/*!
 * maptalks v1.0.0-rc.30
 * LICENSE : BSD-3-Clause
 * (c) 2016-2024 maptalks.org
 */
(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
  (global = global || self, factory(global.maptalks = {}));
}(this, function (exports) { 'use strict';

  var version = "1.0.0-rc.30";

  var GlobalConfig = {
    idleLog: false,
    idleTimeRemaining: 8,
    idleForceTimeThreshold: 100,
    idleTimeout: 1000,
    workerCount: window.MAPTALKS_WORKER_COUNT || 0,
    taskCountPerWorkerMessage: 5
  };

  var INTERNAL_LAYER_PREFIX = '_maptalks__internal_layer_';
  var GEOMETRY_COLLECTION_TYPES = ['MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
  var GEOJSON_TYPES = ['FeatureCollection', 'Feature', 'Point', 'LineString', 'Polygon'].concat(GEOMETRY_COLLECTION_TYPES);
  var RESOURCE_PROPERTIES = ['markerFile', 'polygonPatternFile', 'linePatternFile', 'markerFillPatternFile', 'markerLinePatternFile'];
  var RESOURCE_SIZE_PROPERTIES = [['markerWidth', 'markerHeight'], [], [null, 'lineWidth'], [], [null, 'markerLineWidth']];
  var NUMERICAL_PROPERTIES = {
    'lineWidth': 1,
    'lineOpacity': 1,
    'lineDx': 1,
    'lineDy': 1,
    'polygonOpacity': 1,
    'markerWidth': 1,
    'markerHeight': 1,
    'markerDx': 1,
    'markerDy': 1,
    'markerOpacity': 1,
    'markerFillOpacity': 1,
    'markerLineWidth': 1,
    'markerLineOpacity': 1,
    'textSize': 1,
    'textOpacity': 1,
    'textHaloRadius': 1,
    'textWrapWidth': 1,
    'textLineSpacing': 1,
    'textDx': 1,
    'textDy': 1
  };
  var COLOR_PROPERTIES = ['lineColor', 'polygonFill', 'markerFill', 'markerLineColor', 'textFill'];
  var DEFAULT_TEXT_SIZE = 14;

  function now() {
    return Date.now();
  }
  function extend(dest) {
    for (var i = 1; i < arguments.length; i++) {
      var src = arguments[i];
      for (var k in src) {
        dest[k] = src[k];
      }
    }
    return dest;
  }
  function isNil(obj) {
    return obj == null;
  }
  function isNumber(val) {
    return typeof val === 'number' && !isNaN(val);
  }
  function isInteger(n) {
    return (n | 0) === n;
  }
  function isObject(obj) {
    return typeof obj === 'object' && !!obj;
  }
  function isString(obj) {
    if (isNil(obj)) {
      return false;
    }
    return typeof obj === 'string' || obj.constructor !== null && obj.constructor === String;
  }
  function isFunction(obj) {
    if (isNil(obj)) {
      return false;
    }
    return typeof obj === 'function' || obj.constructor !== null && obj.constructor === Function;
  }
  var hasOwnProperty = Object.prototype.hasOwnProperty;
  function hasOwn(obj, key) {
    return hasOwnProperty.call(obj, key);
  }
  function join(arr, seperator) {
    if (arr.join) {
      return arr.join(seperator || ',');
    } else {
      return Array.prototype.join.call(arr, seperator || ',');
    }
  }
  function isEmpty(object) {
    var property;
    for (property in object) {
      return false;
    }
    return !property;
  }
  var pi = Math.PI / 180;
  function toRadian(d) {
    return d * pi;
  }
  function toDegree(r) {
    return r / pi;
  }

  var IS_NODE = Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]' && !process.versions['electron'] && !process.versions['nw'] && !process.versions['node-webkit'];

  var Browser = {};
  function getDevicePixelRatio() {
    return window.devicePixelRatio || window.screen.deviceXDPI / window.screen.logicalXDPI;
  }
  if (!IS_NODE) {
    var ua = navigator.userAgent.toLowerCase(),
      doc = document.documentElement || {
        style: {}
      },
      ie = ('ActiveXObject' in window),
      webkit = ua.indexOf('webkit') !== -1,
      phantomjs = ua.indexOf('phantom') !== -1,
      android23 = ua.search('android [23]') !== -1,
      chrome = ua.indexOf('chrome') !== -1,
      gecko = ua.indexOf('gecko') !== -1 && !webkit && !window.opera && !ie,
      iosWeixin = /iphone/i.test(ua) && /micromessenger/i.test(ua),
      mobile = typeof orientation !== 'undefined' || ua.indexOf('mobile') !== -1,
      msPointer = !window.PointerEvent && window.MSPointerEvent,
      pointer = window.PointerEvent && navigator.pointerEnabled || msPointer,
      ie3d = ie && 'transition' in doc.style,
      webkit3d = 'WebKitCSSMatrix' in window && 'm11' in new window.WebKitCSSMatrix() && !android23,
      gecko3d = ('MozPerspective' in doc.style),
      opera12 = ('OTransition' in doc.style),
      any3d = (ie3d || webkit3d || gecko3d) && !opera12 && !phantomjs,
      imageBitMap = typeof window !== 'undefined' && isFunction(window.createImageBitmap),
      resizeObserver = typeof window !== 'undefined' && isFunction(window.ResizeObserver),
      btoa = typeof window !== 'undefined' && isFunction(window.btoa),
      proxy = typeof window !== 'undefined' && isFunction(window.Proxy),
      requestIdleCallback$1 = typeof window !== 'undefined' && isFunction(window.requestIdleCallback);
    var chromeVersion = 0;
    if (chrome) {
      chromeVersion = ua.match(/chrome\/([\d.]+)/)[1];
    }
    var touch = !phantomjs && (pointer || 'ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch);
    var webgl = typeof window !== 'undefined' && 'WebGLRenderingContext' in window;
    var devicePixelRatio = getDevicePixelRatio();
    var decodeImageInWorker = false;
    try {
      var offCanvas = new OffscreenCanvas(2, 2);
      offCanvas.getContext('2d');
      decodeImageInWorker = true;
    } catch (err) {
      decodeImageInWorker = false;
    }
    var supportsPassive = false;
    try {
      window.addEventListener('testPassive', function () {}, {
        get passive() {
          supportsPassive = true;
        }
      });
    } catch (e) {}
    Browser = {
      isTest: false,
      ie: ie,
      ielt9: ie && !document.addEventListener,
      edge: 'msLaunchUri' in navigator && !('documentMode' in document),
      webkit: webkit,
      gecko: gecko,
      android: ua.indexOf('android') !== -1,
      android23: android23,
      chrome: chrome,
      chromeVersion: chromeVersion,
      safari: !chrome && ua.indexOf('safari') !== -1,
      phantomjs: phantomjs,
      ie3d: ie3d,
      webkit3d: webkit3d,
      gecko3d: gecko3d,
      opera12: opera12,
      any3d: any3d,
      iosWeixin: iosWeixin,
      mobile: mobile,
      mobileWebkit: mobile && webkit,
      mobileWebkit3d: mobile && webkit3d,
      mobileOpera: mobile && window.opera,
      mobileGecko: mobile && gecko,
      touch: !!touch,
      msPointer: !!msPointer,
      pointer: !!pointer,
      retina: devicePixelRatio > 1,
      devicePixelRatio: devicePixelRatio,
      language: navigator.browserLanguage ? navigator.browserLanguage : navigator.language,
      ie9: ie && document.documentMode === 9,
      ie10: ie && document.documentMode === 10,
      webgl: webgl,
      imageBitMap: imageBitMap,
      resizeObserver: resizeObserver,
      btoa: btoa,
      decodeImageInWorker: decodeImageInWorker,
      monitorDPRChange: true,
      supportsPassive: supportsPassive,
      proxy: proxy,
      requestIdleCallback: requestIdleCallback$1,
      checkDevicePixelRatio: function checkDevicePixelRatio() {
        if (typeof window !== 'undefined' && Browser.monitorDPRChange) {
          var _devicePixelRatio = getDevicePixelRatio();
          var changed = _devicePixelRatio !== Browser.devicePixelRatio;
          if (changed) {
            Browser.devicePixelRatio = _devicePixelRatio;
          }
          return changed;
        }
        return false;
      }
    };
  }
  var Browser$1 = Browser;

  function _defineProperties(target, props) {
    for (var i = 0; i < props.length; i++) {
      var descriptor = props[i];
      descriptor.enumerable = descriptor.enumerable || false;
      descriptor.configurable = true;
      if ("value" in descriptor) descriptor.writable = true;
      Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
    }
  }
  function _createClass(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    Object.defineProperty(Constructor, "prototype", {
      writable: false
    });
    return Constructor;
  }
  function _extends() {
    _extends = Object.assign ? Object.assign.bind() : function (target) {
      for (var i = 1; i < arguments.length; i++) {
        var source = arguments[i];
        for (var key in source) {
          if (Object.prototype.hasOwnProperty.call(source, key)) {
            target[key] = source[key];
          }
        }
      }
      return target;
    };
    return _extends.apply(this, arguments);
  }
  function _inheritsLoose(subClass, superClass) {
    subClass.prototype = Object.create(superClass.prototype);
    subClass.prototype.constructor = subClass;
    _setPrototypeOf(subClass, superClass);
  }
  function _getPrototypeOf(o) {
    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
      return o.__proto__ || Object.getPrototypeOf(o);
    };
    return _getPrototypeOf(o);
  }
  function _setPrototypeOf(o, p) {
    _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
      o.__proto__ = p;
      return o;
    };
    return _setPrototypeOf(o, p);
  }
  function _isNativeReflectConstruct() {
    if (typeof Reflect === "undefined" || !Reflect.construct) return false;
    if (Reflect.construct.sham) return false;
    if (typeof Proxy === "function") return true;
    try {
      Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
      return true;
    } catch (e) {
      return false;
    }
  }
  function _construct(Parent, args, Class) {
    if (_isNativeReflectConstruct()) {
      _construct = Reflect.construct.bind();
    } else {
      _construct = function _construct(Parent, args, Class) {
        var a = [null];
        a.push.apply(a, args);
        var Constructor = Function.bind.apply(Parent, a);
        var instance = new Constructor();
        if (Class) _setPrototypeOf(instance, Class.prototype);
        return instance;
      };
    }
    return _construct.apply(null, arguments);
  }
  function _isNativeFunction(fn) {
    return Function.toString.call(fn).indexOf("[native code]") !== -1;
  }
  function _wrapNativeSuper(Class) {
    var _cache = typeof Map === "function" ? new Map() : undefined;
    _wrapNativeSuper = function _wrapNativeSuper(Class) {
      if (Class === null || !_isNativeFunction(Class)) return Class;
      if (typeof Class !== "function") {
        throw new TypeError("Super expression must either be null or a function");
      }
      if (typeof _cache !== "undefined") {
        if (_cache.has(Class)) return _cache.get(Class);
        _cache.set(Class, Wrapper);
      }
      function Wrapper() {
        return _construct(Class, arguments, _getPrototypeOf(this).constructor);
      }
      Wrapper.prototype = Object.create(Class.prototype, {
        constructor: {
          value: Wrapper,
          enumerable: false,
          writable: true,
          configurable: true
        }
      });
      return _setPrototypeOf(Wrapper, Class);
    };
    return _wrapNativeSuper(Class);
  }
  function _assertThisInitialized(self) {
    if (self === void 0) {
      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }
    return self;
  }
  function _toPrimitive(input, hint) {
    if (typeof input !== "object" || input === null) return input;
    var prim = input[Symbol.toPrimitive];
    if (prim !== undefined) {
      var res = prim.call(input, hint || "default");
      if (typeof res !== "object") return res;
      throw new TypeError("@@toPrimitive must return a primitive value.");
    }
    return (hint === "string" ? String : Number)(input);
  }
  function _toPropertyKey(arg) {
    var key = _toPrimitive(arg, "string");
    return typeof key === "symbol" ? key : String(key);
  }

  var Position = function () {
    function Position(x, y, z) {
      if (!isNil(x) && !isNil(y)) {
        this.x = +x;
        this.y = +y;
        this.z = z;
      } else if (!isNil(x.x) && !isNil(x.y)) {
        this.x = +x.x;
        this.y = +x.y;
        this.z = x.z;
      } else if (Array.isArray(x)) {
        this.x = +x[0];
        this.y = +x[1];
        this.z = x[2];
      }
      if (this._isNaN()) {
        throw new Error('Position is NaN');
      }
    }
    var _proto = Position.prototype;
    _proto.set = function set(x, y, z) {
      this.x = x;
      this.y = y;
      this.z = z || 0;
      return this;
    };
    _proto.abs = function abs() {
      return new this.constructor(Math.abs(this.x), Math.abs(this.y));
    };
    _proto._abs = function _abs() {
      this.x = Math.abs(this.x);
      this.y = Math.abs(this.y);
      return this;
    };
    _proto._round = function _round() {
      this.x = Math.round(this.x);
      this.y = Math.round(this.y);
      return this;
    };
    _proto.round = function round() {
      return new this.constructor(Math.round(this.x), Math.round(this.y));
    };
    _proto._ceil = function _ceil() {
      this.x = Math.ceil(this.x);
      this.y = Math.ceil(this.y);
      return this;
    };
    _proto.ceil = function ceil() {
      return new this.constructor(Math.ceil(this.x), Math.ceil(this.y));
    };
    _proto.distanceTo = function distanceTo(point) {
      var x = point.x - this.x,
        y = point.y - this.y;
      return Math.sqrt(x * x + y * y);
    };
    _proto.mag = function mag() {
      return Math.sqrt(this.x * this.x + this.y * this.y);
    };
    _proto._floor = function _floor() {
      this.x = Math.floor(this.x);
      this.y = Math.floor(this.y);
      return this;
    };
    _proto.floor = function floor() {
      return new this.constructor(Math.floor(this.x), Math.floor(this.y));
    };
    _proto.copy = function copy() {
      return new this.constructor(this.x, this.y, this.z);
    };
    _proto._add = function _add(x, y) {
      if (!isNil(x.x)) {
        this.x += x.x;
        this.y += x.y;
      } else if (!isNil(x[0])) {
        this.x += x[0];
        this.y += x[1];
      } else {
        this.x += x;
        this.y += y;
      }
      return this;
    };
    _proto.add = function add(x, y) {
      var nx, ny;
      if (!isNil(x.x)) {
        nx = this.x + x.x;
        ny = this.y + x.y;
      } else if (!isNil(x[0])) {
        nx = this.x + x[0];
        ny = this.y + x[1];
      } else {
        nx = this.x + x;
        ny = this.y + y;
      }
      return new this.constructor(nx, ny);
    };
    _proto._sub = function _sub(x, y) {
      if (!isNil(x.x)) {
        this.x -= x.x;
        this.y -= x.y;
      } else if (!isNil(x[0])) {
        this.x -= x[0];
        this.y -= x[1];
      } else {
        this.x -= x;
        this.y -= y;
      }
      return this;
    };
    _proto._substract = function _substract() {
      return this._sub.apply(this, arguments);
    };
    _proto.sub = function sub(x, y) {
      var nx, ny;
      if (!isNil(x.x)) {
        nx = this.x - x.x;
        ny = this.y - x.y;
      } else if (!isNil(x[0])) {
        nx = this.x - x[0];
        ny = this.y - x[1];
      } else {
        nx = this.x - x;
        ny = this.y - y;
      }
      return new this.constructor(nx, ny);
    };
    _proto.substract = function substract() {
      return this.sub.apply(this, arguments);
    };
    _proto.multi = function multi(ratio) {
      return new this.constructor(this.x * ratio, this.y * ratio);
    };
    _proto._multi = function _multi(ratio) {
      this.x *= ratio;
      this.y *= ratio;
      return this;
    };
    _proto.div = function div(n) {
      return this.multi(1 / n);
    };
    _proto._div = function _div(n) {
      return this._multi(1 / n);
    };
    _proto.equals = function equals(c) {
      if (!(c instanceof this.constructor)) {
        return false;
      }
      return this.x === c.x && this.y === c.y && this.z === c.z;
    };
    _proto._isNaN = function _isNaN() {
      return isNaN(this.x) || isNaN(this.y) || isNumber(this.z) && isNaN(this.z);
    };
    _proto.isZero = function isZero() {
      return this.x === 0 && this.y === 0;
    };
    _proto.toArray = function toArray() {
      if (isNumber(this.z)) {
        return [this.x, this.y, this.z];
      }
      return [this.x, this.y];
    };
    _proto.toFixed = function toFixed(n) {
      return new this.constructor(this.x.toFixed(n), this.y.toFixed(n), isNumber(this.z) ? this.z.toFixed : undefined);
    };
    _proto.toJSON = function toJSON() {
      var json = {
        x: this.x,
        y: this.y
      };
      if (isNumber(this.z)) {
        json.z = this.z;
      }
      return json;
    };
    return Position;
  }();

  var Point = function (_Position) {
    _inheritsLoose(Point, _Position);
    function Point() {
      return _Position.apply(this, arguments) || this;
    }
    var _proto = Point.prototype;
    _proto.closeTo = function closeTo(p, delta) {
      if (!delta) {
        delta = 0;
      }
      return this.x >= p.x - delta && this.x <= p.x + delta && this.y >= p.y - delta && this.y <= p.y + delta;
    };
    _proto.mag = function mag() {
      return Math.sqrt(this.x * this.x + this.y * this.y);
    };
    _proto.unit = function unit() {
      return this.copy()._unit();
    };
    _proto._unit = function _unit() {
      this._div(this.mag());
      return this;
    };
    _proto.perp = function perp() {
      return this.copy()._perp();
    };
    _proto._perp = function _perp() {
      var y = this.y;
      this.y = this.x;
      this.x = -y;
      return this;
    };
    _proto.angleWith = function angleWith(b) {
      return this.angleWithSep(b.x, b.y);
    };
    _proto.angleWithSep = function angleWithSep(x, y) {
      return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
    };
    _proto._rotate = function _rotate(angle) {
      var cos = Math.cos(angle),
        sin = Math.sin(angle),
        x = cos * this.x - sin * this.y,
        y = sin * this.x + cos * this.y;
      this.x = x;
      this.y = y;
      return this;
    };
    _proto.rotate = function rotate(a) {
      return this.copy()._rotate(a);
    };
    return Point;
  }(Position);

  var requestAnimFrame, cancelAnimFrame;
  (function () {
    if (IS_NODE) {
      requestAnimFrame = function requestAnimFrame(fn) {
        return setTimeout(fn, 16);
      };
      cancelAnimFrame = clearTimeout;
      return;
    }
    var requestFn, cancelFn;
    var timeToCall = 1000 / 30;
    function timeoutDefer(fn) {
      return setTimeout(fn, timeToCall);
    }
    function getPrefixed(name) {
      return window['webkit' + name] || window['moz' + name] || window['ms' + name];
    }
    if (typeof window != 'undefined') {
      requestFn = window['requestAnimationFrame'] || getPrefixed('RequestAnimationFrame') || timeoutDefer;
      cancelFn = window['cancelAnimationFrame'] || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function (id) {
        window.clearTimeout(id);
      };
    } else {
      requestFn = timeoutDefer;
      cancelFn = clearTimeout;
    }
    requestAnimFrame = function requestAnimFrame(fn) {
      return requestFn(fn);
    };
    cancelAnimFrame = function cancelAnimFrame(id) {
      if (id) {
        cancelFn(id);
      }
    };
  })();
  function isSVG(url) {
    var prefix = 'data:image/svg+xml';
    if (url.length > 4 && url.slice(-4) === '.svg') {
      return 1;
    } else if (url.slice(0, prefix.length) === prefix) {
      return 2;
    }
    return 0;
  }
  function loadImage(img, imgDesc) {
    if (IS_NODE && loadImage.node) {
      loadImage.node(img, imgDesc);
      return;
    }
    img.src = imgDesc[0];
  }
  var uid = 0;
  function UID() {
    return uid++;
  }
  var GUID = UID;
  function parseJSON(str) {
    if (!str || !isString(str)) {
      return str;
    }
    return JSON.parse(str);
  }
  function pushIn(dest) {
    for (var i = 1; i < arguments.length; i++) {
      var src = arguments[i];
      if (src && src.length) {
        for (var ii = 0, ll = src.length; ii < ll; ii++) {
          dest.push(src[ii]);
        }
      }
    }
    return dest.length;
  }
  function removeFromArray(obj, array) {
    var i = array.indexOf(obj);
    if (i > -1) {
      array.splice(i, 1);
    }
  }
  function forEachCoord(arr, fn, context) {
    if (!Array.isArray(arr)) {
      return context ? fn.call(context, arr) : fn(arr);
    }
    var result = [];
    var p, pp;
    for (var i = 0, len = arr.length; i < len; i++) {
      p = arr[i];
      if (isNil(p)) {
        result.push(null);
        continue;
      }
      if (Array.isArray(p)) {
        result.push(forEachCoord(p, fn, context));
      } else {
        pp = context ? fn.call(context, p) : fn(p);
        result.push(pp);
      }
    }
    return result;
  }
  function getValueOrDefault(v, d) {
    return v === undefined ? d : v;
  }
  function sign(x) {
    if (Math.sign) {
      return Math.sign(x);
    }
    x = +x;
    if (x === 0 || isNaN(x)) {
      return Number(x);
    }
    return x > 0 ? 1 : -1;
  }
  function log2(x) {
    if (Math.log2) {
      return Math.log2(x);
    }
    var v = Math.log(x) * Math.LOG2E;
    var rounded = Math.round(v);
    if (Math.abs(rounded - v) < 1E-14) {
      return rounded;
    } else {
      return v;
    }
  }
  function interpolate(a, b, t) {
    return a * (1 - t) + b * t;
  }
  function wrap(n, min, max) {
    if (n === max || n === min) {
      return n;
    }
    var d = max - min;
    var w = ((n - min) % d + d) % d + min;
    return w;
  }
  function clamp(n, min, max) {
    return Math.min(max, Math.max(min, n));
  }
  function isArrayHasData(obj) {
    return Array.isArray(obj) && obj.length > 0;
  }
  var urlPattern = /^([a-z][a-z\d+\-.]*:)?\/\//i;
  function isURL(url) {
    return urlPattern.test(url);
  }
  var cssUrlReWithQuote = /^url\((['"])(.+)\1\)$/i;
  var cssUrlRe = /^url\(([^'"].*[^'"])\)$/i;
  function isCssUrl(str) {
    if (!isString(str)) {
      return 0;
    }
    if (cssUrlRe.test(str)) {
      return 1;
    }
    if (cssUrlReWithQuote.test(str)) {
      return 2;
    }
    return 3;
  }
  function extractCssUrl(str) {
    var test = isCssUrl(str);
    var matches;
    if (test === 3) {
      return str;
    } else if (test === 1) {
      matches = cssUrlRe.exec(str);
      return matches[1];
    } else if (test === 2) {
      matches = cssUrlReWithQuote.exec(str);
      return matches[2];
    } else {
      return str;
    }
  }
  var b64chrs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  function btoa$1(input) {
    if (Browser$1.btoa) {
      return window.btoa(input);
    }
    var str = String(input);
    var output = '';
    for (var block, charCode, idx = 0, map = b64chrs; str.charAt(idx | 0) || (map = '=', idx % 1); output += map.charAt(63 & block >> 8 - idx % 1 * 8)) {
      charCode = str.charCodeAt(idx += 3 / 4);
      if (charCode > 0xFF) {
        throw new Error('\'btoa\' failed: The string to be encoded contains characters outside of the Latin1 range.');
      }
      block = block << 8 | charCode;
    }
    return output;
  }
  function b64toBlob(b64Data, contentType) {
    var byteCharacters = atob(b64Data);
    var arraybuffer = new ArrayBuffer(byteCharacters.length);
    var view = new Uint8Array(arraybuffer);
    for (var i = 0; i < byteCharacters.length; i++) {
      view[i] = byteCharacters.charCodeAt(i) & 0xff;
    }
    var blob = new Blob([arraybuffer], {
      type: contentType
    });
    return blob;
  }
  function computeDegree(x0, y0, x1, y1) {
    var dx = x1 - x0;
    var dy = y1 - y0;
    return Math.atan2(dy, dx);
  }
  var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7';
  function equalMapView(obj1, obj2) {
    if (!obj1 && !obj2) {
      return true;
    } else if (!obj1 || !obj2) {
      return false;
    }
    for (var p in obj1) {
      if (p === 'center') {
        if (!obj2[p] || !approx(obj1[p][0], obj2[p][0]) || !approx(obj1[p][1], obj2[p][1])) {
          return false;
        }
      } else if (obj1[p] !== obj2[p]) {
        return false;
      }
    }
    return true;
  }
  function approx(val, expected, delta) {
    if (delta == null) {
      delta = 1e-6;
    }
    return val >= expected - delta && val <= expected + delta;
  }
  function flash(interval, count, cb, context) {
    if (!interval) {
      interval = 100;
    }
    if (!count) {
      count = 4;
    }
    var me = this;
    var initVisible = this.isVisible();
    count *= 2;
    if (this._flashTimeout) {
      clearTimeout(this._flashTimeout);
    }
    function flashGeo() {
      if (count === 0) {
        if (initVisible) {
          me.show();
        } else {
          me.hide();
        }
        if (cb) {
          if (context) {
            cb.call(context);
          } else {
            cb();
          }
        }
        return;
      }
      if (count % 2 === 0) {
        me.hide();
      } else {
        me.show();
      }
      count--;
      me._flashTimeout = setTimeout(flashGeo, interval);
    }
    this._flashTimeout = setTimeout(flashGeo, interval);
    return this;
  }
  function _defaults$1(obj, defaults) {
    var keys = Object.getOwnPropertyNames(defaults);
    for (var i = 0; i < keys.length; i++) {
      var key = keys[i];
      var value = Object.getOwnPropertyDescriptor(defaults, key);
      if (value && value.configurable && obj[key] === undefined) {
        Object.defineProperty(obj, key, value);
      }
    }
    return obj;
  }
  function getPointsResultPts(points, ptKey) {
    if (points === void 0) {
      points = [];
    }
    if (ptKey === void 0) {
      ptKey = '_pt';
    }
    var resultPoints = [];
    for (var i = 0, len = points.length; i < len; i++) {
      var point = points[i];
      if (!point) {
        resultPoints.push(null);
        continue;
      }
      if (!point[ptKey]) {
        point[ptKey] = new Point(0, 0);
      }
      var pt = point[ptKey];
      pt.x = 0;
      pt.y = 0;
      resultPoints.push(pt);
    }
    return resultPoints;
  }
  function getImageBitMap(data, cb) {
    cb(data.data);
  }
  function getAbsoluteURL(url) {
    if (url && url.indexOf('http://') === 0 || url.indexOf('https://') === 0) {
      return url;
    }
    var a = document.createElement('a');
    a.href = url;
    url = a.href;
    a = null;
    return url;
  }
  var CANVAS_SIZE_TEMP = {
    cssWidth: '1px',
    cssHeight: '1px',
    width: 1,
    height: 1
  };
  function calCanvasSize(size, devicePixelRatio) {
    if (devicePixelRatio === void 0) {
      devicePixelRatio = 1;
    }
    var width = size.width,
      height = size.height;
    CANVAS_SIZE_TEMP.cssWidth = width + 'px';
    CANVAS_SIZE_TEMP.cssHeight = height + 'px';
    CANVAS_SIZE_TEMP.width = Math.round(width * devicePixelRatio);
    CANVAS_SIZE_TEMP.height = Math.round(height * devicePixelRatio);
    return CANVAS_SIZE_TEMP;
  }

  var canvas;
  var OPTIONS = {
    width: 100,
    height: 10
  };
  function getCanvas() {
    if (!canvas) {
      var width = OPTIONS.width,
        height = OPTIONS.height;
      if (OffscreenCanvas) {
        canvas = new OffscreenCanvas(width, height);
      } else {
        canvas = document.createElement('canvas');
        canvas.width = width;
        canvas.height = height;
      }
    }
    return canvas;
  }
  var ColorIn = function () {
    function ColorIn(colors, options) {
      if (options === void 0) {
        options = {};
      }
      if (!Array.isArray(colors)) {
        console.error('colors is not array');
        return;
      }
      if (colors.length < 2) {
        console.error('colors.length should >1');
        return;
      }
      this.colors = colors;
      var min = Infinity,
        max = -Infinity;
      for (var i = 0, len = colors.length; i < len; i++) {
        var value = colors[i][0];
        min = Math.min(value, min);
        max = Math.max(value, max);
      }
      this.min = min;
      this.max = max;
      this.valueOffset = this.max - this.min;
      this.options = Object.assign({}, OPTIONS, options);
      this._initImgData();
    }
    var _proto = ColorIn.prototype;
    _proto.getImageData = function getImageData() {
      return this.imgData;
    };
    _proto._initImgData = function _initImgData() {
      var canvas = getCanvas();
      var _this$options = this.options,
        width = _this$options.width,
        height = _this$options.height;
      canvas.width = width;
      canvas.height = height;
      var ctx = canvas.getContext('2d');
      ctx.clearRect(0, 0, canvas.width, canvas.height);
      var gradient = ctx.createLinearGradient(0, 0, canvas.width, 0);
      var colors = this.colors,
        valueOffset = this.valueOffset;
      for (var i = 0, len = colors.length; i < len; i++) {
        var _colors$i = colors[i],
          stop = _colors$i[0],
          color = _colors$i[1];
        var s = (stop - this.min) / valueOffset;
        gradient.addColorStop(s, color);
      }
      ctx.fillStyle = gradient;
      ctx.fillRect(0, 0, canvas.width, canvas.height);
      this.imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
    };
    _proto.getColor = function getColor(stop) {
      stop = Math.max(this.min, stop);
      stop = Math.min(stop, this.max);
      var s = (stop - this.min) / this.valueOffset;
      var x = Math.round(s * this.imgData.width);
      x = Math.min(x, this.imgData.width - 1);
      var idx = x * 4;
      var r = this.imgData.data[idx];
      var g = this.imgData.data[idx + 1];
      var b = this.imgData.data[idx + 2];
      var a = this.imgData.data[idx + 3];
      return [r, g, b, a];
    };
    return ColorIn;
  }();

  var isMapSupported = typeof Map === 'function';
  var colorInCache;
  if (isMapSupported) {
    colorInCache = new Map();
  }
  function createFunction(parameters, defaultType) {
    var fun;
    var isFeatureConstant, isZoomConstant;
    if (!isFunctionDefinition(parameters)) {
      fun = function fun() {
        return parameters;
      };
      isFeatureConstant = true;
      isZoomConstant = true;
    } else {
      var zoomAndFeatureDependent = parameters.stops && typeof parameters.stops[0][0] === 'object';
      var featureDependent = zoomAndFeatureDependent || parameters.property !== undefined;
      var zoomDependent = zoomAndFeatureDependent || !featureDependent;
      var type = parameters.type || defaultType || 'exponential';
      var innerFun;
      if (type === 'exponential') {
        innerFun = evaluateExponentialFunction;
      } else if (type === 'interval') {
        innerFun = evaluateIntervalFunction;
      } else if (type === 'categorical') {
        innerFun = evaluateCategoricalFunction;
      } else if (type === 'identity') {
        innerFun = evaluateIdentityFunction;
      } else if (type === 'color-interpolate') {
        innerFun = evaluateColorInterpolateFunction;
      } else {
        throw new Error('Unknown function type "' + type + '"');
      }
      if (zoomAndFeatureDependent) {
        var featureFunctions = {};
        var featureFunctionStops = [];
        for (var s = 0; s < parameters.stops.length; s++) {
          var stop = parameters.stops[s];
          if (featureFunctions[stop[0].zoom] === undefined) {
            featureFunctions[stop[0].zoom] = {
              zoom: stop[0].zoom,
              type: parameters.type,
              property: parameters.property,
              default: parameters.default,
              stops: []
            };
          }
          featureFunctions[stop[0].zoom].stops.push([stop[0].value, stop[1]]);
        }
        for (var z in featureFunctions) {
          featureFunctionStops.push([featureFunctions[z].zoom, createFunction(featureFunctions[z])]);
        }
        fun = function fun(zoom, feature) {
          var value = evaluateExponentialFunction({
            stops: featureFunctionStops,
            base: parameters.base
          }, zoom)(zoom, feature);
          return typeof value === 'function' ? value(zoom, feature) : value;
        };
        isFeatureConstant = false;
        isZoomConstant = false;
      } else if (zoomDependent) {
        fun = function fun(zoom) {
          var value = innerFun(parameters, zoom);
          return typeof value === 'function' ? value(zoom) : value;
        };
        isFeatureConstant = true;
        isZoomConstant = false;
      } else {
        fun = function fun(zoom, feature) {
          var value = innerFun(parameters, feature ? feature[parameters.property] : null);
          return typeof value === 'function' ? value(zoom, feature) : value;
        };
        isFeatureConstant = false;
        isZoomConstant = true;
      }
    }
    fun.isZoomConstant = isZoomConstant;
    fun.isFeatureConstant = isFeatureConstant;
    return fun;
  }
  function coalesce(a, b, c) {
    if (a !== undefined) return a;
    if (b !== undefined) return b;
    if (c !== undefined) return c;
    return null;
  }
  function evaluateCategoricalFunction(parameters, input) {
    for (var i = 0; i < parameters.stops.length; i++) {
      if (input === parameters.stops[i][0]) {
        return parameters.stops[i][1];
      }
    }
    return parameters.default;
  }
  function evaluateIntervalFunction(parameters, input) {
    for (var i = 0; i < parameters.stops.length; i++) {
      if (input < parameters.stops[i][0]) break;
    }
    return parameters.stops[Math.max(i - 1, 0)][1];
  }
  function evaluateExponentialFunction(parameters, input) {
    var base = parameters.base !== undefined ? parameters.base : 1;
    var i = 0;
    while (true) {
      if (i >= parameters.stops.length) break;else if (input <= parameters.stops[i][0]) break;else i++;
    }
    if (i === 0) {
      return parameters.stops[i][1];
    } else if (i === parameters.stops.length) {
      return parameters.stops[i - 1][1];
    } else {
      return interpolate$1(input, base, parameters.stops[i - 1][0], parameters.stops[i][0], parameters.stops[i - 1][1], parameters.stops[i][1]);
    }
  }
  var COLORIN_OPTIONS = {
    width: 100,
    height: 1
  };
  function evaluateColorInterpolateFunction(parameters, input) {
    var stops = parameters.stops;
    if (stops && stops.length > 1) {
      var colorIn;
      if (colorInCache) {
        var key = JSON.stringify(stops);
        if (!colorInCache.has(key)) {
          var _colorIn = new ColorIn(stops, COLORIN_OPTIONS);
          colorInCache.set(key, _colorIn);
        }
        colorIn = colorInCache.get(key);
      } else {
        colorIn = new ColorIn(stops, COLORIN_OPTIONS);
      }
      var _colorIn$getColor = colorIn.getColor(input),
        r = _colorIn$getColor[0],
        g = _colorIn$getColor[1],
        b = _colorIn$getColor[2],
        a = _colorIn$getColor[3];
      return [r / 255, g / 255, b / 255, a / 255];
    } else if (stops && stops.length === 1) {
      return stops[0][1];
    }
    return null;
  }
  function evaluateIdentityFunction(parameters, input) {
    return coalesce(input, parameters.default);
  }
  function interpolate$1(input, base, inputLower, inputUpper, outputLower, outputUpper) {
    if (typeof outputLower === 'function') {
      return function () {
        var evaluatedLower = outputLower.apply(undefined, arguments);
        var evaluatedUpper = outputUpper.apply(undefined, arguments);
        return interpolate$1(input, base, inputLower, inputUpper, evaluatedLower, evaluatedUpper);
      };
    } else if (outputLower.length) {
      return interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper);
    } else {
      return interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper);
    }
  }
  function interpolateNumber(input, base, inputLower, inputUpper, outputLower, outputUpper) {
    var difference = inputUpper - inputLower;
    var progress = input - inputLower;
    var ratio;
    if (base === 1) {
      ratio = progress / difference;
    } else {
      ratio = (Math.pow(base, progress) - 1) / (Math.pow(base, difference) - 1);
    }
    return outputLower * (1 - ratio) + outputUpper * ratio;
  }
  function interpolateArray(input, base, inputLower, inputUpper, outputLower, outputUpper) {
    var output = [];
    for (var i = 0; i < outputLower.length; i++) {
      output[i] = interpolateNumber(input, base, inputLower, inputUpper, outputLower[i], outputUpper[i]);
    }
    return output;
  }
  function isFunctionDefinition(obj) {
    return obj && typeof obj === 'object' && (obj.stops || obj.property && obj.type === 'identity');
  }
  function hasFunctionDefinition(obj) {
    for (var p in obj) {
      if (isFunctionDefinition(obj[p])) {
        return true;
      }
    }
    return false;
  }
  function interpolated(parameters) {
    return createFunction1(parameters, 'exponential');
  }
  function piecewiseConstant(parameters) {
    return createFunction1(parameters, 'interval');
  }
  function loadFunctionTypes(obj, argFn) {
    if (!obj) {
      return null;
    }
    var hit = false;
    if (Array.isArray(obj)) {
      var multResult = [],
        loaded;
      for (var i = 0; i < obj.length; i++) {
        loaded = loadFunctionTypes(obj[i], argFn);
        if (!loaded) {
          multResult.push(obj[i]);
        } else {
          multResult.push(loaded);
          hit = true;
        }
      }
      return hit ? multResult : obj;
    }
    var result = {
        '__fn_types_loaded': true
      },
      props = [],
      p;
    for (p in obj) {
      if (obj.hasOwnProperty(p)) {
        props.push(p);
      }
    }
    var buildFn = function buildFn(p) {
      Object.defineProperty(result, p, {
        get: function get() {
          if (!this['__fn_' + p]) {
            this['__fn_' + p] = interpolated(this['_' + p]);
          }
          return this['__fn_' + p].apply(this, argFn());
        },
        set: function set(v) {
          this['_' + p] = v;
        },
        configurable: true,
        enumerable: true
      });
    };
    for (var _i = 0, len = props.length; _i < len; _i++) {
      p = props[_i];
      if (isFunctionDefinition(obj[p])) {
        hit = true;
        result['_' + p] = obj[p];
        buildFn(p);
      } else {
        result[p] = obj[p];
      }
    }
    return hit ? result : obj;
  }
  function getFunctionTypeResources(t) {
    if (!t || !t.stops) {
      return [];
    }
    var res = [];
    for (var i = 0, l = t.stops.length; i < l; i++) {
      res.push(t.stops[i][1]);
    }
    return res;
  }
  function createFunction1(parameters, defaultType) {
    if (!isFunctionDefinition(parameters)) {
      return function () {
        return parameters;
      };
    }
    parameters = JSON.parse(JSON.stringify(parameters));
    var isZoomConstant = true;
    var isFeatureConstant = true;
    var stops = parameters.stops;
    if (stops) {
      for (var i = 0; i < stops.length; i++) {
        if (isFunctionDefinition(stops[i][1])) {
          var _fn = createFunction1(stops[i][1], defaultType);
          isZoomConstant = isZoomConstant && _fn.isZoomConstant;
          isFeatureConstant = isFeatureConstant && _fn.isFeatureConstant;
          stops[i] = [stops[i][0], _fn];
        }
      }
    }
    var fn = createFunction(parameters, defaultType);
    fn.isZoomConstant = isZoomConstant && fn.isZoomConstant;
    fn.isFeatureConstant = isFeatureConstant && fn.isFeatureConstant;
    return fn;
  }

  var types = ['Unknown', 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon', 'GeometryCollection'];
  function isObject$1(obj) {
    return typeof obj === 'object' && !!obj;
  }
  function createFilter(filter) {
    return new Function('f', "var p = (f && f.properties || {}); return " + compile(filter));
  }
  function isFeatureFilter(filter) {
    if (filter === true || filter === false) {
      return true;
    }
    if (!Array.isArray(filter) || filter.length === 0) {
      return false;
    }
    switch (filter[0]) {
      case 'has':
      case '!has':
        return filter.length === 2 && (typeof filter[1] === 'string' || filter[1].property && filter[1].op);
      case 'in':
      case '!in':
        return filter.length >= 2 && (typeof filter[1] === 'string' || filter[1].property && filter[1].op);
      case '==':
      case '!=':
      case '>':
      case '>=':
      case '<':
      case '<=':
        return filter.length === 3 && (typeof filter[1] === 'string' || filter[1].property && filter[1].op);
      case 'none':
      case 'any':
      case 'all':
        for (var _iterator = filter.slice(1), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
          var _ref;
          if (_isArray) {
            if (_i >= _iterator.length) break;
            _ref = _iterator[_i++];
          } else {
            _i = _iterator.next();
            if (_i.done) break;
            _ref = _i.value;
          }
          var f = _ref;
          if (!isFeatureFilter(f) && typeof f !== 'boolean') {
            return false;
          }
        }
        return true;
      case 'contains':
        return true;
      default:
        return false;
    }
  }
  function compile(filter) {
    if (!filter) return 'true';
    var op = filter[0];
    if (filter.length <= 1) return op === 'any' ? 'false' : 'true';
    var str = op === '==' ? compileComparisonOp(filter[1], filter[2], '===', false) : op === '!=' ? compileComparisonOp(filter[1], filter[2], '!==', false) : op === '<' || op === '>' || op === '<=' || op === '>=' ? compileComparisonOp(filter[1], filter[2], op, true) : op === 'any' ? compileLogicalOp(filter.slice(1), '||') : op === 'all' ? compileLogicalOp(filter.slice(1), '&&') : op === 'none' ? compileNegation(compileLogicalOp(filter.slice(1), '||')) : op === 'in' ? compileInOp(filter[1], filter.slice(2)) : op === '!in' ? compileNegation(compileInOp(filter[1], filter.slice(2))) : op === 'has' ? compileHasOp(filter[1]) : op === '!has' ? compileNegation(compileHasOp(filter[1])) : op === 'contains' ? compileContains(filter[1], filter[2], filter[3]) : 'true';
    return "(" + str + ")";
  }
  function compileFunction(propertyObj, value, op, checkType) {
    var property = propertyObj.property,
      funName = propertyObj.op;
    var left = compilePropertyReference(property);
    if (funName === 'length') {
      left = "((" + left + "+='').length)";
    } else {
      console.error("not support " + funName + " op");
      return 'false';
    }
    return getComparisonCode(left, property, value, op, checkType);
  }
  function compileContains(property, str, index) {
    var prop = compilePropertyReference(property);
    if (index !== undefined) {
      return "(" + prop + " + '').indexOf(\"" + str + "\") === " + index;
    } else {
      return "(" + prop + " + '').indexOf(\"" + str + "\") >= 0";
    }
  }
  function compilePropertyReference(property) {
    return property[0] === '$' ? 'f.' + property.substring(1) : 'p[' + JSON.stringify(property) + ']';
  }
  function compileComparisonOp(property, value, op, checkType) {
    if (isObject$1(property) && property.op) {
      return compileFunction(property, value, op, checkType);
    }
    var left = compilePropertyReference(property);
    return getComparisonCode(left, property, value, op, checkType);
  }
  function getComparisonCode(left, property, value, op, checkType) {
    var right = property === '$type' ? types.indexOf(value) : JSON.stringify(value);
    return (checkType ? "typeof " + left + "=== typeof " + right + "&&" : '') + left + op + right;
  }
  function compileLogicalOp(expressions, op) {
    return expressions.map(compile).join(op);
  }
  function compileInOp(property, values) {
    if (property === '$type') values = values.map(function (value) {
      return types.indexOf(value);
    });
    var left = JSON.stringify(values.sort(compare));
    var right = compilePropertyReference(property);
    if (values.length <= 200) return left + ".indexOf(" + right + ") !== -1";
    return "function(v, a, i, j) {\n        while (i <= j) { var m = (i + j) >> 1;\n            if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\n        }\n    return false; }(" + right + ", " + left + ",0," + (values.length - 1) + ")";
  }
  function compileHasOp(property) {
    return property === '$id' ? '"id" in f' : JSON.stringify(property) + " in p";
  }
  function compileNegation(expression) {
    return "!(" + expression + ")";
  }
  function compare(a, b) {
    return a < b ? -1 : a > b ? 1 : 0;
  }
  function getFilterFeature(geometry) {
    var json = geometry._toJSON(),
      g = json['feature'];
    g['type'] = types.indexOf(g['geometry']['type']);
    g['subType'] = json['subType'];
    return g;
  }
  function compileStyle(styles) {
    if (!Array.isArray(styles)) {
      return compileStyle([styles]);
    }
    var compiled = [];
    for (var i = 0; i < styles.length; i++) {
      var filter = void 0;
      if (styles[i]['filter'] === true) {
        filter = function filter() {
          return true;
        };
      } else {
        filter = createFilter(styles[i]['filter']);
      }
      compiled.push(extend$1({}, styles[i], {
        filter: filter
      }));
    }
    return compiled;
  }
  function extend$1(dest) {
    for (var i = 1; i < arguments.length; i++) {
      var src = arguments[i];
      for (var k in src) {
        dest[k] = src[k];
      }
    }
    return dest;
  }

  var arr = [],
    prop = {};
  function loadGeoSymbol(symbol, geo) {
    return loadFunctionTypes(symbol, function () {
      var map = geo.getMap();
      return set$1(arr, map ? map.getZoom() : 12, extend({}, geo.getProperties(), setProp(prop, map && map.getBearing() || 0, map && map.getPitch() || 0, map ? map.getZoom() : 10)));
    });
  }
  function set$1(arr, a0, a1) {
    arr[0] = a0;
    arr[1] = a1;
    return arr;
  }
  function setProp(prop, b, p, z) {
    prop['{bearing}'] = b;
    prop['{pitch}'] = p;
    prop['{zoom}'] = z;
    return prop;
  }

  var index = /*#__PURE__*/Object.freeze({
    loadGeoSymbol: loadGeoSymbol,
    createFilter: createFilter,
    isFeatureFilter: isFeatureFilter,
    getFilterFeature: getFilterFeature,
    compileStyle: compileStyle,
    isFunctionDefinition: isFunctionDefinition,
    hasFunctionDefinition: hasFunctionDefinition,
    interpolated: interpolated,
    piecewiseConstant: piecewiseConstant,
    loadFunctionTypes: loadFunctionTypes,
    getFunctionTypeResources: getFunctionTypeResources
  });

  function translateToSVGStyles(s) {
    var result = {
      'stroke': {
        'stroke': s['markerLineColor'],
        'stroke-width': s['markerLineWidth'],
        'stroke-opacity': s['markerLineOpacity'],
        'stroke-dasharray': null,
        'stroke-linecap': 'butt',
        'stroke-linejoin': 'round'
      },
      'fill': {
        'fill': s['markerFill'],
        'fill-opacity': s['markerFillOpacity']
      }
    };
    if (result['stroke']['stroke-width'] === 0) {
      result['stroke']['stroke-opacity'] = 0;
    }
    return result;
  }
  function getMarkerPathBase64(symbol, width, height) {
    if (!symbol['markerPath']) {
      return null;
    }
    var op = 1;
    var styles = translateToSVGStyles(symbol);
    if (isNumber(symbol['markerOpacity'])) {
      op = symbol['markerOpacity'];
    }
    if (isNumber(symbol['opacity'])) {
      op *= symbol['opacity'];
    }
    var svgStyles = {};
    if (styles) {
      for (var p in styles['stroke']) {
        if (styles['stroke'].hasOwnProperty(p)) {
          if (!isNil(styles['stroke'][p])) {
            svgStyles[p] = styles['stroke'][p];
          }
        }
      }
      for (var _p in styles['fill']) {
        if (styles['fill'].hasOwnProperty(_p)) {
          if (!isNil(styles['fill'][_p])) {
            svgStyles[_p] = styles['fill'][_p];
          }
        }
      }
    }
    var pathes = Array.isArray(symbol['markerPath']) ? symbol['markerPath'] : [symbol['markerPath']];
    var path;
    var pathesToRender = [];
    for (var i = 0; i < pathes.length; i++) {
      path = isString(pathes[i]) ? {
        'path': pathes[i]
      } : pathes[i];
      path = extend({}, path, svgStyles);
      path['d'] = path['path'];
      delete path['path'];
      pathesToRender.push(path);
    }
    var svg = ['<svg version="1.1"', 'xmlns="http://www.w3.org/2000/svg"'];
    if (op < 1) {
      svg.push('opacity="' + op + '"');
    }
    if (symbol['markerPathWidth'] && symbol['markerPathHeight']) {
      svg.push('viewBox="0 0 ' + symbol['markerPathWidth'] + ' ' + symbol['markerPathHeight'] + '"');
    }
    svg.push('preserveAspectRatio="none"');
    if (width) {
      svg.push('width="' + width + '"');
    }
    if (height) {
      svg.push('height="' + height + '"');
    }
    svg.push('><defs></defs>');
    for (var _i = 0; _i < pathesToRender.length; _i++) {
      var strPath = '<path ';
      for (var _p2 in pathesToRender[_i]) {
        if (pathesToRender[_i].hasOwnProperty(_p2)) {
          strPath += ' ' + _p2 + '="' + pathesToRender[_i][_p2] + '"';
        }
      }
      strPath += '></path>';
      svg.push(strPath);
    }
    svg.push('</svg>');
    var b64 = 'data:image/svg+xml;base64,' + btoa$1(svg.join(' '));
    return b64;
  }
  function getExternalResources(symbol, toAbsolute) {
    if (!symbol) {
      return [];
    }
    var symbols = symbol;
    if (!Array.isArray(symbol)) {
      symbols = [symbol];
    }
    var resources = [];
    var props = RESOURCE_PROPERTIES;
    var res, resSizeProp;
    var w, h;
    for (var i = symbols.length - 1; i >= 0; i--) {
      symbol = symbols[i];
      if (!symbol) {
        continue;
      }
      if (toAbsolute) {
        symbol = convertResourceUrl(symbol);
      }
      for (var ii = 0; ii < props.length; ii++) {
        res = symbol[props[ii]];
        if (isFunctionDefinition(res)) {
          res = getFunctionTypeResources(res);
        }
        if (!res) {
          continue;
        }
        if (!Array.isArray(res)) {
          res = [res];
        }
        for (var iii = 0; iii < res.length; iii++) {
          if (res[iii].slice(0, 4) === 'url(') {
            res[iii] = extractCssUrl(res[iii]);
          }
          resSizeProp = RESOURCE_SIZE_PROPERTIES[ii];
          resources.push([res[iii], symbol[resSizeProp[0]], symbol[resSizeProp[1]]]);
        }
      }
      if (symbol['markerType'] === 'path' && symbol['markerPath']) {
        w = isFunctionDefinition(symbol['markerWidth']) ? 200 : symbol['markerWidth'];
        h = isFunctionDefinition(symbol['markerHeight']) ? 200 : symbol['markerHeight'];
        if (isFunctionDefinition(symbol['markerPath'])) {
          res = getFunctionTypeResources(symbol['markerPath']);
          var path = symbol['markerPath'];
          for (var _iii = 0; _iii < res.length; _iii++) {
            symbol['markerPath'] = res[_iii];
            resources.push([getMarkerPathBase64(symbol), w, h]);
          }
          symbol['markerPath'] = path;
        } else {
          resources.push([getMarkerPathBase64(symbol), w, h]);
        }
      }
    }
    return resources;
  }
  function convertResourceUrl(symbol) {
    if (!symbol) {
      return null;
    }
    var s = symbol;
    if (IS_NODE) {
      return s;
    }
    var props = RESOURCE_PROPERTIES;
    var res;
    for (var ii = 0, len = props.length; ii < len; ii++) {
      res = s[props[ii]];
      if (!res) {
        continue;
      }
      s[props[ii]] = _convertUrl(res);
    }
    return s;
  }
  function _convertUrl(res) {
    if (isFunctionDefinition(res) && res.stops) {
      var stops = res.stops;
      for (var i = 0; i < stops.length; i++) {
        stops[i][1] = _convertUrl(stops[i][1]);
      }
      return res;
    }
    if (res.slice(0, 4) === 'url(') {
      res = extractCssUrl(res);
    }
    return res;
  }

  var Size = function () {
    function Size(width, height) {
      if (isNumber(width) && isNumber(height)) {
        this.width = width;
        this.height = height;
      } else if (isNumber(width['width'])) {
        this.width = width.width;
        this.height = width.height;
      } else if (Array.isArray(width)) {
        this.width = width[0];
        this.height = width[1];
      }
    }
    var _proto = Size.prototype;
    _proto.copy = function copy() {
      return new Size(this['width'], this['height']);
    };
    _proto.add = function add(x, y) {
      var w, h;
      if (x instanceof Size) {
        w = this.width + x.width;
        h = this.height + x.height;
      } else {
        w = this.width + x;
        h = this.height + y;
      }
      return new Size(w, h);
    };
    _proto.equals = function equals(size) {
      return this['width'] === size['width'] && this['height'] === size['height'];
    };
    _proto.multi = function multi(ratio) {
      return new Size(this['width'] * ratio, this['height'] * ratio);
    };
    _proto._multi = function _multi(ratio) {
      this['width'] *= ratio;
      this['height'] *= ratio;
      return this;
    };
    _proto._round = function _round() {
      this['width'] = Math.round(this['width']);
      this['height'] = Math.round(this['height']);
      return this;
    };
    _proto.toPoint = function toPoint() {
      return new Point(this['width'], this['height']);
    };
    _proto.toArray = function toArray() {
      return [this['width'], this['height']];
    };
    _proto.toJSON = function toJSON() {
      return {
        'width': this['width'],
        'height': this['height']
      };
    };
    return Size;
  }();

  function trim(str) {
    return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
  }
  var specialPattern = /[\b\t\r\v\f]/igm;
  function escapeSpecialChars(str) {
    if (!isString(str)) {
      return str;
    }
    return str.replace(specialPattern, '');
  }
  function splitWords(chr) {
    return trim(chr).split(/\s+/);
  }
  var rulerCtx = typeof document !== 'undefined' ? document.createElement('canvas').getContext('2d') : null;
  function stringWidth(text, font) {
    if (stringWidth.node) {
      return stringWidth.node(text, font);
    }
    rulerCtx.font = font;
    return rulerCtx.measureText(text).width;
  }
  function stringLength(text, font, size) {
    var w = stringWidth(text, font);
    return new Size(w, size || DEFAULT_TEXT_SIZE);
  }
  function splitContent(content, font, wrapWidth, textWidth) {
    if (!content || content.length === 0) {
      return [{
        'text': '',
        'width': 0
      }];
    }
    var width = isNil(textWidth) ? stringWidth(content, font) : textWidth;
    var chrWidth = width / content.length,
      minChrCount = Math.floor(wrapWidth / chrWidth / 2);
    if (chrWidth >= wrapWidth || minChrCount <= 0) {
      return [{
        'text': '',
        'width': wrapWidth
      }];
    }
    if (width <= wrapWidth) return [{
      'text': content,
      'width': width
    }];
    var result = [];
    var testStr = content.substring(0, minChrCount),
      prew = chrWidth * minChrCount;
    for (var i = minChrCount, l = content.length; i < l; i++) {
      var chr = content[i];
      var w = stringWidth(testStr + chr);
      if (w >= wrapWidth) {
        result.push({
          'text': testStr,
          'width': prew
        });
        testStr = content.substring(i, minChrCount + i);
        i += minChrCount - 1;
        prew = chrWidth * minChrCount;
      } else {
        testStr += chr;
        prew = w;
      }
      if (i >= l - 1) {
        prew = stringWidth(testStr);
        result.push({
          'text': testStr,
          'width': prew
        });
      }
    }
    return result;
  }
  var CONTENT_EXPRE = /\{([\w_]+)\}/g;
  function replaceVariable(str, props) {
    if (!isString(str)) {
      return str;
    }
    return str.replace(CONTENT_EXPRE, function (str, key) {
      if (!props) {
        return '';
      }
      var value = props[key];
      if (isNil(value)) {
        return '';
      } else if (Array.isArray(value)) {
        return value.join();
      }
      return value;
    });
  }
  function describeText(textContent, symbol) {
    if (isNumber(textContent)) {
      textContent += '';
    }
    textContent = textContent || '';
    var maxHeight = symbol['textMaxHeight'] || 0;
    var textDesc = splitTextToRow(textContent, symbol);
    if (maxHeight && maxHeight < textDesc.size.height) {
      textDesc.size.height = maxHeight;
    }
    return textDesc;
  }
  function getAlignPoint(size, horizontalAlignment, verticalAlignment) {
    var width = size['width'],
      height = size['height'];
    var alignW, alignH;
    if (horizontalAlignment === 'left') {
      alignW = -width;
    } else if (horizontalAlignment === 'right') {
      alignW = 0;
    } else {
      alignW = -width / 2;
    }
    if (verticalAlignment === 'top') {
      alignH = -height;
    } else if (verticalAlignment === 'bottom') {
      alignH = 0;
    } else {
      alignH = -height / 2;
    }
    return new Point(alignW, alignH);
  }
  var DEFAULT_FONT = 'monospace';
  var DEFAULT_TEXTSIZE = 14;
  function getFont(style) {
    if (style['textFont']) {
      return style['textFont'];
    } else {
      var textSize = style.textSize;
      if (isNil(textSize)) {
        textSize = DEFAULT_TEXTSIZE;
      }
      return (style['textStyle'] && style['textStyle'] !== 'normal' ? style['textStyle'] + ' ' : '') + (style['textWeight'] && style['textWeight'] !== 'normal' ? style['textWeight'] + ' ' : '') + textSize + 'px ' + (style['textFaceName'] ? style['textFaceName'] : DEFAULT_FONT);
    }
  }
  function splitTextToRow(text, style) {
    var font = getFont(style),
      lineSpacing = style['textLineSpacing'] || 0,
      size = stringLength(text, font, style['textSize']),
      textWidth = size['width'],
      textHeight = size['height'],
      wrapChar = style['textWrapCharacter'] || '\n',
      textRows = [];
    var wrapWidth = style['textWrapWidth'];
    if (!wrapWidth || wrapWidth > textWidth) {
      wrapWidth = textWidth;
    }
    if (!isString(text)) {
      text += '';
    }
    var actualWidth = 0;
    if (wrapChar && text.indexOf(wrapChar) >= 0) {
      var texts = text.split(wrapChar);
      for (var i = 0, l = texts.length; i < l; i++) {
        var t = texts[i];
        var tWidth = stringWidth(t, font);
        if (tWidth > wrapWidth) {
          var contents = splitContent(t, font, wrapWidth, tWidth);
          for (var ii = 0, ll = contents.length; ii < ll; ii++) {
            var w = contents[ii].width;
            if (w > actualWidth) {
              actualWidth = w;
            }
            textRows.push({
              'text': contents[ii].text,
              'size': new Size(w, textHeight)
            });
          }
        } else {
          if (tWidth > actualWidth) {
            actualWidth = tWidth;
          }
          textRows.push({
            'text': t,
            'size': new Size(tWidth, textHeight)
          });
        }
      }
    } else if (textWidth > wrapWidth) {
      var _contents = splitContent(text, font, wrapWidth, textWidth);
      for (var _i = 0; _i < _contents.length; _i++) {
        var _w = _contents[_i].width;
        if (_w > actualWidth) {
          actualWidth = _w;
        }
        textRows.push({
          'text': _contents[_i].text,
          'size': new Size(_w, textHeight)
        });
      }
    } else {
      if (textWidth > actualWidth) {
        actualWidth = textWidth;
      }
      textRows.push({
        'text': text,
        'size': size
      });
    }
    var rowNum = textRows.length;
    var textSize = new Size(actualWidth, textHeight * rowNum + lineSpacing * (rowNum - 1));
    return {
      'total': rowNum,
      'size': textSize,
      'rows': textRows,
      'rawSize': size
    };
  }
  function hashCode(s) {
    var hash = 0;
    var strlen = s && s.length || 0;
    if (!strlen) {
      return hash;
    }
    var c;
    for (var i = 0; i < strlen; i++) {
      c = s.charCodeAt(i);
      hash = (hash << 5) - hash + c;
      hash = hash & hash;
    }
    return hash;
  }

  var strings = /*#__PURE__*/Object.freeze({
    trim: trim,
    escapeSpecialChars: escapeSpecialChars,
    splitWords: splitWords,
    stringWidth: stringWidth,
    stringLength: stringLength,
    splitContent: splitContent,
    CONTENT_EXPRE: CONTENT_EXPRE,
    replaceVariable: replaceVariable,
    describeText: describeText,
    getAlignPoint: getAlignPoint,
    DEFAULT_FONT: DEFAULT_FONT,
    DEFAULT_TEXTSIZE: DEFAULT_TEXTSIZE,
    getFont: getFont,
    splitTextToRow: splitTextToRow,
    hashCode: hashCode
  });

  function isGradient(g) {
    return g && g['colorStops'];
  }
  function getGradientStamp(g) {
    var keys = [g['type']];
    if (g['places']) {
      keys.push(g['places'].join());
    }
    if (g['colorStops']) {
      var stops = [];
      for (var i = g['colorStops'].length - 1; i >= 0; i--) {
        stops.push(g['colorStops'][i].join());
      }
      keys.push(stops.join(','));
    }
    return keys.join('_');
  }
  function getSymbolStamp(symbol, prefix) {
    return getSymbolHash(symbol, prefix);
  }
  function getSymbolHash(symbol, prefix) {
    if (!symbol) {
      return 1;
    }
    var keys = [];
    if (Array.isArray(symbol)) {
      for (var i = 0; i < symbol.length; i++) {
        keys.push(getSymbolHash(symbol[i], prefix));
      }
      return keys.sort().join(',');
    }
    var sortedKeys = Object.keys(symbol).sort();
    var sortedSymbol = sortedKeys.reduce(function (accumulator, curValue) {
      if (!prefix || curValue.indexOf(prefix) === 0) {
        accumulator[curValue] = symbol[curValue];
      }
      return accumulator;
    }, {});
    var hash = hashCode(JSON.stringify(sortedSymbol));
    return hash;
  }
  function lowerSymbolOpacity(symbol, ratio) {
    function s(_symbol, _ratio) {
      var op = _symbol['opacity'];
      if (isNil(op)) {
        _symbol['opacity'] = _ratio;
      } else {
        _symbol['opacity'] *= _ratio;
      }
    }
    var lower;
    if (Array.isArray(symbol)) {
      lower = [];
      for (var i = 0; i < symbol.length; i++) {
        var d = extend({}, symbol[i]);
        s(d, ratio);
        lower.push(d);
      }
    } else {
      lower = extend({}, symbol);
      s(lower, ratio);
    }
    return lower;
  }
  function extendSymbol(symbol) {
    var sources = Array.prototype.slice.call(arguments, 1);
    if (!sources || !sources.length) {
      sources = [{}];
    }
    if (Array.isArray(symbol)) {
      var s, dest;
      var result = [];
      for (var i = 0, l = symbol.length; i < l; i++) {
        s = symbol[i];
        dest = {};
        for (var ii = 0, ll = sources.length; ii < ll; ii++) {
          if (!Array.isArray(sources[ii])) {
            extend(dest, s, sources[ii] ? sources[ii] : {});
          } else if (!isNil(sources[ii][i])) {
            extend(dest, s, sources[ii][i]);
          } else {
            extend(dest, s ? s : {});
          }
        }
        result.push(dest);
      }
      return result;
    } else {
      var args = [{}, symbol];
      args.push.apply(args, sources);
      return extend.apply(this, args);
    }
  }
  function parseStyleRootPath(style) {
    if (style.symbol) {
      style = [style];
    }
    if (Array.isArray(style)) {
      return style;
    }
    var root = style['$root'];
    var iconset = style['$iconset'];
    style = style.style;
    if (root || iconset) {
      if (root && root[root.length - 1] === '/') {
        root = root.substring(0, root.length - 1);
      }
      if (iconset && iconset[iconset.length - 1] === '/') {
        iconset = iconset.substring(0, iconset.length - 1);
      }
      var replacer = function replacer(match) {
        if (match === '{$root}') {
          return root;
        } else if (match === '{$iconset}') {
          return iconset;
        }
        return null;
      };
      convertStylePath(style, replacer);
    }
    return style;
  }
  function convertStylePath(styles, replacer) {
    for (var i = 0; i < styles.length; i++) {
      var symbol = styles[i].symbol;
      if (symbol) {
        parseSymbolPath(symbol, replacer);
      }
    }
  }
  var URL_PATTERN = /(\{\$root\}|\{\$iconset\})/g;
  function parseSymbolPath(symbol, replacer) {
    for (var p in symbol) {
      if (symbol.hasOwnProperty(p) && p !== 'textName') {
        if (isString(symbol[p]) && symbol[p].length > 2) {
          symbol[p] = symbol[p].replace(URL_PATTERN, replacer);
        } else if (isFunctionDefinition(symbol[p])) {
          symbol[p] = parseStops(symbol[p], replacer);
        } else if (isObject(symbol[p])) {
          parseSymbolPath(symbol[p], replacer);
        }
      }
    }
  }
  function parseStops(value, replacer) {
    var defaultValue = value['default'];
    if (isString(defaultValue)) {
      value['default'] = defaultValue.replace(URL_PATTERN, replacer);
    }
    var stops = value.stops;
    if (!stops) {
      return value;
    }
    for (var i = 0; i < stops.length; i++) {
      if (!Array.isArray(stops[i])) {
        continue;
      }
      if (isString(stops[i][1])) {
        stops[i][1] = stops[i][1].replace(URL_PATTERN, replacer);
      } else if (isFunctionDefinition(stops[i][1])) {
        stops[i][1] = parseStops(stops[i][1], replacer);
      }
    }
    return value;
  }
  function isDashLine(symbolizers) {
    if (symbolizers === void 0) {
      symbolizers = [];
    }
    if (!Array.isArray(symbolizers)) {
      symbolizers = [symbolizers];
    }
    var len = symbolizers.length;
    for (var i = 0; i < len; i++) {
      var symbolizer = symbolizers[i];
      if (!symbolizer.style) {
        continue;
      }
      var _symbolizer$style = symbolizer.style,
        lineDasharray = _symbolizer$style.lineDasharray,
        lineWidth = _symbolizer$style.lineWidth;
      if (lineWidth && isNumber(lineWidth) && lineWidth > 0 && lineDasharray && Array.isArray(lineDasharray) && lineDasharray.length) {
        return true;
      }
    }
    return false;
  }



  var index$1 = /*#__PURE__*/Object.freeze({
    now: now,
    extend: extend,
    isNil: isNil,
    isNumber: isNumber,
    isInteger: isInteger,
    isObject: isObject,
    isString: isString,
    isFunction: isFunction,
    hasOwn: hasOwn,
    join: join,
    isEmpty: isEmpty,
    toRadian: toRadian,
    toDegree: toDegree,
    IS_NODE: IS_NODE,
    get requestAnimFrame () { return requestAnimFrame; },
    get cancelAnimFrame () { return cancelAnimFrame; },
    isSVG: isSVG,
    loadImage: loadImage,
    UID: UID,
    GUID: GUID,
    parseJSON: parseJSON,
    pushIn: pushIn,
    removeFromArray: removeFromArray,
    forEachCoord: forEachCoord,
    getValueOrDefault: getValueOrDefault,
    sign: sign,
    log2: log2,
    interpolate: interpolate,
    wrap: wrap,
    clamp: clamp,
    isArrayHasData: isArrayHasData,
    isURL: isURL,
    isCssUrl: isCssUrl,
    extractCssUrl: extractCssUrl,
    btoa: btoa$1,
    b64toBlob: b64toBlob,
    computeDegree: computeDegree,
    emptyImageUrl: emptyImageUrl,
    equalMapView: equalMapView,
    flash: flash,
    _defaults: _defaults$1,
    getPointsResultPts: getPointsResultPts,
    getImageBitMap: getImageBitMap,
    getAbsoluteURL: getAbsoluteURL,
    calCanvasSize: calCanvasSize,
    translateToSVGStyles: translateToSVGStyles,
    getMarkerPathBase64: getMarkerPathBase64,
    getExternalResources: getExternalResources,
    convertResourceUrl: convertResourceUrl,
    isGradient: isGradient,
    getGradientStamp: getGradientStamp,
    getSymbolStamp: getSymbolStamp,
    getSymbolHash: getSymbolHash,
    lowerSymbolOpacity: lowerSymbolOpacity,
    extendSymbol: extendSymbol,
    parseStyleRootPath: parseStyleRootPath,
    convertStylePath: convertStylePath,
    parseSymbolPath: parseSymbolPath,
    isDashLine: isDashLine,
    trim: trim,
    escapeSpecialChars: escapeSpecialChars,
    splitWords: splitWords,
    stringWidth: stringWidth,
    stringLength: stringLength,
    splitContent: splitContent,
    CONTENT_EXPRE: CONTENT_EXPRE,
    replaceVariable: replaceVariable,
    describeText: describeText,
    getAlignPoint: getAlignPoint,
    DEFAULT_FONT: DEFAULT_FONT,
    DEFAULT_TEXTSIZE: DEFAULT_TEXTSIZE,
    getFont: getFont,
    splitTextToRow: splitTextToRow,
    hashCode: hashCode
  });

  var first = function first(props) {
    return props[0];
  };
  var testProp = IS_NODE ? first : function (props) {
    var style = document.documentElement && document.documentElement.style || {};
    for (var i = 0; i < props.length; i++) {
      if (props[i] in style) {
        return props[i];
      }
    }
    return false;
  };
  var TRANSFORM = testProp(['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
  var TRANSFORMORIGIN = testProp(['transformOrigin', 'WebkitTransformOrigin', 'OTransformOrigin', 'MozTransformOrigin', 'msTransformOrigin']);
  var TRANSITION = testProp(['transition', 'WebkitTransition', 'OTransition', 'MozTransition', 'msTransition']);
  var CSSFILTER = testProp(['filter', 'WebkitFilter', 'OFilter', 'MozFilter', 'msFilter']);
  function createEl(tagName, className) {
    var el = document.createElement(tagName);
    if (className) {
      setClass(el, className);
    }
    return el;
  }
  function createElOn(tagName, style, container) {
    var el = createEl(tagName);
    if (style) {
      setStyle(el, style);
    }
    if (container) {
      container.appendChild(el);
    }
    return el;
  }
  function removeDomNode(node) {
    if (!node) {
      return this;
    }
    if (Browser$1.ielt9 || Browser$1.ie9) {
      var d = createEl('div');
      d.appendChild(node);
      d.innerHTML = '';
      d = null;
    } else if (node.parentNode) {
      node.parentNode.removeChild(node);
    }
    return this;
  }
  function addDomEvent(obj, typeArr, handler, context) {
    if (!obj || !obj.addEventListener || !typeArr || !handler) {
      return this;
    }
    var eventHandler = function eventHandler(e) {
      if (!e) {
        e = window.event;
      }
      handler.call(context || obj, e);
      return;
    };
    var types = typeArr.split(' ');
    for (var i = types.length - 1; i >= 0; i--) {
      var type = types[i];
      if (!type) {
        continue;
      }
      if (!obj['Z__' + type]) {
        obj['Z__' + type] = [];
      }
      var hit = listensDomEvent(obj, type, handler);
      if (hit >= 0) {
        console.warn(obj, "find '" + type + "' handler:", handler, ' The old listener function will be removed');
        removeDomEvent(obj, type, handler);
      }
      obj['Z__' + type].push({
        callback: eventHandler,
        src: handler
      });
      obj.addEventListener(type, eventHandler, Browser$1.supportsPassive ? {
        capture: false,
        passive: false
      } : false);
    }
    return this;
  }
  function removeDomEvent(obj, typeArr, handler) {
    function doRemove(type, callback) {
      if (type === 'mousewheel' && Browser$1.gecko) {
        type = 'DOMMouseScroll';
      }
      obj.removeEventListener(type, callback, false);
    }
    if (!obj || !obj.removeEventListener || !typeArr) {
      return this;
    }
    var types = typeArr.split(' ');
    for (var i = types.length - 1; i >= 0; i--) {
      var type = types[i];
      if (!type) {
        continue;
      }
      if (!handler && obj['Z__' + type]) {
        var handlers = obj['Z__' + type];
        for (var j = 0, jlen = handlers.length; j < jlen; j++) {
          doRemove(handlers[j].callback);
        }
        delete obj['Z__' + type];
        return this;
      }
      var hit = listensDomEvent(obj, type, handler);
      if (hit < 0) {
        return this;
      }
      var hitHandler = obj['Z__' + type][hit];
      doRemove(type, hitHandler.callback);
      obj['Z__' + type].splice(hit, 1);
    }
    return this;
  }
  function listensDomEvent(obj, type, handler) {
    if (!obj || !obj['Z__' + type] || !handler) {
      return -1;
    }
    var handlers = obj['Z__' + type];
    for (var i = 0, len = handlers.length; i < len; i++) {
      if (handlers[i].src === handler) {
        return i;
      }
    }
    return -1;
  }
  function preventDefault(event) {
    if (event.preventDefault) {
      event.preventDefault();
    } else {
      event.returnValue = false;
    }
    return this;
  }
  function stopPropagation(e) {
    e._cancelBubble = true;
    if (e.stopPropagation) {
      e.stopPropagation();
    } else {
      e.cancelBubble = true;
    }
    return this;
  }
  function preventSelection(dom) {
    dom.onselectstart = function () {
      return false;
    };
    dom.ondragstart = function () {
      return false;
    };
    dom.setAttribute('unselectable', 'on');
    return this;
  }
  function offsetDom(dom, offset) {
    if (!dom) {
      return null;
    }
    if (Browser$1.any3d) {
      setTransform(dom, offset);
    } else {
      dom.style.left = offset.x + 'px';
      dom.style.top = offset.y + 'px';
    }
    return offset;
  }
  function computeDomPosition(dom) {
    var style = window.getComputedStyle(dom);
    var padding = [parseInt(style['padding-left']), parseInt(style['padding-top'])];
    var rect = dom.getBoundingClientRect();
    var offsetWidth = dom.offsetWidth,
      offsetHeight = dom.offsetHeight;
    var scaleX = offsetWidth ? rect.width / offsetWidth : 1,
      scaleY = offsetHeight ? rect.height / offsetHeight : 1;
    dom.__position = [rect.left + padding[0], rect.top + padding[1], scaleX, scaleY];
    return dom.__position;
  }
  function getEventContainerPoint(ev, dom) {
    if (!ev) {
      ev = window.event;
    }
    var domPos = dom.__position;
    if (!domPos) {
      domPos = computeDomPosition(dom);
    }
    return new Point((ev.clientX - domPos[0] - dom.clientLeft) / domPos[2], (ev.clientY - domPos[1] - dom.clientTop) / domPos[3]);
  }
  function endsWith(str, suffix) {
    var l = str.length - suffix.length;
    return l >= 0 && str.indexOf(suffix, l) === l;
  }
  function setStyle(dom, strCss) {
    var cssText = dom.style.cssText;
    if (!endsWith(cssText, ';')) {
      cssText += ';';
    }
    dom.style.cssText = cssText + strCss;
    return this;
  }
  function hasClass(el, name) {
    if (el.classList !== undefined) {
      return el.classList.contains(name);
    }
    var className = getClass(el);
    return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
  }
  function addClass(el, name) {
    if (el.classList !== undefined && !hasClass(el, name)) {
      var classes = splitWords(name);
      for (var i = 0, len = classes.length; i < len; i++) {
        el.classList.add(classes[i]);
      }
    } else {
      var className = getClass(el);
      setClass(el, (className ? className + ' ' : '') + name);
    }
    return this;
  }
  function setClass(el, name) {
    if (isNil(el.className.baseVal)) {
      el.className = name;
    } else {
      el.className.baseVal = name;
    }
    return this;
  }
  function getClass(el) {
    return isNil(el.className.baseVal) ? el.className : el.className.baseVal;
  }
  function setOpacity(el, value) {
    el.style.opacity = value;
    return this;
  }
  function setTransform(el, offset) {
    var pos = offset || new Point(0, 0);
    el.style[TRANSFORM] = Browser$1.any3d ? 'translate3d(' + pos.x + 'px,' + pos.y + 'px,0px)' : 'translate(' + pos.x + 'px,' + pos.y + 'px)';
    return this;
  }
  function setTransformMatrix(el, m) {
    var text = 'matrix(' + (isString(m) ? m : m.join()) + ')';
    if (el.style[TRANSFORM] !== text) {
      el.style[TRANSFORM] = text;
    }
    return this;
  }
  function removeTransform(el) {
    if (el.style[TRANSFORM]) {
      el.style[TRANSFORM] = '';
    }
    return this;
  }
  function isHTML(str) {
    return /<[a-z\][\s\S]*>/i.test(str);
  }
  function measureDom(parentTag, dom) {
    var ruler = getDomRuler(parentTag);
    if (isString(dom)) {
      ruler.innerHTML = dom;
    } else {
      ruler.appendChild(dom);
    }
    var result = new Size(ruler.clientWidth, ruler.clientHeight);
    removeDomNode(ruler);
    return result;
  }
  function getDomRuler(tag) {
    var span = document.createElement(tag);
    span.style.cssText = 'position:absolute;left:-10000px;top:-10000px;';
    document.body.appendChild(span);
    return span;
  }
  var on = addDomEvent;
  var off = removeDomEvent;
  function isMoveEvent(type) {
    return type && (type === 'mousemove' || type === 'touchmove');
  }
  var MOUSEMOVE_THROTTLE_TIME = 48;
  function isMousemoveEventBlocked(target, mousemoveThrottleTime) {
    var currentTime = now();
    var TIME = mousemoveThrottleTime || MOUSEMOVE_THROTTLE_TIME;
    if (target._mousemoveTime && currentTime - target._mousemoveTime < TIME) {
      return true;
    }
    target._mousemoveTime = currentTime;
    return false;
  }

  var dom = /*#__PURE__*/Object.freeze({
    TRANSFORM: TRANSFORM,
    TRANSFORMORIGIN: TRANSFORMORIGIN,
    TRANSITION: TRANSITION,
    CSSFILTER: CSSFILTER,
    createEl: createEl,
    createElOn: createElOn,
    removeDomNode: removeDomNode,
    addDomEvent: addDomEvent,
    removeDomEvent: removeDomEvent,
    listensDomEvent: listensDomEvent,
    preventDefault: preventDefault,
    stopPropagation: stopPropagation,
    preventSelection: preventSelection,
    offsetDom: offsetDom,
    computeDomPosition: computeDomPosition,
    getEventContainerPoint: getEventContainerPoint,
    setStyle: setStyle,
    hasClass: hasClass,
    addClass: addClass,
    setClass: setClass,
    getClass: getClass,
    setOpacity: setOpacity,
    setTransform: setTransform,
    setTransformMatrix: setTransformMatrix,
    removeTransform: removeTransform,
    isHTML: isHTML,
    measureDom: measureDom,
    getDomRuler: getDomRuler,
    on: on,
    off: off,
    isMoveEvent: isMoveEvent,
    MOUSEMOVE_THROTTLE_TIME: MOUSEMOVE_THROTTLE_TIME,
    isMousemoveEventBlocked: isMousemoveEventBlocked
  });

  var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

  function createCommonjsModule(fn, module) {
  	return module = { exports: {} }, fn(module, module.exports), module.exports;
  }

  var zousanMin = createCommonjsModule(function (module) {
    !function (t) {

      function e(t) {
        if (t) {
          var e = this;
          t(function (t) {
            e.resolve(t);
          }, function (t) {
            e.reject(t);
          });
        }
      }
      function n(t, e) {
        if ("function" == typeof t.y) try {
          var n = t.y.call(i, e);
          t.p.resolve(n);
        } catch (o) {
          t.p.reject(o);
        } else t.p.resolve(e);
      }
      function o(t, e) {
        if ("function" == typeof t.n) try {
          var n = t.n.call(i, e);
          t.p.resolve(n);
        } catch (o) {
          t.p.reject(o);
        } else t.p.reject(e);
      }
      var r,
        i,
        c = "fulfilled",
        u = "rejected",
        s = "undefined",
        f = function () {
          function e() {
            for (; n.length - o;) {
              try {
                n[o]();
              } catch (e) {
                t.console && t.console.error(e);
              }
              n[o++] = i, o == r && (n.splice(0, r), o = 0);
            }
          }
          var n = [],
            o = 0,
            r = 1024,
            c = function () {
              if (typeof MutationObserver !== s) {
                var t = document.createElement("div"),
                  n = new MutationObserver(e);
                return n.observe(t, {
                  attributes: !0
                }), function () {
                  t.setAttribute("a", 0);
                };
              }
              return typeof setImmediate !== s ? function () {
                setImmediate(e);
              } : function () {
                setTimeout(e, 0);
              };
            }();
          return function (t) {
            n.push(t), n.length - o == 1 && c();
          };
        }();
      e.prototype = {
        resolve: function resolve(t) {
          if (this.state === r) {
            if (t === this) return this.reject(new TypeError("Attempt to resolve promise with self"));
            var e = this;
            if (t && ("function" == typeof t || "object" == typeof t)) try {
              var o = !0,
                i = t.then;
              if ("function" == typeof i) return void i.call(t, function (t) {
                o && (o = !1, e.resolve(t));
              }, function (t) {
                o && (o = !1, e.reject(t));
              });
            } catch (u) {
              return void (o && this.reject(u));
            }
            this.state = c, this.v = t, e.c && f(function () {
              for (var o = 0, r = e.c.length; r > o; o++) {
                n(e.c[o], t);
              }
            });
          }
        },
        reject: function reject(n) {
          if (this.state === r) {
            this.state = u, this.v = n;
            var i = this.c;
            i ? f(function () {
              for (var t = 0, e = i.length; e > t; t++) {
                o(i[t], n);
              }
            }) : !e.suppressUncaughtRejectionError && t.console && t.console.log("You upset Zousan. Please catch rejections: ", n, n ? n.stack : null);
          }
        },
        then: function then(t, i) {
          var u = new e(),
            s = {
              y: t,
              n: i,
              p: u
            };
          if (this.state === r) this.c ? this.c.push(s) : this.c = [s];else {
            var l = this.state,
              a = this.v;
            f(function () {
              l === c ? n(s, a) : o(s, a);
            });
          }
          return u;
        },
        "catch": function _catch(t) {
          return this.then(null, t);
        },
        "finally": function _finally(t) {
          return this.then(t, t);
        },
        timeout: function timeout(t, n) {
          n = n || "Timeout";
          var o = this;
          return new e(function (e, r) {
            setTimeout(function () {
              r(Error(n));
            }, t), o.then(function (t) {
              e(t);
            }, function (t) {
              r(t);
            });
          });
        }
      }, e.resolve = function (t) {
        var n = new e();
        return n.resolve(t), n;
      }, e.reject = function (t) {
        var n = new e();
        return n.reject(t), n;
      }, e.all = function (t) {
        function n(n, c) {
          n && "function" == typeof n.then || (n = e.resolve(n)), n.then(function (e) {
            o[c] = e, r++, r == t.length && i.resolve(o);
          }, function (t) {
            i.reject(t);
          });
        }
        for (var o = [], r = 0, i = new e(), c = 0; c < t.length; c++) {
          n(t[c], c);
        }
        return t.length || i.resolve(o), i;
      }, module.exports && (module.exports = e), t.define && t.define.amd && t.define([], function () {
        return e;
      }), t.Zousan = e, e.soon = f;
    }("undefined" != typeof commonjsGlobal ? commonjsGlobal : commonjsGlobal);
  });

  var promise;
  if (typeof Promise !== 'undefined') {
    promise = Promise;
  } else {
    promise = zousanMin;
  }
  var Promise$1 = promise;

  var imageFetchWorkerKey = 'core-fetch-image';
  var globalWorkerPool;
  function setWorkerPool(pool) {
    globalWorkerPool = pool;
  }
  function getWorkerPool() {
    return globalWorkerPool;
  }
  var workersCreated = false;
  function setWorkersCreated() {
    workersCreated = true;
  }
  function workersHasCreated() {
    return workersCreated;
  }
  var ADAPTER_CREATED_LIST = [];
  function adapterHasCreated(workerKey) {
    return ADAPTER_CREATED_LIST.indexOf(workerKey) > -1;
  }
  function pushAdapterCreated(workerKey) {
    if (!adapterHasCreated(workerKey)) {
      ADAPTER_CREATED_LIST.push(workerKey);
    }
  }

  var adapters = {};
  function registerWorkerAdapter(workerKey, adapter) {
    adapters[workerKey] = adapter;
  }
  var header = "\n    var adapters = {};\n    // Dynamic Create Adapter\n    function createAdapter(key,code){\n        if(adapters[key]||!code){\n            return;\n        }\n        var func=new Function('exports',code+'(exports)');\n        var workerExports={};\n        func(workerExports,self);\n        adapters[key]=workerExports;\n        workerExports.initialize && workerExports.initialize(self);\n        \n    }\n    onmessage = function (msg) {\n        msg = msg.data;\n        //createAdapter\n        if (msg.messageType === 'createAdapter') {\n           var key=msg.key;\n           var code=msg.code;\n           createAdapter(key,code);\n           postMessage({adapterName:key});\n           return;\n        }\n        // postMessage when main thread idle\n        if(msg.messageType==='idle'){\n            var messageCount = msg.messageCount||5;\n            handleMessageQueue(messageCount);\n            return;\n        }\n        if (msg.messageType === 'batch') {\n            const messages = msg.messages;\n            if (messages) {\n                for (let i = 0; i < messages.length; i++) {\n                    dispatch(messages[i]);\n                }\n            }\n        } else {\n            dispatch(msg);\n        }\n    };\n\n    function dispatch(msg) {\n        var workerKey = msg.workerKey;\n        var adapter = adapters[workerKey];\n        if (!adapter) {\n            post(msg.callback, 'Unregistered worker adapters for ' + workerKey);\n            return;\n        }\n        try {\n            adapter.onmessage(msg, wrap(msg.callback));\n        } catch (err) {\n            post(msg.callback, workerKey + ':' + err.message);\n            console.error(err);\n            throw err;\n        }\n    }\n\n    var messageResultQueue = [];\n    \n    function handleMessageQueue(messageCount){\n       if(messageResultQueue.length===0){\n          return;\n       }\n       var queues = messageResultQueue.slice(0,messageCount);\n       queues.forEach(function(queue){\n          post(queue.callback,queue.err,queue.data,queue.buffers);\n       });\n       messageResultQueue=messageResultQueue.slice(messageCount,Infinity);\n    }\n\n    function post(callback, err, data, buffers) {\n        var msg = {\n            callback : callback\n        };\n        if (err) {\n            msg.error = err;\n        } else {\n            msg.data = data;\n        }\n        if (buffers && buffers.length > 0) {\n            postMessage(msg, buffers);\n        } else {\n            postMessage(msg);\n        }\n    }\n\n    function joinQueue(callback,err,data,buffers){\n        messageResultQueue.push({\n            callback:callback,\n            err:err,\n            data:data,\n            buffers:buffers\n        });\n    }\n\n    function wrap(callback) {\n        return function (err, data, buffers) {\n            joinQueue(callback, err, data, buffers);\n        };\n    }\n    var workerExports;\n";
  var footer = "\n    workerExports = null;\n";
  function compileWorkerSource() {
    var source = header;
    for (var p in adapters) {
      var adapter = adapters[p];
      pushAdapterCreated(p);
      if (isFunction(adapter)) {
        if (adapter.length === 0) {
          adapter = adapter();
        }
      }
      source += "\n    workerExports = {};\n    (" + adapter + ")(workerExports, self);\n    adapters['" + p + "'] = workerExports";
      source += "\n    workerExports.initialize && workerExports.initialize(self);\n        ";
    }
    source += footer;
    return source;
  }
  var url;
  function getWorkerSourcePath() {
    if (typeof window === 'undefined') {
      return null;
    }
    if (!url) {
      var source = compileWorkerSource();
      url = window.URL.createObjectURL(new Blob([source], {
        type: 'text/javascript'
      }));
      adapters = {};
    }
    return url;
  }
  function createAdapter(key, cb) {
    if (!adapters[key]) {
      console.error("not find " + key + " adapter");
      return;
    }
    var adapter = adapters[key];
    if (isFunction(adapter)) {
      if (adapter.length === 0) {
        adapter = adapter();
      }
    }
    adapter = "(" + adapter + ")";
    var workerPool = getWorkerPool();
    if (!workerPool) {
      return;
    }
    var workers = workerPool.workers || [];
    if (workers.length === 0) {
      console.error('workerpool workers count is 0');
    }
    var count = 0;
    var messageCB = function messageCB(msg) {
      msg = msg.data || {};
      if (msg.adapterName === key) {
        count++;
        if (count === workers.length) {
          workers.forEach(function (worker) {
            worker.removeEventListener('message', messageCB);
          });
          delete adapters[key];
          cb();
        }
      }
    };
    workers.forEach(function (worker) {
      worker.addEventListener('message', messageCB);
      worker.postMessage({
        key: key,
        code: adapter,
        messageType: 'createAdapter'
      });
    });
  }

  var hardwareConcurrency = typeof window !== 'undefined' ? window.navigator.hardwareConcurrency || 4 : 0;
  var hardwareWorkerCount = Math.max(Math.floor(hardwareConcurrency / 2), 1);
  var MessageBatch = function () {
    function MessageBatch(limit) {
      if (limit === void 0) {
        limit = 50;
      }
      this._limit = limit;
      this._messages = [];
      this.buffers = [];
    }
    var _proto = MessageBatch.prototype;
    _proto.addMessage = function addMessage(msg, buffers) {
      this._messages.push(msg);
      if (!Array.isArray(buffers)) {
        return;
      }
      for (var i = 0; i < buffers.length; i++) {
        if (this.buffers.indexOf(buffers[i]) < 0) {
          this.buffers.push(buffers[i]);
        }
      }
    };
    _proto.isFull = function isFull() {
      return this._messages.length >= this._limit;
    };
    _proto.getMessage = function getMessage() {
      return {
        messageType: 'batch',
        messages: this._messages
      };
    };
    return MessageBatch;
  }();
  var WorkerPool = function () {
    function WorkerPool() {
      this.active = {};
      this.workerCount = typeof window !== 'undefined' ? GlobalConfig.workerCount || hardwareWorkerCount : 0;
      this._messages = [];
      this._messageBuffers = [];
    }
    var _proto2 = WorkerPool.prototype;
    _proto2.acquire = function acquire(id) {
      if (!this.workers) {
        this.workers = [];
        var url = getWorkerSourcePath();
        for (var i = 0; i < this.workerCount; i++) {
          var worker = new Worker(url);
          worker.id = i;
          this.workers.push(worker);
        }
        URL.revokeObjectURL(url);
        setWorkersCreated();
      }
      this.active[id] = true;
      return this.workers.slice();
    };
    _proto2.release = function release(id) {
      delete this.active[id];
      if (Object.keys(this.active).length === 0) {
        this.workers.forEach(function (w) {
          w.terminate();
        });
        this.workers = null;
      }
    };
    _proto2.addMessage = function addMessage(workerId, data, buffers) {
      var batches = this._messages[workerId];
      if (!batches || !batches.length) {
        batches = this._messages[workerId] = [new MessageBatch()];
      }
      var batch = batches[batches.length - 1];
      if (batch.isFull()) {
        batch = new MessageBatch();
        this._messages[workerId].push(batch);
      }
      batch.addMessage(data, buffers);
    };
    _proto2.commit = function commit() {
      if (!this.workers) {
        return;
      }
      if (this._messages.length) {
        for (var i = 0; i < this._messages.length; i++) {
          if (!this._messages[i] || !this._messages[i].length) {
            continue;
          }
          var batch = this._messages[i].shift();
          this.workers[i].postMessage(batch.getMessage(), batch.buffers);
        }
      }
    };
    _proto2.getWorkers = function getWorkers() {
      return this.workers || [];
    };
    _proto2.broadcastIdleMessage = function broadcastIdleMessage() {
      var workers = this.getWorkers();
      workers.forEach(function (worker) {
        worker.postMessage({
          messageType: 'idle',
          messageCount: GlobalConfig.taskCountPerWorkerMessage
        });
      });
      return this;
    };
    return WorkerPool;
  }();
  var globalWorkerPool$1;
  function getGlobalWorkerPool() {
    if (!globalWorkerPool$1) {
      globalWorkerPool$1 = new WorkerPool();
      setWorkerPool(globalWorkerPool$1);
    }
    return globalWorkerPool$1;
  }

  var tasks = [];
  function runTaskAsync(task) {
    startTasks();
    var promise = new Promise$1(function (resolve, reject) {
      if (!task) {
        reject(new Error('task is null'));
        return;
      }
      if (isFunction(task)) {
        task = {
          count: 1,
          run: task
        };
      }
      if (!task.run) {
        reject(new Error('task.run is null'));
        return;
      }
      if (isNil(task.count)) {
        task.count = 1;
      }
      task.count = Math.ceil(task.count);
      if (!isNumber(task.count)) {
        reject(new Error('task.count is not number'));
        return;
      }
      task.results = [];
      tasks.push(task);
      task.resolve = resolve;
    });
    return promise;
  }
  function executeMicroTasks() {
    if (tasks.length === 0) {
      return;
    }
    var runingTasks = [],
      endTasks = [];
    var len = tasks.length;
    for (var i = 0; i < len; i++) {
      var task = tasks[i];
      task.count--;
      if (task.count === -1) {
        endTasks.push(task);
      } else {
        runingTasks.push(task);
        var result = task.run();
        task.results.push(result);
      }
    }
    tasks = runingTasks;
    len = endTasks.length;
    for (var _i = 0; _i < len; _i++) {
      var _task = endTasks[_i];
      if (_task.resolve) {
        _task.resolve(_task.results);
      }
    }
  }
  var broadcastIdleMessage = true;
  function loop() {
    if (broadcastIdleMessage) {
      getGlobalWorkerPool().broadcastIdleMessage();
    } else {
      getGlobalWorkerPool().commit();
    }
    executeMicroTasks();
    broadcastIdleMessage = !broadcastIdleMessage;
  }
  var loopFrameTime = now();
  function frameLoop(deadline) {
    var idleTimeRemaining = GlobalConfig.idleTimeRemaining,
      idleLog = GlobalConfig.idleLog,
      idleTimeout = GlobalConfig.idleTimeout,
      idleForceTimeThreshold = GlobalConfig.idleForceTimeThreshold;
    if (Browser$1.requestIdleCallback) {
      if (deadline && deadline.timeRemaining) {
        var t = deadline.timeRemaining();
        if (t > idleTimeRemaining || deadline.didTimeout) {
          if (deadline.didTimeout && idleLog) {
            console.error('idle timeout in', idleTimeout);
          }
          loop();
          loopFrameTime = now();
        } else {
          var time = now();
          if (time - loopFrameTime > idleForceTimeThreshold) {
            loop();
            loopFrameTime = now();
          }
          if (t <= idleTimeRemaining && idleLog) {
            console.warn('currrent page is busy,the timeRemaining is', t);
          }
        }
      }
      requestIdleCallback(frameLoop, {
        timeout: idleTimeout
      });
    } else {
      loop();
      requestAnimFrame(frameLoop);
      if (idleLog) {
        console.warn('current env not support requestIdleCallback. Fallback to requestAnimFrame');
      }
    }
  }
  var started = false;
  function startTasks() {
    if (started) {
      return;
    }
    started = true;
    var idleTimeout = GlobalConfig.idleTimeout;
    if (Browser$1.requestIdleCallback) {
      requestIdleCallback(frameLoop, {
        timeout: idleTimeout
      });
    } else {
      requestAnimFrame(frameLoop);
    }
  }

  var MicroTask = /*#__PURE__*/Object.freeze({
    runTaskAsync: runTaskAsync,
    startTasks: startTasks
  });

  var isMapSupported$1 = typeof Map === 'function';
  var nullOnRemove = function nullOnRemove() {};
  var ArrayLRUCache = function () {
    function ArrayLRUCache(max, onRemove) {
      this.max = max;
      this.onRemove = onRemove || nullOnRemove;
      this.reset();
    }
    var _proto = ArrayLRUCache.prototype;
    _proto.reset = function reset() {
      for (var key in this.data) {
        this.onRemove(this.data[key]);
      }
      this.data = {};
      this.order = [];
      return this;
    };
    _proto.clear = function clear() {
      this.reset();
      delete this.onRemove;
    };
    _proto.add = function add(key, data) {
      if (this.has(key)) {
        this.order.splice(this.order.indexOf(key), 1);
        this.data[key] = data;
        this.order.push(key);
      } else {
        this.data[key] = data;
        this.order.push(key);
        if (this.order.length > this.max) {
          var removedData = this.getAndRemove(this.order[0]);
          if (removedData) this.onRemove(removedData);
        }
      }
      return this;
    };
    _proto.has = function has(key) {
      return key in this.data;
    };
    _proto.keys = function keys() {
      return this.order;
    };
    _proto.getAndRemove = function getAndRemove(key) {
      if (!this.has(key)) {
        return null;
      }
      var data = this.data[key];
      delete this.data[key];
      this.order.splice(this.order.indexOf(key), 1);
      return data;
    };
    _proto.get = function get(key) {
      if (!this.has(key)) {
        return null;
      }
      var data = this.data[key];
      return data;
    };
    _proto.remove = function remove(key) {
      if (!this.has(key)) {
        return this;
      }
      var data = this.data[key];
      delete this.data[key];
      this.onRemove(data);
      this.order.splice(this.order.indexOf(key), 1);
      return this;
    };
    _proto.setMaxSize = function setMaxSize(max) {
      this.max = max;
      while (this.order.length > this.max) {
        var removedData = this.getAndRemove(this.order[0]);
        if (removedData) this.onRemove(removedData);
      }
      return this;
    };
    return ArrayLRUCache;
  }();
  var MapLRUCache;
  if (isMapSupported$1) {
    MapLRUCache = function () {
      function MapLRUCache(max, onRemove) {
        this.max = max;
        this.onRemove = onRemove || nullOnRemove;
        this.reset();
      }
      var _proto2 = MapLRUCache.prototype;
      _proto2.reset = function reset() {
        if (this.data) {
          var values = this.data.values();
          for (var _iterator = values, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
            var _ref;
            if (_isArray) {
              if (_i >= _iterator.length) break;
              _ref = _iterator[_i++];
            } else {
              _i = _iterator.next();
              if (_i.done) break;
              _ref = _i.value;
            }
            var p = _ref;
            this.onRemove(p);
          }
        }
        this.data = new Map();
        return this;
      };
      _proto2.clear = function clear() {
        this.reset();
        delete this.onRemove;
      };
      _proto2.add = function add(key, data) {
        if (!data) {
          return this;
        }
        if (this.has(key)) {
          this.data.delete(key);
          this.data.set(key, data);
        } else {
          this.data.set(key, data);
        }
        return this;
      };
      _proto2.keys = function keys() {
        var keys = new Array(this.data.size);
        var i = 0;
        var iterator = this.data.keys();
        for (var _iterator2 = iterator, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
          var _ref2;
          if (_isArray2) {
            if (_i2 >= _iterator2.length) break;
            _ref2 = _iterator2[_i2++];
          } else {
            _i2 = _iterator2.next();
            if (_i2.done) break;
            _ref2 = _i2.value;
          }
          var k = _ref2;
          keys[i++] = k;
        }
        return keys;
      };
      _proto2.shrink = function shrink() {
        var iterator = this.data.keys();
        var item = iterator.next();
        while (this.data.size > this.max) {
          var removedData = this.getAndRemove(item.value);
          if (removedData) {
            this.onRemove(removedData);
          }
          item = iterator.next();
        }
      };
      _proto2.has = function has(key) {
        return this.data.has(key);
      };
      _proto2.getAndRemove = function getAndRemove(key) {
        if (!this.has(key)) {
          return null;
        }
        var data = this.data.get(key);
        this.data.delete(key);
        return data;
      };
      _proto2.get = function get(key) {
        if (!this.has(key)) {
          return null;
        }
        var data = this.data.get(key);
        return data;
      };
      _proto2.remove = function remove(key) {
        if (!this.has(key)) {
          return this;
        }
        var data = this.data.get(key);
        this.data.delete(key);
        this.onRemove(data);
        return this;
      };
      _proto2.setMaxSize = function setMaxSize(max) {
        this.max = max;
        if (this.data.size > this.max) {
          this.shrink();
        }
        return this;
      };
      return MapLRUCache;
    }();
  }
  var LRUCache = isMapSupported$1 ? MapLRUCache : ArrayLRUCache;

  var Ajax = {
    jsonp: function jsonp(url, callback) {
      var name = '_maptalks_jsonp_' + UID();
      if (url.match(/\?/)) url += '&callback=' + name;else url += '?callback=' + name;
      var script = document.createElement('script');
      script.type = 'text/javascript';
      script.src = url;
      window[name] = function (data) {
        callback(null, data);
        document.getElementsByTagName('head')[0].removeChild(script);
        script = null;
        delete window[name];
      };
      document.getElementsByTagName('head')[0].appendChild(script);
      return this;
    },
    get: function get(url, options, cb) {
      if (isFunction(options)) {
        var t = cb;
        cb = options;
        options = t;
      }
      if (IS_NODE && Ajax.get.node) {
        return Ajax.get.node(url, cb, options);
      }
      var client = Ajax._getClient(cb);
      client.open('GET', url, true);
      if (options) {
        for (var k in options.headers) {
          client.setRequestHeader(k, options.headers[k]);
        }
        client.withCredentials = options.credentials === 'include';
        if (options['responseType']) {
          client.responseType = options['responseType'];
        }
      }
      client.send(null);
      return client;
    },
    post: function post(url, options, cb) {
      var postData;
      if (!isString(url)) {
        var t = cb;
        postData = options;
        options = url;
        url = options.url;
        cb = t;
      } else {
        if (isFunction(options)) {
          var _t = cb;
          cb = options;
          options = _t;
        }
        options = options || {};
        postData = options.postData;
      }
      if (IS_NODE && Ajax.post.node) {
        options.url = url;
        return Ajax.post.node(options, postData, cb);
      }
      var client = Ajax._getClient(cb);
      client.open('POST', options.url, true);
      if (!options.headers) {
        options.headers = {};
      }
      if (!options.headers['Content-Type']) {
        options.headers['Content-Type'] = 'application/x-www-form-urlencoded';
      }
      if ('setRequestHeader' in client) {
        for (var p in options.headers) {
          if (options.headers.hasOwnProperty(p)) {
            client.setRequestHeader(p, options.headers[p]);
          }
        }
      }
      if (!isString(postData)) {
        postData = JSON.stringify(postData);
      }
      client.send(postData);
      return client;
    },
    _wrapCallback: function _wrapCallback(client, cb) {
      return function () {
        if (client.readyState === 4) {
          if (client.status === 200) {
            if (client.responseType === 'arraybuffer') {
              var response = client.response;
              if (response.byteLength === 0) {
                cb(new Error('http status 200 returned without content.'));
              } else {
                cb(null, {
                  data: client.response,
                  cacheControl: client.getResponseHeader('Cache-Control'),
                  expires: client.getResponseHeader('Expires'),
                  contentType: client.getResponseHeader('Content-Type')
                });
              }
            } else {
              cb(null, client.responseText);
            }
          } else {
            cb(new Error(client.statusText + ',' + client.status));
          }
        }
      };
    },
    _getClient: function _getClient(cb) {
      var client;
      try {
        client = new XMLHttpRequest();
      } catch (e) {
        try {
          client = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (e) {
          try {
            client = new ActiveXObject('Microsoft.XMLHTTP');
          } catch (e) {}
        }
      }
      client.onreadystatechange = Ajax._wrapCallback(client, cb);
      return client;
    },
    getArrayBuffer: function getArrayBuffer(url, options, cb) {
      if (isFunction(options)) {
        var t = cb;
        cb = options;
        options = t;
      }
      if (!options) {
        options = {};
      }
      options['responseType'] = 'arraybuffer';
      return Ajax.get(url, options, cb);
    },
    getImage: function getImage(img, url, options) {
      return Ajax.getArrayBuffer(url, options, function (err, imgData) {
        if (err) {
          if (img.onerror) {
            img.onerror(err);
          }
        } else if (imgData) {
          var URL = window.URL || window.webkitURL;
          var onload = img.onload;
          img.onload = function () {
            if (onload) {
              onload();
            }
            URL.revokeObjectURL(img.src);
          };
          var blob = new Blob([new Uint8Array(imgData.data)], {
            type: imgData.contentType
          });
          img.cacheControl = imgData.cacheControl;
          img.expires = imgData.expires;
          img.src = imgData.data.byteLength ? URL.createObjectURL(blob) : emptyImageUrl;
        }
      });
    }
  };
  Ajax.getJSON = function (url, options, cb) {
    if (isFunction(options)) {
      var t = cb;
      cb = options;
      options = t;
    }
    var callback = function callback(err, resp) {
      var data = resp ? parseJSON(resp) : null;
      cb(err, data);
    };
    if (options && options['jsonp']) {
      return Ajax.jsonp(url, callback);
    }
    return Ajax.get(url, options, callback);
  };

  var minx = Infinity,
    miny = Infinity,
    maxx = -Infinity,
    maxy = -Infinity;
  function getDefaultBBOX() {
    return [minx, miny, maxx, maxy];
  }
  var BBOX_TEMP = getDefaultBBOX();
  function resetBBOX(bbox) {
    bbox[0] = minx;
    bbox[1] = miny;
    bbox[2] = maxx;
    bbox[3] = maxy;
  }
  function pointsBBOX(points, out) {
    if (!points) {
      return;
    }
    if (Array.isArray(points[0])) {
      for (var i = 0, len = points.length; i < len; i++) {
        pointsBBOX(points[i], out);
      }
    } else if (Array.isArray(points)) {
      for (var _i = 0, _len = points.length; _i < _len; _i++) {
        var _points$_i = points[_i],
          x = _points$_i.x,
          y = _points$_i.y;
        out[0] = Math.min(x, out[0]);
        out[1] = Math.min(y, out[1]);
        out[2] = Math.max(x, out[2]);
        out[3] = Math.max(y, out[3]);
      }
    } else {
      var x = points.x,
        y = points.y;
      out[0] = Math.min(x, out[0]);
      out[1] = Math.min(y, out[1]);
      out[2] = Math.max(x, out[2]);
      out[3] = Math.max(y, out[3]);
    }
  }
  function setBBOX(bbox, x1, y1, x2, y2) {
    if (x1 !== 0 && !x1) {
      return;
    }
    if (Array.isArray(x1)) {
      y1 = x1[1];
      x2 = x1[2];
      y2 = x1[3];
      x1 = x1[0];
    }
    bbox[0] = Math.min(x1, bbox[0]);
    bbox[1] = Math.min(y1, bbox[1]);
    bbox[2] = Math.max(x2, bbox[2]);
    bbox[3] = Math.max(y2, bbox[3]);
  }
  function validateBBOX(bbox) {
    return bbox && bbox[0] !== Infinity && bbox[0] !== undefined;
  }
  function bufferBBOX(bbox, bufferSize) {
    if (bufferSize === void 0) {
      bufferSize = 0;
    }
    bbox[0] -= bufferSize;
    bbox[1] -= bufferSize;
    bbox[2] += bufferSize;
    bbox[3] += bufferSize;
  }

  var DEFAULT_STROKE_COLOR = '#000';
  var DEFAULT_FILL_COLOR = 'rgba(255,255,255,0)';
  var DEFAULT_TEXT_COLOR = '#000';
  var hitTesting = false;
  var TEMP_CANVAS = null;
  var RADIAN = Math.PI / 180;
  var textOffsetY = 1;
  var Canvas = {
    getCanvas2DContext: function getCanvas2DContext(canvas) {
      return canvas.getContext('2d', {
        willReadFrequently: true
      });
    },
    setHitTesting: function setHitTesting(testing) {
      hitTesting = testing;
    },
    createCanvas: function createCanvas(width, height, canvasClass) {
      var canvas;
      if (!IS_NODE) {
        canvas = createEl('canvas');
        canvas.width = width;
        canvas.height = height;
      } else {
        canvas = new canvasClass(width, height);
      }
      return canvas;
    },
    prepareCanvasFont: function prepareCanvasFont(ctx, style) {
      ctx.textBaseline = 'top';
      ctx.font = getFont(style);
      var fill = style['textFill'];
      if (!fill) {
        fill = DEFAULT_TEXT_COLOR;
      }
      ctx.fillStyle = Canvas.getRgba(fill, style['textOpacity']);
    },
    prepareCanvas: function prepareCanvas(ctx, style, resources, testing) {
      if (!style) {
        return;
      }
      var strokeWidth = style['lineWidth'];
      if (!isNil(strokeWidth) && ctx.lineWidth !== strokeWidth) {
        ctx.lineWidth = strokeWidth;
      }
      var strokePattern = style['linePatternFile'];
      var strokeColor = style['lineColor'] || DEFAULT_STROKE_COLOR;
      if (testing) {
        ctx.strokeStyle = '#000';
      } else if (strokePattern && resources) {
        var patternOffset;
        if (style['linePatternDx'] || style['linePatternDy']) {
          patternOffset = [style['linePatternDx'], style['linePatternDy']];
        }
        Canvas._setStrokePattern(ctx, strokePattern, strokeWidth, patternOffset, resources);
        style['lineDasharray'] = [];
      } else if (isGradient(strokeColor)) {
        if (style['lineGradientExtent']) {
          ctx.strokeStyle = Canvas._createGradient(ctx, strokeColor, style['lineGradientExtent']);
        } else {
          ctx.strokeStyle = DEFAULT_STROKE_COLOR;
        }
      } else {
          if (Array.isArray(strokeColor)) {
            strokeColor = Canvas.normalizeColorToRGBA(strokeColor);
          }
          ctx.strokeStyle = strokeColor;
        }
      if (style['lineJoin']) {
        ctx.lineJoin = style['lineJoin'];
      }
      if (style['lineCap']) {
        ctx.lineCap = style['lineCap'];
      }
      if (ctx.setLineDash && isArrayHasData(style['lineDasharray'])) {
        ctx.setLineDash(style['lineDasharray']);
      }
      var polygonPattern = style['polygonPatternFile'];
      var fill = style['polygonFill'] || DEFAULT_FILL_COLOR;
      if (testing) {
        ctx.fillStyle = '#000';
      } else if (polygonPattern && resources) {
        var fillImgUrl = extractImageUrl(polygonPattern);
        var fillTexture = resources.getImage([fillImgUrl, null, null]);
        if (!fillTexture) {
          fillTexture = resources.getImage([fillImgUrl + '-texture', null, strokeWidth]);
        }
        if (isSVG(fillImgUrl) && fillTexture instanceof Image && (Browser$1.edge || Browser$1.ie)) {
          var w = fillTexture.width || 20,
            h = fillTexture.height || 20;
          var canvas = Canvas.createCanvas(w, h);
          Canvas.image(canvas.getContext('2d'), fillTexture, 0, 0, w, h);
          fillTexture = canvas;
        }
        if (!fillTexture) {
          if (typeof console !== 'undefined') {
            console.warn('img not found for', fillImgUrl);
          }
        } else {
          ctx.fillStyle = ctx.createPattern(fillTexture, 'repeat');
          if (style['polygonPatternDx'] || style['polygonPatternDy']) {
            ctx.fillStyle['polygonPatternOffset'] = [style['polygonPatternDx'], style['polygonPatternDy']];
          }
        }
      } else if (isGradient(fill)) {
        if (style['polygonGradientExtent']) {
          ctx.fillStyle = Canvas._createGradient(ctx, fill, style['polygonGradientExtent']);
        } else {
          ctx.fillStyle = 'rgba(255,255,255,0)';
        }
      } else {
          if (Array.isArray(fill)) {
            fill = Canvas.normalizeColorToRGBA(fill);
          }
          ctx.fillStyle = fill;
        }
    },
    _createGradient: function _createGradient(ctx, g, extent) {
      var gradient = null,
        places = g['places'];
      var min = extent.getMin(),
        max = extent.getMax(),
        width = extent.getWidth(),
        height = extent.getHeight();
      if (!g['type'] || g['type'] === 'linear') {
        if (!places) {
          places = [min.x, min.y, max.x, min.y];
        } else {
          if (places.length !== 4) {
            throw new Error('A linear gradient\'s places should have 4 numbers.');
          }
          places = [min.x + places[0] * width, min.y + places[1] * height, min.x + places[2] * width, min.y + places[3] * height];
        }
        gradient = ctx.createLinearGradient.apply(ctx, places);
      } else if (g['type'] === 'radial') {
        if (!places) {
          var c = extent.getCenter()._round();
          places = [c.x, c.y, Math.abs(c.x - min.x), c.x, c.y, 0];
        } else {
          if (places.length !== 6) {
            throw new Error('A radial gradient\'s places should have 6 numbers.');
          }
          places = [min.x + places[0] * width, min.y + places[1] * height, width * places[2], min.x + places[3] * width, min.y + places[4] * height, width * places[5]];
        }
        gradient = ctx.createRadialGradient.apply(ctx, places);
      }
      g['colorStops'].forEach(function (stop) {
        gradient.addColorStop.apply(gradient, stop);
      });
      return gradient;
    },
    _setStrokePattern: function _setStrokePattern(ctx, strokePattern, strokeWidth, linePatternOffset, resources) {
      var imgUrl = extractImageUrl(strokePattern);
      var imageTexture;
      if (IS_NODE) {
        imageTexture = resources.getImage([imgUrl, null, strokeWidth]);
      } else {
        var key = imgUrl + '-texture-' + strokeWidth;
        imageTexture = resources.getImage(key);
        if (!imageTexture) {
          var imageRes = resources.getImage([imgUrl, null, null]);
          if (imageRes) {
            var w;
            if (!imageRes.width || !imageRes.height) {
              w = strokeWidth;
            } else {
              w = Math.round(imageRes.width * strokeWidth / imageRes.height);
            }
            var patternCanvas = Canvas.createCanvas(w, strokeWidth, ctx.canvas.constructor);
            Canvas.image(patternCanvas.getContext('2d'), imageRes, 0, 0, w, strokeWidth);
            resources.addResource([key, null, strokeWidth], patternCanvas);
            imageTexture = patternCanvas;
          }
        }
      }
      if (imageTexture) {
        ctx.strokeStyle = ctx.createPattern(imageTexture, 'repeat');
        ctx.strokeStyle['linePatternOffset'] = linePatternOffset;
      } else if (typeof console !== 'undefined') {
        console.warn('img not found for', imgUrl);
      }
    },
    clearRect: function clearRect(ctx, x1, y1, x2, y2) {
      ctx.canvas._drawn = false;
      ctx.clearRect(x1, y1, x2, y2);
    },
    fillCanvas: function fillCanvas(ctx, fillOpacity, x, y) {
      if (hitTesting) {
        fillOpacity = 1;
      }
      ctx.canvas._drawn = true;
      if (fillOpacity === 0) {
        return;
      }
      var isPattern = Canvas._isPattern(ctx.fillStyle);
      var offset = ctx.fillStyle && ctx.fillStyle['polygonPatternOffset'];
      var dx = offset ? offset[0] : 0,
        dy = offset ? offset[1] : 0;
      if (isNil(fillOpacity)) {
        fillOpacity = 1;
      }
      var alpha;
      if (fillOpacity < 1) {
        alpha = ctx.globalAlpha;
        ctx.globalAlpha *= fillOpacity;
      }
      if (isPattern) {
        x = x || 0;
        y = y || 0;
        ctx.translate(x + dx, y + dy);
      }
      ctx.fill();
      if (isPattern) {
        ctx.translate(-x - dx, -y - dy);
      }
      if (fillOpacity < 1) {
        ctx.globalAlpha = alpha;
      }
    },
    getRgba: function getRgba(color, op) {
      if (isNil(op)) {
        op = 1;
      }
      if (color[0] !== '#') {
        if (Array.isArray(color)) {
          color = Canvas.normalizeColorToRGBA(color, op);
        }
        return color;
      }
      var r, g, b;
      if (color.length === 7) {
        r = parseInt(color.substring(1, 3), 16);
        g = parseInt(color.substring(3, 5), 16);
        b = parseInt(color.substring(5, 7), 16);
      } else {
        r = parseInt(color.substring(1, 2), 16) * 17;
        g = parseInt(color.substring(2, 3), 16) * 17;
        b = parseInt(color.substring(3, 4), 16) * 17;
      }
      return 'rgba(' + r + ',' + g + ',' + b + ',' + op + ')';
    },
    normalizeColorToRGBA: function normalizeColorToRGBA(fill, opacity) {
      if (opacity === void 0) {
        opacity = 1;
      }
      return "rgba(" + fill[0] * 255 + "," + fill[1] * 255 + "," + fill[2] * 255 + "," + (fill.length === 4 ? fill[3] : 1) * opacity + ")";
    },
    image: function image(ctx, img, x, y, width, height) {
      ctx.canvas._drawn = true;
      try {
        if (isNumber(width) && isNumber(height)) {
          ctx.drawImage(img, x, y, width, height);
        } else {
          ctx.drawImage(img, x, y);
        }
      } catch (error) {
        if (console) {
          console.warn('error when drawing image on canvas:', error);
          console.warn(img);
        }
      }
    },
    text: function text(ctx, _text, pt, style, textDesc) {
      return Canvas._textOnMultiRow(ctx, textDesc['rows'], style, pt, textDesc['size'], textDesc['rawSize']);
    },
    _textOnMultiRow: function _textOnMultiRow(ctx, texts, style, point, splitTextSize, textSize) {
      var ptAlign = getAlignPoint(splitTextSize, style['textHorizontalAlignment'], style['textVerticalAlignment']),
        lineHeight = textSize['height'] + style['textLineSpacing'],
        basePoint = point.add(0, ptAlign.y),
        maxHeight = style['textMaxHeight'];
      var text,
        rowAlign,
        height = 0;
      resetBBOX(BBOX_TEMP);
      for (var i = 0, len = texts.length; i < len; i++) {
        text = texts[i]['text'];
        rowAlign = getAlignPoint(texts[i]['size'], style['textHorizontalAlignment'], style['textVerticalAlignment']);
        var _point = basePoint.add(rowAlign.x, i * lineHeight);
        Canvas._textOnLine(ctx, text, _point, style['textHaloRadius'], style['textHaloFill'], style['textHaloOpacity']);
        var _textSize = texts[i].size;
        var minx = _point.x,
          miny = _point.y,
          maxx = minx + _textSize.width,
          maxy = miny + _textSize.height;
        setBBOX(BBOX_TEMP, minx, miny, maxx, maxy);
        if (maxHeight > 0) {
          height += lineHeight;
          if (height + _textSize['height'] >= maxHeight) {
            break;
          }
        }
      }
      return BBOX_TEMP;
    },
    _textOnLine: function _textOnLine(ctx, text, pt, textHaloRadius, textHaloFill, textHaloAlpha) {
      if (hitTesting) {
        textHaloAlpha = 1;
      }
      var drawHalo = textHaloAlpha !== 0 && textHaloRadius !== 0;
      ctx.textBaseline = 'top';
      var gco, fill;
      var shadowBlur = ctx.shadowBlur,
        shadowOffsetX = ctx.shadowOffsetX,
        shadowOffsetY = ctx.shadowOffsetY;
      if (drawHalo) {
        var alpha = ctx.globalAlpha;
        ctx.globalAlpha *= textHaloAlpha;
        ctx.miterLimit = 2;
        ctx.lineJoin = 'round';
        ctx.lineCap = 'round';
        ctx.lineWidth = textHaloRadius * 2;
        if (Array.isArray(textHaloFill)) {
          textHaloFill = Canvas.normalizeColorToRGBA(textHaloFill);
        }
        ctx.strokeStyle = textHaloFill;
        ctx.strokeText(text, pt.x, pt.y + textOffsetY);
        ctx.miterLimit = 10;
        ctx.globalAlpha = alpha;
        gco = ctx.globalCompositeOperation;
        ctx.globalCompositeOperation = 'destination-out';
        fill = ctx.fillStyle;
        ctx.fillStyle = '#000';
      }
      if (shadowBlur && drawHalo) {
        ctx.shadowBlur = ctx.shadowOffsetX = ctx.shadowOffsetY = 0;
      }
      Canvas.fillText(ctx, text, pt);
      if (gco) {
        ctx.globalCompositeOperation = gco;
        Canvas.fillText(ctx, text, pt, fill);
        if (shadowBlur) {
          ctx.shadowBlur = shadowBlur;
          ctx.shadowOffsetX = shadowOffsetX;
          ctx.shadowOffsetY = shadowOffsetY;
        }
      }
    },
    fillText: function fillText(ctx, text, pt, rgba) {
      ctx.canvas._drawn = true;
      if (rgba) {
        ctx.fillStyle = rgba;
      }
      ctx.fillText(text, pt.x, pt.y + textOffsetY);
    },
    _stroke: function _stroke(ctx, strokeOpacity, x, y) {
      if (hitTesting) {
        strokeOpacity = 1;
      }
      ctx.canvas._drawn = true;
      if (strokeOpacity === 0) {
        return;
      }
      var offset = ctx.strokeStyle && ctx.strokeStyle['linePatternOffset'];
      var dx = offset ? offset[0] : 0,
        dy = offset ? offset[1] : 0;
      var isPattern = Canvas._isPattern(ctx.strokeStyle) && (!isNil(x) && !isNil(y) || !isNil(dx) && !isNil(dy));
      if (isNil(strokeOpacity)) {
        strokeOpacity = 1;
      }
      var alpha;
      if (strokeOpacity < 1) {
        alpha = ctx.globalAlpha;
        ctx.globalAlpha *= strokeOpacity;
      }
      if (isPattern) {
        x = x || 0;
        y = y || 0;
        ctx.translate(x + dx, y + dy);
      }
      ctx.stroke();
      if (isPattern) {
        ctx.translate(-x - dx, -y - dy);
      }
      if (strokeOpacity < 1) {
        ctx.globalAlpha = alpha;
      }
    },
    _path: function _path(ctx, points, lineDashArray, lineOpacity, ignoreStrokePattern) {
      if (!isArrayHasData(points)) {
        return;
      }
      function fillWithPattern(p1, p2) {
        var degree = computeDegree(p1.x, p1.y, p2.x, p2.y);
        ctx.save();
        var cosd = Math.cos(degree);
        if (Math.abs(cosd) < 1E-7) {
          ctx.translate(p1.x - ctx.lineWidth / 2, p1.y);
        } else {
          ctx.translate(p1.x, p1.y - ctx.lineWidth / 2 / cosd);
        }
        ctx.rotate(degree);
        Canvas._stroke(ctx, lineOpacity);
        ctx.restore();
      }
      var isDashed = isArrayHasData(lineDashArray);
      var isPatternLine = ignoreStrokePattern === true ? false : Canvas._isPattern(ctx.strokeStyle);
      var point, prePoint, nextPoint;
      for (var i = 0, len = points.length; i < len; i++) {
        point = points[i];
        if (!isDashed || ctx.setLineDash) {
          ctx.lineTo(point.x, point.y);
          if (isPatternLine && i > 0) {
            prePoint = points[i - 1];
            fillWithPattern(prePoint, point);
            ctx.beginPath();
            ctx.moveTo(point.x, point.y);
          }
        } else if (isDashed) {
          if (i === len - 1) {
            break;
          }
          nextPoint = points[i + 1];
          drawDashLine(ctx, point, nextPoint, lineDashArray, isPatternLine);
        }
      }
    },
    path: function path(ctx, points, lineOpacity, fillOpacity, lineDashArray) {
      if (!isArrayHasData(points)) {
        return;
      }
      ctx.beginPath();
      ctx.moveTo(points[0].x, points[0].y);
      Canvas._path(ctx, points, lineDashArray, lineOpacity);
      Canvas._stroke(ctx, lineOpacity);
    },
    _multiClip: function _multiClip(ctx, points) {
      if (!points || points.length === 0) return;
      points = points[0];
      for (var i = 0, len = points.length; i < len; i++) {
        var point = points[i];
        var x = point.x,
          y = point.y;
        if (i === 0) {
          ctx.moveTo(x, y);
        } else {
          ctx.lineTo(x, y);
        }
        if (i === len - 1) {
          x = points[0].x;
          y = points[0].y;
          ctx.lineTo(x, y);
        }
      }
    },
    polygon: function polygon(ctx, points, lineOpacity, fillOpacity, lineDashArray, smoothness) {
      if (ctx.isMultiClip) {
        Canvas._multiClip(ctx, points);
        return;
      }
      if (ctx.isClip) {
        Canvas._multiClip(ctx, Array.isArray(points[0]) ? points : [points]);
        return;
      }
      if (!isArrayHasData(points)) {
        return;
      }
      var isPatternLine = Canvas._isPattern(ctx.strokeStyle),
        fillFirst = isArrayHasData(lineDashArray) && !ctx.setLineDash || isPatternLine && !smoothness;
      if (!isArrayHasData(points[0])) {
        points = [points];
      }
      var savedCtx = ctx;
      if (points.length > 1 && !IS_NODE) {
        if (!TEMP_CANVAS) {
          TEMP_CANVAS = Canvas.createCanvas(1, 1);
        }
        ctx.canvas._drawn = false;
        TEMP_CANVAS.width = ctx.canvas.width;
        TEMP_CANVAS.height = ctx.canvas.height;
        ctx = TEMP_CANVAS.getContext('2d');
        setLineDash(ctx, []);
        setLineDash(ctx, lineDashArray);
        copyProperties(ctx, savedCtx);
      }
      var op, i, len;
      if (fillFirst) {
        ctx.save();
        for (i = 0, len = points.length; i < len; i++) {
          if (!isArrayHasData(points[i])) {
            continue;
          }
          Canvas._ring(ctx, points[i], null, 0, true);
          op = fillOpacity;
          if (i > 0) {
            ctx.globalCompositeOperation = 'destination-out';
            op = 1;
          }
          Canvas.fillCanvas(ctx, op, points[i][0].x, points[i][0].y);
          if (i > 0) {
            ctx.globalCompositeOperation = 'source-over';
          } else if (len > 1) {
            ctx.fillStyle = '#fff';
          }
          Canvas._stroke(ctx, 0);
        }
        ctx.restore();
      }
      var fillStyle = ctx.fillStyle;
      for (i = 0, len = points.length; i < len; i++) {
        if (!isArrayHasData(points[i])) {
          continue;
        }
        if (smoothness) {
          Canvas.paintSmoothLine(ctx, points[i], lineOpacity, smoothness, true);
          ctx.closePath();
        } else {
          Canvas._ring(ctx, points[i], lineDashArray, lineOpacity);
        }
        if (!fillFirst) {
          op = fillOpacity;
          if (i > 0) {
            ctx.globalCompositeOperation = 'destination-out';
            op = 1;
          }
          Canvas.fillCanvas(ctx, op, points[i][0].x, points[i][0].y);
          if (i > 0) {
            ctx.globalCompositeOperation = 'source-over';
          } else if (len > 1) {
            ctx.fillStyle = '#fff';
          }
        }
        Canvas._stroke(ctx, lineOpacity);
      }
      if (ctx.fillStyle !== fillStyle) {
        ctx.fillStyle = fillStyle;
      }
      if (points.length > 1 && !IS_NODE) {
        savedCtx.drawImage(TEMP_CANVAS, 0, 0);
        savedCtx.canvas._drawn = ctx.canvas._drawn;
        copyProperties(savedCtx, ctx);
      }
    },
    _ring: function _ring(ctx, ring, lineDashArray, lineOpacity, ignorePattern) {
      var isPattern = Canvas._isPattern(ctx.strokeStyle);
      if (!ignorePattern && isPattern && !ring[0].equals(ring[ring.length - 1])) {
        ring = ring.concat([ring[0]]);
      }
      ctx.beginPath();
      ctx.moveTo(ring[0].x, ring[0].y);
      Canvas._path(ctx, ring, lineDashArray, lineOpacity, ignorePattern);
      if (!isPattern) {
        ctx.closePath();
      }
    },
    paintSmoothLine: function paintSmoothLine(ctx, points, lineOpacity, smoothValue, close, tailIdx, tailRatio) {
      if (!points) {
        return;
      }
      if (points.length <= 2 || !smoothValue) {
        Canvas.path(ctx, points, lineOpacity);
        return;
      }
      function interpolate$$1(t0, t1, x1, y1, bx1, by1, bx2, by2, x2, y2) {
        var u0 = 1.0 - t0;
        var u1 = 1.0 - t1;
        var qxa = x1 * u0 * u0 + bx1 * 2 * t0 * u0 + bx2 * t0 * t0;
        var qxb = x1 * u1 * u1 + bx1 * 2 * t1 * u1 + bx2 * t1 * t1;
        var qxc = bx1 * u0 * u0 + bx2 * 2 * t0 * u0 + x2 * t0 * t0;
        var qxd = bx1 * u1 * u1 + bx2 * 2 * t1 * u1 + x2 * t1 * t1;
        var qya = y1 * u0 * u0 + by1 * 2 * t0 * u0 + by2 * t0 * t0;
        var qyb = y1 * u1 * u1 + by1 * 2 * t1 * u1 + by2 * t1 * t1;
        var qyc = by1 * u0 * u0 + by2 * 2 * t0 * u0 + y2 * t0 * t0;
        var qyd = by1 * u1 * u1 + by2 * 2 * t1 * u1 + y2 * t1 * t1;
        var xb = qxa * u1 + qxc * t1;
        var xc = qxb * u0 + qxd * t0;
        var xd = qxb * u1 + qxd * t1;
        var yb = qya * u1 + qyc * t1;
        var yc = qyb * u0 + qyd * t0;
        var yd = qyb * u1 + qyd * t1;
        return [xb, yb, xc, yc, xd, yd];
      }
      function getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, t) {
        var xc1 = (x0 + x1) / 2.0,
          yc1 = (y0 + y1) / 2.0;
        var xc2 = (x1 + x2) / 2.0,
          yc2 = (y1 + y2) / 2.0;
        var xc3 = (x2 + x3) / 2.0,
          yc3 = (y2 + y3) / 2.0;
        var len1 = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
        var len2 = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        var len3 = Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));
        var k1 = len1 / (len1 + len2);
        var k2 = len2 / (len2 + len3);
        var xm1 = xc1 + (xc2 - xc1) * k1,
          ym1 = yc1 + (yc2 - yc1) * k1;
        var xm2 = xc2 + (xc3 - xc2) * k2,
          ym2 = yc2 + (yc3 - yc2) * k2;
        var ctrl1X = xm1 + (xc2 - xm1) * smoothValue + x1 - xm1,
          ctrl1Y = ym1 + (yc2 - ym1) * smoothValue + y1 - ym1,
          ctrl2X = xm2 + (xc2 - xm2) * smoothValue + x2 - xm2,
          ctrl2Y = ym2 + (yc2 - ym2) * smoothValue + y2 - ym2;
        var ctrlPoints = [ctrl1X, ctrl1Y, ctrl2X, ctrl2Y];
        if (t < 1) {
          return interpolate$$1(0, t, x1, y1, ctrl1X, ctrl1Y, ctrl2X, ctrl2Y, x2, y2);
        } else {
          return ctrlPoints;
        }
      }
      var count = points.length;
      var l = close ? count : count - 1;
      ctx.beginPath();
      ctx.moveTo(points[0].x, points[0].y);
      if (tailRatio !== undefined) l -= Math.max(l - tailIdx - 1, 0);
      var preCtrlPoints;
      for (var i = 0; i < l; i++) {
        var x1 = points[i].x,
          y1 = points[i].y;
        var x0 = void 0,
          y0 = void 0,
          x2 = void 0,
          y2 = void 0,
          x3 = void 0,
          y3 = void 0;
        if (i - 1 < 0) {
          if (!close) {
            x0 = points[i + 1].x;
            y0 = points[i + 1].y;
          } else {
            x0 = points[l - 1].x;
            y0 = points[l - 1].y;
          }
        } else {
          x0 = points[i - 1].x;
          y0 = points[i - 1].y;
        }
        if (i + 1 < count) {
          x2 = points[i + 1].x;
          y2 = points[i + 1].y;
        } else {
          x2 = points[i + 1 - count].x;
          y2 = points[i + 1 - count].y;
        }
        if (i + 2 < count) {
          x3 = points[i + 2].x;
          y3 = points[i + 2].y;
        } else if (!close) {
          x3 = points[i].x;
          y3 = points[i].y;
        } else {
          x3 = points[i + 2 - count].x;
          y3 = points[i + 2 - count].y;
        }
        var ctrlPoints = getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, i === l - 1 ? tailRatio : 1);
        if (i === l - 1 && tailRatio >= 0 && tailRatio < 1) {
          ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], ctrlPoints[4], ctrlPoints[5]);
          points.splice(l - 1, count - (l - 1) - 1);
          var lastPoint = new Point(ctrlPoints[4], ctrlPoints[5]);
          lastPoint.prevCtrlPoint = new Point(ctrlPoints[2], ctrlPoints[3]);
          points.push(lastPoint);
          count = points.length;
        } else {
          ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], x2, y2);
        }
        points[i].nextCtrlPoint = ctrlPoints.slice(0, 2);
        points[i].prevCtrlPoint = preCtrlPoints ? preCtrlPoints.slice(2) : null;
        preCtrlPoints = ctrlPoints;
      }
      if (!close && points[1].prevCtrlPoint) {
        points[0].nextCtrlPoint = points[1].prevCtrlPoint;
        delete points[0].prevCtrlPoint;
      }
      if (!points[count - 1].prevCtrlPoint) {
        points[count - 1].prevCtrlPoint = points[count - 2].nextCtrlPoint;
      }
      Canvas._stroke(ctx, lineOpacity);
    },
    _arcBetween: function _arcBetween(ctx, p1, p2, degree) {
      var a = degree,
        dist = p1.distanceTo(p2),
        r = dist / 2 / Math.sin(a / 2);
      var p1p2 = Math.asin((p2.y - p1.y) / dist);
      if (p1.x > p2.x) {
        p1p2 = Math.PI - p1p2;
      }
      var cp2 = 90 * RADIAN - a / 2,
        da = p1p2 - cp2;
      var dx = Math.cos(da) * r,
        dy = Math.sin(da) * r,
        cx = p1.x + dx,
        cy = p1.y + dy;
      var startAngle = Math.asin((p2.y - cy) / r);
      if (cx > p2.x) {
        startAngle = Math.PI - startAngle;
      }
      var endAngle = startAngle + a;
      ctx.beginPath();
      ctx.arc(cx, cy, r, startAngle, endAngle);
      return [cx, cy];
    },
    _lineTo: function _lineTo(ctx, p) {
      ctx.lineTo(p.x, p.y);
    },
    bezierCurveAndFill: function bezierCurveAndFill(ctx, points, lineOpacity, fillOpacity) {
      ctx.beginPath();
      var start = points[0];
      ctx.moveTo(start.x, start.y);
      var args = [ctx];
      args.push.apply(args, points.splice(1));
      Canvas._bezierCurveTo.apply(Canvas, args);
      Canvas.fillCanvas(ctx, fillOpacity);
      Canvas._stroke(ctx, lineOpacity);
    },
    _bezierCurveTo: function _bezierCurveTo(ctx, p1, p2, p3) {
      ctx.bezierCurveTo(p1.x, p1.y, p2.x, p2.y, p3.x, p3.y);
    },
    ellipse: function ellipse(ctx, pt, width, heightTop, heightBottom, lineOpacity, fillOpacity) {
      function bezierEllipse(x, y, a, b, b1) {
        var k = 0.5522848,
          ox = a * k,
          oy = b * k,
          oy1 = b1 * k;
        ctx.moveTo(x - a, y);
        ctx.bezierCurveTo(x - a, y - oy, x - ox, y - b, x, y - b);
        ctx.bezierCurveTo(x + ox, y - b, x + a, y - oy, x + a, y);
        ctx.bezierCurveTo(x + a, y + oy1, x + ox, y + b1, x, y + b1);
        ctx.bezierCurveTo(x - ox, y + b1, x - a, y + oy1, x - a, y);
        ctx.closePath();
      }
      ctx.beginPath();
      if (width === heightTop && width === heightBottom) {
        ctx.arc(pt.x, pt.y, width, 0, 2 * Math.PI);
      } else if (ctx.ellipse) {
        if (heightTop !== heightBottom) {
          ctx.ellipse(pt.x, pt.y, width, heightTop, 0, RADIAN * 180, RADIAN * 360, false);
          ctx.ellipse(pt.x, pt.y, width, heightBottom, 0, 0, RADIAN * 180, false);
        } else {
          ctx.ellipse(pt.x, pt.y, width, heightTop, 0, 0, RADIAN * 360, false);
        }
      } else {
        bezierEllipse(pt.x, pt.y, width, heightTop, heightBottom);
      }
      Canvas.fillCanvas(ctx, fillOpacity, pt.x - width, pt.y - heightTop);
      Canvas._stroke(ctx, lineOpacity, pt.x - width, pt.y - heightTop);
    },
    rectangle: function rectangle(ctx, pt, size, lineOpacity, fillOpacity) {
      var x = pt.x,
        y = pt.y;
      ctx.beginPath();
      ctx.rect(x, y, size['width'], size['height']);
      Canvas.fillCanvas(ctx, fillOpacity, x, y);
      Canvas._stroke(ctx, lineOpacity, x, y);
    },
    sector: function sector(ctx, pt, size, angles, lineOpacity, fillOpacity) {
      var rad = RADIAN;
      var startAngle = angles[0],
        endAngle = angles[1];
      function sector(ctx, x, y, radius, startAngle, endAngle) {
        var sDeg = rad * -endAngle;
        var eDeg = rad * -startAngle;
        ctx.beginPath();
        ctx.moveTo(x, y);
        ctx.arc(x, y, radius, sDeg, eDeg);
        ctx.lineTo(x, y);
        Canvas.fillCanvas(ctx, fillOpacity, x - radius, y - radius);
        Canvas._stroke(ctx, lineOpacity, x - radius, y - radius);
      }
      sector(ctx, pt.x, pt.y, size, startAngle, endAngle);
    },
    _isPattern: function _isPattern(style) {
      return !isString(style) && !('addColorStop' in style);
    },
    drawCross: function drawCross(ctx, x, y, lineWidth, color) {
      ctx.canvas._drawn = true;
      ctx.strokeStyle = color;
      ctx.lineWidth = lineWidth;
      ctx.beginPath();
      ctx.moveTo(x - 5, y);
      ctx.lineTo(x + 5, y);
      ctx.moveTo(x, y - 5);
      ctx.lineTo(x, y + 5);
      ctx.stroke();
    },
    copy: function copy(canvas, c) {
      var target = c || createEl('canvas');
      target.width = canvas.width;
      target.height = canvas.height;
      target.getContext('2d').drawImage(canvas, 0, 0);
      return target;
    },
    pixelRect: function pixelRect(ctx, point, lineOpacity, fillOpacity) {
      var lineWidth = ctx.lineWidth;
      var alpha = ctx.globalAlpha;
      var isStroke = false;
      if (lineWidth > 0 && lineOpacity > 0) {
        isStroke = true;
        if (lineOpacity < 1) {
          ctx.globalAlpha *= lineOpacity;
        }
      } else if (fillOpacity > 0) {
        if (fillOpacity < 1) {
          ctx.globalAlpha *= fillOpacity;
        }
      } else {
        return;
      }
      ctx.canvas._drawn = true;
      if (isStroke) {
        ctx.strokeRect(point[0], point[1], 1, 1);
      } else {
        ctx.fillRect(point[0], point[1], 1, 1);
      }
      if (ctx.globalAlpha !== alpha) {
        ctx.globalAlpha = alpha;
      }
    }
  };
  function drawDashLine(ctx, startPoint, endPoint, dashArray) {
    var fromX = startPoint.x,
      fromY = startPoint.y,
      toX = endPoint.x,
      toY = endPoint.y;
    var pattern = dashArray;
    var lt = function lt(a, b) {
      return a <= b;
    };
    var gt = function gt(a, b) {
      return a >= b;
    };
    var capmin = function capmin(a, b) {
      return Math.min(a, b);
    };
    var capmax = function capmax(a, b) {
      return Math.max(a, b);
    };
    var checkX = {
      thereYet: gt,
      cap: capmin
    };
    var checkY = {
      thereYet: gt,
      cap: capmin
    };
    if (fromY - toY > 0) {
      checkY.thereYet = lt;
      checkY.cap = capmax;
    }
    if (fromX - toX > 0) {
      checkX.thereYet = lt;
      checkX.cap = capmax;
    }
    ctx.moveTo(fromX, fromY);
    var offsetX = fromX;
    var offsetY = fromY;
    var idx = 0,
      dash = true;
    var ang, len;
    while (!(checkX.thereYet(offsetX, toX) && checkY.thereYet(offsetY, toY))) {
      ang = Math.atan2(toY - fromY, toX - fromX);
      len = pattern[idx];
      offsetX = checkX.cap(toX, offsetX + Math.cos(ang) * len);
      offsetY = checkY.cap(toY, offsetY + Math.sin(ang) * len);
      if (dash) {
        ctx.lineTo(offsetX, offsetY);
      } else {
        ctx.moveTo(offsetX, offsetY);
      }
      idx = (idx + 1) % pattern.length;
      dash = !dash;
    }
  }
  var prefix = 'data:image/';
  function extractImageUrl(url) {
    if (url.substring(0, prefix.length) === prefix) {
      return url;
    }
    return extractCssUrl(url);
  }
  function copyProperties(ctx, savedCtx) {
    ctx.filter = savedCtx.filter;
    ctx.fillStyle = savedCtx.fillStyle;
    ctx.globalAlpha = savedCtx.globalAlpha;
    ctx.lineCap = savedCtx.lineCap;
    ctx.lineDashOffset = savedCtx.lineDashOffset;
    ctx.lineJoin = savedCtx.lineJoin;
    ctx.lineWidth = savedCtx.lineWidth;
    ctx.shadowBlur = savedCtx.shadowBlur;
    ctx.shadowColor = savedCtx.shadowColor;
    ctx.shadowOffsetX = savedCtx.shadowOffsetX;
    ctx.shadowOffsetY = savedCtx.shadowOffsetY;
    ctx.strokeStyle = savedCtx.strokeStyle;
  }
  function setLineDash(ctx, lineDashArray) {
    if (!lineDashArray || !ctx.setLineDash || !Array.isArray(lineDashArray)) {
      return;
    }
    ctx.setLineDash(lineDashArray);
  }

  function generateWrapKey(eventType) {
    return 'Z__' + eventType;
  }
  var Eventable = function Eventable(Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      var _proto = _class.prototype;
      _proto.on = function on$$1(eventsOn, handler, context) {
        if (!eventsOn) {
          return this;
        }
        if (!isString(eventsOn)) {
          return this._switch('on', eventsOn, handler);
        }
        if (!handler) {
          return this;
        }
        if (!this._eventMap) {
          this._eventMap = {};
        }
        var eventTypes = eventsOn.toLowerCase().split(' ');
        var evtType;
        if (!context) {
          context = this;
        }
        var isAdd = isNumber(handler._id);
        handler._id = UID();
        var handlerChain;
        for (var ii = 0, ll = eventTypes.length; ii < ll; ii++) {
          evtType = eventTypes[ii];
          var wrapKey = generateWrapKey(evtType);
          if (handler[wrapKey]) {
            handler[wrapKey]._id = handler._id;
          }
          handlerChain = this._eventMap[evtType];
          if (!handlerChain) {
            handlerChain = [];
            this._eventMap[evtType] = handlerChain;
          }
          if (!isAdd) {
            handlerChain.push({
              handler: handler,
              context: context
            });
            continue;
          }
          var l = handlerChain.length;
          if (l > 0) {
            for (var i = 0; i < l; i++) {
              if (handler === handlerChain[i].handler && handlerChain[i].context === context) {
                if (!Browser$1.isTest) {
                  console.warn(this, "find '" + eventsOn + "' handler:", handler, ' The old listener function will be removed');
                }
                return this;
              }
            }
          }
          handlerChain.push({
            handler: handler,
            context: context
          });
        }
        return this;
      };
      _proto.addEventListener = function addEventListener() {
        return this.on.apply(this, arguments);
      };
      _proto.once = function once(eventTypes, handler, context) {
        if (!isString(eventTypes)) {
          var once = {};
          for (var p in eventTypes) {
            if (eventTypes.hasOwnProperty(p)) {
              once[p] = this._wrapOnceHandler(p, eventTypes[p], context);
            }
          }
          return this._switch('on', once);
        }
        var evetTypes = eventTypes.split(' ');
        for (var i = 0, l = evetTypes.length; i < l; i++) {
          this.on(evetTypes[i], this._wrapOnceHandler(evetTypes[i], handler, context));
        }
        return this;
      };
      _proto.off = function off$$1(eventsOff, handler, context) {
        if (!this._eventMap || !eventsOff) {
          return this;
        }
        if (!isString(eventsOff)) {
          return this._switch('off', eventsOff, handler);
        }
        if (!handler) {
          return this;
        }
        if (!isNumber(handler._id)) {
          return this;
        }
        var eventTypes = eventsOff.split(' ');
        var eventType, listeners, wrapKey;
        if (!context) {
          context = this;
        }
        for (var j = 0, jl = eventTypes.length; j < jl; j++) {
          eventType = eventTypes[j].toLowerCase();
          wrapKey = generateWrapKey(eventType);
          listeners = this._eventMap[eventType];
          if (!listeners) {
            continue;
          }
          for (var i = listeners.length - 1; i >= 0; i--) {
            var listener = listeners[i];
            if ((handler === listener.handler || handler === listener.handler[wrapKey]) && listener.context === context) {
              delete listener.handler[wrapKey];
              listeners.splice(i, 1);
            }
          }
          if (!listeners.length) {
            delete this._eventMap[eventType];
          }
        }
        return this;
      };
      _proto.removeEventListener = function removeEventListener() {
        return this.off.apply(this, arguments);
      };
      _proto.listens = function listens(eventType, handler, context) {
        if (!this._eventMap || !isString(eventType)) {
          return 0;
        }
        var handlerChain = this._eventMap[eventType.toLowerCase()];
        if (!handlerChain || !handlerChain.length) {
          return 0;
        }
        if (!handler) {
          return handlerChain.length;
        }
        for (var i = 0, len = handlerChain.length; i < len; i++) {
          if (handler === handlerChain[i].handler && (isNil(context) || handlerChain[i].context === context)) {
            return 1;
          }
        }
        return 0;
      };
      _proto.getListeningEvents = function getListeningEvents() {
        if (!this._eventMap) {
          return [];
        }
        return Object.keys(this._eventMap);
      };
      _proto.copyEventListeners = function copyEventListeners(target) {
        var eventMap = target._eventMap;
        if (!eventMap) {
          return this;
        }
        var handlerChain;
        for (var eventType in eventMap) {
          handlerChain = eventMap[eventType];
          for (var i = 0, len = handlerChain.length; i < len; i++) {
            this.on(eventType, handlerChain[i].handler, handlerChain[i].context);
          }
        }
        return this;
      };
      _proto.fire = function fire() {
        if (this._eventParent) {
          return this._eventParent.fire.apply(this._eventParent, arguments);
        }
        return this._fire.apply(this, arguments);
      };
      _proto._wrapOnceHandler = function _wrapOnceHandler(evtType, handler, context) {
        var key = generateWrapKey(evtType);
        var called = false;
        var fn = function onceHandler() {
          if (called) {
            return;
          }
          delete fn[key];
          called = true;
          if (context) {
            handler.apply(context, arguments);
          } else {
            handler.apply(this, arguments);
          }
          onceHandler._called = true;
        };
        fn[key] = handler;
        return fn;
      };
      _proto._switch = function _switch(to, eventKeys, context) {
        for (var p in eventKeys) {
          if (eventKeys.hasOwnProperty(p)) {
            this[to](p, eventKeys[p], context);
          }
        }
        return this;
      };
      _proto._clearListeners = function _clearListeners(eventType) {
        if (!this._eventMap || !isString(eventType)) {
          return;
        }
        var handlerChain = this._eventMap[eventType.toLowerCase()];
        if (!handlerChain) {
          return;
        }
        this._eventMap[eventType] = null;
      };
      _proto._clearAllListeners = function _clearAllListeners() {
        this._eventMap = null;
      };
      _proto._setEventParent = function _setEventParent(parent) {
        this._eventParent = parent;
        return this;
      };
      _proto._setEventTarget = function _setEventTarget(target) {
        this._eventTarget = target;
        return this;
      };
      _proto._fire = function _fire(eventType, param) {
        if (!this._eventMap) {
          return this;
        }
        eventType = eventType.toLowerCase();
        var handlerChain = this._eventMap[eventType];
        if (!handlerChain) {
          return this;
        }
        if (!param) {
          param = {};
        }
        param['type'] = eventType;
        param['target'] = this._eventTarget || this;
        var queue = handlerChain.slice(0);
        var context, bubble, passed;
        for (var i = 0, len = queue.length; i < len; i++) {
          if (!queue[i]) {
            continue;
          }
          var handler = queue[i].handler;
          if (handler._called) {
            continue;
          }
          context = queue[i].context;
          bubble = true;
          passed = extend({}, param);
          if (context) {
            bubble = queue[i].handler.call(context, passed);
          } else {
            bubble = queue[i].handler(passed);
          }
          if (bubble === false) {
            if (param['domEvent']) {
              stopPropagation(param['domEvent']);
            }
          }
        }
        var eventQueue = this._eventMap[eventType];
        if (eventQueue) {
          var queueExcludeOnce = [];
          for (var _i = 0, _len = eventQueue.length; _i < _len; _i++) {
            var _handler = eventQueue[_i].handler;
            if (!_handler._called) {
              queueExcludeOnce.push(eventQueue[_i]);
            }
          }
          this._eventMap[eventType] = queueExcludeOnce;
        }
        return this;
      };
      return _class;
    }(Base);
  };

  var Handler = function () {
    function Handler(target) {
      this.target = target;
    }
    var _proto = Handler.prototype;
    _proto.enable = function enable() {
      if (this._enabled) {
        return this;
      }
      this._enabled = true;
      this.addHooks();
      return this;
    };
    _proto.disable = function disable() {
      if (!this._enabled) {
        return this;
      }
      this._enabled = false;
      this.removeHooks();
      return this;
    };
    _proto.enabled = function enabled() {
      return !!this._enabled;
    };
    _proto.remove = function remove() {
      this.disable();
      delete this.target;
      delete this.dom;
    };
    return Handler;
  }();
  var Handler$1 = Eventable(Handler);

  var Class = function () {
    function Class(options) {
      if (!this || !this.setOptions) {
        throw new Error('Class instance is being created without "new" operator.');
      }
      this.setOptions(options);
      this.callInitHooks();
      this._isUpdatingOptions = false;
    }
    var _proto = Class.prototype;
    _proto.proxyOptions = function proxyOptions() {
      var _this = this;
      if (!Browser$1.proxy) {
        return this;
      }
      if (this.options.isExtensible) {
        return this;
      }
      this.options = new Proxy(this.options, {
        set: function set(target, key, value) {
          if (target[key] === value) {
            return true;
          }
          target[key] = value;
          if (_this._isUpdatingOptions) {
            return true;
          }
          var opts = {};
          opts[key] = value;
          _this.config(opts);
          return true;
        }
      });
      return this;
    };
    _proto.callInitHooks = function callInitHooks() {
      var proto = Object.getPrototypeOf(this);
      this._visitInitHooks(proto);
      return this;
    };
    _proto.setOptions = function setOptions(options) {
      if (!this.hasOwnProperty('options')) {
        this.options = this.options ? Object.create(this.options) : {};
      }
      if (!options) {
        return this;
      }
      for (var i in options) {
        this.options[i] = options[i];
      }
      return this;
    };
    _proto.config = function config(conf) {
      this._isUpdatingOptions = true;
      if (!conf) {
        var config = {};
        for (var p in this.options) {
          if (this.options.hasOwnProperty(p)) {
            config[p] = this.options[p];
          }
        }
        this._isUpdatingOptions = false;
        return config;
      } else {
        if (arguments.length === 2) {
          var t = {};
          t[conf] = arguments[1];
          conf = t;
        }
        for (var i in conf) {
          this.options[i] = conf[i];
          if (this[i] && this[i] instanceof Handler$1) {
            if (conf[i]) {
              this[i].enable();
            } else {
              this[i].disable();
            }
          }
        }
        this.onConfig(conf);
        this._isUpdatingOptions = false;
      }
      return this;
    };
    _proto.onConfig = function onConfig() {};
    _proto._visitInitHooks = function _visitInitHooks(proto) {
      if (this._initHooksCalled) {
        return;
      }
      var parentProto = Object.getPrototypeOf(proto);
      if (parentProto._visitInitHooks) {
        parentProto._visitInitHooks.call(this, parentProto);
      }
      this._initHooksCalled = true;
      var hooks = proto._initHooks;
      if (hooks && hooks !== parentProto._initHooks) {
        for (var i = 0; i < hooks.length; i++) {
          hooks[i].call(this);
        }
      }
    };
    Class.addInitHook = function addInitHook(fn) {
      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
      }
      var init = typeof fn === 'function' ? fn : function () {
        this[fn].apply(this, args);
      };
      var proto = this.prototype;
      var parentProto = Object.getPrototypeOf(proto);
      if (!proto._initHooks || proto._initHooks === parentProto._initHooks) {
        proto._initHooks = [];
      }
      proto._initHooks.push(init);
      return this;
    };
    Class.include = function include() {
      for (var i = 0; i < arguments.length; i++) {
        extend(this.prototype, i < 0 || arguments.length <= i ? undefined : arguments[i]);
      }
      return this;
    };
    Class.mergeOptions = function mergeOptions(options) {
      var proto = this.prototype;
      var parentProto = Object.getPrototypeOf(proto);
      if (!proto.options || proto.options === parentProto.options) {
        proto.options = proto.options ? Object.create(proto.options) : {};
      }
      extend(proto.options, options);
      return this;
    };
    return Class;
  }();

  var Base = function Base() {};
  var GlobalEventable = function (_Eventable) {
    _inheritsLoose(GlobalEventable, _Eventable);
    function GlobalEventable() {
      return _Eventable.apply(this, arguments) || this;
    }
    return GlobalEventable;
  }(Eventable(Base));
  var GlobalEvent = new GlobalEventable();
  var EVENT_DPR_CHANGE = 'dprchange';
  var EVENT_DOC_VISIBILITY_CHANGE = 'docvisibilitychange';
  var EVENT_DOC_DRAGSTART = 'dragstart';
  var EVENT_DOC_DRAGEND = 'dragend';
  if (typeof window !== 'undefined' && window.matchMedia) {
    for (var i = 1; i < 500; i++) {
      var dpi = (i * 0.01).toFixed(2);
      var screen$1 = window.matchMedia("screen and (resolution: " + dpi + "dppx)");
      if (screen$1) {
        if (screen$1.addEventListener) {
          screen$1.addEventListener('change', Browser$1.checkDevicePixelRatio);
        } else if (screen$1.addListener) {
          screen$1.addListener(Browser$1.checkDevicePixelRatio);
        }
      }
    }
  }
  if (Browser$1.devicePixelRatio) {
    var tempDPI = Browser$1.devicePixelRatio;
    Object.defineProperty(Browser$1, 'devicePixelRatio', {
      get: function get() {
        return tempDPI;
      },
      set: function set(value) {
        if (value === tempDPI) {
          return;
        }
        tempDPI = value;
        if (!Browser$1.monitorDPRChange) {
          return;
        }
        GlobalEvent.fire(EVENT_DPR_CHANGE, {
          devicePixelRatio: value
        });
      }
    });
  }
  if (Browser$1.webgl && typeof document !== 'undefined') {
    addDomEvent(document, 'visibilitychange', function () {
      GlobalEvent.fire(EVENT_DOC_VISIBILITY_CHANGE, {
        visibilityState: document.visibilityState
      });
    });
    addDomEvent(document, 'dragstart', function () {
      GlobalEvent.fire(EVENT_DOC_DRAGSTART);
    });
    addDomEvent(document, 'dragend', function () {
      GlobalEvent.fire(EVENT_DOC_DRAGEND);
    });
  }

  var registeredTypes = {};
  var JSONAble = (function (Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      _class.registerJSONType = function registerJSONType(type) {
        if (!type) {
          return this;
        }
        if (registeredTypes[type]) {
          console.error(type + " has register. please use Different name for:", this);
          return this;
        }
        registeredTypes[type] = this;
        return this;
      };
      _class.getJSONClass = function getJSONClass(type) {
        if (!type) {
          return null;
        }
        return registeredTypes[type];
      };
      var _proto = _class.prototype;
      _proto.getJSONType = function getJSONType() {
        if (this._jsonType === undefined) {
          var clazz = Object.getPrototypeOf(this).constructor;
          for (var p in registeredTypes) {
            if (registeredTypes[p] === clazz) {
              this._jsonType = p;
              break;
            }
          }
        }
        if (!this._jsonType) {
          throw new Error('Found an unregistered Layer/Geometry class!');
        }
        return this._jsonType;
      };
      return _class;
    }(Base);
  });

  var quickselect = createCommonjsModule(function (module, exports) {
    (function (global, factory) {
      module.exports = factory();
    })(commonjsGlobal, function () {

      function quickselect(arr, k, left, right, compare) {
        quickselectStep(arr, k, left || 0, right || arr.length - 1, compare || defaultCompare);
      }
      function quickselectStep(arr, k, left, right, compare) {
        while (right > left) {
          if (right - left > 600) {
            var n = right - left + 1;
            var m = k - left + 1;
            var z = Math.log(n);
            var s = 0.5 * Math.exp(2 * z / 3);
            var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
            var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
            var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
            quickselectStep(arr, k, newLeft, newRight, compare);
          }
          var t = arr[k];
          var i = left;
          var j = right;
          swap(arr, left, k);
          if (compare(arr[right], t) > 0) swap(arr, left, right);
          while (i < j) {
            swap(arr, i, j);
            i++;
            j--;
            while (compare(arr[i], t) < 0) {
              i++;
            }
            while (compare(arr[j], t) > 0) {
              j--;
            }
          }
          if (compare(arr[left], t) === 0) swap(arr, left, j);else {
            j++;
            swap(arr, j, right);
          }
          if (j <= k) left = j + 1;
          if (k <= j) right = j - 1;
        }
      }
      function swap(arr, i, j) {
        var tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
      }
      function defaultCompare(a, b) {
        return a < b ? -1 : a > b ? 1 : 0;
      }
      return quickselect;
    });
  });

  var rbush_1 = rbush;
  var default_1 = rbush;
  function rbush(maxEntries, format) {
    if (!(this instanceof rbush)) return new rbush(maxEntries, format);
    this._maxEntries = Math.max(4, maxEntries || 9);
    this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
    if (format) {
      this._initFormat(format);
    }
    this.clear();
  }
  rbush.prototype = {
    all: function all() {
      return this._all(this.data, []);
    },
    search: function search(bbox) {
      var node = this.data,
        result = [],
        toBBox = this.toBBox;
      if (!intersects(bbox, node)) return result;
      var nodesToSearch = [],
        i,
        len,
        child,
        childBBox;
      while (node) {
        for (i = 0, len = node.children.length; i < len; i++) {
          child = node.children[i];
          childBBox = node.leaf ? toBBox(child) : child;
          if (intersects(bbox, childBBox)) {
            if (node.leaf) result.push(child);else if (contains(bbox, childBBox)) this._all(child, result);else nodesToSearch.push(child);
          }
        }
        node = nodesToSearch.pop();
      }
      return result;
    },
    collides: function collides(bbox) {
      var node = this.data,
        toBBox = this.toBBox;
      if (!intersects(bbox, node)) return false;
      var nodesToSearch = [],
        i,
        len,
        child,
        childBBox;
      while (node) {
        for (i = 0, len = node.children.length; i < len; i++) {
          child = node.children[i];
          childBBox = node.leaf ? toBBox(child) : child;
          if (intersects(bbox, childBBox)) {
            if (node.leaf || contains(bbox, childBBox)) return true;
            nodesToSearch.push(child);
          }
        }
        node = nodesToSearch.pop();
      }
      return false;
    },
    load: function load(data) {
      if (!(data && data.length)) return this;
      if (data.length < this._minEntries) {
        for (var i = 0, len = data.length; i < len; i++) {
          this.insert(data[i]);
        }
        return this;
      }
      var node = this._build(data.slice(), 0, data.length - 1, 0);
      if (!this.data.children.length) {
        this.data = node;
      } else if (this.data.height === node.height) {
        this._splitRoot(this.data, node);
      } else {
        if (this.data.height < node.height) {
          var tmpNode = this.data;
          this.data = node;
          node = tmpNode;
        }
        this._insert(node, this.data.height - node.height - 1, true);
      }
      return this;
    },
    insert: function insert(item) {
      if (item) this._insert(item, this.data.height - 1);
      return this;
    },
    clear: function clear() {
      this.data = createNode([]);
      return this;
    },
    remove: function remove(item, equalsFn) {
      if (!item) return this;
      var node = this.data,
        bbox = this.toBBox(item),
        path = [],
        indexes = [],
        i,
        parent,
        index,
        goingUp;
      while (node || path.length) {
        if (!node) {
          node = path.pop();
          parent = path[path.length - 1];
          i = indexes.pop();
          goingUp = true;
        }
        if (node.leaf) {
          index = findItem(item, node.children, equalsFn);
          if (index !== -1) {
            node.children.splice(index, 1);
            path.push(node);
            this._condense(path);
            return this;
          }
        }
        if (!goingUp && !node.leaf && contains(node, bbox)) {
          path.push(node);
          indexes.push(i);
          i = 0;
          parent = node;
          node = node.children[0];
        } else if (parent) {
          i++;
          node = parent.children[i];
          goingUp = false;
        } else node = null;
      }
      return this;
    },
    toBBox: function toBBox(item) {
      return item;
    },
    compareMinX: compareNodeMinX,
    compareMinY: compareNodeMinY,
    toJSON: function toJSON() {
      return this.data;
    },
    fromJSON: function fromJSON(data) {
      this.data = data;
      return this;
    },
    _all: function _all(node, result) {
      var nodesToSearch = [];
      while (node) {
        if (node.leaf) result.push.apply(result, node.children);else nodesToSearch.push.apply(nodesToSearch, node.children);
        node = nodesToSearch.pop();
      }
      return result;
    },
    _build: function _build(items, left, right, height) {
      var N = right - left + 1,
        M = this._maxEntries,
        node;
      if (N <= M) {
        node = createNode(items.slice(left, right + 1));
        calcBBox(node, this.toBBox);
        return node;
      }
      if (!height) {
        height = Math.ceil(Math.log(N) / Math.log(M));
        M = Math.ceil(N / Math.pow(M, height - 1));
      }
      node = createNode([]);
      node.leaf = false;
      node.height = height;
      var N2 = Math.ceil(N / M),
        N1 = N2 * Math.ceil(Math.sqrt(M)),
        i,
        j,
        right2,
        right3;
      multiSelect(items, left, right, N1, this.compareMinX);
      for (i = left; i <= right; i += N1) {
        right2 = Math.min(i + N1 - 1, right);
        multiSelect(items, i, right2, N2, this.compareMinY);
        for (j = i; j <= right2; j += N2) {
          right3 = Math.min(j + N2 - 1, right2);
          node.children.push(this._build(items, j, right3, height - 1));
        }
      }
      calcBBox(node, this.toBBox);
      return node;
    },
    _chooseSubtree: function _chooseSubtree(bbox, node, level, path) {
      var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;
      while (true) {
        path.push(node);
        if (node.leaf || path.length - 1 === level) break;
        minArea = minEnlargement = Infinity;
        for (i = 0, len = node.children.length; i < len; i++) {
          child = node.children[i];
          area = bboxArea(child);
          enlargement = enlargedArea(bbox, child) - area;
          if (enlargement < minEnlargement) {
            minEnlargement = enlargement;
            minArea = area < minArea ? area : minArea;
            targetNode = child;
          } else if (enlargement === minEnlargement) {
            if (area < minArea) {
              minArea = area;
              targetNode = child;
            }
          }
        }
        node = targetNode || node.children[0];
      }
      return node;
    },
    _insert: function _insert(item, level, isNode) {
      var toBBox = this.toBBox,
        bbox = isNode ? item : toBBox(item),
        insertPath = [];
      var node = this._chooseSubtree(bbox, this.data, level, insertPath);
      node.children.push(item);
      extend$2(node, bbox);
      while (level >= 0) {
        if (insertPath[level].children.length > this._maxEntries) {
          this._split(insertPath, level);
          level--;
        } else break;
      }
      this._adjustParentBBoxes(bbox, insertPath, level);
    },
    _split: function _split(insertPath, level) {
      var node = insertPath[level],
        M = node.children.length,
        m = this._minEntries;
      this._chooseSplitAxis(node, m, M);
      var splitIndex = this._chooseSplitIndex(node, m, M);
      var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
      newNode.height = node.height;
      newNode.leaf = node.leaf;
      calcBBox(node, this.toBBox);
      calcBBox(newNode, this.toBBox);
      if (level) insertPath[level - 1].children.push(newNode);else this._splitRoot(node, newNode);
    },
    _splitRoot: function _splitRoot(node, newNode) {
      this.data = createNode([node, newNode]);
      this.data.height = node.height + 1;
      this.data.leaf = false;
      calcBBox(this.data, this.toBBox);
    },
    _chooseSplitIndex: function _chooseSplitIndex(node, m, M) {
      var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
      minOverlap = minArea = Infinity;
      for (i = m; i <= M - m; i++) {
        bbox1 = distBBox(node, 0, i, this.toBBox);
        bbox2 = distBBox(node, i, M, this.toBBox);
        overlap = intersectionArea(bbox1, bbox2);
        area = bboxArea(bbox1) + bboxArea(bbox2);
        if (overlap < minOverlap) {
          minOverlap = overlap;
          index = i;
          minArea = area < minArea ? area : minArea;
        } else if (overlap === minOverlap) {
          if (area < minArea) {
            minArea = area;
            index = i;
          }
        }
      }
      return index;
    },
    _chooseSplitAxis: function _chooseSplitAxis(node, m, M) {
      var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
        compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
        xMargin = this._allDistMargin(node, m, M, compareMinX),
        yMargin = this._allDistMargin(node, m, M, compareMinY);
      if (xMargin < yMargin) node.children.sort(compareMinX);
    },
    _allDistMargin: function _allDistMargin(node, m, M, compare) {
      node.children.sort(compare);
      var toBBox = this.toBBox,
        leftBBox = distBBox(node, 0, m, toBBox),
        rightBBox = distBBox(node, M - m, M, toBBox),
        margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
        i,
        child;
      for (i = m; i < M - m; i++) {
        child = node.children[i];
        extend$2(leftBBox, node.leaf ? toBBox(child) : child);
        margin += bboxMargin(leftBBox);
      }
      for (i = M - m - 1; i >= m; i--) {
        child = node.children[i];
        extend$2(rightBBox, node.leaf ? toBBox(child) : child);
        margin += bboxMargin(rightBBox);
      }
      return margin;
    },
    _adjustParentBBoxes: function _adjustParentBBoxes(bbox, path, level) {
      for (var i = level; i >= 0; i--) {
        extend$2(path[i], bbox);
      }
    },
    _condense: function _condense(path) {
      for (var i = path.length - 1, siblings; i >= 0; i--) {
        if (path[i].children.length === 0) {
          if (i > 0) {
            siblings = path[i - 1].children;
            siblings.splice(siblings.indexOf(path[i]), 1);
          } else this.clear();
        } else calcBBox(path[i], this.toBBox);
      }
    },
    _initFormat: function _initFormat(format) {
      var compareArr = ['return a', ' - b', ';'];
      this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
      this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));
      this.toBBox = new Function('a', 'return {minX: a' + format[0] + ', minY: a' + format[1] + ', maxX: a' + format[2] + ', maxY: a' + format[3] + '};');
    }
  };
  function findItem(item, items, equalsFn) {
    if (!equalsFn) return items.indexOf(item);
    for (var i = 0; i < items.length; i++) {
      if (equalsFn(item, items[i])) return i;
    }
    return -1;
  }
  function calcBBox(node, toBBox) {
    distBBox(node, 0, node.children.length, toBBox, node);
  }
  function distBBox(node, k, p, toBBox, destNode) {
    if (!destNode) destNode = createNode(null);
    destNode.minX = Infinity;
    destNode.minY = Infinity;
    destNode.maxX = -Infinity;
    destNode.maxY = -Infinity;
    for (var i = k, child; i < p; i++) {
      child = node.children[i];
      extend$2(destNode, node.leaf ? toBBox(child) : child);
    }
    return destNode;
  }
  function extend$2(a, b) {
    a.minX = Math.min(a.minX, b.minX);
    a.minY = Math.min(a.minY, b.minY);
    a.maxX = Math.max(a.maxX, b.maxX);
    a.maxY = Math.max(a.maxY, b.maxY);
    return a;
  }
  function compareNodeMinX(a, b) {
    return a.minX - b.minX;
  }
  function compareNodeMinY(a, b) {
    return a.minY - b.minY;
  }
  function bboxArea(a) {
    return (a.maxX - a.minX) * (a.maxY - a.minY);
  }
  function bboxMargin(a) {
    return a.maxX - a.minX + (a.maxY - a.minY);
  }
  function enlargedArea(a, b) {
    return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) * (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
  }
  function intersectionArea(a, b) {
    var minX = Math.max(a.minX, b.minX),
      minY = Math.max(a.minY, b.minY),
      maxX = Math.min(a.maxX, b.maxX),
      maxY = Math.min(a.maxY, b.maxY);
    return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
  }
  function contains(a, b) {
    return a.minX <= b.minX && a.minY <= b.minY && b.maxX <= a.maxX && b.maxY <= a.maxY;
  }
  function intersects(a, b) {
    return b.minX <= a.maxX && b.minY <= a.maxY && b.maxX >= a.minX && b.maxY >= a.minY;
  }
  function createNode(children) {
    return {
      children: children,
      height: 1,
      leaf: true,
      minX: Infinity,
      minY: Infinity,
      maxX: -Infinity,
      maxY: -Infinity
    };
  }
  function multiSelect(arr, left, right, n, compare) {
    var stack = [left, right],
      mid;
    while (stack.length) {
      right = stack.pop();
      left = stack.pop();
      if (right - left <= n) continue;
      mid = left + Math.ceil((right - left) / n / 2) * n;
      quickselect(arr, mid, left, right, compare);
      stack.push(left, mid, mid, right);
    }
  }
  rbush_1.default = default_1;

  var search = {};
  var CollisionIndex = function () {
    function CollisionIndex() {
      this._tree = rbush_1(9, ['[0]', '[1]', '[2]', '[3]']);
    }
    var _proto = CollisionIndex.prototype;
    _proto.collides = function collides(box) {
      search.minX = box[0];
      search.minY = box[1];
      search.maxX = box[2];
      search.maxY = box[3];
      return this._tree.collides(search);
    };
    _proto.insertBox = function insertBox(box) {
      var tree = this._tree;
      tree.insert(box);
      return this;
    };
    _proto.bulkInsertBox = function bulkInsertBox(boxes) {
      this._tree.load(boxes);
      return this;
    };
    _proto.clear = function clear() {
      this._tree.clear();
      return this;
    };
    return CollisionIndex;
  }();

  function Handlerable (Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      var _proto = _class.prototype;
      _proto.addHandler = function addHandler(name, handlerClass) {
        if (!handlerClass) {
          return this;
        }
        if (!this._handlers) {
          this._handlers = [];
        }
        if (this[name]) {
          this[name].enable();
          return this;
        }
        var handler = this[name] = new handlerClass(this);
        this._handlers.push(handler);
        if (this.options[name]) {
          handler.enable();
        }
        return this;
      };
      _proto.removeHandler = function removeHandler(name) {
        if (!name) {
          return this;
        }
        var handler = this[name];
        if (handler) {
          var hit = this._handlers.indexOf(handler);
          if (hit >= 0) {
            this._handlers.splice(hit, 1);
          }
          this[name].remove();
          delete this[name];
        }
        return this;
      };
      _proto._clearHandlers = function _clearHandlers() {
        for (var i = 0, len = this._handlers.length; i < len; i++) {
          this._handlers[i].remove();
        }
        this._handlers = [];
      };
      return _class;
    }(Base);
  }

  var START_EVENTS = 'touchstart mousedown';
  var MOVE_EVENTS = {
    mousedown: 'mousemove',
    touchstart: 'touchmove',
    pointerdown: 'touchmove',
    MSPointerDown: 'touchmove'
  };
  var END_EVENTS = {
    mousedown: 'mouseup',
    touchstart: 'touchend',
    pointerdown: 'touchend',
    MSPointerDown: 'touchend'
  };
  var DragHandler = function (_Handler) {
    _inheritsLoose(DragHandler, _Handler);
    function DragHandler(dom, options) {
      var _this;
      if (options === void 0) {
        options = {};
      }
      _this = _Handler.call(this, null) || this;
      _this.dom = dom;
      _this.options = options;
      return _this;
    }
    var _proto = DragHandler.prototype;
    _proto.enable = function enable() {
      if (!this.dom) {
        return this;
      }
      this._onMouseDown = function (e) {
        return this.onMouseDown(e);
      };
      on(this.dom, START_EVENTS, this._onMouseDown, this);
      return this;
    };
    _proto.disable = function disable() {
      if (!this.dom) {
        return this;
      }
      this._offEvents();
      off(this.dom, START_EVENTS, this._onMouseDown);
      delete this._onMouseDown;
      return this;
    };
    _proto.onMouseDown = function onMouseDown(event) {
      if (!this.options['rightclick'] && event.button === 2) {
        return;
      }
      if (event.touches && event.touches.length > 1) {
        return;
      }
      if (this.options['cancelOn'] && this.options['cancelOn'](event) === true) {
        return;
      }
      var dom = this.dom;
      if (dom.setCapture) {
        dom.setCapture();
      } else if (window.captureEvents) {
        window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
      }
      dom['ondragstart'] = function () {
        return false;
      };
      delete this.moved;
      var actual = event.touches ? event.touches[0] : event;
      this.startPos = new Point(actual.clientX, actual.clientY);
      off(document, MOVE_EVENTS[event.type], this.onMouseMove, this);
      off(document, END_EVENTS[event.type], this.onMouseUp, this);
      on(document, MOVE_EVENTS[event.type], this.onMouseMove, this);
      on(document, END_EVENTS[event.type], this.onMouseUp, this);
      if (!this.options['ignoreMouseleave']) {
        off(this.dom, 'mouseleave', this.onMouseUp, this);
        on(this.dom, 'mouseleave', this.onMouseUp, this);
      }
      this.fire('mousedown', {
        'domEvent': event,
        'mousePos': new Point(actual.clientX, actual.clientY)
      });
    };
    _proto.onMouseMove = function onMouseMove(event) {
      if (event.touches && event.touches.length > 1) {
        if (this.moved) {
          this.interupted = true;
          this.onMouseUp(event);
        }
        return;
      }
      var actual = event.touches ? event.touches[0] : event;
      var newPos = new Point(actual.clientX, actual.clientY),
        offset = newPos.sub(this.startPos);
      if (!offset.x && !offset.y) {
        return;
      }
      if (!this.moved) {
        this.fire('dragstart', {
          'domEvent': event,
          'mousePos': this.startPos.copy()
        });
        this.moved = true;
      } else {
        this.fire('dragging', {
          'domEvent': event,
          'mousePos': new Point(actual.clientX, actual.clientY)
        });
      }
    };
    _proto.onMouseUp = function onMouseUp(event) {
      var actual = event.changedTouches ? event.changedTouches[0] : event;
      this._offEvents();
      var param = {
        'domEvent': event
      };
      if (isNumber(actual.clientX)) {
        param['mousePos'] = new Point(parseInt(actual.clientX, 0), parseInt(actual.clientY, 0));
      }
      if (this.moved) {
        param.interupted = this.interupted;
        this.fire('dragend', param);
        delete this.interupted;
        delete this.moved;
      }
      this.fire('mouseup', param);
    };
    _proto._offEvents = function _offEvents() {
      var dom = this.dom;
      off(dom, 'mouseleave', this.onMouseUp, this);
      if (typeof document === 'undefined' || typeof window === 'undefined') {
        return;
      }
      for (var i in MOVE_EVENTS) {
        off(document, MOVE_EVENTS[i], this.onMouseMove, this);
        off(document, END_EVENTS[i], this.onMouseUp, this);
      }
      if (dom['releaseCapture']) {
        dom['releaseCapture']();
      } else if (window.captureEvents) {
        window.captureEvents(window['Event'].MOUSEMOVE | window['Event'].MOUSEUP);
      }
    };
    return DragHandler;
  }(Handler$1);

  var Coordinate = function (_Position) {
    _inheritsLoose(Coordinate, _Position);
    function Coordinate() {
      return _Position.apply(this, arguments) || this;
    }
    Coordinate.toNumberArrays = function toNumberArrays(coordinates) {
      if (!Array.isArray(coordinates)) {
        return [coordinates.x, coordinates.y];
      }
      return forEachCoord(coordinates, function (coord) {
        return [coord.x, coord.y];
      });
    };
    Coordinate.toCoordinates = function toCoordinates(coordinates) {
      if (isNumber(coordinates[0]) && isNumber(coordinates[1])) {
        return new Coordinate(coordinates);
      }
      if (coordinates instanceof Coordinate) {
        return coordinates;
      }
      var result = [];
      for (var i = 0, len = coordinates.length; i < len; i++) {
        var child = coordinates[i];
        if (Array.isArray(child)) {
          if (isNumber(child[0])) {
            result.push(new Coordinate(child));
          } else {
            result.push(Coordinate.toCoordinates(child));
          }
        } else if (child instanceof Coordinate) {
          result.push(child);
        } else {
          result.push(new Coordinate(child));
        }
      }
      return result;
    };
    return Coordinate;
  }(Position);

  var CRS = function () {
    function CRS(type, properties) {
      this.type = type;
      this.properties = properties;
    }
    CRS.createProj4 = function createProj4(proj) {
      return new CRS('proj4', {
        'proj': proj
      });
    };
    CRS.fromProjectionCode = function fromProjectionCode(code) {
      if (!code) {
        return null;
      }
      code = code.toUpperCase().replace(':', '');
      return CRS[code] || null;
    };
    return CRS;
  }();
  CRS.WGS84 = CRS.createProj4('+proj=longlat +datum=WGS84 +no_defs');
  CRS.EPSG4326 = CRS.WGS84;
  CRS.EPSG3857 = CRS.createProj4('+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext  +no_defs');
  CRS.IDENTITY = CRS.createProj4('+proj=identity +no_defs');
  CRS.CGCS2000 = CRS.createProj4('+proj=longlat +datum=CGCS2000');
  CRS.EPSG4490 = CRS.CGCS2000;
  CRS.BD09LL = CRS.createProj4('+proj=longlat +datum=BD09');
  CRS.GCJ02 = CRS.createProj4('+proj=longlat +datum=GCJ02');

  var TEMP_POINT0 = new Point(0, 0);
  var TEMP_COORD0 = new Coordinate(0, 0);
  var TEMP_COORD1 = new Coordinate(0, 0);
  var TEMP_COORD2 = new Coordinate(0, 0);
  var TEMP_COORD3 = new Coordinate(0, 0);
  var TEMP_COORD4 = new Coordinate(0, 0);
  var TEMP_COORD5 = new Coordinate(0, 0);
  var TEMP_COORD6 = new Coordinate(0, 0);
  var TEMP_COORD7 = new Coordinate(0, 0);
  var MINMAX = [];
  var TEMP_EXTENT;
  var TEMP_COMBINE = [];
  var Extent = function () {
    function Extent(p1, p2, p3, p4) {
      this._clazz = Coordinate;
      var l = arguments.length;
      var proj = l > 0 ? arguments[l - 1] : null;
      if (proj && proj.unproject) {
        this.projection = arguments[l - 1];
      }
      this._dirty = true;
      this._initialize(p1, p2, p3, p4);
    }
    var _proto = Extent.prototype;
    _proto._initialize = function _initialize(p1, p2, p3, p4) {
      this.xmin = null;
      this.xmax = null;
      this.ymin = null;
      this.ymax = null;
      if (isNil(p1)) {
        return;
      }
      var projection = this.projection;
      if (isNumber(p1) && isNumber(p2) && isNumber(p3) && isNumber(p4)) {
        if (projection) {
          this.set(p1, p2, p3, p4);
        } else {
          this.set(Math.min(p1, p3), Math.min(p2, p4), Math.max(p1, p3), Math.max(p2, p4));
        }
        return;
      } else if (Array.isArray(p1)) {
        if (projection) {
          this.set(p1[0], p1[1], p1[2], p1[3]);
        } else {
          this.set(Math.min(p1[0], p1[2]), Math.min(p1[1], p1[3]), Math.max(p1[0], p1[2]), Math.max(p1[1], p1[3]));
        }
      } else if (isNumber(p1.x) && isNumber(p2.x) && isNumber(p1.y) && isNumber(p2.y)) {
        if (projection) {
          this.set(p1.x, p1.y, p2.x, p2.y);
        } else {
          if (p1.x > p2.x) {
            this['xmin'] = p2.x;
            this['xmax'] = p1.x;
          } else {
            this['xmin'] = p1.x;
            this['xmax'] = p2.x;
          }
          if (p1.y > p2.y) {
            this['ymin'] = p2.y;
            this['ymax'] = p1.y;
          } else {
            this['ymin'] = p1.y;
            this['ymax'] = p2.y;
          }
        }
      } else if (isNumber(p1['xmin']) && isNumber(p1['xmax']) && isNumber(p1['ymin']) && isNumber(p1['ymax'])) {
        this.set(p1['xmin'], p1['ymin'], p1['xmax'], p1['ymax']);
      }
    };
    _proto._add = function _add(p) {
      this._dirty = true;
      if (!isNil(p.x)) {
        this['xmin'] += p.x;
        this['ymin'] += p.y;
        this['xmax'] += p.x;
        this['ymax'] += p.y;
      } else if (!isNil(p.xmin)) {
        this['xmin'] += p.xmin;
        this['ymin'] += p.ymin;
        this['xmax'] += p.xmax;
        this['ymax'] += p.ymax;
      } else if (!isNil(p[0])) {
        this['xmin'] += p[0];
        this['ymin'] += p[1];
        this['xmax'] += p[0];
        this['ymax'] += p[1];
      }
      return this;
    };
    _proto.add = function add() {
      var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
      return e._add.apply(e, arguments);
    };
    _proto._scale = function _scale(s) {
      this._dirty = true;
      this['xmin'] *= s;
      this['ymin'] *= s;
      this['xmax'] *= s;
      this['ymax'] *= s;
      return this;
    };
    _proto._sub = function _sub(p) {
      this._dirty = true;
      if (!isNil(p.x)) {
        this['xmin'] -= p.x;
        this['ymin'] -= p.y;
        this['xmax'] -= p.x;
        this['ymax'] -= p.y;
      } else if (!isNil(p.xmin)) {
        this['xmin'] -= p.xmin;
        this['ymin'] -= p.ymin;
        this['xmax'] -= p.xmax;
        this['ymax'] -= p.ymax;
      } else if (!isNil(p[0])) {
        this['xmin'] -= p[0];
        this['ymin'] -= p[1];
        this['xmax'] -= p[0];
        this['ymax'] -= p[1];
      }
      return this;
    };
    _proto._substract = function _substract() {
      return this._sub.apply(this, arguments);
    };
    _proto.sub = function sub() {
      var e = new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
      return e._sub.apply(e, arguments);
    };
    _proto.substract = function substract() {
      return this.sub.apply(this, arguments);
    };
    _proto.round = function round() {
      return new this.constructor(Math.round(this['xmin']), Math.round(this['ymin']), Math.round(this['xmax']), Math.round(this['ymax']), this.projection);
    };
    _proto._round = function _round() {
      this._dirty = true;
      this['xmin'] = Math.round(this['xmin']);
      this['ymin'] = Math.round(this['ymin']);
      this['xmax'] = Math.round(this['xmax']);
      this['ymax'] = Math.round(this['ymax']);
      return this;
    };
    _proto.getMin = function getMin(out) {
      if (out) {
        out.set(this['xmin'], this['ymin']);
        return out;
      }
      return new this._clazz(this['xmin'], this['ymin']);
    };
    _proto.getMax = function getMax(out) {
      if (out) {
        out.set(this['xmax'], this['ymax']);
        return out;
      }
      return new this._clazz(this['xmax'], this['ymax']);
    };
    _proto.getCenter = function getCenter(out) {
      var x = (this['xmin'] + this['xmax']) / 2;
      var y = (this['ymin'] + this['ymax']) / 2;
      if (out) {
        out.set(x, y);
        return out;
      }
      return new this._clazz(x, y);
    };
    _proto.isValid = function isValid() {
      return !isNil(this['xmin']) && !isNil(this['ymin']) && !isNil(this['xmax']) && !isNil(this['ymax']);
    };
    _proto.equals = function equals(ext2) {
      return this['xmin'] === ext2['xmin'] && this['xmax'] === ext2['xmax'] && this['ymin'] === ext2['ymin'] && this['ymax'] === ext2['ymax'];
    };
    _proto.intersects = function intersects(ext2) {
      this._project(this);
      this._project(ext2);
      var rxmin = Math.max(this['pxmin'], ext2['pxmin']);
      var rymin = Math.max(this['pymin'], ext2['pymin']);
      var rxmax = Math.min(this['pxmax'], ext2['pxmax']);
      var rymax = Math.min(this['pymax'], ext2['pymax']);
      var intersects = !(rxmin > rxmax || rymin > rymax);
      return intersects;
    };
    _proto.within = function within(extent) {
      this._project(this);
      this._project(extent);
      return this.pxmin >= extent.pxmin && this.pxmax <= extent.pxmax && this.pymin >= extent.pymin && this.pymax <= extent.pymax;
    };
    _proto.contains = function contains(c) {
      if (!c) {
        return false;
      }
      this._project(this);
      var proj = this.projection;
      if (proj) {
        if (c.x !== undefined) {
          var coord = TEMP_COORD0;
          if (Array.isArray(c)) {
            coord.x = c[0];
            coord.y = c[1];
          } else {
            coord.x = c.x;
            coord.y = c.y;
          }
          c = proj.project(coord, coord);
        } else if (c.xmin !== undefined) {
          this._project(c);
        }
      }
      return (c.x || c.pxmin || 0) >= this.pxmin && (c.x || c.pxmax || 0) <= this.pxmax && (c.y || c.pymin || 0) >= this.pymin && (c.y || c.pymax || 0) <= this.pymax;
    };
    _proto.getWidth = function getWidth() {
      return Math.abs(this['xmax'] - this['xmin']);
    };
    _proto.getHeight = function getHeight() {
      return Math.abs(this['ymax'] - this['ymin']);
    };
    _proto.getSize = function getSize() {
      return new Size(this.getWidth(), this.getHeight());
    };
    _proto.set = function set(xmin, ymin, xmax, ymax) {
      this.xmin = xmin;
      this.ymin = ymin;
      this.xmax = xmax;
      this.ymax = ymax;
      this._dirty = true;
      return this;
    };
    _proto.__combine = function __combine(extent) {
      if (extent.x !== undefined) {
        TEMP_EXTENT.xmin = TEMP_EXTENT.xmax = extent.x;
        TEMP_EXTENT.ymin = TEMP_EXTENT.ymax = extent.y;
        extent = TEMP_EXTENT;
      }
      this._project(extent);
      this._project(this);
      var inited = isNumber(this.pxmin);
      var xmin, ymin, xmax, ymax;
      if (!inited) {
        xmin = extent['pxmin'];
        ymin = extent['pymin'];
        xmax = extent['pxmax'];
        ymax = extent['pymax'];
      } else {
        xmin = Math.min(this['pxmin'], extent['pxmin']);
        ymin = Math.min(this['pymin'], extent['pymin']);
        xmax = Math.max(this['pxmax'], extent['pxmax']);
        ymax = Math.max(this['pymax'], extent['pymax']);
      }
      var proj = this.projection;
      if (proj) {
        TEMP_COORD1.set(xmin, ymin);
        TEMP_COORD2.set(xmax, ymax);
        var min = proj.unproject(TEMP_COORD1, TEMP_COORD1),
          max = proj.unproject(TEMP_COORD2, TEMP_COORD2);
        xmin = min.x;
        ymin = min.y;
        xmax = max.x;
        ymax = max.y;
      }
      TEMP_COMBINE[0] = xmin;
      TEMP_COMBINE[1] = ymin;
      TEMP_COMBINE[2] = xmax;
      TEMP_COMBINE[3] = ymax;
      return TEMP_COMBINE;
    };
    _proto._combine = function _combine(extent) {
      if (!extent || extent.isValid && !extent.isValid()) {
        return this;
      }
      var ext = this.__combine(extent);
      this.set(ext[0], ext[1], ext[2], ext[3]);
      this._dirty = true;
      return this;
    };
    _proto.combine = function combine(extent) {
      if (!extent || extent.isValid && !extent.isValid()) {
        return this;
      }
      var ext = this.__combine(extent);
      return new this.constructor(ext[0], ext[1], ext[2], ext[3], this.projection);
    };
    _proto.intersection = function intersection(extent) {
      if (!this.intersects(extent)) {
        return null;
      }
      TEMP_COORD3.x = Math.max(this['pxmin'], extent['pxmin']);
      TEMP_COORD3.y = Math.max(this['pymin'], extent['pymin']);
      TEMP_COORD4.x = Math.min(this['pxmax'], extent['pxmax']);
      TEMP_COORD4.y = Math.min(this['pymax'], extent['pymax']);
      var min = TEMP_COORD3,
        max = TEMP_COORD4;
      var proj = this.projection;
      if (proj) {
        min = proj.unproject(min, min);
        max = proj.unproject(max, max);
      }
      return new this.constructor(min, max, proj);
    };
    _proto.expand = function expand(distance) {
      var w, h;
      if (!isNumber(distance)) {
        w = distance['width'] || distance['x'] || distance[0] || 0;
        h = distance['height'] || distance['y'] || distance[1] || 0;
      } else {
        w = h = distance;
      }
      return new this.constructor(this['xmin'] - w, this['ymin'] - h, this['xmax'] + w, this['ymax'] + h, this.projection);
    };
    _proto._expand = function _expand(distance) {
      var w, h;
      if (!isNumber(distance)) {
        w = distance['width'] || distance['x'] || distance[0] || 0;
        h = distance['height'] || distance['y'] || distance[1] || 0;
      } else {
        w = h = distance;
      }
      this['xmin'] -= w;
      this['ymin'] -= h;
      this['xmax'] += w;
      this['ymax'] += h;
      this._dirty = true;
      return this;
    };
    _proto.toJSON = function toJSON() {
      return {
        'xmin': this['xmin'],
        'ymin': this['ymin'],
        'xmax': this['xmax'],
        'ymax': this['ymax']
      };
    };
    _proto.toArray = function toArray(out) {
      var xmin = this['xmin'],
        ymin = this['ymin'],
        xmax = this['xmax'],
        ymax = this['ymax'];
      if (!out) {
        return [new this._clazz([xmin, ymax]), new this._clazz([xmax, ymax]), new this._clazz([xmax, ymin]), new this._clazz([xmin, ymin]), new this._clazz([xmin, ymax])];
      } else {
        out[0].x = xmin;
        out[0].y = ymax;
        out[1].x = xmax;
        out[1].y = ymax;
        out[2].x = xmax;
        out[2].y = ymin;
        out[3].x = xmin;
        out[3].y = ymin;
        out[4].x = xmin;
        out[4].y = ymax;
        return out;
      }
    };
    _proto.toString = function toString() {
      return this.xmin + "," + this.ymin + "," + this.xmax + "," + this.ymax;
    };
    _proto.copy = function copy() {
      return new this.constructor(this['xmin'], this['ymin'], this['xmax'], this['ymax'], this.projection);
    };
    _proto.convertTo = function convertTo(fn, out) {
      if (!this.isValid()) {
        return null;
      }
      var e = out || new this.constructor();
      if (out) {
        e.set(null, null, null, null);
      }
      var coord;
      if (this._clazz === Coordinate) {
        coord = TEMP_COORD5;
      } else if (this._clazz === Point) {
        coord = TEMP_POINT0;
      }
      coord.x = this.xmin;
      coord.y = this.ymax;
      e._combine(fn(coord));
      coord.x = this.xmax;
      e._combine(fn(coord));
      coord.y = this.ymin;
      e._combine(fn(coord));
      coord.x = this.xmin;
      e._combine(fn(coord));
      return e;
    };
    _proto._project = function _project(ext) {
      if (!ext || !ext.isValid()) {
        if (ext) {
          ext.pxmin = ext.pxmax = ext.pymin = ext.pymax = null;
        }
        return;
      }
      var proj = this.projection;
      if (proj) {
        if (ext._dirty) {
          TEMP_COORD6.set(ext.xmax, ext.ymin);
          TEMP_COORD7.set(ext.xmin, ext.ymax);
          MINMAX[0] = TEMP_COORD6;
          MINMAX[1] = TEMP_COORD7;
          var minmax = proj.projectCoords(MINMAX);
          var min = minmax[0],
            max = minmax[1];
          ext.pxmin = Math.min(min.x, max.x);
          ext.pymin = Math.min(min.y, max.y);
          ext.pxmax = Math.max(min.x, max.x);
          ext.pymax = Math.max(min.y, max.y);
        }
        delete ext._dirty;
      } else {
        ext.pxmin = ext.xmin;
        ext.pxmax = ext.xmax;
        ext.pymin = ext.ymin;
        ext.pymax = ext.ymax;
      }
    };
    return Extent;
  }();
  TEMP_EXTENT = new Extent(0, 0, 0, 0);

  var PointExtent = function (_Extent) {
    _inheritsLoose(PointExtent, _Extent);
    function PointExtent(p1, p2, p3, p4) {
      var _this;
      _this = _Extent.call(this, p1, p2, p3, p4) || this;
      _this._clazz = Point;
      return _this;
    }
    return PointExtent;
  }(Extent);

  var Transformation = function () {
    function Transformation(matrix) {
      this.matrix = matrix;
    }
    var _proto = Transformation.prototype;
    _proto.transform = function transform(coordinates, scale, out) {
      var x = this.matrix[0] * (coordinates.x - this.matrix[2]) / scale;
      var y = -this.matrix[1] * (coordinates.y - this.matrix[3]) / scale;
      if (out) {
        out.x = x;
        out.y = y;
        return out;
      }
      return new Point(x, y);
    };
    _proto.untransform = function untransform(point, scale, out) {
      var x = point.x * scale / this.matrix[0] + this.matrix[2];
      var y = point.y * scale / -this.matrix[1] + this.matrix[3];
      if (out) {
        out.x = x;
        out.y = y;
        return out;
      }
      return new Coordinate(x, y);
    };
    return Transformation;
  }();

  var Common = {
    is: function is(code) {
      if (this.code === code) {
        return true;
      }
      if (!this.aliases) {
        return false;
      }
      for (var i = 0; i < this.aliases.length; i++) {
        if (this.aliases[i] === code) {
          return true;
        }
      }
      return false;
    },
    project: function project() {},
    unproject: function unproject() {},
    projectCoords: function projectCoords(coordinates, antiMeridian) {
      var _this = this;
      if (!coordinates) {
        return [];
      }
      if (!Array.isArray(coordinates)) {
        return this.project(coordinates);
      }
      if (coordinates.length === 0) {
        return [];
      }
      if (!this.isSphere()) {
        return forEachCoord(coordinates, this.project, this);
      }
      if (Array.isArray(coordinates[0])) {
        return coordinates.map(function (coords) {
          return _this.projectCoords(coords, antiMeridian);
        });
      } else {
        var antiMeridianEnable = antiMeridian !== false;
        var circum = this.getCircum();
        var extent = this.getSphereExtent(),
          sx = extent.sx,
          sy = extent.sy;
        var wrapX, wrapY;
        var pre = coordinates[0],
          current,
          dx,
          dy,
          p;
        var prj = [this.project(pre)];
        for (var i = 1, l = coordinates.length; i < l; i++) {
          current = coordinates[i];
          dx = current.x - pre.x;
          dy = current.y - pre.y;
          p = this.project(current);
          if (Math.abs(dx) > 180 && antiMeridianEnable) {
            if (wrapX === undefined) {
              wrapX = current.x > pre.x;
            }
            if (wrapX) {
              p._add(-circum.x * sign(dx) * sx, 0);
              current._add(-360 * sign(dx), 0);
            }
          }
          if (Math.abs(dy) > 90 && antiMeridianEnable) {
            if (wrapY === undefined) {
              wrapY = current.y < pre.y;
            }
            if (wrapY) {
              p._add(0, -circum.y * sign(dy) * sy);
              current._add(0, -180 * sign(dy));
            }
          }
          pre = current;
          prj.push(p);
        }
        return prj;
      }
    },
    unprojectCoords: function unprojectCoords(projCoords) {
      if (!projCoords) {
        return [];
      }
      if (!Array.isArray(projCoords)) {
        return this.unproject(projCoords);
      }
      return forEachCoord(projCoords, this.unproject, this);
    },
    isSphere: function isSphere() {
      return !!this.sphere;
    },
    isOutSphere: function isOutSphere(pcoord) {
      if (!this.isSphere()) {
        return false;
      }
      var extent = this.getSphereExtent();
      return !extent.contains(pcoord);
    },
    wrapCoord: function wrapCoord(pcoord) {
      if (!this.isSphere()) {
        return pcoord;
      }
      var extent = this.getSphereExtent();
      var wrapped = new Coordinate(pcoord);
      if (!extent.contains(wrapped)) {
        wrapped.x = wrap(pcoord.x, extent.xmin, extent.xmax);
        wrapped.y = wrap(pcoord.y, extent.ymin, extent.ymax);
      }
      return wrapped;
    },
    getCircum: function getCircum() {
      if (!this.circum && this.isSphere()) {
        var extent = this.getSphereExtent();
        this.circum = {
          x: extent.getWidth(),
          y: extent.getHeight()
        };
      }
      return this.circum;
    },
    getSphereExtent: function getSphereExtent() {
      if (!this.extent && this.isSphere()) {
        var max = this.project(new Coordinate(180, 90)),
          min = this.project(new Coordinate(-180, -90));
        this.extent = new Extent(min, max, this);
        this.extent.sx = max.x > min.x ? 1 : -1;
        this.extent.sy = max.y > min.y ? 1 : -1;
      }
      return this.extent;
    }
  };

  var Common$1 = {
    measureLength: function measureLength(c1, c2) {
      if (!Array.isArray(c1)) {
        return this.measureLenBetween(c1, c2);
      }
      var len = 0;
      for (var i = 0, l = c1.length; i < l - 1; i++) {
        len += this.measureLenBetween(c1[i], c1[i + 1]);
      }
      return len;
    }
  };

  var Identity = extend({
    'measure': 'IDENTITY',
    measureLenBetween: function measureLenBetween(c1, c2) {
      if (!c1 || !c2) {
        return 0;
      }
      try {
        return Math.sqrt(Math.pow(c1.x - c2.x, 2) + Math.pow(c1.y - c2.y, 2));
      } catch (err) {
        return 0;
      }
    },
    measureArea: function measureArea(coordinates) {
      if (!Array.isArray(coordinates)) {
        return 0;
      }
      var area = 0;
      for (var i = 0, len = coordinates.length; i < len; i++) {
        var c1 = coordinates[i];
        var c2 = null;
        if (i === len - 1) {
          c2 = coordinates[0];
        } else {
          c2 = coordinates[i + 1];
        }
        area += c1.x * c2.y - c1.y * c2.x;
      }
      return Math.abs(area / 2);
    },
    locate: function locate(c, xDist, yDist, out) {
      out = out || new Coordinate(0, 0);
      out.set(c.x, c.y);
      return this._locate(out, xDist, yDist);
    },
    _locate: function _locate(c, xDist, yDist) {
      if (!c) {
        return null;
      }
      if (!xDist) {
        xDist = 0;
      }
      if (!yDist) {
        yDist = 0;
      }
      if (!xDist && !yDist) {
        return c;
      }
      c.x = c.x + xDist;
      c.y = c.y + yDist;
      return c;
    },
    rotate: function rotate(c, pivot, angle) {
      c = new Coordinate(c.x, c.y);
      return this._rotate(c, pivot, angle);
    },
    _rotate: function () {
      var tmp = new Point(0, 0);
      return function (c, pivot, angle) {
        tmp.x = c.x - pivot.x;
        tmp.y = c.y - pivot.y;
        tmp._rotate(angle * Math.PI / 180);
        c.x = pivot.x + tmp.x;
        c.y = pivot.y + tmp.y;
        return c;
      };
    }()
  }, Common$1);

  var Sphere = function () {
    function Sphere(radius) {
      this.radius = radius;
    }
    var _proto = Sphere.prototype;
    _proto.measureLenBetween = function measureLenBetween(c1, c2) {
      if (!c1 || !c2) {
        return 0;
      }
      var b = toRadian(c1.y);
      var d = toRadian(c2.y),
        e = b - d,
        f = toRadian(c1.x) - toRadian(c2.x);
      b = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(e / 2), 2) + Math.cos(b) * Math.cos(d) * Math.pow(Math.sin(f / 2), 2)));
      b *= this.radius;
      return b;
    };
    _proto.measureArea = function measureArea(coordinates) {
      var a = toRadian(this.radius);
      var b = 0,
        c = coordinates,
        d = c.length;
      if (d < 3) {
        return 0;
      }
      var i;
      for (i = 0; i < d - 1; i++) {
        var e = c[i],
          f = c[i + 1];
        b += e.x * a * Math.cos(toRadian(e.y)) * f.y * a - f.x * a * Math.cos(toRadian(f.y)) * e.y * a;
      }
      d = c[i];
      c = c[0];
      b += d.x * a * Math.cos(toRadian(d.y)) * c.y * a - c.x * a * Math.cos(toRadian(c.y)) * d.y * a;
      return 0.5 * Math.abs(b);
    };
    _proto.locate = function locate(c, xDist, yDist, out) {
      out = out || new Coordinate(0, 0);
      out.set(c.x, c.y);
      return this._locate(out, xDist, yDist);
    };
    _proto._locate = function _locate(c, xDist, yDist) {
      if (!c) {
        return null;
      }
      if (!xDist) {
        xDist = 0;
      }
      if (!yDist) {
        yDist = 0;
      }
      if (!xDist && !yDist) {
        return c;
      }
      var x, y;
      var ry = toRadian(c.y);
      if (yDist !== 0) {
        var dy = Math.abs(yDist);
        var sy = Math.sin(dy / (2 * this.radius)) * 2;
        ry = ry + sy * (yDist > 0 ? 1 : -1);
        y = wrap(ry * 180 / Math.PI, -90, 90);
      } else {
        y = c.y;
      }
      if (xDist !== 0) {
        var dx = Math.abs(xDist);
        var rx = toRadian(c.x);
        var sx = 2 * Math.sqrt(Math.pow(Math.sin(dx / (2 * this.radius)), 2) / Math.pow(Math.cos(ry), 2));
        rx = rx + sx * (xDist > 0 ? 1 : -1);
        x = wrap(rx * 180 / Math.PI, -180, 180);
      } else {
        x = c.x;
      }
      c.x = x;
      c.y = y;
      return c;
    };
    _proto.rotate = function rotate(c, pivot, angle) {
      c = new Coordinate(c);
      return this._rotate(c, pivot, angle);
    };
    _proto._rotate = function _rotate(c, pivot, angle) {
      var initialAngle = rhumbBearing(pivot, c);
      var finalAngle = initialAngle - angle;
      var distance = this.measureLenBetween(pivot, c);
      c.x = pivot.x;
      c.y = pivot.y;
      return calculateRhumbDestination(c, distance, finalAngle, this.radius);
    };
    return Sphere;
  }();
  function rhumbBearing(start, end, options) {
    if (options === void 0) {
      options = {};
    }
    var bear360;
    if (options.final) bear360 = calculateRhumbBearing(end, start);else bear360 = calculateRhumbBearing(start, end);
    var bear180 = bear360 > 180 ? -(360 - bear360) : bear360;
    return bear180;
  }
  function calculateRhumbBearing(from, to) {
    var phi1 = toRadian(from.y);
    var phi2 = toRadian(to.y);
    var deltaLambda = toRadian(to.x - from.x);
    if (deltaLambda > Math.PI) deltaLambda -= 2 * Math.PI;
    if (deltaLambda < -Math.PI) deltaLambda += 2 * Math.PI;
    var deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
    var theta = Math.atan2(deltaLambda, deltaPsi);
    return (toDegree(theta) + 360) % 360;
  }
  function calculateRhumbDestination(origin, distance, bearing, radius) {
    var delta = distance / radius;
    var lambda1 = origin.x * Math.PI / 180;
    var phi1 = toRadian(origin.y);
    var theta = toRadian(bearing);
    var DeltaPhi = delta * Math.cos(theta);
    var phi2 = phi1 + DeltaPhi;
    if (Math.abs(phi2) > Math.PI / 2) phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2;
    var DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
    var q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);
    var DeltaLambda = delta * Math.sin(theta) / q;
    var lambda2 = lambda1 + DeltaLambda;
    origin.x = (lambda2 * 180 / Math.PI + 540) % 360 - 180;
    origin.y = phi2 * 180 / Math.PI;
    return origin;
  }
  var WGS84Sphere = extend({
    'measure': 'EPSG:4326',
    sphere: new Sphere(6378137),
    measureLenBetween: function measureLenBetween() {
      return this.sphere.measureLenBetween.apply(this.sphere, arguments);
    },
    measureArea: function measureArea() {
      return this.sphere.measureArea.apply(this.sphere, arguments);
    },
    _locate: function _locate() {
      return this.sphere._locate.apply(this.sphere, arguments);
    },
    locate: function locate() {
      return this.sphere.locate.apply(this.sphere, arguments);
    },
    _rotate: function _rotate() {
      return this.sphere._rotate.apply(this.sphere, arguments);
    },
    rotate: function rotate() {
      return this.sphere.rotate.apply(this.sphere, arguments);
    }
  }, Common$1);
  var BaiduSphere = extend({
    'measure': 'BAIDU',
    sphere: new Sphere(6370996.81),
    measureLenBetween: function measureLenBetween() {
      return this.sphere.measureLenBetween.apply(this.sphere, arguments);
    },
    measureArea: function measureArea() {
      return this.sphere.measureArea.apply(this.sphere, arguments);
    },
    _locate: function _locate() {
      return this.sphere._locate.apply(this.sphere, arguments);
    },
    locate: function locate() {
      return this.sphere.locate.apply(this.sphere, arguments);
    },
    _rotate: function _rotate() {
      return this.sphere._rotate.apply(this.sphere, arguments);
    },
    rotate: function rotate() {
      return this.sphere.rotate.apply(this.sphere, arguments);
    }
  }, Common$1);

  var DEFAULT = WGS84Sphere;
  var measurers = {};
  function registerMeasurer(m) {
    measurers[m.measure] = m;
  }
  registerMeasurer(Identity);
  registerMeasurer(WGS84Sphere);
  registerMeasurer(BaiduSphere);
  var Measurer = {
    getInstance: function getInstance(name) {
      if (!name) {
        return DEFAULT;
      }
      for (var p in measurers) {
        if (hasOwn(measurers, p)) {
          var mName = measurers[p]['measure'];
          if (!mName) {
            continue;
          }
          if (name.toLowerCase() === mName.toLowerCase()) {
            return measurers[p];
          }
        }
      }
      return null;
    }
  };

  var index$2 = /*#__PURE__*/Object.freeze({
    Identity: Identity,
    DEFAULT: DEFAULT,
    Measurer: Measurer,
    WGS84Sphere: WGS84Sphere,
    BaiduSphere: BaiduSphere
  });

  var delta = 1E-7;
  var EPSG3857 = extend({}, Common, {
    code: 'EPSG:3857',
    rad: Math.PI / 180,
    metersPerDegree: 6378137 * Math.PI / 180,
    maxLatitude: 85.0511287798,
    project: function project(lnglat, out) {
      var rad = this.rad,
        metersPerDegree = this.metersPerDegree,
        max = this.maxLatitude;
      var lng = lnglat.x,
        lat = Math.max(Math.min(max, lnglat.y), -max);
      var c;
      if (lat === 0) {
        c = 0;
      } else {
        c = Math.log(Math.tan((90 + lat) * rad / 2)) / rad;
      }
      var x = lng * metersPerDegree;
      var y = c * metersPerDegree;
      if (out) {
        out.x = x;
        out.y = y;
        return out;
      }
      return new Coordinate(x, y);
    },
    unproject: function unproject(pLnglat, out) {
      var rad = this.rad;
      var metersPerDegree = this.metersPerDegree;
      var x = pLnglat.x / metersPerDegree;
      var y = pLnglat.y;
      var c;
      if (y === 0) {
        c = 0;
      } else {
        c = y / metersPerDegree;
        c = (2 * Math.atan(Math.exp(c * rad)) - Math.PI / 2) / rad;
      }
      if (Math.abs(Math.abs(x) - 180) < delta) {
        x = sign(x) * 180;
      }
      if (Math.abs(Math.abs(c) - this.maxLatitude) < delta) {
        c = sign(c) * this.maxLatitude;
      }
      var rx = wrap(x, -180, 180);
      var ry = wrap(c, -this.maxLatitude, this.maxLatitude);
      if (out) {
        out.x = rx;
        out.y = ry;
        return out;
      }
      return new Coordinate(rx, ry);
    }
  }, WGS84Sphere);

  var Projection_EPSG4326 = extend({}, Common, {
    code: 'EPSG:4326',
    aliases: ['EPSG:4490'],
    project: function project(p, out) {
      if (out) {
        out.x = p.x;
        out.y = p.y;
        return out;
      }
      return new Coordinate(p);
    },
    unproject: function unproject(p, out) {
      if (out) {
        out.x = p.x;
        out.y = p.y;
        return out;
      }
      return new Coordinate(p);
    }
  }, WGS84Sphere);

  var fabs = Math.abs,
    sin = Math.sin,
    cos = Math.cos,
    tan = Math.tan,
    atan = Math.atan,
    atan2 = Math.atan2,
    sqrt = Math.sqrt,
    log = Math.log,
    hypot = Math.hypot,
    sinh = Math.sinh,
    cosh = Math.cosh;
  var HUGE_VAL = Infinity,
    M_PI = Math.PI;
  function pj_etmerc(P) {
    var cgb = [],
      cbg = [],
      utg = [],
      gtu = [],
      Qn,
      Zb,
      f,
      n,
      np,
      Z;
    if (P.es <= 0) ;
    f = P.es / (1 + sqrt(1 - P.es));
    np = n = f / (2 - f);
    cgb[0] = n * (2 + n * (-2 / 3 + n * (-2 + n * (116 / 45 + n * (26 / 45 + n * (-2854 / 675))))));
    cbg[0] = n * (-2 + n * (2 / 3 + n * (4 / 3 + n * (-82 / 45 + n * (32 / 45 + n * (4642 / 4725))))));
    np *= n;
    cgb[1] = np * (7 / 3 + n * (-8 / 5 + n * (-227 / 45 + n * (2704 / 315 + n * (2323 / 945)))));
    cbg[1] = np * (5 / 3 + n * (-16 / 15 + n * (-13 / 9 + n * (904 / 315 + n * (-1522 / 945)))));
    np *= n;
    cgb[2] = np * (56 / 15 + n * (-136 / 35 + n * (-1262 / 105 + n * (73814 / 2835))));
    cbg[2] = np * (-26 / 15 + n * (34 / 21 + n * (8 / 5 + n * (-12686 / 2835))));
    np *= n;
    cgb[3] = np * (4279 / 630 + n * (-332 / 35 + n * (-399572 / 14175)));
    cbg[3] = np * (1237 / 630 + n * (-12 / 5 + n * (-24832 / 14175)));
    np *= n;
    cgb[4] = np * (4174 / 315 + n * (-144838 / 6237));
    cbg[4] = np * (-734 / 315 + n * (109598 / 31185));
    np *= n;
    cgb[5] = np * (601676 / 22275);
    cbg[5] = np * (444337 / 155925);
    np = n * n;
    Qn = P.k0 / (1 + n) * (1 + np * (1 / 4 + np * (1 / 64 + np / 256)));
    utg[0] = n * (-0.5 + n * (2 / 3 + n * (-37 / 96 + n * (1 / 360 + n * (81 / 512 + n * (-96199 / 604800))))));
    gtu[0] = n * (0.5 + n * (-2 / 3 + n * (5 / 16 + n * (41 / 180 + n * (-127 / 288 + n * (7891 / 37800))))));
    utg[1] = np * (-1 / 48 + n * (-1 / 15 + n * (437 / 1440 + n * (-46 / 105 + n * (1118711 / 3870720)))));
    gtu[1] = np * (13 / 48 + n * (-3 / 5 + n * (557 / 1440 + n * (281 / 630 + n * (-1983433 / 1935360)))));
    np *= n;
    utg[2] = np * (-17 / 480 + n * (37 / 840 + n * (209 / 4480 + n * (-5569 / 90720))));
    gtu[2] = np * (61 / 240 + n * (-103 / 140 + n * (15061 / 26880 + n * (167603 / 181440))));
    np *= n;
    utg[3] = np * (-4397 / 161280 + n * (11 / 504 + n * (830251 / 7257600)));
    gtu[3] = np * (49561 / 161280 + n * (-179 / 168 + n * (6601661 / 7257600)));
    np *= n;
    utg[4] = np * (-4583 / 161280 + n * (108847 / 3991680));
    gtu[4] = np * (34729 / 80640 + n * (-3418889 / 1995840));
    np *= n;
    utg[5] = np * (-20648693 / 638668800);
    gtu[5] = np * (212378941 / 319334400);
    Z = gatg(cbg, P.phi0);
    Zb = -Qn * (Z + clens(gtu, 2 * Z));
    P.fwd = e_fwd;
    P.inv = e_inv;
    function e_fwd(lp, xy) {
      var sin_Cn, cos_Cn, cos_Ce, sin_Ce, tmp;
      var Cn = lp.phi,
        Ce = lp.lam;
      Cn = gatg(cbg, Cn);
      sin_Cn = sin(Cn);
      cos_Cn = cos(Cn);
      sin_Ce = sin(Ce);
      cos_Ce = cos(Ce);
      Cn = atan2(sin_Cn, cos_Ce * cos_Cn);
      Ce = atan2(sin_Ce * cos_Cn, hypot(sin_Cn, cos_Cn * cos_Ce));
      Ce = asinhy(tan(Ce));
      tmp = clenS(gtu, 2 * Cn, 2 * Ce);
      Cn += tmp[0];
      Ce += tmp[1];
      if (fabs(Ce) <= 2.623395162778) {
        xy.y = Qn * Cn + Zb;
        xy.x = Qn * Ce;
      } else {
        xy.x = xy.y = HUGE_VAL;
      }
    }
    function e_inv(xy, lp) {
      var sin_Cn, cos_Cn, cos_Ce, sin_Ce, tmp;
      var Cn = xy.y,
        Ce = xy.x;
      Cn = (Cn - Zb) / Qn;
      Ce = Ce / Qn;
      if (fabs(Ce) <= 2.623395162778) {
        tmp = clenS(utg, 2 * Cn, 2 * Ce);
        Cn += tmp[0];
        Ce += tmp[1];
        Ce = atan(sinh(Ce));
        sin_Cn = sin(Cn);
        cos_Cn = cos(Cn);
        sin_Ce = sin(Ce);
        cos_Ce = cos(Ce);
        Ce = atan2(sin_Ce, cos_Ce * cos_Cn);
        Cn = atan2(sin_Cn * cos_Ce, hypot(sin_Ce, cos_Ce * cos_Cn));
        lp.phi = gatg(cgb, Cn);
        lp.lam = Ce;
      } else {
        lp.phi = lp.lam = HUGE_VAL;
      }
    }
    function log1py(x) {
      var y = 1 + x,
        z = y - 1;
      return z === 0 ? x : x * log(y) / z;
    }
    function asinhy(x) {
      var y = fabs(x);
      y = log1py(y * (1 + y / (hypot(1, y) + 1)));
      return x < 0 ? -y : y;
    }
    function gatg(pp, B) {
      var cos_2B = 2 * cos(2 * B),
        i = pp.length - 1,
        h1 = pp[i],
        h2 = 0,
        h;
      while (--i >= 0) {
        h = -h2 + cos_2B * h1 + pp[i];
        h2 = h1;
        h1 = h;
      }
      return B + h * sin(2 * B);
    }
    function clens(pp, arg_r) {
      var r = 2 * cos(arg_r),
        i = pp.length - 1,
        hr1 = pp[i],
        hr2 = 0,
        hr;
      while (--i >= 0) {
        hr = -hr2 + r * hr1 + pp[i];
        hr2 = hr1;
        hr1 = hr;
      }
      return sin(arg_r) * hr;
    }
    function clenS(pp, arg_r, arg_i) {
      var sin_arg_r = sin(arg_r),
        cos_arg_r = cos(arg_r),
        sinh_arg_i = sinh(arg_i),
        cosh_arg_i = cosh(arg_i),
        r = 2 * cos_arg_r * cosh_arg_i,
        i = -2 * sin_arg_r * sinh_arg_i,
        j = pp.length - 1,
        hr = pp[j],
        hi1 = 0,
        hr1 = 0,
        hi = 0,
        hr2,
        hi2;
      while (--j >= 0) {
        hr2 = hr1;
        hi2 = hi1;
        hr1 = hr;
        hi1 = hi;
        hr = -hr2 + r * hr1 - i * hi1 + pp[j];
        hi = -hi2 + i * hr1 + r * hi1;
      }
      r = sin_arg_r * cosh_arg_i;
      i = cos_arg_r * sinh_arg_i;
      return [r * hr - i * hi, r * hi + i * hr];
    }
  }

  var RAD_TO_DEG$1 = 57.295779513082321,
    DEG_TO_RAD = 0.017453292519943296;
  var SRS_WGS84_SEMIMAJOR = 6378137;
  var SRS_WGS84_ESQUARED = 0.0066943799901413165;
  var aliases = ['Traverse_Mercator'];
  var PROJ9807 = extend({}, Common, {
    code: 'EPSG:9807',
    aliases: aliases,
    create: function create(params) {
      var P = {
        a: SRS_WGS84_SEMIMAJOR,
        es: SRS_WGS84_ESQUARED,
        x0: isNil(params.falseEasting) ? 500000 : params.falseEasting,
        y0: isNil(params.falseNorthing) ? 0 : params.falseNorthing,
        k0: params.scaleFactor || 0.9996,
        lam0: (params.centralMeridian || 0) * DEG_TO_RAD,
        phi0: (params.latitudeOfOrigin || 0) * DEG_TO_RAD,
        originLam0: params.startLongtitude || 0,
        originPhi0: params.startLatitude || 0
      };
      pj_etmerc(P);
      var lp = {
        lam: 0,
        phi: 0
      };
      var xy = {};
      var originX = 0;
      var originY = 0;
      if (P.originLam0 || P.originPhi0) {
        lp.lam = P.originLam0 * DEG_TO_RAD - P.lam0;
        lp.phi = P.originPhi0 * DEG_TO_RAD;
        P.fwd(lp, xy);
        originX = P.a * xy.x + P.x0;
        originY = P.a * xy.y + P.y0;
      }
      return extend({}, Common, {
        code: 'EPSG:9807',
        aliases: aliases,
        centralMeridian: params.centralMeridian,
        project: function project(p, out) {
          lp.lam = p.x * DEG_TO_RAD - P.lam0;
          lp.phi = p.y * DEG_TO_RAD;
          P.fwd(lp, xy);
          var x = P.a * xy.x + P.x0 - originX;
          var y = P.a * xy.y + P.y0 - originY;
          if (out) {
            out.x = x;
            out.y = y;
            return out;
          }
          return new Coordinate(x, y);
        },
        unproject: function unproject(p, out) {
          xy.x = (p.x - P.x0 + originX) / P.a;
          xy.y = (p.y - P.y0 + originY) / P.a;
          P.inv(xy, lp);
          var x = (lp.lam + P.lam0) * RAD_TO_DEG$1;
          var y = lp.phi * RAD_TO_DEG$1;
          if (out) {
            out.x = x;
            out.y = y;
            return out;
          }
          return new Coordinate(x, y);
        }
      }, WGS84Sphere);
    }
  });

  var Projection_UTM = extend({}, PROJ9807, {
    code: 'utm',
    aliases: [],
    create: function create(params) {
      var P = {};
      var zone = parseInt(params.zone);
      P.falseNorthing = params.south ? 10000000 : 0;
      P.falseEasting = 500000;
      if (zone > 0 && zone <= 60) {
        zone--;
      } else {
        throw new Error('zone must be > 0 and <= 60.');
      }
      P.centralMeridian = (zone + 0.5) * 6 - 180;
      P.scaleFactor = 0.9996;
      return PROJ9807.create(P);
    }
  });

  var Projection_Baidu = extend({}, Common, {
    code: 'BAIDU',
    project: function project(p, out) {
      return this.convertLL2MC(p, out);
    },
    unproject: function unproject(p, out) {
      return this.convertMC2LL(p, out);
    }
  }, BaiduSphere, {
    EARTHRADIUS: 6370996.81,
    MCBAND: [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0],
    LLBAND: [75, 60, 45, 30, 15, 0],
    MC2LL: [[1.410526172116255e-8, 0.00000898305509648872, -1.9939833816331, 200.9824383106796, -187.2403703815547, 91.6087516669843, -23.38765649603339, 2.57121317296198, -0.03801003308653, 17337981.2], [-7.435856389565537e-9, 0.000008983055097726239, -0.78625201886289, 96.32687599759846, -1.85204757529826, -59.36935905485877, 47.40033549296737, -16.50741931063887, 2.28786674699375, 10260144.86], [-3.030883460898826e-8, 0.00000898305509983578, 0.30071316287616, 59.74293618442277, 7.357984074871, -25.38371002664745, 13.45380521110908, -3.29883767235584, 0.32710905363475, 6856817.37], [-1.981981304930552e-8, 0.000008983055099779535, 0.03278182852591, 40.31678527705744, 0.65659298677277, -4.44255534477492, 0.85341911805263, 0.12923347998204, -0.04625736007561, 4482777.06], [3.09191371068437e-9, 0.000008983055096812155, 0.00006995724062, 23.10934304144901, -0.00023663490511, -0.6321817810242, -0.00663494467273, 0.03430082397953, -0.00466043876332, 2555164.4], [2.890871144776878e-9, 0.000008983055095805407, -3.068298e-8, 7.47137025468032, -0.00000353937994, -0.02145144861037, -0.00001234426596, 0.00010322952773, -0.00000323890364, 826088.5]],
    LL2MC: [[-0.0015702102444, 111320.7020616939, 1704480524535203, -10338987376042340, 26112667856603880, -35149669176653700, 26595700718403920, -10725012454188240, 1800819912950474, 82.5], [0.0008277824516172526, 111320.7020463578, 647795574.6671607, -4082003173.641316, 10774905663.51142, -15171875531.51559, 12053065338.62167, -5124939663.577472, 913311935.9512032, 67.5], [0.00337398766765, 111320.7020202162, 4481351.045890365, -23393751.19931662, 79682215.47186455, -115964993.2797253, 97236711.15602145, -43661946.33752821, 8477230.501135234, 52.5], [0.00220636496208, 111320.7020209128, 51751.86112841131, 3796837.749470245, 992013.7397791013, -1221952.21711287, 1340652.697009075, -620943.6990984312, 144416.9293806241, 37.5], [-0.0003441963504368392, 111320.7020576856, 278.2353980772752, 2485758.690035394, 6070.750963243378, 54821.18345352118, 9540.606633304236, -2710.55326746645, 1405.483844121726, 22.5], [-0.0003218135878613132, 111320.7020701615, 0.00369383431289, 823725.6402795718, 0.46104986909093, 2351.343141331292, 1.58060784298199, 8.77738589078284, 0.37238884252424, 7.45]],
    convertMC2LL: function convertMC2LL(cB, out) {
      var cE;
      for (var cD = 0, len = this.MCBAND.length; cD < len; cD++) {
        if (Math.abs(cB.y) >= this.MCBAND[cD]) {
          cE = this.MC2LL[cD];
          break;
        }
      }
      var T = this.convertor(cB, cE, out);
      return T;
    },
    convertLL2MC: function convertLL2MC(T, out) {
      var cD, cC, len;
      T.x = this.getLoop(T.x, -180, 180);
      T.y = this.getRange(T.y, -74, 74);
      var cB = new Coordinate(T.x, T.y);
      for (cC = 0, len = this.LLBAND.length; cC < len; cC++) {
        if (cB.y >= this.LLBAND[cC]) {
          cD = this.LL2MC[cC];
          break;
        }
      }
      if (!cD) {
        for (cC = this.LLBAND.length - 1; cC >= 0; cC--) {
          if (cB.y <= -this.LLBAND[cC]) {
            cD = this.LL2MC[cC];
            break;
          }
        }
      }
      var cE = this.convertor(T, cD, out);
      return cE;
    },
    convertor: function convertor(cC, cD, out) {
      if (!cC || !cD) {
        return null;
      }
      var T = cD[0] + cD[1] * Math.abs(cC.x);
      var cB = Math.abs(cC.y) / cD[9];
      var cE = cD[2] + cD[3] * cB + cD[4] * cB * cB + cD[5] * cB * cB * cB + cD[6] * cB * cB * cB * cB + cD[7] * cB * cB * cB * cB * cB + cD[8] * cB * cB * cB * cB * cB * cB;
      T *= cC.x < 0 ? -1 : 1;
      cE *= cC.y < 0 ? -1 : 1;
      if (out) {
        out.x = T;
        out.y = cE;
        return out;
      }
      return new Coordinate(T, cE);
    },
    toRadians: function toRadians(T) {
      return Math.PI * T / 180;
    },
    toDegrees: function toDegrees(T) {
      return 180 * T / Math.PI;
    },
    getRange: function getRange(cC, cB, T) {
      if (cB != null) {
        cC = Math.max(cC, cB);
      }
      if (T != null) {
        cC = Math.min(cC, T);
      }
      return cC;
    },
    getLoop: function getLoop(cC, cB, T) {
      if (cC === Infinity) {
        return T;
      } else if (cC === -Infinity) {
        return cB;
      }
      while (cC > T) {
        cC -= T - cB;
      }
      while (cC < cB) {
        cC += T - cB;
      }
      return cC;
    }
  });

  var Projection_IDENTITY = extend({}, Common, {
    code: 'IDENTITY',
    project: function project(p, out) {
      if (out) {
        out.x = p.x;
        out.y = p.y;
        return out;
      }
      return p.copy();
    },
    unproject: function unproject(p, out) {
      if (out) {
        out.x = p.x;
        out.y = p.y;
        return out;
      }
      return p.copy();
    }
  }, Identity);

  var DEFAULT$1 = EPSG3857;

  var projections = /*#__PURE__*/Object.freeze({
    EPSG3857: EPSG3857,
    DEFAULT: DEFAULT$1,
    EPSG4326: Projection_EPSG4326,
    EPSG9807: PROJ9807,
    UTM: Projection_UTM,
    BAIDU: Projection_Baidu,
    IDENTITY: Projection_IDENTITY,
    Common: Common
  });

  var Renderable = (function (Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      _class.registerRenderer = function registerRenderer(name, clazz) {
        var proto = this.prototype;
        var parentProto = Object.getPrototypeOf(proto);
        if (!proto._rendererClasses || proto._rendererClasses === parentProto._rendererClasses) {
          proto._rendererClasses = proto._rendererClasses ? Object.create(proto._rendererClasses) : {};
        }
        proto._rendererClasses[name.toLowerCase()] = clazz;
        return this;
      };
      _class.getRendererClass = function getRendererClass(name) {
        var proto = this.prototype;
        if (!proto._rendererClasses) {
          return null;
        }
        return proto._rendererClasses[name.toLowerCase()];
      };
      return _class;
    }(Base);
  });

  var dedicatedWorker = 0;
  var EMPTY_BUFFERS = [];
  var Actor = function () {
    function Actor(workerKey) {
      var _this = this;
      startTasks();
      this._delayMessages = [];
      this.initializing = false;
      var hasCreated = adapterHasCreated(workerKey);
      if (workersHasCreated() && !hasCreated) {
        this.initializing = true;
        console.log("Injecting codes in worker with worker key: :" + workerKey);
        createAdapter(workerKey, function () {
          _this.initializing = false;
          _this.created();
        });
      }
      this.workerKey = workerKey;
      this.workerPool = getGlobalWorkerPool();
      this.currentActor = 0;
      this.actorId = UID();
      this.workers = this.workerPool.acquire(this.actorId);
      this.callbacks = {};
      this.callbackID = 0;
      this.receiveFn = this.receive.bind(this);
      this.workers.forEach(function (w) {
        w.addEventListener('message', _this.receiveFn, false);
      });
      pushAdapterCreated(workerKey);
    }
    var _proto = Actor.prototype;
    _proto.created = function created() {
      var _this2 = this;
      this._delayMessages.forEach(function (message) {
        var command = message.command,
          data = message.data,
          buffers = message.buffers,
          cb = message.cb,
          workerId = message.workerId;
        _this2[command](data, buffers, cb, workerId);
      });
      this._delayMessages = [];
    };
    _proto.isActive = function isActive() {
      return !!this.workers;
    };
    _proto.broadcast = function broadcast(data, buffers, cb) {
      var _this3 = this;
      if (this.initializing) {
        this._delayMessages.push({
          command: 'broadcast',
          data: data,
          buffers: buffers,
          cb: cb
        });
        return this;
      }
      cb = cb || function () {};
      asyncAll(this.workers, function (worker, done) {
        _this3.send(data, buffers, done, worker.id);
      }, cb);
      return this;
    };
    _proto.send = function send(data, buffers, cb, workerId) {
      if (this.initializing) {
        this._delayMessages.push({
          command: 'send',
          data: data,
          buffers: buffers,
          cb: cb,
          workerId: workerId
        });
        return this;
      }
      var id = cb ? this.actorId + ":" + this.callbackID++ : null;
      if (cb) this.callbacks[id] = cb;
      this.post({
        data: data,
        callback: String(id)
      }, buffers, workerId);
      return this;
    };
    _proto.receive = function receive(message) {
      var _this4 = this;
      var data = message.data,
        id = data.callback;
      var callback = this.callbacks[id];
      delete this.callbacks[id];
      if (data.type === '<request>') {
        if (this.actorId === data.actorId) {
          this[data.command](data.params, function (err, cbData, buffers) {
            var message = {
              type: '<response>',
              callback: data.callback
            };
            if (err) {
              message.error = err.message;
            } else {
              message.data = cbData;
            }
            _this4.post(message, buffers || EMPTY_BUFFERS, data.workerId);
          });
        }
      } else if (callback && data.error) {
        callback(data.error);
      } else if (callback) {
        callback(null, data.data);
      }
    };
    _proto.remove = function remove() {
      var _this5 = this;
      this.workers.forEach(function (w) {
        w.removeEventListener('message', _this5.receiveFn, false);
      });
      delete this.receiveFn;
      delete this.workers;
      delete this.callbacks;
      delete this.workerPool;
    };
    _proto.post = function post(data, buffers, targetID) {
      if (typeof targetID !== 'number' || isNaN(targetID)) {
        targetID = this.currentActor = (this.currentActor + 1) % this.workerPool.workerCount;
      }
      data.workerId = targetID;
      data.workerKey = this.workerKey;
      data.actorId = this.actorId;
      this.workerPool.addMessage(targetID, data, buffers || EMPTY_BUFFERS);
      return targetID;
    };
    _proto.getDedicatedWorker = function getDedicatedWorker() {
      dedicatedWorker = (dedicatedWorker + 1) % this.workerPool.workerCount;
      return dedicatedWorker;
    };
    return Actor;
  }();
  function asyncAll(array, fn, callback) {
    if (!array.length) {
      callback(null, []);
    }
    var remaining = array.length;
    var results = new Array(array.length);
    var error = null;
    array.forEach(function (item, i) {
      fn(item, function (err, result) {
        if (err) error = err;
        results[i] = result;
        if (--remaining === 0) callback(error, results);
      });
    });
  }

  var EMPTY_ARRAY = [];
  var ResourceWorkerConnection = function (_Actor) {
    _inheritsLoose(ResourceWorkerConnection, _Actor);
    function ResourceWorkerConnection() {
      return _Actor.call(this, imageFetchWorkerKey) || this;
    }
    var _proto = ResourceWorkerConnection.prototype;
    _proto.fetchImage = function fetchImage(url, cb) {
      var data = {
        url: url
      };
      this.send(data, EMPTY_ARRAY, cb);
    };
    return ResourceWorkerConnection;
  }(Actor);
  var CanvasRenderer = function (_Class) {
    _inheritsLoose(CanvasRenderer, _Class);
    function CanvasRenderer(layer) {
      var _this;
      _this = _Class.call(this) || this;
      _this.layer = layer;
      _this._painted = false;
      _this._drawTime = 0;
      if (Browser$1.decodeImageInWorker && !Browser$1.safari && !Browser$1.iosWeixin) {
        _this._resWorkerConn = new ResourceWorkerConnection();
      }
      _this.setToRedraw();
      return _this;
    }
    var _proto2 = CanvasRenderer.prototype;
    _proto2.render = function render(framestamp) {
      this.prepareRender();
      if (!this.getMap() || !this.layer.isVisible()) {
        return;
      }
      if (!this.resources) {
        this.resources = new ResourceCache();
      }
      this.checkAndDraw(this._tryToDraw, framestamp);
      this._frameTime = framestamp;
    };
    _proto2.getFrameTimestamp = function getFrameTimestamp() {
      return this._frameTime || 0;
    };
    _proto2.checkAndDraw = function checkAndDraw(drawFn) {
      var _this2 = this;
      this._toRedraw = false;
      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
      }
      if (this.checkResources) {
        var resources = this.checkResources();
        if (resources.length > 0) {
          this._loadingResource = true;
          this.loadResources(resources).then(function () {
            _this2._loadingResource = false;
            if (_this2.layer) {
              _this2.layer.fire('resourceload');
              var map = _this2.layer.getMap();
              _this2.setToRedraw();
              map.getRenderer().callInNextFrame(function () {
                _this2.setToRedraw();
              });
            }
          });
        } else {
          drawFn.call.apply(drawFn, [this].concat(args));
        }
      } else {
        drawFn.call.apply(drawFn, [this].concat(args));
      }
    };
    _proto2.testIfNeedRedraw = function testIfNeedRedraw() {
      var map = this.getMap();
      if (this._loadingResource) {
        return false;
      }
      if (this._toRedraw) {
        return true;
      }
      if (map.isInteracting() && !this.drawOnInteracting) {
        return false;
      }
      if (this.needToRedraw()) {
        return true;
      }
      return false;
    };
    _proto2.needToRedraw = function needToRedraw() {
      var map = this.getMap();
      if (map.isInteracting() || map.getRenderer().isViewChanged()) {
        return !(!map.getPitch() && map.isMoving() && !map.isZooming() && !map.isRotating() && !this.layer.options['forceRenderOnMoving']);
      }
      return false;
    };
    _proto2.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {};
    _proto2.isLoadingResource = function isLoadingResource() {
      return this._loadingResource;
    };
    _proto2.isRenderComplete = function isRenderComplete() {
      return !!this._renderComplete;
    };
    _proto2.mustRenderOnInteracting = function mustRenderOnInteracting() {
      return !this._painted;
    };
    _proto2.setToRedraw = function setToRedraw() {
      this._toRedraw = true;
      return this;
    };
    _proto2.setCanvasUpdated = function setCanvasUpdated() {
      this._canvasUpdated = true;
      return this;
    };
    _proto2.isCanvasUpdated = function isCanvasUpdated() {
      return !!this._canvasUpdated;
    };
    _proto2.remove = function remove() {
      this.onRemove();
      delete this._loadingResource;
      delete this.southWest;
      delete this.canvas;
      delete this.context;
      delete this.canvasExtent2D;
      delete this._extent2D;
      if (this.resources) {
        this.resources.remove();
      }
      delete this.resources;
      if (this._resWorkerConn) {
        this._resWorkerConn.remove();
        delete this._resWorkerConn;
      }
      delete this.layer;
    };
    _proto2.onRemove = function onRemove() {};
    _proto2.onAdd = function onAdd() {};
    _proto2.getMap = function getMap() {
      if (!this.layer) {
        return null;
      }
      return this.layer.getMap();
    };
    _proto2.getCanvasImage = function getCanvasImage() {
      var map = this.getMap();
      this._canvasUpdated = false;
      if (this._renderZoom !== map.getZoom() || !this.canvas || !this._extent2D) {
        return null;
      }
      if (this.isBlank()) {
        return null;
      }
      if (this.layer.isEmpty && this.layer.isEmpty()) {
        return null;
      }
      var containerPoint = map._pointToContainerPoint(this.southWest)._add(0, -map.height);
      return {
        'image': this.canvas,
        'layer': this.layer,
        'point': containerPoint
      };
    };
    _proto2.clear = function clear() {
      this.clearCanvas();
    };
    _proto2.isBlank = function isBlank() {
      if (!this._painted) {
        return true;
      }
      return false;
    };
    _proto2.show = function show() {
      this.setToRedraw();
    };
    _proto2.hide = function hide() {
      this.clear();
      this.setToRedraw();
    };
    _proto2.setZIndex = function setZIndex() {
      this.setToRedraw();
    };
    _proto2.hitDetect = function hitDetect(point) {
      if (!this.context || this.layer.isEmpty && this.layer.isEmpty() || this.isBlank() || this._errorThrown || this.layer.isVisible && !this.layer.isVisible()) {
        return false;
      }
      var map = this.getMap();
      var r = map.getDevicePixelRatio();
      var size = map.getSize();
      if (point.x < 0 || point.x > size['width'] * r || point.y < 0 || point.y > size['height'] * r) {
        return false;
      }
      var imageData = this.getImageData && this.getImageData();
      if (imageData) {
        var x = Math.round(r * point.x),
          y = Math.round(r * point.y);
        var idx = y * imageData.width * 4 + x * 4;
        return imageData.data[idx + 3] > 0;
      }
      try {
        var imgData = this.context.getImageData(r * point.x, r * point.y, 1, 1).data;
        if (imgData[3] > 0) {
          return true;
        }
      } catch (error) {
        if (!this._errorThrown) {
          if (console) {
            console.warn('hit detect failed with tainted canvas, some geometries have external resources in another domain:\n', error);
          }
          this._errorThrown = true;
        }
        return false;
      }
      return false;
    };
    _proto2.loadResources = function loadResources(resourceUrls) {
      if (!this.resources) {
        this.resources = new ResourceCache();
      }
      var resources = this.resources,
        promises = [];
      if (isArrayHasData(resourceUrls)) {
        var cache = {};
        for (var i = resourceUrls.length - 1; i >= 0; i--) {
          var url = resourceUrls[i];
          if (!url || !url.length || cache[url.join('-')]) {
            continue;
          }
          cache[url.join('-')] = 1;
          if (!resources.isResourceLoaded(url, true)) {
            promises.push(new Promise$1(this._promiseResource(url)));
          }
        }
      }
      return Promise$1.all(promises);
    };
    _proto2.prepareRender = function prepareRender() {
      delete this._renderComplete;
      var map = this.getMap();
      this._renderZoom = map.getZoom();
      this.canvasExtent2D = this._extent2D = map._get2DExtent();
      this.southWest = map._containerPointToPoint(new Point(0, map.height));
    };
    _proto2.createCanvas = function createCanvas() {
      if (this.canvas) {
        return;
      }
      var map = this.getMap();
      var size = map.getSize();
      var r = map.getDevicePixelRatio(),
        w = Math.round(r * size.width),
        h = Math.round(r * size.height);
      if (this.layer._canvas) {
        var canvas = this.layer._canvas;
        canvas.width = w;
        canvas.height = h;
        if (canvas.style) {
          canvas.style.width = size.width + 'px';
          canvas.style.height = size.height + 'px';
        }
        this.canvas = this.layer._canvas;
      } else {
        this.canvas = Canvas.createCanvas(w, h, map.CanvasClass);
      }
      this.onCanvasCreate();
    };
    _proto2.onCanvasCreate = function onCanvasCreate() {};
    _proto2.createContext = function createContext() {
      if (this.gl && this.gl.canvas === this.canvas || this.context) {
        return;
      }
      this.context = Canvas.getCanvas2DContext(this.canvas);
      if (!this.context) {
        return;
      }
      if (this.layer.options['globalCompositeOperation']) {
        this.context.globalCompositeOperation = this.layer.options['globalCompositeOperation'];
      }
      var dpr = this.getMap().getDevicePixelRatio();
      if (dpr !== 1) {
        this.context.scale(dpr, dpr);
      }
    };
    _proto2.resetCanvasTransform = function resetCanvasTransform() {
      if (!this.context) {
        return;
      }
      var dpr = this.getMap().getDevicePixelRatio();
      this.context.setTransform(dpr, 0, 0, dpr, 0, 0);
    };
    _proto2.resizeCanvas = function resizeCanvas(canvasSize) {
      var canvas = this.canvas;
      if (!canvas) {
        return;
      }
      var size = canvasSize || this.getMap().getSize();
      var r = this.getMap().getDevicePixelRatio();
      var _calCanvasSize = calCanvasSize(size, r),
        width = _calCanvasSize.width,
        height = _calCanvasSize.height,
        cssWidth = _calCanvasSize.cssWidth,
        cssHeight = _calCanvasSize.cssHeight;
      if (this.layer._canvas && (canvas.style.width !== cssWidth || canvas.style.height !== cssHeight)) {
        canvas.style.width = cssWidth;
        canvas.style.height = cssHeight;
      }
      if (canvas.width === width && canvas.height === height) {
        return;
      }
      canvas.height = height;
      canvas.width = width;
      if (r !== 1 && this.context) {
        this.context.scale(r, r);
      }
    };
    _proto2.clearCanvas = function clearCanvas() {
      if (!this.context || !this.getMap()) {
        return;
      }
      var r = this.getMap().getDevicePixelRatio();
      var rScale = 1 / r;
      var w = this.canvas.width * rScale,
        h = this.canvas.height * rScale;
      Canvas.clearRect(this.context, 0, 0, Math.max(w, this.canvas.width), Math.max(h, this.canvas.height));
    };
    _proto2.prepareCanvas = function prepareCanvas() {
      if (!this.canvas) {
        this.createCanvas();
        this.createContext();
        this.layer.onCanvasCreate();
        this.layer.fire('canvascreate', {
          'context': this.context,
          'gl': this.gl
        });
      } else {
        this.resetCanvasTransform();
        this.clearCanvas();
        this.resizeCanvas();
      }
      delete this._maskExtent;
      var mask = this.layer.getMask();
      if (!mask) {
        this.layer.fire('renderstart', {
          'context': this.context,
          'gl': this.gl
        });
        return null;
      }
      var maskExtent2D = this._maskExtent = mask._getMaskPainter().get2DExtent();
      if (!maskExtent2D.intersects(this._extent2D)) {
        this.layer.fire('renderstart', {
          'context': this.context,
          'gl': this.gl
        });
        return maskExtent2D;
      }
      this.layer.fire('renderstart', {
        'context': this.context,
        'gl': this.gl
      });
      return maskExtent2D;
    };
    _proto2.clipCanvas = function clipCanvas(context) {
      var mask = this.layer.getMask();
      if (!mask) {
        return false;
      }
      var old = this.southWest;
      var map = this.getMap();
      this.southWest = map._containerPointToPoint(new Point(0, map.height));
      context.save();
      var dpr = map.getDevicePixelRatio();
      if (dpr !== 1) {
        context.save();
        context.scale(dpr, dpr);
      }
      if (mask.getGeometries) {
        context.isMultiClip = true;
        var masks = mask.getGeometries() || [];
        context.beginPath();
        masks.forEach(function (_mask) {
          var painter = _mask._getMaskPainter();
          painter.paint(null, context);
        });
        context.stroke();
        context.isMultiClip = false;
      } else {
        context.isClip = true;
        context.beginPath();
        var painter = mask._getMaskPainter();
        painter.paint(null, context);
        context.isClip = false;
      }
      if (dpr !== 1) {
        context.restore();
      }
      context.clip();
      this.southWest = old;
      return true;
    };
    _proto2.getViewExtent = function getViewExtent() {
      return {
        'extent': this._extent2D,
        'maskExtent': this._maskExtent,
        'zoom': this._renderZoom,
        'southWest': this.southWest
      };
    };
    _proto2.completeRender = function completeRender() {
      if (this.getMap()) {
        this._renderComplete = true;
        this.layer.fire('renderend', {
          'context': this.context,
          'gl': this.gl
        });
        this.setCanvasUpdated();
      }
    };
    _proto2.getEvents = function getEvents() {
      return {
        '_zoomstart': this.onZoomStart,
        '_zooming': this.onZooming,
        '_zoomend': this.onZoomEnd,
        '_resize': this.onResize,
        '_movestart': this.onMoveStart,
        '_moving': this.onMoving,
        '_moveend': this.onMoveEnd,
        '_dragrotatestart': this.onDragRotateStart,
        '_dragrotating': this.onDragRotating,
        '_dragrotateend': this.onDragRotateEnd,
        '_spatialreferencechange': this.onSpatialReferenceChange
      };
    };
    _proto2.onZoomStart = function onZoomStart() {};
    _proto2.onZoomEnd = function onZoomEnd() {
      this.setToRedraw();
    };
    _proto2.onZooming = function onZooming() {};
    _proto2.onMoveStart = function onMoveStart() {};
    _proto2.onMoving = function onMoving() {};
    _proto2.onMoveEnd = function onMoveEnd() {
      this.setToRedraw();
    };
    _proto2.onResize = function onResize() {
      delete this._extent2D;
      this.resizeCanvas();
      this.setToRedraw();
    };
    _proto2.onDragRotateStart = function onDragRotateStart() {};
    _proto2.onDragRotating = function onDragRotating() {};
    _proto2.onDragRotateEnd = function onDragRotateEnd() {
      this.setToRedraw();
    };
    _proto2.onSpatialReferenceChange = function onSpatialReferenceChange() {};
    _proto2.getDrawTime = function getDrawTime() {
      return this._drawTime;
    };
    _proto2._tryToDraw = function _tryToDraw(framestamp) {
      this._toRedraw = false;
      if (!this.canvas && this.layer.isEmpty && this.layer.isEmpty()) {
        this._renderComplete = true;
        return;
      }
      this._drawAndRecord(framestamp);
    };
    _proto2._drawAndRecord = function _drawAndRecord(framestamp) {
      if (!this.getMap()) {
        return;
      }
      var painted = this._painted;
      this._painted = true;
      var t = now();
      this.draw(framestamp);
      t = now() - t;
      this._drawTime = painted ? t : t / 2;
      if (painted && this.layer && this.layer.options['logDrawTime']) {
        console.log(this.layer.getId(), 'frameTimeStamp:', framestamp, 'drawTime:', this._drawTime);
      }
    };
    _proto2._promiseResource = function _promiseResource(url) {
      var layer = this.layer;
      var me = this,
        resources = this.resources,
        crossOrigin = layer.options['crossOrigin'];
      var renderer = layer.options['renderer'] || '';
      return function (resolve) {
        if (resources.isResourceLoaded(url, true)) {
          resolve(url);
          return;
        }
        var fetchInWorker = !isSVG(url[0]) && me._resWorkerConn && (layer.options['renderer'] !== 'canvas' || layer.options['decodeImageInWorker']);
        if (fetchInWorker) {
          var uri = getAbsoluteURL(url[0]);
          me._resWorkerConn.fetchImage(uri, function (err, data) {
            if (err) {
              if (err && typeof console !== 'undefined') {
                console.warn(err);
              }
              resolve(url);
              return;
            }
            getImageBitMap(data, function (bitmap) {
              me._cacheResource(url, bitmap);
              resolve(url);
            });
          });
        } else {
          var img = new Image();
          if (!isNil(crossOrigin)) {
            img['crossOrigin'] = crossOrigin;
          } else if (renderer !== 'canvas') {
            img['crossOrigin'] = '';
          }
          if (isSVG(url[0]) && !IS_NODE) {
            if (url[1]) {
              url[1] *= 2;
            }
            if (url[2]) {
              url[2] *= 2;
            }
          }
          img.onload = function () {
            me._cacheResource(url, img);
            resolve(url);
          };
          img.onabort = function (err) {
            if (console) {
              console.warn('image loading aborted: ' + url[0]);
            }
            if (err) {
              if (console) {
                console.warn(err);
              }
            }
            resolve(url);
          };
          img.onerror = function (err) {
            if (err && typeof console !== 'undefined') {
              console.warn(err);
            }
            resources.markErrorResource(url);
            resolve(url);
          };
          loadImage(img, url);
        }
      };
    };
    _proto2._cacheResource = function _cacheResource(url, img) {
      if (!this.layer || !this.resources) {
        return;
      }
      var w = url[1],
        h = url[2];
      if (this.layer.options['cacheSvgOnCanvas'] && isSVG(url[0]) === 1 && (Browser$1.edge || Browser$1.ie)) {
        if (isNil(w)) {
          w = img.width || this.layer.options['defaultIconSize'][0];
        }
        if (isNil(h)) {
          h = img.height || this.layer.options['defaultIconSize'][1];
        }
        var canvas = Canvas.createCanvas(w, h);
        Canvas.image(canvas.getContext('2d'), img, 0, 0, w, h);
        img = canvas;
      }
      this.resources.addResource(url, img);
    };
    return CanvasRenderer;
  }(Class);
  var ResourceCache = function () {
    function ResourceCache() {
      this.resources = {};
      this._errors = {};
    }
    var _proto3 = ResourceCache.prototype;
    _proto3.addResource = function addResource(url, img) {
      var _this3 = this;
      this.resources[url[0]] = {
        image: img,
        width: +url[1],
        height: +url[2],
        refCnt: 0
      };
      if (img && img.width && img.height && !img.close && Browser$1.imageBitMap && !Browser$1.safari && !Browser$1.iosWeixin) {
        if (img.src && isSVG(img.src)) {
          return;
        }
        createImageBitmap(img).then(function (imageBitmap) {
          if (!_this3.resources[url[0]]) {
            return;
          }
          _this3.resources[url[0]].image = imageBitmap;
        });
      }
    };
    _proto3.isResourceLoaded = function isResourceLoaded(url, checkSVG) {
      if (!url) {
        return false;
      }
      var imgUrl = this._getImgUrl(url);
      if (this._errors[imgUrl]) {
        return true;
      }
      var img = this.resources[imgUrl];
      if (!img) {
        return false;
      }
      if (checkSVG && isSVG(url[0]) && (+url[1] > img.width || +url[2] > img.height)) {
        return false;
      }
      return true;
    };
    _proto3.login = function login(url) {
      var res = this.resources[url];
      if (res) {
        res.refCnt++;
      }
    };
    _proto3.logout = function logout(url) {
      var res = this.resources[url];
      if (res && res.refCnt-- <= 0) {
        if (res.image && res.image.close) {
          res.image.close();
        }
        delete this.resources[url];
      }
    };
    _proto3.getImage = function getImage(url) {
      var imgUrl = this._getImgUrl(url);
      if (!this.isResourceLoaded(url) || this._errors[imgUrl]) {
        return null;
      }
      return this.resources[imgUrl].image;
    };
    _proto3.markErrorResource = function markErrorResource(url) {
      this._errors[this._getImgUrl(url)] = 1;
    };
    _proto3.merge = function merge(res) {
      if (!res) {
        return this;
      }
      for (var p in res.resources) {
        var img = res.resources[p];
        this.addResource([p, img.width, img.height], img.image);
      }
      return this;
    };
    _proto3.forEach = function forEach(fn) {
      if (!this.resources) {
        return this;
      }
      for (var p in this.resources) {
        if (hasOwn(this.resources, p)) {
          fn(p, this.resources[p]);
        }
      }
      return this;
    };
    _proto3._getImgUrl = function _getImgUrl(url) {
      if (!Array.isArray(url)) {
        return url;
      }
      return url[0];
    };
    _proto3.remove = function remove() {
      for (var p in this.resources) {
        var res = this.resources[p];
        if (res && res.image && res.image.close) {
          res.image.close();
        }
      }
      this.resources = {};
    };
    return ResourceCache;
  }();
  var workerSource = "\nfunction (exports) {\n    exports.onmessage = function (msg, postResponse) {\n        var url = msg.data.url;\n        var fetchOptions = msg.data.fetchOptions;\n        requestImageOffscreen(url, function (err, data) {\n            var buffers = [];\n            if (data && data.data) {\n                buffers.push(data.data);\n            }\n            postResponse(err, data, buffers);\n        }, fetchOptions);\n    };\n\n    function requestImageOffscreen(url, cb, fetchOptions) {\n        fetch(url, fetchOptions ? fetchOptions : {})\n            .then(response => response.arrayBuffer())\n            .then(arrayBuffer => {\n                const blob=new Blob([arrayBuffer]);\n                return createImageBitmap(blob);\n            })\n            .then(bitmap => {\n                cb(null, {data:bitmap});\n            }).catch(err => {\n                console.warn('error when loading tile:', url);\n                console.warn(err);\n                cb(err);\n            });\n    }\n}";
  function registerWorkerSource() {
    if (!Browser$1.decodeImageInWorker) {
      return;
    }
    registerWorkerAdapter(imageFetchWorkerKey, function () {
      return workerSource;
    });
  }
  registerWorkerSource();

  var DEFAULT_MARKER_SYMBOLS = {
    markerWidth: 10,
    markerHeight: 10,
    markerLineWidth: 1
  };
  var TEMP_DXDYPOINT = new Point(0, 0);
  function getDxDyRad(dxdy) {
    if (!dxdy) {
      return 0;
    }
    var x = dxdy.x,
      y = dxdy.y;
    if (x === 0 && y === 0) {
      return 0;
    }
    if (x === 0 || !x) {
      if (y < 0) {
        return -Math.PI / 2;
      }
      if (y > 0) {
        return Math.PI / 2;
      }
    }
    var tan = y / x;
    if (y < 0 && x < 0) {
      return Math.atan(tan) - Math.PI;
    } else if (y > 0 && x < 0) {
      return Math.atan(tan) + Math.PI;
    }
    return Math.atan(tan);
  }
  function getImageRotateBBOX(width, height, rad) {
    var rad2 = Math.PI / 2 + rad;
    var rad3 = Math.PI / 4 + rad;
    var rad4 = rad;
    var r2 = height;
    var r3 = Math.sqrt(width * width + height * height);
    var r4 = width;
    var p1x = 0,
      p1y = 0;
    var p2x = Math.cos(rad2) * r2,
      p2y = Math.sin(rad2) * r2;
    var p3x = Math.cos(rad3) * r3,
      p3y = Math.sin(rad3) * r3;
    var p4x = Math.cos(rad4) * r4,
      p4y = Math.sin(rad4) * r4;
    var minx = Math.min(p2x, p3x, p4x, p1x);
    var miny = Math.min(p2y, p3y, p4y, p1y);
    var maxx = Math.max(p2x, p3x, p4x, p1x);
    var maxy = Math.max(p2y, p3y, p4y, p1y);
    return [minx, miny, maxx - minx, maxy - miny];
  }
  function getMarkerRotationExtent(out, rad, width, height, dxdy, alignPoint) {
    var x = dxdy.x + alignPoint.x,
      y = dxdy.y + alignPoint.y;
    TEMP_DXDYPOINT.x = x;
    TEMP_DXDYPOINT.y = y;
    var dxdyRad = getDxDyRad(TEMP_DXDYPOINT);
    var radius = Math.sqrt(x * x + y * y);
    var rx = Math.cos(rad + dxdyRad) * radius,
      ry = Math.sin(rad + dxdyRad) * radius;
    var minx = 0,
      miny = 0;
    minx += rx;
    miny += ry;
    var _getImageRotateBBOX = getImageRotateBBOX(width, height, rad, alignPoint),
      offsetX = _getImageRotateBBOX[0],
      offsetY = _getImageRotateBBOX[1],
      w = _getImageRotateBBOX[2],
      h = _getImageRotateBBOX[3];
    minx += offsetX;
    miny += offsetY;
    var maxx = minx + Math.max(width, w),
      maxy = miny + Math.max(height, h);
    out.set(minx, miny, maxx, maxy);
    return out;
  }
  function getVectorPadding() {
    return 0.5;
  }
  var DXDY = new Point(0, 0);
  function getFixedExtent(out, dx, dy, rotation, alignPoint, w, h) {
    var dxdy = DXDY.set(dx, dy);
    if (rotation) {
      return getMarkerRotationExtent(out, rotation, w, h, dxdy, alignPoint);
    }
    var result = out.set(dxdy.x, dxdy.y, dxdy.x + w, dxdy.y + h);
    result._add(alignPoint);
    if (rotation) {
      rotateExtent(result, rotation);
    }
    return result;
  }
  var SIZE = [];
  function getVectorMarkerFixedExtent(out, symbol, size) {
    size = size || calVectorMarkerSize(SIZE, symbol);
    if (size && (size[0] === 0 || size[1] === 0)) {
      emptyExtent(out);
      return out;
    }
    var alignPoint = getVectorMarkerAnchor(symbol, size[0], size[1]);
    return getFixedExtent(out, symbol['markerDx'] || 0, symbol['markerDy'] || 0, getMarkerRotation(symbol), alignPoint, size[0], size[1]);
  }
  function getDefaultHAlign(markerType) {
    if (markerType === 'rectangle') {
      return 'right';
    } else {
      return 'middle';
    }
  }
  function getDefaultVAlign(markerType) {
    if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
      return 'top';
    } else if (markerType === 'rectangle') {
      return 'bottom';
    } else {
      return 'middle';
    }
  }
  var TEMP_SIZE = new Size(0, 0);
  function getVectorMarkerAnchor(symbol, w, h) {
    var padding = getVectorPadding();
    var shadow = 2 * (symbol['shadowBlur'] || 0),
      margin = shadow + padding;
    TEMP_SIZE.width = w;
    TEMP_SIZE.height = h;
    var markerType = symbol['markerType'];
    var p = getAlignPoint(TEMP_SIZE, symbol['markerHorizontalAlignment'] || getDefaultHAlign(markerType), symbol['markerVerticalAlignment'] || getDefaultVAlign(markerType));
    if (p.x !== -w / 2) {
      p.x -= sign(p.x + w / 2) * margin;
    }
    if (p.y !== -h / 2) {
      p.y -= sign(p.y + h / 2) * margin;
    }
    return p;
  }
  function calVectorMarkerSize(out, symbol) {
    var padding = getVectorPadding(symbol);
    var width = getValueOrDefault(symbol['markerWidth'], DEFAULT_MARKER_SYMBOLS.markerWidth);
    var height = getValueOrDefault(symbol['markerHeight'], DEFAULT_MARKER_SYMBOLS.markerHeight);
    if (width === 0 || height === 0) {
      out[0] = 0;
      out[1] = 0;
      return out;
    }
    var lineWidth = getValueOrDefault(symbol['markerLineWidth'], DEFAULT_MARKER_SYMBOLS.markerLineWidth),
      shadow = 2 * ((symbol['shadowBlur'] || 0) + Math.max(Math.abs(symbol['shadowOffsetX'] || 0) + Math.abs(symbol['shadowOffsetY'] || 0))),
      w = Math.round(width + lineWidth + shadow + padding * 2),
      h = Math.round(height + lineWidth + shadow + padding * 2);
    out[0] = w;
    out[1] = h;
    return out;
  }
  var ROTATE_EXTENT = new PointExtent();
  function rotateExtent(fixedExtent, angle) {
    var xmin = fixedExtent.xmin,
      ymin = fixedExtent.ymin,
      xmax = fixedExtent.xmax,
      ymax = fixedExtent.ymax;
    ROTATE_EXTENT.set(xmin, ymin, xmax, ymax);
    return ROTATE_EXTENT.convertTo(function (p) {
      return p._rotate(angle);
    }, fixedExtent);
  }
  function getMarkerRotation(symbol, prop) {
    if (prop === void 0) {
      prop = 'markerRotation';
    }
    var r = symbol[prop];
    if (!isNumber(r)) {
      return 0;
    }
    return -r * Math.PI / 180;
  }
  function getImageMarkerFixedExtent(out, symbol, resources) {
    var url = symbol['markerFile'],
      img = resources ? resources.getImage(url) : null;
    var width = symbol['markerWidth'] || (img ? img.width : 0),
      height = symbol['markerHeight'] || (img ? img.height : 0);
    TEMP_SIZE.width = width;
    TEMP_SIZE.height = height;
    if (symbol['markerWidth'] === 0 || symbol['markerHeight'] === 0) {
      emptyExtent(out);
      return out;
    }
    var alignPoint = getAlignPoint(TEMP_SIZE, symbol['markerHorizontalAlignment'] || 'middle', symbol['markerVerticalAlignment'] || 'top');
    return getFixedExtent(out, symbol['markerDx'] || 0, symbol['markerDy'] || 0, getMarkerRotation(symbol), alignPoint, width, height);
  }
  function getTextMarkerFixedExtent(out, symbol, textDesc) {
    var size = textDesc['size'];
    if (size && (size.width === 0 || size.height === 0)) {
      emptyExtent(out);
      return out;
    }
    var alignPoint = getAlignPoint(size, symbol['textHorizontalAlignment'], symbol['textVerticalAlignment']);
    var textHaloRadius = symbol.textHaloRadius || 0;
    var extent = getFixedExtent(out, symbol['textDx'] || 0, symbol['textDy'] || 0, getMarkerRotation(symbol, 'textRotation'), alignPoint, size.width, size.height);
    extent.xmin -= textHaloRadius;
    extent.xmax += textHaloRadius;
    extent.ymin -= textHaloRadius;
    extent.ymax += textHaloRadius;
    return extent;
  }
  var FIXED_EXTENT = new PointExtent();
  function getMarkerFixedExtent(out, symbol, resources, textDesc) {
    var extent = out || new PointExtent();
    if (Array.isArray(symbol)) {
      var symbols = symbol;
      for (var i = 0; i < symbols.length; i++) {
        getMarkerFixedExtent(extent, symbols[i], resources, textDesc[i]);
      }
      return extent;
    }
    if (isTextSymbol(symbol)) {
      extent._combine(getTextMarkerFixedExtent(FIXED_EXTENT, symbol, textDesc));
    }
    if (isImageSymbol(symbol)) {
      extent._combine(getImageMarkerFixedExtent(FIXED_EXTENT, symbol, resources));
    }
    if (isVectorSymbol(symbol)) {
      extent._combine(getVectorMarkerFixedExtent(FIXED_EXTENT, symbol));
    }
    if (isPathSymbol(symbol)) {
      extent._combine(getImageMarkerFixedExtent(FIXED_EXTENT, symbol));
    }
    return extent;
  }
  function isTextSymbol(symbol) {
    if (!symbol) {
      return false;
    }
    if (!isNil(symbol['textName'])) {
      return true;
    }
    return false;
  }
  function isImageSymbol(symbol) {
    if (!symbol) {
      return false;
    }
    if (!isNil(symbol['markerFile'])) {
      return true;
    }
    return false;
  }
  function isVectorSymbol(symbol) {
    if (!symbol) {
      return false;
    }
    if (isNil(symbol['markerFile']) && !isNil(symbol['markerType']) && symbol['markerType'] !== 'path') {
      return true;
    }
    return false;
  }
  function isPathSymbol(symbol) {
    if (!symbol) {
      return false;
    }
    if (isNil(symbol['markerFile']) && symbol['markerType'] === 'path') {
      return true;
    }
    return false;
  }
  var DYNAMIC_SYMBOL_PROPS = ['markerWidth', 'markerHeight', 'markerHorizontalAlignment', 'markerVerticalAlignment', 'markerDx', 'markerDy', 'markerRotation', 'textName', 'textSize', 'textDx', 'textDy', 'textVerticalAlignment', 'textHorizontalAlignment', 'textRotation', 'textWrapWidth'];
  var SIZE_SYMBOL_PROPS = ['textName', 'markerType', 'markerFile', 'textHaloRadius', 'shadowBlur', 'shadowOffsetX', 'shadowOffsetY', 'textWrapWidth'];
  function emptyExtent(extent) {
    if (!extent) {
      return;
    }
    extent.xmin = Infinity;
    extent.ymin = Infinity;
    extent.xmax = -Infinity;
    extent.ymax = -Infinity;
  }

  function clipLine(points, bounds, round, noCut) {
    var parts = [];
    var k = 0,
      segment;
    for (var j = 0, l = points.length; j < l - 1; j++) {
      segment = clipSegment(points[j], points[j + 1], bounds, j, round, noCut);
      if (!segment) {
        continue;
      }
      parts[k] = parts[k] || [];
      parts[k].push({
        'point': segment[0],
        'index': j
      });
      if (segment[1] !== points[j + 1] || j === l - 2) {
        parts[k].push({
          'point': segment[1],
          'index': j + 1
        });
        k++;
      }
    }
    return parts;
  }
  var _lastCode;
  function clipSegment(a, b, bounds, useLastCode, round, noCut) {
    var codeA = useLastCode ? _lastCode : _getBitCode(a, bounds),
      codeB = _getBitCode(b, bounds),
      codeOut,
      p,
      newCode;
    _lastCode = codeB;
    while (true) {
      if (!(codeA | codeB)) {
        return [a, b];
      }
      if (codeA & codeB) {
        return false;
      }
      if (noCut) {
        return [a, b];
      }
      codeOut = codeA || codeB;
      p = _getEdgeIntersection(a, b, codeOut, bounds, round);
      newCode = _getBitCode(p, bounds);
      if (codeOut === codeA) {
        a = p;
        codeA = newCode;
      } else {
        b = p;
        codeB = newCode;
      }
    }
  }
  function clipPolygon(points, bounds, round) {
    var edges = [1, 4, 2, 8];
    var clippedPoints, i, j, k, a, b, len, edge, p;
    for (i = 0, len = points.length; i < len; i++) {
      points[i]._code = _getBitCode(points[i], bounds);
    }
    for (k = 0; k < 4; k++) {
      edge = edges[k];
      clippedPoints = [];
      for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
        a = points[i];
        b = points[j];
        if (!(a._code & edge)) {
          if (b._code & edge) {
            p = _getEdgeIntersection(b, a, edge, bounds, round);
            p._code = _getBitCode(p, bounds);
            clippedPoints.push(p);
          }
          clippedPoints.push(a);
        } else if (!(b._code & edge)) {
          p = _getEdgeIntersection(b, a, edge, bounds, round);
          p._code = _getBitCode(p, bounds);
          clippedPoints.push(p);
        }
      }
      points = clippedPoints;
    }
    return points;
  }
  function _getEdgeIntersection(a, b, code, bounds, round) {
    var dx = b.x - a.x,
      dy = b.y - a.y,
      min = bounds.getMin(),
      max = bounds.getMax();
    var x, y;
    if (code & 8) {
      x = a.x + dx * (max.y - a.y) / dy;
      y = max.y;
    } else if (code & 4) {
      x = a.x + dx * (min.y - a.y) / dy;
      y = min.y;
    } else if (code & 2) {
      x = max.x;
      y = a.y + dy * (max.x - a.x) / dx;
    } else if (code & 1) {
      x = min.x;
      y = a.y + dy * (min.x - a.x) / dx;
    }
    var p = new Point(x, y);
    if (round) {
      p._round();
    }
    return p;
  }
  function _getBitCode(p, bounds) {
    var code = 0;
    if (p.x < bounds.getMin().x) {
      code |= 1;
    } else if (p.x > bounds.getMax().x) {
      code |= 2;
    }
    if (p.y < bounds.getMin().y) {
      code |= 4;
    } else if (p.y > bounds.getMax().y) {
      code |= 8;
    }
    return code;
  }
  function withInEllipse(point, center, southeast, tolerance) {
    point = new Point(point);
    var a = Math.abs(southeast.x - center.x),
      b = Math.abs(southeast.y - center.y),
      c = Math.sqrt(Math.abs(a * a - b * b)),
      xfocus = a >= b;
    var f1, f2, d;
    if (xfocus) {
      f1 = new Point(center.x - c, center.y);
      f2 = new Point(center.x + c, center.y);
      d = a * 2;
    } else {
      f1 = new Point(center.x, center.y - c);
      f2 = new Point(center.x, center.y + c);
      d = b * 2;
    }
    return point.distanceTo(f1) + point.distanceTo(f2) <= d + 2 * tolerance;
  }

  var Symbolizer = function () {
    function Symbolizer() {
      this.bbox = getDefaultBBOX();
    }
    var _proto = Symbolizer.prototype;
    _proto._setBBOX = function _setBBOX(ctx, x1, y1, x2, y2) {
      if (!ctx.isHitTesting) {
        setBBOX(this.bbox, x1, y1, x2, y2);
      }
      return this;
    };
    _proto._bufferBBOX = function _bufferBBOX(ctx, bufferSize) {
      if (bufferSize === void 0) {
        bufferSize = 0;
      }
      if (!ctx.isHitTesting) {
        bufferBBOX(this.bbox, bufferSize);
      }
      return this;
    };
    _proto.getMap = function getMap() {
      return this.geometry.getMap();
    };
    _proto.getPainter = function getPainter() {
      return this.painter;
    };
    _proto.isDynamicSize = function isDynamicSize() {
      return false;
    };
    Symbolizer.testColor = function testColor(prop) {
      if (!prop || !isString(prop)) {
        return false;
      }
      if (COLOR_PROPERTIES.indexOf(prop) >= 0) {
        return true;
      }
      return false;
    };
    return Symbolizer;
  }();

  var CanvasSymbolizer = function (_Symbolizer) {
    _inheritsLoose(CanvasSymbolizer, _Symbolizer);
    function CanvasSymbolizer() {
      return _Symbolizer.apply(this, arguments) || this;
    }
    var _proto = CanvasSymbolizer.prototype;
    _proto._prepareContext = function _prepareContext(ctx) {
      if (isFunctionDefinition(this.symbol['opacity'])) {
        if (!this._opacityFn) {
          this._opacityFn = interpolated(this.symbol['opacity']);
        }
      } else {
        delete this._opacityFn;
      }
      if (isNumber(this.symbol['opacity'])) {
        if (ctx.globalAlpha !== this.symbol['opacity']) {
          ctx.globalAlpha = this.symbol['opacity'];
        }
      } else if (this._opacityFn) {
        var map = this.getMap();
        ctx.globalAlpha = this._opacityFn(map.getZoom());
      } else if (ctx.globalAlpha !== 1) {
        ctx.globalAlpha = 1;
      }
    };
    _proto.prepareCanvas = function prepareCanvas(ctx, style, resources) {
      if (ctx.setLineDash && isArrayHasData(style['lineDasharray'])) {
        ctx.setLineDash(style['lineDasharray']);
      }
      var isHitTesting = this.getPainter().isHitTesting();
      Canvas.prepareCanvas(ctx, style, resources, isHitTesting);
    };
    _proto.remove = function remove() {};
    _proto.setZIndex = function setZIndex() {};
    _proto.show = function show() {};
    _proto.hide = function hide() {};
    _proto._defineStyle = function _defineStyle(style) {
      return loadGeoSymbol(style, this.geometry);
    };
    return CanvasSymbolizer;
  }(Symbolizer);

  function getImage(resources, url) {
    var img = resources && resources.getImage(url);
    return img || null;
  }
  function drawVectorMarker(ctx, point, symbol, resources) {
    var strokeAndFill = translateMarkerLineAndFill(symbol);
    var style = symbol,
      markerType = style['markerType'].toLowerCase(),
      vectorArray = getVectorMarkerPoints(markerType, style['markerWidth'], style['markerHeight']),
      lineOpacity = strokeAndFill['lineOpacity'],
      fillOpacity = strokeAndFill['polygonOpacity'];
    var gradient = isGradient(strokeAndFill['polygonFill']);
    if (gradient) {
      var gradientExtent;
      if (isGradient(strokeAndFill['polygonFill'])) {
        if (!gradientExtent) {
          gradientExtent = getGraidentExtent(point, style.markerWidth, style.markerHeight);
        }
        strokeAndFill['polygonGradientExtent'] = gradientExtent;
      }
    }
    Canvas.prepareCanvas(ctx, strokeAndFill, resources);
    var width = style['markerWidth'],
      height = style['markerHeight'],
      hLineWidth = style['markerLineWidth'] / 2;
    if (markerType === 'ellipse') {
      Canvas.ellipse(ctx, point, width / 2, height / 2, height / 2, lineOpacity, fillOpacity);
    } else if (markerType === 'cross' || markerType === 'x') {
      for (var j = vectorArray.length - 1; j >= 0; j--) {
        vectorArray[j]._add(point);
      }
      Canvas.path(ctx, vectorArray.slice(0, 2), lineOpacity);
      Canvas.path(ctx, vectorArray.slice(2, 4), lineOpacity);
    } else if (markerType === 'diamond' || markerType === 'bar' || markerType === 'square' || markerType === 'rectangle' || markerType === 'triangle') {
      if (markerType === 'bar') {
        point = point.add(0, -hLineWidth);
      } else if (markerType === 'rectangle') {
        point = point.add(hLineWidth, hLineWidth);
      }
      for (var _j = vectorArray.length - 1; _j >= 0; _j--) {
        vectorArray[_j]._add(point);
      }
      Canvas.polygon(ctx, vectorArray, lineOpacity, fillOpacity);
    } else if (markerType === 'pin') {
      point = point.add(0, -hLineWidth);
      for (var _j2 = vectorArray.length - 1; _j2 >= 0; _j2--) {
        vectorArray[_j2]._add(point);
      }
      var lineCap = ctx.lineCap;
      ctx.lineCap = 'round';
      Canvas.bezierCurveAndFill(ctx, vectorArray, lineOpacity, fillOpacity);
      ctx.lineCap = lineCap;
    } else if (markerType === 'pie') {
      point = point.add(0, -hLineWidth);
      var angle = Math.atan(width / 2 / height) * 180 / Math.PI;
      var _lineCap = ctx.lineCap;
      ctx.lineCap = 'round';
      Canvas.sector(ctx, point, height, [90 - angle, 90 + angle], lineOpacity, fillOpacity);
      ctx.lineCap = _lineCap;
    } else {
      throw new Error('unsupported markerType: ' + markerType);
    }
    return ctx.canvas;
  }
  function getGraidentExtent(point, w, h) {
    var e = new PointExtent();
    e._combine(point);
    e['xmin'] += -w / 2;
    e['ymin'] += -h / 2;
    e['xmax'] += w / 2;
    e['ymax'] += h / 2;
    return e;
  }
  function translateMarkerLineAndFill(s) {
    var result = {
      'lineColor': s['markerLineColor'],
      'linePatternFile': s['markerLinePatternFile'],
      'lineWidth': s['markerLineWidth'],
      'lineOpacity': s['markerLineOpacity'],
      'lineDasharray': s['markerLineDasharray'],
      'lineCap': 'butt',
      'lineJoin': 'round',
      'polygonFill': s['markerFill'],
      'polygonPatternFile': s['markerFillPatternFile'],
      'polygonOpacity': s['markerFillOpacity']
    };
    if (result['lineWidth'] === 0) {
      result['lineOpacity'] = 0;
    }
    return result;
  }
  function getVectorMarkerPoints(markerType, width, height) {
    var hh = height / 2,
      hw = width / 2;
    var left = 0,
      top = 0;
    var v0, v1, v2, v3;
    if (markerType === 'triangle') {
      v0 = new Point(left, top - hh);
      v1 = new Point(left - hw, top + hh);
      v2 = new Point(left + hw, top + hh);
      return [v0, v1, v2];
    } else if (markerType === 'cross') {
      v0 = new Point(left - hw, top);
      v1 = new Point(left + hw, top);
      v2 = new Point(left, top - hh);
      v3 = new Point(left, top + hh);
      return [v0, v1, v2, v3];
    } else if (markerType === 'diamond') {
      v0 = new Point(left - hw, top);
      v1 = new Point(left, top - hh);
      v2 = new Point(left + hw, top);
      v3 = new Point(left, top + hh);
      return [v0, v1, v2, v3];
    } else if (markerType === 'square') {
      v0 = new Point(left - hw, top + hh);
      v1 = new Point(left + hw, top + hh);
      v2 = new Point(left + hw, top - hh);
      v3 = new Point(left - hw, top - hh);
      return [v0, v1, v2, v3];
    } else if (markerType === 'rectangle') {
      v0 = new Point(left, top);
      v1 = v0.add(width, 0);
      v2 = v0.add(width, height);
      v3 = v0.add(0, height);
      return [v0, v1, v2, v3];
    } else if (markerType === 'x') {
      v0 = new Point(left - hw, top + hh);
      v1 = new Point(left + hw, top - hh);
      v2 = new Point(left + hw, top + hh);
      v3 = new Point(left - hw, top - hh);
      return [v0, v1, v2, v3];
    } else if (markerType === 'bar') {
      v0 = new Point(left - hw, top - height);
      v1 = new Point(left + hw, top - height);
      v2 = new Point(left + hw, top);
      v3 = new Point(left - hw, top);
      return [v0, v1, v2, v3];
    } else if (markerType === 'pin' || markerType === 'pie') {
      var extWidth = height * Math.atan(hw / hh);
      v0 = new Point(left, top);
      v1 = new Point(left - extWidth, top - height);
      v2 = new Point(left + extWidth, top - height);
      v3 = new Point(left, top);
      return [v0, v1, v2, v3];
    }
    return [];
  }

  var TEMP_POINT0$1 = new Point(0, 0);
  var TEMP_POINT1 = new Point(0, 0);
  var TEMP_POINT2 = new Point(0, 0);
  var TEMP_POINT3 = new Point(0, 0);
  var PointSymbolizer = function (_CanvasSymbolizer) {
    _inheritsLoose(PointSymbolizer, _CanvasSymbolizer);
    function PointSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _CanvasSymbolizer.call(this) || this;
      _this.symbol = symbol;
      _this.geometry = geometry;
      _this.painter = painter;
      return _this;
    }
    var _proto = PointSymbolizer.prototype;
    _proto.get2DExtent = function get2DExtent() {
      var map = this.getMap();
      var glRes = map.getGLRes();
      var extent = new PointExtent();
      var renderPoints = this._getRenderPoints()[0];
      for (var i = renderPoints.length - 1; i >= 0; i--) {
        if (renderPoints[i]) {
          extent._combine(map._pointAtResToPoint(renderPoints[i], glRes));
        }
      }
      return extent;
    };
    _proto.isDynamicSize = function isDynamicSize() {
      var symbol = this.symbol;
      return isFunctionDefinition(symbol['markerWidth']) || isFunctionDefinition(symbol['markerHeight']) || isFunctionDefinition(symbol['textSize']);
    };
    _proto._rotateExtent = function _rotateExtent(fixedExtent, angle) {
      return fixedExtent.convertTo(function (p) {
        return p._rotate(angle);
      });
    };
    _proto._getRenderPoints = function _getRenderPoints() {
      var painter = this.getPainter();
      var placement = painter.isSpriting() ? 'center' : this.getPlacement();
      return this.getPainter().getRenderPoints(placement);
    };
    _proto._getRenderContainerPoints = function _getRenderContainerPoints(ignoreAltitude) {
      var painter = this.getPainter();
      if (painter.isSpriting()) {
        return this._getRenderPoints()[0];
      }
      var geometry = this.geometry;
      var dxdy = this.getDxDy();
      var cpoints;
      if (geometry._cPoint && !ignoreAltitude) {
        var p = ignoreAltitude ? TEMP_POINT2 : TEMP_POINT3;
        p.set(geometry._cPoint.x, geometry._cPoint.y);
        var containerOffset = painter.containerOffset;
        p._sub(containerOffset);
        var dx = dxdy.x,
          dy = dxdy.y;
        if (dx || dy) {
          p._add(dx || 0, dy || 0);
        }
        cpoints = [p];
      } else {
        var points = this._getRenderPoints()[0];
        cpoints = this.painter._pointContainerPoints(points, dxdy.x, dxdy.y, ignoreAltitude, true, this.getPlacement());
      }
      if (!cpoints || !Array.isArray(cpoints[0])) {
        return cpoints;
      }
      var flat = [];
      for (var i = 0, l = cpoints.length; i < l; i++) {
        for (var ii = 0, ll = cpoints[i].length; ii < ll; ii++) {
          flat.push(cpoints[i][ii]);
        }
      }
      return flat;
    };
    _proto.getPlacement = function getPlacement() {
      return this.symbol['markerPlacement'];
    };
    _proto.getRotation = function getRotation() {
      return getMarkerRotation(this.style);
    };
    _proto.getDxDy = function getDxDy() {
      var s = this.style;
      var dx = s['markerDx'],
        dy = s['markerDy'];
      return new Point(dx, dy);
    };
    _proto._getRotationAt = function _getRotationAt(i) {
      var r = this.getRotation();
      if (!r) {
        r = 0;
      }
      var rotations = this._getRenderPoints()[1];
      if (!rotations || !rotations[i]) {
        return r;
      }
      var map = this.getMap();
      var p0 = rotations[i][0],
        p1 = rotations[i][1];
      if (map.isTransforming()) {
        var glRes = map.getGLRes();
        p0 = map._pointAtResToContainerPoint(rotations[i][0], glRes, 0, TEMP_POINT0$1);
        p1 = map._pointAtResToContainerPoint(rotations[i][1], glRes, 0, TEMP_POINT1);
        return r + computeDegree(p0.x, p0.y, p1.x, p1.y);
      } else {
        return r + -computeDegree(p0.x, p0.y, p1.x, p1.y);
      }
    };
    _proto._rotate = function _rotate(ctx, origin, rotation) {
      if (rotation) {
        var dxdy = this.getDxDy();
        var p = origin.sub(dxdy);
        ctx.save();
        ctx.translate(p.x, p.y);
        ctx.rotate(rotation);
        return dxdy;
      }
      return null;
    };
    return PointSymbolizer;
  }(CanvasSymbolizer);

  var DebugSymbolizer = function (_PointSymbolizer) {
    _inheritsLoose(DebugSymbolizer, _PointSymbolizer);
    function DebugSymbolizer() {
      return _PointSymbolizer.apply(this, arguments) || this;
    }
    var _proto = DebugSymbolizer.prototype;
    _proto.getPlacement = function getPlacement() {
      return 'point';
    };
    _proto.getDxDy = function getDxDy() {
      return new Point(0, 0);
    };
    _proto.symbolize = function symbolize(ctx) {
      var geometry = this.geometry,
        layer = geometry.getLayer();
      if (!geometry.options['debug'] && layer && !layer.options['debug']) {
        return;
      }
      var map = this.getMap();
      if (!map || map.isZooming()) {
        return;
      }
      var color = layer.options['debugOutline'],
        op = 1;
      ctx.strokeStyle = color;
      ctx.fillStyle = color;
      ctx.lineWidth = 1;
      ctx.font = '18px  serif';
      var outline = geometry.getContainerExtent().toArray();
      Canvas.polygon(ctx, [outline], op, 0);
      var points = this._getRenderContainerPoints(),
        id = this.geometry.getId(),
        cross = getVectorMarkerPoints('cross', 10, 10);
      for (var i = 0; i < points.length; i++) {
        var p = points[i];
        if (!isNil(id)) {
          Canvas.fillText(ctx, id, p.add(8, -4), color);
        }
        var c = [];
        for (var ii = 0; ii < cross.length; ii++) {
          c.push(cross[ii].add(p));
        }
        Canvas.path(ctx, c.slice(0, 2), op);
        Canvas.path(ctx, c.slice(2, 4), op);
      }
    };
    return DebugSymbolizer;
  }(PointSymbolizer);

  var TEMP_SIZE$1 = new Size(1, 1);
  var TEMP_EXTENT$1 = new PointExtent();
  var ImageMarkerSymbolizer = function (_PointSymbolizer) {
    _inheritsLoose(ImageMarkerSymbolizer, _PointSymbolizer);
    ImageMarkerSymbolizer.test = function test(symbol) {
      return isImageSymbol(symbol);
    };
    function ImageMarkerSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
      _this.style = _this._defineStyle(_this.translate());
      return _this;
    }
    var _proto = ImageMarkerSymbolizer.prototype;
    _proto.symbolize = function symbolize(ctx, resources) {
      var style = this.style;
      if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['markerOpacity'] === 0)) {
        return;
      }
      var cookedPoints = this._getRenderContainerPoints();
      if (!isArrayHasData(cookedPoints)) {
        return;
      }
      var img = this._getImage(resources);
      if (!img) {
        if (typeof console !== 'undefined') {
          console.warn('no img found for ' + (this.style['markerFile'] || this._url[0]));
        }
        return;
      }
      this._prepareContext(ctx);
      var width = style['markerWidth'];
      var height = style['markerHeight'];
      if (!isNumber(width) || !isNumber(height)) {
        width = img.width;
        height = img.height;
        style['markerWidth'] = width;
        style['markerHeight'] = height;
        var imgURL = style['markerFile'];
        if (!resources.isResourceLoaded(imgURL)) {
          resources.addResource(imgURL, img);
        }
        var painter = this.getPainter();
        if (!painter.isSpriting()) {
          painter.removeCache();
        }
      }
      var alpha;
      if (this.symbol['markerType'] !== 'path' && isNumber(style['markerOpacity']) && style['markerOpacity'] < 1) {
        alpha = ctx.globalAlpha;
        ctx.globalAlpha *= style['markerOpacity'];
      }
      TEMP_SIZE$1.width = width;
      TEMP_SIZE$1.height = height;
      var alignPoint = getAlignPoint(TEMP_SIZE$1, style['markerHorizontalAlignment'], style['markerVerticalAlignment']);
      for (var i = 0, len = cookedPoints.length; i < len; i++) {
        var p = cookedPoints[i];
        var origin = this.getRotation() ? this._rotate(ctx, p, this._getRotationAt(i)) : null;
        var extent = void 0;
        if (origin) {
          var pixel = p.sub(origin);
          p = origin;
          var rad = this._getRotationAt(i);
          extent = getMarkerRotationExtent(TEMP_EXTENT$1, rad, width, height, p, alignPoint);
          extent._add(pixel);
        }
        var x = p.x + alignPoint.x,
          y = p.y + alignPoint.y;
        Canvas.image(ctx, img, x, y, width, height);
        if (origin) {
          ctx.restore();
        }
        if (origin) {
          this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
        } else {
          this._setBBOX(ctx, x, y, x + width, y + height);
        }
      }
      if (alpha !== undefined) {
        ctx.globalAlpha = alpha;
      }
    };
    _proto._getImage = function _getImage(resources) {
      return getImage(resources, this.style['markerFile']);
    };
    _proto.getFixedExtent = function getFixedExtent(resources) {
      this._fixedExtent = this._fixedExtent || new PointExtent();
      return getImageMarkerFixedExtent(this._fixedExtent, this.style, resources);
    };
    _proto.translate = function translate() {
      var s = this.symbol;
      return {
        'markerFile': s['markerFile'],
        'markerOpacity': getValueOrDefault(s['markerOpacity'], 1),
        'markerWidth': getValueOrDefault(s['markerWidth'], null),
        'markerHeight': getValueOrDefault(s['markerHeight'], null),
        'markerRotation': getValueOrDefault(s['markerRotation'], 0),
        'markerDx': getValueOrDefault(s['markerDx'], 0),
        'markerDy': getValueOrDefault(s['markerDy'], 0),
        'markerHorizontalAlignment': getValueOrDefault(s['markerHorizontalAlignment'], 'middle'),
        'markerVerticalAlignment': getValueOrDefault(s['markerVerticalAlignment'], 'top')
      };
    };
    return ImageMarkerSymbolizer;
  }(PointSymbolizer);

  var TEMP_COORD0$1 = new Coordinate(0, 0);
  var TEMP_COORD1$1 = new Coordinate(0, 0);
  var StrokeAndFillSymbolizer = function (_CanvasSymbolizer) {
    _inheritsLoose(StrokeAndFillSymbolizer, _CanvasSymbolizer);
    StrokeAndFillSymbolizer.test = function test(symbol, geometry) {
      if (!symbol) {
        return false;
      }
      if (geometry && geometry.isPoint) {
        return false;
      }
      for (var p in symbol) {
        var f = p.slice(0, 4);
        if (f === 'line' || f === 'poly') {
          return true;
        }
      }
      return false;
    };
    function StrokeAndFillSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _CanvasSymbolizer.call(this) || this;
      _this.symbol = symbol;
      _this.geometry = geometry;
      _this.painter = painter;
      if (geometry.isPoint) {
        return _assertThisInitialized(_this);
      }
      _this.style = _this._defineStyle(_this.translate());
      return _this;
    }
    var _proto = StrokeAndFillSymbolizer.prototype;
    _proto.symbolize = function symbolize(ctx, resources) {
      var style = this.style;
      if (style['polygonOpacity'] === 0 && style['lineOpacity'] === 0 && !this.painter.isHitTesting()) {
        return;
      }
      var paintParams = this._getPaintParams();
      if (!paintParams) {
        return;
      }
      this._prepareContext(ctx);
      var isGradient$$1 = isGradient(style['lineColor']),
        isPath = this.geometry.getJSONType() === 'Polygon' || this.geometry.type === 'LineString';
      if (isGradient$$1 && (style['lineColor']['places'] || !isPath)) {
        style['lineGradientExtent'] = this.geometry.getContainerExtent()._expand(style['lineWidth']);
      }
      if (isGradient(style['polygonFill'])) {
        style['polygonGradientExtent'] = this.geometry.getContainerExtent();
      }
      var geometryEventTolerance = this.geometry.getLayer().options['geometryEventTolerance'] || 0;
      var tolerance = this.geometry._hitTestTolerance() + geometryEventTolerance;
      var points = paintParams[0],
        isSplitted = this.geometry.getJSONType() === 'Polygon' && points.length > 0 && Array.isArray(points[0][0]) || this.geometry.type === 'LineString' && points.length > 0 && Array.isArray(points[0]);
      if (isSplitted) {
        for (var i = 0; i < points.length; i++) {
          this.prepareCanvas(ctx, style, resources);
          if (isGradient$$1 && isPath && !style['lineColor']['places']) {
            this._createGradient(ctx, points[i], style['lineColor']);
          }
          var params = [ctx, points[i]];
          if (paintParams.length > 1) {
            params.push.apply(params, paintParams.slice(1));
          }
          params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
          var bbox = this.geometry._paintOn.apply(this.geometry, params);
          this._setBBOX(ctx, bbox);
          this._bufferBBOX(ctx, tolerance);
        }
      } else {
        this.prepareCanvas(ctx, style, resources);
        if (isGradient$$1 && isPath && !style['lineColor']['places']) {
          this._createGradient(ctx, points, style['lineColor']);
        }
        var _params = [ctx];
        _params.push.apply(_params, paintParams);
        _params.push(style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
        var _bbox = this.geometry._paintOn.apply(this.geometry, _params);
        this._setBBOX(ctx, _bbox);
        this._bufferBBOX(ctx, tolerance);
      }
      if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
        ctx.setLineDash([]);
      }
    };
    _proto.get2DExtent = function get2DExtent() {
      var map = this.getMap();
      var extent = this.geometry._getPrjExtent();
      if (!extent) {
        return null;
      }
      if (!this._extMin || !this._extMax) {
        this._extMin = new Coordinate(0, 0);
        this._extMax = new Coordinate(0, 0);
      }
      this._extMin.x = extent['xmin'];
      this._extMin.y = extent['ymin'];
      this._extMax.x = extent['xmax'];
      this._extMax.y = extent['ymax'];
      var min = map._prjToPoint(this._extMin, undefined, TEMP_COORD0$1),
        max = map._prjToPoint(this._extMax, undefined, TEMP_COORD1$1);
      if (!this._pxExtent) {
        this._pxExtent = new PointExtent(min, max);
      } else {
        this._pxExtent.set(Math.min(min.x, max.x), Math.min(min.y, max.y), Math.max(min.x, max.x), Math.max(min.y, max.y));
      }
      return this._pxExtent;
    };
    _proto.getFixedExtent = function getFixedExtent() {
      var t = this.style['lineWidth'] / 2;
      return new PointExtent(-t, -t, t, t);
    };
    _proto._getPaintParams = function _getPaintParams() {
      return this.getPainter().getPaintParams(this.style['lineDx'], this.style['lineDy']);
    };
    _proto.translate = function translate() {
      var s = this.symbol;
      var result = {
        'lineColor': getValueOrDefault(s['lineColor'], '#000'),
        'lineWidth': getValueOrDefault(s['lineWidth'], 2),
        'lineOpacity': getValueOrDefault(s['lineOpacity'], 1),
        'lineDasharray': getValueOrDefault(s['lineDasharray'], []),
        'lineCap': getValueOrDefault(s['lineCap'], 'butt'),
        'lineJoin': getValueOrDefault(s['lineJoin'], 'miter'),
        'linePatternFile': getValueOrDefault(s['linePatternFile'], null),
        'lineDx': getValueOrDefault(s['lineDx'], 0),
        'lineDy': getValueOrDefault(s['lineDy'], 0),
        'polygonFill': getValueOrDefault(s['polygonFill'], null),
        'polygonOpacity': getValueOrDefault(s['polygonOpacity'], 1),
        'polygonPatternFile': getValueOrDefault(s['polygonPatternFile'], null),
        'polygonPatternDx': getValueOrDefault(s['polygonPatternDx'], 0),
        'polygonPatternDy': getValueOrDefault(s['polygonPatternDy'], 0),
        'linePatternDx': getValueOrDefault(s['linePatternDx'], 0),
        'linePatternDy': getValueOrDefault(s['linePatternDy'], 0)
      };
      if (result['lineWidth'] === 0) {
        result['lineOpacity'] = 0;
      }
      if (this.geometry.type === 'LineString' && !result['polygonFill']) {
        result['polygonFill'] = result['lineColor'];
      }
      return result;
    };
    _proto._createGradient = function _createGradient(ctx, points, lineColor) {
      if (!Array.isArray(points) || !points.length) {
        return;
      }
      var _getGradientPoints = getGradientPoints(points),
        p1 = _getGradientPoints[0],
        p2 = _getGradientPoints[1];
      if (!p1 || !p2) {
        console.error('unable create canvas LinearGradient,error data:', points);
        return;
      }
      var grad = ctx.createLinearGradient(p1.x, p1.y, p2.x, p2.y);
      lineColor['colorStops'].forEach(function (stop) {
        grad.addColorStop.apply(grad, stop);
      });
      ctx.strokeStyle = grad;
    };
    return StrokeAndFillSymbolizer;
  }(CanvasSymbolizer);
  function getGradientPoints(points) {
    var pts;
    var isLine = true;
    if (Array.isArray(points[0])) {
      pts = points[0];
      isLine = false;
    } else {
      pts = points;
    }
    var len = pts.length;
    if (isLine) {
      return [pts[0], pts[len - 1]];
    }
    var p1 = pts[0];
    var distance = 0,
      p2;
    for (var i = 1; i < len; i++) {
      var p = pts[i];
      var dis = p1.distanceTo(p);
      if (dis > distance) {
        distance = dis;
        p2 = p;
      }
    }
    return [p1, p2];
  }

  var TEMP_EXTENT$2 = new PointExtent();
  var TextMarkerSymbolizer = function (_PointSymbolizer) {
    _inheritsLoose(TextMarkerSymbolizer, _PointSymbolizer);
    TextMarkerSymbolizer.test = function test(symbol) {
      return isTextSymbol(symbol);
    };
    function TextMarkerSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
      var style = _this.translate();
      _this._dynamic = hasFunctionDefinition(style);
      _this.style = _this._defineStyle(style);
      if (_this.style['textWrapWidth'] === 0) {
        return _assertThisInitialized(_this);
      }
      _this.strokeAndFill = _this._defineStyle(_this.translateLineAndFill(_this.style));
      return _this;
    }
    var _proto = TextMarkerSymbolizer.prototype;
    _proto.symbolize = function symbolize(ctx, resources) {
      if (!this.painter.isHitTesting() && (this.style['textSize'] === 0 || !this.style['textOpacity'] && (!this.style['textHaloRadius'] || !this.style['textHaloOpacity']) || this.style['textWrapWidth'] === 0)) {
        return;
      }
      var cookedPoints = this._getRenderContainerPoints();
      if (!isArrayHasData(cookedPoints)) {
        return;
      }
      var style = this.style,
        strokeAndFill = this.strokeAndFill;
      var textContent = replaceVariable(this.style['textName'], this.geometry.getProperties());
      if (this._dynamic) {
        delete this._textDesc;
      }
      var textDesc = this._textDesc = this._textDesc || describeText(textContent, this.style);
      this._prepareContext(ctx);
      this.prepareCanvas(ctx, strokeAndFill, resources);
      Canvas.prepareCanvasFont(ctx, style);
      var textHaloRadius = style.textHaloRadius || 0;
      for (var i = 0, len = cookedPoints.length; i < len; i++) {
        var p = cookedPoints[i];
        var origin = this.getRotation() ? this._rotate(ctx, p, this._getRotationAt(i)) : null;
        var extent = void 0;
        if (origin) {
          var pixel = p.sub(origin);
          p = origin;
          var rad = this._getRotationAt(i);
          var _ref = textDesc.size || {
              width: 0,
              height: 0
            },
            width = _ref.width,
            height = _ref.height;
          var alignPoint = getAlignPoint(textDesc.size, style['textHorizontalAlignment'], style['textVerticalAlignment']);
          extent = getMarkerRotationExtent(TEMP_EXTENT$2, rad, width, height, p, alignPoint);
          extent._add(pixel);
        }
        var bbox = Canvas.text(ctx, textContent, p, style, textDesc);
        if (origin) {
          this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
          ctx.restore();
        } else {
          this._setBBOX(ctx, bbox);
        }
        this._bufferBBOX(ctx, textHaloRadius);
      }
    };
    _proto.getPlacement = function getPlacement() {
      return this.symbol['textPlacement'];
    };
    _proto.getRotation = function getRotation() {
      var r = this.style['textRotation'];
      if (!isNumber(r)) {
        return null;
      }
      return -r * Math.PI / 180;
    };
    _proto.getDxDy = function getDxDy() {
      var s = this.style;
      return new Point(s['textDx'], s['textDy']);
    };
    _proto.getFixedExtent = function getFixedExtent() {
      var textDesc = this.geometry.getTextDesc();
      if (Array.isArray(textDesc)) {
        textDesc = textDesc[this._index];
      }
      this._fixedExtent = this._fixedExtent || new PointExtent();
      if (!textDesc) {
        return this._fixedExtent;
      }
      return getTextMarkerFixedExtent(this._fixedExtent, this.style, textDesc);
    };
    _proto.translate = function translate() {
      var s = this.symbol;
      var result = {
        'textName': s['textName'],
        'textFaceName': getValueOrDefault(s['textFaceName'], 'monospace'),
        'textWeight': getValueOrDefault(s['textWeight'], 'normal'),
        'textStyle': getValueOrDefault(s['textStyle'], 'normal'),
        'textSize': getValueOrDefault(s['textSize'], DEFAULT_TEXT_SIZE),
        'textFont': getValueOrDefault(s['textFont'], null),
        'textFill': getValueOrDefault(s['textFill'], '#000'),
        'textOpacity': getValueOrDefault(s['textOpacity'], 1),
        'textHaloFill': getValueOrDefault(s['textHaloFill'], '#ffffff'),
        'textHaloRadius': getValueOrDefault(s['textHaloRadius'], 0),
        'textHaloOpacity': getValueOrDefault(s['textHaloOpacity'], 1),
        'textWrapWidth': getValueOrDefault(s['textWrapWidth'], null),
        'textWrapCharacter': getValueOrDefault(s['textWrapCharacter'], '\n'),
        'textLineSpacing': getValueOrDefault(s['textLineSpacing'], 0),
        'textDx': getValueOrDefault(s['textDx'], 0),
        'textDy': getValueOrDefault(s['textDy'], 0),
        'textHorizontalAlignment': getValueOrDefault(s['textHorizontalAlignment'], 'middle'),
        'textVerticalAlignment': getValueOrDefault(s['textVerticalAlignment'], 'middle'),
        'textAlign': getValueOrDefault(s['textAlign'], 'center'),
        'textRotation': getValueOrDefault(s['textRotation'], 0),
        'textMaxWidth': getValueOrDefault(s['textMaxWidth'], 0),
        'textMaxHeight': getValueOrDefault(s['textMaxHeight'], 0)
      };
      if (result['textMaxWidth'] > 0 && (!result['textWrapWidth'] || result['textWrapWidth'] > result['textMaxWidth'])) {
        if (!result['textWrapWidth']) {
          result['textMaxHeight'] = 1;
        }
        result['textWrapWidth'] = result['textMaxWidth'];
      }
      return result;
    };
    _proto.translateLineAndFill = function translateLineAndFill(s) {
      return {
        'lineColor': s['textHaloRadius'] ? s['textHaloFill'] : s['textFill'],
        'lineWidth': s['textHaloRadius'],
        'lineOpacity': s['textOpacity'],
        'lineDasharray': null,
        'lineCap': 'butt',
        'lineJoin': 'round',
        'polygonFill': s['textFill'],
        'polygonOpacity': s['textOpacity']
      };
    };
    return TextMarkerSymbolizer;
  }(PointSymbolizer);

  var MARKER_SIZE = [];
  var TEMP_EXTENT$3 = new PointExtent();
  var DEFAULT_ANCHOR = new Point(0, 0);
  var VectorMarkerSymbolizer = function (_PointSymbolizer) {
    _inheritsLoose(VectorMarkerSymbolizer, _PointSymbolizer);
    VectorMarkerSymbolizer.test = function test(symbol) {
      return isVectorSymbol(symbol);
    };
    function VectorMarkerSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
      var style = _this.translate();
      _this._dynamic = hasFunctionDefinition(style);
      _this.style = _this._defineStyle(style);
      _this.strokeAndFill = _this._defineStyle(translateMarkerLineAndFill(_this.style));
      _this.padding = 0;
      return _this;
    }
    var _proto = VectorMarkerSymbolizer.prototype;
    _proto.symbolize = function symbolize(ctx, resources) {
      var style = this.style;
      if (!this.painter.isHitTesting() && (style['markerWidth'] === 0 || style['markerHeight'] === 0 || style['polygonOpacity'] === 0 && style['lineOpacity'] === 0)) {
        return;
      }
      var cookedPoints = this._getRenderContainerPoints();
      if (!isArrayHasData(cookedPoints)) {
        return;
      }
      this._prepareContext(ctx);
      if (this.getPainter().isSpriting() || this.geometry.getLayer().getMask() === this.geometry || this._dynamic || this.geometry.getLayer().options['cacheVectorOnCanvas'] === false) {
        this._drawMarkers(ctx, cookedPoints, resources);
      } else {
        this._drawMarkersWithCache(ctx, cookedPoints, resources);
      }
    };
    _proto._drawMarkers = function _drawMarkers(ctx, cookedPoints, resources) {
      for (var i = cookedPoints.length - 1; i >= 0; i--) {
        var point = cookedPoints[i];
        var size = calVectorMarkerSize(MARKER_SIZE, this.style);
        var width = size[0],
          height = size[1];
        var extent = void 0;
        var origin = this.getRotation() ? this._rotate(ctx, point, this._getRotationAt(i)) : null;
        if (origin) {
          var pixel = point.sub(origin);
          point = origin;
          var rad = this._getRotationAt(i);
          extent = getMarkerRotationExtent(TEMP_EXTENT$3, rad, width, height, point, DEFAULT_ANCHOR);
          extent._add(pixel);
        }
        this._drawVectorMarker(ctx, point, resources);
        if (origin) {
          ctx.restore();
          this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
        } else {
          var _point = point,
            x = _point.x,
            y = _point.y;
          this._setBBOX(ctx, x, y, x + width, y + height);
        }
      }
    };
    _proto._drawMarkersWithCache = function _drawMarkersWithCache(ctx, cookedPoints, resources) {
      var stamp = this._stampSymbol();
      var image = resources.getImage(stamp);
      if (!image) {
        image = this._createMarkerImage(ctx, resources);
        resources.addResource([stamp, image.width, image.height], image);
      }
      var anchor = getVectorMarkerAnchor(this.style, image.width, image.height);
      for (var i = cookedPoints.length - 1; i >= 0; i--) {
        var point = cookedPoints[i];
        var origin = this.getRotation() ? this._rotate(ctx, point, this._getRotationAt(i)) : null;
        var extent = void 0;
        if (origin) {
          var pixel = point.sub(origin);
          point = origin;
          var rad = this._getRotationAt(i);
          extent = getMarkerRotationExtent(TEMP_EXTENT$3, rad, image.width, image.height, point, anchor);
          extent._add(pixel);
        }
        var x = point.x + anchor.x,
          y = point.y + anchor.y;
        Canvas.image(ctx, image, x, y);
        if (origin) {
          ctx.restore();
          this._setBBOX(ctx, extent.xmin, extent.ymin, extent.xmax, extent.ymax);
        } else {
          this._setBBOX(ctx, x, y, x + image.width, y + image.height);
        }
      }
    };
    _proto._createMarkerImage = function _createMarkerImage(ctx, resources) {
      var canvasClass = ctx.canvas.constructor,
        size = calVectorMarkerSize(MARKER_SIZE, this.style),
        canvas = Canvas.createCanvas(size[0], size[1], canvasClass),
        point = this._getCacheImageAnchor(size[0], size[1]);
      var context = canvas.getContext('2d');
      this._drawVectorMarker(context, point, resources);
      return canvas;
    };
    _proto._stampSymbol = function _stampSymbol() {
      if (!this._stamp) {
        this._stamp = hashCode([this.style['markerType'], isGradient(this.style['markerFill']) ? getGradientStamp(this.style['markerFill']) : this.style['markerFill'], this.style['markerFillOpacity'], this.style['markerFillPatternFile'], isGradient(this.style['markerLineColor']) ? getGradientStamp(this.style['markerLineColor']) : this.style['markerLineColor'], this.style['markerLineWidth'], this.style['markerLineOpacity'], this.style['markerLineDasharray'] ? this.style['markerLineDasharray'].join(',') : '', this.style['markerLinePatternFile'], this.style['markerWidth'], this.style['markerHeight'], this.style['markerHorizontalAlignment'], this.style['markerVerticalAlignment']].join('_'));
      }
      return this._stamp;
    };
    _proto._getCacheImageAnchor = function _getCacheImageAnchor(w, h) {
      var shadow = 2 * (this.symbol['shadowBlur'] || 0),
        margin = shadow + this.padding;
      var markerType = this.style['markerType'];
      if (markerType === 'bar' || markerType === 'pie' || markerType === 'pin') {
        return new Point(w / 2, h - margin);
      } else if (markerType === 'rectangle') {
        return new Point(margin, margin);
      } else {
        return new Point(w / 2, h / 2);
      }
    };
    _proto._getGraidentExtent = function _getGraidentExtent(points) {
      var e = new PointExtent(),
        dxdy = this.getDxDy(),
        m = this.getFixedExtent();
      if (Array.isArray(points)) {
        for (var i = points.length - 1; i >= 0; i--) {
          e._combine(points[i]);
        }
      } else {
        e._combine(points);
      }
      e['xmin'] += m['xmin'] - dxdy.x;
      e['ymin'] += m['ymin'] - dxdy.y;
      e['xmax'] += m['xmax'] - dxdy.x;
      e['ymax'] += m['ymax'] - dxdy.y;
      return e;
    };
    _proto._drawVectorMarker = function _drawVectorMarker(ctx, point, resources) {
      drawVectorMarker(ctx, point, this.style, resources);
    };
    _proto.getFixedExtent = function getFixedExtent() {
      var isDynamic = this.isDynamicSize();
      var w = this.style.markerWidth;
      var h = this.style.markerHeight;
      this._fixedExtent = this._fixedExtent || new PointExtent();
      return getVectorMarkerFixedExtent(this._fixedExtent, this.style, isDynamic ? [128, 128 * (w === 0 ? 1 : h / w)] : null);
    };
    _proto.translate = function translate() {
      var s = this.symbol;
      var result = {
        'markerType': getValueOrDefault(s['markerType'], 'ellipse'),
        'markerFill': getValueOrDefault(s['markerFill'], '#00f'),
        'markerFillOpacity': getValueOrDefault(s['markerFillOpacity'], 1),
        'markerFillPatternFile': getValueOrDefault(s['markerFillPatternFile'], null),
        'markerLineColor': getValueOrDefault(s['markerLineColor'], '#000'),
        'markerLineWidth': getValueOrDefault(s['markerLineWidth'], DEFAULT_MARKER_SYMBOLS.markerLineWidth),
        'markerLineOpacity': getValueOrDefault(s['markerLineOpacity'], 1),
        'markerLineDasharray': getValueOrDefault(s['markerLineDasharray'], []),
        'markerLinePatternFile': getValueOrDefault(s['markerLinePatternFile'], null),
        'markerDx': getValueOrDefault(s['markerDx'], 0),
        'markerDy': getValueOrDefault(s['markerDy'], 0),
        'markerWidth': getValueOrDefault(s['markerWidth'], DEFAULT_MARKER_SYMBOLS.markerWidth),
        'markerHeight': getValueOrDefault(s['markerHeight'], DEFAULT_MARKER_SYMBOLS.markerHeight),
        'markerRotation': getValueOrDefault(s['markerRotation'], 0),
        'shadowBlur': getValueOrDefault(s['shadowBlur'], 0),
        'shadowOffsetX': getValueOrDefault(s['shadowOffsetX'], 0),
        'shadowOffsetY': getValueOrDefault(s['shadowOffsetY'], 0)
      };
      var markerType = result['markerType'];
      var ha = getDefaultHAlign(markerType);
      var va = getDefaultVAlign(markerType);
      result['markerHorizontalAlignment'] = getValueOrDefault(s['markerHorizontalAlignment'], ha);
      result['markerVerticalAlignment'] = getValueOrDefault(s['markerVerticalAlignment'], va);
      if (isNumber(s['markerOpacity'])) {
        if (isNumber(s['markerFillOpacity'])) {
          result['markerFillOpacity'] *= s['markerOpacity'];
        }
        if (isNumber(s['markerLineOpacity'])) {
          result['markerLineOpacity'] *= s['markerOpacity'];
        }
      }
      return result;
    };
    return VectorMarkerSymbolizer;
  }(PointSymbolizer);

  var VectorPathMarkerSymbolizer = function (_ImageMarkerSymbolize) {
    _inheritsLoose(VectorPathMarkerSymbolizer, _ImageMarkerSymbolize);
    VectorPathMarkerSymbolizer.test = function test(symbol) {
      return isPathSymbol(symbol);
    };
    function VectorPathMarkerSymbolizer(symbol, geometry, painter) {
      var _this;
      if (isNil(symbol['markerWidth'])) {
        symbol['markerWidth'] = 80;
      }
      if (isNil(symbol['markerHeight'])) {
        symbol['markerHeight'] = 80;
      }
      _this = _ImageMarkerSymbolize.call(this, symbol, geometry, painter) || this;
      symbol = extend(symbol, _this.translate());
      var style = _this.style = _this._defineStyle(symbol);
      if (Browser$1.gecko) {
        _this._url = [getMarkerPathBase64(style, style['markerWidth'], style['markerHeight']), style['markerWidth'], style['markerHeight']];
      } else {
        _this._url = [getMarkerPathBase64(style), style['markerWidth'], style['markerHeight']];
      }
      return _this;
    }
    var _proto = VectorPathMarkerSymbolizer.prototype;
    _proto._prepareContext = function _prepareContext() {};
    _proto._getImage = function _getImage(resources) {
      var _this2 = this;
      if (resources && resources.isResourceLoaded(this._url)) {
        return resources.getImage(this._url);
      }
      var painter = this.painter;
      var image = new Image();
      image.onload = function () {
        var renderer = painter.getLayer() && painter.getLayer().getRenderer();
        if (renderer) {
          renderer.setToRedraw();
        }
      };
      image.onerror = function (err) {
        if (err && typeof console !== 'undefined') {
          console.warn(err);
        }
        resources.markErrorResource(_this2._url);
      };
      image.src = this._url[0];
      if (resources) {
        resources.addResource(this._url, image);
      }
      return image;
    };
    return VectorPathMarkerSymbolizer;
  }(ImageMarkerSymbolizer);

  var defaultSymbol = {
    lineWidth: 1,
    polygonFill: '#fff',
    polygonOpacity: 0.5
  };
  var DrawAltitudeSymbolizer = function (_PointSymbolizer) {
    _inheritsLoose(DrawAltitudeSymbolizer, _PointSymbolizer);
    DrawAltitudeSymbolizer.test = function test(symbol, geometry) {
      var layer = geometry.getLayer();
      if (!layer) {
        return false;
      }
      var type = geometry.getJSONType();
      return type === 'Marker' || type === 'LineString';
    };
    function DrawAltitudeSymbolizer(symbol, geometry, painter) {
      var _this;
      _this = _PointSymbolizer.call(this, symbol, geometry, painter) || this;
      _this.style = geometry.getLayer().options['drawAltitude'];
      if (!_this.style || !isObject(_this.style)) {
        _this.style = {
          'lineWidth': 2
        };
      }
      if (!_this.style['lineWidth']) {
        _this.style['lineWidth'] = 0;
      }
      _this.dxdy = _this._defineStyle({
        'dx': symbol['textDx'] || symbol['markerDx'],
        'dy': symbol['textDy'] || symbol['markerDy']
      });
      return _this;
    }
    var _proto = DrawAltitudeSymbolizer.prototype;
    _proto.symbolize = function symbolize(ctx) {
      var layer = this.geometry.getLayer();
      if (!layer.options['drawAltitude']) {
        return;
      }
      if (!this.geometry.hasAltitude()) {
        return;
      }
      var style = this._getStyle();
      this._prepareContext(ctx);
      if (this.geometry.type === 'LineString') {
        var paintParams = this._getPaintParams(style['lineDx'], style['lineDy'], false, true);
        if (!paintParams) {
          return;
        }
        var groundPoints = this.getPainter().getPaintParams(style['lineDx'], style['lineDy'], true, true, '_groundpt')[0];
        this._drawLineAltitude(ctx, paintParams[0], groundPoints);
      } else {
        var point = this._getRenderContainerPoints(),
          groundPoint = this._getRenderContainerPoints(true);
        if (!point || point.length === 0) {
          return;
        }
        this._drawMarkerAltitude(ctx, point[0], groundPoint[0]);
      }
    };
    _proto.getDxDy = function getDxDy() {
      var s = this.dxdy;
      return new Point(s['dx'] || 0, s['dy'] || 0);
    };
    _proto.get2DExtent = function get2DExtent() {
      if (this.geometry.type === 'LineString') {
        return StrokeAndFillSymbolizer.prototype.get2DExtent.apply(this);
      } else {
        return _PointSymbolizer.prototype.get2DExtent.call(this);
      }
    };
    _proto.getPlacement = function getPlacement() {
      return 'point';
    };
    _proto._getPaintParams = function _getPaintParams(dx, dy) {
      return this.getPainter().getPaintParams(dx || 0, dy || 0, null, true, '_altpt');
    };
    _proto._drawMarkerAltitude = function _drawMarkerAltitude(ctx, point, groundPoint) {
      var style = this._getStyle();
      this.prepareCanvas(ctx, style);
      Canvas.path(ctx, [point, groundPoint], style['lineOpacity'], null, style['lineDasharray']);
    };
    _proto._drawLineAltitude = function _drawLineAltitude(ctx, points, groundPoints) {
      var style = this._getStyle();
      var isSplitted = points.length > 0 && Array.isArray(points[0]);
      if (isSplitted) {
        for (var i = 0; i < points.length; i++) {
          this._drawLine(ctx, points[i], groundPoints[i]);
        }
      } else {
        this._drawLine(ctx, points, groundPoints);
      }
      if (ctx.setLineDash && Array.isArray(style['lineDasharray'])) {
        ctx.setLineDash([]);
      }
    };
    _proto._drawLine = function _drawLine(ctx, points, groundPoints) {
      var style = this._getStyle();
      this.prepareCanvas(ctx, style);
      for (var i = 0, l = points.length - 1; i < l; i++) {
        Canvas.polygon(ctx, [points[i], points[i + 1], groundPoints[i + 1], groundPoints[i]], style['lineOpacity'], style['polygonOpacity'], style['lineDasharray']);
      }
    };
    _proto._getStyle = function _getStyle() {
      var style = this.geometry.getLayer().options['drawAltitude'];
      if (!isObject(style)) {
        style = defaultSymbol;
      }
      if (!style['lineWidth']) {
        style['lineWidth'] = 0;
        style['lineOpacity'] = 0;
      }
      return style;
    };
    return DrawAltitudeSymbolizer;
  }(PointSymbolizer);



  var index$3 = /*#__PURE__*/Object.freeze({
    Symbolizer: Symbolizer,
    CanvasSymbolizer: CanvasSymbolizer,
    DebugSymbolizer: DebugSymbolizer,
    ImageMarkerSymbolizer: ImageMarkerSymbolizer,
    PointSymbolizer: PointSymbolizer,
    StrokeAndFillSymbolizer: StrokeAndFillSymbolizer,
    TextMarkerSymbolizer: TextMarkerSymbolizer,
    VectorMarkerSymbolizer: VectorMarkerSymbolizer,
    VectorPathMarkerSymbolizer: VectorPathMarkerSymbolizer,
    DrawAltitudeSymbolizer: DrawAltitudeSymbolizer
  });

  var registerSymbolizers = [DrawAltitudeSymbolizer, StrokeAndFillSymbolizer, ImageMarkerSymbolizer, VectorPathMarkerSymbolizer, VectorMarkerSymbolizer, TextMarkerSymbolizer];
  var testCanvas;
  var TEMP_POINT0$2 = new Point(0, 0);
  var TEMP_PAINT_EXTENT = new PointExtent();
  var TEMP_FIXED_EXTENT = new PointExtent();
  var TEMP_CLIP_EXTENT0 = new PointExtent();
  var TEMP_CLIP_EXTENT1 = new PointExtent();
  var TEMP_CLIP_EXTENT2 = new PointExtent();
  var PROJECTION = {};
  var TEMP_BBOX = {
    minx: Infinity,
    miny: Infinity,
    maxx: -Infinity,
    maxy: -Infinity
  };
  var Painter = function (_Class) {
    _inheritsLoose(Painter, _Class);
    function Painter(geometry) {
      var _this;
      _this = _Class.call(this) || this;
      _this.geometry = geometry;
      _this.symbolizers = _this._createSymbolizers();
      _this._altAtGL = _this._getGeometryAltitude();
      _this.bbox = getDefaultBBOX();
      _this._drawTime = 0;
      return _this;
    }
    var _proto = Painter.prototype;
    _proto._setDrawTime = function _setDrawTime(time) {
      this._drawTime = time;
      return this;
    };
    _proto.getRenderBBOX = function getRenderBBOX() {
      var layer = this.getLayer();
      if (layer && layer._drawTime !== this._drawTime) {
        return null;
      }
      resetBBOX(this.bbox);
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        var symbolizer = this.symbolizers[i];
        var bbox = symbolizer.bbox;
        if (!validateBBOX(bbox)) {
          continue;
        }
        setBBOX(this.bbox, bbox);
      }
      if (validateBBOX(this.bbox)) {
        return this.bbox;
      }
      return null;
    };
    _proto.getMap = function getMap() {
      return this.geometry.getMap();
    };
    _proto.getLayer = function getLayer() {
      return this.geometry && this.geometry.getLayer();
    };
    _proto._createSymbolizers = function _createSymbolizers() {
      var geoSymbol = this.getSymbol(),
        symbolizers = [],
        regSymbolizers = registerSymbolizers;
      var symbols = geoSymbol;
      if (!Array.isArray(geoSymbol)) {
        symbols = [geoSymbol];
      }
      for (var ii = symbols.length - 1; ii >= 0; ii--) {
        var symbol = symbols[ii];
        for (var i = regSymbolizers.length - 1; i >= 0; i--) {
          if (regSymbolizers[i].test(symbol, this.geometry)) {
            var symbolizer = new regSymbolizers[i](symbol, this.geometry, this);
            symbolizer._index = ii;
            symbolizers.push(symbolizer);
            if (symbolizer instanceof PointSymbolizer) {
              this._hasPoint = true;
            }
          }
        }
      }
      if (!symbolizers.length) {
        if (console) {
          var id = this.geometry.getId();
          console.warn('invalid symbol for geometry(' + (this.geometry ? this.geometry.getType() + (id ? ':' + id : '') : '') + ') to draw : ' + JSON.stringify(geoSymbol));
        }
      }
      this._debugSymbolizer = new DebugSymbolizer(geoSymbol, this.geometry, this);
      return symbolizers;
    };
    _proto.hasPoint = function hasPoint() {
      return !!this._hasPoint;
    };
    _proto.getRenderPoints = function getRenderPoints(placement) {
      this._verifyProjection();
      if (!this._renderPoints) {
        this._renderPoints = {};
      }
      if (!placement) {
        placement = 'center';
      }
      if (!this._renderPoints[placement]) {
        this._renderPoints[placement] = this.geometry._getRenderPoints(placement);
      }
      return this._renderPoints[placement];
    };
    _proto.getPaintParams = function getPaintParams(dx, dy, ignoreAltitude, disableClip, ptkey) {
      if (ptkey === void 0) {
        ptkey = '_pt';
      }
      var renderer = this.getLayer()._getRenderer();
      var mapStateCache = renderer.mapStateCache;
      var resolution, pitch, bearing, glScale, containerExtent;
      var map = this.getMap();
      if (mapStateCache && !this._hitPoint) {
        resolution = mapStateCache.resolution;
        pitch = mapStateCache.pitch;
        bearing = mapStateCache.bearing;
        glScale = mapStateCache.glScale;
        containerExtent = mapStateCache.containerExtent;
      } else {
        resolution = map.getResolution();
        pitch = map.getPitch();
        bearing = map.getBearing();
        glScale = map.getGLScale();
        containerExtent = map.getContainerExtent();
      }
      var geometry = this.geometry,
        res = resolution,
        pitched = pitch !== 0,
        rotated = bearing !== 0;
      var params = this._cachedParams;
      var paintAsPath = geometry._paintAsPath && geometry._paintAsPath();
      if (paintAsPath && this._unsimpledParams && res <= this._unsimpledParams._res) {
        params = this._unsimpledParams;
      } else if (!params || params._res !== resolution || this._pitched !== pitched && geometry._redrawWhenPitch() || this._rotated !== rotated && geometry._redrawWhenRotate()) {
        params = geometry._getPaintParams();
        if (!params) {
          return null;
        }
        params._res = res;
        if (!geometry._simplified && paintAsPath) {
          if (!this._unsimpledParams) {
            this._unsimpledParams = params;
          }
          if (res > this._unsimpledParams._res) {
            this._unsimpledParams._res = res;
          }
        }
        this._cachedParams = params;
      }
      if (!params) {
        return null;
      }
      this._pitched = pitched;
      this._rotated = rotated;
      var zoomScale = glScale,
        tr = [],
        points = params[0];
      var mapExtent = containerExtent;
      var cPoints = this._pointContainerPoints(points, dx, dy, ignoreAltitude, disableClip || this._hitPoint && !mapExtent.contains(this._hitPoint), null, ptkey);
      if (!cPoints) {
        return null;
      }
      tr.push(cPoints);
      for (var i = 1, l = params.length; i < l; i++) {
        if (isNumber(params[i]) || params[i] instanceof Size) {
          if (isNumber(params[i])) {
            tr.push(params[i] / zoomScale);
          } else {
            tr.push(params[i].multi(1 / zoomScale));
          }
        } else {
          tr.push(params[i]);
        }
      }
      return tr;
    };
    _proto._pointContainerPoints = function _pointContainerPoints(points, dx, dy, ignoreAltitude, disableClip, pointPlacement, ptkey) {
      if (ptkey === void 0) {
        ptkey = '_pt';
      }
      if (this._aboveCamera()) {
        return null;
      }
      var renderer = this.getLayer()._getRenderer();
      var mapStateCache = renderer.mapStateCache;
      var map = this.getMap(),
        geometry = this.geometry,
        containerOffset = this.containerOffset;
      var glRes, containerExtent;
      if (mapStateCache) {
        glRes = mapStateCache.glRes;
        containerExtent = mapStateCache.containerExtent;
      } else {
        glRes = map.getGLRes();
        containerExtent = map.getContainerExtent();
      }
      var cPoints;
      var roundPoint = this.getLayer().options['roundPoint'];
      var minx = Infinity,
        miny = Infinity,
        maxx = -Infinity,
        maxy = -Infinity;
      var needClip = !disableClip;
      var clipBBoxBufferSize = renderer.layer.options['clipBBoxBufferSize'] || 3;
      var symbolizers = this.symbolizers;
      function pointsContainerPoints(viewPoints, alts) {
        if (viewPoints === void 0) {
          viewPoints = [];
        }
        if (alts === void 0) {
          alts = [];
        }
        var pts = getPointsResultPts(viewPoints, ptkey);
        pts = map._pointsAtResToContainerPoints(viewPoints, glRes, alts, pts);
        for (var i = 0, len = pts.length; i < len; i++) {
          var p = pts[i];
          p._sub(containerOffset);
          if (dx || dy) {
            p._add(dx || 0, dy || 0);
          }
          if (roundPoint) {
            p.x = Math.ceil(p.x);
            p.y = Math.ceil(p.y);
          }
          minx = Math.min(p.x, minx);
          miny = Math.min(p.y, miny);
          maxx = Math.max(p.x, maxx);
          maxy = Math.max(p.y, maxy);
        }
        if (needClip && isDashLine(symbolizers)) {
          TEMP_CLIP_EXTENT2.ymin = containerExtent.ymin;
          if (TEMP_CLIP_EXTENT2.ymin < clipBBoxBufferSize) {
            TEMP_CLIP_EXTENT2.ymin = containerExtent.ymin - clipBBoxBufferSize;
          }
          TEMP_CLIP_EXTENT2.xmin = containerExtent.xmin - clipBBoxBufferSize;
          TEMP_CLIP_EXTENT2.xmax = containerExtent.xmax + clipBBoxBufferSize;
          TEMP_CLIP_EXTENT2.ymax = containerExtent.ymax + clipBBoxBufferSize;
          if (geometry.getShell && geometry.getHoles) {
            return clipPolygon(pts, TEMP_CLIP_EXTENT2);
          }
          var clipPts = clipLine(pts, TEMP_CLIP_EXTENT2, false);
          if (clipPts.length) {
            var _points = [];
            clipPts.forEach(function (clipPt) {
              for (var _i = 0, _len = clipPt.length; _i < _len; _i++) {
                _points.push(clipPt[_i].point);
              }
            });
            return _points;
          }
        }
        return pts;
      }
      var altitude = this.getAltitude();
      if (Array.isArray(points)) {
        var _geometry = this.geometry;
        var clipped;
        if (!disableClip && _geometry.options['enableClip']) {
          clipped = this._clip(points, altitude);
          if (clipped.inView) {
            needClip = false;
          }
        } else {
          clipped = {
            points: points,
            altitude: altitude
          };
        }
        var clipPoints = clipped.points;
        altitude = clipped.altitude;
        if (ignoreAltitude) {
          altitude = 0;
        }
        var alt = altitude;
        cPoints = [];
        var alts = [];
        var altitudeIsNumber = isNumber(altitude);
        for (var i = 0, l = clipPoints.length; i < l; i++) {
          var c = clipPoints[i];
          if (Array.isArray(c)) {
            if (altitudeIsNumber) {
              var _cring = pointsContainerPoints(c, altitude);
              cPoints.push(_cring);
              continue;
            }
            var altArray = [];
            for (var ii = 0, ll = c.length; ii < ll; ii++) {
              if (Array.isArray(altitude)) {
                if (altitude[i]) {
                  alt = altitude[i][ii];
                } else {
                  alt = 0;
                }
              }
              altArray.push(alt);
            }
            var cring = pointsContainerPoints(c, altArray);
            cPoints.push(cring);
          } else {
            if (Array.isArray(altitude)) {
              if (pointPlacement === 'vertex-last') {
                alt = altitude[altitude.length - 1 - i];
              } else if (pointPlacement === 'line') {
                alt = (altitude[i] + altitude[i + 1]) / 2;
              } else {
                alt = altitude[i];
              }
            }
            alts.push(alt);
          }
        }
        if (alts.length) {
          cPoints = pointsContainerPoints(clipPoints, alts);
        }
      } else if (points instanceof Point) {
        if (ignoreAltitude) {
          altitude = 0;
        }
        cPoints = map._pointAtResToContainerPoint(points, glRes, altitude)._sub(containerOffset);
        if (dx || dy) {
          cPoints._add(dx, dy);
        }
      }
      TEMP_BBOX.minx = minx;
      TEMP_BBOX.miny = miny;
      TEMP_BBOX.maxx = maxx;
      TEMP_BBOX.maxy = maxy;
      this._containerBbox = TEMP_BBOX;
      return cPoints;
    };
    _proto._clip = function _clip(points, altitude) {
      if (isNumber(altitude) && altitude !== 0) {
        return {
          points: points,
          altitude: altitude
        };
      }
      if (Array.isArray(altitude)) {
        var hasAltitude = false;
        for (var i = 0, len = altitude.length; i < len; i++) {
          if (altitude[i] !== 0) {
            hasAltitude = true;
            break;
          }
        }
        if (hasAltitude) {
          return {
            points: points,
            altitude: altitude
          };
        }
      }
      var map = this.getMap(),
        geometry = this.geometry;
      var lineWidth = this.getSymbol()['lineWidth'];
      if (!isNumber(lineWidth)) {
        lineWidth = 4;
      }
      var renderer = this.getLayer()._getRenderer();
      var mapStateCache = renderer.mapStateCache;
      var _2DExtent, glExtent, pitch;
      if (mapStateCache) {
        _2DExtent = mapStateCache._2DExtent;
        glExtent = mapStateCache.glExtent;
        pitch = mapStateCache.pitch;
      } else {
        _2DExtent = map._get2DExtent();
        glExtent = map._get2DExtentAtRes(map.getGLRes());
        pitch = map.getPitch();
      }
      var extent2D = _2DExtent._expand(lineWidth);
      if (pitch > 0 && altitude) {
        var c = map.cameraLookAt;
        var pos = map.cameraPosition;
        TEMP_POINT0$2.set(pos.x, pos.y);
        extent2D = extent2D._combine(TEMP_POINT0$2._add(sign(c[0] - pos[0]), sign(c[1] - pos[1])));
      }
      var e = this.get2DExtent(null, TEMP_CLIP_EXTENT1);
      var clipPoints = points;
      if (e.within(extent2D)) {
        return {
          points: clipPoints,
          altitude: altitude,
          inView: true
        };
      }
      var glExtent2D = glExtent._expand(lineWidth * map._glScale);
      TEMP_CLIP_EXTENT0.xmin = glExtent2D.xmin;
      TEMP_CLIP_EXTENT0.xmax = glExtent2D.xmax;
      TEMP_CLIP_EXTENT0.ymin = glExtent2D.ymin;
      TEMP_CLIP_EXTENT0.ymax = glExtent2D.ymax;
      var smoothness = geometry.options['smoothness'];
      if (geometry.getShell && this.geometry.getHoles && !smoothness) {
        var xmin = glExtent2D.xmin,
          ymin = glExtent2D.ymin,
          xmax = glExtent2D.xmax,
          ymax = glExtent2D.ymax;
        var dx = Math.abs(xmax - xmin),
          dy = Math.abs(ymax - ymin);
        var r = Math.sqrt(dx * dx + dy * dy);
        var rx = (r - dx) / 2,
          ry = (r - dy) / 2;
        TEMP_CLIP_EXTENT0.xmin = glExtent2D.xmin - rx;
        TEMP_CLIP_EXTENT0.xmax = glExtent2D.xmax + rx;
        TEMP_CLIP_EXTENT0.ymin = glExtent2D.ymin - ry;
        TEMP_CLIP_EXTENT0.ymax = glExtent2D.ymax + ry;
        if (!Array.isArray(points[0])) {
          clipPoints = clipPolygon(points, TEMP_CLIP_EXTENT0);
        } else {
          clipPoints = [];
          for (var _i2 = 0; _i2 < points.length; _i2++) {
            var part = clipPolygon(points[_i2], TEMP_CLIP_EXTENT0);
            if (part.length) {
              clipPoints.push(part);
            }
          }
        }
      } else if (geometry.getJSONType() === 'LineString' && !smoothness) {
        if (!Array.isArray(points[0])) {
          clipPoints = clipLine(points, TEMP_CLIP_EXTENT0, false, !!smoothness);
        } else {
          clipPoints = [];
          for (var _i3 = 0; _i3 < points.length; _i3++) {
            pushIn(clipPoints, clipLine(points[_i3], TEMP_CLIP_EXTENT0, false, !!smoothness));
          }
        }
        return this._interpolateSegAlt(clipPoints, points, altitude);
      }
      return {
        points: clipPoints,
        altitude: altitude
      };
    };
    _proto._interpolateSegAlt = function _interpolateSegAlt(clipSegs, orig, altitude) {
      if (!Array.isArray(altitude)) {
        var fn = function fn(cc) {
          return cc.point;
        };
        return {
          points: clipSegs.map(function (c) {
            if (Array.isArray(c)) {
              return c.map(fn);
            }
            return c.point;
          }),
          altitude: altitude
        };
      }
      var segsWithAlt = interpolateAlt(clipSegs, orig, altitude);
      altitude = [];
      var points = segsWithAlt.map(function (p) {
        if (Array.isArray(p)) {
          var alt = [];
          var cp = p.map(function (pp) {
            alt.push(pp.altitude);
            return pp.point;
          });
          altitude.push(alt);
          return cp;
        }
        altitude.push(p.altitude);
        return p.point;
      });
      return {
        points: points,
        altitude: altitude
      };
    };
    _proto.getSymbol = function getSymbol() {
      return this.geometry._getInternalSymbol();
    };
    _proto._resetSymbolizersBBOX = function _resetSymbolizersBBOX() {
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        var symbolizer = this.symbolizers[i];
        var bbox = symbolizer.bbox;
        resetBBOX(bbox);
      }
      return this;
    };
    _proto.paint = function paint(extent, context, offset) {
      if (!this.symbolizers) {
        return;
      }
      var layer = this.getLayer();
      var renderer = layer._getRenderer();
      if (!renderer || !renderer.context && !context) {
        return;
      }
      var mapStateCache = renderer.mapStateCache || {};
      if (!this.geometry._isCheck) {
        if (extent && !extent.intersects(this.get2DExtent(renderer.resources, TEMP_PAINT_EXTENT))) {
          return;
        }
      }
      var map = this.getMap();
      if (this._aboveCamera()) {
        return;
      }
      this.containerOffset = offset || mapStateCache.offset || map._pointToContainerPoint(renderer.southWest)._add(0, -map.height);
      this._beforePaint();
      var ctx = context || renderer.context;
      if (!ctx.isHitTesting) {
        this._resetSymbolizersBBOX();
      }
      var contexts = [ctx, renderer.resources];
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        if (ctx.shadowBlur || this.symbolizers[i].symbol['shadowBlur']) {
          this._prepareShadow(ctx, this.symbolizers[i].symbol);
        }
        this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
      }
      this._afterPaint();
      this._painted = true;
      if (this.geometry.options['debug'] || layer.options['debug']) {
        this._debugSymbolizer.symbolize.apply(this._debugSymbolizer, contexts);
      }
    };
    _proto.getSprite = function getSprite(resources, canvasClass) {
      if (!this.geometry.isPoint) {
        return null;
      }
      this._spriting = true;
      if (!this._sprite && this.symbolizers.length > 0) {
        var extent = new PointExtent();
        this.symbolizers.forEach(function (s) {
          var markerExtent = s.getFixedExtent(resources);
          extent._combine(markerExtent);
        });
        var origin = extent.getMin().multi(-1);
        var clazz = canvasClass || (this.getMap() ? this.getMap().CanvasClass : null);
        var canvas = Canvas.createCanvas(extent.getWidth(), extent.getHeight(), clazz);
        var bak;
        if (this._renderPoints) {
          bak = this._renderPoints;
        }
        var ctx = canvas.getContext('2d');
        var contexts = [ctx, resources];
        for (var i = this.symbolizers.length - 1; i >= 0; i--) {
          var dxdy = this.symbolizers[i].getDxDy();
          this._renderPoints = {
            'center': [[origin.add(dxdy)]]
          };
          this._prepareShadow(ctx, this.symbolizers[i].symbol);
          this.symbolizers[i].symbolize.apply(this.symbolizers[i], contexts);
        }
        if (bak) {
          this._renderPoints = bak;
        }
        this._sprite = {
          'canvas': canvas,
          'offset': extent.getCenter()
        };
      }
      this._spriting = false;
      return this._sprite;
    };
    _proto.isSpriting = function isSpriting() {
      return !!this._spriting;
    };
    _proto.hitTest = function hitTest(cp, tolerance) {
      if (!tolerance || tolerance < 0.5) {
        tolerance = 0.5;
      }
      this._hitPoint = cp.sub(tolerance, tolerance);
      if (!testCanvas) {
        var canvasClass = this.getMap() ? this.getMap().CanvasClass : null;
        testCanvas = Canvas.createCanvas(1, 1, canvasClass);
      }
      Canvas.setHitTesting(true);
      testCanvas.width = testCanvas.height = 2 * tolerance;
      var ctx = Canvas.getCanvas2DContext(testCanvas);
      ctx.isHitTesting = true;
      try {
        this.paint(null, ctx, this._hitPoint);
      } catch (e) {
        throw e;
      } finally {
        Canvas.setHitTesting(false);
      }
      delete this._hitPoint;
      var imgData = ctx.getImageData(0, 0, testCanvas.width, testCanvas.height).data;
      for (var i = 3, l = imgData.length; i < l; i += 4) {
        if (imgData[i] > 0) {
          return true;
        }
      }
      return false;
    };
    _proto.isHitTesting = function isHitTesting() {
      return !!this._hitPoint;
    };
    _proto._prepareShadow = function _prepareShadow(ctx, symbol) {
      if (symbol['shadowBlur']) {
        ctx.shadowBlur = this.isHitTesting() ? 0 : symbol['shadowBlur'];
        ctx.shadowColor = symbol['shadowColor'] || '#000';
        ctx.shadowOffsetX = symbol['shadowOffsetX'] || 0;
        ctx.shadowOffsetY = symbol['shadowOffsetY'] || 0;
      } else if (ctx.shadowBlur) {
        ctx.shadowBlur = null;
        ctx.shadowColor = null;
        ctx.shadowOffsetX = null;
        ctx.shadowOffsetY = null;
      }
    };
    _proto._eachSymbolizer = function _eachSymbolizer(fn, context) {
      if (!this.symbolizers) {
        return;
      }
      if (!context) {
        context = this;
      }
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        fn.apply(context, [this.symbolizers[i]]);
      }
    };
    _proto.get2DExtent = function get2DExtent(resources, out) {
      this._verifyProjection();
      var map = this.getMap();
      resources = resources || this.getLayer()._getRenderer().resources;
      var zoom = map.getZoom();
      var isDynamicSize = this._isDynamicSize();
      if (!this._extent2D || this._extent2D._zoom !== zoom || !this._fixedExtent) {
        if (this._extent2D && this._extent2D._zoom !== zoom) {
          delete this._extent2D;
        }
        if (this.symbolizers) {
          if (!this._extent2D) {
            this._extent2D = this._computeExtent2D(new PointExtent());
            this._extent2D._zoom = zoom;
          }
          if (!this._fixedExtent) {
            this._fixedExtent = this._computeFixedExtent(resources, new PointExtent());
          }
        }
      }
      if (!this._extent2D) {
        if (isDynamicSize) {
          delete this._fixedExtent;
        }
        return null;
      }
      var _this$_fixedExtent = this._fixedExtent,
        xmin = _this$_fixedExtent.xmin,
        ymin = _this$_fixedExtent.ymin,
        xmax = _this$_fixedExtent.xmax,
        ymax = _this$_fixedExtent.ymax;
      if (isDynamicSize) {
        delete this._fixedExtent;
      }
      TEMP_FIXED_EXTENT.set(xmin, -ymax, xmax, -ymin);
      if (out) {
        out.set(this._extent2D['xmin'], this._extent2D['ymin'], this._extent2D['xmax'], this._extent2D['ymax']);
        out._add(TEMP_FIXED_EXTENT);
        return out;
      }
      return this._extent2D.add(TEMP_FIXED_EXTENT);
    };
    _proto._computeExtent2D = function _computeExtent2D(extent) {
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        var symbolizer = this.symbolizers[i];
        extent._combine(symbolizer.get2DExtent());
      }
      return extent;
    };
    _proto._computeFixedExtent = function _computeFixedExtent(resources, extent) {
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        var symbolizer = this.symbolizers[i];
        if (symbolizer.getFixedExtent) {
          extent._combine(symbolizer.getFixedExtent(resources));
        }
      }
      return extent;
    };
    _proto._isDynamicSize = function _isDynamicSize() {
      for (var i = this.symbolizers.length - 1; i >= 0; i--) {
        var symbolizer = this.symbolizers[i];
        if (symbolizer.isDynamicSize()) {
          return true;
        }
      }
      return false;
    };
    _proto._aboveCamera = function _aboveCamera() {
      var altitude = this.getMinAltitude();
      var map = this.getMap();
      var glRes = map.getGLRes();
      altitude = map.altitudeToPoint(altitude, glRes) * sign(altitude);
      var frustumAlt = map.getFrustumAltitude();
      return altitude && frustumAlt && frustumAlt < altitude;
    };
    _proto.getFixedExtent = function getFixedExtent() {
      var map = this.getMap();
      var zoom = map.getZoom();
      if (this._isDynamicSize()) {
        return this._computeFixedExtent(null, new PointExtent());
      }
      if (!this._extent2D || this._extent2D._zoom !== zoom) {
        this.get2DExtent(null, TEMP_FIXED_EXTENT);
      }
      return this._fixedExtent;
    };
    _proto.setZIndex = function setZIndex(change) {
      this._eachSymbolizer(function (symbolizer) {
        symbolizer.setZIndex(change);
      });
    };
    _proto.show = function show() {
      if (!this._painted) {
        var layer = this.getLayer();
        if (!layer.isCanvasRender()) {
          this.paint();
        }
      } else {
        this.removeCache();
        this._eachSymbolizer(function (symbolizer) {
          symbolizer.show();
        });
      }
    };
    _proto.hide = function hide() {
      this._eachSymbolizer(function (symbolizer) {
        symbolizer.hide();
      });
    };
    _proto.repaint = function repaint() {
      this._altAtGL = this._getGeometryAltitude();
      this.removeCache();
      var layer = this.getLayer();
      if (!layer) {
        return;
      }
      var renderer = layer.getRenderer();
      if (!renderer || !renderer.setToRedraw()) {
        return;
      }
      renderer.setToRedraw();
    };
    _proto.refreshSymbol = function refreshSymbol() {
      this.removeCache();
      this._removeSymbolizers();
      this.symbolizers = this._createSymbolizers();
    };
    _proto.remove = function remove() {
      this.removeCache();
      this._removeSymbolizers();
    };
    _proto._removeSymbolizers = function _removeSymbolizers() {
      this._eachSymbolizer(function (symbolizer) {
        delete symbolizer.painter;
        symbolizer.remove();
      });
      delete this.symbolizers;
    };
    _proto.removeCache = function removeCache() {
      delete this._renderPoints;
      delete this._paintParams;
      delete this._sprite;
      delete this._extent2D;
      delete this._fixedExtent;
      delete this._cachedParams;
      delete this._unsimpledParams;
    };
    _proto.getAltitude = function getAltitude() {
      var propAlt = this.geometry._getAltitude();
      if (propAlt !== this._propAlt) {
        this._altAtGL = this._getGeometryAltitude();
      }
      if (!this._altAtGL) {
        return 0;
      }
      return this._altAtGL;
    };
    _proto.getMinAltitude = function getMinAltitude() {
      if (!this.minAltitude) {
        return 0;
      }
      return this.minAltitude;
    };
    _proto.getMaxAltitude = function getMaxAltitude() {
      if (!this.maxAltitude) {
        return 0;
      }
      return this.maxAltitude;
    };
    _proto._getGeometryAltitude = function _getGeometryAltitude() {
      var _this2 = this;
      var map = this.getMap();
      if (!map) {
        return 0;
      }
      var altitude = this.geometry._getAltitude();
      this._propAlt = altitude;
      if (!altitude) {
        this.minAltitude = this.maxAltitude = 0;
        return 0;
      }
      var center = this.geometry.getCenter();
      if (!center) {
        return 0;
      }
      if (Array.isArray(altitude)) {
        this.minAltitude = Number.MAX_VALUE;
        this.maxAltitude = Number.MIN_VALUE;
        return altitude.map(function (alt) {
          var a = alt;
          if (a < _this2.minAltitude) {
            _this2.minAltitude = a;
          }
          if (a > _this2.maxAltitude) {
            _this2.maxAltitude = a;
          }
          return a;
        });
      } else {
        this.minAltitude = this.maxAltitude = altitude;
        return this.minAltitude;
      }
    };
    _proto._verifyProjection = function _verifyProjection() {
      var projection = this.geometry._getProjection() || PROJECTION;
      if (this._projCode && this._projCode !== projection.code) {
        this.removeCache();
      }
      this._projCode = projection.code;
    };
    _proto._beforePaint = function _beforePaint() {};
    _proto._afterPaint = function _afterPaint() {};
    return Painter;
  }(Class);
  function interpolateAlt(points, orig, altitude) {
    if (!Array.isArray(altitude)) {
      return points;
    }
    var parts = [];
    for (var i = 0, l = points.length; i < l; i++) {
      if (Array.isArray(points[i])) {
        parts.push(interpolateAlt(points[i], orig, altitude));
      } else {
        var p = points[i];
        if (!p.point.equals(orig[p.index])) {
          var w0 = void 0,
            w1 = void 0;
          if (p.index === 0) {
            w0 = p.index;
            w1 = p.index + 1;
          } else {
            w0 = p.index - 1;
            w1 = p.index;
          }
          var t0 = p.point.distanceTo(orig[w1]);
          var t = t0 / (t0 + orig[w0].distanceTo(p.point));
          var alt = interpolate(altitude[w0], altitude[w1], 1 - t);
          p.altitude = alt;
          parts.push(p);
        } else {
          p.altitude = altitude[p.index];
          parts.push(p);
        }
      }
    }
    return parts;
  }

  var TEMP_EXTENT$4 = new PointExtent();
  var CollectionPainter = function (_Class) {
    _inheritsLoose(CollectionPainter, _Class);
    function CollectionPainter(geometry, isMask) {
      var _this;
      _this = _Class.call(this) || this;
      _this.geometry = geometry;
      _this.isMask = isMask;
      _this.bbox = getDefaultBBOX();
      _this._drawTime = 0;
      return _this;
    }
    var _proto = CollectionPainter.prototype;
    _proto._setDrawTime = function _setDrawTime(time) {
      this._drawTime = time;
      this._eachPainter(function (painter) {
        painter._setDrawTime(time);
      });
      return this;
    };
    _proto.getRenderBBOX = function getRenderBBOX() {
      var _this2 = this;
      var layer = this.getLayer();
      if (layer && layer._drawTime !== this._drawTime) {
        return null;
      }
      resetBBOX(this.bbox);
      this._eachPainter(function (painter) {
        var bbox = painter.getRenderBBOX();
        if (!validateBBOX(bbox)) {
          return;
        }
        setBBOX(_this2.bbox, bbox);
      });
      if (validateBBOX(this.bbox)) {
        return this.bbox;
      }
      return null;
    };
    _proto._eachPainter = function _eachPainter(fn) {
      var geometries = this.geometry.getGeometries();
      var painter;
      for (var i = 0, len = geometries.length; i < len; i++) {
        painter = this.isMask ? geometries[i]._getMaskPainter() : geometries[i]._getPainter();
        if (!painter) {
          continue;
        }
        if (painter) {
          if (fn.call(this, painter) === false) {
            break;
          }
        }
      }
    };
    _proto.getLayer = function getLayer() {
      return this.geometry && this.geometry.getLayer();
    };
    _proto.paint = function paint(extent) {
      if (!this.geometry) {
        return;
      }
      this._eachPainter(function (painter) {
        painter.paint(extent);
      });
    };
    _proto.get2DExtent = function get2DExtent(resources, out) {
      if (out) {
        out.set(null, null, null, null);
      }
      var extent = out || new PointExtent();
      this._eachPainter(function (painter) {
        extent = extent._combine(painter.get2DExtent(resources, TEMP_EXTENT$4));
      });
      return extent;
    };
    _proto.remove = function remove() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.remove.apply(painter, args);
      });
    };
    _proto.setZIndex = function setZIndex() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.setZIndex.apply(painter, args);
      });
    };
    _proto.show = function show() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.show.apply(painter, args);
      });
    };
    _proto.hide = function hide() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.hide.apply(painter, args);
      });
    };
    _proto.repaint = function repaint() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.repaint.apply(painter, args);
      });
    };
    _proto.refreshSymbol = function refreshSymbol() {
      var args = arguments;
      this._eachPainter(function (painter) {
        painter.refreshSymbol.apply(painter, args);
      });
    };
    _proto.hasPoint = function hasPoint() {
      var result = false;
      this._eachPainter(function (painter) {
        if (painter.hasPoint()) {
          result = true;
          return false;
        }
        return true;
      });
      return result;
    };
    _proto.getMinAltitude = function getMinAltitude() {
      var first = true;
      var result = 0;
      this._eachPainter(function (painter) {
        var alt = painter.getMinAltitude();
        if (first || alt < result) {
          first = false;
          result = alt;
        }
      });
      return result;
    };
    _proto.getMaxAltitude = function getMaxAltitude() {
      var result = 0;
      this._eachPainter(function (painter) {
        var alt = painter.getMaxAltitude();
        if (alt > result) {
          result = alt;
        }
      });
      return result;
    };
    return CollectionPainter;
  }(Class);

  var MAX_ZOOM = 23;
  var DefaultSpatialReference = {
    'EPSG:3857': {
      'projection': 'EPSG:3857',
      'resolutions': function () {
        var resolutions = [];
        var d = 2 * 6378137 * Math.PI;
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = d / (256 * Math.pow(2, i));
        }
        return resolutions;
      }(),
      'fullExtent': {
        'top': 6378137 * Math.PI,
        'left': -6378137 * Math.PI,
        'bottom': -6378137 * Math.PI,
        'right': 6378137 * Math.PI
      }
    },
    'EPSG:4326': {
      'projection': 'EPSG:4326',
      'fullExtent': {
        'top': 90,
        'left': -180,
        'bottom': -90,
        'right': 180
      },
      'resolutions': function () {
        var resolutions = [];
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = 180 / (Math.pow(2, i) * 128);
        }
        return resolutions;
      }()
    },
    'BAIDU': {
      'projection': 'baidu',
      'resolutions': function () {
        var res = Math.pow(2, 18);
        var resolutions = [];
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = res;
          res *= 0.5;
        }
        return resolutions;
      }(),
      'fullExtent': {
        'top': 33554432,
        'left': -33554432,
        'bottom': -33554432,
        'right': 33554432
      }
    },
    'IDENTITY': {
      'projection': 'identity',
      'resolutions': function () {
        var res = Math.pow(2, 8);
        var resolutions = [];
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = res;
          res *= 0.5;
        }
        return resolutions;
      }(),
      'fullExtent': {
        'top': 200000,
        'left': -200000,
        'bottom': -200000,
        'right': 200000
      }
    },
    'PRESET-VT-3857': {
      'projection': 'EPSG:3857',
      'resolutions': function () {
        var resolutions = [];
        var d = 6378137 * Math.PI;
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = d / (256 * Math.pow(2, i));
        }
        return resolutions;
      }(),
      'fullExtent': {
        'top': 6378137 * Math.PI,
        'left': -6378137 * Math.PI,
        'bottom': -6378137 * Math.PI,
        'right': 6378137 * Math.PI
      }
    },
    'PRESET-VT-4326': {
      'projection': 'EPSG:4326',
      'fullExtent': {
        'top': 90,
        'left': -180,
        'bottom': -90,
        'right': 180
      },
      'resolutions': function () {
        var resolutions = [];
        for (var i = 0; i < MAX_ZOOM; i++) {
          resolutions[i] = 180 / 4 / (Math.pow(2, i) * 128);
        }
        return resolutions;
      }()
    }
  };
  DefaultSpatialReference['EPSG:4490'] = DefaultSpatialReference['EPSG:4326'];
  DefaultSpatialReference['PRESET-3857-512'] = DefaultSpatialReference['PRESET-VT-3857'];
  DefaultSpatialReference['PRESET-4326-512'] = DefaultSpatialReference['PRESET-VT-4326'];
  var SpatialReference = function () {
    function SpatialReference(options) {
      if (options === void 0) {
        options = {};
      }
      this.options = options;
      this._initSpatialRef();
    }
    SpatialReference.registerPreset = function registerPreset(name, value) {
      name = name && name.toUpperCase();
      if (DefaultSpatialReference[name]) {
        console.warn("Spatial reference " + name + " already registered.");
      }
      DefaultSpatialReference[name] = value;
    };
    SpatialReference.getPreset = function getPreset(preset) {
      return DefaultSpatialReference[preset.toUpperCase()];
    };
    SpatialReference.getAllPresets = function getAllPresets() {
      return Object.keys(DefaultSpatialReference);
    };
    SpatialReference.getProjectionInstance = function getProjectionInstance(projection) {
      if (!projection) {
        return null;
      }
      if (isString(projection)) {
        projection = {
          code: projection
        };
      }
      if (projection.project) {
        if (!projection.locate) {
          projection = extend({}, projection);
          if (projection.measure === 'identity') {
            extend(projection, Measurer.getInstance('IDENTITY'));
          } else {
            extend(projection, Measurer.getInstance('EPSG:4326'));
          }
        }
        return projection;
      }
      var prjName = (projection.code + '').toLowerCase();
      for (var p in projections) {
        if (hasOwn(projections, p)) {
          var names = projections[p].aliases || [];
          var code = projections[p]['code'];
          names.push(code);
          for (var i = 0; i < names.length; i++) {
            if (names[i].toLowerCase() === prjName) {
              if (projections[p].create) {
                var instance = projections[p].create(projection);
                instance.code = names[i];
                return instance;
              } else {
                if (projections[p].code === names[i]) {
                  return projections[p];
                }
                var _instance = extend({}, projections[p]);
                _instance.code = names[i];
                return _instance;
              }
            }
          }
        }
      }
      return null;
    };
    SpatialReference.equals = function equals(sp1, sp2) {
      if (isString(sp1) || isString(sp2)) {
        return sp1 === sp2;
      }
      if (!sp1 && !sp2) {
        return true;
      } else if (!sp1 || !sp2) {
        return false;
      }
      if (sp1.projection !== sp2.projection) {
        return false;
      }
      var f1 = sp1.fullExtent,
        f2 = sp2.fullExtent;
      if (f1 && !f2 || !f1 && f2) {
        return false;
      }
      if (f1 && f2) {
        if (f1.top !== f2.top || f1.bottom !== f2.bottom || f1.left !== f2.left || f1.right !== f2.right) {
          return false;
        }
      }
      var r1 = sp1.resolutions,
        r2 = sp2.resolutions;
      if (r1 && r2) {
        if (r1.length !== r2.length) {
          return false;
        }
        for (var i = 0; i < r1.length; i++) {
          if (r1[i] !== r2[i]) {
            return false;
          }
        }
      } else if (r1 || r2) {
        return false;
      }
      return true;
    };
    var _proto = SpatialReference.prototype;
    _proto._initSpatialRef = function _initSpatialRef() {
      var projection = this.options['projection'];
      if (projection) {
        projection = SpatialReference.getProjectionInstance(projection);
      } else {
        projection = DEFAULT$1;
      }
      if (!projection) {
        throw new Error('must provide a valid projection in map\'s spatial reference.');
      }
      projection = extend({}, Common, projection);
      if (!projection.measureLength) {
        extend(projection, Measurer.DEFAULT);
      }
      this._projection = projection;
      var defaultSpatialRef,
        resolutions = this.options['resolutions'];
      if (!resolutions) {
        if (projection['code']) {
          defaultSpatialRef = DefaultSpatialReference[projection['code'].toUpperCase()];
          if (defaultSpatialRef) {
            resolutions = defaultSpatialRef['resolutions'];
            this.isEPSG = projection['code'] !== 'IDENTITY';
          }
        }
        if (!resolutions) {
          throw new Error('must provide valid resolutions in map\'s spatial reference.');
        }
      }
      this._resolutions = resolutions;
      this._pyramid = true;
      if (this._pyramid) {
        for (var i = 0; i < resolutions.length; i++) {
          if (resolutions[i] && resolutions[i - 1]) {
            if (resolutions[i - 1] / resolutions[i] !== 2) {
              this._pyramid = false;
              break;
            }
          }
        }
      }
      var fullExtent = this.options['fullExtent'];
      if (!fullExtent) {
        if (projection['code']) {
          defaultSpatialRef = DefaultSpatialReference[projection['code'].toUpperCase()];
          if (defaultSpatialRef) {
            fullExtent = defaultSpatialRef['fullExtent'];
          }
        }
        if (!fullExtent) {
          throw new Error('must provide a valid fullExtent in map\'s spatial reference.');
        }
      }
      if (!isNil(fullExtent['left'])) {
        this._fullExtent = new Extent(new Coordinate(fullExtent['left'], fullExtent['top']), new Coordinate(fullExtent['right'], fullExtent['bottom']));
      } else {
        this._fullExtent = new Extent(fullExtent);
        fullExtent['left'] = fullExtent['xmin'];
        fullExtent['right'] = fullExtent['xmax'];
        fullExtent['top'] = fullExtent['ymax'];
        fullExtent['bottom'] = fullExtent['ymin'];
      }
      if (isNil(fullExtent['top']) || isNil(fullExtent['bottom']) || isNil(fullExtent['left']) || isNil(fullExtent['right'])) {
        throw new Error('must provide valid top/bottom/left/right in fullExtent.');
      }
      extend(this._fullExtent, fullExtent);
      this._projection.fullExtent = fullExtent;
      var a = fullExtent['right'] >= fullExtent['left'] ? 1 : -1,
        b = fullExtent['top'] >= fullExtent['bottom'] ? -1 : 1;
      this._transformation = new Transformation([a, b, 0, 0]);
    };
    _proto.getResolutions = function getResolutions() {
      return this._resolutions || [];
    };
    _proto.getResolution = function getResolution(zoom) {
      var z = zoom | 0;
      if (z < 0) {
        z = 0;
      } else if (z > this._resolutions.length - 1) {
        z = this._resolutions.length - 1;
      }
      var res = this._resolutions[z];
      if (z !== zoom && zoom > 0 && z < this._resolutions.length - 1) {
        var next = this._resolutions[z + 1];
        return res + (next - res) * (zoom - z);
      }
      return res;
    };
    _proto.getProjection = function getProjection() {
      return this._projection;
    };
    _proto.getFullExtent = function getFullExtent() {
      return this._fullExtent;
    };
    _proto.getTransformation = function getTransformation() {
      return this._transformation;
    };
    _proto.getMinZoom = function getMinZoom() {
      for (var i = 0; i < this._resolutions.length; i++) {
        if (!isNil(this._resolutions[i])) {
          return i;
        }
      }
      return 0;
    };
    _proto.getMaxZoom = function getMaxZoom() {
      for (var i = this._resolutions.length - 1; i >= 0; i--) {
        if (!isNil(this._resolutions[i])) {
          return i;
        }
      }
      return this._resolutions.length - 1;
    };
    _proto.getZoomDirection = function getZoomDirection() {
      return sign(this._resolutions[this.getMinZoom()] - this._resolutions[this.getMaxZoom()]);
    };
    _proto.toJSON = function toJSON() {
      if (!this.json) {
        this.json = {
          'resolutions': this._resolutions,
          'fullExtent': {
            'top': this._fullExtent.top,
            'left': this._fullExtent.left,
            'bottom': this._fullExtent.bottom,
            'right': this._fullExtent.right
          },
          'projection': this._projection.code
        };
      }
      return this.json;
    };
    _proto.isPyramid = function isPyramid() {
      return this._pyramid;
    };
    return SpatialReference;
  }();

  var TEMP_POINT0$3 = new Point(0, 0);
  var TEMP_EXTENT$5 = new PointExtent();
  var TEMP_PROPERTIES = {};
  function validateExtent(extent) {
    if (!extent) {
      return false;
    }
    var xmin = extent.xmin,
      ymin = extent.ymin,
      xmax = extent.xmax,
      ymax = extent.ymax;
    return xmax - xmin > 0 && ymax - ymin > 0;
  }
  var options = {
    'id': null,
    'visible': true,
    'interactive': true,
    'editable': true,
    'cursor': null,
    'antiMeridian': false,
    'defaultProjection': 'EPSG:4326'
  };
  var Geometry = function (_JSONAble) {
    _inheritsLoose(Geometry, _JSONAble);
    function Geometry(options) {
      var _this;
      var opts = extend({}, options);
      var symbol = opts['symbol'];
      var properties = opts['properties'];
      var id = opts['id'];
      delete opts['symbol'];
      delete opts['id'];
      delete opts['properties'];
      _this = _JSONAble.call(this, opts) || this;
      if (symbol) {
        _this.setSymbol(symbol);
      } else {
        _this._genSizeSymbol();
      }
      if (properties) {
        _this.setProperties(properties);
      }
      if (!isNil(id)) {
        _this.setId(id);
      }
      return _this;
    }
    var _proto = Geometry.prototype;
    _proto.getFirstCoordinate = function getFirstCoordinate() {
      if (this.type === 'GeometryCollection') {
        var geometries = this.getGeometries();
        if (!geometries.length) {
          return null;
        }
        return geometries[0].getFirstCoordinate();
      }
      var coordinates = this.getCoordinates();
      if (!Array.isArray(coordinates)) {
        return coordinates;
      }
      do {
        coordinates = coordinates[0];
      } while (Array.isArray(coordinates) && coordinates.length > 0);
      return coordinates;
    };
    _proto.getLastCoordinate = function getLastCoordinate() {
      if (this.type === 'GeometryCollection') {
        var geometries = this.getGeometries();
        if (!geometries.length) {
          return null;
        }
        return geometries[geometries.length - 1].getLastCoordinate();
      }
      var coordinates = this.getCoordinates();
      if (!Array.isArray(coordinates)) {
        return coordinates;
      }
      do {
        coordinates = coordinates[coordinates.length - 1];
      } while (Array.isArray(coordinates) && coordinates.length > 0);
      return coordinates;
    };
    _proto.addTo = function addTo(layer, fitview) {
      layer.addGeometry(this, fitview);
      return this;
    };
    _proto.getLayer = function getLayer() {
      if (!this._layer) {
        return null;
      }
      return this._layer;
    };
    _proto.getMap = function getMap() {
      if (!this._layer) {
        return null;
      }
      return this._layer.getMap();
    };
    _proto.getId = function getId() {
      return this._id;
    };
    _proto.setId = function setId(id) {
      var oldId = this.getId();
      this._id = id;
      this._fireEvent('idchange', {
        'old': oldId,
        'new': id
      });
      return this;
    };
    _proto.getProperties = function getProperties() {
      if (!this.properties) {
        if (this._getParent()) {
          return this._getParent().getProperties();
        }
        return null;
      }
      return this.properties;
    };
    _proto.setProperties = function setProperties(properties) {
      var old = this.properties;
      this.properties = isObject(properties) ? extend({}, properties) : properties;
      this._clearAltitudeCache();
      this._repaint();
      this._fireEvent('propertieschange', {
        'old': old,
        'new': properties
      });
      return this;
    };
    _proto.getType = function getType() {
      return this.type;
    };
    _proto.getSymbol = function getSymbol() {
      var s = this._symbol;
      if (s) {
        if (!Array.isArray(s)) {
          return extend({}, s);
        } else {
          return extendSymbol(s);
        }
      }
      return null;
    };
    _proto.setSymbol = function setSymbol(symbol) {
      this._symbolUpdated = symbol;
      this._symbol = this._prepareSymbol(symbol);
      this.onSymbolChanged();
      delete this._compiledSymbol;
      delete this._symbolHash;
      return this;
    };
    _proto.getSymbolHash = function getSymbolHash$$1() {
      if (!this._symbolHash) {
        this._symbolHash = getSymbolHash(this._symbolUpdated);
      }
      return this._symbolHash;
    };
    _proto.updateSymbol = function updateSymbol(props) {
      if (!props) {
        return this;
      }
      var s = this._getSymbol();
      if (Array.isArray(s)) {
        if (!Array.isArray(props)) {
          throw new Error('Parameter of updateSymbol is not an array.');
        }
        for (var i = 0; i < props.length; i++) {
          if (isTextSymbol(props[i])) {
            delete this._textDesc;
          }
          if (s[i] && props[i]) {
            s[i] = extendSymbol(s[i], props[i]);
          }
        }
      } else if (Array.isArray(props)) {
        throw new Error('Geometry\'s symbol is not an array to update.');
      } else {
        if (isTextSymbol(s)) {
          delete this._textDesc;
        }
        if (s) {
          s = extendSymbol(s, props);
        } else {
          s = extendSymbol(this._getInternalSymbol(), props);
        }
      }
      this._eventSymbolProperties = props;
      delete this._compiledSymbol;
      return this.setSymbol(s);
    };
    _proto.getTextContent = function getTextContent() {
      var symbol = this._getInternalSymbol();
      if (Array.isArray(symbol)) {
        var contents = [];
        var has = false;
        for (var i = 0; i < symbol.length; i++) {
          contents[i] = replaceVariable(symbol[i] && symbol[i]['textName'], this.getProperties());
          if (!isNil(contents[i])) {
            has = true;
          }
        }
        return has ? contents : null;
      }
      return replaceVariable(symbol && symbol['textName'], this.getProperties());
    };
    _proto.getTextDesc = function getTextDesc() {
      if (!this._textDesc) {
        var textContent = this.getTextContent();
        var symbol = this._sizeSymbol;
        var isArray = Array.isArray(textContent);
        if (Array.isArray(symbol)) {
          this._textDesc = symbol.map(function (s, i) {
            return describeText(isArray ? textContent[i] : '', s);
          });
        } else {
          this._textDesc = describeText(textContent, symbol);
        }
      }
      return this._textDesc;
    };
    _proto.getCenter = function getCenter() {
      return this._computeCenter(this._getMeasurer());
    };
    _proto.getExtent = function getExtent() {
      var prjExt = this._getPrjExtent();
      var projection = this._getProjection();
      if (prjExt && projection) {
        var min = projection.unproject(new Coordinate(prjExt['xmin'], prjExt['ymin'])),
          max = projection.unproject(new Coordinate(prjExt['xmax'], prjExt['ymax']));
        return new Extent(min, max, projection);
      } else {
        return this._computeExtent(this._getMeasurer());
      }
    };
    _proto.getContainerExtent = function getContainerExtent(out) {
      var extent2d = this.get2DExtent();
      if (!extent2d || !extent2d.isValid()) {
        return null;
      }
      var map = this.getMap();
      var glRes = map.getGLRes();
      var minAltitude = this.getMinAltitude();
      var extent = extent2d.convertTo(function (c) {
        return map._pointAtResToContainerPoint(c, glRes, minAltitude, TEMP_POINT0$3);
      }, out);
      var maxAltitude = this.getMaxAltitude();
      if (maxAltitude !== minAltitude) {
        var extent2 = extent2d.convertTo(function (c) {
          return map._pointAtResToContainerPoint(c, glRes, maxAltitude, TEMP_POINT0$3);
        }, TEMP_EXTENT$5);
        extent._combine(extent2);
      }
      var layer = this.getLayer();
      if (layer && this.type === 'LineString' && maxAltitude && layer.options['drawAltitude']) {
        var groundExtent = extent2d.convertTo(function (c) {
          return map._pointAtResToContainerPoint(c, glRes, 0, TEMP_POINT0$3);
        }, TEMP_EXTENT$5);
        extent._combine(groundExtent);
      }
      if (extent) {
        var fixedExtent = this._getFixedExtent();
        if (validateExtent(fixedExtent)) {
          extent._add(fixedExtent);
        }
      }
      var smoothness = this.options['smoothness'];
      if (smoothness) {
        extent._expand(extent.getWidth() * 0.15);
      }
      return extent;
    };
    _proto._getFixedExtent = function _getFixedExtent() {
      if (!this._fixedExtent) {
        this._fixedExtent = new PointExtent();
      }
      var symbol = this._sizeSymbol;
      var t = (symbol && symbol['lineWidth'] || 1) / 2;
      this._fixedExtent.set(-t, -t, t, t);
      var dx = symbol && symbol['lineDx'] || 0;
      this._fixedExtent._add([dx, 0]);
      var dy = symbol && symbol['lineDy'] || 0;
      this._fixedExtent._add([0, dy]);
      return this._fixedExtent;
    };
    _proto.get2DExtent = function get2DExtent() {
      var map = this.getMap();
      if (!map) {
        return null;
      }
      if (this._extent2d) {
        return this._extent2d;
      }
      var extent = this._getPrjExtent();
      if (!extent || !extent.isValid()) {
        return null;
      }
      var min = extent.getMin();
      var max = extent.getMax();
      var glRes = map.getGLRes();
      map._prjToPointAtRes(min, glRes, min);
      map._prjToPointAtRes(max, glRes, max);
      this._extent2d = new PointExtent(min, max);
      this._extent2d.z = map.getZoom();
      return this._extent2d;
    };
    _proto.getSize = function getSize() {
      var extent = this.getContainerExtent();
      return extent ? extent.getSize() : null;
    };
    _proto.containsPoint = function containsPoint(containerPoint, t) {
      if (!this.getMap()) {
        throw new Error('The geometry is required to be added on a map to perform "containsPoint".');
      }
      if (containerPoint instanceof Coordinate) {
        containerPoint = this.getMap().coordToContainerPoint(containerPoint);
      }
      return this._containsPoint(containerPoint, t);
    };
    _proto._containsPoint = function _containsPoint(containerPoint, t) {
      var painter = this._getPainter();
      if (!painter) {
        return false;
      }
      t = t || 0;
      if (this._hitTestTolerance) {
        t += this._hitTestTolerance();
      }
      return painter.hitTest(containerPoint, t);
    };
    _proto.show = function show() {
      this.options['visible'] = true;
      if (this.getMap()) {
        var painter = this._getPainter();
        if (painter) {
          painter.show();
        }
        this._fireEvent('show');
      }
      return this;
    };
    _proto.hide = function hide() {
      this.options['visible'] = false;
      if (this.getMap()) {
        this.onHide();
        var painter = this._getPainter();
        if (painter) {
          painter.hide();
        }
        this._fireEvent('hide');
      }
      return this;
    };
    _proto.isVisible = function isVisible() {
      if (!this.options['visible']) {
        return false;
      }
      var symbol = this._getInternalSymbol();
      if (!symbol) {
        return true;
      }
      if (Array.isArray(symbol)) {
        if (!symbol.length) {
          return true;
        }
        for (var i = 0, l = symbol.length; i < l; i++) {
          if (isNil(symbol[i]['opacity']) || symbol[i]['opacity'] > 0) {
            return true;
          }
        }
        return false;
      } else {
        return isNil(symbol['opacity']) || isObject(symbol['opacity']) || isNumber(symbol['opacity']) && symbol['opacity'] > 0;
      }
    };
    _proto.getZIndex = function getZIndex() {
      return this.options['zIndex'] || 0;
    };
    _proto.setZIndex = function setZIndex(zIndex) {
      var old = this.options['zIndex'];
      this.options['zIndex'] = zIndex;
      this._fireEvent('zindexchange', {
        'old': old,
        'new': zIndex
      });
      return this;
    };
    _proto.setZIndexSilently = function setZIndexSilently(zIndex) {
      this.options['zIndex'] = zIndex;
      return this;
    };
    _proto.bringToFront = function bringToFront() {
      var layer = this.getLayer();
      if (!layer || !layer.getGeoMaxZIndex) {
        return this;
      }
      var topZ = layer.getGeoMaxZIndex();
      this.setZIndex(topZ + 1);
      return this;
    };
    _proto.bringToBack = function bringToBack() {
      var layer = this.getLayer();
      if (!layer || !layer.getGeoMinZIndex) {
        return this;
      }
      var bottomZ = layer.getGeoMinZIndex();
      this.setZIndex(bottomZ - 1);
      return this;
    };
    _proto.translate = function translate(x, y) {
      if (isNil(x)) {
        return this;
      }
      var offset = new Coordinate(x, y);
      if (offset.x === 0 && offset.y === 0) {
        return this;
      }
      var coordinates = this.getCoordinates();
      this._silence = true;
      if (coordinates) {
        if (Array.isArray(coordinates)) {
          var translated = forEachCoord(coordinates, function (coord) {
            return coord.add(offset);
          });
          this.setCoordinates(translated);
        } else {
          this.setCoordinates(coordinates.add(offset));
        }
      }
      this._silence = false;
      this._fireEvent('positionchange');
      return this;
    };
    _proto.flash = function flash$$1(interval, count, cb, context) {
      return flash.call(this, interval, count, cb, context);
    };
    _proto.copy = function copy() {
      var json = this.toJSON();
      var ret = Geometry.fromJSON(json);
      ret.options['visible'] = true;
      return ret;
    };
    _proto.remove = function remove() {
      var layer = this.getLayer();
      if (!layer) {
        return this;
      }
      this._fireEvent('removestart');
      this._unbind();
      this._fireEvent('removeend');
      this._fireEvent('remove');
      return this;
    };
    _proto.toGeoJSONGeometry = function toGeoJSONGeometry() {
      var gJson = this._exportGeoJSONGeometry();
      return gJson;
    };
    _proto.toGeoJSON = function toGeoJSON(opts) {
      if (!opts) {
        opts = {};
      }
      var feature = {
        'type': 'Feature',
        'geometry': null
      };
      if (isNil(opts['geometry']) || opts['geometry']) {
        var geoJSON = this._exportGeoJSONGeometry();
        feature['geometry'] = geoJSON;
      }
      var id = this.getId();
      if (!isNil(id)) {
        feature['id'] = id;
      }
      var properties;
      if (isNil(opts['properties']) || opts['properties']) {
        properties = this._exportProperties();
      }
      feature['properties'] = properties;
      return feature;
    };
    _proto.toJSON = function toJSON(options) {
      if (!options) {
        options = {};
      }
      var json = this._toJSON(options);
      var other = this._exportGraphicOptions(options);
      extend(json, other);
      return json;
    };
    _proto.getLength = function getLength() {
      return this._computeGeodesicLength(this._getMeasurer());
    };
    _proto.getArea = function getArea() {
      return this._computeGeodesicArea(this._getMeasurer());
    };
    _proto.rotate = function rotate(angle, pivot) {
      if (!isNumber(angle)) {
        console.error("angle:" + angle + " is not number");
        return this;
      }
      if (this.type === 'GeometryCollection') {
        var geometries = this.getGeometries();
        geometries.forEach(function (g) {
          return g.rotate(angle, pivot);
        });
        return this;
      }
      if (!pivot) {
        pivot = this.getCenter();
      } else {
        pivot = new Coordinate(pivot);
      }
      this._angle = angle;
      this._pivot = pivot;
      var measurer = this._getMeasurer();
      var coordinates = this.getCoordinates();
      if (!Array.isArray(coordinates)) {
        if ((pivot.x !== coordinates.x || pivot.y !== coordinates.y) && !this.getShell) {
          var c = measurer._rotate(coordinates, pivot, angle);
          this.setCoordinates(c);
        } else {
          this.onPositionChanged();
        }
        return this;
      }
      forEachCoord(coordinates, function (c) {
        return measurer._rotate(c, pivot, angle);
      });
      this.setCoordinates(coordinates);
      return this;
    };
    _proto._rotatePrjCoordinates = function _rotatePrjCoordinates(coordinates) {
      if (!coordinates || this._angle === 0 || !this._pivot) {
        return coordinates;
      }
      var projection = this._getProjection();
      if (!projection) {
        return coordinates;
      }
      var offsetAngle = 0;
      var isArray = Array.isArray(coordinates);
      var coord = isArray ? coordinates : [coordinates];
      var rotatePrjCoordinates = [];
      var cx, cy;
      if (this.getRotateOffsetAngle) {
        offsetAngle = this.getRotateOffsetAngle();
        var center = coord[coord.length - 1];
        cx = center.x;
        cy = center.y;
      } else {
        var bbox = getDefaultBBOX();
        pointsBBOX(coord, bbox);
        var minx = bbox[0],
          miny = bbox[1],
          maxx = bbox[2],
          maxy = bbox[3];
        cx = (minx + maxx) / 2;
        cy = (miny + maxy) / 2;
      }
      for (var i = 0, len = coord.length; i < len; i++) {
        var c = coord[i];
        var x = c.x,
          y = c.y;
        var dx = x - cx,
          dy = y - cy;
        var r = Math.sqrt(dx * dx + dy * dy);
        var sAngle = getSegmentAngle(cx, cy, x, y);
        var rad = (sAngle - this._angle + offsetAngle) / 180 * Math.PI;
        var _rx = Math.cos(rad) * r,
          _ry = Math.sin(rad) * r;
        var rc = new Coordinate(cx + _rx, cy + _ry);
        rotatePrjCoordinates.push(rc);
      }
      var prjCenter = projection.project(this._pivot);
      var rx = prjCenter.x,
        ry = prjCenter.y;
      var translateX = cx - rx,
        translateY = cy - ry;
      for (var _i = 0, _len = rotatePrjCoordinates.length; _i < _len; _i++) {
        var _c = rotatePrjCoordinates[_i];
        _c.x -= translateX;
        _c.y -= translateY;
      }
      if (isArray) {
        return rotatePrjCoordinates;
      }
      return rotatePrjCoordinates[0];
    };
    _proto.isRotated = function isRotated() {
      return isNumber(this._angle) && this._pivot;
    };
    _proto._getConnectPoints = function _getConnectPoints() {
      return [this.getCenter()];
    };
    _proto._initOptions = function _initOptions(options) {
      var opts = extend({}, options);
      var symbol = opts['symbol'];
      var properties = opts['properties'];
      var id = opts['id'];
      delete opts['symbol'];
      delete opts['id'];
      delete opts['properties'];
      this.setOptions(opts);
      if (symbol) {
        this.setSymbol(symbol);
      }
      if (properties) {
        this.setProperties(properties);
      }
      if (!isNil(id)) {
        this.setId(id);
      }
    };
    _proto._bindLayer = function _bindLayer(layer) {
      if (layer === this.getLayer()) {
        return;
      }
      if (this.getLayer()) {
        throw new Error('Geometry cannot be added to two or more layers at the same time.');
      }
      this._layer = layer;
      this._clearCache();
      this._bindInfoWindow();
      this._bindMenu();
    };
    _proto._prepareSymbol = function _prepareSymbol(symbol) {
      if (Array.isArray(symbol)) {
        var cookedSymbols = [];
        for (var i = 0; i < symbol.length; i++) {
          cookedSymbols.push(convertResourceUrl(this._checkAndCopySymbol(symbol[i])));
        }
        return cookedSymbols;
      } else if (symbol) {
        symbol = this._checkAndCopySymbol(symbol);
        return convertResourceUrl(symbol);
      }
      return null;
    };
    _proto._checkAndCopySymbol = function _checkAndCopySymbol(symbol) {
      var s = {};
      for (var i in symbol) {
        if (NUMERICAL_PROPERTIES[i] && isString(symbol[i])) {
          s[i] = +symbol[i];
        } else {
          s[i] = symbol[i];
        }
      }
      return s;
    };
    _proto._getSymbol = function _getSymbol() {
      return this._symbol;
    };
    _proto._setExternSymbol = function _setExternSymbol(symbol) {
      this._eventSymbolProperties = symbol;
      if (!this._symbol) {
        delete this._textDesc;
      }
      this._externSymbol = this._prepareSymbol(symbol);
      this.onSymbolChanged();
      return this;
    };
    _proto._getInternalSymbol = function _getInternalSymbol() {
      if (this._symbol) {
        return this._symbol;
      } else if (this._externSymbol) {
        return this._externSymbol;
      } else if (this.options['symbol']) {
        return this.options['symbol'];
      }
      return null;
    };
    _proto._getPrjExtent = function _getPrjExtent() {
      var p = this._getProjection();
      this._verifyProjection();
      if (!this._extent && p) {
        this._extent = this._computePrjExtent(p);
      }
      return this._extent;
    };
    _proto._unbind = function _unbind() {
      var layer = this.getLayer();
      if (!layer) {
        return;
      }
      if (this._animPlayer) {
        this._animPlayer.finish();
      }
      this._unbindMenu();
      this._unbindInfoWindow();
      if (this.isEditing()) {
        this.endEdit();
      }
      this._removePainter();
      if (this.onRemove) {
        this.onRemove();
      }
      if (layer.onRemoveGeometry) {
        layer.onRemoveGeometry(this);
      }
      delete this._layer;
      delete this._internalId;
      delete this._extent;
    };
    _proto._getInternalId = function _getInternalId() {
      return this._internalId;
    };
    _proto._setInternalId = function _setInternalId(id) {
      this._internalId = id;
    };
    _proto._getMeasurer = function _getMeasurer() {
      if (this._getProjection()) {
        return this._getProjection();
      }
      return SpatialReference.getProjectionInstance(this.options['defaultProjection']);
    };
    _proto._getProjection = function _getProjection() {
      var map = this.getMap();
      if (map) {
        return map.getProjection();
      }
      return null;
    };
    _proto._verifyProjection = function _verifyProjection() {
      var projection = this._getProjection();
      if (this._projCode && projection && this._projCode !== projection.code) {
        this._clearProjection();
      }
      this._projCode = projection ? projection.code : this._projCode;
    };
    _proto._getExternalResources = function _getExternalResources() {
      var symbol = this._getInternalSymbol();
      return getExternalResources(symbol);
    };
    _proto._getPainter = function _getPainter() {
      if (this._painter) {
        return this._painter;
      }
      var layer = this.getLayer();
      if (!this._painter && layer) {
        if (GEOMETRY_COLLECTION_TYPES.indexOf(this.type) !== -1) {
          if (layer.constructor.getCollectionPainterClass) {
            var clazz = layer.constructor.getCollectionPainterClass();
            if (clazz) {
              this._painter = new clazz(this);
            }
          }
        } else if (layer.constructor.getPainterClass) {
          var _clazz = layer.constructor.getPainterClass();
          if (_clazz) {
            this._painter = new _clazz(this);
          }
        }
      }
      return this._painter;
    };
    _proto._getMaskPainter = function _getMaskPainter() {
      if (this._maskPainter) {
        return this._maskPainter;
      }
      this._maskPainter = this.getGeometries && this.getGeometries() ? new CollectionPainter(this, true) : new Painter(this);
      return this._maskPainter;
    };
    _proto._removePainter = function _removePainter() {
      if (this._painter) {
        this._painter.remove();
      }
      delete this._painter;
    };
    _proto._paint = function _paint(extent) {
      if (this._painter) {
        if (this._dirtyCoords) {
          delete this._dirtyCoords;
          var projection = this._getProjection();
          if (projection) {
            this._pcenter = projection.project(this._coordinates);
            this._clearCache();
          }
        }
        this._painter.paint(extent);
      }
    };
    _proto._clearCache = function _clearCache() {
      delete this._extent;
      delete this._extent2d;
      this._clearAltitudeCache();
    };
    _proto._clearProjection = function _clearProjection() {
      delete this._extent;
      delete this._extent2d;
    };
    _proto._repaint = function _repaint() {
      if (this._painter) {
        this._painter.repaint();
      }
    };
    _proto.onHide = function onHide() {
      this.closeMenu();
      this.closeInfoWindow();
    };
    _proto.onShapeChanged = function onShapeChanged() {
      this._clearCache();
      this._repaint();
      this._fireEvent('shapechange');
    };
    _proto.onPositionChanged = function onPositionChanged() {
      this._clearCache();
      this._repaint();
      this._fireEvent('positionchange');
    };
    _proto.onSymbolChanged = function onSymbolChanged() {
      if (this._painter) {
        this._painter.refreshSymbol();
      }
      var e = {};
      if (this._eventSymbolProperties) {
        e.properties = JSON.parse(JSON.stringify(this._eventSymbolProperties));
        delete this._eventSymbolProperties;
      } else {
        delete this._textDesc;
      }
      this._genSizeSymbol();
      this._fireEvent('symbolchange', e);
    };
    _proto._genSizeSymbol = function _genSizeSymbol() {
      var symbol = this._getInternalSymbol();
      if (!symbol) {
        delete this._sizeSymbol;
        return;
      }
      if (Array.isArray(symbol)) {
        this._sizeSymbol = [];
        var dynamicSize = false;
        for (var i = 0; i < symbol.length; i++) {
          var s = this._sizeSymbol[i] = this._getSizeSymbol(symbol[i]);
          if (!dynamicSize && s && s._dynamic) {
            dynamicSize = true;
          }
        }
        this._sizeSymbol._dynamic = dynamicSize;
      } else {
        this._sizeSymbol = this._getSizeSymbol(symbol);
      }
    };
    _proto._getSizeSymbol = function _getSizeSymbol(symbol) {
      var symbolSize = loadGeoSymbol({
        lineWidth: symbol['lineWidth'],
        lineDx: symbol['lineDx'],
        lineDy: symbol['lineDy']
      }, this);
      if (isFunctionDefinition(symbol['lineWidth']) || isFunctionDefinition(symbol['lineDx']) || isFunctionDefinition(symbol['lineDy'])) {
        symbolSize._dynamic = true;
      }
      return symbolSize;
    };
    _proto._getCompiledSymbol = function _getCompiledSymbol() {
      if (this._compiledSymbol) {
        return this._compiledSymbol;
      }
      this._compiledSymbol = loadGeoSymbol(this._getInternalSymbol(), this);
      return this._compiledSymbol;
    };
    _proto.onConfig = function onConfig(conf) {
      var properties;
      if (conf['properties']) {
        properties = conf['properties'];
        delete conf['properties'];
      }
      var needRepaint = false;
      for (var p in conf) {
        if (conf.hasOwnProperty(p)) {
          var prefix = p.slice(0, 5);
          if (prefix === 'arrow' || prefix === 'smoot') {
            needRepaint = true;
            break;
          }
        }
      }
      if (properties) {
        this.setProperties(properties);
        this._repaint();
      } else if (needRepaint) {
        this._repaint();
      }
    };
    _proto._setParent = function _setParent(geometry) {
      if (geometry) {
        this._parent = geometry;
      }
    };
    _proto._getParent = function _getParent() {
      return this._parent;
    };
    _proto._fireEvent = function _fireEvent(eventName, param) {
      if (this._silence) {
        return;
      }
      if (this.getLayer() && this.getLayer()._onGeometryEvent) {
        if (!param) {
          param = {};
        }
        param['type'] = eventName;
        param['target'] = this;
        this.getLayer()._onGeometryEvent(param);
      }
      this.fire(eventName, param);
    };
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options)
      };
    };
    _proto._exportGraphicOptions = function _exportGraphicOptions(options) {
      var json = {};
      if (isNil(options['options']) || options['options']) {
        json['options'] = this.config();
      }
      if (isNil(options['symbol']) || options['symbol']) {
        json['symbol'] = this.getSymbol();
      }
      if (isNil(options['infoWindow']) || options['infoWindow']) {
        if (this._infoWinOptions) {
          json['infoWindow'] = this._infoWinOptions;
        }
      }
      return json;
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var points = this.getCoordinates();
      var coordinates = Coordinate.toNumberArrays(points);
      return {
        'type': this.getType(),
        'coordinates': coordinates
      };
    };
    _proto._exportProperties = function _exportProperties() {
      var properties = null;
      var geoProperties = this.getProperties();
      if (!isNil(geoProperties)) {
        if (isObject(geoProperties)) {
          properties = extend({}, geoProperties);
        } else {
          properties = geoProperties;
        }
      }
      return properties;
    };
    _proto._hitTestTolerance = function _hitTestTolerance() {
      return 0;
    };
    _proto._getAltitude = function _getAltitude() {
      var layer = this.getLayer();
      if (!layer) {
        return 0;
      }
      var layerOpts = layer.options;
      var layerAltitude = layer.getAltitude ? layer.getAltitude() : 0;
      var enableAltitude = layerOpts['enableAltitude'];
      if (!enableAltitude) {
        return layerAltitude;
      }
      var altitudeProperty = getAltitudeProperty(layer);
      var properties = this.properties || TEMP_PROPERTIES;
      var altitude = properties[altitudeProperty];
      if (isNil(altitude)) {
        var alts = getGeometryCoordinatesAlts(this, layerAltitude, enableAltitude);
        if (!isNil(alts)) {
          return alts;
        }
        return layerAltitude;
      }
      if (Array.isArray(altitude)) {
        return altitude.map(function (alt) {
          return alt + layerAltitude;
        });
      }
      return altitude + layerAltitude;
    };
    _proto.getAltitude = function getAltitude() {
      var layer = this.getLayer();
      var altitudeProperty = getAltitudeProperty(layer);
      var properties = this.properties || TEMP_PROPERTIES;
      var altitude = properties[altitudeProperty];
      if (!isNil(altitude)) {
        return altitude;
      }
      var alts = getGeometryCoordinatesAlts(this, 0, false);
      if (!isNil(alts)) {
        return alts;
      }
      return 0;
    };
    _proto.hasAltitude = function hasAltitude() {
      var altitude = this._getAltitude();
      if (!altitude) {
        return false;
      }
      return true;
    };
    _proto.setAltitude = function setAltitude(alt) {
      if (!isNumber(alt)) {
        return this;
      }
      var layer = this.getLayer();
      var altitudeProperty = getAltitudeProperty(layer);
      var properties = this.properties || TEMP_PROPERTIES;
      var altitude = properties[altitudeProperty];
      if (!isNil(altitude)) {
        if (Array.isArray(altitude)) {
          for (var i = 0, len = altitude.length; i < len; i++) {
            altitude[i] = alt;
          }
        } else {
          properties[altitudeProperty] = alt;
        }
      }
      var coordinates = this.getCoordinates ? this.getCoordinates() : null;
      if (!coordinates) {
        return this;
      }
      setCoordinatesAlt(coordinates, alt);
      if (layer) {
        var render = layer.getRenderer();
        if (render && render.gl) {
          this.setCoordinates(coordinates);
        } else if (render) {
          this._repaint();
        }
      }
      this._clearAltitudeCache();
      return this;
    };
    _proto._genMinMaxAlt = function _genMinMaxAlt() {
      var _this2 = this;
      var altitude = this._getAltitude();
      if (Array.isArray(altitude)) {
        this._minAlt = Number.MAX_VALUE;
        this._maxAlt = Number.MIN_VALUE;
        altitude.forEach(function (alt) {
          var a = alt;
          if (a < _this2._minAlt) {
            _this2._minAlt = a;
          }
          if (a > _this2._maxAlt) {
            _this2._maxAlt = a;
          }
        });
      } else {
        this._minAlt = this._maxAlt = altitude;
      }
    };
    _proto.getMinAltitude = function getMinAltitude() {
      if (this._minAlt === undefined) {
        this._genMinMaxAlt();
      }
      if (!this._minAlt) {
        return 0;
      }
      return this._minAlt;
    };
    _proto.getMaxAltitude = function getMaxAltitude() {
      if (this._maxAlt === undefined) {
        this._genMinMaxAlt();
      }
      if (!this._maxAlt) {
        return 0;
      }
      return this._maxAlt;
    };
    _proto._clearAltitudeCache = function _clearAltitudeCache() {
      this._minAlt = undefined;
      this._maxAlt = undefined;
      return this;
    };
    return Geometry;
  }(JSONAble(Eventable(Handlerable(Class))));
  Geometry.mergeOptions(options);
  function getAltitudeProperty(layer) {
    var altitudeProperty = 'altitude';
    if (layer) {
      var layerOpts = layer.options;
      altitudeProperty = layerOpts['altitudeProperty'];
    }
    return altitudeProperty;
  }
  function getGeometryCoordinatesAlts(geometry, layerAlt, enableAltitude) {
    var coordinates = geometry.getCoordinates ? geometry.getCoordinates() : null;
    if (coordinates) {
      var tempAlts = [];
      coordinatesHasAlt(coordinates, tempAlts);
      if (tempAlts.length) {
        var alts = getCoordinatesAlts(coordinates, layerAlt, enableAltitude);
        if (geometry.getShell && Array.isArray(alts[0])) {
          return alts[0][0];
        }
        return alts;
      }
    }
    return null;
  }
  function setCoordinatesAlt(coordinates, alt) {
    if (Array.isArray(coordinates)) {
      for (var i = 0, len = coordinates.length; i < len; i++) {
        setCoordinatesAlt(coordinates[i], alt);
      }
    } else {
      coordinates.z = alt;
    }
  }
  function coordinatesHasAlt(coordinates, tempAlts) {
    if (tempAlts.length) {
      return;
    }
    if (Array.isArray(coordinates)) {
      for (var i = 0, len = coordinates.length; i < len; i++) {
        coordinatesHasAlt(coordinates[i], tempAlts);
      }
    } else if (isNumber(coordinates.z)) {
      tempAlts.push(coordinates.z);
    }
  }
  function getCoordinatesAlts(coordinates, layerAlt, enableAltitude) {
    if (Array.isArray(coordinates)) {
      var alts = [];
      for (var i = 0, len = coordinates.length; i < len; i++) {
        alts.push(getCoordinatesAlts(coordinates[i], layerAlt, enableAltitude));
      }
      return alts;
    }
    if (isNumber(coordinates.z)) {
      return enableAltitude ? layerAlt + coordinates.z : coordinates.z;
    } else if (enableAltitude) {
      return layerAlt;
    } else {
      return 0;
    }
  }
  function getSegmentAngle(cx, cy, x, y) {
    if (cx === x) {
      if (y > cy) {
        return -90;
      }
      return 90;
    }
    x -= cx;
    y -= cy;
    y = -y;
    var rad = Math.atan2(y, x);
    return rad / Math.PI * 180;
  }

  var options$1 = {
    'attribution': null,
    'minZoom': null,
    'maxZoom': null,
    'visible': true,
    'opacity': 1,
    'globalCompositeOperation': null,
    'renderer': 'canvas',
    'debugOutline': '#0f0',
    'cssFilter': null,
    'forceRenderOnMoving': false,
    'forceRenderOnZooming': false,
    'forceRenderOnRotating': false,
    'collision': false,
    'collisionScope': 'layer',
    'hitDetect': function () {
      return !Browser$1.mobile;
    }()
  };
  var Layer = function (_JSONAble) {
    _inheritsLoose(Layer, _JSONAble);
    function Layer(id, options) {
      var _this;
      var canvas;
      if (options) {
        canvas = options.canvas;
        delete options.canvas;
      }
      _this = _JSONAble.call(this, options) || this;
      _this._canvas = canvas;
      _this.setId(id);
      if (options) {
        _this.setZIndex(options.zIndex);
        if (options.mask) {
          _this.setMask(Geometry.fromJSON(options.mask));
        }
      }
      _this.proxyOptions();
      return _this;
    }
    var _proto = Layer.prototype;
    _proto.load = function load() {
      if (!this.getMap()) {
        return this;
      }
      if (this.onLoad()) {
        this._initRenderer();
        var zIndex = this.getZIndex();
        if (!isNil(zIndex)) {
          this._renderer.setZIndex(zIndex);
          if (!this.isCanvasRender()) {
            this._renderer.render();
          }
        }
        this.onLoadEnd();
      }
      return this;
    };
    _proto.getId = function getId() {
      return this._id;
    };
    _proto.setId = function setId(id) {
      var old = this._id;
      if (!isNil(id)) {
        id = id + '';
      }
      this._id = id;
      this.fire('idchange', {
        'old': old,
        'new': id
      });
      return this;
    };
    _proto.addTo = function addTo(map) {
      map.addLayer(this);
      return this;
    };
    _proto.setZIndex = function setZIndex(zIndex) {
      this._zIndex = zIndex;
      if (isNil(zIndex)) {
        delete this.options['zIndex'];
      } else {
        this.options.zIndex = zIndex;
      }
      if (this.map) {
        this.map._sortLayersByZIndex();
      }
      if (this._renderer) {
        this._renderer.setZIndex(zIndex);
      }
      this.fire('setzindex', {
        zIndex: zIndex
      });
      return this;
    };
    _proto.getZIndex = function getZIndex() {
      return this._zIndex || 0;
    };
    _proto.getMinZoom = function getMinZoom() {
      var map = this.getMap();
      var minZoom = this.options['minZoom'];
      return map ? Math.max(map.getMinZoom(), minZoom || 0) : minZoom;
    };
    _proto.getMaxZoom = function getMaxZoom() {
      var map = this.getMap();
      var maxZoom = this.options['maxZoom'];
      return map ? Math.min(map.getMaxZoom(), isNil(maxZoom) ? Infinity : maxZoom) : maxZoom;
    };
    _proto.getOpacity = function getOpacity() {
      return this.options['opacity'];
    };
    _proto.setOpacity = function setOpacity(op) {
      this.config('opacity', op);
      this.fire('setopacity', {
        opacity: op
      });
      return this;
    };
    _proto.isCanvasRender = function isCanvasRender() {
      var renderer = this._getRenderer();
      return renderer && renderer instanceof CanvasRenderer;
    };
    _proto.getMap = function getMap() {
      if (this.map) {
        return this.map;
      }
      return null;
    };
    _proto.getProjection = function getProjection() {
      var map = this.getMap();
      return map ? map.getProjection() : null;
    };
    _proto.bringToFront = function bringToFront() {
      var layers = this._getLayerList();
      if (!layers.length) {
        return this;
      }
      var topLayer = layers[layers.length - 1];
      if (layers.length === 1 || topLayer === this) {
        return this;
      }
      var max = topLayer.getZIndex();
      this.setZIndex(max + 1);
      return this;
    };
    _proto.bringToBack = function bringToBack() {
      var layers = this._getLayerList();
      if (!layers.length) {
        return this;
      }
      var bottomLayer = layers[0];
      if (layers.length === 1 || bottomLayer === this) {
        return this;
      }
      var min = bottomLayer.getZIndex();
      this.setZIndex(min - 1);
      return this;
    };
    _proto.show = function show() {
      var _this2 = this;
      if (!this.options['visible']) {
        this.options['visible'] = true;
        var renderer = this.getRenderer();
        if (renderer) {
          renderer.show();
        }
        var map = this.getMap();
        if (renderer && map) {
          map.once('renderend', function () {
            _this2.fire('show');
          });
        } else {
          this.fire('show');
        }
      }
      return this;
    };
    _proto.hide = function hide() {
      var _this3 = this;
      if (this.options['visible']) {
        this.options['visible'] = false;
        var renderer = this.getRenderer();
        if (renderer) {
          renderer.hide();
        }
        var map = this.getMap();
        if (renderer && map) {
          map.once('renderend', function () {
            _this3.fire('hide');
          });
        } else {
          this.fire('hide');
        }
      }
      return this;
    };
    _proto.isVisible = function isVisible() {
      if (isNumber(this.options['opacity']) && this.options['opacity'] <= 0) {
        return false;
      }
      var map = this.getMap();
      if (map) {
        var zoom = map.getZoom();
        if (!isNil(this.options['maxZoom']) && this.options['maxZoom'] < zoom || !isNil(this.options['minZoom']) && this.options['minZoom'] > zoom) {
          return false;
        }
      }
      if (isNil(this.options['visible'])) {
        this.options['visible'] = true;
      }
      return this.options['visible'];
    };
    _proto.remove = function remove() {
      if (this.map) {
        var renderer = this.map.getRenderer();
        this.map.removeLayer(this);
        if (renderer) {
          renderer.setToRedraw();
        }
      } else {
        this.fire('remove');
      }
      return this;
    };
    _proto.getMask = function getMask() {
      return this._mask;
    };
    _proto.setMask = function setMask(mask) {
      if (!(mask.type === 'Point' && mask._isVectorMarker() || mask.type === 'Polygon' || mask.type === 'MultiPolygon')) {
        throw new Error('Mask for a layer must be a marker with vector marker symbol or a Polygon(MultiPolygon).');
      }
      mask._bindLayer(this);
      if (mask.type === 'Point') {
        mask.updateSymbol({
          'markerLineColor': 'rgba(0, 0, 0, 0)',
          'markerFillOpacity': 0
        });
      } else {
        mask.setSymbol({
          'lineColor': 'rgba(0, 0, 0, 0)',
          'polygonOpacity': 0
        });
      }
      this._mask = mask;
      this.options.mask = mask.toJSON();
      if (!this.getMap() || this.getMap().isZooming()) {
        return this;
      }
      var renderer = this._getRenderer();
      if (renderer && renderer.setToRedraw) {
        this._getRenderer().setToRedraw();
      }
      return this;
    };
    _proto.removeMask = function removeMask() {
      delete this._mask;
      delete this.options.mask;
      if (!this.getMap() || this.getMap().isZooming()) {
        return this;
      }
      var renderer = this._getRenderer();
      if (renderer && renderer.setToRedraw) {
        this._getRenderer().setToRedraw();
      }
      return this;
    };
    _proto.onLoad = function onLoad() {
      return true;
    };
    _proto.onLoadEnd = function onLoadEnd() {};
    _proto.isLoaded = function isLoaded() {
      return !!this._loaded;
    };
    _proto.getCollisionIndex = function getCollisionIndex() {
      if (this.options['collisionScope'] === 'layer') {
        if (!this._collisionIndex) {
          this._collisionIndex = new CollisionIndex();
        }
        return this._collisionIndex;
      }
      var map = this.getMap();
      if (!map) {
        return null;
      }
      return map.getCollisionIndex();
    };
    _proto.clearCollisionIndex = function clearCollisionIndex() {
      if (this.options['collisionScope'] === 'layer' && this._collisionIndex) {
        this._collisionIndex.clear();
      }
      return this;
    };
    _proto.getRenderer = function getRenderer() {
      return this._getRenderer();
    };
    _proto.onConfig = function onConfig(conf) {
      var needUpdate = conf && Object.keys && Object.keys(conf).length > 0;
      if (needUpdate && isNil(conf['animation'])) {
        if (this._optionsHook && isFunction(this._optionsHook)) {
          this._optionsHook(conf);
        }
        if (this._silentConfig) {
          return;
        }
        var renderer = this.getRenderer();
        if (renderer && renderer.setToRedraw) {
          renderer.setToRedraw();
        }
      }
    };
    _proto.onAdd = function onAdd() {};
    _proto.onRendererCreate = function onRendererCreate() {};
    _proto.onCanvasCreate = function onCanvasCreate() {};
    _proto.onRemove = function onRemove() {};
    _proto._bindMap = function _bindMap(map, zIndex) {
      if (!map) {
        return;
      }
      this.map = map;
      if (!isNil(zIndex)) {
        this.setZIndex(zIndex);
      }
      this._switchEvents('on', this);
      this.onAdd();
      this.fire('add');
    };
    _proto._initRenderer = function _initRenderer() {
      var renderer = this.options['renderer'];
      if (!this.constructor.getRendererClass) {
        return;
      }
      var clazz = this.constructor.getRendererClass(renderer);
      if (!clazz) {
        throw new Error('Invalid renderer for Layer(' + this.getId() + '):' + renderer);
      }
      this._renderer = new clazz(this);
      this._renderer.layer = this;
      this._renderer.setZIndex(this.getZIndex());
      this._switchEvents('on', this._renderer);
      if (this._renderer.onAdd) {
        this._renderer.onAdd();
      }
      this.onRendererCreate();
      this.fire('renderercreate', {
        'renderer': this._renderer
      });
    };
    _proto._doRemove = function _doRemove() {
      this._loaded = false;
      this._switchEvents('off', this);
      this.onRemove();
      if (this._renderer) {
        this._switchEvents('off', this._renderer);
        this._renderer.remove();
        delete this._renderer;
      }
      delete this.map;
      delete this._collisionIndex;
    };
    _proto._switchEvents = function _switchEvents(to, emitter) {
      if (emitter && emitter.getEvents && this.getMap()) {
        this.getMap()[to](emitter.getEvents(), emitter);
      }
    };
    _proto._getRenderer = function _getRenderer() {
      return this._renderer;
    };
    _proto._getLayerList = function _getLayerList() {
      if (!this.map) {
        return [];
      }
      return this.map._layers;
    };
    _proto._getMask2DExtent = function _getMask2DExtent() {
      if (!this._mask || !this.getMap()) {
        return null;
      }
      var painter = this._mask._getMaskPainter();
      if (!painter) {
        return null;
      }
      return painter.get2DExtent();
    };
    return Layer;
  }(JSONAble(Eventable(Renderable(Class))));
  Layer.mergeOptions(options$1);
  var fire = Layer.prototype.fire;
  Layer.prototype.fire = function (eventType, param) {
    if (eventType === 'layerload') {
      this._loaded = true;
    }
    if (this.map) {
      if (!param) {
        param = {};
      }
      param['type'] = eventType;
      param['target'] = this;
      this.map._onLayerEvent(param);
    }
    fire.apply(this, arguments);
    if (['show', 'hide'].indexOf(eventType) > -1) {
      this.fire('visiblechange', Object.assign({}, param, {
        visible: this.options.visible
      }));
    }
    return this;
  };

  var TEMP_COORD = new Coordinate(0, 0);
  var TEMP_POINT = new Point(0, 0);
  var REDRAW_OPTIONS_PROPERTIES = ['centerCross', 'fog', 'fogColor', 'debugSky'];
  var options$2 = {
    'maxVisualPitch': 70,
    'maxPitch': 80,
    'centerCross': false,
    'zoomInCenter': false,
    'zoomOrigin': null,
    'zoomAnimation': function () {
      return !IS_NODE;
    }(),
    'zoomAnimationDuration': 330,
    'panAnimation': function () {
      return !IS_NODE;
    }(),
    'panAnimationDuration': 600,
    'rotateAnimation': function () {
      return !IS_NODE;
    }(),
    'zoomable': true,
    'enableInfoWindow': true,
    'hitDetect': function () {
      return !Browser$1.mobile;
    }(),
    'hitDetectLimit': 5,
    'fpsOnInteracting': 25,
    'fps': 30,
    'layerCanvasLimitOnInteracting': -1,
    'maxZoom': null,
    'minZoom': null,
    'maxExtent': null,
    'fixCenterOnResize': true,
    'checkSize': true,
    'checkSizeInterval': 1000,
    'renderer': 'canvas',
    'cascadePitches': [10, 60],
    'renderable': true,
    'clickTimeThreshold': 280,
    'stopRenderOnOffscreen': true,
    'preventWheelScroll': true,
    'preventTouch': true,
    'supportPluginEvent': true,
    'switchDragButton': false,
    'mousemoveThrottleTime': MOUSEMOVE_THROTTLE_TIME
  };
  var Map$1 = function (_Handlerable) {
    _inheritsLoose(Map, _Handlerable);
    function Map(container, options) {
      var _this;
      if (!options) {
        throw new Error('Invalid options when creating map.');
      }
      if (!options['center']) {
        throw new Error('Invalid center when creating map.');
      }
      var opts = extend({}, options);
      var zoom = opts['zoom'];
      delete opts['zoom'];
      var center = new Coordinate(opts['center']);
      delete opts['center'];
      var baseLayer = opts['baseLayer'];
      delete opts['baseLayer'];
      var layers = opts['layers'];
      delete opts['layers'];
      _this = _Handlerable.call(this, opts) || this;
      _this.VERSION = Map.VERSION;
      Object.defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), 'id', {
        value: UID(),
        writable: false
      });
      _this._loaded = false;
      _this._initContainer(container);
      _this._panels = {};
      _this._baseLayer = null;
      _this._layers = [];
      _this._zoomLevel = zoom;
      _this._center = center;
      _this.setSpatialReference(opts['spatialReference'] || opts['view']);
      _this._mapViewPoint = new Point(0, 0);
      _this._initRenderer();
      _this._updateMapSize(_this._getContainerDomSize());
      if (baseLayer) {
        _this.setBaseLayer(baseLayer);
      }
      if (layers) {
        _this.addLayer(layers);
      }
      _this.setMaxExtent(opts['maxExtent']);
      _this._Load();
      _this.proxyOptions();
      _this.isMap = true;
      return _this;
    }
    Map.addOnLoadHook = function addOnLoadHook(fn) {
      var args = Array.prototype.slice.call(arguments, 1);
      var onload = typeof fn === 'function' ? fn : function () {
        this[fn].apply(this, args);
      };
      this.prototype._onLoadHooks = this.prototype._onLoadHooks || [];
      this.prototype._onLoadHooks.push(onload);
      return this;
    };
    var _proto = Map.prototype;
    _proto.isLoaded = function isLoaded() {
      return !!this._loaded;
    };
    _proto.getContainer = function getContainer() {
      return this._containerDOM;
    };
    _proto.getSpatialReference = function getSpatialReference() {
      return this._spatialReference;
    };
    _proto.setSpatialReference = function setSpatialReference(ref) {
      var oldRef = this.options['spatialReference'];
      if (this._loaded && SpatialReference.equals(oldRef, ref)) {
        return this;
      }
      this._updateSpatialReference(ref, oldRef);
      return this;
    };
    _proto._updateSpatialReference = function _updateSpatialReference(ref, oldRef) {
      if (isString(ref)) {
        ref = SpatialReference.getPreset(ref);
      }
      ref = extend({}, ref);
      this._center = this.getCenter();
      this.options['spatialReference'] = ref;
      this._spatialReference = new SpatialReference(ref);
      var projection = this._spatialReference.getProjection();
      if (this.options['spatialReference'] && isFunction(this.options['spatialReference']['projection'])) {
        this.options['spatialReference']['projection'] = projection['code'];
      }
      this._resetMapStatus();
      if (PROJ9807.is(projection.code)) {
        this._originLng = projection.centralMeridian;
        this._altitudeOriginDirty = true;
      }
      this._fireEvent('spatialreferencechange', {
        'old': oldRef,
        'new': extend({}, this.options['spatialReference'])
      });
      return this;
    };
    _proto.onConfig = function onConfig(conf) {
      var ref = conf['spatialReference'] || conf['view'];
      if (!isNil(ref)) {
        this._updateSpatialReference(ref, null);
      }
      var needUpdate = false;
      for (var i = 0, len = REDRAW_OPTIONS_PROPERTIES.length; i < len; i++) {
        var key = REDRAW_OPTIONS_PROPERTIES[i];
        if (!isNil(conf[key])) {
          needUpdate = true;
          break;
        }
      }
      if (!needUpdate) {
        return this;
      }
      var renderer = this.getRenderer();
      if (renderer) {
        renderer.setToRedraw();
      }
      return this;
    };
    _proto.getProjection = function getProjection() {
      if (!this._spatialReference) {
        return null;
      }
      return this._spatialReference.getProjection();
    };
    _proto.getFullExtent = function getFullExtent() {
      if (!this._spatialReference) {
        return null;
      }
      return this._spatialReference.getFullExtent();
    };
    _proto.setCursor = function setCursor(cursor) {
      delete this._cursor;
      this._trySetCursor(cursor);
      this._cursor = cursor;
      return this;
    };
    _proto.resetCursor = function resetCursor() {
      return this.setCursor(null);
    };
    _proto.getCenter = function getCenter() {
      if (!this._loaded || !this._prjCenter) {
        return this._center;
      }
      var projection = this.getProjection();
      var center = projection.unproject(this._prjCenter);
      center.x = Math.round(center.x * 1E8) / 1E8;
      center.y = Math.round(center.y * 1E8) / 1E8;
      if (this.centerAltitude) {
        center.z = this.centerAltitude;
      }
      return center;
    };
    _proto.setCenter = function setCenter(center, padding) {
      if (!center) {
        return this;
      }
      center = new Coordinate(center);
      if (padding) {
        center = this._getCenterByPadding(center, this.getZoom(), padding);
      }
      var projection = this.getProjection();
      var pcenter = projection.project(center);
      if (!this._verifyExtent(pcenter)) {
        return this;
      }
      if (!this._loaded) {
        this._center = center;
        return this;
      }
      this.onMoveStart();
      this._setPrjCenter(pcenter);
      this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
      return this;
    };
    _proto.getSize = function getSize() {
      if (isNil(this.width) || isNil(this.height)) {
        return this._getContainerDomSize();
      }
      return new Size(this.width, this.height);
    };
    _proto.getContainerExtent = function getContainerExtent() {
      var visualHeight = this.height;
      var pitch = this.getPitch(),
        maxVisualPitch = this.options['maxVisualPitch'];
      if (maxVisualPitch && pitch > maxVisualPitch) {
        visualHeight = this._getVisualHeight(maxVisualPitch);
      }
      return new PointExtent(0, this.height - visualHeight, this.width, this.height);
    };
    _proto._getVisualHeight = function _getVisualHeight(visualPitch) {
      visualPitch = visualPitch || 1E-2;
      var pitch = (90 - this.getPitch()) * Math.PI / 180;
      var fov = this.getFov() * Math.PI / 180;
      visualPitch *= Math.PI / 180;
      var cameraToCenter = this.cameraCenterDistance / this.getGLScale();
      var tanB = Math.tan(fov / 2);
      var tanP = Math.tan(visualPitch);
      var visualDistance = cameraToCenter * tanB / (1 / tanP - tanB) / Math.sin(visualPitch);
      var x = cameraToCenter * (Math.sin(pitch) * visualDistance / (cameraToCenter + Math.cos(pitch) * visualDistance));
      return this.height / 2 + x;
    };
    _proto.getExtent = function getExtent() {
      return this._pointToExtent(this._get2DExtent());
    };
    _proto.getProjExtent = function getProjExtent() {
      var extent2D = this._get2DExtent();
      return new Extent(this._pointToPrj(extent2D.getMin()), this._pointToPrj(extent2D.getMax()));
    };
    _proto.getPrjExtent = function getPrjExtent() {
      return this.getProjExtent();
    };
    _proto.getMaxExtent = function getMaxExtent() {
      if (!this.options['maxExtent']) {
        return null;
      }
      return new Extent(this.options['maxExtent'], this.getProjection());
    };
    _proto.setMaxExtent = function setMaxExtent(extent) {
      if (extent) {
        var maxExt = new Extent(extent, this.getProjection());
        this.options['maxExtent'] = maxExt;
        var projection = this.getProjection();
        this._prjMaxExtent = maxExt.convertTo(function (c) {
          return projection.project(c);
        });
        if (!this._verifyExtent(this._getPrjCenter())) {
          if (this._loaded) {
            this._panTo(this._prjMaxExtent.getCenter());
          } else {
            this._center = projection.unproject(this._prjMaxExtent.getCenter());
          }
        }
      } else {
        delete this.options['maxExtent'];
        delete this._prjMaxExtent;
      }
      return this;
    };
    _proto.getZoom = function getZoom() {
      return this._zoomLevel;
    };
    _proto.getZoomForScale = function getZoomForScale(scale, fromZoom, isFraction) {
      var zoom = this.getZoom();
      if (isNil(fromZoom)) {
        fromZoom = zoom;
      }
      if (scale === 1 && fromZoom === zoom) {
        return zoom;
      }
      var res = this._getResolution(fromZoom),
        targetRes = res / scale;
      var scaleZoom = this.getZoomFromRes(targetRes);
      if (isFraction) {
        return scaleZoom;
      } else {
        var delta = 1E-6;
        return this.getSpatialReference().getZoomDirection() < 0 ? Math.ceil(scaleZoom - delta) : Math.floor(scaleZoom + delta);
      }
    };
    _proto.getZoomFromRes = function getZoomFromRes(res) {
      var resolutions = this._getResolutions(),
        minRes = this._getResolution(this.getMinZoom()),
        maxRes = this._getResolution(this.getMaxZoom());
      if (minRes <= maxRes) {
        if (res <= minRes) {
          return this.getMinZoom();
        } else if (res >= maxRes) {
          return this.getMaxZoom();
        }
      } else if (res >= minRes) {
        return this.getMinZoom();
      } else if (res <= maxRes) {
        return this.getMaxZoom();
      }
      var l = resolutions.length;
      for (var i = 0; i < l - 1; i++) {
        if (!resolutions[i]) {
          continue;
        }
        var gap = resolutions[i + 1] - resolutions[i];
        var test = res - resolutions[i];
        if (sign(gap) === sign(test) && Math.abs(gap) >= Math.abs(test)) {
          return i + test / gap;
        }
      }
      return l - 1;
    };
    _proto.setZoom = function setZoom(zoom, options) {
      if (options === void 0) {
        options = {
          'animation': true
        };
      }
      if (isNaN(zoom) || isNil(zoom)) {
        return this;
      }
      zoom = +zoom;
      if (this._loaded && this.options['zoomAnimation'] && options['animation']) {
        this._zoomAnimation(zoom);
      } else {
        this._zoom(zoom);
      }
      return this;
    };
    _proto.getMaxZoom = function getMaxZoom() {
      if (!isNil(this.options['maxZoom'])) {
        return this.options['maxZoom'];
      }
      return this.getMaxNativeZoom();
    };
    _proto.setMaxZoom = function setMaxZoom(maxZoom) {
      var viewMaxZoom = this.getMaxNativeZoom();
      if (maxZoom > viewMaxZoom) {
        maxZoom = viewMaxZoom;
      }
      if (maxZoom !== null && maxZoom < this._zoomLevel) {
        this.setZoom(maxZoom);
        maxZoom = +maxZoom;
      }
      this.options['maxZoom'] = maxZoom;
      return this;
    };
    _proto.getMinZoom = function getMinZoom() {
      if (!isNil(this.options['minZoom'])) {
        return this.options['minZoom'];
      }
      return this._spatialReference.getMinZoom();
    };
    _proto.setMinZoom = function setMinZoom(minZoom) {
      if (minZoom !== null) {
        minZoom = +minZoom;
        var viewMinZoom = this._spatialReference.getMinZoom();
        if (minZoom < viewMinZoom) {
          minZoom = viewMinZoom;
        }
        if (minZoom > this._zoomLevel) {
          this.setZoom(minZoom);
        }
      }
      this.options['minZoom'] = minZoom;
      return this;
    };
    _proto.getMaxNativeZoom = function getMaxNativeZoom() {
      var ref = this.getSpatialReference();
      if (!ref) {
        return null;
      }
      return ref.getMaxZoom();
    };
    _proto.getGLRes = function getGLRes() {
      if (this._glRes) {
        return this._glRes;
      }
      var fullExtent = this.getSpatialReference().getFullExtent();
      this._glRes = (fullExtent.right - fullExtent.left) / Math.pow(2, 19);
      return this._glRes;
    };
    _proto.getGLScale = function getGLScale(zoom) {
      if (isNil(zoom)) {
        zoom = this.getZoom();
      }
      return this._getResolution(zoom) / this.getGLRes();
    };
    _proto.zoomIn = function zoomIn() {
      return this.setZoom(this.getZoom() + 1);
    };
    _proto.zoomOut = function zoomOut() {
      return this.setZoom(this.getZoom() - 1);
    };
    _proto.isZooming = function isZooming() {
      return !!this._zooming;
    };
    _proto.isInteracting = function isInteracting() {
      return this.isZooming() || this.isMoving() || this.isRotating();
    };
    _proto.setCenterAndZoom = function setCenterAndZoom(center, zoom) {
      if (!isNil(zoom) && this._zoomLevel !== zoom) {
        this.setCenter(center);
        this.setZoom(zoom, {
          animation: false
        });
      } else {
        this.setCenter(center);
      }
      return this;
    };
    _proto._getPaddingSize = function _getPaddingSize(options) {
      if (options === void 0) {
        options = {};
      }
      if (options['paddingLeft'] || options['paddingTop'] || options['paddingRight'] || options['paddingBottom']) {
        return {
          width: (options['paddingLeft'] || 0) + (options['paddingRight'] || 0),
          height: (options['paddingTop'] || 0) + (options['paddingBottom'] || 0)
        };
      }
      return null;
    };
    _proto.getFitZoom = function getFitZoom(extent, isFraction, padding) {
      var _this2 = this;
      if (!extent || !(extent instanceof Extent)) {
        return this._zoomLevel;
      }
      if (extent['xmin'] === extent['xmax'] && extent['ymin'] === extent['ymax']) {
        return this.getMaxZoom();
      }
      var size = this.getSize();
      var paddingSize = this._getPaddingSize(padding);
      if (paddingSize) {
        size = {
          width: size.width - (paddingSize.width || 0),
          height: size.height - (paddingSize.height || 0)
        };
      }
      var containerExtent = extent.convertTo(function (p) {
        return _this2.coordToPoint(p);
      });
      var w = containerExtent.getWidth(),
        h = containerExtent.getHeight();
      var scaleX = size['width'] / w,
        scaleY = size['height'] / h;
      var scale = this.getSpatialReference().getZoomDirection() < 0 ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
      var zoom = this.getZoomForScale(scale, null, isFraction);
      return zoom;
    };
    _proto.getView = function getView() {
      return {
        'center': this.getCenter().toArray(),
        'zoom': this.getZoom(),
        'pitch': this.getPitch(),
        'bearing': this.getBearing()
      };
    };
    _proto.setView = function setView(view) {
      if (!view) {
        return this;
      }
      if (view['center']) {
        this.setCenter(view['center']);
      }
      if (view['zoom'] !== null && !isNaN(+view['zoom'])) {
        this.setZoom(+view['zoom'], {
          'animation': false
        });
      }
      if (view['pitch'] !== null && !isNaN(+view['pitch'])) {
        this.setPitch(+view['pitch']);
      }
      if (view['pitch'] !== null && !isNaN(+view['bearing'])) {
        this.setBearing(+view['bearing']);
      }
      return this;
    };
    _proto.getResolution = function getResolution(zoom) {
      return this._getResolution(zoom);
    };
    _proto.getScale = function getScale(zoom) {
      var z = isNil(zoom) ? this.getZoom() : zoom;
      var max = this._getResolution(this.getMaxNativeZoom()),
        res = this._getResolution(z);
      return res / max;
    };
    _proto._getCenterByPadding = function _getCenterByPadding(center, zoom, padding) {
      if (padding === void 0) {
        padding = {};
      }
      var point = this.coordinateToPoint(center, zoom);
      var _padding = padding,
        _padding$paddingLeft = _padding.paddingLeft,
        paddingLeft = _padding$paddingLeft === void 0 ? 0 : _padding$paddingLeft,
        _padding$paddingRight = _padding.paddingRight,
        paddingRight = _padding$paddingRight === void 0 ? 0 : _padding$paddingRight,
        _padding$paddingTop = _padding.paddingTop,
        paddingTop = _padding$paddingTop === void 0 ? 0 : _padding$paddingTop,
        _padding$paddingBotto = _padding.paddingBottom,
        paddingBottom = _padding$paddingBotto === void 0 ? 0 : _padding$paddingBotto;
      var pX = 0;
      var pY = 0;
      if (paddingLeft || paddingRight) {
        pX = (paddingRight - paddingLeft) / 2;
      }
      if (paddingTop || paddingBottom) {
        pY = (paddingTop - paddingBottom) / 2;
      }
      var newPoint = new Point({
        x: point.x + pX,
        y: point.y + pY
      });
      return this.pointToCoordinate(newPoint, zoom);
    };
    _proto.fitExtent = function fitExtent(extent, zoomOffset, options, step) {
      if (options === void 0) {
        options = {};
      }
      if (!extent) {
        return this;
      }
      extent = new Extent(extent, this.getProjection());
      var zoom = this.getFitZoom(extent, options.isFraction || false, options) + (zoomOffset || 0);
      var center = extent.getCenter();
      if (this._getPaddingSize(options)) {
        center = this._getCenterByPadding(center, zoom, options);
      }
      if (typeof options['animation'] === 'undefined' || options['animation']) return this._animateTo({
        center: center,
        zoom: zoom
      }, {
        'duration': options['duration'] || this.options['zoomAnimationDuration'],
        'easing': options['easing'] || 'out'
      }, step);else return this.setCenterAndZoom(center, zoom);
    };
    _proto.getBaseLayer = function getBaseLayer() {
      return this._baseLayer;
    };
    _proto.setBaseLayer = function setBaseLayer(baseLayer) {
      var isChange = false;
      if (this._baseLayer) {
        isChange = true;
        this._fireEvent('baselayerchangestart');
        this._baseLayer.remove();
      }
      if (!baseLayer) {
        delete this._baseLayer;
        this._fireEvent('baselayerchangeend');
        this._fireEvent('setbaselayer');
        return this;
      }
      this._baseLayer = baseLayer;
      baseLayer._bindMap(this, -1);
      function onbaseLayerload() {
        this._fireEvent('baselayerload');
        if (isChange) {
          isChange = false;
          this._fireEvent('baselayerchangeend');
        }
      }
      this._baseLayer.on('layerload', onbaseLayerload, this);
      if (this._loaded) {
        this._baseLayer.load();
      }
      this._fireEvent('setbaselayer');
      return this;
    };
    _proto.removeBaseLayer = function removeBaseLayer() {
      if (this._baseLayer) {
        this._baseLayer.remove();
        delete this._baseLayer;
        this._fireEvent('baselayerremove');
      }
      return this;
    };
    _proto.getLayers = function getLayers(filter) {
      return this._getLayers(function (layer) {
        if (layer === this._baseLayer || layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
          return false;
        }
        if (filter) {
          return filter(layer);
        }
        return true;
      });
    };
    _proto.getLayer = function getLayer(id) {
      if (!id) {
        return null;
      }
      var layer = this._layerCache ? this._layerCache[id] : null;
      if (layer) {
        return layer;
      }
      var baseLayer = this.getBaseLayer();
      if (baseLayer && baseLayer.getId() === id) {
        return baseLayer;
      }
      return null;
    };
    _proto.addLayer = function addLayer(layers) {
      if (!layers) {
        return this;
      }
      if (!Array.isArray(layers)) {
        layers = Array.prototype.slice.call(arguments, 0);
        return this.addLayer(layers);
      }
      if (!this._layerCache) {
        this._layerCache = {};
      }
      var mapLayers = this._layers;
      for (var i = 0, len = layers.length; i < len; i++) {
        var layer = layers[i];
        var id = layer.getId();
        if (isNil(id)) {
          throw new Error('Invalid id for the layer: ' + id);
        }
        if (layer.getMap() === this) {
          continue;
        }
        if (this._layerCache[id]) {
          throw new Error('Duplicate layer id in the map: ' + id);
        }
        this._layerCache[id] = layer;
        layer._bindMap(this);
        mapLayers.push(layer);
        if (this._loaded) {
          layer.load();
        }
      }
      this._sortLayersByZIndex();
      this._fireEvent('addlayer', {
        'layers': layers
      });
      return this;
    };
    _proto.removeLayer = function removeLayer(layers) {
      if (!layers) {
        return this;
      }
      if (!Array.isArray(layers)) {
        return this.removeLayer([layers]);
      }
      var removed = [];
      for (var i = 0, len = layers.length; i < len; i++) {
        var layer = layers[i];
        if (!(layer instanceof Layer)) {
          layer = this.getLayer(layer);
        }
        if (!layer) {
          continue;
        }
        var map = layer.getMap();
        if (!map || map !== this) {
          continue;
        }
        removed.push(layer);
        this._removeLayer(layer, this._layers);
        if (this._loaded) {
          layer._doRemove();
        }
        var id = layer.getId();
        if (this._layerCache) {
          delete this._layerCache[id];
        }
      }
      if (removed.length > 0) {
        var renderer = this.getRenderer();
        if (renderer) {
          renderer.setLayerCanvasUpdated();
        }
        this.once('frameend', function () {
          removed.forEach(function (layer) {
            layer.fire('remove');
          });
        });
      }
      this._fireEvent('removelayer', {
        'layers': layers
      });
      return this;
    };
    _proto.sortLayers = function sortLayers(layers) {
      if (!layers || !Array.isArray(layers)) {
        return this;
      }
      var layersToOrder = [];
      var minZ = Number.MAX_VALUE;
      for (var i = 0, l = layers.length; i < l; i++) {
        var layer = layers[i];
        if (isString(layers[i])) {
          layer = this.getLayer(layer);
        }
        if (!(layer instanceof Layer) || !layer.getMap() || layer.getMap() !== this) {
          throw new Error('It must be a layer added to this map to order.');
        }
        if (layer.getZIndex() < minZ) {
          minZ = layer.getZIndex();
        }
        layersToOrder.push(layer);
      }
      for (var _i = 0, _l = layersToOrder.length; _i < _l; _i++) {
        layersToOrder[_i].setZIndex(minZ + _i);
      }
      return this;
    };
    _proto.toDataURL = function toDataURL(options) {
      if (!options) {
        options = {};
      }
      var mimeType = options['mimeType'];
      if (!mimeType) {
        mimeType = 'image/png';
      }
      var save = options['save'];
      var renderer = this._getRenderer();
      if (renderer && renderer.toDataURL) {
        var file = options['fileName'];
        if (!file) {
          file = 'export';
        }
        var dataURL = renderer.toDataURL(mimeType, options.quality || 0.92);
        if (save && dataURL) {
          var imgURL;
          if (typeof Blob !== 'undefined' && typeof atob !== 'undefined') {
            var blob = b64toBlob(dataURL.replace(/^data:image\/(png|jpeg|jpg|webp);base64,/, ''), mimeType);
            imgURL = URL.createObjectURL(blob);
          } else {
            imgURL = dataURL;
          }
          var dlLink = document.createElement('a');
          dlLink.download = file;
          dlLink.href = imgURL;
          document.body.appendChild(dlLink);
          dlLink.click();
          document.body.removeChild(dlLink);
        }
        return dataURL;
      }
      return null;
    };
    _proto.coordToPoint = function coordToPoint(coordinate, zoom, out) {
      return this.coordinateToPoint(coordinate, zoom, out);
    };
    _proto.coordToPointAtRes = function coordToPointAtRes(coordinate, res, out) {
      return this.coordinateToPointAtRes(coordinate, res, out);
    };
    _proto.pointToCoord = function pointToCoord(point, zoom, out) {
      return this.pointToCoordinate(point, zoom, out);
    };
    _proto.pointAtResToCoord = function pointAtResToCoord(point, res, out) {
      return this.pointAtResToCoordinate(point, res, out);
    };
    _proto.coordToViewPoint = function coordToViewPoint(coordinate, out, altitude) {
      return this.coordinateToViewPoint(coordinate, out, altitude);
    };
    _proto.viewPointToCoord = function viewPointToCoord(viewPoint, out) {
      return this.viewPointToCoordinate(viewPoint, out);
    };
    _proto.coordToContainerPoint = function coordToContainerPoint(coordinate, zoom, out) {
      return this.coordinateToContainerPoint(coordinate, zoom, out);
    };
    _proto.containerPointToCoord = function containerPointToCoord(containerPoint, out) {
      return this.containerPointToCoordinate(containerPoint, out);
    };
    _proto.containerPointToViewPoint = function containerPointToViewPoint(containerPoint, out) {
      if (out) {
        out.set(containerPoint.x, containerPoint.y);
      } else {
        out = containerPoint.copy();
      }
      return out._sub(this.getViewPoint());
    };
    _proto.viewPointToContainerPoint = function viewPointToContainerPoint(viewPoint, out) {
      if (out) {
        out.set(viewPoint.x, viewPoint.y);
      } else {
        out = viewPoint.copy();
      }
      return out._add(this.getViewPoint());
    };
    _proto.checkSize = function checkSize(force) {
      var justStart = now() - this._initTime < 1500 && this.width === 0 || this.height === 0;
      var watched = this._getContainerDomSize(),
        oldHeight = this.height,
        oldWidth = this.width;
      if (!force && watched['width'] === oldWidth && watched['height'] === oldHeight) {
        return this;
      }
      computeDomPosition(this._containerDOM);
      var center = this.getCenter();
      if (!this.options['fixCenterOnResize']) {
        var vh = this._getVisualHeight(this.getPitch());
        var nwCP = new Point(0, this.height - vh);
        var nwCoord = this._containerPointToPrj(nwCP);
        this._updateMapSize(watched);
        var vhAfter = this._getVisualHeight(this.getPitch());
        var nwCPAfter = new Point(0, this.height - vhAfter);
        this._setPrjCoordAtContainerPoint(nwCoord, nwCPAfter);
        this._mapViewCoord = this._getPrjCenter();
      } else {
        this._updateMapSize(watched);
      }
      var hided = watched['width'] === 0 || watched['height'] === 0 || oldWidth === 0 || oldHeight === 0;
      if (justStart || hided) {
        this._eventSilence = true;
        this.setCenter(center);
        delete this._eventSilence;
      }
      this._fireEvent('resize');
      return this;
    };
    _proto.locate = function locate(coordinate, dx, dy) {
      return this.getProjection()._locate(new Coordinate(coordinate), dx, dy);
    };
    _proto.getMainPanel = function getMainPanel() {
      return this._getRenderer().getMainPanel();
    };
    _proto.getPanels = function getPanels() {
      return this._panels;
    };
    _proto.remove = function remove() {
      var _this3 = this;
      if (this.isRemoved()) {
        return this;
      }
      this._fireEvent('removestart');
      this._removeDomEvents();
      this._clearHandlers();
      this.removeBaseLayer();
      var layers = this.getLayers();
      for (var i = 0; i < layers.length; i++) {
        layers[i].remove();
      }
      if (this._getRenderer()) {
        this._getRenderer().remove();
      }
      if (this._containerDOM.childNodes && this._containerDOM.childNodes.length > 0) {
        Array.prototype.slice.call(this._containerDOM.childNodes, 0).filter(function (node) {
          return node.className === 'maptalks-wrapper';
        }).forEach(function (node) {
          return _this3._containerDOM.removeChild(node);
        });
      }
      delete this._panels;
      delete this._containerDOM;
      delete this.renderer;
      this._fireEvent('removeend');
      this._clearAllListeners();
      return this;
    };
    _proto.isRemoved = function isRemoved() {
      return !this._containerDOM;
    };
    _proto.isMoving = function isMoving() {
      return !!this._moving;
    };
    _proto.onMoveStart = function onMoveStart(param) {
      if (this._mapAnimPlayer) {
        this._stopAnim(this._mapAnimPlayer);
      }
      var prjCenter = this._getPrjCenter();
      if (!this._originCenter || this._verifyExtent(prjCenter)) {
        this._originCenter = prjCenter;
      }
      this._moving = true;
      this._trySetCursor('move');
      this._fireEvent('movestart', this._parseEvent(param ? param['domEvent'] : null, 'movestart'));
    };
    _proto.onMoving = function onMoving(param) {
      this._fireEvent('moving', this._parseEvent(param ? param['domEvent'] : null, 'moving'));
    };
    _proto.onMoveEnd = function onMoveEnd(param) {
      this._moving = false;
      if (!this._suppressRecenter) {
        this._recenterOnTerrain();
      }
      this._trySetCursor('default');
      this._fireEvent('moveend', param && param['domEvent'] ? this._parseEvent(param['domEvent'], 'moveend') : param);
      if (!this._verifyExtent(this._getPrjCenter()) && this._originCenter) {
        var moveTo = this._originCenter;
        this._panTo(moveTo);
      }
    };
    _proto.onDragRotateStart = function onDragRotateStart(param) {
      this._dragRotating = true;
      this._fireEvent('dragrotatestart', this._parseEvent(param ? param['domEvent'] : null, 'dragrotatestart'));
    };
    _proto.onDragRotating = function onDragRotating(param) {
      this._fireEvent('dragrotating', this._parseEvent(param ? param['domEvent'] : null, 'dragrotating'));
    };
    _proto.onDragRotateEnd = function onDragRotateEnd(param) {
      this._dragRotating = false;
      this._fireEvent('dragrotateend', this._parseEvent(param ? param['domEvent'] : null, 'dragrotateend'));
    };
    _proto.isDragRotating = function isDragRotating() {
      return !!this._dragRotating;
    };
    _proto.isOffscreen = function isOffscreen(box, viewportPadding) {
      if (viewportPadding === void 0) {
        viewportPadding = 0;
      }
      var width = this.width,
        height = this.height;
      var screenRightBoundary = width + viewportPadding;
      var screenBottomBoundary = height + viewportPadding;
      var xmin = box.xmin,
        ymin = box.ymin,
        xmax = box.xmax,
        ymax = box.ymax;
      if (Array.isArray(box)) {
        xmin = box[0];
        ymin = box[1];
        xmax = box[2];
        ymax = box[3];
      }
      return xmax < viewportPadding || xmin >= screenRightBoundary || ymax < viewportPadding || ymin > screenBottomBoundary;
    };
    _proto.getRenderer = function getRenderer() {
      return this._getRenderer();
    };
    _proto.getDevicePixelRatio = function getDevicePixelRatio() {
      return this.options['devicePixelRatio'] || Browser$1.devicePixelRatio || 1;
    };
    _proto.setDevicePixelRatio = function setDevicePixelRatio(dpr) {
      if (isNumber(dpr) && dpr > 0 && dpr !== this.options['devicePixelRatio']) {
        this.options['devicePixelRatio'] = dpr;
        this.checkSize(true);
      }
      return this;
    };
    _proto._initContainer = function _initContainer(container) {
      if (isString(container)) {
        this._containerDOM = document.getElementById(container);
        if (!this._containerDOM) {
          throw new Error('Invalid container when creating map: \'' + container + '\'');
        }
      } else {
        this._containerDOM = container;
        if (IS_NODE) {
          this.CanvasClass = this._containerDOM.constructor;
        }
      }
      if (this._containerDOM.childNodes && this._containerDOM.childNodes.length > 0) {
        if (this._containerDOM.childNodes[0].className === 'maptalks-wrapper') {
          throw new Error('Container is already loaded with another map instance, use map.remove() to clear it.');
        }
      }
    };
    _proto._trySetCursor = function _trySetCursor(cursor) {
      if (!this._cursor && !this._priorityCursor) {
        if (!cursor) {
          cursor = 'default';
        }
        this._setCursorToPanel(cursor);
      }
      return this;
    };
    _proto._setPriorityCursor = function _setPriorityCursor(cursor) {
      if (!cursor) {
        var hasCursor = false;
        if (this._priorityCursor) {
          hasCursor = true;
        }
        delete this._priorityCursor;
        if (hasCursor) {
          this.setCursor(this._cursor);
        }
      } else {
        this._priorityCursor = cursor;
        this._setCursorToPanel(cursor);
      }
      return this;
    };
    _proto._setCursorToPanel = function _setCursorToPanel(cursor) {
      var panel = this.getMainPanel();
      if (panel && panel.style && panel.style.cursor !== cursor) {
        panel.style.cursor = cursor;
      }
    };
    _proto._removeLayer = function _removeLayer(layer, layerList) {
      if (!layer || !layerList) {
        return;
      }
      var index = layerList.indexOf(layer);
      if (index > -1) {
        layerList.splice(index, 1);
      }
    };
    _proto._sortLayersByZIndex = function _sortLayersByZIndex() {
      if (!this._layers) {
        return;
      }
      for (var i = 0, l = this._layers.length; i < l; i++) {
        this._layers[i]._order = i;
        if (this._layers[i].sortLayersByZIndex) {
          this._layers[i].sortLayersByZIndex();
        }
      }
      this._layers.sort(function (a, b) {
        var c = a.getZIndex() - b.getZIndex();
        if (c === 0) {
          return a._order - b._order;
        }
        return c;
      });
    };
    _proto._fireEvent = function _fireEvent(eventName, param) {
      if (this._eventSilence) {
        return;
      }
      var underline = '_';
      if (eventName[0] !== underline) {
        this.fire(underline + eventName, param);
      }
      this.fire(eventName, param);
    };
    _proto._Load = function _Load() {
      this._resetMapStatus();
      if (this.options['pitch']) {
        this.setPitch(this.options['pitch']);
        delete this.options['pitch'];
      }
      if (this.options['bearing']) {
        this.setBearing(this.options['bearing']);
        delete this.options['bearing'];
      }
      delete this._glRes;
      this._loadAllLayers();
      this._getRenderer().onLoad();
      this._loaded = true;
      this._callOnLoadHooks();
      this._initTime = now();
    };
    _proto._initRenderer = function _initRenderer() {
      var renderer = this.options['renderer'];
      var clazz = Map.getRendererClass(renderer);
      this._renderer = new clazz(this);
      this._renderer.load();
    };
    _proto._getRenderer = function _getRenderer() {
      return this._renderer;
    };
    _proto._loadAllLayers = function _loadAllLayers() {
      function loadLayer(layer) {
        if (layer) {
          layer.load();
        }
      }
      if (this._baseLayer) {
        this._baseLayer.load();
      }
      this._eachLayer(loadLayer, this.getLayers());
    };
    _proto._getLayers = function _getLayers(filter) {
      var layers = this._baseLayer ? [this._baseLayer].concat(this._layers) : this._layers;
      var result = [];
      for (var i = 0; i < layers.length; i++) {
        if (!filter || filter.call(this, layers[i])) {
          result.push(layers[i]);
        }
      }
      return result;
    };
    _proto._eachLayer = function _eachLayer(fn) {
      if (arguments.length < 2) {
        return;
      }
      var layerLists = Array.prototype.slice.call(arguments, 1);
      if (layerLists && !Array.isArray(layerLists)) {
        layerLists = [layerLists];
      }
      var layers = [];
      for (var i = 0, len = layerLists.length; i < len; i++) {
        layers = layers.concat(layerLists[i]);
      }
      for (var j = 0, jlen = layers.length; j < jlen; j++) {
        fn.call(fn, layers[j]);
      }
    };
    _proto._onLayerEvent = function _onLayerEvent(param) {
      if (!param) {
        return;
      }
      if (param['type'] === 'idchange') {
        delete this._layerCache[param['old']];
        this._layerCache[param['new']] = param['target'];
      }
    };
    _proto._resetMapStatus = function _resetMapStatus() {
      var maxZoom = this.getMaxZoom(),
        minZoom = this.getMinZoom();
      var viewMaxZoom = this._spatialReference.getMaxZoom(),
        viewMinZoom = this._spatialReference.getMinZoom();
      if (isNil(maxZoom) || maxZoom === -1 || maxZoom > viewMaxZoom) {
        this.setMaxZoom(viewMaxZoom);
      }
      if (isNil(minZoom) || minZoom === -1 || minZoom < viewMinZoom) {
        this.setMinZoom(viewMinZoom);
      }
      maxZoom = this.getMaxZoom();
      minZoom = this.getMinZoom();
      if (maxZoom < minZoom) {
        this.setMaxZoom(minZoom);
      }
      if (isNil(this._zoomLevel) || this._zoomLevel > maxZoom) {
        this._zoomLevel = maxZoom;
      }
      if (this._zoomLevel < minZoom) {
        this._zoomLevel = minZoom;
      }
      delete this._prjCenter;
      delete this._glRes;
      var projection = this.getProjection();
      this._prjCenter = projection.project(this._center);
      this._calcMatrices();
      var renderer = this._getRenderer();
      if (renderer) {
        renderer.resetContainer();
      }
    };
    _proto._getContainerDomSize = function _getContainerDomSize() {
      if (!this._containerDOM) {
        return null;
      }
      var containerDOM = this._containerDOM;
      var width, height;
      if (this._containerDomContentRect) {
        width = this._containerDomContentRect.width;
        height = this._containerDomContentRect.height;
        return new Size(width, height);
      }
      if (!isNil(containerDOM.width) && !isNil(containerDOM.height)) {
        width = containerDOM.width;
        height = containerDOM.height;
        var dpr = this.getDevicePixelRatio();
        if (dpr !== 1 && containerDOM['layer']) {
          width /= dpr;
          height /= dpr;
        }
      } else if (!isNil(containerDOM.clientWidth) && !isNil(containerDOM.clientHeight)) {
        width = parseInt(containerDOM.clientWidth, 0);
        height = parseInt(containerDOM.clientHeight, 0);
      } else {
        throw new Error('can not get size of container');
      }
      return new Size(width, height);
    };
    _proto._updateMapSize = function _updateMapSize(mSize) {
      this.width = mSize['width'];
      this.height = mSize['height'];
      this._getRenderer().updateMapSize(mSize);
      this._calcMatrices();
      return this;
    };
    _proto._getPrjCenter = function _getPrjCenter() {
      return this._prjCenter;
    };
    _proto._setPrjCenter = function _setPrjCenter(pcenter) {
      this._prjCenter = pcenter;
      if (this.isInteracting() && !this.isMoving()) {
        this._mapViewCoord = pcenter;
      }
      this._calcMatrices();
    };
    _proto._setPrjCoordAtContainerPoint = function _setPrjCoordAtContainerPoint(coordinate, point) {
      if (!this.centerAltitude && point.x === this.width / 2 && point.y === this.height / 2) {
        return this;
      }
      var t = this._containerPointToPoint(point)._sub(this._prjToPoint(this._getPrjCenter()));
      var pcenter = this._pointToPrj(this._prjToPoint(coordinate).sub(t));
      this._setPrjCenter(pcenter);
      return this;
    };
    _proto._verifyExtent = function _verifyExtent(prjCenter) {
      if (!prjCenter) {
        return false;
      }
      var maxExt = this._prjMaxExtent;
      if (!maxExt) {
        return true;
      }
      return maxExt.contains(prjCenter);
    };
    _proto._offsetCenterByPixel = function _offsetCenterByPixel(pixel) {
      var pos = TEMP_POINT.set(this.width / 2 - pixel.x, this.height / 2 - pixel.y);
      var coord = this._containerPointToPrj(pos, TEMP_COORD);
      var containerCenter = TEMP_POINT.set(this.width / 2, this.height / 2);
      this._setPrjCoordAtContainerPoint(coord, containerCenter);
    };
    _proto.offsetPlatform = function offsetPlatform(offset) {
      if (!offset) {
        return this._mapViewPoint;
      } else {
        this._getRenderer().offsetPlatform(offset);
        this._mapViewCoord = this._getPrjCenter();
        this._mapViewPoint = this._mapViewPoint.add(offset);
        return this;
      }
    };
    _proto.getViewPoint = function getViewPoint() {
      var offset = this._getViewPointFrameOffset();
      var panelOffset = this.offsetPlatform();
      if (offset) {
        panelOffset = panelOffset.add(offset);
      }
      return panelOffset;
    };
    _proto._resetMapViewPoint = function _resetMapViewPoint() {
      this._mapViewPoint = new Point(0, 0);
      this._mapViewCoord = this._getPrjCenter();
    };
    _proto._getResolution = function _getResolution(zoom) {
      if ((zoom === undefined || zoom === this._zoomLevel) && this._mapRes !== undefined) {
        return this._mapRes;
      }
      if (isNil(zoom)) {
        zoom = this._zoomLevel;
      }
      return this._spatialReference.getResolution(zoom);
    };
    _proto._getResolutions = function _getResolutions() {
      return this._spatialReference.getResolutions();
    };
    _proto._prjToPoint = function _prjToPoint(pCoord, zoom, out) {
      zoom = isNil(zoom) ? this.getZoom() : zoom;
      var res = this._getResolution(zoom);
      return this._prjToPointAtRes(pCoord, res, out);
    };
    _proto._prjToPointAtRes = function _prjToPointAtRes(pCoord, res, out) {
      return this._spatialReference.getTransformation().transform(pCoord, res, out);
    };
    _proto._prjsToPointsAtRes = function _prjsToPointsAtRes(pCoords, res, resultPoints) {
      if (resultPoints === void 0) {
        resultPoints = [];
      }
      var transformation = this._spatialReference.getTransformation();
      var pts = [];
      for (var i = 0, len = pCoords.length; i < len; i++) {
        var pt = transformation.transform(pCoords[i], res, resultPoints[i]);
        pts.push(pt);
      }
      return pts;
    };
    _proto._pointToPrj = function _pointToPrj(point, zoom, out) {
      zoom = isNil(zoom) ? this.getZoom() : zoom;
      var res = this._getResolution(zoom);
      return this._pointToPrjAtRes(point, res, out);
    };
    _proto._pointToPrjAtRes = function _pointToPrjAtRes(point, res, out) {
      return this._spatialReference.getTransformation().untransform(point, res, out);
    };
    _proto._pointToPoint = function _pointToPoint(point, zoom, out) {
      if (!isNil(zoom)) {
        return this._pointAtResToPoint(point, this._getResolution(zoom), out);
      }
      if (out) {
        out.x = point.x;
        out.y = point.y;
      } else {
        out = point.copy();
      }
      return out;
    };
    _proto._pointAtResToPoint = function _pointAtResToPoint(point, res, out) {
      if (out) {
        out.x = point.x;
        out.y = point.y;
      } else {
        out = point.copy();
      }
      return out._multi(res / this._getResolution());
    };
    _proto._pointToPointAtRes = function _pointToPointAtRes(point, res, out) {
      if (out) {
        out.x = point.x;
        out.y = point.y;
      } else {
        out = point.copy();
      }
      return out._multi(this._getResolution() / res);
    };
    _proto._containerPointToPrj = function _containerPointToPrj(containerPoint, out) {
      return this._pointToPrj(this._containerPointToPoint(containerPoint, undefined, out), undefined, out);
    };
    _proto._callOnLoadHooks = function _callOnLoadHooks() {
      var proto = Map.prototype;
      if (!proto._onLoadHooks) {
        return;
      }
      for (var i = 0, l = proto._onLoadHooks.length; i < l; i++) {
        proto._onLoadHooks[i].call(this);
      }
    };
    _proto._fixPrjOnWorldWide = function _fixPrjOnWorldWide(prjCoord) {
      var projection = this.getProjection();
      if (projection && projection.fullExtent && prjCoord) {
        var _ref = projection.fullExtent || {},
          left = _ref.left,
          bottom = _ref.bottom,
          top = _ref.top,
          right = _ref.right;
        if (isNumber(left)) {
          prjCoord.x = Math.max(left, prjCoord.x);
        }
        if (isNumber(right)) {
          prjCoord.x = Math.min(right, prjCoord.x);
        }
        if (isNumber(bottom)) {
          prjCoord.y = Math.max(bottom, prjCoord.y);
        }
        if (isNumber(top)) {
          prjCoord.y = Math.min(top, prjCoord.y);
        }
      }
      return this;
    };
    return Map;
  }(Handlerable(Eventable(Renderable(Class))));
  Map$1.include({
    coordinateToPoint: function coordinateToPoint(coordinate, zoom, out) {
      var res = this._getResolution(zoom);
      return this.coordinateToPointAtRes(coordinate, res, out);
    },
    coordinateToPointAtRes: function () {
      var COORD = new Coordinate(0, 0);
      return function (coordinate, res, out) {
        var prjCoord = this.getProjection().project(coordinate, COORD);
        return this._prjToPointAtRes(prjCoord, res, out);
      };
    }(),
    pointToCoordinate: function () {
      var COORD = new Coordinate(0, 0);
      return function (point, zoom, out) {
        var prjCoord = this._pointToPrj(point, zoom, COORD);
        return this.getProjection().unproject(prjCoord, out);
      };
    }(),
    pointAtResToCoordinate: function () {
      var COORD = new Coordinate(0, 0);
      return function (point, res, out) {
        var prjCoord = this._pointToPrjAtRes(point, res, COORD);
        return this.getProjection().unproject(prjCoord, out);
      };
    }(),
    coordinateToViewPoint: function () {
      var COORD = new Coordinate(0, 0);
      return function (coordinate, out, altitude) {
        return this._prjToViewPoint(this.getProjection().project(coordinate, COORD), out, altitude);
      };
    }(),
    viewPointToCoordinate: function () {
      var COORD = new Coordinate(0, 0);
      return function (viewPoint, out) {
        return this.getProjection().unproject(this._viewPointToPrj(viewPoint, COORD), out);
      };
    }(),
    coordinateToContainerPoint: function coordinateToContainerPoint(coordinate, zoom, out) {
      var res = this._getResolution(zoom);
      return this.coordinateToContainerPointAtRes(coordinate, res, out);
    },
    coordinateToContainerPointAtRes: function () {
      var COORD = new Coordinate(0, 0);
      return function (coordinate, res, out) {
        var pCoordinate = this.getProjection().project(coordinate, COORD);
        return this._prjToContainerPointAtRes(pCoordinate, res, out);
      };
    }(),
    coordinatesToContainerPoints: function coordinatesToContainerPoints(coordinates, zoom) {
      var res = this._getResolution(zoom);
      return this.coordinatesToContainerPointsAtRes(coordinates, res);
    },
    coordinatesToContainerPointsAtRes: function () {
      return function (coordinates, resolution) {
        var pts = [];
        var transformation = this._spatialReference.getTransformation();
        var res = resolution / this._getResolution();
        var projection = this.getProjection();
        var prjOut = new Coordinate(0, 0);
        var isTransforming = this.isTransforming();
        var centerPoint = this._prjToPoint(this._getPrjCenter(), undefined, TEMP_COORD);
        for (var i = 0, len = coordinates.length; i < len; i++) {
          var pCoordinate = projection.project(coordinates[i], prjOut);
          var point = transformation.transform(pCoordinate, resolution);
          point = point._multi(res);
          this._toContainerPoint(point, isTransforming, coordinates[i].z, centerPoint);
          pts.push(point);
        }
        return pts;
      };
    }(),
    containerPointToCoordinate: function () {
      var COORD = new Coordinate(0, 0);
      return function (containerPoint, out) {
        var pCoordinate = this._containerPointToPrj(containerPoint, COORD);
        return this.getProjection().unproject(pCoordinate, out);
      };
    }(),
    containerToExtent: function () {
      var POINT0 = new Point(0, 0);
      var POINT1 = new Point(0, 0);
      return function (containerExtent) {
        var extent2D = new PointExtent(this._containerPointToPoint(containerExtent.getMin(POINT0), undefined, POINT0), this._containerPointToPoint(containerExtent.getMax(POINT1), undefined, POINT1));
        return this._pointToExtent(extent2D);
      };
    }(),
    distanceToPixel: function () {
      var POINT0 = new Point(0, 0);
      var POINT1 = new Point(0, 0);
      return function (xDist, yDist, zoom) {
        var projection = this.getProjection();
        if (!projection) {
          return null;
        }
        var scale = this.getScale() / this.getScale(zoom);
        var center = this.getCenter(),
          target = projection.locate(center, xDist, yDist);
        var p0 = this.coordToContainerPoint(center, undefined, POINT0),
          p1 = this.coordToContainerPoint(target, undefined, POINT1);
        p1._sub(p0)._multi(scale)._abs();
        return new Size(p1.x, p1.y);
      };
    }(),
    distanceToPoint: function distanceToPoint(xDist, yDist, zoom, paramCenter) {
      var res = this._getResolution(zoom);
      return this.distanceToPointAtRes(xDist, yDist, res, paramCenter);
    },
    distanceToPointAtRes: function () {
      var POINT = new Point(0, 0);
      var COORD = new Coordinate(0, 0);
      return function (xDist, yDist, res, paramCenter, out) {
        var projection = this.getProjection();
        if (!projection) {
          return null;
        }
        var center = paramCenter || this.getCenter(),
          target = projection.locate(center, xDist, yDist, COORD);
        var p0 = this.coordToPointAtRes(center, res, POINT),
          p1 = this.coordToPointAtRes(target, res, out);
        p1._sub(p0)._abs();
        return p1;
      };
    }(),
    altitudeToPoint: function () {
      var DEFAULT_CENTER = new Coordinate(0, 40);
      var POINT = new Point(0, 0);
      return function (altitude, res, originCenter) {
        if (altitude === void 0) {
          altitude = 0;
        }
        if (this._altitudeOriginDirty) {
          DEFAULT_CENTER.x = this._originLng;
          this._altitudeOriginDirty = false;
        }
        var p = this.distanceToPointAtRes(altitude, altitude, res, originCenter || DEFAULT_CENTER, POINT);
        if (altitude < 0 && p.x > 0) {
          p.x = -p.x;
        }
        var heightFactor = this.options['heightFactor'];
        if (heightFactor && heightFactor !== 1) {
          p.x *= heightFactor;
          p.y *= heightFactor;
        }
        return p.x;
      };
    }(),
    pointAtResToAltitude: function () {
      var DEFAULT_CENTER = new Coordinate(0, 40);
      return function (point, res, originCenter) {
        if (point === void 0) {
          point = 0;
        }
        var altitude = this.pointAtResToDistance(point, 0, res, originCenter || DEFAULT_CENTER);
        return altitude;
      };
    }(),
    pixelToDistance: function () {
      var COORD0 = new Coordinate(0, 0);
      var COORD1 = new Coordinate(0, 0);
      var TARGET0 = new Coordinate(0, 0);
      var TARGET1 = new Coordinate(0, 0);
      return function (width, height) {
        var projection = this.getProjection();
        if (!projection) {
          return null;
        }
        var fullExt = this.getFullExtent();
        var d = fullExt['top'] > fullExt['bottom'] ? -1 : 1;
        var coord0 = COORD0.set(this.width / 2, this.height / 2);
        var coord1 = COORD1.set(this.width / 2 + width, this.height / 2 + d * height);
        var target0 = this.containerPointToCoord(coord0, TARGET0);
        var target1 = this.containerPointToCoord(coord1, TARGET1);
        return projection.measureLength(target0, target1);
      };
    }(),
    pointToDistance: function pointToDistance(dx, dy, zoom) {
      var res = this.getResolution(zoom);
      return this.pointAtResToDistance(dx, dy, res);
    },
    pointAtResToDistance: function () {
      var POINT = new Point(0, 0);
      var PRJ_COORD = new Coordinate(0, 0);
      var COORD0 = new Coordinate(0, 0);
      var COORD1 = new Coordinate(0, 0);
      return function (dx, dy, res, paramCenter) {
        var projection = this.getProjection();
        if (!projection) {
          return null;
        }
        var prjCoord = paramCenter ? projection.project(paramCenter, PRJ_COORD) : this._getPrjCenter();
        var c = this._prjToPointAtRes(prjCoord, res, POINT);
        c._add(dx, dy);
        var target = this.pointAtResToCoord(c, res, COORD0);
        var src = paramCenter ? paramCenter : projection.unproject(prjCoord, COORD1);
        return projection.measureLength(src, target);
      };
    }(),
    locateByPoint: function () {
      var POINT = new Point(0, 0);
      return function (coordinate, px, py) {
        var point = this.coordToContainerPoint(coordinate, undefined, POINT);
        return this.containerPointToCoord(point._add(px, py));
      };
    }(),
    _get2DExtent: function _get2DExtent(zoom, out) {
      var cached;
      if ((zoom === undefined || zoom === this._zoomLevel) && this._mapExtent2D) {
        cached = this._mapExtent2D;
      }
      if (cached) {
        if (out) {
          out.set(cached['xmin'], cached['ymin'], cached['xmax'], cached['ymax']);
          return out;
        }
        return cached.copy();
      }
      var res = this._getResolution(zoom);
      return this._get2DExtentAtRes(res, out);
    },
    _get2DExtentAtRes: function () {
      var POINT = new Point(0, 0);
      return function (res, out) {
        var _this4 = this;
        if (res === this._mapGlRes && this._mapGlExtent2D) {
          return this._mapGlExtent2D;
        }
        var cExtent = this.getContainerExtent();
        return cExtent.convertTo(function (c) {
          return _this4._containerPointToPointAtRes(c, res, POINT);
        }, out);
      };
    }(),
    _pointToExtent: function () {
      var COORD0 = new Coordinate(0, 0);
      var COORD1 = new Coordinate(0, 0);
      return function (extent2D) {
        var min2d = extent2D.getMin(),
          max2d = extent2D.getMax();
        var fullExtent = this.getFullExtent();
        var _ref2 = !fullExtent || fullExtent.left <= fullExtent.right ? [min2d.x, max2d.x] : [max2d.x, min2d.x],
          minx = _ref2[0],
          maxx = _ref2[1];
        var _ref3 = !fullExtent || fullExtent.top > fullExtent.bottom ? [max2d.y, min2d.y] : [min2d.y, max2d.y],
          miny = _ref3[0],
          maxy = _ref3[1];
        var min = min2d.set(minx, maxy);
        var max = max2d.set(maxx, miny);
        return new Extent(this.pointToCoord(min, undefined, COORD0), this.pointToCoord(max, undefined, COORD1), this.getProjection());
      };
    }(),
    _getViewPointFrameOffset: function () {
      var POINT = new Point(0, 0);
      return function () {
        if (this.isZooming()) {
          return null;
        }
        var pcenter = this._getPrjCenter();
        if (this._mapViewCoord && !this._mapViewCoord.equals(pcenter)) {
          return this._prjToContainerPoint(this._mapViewCoord)._sub(this._prjToContainerPoint(pcenter, undefined, POINT));
        }
        return null;
      };
    }(),
    _viewPointToPrj: function () {
      var POINT = new Point(0, 0);
      return function (viewPoint, out) {
        return this._containerPointToPrj(this.viewPointToContainerPoint(viewPoint, POINT), out);
      };
    }(),
    _prjToContainerPoint: function _prjToContainerPoint(pCoordinate, zoom, out, altitude) {
      var res = this._getResolution(zoom);
      return this._prjToContainerPointAtRes(pCoordinate, res, out, altitude);
    },
    _prjToContainerPointAtRes: function () {
      var POINT = new Point(0, 0);
      return function (pCoordinate, res, out, altitude) {
        return this._pointAtResToContainerPoint(this._prjToPointAtRes(pCoordinate, res, POINT), res, altitude || 0, out);
      };
    }(),
    _prjToViewPoint: function () {
      var POINT = new Point(0, 0);
      return function (pCoordinate, out, altitude) {
        var containerPoint = this._prjToContainerPoint(pCoordinate, undefined, POINT, altitude);
        return this.containerPointToViewPoint(containerPoint, out);
      };
    }(),
    _viewPointToPoint: function () {
      var POINT = new Point(0, 0);
      return function (viewPoint, zoom, out) {
        return this._containerPointToPoint(this.viewPointToContainerPoint(viewPoint, POINT), zoom, out);
      };
    }(),
    _pointToViewPoint: function () {
      var COORD = new Coordinate(0, 0);
      return function (point, zoom, out) {
        return this._prjToViewPoint(this._pointToPrj(point, zoom, COORD), out);
      };
    }()
  });
  Map$1.mergeOptions(options$2);

  var MapDoubleClickZoomHandler = function (_Handler) {
    _inheritsLoose(MapDoubleClickZoomHandler, _Handler);
    function MapDoubleClickZoomHandler() {
      return _Handler.apply(this, arguments) || this;
    }
    var _proto = MapDoubleClickZoomHandler.prototype;
    _proto.addHooks = function addHooks() {
      if (!this.target) {
        return;
      }
      this.target.on('_dblclick', this._onDoubleClick, this);
    };
    _proto.removeHooks = function removeHooks() {
      if (!this.target) {
        return;
      }
      this.target.off('_dblclick', this._onDoubleClick, this);
    };
    _proto._onDoubleClick = function _onDoubleClick(param) {
      var map = this.target;
      if (map.options['doubleClickZoom']) {
        var oldZoom = map.getZoom(),
          zoom = param['domEvent']['shiftKey'] ? Math.ceil(oldZoom) - 1 : Math.floor(oldZoom) + 1;
        map._zoomAnimation(zoom, param['containerPoint']);
      }
    };
    return MapDoubleClickZoomHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'doubleClickZoom': true
  });
  Map$1.addOnLoadHook('addHandler', 'doubleClickZoom', MapDoubleClickZoomHandler);

  var MapDragHandler = function (_Handler) {
    _inheritsLoose(MapDragHandler, _Handler);
    function MapDragHandler() {
      return _Handler.apply(this, arguments) || this;
    }
    var _proto = MapDragHandler.prototype;
    _proto.addHooks = function addHooks() {
      var map = this.target;
      if (!map) {
        return;
      }
      var dom = map._panels.mapWrapper || map._containerDOM;
      this._dragHandler = new DragHandler(dom, {
        'cancelOn': this._cancelOn.bind(this),
        'rightclick': true
      });
      this._dragHandler.on('mousedown', this._onMouseDown, this).on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this).enable();
    };
    _proto.removeHooks = function removeHooks() {
      this._dragHandler.off('mousedown', this._onMouseDown, this).off('dragstart', this._onDragStart, this).off('dragging', this._onDragging, this).off('dragend', this._onDragEnd, this);
      this._dragHandler.remove();
      delete this._dragHandler;
    };
    _proto._cancelOn = function _cancelOn(domEvent) {
      if (this.target.isZooming() || this._ignore(domEvent)) {
        return true;
      }
      return false;
    };
    _proto._ignore = function _ignore(param) {
      if (!param) {
        return false;
      }
      if (param.domEvent) {
        param = param.domEvent;
      }
      return this.target._ignoreEvent(param) || this.target._isEventOutMap(param);
    };
    _proto._onMouseDown = function _onMouseDown(param) {
      delete this.startDragTime;
      delete this._mode;
      var switchDragButton = this.target.options['switchDragButton'];
      var rotateModeButton = switchDragButton ? 0 : 2;
      var isTouch = param.domEvent.type === 'touchstart';
      var isRotatonMode = switchDragButton && isTouch || param.domEvent.button === rotateModeButton || param.domEvent.ctrlKey;
      if (isRotatonMode) {
        if (this.target.options['dragRotate'] || this.target.options['dragPitch']) {
          this._mode = 'rotatePitch';
        }
      } else if (this.target.options['dragPan']) {
        this._mode = 'move';
      }
      this.target._stopAnim(this.target._mapAnimPlayer);
      preventDefault(param['domEvent']);
    };
    _proto._onDragStart = function _onDragStart(param) {
      this.startDragTime = now();
      if (this._mode === 'move') {
        this._moveStart(param);
      } else if (this._mode === 'rotatePitch') {
        this._rotateStart(param);
      }
    };
    _proto._onDragging = function _onDragging(param) {
      var map = this.target;
      if (map._isEventOutMap(param['domEvent'])) {
        return;
      }
      if (this._mode === 'move') {
        this._moving(param);
      } else if (this._mode === 'rotatePitch') {
        this._rotating(param);
      }
    };
    _proto._onDragEnd = function _onDragEnd(param) {
      if (this._mode === 'move') {
        this._moveEnd(param);
      } else if (this._mode === 'rotatePitch') {
        this._rotateEnd(param);
      }
      delete this.startDragTime;
      delete this.startBearing;
    };
    _proto._start = function _start(param) {
      this.preX = param['mousePos'].x;
      this.preY = param['mousePos'].y;
      this.startX = this.preX;
      this.startY = this.preY;
      this._startPrjCenter = this.target._getPrjCenter().copy();
    };
    _proto._moveStart = function _moveStart(param) {
      this._start(param);
      var map = this.target;
      map.onMoveStart(param);
      var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
      this.startPrjCoord = map._containerPointToPrj(p);
    };
    _proto._moving = function _moving(param) {
      if (!this.startDragTime) {
        return;
      }
      var map = this.target;
      var p = getEventContainerPoint(map._getActualEvent(param.domEvent), map.getContainer());
      map._setPrjCoordAtContainerPoint(this.startPrjCoord, p);
      map.onMoving(param);
    };
    _proto._moveEnd = function _moveEnd(param) {
      if (!this.startDragTime) {
        return;
      }
      var isTouch = param.domEvent.type === 'touchend';
      var map = this.target;
      var t = now() - this.startDragTime;
      var mx = param['mousePos'].x,
        my = param['mousePos'].y;
      var dx = mx - this.startX;
      var dy = my - this.startY;
      var currentCenter = map._getPrjCenter();
      var dxy = currentCenter.sub(this._startPrjCenter);
      this._clear();
      if (map.options['panAnimation'] && !param.interupted && map._verifyExtent(map._getPrjCenter()) && t < 280 && Math.abs(dy) + Math.abs(dx) > 5) {
        t = 5 * t;
        var dscale = isTouch ? 5 : 2.8;
        var targetPrjCoord = currentCenter.add(dxy._multi(dscale));
        map._panTo(targetPrjCoord, {
          'duration': isTouch ? t * 3 : t * 2,
          'easing': 'outExpo'
        });
      } else {
        map.onMoveEnd(param);
      }
    };
    _proto._rotateStart = function _rotateStart(param) {
      this._start(param);
      delete this._rotateMode;
      this.startBearing = this.target.getBearing();
      this.target.onDragRotateStart(param);
      this._db = 0;
    };
    _proto._rotating = function _rotating(param) {
      var map = this.target;
      var mx = param['mousePos'].x,
        my = param['mousePos'].y;
      var prePitch = map.getPitch(),
        preBearing = map.getBearing();
      var dx = Math.abs(mx - this.preX),
        dy = Math.abs(my - this.preY);
      if (!this._rotateMode) {
        if (map.options['dragRotatePitch']) {
          this._rotateMode = 'rotate_pitch';
        } else if (dx > dy) {
          this._rotateMode = 'rotate';
        } else if (dx < dy) {
          this._rotateMode = 'pitch';
        } else {
          this._rotateMode = 'rotate';
        }
      }
      if (this._rotateMode === 'pitch' && prePitch === 0 && dy < 10) {
        return;
      }
      if (this._rotateMode.indexOf('rotate') >= 0 && map.options['dragRotate']) {
        var factor = 0.15;
        var db = 0;
        if (map.options['dragPitch'] || dx > dy) {
          db = -factor * (this.preX - mx);
        } else if (mx > map.width / 2) {
          db = factor * (this.preY - my);
        } else {
          db = -factor * (this.preY - my);
        }
        var bearing = map.getBearing() + db;
        this._db = this._db || 0;
        this._db += db;
        map._setBearing(bearing);
      }
      if (this._rotateMode.indexOf('pitch') >= 0 && map.options['dragPitch']) {
        map._setPitch(map.getPitch() + (this.preY - my) * 0.15);
      }
      this.preX = mx;
      this.preY = my;
      if (map.getBearing() !== preBearing || map.getPitch() !== prePitch) {
        map.onDragRotating(param);
      }
    };
    _proto._rotateEnd = function _rotateEnd(param) {
      var map = this.target;
      var bearing = map.getBearing();
      this._clear();
      var t = now() - this.startDragTime;
      map.onDragRotateEnd(param);
      if (map.options['rotateAnimation'] && Math.abs(bearing - this.startBearing) > 20 && (this._rotateMode === 'rotate' || this._rotateMode === 'rotate_pitch') && !param.interupted && t < 400) {
        var _bearing = map.getBearing();
        map._animateTo({
          'bearing': _bearing + this._db / 1.5
        }, {
          'easing': 'outQuint',
          'duration': 1600
        });
      }
    };
    _proto._clear = function _clear() {
      delete this.startPrjCoord;
      delete this.preX;
      delete this.preY;
      delete this.startX;
      delete this.startY;
    };
    return MapDragHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'draggable': true,
    'dragPan': true,
    'dragRotatePitch': true,
    'dragRotate': true,
    'dragPitch': true
  });
  Map$1.addOnLoadHook('addHandler', 'draggable', MapDragHandler);

  var EVENTS = 'mousedown ' + 'mouseup ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'touchstart ' + 'touchmove ' + 'touchend ' + 'mouseout';
  var MOUSEEVENT_ASSOCIATION_TABLE = {
    'mousemove': ['mousemove', 'mouseover', 'mouseout', 'mouseenter'],
    'touchend': ['touchend', 'click']
  };
  var isGeo = function isGeo(geometry) {
    return geometry && geometry.getLayer && geometry.on && geometry.fire;
  };
  var getGeoId = function getGeoId(geometry) {
    if (geometry._getInternalId) {
      return geometry._getInternalId();
    } else if (geometry.getId) {
      return geometry.getId();
    }
    return null;
  };
  var fireGeoEvent = function fireGeoEvent(geometry, domEvent, type) {
    if (geometry._onEvent) {
      return geometry._onEvent(domEvent, type);
    }
    var layer = geometry.getLayer();
    if (layer && layer.fireGeoEvent) {
      return layer.fireGeoEvent(geometry, domEvent, type);
    }
    return null;
  };
  var MapGeometryEventsHandler = function (_Handler) {
    _inheritsLoose(MapGeometryEventsHandler, _Handler);
    function MapGeometryEventsHandler() {
      return _Handler.apply(this, arguments) || this;
    }
    var _proto = MapGeometryEventsHandler.prototype;
    _proto.addHooks = function addHooks() {
      var map = this.target;
      var dom = map._panels.allLayers || map._containerDOM;
      on(dom, EVENTS, this._identifyGeometryEvents, this);
    };
    _proto.removeHooks = function removeHooks() {
      var map = this.target;
      var dom = map._panels.allLayers || map._containerDOM;
      off(dom, EVENTS, this._identifyGeometryEvents, this);
    };
    _proto._identifyGeometryEvents = function _identifyGeometryEvents(domEvent, type) {
      var map = this.target;
      if (map.isInteracting() || map._ignoreEvent(domEvent)) {
        return;
      }
      var oneMoreEvent = null;
      var eventType = type || domEvent.type;
      if (isMoveEvent(eventType) && !Browser$1.isTest && isMousemoveEventBlocked(this, map.options['mousemoveThrottleTime'])) {
        stopPropagation(domEvent);
        return;
      }
      var isMousedown = eventType === 'mousedown' || eventType === 'touchstart' && domEvent.touches && domEvent.touches.length === 1;
      if (isMousedown) {
        this._mouseDownTime = now();
      } else if ((eventType === 'click' || eventType === 'touchend') && this._mouseDownTime) {
        var downTime = this._mouseDownTime;
        delete this._mouseDownTime;
        var time = now();
        if (time - downTime > 300) {
          if (eventType === 'click') {
            return;
          }
        } else if (eventType === 'touchend') {
          oneMoreEvent = 'click';
        }
      }
      var actual = domEvent.touches && domEvent.touches.length > 0 ? domEvent.touches[0] : domEvent.changedTouches && domEvent.changedTouches.length > 0 ? domEvent.changedTouches[0] : domEvent;
      if (!actual) {
        return;
      }
      var containerPoint = getEventContainerPoint(actual, map._containerDOM);
      if (eventType === 'touchstart') {
        if (map.options['preventTouch']) {
          preventDefault(domEvent);
        }
      }
      var geometryCursorStyle = null;
      var tops = this.target.getRenderer().getTopElements();
      var topOnlyEvent = isMousedown && domEvent.button !== 2;
      for (var i = 0; i < tops.length; i++) {
        if (tops[i].hitTest(containerPoint)) {
          var cursor = tops[i].options['cursor'];
          if (cursor) {
            geometryCursorStyle = cursor;
          }
          if (topOnlyEvent || tops[i].events && tops[i].events.indexOf(eventType) >= 0) {
            var e = {
              target: map,
              type: eventType,
              domEvent: domEvent,
              containerPoint: containerPoint
            };
            if (topOnlyEvent) {
              map._setPriorityCursor(geometryCursorStyle);
              tops[i].mousedown(e);
              return;
            } else {
              tops[i].onEvent(e);
            }
          }
        }
      }
      var layers = map._getLayers(function (layer) {
        if (layer.identify && layer.options['geometryEvents']) {
          return true;
        }
        return false;
      });
      if (!layers.length) {
        return;
      }
      var eventTypes = MOUSEEVENT_ASSOCIATION_TABLE[eventType] || [eventType];
      var identifyOptions = {
        'includeInternals': true,
        'filter': function filter(geometry) {
          if (geometry instanceof Geometry) {
            var eventToFire = geometry._getEventTypeToFire(domEvent);
            if (eventType === 'mousemove') {
              if (!geometryCursorStyle && geometry.options['cursor']) {
                geometryCursorStyle = geometry.options['cursor'];
              }
              return true;
            } else if (!geometry.listens(eventToFire) && !geometry.listens(oneMoreEvent)) {
              return false;
            }
            return true;
          } else if (isGeo(geometry)) {
            return true;
          }
          return false;
        },
        'count': 1,
        'onlyVisible': map.options['onlyVisibleGeometryEvents'],
        containerPoint: containerPoint,
        layers: layers,
        eventTypes: eventTypes,
        domEvent: domEvent
      };
      var callback = fireGeometryEvent.bind(this);
      if (isMoveEvent(eventType)) {
        this._queryIdentifyTimeout = map.getRenderer().callInNextFrame(function () {
          if (map.isInteracting()) {
            return;
          }
          map.identifyAtPoint(identifyOptions, callback);
        });
      } else {
        map.identifyAtPoint(identifyOptions, callback);
      }
      function fireGeometryEvent(geometries) {
        var _this = this;
        var propagation = true;
        var getOldGeos = function getOldGeos() {
          var geos = _this._prevOverGeos && _this._prevOverGeos.geos;
          return geos || [];
        };
        var oldGeosMouseout = function oldGeosMouseout(oldTargets, geoMap) {
          if (oldTargets === void 0) {
            oldTargets = [];
          }
          if (geoMap === void 0) {
            geoMap = {};
          }
          if (oldTargets && oldTargets.length > 0) {
            for (var _i = oldTargets.length - 1; _i >= 0; _i--) {
              var oldTarget = oldTargets[_i];
              if (!isGeo(oldTarget)) {
                continue;
              }
              var oldTargetId = getGeoId(oldTargets[_i]);
              if (!geoMap[oldTargetId]) {
                propagation = fireGeoEvent(oldTarget, domEvent, 'mouseout');
              }
            }
          }
        };
        if (eventType === 'mouseout') {
          var oldTargets = getOldGeos();
          this._prevOverGeos = {
            'geos': [],
            'geomap': {}
          };
          oldGeosMouseout(oldTargets, {});
        } else if (eventType === 'mousemove') {
          var geoMap = {};
          if (geometries.length > 0) {
            for (var _i2 = geometries.length - 1; _i2 >= 0; _i2--) {
              var geo = geometries[_i2];
              if (!isGeo(geo)) {
                continue;
              }
              var iid = getGeoId(geo);
              geoMap[iid] = geo;
              fireGeoEvent(geo, domEvent);
              if (!this._prevOverGeos || !this._prevOverGeos.geomap[iid]) {
                fireGeoEvent(geo, domEvent, 'mouseenter');
              }
              propagation = fireGeoEvent(geo, domEvent, 'mouseover');
            }
          }
          map._setPriorityCursor(geometryCursorStyle);
          var _oldTargets = getOldGeos();
          this._prevOverGeos = {
            'geos': geometries,
            'geomap': geoMap
          };
          oldGeosMouseout(_oldTargets, geoMap);
        } else {
          if (!geometries || !geometries.length) {
            return;
          }
          for (var _i3 = geometries.length - 1; _i3 >= 0; _i3--) {
            if (!isGeo(geometries[_i3])) {
              continue;
            }
            propagation = fireGeoEvent(geometries[_i3], domEvent);
            if (oneMoreEvent) {
              fireGeoEvent(geometries[_i3], domEvent, oneMoreEvent);
            }
            break;
          }
        }
        if (propagation === false) {
          stopPropagation(domEvent);
        }
      }
    };
    return MapGeometryEventsHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'geometryEvents': true,
    'onlyVisibleGeometryEvents': true
  });
  Map$1.addOnLoadHook('addHandler', 'geometryEvents', MapGeometryEventsHandler);

  var wheelZoomDelta = 4.000244140625;
  var defaultZoomRate = 1 / 100;
  var wheelZoomRate = 1 / 450;
  var maxScalePerFrame = 2;
  var MapScrollWheelZoomHandler = function (_Handler) {
    _inheritsLoose(MapScrollWheelZoomHandler, _Handler);
    function MapScrollWheelZoomHandler(target) {
      var _this;
      _this = _Handler.call(this, target) || this;
      _this._thisScrollZoom = _this._scrollZoom.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this._wheelZoomRate = wheelZoomRate;
      _this._defaultZoomRate = defaultZoomRate;
      _this._delta = 0;
      return _this;
    }
    var _proto = MapScrollWheelZoomHandler.prototype;
    _proto.addHooks = function addHooks() {
      addDomEvent(this.target._containerDOM, 'wheel', this._onWheelScroll, this);
    };
    _proto.removeHooks = function removeHooks() {
      removeDomEvent(this.target._containerDOM, 'wheel', this._onWheelScroll);
    };
    _proto._onWheelScroll = function _onWheelScroll(evt) {
      var map = this.target;
      if (map.options['preventWheelScroll']) {
        preventDefault(evt);
        stopPropagation(evt);
      }
      if (map._ignoreEvent(evt) || map._isEventOutMap(evt) || !map.options['zoomable']) {
        return false;
      }
      var container = map._containerDOM;
      var origin = map._checkZoomOrigin(getEventContainerPoint(evt, container));
      if (map.options['seamlessZoom']) {
        if (!this._zooming) {
          this._trackPadSuspect = 0;
          this._ensureTrackpad = false;
        }
        return this._seamless(evt, origin);
      } else {
        return this._interval(evt, origin);
      }
    };
    _proto._seamless = function _seamless(evt, origin) {
      var value = evt.deltaMode === window.WheelEvent.DOM_DELTA_LINE ? evt.deltaY * 60 : evt.deltaY;
      if (value % wheelZoomDelta !== 0) {
        if (!this._ensureTrackpad) {
          if (Math.abs(value) < 60) {
            this._trackPadSuspect++;
          } else {
            this._trackPadSuspect = 0;
          }
          if (this._trackPadSuspect >= 2) {
            this._ensureTrackpad = true;
          }
        }
        if (this._ensureTrackpad) {
          value *= 14;
        }
      }
      if (evt.shiftKey && value) value = value / 4;
      this._lastWheelEvent = evt;
      this._delta -= value;
      if (!this._zooming && this._delta) {
        var map = this.target;
        this._zoomOrigin = origin;
        map.onZoomStart(null, origin);
      }
      this._start();
    };
    _proto._start = function _start() {
      if (!this._delta) return;
      this._zooming = true;
      var map = this.target;
      if (!this._active) {
        map.getRenderer().callInNextFrame(this._thisScrollZoom);
        this._active = true;
      }
    };
    _proto._scrollZoom = function _scrollZoom() {
      var _this2 = this;
      this._active = false;
      if (!this._delta) {
        return;
      }
      var zoomRate = Math.abs(this._delta) > wheelZoomDelta ? this._wheelZoomRate : this._defaultZoomRate;
      var scale = maxScalePerFrame / (1 + Math.exp(-Math.abs(this._delta * zoomRate)));
      if (this._delta < 0 && scale !== 0) {
        scale = 1 / scale;
      }
      var map = this.target;
      var zoom = map.getZoom();
      var targetZoom = map.getZoomForScale(scale, zoom, true);
      this._delta = 0;
      map.onZooming(targetZoom, this._zoomOrigin);
      if (this._timeout) {
        clearTimeout(this._timeout);
      }
      this._timeout = setTimeout(function () {
        _this2._zooming = false;
        delete _this2._timeout;
        map.onZoomEnd(map.getZoom(), _this2._zoomOrigin);
      }, 210);
    };
    _proto._interval = function _interval(evt, origin) {
      var _this3 = this;
      var map = this.target;
      if (this._zooming) {
        this._requesting++;
        return false;
      }
      this._requesting = 0;
      var levelValue = (evt.deltaY ? evt.deltaY * -1 : evt.wheelDelta ? evt.wheelDelta : evt.detail) > 0 ? 1 : -1;
      if (evt.detail) {
        levelValue *= -1;
      }
      var zoom = map.getZoom();
      var nextZoom = zoom + levelValue;
      nextZoom = map._checkZoom(levelValue > 0 ? Math.ceil(nextZoom) : Math.floor(nextZoom));
      if (nextZoom === zoom) {
        return false;
      }
      this._zooming = true;
      if (!this._delta) {
        map.onZoomStart(null, origin);
        this._origin = origin;
        this._delta = levelValue;
        this._startZoom = map.getZoom();
      }
      var duration = 90;
      map._animateTo({
        'zoom': nextZoom - this._delta * 1 / 2,
        'around': this._origin
      }, {
        'continueOnViewChanged': true,
        'easing': 'linear',
        'duration': duration,
        'wheelZoom': true
      }, function (frame) {
        if (frame.state.playState !== 'finished') {
          if (frame.state.playState !== 'running') {
            delete _this3._zooming;
            delete _this3._requesting;
          }
          return;
        }
        if (_this3._requesting < 1 || Math.abs(nextZoom - _this3._startZoom) > 2 || nextZoom === map.getMaxZoom() || nextZoom === map.getMinZoom()) {
          map._animateTo({
            'zoom': nextZoom,
            'around': _this3._origin
          }, {
            'continueOnViewChanged': true,
            'duration': 100
          }, function (frame) {
            if (frame.state.playState !== 'running') {
              delete _this3._zooming;
              delete _this3._requesting;
            }
          });
          delete _this3._startZoom;
          delete _this3._origin;
          delete _this3._delta;
          _this3._requesting = 0;
        } else if (!isNil(_this3._requesting)) {
          delete _this3._zooming;
          _this3._onWheelScroll(evt);
        }
      });
      return false;
    };
    return MapScrollWheelZoomHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'scrollWheelZoom': true,
    'seamlessZoom': true
  });
  Map$1.addOnLoadHook('addHandler', 'scrollWheelZoom', MapScrollWheelZoomHandler);

  var MapTouchZoomHandler = function (_Handler) {
    _inheritsLoose(MapTouchZoomHandler, _Handler);
    function MapTouchZoomHandler() {
      return _Handler.apply(this, arguments) || this;
    }
    var _proto = MapTouchZoomHandler.prototype;
    _proto.addHooks = function addHooks() {
      addDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart, this);
    };
    _proto.removeHooks = function removeHooks() {
      removeDomEvent(this.target.getContainer(), 'touchstart', this._onTouchStart);
    };
    _proto._onTouchStart = function _onTouchStart(event) {
      var map = this.target;
      if (!event.touches || event.touches.length < 2) {
        return;
      }
      var container = map.getContainer();
      var p1 = getEventContainerPoint(event.touches[0], container),
        p2 = getEventContainerPoint(event.touches[1], container);
      this.preY = p1.y;
      this._startP1 = p1;
      this._startP2 = p2;
      this._startDist = p1.distanceTo(p2);
      this._startVector = p1.sub(p2);
      this._startZoom = map.getZoom();
      this._startBearing = map.getBearing();
      off(document, 'touchmove', this._onTouchMove, this);
      off(document, 'touchend', this._onTouchEnd, this);
      addDomEvent(document, 'touchmove', this._onTouchMove, this);
      addDomEvent(document, 'touchend', this._onTouchEnd, this);
      if (map.options['preventTouch']) {
        preventDefault(event);
      }
      map._fireEvent('touchactstart');
    };
    _proto._onTouchMove = function _onTouchMove(event) {
      var map = this.target;
      if (!event.touches || event.touches.length < 2) {
        return;
      }
      var container = map.getContainer(),
        p1 = getEventContainerPoint(event.touches[0], container),
        p2 = getEventContainerPoint(event.touches[1], container),
        d1 = p1.sub(this._startP1),
        d2 = p2.sub(this._startP2),
        vector = p1.sub(p2),
        scale = p1.distanceTo(p2) / this._startDist,
        bearing = vector.angleWith(this._startVector) * 180 / Math.PI,
        preY = this.preY || p1.y,
        pitch = (preY - p1.y) * 0.4;
      this.preY = p1.y;
      var param = {
        'domEvent': event,
        'mousePos': [p1, p2]
      };
      if (!this.mode) {
        if (map.options['touchRotate'] && Math.abs(bearing) > 8) {
          this.mode = map.options['touchZoomRotate'] ? 'rotate_zoom' : 'rotate';
        } else if (map.options['touchPitch'] && d1.y * d2.y > 0 && Math.abs(d1.y) > 10 && Math.abs(d2.y) > 10) {
          this.mode = 'pitch';
        } else if (map.options['zoomable'] && map.options['touchZoom'] && Math.abs(1 - scale) > 0.15) {
          this.mode = map.options['touchZoomRotate'] && map.options['touchRotate'] ? 'rotate_zoom' : 'zoom';
        }
        this._startTouching(param);
      }
      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
        this._scale = scale;
        var res = map._getResolution(this._startZoom) / scale;
        var zoom = map.getZoomFromRes(res);
        map.onZooming(zoom, this._Origin);
      }
      if (this.mode === 'rotate' || this.mode === 'rotate_zoom') {
        map._setBearing(this._startBearing + bearing);
        map.onDragRotating(param);
      } else if (this.mode === 'pitch') {
        map._setPitch(map.getPitch() + pitch);
        map.onDragRotating(param);
      }
      map._fireEvent('touchactinging');
    };
    _proto._startTouching = function _startTouching(param) {
      var map = this.target;
      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
        var size = map.getSize();
        this._Origin = new Point(size['width'] / 2, size['height'] / 2);
        map.onZoomStart(null, this._Origin);
      }
      if (this.mode === 'rotate' || this.mode === 'pitch' || this.mode === 'rotate_zoom') {
        map.onDragRotateStart(param);
      }
    };
    _proto._onTouchEnd = function _onTouchEnd(event) {
      delete this.preY;
      var map = this.target;
      off(document, 'touchmove', this._onTouchMove, this);
      off(document, 'touchend', this._onTouchEnd, this);
      if (this.mode === 'zoom' || this.mode === 'rotate_zoom') {
        var scale = this._scale;
        var res = map._getResolution(this._startZoom) / scale;
        var zoom = map.getZoomFromRes(res);
        map.onZoomEnd(zoom, this._Origin);
      }
      if (this.mode === 'pitch' || this.mode === 'rotate' || this.mode === 'rotate_zoom') {
        map.onDragRotateEnd({
          'domEvent': event
        });
      }
      delete this.mode;
      map._fireEvent('touchactend');
    };
    return MapTouchZoomHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'touchGesture': true,
    'touchZoom': true,
    'touchPitch': true,
    'touchRotate': true,
    'touchZoomRotate': false
  });
  Map$1.addOnLoadHook('addHandler', 'touchGesture', MapTouchZoomHandler);

  var KEY = '__anim_player';
  var Easing = {
    outExpo: function outExpo(x) {
      return x === 1 ? 1 : 1 - Math.pow(2, -10 * x);
    },
    outQuint: function outQuint(x) {
      return 1 - Math.pow(1 - x, 5);
    },
    in: function _in(t) {
      return Math.pow(t, 2);
    },
    out: function out(t) {
      return 1 - Easing.in(1 - t);
    },
    inAndOut: function inAndOut(t) {
      return 3 * t * t - 2 * t * t * t;
    },
    linear: function linear(t) {
      return t;
    },
    upAndDown: function upAndDown(t) {
      if (t < 0.5) {
        return Easing.inAndOut(2 * t);
      } else {
        return 1 - Easing.inAndOut(2 * (t - 0.5));
      }
    }
  };
  var Frame = function () {
    function Frame(state, styles) {
      this.state = state;
      this.styles = styles;
    }
    _createClass(Frame, [{
      key: "playState",
      get: function get() {
        return this.state.playState;
      }
    }, {
      key: "symbol",
      get: function get() {
        return this.styles.symbol;
      }
    }]);
    return Frame;
  }();
  var Player = function Player(animation, options, onFrame, target) {
    this._animation = animation;
    this.options = options;
    this._onFrame = onFrame;
    this.playState = 'idle';
    this.ready = true;
    this.finished = false;
    this.target = target;
  };
  var Animation = {
    speed: {
      'slow': 2000,
      'normal': 1000,
      'fast': 500
    },
    _resolveStyles: function _resolveStyles(styles) {
      if (!styles) {
        return null;
      }
      function resolveChild(child) {
        if (!Array.isArray(child)) {
          return Animation._resolveStyles(child);
        }
        var start = [],
          d = [],
          dest = [];
        for (var i = 0; i < child.length; i++) {
          var _styles = Animation._resolveStyles(child[i]);
          if (_styles) {
            start.push(_styles[0]);
            d.push(_styles[1]);
            dest.push(_styles[2]);
          }
        }
        if (!start.length) {
          return null;
        } else {
          return [start, d, dest];
        }
      }
      function resolveVal(val) {
        var values = val;
        var clazz;
        if (!Array.isArray(val)) {
          if (isNumber(val)) {
            values = [0, val];
          } else if (val instanceof Point || val instanceof Coordinate) {
            clazz = val.constructor;
            values = [new clazz(0, 0), val];
          } else {
            values = [val, val];
          }
        }
        var v1 = values[0],
          v2 = values[1];
        if (isNumber(v1) && isNumber(v2)) {
          if (v1 === v2) {
            return null;
          }
          return [v1, v2 - v1, v2];
        } else if (Array.isArray(v1) && isNumber(v1[0]) || v1 instanceof Coordinate || v1 instanceof Point) {
          if (Array.isArray(v1)) {
            v1 = new Coordinate(v1);
            v2 = new Coordinate(v2);
          } else {
            clazz = v1.constructor;
            v1 = new clazz(v1);
            v2 = new clazz(v2);
          }
          if (v1.equals(v2)) {
            return null;
          }
          return [v1, v2.sub(v1), v2];
        } else {
          return [v1, v2, v2];
        }
      }
      function isChild(val) {
        if (!Array.isArray(val) && val.constructor === Object) {
          return true;
        } else if (Array.isArray(val) && val[0].constructor === Object) {
          return true;
        }
        return false;
      }
      var d = {},
        start = {},
        dest = {};
      for (var p in styles) {
        if (styles.hasOwnProperty(p)) {
          var values = styles[p];
          if (!values) {
            continue;
          } else if (Array.isArray(values)) {
            if (isNil(values[0]) || isNil(values[1])) {
              continue;
            }
          }
          var childStyles = void 0;
          if (isChild(values)) {
            childStyles = resolveChild(values);
          } else {
            childStyles = resolveVal(values);
          }
          if (childStyles) {
            start[p] = childStyles[0];
            d[p] = childStyles[1];
            dest[p] = childStyles[2];
          }
        }
      }
      return [start, d, dest];
    },
    framing: function framing(styles, options) {
      if (!options) {
        options = {};
      }
      var easing = options['easing'] ? Easing[options['easing']] : Easing.linear;
      if (!easing) {
        easing = Easing.linear;
      }
      var dStyles, startStyles, destStyles;
      styles = Animation._resolveStyles(styles);
      if (styles) {
        startStyles = styles[0];
        dStyles = styles[1];
        destStyles = styles[2];
      }
      var deltaStyles = function deltaStyles(delta, _startStyles, _dStyles) {
        if (!_startStyles || !_dStyles) {
          return null;
        }
        var result = {};
        for (var p in _dStyles) {
          if (_dStyles.hasOwnProperty(p)) {
            if (_startStyles[p] === destStyles[p]) {
              result[p] = _startStyles[p];
              continue;
            }
            var s = _startStyles[p],
              d = _dStyles[p];
            if (isNumber(d)) {
              result[p] = s + delta * d;
            } else if (Array.isArray(d)) {
              var children = [];
              for (var i = 0; i < d.length; i++) {
                children.push(deltaStyles(delta, s[i], d[i]));
              }
              result[p] = children;
            } else {
              var clazz = d.constructor;
              if (clazz === Object) {
                result[p] = deltaStyles(delta, s, d);
              } else if (s instanceof Point || s instanceof Coordinate) {
                result[p] = s.add(d.multi(delta));
              } else {
                result[p] = d;
              }
            }
          }
        }
        return result;
      };
      return function (elapsed, duration) {
        var state, d;
        if (elapsed < 0) {
          state = {
            'playState': 'idle',
            'delta': 0
          };
          d = startStyles;
        } else if (elapsed < duration) {
          var delta = easing(elapsed / duration);
          state = {
            'playState': 'running',
            'delta': delta
          };
          d = deltaStyles(delta, startStyles, dStyles);
        } else {
          state = {
            'playState': 'finished',
            'delta': 1
          };
          d = destStyles;
        }
        state['startStyles'] = startStyles;
        state['destStyles'] = destStyles;
        state['progress'] = elapsed;
        state['remainingMs'] = duration - elapsed;
        return new Frame(state, d);
      };
    },
    _requestAnimFrame: function _requestAnimFrame(fn) {
      if (!this._frameQueue) {
        this._frameQueue = [];
      }
      this._frameQueue.push(fn);
      this._a();
    },
    _a: function _a() {
      if (!this._animationFrameId) {
        this._animationFrameId = requestAnimFrame(Animation._frameFn);
      }
    },
    _run: function _run() {
      if (this._frameQueue.length) {
        var running = this._frameQueue;
        this._frameQueue = [];
        for (var i = 0, len = running.length; i < len; i++) {
          running[i]();
        }
        if (this._frameQueue.length) {
          this._animationFrameId = requestAnimFrame(Animation._frameFn);
        } else {
          delete this._animationFrameId;
        }
      }
    },
    animate: function animate(styles, options, step, target) {
      if (!options) {
        options = {};
      }
      var animation = Animation.framing(styles, options);
      var player = new Player(animation, options, step, target);
      return player;
    }
  };
  Animation._frameFn = Animation._run.bind(Animation);
  extend(Player.prototype, {
    _prepare: function _prepare() {
      var options = this.options;
      var duration = options['speed'] || options['duration'];
      if (isString(duration)) {
        duration = Animation.speed[duration];
        if (!duration) {
          duration = +duration;
        }
      }
      if (!duration) {
        duration = Animation.speed['normal'];
      }
      this.duration = duration;
      this._framer = options['framer'] || Animation._requestAnimFrame.bind(Animation);
    },
    play: function play() {
      if (this.playState !== 'idle' && this.playState !== 'paused' || this.target && this.target[KEY]) {
        return this;
      }
      if (this.target) {
        this.target[KEY] = 1;
      }
      if (this.playState === 'idle') {
        this.currentTime = 0;
        this._prepare();
      }
      var t = now();
      if (!this.startTime) {
        var options = this.options;
        this.startTime = options['startTime'] ? options['startTime'] : t;
      }
      this._playStartTime = Math.max(t, this.startTime);
      if (this.playState === 'paused') {
        this._playStartTime -= this.currentTime;
      }
      this.playState = 'running';
      this._run();
      return this;
    },
    pause: function pause() {
      if (this.playState === 'paused') {
        return this;
      }
      this.playState = 'paused';
      this._run();
      return this;
    },
    cancel: function cancel() {
      if (this.playState === 'idle') {
        return this;
      }
      this.playState = 'idle';
      this.finished = false;
      this._run();
      return this;
    },
    finish: function finish() {
      if (this.playState === 'finished') {
        return this;
      }
      this.playState = 'finished';
      this.finished = true;
      this._run();
      return this;
    },
    reverse: function reverse() {},
    _run: function _run() {
      var _this = this;
      var onFrame = this._onFrame;
      var t = now();
      var elapsed = t - this._playStartTime;
      if (this.options['repeat'] && elapsed >= this.duration) {
        this._playStartTime = t;
        elapsed = 0;
      }
      if (this.playState !== 'running') {
        if (this.target) {
          delete this.target[KEY];
        }
        if (onFrame) {
          if (this.playState === 'finished') {
            elapsed = this.duration;
          } else if (this.playState === 'idle') {
            elapsed = 0;
          }
          var _frame = this._animation(elapsed, this.duration);
          _frame.state.playState = this.playState;
          onFrame(_frame);
        }
        return;
      }
      var frame = this._animation(elapsed, this.duration);
      this.playState = frame.state['playState'];
      if (this.playState !== 'running' && this.target) {
        delete this.target[KEY];
      }
      if (this.playState === 'idle') {
        if (this.startTime > t) {
          setTimeout(this._run.bind(this), this.startTime - t);
        }
      } else if (this.playState === 'running') {
        this._framer(function () {
          if (_this.playState !== 'running') {
            return;
          }
          _this.currentTime = elapsed;
          if (onFrame) {
            onFrame(frame);
          }
          _this._run();
        });
      } else if (this.playState === 'finished') {
        this.finished = true;
        if (onFrame) {
          onFrame(frame);
        }
      }
    }
  });
  var animate = Animation.animate;

  var Animation$1 = /*#__PURE__*/Object.freeze({
    Animation: Animation,
    Easing: Easing,
    Player: Player,
    Frame: Frame,
    animate: animate
  });

  var simplify = createCommonjsModule(function (module) {
    (function () {
      function getSqDist(p1, p2) {
        var dx = p1.x - p2.x,
          dy = p1.y - p2.y;
        return dx * dx + dy * dy;
      }
      function getSqSegDist(p, p1, p2) {
        var x = p1.x,
          y = p1.y,
          dx = p2.x - x,
          dy = p2.y - y;
        if (dx !== 0 || dy !== 0) {
          var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy);
          if (t > 1) {
            x = p2.x;
            y = p2.y;
          } else if (t > 0) {
            x += dx * t;
            y += dy * t;
          }
        }
        dx = p.x - x;
        dy = p.y - y;
        return dx * dx + dy * dy;
      }
      function simplifyRadialDist(points, sqTolerance) {
        var prevPoint = points[0],
          newPoints = [prevPoint],
          point;
        for (var i = 1, len = points.length; i < len; i++) {
          point = points[i];
          if (getSqDist(point, prevPoint) > sqTolerance) {
            newPoints.push(point);
            prevPoint = point;
          }
        }
        if (prevPoint !== point) newPoints.push(point);
        return newPoints;
      }
      function simplifyDPStep(points, first, last, sqTolerance, simplified) {
        var maxSqDist = sqTolerance,
          index;
        for (var i = first + 1; i < last; i++) {
          var sqDist = getSqSegDist(points[i], points[first], points[last]);
          if (sqDist > maxSqDist) {
            index = i;
            maxSqDist = sqDist;
          }
        }
        if (maxSqDist > sqTolerance) {
          if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified);
          simplified.push(points[index]);
          if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified);
        }
      }
      function simplifyDouglasPeucker(points, sqTolerance) {
        var last = points.length - 1;
        var simplified = [points[0]];
        simplifyDPStep(points, 0, last, sqTolerance, simplified);
        simplified.push(points[last]);
        return simplified;
      }
      function simplify(points, tolerance, highestQuality) {
        if (points.length <= 2) return points;
        var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;
        points = highestQuality ? points : simplifyRadialDist(points, sqTolerance);
        points = simplifyDouglasPeucker(points, sqTolerance);
        return points;
      }
      {
        module.exports = simplify;
        module.exports.default = simplify;
      }
    })();
  });

  var options$3 = {
    'smoothness': 0,
    'enableClip': true,
    'enableSimplify': true,
    'simplifyTolerance': 2,
    'symbol': {
      'lineColor': '#000',
      'lineWidth': 2,
      'lineOpacity': 1,
      'polygonFill': '#fff',
      'polygonOpacity': 1,
      'opacity': 1
    }
  };
  var Path = function (_Geometry) {
    _inheritsLoose(Path, _Geometry);
    function Path() {
      return _Geometry.apply(this, arguments) || this;
    }
    var _proto = Path.prototype;
    _proto.animateShow = function animateShow(options, cb) {
      var _this = this;
      if (options === void 0) {
        options = {};
      }
      if (this._showPlayer) {
        this._showPlayer.finish();
      }
      if (isFunction(options)) {
        options = {};
        cb = options;
      }
      var coordinates = this.getCoordinates();
      if (coordinates.length === 0) {
        return this;
      }
      this._animIdx = 0;
      this._animLenSoFar = 0;
      this.show();
      var isPolygon = !!this.getShell;
      var animCoords = isPolygon ? this.getShell().concat(this.getShell()[0]) : coordinates;
      var projection = this._getProjection();
      var prjAnimCoords = projection.projectCoords(animCoords, this.options['antiMeridian']);
      this._prjAniShowCenter = this._getPrjExtent().getCenter();
      this._aniShowCenter = projection.unproject(this._prjAniShowCenter);
      var duration = options['duration'] || 1000,
        easing = options['easing'] || 'out';
      this.setCoordinates([]);
      var length = 0;
      if (prjAnimCoords.length) {
        prjAnimCoords[0]._distance = 0;
      }
      for (var i = 1; i < prjAnimCoords.length; i++) {
        var distance = prjAnimCoords[i].distanceTo(prjAnimCoords[i - 1]);
        prjAnimCoords[i]._distance = distance;
        length += distance;
      }
      this._tempCoord = new Coordinate(0, 0);
      this._tempPrjCoord = new Point(0, 0);
      var player = this._showPlayer = Animation.animate({
        't': duration
      }, {
        'duration': duration,
        'easing': easing
      }, function (frame) {
        if (!_this.getMap()) {
          if (player.playState !== 'finished') {
            player.finish();
            if (cb) {
              var _coordinates = _this.getCoordinates();
              cb(frame, _coordinates[_coordinates.length - 1]);
            }
          }
          return;
        }
        var currentCoord = _this._drawAnimShowFrame(frame.styles.t, duration, length, animCoords, prjAnimCoords);
        if (frame.state.playState === 'finished') {
          delete _this._showPlayer;
          delete _this._aniShowCenter;
          delete _this._prjAniShowCenter;
          delete _this._animIdx;
          delete _this._animLenSoFar;
          delete _this._animTailRatio;
          delete _this._tempCoord;
          delete _this._tempPrjCoord;
          _this.setCoordinates(coordinates);
        }
        if (cb) {
          cb(frame, currentCoord);
        }
      }, this);
      player.play();
      return player;
    };
    _proto._drawAnimShowFrame = function _drawAnimShowFrame(t, duration, length, coordinates, prjCoords) {
      if (t === 0) {
        return coordinates[0];
      }
      var targetLength = t / duration * length;
      var segLen = 0;
      var i, l;
      for (i = this._animIdx + 1, l = prjCoords.length; i < l; i++) {
        segLen = prjCoords[i]._distance;
        if (this._animLenSoFar + segLen > targetLength) {
          break;
        }
        this._animLenSoFar += segLen;
      }
      this._animIdx = i - 1;
      if (this._animIdx >= l - 1) {
        this.setCoordinates(coordinates);
        return coordinates[coordinates.length - 1];
      }
      var idx = this._animIdx;
      var p1 = prjCoords[idx],
        p2 = prjCoords[idx + 1],
        span = targetLength - this._animLenSoFar,
        r = span / segLen;
      this._animTailRatio = r;
      var x = p1.x + (p2.x - p1.x) * r,
        y = p1.y + (p2.y - p1.y) * r;
      this._tempPrjCoord.x = x;
      this._tempPrjCoord.y = y;
      var lastCoord = this._tempPrjCoord;
      var c1 = coordinates[idx],
        c2 = coordinates[idx + 1];
      var cx = c1.x + (c2.x - c1.x) * r,
        cy = c1.y + (c2.y - c1.y) * r;
      this._tempCoord.x = cx;
      this._tempCoord.y = cy;
      var targetCoord = this._tempCoord;
      var isPolygon = !!this.getShell;
      if (!isPolygon && this.options['smoothness'] > 0) {
        var animCoords = [],
          prjAnimCoords = [];
        for (var _i = 0; _i <= this._animIdx; _i++) {
          animCoords.push(coordinates[_i]);
          prjAnimCoords.push(prjCoords[_i]);
        }
        animCoords.push(targetCoord, targetCoord);
        prjAnimCoords.push(lastCoord, lastCoord);
        this.setCoordinates(animCoords);
        this._setPrjCoordinates(prjAnimCoords);
      } else {
        var _animCoords = coordinates.slice(0, this._animIdx + 1);
        _animCoords.push(targetCoord);
        var _prjAnimCoords = prjCoords.slice(0, this._animIdx + 1);
        _prjAnimCoords.push(lastCoord);
        if (isPolygon) {
          this.setCoordinates([this._aniShowCenter].concat(_animCoords));
          this._setPrjCoordinates([this._prjAniShowCenter].concat(_prjAnimCoords));
        } else {
          this.setCoordinates(_animCoords);
          this._setPrjCoordinates(_prjAnimCoords);
        }
      }
      return targetCoord;
    };
    _proto._getCenterInExtent = function _getCenterInExtent(extent, coordinates, clipFn) {
      var meExtent = this.getExtent();
      if (!extent.intersects(meExtent)) {
        return null;
      }
      var clipped = clipFn(coordinates, extent);
      if (clipped.length === 0) {
        return null;
      }
      var sumx = 0,
        sumy = 0,
        counter = 0;
      clipped.forEach(function (part) {
        if (Array.isArray(part)) {
          part.forEach(function (c) {
            if (c.point) {
              c = c.point;
            }
            sumx += c.x;
            sumy += c.y;
            counter++;
          });
        } else {
          if (part.point) {
            part = part.point;
          }
          sumx += part.x;
          sumy += part.y;
          counter++;
        }
      });
      var c = new Coordinate(sumx, sumy)._multi(1 / counter);
      c.count = counter;
      return c;
    };
    _proto._getPath2DPoints = function _getPath2DPoints(prjCoords, disableSimplify, res) {
      if (!isArrayHasData(prjCoords)) {
        return [];
      }
      var map = this.getMap(),
        isSimplify = !disableSimplify && this._shouldSimplify(),
        tolerance = this.options['simplifyTolerance'] * map._getResolution(),
        isMulti = Array.isArray(prjCoords[0]);
      delete this._simplified;
      if (isSimplify && !isMulti) {
        var count = prjCoords.length;
        prjCoords = simplify(prjCoords, tolerance, false);
        this._simplified = prjCoords.length < count;
      }
      if (!res) {
        res = map._getResolution();
      }
      if (!Array.isArray(prjCoords)) {
        return map._prjToPointAtRes(prjCoords, res);
      } else {
        var resultPoints = [];
        var glPointKey = '_glPt';
        if (!Array.isArray(prjCoords[0])) {
          resultPoints = getPointsResultPts(prjCoords, glPointKey);
          return map._prjsToPointsAtRes(prjCoords, res, resultPoints);
        }
        var pts = [];
        for (var i = 0, len = prjCoords.length; i < len; i++) {
          var prjCoord = prjCoords[i];
          resultPoints = getPointsResultPts(prjCoord, glPointKey);
          var pt = map._prjsToPointsAtRes(prjCoord, res, resultPoints);
          pts.push(pt);
        }
        return pts;
      }
    };
    _proto._shouldSimplify = function _shouldSimplify() {
      var layer = this.getLayer();
      var hasAltitude = layer.options['enableAltitude'];
      return layer && layer.options['enableSimplify'] && !hasAltitude && this.options['enableSimplify'] && !this._showPlayer;
    };
    _proto._setPrjCoordinates = function _setPrjCoordinates(prjPoints) {
      this._prjCoords = prjPoints;
      this.onShapeChanged();
    };
    _proto._getPrjCoordinates = function _getPrjCoordinates() {
      this._verifyProjection();
      if (!this._prjCoords && this._getProjection()) {
        this._prjCoords = this._projectCoords(this._coordinates);
      }
      return this._prjCoords;
    };
    _proto._updateCache = function _updateCache() {
      this._clearCache();
      var projection = this._getProjection();
      if (!projection) {
        return;
      }
      if (this._prjCoords) {
        this._coordinates = this._unprojectCoords(this._getPrjCoordinates());
      }
    };
    _proto._clearProjection = function _clearProjection() {
      this._prjCoords = null;
      _Geometry.prototype._clearProjection.call(this);
    };
    _proto._projectCoords = function _projectCoords(points) {
      var projection = this._getProjection();
      if (projection) {
        return projection.projectCoords(points, this.options['antiMeridian']);
      }
      return [];
    };
    _proto._unprojectCoords = function _unprojectCoords(prjPoints) {
      var projection = this._getProjection();
      if (projection) {
        return projection.unprojectCoords(prjPoints);
      }
      return [];
    };
    _proto._computeCenter = function _computeCenter() {
      var ring = this._coordinates;
      if (!isArrayHasData(ring)) {
        return null;
      }
      var sumx = 0,
        sumy = 0,
        counter = 0;
      var size = ring.length;
      for (var i = 0; i < size; i++) {
        if (ring[i]) {
          if (isNumber(ring[i].x) && isNumber(ring[i].y)) {
            sumx += ring[i].x;
            sumy += ring[i].y;
            counter++;
          }
        }
      }
      return new Coordinate(sumx / counter, sumy / counter);
    };
    _proto._computeExtent = function _computeExtent() {
      var shell = this._coordinates;
      if (!isArrayHasData(shell)) {
        return null;
      }
      var rings = [shell];
      if (this.hasHoles && this.hasHoles()) {
        rings.push.apply(rings, this.getHoles());
      }
      return this._coords2Extent(rings, this._getProjection());
    };
    _proto._computePrjExtent = function _computePrjExtent() {
      var coords = [this._getPrjCoordinates()];
      if (this.hasHoles && this.hasHoles()) {
        coords.push.apply(coords, this._getPrjHoles());
      }
      return this._coords2Extent(coords);
    };
    _proto._get2DLength = function _get2DLength() {
      var vertexes = this._getPath2DPoints(this._getPrjCoordinates(), true);
      var len = 0;
      for (var i = 1, l = vertexes.length; i < l; i++) {
        len += vertexes[i].distanceTo(vertexes[i - 1]);
      }
      return len;
    };
    _proto._hitTestTolerance = function _hitTestTolerance() {
      var symbol = this._getInternalSymbol();
      var w;
      if (Array.isArray(symbol)) {
        w = 0;
        for (var i = 0; i < symbol.length; i++) {
          if (isNumber(symbol[i]['lineWidth'])) {
            if (symbol[i]['lineWidth'] > w) {
              w = symbol[i]['lineWidth'];
            }
          }
        }
      } else {
        w = symbol['lineWidth'];
      }
      return _Geometry.prototype._hitTestTolerance.call(this) + (isNumber(w) ? w / 2 : 1.5);
    };
    _proto._coords2Extent = function _coords2Extent(coords, proj) {
      if (!coords || coords.length === 0 || Array.isArray(coords[0]) && coords[0].length === 0) {
        return null;
      }
      var result = new Extent(proj);
      for (var i = 0, l = coords.length; i < l; i++) {
        for (var j = 0, ll = coords[i].length; j < ll; j++) {
          result._combine(coords[i][j]);
        }
      }
      return result;
    };
    return Path;
  }(Geometry);
  Path.mergeOptions(options$3);

  var JSON_TYPE = 'Polygon';
  var Polygon = function (_Path) {
    _inheritsLoose(Polygon, _Path);
    function Polygon(coordinates, opts) {
      var _this;
      _this = _Path.call(this, opts) || this;
      _this.type = 'Polygon';
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      return _this;
    }
    var _proto = Polygon.prototype;
    _proto.getOutline = function getOutline() {
      var painter = this._getPainter();
      if (!painter) {
        return null;
      }
      var extent = this.getExtent();
      return new Polygon(extent.toArray(), {
        symbol: {
          'lineWidth': 1,
          'lineColor': '6b707b'
        }
      });
    };
    _proto.setCoordinates = function setCoordinates(coordinates) {
      if (!coordinates) {
        this._coordinates = null;
        this._holes = null;
        this._projectRings();
        return this;
      }
      var rings = Coordinate.toCoordinates(coordinates);
      var len = rings.length;
      if (!Array.isArray(rings[0])) {
        this._coordinates = this._trimRing(rings);
      } else {
        this._coordinates = this._trimRing(rings[0]);
        if (len > 1) {
          var holes = [];
          for (var i = 1; i < len; i++) {
            if (!rings[i]) {
              continue;
            }
            holes.push(this._trimRing(rings[i]));
          }
          this._holes = holes;
        } else {
          this._holes = null;
        }
      }
      this._projectRings();
      return this;
    };
    _proto.getCoordinates = function getCoordinates() {
      if (!this._coordinates) {
        return [];
      }
      var holes = this.getHoles();
      var rings = [this._copyAndCloseRing(this._coordinates)];
      for (var i = 0, l = holes.length; i < l; i++) {
        rings.push(this._copyAndCloseRing(holes[i]));
      }
      return rings;
    };
    _proto.getCenterInExtent = function getCenterInExtent(extent) {
      return this._getCenterInExtent(extent, this.getShell(), clipPolygon);
    };
    _proto.getShell = function getShell() {
      return this._coordinates || [];
    };
    _proto.getHoles = function getHoles() {
      return this._holes || [];
    };
    _proto.hasHoles = function hasHoles() {
      return this.getHoles().length > 0;
    };
    _proto._projectRings = function _projectRings() {
      if (!this.getMap()) {
        this.onShapeChanged();
        return;
      }
      this._prjCoords = this._projectCoords(this._coordinates);
      this._prjHoles = this._projectCoords(this._holes);
      this.onShapeChanged();
    };
    _proto._setPrjCoordinates = function _setPrjCoordinates(prjCoords) {
      this._prjCoords = prjCoords;
      this.onShapeChanged();
    };
    _proto._cleanRing = function _cleanRing(ring) {
      for (var i = ring.length - 1; i >= 0; i--) {
        if (!ring[i]) {
          ring.splice(i, 1);
        }
      }
    };
    _proto._checkRing = function _checkRing(ring) {
      this._cleanRing(ring);
      if (!ring || !isArrayHasData(ring)) {
        return false;
      }
      var lastPoint = ring[ring.length - 1];
      var isClose = true;
      if (ring[0].x !== lastPoint.x || ring[0].y !== lastPoint.y) {
        isClose = false;
      }
      return isClose;
    };
    _proto._trimRing = function _trimRing(ring) {
      var isClose = this._checkRing(ring);
      if (isArrayHasData(ring) && isClose) {
        ring.splice(ring.length - 1, 1);
      }
      return ring;
    };
    _proto._copyAndCloseRing = function _copyAndCloseRing(ring) {
      ring = ring.slice(0);
      var isClose = this._checkRing(ring);
      if (isArrayHasData(ring) && !isClose) {
        ring.push(ring[0].copy());
        return ring;
      } else {
        return ring;
      }
    };
    _proto._getPrjShell = function _getPrjShell() {
      if (this.getJSONType() === JSON_TYPE) {
        return this._getPrjCoordinates();
      }
      this._verifyProjection();
      if (this._getProjection() && !this._prjShell) {
        this._prjShell = this._projectCoords(this._getShell ? this._getShell() : this.getShell());
      }
      return this._prjShell;
    };
    _proto._getPrjHoles = function _getPrjHoles() {
      var projection = this._getProjection();
      this._verifyProjection();
      if (projection && !this._prjHoles) {
        this._prjHoles = this._projectCoords(this.getHoles());
      }
      return this._prjHoles;
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
      var rings = this.getCoordinates();
      if (!isArrayHasData(rings)) {
        return 0;
      }
      var result = 0;
      for (var i = 0, len = rings.length; i < len; i++) {
        result += measurer.measureLength(rings[i]);
      }
      return result;
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea(measurer) {
      var rings = this.getCoordinates();
      if (!isArrayHasData(rings)) {
        return 0;
      }
      var result = measurer.measureArea(rings[0]);
      for (var i = 1, len = rings.length; i < len; i++) {
        result -= measurer.measureArea(rings[i]);
      }
      return result;
    };
    _proto._updateCache = function _updateCache() {
      _Path.prototype._updateCache.call(this);
      if (this._prjHoles) {
        this._holes = this._unprojectCoords(this._getPrjHoles());
      }
    };
    _proto._clearCache = function _clearCache() {
      delete this._prjShell;
      return _Path.prototype._clearCache.call(this);
    };
    _proto._clearProjection = function _clearProjection() {
      if (this._prjHoles) {
        this._prjHoles = null;
      }
      if (this._prjShell) {
        this._prjShell = null;
      }
      _Path.prototype._clearProjection.call(this);
    };
    return Polygon;
  }(Path);
  Polygon.registerJSONType(JSON_TYPE);

  function CenterMixin (Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      var _proto = _class.prototype;
      _proto.getCoordinates = function getCoordinates() {
        return this._coordinates;
      };
      _proto.setCoordinates = function setCoordinates(coordinates) {
        var center = coordinates instanceof Coordinate ? coordinates : new Coordinate(coordinates);
        this._coordinates = center;
        if (!this.getMap()) {
          this._dirtyCoords = true;
          this.onPositionChanged();
          return this;
        }
        var projection = this._getProjection();
        this._setPrjCoordinates(projection.project(this._coordinates));
        return this;
      };
      _proto._getCenter2DPoint = function _getCenter2DPoint(res) {
        var map = this.getMap();
        if (!map) {
          return null;
        }
        var pcenter = this._getPrjCoordinates();
        if (!pcenter) {
          return null;
        }
        if (!res) {
          res = map._getResolution();
        }
        return map._prjToPointAtRes(pcenter, res);
      };
      _proto._getPrjCoordinates = function _getPrjCoordinates() {
        var projection = this._getProjection();
        this._verifyProjection();
        if (!this._pcenter && projection) {
          if (this._coordinates) {
            this._pcenter = projection.project(this._coordinates);
          }
        }
        return this._pcenter;
      };
      _proto._setPrjCoordinates = function _setPrjCoordinates(pcenter) {
        this._pcenter = pcenter;
        this.onPositionChanged();
      };
      _proto._updateCache = function _updateCache() {
        this._clearCache();
        var projection = this._getProjection();
        if (this._pcenter && projection) {
          this._coordinates = projection.unproject(this._pcenter);
        }
      };
      _proto._clearProjection = function _clearProjection() {
        this._pcenter = null;
        _Base.prototype._clearProjection.call(this);
      };
      _proto._computeCenter = function _computeCenter() {
        return this._coordinates ? this._coordinates.copy() : null;
      };
      return _class;
    }(Base);
  }

  var TEMP_EXTENT$6 = new PointExtent();
  var options$4 = {
    'symbol': {
      'markerType': 'path',
      'markerPath': [{
        'path': 'M8 23l0 0 0 0 0 0 0 0 0 0c-4,-5 -8,-10 -8,-14 0,-5 4,-9 8,-9l0 0 0 0c4,0 8,4 8,9 0,4 -4,9 -8,14z M3,9 a5,5 0,1,0,0,-0.9Z',
        'fill': '#DE3333'
      }],
      'markerPathWidth': 16,
      'markerPathHeight': 23,
      'markerWidth': 24,
      'markerHeight': 34
    },
    'hitTestForEvent': false,
    'collision': true
  };
  var Marker = function (_CenterMixin) {
    _inheritsLoose(Marker, _CenterMixin);
    function Marker(coordinates, opts) {
      var _this;
      _this = _CenterMixin.call(this, opts) || this;
      _this.type = 'Point';
      _this.isPoint = true;
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      return _this;
    }
    var _proto = Marker.prototype;
    _proto.getOutline = function getOutline() {
      var coord = this.getCoordinates();
      var extent = this.getContainerExtent();
      var anchor = this.getMap().coordToContainerPoint(coord);
      return new Marker(coord, {
        'symbol': {
          'markerType': 'square',
          'markerWidth': extent.getWidth(),
          'markerHeight': extent.getHeight(),
          'markerLineWidth': 1,
          'markerLineColor': '6b707b',
          'markerFill': 'rgba(0, 0, 0, 0)',
          'markerDx': extent.xmin - (anchor.x - extent.getWidth() / 2),
          'markerDy': extent.ymin - (anchor.y - extent.getHeight() / 2)
        }
      });
    };
    _proto.setSymbol = function setSymbol() {
      var _CenterMixin$prototyp;
      delete this._fixedExtent;
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
      return (_CenterMixin$prototyp = _CenterMixin.prototype.setSymbol).call.apply(_CenterMixin$prototyp, [this].concat(args));
    };
    _proto._getSizeSymbol = function _getSizeSymbol(symbol) {
      var s = {};
      var dynamic = false;
      var dynamicSize = false;
      for (var i = 0; i < DYNAMIC_SYMBOL_PROPS.length; i++) {
        var v = symbol[DYNAMIC_SYMBOL_PROPS[i]];
        if (isNil(v)) {
          continue;
        }
        if (!dynamic && isFunctionDefinition(v)) {
          dynamic = true;
          dynamicSize = true;
        }
        s[DYNAMIC_SYMBOL_PROPS[i]] = v;
      }
      for (var _i = 0; _i < SIZE_SYMBOL_PROPS.length; _i++) {
        var _v = symbol[SIZE_SYMBOL_PROPS[_i]];
        if (isNil(_v)) {
          continue;
        }
        if (!dynamic && isFunctionDefinition(_v)) {
          dynamic = true;
        }
        s[SIZE_SYMBOL_PROPS[_i]] = _v;
      }
      var sizeSymbol;
      if (dynamic) {
        sizeSymbol = loadGeoSymbol(s, this);
        if (dynamicSize) {
          sizeSymbol._dynamic = true;
        }
      } else {
        sizeSymbol = s;
      }
      return sizeSymbol;
    };
    _proto._setExternSymbol = function _setExternSymbol(symbol) {
      if (!this._symbol) {
        delete this._fixedExtent;
      }
      return _CenterMixin.prototype._setExternSymbol.call(this, symbol);
    };
    _proto._isDynamicSize = function _isDynamicSize() {
      return this._sizeSymbol && this._sizeSymbol._dynamic;
    };
    _proto._getFixedExtent = function _getFixedExtent() {
      if (this._fixedExtent && !this._isDynamicSize()) {
        return this._fixedExtent;
      }
      this._fixedExtent = this._fixedExtent || new PointExtent();
      this._fixedExtent.set(null, null, null, null);
      var symbol = this._sizeSymbol;
      if (!symbol) {
        return this._fixedExtent;
      }
      var renderer = this.getLayer() && this.getLayer().getRenderer();
      var resources = renderer && renderer.resources;
      var textDesc = this.getTextDesc();
      if (Array.isArray(symbol)) {
        TEMP_EXTENT$6.set(Infinity, Infinity, -Infinity, -Infinity);
        for (var i = 0; i < symbol.length; i++) {
          if (!symbol[i]) {
            continue;
          }
          this._fixedExtent._combine(getMarkerFixedExtent(TEMP_EXTENT$6, symbol[i], resources, textDesc && textDesc[i]));
        }
      } else {
        this._fixedExtent = getMarkerFixedExtent(this._fixedExtent, symbol, resources, textDesc);
      }
      return this._fixedExtent;
    };
    _proto._isVectorMarker = function _isVectorMarker() {
      var symbol = this._getInternalSymbol();
      if (Array.isArray(symbol)) {
        return false;
      }
      return isVectorSymbol(symbol);
    };
    _proto._canEdit = function _canEdit() {
      var symbol = this._getInternalSymbol();
      if (Array.isArray(symbol)) {
        return false;
      }
      return isVectorSymbol(symbol) || isPathSymbol(symbol) || isImageSymbol(symbol);
    };
    _proto._containsPoint = function _containsPoint(point, t) {
      var extent = this.getContainerExtent();
      if (t) {
        extent = extent.expand(t);
      }
      if (extent.contains(point)) {
        if (this.options['hitTestForEvent']) {
          return _CenterMixin.prototype._containsPoint.call(this, point, t);
        } else {
          return true;
        }
      } else {
        return false;
      }
    };
    _proto._computeExtent = function _computeExtent() {
      return computeExtent.call(this, 'getCenter');
    };
    _proto._computePrjExtent = function _computePrjExtent() {
      return computeExtent.call(this, '_getPrjCoordinates');
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength() {
      return 0;
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      return 0;
    };
    _proto._getSprite = function _getSprite(resources, canvasClass) {
      if (this._getPainter()) {
        return this._getPainter().getSprite(resources, canvasClass);
      }
      return new Painter(this).getSprite(resources, canvasClass);
    };
    return Marker;
  }(CenterMixin(Geometry));
  Marker.mergeOptions(options$4);
  Marker.registerJSONType('Marker');
  function computeExtent(fn) {
    var coordinates = this[fn]();
    if (!coordinates) {
      return null;
    }
    return new Extent(coordinates, coordinates, this._getProjection());
  }

  var options$5 = {
    'arrowStyle': null,
    'arrowPlacement': 'vertex-last'
  };
  var LineString = function (_Path) {
    _inheritsLoose(LineString, _Path);
    function LineString(coordinates, options) {
      var _this;
      _this = _Path.call(this, options) || this;
      _this.type = 'LineString';
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      return _this;
    }
    var _proto = LineString.prototype;
    _proto.getOutline = function getOutline() {
      return Polygon.prototype.getOutline.call(this);
    };
    _proto.setCoordinates = function setCoordinates(coordinates) {
      if (!coordinates) {
        this._coordinates = null;
        this._setPrjCoordinates(null);
        return this;
      }
      this._coordinates = Coordinate.toCoordinates(coordinates);
      if (this.getMap()) {
        this._setPrjCoordinates(this._projectCoords(this._coordinates));
      } else {
        this.onShapeChanged();
      }
      return this;
    };
    _proto.getCoordinates = function getCoordinates() {
      return this._coordinates || [];
    };
    _proto.getCenterInExtent = function getCenterInExtent(extent) {
      return this._getCenterInExtent(extent, this.getCoordinates(), clipLine);
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength(measurer) {
      return measurer.measureLength(this.getCoordinates());
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      return 0;
    };
    return LineString;
  }(Path);
  LineString.mergeOptions(options$5);
  LineString.registerJSONType('LineString');

  var TEMP_EXTENT$7 = new PointExtent();
  var GeometryCollection = function (_Geometry) {
    _inheritsLoose(GeometryCollection, _Geometry);
    function GeometryCollection(geometries, opts) {
      var _this;
      _this = _Geometry.call(this, opts) || this;
      _this.type = 'GeometryCollection';
      _this.setGeometries(geometries);
      return _this;
    }
    var _proto = GeometryCollection.prototype;
    _proto.getContainerExtent = function getContainerExtent(out) {
      var extent = out || new PointExtent();
      this.forEach(function (geo) {
        extent._combine(geo.getContainerExtent(TEMP_EXTENT$7));
      });
      return extent;
    };
    _proto.setGeometries = function setGeometries(_geometries) {
      var geometries = this._checkGeometries(_geometries || []);
      var symbol = this._getSymbol();
      var options = this.config();
      var properties = this.getProperties();
      for (var i = geometries.length - 1; i >= 0; i--) {
        geometries[i]._initOptions(options);
        geometries[i]._setParent(this);
        geometries[i]._setEventParent(this);
        if (symbol) {
          geometries[i].setSymbol(symbol);
        }
        if (properties) {
          geometries[i].setProperties(properties);
        }
      }
      this._geometries = geometries;
      if (this.getLayer()) {
        this._bindGeometriesToLayer();
        this.onShapeChanged();
      }
      return this;
    };
    _proto.getGeometries = function getGeometries() {
      return this._geometries || [];
    };
    _proto.forEach = function forEach(fn, context) {
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        if (!context) {
          fn(geometries[i], i);
        } else {
          fn.call(context, geometries[i], i);
        }
      }
      return this;
    };
    _proto.filter = function filter(fn, context) {
      if (!fn) {
        return new GeometryCollection();
      }
      var selected = [];
      var isFn = isFunction(fn);
      var filter = isFn ? fn : createFilter(fn);
      this.forEach(function (geometry) {
        var g = isFn ? geometry : getFilterFeature(geometry);
        if (context ? filter.call(context, g) : filter(g)) {
          selected.push(geometry);
        }
      }, this);
      return new GeometryCollection(selected);
    };
    _proto.translate = function translate(offset) {
      if (!offset) {
        return this;
      }
      if (this.isEmpty()) {
        return this;
      }
      var args = arguments;
      this.forEach(function (geometry) {
        if (geometry && geometry.translate) {
          geometry.translate.apply(geometry, args);
        }
      });
      return this;
    };
    _proto.isEmpty = function isEmpty$$1() {
      return !isArrayHasData(this.getGeometries());
    };
    _proto.remove = function remove() {
      this.forEach(function (geometry) {
        geometry._unbind();
      });
      return Geometry.prototype.remove.apply(this, arguments);
    };
    _proto.show = function show() {
      this.options['visible'] = true;
      this.forEach(function (geometry) {
        geometry.show();
      });
      return this;
    };
    _proto.hide = function hide() {
      this.options['visible'] = false;
      this.forEach(function (geometry) {
        geometry.hide();
      });
      return this;
    };
    _proto.onConfig = function onConfig(config) {
      this.forEach(function (geometry) {
        geometry.config(config);
      });
    };
    _proto.getSymbol = function getSymbol() {
      var s = _Geometry.prototype.getSymbol.call(this);
      if (!s) {
        var symbols = [];
        var is = false;
        this.forEach(function (g) {
          var symbol = g.getSymbol();
          if (symbol && !is) {
            is = true;
          }
          symbols.push(g.getSymbol());
        });
        if (is) {
          s = {
            'children': symbols
          };
        }
      }
      return s;
    };
    _proto.setSymbol = function setSymbol(s) {
      var _this2 = this;
      if (s && s['children']) {
        this._symbol = null;
        this.forEach(function (g, i) {
          g._eventSymbolProperties = _this2._eventSymbolProperties;
          g.setSymbol(s['children'][i]);
        });
      } else {
        var symbol = this._prepareSymbol(s);
        this._symbol = symbol;
        this.forEach(function (g) {
          g._eventSymbolProperties = _this2._eventSymbolProperties;
          g.setSymbol(symbol);
        });
      }
      this.onSymbolChanged();
      return this;
    };
    _proto._setExternSymbol = function _setExternSymbol(symbol) {
      symbol = this._prepareSymbol(symbol);
      this._externSymbol = symbol;
      this.forEach(function (geometry) {
        geometry._setExternSymbol(symbol);
      });
      this.onSymbolChanged();
      return this;
    };
    _proto._bindLayer = function _bindLayer() {
      _Geometry.prototype._bindLayer.apply(this, arguments);
      this._bindGeometriesToLayer();
    };
    _proto._bindGeometriesToLayer = function _bindGeometriesToLayer() {
      var layer = this.getLayer();
      this.forEach(function (geometry) {
        geometry._bindLayer(layer);
      });
    };
    _proto._checkGeometries = function _checkGeometries(geometries) {
      var invalidGeoError = 'The geometry added to collection is invalid.';
      geometries = Array.isArray(geometries) ? geometries : [geometries];
      var filterGeometries = [];
      for (var i = 0, l = geometries.length; i < l; i++) {
        var geometry = geometries[i];
        if (!geometry) {
          continue;
        }
        if (!this._checkGeo(geometry)) {
          console.error(invalidGeoError + ' Index: ' + i);
          continue;
        }
        if (isSelf(geometry)) {
          if (!Browser$1.isTest) {
            console.error(geometry, ' is GeometryCollection sub class,it Cannot be placed in GeometryCollection');
          }
          continue;
        }
        filterGeometries.push(geometry);
      }
      return filterGeometries;
    };
    _proto._checkGeo = function _checkGeo(geo) {
      return geo instanceof Geometry;
    };
    _proto._updateCache = function _updateCache() {
      this._clearCache();
      if (this.isEmpty()) {
        return;
      }
      this.forEach(function (geometry) {
        if (geometry && geometry._updateCache) {
          geometry._updateCache();
        }
      });
    };
    _proto._removePainter = function _removePainter() {
      if (this._painter) {
        this._painter.remove();
      }
      delete this._painter;
      this.forEach(function (geometry) {
        geometry._removePainter();
      });
    };
    _proto._computeCenter = function _computeCenter(projection) {
      if (!projection || this.isEmpty()) {
        return null;
      }
      var sumX = 0,
        sumY = 0,
        counter = 0;
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        var center = geometries[i]._computeCenter(projection);
        if (center) {
          sumX += center.x;
          sumY += center.y;
          counter++;
        }
      }
      if (counter === 0) {
        return null;
      }
      return new Coordinate(sumX / counter, sumY / counter);
    };
    _proto._containsPoint = function _containsPoint(point, t) {
      if (this.isEmpty()) {
        return false;
      }
      delete this._pickGeometryIndex;
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (geometries[i]._containsPoint(point, t)) {
          this._pickGeometryIndex = i;
          return true;
        }
      }
      return false;
    };
    _proto._hitTestTolerance = function _hitTestTolerance() {
      var geometries = this.getGeometries();
      var hitTolerance = 0;
      for (var i = 0, len = geometries.length; i < len; i++) {
        var t = geometries[i]._hitTestTolerance();
        hitTolerance = Math.max(hitTolerance, t);
      }
      return hitTolerance;
    };
    _proto._computeExtent = function _computeExtent(projection) {
      return computeExtent$1.call(this, projection, '_computeExtent');
    };
    _proto._computePrjExtent = function _computePrjExtent(projection) {
      return computeExtent$1.call(this, projection, '_computePrjExtent');
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength(projection) {
      if (!projection || this.isEmpty()) {
        return 0;
      }
      var geometries = this.getGeometries();
      var result = 0;
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        result += geometries[i]._computeGeodesicLength(projection);
      }
      return result;
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea(projection) {
      if (!projection || this.isEmpty()) {
        return 0;
      }
      var geometries = this.getGeometries();
      var result = 0;
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        result += geometries[i]._computeGeodesicArea(projection);
      }
      return result;
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var children = [];
      if (!this.isEmpty()) {
        var geometries = this.getGeometries();
        for (var i = 0, l = geometries.length; i < l; i++) {
          if (!geometries[i]) {
            continue;
          }
          children.push(geometries[i]._exportGeoJSONGeometry());
        }
      }
      return {
        'type': 'GeometryCollection',
        'geometries': children
      };
    };
    _proto._toJSON = function _toJSON(options) {
      options = extend({}, options);
      var feature = {
        'type': 'Feature',
        'geometry': {
          'type': 'GeometryCollection',
          'geometries': this.getGeometries().filter(function (geo) {
            return geo && geo._toJSON;
          }).map(function (geo) {
            var json = geo._toJSON();
            if (json.subType) {
              return json;
            }
            return geo._exportGeoJSONGeometry();
          })
        }
      };
      var id = this.getId();
      if (!isNil(id)) {
        feature['id'] = id;
      }
      var properties;
      if (isNil(options['properties']) || options['properties']) {
        properties = this._exportProperties();
      }
      feature['properties'] = properties;
      options.feature = feature;
      return options;
    };
    _proto._clearProjection = function _clearProjection() {
      if (this.isEmpty()) {
        return;
      }
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        geometries[i]._clearProjection();
      }
    };
    _proto._getConnectPoints = function _getConnectPoints() {
      var extent = this.getExtent();
      var anchors = [new Coordinate(extent.xmin, extent.ymax), new Coordinate(extent.xmax, extent.ymin), new Coordinate(extent.xmin, extent.ymin), new Coordinate(extent.xmax, extent.ymax)];
      return anchors;
    };
    _proto._getExternalResources = function _getExternalResources() {
      if (this.isEmpty()) {
        return [];
      }
      var geometries = this.getGeometries(),
        resources = [];
      var cache = {};
      var symbol, res, key;
      for (var i = 0, l = geometries.length; i < l; i++) {
        if (!geometries[i]) {
          continue;
        }
        symbol = geometries[i]._getInternalSymbol();
        res = getExternalResources(symbol);
        for (var ii = 0, ll = res.length; ii < ll; ii++) {
          key = res[ii].join();
          if (!cache[key]) {
            resources.push(res[ii]);
            cache[key] = 1;
          }
        }
      }
      return resources;
    };
    _proto.startEdit = function startEdit(opts) {
      var _this3 = this;
      if (this.isEmpty()) {
        return this;
      }
      if (!opts) {
        opts = {};
      }
      if (opts['symbol']) {
        this._originalSymbol = this.getSymbol();
        this.setSymbol(opts['symbol']);
      }
      this._draggbleBeforeEdit = this.options['draggable'];
      this.config('draggable', false);
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        geometries[i].startEdit(opts);
      }
      this._editing = true;
      var layer = this.getLayer();
      var needShadow = layer && layer.options['renderer'] === 'canvas';
      if (needShadow) {
        this.hide();
      }
      setTimeout(function () {
        _this3.fire('editstart');
      }, 1);
      return this;
    };
    _proto.endEdit = function endEdit() {
      if (this.isEmpty()) {
        return this;
      }
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        geometries[i].endEdit();
      }
      if (this._originalSymbol) {
        this.setSymbol(this._originalSymbol);
        delete this._originalSymbol;
      }
      this._editing = false;
      this.show();
      this.config('draggable', this._draggbleBeforeEdit);
      this.fire('editend');
      return this;
    };
    _proto.isEditing = function isEditing() {
      if (!this._editing) {
        return false;
      }
      return true;
    };
    return GeometryCollection;
  }(Geometry);
  GeometryCollection.registerJSONType('GeometryCollection');
  function computeExtent$1(projection, fn) {
    if (this.isEmpty()) {
      return null;
    }
    var extent = new Extent();
    var geometries = this.getGeometries();
    for (var i = 0, l = geometries.length; i < l; i++) {
      if (!geometries[i]) {
        continue;
      }
      var e = geometries[i][fn](projection);
      if (e) {
        extent._combine(e);
      }
    }
    return extent;
  }
  function isSelf(geom) {
    return geom instanceof GeometryCollection;
  }

  var MultiGeometry = function (_GeometryCollection) {
    _inheritsLoose(MultiGeometry, _GeometryCollection);
    function MultiGeometry(geoType, type, data, options) {
      var _this;
      _this = _GeometryCollection.call(this, null, options) || this;
      _this.GeometryType = geoType;
      _this.type = type;
      _this._initData(data);
      return _this;
    }
    var _proto = MultiGeometry.prototype;
    _proto.getCoordinates = function getCoordinates() {
      var coordinates = [];
      var geometries = this.getGeometries();
      for (var i = 0, l = geometries.length; i < l; i++) {
        var child = geometries[i];
        coordinates.push(child.getShell && child.getJSONType() !== 'Polygon' ? [child.getShell()] : child.getCoordinates());
      }
      return coordinates;
    };
    _proto.setCoordinates = function setCoordinates(coordinates) {
      coordinates = coordinates || [];
      var geometries = [];
      for (var i = 0, l = coordinates.length; i < l; i++) {
        var g = new this.GeometryType(coordinates[i], this.config());
        geometries.push(g);
      }
      this.setGeometries(geometries);
      return this;
    };
    _proto._initData = function _initData(data) {
      data = data || [];
      if (data.length) {
        if (data[0] instanceof this.GeometryType) {
          this.setGeometries(data);
        } else {
          this.setCoordinates(data);
        }
      }
    };
    _proto._checkGeo = function _checkGeo(geo) {
      return geo instanceof this.GeometryType;
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var points = this.getCoordinates();
      var coordinates = Coordinate.toNumberArrays(points);
      return {
        'type': this.getType(),
        'coordinates': coordinates
      };
    };
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options)
      };
    };
    return MultiGeometry;
  }(GeometryCollection);

  var MultiPoint = function (_MultiGeometry) {
    _inheritsLoose(MultiPoint, _MultiGeometry);
    function MultiPoint(data, opts) {
      return _MultiGeometry.call(this, Marker, 'MultiPoint', data, opts) || this;
    }
    var _proto = MultiPoint.prototype;
    _proto.findClosest = function findClosest(coordinate) {
      if (!coordinate) {
        return null;
      }
      var coords = this.getCoordinates();
      var hit = null;
      var max = Infinity;
      coords.forEach(function (c) {
        var dist = distanceTo(c, coordinate);
        if (dist < max) {
          hit = c;
          max = dist;
        }
      });
      return hit;
    };
    return MultiPoint;
  }(MultiGeometry);
  MultiPoint.registerJSONType('MultiPoint');
  function distanceTo(p0, p1) {
    var x = p1.x - p0.x,
      y = p1.y - p0.y;
    return Math.sqrt(x * x + y * y);
  }

  var MultiPath = function (_MultiGeometry) {
    _inheritsLoose(MultiPath, _MultiGeometry);
    function MultiPath() {
      return _MultiGeometry.apply(this, arguments) || this;
    }
    var _proto = MultiPath.prototype;
    _proto.getCenterInExtent = function getCenterInExtent(extent) {
      var children = this.getGeometries();
      var sumx = 0,
        sumy = 0,
        counter = 0;
      children.forEach(function (l) {
        var c = l.getCenterInExtent(extent);
        if (c) {
          sumx += c.x * c.count;
          sumy += c.y * c.count;
          counter += c.count;
        }
      });
      if (counter === 0) {
        return null;
      }
      return new Coordinate(sumx, sumy)._multi(1 / counter);
    };
    return MultiPath;
  }(MultiGeometry);

  var MultiLineString = function (_MultiPath) {
    _inheritsLoose(MultiLineString, _MultiPath);
    function MultiLineString(data, options) {
      return _MultiPath.call(this, LineString, 'MultiLineString', data, options) || this;
    }
    return MultiLineString;
  }(MultiPath);
  MultiLineString.registerJSONType('MultiLineString');

  var MultiPolygon = function (_MultiPath) {
    _inheritsLoose(MultiPolygon, _MultiPath);
    function MultiPolygon(data, opts) {
      return _MultiPath.call(this, Polygon, 'MultiPolygon', data, opts) || this;
    }
    return MultiPolygon;
  }(MultiPath);
  MultiPolygon.registerJSONType('MultiPolygon');

  var types$1 = {
    'Marker': Marker,
    'LineString': LineString,
    'Polygon': Polygon,
    'MultiPoint': MultiPoint,
    'MultiLineString': MultiLineString,
    'MultiPolygon': MultiPolygon
  };
  var GeoJSON = {
    toGeometry: function toGeometry(geoJSON, foreachFn) {
      if (isString(geoJSON)) {
        geoJSON = parseJSON(geoJSON);
      }
      if (Array.isArray(geoJSON)) {
        var resultGeos = [];
        for (var i = 0, len = geoJSON.length; i < len; i++) {
          var geo = GeoJSON._convert(geoJSON[i], foreachFn);
          if (Array.isArray(geo)) {
            pushIn(resultGeos, geo);
          } else {
            resultGeos.push(geo);
          }
        }
        return resultGeos;
      } else {
        var resultGeo = GeoJSON._convert(geoJSON, foreachFn);
        return resultGeo;
      }
    },
    toGeometryAsync: function toGeometryAsync(geoJSON, foreachFn, countPerTime) {
      if (countPerTime === void 0) {
        countPerTime = 2000;
      }
      if (isString(geoJSON)) {
        geoJSON = parseJSON(geoJSON);
      }
      return new Promise$1(function (resolve) {
        var resultGeos = [];
        if (geoJSON && (Array.isArray(geoJSON) || Array.isArray(geoJSON.features))) {
          var pageSize = isNumber(countPerTime) ? Math.round(countPerTime) : 2000;
          var features = geoJSON.features || geoJSON;
          var count = Math.ceil(features.length / pageSize);
          var page = 1;
          var run = function run() {
            var startIndex = (page - 1) * pageSize,
              endIndex = page * pageSize;
            var fs = features.slice(startIndex, endIndex);
            var geos = GeoJSON.toGeometry(fs, foreachFn);
            page++;
            return geos;
          };
          runTaskAsync({
            count: count,
            run: run
          }).then(function (geoList) {
            for (var i = 0, len = geoList.length; i < len; i++) {
              var geo = geoList[i];
              if (!geo) {
                continue;
              }
              if (Array.isArray(geo)) {
                pushIn(resultGeos, geo);
              } else {
                resultGeos.push(geo);
              }
            }
            resolve(resultGeos);
          });
        } else {
          var geo = GeoJSON.toGeometry(geoJSON, foreachFn);
          resolve(geo);
        }
      });
    },
    _convert: function _convert(json, foreachFn) {
      if (!json || isNil(json['type'])) {
        return null;
      }
      var type = json['type'];
      if (type === 'Feature') {
        var g = json['geometry'];
        var geometry = GeoJSON._convert(g);
        if (!geometry) {
          return null;
        }
        geometry.setId(json['id']);
        geometry.setProperties(json['properties']);
        if (foreachFn) {
          foreachFn(geometry);
        }
        return geometry;
      } else if (type === 'FeatureCollection') {
        var features = json['features'];
        if (!features) {
          return null;
        }
        return GeoJSON.toGeometry(features, foreachFn);
      } else if (['Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'].indexOf(type) >= 0) {
        var clazz = type === 'Point' ? 'Marker' : type;
        var result = new types$1[clazz](json['coordinates']);
        if (foreachFn) {
          foreachFn(result);
        }
        return result;
      } else if (type === 'GeometryCollection') {
        var geometries = json['geometries'];
        if (!isArrayHasData(geometries)) {
          var _result2 = new GeometryCollection();
          if (foreachFn) {
            foreachFn(_result2);
          }
          return _result2;
        }
        var mGeos = [];
        var size = geometries.length;
        for (var i = 0; i < size; i++) {
          if (geometries[i].subType) {
            mGeos.push(Geometry.getJSONClass(geometries[i].subType).fromJSON(geometries[i]));
          } else {
            mGeos.push(GeoJSON._convert(geometries[i]));
          }
        }
        var _result = new GeometryCollection(mGeos);
        if (foreachFn) {
          foreachFn(_result);
        }
        return _result;
      }
      return null;
    },
    _isGeoJSON: function _isGeoJSON(json) {
      if (!json) {
        return false;
      }
      json = json || {};
      if (Array.isArray(json) && json.length) {
        return GeoJSON.isGeoJSON(json[0]);
      }
      var type = json.type;
      if (!type) {
        return false;
      }
      if (GEOJSON_TYPES.indexOf(type) === -1) {
        return false;
      }
      var _json = json,
        features = _json.features,
        geometries = _json.geometries,
        geometry = _json.geometry,
        coordinates = _json.coordinates;
      if (coordinates && Array.isArray(coordinates)) {
        return true;
      }
      if (Array.isArray(geometries)) {
        return true;
      }
      if (Array.isArray(features)) {
        return true;
      }
      if (geometry) {
        var _coordinates = geometry.coordinates;
        if (_coordinates && Array.isArray(_coordinates)) {
          return true;
        }
      }
      return false;
    }
  };

  var options$6 = {
    'numberOfShellPoints': 60
  };
  var Circle = function (_CenterMixin) {
    _inheritsLoose(Circle, _CenterMixin);
    Circle.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var circle = new Circle(json['coordinates'], json['radius'], json['options']);
      circle.setProperties(feature['properties']);
      return circle;
    };
    function Circle(coordinates, radius, opts) {
      var _this;
      _this = _CenterMixin.call(this, null, opts) || this;
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      _this._radius = radius;
      return _this;
    }
    var _proto = Circle.prototype;
    _proto.getRadius = function getRadius() {
      return this._radius;
    };
    _proto.setRadius = function setRadius(radius) {
      this._radius = radius;
      this.onShapeChanged();
      return this;
    };
    _proto.getShell = function getShell() {
      var measurer = this._getMeasurer(),
        center = this.getCoordinates(),
        numberOfPoints = this.options['numberOfShellPoints'],
        radius = this.getRadius();
      var shell = [];
      var rad, dx, dy;
      for (var i = 0, len = numberOfPoints - 1; i < len; i++) {
        rad = 360 * i / len * Math.PI / 180;
        dx = radius * Math.cos(rad);
        dy = radius * Math.sin(rad);
        var vertex = measurer.locate(center, dx, dy);
        vertex.z = center.z;
        shell.push(vertex);
      }
      shell.push(shell[0]);
      return shell;
    };
    _proto.getHoles = function getHoles() {
      return [];
    };
    _proto.animateShow = function animateShow() {
      return this.show();
    };
    _proto._containsPoint = function _containsPoint(point, tolerance) {
      var map = this.getMap();
      if (map.getPitch()) {
        return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
      }
      var center = map._pointToContainerPoint(this._getCenter2DPoint()),
        size = this.getSize(),
        t = this._hitTestTolerance() + (tolerance || 0),
        se = center.add(size.width / 2, size.height / 2);
      return withInEllipse(point, center, se, t);
    };
    _proto._computePrjExtent = function _computePrjExtent(projection) {
      var minmax = this._getMinMax(projection);
      if (!minmax) {
        return null;
      }
      var pcenter = this._getPrjCoordinates();
      var pminmax = minmax.map(function (c) {
        return projection.project(c);
      });
      var leftx = pminmax[0].x - pcenter.x;
      var rightx = pminmax[1].x - pcenter.x;
      var topy = pminmax[2].y - pcenter.y;
      var bottomy = pminmax[3].y - pcenter.y;
      return new Extent(pcenter.add(leftx, topy), pcenter.add(rightx, bottomy));
    };
    _proto._computeExtent = function _computeExtent(measurer) {
      var minmax = this._getMinMax(measurer);
      if (!minmax) {
        return null;
      }
      return new Extent(minmax[0].x, minmax[2].y, minmax[1].x, minmax[3].y, this._getProjection());
    };
    _proto._getMinMax = function _getMinMax(measurer) {
      if (!measurer || !this._coordinates || isNil(this._radius)) {
        return null;
      }
      var radius = this._radius;
      var p1 = measurer.locate(this._coordinates, -radius, 0),
        p2 = measurer.locate(this._coordinates, radius, 0),
        p3 = measurer.locate(this._coordinates, 0, radius),
        p4 = measurer.locate(this._coordinates, 0, -radius);
      return [p1, p2, p3, p4];
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength() {
      if (isNil(this._radius)) {
        return 0;
      }
      return Math.PI * 2 * this._radius;
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      if (isNil(this._radius)) {
        return 0;
      }
      return Math.PI * Math.pow(this._radius, 2);
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
      return {
        'type': 'Polygon',
        'coordinates': coordinates
      };
    };
    _proto._toJSON = function _toJSON(options) {
      var center = this.getCenter();
      var opts = extend({}, options);
      opts.geometry = false;
      var feature = this.toGeoJSON(opts);
      feature['geometry'] = {
        'type': 'Polygon'
      };
      return {
        'feature': feature,
        'subType': 'Circle',
        'coordinates': [center.x, center.y],
        'radius': this.getRadius()
      };
    };
    return Circle;
  }(CenterMixin(Polygon));
  Circle.mergeOptions(options$6);
  Circle.registerJSONType('Circle');

  var options$7 = {
    'numberOfShellPoints': 81
  };
  var Ellipse = function (_CenterMixin) {
    _inheritsLoose(Ellipse, _CenterMixin);
    Ellipse.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var ellipse = new Ellipse(json['coordinates'], json['width'], json['height'], json['options']);
      ellipse.setProperties(feature['properties']);
      return ellipse;
    };
    function Ellipse(coordinates, width, height, opts) {
      var _this;
      _this = _CenterMixin.call(this, null, opts) || this;
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      _this.width = width;
      _this.height = height;
      return _this;
    }
    var _proto = Ellipse.prototype;
    _proto.getWidth = function getWidth() {
      return this.width;
    };
    _proto.setWidth = function setWidth(width) {
      this.width = width;
      this.onShapeChanged();
      return this;
    };
    _proto.getHeight = function getHeight() {
      return this.height;
    };
    _proto.setHeight = function setHeight(height) {
      this.height = height;
      this.onShapeChanged();
      return this;
    };
    _proto.getShell = function getShell() {
      if (this.isRotated()) {
        return this.getRotatedShell();
      }
      return this._getShell();
    };
    _proto._getShell = function _getShell() {
      var measurer = this._getMeasurer(),
        center = this.getCoordinates(),
        numberOfPoints = this.options['numberOfShellPoints'] - 1,
        width = this.getWidth(),
        height = this.getHeight();
      var shell = [];
      var s = Math.pow(width / 2, 2) * Math.pow(height / 2, 2),
        sx = Math.pow(width / 2, 2),
        sy = Math.pow(height / 2, 2);
      var deg, rad, dx, dy;
      for (var i = 0; i < numberOfPoints; i++) {
        deg = 360 * i / numberOfPoints;
        rad = deg * Math.PI / 180;
        dx = Math.sqrt(s / (sx * Math.pow(Math.tan(rad), 2) + sy));
        dy = Math.sqrt(s / (sy * Math.pow(1 / Math.tan(rad), 2) + sx));
        if (deg > 90 && deg < 270) {
          dx *= -1;
        }
        if (deg > 180 && deg < 360) {
          dy *= -1;
        }
        var vertex = measurer.locate(center, dx, dy);
        vertex.z = center.z;
        shell.push(vertex);
      }
      shell.push(shell[0].copy());
      return shell;
    };
    _proto._getPrjShell = function _getPrjShell() {
      var shell = _CenterMixin.prototype._getPrjShell.call(this);
      return this._rotatePrjCoordinates(shell);
    };
    _proto.getHoles = function getHoles() {
      return [];
    };
    _proto.animateShow = function animateShow() {
      return this.show();
    };
    _proto._containsPoint = function _containsPoint(point, tolerance) {
      var map = this.getMap();
      if (map.isTransforming()) {
        return _CenterMixin.prototype._containsPoint.call(this, point, tolerance);
      }
      var projection = map.getProjection();
      var t = this._hitTestTolerance() + (tolerance || 0),
        pps = projection.projectCoords([this._coordinates, map.locate(this._coordinates, this.getWidth() / 2, this.getHeight() / 2)], this.options['antiMeridian']),
        p0 = map._prjToContainerPoint(pps[0]),
        p1 = map._prjToContainerPoint(pps[1]);
      return withInEllipse(point, p0, p1, t);
    };
    _proto._computePrjExtent = function _computePrjExtent() {
      if (this.isRotated()) {
        return this._computeRotatedPrjExtent();
      }
      return Circle.prototype._computePrjExtent.apply(this, arguments);
    };
    _proto._computeExtent = function _computeExtent() {
      return Circle.prototype._computeExtent.apply(this, arguments);
    };
    _proto._getMinMax = function _getMinMax(measurer) {
      if (!measurer || !this._coordinates || isNil(this.width) || isNil(this.height)) {
        return null;
      }
      var width = this.getWidth(),
        height = this.getHeight();
      var p1 = measurer.locate(this._coordinates, -width / 2, 0),
        p2 = measurer.locate(this._coordinates, width / 2, 0),
        p3 = measurer.locate(this._coordinates, 0, -height / 2),
        p4 = measurer.locate(this._coordinates, 0, height / 2);
      return [p1, p2, p3, p4];
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength() {
      if (isNil(this.width) || isNil(this.height)) {
        return 0;
      }
      var longer = this.width > this.height ? this.width : this.height;
      return 2 * Math.PI * longer / 2 - 4 * Math.abs(this.width - this.height);
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      if (isNil(this.width) || isNil(this.height)) {
        return 0;
      }
      return Math.PI * this.width * this.height / 4;
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
      return {
        'type': 'Polygon',
        'coordinates': coordinates
      };
    };
    _proto._toJSON = function _toJSON(options) {
      var opts = extend({}, options);
      var center = this.getCenter();
      opts.geometry = false;
      var feature = this.toGeoJSON(opts);
      feature['geometry'] = {
        'type': 'Polygon'
      };
      return {
        'feature': feature,
        'subType': 'Ellipse',
        'coordinates': [center.x, center.y],
        'width': this.getWidth(),
        'height': this.getHeight()
      };
    };
    return Ellipse;
  }(CenterMixin(Polygon));
  Ellipse.mergeOptions(options$7);
  Ellipse.registerJSONType('Ellipse');

  var Rectangle = function (_Polygon) {
    _inheritsLoose(Rectangle, _Polygon);
    Rectangle.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var rect = new Rectangle(json['coordinates'], json['width'], json['height'], json['options']);
      rect.setProperties(feature['properties']);
      return rect;
    };
    function Rectangle(coordinates, width, height, opts) {
      var _this;
      _this = _Polygon.call(this, null, opts) || this;
      if (coordinates) {
        _this.setCoordinates(coordinates);
      }
      _this._width = width;
      _this._height = height;
      return _this;
    }
    var _proto = Rectangle.prototype;
    _proto.getCoordinates = function getCoordinates() {
      return this._coordinates;
    };
    _proto.setCoordinates = function setCoordinates(nw) {
      this._coordinates = nw instanceof Coordinate ? nw : new Coordinate(nw);
      if (!this._coordinates || !this.getMap()) {
        this.onPositionChanged();
        return this;
      }
      var projection = this._getProjection();
      this._setPrjCoordinates(projection.project(this._coordinates));
      return this;
    };
    _proto.getWidth = function getWidth() {
      return this._width;
    };
    _proto.setWidth = function setWidth(width) {
      this._width = width;
      this.onShapeChanged();
      return this;
    };
    _proto.getHeight = function getHeight() {
      return this._height;
    };
    _proto.setHeight = function setHeight(height) {
      this._height = height;
      this.onShapeChanged();
      return this;
    };
    _proto.getShell = function getShell() {
      if (this.isRotated()) {
        return this.getRotatedShell();
      }
      return this._getShell();
    };
    _proto._getShell = function _getShell() {
      var measurer = this._getMeasurer();
      var nw = this._coordinates;
      var map = this.getMap();
      var sx = 1,
        sy = -1;
      if (map) {
        var fExt = map.getFullExtent();
        if (fExt['left'] > fExt['right']) {
          sx = -1;
        }
        if (fExt['bottom'] > fExt['top']) {
          sy = 1;
        }
      }
      var points = [];
      points.push(nw);
      var p0 = measurer.locate(nw, sx * this._width, 0);
      p0.z = nw.z;
      points.push(p0);
      var p1 = measurer.locate(nw, sx * this._width, sy * this._height);
      p1.z = nw.z;
      points.push(p1);
      var p2 = measurer.locate(nw, 0, sy * this._height);
      points.push(p2);
      p2.z = nw.z;
      points.push(nw);
      return points;
    };
    _proto.getHoles = function getHoles() {
      return [];
    };
    _proto.animateShow = function animateShow() {
      return this.show();
    };
    _proto._getPrjCoordinates = function _getPrjCoordinates() {
      var projection = this._getProjection();
      this._verifyProjection();
      if (!this._pnw && projection) {
        if (this._coordinates) {
          this._pnw = projection.project(this._coordinates);
        }
      }
      return this._pnw;
    };
    _proto._setPrjCoordinates = function _setPrjCoordinates(pnw) {
      this._pnw = pnw;
      this.onPositionChanged();
    };
    _proto._getPrjShell = function _getPrjShell() {
      var shell = _Polygon.prototype._getPrjShell.call(this);
      var projection = this._getProjection();
      if (!projection.isSphere()) {
        return this._rotatePrjCoordinates(shell);
      }
      var sphereExtent = projection.getSphereExtent(),
        sx = sphereExtent.sx,
        sy = sphereExtent.sy;
      var circum = this._getProjection().getCircum();
      var nw = shell[0];
      for (var i = 1, l = shell.length; i < l; i++) {
        var p = shell[i];
        var dx = 0,
          dy = 0;
        if (sx * (nw.x - p.x) > 0) {
          dx = circum.x * sx;
        }
        if (sy * (nw.y - p.y) < 0) {
          dy = circum.y * sy;
        }
        shell[i]._add(dx, dy);
      }
      return this._rotatePrjCoordinates(shell);
    };
    _proto._updateCache = function _updateCache() {
      this._clearCache();
      var projection = this._getProjection();
      if (this._pnw && projection) {
        this._coordinates = projection.unproject(this._pnw);
      }
    };
    _proto._clearProjection = function _clearProjection() {
      this._pnw = null;
      _Polygon.prototype._clearProjection.call(this);
    };
    _proto._computeCenter = function _computeCenter(measurer) {
      return measurer.locate(this._coordinates, this._width / 2, -this._height / 2);
    };
    _proto._containsPoint = function _containsPoint(point, tolerance) {
      var map = this.getMap();
      if (map.isTransforming()) {
        return _Polygon.prototype._containsPoint.call(this, point, tolerance);
      }
      var t = isNil(tolerance) ? this._hitTestTolerance() : tolerance,
        r = map._getResolution() * t;
      var extent = this._getPrjExtent().expand(r);
      var p = map._containerPointToPrj(point);
      return extent.contains(p);
    };
    _proto._computePrjExtent = function _computePrjExtent(projection) {
      if (this.isRotated()) {
        return this._computeRotatedPrjExtent();
      }
      var se = this._getSouthEast(projection);
      if (!se) {
        return null;
      }
      var prjs = projection.projectCoords([new Coordinate(this._coordinates.x, se.y), new Coordinate(se.x, this._coordinates.y)], this.options['antiMeridian']);
      return new Extent(prjs[0], prjs[1]);
    };
    _proto._computeExtent = function _computeExtent(measurer) {
      var se = this._getSouthEast(measurer);
      if (!se) {
        return null;
      }
      return new Extent(this._coordinates, se, this._getProjection());
    };
    _proto._getSouthEast = function _getSouthEast(measurer) {
      if (!measurer || !this._coordinates || isNil(this._width) || isNil(this._height)) {
        return null;
      }
      var width = this.getWidth(),
        height = this.getHeight();
      var w = width,
        h = -height;
      if (measurer.fullExtent) {
        var fullExtent = measurer.fullExtent,
          sx = fullExtent.right > fullExtent.left ? 1 : -1,
          sy = fullExtent.top > fullExtent.bottom ? 1 : -1;
        w *= sx;
        h *= sy;
      }
      var rightPoint = measurer.locate(this._coordinates, w, 0);
      var bottomPoint = measurer.locate(this._coordinates, 0, h);
      rightPoint.y = bottomPoint.y;
      return rightPoint;
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength() {
      if (isNil(this._width) || isNil(this._height)) {
        return 0;
      }
      return 2 * (this._width + this._height);
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      if (isNil(this._width) || isNil(this._height)) {
        return 0;
      }
      return this._width * this._height;
    };
    _proto._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
      var coordinates = Coordinate.toNumberArrays([this.getShell()]);
      return {
        'type': 'Polygon',
        'coordinates': coordinates
      };
    };
    _proto._toJSON = function _toJSON(options) {
      var opts = extend({}, options);
      var nw = this.getCoordinates();
      opts.geometry = false;
      var feature = this.toGeoJSON(opts);
      feature['geometry'] = {
        'type': 'Polygon'
      };
      return {
        'feature': feature,
        'subType': 'Rectangle',
        'coordinates': [nw.x, nw.y],
        'width': this.getWidth(),
        'height': this.getHeight()
      };
    };
    return Rectangle;
  }(Polygon);
  Rectangle.registerJSONType('Rectangle');

  var options$8 = {
    'numberOfShellPoints': 60
  };
  var Sector = function (_Circle) {
    _inheritsLoose(Sector, _Circle);
    Sector.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var sector = new Sector(json['coordinates'], json['radius'], json['startAngle'], json['endAngle'], json['options']);
      sector.setProperties(feature['properties']);
      return sector;
    };
    function Sector(coordinates, radius, startAngle, endAngle, opts) {
      var _this;
      _this = _Circle.call(this, coordinates, radius, opts) || this;
      _this.startAngle = startAngle;
      _this.endAngle = endAngle;
      return _this;
    }
    var _proto = Sector.prototype;
    _proto.getStartAngle = function getStartAngle() {
      return this.startAngle;
    };
    _proto.setStartAngle = function setStartAngle(startAngle) {
      this.startAngle = startAngle;
      this.onShapeChanged();
      return this;
    };
    _proto.getEndAngle = function getEndAngle() {
      return this.endAngle;
    };
    _proto.setEndAngle = function setEndAngle(endAngle) {
      this.endAngle = endAngle;
      this.onShapeChanged();
      return this;
    };
    _proto.getShell = function getShell() {
      if (this.isRotated()) {
        return this.getRotatedShell();
      }
      return this._getShell();
    };
    _proto._getShell = function _getShell() {
      var measurer = this._getMeasurer(),
        center = this.getCoordinates(),
        numberOfPoints = this.options['numberOfShellPoints'] - 2,
        radius = this.getRadius(),
        shell = [center.copy()],
        startAngle = this.getStartAngle(),
        angle = this.getEndAngle() - startAngle;
      var rad, dx, dy;
      for (var i = 0; i < numberOfPoints; i++) {
        rad = (angle * i / (numberOfPoints - 1) + startAngle) * Math.PI / 180;
        dx = radius * Math.cos(rad);
        dy = radius * Math.sin(rad);
        var vertex = measurer.locate(center, dx, dy);
        vertex.z = center.z;
        shell.push(vertex);
      }
      shell.push(center.copy());
      return shell;
    };
    _proto.getRotateOffsetAngle = function getRotateOffsetAngle() {
      return 90;
    };
    _proto._getPrjShell = function _getPrjShell() {
      var shell = _Circle.prototype._getPrjShell.call(this);
      return this._rotatePrjCoordinates(shell);
    };
    _proto._computePrjExtent = function _computePrjExtent() {
      if (this.isRotated()) {
        return this._computeRotatedPrjExtent();
      }
      return Circle.prototype._computePrjExtent.apply(this, arguments);
    };
    _proto._containsPoint = function _containsPoint(point, tolerance) {
      var map = this.getMap();
      if (map.isTransforming()) {
        return _Circle.prototype._containsPoint.call(this, point, tolerance);
      }
      var center = map._pointToContainerPoint(this._getCenter2DPoint()),
        t = this._hitTestTolerance() + (tolerance || 0),
        size = this.getSize(),
        pc = center,
        pp = point,
        x = pp.x - pc.x,
        y = pc.y - pp.y,
        atan2 = Math.atan2(y, x),
        angle = atan2 < 0 ? (atan2 + 2 * Math.PI) * 360 / (2 * Math.PI) : atan2 * 360 / (2 * Math.PI);
      var sAngle = this.startAngle % 360,
        eAngle = this.endAngle % 360;
      var between = false;
      if (sAngle > eAngle) {
        between = !(angle > eAngle && angle < sAngle);
      } else {
        between = angle >= sAngle && angle <= eAngle;
      }
      return pp.distanceTo(pc) <= size.width / 2 + t && between;
    };
    _proto._computeGeodesicLength = function _computeGeodesicLength() {
      if (isNil(this._radius)) {
        return 0;
      }
      return Math.PI * 2 * this._radius * Math.abs(this.startAngle - this.endAngle) / 360 + 2 * this._radius;
    };
    _proto._computeGeodesicArea = function _computeGeodesicArea() {
      if (isNil(this._radius)) {
        return 0;
      }
      return Math.PI * Math.pow(this._radius, 2) * Math.abs(this.startAngle - this.endAngle) / 360;
    };
    _proto._toJSON = function _toJSON(options) {
      var opts = extend({}, options);
      var center = this.getCenter();
      opts.geometry = false;
      var feature = this.toGeoJSON(opts);
      feature['geometry'] = {
        'type': 'Polygon'
      };
      return {
        'feature': feature,
        'subType': 'Sector',
        'coordinates': [center.x, center.y],
        'radius': this.getRadius(),
        'startAngle': this.getStartAngle(),
        'endAngle': this.getEndAngle()
      };
    };
    return Sector;
  }(Circle);
  Sector.mergeOptions(options$8);
  Sector.registerJSONType('Sector');

  var options$9 = {
    'enableSimplify': false,
    'enableClip': false
  };
  var Curve = function (_LineString) {
    _inheritsLoose(Curve, _LineString);
    function Curve() {
      return _LineString.apply(this, arguments) || this;
    }
    var _proto = Curve.prototype;
    _proto._arc = function _arc(ctx, points, lineOpacity) {
      var degree = this.options['arcDegree'] * Math.PI / 180;
      for (var i = 1, l = points.length; i < l; i++) {
        var c = Canvas._arcBetween(ctx, points[i - 1], points[i], degree);
        var ctrlPoint = [points[i - 1].x + points[i].x - c[0], points[i - 1].y + points[i].y - c[1]];
        points[i - 1].nextCtrlPoint = ctrlPoint;
        points[i].prevCtrlPoint = ctrlPoint;
        Canvas._stroke(ctx, lineOpacity);
      }
    };
    _proto._quadraticCurve = function _quadraticCurve(ctx, points) {
      if (points.length <= 2) {
        Canvas._path(ctx, points);
        return;
      }
      var i, l;
      for (i = 2, l = points.length; i < l; i += 2) {
        ctx.quadraticCurveTo(points[i - 1].x, points[i - 1].y, points[i].x, points[i].y);
      }
      i -= 1;
      if (i < l) {
        for (; i < l; i++) {
          ctx.lineTo(points[i].x, points[i].y);
        }
      }
    };
    _proto._bezierCurve = function _bezierCurve(ctx, points) {
      if (points.length <= 3) {
        Canvas._path(ctx, points);
        return;
      }
      var i, l;
      for (i = 1, l = points.length; i + 2 < l; i += 3) {
        ctx.bezierCurveTo(points[i].x, points[i].y, points[i + 1].x, points[i + 1].y, points[i + 2].x, points[i + 2].y);
      }
      if (i < l) {
        for (; i < l; i++) {
          ctx.lineTo(points[i].x, points[i].y);
        }
      }
    };
    _proto._getCurveArrowPoints = function _getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, step) {
      var l = segments.length;
      var i;
      for (i = step; i < l; i += step) {
        var arrow = this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance);
        if (arrow) {
          arrows.push(arrow);
        }
      }
      i -= step;
      if (i < l - 1) {
        for (i += 1; i < l; i++) {
          var _arrow = this._getArrowShape(segments[i - 1], segments[i], lineWidth, arrowStyle, tolerance);
          if (_arrow) {
            arrows.push(_arrow);
          }
        }
      }
    };
    return Curve;
  }(LineString);
  Curve.mergeOptions(options$9);

  var options$a = {
    'arcDegree': 90
  };
  var ArcCurve = function (_Curve) {
    _inheritsLoose(ArcCurve, _Curve);
    function ArcCurve() {
      return _Curve.apply(this, arguments) || this;
    }
    var _proto = ArcCurve.prototype;
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options),
        'subType': 'ArcCurve'
      };
    };
    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
      ctx.beginPath();
      this._arc(ctx, points, lineOpacity);
      Canvas._stroke(ctx, lineOpacity);
      this._paintArrow(ctx, points, lineOpacity);
    };
    ArcCurve.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var arc = new ArcCurve(feature['geometry']['coordinates'], json['options']);
      arc.setProperties(feature['properties']);
      return arc;
    };
    return ArcCurve;
  }(Curve);
  ArcCurve.registerJSONType('ArcCurve');
  ArcCurve.mergeOptions(options$a);

  var CubicBezierCurve = function (_Curve) {
    _inheritsLoose(CubicBezierCurve, _Curve);
    function CubicBezierCurve() {
      return _Curve.apply(this, arguments) || this;
    }
    CubicBezierCurve.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var curve = new CubicBezierCurve(feature['geometry']['coordinates'], json['options']);
      curve.setProperties(feature['properties']);
      return curve;
    };
    var _proto = CubicBezierCurve.prototype;
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options),
        'subType': 'CubicBezierCurve'
      };
    };
    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
      ctx.beginPath();
      ctx.moveTo(points[0].x, points[0].y);
      this._bezierCurve(ctx, points);
      Canvas._stroke(ctx, lineOpacity);
      this._paintArrow(ctx, points, lineOpacity);
    };
    _proto._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
      return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 3);
    };
    return CubicBezierCurve;
  }(Curve);
  CubicBezierCurve.registerJSONType('CubicBezierCurve');

  var QuadBezierCurve = function (_Curve) {
    _inheritsLoose(QuadBezierCurve, _Curve);
    function QuadBezierCurve() {
      return _Curve.apply(this, arguments) || this;
    }
    QuadBezierCurve.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var curve = new QuadBezierCurve(feature['geometry']['coordinates'], json['options']);
      curve.setProperties(feature['properties']);
      return curve;
    };
    var _proto = QuadBezierCurve.prototype;
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options),
        'subType': 'QuadBezierCurve'
      };
    };
    _proto._paintOn = function _paintOn(ctx, points, lineOpacity) {
      ctx.beginPath();
      ctx.moveTo(points[0].x, points[0].y);
      this._quadraticCurve(ctx, points, lineOpacity);
      Canvas._stroke(ctx, lineOpacity);
      this._paintArrow(ctx, points, lineOpacity);
    };
    _proto._getArrowPoints = function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
      return this._getCurveArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance, 2);
    };
    return QuadBezierCurve;
  }(Curve);
  QuadBezierCurve.registerJSONType('QuadBezierCurve');

  var defaultSymbol$1 = {
    'textFaceName': 'monospace',
    'textSize': 12,
    'textLineSpacing': 8,
    'textWrapCharacter': '\n',
    'textHorizontalAlignment': 'middle',
    'textVerticalAlignment': 'middle'
  };
  var defaultBoxSymbol = {
    'markerType': 'square',
    'markerLineColor': '#000',
    'markerLineWidth': 2,
    'markerLineOpacity': 1,
    'markerFill': '#fff',
    'markerOpacity': 1
  };
  var TextMarker = function (_Marker) {
    _inheritsLoose(TextMarker, _Marker);
    function TextMarker() {
      return _Marker.apply(this, arguments) || this;
    }
    var _proto = TextMarker.prototype;
    _proto.getContent = function getContent() {
      return this._content;
    };
    _proto.setContent = function setContent(content) {
      var old = this._content;
      this._content = escapeSpecialChars(content);
      this._refresh();
      this._fireEvent('contentchange', {
        'old': old,
        'new': content
      });
      return this;
    };
    _proto.onAdd = function onAdd() {
      this._refresh();
    };
    _proto.toJSON = function toJSON() {
      var json = _Marker.prototype.toJSON.call(this);
      delete json['symbol'];
      return json;
    };
    _proto.setSymbol = function setSymbol(symbol) {
      if (this._refreshing || !symbol) {
        return _Marker.prototype.setSymbol.call(this, symbol);
      }
      var s = this._parseSymbol(symbol);
      if (this.setTextStyle) {
        var style = this.getTextStyle() || {};
        style.symbol = s[0];
        this.setTextStyle(style);
      } else if (this.setTextSymbol) {
        this.setTextSymbol(s[0]);
      }
      if (this.setBoxStyle) {
        var _style = this.getBoxStyle() || {};
        _style.symbol = s[1];
        this.setBoxStyle(_style);
      } else if (this.setBoxSymbol) {
        this.setBoxSymbol(s[1]);
      }
      return this;
    };
    _proto._parseSymbol = function _parseSymbol(symbol) {
      var t = {};
      var b = {};
      for (var p in symbol) {
        if (hasOwn(symbol, p)) {
          if (p.indexOf('text') === 0) {
            t[p] = symbol[p];
          } else {
            b[p] = symbol[p];
          }
        }
      }
      return [t, b];
    };
    _proto._getTextSize = function _getTextSize(symbol) {
      return splitTextToRow(this._content, symbol)['size'];
    };
    _proto._getInternalSymbol = function _getInternalSymbol() {
      return this._symbol;
    };
    _proto._getDefaultTextSymbol = function _getDefaultTextSymbol() {
      return extend({}, defaultSymbol$1);
    };
    _proto._getDefaultBoxSymbol = function _getDefaultBoxSymbol() {
      return extend({}, defaultBoxSymbol);
    };
    _proto._getDefaultPadding = function _getDefaultPadding() {
      return [12, 8];
    };
    return TextMarker;
  }(Marker);

  var options$b = {
    'textStyle': {
      'wrap': true,
      'padding': [12, 8],
      'verticalAlignment': 'middle',
      'horizontalAlignment': 'middle'
    },
    'boxSymbol': null
  };
  var TextBox = function (_TextMarker) {
    _inheritsLoose(TextBox, _TextMarker);
    function TextBox(content, coordinates, width, height, options) {
      var _this;
      if (options === void 0) {
        options = {};
      }
      _this = _TextMarker.call(this, coordinates, options) || this;
      _this._content = escapeSpecialChars(content);
      _this._width = isNil(width) ? 100 : width;
      _this._height = isNil(height) ? 40 : height;
      if (options.boxSymbol) {
        _this.setBoxSymbol(options.boxSymbol);
      }
      if (options.textStyle) {
        _this.setTextStyle(options.textStyle);
      }
      _this._refresh();
      return _this;
    }
    var _proto = TextBox.prototype;
    _proto.getWidth = function getWidth() {
      return this._width;
    };
    _proto.setWidth = function setWidth(width) {
      this._width = width;
      this._refresh();
      return this;
    };
    _proto.getHeight = function getHeight() {
      return this._height;
    };
    _proto.setHeight = function setHeight(height) {
      this._height = height;
      this._refresh();
      return this;
    };
    _proto.getBoxSymbol = function getBoxSymbol() {
      return extend({}, this.options.boxSymbol);
    };
    _proto.setBoxSymbol = function setBoxSymbol(symbol) {
      this.options.boxSymbol = symbol ? extend({}, symbol) : symbol;
      if (this.getSymbol()) {
        this._refresh();
      }
      return this;
    };
    _proto.getTextStyle = function getTextStyle() {
      if (!this.options.textStyle) {
        return null;
      }
      return extend({}, this.options.textStyle);
    };
    _proto.setTextStyle = function setTextStyle(style) {
      this.options.textStyle = style ? extend({}, style) : style;
      if (this.getSymbol()) {
        this._refresh();
      }
      return this;
    };
    TextBox.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var textBox = new TextBox(json['content'], feature['geometry']['coordinates'], json['width'], json['height'], json['options']);
      textBox.setProperties(feature['properties']);
      textBox.setId(feature['id']);
      if (json['symbol']) {
        textBox.setSymbol(json['symbol']);
      }
      return textBox;
    };
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options),
        'width': this.getWidth(),
        'height': this.getHeight(),
        'subType': 'TextBox',
        'content': this._content
      };
    };
    _proto._refresh = function _refresh() {
      var textStyle = this.getTextStyle() || {},
        padding = textStyle['padding'] || [12, 8];
      var maxWidth, maxHeight;
      if (isFunctionDefinition(this._width)) {
        maxWidth = JSON.parse(JSON.stringify(this._width));
        var stops = maxWidth.stops;
        if (stops) {
          for (var i = 0; i < stops.length; i++) {
            stops[i][1] = stops[i][1] - 2 * padding[0];
          }
        }
      } else {
        maxWidth = this._width - 2 * padding[0];
      }
      if (isFunctionDefinition(this._height)) {
        maxHeight = JSON.parse(JSON.stringify(this._height));
        var _stops = maxHeight.stops;
        if (_stops) {
          for (var _i = 0; _i < _stops.length; _i++) {
            _stops[_i][1] = _stops[_i][1] - 2 * padding[1];
          }
        }
      } else {
        maxHeight = this._height - 2 * padding[1];
      }
      var symbol = extend({}, textStyle.symbol || this._getDefaultTextSymbol(), this.options.boxSymbol || this._getDefaultBoxSymbol(), {
        'textName': this._content,
        'markerWidth': this._width,
        'markerHeight': this._height,
        'textHorizontalAlignment': 'middle',
        'textVerticalAlignment': 'middle',
        'textMaxWidth': maxWidth,
        'textMaxHeight': maxHeight
      });
      if (textStyle['wrap'] && !symbol['textWrapWidth']) {
        symbol['textWrapWidth'] = maxWidth;
      }
      var hAlign = textStyle['horizontalAlignment'];
      symbol['textDx'] = symbol['markerDx'] || 0;
      var offsetX;
      if (isFunctionDefinition(this._width)) {
        offsetX = JSON.parse(JSON.stringify(this._width));
        var _stops2 = offsetX.stops;
        if (_stops2) {
          for (var _i2 = 0; _i2 < _stops2.length; _i2++) {
            _stops2[_i2][1] = _stops2[_i2][1] / 2 - padding[0];
            if (hAlign === 'left') {
              _stops2[_i2][1] *= -1;
            }
          }
        }
      } else {
        offsetX = symbol['markerWidth'] / 2 - padding[0];
        if (hAlign === 'left') {
          offsetX *= -1;
        }
      }
      if (hAlign === 'left') {
        symbol['textHorizontalAlignment'] = 'right';
        symbol['textDx'] = offsetX;
      } else if (hAlign === 'right') {
        symbol['textHorizontalAlignment'] = 'left';
        symbol['textDx'] = offsetX;
      }
      var vAlign = textStyle['verticalAlignment'];
      symbol['textDy'] = symbol['markerDy'] || 0;
      var offsetY;
      if (isFunctionDefinition(this._height)) {
        offsetY = JSON.parse(JSON.stringify(this._height));
        var _stops3 = offsetY.stops;
        if (_stops3) {
          for (var _i3 = 0; _i3 < _stops3.length; _i3++) {
            _stops3[_i3][1] = _stops3[_i3][1] / 2 - padding[1];
            if (vAlign === 'top') {
              _stops3[_i3][1] *= -1;
            }
          }
        }
      } else {
        offsetY = symbol['markerHeight'] / 2 - padding[1];
        if (vAlign === 'top') {
          offsetY *= -1;
        }
      }
      if (vAlign === 'top') {
        symbol['textVerticalAlignment'] = 'bottom';
        symbol['textDy'] = offsetY;
      } else if (vAlign === 'bottom') {
        symbol['textVerticalAlignment'] = 'top';
        symbol['textDy'] = offsetY;
      }
      this._refreshing = true;
      this.updateSymbol(symbol);
      delete this._refreshing;
    };
    _proto.startEdit = function startEdit(opts) {
      var symbol = this._getCompiledSymbol();
      if (isFunctionDefinition(this._width)) {
        var markerWidth = symbol['markerWidth'];
        this._oldWidth = this._width;
        this.setWidth(markerWidth);
      }
      if (isFunctionDefinition(this._height)) {
        var markerHeight = symbol['markerHeight'];
        this._oldHeight = this._height;
        this.setHeight(markerHeight);
      }
      _TextMarker.prototype.startEdit.call(this, opts);
    };
    _proto.endEdit = function endEdit() {
      var map = this.getMap();
      var zoom = map && map.getZoom();
      if (this._oldWidth) {
        var markerWidth = this._width;
        var widthFn = interpolated(this._oldWidth);
        var oldExpectedWidth = widthFn(zoom);
        var scale = markerWidth / oldExpectedWidth;
        var stops = this._oldWidth.stops;
        for (var i = 0; i < stops.length; i++) {
          stops[i][1] *= scale;
        }
        this.setWidth(this._oldWidth);
        delete this._oldWidth;
      }
      if (this._oldHeight) {
        var markerHeight = this._height;
        var heightFn = interpolated(this._oldHeight);
        var oldExpectedHeight = heightFn(zoom);
        var _scale = markerHeight / oldExpectedHeight;
        var _stops4 = this._oldHeight.stops;
        for (var _i4 = 0; _i4 < _stops4.length; _i4++) {
          _stops4[_i4][1] *= _scale;
        }
        this.setHeight(this._oldHeight);
        delete this._oldHeight;
      }
      _TextMarker.prototype.endEdit.call(this);
    };
    return TextBox;
  }(TextMarker);
  TextBox.mergeOptions(options$b);
  TextBox.registerJSONType('TextBox');

  var options$c = {
    'boxStyle': null,
    textSymbol: null
  };
  var Label = function (_TextMarker) {
    _inheritsLoose(Label, _TextMarker);
    function Label(content, coordinates, options) {
      var _this;
      if (options === void 0) {
        options = {};
      }
      _this = _TextMarker.call(this, coordinates, options) || this;
      if (options.textSymbol) {
        _this.setTextSymbol(options.textSymbol);
      }
      if (options.boxStyle) {
        _this.setBoxStyle(options.boxStyle);
      }
      _this._content = escapeSpecialChars(content);
      _this._refresh();
      return _this;
    }
    var _proto = Label.prototype;
    _proto.getBoxStyle = function getBoxStyle() {
      if (!this.options.boxStyle) {
        return null;
      }
      return extend({}, this.options.boxStyle);
    };
    _proto.setBoxStyle = function setBoxStyle(style) {
      this.options.boxStyle = style ? extend({}, style) : style;
      this._refresh();
      return this;
    };
    _proto.getTextSymbol = function getTextSymbol() {
      return extend({}, this._getDefaultTextSymbol(), this.options.textSymbol);
    };
    _proto.setTextSymbol = function setTextSymbol(symbol) {
      this.options.textSymbol = symbol ? extend({}, symbol) : symbol;
      this._refresh();
      return this;
    };
    Label.fromJSON = function fromJSON(json) {
      var feature = json['feature'];
      var label = new Label(json['content'], feature['geometry']['coordinates'], json['options']);
      label.setProperties(feature['properties']);
      label.setId(feature['id']);
      if (json['symbol']) {
        label.setSymbol(json['symbol']);
      }
      return label;
    };
    _proto._canEdit = function _canEdit() {
      return false;
    };
    _proto._toJSON = function _toJSON(options) {
      return {
        'feature': this.toGeoJSON(options),
        'subType': 'Label',
        'content': this._content
      };
    };
    _proto._refresh = function _refresh() {
      var symbol = extend({}, this.getTextSymbol(), {
        'textName': this._content
      });
      var boxStyle = this.getBoxStyle();
      if (boxStyle) {
        extend(symbol, boxStyle.symbol);
        var sizes = this._getBoxSize(symbol),
          textSize = sizes[1],
          padding = boxStyle['padding'] || this._getDefaultPadding();
        var boxSize = sizes[0];
        symbol['markerWidth'] = boxSize['width'];
        symbol['markerHeight'] = boxSize['height'];
        var dx = symbol['textDx'] || 0,
          dy = symbol['textDy'] || 0,
          textAlignPoint = getAlignPoint(textSize, symbol['textHorizontalAlignment'], symbol['textVerticalAlignment'])._add(dx, dy);
        var hAlign = boxStyle['horizontalAlignment'] || 'middle';
        symbol['markerDx'] = textAlignPoint.x;
        if (hAlign === 'left') {
          symbol['markerDx'] += symbol['markerWidth'] / 2 - padding[0];
        } else if (hAlign === 'right') {
          symbol['markerDx'] -= symbol['markerWidth'] / 2 - textSize['width'] - padding[0];
        } else {
          symbol['markerDx'] += textSize['width'] / 2;
        }
        var vAlign = boxStyle['verticalAlignment'] || 'middle';
        symbol['markerDy'] = textAlignPoint.y;
        if (vAlign === 'top') {
          symbol['markerDy'] += symbol['markerHeight'] / 2 - padding[1];
        } else if (vAlign === 'bottom') {
          symbol['markerDy'] -= symbol['markerHeight'] / 2 - textSize['height'] - padding[1];
        } else {
          symbol['markerDy'] += textSize['height'] / 2;
        }
      }
      this._refreshing = true;
      this.updateSymbol(symbol);
      delete this._refreshing;
    };
    _proto._getBoxSize = function _getBoxSize(symbol) {
      if (!symbol['markerType']) {
        symbol['markerType'] = 'square';
      }
      var boxStyle = this.getBoxStyle();
      var size = this._getTextSize(symbol);
      var width, height;
      var padding = boxStyle['padding'] || this._getDefaultPadding();
      width = size['width'] + padding[0] * 2;
      height = size['height'] + padding[1] * 2;
      if (boxStyle['minWidth']) {
        if (!width || width < boxStyle['minWidth']) {
          width = boxStyle['minWidth'];
        }
      }
      if (boxStyle['minHeight']) {
        if (!height || height < boxStyle['minHeight']) {
          height = boxStyle['minHeight'];
        }
      }
      return [new Size(width, height), size];
    };
    return Label;
  }(TextMarker);
  Label.mergeOptions(options$c);
  Label.registerJSONType('Label');

  var Connectable = function Connectable(Base) {
    return function (_Base) {
      _inheritsLoose(_class, _Base);
      function _class() {
        return _Base.apply(this, arguments) || this;
      }
      _class._hasConnectors = function _hasConnectors(geometry) {
        return !isNil(geometry.__connectors) && geometry.__connectors.length > 0;
      };
      _class._getConnectors = function _getConnectors(geometry) {
        return geometry.__connectors;
      };
      var _proto = _class.prototype;
      _proto.getConnectSource = function getConnectSource() {
        return this._connSource;
      };
      _proto.setConnectSource = function setConnectSource(src) {
        var target = this._connTarget;
        this.onRemove();
        this._connSource = src;
        this._connTarget = target;
        this.onAdd();
        return this;
      };
      _proto.getConnectTarget = function getConnectTarget() {
        return this._connTarget;
      };
      _proto.setConnectTarget = function setConnectTarget(target) {
        var src = this._connSource;
        this.onRemove();
        this._connSource = src;
        this._connTarget = target;
        this._updateCoordinates();
        this._registerEvents();
        return this;
      };
      _proto._updateCoordinates = function _updateCoordinates() {
        var map = this.getMap();
        if (!map && this._connSource) {
          map = this._connSource.getMap();
        }
        if (!map && this._connTarget) {
          map = this._connTarget.getMap();
        }
        if (!map) {
          return;
        }
        if (!this._connSource || !this._connTarget) {
          return;
        }
        var srcPoints = this._connSource._getConnectPoints();
        var targetPoints = this._connTarget._getConnectPoints();
        var minDist = 0;
        var oldCoordinates = this.getCoordinates();
        var c1, c2;
        for (var i = 0, len = srcPoints.length; i < len; i++) {
          var p1 = srcPoints[i];
          for (var j = 0, length = targetPoints.length; j < length; j++) {
            var p2 = targetPoints[j];
            var dist = map.computeLength(p1, p2);
            if (i === 0 && j === 0) {
              c1 = p1;
              c2 = p2;
              minDist = dist;
            } else if (dist < minDist) {
              c1 = p1;
              c2 = p2;
            }
          }
        }
        if (!isArrayHasData(oldCoordinates) || !oldCoordinates[0].equals(c1) || !oldCoordinates[1].equals(c2)) {
          this.setCoordinates([c1, c2]);
        }
      };
      _proto.onAdd = function onAdd() {
        this._registerEvents();
        this._updateCoordinates();
      };
      _proto.onRemove = function onRemove() {
        if (this._connSource) {
          if (this._connSource.__connectors) {
            removeFromArray(this, this._connSource.__connectors);
          }
          this._connSource.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
          this._connSource.off('dragstart mousedown mouseover', this._showConnect, this);
          this._connSource.off('dragend mouseup mouseout', this.hide, this);
          this._connSource.off('show', this._showConnect, this).off('hide', this.hide, this);
          delete this._connSource;
        }
        if (this._connTarget) {
          removeFromArray(this, this._connTarget.__connectors);
          this._connTarget.off('dragging positionchange', this._updateCoordinates, this).off('remove', this.onRemove, this);
          this._connTarget.off('show', this._showConnect, this).off('hide', this.hide, this);
          delete this._connTarget;
        }
        if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
          var map = this.getMap();
          if (map) {
            map.off('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
          }
        }
      };
      _proto._showConnect = function _showConnect() {
        if (!this._connSource || !this._connTarget) {
          return;
        }
        if (this._connSource.isVisible() && this._connTarget.isVisible()) {
          this._updateCoordinates();
          this.show();
        }
      };
      _proto._registerEvents = function _registerEvents() {
        if (!this._connSource || !this._connTarget) {
          return;
        }
        if (!this._connSource.__connectors) {
          this._connSource.__connectors = [];
        }
        if (!this._connTarget.__connectors) {
          this._connTarget.__connectors = [];
        }
        this._connSource.__connectors.push(this);
        this._connTarget.__connectors.push(this);
        this._connSource.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
        this._connTarget.on('dragging positionchange', this._updateCoordinates, this).on('remove', this.remove, this);
        this._connSource.on('show', this._showConnect, this).on('hide', this.hide, this);
        this._connTarget.on('show', this._showConnect, this).on('hide', this.hide, this);
        var trigger = this.options['showOn'];
        this.hide();
        if (trigger === 'moving') {
          this._connSource.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
          this._connTarget.on('dragstart', this._showConnect, this).on('dragend', this.hide, this);
        } else if (trigger === 'click') {
          this._connSource.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
          this._connTarget.on('mousedown', this._showConnect, this).on('mouseup', this.hide, this);
        } else if (trigger === 'mouseover') {
          this._connSource.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
          this._connTarget.on('mouseover', this._showConnect, this).on('mouseout', this.hide, this);
        } else {
          this._showConnect();
        }
        if (!(this._connSource instanceof Geometry) || !(this._connTarget instanceof Geometry)) {
          var map = this.getMap();
          if (map) {
            map.on('movestart moving moveend zoomstart zooming zoomend rotate pitch fovchange spatialreferencechange', this._updateCoordinates, this);
          }
        }
      };
      return _class;
    }(Base);
  };
  var options$d = {
    showOn: 'always'
  };
  var ConnectorLine = function (_Connectable) {
    _inheritsLoose(ConnectorLine, _Connectable);
    function ConnectorLine(src, target, options) {
      var _this;
      _this = _Connectable.call(this, null, options) || this;
      if (arguments.length === 1) {
        options = src;
        src = null;
        target = null;
      }
      _this._connSource = src;
      _this._connTarget = target;
      return _this;
    }
    return ConnectorLine;
  }(Connectable(LineString));
  ConnectorLine.mergeOptions(options$d);
  ConnectorLine.registerJSONType('ConnectorLine');
  var ArcConnectorLine = function (_Connectable2) {
    _inheritsLoose(ArcConnectorLine, _Connectable2);
    function ArcConnectorLine(src, target, options) {
      var _this2;
      _this2 = _Connectable2.call(this, null, options) || this;
      if (arguments.length === 1) {
        options = src;
        src = null;
        target = null;
      }
      _this2._connSource = src;
      _this2._connTarget = target;
      return _this2;
    }
    return ArcConnectorLine;
  }(Connectable(ArcCurve));
  ArcConnectorLine.mergeOptions(options$d);
  ArcConnectorLine.registerJSONType('ArcConnectorLine');

  function isGeometry(geo) {
    return geo && geo instanceof Geometry;
  }
  var options$e = {
    'drawImmediate': false,
    'geometryEvents': true,
    'geometryEventTolerance': 1
  };
  var TMP_EVENTS_ARR = [];
  var OverlayLayer = function (_Layer) {
    _inheritsLoose(OverlayLayer, _Layer);
    function OverlayLayer(id, geometries, options) {
      var _this;
      if (geometries && !isGeometry(geometries) && !Array.isArray(geometries) && GEOJSON_TYPES.indexOf(geometries.type) < 0) {
        options = geometries;
        geometries = null;
      }
      _this = _Layer.call(this, id, options) || this;
      _this._maxZIndex = 0;
      _this._minZIndex = 0;
      _this._initCache();
      if (geometries) {
        _this.addGeometry(geometries);
      }
      var style = _this.options['style'];
      if (style) {
        _this.setStyle(style);
      }
      return _this;
    }
    var _proto = OverlayLayer.prototype;
    _proto.getGeometryById = function getGeometryById(id) {
      if (isNil(id) || id === '') {
        return null;
      }
      if (!this._geoMap[id]) {
        return null;
      }
      return this._geoMap[id];
    };
    _proto.getGeometries = function getGeometries(filter, context) {
      if (!filter) {
        return this._geoList.slice(0);
      }
      var result = [];
      var geometry, filtered;
      for (var i = 0, l = this._geoList.length; i < l; i++) {
        geometry = this._geoList[i];
        if (context) {
          filtered = filter.call(context, geometry);
        } else {
          filtered = filter(geometry);
        }
        if (filtered) {
          result.push(geometry);
        }
      }
      return result;
    };
    _proto.getFirstGeometry = function getFirstGeometry() {
      if (!this._geoList.length) {
        return null;
      }
      return this._geoList[0];
    };
    _proto.getLastGeometry = function getLastGeometry() {
      var len = this._geoList.length;
      if (len === 0) {
        return null;
      }
      return this._geoList[len - 1];
    };
    _proto.getCount = function getCount() {
      return this._geoList.length;
    };
    _proto.getExtent = function getExtent() {
      if (this.getCount() === 0) {
        return null;
      }
      var extent = new Extent(this.getProjection());
      this.forEach(function (g) {
        extent._combine(g.getExtent());
      });
      return extent;
    };
    _proto.forEach = function forEach(fn, context) {
      var copyOnWrite = this._geoList.slice(0);
      for (var i = 0, l = copyOnWrite.length; i < l; i++) {
        if (!context) {
          fn(copyOnWrite[i], i);
        } else {
          fn.call(context, copyOnWrite[i], i);
        }
      }
      return this;
    };
    _proto.filter = function filter(fn, context) {
      var selected = [];
      var isFn = isFunction(fn);
      var filter = isFn ? fn : createFilter(fn);
      this.forEach(function (geometry) {
        var g = isFn ? geometry : getFilterFeature(geometry);
        if (context ? filter.call(context, g) : filter(g)) {
          selected.push(geometry);
        }
      }, this);
      return selected;
    };
    _proto.isEmpty = function isEmpty$$1() {
      return !this._geoList.length;
    };
    _proto.addGeometry = function addGeometry(geometries, fitView) {
      if (!geometries) {
        return this;
      }
      if (geometries.type === 'FeatureCollection') {
        return this.addGeometry(GeoJSON.toGeometry(geometries), fitView);
      } else if (!Array.isArray(geometries)) {
        var count = arguments.length;
        var last = arguments[count - 1];
        geometries = Array.prototype.slice.call(arguments, 0, count - 1);
        fitView = last;
        if (last && isObject(last) && ('type' in last || isGeometry(last))) {
          geometries.push(last);
          fitView = false;
        }
        return this.addGeometry(geometries, fitView);
      } else if (geometries.length === 0) {
        return this;
      }
      this._initCache();
      var extent;
      if (fitView) {
        extent = new Extent();
      }
      this._toSort = this._maxZIndex > 0;
      var geos = [];
      for (var i = 0, l = geometries.length; i < l; i++) {
        var geo = geometries[i];
        if (!(geo && (GeoJSON._isGeoJSON(geo) || isGeometry(geo)))) {
          throw new Error('Invalid geometry to add to layer(' + this.getId() + ') at index:' + i);
        }
        if (geo.getLayer && geo.getLayer() === this) {
          continue;
        }
        if (!isGeometry(geo)) {
          geo = Geometry.fromJSON(geo);
          if (Array.isArray(geo)) {
            for (var ii = 0, ll = geo.length; ii < ll; ii++) {
              this._add(geo[ii], extent, i);
              geos.push(geo[ii]);
            }
          }
        }
        if (!geo) {
          throw new Error('Invalid geometry to add to layer(' + this.getId() + ') at index:' + i);
        }
        if (!Array.isArray(geo)) {
          this._add(geo, extent, i);
          geos.push(geo);
        }
      }
      var map = this.getMap();
      if (map) {
        this._getRenderer().onGeometryAdd(geos);
        if (extent && !isNil(extent.xmin)) {
          var center = extent.getCenter();
          var z = map.getFitZoom(extent);
          if (isObject(fitView)) {
            var step = isFunction(fitView.step) ? fitView.step : function () {
              return undefined;
            };
            map.animateTo({
              center: center,
              zoom: z
            }, extend({
              duration: map.options.zoomAnimationDuration,
              easing: 'out'
            }, fitView), step);
          } else if (fitView === true) {
            map.setCenterAndZoom(center, z);
          }
        }
      }
      this.fire('addgeo', {
        'geometries': geometries
      });
      return this;
    };
    _proto.getGeoMinZIndex = function getGeoMinZIndex() {
      return this._minZIndex;
    };
    _proto.getGeoMaxZIndex = function getGeoMaxZIndex() {
      return this._maxZIndex;
    };
    _proto._add = function _add(geo, extent, i) {
      if (!this._toSort) {
        this._toSort = geo.getZIndex() !== 0;
      }
      this._updateZIndex(geo.getZIndex());
      var geoId = geo.getId();
      if (!isNil(geoId)) {
        if (!isNil(this._geoMap[geoId])) {
          throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + geoId + ', at index:' + i);
        }
        this._geoMap[geoId] = geo;
      }
      var internalId = UID();
      geo._setInternalId(internalId);
      this._geoList.push(geo);
      this.onAddGeometry(geo);
      geo._bindLayer(this);
      if (geo.onAdd) {
        geo.onAdd();
      }
      if (extent) {
        extent._combine(geo.getExtent());
      }
      geo._fireEvent('add', {
        'layer': this
      });
      if (this._cookedStyles) {
        this._styleGeometry(geo);
      }
    };
    _proto.removeGeometry = function removeGeometry(geometries) {
      if (!Array.isArray(geometries)) {
        return this.removeGeometry([geometries]);
      }
      for (var i = geometries.length - 1; i >= 0; i--) {
        if (!(geometries[i] instanceof Geometry)) {
          geometries[i] = this.getGeometryById(geometries[i]);
        }
        if (!geometries[i] || this !== geometries[i].getLayer()) continue;
        geometries[i].remove();
      }
      this.fire('removegeo', {
        'geometries': geometries
      });
      return this;
    };
    _proto.clear = function clear() {
      this._clearing = true;
      this.forEach(function (geo) {
        geo.remove();
      });
      this._geoMap = {};
      var old = this._geoList;
      this._geoList = [];
      var renderer = this._getRenderer();
      if (renderer) {
        renderer.onGeometryRemove(old);
        if (renderer.clearImageData) {
          renderer.clearImageData();
          delete renderer._lastGeosToDraw;
        }
      }
      this._clearing = false;
      this.fire('clear');
      return this;
    };
    _proto.onRemoveGeometry = function onRemoveGeometry(geometry) {
      if (!geometry || this._clearing) {
        return;
      }
      if (this !== geometry.getLayer()) {
        return;
      }
      var internalId = geometry._getInternalId();
      if (isNil(internalId)) {
        return;
      }
      var geoId = geometry.getId();
      if (!isNil(geoId)) {
        delete this._geoMap[geoId];
      }
      var idx = this._findInList(geometry);
      if (idx >= 0) {
        this._geoList.splice(idx, 1);
      }
      if (this._getRenderer()) {
        this._getRenderer().onGeometryRemove([geometry]);
      }
    };
    _proto.getStyle = function getStyle() {
      if (!this.options['style']) {
        return null;
      }
      return this.options['style'];
    };
    _proto.setStyle = function setStyle(style) {
      this.options.style = style;
      style = parseStyleRootPath(style);
      this._cookedStyles = compileStyle(style);
      this.forEach(function (geometry) {
        this._styleGeometry(geometry);
      }, this);
      this.fire('setstyle', {
        'style': style
      });
      return this;
    };
    _proto._styleGeometry = function _styleGeometry(geometry) {
      if (!this._cookedStyles) {
        return false;
      }
      var g = getFilterFeature(geometry);
      for (var i = 0, len = this._cookedStyles.length; i < len; i++) {
        if (this._cookedStyles[i]['filter'](g) === true) {
          geometry._setExternSymbol(this._cookedStyles[i]['symbol']);
          return true;
        }
      }
      return false;
    };
    _proto.removeStyle = function removeStyle() {
      if (!this.options.style) {
        return this;
      }
      delete this.options.style;
      delete this._cookedStyles;
      this.forEach(function (geometry) {
        geometry._setExternSymbol(null);
      }, this);
      this.fire('removestyle');
      return this;
    };
    _proto.onAddGeometry = function onAddGeometry(geo) {
      var style = this.getStyle();
      if (style) {
        this._styleGeometry(geo);
      }
    };
    _proto.hide = function hide() {
      for (var i = 0, l = this._geoList.length; i < l; i++) {
        this._geoList[i].onHide();
      }
      return Layer.prototype.hide.call(this);
    };
    _proto._initCache = function _initCache() {
      if (!this._geoList) {
        this._geoList = [];
        this._geoMap = {};
      }
    };
    _proto._updateZIndex = function _updateZIndex() {
      for (var _len = arguments.length, zIndex = new Array(_len), _key = 0; _key < _len; _key++) {
        zIndex[_key] = arguments[_key];
      }
      this._maxZIndex = Math.max(this._maxZIndex, Math.max.apply(Math, zIndex));
      this._minZIndex = Math.min(this._minZIndex, Math.min.apply(Math, zIndex));
    };
    _proto._sortGeometries = function _sortGeometries() {
      var _this2 = this;
      if (!this._toSort) {
        return;
      }
      this._maxZIndex = 0;
      this._minZIndex = 0;
      this._geoList.sort(function (a, b) {
        _this2._updateZIndex(a.getZIndex(), b.getZIndex());
        return _this2._compare(a, b);
      });
      this._toSort = false;
    };
    _proto._compare = function _compare(a, b) {
      if (a.getZIndex() === b.getZIndex()) {
        return a._getInternalId() - b._getInternalId();
      }
      return a.getZIndex() - b.getZIndex();
    };
    _proto._findInList = function _findInList(geo) {
      var len = this._geoList.length;
      if (len === 0) {
        return -1;
      }
      this._sortGeometries();
      var low = 0,
        high = len - 1,
        middle;
      while (low <= high) {
        middle = Math.floor((low + high) / 2);
        if (this._geoList[middle] === geo) {
          return middle;
        } else if (this._compare(this._geoList[middle], geo) > 0) {
          high = middle - 1;
        } else {
          low = middle + 1;
        }
      }
      return -1;
    };
    _proto._onGeometryEvent = function _onGeometryEvent(param) {
      if (!param || !param['target']) {
        return;
      }
      var type = param['type'];
      if (type === 'idchange') {
        this._onGeometryIdChange(param);
      } else if (type === 'zindexchange') {
        this._onGeometryZIndexChange(param);
      } else if (type === 'positionchange') {
        this._onGeometryPositionChange(param);
      } else if (type === 'shapechange') {
        this._onGeometryShapeChange(param);
      } else if (type === 'symbolchange') {
        this._onGeometrySymbolChange(param);
      } else if (type === 'show') {
        this._onGeometryShow(param);
      } else if (type === 'hide') {
        this._onGeometryHide(param);
      } else if (type === 'propertieschange') {
        this._onGeometryPropertiesChange(param);
      }
    };
    _proto._onGeometryIdChange = function _onGeometryIdChange(param) {
      if (param['new'] === param['old']) {
        if (this._geoMap[param['old']] && this._geoMap[param['old']] === param['target']) {
          return;
        }
      }
      if (!isNil(param['new'])) {
        if (this._geoMap[param['new']]) {
          throw new Error('Duplicate geometry id in layer(' + this.getId() + '):' + param['new']);
        }
        this._geoMap[param['new']] = param['target'];
      }
      if (!isNil(param['old']) && param['new'] !== param['old']) {
        delete this._geoMap[param['old']];
      }
    };
    _proto._onGeometryZIndexChange = function _onGeometryZIndexChange(param) {
      if (param['old'] !== param['new']) {
        this._updateZIndex(param['new']);
        this._toSort = true;
        if (this._getRenderer()) {
          this._getRenderer().onGeometryZIndexChange(param);
        }
      }
    };
    _proto._onGeometryPositionChange = function _onGeometryPositionChange(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometryPositionChange(param);
      }
    };
    _proto._onGeometryShapeChange = function _onGeometryShapeChange(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometryShapeChange(param);
      }
    };
    _proto._onGeometrySymbolChange = function _onGeometrySymbolChange(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometrySymbolChange(param);
      }
    };
    _proto._onGeometryShow = function _onGeometryShow(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometryShow(param);
      }
    };
    _proto._onGeometryHide = function _onGeometryHide(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometryHide(param);
      }
    };
    _proto._onGeometryPropertiesChange = function _onGeometryPropertiesChange(param) {
      if (this._getRenderer()) {
        this._getRenderer().onGeometryPropertiesChange(param);
      }
    };
    _proto._hasGeoListeners = function _hasGeoListeners(eventTypes) {
      if (!eventTypes) {
        return false;
      }
      if (!Array.isArray(eventTypes)) {
        TMP_EVENTS_ARR[0] = eventTypes;
        eventTypes = TMP_EVENTS_ARR;
      }
      var geos = this.getGeometries() || [];
      for (var i = 0, len = geos.length; i < len; i++) {
        var geometry = geos[i];
        if (!geometry) {
          continue;
        }
        if (geometry.options.cursor) {
          return true;
        }
        for (var j = 0, len1 = eventTypes.length; j < len1; j++) {
          var eventType = eventTypes[j];
          var listens = geometry.listens(eventType);
          if (listens > 0) {
            return true;
          }
        }
      }
      return false;
    };
    return OverlayLayer;
  }(Layer);
  OverlayLayer.mergeOptions(options$e);

  var TEMP_EXTENT$8 = new PointExtent();
  var options$f = {
    'debug': false,
    'enableSimplify': true,
    'defaultIconSize': [20, 20],
    'cacheVectorOnCanvas': true,
    'cacheSvgOnCanvas': Browser$1.gecko,
    'enableAltitude': false,
    'altitudeProperty': 'altitude',
    'drawAltitude': false,
    'sortByDistanceToCamera': false,
    'roundPoint': false,
    'altitude': 0,
    'clipBBoxBufferSize': 3,
    'collision': false,
    'collisionBufferSize': 2,
    'collisionDelay': 250,
    'collisionScope': 'layer',
    'progressiveRender': false,
    'progressiveRenderCount': 1000,
    'progressiveRenderDebug': false
  };
  var VectorLayer = function (_OverlayLayer) {
    _inheritsLoose(VectorLayer, _OverlayLayer);
    function VectorLayer(id, geometries, options) {
      return _OverlayLayer.call(this, id, geometries, options) || this;
    }
    var _proto = VectorLayer.prototype;
    _proto.onConfig = function onConfig(conf) {
      _OverlayLayer.prototype.onConfig.call(this, conf);
      if (conf['enableAltitude'] || conf['drawAltitude'] || conf['altitudeProperty']) {
        var renderer = this.getRenderer();
        if (renderer && renderer.setToRedraw) {
          renderer.setToRedraw();
        }
      }
    };
    _proto.identify = function identify(coordinate, options) {
      if (options === void 0) {
        options = {};
      }
      var renderer = this.getRenderer();
      if (!(coordinate instanceof Coordinate)) {
        coordinate = new Coordinate(coordinate);
      }
      var cp = this.getMap().coordToContainerPoint(coordinate);
      if (options['onlyVisible'] && renderer && renderer.identifyAtPoint) {
        return renderer.identifyAtPoint(cp, options);
      }
      return this._hitGeos(this._geoList, cp, options);
    };
    _proto.identifyAtPoint = function identifyAtPoint(point, options) {
      if (options === void 0) {
        options = {};
      }
      var renderer = this.getRenderer();
      if (!(point instanceof Point)) {
        point = new Point(point);
      }
      if (options['onlyVisible'] && renderer && renderer.identifyAtPoint) {
        return renderer.identifyAtPoint(point, options);
      }
      return this._hitGeos(this._geoList, point, options);
    };
    _proto._hitGeos = function _hitGeos(geometries, cp, options) {
      if (options === void 0) {
        options = {};
      }
      if (!geometries || !geometries.length) {
        return [];
      }
      var filter = options['filter'],
        hits = [];
      var tolerance = options['tolerance'];
      var map = this.getMap();
      var renderer = this.getRenderer();
      var imageData = renderer && renderer.getImageData && renderer.getImageData();
      if (imageData) {
        var hitTolerance = 0;
        var maxTolerance = renderer.maxTolerance;
        if (isNumber(maxTolerance)) {
          hitTolerance = maxTolerance;
        } else {
          for (var i = geometries.length - 1; i >= 0; i--) {
            var t = geometries[i]._hitTestTolerance() + (tolerance || 0);
            if (t > hitTolerance) {
              hitTolerance = t;
            }
          }
        }
        var r = map.getDevicePixelRatio();
        imageData.r = r;
        var hit = false;
        var cpx = cp.x - hitTolerance;
        var cpy = cp.y - hitTolerance;
        for (var _i = -hitTolerance; _i <= hitTolerance; _i++) {
          for (var j = -hitTolerance; j <= hitTolerance; j++) {
            var x = Math.round((cpx + _i) * r),
              y = Math.round((cpy + j) * r);
            var idx = y * imageData.width * 4 + x * 4;
            if (imageData.data[idx + 3] > 0) {
              hit = true;
              break;
            }
          }
          if (hit) {
            break;
          }
        }
        if (!hit) {
          return hits;
        }
      }
      var onlyVisible = options.onlyVisible;
      for (var _i2 = geometries.length - 1; _i2 >= 0; _i2--) {
        var geo = geometries[_i2];
        if (!geo || !geo.options['interactive']) {
          continue;
        }
        if (!onlyVisible && !geo.isVisible()) {
          continue;
        }
        var painter = geo._getPainter();
        if (!painter) {
          continue;
        }
        var bbox = painter.getRenderBBOX && painter.getRenderBBOX();
        if (bbox) {
          var _x = cp.x,
            _y = cp.y;
          if (_x < bbox[0] || _y < bbox[1] || _x > bbox[2] || _y > bbox[3]) {
            continue;
          }
        }
        if (!(geo instanceof LineString) || !geo._getArrowStyle() && !(geo instanceof Curve)) {
          var extent = geo.getContainerExtent(TEMP_EXTENT$8);
          if (tolerance) {
            extent = extent._expand(tolerance);
          }
          if (!extent || !extent.contains(cp)) {
            continue;
          }
        }
        if (geo._containsPoint(cp, tolerance) && (!filter || filter(geo))) {
          hits.push(geo);
          if (options['count']) {
            if (hits.length >= options['count']) {
              break;
            }
          }
        }
      }
      return hits;
    };
    _proto.getAltitude = function getAltitude() {
      return this.options['altitude'] || 0;
    };
    _proto.toJSON = function toJSON(options) {
      if (!options) {
        options = {};
      }
      var profile = {
        'type': this.getJSONType(),
        'id': this.getId(),
        'options': this.config()
      };
      if (isNil(options['geometries']) || options['geometries']) {
        var clipExtent;
        if (options['clipExtent']) {
          var map = this.getMap();
          var projection = map ? map.getProjection() : null;
          clipExtent = new Extent(options['clipExtent'], projection);
        }
        var geoJSONs = [];
        var geometries = this.getGeometries();
        for (var i = 0, len = geometries.length; i < len; i++) {
          var geo = geometries[i];
          var geoExt = geo.getExtent();
          if (!geoExt || clipExtent && !clipExtent.intersects(geoExt)) {
            continue;
          }
          var json = geo.toJSON(options['geometries']);
          geoJSONs.push(json);
        }
        profile['geometries'] = geoJSONs;
      }
      return profile;
    };
    VectorLayer.fromJSON = function fromJSON(json) {
      if (!json || json['type'] !== 'VectorLayer') {
        return null;
      }
      var layer = new VectorLayer(json['id'], json['options']);
      var geoJSONs = json['geometries'];
      var geometries = [];
      for (var i = 0; i < geoJSONs.length; i++) {
        var geo = Geometry.fromJSON(geoJSONs[i]);
        if (geo) {
          geometries.push(geo);
        }
      }
      layer.addGeometry(geometries);
      return layer;
    };
    VectorLayer.getPainterClass = function getPainterClass() {
      return Painter;
    };
    VectorLayer.getCollectionPainterClass = function getCollectionPainterClass() {
      return CollectionPainter;
    };
    return VectorLayer;
  }(OverlayLayer);
  VectorLayer.mergeOptions(options$f);
  VectorLayer.registerJSONType('VectorLayer');

  var key = '_map_tool';
  var MapTool = function (_Eventable) {
    _inheritsLoose(MapTool, _Eventable);
    function MapTool() {
      return _Eventable.apply(this, arguments) || this;
    }
    var _proto = MapTool.prototype;
    _proto.addTo = function addTo(map) {
      if (!map) {
        return this;
      }
      this._map = map;
      if (map[key]) {
        map[key].disable();
      }
      if (this.onAdd) {
        this.onAdd();
      }
      this.enable();
      map[key] = this;
      this._fireEvent('add');
      return this;
    };
    _proto.getMap = function getMap() {
      return this._map;
    };
    _proto.enable = function enable() {
      var map = this._map;
      if (!map || this._enabled) {
        return this;
      }
      this._enabled = true;
      this._switchEvents('off');
      this._registerEvents();
      if (this.onEnable) {
        this.onEnable();
      }
      this._fireEvent('enable');
      return this;
    };
    _proto.disable = function disable() {
      if (!this._enabled || !this._map) {
        return this;
      }
      this._enabled = false;
      this._switchEvents('off');
      if (this.onDisable) {
        this.onDisable();
      }
      this._fireEvent('disable');
      return this;
    };
    _proto.isEnabled = function isEnabled() {
      if (!this._enabled) {
        return false;
      }
      return true;
    };
    _proto.remove = function remove() {
      if (!this._map) {
        return this;
      }
      this.disable();
      if (this._map) {
        delete this._map[key];
        delete this._map;
      }
      this._fireEvent('remove');
      return this;
    };
    _proto._registerEvents = function _registerEvents() {
      this._switchEvents('on');
    };
    _proto._switchEvents = function _switchEvents(to) {
      var events = this.getEvents();
      if (events) {
        this._map[to](events, this);
      }
    };
    _proto._fireEvent = function _fireEvent(eventName, param) {
      if (!param) {
        param = {};
      }
      this.fire(eventName, param);
    };
    return MapTool;
  }(Eventable(Class));

  var options$g = {
    'symbol': {
      'lineColor': '#000',
      'lineWidth': 2,
      'lineOpacity': 1,
      'polygonFill': '#fff',
      'polygonOpacity': 0.3
    },
    'doubleClickZoom': false,
    'mode': null,
    'once': false,
    'autoPanAtEdge': false,
    'ignoreMouseleave': true,
    'blockGeometryEvents': false,
    'zIndex': Number.MAX_VALUE
  };
  var registeredMode = {};
  var DrawTool = function (_MapTool) {
    _inheritsLoose(DrawTool, _MapTool);
    DrawTool.registerMode = function registerMode(name, modeAction) {
      registeredMode[name.toLowerCase()] = modeAction;
    };
    DrawTool.getRegisterMode = function getRegisterMode(name) {
      return registeredMode[name.toLowerCase()];
    };
    function DrawTool(options) {
      var _this;
      _this = _MapTool.call(this, options) || this;
      _this._checkMode();
      _this._events = {
        'click': _this._clickHandler,
        'mousemove touchmove': _this._mouseMoveHandler,
        'dblclick': _this._doubleClickHandler,
        'mousedown touchstart': _this._mouseDownHandler,
        'mouseup touchend': _this._mouseUpHandler,
        'mousemove': _this._mouseMoveHandler,
        'mousedown': _this._mouseDownHandler,
        'mouseup': _this._mouseUpHandler
      };
      return _this;
    }
    var _proto = DrawTool.prototype;
    _proto.getMode = function getMode() {
      if (this.options['mode']) {
        return this.options['mode'].toLowerCase();
      }
      return null;
    };
    _proto.setMode = function setMode(mode) {
      if (this._geometry) {
        this._geometry.remove();
        delete this._geometry;
      }
      this._clearStage();
      this._switchEvents('off');
      this.options['mode'] = mode;
      this._checkMode();
      if (this.isEnabled()) {
        this._switchEvents('on');
        this._restoreMapCfg();
        this._saveMapCfg();
      }
      return this;
    };
    _proto.getSymbol = function getSymbol() {
      var symbol = this.options['symbol'];
      if (symbol) {
        return extendSymbol(symbol);
      } else {
        return extendSymbol(this.options['symbol']);
      }
    };
    _proto.setSymbol = function setSymbol(symbol) {
      if (!symbol) {
        return this;
      }
      this.options['symbol'] = symbol;
      if (this._geometry) {
        this._geometry.setSymbol(symbol);
      }
      return this;
    };
    _proto.getCurrentGeometry = function getCurrentGeometry() {
      return this._geometry;
    };
    _proto.onAdd = function onAdd() {
      this._checkMode();
    };
    _proto.onEnable = function onEnable() {
      this._saveMapCfg();
      this._drawToolLayer = this._getDrawLayer();
      this._clearStage();
      this._loadResources();
      var map = this.getMap();
      if (this.options['autoPanAtEdge']) {
        this._mapAutoPanAtEdge = map.options['autoPanAtEdge'];
        if (!this._mapAutoPanAtEdge) {
          map.config({
            autoPanAtEdge: true
          });
        }
      }
      this._geometryEvents = map.options['geometryEvents'];
      if (this.options['blockGeometryEvents']) {
        map.config('geometryEvents', false);
      }
      return this;
    };
    _proto.onDisable = function onDisable() {
      var map = this.getMap();
      this._restoreMapCfg();
      this.endDraw({
        ignoreEndEvent: true
      });
      if (this._map) {
        map.removeLayer(this._getDrawLayer());
        if (this.options['autoPanAtEdge']) {
          if (!this._mapAutoPanAtEdge) {
            map.config({
              autoPanAtEdge: false
            });
          }
        }
      }
      if (this.options['blockGeometryEvents']) {
        map.config('geometryEvents', this._geometryEvents);
      }
      return this;
    };
    _proto.undo = function undo() {
      var registerMode = this._getRegisterMode();
      var action = registerMode.action;
      if (!this._shouldRecordHistory(action) || !this._historyPointer) {
        return this;
      }
      var coords = this._clickCoords.slice(0, --this._historyPointer);
      registerMode.update(this.getMap().getProjection(), coords, this._geometry);
      return this;
    };
    _proto.redo = function redo() {
      var registerMode = this._getRegisterMode();
      var action = registerMode.action;
      if (!this._shouldRecordHistory(action) || isNil(this._historyPointer) || this._historyPointer === this._clickCoords.length) {
        return this;
      }
      var coords = this._clickCoords.slice(0, ++this._historyPointer);
      registerMode.update(this.getMap().getProjection(), coords, this._geometry);
      return this;
    };
    _proto._shouldRecordHistory = function _shouldRecordHistory(actions) {
      return Array.isArray(actions) && actions[0] === 'click' && actions[1] === 'mousemove' && actions[2] === 'dblclick';
    };
    _proto._checkMode = function _checkMode() {
      this._getRegisterMode();
    };
    _proto._saveMapCfg = function _saveMapCfg() {
      var map = this.getMap();
      this._mapDoubleClickZoom = map.options['doubleClickZoom'];
      map.config({
        'doubleClickZoom': this.options['doubleClickZoom']
      });
      var actions = this._getRegisterMode()['action'];
      var dragging = false;
      for (var i = 0; i < actions.length; i++) {
        if (actions[i].indexOf('mousedown') >= 0 || actions[i].indexOf('touchstart') >= 0) {
          dragging = true;
          break;
        }
      }
      if (dragging) {
        var _map = this.getMap();
        this._mapDraggable = _map.options['draggable'];
        _map.config({
          'draggable': false
        });
      }
    };
    _proto._restoreMapCfg = function _restoreMapCfg() {
      var map = this.getMap();
      map.config({
        'doubleClickZoom': this._mapDoubleClickZoom
      });
      if (!isNil(this._mapDraggable)) {
        map.config('draggable', this._mapDraggable);
      }
      delete this._mapDraggable;
      delete this._mapDoubleClickZoom;
    };
    _proto._loadResources = function _loadResources() {
      var symbol = this.getSymbol();
      var resources = getExternalResources(symbol);
      if (resources.length > 0) {
        this._drawToolLayer._getRenderer().loadResources(resources);
      }
    };
    _proto._getProjection = function _getProjection() {
      return this._map.getProjection();
    };
    _proto._getRegisterMode = function _getRegisterMode() {
      var mode = this.getMode();
      var registerMode = DrawTool.getRegisterMode(mode);
      if (!registerMode) {
        throw new Error(mode + ' is not a valid mode of DrawTool.');
      }
      return registerMode;
    };
    _proto.getEvents = function getEvents() {
      var action = this._getRegisterMode()['action'];
      var _events = {};
      if (Array.isArray(action)) {
        for (var i = 0; i < action.length; i++) {
          _events[action[i]] = this._events[action[i]];
        }
        return _events;
      }
      return null;
    };
    _proto._mouseDownHandler = function _mouseDownHandler(event) {
      this._createGeometry(event);
    };
    _proto._mouseUpHandler = function _mouseUpHandler(event) {
      this.endDraw(event);
    };
    _proto._clickHandler = function _clickHandler(event) {
      var map = this.getMap();
      var registerMode = this._getRegisterMode();
      if (this._clickCoords && this._clickCoords.length) {
        var len = this._clickCoords.length;
        var prjCoord = map._pointToPrj(event['point2d']);
        if (this._clickCoords[len - 1].equals(prjCoord)) {
          return;
        }
      }
      if (!this._geometry) {
        this._createGeometry(event);
      } else {
        var _prjCoord = map._pointToPrj(event['point2d']);
        if (!isNil(this._historyPointer)) {
          this._clickCoords = this._clickCoords.slice(0, this._historyPointer);
        }
        var snapTo = this._geometry.snapTo;
        if (snapTo && isFunction(snapTo)) {
          var snapResult = this._getSnapResult(snapTo, event.containerPoint);
          _prjCoord = snapResult.prjCoord;
          this._clickCoords = this._clickCoords.concat(snapResult.effectedVertex);
          if (this._clickCoords[this._clickCoords.length - 1].equals(_prjCoord)) {
            return;
          }
        }
        this._clickCoords.push(_prjCoord);
        this._historyPointer = this._clickCoords.length;
        event.drawTool = this;
        registerMode['update'](map.getProjection(), this._clickCoords, this._geometry, event);
        if (this.getMode() === 'point') {
          this.endDraw(event);
          return;
        }
        if (this._clickCoords.length <= 1) {
          this._fireEvent('drawstart', event);
        } else {
          this._fireEvent('drawvertex', event);
        }
        if (registerMode['clickLimit'] && registerMode['clickLimit'] === this._historyPointer) {
          this.endDraw(event);
        }
      }
    };
    _proto._createGeometry = function _createGeometry(event) {
      var mode = this.getMode();
      var registerMode = this._getRegisterMode();
      var prjCoord = this.getMap()._pointToPrj(event['point2d']);
      var symbol = this.getSymbol();
      if (!this._geometry) {
        this._fireEvent('drawprepare', event);
        this._clickCoords = [prjCoord];
        event.drawTool = this;
        this._geometry = registerMode['create'](this.getMap().getProjection(), this._clickCoords, event);
        if (symbol && mode !== 'point') {
          this._geometry.setSymbol(symbol);
        } else if (this.options.hasOwnProperty('symbol')) {
          this._geometry.setSymbol(this.options['symbol']);
        }
        this._addGeometryToStage(this._geometry);
        this._fireEvent('drawstart', event);
        var snapTo = this._geometry.snapTo;
        if (snapTo && isFunction(snapTo)) {
          var snapResult = this._getSnapResult(snapTo, event.containerPoint);
          var map = this.getMap();
          if (map && snapResult) {
            var _prjCoord2 = snapResult.prjCoord;
            this._clickCoords = [_prjCoord2];
            registerMode['update'](map.getProjection(), this._clickCoords, this._geometry, event);
          }
        }
      }
      if (mode === 'point' && event.type !== 'mousemove') {
        this.endDraw(event);
      }
    };
    _proto._mouseMoveHandler = function _mouseMoveHandler(event) {
      var map = this.getMap();
      if (!map || map.isInteracting()) {
        return;
      }
      if (this.getMode() === 'point' && !this._geometry) {
        this._createGeometry(event);
        return;
      }
      if (!this._geometry) {
        return;
      }
      var containerPoint = this._getMouseContainerPoint(event);
      if (!this._isValidContainerPoint(containerPoint)) {
        return;
      }
      var prjCoord = map._pointToPrj(event['point2d']);
      var snapAdditionVertex = [];
      var snapTo = this._geometry.snapTo;
      if (snapTo && isFunction(snapTo)) {
        var snapResult = this._getSnapResult(snapTo, containerPoint);
        prjCoord = snapResult.prjCoord;
        snapAdditionVertex = snapResult.effectedVertex;
      }
      var projection = map.getProjection();
      event.drawTool = this;
      var registerMode = this._getRegisterMode();
      if (this._shouldRecordHistory(registerMode.action)) {
        var path = this._clickCoords.slice(0, this._historyPointer);
        if (path && path.length > 0 && prjCoord.equals(path[path.length - 1])) {
          return;
        }
        registerMode['update'](projection, path.concat(snapAdditionVertex, [prjCoord]), this._geometry, event);
      } else {
        registerMode['update'](projection, prjCoord, this._geometry, event);
      }
      this._fireEvent('mousemove', event);
    };
    _proto._doubleClickHandler = function _doubleClickHandler(event) {
      if (!this._geometry) {
        return;
      }
      var containerPoint = this._getMouseContainerPoint(event);
      if (!this._isValidContainerPoint(containerPoint)) {
        return;
      }
      var registerMode = this._getRegisterMode();
      var clickCoords = this._clickCoords;
      if (clickCoords.length < 2) {
        return;
      }
      var mode = this.getMode();
      if (mode && mode.indexOf('polygon') > -1 && clickCoords.length < 3) {
        return;
      }
      var projection = this.getMap().getProjection();
      var path = [clickCoords[0]];
      for (var i = 1, len = clickCoords.length; i < len; i++) {
        if (clickCoords[i].x !== clickCoords[i - 1].x || clickCoords[i].y !== clickCoords[i - 1].y) {
          path.push(clickCoords[i]);
        }
      }
      if (path.length < 2 || this._geometry && this._geometry instanceof Polygon && path.length < 3) {
        return;
      }
      event.drawTool = this;
      registerMode['update'](projection, path, this._geometry, event);
      this.endDraw(event);
    };
    _proto._addGeometryToStage = function _addGeometryToStage(geometry) {
      var drawLayer = this._getDrawLayer();
      drawLayer.addGeometry(geometry);
    };
    _proto.endDraw = function endDraw(param) {
      if (!this._geometry || this._ending) {
        return this;
      }
      this._ending = true;
      var geometry = this._geometry;
      this._clearStage();
      param = param || {};
      this._geometry = geometry;
      if (!param.ignoreEndEvent) {
        this._fireEvent('drawend', param);
      }
      delete this._geometry;
      if (this.options['once']) {
        this.disable();
      }
      delete this._ending;
      delete this._historyPointer;
      if (this._vertexes) {
        this._vertexes = [];
      }
      return this;
    };
    _proto._clearStage = function _clearStage() {
      this._getDrawLayer().clear();
      delete this._geometry;
      delete this._clickCoords;
    };
    _proto._getMouseContainerPoint = function _getMouseContainerPoint(event) {
      var action = this._getRegisterMode()['action'];
      if (action[0].indexOf('mousedown') >= 0 || action[0].indexOf('touchstart') >= 0) {
        stopPropagation(event['domEvent']);
      }
      return event['containerPoint'];
    };
    _proto._isValidContainerPoint = function _isValidContainerPoint(containerPoint) {
      var mapSize = this._map.getSize();
      var w = mapSize['width'],
        h = mapSize['height'];
      if (containerPoint.x < 0 || containerPoint.y < 0) {
        return false;
      } else if (containerPoint.x > w || containerPoint.y > h) {
        return false;
      }
      return true;
    };
    _proto._getSnapResult = function _getSnapResult(snapTo, containerPoint) {
      var map = this.getMap();
      var lastContainerPoints = [];
      if (this.options.edgeAutoComplete) {
        var lastCoord = this._clickCoords[(this._historyPointer || 1) - 1];
        lastContainerPoints.push(map._prjToContainerPoint(lastCoord));
        var beforeLastCoord = this._clickCoords[(this._historyPointer || 1) - 2];
        if (beforeLastCoord) {
          lastContainerPoints.push(map._prjToContainerPoint(beforeLastCoord));
        }
      }
      var snapResult = snapTo(containerPoint, lastContainerPoints);
      containerPoint = (snapResult.effectedVertex ? snapResult.point : snapResult) || containerPoint;
      var prjCoord = map._containerPointToPrj(containerPoint);
      if (snapResult.effectedVertex) {
        snapResult.effectedVertex = snapResult.effectedVertex.map(function (vertex) {
          return map._containerPointToPrj(vertex);
        });
      }
      return {
        prjCoord: prjCoord,
        effectedVertex: snapResult.effectedVertex || []
      };
    };
    _proto._getDrawLayer = function _getDrawLayer() {
      var drawLayerId = INTERNAL_LAYER_PREFIX + 'drawtool';
      var drawToolLayer = this._map.getLayer(drawLayerId);
      if (!drawToolLayer) {
        drawToolLayer = new VectorLayer(drawLayerId, {
          'enableSimplify': false,
          'enableAltitude': this.options['enableAltitude'],
          'zIndex': this.options.zIndex
        });
        this._map.addLayer(drawToolLayer);
      }
      this._pushLayers(drawToolLayer);
      return drawToolLayer;
    };
    _proto._fireEvent = function _fireEvent(eventName, param) {
      if (!param) {
        param = {};
      }
      param = extend({}, param);
      if (this._geometry) {
        param['geometry'] = this._getRegisterMode()['generate'](this._geometry, {
          drawTool: this
        });
        param.tempGeometry = this._geometry;
      }
      MapTool.prototype._fireEvent.call(this, eventName, param);
    };
    _proto._pushLayers = function _pushLayers(layers) {
      var _this2 = this;
      if (!layers) {
        return this;
      }
      if (!Array.isArray(layers)) {
        layers = [layers];
      }
      this._layers = this._layers || [];
      layers.forEach(function (layer) {
        if (_this2._layers.indexOf(layer) === -1) {
          _this2._layers.push(layer);
        }
      });
      return this;
    };
    _proto._outLayers = function _outLayers(layers) {
      var _this3 = this;
      if (!layers) {
        return this;
      }
      if (!Array.isArray(layers)) {
        layers = [layers];
      }
      this._layers = this._layers || [];
      layers.forEach(function (layer) {
        for (var i = 0, len = _this3._layers.length; i < len; i++) {
          if (layer === _this3._layers[i]) {
            _this3._layers.splice(i, 1);
            break;
          }
        }
      });
      return this;
    };
    _proto.setLayerZIndex = function setLayerZIndex(zIndex) {
      if (!isNumber(zIndex)) {
        return this;
      }
      this.options.zIndex = zIndex;
      this._layers = this._layers || [];
      this._layers.forEach(function (layer) {
        if (layer && layer.setZIndex) {
          layer.setZIndex(zIndex);
        }
      });
      return this;
    };
    return DrawTool;
  }(MapTool);
  DrawTool.mergeOptions(options$g);

  var MapBoxZoomHander = function (_Handler) {
    _inheritsLoose(MapBoxZoomHander, _Handler);
    function MapBoxZoomHander(target) {
      var _this;
      _this = _Handler.call(this, target) || this;
      _this.drawTool = new DrawTool({
        'mode': 'boxZoom',
        'ignoreMouseleave': false
      });
      return _this;
    }
    var _proto = MapBoxZoomHander.prototype;
    _proto.addHooks = function addHooks() {
      this.target.on('_mousedown', this._onMouseDown, this);
    };
    _proto.removeHooks = function removeHooks() {
      this.target.off('_mousedown', this._onMouseDown, this);
      if (this.drawTool.isEnabled()) {
        this.drawTool.remove();
      }
    };
    _proto._onMouseDown = function _onMouseDown(param) {
      if (!this.target.options['boxZoom']) {
        return;
      }
      if (param.domEvent.shiftKey) {
        this.drawTool.setSymbol(this.target.options['boxZoomSymbol']).on('drawend', this._boxZoom, this).addTo(this.target);
      }
    };
    _proto._boxZoom = function _boxZoom(param) {
      var map = this.target;
      this.drawTool.remove();
      var geometry = param.geometry,
        center = geometry.getCenter(),
        symbol = geometry.getSymbol(),
        w = symbol.markerWidth,
        h = symbol.markerHeight;
      var extent = new Extent(center, map.locateByPoint(center, w, h), map.getProjection());
      var zoom = map.getFitZoom(extent);
      map._animateTo({
        center: extent.getCenter(),
        zoom: zoom
      });
    };
    return MapBoxZoomHander;
  }(Handler$1);
  Map$1.mergeOptions({
    'boxZoom': true,
    'boxZoomSymbol': {
      'markerType': 'rectangle',
      'markerLineWidth': 3,
      'markerLineColor': '#1bbc9b',
      'markerLineDasharray': [10, 5],
      'markerFillOpacity': 0.1,
      'markerFill': '#1bbc9b',
      'markerWidth': 1,
      'markerHeight': 1
    }
  });
  Map$1.addOnLoadHook('addHandler', 'boxZoom', MapBoxZoomHander);

  var PANOFFSET = 30;
  var MapAutoPanAtEdgeHandler = function (_Handler) {
    _inheritsLoose(MapAutoPanAtEdgeHandler, _Handler);
    function MapAutoPanAtEdgeHandler() {
      return _Handler.apply(this, arguments) || this;
    }
    var _proto = MapAutoPanAtEdgeHandler.prototype;
    _proto.addHooks = function addHooks() {
      if (!this.target) {
        return;
      }
      this.target.on('_mousemove', this._onMouseMove, this);
    };
    _proto.removeHooks = function removeHooks() {
      if (!this.target) {
        return;
      }
      this.target.off('_mousemove', this._onMouseMove, this);
    };
    _proto._onMouseMove = function _onMouseMove(event) {
      var map = this.target;
      if (map.options['autoPanAtEdge']) {
        var containerPoint = event.containerPoint;
        var containerExtent = map.getContainerExtent();
        if (containerExtent) {
          var x = containerPoint.x,
            y = containerPoint.y;
          var xmax = containerExtent.xmax,
            ymax = containerExtent.ymax;
          var p;
          if (x < PANOFFSET) {
            p = [Math.abs(x - PANOFFSET), 0];
          }
          if (y < PANOFFSET) {
            p = [0, Math.abs(y - PANOFFSET)];
          }
          if (x + PANOFFSET > xmax) {
            p = [-Math.abs(x + PANOFFSET - xmax), 0];
          }
          if (y + PANOFFSET > ymax) {
            p = [0, -Math.abs(y + PANOFFSET - ymax)];
          }
          if (p) {
            map.panBy(p, {
              duration: 1
            });
          }
        }
      }
    };
    return MapAutoPanAtEdgeHandler;
  }(Handler$1);
  Map$1.mergeOptions({
    'autoPanAtEdge': false
  });
  Map$1.addOnLoadHook('addHandler', 'autoPanAtEdge', MapAutoPanAtEdgeHandler);

  Map$1.include({
    animateTo: function animateTo(view, options, step) {
      var _this = this;
      if (options === void 0) {
        options = {};
      }
      view = extend({}, this.getView(), view);
      if (isFunction(options)) {
        step = options;
        options = {};
      }
      var projection = this.getProjection(),
        currView = this.getView(),
        props = {};
      var empty = true;
      for (var p in view) {
        if (hasOwn(view, p) && !isNil(view[p]) && (p === 'prjCenter' || !isNil(currView[p]))) {
          empty = false;
          if (p === 'center') {
            var from = new Coordinate(currView[p]),
              to = new Coordinate(view[p]);
            if (!from.equals(to)) {
              props['center'] = [from, to];
            }
          } else if (p === 'prjCenter') {
            var _from = new Coordinate(this._getPrjCenter());
            var _to = new Coordinate(view[p]);
            if (!_from.equals(_to)) {
              props['prjCenter'] = [_from, _to];
            }
          } else if (currView[p] !== view[p] && p !== 'around') {
            props[p] = [currView[p], view[p]];
          }
        }
      }
      if (empty) {
        return null;
      }
      if (this._animPlayer) {
        if (this._isInternalAnimation) {
          if (this._animPlayer.playState === 'running') {
            this._animPlayer.pause();
            this._prevAnimPlayer = this._animPlayer;
          }
        } else {
          delete this._prevAnimPlayer;
          this._stopAnim(this._animPlayer);
        }
      }
      var zoomOrigin = view['around'] || new Point(this.width / 2, this.height / 2);
      var renderer = this._getRenderer(),
        framer = function framer(fn) {
          renderer.callInNextFrame(fn);
        };
      var player = this._animPlayer = Animation.animate(props, {
        'easing': options['easing'] || 'out',
        'duration': options['duration'] || this.options['zoomAnimationDuration'],
        'framer': framer,
        'repeat': options['repeat']
      }, function (frame) {
        if (_this.isRemoved()) {
          player.finish();
          return;
        }
        if (player.playState === 'running') {
          if (frame.styles['center']) {
            var center = frame.styles['center'];
            _this._setPrjCenter(projection.project(center));
            _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
          } else if (frame.styles['prjCenter']) {
            var _center = frame.styles['prjCenter'];
            _this._setPrjCenter(_center);
            _this.onMoving(_this._parseEventFromCoord(_this.getCenter()));
          }
          if (!isNil(frame.styles['zoom'])) {
            _this.onZooming(frame.styles['zoom'], zoomOrigin);
          }
          if (!isNil(frame.styles['pitch'])) {
            _this._setPitch(frame.styles['pitch']);
          }
          if (!isNil(frame.styles['bearing'])) {
            _this._setBearing(frame.styles['bearing']);
          }
          _this._fireEvent('animating');
        } else if (player.playState !== 'paused' || player === _this._mapAnimPlayer) {
          if (!player._interupted) {
            if (props['center']) {
              _this._setPrjCenter(projection.project(props['center'][1]));
            } else if (props['prjCenter']) {
              _this._setPrjCenter(props['prjCenter'][1]);
            }
            if (!isNil(props['pitch'])) {
              _this._setPitch(props['pitch'][1]);
            }
            if (!isNil(props['bearing'])) {
              _this._setBearing(props['bearing'][1]);
            }
          }
          _this._endAnim(player, props, zoomOrigin, options);
        }
        if (step) {
          step(frame);
        }
      }, this);
      this._startAnim(props, zoomOrigin);
      return player;
    },
    _animateTo: function _animateTo(view, options, step) {
      if (options === void 0) {
        options = {};
      }
      if (this._mapAnimPlayer) {
        this._stopAnim(this._mapAnimPlayer);
      }
      this._isInternalAnimation = true;
      this._mapAnimPlayer = this.animateTo(view, options, step);
      delete this._isInternalAnimation;
      return this._mapAnimPlayer;
    },
    flyTo: function flyTo(view, options, step) {
      var _this2 = this;
      if (options === void 0) {
        options = {};
      }
      view = extend({}, this.getView(), view);
      if (this._animPlayer) {
        if (this._isInternalAnimation) {
          if (this._animPlayer.playState === 'running') {
            this._animPlayer.pause();
            this._prevAnimPlayer = this._animPlayer;
          }
        } else {
          delete this._prevAnimPlayer;
          this._stopAnim(this._animPlayer);
        }
      }
      if (isFunction(options)) {
        step = options;
        options = {};
      }
      options = extend({
        curve: 1.42
      }, options);
      var map = this;
      function zoomScale(z0, z1) {
        return map.getResolution(z1) / map.getResolution(z0);
      }
      var zoomOrigin = view['around'] || new Point(this.width / 2, this.height / 2);
      var minZoom = this.getMinZoom();
      var maxZoom = this.getMaxZoom();
      var projection = this.getProjection();
      var currView = this.getView();
      var startZoom = currView.zoom;
      var startBearing = currView.bearing;
      var startPitch = currView.pitch;
      var zoom = 'zoom' in view ? clamp(+view.zoom, minZoom, maxZoom) : startZoom;
      var bearing = 'bearing' in view ? +view.bearing : startBearing;
      var pitch = 'pitch' in view ? +view.pitch : startPitch;
      var center = projection.project(view.center && new Coordinate(view.center) || this.getCenter());
      var scale = zoomScale(zoom, startZoom);
      var from = projection.project(this.getCenter());
      var delta = center.sub(from);
      var rho = options.curve;
      var w0 = Math.max(this.width, this.height),
        w1 = w0 / scale,
        u1 = delta.mag();
      if ('minZoom' in options) {
        var animMinZoom = clamp(Math.min(options.minZoom, startZoom, zoom), minZoom, maxZoom);
        var wMax = w0 / zoomScale(animMinZoom, startZoom);
        rho = Math.sqrt(wMax / u1 * 2);
      }
      var rho2 = rho * rho;
      function r(i) {
        var b = (w1 * w1 - w0 * w0 + (i ? -1 : 1) * rho2 * rho2 * u1 * u1) / (2 * (i ? w1 : w0) * rho2 * u1);
        return Math.log(Math.sqrt(b * b + 1) - b);
      }
      function sinh(n) {
        return (Math.exp(n) - Math.exp(-n)) / 2;
      }
      function cosh(n) {
        return (Math.exp(n) + Math.exp(-n)) / 2;
      }
      function tanh(n) {
        return sinh(n) / cosh(n);
      }
      var r0 = r(0);
      var w = function w(s) {
        return cosh(r0) / cosh(r0 + rho * s);
      };
      var u = function u(s) {
        return w0 * ((cosh(r0) * tanh(r0 + rho * s) - sinh(r0)) / rho2) / u1;
      };
      var S = (r(1) - r0) / rho;
      if (Math.abs(u1) < 0.000001 || !isFinite(S)) {
        if (Math.abs(w0 - w1) < 0.000001) return this.animateTo(view, options, step);
        var k = w1 < w0 ? -1 : 1;
        S = Math.abs(Math.log(w1 / w0)) / rho;
        u = function u() {
          return 0;
        };
        w = function w(s) {
          return Math.exp(k * rho * s);
        };
      }
      var renderer = this._getRenderer();
      var framer = function framer(fn) {
        renderer.callInNextFrame(fn);
      };
      var player = this._animPlayer = Animation.animate({
        k: [0, 1]
      }, {
        'easing': options['easing'] || 'out',
        'duration': options['duration'] || 8,
        'framer': framer
      }, function (frame) {
        if (_this2.isRemoved()) {
          player.finish();
          return;
        }
        var k = frame.styles.k;
        var s = k * S;
        var scale = 1 / w(s);
        var props = {};
        if (view.center) {
          var newCenter = k === 1 ? center : from.add(delta.multi(u(s)));
          props.prjCenter = [center, newCenter];
        }
        if (startZoom !== zoom) {
          var newZoom = k === 1 ? zoom : _this2.getZoomForScale(scale, startZoom, true);
          props.zoom = [startZoom, newZoom];
        }
        if (startPitch !== pitch) {
          var newPitch = interpolate$2(startPitch, pitch, k);
          props.pitch = [pitch, newPitch];
        }
        if (startBearing !== bearing) {
          var newBearing = interpolate$2(startBearing, bearing, k);
          props.bearing = [bearing, newBearing];
        }
        if (player.playState === 'running') {
          if (props['prjCenter']) {
            var _center2 = props['prjCenter'];
            _this2._setPrjCenter(_center2[1]);
            _this2.onMoving(_this2._parseEventFromCoord(_this2.getCenter()));
          }
          if (props['zoom']) {
            _this2.onZooming(props['zoom'][1], zoomOrigin);
          }
          if (props['pitch']) {
            _this2._setPitch(props['pitch'][1]);
          }
          if (props['bearing']) {
            _this2._setBearing(props['bearing'][1]);
          }
          _this2._fireEvent('animating');
        } else if (player.playState !== 'paused' || player === _this2._mapAnimPlayer) {
          if (!player._interupted) {
            if (props['prjCenter']) {
              _this2._setPrjCenter(props['prjCenter'][1]);
            }
            if (props['pitch']) {
              _this2._setPitch(props['pitch'][1]);
            }
            if (props['bearing']) {
              _this2._setBearing(props['bearing'][1]);
            }
          }
          _this2._endAnim(player, props, zoomOrigin, options);
        }
        if (step) {
          step(frame);
        }
      });
      this._startAnim({
        center: view.center,
        zoom: view.zoom !== startZoom,
        pitch: pitch !== startPitch,
        bearing: bearing !== startBearing
      }, zoomOrigin);
      return this;
    },
    isAnimating: function isAnimating() {
      return !!this._animPlayer;
    },
    isRotating: function isRotating() {
      return this.isDragRotating() || !!this._animRotating;
    },
    _endAnim: function _endAnim(player, props, zoomOrigin, options) {
      delete this._animRotating;
      var evtType = player._interupted ? 'animateinterrupted' : 'animateend';
      if (player === this._animPlayer) {
        delete this._animPlayer;
      }
      if (player === this._mapAnimPlayer) {
        delete this._mapAnimPlayer;
      }
      if (props['center']) {
        var endCoord;
        if (player._interupted) {
          endCoord = this.getCenter();
        } else {
          endCoord = props['center'][1];
        }
        this.onMoveEnd(this._parseEventFromCoord(endCoord));
      } else if (props['prjCenter']) {
        var _endCoord;
        if (player._interupted) {
          _endCoord = this._getPrjCenter();
        } else {
          _endCoord = props['prjCenter'][1];
        }
        var event = this._parseEventFromCoord(this.getProjection().unproject(_endCoord));
        event['point2d'] = this._prjToPoint(_endCoord);
        this.onMoveEnd(event);
      }
      if (!isNil(props['zoom'])) {
        if (player._interupted) {
          this.onZoomEnd(this.getZoom());
        } else if (!options['wheelZoom']) {
          this.onZoomEnd(props['zoom'][1]);
        } else {
          this.onZooming(props['zoom'][1], zoomOrigin);
        }
      }
      if (evtType) {
        this._fireEvent(evtType);
      }
      if (!isNil(props['pitch']) && !this.getPitch()) {
        this.getRenderer().setToRedraw();
      }
      if (!options['wheelZoom']) {
        this._resumePrev(player);
      }
    },
    _startAnim: function _startAnim(props, zoomOrigin) {
      if (!this._animPlayer) {
        return;
      }
      if (props['center'] || props['prjCenter']) {
        this.onMoveStart();
      }
      if (props['zoom'] && !this.isZooming()) {
        this.onZoomStart(props['zoom'][1], zoomOrigin);
      }
      if (props['pitch'] || props['bearing']) {
        this._animRotating = true;
      }
      this._fireEvent('animatestart');
      this._animPlayer.play();
    },
    _stopAnim: function _stopAnim(player) {
      if (!player) {
        return;
      }
      delete this._animRotating;
      if (player.playState !== 'finished') {
        player._interupted = true;
        player.cancel();
      }
      if (player === this._animPlayer) {
        delete this._animPlayer;
      }
      if (player === this._mapAnimPlayer) {
        delete this._mapAnimPlayer;
      }
    },
    _resumePrev: function _resumePrev(player) {
      if (!this._prevAnimPlayer) {
        return;
      }
      var prevPlayer = this._prevAnimPlayer;
      if (prevPlayer.playState !== 'paused') {
        delete this._prevAnimPlayer;
      }
      if (player !== prevPlayer) {
        this._animPlayer = prevPlayer;
        prevPlayer.play();
      }
    }
  });
  function interpolate$2(a, b, t) {
    return a * (1 - t) + b * t;
  }

  function dragEventHanlder(event) {
    event.stopPropagation();
    event.preventDefault();
  }
  var DRAGEVENTS = ['dragstart', 'dragenter', 'dragend', 'dragleave', 'dragover'].join(' ').toString();
  var events = 'mousedown ' + 'mouseup ' + 'mouseover ' + 'mouseout ' + 'mouseenter ' + 'mouseleave ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend ' + 'drop ';
  Map$1.include({
    _registerDomEvents: function _registerDomEvents() {
      var dom = this._panels.mapWrapper || this._containerDOM;
      addDomEvent(dom, events, this._handleDOMEvent, this);
      addDomEvent(dom, DRAGEVENTS, dragEventHanlder, this);
    },
    _removeDomEvents: function _removeDomEvents() {
      var dom = this._panels.mapWrapper || this._containerDOM;
      removeDomEvent(dom, events, this._handleDOMEvent, this);
      removeDomEvent(dom, DRAGEVENTS, dragEventHanlder, this);
    },
    _handleDOMEvent: function _handleDOMEvent(e) {
      if (e && e.type === 'drop') {
        e.stopPropagation();
        e.preventDefault();
        var eventParam = this._parseEvent(e, e.type);
        eventParam = extend({}, eventParam, {
          dataTransfer: e.dataTransfer
        });
        this._fireEvent(e.type, eventParam);
        return;
      }
      var clickTimeThreshold = this.options['clickTimeThreshold'];
      var type = e.type;
      if (isMoveEvent(type) && !Browser$1.isTest && isMousemoveEventBlocked(this, this.options['mousemoveThrottleTime'])) {
        return;
      }
      var isMouseDown = type === 'mousedown' || type === 'touchstart' && (!e.touches || e.touches.length === 1);
      if (isMouseDown) {
        this._domMouseDownTime = now();
        this._domMouseDownView = this.getView();
      }
      var isRotating = type === 'contextmenu' && isRotatingMap(this);
      if (type === 'contextmenu') {
        preventDefault(e);
        var downTime = this._domMouseDownTime;
        var time = now();
        if (time - downTime <= clickTimeThreshold && !isRotating) {
          this._fireDOMEvent(this, e, 'dom:' + e.type);
        }
      } else {
        this._fireDOMEvent(this, e, 'dom:' + e.type);
      }
      if (this._ignoreEvent(e) || this._isEventOutMap(e)) {
        return;
      }
      var mimicClick = false;
      if (isMouseDown) {
        this._mouseDownTime = now();
      } else if (type === 'click' || type === 'touchend' || type === 'contextmenu') {
        if (!this._mouseDownTime) {
          return;
        } else {
          var _downTime = this._mouseDownTime;
          delete this._mouseDownTime;
          var _time = now();
          if (_time - _downTime > clickTimeThreshold) {
            if (type === 'click' || type === 'contextmenu') {
              return;
            }
          } else if (type === 'contextmenu') {
            if (isRotating) {
              return;
            }
          } else if (type === 'touchend') {
            mimicClick = true;
          }
        }
      }
      var mimicEvent;
      if (mimicClick) {
        if (this._clickTime && now() - this._clickTime <= clickTimeThreshold) {
          delete this._clickTime;
          mimicEvent = 'dblclick';
          this._fireDOMEvent(this, e, 'dom:dblclick');
        } else {
          this._clickTime = now();
          mimicEvent = 'click';
          this._fireDOMEvent(this, e, 'dom:click');
        }
      }
      if (this._ignoreEvent(e) || this._isEventOutMap(e)) {
        return;
      }
      this._fireDOMEvent(this, e, type);
      if (mimicEvent) {
        this._fireDOMEvent(this, e, mimicEvent);
      }
    },
    _ignoreEvent: function _ignoreEvent(domEvent) {
      if (!domEvent || !this._panels.control) {
        return false;
      }
      var target = domEvent.srcElement || domEvent.target;
      var preTarget;
      if (target) {
        while (target && target !== this._containerDOM) {
          if (target.className && target.className.indexOf && (target.className.indexOf('maptalks-control') >= 0 || target.className.indexOf('maptalks-ui') >= 0 && preTarget && !preTarget['eventsPropagation'])) {
            return true;
          }
          preTarget = target;
          target = target.parentNode;
        }
      }
      return false;
    },
    _isEventOutMap: function _isEventOutMap(domEvent) {
      if (this.getPitch() > this.options['maxVisualPitch']) {
        var actualEvent = this._getActualEvent(domEvent);
        var eventPos = getEventContainerPoint(actualEvent, this._containerDOM);
        if (!this.getContainerExtent().contains(eventPos)) {
          return true;
        }
      }
      return false;
    },
    _parseEvent: function _parseEvent(e, type) {
      if (!e) {
        return null;
      }
      var eventParam = {
        'domEvent': e
      };
      if (type !== 'keypress') {
        var actual = this._getActualEvent(e);
        if (actual && actual.clientX !== undefined) {
          var containerPoint = getEventContainerPoint(actual, this._containerDOM);
          eventParam = extend(eventParam, {
            'containerPoint': containerPoint,
            'viewPoint': this.containerPointToViewPoint(containerPoint)
          });
          var maxVisualPitch = this.options['maxVisualPitch'];
          if (this.getPitch() <= maxVisualPitch || containerPoint.y >= this.height - this._getVisualHeight(maxVisualPitch)) {
            eventParam = extend(eventParam, {
              'coordinate': this.containerPointToCoord(containerPoint),
              'point2d': this._containerPointToPoint(containerPoint)
            });
          }
        }
      }
      return eventParam;
    },
    _parseEventFromCoord: function _parseEventFromCoord(coord) {
      var containerPoint = this.coordToContainerPoint(coord),
        viewPoint = this.containerPointToViewPoint(containerPoint);
      var e = {
        'coordinate': coord,
        'containerPoint': containerPoint,
        'viewPoint': viewPoint,
        'point2d': this.coordToPoint(coord)
      };
      return e;
    },
    _getActualEvent: function _getActualEvent(e) {
      return e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
    },
    _fireDOMEvent: function _fireDOMEvent(target, e, type) {
      var _this = this;
      if (this.isRemoved()) {
        return;
      }
      var eventParam = this._parseEvent(e, type);
      if (isMoveEvent(type)) {
        this.getRenderer().callInNextFrame(function () {
          if (eventParam.domEvent && eventParam.domEvent._cancelBubble) {
            _this._fireEvent('_' + type, eventParam);
            return;
          }
          _this._fireEvent(type, eventParam);
        });
      } else {
        this._fireEvent(type, eventParam);
      }
    },
    _getEventParams: function _getEventParams(e) {
      var map = this;
      var eventParam = {
        'domEvent': e
      };
      var actual = e.touches && e.touches.length > 0 ? e.touches[0] : e.changedTouches && e.changedTouches.length > 0 ? e.changedTouches[0] : e;
      if (actual) {
        var containerPoint = getEventContainerPoint(actual, map._containerDOM);
        eventParam['coordinate'] = map.containerPointToCoordinate(containerPoint);
        eventParam['containerPoint'] = containerPoint;
        eventParam['viewPoint'] = map.containerPointToViewPoint(containerPoint);
        eventParam['pont2d'] = map._containerPointToPoint(containerPoint);
      }
      return eventParam;
    }
  });
  Map$1.addOnLoadHook('_registerDomEvents');
  function isRotatingMap(map) {
    if (!map._domMouseDownView) {
      return true;
    }
    var view = map.getView(),
      mouseDownView = map._domMouseDownView;
    return view.bearing !== mouseDownView.bearing || view.pitch !== mouseDownView.pitch;
  }

  Map$1.include({
    isFullScreen: function isFullScreen() {
      return !!(document.webkitIsFullScreen || document.mozFullScreen || document.msFullscreenElement || document.fullscreenElement);
    },
    requestFullScreen: function requestFullScreen(dom) {
      this._fireEvent('fullscreenstart');
      this._requestFullScreen(dom || this._containerDOM);
      this._fireEvent('fullscreenend');
      return this;
    },
    cancelFullScreen: function cancelFullScreen() {
      this._cancelFullScreen();
      this._fireEvent('cancelfullscreen');
      return this;
    },
    _requestFullScreen: function _requestFullScreen(dom) {
      if (dom.requestFullscreen) {
        dom.requestFullscreen();
      } else if (dom.mozRequestFullScreen) {
        dom.mozRequestFullScreen();
      } else if (dom.webkitRequestFullScreen) {
        dom.webkitRequestFullScreen();
      } else if (dom.msRequestFullScreen) {
        dom.msRequestFullScreen();
      } else {
        var features = 'fullscreen=1,status=no,resizable=yes,top=0,left=0,scrollbars=no,' + 'titlebar=no,menubar=no,location=no,toolbar=no,z-look=yes,' + 'width=' + (screen.availWidth - 8) + ',height=' + (screen.availHeight - 45);
        var newWin = window.open(location.href, '_blank', features);
        if (newWin !== null) {
          window.opener = null;
          window.close();
        }
      }
    },
    _cancelFullScreen: function _cancelFullScreen() {
      if (document.exitFullscreen) {
        document.exitFullscreen();
      } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
      } else if (document.webkitCancelFullScreen) {
        document.webkitCancelFullScreen();
      } else {
        var features = 'fullscreen=no,status=yes,resizable=yes,scrollbars=no,' + 'titlebar=no,menubar=yes,location=yes,toolbar=yes,z-look=yes';
        var newWin = window.open(location.href, '_blank', features);
        if (newWin !== null) {
          window.opener = null;
          window.close();
        }
      }
    }
  });

  Map$1.include({
    panTo: function panTo(coordinate, options, step) {
      if (options === void 0) {
        options = {};
      }
      if (!coordinate) {
        return this;
      }
      if (isFunction(options)) {
        step = options;
        options = {};
      }
      coordinate = new Coordinate(coordinate);
      if (typeof options['animation'] === 'undefined' || options['animation']) {
        var prjCoord = this.getProjection().project(coordinate);
        return this._panAnimation(prjCoord, options['duration'], step);
      } else {
        this.setCenter(coordinate);
      }
      return this;
    },
    _panTo: function _panTo(prjCoord, options) {
      if (options === void 0) {
        options = {};
      }
      if (typeof options['animation'] === 'undefined' || options['animation']) {
        return this._panAnimation(prjCoord, options['duration']);
      } else {
        this.onMoveStart();
        this._setPrjCenter(prjCoord);
        this.onMoveEnd(this._parseEventFromCoord(this.getCenter()));
        return this;
      }
    },
    panBy: function panBy(offset, options, step) {
      if (options === void 0) {
        options = {};
      }
      if (!offset) {
        return this;
      }
      if (isFunction(options)) {
        step = options;
        options = {};
      }
      offset = new Point(offset);
      var containerExtent = this.getContainerExtent();
      var ymin = containerExtent.ymin;
      if (ymin > 0 && offset.y > 30) {
        var y = offset.y;
        offset.y = 30;
        offset.x = offset.x * 30 / y;
        console.warn('offset is limited to panBy when pitch is above maxPitch');
      }
      if (typeof options['animation'] === 'undefined' || options['animation']) {
        offset = offset.multi(-1);
        var target = this._containerPointToPrj(new Point(this.width / 2 + offset.x, this.height / 2 + offset.y));
        this._panAnimation(target, options['duration'], step);
      } else {
        this.onMoveStart();
        this._offsetCenterByPixel(offset);
        var endCoord = this.containerPointToCoord(new Point(this.width / 2, this.height / 2));
        this.onMoveEnd(this._parseEventFromCoord(endCoord));
      }
      return this;
    },
    _panAnimation: function _panAnimation(target, t, cb) {
      return this._animateTo({
        'prjCenter': target
      }, {
        'duration': t || this.options['panAnimationDuration']
      }, cb);
    }
  });

  Geometry.fromJSON = function (json) {
    if (Array.isArray(json)) {
      var result = [];
      for (var i = 0, len = json.length; i < len; i++) {
        var c = Geometry.fromJSON(json[i]);
        if (Array.isArray(json)) {
          result = result.concat(c);
        } else {
          result.push(c);
        }
      }
      return result;
    }
    if (json && !json['feature']) {
      return GeoJSON.toGeometry(json);
    }
    var geometry;
    if (json['subType']) {
      geometry = Geometry.getJSONClass(json['subType']).fromJSON(json);
      if (!isNil(json['feature']['id'])) {
        geometry.setId(json['feature']['id']);
      }
    } else {
      geometry = GeoJSON.toGeometry(json['feature']);
      if (json['options']) {
        geometry.config(json['options']);
      }
    }
    if (json['symbol']) {
      geometry.setSymbol(json['symbol']);
    }
    if (json['infoWindow']) {
      geometry.setInfoWindow(json['infoWindow']);
    }
    return geometry;
  };
  Layer.fromJSON = function (layerJSON) {
    if (!layerJSON) {
      return null;
    }
    var layerType = layerJSON['type'];
    var clazz = Layer.getJSONClass(layerType);
    if (!clazz || !clazz.fromJSON) {
      throw new Error('unsupported layer type:' + layerType);
    }
    return clazz.fromJSON(layerJSON);
  };
  Map$1.include({
    'JSON_VERSION': '1.0',
    toJSON: function toJSON(options) {
      if (!options) {
        options = {};
      }
      var json = {
        'jsonVersion': this['JSON_VERSION'],
        'version': this.VERSION,
        'extent': this.getExtent().toJSON()
      };
      json['options'] = this.config();
      json['options']['center'] = this.getCenter();
      json['options']['zoom'] = this.getZoom();
      json['options']['bearing'] = this.getBearing();
      json['options']['pitch'] = this.getPitch();
      var baseLayer = this.getBaseLayer();
      if ((isNil(options['baseLayer']) || options['baseLayer']) && baseLayer) {
        json['baseLayer'] = baseLayer.toJSON(options['baseLayer']);
      }
      var extraLayerOptions = {};
      if (options['clipExtent']) {
        if (options['clipExtent'] === true) {
          extraLayerOptions['clipExtent'] = this.getExtent();
        } else {
          extraLayerOptions['clipExtent'] = options['clipExtent'];
        }
      }
      var layersJSON = [];
      if (isNil(options['layers']) || options['layers'] && !Array.isArray(options['layers'])) {
        var layers = this.getLayers();
        for (var i = 0, len = layers.length; i < len; i++) {
          if (!layers[i].toJSON) {
            continue;
          }
          var opts = extend({}, isObject(options['layers']) ? options['layers'] : {}, extraLayerOptions);
          layersJSON.push(layers[i].toJSON(opts));
        }
        json['layers'] = layersJSON;
      } else if (isArrayHasData(options['layers'])) {
        var _layers = options['layers'];
        for (var _i = 0; _i < _layers.length; _i++) {
          var exportOption = _layers[_i];
          var layer = this.getLayer(exportOption['id']);
          if (!layer.toJSON) {
            continue;
          }
          var _opts = extend({}, exportOption['options'], extraLayerOptions);
          layersJSON.push(layer.toJSON(_opts));
        }
        json['layers'] = layersJSON;
      } else {
        json['layers'] = [];
      }
      return json;
    }
  });
  Map$1.fromJSON = function (container, profile, options) {
    if (!container || !profile) {
      return null;
    }
    if (!options) {
      options = {};
    }
    var map = new Map$1(container, profile['options']);
    if (isNil(options['baseLayer']) || options['baseLayer']) {
      var baseLayer = Layer.fromJSON(profile['baseLayer']);
      if (baseLayer) {
        map.setBaseLayer(baseLayer);
      }
    }
    if (isNil(options['layers']) || options['layers']) {
      var layers = [];
      var layerJSONs = profile['layers'];
      for (var i = 0; i < layerJSONs.length; i++) {
        var layer = Layer.fromJSON(layerJSONs[i]);
        layers.push(layer);
      }
      map.addLayer(layers);
    }
    return map;
  };

  Map$1.include({
    computeLength: function computeLength(coord1, coord2) {
      if (!this.getProjection()) {
        return null;
      }
      var p1 = new Coordinate(coord1),
        p2 = new Coordinate(coord2);
      if (p1.equals(p2)) {
        return 0;
      }
      return this.getProjection().measureLength(p1, p2);
    },
    computeGeometryLength: function computeGeometryLength(geometry) {
      return geometry._computeGeodesicLength(this.getProjection());
    },
    computeGeometryArea: function computeGeometryArea(geometry) {
      return geometry._computeGeodesicArea(this.getProjection());
    },
    identify: function identify(opts, callback) {
      opts = opts || {};
      var coordinate = new Coordinate(opts['coordinate']);
      return this._identify(opts, callback, function (layer) {
        return layer.identify(coordinate, opts);
      });
    },
    identifyAtPoint: function identifyAtPoint(opts, callback) {
      var isMapGeometryEvent = opts.includeInternals;
      var tolerance = opts.tolerance;
      opts = opts || {};
      var containerPoint = new Point(opts['containerPoint']);
      var coordinate = this.containerPointToCoord(containerPoint);
      return this._identify(opts, callback, function (layer) {
        var result;
        var containerPoint = opts.containerPoint;
        if (isMapGeometryEvent && !isNil(layer.options.geometryEventTolerance)) {
          opts.tolerance = opts.tolerance || 0;
          opts.tolerance += layer.options.geometryEventTolerance;
        }
        if (layer._hasGeoListeners && isMapGeometryEvent && opts.eventTypes.indexOf('mousemove') >= 0) {
          if (!layer._hasGeoListeners(opts.eventTypes)) {
            return [];
          }
        }
        if (layer.identifyAtPoint) {
          result = layer.identifyAtPoint(containerPoint, opts);
        } else if (coordinate && layer.identify) {
          result = layer.identify(coordinate, opts);
        } else {
          result = [];
        }
        if (isMapGeometryEvent) {
          if (isNil(tolerance)) {
            delete opts.tolerance;
          } else {
            opts.tolerance = tolerance;
          }
        }
        if (!result || !result.length) {
          layer.fire('identifyempty', opts);
          if (layer.getLayers && isFunction(layer.getLayers)) {
            var layers = (layer.getLayers() || []).filter(function (childLayer) {
              return childLayer;
            });
            layers.forEach(function (childLayer) {
              childLayer.fire('identifyempty', opts);
            });
          }
        }
        return result;
      });
    },
    _identify: function _identify(opts, callback, fn) {
      var reqLayers = opts['layers'];
      if (!isArrayHasData(reqLayers)) {
        return this;
      }
      var eventTypes = opts.eventTypes;
      var layers = [];
      for (var i = 0, len = reqLayers.length; i < len; i++) {
        if (isString(reqLayers[i])) {
          layers.push(this.getLayer(reqLayers[i]));
        } else {
          layers.push(reqLayers[i]);
        }
      }
      if (eventTypes) {
        layers = layers.filter(function (layer) {
          if (!layer._hasGeoListeners) {
            return true;
          }
          return layer._hasGeoListeners(eventTypes);
        });
      }
      var hits = [];
      for (var _i = layers.length - 1; _i >= 0; _i--) {
        if (opts['count'] && hits.length >= opts['count']) {
          break;
        }
        var layer = layers[_i];
        if (!layer || !layer.getMap() || !opts['includeInvisible'] && !layer.isVisible() || !opts['includeInternals'] && layer.getId().indexOf(INTERNAL_LAYER_PREFIX) >= 0) {
          continue;
        }
        var layerHits = fn(layer);
        var layerId = layer.getId();
        if (layerHits) {
          if (Array.isArray(layerHits)) {
            for (var _i2 = 0; _i2 < layerHits.length; _i2++) {
              if (layerHits[_i2] && !layerHits[_i2].getLayer && isNil(layerHits[_i2].layer)) {
                layerHits[_i2].layer = layerId;
              }
            }
            pushIn(hits, layerHits);
          } else {
            if (!layerHits.getLayer && isNil(layerHits.layer)) {
              layerHits.layer = layerId;
            }
            hits.push(layerHits);
          }
        }
      }
      callback.call(this, hits);
      return this;
    }
  });

  Map$1.include({
    _zoom: function _zoom(nextZoom, origin) {
      if (!this.options['zoomable'] || this.isZooming()) {
        return;
      }
      origin = this._checkZoomOrigin(origin);
      nextZoom = this._checkZoom(nextZoom);
      this.onZoomStart(nextZoom, origin);
      this._frameZoom = this.getZoom();
      this.onZoomEnd(nextZoom, origin);
    },
    _zoomAnimation: function _zoomAnimation(nextZoom, origin, startScale) {
      if (!this.options['zoomable'] || this.isZooming()) {
        return;
      }
      nextZoom = this._checkZoom(nextZoom);
      if (this.getZoom() === nextZoom) {
        return;
      }
      origin = this._checkZoomOrigin(origin);
      this._startZoomAnim(nextZoom, origin, startScale);
    },
    _checkZoomOrigin: function _checkZoomOrigin(origin) {
      if (!origin || this.options['zoomInCenter']) {
        origin = new Point(this.width / 2, this.height / 2);
      }
      if (this.options['zoomOrigin']) {
        origin = new Point(this.options['zoomOrigin']);
      }
      return origin;
    },
    _startZoomAnim: function _startZoomAnim(nextZoom, origin, startScale) {
      if (isNil(startScale)) {
        startScale = 1;
      }
      var endScale = this._getResolution(this._startZoomVal) / this._getResolution(nextZoom);
      var duration = this.options['zoomAnimationDuration'] * Math.abs(endScale - startScale) / Math.abs(endScale - 1);
      this._frameZoom = this._startZoomVal;
      this._animateTo({
        'zoom': nextZoom,
        'around': origin
      }, {
        'continueOnViewChanged': true,
        'duration': duration
      });
    },
    onZoomStart: function onZoomStart(nextZoom, origin) {
      if (!this.options['zoomable'] || this.isZooming()) {
        return;
      }
      if (this._mapAnimPlayer) {
        this._stopAnim(this._mapAnimPlayer);
      }
      delete this.cameraZenithDistance;
      this._zooming = true;
      this._startZoomVal = this.getZoom();
      this._startZoomCoord = this._containerPointToPrj(origin);
      this._fireEvent('zoomstart', {
        'from': this._startZoomVal,
        'to': nextZoom
      });
    },
    onZooming: function onZooming(nextZoom, origin, startScale) {
      if (!this.options['zoomable']) {
        return;
      }
      var frameZoom = this._frameZoom;
      if (frameZoom === nextZoom) {
        return;
      }
      if (isNil(startScale)) {
        startScale = 1;
      }
      this._zoomTo(nextZoom, origin);
      var res = this.getResolution(nextZoom),
        fromRes = this.getResolution(this._startZoomVal),
        scale = fromRes / res / startScale,
        startPoint = this._prjToContainerPoint(this._startZoomCoord, this._startZoomVal);
      var offset = this.getViewPoint();
      if (!this.isRotating() && !startPoint.equals(origin) && scale !== 1) {
        var pitch = this.getPitch();
        var originOffset = startPoint._sub(origin)._multi(1 / (1 - scale));
        if (pitch) {
          originOffset.y /= Math.cos(pitch * Math.PI / 180);
        }
        origin = origin.add(originOffset);
      }
      var matrix = {
        'view': [scale, 0, 0, scale, (origin.x - offset.x) * (1 - scale), (origin.y - offset.y) * (1 - scale)]
      };
      var dpr = this.getDevicePixelRatio();
      if (dpr !== 1) {
        origin = origin.multi(dpr);
      }
      matrix['container'] = [scale, 0, 0, scale, origin.x * (1 - scale), origin.y * (1 - scale)];
      this._fireEvent('zooming', {
        'from': this._startZoomVal,
        'to': nextZoom,
        'origin': origin,
        'matrix': matrix
      });
      this._frameZoom = nextZoom;
    },
    onZoomEnd: function onZoomEnd(nextZoom, origin) {
      if (!this.options['zoomable']) {
        return;
      }
      var startZoomVal = this._startZoomVal;
      this._zoomTo(nextZoom, origin);
      this._zooming = false;
      this._getRenderer().onZoomEnd();
      if (!this._suppressRecenter) {
        this._recenterOnTerrain();
      }
      this._fireEvent('zoomend', {
        'from': startZoomVal,
        'to': nextZoom
      });
      if (!this._verifyExtent(this._getPrjCenter())) {
        this._panTo(this._prjMaxExtent.getCenter());
      }
    },
    _zoomTo: function _zoomTo(nextZoom, origin) {
      this._zoomLevel = nextZoom;
      this._calcMatrices();
      if (origin) {
        this._setPrjCoordAtContainerPoint(this._startZoomCoord, origin);
      }
    },
    _checkZoom: function _checkZoom(nextZoom) {
      var maxZoom = this.getMaxZoom(),
        minZoom = this.getMinZoom();
      if (nextZoom < minZoom) {
        nextZoom = minZoom;
      }
      if (nextZoom > maxZoom) {
        nextZoom = maxZoom;
      }
      return nextZoom;
    }
  });

  function perspective(out, fovy, aspect, near, far) {
    var f = 1.0 / Math.tan(fovy / 2),
      nf = 1 / (near - far);
    out[0] = f / aspect;
    out[1] = 0;
    out[2] = 0;
    out[3] = 0;
    out[4] = 0;
    out[5] = f;
    out[6] = 0;
    out[7] = 0;
    out[8] = 0;
    out[9] = 0;
    out[10] = (far + near) * nf;
    out[11] = -1;
    out[12] = 0;
    out[13] = 0;
    out[14] = 2 * far * near * nf;
    out[15] = 0;
    return out;
  }
  function translate(out, a, v) {
    var x = v[0],
      y = v[1],
      z = v[2],
      a00,
      a01,
      a02,
      a03,
      a10,
      a11,
      a12,
      a13,
      a20,
      a21,
      a22,
      a23;
    if (a === out) {
      out[12] = a[0] * x + a[4] * y + a[8] * z + a[12];
      out[13] = a[1] * x + a[5] * y + a[9] * z + a[13];
      out[14] = a[2] * x + a[6] * y + a[10] * z + a[14];
      out[15] = a[3] * x + a[7] * y + a[11] * z + a[15];
    } else {
      a00 = a[0];
      a01 = a[1];
      a02 = a[2];
      a03 = a[3];
      a10 = a[4];
      a11 = a[5];
      a12 = a[6];
      a13 = a[7];
      a20 = a[8];
      a21 = a[9];
      a22 = a[10];
      a23 = a[11];
      out[0] = a00;
      out[1] = a01;
      out[2] = a02;
      out[3] = a03;
      out[4] = a10;
      out[5] = a11;
      out[6] = a12;
      out[7] = a13;
      out[8] = a20;
      out[9] = a21;
      out[10] = a22;
      out[11] = a23;
      out[12] = a00 * x + a10 * y + a20 * z + a[12];
      out[13] = a01 * x + a11 * y + a21 * z + a[13];
      out[14] = a02 * x + a12 * y + a22 * z + a[14];
      out[15] = a03 * x + a13 * y + a23 * z + a[15];
    }
    return out;
  }
  function scale(out, a, v) {
    var x = v[0],
      y = v[1],
      z = v[2];
    out[0] = a[0] * x;
    out[1] = a[1] * x;
    out[2] = a[2] * x;
    out[3] = a[3] * x;
    out[4] = a[4] * y;
    out[5] = a[5] * y;
    out[6] = a[6] * y;
    out[7] = a[7] * y;
    out[8] = a[8] * z;
    out[9] = a[9] * z;
    out[10] = a[10] * z;
    out[11] = a[11] * z;
    out[12] = a[12];
    out[13] = a[13];
    out[14] = a[14];
    out[15] = a[15];
    return out;
  }
  function rotateX(out, a, rad) {
    var s = Math.sin(rad),
      c = Math.cos(rad),
      a10 = a[4],
      a11 = a[5],
      a12 = a[6],
      a13 = a[7],
      a20 = a[8],
      a21 = a[9],
      a22 = a[10],
      a23 = a[11];
    if (a !== out) {
      out[0] = a[0];
      out[1] = a[1];
      out[2] = a[2];
      out[3] = a[3];
      out[12] = a[12];
      out[13] = a[13];
      out[14] = a[14];
      out[15] = a[15];
    }
    out[4] = a10 * c + a20 * s;
    out[5] = a11 * c + a21 * s;
    out[6] = a12 * c + a22 * s;
    out[7] = a13 * c + a23 * s;
    out[8] = a20 * c - a10 * s;
    out[9] = a21 * c - a11 * s;
    out[10] = a22 * c - a12 * s;
    out[11] = a23 * c - a13 * s;
    return out;
  }
  function rotateZ(out, a, rad) {
    var s = Math.sin(rad),
      c = Math.cos(rad),
      a00 = a[0],
      a01 = a[1],
      a02 = a[2],
      a03 = a[3],
      a10 = a[4],
      a11 = a[5],
      a12 = a[6],
      a13 = a[7];
    if (a !== out) {
      out[8] = a[8];
      out[9] = a[9];
      out[10] = a[10];
      out[11] = a[11];
      out[12] = a[12];
      out[13] = a[13];
      out[14] = a[14];
      out[15] = a[15];
    }
    out[0] = a00 * c + a10 * s;
    out[1] = a01 * c + a11 * s;
    out[2] = a02 * c + a12 * s;
    out[3] = a03 * c + a13 * s;
    out[4] = a10 * c - a00 * s;
    out[5] = a11 * c - a01 * s;
    out[6] = a12 * c - a02 * s;
    out[7] = a13 * c - a03 * s;
    return out;
  }
  function multiply(out, a, b) {
    var a00 = a[0],
      a01 = a[1],
      a02 = a[2],
      a03 = a[3],
      a10 = a[4],
      a11 = a[5],
      a12 = a[6],
      a13 = a[7],
      a20 = a[8],
      a21 = a[9],
      a22 = a[10],
      a23 = a[11],
      a30 = a[12],
      a31 = a[13],
      a32 = a[14],
      a33 = a[15];
    var b0 = b[0],
      b1 = b[1],
      b2 = b[2],
      b3 = b[3];
    out[0] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
    out[1] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
    out[2] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
    out[3] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
    b0 = b[4];
    b1 = b[5];
    b2 = b[6];
    b3 = b[7];
    out[4] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
    out[5] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
    out[6] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
    out[7] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
    b0 = b[8];
    b1 = b[9];
    b2 = b[10];
    b3 = b[11];
    out[8] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
    out[9] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
    out[10] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
    out[11] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
    b0 = b[12];
    b1 = b[13];
    b2 = b[14];
    b3 = b[15];
    out[12] = b0 * a00 + b1 * a10 + b2 * a20 + b3 * a30;
    out[13] = b0 * a01 + b1 * a11 + b2 * a21 + b3 * a31;
    out[14] = b0 * a02 + b1 * a12 + b2 * a22 + b3 * a32;
    out[15] = b0 * a03 + b1 * a13 + b2 * a23 + b3 * a33;
    return out;
  }
  function invert(out, a) {
    var a00 = a[0],
      a01 = a[1],
      a02 = a[2],
      a03 = a[3],
      a10 = a[4],
      a11 = a[5],
      a12 = a[6],
      a13 = a[7],
      a20 = a[8],
      a21 = a[9],
      a22 = a[10],
      a23 = a[11],
      a30 = a[12],
      a31 = a[13],
      a32 = a[14],
      a33 = a[15],
      b00 = a00 * a11 - a01 * a10,
      b01 = a00 * a12 - a02 * a10,
      b02 = a00 * a13 - a03 * a10,
      b03 = a01 * a12 - a02 * a11,
      b04 = a01 * a13 - a03 * a11,
      b05 = a02 * a13 - a03 * a12,
      b06 = a20 * a31 - a21 * a30,
      b07 = a20 * a32 - a22 * a30,
      b08 = a20 * a33 - a23 * a30,
      b09 = a21 * a32 - a22 * a31,
      b10 = a21 * a33 - a23 * a31,
      b11 = a22 * a33 - a23 * a32,
      det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
    if (!det) {
      return null;
    }
    det = 1.0 / det;
    out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
    out[1] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
    out[2] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
    out[3] = (a22 * b04 - a21 * b05 - a23 * b03) * det;
    out[4] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
    out[5] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
    out[6] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
    out[7] = (a20 * b05 - a22 * b02 + a23 * b01) * det;
    out[8] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
    out[9] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
    out[10] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
    out[11] = (a21 * b02 - a20 * b04 - a23 * b00) * det;
    out[12] = (a11 * b07 - a10 * b09 - a12 * b06) * det;
    out[13] = (a00 * b09 - a01 * b07 + a02 * b06) * det;
    out[14] = (a31 * b01 - a30 * b03 - a32 * b00) * det;
    out[15] = (a20 * b03 - a21 * b01 + a22 * b00) * det;
    return out;
  }
  function identity(out) {
    out[0] = 1;
    out[1] = 0;
    out[2] = 0;
    out[3] = 0;
    out[4] = 0;
    out[5] = 1;
    out[6] = 0;
    out[7] = 0;
    out[8] = 0;
    out[9] = 0;
    out[10] = 1;
    out[11] = 0;
    out[12] = 0;
    out[13] = 0;
    out[14] = 0;
    out[15] = 1;
    return out;
  }
  function copy(out, a) {
    out[0] = a[0];
    out[1] = a[1];
    out[2] = a[2];
    out[3] = a[3];
    out[4] = a[4];
    out[5] = a[5];
    out[6] = a[6];
    out[7] = a[7];
    out[8] = a[8];
    out[9] = a[9];
    out[10] = a[10];
    out[11] = a[11];
    out[12] = a[12];
    out[13] = a[13];
    out[14] = a[14];
    out[15] = a[15];
    return out;
  }

  function set$2(out, x, y, z) {
    out[0] = x;
    out[1] = y;
    out[2] = z;
    return out;
  }
  function add(out, a, b) {
    out[0] = a[0] + b[0];
    out[1] = a[1] + b[1];
    out[2] = a[2] + b[2];
    return out;
  }
  function subtract(out, a, b) {
    out[0] = a[0] - b[0];
    out[1] = a[1] - b[1];
    out[2] = a[2] - b[2];
    return out;
  }
  function length(a) {
    var x = a[0],
      y = a[1],
      z = a[2];
    return Math.sqrt(x * x + y * y + z * z);
  }
  function normalize(out, a) {
    var x = a[0],
      y = a[1],
      z = a[2];
    var len = x * x + y * y + z * z;
    if (len > 0) {
      len = 1 / Math.sqrt(len);
      out[0] = a[0] * len;
      out[1] = a[1] * len;
      out[2] = a[2] * len;
    }
    return out;
  }
  function dot(a, b) {
    return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  }
  function scale$1(out, a, b) {
    out[0] = a[0] * b;
    out[1] = a[1] * b;
    out[2] = a[2] * b;
    return out;
  }
  function cross(out, a, b) {
    var ax = a[0],
      ay = a[1],
      az = a[2],
      bx = b[0],
      by = b[1],
      bz = b[2];
    out[0] = ay * bz - az * by;
    out[1] = az * bx - ax * bz;
    out[2] = ax * by - ay * bx;
    return out;
  }
  function distance(a, b) {
    var x = b[0] - a[0];
    var y = b[1] - a[1];
    var z = b[2] - a[2];
    return Math.hypot ? Math.hypot(x, y, z) : hypot$1(x, y, z);
  }
  function transformMat4(out, a, m) {
    var x = a[0],
      y = a[1],
      z = a[2];
    var w = m[3] * x + m[7] * y + m[11] * z + m[15];
    w = w || 1.0;
    out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
    out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
    out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
    return out;
  }
  function hypot$1() {
    var y = 0;
    var i = arguments.length;
    while (i--) {
      y += arguments[i] * arguments[i];
    }
    return Math.sqrt(y);
  }

  function applyMatrix(out, v, e) {
    var x = v[0],
      y = v[1],
      z = v[2];
    var w = 1 / (e[3] * x + e[7] * y + e[11] * z + e[15]);
    out[0] = (e[0] * x + e[4] * y + e[8] * z + e[12]) * w;
    out[1] = (e[1] * x + e[5] * y + e[9] * z + e[13]) * w;
    out[2] = (e[2] * x + e[6] * y + e[10] * z + e[14]) * w;
    return out;
  }
  function matrixToQuaternion(out, te) {
    var m11 = te[0],
      m12 = te[4],
      m13 = te[8],
      m21 = te[1],
      m22 = te[5],
      m23 = te[9],
      m31 = te[2],
      m32 = te[6],
      m33 = te[10],
      trace = m11 + m22 + m33;
    var s;
    if (trace > 0) {
      s = 0.5 / Math.sqrt(trace + 1.0);
      out.w = 0.25 / s;
      out.x = (m32 - m23) * s;
      out.y = (m13 - m31) * s;
      out.z = (m21 - m12) * s;
    } else if (m11 > m22 && m11 > m33) {
      s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
      out.w = (m32 - m23) / s;
      out.x = 0.25 * s;
      out.y = (m12 + m21) / s;
      out.z = (m13 + m31) / s;
    } else if (m22 > m33) {
      s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
      out.w = (m13 - m31) / s;
      out.x = (m12 + m21) / s;
      out.y = 0.25 * s;
      out.z = (m23 + m32) / s;
    } else {
      s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
      out.w = (m21 - m12) / s;
      out.x = (m13 + m31) / s;
      out.y = (m23 + m32) / s;
      out.z = 0.25 * s;
    }
    return this;
  }
  function quaternionToMatrix(out, q) {
    var te = out;
    var x = q.x,
      y = q.y,
      z = q.z,
      w = q.w;
    var x2 = x + x,
      y2 = y + y,
      z2 = z + z;
    var xx = x * x2,
      xy = x * y2,
      xz = x * z2;
    var yy = y * y2,
      yz = y * z2,
      zz = z * z2;
    var wx = w * x2,
      wy = w * y2,
      wz = w * z2;
    te[0] = 1 - (yy + zz);
    te[4] = xy - wz;
    te[8] = xz + wy;
    te[1] = xy + wz;
    te[5] = 1 - (xx + zz);
    te[9] = yz - wx;
    te[2] = xz - wy;
    te[6] = yz + wx;
    te[10] = 1 - (xx + yy);
    te[3] = 0;
    te[7] = 0;
    te[11] = 0;
    te[12] = 0;
    te[13] = 0;
    te[14] = 0;
    te[15] = 1;
    return te;
  }
  function setPosition(out, v) {
    var te = out;
    te[12] = v[0];
    te[13] = v[1];
    te[14] = v[2];
    return out;
  }
  function lookAt(te, eye, target, up) {
    var x = [0, 0, 0];
    var y = [0, 0, 0];
    var z = [0, 0, 0];
    subtract(z, eye, target);
    if (length(z) === 0) {
      z[2] = 1;
    }
    normalize(z, z);
    cross(x, up, z);
    if (length(z) === 0) {
      if (Math.abs(up[2]) === 1) {
        z[0] += 0.0001;
      } else {
        z[2] += 0.0001;
      }
      normalize(z, z);
      cross(x, up, z);
    }
    normalize(x, x);
    cross(y, z, x);
    te[0] = x[0];
    te[4] = y[0];
    te[8] = z[0];
    te[1] = x[1];
    te[5] = y[1];
    te[9] = z[1];
    te[2] = x[2];
    te[6] = y[2];
    te[10] = z[2];
    return te;
  }

  var RADIAN$1 = Math.PI / 180;
  var DEFAULT_FOV = 0.6435011087932844;
  var TEMP_COORD$1 = new Coordinate(0, 0);
  var TEMP_POINT$1 = new Point(0, 0);
  var altitudesHasData = function altitudesHasData(altitudes) {
    if (isNumber(altitudes)) {
      return altitudes !== 0;
    } else if (Array.isArray(altitudes) && altitudes.length > 0) {
      for (var i = 0, len = altitudes.length; i < len; i++) {
        if (isNumber(altitudes[i]) && altitudes[i] !== 0) {
          return true;
        }
      }
    }
    return false;
  };
  Map$1.include({
    getFov: function getFov() {
      if (!this._fov) {
        this._fov = DEFAULT_FOV;
      }
      return this._fov / RADIAN$1;
    },
    setFov: function setFov(fov) {
      if (this.isZooming()) {
        return this;
      }
      fov = Math.max(0.01, Math.min(60, fov));
      if (this._fov === fov) return this;
      var from = this.getFov();
      this._fov = fov * RADIAN$1;
      this._calcMatrices();
      this._renderLayers();
      this._fireEvent('fovchange', {
        'from': from,
        'to': this.getFov()
      });
      return this;
    },
    getBearing: function getBearing() {
      if (!this._angle) {
        return 0;
      }
      return -this._angle / RADIAN$1;
    },
    setBearing: function setBearing(bearing) {
      if (this._mapAnimPlayer) {
        this._stopAnim(this._mapAnimPlayer);
      }
      return this._setBearing(bearing);
    },
    _setBearing: function _setBearing(bearing) {
      if (Browser$1.ie9) {
        throw new Error('map can\'t rotate in IE9.');
      }
      var b = -wrap(bearing, -180, 180) * RADIAN$1;
      if (this._angle === b) return this;
      var from = this.getBearing();
      this._fireEvent('rotatestart', {
        'from': from,
        'to': b
      });
      this._angle = b;
      this._calcMatrices();
      this._renderLayers();
      this._fireEvent('rotate', {
        'from': from,
        'to': b
      });
      this._fireEvent('rotateend', {
        'from': from,
        'to': b
      });
      return this;
    },
    getPitch: function getPitch() {
      if (!this._pitch) {
        return 0;
      }
      return this._pitch / Math.PI * 180;
    },
    setPitch: function setPitch(pitch) {
      if (this._mapAnimPlayer) {
        this._stopAnim(this._mapAnimPlayer);
      }
      return this._setPitch(pitch);
    },
    _setPitch: function _setPitch(pitch) {
      if (Browser$1.ie9) {
        throw new Error('map can\'t tilt in IE9.');
      }
      var p = clamp(pitch, 0, this.options['maxPitch']) * RADIAN$1;
      if (this._pitch === p) return this;
      var from = this.getPitch();
      this._fireEvent('pitchstart', {
        'from': from,
        'to': p
      });
      this._pitch = p;
      this._calcMatrices();
      this._renderLayers();
      this._fireEvent('pitch', {
        'from': from,
        'to': p
      });
      this._fireEvent('pitchend', {
        'from': from,
        'to': p
      });
      return this;
    },
    setCameraMovements: function setCameraMovements(frameOptions, extraOptions) {
      var _this = this;
      if (!Array.isArray(frameOptions) || !frameOptions.length) {
        return this;
      }
      this.setView({
        center: frameOptions[0].center,
        zoom: frameOptions[0].zoom,
        pitch: frameOptions[0].pitch,
        bearing: frameOptions[0].bearing
      });
      if (frameOptions.length === 1) return this;
      var index = 1;
      var _onFrame = function onFrame(frame) {
        if (frame.state.playState === 'finished') {
          index++;
          if (index === frameOptions.length - 1) _onFrame = null;
          var frameOption = frameOptions[index];
          frameOption.duration = frameOption.timestamp - frameOptions[index - 1].timestamp;
          if (extraOptions && extraOptions.autoRotate) {
            frameOption.bearing = calculateBearing(frameOptions[index - 1].center, frameOption.center);
          }
          _this._setCameraMovement(frameOption, _onFrame);
        }
      };
      if (frameOptions.length === 2) _onFrame = null;
      var currentBearing = this.getBearing();
      this._setCameraMovement(_extends({
        bearing: currentBearing
      }, frameOptions[index], {
        duration: frameOptions[index].timestamp - frameOptions[index - 1].timestamp
      }), _onFrame);
      var play = function play() {
        _this._animPlayer.play();
      };
      var pause = function pause() {
        _this._animPlayer.pause();
      };
      var cancel = function cancel() {
        _this._animPlayer.cancel();
      };
      var finish = function finish() {
        _this._animPlayer.finish();
      };
      var reverse = function reverse() {
        _this._animPlayer.reverse();
      };
      return {
        play: play,
        pause: pause,
        cancel: cancel,
        finish: finish,
        reverse: reverse
      };
    },
    _setCameraMovement: function _setCameraMovement(frameOption, frame) {
      this.animateTo({
        zoom: frameOption.zoom,
        center: frameOption.center,
        pitch: frameOption.pitch,
        bearing: frameOption.bearing
      }, {
        duration: frameOption.duration,
        easing: 'out'
      }, frame);
    },
    setCameraPosition: function setCameraPosition(params) {
      var position = params.position,
        pitch = params.pitch,
        bearing = params.bearing;
      var cameraAltitude = position[2] * this._meterToGLPoint;
      var centerAltitude = this.centerAltitude || 0;
      var centerPointZ = centerAltitude * this._meterToGLPoint;
      var cz = cameraAltitude - centerPointZ;
      var pitchRadian = pitch * RADIAN$1;
      var cameraToGroundDistance = cz / Math.cos(pitchRadian);
      var dist = Math.sin(pitchRadian) * cameraToGroundDistance;
      var cameraToCenterDistance = cameraToGroundDistance + centerPointZ;
      var zoom = this._getZoomFromCameraToCenterDistance(cameraToCenterDistance);
      var wrapBearing = wrap(bearing, -180, 180);
      var bearingRadian = wrapBearing * RADIAN$1;
      var glRes = this.getGLRes();
      var tempCoord = new Coordinate(position[0], position[1]);
      var tempPoint = this.coordToPointAtRes(tempCoord, glRes);
      var point = new Point(0, 0);
      point.x = tempPoint.x + dist * Math.sin(bearingRadian);
      point.y = tempPoint.y + dist * Math.cos(bearingRadian);
      var prjCenter = this._pointToPrjAtRes(point, this.getGLRes());
      this._setPrjCenter(prjCenter);
      this.setView({
        bearing: bearing,
        pitch: pitch,
        zoom: zoom
      });
      return this;
    },
    _getZoomFromCameraToCenterDistance: function _getZoomFromCameraToCenterDistance(distance$$1) {
      var ratio = this._getFovRatio();
      var scale$$1 = distance$$1 * ratio * 2 / (this.height || 1) * this.getGLRes();
      var resolutions = this._getResolutions();
      var z = 0;
      for (z; z < resolutions.length - 1; z++) {
        if (resolutions[z] === scale$$1) {
          return z;
        } else if (resolutions[z + 1] === scale$$1) {
          return z + 1;
        } else if (scale$$1 < resolutions[z] && scale$$1 > resolutions[z + 1]) {
          z = (scale$$1 - resolutions[z]) / (resolutions[z + 1] - resolutions[z]) + z;
          return z - 1;
        } else {
          continue;
        }
      }
      return z;
    },
    isTransforming: function isTransforming() {
      return !!(this._pitch || this._angle);
    },
    getFrustumAltitude: function getFrustumAltitude() {
      return this._frustumAltitude;
    },
    _calcFrustumAltitude: function _calcFrustumAltitude() {
      var pitch = 90 - this.getPitch();
      var fov = this.getFov() / 2;
      var cameraAlt = this.cameraPosition ? this.cameraPosition[2] : 0;
      if (fov <= pitch) {
        return cameraAlt;
      }
      fov = Math.PI * fov / 180;
      var d1 = new Point(this.cameraPosition).distanceTo(new Point(this.cameraLookAt)),
        d2 = cameraAlt * Math.tan(fov * 2);
      var d = Math.tan(fov) * (d1 + d2);
      return cameraAlt + d;
    },
    _pointToContainerPoint: function _pointToContainerPoint(point, zoom, altitude, out) {
      if (altitude === void 0) {
        altitude = 0;
      }
      var res = this._getResolution(zoom);
      return this._pointAtResToContainerPoint(point, res, altitude, out);
    },
    _pointAtResToContainerPoint: function _pointAtResToContainerPoint(point, res, altitude, out) {
      if (altitude === void 0) {
        altitude = 0;
      }
      if (!out) {
        out = new Point(0, 0);
      }
      point = this._pointAtResToPoint(point, res, out);
      var isTransforming = this.isTransforming();
      var centerPoint;
      if (!isTransforming && !altitude) {
        centerPoint = this._prjToPoint(this._getPrjCenter(), undefined, TEMP_COORD$1);
      }
      this._toContainerPoint(out, isTransforming, altitude, centerPoint);
      return out;
    },
    _pointsAtResToContainerPoints: function _pointsAtResToContainerPoints(points, targetRes, altitudes, resultPoints) {
      if (altitudes === void 0) {
        altitudes = [];
      }
      if (resultPoints === void 0) {
        resultPoints = [];
      }
      var pitch = this.getPitch(),
        bearing = this.getBearing();
      var scale$$1 = targetRes / this._getResolution();
      if (pitch === 0 && bearing === 0 && !altitudesHasData(altitudes)) {
        var _this$_get2DExtent = this._get2DExtent(),
          xmin = _this$_get2DExtent.xmin,
          ymin = _this$_get2DExtent.ymin,
          xmax = _this$_get2DExtent.xmax,
          ymax = _this$_get2DExtent.ymax;
        if (xmax > xmin && ymax > ymin) {
          var _this$getSize = this.getSize(),
            width = _this$getSize.width,
            height = _this$getSize.height;
          var dxPerPixel = (xmax - xmin) / width,
            dyPerPixel = (ymax - ymin) / height;
          for (var i = 0, len = points.length; i < len; i++) {
            if (!points[i]) {
              resultPoints[i] = null;
              continue;
            }
            var pt = resultPoints[i];
            pt.x = points[i].x;
            pt.y = points[i].y;
            pt._multi(scale$$1);
            pt.x = (pt.x - xmin) * dxPerPixel;
            pt.y = height - (pt.y - ymin) * dyPerPixel;
          }
          return resultPoints;
        }
      }
      var altitudeIsArray = Array.isArray(altitudes);
      var isTransforming = this.isTransforming();
      var centerPoint = this._prjToPoint(this._getPrjCenter(), undefined, TEMP_COORD$1);
      for (var _i = 0, _len = points.length; _i < _len; _i++) {
        if (!points[_i]) {
          resultPoints[_i] = null;
          continue;
        }
        var _pt = resultPoints[_i];
        _pt.x = points[_i].x;
        _pt.y = points[_i].y;
        _pt._multi(scale$$1);
        var altitude = altitudeIsArray ? altitudes[_i] || 0 : altitudes;
        this._toContainerPoint(_pt, isTransforming, altitude, centerPoint);
      }
      return resultPoints;
    },
    _toContainerPoint: function () {
      var a = [0, 0, 0];
      return function (out, isTransforming, altitude, centerPoint) {
        var w2 = this.width / 2,
          h2 = this.height / 2;
        if (isTransforming || altitude) {
          if (!this._altitudeScale) {
            this._altitudeScale = this.altitudeToPoint(100, this.getGLRes()) / 100;
          }
          var _scale = this._glScale;
          set$2(a, out.x * _scale, out.y * _scale, altitude * this._altitudeScale);
          var t = this._projIfBehindCamera(a, this.cameraPosition, this.cameraForward);
          applyMatrix(t, t, this.projViewMatrix);
          out.x = t[0] * w2 + w2;
          out.y = -(t[1] * h2) + h2;
        } else {
          out._sub(centerPoint.x, centerPoint.y);
          out.set(out.x, -out.y);
          out._add(w2, h2);
        }
      };
    }(),
    _projIfBehindCamera: function () {
      var vectorFromCam = new Array(3);
      var proj = new Array(3);
      var sub = new Array(3);
      return function (position, cameraPos, camForward) {
        subtract(vectorFromCam, position, cameraPos);
        var camNormDot = dot(camForward, vectorFromCam);
        if (camNormDot <= 0) {
          scale$1(proj, camForward, camNormDot * 1.01);
          add(position, cameraPos, subtract(sub, vectorFromCam, proj));
        }
        return position;
      };
    }(),
    _containerPointToPoint: function _containerPointToPoint(p, zoom, out) {
      var res = this._getResolution(zoom);
      return this._containerPointToPointAtRes(p, res, out);
    },
    _containerPointToPointAtRes: function () {
      var cp = [0, 0, 0],
        coord0 = [0, 0, 0, 1],
        coord1 = [0, 0, 0, 1];
      return function (p, res, out) {
        if (this.isTransforming()) {
          var w2 = this.width / 2 || 1,
            h2 = this.height / 2 || 1;
          set$2(cp, (p.x - w2) / w2, (h2 - p.y) / h2, 0);
          set$2(coord0, cp[0], cp[1], 0);
          set$2(coord1, cp[0], cp[1], 1);
          coord0[3] = coord1[3] = 1;
          applyMatrix(coord0, coord0, this.projViewMatrixInverse);
          applyMatrix(coord1, coord1, this.projViewMatrixInverse);
          var x0 = coord0[0];
          var x1 = coord1[0];
          var y0 = coord0[1];
          var y1 = coord1[1];
          var z0 = coord0[2];
          var z1 = coord1[2];
          var t = z0 === z1 ? 0 : (0 - z0) / (z1 - z0);
          var _x = interpolate(x0, x1, t);
          var _y = interpolate(y0, y1, t);
          if (out) {
            out.x = _x;
            out.y = _y;
          } else {
            out = new Point(_x, _y);
          }
          out._multi(1 / this._glScale);
          return this._getResolution() === res ? out : this._pointToPointAtRes(out, res, out);
        }
        var centerPoint = this._prjToPointAtRes(this._getPrjCenter(), res, out),
          scale$$1 = this._getResolution() / res;
        var x = scale$$1 * (p.x - this.width / 2),
          y = scale$$1 * (p.y - this.height / 2);
        return centerPoint._add(x, -y);
      };
    }(),
    _calcMatrices: function () {
      var m1 = createMat4();
      return function () {
        delete this._mapRes;
        delete this._mapGlRes;
        delete this._mapExtent2D;
        delete this._mapGlExtent2D;
        var size = this.getSize();
        var w = size.width || 1,
          h = size.height || 1;
        this._glScale = this.getGLScale();
        var worldMatrix = this._getCameraWorldMatrix();
        var fov = this.getFov() * Math.PI / 180;
        var farZ = this._getCameraFar(fov, this.getPitch());
        this.cameraFar = farZ;
        this.cameraNear = this.cameraCenterDistance / 20;
        var projMatrix = this.projMatrix || createMat4();
        perspective(projMatrix, fov, w / h, this.cameraNear, farZ);
        this.projMatrix = projMatrix;
        this.viewMatrix = invert(this.viewMatrix || createMat4(), worldMatrix);
        this.projViewMatrix = multiply(this.projViewMatrix || createMat4(), projMatrix, this.viewMatrix);
        this._calcCascadeMatrixes();
        this.projViewMatrixInverse = multiply(this.projViewMatrixInverse || createMat4(), worldMatrix, invert(m1, projMatrix));
        this.domCssMatrix = this._calcDomMatrix();
        this._frustumAltitude = this._calcFrustumAltitude();
        this._mapRes = this._getResolution();
        this._mapGlRes = this.getGLRes();
        this._mapExtent2D = this._get2DExtent();
        this._mapGlExtent2D = this._get2DExtentAtRes(this._mapGlRes);
      };
    }(),
    _getCameraFar: function _getCameraFar(fov, pitch) {
      var cameraCenterDistance = this.cameraCenterDistance = distance(this.cameraPosition, this.cameraLookAt);
      var farZ = cameraCenterDistance;
      var y = (this.options['cameraInfiniteFar'] ? 10 : 4) * cameraCenterDistance;
      if (pitch > 0) {
        pitch = pitch * Math.PI / 180;
        if (2 / Math.PI - pitch > fov / 2) {
          var tanFov = Math.tan(fov / 2);
          var tanP = Math.tan(pitch);
          y = Math.max(cameraCenterDistance * tanFov / (1 / tanP - tanFov), y);
        }
      }
      farZ += y;
      return farZ + 1.0;
    },
    _calcCascadeMatrixes: function () {
      var projMatrix = createMat4();
      function cal(curPitch, pitch, out) {
        var w = this.width;
        var h = this.height;
        var fov = this.getFov() * Math.PI / 180;
        var farZ = this._getCameraFar(fov, pitch);
        var cameraCenterDistance = this.cameraCenterDistance;
        farZ = cameraCenterDistance + (farZ - cameraCenterDistance) / Math.cos((90 - pitch) * Math.PI / 180) * Math.cos((90 - curPitch) * Math.PI / 180);
        perspective(projMatrix, fov, w / h, 0.1, farZ);
        var viewMatrix = this.viewMatrix;
        return multiply(out, projMatrix, viewMatrix);
      }
      return function () {
        var pitch = this.getPitch();
        var cascadePitch0 = this.options['cascadePitches'][0];
        var cascadePitch1 = this.options['cascadePitches'][1];
        var projViewMatrix0 = this.cascadeFrustumMatrix0 = this.cascadeFrustumMatrix0 || createMat4();
        var projViewMatrix1 = this.cascadeFrustumMatrix1 = this.cascadeFrustumMatrix1 || createMat4();
        if (pitch > cascadePitch0) {
          cal.call(this, pitch, cascadePitch0, projViewMatrix0);
        } else {
          copy(this.cascadeFrustumMatrix0, this.projViewMatrix);
        }
        if (pitch > cascadePitch1) {
          cal.call(this, pitch, cascadePitch1, projViewMatrix1);
        } else {
          copy(this.cascadeFrustumMatrix1, this.cascadeFrustumMatrix0);
        }
      };
    }(),
    _calcDomMatrix: function () {
      var m = createMat4(),
        m1 = createMat4(),
        minusY = [1, -1, 1],
        arr = [0, 0, 0];
      return function () {
        var width = this.width || 1;
        var height = this.height || 1;
        var cameraToCenterDistance = 0.5 / Math.tan(this._fov / 2) * height;
        scale(m, this.projMatrix, minusY);
        translate(m, m, set$2(arr, 0, 0, -cameraToCenterDistance));
        if (this._pitch) {
          rotateX(m, m, this._pitch);
        }
        if (this._angle) {
          rotateZ(m, m, this._angle);
        }
        identity(m1);
        scale(m1, m1, set$2(arr, width / 2, -height / 2, 1));
        return multiply(this.domCssMatrix || createMat4(), m1, m);
      };
    }(),
    _getFovZ: function _getFovZ(zoom) {
      var scale$$1 = this.getGLScale(zoom);
      var ratio = this._getFovRatio();
      return scale$$1 * (this.height || 1) / 2 / ratio;
    },
    _getCameraWorldMatrix: function () {
      var q = {};
      return function () {
        var glRes = this.getGLRes();
        if (!this._meterToGLPoint) {
          this._meterToGLPoint = this.distanceToPointAtRes(100, 0, glRes).x / 100;
        }
        var center2D = this._prjToPointAtRes(this._prjCenter, glRes, TEMP_POINT$1);
        var centerAltitude = this.centerAltitude || 0;
        var centerPointZ = centerAltitude * this._meterToGLPoint;
        this.cameraLookAt = set$2(this.cameraLookAt || [0, 0, 0], center2D.x, center2D.y, centerPointZ);
        var pitch = this.getPitch() * RADIAN$1;
        var bearing = this.getBearing() * RADIAN$1;
        var cameraToCenterDistance = this._getFovZ();
        var cameraZenithDistance = this.cameraZenithDistance === undefined ? cameraToCenterDistance : this.cameraZenithDistance;
        var cameraToGroundDistance = cameraZenithDistance - centerPointZ;
        var cz = cameraToGroundDistance * Math.cos(pitch);
        var dist = Math.sin(pitch) * cameraToGroundDistance;
        var cx = center2D.x - dist * Math.sin(bearing);
        var cy = center2D.y - dist * Math.cos(bearing);
        this.cameraPosition = set$2(this.cameraPosition || [0, 0, 0], cx, cy, cz + centerPointZ);
        this.cameraToCenterDistance = cameraToCenterDistance;
        var d = dist || 1;
        var up = this.cameraUp = set$2(this.cameraUp || [0, 0, 0], Math.sin(bearing) * d, Math.cos(bearing) * d, 0);
        var m = this.cameraWorldMatrix = this.cameraWorldMatrix || createMat4();
        lookAt(m, this.cameraPosition, this.cameraLookAt, up);
        var cameraForward = this.cameraForward || [0, 0, 0];
        subtract(cameraForward, this.cameraLookAt, this.cameraPosition);
        this.cameraForward = normalize(cameraForward, cameraForward);
        matrixToQuaternion(q, m);
        quaternionToMatrix(m, q);
        setPosition(m, this.cameraPosition);
        return m;
      };
    }(),
    updateCenterAltitude: function updateCenterAltitude() {
      this.getRenderer().setToRedraw();
      if (!this.centerAltitude && this._hasAltitudeLayer()) {
        this.centerAltitude = 0;
      }
      this._recenterOnTerrain();
    },
    _recenterOnTerrain: function _recenterOnTerrain() {
      if (this.centerAltitude === undefined) {
        return;
      }
      var queriedAltitude = this._queryTerrainByProjCoord(this._prjCenter);
      if (isNil(queriedAltitude) && this._hasAltitudeLayer()) {
        queriedAltitude = this.centerAltitude;
      }
      var centerAltitude = queriedAltitude || 0;
      var pitch = this.getPitch() * RADIAN$1;
      var bearing = this.getBearing() * RADIAN$1;
      var altDist = (centerAltitude - this.centerAltitude) * this._meterToGLPoint;
      var cameraToCenterDistance = this._getFovZ();
      var cameraZenithDistance = this.cameraZenithDistance === undefined ? cameraToCenterDistance : this.cameraZenithDistance;
      var cameraToGroundDistance = cameraZenithDistance - this.centerAltitude * this._meterToGLPoint;
      var newCameraToGroundDistance = cameraToGroundDistance - altDist / Math.cos(pitch);
      var cameraPosition = this.cameraPosition;
      var dist = Math.sin(pitch) * newCameraToGroundDistance;
      var center2D = TEMP_POINT$1;
      center2D.x = cameraPosition[0] + dist * Math.sin(bearing);
      center2D.y = cameraPosition[1] + dist * Math.cos(bearing);
      var centerPointZ = centerAltitude * this._meterToGLPoint;
      this.cameraZenithDistance = (cameraPosition[2] - centerPointZ) / Math.cos(pitch) + centerPointZ;
      this.centerAltitude = centerAltitude;
      var newCenter = this.pointAtResToCoordinate(center2D, this.getGLRes(), TEMP_COORD$1);
      this._eventSilence = true;
      this._suppressRecenter = true;
      this.setCenter(newCenter);
      delete this._suppressRecenter;
      delete this._eventSilence;
      if (isNil(queriedAltitude)) {
        delete this.centerAltitude;
      }
    },
    _queryTerrainByProjCoord: function _queryTerrainByProjCoord(coord) {
      var layers = this._getLayers();
      for (var i = 0; i < layers.length; i++) {
        if (layers[i].queryTerrainByProjCoord) {
          return layers[i].queryTerrainByProjCoord(coord)[0];
        }
      }
      return 0;
    },
    _hasAltitudeLayer: function _hasAltitudeLayer() {
      var layers = this._getLayers();
      for (var i = 0; i < layers.length; i++) {
        if (layers[i].getTerrainLayer && layers[i].getTerrainLayer()) {
          return true;
        }
      }
      return false;
    },
    _getFovRatio: function _getFovRatio() {
      var fov = this.getFov();
      return Math.tan(fov / 2 * RADIAN$1);
    },
    _renderLayers: function _renderLayers() {
      if (this.isInteracting()) {
        return;
      }
      var layers = this._getLayers();
      layers.forEach(function (layer) {
        if (!layer) {
          return;
        }
        var renderer = layer._getRenderer();
        if (renderer && renderer.setToRedraw) {
          renderer.setToRedraw();
        }
      });
    }
  });
  function createMat4() {
    return identity(new Array(16));
  }
  function calculateBearing(start, end) {
    var lon1 = toRadian(start[0]);
    var lon2 = toRadian(end[0]);
    var lat1 = toRadian(start[1]);
    var lat2 = toRadian(end[1]);
    var a = Math.sin(lon2 - lon1) * Math.cos(lat2);
    var b = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
    return toDegree(Math.atan2(a, b));
  }

  Map$1.include({
    _onViewChange: function _onViewChange(view) {
      if (!this._viewHistory) {
        this._viewHistory = [];
        this._viewHistoryPointer = 0;
      }
      var old = this._getCurrentView();
      for (var i = this._viewHistory.length - 1; i >= 0; i--) {
        if (equalMapView(view, this._viewHistory[i])) {
          this._viewHistoryPointer = i;
          this._fireViewChange(old, view);
          return;
        }
      }
      if (this._viewHistoryPointer < this._viewHistory.length - 1) {
        this._viewHistory.splice(this._viewHistoryPointer + 1);
      }
      this._viewHistory.push(view);
      var count = this.options['viewHistoryCount'];
      if (count > 0 && this._viewHistory.length > count) {
        this._viewHistory.splice(0, this._viewHistory.length - count);
      }
      this._viewHistoryPointer = this._viewHistory.length - 1;
      this._fireViewChange(old, view);
    },
    zoomToPreviousView: function zoomToPreviousView(options) {
      if (options === void 0) {
        options = {};
      }
      if (!this.hasPreviousView()) {
        return null;
      }
      var view = this._viewHistory[--this._viewHistoryPointer];
      this._zoomToView(view, options);
      return view;
    },
    hasPreviousView: function hasPreviousView() {
      if (!this._viewHistory || this._viewHistoryPointer === 0) {
        return false;
      }
      return true;
    },
    zoomToNextView: function zoomToNextView(options) {
      if (options === void 0) {
        options = {};
      }
      if (!this.hasNextView()) {
        return null;
      }
      var view = this._viewHistory[++this._viewHistoryPointer];
      this._zoomToView(view, options);
      return view;
    },
    hasNextView: function hasNextView() {
      if (!this._viewHistory || this._viewHistoryPointer === this._viewHistory.length - 1) {
        return false;
      }
      return true;
    },
    _zoomToView: function _zoomToView(view, options) {
      var _this = this;
      var old = this.getView();
      if (options['animation']) {
        this._animateTo(view, {
          'duration': options['duration']
        }, function (frame) {
          if (frame.state.playState === 'finished') {
            _this._fireViewChange(old, view);
          }
        });
      } else {
        this.setView(view);
        this._fireViewChange(old, view);
      }
    },
    getViewHistory: function getViewHistory() {
      return this._viewHistory;
    },
    _fireViewChange: function _fireViewChange(old, view) {
      this._fireEvent('viewchange', {
        'old': old,
        'new': view
      });
      this._insertUICollidesQueue();
    },
    _getCurrentView: function _getCurrentView() {
      if (!this._viewHistory) {
        return null;
      }
      return this._viewHistory[this._viewHistoryPointer];
    }
  });
  Map$1.mergeOptions({
    'viewHistory': true,
    'viewHistoryCount': 10
  });

  var UICollisionIndex = new CollisionIndex();
  Map$1.include({
    getCollisionIndex: function getCollisionIndex() {
      if (!this._collisionIndex) {
        this.createCollisionIndex();
      }
      return this._collisionIndex || this.createCollisionIndex();
    },
    createCollisionIndex: function createCollisionIndex() {
      this.clearCollisionIndex();
      this._collisionIndex = new CollisionIndex();
      return this._collisionIndex;
    },
    clearCollisionIndex: function clearCollisionIndex() {
      this.collisionFrameTime = 0;
      if (this._collisionIndex) {
        this._collisionIndex.clear();
      }
      return this;
    },
    _insertUICollidesQueue: function _insertUICollidesQueue() {
      if (!this._uiCollidesQueue) {
        this._uiCollidesQueue = [];
      }
      this._uiCollidesQueue.push(1);
      return this;
    },
    uiCollides: function uiCollides() {
      if (!this.uiList || this.uiList.length === 0 || !this._uiCollidesQueue || this._uiCollidesQueue.length === 0) {
        return this;
      }
      var collisionIndex = UICollisionIndex;
      collisionIndex.clear();
      var uiList = this.uiList;
      for (var i = 0, len = uiList.length; i < len; i++) {
        var ui = uiList[i];
        var _ui$options = ui.options,
          collisionBufferSize = _ui$options.collisionBufferSize,
          collision = _ui$options.collision;
        if (!collision) {
          continue;
        }
        var dom = ui.getDOM();
        if (!ui.isVisible() || !dom) {
          continue;
        }
        if (!dom.getBoundingClientRect) {
          continue;
        }
        if (!ui.bbox) {
          ui.bbox = [0, 0, 0, 0];
        }
        var bcRect = dom.getBoundingClientRect();
        var x = bcRect.x,
          y = bcRect.y;
        var width = bcRect.width,
          height = bcRect.height;
        if (width === 0 || height === 0) {
          var size = ui.getSize();
          if (size) {
            width = size.width;
            height = size.height;
          }
        }
        var minX = x - collisionBufferSize,
          maxX = x + width + collisionBufferSize;
        var minY = y - collisionBufferSize,
          maxY = y + height + collisionBufferSize;
        ui.bbox[0] = minX;
        ui.bbox[1] = minY;
        ui.bbox[2] = maxX;
        ui.bbox[3] = maxY;
        if (collisionIndex.collides(ui.bbox)) {
          ui._collidesEffect(false);
          continue;
        }
        collisionIndex.insertBox(ui.bbox);
        ui._collidesEffect(true);
      }
      this._uiCollidesQueue = [];
      return this;
    },
    _addUI: function _addUI(ui) {
      if (!this.uiList) {
        this.uiList = [];
      }
      var index = this.uiList.indexOf(ui);
      if (index > -1) {
        return this;
      }
      this.uiList.push(ui);
      this.uiList = this.uiList.sort(function (a, b) {
        return b.options['collisionWeight'] - a.options['collisionWeight'];
      });
      return this;
    },
    _removeUI: function _removeUI(ui) {
      if (!this.uiList) {
        return -1;
      }
      var index = this.uiList.indexOf(ui);
      if (index < 0) {
        return index;
      }
      this.uiList.splice(index, 1);
      return index;
    }
  });

  var distancetool = {
  	start: "Start",
  	units: {
  		mile: " mi",
  		feet: " ft",
  		kilometer: " km",
  		meter: " m"
  	}
  };
  var areatool = {
  	units: {
  		mile: " miÂ²",
  		feet: " ftÂ²",
  		kilometer: " kmÂ²",
  		meter: " mÂ²"
  	}
  };
  var zhCn = {
  	distancetool: distancetool,
  	areatool: areatool
  };

  var distancetool$1 = {
  	start: "Inicio",
  	units: {
  		mile: " mi",
  		feet: " ft",
  		kilometer: " km",
  		meter: " m"
  	}
  };
  var areatool$1 = {
  	units: {
  		mile: " miÂ²",
  		feet: " ftÂ²",
  		kilometer: " kmÂ²",
  		meter: " mÂ²"
  	}
  };
  var esMX = {
  	distancetool: distancetool$1,
  	areatool: areatool$1
  };

  var distancetool$2 = {
  	start: "Start",
  	units: {
  		mile: " mi",
  		feet: " ft",
  		kilometer: " km",
  		meter: " m"
  	}
  };
  var areatool$2 = {
  	units: {
  		mile: " miÂ²",
  		feet: " ftÂ²",
  		kilometer: " kmÂ²",
  		meter: " mÂ²"
  	}
  };
  var enUS = {
  	distancetool: distancetool$2,
  	areatool: areatool$2
  };

  var TranslatorError = function (_Error) {
    _inheritsLoose(TranslatorError, _Error);
    function TranslatorError(msg) {
      var _this;
      _this = _Error.call(this, 'Translator: ' + msg) || this;
      _this.name = 'TranslatorError';
      return _this;
    }
    return TranslatorError;
  }(_wrapNativeSuper(Error));
  var Translator = function (_Class) {
    _inheritsLoose(Translator, _Class);
    function Translator(lang) {
      var _this2;
      _this2 = _Class.call(this) || this;
      _this2.languages = {
        'zh-CN': zhCn,
        'es-MX': esMX,
        'en-US': enUS
      };
      _this2.nodes = {};
      _this2.setLang(lang || 'zh-CN');
      return _this2;
    }
    var _proto = Translator.prototype;
    _proto.setLang = function setLang(lang) {
      var newLanguageNodes = this.languages[lang];
      if (!newLanguageNodes) throw new TranslatorError('Setted Lang does not exist');
      this.nodes = newLanguageNodes;
    };
    _proto._validateNestedProps = function _validateNestedProps(nestedProps) {
      nestedProps.forEach(function (p) {
        if (p === '') throw new TranslatorError('Any of sides of a dot "." cannot be empty');
      });
    };
    _proto.translate = function translate(textNode) {
      if (textNode === void 0) {
        textNode = null;
      }
      if (textNode == null) throw new TranslatorError('Missing parameter textNode');
      if (typeof textNode === 'string') {
        var translatedText = null;
        if (textNode.includes('.')) {
          var nestedProps = textNode.split('.');
          if (nestedProps.length > 3) throw new TranslatorError("Translate function can only access through 3 nested properties, trying to access -> " + nestedProps.length);
          this._validateNestedProps(nestedProps);
          try {
            var _translatedText = null;
            switch (nestedProps.length) {
              case 2:
                _translatedText = this.nodes[nestedProps[0]][nestedProps[1]];
                break;
              case 3:
                _translatedText = this.nodes[nestedProps[0]][nestedProps[1]][nestedProps[2]];
                break;
            }
            return _translatedText;
          } catch (err) {
            throw new TranslatorError('Unable to find the text translated in lang json' + err.message);
          }
        } else {
          translatedText = this.nodes[textNode];
          return translatedText;
        }
      } else {
        throw new TranslatorError('Param passed has to be a String');
      }
    };
    return Translator;
  }(Class);

  var options$h = {
    'formatLabelContent': null,
    'decimalPlaces': 2,
    'mode': 'LineString',
    'language': 'zh-CN',
    'metric': true,
    'imperial': false,
    'symbol': {
      'lineColor': '#000',
      'lineWidth': 3,
      'lineOpacity': 1
    },
    'vertexSymbol': {
      'markerType': 'ellipse',
      'markerFill': '#fff',
      'markerLineColor': '#000',
      'markerLineWidth': 3,
      'markerWidth': 11,
      'markerHeight': 11
    },
    'labelOptions': {
      'textSymbol': {
        'textFaceName': 'monospace',
        'textLineSpacing': 1,
        'textHorizontalAlignment': 'right',
        'textDx': 15
      },
      'boxStyle': {
        'padding': [6, 2],
        'symbol': {
          'markerType': 'square',
          'markerFill': '#fff',
          'markerFillOpacity': 0.9,
          'markerLineColor': '#b4b3b3'
        }
      }
    },
    'clearButtonSymbol': [{
      'markerType': 'square',
      'markerFill': '#fff',
      'markerLineColor': '#b4b3b3',
      'markerLineWidth': 2,
      'markerWidth': 15,
      'markerHeight': 15,
      'markerDx': 20
    }, {
      'markerType': 'x',
      'markerWidth': 10,
      'markerHeight': 10,
      'markerDx': 20
    }]
  };
  var DistanceTool = function (_DrawTool) {
    _inheritsLoose(DistanceTool, _DrawTool);
    function DistanceTool(options) {
      var _this;
      _this = _DrawTool.call(this, options) || this;
      _this.on('enable', _this._afterEnable, _assertThisInitialized(_assertThisInitialized(_this))).on('disable', _this._afterDisable, _assertThisInitialized(_assertThisInitialized(_this)));
      _this._measureLayers = [];
      _this.translator = new Translator(_this.options['language']);
      return _this;
    }
    var _proto = DistanceTool.prototype;
    _proto.clear = function clear() {
      if (isArrayHasData(this._measureLayers)) {
        for (var i = 0; i < this._measureLayers.length; i++) {
          this._measureLayers[i].remove();
        }
      }
      delete this._lastMeasure;
      delete this._lastVertex;
      this._outLayers(this._measureLayers);
      this._measureLayers = [];
      return this;
    };
    _proto.getMeasureLayers = function getMeasureLayers() {
      return this._measureLayers;
    };
    _proto.getLastMeasure = function getLastMeasure() {
      if (!this._lastMeasure) {
        return 0;
      }
      return this._lastMeasure;
    };
    _proto.undo = function undo() {
      _DrawTool.prototype.undo.call(this);
      var pointer = this._historyPointer;
      if (pointer !== this._vertexes.length) {
        for (var i = pointer; i < this._vertexes.length; i++) {
          if (this._vertexes[i].label) {
            this._vertexes[i].label.remove();
          }
          this._vertexes[i].marker.remove();
        }
      }
      return this;
    };
    _proto.redo = function redo() {
      _DrawTool.prototype.redo.call(this);
      var i = this._historyPointer - 1;
      if (this._vertexes[i]) {
        if (!this._vertexes[i].marker.getLayer()) {
          if (this._vertexes[i].label) {
            this._vertexes[i].label.addTo(this._measureMarkerLayer);
          }
          this._vertexes[i].marker.addTo(this._measureMarkerLayer);
        }
      }
      return this;
    };
    _proto._formatLabelContent = function _formatLabelContent(params) {
      var formatLabelContent = this.options.formatLabelContent;
      if (formatLabelContent && isFunction(formatLabelContent)) {
        return formatLabelContent.call(this, params) + '';
      }
      return null;
    };
    _proto._measure = function _measure(toMeasure) {
      var map = this.getMap();
      var length;
      if (toMeasure instanceof Geometry) {
        length = map.computeGeometryLength(toMeasure);
      } else if (Array.isArray(toMeasure)) {
        length = map.getProjection().measureLength(toMeasure);
      }
      this._lastMeasure = length;
      var result = this._formatLabelContent(length);
      if (result) {
        return result;
      }
      var units = [this.translator.translate('distancetool.units.meter'), this.translator.translate('distancetool.units.kilometer'), this.translator.translate('distancetool.units.feet'), this.translator.translate('distancetool.units.mile')];
      var content = '';
      var decimals = this.options['decimalPlaces'];
      if (this.options['metric']) {
        content += length < 1000 ? length.toFixed(decimals) + units[0] : (length / 1000).toFixed(decimals) + units[1];
      }
      if (this.options['imperial']) {
        length *= 3.2808399;
        if (content.length > 0) {
          content += '\n';
        }
        content += length < 5280 ? length.toFixed(decimals) + units[2] : (length / 5280).toFixed(decimals) + units[3];
      }
      return content;
    };
    _proto._registerMeasureEvents = function _registerMeasureEvents() {
      this.on('drawstart', this._msOnDrawStart, this).on('drawvertex', this._msOnDrawVertex, this).on('mousemove', this._msOnMouseMove, this).on('drawend', this._msOnDrawEnd, this);
    };
    _proto._afterEnable = function _afterEnable() {
      this._registerMeasureEvents();
    };
    _proto._afterDisable = function _afterDisable() {
      this.off('drawstart', this._msOnDrawStart, this).off('drawvertex', this._msOnDrawVertex, this).off('mousemove', this._msOnMouseMove, this).off('drawend', this._msOnDrawEnd, this);
    };
    _proto._msOnDrawStart = function _msOnDrawStart(param) {
      var map = this.getMap();
      var prjCoord = map._pointToPrj(param['point2d']);
      var uid = UID();
      var layerId = 'distancetool_' + uid;
      var markerLayerId = 'distancetool_markers_' + uid;
      var zIndex = this.options.zIndex;
      if (!map.getLayer(layerId)) {
        this._measureLineLayer = new VectorLayer(layerId, {
          zIndex: zIndex
        }).addTo(map);
        this._measureMarkerLayer = new VectorLayer(markerLayerId, {
          zIndex: zIndex
        }).addTo(map);
      } else {
        this._measureLineLayer = map.getLayer(layerId);
        this._measureMarkerLayer = map.getLayer(markerLayerId);
      }
      this._measureLayers.push(this._measureLineLayer);
      this._measureLayers.push(this._measureMarkerLayer);
      this._pushLayers([this._measureLineLayer, this._measureMarkerLayer]);
      var marker = new Marker(param['coordinate'], {
        'symbol': this.options['vertexSymbol']
      });
      marker._setPrjCoordinates(prjCoord);
      var content = this.translator.translate('distancetool.start');
      var startLabel = new Label(content, param['coordinate'], this.options['labelOptions']);
      startLabel._setPrjCoordinates(prjCoord);
      this._lastVertex = startLabel;
      this._addVertexMarker(marker, startLabel);
    };
    _proto._msOnMouseMove = function _msOnMouseMove(param) {
      var ms = this._measure(this._msGetCoordsToMeasure(param));
      if (!this._tailMarker) {
        var symbol = extendSymbol(this.options['vertexSymbol']);
        symbol['markerWidth'] /= 2;
        symbol['markerHeight'] /= 2;
        this._tailMarker = new Marker(param['coordinate'], {
          'symbol': symbol
        }).addTo(this._measureMarkerLayer);
        this._tailLabel = new Label(ms, param['coordinate'], this.options['labelOptions']).addTo(this._measureMarkerLayer);
      }
      var prjCoords = this._geometry._getPrjCoordinates();
      var lastCoord = prjCoords[prjCoords.length - 1];
      this._tailMarker.setCoordinates(param['coordinate']);
      this._tailMarker._setPrjCoordinates(lastCoord);
      this._tailLabel.setContent(ms);
      this._tailLabel.setCoordinates(param['coordinate']);
      this._tailLabel._setPrjCoordinates(lastCoord);
    };
    _proto._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
      return param['geometry'].getCoordinates().concat([param['coordinate']]);
    };
    _proto._msOnDrawVertex = function _msOnDrawVertex(param) {
      var prjCoords = this._geometry._getPrjCoordinates();
      var lastCoord = prjCoords[prjCoords.length - 1];
      var geometry = param['geometry'];
      var marker = new Marker(param['coordinate'], {
        'symbol': this.options['vertexSymbol']
      });
      var length = this._measure(geometry);
      var vertexLabel = new Label(length, param['coordinate'], this.options['labelOptions']);
      this._addVertexMarker(marker, vertexLabel);
      vertexLabel._setPrjCoordinates(lastCoord);
      marker._setPrjCoordinates(lastCoord);
      this._lastVertex = vertexLabel;
    };
    _proto._addVertexMarker = function _addVertexMarker(marker, vertexLabel) {
      if (!this._vertexes) {
        this._vertexes = [];
      }
      if (this._historyPointer !== undefined && this._vertexes.length > this._historyPointer - 1) {
        this._vertexes.length = this._historyPointer - 1;
      }
      this._vertexes.push({
        label: vertexLabel,
        marker: marker
      });
      this._measureMarkerLayer.addGeometry(marker);
      if (vertexLabel) {
        this._measureMarkerLayer.addGeometry(vertexLabel);
      }
    };
    _proto._msOnDrawEnd = function _msOnDrawEnd(param) {
      this._clearTailMarker();
      if (param['geometry']._getPrjCoordinates().length < 2) {
        this._lastMeasure = 0;
        this._clearMeasureLayers();
        return;
      }
      var size = this._lastVertex.getSize();
      if (!size) {
        size = new Size(10, 10);
      }
      this._addClearMarker(this._lastVertex.getCoordinates(), this._lastVertex._getPrjCoordinates(), size['width']);
      var geo = param['geometry'].copy();
      geo._setPrjCoordinates(param['geometry']._getPrjCoordinates());
      geo.addTo(this._measureLineLayer);
      this._lastMeasure = geo.getLength();
    };
    _proto._addClearMarker = function _addClearMarker(coordinates, prjCoord, dx) {
      var symbol = this.options['clearButtonSymbol'];
      var dxSymbol = {
        'markerDx': (symbol['markerDx'] || 0) + dx,
        'textDx': (symbol['textDx'] || 0) + dx
      };
      if (Array.isArray(symbol)) {
        dxSymbol = symbol.map(function (s) {
          if (s) {
            return {
              'markerDx': (s['markerDx'] || 0) + dx,
              'textDx': (s['textDx'] || 0) + dx
            };
          }
          return null;
        });
      }
      symbol = extendSymbol(symbol, dxSymbol);
      var endMarker = new Marker(coordinates, {
        'symbol': symbol
      });
      var measureLineLayer = this._measureLineLayer,
        measureMarkerLayer = this._measureMarkerLayer;
      endMarker.on('click', function () {
        measureLineLayer.remove();
        measureMarkerLayer.remove();
        return false;
      }, this);
      endMarker.addTo(this._measureMarkerLayer);
      endMarker._setPrjCoordinates(prjCoord);
    };
    _proto._clearTailMarker = function _clearTailMarker() {
      if (this._tailMarker) {
        this._tailMarker.remove();
        delete this._tailMarker;
      }
      if (this._tailLabel) {
        this._tailLabel.remove();
        delete this._tailLabel;
      }
    };
    _proto._clearMeasureLayers = function _clearMeasureLayers() {
      this._measureLineLayer.remove();
      this._measureMarkerLayer.remove();
    };
    return DistanceTool;
  }(DrawTool);
  DistanceTool.mergeOptions(options$h);

  var options$i = {
    'mode': 'Polygon',
    'symbol': {
      'lineColor': '#000000',
      'lineWidth': 2,
      'lineOpacity': 1,
      'lineDasharray': '',
      'polygonFill': '#ffffff',
      'polygonOpacity': 0.5
    },
    'language': 'zh-CN'
  };
  var AreaTool = function (_DistanceTool) {
    _inheritsLoose(AreaTool, _DistanceTool);
    function AreaTool(options) {
      var _this;
      _this = _DistanceTool.call(this, options) || this;
      _this.translator = new Translator(_this.options['language']);
      _this._measureLayers = [];
      return _this;
    }
    var _proto = AreaTool.prototype;
    _proto._measure = function _measure(toMeasure) {
      var map = this.getMap();
      var area;
      if (toMeasure instanceof Geometry) {
        area = map.computeGeometryArea(toMeasure);
      } else if (Array.isArray(toMeasure)) {
        area = map.getProjection().measureArea(toMeasure);
      }
      this._lastMeasure = area;
      var result = this._formatLabelContent(area);
      if (result) {
        return result;
      }
      var units = [this.translator.translate('areatool.units.meter'), this.translator.translate('areatool.units.kilometer'), this.translator.translate('areatool.units.feet'), this.translator.translate('areatool.units.mile')];
      var content = '';
      var decimals = this.options['decimalPlaces'];
      if (this.options['metric']) {
        content += area < 1E6 ? area.toFixed(decimals) + units[0] : (area / 1E6).toFixed(decimals) + units[1];
      }
      if (this.options['imperial']) {
        area *= Math.pow(3.2808399, 2);
        if (content.length > 0) {
          content += '\n';
        }
        var sqmi = 5280 * 5280;
        content += area < sqmi ? area.toFixed(decimals) + units[2] : (area / sqmi).toFixed(decimals) + units[3];
      }
      return content;
    };
    _proto._msGetCoordsToMeasure = function _msGetCoordsToMeasure(param) {
      return param['geometry'].getShell().concat([param['coordinate']]);
    };
    _proto._msOnDrawVertex = function _msOnDrawVertex(param) {
      var prjCoord = this.getMap()._pointToPrj(param['point2d']);
      var vertexMarker = new Marker(param['coordinate'], {
        'symbol': this.options['vertexSymbol']
      });
      vertexMarker._setPrjCoordinates(prjCoord);
      this._measure(param['geometry']);
      this._lastVertex = vertexMarker;
      this._addVertexMarker(vertexMarker);
    };
    _proto._msOnDrawEnd = function _msOnDrawEnd(param) {
      this._clearTailMarker();
      var prjCoord;
      if (param['point2d']) {
        prjCoord = this.getMap()._pointToPrj(param['point2d']);
      } else {
        var prjCoords = param['geometry']._getPrjCoordinates();
        prjCoords = prjCoords.slice(0, prjCoords.length - 1);
        param['geometry']._setPrjCoordinates(prjCoords);
        prjCoord = prjCoords[prjCoords.length - 1];
      }
      if (param['geometry']._getPrjCoordinates().length < 3) {
        this._lastMeasure = 0;
        this._clearMeasureLayers();
        return;
      }
      var ms = this._measure(param['geometry']);
      var projection = this.getMap().getProjection();
      var coord = projection.unproject(prjCoord);
      var endLabel = new Label(ms, coord, this.options['labelOptions']).addTo(this._measureMarkerLayer);
      endLabel._setPrjCoordinates(prjCoord);
      var size = endLabel.getSize();
      if (!size) {
        size = new Size(10, 10);
      }
      this._addClearMarker(coord, prjCoord, size['width']);
      var geo = param['geometry'].copy();
      geo._setPrjCoordinates(param['geometry']._getPrjCoordinates());
      geo.addTo(this._measureLineLayer);
      this._lastMeasure = geo.getArea();
    };
    return AreaTool;
  }(DistanceTool);
  AreaTool.mergeOptions(options$i);

  var circleHooks = {
    'create': function create(projection, prjCoord) {
      var center = projection.unproject(prjCoord[0]);
      var circle = new Circle(center, 0);
      circle._setPrjCoordinates(prjCoord[0]);
      return circle;
    },
    'update': function update(projection, prjPath, geometry) {
      var map = geometry.getMap();
      var prjCoord = Array.isArray(prjPath) ? prjPath[prjPath.length - 1] : prjPath;
      var nextCoord = projection.unproject(prjCoord);
      var radius = map.computeLength(geometry.getCenter(), nextCoord);
      geometry.setRadius(radius);
    },
    'generate': function generate(geometry) {
      return geometry;
    }
  };
  DrawTool.registerMode('circle', extend({
    'clickLimit': 2,
    'action': ['click', 'mousemove', 'click']
  }, circleHooks));
  DrawTool.registerMode('freeHandCircle', extend({
    'action': ['mousedown touchstart', 'mousemove touchmove', 'mouseup touchend']
  }, circleHooks));
  var ellipseHooks = {
    'create': function create(projection, prjCoord) {
      var center = projection.unproject(prjCoord[0]);
      var ellipse = new Ellipse(center, 0, 0);
      ellipse._setPrjCoordinates(prjCoord[0]);
      return ellipse;
    },
    'update': function update(projection, prjPath, geometry) {
      var map = geometry.getMap();
      var center = geometry.getCenter();
      var prjCoord = Array.isArray(prjPath) ? prjPath[prjPath.length - 1] : prjPath;
      var nextCoord = projection.unproject(prjCoord);
      var rx = map.computeLength(center, new Coordinate({
        x: nextCoord.x,
        y: center.y
      }));
      var ry = map.computeLength(center, new Coordinate({
        x: center.x,
        y: nextCoord.y
      }));
      geometry.setWidth(rx * 2);
      geometry.setHeight(ry * 2);
    },
    'generate': function generate(geometry) {
      return geometry;
    }
  };
  DrawTool.registerMode('ellipse', extend({
    'clickLimit': 2,
    'action': ['click', 'mousemove', 'click']
  }, ellipseHooks));
  DrawTool.registerMode('freeHandEllipse', extend({
    'action': ['mousedown touchstart', 'mousemove touchmove', 'mouseup touchend']
  }, ellipseHooks));
  var rectangleHooks = {
    'create': function create(projection, prjCoords) {
      var rect = new Polygon([]);
      rect._firstClick = prjCoords[0];
      return rect;
    },
    'update': function update(projection, prjCoords, geometry, param) {
      var map = geometry.getMap();
      var containerPoint = param['containerPoint'];
      var firstClick = map._prjToContainerPoint(geometry._firstClick);
      var ring = [[firstClick.x, firstClick.y], [containerPoint.x, firstClick.y], [containerPoint.x, containerPoint.y], [firstClick.x, containerPoint.y]];
      geometry.setCoordinates(ring.map(function (c) {
        return map.containerPointToCoord(new Point(c));
      }));
      geometry._setPrjCoordinates(ring.map(function (c) {
        return map._containerPointToPrj(new Point(c));
      }));
    },
    'generate': function generate(geometry) {
      return geometry;
    }
  };
  DrawTool.registerMode('rectangle', extend({
    'clickLimit': 2,
    'action': ['click', 'mousemove', 'click']
  }, rectangleHooks));
  DrawTool.registerMode('freeHandRectangle', extend({
    'action': ['mousedown touchstart', 'mousemove touchmove', 'mouseup touchend']
  }, rectangleHooks));
  DrawTool.registerMode('point', {
    'clickLimit': 1,
    'action': ['click', 'mousemove'],
    'create': function create(projection, prjCoord) {
      var center = projection.unproject(prjCoord[0]);
      var marker = new Marker(center);
      marker._setPrjCoordinates(prjCoord[0]);
      return marker;
    },
    'generate': function generate(geometry) {
      return geometry;
    },
    'update': function update(projection, prjCoord, geometry) {
      if (Array.isArray(prjCoord)) {
        prjCoord = prjCoord[prjCoord.length - 1];
      }
      if (!prjCoord) {
        return geometry;
      }
      var coordinate = projection.unproject(prjCoord);
      geometry.setCoordinates(coordinate);
      return geometry;
    }
  });
  var polygonHooks = {
    'create': function create(projection, prjPath) {
      var path = prjPath.map(function (c) {
        return projection.unproject(c);
      });
      var line = new LineString(path);
      line._setPrjCoordinates(prjPath);
      return line;
    },
    'update': function update(projection, path, geometry) {
      var symbol = geometry.getSymbol();
      var prjCoords;
      if (Array.isArray(path)) {
        prjCoords = path;
      } else {
        prjCoords = geometry._getPrjCoordinates();
        prjCoords.push(path);
      }
      var coordinates = prjCoords.map(function (c) {
        return projection.unproject(c);
      });
      geometry.setCoordinates(coordinates);
      geometry._setPrjCoordinates(prjCoords);
      var layer = geometry.getLayer();
      if (layer) {
        var polygon = layer.getGeometryById('polygon');
        if (!polygon && prjCoords.length >= 3) {
          polygon = new Polygon([coordinates], {
            'id': 'polygon'
          });
          if (symbol) {
            var pSymbol = extendSymbol(symbol, {
              'lineOpacity': 0
            });
            polygon.setSymbol(pSymbol);
          }
          polygon.addTo(layer);
        }
        if (polygon) {
          polygon._setPrjCoordinates(prjCoords);
        }
      }
    },
    'generate': function generate(geometry) {
      var polygon = new Polygon(geometry.getCoordinates(), {
        'symbol': geometry.getSymbol()
      });
      polygon._setPrjCoordinates(geometry._getPrjCoordinates());
      polygon._projCode = geometry._projCode;
      return polygon;
    }
  };
  DrawTool.registerMode('polygon', extend({
    'action': ['click', 'mousemove', 'dblclick']
  }, polygonHooks));
  DrawTool.registerMode('freeHandPolygon', extend({
    'action': ['mousedown touchstart', 'mousemove touchmove', 'mouseup touchend']
  }, polygonHooks));
  var lineStringHooks = {
    'create': function create(projection, prjPath) {
      var path = prjPath.map(function (c) {
        return projection.unproject(c);
      });
      var line = new LineString(path);
      line._setPrjCoordinates(prjPath);
      return line;
    },
    'update': function update(projection, prjPath, geometry) {
      var prjCoords;
      if (Array.isArray(prjPath)) {
        prjCoords = prjPath;
      } else {
        prjCoords = geometry._getPrjCoordinates();
        prjCoords.push(prjPath);
      }
      var path = prjCoords.map(function (c) {
        return projection.unproject(c);
      });
      geometry.setCoordinates(path);
      geometry._setPrjCoordinates(prjCoords);
    },
    'generate': function generate(geometry) {
      return geometry;
    }
  };
  DrawTool.registerMode('linestring', extend({
    'action': ['click', 'mousemove', 'dblclick']
  }, lineStringHooks));
  DrawTool.registerMode('freeHandLinestring', extend({
    'action': ['mousedown touchstart', 'mousemove touchmove', 'mouseup touchend']
  }, lineStringHooks));
  DrawTool.registerMode('arccurve', {
    'action': ['click', 'mousemove', 'dblclick'],
    'create': function create(projection, prjPath) {
      var path = prjPath.map(function (c) {
        return projection.unproject(c);
      });
      var arc = new ArcCurve(path);
      arc._setPrjCoordinates(prjPath);
      return arc;
    },
    'update': lineStringHooks.update,
    'generate': function generate(geometry) {
      return geometry;
    }
  });
  DrawTool.registerMode('quadbeziercurve', {
    'action': ['click', 'mousemove', 'dblclick'],
    'create': function create(projection, prjPath) {
      var path = prjPath.map(function (c) {
        return projection.unproject(c);
      });
      var curve = new QuadBezierCurve(path);
      curve._setPrjCoordinates(prjPath);
      return curve;
    },
    'update': lineStringHooks.update,
    'generate': function generate(geometry) {
      return geometry;
    }
  });
  DrawTool.registerMode('cubicbeziercurve', {
    'action': ['click', 'mousemove', 'dblclick'],
    'create': function create(projection, prjPath) {
      var path = prjPath.map(function (c) {
        return projection.unproject(c);
      });
      var curve = new CubicBezierCurve(path);
      curve._setPrjCoordinates(prjPath);
      return curve;
    },
    'update': lineStringHooks.update,
    'generate': function generate(geometry) {
      return geometry;
    }
  });
  DrawTool.registerMode('boxZoom', {
    'action': ['mousedown', 'mousemove', 'mouseup'],
    'create': function create(projection, prjCoord) {
      prjCoord = prjCoord[0];
      var center = projection.unproject(prjCoord);
      var marker = new Marker(center);
      marker._firstClick = prjCoord;
      return marker;
    },
    'update': function update(projection, prjCoord, geometry, param) {
      var map = geometry.getMap();
      var p1 = map._prjToContainerPoint(geometry._firstClick),
        p2 = param['containerPoint'];
      prjCoord = map._containerPointToPrj(new Coordinate(Math.min(p1.x, p2.x), Math.min(p1.y, p2.y)));
      var center = projection.unproject(prjCoord);
      geometry.setCoordinates(center)._setPrjCoordinates(prjCoord);
      geometry.updateSymbol({
        markerWidth: Math.abs(p1.x - p2.x),
        markerHeight: Math.abs(p1.y - p2.y)
      });
    },
    'generate': function generate(geometry) {
      return geometry;
    }
  });

  function parse(arcConf) {
    var tileInfo = arcConf['tileInfo'],
      tileSize = [tileInfo['cols'], tileInfo['rows']],
      resolutions = [],
      lods = tileInfo['lods'];
    for (var i = 0, len = lods.length; i < len; i++) {
      resolutions.push(lods[i]['resolution']);
    }
    var fullExtent = arcConf['fullExtent'],
      origin = tileInfo['origin'],
      tileSystem = [1, -1, origin['x'], origin['y']];
    delete fullExtent['spatialReference'];
    return {
      'spatialReference': {
        'resolutions': resolutions,
        'fullExtent': fullExtent
      },
      'tileSystem': tileSystem,
      'tileSize': tileSize
    };
  }
  SpatialReference.loadArcgis = function (url, cb, options) {
    if (options === void 0) {
      options = {
        'jsonp': true
      };
    }
    if (isString(url) && url.substring(0, 1) !== '{') {
      Ajax.getJSON(url, function (err, json) {
        if (err) {
          cb(err);
          return;
        }
        var spatialRef = parse(json);
        cb(null, spatialRef);
      }, options);
    } else {
      if (isString(url)) {
        url = parseJSON(url);
      }
      var spatialRef = parse(url);
      cb(null, spatialRef);
    }
    return this;
  };

  function getProjectionCode(code) {
    var newcode = '';
    var codeArray = code.split('');
    for (var len = codeArray.length, i = len - 1; i >= 0; i--) {
      if (!isNaN(codeArray[i])) {
        newcode = codeArray[i] + newcode;
      } else {
        break;
      }
    }
    return newcode;
  }
  function getProjection(projection) {
    var prj = projection.indexOf('EPSG') > -1 ? projection : 'EPSG:' + projection;
    prj = strReplace(prj, [['4490', '4326'], ['102100', '3857'], ['900913', '3857']]);
    return prj;
  }
  function strReplace(str, repArray) {
    if (repArray === void 0) {
      repArray = [];
    }
    repArray.forEach(function (rep) {
      var template = rep[0],
        value = rep[1];
      str = str.replace(template, value);
    });
    return str;
  }
  function getTransformValue(options) {
    var projection = options.projection,
      isArcgis = options.isArcgis,
      isGeoServer = options.isGeoServer,
      isSuperMap = options.isSuperMap;
    var transformValue = 0.0002645833333333333;
    if (isArcgis || isGeoServer || isSuperMap) {
      transformValue = 0.00028;
    }
    if (projection && projection.indexOf('4326') > -1) {
      transformValue = 2.3767925226029154e-9;
      if (isArcgis || isSuperMap) {
        transformValue = 2.518101729011901e-9;
      }
      if (isGeoServer) {
        transformValue = 2.51528279553466e-9;
      }
    }
    return transformValue;
  }
  var ns = 'wmts';
  function getElementsByTagName(element, localName) {
    var result = element.getElementsByTagName(localName);
    if (result && result.length) {
      return result;
    }
    var name = ns + ':' + localName;
    return element.getElementsByTagName(name);
  }
  function getTileMatrixSet(TileMatrixSets, TileMatrixSetLink) {
    for (var i = 0; i < TileMatrixSets.length; i++) {
      var TileMatrixSet = TileMatrixSets[i];
      TileMatrixSet = TileMatrixSet.getElementsByTagName('ows:Identifier')[0];
      if (TileMatrixSet) {
        if (TileMatrixSet.textContent === TileMatrixSetLink) {
          return TileMatrixSets[i];
        }
      }
    }
    return null;
  }
  function parseWMTSXML(str, requestUrl, options) {
    if (options.isArcgis == null) {
      options.isArcgis = str.indexOf('arcgis') > -1;
    }
    if (options.isSuperMap == null) {
      options.isSuperMap = str.indexOf('supermap') > -1;
    }
    var parser = new DOMParser();
    var xmlDoc = parser.parseFromString(str, 'text/xml');
    var content = xmlDoc.querySelectorAll('Contents')[0];
    if (!content) {
      return [];
    }
    var layers = getElementsByTagName(content, 'Layer');
    if (!layers.length) {
      return [];
    }
    var TileMatrixSets = [];
    for (var i = 0, len = content.childNodes.length; i < len; i++) {
      if (content.childNodes[i].localName === 'TileMatrixSet') {
        TileMatrixSets.push(content.childNodes[i]);
      }
    }
    if (!TileMatrixSets.length) {
      return [];
    }
    var result = [];
    for (var _i = 0, _len = layers.length; _i < _len; _i++) {
      var layer = layers[_i];
      var style = layer.querySelectorAll('Style')[0];
      if (style) {
        style = style.getElementsByTagName('ows:Identifier')[0];
        if (style) {
          style = style.textContent;
        }
      }
      var layerName = layer.getElementsByTagName('ows:Identifier')[0];
      if (layerName) {
        layerName = layerName.textContent;
      }
      var tileMatrixSetLinks = getElementsByTagName(layer, 'TileMatrixSetLink');
      if (tileMatrixSetLinks.length === 0) {
        continue;
      }
      for (var j = 0, len1 = tileMatrixSetLinks.length; j < len1; j++) {
        var tileMatrixSetLink = tileMatrixSetLinks[j];
        tileMatrixSetLink = getElementsByTagName(tileMatrixSetLink, 'TileMatrixSet')[0];
        if (tileMatrixSetLink) {
          tileMatrixSetLink = tileMatrixSetLink.textContent;
        }
        var tileMatrixSet = getTileMatrixSet(TileMatrixSets, tileMatrixSetLink);
        if (!tileMatrixSet) {
          continue;
        }
        var resourceURL = layer.querySelectorAll('ResourceURL')[0];
        var url = '';
        if (resourceURL) {
          url = resourceURL.attributes.template.value;
        }
        var _parseTileMatrixSet = parseTileMatrixSet(tileMatrixSet, options),
          resolutions = _parseTileMatrixSet.resolutions,
          tileSize = _parseTileMatrixSet.tileSize,
          tileSystem = _parseTileMatrixSet.tileSystem,
          projection = _parseTileMatrixSet.projection,
          TileMatrixSet = _parseTileMatrixSet.TileMatrixSet,
          isGeoServer = _parseTileMatrixSet.isGeoServer,
          levelStr = _parseTileMatrixSet.levelStr;
        if (!url.length) {
          url = requestUrl.substr(0, requestUrl.lastIndexOf('?'));
          url += '?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER={LAYER}&STYLE={Style}&TILEMATRIXSET={TileMatrixSet}&FORMAT={tiles}&TILEMATRIX={TileMatrix}&TILEROW={TileRow}&TILECOL={TileCol}';
        }
        var urlTemplate = strReplace(url, [['{LAYER}', layerName], ['{Layer}', layerName], ['{layer}', layerName], ['{STYLE}', style], ['{Style}', style], ['{style}', style], ['{TileMatrixSet}', TileMatrixSet], ['{TileMatrix}', isGeoServer ? levelStr + ":{z}" : '{z}'], ['{TileRow}', '{y}'], ['{TileCol}', '{x}'], ['{tiles}', isGeoServer ? 'image/png' : 'tiles']]);
        result.push({
          tileSize: tileSize,
          tileSystem: tileSystem,
          spatialReference: {
            resolutions: resolutions,
            projection: projection
          },
          urlTemplate: urlTemplate,
          info: {
            layerName: layerName,
            TileMatrixSet: TileMatrixSet,
            style: style,
            tileSize: tileSize,
            tileSystem: tileSystem,
            resolutions: resolutions,
            projection: projection,
            urlTemplate: urlTemplate
          }
        });
      }
    }
    return result;
  }
  function parseTileMatrixSet(TileMatrixSet, options) {
    if (options === void 0) {
      options = {};
    }
    var TileMatrixs = getElementsByTagName(TileMatrixSet, 'TileMatrix');
    var resolutions = [],
      tileSystem = [],
      tileSize = [];
    var projection,
      tset,
      isGeoServer = false,
      levelStr;
    if (!projection) {
      var supportedCRS = TileMatrixSet.getElementsByTagName('ows:SupportedCRS')[0];
      if (supportedCRS) {
        projection = supportedCRS.textContent;
        projection = projection.split('EPSG')[1];
        projection = getProjectionCode(projection);
        projection = getProjection(projection);
      }
    }
    if (!tset) {
      tset = TileMatrixSet.getElementsByTagName('ows:Identifier')[0];
      if (tset) {
        tset = tset.textContent;
      }
    }
    options.projection = projection;
    var minLevel = Infinity;
    for (var index = 0; index < TileMatrixs.length; index++) {
      var TileMatrix = TileMatrixs[index];
      var level = TileMatrix.getElementsByTagName('ows:Identifier')[0].textContent;
      if (isNaN(parseInt(level))) {
        levelStr = level.substr(0, level.lastIndexOf(':'));
        level = level.split(':');
        level = level[level.length - 1];
        level = parseInt(level);
        isGeoServer = true;
        options.isGeoServer = true;
      } else {
        level = parseInt(level);
      }
      minLevel = Math.min(minLevel, level);
      var ScaleDenominator = getElementsByTagName(TileMatrix, 'ScaleDenominator')[0].textContent;
      var TopLeftCorner = getElementsByTagName(TileMatrix, 'TopLeftCorner')[0].textContent;
      var TileWidth = getElementsByTagName(TileMatrix, 'TileWidth')[0].textContent;
      var TileHeight = getElementsByTagName(TileMatrix, 'TileHeight')[0].textContent;
      if (tileSize.length === 0) {
        tileSize.push(parseInt(TileWidth), parseInt(TileHeight));
      }
      if (tileSystem.length === 0) {
        var _TopLeftCorner$split$ = TopLeftCorner.split(' ').filter(function (s) {
            return s !== '';
          }).map(function (v) {
            return parseFloat(v);
          }),
          x = _TopLeftCorner$split$[0],
          y = _TopLeftCorner$split$[1];
        if (x > 0) {
          tileSystem.push(1, -1, y, x);
        } else {
          tileSystem.push(1, -1, x, y);
        }
      }
      var transformValue = getTransformValue(options);
      var res = parseFloat(ScaleDenominator) * transformValue;
      resolutions.push(res);
    }
    if (minLevel > 0) {
      var _res = resolutions[0];
      for (var i = minLevel - 1; i >= 0; i--) {
        _res = _res * 2;
        resolutions.splice(0, 0, _res);
      }
    }
    return {
      resolutions: resolutions,
      tileSize: tileSize,
      tileSystem: tileSystem,
      projection: projection,
      TileMatrixSet: tset,
      isGeoServer: isGeoServer,
      levelStr: levelStr
    };
  }
  SpatialReference.loadWMTS = function (url, cb, options) {
    if (options === void 0) {
      options = {
        'jsonp': true
      };
    }
    if (isString(url)) {
      Ajax.get(url, function (err, xml) {
        if (err) {
          cb(err);
          return;
        }
        var layers = parseWMTSXML(xml, url, options);
        cb(null, layers);
      }, options);
    }
    return this;
  };

  var options$j = {
    'eventsPropagation': false,
    'eventsToStop': null,
    'dx': 0,
    'dy': 0,
    'autoPan': false,
    'autoPanDuration': 600,
    'single': true,
    'animation': 'scale',
    'animationOnHide': false,
    'animationDuration': 500,
    'pitchWithMap': false,
    'rotateWithMap': false,
    'visible': true,
    'roundPoint': false,
    'collision': false,
    'collisionBufferSize': 2,
    'collisionWeight': 0,
    'collisionFadeIn': false,
    'zIndex': 0
  };
  var UIComponent = function (_Eventable) {
    _inheritsLoose(UIComponent, _Eventable);
    function UIComponent(options) {
      var _this;
      _this = _Eventable.call(this, options) || this;
      _this.proxyOptions();
      return _this;
    }
    var _proto = UIComponent.prototype;
    _proto.addTo = function addTo(owner) {
      this._owner = owner;
      this._switchEvents('on');
      if (this.onAdd) {
        this.onAdd();
      }
      this.fire('add');
      return this;
    };
    _proto.getMap = function getMap() {
      if (!this._owner) {
        return null;
      }
      if (this._owner.getBaseLayer) {
        return this._owner;
      }
      return this._owner.getMap();
    };
    _proto._collides = function _collides() {
      var map = this.getMap();
      if (!map) {
        return this;
      }
      map._addUI(this);
      map._insertUICollidesQueue();
      return this;
    };
    _proto._collidesEffect = function _collidesEffect(show) {
      var dom = this.getDOM();
      if (!dom) {
        return this;
      }
      var visibility = show ? 'visible' : 'hidden';
      dom.style.visibility = visibility;
      if (!dom.classList || !dom.classList.add) {
        return this;
      }
      if (!this.options['collisionFadeIn']) {
        return this;
      }
      var classList = dom.classList;
      var className = 'mtk-ui-fadein';
      var hasClass$$1 = classList.contains(className);
      if (show && !hasClass$$1) {
        dom.classList.add(className);
      } else if (!show && hasClass$$1) {
        dom.classList.remove(className);
      }
      return this;
    };
    _proto.show = function show(coordinate) {
      var _this2 = this;
      var map = this.getMap();
      if (!map) {
        return this;
      }
      this.options['visible'] = true;
      coordinate = coordinate || this._coordinate || this._owner.getCenter();
      if (!(coordinate instanceof Coordinate)) {
        coordinate = new Coordinate(coordinate);
      }
      var visible = this.isVisible();
      if (!this._showBySymbolChange) {
        this.fire('showstart');
      }
      var container = this._getUIContainer();
      this._coordinate = coordinate;
      this._removePrevDOM();
      if (!this._mapEventsOn) {
        this._switchMapEvents('on');
      }
      var dom = this.__uiDOM = this.buildOn(map);
      dom['eventsPropagation'] = this.options['eventsPropagation'];
      this._observerDomSize(dom);
      var zIndex = this.options.zIndex;
      if (!dom) {
        if (!this._showBySymbolChange) {
          this.fire('showend');
        }
        this._collides();
        this.setZIndex(zIndex);
        return this;
      }
      this._measureSize(dom);
      if (this._singleton()) {
        dom._uiComponent = this;
        map[this._uiDomKey()] = dom;
      }
      this._setPosition();
      dom.style[TRANSITION] = null;
      container.appendChild(dom);
      var anim = this._getAnimation();
      if (visible) {
        anim.ok = false;
      }
      if (anim.ok) {
        if (anim.fade) {
          dom.style.opacity = 0;
        }
        if (anim.scale) {
          if (this.getTransformOrigin) {
            var origin = this.getTransformOrigin();
            dom.style[TRANSFORMORIGIN] = origin;
          }
          dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(0)';
        }
      }
      if (!this.isSupportZoomFilter()) {
        dom.style.display = '';
      }
      if (this.options['eventsToStop']) {
        on(dom, this.options['eventsToStop'], stopPropagation);
      }
      var transition = anim.transition;
      if (anim.ok && transition) {
        dom.offsetHeight;
        if (transition) {
          dom.style[TRANSITION] = transition;
        }
        if (anim.fade) {
          dom.style.opacity = 1;
        }
        if (anim.scale) {
          dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(1)';
        }
      }
      if (!this._showBySymbolChange) {
        this.fire('showend');
      }
      this._collides();
      clearTimeout(this._autoPanId);
      if (this.options['autoPan']) {
        this._autoPanId = setTimeout(function () {
          _this2._autoPan();
        }, 32);
      }
      this.setZIndex(zIndex);
      return this;
    };
    _proto.hide = function hide() {
      var _this3 = this;
      if (!this.getDOM()) {
        return this;
      }
      if (this._onDomMouseout) {
        this._onDomMouseout();
      }
      this.options['visible'] = false;
      var anim = this._getAnimation(),
        dom = this.getDOM();
      if (!this.options['animationOnHide']) {
        anim.ok = false;
      }
      if (!anim.ok) {
        dom.style.display = 'none';
        this.fire('hide');
      } else {
        dom.offsetHeight;
        dom.style[TRANSITION] = anim.transition;
        setTimeout(function () {
          dom.style.display = 'none';
          _this3.fire('hide');
        }, this.options['animationDuration']);
      }
      if (anim.fade) {
        dom.style.opacity = 0;
      }
      if (anim.scale) {
        dom.style[TRANSFORM] = this._toCSSTranslate(this._pos) + ' scale(0)';
      }
      this._switchMapEvents('off');
      this._collides();
      return this;
    };
    _proto.isVisible = function isVisible() {
      if (!this.options['visible']) {
        return false;
      }
      var dom = this.getDOM();
      return this.getMap() && dom && dom.parentNode && dom.style.display !== 'none';
    };
    _proto.remove = function remove() {
      delete this._mapEventsOn;
      if (!this._owner) {
        return this;
      }
      var map = this.getMap();
      if (map) {
        map._removeUI(this);
      }
      this.hide();
      this._switchEvents('off');
      if (this.onRemove) {
        this.onRemove();
      }
      if (!this._singleton() && this.__uiDOM) {
        this._removePrevDOM();
      }
      delete this._owner;
      this.fire('remove');
      this._collides();
      return this;
    };
    _proto.getSize = function getSize() {
      if (this._domContentRect && this._size) {
        this._size.width = this._domContentRect.width;
        this._size.height = this._domContentRect.height;
      }
      if (this._size) {
        return this._size.copy();
      } else {
        return null;
      }
    };
    _proto.getOwner = function getOwner() {
      return this._owner;
    };
    _proto.getDOM = function getDOM() {
      return this.__uiDOM;
    };
    _proto.setZIndex = function setZIndex(zIndex) {
      if (!isNumber(zIndex)) {
        return this;
      }
      var dom = this.getDOM();
      if (!dom) {
        return this;
      }
      dom.style.zIndex = zIndex;
      if (zIndex !== this.options.zIndex) {
        this.options.zIndex = zIndex;
      }
      return this;
    };
    _proto._roundPoint = function _roundPoint(point) {
      if (this.options.roundPoint) {
        point = point._round();
      }
      return point;
    };
    _proto.getPosition = function getPosition() {
      if (!this.getMap()) {
        return null;
      }
      var p = this._roundPoint(this._getViewPoint());
      if (this.getOffset) {
        var o = this._roundPoint(this.getOffset());
        if (o) {
          p._add(o);
        }
      }
      return p;
    };
    _proto._getAnimation = function _getAnimation() {
      var anim = {
        'fade': false,
        'scale': false
      };
      var animations = this.options['animation'] ? this.options['animation'].split(',') : [];
      for (var i = 0; i < animations.length; i++) {
        var trimed = trim(animations[i]);
        if (trimed === 'fade') {
          anim.fade = true;
        } else if (trimed === 'scale') {
          anim.scale = true;
        }
      }
      var transition = null;
      if (anim.fade) {
        transition = 'opacity ' + this.options['animationDuration'] + 'ms';
      }
      if (anim.scale) {
        transition = transition ? transition + ',' : '';
        transition += TRANSFORM + ' ' + this.options['animationDuration'] + 'ms';
      }
      anim.transition = transition;
      anim.ok = transition !== null;
      return anim;
    };
    _proto._getViewPoint = function _getViewPoint() {
      var altitude = 0;
      var coordinates = this._coordinate || {};
      if (isNumber(coordinates.z)) {
        altitude = coordinates.z;
      } else if (this._owner && this._owner.getAltitude) {
        altitude = this._owner.getAltitude() || 0;
        if (!isNumber(altitude)) {
          altitude = 0;
        }
      }
      var alt = this._meterToPoint(this._coordinate, altitude);
      return this.getMap().coordToViewPoint(this._coordinate, undefined, alt)._add(this.options['dx'], this.options['dy']);
    };
    _proto._meterToPoint = function _meterToPoint(center, altitude) {
      return altitude;
    };
    _proto._autoPan = function _autoPan() {
      var map = this.getMap(),
        dom = this.getDOM();
      if (!dom || !map || map.isMoving()) {
        return;
      }
      var point = this._getViewPoint()._round();
      var mapWidth = map.width;
      var mapHeight = map.height;
      var mapContainer = map.getContainer();
      if (dom && mapContainer && dom.getBoundingClientRect) {
        var mapRect = mapContainer.getBoundingClientRect();
        var mapLeft = mapRect.left;
        var mapTop = mapRect.top;
        var _margin = 50;
        var rect = dom.getBoundingClientRect();
        var offsetX = 0,
          offsetY = 0;
        var _left = rect.left,
          right = rect.right,
          _top = rect.top,
          bottom = rect.bottom;
        var width = rect.width,
          height = rect.height;
        _left -= mapLeft;
        right -= mapLeft;
        _top -= mapTop;
        bottom -= mapTop;
        if (width > 0 && height > 0) {
          if (_left < _margin) {
            offsetX = _margin - _left;
          }
          if (offsetX === 0 && right + _margin > mapWidth) {
            offsetX = -(right + _margin - mapWidth);
          }
          if (_top < _margin) {
            offsetY = _margin - _top;
          }
          if (offsetY === 0 && bottom + _margin > mapHeight) {
            offsetY = -(bottom + _margin - mapHeight);
          }
          if (offsetX !== 0 || offsetY !== 0) {
            var pitch = map.getPitch();
            if (pitch > 40 && offsetY !== 0 && this._coordinate) {
              map.animateTo({
                center: this._coordinate
              }, {
                duration: map.options['panAnimationDuration']
              });
            } else {
              map.panBy([Math.ceil(offsetX), Math.ceil(offsetY)]);
            }
          }
          return;
        }
      }
      var containerPoint0 = map.viewPointToContainerPoint(point);
      var offset = this.getOffset();
      var containerPoint = containerPoint0.add(offset);
      var prjCoord = map._viewPointToPrj(point);
      var domWidth = parseInt(dom.clientWidth);
      var domHeight = parseInt(dom.clientHeight);
      var margin = 50;
      var left = 0,
        top = 0;
      if (containerPoint.x < 0) {
        left = -containerPoint.x + margin;
      } else if (containerPoint.x + domWidth > mapWidth) {
        left = -(containerPoint.x + domWidth - mapWidth) - margin;
      }
      if (containerPoint.y - domHeight < 0) {
        top = Math.abs(containerPoint.y - domHeight) + margin;
      } else if (containerPoint.y + domHeight > mapHeight) {
        top = mapHeight - (containerPoint.y + domHeight) - margin;
      }
      if (domWidth >= mapWidth) {
        left = mapWidth / 2 - containerPoint0.x;
      }
      if (top !== 0 || left !== 0) {
        var newContainerPoint = containerPoint0.add(left, top);
        var t = map._containerPointToPoint(newContainerPoint)._sub(map._prjToPoint(map._getPrjCenter()));
        var target = map._pointToPrj(map._prjToPoint(prjCoord).sub(t));
        map._panAnimation(target);
      }
    };
    _proto._measureSize = function _measureSize(dom) {
      var container = this._getUIContainer();
      dom.style.position = 'absolute';
      var anchor = dom.style.bottom ? 'bottom' : 'top';
      dom.style.display = '';
      container.appendChild(dom);
      if (dom.getBoundingClientRect) {
        var rect = dom.getBoundingClientRect();
        this._size = new Size(rect.width, rect.height);
      } else {
        this._size = new Size(dom.clientWidth, dom.clientHeight);
      }
      dom.style.display = 'none';
      dom.style.left = '0px';
      dom.style[anchor] = '0px';
      return this._size;
    };
    _proto._removePrevDOM = function _removePrevDOM() {
      if (this.onDomRemove) {
        this.onDomRemove();
      }
      var eventsToStop = this.options['eventsToStop'];
      if (this._singleton()) {
        var map = this.getMap(),
          key = this._uiDomKey();
        if (map[key]) {
          if (eventsToStop) {
            off(map[key], eventsToStop, stopPropagation);
          }
          var uiComponent = map[key]._uiComponent;
          if (uiComponent && uiComponent !== this && uiComponent.isVisible()) {
            uiComponent.fire('hide');
          }
          removeDomNode(map[key]);
          if (uiComponent && !this.hideDom) {
            uiComponent._switchMapEvents('off');
          }
          delete map[key];
        }
        delete this.__uiDOM;
      } else if (this.__uiDOM) {
        if (eventsToStop) {
          off(this.__uiDOM, eventsToStop, stopPropagation);
        }
        removeDomNode(this.__uiDOM);
        delete this.__uiDOM;
      }
      if (this._resizeObserver) {
        this._resizeObserver.disconnect();
        delete this._resizeObserver;
        delete this._domContentRect;
      }
    };
    _proto._uiDomKey = function _uiDomKey() {
      return '__ui_' + this._getClassName();
    };
    _proto._singleton = function _singleton() {
      return this.options['single'];
    };
    _proto._getUIContainer = function _getUIContainer() {
      return this.getMap()._panels['ui'];
    };
    _proto._getClassName = function _getClassName() {
      return 'UIComponent';
    };
    _proto._switchMapEvents = function _switchMapEvents(to) {
      var map = this.getMap();
      if (!map) {
        return;
      }
      this._mapEventsOn = to === 'on';
      var events = this._getDefaultEvents();
      if (this.getEvents) {
        extend(events, this.getEvents());
      }
      if (events) {
        for (var p in events) {
          if (events.hasOwnProperty(p)) {
            map[to](p, events[p], this);
          }
        }
      }
    };
    _proto._switchEvents = function _switchEvents(to) {
      var ownerEvents = this._getOwnerEvents();
      if (this._owner) {
        for (var p in ownerEvents) {
          if (ownerEvents.hasOwnProperty(p)) {
            this._owner[to](p, ownerEvents[p], this);
          }
        }
      }
    };
    _proto._getDefaultEvents = function _getDefaultEvents() {
      return {
        'zooming rotate pitch': this.onEvent,
        'zoomend': this.onZoomEnd,
        'moving': this.onMoving,
        'moveend': this.onMoving,
        'resize': this.onResize
      };
    };
    _proto._getOwnerEvents = function _getOwnerEvents() {
      var events = {};
      if (this._owner && this._owner instanceof Geometry) {
        events.positionchange = this.onGeometryPositionChange;
        events.symbolchange = this._updatePosition;
      }
      if (this.getOwnerEvents) {
        extend(events, this.getOwnerEvents());
      }
      return events;
    };
    _proto.onGeometryPositionChange = function onGeometryPositionChange(param) {
      if (this._owner && this.isVisible()) {
        this._showBySymbolChange = true;
        this.show(param['target'].getCenter());
        delete this._showBySymbolChange;
      }
    };
    _proto.onMoving = function onMoving() {
      if (this.isVisible() && this.getMap().isTransforming()) {
        this._updatePosition();
      }
    };
    _proto.onEvent = function onEvent() {
      if (this.isVisible()) {
        this._updatePosition();
      }
    };
    _proto.onZoomEnd = function onZoomEnd() {
      if (this.isVisible()) {
        this._setPosition();
      }
    };
    _proto.onResize = function onResize() {
      if (this.isVisible()) {
        this._setPosition();
      }
    };
    _proto.onDomSizeChange = function onDomSizeChange() {
      if (this.isVisible()) {
        this._setPosition();
        this._collides();
      }
    };
    _proto._updatePosition = function _updatePosition() {
      if (!this.getMap()) {
        return this;
      }
      var renderer = this.getMap()._getRenderer();
      renderer.callInNextFrame(this._setPosition.bind(this));
      return this;
    };
    _proto._setPosition = function _setPosition() {
      var dom = this.getDOM();
      if (!dom) return;
      dom.style[TRANSITION] = null;
      var p = this.getPosition();
      this._pos = p;
      dom.style[TRANSFORM] = this._toCSSTranslate(p) + ' scale(1)';
    };
    _proto._toCSSTranslate = function _toCSSTranslate(p) {
      if (!p) {
        return '';
      }
      if (Browser$1.any3d) {
        var map = this.getMap(),
          bearing = map ? map.getBearing() : 0,
          pitch = map ? map.getPitch() : 0;
        var r = '';
        if (this.options['pitchWithMap'] && pitch) {
          r += " rotateX(" + Math.round(pitch) + "deg)";
        }
        if (this.options['rotateWithMap'] && bearing) {
          r += " rotateZ(" + Math.round(-bearing) + "deg)";
        }
        return 'translate3d(' + p.x + 'px,' + p.y + 'px, 0px)' + r;
      } else {
        return 'translate(' + p.x + 'px,' + p.y + 'px)';
      }
    };
    _proto._observerDomSize = function _observerDomSize(dom) {
      var _this4 = this;
      if (!dom || !Browser$1.resizeObserver || this._resizeObserver) {
        return this;
      }
      this._resizeObserver = new ResizeObserver(function (entries) {
        if (entries.length) {
          var borderBoxSize = entries[0].borderBoxSize;
          if (borderBoxSize && borderBoxSize.length) {
            _this4._domContentRect = {
              width: borderBoxSize[0].inlineSize,
              height: borderBoxSize[0].blockSize
            };
          } else {
            _this4._domContentRect = entries[0].contentRect;
          }
        } else {
          delete _this4._domContentRect;
        }
        if (_this4.onDomSizeChange) {
          _this4.onDomSizeChange();
        }
      });
      this._resizeObserver.observe(dom);
      return this;
    };
    _proto.isSupportZoomFilter = function isSupportZoomFilter() {
      return false;
    };
    _proto.onConfig = function onConfig() {
      this._updatePosition();
      return this;
    };
    UIComponent.isSupport = function isSupport(owner) {
      if (owner && isFunction(owner.on) && isFunction(owner.off) && isFunction(owner.getCenter)) {
        return true;
      }
      return false;
    };
    return UIComponent;
  }(Eventable(Class));
  UIComponent.mergeOptions(options$j);

  var options$k = {
    'containerClass': null,
    'eventsPropagation': true,
    'draggable': false,
    'single': false,
    'content': null,
    'altitude': 0,
    'minZoom': 0,
    'maxZoom': null,
    'horizontalAlignment': 'middle',
    'verticalAlignment': 'middle'
  };
  var domEvents = 'mousedown ' + 'mouseup ' + 'mouseenter ' + 'mouseover ' + 'mouseout ' + 'mousemove ' + 'click ' + 'dblclick ' + 'contextmenu ' + 'keypress ' + 'touchstart ' + 'touchmove ' + 'touchend';
  var UIMarker = function (_Handlerable) {
    _inheritsLoose(UIMarker, _Handlerable);
    function UIMarker(coordinate, options) {
      var _this;
      _this = _Handlerable.call(this, options) || this;
      _this._markerCoord = new Coordinate(coordinate);
      return _this;
    }
    var _proto = UIMarker.prototype;
    _proto._getClassName = function _getClassName() {
      return 'UIMarker';
    };
    _proto.setCoordinates = function setCoordinates(coordinates) {
      this._markerCoord = coordinates;
      this.fire('positionchange');
      if (this.isVisible()) {
        this._coordinate = this._markerCoord;
        this._setPosition();
        this._collides();
      }
      return this;
    };
    _proto.getCoordinates = function getCoordinates() {
      return this._markerCoord;
    };
    _proto.getCenter = function getCenter() {
      return this.getCoordinates();
    };
    _proto.getAltitude = function getAltitude() {
      var coordinates = this.getCoordinates() || {};
      if (isNumber(coordinates.z)) {
        return coordinates.z;
      }
      return this.options.altitude || 0;
    };
    _proto.setAltitude = function setAltitude(alt) {
      if (isNumber(alt) && this._markerCoord) {
        this._markerCoord.z = alt;
        if (this._updatePosition) {
          this._updatePosition();
          this._collides();
        }
      }
      return this;
    };
    _proto.setContent = function setContent(content) {
      var old = this.options['content'];
      this.options['content'] = content;
      this.fire('contentchange', {
        'old': old,
        'new': content
      });
      if (this.isVisible()) {
        this.show();
      }
      return this;
    };
    _proto.getContent = function getContent() {
      return this.options['content'];
    };
    _proto.onAdd = function onAdd() {
      if (this._owner && !this._owner.isMap) {
        throw new Error('UIMarker Can only be added to the map, but owner is:', this._owner.getJSONType());
      }
      this.show();
      return this;
    };
    _proto.show = function show() {
      return _Handlerable.prototype.show.call(this, this._markerCoord);
    };
    _proto.flash = function flash$$1(interval, count, cb, context) {
      return flash.call(this, interval, count, cb, context);
    };
    _proto.buildOn = function buildOn() {
      var dom;
      var content = this.options['content'];
      var isStr = isString(content);
      if (isStr || isFunction(content)) {
        dom = createEl('div');
        if (isStr) {
          dom.innerHTML = this.options['content'];
        } else {
          content.bind(this)(dom);
        }
      } else {
        dom = this.options['content'];
      }
      if (this.options['containerClass']) {
        dom.className = this.options['containerClass'];
      }
      this._registerDOMEvents(dom);
      return dom;
    };
    _proto.getOffset = function getOffset() {
      var size = this.getSize();
      var offsetX = -size.width / 2,
        offsetY = -size.height / 2;
      var _this$options = this.options,
        horizontalAlignment = _this$options.horizontalAlignment,
        verticalAlignment = _this$options.verticalAlignment;
      if (horizontalAlignment === 'left') {
        offsetX = -size.width;
      } else if (horizontalAlignment === 'right') {
        offsetX = 0;
      }
      if (verticalAlignment === 'top') {
        offsetY = -size.height;
      } else if (verticalAlignment === 'bottom') {
        offsetY = 0;
      }
      return new Point(offsetX, offsetY);
    };
    _proto.getTransformOrigin = function getTransformOrigin() {
      return 'center center';
    };
    _proto.onDomRemove = function onDomRemove() {
      var dom = this.getDOM();
      this._removeDOMEvents(dom);
    };
    _proto.isDragging = function isDragging() {
      if (this['draggable']) {
        return this['draggable'].isDragging();
      }
      return false;
    };
    _proto._registerDOMEvents = function _registerDOMEvents(dom) {
      on(dom, domEvents, this._onDomEvents, this);
    };
    _proto._onDomEvents = function _onDomEvents(e) {
      var event = this.getMap()._parseEvent(e, e.type);
      var type = e.type;
      if (type === 'mousedown') {
        this._mousedownEvent = e;
      }
      if (type === 'mouseup') {
        this._mouseupEvent = e;
      }
      if (type === 'click' && this._mouseClickPositionIsChange()) {
        return;
      }
      if (type === 'touchstart') {
        this._touchstartTime = now();
      }
      this.fire(e.type, event);
      if (type === 'touchend' && Browser$1.touch) {
        var clickTimeThreshold = this.getMap().options.clickTimeThreshold || 280;
        if (now() - this._touchstartTime < clickTimeThreshold) {
          this._onDomEvents(extend({}, e, {
            type: 'click'
          }));
        }
      }
    };
    _proto._removeDOMEvents = function _removeDOMEvents(dom) {
      off(dom, domEvents, this._onDomEvents, this);
    };
    _proto._mouseClickPositionIsChange = function _mouseClickPositionIsChange() {
      var _ref = this._mousedownEvent || {},
        x1 = _ref.x,
        y1 = _ref.y;
      var _ref2 = this._mouseupEvent || {},
        x2 = _ref2.x,
        y2 = _ref2.y;
      return x1 !== x2 || y1 !== y2;
    };
    _proto._getConnectPoints = function _getConnectPoints() {
      var map = this.getMap();
      var containerPoint = map.coordToContainerPoint(this.getCoordinates());
      var size = this.getSize(),
        width = size.width,
        height = size.height;
      var anchors = [map.containerPointToCoordinate(containerPoint.add(-width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(0, height / 2)), map.containerPointToCoordinate(containerPoint.add(0, -height / 2))];
      return anchors;
    };
    _proto._getViewPoint = function _getViewPoint() {
      var alt = 0;
      if (this._owner) {
        var altitude = this.getAltitude();
        if (altitude > 0) {
          alt = this._meterToPoint(this._coordinate, altitude);
        }
      }
      return this.getMap().coordToViewPoint(this._coordinate, undefined, alt)._add(this.options['dx'], this.options['dy']);
    };
    _proto._getDefaultEvents = function _getDefaultEvents() {
      return extend({}, _Handlerable.prototype._getDefaultEvents.call(this), {
        'zooming zoomend': this.onZoomFilter
      });
    };
    _proto._setPosition = function _setPosition() {
      this.onZoomFilter();
      _Handlerable.prototype._setPosition.call(this);
    };
    _proto.onZoomFilter = function onZoomFilter() {
      var dom = this.getDOM();
      if (!dom) return;
      if (!this.isVisible() && dom.style.display !== 'none') {
        dom.style.display = 'none';
      } else if (this.isVisible() && dom.style.display === 'none') {
        dom.style.display = '';
      }
    };
    _proto.isVisible = function isVisible() {
      var map = this.getMap();
      if (!map) {
        return false;
      }
      if (!this.options['visible']) {
        return false;
      }
      var zoom = map.getZoom();
      var _this$options2 = this.options,
        minZoom = _this$options2.minZoom,
        maxZoom = _this$options2.maxZoom;
      if (!isNil(minZoom) && zoom < minZoom || !isNil(maxZoom) && zoom > maxZoom) {
        return false;
      }
      var dom = this.getDOM();
      return dom && true;
    };
    _proto.isSupportZoomFilter = function isSupportZoomFilter() {
      return true;
    };
    return UIMarker;
  }(Handlerable(UIComponent));
  UIMarker.mergeOptions(options$k);
  var EVENTS$1 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
  var UIMarkerDragHandler = function (_Handler) {
    _inheritsLoose(UIMarkerDragHandler, _Handler);
    function UIMarkerDragHandler(target) {
      return _Handler.call(this, target) || this;
    }
    var _proto2 = UIMarkerDragHandler.prototype;
    _proto2.addHooks = function addHooks() {
      this.target.on(EVENTS$1, this._startDrag, this);
    };
    _proto2.removeHooks = function removeHooks() {
      this.target.off(EVENTS$1, this._startDrag, this);
    };
    _proto2._startDrag = function _startDrag(param) {
      var domEvent = param['domEvent'];
      if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
        return;
      }
      if (this.isDragging()) {
        return;
      }
      this.target.on('click', this._endDrag, this);
      this._lastCoord = param['coordinate'];
      this._lastPoint = param['containerPoint'];
      this._prepareDragHandler();
      this._dragHandler.onMouseDown(param['domEvent']);
      this.target.fire('dragstart', param);
    };
    _proto2._prepareDragHandler = function _prepareDragHandler() {
      this._dragHandler = new DragHandler(this.target.getDOM(), {
        'cancelOn': this._cancelOn.bind(this),
        'ignoreMouseleave': true
      });
      this._dragHandler.on('mousedown', this._onMouseDown, this);
      this._dragHandler.on('dragging', this._dragging, this);
      this._dragHandler.on('mouseup', this._endDrag, this);
      this._dragHandler.enable();
    };
    _proto2._cancelOn = function _cancelOn(domEvent) {
      var target = domEvent.srcElement || domEvent.target,
        tagName = target.tagName.toLowerCase();
      if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
        return true;
      }
      return false;
    };
    _proto2._onMouseDown = function _onMouseDown(param) {
      stopPropagation(param['domEvent']);
    };
    _proto2._dragging = function _dragging(param) {
      var target = this.target,
        map = target.getMap(),
        eventParam = map._parseEvent(param['domEvent']),
        domEvent = eventParam['domEvent'];
      if (domEvent.touches && domEvent.touches.length > 1) {
        return;
      }
      if (!this._isDragging) {
        this._isDragging = true;
        return;
      }
      var coord = eventParam['coordinate'],
        point = eventParam['containerPoint'];
      if (!this._lastCoord) {
        this._lastCoord = coord;
      }
      if (!this._lastPoint) {
        this._lastPoint = point;
      }
      var coordOffset = coord.sub(this._lastCoord),
        pointOffset = point.sub(this._lastPoint);
      this._lastCoord = coord;
      this._lastPoint = point;
      this.target.setCoordinates(this.target.getCoordinates().add(coordOffset));
      eventParam['coordOffset'] = coordOffset;
      eventParam['pointOffset'] = pointOffset;
      target.fire('dragging', eventParam);
    };
    _proto2._endDrag = function _endDrag(param) {
      var target = this.target,
        map = target.getMap();
      if (this._dragHandler) {
        target.off('click', this._endDrag, this);
        this._dragHandler.disable();
        delete this._dragHandler;
      }
      delete this._lastCoord;
      delete this._lastPoint;
      this._isDragging = false;
      if (!map) {
        return;
      }
      var eventParam = map._parseEvent(param['domEvent']);
      if (target && target._mouseClickPositionIsChange && target._mouseClickPositionIsChange()) {
        target.fire('dragend', eventParam);
      }
    };
    _proto2.isDragging = function isDragging() {
      if (!this._isDragging) {
        return false;
      }
      return true;
    };
    return UIMarkerDragHandler;
  }(Handler$1);
  UIMarker.addInitHook('addHandler', 'draggable', UIMarkerDragHandler);

  var PROPERTY_PATTERN = /\{ *([\w_]+) *\}/g;
  var options$l = {
    'containerClass': 'maptalks-msgBox',
    'autoPan': true,
    'autoCloseOn': null,
    'autoOpenOn': 'click',
    'width': 'auto',
    'minHeight': 120,
    'custom': false,
    'title': null,
    'content': null,
    'enableTemplate': false
  };
  var EMPTY_SIZE = new Size(0, 0);
  var InfoWindow = function (_UIComponent) {
    _inheritsLoose(InfoWindow, _UIComponent);
    function InfoWindow() {
      return _UIComponent.apply(this, arguments) || this;
    }
    var _proto = InfoWindow.prototype;
    _proto._getClassName = function _getClassName() {
      return 'InfoWindow';
    };
    _proto.addTo = function addTo(owner) {
      if (owner instanceof Geometry) {
        if (owner.getInfoWindow() && owner.getInfoWindow() !== this) {
          owner.removeInfoWindow();
        }
        owner._infoWindow = this;
      }
      return _UIComponent.prototype.addTo.call(this, owner);
    };
    _proto.setContent = function setContent(content) {
      var old = this.options['content'];
      this.options['content'] = content;
      this.fire('contentchange', {
        'old': old,
        'new': content
      });
      if (this.isVisible()) {
        this.show(this._coordinate);
      }
      return this;
    };
    _proto.getContent = function getContent() {
      return this.options['content'];
    };
    _proto.setTitle = function setTitle(title) {
      var old = title;
      this.options['title'] = title;
      this.fire('contentchange', {
        'old': old,
        'new': title
      });
      if (this.isVisible()) {
        this.show(this._coordinate);
      }
      return this;
    };
    _proto.getTitle = function getTitle() {
      return this.options['title'];
    };
    _proto.buildOn = function buildOn() {
      var isFunc = isFunction(this.options['content']);
      var isStr = isString(this.options['content']);
      if (this.options['custom']) {
        if (isStr || isFunc) {
          var _dom = createEl('div');
          if (isStr) {
            _dom.innerHTML = this.options['content'];
            this._replaceTemplate(_dom);
          } else {
            this.options['content'].bind(this)(_dom);
          }
          return _dom;
        } else {
          this._replaceTemplate(this.options['content']);
          return this.options['content'];
        }
      }
      this._bindDomEvents(this.getDOM(), 'off');
      var dom = createEl('div');
      if (this.options['containerClass']) {
        dom.className = this.options['containerClass'];
      }
      var width = this._getWindowWidth();
      dom.style.width = isNumber(width) ? width + 'px' : 'auto';
      dom.style.bottom = '0px';
      var content = '<em class="maptalks-ico"></em>';
      if (this.options['title']) {
        content += '<h2>' + this.options['title'] + '</h2>';
      }
      content += '<a href="javascript:void(0);" class="maptalks-close">×</a><div class="maptalks-msgContent"></div>';
      dom.innerHTML = content;
      this._replaceTemplate(dom);
      var msgContent = dom.querySelector('.maptalks-msgContent');
      if (isStr || isFunc) {
        if (isStr) {
          msgContent.innerHTML = this.options['content'];
        } else {
          this.options['content'].bind(this)(msgContent);
        }
      } else {
        msgContent.appendChild(this.options['content']);
      }
      this._onCloseBtnClick = this.hide.bind(this);
      var closeBtn = dom.querySelector('.maptalks-close');
      addDomEvent(closeBtn, 'click touchend', this._onCloseBtnClick);
      if (!isFunc) {
        this._replaceTemplate(msgContent);
      }
      this._bindDomEvents(dom, 'on');
      return dom;
    };
    _proto._replaceTemplate = function _replaceTemplate(dom) {
      if (this.options['enableTemplate'] && this._owner && this._owner.getProperties && dom && dom.innerHTML) {
        var properties = this._owner.getProperties() || {};
        if (isObject(properties)) {
          var html = dom.innerHTML;
          dom.innerHTML = html.replace(PROPERTY_PATTERN, function (str, key) {
            return properties[key];
          });
        }
      }
      return this;
    };
    _proto.getTransformOrigin = function getTransformOrigin() {
      var size = this.getSize();
      return size.width / 2 + 'px bottom';
    };
    _proto.getOffset = function getOffset() {
      var size = this.getSize();
      var o = new Point(-size['width'] / 2, 0);
      if (!this.options['custom']) {
        o._sub(4, 12);
      } else {
        o._sub(0, size['height']);
      }
      var owner = this.getOwner();
      if (owner instanceof Marker || owner instanceof MultiPoint) {
        var painter, markerSize;
        if (owner instanceof Marker) {
          painter = owner._getPainter();
          markerSize = owner.getSize();
        } else {
          var children = owner.getGeometries();
          if (!children || !children.length) {
            return o;
          }
          painter = children[0]._getPainter();
          markerSize = children[0].getSize();
        }
        if (!markerSize) {
          markerSize = EMPTY_SIZE;
        }
        if (painter) {
          var fixExtent = painter.getFixedExtent();
          o._add(fixExtent.xmax - markerSize.width / 2, fixExtent.ymin);
        } else {
          o._add(0, -markerSize.height);
        }
      }
      return o;
    };
    _proto.show = function show(coordinate) {
      if (!this.getMap()) {
        return this;
      }
      if (!this.getMap().options['enableInfoWindow']) {
        return this;
      }
      return _UIComponent.prototype.show.call(this, coordinate);
    };
    _proto.getEvents = function getEvents() {
      if (!this.options['autoCloseOn']) {
        return null;
      }
      var events = {};
      events[this.options['autoCloseOn']] = this.hide;
      return events;
    };
    _proto.getOwnerEvents = function getOwnerEvents() {
      var owner = this.getOwner();
      if (!this.options['autoOpenOn'] || !owner) {
        return null;
      }
      var events = {};
      events[this.options['autoOpenOn']] = this._onAutoOpen;
      return events;
    };
    _proto.onRemove = function onRemove() {
      this._onDomMouseout();
      this.onDomRemove();
    };
    _proto.onDomRemove = function onDomRemove() {
      if (this._onCloseBtnClick) {
        var dom = this.getDOM();
        var closeBtn = dom.childNodes[2];
        removeDomEvent(closeBtn, 'click touchend', this._onCloseBtnClick);
        delete this._onCloseBtnClick;
      }
    };
    _proto._onAutoOpen = function _onAutoOpen(e) {
      var _this = this;
      var owner = this.getOwner();
      setTimeout(function () {
        if (owner instanceof Marker || owner instanceof UIComponent) {
          _this.show(owner.getCoordinates());
        } else if (owner instanceof MultiPoint) {
          _this.show(owner.findClosest(e.coordinate));
        } else if (owner instanceof LineString || owner instanceof MultiLineString) {
          if (_this.getMap().getScale() >= 8) {
            e.coordinate = _this._rectifyMouseCoordinte(owner, e.coordinate);
          }
          _this.show(e.coordinate);
        } else {
          _this.show(e.coordinate);
        }
      }, 1);
    };
    _proto._rectifyMouseCoordinte = function _rectifyMouseCoordinte(owner, mouseCoordinate) {
      var _this2 = this;
      if (owner instanceof LineString) {
        return this._rectifyLineStringMouseCoordinate(owner, mouseCoordinate).coordinate;
      } else if (owner instanceof MultiLineString) {
        return owner.getGeometries().map(function (lineString) {
          return _this2._rectifyLineStringMouseCoordinate(lineString, mouseCoordinate);
        }).sort(function (a, b) {
          return a.dis - b.dis;
        })[0].coordinate;
      }
      return mouseCoordinate;
    };
    _proto._rectifyLineStringMouseCoordinate = function _rectifyLineStringMouseCoordinate(lineString, mouseCoordinate) {
      var _this3 = this;
      var pts = lineString.getCoordinates().map(function (coordinate) {
        return _this3.getMap().coordToContainerPoint(coordinate);
      });
      var mousePt = this.getMap().coordToContainerPoint(mouseCoordinate);
      var minDis = Infinity,
        coordinateIndex = -1;
      for (var i = 0, len = pts.length; i < len; i++) {
        var pt = pts[i];
        var dis = mousePt.distanceTo(pt);
        if (dis < minDis) {
          minDis = dis;
          coordinateIndex = i;
        }
      }
      var filterPts = [];
      if (coordinateIndex === 0) {
        filterPts.push(pts[0], pts[1]);
      } else if (coordinateIndex === pts.length - 1) {
        filterPts.push(pts[coordinateIndex - 1], pts[coordinateIndex]);
      } else {
        filterPts.push(pts[coordinateIndex - 1], pts[coordinateIndex], pts[coordinateIndex + 1]);
      }
      var xys = [];
      var _this$getMap$getSize = this.getMap().getSize(),
        width = _this$getMap$getSize.width,
        height = _this$getMap$getSize.height;
      for (var _i = 0, _len = filterPts.length - 1; _i < _len; _i++) {
        var pt1 = filterPts[_i],
          pt2 = filterPts[_i + 1];
        if (pt1.x === pt2.x) {
          var miny = Math.max(0, Math.min(pt1.y, pt2.y));
          var maxy = Math.min(height, Math.max(pt1.y, pt2.y));
          for (var y = miny; y <= maxy; y++) {
            xys.push(new Point(pt1.x, y));
          }
        } else {
          var k = (pt2.y - pt1.y) / (pt2.x - pt1.x);
          var minx = Math.max(0, Math.min(pt1.x, pt2.x));
          var maxx = Math.min(width, Math.max(pt1.x, pt2.x));
          for (var x = minx; x <= maxx; x++) {
            var _y = k * (x - pt1.x) + pt1.y;
            xys.push(new Point(x, _y));
          }
        }
      }
      var minPtDis = Infinity,
        ptIndex = -1;
      for (var _i2 = 0, _len2 = xys.length; _i2 < _len2; _i2++) {
        var _pt = xys[_i2];
        var _dis = mousePt.distanceTo(_pt);
        if (_dis < minPtDis) {
          minPtDis = _dis;
          ptIndex = _i2;
        }
      }
      return {
        dis: minPtDis,
        coordinate: ptIndex < 0 ? mouseCoordinate : this.getMap().containerPointToCoord(xys[ptIndex])
      };
    };
    _proto._getWindowWidth = function _getWindowWidth() {
      var defaultWidth = options$l.width;
      var width = this.options['width'];
      if (!width) {
        width = defaultWidth;
      }
      return width;
    };
    _proto._bindDomEvents = function _bindDomEvents(dom, to) {
      if (!dom) {
        return;
      }
      var events = this._getDomEvents();
      var bindEvent = to === 'on' ? on : off;
      for (var eventName in events) {
        bindEvent(dom, eventName, events[eventName], this);
      }
    };
    _proto._getDomEvents = function _getDomEvents() {
      return {
        'mouseover': this._onDomMouseover,
        'mouseout': this._onDomMouseout
      };
    };
    _proto._onDomMouseover = function _onDomMouseover(domEvent) {
      var map = this.getMap();
      if (!map) {
        return;
      }
      map.options['preventWheelScroll'] = false;
    };
    _proto._onDomMouseout = function _onDomMouseout(domEvent) {
      var map = this.getMap();
      if (!map) {
        return;
      }
      map.options['preventWheelScroll'] = true;
    };
    return InfoWindow;
  }(UIComponent);
  InfoWindow.mergeOptions(options$l);

  var HIDEDOMEVENTS = 'remove hide shapechange positionchange dragend animatestart';
  var options$m = {
    'width': 0,
    'height': 0,
    'animation': 'fade',
    'containerClass': 'maptalks-tooltip',
    'showTimeout': 400
  };
  var ToolTip = function (_UIComponent) {
    _inheritsLoose(ToolTip, _UIComponent);
    var _proto = ToolTip.prototype;
    _proto._getClassName = function _getClassName() {
      return 'ToolTip';
    };
    function ToolTip(content, options) {
      var _this;
      if (options === void 0) {
        options = {};
      }
      _this = _UIComponent.call(this, options) || this;
      _this._content = content;
      return _this;
    }
    _proto.addTo = function addTo(owner) {
      if (ToolTip.isSupport(owner)) {
        owner.on('mousemove', this.onMouseMove, this);
        owner.on('mouseout', this.onMouseOut, this);
        owner.on(HIDEDOMEVENTS, this.hideDom, this);
        return _UIComponent.prototype.addTo.call(this, owner);
      } else {
        throw new Error('Invalid geometry or UIMarker the tooltip is added to.');
      }
    };
    _proto.setStyle = function setStyle$$1(cssName) {
      this.options.containerClass = cssName;
      return this;
    };
    _proto.getStyle = function getStyle() {
      return this.options.containerClass;
    };
    _proto.getContent = function getContent() {
      return this._content;
    };
    _proto.buildOn = function buildOn() {
      var dom = createEl('div');
      var options = this.options || {};
      if (options.height) {
        dom.style.height = options.height + 'px';
      }
      if (options.width) {
        dom.style.width = options.width + 'px';
      }
      var cssName = options.containerClass || options.cssName;
      if (!cssName && options.height) {
        dom.style.lineHeight = options.height + 'px';
      }
      if (isFunction(this._content)) {
        this._content.bind(this)(dom);
      } else {
        dom.innerHTML = "<div class=\"" + cssName + "\">" + this._content + "</div>";
      }
      return dom;
    };
    _proto.onMouseOut = function onMouseOut() {
      clearTimeout(this._timeout);
      if (this.isVisible()) {
        this._removePrevDOM();
      }
      this._switchMapEvents('off');
    };
    _proto.onMouseMove = function onMouseMove(e) {
      var _this2 = this;
      clearTimeout(this._timeout);
      var map = this.getMap();
      if (!map) {
        return;
      }
      var coord = map.locateByPoint(e.coordinate, -5, 25);
      if (this.options['showTimeout'] === 0) {
        this.show(coord);
      } else {
        this._timeout = setTimeout(function () {
          if (map) {
            _this2.show(coord);
          }
        }, this.options['showTimeout']);
      }
    };
    _proto.onRemove = function onRemove() {
      clearTimeout(this._timeout);
      if (this._owner) {
        this._owner.off('mouseover', this.onMouseOver, this);
        this._owner.off('mouseout', this.onMouseOut, this);
        this._owner.off(HIDEDOMEVENTS, this.hideDom, this);
      }
    };
    _proto.hideDom = function hideDom() {
      return this.hide();
    };
    _proto.onEvent = function onEvent() {
      _UIComponent.prototype.onEvent.call(this);
      this.hideDom();
      return this;
    };
    _proto._getViewPoint = function _getViewPoint() {
      return this.getMap().coordToViewPoint(this._coordinate, undefined, 0)._add(this.options['dx'], this.options['dy']);
    };
    return ToolTip;
  }(UIComponent);
  ToolTip.mergeOptions(options$m);

  var defaultOptions = {
    'containerClass': 'maptalks-menu',
    'animation': null,
    'animationDelay': 10,
    'animationOnHide': false,
    'autoPan': false,
    'width': 160,
    'maxHeight': 0,
    'custom': false,
    'items': []
  };
  var Menu = function (_UIComponent) {
    _inheritsLoose(Menu, _UIComponent);
    function Menu(options) {
      return _UIComponent.call(this, options) || this;
    }
    var _proto = Menu.prototype;
    _proto._getClassName = function _getClassName() {
      return 'Menu';
    };
    _proto.addTo = function addTo(owner) {
      if (owner._menu && owner._menu !== this) {
        owner.removeMenu();
      }
      owner._menu = this;
      this._owner = owner;
      return UIComponent.prototype.addTo.apply(this, arguments);
    };
    _proto.setItems = function setItems(items) {
      this.options['items'] = items;
      return this;
    };
    _proto.getItems = function getItems() {
      return this.options['items'] || [];
    };
    _proto.buildOn = function buildOn() {
      if (this.options['custom']) {
        if (isString(this.options['items'])) {
          var container = createEl('div');
          container.innerHTML = this.options['items'];
          return container;
        } else {
          return this.options['items'];
        }
      } else {
        var dom = createEl('div');
        if (this.options['containerClass']) {
          addClass(dom, this.options['containerClass']);
        }
        dom.style.width = this._getMenuWidth() + 'px';
        var menuItems = this._createMenuItemDom();
        dom.appendChild(menuItems);
        on(dom, 'contextmenu', preventDefault);
        return dom;
      }
    };
    _proto.getOffset = function getOffset() {
      if (!this.getMap()) {
        return null;
      }
      var mapSize = this.getMap().getSize(),
        p = this.getMap().viewPointToContainerPoint(this._getViewPoint()),
        size = this.getSize();
      var dx = 0,
        dy = 0;
      if (p.x + size['width'] > mapSize['width']) {
        dx = -size['width'];
      }
      if (p.y + size['height'] > mapSize['height']) {
        dy = -size['height'];
      }
      return new Point(dx, dy);
    };
    _proto.getTransformOrigin = function getTransformOrigin() {
      var p = this.getOffset()._multi(-1);
      return p.x + 'px ' + p.y + 'px';
    };
    _proto.getEvents = function getEvents() {
      return {
        '_zoomstart _zoomend _movestart _dblclick _click': this._removePrevDOM
      };
    };
    _proto._createMenuItemDom = function _createMenuItemDom() {
      var me = this;
      var map = this.getMap();
      var ul = createEl('ul');
      addClass(ul, 'maptalks-menu-items');
      var items = this.getItems();
      function onMenuClick(index) {
        return function (e) {
          var param = map._parseEvent(e, 'click');
          param['target'] = me;
          param['owner'] = me._owner;
          param['index'] = index;
          var result = this._callback(param);
          if (result === false) {
            return;
          }
          me.hide();
          if (me._owner) {
            me._owner.fire('closemenu');
          }
        };
      }
      var item, itemDOM;
      for (var i = 0, len = items.length; i < len; i++) {
        item = items[i];
        if (item === '-' || item === '_') {
          itemDOM = createEl('li');
          addClass(itemDOM, 'maptalks-menu-splitter');
        } else {
          itemDOM = createEl('li');
          var itemTitle = item['item'];
          if (isFunction(itemTitle)) {
            itemTitle = itemTitle({
              'owner': this._owner,
              'index': i
            });
          }
          itemDOM.innerHTML = itemTitle;
          itemDOM._callback = item['click'];
          on(itemDOM, 'click', onMenuClick(i));
        }
        ul.appendChild(itemDOM);
      }
      var maxHeight = this.options['maxHeight'] || 0;
      if (maxHeight > 0) {
        setStyle(ul, 'max-height: ' + maxHeight + 'px; overflow-y: auto;');
      }
      return ul;
    };
    _proto._getMenuWidth = function _getMenuWidth() {
      var defaultWidth = 160;
      var width = this.options['width'] || defaultWidth;
      return width;
    };
    return Menu;
  }(UIComponent);
  Menu.mergeOptions(defaultOptions);

  var Menuable = {
    setMenu: function setMenu(options) {
      this._menuOptions = options;
      if (this._menu) {
        this._menu.setOptions(options);
      } else {
        this.on('contextmenu', this._defaultOpenMenu, this);
      }
      return this;
    },
    getMenu: function getMenu() {
      return this._menu;
    },
    openMenu: function openMenu(coordinate) {
      var map = this instanceof Map$1 ? this : this.getMap();
      if (!coordinate) {
        coordinate = this.getCenter();
      }
      if (!this._menu) {
        if (this._menuOptions && map) {
          this._bindMenu();
          this._menu.show(coordinate);
        }
      } else {
        this._menu.show(coordinate);
      }
      this.fire('openmenu', {
        coordinate: coordinate
      });
      return this;
    },
    setMenuItems: function setMenuItems(items) {
      if (!this._menuOptions) {
        this._menuOptions = {};
      }
      if (Array.isArray(items)) {
        this._menuOptions['custom'] = false;
      }
      this._menuOptions['items'] = items;
      this.setMenu(this._menuOptions);
      return this;
    },
    getMenuItems: function getMenuItems() {
      if (this._menu) {
        return this._menu.getItems();
      } else if (this._menuOptions) {
        return this._menuOptions['items'] || [];
      }
      return [];
    },
    closeMenu: function closeMenu() {
      if (this._menu) {
        this._menu.hide();
      }
      this.fire('closemenu', {});
      return this;
    },
    removeMenu: function removeMenu() {
      this.off('contextmenu', this._defaultOpenMenu, this);
      this._unbindMenu();
      delete this._menuOptions;
      this.fire('removemenu', {});
      return this;
    },
    _bindMenu: function _bindMenu() {
      if (!this._menuOptions) {
        return this;
      }
      this._menu = new Menu(this._menuOptions);
      this._menu.addTo(this);
      return this;
    },
    _unbindMenu: function _unbindMenu() {
      if (this._menu) {
        this.closeMenu();
        this._menu.remove();
        delete this._menu;
      }
      return this;
    },
    _defaultOpenMenu: function _defaultOpenMenu(param) {
      this.openMenu(param['coordinate']);
      return false;
    }
  };
  Map$1.include(Menuable);
  Geometry.include(Menuable);



  var index$4 = /*#__PURE__*/Object.freeze({
    UIComponent: UIComponent,
    UIMarker: UIMarker,
    InfoWindow: InfoWindow,
    ToolTip: ToolTip,
    Menuable: Menuable,
    Menu: Menu
  });

  var Control = function (_Eventable) {
    _inheritsLoose(Control, _Eventable);
    function Control(options) {
      if (options && options['position'] && !isString(options['position'])) {
        options['position'] = extend({}, options['position']);
      }
      return _Eventable.call(this, options) || this;
    }
    var _proto = Control.prototype;
    _proto.addTo = function addTo(map) {
      this.remove();
      if (!map.options['control']) {
        return this;
      }
      this._map = map;
      var controlContainer = map._panels.control;
      this.__ctrlContainer = createEl('div');
      setStyle(this.__ctrlContainer, 'position:absolute;overflow:visible;');
      this.update();
      controlContainer.appendChild(this.__ctrlContainer);
      if (this.onAdd) {
        this.onAdd();
      }
      this.fire('add', {
        'dom': controlContainer
      });
      return this;
    };
    _proto.update = function update() {
      this.__ctrlContainer.innerHTML = '';
      this._controlDom = this.buildOn(this.getMap());
      if (this._controlDom) {
        this._updatePosition();
        this.__ctrlContainer.appendChild(this._controlDom);
      }
      return this;
    };
    _proto.getMap = function getMap() {
      return this._map;
    };
    _proto.getPosition = function getPosition() {
      return extend({}, this._parse(this.options['position']));
    };
    _proto.setPosition = function setPosition(position) {
      if (isString(position)) {
        this.options['position'] = position;
      } else {
        this.options['position'] = extend({}, position);
      }
      this._updatePosition();
      return this;
    };
    _proto.getContainerPoint = function getContainerPoint() {
      var position = this.getPosition();
      var size = this.getMap().getSize();
      var x, y;
      if (!isNil(position['left'])) {
        x = parseInt(position['left']);
      } else if (!isNil(position['right'])) {
        x = size['width'] - parseInt(position['right']);
      }
      if (!isNil(position['top'])) {
        y = parseInt(position['top']);
      } else if (!isNil(position['bottom'])) {
        y = size['height'] - parseInt(position['bottom']);
      }
      return new Point(x, y);
    };
    _proto.getContainer = function getContainer() {
      return this.__ctrlContainer;
    };
    _proto.getDOM = function getDOM() {
      return this._controlDom;
    };
    _proto.show = function show() {
      this.__ctrlContainer.style.display = '';
      return this;
    };
    _proto.hide = function hide() {
      this.__ctrlContainer.style.display = 'none';
      return this;
    };
    _proto.isVisible = function isVisible() {
      return this.__ctrlContainer && this.__ctrlContainer.style.display === '';
    };
    _proto.remove = function remove() {
      if (!this._map) {
        return this;
      }
      removeDomNode(this.__ctrlContainer);
      if (this.onRemove) {
        this.onRemove();
      }
      delete this._map;
      delete this.__ctrlContainer;
      delete this._controlDom;
      this.fire('remove');
      return this;
    };
    _proto._parse = function _parse(position) {
      var p = position;
      if (isString(position)) {
        p = Control['positions'][p];
      }
      return p;
    };
    _proto._updatePosition = function _updatePosition() {
      var position = this.getPosition();
      if (!position) {
        position = {
          'top': 20,
          'left': 20
        };
      }
      for (var p in position) {
        if (position.hasOwnProperty(p)) {
          position[p] = parseInt(position[p]);
          this.__ctrlContainer.style[p] = position[p] + 'px';
        }
      }
      this.fire('positionchange', {
        'position': extend({}, position)
      });
    };
    return Control;
  }(Eventable(Class));
  Control.positions = {
    'top-left': {
      'top': 20,
      'left': 20
    },
    'top-right': {
      'top': 20,
      'right': 20
    },
    'bottom-left': {
      'bottom': 20,
      'left': 20
    },
    'bottom-right': {
      'bottom': 20,
      'right': 20
    }
  };
  Map$1.mergeOptions({
    'control': true
  });
  Map$1.include({
    addControl: function addControl(control) {
      if (this._containerDOM.getContext) {
        return this;
      }
      control.addTo(this);
      return this;
    },
    removeControl: function removeControl(control) {
      if (!control || control.getMap() !== this) {
        return this;
      }
      control.remove();
      return this;
    }
  });

  var options$n = {
    'position': {
      'bottom': 0,
      'left': 0
    },
    'content': '<a href="http://maptalks.org" target="_blank">maptalks</a>'
  };
  var layerEvents = 'addlayer removelayer setbaselayer baselayerremove';
  var Attribution = function (_Control) {
    _inheritsLoose(Attribution, _Control);
    function Attribution() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Attribution.prototype;
    _proto.buildOn = function buildOn() {
      this._attributionContainer = createEl('div');
      this._attributionContainer.className = 'maptalks-attribution';
      this._update();
      return this._attributionContainer;
    };
    _proto.onAdd = function onAdd() {
      this.getMap().on(layerEvents, this._update, this);
    };
    _proto.onRemove = function onRemove() {
      this.getMap().off(layerEvents, this._update, this);
    };
    _proto._update = function _update() {
      var map = this.getMap();
      if (!map) {
        return;
      }
      var attributions = map._getLayers(function (layer) {
        return layer.options['attribution'];
      }).reverse().map(function (layer) {
        return layer.options['attribution'];
      });
      var content = this.options['content'] + (attributions.length > 0 ? ' - ' + attributions.join(', ') : '');
      this._attributionContainer.innerHTML = '<span style="padding:0px 4px">' + content + '</span>';
    };
    return Attribution;
  }(Control);
  Attribution.mergeOptions(options$n);
  Map$1.mergeOptions({
    'attribution': true
  });
  Map$1.addOnLoadHook(function () {
    var a = this.options['attribution'] || this.options['attributionControl'];
    if (a) {
      this.attributionControl = new Attribution(a);
      this.addControl(this.attributionControl);
    }
  });

  var options$o = {
    position: {
      'top': 120,
      'left': 20
    }
  };
  var Compass = function (_Control) {
    _inheritsLoose(Compass, _Control);
    function Compass() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Compass.prototype;
    _proto.buildOn = function buildOn(map) {
      var compass = this._getCompass();
      this._compass = compass;
      this._registerDomEvents();
      map.on('resize moving moveend zooming zoomend rotate rotateend dragrotating dragrotateend viewchange', this._rotateCompass, this);
      return compass;
    };
    _proto.onAdd = function onAdd() {
      this._rotateCompass();
    };
    _proto._getCompass = function _getCompass() {
      var compass = createEl('div', 'maptalks-compass');
      return compass;
    };
    _proto._registerDomEvents = function _registerDomEvents() {
      on(this._compass, 'click', this._resetView, this);
    };
    _proto._rotateCompass = function _rotateCompass() {
      var bearing = this.getMap().getBearing().toFixed(1);
      if (bearing <= 180) bearing *= -1;
      if (bearing !== this._bearing) {
        this._bearing = bearing;
        setStyle(this._compass, "transform: rotate(" + this._bearing + "deg);");
      }
    };
    _proto.onRemove = function onRemove() {
      this.getMap().off('resize moving moveend zooming zoomend rotate rotateend dragrotating dragrotateend viewchange', this._rotateCompass, this);
      delete this._compass;
      delete this._bearing;
    };
    _proto._resetView = function _resetView() {
      var view = {
        bearing: 0
      };
      this.getMap().animateTo(view);
    };
    return Compass;
  }(Control);
  Compass.mergeOptions(options$o);
  Map$1.mergeOptions({
    'compassControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['compassControl']) {
      this.compassControl = new Compass(this.options['compassControl']);
      this.addControl(this.compassControl);
    }
  });

  var options$p = {
    'position': 'top-right',
    'baseTitle': 'Base Layers',
    'overlayTitle': 'Layers',
    'excludeLayers': [],
    'containerClass': 'maptalks-layer-switcher'
  };
  var LayerSwitcher = function (_Control) {
    _inheritsLoose(LayerSwitcher, _Control);
    function LayerSwitcher() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = LayerSwitcher.prototype;
    _proto.buildOn = function buildOn() {
      var container = this.container = createEl('div', this.options['containerClass']),
        panel = this.panel = createEl('div', 'panel'),
        button = this.button = createEl('button');
      container.appendChild(button);
      container.appendChild(panel);
      return container;
    };
    _proto.onAdd = function onAdd() {
      on(this.button, 'mouseover', this._show, this);
      on(this.panel, 'mouseleave', this._hide, this);
      on(this.getMap(), 'click', this._hide, this);
    };
    _proto.onRemove = function onRemove() {
      if (this.panel) {
        off(this.button, 'mouseover', this._show, this);
        off(this.panel, 'mouseleave', this._hide, this);
        off(this.getMap(), 'click', this._hide, this);
        removeDomNode(this.panel);
        removeDomNode(this.button);
        delete this.panel;
        delete this.button;
        delete this.container;
      }
    };
    _proto._show = function _show() {
      if (!hasClass(this.container, 'shown')) {
        addClass(this.container, 'shown');
        this._createPanel();
      }
    };
    _proto._hide = function _hide(e) {
      if (!this.panel.contains(e.toElement || e.relatedTarget)) {
        setClass(this.container, this.options['containerClass']);
      }
    };
    _proto._createPanel = function _createPanel() {
      this.panel.innerHTML = '';
      var ul = createEl('ul');
      this.panel.appendChild(ul);
      this._renderLayers(this.getMap(), ul);
    };
    _proto._renderLayers = function _renderLayers(map, elm) {
      var _this = this;
      var base = map.getBaseLayer(),
        layers = map.getLayers(),
        len = layers.length;
      if (base) {
        var baseLayers = base.layers || [base],
          li = createEl('li', 'group'),
          ul = createEl('ul'),
          label = createEl('label');
        label.innerHTML = this.options['baseTitle'];
        li.appendChild(label);
        for (var i = 0, _len = baseLayers.length; i < _len; i++) {
          var layer = baseLayers[i];
          if (this._isExcluded(layer)) {
            ul.appendChild(this._renderLayer(baseLayers[i], true));
            li.appendChild(ul);
            elm.appendChild(li);
          }
        }
      }
      if (len) {
        var _li = createEl('li', 'group'),
          _ul = createEl('ul'),
          _label = createEl('label'),
          input = createEl('input');
        input.type = 'checkbox';
        input.checked = true;
        _label.innerHTML = this.options['overlayTitle'];
        _li.appendChild(input);
        _li.appendChild(_label);
        var groupInputOnChange = function groupInputOnChange(e) {
          var checked = e.target.checked;
          var parentNode = e.target.parentNode;
          if (!parentNode) {
            return;
          }
          var ul = parentNode.getElementsByTagName('ul')[0];
          if (!ul) {
            return;
          }
          var parentLayerShow = function parentLayerShow(node) {
            var layer = node._layer;
            if (layer) {
              layer[checked ? 'show' : 'hide']();
            }
          };
          var layerShow = function layerShow(li) {
            var layer = li._layer,
              checkbox = li.childNodes[0];
            if (checkbox) {
              checkbox.checked = checked;
            }
            if (layer) {
              layer[checked ? 'show' : 'hide']();
            }
          };
          parentLayerShow(parentNode);
          ul.childNodes.forEach(function (li) {
            layerShow(li);
            var childUl = li.getElementsByTagName('ul')[0];
            if (!childUl) {
              return;
            }
            parentLayerShow(li);
            childUl.childNodes.forEach(function (li) {
              layerShow(li);
            });
          });
        };
        for (var _i = 0; _i < len; _i++) {
          var _layer = layers[_i];
          if (this._isExcluded(_layer)) {
            if (_layer.getLayers) {
              (function () {
                var groupLi = createEl('li', 'group'),
                  groupUl = createEl('ul'),
                  groupLabel = createEl('label'),
                  groupInput = createEl('input');
                groupLabel.innerHTML = _layer.getId();
                groupInput.type = 'checkbox';
                groupInput.checked = _layer.isVisible();
                groupInput.onchange = groupInputOnChange;
                groupLi.appendChild(groupInput);
                groupLi.appendChild(groupLabel);
                groupLi.appendChild(groupUl);
                groupLi._layer = _layer;
                _ul.appendChild(groupLi);
                var groupLayers = _layer.getLayers() || [];
                groupLayers.forEach(function (layer) {
                  groupUl.appendChild(_this._renderLayer(layer, false, groupInput.checked));
                });
              })();
            } else {
              _ul.appendChild(this._renderLayer(_layer));
            }
            if (_layer && !_layer.isVisible()) {
              input.checked = false;
            }
          }
        }
        _li.appendChild(_ul);
        elm.appendChild(_li);
        input.onchange = groupInputOnChange;
      }
    };
    _proto._isExcluded = function _isExcluded(layer) {
      var id = layer.getId(),
        excludeLayers = this.options['excludeLayers'];
      return !(excludeLayers.length && excludeLayers.indexOf(id) >= 0);
    };
    _proto._renderLayer = function _renderLayer(layer, isBase, parentChecked) {
      var _this2 = this;
      if (parentChecked === void 0) {
        parentChecked = true;
      }
      var li = createEl('li', 'layer'),
        label = createEl('label'),
        input = createEl('input'),
        map = this.getMap();
      var visible = layer.options['visible'];
      layer.options['visible'] = true;
      var enabled = layer.isVisible();
      layer.options['visible'] = visible;
      li.className = 'layer';
      if (isBase) {
        input.type = 'radio';
        input.name = 'base';
      } else {
        input.type = 'checkbox';
      }
      input.checked = visible && enabled;
      if (!parentChecked) {
        input.checked = false;
      }
      if (!enabled) {
        input.setAttribute('disabled', 'disabled');
      }
      input.onchange = function (e) {
        if (e.target.type === 'radio') {
          var baseLayer = map.getBaseLayer(),
            baseLayers = baseLayer.layers;
          if (baseLayers) {
            for (var i = 0, len = baseLayers.length; i < len; i++) {
              var _baseLayer = baseLayers[i];
              _baseLayer[_baseLayer === layer ? 'show' : 'hide']();
            }
          } else if (!baseLayer.isVisible()) {
            baseLayer.show();
          }
          map._fireEvent('setbaselayer');
        } else {
          layer[e.target.checked ? 'show' : 'hide']();
        }
        _this2.fire('layerchange', {
          target: layer
        });
      };
      li.appendChild(input);
      label.innerHTML = layer.getId();
      li.appendChild(label);
      li._layer = layer;
      return li;
    };
    return LayerSwitcher;
  }(Control);
  LayerSwitcher.mergeOptions(options$p);
  Map$1.mergeOptions({
    'layerSwitcherControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['layerSwitcherControl']) {
      this.layerSwitcherControl = new LayerSwitcher(this.options['layerSwitcherControl']);
      this.addControl(this.layerSwitcherControl);
    }
  });

  var options$q = {
    'level': 4,
    'position': {
      'right': 1,
      'bottom': 1
    },
    'size': [300, 200],
    'maximize': true,
    'symbol': {
      'lineWidth': 3,
      'lineColor': '#1bbc9b',
      'polygonFill': '#1bbc9b',
      'polygonOpacity': 0.4
    },
    'containerClass': 'maptalks-overview',
    'buttonClass': 'maptalks-overview-button'
  };
  var Overview = function (_Control) {
    _inheritsLoose(Overview, _Control);
    function Overview() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Overview.prototype;
    _proto.buildOn = function buildOn() {
      var size = this.options['size'];
      if (!this.options['maximize']) {
        size = [0, 0];
      }
      var container = createEl('div');
      var mapContainer = this.mapContainer = createEl('div');
      mapContainer.style.width = size[0] + 'px';
      mapContainer.style.height = size[1] + 'px';
      mapContainer.className = this.options['containerClass'];
      var button = this.button = createEl('div');
      button.className = this.options['buttonClass'];
      container.appendChild(mapContainer);
      container.appendChild(button);
      return container;
    };
    _proto.onAdd = function onAdd() {
      if (this.options['maximize']) {
        this._createOverview();
      }
      this.getMap().on('resize moving zooming rotate dragrotating viewchange', this._update, this).on('setbaselayer', this._updateBaseLayer, this).on('spatialreferencechange', this._updateSpatialReference, this);
      on(this.button, 'click', this._onButtonClick, this);
      this._updateButtonText();
    };
    _proto.onRemove = function onRemove() {
      this.getMap().off('resize moving zooming rotate dragrotating viewchange', this._update, this).off('setbaselayer', this._updateBaseLayer, this).off('spatialreferencechange', this._updateSpatialReference, this);
      if (this._overview) {
        this._overview.remove();
        delete this._overview;
        delete this._perspective;
      }
      off(this.button, 'click', this._onButtonClick, this);
    };
    _proto.maxmize = function maxmize() {
      var size = this.options['size'];
      var dom = this.mapContainer;
      dom.style.width = size[0] + 'px';
      dom.style.height = size[1] + 'px';
      this._createOverview();
      return this;
    };
    _proto.minimize = function minimize() {
      if (this._overview) {
        this._overview.remove();
      }
      delete this._overview;
      delete this._perspective;
      var dom = this.mapContainer;
      dom.style.width = 0 + 'px';
      dom.style.height = 0 + 'px';
      return this;
    };
    _proto.getOverviewMap = function getOverviewMap() {
      return this._overview;
    };
    _proto._onButtonClick = function _onButtonClick() {
      if (!this._overview) {
        this.maxmize();
      } else {
        this.minimize();
      }
      this._updateButtonText();
    };
    _proto._updateButtonText = function _updateButtonText() {
      if (this._overview) {
        this.button.innerHTML = '-';
      } else {
        this.button.innerHTML = '+';
      }
    };
    _proto._createOverview = function _createOverview() {
      var map = this.getMap(),
        dom = this.mapContainer;
      var options = map.config();
      extend(options, {
        'center': map.getCenter(),
        'zoom': this._getOverviewZoom(),
        'zoomAnimationDuration': 150,
        'pitch': 0,
        'bearing': 0,
        'scrollWheelZoom': false,
        'checkSize': false,
        'doubleClickZoom': false,
        'touchZoom': false,
        'control': false,
        'draggable': false,
        'maxExtent': null
      });
      this._overview = new Map$1(dom, options);
      this._updateBaseLayer();
      this._perspective = new Polygon(this._getPerspectiveCoords(), {
        'draggable': true,
        'cursor': 'move',
        'symbol': this.options['symbol']
      }).on('dragend', this._onDragEnd, this);
      new VectorLayer('perspective_layer', this._perspective).addTo(this._overview);
      this.fire('load');
    };
    _proto._getOverviewZoom = function _getOverviewZoom() {
      var map = this.getMap(),
        zoom = map.getZoom(),
        minZoom = map.getMinZoom(),
        level = this.options['level'];
      if (level > 0) {
        for (var i = level; i > 0; i--) {
          if (zoom - i >= minZoom) {
            return zoom - i;
          }
        }
      } else {
        for (var _i = level; _i < 0; _i++) {
          if (zoom - _i >= minZoom) {
            return zoom - _i;
          }
        }
      }
      return zoom;
    };
    _proto._onDragEnd = function _onDragEnd() {
      var center = this._perspective.getCenter();
      this._overview.setCenter(center);
      this.getMap().panTo(center);
    };
    _proto._getPerspectiveCoords = function _getPerspectiveCoords() {
      var map = this.getMap();
      var projection = map.getProjection();
      return map.getContainerExtent().toArray().map(function (c) {
        if (projection) {
          var prjCoord = map._containerPointToPrj(c);
          map._fixPrjOnWorldWide(prjCoord);
          return projection.unproject(prjCoord);
        }
        return map.containerPointToCoordinate(c);
      });
    };
    _proto._update = function _update() {
      if (!this._overview) {
        return;
      }
      computeDomPosition(this._overview._containerDOM);
      var coords = this._getPerspectiveCoords();
      this._perspective.setCoordinates(coords);
      this._overview.setCenterAndZoom(this.getMap().getCenter(), this._getOverviewZoom());
    };
    _proto._updateSpatialReference = function _updateSpatialReference() {
      if (!this._overview) {
        return;
      }
      var map = this.getMap();
      var spatialRef = map.options['spatialReference'];
      this._overview.setSpatialReference(spatialRef);
    };
    _proto._updateBaseLayer = function _updateBaseLayer() {
      if (!this._overview) {
        return;
      }
      var map = this.getMap(),
        baseLayer = map.getBaseLayer();
      if (!baseLayer) {
        this._overview.setBaseLayer(null);
        return;
      }
      var layers = baseLayer.layers;
      var showIndex = 0;
      if (layers) {
        for (var i = 0, l = layers.length; i < l; i++) {
          var _layer = layers[i];
          if (_layer.isVisible()) {
            showIndex = i;
            break;
          }
        }
      }
      var json = baseLayer.toJSON();
      var options = null;
      if (layers) {
        options = json.layers[showIndex].options;
        options.visible = true;
      } else {
        options = json.options;
      }
      this._overview.setMinZoom(options.minZoom || null).setMaxZoom(options.maxZoom || null);
      delete options.minZoom;
      delete options.maxZoom;
      delete json.options.canvas;
      json.options.visible = true;
      json.options.renderer = 'canvas';
      var layer = Layer.fromJSON(json);
      for (var p in baseLayer) {
        if (isFunction(baseLayer[p]) && baseLayer.hasOwnProperty(p) && baseLayer[p] !== baseLayer.constructor.prototype[p]) {
          layer[p] = baseLayer[p];
        }
      }
      this._overview.setBaseLayer(layer);
    };
    return Overview;
  }(Control);
  Overview.mergeOptions(options$q);
  Map$1.mergeOptions({
    'overviewControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['overviewControl']) {
      this.overviewControl = new Overview(this.options['overviewControl']);
      this.addControl(this.overviewControl);
    }
  });

  var options$r = {
    'position': 'top-right',
    'draggable': true,
    'custom': false,
    'content': '',
    'closeButton': true
  };
  var Panel = function (_Control) {
    _inheritsLoose(Panel, _Control);
    function Panel() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Panel.prototype;
    _proto.buildOn = function buildOn() {
      var dom;
      if (this.options['custom']) {
        if (isString(this.options['content'])) {
          dom = createEl('div');
          dom.innerHTML = this.options['content'];
        } else {
          dom = this.options['content'];
        }
      } else {
        dom = createEl('div', 'maptalks-panel');
        if (this.options['closeButton']) {
          var closeButton = createEl('a', 'maptalks-close');
          closeButton.innerText = 'Ã—';
          closeButton.href = 'javascript:;';
          closeButton.onclick = function () {
            dom.style.display = 'none';
          };
          dom.appendChild(closeButton);
        }
        var panelContent = createEl('div', 'maptalks-panel-content');
        panelContent.innerHTML = this.options['content'];
        dom.appendChild(panelContent);
      }
      this.draggable = new DragHandler(dom, {
        'cancelOn': this._cancelOn.bind(this),
        'ignoreMouseleave': true
      });
      this.draggable.on('dragstart', this._onDragStart, this).on('dragging', this._onDragging, this).on('dragend', this._onDragEnd, this);
      if (this.options['draggable']) {
        this.draggable.enable();
      }
      return dom;
    };
    _proto.update = function update() {
      if (this.draggable) {
        this.draggable.disable();
        delete this.draggable;
      }
      return Control.prototype.update.call(this);
    };
    _proto.setContent = function setContent(content) {
      var old = this.options['content'];
      this.options['content'] = content;
      this.fire('contentchange', {
        'old': old,
        'new': content
      });
      if (this.isVisible()) {
        this.update();
      }
      return this;
    };
    _proto.getContent = function getContent() {
      return this.options['content'];
    };
    _proto._cancelOn = function _cancelOn(domEvent) {
      var target = domEvent.srcElement || domEvent.target,
        tagName = target.tagName.toLowerCase();
      if (tagName === 'button' || tagName === 'input' || tagName === 'select' || tagName === 'option' || tagName === 'textarea') {
        return true;
      }
      return false;
    };
    _proto._onDragStart = function _onDragStart(param) {
      this._startPos = param['mousePos'];
      this._startPosition = extend({}, this.getPosition());
      this.fire('dragstart', param);
    };
    _proto._onDragging = function _onDragging(param) {
      var pos = param['mousePos'];
      var offset = pos.sub(this._startPos);
      var startPosition = this._startPosition;
      var position = this.getPosition();
      if (!isNil(position['top'])) {
        position['top'] = parseInt(startPosition['top']) + offset.y;
      }
      if (!isNil(position['bottom'])) {
        position['bottom'] = parseInt(startPosition['bottom']) - offset.y;
      }
      if (!isNil(position['left'])) {
        position['left'] = parseInt(startPosition['left']) + offset.x;
      }
      if (!isNil(position['right'])) {
        position['right'] = parseInt(startPosition['right']) - offset.x;
      }
      this.setPosition(position);
      this.fire('dragging', param);
    };
    _proto._onDragEnd = function _onDragEnd(param) {
      delete this._startPos;
      delete this._startPosition;
      this.fire('dragend', param);
    };
    _proto._getConnectPoints = function _getConnectPoints() {
      var map = this.getMap();
      var containerPoint = this.getContainerPoint();
      var dom = this.getDOM(),
        width = parseInt(dom.clientWidth),
        height = parseInt(dom.clientHeight);
      var anchors = [map.containerPointToCoordinate(containerPoint.add(width / 2, 0)), map.containerPointToCoordinate(containerPoint.add(width, height / 2)), map.containerPointToCoordinate(containerPoint.add(width / 2, height)), map.containerPointToCoordinate(containerPoint.add(0, height / 2))];
      return anchors;
    };
    return Panel;
  }(Control);
  Panel.mergeOptions(options$r);

  var options$s = {
    position: {
      'top': 156,
      'left': 20
    },
    view: null
  };
  var Reset = function (_Control) {
    _inheritsLoose(Reset, _Control);
    function Reset() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Reset.prototype;
    _proto.buildOn = function buildOn() {
      var reset = this._getReset();
      this._reset = reset;
      this._registerDomEvents();
      return reset;
    };
    _proto.onAdd = function onAdd() {
      this._view = !this.options.view ? this.getMap().getView() : this.options.view;
    };
    _proto.setView = function setView(view) {
      this._view = view;
    };
    _proto._getReset = function _getReset() {
      var reset = createEl('div', 'maptalks-reset');
      return reset;
    };
    _proto._registerDomEvents = function _registerDomEvents() {
      on(this._reset, 'click', this._resetView, this);
    };
    _proto.onRemove = function onRemove() {
      delete this._reset;
      delete this._view;
    };
    _proto._resetView = function _resetView() {
      this.getMap().setView(this._view);
    };
    return Reset;
  }(Control);
  Reset.mergeOptions(options$s);
  Map$1.mergeOptions({
    'resetControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['resetControl']) {
      this.resetControl = new Reset(this.options['resetControl']);
      this.addControl(this.resetControl);
    }
  });

  var options$t = {
    'position': 'bottom-left',
    'maxWidth': 100,
    'metric': true,
    'imperial': false,
    'containerClass': null
  };
  var EVENTS_TO_LISTEN = 'zoomend moving moveend';
  var Scale = function (_Control) {
    _inheritsLoose(Scale, _Control);
    function Scale() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Scale.prototype;
    _proto.buildOn = function buildOn(map) {
      this._map = map;
      this._scaleContainer = createEl('div', this.options['containerClass']);
      this._addScales();
      map.on(EVENTS_TO_LISTEN, this._update, this);
      if (this._map._loaded) {
        this._update();
      }
      return this._scaleContainer;
    };
    _proto.onRemove = function onRemove() {
      this.getMap().off(EVENTS_TO_LISTEN, this._update, this);
    };
    _proto._addScales = function _addScales() {
      var css = 'border: 2px solid #000000;border-top: none;line-height: 1.1;padding: 0px;' + 'color: #000000;font-size: 11px;text-align:center;white-space: nowrap;overflow: hidden' + ';-moz-box-sizing: content-box;box-sizing: content-box;background: #fff; background: rgba(255, 255, 255, 0);';
      if (this.options['metric']) {
        this._mScale = createElOn('div', this.options['containerClass'] ? null : css, this._scaleContainer);
      }
      if (this.options['imperial']) {
        this._iScale = createElOn('div', this.options['containerClass'] ? null : css, this._scaleContainer);
      }
    };
    _proto._update = function _update() {
      var map = this._map;
      var maxMeters = map.pixelToDistance(this.options['maxWidth'], 0);
      this._updateScales(maxMeters);
    };
    _proto._updateScales = function _updateScales(maxMeters) {
      if (this.options['metric'] && maxMeters) {
        this._updateMetric(maxMeters);
      }
      if (this.options['imperial'] && maxMeters) {
        this._updateImperial(maxMeters);
      }
    };
    _proto._updateMetric = function _updateMetric(maxMeters) {
      var meters = this._getRoundNum(maxMeters),
        label = meters < 1000 ? meters + ' m' : meters / 1000 + ' km';
      this._updateScale(this._mScale, label, meters / maxMeters);
    };
    _proto._updateImperial = function _updateImperial(maxMeters) {
      var maxFeet = maxMeters * 3.2808399;
      var maxMiles, miles, feet;
      if (maxFeet > 5280) {
        maxMiles = maxFeet / 5280;
        miles = this._getRoundNum(maxMiles);
        this._updateScale(this._iScale, miles + ' mile', miles / maxMiles);
      } else {
        feet = this._getRoundNum(maxFeet);
        this._updateScale(this._iScale, feet + ' feet', feet / maxFeet);
      }
    };
    _proto._updateScale = function _updateScale(scale, text, ratio) {
      scale['style']['width'] = Math.round(this.options['maxWidth'] * ratio) + 'px';
      scale['innerHTML'] = text;
    };
    _proto._getRoundNum = function _getRoundNum(num) {
      var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1);
      var d = num / pow10;
      d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
      return pow10 * d;
    };
    return Scale;
  }(Control);
  Scale.mergeOptions(options$t);
  Map$1.mergeOptions({
    'scaleControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['scaleControl']) {
      this.scaleControl = new Scale(this.options['scaleControl']);
      this.addControl(this.scaleControl);
    }
  });

  var options$u = {
    'height': 28,
    'vertical': false,
    'position': 'top-right',
    'reverseMenu': false,
    'items': {}
  };
  var Toolbar = function (_Control) {
    _inheritsLoose(Toolbar, _Control);
    function Toolbar() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Toolbar.prototype;
    _proto.buildOn = function buildOn(map) {
      this._map = map;
      var dom = createEl('div');
      var ul = createEl('ul', 'maptalks-toolbar-hx');
      dom.appendChild(ul);
      if (this.options['vertical']) {
        addClass(dom, 'maptalks-toolbar-vertical');
      } else {
        addClass(dom, 'maptalks-toolbar-horizonal');
      }
      var me = this;
      function onButtonClick(fn, index, childIndex, targetDom) {
        var item = me._getItems()[index];
        return function (e) {
          stopPropagation(e);
          return fn({
            'target': item,
            'index': index,
            'childIndex': childIndex,
            'dom': targetDom
          });
        };
      }
      var items = this.options['items'];
      if (isArrayHasData(items)) {
        for (var i = 0, len = items.length; i < len; i++) {
          var item = items[i];
          var li = createEl('li');
          if (this.options['height'] !== 28) {
            li.style.lineHeight = this.options['height'] + 'px';
          }
          li.style.height = this.options['height'] + 'px';
          li.style.cursor = 'pointer';
          if (isHTML(item['item'])) {
            li.style.textAlign = 'center';
            var itemSize = measureDom('div', item['item']);
            li.innerHTML = '<div style="margin-top:' + (this.options['height'] - itemSize['height']) / 2 + 'px;">' + item['item'] + '</div>';
          } else {
            li.innerHTML = item['item'];
          }
          if (item['click']) {
            on(li, 'click', onButtonClick(item['click'], i, null, li));
          }
          if (isArrayHasData(item['children'])) {
            var dropMenu = this._createDropMenu(i);
            li.appendChild(dropMenu);
            li._menu = dropMenu;
            on(li, 'mouseover', function () {
              this._menu.style.display = '';
            });
            on(li, 'mouseout', function () {
              this._menu.style.display = 'none';
            });
          }
          ul.appendChild(li);
        }
      }
      return dom;
    };
    _proto._createDropMenu = function _createDropMenu(index) {
      var me = this;
      function onButtonClick(fn, index, childIndex) {
        var item = me._getItems()[index]['children'][childIndex];
        return function (e) {
          stopPropagation(e);
          return fn({
            'target': item,
            'index': index,
            'childIndex': childIndex
          });
        };
      }
      var menuDom = createEl('div', 'maptalks-dropMenu'),
        items = this._getItems(),
        len = items.length,
        menuUL = createEl('ul'),
        children = items[index]['children'];
      if (index === len - 1 && children) {
        menuDom.style.cssText = 'right: 0px;';
        menuUL.style.cssText = 'right: 0px;position: absolute;';
        if (this.options['reverseMenu']) {
          menuUL.style.bottom = 0;
        }
      }
      menuDom.appendChild(createEl('em', 'maptalks-ico'));
      var liWidth = 0;
      for (var i = 0, l = children.length; i < l; i++) {
        var size = stringLength(children[i]['item'], '12px');
        if (size.width > liWidth) {
          liWidth = size.width;
        }
      }
      for (var _i = 0, _l = children.length; _i < _l; _i++) {
        var child = children[_i];
        var li = createEl('li');
        li.innerHTML = '<a href="javascript:;">' + child['item'] + '</a>';
        li.style.cursor = 'pointer';
        li.style.width = liWidth + 24 + 'px';
        on(li.childNodes[0], 'click', onButtonClick(child['click'], index, _i));
        menuUL.appendChild(li);
      }
      if (this.options['vertical']) {
        var width = liWidth < 95 ? 95 : liWidth;
        if (this.options['reverseMenu']) {
          menuDom.style.right = -(width + 10 * 2 + 2) + 'px';
        } else {
          menuDom.style.left = -(width + 10 * 2 + 2) + 'px';
        }
      } else if (this.options['reverseMenu']) {
        menuDom.style.bottom = '28px';
      } else {
        menuDom.style.top = '29px';
      }
      menuDom.appendChild(menuUL);
      menuDom.style.display = 'none';
      return menuDom;
    };
    _proto._getItems = function _getItems() {
      return this.options['items'] || [];
    };
    return Toolbar;
  }(Control);
  Toolbar.mergeOptions(options$u);

  var options$v = {
    'position': 'top-left',
    'zoomLevel': true,
    'seamless': false
  };
  var Zoom = function (_Control) {
    _inheritsLoose(Zoom, _Control);
    function Zoom() {
      return _Control.apply(this, arguments) || this;
    }
    var _proto = Zoom.prototype;
    _proto.buildOn = function buildOn(map) {
      var options = this.options;
      var dom = createEl('div', 'maptalks-zoom');
      if (options['zoomLevel']) {
        var levelWrapper = createEl('span', 'maptalks-zoom-zoomlevel');
        var levelDOM = createEl('span', 'maptalks-zoom-zoomlevel-text');
        levelWrapper.appendChild(levelDOM);
        dom.appendChild(levelWrapper);
        this._levelDOM = levelDOM;
      }
      var zoomDOM = createEl('div', 'maptalks-zoom-slider');
      var zoomInButton = createEl('a', 'maptalks-zoom-zoomin');
      zoomInButton.href = 'javascript:;';
      zoomDOM.appendChild(zoomInButton);
      this._zoomInButton = zoomInButton;
      var zoomOutButton = createEl('a', 'maptalks-zoom-zoomout');
      zoomOutButton.href = 'javascript:;';
      zoomDOM.appendChild(zoomOutButton);
      this._zoomOutButton = zoomOutButton;
      dom.appendChild(zoomDOM);
      map.on('_zoomend _zooming _zoomstart _spatialreferencechange', this._update, this);
      this._update();
      this._registerDomEvents();
      return dom;
    };
    _proto.onRemove = function onRemove() {
      this.getMap().off('_zoomend _zooming _zoomstart _spatialreferencechange', this._update, this);
    };
    _proto._update = function _update() {
      this._updateText();
    };
    _proto._updateText = function _updateText() {
      if (this._levelDOM) {
        var map = this.getMap();
        var zoom = map.getZoom();
        if (!isInteger(zoom)) {
          zoom = Math.floor(zoom * 10) / 10;
        }
        this._levelDOM.innerHTML = zoom;
      }
    };
    _proto._registerDomEvents = function _registerDomEvents() {
      if (this._zoomInButton) {
        on(this._zoomInButton, 'click', this._onZoomInClick, this);
      }
      if (this._zoomOutButton) {
        on(this._zoomOutButton, 'click', this._onZoomOutClick, this);
      }
    };
    _proto._onZoomInClick = function _onZoomInClick(e) {
      preventDefault(e);
      this.getMap().zoomIn();
    };
    _proto._onZoomOutClick = function _onZoomOutClick(e) {
      preventDefault(e);
      this.getMap().zoomOut();
    };
    return Zoom;
  }(Control);
  Zoom.mergeOptions(options$v);
  Map$1.mergeOptions({
    'zoomControl': false
  });
  Map$1.addOnLoadHook(function () {
    if (this.options['zoomControl']) {
      this.zoomControl = new Zoom(this.options['zoomControl']);
      this.addControl(this.zoomControl);
    }
  });



  var index$5 = /*#__PURE__*/Object.freeze({
    Control: Control,
    Attribution: Attribution,
    Compass: Compass,
    LayerSwitcher: LayerSwitcher,
    Overview: Overview,
    Panel: Panel,
    Reset: Reset,
    Scale: Scale,
    Toolbar: Toolbar,
    Zoom: Zoom
  });

  var TileSystem = function () {
    function TileSystem(sx, sy, ox, oy) {
      if (Array.isArray(sx)) {
        this.scale = {
          x: sx[0],
          y: sx[1]
        };
        this.origin = {
          x: sx[2],
          y: sx[3]
        };
      } else {
        this.scale = {
          x: sx,
          y: sy
        };
        this.origin = {
          x: ox,
          y: oy
        };
      }
    }
    TileSystem.getDefault = function getDefault(projection) {
      var code = projection['code'].toLowerCase();
      if (code === 'baidu') {
        return 'baidu';
      } else if (code === 'EPSG:4326'.toLowerCase() || code === 'EPSG:4490'.toLowerCase()) {
        return 'tms-global-geodetic';
      } else if (code === 'identity') {
        return [1, -1, 0, 0];
      } else {
        return 'web-mercator';
      }
    };
    return TileSystem;
  }();
  var semiCircum = 6378137 * Math.PI;
  extend(TileSystem, {
    'web-mercator': new TileSystem([1, -1, -semiCircum, semiCircum]),
    'tms-global-mercator': new TileSystem([1, 1, -semiCircum, -semiCircum]),
    'tms-global-geodetic': new TileSystem([1, 1, -180, -90]),
    'baidu': new TileSystem([1, 1, 0, 0])
  });

  var TileConfig = function () {
    function TileConfig(map, tileSystem, fullExtent, tileSize) {
      this.map = map;
      this.tileSize = tileSize;
      this.fullExtent = fullExtent;
      this.prepareTileInfo(tileSystem, fullExtent);
      this._xScale = fullExtent['right'] >= fullExtent['left'] ? 1 : -1;
      this._yScale = fullExtent['top'] >= fullExtent['bottom'] ? 1 : -1;
      var glRes = map.getGLRes();
      this._pointOrigin = map._prjToPointAtRes(new Point(this.tileSystem['origin']), glRes);
      this._glRes = glRes;
    }
    var _proto = TileConfig.prototype;
    _proto.prepareTileInfo = function prepareTileInfo(tileSystem, fullExtent) {
      if (isString(tileSystem)) {
        tileSystem = TileSystem[tileSystem.toLowerCase()];
      } else if (Array.isArray(tileSystem)) {
        tileSystem = new TileSystem(tileSystem);
      }
      if (!tileSystem) {
        throw new Error('Invalid TileSystem');
      }
      this.tileSystem = tileSystem;
      var a = fullExtent['right'] > fullExtent['left'] ? 1 : -1,
        b = fullExtent['top'] > fullExtent['bottom'] ? -1 : 1,
        c = tileSystem['origin']['x'],
        d = tileSystem['origin']['y'];
      this.transformation = new Transformation([a, b, c, d]);
    };
    _proto._getTileNum = function _getTileNum(point, res) {
      var tileSystem = this.tileSystem,
        tileSize = this['tileSize'],
        delta = 1E-7;
      var tileX = Math.floor(delta * tileSystem['scale']['x'] + point.x / (tileSize['width'] * res));
      var tileY = Math.ceil(delta * tileSystem['scale']['y'] + point.y / (tileSize['height'] * res));
      return {
        'x': tileSystem['scale']['x'] * tileX,
        'y': tileSystem['scale']['y'] * tileY
      };
    };
    _proto.getTileIndex = function getTileIndex(pCoord, res, repeatWorld) {
      var tileSystem = this.tileSystem;
      var point = this.transformation.transform(pCoord, 1);
      var tileIndex = this._getTileNum(point, res);
      if (tileSystem['scale']['x'] < 0) {
        tileIndex['x'] -= 1;
      }
      if (tileSystem['scale']['y'] > 0) {
        tileIndex['y'] -= 1;
      }
      return this.getNeighorTileIndex(tileIndex['x'], tileIndex['y'], 0, 0, res, repeatWorld);
    };
    _proto.getNeighorTileIndex = function getNeighorTileIndex(tileX, tileY, offsetX, offsetY, res, repeatWorld) {
      var tileSystem = this.tileSystem;
      var x = tileX + tileSystem['scale']['x'] * offsetX;
      var y = tileY - tileSystem['scale']['y'] * offsetY;
      var out = false;
      var idx = x;
      var idy = y;
      var ext = this._getTileFullIndex(res);
      if (repeatWorld) {
        if (repeatWorld === true || repeatWorld === 'x') {
          if (ext['xmax'] === ext['xmin']) {
            x = ext['xmin'];
          } else if (x < ext['xmin']) {
            x = ext['xmax'] - (ext['xmin'] - x) % (ext['xmax'] - ext['xmin']);
            if (x === ext['xmax']) {
              x = ext['xmin'];
            }
          } else if (x >= ext['xmax']) {
            x = ext['xmin'] + (x - ext['xmin']) % (ext['xmax'] - ext['xmin']);
          }
        }
        if (repeatWorld === true || repeatWorld === 'y') {
          if (ext['ymax'] === ext['ymin']) {
            y = ext['ymin'];
          } else if (y >= ext['ymax']) {
            y = ext['ymin'] + (y - ext['ymin']) % (ext['ymax'] - ext['ymin']);
          } else if (y < ext['ymin']) {
            y = ext['ymax'] - (ext['ymin'] - y) % (ext['ymax'] - ext['ymin']);
            if (y === ext['ymax']) {
              y = ext['ymin'];
            }
          }
        }
      }
      if (x < ext['xmin'] || x > ext['xmax'] || y > ext['ymax'] || y < ext['ymin']) {
        out = true;
      }
      return {
        'x': x,
        'y': y,
        'idx': idx,
        'idy': idy,
        out: out
      };
    };
    _proto._getTileFullIndex = function _getTileFullIndex(res) {
      if (!this._tileFullIndex) {
        this._tileFullIndex = {};
      }
      if (this._tileFullIndex[res]) {
        return this._tileFullIndex[res];
      }
      var ext = this.fullExtent;
      var transformation = this.transformation;
      var nwIndex = this._getTileNum(transformation.transform(new Coordinate(ext['left'], ext['top']), 1), res);
      var seIndex = this._getTileNum(transformation.transform(new Coordinate(ext['right'], ext['bottom']), 1), res);
      var tileSystem = this.tileSystem;
      if (tileSystem['scale']['x'] < 0) {
        nwIndex.x -= 1;
        seIndex.x -= 1;
      }
      if (tileSystem['scale']['y'] > 0) {
        nwIndex.y -= 1;
        seIndex.y -= 1;
      }
      this._tileFullIndex[res] = new Extent(nwIndex, seIndex);
      return this._tileFullIndex[res];
    };
    _proto.getTilePrjNW = function getTilePrjNW(tileX, tileY, res, out) {
      var tileSystem = this.tileSystem;
      var tileSize = this['tileSize'];
      var y = tileSystem['origin']['y'] + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 1 : 0)) * res * tileSize['height'];
      var x = tileSystem['origin']['x'] + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 0 : 1)) * res * tileSize['width'];
      if (out) {
        out.set(x, y);
        return out;
      }
      return new Coordinate(x, y);
    };
    _proto.getTilePointNW = function getTilePointNW(tileX, tileY, res, out) {
      var scale = this._glRes / res;
      var tileSystem = this.tileSystem;
      var tileSize = this['tileSize'];
      var y = this._pointOrigin.y * scale + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 1 : 0)) * tileSize['height'];
      var x = this._pointOrigin.x * scale + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 0 : 1)) * tileSize['width'];
      if (out) {
        out.set(x, y);
        return out;
      }
      return new Point(x, y);
    };
    _proto.getTilePrjSE = function getTilePrjSE(tileX, tileY, res, out) {
      var tileSystem = this.tileSystem;
      var tileSize = this['tileSize'];
      var y = tileSystem['origin']['y'] + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 0 : 1)) * res * tileSize['height'];
      var x = tileSystem['origin']['x'] + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 1 : 0)) * res * tileSize['width'];
      if (out) {
        out.set(x, y);
        return out;
      }
      return new Coordinate(x, y);
    };
    _proto.getTilePointSE = function getTilePointSE(tileX, tileY, res, out) {
      var scale = this._glRes / res;
      var tileSystem = this.tileSystem;
      var tileSize = this['tileSize'];
      var y = this._pointOrigin.y * scale + this._yScale * tileSystem['scale']['y'] * (tileY + (tileSystem['scale']['y'] === 1 ? 0 : 1)) * tileSize['height'];
      var x = this._pointOrigin.x * scale + this._xScale * tileSystem['scale']['x'] * (tileX + (tileSystem['scale']['x'] === 1 ? 1 : 0)) * tileSize['width'];
      if (out) {
        out.set(x, y);
        return out;
      }
      return new Point(x, y);
    };
    _proto.getTilePrjExtent = function getTilePrjExtent(tileX, tileY, res) {
      var nw = this.getTilePrjNW(tileX, tileY, res),
        se = this.getTilePrjSE(tileX, tileY, res);
      return new Extent(nw, se);
    };
    return TileConfig;
  }();

  var planes = [];
  for (var i$1 = 0; i$1 < 6; i$1++) {
    planes[i$1] = [];
  }
  var p = [];
  function intersectsBox(matrix, box, mask) {
    setPlanes(matrix);
    for (var i = 0; i < 6; i++) {
      if (mask && mask.charAt(i) === '0') {
        continue;
      }
      var plane = planes[i];
      p[0] = plane[0] > 0 ? box[1][0] : box[0][0];
      p[1] = plane[1] > 0 ? box[1][1] : box[0][1];
      p[2] = plane[2] > 0 ? box[1][2] : box[0][2];
      if (distanceToPoint(plane, p) < 0) {
        return false;
      }
    }
    return true;
  }
  function setPlanes(m) {
    var me = m;
    var me0 = me[0],
      me1 = me[1],
      me2 = me[2],
      me3 = me[3];
    var me4 = me[4],
      me5 = me[5],
      me6 = me[6],
      me7 = me[7];
    var me8 = me[8],
      me9 = me[9],
      me10 = me[10],
      me11 = me[11];
    var me12 = me[12],
      me13 = me[13],
      me14 = me[14],
      me15 = me[15];
    setComponents(planes[0], me3 - me0, me7 - me4, me11 - me8, me15 - me12);
    setComponents(planes[1], me3 + me0, me7 + me4, me11 + me8, me15 + me12);
    setComponents(planes[2], me3 + me1, me7 + me5, me11 + me9, me15 + me13);
    setComponents(planes[3], me3 - me1, me7 - me5, me11 - me9, me15 - me13);
    setComponents(planes[4], me3 - me2, me7 - me6, me11 - me10, me15 - me14);
    setComponents(planes[5], me3 + me2, me7 + me6, me11 + me10, me15 + me14);
  }
  var normalLength = 1.0 / 6;
  function setComponents(out, x, y, z, w) {
    out[0] = x * normalLength;
    out[1] = y * normalLength;
    out[2] = z * normalLength;
    out[3] = w * normalLength;
    return out;
  }
  function distanceToPoint(plane, p) {
    return plane[0] * p[0] + plane[1] * p[1] + plane[2] * p[2] + plane[3];
  }

  var DEFAULT_MAXERROR = 1;
  var TEMP_POINT$2 = new Point(0, 0);
  var MAX_ROOT_NODES = 32;
  var isSetAvailable = typeof Set !== 'undefined';
  var TileHashset = function () {
    function TileHashset() {
      this._table = isSetAvailable ? new Set() : {};
    }
    var _proto = TileHashset.prototype;
    _proto.add = function add$$1(key) {
      if (isSetAvailable) {
        this._table.add(key);
      } else {
        this._table[key] = true;
      }
    };
    _proto.has = function has(key) {
      if (isSetAvailable) {
        return this._table.has(key);
      } else {
        return this._table[key];
      }
    };
    _proto.reset = function reset() {
      if (isSetAvailable) {
        this._table.clear();
      } else {
        this._table = {};
      }
    };
    return TileHashset;
  }();
  var options$w = {
    'urlTemplate': null,
    'subdomains': null,
    'errorUrl': null,
    'repeatWorld': true,
    'background': true,
    'loadingLimitOnInteracting': 3,
    'loadingLimit': 0,
    'tileRetryCount': 0,
    'placeholder': false,
    'crossOrigin': null,
    'tileSize': [256, 256],
    'offset': [0, 0],
    'tileSystem': null,
    'fadeAnimation': !IS_NODE,
    'fadeDuration': 1000 / 60 * 10,
    'debug': false,
    'spatialReference': null,
    'maxCacheSize': 256,
    'renderer': function () {
      return Browser$1.webgl ? 'gl' : 'canvas';
    }(),
    'clipByPitch': true,
    'maxAvailableZoom': null,
    'cascadeTiles': true,
    'zoomOffset': 0,
    'pyramidMode': 1,
    'decodeImageInWorker': false,
    'tileLimitPerFrame': 0,
    'tileStackStartDepth': 7,
    'tileStackDepth': 6,
    'awareOfTerrain': true,
    'bufferPixel': 0.5,
    'mipmapTexture': true,
    'depthMask': true
  };
  var URL_PATTERN$1 = /\{ *([\w_]+) *\}/g;
  var TEMP_POINT0$4 = new Point(0, 0);
  var TEMP_POINT1$1 = new Point(0, 0);
  var TEMP_POINT2$1 = new Point(0, 0);
  var TEMP_POINT3$1 = new Point(0, 0);
  var TEMP_POINT4 = new Point(0, 0);
  var TEMP_POINT6 = new Point(0, 0);
  var TILE_BOX = [[0, 0, 0], [0, 0, 0]];
  var TILE_MIN = [0, 0, 0];
  var TILE_MAX = [0, 0, 0];
  var ARR3 = [];
  var TileLayer = function (_Layer) {
    _inheritsLoose(TileLayer, _Layer);
    function TileLayer() {
      return _Layer.apply(this, arguments) || this;
    }
    TileLayer.fromJSON = function fromJSON(layerJSON) {
      if (!layerJSON || layerJSON['type'] !== 'TileLayer') {
        return null;
      }
      return new TileLayer(layerJSON['id'], layerJSON['options']);
    };
    var _proto2 = TileLayer.prototype;
    _proto2.forceReload = function forceReload() {
      this.fire('forcereloadstart');
      this.clear();
      this.load();
      this.fire('forcereloadend');
      return this;
    };
    _proto2.getTileSize = function getTileSize() {
      if (this._tileSize) {
        return this._tileSize;
      }
      var size = this.options['tileSize'];
      if (isNumber(size)) {
        size = [size, size];
      }
      this._tileSize = new Size(size);
      return this._tileSize;
    };
    _proto2.getTiles = function getTiles(z, parentLayer) {
      this._coordCache = {};
      if (this._isPyramidMode()) {
        return this._getPyramidTiles(z, parentLayer);
      } else {
        return this._getCascadeTiles(z, parentLayer);
      }
    };
    _proto2._isPyramidMode = function _isPyramidMode() {
      var sr = this.getSpatialReference();
      return !this._disablePyramid && !this._hasOwnSR && this.options['pyramidMode'] && sr && sr.isPyramid();
    };
    _proto2._getTileFullExtent = function _getTileFullExtent() {
      if (this._tileFullExtent) {
        return this._tileFullExtent;
      }
      var sr = this.getSpatialReference();
      var fullExtent = sr.getFullExtent();
      var res = sr.getResolution(0);
      var map = this.getMap();
      this._tileFullExtent = fullExtent.convertTo(function (c) {
        return map._prjToPointAtRes(c, res, TEMP_POINT$2);
      });
      return this._tileFullExtent;
    };
    _proto2._getRootNodes = function _getRootNodes(offset0) {
      var map = this.getMap();
      if (this._rootNodes) {
        var _this$_rootNodes = this._rootNodes,
          _tiles = _this$_rootNodes.tiles,
          mapWidth = _this$_rootNodes.mapWidth,
          mapHeight = _this$_rootNodes.mapHeight;
        if (map.width !== mapWidth || map.height !== mapHeight) {
          var _error = this._getRootError();
          for (var i = 0; i < _tiles.length; i++) {
            _tiles[i].error = _error;
          }
          this._rootNodes.mapWidth = map.width;
          this._rootNodes.mapHeight = map.height;
        }
        for (var _i = 0; _i < _tiles.length; _i++) {
          _tiles[_i].offset[0] = offset0[0];
          _tiles[_i].offset[1] = offset0[1];
        }
        return this._rootNodes;
      }
      var sr = this.getSpatialReference();
      var res = sr.getResolution(0);
      var tileConfig = this._getTileConfig();
      var fullExtent = sr.getFullExtent();
      var _tileConfig$tileSyste = tileConfig.tileSystem,
        origin = _tileConfig$tileSyste.origin,
        scale = _tileConfig$tileSyste.scale;
      var extent000 = tileConfig.getTilePrjExtent(0, 0, res);
      var w = extent000.getWidth();
      var h = extent000.getHeight();
      var delta = 1E-5;
      var left = Math.abs((origin.x - fullExtent.left) / w);
      left = Math.ceil(left - delta);
      var right = Math.abs((fullExtent.right - origin.x) / w);
      right = Math.ceil(right - delta);
      var top = Math.ceil(Math.abs(fullExtent.top - origin.y) / h);
      top = Math.ceil(top - delta);
      var bottom = Math.ceil(Math.abs(fullExtent.bottom - origin.y) / h);
      bottom = Math.ceil(bottom - delta);
      if ((right + left) * (bottom + top) > MAX_ROOT_NODES) {
        return {
          status: 0,
          error: 'Too many root nodes'
        };
      }
      var error = this._getRootError();
      var tiles = [];
      var z = 0;
      for (var _i2 = -left; _i2 < right; _i2++) {
        for (var j = -top; j < bottom; j++) {
          var y = scale.y < 0 ? j : -(j + 1);
          tiles.push(this.createTileNode(_i2, y, z, _i2, y, res, error));
        }
      }
      this._rootNodes = {
        status: 1,
        tiles: tiles,
        mapWidth: map.width,
        mapHeight: map.height
      };
      return this._getRootNodes(offset0);
    };
    _proto2.createTileNode = function createTileNode(x, y, z, idx, idy, res, error, parentId, extent2d, tileId) {
      var map = this.getMap();
      var zoomOffset = this.options['zoomOffset'];
      if (!extent2d) {
        var tileConfig = this._getTileConfig();
        extent2d = tileConfig.getTilePrjExtent(x, y, res).convertTo(function (c) {
          return map._prjToPointAtRes(c, res, TEMP_POINT$2);
        });
      }
      var offset = this._getTileOffset(z);
      return {
        parent: parentId,
        layer: this.getId(),
        x: x,
        y: y,
        z: z,
        idx: idx,
        idy: idy,
        res: res,
        extent2d: extent2d,
        id: tileId || this._getTileId(x, y, z),
        url: this.getTileUrl(x, y, z + zoomOffset),
        offset: offset,
        error: error,
        children: []
      };
    };
    _proto2._getRootError = function _getRootError() {
      var map = this.getMap();
      var fov = toRadian(map.getFov());
      var aspectRatio = map.width / map.height;
      var cameraZ = map.cameraPosition[2];
      var heightZ = cameraZ * Math.tan(0.5 * fov);
      var widthZ = heightZ * aspectRatio;
      var diagonalZ = Math.sqrt(cameraZ * cameraZ + heightZ * heightZ + widthZ * widthZ);
      var fov0 = map._getFovZ(0);
      var error = fov0 * (diagonalZ / cameraZ);
      var sr = this.getSpatialReference();
      var res = sr.getResolution(0);
      return error * res / map.getResolution(0);
    };
    _proto2._getPyramidTiles = function _getPyramidTiles(z, layer) {
      var map = this.getMap();
      if (isNaN(+z)) {
        z = this._getTileZoom(map.getZoom());
      }
      var sr = this.getSpatialReference();
      var maxZoom = Math.min(z, this.getMaxZoom(), this.getMaxAvailableZoom() || Infinity);
      var projectionView = map.projViewMatrix;
      var fullExtent = this._getTileFullExtent();
      var offset0 = this._getTileOffset(0);
      var queue;
      if (this.options['repeatWorld']) {
        var mapContainerExtent = map.getContainerExtent();
        var mapExtent2D = this._convertToExtent2d(mapContainerExtent);
        var scale = sr.getResolution(0) / map.getResolution();
        if (!mapExtent2D.within(fullExtent.copy()._scale(scale))) {
          var pitch = map.getPitch();
          var cascadePitch1 = map.options['cascadePitches'][1];
          var visualHeight1 = Math.floor(map._getVisualHeight(cascadePitch1));
          var visualContainerExtent = pitch <= cascadePitch1 ? mapContainerExtent : new PointExtent(0, map.height - visualHeight1, map.width, map.height);
          this._visitedTiles = new TileHashset();
          var tileGrid = this._getTiles(0 - this.options['zoomOffset'], visualContainerExtent, 2, layer && layer.getRenderer(), true);
          var error = this._getRootError() * Math.pow(2, this.options['zoomOffset']);
          tileGrid.tiles.forEach(function (t) {
            t.error = error;
          });
          queue = tileGrid.tiles;
        } else {
          var rootNodes = this._getRootNodes(offset0);
          if (rootNodes.status !== 1) {
            console.warn(rootNodes.error);
            this._disablePyramid = true;
            return this.getTiles(z, layer);
          }
          queue = rootNodes.tiles.concat();
        }
      } else {
        var _rootNodes = this._getRootNodes(offset0);
        if (_rootNodes.status !== 1) {
          console.warn(_rootNodes.error);
          this._disablePyramid = true;
          return this.getTiles(z, layer);
        }
        queue = _rootNodes.tiles.concat();
      }
      var glRes = map.getGLRes();
      var offsets = {
        0: offset0
      };
      var extent = new PointExtent();
      var tiles = [];
      var parents = [];
      while (queue.length > 0) {
        var node = queue.pop();
        if (node.z === maxZoom) {
          extent._combine(node.extent2d);
          tiles.push(node);
          continue;
        }
        if (!offsets[node.z + 1]) {
          offsets[node.z + 1] = this._getTileOffset(node.z + 1);
        }
        this._splitNode(node, projectionView, queue, tiles, extent, maxZoom, offsets[node.z + 1], layer && layer.getRenderer(), glRes);
        if (this.isParentTile(z, maxZoom, node)) {
          parents.push(node);
        }
      }
      parents.sort(sortingTiles);
      return {
        tileGrids: [{
          extent: extent,
          count: tiles.length,
          tiles: tiles,
          parents: parents,
          offset: [0, 0],
          zoom: z
        }],
        count: tiles.length
      };
    };
    _proto2.isParentTile = function isParentTile(z, maxZoom, tile) {
      var stackMinZoom = Math.max(this.getMinZoom(), z - this.options['tileStackStartDepth']);
      var stackMaxZoom = Math.min(maxZoom, stackMinZoom + this.options['tileStackDepth']);
      return tile.z >= stackMinZoom && tile.z < stackMaxZoom;
    };
    _proto2._splitNode = function _splitNode(node, projectionView, queue, tiles, gridExtent, maxZoom, offset, parentRenderer, glRes) {
      var z = node.z + 1;
      var sr = this.getSpatialReference();
      var idx = node.idx,
        idy = node.idy;
      var renderer = parentRenderer || this.getRenderer();
      var hasCurrentIn = false;
      var children = [];
      var res = sr.getResolution(z);
      var glScale = res / glRes;
      for (var i = 0; i < 4; i++) {
        var dx = i % 2;
        var dy = i >> 1;
        var childIdx = (idx << 1) + dx;
        var childIdy = (idy << 1) + dy;
        if (!node.children) {
          node.children = [];
        }
        var tileId = node.children[i];
        if (!tileId) {
          tileId = this._getTileId(childIdx, childIdy, z);
          node.children[i] = tileId;
        }
        var cached = renderer.isTileCachedOrLoading(tileId);
        var childNode = cached && cached.info;
        if (!childNode) {
          if (!this.tileInfoCache) {
            this.tileInfoCache = new LRUCache(this.options['maxCacheSize'] * 4);
          }
          childNode = this.tileInfoCache.get(tileId);
          if (!childNode) {
            childNode = this._createChildNode(node, dx, dy, offset, tileId);
          }
        }
        childNode.error = node.error / 2;
        childNode.offset[0] = offset[0];
        childNode.offset[1] = offset[1];
        var visible = this._isTileVisible(childNode, projectionView, glScale, maxZoom, offset);
        if (visible === 1) {
          hasCurrentIn = true;
        } else if (visible === -1) {
          continue;
        } else if (visible === 0 && z !== maxZoom) {
          tiles.push(node);
          gridExtent._combine(node.extent2d);
          return;
        }
        children.push(childNode);
      }
      if (z === maxZoom) {
        if (hasCurrentIn) {
          queue.push.apply(queue, children);
        } else {
          tiles.push(node);
          gridExtent._combine(node.extent2d);
        }
      } else {
        queue.push.apply(queue, children);
      }
    };
    _proto2._createChildNode = function _createChildNode(node, dx, dy, offset, tileId) {
      var x = node.x,
        y = node.y,
        idx = node.idx,
        idy = node.idy,
        extent2d = node.extent2d;
      var z = node.z + 1;
      var childX = (x << 1) + dx;
      var childY = (y << 1) + dy;
      var childIdx = (idx << 1) + dx;
      var childIdy = (idy << 1) + dy;
      var childScale = 2;
      var width = extent2d.getWidth() / 2 * childScale;
      var height = extent2d.getHeight() / 2 * childScale;
      var minx = extent2d.xmin * childScale;
      var maxy = extent2d.ymax * childScale;
      var miny = extent2d.ymin * childScale;
      var tileSystem = this._getTileConfig().tileSystem;
      var scaleY = tileSystem.scale.y;
      tileId = tileId || this._getTileId(childIdx, childIdy, z);
      var extent;
      if (scaleY < 0) {
        var nwx = minx + dx * width;
        var nwy = maxy - dy * height;
        extent = new PointExtent(nwx, nwy - height, nwx + width, nwy);
      } else {
        var swx = minx + dx * width;
        var swy = miny + dy * height;
        extent = new PointExtent(swx, swy, swx + width, swy + height);
      }
      var childNode = this.createTileNode(childX, childY, z, childIdx, childIdy, node.res / 2, node.error / 2, node.id, extent, tileId);
      this.tileInfoCache.add(tileId, childNode);
      return childNode;
    };
    _proto2._isTileVisible = function _isTileVisible(node, projectionView, glScale, maxZoom, offset) {
      if (node.z === 0) {
        return 1;
      }
      if (!this._isTileInFrustum(node, projectionView, glScale, offset)) {
        return -1;
      }
      var maxError = this.options['maxError'];
      if (isNil(maxError)) {
        maxError = DEFAULT_MAXERROR;
      }
      var error = this._getScreenSpaceError(node, glScale, maxZoom, offset);
      return error >= maxError ? 1 : 0;
    };
    _proto2._isTileInFrustum = function _isTileInFrustum(node, projectionView, glScale, offset) {
      if (!this._zScale) {
        var map = this.getMap();
        var glRes = map.getGLRes();
        this._zScale = map.altitudeToPoint(100, glRes) / 100;
      }
      var renderer = this.getRenderer();
      var _node$extent2d = node.extent2d,
        xmin = _node$extent2d.xmin,
        ymin = _node$extent2d.ymin,
        xmax = _node$extent2d.xmax,
        ymax = _node$extent2d.ymax;
      TILE_BOX[0][0] = (xmin - offset[0]) * glScale;
      TILE_BOX[0][1] = (ymin - offset[1]) * glScale;
      var minAltitude = node.minAltitude || renderer && renderer.avgMinAltitude || 0;
      TILE_BOX[0][2] = minAltitude * this._zScale;
      TILE_BOX[1][0] = (xmax - offset[0]) * glScale;
      TILE_BOX[1][1] = (ymax - offset[1]) * glScale;
      var maxAltitude = node.maxAltitude || renderer && renderer.avgMaxAltitude || 0;
      TILE_BOX[1][2] = maxAltitude * this._zScale;
      return intersectsBox(projectionView, TILE_BOX);
    };
    _proto2._getScreenSpaceError = function _getScreenSpaceError(node, glScale, maxZoom, offset) {
      var geometricError = node.error;
      var map = this.getMap();
      var _node$extent2d2 = node.extent2d,
        xmin = _node$extent2d2.xmin,
        ymin = _node$extent2d2.ymin,
        xmax = _node$extent2d2.xmax,
        ymax = _node$extent2d2.ymax;
      TILE_MIN[0] = (xmin - offset[0]) * glScale;
      TILE_MIN[1] = (ymin - offset[1]) * glScale;
      TILE_MAX[0] = (xmax - offset[0]) * glScale;
      TILE_MAX[1] = (ymax - offset[1]) * glScale;
      var distanceToCamera = distanceToRect(TILE_MIN, TILE_MAX, map.cameraPosition);
      var distance$$1 = Math.max(Math.abs(distanceToCamera), 1E-7);
      var gap = Math.abs(node.z - maxZoom);
      var r;
      if (map.height < 1000) {
        r = 1;
      } else {
        r = gap <= 1 ? 1 : gap <= 2 ? 0.7 : 0.605;
      }
      var error = geometricError * r / distance$$1;
      return error;
    };
    _proto2._getCascadeTiles = function _getCascadeTiles(z, parentLayer) {
      var map = this.getMap();
      var pitch = map.getPitch();
      var parentRenderer = parentLayer && parentLayer.getRenderer();
      var mapExtent = map.getContainerExtent();
      var tileGrids = [];
      var count = 0;
      var minZoom = this.getMinZoom();
      var cascadePitch0 = map.options['cascadePitches'][0];
      var cascadePitch1 = map.options['cascadePitches'][1];
      var visualHeight1 = Math.floor(map._getVisualHeight(cascadePitch1));
      var tileZoom = isNil(z) ? this._getTileZoom(map.getZoom()) : z;
      this._visitedTiles = new TileHashset();
      if (!isNil(z) || !this.options['cascadeTiles'] || pitch <= cascadePitch0 || !isNil(minZoom) && tileZoom <= minZoom) {
        var containerExtent = pitch <= cascadePitch1 ? mapExtent : new PointExtent(0, map.height - visualHeight1, map.width, map.height);
        var _currentTiles = this._getTiles(tileZoom, containerExtent, 2, parentRenderer);
        if (_currentTiles) {
          count += _currentTiles.tiles.length;
          tileGrids.push(_currentTiles);
        }
        return {
          tileGrids: tileGrids,
          count: count
        };
      }
      var visualHeight0 = Math.floor(map._getVisualHeight(cascadePitch0));
      var extent0 = new PointExtent(0, map.height - visualHeight0, map.width, map.height);
      var currentTiles = this._getTiles(tileZoom, extent0, 0, parentRenderer);
      count += currentTiles ? currentTiles.tiles.length : 0;
      tileGrids.push(currentTiles);
      var cascadeHeight = extent0.ymin;
      var d = map.getSpatialReference().getZoomDirection();
      var cascadeLevels = d;
      var cascadeTiles1;
      if (pitch > cascadePitch1) {
        if (tileZoom - cascadeLevels <= minZoom) {
          cascadeLevels = 0;
        }
        var extent1 = new PointExtent(0, map.height - visualHeight1, map.width, cascadeHeight);
        cascadeTiles1 = this._getTiles(tileZoom - cascadeLevels, extent1, 1, parentRenderer);
        count += cascadeTiles1 ? cascadeTiles1.tiles.length : 0;
        cascadeHeight = extent1.ymin;
        cascadeLevels += 4 * d;
        tileGrids.push(cascadeTiles1);
      }
      var cascadeTiles2;
      if (tileZoom - cascadeLevels >= minZoom) {
        var extent2 = new PointExtent(0, mapExtent.ymin, map.width, cascadeHeight);
        cascadeTiles2 = this._getTiles(tileZoom - cascadeLevels, extent2, 2, parentRenderer);
        count += cascadeTiles2 ? cascadeTiles2.tiles.length : 0;
        tileGrids.push(cascadeTiles2);
      }
      if (cascadeTiles1 && cascadeTiles2) {
        tileGrids[1] = cascadeTiles2;
        tileGrids[2] = cascadeTiles1;
      }
      return {
        tileGrids: tileGrids,
        count: count
      };
    };
    _proto2.getTileUrl = function getTileUrl(x, y, z) {
      var urlTemplate = this.options['urlTemplate'];
      var domain = '';
      if (this.options['subdomains']) {
        var subdomains = this.options['subdomains'];
        if (isArrayHasData(subdomains)) {
          var length$$1 = subdomains.length;
          var s = (x + y) % length$$1;
          if (s < 0) {
            s = 0;
          }
          domain = subdomains[s];
        }
      }
      if (isFunction(urlTemplate)) {
        return urlTemplate(x, y, z, domain);
      }
      var data = {
        'x': x,
        'y': y,
        'z': z,
        's': domain
      };
      if (this.options.token) {
        data.token = this.options.token;
      }
      if (this.options.customTags) {
        extend(data, this.options.customTags);
      }
      return urlTemplate.replace(URL_PATTERN$1, function (str, key) {
        var value = data[key];
        if (value === undefined) {
          throw new Error('No value provided for variable ' + str);
        } else if (typeof value === 'function') {
          value = value(data);
        }
        return value;
      });
    };
    _proto2.clear = function clear() {
      if (this._renderer) {
        this._renderer.clear();
      }
      if (this.tileInfoCache) {
        this.tileInfoCache.reset();
      }
      this.fire('clear');
      return this;
    };
    _proto2.toJSON = function toJSON() {
      var profile = {
        'type': this.getJSONType(),
        'id': this.getId(),
        'options': this.config()
      };
      return profile;
    };
    _proto2.getSpatialReference = function getSpatialReference() {
      var map = this.getMap();
      if (map && (!this.options['spatialReference'] || SpatialReference.equals(this.options['spatialReference'], map.options['spatialReference']))) {
        return map.getSpatialReference();
      }
      if (this._sr) {
        return this._sr;
      }
      var config = this.options['spatialReference'];
      if (isString(config)) {
        config = SpatialReference.getPreset(config);
        if (!config) {
          throw new Error("Unsupported spatial reference: " + this.options['spatialReference'] + ", possible values: " + SpatialReference.getAllPresets().join());
        }
      }
      this._sr = new SpatialReference(config);
      this._srMinZoom = this._sr.getMinZoom();
      this._srMaxZoom = this._sr.getMaxZoom();
      this._hasOwnSR = this._sr.toJSON().projection !== map.getSpatialReference().toJSON().projection;
      return this._sr;
    };
    _proto2.getMinZoom = function getMinZoom() {
      var minZoom = this.options['minZoom'] || 0;
      var sr = this.getSpatialReference();
      if (sr !== this.getMap().getSpatialReference()) {
        return Math.max(minZoom, this._srMinZoom);
      }
      return minZoom;
    };
    _proto2.getMaxZoom = function getMaxZoom() {
      var sr = this.getSpatialReference();
      if (sr !== this.getMap().getSpatialReference()) {
        return Math.min(_Layer.prototype.getMaxZoom.call(this), this._srMaxZoom);
      }
      return _Layer.prototype.getMaxZoom.call(this);
    };
    _proto2._getTileZoom = function _getTileZoom(zoom) {
      if (!this._hasOwnSR) {
        var res0 = this.getMap().getResolution(zoom);
        var res1 = this.getSpatialReference().getResolution(zoom);
        var dz = Math.log(res1 / res0) * Math.LOG2E;
        zoom += dz;
      }
      var maxZoom = this.getMaxAvailableZoom();
      if (!isNil(maxZoom) && zoom > maxZoom) {
        zoom = maxZoom;
      }
      if (!isInteger(zoom)) {
        zoom = Math.round(zoom);
      }
      zoom = Math.max(0, zoom);
      return zoom;
    };
    _proto2.getMaxAvailableZoom = function getMaxAvailableZoom() {
      var sr = this.getSpatialReference();
      return this.options['maxAvailableZoom'] || sr && sr.getMaxZoom();
    };
    _proto2._getTiles = function _getTiles(tileZoom, containerExtent, cascadeLevel, parentRenderer, ignoreMinZoom) {
      var map = this.getMap();
      var z = tileZoom;
      var frustumMatrix = map.projViewMatrix;
      var canSplitTile = map.getResolution(tileZoom) / map.getResolution(tileZoom - 1) === 0.5;
      if (cascadeLevel < 2) {
        if (cascadeLevel === 0 && canSplitTile) {
          z -= 1;
        }
        frustumMatrix = cascadeLevel === 0 ? map.cascadeFrustumMatrix0 : cascadeLevel === 1 ? map.cascadeFrustumMatrix1 : map.projViewMatrix;
      }
      var zoom = z + this.options['zoomOffset'];
      var offset = this._getTileOffset(z),
        hasOffset = offset[0] || offset[1];
      var emptyGrid = {
        'zoom': z,
        'extent': null,
        'offset': offset,
        'tiles': []
      };
      if (zoom < 0) {
        return emptyGrid;
      }
      if (!map || !this.isVisible() || !map.width || !map.height) {
        return emptyGrid;
      }
      if (!ignoreMinZoom) {
        var minZoom = this.getMinZoom(),
          maxZoom = this.getMaxZoom();
        if (!isNil(minZoom) && z < minZoom || !isNil(maxZoom) && z > maxZoom) {
          return emptyGrid;
        }
      }
      var tileConfig = this._getTileConfig();
      if (!tileConfig) {
        return emptyGrid;
      }
      var tileOffsets = {
        zoom: offset
      };
      var sr = this.getSpatialReference();
      var res = sr.getResolution(z);
      var glScale;
      if (this._hasOwnSR) {
        glScale = map.getGLScale(z);
      } else {
        glScale = res / map.getGLRes();
      }
      var repeatWorld = !this._hasOwnSR && this.options['repeatWorld'];
      var extent2d = this._convertToExtent2d(containerExtent);
      var maskExtent = this._getMask2DExtent();
      if (maskExtent) {
        var intersection = maskExtent.intersection(extent2d);
        if (!intersection) {
          return emptyGrid;
        }
        containerExtent = intersection.convertTo(function (c) {
          return map._pointToContainerPoint(c, undefined, 0, TEMP_POINT$2);
        });
      }
      var prjCenter = map._containerPointToPrj(containerExtent.getCenter(), TEMP_POINT0$4);
      var centerPoint = map._prjToPoint(prjCenter, z, TEMP_POINT1$1);
      var c;
      if (hasOffset) {
        c = this._project(map._pointToPrj(centerPoint._add(offset), z, TEMP_POINT1$1), TEMP_POINT1$1);
      } else {
        c = this._project(prjCenter, TEMP_POINT1$1);
      }
      var extentScale = map.getGLScale() / map.getGLScale(z);
      TEMP_POINT2$1.x = extent2d.xmin * extentScale;
      TEMP_POINT2$1.y = extent2d.ymax * extentScale;
      TEMP_POINT3$1.x = extent2d.xmax * extentScale;
      TEMP_POINT3$1.y = extent2d.ymin * extentScale;
      var pmin = this._project(map._pointToPrj(TEMP_POINT2$1._add(offset), z, TEMP_POINT2$1), TEMP_POINT2$1);
      var pmax = this._project(map._pointToPrj(TEMP_POINT3$1._add(offset), z, TEMP_POINT3$1), TEMP_POINT3$1);
      var centerTile = tileConfig.getTileIndex(c, res, repeatWorld);
      var ltTile = tileConfig.getTileIndex(pmin, res, repeatWorld);
      var rbTile = tileConfig.getTileIndex(pmax, res, repeatWorld);
      var top = Math.ceil(Math.abs(centerTile.idy - ltTile.idy)),
        left = Math.ceil(Math.abs(centerTile.idx - ltTile.idx)),
        bottom = Math.ceil(Math.abs(centerTile.idy - rbTile.idy)),
        right = Math.ceil(Math.abs(centerTile.idx - rbTile.idx));
      var allCount = (top + bottom + 1) * (left + right + 1);
      var tileSize = this.getTileSize();
      var renderer = this.getRenderer() || parentRenderer,
        scale = this._getTileConfig().tileSystem.scale;
      var tiles = [],
        extent = new PointExtent();
      var tilePoint = new Point(0, 0);
      for (var i = -top; i <= bottom; i++) {
        var j = -left;
        var leftVisitEnd = -Infinity;
        var rightVisitEnd = false;
        while (j >= leftVisitEnd && j <= right) {
          var idx = tileConfig.getNeighorTileIndex(centerTile.idx, centerTile.idy, j, i, res, repeatWorld);
          if (leftVisitEnd === -Infinity) {
            j++;
          } else {
            j--;
          }
          var tileId = this._getTileId(idx.idx, idx.idy, z);
          if (idx.out || this._visitedTiles && this._visitedTiles.has(tileId)) {
            continue;
          }
          var tileInfo = renderer && renderer.isTileCachedOrLoading(tileId);
          if (tileInfo) {
            tileInfo = tileInfo.info;
          }
          var p = void 0;
          if (tileInfo) {
            var _tileInfo = tileInfo,
              _extent2d = _tileInfo.extent2d;
            tilePoint.set(_extent2d.xmin, _extent2d.ymax);
            p = tilePoint;
          } else if (!this._hasOwnSR) {
            p = tileConfig.getTilePointNW(idx.x, idx.y, res);
          } else {
            var pnw = tileConfig.getTilePrjNW(idx.x, idx.y, res);
            p = map._prjToPoint(this._unproject(pnw, TEMP_POINT3$1), z);
          }
          var width = void 0,
            height = void 0;
          if (!this._hasOwnSR) {
            width = tileSize.width;
            height = tileSize.height;
          } else {
            var pp = void 0;
            if (!this._hasOwnSR) {
              pp = tileConfig.getTilePointSE(idx.x, idx.y, res);
            } else {
              var pse = tileConfig.getTilePrjSE(idx.x, idx.y, res);
              pp = map._prjToPoint(this._unproject(pse, TEMP_POINT3$1), z, TEMP_POINT3$1);
            }
            width = Math.ceil(Math.abs(pp.x - p.x));
            height = Math.ceil(Math.abs(pp.y - p.y));
          }
          var dx = scale.x * (idx.idx - idx.x) * width,
            dy = scale.y * (idx.idy - idx.y) * height;
          if (!tileInfo && (dx || dy)) {
            p._add(dx, dy);
          }
          var tileExtent = tileInfo && tileInfo.extent2d || new PointExtent(p.x, p.y - height, p.x + width, p.y);
          if (allCount <= 4 || rightVisitEnd || this._isTileInExtent(frustumMatrix, tileExtent, offset, glScale)) {
            var tileRes = this._hasOwnSR ? map._getResolution(z) : res;
            if (this._visitedTiles && cascadeLevel === 0) {
              this._visitedTiles.add(tileId);
            }
            if (canSplitTile && cascadeLevel === 0) {
              this._splitTiles(frustumMatrix, tiles, renderer, idx, z + 1, tileRes, tileExtent, dx, dy, tileOffsets);
              extent._combine(tileExtent);
            } else {
              if (!tileInfo) {
                tileInfo = this.createTileNode(idx.x, idx.y, z, idx.idx, idx.idy, tileRes, 0, null, tileExtent, tileId);
              } else {
                tileInfo.offset[0] = offset[0];
                tileInfo.offset[1] = offset[1];
              }
              tiles.push(tileInfo);
              extent._combine(tileExtent);
            }
            if (leftVisitEnd === -Infinity) {
              leftVisitEnd = j;
              j = right;
            } else if (!rightVisitEnd) {
              rightVisitEnd = true;
            }
          }
        }
      }
      if (tiles.length) {
        var center = map._containerPointToPoint(containerExtent.getCenter(), z, TEMP_POINT$2)._add(offset);
        var point0 = new Point(0, 0);
        var point1 = new Point(0, 0);
        tiles.sort(function (a, b) {
          point0.set((a.extent2d.xmin + a.extent2d.xmax) / 2, (a.extent2d.ymin + a.extent2d.ymax) / 2);
          point1.set((b.extent2d.xmin + b.extent2d.xmax) / 2, (b.extent2d.ymin + b.extent2d.ymax) / 2);
          return point0.distanceTo(center) - point1.distanceTo(center);
        });
      }
      return {
        'offset': offset,
        'zoom': tileZoom,
        'extent': extent,
        'tiles': tiles
      };
    };
    _proto2._convertToExtent2d = function _convertToExtent2d(containerExtent) {
      var _this = this;
      var map = this.getMap();
      return containerExtent.convertTo(function (c) {
        var result;
        if (c.y > 0 && c.y < map.height) {
          var key = (c.x === 0 ? 0 : 1) + c.y;
          if (!_this._coordCache[key]) {
            _this._coordCache[key] = map._containerPointToPoint(c);
          }
          result = _this._coordCache[key];
        }
        result = map._containerPointToPoint(c, undefined, TEMP_POINT$2);
        return result;
      });
    };
    _proto2._splitTiles = function _splitTiles(frustumMatrix, tiles, renderer, tileIdx, z, res, tileExtent, dx, dy, tileOffsets) {
      var yOrder = this._getTileConfig().tileSystem.scale.y;
      var glScale = this.getMap().getGLScale(z);
      var corner = TEMP_POINT4.set(tileExtent.xmin * 2, yOrder < 0 ? tileExtent.ymax * 2 : tileExtent.ymin * 2);
      var w = tileExtent.getWidth();
      var h = tileExtent.getHeight();
      var idx = tileIdx.idx * 2;
      var idy = tileIdx.idy * 2;
      var x = tileIdx.x * 2;
      var y = tileIdx.y * 2;
      var tile = this._checkAndAddTile(frustumMatrix, renderer, idx, idy, x, y, z, res, 0, 0, w, h, corner, glScale, tileOffsets);
      if (tile) tiles.push(tile);
      tile = this._checkAndAddTile(frustumMatrix, renderer, idx, idy, x, y, z, res, 0, 1, w, h, corner, glScale, tileOffsets);
      if (tile) tiles.push(tile);
      tile = this._checkAndAddTile(frustumMatrix, renderer, idx, idy, x, y, z, res, 1, 0, w, h, corner, glScale, tileOffsets);
      if (tile) tiles.push(tile);
      tile = this._checkAndAddTile(frustumMatrix, renderer, idx, idy, x, y, z, res, 1, 1, w, h, corner, glScale, tileOffsets);
      if (tile) tiles.push(tile);
    };
    _proto2._checkAndAddTile = function _checkAndAddTile(frustumMatrix, renderer, idx, idy, x, y, z, res, i, j, w, h, corner, glScale, tileOffsets) {
      var tileId = this._getTileId(idx + i, idy + j, z);
      if (this._visitedTiles && this._visitedTiles.has(tileId)) {
        return null;
      }
      var offset = tileOffsets[z];
      if (!offset) {
        offset = tileOffsets[z] = this._getTileOffset(z);
      }
      var yOrder = this._getTileConfig().tileSystem.scale.y;
      var childExtent = new PointExtent(corner.x + i * w, corner.y + yOrder * j * h, corner.x + (i + 1) * w, corner.y + yOrder * (j + 1) * h);
      if (!this._isSplittedTileInExtent(frustumMatrix, childExtent, offset, glScale)) {
        return null;
      }
      var childRes = res / 2;
      var tileInfo = renderer && renderer.isTileCachedOrLoading(tileId);
      if (!tileInfo) {
        tileInfo = this.createTileNode(x + i, y + j, z, idx + i, idx + y, childRes, 0, null, childExtent, tileId);
      } else {
        tileInfo = tileInfo.info;
      }
      return tileInfo;
    };
    _proto2._getTileOffset = function _getTileOffset() {
      var offset = this.options['offset'];
      if (isFunction(offset)) {
        var _offset;
        for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
          params[_key] = arguments[_key];
        }
        offset = (_offset = offset).call.apply(_offset, [this].concat(params));
      }
      if (isNumber(offset)) {
        offset = [offset, offset];
      }
      return offset || [0, 0];
    };
    _proto2.getTileId = function getTileId(x, y, zoom, id) {
      return this._getTileId(x, y, zoom, id);
    };
    _proto2._getTileId = function _getTileId(x, y, zoom, id) {
      return (id || this.getId()) + "_" + x + "_" + y + "_" + zoom;
    };
    _proto2._project = function _project(pcoord, out) {
      if (this._hasOwnSR) {
        var map = this.getMap();
        var mapProjection = map.getProjection();
        var projection = this.getSpatialReference().getProjection();
        return projection.project(mapProjection.unproject(pcoord, out), out);
      } else {
        return pcoord;
      }
    };
    _proto2._unproject = function _unproject(pcoord, out) {
      if (this._hasOwnSR) {
        var map = this.getMap();
        var sr = this.getSpatialReference();
        var mapProjection = map.getProjection();
        var projection = sr.getProjection();
        return mapProjection.project(projection.unproject(pcoord, out), out);
      } else {
        return pcoord;
      }
    };
    _proto2._initTileConfig = function _initTileConfig() {
      var map = this.getMap(),
        tileSize = this.getTileSize();
      var sr = this.getSpatialReference();
      var projection = sr.getProjection(),
        fullExtent = sr.getFullExtent();
      this._defaultTileConfig = new TileConfig(map, TileSystem.getDefault(projection), fullExtent, tileSize);
      if (this.options.hasOwnProperty('tileSystem')) {
        this._tileConfig = new TileConfig(map, this.options['tileSystem'], fullExtent, tileSize);
      }
      delete this._rootNodes;
      delete this._tileFullExtent;
      delete this._disablePyramid;
    };
    _proto2._getTileConfig = function _getTileConfig() {
      if (!this._defaultTileConfig) {
        this._initTileConfig();
      }
      return this._tileConfig || this._defaultTileConfig;
    };
    _proto2._bindMap = function _bindMap(map) {
      var baseLayer = map.getBaseLayer();
      if (baseLayer === this) {
        if (!baseLayer.options.hasOwnProperty('forceRenderOnMoving')) {
          this.config({
            'forceRenderOnMoving': true
          });
        }
      }
      this._onSpatialReferenceChange();
      return _Layer.prototype._bindMap.apply(this, arguments);
    };
    _proto2._isTileInExtent = function _isTileInExtent(frustumMatrix, tileExtent, offset, glScale) {
      var map = this.getMap();
      var matrix;
      if (frustumMatrix !== map.projViewMatrix) {
        var tileCenter = tileExtent.getCenter(TEMP_POINT6)._sub(offset[0], offset[1])._multi(glScale);
        set$2(ARR3, tileCenter.x, tileCenter.y, 0);
        var ndc = transformMat4(ARR3, ARR3, map.projViewMatrix);
        matrix = ndc[1] < 0 ? map.projViewMatrix : frustumMatrix;
      } else {
        matrix = map.projViewMatrix;
      }
      TILE_BOX[0][0] = (tileExtent.xmin - offset[0]) * glScale;
      TILE_BOX[0][1] = (tileExtent.ymin - offset[1]) * glScale;
      TILE_BOX[1][0] = (tileExtent.xmax - offset[0]) * glScale;
      TILE_BOX[1][1] = (tileExtent.ymax - offset[1]) * glScale;
      return intersectsBox(matrix, TILE_BOX);
    };
    _proto2._isSplittedTileInExtent = function _isSplittedTileInExtent(frustumMatrix, tileExtent, offset, glScale) {
      var map = this.getMap();
      TILE_BOX[0][0] = (tileExtent.xmin - offset[0]) * glScale;
      TILE_BOX[0][1] = (tileExtent.ymin - offset[1]) * glScale;
      TILE_BOX[1][0] = (tileExtent.xmax - offset[0]) * glScale;
      TILE_BOX[1][1] = (tileExtent.ymax - offset[1]) * glScale;
      return intersectsBox(map.projViewMatrix, TILE_BOX);
    };
    _proto2.getEvents = function getEvents() {
      return {
        'spatialreferencechange': this._onSpatialReferenceChange
      };
    };
    _proto2._onSpatialReferenceChange = function _onSpatialReferenceChange() {
      delete this._tileConfig;
      delete this._defaultTileConfig;
      delete this._sr;
      delete this._srMinZoom;
      delete this._hasOwnSR;
      delete this._rootNodes;
      if (this.tileInfoCache) {
        this.tileInfoCache.reset();
      }
      var renderer = this.getRenderer();
      if (renderer) {
        renderer.clear();
      }
    };
    _proto2.getPolygonOffsetCount = function getPolygonOffsetCount() {
      return 2;
    };
    _proto2.getPolygonOffset = function getPolygonOffset() {
      return this._polygonOffset || 0;
    };
    _proto2.setPolygonOffset = function setPolygonOffset(offset) {
      this._polygonOffset = offset;
      return this;
    };
    return TileLayer;
  }(Layer);
  TileLayer.registerJSONType('TileLayer');
  TileLayer.mergeOptions(options$w);
  function distanceToRect(min, max, xyz) {
    var dx = Math.max(min[0] - xyz[0], 0, xyz[0] - max[0]);
    var dy = Math.max(min[1] - xyz[1], 0, xyz[1] - max[1]);
    var dz = Math.max(min[2] - xyz[2], 0, xyz[2] - max[2]);
    return Math.sqrt(dx * dx + dy * dy + dz * dz);
  }
  function sortingTiles(t0, t1) {
    return t0.z - t1.z;
  }

  var options$x = {
    'maxCacheSize': 1024
  };
  var DEFAULT_TILESIZE = new Size(256, 256);
  var EVENTS$2 = 'show hide remove setzindex forcereloadstart';
  function checkLayers(tileLayers) {
    if (!Array.isArray(tileLayers)) {
      tileLayers = [tileLayers];
    }
    return tileLayers;
  }
  var GroupTileLayer = function (_TileLayer) {
    _inheritsLoose(GroupTileLayer, _TileLayer);
    GroupTileLayer.fromJSON = function fromJSON(layerJSON) {
      if (!layerJSON || layerJSON['type'] !== 'GroupTileLayer') {
        return null;
      }
      var layers = layerJSON['layers'].map(function (json) {
        return Layer.fromJSON(json);
      });
      return new GroupTileLayer(layerJSON['id'], layers, layerJSON['options']);
    };
    function GroupTileLayer(id, layers, options) {
      var _this;
      _this = _TileLayer.call(this, id, options) || this;
      _this.layers = layers || [];
      _this._checkChildren();
      _this.layerMap = {};
      _this._groupChildren = [];
      return _this;
    }
    var _proto = GroupTileLayer.prototype;
    _proto.getLayers = function getLayers() {
      return this.layers;
    };
    _proto.addLayer = function addLayer(tileLayers) {
      var _this2 = this;
      if (tileLayers === void 0) {
        tileLayers = [];
      }
      tileLayers = checkLayers(tileLayers);
      var len = this.layers.length;
      tileLayers.forEach(function (tileLayer) {
        if (!(tileLayer instanceof TileLayer)) {
          return;
        }
        if (_this2.layers.indexOf(tileLayer) === -1 && !_this2.layerMap[tileLayer.getId()]) {
          _this2.layers.push(tileLayer);
        }
      });
      if (len !== this.layers.length) {
        this._sortLayers();
        this._refresh();
        this._renderLayers();
      }
      return this;
    };
    _proto.removeLayer = function removeLayer(tileLayers) {
      var _this3 = this;
      if (tileLayers === void 0) {
        tileLayers = [];
      }
      tileLayers = checkLayers(tileLayers);
      var len = this.layers.length;
      tileLayers.forEach(function (tileLayer) {
        if (!(tileLayer instanceof TileLayer)) {
          tileLayer = _this3.layerMap[tileLayer];
        }
        if (!(tileLayer instanceof TileLayer)) {
          return;
        }
        var index = _this3.layers.indexOf(tileLayer);
        if (index >= 0) {
          _this3.layers.splice(index, 1);
          tileLayer._doRemove();
          tileLayer.off(EVENTS$2, _this3._onLayerShowHide, _this3);
        }
      });
      if (len !== this.layers.length) {
        this._refresh();
        this._renderLayers();
      }
      return this;
    };
    _proto.clearLayers = function clearLayers() {
      var _this4 = this;
      this.layers.forEach(function (layer) {
        layer._doRemove();
        layer.off(EVENTS$2, _this4._onLayerShowHide, _this4);
      });
      this.layers = [];
      this._refresh();
      this._renderLayers();
      return this;
    };
    _proto.toJSON = function toJSON() {
      var profile = {
        'type': this.getJSONType(),
        'id': this.getId(),
        'layers': this.layers.map(function (layer) {
          return layer.toJSON();
        }),
        'options': this.config()
      };
      return profile;
    };
    _proto.getTileSize = function getTileSize(id) {
      var layer = this.getLayer(id);
      if (!layer) {
        return DEFAULT_TILESIZE;
      }
      return layer.getTileSize();
    };
    _proto.getTiles = function getTiles(z, parentLayer) {
      var layers = this.layers;
      var tiles = [];
      var count = 0;
      for (var i = 0, l = layers.length; i < l; i++) {
        var layer = layers[i];
        if (!layer || !layer.options['visible'] || !layer.isVisible() || !layer.getMap()) {
          continue;
        }
        var childGrid = layer.getTiles(z, parentLayer || this);
        if (!childGrid || childGrid.count === 0) {
          continue;
        }
        count += childGrid.count;
        pushIn(tiles, childGrid.tileGrids);
      }
      return {
        count: count,
        tileGrids: tiles
      };
    };
    _proto.onAdd = function onAdd() {
      this._sortLayers();
      this._refresh();
      _TileLayer.prototype.onAdd.call(this);
    };
    _proto.onRemove = function onRemove() {
      var _this5 = this;
      this.layers.forEach(function (layer) {
        layer._doRemove();
        layer.off(EVENTS$2, _this5._onLayerShowHide, _this5);
      });
      this.layerMap = {};
      this._groupChildren = [];
      _TileLayer.prototype.onRemove.call(this);
    };
    _proto.getLayer = function getLayer(id) {
      return this.getChildLayer(id);
    };
    _proto.getChildLayer = function getChildLayer(id) {
      var layer = this.layerMap[id];
      if (layer) {
        return layer;
      }
      for (var i = 0; i < this._groupChildren.length; i++) {
        var child = this._groupChildren[i].getChildLayer(id);
        if (child) {
          return child;
        }
      }
      return null;
    };
    _proto._removeChildTileCache = function _removeChildTileCache(layer) {
      if (!layer) {
        return this;
      }
      var renderer = this.getRenderer();
      if (!renderer) {
        return this;
      }
      var cache;
      var id = layer.getId();
      var validateCache = function validateCache() {
        return cache && cache.info && cache.info.layer === id;
      };
      if (renderer.tileCache) {
        var keys = renderer.tileCache.keys();
        keys.forEach(function (key) {
          cache = renderer.tileCache.get(key);
          if (validateCache()) {
            renderer.tileCache.remove(key);
          }
        });
      }
      var tilesInView = renderer.tilesInView || {};
      for (var key in tilesInView) {
        cache = tilesInView[key];
        if (validateCache()) {
          delete tilesInView[key];
        }
      }
      var tilesLoading = renderer.tilesLoading || {};
      for (var _key in tilesLoading) {
        cache = tilesLoading[_key];
        if (validateCache()) {
          renderer.abortTileLoading(cache.image, cache.info);
        }
      }
      return this;
    };
    _proto._onLayerShowHide = function _onLayerShowHide(e) {
      var _ref = e || {},
        type = _ref.type,
        target = _ref.target;
      if (type === 'remove' && target) {
        this.layers.splice(this.layers.indexOf(target), 1);
        target._doRemove();
        target.off(EVENTS$2, this._onLayerShowHide, this);
        this._refresh();
      } else if (type === 'setzindex') {
        this._sortLayers();
      } else if (type === 'forcereloadstart') {
        this._removeChildTileCache(target);
      }
      this._renderLayers();
      return this;
    };
    _proto._renderLayers = function _renderLayers() {
      var renderer = this.getRenderer();
      if (renderer) {
        renderer.setToRedraw();
      }
      return this;
    };
    _proto._refresh = function _refresh() {
      var _this6 = this;
      var map = this.getMap();
      this._groupChildren = [];
      this.layerMap = {};
      this.layers.forEach(function (layer) {
        _this6.layerMap[layer.getId()] = layer;
        if (layer.getChildLayer) {
          _this6._groupChildren.push(layer);
        }
        if (!layer.getMap()) {
          layer._bindMap(map);
        }
        layer.off(EVENTS$2, _this6._onLayerShowHide, _this6);
        layer.on(EVENTS$2, _this6._onLayerShowHide, _this6);
      });
      return this;
    };
    _proto.isVisible = function isVisible() {
      if (!_TileLayer.prototype.isVisible.call(this)) {
        return false;
      }
      var children = this.layers;
      for (var i = 0, l = children.length; i < l; i++) {
        if (children[i].isVisible()) {
          return true;
        }
      }
      return false;
    };
    _proto._checkChildren = function _checkChildren() {
      var _this7 = this;
      var ids = {};
      this.layers.forEach(function (layer) {
        var layerId = layer.getId();
        if (ids[layerId]) {
          throw new Error("Duplicate child layer id (" + layerId + ") in the GroupTileLayer (" + _this7.getId() + ")");
        } else {
          ids[layerId] = 1;
        }
      });
    };
    _proto._sortLayers = function _sortLayers() {
      this.layers.sort(function (a, b) {
        return a.options.zIndex - b.options.zIndex;
      });
    };
    return GroupTileLayer;
  }(TileLayer);
  GroupTileLayer.registerJSONType('GroupTileLayer');
  GroupTileLayer.mergeOptions(options$x);

  var options$y = {
    crs: null,
    uppercase: false,
    detectRetina: false
  };
  var defaultWmsParams = {
    service: 'WMS',
    request: 'GetMap',
    layers: '',
    styles: '',
    format: 'image/jpeg',
    transparent: false,
    version: '1.1.1'
  };
  var wmsExcludeParams;
  var WMSTileLayer = function (_TileLayer) {
    _inheritsLoose(WMSTileLayer, _TileLayer);
    function WMSTileLayer(id, options) {
      var _this;
      _this = _TileLayer.call(this, id) || this;
      if (!wmsExcludeParams) {
        wmsExcludeParams = extend({}, _this.options);
      }
      _this.wmsParams = extend({}, defaultWmsParams);
      _this.setOptions(options);
      _this.setZIndex(options.zIndex);
      if (!Browser$1.proxy) {
        _this._optionsHook(options);
      }
      return _this;
    }
    var _proto = WMSTileLayer.prototype;
    _proto._optionsHook = function _optionsHook(options) {
      if (options === void 0) {
        options = {};
      }
      for (var p in options) {
        if (p === 'tileSize') {
          this._tileSize = null;
        }
        if (!(p in wmsExcludeParams)) {
          this.wmsParams[p] = options[p];
        }
      }
      var tileSize = this.getTileSize();
      this.wmsParams.width = tileSize.width;
      this.wmsParams.height = tileSize.height;
      this._wmsVersion = parseFloat(this.wmsParams.version);
      return this;
    };
    _proto.onAdd = function onAdd() {
      var dpr = this.getMap().getDevicePixelRatio();
      var r = options$y.detectRetina ? dpr : 1;
      this.wmsParams.width *= r;
      this.wmsParams.height *= r;
      var crs = this.options.crs || this.getMap().getProjection().code;
      var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
      this.wmsParams[projectionKey] = crs;
      _TileLayer.prototype.onAdd.call(this);
    };
    _proto.getTileUrl = function getTileUrl(x, y, z) {
      var res = this.getSpatialReference().getResolution(z),
        tileConfig = this._getTileConfig(),
        tileExtent = tileConfig.getTilePrjExtent(x, y, res);
      var max = tileExtent.getMax(),
        min = tileExtent.getMin();
      var bbox = (this._wmsVersion >= 1.3 && (this.wmsParams.crs === 'EPSG:4326' || this.wmsParams.crs === 'EPSG:4490') ? [min.y, min.x, max.y, max.x] : [min.x, min.y, max.x, max.y]).join(',');
      var url = _TileLayer.prototype.getTileUrl.call(this, x, y, z);
      return url + getParamString(this.wmsParams, url, this.options.uppercase) + (this.options.uppercase ? '&BBOX=' : '&bbox=') + bbox;
    };
    _proto.toJSON = function toJSON() {
      return {
        'type': 'WMSTileLayer',
        'id': this.getId(),
        'options': this.config()
      };
    };
    WMSTileLayer.fromJSON = function fromJSON(layerJSON) {
      if (!layerJSON || layerJSON['type'] !== 'WMSTileLayer') {
        return null;
      }
      return new WMSTileLayer(layerJSON['id'], layerJSON['options']);
    };
    return WMSTileLayer;
  }(TileLayer);
  WMSTileLayer.registerJSONType('WMSTileLayer');
  WMSTileLayer.mergeOptions(options$y);
  function getParamString(obj, existingUrl, uppercase) {
    var params = [];
    for (var i in obj) {
      params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
    }
    return (!existingUrl || existingUrl.indexOf('?') === -1 ? '?' : '&') + params.join('&');
  }

  var CanvasTileLayer = function (_TileLayer) {
    _inheritsLoose(CanvasTileLayer, _TileLayer);
    function CanvasTileLayer(id, options) {
      var _this;
      _this = _TileLayer.call(this, id, options) || this;
      if (!_this.options.hasOwnProperty('forceRenderOnMoving')) {
        _this.options['forceRenderOnMoving'] = false;
      }
      return _this;
    }
    var _proto = CanvasTileLayer.prototype;
    _proto.drawTile = function drawTile() {};
    _proto.toJSON = function toJSON() {
      return {
        'type': 'CanvasTileLayer',
        'id': this.getId(),
        'options': this.config()
      };
    };
    CanvasTileLayer.fromJSON = function fromJSON(layerJSON) {
      if (!layerJSON || layerJSON['type'] !== 'CanvasTileLayer') {
        return null;
      }
      return new CanvasTileLayer(layerJSON['id'], layerJSON['options']);
    };
    return CanvasTileLayer;
  }(TileLayer);
  CanvasTileLayer.registerJSONType('CanvasTileLayer');

  function createGLContext(canvas, options) {
    var attributes = {
      'alpha': true,
      'stencil': true,
      'preserveDrawingBuffer': true,
      'antialias': false
    };
    var names = ['webgl', 'experimental-webgl'];
    var context = null;
    for (var i = 0; i < names.length; ++i) {
      try {
        context = canvas.getContext(names[i], options || attributes);
      } catch (e) {}
      if (context) {
        break;
      }
    }
    return context;
  }
  function compileShader(gl, type, source) {
    var shader = gl.createShader(type);
    gl.shaderSource(shader, source);
    gl.compileShader(shader);
    var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
    if (!compiled) {
      var error = gl.getShaderInfoLog(shader);
      gl.deleteShader(shader);
      throw new Error('Failed to compile shader: ' + error);
    }
    return shader;
  }
  function createProgram(gl, vert, frag) {
    var vertexShader = compileShader(gl, gl.VERTEX_SHADER, vert);
    var fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, frag);
    if (!vertexShader || !fragmentShader) {
      return null;
    }
    var program = gl.createProgram();
    if (!program) {
      return null;
    }
    gl.attachShader(program, vertexShader);
    gl.attachShader(program, fragmentShader);
    gl.linkProgram(program);
    return {
      program: program,
      vertexShader: vertexShader,
      fragmentShader: fragmentShader
    };
  }
  function enableVertexAttrib(gl, program, attributes) {
    if (Array.isArray(attributes[0])) {
      var FSIZE = Float32Array.BYTES_PER_ELEMENT;
      var STRIDE = 0;
      for (var i = 0; i < attributes.length; i++) {
        STRIDE += attributes[i][1] || 0;
      }
      var offset = 0;
      for (var _i = 0; _i < attributes.length; _i++) {
        var attr = gl.getAttribLocation(program, attributes[_i][0]);
        if (attr < 0) {
          throw new Error('Failed to get the storage location of ' + attributes[_i][0]);
        }
        gl.vertexAttribPointer(attr, attributes[_i][1], gl[attributes[_i][2] || 'FLOAT'], false, FSIZE * STRIDE, FSIZE * offset);
        offset += attributes[_i][1] || 0;
        gl.enableVertexAttribArray(attr);
      }
    } else {
      var _attr = gl.getAttribLocation(program, attributes[0]);
      gl.vertexAttribPointer(_attr, attributes[1], gl[attributes[2] || 'FLOAT'], false, 0, 0);
      gl.enableVertexAttribArray(_attr);
    }
  }
  var DEPTH_FUNC_CONSTANTS = {
    'never': 0x0200,
    '<': 0x0201,
    '=': 0x0202,
    '<=': 0x0203,
    '>': 0x0204,
    '!=': 0x0205,
    '>=': 0x0206,
    'always': 0x0207
  };
  function getDepthFunc(v) {
    return DEPTH_FUNC_CONSTANTS[v];
  }

  var DEFAULT_BASE_COLOR = [1, 1, 1, 1];
  var shaders = {
    'vertexShader': "\n        attribute vec2 a_position;\n\n        attribute vec2 a_texCoord;\n\n        uniform mat4 u_matrix;\n\n        varying vec2 v_texCoord;\n\n        void main() {\n            gl_Position = u_matrix * vec4(a_position, 0., 1.);\n\n            v_texCoord = a_texCoord;\n        }\n    ",
    'fragmentShader': "\n        precision mediump float;\n\n        uniform sampler2D u_image;\n\n        uniform float u_opacity;\n        uniform float u_debug_line;\n        uniform vec4 u_base_color;\n        uniform float u_alpha_test;\n        varying vec2 v_texCoord;\n\n        void main() {\n            if (u_debug_line == 1.) {\n                gl_FragColor = vec4(0., 1., 0., 1.);\n            } else {\n                gl_FragColor = texture2D(u_image, v_texCoord) * u_opacity;\n            }\n            gl_FragColor *= u_base_color;\n            if (gl_FragColor.a < u_alpha_test) {\n                discard;\n            }\n        }\n    "
  };
  var v2 = [0, 0],
    v3 = [0, 0, 0],
    arr16 = new Array(16);
  var DEBUG_POINT = new Point(20, 20);
  var ImageGLRenderable = function ImageGLRenderable(Base) {
    var renderable = function (_Base) {
      _inheritsLoose(renderable, _Base);
      function renderable() {
        return _Base.apply(this, arguments) || this;
      }
      var _proto = renderable.prototype;
      _proto.drawGLImage = function drawGLImage(image, x, y, w, h, scale$$1, opacity, debug, baseColor) {
        if (this.gl.program !== this.program) {
          this.useProgram(this.program);
        }
        var gl = this.gl;
        this.loadTexture(image);
        var inGroup = this.canvas.gl && this.canvas.gl.wrap;
        if (inGroup) {
          var layerOpacity = this.layer && this.layer.options['opacity'];
          if (isNil(layerOpacity)) {
            layerOpacity = 1;
          }
          opacity *= layerOpacity;
        }
        v3[0] = x || 0;
        v3[1] = y || 0;
        v3[2] = 0;
        var layer = this.layer;
        if (layer) {
          var altitude = layer.options.altitude;
          var altIsNumber = isNumber(altitude);
          if (!altIsNumber) {
            this._layerAlt = 0;
          }
          if (this._layerAltitude !== altitude && altIsNumber) {
            var map = layer.getMap();
            if (map) {
              var z = map.altitudeToPoint(altitude, map.getGLRes());
              this._layerAltitude = altitude;
              this._layerAlt = z;
            }
          }
        }
        v3[2] = this._layerAlt || 0;
        var uMatrix = identity(arr16);
        translate(uMatrix, uMatrix, v3);
        scale(uMatrix, uMatrix, [scale$$1, scale$$1, 1]);
        multiply(uMatrix, this.getMap().projViewMatrix, uMatrix);
        gl.uniformMatrix4fv(this.program['u_matrix'], false, uMatrix);
        gl.uniform1f(this.program['u_opacity'], opacity);
        gl.uniform1f(this.program['u_debug_line'], 0);
        gl.uniform4fv(this.program['u_base_color'], baseColor || DEFAULT_BASE_COLOR);
        gl.uniform1f(this.program['u_alpha_test'], this.layer.options['alphaTest'] || 0);
        var glBuffer = image.glBuffer;
        if (glBuffer && (glBuffer.width !== w || glBuffer.height !== h)) {
          this.saveImageBuffer(glBuffer);
          delete image.glBuffer;
        }
        if (!image.glBuffer) {
          image.glBuffer = this.bufferTileData(0, 0, w, h);
        } else {
          gl.bindBuffer(gl.ARRAY_BUFFER, glBuffer);
        }
        v2[0] = 'a_position';
        v2[1] = 2;
        v2[2] = image.glBuffer.type;
        this.enableVertexAttrib(v2);
        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
        v2[0] = 'a_texCoord';
        v2[1] = 2;
        v2[2] = 'UNSIGNED_BYTE';
        this.enableVertexAttrib(v2);
        gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
        if (debug) {
          this.drawDebug(uMatrix, 0, 0, w, h, debug);
        }
      };
      _proto.drawDebug = function drawDebug(uMatrix, x, y, w, h, debugInfo) {
        var gl = this.gl;
        gl.disable(gl.DEPTH_TEST);
        gl.bindBuffer(gl.ARRAY_BUFFER, this._debugBuffer);
        this.enableVertexAttrib(['a_position', 2, 'FLOAT']);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([x, y, x + w, y, x + w, y - h, x, y - h, x, y]), gl.DYNAMIC_DRAW);
        gl.uniformMatrix4fv(this.program['u_matrix'], false, uMatrix);
        gl.uniform1f(this.program['u_opacity'], 1);
        gl.uniform1f(this.program['u_debug_line'], 1);
        gl.uniform4fv(this.program['u_base_color'], DEFAULT_BASE_COLOR);
        gl.uniform1f(this.program['u_alpha_test'], this.layer.options['alphaTest'] || 0);
        gl.drawArrays(gl.LINE_STRIP, 0, 5);
        var canvas = this._debugInfoCanvas;
        if (!canvas) {
          var dpr = this.getMap().getDevicePixelRatio() > 1 ? 2 : 1;
          canvas = this._debugInfoCanvas = document.createElement('canvas');
          canvas.width = 256 * dpr;
          canvas.height = 32 * dpr;
          var _ctx = canvas.getContext('2d');
          _ctx.font = '20px monospace';
          _ctx.scale(dpr, dpr);
        }
        var ctx = canvas.getContext('2d');
        ctx.clearRect(0, 0, canvas.width, canvas.height);
        var color = this.layer.options['debugOutline'];
        Canvas.fillText(ctx, debugInfo, DEBUG_POINT, color);
        this.loadTexture(canvas);
        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, canvas);
        w = 256;
        var x1 = x;
        var x2 = x + w;
        var y1 = y - h + 32;
        var y2 = y - h;
        gl.bufferData(gl.ARRAY_BUFFER, this.set8(x1, y1, x1, y2, x2, y1, x2, y2), gl.DYNAMIC_DRAW);
        gl.uniform1f(this.program['u_debug_line'], 0);
        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
        this.enableVertexAttrib(['a_texCoord', 2, 'UNSIGNED_BYTE']);
        gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
        gl.enable(gl.DEPTH_TEST);
      };
      _proto.bufferTileData = function bufferTileData(x, y, w, h, buffer) {
        var x1 = x;
        var x2 = x + w;
        var y1 = y;
        var y2 = y - h;
        var data;
        if (isInteger(x1) && isInteger(x2) && isInteger(y1) && isInteger(y2)) {
          data = this.set8Int(x1, y1, x1, y2, x2, y1, x2, y2);
        } else {
          data = this.set8(x1, y1, x1, y2, x2, y1, x2, y2);
        }
        var glBuffer = this.loadImageBuffer(data, buffer);
        glBuffer.width = w;
        glBuffer.height = h;
        glBuffer.type = data instanceof Int16Array ? 'SHORT' : 'FLOAT';
        return glBuffer;
      };
      _proto.drawTinImage = function drawTinImage(image, vertices, texCoords, indices, opacity) {
        var gl = this.gl;
        this.loadTexture(image);
        gl.uniformMatrix4fv(this.program['u_matrix'], false, this.getMap().projViewMatrix);
        gl.uniform1f(this.program['u_opacity'], opacity);
        gl.bindBuffer(gl.ARRAY_BUFFER, this.posBuffer);
        this.enableVertexAttrib(['a_position', 3]);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.DYNAMIC_DRAW);
        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
        this.enableVertexAttrib(['a_texCoord', 2]);
        gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(texCoords), gl.DYNAMIC_DRAW);
        gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, new Uint16Array(indices), gl.DYNAMIC_DRAW);
        gl.drawElements(gl.TRIANGLES, indices.length, gl.UNSIGNED_SHORT, 0);
      };
      _proto.createCanvas2 = function createCanvas2() {
        this.canvas2 = Canvas.createCanvas(this.canvas.width, this.canvas.height);
      };
      _proto.createGLContext = function createGLContext$$1() {
        if (this.canvas.gl && this.canvas.gl.wrap) {
          this.gl = this.canvas.gl.wrap();
        } else {
          this.gl = createGLContext(this.canvas2 || this.canvas, this.layer.options['glOptions']);
        }
        var gl = this.gl;
        gl.clearColor(0.0, 0.0, 0.0, 0.0);
        gl.enable(gl.DEPTH_TEST);
        gl.enable(gl.STENCIL_TEST);
        gl.enable(gl.BLEND);
        gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
        this.program = this.createProgram(shaders['vertexShader'], this.layer.options['fragmentShader'] || shaders['fragmentShader']);
        this._debugBuffer = this.createBuffer();
        this.useProgram(this.program);
        this.texBuffer = this.createBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, this.texBuffer);
        this.enableVertexAttrib(['a_texCoord', 2, 'UNSIGNED_BYTE']);
        gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([0.0, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0]), gl.STATIC_DRAW);
        this.enableSampler('u_image');
        gl.activeTexture(gl['TEXTURE0']);
        gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, true);
      };
      _proto.resizeGLCanvas = function resizeGLCanvas() {
        if (this.gl) {
          this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
        }
        if (!this.canvas2) {
          return;
        }
        if (this.canvas2.width !== this.canvas.width || this.canvas2.height !== this.canvas.height) {
          this.canvas2.width = this.canvas.width;
          this.canvas2.height = this.canvas.height;
        }
      };
      _proto.clearGLCanvas = function clearGLCanvas() {
        if (this.gl) {
          this.gl.clearStencil(0xFF);
          this.gl.clear(this.gl.COLOR_BUFFER_BIT | this.gl.STENCIL_BUFFER_BIT);
        }
        if (!this.gl.wrap) {
          this.gl.clear(this.gl.DEPTH_BUFFER_BIT);
        }
      };
      _proto.disposeImage = function disposeImage(image) {
        if (!image) {
          return;
        }
        if (image.texture) {
          this.saveTexture(image.texture);
        }
        if (image.glBuffer) {
          this.saveImageBuffer(image.glBuffer);
        }
        delete image.texture;
        delete image.glBuffer;
      };
      _proto._createTexture = function _createTexture(image) {
        var gl = this.gl;
        var texture = this.getTexture() || gl.createTexture();
        gl.bindTexture(gl.TEXTURE_2D, texture);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
        gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
        var genMipmap = this.layer.options['mipmapTexture'];
        if (genMipmap && (!isPowerOfTwo(image.width) || !isPowerOfTwo(image.height))) {
          image = resize(image);
        }
        gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
        if (genMipmap) {
          gl.generateMipmap(gl.TEXTURE_2D);
        }
        return texture;
      };
      _proto.getTexture = function getTexture() {
        if (!this._textures) {
          this._textures = [];
        }
        var textures = this._textures;
        return textures && textures.length > 0 ? textures.pop() : null;
      };
      _proto.saveTexture = function saveTexture(texture) {
        this._textures.push(texture);
      };
      _proto.loadTexture = function loadTexture(image) {
        var map = this.getMap();
        var gl = this.gl;
        var texture = image.texture;
        if (!texture) {
          texture = this._createTexture(image);
          image.texture = texture;
        }
        gl.bindTexture(gl.TEXTURE_2D, texture);
        var genMipmap = this.layer.options['mipmapTexture'];
        if (genMipmap) {
          if (map.isMoving() && map.getRenderer().isViewChanged()) {
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_LINEAR);
          } else {
            gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
          }
        }
        return texture;
      };
      _proto.getImageBuffer = function getImageBuffer() {
        if (!this._imageBuffers) {
          this._imageBuffers = [];
        }
        var imageBuffers = this._imageBuffers;
        return imageBuffers && imageBuffers.length > 0 ? imageBuffers.pop() : null;
      };
      _proto.saveImageBuffer = function saveImageBuffer(buffer) {
        if (!this._imageBuffers) {
          this._imageBuffers = [];
        }
        this._imageBuffers.push(buffer);
      };
      _proto.loadImageBuffer = function loadImageBuffer(data, glBuffer) {
        var gl = this.gl;
        var buffer = glBuffer || this.createImageBuffer();
        gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
        gl.bufferData(gl.ARRAY_BUFFER, data, gl.STATIC_DRAW);
        return buffer;
      };
      _proto.createImageBuffer = function createImageBuffer() {
        return this.getImageBuffer() || this.createBuffer();
      };
      _proto.removeGLCanvas = function removeGLCanvas() {
        var gl = this.gl;
        if (!gl) {
          return;
        }
        if (this._debugBuffer) {
          gl.deleteBuffer(this._debugBuffer);
          delete this._debugBuffer;
        }
        if (this._buffers) {
          this._buffers.forEach(function (b) {
            gl.deleteBuffer(b);
          });
          delete this._buffers;
        }
        if (this._textures) {
          this._textures.forEach(function (t) {
            return gl.deleteTexture(t);
          });
          delete this._textures;
        }
        if (this._debugInfoCanvas) {
          var texture = this._debugInfoCanvas.texture;
          if (texture) {
            gl.deleteTexture(texture);
          }
          delete this._debugInfoCanvas.texture;
          delete this._debugInfoCanvas;
        }
        var program = gl.program;
        gl.deleteShader(program.fragmentShader);
        gl.deleteShader(program.vertexShader);
        gl.deleteProgram(program);
        delete this.gl;
        delete this.canvas2;
      };
      _proto.createBuffer = function createBuffer() {
        var gl = this.gl;
        var buffer = gl.createBuffer();
        if (!buffer) {
          throw new Error('Failed to create the buffer object');
        }
        if (!this._buffers) {
          this._buffers = [];
        }
        this._buffers.push(buffer);
        return buffer;
      };
      _proto.enableVertexAttrib = function enableVertexAttrib$$1(attributes) {
        enableVertexAttrib(this.gl, this.gl.program, attributes);
      };
      _proto.createProgram = function createProgram$$1(vert, frag) {
        var gl = this.gl;
        var _createProgram2 = createProgram(gl, vert, frag),
          program = _createProgram2.program,
          vertexShader = _createProgram2.vertexShader,
          fragmentShader = _createProgram2.fragmentShader;
        var numUniforms = gl.getProgramParameter(program, 0x8B86);
        var activeUniforms = [];
        for (var i = 0; i < numUniforms; ++i) {
          var info = gl.getActiveUniform(program, i);
          activeUniforms.push(info.name);
        }
        program.vertexShader = vertexShader;
        program.fragmentShader = fragmentShader;
        this._initUniforms(program, activeUniforms);
        return program;
      };
      _proto.useProgram = function useProgram(program) {
        var gl = this.gl;
        gl.useProgram(program);
        gl.program = program;
        return this;
      };
      _proto.enableSampler = function enableSampler(sampler, texIdx) {
        var gl = this.gl;
        var uSampler = this._getUniform(gl.program, sampler);
        if (!texIdx) {
          texIdx = 0;
        }
        gl.uniform1i(uSampler, texIdx);
        return uSampler;
      };
      _proto._initUniforms = function _initUniforms(program, uniforms) {
        for (var i = 0; i < uniforms.length; i++) {
          var name = uniforms[i];
          var uniform = uniforms[i];
          var b = name.indexOf('[');
          if (b >= 0) {
            name = name.substring(0, b);
            if (!IS_NODE) {
              uniform = uniform.substring(0, b);
            }
          }
          program[name] = this._getUniform(program, uniform);
        }
      };
      _proto._getUniform = function _getUniform(program, uniformName) {
        var gl = this.gl;
        var uniform = gl.getUniformLocation(program, uniformName);
        if (!uniform) {
          throw new Error('Failed to get the storage location of ' + uniformName);
        }
        return uniform;
      };
      return renderable;
    }(Base);
    extend(renderable.prototype, {
      set8: function () {
        var out = Browser$1.ie9 ? null : new Float32Array(8);
        return function (a0, a1, a2, a3, a4, a5, a6, a7) {
          out[0] = a0;
          out[1] = a1;
          out[2] = a2;
          out[3] = a3;
          out[4] = a4;
          out[5] = a5;
          out[6] = a6;
          out[7] = a7;
          return out;
        };
      }(),
      set8Int: function () {
        var out = Browser$1.ie9 ? null : new Int16Array(8);
        return function (a0, a1, a2, a3, a4, a5, a6, a7) {
          out[0] = a0;
          out[1] = a1;
          out[2] = a2;
          out[3] = a3;
          out[4] = a4;
          out[5] = a5;
          out[6] = a6;
          out[7] = a7;
          return out;
        };
      }()
    });
    return renderable;
  };
  function resize(image) {
    if (isPowerOfTwo(image.width) && isPowerOfTwo(image.height)) {
      return image;
    }
    var width = image.width;
    var height = image.height;
    if (!isPowerOfTwo(width)) {
      width = ceilPowerOfTwo(width);
    }
    if (!isPowerOfTwo(height)) {
      height = ceilPowerOfTwo(height);
    }
    var canvas = document.createElement('canvas');
    canvas.width = width;
    canvas.height = height;
    var ctx = canvas.getContext('2d');
    ctx.imageSmoothingEnabled = false;
    ctx.drawImage(image, 0, 0, width, height);
    return canvas;
  }
  function isPowerOfTwo(value) {
    return (value & value - 1) === 0 && value !== 0;
  }
  function ceilPowerOfTwo(value) {
    return Math.pow(2, Math.ceil(Math.log(value) / Math.LN2));
  }

  var options$z = {
    renderer: Browser$1.webgl ? 'gl' : 'canvas',
    crossOrigin: null,
    alphaTest: 0,
    depthMask: true,
    depthFunc: '<='
  };
  var TEMP_POINT$3 = new Point(0, 0);
  var ImageLayer = function (_Layer) {
    _inheritsLoose(ImageLayer, _Layer);
    function ImageLayer(id, images, options) {
      var _this;
      if (images && !Array.isArray(images) && !images.url) {
        options = images;
        images = null;
      }
      _this = _Layer.call(this, id, options) || this;
      _this._images = images;
      return _this;
    }
    var _proto = ImageLayer.prototype;
    _proto.onAdd = function onAdd() {
      this._prepareImages(this._images);
    };
    _proto.setImages = function setImages(images) {
      this._images = images;
      this._prepareImages(images);
      return this;
    };
    _proto.getImages = function getImages() {
      return this._images;
    };
    _proto._prepareImages = function _prepareImages(images) {
      images = images || [];
      if (!Array.isArray(images)) {
        images = [images];
      }
      var map = this.getMap();
      var glRes = map.getGLRes();
      this._imageData = images.map(function (img) {
        var extent = new Extent(img.extent);
        return extend({}, img, {
          extent: extent,
          extent2d: extent.convertTo(function (c) {
            return map.coordToPointAtRes(c, glRes);
          })
        });
      });
      this._images = images;
      var renderer = this.getRenderer();
      if (renderer) {
        renderer.refreshImages();
      }
    };
    return ImageLayer;
  }(Layer);
  ImageLayer.mergeOptions(options$z);
  var EMPTY_ARRAY$1 = [];
  var ImageLayerCanvasRenderer = function (_CanvasRenderer) {
    _inheritsLoose(ImageLayerCanvasRenderer, _CanvasRenderer);
    function ImageLayerCanvasRenderer() {
      return _CanvasRenderer.apply(this, arguments) || this;
    }
    var _proto2 = ImageLayerCanvasRenderer.prototype;
    _proto2.isDrawable = function isDrawable() {
      if (this.getMap().getPitch()) {
        if (console) {
          console.warn('ImageLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
        }
        return false;
      }
      return true;
    };
    _proto2.checkResources = function checkResources() {
      var _this2 = this;
      if (this._imageLoaded) {
        return EMPTY_ARRAY$1;
      }
      var layer = this.layer;
      var urls = layer._imageData.map(function (img) {
        return [img.url, null, null];
      });
      if (this.resources) {
        var unloaded = [];
        var resources = new ResourceCache();
        urls.forEach(function (url) {
          if (_this2.resources.isResourceLoaded(url)) {
            var img = _this2.resources.getImage(url);
            resources.addResource(url, img);
          } else {
            unloaded.push(url);
          }
        });
        this.resources.forEach(function (url, res) {
          if (!resources.isResourceLoaded(url)) {
            _this2.retireImage(res.image);
          }
        });
        this.resources = resources;
        urls = unloaded;
      }
      this._imageLoaded = true;
      return urls;
    };
    _proto2.retireImage = function retireImage(image) {
      if (image.close) {
        image.close();
      }
    };
    _proto2.refreshImages = function refreshImages() {
      this._imageLoaded = false;
      this.setToRedraw();
    };
    _proto2.draw = function draw(timestamp, context) {
      if (!this.isDrawable()) {
        return;
      }
      this.prepareCanvas();
      this._painted = false;
      this._drawImages(timestamp, context);
      this.completeRender();
    };
    _proto2._drawImages = function _drawImages() {
      var imgData = this.layer._imageData;
      var map = this.getMap();
      var mapExtent = map._get2DExtentAtRes(map.getGLRes());
      if (imgData && imgData.length) {
        for (var i = 0; i < imgData.length; i++) {
          var extent = imgData[i].extent2d;
          var image = this.resources && this.resources.getImage(imgData[i].url);
          if (image && mapExtent.intersects(extent)) {
            this._painted = true;
            this._drawImage(image, extent, imgData[i].opacity || 1);
          }
        }
      }
    };
    _proto2._drawImage = function _drawImage(image, extent, opacity) {
      var globalAlpha = 0;
      var ctx = this.context;
      if (opacity < 1) {
        globalAlpha = ctx.globalAlpha;
        ctx.globalAlpha = opacity;
      }
      var map = this.getMap();
      var nw = TEMP_POINT$3.set(extent.xmin, extent.ymax);
      var point = map._pointAtResToContainerPoint(nw, map.getGLRes());
      var x = point.x,
        y = point.y;
      var bearing = map.getBearing();
      if (bearing) {
        ctx.save();
        ctx.translate(x, y);
        if (bearing) {
          ctx.rotate(-bearing * Math.PI / 180);
        }
        x = y = 0;
      }
      var scale = map.getGLScale();
      ctx.drawImage(image, x, y, extent.getWidth() / scale, extent.getHeight() / scale);
      if (bearing) {
        ctx.restore();
      }
      if (globalAlpha) {
        ctx.globalAlpha = globalAlpha;
      }
    };
    _proto2.drawOnInteracting = function drawOnInteracting() {
      this.draw();
    };
    return ImageLayerCanvasRenderer;
  }(CanvasRenderer);
  var ImageLayerGLRenderer = function (_ImageGLRenderable) {
    _inheritsLoose(ImageLayerGLRenderer, _ImageGLRenderable);
    function ImageLayerGLRenderer() {
      return _ImageGLRenderable.apply(this, arguments) || this;
    }
    var _proto3 = ImageLayerGLRenderer.prototype;
    _proto3.drawOnInteracting = function drawOnInteracting(event, timestamp, context) {
      this.draw(timestamp, context);
    };
    _proto3._prepareGLContext = function _prepareGLContext() {
      var gl = this.gl;
      if (gl) {
        gl.disable(gl.STENCIL_TEST);
        gl.disable(gl.POLYGON_OFFSET_FILL);
        gl.enable(gl.DEPTH_TEST);
        gl.enable(gl.BLEND);
        gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
        gl.depthFunc(getDepthFunc(this.layer.options['depthFunc']));
        var depthMask = !!this.layer.options['depthMask'];
        gl.depthMask(depthMask);
      }
    };
    _proto3._drawImages = function _drawImages(timestamp, parentContext) {
      var gl = this.gl;
      if (parentContext && parentContext.renderTarget) {
        var fbo = parentContext.renderTarget.fbo;
        if (fbo) {
          var framebuffer = parentContext.renderTarget.getFramebuffer(fbo);
          gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
        }
      }
      this._prepareGLContext();
      _ImageGLRenderable.prototype._drawImages.call(this);
      if (parentContext && parentContext.renderTarget) {
        var _fbo = parentContext.renderTarget.fbo;
        if (_fbo) {
          gl.bindFramebuffer(gl.FRAMEBUFFER, null);
        }
      }
    };
    _proto3.isDrawable = function isDrawable() {
      return true;
    };
    _proto3._drawImage = function _drawImage(image, extent, opacity) {
      this.drawGLImage(image, extent.xmin, extent.ymax, extent.getWidth(), extent.getHeight(), 1, opacity);
    };
    _proto3.createContext = function createContext() {
      this.createGLContext();
    };
    _proto3.resizeCanvas = function resizeCanvas(canvasSize) {
      if (!this.canvas) {
        return;
      }
      _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
      this.resizeGLCanvas();
    };
    _proto3.clearCanvas = function clearCanvas() {
      if (!this.canvas) {
        return;
      }
      _ImageGLRenderable.prototype.clearCanvas.call(this);
      this.clearGLCanvas();
    };
    _proto3.retireImage = function retireImage(image) {
      if (image.close) {
        image.close();
      }
      this.disposeImage(image);
    };
    _proto3.onRemove = function onRemove() {
      this.removeGLCanvas();
      _ImageGLRenderable.prototype.onRemove.call(this);
    };
    return ImageLayerGLRenderer;
  }(ImageGLRenderable(ImageLayerCanvasRenderer));
  ImageLayer.registerRenderer('canvas', ImageLayerCanvasRenderer);
  ImageLayer.registerRenderer('gl', ImageLayerGLRenderer);

  var CanvasLayerRenderer = function (_CanvasRenderer) {
    _inheritsLoose(CanvasLayerRenderer, _CanvasRenderer);
    function CanvasLayerRenderer() {
      return _CanvasRenderer.apply(this, arguments) || this;
    }
    var _proto = CanvasLayerRenderer.prototype;
    _proto.getPrepareParams = function getPrepareParams() {
      return [];
    };
    _proto.getDrawParams = function getDrawParams() {
      return [];
    };
    _proto.onCanvasCreate = function onCanvasCreate() {
      if (this.canvas && this.layer.options['doubleBuffer']) {
        this.buffer = Canvas.createCanvas(this.canvas.width, this.canvas.height, this.getMap().CanvasClass);
      }
    };
    _proto.needToRedraw = function needToRedraw() {
      if (this.layer.options['animation']) {
        return true;
      }
      var map = this.getMap();
      if (map.isInteracting() && !this.layer.drawOnInteracting) {
        return false;
      }
      return _CanvasRenderer.prototype.needToRedraw.call(this);
    };
    _proto.draw = function draw() {
      this.prepareCanvas();
      this.prepareDrawContext();
      this._drawLayer.apply(this, arguments);
    };
    _proto.drawOnInteracting = function drawOnInteracting() {
      this._drawLayerOnInteracting.apply(this, arguments);
    };
    _proto.getCanvasImage = function getCanvasImage() {
      var canvasImg = _CanvasRenderer.prototype.getCanvasImage.call(this);
      if (canvasImg && canvasImg.image && this.layer.options['doubleBuffer']) {
        var canvas = canvasImg.image;
        if (this.buffer.width !== canvas.width || this.buffer.height !== canvas.height) {
          this.buffer.width = canvas.width;
          this.buffer.height = canvas.height;
        }
        var bufferContext = this.buffer.getContext('2d');
        var prevent = this.layer.doubleBuffer(bufferContext, this.context);
        if (prevent === undefined || prevent) {
          Canvas.image(bufferContext, canvas, 0, 0);
          canvasImg.image = this.buffer;
        }
      }
      return canvasImg;
    };
    _proto.remove = function remove() {
      delete this._drawContext;
      return _CanvasRenderer.prototype.remove.call(this);
    };
    _proto.onZoomStart = function onZoomStart(param) {
      this.layer.onZoomStart(param);
      _CanvasRenderer.prototype.onZoomStart.call(this, param);
    };
    _proto.onZooming = function onZooming(param) {
      this.layer.onZooming(param);
      _CanvasRenderer.prototype.onZooming.call(this, param);
    };
    _proto.onZoomEnd = function onZoomEnd(param) {
      this.layer.onZoomEnd(param);
      _CanvasRenderer.prototype.onZoomEnd.call(this, param);
    };
    _proto.onMoveStart = function onMoveStart(param) {
      this.layer.onMoveStart(param);
      _CanvasRenderer.prototype.onMoveStart.call(this, param);
    };
    _proto.onMoving = function onMoving(param) {
      this.layer.onMoving(param);
      _CanvasRenderer.prototype.onMoving.call(this, param);
    };
    _proto.onMoveEnd = function onMoveEnd(param) {
      this.layer.onMoveEnd(param);
      _CanvasRenderer.prototype.onMoveEnd.call(this, param);
    };
    _proto.onResize = function onResize(param) {
      this.layer.onResize(param);
      _CanvasRenderer.prototype.onResize.call(this, param);
    };
    _proto.prepareDrawContext = function prepareDrawContext() {
      if (!this._predrawed) {
        var params = ensureParams(this.getPrepareParams());
        this._drawContext = this.layer.prepareToDraw.apply(this.layer, [this.context].concat(params));
        if (!this._drawContext) {
          this._drawContext = [];
        }
        if (!Array.isArray(this._drawContext)) {
          this._drawContext = [this._drawContext];
        }
        this._predrawed = true;
      }
    };
    _proto._prepareDrawParams = function _prepareDrawParams() {
      if (!this.getMap()) {
        return null;
      }
      var view = this.getViewExtent();
      if (view['maskExtent'] && !view['extent'].intersects(view['maskExtent'])) {
        this.completeRender();
        return null;
      }
      var args = [this.context, view];
      var params = ensureParams(this.getDrawParams());
      args.push.apply(args, params);
      args.push.apply(args, this._drawContext);
      return args;
    };
    _proto._drawLayer = function _drawLayer() {
      var params = this._prepareDrawParams();
      if (!params) {
        return;
      }
      for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
        args[_key] = arguments[_key];
      }
      this.layer.draw.apply(this.layer, params.concat(args));
      this.completeRender();
    };
    _proto._drawLayerOnInteracting = function _drawLayerOnInteracting() {
      if (!this.layer.drawOnInteracting) {
        return;
      }
      var params = this._prepareDrawParams();
      if (!params) {
        return;
      }
      for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
        args[_key2] = arguments[_key2];
      }
      this.layer.drawOnInteracting.apply(this.layer, params.concat(args));
      this.completeRender();
    };
    return CanvasLayerRenderer;
  }(CanvasRenderer);
  function ensureParams(params) {
    if (!params) {
      params = [];
    }
    if (!Array.isArray(params)) {
      params = [params];
    }
    return params;
  }

  var options$A = {
    'doubleBuffer': false,
    'animation': false
  };
  var CanvasLayer = function (_Layer) {
    _inheritsLoose(CanvasLayer, _Layer);
    function CanvasLayer() {
      return _Layer.apply(this, arguments) || this;
    }
    var _proto = CanvasLayer.prototype;
    _proto.isCanvasRender = function isCanvasRender() {
      return true;
    };
    _proto.prepareToDraw = function prepareToDraw() {};
    _proto.draw = function draw() {};
    _proto.redraw = function redraw() {
      if (this._getRenderer()) {
        this._getRenderer().setToRedraw();
      }
      return this;
    };
    _proto.play = function play() {
      this.config('animation', true);
      return this;
    };
    _proto.pause = function pause() {
      this.config('animation', false);
      return this;
    };
    _proto.isPlaying = function isPlaying() {
      return this.options['animation'];
    };
    _proto.clearCanvas = function clearCanvas() {
      if (this._getRenderer()) {
        this._getRenderer().clearCanvas();
      }
      return this;
    };
    _proto.requestMapToRender = function requestMapToRender() {
      if (this._getRenderer()) {
        this._getRenderer().requestMapToRender();
      }
      return this;
    };
    _proto.completeRender = function completeRender() {
      if (this._getRenderer()) {
        this._getRenderer().completeRender();
      }
      return this;
    };
    _proto.onCanvasCreate = function onCanvasCreate() {
      return this;
    };
    _proto.onZoomStart = function onZoomStart() {};
    _proto.onZooming = function onZooming() {};
    _proto.onZoomEnd = function onZoomEnd() {};
    _proto.onMoveStart = function onMoveStart() {};
    _proto.onMoving = function onMoving() {};
    _proto.onMoveEnd = function onMoveEnd() {};
    _proto.onResize = function onResize() {};
    _proto.doubleBuffer = function doubleBuffer(bufferContext) {
      bufferContext.clearRect(0, 0, bufferContext.canvas.width, bufferContext.canvas.height);
      return this;
    };
    return CanvasLayer;
  }(Layer);
  CanvasLayer.mergeOptions(options$A);
  CanvasLayer.registerRenderer('canvas', CanvasLayerRenderer);

  var TEMP_POINT$4 = new Point(0, 0);
  var options$B = {
    'animation': true
  };
  var ParticleLayer = function (_CanvasLayer) {
    _inheritsLoose(ParticleLayer, _CanvasLayer);
    function ParticleLayer() {
      return _CanvasLayer.apply(this, arguments) || this;
    }
    var _proto = ParticleLayer.prototype;
    _proto.getParticles = function getParticles() {};
    _proto.draw = function draw(context, view) {
      var points = this.getParticles(now());
      if (!points || points.length === 0) {
        var renderer = this._getRenderer();
        if (renderer) {
          this._getRenderer()._shouldClear = true;
        }
        return;
      }
      var map = this.getMap();
      var extent = view.extent;
      if (view.maskExtent) {
        extent = view.extent.intersection(view.maskExtent);
      }
      extent = extent.convertTo(function (c) {
        return map._pointToContainerPoint(c, undefined, 0, TEMP_POINT$4);
      });
      var e = 2 * Math.PI;
      for (var i = 0, l = points.length; i < l; i++) {
        var pos = points[i].point;
        if (extent.contains(pos)) {
          var color = points[i].color || this.options['lineColor'] || '#fff',
            r = points[i].r;
          if (context.fillStyle !== color) {
            context.fillStyle = color;
          }
          if (r <= 2) {
            context.fillRect(pos.x - r / 2, pos.y - r / 2, r, r);
          } else {
            context.beginPath();
            context.arc(pos.x, pos.y, r / 2, 0, e);
            context.fill();
          }
        }
      }
      this._fillCanvas(context);
    };
    _proto._fillCanvas = function _fillCanvas(context) {
      var g = context.globalCompositeOperation;
      context.globalCompositeOperation = 'destination-out';
      var trail = this.options['trail'] || 30;
      context.fillStyle = 'rgba(0, 0, 0, ' + 1 / trail + ')';
      context.fillRect(0, 0, context.canvas.width, context.canvas.height);
      context.globalCompositeOperation = g;
    };
    return ParticleLayer;
  }(CanvasLayer);
  ParticleLayer.mergeOptions(options$B);
  ParticleLayer.registerRenderer('canvas', function (_CanvasLayerRenderer) {
    _inheritsLoose(_class, _CanvasLayerRenderer);
    function _class() {
      return _CanvasLayerRenderer.apply(this, arguments) || this;
    }
    var _proto2 = _class.prototype;
    _proto2.draw = function draw() {
      if (!this.canvas || !this.layer.options['animation'] || this._shouldClear) {
        this.prepareCanvas();
        this._shouldClear = false;
      }
      this.prepareDrawContext();
      this._drawLayer();
    };
    _proto2.drawOnInteracting = function drawOnInteracting() {
      this.draw();
      this._shouldClear = false;
    };
    _proto2.onSkipDrawOnInteracting = function onSkipDrawOnInteracting() {
      this._shouldClear = true;
    };
    return _class;
  }(CanvasLayerRenderer));

  var resources = new ResourceCache();
  var prevX, prevY;
  var EditHandle = function (_Eventable) {
    _inheritsLoose(EditHandle, _Eventable);
    function EditHandle(target, map, options) {
      var _this;
      _this = _Eventable.call(this, options) || this;
      _this.target = target;
      target.once('remove', _this.delete, _assertThisInitialized(_assertThisInitialized(_this)));
      var symbol = _this.options['symbol'];
      var lineWidth = symbol['markerLineWidth'] || 1;
      _this.w = symbol['markerWidth'] + lineWidth;
      _this.h = symbol['markerHeight'] + lineWidth;
      _this.opacity = isNil(symbol['opacity']) ? 1 : symbol['opacity'];
      _this.map = map;
      _this.events = options.events;
      _this._fetchImage();
      _this.addTo(map);
      return _this;
    }
    var _proto = EditHandle.prototype;
    _proto.getCursor = function getCursor() {
      return this.options['cursor'] || 'default';
    };
    _proto._fetchImage = function _fetchImage() {
      var map = this.map;
      var symbol = this.options.symbol;
      var markerFile = symbol.markerFile;
      this.url = markerFile || getSymbolHash(symbol);
      var img = resources.getImage(this.url);
      if (!img) {
        var w = this.w;
        var h = this.h;
        if (markerFile) {
          img = new Image();
          img.onload = function () {
            var renderer = map.getRenderer();
            if (renderer) {
              renderer.setToRedraw();
            }
          };
          img.src = this.url;
        } else {
          var canvas = document.createElement('canvas');
          canvas.width = w;
          canvas.height = h;
          var ctx = canvas.getContext('2d');
          img = drawVectorMarker(ctx, {
            x: w / 2,
            y: h / 2
          }, symbol, resources);
        }
        resources.addResource([this.url, w, h], img);
      }
      resources.login(this.url);
      this._img = img;
    };
    _proto.setContainerPoint = function setContainerPoint(cp) {
      this._point = cp;
      this._point._sub(this.w / 2, this.h / 2);
    };
    _proto.getContainerPoint = function getContainerPoint() {
      return this._point.add(this.w / 2, this.h / 2);
    };
    _proto.offset = function offset(p) {
      this._point._add(p);
    };
    _proto.render = function render(ctx) {
      if (!this._img) {
        return false;
      }
      var symbol = this.options['symbol'];
      var dx = symbol['markerDx'] || 0;
      var dy = symbol['markerDy'] || 0;
      var map = this.map;
      var _this$_point = this._point,
        x = _this$_point.x,
        y = _this$_point.y;
      var w = this.w;
      var h = this.h;
      if (x + w > 0 && x < map.width && y + h > 0 && y < map.height) {
        var dpr = map.getDevicePixelRatio();
        ctx.globalAlpha = this.opacity;
        ctx.drawImage(this._img, Math.round((x + dx) * dpr), Math.round((y + dy) * dpr), Math.round(w * dpr), Math.round(h * dpr));
        return true;
      }
      return false;
    };
    _proto.delete = function _delete() {
      if (this.map) {
        var renderer = this.map.getRenderer();
        if (renderer) {
          renderer.removeTopElement(this);
        }
      }
      resources.logout(this.url);
      if (this._dragger) {
        this._dragger.disable();
        delete this._dragger;
      }
      delete this.map;
    };
    _proto.hitTest = function hitTest(p) {
      var symbol = this.options['symbol'];
      var dx = symbol['markerDx'] || 0;
      var dy = symbol['markerDy'] || 0;
      var w = this.w;
      var h = this.h;
      var x = this._point.x + dx;
      var y = this._point.y + dy;
      return p.x >= x && p.x <= x + w && p.y >= y && p.y <= y + h;
    };
    _proto.addTo = function addTo(map) {
      this.map = map;
      var renderer = map.getRenderer();
      renderer.addTopElement(this);
    };
    _proto.onEvent = function onEvent(e) {
      this.fire(e.type, e);
    };
    _proto.mousedown = function mousedown(e) {
      var map = e.target;
      var cursor = this.options['cursor'];
      if (cursor) {
        map.setCursor(cursor);
      }
      this.onDragstart(e);
    };
    _proto.onDragstart = function onDragstart(e) {
      var containerPoint = e.containerPoint,
        map = e.target;
      var dom = map._panels.mapWrapper || map._containerDOM;
      var dragHandler = this._dragger = new DragHandler(dom);
      dragHandler.on('dragging', this.onDragging, this).on('mouseup', this.onDragend, this).enable();
      dragHandler.type = 'handle';
      dragHandler.onMouseDown(e['domEvent']);
      prevX = containerPoint.x;
      prevY = containerPoint.y;
      this.fire('dragstart', {
        containerPoint: containerPoint
      });
    };
    _proto.onDragging = function onDragging(e) {
      if (!this._dragger) {
        return;
      }
      var activeMap = this.map;
      var containerPoint = getEventContainerPoint(e.domEvent, activeMap._containerDOM);
      var offset = {
        x: containerPoint.x - prevX,
        y: containerPoint.y - prevY
      };
      var prevCoord = activeMap.containerPointToCoord(new Point(prevX, prevY));
      var currentCoord = activeMap.containerPointToCoord(containerPoint);
      prevX = containerPoint.x;
      prevY = containerPoint.y;
      this.offset(offset);
      this.fire('dragging', {
        containerPoint: containerPoint,
        coordOffset: currentCoord._sub(prevCoord)
      });
    };
    _proto.onDragend = function onDragend(e) {
      if (!this._dragger) {
        return;
      }
      var map = this.map;
      map.resetCursor();
      var containerPoint = getEventContainerPoint(e.domEvent, map._containerDOM);
      var offset = {
        x: containerPoint.x - prevX,
        y: containerPoint.y - prevY
      };
      this.offset(offset);
      this._dragger.disable();
      delete this._dragger;
      this.fire('dragend', {
        containerPoint: containerPoint
      });
    };
    return EditHandle;
  }(Eventable(Class));

  var EditOutline = function () {
    function EditOutline(target, map) {
      this.target = target;
      target.once('remove', this.delete, this);
      this.map = map;
      this.addTo(map);
    }
    var _proto = EditOutline.prototype;
    _proto.setPoints = function setPoints(points) {
      this.points = points;
      var allX = points.map(function (p) {
        return p.x;
      });
      var allY = points.map(function (p) {
        return p.y;
      });
      this.xmin = Math.min.apply(Math, allX);
      this.xmax = Math.max.apply(Math, allX);
      this.ymin = Math.min.apply(Math, allY);
      this.ymax = Math.max.apply(Math, allY);
    };
    _proto.hitTest = function hitTest() {
      return false;
    };
    _proto.render = function render(ctx) {
      var map = this.map;
      if (this.xmax <= 0 || this.xmin >= map.width || this.ymax <= 0 || this.ymin >= map.height) {
        return;
      }
      var dpr = map.getDevicePixelRatio();
      var padding = 0.5;
      function c(v) {
        return Math.round(v) * dpr + padding;
      }
      ctx.lineWidth = 1;
      ctx.strokeStyle = '#000';
      ctx.globalAlpha = 1;
      ctx.beginPath();
      var points = this.points;
      ctx.moveTo(c(points[0].x), c(points[0].y));
      for (var i = 1; i < this.points.length; i++) {
        ctx.lineTo(c(points[i].x), c(points[i].y));
      }
      ctx.closePath();
      ctx.stroke();
    };
    _proto.addTo = function addTo(map) {
      this.map = map;
      var renderer = map.getRenderer();
      renderer.addTopElement(this);
    };
    _proto.delete = function _delete() {
      if (this.map) {
        var renderer = this.map.getRenderer();
        if (renderer) {
          renderer.removeTopElement(this);
        }
      }
    };
    return EditOutline;
  }();

  var EDIT_STAGE_LAYER_PREFIX = INTERNAL_LAYER_PREFIX + '_edit_stage_';
  function createHandleSymbol(markerType, opacity) {
    return {
      'markerType': markerType,
      'markerFill': '#fff',
      'markerLineColor': '#000',
      'markerLineWidth': 2,
      'markerWidth': 10,
      'markerHeight': 10,
      'opacity': opacity
    };
  }
  var options$C = {
    'fixAspectRatio': false,
    'symbol': null,
    'removeVertexOn': 'contextmenu',
    'centerHandleSymbol': createHandleSymbol('ellipse', 1),
    'vertexHandleSymbol': createHandleSymbol('square', 1),
    'newVertexHandleSymbol': createHandleSymbol('square', 0.4)
  };
  var GeometryEditor = function (_Eventable) {
    _inheritsLoose(GeometryEditor, _Eventable);
    function GeometryEditor(geometry, opts) {
      var _this;
      _this = _Eventable.call(this, opts) || this;
      _this._geometry = geometry;
      if (!_this._geometry) {
        return _assertThisInitialized(_this);
      }
      return _this;
    }
    var _proto = GeometryEditor.prototype;
    _proto.getMap = function getMap() {
      return this._geometry.getMap();
    };
    _proto.prepare = function prepare() {
      var map = this.getMap();
      if (!map) {
        return;
      }
      map.on('drawtopstart', this._refresh, this);
      if (this.options['symbol']) {
        this._originalSymbol = this._geometry.getSymbol();
        this._geometry.setSymbol(this.options['symbol']);
      }
      this._prepareEditStageLayer();
    };
    _proto._prepareEditStageLayer = function _prepareEditStageLayer() {
      var layer = this._geometry.getLayer();
      if (layer.options['renderer'] !== 'canvas') {
        return;
      }
      var map = this.getMap();
      var uid = UID();
      var shadowId = EDIT_STAGE_LAYER_PREFIX + uid + '_shadow';
      this._shadowLayer = map.getLayer(shadowId);
      if (!this._shadowLayer) {
        var LayerType = layer.constructor;
        this._shadowLayer = new LayerType(shadowId);
        map.addLayer(this._shadowLayer);
      }
    };
    _proto.start = function start() {
      if (!this._geometry || !this._geometry.getMap() || this._geometry.editing) {
        return;
      }
      this.editing = true;
      this.prepare();
      var geometry = this._geometry;
      var shadow;
      var layer = this._geometry.getLayer();
      var needShadow = layer.options['renderer'] === 'canvas';
      this._geometryDraggble = geometry.options['draggable'];
      if (needShadow) {
        geometry.config('draggable', false);
        shadow = geometry.copy();
        shadow.setSymbol(geometry._getInternalSymbol());
        shadow.copyEventListeners(geometry);
        if (geometry._getParent()) {
          shadow.copyEventListeners(geometry._getParent());
        }
        shadow._setEventTarget(geometry);
        shadow.setId(null).config({
          'draggable': false
        });
        this._shadow = shadow;
        geometry.hide();
      } else if (geometry instanceof Marker) {
        geometry.config('draggable', true);
      }
      this._switchGeometryEvents('on');
      if (geometry instanceof Marker || geometry instanceof Circle || geometry instanceof Rectangle || geometry instanceof Ellipse) {
        this._createOrRefreshOutline();
      }
      if (this._shadowLayer) {
        this._shadowLayer.bringToFront().addGeometry(shadow);
      }
      if (!(geometry instanceof Marker)) {
        this._createCenterHandle();
      } else if (shadow) {
        shadow.config('draggable', true);
        shadow.on('dragend', this._onMarkerDragEnd, this);
      }
      if (geometry instanceof Marker && this.options['resize'] !== false) {
        this.createMarkerEditor();
      } else if (geometry instanceof Circle) {
        this.createCircleEditor();
      } else if (geometry instanceof Rectangle) {
        this.createEllipseOrRectEditor();
      } else if (geometry instanceof Ellipse) {
        this.createEllipseOrRectEditor();
      } else if (geometry instanceof Sector) ; else if (geometry instanceof Polygon || geometry instanceof LineString) {
        this.createPolygonEditor();
      }
    };
    _proto.stop = function stop() {
      delete this._history;
      delete this._historyPointer;
      delete this._editOutline;
      this._switchGeometryEvents('off');
      var map = this.getMap();
      if (!map) {
        this.fire('remove');
        return;
      }
      this._geometry.config('draggable', this._geometryDraggble);
      if (this._shadow) {
        delete this._shadow;
        delete this._geometryDraggble;
        this._geometry.show();
      }
      if (this._shadowLayer) {
        this._shadowLayer.remove();
        delete this._shadowLayer;
      }
      this._refreshHooks = [];
      if (this.options['symbol']) {
        this._geometry.setSymbol(this._originalSymbol);
        delete this._originalSymbol;
      }
      this.editing = false;
      this.fire('remove');
    };
    _proto.isEditing = function isEditing() {
      if (isNil(this.editing)) {
        return false;
      }
      return this.editing;
    };
    _proto._getGeometryEvents = function _getGeometryEvents() {
      return {
        'symbolchange': this._onGeoSymbolChange,
        'dragstart': this._onDragStart,
        'dragend': this._onDragEnd,
        'positionchange shapechange': this._exeAndReset
      };
    };
    _proto._switchGeometryEvents = function _switchGeometryEvents(oper) {
      if (this._geometry) {
        var events = this._getGeometryEvents();
        for (var p in events) {
          this._geometry[oper](p, events[p], this);
        }
      }
    };
    _proto._onGeoSymbolChange = function _onGeoSymbolChange(param) {
      if (this._shadow) {
        this._shadow.setSymbol(param.target._getInternalSymbol());
      }
    };
    _proto._onMarkerDragEnd = function _onMarkerDragEnd() {
      this._update('setCoordinates', this._shadow.getCoordinates().toArray());
    };
    _proto._createOrRefreshOutline = function _createOrRefreshOutline() {
      var geometry = this._geometry;
      var outline = this._editOutline;
      if (!outline) {
        this._editOutline = new EditOutline(this, this.getMap());
        this._addRefreshHook(this._createOrRefreshOutline);
      }
      var points = this._editOutline.points;
      if (geometry instanceof Marker) {
        this._editOutline.setPoints(geometry.getContainerExtent().toArray(points));
      } else {
        var map = this.getMap();
        var extent = geometry._getPrjExtent();
        points = extent.toArray(points);
        points.forEach(function (c) {
          return map._prjToContainerPoint(c, null, c);
        });
        this._editOutline.setPoints(points);
      }
      return outline;
    };
    _proto._createCenterHandle = function _createCenterHandle() {
      var _this2 = this;
      var map = this.getMap();
      var symbol = this.options['centerHandleSymbol'];
      var shadow;
      var cointainerPoint = map.coordToContainerPoint(this._geometry.getCenter());
      var handle = this.createHandle(cointainerPoint, {
        'symbol': symbol,
        'cursor': 'move',
        onDown: function onDown() {
          if (_this2._shadow) {
            shadow = _this2._shadow.copy();
            var _symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
            shadow.setSymbol(_symbol).addTo(_this2._geometry.getLayer());
          }
        },
        onMove: function onMove(param) {
          var offset = param['coordOffset'];
          if (shadow) {
            shadow.translate(offset);
          } else {
            _this2._geometry.translate(offset);
          }
        },
        onUp: function onUp() {
          if (shadow) {
            var shadowFirst = shadow.getFirstCoordinate();
            var first = _this2._geometry.getFirstCoordinate();
            var offset = shadowFirst.sub(first);
            _this2._update('translate', offset);
            shadow.remove();
          }
        }
      });
      this._addRefreshHook(function () {
        var center = _this2._geometry.getCenter();
        handle.setContainerPoint(map.coordToContainerPoint(center));
      });
    };
    _proto._createHandleInstance = function _createHandleInstance(containerPoint, opts) {
      var map = this.getMap();
      var symbol = loadFunctionTypes(opts['symbol'], function () {
        return [map.getZoom(), {
          '{bearing}': map.getBearing(),
          '{pitch}': map.getPitch(),
          '{zoom}': map.getZoom()
        }];
      });
      var removeVertexOn = this.options['removeVertexOn'];
      var handle = new EditHandle(this, map, {
        symbol: symbol,
        cursor: opts['cursor'],
        events: removeVertexOn
      });
      handle.setContainerPoint(containerPoint);
      return handle;
    };
    _proto.createHandle = function createHandle(containerPoint, opts) {
      if (!opts) {
        opts = {};
      }
      var handle = this._createHandleInstance(containerPoint, opts);
      var me = this;
      function onHandleDragstart(param) {
        this._updating = true;
        if (opts.onDown) {
          opts.onDown.call(me, param['containerPoint'], param);
          this._geometry.fire('handledragstart');
        }
        return false;
      }
      function onHandleDragging(param) {
        me._hideContext();
        if (opts.onMove) {
          opts.onMove.call(me, param);
          this._geometry.fire('handledragging');
        }
        return false;
      }
      function onHandleDragEnd(ev) {
        if (opts.onUp) {
          opts.onUp.call(me, ev);
          this._geometry.fire('handledragend');
        }
        this._updating = false;
        return false;
      }
      handle.on('dragstart', onHandleDragstart, this);
      handle.on('dragging', onHandleDragging, this);
      handle.on('dragend', onHandleDragEnd, this);
      if (opts.onRefresh) {
        handle.refresh = opts.onRefresh;
      }
      return handle;
    };
    _proto._createResizeHandles = function _createResizeHandles(blackList, onHandleMove, onHandleUp) {
      var _this3 = this;
      var cursors = ['nw-resize', 'n-resize', 'ne-resize', 'w-resize', 'e-resize', 'sw-resize', 's-resize', 'se-resize'];
      var axis = [null, 'y', null, 'x', 'x', null, 'y', null];
      var geometry = this._geometry;
      var isMarker = geometry instanceof Marker;
      function getResizeAnchors() {
        if (isMarker) {
          var _ext = geometry.getContainerExtent();
          return [new Point(_ext['xmin'], _ext['ymin']), new Point((_ext['xmax'] + _ext['xmin']) / 2, _ext['ymin']), new Point(_ext['xmax'], _ext['ymin']), new Point(_ext['xmin'], (_ext['ymin'] + _ext['ymax']) / 2), new Point(_ext['xmax'], (_ext['ymin'] + _ext['ymax']) / 2), new Point(_ext['xmin'], _ext['ymax']), new Point((_ext['xmax'] + _ext['xmin']) / 2, _ext['ymax']), new Point(_ext['xmax'], _ext['ymax'])];
        }
        var ext = geometry._getPrjExtent();
        return [new Point(ext['xmin'], ext['ymax']), new Point((ext['xmax'] + ext['xmin']) / 2, ext['ymax']), new Point(ext['xmax'], ext['ymax']), new Point(ext['xmin'], (ext['ymax'] + ext['ymin']) / 2), new Point(ext['xmax'], (ext['ymax'] + ext['ymin']) / 2), new Point(ext['xmin'], ext['ymin']), new Point((ext['xmax'] + ext['xmin']) / 2, ext['ymin']), new Point(ext['xmax'], ext['ymin'])];
      }
      if (!blackList) {
        blackList = [];
      }
      var me = this;
      var resizeHandles = [],
        anchorIndexes = {},
        map = this.getMap(),
        handleSymbol = this.options['vertexHandleSymbol'];
      var fnLocateHandles = function fnLocateHandles() {
        var anchors = getResizeAnchors();
        var _loop = function _loop(i) {
          if (Array.isArray(blackList)) {
            var isBlack = blackList.some(function (ele) {
              return ele === i;
            });
            if (isBlack) {
              return "continue";
            }
          }
          var anchor = anchors[i],
            point = isMarker ? anchor : map._prjToContainerPoint(anchor);
          if (resizeHandles.length < anchors.length - blackList.length) {
            var handle = _this3.createHandle(point, {
              'symbol': handleSymbol,
              'cursor': cursors[i],
              'axis': axis[i],
              onMove: function (_index) {
                return function (e) {
                  me._updating = true;
                  onHandleMove(e.containerPoint, _index);
                  geometry.fire('resizing');
                };
              }(i),
              onUp: function onUp() {
                me._updating = false;
                onHandleUp();
              }
            });
            anchorIndexes[i] = resizeHandles.length;
            resizeHandles.push(handle);
          } else {
            resizeHandles[anchorIndexes[i]].setContainerPoint(point);
          }
        };
        for (var i = 0; i < anchors.length; i++) {
          var _ret = _loop(i);
          if (_ret === "continue") continue;
        }
      };
      fnLocateHandles();
      this._addRefreshHook(fnLocateHandles);
      return resizeHandles;
    };
    _proto.createMarkerEditor = function createMarkerEditor() {
      var _this4 = this;
      var geometryToEdit = this._shadow || this._geometry,
        map = this.getMap();
      if (!geometryToEdit._canEdit()) {
        if (console) {
          console.warn('A marker can\'t be resized with symbol:', geometryToEdit.getSymbol());
        }
        return;
      }
      if (!this._history) {
        this._recordHistory(getUpdates());
      }
      var symbol = geometryToEdit._getInternalSymbol();
      var dxdy = new Point(0, 0);
      if (isNumber(symbol['markerDx'])) {
        dxdy.x = symbol['markerDx'];
      }
      if (isNumber(symbol['markerDy'])) {
        dxdy.y = symbol['markerDy'];
      }
      var blackList = null;
      var verticalAnchor = 'middle';
      var horizontalAnchor = 'middle';
      if (VectorMarkerSymbolizer.test(symbol)) {
        var type = symbol['markerType'];
        if (type === 'pin' || type === 'pie' || type === 'bar') {
          blackList = [5, 6, 7];
          verticalAnchor = 'bottom';
        } else if (type === 'rectangle') {
          blackList = [0, 1, 2, 3, 5];
          verticalAnchor = 'top';
          horizontalAnchor = 'left';
        }
      } else if (ImageMarkerSymbolizer.test(symbol) || VectorPathMarkerSymbolizer.test(symbol)) {
        verticalAnchor = 'bottom';
        blackList = [5, 6, 7];
      }
      var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
      var aspectRatio;
      if (this.options['fixAspectRatio']) {
        var size = geometryToEdit.getSize();
        aspectRatio = size.width / size.height;
      }
      var resizeHandles = this._createResizeHandles(blackList, function (containerPoint, i) {
        if (blackList && blackList.indexOf(i) >= 0) {
          var newCoordinates = map.containerPointToCoordinate(containerPoint.sub(dxdy));
          var coordinates = geometryToEdit.getCoordinates();
          newCoordinates.x = coordinates.x;
          geometryToEdit.setCoordinates(newCoordinates);
          _this4._updateCoordFromShadow(true);
          var mirrorHandle = resizeHandles[resizeHandles.length - 1 - i];
          var mirror = mirrorHandle.getContainerPoint();
          containerPoint = mirror;
        }
        var viewCenter = map.coordToContainerPoint(geometryToEdit.getCoordinates()).add(dxdy),
          symbol = geometryToEdit._getInternalSymbol();
        var wh = containerPoint.sub(viewCenter);
        if (verticalAnchor === 'bottom' && containerPoint.y > viewCenter.y) {
          wh.y = 0;
        }
        var vr = verticalAnchor === 'middle' ? 2 : 1;
        var hr = horizontalAnchor === 'left' ? 1 : 2;
        var width = Math.abs(wh.x) * hr,
          height = Math.abs(wh.y) * vr;
        if (aspectRatio) {
          width = Math.max(width, height * aspectRatio);
          height = width / aspectRatio;
        }
        var ability = resizeAbilities[i];
        if (!(geometryToEdit instanceof TextBox)) {
          if (aspectRatio || ability === 0 || ability === 2) {
            symbol['markerWidth'] = Math.min(width, _this4._geometry.options['maxMarkerWidth'] || Infinity);
          }
          if (aspectRatio || ability === 1 || ability === 2) {
            symbol['markerHeight'] = Math.min(height, _this4._geometry.options['maxMarkerHeight'] || Infinity);
          }
          geometryToEdit.setSymbol(symbol);
          if (geometryToEdit !== _this4._geometry) {
            _this4._geometry.setSymbol(symbol);
          }
        } else {
          if (aspectRatio || ability === 0 || ability === 2) {
            geometryToEdit.setWidth(width);
            if (geometryToEdit !== _this4._geometry) {
              _this4._geometry.setWidth(width);
            }
          }
          if (aspectRatio || ability === 1 || ability === 2) {
            geometryToEdit.setHeight(height);
            if (geometryToEdit !== _this4._geometry) {
              _this4._geometry.setHeight(height);
            }
          }
        }
      }, function () {
        _this4._update(getUpdates());
      });
      function getUpdates() {
        var updates = [['setCoordinates', geometryToEdit.getCoordinates().toArray()]];
        if (geometryToEdit instanceof TextBox) {
          updates.push(['setWidth', geometryToEdit.getWidth()]);
          updates.push(['setHeight', geometryToEdit.getHeight()]);
        } else {
          updates.push(['setSymbol', geometryToEdit.getSymbol()]);
        }
        return updates;
      }
    };
    _proto.createCircleEditor = function createCircleEditor() {
      var _this5 = this;
      var geo = this._shadow || this._geometry;
      var map = this.getMap();
      if (!this._history) {
        this._recordHistory([['setCoordinates', geo.getCoordinates().toArray()], ['setRadius', geo.getRadius()]]);
      }
      this._createResizeHandles(null, function (handleContainerPoint) {
        var center = geo.getCenter();
        var mouseCoordinate = map.containerPointToCoord(handleContainerPoint);
        var wline = new LineString([[center.x, center.y], [mouseCoordinate.x, center.y]]);
        var hline = new LineString([[center.x, center.y], [center.x, mouseCoordinate.y]]);
        var r = Math.max(map.computeGeometryLength(wline), map.computeGeometryLength(hline));
        geo.setRadius(r);
        if (geo !== _this5._geometry) {
          _this5._geometry.setRadius(r);
        }
      }, function () {
        _this5._update('setRadius', geo.getRadius());
      });
    };
    _proto.createEllipseOrRectEditor = function createEllipseOrRectEditor() {
      var _this6 = this;
      var resizeAbilities = [2, 1, 2, 0, 0, 2, 1, 2];
      var geometryToEdit = this._shadow || this._geometry;
      if (!this._history) {
        this._recordHistory(getUpdates());
      }
      var map = this.getMap();
      var isRect = this._geometry instanceof Rectangle;
      var aspectRatio;
      if (this.options['fixAspectRatio']) {
        aspectRatio = geometryToEdit.getWidth() / geometryToEdit.getHeight();
      }
      var resizeHandles = this._createResizeHandles(null, function (mouseContainerPoint, i) {
        var r = isRect ? 1 : 2;
        var pointSub, w, h;
        var handle = resizeHandles[i];
        var targetPoint = handle.getContainerPoint();
        var ability = resizeAbilities[i];
        if (isRect) {
          var mirror = resizeHandles[7 - i];
          var mirrorContainerPoint = mirror.getContainerPoint();
          pointSub = targetPoint.sub(mirrorContainerPoint);
          var absSub = pointSub.abs();
          w = map.pixelToDistance(absSub.x, 0);
          h = map.pixelToDistance(0, absSub.y);
          var size = geometryToEdit.getSize();
          var geoCoord = geometryToEdit.getCoordinates();
          var width = geometryToEdit.getWidth();
          var height = geometryToEdit.getHeight();
          var mouseCoordinate = map.containerPointToCoord(mouseContainerPoint);
          var mirrorCoordinate = map.containerPointToCoord(mirrorContainerPoint);
          var wline = new LineString([[mirrorCoordinate.x, mirrorCoordinate.y], [mouseCoordinate.x, mirrorCoordinate.y]]);
          var hline = new LineString([[mirrorCoordinate.x, mirrorCoordinate.y], [mirrorCoordinate.x, mouseCoordinate.y]]);
          w = map.computeGeometryLength(wline);
          h = map.computeGeometryLength(hline);
          if (ability === 0) {
            if (aspectRatio) {
              absSub.y = absSub.x / aspectRatio;
              size.height = Math.abs(absSub.y);
              h = w / aspectRatio;
            }
            targetPoint.y = mirrorContainerPoint.y - size.height / 2;
            mouseCoordinate.y = geoCoord.y;
            if (i === 4) {
              mouseCoordinate.x = Math.min(mouseCoordinate.x, geoCoord.x);
            } else {
              var mirrorCoord = map.locate(geoCoord, width, 0);
              mouseCoordinate.x = map.locate(new Coordinate(mirrorCoord.x, mouseCoordinate.y), -w, 0).x;
            }
          } else if (ability === 1) {
            if (aspectRatio) {
              absSub.x = absSub.y * aspectRatio;
              size.width = Math.abs(absSub.x);
              w = h * aspectRatio;
            }
            targetPoint.x = mirrorContainerPoint.x - size.width / 2;
            mouseCoordinate.x = geoCoord.x;
            mouseCoordinate.y = Math.max(mouseCoordinate.y, mirrorCoordinate.y);
          } else {
            if (aspectRatio) {
              if (w > h * aspectRatio) {
                h = w / aspectRatio;
                targetPoint.y = mirrorContainerPoint.y + absSub.x * sign(pointSub.y) / aspectRatio;
              } else {
                w = h * aspectRatio;
                targetPoint.x = mirrorContainerPoint.x + absSub.y * sign(pointSub.x) * aspectRatio;
              }
            }
            if (i === 0 || i === 5) {
              var _mirrorCoord = i === 0 ? map.locate(geoCoord, width, 0) : map.locate(geoCoord, width, -height);
              mouseCoordinate.x = map.locate(new Coordinate(_mirrorCoord.x, mouseCoordinate.y), -w, 0).x;
            } else {
              mouseCoordinate.x = Math.min(mouseCoordinate.x, mirrorCoordinate.x);
            }
            mouseCoordinate.y = Math.max(mouseCoordinate.y, mirrorCoordinate.y);
          }
          geometryToEdit.setCoordinates(mouseCoordinate);
          _this6._updateCoordFromShadow(true);
        } else {
          var center = geometryToEdit.getCenter();
          var _mouseCoordinate = map.containerPointToCoord(targetPoint);
          var _wline = new LineString([[center.x, center.y], [_mouseCoordinate.x, center.y]]);
          var _hline = new LineString([[center.x, center.y], [center.x, _mouseCoordinate.y]]);
          w = map.computeGeometryLength(_wline);
          h = map.computeGeometryLength(_hline);
          if (aspectRatio) {
            w = Math.max(w, h * aspectRatio);
            h = w / aspectRatio;
          }
        }
        if (aspectRatio || ability === 0 || ability === 2) {
          geometryToEdit.setWidth(w * r);
          if (geometryToEdit !== _this6._geometry) {
            _this6._geometry.setWidth(w * r);
          }
        }
        if (aspectRatio || ability === 1 || ability === 2) {
          geometryToEdit.setHeight(h * r);
          if (geometryToEdit !== _this6._geometry) {
            _this6._geometry.setHeight(h * r);
          }
        }
      }, function () {
        _this6._update(getUpdates());
      });
      function getUpdates() {
        return [['setCoordinates', geometryToEdit.getCoordinates().toArray()], ['setWidth', geometryToEdit.getWidth()], ['setHeight', geometryToEdit.getHeight()]];
      }
    };
    _proto.createPolygonEditor = function createPolygonEditor() {
      var map = this.getMap(),
        geoToEdit = this._shadow || this._geometry,
        me = this;
      if (!this._history) {
        this._recordHistory('setCoordinates', Coordinate.toNumberArrays(geoToEdit.getCoordinates()));
      }
      var verticeLimit = geoToEdit instanceof Polygon ? 3 : 2;
      var propertyOfVertexIndex = 'maptalks--editor-vertex-index';
      var vertexHandles = {
          0: []
        },
        newVertexHandles = {
          0: []
        };
      function getVertexCoordinates(ringIndex) {
        if (ringIndex === void 0) {
          ringIndex = 0;
        }
        if (geoToEdit instanceof Polygon) {
          var coordinates = geoToEdit.getCoordinates()[ringIndex] || [];
          return coordinates.slice(0, coordinates.length - 1);
        } else {
          return geoToEdit.getCoordinates();
        }
      }
      function getVertexPrjCoordinates(ringIndex) {
        if (ringIndex === void 0) {
          ringIndex = 0;
        }
        if (ringIndex === 0) {
          return geoToEdit._getPrjCoordinates();
        }
        return geoToEdit._getPrjHoles()[ringIndex - 1];
      }
      function onVertexAddOrRemove() {
        for (var ringIndex in vertexHandles) {
          for (var i = vertexHandles[ringIndex].length - 1; i >= 0; i--) {
            vertexHandles[ringIndex][i][propertyOfVertexIndex] = i;
          }
          for (var _i = newVertexHandles[ringIndex].length - 1; _i >= 0; _i--) {
            newVertexHandles[ringIndex][_i][propertyOfVertexIndex] = _i;
          }
        }
        me._updateCoordFromShadow();
      }
      function removeVertex(param) {
        me._updating = true;
        var handle = param['target'],
          index = handle[propertyOfVertexIndex];
        var ringIndex = isNumber(handle._ringIndex) ? handle._ringIndex : 0;
        var prjCoordinates = getVertexPrjCoordinates(ringIndex);
        if (prjCoordinates.length <= verticeLimit) {
          return;
        }
        var isEnd = geoToEdit instanceof LineString && (index === 0 || index === prjCoordinates.length - 1);
        prjCoordinates.splice(index, 1);
        if (ringIndex > 0) {
          geoToEdit._prjHoles[ringIndex - 1] = prjCoordinates;
        } else {
          geoToEdit._setPrjCoordinates(prjCoordinates);
        }
        geoToEdit._updateCache();
        vertexHandles[ringIndex].splice(index, 1)[0].delete();
        if (index < newVertexHandles[ringIndex].length) {
          newVertexHandles[ringIndex].splice(index, 1)[0].delete();
        }
        var nextIndex;
        if (index === 0) {
          nextIndex = newVertexHandles[ringIndex].length - 1;
        } else {
          nextIndex = index - 1;
        }
        newVertexHandles[ringIndex].splice(nextIndex, 1)[0].delete();
        if (!isEnd) {
          newVertexHandles[ringIndex].splice(nextIndex, 0, createNewVertexHandle.call(me, nextIndex, ringIndex));
        }
        if (ringIndex > 0) {
          var coordiantes = geoToEdit.getCoordinates();
          var ring = coordiantes[ringIndex];
          if (ring && Array.isArray(ring) && ring.length > 1) {
            ring.splice(index, 1);
            if (geoToEdit !== this._geometry) {
              geoToEdit.setCoordinates(coordiantes);
            }
          }
        }
        onVertexAddOrRemove();
        me._updating = false;
      }
      function moveVertexHandle(handleConatainerPoint, index, ringIndex) {
        if (ringIndex === void 0) {
          ringIndex = 0;
        }
        var snapTo = me._geometry.snapTo;
        if (snapTo && isFunction(snapTo)) {
          handleConatainerPoint = me._geometry.snapTo(handleConatainerPoint) || handleConatainerPoint;
        }
        var vertice = getVertexPrjCoordinates(ringIndex);
        var nVertex = map._containerPointToPrj(handleConatainerPoint.sub(getDxDy()));
        var pVertex = vertice[index];
        pVertex.x = nVertex.x;
        pVertex.y = nVertex.y;
        geoToEdit._updateCache();
        geoToEdit.onShapeChanged();
        me._updateCoordFromShadow(true);
        var nextIndex;
        if (index === 0) {
          nextIndex = newVertexHandles[ringIndex].length - 1;
        } else {
          nextIndex = index - 1;
        }
        if (newVertexHandles[ringIndex][index]) {
          newVertexHandles[ringIndex][index].refresh();
        }
        if (newVertexHandles[ringIndex][nextIndex]) {
          newVertexHandles[ringIndex][nextIndex].refresh();
        }
      }
      var hanldeDxdy = new Point(0, 0);
      function getDxDy() {
        var compiledSymbol = geoToEdit._getCompiledSymbol();
        hanldeDxdy.x = compiledSymbol.lineDx || 0;
        hanldeDxdy.y = compiledSymbol.lineDy || 0;
        return hanldeDxdy;
      }
      function createVertexHandle(index, ringIndex, ringCoordinates) {
        if (ringIndex === void 0) {
          ringIndex = 0;
        }
        var vertex = (ringCoordinates || getVertexCoordinates(ringIndex))[index];
        var handle = me.createHandle(map.coordToContainerPoint(vertex)._add(getDxDy()), {
          'symbol': me.options['vertexHandleSymbol'],
          'cursor': 'pointer',
          'axis': null,
          onMove: function onMove() {
            moveVertexHandle(handle.getContainerPoint(), handle[propertyOfVertexIndex], ringIndex);
          },
          onRefresh: function onRefresh(rIndex, ringCoordinates) {
            vertex = (ringCoordinates || getVertexCoordinates(ringIndex))[handle[propertyOfVertexIndex]];
            var containerPoint = map.coordToContainerPoint(vertex);
            handle.setContainerPoint(containerPoint._add(getDxDy()));
          },
          onUp: function onUp() {
            me._updateCoordFromShadow();
          },
          onDown: function onDown(param, e) {
            if (e && e.domEvent && e.domEvent.button === 2) {
              return;
            }
          }
        });
        handle[propertyOfVertexIndex] = index;
        handle._ringIndex = ringIndex;
        handle.on(me.options['removeVertexOn'], removeVertex);
        return handle;
      }
      var pauseRefresh = false;
      function createNewVertexHandle(index, ringIndex, ringCoordinates) {
        if (ringIndex === void 0) {
          ringIndex = 0;
        }
        var vertexCoordinates = ringCoordinates || getVertexCoordinates(ringIndex);
        var nextVertex;
        if (index + 1 >= vertexCoordinates.length) {
          nextVertex = vertexCoordinates[0];
        } else {
          nextVertex = vertexCoordinates[index + 1];
        }
        var vertex = vertexCoordinates[index].add(nextVertex).multi(1 / 2);
        var handle = me.createHandle(vertex, {
          'symbol': me.options['newVertexHandleSymbol'],
          'cursor': 'pointer',
          'axis': null,
          onDown: function onDown(param, e) {
            if (e && e.domEvent && e.domEvent.button === 2) {
              return;
            }
            var prjCoordinates = getVertexPrjCoordinates(ringIndex);
            var vertexIndex = handle[propertyOfVertexIndex];
            var cp = handle.getContainerPoint();
            var pVertex = map._containerPointToPrj(cp);
            prjCoordinates.splice(vertexIndex + 1, 0, pVertex);
            if (ringIndex > 0) {
              geoToEdit._prjHoles[ringIndex - 1] = prjCoordinates;
            } else {
              geoToEdit._setPrjCoordinates(prjCoordinates);
            }
            geoToEdit._updateCache();
            handle.opacity = 1;
            newVertexHandles[ringIndex].splice(vertexIndex, 0, createNewVertexHandle.call(me, vertexIndex, ringIndex), createNewVertexHandle.call(me, vertexIndex + 1, ringIndex));
            pauseRefresh = true;
          },
          onMove: function onMove() {
            moveVertexHandle(handle.getContainerPoint(), handle[propertyOfVertexIndex] + 1, ringIndex);
          },
          onUp: function onUp(e) {
            if (e && e.domEvent && e.domEvent.button === 2) {
              pauseRefresh = false;
              return;
            }
            var vertexIndex = handle[propertyOfVertexIndex];
            removeFromArray(handle, newVertexHandles[ringIndex]);
            handle.delete();
            vertexHandles[ringIndex].splice(vertexIndex + 1, 0, createVertexHandle.call(me, vertexIndex + 1, ringIndex));
            onVertexAddOrRemove();
            me._updateCoordFromShadow();
            pauseRefresh = false;
          },
          onRefresh: function onRefresh(rIndex, ringCoordinates) {
            vertexCoordinates = ringCoordinates || getVertexCoordinates(rIndex);
            var vertexIndex = handle[propertyOfVertexIndex];
            var nextIndex;
            if (vertexIndex === vertexCoordinates.length - 1) {
              nextIndex = 0;
            } else {
              nextIndex = vertexIndex + 1;
            }
            var refreshVertex = vertexCoordinates[vertexIndex].add(vertexCoordinates[nextIndex]).multi(1 / 2);
            var containerPoint = map.coordToContainerPoint(refreshVertex);
            handle.setContainerPoint(containerPoint._add(getDxDy()));
          }
        });
        handle[propertyOfVertexIndex] = index;
        return handle;
      }
      if (geoToEdit instanceof Polygon) {
        var rings = geoToEdit.getHoles().length + 1;
        for (var ringIndex = 0; ringIndex < rings; ringIndex++) {
          vertexHandles[ringIndex] = [];
          newVertexHandles[ringIndex] = [];
          var vertexCoordinates = getVertexCoordinates(ringIndex);
          for (var i = 0, len = vertexCoordinates.length; i < len; i++) {
            vertexHandles[ringIndex].push(createVertexHandle.call(this, i, ringIndex, vertexCoordinates));
            if (i < len - 1) {
              newVertexHandles[ringIndex].push(createNewVertexHandle.call(this, i, ringIndex, vertexCoordinates));
            }
          }
          newVertexHandles[ringIndex].push(createNewVertexHandle.call(this, vertexCoordinates.length - 1, ringIndex, vertexCoordinates));
        }
      } else {
        var _ringIndex = 0;
        var _vertexCoordinates = getVertexCoordinates(_ringIndex);
        for (var _i2 = 0, _len = _vertexCoordinates.length; _i2 < _len; _i2++) {
          vertexHandles[_ringIndex].push(createVertexHandle.call(this, _i2, _ringIndex, _vertexCoordinates));
          if (_i2 < _len - 1) {
            newVertexHandles[_ringIndex].push(createNewVertexHandle.call(this, _i2, _ringIndex, _vertexCoordinates));
          }
        }
        if (newVertexHandles[_ringIndex].length && geoToEdit.getCoordinates().length === 2) {
          newVertexHandles[_ringIndex][0].options.symbol['markerDx'] = 12;
        }
      }
      this._addRefreshHook(function () {
        if (pauseRefresh) {
          return;
        }
        for (var _ringIndex2 in newVertexHandles) {
          var ringCoordinates = getVertexCoordinates(_ringIndex2);
          for (var _i3 = newVertexHandles[_ringIndex2].length - 1; _i3 >= 0; _i3--) {
            newVertexHandles[_ringIndex2][_i3].refresh(_ringIndex2, ringCoordinates);
          }
        }
        if (newVertexHandles[0].length && geoToEdit instanceof LineString) {
          if (geoToEdit.getCoordinates().length === 2) {
            newVertexHandles[0][0].options.symbol['markerDx'] = 12;
          } else if (geoToEdit.getCoordinates().length > 2) {
            newVertexHandles[0][0].options.symbol['markerDx'] = 0;
          }
        }
        for (var _ringIndex3 in vertexHandles) {
          var _ringCoordinates = getVertexCoordinates(_ringIndex3);
          for (var _i4 = vertexHandles[_ringIndex3].length - 1; _i4 >= 0; _i4--) {
            vertexHandles[_ringIndex3][_i4].refresh(_ringIndex3, _ringCoordinates);
          }
        }
      });
    };
    _proto._refresh = function _refresh() {
      if (this._refreshHooks) {
        for (var i = this._refreshHooks.length - 1; i >= 0; i--) {
          this._refreshHooks[i].call(this);
        }
      }
    };
    _proto._hideContext = function _hideContext() {
      if (this._geometry) {
        this._geometry.closeMenu();
        this._geometry.closeInfoWindow();
      }
    };
    _proto._addRefreshHook = function _addRefreshHook(fn) {
      if (!fn) {
        return;
      }
      if (!this._refreshHooks) {
        this._refreshHooks = [];
      }
      this._refreshHooks.push(fn);
    };
    _proto._update = function _update(method) {
      for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key = 1; _key < _len2; _key++) {
        args[_key - 1] = arguments[_key];
      }
      this._exeHistory([method, args]);
      this._recordHistory.apply(this, [method].concat(args));
    };
    _proto._updateCoordFromShadow = function _updateCoordFromShadow(ignoreRecord) {
      var geoToEdit = this._shadow || this._geometry;
      var coords = geoToEdit.getCoordinates();
      var geo = this._geometry;
      var updating = this._updating;
      this._updating = true;
      geo.setCoordinates(coords);
      if (!ignoreRecord) {
        this._recordHistory('setCoordinates', Coordinate.toNumberArrays(geo.getCoordinates()));
      }
      this._updating = updating;
    };
    _proto._recordHistory = function _recordHistory(method) {
      if (!this._history) {
        this._history = [];
        this._historyPointer = 0;
      }
      for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key2 = 1; _key2 < _len3; _key2++) {
        args[_key2 - 1] = arguments[_key2];
      }
      if (this._history.length) {
        var lastOperation = this._history[this._history.length - 1];
        if (lastOperation[0] === method && JSON.stringify(lastOperation[1]) === JSON.stringify(args)) {
          return;
        }
      }
      if (this._historyPointer < this._history.length - 1) {
        this._history.splice(this._historyPointer + 1);
      }
      this._history.push([method, args]);
      this._historyPointer = this._history.length - 1;
      this._geometry.fire('editrecord');
    };
    _proto.cancel = function cancel() {
      if (!this._history || this._historyPointer === 0) {
        return this;
      }
      this._historyPointer = 0;
      var record = this._history[0];
      this._exeAndReset(record);
      return this;
    };
    _proto.undo = function undo() {
      if (!this._history || this._historyPointer === 0) {
        return this;
      }
      var record = this._history[--this._historyPointer];
      this._exeAndReset(record);
      return this;
    };
    _proto.redo = function redo() {
      if (!this._history || this._historyPointer === this._history.length - 1) {
        return this;
      }
      var record = this._history[++this._historyPointer];
      this._exeAndReset(record);
      return this;
    };
    _proto._exeAndReset = function _exeAndReset(record) {
      if (this._updating) {
        return;
      }
      this._exeHistory(record);
      var history = this._history,
        pointer = this._historyPointer;
      this.stop();
      this._history = history;
      this._historyPointer = pointer;
      this.start();
    };
    _proto._onDragStart = function _onDragStart() {
      this._updating = true;
    };
    _proto._onDragEnd = function _onDragEnd() {
      this._updating = false;
    };
    _proto._exeHistory = function _exeHistory(record) {
      if (!Array.isArray(record)) {
        return;
      }
      var updating = this._updating;
      this._updating = true;
      var geoToEdit = this._shadow || this._geometry;
      var geo = this._geometry;
      if (Array.isArray(record[0])) {
        record[0].forEach(function (o) {
          var m = o[0],
            args = o.slice(1);
          geoToEdit[m].apply(geoToEdit, args);
          if (geoToEdit !== geo) {
            geo[m].apply(geo, args);
          }
        });
      } else {
        geoToEdit[record[0]].apply(geoToEdit, record[1]);
        if (geoToEdit !== geo) {
          geo[record[0]].apply(geo, record[1]);
        }
      }
      this._updating = updating;
    };
    return GeometryEditor;
  }(Eventable(Class));
  GeometryEditor.mergeOptions(options$C);

  var TextEditable = {
    startEditText: function startEditText() {
      if (!this.getMap()) {
        return this;
      }
      this.hide();
      this.endEditText();
      this._prepareEditor();
      this._fireEvent('edittextstart');
      return this;
    },
    endEditText: function endEditText() {
      if (this._textEditor) {
        var html = this._textEditor.innerHTML;
        html = html.replace(/<p>/ig, '').replace(/<\/p>/ig, '<br/>');
        this._textEditor.innerHTML = html;
        var content = this._textEditor.innerText.replace(/[\r\n]+$/gi, '');
        this.setContent(content);
        off(this._textEditor, 'mousedown dblclick', stopPropagation);
        this.getMap().off('mousedown', this.endEditText, this);
        this._editUIMarker.remove();
        delete this._editUIMarker;
        this._textEditor.onkeyup = null;
        delete this._textEditor;
        this.show();
        this._fireEvent('edittextend');
      }
      return this;
    },
    isEditingText: function isEditingText() {
      if (this._textEditor) {
        return true;
      }
      return false;
    },
    getTextEditor: function getTextEditor() {
      return this._editUIMarker;
    },
    _prepareEditor: function _prepareEditor() {
      var map = this.getMap();
      var editContainer = this._createEditor();
      this._textEditor = editContainer;
      map.on('mousedown', this.endEditText, this);
      var offset = this._getEditorOffset();
      this._editUIMarker = new UIMarker(this.getCoordinates(), {
        'animation': null,
        'content': editContainer,
        'dx': offset.dx,
        'dy': offset.dy
      }).addTo(map);
      this._setCursorToLast(this._textEditor);
    },
    _getEditorOffset: function _getEditorOffset() {
      var symbol = this._getInternalSymbol() || {};
      var dx = 0,
        dy = 0;
      var textAlign = symbol['textHorizontalAlignment'];
      if (textAlign === 'middle' || isNil(textAlign)) {
        dx = (symbol['textDx'] || 0) - 2;
        dy = (symbol['textDy'] || 0) - 2;
      } else {
        dx = (symbol['markerDx'] || 0) - 2;
        dy = (symbol['markerDy'] || 0) - 2;
      }
      return {
        'dx': dx,
        'dy': dy
      };
    },
    _createEditor: function _createEditor() {
      var content = this.getContent();
      var labelSize = this.getSize(),
        symbol = this._getInternalSymbol() || {},
        width = labelSize.width,
        textColor = symbol['textFill'] || '#000000',
        textSize = symbol['textSize'] || 12,
        height = labelSize.height,
        lineColor = symbol['markerLineColor'] || '#000',
        fill = symbol['markerFill'] || '#3398CC',
        spacing = symbol['textLineSpacing'] || 0;
      var editor = createEl('div');
      editor.contentEditable = true;
      editor.style.cssText = "background:" + fill + "; border:1px solid " + lineColor + ";\n            color:" + textColor + ";font-size:" + textSize + "px;width:" + (width - 2) + "px;height:" + (height - 2) + "px;margin: auto;\n            line-height:" + (textSize + spacing) + "px;outline: 0; padding:0; margin:0;word-wrap: break-word;\n            overflow: hidden;-webkit-user-modify: read-write-plaintext-only;";
      editor.innerText = content;
      on(editor, 'mousedown dblclick', stopPropagation);
      editor.onkeyup = function (event) {
        var h = editor.style.height || 0;
        if (event.keyCode === 13) {
          editor.style.height = parseInt(h) + textSize / 2 + 'px';
        }
      };
      return editor;
    },
    _setCursorToLast: function _setCursorToLast(obj) {
      var range;
      if (window.getSelection) {
        obj.focus();
        range = window.getSelection();
        range.selectAllChildren(obj);
        range.collapseToEnd();
      } else if (document.selection) {
        range = document.selection.createRange();
        range.moveToElementText(obj);
        range.collapse(false);
        range.select();
      }
    }
  };
  TextMarker.include(TextEditable);

  Geometry.include({
    animate: function animate$$1(styles, options, step) {
      var _this = this;
      if (this._animPlayer) {
        this._animPlayer.finish();
      }
      if (isFunction(options)) {
        step = options;
      }
      if (!options) {
        options = {};
      }
      var map = this.getMap(),
        projection = this._getProjection(),
        stylesToAnimate = this._prepareAnimationStyles(styles);
      var preTranslate;
      var isFocusing = options['focus'];
      delete this._animationStarted;
      if (map) {
        var renderer = map._getRenderer();
        var framer = function framer(fn) {
          renderer.callInNextFrame(fn);
        };
        options['framer'] = framer;
      }
      var player = Animation.animate(stylesToAnimate, options, function (frame) {
        if (map && map.isRemoved()) {
          player.finish();
          return;
        }
        if (map && !_this._animationStarted && isFocusing) {
          map.onMoveStart();
        }
        var styles = frame.styles;
        for (var p in styles) {
          if (p !== 'symbol' && p !== 'translate' && styles.hasOwnProperty(p)) {
            var fnName = 'set' + p[0].toUpperCase() + p.slice(1);
            _this[fnName](styles[p]);
          }
        }
        var translate = styles['translate'];
        if (translate) {
          var toTranslate = translate;
          if (preTranslate) {
            toTranslate = translate.sub(preTranslate);
          }
          preTranslate = translate;
          _this.translate(toTranslate);
        }
        var dSymbol = styles['symbol'];
        if (dSymbol) {
          var symbol = _this.getSymbol() || {};
          _this.setSymbol(extendSymbol(symbol, dSymbol));
        }
        if (map && isFocusing) {
          var pcenter = projection.project(_this.getCenter());
          map._setPrjCenter(pcenter);
          var e = map._parseEventFromCoord(projection.unproject(pcenter));
          if (player.playState !== 'running') {
            map.onMoveEnd(e);
          } else {
            map.onMoving(e);
          }
        }
        _this._fireAnimateEvent(player.playState);
        if (step) {
          step(frame);
        }
      }, this);
      this._animPlayer = player;
      return this._animPlayer.play();
    },
    _prepareAnimationStyles: function _prepareAnimationStyles(styles) {
      var symbol = this._getInternalSymbol();
      var stylesToAnimate = {};
      for (var p in styles) {
        if (styles.hasOwnProperty(p)) {
          var v = styles[p];
          if (p !== 'translate' && p !== 'symbol') {
            var fnName = 'get' + p[0].toUpperCase() + p.substring(1);
            var current = this[fnName]();
            stylesToAnimate[p] = [current, v];
          } else if (p === 'symbol') {
            var symbolToAnimate = void 0;
            if (Array.isArray(styles['symbol'])) {
              if (!Array.isArray(symbol)) {
                throw new Error('geometry\'symbol isn\'t a composite symbol, while the symbol in styles is.');
              }
              symbolToAnimate = [];
              var symbolInStyles = styles['symbol'];
              for (var i = 0; i < symbolInStyles.length; i++) {
                if (!symbolInStyles[i]) {
                  symbolToAnimate.push(null);
                  continue;
                }
                var a = {};
                for (var sp in symbolInStyles[i]) {
                  if (symbolInStyles[i].hasOwnProperty(sp)) {
                    a[sp] = [symbol[i][sp], symbolInStyles[i][sp]];
                  }
                }
                symbolToAnimate.push(a);
              }
            } else {
              if (Array.isArray(symbol)) {
                throw new Error('geometry\'symbol is a composite symbol, while the symbol in styles isn\'t.');
              }
              symbolToAnimate = {};
              for (var _sp in v) {
                if (v.hasOwnProperty(_sp)) {
                  symbolToAnimate[_sp] = [symbol[_sp], v[_sp]];
                }
              }
            }
            stylesToAnimate['symbol'] = symbolToAnimate;
          } else if (p === 'translate') {
            stylesToAnimate['translate'] = new Coordinate(v);
          }
        }
      }
      return stylesToAnimate;
    },
    _fireAnimateEvent: function _fireAnimateEvent(playState) {
      if (playState === 'finished') {
        delete this._animationStarted;
        this._fireEvent('animateend');
      } else if (playState === 'running') {
        if (this._animationStarted) {
          this._fireEvent('animating');
        } else {
          this._fireEvent('animatestart');
          this._animationStarted = true;
        }
      }
    }
  });

  var DRAG_STAGE_LAYER_ID = INTERNAL_LAYER_PREFIX + '_drag_stage';
  var EVENTS$3 = Browser$1.touch ? 'touchstart mousedown' : 'mousedown';
  var GeometryDragHandler = function (_Handler) {
    _inheritsLoose(GeometryDragHandler, _Handler);
    function GeometryDragHandler(target) {
      return _Handler.call(this, target) || this;
    }
    var _proto = GeometryDragHandler.prototype;
    _proto.addHooks = function addHooks() {
      this.target.on(EVENTS$3, this._startDrag, this);
    };
    _proto.removeHooks = function removeHooks() {
      this._endDrag();
      this.target.off(EVENTS$3, this._startDrag, this);
      delete this.container;
    };
    _proto._prepareDragHandler = function _prepareDragHandler() {
      this._dragHandler = new DragHandler(this.container);
      this._dragHandler.on('dragging', this._dragging, this).on('mouseup', this._endDrag, this).enable();
    };
    _proto._prepareShadow = function _prepareShadow() {
      var _this = this;
      var target = this.target;
      var needShadow = target.getLayer().options['renderer'] === 'canvas';
      if (!needShadow) {
        return;
      }
      this._prepareDragStageLayer();
      if (this._shadow) {
        this._shadow.remove();
      }
      var shadow = this._shadow = target.copy();
      if (shadow.getGeometries) {
        var shadows = shadow.getGeometries();
        var geos = target.getGeometries();
        shadows.forEach(function (g, i) {
          _this._updateShadowSymbol(g, geos[i]);
        });
      } else {
        this._updateShadowSymbol(shadow, target);
      }
      shadow.setId(null);
      this._prepareShadowConnectors();
    };
    _proto._updateShadowSymbol = function _updateShadowSymbol(shadow, target) {
      shadow.setSymbol(target._getInternalSymbol());
      if (target.options['dragShadow']) {
        var symbol = lowerSymbolOpacity(shadow._getInternalSymbol(), 0.5);
        shadow.setSymbol(symbol);
      }
    };
    _proto._prepareShadowConnectors = function _prepareShadowConnectors() {
      var target = this.target;
      var shadow = this._shadow;
      var resources = this._dragStageLayer._getRenderer().resources;
      var shadowConnectors = [];
      if (ConnectorLine._hasConnectors(target)) {
        var connectors = ConnectorLine._getConnectors(target);
        for (var i = 0, l = connectors.length; i < l; i++) {
          var targetConn = connectors[i];
          var connOptions = targetConn.config(),
            connSymbol = targetConn._getInternalSymbol();
          connOptions['symbol'] = lowerSymbolOpacity(connSymbol, 0.5);
          var conn = void 0;
          if (targetConn.getConnectSource() === target) {
            conn = new targetConn.constructor(shadow, targetConn.getConnectTarget(), connOptions);
          } else {
            conn = new targetConn.constructor(targetConn.getConnectSource(), shadow, connOptions);
          }
          shadowConnectors.push(conn);
          if (targetConn.getLayer() && targetConn.getLayer()._getRenderer()) {
            resources.merge(targetConn.getLayer()._getRenderer().resources);
          }
        }
      }
      this._shadowConnectors = shadowConnectors;
      shadowConnectors.push(shadow);
      this._dragStageLayer.bringToFront().addGeometry(shadowConnectors);
    };
    _proto._onTargetUpdated = function _onTargetUpdated() {
      if (this._shadow) {
        this._shadow.setSymbol(this.target._getSymbol());
      }
    };
    _proto._prepareDragStageLayer = function _prepareDragStageLayer() {
      var map = this.target.getMap(),
        layer = this.target.getLayer();
      this._dragStageLayer = map.getLayer(DRAG_STAGE_LAYER_ID);
      if (!this._dragStageLayer) {
        this._dragStageLayer = new VectorLayer(DRAG_STAGE_LAYER_ID, {
          enableAltitude: layer.options['enableAltitude'],
          altitudeProperty: layer.options['altitudeProperty']
        });
        map.addLayer(this._dragStageLayer);
      }
      var resources = new ResourceCache();
      resources.merge(layer._getRenderer().resources);
      this._dragStageLayer._getRenderer().resources = resources;
    };
    _proto._startDrag = function _startDrag(param) {
      var map = this.target.getMap();
      if (!map) {
        return;
      }
      var parent = this.target._getParent();
      if (parent) {
        return;
      }
      if (this.isDragging()) {
        return;
      }
      var domEvent = param['domEvent'];
      if (domEvent.touches && domEvent.touches.length > 1 || domEvent.button === 2) {
        return;
      }
      this.container = map._panels.mapWrapper || map._containerDOM;
      this.target.on('click', this._endDrag, this);
      this._lastCoord = this._correctCoord(param['coordinate']);
      this._lastPoint = param['containerPoint'];
      this._prepareDragHandler();
      this._dragHandler.onMouseDown(param['domEvent']);
      on(this.container, 'mouseleave', this._endDrag, this);
      this._startParam = param;
      this._moved = false;
      return;
    };
    _proto._dragging = function _dragging(param) {
      var target = this.target;
      var map = target.getMap();
      if (map._isEventOutMap(param['domEvent'])) {
        return;
      }
      var e = map._parseEvent(param['domEvent']);
      var domEvent = e['domEvent'];
      if (domEvent.touches && domEvent.touches.length > 1) {
        return;
      }
      var visualHeight = map._getVisualHeight(map.options['maxVisualPitch']);
      if (e.containerPoint.y < map.height - visualHeight) {
        return;
      }
      if (!this._moved) {
        this._moved = true;
        target.on('symbolchange', this._onTargetUpdated, this);
        this._isDragging = true;
        this._prepareShadow();
        if (this._shadow) {
          if (!target.options['dragShadow']) {
            target.hide();
          }
          this._shadow._fireEvent('dragstart', e);
        }
        this.target._fireEvent('dragstart', this._startParam || e);
        delete this._startParam;
        return;
      }
      var geo = this._shadow || target;
      var axis = geo.options['dragOnAxis'],
        dragOnScreenAxis = geo.options['dragOnScreenAxis'],
        point = e['containerPoint'];
      var coord = e['coordinate'];
      this._lastPoint = this._lastPoint || point;
      this._lastCoord = this._lastCoord || coord;
      if (dragOnScreenAxis) {
        if (axis === 'x') {
          point.y = this._lastPoint.y;
        } else if (axis === 'y') {
          point.x = this._lastPoint.x;
        }
        coord = map.containerPointToCoord(point);
      } else {
        coord = this._correctCoord(coord);
      }
      var pointOffset = point.sub(this._lastPoint);
      var coordOffset = coord.sub(this._lastCoord);
      if (!dragOnScreenAxis) {
        if (axis === 'x') {
          pointOffset.y = coordOffset.y = 0;
        } else if (axis === 'y') {
          pointOffset.x = coordOffset.x = 0;
        }
      }
      this._lastPoint = point;
      this._lastCoord = coord;
      geo.translate(coordOffset);
      if (geo !== target && !target.options['dragShadow']) {
        target.translate(coordOffset);
      }
      e['coordOffset'] = coordOffset;
      e['pointOffset'] = pointOffset;
      geo._fireEvent('dragging', e);
      if (geo !== target) {
        target._fireEvent('dragging', e);
      }
    };
    _proto._endDrag = function _endDrag(param) {
      if (this._dragHandler) {
        this._dragHandler.disable();
        delete this._dragHandler;
      }
      if (this.container) {
        off(this.container, 'mouseleave', this._endDrag, this);
      }
      if (!this.target) {
        return;
      }
      var target = this.target;
      target.off('click', this._endDrag, this);
      target.off('symbolchange', this._onTargetUpdated, this);
      delete this._lastCoord;
      delete this._lastPoint;
      this._isDragging = false;
      var map = target.getMap();
      if (this.enabled() && map) {
        var e = map._parseEvent(param ? param['domEvent'] : null);
        this._updateTargetAndRemoveShadow(e);
        if (this._moved) {
          target._fireEvent('dragend', e);
        }
      }
    };
    _proto.isDragging = function isDragging() {
      if (!this._isDragging) {
        return false;
      }
      return true;
    };
    _proto._updateTargetAndRemoveShadow = function _updateTargetAndRemoveShadow(eventParam) {
      if (!this._shadow) {
        return;
      }
      var target = this.target,
        map = target.getMap();
      if (!target.options['dragShadow']) {
        target.show();
      }
      var shadow = this._shadow;
      if (shadow) {
        if (target.options['dragShadow']) {
          var shadowFirst = shadow.getFirstCoordinate();
          var first = target.getFirstCoordinate();
          var offset = shadowFirst.sub(first);
          target.translate(offset);
        }
        shadow._fireEvent('dragend', eventParam);
        shadow.remove();
        delete this._shadow;
      }
      if (this._shadowConnectors) {
        map.getLayer(DRAG_STAGE_LAYER_ID).removeGeometry(this._shadowConnectors);
        delete this._shadowConnectors;
      }
      if (this._dragStageLayer) {
        this._dragStageLayer._getRenderer().resources = new ResourceCache();
        this._dragStageLayer.remove();
      }
    };
    _proto._correctCoord = function _correctCoord(coord) {
      var map = this.target.getMap();
      if (!map.getPitch()) {
        return coord;
      }
      var target = this.target;
      if (!target.getMinAltitude()) {
        return coord;
      }
      var alt = (target.getMinAltitude() + target.getMaxAltitude()) / 2;
      return map.locateByPoint(coord, 0, -alt);
    };
    return GeometryDragHandler;
  }(Handler$1);
  Geometry.mergeOptions({
    'draggable': false,
    'dragShadow': true,
    'dragOnAxis': null,
    'dragOnScreenAxis': false
  });
  Geometry.addInitHook('addHandler', 'draggable', GeometryDragHandler);
  Geometry.include({
    isDragging: function isDragging() {
      if (this._getParent()) {
        return this._getParent().isDragging();
      }
      if (this['draggable']) {
        return this['draggable'].isDragging();
      }
      return false;
    }
  });

  Geometry.include({
    startEdit: function startEdit(opts) {
      var map = this.getMap();
      if (!map || !this.options['editable']) {
        return this;
      }
      if (this._editor) {
        this.endEdit();
      }
      this._editor = new GeometryEditor(this, opts);
      this._editor.start();
      if (!this._getParent()) {
        this.fire('editstart');
      }
      map.getRenderer().setToRedraw();
      return this;
    },
    endEdit: function endEdit() {
      if (this._editor) {
        this._editor.stop();
        delete this._editor;
        if (!this._getParent()) {
          this.fire('editend');
        }
        var map = this.getMap();
        if (map) {
          map.getRenderer().setToRedraw();
        }
      }
      return this;
    },
    redoEdit: function redoEdit() {
      if (!this.isEditing()) {
        return this;
      }
      this._editor.redo();
      if (!this._getParent()) {
        this.fire('redoedit');
      }
      return this;
    },
    undoEdit: function undoEdit() {
      if (!this.isEditing()) {
        return this;
      }
      this._editor.undo();
      if (!this._getParent()) {
        this.fire('undoedit');
      }
      return this;
    },
    cancelEdit: function cancelEdit() {
      if (!this.isEditing()) {
        return this;
      }
      if (this._editor) this._editor.cancel();
      if (!this._getParent()) {
        this.fire('canceledit');
      }
      return this;
    },
    isEditing: function isEditing() {
      if (this._editor) {
        return this._editor.isEditing();
      }
      return false;
    }
  });

  Geometry.include({
    _onEvent: function _onEvent(event, type) {
      var map = this.getMap();
      if (!map) {
        return;
      }
      var eventType = type || this._getEventTypeToFire(event);
      if (eventType === 'contextmenu' && this.listens('contextmenu')) {
        stopPropagation(event);
        preventDefault(event);
      }
      var params = map._getEventParams(event);
      if (isNumber(this._pickGeometryIndex)) {
        params.pickGeometryIndex = this._pickGeometryIndex;
      }
      this._fireEvent(eventType, params);
    },
    _getEventTypeToFire: function _getEventTypeToFire(domEvent) {
      return domEvent.type;
    }
  });

  Geometry.include({
    setInfoWindow: function setInfoWindow(options) {
      this.removeInfoWindow();
      if (options instanceof InfoWindow) {
        this._infoWindow = options;
        this._infoWinOptions = extend({}, this._infoWindow.options);
        this._infoWindow.addTo(this);
        return this;
      }
      this._infoWinOptions = extend({}, options);
      if (this._infoWindow) {
        this._infoWindow.setOptions(options);
      } else if (this.getMap()) {
        this._bindInfoWindow();
      }
      return this;
    },
    getInfoWindow: function getInfoWindow() {
      if (!this._infoWindow) {
        return null;
      }
      return this._infoWindow;
    },
    openInfoWindow: function openInfoWindow(coordinate) {
      if (!this.getMap()) {
        return this;
      }
      if (!coordinate) {
        coordinate = this.getCenter();
      }
      if (!this._infoWindow) {
        if (this._infoWinOptions && this.getMap()) {
          this._bindInfoWindow();
          this._infoWindow.show(coordinate);
        }
      } else {
        this._infoWindow.show(coordinate);
      }
      return this;
    },
    closeInfoWindow: function closeInfoWindow() {
      if (this._infoWindow) {
        this._infoWindow.hide();
      }
			this.fire('closeInfoWindow'); // 弹窗关闭时抛出事件 用于geom取消高亮状态
      return this;
    },
    removeInfoWindow: function removeInfoWindow() {
      this._unbindInfoWindow();
      delete this._infoWinOptions;
      delete this._infoWindow;
      return this;
    },
    _bindInfoWindow: function _bindInfoWindow() {
      var options = this._infoWinOptions;
      if (!options) {
        return this;
      }
      this._infoWindow = new InfoWindow(options);
      this._infoWindow.addTo(this);
      return this;
    },
    _unbindInfoWindow: function _unbindInfoWindow() {
      if (this._infoWindow) {
        this.closeInfoWindow();
        this._infoWindow.remove();
        delete this._infoWindow;
      }
      return this;
    }
  });

  var TILE_POINT = new Point(0, 0);
  var TEMP_POINT$5 = new Point(0, 0);
  var TEMP_POINT1$2 = new Point(0, 0);
  var TEMP_POINT2$2 = new Point(0, 0);
  var EMPTY_ARRAY$2 = [];
  var TileWorkerConnection = function (_Actor) {
    _inheritsLoose(TileWorkerConnection, _Actor);
    function TileWorkerConnection() {
      return _Actor.call(this, imageFetchWorkerKey) || this;
    }
    var _proto = TileWorkerConnection.prototype;
    _proto.checkUrl = function checkUrl(url) {
      if (!url || !isString(url)) {
        return url;
      }
      return getAbsoluteURL(url);
    };
    _proto.fetchImage = function fetchImage(url, workerId, cb, fetchOptions) {
      url = this.checkUrl(url);
      var data = {
        url: url,
        fetchOptions: fetchOptions
      };
      this.send(data, EMPTY_ARRAY$2, cb, workerId);
    };
    return TileWorkerConnection;
  }(Actor);
  var BLANK_IMAGE = new Image();
  var TileLayerCanvasRenderer = function (_CanvasRenderer) {
    _inheritsLoose(TileLayerCanvasRenderer, _CanvasRenderer);
    function TileLayerCanvasRenderer(layer) {
      var _this;
      _this = _CanvasRenderer.call(this, layer) || this;
      _this.tilesInView = {};
      _this.tilesLoading = {};
      _this._parentTiles = [];
      _this._childTiles = [];
      _this._tileQueue = [];
      _this._tileQueueIds = new Set();
      var tileSize = layer.getTileSize().width;
      _this.tileCache = new LRUCache(layer.options['maxCacheSize'] * tileSize / 512 * tileSize / 512, function (tile) {
        _this.deleteTile(tile);
      });
      if (Browser$1.decodeImageInWorker && _this.layer.options['decodeImageInWorker'] && (layer.options['renderer'] === 'gl' || !Browser$1.safari && !Browser$1.iosWeixin)) {
        _this._tileImageWorkerConn = new TileWorkerConnection();
      }
      _this._compareTiles = compareTiles.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      return _this;
    }
    var _proto2 = TileLayerCanvasRenderer.prototype;
    _proto2.getCurrentTileZoom = function getCurrentTileZoom() {
      return this._tileZoom;
    };
    _proto2.draw = function draw(timestamp, context) {
      var map = this.getMap();
      if (!this.isDrawable()) {
        return;
      }
      var mask2DExtent = this.prepareCanvas();
      if (mask2DExtent) {
        if (!mask2DExtent.intersects(this.canvasExtent2D)) {
          this.completeRender();
          return;
        }
      }
      if (this._renderTimestamp !== timestamp) {
        this._consumeTileQueue();
        this._computeAvgTileAltitude();
        this._renderTimestamp = timestamp;
      }
      var currentTiles;
      var hasFreshTiles = false;
      var frameTiles = this._frameTiles;
      if (frameTiles && timestamp === frameTiles.timestamp) {
        if (frameTiles.empty) {
          return;
        }
        currentTiles = frameTiles;
      } else {
        currentTiles = this._getTilesInCurrentFrame();
        if (!currentTiles) {
          this._frameTiles = {
            empty: true,
            timestamp: timestamp
          };
          this.completeRender();
          return;
        }
        hasFreshTiles = true;
        this._frameTiles = currentTiles;
        this._frameTiles.timestamp = timestamp;
        if (currentTiles.loadingCount) {
          this.loadTileQueue(currentTiles.tileQueue);
        }
      }
      var _currentTiles = currentTiles,
        tiles = _currentTiles.tiles,
        childTiles = _currentTiles.childTiles,
        parentTiles = _currentTiles.parentTiles,
        placeholders = _currentTiles.placeholders,
        loading = _currentTiles.loading,
        loadingCount = _currentTiles.loadingCount,
        missedTiles = _currentTiles.missedTiles,
        incompleteTiles = _currentTiles.incompleteTiles;
      this._drawTiles(tiles, parentTiles, childTiles, placeholders, context, missedTiles, incompleteTiles);
      if (!loadingCount) {
        if (!loading) {
          if (!map.isAnimating() && (this._parentTiles.length || this._childTiles.length)) {
            this._parentTiles = [];
            this._childTiles = [];
            this.setToRedraw();
          }
          this.completeRender();
        }
      }
      if (hasFreshTiles) {
        this.retireTiles();
      }
    };
    _proto2.getTileGridsInCurrentFrame = function getTileGridsInCurrentFrame() {
      return this._frameTileGrids;
    };
    _proto2.getCurrentTimestamp = function getCurrentTimestamp() {
      return this._renderTimestamp || 0;
    };
    _proto2._getTilesInCurrentFrame = function _getTilesInCurrentFrame() {
      var map = this.getMap();
      var layer = this.layer;
      var terrainTileMode = layer._isPyramidMode() && layer.options['terrainTileMode'];
      var tileGrids = layer.getTiles();
      this._frameTileGrids = tileGrids;
      tileGrids = tileGrids.tileGrids;
      if (!tileGrids || !tileGrids.length) {
        return null;
      }
      var count = tileGrids.reduce(function (acc, curr) {
        return acc + (curr && curr.tiles && curr.tiles.length || 0);
      }, 0);
      if (count >= this.tileCache.max / 2) {
        this.tileCache.setMaxSize(count * 2 + 1);
      }
      var loadingCount = 0;
      var loading = false;
      var checkedTiles = {};
      var tiles = [],
        parentTiles = [],
        parentKeys = {},
        childTiles = [],
        childKeys = {},
        placeholders = [],
        placeholderKeys = {};
      var tileQueue = {};
      var preLoadingCount = this.markTiles();
      var loadingLimit = this._getLoadLimit();
      var l = tileGrids.length;
      var isFirstRender = this._tileZoom === undefined && !this._terrainHelper;
      this._tileZoom = tileGrids[0]['zoom'];
      var missingTiles = null;
      var incompleteTiles = null;
      if (terrainTileMode) {
        missingTiles = [];
        incompleteTiles = new Map();
      }
      for (var i = 0; i < l; i++) {
        var tileGrid = tileGrids[i];
        var gridTiles = tileGrid['tiles'];
        var parents = tileGrid['parents'] || EMPTY_ARRAY$2;
        var parentCount = parents.length;
        var allTiles = isFirstRender ? gridTiles : parents.concat(gridTiles);
        var placeholder = void 0;
        if (allTiles.length) {
          placeholder = this._generatePlaceHolder(allTiles[0].res);
        }
        for (var j = 0, _l = allTiles.length; j < _l; j++) {
          var tile = allTiles[j];
          var tileId = tile.id;
          var isParentTile = j < parentCount;
          var tileLoading = false;
          var tilesCount = tiles.length;
          if (this._isLoadingTile(tileId)) {
            tileLoading = loading = true;
            this.markCurrent(this.tilesLoading[tileId], true);
          } else {
            var cached = this.getCachedTile(tile, isParentTile);
            if (cached) {
              if (!isParentTile) {
                if (cached.image && this.isTileFadingIn(cached.image)) {
                  tileLoading = loading = true;
                  this.setToRedraw();
                }
                if (this.isTileComplete(cached)) {
                  tiles.push(cached);
                } else {
                  tileLoading = true;
                  if (terrainTileMode) {
                    incompleteTiles.set(tileId, cached);
                  }
                }
              }
            } else {
              tileLoading = loading = true;
              var hitLimit = loadingLimit && loadingCount + preLoadingCount[0] > loadingLimit;
              if (!this._tileQueueIds.has(tile.id) && !hitLimit && (!map.isInteracting() || map.isMoving() || map.isRotating())) {
                loadingCount++;
                var key = tileId;
                tileQueue[key] = tile;
              }
            }
          }
          if (terrainTileMode && !isParentTile) {
            if (tiles.length === tilesCount) {
              missingTiles.push(tile);
            } else {
              checkedTiles[tile.id] = 1;
            }
          }
          if (terrainTileMode) continue;
          if (isParentTile) continue;
          if (!tileLoading) continue;
          if (checkedTiles[tileId]) continue;
          checkedTiles[tileId] = 1;
          if (placeholder && !placeholderKeys[tileId]) {
            tile.cache = false;
            placeholders.push({
              image: placeholder,
              info: tile
            });
            placeholderKeys[tileId] = 1;
          }
          var children = this._findChildTiles(tile);
          if (children.length) {
            children.forEach(function (c) {
              if (!childKeys[c.info.id]) {
                childTiles.push(c);
                childKeys[c.info.id] = 1;
              }
            });
          }
          if (!children.length || children.length !== 4) {
            var parentTile = this._findParentTile(tile);
            if (parentTile) {
              var parentId = parentTile.info.id;
              if (parentKeys[parentId] === undefined) {
                parentKeys[parentId] = parentTiles.length;
                parentTiles.push(parentTile);
              }
            }
          }
        }
      }
      var missedTiles = [];
      if (terrainTileMode) {
        for (var _i = 0; _i < missingTiles.length; _i++) {
          var _tile = missingTiles[_i].info ? missingTiles[_i].info : missingTiles[_i];
          if (!_tile.parent || checkedTiles[_tile.id]) {
            continue;
          }
          var _this$_findChildTiles = this._findChildTiles(_tile),
            _children = _this$_findChildTiles.tiles,
            childMissedTiles = _this$_findChildTiles.missedTiles;
          if (_children.length) {
            pushIn(tiles, _children);
            pushIn(missedTiles, childMissedTiles);
            continue;
          } else if (incompleteTiles.has(_tile.id)) {
            tiles.push(incompleteTiles.get(_tile.id));
            incompleteTiles.delete(_tile.id);
            continue;
          }
          checkedTiles[_tile.id] = 1;
          missedTiles.push(_tile);
        }
      }
      this.tileCache.shrink();
      return {
        childTiles: childTiles,
        missedTiles: missedTiles,
        parentTiles: parentTiles,
        tiles: tiles,
        incompleteTiles: incompleteTiles && Array.from(incompleteTiles.values()),
        placeholders: placeholders,
        loading: loading,
        loadingCount: loadingCount,
        tileQueue: tileQueue
      };
    };
    _proto2.removeTileCache = function removeTileCache(tileId) {
      delete this.tilesInView[tileId];
      this.tileCache.remove(tileId);
    };
    _proto2.isTileCachedOrLoading = function isTileCachedOrLoading(tileId) {
      return this.tileCache.get(tileId) || this.tilesInView[tileId] || this.tilesLoading[tileId];
    };
    _proto2.isTileCached = function isTileCached(tileId) {
      return !!(this.tileCache.get(tileId) || this.tilesInView[tileId]);
    };
    _proto2.isTileFadingIn = function isTileFadingIn(tileImage) {
      return this._getTileFadingOpacity(tileImage) < 1;
    };
    _proto2._drawTiles = function _drawTiles(tiles, parentTiles, childTiles, placeholders, parentContext) {
      var _this2 = this;
      if (parentTiles.length) {
        parentTiles.sort(this._compareTiles);
        this._parentTiles = parentTiles;
      }
      if (childTiles.length) {
        this._childTiles = childTiles;
        this._childTiles.sort(this._compareTiles);
      }
      var drawBackground = true;
      var backgroundTimestamp = this.canvas._parentTileTimestamp;
      if (this.layer.constructor === TileLayer || this.layer.constructor === WMSTileLayer) {
        if (this._renderTimestamp === backgroundTimestamp) {
          drawBackground = false;
        } else {
          this.canvas._parentTileTimestamp = this._renderTimestamp;
        }
      }
      var renderInGL = this.layer.options.renderer === 'gl' && (!this.isGL || this.isGL());
      var context = {
        tiles: tiles,
        parentTiles: this._parentTiles,
        childTiles: this._childTiles,
        parentContext: parentContext
      };
      this.onDrawTileStart(context, parentContext);
      if (drawBackground && this.layer.options['opacity'] === 1) {
        this.layer._silentConfig = true;
        var fadingAnimation = this.layer.options['fadeAnimation'];
        this.layer.options['fadeAnimation'] = false;
        if (renderInGL) {
          this._drawChildTiles(childTiles, parentContext);
          this._drawParentTiles(this._parentTiles, parentContext);
        } else {
          this._drawParentTiles(this._parentTiles, parentContext);
          this._drawChildTiles(childTiles, parentContext);
        }
        this.layer.options['fadeAnimation'] = fadingAnimation;
        this.layer._silentConfig = false;
      }
      this.drawingCurrentTiles = true;
      tiles.sort(this._compareTiles);
      for (var i = 0, l = tiles.length; i < l; i++) {
        this._drawTileAndCache(tiles[i], parentContext);
      }
      delete this.drawingCurrentTiles;
      if (drawBackground && this.layer.options['opacity'] < 1) {
        this.layer._silentConfig = true;
        var _fadingAnimation = this.layer.options['fadeAnimation'];
        this.layer.options['fadeAnimation'] = false;
        if (renderInGL) {
          this._drawChildTiles(childTiles, parentContext);
          this._drawParentTiles(this._parentTiles, parentContext);
        } else {
          this._drawParentTiles(this._parentTiles, parentContext);
          this._drawChildTiles(childTiles, parentContext);
        }
        this.layer.options['fadeAnimation'] = _fadingAnimation;
        this.layer._silentConfig = false;
      }
      placeholders.forEach(function (t) {
        return _this2._drawTile(t.info, t.image, parentContext);
      });
      this.onDrawTileEnd(context, parentContext);
    };
    _proto2._drawChildTiles = function _drawChildTiles(childTiles, parentContext) {
      var _this3 = this;
      this.drawingChildTiles = true;
      childTiles.forEach(function (t) {
        return _this3._drawTile(t.info, t.image, parentContext);
      });
      delete this.drawingChildTiles;
    };
    _proto2._drawParentTiles = function _drawParentTiles(parentTiles, parentContext) {
      var _this4 = this;
      this.drawingParentTiles = true;
      this._parentTiles.forEach(function (t) {
        return _this4._drawTile(t.info, t.image, parentContext);
      });
      delete this.drawingParentTiles;
    };
    _proto2.onDrawTileStart = function onDrawTileStart() {};
    _proto2.onDrawTileEnd = function onDrawTileEnd() {};
    _proto2._drawTile = function _drawTile(info, image, parentContext) {
      if (image) {
        this.drawTile(info, image, parentContext);
      }
    };
    _proto2._drawTileAndCache = function _drawTileAndCache(tile, parentContext) {
      if (this.isValidCachedTile(tile)) {
        this._addTileToCache(tile.info, tile.image);
      }
      this._drawTile(tile.info, tile.image, parentContext);
    };
    _proto2.drawOnInteracting = function drawOnInteracting(event, timestamp, context) {
      this.draw(timestamp, context);
    };
    _proto2.needToRedraw = function needToRedraw() {
      var map = this.getMap();
      if (this._tileQueue.length) {
        return true;
      }
      if (map.getPitch()) {
        return _CanvasRenderer.prototype.needToRedraw.call(this);
      }
      if (map.isRotating() || map.isZooming()) {
        return true;
      }
      if (map.isMoving()) {
        return !!this.layer.options['forceRenderOnMoving'];
      }
      return _CanvasRenderer.prototype.needToRedraw.call(this);
    };
    _proto2.hitDetect = function hitDetect() {
      return false;
    };
    _proto2._getLoadLimit = function _getLoadLimit() {
      if (this.getMap().isInteracting()) {
        return this.layer.options['loadingLimitOnInteracting'];
      }
      return this.layer.options['loadingLimit'] || 0;
    };
    _proto2.isDrawable = function isDrawable() {
      if (this.getMap().getPitch()) {
        if (console) {
          console.warn('TileLayer with canvas renderer can\'t be pitched, use gl renderer (\'renderer\' : \'gl\') instead.');
        }
        this.clear();
        return false;
      }
      return true;
    };
    _proto2.clear = function clear() {
      this.retireTiles(true);
      this.tileCache.reset();
      this.tilesInView = {};
      this.tilesLoading = {};
      this._tileQueue = [];
      this._tileQueueIds.clear();
      this._parentTiles = [];
      this._childTiles = [];
      _CanvasRenderer.prototype.clear.call(this);
    };
    _proto2._isLoadingTile = function _isLoadingTile(tileId) {
      return !!this.tilesLoading[tileId];
    };
    _proto2.clipCanvas = function clipCanvas(context) {
      return _CanvasRenderer.prototype.clipCanvas.call(this, context);
    };
    _proto2._clipByPitch = function _clipByPitch(ctx) {
      var map = this.getMap();
      if (map.getPitch() <= map.options['maxVisualPitch']) {
        return false;
      }
      if (!this.layer.options['clipByPitch']) {
        return false;
      }
      var clipExtent = map.getContainerExtent();
      var r = map.getDevicePixelRatio();
      ctx.save();
      ctx.strokeStyle = 'rgba(0, 0, 0, 0)';
      ctx.beginPath();
      ctx.rect(0, Math.ceil(clipExtent.ymin) * r, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(clipExtent.getHeight()) * r);
      ctx.stroke();
      ctx.clip();
      return true;
    };
    _proto2.loadTileQueue = function loadTileQueue(tileQueue) {
      for (var p in tileQueue) {
        if (tileQueue.hasOwnProperty(p)) {
          var tile = tileQueue[p];
          var tileImage = this.loadTile(tile);
          if (tileImage.loadTime === undefined) {
            this.tilesLoading[tile['id']] = {
              image: tileImage,
              current: true,
              info: tile
            };
          }
        }
      }
    };
    _proto2.loadTile = function loadTile(tile) {
      var _this5 = this;
      var tileImage = {};
      if (this.loadTileBitmap) {
        var onLoad = function onLoad(bitmap) {
          _this5.onTileLoad(bitmap, tile);
        };
        this.loadTileBitmap(tile['url'], tile, onLoad);
      } else if (this._tileImageWorkerConn && this.loadTileImage === this.constructor.prototype.loadTileImage) {
        this._fetchImage(tileImage, tile);
      } else {
        var tileSize = this.layer.getTileSize(tile.layer);
        tileImage = new Image();
        tileImage.width = tileSize['width'];
        tileImage.height = tileSize['height'];
        tileImage.onload = this.onTileLoad.bind(this, tileImage, tile);
        tileImage.onerror = this.onTileError.bind(this, tileImage, tile);
        this.loadTileImage(tileImage, tile['url']);
      }
      return tileImage;
    };
    _proto2._fetchImage = function _fetchImage(image, tile) {
      var _this6 = this;
      if (image instanceof Image) {
        image.src = tile.url;
      } else {
        var x = tile.x,
          y = tile.y;
        var workerId = Math.abs(x + y) % this._tileImageWorkerConn.workers.length;
        this._tileImageWorkerConn.fetchImage(tile.url, workerId, function (err, data) {
          if (err) {
            _this6.onTileError(image, tile, err);
          } else {
            getImageBitMap(data, function (bitmap) {
              _this6.onTileLoad(bitmap, tile);
            });
          }
        }, this.layer.options['fetchOptions'] || {
          referrer: document.location.href,
          headers: {
            accept: 'image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8'
          }
        });
      }
    };
    _proto2.loadTileImage = function loadTileImage(tileImage, url) {
      var crossOrigin = this.layer.options['crossOrigin'];
      if (!isNil(crossOrigin)) {
        tileImage.crossOrigin = crossOrigin;
      }
      return loadImage(tileImage, [url]);
    };
    _proto2.abortTileLoading = function abortTileLoading(tileImage, tileInfo) {
      if (tileInfo && tileInfo.id !== undefined) {
        this.removeTileLoading(tileInfo);
      }
      if (!tileImage) return;
      if (tileImage instanceof Image) {
        tileImage.onload = falseFn;
        tileImage.onerror = falseFn;
        tileImage.src = emptyImageUrl;
      }
    };
    _proto2.onTileLoad = function onTileLoad(tileImage, tileInfo) {
      this.removeTileLoading(tileInfo);
      this._tileQueue.push({
        tileInfo: tileInfo,
        tileData: tileImage
      });
      this._tileQueueIds.add(tileInfo.id);
      this.setToRedraw();
    };
    _proto2.removeTileLoading = function removeTileLoading(tileInfo) {
      delete this.tilesLoading[tileInfo.id];
      this.setToRedraw();
    };
    _proto2._consumeTileQueue = function _consumeTileQueue() {
      var count = 0;
      var limit = this.layer.options['tileLimitPerFrame'];
      var queue = this._tileQueue;
      while (queue.length && (limit <= 0 || count < limit)) {
        var _queue$shift = queue.shift(),
          tileData = _queue$shift.tileData,
          tileInfo = _queue$shift.tileInfo;
        if (!this._tileQueueIds.has(tileInfo.id)) {
          continue;
        }
        this._tileQueueIds.delete(tileInfo.id);
        if (!this.checkTileInQueue(tileData, tileInfo)) {
          continue;
        }
        this.consumeTile(tileData, tileInfo);
        count++;
      }
    };
    _proto2._computeAvgTileAltitude = function _computeAvgTileAltitude() {
      var sumMin = 0;
      var sumMax = 0;
      var count = 0;
      for (var p in this.tilesInView) {
        var info = this.tilesInView[p] && this.tilesInView[p].info;
        if (info) {
          sumMin += info.minAltitude || 0;
          sumMax += info.maxAltitude || 0;
          count++;
        }
      }
      this.avgMinAltitude = sumMin / count;
      this.avgMaxAltitude = sumMax / count;
    };
    _proto2.checkTileInQueue = function checkTileInQueue() {
      return true;
    };
    _proto2.consumeTile = function consumeTile(tileImage, tileInfo) {
      if (!this.layer) {
        return;
      }
      if (!this.tilesInView) {
        return;
      }
      var e = {
        tile: tileInfo,
        tileImage: tileImage
      };
      tileImage = e.tileImage;
      this.resetTileLoadTime(tileImage);
      this.removeTileLoading(tileInfo);
      this._addTileToCache(tileInfo, tileImage);
      this.layer.fire('tileload', e);
      this.setToRedraw();
    };
    _proto2.resetTileLoadTime = function resetTileLoadTime(tileImage) {
      tileImage.loadTime = now();
    };
    _proto2.onTileError = function onTileError(tileImage, tileInfo) {
      if (!this.layer) {
        return;
      }
      tileImage.onerrorTick = tileImage.onerrorTick || 0;
      var tileRetryCount = this.layer.options['tileRetryCount'];
      if (tileRetryCount > tileImage.onerrorTick) {
        tileImage.onerrorTick++;
        this._fetchImage(tileImage, tileInfo);
        this.removeTileLoading(tileInfo);
        return;
      }
      var errorUrl = this.layer.options['errorUrl'];
      if (errorUrl) {
        if (tileImage instanceof Image && tileImage.src !== errorUrl) {
          tileImage.src = errorUrl;
          this.removeTileLoading(tileInfo);
          return;
        } else {
          tileImage = new Image();
          tileImage.src = errorUrl;
        }
      }
      tileImage = tileImage instanceof Image ? tileImage : BLANK_IMAGE;
      this.abortTileLoading(tileImage, tileInfo);
      tileImage.loadTime = 0;
      this.removeTileLoading(tileInfo);
      this._addTileToCache(tileInfo, tileImage);
      this.setToRedraw();
      this.layer.fire('tileerror', {
        tile: tileInfo
      });
    };
    _proto2.drawTile = function drawTile(tileInfo, tileImage) {
      if (!tileImage || !this.getMap()) {
        return;
      }
      var extent2d = tileInfo.extent2d,
        offset = tileInfo.offset;
      var point = TILE_POINT.set(extent2d.xmin - offset[0], extent2d.ymax - offset[1]),
        tileZoom = tileInfo.z,
        tileId = tileInfo.id;
      var map = this.getMap(),
        zoom = map.getZoom(),
        ctx = this.context,
        cp = map._pointAtResToContainerPoint(point, tileInfo.res, 0, TEMP_POINT$5),
        bearing = map.getBearing(),
        transformed = bearing || zoom !== tileZoom;
      var opacity = this.getTileOpacity(tileImage, tileInfo);
      var alpha = ctx.globalAlpha;
      if (opacity < 1) {
        ctx.globalAlpha = opacity;
      }
      if (!transformed) {
        cp._round();
      }
      var x = cp.x,
        y = cp.y;
      var w = tileInfo.extent2d.xmax - tileInfo.extent2d.xmin;
      var h = tileInfo.extent2d.ymax - tileInfo.extent2d.ymin;
      var layer = this.layer;
      var bufferPixel = layer ? layer.options.bufferPixel : 0;
      if (transformed) {
        ctx.save();
        ctx.translate(x, y);
        if (bearing) {
          ctx.rotate(-bearing * Math.PI / 180);
        }
        w += bufferPixel;
        h += bufferPixel;
        var res = map._getResolution();
        if (res !== tileInfo.res) {
          var scale = tileInfo.res / res;
          ctx.scale(scale, scale);
        }
        x = y = 0;
      }
      Canvas.image(ctx, tileImage, x, y, w, h);
      if (this.layer.options['debug']) {
        var color = this.layer.options['debugOutline'];
        ctx.save();
        ctx.strokeStyle = color;
        ctx.fillStyle = color;
        ctx.strokeWidth = 10;
        ctx.font = '20px monospace';
        var _point = new Point(x, y);
        Canvas.rectangle(ctx, _point, {
          width: w,
          height: h
        }, 1, 0);
        Canvas.fillText(ctx, this.getDebugInfo(tileId), _point._add(32, h - 14), color);
        Canvas.drawCross(ctx, x + w / 2, y + h / 2, 2, color);
        ctx.restore();
      }
      if (transformed) {
        ctx.restore();
      }
      if (ctx.globalAlpha !== alpha) {
        ctx.globalAlpha = alpha;
      }
      this.setCanvasUpdated();
    };
    _proto2.getDebugInfo = function getDebugInfo(tileId) {
      var xyz = tileId.split('_');
      var length = xyz.length;
      return xyz[length - 3] + '/' + xyz[length - 2] + '/' + xyz[length - 1];
    };
    _proto2.findChildTiles = function findChildTiles(info) {
      return this._findChildTiles(info);
    };
    _proto2._findChildTiles = function _findChildTiles(info) {
      var layer = this._getLayerOfTile(info.layer);
      var terrainTileMode = layer && layer.options['terrainTileMode'] && layer._isPyramidMode();
      if (!layer || !layer.options['background'] && !terrainTileMode || info.z > this.layer.getMaxZoom()) {
        return EMPTY_ARRAY$2;
      }
      var map = this.getMap();
      var children = [];
      if (layer._isPyramidMode()) {
        if (!terrainTileMode) {
          var _layer = this._getLayerOfTile(info.layer);
          var _zoomDiff = 2;
          var _cx = info.x * 2;
          var _cy = info.y * 2;
          var _cz = info.z + 1;
          var queue = [];
          for (var j = 0; j < 2; j++) {
            for (var jj = 0; jj < 2; jj++) {
              queue.push(_cx + j, _cy + jj, _cz);
            }
          }
          while (queue.length) {
            var z = queue.pop();
            var y = queue.pop();
            var x = queue.pop();
            var id = _layer._getTileId(x, y, z, info.layer);
            var canVisit = z + 1 <= info.z + _zoomDiff;
            var tile = this.tileCache.getAndRemove(id);
            if (tile) {
              if (this.isValidCachedTile(tile)) {
                children.push(tile);
                this.tileCache.add(id, tile);
              } else if (canVisit) {
                for (var _j = 0; _j < 2; _j++) {
                  for (var _jj = 0; _jj < 2; _jj++) {
                    queue.push(x * 2 + _j, y * 2 + _jj, z + 1);
                  }
                }
              }
            } else if (canVisit) {
              for (var _j2 = 0; _j2 < 2; _j2++) {
                for (var _jj2 = 0; _jj2 < 2; _jj2++) {
                  queue.push(x * 2 + _j2, y * 2 + _jj2, z + 1);
                }
              }
            }
          }
          return children;
        }
        var missedTiles;
        if (terrainTileMode) {
          missedTiles = [];
        }
        var cx = info.x * 2;
        var cy = info.y * 2;
        var cz = info.z + 1;
        var candidates = [];
        for (var i = 0; i < 2; i++) {
          for (var ii = 0; ii < 2; ii++) {
            var _x = cx + i;
            var _y = cy + ii;
            var _z = cz;
            var _id = layer._getTileId(_x, _y, _z, info.layer);
            var _tile2 = this.tileCache.getAndRemove(_id);
            if (_tile2 && this.isValidCachedTile(_tile2)) {
              children.push(_tile2);
              this.tileCache.add(_id, _tile2);
              candidates.push(null);
            } else {
              candidates.push(_id);
            }
          }
        }
        if (children.length < 4) {
          var index = 0;
          for (var _i2 = 0; _i2 < 2; _i2++) {
            for (var _ii = 0; _ii < 2; _ii++) {
              var _id2 = candidates[index++];
              if (!_id2) {
                continue;
              }
              var _x2 = cx + _i2;
              var _y2 = cy + _ii;
              var _z2 = cz;
              var childrenCount = children.length;
              var childCandidates = [];
              for (var _j3 = 0; _j3 < 2; _j3++) {
                for (var _jj3 = 0; _jj3 < 2; _jj3++) {
                  var xx = _x2 * 2 + _j3;
                  var yy = _y2 * 2 + _jj3;
                  var zz = _z2 + 1;
                  var _id3 = layer._getTileId(xx, yy, zz, info.layer);
                  var childTile = this.tileCache.getAndRemove(_id3);
                  if (childTile && this.isValidCachedTile(childTile)) {
                    children.push(childTile);
                    this.tileCache.add(_id3, childTile);
                    childCandidates.push(null);
                  } else {
                    childCandidates.push(_id3);
                  }
                }
              }
              if (!terrainTileMode) {
                continue;
              }
              if (children.length - childrenCount < 4) {
                var childTileInfo = layer.tileInfoCache.get(_id2) || layer._createChildNode(info, _i2, _ii, [0, 0], _id2);
                if (children.length - childrenCount === 0) {
                  missedTiles.push(childTileInfo);
                } else {
                  var _index = 0;
                  for (var _j4 = 0; _j4 < 2; _j4++) {
                    for (var _jj4 = 0; _jj4 < 2; _jj4++) {
                      var _id4 = childCandidates[_index++];
                      if (!_id4) {
                        continue;
                      }
                      var grandsonTileInfo = this.layer.tileInfoCache.get(_id4) || layer._createChildNode(childTileInfo, _j4, _jj4, [0, 0], _id4);
                      missedTiles.push(grandsonTileInfo);
                    }
                  }
                }
              }
            }
          }
        }
        return terrainTileMode ? {
          tiles: children,
          missedTiles: missedTiles
        } : children;
      }
      var zoomDiff = 1;
      var res = info.res;
      var min = info.extent2d.getMin(),
        max = info.extent2d.getMax(),
        pmin = layer._project(map._pointToPrjAtRes(min, res, TEMP_POINT1$2), TEMP_POINT1$2),
        pmax = layer._project(map._pointToPrjAtRes(max, res, TEMP_POINT2$2), TEMP_POINT2$2);
      for (var _i3 = 1; _i3 < zoomDiff; _i3++) {
        this._findChildTilesAt(children, pmin, pmax, layer, info.z + _i3);
      }
      return children;
    };
    _proto2._findChildTilesAt = function _findChildTilesAt(children, pmin, pmax, layer, childZoom) {
      var layerId = layer.getId(),
        res = layer.getSpatialReference().getResolution(childZoom);
      if (!res) {
        return;
      }
      var dmin = layer._getTileConfig().getTileIndex(pmin, res),
        dmax = layer._getTileConfig().getTileIndex(pmax, res);
      var sx = Math.min(dmin.idx, dmax.idx),
        ex = Math.max(dmin.idx, dmax.idx);
      var sy = Math.min(dmin.idy, dmax.idy),
        ey = Math.max(dmin.idy, dmax.idy);
      var id, tile;
      for (var i = sx; i < ex; i++) {
        for (var ii = sy; ii < ey; ii++) {
          id = layer._getTileId(i, ii, childZoom, layerId);
          tile = this.tileCache.getAndRemove(id);
          if (tile) {
            if (this.isValidCachedTile(tile)) {
              children.push(tile);
              this.tileCache.add(id, tile);
            }
          }
        }
      }
    };
    _proto2.findParentTile = function findParentTile(info, targetDiff) {
      return this._findParentTile(info, targetDiff);
    };
    _proto2._findParentTile = function _findParentTile(info, targetDiff) {
      var map = this.getMap(),
        layer = this._getLayerOfTile(info.layer);
      if (!layer || !layer.options['background'] && !layer.options['terrainTileMode']) {
        return null;
      }
      var minZoom = layer.getMinZoom();
      var zoomDiff = targetDiff || info.z - minZoom;
      if (layer._isPyramidMode()) {
        var endZoom = info.z - zoomDiff;
        for (var z = info.z - 1; z >= endZoom; z--) {
          var diff = info.z - z;
          var scale = Math.pow(2, diff);
          var x = Math.floor(info.x / scale);
          var y = Math.floor(info.y / scale);
          var id = void 0;
          if (z === info.z - 1) {
            id = info.parent;
          } else {
            id = layer._getTileId(x, y, z, info.layer);
          }
          var tile = this.tileCache.getAndRemove(id);
          if (tile) {
            if (this.isValidCachedTile(tile)) {
              this.tileCache.add(id, tile);
              return tile;
            }
          }
        }
        return null;
      }
      var sr = layer.getSpatialReference();
      var d = sr.getZoomDirection();
      var res = info.res;
      var center = info.extent2d.getCenter(),
        prj = layer._project(map._pointToPrjAtRes(center, res));
      for (var _diff = 1; _diff <= zoomDiff; _diff++) {
        var _z3 = info.z - d * _diff;
        var _res = sr.getResolution(_z3);
        if (!_res) continue;
        var tileIndex = layer._getTileConfig().getTileIndex(prj, _res);
        var _id5 = layer._getTileId(tileIndex.x, tileIndex.y, _z3, info.layer);
        var _tile3 = this.tileCache.getAndRemove(_id5);
        if (_tile3) {
          this.tileCache.add(_id5, _tile3);
          return _tile3;
        }
      }
      return null;
    };
    _proto2.isValidCachedTile = function isValidCachedTile(tile) {
      return !!tile.image;
    };
    _proto2.isTileComplete = function isTileComplete() {
      return true;
    };
    _proto2._getLayerOfTile = function _getLayerOfTile(layerId) {
      return this.layer.getChildLayer ? this.layer.getChildLayer(layerId) : this.layer;
    };
    _proto2.getCachedTile = function getCachedTile(tile, isParent) {
      var tileId = tile.id;
      var tilesInView = this.tilesInView;
      var cached = this.tileCache.getAndRemove(tileId);
      if (cached) {
        if (!isParent) {
          tilesInView[tileId] = cached;
        }
        var tilesLoading = this.tilesLoading;
        if (tilesLoading && tilesLoading[tileId]) {
          this.markCurrent(tilesLoading[tileId], false);
          var _tilesLoading$tileId = tilesLoading[tileId],
            image = _tilesLoading$tileId.image,
            info = _tilesLoading$tileId.info;
          this.abortTileLoading(image, info);
          delete tilesLoading[tileId];
        }
      } else {
        cached = tilesInView[tileId];
      }
      if (cached) {
        cached.current = true;
        if (this.isValidCachedTile(cached)) {
          this.tileCache.add(tileId, cached);
        }
      }
      return cached;
    };
    _proto2._addTileToCache = function _addTileToCache(tileInfo, tileImage) {
      if (this.isValidCachedTile({
        info: tileInfo,
        image: tileImage
      })) {
        this.tilesInView[tileInfo.id] = {
          image: tileImage,
          current: true,
          info: tileInfo
        };
      }
    };
    _proto2.getTileOpacity = function getTileOpacity(tileImage, tileInfo) {
      var opacity = this._getTileFadingOpacity(tileImage);
      if (this.layer.getChildLayer) {
        var childLayer = this.layer.getLayer(tileInfo.layer);
        if (childLayer) {
          opacity *= childLayer.options['opacity'];
        }
      }
      return opacity;
    };
    _proto2._getTileFadingOpacity = function _getTileFadingOpacity(tileImage) {
      if (!this.layer.options['fadeAnimation'] || !tileImage.loadTime) {
        return 1;
      }
      return Math.min(1, (now() - tileImage.loadTime) / this.layer.options['fadeDuration']);
    };
    _proto2.onRemove = function onRemove() {
      this.clear();
      delete this.tileCache;
      delete this._tilePlaceHolder;
      delete this._tileZoom;
      _CanvasRenderer.prototype.onRemove.call(this);
    };
    _proto2.markCurrent = function markCurrent(tile, isCurrent) {
      tile.current = isCurrent;
    };
    _proto2.markTiles = function markTiles() {
      var a = 0,
        b = 0;
      if (this.tilesLoading) {
        for (var p in this.tilesLoading) {
          this.markCurrent(this.tilesLoading[p], false);
          a++;
        }
      }
      if (this.tilesInView) {
        for (var _p in this.tilesInView) {
          this.markCurrent(this.tilesInView[_p], false);
          b++;
        }
      }
      return [a, b];
    };
    _proto2.retireTiles = function retireTiles(force) {
      for (var i in this.tilesLoading) {
        var tile = this.tilesLoading[i];
        if (force || !tile.current) {
          if (tile.image) {
            this.abortTileLoading(tile.image, tile.info);
          }
          this.deleteTile(tile);
          this.removeTileLoading(tile.info);
        }
      }
      for (var _i4 in this.tilesInView) {
        var _tile4 = this.tilesInView[_i4];
        if (!_tile4.current) {
          delete this.tilesInView[_i4];
          if (!this.tileCache.has(_i4)) {
            this.deleteTile(_tile4);
          }
        }
      }
    };
    _proto2.deleteTile = function deleteTile(tile) {
      if (!tile || !tile.image) {
        return;
      }
      var tileId = tile.info.id;
      if (this._tileQueueIds.has(tileId)) {
        this._tileQueueIds.delete(tileId);
      }
      if (tile.image.close) {
        tile.image.close();
      }
      if (tile.image instanceof Image) {
        tile.image.onload = null;
        tile.image.onerror = null;
      }
    };
    _proto2._generatePlaceHolder = function _generatePlaceHolder(res) {
      var map = this.getMap();
      var placeholder = this.layer.options['placeholder'];
      if (!placeholder || map.getPitch()) {
        return null;
      }
      var tileSize = this.layer.getTileSize(),
        scale = res / map._getResolution(),
        canvas = this._tilePlaceHolder = this._tilePlaceHolder || Canvas.createCanvas(1, 1, map.CanvasClass);
      canvas.width = tileSize.width * scale;
      canvas.height = tileSize.height * scale;
      if (isFunction(placeholder)) {
        placeholder(canvas);
      } else {
        defaultPlaceholder(canvas);
      }
      return canvas;
    };
    _proto2.setTerrainHelper = function setTerrainHelper(helper) {
      this._terrainHelper = helper;
    };
    return TileLayerCanvasRenderer;
  }(CanvasRenderer);
  TileLayer.registerRenderer('canvas', TileLayerCanvasRenderer);
  function falseFn() {
    return false;
  }
  function defaultPlaceholder(canvas) {
    var ctx = canvas.getContext('2d'),
      cw = canvas.width,
      ch = canvas.height,
      w = cw / 16,
      h = ch / 16;
    ctx.beginPath();
    for (var i = 0; i < 16; i++) {
      ctx.moveTo(0, i * h);
      ctx.lineTo(cw, i * h);
      ctx.moveTo(i * w, 0);
      ctx.lineTo(i * w, ch);
    }
    ctx.strokeStyle = 'rgba(180, 180, 180, 0.1)';
    ctx.lineWidth = 1;
    ctx.stroke();
    ctx.beginPath();
    var path = [[0, 0], [cw, 0], [0, ch], [cw, ch], [0, 0], [0, ch], [cw, 0], [cw, ch], [0, ch / 2], [cw, ch / 2], [cw / 2, 0], [cw / 2, ch]];
    for (var _i5 = 1; _i5 < path.length; _i5 += 2) {
      ctx.moveTo(path[_i5 - 1][0], path[_i5 - 1][1]);
      ctx.lineTo(path[_i5][0], path[_i5][1]);
    }
    ctx.lineWidth = 1 * 4;
    ctx.stroke();
  }
  function compareTiles(a, b) {
    return Math.abs(this._tileZoom - a.info.z) - Math.abs(this._tileZoom - b.info.z);
  }

  var TILE_POINT$1 = new Point(0, 0);
  var MESH_TO_TEST = {
    properties: {}
  };
  var TileLayerGLRenderer = function (_ImageGLRenderable) {
    _inheritsLoose(TileLayerGLRenderer, _ImageGLRenderable);
    function TileLayerGLRenderer() {
      return _ImageGLRenderable.apply(this, arguments) || this;
    }
    var _proto = TileLayerGLRenderer.prototype;
    _proto.isDrawable = function isDrawable() {
      return true;
    };
    _proto.needToRedraw = function needToRedraw() {
      var map = this.getMap();
      if (this.isGL() && !map.getPitch() && map.isZooming() && !map.isMoving() && !map.isRotating()) {
        return true;
      }
      return _ImageGLRenderable.prototype.needToRedraw.call(this);
    };
    _proto.onDrawTileStart = function onDrawTileStart(context, parentContext) {
      var gl = this.gl;
      gl.enable(gl.DEPTH_TEST);
      gl.depthFunc(gl.LEQUAL);
      gl.enable(gl.POLYGON_OFFSET_FILL);
      gl.enable(gl.STENCIL_TEST);
      gl.stencilOp(gl.KEEP, gl.KEEP, gl.REPLACE);
      var depthMask = !!this.layer.options['depthMask'];
      gl.depthMask(depthMask);
      if (parentContext && parentContext.renderTarget) {
        var fbo = parentContext.renderTarget.fbo;
        if (fbo) {
          var framebuffer = parentContext.renderTarget.getFramebuffer(fbo);
          gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
        }
      }
    };
    _proto.onDrawTileEnd = function onDrawTileEnd(context, parentContext) {
      var gl = this.gl;
      if (parentContext && parentContext.renderTarget) {
        var fbo = parentContext.renderTarget.fbo;
        if (fbo) {
          gl.bindFramebuffer(gl.FRAMEBUFFER, null);
        }
      }
    };
    _proto.drawTile = function drawTile(tileInfo, tileImage, parentContext) {
      if (parentContext && parentContext.sceneFilter) {
        if (!parentContext.sceneFilter(MESH_TO_TEST)) {
          return;
        }
      }
      var map = this.getMap();
      if (!tileInfo || !map || !tileImage) {
        return;
      }
      var scale = tileInfo._glScale = tileInfo._glScale || tileInfo.res / map.getGLRes();
      var w = tileInfo.extent2d.xmax - tileInfo.extent2d.xmin;
      var h = tileInfo.extent2d.ymax - tileInfo.extent2d.ymin;
      if (tileInfo.cache !== false) {
        this._bindGLBuffer(tileImage, w, h);
      }
      if (!this.isGL()) {
        _ImageGLRenderable.prototype.drawTile.call(this, tileInfo, tileImage);
        return;
      }
      var extent2d = tileInfo.extent2d,
        offset = tileInfo.offset;
      var point = TILE_POINT$1.set(extent2d.xmin - offset[0], tileInfo.extent2d.ymax - offset[1]);
      var x = point.x * scale,
        y = point.y * scale;
      var opacity = this.getTileOpacity(tileImage, tileInfo);
      var debugInfo = null;
      if (this.layer.options['debug']) {
        debugInfo = this.getDebugInfo(tileInfo.id);
      }
      var gl = this.gl;
      gl.stencilFunc(gl.LEQUAL, Math.abs(this.getCurrentTileZoom() - tileInfo.z), 0xFF);
      var layerPolygonOffset = this.layer.getPolygonOffset();
      var polygonOffset = this.drawingCurrentTiles ? layerPolygonOffset : layerPolygonOffset + 1;
      gl.polygonOffset(polygonOffset, polygonOffset);
      this.drawGLImage(tileImage, x, y, w, h, scale, opacity, debugInfo);
      if (this._getTileFadingOpacity(tileImage) < 1) {
        this.setToRedraw();
      } else {
        this.setCanvasUpdated();
      }
    };
    _proto._bindGLBuffer = function _bindGLBuffer(image, w, h) {
      if (!image.glBuffer) {
        image.glBuffer = this.bufferTileData(0, 0, w, h);
      }
    };
    _proto.loadTileImage = function loadTileImage(tileImage, url) {
      var crossOrigin = this.layer.options['crossOrigin'];
      tileImage.crossOrigin = crossOrigin !== null ? crossOrigin : '';
      tileImage.src = url;
      return;
    };
    _proto.onCanvasCreate = function onCanvasCreate() {
      if (!this.canvas.gl || !this.canvas.gl.wrap) {
        this.createCanvas2();
      }
    };
    _proto.createContext = function createContext() {
      _ImageGLRenderable.prototype.createContext.call(this);
      this.createGLContext();
    };
    _proto.resizeCanvas = function resizeCanvas(canvasSize) {
      if (!this.canvas) {
        return;
      }
      _ImageGLRenderable.prototype.resizeCanvas.call(this, canvasSize);
      this.resizeGLCanvas();
    };
    _proto.clearCanvas = function clearCanvas() {
      if (!this.canvas) {
        return;
      }
      _ImageGLRenderable.prototype.clearCanvas.call(this);
      this.clearGLCanvas();
    };
    _proto.getCanvasImage = function getCanvasImage() {
      if (!this.isGL() || !this.canvas2) {
        return _ImageGLRenderable.prototype.getCanvasImage.call(this);
      }
      var img = _ImageGLRenderable.prototype.getCanvasImage.call(this);
      if (img) {
        img.image = this.canvas2;
      }
      return img;
    };
    _proto.isGL = function isGL() {
      if (this.canvas.gl && this.canvas.gl.wrap) {
        return true;
      }
      var map = this.getMap();
      return map && (map.getPitch() || map.getBearing()) || this.layer && !!this.layer.options['fragmentShader'];
    };
    _proto.deleteTile = function deleteTile(tile) {
      _ImageGLRenderable.prototype.deleteTile.call(this, tile);
      if (tile && tile.image) {
        this.disposeImage(tile.image);
      }
      delete tile.image;
    };
    _proto.onRemove = function onRemove() {
      _ImageGLRenderable.prototype.onRemove.call(this);
      this.removeGLCanvas();
    };
    return TileLayerGLRenderer;
  }(ImageGLRenderable(TileLayerCanvasRenderer));
  TileLayer.registerRenderer('gl', TileLayerGLRenderer);

  function _loadTile(tile) {
    var tileSize = this.layer.getTileSize(),
      canvasClass = this.canvas.constructor,
      map = this.getMap();
    var r = map.getDevicePixelRatio();
    var tileCanvas = Canvas.createCanvas(tileSize['width'] * r, tileSize['height'] * r, canvasClass);
    tileCanvas['layer'] = this.layer;
    var me = this;
    var point = new Point(tile['extent2d'].xmin, tile['extent2d'].ymax);
    var extent = new Extent(map.pointToCoordinate(point), map.pointToCoordinate(point.add(tileSize.width, tileSize.height)), map.getProjection());
    this.layer.drawTile(tileCanvas, {
      'url': tile['url'],
      'point': point,
      'center': map.pointToCoordinate(point.add(tileSize['width'] / 2, tileSize['height'] / 2)),
      'extent': extent,
      'z': tile['z'],
      'x': tile['x'],
      'y': tile['y']
    }, function (error) {
      if (error) {
        me.onTileError(tileCanvas, tile);
        return;
      }
      me.onTileLoad(tileCanvas, tile);
    });
    return tileCanvas;
  }
  var CanvasRenderer$1 = function (_TileLayerCanvasRende) {
    _inheritsLoose(CanvasRenderer, _TileLayerCanvasRende);
    function CanvasRenderer() {
      return _TileLayerCanvasRende.apply(this, arguments) || this;
    }
    var _proto = CanvasRenderer.prototype;
    _proto.loadTile = function loadTile() {
      return _loadTile.apply(this, arguments);
    };
    return CanvasRenderer;
  }(TileLayerCanvasRenderer);
  var GLRenderer = function (_TileLayerGLRenderer) {
    _inheritsLoose(GLRenderer, _TileLayerGLRenderer);
    function GLRenderer() {
      return _TileLayerGLRenderer.apply(this, arguments) || this;
    }
    var _proto2 = GLRenderer.prototype;
    _proto2.loadTile = function loadTile() {
      return _loadTile.apply(this, arguments);
    };
    return GLRenderer;
  }(TileLayerGLRenderer);
  CanvasTileLayer.registerRenderer('canvas', CanvasRenderer$1);
  CanvasTileLayer.registerRenderer('gl', GLRenderer);

  var quadVertices = typeof Int8Array !== 'undefined' ? new Int8Array([-1, 1, 0, -1, -1, 0, 1, 1, 0, 1, -1, 0]) : [];
  var vert = "\n    attribute vec3 a_position;\n    uniform mat4 transform;\n\n    void main()\n    {\n        gl_Position = transform * vec4(a_position, 1.0);\n    }\n";
  var frag = "\n    precision mediump float;\n    uniform vec3 color;\n    void main()\n    {\n        gl_FragColor = vec4(color, 1.0);\n    }\n";
  var QuadStencil = function () {
    function QuadStencil(gl, vertices, debug) {
      this.gl = gl;
      this.quadVertices = vertices || quadVertices;
      this.attributes = ['a_position', 3, getType(vertices)];
      this.debug = debug;
    }
    var _proto = QuadStencil.prototype;
    _proto.start = function start() {
      var gl = this.gl;
      gl.enable(gl.STENCIL_TEST);
      gl.stencilMask(0xFF);
      gl.stencilOp(gl.KEEP, gl.REPLACE, gl.REPLACE);
      gl.depthMask(false);
      this._save();
      if (!this.buffer) {
        this._createBuffer();
        this._createProgram();
      }
      gl.useProgram(this.program);
      gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
      enableVertexAttrib(gl, this.program, this.attributes);
      if (!this.transformLoc) {
        this.transformLoc = gl.getUniformLocation(this.program, 'transform');
      }
      if (!this.colorLoc) {
        this.colorLoc = gl.getUniformLocation(this.program, 'color');
      }
      if (this.debug) {
        return;
      }
      gl.colorMask(false, false, false, false);
    };
    _proto.end = function end() {
      var gl = this.gl;
      gl.depthMask(true);
      this._restore();
      if (this.debug) {
        return;
      }
      gl.colorMask(true, true, true, true);
    };
    _proto.draw = function draw(transform) {
      var gl = this.gl;
      gl.uniformMatrix4fv(this.transformLoc, false, transform);
      gl.uniform3fv(this.colorLoc, [Math.random(), Math.random(), Math.random()]);
      gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
    };
    _proto.remove = function remove() {
      var gl = this.gl;
      if (this.buffer) {
        gl.deleteBuffer(this.buffer);
      }
      if (this.program) {
        gl.deleteShader(this.program.fragmentShader);
        gl.deleteShader(this.program.vertexShader);
        gl.deleteProgram(this.program);
      }
      delete this.transformLoc;
      delete this.gl;
      return this;
    };
    _proto.stencilMask = function stencilMask(mask) {
      this.gl.stencilMask(mask);
      return this;
    };
    _proto.stencilFunc = function stencilFunc(func, ref, mask) {
      this.ref = ref;
      this.gl.stencilFunc(func, ref, mask);
      return this;
    };
    _proto.stencilOp = function stencilOp(fail, zfail, zpass) {
      this.gl.stencilOp(fail, zfail, zpass);
      return this;
    };
    _proto.resetFunc = function resetFunc() {
      this.ref = 1;
      this.gl.stencilFunc(this.gl.ALWAYS, 1, 0xFF);
      return this;
    };
    _proto._save = function _save() {
      var gl = this.gl;
      this._savedProgram = gl.program;
    };
    _proto._restore = function _restore() {
      var gl = this.gl;
      gl.program = this._savedProgram;
      if (gl.program) {
        gl.useProgram(gl.program);
      }
    };
    _proto._createBuffer = function _createBuffer() {
      var gl = this.gl;
      this.buffer = gl.createBuffer();
      if (!this.buffer) {
        throw new Error('Failed to create the buffer object');
      }
      gl.bindBuffer(gl.ARRAY_BUFFER, this.buffer);
      gl.bufferData(gl.ARRAY_BUFFER, this.quadVertices, gl.STATIC_DRAW);
    };
    _proto._createProgram = function _createProgram() {
      var _createProgram2 = createProgram(this.gl, vert, frag),
        program = _createProgram2.program,
        vertexShader = _createProgram2.vertexShader,
        fragmentShader = _createProgram2.fragmentShader;
      program.vertexShader = vertexShader;
      program.fragmentShader = fragmentShader;
      this.program = program;
    };
    return QuadStencil;
  }();
  function getType(arr) {
    if (arr instanceof Float32Array) {
      return 'FLOAT';
    } else if (arr instanceof Int16Array) {
      return 'SHORT';
    } else if (arr instanceof Uint16Array) {
      return 'UNSIGNED_SHORT';
    } else if (arr instanceof Int8Array) {
      return 'BYTE';
    } else if (arr instanceof Uint8Array || arr instanceof Uint8ClampedArray) {
      return 'UNSIGNED_BYTE';
    }
    return 'FLOAT';
  }

  var OverlayLayerRenderer = function (_CanvasRenderer) {
    _inheritsLoose(OverlayLayerRenderer, _CanvasRenderer);
    function OverlayLayerRenderer() {
      return _CanvasRenderer.apply(this, arguments) || this;
    }
    var _proto = OverlayLayerRenderer.prototype;
    _proto.checkResources = function checkResources() {
      var geometries = this._geosToCheck || [];
      if (!this._resourceChecked && this.layer._geoList) {
        pushIn(geometries, this.layer._geoList);
      }
      if (!isArrayHasData(geometries)) {
        return [];
      }
      var resources = [];
      var cache = {};
      for (var i = geometries.length - 1; i >= 0; i--) {
        var geo = geometries[i];
        var res = geo._getExternalResources();
        if (!res.length) {
          continue;
        }
        if (!this.resources) {
          resources.push.apply(resources, res);
        } else {
          for (var _i = 0; _i < res.length; _i++) {
            var url = res[_i][0];
            if (!this.resources.isResourceLoaded(res[_i]) && !cache[url]) {
              resources.push(res[_i]);
              cache[url] = 1;
            }
          }
        }
      }
      this._resourceChecked = true;
      delete this._geosToCheck;
      return resources;
    };
    _proto.render = function render() {
      this.layer._sortGeometries();
      return _CanvasRenderer.prototype.render.apply(this, arguments);
    };
    _proto._addGeoToCheckRes = function _addGeoToCheckRes(res) {
      if (!res) {
        return;
      }
      if (!Array.isArray(res)) {
        res = [res];
      }
      if (!this._geosToCheck) {
        this._geosToCheck = [];
      }
      pushIn(this._geosToCheck, res);
    };
    _proto.onGeometryAdd = function onGeometryAdd(geometries) {
      this._addGeoToCheckRes(geometries);
      redraw(this);
    };
    _proto.onGeometryRemove = function onGeometryRemove() {
      redraw(this);
    };
    _proto.onGeometrySymbolChange = function onGeometrySymbolChange(e) {
      this._addGeoToCheckRes(e.target);
      redraw(this);
    };
    _proto.onGeometryShapeChange = function onGeometryShapeChange() {
      redraw(this);
    };
    _proto.onGeometryPositionChange = function onGeometryPositionChange() {
      redraw(this);
    };
    _proto.onGeometryZIndexChange = function onGeometryZIndexChange() {
      redraw(this);
    };
    _proto.onGeometryShow = function onGeometryShow() {
      redraw(this);
    };
    _proto.onGeometryHide = function onGeometryHide() {
      redraw(this);
    };
    _proto.onGeometryPropertiesChange = function onGeometryPropertiesChange() {
      redraw(this);
    };
    return OverlayLayerRenderer;
  }(CanvasRenderer);
  function redraw(renderer) {
    if (renderer.layer.options['drawImmediate']) {
      renderer.render();
    }
    renderer.setToRedraw();
  }

  var TEMP_EXTENT$9 = new PointExtent();
  var TEMP_VEC3 = [];
  var TEMP_FIXEDEXTENT = new PointExtent();
  var PLACEMENT_CENTER = 'center';
  var tempCollisionIndex = new CollisionIndex();
  function clearCanvas(canvas) {
    if (!canvas) {
      return null;
    }
    var ctx = canvas.getContext('2d');
    ctx.clearRect(0, 0, canvas.width, canvas.height);
    return ctx;
  }
  function isDebug(layer) {
    return layer && layer.options.progressiveRender && layer.options.progressiveRenderDebug;
  }
  var VectorLayerRenderer = function (_OverlayLayerCanvasRe) {
    _inheritsLoose(VectorLayerRenderer, _OverlayLayerCanvasRe);
    function VectorLayerRenderer() {
      return _OverlayLayerCanvasRe.apply(this, arguments) || this;
    }
    var _proto = VectorLayerRenderer.prototype;
    _proto.setToRedraw = function setToRedraw() {
      _OverlayLayerCanvasRe.prototype.setToRedraw.call(this);
      this._resetProgressiveRender();
      return this;
    };
    _proto._geoIsCollision = function _geoIsCollision(geo, collisionIndex) {
      if (!geo) {
        return false;
      }
      var collision = geo.options.collision;
      if (!collision) {
        return false;
      }
      if (geo.isPoint && geo.getContainerExtent) {
        if (!geo.bbox) {
          geo.bbox = [0, 0, 0, 0];
        }
        var bufferSize = this.layer.options['collisionBufferSize'];
        var extent = geo.getContainerExtent();
        if (!extent) {
          return false;
        }
        geo.bbox[0] = extent.xmin - bufferSize;
        geo.bbox[1] = extent.ymin - bufferSize;
        geo.bbox[2] = extent.xmax + bufferSize;
        geo.bbox[3] = extent.ymax + bufferSize;
        if (collisionIndex.collides(geo.bbox)) {
          return true;
        }
        collisionIndex.insertBox(geo.bbox);
      }
      return false;
    };
    _proto.getImageData = function getImageData() {
      if (!this._lastRenderTime || now() - this._lastRenderTime < 32) {
        return null;
      }
      if (!this.context || !this.context.canvas) {
        return null;
      }
      if (!this._imageData) {
        var _this$context$canvas = this.context.canvas,
          width = _this$context$canvas.width,
          height = _this$context$canvas.height;
        try {
          this._imageData = this.context.getImageData(0, 0, width, height);
        } catch (error) {
          console.warn('hit detect failed with tainted canvas, some geometries have external resources in another domain:\n', error);
        }
      }
      return this._imageData;
    };
    _proto.clearImageData = function clearImageData() {
      this._imageData = null;
      delete this._imageData;
      this._lastRenderTime = now();
    };
    _proto.checkResources = function checkResources() {
      var _this = this;
      var resources = _OverlayLayerCanvasRe.prototype.checkResources.apply(this, arguments);
      var style = this.layer.getStyle();
      if (style) {
        if (!Array.isArray(style)) {
          style = [style];
        }
        style.forEach(function (s) {
          var res = getExternalResources(s['symbol'], true);
          for (var i = 0, l = res.length; i < l; i++) {
            if (!_this.resources.isResourceLoaded(res[i])) {
              resources.push(res[i]);
            }
          }
        });
      }
      return resources;
    };
    _proto.needToRedraw = function needToRedraw() {
      if (this.isProgressiveRender() && !this.renderEnd) {
        return true;
      }
      var map = this.getMap();
      if (map.isInteracting() && this.layer.options['enableAltitude']) {
        return true;
      }
      if (map.isZooming() && !map.isRotating() && !map.getPitch() && !this._hasPoint && this.layer.constructor === VectorLayer) {
        return false;
      }
      return _OverlayLayerCanvasRe.prototype.needToRedraw.call(this);
    };
    _proto.draw = function draw() {
      if (!this.getMap()) {
        return;
      }
      if (!this.layer.isVisible() || this.layer.isEmpty()) {
        this.clearCanvas();
        this.completeRender();
        return;
      }
      this.prepareCanvas();
      this.drawGeos();
      this.completeRender();
    };
    _proto.isBlank = function isBlank() {
      if (!this.context) {
        return false;
      }
      if (this.isProgressiveRender()) {
        return false;
      }
      return !this.context.canvas._drawn;
    };
    _proto.drawOnInteracting = function drawOnInteracting() {
      if (!this._geosToDraw) {
        return;
      }
      this._updateMapStateCache();
      this._updateDisplayExtent();
      var map = this.getMap();
      var count = this.layer.getCount();
      var res = this.mapStateCache.resolution;
      if (map.isZooming() && map.options['seamlessZoom'] && this._drawnRes !== undefined && res > this._drawnRes * 1.5 && this._geosToDraw.length < count || map.isMoving() || map.isInteracting()) {
        this.prepareToDraw();
        this._batchConversionMarkers(this.mapStateCache.glRes);
        if (!this._onlyHasPoint) {
          this._checkGeos();
        }
        this._drawnRes = res;
      }
      this._sortByDistanceToCamera(map.cameraPosition);
      var _this$layer$options = this.layer.options,
        collision = _this$layer$options.collision,
        collisionDelay = _this$layer$options.collisionDelay;
      if (collision) {
        var time = now();
        if (!this._lastCollisionTime) {
          this._lastCollisionTime = time;
        }
        if (time - this._lastCollisionTime <= collisionDelay) {
          this._geosToDraw = this._lastGeosToDraw || this._geosToDraw;
        } else {
          this._collidesGeos();
          this._lastCollisionTime = time;
        }
      }
      for (var i = 0, l = this._geosToDraw.length; i < l; i++) {
        var geo = this._geosToDraw[i];
        if (!geo._isCheck) {
          if (!geo.isVisible()) {
            delete geo._cPoint;
            delete geo._inCurrentView;
            continue;
          }
        }
        geo._paint(this._displayExtent);
        this._geosToDraw[i]._cPoint = undefined;
        this._geosToDraw[i]._inCurrentView = undefined;
      }
      this.clearImageData();
      this._lastGeosToDraw = this._geosToDraw;
      if (isDebug(this.layer)) {
        console.log('progressiveRender on drawOnInteracting page:', this.page);
      }
    };
    _proto.show = function show() {
      this.layer.forEach(function (geo) {
        geo._repaint();
      });
      _OverlayLayerCanvasRe.prototype.show.apply(this, arguments);
    };
    _proto.forEachGeo = function forEachGeo(fn, context) {
      this.layer.forEach(fn, context);
    };
    _proto._checkGeos = function _checkGeos() {
      var geos = this._getCurrentNeedRenderGeos();
      for (var i = 0, len = geos.length; i < len; i++) {
        this.checkGeo(geos[i]);
      }
      return this;
    };
    _proto.drawGeos = function drawGeos() {
      this._drawSnapshot();
      this._updateMapStateCache();
      this._drawnRes = this.mapStateCache.resolution;
      this._updateDisplayExtent();
      this.prepareToDraw();
      this._batchConversionMarkers(this.mapStateCache.glRes);
      if (!this._onlyHasPoint) {
        this._checkGeos();
      }
      this._sortByDistanceToCamera(this.getMap().cameraPosition);
      this._collidesGeos();
      for (var i = 0, len = this._geosToDraw.length; i < len; i++) {
        this._geosToDraw[i]._paint();
        this._geosToDraw[i]._cPoint = undefined;
        this._geosToDraw[i]._inCurrentView = undefined;
      }
      this.clearImageData();
      this._lastGeosToDraw = this._geosToDraw;
      if (isDebug(this.layer)) {
        console.log('progressiveRender drawGeos page:', this.page);
      }
      this._snapshot();
      this._setDrawGeosDrawTime();
    };
    _proto.prepareToDraw = function prepareToDraw() {
      this.layer._drawTime = now();
      this._hasPoint = false;
      this._geosToDraw = [];
      return this;
    };
    _proto._setDrawGeosDrawTime = function _setDrawGeosDrawTime() {
      var time = now();
      var drawTime = this.layer._drawTime;
      var painterList = this.getGeoPainterList();
      for (var i = 0, len = painterList.length; i < len; i++) {
        var painter = painterList[i];
        if (painter && painter._setDrawTime) {
          painter._setDrawTime(drawTime);
        }
      }
      if (isDebug(this.layer)) {
        console.log('_setDrawGeosDrawTime time:', now() - time + 'ms');
      }
      return this;
    };
    _proto.checkGeo = function checkGeo(geo) {
      if (geo.isPoint && this._onlyHasPoint !== undefined) {
        if (geo._inCurrentView) {
          this._hasPoint = true;
          geo._isCheck = true;
          this._geosToDraw.push(geo);
        }
        return;
      }
      geo._isCheck = false;
      if (!geo || !geo.isVisible() || !geo.getMap() || !geo.getLayer() || !geo.getLayer().isCanvasRender()) {
        return;
      }
      var painter = geo._getPainter();
      var inCurrentView = true;
      if (geo._inCurrentView) {
        inCurrentView = true;
      } else if (geo._inCurrentView === false) {
        inCurrentView = false;
      } else {
        var extent2D = painter.get2DExtent(this.resources, TEMP_EXTENT$9);
        if (!extent2D || !extent2D.intersects(this._displayExtent)) {
          inCurrentView = false;
        }
      }
      if (!inCurrentView) {
        return;
      }
      if (painter.hasPoint()) {
        this._hasPoint = true;
      }
      geo._isCheck = true;
      this._geosToDraw.push(geo);
    };
    _proto._collidesGeos = function _collidesGeos() {
      var collision = this.layer.options['collision'];
      if (!collision) {
        return this;
      }
      var collisionScope = this.layer.options['collisionScope'];
      var map = this.layer.getMap();
      var collisionIndex = collisionScope === 'map' ? map.getCollisionIndex() : tempCollisionIndex;
      if (collisionIndex === tempCollisionIndex) {
        collisionIndex.clear();
      }
      var geos = this._geosToDraw;
      this._geosToDraw = [];
      for (var i = 0, len = geos.length; i < len; i++) {
        if (this._geoIsCollision(geos[i], collisionIndex)) {
          continue;
        }
        this._geosToDraw.push(geos[i]);
      }
      return this;
    };
    _proto.onZoomEnd = function onZoomEnd() {
      delete this.canvasExtent2D;
      _OverlayLayerCanvasRe.prototype.onZoomEnd.apply(this, arguments);
    };
    _proto.onRemove = function onRemove() {
      this.forEachGeo(function (g) {
        g.onHide();
      });
      delete this._geosToDraw;
      delete this.snapshotCanvas;
      delete this.pageGeos;
      delete this.geoPainterList;
    };
    _proto.onGeometryPropertiesChange = function onGeometryPropertiesChange(param) {
      if (param) {
        this.layer._styleGeometry(param['target']);
      }
      _OverlayLayerCanvasRe.prototype.onGeometryPropertiesChange.call(this, param);
    };
    _proto._updateDisplayExtent = function _updateDisplayExtent() {
      var extent2D = this.canvasExtent2D;
      if (this._maskExtent) {
        if (!this._maskExtent.intersects(extent2D)) {
          this.completeRender();
          return;
        }
        extent2D = extent2D.intersection(this._maskExtent);
      }
      this._displayExtent = extent2D;
    };
    _proto.identifyAtPoint = function identifyAtPoint(point, options) {
      if (options === void 0) {
        options = {};
      }
      var geometries = this.getGeosForIdentify();
      if (!geometries) {
        return [];
      }
      return this.layer._hitGeos(geometries, point, options);
    };
    _proto._updateMapStateCache = function _updateMapStateCache() {
      var map = this.getMap();
      var offset = map._pointToContainerPoint(this.southWest)._add(0, -map.height);
      var resolution = map.getResolution();
      var pitch = map.getPitch();
      var bearing = map.getBearing();
      var glScale = map.getGLScale();
      var glRes = map.getGLRes();
      var containerExtent = map.getContainerExtent();
      var _2DExtent = map._get2DExtent();
      var glExtent = map._get2DExtentAtRes(glRes);
      this.mapStateCache = {
        resolution: resolution,
        pitch: pitch,
        bearing: bearing,
        glScale: glScale,
        glRes: glRes,
        _2DExtent: _2DExtent,
        glExtent: glExtent,
        containerExtent: containerExtent,
        offset: offset
      };
      return this;
    };
    _proto._batchConversionMarkers = function _batchConversionMarkers(glRes) {
      this._onlyHasPoint = undefined;
      if (!this._constructorIsThis()) {
        return [];
      }
      var cPoints = [];
      var markers = [];
      var altitudes = [];
      var altitudeCache = {};
      var layer = this.layer;
      var layerOpts = layer.options;
      var layerAltitude = layer.getAltitude ? layer.getAltitude() : 0;
      var isCanvasRender = layer.isCanvasRender();
      this._onlyHasPoint = true;
      var idx = 0;
      var geos = this._getCurrentNeedRenderGeos();
      for (var i = 0, len = geos.length; i < len; i++) {
        var geo = geos[i];
        if (geo.isPoint) {
          var painter = geo._painter;
          if (!painter) {
            painter = geo._getPainter();
          }
          var point = painter.getRenderPoints(PLACEMENT_CENTER)[0][0];
          var altitude = layerOpts['enableAltitude'] ? geo._getAltitude() : layerAltitude;
          if (altitudeCache[altitude] === undefined) {
            altitudeCache[altitude] = painter.getAltitude();
          }
          cPoints[idx] = point;
          altitudes[idx] = altitudeCache[altitude];
          markers[idx] = geo;
          idx++;
        } else {
          this._onlyHasPoint = false;
        }
      }
      if (idx === 0) {
        return [];
      }
      var map = this.getMap();
      var pts = getPointsResultPts(cPoints, '_pt');
      pts = map._pointsAtResToContainerPoints(cPoints, glRes, altitudes, pts);
      var containerExtent = map.getContainerExtent();
      var xmax = containerExtent.xmax,
        ymax = containerExtent.ymax,
        xmin = containerExtent.xmin,
        ymin = containerExtent.ymin;
      var extentCache = {};
      for (var _i = 0, _len = markers.length; _i < _len; _i++) {
        var _geo = markers[_i];
        _geo._cPoint = pts[_i];
        if (!_geo._cPoint) {
          _geo._inCurrentView = false;
          continue;
        }
        var _pts$_i = pts[_i],
          x = _pts$_i.x,
          y = _pts$_i.y;
        _geo._inCurrentView = x >= xmin && y >= ymin && x <= xmax && y <= ymax;
        if (!_geo._inCurrentView) {
          var symbolkey = _geo.getSymbolHash();
          var fixedExtent = void 0;
          if (symbolkey) {
            fixedExtent = extentCache[symbolkey] = extentCache[symbolkey] || _geo._painter.getFixedExtent();
          } else {
            fixedExtent = _geo._painter.getFixedExtent();
          }
          TEMP_FIXEDEXTENT.set(fixedExtent.xmin, fixedExtent.ymin, fixedExtent.xmax, fixedExtent.ymax);
          TEMP_FIXEDEXTENT._add(pts[_i]);
          _geo._inCurrentView = TEMP_FIXEDEXTENT.intersects(containerExtent);
        }
        if (_geo._inCurrentView) {
          if (!_geo.isVisible() || !isCanvasRender) {
            _geo._inCurrentView = false;
          }
          if (this._onlyHasPoint && _geo._inCurrentView) {
            this._hasPoint = true;
            _geo._isCheck = true;
            this._geosToDraw.push(_geo);
          }
        }
      }
      return pts;
    };
    _proto._sortByDistanceToCamera = function _sortByDistanceToCamera(cameraPosition) {
      if (!this.layer.options['sortByDistanceToCamera']) {
        return;
      }
      if (!this._geosToDraw.length) {
        return;
      }
      var map = this.getMap();
      var p = map.distanceToPoint(1000, 0, map.getGLScale()).x;
      var meterScale = p / 1000;
      var placement = 'center';
      this._geosToDraw.sort(function (a, b) {
        if (!a.isPoint || !b.isPoint) {
          return 0;
        }
        var painter0 = a._painter;
        var painter1 = b._painter;
        if (!painter0 || !painter1) {
          return 0;
        }
        var point0 = painter0.getRenderPoints(placement)[0][0];
        var point1 = painter1.getRenderPoints(placement)[0][0];
        var alt0 = painter0.getAltitude() * meterScale;
        var alt1 = painter1.getAltitude() * meterScale;
        set$2(TEMP_VEC3, point0.x, point0.y, alt0);
        var dist0 = distance(TEMP_VEC3, cameraPosition);
        set$2(TEMP_VEC3, point1.x, point1.y, alt1);
        var dist1 = distance(TEMP_VEC3, cameraPosition);
        return dist1 - dist0;
      });
    };
    _proto._constructorIsThis = function _constructorIsThis() {
      return this.constructor === VectorLayerRenderer;
    };
    _proto.isProgressiveRender = function isProgressiveRender() {
      var layer = this.layer;
      if (!layer) {
        return false;
      }
      var _ref = layer.options || {},
        progressiveRender = _ref.progressiveRender,
        collision = _ref.collision;
      if (collision) {
        return false;
      }
      return progressiveRender;
    };
    _proto.getGeosForIdentify = function getGeosForIdentify() {
      if (!this.isProgressiveRender()) {
        return this._geosToDraw || [];
      }
      return this.pageGeos || [];
    };
    _proto.getGeoPainterList = function getGeoPainterList() {
      if (!this.isProgressiveRender()) {
        var list = [];
        var geos = this._geosToDraw || [];
        for (var i = 0, len = geos.length; i < len; i++) {
          list.push(geos[i]._painter);
        }
        return list;
      }
      return this.geoPainterList || [];
    };
    _proto._checkSnapshotCanvas = function _checkSnapshotCanvas() {
      if (!this.isProgressiveRender()) {
        delete this.snapshotCanvas;
        return null;
      }
      var canvas = this.canvas;
      if (!canvas) {
        delete this.snapshotCanvas;
        return null;
      }
      if (!this.snapshotCanvas) {
        this.snapshotCanvas = Canvas.createCanvas(1, 1);
      }
      var snapshotCanvas = this.snapshotCanvas;
      var width = canvas.width,
        height = canvas.height,
        style = canvas.style;
      if (snapshotCanvas.width !== width || snapshotCanvas.height !== height) {
        snapshotCanvas.width = width;
        snapshotCanvas.height = height;
      }
      if (snapshotCanvas.style.width !== style.width || snapshotCanvas.style.height !== style.height) {
        snapshotCanvas.style.width = style.width;
        snapshotCanvas.style.height = style.height;
      }
      return snapshotCanvas;
    };
    _proto._getCurrentNeedRenderGeos = function _getCurrentNeedRenderGeos() {
      var geos = this.layer._geoList || [];
      if (!this.isProgressiveRender()) {
        return geos;
      }
      if (this.renderEnd) {
        return [];
      }
      var layer = this.layer;
      var progressiveRenderCount = layer.options.progressiveRenderCount;
      var pageSize = progressiveRenderCount;
      var page = this.page;
      var start = (page - 1) * pageSize,
        end = page * pageSize;
      var pageGeos = geos.slice(start, end);
      return pageGeos;
    };
    _proto._resetProgressiveRender = function _resetProgressiveRender() {
      if (isDebug(this.layer)) {
        console.log('progressiveRender resetProgressiveRender');
      }
      this.renderEnd = false;
      this.page = 1;
      this.pageGeos = [];
      this.geoPainterList = [];
      this.maxTolerance = 0;
      this._clearSnapshotCanvas();
    };
    _proto._clearSnapshotCanvas = function _clearSnapshotCanvas() {
      var snapshotCanvas = this._checkSnapshotCanvas();
      if (snapshotCanvas) {
        clearCanvas(snapshotCanvas);
      }
    };
    _proto._snapshot = function _snapshot() {
      var progressiveRender = this.isProgressiveRender();
      var geosToDraw = this._geosToDraw || [];
      for (var i = 0, len = geosToDraw.length; i < len; i++) {
        var geo = geosToDraw[i];
        var t = geo._hitTestTolerance() || 0;
        this.maxTolerance = Math.max(this.maxTolerance, t);
        if (progressiveRender) {
          this.pageGeos.push(geo);
          var painter = geo._painter;
          this.geoPainterList.push(painter);
        }
      }
      if (!progressiveRender) {
        return this;
      }
      var time = now();
      var snapshotCanvas = this._checkSnapshotCanvas();
      if (snapshotCanvas && this.canvas) {
        var ctx = clearCanvas(snapshotCanvas);
        ctx.drawImage(this.canvas, 0, 0);
      }
      var layer = this.layer;
      var progressiveRenderCount = layer.options.progressiveRenderCount;
      var geos = layer._geoList || [];
      var pages = Math.ceil(geos.length / progressiveRenderCount);
      this.renderEnd = this.page >= pages;
      if (this.renderEnd) {
        this._setDrawGeosDrawTime();
      }
      if (isDebug(this.layer)) {
        console.log('snapshot time:', now() - time + 'ms');
      }
      this.page++;
      return this;
    };
    _proto._drawSnapshot = function _drawSnapshot() {
      if (!this.isProgressiveRender()) {
        return this;
      }
      var snapshotCanvas = this.snapshotCanvas,
        context = this.context;
      if (!snapshotCanvas || !context) {
        return this;
      }
      var map = this.getMap();
      if (!map) {
        return this;
      }
      var dpr = map.getDevicePixelRatio() || 1;
      var rScale = 1 / dpr;
      context.scale(rScale, rScale);
      context.drawImage(snapshotCanvas, 0, 0);
      context.scale(dpr, dpr);
      return this;
    };
    return VectorLayerRenderer;
  }(OverlayLayerRenderer);
  VectorLayer.registerRenderer('canvas', VectorLayerRenderer);

  var MapRenderer = function (_Class) {
    _inheritsLoose(MapRenderer, _Class);
    function MapRenderer(map) {
      var _this;
      _this = _Class.call(this) || this;
      _this.map = map;
      _this._handlerQueue = [];
      _this._thisDocVisibilitychange = _this._onDocVisibilitychange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this._thisDocDragStart = _this._onDocDragStart.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this._thisDocDragEnd = _this._onDocDragEnd.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      _this._thisDocDPRChange = _this._onDocDPRChange.bind(_assertThisInitialized(_assertThisInitialized(_this)));
      return _this;
    }
    var _proto = MapRenderer.prototype;
    _proto.callInNextFrame = function callInNextFrame(fn) {
      this._handlerQueue.push(fn);
    };
    _proto.executeFrameCallbacks = function executeFrameCallbacks() {
      var running = this._handlerQueue;
      this._handlerQueue = [];
      for (var i = 0, l = running.length; i < l; i++) {
        running[i]();
      }
    };
    _proto.offsetPlatform = function offsetPlatform(offset, force) {
      if (!this.map._panels.front) {
        return this;
      }
      if (!force && offset.x === 0 && offset.y === 0) {
        return this;
      }
      var panels = this.map._panels;
      var hasFront = this._frontCount = panels.back.layerDOM.childElementCount;
      var hasBack = this._backCount = panels.front.layerDOM.childElementCount;
      var hasUI = this._uiCount = panels.front.uiDOM.childElementCount;
      if (hasFront || hasBack || hasUI) {
        var pos = this.map.offsetPlatform();
        if (offset) {
          pos = pos.add(offset)._round();
        } else {
          pos = pos.round();
        }
        if (hasBack) {
          offsetDom(panels.back, pos);
        }
        if (hasFront || hasUI) {
          offsetDom(panels.front, pos);
        }
      }
      return this;
    };
    _proto.domChanged = function domChanged() {
      var panels = this.map._panels;
      if (!panels.front) {
        return false;
      }
      var frontCount = panels.back.layerDOM.childElementCount;
      if (this._frontCount === undefined || this._frontCount !== frontCount) {
        return true;
      }
      var backCount = panels.front.layerDOM.childElementCount;
      if (this._backCount === undefined || this._backCount !== backCount) {
        return true;
      }
      var uiCount = panels.front.uiDOM.childElementCount;
      if (this._uiCount === undefined || this._uiCount !== uiCount) {
        return true;
      }
      return false;
    };
    _proto.resetContainer = function resetContainer() {
      if (!this.map) {
        return;
      }
      this.map._resetMapViewPoint();
      if (this.map._panels.front) {
        var pos = new Point(0, 0);
        offsetDom(this.map._panels.back, pos);
        offsetDom(this.map._panels.front, pos);
      }
    };
    _proto.onZoomEnd = function onZoomEnd() {
      this.resetContainer();
    };
    _proto.onLoad = function onLoad() {
      this._frameLoop();
    };
    _proto._onDocVisibilitychange = function _onDocVisibilitychange() {
      if (document.visibilityState !== 'visible') {
        return;
      }
      this.setToRedraw();
    };
    _proto._getWrapPanel = function _getWrapPanel() {
      if (!this.map) {
        return null;
      }
      var panels = this.map.getPanels();
      return panels && panels.mapWrapper;
    };
    _proto._onDocDragStart = function _onDocDragStart() {
      var wrapPanel = this._getWrapPanel();
      if (wrapPanel) {
        wrapPanel.style.overflow = 'visible';
      }
      return;
    };
    _proto._onDocDragEnd = function _onDocDragEnd() {
      var wrapPanel = this._getWrapPanel();
      if (wrapPanel) {
        wrapPanel.style.overflow = 'hidden';
      }
      return;
    };
    _proto._onDocDPRChange = function _onDocDPRChange() {
      var map = this.map;
      if (!map || !map.options || map.options['devicePixelRatio'] || !map.checkSize || !map.getRenderer) {
        return;
      }
      var renderer = map.getRenderer();
      if (renderer) {
        map.checkSize(true);
      }
    };
    _proto._containerIsOffscreen = function _containerIsOffscreen() {
      var container = this.map.getContainer();
      if (!container || !container.style || container.style.display === 'none') {
        return true;
      }
      var minSize = Math.min(container.clientWidth, container.clientHeight);
      return minSize <= 0;
    };
    return MapRenderer;
  }(Class);

  var MapCanvasRenderer = function (_MapRenderer) {
    _inheritsLoose(MapCanvasRenderer, _MapRenderer);
    function MapCanvasRenderer(map) {
      var _this;
      _this = _MapRenderer.call(this, map) || this;
      _this._containerIsCanvas = !!map._containerDOM.getContext;
      _this._registerEvents();
      _this._loopTime = 0;
      _this._resizeEventList = [];
      _this._resizeTime = -Infinity;
      return _this;
    }
    var _proto = MapCanvasRenderer.prototype;
    _proto.load = function load() {
      this.initContainer();
    };
    _proto.renderFrame = function renderFrame(framestamp) {
      var map = this.map;
      if (!map || !map.options['renderable']) {
        return false;
      }
      this._handleResizeEventList(framestamp);
      if (map.options['stopRenderOnOffscreen'] && this._containerIsOffscreen()) {
        return true;
      }
      this._updateDomPosition(framestamp);
      delete this._isViewChanged;
      map._fireEvent('framestart');
      this.updateMapDOM();
      map.clearCollisionIndex();
      var layers = this._getAllLayerToRender();
      this.drawLayers(layers, framestamp);
      var updated = this.drawLayerCanvas(layers);
      if (updated) {
        this.drawTops();
        this._drawCenterCross();
        if (map.options['debugSky']) {
          this._debugSky();
        }
      }
      this._needClear = false;
      map._fireEvent('frameend');
      this._recordView();
      this._mapview = this._getMapView();
      delete this._spatialRefChanged;
      this._fireLayerLoadEvents();
      this.executeFrameCallbacks();
      this._canvasUpdated = false;
      map.uiCollides();
      return true;
    };
    _proto.updateMapDOM = function updateMapDOM() {
      var map = this.map;
      if (map.isZooming()) {
        return;
      }
      var offset = map._getViewPointFrameOffset();
      if (offset) {
        map.offsetPlatform(offset);
      } else if (this.domChanged()) {
        this.offsetPlatform(null, true);
      }
    };
    _proto.drawLayers = function drawLayers(layers, framestamp) {
      var map = this.map,
        isInteracting = map.isInteracting(),
        canvasIds = [],
        updatedIds = [],
        fps = map.options['fpsOnInteracting'] || 0,
        timeLimit = fps === 0 ? 0 : 1000 / fps,
        layerLimit = this.map.options['layerCanvasLimitOnInteracting'],
        l = layers.length;
      var baseLayer = map.getBaseLayer();
      var t = 0;
      for (var i = 0; i < l; i++) {
        var layer = layers[i];
        if (!layer.isVisible()) {
          continue;
        }
        var isCanvas = layer.isCanvasRender();
        if (isCanvas) {
          canvasIds.push(layer.getId());
        }
        var renderer = layer._getRenderer();
        if (!renderer) {
          continue;
        }
        var needsRedraw = this._checkLayerRedraw(layer);
        if (isCanvas && renderer.isCanvasUpdated()) {
          if (!needsRedraw) {
            updatedIds.push(layer.getId());
          }
          this.setLayerCanvasUpdated();
        }
        var transformMatrix = renderer.__zoomTransformMatrix;
        delete renderer.__zoomTransformMatrix;
        if (!needsRedraw) {
          if (isCanvas && isInteracting) {
            if (map.isZooming() && !map.getPitch()) {
              renderer.prepareRender();
              renderer.__zoomTransformMatrix = this._zoomMatrix;
            } else if (map.getPitch() || map.isRotating()) {
              renderer.clearCanvas();
            }
          }
          continue;
        }
        if (isInteracting && isCanvas) {
          if (layerLimit > 0 && l - 1 - i > layerLimit && layer !== baseLayer) {
            layer._getRenderer().clearCanvas();
            continue;
          }
          t += this._drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp);
        } else if (isInteracting && renderer.drawOnInteracting) {
          if (renderer.prepareRender) {
            renderer.prepareRender();
          }
          if (renderer.checkAndDraw) {
            renderer.checkAndDraw(renderer.drawOnInteracting, this._eventParam, framestamp);
          } else {
            renderer.drawOnInteracting(this._eventParam, framestamp);
          }
        } else {
          renderer.render(framestamp);
          if (isCanvas && transformMatrix && renderer.isLoadingResource()) {
            renderer.__zoomTransformMatrix = transformMatrix;
          }
        }
        if (isCanvas) {
          updatedIds.push(layer.getId());
          this.setLayerCanvasUpdated();
        }
      }
      var preCanvasIds = this._canvasIds || [];
      var preUpdatedIds = this._updatedIds || [];
      this._canvasIds = canvasIds;
      this._updatedIds = updatedIds;
      if (!this.isLayerCanvasUpdated()) {
        var sep = '---';
        if (preCanvasIds.join(sep) !== canvasIds.join(sep) || preUpdatedIds.join(sep) !== updatedIds.join(sep)) {
          this.setLayerCanvasUpdated();
        }
      }
    };
    _proto._checkLayerRedraw = function _checkLayerRedraw(layer) {
      if (this.isSpatialReferenceChanged()) {
        return true;
      }
      var map = this.map;
      var renderer = layer._getRenderer();
      if (layer.isCanvasRender()) {
        return renderer.testIfNeedRedraw();
      } else {
        if (renderer.needToRedraw && renderer.needToRedraw()) {
          return true;
        }
        return map.isInteracting() || this.isViewChanged();
      }
    };
    _proto._drawCanvasLayerOnInteracting = function _drawCanvasLayerOnInteracting(layer, t, timeLimit, framestamp) {
      var map = this.map,
        renderer = layer._getRenderer(),
        drawTime = renderer.getDrawTime(),
        inTime = timeLimit === 0 || timeLimit > 0 && t + drawTime <= timeLimit;
      if (renderer.mustRenderOnInteracting && renderer.mustRenderOnInteracting()) {
        renderer.render(framestamp);
      } else if (renderer.drawOnInteracting && (layer === map.getBaseLayer() || inTime || map.isZooming() && layer.options['forceRenderOnZooming'] || map.isMoving() && layer.options['forceRenderOnMoving'] || map.isRotating() && layer.options['forceRenderOnRotating'])) {
        renderer.prepareRender();
        renderer.prepareCanvas();
        if (renderer.checkAndDraw) {
          renderer.checkAndDraw(renderer.drawOnInteracting, this._eventParam, framestamp);
        } else {
          renderer.drawOnInteracting(this._eventParam, framestamp);
        }
        return drawTime;
      } else if (map.isZooming() && !map.getPitch() && !map.isRotating()) {
        renderer.prepareRender();
        renderer.__zoomTransformMatrix = this._zoomMatrix;
      } else if (map.getPitch() || map.isRotating()) {
        renderer.clearCanvas();
      }
      if (renderer.drawOnInteracting && !inTime) {
        renderer.onSkipDrawOnInteracting(this._eventParam, framestamp);
      }
      return 0;
    };
    _proto._fireLayerLoadEvents = function _fireLayerLoadEvents() {
      if (this._updatedIds && this._updatedIds.length > 0) {
        var map = this.map;
        this._updatedIds.reverse().forEach(function (id) {
          var layer = map.getLayer(id);
          if (!layer) {
            return;
          }
          var renderer = layer._getRenderer();
          if (!renderer || !renderer.isRenderComplete()) {
            return;
          }
          layer.fire('layerload');
        });
      }
    };
    _proto.isLayerCanvasUpdated = function isLayerCanvasUpdated() {
      return this._canvasUpdated;
    };
    _proto.setLayerCanvasUpdated = function setLayerCanvasUpdated() {
      this._canvasUpdated = true;
    };
    _proto.drawLayerCanvas = function drawLayerCanvas(layers) {
      var map = this.map;
      if (!map) {
        return false;
      }
      if (!this.isLayerCanvasUpdated() && !this.isViewChanged() && this._needClear === false) {
        return false;
      }
      if (!this.canvas) {
        this.createCanvas();
      }
      map._fireEvent('renderstart', {
        'context': this.context
      });
      if (!this._updateCanvasSize()) {
        this.clearCanvas();
      }
      var interacting = map.isInteracting(),
        limit = map.options['layerCanvasLimitOnInteracting'];
      var len = layers.length;
      var baseLayerImage;
      var images = [];
      for (var i = 0; i < len; i++) {
        if (!layers[i].isVisible() || !layers[i].isCanvasRender()) {
          continue;
        }
        var renderer = layers[i]._getRenderer();
        if (!renderer) {
          continue;
        }
        var layerImage = this._getLayerImage(layers[i]);
        if (layerImage && layerImage['image']) {
          if (layers[i] === map.getBaseLayer()) {
            baseLayerImage = [layers[i], layerImage];
          } else {
            images.push([layers[i], layerImage]);
          }
        }
      }
      var targetWidth = this.canvas.width;
      var targetHeight = this.canvas.height;
      if (baseLayerImage) {
        this._drawLayerCanvasImage(baseLayerImage[0], baseLayerImage[1], targetWidth, targetHeight);
        this._drawFog();
      }
      len = images.length;
      var start = interacting && limit >= 0 && len > limit ? len - limit : 0;
      for (var _i = start; _i < len; _i++) {
        this._drawLayerCanvasImage(images[_i][0], images[_i][1], targetWidth, targetHeight);
      }
      map._fireEvent('renderend', {
        'context': this.context
      });
      return true;
    };
    _proto.setToRedraw = function setToRedraw() {
      var layers = this._getAllLayerToRender();
      this._needClear = true;
      for (var i = 0, l = layers.length; i < l; i++) {
        var renderer = layers[i].getRenderer();
        if (renderer && renderer.canvas && renderer.setToRedraw) {
          renderer.setToRedraw();
        }
      }
    };
    _proto.updateMapSize = function updateMapSize(size) {
      if (!size || this._containerIsCanvas) {
        return;
      }
      var width = size['width'] + 'px',
        height = size['height'] + 'px';
      var panels = this.map._panels;
      panels.mapWrapper.style.width = width;
      panels.mapWrapper.style.height = height;
      this._updateCanvasSize();
    };
    _proto.getMainPanel = function getMainPanel() {
      if (!this.map) {
        return null;
      }
      if (this._containerIsCanvas) {
        return this.map._containerDOM;
      }
      if (this.map._panels) {
        return this.map._panels.mapWrapper;
      }
      return null;
    };
    _proto.toDataURL = function toDataURL(mimeType, quality) {
      if (!this.canvas) {
        return null;
      }
      return this.canvas.toDataURL(mimeType, quality);
    };
    _proto.remove = function remove() {
      if (Browser$1.webgl && typeof document !== 'undefined') {
        GlobalEvent.off(EVENT_DPR_CHANGE, this._thisDocDPRChange, this);
        GlobalEvent.off(EVENT_DOC_VISIBILITY_CHANGE, this._thisDocVisibilitychange, this);
        GlobalEvent.off(EVENT_DOC_DRAGSTART, this._thisDocDragStart, this);
        GlobalEvent.off(EVENT_DOC_DRAGEND, this._thisDocDragEnd, this);
      }
      if (this._resizeInterval) {
        clearInterval(this._resizeInterval);
      }
      if (this._resizeObserver) {
        this._resizeObserver.disconnect();
      }
      delete this.context;
      delete this.canvas;
      delete this.map;
      delete this._spatialRefChanged;
      this._cancelFrameLoop();
    };
    _proto.hitDetect = function hitDetect(point) {
      var map = this.map;
      if (!map || !map.options['hitDetect'] || map.isInteracting()) {
        return;
      }
      var layers = map._getLayers();
      var cursor = 'default';
      var limit = map.options['hitDetectLimit'] || 0;
      var counter = 0;
      if (point && point._round) {
        point._round();
      }
      for (var i = layers.length - 1; i >= 0; i--) {
        var layer = layers[i];
        if (!layer.options['hitDetect'] || layer.isEmpty && layer.isEmpty() || !layer.options['geometryEvents']) {
          continue;
        }
        var renderer = layer._getRenderer();
        if (!renderer || !renderer.hitDetect) {
          continue;
        }
        if (renderer.isBlank && renderer.isBlank()) {
          continue;
        }
        if (layer.options['cursor'] !== 'default' && renderer.hitDetect(point)) {
          cursor = layer.options['cursor'] || 'pointer';
          break;
        }
        counter++;
        if (limit > 0 && counter > limit) {
          break;
        }
      }
      map._trySetCursor(cursor);
    };
    _proto._getLayerImage = function _getLayerImage(layer) {
      var renderer = layer._getRenderer();
      if (renderer.getCanvasImage) {
        return renderer.getCanvasImage();
      }
      return null;
    };
    _proto.initContainer = function initContainer() {
      var panels = this.map._panels;
      function createContainer(name, className, cssText, enableSelect) {
        var c = createEl('div', className);
        if (cssText) {
          c.style.cssText = cssText;
        }
        panels[name] = c;
        if (!enableSelect) {
          preventSelection(c);
        }
        return c;
      }
      var containerDOM = this.map._containerDOM;
      if (this._containerIsCanvas) {
        return;
      }
      containerDOM.innerHTML = '';
      var POSITION0 = 'position:absolute;top:0px;left:0px;';
      var mapWrapper = createContainer('mapWrapper', 'maptalks-wrapper', 'position:absolute;overflow:hidden;', true),
        mapAllLayers = createContainer('allLayers', 'maptalks-all-layers', POSITION0 + 'padding:0px;margin:0px;z-index:0;overflow:visible;', true),
        backStatic = createContainer('backStatic', 'maptalks-back-static', POSITION0 + 'z-index:0;', true),
        back = createContainer('back', 'maptalks-back', POSITION0 + 'z-index:1;'),
        backLayer = createContainer('backLayer', 'maptalks-back-layer', POSITION0),
        canvasContainer = createContainer('canvasContainer', 'maptalks-canvas-layer', POSITION0 + 'border:none;z-index:2;'),
        frontStatic = createContainer('frontStatic', 'maptalks-front-static', POSITION0 + 'z-index:3;', true),
        front = createContainer('front', 'maptalks-front', POSITION0 + 'z-index:4;', true),
        frontLayer = createContainer('frontLayer', 'maptalks-front-layer', POSITION0 + 'z-index:0;'),
        ui = createContainer('ui', 'maptalks-ui', POSITION0 + 'border:none;z-index:1;', true),
        control = createContainer('control', 'maptalks-control', 'z-index:1', true);
      containerDOM.appendChild(mapWrapper);
      mapAllLayers.appendChild(backStatic);
      back.appendChild(backLayer);
      back.layerDOM = backLayer;
      mapAllLayers.appendChild(back);
      mapAllLayers.appendChild(canvasContainer);
      front.appendChild(frontLayer);
      front.layerDOM = frontLayer;
      front.uiDOM = ui;
      mapAllLayers.appendChild(frontStatic);
      mapAllLayers.appendChild(front);
      front.appendChild(ui);
      mapWrapper.appendChild(mapAllLayers);
      mapWrapper.appendChild(control);
      this.createCanvas();
      this.resetContainer();
      var mapSize = this.map._getContainerDomSize();
      this.updateMapSize(mapSize);
    };
    _proto.isViewChanged = function isViewChanged() {
      if (this._isViewChanged !== undefined) {
        return this._isViewChanged;
      }
      var previous = this._mapview;
      var view = this._getMapView();
      this._isViewChanged = !previous || !equalMapView(previous, view);
      return this._isViewChanged;
    };
    _proto._recordView = function _recordView() {
      var map = this.map;
      if (!map._onViewChange || map.isInteracting() || map.isAnimating()) {
        return;
      }
      if (!equalMapView(map.getView(), map._getCurrentView())) {
        map._onViewChange(map.getView());
      }
    };
    _proto.isSpatialReferenceChanged = function isSpatialReferenceChanged() {
      return this._spatialRefChanged;
    };
    _proto._getMapView = function _getMapView() {
      var map = this.map;
      var center = map._getPrjCenter();
      return {
        x: center.x,
        y: center.y,
        zoom: map.getZoom(),
        pitch: map.getPitch(),
        bearing: map.getBearing(),
        width: map.width,
        height: map.height
      };
    };
    _proto._frameLoop = function _frameLoop(framestamp) {
      var _this2 = this;
      if (!this.map) {
        this._cancelFrameLoop();
        return;
      }
      framestamp = framestamp || 0;
      this._animationFrame = requestAnimFrame(function (framestamp) {
        _this2._frameLoop(framestamp);
      });
      this._frameTimestamp = framestamp;
      this._resizeCount = 0;
      this.renderFrame(framestamp);
    };
    _proto._cancelFrameLoop = function _cancelFrameLoop() {
      if (this._animationFrame) {
        cancelAnimFrame(this._animationFrame);
      }
    };
    _proto._drawLayerCanvasImage = function _drawLayerCanvasImage(layer, layerImage, targetWidth, targetHeight) {
      var ctx = this.context;
      var point = layerImage['point'].round();
      var dpr = this.map.getDevicePixelRatio();
      if (dpr !== 1) {
        point._multi(dpr);
      }
      var canvasImage = layerImage['image'];
      var width = canvasImage.width,
        height = canvasImage.height;
      if (point.x + width <= 0 || point.y + height <= 0) {
        return;
      }
      var op = layer.options['opacity'];
      if (!isNumber(op)) {
        op = 1;
      }
      if (op <= 0) {
        return;
      }
      var imgOp = layerImage['opacity'];
      if (!isNumber(imgOp)) {
        imgOp = 1;
      }
      if (imgOp <= 0) {
        return;
      }
      var alpha = ctx.globalAlpha;
      if (op < 1) {
        ctx.globalAlpha *= op;
      }
      if (imgOp < 1) {
        ctx.globalAlpha *= imgOp;
      }
      if (layer.options['cssFilter']) {
        ctx.filter = layer.options['cssFilter'];
      }
      var renderer = layer.getRenderer();
      var matrix = renderer.__zoomTransformMatrix;
      var clipped = renderer.clipCanvas(this.context);
      if (matrix) {
        ctx.save();
        ctx.setTransform.apply(ctx, matrix);
      }
      ctx.drawImage(canvasImage, 0, 0, width, height, point.x, point.y, targetWidth, targetHeight);
      if (matrix) {
        ctx.restore();
      }
      if (clipped) {
        ctx.restore();
      }
      if (ctx.filter !== 'none') {
        ctx.filter = 'none';
      }
      ctx.globalAlpha = alpha;
    };
    _proto._drawCenterCross = function _drawCenterCross() {
      var cross = this.map.options['centerCross'];
      if (cross) {
        var ctx = this.context;
        var p = new Point(this.canvas.width / 2, this.canvas.height / 2);
        if (isFunction(cross)) {
          cross(ctx, p);
        } else {
          Canvas.drawCross(this.context, p.x, p.y, 2, '#f00');
        }
      }
    };
    _proto._drawContainerExtent = function _drawContainerExtent() {
      var cascadePitches = this.map.options.cascadePitches;
      var h30 = this.map.height - this.map._getVisualHeight(cascadePitches[0]);
      var h60 = this.map.height - this.map._getVisualHeight(cascadePitches[1]);
      var extent = this.map.getContainerExtent();
      var ctx = this.context;
      ctx.beginPath();
      ctx.moveTo(0, extent.ymin);
      ctx.lineTo(extent.xmax, extent.ymin);
      ctx.stroke();
      ctx.beginPath();
      ctx.moveTo(0, h30);
      ctx.lineTo(extent.xmax, h30);
      ctx.stroke();
      ctx.beginPath();
      ctx.moveTo(0, h60);
      ctx.lineTo(extent.xmax, h60);
      ctx.stroke();
    };
    _proto._drawFog = function _drawFog() {
      var map = this.map;
      if (map.getPitch() <= map.options['maxVisualPitch'] || !map.options['fog']) {
        return;
      }
      var fogThickness = 30;
      var r = map.getDevicePixelRatio();
      var ctx = this.context,
        clipExtent = map.getContainerExtent();
      var top = (map.height - map._getVisualHeight(75)) * r;
      if (top < 0) top = 0;
      var bottom = clipExtent.ymin * r,
        h = Math.ceil(bottom - top),
        color = map.options['fogColor'].join();
      var gradient = ctx.createLinearGradient(0, top, 0, bottom + fogThickness);
      var landscape = 1 - fogThickness / (h + fogThickness);
      gradient.addColorStop(0, "rgba(" + color + ", 0)");
      gradient.addColorStop(0.3, "rgba(" + color + ", 0.3)");
      gradient.addColorStop(landscape, "rgba(" + color + ", 1)");
      gradient.addColorStop(1, "rgba(" + color + ", 0)");
      ctx.beginPath();
      ctx.fillStyle = gradient;
      ctx.fillRect(0, top, Math.ceil(clipExtent.getWidth()) * r, Math.ceil(h + fogThickness));
    };
    _proto._debugSky = function _debugSky() {
      var map = this.map;
      if (!map) {
        return this;
      }
      var height = map.getContainerExtent().ymin;
      if (height <= 0) {
        return this;
      }
      var ctx = this.context;
      ctx.strokeStyle = 'red';
      ctx.strokeRect(0, 0, map.width, height);
      return this;
    };
    _proto._getAllLayerToRender = function _getAllLayerToRender() {
      return this.map._getLayers();
    };
    _proto.clearCanvas = function clearCanvas() {
      if (!this.canvas) {
        return;
      }
      Canvas.clearRect(this.context, 0, 0, this.canvas.width, this.canvas.height);
    };
    _proto._updateCanvasSize = function _updateCanvasSize() {
      if (!this.canvas || this._containerIsCanvas) {
        return false;
      }
      var map = this.map,
        mapSize = map.getSize(),
        canvas = this.canvas,
        r = map.getDevicePixelRatio();
      var _calCanvasSize = calCanvasSize(mapSize, r),
        width = _calCanvasSize.width,
        height = _calCanvasSize.height,
        cssWidth = _calCanvasSize.cssWidth,
        cssHeight = _calCanvasSize.cssHeight;
      if (canvas.style && (canvas.style.width !== cssWidth || canvas.style.height !== cssHeight)) {
        canvas.style.width = cssWidth;
        canvas.style.height = cssHeight;
      }
      if (width === canvas.width && height === canvas.height) {
        return false;
      }
      canvas.height = height;
      canvas.width = width;
      this.topLayer.width = canvas.width;
      this.topLayer.height = canvas.height;
      return true;
    };
    _proto.createCanvas = function createCanvas() {
      this.topLayer = createEl('canvas');
      this.topCtx = this.topLayer.getContext('2d');
      if (this._containerIsCanvas) {
        this.canvas = this.map._containerDOM;
      } else {
        this.canvas = createEl('canvas');
        this._updateCanvasSize();
        this.map._panels.canvasContainer.appendChild(this.canvas);
      }
      this.context = this.canvas.getContext('2d');
    };
    _proto._updateDomPosition = function _updateDomPosition(framestamp) {
      if (this._checkPositionTime === undefined) {
        this._checkPositionTime = -Infinity;
      }
      var dTime = Math.abs(framestamp - this._checkPositionTime);
      if (dTime >= 500) {
        computeDomPosition(this.map._containerDOM);
        this._checkPositionTime = Math.min(framestamp, this._checkPositionTime);
      }
      return this;
    };
    _proto._handleResizeEventList = function _handleResizeEventList(time) {
      if (!this._resizeEventList) {
        return this;
      }
      var len = this._resizeEventList.length;
      if (len === 0) {
        return this;
      }
      if (this._resizeTime && time - this._resizeTime < 60) {
        return this;
      }
      var contentRect = this._resizeEventList[len - 1].contentRect;
      this.map._containerDomContentRect = contentRect;
      this._resizeEventList = [];
      this._checkSize(contentRect);
      this._resizeCount = this._resizeCount || 0;
      this.renderFrame((this._frameTimestamp || 0) + ++this._resizeCount / 100);
      this._resizeTime = time;
      return this;
    };
    _proto._checkSize = function _checkSize() {
      if (!this.map) {
        return;
      }
      this.map.checkSize();
    };
    _proto._setCheckSizeInterval = function _setCheckSizeInterval(interval) {
      var _this3 = this;
      if (Browser$1.resizeObserver) {
        if (this._resizeObserver) {
          this._resizeObserver.disconnect();
        }
        if (this.map) {
          this._resizeObserver = new ResizeObserver(function (entries) {
            if (!_this3.map || _this3.map.isRemoved()) {
              _this3._resizeObserver.disconnect();
            } else if (entries.length) {
              _this3._resizeEventList = _this3._resizeEventList || [];
              _this3._resizeEventList.push(entries[0]);
            }
          });
          this._resizeObserver.observe(this.map._containerDOM);
        }
      } else {
        clearInterval(this._resizeInterval);
        this._checkSizeInterval = interval;
        this._resizeInterval = setInterval(function () {
          if (!_this3.map || _this3.map.isRemoved()) {
            clearInterval(_this3._resizeInterval);
          } else {
            _this3._checkSize();
          }
        }, this._checkSizeInterval);
      }
    };
    _proto._registerEvents = function _registerEvents() {
      var _this4 = this;
      var map = this.map;
      if (map.options['checkSize'] && !IS_NODE && typeof window !== 'undefined') {
        this._setCheckSizeInterval(map.options['checkSizeInterval']);
      }
      if (!Browser$1.mobile) {
        map.on('_mousemove', this._onMapMouseMove, this);
      }
      map.on('_dragrotatestart _dragrotating _dragrotateend _movestart _moving _moveend _zoomstart', function (param) {
        _this4._eventParam = param;
      });
      map.on('_zooming', function (param) {
        if (!map.getPitch()) {
          _this4._zoomMatrix = param['matrix']['container'];
        }
        _this4._eventParam = param;
      });
      map.on('_zoomend', function (param) {
        _this4._eventParam = param;
        delete _this4._zoomMatrix;
      });
      map.on('_spatialreferencechange', function () {
        _this4._spatialRefChanged = true;
      });
      if (Browser$1.webgl && typeof document !== 'undefined') {
        GlobalEvent.on(EVENT_DPR_CHANGE, this._thisDocDPRChange, this);
        GlobalEvent.on(EVENT_DOC_VISIBILITY_CHANGE, this._thisDocVisibilitychange, this);
        GlobalEvent.on(EVENT_DOC_DRAGSTART, this._thisDocDragStart, this);
        GlobalEvent.on(EVENT_DOC_DRAGEND, this._thisDocDragEnd, this);
      }
    };
    _proto._onMapMouseMove = function _onMapMouseMove(param) {
      var _this5 = this;
      var map = this.map;
      if (map.isInteracting() || !map.options['hitDetect']) {
        return;
      }
      if (this._hitDetectFrame) {
        cancelAnimFrame(this._hitDetectFrame);
      }
      this._hitDetectFrame = requestAnimFrame(function () {
        _this5.hitDetect(param['containerPoint']);
      });
    };
    _proto._getCanvasLayers = function _getCanvasLayers() {
      return this.map._getLayers(function (layer) {
        return layer.isCanvasRender();
      });
    };
    _proto.addTopElement = function addTopElement(e) {
      if (!this._tops) {
        this._tops = [];
      }
      this._tops.push(e);
    };
    _proto.removeTopElement = function removeTopElement(e) {
      if (!this._tops) {
        return;
      }
      var idx = this._tops.indexOf(e);
      if (idx >= 0) {
        this._tops.splice(idx, 1);
      }
    };
    _proto.getTopElements = function getTopElements() {
      return this._tops || [];
    };
    _proto.drawTops = function drawTops() {
      this.topCtx.clearRect(0, 0, this.topLayer.width, this.topLayer.height);
      this.map.fire('drawtopstart');
      this.map.fire('drawtops');
      var tops = this.getTopElements();
      var updated = false;
      for (var i = 0; i < tops.length; i++) {
        if (tops[i].render(this.topCtx)) {
          updated = true;
        }
      }
      if (updated) {
        this.context.drawImage(this.topLayer, 0, 0);
      }
      this.map.fire('drawtopsend');
    };
    return MapCanvasRenderer;
  }(MapRenderer);
  Map$1.registerRenderer('canvas', MapCanvasRenderer);
  Map$1.mergeOptions({
    'fog': false,
    'fogColor': [233, 233, 233]
  });



  var index$6 = /*#__PURE__*/Object.freeze({
    ResourceCache: ResourceCache,
    CanvasRenderer: CanvasRenderer,
    ImageGLRenderable: ImageGLRenderable,
    MapRenderer: MapRenderer,
    MapCanvasRenderer: MapCanvasRenderer,
    Renderable: Renderable,
    ImageLayerCanvasRenderer: ImageLayerCanvasRenderer,
    ImageLayerGLRenderer: ImageLayerGLRenderer,
    TileLayerCanvasRenderer: TileLayerCanvasRenderer,
    TileLayerGLRenderer: TileLayerGLRenderer,
    CanvasTileLayerCanvasRenderer: CanvasRenderer$1,
    CanvasTileLayerGLRenderer: GLRenderer,
    QuadStencil: QuadStencil,
    OverlayLayerCanvasRenderer: OverlayLayerRenderer,
    VectorLayerCanvasRenderer: VectorLayerRenderer,
    CanvasLayerRenderer: CanvasLayerRenderer
  });

  var CenterPointRenderer = {
    _getRenderPoints: function _getRenderPoints() {
      return [[this._getCenter2DPoint(this.getMap().getGLRes())], null];
    }
  };
  Marker.include(CenterPointRenderer);
  Ellipse.include(CenterPointRenderer);
  Circle.include(CenterPointRenderer);
  Sector.include(CenterPointRenderer);
  Rectangle.include({
    _getRenderPoints: function _getRenderPoints(placement) {
      var map = this.getMap();
      var glRes = map.getGLRes();
      if (placement === 'vertex') {
        var shell = this._trimRing(this.getShell());
        var points = [];
        for (var i = 0, len = shell.length; i < len; i++) {
          points.push(map.coordToPointAtRes(shell[i], glRes));
        }
        return [points, null];
      } else {
        var c = map.coordToPointAtRes(this.getCenter(), glRes);
        return [[c], null];
      }
    }
  });
  var PolyRenderer = {
    _getRenderPoints: function _getRenderPoints(placement) {
      var map = this.getMap();
      var glRes = map.getGLRes();
      var points,
        rotations = null;
      if (placement === 'point') {
        points = this._getPath2DPoints(this._getPrjCoordinates(), false, glRes);
        if (points && points.length > 0 && Array.isArray(points[0])) {
          points = points[0].concat(points[1]);
        }
      } else if (placement === 'vertex') {
        points = this._getPath2DPoints(this._getPrjCoordinates(), false, glRes);
        rotations = [];
        if (points && points.length > 0 && Array.isArray(points[0])) {
          for (var i = 0, l = points.length; i < l; i++) {
            for (var ii = 0, ll = points[i].length; ii < ll; ii++) {
              if (ii === 0) {
                rotations.push([points[i][ii], points[i][ii + 1]]);
              } else {
                rotations.push([points[i][ii - 1], points[i][ii]]);
              }
            }
          }
          points = points[0].concat(points[1]);
        } else {
          for (var _i = 0, _l = points.length; _i < _l; _i++) {
            if (_i === 0) {
              rotations.push([points[_i], points[_i + 1]]);
            } else {
              rotations.push([points[_i - 1], points[_i]]);
            }
          }
        }
      } else if (placement === 'line') {
        points = [];
        rotations = [];
        var vertice = this._getPath2DPoints(this._getPrjCoordinates(), false, glRes),
          isSplitted = vertice.length > 0 && Array.isArray(vertice[0]);
        if (isSplitted) {
          var ring;
          for (var _i2 = 1, _l2 = vertice.length; _i2 < _l2; _i2++) {
            ring = vertice[_i2];
            if (this instanceof Polygon && ring.length > 0 && !ring[0].equals(ring[ring.length - 1])) {
              ring.push(ring[0]);
            }
            for (var _ii = 1, _ll = ring.length; _ii < _ll; _ii++) {
              points.push(ring[_ii].add(ring[_ii - 1])._multi(0.5));
              rotations.push([ring[_ii - 1], ring[_ii]]);
            }
          }
        } else {
          if (this instanceof Polygon && vertice.length > 0 && !vertice[0].equals(vertice[vertice.length - 1])) {
            vertice.push(vertice[0]);
          }
          for (var _i3 = 1, _l3 = vertice.length; _i3 < _l3; _i3++) {
            points.push(vertice[_i3].add(vertice[_i3 - 1])._multi(0.5));
            rotations.push([vertice[_i3 - 1], vertice[_i3]]);
          }
        }
      } else if (placement === 'vertex-first') {
        var coords = this._getPrjCoordinates();
        var _l4 = coords.length;
        var point0 = _l4 ? map._prjToPointAtRes(coords[0], glRes) : null;
        points = _l4 ? [point0] : [];
        rotations = _l4 ? [[point0, coords[1] ? map._prjToPointAtRes(coords[1], glRes) : point0]] : [];
      } else if (placement === 'vertex-last') {
        var _coords = this._getPrjCoordinates();
        var _l5 = _coords.length;
        var curretPoint = _l5 ? map._prjToPointAtRes(_coords[_l5 - 1], glRes) : null;
        points = _l5 ? [curretPoint] : [];
        var previous = _l5 > 1 ? _l5 - 2 : _l5 - 1;
        rotations = _l5 ? [[_coords[previous] ? map._prjToPointAtRes(_coords[previous], glRes) : curretPoint, curretPoint]] : [];
      } else {
        var center = this.getCenter();
        if (!center) {
          points = [];
        } else {
          var pcenter = this._getProjection().project(center);
          points = [map._prjToPointAtRes(pcenter, glRes)];
        }
      }
      return [points, rotations];
    }
  };
  LineString.include(PolyRenderer);
  Polygon.include(PolyRenderer);

  var TEMP_WITHIN = {
    within: false,
    center: [0, 0]
  };
  function isWithinPixel(painter) {
    if (!painter || !painter._containerBbox) {
      TEMP_WITHIN.within = false;
    } else {
      TEMP_WITHIN.within = false;
      var _painter$_containerBb = painter._containerBbox,
        minx = _painter$_containerBb.minx,
        miny = _painter$_containerBb.miny,
        maxx = _painter$_containerBb.maxx,
        maxy = _painter$_containerBb.maxy;
      var offsetx = Math.abs(maxx - minx);
      var offsety = Math.abs(maxy - miny);
      if (offsetx <= 1 && offsety <= 1) {
        TEMP_WITHIN.within = true;
        TEMP_WITHIN.center[0] = (minx + maxx) / 2;
        TEMP_WITHIN.center[1] = (miny + maxy) / 2;
      }
      delete painter._containerBbox;
    }
    return TEMP_WITHIN;
  }
  Geometry.include({
    _redrawWhenPitch: function _redrawWhenPitch() {
      return false;
    },
    _redrawWhenRotate: function _redrawWhenRotate() {
      return false;
    },
    _getRenderBBOX: function _getRenderBBOX(ctx, points) {
      if (!ctx.isHitTesting) {
        resetBBOX(BBOX_TEMP);
        pointsBBOX(points, BBOX_TEMP);
        return BBOX_TEMP;
      }
      return null;
    }
  });
  function _computeRotatedPrjExtent() {
    var coord = this._getPrjShell();
    var bbox = getDefaultBBOX();
    pointsBBOX(coord, bbox);
    var minx = bbox[0],
      miny = bbox[1],
      maxx = bbox[2],
      maxy = bbox[3];
    return new Extent(minx, miny, maxx, maxy);
  }
  function getRotatedShell() {
    var prjs = this._getPrjShell();
    if (!prjs || !Array.isArray(prjs)) {
      return [];
    }
    var projection = this._getProjection();
    var coordinates = this.getCoordinates() || {};
    return prjs.map(function (prj) {
      var c = projection.unproject(prj);
      c.z = coordinates.z || 0;
      return c;
    });
  }
  var el = {
    _redrawWhenPitch: function _redrawWhenPitch() {
      return true;
    },
    _redrawWhenRotate: function _redrawWhenRotate() {
      return this instanceof Ellipse || this instanceof Sector;
    },
    _computeRotatedPrjExtent: _computeRotatedPrjExtent,
    getRotatedShell: getRotatedShell,
    _paintAsPath: function _paintAsPath() {
      if (this.isRotated()) {
        return true;
      }
      var map = this.getMap();
      var altitude = this._getAltitude();
      return altitude > 0 || map.getPitch() || this instanceof Ellipse && map.getBearing();
    },
    _getPaintParams: function _getPaintParams() {
      var map = this.getMap();
      if (this._paintAsPath()) {
        return Polygon.prototype._getPaintParams.call(this, true);
      }
      var pcenter = this._getPrjCoordinates();
      var pt = map._prjToPointAtRes(pcenter, map.getGLRes());
      var size = this._getRenderSize(pt);
      return [pt].concat(size);
    },
    _paintOn: function _paintOn() {
      if (this._paintAsPath()) {
        return Canvas.polygon.apply(Canvas, arguments);
      } else {
        return Canvas.ellipse.apply(Canvas, arguments);
      }
    },
    _getRenderSize: function _getRenderSize(pt) {
      var map = this.getMap(),
        glRes = map.getGLRes();
      var prjExtent = this._getPrjExtent();
      var pmin = map._prjToPointAtRes(prjExtent.getMin(), glRes),
        pmax = map._prjToPointAtRes(prjExtent.getMax(), glRes);
      return [Math.abs(pmax.x - pmin.x) / 2, Math.abs(pmax.y - pt.y), Math.abs(pt.y - pmin.y)];
    }
  };
  Ellipse.include(el);
  Circle.include(el);
  Rectangle.include({
    _getPaintParams: function _getPaintParams() {
      var map = this.getMap();
      var shell = this._getPrjShell();
      var points = this._getPath2DPoints(shell, false, map.getGLRes());
      return [points];
    },
    _paintOn: Canvas.polygon,
    _computeRotatedPrjExtent: _computeRotatedPrjExtent,
    getRotatedShell: getRotatedShell
  });
  Sector.include(el, {
    _redrawWhenPitch: function _redrawWhenPitch() {
      return true;
    },
    _getPaintParams: function _getPaintParams() {
      if (this._paintAsPath()) {
        return Polygon.prototype._getPaintParams.call(this, true);
      }
      var map = this.getMap();
      var pt = map._prjToPointAtRes(this._getPrjCoordinates(), map.getGLRes());
      var size = this._getRenderSize(pt);
      return [pt, size[0], [this.getStartAngle(), this.getEndAngle()]];
    },
    _paintOn: function _paintOn() {
      if (this._paintAsPath()) {
        return Canvas.polygon.apply(Canvas, arguments);
      } else {
        var r = this.getMap().getBearing();
        var args = arguments;
        if (r) {
          args[3] = args[3].slice(0);
          args[3][0] += r;
          args[3][1] += r;
        }
        return Canvas.sector.apply(Canvas, args);
      }
    }
  });
  Path.include({
    _paintAsPath: function _paintAsPath() {
      return true;
    }
  });
  LineString.include({
    arrowStyles: {
      'classic': [3, 4]
    },
    _getArrowShape: function _getArrowShape(prePoint, point, lineWidth, arrowStyle, tolerance) {
      if (!prePoint || !point || prePoint.equals(point)) {
        return null;
      }
      if (!tolerance) {
        tolerance = 0;
      }
      var width = lineWidth * arrowStyle[0],
        height = lineWidth * arrowStyle[1] + tolerance,
        hw = width / 2 + tolerance;
      var normal;
      if (point.nextCtrlPoint || point.prevCtrlPoint) {
        if (point.prevCtrlPoint) {
          normal = point.sub(new Point(point.prevCtrlPoint));
        } else {
          normal = point.sub(new Point(point.nextCtrlPoint));
        }
      } else {
        normal = point.sub(prePoint);
      }
      normal._unit();
      var p1 = point.sub(normal.multi(height));
      normal._perp();
      var p0 = p1.add(normal.multi(hw));
      normal._multi(-1);
      var p2 = p1.add(normal.multi(hw));
      return [p0, point, p2, p0];
    },
    _getPaintParams: function _getPaintParams() {
      var prjVertexes = this._getPrjCoordinates();
      var points = this._getPath2DPoints(prjVertexes, false, this.getMap().getGLRes());
      return [points];
    },
    _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
      var r = isWithinPixel(this._painter);
      if (r.within) {
        Canvas.pixelRect(ctx, r.center, lineOpacity, fillOpacity);
      } else if (this.options['smoothness']) {
        Canvas.paintSmoothLine(ctx, points, lineOpacity, this.options['smoothness'], false, this._animIdx, this._animTailRatio);
      } else {
        Canvas.path(ctx, points, lineOpacity, null, dasharray);
      }
      this._paintArrow(ctx, points, lineOpacity);
      return this._getRenderBBOX(ctx, points);
    },
    _getArrowPlacement: function _getArrowPlacement() {
      return this.options['arrowPlacement'];
    },
    _getArrowStyle: function _getArrowStyle() {
      var arrowStyle = this.options['arrowStyle'];
      if (arrowStyle) {
        return Array.isArray(arrowStyle) ? arrowStyle : this.arrowStyles[arrowStyle];
      }
      return null;
    },
    _getArrows: function _getArrows(points, lineWidth, tolerance) {
      var arrowStyle = this._getArrowStyle();
      if (!arrowStyle || points.length < 2) {
        return [];
      }
      var isSplitted = points.length > 0 && Array.isArray(points[0]);
      var segments = isSplitted ? points : [points];
      var placement = this._getArrowPlacement();
      var arrows = [];
      var map = this.getMap(),
        first = map.coordToContainerPoint(this.getFirstCoordinate()),
        last = map.coordToContainerPoint(this.getLastCoordinate());
      for (var i = segments.length - 1; i >= 0; i--) {
        if (placement === 'vertex-first' || placement === 'vertex-firstlast' && segments[i][0].closeTo(first, 0.01)) {
          var arrow = this._getArrowShape(segments[i][1], segments[i][0], lineWidth, arrowStyle, tolerance);
          if (arrow) {
            arrows.push(arrow);
          }
        }
        if (placement === 'vertex-last' || placement === 'vertex-firstlast' && segments[i][segments[i].length - 1].closeTo(last, 0.01)) {
          var _arrow = this._getArrowShape(segments[i][segments[i].length - 2], segments[i][segments[i].length - 1], lineWidth, arrowStyle, tolerance);
          if (_arrow) {
            arrows.push(_arrow);
          }
        } else if (placement === 'point') {
          this._getArrowPoints(arrows, segments[i], lineWidth, arrowStyle, tolerance);
        }
      }
      return arrows;
    },
    _getArrowPoints: function _getArrowPoints(arrows, segments, lineWidth, arrowStyle, tolerance) {
      for (var ii = 0, ll = segments.length - 1; ii < ll; ii++) {
        var arrow = this._getArrowShape(segments[ii], segments[ii + 1], lineWidth, arrowStyle, tolerance);
        if (arrow) {
          arrows.push(arrow);
        }
      }
    },
    _paintArrow: function _paintArrow(ctx, points, lineOpacity) {
      var lineWidth = this._getInternalSymbol()['lineWidth'];
      if (!isNumber(lineWidth) || lineWidth < 3) {
        lineWidth = 3;
      }
      var arrows = this._getArrows(points, lineWidth);
      if (!arrows.length) {
        return;
      }
      if (ctx.setLineDash) {
        ctx.setLineDash([]);
      }
      for (var i = arrows.length - 1; i >= 0; i--) {
        ctx.fillStyle = ctx.strokeStyle;
        Canvas.polygon(ctx, arrows[i], lineOpacity, lineOpacity);
      }
    }
  });
  Polygon.include({
    _getPaintParams: function _getPaintParams(disableSimplify) {
      var glRes = this.getMap().getGLRes();
      var prjVertexes = this._getPrjShell();
      var points = this._getPath2DPoints(prjVertexes, disableSimplify, glRes);
      var isSplitted = points.length > 0 && Array.isArray(points[0]);
      if (isSplitted) {
        points = [[points[0]], [points[1]]];
      }
      var prjHoles = this._getPrjHoles();
      var holePoints = [];
      if (prjHoles && prjHoles.length > 0) {
        var simplified = this._simplified;
        for (var i = 0; i < prjHoles.length; i++) {
          var hole = this._getPath2DPoints(prjHoles[i], disableSimplify, glRes);
          if (Array.isArray(hole) && isSplitted) {
            if (Array.isArray(hole[0])) {
              points[0].push(hole[0]);
              points[1].push(hole[1]);
            } else {
              points[0].push(hole);
            }
          } else {
            holePoints.push(hole);
          }
        }
        if (simplified) {
          this._simplified = simplified;
        }
      }
      if (!isSplitted) {
        points = [points];
        pushIn(points, holePoints);
      }
      return [points];
    },
    _paintOn: function _paintOn(ctx, points, lineOpacity, fillOpacity, dasharray) {
      var r = isWithinPixel(this._painter);
      if (r.within) {
        Canvas.pixelRect(ctx, r.center, lineOpacity, fillOpacity);
      } else {
        Canvas.polygon(ctx, points, lineOpacity, fillOpacity, dasharray, this.options['smoothness']);
      }
      return this._getRenderBBOX(ctx, points);
    }
  });

  Map$1.VERSION = version;
  var worker = {
    Actor: Actor
  };

  exports.Util = index$1;
  exports.DomUtil = dom;
  exports.StringUtil = strings;
  exports.MapboxUtil = index;
  exports.MicroTask = MicroTask;
  exports.Map = Map$1;
  exports.ui = index$4;
  exports.control = index$5;
  exports.renderer = index$6;
  exports.symbolizer = index$3;
  exports.animation = Animation$1;
  exports.worker = worker;
  exports.Globalconfig = GlobalConfig;
  exports.Browser = Browser$1;
  exports.LRUCache = LRUCache;
  exports.Ajax = Ajax;
  exports.Canvas = Canvas;
  exports.Promise = Promise$1;
  exports.Class = Class;
  exports.Eventable = Eventable;
  exports.GlobalEvent = GlobalEvent;
  exports.JSONAble = JSONAble;
  exports.CollisionIndex = CollisionIndex;
  exports.Handlerable = Handlerable;
  exports.Handler = Handler$1;
  exports.DragHandler = DragHandler;
  exports.MapTool = MapTool;
  exports.DrawTool = DrawTool;
  exports.AreaTool = AreaTool;
  exports.DistanceTool = DistanceTool;
  exports.SpatialReference = SpatialReference;
  exports.animate = animate;
  exports.registerWorkerAdapter = registerWorkerAdapter;
  exports.INTERNAL_LAYER_PREFIX = INTERNAL_LAYER_PREFIX;
  exports.GEOMETRY_COLLECTION_TYPES = GEOMETRY_COLLECTION_TYPES;
  exports.GEOJSON_TYPES = GEOJSON_TYPES;
  exports.RESOURCE_PROPERTIES = RESOURCE_PROPERTIES;
  exports.RESOURCE_SIZE_PROPERTIES = RESOURCE_SIZE_PROPERTIES;
  exports.NUMERICAL_PROPERTIES = NUMERICAL_PROPERTIES;
  exports.COLOR_PROPERTIES = COLOR_PROPERTIES;
  exports.DEFAULT_TEXT_SIZE = DEFAULT_TEXT_SIZE;
  exports.projection = projections;
  exports.measurer = index$2;
  exports.Coordinate = Coordinate;
  exports.CRS = CRS;
  exports.Extent = Extent;
  exports.Point = Point;
  exports.PointExtent = PointExtent;
  exports.Size = Size;
  exports.Transformation = Transformation;
  exports.Layer = Layer;
  exports.TileLayer = TileLayer;
  exports.GroupTileLayer = GroupTileLayer;
  exports.WMSTileLayer = WMSTileLayer;
  exports.CanvasTileLayer = CanvasTileLayer;
  exports.ImageLayer = ImageLayer;
  exports.OverlayLayer = OverlayLayer;
  exports.VectorLayer = VectorLayer;
  exports.CanvasLayer = CanvasLayer;
  exports.ParticleLayer = ParticleLayer;
  exports.TileSystem = TileSystem;
  exports.TileConfig = TileConfig;
  exports.ArcCurve = ArcCurve;
  exports.Circle = Circle;
  exports.ConnectorLine = ConnectorLine;
  exports.ArcConnectorLine = ArcConnectorLine;
  exports.CubicBezierCurve = CubicBezierCurve;
  exports.Curve = Curve;
  exports.Ellipse = Ellipse;
  exports.GeoJSON = GeoJSON;
  exports.Geometry = Geometry;
  exports.GeometryCollection = GeometryCollection;
  exports.Label = Label;
  exports.LineString = LineString;
  exports.Marker = Marker;
  exports.MultiLineString = MultiLineString;
  exports.MultiPoint = MultiPoint;
  exports.MultiPolygon = MultiPolygon;
  exports.Polygon = Polygon;
  exports.QuadBezierCurve = QuadBezierCurve;
  exports.Rectangle = Rectangle;
  exports.Sector = Sector; 
  exports.TextBox = TextBox;
  exports.TextMarker = TextMarker;

  Object.defineProperty(exports, '__esModule', { value: true });

  // typeof console !== 'undefined' && console.log && console.log('maptalks v1.0.0-rc.30');

}));
/*!
 * @maptalks/gl-layers v0.31.8
 * LICENSE : MIT
 * (c) 2016-2024 maptalks.com
 */
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],factory):factory((global="undefined"!=typeof globalThis?globalThis:global||self).maptalks=global.maptalks||{},global.maptalks)}(this,(function(exports,t$1){"use strict";function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(k){if("default"!==k){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:!0,get:function(){return e[k]}})}})),n.default=e,Object.freeze(n)}var t__namespace=_interopNamespace(t$1),regl_min=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self,{exports:{}});!function(module,exports){module.exports=function(){function U(a,b){this.id=Cb++,this.type=a,this.data=b}function W(a){if(0===a.length)return[];var b=a.charAt(0),c=a.charAt(a.length-1);if(1<a.length&&b===c&&('"'===b||"'"===b))return['"'+a.substr(1,a.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(b=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(a))return W(a.substr(0,b.index)).concat(W(b[1])).concat(W(a.substr(b.index+b[0].length)));if(1===(b=a.split(".")).length)return['"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(a=[],c=0;c<b.length;++c)a=a.concat(W(b[c]));return a}function ab(a){return"["+W(a).join("][")+"]"}function bb(a,b){return"function"==typeof a?new U(0,a):"number"==typeof a||"boolean"==typeof a?new U(5,a):Array.isArray(a)?new U(6,a.map((function(a,e){return bb(a)}))):a instanceof U?a:void 0}function Db(){var a={"":0},b=[""];return{id:function(c){var e=a[c];return e||(e=a[c]=b.length,b.push(c),e)},str:function(a){return b[a]}}}function Eb(a,b,c){function e(){var b=window.innerWidth,e=window.innerHeight;a!==document.body&&(b=(e=a.getBoundingClientRect()).right-e.left,e=e.bottom-e.top),f.width=c*b,f.height=c*e,F(f.style,{width:b+"px",height:e+"px"})}var d,f=document.createElement("canvas");return F(f.style,{border:0,margin:0,padding:0,top:0,left:0}),a.appendChild(f),a===document.body&&(f.style.position="absolute",F(a.style,{margin:0,padding:0})),a!==document.body&&"function"==typeof ResizeObserver?(d=new ResizeObserver((function(){setTimeout(e)}))).observe(a):window.addEventListener("resize",e,!1),e(),{canvas:f,onDestroy:function(){d?d.disconnect():window.removeEventListener("resize",e),a.removeChild(f)}}}function Fb(a,b){function c(c){try{return a.getContext(c,b)}catch(f){return null}}return c("webgl")||c("experimental-webgl")||c("webgl-experimental")}function cb(a){return"string"==typeof a?a.split():a}function db(a){return"string"==typeof a?document.querySelector(a):a}function Gb(a){var c,e,f,d,b=a||{};a={};var p=[],r=[],v="undefined"==typeof window?1:window.devicePixelRatio,m=!1,u=function(a){},n=function(){};if("string"==typeof b?c=document.querySelector(b):"object"==typeof b&&("string"==typeof b.nodeName&&"function"==typeof b.appendChild&&"function"==typeof b.getBoundingClientRect?c=b:"function"==typeof b.drawArrays||"function"==typeof b.drawElements?f=(d=b).canvas:("gl"in b?d=b.gl:"canvas"in b?f=db(b.canvas):"container"in b&&(e=db(b.container)),"attributes"in b&&(a=b.attributes),"extensions"in b&&(p=cb(b.extensions)),"optionalExtensions"in b&&(r=cb(b.optionalExtensions)),"onDone"in b&&(u=b.onDone),"profile"in b&&(m=!!b.profile),"pixelRatio"in b&&(v=+b.pixelRatio))),c&&("canvas"===c.nodeName.toLowerCase()?f=c:e=c),!d){if(!f){if(!(c=Eb(e||document.body,u,v)))return null;f=c.canvas,n=c.onDestroy}void 0===a.premultipliedAlpha&&(a.premultipliedAlpha=!0),d=Fb(f,a)}return d?{gl:d,canvas:f,container:e,extensions:p,optionalExtensions:r,pixelRatio:v,profile:m,onDone:u,onDestroy:n}:(n(),u("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function Hb(a,b){function c(b){var c;b=b.toLowerCase();try{c=e[b]=a.getExtension(b)}catch(f){}return!!c}for(var e={},f=0;f<b.extensions.length;++f){var d=b.extensions[f];if(!c(d))return b.onDestroy(),b.onDone('"'+d+'" extension is not supported by the current WebGL context, try upgrading your system or a different browser'),null}return b.optionalExtensions.forEach(c),{extensions:e,restore:function(){Object.keys(e).forEach((function(a){if(e[a]&&!c(a))throw Error("(regl): error restoring extension "+a)}))}}}function J(a,b){for(var c=Array(a),e=0;e<a;++e)c[e]=b(e);return c}function eb(a){var b,c;return b=(65535<a)<<4,b|=c=(255<(a>>>=b))<<3,(b|=c=(15<(a>>>=c))<<2)|(c=(3<(a>>>=c))<<1)|a>>>c>>1}function fb(){function a(a){a:{for(var b=16;268435456>=b;b*=16)if(a<=b){a=b;break a}a=0}return 0<(b=c[eb(a)>>2]).length?b.pop():new ArrayBuffer(a)}function b(a){c[eb(a.byteLength)>>2].push(a)}var c=J(8,(function(){return[]}));return{alloc:a,free:b,allocType:function(b,c){var d=null;switch(b){case 5120:d=new Int8Array(a(c),0,c);break;case 5121:d=new Uint8Array(a(c),0,c);break;case 5122:d=new Int16Array(a(2*c),0,c);break;case 5123:d=new Uint16Array(a(2*c),0,c);break;case 5124:d=new Int32Array(a(4*c),0,c);break;case 5125:d=new Uint32Array(a(4*c),0,c);break;case 5126:d=new Float32Array(a(4*c),0,c);break;default:return null}return d.length!==c?d.subarray(0,c):d},freeType:function(a){b(a.buffer)}}}function Z(a){return!!a&&"object"==typeof a&&Array.isArray(a.shape)&&Array.isArray(a.stride)&&"number"==typeof a.offset&&a.shape.length===a.stride.length&&(Array.isArray(a.data)||K(a.data))}function gb(a,b,c,e,f,d){for(var p=0;p<b;++p)for(var r=a[p],v=0;v<c;++v)for(var m=r[v],u=0;u<e;++u)f[d++]=m[u]}function hb(a,b,c,e,f){for(var d=1,p=c+1;p<b.length;++p)d*=b[p];var r=b[c];if(4==b.length-c){var v=b[c+1],m=b[c+2];for(b=b[c+3],p=0;p<r;++p)gb(a[p],v,m,b,e,f),f+=d}else for(p=0;p<r;++p)hb(a[p],b,c+1,e,f),f+=d}function Fa(a){return 0|Ga[Object.prototype.toString.call(a)]}function ib(a,b){for(var c=0;c<b.length;++c)a[c]=b[c]}function jb(a,b,c,e,f,d,p){for(var r=0,v=0;v<c;++v)for(var m=0;m<e;++m)a[r++]=b[f*v+d*m+p]}function Ib(a,b,c,e){function f(b){this.id=v++,this.buffer=a.createBuffer(),this.type=b,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,c.profile&&(this.stats={size:0})}function d(b,c,q){b.byteLength=c.byteLength,a.bufferData(b.type,c,q)}function p(a,b,c,h,g,k){if(a.usage=c,Array.isArray(b)){if(a.dtype=h||5126,0<b.length)if(Array.isArray(b[0])){g=kb(b);for(var l=h=1;l<g.length;++l)h*=g[l];a.dimension=h,d(a,b=Sa(b,g,a.dtype),c),k?a.persistentData=b:D.freeType(b)}else"number"==typeof b[0]?(a.dimension=g,ib(g=D.allocType(a.dtype,b.length),b),d(a,g,c),k?a.persistentData=g:D.freeType(g)):K(b[0])&&(a.dimension=b[0].length,a.dtype=h||Fa(b[0])||5126,d(a,b=Sa(b,[b.length,b[0].length],a.dtype),c),k?a.persistentData=b:D.freeType(b))}else if(K(b))a.dtype=h||Fa(b),a.dimension=g,d(a,b,c),k&&(a.persistentData=new Uint8Array(new Uint8Array(b.buffer)));else if(Z(b)){var e=b.stride,t=(l=b.offset,0),ka=0,f=0,m=0;1===(g=b.shape).length?(t=g[0],ka=1,f=e[0],m=0):2===g.length&&(t=g[0],ka=g[1],f=e[0],m=e[1]),a.dtype=h||Fa(b.data)||5126,a.dimension=ka,jb(g=D.allocType(a.dtype,t*ka),b.data,t,ka,f,m,l),d(a,g,c),k?a.persistentData=g:D.freeType(g)}else b instanceof ArrayBuffer&&(a.dtype=5121,a.dimension=g,d(a,b,c),k&&(a.persistentData=new Uint8Array(new Uint8Array(b))))}function r(c){b.bufferCount--,e(c),a.deleteBuffer(c.buffer),c.buffer=null,delete m[c.id]}var v=0,m={};f.prototype.bind=function(){a.bindBuffer(this.type,this.buffer)},f.prototype.destroy=function(){r(this)};var u=[];return c.profile&&(b.getTotalBufferSize=function(){var a=0;return Object.keys(m).forEach((function(b){a+=m[b].stats.size})),a}),{create:function(n,e,d,h){function g(b){var n=35044,t=null,e=0,d=0,f=k&&k.dimension||1;return Array.isArray(b)||K(b)||Z(b)||b instanceof ArrayBuffer?t=b:"number"==typeof b?e=0|b:b&&("data"in b&&(t=b.data),"usage"in b&&(n=lb[b.usage]),"type"in b&&(d=Ha[b.type]),"dimension"in b&&(f=0|b.dimension),"length"in b&&(e=0|b.length)),k.bind(),t?p(k,t,n,d,f,h):(e&&a.bufferData(k.type,e,n),k.dtype=d||5121,k.usage=n,k.dimension=f,k.byteLength=e),c.profile&&(k.stats.size=k.byteLength*ia[k.dtype]),g}b.bufferCount++;var k=new f(e);return m[k.id]=k,d||g(n),g._reglType="buffer",g._buffer=k,g.subdata=function(b,c){var n,t=0|(c||0);if(k.bind(),K(b)||b instanceof ArrayBuffer)a.bufferSubData(k.type,t,b);else if(Array.isArray(b)){if(0<b.length)if("number"==typeof b[0]){var e=D.allocType(k.dtype,b.length);ib(e,b),a.bufferSubData(k.type,t,e),D.freeType(e)}else(Array.isArray(b[0])||K(b[0]))&&(n=kb(b),e=Sa(b,n,k.dtype),a.bufferSubData(k.type,t,e),D.freeType(e))}else if(Z(b)){var d=b.stride,h=e=0,f=0,E=0;1===(n=b.shape).length?(e=n[0],h=1,f=d[0],E=0):2===n.length&&(e=n[0],h=n[1],f=d[0],E=d[1]),n=Array.isArray(b.data)?k.dtype:Fa(b.data),jb(n=D.allocType(n,e*h),b.data,e,h,f,E,b.offset),a.bufferSubData(k.type,t,n),D.freeType(n)}return g},c.profile&&(g.stats=k.stats),g.destroy=function(){r(k)},g},createStream:function(a,b){var c=u.pop();return c||(c=new f(a)),c.bind(),p(c,b,35040,0,1,!1),c},destroyStream:function(a){u.push(a)},clear:function(){S(m).forEach(r),u.forEach(r)},getBuffer:function(a){return a&&a._buffer instanceof f?a._buffer:null},restore:function(){S(m).forEach((function(b){b.buffer=a.createBuffer(),a.bindBuffer(b.type,b.buffer),a.bufferData(b.type,b.persistentData||b.byteLength,b.usage)}))},_initBuffer:p}}function Jb(a,b,c,e){function f(a){this.id=v++,r[this.id]=this,this.buffer=a,this.primType=4,this.type=this.vertCount=0}function d(e,d,f,h,g,k,l){var m;if(e.buffer.bind(),d?((m=l)||K(d)&&(!Z(d)||K(d.data))||(m=b.oes_element_index_uint?5125:5123),c._initBuffer(e.buffer,d,f,m,3)):(a.bufferData(34963,k,f),e.buffer.dtype=m||5121,e.buffer.usage=f,e.buffer.dimension=3,e.buffer.byteLength=k),m=l,!l){switch(e.buffer.dtype){case 5121:case 5120:m=5121;break;case 5123:case 5122:m=5123;break;case 5125:case 5124:m=5125}e.buffer.dtype=m}e.type=m,0>(d=g)&&(d=e.buffer.byteLength,5123===m?d>>=1:5125===m&&(d>>=2)),e.vertCount=d,d=h,0>h&&(d=4,1===(h=e.buffer.dimension)&&(d=0),2===h&&(d=1),3===h&&(d=4)),e.primType=d}function p(a){e.elementsCount--,delete r[a.id],a.buffer.destroy(),a.buffer=null}var r={},v=0,m={uint8:5121,uint16:5123};b.oes_element_index_uint&&(m.uint32=5125),f.prototype.bind=function(){this.buffer.bind()};var u=[];return{create:function(a,b){function q(a){if(a)if("number"==typeof a)h(a),g.primType=4,g.vertCount=0|a,g.type=5121;else{var b=null,c=35044,e=-1,f=-1,n=0,r=0;Array.isArray(a)||K(a)||Z(a)?b=a:("data"in a&&(b=a.data),"usage"in a&&(c=lb[a.usage]),"primitive"in a&&(e=Ia[a.primitive]),"count"in a&&(f=0|a.count),"type"in a&&(r=m[a.type]),"length"in a?n=0|a.length:(n=f,5123===r||5122===r?n*=2:5125!==r&&5124!==r||(n*=4))),d(g,b,c,e,f,n,r)}else h(),g.primType=4,g.vertCount=0,g.type=5121;return q}var h=c.create(null,34963,!0),g=new f(h._buffer);return e.elementsCount++,q(a),q._reglType="elements",q._elements=g,q.subdata=function(a,b){return h.subdata(a,b),q},q.destroy=function(){p(g)},q},createStream:function(a){var b=u.pop();return b||(b=new f(c.create(null,34963,!0,!1)._buffer)),d(b,a,35040,-1,-1,0,0),b},destroyStream:function(a){u.push(a)},getElements:function(a){return"function"==typeof a&&a._elements instanceof f?a._elements:null},clear:function(){S(r).forEach(p)}}}function mb(a){for(var b=D.allocType(5123,a.length),c=0;c<a.length;++c)if(isNaN(a[c]))b[c]=65535;else if(1/0===a[c])b[c]=31744;else if(-1/0===a[c])b[c]=64512;else{nb[0]=a[c];var f=(e=Kb[0])>>>31<<15,d=(e<<1>>>24)-127,e=e>>13&1023;b[c]=-24>d?f:-14>d?f+(e+1024>>-14-d):15<d?f+31744:f+(d+15<<10)+e}return b}function na(a){return Array.isArray(a)||K(a)}function oa(a){return"[object "+a+"]"}function ob(a){return Array.isArray(a)&&(0===a.length||"number"==typeof a[0])}function pb(a){return!(!Array.isArray(a)||0===a.length||!na(a[0]))}function ja(a){return Object.prototype.toString.call(a)}function Ta(a){if(!a)return!1;var b=ja(a);return 0<=Lb.indexOf(b)||ob(a)||pb(a)||Z(a)}function qb(a,b){36193===a.type?(a.data=mb(b),D.freeType(b)):a.data=b}function Ja(a,b,c,e,f,d){if(a=void 0!==H[a]?H[a]:R[a]*pa[b],d&&(a*=6),f){for(e=0;1<=c;)e+=a*c*c,c/=2;return e}return a*c*e}function Mb(a,b,c,e,f,d,p){function r(){this.format=this.internalformat=6408,this.type=5121,this.flipY=this.premultiplyAlpha=this.compressed=!1,this.unpackAlignment=1,this.colorSpace=37444,this.channels=this.height=this.width=0}function v(a,b){a.internalformat=b.internalformat,a.format=b.format,a.type=b.type,a.compressed=b.compressed,a.premultiplyAlpha=b.premultiplyAlpha,a.flipY=b.flipY,a.unpackAlignment=b.unpackAlignment,a.colorSpace=b.colorSpace,a.width=b.width,a.height=b.height,a.channels=b.channels}function m(a,b){if("object"==typeof b&&b){"premultiplyAlpha"in b&&(a.premultiplyAlpha=b.premultiplyAlpha),"flipY"in b&&(a.flipY=b.flipY),"alignment"in b&&(a.unpackAlignment=b.alignment),"colorSpace"in b&&(a.colorSpace=Nb[b.colorSpace]),"type"in b&&(a.type=N[b.type]);var c=a.width,e=a.height,d=a.channels,g=!1;"shape"in b?(c=b.shape[0],e=b.shape[1],3===b.shape.length&&(d=b.shape[2],g=!0)):("radius"in b&&(c=e=b.radius),"width"in b&&(c=b.width),"height"in b&&(e=b.height),"channels"in b&&(d=b.channels,g=!0)),a.width=0|c,a.height=0|e,a.channels=0|d,c=!1,"format"in b&&(e=a.internalformat=G[c=b.format],a.format=x[e],c in N&&!("type"in b)&&(a.type=N[c]),c in ga&&(a.compressed=!0),c=!0),!g&&c?a.channels=R[a.format]:g&&!c&&a.channels!==Ma[a.format]&&(a.format=a.internalformat=Ma[a.channels])}}function u(b){a.pixelStorei(37440,b.flipY),a.pixelStorei(37441,b.premultiplyAlpha),a.pixelStorei(37443,b.colorSpace),a.pixelStorei(3317,b.unpackAlignment)}function n(){r.call(this),this.yOffset=this.xOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function z(a,b){var c=null;if(Ta(b)?c=b:b&&(m(a,b),"x"in b&&(a.xOffset=0|b.x),"y"in b&&(a.yOffset=0|b.y),Ta(b.data)&&(c=b.data)),b.copy){var e=f.viewportWidth,d=f.viewportHeight;a.width=a.width||e-a.xOffset,a.height=a.height||d-a.yOffset,a.needsCopy=!0}else if(c){if(K(c))a.channels=a.channels||4,a.data=c,"type"in b||5121!==a.type||(a.type=0|Ga[Object.prototype.toString.call(c)]);else if(ob(c)){switch(a.channels=a.channels||4,d=(e=c).length,a.type){case 5121:case 5123:case 5125:case 5126:(d=D.allocType(a.type,d)).set(e),a.data=d;break;case 36193:a.data=mb(e)}a.alignment=1,a.needsFree=!0}else if(Z(c)){e=c.data,Array.isArray(e)||5121!==a.type||(a.type=0|Ga[Object.prototype.toString.call(e)]);var t,E,h,l,g=c.stride;3===(d=c.shape).length?(h=d[2],l=g[2]):l=h=1,t=d[0],E=d[1],d=g[0],g=g[1],a.alignment=1,a.width=t,a.height=E,a.channels=h,a.format=a.internalformat=Ma[h],a.needsFree=!0,t=l,c=c.offset;for(var w=D.allocType(36193===a.type?5126:a.type,(h=a.width)*(l=a.height)*(E=a.channels)),O=0,da=0;da<l;++da)for(var xa=0;xa<h;++xa)for(var Ua=0;Ua<E;++Ua)w[O++]=e[d*xa+g*da+t*Ua+c];qb(a,w)}else if(ja(c)===Va||ja(c)===Wa||ja(c)===sb)a.element=ja(c)===Va||ja(c)===Wa?c:c.canvas,a.width=a.element.width,a.height=a.element.height,a.channels=4;else if(ja(c)===tb)a.element=c,a.width=c.width,a.height=c.height,a.channels=4;else if(ja(c)===ub)a.element=c,a.width=c.naturalWidth,a.height=c.naturalHeight,a.channels=4;else if(ja(c)===vb)a.element=c,a.width=c.videoWidth,a.height=c.videoHeight,a.channels=4;else if(pb(c)){for(e=a.width||c[0].length,d=a.height||c.length,g=a.channels,g=na(c[0][0])?g||c[0][0].length:g||1,t=Oa.shape(c),h=1,l=0;l<t.length;++l)h*=t[l];h=D.allocType(36193===a.type?5126:a.type,h),Oa.flatten(c,t,"",h),qb(a,h),a.alignment=1,a.width=e,a.height=d,a.channels=g,a.format=a.internalformat=Ma[g],a.needsFree=!0}}else a.width=a.width||1,a.height=a.height||1,a.channels=a.channels||4}function q(b,c,d,g,h){var t=b.element,l=b.data,E=b.internalformat,f=b.format,m=b.type,w=b.width,O=b.height;u(b),t?a.texSubImage2D(c,h,d,g,f,m,t):b.compressed?a.compressedTexSubImage2D(c,h,d,g,E,w,O,l):b.needsCopy?(e(),a.copyTexSubImage2D(c,h,d,g,b.xOffset,b.yOffset,w,O)):a.texSubImage2D(c,h,d,g,w,O,f,m,l)}function h(){return wb.pop()||new n}function g(a){a.needsFree&&D.freeType(a.data),n.call(a),wb.push(a)}function k(){r.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)}function l(a,b,c){var e=a.images[0]=h();a.mipmask=1,e.width=a.width=b,e.height=a.height=c,e.channels=a.channels=4}function A(a,b){var c=null;if(Ta(b))v(c=a.images[0]=h(),a),z(c,b),a.mipmask=1;else if(m(a,b),Array.isArray(b.mipmap))for(var e=b.mipmap,d=0;d<e.length;++d)v(c=a.images[d]=h(),a),c.width>>=d,c.height>>=d,z(c,e[d]),a.mipmask|=1<<d;else v(c=a.images[0]=h(),a),z(c,b),a.mipmask=1;v(a,a.images[0])}function t(b,c){for(var d=b.images,g=0;g<d.length&&d[g];++g){var h=d[g],t=c,l=g,E=h.element,f=h.data,m=h.internalformat,w=h.format,O=h.type,da=h.width,xa=h.height;u(h),E?a.texImage2D(t,l,w,w,O,E):h.compressed?a.compressedTexImage2D(t,l,m,Math.max(1,da),Math.max(1,xa),0,f):h.needsCopy?(e(),a.copyTexImage2D(t,l,w,h.xOffset,h.yOffset,da,xa,0)):a.texImage2D(t,l,w,da,xa,0,w,O,f||null)}}function ka(){var a=J.pop()||new k;r.call(a);for(var b=a.mipmask=0;16>b;++b)a.images[b]=null;return a}function wa(a){for(var b=a.images,c=0;c<b.length;++c)b[c]&&g(b[c]),b[c]=null;J.push(a)}function B(){this.magFilter=this.minFilter=9728,this.wrapT=this.wrapS=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function C(a,b){"min"in b&&(a.minFilter=ya[b.min],0<=Ob.indexOf(a.minFilter)&&!("faces"in b)&&(a.genMipmaps=!0)),"mag"in b&&(a.magFilter=Q[b.mag]);var c=a.wrapS,d=a.wrapT;if("wrap"in b){var e=b.wrap;"string"==typeof e?c=d=ha[e]:Array.isArray(e)&&(c=ha[e[0]],d=ha[e[1]])}else"wrapS"in b&&(c=ha[b.wrapS]),"wrapT"in b&&(d=ha[b.wrapT]);if(a.wrapS=c,a.wrapT=d,"anisotropic"in b&&(a.anisotropic=b.anisotropic),"mipmap"in b){switch(c=!1,typeof b.mipmap){case"string":a.mipmapHint=Pb[b.mipmap],c=a.genMipmaps=!0;break;case"boolean":c=a.genMipmaps=b.mipmap;break;case"object":a.genMipmaps=!1,c=!0}!c||"min"in b||(a.minFilter=9984)}}function M(c,d){a.texParameteri(d,10241,c.minFilter),a.texParameteri(d,10240,c.magFilter),a.texParameteri(d,10242,c.wrapS),a.texParameteri(d,10243,c.wrapT),b.ext_texture_filter_anisotropic&&a.texParameteri(d,34046,c.anisotropic),c.genMipmaps&&(a.hint(33170,c.mipmapHint),a.generateMipmap(d))}function E(b){r.call(this),this.mipmask=0,this.internalformat=6408,this.id=Y++,this.refCount=1,this.target=b,this.texture=a.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new B,p.profile&&(this.stats={size:0})}function aa(b){a.activeTexture(33984),a.bindTexture(b.target,b.texture)}function ta(){var b=T[0];b?a.bindTexture(b.target,b.texture):a.bindTexture(3553,null)}function y(b){var c=b.texture,e=b.unit,g=b.target;0<=e&&(a.activeTexture(33984+e),a.bindTexture(g,null),T[e]=null),a.deleteTexture(c),b.texture=null,b.params=null,b.pixels=null,b.refCount=0,delete ea[b.id],d.textureCount--}var Pb={"don't care":4352,"dont care":4352,nice:4354,fast:4353},ha={repeat:10497,clamp:33071,mirror:33648},Q={nearest:9728,linear:9729},ya=F({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},Q),Nb={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},G={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},ga={};b.ext_srgb&&(G.srgb=35904,G.srgba=35906),b.oes_texture_float&&(N.float32=N.float=5126),b.oes_texture_half_float&&(N.float16=N["half float"]=36193),b.webgl_depth_texture&&(F(G,{depth:6402,"depth stencil":34041}),F(N,{uint16:5123,uint32:5125,"depth stencil":34042})),b.webgl_compressed_texture_s3tc&&F(ga,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),b.webgl_compressed_texture_atc&&F(ga,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),b.webgl_compressed_texture_pvrtc&&F(ga,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),b.webgl_compressed_texture_etc1&&(ga["rgb etc1"]=36196);var I=Array.prototype.slice.call(a.getParameter(34467));Object.keys(ga).forEach((function(a){var b=ga[a];0<=I.indexOf(b)&&(G[a]=b)}));var H=Object.keys(G);c.textureFormats=H;var ba=[];Object.keys(G).forEach((function(a){ba[G[a]]=a}));var L=[];Object.keys(N).forEach((function(a){L[N[a]]=a}));var Da=[];Object.keys(Q).forEach((function(a){Da[Q[a]]=a}));var la=[];Object.keys(ya).forEach((function(a){la[ya[a]]=a}));var ma=[];Object.keys(ha).forEach((function(a){ma[ha[a]]=a}));var x=H.reduce((function(a,c){var d=G[c];return a[d]=6409===d||6406===d||6409===d||6410===d||6402===d||34041===d||b.ext_srgb&&(35904===d||35906===d)?d:32855===d||0<=c.indexOf("rgba")?6408:6407,a}),{}),wb=[],J=[],Y=0,ea={},fa=c.maxTextureUnits,T=Array(fa).map((function(){return null}));return F(E.prototype,{bind:function(){this.bindCount+=1;var b=this.unit;if(0>b){for(var c=0;c<fa;++c){var e=T[c];if(e){if(0<e.bindCount)continue;e.unit=-1}T[c]=this,b=c;break}p.profile&&d.maxTextureUnits<b+1&&(d.maxTextureUnits=b+1),this.unit=b,a.activeTexture(33984+b),a.bindTexture(this.target,this.texture)}return b},unbind:function(){--this.bindCount},decRef:function(){0>=--this.refCount&&y(this)}}),p.profile&&(d.getTotalTextureSize=function(){var a=0;return Object.keys(ea).forEach((function(b){a+=ea[b].stats.size})),a}),{create2D:function(b,c){function e(a,b){var c=f.texInfo;B.call(c);var d=ka();return"number"==typeof a?l(d,0|a,"number"==typeof b?0|b:0|a):a?(C(c,a),A(d,a)):l(d,1,1),c.genMipmaps&&(d.mipmask=(Math.max(d.width,d.height)<<1)-1),f.mipmask=d.mipmask,v(f,d),f.internalformat=d.internalformat,e.width=d.width,e.height=d.height,aa(f),t(d,3553),M(c,3553),ta(),wa(d),p.profile&&(f.stats.size=Ja(f.internalformat,f.type,d.width,d.height,c.genMipmaps,!1)),e.format=ba[f.internalformat],e.type=L[f.type],e.mag=Da[c.magFilter],e.min=la[c.minFilter],e.wrapS=ma[c.wrapS],e.wrapT=ma[c.wrapT],e}var f=new E(3553);return ea[f.id]=f,d.textureCount++,e(b,c),e.subimage=function(a,b,c,d){b|=0,c|=0,d|=0;var t=h();return v(t,f),t.width=0,t.height=0,z(t,a),t.width=t.width||(f.width>>d)-b,t.height=t.height||(f.height>>d)-c,aa(f),q(t,3553,b,c,d),ta(),g(t),e},e.resize=function(b,c){var d=0|b,g=0|c||d;if(d===f.width&&g===f.height)return e;e.width=f.width=d,e.height=f.height=g,aa(f);for(var h=0;f.mipmask>>h;++h){var t=d>>h,w=g>>h;if(!t||!w)break;a.texImage2D(3553,h,f.format,t,w,0,f.format,f.type,null)}return ta(),p.profile&&(f.stats.size=Ja(f.internalformat,f.type,d,g,!1,!1)),e},e._reglType="texture2d",e._texture=f,p.profile&&(e.stats=f.stats),e.destroy=function(){f.decRef()},e},createCube:function(b,c,e,f,n,r){function k(a,b,c,d,e,f){var g,ca=y.texInfo;for(B.call(ca),g=0;6>g;++g)u[g]=ka();if("number"!=typeof a&&a){if("object"==typeof a)if(b)A(u[0],a),A(u[1],b),A(u[2],c),A(u[3],d),A(u[4],e),A(u[5],f);else if(C(ca,a),m(y,a),"faces"in a)for(a=a.faces,g=0;6>g;++g)v(u[g],y),A(u[g],a[g]);else for(g=0;6>g;++g)A(u[g],a)}else for(a=0|a||1,g=0;6>g;++g)l(u[g],a,a);for(v(y,u[0]),y.mipmask=ca.genMipmaps?(Math.max(u[0].width,u[0].height)<<1)-1:u[0].mipmask,y.internalformat=u[0].internalformat,k.width=u[0].width,k.height=u[0].height,aa(y),g=0;6>g;++g)t(u[g],34069+g);for(M(ca,34067),ta(),p.profile&&(y.stats.size=Ja(y.internalformat,y.type,k.width,k.height,ca.genMipmaps,!0)),k.format=ba[y.internalformat],k.type=L[y.type],k.mag=Da[ca.magFilter],k.min=la[ca.minFilter],k.wrapS=ma[ca.wrapS],k.wrapT=ma[ca.wrapT],g=0;6>g;++g)wa(u[g]);return k}var y=new E(34067);ea[y.id]=y,d.cubeCount++;var u=Array(6);return k(b,c,e,f,n,r),k.subimage=function(a,b,c,d,e){c|=0,d|=0,e|=0;var f=h();return v(f,y),f.width=0,f.height=0,z(f,b),f.width=f.width||(y.width>>e)-c,f.height=f.height||(y.height>>e)-d,aa(y),q(f,34069+a,c,d,e),ta(),g(f),k},k.resize=function(b){if((b|=0)!==y.width){k.width=y.width=b,k.height=y.height=b,aa(y);for(var c=0;6>c;++c)for(var d=0;y.mipmask>>d;++d)a.texImage2D(34069+c,d,y.format,b>>d,b>>d,0,y.format,y.type,null);return ta(),p.profile&&(y.stats.size=Ja(y.internalformat,y.type,k.width,k.height,!1,!0)),k}},k._reglType="textureCube",k._texture=y,p.profile&&(k.stats=y.stats),k.destroy=function(){y.decRef()},k},clear:function(){for(var b=0;b<fa;++b)a.activeTexture(33984+b),a.bindTexture(3553,null),T[b]=null;S(ea).forEach(y),d.cubeCount=0,d.textureCount=0},getTexture:function(a){return null},restore:function(){for(var b=0;b<fa;++b){var c=T[b];c&&(c.bindCount=0,c.unit=-1,T[b]=null)}S(ea).forEach((function(b){b.texture=a.createTexture(),a.bindTexture(b.target,b.texture);for(var c=0;32>c;++c)if(0!=(b.mipmask&1<<c))if(3553===b.target)a.texImage2D(3553,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);else for(var d=0;6>d;++d)a.texImage2D(34069+d,c,b.internalformat,b.width>>c,b.height>>c,0,b.internalformat,b.type,null);M(b.texInfo,b.target)}))},refresh:function(){for(var b=0;b<fa;++b){var c=T[b];c&&(c.bindCount=0,c.unit=-1,T[b]=null),a.activeTexture(33984+b),a.bindTexture(3553,null),a.bindTexture(34067,null)}}}}function Qb(a,b,c,e,f,d){function p(a,b,c){this.target=a,this.texture=b,this.renderbuffer=c;var d=a=0;b?(a=b.width,d=b.height):c&&(a=c.width,d=c.height),this.width=a,this.height=d}function r(a){a&&(a.texture&&a.texture._texture.decRef(),a.renderbuffer&&a.renderbuffer._renderbuffer.decRef())}function v(a,b,c){a&&(a.texture?a.texture._texture.refCount+=1:a.renderbuffer._renderbuffer.refCount+=1)}function m(b,c){c&&(c.texture?a.framebufferTexture2D(36160,b,c.target,c.texture._texture.texture,0):a.framebufferRenderbuffer(36160,b,36161,c.renderbuffer._renderbuffer.renderbuffer))}function u(a){var b=3553,c=null,d=null,e=a;return"object"==typeof a&&(e=a.data,"target"in a&&(b=0|a.target)),"texture2d"===(a=e._reglType)||"textureCube"===a?c=e:"renderbuffer"===a&&(d=e,b=36161),new p(b,c,d)}function n(a,b,c,d,g){return c?((a=e.create2D({width:a,height:b,format:d,type:g}))._texture.refCount=0,new p(3553,a,null)):((a=f.create({width:a,height:b,format:d}))._renderbuffer.refCount=0,new p(36161,null,a))}function z(a){return a&&(a.texture||a.renderbuffer)}function q(a,b,c){a&&(a.texture?a.texture.resize(b,c):a.renderbuffer&&a.renderbuffer.resize(b,c),a.width=b,a.height=c)}function h(){this.id=C++,M[this.id]=this,this.framebuffer=a.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function g(a){a.colorAttachments.forEach(r),r(a.depthAttachment),r(a.stencilAttachment),r(a.depthStencilAttachment)}function k(b){a.deleteFramebuffer(b.framebuffer),b.framebuffer=null,d.framebufferCount--,delete M[b.id]}function l(b,d){var e;a.bindFramebuffer(36160,b.framebuffer);var g=b.colorAttachments;for(e=0;e<g.length;++e)m(36064+e,g[e]);for(e=g.length;e<c.maxColorAttachments;++e)a.framebufferTexture2D(36160,36064+e,3553,null,0);a.framebufferTexture2D(36160,33306,3553,null,0),a.framebufferTexture2D(36160,36096,3553,null,0),a.framebufferTexture2D(36160,36128,3553,null,0),m(36096,b.depthAttachment),m(36128,b.stencilAttachment),m(33306,b.depthStencilAttachment),d||(a.checkFramebufferStatus(36160),a.isContextLost()),a.bindFramebuffer(36160,t.next?t.next.framebuffer:null),t.cur=t.next,d||a.getError()}function A(b,c){function e(a,b){var c,d=0,h=0,t=!0,k=!0;c=null;var m=!0,q="rgba",r="uint8",p=1,A=null,E=null,la=null,M=!1;if("number"==typeof a)d=0|a,h=0|b||d;else if(a){var x=a;"shape"in x?(d=(h=x.shape)[0],h=h[1]):("radius"in x&&(d=h=x.radius),"width"in x&&(d=x.width),"height"in x&&(h=x.height)),("color"in x||"colors"in x)&&(c=x.color||x.colors),c||("colorCount"in x&&(p=0|x.colorCount),"colorTexture"in x&&(m=!!x.colorTexture,q="rgba4"),"colorType"in x&&(r=x.colorType,!m)&&("half float"===r||"float16"===r?q="rgba16f":"float"!==r&&"float32"!==r||(q="rgba32f")),"colorFormat"in x&&(0<=ka.indexOf(q=x.colorFormat)?m=!0:0<=wa.indexOf(q)&&(m=!1))),("depthTexture"in x||"depthStencilTexture"in x)&&(M=!(!x.depthTexture&&!x.depthStencilTexture)),"depth"in x&&("boolean"==typeof x.depth?t=x.depth:(A=x.depth,k=!1)),"stencil"in x&&("boolean"==typeof x.stencil?k=x.stencil:(E=x.stencil,t=!1)),"depthStencil"in x&&("boolean"==typeof x.depthStencil?t=k=x.depthStencil:(la=x.depthStencil,k=t=!1))}else d=h=1;var C=null,aa=null,B=null,F=null;if(Array.isArray(c))C=c.map(u);else if(c)C=[u(c)];else for(C=Array(p),c=0;c<p;++c)C[c]=n(d,h,m,q,r);for(d=d||C[0].width,h=h||C[0].height,A?aa=u(A):t&&!k&&(aa=n(d,h,M,"depth","uint32")),E?B=u(E):k&&!t&&(B=n(d,h,!1,"stencil","uint8")),la?F=u(la):!A&&!E&&k&&t&&(F=n(d,h,M,"depth stencil","depth stencil")),t=null,c=0;c<C.length;++c)v(C[c]),C[c]&&C[c].texture&&(k=Xa[C[c].texture._texture.format]*Pa[C[c].texture._texture.type],null===t&&(t=k));return v(aa),v(B),v(F),g(f),f.width=d,f.height=h,f.colorAttachments=C,f.depthAttachment=aa,f.stencilAttachment=B,f.depthStencilAttachment=F,e.color=C.map(z),e.depth=z(aa),e.stencil=z(B),e.depthStencil=z(F),e.width=f.width,e.height=f.height,l(f,x&&x.ignoreStatusCheck),e}var f=new h;return d.framebufferCount++,e(b,c),F(e,{resize:function(a,b){var c=Math.max(0|a,1),d=Math.max(0|b||c,1);if(c===f.width&&d===f.height)return e;for(var g=f.colorAttachments,h=0;h<g.length;++h)q(g[h],c,d);return q(f.depthAttachment,c,d),q(f.stencilAttachment,c,d),q(f.depthStencilAttachment,c,d),f.width=e.width=c,f.height=e.height=d,l(f),e},blit:function(b,c,d){a.bindFramebuffer(36008,b._framebuffer.framebuffer),a.bindFramebuffer(36009,f.framebuffer),c||(c=16384),a.blitFramebuffer(0,0,b.width,b.height,0,0,f.width,f.height,c,"linear"===d?9729:9728),a.bindFramebuffer(36008,null),a.bindFramebuffer(36009,null)},_reglType:"framebuffer",_framebuffer:f,destroy:function(){k(f),g(f)},use:function(a){t.setFBO({framebuffer:e},a)}})}var t={cur:null,next:null,dirty:!1,setFBO:null},ka=["rgba"],wa=["rgba4","rgb565","rgb5 a1"];b.ext_srgb&&wa.push("srgba"),b.ext_color_buffer_half_float&&wa.push("rgba16f","rgb16f"),b.webgl_color_buffer_float&&wa.push("rgba32f");var B=["uint8"];b.oes_texture_half_float&&B.push("half float","float16"),b.oes_texture_float&&B.push("float","float32");var C=0,M={};return F(t,{getFramebuffer:function(a){return"function"==typeof a&&"framebuffer"===a._reglType&&(a=a._framebuffer)instanceof h?a:null},create:A,createCube:function(a){function b(a){var d,f={color:null},g=0,h=null;d="rgba";var t="uint8",l=1;if("number"==typeof a?g=0|a:a?("shape"in a?g=a.shape[0]:("radius"in a&&(g=0|a.radius),"width"in a?g=0|a.width:"height"in a&&(g=0|a.height)),("color"in a||"colors"in a)&&(h=a.color||a.colors),h||("colorCount"in a&&(l=0|a.colorCount),"colorType"in a&&(t=a.colorType),"colorFormat"in a&&(d=a.colorFormat)),"depth"in a&&(f.depth=a.depth),"stencil"in a&&(f.stencil=a.stencil),"depthStencil"in a&&(f.depthStencil=a.depthStencil)):g=1,h)if(Array.isArray(h))for(a=[],d=0;d<h.length;++d)a[d]=h[d];else a=[h];else for(a=Array(l),h={radius:g,format:d,type:t},d=0;d<l;++d)a[d]=e.createCube(h);for(f.color=Array(a.length),d=0;d<a.length;++d)l=a[d],g=g||l.width,f.color[d]={target:34069,data:a[d]};for(d=0;6>d;++d){for(l=0;l<a.length;++l)f.color[l].target=34069+d;0<d&&(f.depth=c[0].depth,f.stencil=c[0].stencil,f.depthStencil=c[0].depthStencil),c[d]?c[d](f):c[d]=A(f)}return F(b,{width:g,height:g,color:a})}var c=Array(6);return b(a),F(b,{faces:c,resize:function(a){var d=0|a;if(d===b.width)return b;var e=b.color;for(a=0;a<e.length;++a)e[a].resize(d);for(a=0;6>a;++a)c[a].resize(d);return b.width=b.height=d,b},_reglType:"framebufferCube",destroy:function(){c.forEach((function(a){a.destroy()}))}})},clear:function(){S(M).forEach(k)},restore:function(){t.cur=null,t.next=null,t.dirty=!0,S(M).forEach((function(b){b.framebuffer=a.createFramebuffer(),l(b)}))}})}function Ya(){this.w=this.z=this.y=this.x=this.state=0,this.buffer=null,this.size=0,this.normalized=!1,this.type=5126,this.divisor=this.stride=this.offset=0}function Rb(a,b,c,e,f,d,p){function r(a){if(a!==k.currentVAO){var c=b.oes_vertex_array_object;c.bindVertexArrayOES(a?a.vao:null),k.currentVAO=a}}function v(c){if(c!==k.currentVAO){if(c)c.bindAttrs();else{for(var d=b.angle_instanced_arrays,e=0;e<q.length;++e){var f=q[e];f.buffer?(a.enableVertexAttribArray(e),f.buffer.bind(),a.vertexAttribPointer(e,f.size,f.type,f.normalized,f.stride,f.offfset),d&&f.divisor&&d.vertexAttribDivisorANGLE(e,f.divisor)):(a.disableVertexAttribArray(e),a.vertexAttrib4f(e,f.x,f.y,f.z,f.w))}a.bindBuffer(34963,p.elements?p.elements.buffer.buffer:null)}k.currentVAO=c}}function m(){S(g).forEach((function(a){a.destroy()}))}function u(){this.id=++h,this.attributes=[],this.elements=null,this.ownsElements=!1,this.offset=this.count=0,this.instances=-1,this.primitive=4;var a=b.oes_vertex_array_object;this.vao=a?a.createVertexArrayOES():null,g[this.id]=this,this.buffers=[]}function n(){b.oes_vertex_array_object&&S(g).forEach((function(a){a.refresh()}))}var z=c.maxAttributes,q=Array(z);for(c=0;c<z;++c)q[c]=new Ya;var h=0,g={},k={Record:Ya,scope:{},state:q,currentVAO:null,targetVAO:null,restore:b.oes_vertex_array_object?n:function(){},createVAO:function(a){function b(a){var e;Array.isArray(a)?(e=a,c.elements&&c.ownsElements&&c.elements.destroy(),c.elements=null,c.ownsElements=!1,c.offset=0,c.count=0,c.instances=-1,c.primitive=4):(a.elements?(e=a.elements,c.ownsElements?("function"==typeof e&&"elements"===e._reglType?c.elements.destroy():c.elements(e),c.ownsElements=!1):d.getElements(a.elements)?(c.elements=a.elements,c.ownsElements=!1):(c.elements=d.create(a.elements),c.ownsElements=!0)):(c.elements=null,c.ownsElements=!1),e=a.attributes,c.offset=0,c.count=-1,c.instances=-1,c.primitive=4,c.elements&&(c.count=c.elements._elements.vertCount,c.primitive=c.elements._elements.primType),"offset"in a&&(c.offset=0|a.offset),"count"in a&&(c.count=0|a.count),"instances"in a&&(c.instances=0|a.instances),"primitive"in a&&(c.primitive=Ia[a.primitive])),a={};var g=c.attributes;g.length=e.length;for(var h=0;h<e.length;++h){var n,l=e[h],k=g[h]=new Ya,m=l.data||l;Array.isArray(m)||K(m)||Z(m)?(c.buffers[h]&&(n=c.buffers[h],K(m)&&n._buffer.byteLength>=m.byteLength?n.subdata(m):(n.destroy(),c.buffers[h]=null)),c.buffers[h]||(n=c.buffers[h]=f.create(l,34962,!1,!0)),k.buffer=f.getBuffer(n),k.size=0|k.buffer.dimension,k.normalized=!1,k.type=k.buffer.dtype,k.offset=0,k.stride=0,k.divisor=0,k.state=1,a[h]=1):f.getBuffer(l)?(k.buffer=f.getBuffer(l),k.size=0|k.buffer.dimension,k.normalized=!1,k.type=k.buffer.dtype,k.offset=0,k.stride=0,k.divisor=0,k.state=1):f.getBuffer(l.buffer)?(k.buffer=f.getBuffer(l.buffer),k.size=0|(+l.size||k.buffer.dimension),k.normalized=!!l.normalized||!1,k.type="type"in l?Ha[l.type]:k.buffer.dtype,k.offset=0|(l.offset||0),k.stride=0|(l.stride||0),k.divisor=0|(l.divisor||0),k.state=1):"x"in l&&(k.x=+l.x||0,k.y=+l.y||0,k.z=+l.z||0,k.w=+l.w||0,k.state=2)}for(n=0;n<c.buffers.length;++n)!a[n]&&c.buffers[n]&&(c.buffers[n].destroy(),c.buffers[n]=null);return c.refresh(),b}var c=new u;return e.vaoCount+=1,b.destroy=function(){for(var a=0;a<c.buffers.length;++a)c.buffers[a]&&c.buffers[a].destroy();c.buffers.length=0,c.ownsElements&&(c.elements.destroy(),c.elements=null,c.ownsElements=!1),c.destroy()},b._vao=c,b._reglType="vao",b(a)},getVAO:function(a){return"function"==typeof a&&a._vao?a._vao:null},destroyBuffer:function(b){for(var c=0;c<q.length;++c){var d=q[c];d.buffer===b&&(a.disableVertexAttribArray(c),d.buffer=null)}},setVAO:b.oes_vertex_array_object?r:v,clear:b.oes_vertex_array_object?m:function(){}};return u.prototype.bindAttrs=function(){for(var c=b.angle_instanced_arrays,e=this.attributes,f=0;f<e.length;++f){var g=e[f];g.buffer?(a.enableVertexAttribArray(f),a.bindBuffer(34962,g.buffer.buffer),a.vertexAttribPointer(f,g.size,g.type,g.normalized,g.stride,g.offset),c&&g.divisor&&c.vertexAttribDivisorANGLE(f,g.divisor)):(a.disableVertexAttribArray(f),a.vertexAttrib4f(f,g.x,g.y,g.z,g.w))}for(c=e.length;c<z;++c)a.disableVertexAttribArray(c);(c=d.getElements(this.elements))?a.bindBuffer(34963,c.buffer.buffer):a.bindBuffer(34963,null)},u.prototype.refresh=function(){var a=b.oes_vertex_array_object;a&&(a.bindVertexArrayOES(this.vao),this.bindAttrs(),k.currentVAO=null,a.bindVertexArrayOES(null))},u.prototype.destroy=function(){if(this.vao){var a=b.oes_vertex_array_object;this===k.currentVAO&&(k.currentVAO=null,a.bindVertexArrayOES(null)),a.deleteVertexArrayOES(this.vao),this.vao=null}this.ownsElements&&(this.elements.destroy(),this.elements=null,this.ownsElements=!1),g[this.id]&&(delete g[this.id],--e.vaoCount)},k}function Sb(a,b,c,e){function f(a,b,c,d){this.name=a,this.id=b,this.location=c,this.info=d}function d(a,b){for(var c=0;c<a.length;++c)if(a[c].id===b.id)return void(a[c].location=b.location);a.push(b)}function p(c,d,e){if(!(f=(e=35632===c?m:u)[d])){var n=b.str(d),f=a.createShader(c);a.shaderSource(f,n),a.compileShader(f),e[d]=f}return f}function r(a,b){this.id=q++,this.fragId=a,this.vertId=b,this.program=null,this.uniforms=[],this.attributes=[],this.refCount=1,e.profile&&(this.stats={uniformsCount:0,attributesCount:0})}function v(c,g,k){var m;m=p(35632,c.fragId);var n=p(35633,c.vertId);if(g=c.program=a.createProgram(),a.attachShader(g,m),a.attachShader(g,n),k)for(m=0;m<k.length;++m)a.bindAttribLocation(g,(n=k[m])[0],n[1]);a.linkProgram(g),n=a.getProgramParameter(g,35718),e.profile&&(c.stats.uniformsCount=n);var q=c.uniforms;for(m=0;m<n;++m)if(k=a.getActiveUniform(g,m)){if(1<k.size)for(var r=0;r<k.size;++r){var u=k.name.replace("[0]","["+r+"]");d(q,new f(u,b.id(u),a.getUniformLocation(g,u),k))}r=k.name,1<k.size&&(r=r.replace("[0]","")),d(q,new f(r,b.id(r),a.getUniformLocation(g,r),k))}for(n=a.getProgramParameter(g,35721),e.profile&&(c.stats.attributesCount=n),c=c.attributes,m=0;m<n;++m)(k=a.getActiveAttrib(g,m))&&d(c,new f(k.name,b.id(k.name),a.getAttribLocation(g,k.name),k))}var m={},u={},n={},z=[],q=0;return e.profile&&(c.getMaxUniformsCount=function(){var a=0;return z.forEach((function(b){b.stats.uniformsCount>a&&(a=b.stats.uniformsCount)})),a},c.getMaxAttributesCount=function(){var a=0;return z.forEach((function(b){b.stats.attributesCount>a&&(a=b.stats.attributesCount)})),a}),{clear:function(){var b=a.deleteShader.bind(a);S(m).forEach(b),m={},S(u).forEach(b),u={},z.forEach((function(b){a.deleteProgram(b.program)})),z.length=0,n={},c.shaderCount=0},program:function(b,d,e,f){var q=n[d];q||(q=n[d]={});var t=q[b];if(t&&(t.refCount++,!f))return t;var p=new r(d,b);return c.shaderCount++,v(p,e,f),t||(q[b]=p),z.push(p),F(p,{destroy:function(){if(p.refCount--,0>=p.refCount){a.deleteProgram(p.program);var b=z.indexOf(p);z.splice(b,1),c.shaderCount--}0>=q[p.vertId].refCount&&(a.deleteShader(u[p.vertId]),delete u[p.vertId],delete n[p.fragId][p.vertId]),Object.keys(n[p.fragId]).length||(a.deleteShader(m[p.fragId]),delete m[p.fragId],delete n[p.fragId])}})},restore:function(){m={},u={};for(var a=0;a<z.length;++a)v(z[a],null,z[a].attributes.map((function(a){return[a.location,a.name]})))},shader:p,frag:-1,vert:-1}}function Tb(a,b,c,e,f,d,p){function r(d){var f;f=null===b.next?5121:b.next.colorAttachments[0].texture._texture.type;var n=0,r=0,q=e.framebufferWidth,h=e.framebufferHeight,g=null;return K(d)?g=d:d&&(n=0|d.x,r=0|d.y,q=0|(d.width||e.framebufferWidth-n),h=0|(d.height||e.framebufferHeight-r),g=d.data||null),c(),d=q*h*4,g||(5121===f?g=new Uint8Array(d):5126===f&&(g=g||new Float32Array(d))),a.pixelStorei(3333,4),a.readPixels(n,r,q,h,6408,f,g),g}function v(a){var c;return b.setFBO({framebuffer:a.framebuffer},(function(){c=r(a)})),c}return function(a){return a&&"framebuffer"in a?v(a):r(a)}}function za(a){return Array.prototype.slice.call(a)}function Aa(a){return za(a).join("")}function Ub(){function a(){var a=[],b=[];return F((function(){a.push.apply(a,za(arguments))}),{def:function(){var d="v"+c++;return b.push(d),0<arguments.length&&(a.push(d,"="),a.push.apply(a,za(arguments)),a.push(";")),d},toString:function(){return Aa([0<b.length?"var "+b.join(",")+";":"",Aa(a)])}})}function b(){function b(a,e){d(a,e,"=",c.def(a,e),";")}var c=a(),d=a(),e=c.toString,f=d.toString;return F((function(){c.apply(c,za(arguments))}),{def:c.def,entry:c,exit:d,save:b,set:function(a,d,e){b(a,d),c(a,d,"=",e,";")},toString:function(){return e()+f()}})}var c=0,e=[],f=[],d=a(),p={};return{global:d,link:function(a){for(var b=0;b<f.length;++b)if(f[b]===a)return e[b];return b="g"+c++,e.push(b),f.push(a),b},block:a,proc:function(a,c){function d(){var a="a"+e.length;return e.push(a),a}var e=[];c=c||0;for(var f=0;f<c;++f)d();var z=(f=b()).toString;return p[a]=F(f,{arg:d,toString:function(){return Aa(["function(",e.join(),"){",z(),"}"])}})},scope:b,cond:function(){var a=Aa(arguments),c=b(),d=b(),e=c.toString,f=d.toString;return F(c,{then:function(){return c.apply(c,za(arguments)),this},else:function(){return d.apply(d,za(arguments)),this},toString:function(){var b=f();return b&&(b="else{"+b+"}"),Aa(["if(",a,"){",e(),"}",b])}})},compile:function(){var a=['"use strict";',d,"return {"];Object.keys(p).forEach((function(b){a.push('"',b,'":',p[b].toString(),",")})),a.push("}");var b=Aa(a).replace(/;/g,";\n").replace(/}/g,"}\n").replace(/{/g,"{\n");return Function.apply(null,e.concat(b)).apply(null,f)}}}function Qa(a){return Array.isArray(a)||K(a)||Z(a)}function xb(a){return a.sort((function(a,c){return"viewport"===a?-1:"viewport"===c?1:a<c?-1:1}))}function I(a,b,c,e){this.thisDep=a,this.contextDep=b,this.propDep=c,this.append=e}function ua(a){return a&&!(a.thisDep||a.contextDep||a.propDep)}function B(a){return new I(!1,!1,!1,a)}function L(a,b){var c=a.type;if(0===c)return new I(!0,1<=(c=a.data.length),2<=c,b);if(4===c)return new I((c=a.data).thisDep,c.contextDep,c.propDep,b);if(5===c)return new I(!1,!1,!1,b);if(6===c){for(var e=c=!1,f=!1,d=0;d<a.data.length;++d){var p=a.data[d];1===p.type?f=!0:2===p.type?e=!0:3===p.type?c=!0:0===p.type?(c=!0,1<=(p=p.data)&&(e=!0),2<=p&&(f=!0)):4===p.type&&(c=c||p.data.thisDep,e=e||p.data.contextDep,f=f||p.data.propDep)}return new I(c,e,f,b)}return new I(3===c,2===c,1===c,b)}function Vb(a,b,c,e,f,d,p,r,v,m,u,n,z,q,h){function g(a){return a.replace(".","_")}function k(a,b,c){var d=g(a);La.push(a),Ca[d]=qa[d]=!!c,ra[d]=b}function l(a,b,c){var d=g(a);La.push(a),Array.isArray(c)?(qa[d]=c.slice(),Ca[d]=c.slice()):qa[d]=Ca[d]=c,sa[d]=b}function A(){var a=Ub(),c=a.link,d=a.global;a.id=pa++,a.batchId="0";var e=c(rb),f=a.shared={props:"a0"};Object.keys(rb).forEach((function(a){f[a]=d.def(e,".",a)}));var g=a.next={},ca=a.current={};Object.keys(sa).forEach((function(a){Array.isArray(qa[a])&&(g[a]=d.def(f.next,".",a),ca[a]=d.def(f.current,".",a))}));var Wb=a.constants={};Object.keys(Na).forEach((function(a){Wb[a]=d.def(JSON.stringify(Na[a]))})),a.invoke=function(b,d){switch(d.type){case 0:var e=["this",f.context,f.props,a.batchId];return b.def(c(d.data),".call(",e.slice(0,Math.max(d.data.length+1,4)),")");case 1:return b.def(f.props,d.data);case 2:return b.def(f.context,d.data);case 3:return b.def("this",d.data);case 4:return d.data.append(a,b),d.data.ref;case 5:return d.data.toString();case 6:return d.data.map((function(c){return a.invoke(b,c)}))}},a.attribCache={};var X={};return a.scopeAttrib=function(a){if((a=b.id(a))in X)return X[a];var d=m.scope[a];return d||(d=m.scope[a]=new ea),X[a]=c(d)},a}function t(a){var c,b=a.static;if(a=a.dynamic,"profile"in b){var d=!!b.profile;(c=B((function(a,b){return d}))).enable=d}else if("profile"in a){var e=a.profile;c=L(e,(function(a,b){return a.invoke(b,e)}))}return c}function D(a,b){var c=a.static,d=a.dynamic;if("framebuffer"in c){var e=c.framebuffer;return e?(e=r.getFramebuffer(e),B((function(a,b){var c=a.link(e),d=a.shared;return b.set(d.framebuffer,".next",c),b.set(d=d.context,".framebufferWidth",c+".width"),b.set(d,".framebufferHeight",c+".height"),c}))):B((function(a,b){var c=a.shared;return b.set(c.framebuffer,".next","null"),b.set(c=c.context,".framebufferWidth",c+".drawingBufferWidth"),b.set(c,".framebufferHeight",c+".drawingBufferHeight"),"null"}))}if("framebuffer"in d){var f=d.framebuffer;return L(f,(function(a,b){var c=a.invoke(b,f),d=a.shared,e=d.framebuffer;return c=b.def(e,".getFramebuffer(",c,")"),b.set(e,".next",c),b.set(d=d.context,".framebufferWidth",c+"?"+c+".width:"+d+".drawingBufferWidth"),b.set(d,".framebufferHeight",c+"?"+c+".height:"+d+".drawingBufferHeight"),c}))}return null}function H(a,b,c){function d(a){if(a in e){var c=e[a];a=!0;var h,ca,w=0|c.x,g=0|c.y;return"width"in c?h=0|c.width:a=!1,"height"in c?ca=0|c.height:a=!1,new I(!a&&b&&b.thisDep,!a&&b&&b.contextDep,!a&&b&&b.propDep,(function(a,b){var d=a.shared.context,e=h;"width"in c||(e=b.def(d,".","framebufferWidth","-",w));var f=ca;return"height"in c||(f=b.def(d,".","framebufferHeight","-",g)),[w,g,e,f]}))}if(a in f){var k=f[a];return a=L(k,(function(a,b){var c=a.invoke(b,k),d=a.shared.context,e=b.def(c,".x|0"),f=b.def(c,".y|0");return[e,f,b.def('"width" in ',c,"?",c,".width|0:","(",d,".","framebufferWidth","-",e,")"),c=b.def('"height" in ',c,"?",c,".height|0:","(",d,".","framebufferHeight","-",f,")")]})),b&&(a.thisDep=a.thisDep||b.thisDep,a.contextDep=a.contextDep||b.contextDep,a.propDep=a.propDep||b.propDep),a}return b?new I(b.thisDep,b.contextDep,b.propDep,(function(a,b){var c=a.shared.context;return[0,0,b.def(c,".","framebufferWidth"),b.def(c,".","framebufferHeight")]})):null}var e=a.static,f=a.dynamic;if(a=d("viewport")){var g=a;a=new I(a.thisDep,a.contextDep,a.propDep,(function(a,b){var c=g.append(a,b),d=a.shared.context;return b.set(d,".viewportWidth",c[2]),b.set(d,".viewportHeight",c[3]),c}))}return{viewport:a,scissor_box:d("scissor.box")}}function K(a,b){if("string"==typeof(c=a.static).frag&&"string"==typeof c.vert){if(0<Object.keys(b.dynamic).length)return null;var c=b.static,d=Object.keys(c);if(0<d.length&&"number"==typeof c[d[0]]){for(var e=[],f=0;f<d.length;++f)e.push([0|c[d[f]],d[f]]);return e}}return null}function C(a,c,d){function e(a){if(a in f){var c=b.id(f[a]);return(a=B((function(){return c}))).id=c,a}if(a in g){var d=g[a];return L(d,(function(a,b){var c=a.invoke(b,d);return b.def(a.shared.strings,".id(",c,")")}))}return null}var f=a.static,g=a.dynamic,h=e("frag"),k=e("vert"),X=null;return ua(h)&&ua(k)?(X=u.program(k.id,h.id,null,d),a=B((function(a,b){return a.link(X)}))):a=new I(h&&h.thisDep||k&&k.thisDep,h&&h.contextDep||k&&k.contextDep,h&&h.propDep||k&&k.propDep,(function(a,b){var d,e,c=a.shared.shader;return d=h?h.append(a,b):b.def(c,".","frag"),e=k?k.append(a,b):b.def(c,".","vert"),b.def(c+".program("+e+","+d+")")})),{frag:h,vert:k,progVar:a,program:X}}function M(a,b){function c(a,b){if(a in e){var d=0|e[a];return b?g.offset=d:g.instances=d,B((function(a,c){return b&&(a.OFFSET=d),d}))}if(a in f){var w=f[a];return L(w,(function(a,c){var d=a.invoke(c,w);return b&&(a.OFFSET=d),d}))}if(b){if(X)return B((function(a,b){return a.OFFSET=0}));if(h)return new I(k.thisDep,k.contextDep,k.propDep,(function(a,b){return b.def(a.shared.vao+".currentVAO?"+a.shared.vao+".currentVAO.offset:0")}))}else if(h)return new I(k.thisDep,k.contextDep,k.propDep,(function(a,b){return b.def(a.shared.vao+".currentVAO?"+a.shared.vao+".currentVAO.instances:-1")}));return null}var e=a.static,f=a.dynamic,g={},h=!1,k=function(){if("vao"in e){var a=e.vao;return null!==a&&null===m.getVAO(a)&&(a=m.createVAO(a)),h=!0,g.vao=a,B((function(b){var c=m.getVAO(a);return c?b.link(c):"null"}))}if("vao"in f){h=!0;var b=f.vao;return L(b,(function(a,c){var d=a.invoke(c,b);return c.def(a.shared.vao+".getVAO("+d+")")}))}return null}(),X=!1,V=function(){if("elements"in e){if(g.elements=a=e.elements,Qa(a)){var b=g.elements=d.create(a,!0),a=d.getElements(b);X=!0}else a&&(a=d.getElements(a),X=!0);return b=B((function(b,c){if(a){var d=b.link(a);return b.ELEMENTS=d}return b.ELEMENTS=null})),b.value=a,b}if("elements"in f){X=!0;var c=f.elements;return L(c,(function(a,b){var e=(d=a.shared).isBufferArgs,d=d.elements,f=a.invoke(b,c),w=b.def("null");return e=b.def(e,"(",f,")"),f=a.cond(e).then(w,"=",d,".createStream(",f,");").else(w,"=",d,".getElements(",f,");"),b.entry(f),b.exit(a.cond(e).then(d,".destroyStream(",w,");")),a.ELEMENTS=w}))}return h?new I(k.thisDep,k.contextDep,k.propDep,(function(a,b){return b.def(a.shared.vao+".currentVAO?"+a.shared.elements+".getElements("+a.shared.vao+".currentVAO.elements):null")})):null}(),va=c("offset",!0),n=function(){if("primitive"in e){var a=e.primitive;return g.primitive=a,B((function(b,c){return Ia[a]}))}if("primitive"in f){var b=f.primitive;return L(b,(function(a,c){var d=a.constants.primTypes,e=a.invoke(c,b);return c.def(d,"[",e,"]")}))}return X?ua(V)?B(V.value?function(a,b){return b.def(a.ELEMENTS,".primType")}:function(){return 4}):new I(V.thisDep,V.contextDep,V.propDep,(function(a,b){var c=a.ELEMENTS;return b.def(c,"?",c,".primType:",4)})):h?new I(k.thisDep,k.contextDep,k.propDep,(function(a,b){return b.def(a.shared.vao+".currentVAO?"+a.shared.vao+".currentVAO.primitive:4")})):null}(),q=function(){if("count"in e){var a=0|e.count;return g.count=a,B((function(){return a}))}if("count"in f){var b=f.count;return L(b,(function(a,c){return a.invoke(c,b)}))}return X?ua(V)?V?va?new I(va.thisDep,va.contextDep,va.propDep,(function(a,b){return b.def(a.ELEMENTS,".vertCount-",a.OFFSET)})):B((function(a,b){return b.def(a.ELEMENTS,".vertCount")})):B((function(){return-1})):new I(V.thisDep||va.thisDep,V.contextDep||va.contextDep,V.propDep||va.propDep,(function(a,b){var c=a.ELEMENTS;return a.OFFSET?b.def(c,"?",c,".vertCount-",a.OFFSET,":-1"):b.def(c,"?",c,".vertCount:-1")})):h?new I(k.thisDep,k.contextDep,k.propDep,(function(a,b){return b.def(a.shared.vao,".currentVAO?",a.shared.vao,".currentVAO.count:-1")})):null}(),l=c("instances",!1);return{elements:V,primitive:n,count:q,instances:l,offset:va,vao:k,vaoActive:h,elementsActive:X,static:g}}function E(a,b){var c=a.static,d=a.dynamic,e={};return La.forEach((function(a){function b(w,g){if(a in c){var O=w(c[a]);e[f]=B((function(){return O}))}else if(a in d){var h=d[a];e[f]=L(h,(function(a,b){return g(a,b,a.invoke(b,h))}))}}var f=g(a);switch(a){case"cull.enable":case"blend.enable":case"dither":case"stencil.enable":case"depth.enable":case"scissor.enable":case"polygonOffset.enable":case"sample.alpha":case"sample.enable":case"depth.mask":case"lineWidth":return b((function(a){return a}),(function(a,b,c){return c}));case"depth.func":return b((function(a){return Za[a]}),(function(a,b,c){return b.def(a.constants.compareFuncs,"[",c,"]")}));case"depth.range":return b((function(a){return a}),(function(a,b,c){return[b.def("+",c,"[0]"),b=b.def("+",c,"[1]")]}));case"blend.func":return b((function(a){return[Ea["srcRGB"in a?a.srcRGB:a.src],Ea["dstRGB"in a?a.dstRGB:a.dst],Ea["srcAlpha"in a?a.srcAlpha:a.src],Ea["dstAlpha"in a?a.dstAlpha:a.dst]]}),(function(a,b,c){function d(a,e){return b.def('"',a,e,'" in ',c,"?",c,".",a,e,":",c,".",a)}a=a.constants.blendFuncs;var e=d("src","RGB"),f=d("dst","RGB"),w=(e=b.def(a,"[",e,"]"),b.def(a,"[",d("src","Alpha"),"]"));return[e,f=b.def(a,"[",f,"]"),w,a=b.def(a,"[",d("dst","Alpha"),"]")]}));case"blend.equation":return b((function(a){return"string"==typeof a?[fa[a],fa[a]]:"object"==typeof a?[fa[a.rgb],fa[a.alpha]]:void 0}),(function(a,b,c){var d=a.constants.blendEquations,e=b.def(),f=b.def();return(a=a.cond("typeof ",c,'==="string"')).then(e,"=",f,"=",d,"[",c,"];"),a.else(e,"=",d,"[",c,".rgb];",f,"=",d,"[",c,".alpha];"),b(a),[e,f]}));case"blend.color":return b((function(a){return J(4,(function(b){return+a[b]}))}),(function(a,b,c){return J(4,(function(a){return b.def("+",c,"[",a,"]")}))}));case"stencil.mask":return b((function(a){return 0|a}),(function(a,b,c){return b.def(c,"|0")}));case"stencil.func":return b((function(a){return[Za[a.cmp||"keep"],a.ref||0,"mask"in a?a.mask:-1]}),(function(a,b,c){return[a=b.def('"cmp" in ',c,"?",a.constants.compareFuncs,"[",c,".cmp]",":",7680),b.def(c,".ref|0"),b=b.def('"mask" in ',c,"?",c,".mask|0:-1")]}));case"stencil.opFront":case"stencil.opBack":return b((function(b){return["stencil.opBack"===a?1029:1028,Ra[b.fail||"keep"],Ra[b.zfail||"keep"],Ra[b.zpass||"keep"]]}),(function(b,c,d){function e(a){return c.def('"',a,'" in ',d,"?",f,"[",d,".",a,"]:",7680)}var f=b.constants.stencilOps;return["stencil.opBack"===a?1029:1028,e("fail"),e("zfail"),e("zpass")]}));case"polygonOffset.offset":return b((function(a){return[0|a.factor,0|a.units]}),(function(a,b,c){return[b.def(c,".factor|0"),b=b.def(c,".units|0")]}));case"cull.face":return b((function(a){var b=0;return"front"===a?b=1028:"back"===a&&(b=1029),b}),(function(a,b,c){return b.def(c,'==="front"?',1028,":",1029)}));case"frontFace":return b((function(a){return yb[a]}),(function(a,b,c){return b.def(c+'==="cw"?2304:2305')}));case"colorMask":return b((function(a){return a.map((function(a){return!!a}))}),(function(a,b,c){return J(4,(function(a){return"!!"+c+"["+a+"]"}))}));case"sample.coverage":return b((function(a){return["value"in a?a.value:1,!!a.invert]}),(function(a,b,c){return[b.def('"value" in ',c,"?+",c,".value:1"),b=b.def("!!",c,".invert")]}))}})),e}function aa(a,b){var c=a.static,d=a.dynamic,e={};return Object.keys(c).forEach((function(a){var d,b=c[a];if("number"==typeof b||"boolean"==typeof b)d=B((function(){return b}));else if("function"==typeof b){var f=b._reglType;"texture2d"===f||"textureCube"===f?d=B((function(a){return a.link(b)})):"framebuffer"!==f&&"framebufferCube"!==f||(d=B((function(a){return a.link(b.color[0])})))}else na(b)&&(d=B((function(a){return a.global.def("[",J(b.length,(function(a){return b[a]})),"]")})));d.value=b,e[a]=d})),Object.keys(d).forEach((function(a){var b=d[a];e[a]=L(b,(function(a,c){return a.invoke(c,b)}))})),e}function ta(a,c){var d=a.static,e=a.dynamic,g={};return Object.keys(d).forEach((function(a){var c=d[a],e=b.id(a),w=new ea;if(Qa(c))w.state=1,w.buffer=f.getBuffer(f.create(c,34962,!1,!0)),w.type=0;else if(h=f.getBuffer(c))w.state=1,w.buffer=h,w.type=0;else if("constant"in c){var O=c.constant;w.buffer="null",w.state=2,"number"==typeof O?w.x=O:Ba.forEach((function(a,b){b<O.length&&(w[a]=O[b])}))}else{var h=Qa(c.buffer)?f.getBuffer(f.create(c.buffer,34962,!1,!0)):f.getBuffer(c.buffer),k=0|c.offset,n=0|c.stride,q=0|c.size,l=!!c.normalized,m=0;"type"in c&&(m=Ha[c.type]),c=0|c.divisor,w.buffer=h,w.state=1,w.size=q,w.normalized=l,w.type=m||h.dtype,w.offset=k,w.stride=n,w.divisor=c}g[a]=B((function(a,b){var c=a.attribCache;if(e in c)return c[e];var d={isStream:!1};return Object.keys(w).forEach((function(a){d[a]=w[a]})),w.buffer&&(d.buffer=a.link(w.buffer),d.type=d.type||d.buffer+".dtype"),c[e]=d}))})),Object.keys(e).forEach((function(a){var b=e[a];g[a]=L(b,(function(a,c){function d(a){c(h[a],"=",e,".",a,"|0;")}var e=a.invoke(c,b),w=a.constants,g=(f=a.shared).isBufferArgs,f=f.buffer,h={isStream:c.def(!1)},O=new ea;O.state=1,Object.keys(O).forEach((function(a){h[a]=c.def(""+O[a])}));var k=h.buffer,da=h.type;return c("if(",g,"(",e,")){",h.isStream,"=true;",k,"=",f,".createStream(",34962,",",e,");",da,"=",k,".dtype;","}else{",k,"=",f,".getBuffer(",e,");","if(",k,"){",da,"=",k,".dtype;",'}else if("constant" in ',e,"){",h.state,"=",2,";","if(typeof "+e+'.constant === "number"){',h[Ba[0]],"=",e,".constant;",Ba.slice(1).map((function(a){return h[a]})).join("="),"=0;","}else{",Ba.map((function(a,b){return h[a]+"="+e+".constant.length>"+b+"?"+e+".constant["+b+"]:0;"})).join(""),"}}else{","if(",g,"(",e,".buffer)){",k,"=",f,".createStream(",34962,",",e,".buffer);","}else{",k,"=",f,".getBuffer(",e,".buffer);","}",da,'="type" in ',e,"?",w.glTypes,"[",e,".type]:",k,".dtype;",h.normalized,"=!!",e,".normalized;"),d("size"),d("offset"),d("stride"),d("divisor"),c("}}"),c.exit("if(",h.isStream,"){",f,".destroyStream(",k,");","}"),h}))})),g}function y(a){var b=a.static,c=a.dynamic,d={};return Object.keys(b).forEach((function(a){var c=b[a];d[a]=B((function(a,b){return"number"==typeof c||"boolean"==typeof c?""+c:a.link(c)}))})),Object.keys(c).forEach((function(a){var b=c[a];d[a]=L(b,(function(a,c){return a.invoke(c,b)}))})),d}function S(a,b,d,e,f){function h(a){var b=q[a];b&&(l[a]=b)}var k=K(a,b),q=H(a,n=D(a)),V=M(a),l=E(a),p=C(a,f,k);h("viewport"),h(g("scissor.box"));var n,r=0<Object.keys(l).length;if((n={framebuffer:n,draw:V,shader:p,state:l,dirty:r,scopeVAO:null,drawVAO:null,useVAO:!1,attributes:{}}).profile=t(a),n.uniforms=aa(d),n.drawVAO=n.scopeVAO=V.vao,!n.drawVAO&&p.program&&!k&&c.angle_instanced_arrays&&V.static.elements){var u=!0;if(a=p.program.attributes.map((function(a){return a=b.static[a],u=u&&!!a,a})),u&&0<a.length){var x=m.getVAO(m.createVAO({attributes:a,elements:V.static.elements}));n.drawVAO=new I(null,null,null,(function(a,b){return a.link(x)})),n.useVAO=!0}}return k?n.useVAO=!0:n.attributes=ta(b),n.context=y(e),n}function ha(a,b,c){var d=a.shared.context,e=a.scope();Object.keys(c).forEach((function(f){b.save(d,"."+f);var g=c[f].append(a,b);Array.isArray(g)?e(d,".",f,"=[",g.join(),"];"):e(d,".",f,"=",g,";")})),b(e)}function Q(a,b,c,d){var h,f=(e=a.shared).gl,g=e.framebuffer;Ka&&(h=b.def(e.extensions,".webgl_draw_buffers"));var e=(k=a.constants).drawBuffer,k=k.backBuffer;a=c?c.append(a,b):b.def(g,".next"),d||b("if(",a,"!==",g,".cur){"),b("if(",a,"){",f,".bindFramebuffer(",36160,",",a,".framebuffer);"),Ka&&b(h,".drawBuffersWEBGL(",e,"[",a,".colorAttachments.length]);"),b("}else{",f,".bindFramebuffer(",36160,",null);"),Ka&&b(h,".drawBuffersWEBGL(",k,");"),b("}",g,".cur=",a,";"),d||b("}")}function ya(a,b,c){var d=a.shared,e=d.gl,f=a.current,h=a.next,k=d.current,n=d.next,q=a.cond(k,".dirty");La.forEach((function(b){var d,O;if(!((b=g(b))in c.state))if(b in h){d=h[b],O=f[b];var l=J(qa[b].length,(function(a){return q.def(d,"[",a,"]")}));q(a.cond(l.map((function(a,b){return a+"!=="+O+"["+b+"]"})).join("||")).then(e,".",sa[b],"(",l,");",l.map((function(a,b){return O+"["+b+"]="+a})).join(";"),";"))}else d=q.def(n,".",b),l=a.cond(d,"!==",k,".",b),q(l),b in ra?l(a.cond(d).then(e,".enable(",ra[b],");").else(e,".disable(",ra[b],");"),k,".",b,"=",d,";"):l(e,".",sa[b],"(",d,");",k,".",b,"=",d,";")})),0===Object.keys(c.state).length&&q(k,".dirty=false;"),b(q)}function P(a,b,c,d){var e=a.shared,f=a.current,g=e.current,h=e.gl;xb(Object.keys(c)).forEach((function(e){var k=c[e];if(!d||d(k)){var n=k.append(a,b);if(ra[e]){var l=ra[e];ua(k)?b(h,n?".enable(":".disable(",l,");"):b(a.cond(n).then(h,".enable(",l,");").else(h,".disable(",l,");")),b(g,".",e,"=",n,";")}else if(na(n)){var q=f[e];b(h,".",sa[e],"(",n,");",n.map((function(a,b){return q+"["+b+"]="+a})).join(";"),";")}else b(h,".",sa[e],"(",n,");",g,".",e,"=",n,";")}}))}function N(a,b){T&&(a.instancing=b.def(a.shared.extensions,".angle_instanced_arrays"))}function G(a,b,c,d,e){function f(){return"undefined"==typeof performance?"Date.now()":"performance.now()"}function g(a){a(r=b.def(),"=",f(),";"),"string"==typeof e?a(l,".count+=",e,";"):a(l,".count++;"),q&&(d?a(t=b.def(),"=",p,".getNumPendingQueries();"):a(p,".beginQuery(",l,");"))}function h(a){a(l,".cpuTime+=",f(),"-",r,";"),q&&(d?a(p,".pushScopeStats(",t,",",p,".getNumPendingQueries(),",l,");"):a(p,".endQuery();"))}function k(a){var c=b.def(m,".profile");b(m,".profile=",a,";"),b.exit(m,".profile=",c,";")}var r,t,n=a.shared,l=a.stats,m=n.current,p=n.timer;if(c=c.profile){if(ua(c))return void(c.enable?(g(b),h(b.exit),k("true")):k("false"));k(c=c.append(a,b))}else c=b.def(m,".profile");g(n=a.block()),b("if(",c,"){",n,"}"),h(a=a.block()),b.exit("if(",c,"){",a,"}")}function ga(a,b,c,d,e){function f(a){switch(a){case 35664:case 35667:case 35671:return 2;case 35665:case 35668:case 35672:return 3;case 35666:case 35669:case 35673:return 4;default:return 1}}function g(c,d,e){function f(){b(n,".enableVertexAttribArray(",l,");");var g,c=e.type;g=e.size?b.def(e.size,"||",d):d,b(n,".bindBuffer(",34962,",",m,".buffer);",n,".vertexAttribPointer(",[l,g,c,e.normalized,e.stride,e.offset],");",q,".type=",c,";",q,".size=",g,";",da.map((function(a){return q+"."+a+"="+e[a]+";"})).join("")),T&&b("if(",q,".divisor!==",c=e.divisor,"){",a.instancing,".vertexAttribDivisorANGLE(",[l,c],");",q,".divisor=",c,";}")}function k(){b("if(",q,".buffer){",n,".disableVertexAttribArray(",l,");",q,".buffer=null;","}if(",Ba.map((function(a,b){return q+"."+a+"!=="+p[b]})).join("||"),"){",n,".vertexAttrib4f(",l,",",p,");",Ba.map((function(a,b){return q+"."+a+"="+p[b]+";"})).join(""),"}")}var n=h.gl,l=b.def(c,".location"),q=b.def(h.attributes,"[",l,"]"),m=e.buffer,p=[e.x,e.y,e.z,e.w],da=["buffer","normalized","offset","stride"];1===(c=e.state)?f():2===c?k():(b("if(",c,"===",1,"){"),f(),b("}else{"),k(),b("}"))}var h=a.shared;d.forEach((function(d){var n,h=d.name,k=c.attributes[h];if(k){if(!e(k))return;n=k.append(a,b)}else{if(!e(zb))return;var l=a.scopeAttrib(h);n={},Object.keys(new ea).forEach((function(a){n[a]=b.def(l,".",a)}))}g(a.link(d),f(d.info.type),n)}))}function R(a,c,d,e,f,g){for(var l,h=a.shared,k=h.gl,n={},q=0;q<e.length;++q){var m=(p=e[q]).name,r=p.info.type,u=d.uniforms[m];if(1<(t=p.info.size)){if(!u)continue;var x=m.replace("[0]","");if(n[x])continue;n[x]=1}var v,p=a.link(p)+".location";if(u){if(!f(u))continue;if(ua(u)){if(m=u.value,35678===r||35680===r)c(k,".uniform1i(",p,",",(r=a.link(m._texture||m.color[0]._texture))+".bind());"),c.exit(r,".unbind();");else if(35674===r||35675===r||35676===r)t=a.global.def("new Float32Array(["+Array.prototype.slice.call(m)+"])"),m=2,35675===r?m=3:35676===r&&(m=4),c(k,".uniformMatrix",m,"fv(",p,",false,",t,");");else{switch(r){case 5126:l="1f";break;case 35664:l="2f";break;case 35665:l="3f";break;case 35666:l="4f";break;case 35670:case 5124:l="1i";break;case 35671:case 35667:l="2i";break;case 35672:case 35668:l="3i";break;case 35673:case 35669:l="4i"}1<t?(l+="v",m=a.global.def("["+Array.prototype.slice.call(m)+"]")):m=na(m)?Array.prototype.slice.call(m):m,c(k,".uniform",l,"(",p,",",m,");")}continue}v=u.append(a,c)}else{if(!f(zb))continue;v=c.def(h.uniforms,"[",b.id(m),"]")}switch(35678===r?c("if(",v,"&&",v,'._reglType==="framebuffer"){',v,"=",v,".color[0];","}"):35680===r&&c("if(",v,"&&",v,'._reglType==="framebufferCube"){',v,"=",v,".color[0];","}"),m=1,r){case 35678:case 35680:r=c.def(v,"._texture"),c(k,".uniform1i(",p,",",r,".bind());"),c.exit(r,".unbind();");continue;case 5124:case 35670:l="1i";break;case 35667:case 35671:l="2i",m=2;break;case 35668:case 35672:l="3i",m=3;break;case 35669:case 35673:l="4i",m=4;break;case 5126:l="1f";break;case 35664:l="2f",m=2;break;case 35665:l="3f",m=3;break;case 35666:l="4f",m=4;break;case 35674:l="Matrix2fv";break;case 35675:l="Matrix3fv";break;case 35676:l="Matrix4fv"}if(-1===l.indexOf("Matrix")&&1<t&&(l+="v",m=1),"M"===l.charAt(0)){c(k,".uniform",l,"(",p,","),p=Math.pow(r-35674+2,2);var z=a.global.def("new Float32Array(",p,")");Array.isArray(v)?c("false,(",J(p,(function(a){return z+"["+a+"]="+v[a]})),",",z,")"):c("false,(Array.isArray(",v,")||",v," instanceof Float32Array)?",v,":(",J(p,(function(a){return z+"["+a+"]="+v+"["+a+"]"})),",",z,")"),c(");")}else{if(1<m){r=[];for(var A=[],t=0;t<m;++t)Array.isArray(v)?A.push(v[t]):A.push(c.def(v+"["+t+"]")),g&&r.push(c.def());g&&c("if(!",a.batchId,"||",r.map((function(a,b){return a+"!=="+A[b]})).join("||"),"){",r.map((function(a,b){return a+"="+A[b]+";"})).join("")),c(k,".uniform",l,"(",p,",",A.join(","),");")}else g&&(r=c.def(),c("if(!",a.batchId,"||",r,"!==",v,"){",r,"=",v,";")),c(k,".uniform",l,"(",p,",",v,");");g&&c("}")}}}function U(a,b,c,d){function e(f){var g=n[f];return g?g.append(a,g.contextDep&&d.contextDynamic||g.propDep?c:b):b.def(l,".",f)}function f(){function a(){c(u,".drawElementsInstancedANGLE(",[q,r,v,p+"<<(("+v+"-5121)>>1)",t],");")}function b(){c(u,".drawArraysInstancedANGLE(",[q,p,r,t],");")}m&&"null"!==m?x?a():(c("if(",m,"){"),a(),c("}else{"),b(),c("}")):b()}function g(){function a(){c(k+".drawElements("+[q,r,v,p+"<<(("+v+"-5121)>>1)"]+");")}function b(){c(k+".drawArrays("+[q,p,r]+");")}m&&"null"!==m?x?a():(c("if(",m,"){"),a(),c("}else{"),b(),c("}")):b()}var t,u,h=a.shared,k=h.gl,l=h.draw,n=d.draw,m=function(){var e=n.elements,f=b;return e?((e.contextDep&&d.contextDynamic||e.propDep)&&(f=c),e=e.append(a,f),n.elementsActive&&f("if("+e+")"+k+".bindBuffer(34963,"+e+".buffer.buffer);")):(e=f.def(),f(e,"=",l,".","elements",";","if(",e,"){",k,".bindBuffer(",34963,",",e,".buffer.buffer);}","else if(",h.vao,".currentVAO){",e,"=",a.shared.elements+".getElements("+h.vao,".currentVAO.elements);",oa?"":"if("+e+")"+k+".bindBuffer(34963,"+e+".buffer.buffer);","}")),e}(),q=e("primitive"),p=e("offset"),r=function(){var e=n.count,f=b;return e?((e.contextDep&&d.contextDynamic||e.propDep)&&(f=c),e=e.append(a,f)):e=f.def(l,".","count"),e}();if("number"==typeof r){if(0===r)return}else c("if(",r,"){"),c.exit("}");T&&(t=e("instances"),u=a.instancing);var v=m+".type",x=n.elements&&ua(n.elements)&&!n.vaoActive;T&&("number"!=typeof t||0<=t)?"string"==typeof t?(c("if(",t,">0){"),f(),c("}else if(",t,"<0){"),g(),c("}")):f():g()}function ba(a,b,c,d,e){return e=(b=A()).proc("body",e),T&&(b.instancing=e.def(b.shared.extensions,".angle_instanced_arrays")),a(b,e,c,d),b.compile().body}function W(a,b,c,d){N(a,b),c.useVAO?c.drawVAO?b(a.shared.vao,".setVAO(",c.drawVAO.append(a,b),");"):b(a.shared.vao,".setVAO(",a.shared.vao,".targetVAO);"):(b(a.shared.vao,".setVAO(null);"),ga(a,b,c,d.attributes,(function(){return!0}))),R(a,b,c,d.uniforms,(function(){return!0}),!1),U(a,b,b,c)}function Da(a,b){var c=a.proc("draw",1);N(a,c),ha(a,c,b.context),Q(a,c,b.framebuffer),ya(a,c,b),P(a,c,b.state),G(a,c,b,!1,!0);var d=b.shader.progVar.append(a,c);if(c(a.shared.gl,".useProgram(",d,".program);"),b.shader.program)W(a,c,b,b.shader.program);else{c(a.shared.vao,".setVAO(null);");var e=a.global.def("{}"),f=c.def(d,".id"),g=c.def(e,"[",f,"]");c(a.cond(g).then(g,".call(this,a0);").else(g,"=",e,"[",f,"]=",a.link((function(c){return ba(W,a,b,c,1)})),"(",d,");",g,".call(this,a0);"))}0<Object.keys(b.state).length&&c(a.shared.current,".dirty=true;"),a.shared.vao&&c(a.shared.vao,".setVAO(null);")}function la(a,b,c,d){function e(){return!0}a.batchId="a1",N(a,b),ga(a,b,c,d.attributes,e),R(a,b,c,d.uniforms,e,!1),U(a,b,b,c)}function ma(a,b,c,d){function e(a){return a.contextDep&&g||a.propDep}function f(a){return!e(a)}N(a,b);var g=c.contextDep,h=b.def(),k=b.def();a.shared.props=k,a.batchId=h;var n=a.scope(),l=a.scope();b(n.entry,"for(",h,"=0;",h,"<","a1",";++",h,"){",k,"=","a0","[",h,"];",l,"}",n.exit),c.needsContext&&ha(a,l,c.context),c.needsFramebuffer&&Q(a,l,c.framebuffer),P(a,l,c.state,e),c.profile&&e(c.profile)&&G(a,l,c,!1,!0),d?(c.useVAO?c.drawVAO?e(c.drawVAO)?l(a.shared.vao,".setVAO(",c.drawVAO.append(a,l),");"):n(a.shared.vao,".setVAO(",c.drawVAO.append(a,n),");"):n(a.shared.vao,".setVAO(",a.shared.vao,".targetVAO);"):(n(a.shared.vao,".setVAO(null);"),ga(a,n,c,d.attributes,f),ga(a,l,c,d.attributes,e)),R(a,n,c,d.uniforms,f,!1),R(a,l,c,d.uniforms,e,!0),U(a,n,l,c)):(b=a.global.def("{}"),d=c.shader.progVar.append(a,l),k=l.def(d,".id"),n=l.def(b,"[",k,"]"),l(a.shared.gl,".useProgram(",d,".program);","if(!",n,"){",n,"=",b,"[",k,"]=",a.link((function(b){return ba(la,a,c,b,2)})),"(",d,");}",n,".call(this,a0[",h,"],",h,");"))}function x(a,b){function c(a){return a.contextDep&&e||a.propDep}var d=a.proc("batch",2);a.batchId="0",N(a,d);var e=!1,f=!0;Object.keys(b.context).forEach((function(a){e=e||b.context[a].propDep})),e||(ha(a,d,b.context),f=!1);var h=!1;if((g=b.framebuffer)?(g.propDep?e=h=!0:g.contextDep&&e&&(h=!0),h||Q(a,d,g)):Q(a,d,null),b.state.viewport&&b.state.viewport.propDep&&(e=!0),ya(a,d,b),P(a,d,b.state,(function(a){return!c(a)})),b.profile&&c(b.profile)||G(a,d,b,!1,"a1"),b.contextDep=e,b.needsContext=f,b.needsFramebuffer=h,(f=b.shader.progVar).contextDep&&e||f.propDep)ma(a,d,b,null);else if(f=f.append(a,d),d(a.shared.gl,".useProgram(",f,".program);"),b.shader.program)ma(a,d,b,b.shader.program);else{d(a.shared.vao,".setVAO(null);");var g=a.global.def("{}"),k=(h=d.def(f,".id"),d.def(g,"[",h,"]"));d(a.cond(k).then(k,".call(this,a0,a1);").else(k,"=",g,"[",h,"]=",a.link((function(c){return ba(ma,a,b,c,2)})),"(",f,");",k,".call(this,a0,a1);"))}0<Object.keys(b.state).length&&d(a.shared.current,".dirty=true;"),a.shared.vao&&d(a.shared.vao,".setVAO(null);")}function Z(a,c){function d(b){var g=c.shader[b];g&&e.set(f.shader,"."+b,g.append(a,e))}var e=a.proc("scope",3);a.batchId="a2";var f=a.shared,g=f.current;ha(a,e,c.context),c.framebuffer&&c.framebuffer.append(a,e),xb(Object.keys(c.state)).forEach((function(b){var d=c.state[b].append(a,e);na(d)?d.forEach((function(c,d){e.set(a.next[b],"["+d+"]",c)})):e.set(f.next,"."+b,d)})),G(a,e,c,!0,!0),["elements","offset","count","instances","primitive"].forEach((function(b){var d=c.draw[b];d&&e.set(f.draw,"."+b,""+d.append(a,e))})),Object.keys(c.uniforms).forEach((function(d){var g=c.uniforms[d].append(a,e);Array.isArray(g)&&(g="["+g.join()+"]"),e.set(f.uniforms,"["+b.id(d)+"]",g)})),Object.keys(c.attributes).forEach((function(b){var d=c.attributes[b].append(a,e),f=a.scopeAttrib(b);Object.keys(new ea).forEach((function(a){e.set(f,"."+a,d[a])}))})),c.scopeVAO&&e.set(f.vao,".targetVAO",c.scopeVAO.append(a,e)),d("vert"),d("frag"),0<Object.keys(c.state).length&&(e(g,".dirty=true;"),e.exit(g,".dirty=true;")),e("a1(",a.shared.context,",a0,",a.batchId,");")}function ja(a){if("object"==typeof a&&!na(a)){for(var b=Object.keys(a),c=0;c<b.length;++c)if(Y.isDynamic(a[b[c]]))return!0;return!1}}function ia(a,b,c){function d(a,b){g.forEach((function(c){var d=e[c];Y.isDynamic(d)&&(d=a.invoke(b,d),b(l,".",c,"=",d,";"))}))}var e=b.static[c];if(e&&ja(e)){var f=a.global,g=Object.keys(e),h=!1,k=!1,n=!1,l=a.global.def("{}");g.forEach((function(b){var c=e[b];if(Y.isDynamic(c))"function"==typeof c&&(c=e[b]=Y.unbox(c)),b=L(c,null),h=h||b.thisDep,n=n||b.propDep,k=k||b.contextDep;else{switch(f(l,".",b,"="),typeof c){case"number":f(c);break;case"string":f('"',c,'"');break;case"object":Array.isArray(c)&&f("[",c.join(),"]");break;default:f(a.link(c))}f(";")}})),b.dynamic[c]=new Y.DynamicVariable(4,{thisDep:h,contextDep:k,propDep:n,ref:l,append:d}),delete b.static[c]}}var ea=m.Record,fa={add:32774,subtract:32778,"reverse subtract":32779};c.ext_blend_minmax&&(fa.min=32775,fa.max=32776);var T=c.angle_instanced_arrays,Ka=c.webgl_draw_buffers,oa=c.oes_vertex_array_object,qa={dirty:!0,profile:h.profile},Ca={},La=[],ra={},sa={};k("dither",3024),k("blend.enable",3042),l("blend.color","blendColor",[0,0,0,0]),l("blend.equation","blendEquationSeparate",[32774,32774]),l("blend.func","blendFuncSeparate",[1,0,1,0]),k("depth.enable",2929,!0),l("depth.func","depthFunc",513),l("depth.range","depthRange",[0,1]),l("depth.mask","depthMask",!0),l("colorMask","colorMask",[!0,!0,!0,!0]),k("cull.enable",2884),l("cull.face","cullFace",1029),l("frontFace","frontFace",2305),l("lineWidth","lineWidth",1),k("polygonOffset.enable",32823),l("polygonOffset.offset","polygonOffset",[0,0]),k("sample.alpha",32926),k("sample.enable",32928),l("sample.coverage","sampleCoverage",[1,!1]),k("stencil.enable",2960),l("stencil.mask","stencilMask",-1),l("stencil.func","stencilFunc",[519,0,-1]),l("stencil.opFront","stencilOpSeparate",[1028,7680,7680,7680]),l("stencil.opBack","stencilOpSeparate",[1029,7680,7680,7680]),k("scissor.enable",3089),l("scissor.box","scissor",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]),l("viewport","viewport",[0,0,a.drawingBufferWidth,a.drawingBufferHeight]);var rb={gl:a,context:z,strings:b,next:Ca,current:qa,draw:n,elements:d,buffer:f,shader:u,attributes:m.state,vao:m,uniforms:v,framebuffer:r,extensions:c,timer:q,isBufferArgs:Qa},Na={primTypes:Ia,compareFuncs:Za,blendFuncs:Ea,blendEquations:fa,stencilOps:Ra,glTypes:Ha,orientationType:yb};Ka&&(Na.backBuffer=[1029],Na.drawBuffer=J(e.maxDrawbuffers,(function(a){return 0===a?[0]:J(a,(function(a){return 36064+a}))})));var pa=0;return{next:Ca,current:qa,procs:function(){var a=A(),b=a.proc("poll"),d=a.proc("refresh"),f=a.block();b(f),d(f);var l,g=a.shared,h=g.gl,k=g.next,n=g.current;f(n,".dirty=false;"),Q(a,b),Q(a,d,null,!0),T&&(l=a.link(T)),c.oes_vertex_array_object&&d(a.link(c.oes_vertex_array_object),".bindVertexArrayOES(null);");for(var m=0;m<e.maxAttributes;++m){var q=d.def(g.attributes,"[",m,"]"),p=a.cond(q,".buffer");p.then(h,".enableVertexAttribArray(",m,");",h,".bindBuffer(",34962,",",q,".buffer.buffer);",h,".vertexAttribPointer(",m,",",q,".size,",q,".type,",q,".normalized,",q,".stride,",q,".offset);").else(h,".disableVertexAttribArray(",m,");",h,".vertexAttrib4f(",m,",",q,".x,",q,".y,",q,".z,",q,".w);",q,".buffer=null;"),d(p),T&&d(l,".vertexAttribDivisorANGLE(",m,",",q,".divisor);")}return d(a.shared.vao,".currentVAO=null;",a.shared.vao,".setVAO(",a.shared.vao,".targetVAO);"),Object.keys(ra).forEach((function(c){var e=ra[c],g=f.def(k,".",c),l=a.block();l("if(",g,"){",h,".enable(",e,")}else{",h,".disable(",e,")}",n,".",c,"=",g,";"),d(l),b("if(",g,"!==",n,".",c,"){",l,"}")})),Object.keys(sa).forEach((function(c){var l,m,e=sa[c],g=qa[c],q=a.block();q(h,".",e,"("),na(g)?(e=g.length,l=a.global.def(k,".",c),m=a.global.def(n,".",c),q(J(e,(function(a){return l+"["+a+"]"})),");",J(e,(function(a){return m+"["+a+"]="+l+"["+a+"];"})).join("")),b("if(",J(e,(function(a){return l+"["+a+"]!=="+m+"["+a+"]"})).join("||"),"){",q,"}")):(l=f.def(k,".",c),m=f.def(n,".",c),q(l,");",n,".",c,"=",l,";"),b("if(",l,"!==",m,"){",q,"}")),d(q)})),a.compile()}(),compile:function(a,b,c,d,e){var f=A();f.stats=f.link(e),Object.keys(b.static).forEach((function(a){ia(f,b,a)})),Xb.forEach((function(b){ia(f,a,b)}));var g=S(a,b,c,d,f);return Da(f,g),Z(f,g),x(f,g),F(f.compile(),{destroy:function(){g.shader.program.destroy()}})}}}function Ab(a,b){for(var c=0;c<a.length;++c)if(a[c]===b)return c;return-1}var F=function(a,b){for(var c=Object.keys(b),e=0;e<c.length;++e)a[c[e]]=b[c[e]];return a},Cb=0,Y={DynamicVariable:U,define:function(a,b){return new U(a,ab(b+""))},isDynamic:function(a){return"function"==typeof a&&!a._reglType||a instanceof U},unbox:bb,accessor:ab},$a={next:"function"==typeof requestAnimationFrame?function(a){return requestAnimationFrame(a)}:function(a){return setTimeout(a,16)},cancel:"function"==typeof cancelAnimationFrame?function(a){return cancelAnimationFrame(a)}:clearTimeout},Bb="undefined"!=typeof performance&&performance.now?function(){return performance.now()}:function(){return+new Date},D=fb();D.zero=fb();var Yb=function(a,b){var c=1;b.ext_texture_filter_anisotropic&&(c=a.getParameter(34047));var e=1,f=1;b.webgl_draw_buffers&&(e=a.getParameter(34852),f=a.getParameter(36063));var d=!!b.oes_texture_float;if(d){d=a.createTexture(),a.bindTexture(3553,d),a.texImage2D(3553,0,6408,1,1,0,6408,5126,null);var p=a.createFramebuffer();if(a.bindFramebuffer(36160,p),a.framebufferTexture2D(36160,36064,3553,d,0),a.bindTexture(3553,null),36053!==a.checkFramebufferStatus(36160))d=!1;else{a.viewport(0,0,1,1),a.clearColor(1,0,0,1),a.clear(16384);var r=D.allocType(5126,4);a.readPixels(0,0,1,1,6408,5126,r),a.getError()?d=!1:(a.deleteFramebuffer(p),a.deleteTexture(d),d=1===r[0]),D.freeType(r)}}return r=!0,"undefined"!=typeof navigator&&(/MSIE/.test(navigator.userAgent)||/Trident\//.test(navigator.appVersion)||/Edge/.test(navigator.userAgent))||(r=a.createTexture(),p=D.allocType(5121,36),a.activeTexture(33984),a.bindTexture(34067,r),a.texImage2D(34069,0,6408,3,3,0,6408,5121,p),D.freeType(p),a.bindTexture(34067,null),a.deleteTexture(r),r=!a.getError()),{colorBits:[a.getParameter(3410),a.getParameter(3411),a.getParameter(3412),a.getParameter(3413)],depthBits:a.getParameter(3414),stencilBits:a.getParameter(3415),subpixelBits:a.getParameter(3408),extensions:Object.keys(b).filter((function(a){return!!b[a]})),maxAnisotropic:c,maxDrawbuffers:e,maxColorAttachments:f,pointSizeDims:a.getParameter(33901),lineWidthDims:a.getParameter(33902),maxViewportDims:a.getParameter(3386),maxCombinedTextureUnits:a.getParameter(35661),maxCubeMapSize:a.getParameter(34076),maxRenderbufferSize:a.getParameter(34024),maxTextureUnits:a.getParameter(34930),maxTextureSize:a.getParameter(3379),maxAttributes:a.getParameter(34921),maxVertexUniforms:a.getParameter(36347),maxVertexTextureUnits:a.getParameter(35660),maxVaryingVectors:a.getParameter(36348),maxFragmentUniforms:a.getParameter(36349),glsl:a.getParameter(35724),renderer:a.getParameter(7937),vendor:a.getParameter(7936),version:a.getParameter(7938),readFloat:d,npotTextureCube:r}},K=function(a){return a instanceof Uint8Array||a instanceof Uint16Array||a instanceof Uint32Array||a instanceof Int8Array||a instanceof Int16Array||a instanceof Int32Array||a instanceof Float32Array||a instanceof Float64Array||a instanceof Uint8ClampedArray},S=function(a){return Object.keys(a).map((function(b){return a[b]}))},Oa={shape:function(a){for(var b=[];a.length;a=a[0])b.push(a.length);return b},flatten:function(a,b,c,e){var f=1;if(b.length)for(var d=0;d<b.length;++d)f*=b[d];else f=0;switch(c=e||D.allocType(c,f),b.length){case 0:break;case 1:for(e=b[0],b=0;b<e;++b)c[b]=a[b];break;case 2:for(e=b[0],b=b[1],d=f=0;d<e;++d)for(var p=a[d],r=0;r<b;++r)c[f++]=p[r];break;case 3:gb(a,b[0],b[1],b[2],c,0);break;default:hb(a,b,0,c,0)}return c}},Ga={"[object Int8Array]":5120,"[object Int16Array]":5122,"[object Int32Array]":5124,"[object Uint8Array]":5121,"[object Uint8ClampedArray]":5121,"[object Uint16Array]":5123,"[object Uint32Array]":5125,"[object Float32Array]":5126,"[object Float64Array]":5121,"[object ArrayBuffer]":5121},Ha={int8:5120,int16:5122,int32:5124,uint8:5121,uint16:5123,uint32:5125,float:5126,float32:5126},lb={dynamic:35048,stream:35040,static:35044},Sa=Oa.flatten,kb=Oa.shape,ia=[];ia[5120]=1,ia[5122]=2,ia[5124]=4,ia[5121]=1,ia[5123]=2,ia[5125]=4,ia[5126]=4;var Ia={points:0,point:0,lines:1,line:1,triangles:4,triangle:4,"line loop":2,"line strip":3,"triangle strip":5,"triangle fan":6},nb=new Float32Array(1),Kb=new Uint32Array(nb.buffer),Ob=[9984,9986,9985,9987],Ma=[0,6409,6410,6407,6408],R={};R[6409]=R[6406]=R[6402]=1,R[34041]=R[6410]=2,R[6407]=R[35904]=3,R[6408]=R[35906]=4;var Va=oa("HTMLCanvasElement"),Wa=oa("OffscreenCanvas"),sb=oa("CanvasRenderingContext2D"),tb=oa("ImageBitmap"),ub=oa("HTMLImageElement"),vb=oa("HTMLVideoElement"),Lb=Object.keys(Ga).concat([Va,Wa,sb,tb,ub,vb]),pa=[];pa[5121]=1,pa[5126]=4,pa[36193]=2,pa[5123]=2,pa[5125]=4;var H=[];H[32854]=2,H[32855]=2,H[36194]=2,H[34041]=4,H[33776]=.5,H[33777]=.5,H[33778]=1,H[33779]=1,H[35986]=.5,H[35987]=1,H[34798]=1,H[35840]=.5,H[35841]=.25,H[35842]=.5,H[35843]=.25,H[36196]=.5;var P=[];P[32854]=2,P[32855]=2,P[36194]=2,P[33189]=2,P[36168]=1,P[34041]=4,P[35056]=4,P[35907]=4,P[34836]=16,P[34842]=8,P[34843]=6;var Zb=function(a,b,c,e,f){function d(a){this.id=m++,this.refCount=1,this.renderbuffer=a,this.format=32854,this.height=this.width=0,f.profile&&(this.stats={size:0})}function p(b){var c=b.renderbuffer;a.bindRenderbuffer(36161,null),a.deleteRenderbuffer(c),b.renderbuffer=null,b.refCount=0,delete u[b.id],e.renderbufferCount--}var r={rgba4:32854,rgba8:32856,rgb565:36194,"rgb5 a1":32855,depth:33189,stencil:36168,"depth stencil":34041,"depth24 stencil8":35056};b.ext_srgb&&(r.srgba=35907),b.ext_color_buffer_half_float&&(r.rgba16f=34842,r.rgb16f=34843),b.webgl_color_buffer_float&&(r.rgba32f=34836);var v=[];Object.keys(r).forEach((function(a){v[r[a]]=a}));var m=0,u={};return d.prototype.decRef=function(){0>=--this.refCount&&p(this)},f.profile&&(e.getTotalRenderbufferSize=function(){var a=0;return Object.keys(u).forEach((function(b){a+=u[b].stats.size})),a}),{create:function(b,c){function m(b,c){var d=0,e=0,n=32854,p=0;if("object"==typeof b&&b?("shape"in b?(d=0|(e=b.shape)[0],e=0|e[1]):("radius"in b&&(d=e=0|b.radius),"width"in b&&(d=0|b.width),"height"in b&&(e=0|b.height)),"format"in b&&(n=r[b.format]),"samples"in b&&(p=b.samples)):"number"==typeof b?(d=0|b,e="number"==typeof c?0|c:d):b||(d=e=1),d!==h.width||e!==h.height||n!==h.format)return m.width=h.width=d,m.height=h.height=e,m.samples=p,h.format=n,h.samples=p,a.bindRenderbuffer(36161,h.renderbuffer),p&&a.renderbufferStorageMultisample?a.renderbufferStorageMultisample(36161,p,n,d,e):a.renderbufferStorage(36161,n,d,e),f.profile&&(h.stats.size=P[h.format]*h.width*h.height),m.format=v[h.format],m}var h=new d(a.createRenderbuffer());return u[h.id]=h,e.renderbufferCount++,m(b,c),m.resize=function(b,c){var d=0|b,e=0|c||d;if(d===h.width&&e===h.height)return m;m.width=h.width=d,m.height=h.height=e;var n=m.samples;return a.bindRenderbuffer(36161,h.renderbuffer),n&&a.renderbufferStorageMultisample?a.renderbufferStorageMultisample(36161,n,h.format,d,e):a.renderbufferStorage(36161,h.format,d,e),f.profile&&(h.stats.size=P[h.format]*h.width*h.height),m},m._reglType="renderbuffer",m._renderbuffer=h,f.profile&&(m.stats=h.stats),m.destroy=function(){h.decRef()},m},clear:function(){S(u).forEach(p)},restore:function(){S(u).forEach((function(b){b.renderbuffer=a.createRenderbuffer(),a.bindRenderbuffer(36161,b.renderbuffer),b.samples&&a.renderbufferStorageMultisample?a.renderbufferStorageMultisample(36161,b.samples,b.format,b.width,b.height):a.renderbufferStorage(36161,b.format,b.width,b.height)})),a.bindRenderbuffer(36161,null)}}},Xa=[];Xa[6408]=4,Xa[6407]=3;var Pa=[];Pa[5121]=1,Pa[5126]=4,Pa[36193]=2;var Ba=["x","y","z","w"],Xb="blend.func blend.equation stencil.func stencil.opFront stencil.opBack sample.coverage viewport scissor.box polygonOffset.offset".split(" "),Ea={0:0,1:1,zero:0,one:1,"src color":768,"one minus src color":769,"src alpha":770,"one minus src alpha":771,"dst color":774,"one minus dst color":775,"dst alpha":772,"one minus dst alpha":773,"constant color":32769,"one minus constant color":32770,"constant alpha":32771,"one minus constant alpha":32772,"src alpha saturate":776},Za={never:512,less:513,"<":513,equal:514,"=":514,"==":514,"===":514,lequal:515,"<=":515,greater:516,">":516,notequal:517,"!=":517,"!==":517,gequal:518,">=":518,always:519},Ra={0:0,zero:0,keep:7680,replace:7681,increment:7682,decrement:7683,"increment wrap":34055,"decrement wrap":34056,invert:5386},yb={cw:2304,ccw:2305},zb=new I(!1,!1,!1,(function(){})),$b=function(a,b){function c(){this.endQueryIndex=this.startQueryIndex=-1,this.sum=0,this.stats=null}function e(a,b,d){var e=p.pop()||new c;e.startQueryIndex=a,e.endQueryIndex=b,e.sum=0,e.stats=d,r.push(e)}if(!b.ext_disjoint_timer_query)return null;var f=[],d=[],p=[],r=[],v=[],m=[];return{beginQuery:function(a){var c=f.pop()||b.ext_disjoint_timer_query.createQueryEXT();b.ext_disjoint_timer_query.beginQueryEXT(35007,c),d.push(c),e(d.length-1,d.length,a)},endQuery:function(){b.ext_disjoint_timer_query.endQueryEXT(35007)},pushScopeStats:e,update:function(){var a,c;if(0!==(a=d.length)){m.length=Math.max(m.length,a+1),v.length=Math.max(v.length,a+1),v[0]=0;var e=m[0]=0;for(c=a=0;c<d.length;++c)b.ext_disjoint_timer_query.getQueryObjectEXT(q=d[c],34919)?(e+=b.ext_disjoint_timer_query.getQueryObjectEXT(q,34918),f.push(q)):d[a++]=q,v[c+1]=e,m[c+1]=a;for(d.length=a,c=a=0;c<r.length;++c){var q,h=(e=r[c]).startQueryIndex;e.sum+=v[q=e.endQueryIndex]-v[h],(q=m[q])===(h=m[h])?(e.stats.gpuTime+=e.sum/1e6,p.push(e)):(e.startQueryIndex=h,e.endQueryIndex=q,r[a++]=e)}r.length=a}},getNumPendingQueries:function(){return d.length},clear:function(){f.push.apply(f,d);for(var a=0;a<f.length;a++)b.ext_disjoint_timer_query.deleteQueryEXT(f[a]);d.length=0,f.length=0},restore:function(){d.length=0,f.length=0}}};return function(a){function b(){if(0===G.length)t&&t.update(),ba=null;else{ba=$a.next(b),u();for(var a=G.length-1;0<=a;--a){var c=G[a];c&&c(C,null,0)}q.flush(),t&&t.update()}}function c(){!ba&&0<G.length&&(ba=$a.next(b))}function e(){ba&&($a.cancel(b),ba=null)}function f(a){a.preventDefault(),e(),S.forEach((function(a){a()}))}function d(a){q.getError(),g.restore(),y.restore(),E.restore(),K.restore(),P.restore(),Q.restore(),L.restore(),t&&t.restore(),J.procs.refresh(),c(),U.forEach((function(a){a()}))}function p(a){function b(a,c){var d={},e={};return Object.keys(a).forEach((function(b){var f=a[b];if(Y.isDynamic(f))e[b]=Y.unbox(f,b);else{if(c&&Array.isArray(f))for(var g=0;g<f.length;++g)if(Y.isDynamic(f[g]))return void(e[b]=Y.unbox(f,b));d[b]=f}})),{dynamic:e,static:d}}function c(a){for(;n.length<a;)n.push(null);return n}var d=b(a.context||{},!0),e=b(a.uniforms||{},!0),f=b(a.attributes||{},!1);a=b(function(a){function b(a){if(a in c){var d=c[a];delete c[a],Object.keys(d).forEach((function(b){c[a+"."+b]=d[b]}))}}var c=F({},a);return delete c.uniforms,delete c.attributes,delete c.context,delete c.vao,"stencil"in c&&c.stencil.op&&(c.stencil.opBack=c.stencil.opFront=c.stencil.op,delete c.stencil.op),b("blend"),b("depth"),b("cull"),b("stencil"),b("polygonOffset"),b("scissor"),b("sample"),"vao"in a&&(c.vao=a.vao),c}(a),!1);var g={gpuTime:0,cpuTime:0,count:0},h=J.compile(a,f,e,d,g),k=h.draw,l=h.batch,m=h.scope,n=[];return F((function(a,b){var d;if("function"==typeof a)return m.call(this,null,a,0);if("function"==typeof b)if("number"==typeof a)for(d=0;d<a;++d)m.call(this,null,b,d);else{if(!Array.isArray(a))return m.call(this,a,b,0);for(d=0;d<a.length;++d)m.call(this,a[d],b,d)}else if("number"==typeof a){if(0<a)return l.call(this,c(0|a),0|a)}else{if(!Array.isArray(a))return k.call(this,a);if(a.length)return l.call(this,a,a.length)}}),{stats:g,destroy:function(){h.destroy()}})}function r(a,b){var c=0;J.procs.poll();var d=b.color;d&&(q.clearColor(+d[0]||0,+d[1]||0,+d[2]||0,+d[3]||0),c|=16384),"depth"in b&&(q.clearDepth(+b.depth),c|=256),"stencil"in b&&(q.clearStencil(0|b.stencil),c|=1024),q.clear(c)}function v(a){return G.push(a),c(),{cancel:function(){function b(){var a=Ab(G,b);G[a]=G[G.length-1],--G.length,0>=G.length&&e()}var c=Ab(G,a);G[c]=b}}}function m(){var a=R.viewport,b=R.scissor_box;a[0]=a[1]=b[0]=b[1]=0,C.viewportWidth=C.framebufferWidth=C.drawingBufferWidth=a[2]=b[2]=q.drawingBufferWidth,C.viewportHeight=C.framebufferHeight=C.drawingBufferHeight=a[3]=b[3]=q.drawingBufferHeight}function u(){C.tick+=1,C.time=z(),m(),J.procs.poll()}function n(){K.refresh(),m(),J.procs.refresh(),t&&t.update()}function z(){return(Bb()-B)/1e3}if(!(a=Gb(a)))return null;var q=a.gl,h=q.getContextAttributes();q.isContextLost();var g=Hb(q,a);if(!g)return null;var k=Db(),l={vaoCount:0,bufferCount:0,elementsCount:0,framebufferCount:0,shaderCount:0,textureCount:0,cubeCount:0,renderbufferCount:0,maxTextureUnits:0},A=g.extensions,t=$b(q,A),B=Bb(),H=q.drawingBufferHeight,C={tick:0,time:0,viewportWidth:D=q.drawingBufferWidth,viewportHeight:H,framebufferWidth:D,framebufferHeight:H,drawingBufferWidth:D,drawingBufferHeight:H,pixelRatio:a.pixelRatio},D={elements:null,primitive:4,count:-1,offset:0,instances:-1},M=Yb(q,A),E=Ib(q,l,a,(function(a){return L.destroyBuffer(a)})),I=Jb(q,A,E,l),L=Rb(q,A,M,l,E,I,D),y=Sb(q,k,l,a),K=Mb(q,A,M,(function(){J.procs.poll()}),C,l,a),P=Zb(q,A,M,l,a),Q=Qb(q,A,M,K,P,l),J=Vb(q,k,A,M,E,I,K,Q,{},L,y,D,C,t,a),R=(k=Tb(q,Q,J.procs.poll,C),J.next),N=q.canvas,G=[],S=[],U=[],W=[a.onDestroy],ba=null;N&&(N.addEventListener("webglcontextlost",f,!1),N.addEventListener("webglcontextrestored",d,!1));var Z=Q.setFBO=p({framebuffer:Y.define.call(null,1,"framebuffer")});return n(),h=F(p,{clear:function(a){if("framebuffer"in a)if(a.framebuffer&&"framebufferCube"===a.framebuffer_reglType)for(var b=0;6>b;++b)Z(F({framebuffer:a.framebuffer.faces[b]},a),r);else Z(a,r);else r(null,a)},prop:Y.define.bind(null,1),context:Y.define.bind(null,2),this:Y.define.bind(null,3),draw:p({}),buffer:function(a){return E.create(a,34962,!1,!1)},elements:function(a){return I.create(a,!1)},texture:K.create2D,cube:K.createCube,renderbuffer:P.create,framebuffer:Q.create,framebufferCube:Q.createCube,vao:L.createVAO,attributes:h,frame:v,on:function(a,b){var c;switch(a){case"frame":return v(b);case"lost":c=S;break;case"restore":c=U;break;case"destroy":c=W}return c.push(b),{cancel:function(){for(var a=0;a<c.length;++a)if(c[a]===b){c[a]=c[c.length-1],c.pop();break}}}},limits:M,hasExtension:function(a){return 0<=M.extensions.indexOf(a.toLowerCase())},read:k,destroy:function(){G.length=0,e(),N&&(N.removeEventListener("webglcontextlost",f),N.removeEventListener("webglcontextrestored",d)),y.clear(),Q.clear(),P.clear(),L.clear(),K.clear(),I.clear(),E.clear(),t&&t.clear(),W.forEach((function(a){a()}))},_gl:q,_refresh:n,poll:function(){u(),t&&t.update()},now:z,stats:l,blit:Q.blit}),a.onDone(null,h),h}}()}(regl_min);var a$2=regl_min.exports,EPSILON=1e-6,ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,RANDOM=Math.random;var degree=Math.PI/180;var common=Object.freeze({__proto__:null,EPSILON,get ARRAY_TYPE(){return ARRAY_TYPE},RANDOM,setMatrixArrayType:function(type){ARRAY_TYPE=type},toRadian:function(a){return a*degree},equals:function(a,b){return Math.abs(a-b)<=EPSILON*Math.max(1,Math.abs(a),Math.abs(b))}});function set$8(out,m00,m01,m10,m11){return out[0]=m00,out[1]=m01,out[2]=m10,out[3]=m11,out}function multiply$8(out,a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],b0=b[0],b1=b[1],b2=b[2],b3=b[3];return out[0]=a0*b0+a2*b1,out[1]=a1*b0+a3*b1,out[2]=a0*b2+a2*b3,out[3]=a1*b2+a3*b3,out}function fromRotation$4(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=c,out[1]=s,out[2]=-s,out[3]=c,out}function subtract$6(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out[3]=a[3]-b[3],out}var mat2=Object.freeze({__proto__:null,create:function(){var out=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(out[1]=0,out[2]=0),out[0]=1,out[3]=1,out},clone:function(a){var out=new ARRAY_TYPE(4);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out},copy:function(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out},identity:function(out){return out[0]=1,out[1]=0,out[2]=0,out[3]=1,out},fromValues:function(m00,m01,m10,m11){var out=new ARRAY_TYPE(4);return out[0]=m00,out[1]=m01,out[2]=m10,out[3]=m11,out},set:set$8,transpose:function(out,a){if(out===a){var a1=a[1];out[1]=a[2],out[2]=a1}else out[0]=a[0],out[1]=a[2],out[2]=a[1],out[3]=a[3];return out},invert:function(out,a){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],det=a0*a3-a2*a1;return det?(out[0]=a3*(det=1/det),out[1]=-a1*det,out[2]=-a2*det,out[3]=a0*det,out):null},adjoint:function(out,a){var a0=a[0];return out[0]=a[3],out[1]=-a[1],out[2]=-a[2],out[3]=a0,out},determinant:function(a){return a[0]*a[3]-a[2]*a[1]},multiply:multiply$8,rotate:function(out,a,rad){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],s=Math.sin(rad),c=Math.cos(rad);return out[0]=a0*c+a2*s,out[1]=a1*c+a3*s,out[2]=a0*-s+a2*c,out[3]=a1*-s+a3*c,out},scale:function(out,a,v){var a1=a[1],a2=a[2],a3=a[3],v0=v[0],v1=v[1];return out[0]=a[0]*v0,out[1]=a1*v0,out[2]=a2*v1,out[3]=a3*v1,out},fromRotation:fromRotation$4,fromScaling:function(out,v){return out[0]=v[0],out[1]=0,out[2]=0,out[3]=v[1],out},str:function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},frob:function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2))},LDU:function(L,D,U,a){return L[2]=a[2]/a[0],U[0]=a[0],U[1]=a[1],U[3]=a[3]-L[2]*U[1],[L,D,U]},add:function(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out},subtract:subtract$6,exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]},equals:function(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],b0=b[0],b1=b[1],b2=b[2],b3=b[3];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))},multiplyScalar:function(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out},multiplyScalarAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out[3]=a[3]+b[3]*scale,out},mul:multiply$8,sub:subtract$6});function multiply$7(out,a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5];return out[0]=a0*b0+a2*b1,out[1]=a1*b0+a3*b1,out[2]=a0*b2+a2*b3,out[3]=a1*b2+a3*b3,out[4]=a0*b4+a2*b5+a4,out[5]=a1*b4+a3*b5+a5,out}function subtract$5(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out[3]=a[3]-b[3],out[4]=a[4]-b[4],out[5]=a[5]-b[5],out}var mat2d=Object.freeze({__proto__:null,create:function(){var out=new ARRAY_TYPE(6);return ARRAY_TYPE!=Float32Array&&(out[1]=0,out[2]=0,out[4]=0,out[5]=0),out[0]=1,out[3]=1,out},clone:function(a){var out=new ARRAY_TYPE(6);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out},copy:function(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out},identity:function(out){return out[0]=1,out[1]=0,out[2]=0,out[3]=1,out[4]=0,out[5]=0,out},fromValues:function(a,b,c,d,tx,ty){var out=new ARRAY_TYPE(6);return out[0]=a,out[1]=b,out[2]=c,out[3]=d,out[4]=tx,out[5]=ty,out},set:function(out,a,b,c,d,tx,ty){return out[0]=a,out[1]=b,out[2]=c,out[3]=d,out[4]=tx,out[5]=ty,out},invert:function(out,a){var aa=a[0],ab=a[1],ac=a[2],ad=a[3],atx=a[4],aty=a[5],det=aa*ad-ab*ac;return det?(out[0]=ad*(det=1/det),out[1]=-ab*det,out[2]=-ac*det,out[3]=aa*det,out[4]=(ac*aty-ad*atx)*det,out[5]=(ab*atx-aa*aty)*det,out):null},determinant:function(a){return a[0]*a[3]-a[1]*a[2]},multiply:multiply$7,rotate:function(out,a,rad){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],s=Math.sin(rad),c=Math.cos(rad);return out[0]=a0*c+a2*s,out[1]=a1*c+a3*s,out[2]=a0*-s+a2*c,out[3]=a1*-s+a3*c,out[4]=a4,out[5]=a5,out},scale:function(out,a,v){var a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],v0=v[0],v1=v[1];return out[0]=a[0]*v0,out[1]=a1*v0,out[2]=a2*v1,out[3]=a3*v1,out[4]=a4,out[5]=a5,out},translate:function(out,a,v){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],v0=v[0],v1=v[1];return out[0]=a0,out[1]=a1,out[2]=a2,out[3]=a3,out[4]=a0*v0+a2*v1+a4,out[5]=a1*v0+a3*v1+a5,out},fromRotation:function(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=c,out[1]=s,out[2]=-s,out[3]=c,out[4]=0,out[5]=0,out},fromScaling:function(out,v){return out[0]=v[0],out[1]=0,out[2]=0,out[3]=v[1],out[4]=0,out[5]=0,out},fromTranslation:function(out,v){return out[0]=1,out[1]=0,out[2]=0,out[3]=1,out[4]=v[0],out[5]=v[1],out},str:function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"},frob:function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+1)},add:function(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out[4]=a[4]+b[4],out[5]=a[5]+b[5],out},subtract:subtract$5,multiplyScalar:function(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out[4]=a[4]*b,out[5]=a[5]*b,out},multiplyScalarAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out[3]=a[3]+b[3]*scale,out[4]=a[4]+b[4]*scale,out[5]=a[5]+b[5]*scale,out},exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]},equals:function(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))&&Math.abs(a4-b4)<=EPSILON*Math.max(1,Math.abs(a4),Math.abs(b4))&&Math.abs(a5-b5)<=EPSILON*Math.max(1,Math.abs(a5),Math.abs(b5))},mul:multiply$7,sub:subtract$5});function create$6(){var out=new ARRAY_TYPE(9);return ARRAY_TYPE!=Float32Array&&(out[1]=0,out[2]=0,out[3]=0,out[5]=0,out[6]=0,out[7]=0),out[0]=1,out[4]=1,out[8]=1,out}function fromMat4$1(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[4],out[4]=a[5],out[5]=a[6],out[6]=a[8],out[7]=a[9],out[8]=a[10],out}function set$6(out,m00,m01,m02,m10,m11,m12,m20,m21,m22){return out[0]=m00,out[1]=m01,out[2]=m02,out[3]=m10,out[4]=m11,out[5]=m12,out[6]=m20,out[7]=m21,out[8]=m22,out}function transpose$1(out,a){if(out===a){var a01=a[1],a02=a[2],a12=a[5];out[1]=a[3],out[2]=a[6],out[3]=a01,out[5]=a[7],out[6]=a02,out[7]=a12}else out[0]=a[0],out[1]=a[3],out[2]=a[6],out[3]=a[1],out[4]=a[4],out[5]=a[7],out[6]=a[2],out[7]=a[5],out[8]=a[8];return out}function invert$3(out,a){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],b01=a22*a11-a12*a21,b11=-a22*a10+a12*a20,b21=a21*a10-a11*a20,det=a00*b01+a01*b11+a02*b21;return det?(out[0]=b01*(det=1/det),out[1]=(-a22*a01+a02*a21)*det,out[2]=(a12*a01-a02*a11)*det,out[3]=b11*det,out[4]=(a22*a00-a02*a20)*det,out[5]=(-a12*a00+a02*a10)*det,out[6]=b21*det,out[7]=(-a21*a00+a01*a20)*det,out[8]=(a11*a00-a01*a10)*det,out):null}function multiply$6(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],b00=b[0],b01=b[1],b02=b[2],b10=b[3],b11=b[4],b12=b[5],b20=b[6],b21=b[7],b22=b[8];return out[0]=b00*a00+b01*a10+b02*a20,out[1]=b00*a01+b01*a11+b02*a21,out[2]=b00*a02+b01*a12+b02*a22,out[3]=b10*a00+b11*a10+b12*a20,out[4]=b10*a01+b11*a11+b12*a21,out[5]=b10*a02+b11*a12+b12*a22,out[6]=b20*a00+b21*a10+b22*a20,out[7]=b20*a01+b21*a11+b22*a21,out[8]=b20*a02+b21*a12+b22*a22,out}function fromRotation$2(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=c,out[1]=s,out[2]=0,out[3]=-s,out[4]=c,out[5]=0,out[6]=0,out[7]=0,out[8]=1,out}function fromQuat$1(out,q){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,yx=y*x2,yy=y*y2,zx=z*x2,zy=z*y2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;return out[0]=1-yy-zz,out[3]=yx-wz,out[6]=zx+wy,out[1]=yx+wz,out[4]=1-xx-zz,out[7]=zy-wx,out[2]=zx-wy,out[5]=zy+wx,out[8]=1-xx-yy,out}function subtract$4(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out[3]=a[3]-b[3],out[4]=a[4]-b[4],out[5]=a[5]-b[5],out[6]=a[6]-b[6],out[7]=a[7]-b[7],out[8]=a[8]-b[8],out}var mat3=Object.freeze({__proto__:null,create:create$6,fromMat4:fromMat4$1,clone:function(a){var out=new ARRAY_TYPE(9);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out[8]=a[8],out},copy:function(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out[8]=a[8],out},fromValues:function(m00,m01,m02,m10,m11,m12,m20,m21,m22){var out=new ARRAY_TYPE(9);return out[0]=m00,out[1]=m01,out[2]=m02,out[3]=m10,out[4]=m11,out[5]=m12,out[6]=m20,out[7]=m21,out[8]=m22,out},set:set$6,identity:function(out){return out[0]=1,out[1]=0,out[2]=0,out[3]=0,out[4]=1,out[5]=0,out[6]=0,out[7]=0,out[8]=1,out},transpose:transpose$1,invert:invert$3,adjoint:function(out,a){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8];return out[0]=a11*a22-a12*a21,out[1]=a02*a21-a01*a22,out[2]=a01*a12-a02*a11,out[3]=a12*a20-a10*a22,out[4]=a00*a22-a02*a20,out[5]=a02*a10-a00*a12,out[6]=a10*a21-a11*a20,out[7]=a01*a20-a00*a21,out[8]=a00*a11-a01*a10,out},determinant:function(a){var a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8];return a[0]*(a22*a11-a12*a21)+a[1]*(-a22*a10+a12*a20)+a[2]*(a21*a10-a11*a20)},multiply:multiply$6,translate:function(out,a,v){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],x=v[0],y=v[1];return out[0]=a00,out[1]=a01,out[2]=a02,out[3]=a10,out[4]=a11,out[5]=a12,out[6]=x*a00+y*a10+a20,out[7]=x*a01+y*a11+a21,out[8]=x*a02+y*a12+a22,out},rotate:function(out,a,rad){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],s=Math.sin(rad),c=Math.cos(rad);return out[0]=c*a00+s*a10,out[1]=c*a01+s*a11,out[2]=c*a02+s*a12,out[3]=c*a10-s*a00,out[4]=c*a11-s*a01,out[5]=c*a12-s*a02,out[6]=a20,out[7]=a21,out[8]=a22,out},scale:function(out,a,v){var x=v[0],y=v[1];return out[0]=x*a[0],out[1]=x*a[1],out[2]=x*a[2],out[3]=y*a[3],out[4]=y*a[4],out[5]=y*a[5],out[6]=a[6],out[7]=a[7],out[8]=a[8],out},fromTranslation:function(out,v){return out[0]=1,out[1]=0,out[2]=0,out[3]=0,out[4]=1,out[5]=0,out[6]=v[0],out[7]=v[1],out[8]=1,out},fromRotation:fromRotation$2,fromScaling:function(out,v){return out[0]=v[0],out[1]=0,out[2]=0,out[3]=0,out[4]=v[1],out[5]=0,out[6]=0,out[7]=0,out[8]=1,out},fromMat2d:function(out,a){return out[0]=a[0],out[1]=a[1],out[2]=0,out[3]=a[2],out[4]=a[3],out[5]=0,out[6]=a[4],out[7]=a[5],out[8]=1,out},fromQuat:fromQuat$1,normalFromMat4:function(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return det?(out[0]=(a11*b11-a12*b10+a13*b09)*(det=1/det),out[1]=(a12*b08-a10*b11-a13*b07)*det,out[2]=(a10*b10-a11*b08+a13*b06)*det,out[3]=(a02*b10-a01*b11-a03*b09)*det,out[4]=(a00*b11-a02*b08+a03*b07)*det,out[5]=(a01*b08-a00*b10-a03*b06)*det,out[6]=(a31*b05-a32*b04+a33*b03)*det,out[7]=(a32*b02-a30*b05-a33*b01)*det,out[8]=(a30*b04-a31*b02+a33*b00)*det,out):null},projection:function(out,width,height){return out[0]=2/width,out[1]=0,out[2]=0,out[3]=0,out[4]=-2/height,out[5]=0,out[6]=-1,out[7]=1,out[8]=1,out},str:function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"},frob:function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2))},add:function(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out[4]=a[4]+b[4],out[5]=a[5]+b[5],out[6]=a[6]+b[6],out[7]=a[7]+b[7],out[8]=a[8]+b[8],out},subtract:subtract$4,multiplyScalar:function(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out[4]=a[4]*b,out[5]=a[5]*b,out[6]=a[6]*b,out[7]=a[7]*b,out[8]=a[8]*b,out},multiplyScalarAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out[3]=a[3]+b[3]*scale,out[4]=a[4]+b[4]*scale,out[5]=a[5]+b[5]*scale,out[6]=a[6]+b[6]*scale,out[7]=a[7]+b[7]*scale,out[8]=a[8]+b[8]*scale,out},exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&&a[8]===b[8]},equals:function(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],a6=a[6],a7=a[7],a8=a[8],b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5],b6=b[6],b7=b[7],b8=b[8];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))&&Math.abs(a4-b4)<=EPSILON*Math.max(1,Math.abs(a4),Math.abs(b4))&&Math.abs(a5-b5)<=EPSILON*Math.max(1,Math.abs(a5),Math.abs(b5))&&Math.abs(a6-b6)<=EPSILON*Math.max(1,Math.abs(a6),Math.abs(b6))&&Math.abs(a7-b7)<=EPSILON*Math.max(1,Math.abs(a7),Math.abs(b7))&&Math.abs(a8-b8)<=EPSILON*Math.max(1,Math.abs(a8),Math.abs(b8))},mul:multiply$6,sub:subtract$4});function create$5(){var out=new ARRAY_TYPE(16);return ARRAY_TYPE!=Float32Array&&(out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[11]=0,out[12]=0,out[13]=0,out[14]=0),out[0]=1,out[5]=1,out[10]=1,out[15]=1,out}function copy$5(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out[8]=a[8],out[9]=a[9],out[10]=a[10],out[11]=a[11],out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15],out}function identity$2(out){return out[0]=1,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=1,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[10]=1,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out}function transpose(out,a){if(out===a){var a01=a[1],a02=a[2],a03=a[3],a12=a[6],a13=a[7],a23=a[11];out[1]=a[4],out[2]=a[8],out[3]=a[12],out[4]=a01,out[6]=a[9],out[7]=a[13],out[8]=a02,out[9]=a12,out[11]=a[14],out[12]=a03,out[13]=a13,out[14]=a23}else out[0]=a[0],out[1]=a[4],out[2]=a[8],out[3]=a[12],out[4]=a[1],out[5]=a[5],out[6]=a[9],out[7]=a[13],out[8]=a[2],out[9]=a[6],out[10]=a[10],out[11]=a[14],out[12]=a[3],out[13]=a[7],out[14]=a[11],out[15]=a[15];return out}function invert$2(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;return det?(out[0]=(a11*b11-a12*b10+a13*b09)*(det=1/det),out[1]=(a02*b10-a01*b11-a03*b09)*det,out[2]=(a31*b05-a32*b04+a33*b03)*det,out[3]=(a22*b04-a21*b05-a23*b03)*det,out[4]=(a12*b08-a10*b11-a13*b07)*det,out[5]=(a00*b11-a02*b08+a03*b07)*det,out[6]=(a32*b02-a30*b05-a33*b01)*det,out[7]=(a20*b05-a22*b02+a23*b01)*det,out[8]=(a10*b10-a11*b08+a13*b06)*det,out[9]=(a01*b08-a00*b10-a03*b06)*det,out[10]=(a30*b04-a31*b02+a33*b00)*det,out[11]=(a21*b02-a20*b04-a23*b00)*det,out[12]=(a11*b07-a10*b09-a12*b06)*det,out[13]=(a00*b09-a01*b07+a02*b06)*det,out[14]=(a31*b01-a30*b03-a32*b00)*det,out[15]=(a20*b03-a21*b01+a22*b00)*det,out):null}function multiply$5(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b0=b[0],b1=b[1],b2=b[2],b3=b[3];return out[0]=b0*a00+b1*a10+b2*a20+b3*a30,out[1]=b0*a01+b1*a11+b2*a21+b3*a31,out[2]=b0*a02+b1*a12+b2*a22+b3*a32,out[3]=b0*a03+b1*a13+b2*a23+b3*a33,out[4]=(b0=b[4])*a00+(b1=b[5])*a10+(b2=b[6])*a20+(b3=b[7])*a30,out[5]=b0*a01+b1*a11+b2*a21+b3*a31,out[6]=b0*a02+b1*a12+b2*a22+b3*a32,out[7]=b0*a03+b1*a13+b2*a23+b3*a33,out[8]=(b0=b[8])*a00+(b1=b[9])*a10+(b2=b[10])*a20+(b3=b[11])*a30,out[9]=b0*a01+b1*a11+b2*a21+b3*a31,out[10]=b0*a02+b1*a12+b2*a22+b3*a32,out[11]=b0*a03+b1*a13+b2*a23+b3*a33,out[12]=(b0=b[12])*a00+(b1=b[13])*a10+(b2=b[14])*a20+(b3=b[15])*a30,out[13]=b0*a01+b1*a11+b2*a21+b3*a31,out[14]=b0*a02+b1*a12+b2*a22+b3*a32,out[15]=b0*a03+b1*a13+b2*a23+b3*a33,out}function translate$1(out,a,v){var x=v[0],y=v[1],z=v[2],a00=void 0,a01=void 0,a02=void 0,a03=void 0,a10=void 0,a11=void 0,a12=void 0,a13=void 0,a20=void 0,a21=void 0,a22=void 0,a23=void 0;return a===out?(out[12]=a[0]*x+a[4]*y+a[8]*z+a[12],out[13]=a[1]*x+a[5]*y+a[9]*z+a[13],out[14]=a[2]*x+a[6]*y+a[10]*z+a[14],out[15]=a[3]*x+a[7]*y+a[11]*z+a[15]):(a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],out[0]=a00=a[0],out[1]=a01,out[2]=a02,out[3]=a03,out[4]=a10,out[5]=a11,out[6]=a12,out[7]=a13,out[8]=a20,out[9]=a21,out[10]=a22,out[11]=a23,out[12]=a00*x+a10*y+a20*z+a[12],out[13]=a01*x+a11*y+a21*z+a[13],out[14]=a02*x+a12*y+a22*z+a[14],out[15]=a03*x+a13*y+a23*z+a[15]),out}function scale$5(out,a,v){var x=v[0],y=v[1],z=v[2];return out[0]=a[0]*x,out[1]=a[1]*x,out[2]=a[2]*x,out[3]=a[3]*x,out[4]=a[4]*y,out[5]=a[5]*y,out[6]=a[6]*y,out[7]=a[7]*y,out[8]=a[8]*z,out[9]=a[9]*z,out[10]=a[10]*z,out[11]=a[11]*z,out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15],out}function rotate$1(out,a,rad,axis){var s,c,t,a00,a01,a02,a03,a10,a11,a12,a13,a20,a21,a22,a23,b00,b01,b02,b10,b11,b12,b20,b21,b22,x=axis[0],y=axis[1],z=axis[2],len=Math.sqrt(x*x+y*y+z*z);return len<EPSILON?null:(x*=len=1/len,y*=len,z*=len,s=Math.sin(rad),c=Math.cos(rad),a01=a[1],a02=a[2],a03=a[3],a11=a[5],a12=a[6],a13=a[7],a21=a[9],a22=a[10],a23=a[11],b10=x*y*(t=1-c)-z*s,b11=y*y*t+c,b12=z*y*t+x*s,b20=x*z*t+y*s,b21=y*z*t-x*s,b22=z*z*t+c,out[0]=(a00=a[0])*(b00=x*x*t+c)+(a10=a[4])*(b01=y*x*t+z*s)+(a20=a[8])*(b02=z*x*t-y*s),out[1]=a01*b00+a11*b01+a21*b02,out[2]=a02*b00+a12*b01+a22*b02,out[3]=a03*b00+a13*b01+a23*b02,out[4]=a00*b10+a10*b11+a20*b12,out[5]=a01*b10+a11*b11+a21*b12,out[6]=a02*b10+a12*b11+a22*b12,out[7]=a03*b10+a13*b11+a23*b12,out[8]=a00*b20+a10*b21+a20*b22,out[9]=a01*b20+a11*b21+a21*b22,out[10]=a02*b20+a12*b21+a22*b22,out[11]=a03*b20+a13*b21+a23*b22,a!==out&&(out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15]),out)}function fromTranslation$1(out,v){return out[0]=1,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=1,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[10]=1,out[11]=0,out[12]=v[0],out[13]=v[1],out[14]=v[2],out[15]=1,out}function fromScaling(out,v){return out[0]=v[0],out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=v[1],out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[10]=v[2],out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out}function fromRotation$1(out,rad,axis){var s,c,t,x=axis[0],y=axis[1],z=axis[2],len=Math.sqrt(x*x+y*y+z*z);return len<EPSILON?null:(x*=len=1/len,y*=len,z*=len,s=Math.sin(rad),c=Math.cos(rad),out[0]=x*x*(t=1-c)+c,out[1]=y*x*t+z*s,out[2]=z*x*t-y*s,out[3]=0,out[4]=x*y*t-z*s,out[5]=y*y*t+c,out[6]=z*y*t+x*s,out[7]=0,out[8]=x*z*t+y*s,out[9]=y*z*t-x*s,out[10]=z*z*t+c,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out)}function fromRotationTranslation$1(out,q,v){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;return out[0]=1-(yy+zz),out[1]=xy+wz,out[2]=xz-wy,out[3]=0,out[4]=xy-wz,out[5]=1-(xx+zz),out[6]=yz+wx,out[7]=0,out[8]=xz+wy,out[9]=yz-wx,out[10]=1-(xx+yy),out[11]=0,out[12]=v[0],out[13]=v[1],out[14]=v[2],out[15]=1,out}function getTranslation$1(out,mat){return out[0]=mat[12],out[1]=mat[13],out[2]=mat[14],out}function getScaling(out,mat){var m11=mat[0],m12=mat[1],m13=mat[2],m21=mat[4],m22=mat[5],m23=mat[6],m31=mat[8],m32=mat[9],m33=mat[10];return out[0]=Math.sqrt(m11*m11+m12*m12+m13*m13),out[1]=Math.sqrt(m21*m21+m22*m22+m23*m23),out[2]=Math.sqrt(m31*m31+m32*m32+m33*m33),out}function getRotation(out,mat){var trace=mat[0]+mat[5]+mat[10],S=0;return trace>0?(S=2*Math.sqrt(trace+1),out[3]=.25*S,out[0]=(mat[6]-mat[9])/S,out[1]=(mat[8]-mat[2])/S,out[2]=(mat[1]-mat[4])/S):mat[0]>mat[5]&&mat[0]>mat[10]?(S=2*Math.sqrt(1+mat[0]-mat[5]-mat[10]),out[3]=(mat[6]-mat[9])/S,out[0]=.25*S,out[1]=(mat[1]+mat[4])/S,out[2]=(mat[8]+mat[2])/S):mat[5]>mat[10]?(S=2*Math.sqrt(1+mat[5]-mat[0]-mat[10]),out[3]=(mat[8]-mat[2])/S,out[0]=(mat[1]+mat[4])/S,out[1]=.25*S,out[2]=(mat[6]+mat[9])/S):(S=2*Math.sqrt(1+mat[10]-mat[0]-mat[5]),out[3]=(mat[1]-mat[4])/S,out[0]=(mat[8]+mat[2])/S,out[1]=(mat[6]+mat[9])/S,out[2]=.25*S),out}function fromRotationTranslationScale(out,q,v,s){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2,sx=s[0],sy=s[1],sz=s[2];return out[0]=(1-(yy+zz))*sx,out[1]=(xy+wz)*sx,out[2]=(xz-wy)*sx,out[3]=0,out[4]=(xy-wz)*sy,out[5]=(1-(xx+zz))*sy,out[6]=(yz+wx)*sy,out[7]=0,out[8]=(xz+wy)*sz,out[9]=(yz-wx)*sz,out[10]=(1-(xx+yy))*sz,out[11]=0,out[12]=v[0],out[13]=v[1],out[14]=v[2],out[15]=1,out}function fromQuat(out,q){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,yx=y*x2,yy=y*y2,zx=z*x2,zy=z*y2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;return out[0]=1-yy-zz,out[1]=yx+wz,out[2]=zx-wy,out[3]=0,out[4]=yx-wz,out[5]=1-xx-zz,out[6]=zy+wx,out[7]=0,out[8]=zx+wy,out[9]=zy-wx,out[10]=1-xx-yy,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out}function perspective(out,fovy,aspect,near,far){var f=1/Math.tan(fovy/2),nf=void 0;return out[0]=f/aspect,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=f,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[11]=-1,out[12]=0,out[13]=0,out[15]=0,null!=far&&far!==1/0?(out[10]=(far+near)*(nf=1/(near-far)),out[14]=2*far*near*nf):(out[10]=-1,out[14]=-2*near),out}function ortho(out,left,right,bottom,top,near,far){var lr=1/(left-right),bt=1/(bottom-top),nf=1/(near-far);return out[0]=-2*lr,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=-2*bt,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[10]=2*nf,out[11]=0,out[12]=(left+right)*lr,out[13]=(top+bottom)*bt,out[14]=(far+near)*nf,out[15]=1,out}function lookAt(out,eye,center,up){var x0=void 0,x1=void 0,x2=void 0,y0=void 0,y1=void 0,y2=void 0,z0=void 0,z1=void 0,z2=void 0,len=void 0,eyex=eye[0],eyey=eye[1],eyez=eye[2],upx=up[0],upy=up[1],upz=up[2],centerx=center[0],centery=center[1],centerz=center[2];return Math.abs(eyex-centerx)<EPSILON&&Math.abs(eyey-centery)<EPSILON&&Math.abs(eyez-centerz)<EPSILON?identity$2(out):(z0=eyex-centerx,z1=eyey-centery,z2=eyez-centerz,x0=upy*(z2*=len=1/Math.sqrt(z0*z0+z1*z1+z2*z2))-upz*(z1*=len),x1=upz*(z0*=len)-upx*z2,x2=upx*z1-upy*z0,(len=Math.sqrt(x0*x0+x1*x1+x2*x2))?(x0*=len=1/len,x1*=len,x2*=len):(x0=0,x1=0,x2=0),y0=z1*x2-z2*x1,y1=z2*x0-z0*x2,y2=z0*x1-z1*x0,(len=Math.sqrt(y0*y0+y1*y1+y2*y2))?(y0*=len=1/len,y1*=len,y2*=len):(y0=0,y1=0,y2=0),out[0]=x0,out[1]=y0,out[2]=z0,out[3]=0,out[4]=x1,out[5]=y1,out[6]=z1,out[7]=0,out[8]=x2,out[9]=y2,out[10]=z2,out[11]=0,out[12]=-(x0*eyex+x1*eyey+x2*eyez),out[13]=-(y0*eyex+y1*eyey+y2*eyez),out[14]=-(z0*eyex+z1*eyey+z2*eyez),out[15]=1,out)}function subtract$3(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out[3]=a[3]-b[3],out[4]=a[4]-b[4],out[5]=a[5]-b[5],out[6]=a[6]-b[6],out[7]=a[7]-b[7],out[8]=a[8]-b[8],out[9]=a[9]-b[9],out[10]=a[10]-b[10],out[11]=a[11]-b[11],out[12]=a[12]-b[12],out[13]=a[13]-b[13],out[14]=a[14]-b[14],out[15]=a[15]-b[15],out}function exactEquals$5(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]&&a[8]===b[8]&&a[9]===b[9]&&a[10]===b[10]&&a[11]===b[11]&&a[12]===b[12]&&a[13]===b[13]&&a[14]===b[14]&&a[15]===b[15]}var mul$5=multiply$5,mat4=Object.freeze({__proto__:null,create:create$5,clone:function(a){var out=new ARRAY_TYPE(16);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out[8]=a[8],out[9]=a[9],out[10]=a[10],out[11]=a[11],out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15],out},copy:copy$5,fromValues:function(m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33){var out=new ARRAY_TYPE(16);return out[0]=m00,out[1]=m01,out[2]=m02,out[3]=m03,out[4]=m10,out[5]=m11,out[6]=m12,out[7]=m13,out[8]=m20,out[9]=m21,out[10]=m22,out[11]=m23,out[12]=m30,out[13]=m31,out[14]=m32,out[15]=m33,out},set:function(out,m00,m01,m02,m03,m10,m11,m12,m13,m20,m21,m22,m23,m30,m31,m32,m33){return out[0]=m00,out[1]=m01,out[2]=m02,out[3]=m03,out[4]=m10,out[5]=m11,out[6]=m12,out[7]=m13,out[8]=m20,out[9]=m21,out[10]=m22,out[11]=m23,out[12]=m30,out[13]=m31,out[14]=m32,out[15]=m33,out},identity:identity$2,transpose,invert:invert$2,adjoint:function(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];return out[0]=a11*(a22*a33-a23*a32)-a21*(a12*a33-a13*a32)+a31*(a12*a23-a13*a22),out[1]=-(a01*(a22*a33-a23*a32)-a21*(a02*a33-a03*a32)+a31*(a02*a23-a03*a22)),out[2]=a01*(a12*a33-a13*a32)-a11*(a02*a33-a03*a32)+a31*(a02*a13-a03*a12),out[3]=-(a01*(a12*a23-a13*a22)-a11*(a02*a23-a03*a22)+a21*(a02*a13-a03*a12)),out[4]=-(a10*(a22*a33-a23*a32)-a20*(a12*a33-a13*a32)+a30*(a12*a23-a13*a22)),out[5]=a00*(a22*a33-a23*a32)-a20*(a02*a33-a03*a32)+a30*(a02*a23-a03*a22),out[6]=-(a00*(a12*a33-a13*a32)-a10*(a02*a33-a03*a32)+a30*(a02*a13-a03*a12)),out[7]=a00*(a12*a23-a13*a22)-a10*(a02*a23-a03*a22)+a20*(a02*a13-a03*a12),out[8]=a10*(a21*a33-a23*a31)-a20*(a11*a33-a13*a31)+a30*(a11*a23-a13*a21),out[9]=-(a00*(a21*a33-a23*a31)-a20*(a01*a33-a03*a31)+a30*(a01*a23-a03*a21)),out[10]=a00*(a11*a33-a13*a31)-a10*(a01*a33-a03*a31)+a30*(a01*a13-a03*a11),out[11]=-(a00*(a11*a23-a13*a21)-a10*(a01*a23-a03*a21)+a20*(a01*a13-a03*a11)),out[12]=-(a10*(a21*a32-a22*a31)-a20*(a11*a32-a12*a31)+a30*(a11*a22-a12*a21)),out[13]=a00*(a21*a32-a22*a31)-a20*(a01*a32-a02*a31)+a30*(a01*a22-a02*a21),out[14]=-(a00*(a11*a32-a12*a31)-a10*(a01*a32-a02*a31)+a30*(a01*a12-a02*a11)),out[15]=a00*(a11*a22-a12*a21)-a10*(a01*a22-a02*a21)+a20*(a01*a12-a02*a11),out},determinant:function(a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];return(a00*a11-a01*a10)*(a22*a33-a23*a32)-(a00*a12-a02*a10)*(a21*a33-a23*a31)+(a00*a13-a03*a10)*(a21*a32-a22*a31)+(a01*a12-a02*a11)*(a20*a33-a23*a30)-(a01*a13-a03*a11)*(a20*a32-a22*a30)+(a02*a13-a03*a12)*(a20*a31-a21*a30)},multiply:multiply$5,translate:translate$1,scale:scale$5,rotate:rotate$1,rotateX:function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11];return a!==out&&(out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15]),out[4]=a10*c+a20*s,out[5]=a11*c+a21*s,out[6]=a12*c+a22*s,out[7]=a13*c+a23*s,out[8]=a20*c-a10*s,out[9]=a21*c-a11*s,out[10]=a22*c-a12*s,out[11]=a23*c-a13*s,out},rotateY:function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a00=a[0],a01=a[1],a02=a[2],a03=a[3],a20=a[8],a21=a[9],a22=a[10],a23=a[11];return a!==out&&(out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15]),out[0]=a00*c-a20*s,out[1]=a01*c-a21*s,out[2]=a02*c-a22*s,out[3]=a03*c-a23*s,out[8]=a00*s+a20*c,out[9]=a01*s+a21*c,out[10]=a02*s+a22*c,out[11]=a03*s+a23*c,out},rotateZ:function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7];return a!==out&&(out[8]=a[8],out[9]=a[9],out[10]=a[10],out[11]=a[11],out[12]=a[12],out[13]=a[13],out[14]=a[14],out[15]=a[15]),out[0]=a00*c+a10*s,out[1]=a01*c+a11*s,out[2]=a02*c+a12*s,out[3]=a03*c+a13*s,out[4]=a10*c-a00*s,out[5]=a11*c-a01*s,out[6]=a12*c-a02*s,out[7]=a13*c-a03*s,out},fromTranslation:fromTranslation$1,fromScaling,fromRotation:fromRotation$1,fromXRotation:function(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=1,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=c,out[6]=s,out[7]=0,out[8]=0,out[9]=-s,out[10]=c,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out},fromYRotation:function(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=c,out[1]=0,out[2]=-s,out[3]=0,out[4]=0,out[5]=1,out[6]=0,out[7]=0,out[8]=s,out[9]=0,out[10]=c,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out},fromZRotation:function(out,rad){var s=Math.sin(rad),c=Math.cos(rad);return out[0]=c,out[1]=s,out[2]=0,out[3]=0,out[4]=-s,out[5]=c,out[6]=0,out[7]=0,out[8]=0,out[9]=0,out[10]=1,out[11]=0,out[12]=0,out[13]=0,out[14]=0,out[15]=1,out},fromRotationTranslation:fromRotationTranslation$1,fromQuat2:function(out,a){var translation=new ARRAY_TYPE(3),bx=-a[0],by=-a[1],bz=-a[2],bw=a[3],ax=a[4],ay=a[5],az=a[6],aw=a[7],magnitude=bx*bx+by*by+bz*bz+bw*bw;return magnitude>0?(translation[0]=2*(ax*bw+aw*bx+ay*bz-az*by)/magnitude,translation[1]=2*(ay*bw+aw*by+az*bx-ax*bz)/magnitude,translation[2]=2*(az*bw+aw*bz+ax*by-ay*bx)/magnitude):(translation[0]=2*(ax*bw+aw*bx+ay*bz-az*by),translation[1]=2*(ay*bw+aw*by+az*bx-ax*bz),translation[2]=2*(az*bw+aw*bz+ax*by-ay*bx)),fromRotationTranslation$1(out,a,translation),out},getTranslation:getTranslation$1,getScaling,getRotation,fromRotationTranslationScale,fromRotationTranslationScaleOrigin:function(out,q,v,s,o){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2,sx=s[0],sy=s[1],sz=s[2],ox=o[0],oy=o[1],oz=o[2],out0=(1-(yy+zz))*sx,out1=(xy+wz)*sx,out2=(xz-wy)*sx,out4=(xy-wz)*sy,out5=(1-(xx+zz))*sy,out6=(yz+wx)*sy,out8=(xz+wy)*sz,out9=(yz-wx)*sz,out10=(1-(xx+yy))*sz;return out[0]=out0,out[1]=out1,out[2]=out2,out[3]=0,out[4]=out4,out[5]=out5,out[6]=out6,out[7]=0,out[8]=out8,out[9]=out9,out[10]=out10,out[11]=0,out[12]=v[0]+ox-(out0*ox+out4*oy+out8*oz),out[13]=v[1]+oy-(out1*ox+out5*oy+out9*oz),out[14]=v[2]+oz-(out2*ox+out6*oy+out10*oz),out[15]=1,out},fromQuat,frustum:function(out,left,right,bottom,top,near,far){var rl=1/(right-left),tb=1/(top-bottom),nf=1/(near-far);return out[0]=2*near*rl,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=2*near*tb,out[6]=0,out[7]=0,out[8]=(right+left)*rl,out[9]=(top+bottom)*tb,out[10]=(far+near)*nf,out[11]=-1,out[12]=0,out[13]=0,out[14]=far*near*2*nf,out[15]=0,out},perspective,perspectiveFromFieldOfView:function(out,fov,near,far){var upTan=Math.tan(fov.upDegrees*Math.PI/180),downTan=Math.tan(fov.downDegrees*Math.PI/180),leftTan=Math.tan(fov.leftDegrees*Math.PI/180),rightTan=Math.tan(fov.rightDegrees*Math.PI/180),xScale=2/(leftTan+rightTan),yScale=2/(upTan+downTan);return out[0]=xScale,out[1]=0,out[2]=0,out[3]=0,out[4]=0,out[5]=yScale,out[6]=0,out[7]=0,out[8]=-(leftTan-rightTan)*xScale*.5,out[9]=(upTan-downTan)*yScale*.5,out[10]=far/(near-far),out[11]=-1,out[12]=0,out[13]=0,out[14]=far*near/(near-far),out[15]=0,out},ortho,lookAt,targetTo:function(out,eye,target,up){var eyex=eye[0],eyey=eye[1],eyez=eye[2],upx=up[0],upy=up[1],upz=up[2],z0=eyex-target[0],z1=eyey-target[1],z2=eyez-target[2],len=z0*z0+z1*z1+z2*z2;len>0&&(z0*=len=1/Math.sqrt(len),z1*=len,z2*=len);var x0=upy*z2-upz*z1,x1=upz*z0-upx*z2,x2=upx*z1-upy*z0;return(len=x0*x0+x1*x1+x2*x2)>0&&(x0*=len=1/Math.sqrt(len),x1*=len,x2*=len),out[0]=x0,out[1]=x1,out[2]=x2,out[3]=0,out[4]=z1*x2-z2*x1,out[5]=z2*x0-z0*x2,out[6]=z0*x1-z1*x0,out[7]=0,out[8]=z0,out[9]=z1,out[10]=z2,out[11]=0,out[12]=eyex,out[13]=eyey,out[14]=eyez,out[15]=1,out},str:function(a){return"mat4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+", "+a[9]+", "+a[10]+", "+a[11]+", "+a[12]+", "+a[13]+", "+a[14]+", "+a[15]+")"},frob:function(a){return Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)+Math.pow(a[2],2)+Math.pow(a[3],2)+Math.pow(a[4],2)+Math.pow(a[5],2)+Math.pow(a[6],2)+Math.pow(a[7],2)+Math.pow(a[8],2)+Math.pow(a[9],2)+Math.pow(a[10],2)+Math.pow(a[11],2)+Math.pow(a[12],2)+Math.pow(a[13],2)+Math.pow(a[14],2)+Math.pow(a[15],2))},add:function(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out[4]=a[4]+b[4],out[5]=a[5]+b[5],out[6]=a[6]+b[6],out[7]=a[7]+b[7],out[8]=a[8]+b[8],out[9]=a[9]+b[9],out[10]=a[10]+b[10],out[11]=a[11]+b[11],out[12]=a[12]+b[12],out[13]=a[13]+b[13],out[14]=a[14]+b[14],out[15]=a[15]+b[15],out},subtract:subtract$3,multiplyScalar:function(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out[4]=a[4]*b,out[5]=a[5]*b,out[6]=a[6]*b,out[7]=a[7]*b,out[8]=a[8]*b,out[9]=a[9]*b,out[10]=a[10]*b,out[11]=a[11]*b,out[12]=a[12]*b,out[13]=a[13]*b,out[14]=a[14]*b,out[15]=a[15]*b,out},multiplyScalarAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out[3]=a[3]+b[3]*scale,out[4]=a[4]+b[4]*scale,out[5]=a[5]+b[5]*scale,out[6]=a[6]+b[6]*scale,out[7]=a[7]+b[7]*scale,out[8]=a[8]+b[8]*scale,out[9]=a[9]+b[9]*scale,out[10]=a[10]+b[10]*scale,out[11]=a[11]+b[11]*scale,out[12]=a[12]+b[12]*scale,out[13]=a[13]+b[13]*scale,out[14]=a[14]+b[14]*scale,out[15]=a[15]+b[15]*scale,out},exactEquals:exactEquals$5,equals:function(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],a6=a[6],a7=a[7],a8=a[8],a9=a[9],a10=a[10],a11=a[11],a12=a[12],a13=a[13],a14=a[14],a15=a[15],b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5],b6=b[6],b7=b[7],b8=b[8],b9=b[9],b10=b[10],b11=b[11],b12=b[12],b13=b[13],b14=b[14],b15=b[15];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))&&Math.abs(a4-b4)<=EPSILON*Math.max(1,Math.abs(a4),Math.abs(b4))&&Math.abs(a5-b5)<=EPSILON*Math.max(1,Math.abs(a5),Math.abs(b5))&&Math.abs(a6-b6)<=EPSILON*Math.max(1,Math.abs(a6),Math.abs(b6))&&Math.abs(a7-b7)<=EPSILON*Math.max(1,Math.abs(a7),Math.abs(b7))&&Math.abs(a8-b8)<=EPSILON*Math.max(1,Math.abs(a8),Math.abs(b8))&&Math.abs(a9-b9)<=EPSILON*Math.max(1,Math.abs(a9),Math.abs(b9))&&Math.abs(a10-b10)<=EPSILON*Math.max(1,Math.abs(a10),Math.abs(b10))&&Math.abs(a11-b11)<=EPSILON*Math.max(1,Math.abs(a11),Math.abs(b11))&&Math.abs(a12-b12)<=EPSILON*Math.max(1,Math.abs(a12),Math.abs(b12))&&Math.abs(a13-b13)<=EPSILON*Math.max(1,Math.abs(a13),Math.abs(b13))&&Math.abs(a14-b14)<=EPSILON*Math.max(1,Math.abs(a14),Math.abs(b14))&&Math.abs(a15-b15)<=EPSILON*Math.max(1,Math.abs(a15),Math.abs(b15))},mul:mul$5,sub:subtract$3});function create$4(){var out=new ARRAY_TYPE(3);return ARRAY_TYPE!=Float32Array&&(out[0]=0,out[1]=0,out[2]=0),out}function length$4(a){var x=a[0],y=a[1],z=a[2];return Math.sqrt(x*x+y*y+z*z)}function fromValues$4(x,y,z){var out=new ARRAY_TYPE(3);return out[0]=x,out[1]=y,out[2]=z,out}function copy$4(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out}function set$4(out,x,y,z){return out[0]=x,out[1]=y,out[2]=z,out}function add$4(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out}function subtract$2(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out}function multiply$4(out,a,b){return out[0]=a[0]*b[0],out[1]=a[1]*b[1],out[2]=a[2]*b[2],out}function divide$2(out,a,b){return out[0]=a[0]/b[0],out[1]=a[1]/b[1],out[2]=a[2]/b[2],out}function scale$4(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out}function scaleAndAdd$2(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out}function distance$2(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return Math.sqrt(x*x+y*y+z*z)}function squaredDistance$2(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return x*x+y*y+z*z}function squaredLength$4(a){var x=a[0],y=a[1],z=a[2];return x*x+y*y+z*z}function normalize$4(out,a){var x=a[0],y=a[1],z=a[2],len=x*x+y*y+z*z;return len>0&&(len=1/Math.sqrt(len),out[0]=a[0]*len,out[1]=a[1]*len,out[2]=a[2]*len),out}function dot$4(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]}function cross$1(out,a,b){var ax=a[0],ay=a[1],az=a[2],bx=b[0],by=b[1],bz=b[2];return out[0]=ay*bz-az*by,out[1]=az*bx-ax*bz,out[2]=ax*by-ay*bx,out}function transformMat4$2(out,a,m){var x=a[0],y=a[1],z=a[2],w=m[3]*x+m[7]*y+m[11]*z+m[15];return out[0]=(m[0]*x+m[4]*y+m[8]*z+m[12])/(w=w||1),out[1]=(m[1]*x+m[5]*y+m[9]*z+m[13])/w,out[2]=(m[2]*x+m[6]*y+m[10]*z+m[14])/w,out}function angle$1(a,b){var tempA=fromValues$4(a[0],a[1],a[2]),tempB=fromValues$4(b[0],b[1],b[2]);normalize$4(tempA,tempA),normalize$4(tempB,tempB);var cosine=dot$4(tempA,tempB);return cosine>1?0:cosine<-1?Math.PI:Math.acos(cosine)}function equals$5(a,b){var a0=a[0],a1=a[1],a2=a[2],b0=b[0],b1=b[1],b2=b[2];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))}var vec,sub$2=subtract$2,mul$4=multiply$4,div$2=divide$2,dist$2=distance$2,sqrDist$2=squaredDistance$2,len$4=length$4,sqrLen$4=squaredLength$4,forEach$2=(vec=create$4(),function(a,stride,offset,count,fn,arg){var i=void 0,l=void 0;for(stride||(stride=3),offset||(offset=0),l=count?Math.min(count*stride+offset,a.length):a.length,i=offset;i<l;i+=stride)vec[0]=a[i],vec[1]=a[i+1],vec[2]=a[i+2],fn(vec,vec,arg),a[i]=vec[0],a[i+1]=vec[1],a[i+2]=vec[2];return a}),vec3=Object.freeze({__proto__:null,create:create$4,clone:function(a){var out=new ARRAY_TYPE(3);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out},length:length$4,fromValues:fromValues$4,copy:copy$4,set:set$4,add:add$4,subtract:subtract$2,multiply:multiply$4,divide:divide$2,ceil:function(out,a){return out[0]=Math.ceil(a[0]),out[1]=Math.ceil(a[1]),out[2]=Math.ceil(a[2]),out},floor:function(out,a){return out[0]=Math.floor(a[0]),out[1]=Math.floor(a[1]),out[2]=Math.floor(a[2]),out},min:function(out,a,b){return out[0]=Math.min(a[0],b[0]),out[1]=Math.min(a[1],b[1]),out[2]=Math.min(a[2],b[2]),out},max:function(out,a,b){return out[0]=Math.max(a[0],b[0]),out[1]=Math.max(a[1],b[1]),out[2]=Math.max(a[2],b[2]),out},round:function(out,a){return out[0]=Math.round(a[0]),out[1]=Math.round(a[1]),out[2]=Math.round(a[2]),out},scale:scale$4,scaleAndAdd:scaleAndAdd$2,distance:distance$2,squaredDistance:squaredDistance$2,squaredLength:squaredLength$4,negate:function(out,a){return out[0]=-a[0],out[1]=-a[1],out[2]=-a[2],out},inverse:function(out,a){return out[0]=1/a[0],out[1]=1/a[1],out[2]=1/a[2],out},normalize:normalize$4,dot:dot$4,cross:cross$1,lerp:function(out,a,b,t){var ax=a[0],ay=a[1],az=a[2];return out[0]=ax+t*(b[0]-ax),out[1]=ay+t*(b[1]-ay),out[2]=az+t*(b[2]-az),out},hermite:function(out,a,b,c,d,t){var factorTimes2=t*t,factor1=factorTimes2*(2*t-3)+1,factor2=factorTimes2*(t-2)+t,factor3=factorTimes2*(t-1),factor4=factorTimes2*(3-2*t);return out[0]=a[0]*factor1+b[0]*factor2+c[0]*factor3+d[0]*factor4,out[1]=a[1]*factor1+b[1]*factor2+c[1]*factor3+d[1]*factor4,out[2]=a[2]*factor1+b[2]*factor2+c[2]*factor3+d[2]*factor4,out},bezier:function(out,a,b,c,d,t){var inverseFactor=1-t,inverseFactorTimesTwo=inverseFactor*inverseFactor,factorTimes2=t*t,factor1=inverseFactorTimesTwo*inverseFactor,factor2=3*t*inverseFactorTimesTwo,factor3=3*factorTimes2*inverseFactor,factor4=factorTimes2*t;return out[0]=a[0]*factor1+b[0]*factor2+c[0]*factor3+d[0]*factor4,out[1]=a[1]*factor1+b[1]*factor2+c[1]*factor3+d[1]*factor4,out[2]=a[2]*factor1+b[2]*factor2+c[2]*factor3+d[2]*factor4,out},random:function(out,scale){scale=scale||1;var r=2*RANDOM()*Math.PI,z=2*RANDOM()-1,zScale=Math.sqrt(1-z*z)*scale;return out[0]=Math.cos(r)*zScale,out[1]=Math.sin(r)*zScale,out[2]=z*scale,out},transformMat4:transformMat4$2,transformMat3:function(out,a,m){var x=a[0],y=a[1],z=a[2];return out[0]=x*m[0]+y*m[3]+z*m[6],out[1]=x*m[1]+y*m[4]+z*m[7],out[2]=x*m[2]+y*m[5]+z*m[8],out},transformQuat:function(out,a,q){var qx=q[0],qy=q[1],qz=q[2],x=a[0],y=a[1],z=a[2],uvx=qy*z-qz*y,uvy=qz*x-qx*z,uvz=qx*y-qy*x,uuvx=qy*uvz-qz*uvy,uuvy=qz*uvx-qx*uvz,uuvz=qx*uvy-qy*uvx,w2=2*q[3];return uvy*=w2,uvz*=w2,uuvy*=2,uuvz*=2,out[0]=x+(uvx*=w2)+(uuvx*=2),out[1]=y+uvy+uuvy,out[2]=z+uvz+uuvz,out},rotateX:function(out,a,b,c){var p=[],r=[];return p[0]=a[0]-b[0],p[1]=a[1]-b[1],p[2]=a[2]-b[2],r[0]=p[0],r[1]=p[1]*Math.cos(c)-p[2]*Math.sin(c),r[2]=p[1]*Math.sin(c)+p[2]*Math.cos(c),out[0]=r[0]+b[0],out[1]=r[1]+b[1],out[2]=r[2]+b[2],out},rotateY:function(out,a,b,c){var p=[],r=[];return p[0]=a[0]-b[0],p[1]=a[1]-b[1],p[2]=a[2]-b[2],r[0]=p[2]*Math.sin(c)+p[0]*Math.cos(c),r[1]=p[1],r[2]=p[2]*Math.cos(c)-p[0]*Math.sin(c),out[0]=r[0]+b[0],out[1]=r[1]+b[1],out[2]=r[2]+b[2],out},rotateZ:function(out,a,b,c){var p=[],r=[];return p[0]=a[0]-b[0],p[1]=a[1]-b[1],p[2]=a[2]-b[2],r[0]=p[0]*Math.cos(c)-p[1]*Math.sin(c),r[1]=p[0]*Math.sin(c)+p[1]*Math.cos(c),r[2]=p[2],out[0]=r[0]+b[0],out[1]=r[1]+b[1],out[2]=r[2]+b[2],out},angle:angle$1,str:function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"},exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]},equals:equals$5,sub:sub$2,mul:mul$4,div:div$2,dist:dist$2,sqrDist:sqrDist$2,len:len$4,sqrLen:sqrLen$4,forEach:forEach$2});function create$3(){var out=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(out[0]=0,out[1]=0,out[2]=0,out[3]=0),out}function clone$3(a){var out=new ARRAY_TYPE(4);return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out}function fromValues$3(x,y,z,w){var out=new ARRAY_TYPE(4);return out[0]=x,out[1]=y,out[2]=z,out[3]=w,out}function copy$3(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out}function set$3(out,x,y,z,w){return out[0]=x,out[1]=y,out[2]=z,out[3]=w,out}function add$3(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out}function subtract$1(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out[2]=a[2]-b[2],out[3]=a[3]-b[3],out}function multiply$3(out,a,b){return out[0]=a[0]*b[0],out[1]=a[1]*b[1],out[2]=a[2]*b[2],out[3]=a[3]*b[3],out}function divide$1(out,a,b){return out[0]=a[0]/b[0],out[1]=a[1]/b[1],out[2]=a[2]/b[2],out[3]=a[3]/b[3],out}function scale$3(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out}function distance$1(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return Math.sqrt(x*x+y*y+z*z+w*w)}function squaredDistance$1(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return x*x+y*y+z*z+w*w}function length$3(a){var x=a[0],y=a[1],z=a[2],w=a[3];return Math.sqrt(x*x+y*y+z*z+w*w)}function squaredLength$3(a){var x=a[0],y=a[1],z=a[2],w=a[3];return x*x+y*y+z*z+w*w}function normalize$3(out,a){var x=a[0],y=a[1],z=a[2],w=a[3],len=x*x+y*y+z*z+w*w;return len>0&&(len=1/Math.sqrt(len),out[0]=x*len,out[1]=y*len,out[2]=z*len,out[3]=w*len),out}function dot$3(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function lerp$3(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3];return out[0]=ax+t*(b[0]-ax),out[1]=ay+t*(b[1]-ay),out[2]=az+t*(b[2]-az),out[3]=aw+t*(b[3]-aw),out}function transformMat4$1(out,a,m){var x=a[0],y=a[1],z=a[2],w=a[3];return out[0]=m[0]*x+m[4]*y+m[8]*z+m[12]*w,out[1]=m[1]*x+m[5]*y+m[9]*z+m[13]*w,out[2]=m[2]*x+m[6]*y+m[10]*z+m[14]*w,out[3]=m[3]*x+m[7]*y+m[11]*z+m[15]*w,out}function exactEquals$3(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]}function equals$4(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],b0=b[0],b1=b[1],b2=b[2],b3=b[3];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))}var sub$1=subtract$1,mul$3=multiply$3,div$1=divide$1,dist$1=distance$1,sqrDist$1=squaredDistance$1,len$3=length$3,sqrLen$3=squaredLength$3,forEach$1=function(){var vec=create$3();return function(a,stride,offset,count,fn,arg){var i=void 0,l=void 0;for(stride||(stride=4),offset||(offset=0),l=count?Math.min(count*stride+offset,a.length):a.length,i=offset;i<l;i+=stride)vec[0]=a[i],vec[1]=a[i+1],vec[2]=a[i+2],vec[3]=a[i+3],fn(vec,vec,arg),a[i]=vec[0],a[i+1]=vec[1],a[i+2]=vec[2],a[i+3]=vec[3];return a}}(),vec4=Object.freeze({__proto__:null,create:create$3,clone:clone$3,fromValues:fromValues$3,copy:copy$3,set:set$3,add:add$3,subtract:subtract$1,multiply:multiply$3,divide:divide$1,ceil:function(out,a){return out[0]=Math.ceil(a[0]),out[1]=Math.ceil(a[1]),out[2]=Math.ceil(a[2]),out[3]=Math.ceil(a[3]),out},floor:function(out,a){return out[0]=Math.floor(a[0]),out[1]=Math.floor(a[1]),out[2]=Math.floor(a[2]),out[3]=Math.floor(a[3]),out},min:function(out,a,b){return out[0]=Math.min(a[0],b[0]),out[1]=Math.min(a[1],b[1]),out[2]=Math.min(a[2],b[2]),out[3]=Math.min(a[3],b[3]),out},max:function(out,a,b){return out[0]=Math.max(a[0],b[0]),out[1]=Math.max(a[1],b[1]),out[2]=Math.max(a[2],b[2]),out[3]=Math.max(a[3],b[3]),out},round:function(out,a){return out[0]=Math.round(a[0]),out[1]=Math.round(a[1]),out[2]=Math.round(a[2]),out[3]=Math.round(a[3]),out},scale:scale$3,scaleAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out[2]=a[2]+b[2]*scale,out[3]=a[3]+b[3]*scale,out},distance:distance$1,squaredDistance:squaredDistance$1,length:length$3,squaredLength:squaredLength$3,negate:function(out,a){return out[0]=-a[0],out[1]=-a[1],out[2]=-a[2],out[3]=-a[3],out},inverse:function(out,a){return out[0]=1/a[0],out[1]=1/a[1],out[2]=1/a[2],out[3]=1/a[3],out},normalize:normalize$3,dot:dot$3,lerp:lerp$3,random:function(out,scale){var v1,v2,v3,v4,s1,s2;scale=scale||1;do{s1=(v1=2*RANDOM()-1)*v1+(v2=2*RANDOM()-1)*v2}while(s1>=1);do{s2=(v3=2*RANDOM()-1)*v3+(v4=2*RANDOM()-1)*v4}while(s2>=1);var d=Math.sqrt((1-s1)/s2);return out[0]=scale*v1,out[1]=scale*v2,out[2]=scale*v3*d,out[3]=scale*v4*d,out},transformMat4:transformMat4$1,transformQuat:function(out,a,q){var x=a[0],y=a[1],z=a[2],qx=q[0],qy=q[1],qz=q[2],qw=q[3],ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;return out[0]=ix*qw+iw*-qx+iy*-qz-iz*-qy,out[1]=iy*qw+iw*-qy+iz*-qx-ix*-qz,out[2]=iz*qw+iw*-qz+ix*-qy-iy*-qx,out[3]=a[3],out},str:function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},exactEquals:exactEquals$3,equals:equals$4,sub:sub$1,mul:mul$3,div:div$1,dist:dist$1,sqrDist:sqrDist$1,len:len$3,sqrLen:sqrLen$3,forEach:forEach$1});function create$2(){var out=new ARRAY_TYPE(4);return ARRAY_TYPE!=Float32Array&&(out[0]=0,out[1]=0,out[2]=0),out[3]=1,out}function identity$1(out){return out[0]=0,out[1]=0,out[2]=0,out[3]=1,out}function setAxisAngle(out,axis,rad){rad*=.5;var s=Math.sin(rad);return out[0]=s*axis[0],out[1]=s*axis[1],out[2]=s*axis[2],out[3]=Math.cos(rad),out}function multiply$2(out,a,b){var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];return out[0]=ax*bw+aw*bx+ay*bz-az*by,out[1]=ay*bw+aw*by+az*bx-ax*bz,out[2]=az*bw+aw*bz+ax*by-ay*bx,out[3]=aw*bw-ax*bx-ay*by-az*bz,out}function rotateX$1(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=Math.sin(rad),bw=Math.cos(rad);return out[0]=ax*bw+aw*bx,out[1]=ay*bw+az*bx,out[2]=az*bw-ay*bx,out[3]=aw*bw-ax*bx,out}function rotateY$1(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],by=Math.sin(rad),bw=Math.cos(rad);return out[0]=ax*bw-az*by,out[1]=ay*bw+aw*by,out[2]=az*bw+ax*by,out[3]=aw*bw-ay*by,out}function rotateZ$1(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],bz=Math.sin(rad),bw=Math.cos(rad);return out[0]=ax*bw+ay*bz,out[1]=ay*bw-ax*bz,out[2]=az*bw+aw*bz,out[3]=aw*bw-az*bz,out}function slerp(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3],omega=void 0,cosom=void 0,sinom=void 0,scale0=void 0,scale1=void 0;return(cosom=ax*bx+ay*by+az*bz+aw*bw)<0&&(cosom=-cosom,bx=-bx,by=-by,bz=-bz,bw=-bw),1-cosom>EPSILON?(omega=Math.acos(cosom),sinom=Math.sin(omega),scale0=Math.sin((1-t)*omega)/sinom,scale1=Math.sin(t*omega)/sinom):(scale0=1-t,scale1=t),out[0]=scale0*ax+scale1*bx,out[1]=scale0*ay+scale1*by,out[2]=scale0*az+scale1*bz,out[3]=scale0*aw+scale1*bw,out}function fromMat3(out,m){var fTrace=m[0]+m[4]+m[8],fRoot=void 0;if(fTrace>0)fRoot=Math.sqrt(fTrace+1),out[3]=.5*fRoot,out[0]=(m[5]-m[7])*(fRoot=.5/fRoot),out[1]=(m[6]-m[2])*fRoot,out[2]=(m[1]-m[3])*fRoot;else{var i=0;m[4]>m[0]&&(i=1),m[8]>m[3*i+i]&&(i=2);var j=(i+1)%3,k=(i+2)%3;fRoot=Math.sqrt(m[3*i+i]-m[3*j+j]-m[3*k+k]+1),out[i]=.5*fRoot,out[3]=(m[3*j+k]-m[3*k+j])*(fRoot=.5/fRoot),out[j]=(m[3*j+i]+m[3*i+j])*fRoot,out[k]=(m[3*k+i]+m[3*i+k])*fRoot}return out}function fromEuler(out,x,y,z){var halfToRad=.5*Math.PI/180;x*=halfToRad,y*=halfToRad,z*=halfToRad;var sx=Math.sin(x),cx=Math.cos(x),sy=Math.sin(y),cy=Math.cos(y),sz=Math.sin(z),cz=Math.cos(z);return out[0]=sx*cy*cz-cx*sy*sz,out[1]=cx*sy*cz+sx*cy*sz,out[2]=cx*cy*sz-sx*sy*cz,out[3]=cx*cy*cz+sx*sy*sz,out}var tmpvec3,xUnitVec3,yUnitVec3,temp1,temp2,matr,clone$2=clone$3,fromValues$2=fromValues$3,copy$2=copy$3,set$2=set$3,add$2=add$3,mul$2=multiply$2,scale$2=scale$3,dot$2=dot$3,lerp$2=lerp$3,length$2=length$3,len$2=length$2,squaredLength$2=squaredLength$3,sqrLen$2=squaredLength$2,normalize$2=normalize$3,exactEquals$2=exactEquals$3,equals$3=equals$4,rotationTo=(tmpvec3=create$4(),xUnitVec3=fromValues$4(1,0,0),yUnitVec3=fromValues$4(0,1,0),function(out,a,b){var dot=dot$4(a,b);return dot<-.999999?(cross$1(tmpvec3,xUnitVec3,a),len$4(tmpvec3)<1e-6&&cross$1(tmpvec3,yUnitVec3,a),normalize$4(tmpvec3,tmpvec3),setAxisAngle(out,tmpvec3,Math.PI),out):dot>.999999?(out[0]=0,out[1]=0,out[2]=0,out[3]=1,out):(cross$1(tmpvec3,a,b),out[0]=tmpvec3[0],out[1]=tmpvec3[1],out[2]=tmpvec3[2],out[3]=1+dot,normalize$2(out,out))}),sqlerp=(temp1=create$2(),temp2=create$2(),function(out,a,b,c,d,t){return slerp(temp1,a,d,t),slerp(temp2,b,c,t),slerp(out,temp1,temp2,2*t*(1-t)),out}),setAxes=(matr=create$6(),function(out,view,right,up){return matr[0]=right[0],matr[3]=right[1],matr[6]=right[2],matr[1]=up[0],matr[4]=up[1],matr[7]=up[2],matr[2]=-view[0],matr[5]=-view[1],matr[8]=-view[2],normalize$2(out,fromMat3(out,matr))}),quat=Object.freeze({__proto__:null,create:create$2,identity:identity$1,setAxisAngle,getAxisAngle:function(out_axis,q){var rad=2*Math.acos(q[3]),s=Math.sin(rad/2);return s>EPSILON?(out_axis[0]=q[0]/s,out_axis[1]=q[1]/s,out_axis[2]=q[2]/s):(out_axis[0]=1,out_axis[1]=0,out_axis[2]=0),rad},multiply:multiply$2,rotateX:rotateX$1,rotateY:rotateY$1,rotateZ:rotateZ$1,calculateW:function(out,a){var x=a[0],y=a[1],z=a[2];return out[0]=x,out[1]=y,out[2]=z,out[3]=Math.sqrt(Math.abs(1-x*x-y*y-z*z)),out},slerp,random:function(out){var u1=RANDOM(),u2=RANDOM(),u3=RANDOM(),sqrt1MinusU1=Math.sqrt(1-u1),sqrtU1=Math.sqrt(u1);return out[0]=sqrt1MinusU1*Math.sin(2*Math.PI*u2),out[1]=sqrt1MinusU1*Math.cos(2*Math.PI*u2),out[2]=sqrtU1*Math.sin(2*Math.PI*u3),out[3]=sqrtU1*Math.cos(2*Math.PI*u3),out},invert:function(out,a){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],dot=a0*a0+a1*a1+a2*a2+a3*a3,invDot=dot?1/dot:0;return out[0]=-a0*invDot,out[1]=-a1*invDot,out[2]=-a2*invDot,out[3]=a3*invDot,out},conjugate:function(out,a){return out[0]=-a[0],out[1]=-a[1],out[2]=-a[2],out[3]=a[3],out},fromMat3,fromEuler,str:function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"},clone:clone$2,fromValues:fromValues$2,copy:copy$2,set:set$2,add:add$2,mul:mul$2,scale:scale$2,dot:dot$2,lerp:lerp$2,length:length$2,len:len$2,squaredLength:squaredLength$2,sqrLen:sqrLen$2,normalize:normalize$2,exactEquals:exactEquals$2,equals:equals$3,rotationTo,sqlerp,setAxes});function fromRotationTranslation(out,q,t){var ax=.5*t[0],ay=.5*t[1],az=.5*t[2],bx=q[0],by=q[1],bz=q[2],bw=q[3];return out[0]=bx,out[1]=by,out[2]=bz,out[3]=bw,out[4]=ax*bw+ay*bz-az*by,out[5]=ay*bw+az*bx-ax*bz,out[6]=az*bw+ax*by-ay*bx,out[7]=-ax*bx-ay*by-az*bz,out}function copy$1(out,a){return out[0]=a[0],out[1]=a[1],out[2]=a[2],out[3]=a[3],out[4]=a[4],out[5]=a[5],out[6]=a[6],out[7]=a[7],out}function multiply$1(out,a,b){var ax0=a[0],ay0=a[1],az0=a[2],aw0=a[3],bx1=b[4],by1=b[5],bz1=b[6],bw1=b[7],ax1=a[4],ay1=a[5],az1=a[6],aw1=a[7],bx0=b[0],by0=b[1],bz0=b[2],bw0=b[3];return out[0]=ax0*bw0+aw0*bx0+ay0*bz0-az0*by0,out[1]=ay0*bw0+aw0*by0+az0*bx0-ax0*bz0,out[2]=az0*bw0+aw0*bz0+ax0*by0-ay0*bx0,out[3]=aw0*bw0-ax0*bx0-ay0*by0-az0*bz0,out[4]=ax0*bw1+aw0*bx1+ay0*bz1-az0*by1+ax1*bw0+aw1*bx0+ay1*bz0-az1*by0,out[5]=ay0*bw1+aw0*by1+az0*bx1-ax0*bz1+ay1*bw0+aw1*by0+az1*bx0-ax1*bz0,out[6]=az0*bw1+aw0*bz1+ax0*by1-ay0*bx1+az1*bw0+aw1*bz0+ax1*by0-ay1*bx0,out[7]=aw0*bw1-ax0*bx1-ay0*by1-az0*bz1+aw1*bw0-ax1*bx0-ay1*by0-az1*bz0,out}var dot$1=dot$2;var squaredLength$1=squaredLength$2;var quat2=Object.freeze({__proto__:null,create:function(){var dq=new ARRAY_TYPE(8);return ARRAY_TYPE!=Float32Array&&(dq[0]=0,dq[1]=0,dq[2]=0,dq[4]=0,dq[5]=0,dq[6]=0,dq[7]=0),dq[3]=1,dq},clone:function(a){var dq=new ARRAY_TYPE(8);return dq[0]=a[0],dq[1]=a[1],dq[2]=a[2],dq[3]=a[3],dq[4]=a[4],dq[5]=a[5],dq[6]=a[6],dq[7]=a[7],dq},fromValues:function(x1,y1,z1,w1,x2,y2,z2,w2){var dq=new ARRAY_TYPE(8);return dq[0]=x1,dq[1]=y1,dq[2]=z1,dq[3]=w1,dq[4]=x2,dq[5]=y2,dq[6]=z2,dq[7]=w2,dq},fromRotationTranslationValues:function(x1,y1,z1,w1,x2,y2,z2){var dq=new ARRAY_TYPE(8);dq[0]=x1,dq[1]=y1,dq[2]=z1,dq[3]=w1;var ax=.5*x2,ay=.5*y2,az=.5*z2;return dq[4]=ax*w1+ay*z1-az*y1,dq[5]=ay*w1+az*x1-ax*z1,dq[6]=az*w1+ax*y1-ay*x1,dq[7]=-ax*x1-ay*y1-az*z1,dq},fromRotationTranslation,fromTranslation:function(out,t){return out[0]=0,out[1]=0,out[2]=0,out[3]=1,out[4]=.5*t[0],out[5]=.5*t[1],out[6]=.5*t[2],out[7]=0,out},fromRotation:function(out,q){return out[0]=q[0],out[1]=q[1],out[2]=q[2],out[3]=q[3],out[4]=0,out[5]=0,out[6]=0,out[7]=0,out},fromMat4:function(out,a){var outer=create$2();getRotation(outer,a);var t=new ARRAY_TYPE(3);return getTranslation$1(t,a),fromRotationTranslation(out,outer,t),out},copy:copy$1,identity:function(out){return out[0]=0,out[1]=0,out[2]=0,out[3]=1,out[4]=0,out[5]=0,out[6]=0,out[7]=0,out},set:function(out,x1,y1,z1,w1,x2,y2,z2,w2){return out[0]=x1,out[1]=y1,out[2]=z1,out[3]=w1,out[4]=x2,out[5]=y2,out[6]=z2,out[7]=w2,out},getReal:copy$2,getDual:function(out,a){return out[0]=a[4],out[1]=a[5],out[2]=a[6],out[3]=a[7],out},setReal:copy$2,setDual:function(out,q){return out[4]=q[0],out[5]=q[1],out[6]=q[2],out[7]=q[3],out},getTranslation:function(out,a){var ax=a[4],ay=a[5],az=a[6],aw=a[7],bx=-a[0],by=-a[1],bz=-a[2],bw=a[3];return out[0]=2*(ax*bw+aw*bx+ay*bz-az*by),out[1]=2*(ay*bw+aw*by+az*bx-ax*bz),out[2]=2*(az*bw+aw*bz+ax*by-ay*bx),out},translate:function(out,a,v){var ax1=a[0],ay1=a[1],az1=a[2],aw1=a[3],bx1=.5*v[0],by1=.5*v[1],bz1=.5*v[2],ax2=a[4],ay2=a[5],az2=a[6],aw2=a[7];return out[0]=ax1,out[1]=ay1,out[2]=az1,out[3]=aw1,out[4]=aw1*bx1+ay1*bz1-az1*by1+ax2,out[5]=aw1*by1+az1*bx1-ax1*bz1+ay2,out[6]=aw1*bz1+ax1*by1-ay1*bx1+az2,out[7]=-ax1*bx1-ay1*by1-az1*bz1+aw2,out},rotateX:function(out,a,rad){var bx=-a[0],by=-a[1],bz=-a[2],bw=a[3],ax=a[4],ay=a[5],az=a[6],aw=a[7],ax1=ax*bw+aw*bx+ay*bz-az*by,ay1=ay*bw+aw*by+az*bx-ax*bz,az1=az*bw+aw*bz+ax*by-ay*bx,aw1=aw*bw-ax*bx-ay*by-az*bz;return rotateX$1(out,a,rad),out[4]=ax1*(bw=out[3])+aw1*(bx=out[0])+ay1*(bz=out[2])-az1*(by=out[1]),out[5]=ay1*bw+aw1*by+az1*bx-ax1*bz,out[6]=az1*bw+aw1*bz+ax1*by-ay1*bx,out[7]=aw1*bw-ax1*bx-ay1*by-az1*bz,out},rotateY:function(out,a,rad){var bx=-a[0],by=-a[1],bz=-a[2],bw=a[3],ax=a[4],ay=a[5],az=a[6],aw=a[7],ax1=ax*bw+aw*bx+ay*bz-az*by,ay1=ay*bw+aw*by+az*bx-ax*bz,az1=az*bw+aw*bz+ax*by-ay*bx,aw1=aw*bw-ax*bx-ay*by-az*bz;return rotateY$1(out,a,rad),out[4]=ax1*(bw=out[3])+aw1*(bx=out[0])+ay1*(bz=out[2])-az1*(by=out[1]),out[5]=ay1*bw+aw1*by+az1*bx-ax1*bz,out[6]=az1*bw+aw1*bz+ax1*by-ay1*bx,out[7]=aw1*bw-ax1*bx-ay1*by-az1*bz,out},rotateZ:function(out,a,rad){var bx=-a[0],by=-a[1],bz=-a[2],bw=a[3],ax=a[4],ay=a[5],az=a[6],aw=a[7],ax1=ax*bw+aw*bx+ay*bz-az*by,ay1=ay*bw+aw*by+az*bx-ax*bz,az1=az*bw+aw*bz+ax*by-ay*bx,aw1=aw*bw-ax*bx-ay*by-az*bz;return rotateZ$1(out,a,rad),out[4]=ax1*(bw=out[3])+aw1*(bx=out[0])+ay1*(bz=out[2])-az1*(by=out[1]),out[5]=ay1*bw+aw1*by+az1*bx-ax1*bz,out[6]=az1*bw+aw1*bz+ax1*by-ay1*bx,out[7]=aw1*bw-ax1*bx-ay1*by-az1*bz,out},rotateByQuatAppend:function(out,a,q){var qx=q[0],qy=q[1],qz=q[2],qw=q[3],ax=a[0],ay=a[1],az=a[2],aw=a[3];return out[0]=ax*qw+aw*qx+ay*qz-az*qy,out[1]=ay*qw+aw*qy+az*qx-ax*qz,out[2]=az*qw+aw*qz+ax*qy-ay*qx,out[3]=aw*qw-ax*qx-ay*qy-az*qz,out[4]=(ax=a[4])*qw+(aw=a[7])*qx+(ay=a[5])*qz-(az=a[6])*qy,out[5]=ay*qw+aw*qy+az*qx-ax*qz,out[6]=az*qw+aw*qz+ax*qy-ay*qx,out[7]=aw*qw-ax*qx-ay*qy-az*qz,out},rotateByQuatPrepend:function(out,q,a){var qx=q[0],qy=q[1],qz=q[2],qw=q[3],bx=a[0],by=a[1],bz=a[2],bw=a[3];return out[0]=qx*bw+qw*bx+qy*bz-qz*by,out[1]=qy*bw+qw*by+qz*bx-qx*bz,out[2]=qz*bw+qw*bz+qx*by-qy*bx,out[3]=qw*bw-qx*bx-qy*by-qz*bz,out[4]=qx*(bw=a[7])+qw*(bx=a[4])+qy*(bz=a[6])-qz*(by=a[5]),out[5]=qy*bw+qw*by+qz*bx-qx*bz,out[6]=qz*bw+qw*bz+qx*by-qy*bx,out[7]=qw*bw-qx*bx-qy*by-qz*bz,out},rotateAroundAxis:function(out,a,axis,rad){if(Math.abs(rad)<EPSILON)return copy$1(out,a);var axisLength=Math.sqrt(axis[0]*axis[0]+axis[1]*axis[1]+axis[2]*axis[2]);rad*=.5;var s=Math.sin(rad),bx=s*axis[0]/axisLength,by=s*axis[1]/axisLength,bz=s*axis[2]/axisLength,bw=Math.cos(rad),ax1=a[0],ay1=a[1],az1=a[2],aw1=a[3];out[0]=ax1*bw+aw1*bx+ay1*bz-az1*by,out[1]=ay1*bw+aw1*by+az1*bx-ax1*bz,out[2]=az1*bw+aw1*bz+ax1*by-ay1*bx,out[3]=aw1*bw-ax1*bx-ay1*by-az1*bz;var ax=a[4],ay=a[5],az=a[6],aw=a[7];return out[4]=ax*bw+aw*bx+ay*bz-az*by,out[5]=ay*bw+aw*by+az*bx-ax*bz,out[6]=az*bw+aw*bz+ax*by-ay*bx,out[7]=aw*bw-ax*bx-ay*by-az*bz,out},add:function(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out[2]=a[2]+b[2],out[3]=a[3]+b[3],out[4]=a[4]+b[4],out[5]=a[5]+b[5],out[6]=a[6]+b[6],out[7]=a[7]+b[7],out},multiply:multiply$1,mul:multiply$1,scale:function(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out[2]=a[2]*b,out[3]=a[3]*b,out[4]=a[4]*b,out[5]=a[5]*b,out[6]=a[6]*b,out[7]=a[7]*b,out},dot:dot$1,lerp:function(out,a,b,t){var mt=1-t;return dot$1(a,b)<0&&(t=-t),out[0]=a[0]*mt+b[0]*t,out[1]=a[1]*mt+b[1]*t,out[2]=a[2]*mt+b[2]*t,out[3]=a[3]*mt+b[3]*t,out[4]=a[4]*mt+b[4]*t,out[5]=a[5]*mt+b[5]*t,out[6]=a[6]*mt+b[6]*t,out[7]=a[7]*mt+b[7]*t,out},invert:function(out,a){var sqlen=squaredLength$1(a);return out[0]=-a[0]/sqlen,out[1]=-a[1]/sqlen,out[2]=-a[2]/sqlen,out[3]=a[3]/sqlen,out[4]=-a[4]/sqlen,out[5]=-a[5]/sqlen,out[6]=-a[6]/sqlen,out[7]=a[7]/sqlen,out},conjugate:function(out,a){return out[0]=-a[0],out[1]=-a[1],out[2]=-a[2],out[3]=a[3],out[4]=-a[4],out[5]=-a[5],out[6]=-a[6],out[7]=a[7],out},length:length$2,len:length$2,squaredLength:squaredLength$1,sqrLen:squaredLength$1,normalize:function(out,a){var magnitude=squaredLength$1(a);if(magnitude>0){magnitude=Math.sqrt(magnitude);var a0=a[0]/magnitude,a1=a[1]/magnitude,a2=a[2]/magnitude,a3=a[3]/magnitude,b0=a[4],b1=a[5],b2=a[6],b3=a[7],a_dot_b=a0*b0+a1*b1+a2*b2+a3*b3;out[0]=a0,out[1]=a1,out[2]=a2,out[3]=a3,out[4]=(b0-a0*a_dot_b)/magnitude,out[5]=(b1-a1*a_dot_b)/magnitude,out[6]=(b2-a2*a_dot_b)/magnitude,out[7]=(b3-a3*a_dot_b)/magnitude}return out},str:function(a){return"quat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+")"},exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2]&&a[3]===b[3]&&a[4]===b[4]&&a[5]===b[5]&&a[6]===b[6]&&a[7]===b[7]},equals:function(a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],a4=a[4],a5=a[5],a6=a[6],a7=a[7],b0=b[0],b1=b[1],b2=b[2],b3=b[3],b4=b[4],b5=b[5],b6=b[6],b7=b[7];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1,Math.abs(a2),Math.abs(b2))&&Math.abs(a3-b3)<=EPSILON*Math.max(1,Math.abs(a3),Math.abs(b3))&&Math.abs(a4-b4)<=EPSILON*Math.max(1,Math.abs(a4),Math.abs(b4))&&Math.abs(a5-b5)<=EPSILON*Math.max(1,Math.abs(a5),Math.abs(b5))&&Math.abs(a6-b6)<=EPSILON*Math.max(1,Math.abs(a6),Math.abs(b6))&&Math.abs(a7-b7)<=EPSILON*Math.max(1,Math.abs(a7),Math.abs(b7))}});function create(){var out=new ARRAY_TYPE(2);return ARRAY_TYPE!=Float32Array&&(out[0]=0,out[1]=0),out}function copy(out,a){return out[0]=a[0],out[1]=a[1],out}function set(out,x,y){return out[0]=x,out[1]=y,out}function add(out,a,b){return out[0]=a[0]+b[0],out[1]=a[1]+b[1],out}function subtract(out,a,b){return out[0]=a[0]-b[0],out[1]=a[1]-b[1],out}function multiply(out,a,b){return out[0]=a[0]*b[0],out[1]=a[1]*b[1],out}function divide(out,a,b){return out[0]=a[0]/b[0],out[1]=a[1]/b[1],out}function scale(out,a,b){return out[0]=a[0]*b,out[1]=a[1]*b,out}function distance(a,b){var x=b[0]-a[0],y=b[1]-a[1];return Math.sqrt(x*x+y*y)}function squaredDistance(a,b){var x=b[0]-a[0],y=b[1]-a[1];return x*x+y*y}function length(a){var x=a[0],y=a[1];return Math.sqrt(x*x+y*y)}function squaredLength(a){var x=a[0],y=a[1];return x*x+y*y}function transformMat2(out,a,m){var x=a[0],y=a[1];return out[0]=m[0]*x+m[2]*y,out[1]=m[1]*x+m[3]*y,out}function rotate(out,a,b,c){var p0=a[0]-b[0],p1=a[1]-b[1],sinC=Math.sin(c),cosC=Math.cos(c);return out[0]=p0*cosC-p1*sinC+b[0],out[1]=p0*sinC+p1*cosC+b[1],out}var len=length,sub=subtract,mul=multiply,div=divide,dist=distance,sqrDist=squaredDistance,sqrLen=squaredLength,forEach=function(){var vec=create();return function(a,stride,offset,count,fn,arg){var i=void 0,l=void 0;for(stride||(stride=2),offset||(offset=0),l=count?Math.min(count*stride+offset,a.length):a.length,i=offset;i<l;i+=stride)vec[0]=a[i],vec[1]=a[i+1],fn(vec,vec,arg),a[i]=vec[0],a[i+1]=vec[1];return a}}(),vec2=Object.freeze({__proto__:null,create,clone:function(a){var out=new ARRAY_TYPE(2);return out[0]=a[0],out[1]=a[1],out},fromValues:function(x,y){var out=new ARRAY_TYPE(2);return out[0]=x,out[1]=y,out},copy,set,add,subtract,multiply,divide,ceil:function(out,a){return out[0]=Math.ceil(a[0]),out[1]=Math.ceil(a[1]),out},floor:function(out,a){return out[0]=Math.floor(a[0]),out[1]=Math.floor(a[1]),out},min:function(out,a,b){return out[0]=Math.min(a[0],b[0]),out[1]=Math.min(a[1],b[1]),out},max:function(out,a,b){return out[0]=Math.max(a[0],b[0]),out[1]=Math.max(a[1],b[1]),out},round:function(out,a){return out[0]=Math.round(a[0]),out[1]=Math.round(a[1]),out},scale,scaleAndAdd:function(out,a,b,scale){return out[0]=a[0]+b[0]*scale,out[1]=a[1]+b[1]*scale,out},distance,squaredDistance,length,squaredLength,negate:function(out,a){return out[0]=-a[0],out[1]=-a[1],out},inverse:function(out,a){return out[0]=1/a[0],out[1]=1/a[1],out},normalize:function(out,a){var x=a[0],y=a[1],len=x*x+y*y;return len>0&&(len=1/Math.sqrt(len),out[0]=a[0]*len,out[1]=a[1]*len),out},dot:function(a,b){return a[0]*b[0]+a[1]*b[1]},cross:function(out,a,b){var z=a[0]*b[1]-a[1]*b[0];return out[0]=out[1]=0,out[2]=z,out},lerp:function(out,a,b,t){var ax=a[0],ay=a[1];return out[0]=ax+t*(b[0]-ax),out[1]=ay+t*(b[1]-ay),out},random:function(out,scale){scale=scale||1;var r=2*RANDOM()*Math.PI;return out[0]=Math.cos(r)*scale,out[1]=Math.sin(r)*scale,out},transformMat2,transformMat2d:function(out,a,m){var x=a[0],y=a[1];return out[0]=m[0]*x+m[2]*y+m[4],out[1]=m[1]*x+m[3]*y+m[5],out},transformMat3:function(out,a,m){var x=a[0],y=a[1];return out[0]=m[0]*x+m[3]*y+m[6],out[1]=m[1]*x+m[4]*y+m[7],out},transformMat4:function(out,a,m){var x=a[0],y=a[1];return out[0]=m[0]*x+m[4]*y+m[12],out[1]=m[1]*x+m[5]*y+m[13],out},rotate,angle:function(a,b){var x1=a[0],y1=a[1],x2=b[0],y2=b[1],len1=x1*x1+y1*y1;len1>0&&(len1=1/Math.sqrt(len1));var len2=x2*x2+y2*y2;len2>0&&(len2=1/Math.sqrt(len2));var cosine=(x1*x2+y1*y2)*len1*len2;return cosine>1?0:cosine<-1?Math.PI:Math.acos(cosine)},str:function(a){return"vec2("+a[0]+", "+a[1]+")"},exactEquals:function(a,b){return a[0]===b[0]&&a[1]===b[1]},equals:function(a,b){var a0=a[0],a1=a[1],b0=b[0],b1=b[1];return Math.abs(a0-b0)<=EPSILON*Math.max(1,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1,Math.abs(a1),Math.abs(b1))},len,sub,mul,div,dist,sqrDist,sqrLen,forEach});
/*!
	 * @maptalks/gltf-loader v0.95.2
	 * LICENSE : UNLICENSED
	 * (c) 2016-2023 maptalks.org
	 */
let n$1=0;function i$3(e){return null==e}function a$1(e){return!i$3(e)}function o$1(e){return!i$3(e)&&("string"==typeof e||null!==e.constructor&&e.constructor===String)}function f$4(e){for(let t=1;t<arguments.length;t++){const s=arguments[t];for(const t in s)e[t]=s[t]}return e}function u$4(e){switch(e){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView's component type: "+e)}function h$3(e){return 0===e.indexOf("data:")&&e.indexOf("base64,")>0}function c$2(e){const t=function(e){return"undefined"!=typeof self?self.atob(e):window.atob(e)}(e.substring(e.indexOf(",")+1)),s=t.length,r=new Uint8Array(s);for(let e=0;e<s;e++)r[e]=t.charCodeAt(e);return r.buffer}const l$2=[],m$4=[],d$3=[],g$2=[0,0,0],p$6=identity$1([]),b$6=[1,1,1];function y$5(e,t,s,r,n,i,a){const o=u$4(a);if((0===n||n===r*o.BYTES_PER_ELEMENT)&&i%o.BYTES_PER_ELEMENT==0){const n=new o(t,i,s*r);return e.set(n),e}0===n&&(n=r*o.BYTES_PER_ELEMENT);const f=new Uint8Array(r*o.BYTES_PER_ELEMENT);for(let a=0;a<s;a++){let s=null;const u=new Uint8Array(t,n*a+i,r*o.BYTES_PER_ELEMENT);f.set(u),s=new o(f.buffer,0,r);for(let t=0;t<r;t++)e[a*r+t]=s[t]}return e}const _$7="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function x$7(e,t,s){const r=new Uint8Array(e,t,s);return _$7.decode(r)}const w$5={get:function(e,t={}){t||(t={});const s=new AbortController,r=s.signal,n=f$4({},t);n.signal=r,n.method||(n.method="GET");const i=fetch(e,n).then((e=>{const s=this._parseResponse(e,t.responseType);return s.message?s:s.then((s=>"arraybuffer"===t.responseType?{data:s,cacheControl:e.headers.get("Cache-Control"),expires:e.headers.get("Expires"),contentType:e.headers.get("Content-Type")}:s)).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}))})).catch((e=>{if(!e.code||e.code!==DOMException.ABORT_ERR)throw e}));return i.xhr=s,i},_parseResponse:(e,t)=>200!==e.status?{status:e.status,statusText:e.statusText,message:`incorrect http request with status code(${e.status}): ${e.statusText}`}:"arraybuffer"===t?e.arrayBuffer():"json"===t?e.json():e.text(),getArrayBuffer:(e,t={})=>(t||(t={}),t.responseType="arraybuffer",w$5.get(e,t)),getJSON:function(e,t={}){return t&&t.jsonp?w$5.jsonp(e):((t=t||{}).responseType="json",w$5.get(e,t))},jsonp:function(e){const t="_maptalks_jsonp_"+n$1++;e.match(/\?/)?e+="&callback="+t:e+="?callback="+t;let s=document.createElement("script");return s.type="text/javascript",s.src=e,new Promise((e=>{window[t]=function(r){document.getElementsByTagName("head")[0].removeChild(s),s=null,delete window[t],e(r)},document.getElementsByTagName("head")[0].appendChild(s)}))}};class T$7{constructor(e,t,s,r){this._requestImage=e,this.decoders=t,this._supportedFormats=s,this.images={},this._imgRequests={},this._fetchOptions=r||{}}requestImageFromBufferURI(e,t,s){if(this.buffers[e.id]){const n=this._createDataView(t,this.buffers[e.id]);return this.getImageByBuffer(n,s)}if(this._imgRequests[e.id])return this._imgRequests[e.id].then((()=>{const n=this._createDataView(t,this.buffers[e.id]);return this.getImageByBuffer(n,s)}));if(h$3(e.uri)){const r=this.buffers[e.id]=c$2(e.uri),n=this._createDataView(t,r);return this.getImageByBuffer(n,s)}let r;const n=e.uri.indexOf("blob:")>=0;return r=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this._imgRequests[e.id]=w$5.getArrayBuffer(r,this._fetchOptions).then((r=>{const n=this.buffers[e.id]=r.data,i=this._createDataView(t,n);return this.getImageByBuffer(i,s)}))}getImageByBuffer(e,t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const s=this.decoders;return s[t.mimeType]?s[t.mimeType](e,{supportedFormats:this._supportedFormats}):"image/crn"===t.mimeType||"image/ktx2"===t.mimeType||"image/cttf"===t.mimeType?(console.warn("missing transcoder for "+t.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this._getImageInfo(t.id,e)}requestExternalImage(e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const t=0===e.uri.indexOf("data:image/")?e.uri:this.rootPath+"/"+e.uri;return this._imgRequests[e.id]?this._imgRequests[e.id].then((()=>this.images[e.id])):this._imgRequests[e.id]=this._getImageInfo(e.id,t)}_getImageInfo(e,t){return new Promise(((s,r)=>{this._requestImage(t,this._fetchOptions,((n,i)=>{n?r(n):(URL.revokeObjectURL(t),this.images[e]=i,s(this.images[e]))}))}))}}const E$7=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],O$7=[];class I$6{constructor(e,t,s,r){this.rootPath=e,this.gltf=t,this._enableInterleave=!1,this.glbBuffer=s,this.buffers={},this.requests={},this.accessors={},this._compareAccessor(),this._fetchOptions=r}_requestData(e,t){const s=this.gltf,r=s.accessors[t];if(void 0===r.bufferView)return this.accessors[r.id]=this._toBufferData(e,t,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);return this._requestBufferOfBufferView(s.bufferViews[r.bufferView]).then((s=>{const{buffer:n,byteOffset:i}=s;return this.accessors[r.id]=this._toBufferData(e,t,n,i)}))}_requestBufferOfBufferView(e){const t=this.gltf.buffers[e.buffer];if(this.buffers[t.id]){return Promise.resolve({buffer:this.buffers[t.id],byteOffset:0})}if(this.requests[t.id])return this.requests[t.id].then((()=>Promise.resolve({buffer:this.buffers[t.id],byteOffset:0})));if("binary_glTF"!==e.buffer&&"KHR_binary_glTF"!==e.buffer&&t.uri){if(h$3(t.uri)){const e=this.buffers[t.id]=c$2(t.uri);return Promise.resolve({buffer:e,byteOffset:0})}let e;const s=t.uri.indexOf("blob:")>=0;return e=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.requests[t.id]=w$5.getArrayBuffer(e,this._fetchOptions).then((r=>(s&&URL.revokeObjectURL(e),{buffer:this.buffers[t.id]=r.data,byteOffset:0})))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_toBufferData(e,t,r,n=0){const i=this.gltf,a=i.accessors[t],o=void 0!==a.bufferView?i.bufferViews[a.bufferView]:{},f=(o.byteOffset||0)+n,h=this._getTypeItemSize(a.type),c=u$4(a.componentType),l=o.byteStride||0,m={array:void 0,name:e,accessorName:t,byteLength:a.count*h*c.BYTES_PER_ELEMENT,componentType:a.componentType,count:a.count,type:a.type,itemSize:h,max:a.max,min:a.min,extensions:a.extensions};if(a.min&&(m.min=a.min),a.max&&(m.max=a.max),r)if(this._enableInterleave)m.byteStride=l,m.byteOffset=f+(a.byteOffset||0),!l||l===h*c.BYTES_PER_ELEMENT||"indices"===e||"input"===e||"output"===e||e.indexOf("morph")>=0?(m.array=this._typedArray(r,a.count,h,f+(a.byteOffset||0),c),m.array.buffer.byteLength===m.byteLength&&(m.byteOffset=0)):m.array=new Uint8Array(r,f,o.byteLength);else if(a.interleaved){m.byteStride=0,m.byteOffset=0;const e=new c(a.count*h);if(m.array=y$5(e,r,a.count,h,l,f+(a.byteOffset||0),a.componentType),m.extensions&&m.extensions.WEB3D_quantized_attributes&&h>2){const e=new Float32Array(m.array.length),{decodeMatrix:t}=m.extensions.WEB3D_quantized_attributes;for(let r=0;r<m.array.length;r+=h){O$7[0]=m.array[r],O$7[1]=m.array[r+1],O$7[2]=m.array[r+2],O$7[3]=1;const n=transformMat4$1(O$7,O$7,t);e[r]=n[0],e[r+1]=n[1],e[r+2]=n[2]}m.componentType=5126,m.array=e}}else m.byteStride=0,m.array=this._typedArray(r,a.count,h,f+(a.byteOffset||0),c),m.byteOffset=m.array.byteOffset;else{m.array=new c(a.count);const e=m.min||m.max;e&&(m.array[0]=e[0],m.array[1]=e[1],m.array[2]=e[2])}return m}_compareAccessor(){const e=this.gltf.accessors;if(Array.isArray(e))for(let t=0;t<e.length;t++)for(let s=0;s<e.length;s++)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0);else for(const t in e)for(const s in e)t!==s&&e[t].bufferView===e[s].bufferView&&(e[t].interleaved=e[s].interleaved=!0)}_typedArray(e,t,s,r,n){return r%n.BYTES_PER_ELEMENT!=0&&(e=e.slice(r,r+t*s*n.BYTES_PER_ELEMENT),r=0),new n(e,r,s*t)}_getTypeItemSize(e){const t=E$7.indexOf(e);return E$7[t+1]}requestKHRTechniquesWebgl(e){const{shaders:t}=e,s=t.map((e=>{if(void 0!==e.bufferView){const t=this.gltf.bufferViews[e.bufferView],{byteLength:s}=t;return this._requestBufferOfBufferView(t).then((r=>{const{buffer:n,byteOffset:i}=r,a=x$7(n,i+(t.byteOffset||0),s);return e.content=a,e}))}if(e.uri){if(h$3(e.uri)){const t=c$2(e.uri),s=x$7(t,0,t.byteLength);return e.content=s,Promise.resolve(e)}return w$5.get(this.rootPath+"/"+e.uri,this._fetchOptions).then((t=>(e.content=t,e)))}return Promise.resolve(e)}));return Promise.all(s).then((()=>e))}}class R$7 extends T$7{constructor(e,t,s,r,n,i,a){super(r,n,i,a),this.rootPath=e,this.gltf=t,this.requests={},this.buffers={},this.glbBuffer=s,this.accessor=new I$6(e,t,s,a)}iterate(e,t){const s=this.gltf[t];if(!s)return;let r=0;for(const t in s)e(t,s[t],r++)}createNode(e){const s={};if(a$1(e.name)&&(s.name=e.name),a$1(e.children)&&(s.children=e.children),a$1(e.jointName)&&(s.jointName=e.jointName),a$1(e.matrix)&&(s.matrix=e.matrix),a$1(e.rotation)&&(s.rotation=e.rotation),a$1(e.scale)&&(s.scale=e.scale),a$1(e.translation)&&(s.translation=e.translation),a$1(e.extras)&&(s.extras=e.extras),a$1(e.meshes)&&(s.mesh=e.meshes[0]),s.translation||s.rotation||s.scale){const e=function(e,s){if(s.matrix)return s.matrix;if(s.translation||s.scale||s.rotation){const r=fromTranslation$1(l$2,s.translation||g$2),n=fromQuat(m$4,s.rotation||p$6),i=fromScaling(d$3,s.scale||b$6);return multiply$5(i,n,i),multiply$5(e,r,i)}return identity$2(e)}([],s);delete s.translation,delete s.rotation,delete s.scale,s.matrix=e}return s}_loadMaterials(e){const t={};for(const s in e){const r=e[s];let n,i;r.instanceTechnique&&r.instanceTechnique.values?(n=r.instanceTechnique,i=n.values.diffuse):(n=r,i=n.values.tex||n.values.diffuseTex||n.values.diffuse);const a={baseColorTexture:{index:i}};r.name&&(a.name=r.name),r.extensions&&(a.extensions=r.extensions),r.extras&&(a.extras=r.extras),t[s]=a}return t}_loadImage(e){if(e.bufferView||e.extensions&&(e.extensions.KHR_binary_glTF||e.extensions.binary_glTF)){const t=e.bufferView?e:e.extensions.KHR_binary_glTF||e.extensions.binary_glTF;e.extensions&&(e.mimeType=t.mimeType,e.width=t.width,e.height=t.height);const s=this.gltf.bufferViews[t.bufferView],i=this.buffers[t.bufferView]=new Uint8Array(this.glbBuffer.buffer,(s.byteOffset||0)+this.glbBuffer.byteOffset,s.byteLength);return this.getImageByBuffer(i,e)}return this.requestExternalImage(e)}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;const s=this.gltf.images[t.source];return this._loadImage(s).then((e=>({image:{array:e.data,width:e.width,height:e.height,index:t.source,mimeType:s.mimeType,name:s.name,extras:s.extras},sampler:this.gltf.samplers[t.sampler]})))}getBaseColorTexture(e){const t=this.gltf.materials[e];let s,r;if(t.instanceTechnique&&t.instanceTechnique.values?(s=t.instanceTechnique,r=s.values.diffuse):(s=t,r=s.values.tex||s.values.diffuseTex||s.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const n=this.gltf.textures[r];if(!n)return null;return{format:n.format||6408,internalFormat:n.internalFormat||6408,type:n.type||5121,sampler:this.gltf.samplers[n.sampler],source:this.gltf.images[n.source]}}getMaterial(){return null}getAnimations(){return null}}class B$7 extends T$7{constructor(e,t,s,r,n,i,a){super(r,n,i,a),this.rootPath=e,this.gltf=t,this.glbBuffer=s,this.buffers={},this.requests={},this.accessor=new I$6(e,t,s,a)}iterate(e,t){const s=this.gltf[t];if(s)for(let t=0;t<s.length;t++)e(t,s[t],t)}createNode(e){const t={};return f$4(t,e),!a$1(e.weights)&&this.gltf.meshes&&a$1(t.mesh)?t.weights=this.gltf.meshes[t.mesh].weights:e.weights&&(t.weights=e.weights),t}_getTexture(e){const t=this.gltf.textures[e];if(!t)return null;let s=t.source;if(t.extensions&&t.extensions.EXT_texture_webp&&(s=t.extensions.EXT_texture_webp.source),!a$1(s))return null;const r=this.gltf.images[s];return this._loadImage(r).then((e=>{if(!e)return null;const s={image:{array:e.data,mipmap:e.mipmap,width:e.width,height:e.height,index:t.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};f$4(s,t);const n=a$1(t.sampler)?this.gltf.samplers[t.sampler]:void 0;return n&&(s.sampler=n,s.sampler.magFilter=n.magFilter||9729,s.sampler.minFilter=n.minFilter||9729,s.sampler.wrapS=n.wrapS||10497,s.sampler.wrapT=n.wrapT||10497),e.format&&(s.format=e.format),s}))}_loadImage(e){if(!a$1(e.bufferView))return this.requestExternalImage(e);{const t=this.gltf.bufferViews[e.bufferView],s=this.gltf.buffers[t.buffer];if(s.uri)return this.requestImageFromBufferURI(s,t,e);if(this.glbBuffer)return this._requestFromGlbBuffer(t,e)}return null}_requestFromGlbBuffer(e,t){const s=this._createDataView(e,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(s,t)}_createDataView(e,t,s){s=s||0;return new Uint8Array(t,e.byteOffset+s,e.byteLength)}_transformArrayBufferToBase64(e,t){const s=new Array(e.byteLength);for(let t=0;t<e.byteLength;t++)s[t]=String.fromCharCode(e[t]);return s.join(""),"data:"+(t=t||"image/png")+";base64,"+function(e){return"undefined"!=typeof self?self.btoa(e):window.btoa(e)}(unescape(encodeURIComponent(s)))}getAnimations(e){const t=[];return e.forEach((e=>{t.push(this.getSamplers(e.samplers))})),Promise.all(t).then((t=>{for(let s=0;s<t.length;s++)e[s].samplers=t[s];return e}))}getSamplers(e){const t=[];for(let s=0;s<e.length;s++)(a$1(e[s].input)||a$1(e[s].output))&&(t.push(this.accessor._requestData("input",e[s].input)),t.push(this.accessor._requestData("output",e[s].output)));return Promise.all(t).then((t=>{for(let s=0;s<t.length/2;s++)e[s].input=t[2*s],e[s].output=t[2*s+1],e[s].interpolation||(e[s].interpolation="LINEAR");return e}))}}const N$7="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class S$7{static read(e,t=0,s=0){s||(s=e.byteLength);const r=new DataView(e,t,s),n=r.getUint32(4,!0);if(1===n)return S$7.readV1(r,t);if(2===n)return S$7.readV2(e,t);throw new Error("Unsupported glb version : "+n)}static readV1(e,t){const s=e.getUint32(8,!0),r=e.getUint32(12,!0);if(s!==e.byteLength)throw new Error("Length in GLB header is inconsistent with glb's byte length.");const n=q$8(e.buffer,20+t,r);return{json:JSON.parse(n),glbBuffer:{byteOffset:20+t+r,buffer:e.buffer,byteLength:s}}}static readV2(e,t){let s,r,n;const i=new DataView(e,t+12);let a=0;for(;a<i.byteLength;){const o=i.getUint32(a,!0);a+=4;const f=i.getUint32(a,!0);if(a+=4,1313821514===f)s=q$8(e,t+12+a,o);else if(5130562===f){n=t+12+a,r=o;break}a+=o}return{json:JSON.parse(s),glbBuffer:{byteOffset:n,buffer:e,byteLength:r}}}}function q$8(e,t,s){if(N$7){const r=new Uint8Array(e,t,s);return N$7.decode(r)}return function(e){const t=e.length;let s="";for(let r=0;r<t;){let n=e[r++];if(128&n){let s=v$4[n>>3&7];if(!(64&n)||!s||r+s>t)return null;for(n&=63>>s;s>0;s-=1){const t=e[r++];if(128!=(192&t))return null;n=n<<6|63&t}}s+=String.fromCharCode(n)}return s}(new Uint8Array(e,t,s))}const v$4=[1,1,1,1,2,2,3,0],V$7=[0,0,0],M$7=[0,0,0,1],L$7=[1,1,1],D$7={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},U$7={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},C$5={_getTRSW(t,s,n,i,o,f,u,h){const c=a$1(t)?s.animations:[s.animations[0]],l={};for(let s=0;s<c.length;s++){const m=c[s],d=m.name||s;if(a$1(t)&&d!==t)continue;const g=m.channelsMap[n];if(g)for(let t=0;t<g.length;t++){const s=g[t];"translation"===s.target.path?(this._getAnimateData(o,m.samplers[s.sampler],i,1),l.translation=copy$4(V$7,o)):"rotation"===s.target.path?(this._getQuaternion(f,m.samplers[s.sampler],i,1),l.rotation=copy$2(M$7,f)):"scale"===s.target.path?(this._getAnimateData(u,m.samplers[s.sampler],i,1),l.scale=copy$4(L$7,u)):"weights"===s.target.path&&h&&(this._getAnimateData(h,m.samplers[s.sampler],i,h.length),l.weights=h)}}return l},_getAnimateData(e,t,s,r){switch(t.interpolation){case"LINEAR":{const n=this._getPreNext(U$7,t,s,1*r);n&&(e=function(e,t,s,r){for(let n=0;n<e.length;n++)e[n]=t[n]+r*(s[n]-t[n]);return e}(e,n.PREVIOUS,n.NEXT,n.INTERPOLATION));break}case"STEP":{const n=this._getPreNext(U$7,t,s,1*r);n&&(e=function(e,t){for(let s=0;s<e.length;s++)e[s]=t[s];return e}(e,...n.PREVIOUS));break}case"CUBICSPLINE":{const n=this._getPreNext(U$7,t,s,3*r);n&&(e=this._getCubicSpline(e,n,t.input.array,3*r));break}}return e},_getQuaternion(t,r,n){switch(r.interpolation){case"LINEAR":{const s=this._getPreNext(U$7,r,n,1);s&&slerp(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION);break}case"STEP":{const e=this._getPreNext(U$7,r,n,1);e&&(t=set$3(t,...e.PREVIOUS));break}case"CUBICSPLINE":{const e=this._getPreNext(U$7,r,n,3);if(e){for(let t=0;t<e.PREVIOUS.length;t++)e.PREVIOUS[t]=Math.acos(e.PREVIOUS[t]),e.NEXT[t]=Math.acos(e.NEXT[t]);t=this._getCubicSpline(t,e,r.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},_search(e,t){const s=e.length;let r,n,i,a=0,o=s-1,f=Math.floor((a+o)/2);for(;a<=s-1&&o>=0;){if(a===o)return null;if(e[f]<=t&&t<=e[f+1]){const s=e[f];return r=f,n=f+1,i=(t-s)/(e[f+1]-s),{preIndx:r,nextIndex:n,interpolation:i}}t<e[f]?(o=f,f=Math.floor((a+o)/2)):e[f+1]<t&&(a=f,f=Math.floor((a+o)/2))}return null},_getPreNext(e,t,s,r){const n=t.input.array,i=t.output.array,a=t.output.itemSize;(s<n[0]||s>n[n.length-1])&&(s=Math.max(n[0],Math.min(n[n.length-1],s))),s===n[n.length-1]&&(s=n[0]);const o=this._search(n,s);if(!o||!o.nextIndex)return null;const{preIndx:f,nextIndex:u,interpolation:h}=o;e.PREINDEX=f,e.NEXTINDEX=u,e.INTERPOLATION=h;const c=a*r;return e.PREVIOUS=i.subarray(e.PREINDEX*c,(e.PREINDEX+1)*c),e.NEXT=i.subarray(e.NEXTINDEX*c,(e.NEXTINDEX+1)*c),e},_getCubicSpline(e,t,s,r){const n=t.INTERPOLATION,i=s[t.PREINDEX],a=s[t.NEXTINDEX];for(let s=0;s<3;s++){const o=t.PREVIOUS[r+s],f=(a-i)*t.PREVIOUS[2*r+s],u=t.NEXT[3+s],h=(a-i)*t.NEXT[s],c=(2*Math.pow(n,3)-3*Math.pow(n,2)+1)*o+(Math.pow(n,3)-2*Math.pow(n,2)+n)*f+(2*-Math.pow(n,3)+3*Math.pow(n,2))*u+(Math.pow(n,3)-Math.pow(n,2))*h;e[s]=c}return e},getAnimationClip(e,t,n,i){const a=e.nodes[t]&&e.nodes[t].weights;return set$4(V$7,...D$7.TRANSLATION),set$3(M$7,...D$7.ROTATION),set$4(L$7,...D$7.SCALE),this._getTRSW(i,e,t,n,V$7,M$7,L$7,a)},getTimeSpan(e){if(!e.animations)return null;if(e.timeSpan)return e.timeSpan;const t=e.animations;return e.timeSpan={},t.forEach(((t,s)=>{let r=-1/0,n=1/0;const i=t.channels;for(let e=0;e<i.length;e++){const a=t.samplers[i[e].sampler].input.array;a[a.length-1]>r&&(r=a[a.length-1]),a[0]<n&&(n=a[0])}e.timeSpan[t.name||s]={max:r,min:n}})),e.timeSpan},getTimeSpanByName(e,t){const s=this.getTimeSpan(e);return s?a$1(t)?s[t]:s[Object.keys(s)[0]]:null}};let k$7=!1;if("undefined"!=typeof OffscreenCanvas){let e;try{e=new OffscreenCanvas(2,2).getContext("2d")}catch(e){}e&&"undefined"!=typeof createImageBitmap&&(k$7=!0)}const F$7="undefined"==typeof document?null:document.createElement("canvas");class X$8{constructor(e,t,s){if(this.options=s||{},this.options.decoders||(this.options.decoders={}),this._fetchOptions=this.options.fetchOptions||{},t.buffer instanceof ArrayBuffer){const{json:s,glbBuffer:r}=S$7.read(t.buffer,t.byteOffset,t.byteLength);this._init(e,s,r)}else this._init(e,t);this._accessor=new I$6(this.rootPath,this.gltf,this.glbBuffer,this._fetchOptions),this._checkExtensions()}_checkExtensions(){const e=this.gltf.extensionsRequired;if(e){if(e.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(e.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}_loadExtensions(){const e=this.gltf.extensions;return e&&e.KHR_techniques_webgl?this._accessor.requestKHRTechniquesWebgl(e.KHR_techniques_webgl).then((t=>(e.KHR_techniques_webgl=t,e))):Promise.resolve(e)}load(e){const t=this._loadScene(e=e||{}),s=this._loadAnimations(),r=this._loadTextures(),n=this._loadExtensions();return Promise.all([t,s,r,n]).then((e=>(e[0].animations=e[1],e[0].textures=e[2],e[0].extensions=e[3],e[0].transferables=this.transferables||[],this.createChannelsMap(e[0]),e[0])))}createChannelsMap(e){const t=e.animations;if(t)for(let e=0;e<t.length;e++){const s=t[e];s.channelsMap={};for(let e=0;e<s.channels.length;e++){const t=s.channels[e];s.channelsMap[t.target.node]||(s.channelsMap[t.target.node]=[]),s.channelsMap[t.target.node].push(t)}}}getExternalResources(){const e=[];if(this.gltf){const{buffers:t,images:s}=this.gltf;for(let s=0;s<t.length;s++)t[s].uri&&t[s].uri.indexOf("data:application/octet-stream;base64")<0&&e.push({type:"buffer",uri:t[s].uri});for(let t=0;t<s.length;t++)s[t].uri&&s[t].uri.indexOf("data:image/")<0&&e.push({type:"image",uri:s[t].uri})}return e}static getAnimationClip(e,t,s,r){return C$5.getAnimationClip(e,t,s,r)}static getAnimationTimeSpan(e,t){return C$5.getTimeSpanByName(e,t)}static getTypedArrayCtor(e){return u$4(e)}static readInterleavedArray(e,t,s,r,n,i,a){return y$5(e,t,s,r,n,i,a)}_init(e,t,s){this.gltf=t,this.glbBuffer=s,this.version=t.asset?+t.asset.version:1,this.rootPath=e,this.buffers={},this.requests={},this.options.requestImage=k$7?z$7.bind(this):this.options.requestImage||j$7,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new B$7(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions),this.adapter.iterate(((e,t,s)=>{t.id="buffer_"+s}),"buffers"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s}),"images"),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s}),"accessors")):(this.adapter=new R$7(e,t,s,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this._fetchOptions),this.adapter.iterate(((e,t,s)=>{t.id="accessor_"+s}),"accessors"),this.adapter.iterate(((e,t,s)=>{t.id="image_"+s}),"images"))}_parseNodes(e,t){if(e.children&&e.children.length>0){if(!("number"==typeof(s=e.children[0])&&isFinite(s)||o$1(e.children[0])))return e;const r=e.children.map((e=>{const s=t[e];return s.nodeIndex=e,this._parseNodes(s,t)}));e.children=r}var s;return e}_loadScene(e){return this._loadNodes(e).then((e=>{const t=this.scenes=[];let s;for(const t in e)e[t]=this._parseNodes(e[t],e),e[t].nodeIndex=Number(t)?Number(t):t;this.adapter.iterate(((r,n,i)=>{const a={};n.name&&(a.name=n.name),n.nodes&&(a.nodes=n.nodes.map((t=>e[t]))),this.gltf.scene===r&&(s=i),t.push(a)}),"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:s,scenes:t,nodes:e,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const e=this.adapter._loadMaterials(this.gltf.materials);r.materials=e}return delete this.gltf.buffers,r.json=this.gltf,r}))}_loadNodes(e){return this._loadMeshes(e).then((()=>{const e=this.nodes={};return this.adapter.iterate(((t,s)=>{const r=this.adapter.createNode(s,this.meshes,this.skins);e[t]=r}),"nodes"),e}))}_loadSkins(){this.skins=[];const e=[];return this.adapter.iterate(((t,s,r)=>{e.push(this._loadSkin(s).then((e=>{e.index=r,this.skins.push(e)})))}),"skins"),e}_loadSkin(e){return this.adapter.accessor._requestData("inverseBindMatrices",e.inverseBindMatrices).then((t=>(e.inverseBindMatrices=t,t&&t.buffer&&this.transferables&&this.transferables.indexOf(t.buffer)<0&&this.transferables.push(t.buffer),e)))}_loadAnimations(){const e=this.gltf.animations;return a$1(e)?this.adapter.getAnimations(e):null}_loadMeshes(e){this.meshes={};let t=[];return this.adapter.iterate(((s,r,n)=>{t.push(this._loadMesh(r,e).then((e=>{e.index=n,this.meshes[s]=e})))}),"meshes"),t=t.concat(this._loadSkins()),Promise.all(t)}_loadMesh(e,t){const s=e.primitives.map((e=>this._loadPrimitive(e,t))).filter((e=>!!e));return Promise.all(s).then((t=>{const s={};return f$4(s,e),s.primitives=t,s}))}_loadTextures(){const e=this.gltf.textures;if(!e)return null;const t=[];for(const s in e)t.push(this.adapter._getTexture(s));return Promise.all(t).then((t=>{if(this.transferables)for(let e=0;e<t.length;e++){const s=t[e].image.array;if(t[e]&&s){let e;e=s instanceof ImageBitmap?s:s.buffer,e&&this.transferables.indexOf(e)<0&&this.transferables.push(e)}}if(!Array.isArray(e)){const s={},r=Object.keys(e);for(let e=0;e<t.length;e++)t[e]&&(s[r[e]]=t[e]);return s}return t}))}_loadPrimitive(e,t){let s;const n=[],i=e.extensions;if(a$1(e.targets))for(let t=0;t<e.targets.length;t++){const s=e.targets[t];for(const e in s){const r=this.adapter.accessor._requestData(`morphTargets_${e}_${t}`,s[e]);r&&n.push(r)}}if(i&&i.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const e=this.options.decoders.draco,{bufferView:r,attributes:a}=i.KHR_draco_mesh_compression,o=this.gltf.bufferViews[r],f=this._accessor._requestBufferOfBufferView(o).then((s=>{const{buffer:r,byteOffset:n}=s;let{byteOffset:i}=o;i||(i=0);const u=new DataView(r,n+i,o.byteLength);return e(u,{attributes:a,useUniqueIDs:!1,skipAttributeTransform:t.skipAttributeTransform}).then((e=>{const t=Object.values(e.attributes);return e.indices&&t.push(e.indices),t}))}));n.push(f),s=Promise.all(n)}else{const t=e.attributes;for(const e in t){const s=this.adapter.accessor._requestData(e,t[e]);s&&n.push(s)}if(a$1(e.indices)){const t=this.adapter.accessor._requestData("indices",e.indices);t&&n.push(t)}s=Promise.all(n)}return s.then((t=>{if(i&&i.KHR_draco_mesh_compression){const s=e.targets?e.targets.length:0;t[s]=t[s].concat(t.slice(0,s)),t=t[s]}let s,n;const o={attributes:t.reduce(((e,t)=>{if("indices"===t.name)s=t;else if(t.name.indexOf("morphTargets_")>-1)n=n||{},n[t.name.slice(13)]=t;else{if(!("POSITION"!==t.name||t.min&&t.max)){const e=[1/0,1/0,1/0],s=[-1/0,-1/0,-1/0],{itemSize:n,array:i}=t,a=i.length/n;for(let t=0;t<a;t++)for(let r=0;r<n;r++){const a=t*n+r;i[a]<e[r]&&(e[r]=i[a]),i[a]>s[r]&&(s[r]=i[a])}if(t.quantization){const n=t.quantization,i=n.range/(1<<n.quantizationBits),a=n.minValues;scale$4(e,e,i),add$4(e,e,a),scale$4(s,s,i),add$4(s,s,a)}t.min=e,t.max=s}e[t.name]=t}return this.transferables&&t.array.buffer&&this.transferables.indexOf(t.array.buffer)<0&&this.transferables.push(t.array.buffer),e}),{}),material:e.material};return s&&(o.indices=s),n&&(o.morphTargets=n),o.mode=a$1(e.mode)?e.mode:4,a$1(e.extras)&&(o.extras=e.extras),o}))}}function j$7(e,t,s){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!F$7)return void s(new Error("There is no canvas to draw image!"));F$7.width=r.width,F$7.height=r.height;const e=F$7.getContext("2d",{willReadFrequently:!0});e.drawImage(r,0,0,r.width,r.height);const t=e.getImageData(0,0,r.width,r.height),n={width:r.width,height:r.height,data:new Uint8Array(t.data)};s(null,n)},r.onerror=function(e){s(e)},r.src=e}let H$7,K$8;function z$7(e,t,s){H$7||(H$7=new OffscreenCanvas(2,2),K$8=H$7.getContext("2d",{willReadFrequently:!0}));let r=null;if(o$1(e))r=fetch(e,t).then((e=>e.arrayBuffer())).then((e=>{const t=new Blob([new Uint8Array(e)]);return createImageBitmap(t)}));else{const t=new Blob([e]);r=createImageBitmap(t)}r.then(Y$7.bind(this)).then((e=>{s(null,e)})).catch((e=>{console.warn(e),s(e)}))}function Y$7(e){let{width:t,height:s}=e;W$7(t)||(t=G$7(t)),W$7(s)||(s=G$7(s));const r=this.options.maxTextureSize;r&&(t=Math.min(r,t),s=Math.min(r,s)),H$7.width=t,H$7.height=s,K$8.drawImage(e,0,0,t,s),e.close();const n=K$8.getImageData(0,0,t,s);return{width:t,height:s,data:new Uint8Array(n.data)}}function W$7(e){return 0==(e&e-1)&&0!==e}function G$7(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}
/*!
	 * Contains code from google filament
	 * https://github.com/google/filament/
	 * License Apache-2.0
	 */const MAT0=[],TMP0=[],TMP1=[],TMP2=[];function packTangentFrame(q,n,t){const c=cross$1(TMP0,n,t);q=fromMat3(q,function(out,c00,c01,c02,c10,c11,c12,c20,c21,c22){return out[0]=c00,out[1]=c01,out[2]=c02,out[3]=c10,out[4]=c11,out[5]=c12,out[6]=c20,out[7]=c21,out[8]=c22,out}(MAT0,t[0],t[1],t[2],...c,...n));const bias=1/32767;if((q=function(q){return q[3]<0?scale$2(q,q,-1):q}(q=normalize$2(q,q)))[3]<bias){q[3]=bias;const factor=Math.sqrt(1-bias*bias);q[0]*=factor,q[1]*=factor,q[2]*=factor}const b=t[3]>0?cross$1(TMP1,t,n):cross$1(TMP1,n,t);return dot$4(cross$1(TMP2,t,n),b)<0&&scale$2(q,q,-1),q}const COUNTS=[];function buildNormals(positions,indices,out){const normals=out||[];normals.setLength&&normals.setLength(positions.length);const counts=COUNTS;counts.length<positions.length/3&&(counts.length=positions.length/3),counts.fill(0,0,positions.length/3);const len=void 0===indices.length?indices:indices.length;for(let i=0;i<len/3;i++)void 0===indices.length?computeNormal(positions,3*i,3*i+1,3*i+2,normals,counts):computeNormal(positions,indices[3*i],indices[3*i+1],indices[3*i+2],normals,counts);for(let i=0;i<normals.length;i+=3){const count=counts[i/3];0!==count?(normals[i]/=count,normals[i+1]/=count,normals[i+2]/=count):(normals[i]=0,normals[i+1]=0,normals[i+2]=0)}return normals}const V0=[],V1=[],V2=[],vA$1=[],vB=[],vC=[],normal=[];function computeNormal(vertices,v1,v2,v3,normals,counts){set$4(vA$1,vertices[3*v1],vertices[3*v1+1],vertices[3*v1+2]),set$4(vB,vertices[3*v2],vertices[3*v2+1],vertices[3*v2+2]),set$4(vC,vertices[3*v3],vertices[3*v3+1],vertices[3*v3+2]);const cb=sub$2(V0,vC,vB),ab=sub$2(V1,vA$1,vB),cross=cross$1(V2,cb,ab);normalize$4(normal,cross),normals[3*v1]=normals[3*v1]||0,normals[3*v2]=normals[3*v2]||0,normals[3*v3]=normals[3*v3]||0,normals[3*v1+1]=normals[3*v1+1]||0,normals[3*v2+1]=normals[3*v2+1]||0,normals[3*v3+1]=normals[3*v3+1]||0,normals[3*v1+2]=normals[3*v1+2]||0,normals[3*v2+2]=normals[3*v2+2]||0,normals[3*v3+2]=normals[3*v3+2]||0,normals[3*v1]+=normal[0],normals[3*v2]+=normal[0],normals[3*v3]+=normal[0],normals[3*v1+1]+=normal[1],normals[3*v2+1]+=normal[1],normals[3*v3+1]+=normal[1],normals[3*v1+2]+=normal[2],normals[3*v2+2]+=normal[2],normals[3*v3+2]+=normal[2],counts[v1]+=1,counts[v2]+=1,counts[v3]+=1}
/*!
	 * Contains code from THREE.JS
	 * https://github.com/mrdoob/three.js/
	 * License MIT
	 * 
	 * Generate tangents per vertex.
	 */function buildTangents(positions,normals,uvs,indices,out){const nVertices=positions.length/3,tangents=out||new Array(4*nVertices),tan1=[],tan2=[];for(let i=0;i<nVertices;i++)tan1[i]=[0,0,0],tan2[i]=[0,0,0];const vA=[0,0,0],vB=[0,0,0],vC=[0,0,0],uvA=[0,0],uvB=[0,0],uvC=[0,0],sdir=[0,0,0],tdir=[0,0,0];function handleTriangle(a,b,c){fromArray3(vA,positions,3*a),fromArray3(vB,positions,3*b),fromArray3(vC,positions,3*c),fromArray2(uvA,uvs,2*a),fromArray2(uvB,uvs,2*b),fromArray2(uvC,uvs,2*c);const x1=vB[0]-vA[0],x2=vC[0]-vA[0],y1=vB[1]-vA[1],y2=vC[1]-vA[1],z1=vB[2]-vA[2],z2=vC[2]-vA[2],s1=uvB[0]-uvA[0],s2=uvC[0]-uvA[0],t1=uvB[1]-uvA[1],t2=uvC[1]-uvA[1],r=1/(s1*t2-s2*t1);set$4(sdir,(t2*x1-t1*x2)*r,(t2*y1-t1*y2)*r,(t2*z1-t1*z2)*r),set$4(tdir,(s1*x2-s2*x1)*r,(s1*y2-s2*y1)*r,(s1*z2-s2*z1)*r),add$4(tan1[a],tan1[a],sdir),add$4(tan1[b],tan1[b],sdir),add$4(tan1[c],tan1[c],sdir),add$4(tan2[a],tan2[a],tdir),add$4(tan2[b],tan2[b],tdir),add$4(tan2[c],tan2[c],tdir)}for(let j=0,jl=indices.length;j<jl;j+=3)handleTriangle(indices[j+0],indices[j+1],indices[j+2]);const tmp=[],tmp2=[],n=[],n2=[];let w,t,test;function handleVertex(v){fromArray3(n,normals,3*v),copy$4(n2,n),t=tan1[v],copy$4(tmp,t),sub$2(tmp,tmp,scale$4(n,n,dot$4(n,t))),normalize$4(tmp,tmp),cross$1(tmp2,n2,t),test=dot$4(tmp2,tan2[v]),w=test<0?-1:1,tangents[4*v]=tmp[0],tangents[4*v+1]=tmp[1],tangents[4*v+2]=tmp[2],tangents[4*v+3]=w}for(let j=0,jl=indices.length;j<jl;j+=3)handleVertex(indices[j+0]),handleVertex(indices[j+1]),handleVertex(indices[j+2]);return tangents}function fromArray3(out,array,offset){return out[0]=array[offset],out[1]=array[offset+1],out[2]=array[offset+2],out}function fromArray2(out,array,offset){return out[0]=array[offset],out[1]=array[offset+1],out}
/*!
	 * @maptalks/reshader.gl v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.com
	 */function f$3(e){return!d$2(e)&&("string"==typeof e||null!==e.constructor&&e.constructor===String)}function d$2(e){return null==e}function u$3(e){return!d$2(e)}function h$2(e){return!d$2(e)&&("function"==typeof e||null!==e.constructor&&e.constructor===Function)}const m$3="function"==typeof Object.assign;function v$3(e){if(m$3)Object.assign.apply(Object,arguments);else for(let n=1;n<arguments.length;n++){const t=arguments[n];for(const n in t)e[n]=t[n]}return e}function _$6(e){for(let n=1;n<arguments.length;n++){const t=arguments[n];for(const n in t)null!=t[n]&&(e[n]=t[n])}return e}function g$1(e){return"number"==typeof e&&!isNaN(e)}function x$6(e,n,t){return e*(1-t)+n*t}function b$5(e){return Array.isArray(e)||e instanceof Uint8Array||e instanceof Int8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Uint32Array||e instanceof Int32Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e instanceof Float64Array}function p$5(e){return(e=Math.abs(e))<128?Int8Array:e<32768?Int16Array:Float32Array}function y$4(e,n,t){return Math.min(t,Math.max(n,e))}function A$4(e){return e&&e.hasExtension("oes_vertex_array_object")}function S$6(e,n){return Object.prototype.hasOwnProperty.call(e,n)}function T$6(e){if(e.data){if(e.data.BYTES_PER_ELEMENT)return e.data.length*e.data.BYTES_PER_ELEMENT;if(e.data.length)return 4*e.data.length}else{if(e.BYTES_PER_ELEMENT)return e.length*e.BYTES_PER_ELEMENT;if(e.length)return 4*e.length;if(e.buffer&&e.buffer.destroy)return e.buffer._buffer.byteLength}return 0}function M$6(e){return e.width*e.height*O$6(e.format)*C$4(e.type)*("textureCube"===e._reglType?6:1)}function C$4(e){return"uint8"===e?1:"uint16"===e||"float16"===e||"half float"===e?2:"uint32"===e||"float"===e||"float32"===e?4:0}function O$6(e){return"depth"===e||"alpha"===e||"luminance"===e?1:"luminance alpha"===e||"depth stencil"===e?2:"srgba"===e||"rgb5 a1"===e||"rgba"===e.substring(0,4)?4:"srgb"===e||"rgb"===e.substring(0,3)?3:1}function E$6(n){if(!n.componentType)return!1;const t=X$8.getTypedArrayCtor(n.componentType);return n.byteStride>0&&n.byteStride!==n.itemSize*t.BYTES_PER_ELEMENT}function P$5(e){return e&&(e.stride>0||E$6(e))}function I$5(e){let n=0;const t=e&&e.length||0;if(!t)return n;let r;for(let i=0;i<t;i++)r=e.charCodeAt(i),n=(n<<5)-n+r,n&=n;return n}function w$4(e){return 0==(e&e-1)&&0!==e}function D$6(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function R$6(e,n,t){if(b$5(e))return w$4(e.width)&&w$4(e.height)?e:function(e,n,t){let r=n,i=t;w$4(n)||(r=D$6(n)),w$4(t)||(i=D$6(t));const o=new ImageData(new Uint8ClampedArray(e),n,t),a=document.createElement("canvas");a.width=n,a.height=t,a.getContext("2d").putImageData(o,0,0);const s=document.createElement("canvas");s.width=r,s.height=i,s.getContext("2d").drawImage(a,0,0,n,t,0,0,i,i),console.warn(`Texture's size is not power of two, resize from (${n}, ${t}) to (${r}, ${i})`);let c=document.getElementById("_debug_resize_canvas");return c||(c=document.createElement("canvas"),c.id="_debug_resize_canvas",document.body.appendChild(c)),c.width=r,c.height=i,c.getContext("2d").drawImage(s,0,0),s}(e,n,t);if(w$4(e.width)&&w$4(e.height))return e;t=e.height,w$4(n=e.width)||(n=D$6(n)),w$4(t)||(t=D$6(t));const r=document.createElement("canvas");r.width=n,r.height=t,r.getContext("2d").drawImage(e,0,0,n,t);const i=e.src,o=i.lastIndexOf("/")+1,a=i.substring(o);return console.warn(`Texture(${a})'s size is not power of two, resize from (${e.width}, ${e.height}) to (${n}, ${t})`),r}var N$6=Object.freeze({__proto__:null,isString:f$3,isNil:d$2,defined:u$3,isFunction:h$2,extend:v$3,extend1:_$6,extend2:function(e){for(let n=1;n<arguments.length;n++){const t=arguments[n];for(const n in t)void 0===e[n]&&(e[n]=t[n])}return e},isNumber:g$1,log2:function(e){if(Math.log2)return Math.log2(e);const n=Math.log(e)*Math.LOG2E,t=Math.round(n);return Math.abs(t-n)<1e-14?t:n},normalize:function(e,n){let t=0;for(let e=0,r=n.length;e<r;e++)t+=n[e];for(let r=0,i=n.length;r<i;r++)e[r]=n[r]/t;return e},interpolate:x$6,isArray:b$5,lerp:function(e,n,t,r){for(let i=0;i<e.length;i++)e[i]=n[i]+r*(t[i]-n[i]);return e},set:function(e,n){for(let t=0;t<e.length;t++)e[t]=n[t];return e},getPosArrayType:p$5,clamp:y$4,isSupportVAO:A$4,hasOwn:S$6,getBufferSize:T$6,getTexMemorySize:M$6,getTextureByteWidth:C$4,getTextureChannels:O$6,isInStride:E$6,isInterleaved:P$5,getSupportedFormats:function(e){return{etc:!!e.getExtension("WEBGL_compressed_texture_etc"),etc1:!!e.getExtension("WEBGL_compressed_texture_etc1"),s3tc:!!e.getExtension("WEBGL_compressed_texture_s3tc"),pvrtc:!!e.getExtension("WEBGL_compressed_texture_pvrtc"),astc:!!e.getExtension("WEBGL_compressed_texture_astc"),bc7:!!e.getExtension("EXT_texture_compression_bptc")}},hashCode:I$5,isPowerOfTwo:w$4,resizeToPowerOfTwo:R$6});const F$6=e=>class extends e{on(e,n){return this._events||(this._events={type:[n]}),this._events[e]=this._events[e]||[],this._events[e].push(n),this}once(e,n){return this.on(e,this._wrapOnce(e,n))}off(e,n){return this._events&&this._events[e]?(this._events[e].splice(this._events[e].indexOf(n),1),this):this}fire(e,n={}){if(!this._events||!this._events[e])return this;n.target||(n.target=this);const t=this._events[e].slice(0);for(const e of t)e(n);return this}_wrapOnce(e,n){const t=this;let r=!1;return function i(o){r||(r=!0,n(o),t.off(e,i))}}},H$6="__reshader_disposed";var L$6=Object.freeze({__proto__:null,KEY_DISPOSED:H$6,WEBGL_EXTENSIONS:["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives"],WEBGL_OPTIONAL_EXTENSIONS:["OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","EXT_texture_filter_anisotropic"]}),z$6=F$6(class{constructor(e,n){if(h$2(e)){this._texture=e,e=this.config={};for(const n in this._texture)S$6(this._texture,n)&&(h$2(this._texture[n])||(e[n]=this._texture[n]))}else if(this.config=e||{},this.resLoader=n,!e.url&&!e.promise||e.data)e.data&&this._needPowerOf2()&&(e.data instanceof Image?e.data=R$6(e.data):e.hdr||!b$5(e.data)||w$4(e.width)&&w$4(e.height)||(e.data=R$6(e.data,e.width,e.height)));else{this._loading=!0;const t=this;let r;if(e.promise)r=e.promise;else{let t;t=e.arrayBuffer?n.getArrayBuffer:n.get,r=t.call(n,e.url)}e.data=n.getDefaultTexture(e.url),this.promise=r,r.then((e=>(delete this.promise,t._loading=!1,t.config?(e.data instanceof Image&&this._needPowerOf2()&&(e.data=R$6(e.data)),t.onLoad(e),Array.isArray(e)||(e=[e]),t.fire("complete",{target:this,resources:e}),e):e))).catch((e=>{console.error("error when loading texture image.",e),t.fire("error",{target:this,error:e})}))}}isReady(){return!this._loading}set(e,n){return this.config[e]=n,this.dirty=!0,this}get(e){return this.config[e]}getREGLTexture(e){return this._texture||(this._texture=this.createREGLTexture(e),this.config.persistent||(this.config.data&&(this.config.data instanceof ImageBitmap&&this.config.data.close(),this.config.data=[]),this.config.faces&&(this.config.faces=[]),this.config.image&&(this.config.image.array=[]),this.config.mipmap&&delete this.config.mipmap)),this.dirty&&this._updateREGL(),this._texture}getMemorySize(){if(!this.config)return 0;const{width:e,height:n,type:t,format:r}=this.config,i=C$4(t||"uint8"),o=O$6(r||"rgba");return this.config.faces?e*n*i*o*6:e*n*i*o}_updateREGL(){this._texture&&!this._texture[H$6]&&this._texture(this.config),this.dirty=!1}dispose(){this.config&&this.config.url&&(URL.revokeObjectURL(this.config.url),this.resLoader.disposeRes(this.config.url)),this._texture&&!this._texture[H$6]&&(this._texture._reshader_refCount&&this._texture._reshader_refCount--,this._texture._reshader_refCount||(this._texture.destroy(),this._texture[H$6]=!0,delete this._texture)),delete this.resLoader;const e=this.config&&this.config.url;delete this.config,e&&this.fire("disposed",{target:this,url:e})}_needPowerOf2(){const e=this.config;return e.wrap&&"clamp"!==e.wrap||e.wrapS&&"clamp"!==e.wrapS||e.wrapT&&"clamp"!==e.wrapT||e.min&&"nearest"!==e.min&&"linear"!==e.min}});const k$6={};class B$6{constructor(e){this.regl=e}render(e,n,t,r){e.setUniforms(n||k$6),e.setFramebuffer(r);let i=0;if(t){const{opaques:n,transparents:r}=t.getSortedMeshes();i+=e.draw(this.regl,n),i+=e.draw(this.regl,r)}else i+=e.draw(this.regl);return i}clear(e){this.regl.clear(e)}}const U$6=[],V$6=identity$2([]),j$6={min:[],max:[]};class X$7{constructor(e,n){this.min=e||[1/0,1/0,1/0],this.max=n||[-1/0,-1/0,-1/0],this.updateVertex()}static copy(e,n){copy$4(e.min,n.min),copy$4(e.max,n.max);for(let r=0;r<n.vertex.length;r++)copy$4(e.vertex[r],n.vertex[r]);return e}combine(e){return e?(Array.isArray(e)&&(copy$4(j$6.min,e[0]),copy$4(j$6.max,e[1]),e=j$6),e.min[0]<this.min[0]&&(this.min[0]=e.min[0],this._dirty=!0),e.min[1]<this.min[1]&&(this.min[1]=e.min[1],this._dirty=!0),e.min[2]<this.min[2]&&(this.min[2]=e.min[2],this._dirty=!0),e.max[0]>this.max[0]&&(this.max[0]=e.max[0],this._dirty=!0),e.max[1]>this.max[1]&&(this.max[1]=e.max[1],this._dirty=!0),e.max[2]>this.max[2]&&(this.max[2]=e.max[2],this._dirty=!0),this):this}dirty(){return this._dirty=!0,this}getCenter(){return this.center||(this.center=[],this._dirty=!0),this._dirty&&(add$4(this.center,this.min,this.max),scale$4(this.center,this.center,.5)),this._dirty=!1,this.center}containPoint(e){const n=this.min,t=this.max;return n[0]<=e[0]&&n[1]<=e[1]&&n[2]<=e[2]&&t[0]>=e[0]&&t[1]>=e[1]&&t[2]>=e[2]}isFinite(){const e=this.min,n=this.max;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(n[0])&&isFinite(n[1])&&isFinite(n[2])}updateVertex(){if(!this.vertex){this.vertex=[];for(let e=0;e<8;e++)this.vertex.push([])}return this.vertex[0][0]=this.min[0],this.vertex[0][1]=this.min[1],this.vertex[0][2]=this.min[2],this.vertex[1][0]=this.min[0],this.vertex[1][1]=this.min[1],this.vertex[1][2]=this.max[2],this.vertex[2][0]=this.min[0],this.vertex[2][1]=this.max[1],this.vertex[2][2]=this.max[2],this.vertex[3][0]=this.min[0],this.vertex[3][1]=this.max[1],this.vertex[3][2]=this.min[2],this.vertex[4][0]=this.max[0],this.vertex[4][1]=this.min[1],this.vertex[4][2]=this.min[2],this.vertex[5][0]=this.max[0],this.vertex[5][1]=this.min[1],this.vertex[5][2]=this.max[2],this.vertex[6][0]=this.max[0],this.vertex[6][1]=this.max[1],this.vertex[6][2]=this.max[2],this.vertex[7][0]=this.max[0],this.vertex[7][1]=this.max[1],this.vertex[7][2]=this.min[2],this.vertex}copy(e){return e?X$7.copy(e,this):new X$7(this.min.slice(),this.max.slice())}equals(e){if(!equals$5(this.min,e.min)||!equals$5(this.max,e.max))return!1;const n=e.vertex;for(let e=0;e<this.vertex.length;e++)if(!equals$5(n[e],this.vertex[e]))return!1;return!0}transform(e,r){if(e=e||V$6,(r=r||V$6)[1]||r[2]||r[4]||r[6]||r[8]||r[9]){const i=this.vertex,o=multiply$5(U$6,r,e);for(let e=0;e<i.length;e++)transformMat4$2(this.vertex[e],this.vertex[e],o);const a=this.vertex.map((e=>e[0])),s=this.vertex.map((e=>e[1])),c=this.vertex.map((e=>e[2])),l=Math.min(...a),f=Math.max(...a),d=Math.min(...s),u=Math.max(...s),h=Math.min(...c),m=Math.max(...c);set$4(this.min,l,d,h),set$4(this.max,f,u,m)}else{const i=multiply$5(U$6,r,e);transformMat4$2(this.min,this.min,i),transformMat4$2(this.max,this.max,i)}return this}}const W$6=[],K$7={5120:"int8",5122:"int16",5124:"int32",5121:"uint8",5123:"uint16",5125:"uint32",5126:"float"},q$7={5120:1,5122:2,5124:4,5121:1,5123:2,5125:4,5126:4},Y$6={positionSize:3,primitive:"triangles",positionAttribute:"aPosition",normalAttribute:"aNormal",uv0Attribute:"aTexCoord",uv1Attribute:"aTexCoord1",color0Attribute:"aColor0",tangentAttribute:"aTangent",pickingIdAttribute:"aPickingId",textureCoordMatrixAttribute:"aTextureCoordMatrix"};let J$7=1;const Z$7="_reshader_refCount";class Q$7{constructor(e,n,t,r){this._version=0,this.data=e,this.elements=n,this.desc=v$3({},Y$6,r);const i=this._getPosAttritute();this.data[this.desc.positionAttribute]=i,t||(this.elements?t=$$6(this.elements):i&&i.length?t=i.length/this.desc.positionSize:i&&i.interleavedArray?t=i.interleavedArray.length/this.desc.positionSize:i&&i.array&&(t=i.array.length/this.desc.positionSize)),this.count=t,this.elements||(this.elements=t),this.properties={},this._buffers={},this._vao={},this.getVertexCount(),this._prepareData(!0),this.updateBoundingBox()}set version(e){throw new Error("Geometry.version is read only.")}get version(){return this._version}_getPosAttritute(){return this.data[this.desc.positionAttribute]}_prepareData(e){if(!this.data)return;const n=this._buffers||{};for(const t in this.data){const r=this.data[t];if(r)if(r.buffer&&r.buffer.destroy){const n=r.buffer;n[Z$7]||(n[Z$7]=0),e&&n[Z$7]++}else if(r&&r.array)if(E$6(r)){let e=r.array.buffer.__id;e||(e=r.array.buffer.__id=J$7++),this.data[t]={buffer:e,offset:r.byteOffset,stride:r.byteStride,type:K$7[r.componentType],size:r.itemSize,count:r.count,componentType:r.componentType},n[e]||(n[e]={data:r.array.buffer})}else this.data[t]=r.array}this._buffers=n;const t=this.elements;t&&t.array&&(this.elements=this.elements.array)}getAttrData(e){const n=e.key,t=!this._reglData||!this._reglData[n];if(this._reglData||(this._reglData={}),t){const e=this._reglData[n]={},t=this.data,{positionAttribute:r,normalAttribute:i,uv0Attribute:o,uv1Attribute:a,tangentAttribute:s,color0Attribute:c,pickingIdAttribute:l,textureCoordMatrixAttribute:f}=this.desc;v$3(e,this.data),e.aPosition=t[r],t[i]&&(e.aNormal=t[i]),t[o]&&(e.aTexCoord=t[o]),t[a]&&(e.aTexCoord1=t[a]),t[s]&&(e.aTangent=t[s]),t[c]&&(e.aColor0=t[c]),t[l]&&(e.aPickingId=t[l]),t[f]&&(e.aTextureCoordMatrix=t[f])}return this._reglData[n]}getREGLData(e,n,t){this.getAttrData(n);const r=!this._reglData||!this._reglData[n.key];if(A$4(e)&&!t){const t=n&&n.key||"default";if(!this._vao[t]||r||this._vao[t].dirty){const r=this._reglData[n.key],i=this._vertexCount,o=[];for(let e=0;e<n.length;e++){const t=n[e].name,a=r[t]&&r[t].buffer;if(a&&a.destroy)o.push(void 0!==r[t].stride?r[t]:a);else{const e=r[t];if(!e){o.push(this.desc.fillEmptyDataInMissingAttribute?new Uint8Array(4*i):W$6);continue}const n=(e.data&&b$5(e.data)?e.data.length:e.length)/i;e.data?(e.dimension=n,o.push(e)):o.push({data:e,dimension:n})}}const a={attributes:o,primitive:this.getPrimitive()};if(this.elements&&!g$1(this.elements))if(this.elements.destroy)a.elements=this.elements;else{a.elements={primitive:this.getPrimitive(),data:this.elements};const e=this.getElementsType(this.elements);e&&(a.elements.type=e)}this._vao[t]?this._vao[t].vao(a):this._vao[t]={vao:e.vao(a)}}return delete this._vao[t].dirty,this._vao[t]}return this._reglData[n.key]}_isAttrChanged(e){if(e===this._activeAttributes)return!1;if(e.length!==this._activeAttributes.length)return!0;for(let n=0;n<e.length;n++)if(e[n]!==this._activeAttributes[n])return!0;return!1}generateBuffers(e){const n=this._buffers;for(const t in n)n[t].buffer||(n[t].buffer=e.buffer(n[t].data)),delete n[t].data;const t=this.desc.positionAttribute,r=this.desc.altitudeAttribute,i=this.data,o=this._vertexCount,a={};for(const s in i)if(i[s]){if(void 0===i[s].buffer||i[s].buffer instanceof ArrayBuffer){const n=i[s].data?i[s]:{data:i[s]};n.dimension=(i[s].data?i[s].data:i[s]).length/o;const c=e.buffer(n);c[Z$7]=1,a[s]={buffer:c},s!==t&&s!==r||(a[s].array=i[s])}else i[s].buffer.destroy?a[s]=i[s]:n[i[s].buffer]&&(a[s]=v$3({},i[s]),a[s].buffer=n[i[s].buffer].buffer);(this.desc.static||s!==t)&&delete i[s].array}if(this.data=a,delete this._reglData,this.elements&&!g$1(this.elements)){const n={primitive:this.getPrimitive(),data:this.elements},t=this.getElementsType(this.elements);if(t&&(n.type=t),!this.desc.static&&!this.elements.destroy){this.indices=new Uint16Array(this.elements.length);for(let e=0;e<this.elements.length;e++)this.indices[e]=this.elements[e]}this.elements=this.elements.destroy?this.elements:e.elements(n);const r=this.elements;r[Z$7]||(r[Z$7]=0),r[Z$7]++}}getVertexCount(){const{positionAttribute:e,positionSize:n,color0Attribute:t}=this.desc;let r=this.data[e];r.data&&(r=r.data),r.array&&(r=r.array),b$5(r)?this._vertexCount=Math.ceil(r.length/n):r&&void 0!==r.count&&(this._vertexCount=r.count);const i=t;if(this.data[i]){const e=this.data[i].data||this.data[i].array||this.data[i];Array.isArray(e)?this._color0Size=e.length/this._vertexCount:e&&e.count?this._color0Size=e.count/this._vertexCount:this.data[i].buffer&&this.data[i].buffer.destroy&&(this._color0Size=this.data[i].buffer._buffer.dimension)}return this._vertexCount}getColor0Size(){return this._color0Size||0}addBuffer(e,n){return this._buffers[e]={data:n},delete this._reglData,this._deleteVAO(),this}updateBuffer(e,n){if(!this._buffers[e])throw new Error(`invalid buffer ${e} in geometry`);return this._buffers[e].buffer?this._buffers[e].buffer.subdata(n):this._buffers[e].data=n,delete this._reglData,this._deleteVAO(),this}deleteData(e){const n=this.data[e];return n?(this._incrVersion(),n.buffer&&n.buffer.destroy&&n.buffer.destroy(),delete this.data[e],delete this._reglData,this._markVAODirty(),this):this}updateData(e,n){const t=this.data[e];if(!t)return this;let r;return this._incrVersion(),this.data[e]=n,t.buffer&&t.buffer.destroy&&(r=t),e===this.desc.positionAttribute&&this.updateBoundingBox(),this.getVertexCount(),r&&(r.buffer(n),this.data[e]=r),this._prepareData(!1),this.desc.positionAttribute===e&&(this._posDirty=!0),delete this._reglData,this}updateSubData(e,n,t){const r=this.data[e];if(!r)return this;let i;if(this._incrVersion(),r.buffer&&r.buffer.destroy&&(i=r),e===this.desc.positionAttribute&&this._updateSubBoundingBox(n),i){const e=q$7[i.buffer._buffer.dtype];n.BYTES_PER_ELEMENT!==e&&(n=new(function(e,n){return e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Uint8ClampedArray?1===n?Uint8Array:2===n?Uint16Array:Uint32Array:e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array?1===n?Int8Array:2===n?Int16Array:Int32Array:e instanceof Float32Array||e instanceof Float64Array?4===n?Float32Array:Float64Array:null}(n,e))(n)),i.buffer.subdata(n,t*e)}else{const r=this.data[e].data?this.data[e].data:this.data[e];for(let e=0;e<n.length;e++)r[t+e]=n[e]}return this._prepareData(!1),this.desc.positionAttribute===e&&(this._posDirty=!0),delete this._reglData,this}getPrimitive(){return this.desc.primitive}getElements(){return this.elements}setElements(e,n){if(!e)throw new Error("elements data is invalid");this._incrVersion();const t=this.elements;return this.count=void 0===n?$$6(e):n,this.elements=e&&e.destroy?e:t.destroy?t(e):e,this._markVAODirty(!0),this}deleteElements(){return this.elements&&0!==this.elements.length?(this._incrVersion(),this.elements&&this.elements.destroy&&!this.elements[H$6]&&(this.elements.destroy(),this.elements[H$6]=1),this.elements=[],this._markVAODirty(!0),this):this}_markVAODirty(e){if(this._vao){for(const n in this._vao)e?this._vao[n].vao.destroy():this._vao[n].dirty=!0;e&&(this._vao={})}}setDrawCount(e){return this._incrVersion(),this.count1=e,this}getDrawCount(){return this.count1>=0?this.count1:this.count}setDrawOffset(e){return this._incrVersion(),this.offset=e,this}getDrawOffset(){return this.offset||0}dispose(){if(this._deleteVAO(),this._forEachBuffer((e=>{if(!e[H$6]){let n=e[Z$7];n&&n--,n<=0?(e[H$6]=!0,e.destroy()):e[Z$7]=n}})),this.properties){const e=this.properties.oldElementsBeforeHighlight;e&&!e[H$6]&&e.destroy&&(e.destroy(),e[H$6]=!0),delete this.properties.oldElementsBeforeHighlight,delete this.properties.hasInvisible}this.data={},this._buffers={},delete this._reglData,delete this._attributes,this.count=0,this.elements=[],delete this._tempPosArray,this._disposed=!0}isDisposed(){return!!this._disposed}updateBoundingBox(){let e=this.boundingBox;e||(e=this.boundingBox=new X$7);let n,r,i=this.data[this.desc.positionAttribute];if(b$5(i)||(i.data?i=i.data:P$5(i)?i=this._getAttributeData(this.desc.positionAttribute):i.array&&(n=i.min,r=i.max,i=i.array)),i&&i.length){const o=e.min,a=e.max;if(n&&r)set$4(o,...n),set$4(a,...r);else{set$4(o,i[0],i[1],i[2]),set$4(a,i[0],i[1],i[2]);for(let e=3;e<i.length;){const n=i[e++],t=i[e++],r=i[e++];n<o[0]&&(o[0]=n),t<o[1]&&(o[1]=t),r<o[2]&&(o[2]=r),n>a[0]&&(a[0]=n),t>a[1]&&(a[1]=t),r>a[2]&&(a[2]=r)}}e.updateVertex(),e.dirty()}}_updateSubBoundingBox(e){const n=this.boundingBox,t=n.min,r=n.max,i=this.desc.positionSize;for(let n=0;n<e.length;){const o=e[n++],a=e[n++];let s=0;3===i&&(s=e[n++]),o<t[0]&&(t[0]=o),a<t[1]&&(t[1]=a),s<t[2]&&(t[2]=s),o>r[0]&&(r[0]=o),a>r[1]&&(r[1]=a),s>r[2]&&(r[2]=s)}n.updateVertex(),n.dirty()}_getAttributeData(n){const t=this.data[n]&&this.data[n].array?this.data[n].array:this.data[n],r=t.buffer;if(P$5(t)){const i=this._buffers[r]?this._buffers[r].data:t.array,{count:o,size:a,stride:s,offset:c,componentType:l}=t,f=X$8.getTypedArrayCtor(l);if((0===s||s===a*f.BYTES_PER_ELEMENT)&&c%f.BYTES_PER_ELEMENT==0)return new f(i,c,o*a);if(n===this.desc.positionAttribute)return!this._tempPosArray||this._tempPosArray&&this._tempPosArray.length<a*o?(this._tempPosArray=new f(a*o),X$8.readInterleavedArray(this._tempPosArray,i,o,a,s,c,l)):this._posDirty?(this._posDirty=!1,X$8.readInterleavedArray(this._tempPosArray,i,o,a,s,c,l)):this._tempPosArray;{const n=new f(a*o);return X$8.readInterleavedArray(n,i,o,a,s,c,l)}}return t}createTangent(e="aTangent"){this._incrVersion();const{normalAttribute:n,positionAttribute:i,uv0Attribute:o}=this.desc,a=this._getAttributeData(n),f=buildTangents(this._getAttributeData(i),a,this.data[o],this.elements),d=this.data[e]=new Float32Array(f.length),u=[],h=[],m=[];for(let e=0;e<f.length;e+=4){const n=e/4*3;set$4(h,a[n],a[n+1],a[n+2]),set$3(u,f[e],f[e+1],f[e+2],f[e+3]),packTangentFrame(m,h,u),copy$3(d.subarray(e,e+4),m)}delete this._reglData}createNormal(e="aNormal"){this._incrVersion();const n=this._getAttributeData(this.desc.positionAttribute);this.data[e]=buildNormals(n.array||n,this.elements),delete this._reglData}createBarycentric(e="aBarycentric"){if("triangles"!==this.desc.primitive)throw new Error("Primitive must be triangles to create bary centric data");this._incrVersion();const n=new Uint8Array(3*this._vertexCount);for(let e=0,t=this.elements.length;e<t;)for(let t=0;t<3;t++)n[3*this.elements[e++]+t]=1;this.data[e]=n,delete this._reglData}buildUniqueVertex(){this._incrVersion();const e=this.data,n=this.elements;if(!b$5(n))throw new Error("elements must be array to build unique vertex.");const t=Object.keys(e),r={};let i=e[this.desc.positionAttribute];if(i=i.length?i:i.array,!b$5(i))throw new Error(this.desc.positionAttribute+" must be array to build unique vertex.");const o=this._vertexCount,a=n.length;for(let n=0;n<t.length;n++){const i=t[n],s=b$5(e[i])?e[i]:e[i].array,c=s.length/o;if(!b$5(s))throw new Error(i+" must be array to build unique vertex.");r[i]=s,e[i]=new s.constructor(a*c)}let s=0;for(let i=0;i<a;i++){const a=n[i];for(let n=0;n<t.length;n++){const i=t[n],c=e[i],l=r[i].length/o;for(let e=0;e<l;e++)c[s*l+e]=r[i][a*l+e]}n[i]=s++}i=this.data[this.desc.positionAttribute],this._vertexCount=Math.ceil(i.length/this.desc.positionSize),delete this._reglData}getMemorySize(){let e=0;for(const n in this.data)S$6(this.data,n)&&(e+=T$6(this.data[n]));if(this.elements){const n=this.elements;n.destroy?e+=n._elements.buffer.byteLength:n.BYTES_PER_ELEMENT?e+=n.length*n.BYTES_PER_ELEMENT:n.length&&(e+=4*n.length)}return e}_deleteVAO(){for(const e in this._vao)this._vao[e].vao.destroy();this._vao={}}_forEachBuffer(e){this.elements&&this.elements.destroy&&e(this.elements);for(const n in this.data)S$6(this.data,n)&&this.data[n]&&this.data[n].buffer&&this.data[n].buffer.destroy&&e(this.data[n].buffer);for(const n in this._buffers)S$6(this._buffers,n)&&this._buffers[n]&&this._buffers[n].buffer&&this._buffers[n].buffer.destroy&&e(this._buffers[n].buffer)}getElementsType(e){return e instanceof Uint8Array?"uint8":e instanceof Uint16Array?"uint16":e instanceof Uint32Array?"uint32":void 0}_incrVersion(){this._version++}}function $$6(e){if(g$1(e))return e;if(void 0!==e.count)return e.count;if(e.destroy)return e._elements.vertCount;if(void 0!==e.length)return e.length;if(e.data)return e.data.length;throw new Error("invalid elements length")}const ee$5=["points","lines","line strip","line loop","triangles","triangle strip","triangle fan"];function ne$5(e){return ee$5[e]}const te$5={5121:"uint8",5123:"uint16",5125:"uint32",5126:"float",36193:"half float"};function re$5(e){return te$5[e]}const ie$5={6406:"alpha",6407:"rgb",6408:"rgba",6409:"luminance",6410:"luminance alpha",33776:"rgb s3tc dxt1",33777:"rgba s3tc dxt1",33778:"rgba s3tc dxt3",33779:"rgba s3tc dxt5",35840:"rgb pvrtc 4bppv1",35841:"rgb pvrtc 2bppv1",35842:"rgba pvrtc 4bppv1",35843:"rgba pvrtc 2bppv1",35986:"rgb atc",35987:"rgba atc explicit alpha",34798:"rgba atc interpolated alpha",36196:"rgb etc1"};function oe$5(e){return ie$5[e]}const ae$5={9729:"linear",9728:"nearest"};function se$5(e){return ae$5[e]}const ce$5={9729:"linear",9728:"nearest",9984:"nearest mipmap nearest",9985:"linear mipmap nearest",9986:"nearest mipmap linear",9987:"linear mipmap linear"};function le$5(e){return ce$5[e]}const fe$5={10497:"repeat",33071:"clamp",33648:"mirror"};function de$5(e){return fe$5[e]}const ue$5="__reshader_webgl_buffer",he$5="__reshader_webgl_tex";function me$5(e,n,t){let r;if(b$5(n)?n.buffer&&void 0!==n.byteOffset&&(r=n):n.array&&n.array.buffer&&void 0!==n.array.byteOffset&&(r=n.array),!r)return null;const i=r.buffer,o=r.byteOffset;i[ue$5]||(i[ue$5]={});let a=i[ue$5][o];if(!a){const n={};t&&v$3(n,t),n.data=r,a=e.buffer(n),i[ue$5][o]=a}return a}function ve$5(e,n){const t=n.data;if(!t||!t.buffer)return e.texture(n);const r=t.buffer,i=t.byteOffset;r[he$5]||(r[he$5]={});let o=r[he$5][i];return o||(o=e.texture(n),r[he$5][i]=o),o}var _e$5=Object.freeze({__proto__:null,getPrimitive:ne$5,getMaterialType:re$5,getMaterialFormat:oe$5,getTextureMagFilter:se$5,getTextureMinFilter:le$5,getTextureWrap:de$5,getUniqueREGLBuffer:me$5,getUniqueTexture:ve$5});const ge$5=[],xe$5=[],be$5=[],pe$5=[],ye$5=[],Ae$5=[],Se$5=["a","b","c"];class Te$5 extends Q$7{constructor(e,n,t,r){super(e,n,t,{primitive:ne$5(1),positionAttribute:r.positionAttribute})}_getPosAttritute(){const e=this.data[this.desc.positionAttribute];if(!e)return null;const n=Math.pow(10,4),t=Math.cos(Math.PI/180*.8),r=this.elements,i=e.length?e:e.array,o=r.length?r?r.length:i.length/3:r,a=[0,0,0],s=new Array(3),c={},l=[],f=new Me$5;for(let e=0;e<o;e+=3){r.length?(a[0]=r[e],a[1]=r[e+1],a[2]=r[e+2]):(a[0]=e,a[1]=e+1,a[2]=e+2),f.a=this._getPos(pe$5,i,a[0]),f.b=this._getPos(ye$5,i,a[1]),f.c=this._getPos(Ae$5,i,a[2]);const o=f.getNormal(),d=f.a,u=f.b,h=f.c;if(s[0]=`${Math.round(d[0]*n)},${Math.round(d[1]*n)},${Math.round(d[2]*n)}`,s[1]=`${Math.round(u[0]*n)},${Math.round(u[1]*n)},${Math.round(u[2]*n)}`,s[2]=`${Math.round(h[0]*n)},${Math.round(h[1]*n)},${Math.round(h[2]*n)}`,s[0]!==s[1]&&s[1]!==s[2]&&s[2]!==s[0])for(let e=0;e<3;e++)this._calEdgeData(e,a,f,c,s,t,o,l)}for(const e in c)if(c[e]){const{index0:n,index1:t}=c[e];l.push(i[3*n],i[3*n+1],i[3*n+2]),l.push(i[3*t],i[3*t+1],i[3*t+2])}return this.elements=this._createElements(l),l}_getPos(e,n,r){return set$4(e,n[3*r],n[3*r+1],n[3*r+2])}_calEdgeData(e,n,r,i,o,a,s,c){const l=(e+1)%3,f=o[e],d=o[l],u=r[Se$5[e]],h=r[Se$5[l]],m=`${f}_${d}`,v=`${d}_${f}`;v in i&&i[v]?(dot$4(s,i[v].normal)<=a&&(c.push(u[0],u[1],u[2]),c.push(h[0],h[1],h[2])),i[v]=null):m in i||(i[m]={index0:n[e],index1:n[l],normal:copy$4([],s)})}_createElements(e){const n=[],t=e.length/3;for(let e=0;e<t;e++)n.push(e);return n}}class Me$5{constructor(e=[0,0,0],n=[0,0,0],t=[0,0,0]){this.a=e,this.b=n,this.c=t}getNormal(){const e=sub$2(ge$5,this.a,this.b),n=sub$2(xe$5,this.a,this.c);cross$1(be$5,e,n);const r=length$4(be$5);return set$4(be$5,be$5[0]/r,be$5[1]/r,be$5[2]/r)}}var Ce$5=F$6(class{constructor(e={},n){this._version=0,this.uniforms=_$6({},n||{},e);for(const n in e){const t=Object.getOwnPropertyDescriptor(e,n).get;t&&Object.defineProperty(this.uniforms,n,{get:t})}this._reglUniforms={},this.refCount=0,this._bindedOnTextureComplete=this._onTextureComplete.bind(this),this._genUniformKeys(),this._checkTextures()}set version(e){throw new Error("Material.version is read only.")}get version(){return this._version}set doubleSided(e){this._doubleSided=e}get doubleSided(){return this._doubleSided}isReady(){return this._loadingCount<=0}set(e,n){const t=d$2(this.uniforms[e])&&!d$2(n)||!d$2(this.uniforms[e])&&d$2(n);if(this.uniforms[e]&&this.isTexture(e)&&this.uniforms[e].dispose(),d$2(n))d$2(this.uniforms[e])||delete this.uniforms[e];else if(this.uniforms[e]=n,this._reglUniforms){const t=Object.getOwnPropertyDescriptor(this._reglUniforms,e);t&&!t.get&&(this._dirtyProps=this._dirtyProps||[],this._dirtyProps.push(e),this._reglUniforms[e]=n)}return this.isTexture(e)&&this._checkTextures(),t&&(this._genUniformKeys(),this._incrVersion()),this}_getDirtyProps(){return this._dirtyProps}_clearDirtyProps(){this._dirtyProps=null}get(e){return this.uniforms[e]}isDirty(){return this._uniformVer!==this.version}appendDefines(e){const n=this.uniforms;return n?(n.jointTexture&&(e.HAS_SKIN=1),n.morphWeights1&&(e.HAS_MORPH=1),(n.khr_offset||n.khr_rotation||n.khr_scale)&&(e.HAS_KHR_TEXTURE_TRANSFORM=1),e):e}hasSkinAnimation(){return this.uniforms&&this.uniforms.jointTexture&&this.uniforms.skinAnimation}getUniforms(e){if(this._reglUniforms&&!this.isDirty())return this._reglUniforms;const n=this.uniforms,t={};for(const r in n)this.isTexture(r)?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:function(){return n[r].getREGLTexture(e)}}):Object.getOwnPropertyDescriptor(n,r).get?Object.defineProperty(t,r,{enumerable:!0,configurable:!0,get:function(){return n[r]}}):t[r]=n[r];return this._reglUniforms=t,this._uniformVer=this.version,t}isTexture(e){return this.uniforms[e]instanceof z$6}dispose(){for(const e in this.uniforms){const n=this.uniforms[e];n&&(n.dispose?n.dispose():n.destroy&&!n[H$6]&&(n.destroy(),n[H$6]=!0))}delete this.uniforms,delete this._reglUniforms,this._disposed=!0}isDisposed(){return!!this._disposed}_checkTextures(){this._loadingCount=0;for(const e in this.uniforms)if(this.isTexture(e)){const n=this.uniforms[e];n.isReady()||(this._loadingCount++,n.on("complete",this._bindedOnTextureComplete))}}_onTextureComplete(){this._loadingCount--,this._incrVersion(),this._loadingCount<=0&&(this._disposed||this.fire("complete"))}getUniformKeys(){return this._uniformKeys}_genUniformKeys(){const e=[];for(const n in this.uniforms)S$6(this.uniforms,n)&&!d$2(this.uniforms[n])&&e.push(n);this._uniformKeys=e.join()}_incrVersion(){this._version++}getMemorySize(){const e=this.uniforms;let n=0;for(const t in e)this.isTexture(t)?n+=e[t].getMemorySize():this.uniforms[t].destroy&&(n+=M$6(this.uniforms[t]));return n}});const Oe$5={time:0,seeThrough:!0,thickness:.03,fill:[1,.5137254902,.98,1],stroke:[.7019607843,.9333333333,.2274509804,1],dashEnabled:!1,dashAnimate:!1,dashRepeats:1,dashLength:.8,dashOverlap:!0,insideAltColor:!1,squeeze:!1,squeezeMin:.5,squeezeMax:1,dualStroke:!1,secondThickness:.05,opacity:1,noiseEnable:!1};const Pe$5={baseColorFactor:[1,1,1,1],materialShininess:32,environmentExposure:1,specularStrength:32,opacity:1,extrusionOpacity:0,extrusionOpacityRange:[0,1.8],baseColorTexture:null,normalTexture:null,emissiveTexture:null,occlusionTexture:null,uvScale:[1,1],uvOffset:[0,0],alphaTest:0};class Ie$5 extends Ce$5{constructor(e){super(e,Pe$5)}static convertFrom(e){const n={};for(const t in Pe$5)n[t]=e.get(t);return new Ie$5(n)}appendDefines(e,n){super.appendDefines(e,n);const t=this.uniforms;return t.extrusionOpacity&&(e.HAS_EXTRUSION_OPACITY=1),n.data[n.desc.colorAttribute]&&(e.HAS_COLOR=1),n.data[n.desc.color0Attribute]&&(e.HAS_COLOR0=1,e.COLOR0_SIZE=n.getColor0Size()),n.data[n.desc.tangentAttribute]?e.HAS_TANGENT=1:n.data[n.desc.normalAttribute]&&(e.HAS_NORMAL=1),n.data[n.desc.uv0Attribute]?(t.baseColorTexture&&(e.HAS_BASECOLOR_MAP=1),t.occlusionTexture&&n.data[n.desc.uv1Attribute]&&(e.HAS_AO_MAP=1),t.emissiveTexture&&(e.HAS_EMISSIVE_MAP=1),t.normalTexture&&(e.HAS_NORMAL_MAP=1),(e.HAS_BASECOLOR_MAP||e.HAS_AO_MAP||e.HAS_EMISSIVE_MAP||e.HAS_NORMAL_MAP)&&(e.HAS_MAP=1),e):e}}const we$5={toons:4,specularToons:2};const Re$5={baseColorFactor:[1,1,1,1],uvScale:[1,1],uvOffset:[0,0],opacity:1,envMapExposure:128,emissiveFactor:[.1,.1,.1],specularFactor:[0,0,0],envRotationSin:0,envRotationCos:1,reflectivity:.01,themingColor:[0,0,0,0],exposureBias:.6};class Ne$5 extends Ce$5{constructor(e){super(e,Re$5)}appendDefines(e,n){super.appendDefines(e,n);const t=this.uniforms;return t.extrusionOpacity&&(e.HAS_EXTRUSION_OPACITY=1),n.data[n.desc.colorAttribute]&&(e.HAS_COLOR=1),n.data[n.desc.color0Attribute]&&(e.HAS_COLOR0=1,e.COLOR0_SIZE=n.getColor0Size()),n.data[n.desc.uv0Attribute]?(t.baseColorTexture&&(e.HAS_BASECOLOR_MAP=1),t.occlusionTexture&&n.data[n.desc.uv1Attribute]&&(e.HAS_AO_MAP=1),t.emissiveTexture&&(e.HAS_EMISSIVE_MAP=1),t.normalTexture&&(e.HAS_NORMAL_MAP=1),(e.HAS_BASECOLOR_MAP||e.HAS_AO_MAP||e.HAS_EMISSIVE_MAP||e.HAS_NORMAL_MAP)&&(e.HAS_MAP=1),e.ALPHATEST=.01,e.GAMMA_INPUT=1,e.GAMMA_FACTOR=1,e.TONEMAP_OUTPUT=1,e.ENVMAP_MODE_REFLECTION=1,e.ENV_RGBM=1,e.IRR_RGBM=1,e):e}}const Fe$5={diffuseFactor:[1,1,1,1],specularFactor:[1,1,1],glossinessFactor:1,diffuseTexture:null,specularGlossinessTexture:null,normalTexture:null,emissiveTexture:null,occlusionTexture:null},He$5=e=>class extends e{constructor(e){super(e=v$3({},Fe$5,e||{}))}appendDefines(e,n){if(super.appendDefines(e,n),e.SHADING_MODEL_SPECULAR_GLOSSINESS=1,!n.data[n.desc.uv0Attribute])return e;const t=this.uniforms;return t.diffuseTexture&&(e.HAS_DIFFUSE_MAP=1),t.specularGlossinessTexture&&(e.HAS_SPECULARGLOSSINESS_MAP=1),(e.HAS_SPECULARGLOSSINESS_MAP||e.HAS_DIFFUSE_MAP)&&(e.HAS_MAP=1),e}};class Le$5 extends(He$5(Ie$5)){}const ze$5=[];let ke$5=0;class Be$5{constructor(e,t,r={}){this._version=0,this._geometry=e,this._material=t,this.transparent=!!r.transparent,this.bloom=!!r.bloom,this.ssr=!!r.ssr,this.castShadow=d$2(r.castShadow)||r.castShadow,this.picking=!!r.picking,this.disableVAO=!!r.disableVAO,this.uniforms={},this._localTransform=identity$2(new Array(16)),this._positionMatrix=identity$2(new Array(16)),this.properties={},this._dirtyUniforms=!0,this._dirtyGeometry=!0,Object.defineProperty(this,"uuid",{value:ke$5++}),ke$5>Number.MAX_VALUE-10&&(ke$5=0)}set material(e){this._material!==e&&this.setMaterial(e)}get material(){return this._material}set version(e){throw new Error("Mesh.version is read only.")}get version(){return this._version}get geometry(){return this._geometry}set geometry(e){this._geometry!==e&&(this._incrVersion(),this._dirtyGeometry=!0),this._geometry=e}set localTransform(e){this._prevTMat||(this._prevTMat=[]),Array.isArray(e)&&!exactEquals$5(this._prevTMat,e)&&(this._incrVersion(),this._prevTMat=copy$5(this._prevTMat,e)),this._localTransform=e}get localTransform(){return this._localTransform}set positionMatrix(e){this._prevPMat||(this._prevPMat=[]),Array.isArray(e)&&!exactEquals$5(this._prevPMat,e)&&(this._incrVersion(),this._prevPMat=copy$5(this._prevPMat,e)),this._positionMatrix=e}get positionMatrix(){return this._positionMatrix}get config(){return this._cfg||(this._cfg={}),this._cfg.transparent=this.transparent,this._cfg.castShadow=this.castShadow,this._cfg.bloom=this.bloom,this._cfg.ssr=this.ssr,this._cfg.picking=this.picking,this._cfg}get defines(){return this._getDefines()}set defines(e){this.setDefines(e)}setMaterial(e){return this._material=e,this._dirtyUniforms=!0,delete this._materialVer,this.dirtyDefines=!0,this}setParent(e){return this.parent=e,this}setLocalTransform(e){return this.localTransform=e,this}setPositionMatrix(e){this.positionMatrix=e}setUniform(e,n){return void 0===this.uniforms[e]?this._dirtyUniforms=!0:(this._dirtyProps=this._dirtyProps||[],this._dirtyProps.push(e)),this.uniforms[e]=n,this}getUniform(e){return this.uniforms[e]}getDefines(){const e={};return v$3(e,this._getDefines()),this._material&&this._geometry&&this._material.appendDefines(e,this._geometry),e}_getDefines(){this._defines||(this._defines={});const e=this._geometry,n=e.data[e.desc.positionAttribute],t=e.data[e.desc.uv0Attribute],r=e.data[e.desc.normalAttribute];return n&&n.quantization&&(this._defines.HAS_DRACO_POSITION=1),t&&t.quantization&&(this._defines.HAS_DRACO_TEXCOORD=1),r&&r.quantization&&(this._defines.HAS_DRACO_NORMAL=1),this._defines}setDefines(e){const n=this._bakDefines;return this._defines=e,this.dirtyDefines=this.dirtyDefines||!!n!=!!e||!function(e,n){if(!e&&!n)return!0;const t=Object.getOwnPropertyNames(e),r=Object.getOwnPropertyNames(n);if(t.length!==r.length)return!1;for(let r=0;r<t.length;r++)if(e[t[r]]!==n[t[r]])return!1;return!0}(n,e),this.dirtyDefines&&(this._bakDefines=v$3({},e)),this}hasSkinAnimation(){return this._material&&this._material.hasSkinAnimation()}_getDefinesKey(){return this.dirtyDefines=!1,this._createDefinesKey(this.getDefines())}getCommandKey(){if(!this._commandKey||this.dirtyDefines||this._material&&this._materialKeys!==this._material.getUniformKeys()){let e=this._getDefinesKey();e+="_"+(g$1(this.getElements())?"count":"elements"),e+="_"+ +!!this.disableVAO,this._material&&(e+="_"+ +!!this._material.doubleSided),this._commandKey=e,this._material&&(this._materialKeys=this._material.getUniformKeys())}return this._commandKey}getUniforms(e){if(this._dirtyUniforms||this._dirtyGeometry||this._material&&this._materialVer!==this._material.version){this._realUniforms={},this._getUniformsForDraco();const n=this.uniforms;for(const e in this.uniforms)S$6(this.uniforms,e)&&(Object.getOwnPropertyDescriptor(n,e).get?Object.defineProperty(this._realUniforms,e,{enumerable:!0,configurable:!0,get:function(){return n[e]}}):this._realUniforms[e]=n[e]);if(this._material){const n=this._material.getUniforms(e);for(const e in n)S$6(n,e)&&!S$6(this._realUniforms,e)&&(Object.getOwnPropertyDescriptor(n,e).get?Object.defineProperty(this._realUniforms,e,{enumerable:!0,configurable:!0,get:function(){return n[e]}}):this._realUniforms[e]=n[e])}this._dirtyUniforms=!1,this._dirtyGeometry=!1,this._materialVer=this._material&&this._material.version,this._material&&this._material._clearDirtyProps(),this._dirtyProps=null}else if(this._dirtyProps||this._material&&this._material._getDirtyProps()){if(this._dirtyProps)for(const e of this._dirtyProps)this._realUniforms[e]=this.uniforms[e];const n=this._material&&this._material._getDirtyProps();if(n){const t=this._material.getUniforms(e);for(const e of n)this._realUniforms[e]=t[e];this._material._clearDirtyProps()}this._dirtyProps=null}return this._realUniforms.modelMatrix=h$2(this._localTransform)?this._localTransform():this._localTransform,this._realUniforms.positionMatrix=h$2(this._positionMatrix)?this._positionMatrix():this._positionMatrix,this._realUniforms}_getUniformsForDraco(){const e=this._geometry,n=e.data[e.desc.positionAttribute],t=e.data[e.desc.uv0Attribute],r=e.data[e.desc.normalAttribute];if(n&&n.quantization){const e=n.quantization,t=e.range/(1<<e.quantizationBits);this._realUniforms.minValues_pos=e.minValues,this._realUniforms.gltf_u_dec_position_normConstant=t}if(t&&t.quantization){const e=t.quantization;this._realUniforms.minValues_tex=e.minValues,this._realUniforms.gltf_u_dec_texcoord_0_normConstant=e.range/(1<<e.quantizationBits)}r&&r.quantization&&(this._realUniforms.gltf_u_dec_normal_rangeConstant=(1<<r.quantization.quantizationBits)-1)}getMaterial(){return this._material}getElements(){return this._geometry.getElements()}_getREGLAttrData(e,n){return this._geometry.getREGLData(e,n,this.disableVAO)}getREGLProps(e,n){const t=this.getUniforms(e);return v$3(t,this._getREGLAttrData(e,n)),A$4(e)&&!this.disableVAO||(t.elements=this._geometry.getElements()),t.meshProperties=this.properties,t.meshConfig=this.config,t.count=this._geometry.getDrawCount(),t.offset=this._geometry.getDrawOffset(),t.primitive=this._geometry.getPrimitive(),t}dispose(){return delete this._geometry,delete this._material,this.uniforms={},this}isValid(){return this._geometry&&!this._geometry.isDisposed()&&(!this._material||!this._material.isDisposed())}getBoundingBox(){return this._bbox||this.updateBoundingBox(),multiply$5(ze$5,this._localTransform,this._positionMatrix),exactEquals$5(ze$5,this._currentTransform)&&this._geometry.boundingBox.equals(this._geoBox)||this.updateBoundingBox(),this._bboxArr}updateBoundingBox(){const e=this._geometry.boundingBox;this._bbox||(this._bbox=new X$7),this._bboxArr||(this._bboxArr=[[],[]]),this._geoBox||(this._geoBox=new X$7),X$7.copy(this._bbox,e),this._bbox.updateVertex(),"InstancedMesh"===this.constructor.name?(this._bbox.transform(this._localTransform,this._positionMatrix),this._currentTransform=multiply$5(this._currentTransform||[],this._positionMatrix,this._localTransform)):(this._bbox.transform(this._positionMatrix,this._localTransform),this._currentTransform=multiply$5(this._currentTransform||[],this._localTransform,this._positionMatrix)),X$7.copy(this._geoBox,e),copy$4(this._bboxArr[0],this._bbox.min),copy$4(this._bboxArr[1],this._bbox.max)}_createDefinesKey(e){const n=[];for(const t in e)n.push(t,e[t]);return n.join(",")}_incrVersion(){this._version++}getMemorySize(){return(this.geometry&&this.geometry.getMemorySize()||0)+(this.material&&this.material.getMemorySize()||0)}}Be$5.prototype.getWorldTransform=function(){const e=[];return function(){const t=this.parent;return t?multiply$5(e,t.getWorldTransform(),this._localTransform):this._localTransform}}();class Ge$5 extends Be$5{constructor(e,n,t,r,i={}){super(t,r,i),this._instanceCount=n,this.instancedData=e||{},this._checkInstancedProp(),this._vao={}}get instanceCount(){return this._instanceCount}set instanceCount(e){this._incrVersion(),this._instanceCount=e}getMemorySize(){return super.getMemorySize()+this._getInstanceMemorySize()}_getInstanceMemorySize(){let e=0;for(const n in this.instancedData)S$6(this.instancedData,n)&&(e+=T$6(this.instancedData[n]));return e}_checkInstancedProp(){for(const e in this.instancedData)if(this.geometry.data[e])throw new Error(`Duplicate attribute ${e} defined in geometry and instanced data`)}_getREGLAttrData(e,n){const t=this.geometry.getAttrData(n);if(A$4(e)){const r=n.key;if(!this._vao[r]||this._vao[r].dirty){const i=n.map((e=>e.name)),o=[];for(let e=0;e<i.length;e++){const n=t[i[e]];o.push(n&&n.buffer||this.instancedData[i[e]])}const a={attributes:o,primitive:this.geometry.getPrimitive()};this._vao[r]?this._vao[r].vao(a):this._vao[r]={vao:e.vao(a)},delete this._vao[r].dirty}return this._vao[r]}return t}getDefines(){const e=super.getDefines();return e.HAS_INSTANCE=1,e}getCommandKey(e){return"i_"+super.getCommandKey(e)}updateInstancedData(e,n){const t=this.instancedData[e];if(!t)return this;if(this._incrVersion(),this.instancedData[e]=n,t.buffer&&t.buffer.destroy&&t.buffer.destroy(),this._vao)for(const e in this._vao)this._vao[e].dirty=!0;return this}generateInstancedBuffers(e){const n=this.instancedData,t={};for(const r in n)n[r]&&(void 0!==n[r].buffer&&n[r].buffer.destroy?(t[r]=n[r],t[r].divisor&&(t[r].divisor=1)):t[r]=n[r].destroy?{buffer:n[r],divisor:1}:{buffer:e.buffer({data:n[r],dimension:n[r].length/this._instanceCount}),divisor:1});return this.instancedData=t,this}getREGLProps(e,n){const t=super.getREGLProps(e,n);return A$4(e)||v$3(t,this.instancedData),t.elements=this.geometry.getElements(),t.instances=this._instanceCount,t}disposeInstanceData(){const e=this.instancedData;if(e)for(const n in e)e[n]&&e[n].destroy&&!e[n][H$6]&&(e[n][H$6]=1,e[n].destroy());this.instancedData={};for(const e in this._vao)this._vao[e].vao.destroy();this._vao={}}_getBytesPerElement(e){switch(e){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5124:case 5125:case 5126:return 4}throw new Error("unsupported data type: "+e)}}const Ue$5={getArrayBuffer:(e,n)=>Ue$5.get(e,{responseType:"arraybuffer"},n),get:function(e,n,t){const r=Ue$5._getClient(t);if(r.open("GET",e,!0),n){for(const e in n.headers)r.setRequestHeader(e,n.headers[e]);r.withCredentials="include"===n.credentials,n.responseType&&(r.responseType=n.responseType)}return r.send(null),r},_wrapCallback:function(e,n){return function(){4===e.readyState&&(200===e.status?"arraybuffer"===e.responseType?0===e.response.byteLength?n(new Error("http status 200 returned without content.")):n(null,{data:e.response,cacheControl:e.getResponseHeader("Cache-Control"),expires:e.getResponseHeader("Expires"),contentType:e.getResponseHeader("Content-Type")}):n(null,e.responseText):n(new Error(e.statusText+","+e.status)))}},_getClient:function(e){let n;try{n=new XMLHttpRequest}catch(e){try{n=new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{n=new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}}return n.onreadystatechange=Ue$5._wrapCallback(n,e),n}};var Ve$5=F$6(class{constructor(e){this.defaultTexture=e,this.defaultCubeTexture=new Array(6),this.resources={}}get(e){return Array.isArray(e)?this._loadImages(e):this._loadImage(e)}getArrayBuffer(e){if(Array.isArray(e)){const n=e.map((e=>this.getArrayBuffer(e)));return Promise.all(n)}return new Promise(((n,t)=>{Ue$5.getArrayBuffer(e,((r,i)=>{r?t(r):n({url:e,data:i})}))}))}disposeRes(e){return Array.isArray(e)?e.forEach((e=>this._disposeOne(e))):this._disposeOne(e),this}isLoading(){return this._count&&this._count>0}getDefaultTexture(e){return Array.isArray(e)?this._getBlankTextures(e.length):this.defaultTexture}_disposeOne(e){const n=this.resources;n[e]&&(n[e].count--,n[e].count<=0&&delete n[e])}_loadImage(e){const n=this.resources;return n[e]?Promise.resolve({url:e,data:n[e].image}):new Promise(((t,r)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){n[e]={image:i,count:1},t({url:e,data:i})},i.onerror=function(e){r(e)},i.onabort=function(){r(`image(${e}) loading aborted.`)},i.src=e}))}_loadImages(e){const n=e.map((e=>this._loadImage(e,!0)));return Promise.all(n)}_getBlankTextures(e){const n=new Array(e);for(let e=0;e<6;e++)n.push(this.defaultTexture);return n}});const je$5=[],Xe$5=[];let We$5=0;class Ke$5{constructor(e){this._id=We$5++,this.sortedMeshes={},this.setMeshes(e),this._compareBinded=this._compare.bind(this),this.dirty()}setMeshes(e){if(this.clear(),!e||Array.isArray(e)&&!e.length||e===this.meshes)return this;e=Array.isArray(e)?e:[e],this.meshes=[];for(let n=0;n<e.length;n++){const t=e[n];t&&(t._scenes=t._scenes||{},t._scenes[this._id]=1,this.meshes.push(t))}return this.dirty(),this}addMesh(e){return!e||Array.isArray(e)&&!e.length||(Array.isArray(e)?e.forEach((e=>{e._scenes=e._scenes||{},e._scenes[this._id]||(e._scenes[this._id]=1,this.meshes.push(e),this.dirty())})):(e._scenes=e._scenes||{},e._scenes[this._id]||(e._scenes[this._id]=1,this.meshes.push(e),this.dirty()))),this}removeMesh(e){if(!e||Array.isArray(e)&&!e.length)return this;if(Array.isArray(e)){let n=!1;for(let t=0;t<e.length;t++)e[t]._scenes&&e[t]._scenes[this._id]&&(n=!0,this.dirty(),delete e[t]._scenes[this._id]);n&&(this.meshes=this.meshes.filter((n=>e.indexOf(n)<0)))}else{if(!e._scenes||!e._scenes[this._id])return this;const n=this.meshes.indexOf(e);n>=0&&this.meshes.splice(n,1),delete e._scenes[this._id],this.dirty()}return this}getMeshes(){return this.meshes||[]}clear(){if(this.meshes)for(let e=0;e<this.meshes.length;e++)delete this.meshes[e]._scenes[this._id];return this.meshes=[],this.sortedMeshes.opaques=[],this.sortedMeshes.transparents=[],this}dirty(){return this._dirty=!0,this}sortMeshes(e){const n=this.meshes;this.sortFunction&&n.sort(this.sortFunction);let t=this.sortedMeshes.transparents;if(this._dirty){const e=this.sortedMeshes.opaques=[];t=this.sortedMeshes.transparents=[];for(let r=0,i=n.length;r<i;r++)n[r].transparent?t.push(n[r]):e.push(n[r])}e&&t.length>1&&(this._cameraPosition=e,t.sort(this._compareBinded),delete this._cameraPosition),this._dirty=!1}getSortedMeshes(){return this._dirty&&this.sortMeshes(),this.sortedMeshes||[]}_compare(e,n){return transformMat4$2(je$5,e.geometry.boundingBox.getCenter(),e.localTransform),transformMat4$2(Xe$5,n.geometry.boundingBox.getCenter(),n.localTransform),dist$2(Xe$5,this._cameraPosition)-dist$2(je$5,this._cameraPosition)}}const qe$5=String.fromCharCode;function Ye$5(e,n,t,r){if(e[3]>0){const i=Math.pow(2,e[3]-128-8+r);n[t+0]=e[0]*i,n[t+1]=e[1]*i,n[t+2]=e[2]*i}else n[t+0]=0,n[t+1]=0,n[t+2]=0;return n[t+3]=1,n}function Je$5(e,n,t){const r=e[n]/t,i=e[n+1]/t,o=e[n+2]/t;let a=y$4(Math.max(Math.max(r,i),Math.max(o,1e-6)),0,1);a=Math.ceil(255*a)/255,e[n]=Math.min(255,r/a*255),e[n+1]=Math.min(255,i/a*255),e[n+2]=Math.min(255,o/a*255),e[n+3]=Math.min(255,255*a)}function Ze$5(e,n,t,r){let i=0,o=0,a=r;for(;a>0;)if(e[o][0]=n[t++],e[o][1]=n[t++],e[o][2]=n[t++],e[o][3]=n[t++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(let n=e[o][3]<<i>>>0;n>0;n--)(c=e[o])[0]=(s=e[o-1])[0],c[1]=s[1],c[2]=s[2],c[3]=s[3],o++,a--;i+=8}else o++,a--,i=0;var s,c;return t}function Qe$5(e,n,t,r){if(r<8|r>32767)return Ze$5(e,n,t,r);let i=n[t++];if(2!==i)return Ze$5(e,n,t-1,r);if(e[0][1]=n[t++],e[0][2]=n[t++],i=n[t++],(e[0][2]<<8>>>0|i)>>>0!==r)return null;for(let i=0;i<4;i++)for(let o=0;o<r;){let r=n[t++];if(r>128){r=(127&r)>>>0;const a=n[t++];for(;r--;)e[o++][i]=a}else for(;r--;)e[o++][i]=n[t++]}return t}function $e$5(e,n=0,t=9){const r=new Uint8Array(e),i=r.length;if("#?"!==function(e,n,t){let r="";for(let i=0;i<2;i++)r+=qe$5(e[i]);return r}(r))return null;for(var o=2;o<i&&("\n"!==qe$5(r[o])||"\n"!==qe$5(r[o+1]));o++);if(o>=i)return null;o+=2;let a="";for(;o<i;o++){const e=qe$5(r[o]);if("\n"===e)break;a+=e}const s=a.split(" "),c=parseInt(s[1]),l=parseInt(s[3]);if(!l||!c)return null;let f=o+1;const d=[];for(let e=0;e<l;e++){d[e]=[];for(let n=0;n<4;n++)d[e][n]=0}let u=0;const h=new Array(l*c*4);let m=0;for(let e=0;e<c;e++){if(f=Qe$5(d,r,f,l),!f)return null;for(let e=0;e<l;e++)Ye$5(d[e],h,m,n),u=Math.max(u,h[m],h[m+1],h[m+2],h[m+3]),m+=4}u=Math.min(u,t),m=0;for(let e=0;e<c;e++)for(let e=0;e<l;e++)Je$5(h,m,u),m+=4;return{width:l,height:c,pixels:h,rgbmRange:u}}class en$5 extends z$6{onLoad({data:e}){const n=this.config;if(n){if(n.hdr){if(!(e=$e$5(e.data,0,n.maxRange)))throw new Error("Invalid hdr data"+(n.url?":"+n.url:""));this.rgbmRange=e.rgbmRange,n.data=e.pixels}else n.data=e;n.width=n.width||e.width,n.height=n.height||e.height,this._updateREGL()}}createREGLTexture(e){if(b$5(this.config.data)||b$5(this.config.mipmap)){const n=ve$5(e,this.config);return n._reshader_refCount||(n._reshader_refCount=0),n._reshader_refCount++,n}return e.texture(this.config)}}class tn$5 extends Q$7{constructor(e){super({aPosition:new(p$5(e=e||0))([-1,-1,e,1,-1,e,-1,1,e,1,1,e]),aNormal:new Int8Array([0,0,1,0,0,1,0,0,1,0,0,1])},new Uint16Array([0,1,3,3,2,0]))}}const rn$5={vsm_shadow_vert:"\nuniform mat4 shadow_lightProjViewModelMatrix;\nvarying vec4 shadow_vLightSpacePos;\nvoid shadow_computeShadowPars(vec4 position) {\n    shadow_vLightSpacePos = shadow_lightProjViewModelMatrix * position;\n}",vsm_shadow_frag:"\nuniform sampler2D shadow_shadowMap;\nuniform float shadow_opacity;\nuniform vec3 shadow_color;\n#if defined(USE_ESM)\n    uniform float esm_shadow_threshold;\n#endif\nvarying vec4 shadow_vLightSpacePos;\n#ifdef PACK_FLOAT\n    #include <common_pack_float>\n#endif\n#if defined(USE_ESM)\nfloat esm(vec3 projCoords, vec4 shadowTexel) {\n    float compare = projCoords.z;\n    float c = 120.0;\n    #ifdef PACK_FLOAT\n        float depth = common_decodeDepth(shadowTexel);\n        if (depth >= 1.0 - 1E-6 || compare <= depth) {\n            return 1.0;\n        }\n    #else\n        float depth = shadowTexel.r;\n    #endif\n    depth = exp(-c * min(compare - depth, 0.05));\n    return clamp(depth, esm_shadow_threshold, 1.0);\n}\n#endif\n#if defined(USE_VSM)\nfloat vsm_shadow_chebyshevUpperBound(vec3 projCoords, vec4 shadowTexel){\n    vec2 moments = shadowTexel.rg;\n    float distance = projCoords.z;\n    if (distance >= 1.0 || distance <= moments.x)\n        return 1.0 ;\n    float variance = moments.y - (moments.x * moments.x);\n    variance = max(variance, 0.00002);\n    float d = distance - moments.x;\n    float p_max = variance / (variance + d * d);\n    return p_max;\n}\n#endif\nfloat shadow_computeShadow_coeff(sampler2D shadowMap, vec3 projCoords) {\n    vec2 uv = projCoords.xy;\n    vec4 shadowTexel = texture2D(shadowMap, uv);\n    #if defined(USE_ESM)\n        float esm_coeff = esm(projCoords, shadowTexel);\n        float coeff = esm_coeff * esm_coeff;\n    #endif\n    #if defined(USE_VSM)\n        float vsm_coeff = vsm_shadow_chebyshevUpperBound(projCoords, shadowTexel);\n        float coeff = vsm_coeff;\n    #endif\n    return 1.0 - (1.0 - coeff) * shadow_opacity;\n}\nfloat shadow_computeShadow() {\n    vec3 projCoords = shadow_vLightSpacePos.xyz / shadow_vLightSpacePos.w;\n    projCoords = projCoords * 0.5 + 0.5;\n    if(projCoords.z >= 1.0 || projCoords.x < 0.0 || projCoords.x > 1.0 || projCoords.y < 0.0 || projCoords.y > 1.0) return 1.0;\n    return shadow_computeShadow_coeff(shadow_shadowMap, projCoords);\n}\nvec3 shadow_blend(vec3 color, float coeff) {\n    color = color * coeff + shadow_color * shadow_opacity * (1.0 - coeff);\n    return color;\n}",fbo_picking_vert:"\n#ifdef ENABLE_PICKING\n#if HAS_PICKING_ID == 1\nattribute float aPickingId;\n#elif HAS_PICKING_ID == 2\nuniform float uPickingId;\n#endif\nvarying float vPickingId;\nvarying float vFbo_picking_viewZ;\nvarying float vFbo_picking_visible;\n#endif\nvarying float vFbo_picking_fragDepth;\nvoid fbo_picking_setData(float viewPosZ, bool visible) {\n    #ifdef ENABLE_PICKING\n    #if HAS_PICKING_ID == 1\n       vPickingId = aPickingId;\n    #elif HAS_PICKING_ID == 2\n        vPickingId = uPickingId;\n    #endif\n        vFbo_picking_viewZ = viewPosZ;\n    #endif\n    vFbo_picking_visible = visible ? 1.0 : 0.0;\n    vFbo_picking_fragDepth = viewPosZ + 1.0;\n}",common_pack_float:"const float COMMON_FLOAT_MAX =  1.70141184e38;\nconst float COMMON_FLOAT_MIN = 1.17549435e-38;\nfloat common_packFloat(vec4 val){\n    vec4 scl = floor(255.0 * val + 0.5);\n    float sgn = (scl.a < 128.0) ? 1.0 : -1.0;\n    float exn = mod(scl.a * 2.0, 256.0) + floor(scl.b / 128.0) - 127.0;\n    float man = 1.0 +\n        (scl.r / 8388608.0) +\n        (scl.g / 32768.0) +\n        mod(scl.b, 128.0) / 128.0;\n    return sgn * man * pow(2.0, exn);\n}\nvec4 common_unpackFloat(highp float v) {\n    highp float av = abs(v);\n    if(av < COMMON_FLOAT_MIN) {\n        return vec4(0.0, 0.0, 0.0, 0.0);\n    } else if(v > COMMON_FLOAT_MAX) {\n        return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n    } else if(v < -COMMON_FLOAT_MAX) {\n        return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n    }\n    highp vec4 c = vec4(0,0,0,0);\n    highp float e = floor(log2(av));\n    highp float m = av * pow(2.0, -e) - 1.0;\n    c[1] = floor(128.0 * m);\n    m -= c[1] / 128.0;\n    c[2] = floor(32768.0 * m);\n    m -= c[2] / 32768.0;\n    c[3] = floor(8388608.0 * m);\n    highp float ebias = e + 127.0;\n    c[0] = floor(ebias / 2.0);\n    ebias -= c[0] * 2.0;\n    c[1] += floor(ebias) * 128.0;\n    c[0] += 128.0 * step(0.0, -v);\n    return c / 255.0;\n}\nvec4 common_encodeDepth(const in float depth) {\n    float alpha = 1.0;\n    vec4 pack = vec4(0.0);\n    pack.a = alpha;\n    const vec3 code = vec3(1.0, 255.0, 65025.0);\n    pack.rgb = vec3(code * depth);\n    pack.gb = fract(pack.gb);\n    pack.rg -= pack.gb * (1.0 / 256.0);\n    pack.b -= mod(pack.b, 4.0 / 255.0);\n    return pack;\n}\nfloat common_decodeDepth(const in vec4 pack) {\n    return pack.r + pack.g / 255.0;\n}",invert_matrix:"mat4 invert_matrix(mat4 matrix) {\n    #if __VERSION__ == 300\n        return inverse(matrix);\n    #else\n        vec4 vector1 = matrix[0], vector2 = matrix[1], vector3 = matrix[2], vector4 = matrix[3];\n        float a00 = vector1.x, a01 = vector1.y, a02 = vector1.z, a03 = vector1.w;\n        float a10 = vector2.x, a11 = vector2.y, a12 = vector2.z, a13 = vector2.w;\n        float a20 = vector3.x, a21 = vector3.y, a22 = vector3.z, a23 = vector3.w;\n        float a30 = vector4.x, a31 = vector4.y, a32 = vector4.z, a33 = vector4.w;\n        float b00 = a00 * a11 - a01 * a10;\n        float b01 = a00 * a12 - a02 * a10;\n        float b02 = a00 * a13 - a03 * a10;\n        float b03 = a01 * a12 - a02 * a11;\n        float b04 = a01 * a13 - a03 * a11;\n        float b05 = a02 * a13 - a03 * a12;\n        float b06 = a20 * a31 - a21 * a30;\n        float b07 = a20 * a32 - a22 * a30;\n        float b08 = a20 * a33 - a23 * a30;\n        float b09 = a21 * a32 - a22 * a31;\n        float b10 = a21 * a33 - a23 * a31;\n        float b11 = a22 * a33 - a23 * a32;\n        float det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;\n        det = 1.0 / det;\n        mat4 m = mat4(\n            (a11 * b11 - a12 * b10 + a13 * b09) * det,\n            (a02 * b10 - a01 * b11 - a03 * b09) * det,\n            (a31 * b05 - a32 * b04 + a33 * b03) * det,\n            (a22 * b04 - a21 * b05 - a23 * b03) * det,\n            (a12 * b08 - a10 * b11 - a13 * b07) * det,\n            (a00 * b11 - a02 * b08 + a03 * b07) * det,\n            (a32 * b02 - a30 * b05 - a33 * b01) * det,\n            (a20 * b05 - a22 * b02 + a23 * b01) * det,\n            (a10 * b10 - a11 * b08 + a13 * b06) * det,\n            (a01 * b08 - a00 * b10 - a03 * b06) * det,\n            (a30 * b04 - a31 * b02 + a33 * b00) * det,\n            (a21 * b02 - a20 * b04 - a23 * b00) * det,\n            (a11 * b07 - a10 * b09 - a12 * b06) * det,\n            (a00 * b09 - a01 * b07 + a02 * b06) * det,\n            (a31 * b01 - a30 * b03 - a32 * b00) * det,\n            (a20 * b03 - a21 * b01 + a22 * b00) * det\n        );\n        return m;\n    #endif\n}\nmat4 transpose_matrix(mat4 matrix) {\n    #if __VERSION__ == 300\n        return transpose(matrix);\n    #else\n        vec4 vector1 = matrix[0], vector2 = matrix[1], vector3 = matrix[2], vector4 = matrix[3];\n        float a01 = vector1.y, a02 = vector1.z, a03 = vector1.w;\n        float a12 = vector2.z, a13 = vector2.w;\n        float a23 = vector3.w;\n        mat4 m = mat4(\n            vector1.x,\n            vector2.x,\n            vector3.x,\n            vector4.x,\n            a01,\n            vector2.y,\n            vector3.y,\n            vector4.y,\n            a02,\n            a12,\n            vector3.z,\n            vector4.z,\n            a03,\n            a13,\n            a23,\n            vector4.w\n        );\n        return m;\n    #endif\n}",get_output:"#include <invert_matrix>\n#include <draco_decode_vert>\n#ifdef HAS_INSTANCE\n    #include <instance_vert>\n    #ifdef HAS_INSTANCE_COLOR\n        varying vec4 vInstanceColor;\n    #endif\n#endif\n#ifdef HAS_SKIN\n    uniform int skinAnimation;\n    #include <skin_vert>\n#endif\n#include <mask_vert>\n#ifdef HAS_MORPH\n    attribute vec3 POSITION0;\n    attribute vec3 POSITION1;\n    attribute vec3 POSITION2;\n    attribute vec3 POSITION3;\n    attribute vec3 POSITION4;\n    attribute vec3 POSITION5;\n    attribute vec3 POSITION6;\n    attribute vec3 POSITION7;\n    #ifdef HAS_MORPHNORMALS\n        attribute vec3 NORMAL0;\n        attribute vec3 NORMAL1;\n        attribute vec3 NORMAL2;\n        attribute vec3 NORMAL3;\n    #endif\n    uniform vec4 morphWeights1;\n    uniform vec4 morphWeights2;\n#endif\n#ifdef HAS_TERRAIN_ALTITUDE\nattribute float aTerrainAltitude;\n#endif\nmat4 getPositionMatrix() {\n    mat4 worldMatrix;\n    #ifdef HAS_INSTANCE\n        #ifdef HAS_INSTANCE_COLOR\n            vInstanceColor = instance_getInstanceColor();\n        #endif\n        mat4 attributeMatrix = instance_getAttributeMatrix();\n        #ifdef HAS_SKIN\n            if (skinAnimation == 1) {\n                worldMatrix = attributeMatrix * positionMatrix * skin_getSkinMatrix();\n            } else {\n                worldMatrix = attributeMatrix * positionMatrix;\n            }\n        #else\n            worldMatrix = attributeMatrix * positionMatrix;\n        #endif\n    #else\n        #ifdef HAS_SKIN\n            if (skinAnimation == 1) {\n                worldMatrix = skin_getSkinMatrix() * positionMatrix;\n            } else {\n                worldMatrix = positionMatrix;\n            }\n        #else\n            worldMatrix = positionMatrix;\n        #endif\n    #endif\n    return worldMatrix;\n}\n#ifdef HAS_MIN_ALTITUDE\nuniform float minAltitude;\n#endif\nvec4 getPosition(vec3 aPosition) {\n    vec3 position = decode_getPosition(aPosition);\n    #ifdef HAS_MORPH\n        vec4 POSITION = vec4(position + morphWeights1[0] * POSITION0 + morphWeights1[1] * POSITION1 + morphWeights1[2] * POSITION2 + morphWeights1[3] * POSITION3\n        + morphWeights2[0] * POSITION4 + morphWeights2[1] * POSITION5 + morphWeights2[2] * POSITION6 + morphWeights2[3] * POSITION7\n        , 1.0);\n    #else\n        vec4 POSITION = vec4(position, 1.0);\n    #endif\n    #ifdef HAS_TERRAIN_ALTITUDE\n        POSITION.z += aTerrainAltitude * 100.0;\n    #endif\n    #ifdef HAS_MIN_ALTITUDE\n        POSITION.z += minAltitude * 100.0;\n    #endif\n    return POSITION;\n}\nvec3 appendMorphNormal(vec3 NORMAL) {\n    #ifdef HAS_MORPHNORMALS\n        vec3 normal = NORMAL + morphWeights1[0] * NORMAL0 + morphWeights1[1] * NORMAL1 + morphWeights1[2] * NORMAL2 + morphWeights1[3] * NORMAL3;\n    #else\n        vec3 normal = NORMAL;\n    #endif\n    return normal;\n}",instance_vert:"attribute vec4 instance_vectorA;\nattribute vec4 instance_vectorB;\nattribute vec4 instance_vectorC;\n#ifdef HAS_INSTANCE_TERRAIN_ALTITUDE\nattribute float aTerrainAltitude;\nuniform float terrainAltitudeScale;\n#endif\nmat4 instance_getAttributeMatrix() {\n    mat4 mat =  mat4(\n        instance_vectorA.x, instance_vectorB.x, instance_vectorC.x, 0.0,\n        instance_vectorA.y, instance_vectorB.y, instance_vectorC.y, 0.0,\n        instance_vectorA.z, instance_vectorB.z, instance_vectorC.z, 0.0,\n        instance_vectorA.w, instance_vectorB.w, instance_vectorC.w, 1.0\n    );\n    #ifdef HAS_INSTANCE_TERRAIN_ALTITUDE\n        mat4 terrainMat = mat4(\n            1., 0., 0., 0.,\n            0., 1., 0., 0.,\n            0., 0., 1., 0.,\n            0., 0., aTerrainAltitude * terrainAltitudeScale, 1.\n        );\n        mat = terrainMat * mat;\n    #endif\n    return mat;\n}\n#ifdef HAS_INSTANCE_COLOR\n    attribute vec4 instance_color;\n    vec4 instance_getInstanceColor() {\n        return instance_color;\n    }\n#endif",skin_vert:"attribute vec4 WEIGHTS_0;\nattribute vec4 JOINTS_0;\nuniform sampler2D jointTexture;\nuniform vec2 jointTextureSize;\nuniform float numJoints;\n#define ROW0_U ((0.5 + 0.0) / 4.)\n#define ROW1_U ((0.5 + 1.0) / 4.)\n#define ROW2_U ((0.5 + 2.0) / 4.)\n#define ROW3_U ((0.5 + 3.0) / 4.)\nmat4 skin_getBoneMatrix(float jointNdx) {\n    float v = (jointNdx + 0.5) / numJoints;\n    return mat4(\n        texture2D(jointTexture, vec2(ROW0_U, v)),\n        texture2D(jointTexture, vec2(ROW1_U, v)),\n        texture2D(jointTexture, vec2(ROW2_U, v)),\n        texture2D(jointTexture, vec2(ROW3_U, v)));\n}\nmat4 skin_getSkinMatrix() {\n        mat4 skinMatrix = skin_getBoneMatrix(JOINTS_0[0]) * WEIGHTS_0[0] +\n                        skin_getBoneMatrix(JOINTS_0[1]) * WEIGHTS_0[1] +\n                        skin_getBoneMatrix(JOINTS_0[2]) * WEIGHTS_0[2] +\n                        skin_getBoneMatrix(JOINTS_0[3]) * WEIGHTS_0[3];\n        return skinMatrix;\n}",heatmap_render_vert:"#ifdef HAS_HEATMAP\nvarying vec2 heatmap_vTexCoord;\nvoid heatmap_compute(mat4 matrix, vec3 position) {\n    vec4 pos = matrix * vec4(position.xy, 0., 1.);\n    heatmap_vTexCoord = (1. + pos.xy / pos.w) / 2.;\n}\n#endif",heatmap_render_frag:"#ifdef HAS_HEATMAP\nuniform sampler2D heatmap_inputTexture;\nuniform sampler2D heatmap_colorRamp;\nuniform float heatmap_heatmapOpacity;\nvarying vec2 heatmap_vTexCoord;\nvec4 heatmap_getColor(vec4 color) {\n    float t = texture2D(heatmap_inputTexture, heatmap_vTexCoord).r;\n    vec4 heatmapColor = texture2D(heatmap_colorRamp, vec2(t, 0.5)) * heatmap_heatmapOpacity;\n    return color * (1.0 - heatmapColor.a) + heatmapColor * heatmapColor.a;\n}\n#endif",line_extrusion_vert:"#ifdef IS_LINE_EXTRUSION\n    #define ALTITUDE_SCALE 32767.0;\n    #define EXTRUDE_SCALE 63.0;\n    attribute vec2 aExtrude;\n    #ifdef HAS_LINE_WIDTH\n        attribute float aLineWidth;\n    #else\n        uniform float lineWidth;\n    #endif\n    #ifdef HAS_LINE_HEIGHT\n        attribute float aLineHeight;\n    #else\n        uniform float lineHeight;\n    #endif\n    uniform float linePixelScale;\n    vec3 getLineExtrudePosition(vec3 position) {\n        #ifdef HAS_LINE_WIDTH\n            float lineWidth = aLineWidth / 2.0;\n        #endif\n        #ifdef HAS_LINE_HEIGHT\n            float lineHeight = aLineHeight / 10.0;\n        #endif\n        float halfwidth = lineWidth / 2.0;\n        float outset = halfwidth;\n        vec2 dist = outset * aExtrude / EXTRUDE_SCALE;\n        position.z *= lineHeight / ALTITUDE_SCALE;\n        return position + vec3(dist, 0.0) * linePixelScale;\n    }\n#endif",gl2_vert:"#if __VERSION__ == 300\n    #define texture2D texture\n    #define varying out\n    #define attribute in\n#endif",gl2_frag:"#if __VERSION__ == 300\n    #define varying in\n    #define gl_FragDepthEXT gl_FragDepth\n    #define texture2D texture\n    #define textureCube texture\n    #define texture2DProj textureProj\n    #define texture2DLodEXT textureLod\n    #define texture2DProjLodEXT textureProjLod\n    #define textureCubeLodEXT textureLod\n    #define texture2DGradEXT textureGrad\n    #define texture2DProjGradEXT textureProjGrad\n    #define textureCubeGradEXT textureGrad\n    #define texture2D texture\n    out vec4 glFragColor;\n#else\n    vec4 glFragColor;\n#endif",hsv_frag:"\nconst mediump vec4 HSV_K0 = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);\nconst mediump vec4 HSV_K1 = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\nconst mediump float HSV_E = 1.0e-10;\nvec3 hsv_rgb2hsv(vec3 c) {\n    vec4 K = HSV_K0;\n    vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));\n    vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));\n    float d = q.x - min(q.w, q.y);\n    float e = HSV_E;\n    return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);\n}\nvec3 hsv_hsv2rgb(vec3 c) {\n    vec4 K = HSV_K1;\n    vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);\n    return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);\n}\nvec4 hsv_apply(vec4 c, vec3 hsvOffset) {\n    vec3 hsv = hsv_rgb2hsv(c.rgb);\n    hsv += hsv * hsvOffset;\n    hsv = clamp(hsv, 0.0, 1.0);\n    return vec4(hsv_hsv2rgb(hsv), c.a);\n}\nvec3 hsv_apply(vec3 c, vec3 hsvOffset) {\n    vec3 hsv = hsv_rgb2hsv(c.rgb);\n    hsv += hsv * hsvOffset;\n    hsv = clamp(hsv, 0.0, 1.0);\n    return hsv_hsv2rgb(hsv);\n}\nmat4 contrastMatrix(float contrast)\n{\n    float t = (1.0 - contrast) / 2.0;\n    return mat4(\n        contrast, 0., 0., 0.,\n        0., contrast, 0., 0.,\n        0., 0., contrast, 0.,\n        t, t, t, 1\n    );\n}",snow_frag:"#ifdef HAS_SNOW\n    float lerp(float a, float b, float w) {\n        return a + w * (b - a);\n    }\n    vec3 snow(vec4 sceneColor, vec3 normalColor, float height) {\n        float snowIntense = normalColor.b;\n        vec3 fixedC = vec3(1.0, 1.0, 1.0);\n        if (height < 1.0) {\n            float r = lerp(0.5, fixedC.x, snowIntense);\n            float g = lerp(0.5, fixedC.y, snowIntense);\n            float b = lerp(0.5, fixedC.z, snowIntense);\n            return vec3(r, g, b);\n        } else {\n            float r = lerp(sceneColor.r, fixedC.x, snowIntense);\n            float g = lerp(sceneColor.g, fixedC.y, snowIntense);\n            float b = lerp(sceneColor.b, fixedC.z, snowIntense);\n            return vec3(r, g, b);\n        }\n    }\n#endif",draco_decode_vert:"#if defined(HAS_TANGENT)\n    attribute vec4 aTangent;\n#elif defined(HAS_NORMAL)\n    #ifdef HAS_DRACO_NORMAL\n        attribute vec2 aNormal;\n        uniform float gltf_u_dec_normal_rangeConstant;\n    #else\n        attribute vec3 aNormal;\n    #endif\n#endif\n#ifdef HAS_DRACO_POSITION\n    uniform float gltf_u_dec_position_normConstant;\n    uniform vec3 minValues_pos;\n    vec3 decodeDracoPosition(vec3 aPosition) {\n        return minValues_pos + aPosition * gltf_u_dec_position_normConstant;\n    }\n#endif\n#ifdef HAS_DRACO_TEXCOORD\n    uniform vec2 minValues_tex;\n    uniform float gltf_u_dec_texcoord_0_normConstant;\n    vec2 decodeDracoTexcoord(vec2 aTexCoord) {\n        return minValues_tex + aTexCoord * gltf_u_dec_texcoord_0_normConstant;\n    }\n#endif\n#ifdef HAS_WEB3D_quantized_attributes_TEXCOORD\n    uniform mat3 decodeMatrix;\n#endif\n#ifdef HAS_DRACO_NORMAL\n    float czm_signNotZero(float value) {\n        return value >= 0.0 ? 1.0 : -1.0;\n    }\n    vec2 czm_signNotZero(vec2 value) {\n        return vec2(czm_signNotZero(value.x), czm_signNotZero(value.y));\n    }\n    vec3 decodeDracoNormal(vec2 encoded, float range)\n    {\n        if (encoded.x == 0.0 && encoded.y == 0.0) {\n            return vec3(0.0, 0.0, 0.0);\n        }\n        encoded = encoded / range * 2.0 - 1.0;\n        vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n        if (v.z < 0.0) {\n            v.xy = (1.0 - abs(v.yx)) * czm_signNotZero(v.xy);\n        }\n        return normalize(v);\n    }\n    vec3 decode_getNormal(vec2 aNormal) {\n        return decodeDracoNormal(aNormal, gltf_u_dec_normal_rangeConstant).zxy;\n    }\n#endif\n#ifdef HAS_COMPRESSED_INT16\n    #ifdef HAS_COMPRESSED_INT16_POSITION\n      uniform vec2 compressedPositionRange;\n    #endif\n    #ifdef HAS_COMPRESSED_INT16_TEXCOORD_0\n      uniform vec2 compressedTexcoordRange_0;\n    #endif\n    #ifdef HAS_COMPRESSED_INT16_TEXCOORD_1\n      uniform vec2 compressedTexcoordRange_1;\n    #endif\n    #ifdef HAS_COMPRESSED_INT16_NORMAL\n      uniform vec2 compressedNormalRange;\n    #endif\n    #ifdef HAS_COMPRESSED_INT16_RATIO\n      uniform float compressed_ratio;\n    #endif\n    float int16ToFloat32(float value, vec2 range) {\n        float v = (value >= 32768.0) ? -(65536.0 - value) / 32768.0 : value / 32767.0;\n        return (v + 1.0) * (range.y - range.x) / 2.0 + range.x;\n    }\n#endif\nvec3 decode_getPosition(vec3 aPosition) {\n    vec3 position = aPosition;\n    #if defined(HAS_COMPRESSED_INT16) && defined(HAS_COMPRESSED_INT16_POSITION)\n        float x = int16ToFloat32(aPosition.x, compressedPositionRange);\n        float y = int16ToFloat32(aPosition.y, compressedPositionRange);\n        float z = int16ToFloat32(aPosition.z, compressedPositionRange);\n        #ifdef HAS_COMPRESSED_INT16_RATIO\n          position = vec3(x / compressed_ratio, y / compressed_ratio, z);\n        #else\n          position = vec3(x, y, z);\n        #endif\n    #endif\n    #ifdef HAS_DRACO_POSITION\n        return decodeDracoPosition(position);\n    #else\n        return position;\n    #endif\n}\nvec2 decode_getTexcoord(vec2 aTexCoord) {\n    vec2 texcoord = aTexCoord;\n    #if defined(HAS_COMPRESSED_INT16) && (defined(HAS_COMPRESSED_INT16_TEXCOORD_0) || defined(HAS_COMPRESSED_INT16_TEXCOORD_1))\n        float x = int16ToFloat32(aTexCoord.x, compressedTexcoordRange_0);\n        float y = int16ToFloat32(aTexCoord.y, compressedTexcoordRange_0);\n        texcoord = vec2(x, y);\n    #endif\n    #ifdef HAS_DRACO_TEXCOORD\n        return decodeDracoTexcoord(texcoord);\n    #elif defined(HAS_WEB3D_quantized_attributes_TEXCOORD)\n        vec3 web3dTexcoord = decodeMatrix * vec3(texcoord, 1.0);\n        return vec2(web3dTexcoord.x, web3dTexcoord.y);\n    #else\n        return texcoord;\n    #endif\n}\nvec3 decode_getNormal(vec3 aNormal) {\n    #ifdef HAS_COMPRESSED_INT16_NORMAL\n        aNormal.x = int16ToFloat32(aNormal.x, compressedNormalRange);\n        aNormal.y = int16ToFloat32(aNormal.y, compressedNormalRange);\n        aNormal.z = int16ToFloat32(aNormal.z, compressedNormalRange);\n    #endif\n    return aNormal;\n}",highlight_vert:"#if defined(HAS_HIGHLIGHT_COLOR)\n    attribute vec4 aHighlightColor;\n    varying vec4 vHighlightColor;\n#endif\n#if defined(HAS_HIGHLIGHT_OPACITY)\n    attribute float aHighlightOpacity;\n    varying float vHighlightOpacity;\n#endif\nvoid highlight_setVarying() {\n    #if defined(HAS_HIGHLIGHT_COLOR)\n        vHighlightColor = aHighlightColor / 255.0;\n    #endif\n    #if defined(HAS_HIGHLIGHT_OPACITY)\n        vHighlightOpacity = aHighlightOpacity / 255.0;\n    #endif\n}",highlight_frag:"#if defined(HAS_HIGHLIGHT_COLOR)\n\tvarying vec4 vHighlightColor;\n#endif\n#if defined(HAS_HIGHLIGHT_OPACITY)\n    varying float vHighlightOpacity;\n#endif\nvec4 highlight_blendColor(vec4 color) {\n\tvec4 outColor;\n\t#if defined(HAS_HIGHLIGHT_COLOR)\n\t\tcolor.rgb = color.rgb * (1.0 - vHighlightColor.a) + vHighlightColor.rgb * vHighlightColor.a;\n\t\t#ifndef HAS_HIGHLIGHT_COLOR_POINT\n        \tcolor.a = color.a * (1.0 - vHighlightColor.a) + vHighlightColor.a;\n        #endif\n        outColor = color;\n\t#else\n\t\toutColor = color;\n\t#endif\n\t#if defined(HAS_HIGHLIGHT_OPACITY)\n\t\toutColor *= vHighlightOpacity;\n\t#endif\n\treturn outColor;\n}",mask_vert:"#ifdef HAS_MASK_EXTENT\n    uniform vec4 mask_extent;\n    uniform sampler2D mask_colorExtent;\n    uniform sampler2D mask_modeExtent;\n    uniform float mask_maskMode;\n    uniform float mask_hasFlatOut;\n    uniform mat4 viewMatrix;\n    uniform float mask_heightRatio;\n    uniform float mask_heightOffset;\n    varying vec4 vWorldPosition;\n    varying vec2 vUVInExtent;\n    varying float vHeightRatio;\n    varying float vHeightOffset;\n    const float CLIPINSIDE_MODE = 0.2;\n    const float FLATINSIDE_MODE = 0.3;\n    const float FLATOUTSIDE_MODE = 0.4;\n    const float ELEVATE_MODE = 0.7;\n    float random (vec2 st) {\n        return fract(sin(dot(st.xy,vec2(12.9898,78.233)))*43758.5453123) * 0.1;\n    }\n    bool isInExtent(vec4 color) {\n        return length(color.rgb) > 0.0;\n    }\n    float getFlatHeight(float maskMode, float flatHeight, float height) {\n      if (maskMode <= ELEVATE_MODE && maskMode > 0.6) {\n          return flatHeight + height;\n      } else {\n        return flatHeight;\n      }\n    }\n    vec4 getNoErrorPosition(vec4 position, vec4 wPosition) {\n      vec4 realPos = modelViewMatrix * position;      vec4 pos = viewMatrix * wPosition;      vec4 tempPos = viewMatrix * modelMatrix * position;      float deltaX = realPos.x - tempPos.x;\n      float deltaY = realPos.y - tempPos.y;\n      float deltaZ = realPos.z - tempPos.z;\n      pos.x = pos.x + deltaX;\n      pos.y = pos.y + deltaY;\n      pos.z = pos.z + deltaZ;\n      return pos;\n    }\n    vec4 getMaskPosition(vec4 position, mat4 modelMatrix) {\n        vWorldPosition = modelMatrix * position;\n        float w = mask_extent.z - mask_extent.x;\n        float h = mask_extent.y - mask_extent.w;\n        vec2 uvInExtent = vec2((vWorldPosition.x - mask_extent.x) / abs(w), 1.0 - (vWorldPosition.y - mask_extent.w) / h);\n        vec4 extentColor = texture2D(mask_colorExtent, uvInExtent);\n        vec3 maskOptionColor = texture2D(mask_modeExtent, uvInExtent).rgb;\n        float maskMode = maskOptionColor.r;\n        float flatHeight = maskOptionColor.g / mask_heightRatio + mask_heightOffset;\n        float height = getFlatHeight(maskMode, flatHeight, vWorldPosition.z);\n        vec4 wPosition = vec4(vWorldPosition.x, vWorldPosition.y, height, vWorldPosition.w);\n        vUVInExtent = uvInExtent;\n        vHeightRatio = mask_heightRatio;\n        vHeightOffset = mask_heightOffset;\n        if (maskMode <= FLATOUTSIDE_MODE && maskMode > FLATINSIDE_MODE) {\n            return modelViewMatrix * position;;\n        } else if (mask_hasFlatOut == 1.0) {\n            return getNoErrorPosition(position, wPosition);\n        }\n        if (isInExtent(extentColor) == true && maskMode <= FLATINSIDE_MODE && maskMode > CLIPINSIDE_MODE) {\n            return getNoErrorPosition(position, wPosition);\n        } if (isInExtent(extentColor) == true && maskMode <= ELEVATE_MODE && maskMode > 0.6) {\n            return getNoErrorPosition(position, wPosition);\n        } else {\n            return modelViewMatrix * position;\n        }\n    }\n#endif",mask_frag:"#ifdef HAS_MASK_EXTENT\n    uniform sampler2D mask_colorExtent;\n    uniform sampler2D mask_modeExtent;\n    uniform float mask_hasClipOut;\n    varying float vHeightRatio;\n    varying float vHeightOffset;\n    varying vec2 vUVInExtent;\n    varying vec4 vWorldPosition;\n    const float CLIPINSIDE_MODE = 0.1;\n    const float CLIPOUTSIDE_MODE = 0.2;\n    const float FLATINSIDE_MODE = 0.3;\n    const float FLATOUTSIDE_MODE = 0.4;\n    const float COLOR_MODE = 0.5;\n    const float VIDEO_MODE = 0.6;\n    bool isInExtent(vec4 color) {\n        return length(color.rgb) > 0.0;\n    }\n    vec4 setMask(vec4 glFragColor) {\n        vec4 extentColor = texture2D(mask_colorExtent, vUVInExtent);\n        vec4 modeColor = texture2D(mask_modeExtent, vUVInExtent);\n        float maskMode = modeColor.r;\n        float minHeight = modeColor.b / vHeightRatio + vHeightOffset;\n        float maxHeight = modeColor.a / vHeightRatio + vHeightOffset;\n        if (maskMode > CLIPINSIDE_MODE && maskMode <= CLIPOUTSIDE_MODE) {\n            if (minHeight == 0.0 && maxHeight == 0.0) {\n                return glFragColor;\n            } else if (vWorldPosition.z >= minHeight && vWorldPosition.z <= maxHeight) {\n                return glFragColor;\n            } else {\n              discard;\n            }\n        } else if (mask_hasClipOut == 1.0) {\n            discard;\n        }\n        if (isInExtent(extentColor) == true && maskMode <= CLIPINSIDE_MODE && maskMode > 0.0) {\n            if (minHeight == 0.0 && maxHeight == 0.0) {\n                discard;\n            } else if (vWorldPosition.z >= minHeight && vWorldPosition.z <= maxHeight) {\n                discard;\n            } else {\n              return glFragColor;\n            }\n        } else if (isInExtent(extentColor) == true && maskMode <= VIDEO_MODE && maskMode > FLATOUTSIDE_MODE) {\n            if (minHeight == 0.0 && maxHeight == 0.0) {\n                glFragColor = vec4(mix(extentColor.rgb, glFragColor.rgb, 1.0 - extentColor.a), glFragColor.a);\n            } else if (vWorldPosition.z >= minHeight && vWorldPosition.z <= maxHeight) {\n                glFragColor = vec4(mix(extentColor.rgb, glFragColor.rgb, 1.0 - extentColor.a), glFragColor.a);\n            }\n        }\n        return glFragColor;\n    }\n#endif",computeTexcoord_frag:"#ifdef HAS_KHR_TEXTURE_TRANSFORM\n    uniform vec2 khr_offset;\n    uniform float khr_rotation;\n    uniform vec2 khr_scale;\n    vec2 khr_tex_transformTexCoord(vec2 texCoords, vec2 offset, float rotation, vec2 scale) {\n        rotation = -rotation;\n        mat3 transform = mat3(\n        cos(rotation) * scale.x, sin(rotation) * scale.x, 0.0, -sin(rotation) * scale.y, cos(rotation) * scale.y, 0.0, offset.x, offset.y, 1.0);\n        vec2 transformedTexCoords = (transform * vec3(fract(texCoords), 1.0)).xy;\n        return transformedTexCoords;\n    }\n#endif\nvarying highp vec2 vTexCoord;\n#ifdef HAS_I3S_UVREGION\n    varying vec4 vUvRegion;\n#endif\nvec2 computeTexCoord(vec2 texCoord) {\n    #ifdef HAS_I3S_UVREGION\n        vec2 atlasScale = vUvRegion.zw - vUvRegion.xy;\n        vec2 uvAtlas = fract(texCoord) * atlasScale + vUvRegion.xy;\n        return uvAtlas;\n    #elif defined(HAS_KHR_TEXTURE_TRANSFORM)\n        return khr_tex_transformTexCoord(texCoord, khr_offset, khr_rotation, khr_scale);\n    #else\n        return texCoord;\n    #endif\n}",terrain_normal_frag:"#ifdef HAS_TERRAIN_NORMAL\n    uniform sampler2D terrainHeightTexture;\n    uniform vec2 terrainHeightMapResolution;\n    uniform vec2 terrainResolution;\n    uniform float terrainHeightScale;\n    uniform float terrainTileResolution;\n    uniform vec4 terrainUnpackFactors;\n    float getHeight(vec2 uv) {\n        vec4 color = texture2D(terrainHeightTexture, uv) * 255.0;\n        color.a = -1.0;\n        return dot(color, terrainUnpackFactors) / 4.0;\n    }\n    vec3 convertTerrainHeightToNormalMap(vec2 uv) {\n        uv.y = 1.0 - uv.y;\n        vec2 epsilon = 1.0 / terrainHeightMapResolution;\n        float a = getHeight(uv + vec2(-epsilon.x, -epsilon.y));\n        float b = getHeight(uv + vec2(0, -epsilon.y));\n        float c = getHeight(uv + vec2(epsilon.x, -epsilon.y));\n        float d = getHeight(uv + vec2(-epsilon.x, 0));\n        float e = getHeight(uv + vec2(epsilon.x, 0));\n        float f = getHeight(uv + vec2(-epsilon.x, epsilon.y));\n        float g = getHeight(uv + vec2(0, epsilon.y));\n        float h = getHeight(uv + vec2(epsilon.x, epsilon.y));\n        vec2 dxy = vec2(\n            (c + e + e + h) - (a + d + d + f),\n            (f + g + g + h) - (a + b + b + c)\n        );\n        return normalize(vec3(dxy / epsilon, terrainResolution ));\n    }\n#endif",vertex_color_vert:"#ifdef HAS_VERTEX_COLOR\nattribute float aVertexColorType;\nuniform vec4 vertexColorsOfType[VERTEX_TYPES_COUNT];\nvarying vec4 vertexColor_color;\nvoid vertexColor_update() {\n    vertexColor_color = vertexColorsOfType[int(aVertexColorType)];\n}\n#endif",vertex_color_frag:"#ifdef HAS_VERTEX_COLOR\nvarying vec4 vertexColor_color;\nvec4 vertexColor_get() {\n\treturn vertexColor_color;\n}\n#endif",excavate_vert:"#ifdef HAS_EXCAVATE_ANALYSIS\n  uniform vec4 excavateExtent;\n  varying vec2 vCoordinateTexcoord;\n  varying float vHeight;\n  float getWorldHeight() {\n    vec4 wPosition = modelMatrix * getPosition(aPosition);\n    return wPosition.z;\n  }\n  vec2 getCoordinateTexcoord() {\n    mat4 localPositionMatrix = getPositionMatrix();\n    vec4 wPosition = modelMatrix * localPositionMatrix * getPosition(aPosition);\n    float x = (wPosition.x - excavateExtent.x) / (excavateExtent.z - excavateExtent.x);\n    float y = (wPosition.y - excavateExtent.y) / (excavateExtent.w - excavateExtent.y);\n    return vec2(x, y);\n  }\n#endif",excavate_frag:"#ifdef HAS_EXCAVATE_ANALYSIS\n  uniform sampler2D heightmap;\n  uniform float excavateHeight;\n  varying vec2 vCoordinateTexcoord;\n  varying float vHeight;\n  const vec2 range = vec2(-100.0, 1000.0);\n  float decodeHeight(const in vec4 pack) {\n      return pack.r + pack.g / 255.0;\n  }\n  vec4 excavateColor(vec4 fragColor) {\n      float samplerHeight = decodeHeight(texture2D(heightmap, vCoordinateTexcoord));\n      float realHeight = samplerHeight * (range.y - range.x) + range.x;\n      if(realHeight < range.x || realHeight > range.y) {\n          realHeight = 0.0;\n      }\n      if(vHeight > realHeight) {\n          discard;\n      }\n      return fragColor;\n  }\n#endif"};var on$5={register(e,n){if(rn$5[e])throw new Error(`Key of ${e} is already registered in ShaderLib.`);rn$5[e]=n},compile:e=>sn$5(e)};const an$5=/^[ \t]*#include +<([\w\d.]+)>/gm;function sn$5(e){return e.replace(an$5,cn$5)}function cn$5(e,n){const t=rn$5[n];if(!t)throw new Error("Can not resolve #include <"+n+">");return sn$5(t)}let dn$4=0;const un$4={};class hn$5{constructor({vert:e,frag:n,uniforms:t,defines:r,extraCommandProps:i}){this.vert=e,this.frag=n;const o=dn$4++;Object.defineProperty(this,"uid",{enumerable:!0,configurable:!1,get:()=>o}),this.shaderDefines=r&&v$3({},r)||{},t=this.uniforms=(t||[]).slice(),this.contextDesc={};for(let e=0,n=t.length;e<n;e++){const n=t[e];if(f$3(n))if(n.indexOf("[")>0){const{name:e,len:t}=mn$4(n);this.contextDesc[e]={name:e,type:"array",length:t}}else this.contextDesc[n]=null;else if(n.name.indexOf("[")>0){const{name:e,len:t}=mn$4(n.name);this.contextDesc[e]={name:e,type:"array",length:t,fn:n.fn}}else this.contextDesc[n.name]=n}this.extraCommandProps=i&&v$3({},i)||{},this.commands={},this._compileSource()}set shaderDefines(e){this._shaderDefines=e,this.dkey=Object.keys(this._shaderDefines).join()}get shaderDefines(){return this._shaderDefines||{}}setDefines(e){this.shaderDefines=e}setFramebuffer(e){return this.context.framebuffer=e,this}appendDescUniforms(e,n){const t=n,r=this.contextDesc;for(const i in r)if(r[i])if("array"===r[i].type){const o=i,a=r[i].length;let s=n[i];if(r[i].fn&&(s=r[i].fn(null,n)),!s)continue;if(s.length!==a)throw new Error(`${o} uniform's length is not ${a}`);t[o]=t[o]||{};for(let n=0;n<a;n++)t[o][""+n]=s[n].getREGLTexture?s[n].getREGLTexture(e):s[n]}else"function"===r[i].type&&(Object.getOwnPropertyDescriptor(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:function(){return r[i].fn(null,n)}}));return t}setUniforms(e){if(e.modelMatrix||e.positionMatrix)throw new Error("modelMatrix or positionMatrix is reserved uniform name for Mesh, please change to another name");return this.contextKeys=e?Object.keys(e).join():null,this.context=e,this}getVersion(e,n){return"#version"===n.substring(0,8)?"":0===e.limits.version.indexOf("WebGL 2.0")&&300===this.version?"#version 300 es\n":"#version 100\n"}getActiveVars(e,n,t,r){const i=r;if(un$4[i])return un$4[i];const o=e._gl,a=o.createProgram(),s=o.createShader(35633);o.shaderSource(s,n),o.compileShader(s);const c=o.createShader(35632);o.shaderSource(c,t),o.compileShader(c),o.attachShader(a,c),o.attachShader(a,s),o.linkProgram(a);const l=o.getProgramParameter(a,35721),f=[];for(let e=0;e<l;++e){const n=o.getActiveAttrib(a,e);n&&f.push({name:n.name,type:n.type})}const d=o.getProgramParameter(a,35718),u=[];for(let e=0;e<d;++e){const n=o.getActiveUniform(a,e);let t=n.name;n.name.indexOf("[")>0&&(t=t.replace("[0]","")),u.push(t)}return o.deleteProgram(a),o.deleteShader(s),o.deleteShader(c),un$4[i]={activeUniforms:u,activeAttributes:f},un$4[i]}createREGLCommand(e,n,t,r,i,o={}){const a=A$4(e)&&!i,s=v$3({},this.shaderDefines||{},n||{}),c=this._insertDefines(this.vert,s),l=this.getVersion(e,c)+c,f=this._insertDefines(this.frag,s),d=this.getVersion(e,f)+f,u=I$5(l)+"_"+I$5(d),{activeAttributes:h,activeUniforms:m}=this.getActiveVars(e,l,d,u),_={};h.forEach(((n,t)=>{const r=n.name;_[r]=a?t:e.prop(r)}));const x={};m.forEach((n=>{x[n]=e.prop(n)}));const b=this.contextDesc;for(const n in b)if(b[n]&&"function"===b[n].type)x[n]=b[n].fn;else if(b[n]&&"array"===b[n].type){const t=b[n].name,r=b[n].length;for(let n=0;n<r;n++){const r=`${t}[${n}]`;x[r]=e.prop(r)}}else x[n]=e.prop(n);const p={vert:l,frag:d,uniforms:x,attributes:_};a&&(p.vao=e.prop("vao")),a&&!r||!t||g$1(t)||(p.elements=e.prop("elements")),p.count=e.prop("count"),p.offset=e.prop("offset"),p.primitive=e.prop("primitive"),p.framebuffer=e.prop("framebuffer"),r&&(p.instances=e.prop("instances")),v$3(p,this.extraCommandProps,o);const y=e(p);return h.key=h.map((e=>e.name)).join(),y.activeAttributes=h,y}dispose(){for(const e in this.commands){const n=this.commands[e];n&&n.destroy&&!n[H$6]&&(n[H$6]=!0,n.destroy())}this.commands={},delete this.vert,delete this.frag}_insertDefines(e,n){const t=[];for(const e in n)S$6(n,e)&&!h$2(n[e])&&t.push(`#define ${e} ${n[e]}\n`);return t.join("")+e}_compileSource(){this.vert=on$5.compile(this.vert),this.frag=on$5.compile(this.frag)}}function mn$4(e){const n=e.indexOf("["),t=e.indexOf("]");return{name:e.substring(0,n),len:+e.substring(n+1,t)}}class vn$4 extends hn$5{draw(e,n){if(!n||!n.length)return 0;const t=[];let r,i=0;for(let o=0,a=n.length;o<a;o++){if(!n[o].isValid()){o===a-1&&r&&t.length&&r(t);continue}if(!n[o].geometry.getDrawCount()||!this._runFilter(n[o])){o===a-1&&r&&t.length&&r(t);continue}const s=this.getMeshCommand(e,n[o]);t.length&&r!==s&&(r(t),t.length=0);const c=n[o].getREGLProps(e,s.activeAttributes);this._ensureContextDefines(c),c.shaderContext=this.context,this.appendDescUniforms(e,c),t.push(c),i++,o<a-1?r=s:o===a-1&&s(t)}return i}_ensureContextDefines(e){if(this.context&&(e.contextKeys||(e.contextKeys={}),e.contextKeys[this.uid]!==this.contextKeys)){for(const n in this.context)"framebuffer"===n||Object.getOwnPropertyDescriptor(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:function(){return this.shaderContext[n]}});Object.getOwnPropertyDescriptor(e,"framebuffer")||Object.defineProperty(e,"framebuffer",{configurable:!1,enumerable:!0,get:function(){return this.targetFramebuffer||this.shaderContext&&this.shaderContext.framebuffer}}),e.contextKeys[this.uid]=this.contextKeys}}_runFilter(e){const n=this.filter;if(!n)return!0;if(Array.isArray(n)){for(let t=0;t<n.length;t++)if(!n[t](e))return!1;return!0}return n(e)}getMeshCommand(e,n){this._cmdKeys||(this._cmdKeys={});const t=this.dkey||"default";let r=this._cmdKeys[t];r||(r=this._cmdKeys[t]={});const i=n.getCommandKey(e);r[i]||(r[i]=t+"_"+n.getCommandKey(e));const o=r[i];let a=this.commands[o];if(!a){const t=n.getDefines(),r=n.getMaterial(),i={};r&&r.doubleSided&&this.extraCommandProps&&this.extraCommandProps.cull&&(i.cull={enable:!1}),a=this.commands[o]=this.createREGLCommand(e,t,n.getElements(),n instanceof Ge$5,n.disableVAO,i)}return a}}var gn$4="precision mediump float;\n#include <gl2_frag>\nuniform vec4 baseColorFactor;\nuniform float materialShininess;\nuniform float environmentExposure;\nuniform float specularStrength;\nuniform vec3 light0_viewDirection;\nuniform vec3 ambientColor;\nuniform vec4 light0_diffuse;\nuniform vec3 lightSpecular;\nuniform vec3 cameraPosition;\nuniform float alphaTest;\n#ifdef HAS_TOON\nuniform float toons;\nuniform float specularToons;\n#endif\n#ifdef HAS_TANGENT\nvarying vec4 vTangent;\n#endif\n#ifdef HAS_MAP\n#include <computeTexcoord_frag>\n#endif\nvarying vec3 vNormal;\nvarying vec3 vFragPos;\n#ifdef HAS_INSTANCE_COLOR\nvarying vec4 vInstanceColor;\n#endif\n#ifdef HAS_BASECOLOR_MAP\nuniform sampler2D baseColorTexture;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nuniform vec2 extrusionOpacityRange;\nvarying float vExtrusionOpacity;\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nvarying vec4 vColor;\n#elif defined(IS_LINE_EXTRUSION)\nuniform vec4 lineColor;\n#else\nuniform vec4 polygonFill;\n#endif\n#ifdef HAS_LAYER_OPACITY\nuniform float layerOpacity;\n#endif\n#ifdef IS_LINE_EXTRUSION\nuniform float lineOpacity;\n#else\nuniform float polygonOpacity;\n#endif\n#ifdef HAS_AO_MAP\nuniform sampler2D occlusionTexture;\nvarying vec2 vTexCoord1;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D normalTexture;\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D emissiveTexture;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\nuniform vec4 diffuseFactor;\nuniform vec3 specularFactor;\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D diffuseTexture;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\n#include <heatmap_render_frag>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#include <highlight_frag>\n#include <mask_frag>\nvec3 c() {\n  \n#if defined(HAS_NORMAL_MAP)\nvec3 d = normalize(vNormal);\n  vec3 e = texture2D(normalTexture, computeTexCoord(vTexCoord)).xyz * 2. - 1.;\n#if defined(HAS_TANGENT)\nvec3 t = normalize(vTangent.xyz);\n  vec3 b = normalize(cross(d, t) * sign(vTangent.w));\n  mat3 f = mat3(t, b, d);\n  return normalize(f * e);\n#else\nreturn normalize(e);\n#endif\n#else\nreturn normalize(vNormal);\n#endif\n}\nvec4 h(const in vec4 i) {\n  return vec4(i.r < .0031308 ? i.r * 12.92 : 1.055 * pow(i.r, 1. / 2.4) - .055, i.g < .0031308 ? i.g * 12.92 : 1.055 * pow(i.g, 1. / 2.4) - .055, i.b < .0031308 ? i.b * 12.92 : 1.055 * pow(i.b, 1. / 2.4) - .055, i.a);\n}\nvec4 j() {\n  \n#if defined(HAS_BASECOLOR_MAP)\nreturn texture2D(baseColorTexture, computeTexCoord(vTexCoord));\n#elif defined(HAS_DIFFUSE_MAP)\nreturn texture2D(diffuseTexture, computeTexCoord(vTexCoord));\n#elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn diffuseFactor;\n#else\nreturn baseColorFactor;\n#endif\n}\nvec3 k() {\n  \n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nreturn texture2D(specularGlossinessTexture, computeTexCoord(vTexCoord)).rgb;\n#elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn specularFactor;\n#else\nreturn vec3(1.);\n#endif\n}\nvoid main() {\n  vec4 l = j();\n  vec3 m = environmentExposure * ambientColor * l.rgb;\n#ifdef HAS_INSTANCE_COLOR\nm *= vInstanceColor.rgb;\n#endif\nvec3 o = c();\n  vec3 u = normalize(-light0_viewDirection);\n  float v = max(dot(o, u), .0);\n#ifdef HAS_TOON\nfloat A = floor(v * toons);\n  v = A / toons;\n#endif\nvec3 B = light0_diffuse.rgb * v * l.rgb;\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nvec3 i = vColor.rgb;\n#elif defined(IS_LINE_EXTRUSION)\nvec3 i = lineColor.rgb;\n#else\nvec3 i = polygonFill.rgb;\n#endif\n#ifdef HAS_INSTANCE_COLOR\ni *= vInstanceColor.rgb;\n#endif\nm *= i.rgb;\n  B *= i.rgb;\n  vec3 C = normalize(cameraPosition - vFragPos);\n  vec3 D = normalize(u + C);\n  float E = pow(max(dot(o, D), .0), materialShininess);\n#ifdef HAS_TOON\nfloat F = floor(E * specularToons);\n  E = F / specularToons;\n#endif\nvec3 G = specularStrength * lightSpecular * E * k();\n#ifdef HAS_OCCLUSION_MAP\nfloat H = texture2D(occlusionTexture, computeTexCoord(vTexCoord1)).r;\n  m *= H;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat I = shadow_computeShadow();\n  B = shadow_blend(B, I).rgb;\n  G = shadow_blend(G, I).rgb;\n#endif\nvec3 J = m + B + G;\n#ifdef HAS_EMISSIVE_MAP\nvec3 K = texture2D(emissiveTexture, computeTexCoord(vTexCoord)).rgb;\n  J += K;\n#endif\n#ifdef IS_LINE_EXTRUSION\nglFragColor = vec4(J, lineOpacity * l.a);\n#else\nglFragColor = vec4(J, polygonOpacity * l.a);\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nfloat L = vColor.a;\n#elif defined(IS_LINE_EXTRUSION)\nfloat L = lineColor.a;\n#else\nfloat L = polygonFill.a;\n#endif\nglFragColor *= L;\n#ifdef HAS_EXTRUSION_OPACITY\nfloat M = extrusionOpacityRange.x;\n  float N = extrusionOpacityRange.y;\n  float O = M + vExtrusionOpacity * (N - M);\n  O = clamp(O, .0, 1.);\n  glFragColor *= O;\n#endif\nif(glFragColor.a < alphaTest) {\n    discard;\n  }\n#ifdef HAS_HEATMAP\nglFragColor = heatmap_getColor(glFragColor);\n#endif\nglFragColor = highlight_blendColor(glFragColor);\n#ifdef HAS_LAYER_OPACITY\nglFragColor *= layerOpacity;\n#endif\n#ifdef HAS_MASK_EXTENT\nglFragColor = setMask(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",xn$4="#include <gl2_vert>\nattribute vec3 aPosition;\n#include <line_extrusion_vert>\n#ifdef HAS_MAP\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n#ifdef HAS_I3S_UVREGION\nattribute vec4 uvRegion;\nvarying vec4 vUvRegion;\n#endif\n#if defined(HAS_AO_MAP)\nattribute vec2 aTexCoord1;\nvarying vec2 vTexCoord1;\n#endif\n#endif\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nattribute vec3 aColor0;\n#else\nattribute vec4 aColor0;\n#endif\nvarying vec4 vColor;\n#endif\nvarying vec3 vFragPos;\nvarying vec3 vNormal;\nuniform mat4 projMatrix;\nuniform mat3 modelNormalMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 positionMatrix;\nuniform vec2 halton;\nuniform vec2 outSize;\nuniform mat4 projViewMatrix;\n#include <highlight_vert>\n#include <get_output>\n#include <heatmap_render_vert>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nattribute float aExtrusionOpacity;\nvarying float vExtrusionOpacity;\n#endif\n#if defined(HAS_TANGENT)\nvarying vec4 vTangent;\n#endif\nvoid c(const highp vec4 q, out highp vec3 d) {\n  d = vec3(.0, .0, 1.) + vec3(2., -2., -2.) * q.x * q.zwx + vec3(2., 2., -2.) * q.y * q.wzy;\n}\nvoid c(const highp vec4 q, out highp vec3 d, out highp vec3 t) {\n  c(q, d);\n  t = vec3(1., .0, .0) + vec3(-2., 2., -2.) * q.y * q.yxw + vec3(-2., 2., 2.) * q.z * q.zwx;\n}\nvoid main() {\n  \n#ifdef IS_LINE_EXTRUSION\nvec4 e = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 e = getPosition(aPosition);\n#endif\nmat4 f = getPositionMatrix();\n  vFragPos = vec3(modelMatrix * f * e);\n#if defined(HAS_NORMAL) || defined(HAS_TANGENT)\nmat3 h = modelNormalMatrix * mat3(f);\n  vec3 i;\n#if defined(HAS_TANGENT)\nvec3 t;\n  c(aTangent, i, t);\n  vTangent = vec4(h * t, aTangent.w);\n#else\ni = decode_getNormal(aNormal);\n#endif\nvec3 j = appendMorphNormal(i);\n  vNormal = normalize(h * j);\n#else\nvNormal = vec3(.0);\n#endif\nmat4 k = projMatrix;\n  k[2].xy += halton.xy / outSize.xy;\n#ifdef HAS_MASK_EXTENT\ngl_Position = k * getMaskPosition(f * e, modelMatrix);\n#else\ngl_Position = k * modelViewMatrix * f * e;\n#endif\n#ifdef HAS_MAP\nvec2 l = decode_getTexcoord(aTexCoord);\n  vTexCoord = l * uvScale + uvOffset;\n#endif\n#ifdef HAS_AO_MAP\nvec2 m = decode_getTexcoord(aTexCoord1);\n  vTexCoord1 = m * uvScale + uvOffset;\n#endif\n#ifdef HAS_EXTRUSION_OPACITY\nvExtrusionOpacity = aExtrusionOpacity;\n#endif\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nvColor = vec4(aColor0 / 255., 1.);\n#else\nvColor = aColor0 / 255.;\n#endif\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(f * e);\n#endif\n#ifdef HAS_HEATMAP\nheatmap_compute(projMatrix * modelViewMatrix * f, e);\n#endif\n#ifdef HAS_I3S_UVREGION\nvUvRegion = uvRegion / 65535.;\n#endif\nhighlight_setVarying();\n}";class bn$4 extends vn$4{constructor(e={}){const t=[],r=[],o=e.uniforms,a=[{name:"modelNormalMatrix",type:"function",fn:function(e,n){return fromMat4$1(t,n.modelMatrix)}},{name:"modelViewMatrix",type:"function",fn:function(e,t){return multiply$5(r,t.viewMatrix,t.modelMatrix)}}];o&&a.push(...o),super({vert:e.vert||xn$4,frag:e.frag||gn$4,uniforms:a,defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}}),this.version=300}getGeometryDefines(e){const n={};return e.data[e.desc.tangentAttribute]?n.HAS_TANGENT=1:e.data[e.desc.normalAttribute]&&(n.HAS_NORMAL=1),n}}var An$4="#if __VERSION__ == 300\n#define attribute in\n#define varying out\n#endif\nattribute vec2 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\nvoid main() {\n  gl_Position = vec4(aPosition, 0., 1.);\n  vTexCoord = aTexCoord;\n}";const Sn$4=new Int8Array([-1,1,-1,-1,1,1,1,1,-1,-1,1,-1]),Tn$4=new Uint8Array([0,1,0,0,1,1,1,1,0,0,1,0]);class Mn$4 extends vn$4{constructor(e){e.vert=e.vert||An$4,e.extraCommandProps=e.extraCommandProps||{},e.extraCommandProps.depth||(e.extraCommandProps.depth={enable:!1,mask:!1}),e.extraCommandProps.stencil||(e.extraCommandProps.stencil={enable:!1}),super(e)}draw(e){return this._quadMesh||this._createQuadMesh(e),super.draw(e,this._quadMesh)}getMeshCommand(e){const n=this.dkey||"";return this.commands[n+"_quad"]||(this.commands[n+"_quad"]=this.createREGLCommand(e,null,this._quadMesh[0].getElements())),this.commands[n+"_quad"]}_createQuadMesh(e){const n=new Q$7({aPosition:Sn$4,aTexCoord:Tn$4},null,Sn$4.length/2,{positionSize:2,primitive:"triangles"});n.generateBuffers(e),this._quadMesh=[new Be$5(n)]}dispose(){if(this._quadMesh){const e=this._quadMesh[0];e.geometry.dispose(),e.dispose()}return delete this._quadMesh,super.dispose()}}class Cn$4 extends Mn$4{constructor(){super({vert:An$4,frag:"#define SHADER_NAME FXAA\n#define FXAA_REDUCE_MIN   (1.0/ 128.0)\n#define FXAA_REDUCE_MUL   (1.0 / 8.0)\n#define FXAA_SPAN_MAX     8.0\nprecision mediump float;\nvarying vec2 vTexCoord;\nuniform float enableFXAA;\nuniform float enableToneMapping;\nuniform float enableSharpen;\nuniform vec2 resolution;\nuniform sampler2D textureSource;\n#ifdef HAS_NOAA_TEX\nuniform sampler2D noAaTextureSource;\n#endif\n#ifdef HAS_POINT_TEX\nuniform sampler2D pointTextureSource;\n#endif\n#ifdef HAS_TAA_TEX\nuniform sampler2D taaTextureSource;\n#ifdef HAS_FXAA_TEX\nuniform sampler2D fxaaTextureSource;\n#endif\n#endif\nuniform float pixelRatio;\nuniform float sharpFactor;\n#ifdef HAS_OUTLINE_TEX\nuniform sampler2D textureOutline;\nuniform float enableOutline;\nuniform float highlightFactor;\nuniform float outlineFactor;\nuniform float outlineWidth;\nuniform vec3 outlineColor;\n#endif\nvec2 c;\nvec4 d(vec2 e) {\n  \n#ifdef HAS_TAA_TEX\nvec4 f = texture2D(textureSource, e);\n  vec4 taa = texture2D(taaTextureSource, e);\n#ifdef HAS_FXAA_TEX\nvec4 h = texture2D(fxaaTextureSource, e);\n#else\nvec4 h = vec4(.0);\n#endif\nvec4 i = taa + f * (1. - taa.a);\n  return h + i * (1. - h.a);\n#else\nreturn texture2D(textureSource, e);\n#endif\n}\nvec4 j(vec2 k) {\n  vec4 l;\n  mediump vec2 m = vec2(1. / resolution.x, 1. / resolution.y);\n  vec3 n = d((k + vec2(-1., -1.)) * m).xyz;\n  vec3 o = d((k + vec2(1., -1.)) * m).xyz;\n  vec3 u = d((k + vec2(-1., 1.)) * m).xyz;\n  vec3 v = d((k + vec2(1.)) * m).xyz;\n  vec4 A = d(k * m);\n  vec3 B = A.xyz;\n  vec3 C = vec3(.299, .587, .114);\n  float D = dot(n, C);\n  float E = dot(o, C);\n  float F = dot(u, C);\n  float G = dot(v, C);\n  float H = dot(B, C);\n  float I = min(H, min(min(D, E), min(F, G)));\n  float J = max(H, max(max(D, E), max(F, G)));\n  mediump vec2 K;\n  K.x = -((D + E) - (F + G));\n  K.y = (D + F) - (E + G);\n  float L = max((D + E + F + G) * (.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n  float M = 1. / (min(abs(K.x), abs(K.y)) + L);\n  K = min(vec2(FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), K * M)) * m;\n  vec4 N = .5 * (d(k * m + K * (1. / 3. - .5)) + d(k * m + K * (2. / 3. - .5)));\n  vec4 O = N * .5 + .25 * (d(k * m + K * -.5) + d(k * m + K * .5));\n  float P = dot(O.xyz, C);\n  if(P < I || P > J)\n    l = N;\n  else\n    l = O;\n  return l;\n}\nvec3 Q(const in vec3 l, const float R) {\n  vec2 S = pixelRatio / resolution.xy;\n  float T = .0;\n  vec4 n = texture2D(textureSource, c + S * vec2(-1., -1.));\n  n.rgb = mix(vec3(.0), n.rgb, sign(n.a));\n  T += mix(.0, 1., sign(n.a));\n  vec4 v = texture2D(textureSource, c + S * vec2(1.));\n  v.rgb = mix(vec3(.0), v.rgb, sign(v.a));\n  T += mix(.0, 1., sign(v.a));\n  vec4 o = texture2D(textureSource, c + S * vec2(1., -1.));\n  o.rgb = mix(vec3(.0), o.rgb, sign(o.a));\n  T += mix(.0, 1., sign(o.a));\n  vec4 u = texture2D(textureSource, c + S * vec2(-1., 1.));\n  u.rgb = mix(vec3(.0), u.rgb, sign(u.a));\n  T += mix(.0, 1., sign(u.a));\n  return l + R * (T * l - n.rgb - o.rgb - u.rgb - v.rgb);\n}\nvec4 U(const in vec4 l) {\n  return vec4(Q(l.rgb, sharpFactor), l.a);\n}\nvec3 V(const vec3 x) {\n  const float a = 2.51;\n  const float b = .03;\n  const float W = 2.43;\n  const float X = .59;\n  const float Y = .14;\n  return (x * (a * x + b)) / (x * (W * x + X) + Y);\n}\nvec3 Z(vec3 l) {\n  l = l / (l + vec3(1.));\n  return l = pow(l, vec3(1. / 2.2));\n}\n#ifdef HAS_OUTLINE_TEX\nvec4 ba() {\n  float bb = 2.;\n  float bc = 1.;\n  float bd = pixelRatio / resolution[0] * outlineWidth;\n  float be = pixelRatio / resolution[1] * outlineWidth;\n  vec4 bf = (texture2D(textureOutline, c + vec2(bd, be)));\n  vec4 bg = (texture2D(textureOutline, c + vec2(bd, .0)));\n  vec4 bh = (texture2D(textureOutline, c + vec2(bd, -be)));\n  vec4 bi = (texture2D(textureOutline, c + vec2(.0, -be)));\n  vec4 bj = (texture2D(textureOutline, c + vec2(-bd, -be)));\n  vec4 bk = (texture2D(textureOutline, c + vec2(-bd, .0)));\n  vec4 bl = (texture2D(textureOutline, c + vec2(-bd, be)));\n  vec4 bm = (texture2D(textureOutline, c + vec2(.0, be)));\n  vec4 bn = -bb * bk + bb * bg + -bc * bl + bc * bf + -bc * bj + bc * bh;\n  vec4 bo = -bb * bi + bb * bm + -bc * bj + bc * bl + -bc * bh + bc * bf;\n  float bp = sqrt(dot(bo, bo) + dot(bn, bn));\n  bool bq = bp < 1. / 65025.;\n  vec3 br = (texture2D(textureOutline, c)).r * outlineColor;\n  if(br == vec3(.0) || (highlightFactor == .0 && bq)) {\n    return vec4(.0);\n  }\n  float bs = bq ? highlightFactor : min(1., sqrt(bp) * outlineFactor);\n  return bs * vec4(br, 1.);\n}\nvec4 bt(const in vec4 l) {\n  vec4 ba = ba();\n  return ba + vec4(l) * (1. - ba.a);\n}\n#endif\nvoid main() {\n  c = vTexCoord;\n  vec4 l;\n  if(enableFXAA == 1.) {\n    l = j(c * resolution);\n  } else {\n    l = d(vTexCoord);\n  }\n  if(enableSharpen == 1.) {\n    l = U(l);\n  }\n#if defined(HAS_NOAA_TEX) || defined(HAS_POINT_TEX)\nvec4 bu = vec4(.0);\n  vec4 bv = vec4(.0);\n#ifdef HAS_POINT_TEX\nbu = texture2D(pointTextureSource, vTexCoord);\n#endif\n#ifdef HAS_NOAA_TEX\nbv = texture2D(noAaTextureSource, vTexCoord);\n#endif\nvec4 bw = bu + bv * (1. - bu.a);\n  l = bw + l * (1. - bw.a);\n#endif\nif(enableToneMapping == 1.) {\n    l.rgb = Z(l.rgb);\n  }\n#ifdef HAS_OUTLINE_TEX\nl = bt(l);\n#endif\ngl_FragColor = l;\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.resolution[0],height:(e,n)=>n.resolution[1]}}})}getMeshCommand(e,n){const t=this.dkey||"";return this.commands[t+"_fxaa"]||(this.commands[t+"_fxaa"]=this.createREGLCommand(e,null,n.getElements())),this.commands[t+"_fxaa"]}}class En$4 extends Mn$4{constructor(){super({vert:An$4,frag:"precision mediump float;\n#define SHADER_NAME SSAO_BLUR\nstruct MaterialParams {\n  float farPlaneOverEdgeDistance;\n  vec2 axis;\n  vec2 resolution;\n};\nuniform sampler2D materialParams_ssao;\nuniform sampler2D TextureInput;\nuniform MaterialParams materialParams;\nvarying vec2 vTexCoord;\nconst int c = 6;\nfloat d[8];\nvoid e() {\n  d[0] = .099736;\n  d[1] = .096667;\n  d[2] = .088016;\n  d[3] = .075284;\n  d[4] = .060493;\n  d[5] = .045662;\n}\nfloat f(vec2 h) {\n  return (h.x * (256. / 257.) + h.y * (1. / 257.));\n}\nvoid tap(inout float i, inout float j, float k, float h, vec2 l) {\n  vec3 m = texture2D(materialParams_ssao, l).rgb;\n  float n = k;\n  i += m.r * n;\n  j += n;\n}\nvoid main() {\n  e();\n  highp vec2 o = vTexCoord;\n  vec3 m = texture2D(materialParams_ssao, o).rgb;\n  if(m.g * m.b == 1.) {\n    if(materialParams.axis.y > .0) {\n      vec4 u = texture2D(TextureInput, o);\n      gl_FragColor = u;\n    } else {\n      gl_FragColor = vec4(m, 1.);\n    }\n    return;\n  }\n  float h = f(m.gb);\n  float j = d[0];\n  float i = m.r * j;\n  vec2 v = materialParams.axis / materialParams.resolution;\n  vec2 A = v;\n  for(int B = 1; B < c; B++) {\n    float k = d[B];\n    tap(i, j, k, h, o + A);\n    tap(i, j, k, h, o - A);\n    A += v;\n  }\n  float C = i * (1. / j);\n  vec2 gb = m.gb;\n  if(materialParams.axis.y > .0) {\n    vec4 u = texture2D(TextureInput, o);\n    gl_FragColor = vec4(u.rgb * C, u.a);\n  } else {\n    gl_FragColor = vec4(C, gb, 1.);\n  }\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.outputSize[0],height:(e,n)=>n.outputSize[1]}}})}getMeshCommand(e,n){return this.commands.ssao_blur||(this.commands.ssao_blur=this.createREGLCommand(e,null,n.getElements())),this.commands.ssao_blur}}const Pn$4=[-2e-6,0,2e-6,-.095089,.004589,-.031253,.01518,-.025586,.003765,.073426,.021802,.002778,.094587,.043218,.089148,-.009509,.051369,.019673,.139973,-.101685,.10857,-.103804,.219853,-.043016,.004841,-.033988,.094187,.028011,.058466,-.25711,-.051031,.074993,.259843,.118822,-.186537,-.134192,.063949,-.094894,-.072683,.108176,.327108,-.254058,-.04718,.21918,.263895,-.407709,.240834,-.200352];class In$4 extends Mn$4{constructor(){super({vert:An$4,frag:"#if __VERSION__ == 100\n#if defined(GL_OES_standard_derivatives)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#endif\nprecision highp float;\n#include <gl2_frag>\nvarying vec2 vTexCoord;\n#define saturate(x)        clamp(x, 0.0, 1.0)\n#define SHADER_NAME SSAO_EXTRACT\n#define PI 3.14159265359\nconst float c = .0625;\nstruct MaterialParams {\n  mat4 projMatrix;\n  mat4 invProjMatrix;\n  vec4 resolution;\n  float radius;\n  float bias;\n  float power;\n  vec2 cameraNearFar;\n};\nuniform MaterialParams materialParams;\nuniform sampler2D materialParams_depth;\n#define NOISE_NONE      0\n#define NOISE_PATTERN   1\n#define NOISE_RANDOM    2\n#define NOISE_TYPE      NOISE_PATTERN\nconst int d = 16;\nuniform vec3 kSphereSamples[16];\nvec3 e(const int x) {\n  if(x == 0) {\n    return vec3(-.078247, -.749924, -.656880);\n  } else if(x == 1) {\n    return vec3(-.572319, -.102379, -.813615);\n  } else if(x == 2) {\n    return vec3(.048653, -.380791, .923380);\n  } else if(x == 3) {\n    return vec3(.281202, -.656664, -.699799);\n  } else if(x == 4) {\n    return vec3(.711911, -.235841, -.661485);\n  } else if(x == 5) {\n    return vec3(-.445893, .611063, .654050);\n  } else if(x == 6) {\n    return vec3(-.703598, .674837, .222587);\n  } else if(x == 7) {\n    return vec3(.768236, .507457, .390257);\n  } else if(x == 8) {\n    return vec3(-.670286, -.470387, .573980);\n  } else if(x == 9) {\n    return vec3(.199235, .849336, -.488808);\n  } else if(x == 10) {\n    return vec3(-.768068, -.583633, -.263520);\n  } else if(x == 11) {\n    return vec3(-.897330, .328853, .294372);\n  } else if(x == 12) {\n    return vec3(-.570930, -.531056, -.626114);\n  } else if(x == 13) {\n    return vec3(.699014, .063283, -.712303);\n  } else if(x == 14) {\n    return vec3(.207495, .976129, -.064172);\n  } else if(x == 15) {\n    return vec3(-.060901, -.869738, -.489742);\n  } else {\n    return vec3(.0);\n  }\n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n  \n}\nvec2 f(highp float h) {\n  highp float z = clamp(h * 1. / -materialParams.cameraNearFar.y, .0, 1.);\n  highp float t = floor(256. * z);\n  mediump float i = t * (1. / 256.);\n  mediump float j = 256. * z - t;\n  return vec2(i, j);\n}\nfloat k(highp vec2 l) {\n  l = fract(l * vec2(5.3987, 5.4421));\n  l += dot(l.yx, l.xy + vec2(21.5351, 14.3137));\n  highp float xy = l.x * l.y;\n  return fract(xy * 95.4307) + fract(xy * 75.04961) * .5;\n}\nvec3 m(const vec2 o) {\n  \n#if NOISE_TYPE == NOISE_RANDOM\nreturn normalize(2. * vec3(k(o), k(o * 2.), k(o * 4.)) - vec3(1.));\n#elif NOISE_TYPE == NOISE_PATTERN\nvec2 xy = floor(gl_FragCoord.xy);\n  float u = mod(xy.x, 4.);\n  float v = mod(xy.y, 4.);\n  return e(int(u + v * 4.));\n#else\nreturn vec3(.0);\n#endif\n}\nhighp mat4 A() {\n  return materialParams.projMatrix;\n}\nhighp mat4 B() {\n  return materialParams.invProjMatrix;\n}\nhighp float C(const vec2 o) {\n  return texture2D(materialParams_depth, o).r;\n}\nhighp float D(highp float h) {\n  highp mat4 E = A();\n  highp float z = h * 2. - 1.;\n  return -E[3].z / (z + E[2].z);\n}\nhighp float F(const vec2 o) {\n  return D(texture2D(materialParams_depth, o).r);\n}\nhighp vec3 G(in vec2 p, highp float H) {\n  p = p * 2. - 1.;\n  highp mat4 I = B();\n  p.x *= I[0].x;\n  p.y *= I[1].y;\n  return vec3(p * -H, H);\n}\nhighp vec3 J(const highp vec3 K) {\n  highp vec3 L = dFdx(K);\n  highp vec3 M = dFdy(K);\n  return cross(L, M);\n}\nhighp vec3 J(const highp vec3 K, const vec2 o) {\n  vec2 N = o + vec2(materialParams.resolution.z, .0);\n  vec2 O = o + vec2(.0, materialParams.resolution.w);\n  highp vec3 px = G(N, F(N));\n  highp vec3 py = G(O, F(O));\n  highp vec3 L = px - K;\n  highp vec3 M = py - K;\n  return cross(L, M);\n}\nfloat P(const highp vec3 Q, const highp float R, mat3 S, const vec3 T, const vec3 U) {\n  highp mat4 E = A();\n  float V = materialParams.radius;\n  float W = materialParams.bias;\n  highp vec3 X = S * U;\n  float Y = dot(X, T);\n  X = sign(Y) * X;\n  X = Q + X * V;\n  highp vec4 Z = E * vec4(X, 1.);\n  Z.xy = Z.xy * (.5 / Z.w) + .5;\n  highp float ba = C(Z.xy);\n  ba = D(ba);\n  float t = saturate(V / abs(R - ba));\n  float bb = t * t * (3. - 2. * t);\n  return (ba >= X.z + W ? bb : .0);\n}\nvoid main() {\n  highp vec2 o = vTexCoord;\n  highp float h = C(o);\n  highp float bc = D(h);\n  highp vec3 Q = G(o, bc);\n  highp vec3 T = J(Q, o);\n  T = normalize(T);\n  vec3 bd = m(o);\n  vec3 be = bd.xyz;\n  vec3 bf = normalize(be - T * dot(be, T));\n  vec3 bg = cross(T, bf);\n  mat3 S = mat3(bf, bg, T);\n  float bh = .0;\n  for(int bi = 0; bi < d; bi++) {\n    bh += P(Q, bc, S, T, kSphereSamples[bi]);\n  }\n  float bj = 1. - bh / float(d);\n  bj = mix(bj, bj * bj, materialParams.power);\n  glFragColor = vec4(bj, f(Q.z), 1.);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"kSphereSamples",type:"function",fn:function(){return Pn$4}}],extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.outputSize[0],height:(e,n)=>n.outputSize[1]}}}),this.version=300}getMeshCommand(e,n){return this.commands.ssao_extract||(this.commands.ssao_extract=this.createREGLCommand(e,null,n.getElements())),this.commands.ssao_extract}}const wn$4=[];class Dn$4{constructor(e){this._renderer=e}render(e,n,t){const{width:r,height:i}=t;return this._initShaders(),this._extractFBO||this._createTextures(t),this._extract(e,r,i,t),this._blurAndCombine(n,e.cameraFar,r,i)}_blurAndCombine(e,n,t,r){const i=Math.floor(t/2),o=Math.floor(r/2);this._blurHTex.width===i&&this._blurHTex.height===o||(this._blurHFBO.resize(i,o),this._blurVFBO.resize(t,r));const a=[t,r],s=[1,0];return this._renderer.render(this._ssaoBlurShader,{TextureInput:e,materialParams_ssao:this._extractTex,materialParams:{axis:s,farPlaneOverEdgeDistance:-n/.0625,resolution:a},outputSize:[i,o]},null,this._blurHFBO),s[0]=0,s[1]=1,this._renderer.render(this._ssaoBlurShader,{TextureInput:e,materialParams_ssao:this._blurHTex,materialParams:{axis:s,farPlaneOverEdgeDistance:-n/.0625,resolution:a},outputSize:[t,r]},null,this._blurVFBO),this._blurVTex}_extract(e,t,r,i){const o=Math.floor(t/2),a=Math.floor(r/2);this._extractFBO.width===o&&this._extractFBO.height===a||this._extractFBO.resize(o,a);const{projMatrix:s}=e,c=invert$2(wn$4,s);this._renderer.render(this._ssaoExtractShader,{materialParams_depth:i,materialParams:{projMatrix:s,invProjMatrix:c,resolution:[o,a,1/o,1/a],radius:e.radius,bias:e.bias,power:e.power||1,cameraNearFar:[e.cameraNear,e.cameraFar]},outputSize:[o,a]},null,this._extractFBO)}_createTextures(e){const n=Math.floor(e.width/2),t=Math.floor(e.height/2);this._extractTex=this._createTex(n,t,"uint8"),this._extractFBO=this._createFBO(this._extractTex),this._blurHTex=this._createTex(n,t,"uint8"),this._blurHFBO=this._createFBO(this._blurHTex),this._blurVTex=this._createTex(e.width,e.height,"uint8"),this._blurVFBO=this._createFBO(this._blurVTex)}_createTex(e,n,t){return this._renderer.regl.texture({min:"linear",mag:"linear",wrap:"clamp",type:t,width:e,height:n})}_createFBO(e){return this._renderer.regl.framebuffer({width:e.width,height:e.height,colors:[e],depth:!1,stencil:!1})}dispose(){this._extractFBO&&(this._extractFBO.destroy(),delete this._extractFBO,this._blurVFBO.destroy(),this._blurHFBO.destroy(),this._ssaoExtractShader.dispose(),this._ssaoBlurShader.dispose(),delete this._ssaoExtractShader)}_initShaders(){this._ssaoExtractShader||(this._ssaoExtractShader=new In$4,this._ssaoBlurShader=new En$4)}}class Rn$4 extends Mn$4{constructor(){super({vert:An$4,frag:"precision mediump float;\nvarying vec2 vTexCoord;\nuniform vec2 resolution;\nuniform sampler2D textureSource;\nuniform float enableVignette;\nuniform float enableGrain;\nuniform float enableLut;\nuniform float timeGrain;\nuniform float grainFactor;\nuniform vec2 lensRadius;\nuniform float frameMod;\nuniform sampler2D lookupTable;\nfloat c(const in vec2 d) {\n  vec3 e = fract(vec3(d.xyx) * .1031);\n  e += dot(e, e.yzx + 19.19);\n  return fract((e.x + e.y) * e.z);\n}\nfloat f() {\n  float h = c(gl_FragCoord.xy + 1000.0 * fract(timeGrain));\n  float i = h * 2. - 1.;\n  h = i * inversesqrt(abs(i));\n  h = max(-1., h);\n  h = h - sign(i) + .5;\n  return (h + .5) * .5;\n}\nvec4 j(const in vec4 k) {\n  float l = f();\n  return vec4(mix(k.rgb, k.rgb * (k.rgb + (1. - k.rgb) * 2. * l), grainFactor), k.a);\n}\nfloat m(const in float k) {\n  return k < .0031308 ? k * 12.92 : 1.055 * pow(k, 1. / 2.4) - .055;\n}\nvec3 m(const in vec3 k) {\n  return vec3(k.r < .0031308 ? k.r * 12.92 : 1.055 * pow(k.r, 1. / 2.4) - .055, k.g < .0031308 ? k.g * 12.92 : 1.055 * pow(k.g, 1. / 2.4) - .055, k.b < .0031308 ? k.b * 12.92 : 1.055 * pow(k.b, 1. / 2.4) - .055);\n}\nvec4 m(const in vec4 k) {\n  return vec4(k.r < .0031308 ? k.r * 12.92 : 1.055 * pow(k.r, 1. / 2.4) - .055, k.g < .0031308 ? k.g * 12.92 : 1.055 * pow(k.g, 1. / 2.4) - .055, k.b < .0031308 ? k.b * 12.92 : 1.055 * pow(k.b, 1. / 2.4) - .055, k.a);\n}\nfloat n(const in float k) {\n  return k < .04045 ? k * (1. / 12.92) : pow((k + .055) * (1. / 1.055), 2.4);\n}\nvec3 n(const in vec3 k) {\n  return vec3(k.r < .04045 ? k.r * (1. / 12.92) : pow((k.r + .055) * (1. / 1.055), 2.4), k.g < .04045 ? k.g * (1. / 12.92) : pow((k.g + .055) * (1. / 1.055), 2.4), k.b < .04045 ? k.b * (1. / 12.92) : pow((k.b + .055) * (1. / 1.055), 2.4));\n}\nvec4 n(const in vec4 k) {\n  return vec4(k.r < .04045 ? k.r * (1. / 12.92) : pow((k.r + .055) * (1. / 1.055), 2.4), k.g < .04045 ? k.g * (1. / 12.92) : pow((k.g + .055) * (1. / 1.055), 2.4), k.b < .04045 ? k.b * (1. / 12.92) : pow((k.b + .055) * (1. / 1.055), 2.4), k.a);\n}\nfloat o(const in vec2 d, const in float u) {\n  vec3 v = vec3(.06711056, .00583715, 52.9829189);\n  return fract(v.z * fract(dot(d.xy + u * vec2(47., 17.) * .695, v.xy)));\n}\nfloat A() {\n  vec2 B = lensRadius;\n  B.y = min(B.y, B.x - 1e-4);\n  float C = o(gl_FragCoord.xy, frameMod);\n  C = (B.x - B.y) * (B.x + B.y) * .07 * (C - .5);\n  return smoothstep(B.x, B.y, C + distance(vTexCoord, vec2(.5)));\n}\nvec4 D(const in vec4 k) {\n  float l = A();\n  return vec4(m(n(k.rgb) * l), clamp(k.a + (1. - l), .0, 1.));\n}\nvec4 E(in vec4 F, in sampler2D G) {\n  mediump float H = F.b * 63.;\n  mediump vec2 I;\n  I.y = floor(floor(H) / 8.);\n  I.x = floor(H) - I.y * 8.;\n  mediump vec2 J;\n  J.y = floor(ceil(H) / 8.);\n  J.x = ceil(H) - J.y * 8.;\n  highp vec2 K;\n  K.x = I.x * .125 + .5 / 512. + (.125 - 1. / 512.) * F.r;\n  K.y = I.y * .125 + .5 / 512. + (.125 - 1. / 512.) * F.g;\n#ifdef LUT_FLIP_Y\nK.y = 1. - K.y;\n#endif\nhighp vec2 L;\n  L.x = J.x * .125 + .5 / 512. + (.125 - 1. / 512.) * F.r;\n  L.y = J.y * .125 + .5 / 512. + (.125 - 1. / 512.) * F.g;\n#ifdef LUT_FLIP_Y\nL.y = 1. - L.y;\n#endif\nlowp vec4 M = texture2D(G, K);\n  lowp vec4 N = texture2D(G, L);\n  lowp vec4 O = mix(M, N, fract(H));\n  return O;\n}\nvoid main() {\n  vec4 k = texture2D(textureSource, vTexCoord);\n  if(enableLut == 1.) {\n    k = E(k, lookupTable);\n  }\n  if(enableVignette == 1.) {\n    k = D(k);\n  }\n  if(enableGrain == 1.) {\n    k = j(k);\n  }\n  gl_FragColor = k;\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.resolution[0],height:(e,n)=>n.resolution[1]}}})}getMeshCommand(e,n){return this.commands.postprocess||(this.commands.postprocess=this.createREGLCommand(e,null,n.getElements())),this.commands.postprocess}}class Nn$4 extends Mn$4{constructor(){super({vert:An$4,frag:"#define SHADER_NAME TAA\nprecision mediump float;\n#define saturate(x)        clamp(x, 0.0, 1.0)\n#if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT)\n#define TEXTURE_SPACE_UP    -1\n#define TEXTURE_SPACE_DN     1\n#else\n#define TEXTURE_SPACE_UP     1\n#define TEXTURE_SPACE_DN    -1\n#endif\n#define BOX_TYPE_AABB           0\n#define BOX_TYPE_VARIANCE       1\n#define BOX_TYPE_AABB_VARIANCE  2\n#define VARIANCE_GAMMA          1.0\n#define BOX_CLIPPING_ACCURATE   0\n#define BOX_CLIPPING_CLAMP      1\n#define BOX_CLIPPING_NONE       2\n#if defined(TARGET_MOBILE)\n#define BOX_CLIPPING            BOX_CLIPPING_ACCURATE\n#define BOX_TYPE                BOX_TYPE_VARIANCE\n#define USE_YCoCg               0\n#define FILTER_INPUT            1\n#define FILTER_HISTORY          0\n#else\n#define BOX_CLIPPING            BOX_CLIPPING_ACCURATE\n#define BOX_TYPE                BOX_TYPE_AABB_VARIANCE\n#define USE_YCoCg               0\n#define FILTER_INPUT            0\n#define FILTER_HISTORY          0\n#endif\n#define HISTORY_REPROJECTION    1\n#define PREVENT_FLICKERING      0\nstruct MaterialParams {\n  float alpha;\n  mat4 reprojection;\n};\nuniform sampler2D materialParams_color;\nuniform sampler2D materialParams_history;\nuniform vec2 materialParams_history_size;\nuniform vec2 textureOutputSize;\nuniform sampler2D materialParams_depth;\nuniform MaterialParams materialParams;\nfloat c(const vec3 d) {\n  return dot(d, vec3(.2126, .7152, .0722));\n}\nfloat e(const vec3 f) {\n  \n#if USE_YCoCg\nreturn f.x;\n#else\nreturn c(f);\n#endif\n}\nvec3 h(const vec3 i) {\n  float j = dot(i.rgb, vec3(1, 2, 1) * .25);\n  float k = dot(i.rgb, vec3(2, 0, -2) * .25);\n  float l = dot(i.rgb, vec3(-1, 2, -1) * .25);\n  return vec3(j, k, l);\n}\nvec3 m(const vec3 i) {\n  float j = i.x;\n  float k = i.y;\n  float l = i.z;\n  float r = j + k - l;\n  float g = j + l;\n  float b = j - k - l;\n  return vec3(r, g, b);\n}\nvec4 n(const int o, const vec3 u, const vec3 v, const vec4 i, const vec4 A) {\n  const float B = .0001;\n  if(o == BOX_CLIPPING_ACCURATE) {\n    vec4 r = i - A;\n    vec3 C = 1. / (B + r.rgb);\n    vec3 D = (v - A.rgb) * C;\n    vec3 E = (u - A.rgb) * C;\n    vec3 F = min(D, E);\n    return A + r * saturate(max(max(F.x, F.y), F.z));\n  } else if(o == BOX_CLIPPING_CLAMP) {\n    return vec4(clamp(A.rgb, u, v), A.a);\n  }\n  return A;\n}\nvec4 G(const sampler2D H, const highp vec2 I, const highp vec2 J) {\n  highp vec2 K = I * J;\n  highp vec2 L = floor(K - .5) + .5;\n  highp vec2 M = K - L;\n  highp vec2 N = M * M;\n  highp vec2 O = N * M;\n  vec2 P = N - .5 * (O + M);\n  vec2 Q = 1.5 * O - 2.5 * N + 1.;\n  vec2 R = .5 * (O - N);\n  vec2 S = 1. - P - Q - R;\n  vec2 T = Q + S;\n  highp vec2 U = L - vec2(1.);\n  highp vec2 V = L + vec2(2.);\n  highp vec2 W = L + S / T;\n  highp vec2 X = 1. / J;\n  U *= X;\n  V *= X;\n  W *= X;\n  float Z = T.x * P.y;\n  float ba = P.x * T.y;\n  float bb = T.x * T.y;\n  float bc = R.x * T.y;\n  float bd = T.x * R.y;\n  vec4 be = texture2D(H, vec2(W.x, U.y)) * Z + texture2D(H, vec2(U.x, W.y)) * ba + texture2D(H, vec2(W.x, W.y)) * bb + texture2D(H, vec2(V.x, W.y)) * bc + texture2D(H, vec2(W.x, V.y)) * bd;\n  be *= 1. / (Z + ba + bb + bc + bd);\n  return be;\n}\nvec4 bf(sampler2D H, vec2 I, float bg, ivec2 bh) {\n  return texture2D(H, I + vec2(bh));\n}\nvoid main() {\n  highp vec4 I = (gl_FragCoord.xy / textureOutputSize.xy).xyxy;\n  float bi = texture2D(materialParams_depth, I.xy).r;\n#if HISTORY_REPROJECTION\n#if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT)\nI.w = 1. - I.w;\n#endif\nhighp vec4 q = materialParams.reprojection * vec4(I.zw, bi, 1.);\n  I.zw = (q.xy * (1. / q.w)) * .5 + .5;\n#if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT)\nI.w = 1. - I.w;\n#endif\n#endif\nvec4 f = bf(materialParams_color, I.xy, .0, ivec2(0));\n#if FILTER_HISTORY\nvec4 bj = G(materialParams_history, I.zw, materialParams_history_size);\n#else\nvec4 bj = texture2D(materialParams_history, I.zw);\n#endif\n#if USE_YCoCg\nbj.rgb = h(bj.rgb);\n#endif\nvec3 s[9];\n  s[0] = bf(materialParams_color, I.xy, .0, ivec2(-1, TEXTURE_SPACE_DN)).rgb;\n  s[1] = bf(materialParams_color, I.xy, .0, ivec2(0, TEXTURE_SPACE_DN)).rgb;\n  s[2] = bf(materialParams_color, I.xy, .0, ivec2(1, TEXTURE_SPACE_DN)).rgb;\n  s[3] = bf(materialParams_color, I.xy, .0, ivec2(-1, 0)).rgb;\n  s[4] = f.rgb;\n  s[5] = bf(materialParams_color, I.xy, .0, ivec2(1, 0)).rgb;\n  s[6] = bf(materialParams_color, I.xy, .0, ivec2(-1, TEXTURE_SPACE_UP)).rgb;\n  s[7] = bf(materialParams_color, I.xy, .0, ivec2(0, TEXTURE_SPACE_UP)).rgb;\n  s[8] = bf(materialParams_color, I.xy, .0, ivec2(1, TEXTURE_SPACE_UP)).rgb;\n#if USE_YCoCg\nfor(int bk = 0; bk < 9; bk++) {\n    s[bk] = h(s[bk]);\n  }\n  f.rgb = s[4].rgb;\n#endif\n#if FILTER_INPUT\n#else\nvec4 bl = f;\n#endif\n#if BOX_TYPE == BOX_TYPE_AABB || BOX_TYPE == BOX_TYPE_AABB_VARIANCE\nvec3 u = min(s[4], min(min(s[1], s[3]), min(s[5], s[7])));\n  vec3 v = max(s[4], max(max(s[1], s[3]), max(s[5], s[7])));\n  vec3 bm = min(u, min(min(s[0], s[2]), min(s[6], s[8])));\n  vec3 bn = max(v, max(max(s[0], s[2]), max(s[6], s[8])));\n  u = (u + bm) * .5;\n  v = (v + bn) * .5;\n#endif\n#if BOX_TYPE == BOX_TYPE_VARIANCE || BOX_TYPE == BOX_TYPE_AABB_VARIANCE\nvec3 bo = s[4];\n  vec3 bp = s[4] * s[4];\n  for(int bk = 1; bk < 9; bk += 2) {\n    bo += s[bk];\n    bp += s[bk] * s[bk];\n  }\n  vec3 bq = bo * (1. / 5.);\n  vec3 br = bp * (1. / 5.);\n  vec3 bs = sqrt(br - bq * bq);\n#if BOX_TYPE == BOX_TYPE_VARIANCE\nvec3 u = bq - VARIANCE_GAMMA * bs;\n  vec3 v = bq + VARIANCE_GAMMA * bs;\n#else\nu = min(u, bq - VARIANCE_GAMMA * bs);\n  v = max(v, bq + VARIANCE_GAMMA * bs);\n#endif\n#endif\nfloat bt = e(bl.rgb);\n  float bu = e(bj.rgb);\n  float bv = materialParams.alpha;\n#if PREVENT_FLICKERING\nfloat bw = 1. - abs(bt - bu) / (.001 + max(bt, bu));\n  bv *= bw * bw;\n#endif\nbl.rgb *= 1. / (1. + bt);\n  bj.rgb *= 1. / (1. + bu);\n  vec4 be = mix(bj, bl, bv);\n  be.rgb *= 1. / (1. - e(be.rgb));\n#if USE_YCoCg\nbe.rgb = m(be.rgb);\n#endif\nbe = max(vec4(0), be);\n  gl_FragColor = be;\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.materialParams_color.width,height:(e,n)=>n.materialParams_color.height},blend:{enable:!1}}})}getMeshCommand(e,n){return this.commands.taa||(this.commands.taa=this.createREGLCommand(e,null,n.getElements())),this.commands.taa}}const Fn$4=[2,0,0,0,0,2,0,0,0,0,-2,0,-1,-1,1,1];class Hn$4{constructor(e,n){this._jitter=n,this._renderer=e,this._halton=[],this._counter=0}needToRedraw(){return this._counter<this._jitter.getSampleCount()}render(e,t,r,i){const a=this._jitter;this._initShaders(),this._createTextures(e),i&&(this._counter=0),this._counter++;const s=a.getSampleCount();if(this._counter>=s)return this._prevTex;this._fbo.width===e.width&&this._fbo.height===e.height||this._fbo.resize(e.width,e.height);const c=this._outputTex,l=this._prevTex,f=this._uniforms||{materialParams_history_size:[l.width,l.height],textureOutputSize:[],materialParams:{alpha:1,reprojection:[],filterWeights:[]}};f.materialParams.alpha=1/this._counter;const d=f.materialParams.reprojection;multiply$5(d,this._prevProjMatrix||r,invert$2(d,r)),multiply$5(d,d,Fn$4),set(f.materialParams_history_size,l.width,l.height),set(f.textureOutputSize,e.width,e.height),f.materialParams_depth=t,f.materialParams_color=e,f.materialParams_history=l,this._renderer.render(this._shader,f,null,this._fbo);const u=this._outputTex,h=this._fbo;return this._outputTex=this._prevTex,this._fbo=this._prevFbo,this._prevTex=u,this._prevFbo=h,this._prevProjMatrix=copy$5(this._prevProjMatrix||[],r),c}dispose(){this._shader&&(this._shader.dispose(),delete this._shader),this._fbo&&this._fbo.destroy(),this._prevFbo&&this._prevFbo.destroy(),delete this._uniforms}_createTextures(e){if(this._outputTex)return;const n=this._renderer.regl;this._outputTex=this._createColorTex(e),this._fbo=n.framebuffer({width:e.width,height:e.height,colors:[this._outputTex],depth:!1,stencil:!1}),this._prevTex=this._createColorTex(e),this._prevFbo=n.framebuffer({width:e.width,height:e.height,colors:[this._prevTex],depth:!1,stencil:!1})}_createColorTex(e){return this._renderer.regl.texture({min:"linear",mag:"linear",type:"uint8",width:e.width,height:e.height})}_initShaders(){this._shader||(this._shader=new Nn$4)}}const Ln$4=[[.263385,-.0252475],[-.38545,.054485],[-.139795,-.5379925],[-.2793775,.6875475],[.7139025,.4710925],[.90044,-.16422],[.4481775,-.82799],[-.9253375,-.2910625],[.3468025,1.02292],[-1.13742,.33522],[-.7676225,-.9123175],[-.2005775,-1.1774125],[-.926525,.96876],[1.12909,-.7500325],[.9603,1.14625]],zn$4=Ln$4.length,kn$4=[0,0];for(let e=0;e<Ln$4.length;e++)kn$4[0]+=Ln$4[e][0],kn$4[1]+=Ln$4[e][1];kn$4[0]/=zn$4,kn$4[1]/=zn$4;class Bn$4{constructor(e){this._frameNum=0,this._ratio=e||.05,this._avg=[kn$4[0]*this._ratio,kn$4[1]*this._ratio]}getRatio(){return this._ratio}setRatio(e){this._ratio!==e&&(this._ratio=e,this.reset()),this._avg=[kn$4[0]*this._ratio,kn$4[1]*this._ratio]}getAverage(){return this._avg}reset(){this._frameNum=0}getJitter(e){const n=this._frameNum%zn$4,t=this._ratio;return set(e,Ln$4[n][0]*t,Ln$4[n][1]*t),e}frame(){this._frameNum++,this._frameNum%zn$4==0&&(this._frameNum=0)}getSampleCount(){return zn$4}}class Gn$4{constructor(e,n,t=5){this._regl=e,this._renderer=new B$6(e),this._inputRGBM=n,this._level=t}render(e,n){this._initShaders(),this._createTextures(e),this._blur(e,n||0);const t={blurTex0:this._blur01Tex,blurTex1:this._blur11Tex,blurTex2:this._blur21Tex,blurTex3:this._blur31Tex,blurTex4:this._blur41Tex};return this._level>5&&(t.blurTex5=this._blur51Tex,t.blurTex6=this._blur61Tex),t}_blur(e,n){let t=this._blurUniforms;t||(t=this._blurUniforms={rgbmRange:7,blurDir:[0,0],outSize:[0,0],pixelRatio:[1,1],outputSize:[0,0]}),set(t.outSize,e.width,e.height),this._blurOnce(this._blur0Shader,e,this._blur00FBO,this._blur01FBO,.5,n),this._blurOnce(this._blur1Shader,this._blur01FBO.color[0],this._blur10FBO,this._blur11FBO,.5),this._blurOnce(this._blur2Shader,this._blur11FBO.color[0],this._blur20FBO,this._blur21FBO,.5),this._blurOnce(this._blur3Shader,this._blur21FBO.color[0],this._blur30FBO,this._blur31FBO,.5),this._blurOnce(this._blur4Shader,this._blur31FBO.color[0],this._blur40FBO,this._blur41FBO,.5),this._level>5&&(this._blurOnce(this._blur5Shader,this._blur41FBO.color[0],this._blur50FBO,this._blur51FBO,.5),this._blurOnce(this._blur6Shader,this._blur51FBO.color[0],this._blur60FBO,this._blur51FBO,.5))}_blurOnce(e,n,t,r,i,a){const s=Math.ceil(i*n.width),c=Math.ceil(i*n.height);t.width===s&&t.height===c||t.resize(s,c),r.width===s&&r.height===c||r.resize(s,c);const l=this._blurUniforms;l.luminThreshold=a,l.TextureBlurInput=n,l.inputRGBM=+this._inputRGBM,set(l.blurDir,0,1),set(l.outputSize,t.width,t.height),this._renderer.render(e,l,null,t),l.luminThreshold=0,l.inputRGBM=1,set(l.blurDir,1,0),l.TextureBlurInput=t.color[0],this._renderer.render(e,l,null,r)}dispose(){this._blur0Shader&&(this._blur0Shader.dispose(),delete this._blur0Shader,this._blur1Shader.dispose(),this._blur2Shader.dispose(),this._blur3Shader.dispose(),this._blur4Shader.dispose(),this._blur5Shader&&(this._blur5Shader.dispose(),this._blur6Shader.dispose(),delete this._blur5Shader)),this._blur00Tex&&(delete this._blur00Tex,this._blur00FBO.destroy(),this._blur01FBO.destroy(),this._blur10FBO.destroy(),this._blur11FBO.destroy(),this._blur20FBO.destroy(),this._blur21FBO.destroy(),this._blur30FBO.destroy(),this._blur31FBO.destroy(),this._blur40FBO.destroy(),this._blur41FBO.destroy(),this._blur50FBO&&(this._blur50FBO.destroy(),this._blur51FBO.destroy(),this._blur60FBO.destroy(),this._blur61FBO.destroy()))}_createTextures(e){if(this._blur00Tex)return;let n=e.width,t=e.height;this._blur00Tex=this._createColorTex(e,n,t),this._blur00FBO=this._createBlurFBO(this._blur00Tex),this._blur01Tex=this._createColorTex(e),this._blur01FBO=this._createBlurFBO(this._blur01Tex),n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur10Tex=this._createColorTex(e,n,t),this._blur10FBO=this._createBlurFBO(this._blur10Tex),this._blur11Tex=this._createColorTex(e,n,t),this._blur11FBO=this._createBlurFBO(this._blur11Tex),n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur20Tex=this._createColorTex(e,n,t),this._blur20FBO=this._createBlurFBO(this._blur20Tex),this._blur21Tex=this._createColorTex(e,n,t),this._blur21FBO=this._createBlurFBO(this._blur21Tex),n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur30Tex=this._createColorTex(e,n,t),this._blur30FBO=this._createBlurFBO(this._blur30Tex),this._blur31Tex=this._createColorTex(e,n,t),this._blur31FBO=this._createBlurFBO(this._blur31Tex),n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur40Tex=this._createColorTex(e,n,t),this._blur40FBO=this._createBlurFBO(this._blur40Tex),this._blur41Tex=this._createColorTex(e,n,t),this._blur41FBO=this._createBlurFBO(this._blur41Tex),this._level>5&&(n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur50Tex=this._createColorTex(e,n,t),this._blur50FBO=this._createBlurFBO(this._blur50Tex),this._blur51Tex=this._createColorTex(e,n,t),this._blur51FBO=this._createBlurFBO(this._blur51Tex),n=Math.ceil(n/2),t=Math.ceil(t/2),this._blur60Tex=this._createColorTex(e,n,t),this._blur60FBO=this._createBlurFBO(this._blur60Tex),this._blur61Tex=this._createColorTex(e,n,t),this._blur61FBO=this._createBlurFBO(this._blur61Tex))}_createColorTex(e,n,t){return this._regl.texture({min:"linear",mag:"linear",type:"uint8",width:n||e.width,height:t||e.height})}_createBlurFBO(e){return this._regl.framebuffer({width:e.width,height:e.height,colors:[e],depth:!1,stencil:!1})}_initShaders(){if(!this._blur0Shader){const e={vert:An$4,extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.outputSize[0],height:(e,n)=>n.outputSize[1]}},frag:"#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\nuniform float inputRGBM;\nuniform float luminThreshold;\n#define SHADER_NAME GAUSSIAN_BLUR0\nconst vec3 c = vec3(.2126, .7152, .0722);\nfloat d(const in vec3 e) {\n  return dot(e, c);\n}\nvec4 f(vec4 e) {\n  float h = max(sign(d(e.rgb) - luminThreshold), .0);\n  return e * h;\n}\nvec2 i;\nvec4 j(const in vec3 e, const in float k) {\n  vec4 l;\n  vec3 m = e / k;\n  l.a = clamp(max(max(m.r, m.g), max(m.b, 1e-6)), .0, 1.);\n  l.a = ceil(l.a * 255.) / 255.;\n  l.rgb = m / l.a;\n  return l;\n}\nvec3 n(const in vec4 e, const in float k) {\n  if(inputRGBM == .0)\n    return e.rgb;\n  return k * e.rgb * e.a;\n}\nvec4 o() {\n  vec3 u = .375 * (f(vec4(n(texture2D(TextureBlurInput, i.xy), rgbmRange), 1.))).rgb;\n  vec2 v;\n  vec2 A = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  v = A * 1.2;\n  u += .3125 * (f(vec4(n(texture2D(TextureBlurInput, i.xy + v.xy), rgbmRange), 1.))).rgb;\n  u += .3125 * (f(vec4(n(texture2D(TextureBlurInput, i.xy - v.xy), rgbmRange), 1.))).rgb;\n  return vec4(u, 1.);\n}\nvoid main(void) {\n  i = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = o();\n  e = j(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}"};this._blur0Shader=new Mn$4(e),e.frag="#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR1\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .3125 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  m = n * 1.2857142857142858;\n  l += .328125 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .328125 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur1Shader=new Mn$4(e),e.frag="#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR2\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .2734375 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  m = n * 1.3333333333333333;\n  l += .328125 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .328125 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 3.111111111111111;\n  l += .03515625 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .03515625 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur2Shader=new Mn$4(e),e.frag="#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR3\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .24609375 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  m = n * 1.3636363636363635;\n  l += .322265625 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .322265625 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 3.1818181818181817;\n  l += .0537109375 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .0537109375 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur3Shader=new Mn$4(e),e.frag="#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR4\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .2255859375 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  m = n * 1.3846153846153846;\n  l += .314208984375 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .314208984375 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 3.230769230769231;\n  l += .06982421875 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .06982421875 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 5.076923076923077;\n  l += .003173828125 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .003173828125 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur4Shader=new Mn$4(e),this._level>5&&(e.frag="precision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 outSize;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR5\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .20947265625 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  n *= outSize.y * .00075;\n  m = n * 1.4;\n  l += .30548095703125 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .30548095703125 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 3.2666666666666666;\n  l += .08331298828125 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .08331298828125 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 5.133333333333334;\n  l += .00640869140625 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .00640869140625 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur5Shader=new Mn$4(e),e.frag="#version 100\nprecision highp float;\nuniform float rgbmRange;\nuniform sampler2D TextureBlurInput;\nuniform sampler2D TextureInput;\nuniform vec2 blurDir;\nuniform vec2 outSize;\nuniform vec2 pixelRatio;\nuniform vec2 outputSize;\n#define SHADER_NAME GAUSSIAN_BLUR6\nvec2 c;\nvec4 d(const in vec3 e, const in float f) {\n  if(f <= .0)\n    return vec4(e, 1.);\n  vec4 h;\n  vec3 i = e / f;\n  h.a = clamp(max(max(i.r, i.g), max(i.b, 1e-6)), .0, 1.);\n  h.a = ceil(h.a * 255.) / 255.;\n  h.rgb = i / h.a;\n  return h;\n}\nvec3 j(const in vec4 e, const in float f) {\n  if(f <= .0)\n    return e.rgb;\n  return f * e.rgb * e.a;\n}\nvec4 k() {\n  vec3 l = .196380615234375 * (vec4(j(texture2D(TextureBlurInput, c.xy), rgbmRange), 1.)).rgb;\n  vec2 m;\n  vec2 n = pixelRatio.xy * blurDir.xy / outputSize.xy;\n  n *= outSize.y * .00075;\n  m = n * 1.411764705882353;\n  l += .2967529296875 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .2967529296875 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 3.2941176470588234;\n  l += .09442138671875 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .09442138671875 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  m = n * 5.176470588235294;\n  l += .0103759765625 * (vec4(j(texture2D(TextureBlurInput, c.xy + m.xy), rgbmRange), 1.)).rgb;\n  l += .0103759765625 * (vec4(j(texture2D(TextureBlurInput, c.xy - m.xy), rgbmRange), 1.)).rgb;\n  return vec4(l, 1.);\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = k();\n  e = d(e.rgb, rgbmRange);\n  gl_FragColor = e;\n}",this._blur6Shader=new Mn$4(e))}}}class Un$4{constructor(e){this._regl=e,this._renderer=new B$6(e)}render(e,n,t,r,i,o,a,s,c){this._initShaders(),this._createTextures(e);const l=this._blurPass.render(n,t);return this._combine(e,l,n,r,i,o,a,s,c)}_combine(e,n,t,r,i,a,s,c,l){l||this._combineTex.width===e.width&&this._combineTex.height===e.height||this._combineFBO.resize(e.width,e.height);let f=this._combineUniforms;const{blurTex0:d,blurTex1:u,blurTex2:h,blurTex3:m,blurTex4:v}=n;f||(f=this._combineUniforms={bloomFactor:0,bloomRadius:0,rgbmRange:7,TextureBloomBlur1:d,TextureBloomBlur2:u,TextureBloomBlur3:h,TextureBloomBlur4:m,TextureBloomBlur5:v,TextureInput:null,TextureSource:null,outputSize:[0,0]}),f.noAaTextureSource=a,f.pointTextureSource=s,f.enableAA=c,f.bloomFactor=r,f.bloomRadius=i,f.TextureInput=t,f.TextureSource=e,set(f.outputSize,e.width,e.height);const _={};return a?_.HAS_NOAA_TEX=1:delete _.HAS_NOAA_TEX,s?_.HAS_POINT_TEX=1:delete _.HAS_POINT_TEX,this._combineShader.setDefines(_),this._renderer.render(this._combineShader,f,null,l?null:this._combineFBO),l?null:this._combineTex}dispose(){this._combineFBO&&(this._combineFBO.destroy(),delete this._combineFBO),this._blurPass&&(this._blurPass.dispose(),delete this._blurPass),delete this._uniforms}_createTextures(e){this._combineTex||(this._combineTex=this._createColorTex(e,e.width,e.height,"uint8"),this._combineFBO=this._createBlurFBO(this._combineTex))}_createColorTex(e,n,t,r){return this._renderer.regl.texture({min:"linear",mag:"linear",type:r,width:n||e.width,height:t||e.height})}_createBlurFBO(e){return this._renderer.regl.framebuffer({width:e.width,height:e.height,colors:[e],depth:!1,stencil:!1})}_initShaders(){if(!this._combineShader){const e={x:0,y:0,width:(e,n)=>n.outputSize[0],height:(e,n)=>n.outputSize[1]};this._blurPass=new Gn$4(this._regl,!1),this._combineShader=new Mn$4({vert:An$4,frag:"#define FXAA_REDUCE_MIN   (1.0/ 128.0)\n#define FXAA_REDUCE_MUL   (1.0 / 8.0)\n#define FXAA_SPAN_MAX     8.0\nprecision highp float;\nuniform float bloomFactor;\nuniform float bloomRadius;\nuniform float rgbmRange;\nuniform sampler2D TextureBloomBlur1;\nuniform sampler2D TextureBloomBlur2;\nuniform sampler2D TextureBloomBlur3;\nuniform sampler2D TextureBloomBlur4;\nuniform sampler2D TextureBloomBlur5;\nuniform sampler2D TextureInput;\nuniform sampler2D TextureSource;\n#ifdef HAS_NOAA_TEX\nuniform sampler2D noAaTextureSource;\n#endif\n#ifdef HAS_POINT_TEX\nuniform sampler2D pointTextureSource;\n#endif\nuniform float enableAA;\nuniform vec2 outputSize;\n#define SHADER_NAME bloomCombine\nvec2 c;\nvec3 d(const in vec3 e) {\n  return vec3(e.r < .0031308 ? e.r * 12.92 : 1.055 * pow(e.r, 1. / 2.4) - .055, e.g < .0031308 ? e.g * 12.92 : 1.055 * pow(e.g, 1. / 2.4) - .055, e.b < .0031308 ? e.b * 12.92 : 1.055 * pow(e.b, 1. / 2.4) - .055);\n}\nvec3 f(const in vec4 e, const in float h) {\n  if(h <= .0)\n    return e.rgb;\n  return h * e.rgb * e.a;\n}\nfloat i(const float j, const float k) {\n  return mix(j, k * 2. - j, bloomRadius);\n}\nvec4 l(sampler2D m, vec2 n) {\n  vec4 e;\n  mediump vec2 o = vec2(1. / outputSize.x, 1. / outputSize.y);\n  vec3 u = texture2D(m, (n + vec2(-1., -1.)) * o).xyz;\n  vec3 v = texture2D(m, (n + vec2(1., -1.)) * o).xyz;\n  vec3 A = texture2D(m, (n + vec2(-1., 1.)) * o).xyz;\n  vec3 B = texture2D(m, (n + vec2(1.)) * o).xyz;\n  vec4 C = texture2D(m, n * o);\n  vec3 D = C.xyz;\n  vec3 E = vec3(.299, .587, .114);\n  float F = dot(u, E);\n  float G = dot(v, E);\n  float H = dot(A, E);\n  float I = dot(B, E);\n  float J = dot(D, E);\n  float K = min(J, min(min(F, G), min(H, I)));\n  float L = max(J, max(max(F, G), max(H, I)));\n  mediump vec2 M;\n  M.x = -((F + G) - (H + I));\n  M.y = (F + H) - (G + I);\n  float N = max((F + G + H + I) * (.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);\n  float O = 1. / (min(abs(M.x), abs(M.y)) + N);\n  M = min(vec2(FXAA_SPAN_MAX), max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), M * O)) * o;\n  vec4 P = .5 * (texture2D(m, n * o + M * (1. / 3. - .5)) + texture2D(m, n * o + M * (2. / 3. - .5)));\n  vec4 Q = P * .5 + .25 * (texture2D(m, n * o + M * -.5) + texture2D(m, n * o + M * .5));\n  float R = dot(Q.xyz, E);\n  if(R < K || R > L)\n    e = P;\n  else\n    e = Q;\n  return e;\n}\nvec4 S() {\n  vec3 T = vec3(.0);\n  const float U = .6;\n  const float V = 1.1;\n  const float W = .9;\n  const float X = .6;\n  const float Y = .3;\n  const float Z = .1;\n  T += (vec4(f(texture2D(TextureBloomBlur1, c), rgbmRange), 1.)).rgb * i(V, U);\n  T += (vec4(f(texture2D(TextureBloomBlur2, c), rgbmRange), 1.)).rgb * i(W, U);\n  T += (vec4(f(texture2D(TextureBloomBlur3, c), rgbmRange), 1.)).rgb * i(X, U);\n  T += (vec4(f(texture2D(TextureBloomBlur4, c), rgbmRange), 1.)).rgb * i(Y, U);\n  T += (vec4(f(texture2D(TextureBloomBlur5, c), rgbmRange), 1.)).rgb * i(Z, U);\n  vec4 ba;\n  if(enableAA == 1.) {\n    ba = l(TextureInput, gl_FragCoord.xy);\n  } else {\n    ba = texture2D(TextureInput, c);\n  }\n  ba.rgb = mix(vec3(.0), ba.rgb, sign(ba.a));\n  vec4 bb = texture2D(TextureSource, c);\n#ifdef HAS_NOAA_TEX\nvec4 bc = texture2D(noAaTextureSource, c);\n  bb = bc + bb * (1. - bc.a);\n#endif\nvec4 bd = vec4(.0);\n#ifdef HAS_POINT_TEX\nbd = texture2D(pointTextureSource, c);\n#endif\nfloat be = sqrt((T.r + T.g + T.b) / 3.);\n  vec4 bf = vec4(d(T * bloomFactor), be);\n  return bd + (ba + bb * (1. - ba.a)) * (1. - bd.a) + bf;\n}\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 e = S();\n  gl_FragColor = e;\n}",extraCommandProps:{viewport:e}})}}}class Vn$4 extends Mn$4{constructor(){const e=[];super({vert:An$4,frag:"precision highp float;\n#include <gl2_frag>\n#define SHADER_NAME COPY_DEPTH\nuniform sampler2D TextureDepth;\nuniform vec2 textureSize;\n#include <common_pack_float>\nvoid main(void) {\n  vec2 c = gl_FragCoord.xy / textureSize.xy;\n  float d = texture2D(TextureDepth, c).r;\n  glFragColor = common_encodeDepth(d);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"textureSize",type:"function",fn:(n,t)=>(e[0]=t.TextureDepth.width,e[1]=t.TextureDepth.height,e)}],extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.TextureDepth.width,height:(e,n)=>n.TextureDepth.height}}}),this.version=300}getMeshCommand(e,n){return this.commands.copy_depth||(this.commands.copy_depth=this.createREGLCommand(e,null,n.getElements())),this.commands.copy_depth}}class jn$4{static getUniformDeclares(){const e=[[0,0,0,0],[0,0,0,0]],t=new Array(16);return[{name:"invProjMatrix",type:"function",fn:(e,r)=>invert$2(t,r.projMatrix)},{name:"outputFovInfo",type:"array",length:2,fn:function(n,t){const i=Math.tan(.5*t.fov),o=t.outSize[0]/t.outSize[1]*i;return set$3(e[0],o,i,o,-i),set$3(e[1],-o,i,-o,-i),e}},{name:"reprojViewProjMatrix",type:"function",fn:(e,t)=>multiply$5([],t.prevProjViewMatrix,t.cameraWorldMatrix)}]}static getDefines(){return{HAS_SSR:1}}constructor(e){this._regl=e,this._renderer=new B$6(e),this._inputRGBM=0}setup(e){this._initShaders(),this._createTextures(e)}getSSRUniforms(e,n,t){if(!this._depthCopy)return null;const r=this._depthCopy;return{TextureDepth:r,TextureReflected:this.getMipmapTexture(),ssrFactor:n||1,ssrQuality:t||2,outSize:[r.width,r.height],fov:e.getFov()*Math.PI/180,prevProjViewMatrix:this._projViewMatrix||e.projViewMatrix,cameraWorldMatrix:e.cameraWorldMatrix}}genMipMap(e,t,r){return this.setup(e),this._mipmap(e),this.copyDepthTex(t),this._projViewMatrix||(this._projViewMatrix=[]),copy$5(this._projViewMatrix,r),delete this._depthCopied,this._outputTex}getPrevProjViewMatrix(){return this._projViewMatrix}copyDepthTex(e){return this._depthCopied?null:(this.setup(e),this._depthCopy?e.width===this._depthCopy.width&&e.height===this._depthCopy.height||this._depthCopyFBO.resize(e.width,e.height):(this._depthCopy=this._regl.texture({min:"nearest",mag:"nearest",mipmap:!1,type:"uint8",width:e.width,height:e.height}),this._depthCopyFBO=this._regl.framebuffer({width:e.width,height:e.height,colors:[this._depthCopy],colorFormat:"rgba"})),this._renderer.render(this._copyDepthShader,{TextureDepth:e},null,this._depthCopyFBO),this._depthCopied=!0,this._depthCopy)}_mipmap(e){const n=this._targetFBO,t=Math.ceil(.5*e.width),r=Math.ceil(.5*e.height);n.width===t&&n.height===r||n.resize(t,r);let i=this._blurUniforms;i||(i=this._blurUniforms={rgbmRange:7,outputSize:[0,0]}),i.TextureInput=e,i.inputRGBM=+this._inputRGBM,set(i.outputSize,n.width,n.height),this._renderer.render(this._ssrQuadShader,i,null,n)}getMipmapTexture(){return this._outputTex||(this._outputTex=this._renderer.regl.texture({type:"uint8",width:2,height:2})),this._outputTex}dispose(){this._copyDepthShader&&(this._ssrQuadShader.dispose(),this._copyDepthShader.dispose(),this._targetFBO.destroy(),delete this._copyDepthShader),this._depthCopy&&(this._depthCopyFBO.destroy(),delete this._depthCopy,delete this._depthCopyFBO)}_initShaders(){this._copyDepthShader||(this._copyDepthShader=new Vn$4,this._ssrQuadShader=new Mn$4({vert:An$4,frag:"#version 100\nprecision mediump float;\nuniform sampler2D TextureInput;\nuniform vec2 outputSize;\n#define SHADER_NAME QUAD\nvec2 c;\nvoid main(void) {\n  c = gl_FragCoord.xy / outputSize.xy;\n  vec4 d = texture2D(TextureInput, c.xy);\n  gl_FragColor = d;\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.outputSize[0],height:(e,n)=>n.outputSize[1]}}}))}_createTextures(e){if(!this._targetFBO){const n=this._regl;this._outputTex&&this._outputTex.destroy(),this._outputTex=n.texture({min:"linear",mag:"linear",type:"uint8",width:e.width,height:e.height}),this._targetFBO=n.framebuffer({width:e.width,height:e.height,colors:[this._outputTex],depth:!1,stencil:!1})}}}class Xn$4 extends vn$4{constructor(e){const t=[];super({vert:"#define SHADER_NAME HEATMAP\nuniform mat4 projViewModelMatrix;\nuniform float extrudeScale;\nuniform float heatmapIntensity;\nattribute vec3 aPosition;\nvarying vec2 vExtrude;\n#ifdef HAS_HEAT_WEIGHT\nattribute highp float aWeight;\nvarying highp float weight;\n#else\nuniform highp float heatmapWeight;\n#endif\nuniform mediump float heatmapRadius;\nconst highp float c = 1. / 255. / 16.;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n  \n#ifdef HAS_HEAT_WEIGHT\nhighp float d = aWeight / 255.;\n  weight = d;\n#else\nhighp float d = heatmapWeight;\n#endif\nmediump float e = heatmapRadius;\n  vec2 f = vec2(mod(aPosition.xy, 2.) * 2. - 1.);\n  float h = sqrt(-2. * log(c / d / heatmapIntensity / GAUSS_COEF)) / 3.;\n  vExtrude = h * f;\n  vec2 i = vExtrude * e * extrudeScale;\n  vec4 j = vec4(floor(aPosition.xy * .5) + i, aPosition.z, 1);\n  gl_Position = projViewModelMatrix * j;\n}",frag:"#define SHADER_NAME HEATMAP\nprecision mediump float;\nuniform highp float heatmapIntensity;\nvarying vec2 vExtrude;\n#ifdef HAS_HEAT_WEIGHT\nvarying highp float weight;\n#else\nuniform highp float heatmapWeight;\n#endif\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n  \n#ifdef HAS_HEAT_WEIGHT\nhighp float c = weight;\n#else\nhighp float c = heatmapWeight;\n#endif\nfloat d = -.5 * 3. * 3. * dot(vExtrude, vExtrude);\n  float e = c * heatmapIntensity * GAUSS_COEF * exp(d);\n  gl_FragColor = vec4(e, 1., 1., 1.);\n}",uniforms:[{name:"extrudeScale",type:"function",fn:function(e,n){return n.resolution/n.dataResolution*n.tileRatio}},{name:"projViewModelMatrix",type:"function",fn:function(e,r){return multiply$5(t,r.projViewMatrix,r.modelMatrix)}}],extraCommandProps:v$3({},e&&e.extraCommandProps||{},{blend:{enable:!0,func:{src:"one",dst:"one"},equation:"add"}})})}}var Wn$4=[-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,-1,1,1,1,1,1,1,1,1,1,-1,1,-1,-1,-1,-1,1,-1,1,1,1,1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,1,-1,1],Kn$4="#define SHADER_NAME SKYBOX\n#if __VERSION__ == 100\n#ifdef GL_EXT_shader_texture_lod\n#extension GL_EXT_shader_texture_lod : enable\n#define textureCubeLod(tex, uv, lod) textureCubeLodEXT(tex, uv, lod)\n#else\n#define textureCubeLod(tex, uv, lod) textureCube(tex, uv, lod)\n#endif\n#else\n#define textureCubeLod(tex, uv, lod) textureLod(tex, uv, lod)\n#endif\nprecision highp float;\n#include <gl2_frag>\n#include <hsv_frag>\nuniform vec3 hsv;\nvarying vec3 vWorldPos;\n#ifdef USE_AMBIENT\nuniform vec3 diffuseSPH[9];\n#else\nuniform samplerCube cubeMap;\nuniform float bias;\nuniform float size;\n#endif\nuniform float environmentExposure;\n#if defined(INPUT_RGBM) || defined(ENC_RGBM)\nuniform float rgbmRange;\n#endif\nvec4 c(const in vec3 d, const in float e) {\n  if(e <= .0)\n    return vec4(d, 1.);\n  vec4 f;\n  vec3 h = d / e;\n  f.a = clamp(max(max(h.r, h.g), max(h.b, 1e-6)), .0, 1.);\n  f.a = ceil(f.a * 255.) / 255.;\n  f.rgb = h / f.a;\n  return f;\n}\nvec3 i(const in vec4 d, const in float e) {\n  if(e <= .0)\n    return d.rgb;\n  return e * d.rgb * d.a;\n}\nvec4 j(const in samplerCube k, const in vec3 l, const in float m, const in float n) {\n  vec3 o = l;\n  return textureCubeLod(k, o, n);\n}\nvec3 u(const in vec3 v, const in vec3 A[9]) {\n  float x = v.x;\n  float y = v.y;\n  float z = v.z;\n  vec3 B = (A[0] + A[1] * x + A[2] * y + A[3] * z + A[4] * z * x + A[5] * y * z + A[6] * y * x + A[7] * (3. * z * z - 1.) + A[8] * (x * x - y * y));\n  return max(B, vec3(.0));\n}\nfloat C(const in vec2 D) {\n  vec3 E = fract(vec3(D.xyx) * .1031);\n  E += dot(E, E.yzx + 19.19);\n  return fract((E.x + E.y) * E.z);\n}\nvoid main() {\n  vec4 F;\n#ifdef USE_AMBIENT\nvec3 v = normalize(vWorldPos + mix(-.5 / 255., .5 / 255., C(gl_FragCoord.xy)) * 2.);\n  F = vec4(u(v, diffuseSPH), 1.);\n  if(length(hsv) > .0) {\n    F.rgb = hsv_apply(F.rgb, hsv);\n  }\n#else\nF = j(cubeMap, vWorldPos, size, bias);\n#endif\nF.rgb *= environmentExposure;\n#ifdef ENC_RGBM\n#if !defined(USE_AMBIENT) && defined(INPUT_RGBM)\nif(length(hsv) > .0) {\n    F.rgb = hsv_apply(i(F, rgbmRange).rgb, hsv);\n    F = c(F.rgb, rgbmRange);\n  }\n#else\nF = c(F.rgb, rgbmRange);\n#endif\nglFragColor = F;\n#elif !defined(USE_AMBIENT) && defined(INPUT_RGBM)\nglFragColor = vec4(i(F, rgbmRange), 1.);\n  if(length(hsv) > .0) {\n    glFragColor.rgb = hsv_apply(clamp(glFragColor.rgb, .0, 1.), hsv);\n  }\n#else\nif(length(hsv) > .0) {\n    F.rgb = hsv_apply(F.rgb, hsv);\n  }\n  glFragColor = F;\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}";class qn$4 extends vn$4{constructor(){super({vert:"#include <gl2_vert>\nattribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 transformMatrix;\nvarying vec3 vWorldPos;\nvoid main() {\n  vWorldPos = aPosition;\n  mat4 c = mat4(mat3(viewMatrix) * transformMatrix);\n  vec4 d = projMatrix * c * vec4(vWorldPos, 1.);\n  gl_Position = d.xyww;\n}",frag:Kn$4,extraCommandProps:{depth:{enable:!0,range:[1,1],func:"lequal"},viewport:{x:0,y:0,width:(e,n)=>n.resolution[0],height:(e,n)=>n.resolution[1]}}}),this.version=300}setMode(e,n,t){const r={};return e&&(r.INPUT_RGBM=1),n&&(r.ENC_RGBM=1),0===t&&(r.USE_AMBIENT=1),this._skyboxMesh?this._skyboxMesh[0].setDefines(r):this._meshDefines=r,this}draw(e){return this._skyboxMesh||this._createSkyboxMesh(e),super.draw(e,this._skyboxMesh)}_createSkyboxMesh(e){const n=new Q$7({aPosition:new Int8Array(Wn$4)},null,Wn$4.length/3);n.generateBuffers(e),this._skyboxMesh=[new Be$5(n)],this._meshDefines&&(this._skyboxMesh[0].setDefines(this._meshDefines),delete this._meshDefines)}dispose(){if(this._skyboxMesh){const e=this._skyboxMesh[0];e.geometry.dispose(),e.dispose()}return delete this._skyboxMesh,super.dispose()}}class Yn$4 extends vn$4{constructor(e,t){const r={blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},viewport:e};t&&t.extraCommandProps&&v$3(r,t.extraCommandProps);const i=[];super({vert:"#define SHADER_NAME HEATMAP_DISPLAY\nuniform mat4 projViewModelMatrix;\nattribute vec3 aPosition;\nvoid main() {\n  gl_Position = projViewModelMatrix * vec4(aPosition, 1.);\n}",frag:"#define SHADER_NAME HEATMAP_DISPLAY\nprecision mediump float;\nuniform sampler2D inputTexture;\nuniform sampler2D colorRamp;\nuniform vec2 textureOutputSize;\nuniform float heatmapOpacity;\nvoid main() {\n  vec2 c = gl_FragCoord.xy / textureOutputSize.xy;\n  float t = texture2D(inputTexture, c).r;\n  vec4 d = texture2D(colorRamp, vec2(t, .5));\n  gl_FragColor = d * heatmapOpacity;\n}",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(e,t){return multiply$5(i,t.projViewMatrix,t.modelMatrix)}}],extraCommandProps:r})}}class Zn$4 extends Mn$4{constructor(){super({vert:An$4,frag:"precision highp float;\nuniform sampler2D texture;\nuniform vec2 size;\nuniform float enableSharpen;\nuniform float sharpFactor;\nuniform float pixelRatio;\nvec2 c;\nvec3 d(const in vec3 e, const float f) {\n  vec2 h = pixelRatio / size.xy;\n  float i = .0;\n  vec4 j = texture2D(texture, c + h * vec2(-1., -1.));\n  j.rgb = mix(vec3(.0), j.rgb, sign(j.a));\n  i += mix(.0, 1., sign(j.a));\n  vec4 k = texture2D(texture, c + h * vec2(1.));\n  k.rgb = mix(vec3(.0), k.rgb, sign(k.a));\n  i += mix(.0, 1., sign(k.a));\n  vec4 l = texture2D(texture, c + h * vec2(1., -1.));\n  l.rgb = mix(vec3(.0), l.rgb, sign(l.a));\n  i += mix(.0, 1., sign(l.a));\n  vec4 m = texture2D(texture, c + h * vec2(-1., 1.));\n  m.rgb = mix(vec3(.0), m.rgb, sign(m.a));\n  i += mix(.0, 1., sign(m.a));\n  return e + f * (i * e - j.rgb - l.rgb - m.rgb - k.rgb);\n}\nvoid main() {\n  c = gl_FragCoord.xy / size;\n  vec4 e = texture2D(texture, c);\n  if(enableSharpen == 1.) {\n    e.rgb = d(e.rgb, sharpFactor);\n  }\n  gl_FragColor = e;\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.size[0],height:(e,n)=>n.size[1]}}})}getMeshCommand(e,n){return this.commands.copy||(this.commands.copy=this.createREGLCommand(e,null,n.getElements())),this.commands.copy}}class Qn$4 extends vn$4{constructor(e={}){const t=[],r=e.uniforms,i=[{name:"modelViewMatrix",type:"function",fn:function(e,r){return multiply$5(t,r.viewMatrix,r.modelMatrix)}}];r&&i.push(...r),super({vert:"attribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 modelViewMatrix;\nuniform vec2 halton;\nuniform vec2 outSize;\n#include <get_output>\nvoid main() {\n  vec4 c = getPosition(aPosition);\n  mat4 d = getPositionMatrix();\n  mat4 e = projMatrix;\n  e[2].xy += halton.xy / outSize.xy;\n  gl_Position = e * modelViewMatrix * d * c;\n}",frag:"precision mediump float;\nuniform vec4 lineColor;\nuniform float lineOpacity;\nvoid main() {\n  gl_FragColor = lineColor;\n  gl_FragColor.a *= lineOpacity;\n}",uniforms:i,defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}})}}const $n$4=[],et$6=[];const tt$6=[];class rt$6{constructor(e,n,t){this._regl=e,this._layer=t,this._viewport=n,this._init()}_init(){this._shader=new vn$4({vert:"attribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nvarying vec4 vWorldPosition;\n#include <get_output>\nvoid main() {\n  vec4 c = getPosition(aPosition);\n  mat4 d = getPositionMatrix();\n  vec4 e = modelMatrix * d * c;\n  gl_Position = projMatrix * modelViewMatrix * d * c;\n  vWorldPosition = e;\n}",frag:"precision mediump float;\nvarying vec4 vWorldPosition;\nuniform vec2 fogDist;\nuniform vec3 cameraPosition;\nuniform float rainDepth;\nvoid main() {\n  vec3 c = vec3(vWorldPosition[0] - cameraPosition[0], vWorldPosition[1] - cameraPosition[1], vWorldPosition[2] - cameraPosition[2]);\n  float d = length(c);\n  float e = clamp(1. - (d - fogDist.x) / (fogDist.y - fogDist.x), .0, 1.);\n  if(vWorldPosition[2] < rainDepth) {\n    gl_FragColor = vec4(e, .0, .0, 1.);\n  } else {\n    gl_FragColor = vec4(e, 1., .0, 1.);\n  }\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(e,t){return multiply$5(tt$6,t.viewMatrix,t.modelMatrix)}}],extraCommandProps:{viewport:this._viewport}});const e=this._layer.getRenderer().createFBOInfo();this._fbo=this._regl.framebuffer(e),this._scene=new Ke$5,this.renderer=new B$6(this._regl)}render(e,n){return this._resize(),this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this._fbo}),this._scene.setMeshes(e),this.renderer.render(this._shader,{projMatrix:n.projMatrix,viewMatrix:n.viewMatrix,cameraPosition:n.cameraPosition,fogDist:n.fogDist,rainDepth:n.rainDepth},this._scene,this._fbo),this._fbo}dispose(){this._fbo&&this._fbo.destroy(),this._shader&&this._shader.dispose()}_resize(){const e=h$2(this._viewport.width.data)?this._viewport.width.data():this._viewport.width,n=h$2(this._viewport.height.data)?this._viewport.height.data():this._viewport.height;!this._fbo||this._fbo.width===e&&this._fbo.height===n||this._fbo.resize(e,n)}}class it$5 extends Mn$4{constructor(){super({vert:An$4,frag:"#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nvarying vec2 vTexCoord;\n#ifdef HAS_RAIN\nuniform sampler2D ripplesMap;\n#endif\n#ifdef HAS_SNOW\nuniform sampler2D normalMap;\n#endif\n#ifdef HAS_FOG\nuniform vec3 fogColor;\n#endif\nuniform sampler2D sceneMap;\nuniform sampler2D mixFactorMap;\nuniform float time;\nuniform vec2 resolution;\nuniform float snowIntensity;\nfloat c(float a, float b, float w) {\n  return a + w * (b - a);\n}\n#define HASHSCALE1 .1031\n#define HASHSCALE3 vec3(.1031, .1030, .0973)\n#define HASHSCALE4 vec3(.1031, .1030, .0973, .1099)\nfloat d = .5;\nfloat e = .2;\nfloat f = .5;\nfloat h = 20.;\nfloat i(float p) {\n  vec3 j = fract(vec3(p) * HASHSCALE1);\n  j += dot(j, j.yzx + 19.19);\n  return fract((j.x + j.y) * j.z);\n}\nvec2 k(vec2 p) {\n  vec3 j = fract(vec3(p.xyx) * HASHSCALE3);\n  j += dot(j, j.yzx + 19.19);\n  return fract((j.xx + j.yz) * j.zy);\n}\nvec2 l(vec2 m) {\n  float x = fract(sin(dot(m.xy, vec2(122.9898, 783.233))) * 43758.5453);\n  float y = fract(sin(dot(m.xy, vec2(457.6537, 537.2793))) * 37573.5913);\n  return vec2(x, y);\n}\nvec3 n(vec2 o, float u) {\n  vec3 v = vec3(.0);\n  o = o * (2. + u);\n  float A = e * snowIntensity;\n  float B = o.y * (((i(u) * 2. - 1.) * .5 + 1.) * A);\n  float C = (f * time);\n  o += vec2(B, C);\n  vec2 D = k(floor(o) + 31.1759 * u);\n  o = fract(o);\n  o -= (D * 2. - 1.) * .35;\n  o -= .5;\n  float r = length(o);\n  float E = .05 * (1. + .3 * sin(time * d));\n  float F = smoothstep(E, -E, r);\n  vec3 G = vec3(F) * D.x;\n  return G;\n}\nvec3 H() {\n  vec3 v = vec3(0);\n  vec2 o = gl_FragCoord.xy / resolution.xy;\n  o *= vec2(resolution.x / resolution.y, 1.);\n  float I = h * snowIntensity;\n  for(float J = 0.; J < I; J++) {\n    v += n(o, J);\n  }\n  return v;\n}\nvec3 K(vec4 L, vec4 M, float N) {\n  float O = M.b;\n  vec3 P = vec3(1.);\n  if(N < 1.) {\n    float r = c(.5, P.x, O);\n    float g = c(.5, P.y, O);\n    float b = c(.5, P.z, O);\n    return vec3(r, g, b);\n  } else {\n    float r = c(L.r, P.x, O);\n    float g = c(L.g, P.y, O);\n    float b = c(L.b, P.z, O);\n    return vec3(r, g, b);\n  }\n}\nvoid main() {\n  vec4 L = texture2D(sceneMap, vTexCoord);\n  glFragColor = L;\n  vec4 Q = texture2D(mixFactorMap, vTexCoord);\n#ifdef HAS_RAIN\nvec4 R = texture2D(ripplesMap, vTexCoord);\n  if(Q.g < 1.) {\n    L = mix(L, R, .4);\n  }\n  glFragColor = L;\n#endif\n#ifdef HAS_SNOW\nvec3 S = H();\n  glFragColor = vec4(L.rgb + S, L.a);\n#endif\n#ifdef HAS_FOG\nfloat T = Q.r;\n  vec3 U = mix(fogColor, glFragColor.rgb, T);\n  glFragColor = vec4(U, L.a);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.resolution[0],height:(e,n)=>n.resolution[1]}}})}}const ot$6=[],at$6=[.03,.03,.03],st$6=[],ct$6=[],lt$6=[],ft$6=fromRotationTranslation$1([],fromEuler([],90,0,0),[0,0,0]);class dt$6{constructor(e,n){this._regl=e,this._viewport=n,this._init()}_init(){this._shader=new vn$4({vert:"#include <gl2_vert>\nattribute vec3 aPosition;\nattribute vec3 aNormal;\nattribute vec2 aTexCoord;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nvarying vec2 vTexCoord;\n#include <get_output>\nvoid main() {\n  vec4 c = getPosition(aPosition);\n  mat4 d = getPositionMatrix();\n  gl_Position = projMatrix * modelViewMatrix * d * c;\n  vTexCoord = aTexCoord;\n}",frag:"#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nvarying vec2 vTexCoord;\nuniform float rippleRadius;\nuniform float density;\nuniform float time;\nvec3 c(vec2 p) {\n  vec3 q = vec3(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)), dot(p, vec2(419.2, 371.9)));\n  return fract(sin(q) * 43758.5453);\n}\nfloat d(in vec2 x) {\n  vec2 e = x * density / 4000.0;\n  vec2 p = floor(e);\n  vec2 f = fract(e);\n  float h = .0;\n  for(int i = -4; i <= 4; i++)\n    for(int k = -4; k <= 4; k++) {\n      vec2 g = vec2(float(k), float(i));\n      vec3 l = c(p + g);\n      vec2 r = g - f + l.xy;\n      float m = sqrt(dot(r, r));\n      float n = max(mix(smoothstep(.99, .999, max(cos(m - time * 2. + (l.x + l.y) * 5.), 0.)), 0., m), 0.);\n      h += n;\n    }\n  return h;\n}\nvoid main() {\n  vec2 u = vTexCoord;\n  float A = 24. / (rippleRadius * .01);\n  float f = d(A * u) * smoothstep(.0, .4, sin(u.x * 3.151592) * sin(u.y * 3.141592));\n  vec3 B = vec3(-dFdx(f), -dFdy(f), -dFdy(f));\n  glFragColor = vec4(B, 1.);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(e,t){return multiply$5(ot$6,t.viewMatrix,t.modelMatrix)}}],extraCommandProps:{viewport:this._viewport}}),this._shader.version=300,this._fbo=this._regl.framebuffer({color:this._regl.texture({width:this._viewport.width(),height:this._viewport.height(),wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this._scene=new Ke$5,this.renderer=new B$6(this._regl)}_transformRipples(e){const r=e.coordinateToPointAtRes(e.getCenter(),e.getGLRes()),i=e.getGLScale()/e.getGLScale(this._fixZoom),o=set$4(ct$6,i,i,i),s=multiply$4(o,at$6,o),c=identity$2(lt$6);fromRotationTranslationScale(c,fromEuler(st$6,0,0,0),[r.x,r.y,0],s),multiply$5(c,c,ft$6),this._mesh.setLocalTransform(c)}_createRipplesMask(e){this._fixZoom=e.getZoom();const n=800*Math.pow(2,16.685648411389433-this._fixZoom),t={};t.POSITION=[-n,0,-n,n,0,-n,-n,0,n,n,0,n],t.NORMAL=[0,1,0,0,1,0,0,1,0,0,1,0],t.TEXCOORD_0=[0,0,1,0,0,1,1,1];const r=new Q$7(t,[3,1,0,0,2,3],0,{positionAttribute:"POSITION",normalAttribute:"NORMAL",uv0Attribute:"TEXCOORD_0"});r.generateBuffers(this._regl);const i=new Ce$5;return new Be$5(r,i)}render(e,n){return this._resize(),this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this._fbo}),this._mesh=this._mesh||this._createRipplesMask(e),this._scene.setMeshes(this._mesh),this._transformRipples(e),this.renderer.render(this._shader,{projMatrix:n.projMatrix,viewMatrix:n.viewMatrix,time:n.time,rippleRadius:n.rippleRadius,density:n.density},this._scene,this._fbo),this._fbo}dispose(){this._fbo&&this._fbo.destroy(),this._shader&&this._shader.dispose()}_resize(){const e=h$2(this._viewport.width.data)?this._viewport.width.data():this._viewport.width,n=h$2(this._viewport.height.data)?this._viewport.height.data():this._viewport.height;!this._fbo||this._fbo.width===e&&this._fbo.height===n||this._fbo.resize(e,n)}}var ut$6="attribute vec3 aPosition;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\n#ifdef HAS_VIDEO\nattribute vec2 aTexCoord;\nvarying vec2 uv;\n#endif\n#include <get_output>\nvoid main() {\n  mat4 c = getPositionMatrix();\n  vec4 d = c * getPosition(aPosition);\n  gl_Position = projViewModelMatrix * d;\n#ifdef HAS_VIDEO\nuv = aTexCoord;\n#endif\n}";const ht$6=[0,0,0,1];class mt$6{constructor(e,n){this.regl=e,this._viewport=n,this.renderer=new B$6(e),this._init()}_init(){this._maskColorFbo=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this._maskModeFbo=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"nearest",min:"nearest"}),depth:!0});const e=[{name:"projViewModelMatrix",type:"function",fn:(e,t)=>multiply$5([],t.projViewMatrix,t.modelMatrix)}];this._maskColorShader=new vn$4({vert:ut$6,frag:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec4 maskColor;\n#ifdef HAS_VIDEO\nuniform sampler2D maskTexture;\nvarying vec2 uv;\n#endif\nvoid main() {\n  \n#ifdef HAS_VIDEO\ngl_FragColor = texture2D(maskTexture, uv);\n  gl_FragColor.a = maskColor.a;\n#else\ngl_FragColor = maskColor;\n#endif\n}",uniforms:e,extraCommandProps:{viewport:this._viewport}}),this._maskModeShader=new vn$4({vert:ut$6,frag:"#ifdef GL_ES\nprecision highp float;\n#endif\nuniform float maskMode;\n#ifdef HAS_MASK_FLAT\nuniform float flatHeight;\n#endif\n#ifdef HAS_MASK_COLOR\nuniform vec2 heightRange;\n#endif\nvoid main() {\n  \n#if defined(HAS_MASK_FLAT)\ngl_FragColor = vec4(maskMode, flatHeight, .0, 1.);\n#elif defined(HAS_MASK_COLOR)\ngl_FragColor = vec4(maskMode, .0, heightRange.x, heightRange.y);\n#else\ngl_FragColor = vec4(maskMode, .0, .0, .0);\n#endif\n}",uniforms:e,extraCommandProps:{viewport:this._viewport}}),this._scene=new Ke$5}render(e,n){this._resize(),this.renderer.clear({color:ht$6,depth:1,framebuffer:this._maskColorFbo}),this.renderer.clear({color:ht$6,depth:1,framebuffer:this._maskModeFbo}),this._scene.setMeshes(e);const t={projViewMatrix:n};return this.renderer.render(this._maskColorShader,t,this._scene,this._maskColorFbo),this.renderer.render(this._maskModeShader,t,this._scene,this._maskModeFbo),{colorExtent:this._maskColorFbo,modeExtent:this._maskModeFbo}}_resize(){const e=h$2(this._viewport.width)?this._viewport.width():this._viewport.width.data(),n=h$2(this._viewport.height)?this._viewport.height():this._viewport.height.data();!this._maskColorFbo||this._maskColorFbo.width===e&&this._maskColorFbo.height===n||(this._maskColorFbo.resize(e,n),this._maskModeFbo.resize(e,n))}dispose(){this._maskColorFbo&&(this._maskColorFbo.destroy(),delete this._maskColorFbo),this._maskModeFbo&&(this._maskModeFbo.destroy(),delete this._maskModeFbo),this._maskColorShader&&(this._maskColorShader.dispose(),delete this._maskColorShader),this._maskModeShader&&(this._maskModeShader.dispose(),delete this._maskModeShader)}}const vt$6=[],_t$6={width:4,type:"float"};class gt$6{constructor(e,n,t){this._regl=e,this.joints=n,this.inverseBindMatrices=[],this.jointMatrices=[],this.jointData=new Float32Array(16*n.length);for(let e=0;e<n.length;++e)this.inverseBindMatrices.push(new Float32Array(t.buffer,t.byteOffset+16*Float32Array.BYTES_PER_ELEMENT*e,16)),this.jointMatrices.push(new Float32Array(this.jointData.buffer,16*Float32Array.BYTES_PER_ELEMENT*e,16));this.jointTextureSize=[4,6]}update(e,t,r){invert$2(vt$6,e);for(let e=0;e<this.joints.length;++e){const r=this.jointMatrices[e];multiply$5(r,vt$6,t[this.joints[e].nodeIndex]),multiply$5(r,r,this.inverseBindMatrices[e])}_t$6.height=this.joints.length,_t$6.data=this.jointData;const i=_t$6;return r?r(i):r=this._regl.texture(i),r}}const xt$6=[0,0,0],bt$6=[0,0,0,1],pt$6=[1,1,1],yt$6=[];class At$6{constructor(e=[0,0,0],n=[0,0,0,1],t=[1,1,1]){this.translation=e,this.rotation=n,this.scale=t}getMatrix(){return fromRotationTranslationScale(yt$6,this.rotation,this.translation,this.scale)}decompose(e){getTranslation$1(this.translation,e),getRotation(this.rotation,e),getScaling(this.scale,e)}update(e){e&&(e.translation&&!equals$5(e.translation,xt$6)&&copy$4(this.translation,e.translation),e.rotation&&!equals$3(e.rotation,bt$6)&&copy$2(this.rotation,e.rotation),e.scale&&!equals$5(e.scale,pt$6)&&copy$4(this.scale,e.scale))}}class St$6{constructor(e){this._init(e)}_init(e){this.bbox=e.bbox,this.geometry=e.geometry,this.nodeMatrix=e.nodeMatrix,this.materialInfo=e.materialInfo,this.extraInfo=e.extraInfo,this.animationMatrix=e.animationMatrix,this.morphWeights=e.morphWeights,this.skin=e.skin,this.nodeIndex=e.nodeIndex}copyEdgeGeometry(){this.copyGeometry||(this.copyGeometry=this._copyEdgeGeometry(this.geometry))}createCopyBarycentric(){this.copyGeometry&&!this.copyGeometry.data.aBarycentric&&(this.copyGeometry.buildUniqueVertex(),this.copyGeometry.createBarycentric("aBarycentric"))}_copyEdgeGeometry(e){const n=e.data,t=e.indices||e.elements,r={};for(const t in n)if(t===e.desc.positionAttribute)if(b$5(n[t]))r[t]=n[t].slice();else if(n[t].buffer&&n[t].buffer.destroy)r[t]={buffer:n[t].buffer},b$5(n[t].array)&&(r[t].array=n[t].array.slice());else{const n=e._getAttributeData(t);r[t]=t!==e.desc.positionAttribute?n:n.slice()}const i=void 0!==t.length?t.slice():t,o=JSON.parse(JSON.stringify(e.desc)),a=new Te$5(r,i,0,o);return a.properties=e.properties,a}}let Tt$6=0;const Mt$6=[];class Ct$6{constructor(e,n){this.gltf=e,this.regl=n,this.geometries=[],n&&(this._emptyTexture=n.texture({width:2,height:2}))}getMeshesInfo(){return this.gltf?(this.geometries.length||(this._createTextures(this.gltf.textures),this._createSkins(this.gltf.skins),this.gltf.scenes[0].nodes.forEach((e=>{this._parserNode(e,this.geometries)})),this._checkBaseColorFactor()),this.geometries):null}getGLTFBBox(){if(!this.gltf)return null;const e=this.geometries;if(!e||!e.length)return null;const n=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let r=0;r<e.length;r++){const i=e[r].bbox,o=i.min,a=i.max;o[0]<n[0]&&(n[0]=o[0]),o[1]<n[1]&&(n[1]=o[1]),o[2]<n[2]&&(n[2]=o[2]),a[0]>t[0]&&(t[0]=a[0]),a[1]>t[1]&&(t[1]=a[1]),a[2]>t[2]&&(t[2]=a[2])}return{min:n,max:t}}_createSkins(e){if(e){this._skinMap={};for(let n=0;n<e.length;n++){const t=e[n];t.joints=t.joints.map((e=>this.gltf.nodes[e])),this._skinMap[n]=new gt$6(this.regl,t.joints,t.inverseBindMatrices.array),delete t.inverseBindMatrices}}}_createTextures(e){if(e){this._textureMap={};for(let n=0;n<e.length;n++){const t=e[n];this._textureMap[n]||(this._textureMap[n]=this._toTexture(t),delete t.image)}}}_checkBaseColorFactor(){if(!this._checkBaseColorFactorAlpha())for(let e=0;e<this.geometries.length;e++){const n=this.geometries[e].materialInfo.baseColorFactor;n&&0===n[3]&&(n[3]=1)}}_checkBaseColorFactorAlpha(){for(let e=0;e<this.geometries.length;e++){const n=this.geometries[e].materialInfo.baseColorFactor;if(n&&n[3]>0)return!0}return!1}dispose(){this._emptyTexture&&this._emptyTexture.destroy();const e=this.getMeshesInfo();if(e){e.forEach((e=>{e.geometry.dispose();for(const n in e.materialInfo){const t=e.materialInfo[n];t.destroy&&!t[H$6]&&t.destroy()}}));for(const e in this._textureMap){const n=this._textureMap[e];n.destroy&&!n[H$6]&&n.destroy()}delete this.gltf}}updateAnimation(n,t,r,i,o,a,s,c){const l=this.gltf;if(!l)return;if(Tt$6=l.animations?X$8.getAnimationTimeSpan(l,i):null,!Tt$6)return;n-=o;let f=0;f=t||!t&&this._isFirstLoop(n,r,i,o)?n*r*.001%(Tt$6.max-Tt$6.min)+Tt$6.min:n*r*.001+Tt$6.min,l.scenes[0].nodes.forEach((e=>{this._updateNodeMatrix(i,f,e,null,a,c)}));for(const e in this.gltf.nodes){const n=this.gltf.nodes[e],t=a[n.nodeIndex];if(n.skin&&t){const e=n.skin.update(t,a,s[n.nodeIndex]&&s[n.nodeIndex].jointTexture);s[n.nodeIndex]||(s[n.nodeIndex]={jointTextureSize:n.skin.jointTextureSize,numJoints:n.skin.joints.length}),s[n.nodeIndex].jointTexture=e}}}_isFirstLoop(n,t,r,i){const o=this.gltf;return!i||!o||(Tt$6=o.animations?X$8.getAnimationTimeSpan(o,r):null,n*t*.001/(Tt$6.max-Tt$6.min)<1)}hasSkinAnimation(){return!!this._isAnimation}_updateNodeMatrix(e,t,r,i,o,a){r.trs&&(a?a.indexOf(Number(r.nodeIndex))>-1&&this._updateNodeTRS(r,t,e):this._updateNodeTRS(r,t,e)),o[r.nodeIndex]=i?multiply$5(o[r.nodeIndex]||[],i,r.matrix||r.trs.getMatrix()):copy$5(o[r.nodeIndex]||[],r.matrix||r.trs.getMatrix()),r.children&&r.children.forEach((n=>{this._updateNodeMatrix(e,t,n,o[r.nodeIndex],o,a)}))}_updateNodeTRS(n,t,r){const i=X$8.getAnimationClip(this.gltf,Number(n.nodeIndex),t,r);i.weights&&this._updateMorph(n,i.weights),n.trs.update(i)}_updateMorph(e,n){const t=n.length;if(!e.influencesList){e.influencesList=[];for(let n=0;n<t;n++)e.influencesList[n]=[n,0]}const r=e.influencesList;for(let e=0;e<r.length;e++){const t=r[e];t[0]=e,t[1]=n[e]}r.sort(Et$6);const i=[];for(let e=0;e<8;e++)i[e]=[e,0];for(let e=0;e<8;e++)e<t&&r[e][1]?(i[e][0]=r[e][0],i[e][1]=r[e][1]):(i[e][0]=Number.MAX_SAFE_INTEGER,i[e][1]=0);i.sort(Ot$6),e.geometries.forEach((e=>{const n=e.properties.morphTargets;for(let t=0;t<8;t++){const r=i[t],o=r[0],a=r[1];o!==Number.MAX_SAFE_INTEGER&&a?(e.updateData("POSITION"+t,n["POSITION_"+o].array),e.properties.morphWeights[t]=a):e.properties.morphWeights[t]=0}}))}_parserNode(e,t,r){if(e.isParsed)return;e.nodeMatrix=e.nodeMatrix||identity$2([]),e.localMatrix=e.localMatrix||identity$2([]),e.matrix?(e.trs=new At$6,e.trs.decompose(e.matrix)):e.trs=new At$6(e.translation,e.rotation,e.scale),e.localMatrix=e.trs.getMatrix(),r?multiply$5(e.nodeMatrix,r,e.matrix||e.localMatrix):copy$5(e.nodeMatrix,e.matrix||e.localMatrix);const i=e.nodeMatrix;if(e.children)for(let n=0;n<e.children.length;n++)this._parserNode(e.children[n],t,i);if(u$3(e.skin)){this._isAnimation=!0;const n=e.skin;e.trs=new At$6,e.skin=this._skinMap[n]}u$3(e.mesh)&&(e.mesh=this.gltf.meshes[e.mesh],e.mesh.node=e,e.geometries=e.geometries||[],e.mesh.primitives.forEach((r=>{const o=this._createMaterialInfo(r.material),a=function(e,n,t){const r=e.attributes,i=r.COLOR_0;if(i&&i.array instanceof Float32Array){const e=new Uint8Array(i.array.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*i.array[n]);i.array=e}else if(i&&(i.array instanceof Uint16Array||i.array instanceof Int16Array||i.array instanceof Uint32Array||i.array instanceof Int32Array)){const e=new Uint8Array(i.array);i.array=e}t&&r.TEXCOORD_0&&!r.TEXCOORD_0&&(r.TEXCOORD_1=r.TEXCOORD_0);const o={};for(const e in r)o[e]=v$3({},r[e]),n&&(o[e].buffer=me$5(n,r[e],{dimension:r[e].itemSize}));if(e.morphTargets){const e=P$5(o.POSITION)?o.POSITION.itemSize*o.POSITION.count:o.POSITION.array.length;for(let n=0;n<8;n++)o["POSITION"+n]||(o["POSITION"+n]=new Float32Array(e).fill(0));for(let e=0;e<4;e++){const n=o.NORMAL.array?o.NORMAL.array.length:o.NORMAL.length;o["NORMAL"+e]||(o["NORMAL"+e]=new Float32Array(n).fill(0))}}let a=e.indices;a&&void 0===a.bufferView&&a.array&&(a=a.array);const s=new Q$7(o,a,0,{primitive:g$1(e.mode)?ne$5(e.mode):e.mode,positionAttribute:"POSITION",normalAttribute:"NORMAL",uv0Attribute:"TEXCOORD_0",uv1Attribute:"TEXCOORD_1",color0Attribute:"COLOR_0"});return e.morphTargets&&(s.properties.morphWeights=[]),e.mode>3&&!s.data.NORMAL&&s.createNormal("NORMAL"),s}(r,this.regl,o.occlusionTexture);a.properties.morphTargets=r.morphTargets,e.geometries.push(a);let s=a.boundingBox.copy();s=s.transform(identity$2(Mt$6),i);const c={geometry:a,bbox:s,nodeMatrix:i,materialInfo:o,extraInfo:this._createExtralInfo(r.material),animationMatrix:e.trs.getMatrix(),morphWeights:e.weights,nodeIndex:e.nodeIndex};e.skin&&(c.skin={jointTextureSize:[4,6],numJoints:e.skin.joints.length,jointTexture:e.skin.jointTexture});const l=new St$6(c);t.push(l)}))),e.isParsed=!0}_createMaterialInfo(e){const n={};if(this.gltf.materials&&this.gltf.materials[e]){const t=this.gltf.materials[e],r=t.pbrMetallicRoughness;if(r){const e=r.metallicRoughnessTexture,t=r.baseColorTexture;t&&(n.baseColorTexture=this._getTexture(t),t.KHR_texture_transform&&(n.khr_offset=t.KHR_texture_transform.offset||[0,0],n.khr_rotation=t.KHR_texture_transform.rotation||0,n.khr_scale=t.KHR_texture_transform.scale||[1,1])),r.baseColorFactor&&(n.baseColorFactor=r.baseColorFactor),e?n.metallicRoughnessTexture=this._getTexture(e):(n.metallicFactor=u$3(r.metallicFactor)?r.metallicFactor:1,n.roughnessFactor=u$3(r.roughnessFactor)?r.roughnessFactor:1)}const i=t.extensions;if(i&&i.KHR_materials_pbrSpecularGlossiness){const e=i.KHR_materials_pbrSpecularGlossiness;n.name="pbrSpecularGlossiness";for(const t in e)n[t]=u$3(e[t].index)?this._getTexture(e[t]):e[t]}t.normalTexture&&(n.normalTexture=this._getTexture(t.normalTexture)),t.occlusionTexture&&(n.occlusionTexture=this._getTexture(t.occlusionTexture)),t.emissiveTexture&&(n.emissiveTexture=this._getTexture(t.emissiveTexture)),t.emissiveFactor&&(n.emissiveFactor=t.emissiveFactor),n.alphaCutoff=t.alphaCutoff||.5}return n}_createExtralInfo(e){const n={};if(this.gltf.materials&&this.gltf.materials[e]){const t=this.gltf.materials[e];n.doubleSided=t.doubleSided,n.alphaMode=t.alphaMode||"OPAQUE"}return n}_getTexture(e){const n=e.extensions,t=e.index;if(!u$3(t))return null;n&&n.KHR_texture_transform&&(e.KHR_texture_transform=n.KHR_texture_transform);const r=this._textureMap[t];return r.texInfo=e,r}_toTexture(e){if(!e)return this._emptyTexture;const n=e.sampler||{};return new en$5({width:e.image.width,height:e.image.height,data:e.image.array,mag:se$5(n.magFilter)||"linear",min:le$5(n.minFilter)||"linear",wrapS:de$5(n.wrapS)||"repeat",wrapT:de$5(n.wrapT)||"repeat"})}}function Ot$6(e,n){return e[0]-n[0]}function Et$6(e,n){return Math.abs(n[1])-Math.abs(e[1])}function Pt$6(n){const t=n.lastIndexOf("/"),r=n.slice(0,t),i=n.slice(n.lastIndexOf(".")).toLowerCase();return".gltf"===i?function(n,t){return w$5.getJSON(n,{})}(n).then((e=>wt$6(r,e))):".glb"===i?function(n,t){return w$5.getArrayBuffer(n,{})}(n).then((e=>wt$6(r,{buffer:e.data,byteOffset:0}))):null}function It$6(e,n){return new Ct$6(e,n)}function wt$6(n,t){return new X$8(n,t).load()}var Dt$6=Object.freeze({__proto__:null,load:Pt$6,exportGLTFPack:It$6,loadGLTF:wt$6});const Rt$6=[-1,0,-1,1,0,-1,-1,0,1,1,0,1],Ft$6=[3,1,0,0,2,3],Ht$5=[0,0,1,0,0,1,1,1],Lt$6={vertices:[-.8111000061035156,2.0102999210357666,-.8111000061035156,0,.010300000198185444,-0,-.8111000061035156,2.0102999210357666,.8111000061035156,-.8111000061035156,2.0102999210357666,.8111000061035156,0,.010300000198185444,-0,.8111000061035156,2.0102999210357666,.8111000061035156,.8111000061035156,2.0102999210357666,.8111000061035156,0,.010300000198185444,-0,.8111000061035156,2.0102999210357666,-.8111000061035156,.8111000061035156,2.0102999210357666,-.8111000061035156,0,.010300000198185444,-0,-.8111000061035156,2.0102999210357666,-.8111000061035156,.8111000061035156,2.0102999210357666,-.8111000061035156,-.8111000061035156,2.0102999210357666,-.8111000061035156,0,2.9419000148773193,-0,.8111000061035156,2.0102999210357666,.8111000061035156,.8111000061035156,2.0102999210357666,-.8111000061035156,0,2.9419000148773193,-0,-.8111000061035156,2.0102999210357666,-.8111000061035156,-.8111000061035156,2.0102999210357666,.8111000061035156,0,2.9419000148773193,-0,-.8111000061035156,2.0102999210357666,.8111000061035156,.8111000061035156,2.0102999210357666,.8111000061035156,0,2.9419000148773193,-0],normals:[-.9267006516456604,-.3758002817630768,-0,-.9267006516456604,-.3758002817630768,-0,-.9267006516456604,-.3758002817630768,-0,0,-.3758002817630768,.9267006516456604,0,-.3758002817630768,.9267006516456604,0,-.3758002817630768,.9267006516456604,.9267006516456604,-.3758002817630768,-0,.9267006516456604,-.3758002817630768,-0,.9267006516456604,-.3758002817630768,-0,0,-.3758002817630768,-.9267006516456604,0,-.3758002817630768,-.9267006516456604,0,-.3758002817630768,-.9267006516456604,0,.656676173210144,-.7541726231575012,0,.656676173210144,-.7541726231575012,0,.656676173210144,-.7541726231575012,.7541726231575012,.656676173210144,-0,.7541726231575012,.656676173210144,-0,.7541726231575012,.656676173210144,-0,-.7541726231575012,.656676173210144,-0,-.7541726231575012,.656676173210144,-0,-.7541726231575012,.656676173210144,-0,0,.656676173210144,.7541726231575012,0,.656676173210144,.7541726231575012,0,.656676173210144,.7541726231575012],indices:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]},zt$5=["cube","plane","pyramid"],kt$6={cube:{meshes:[{primitives:[{attributes:{POSITION:{array:new Int8Array([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1])},NORMAL:{array:new Int8Array([0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1])},TEXCOORD_0:{array:new Int8Array([0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1,0,0,1,0,0,1,1,1])}},indices:new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),mode:4}]}],scenes:[{nodes:[{mesh:0,scale:[60,60,60]}]}]},"plane-cube":{meshes:[{primitives:[{attributes:{POSITION:{array:new Int8Array(Rt$6)},TEXCOORD_0:{array:new Int8Array(Ht$5)}},indices:new Uint16Array(Ft$6),mode:4}]}],scenes:[{nodes:[{mesh:0,scale:[60,60,60],translation:[0,-60,0]},{mesh:0,scale:[60,60,60],translation:[0,60,0]},{mesh:0,scale:[60,60,60],translation:[60,0,0],rotation:[0,0,.7071067811865475,.7071067811865476]},{mesh:0,scale:[60,60,60],translation:[-60,0,0],rotation:[0,0,.7071067811865475,.7071067811865476]},{mesh:0,scale:[60,60,60],translation:[0,0,60],rotation:[.7071067811865475,0,0,.7071067811865476]},{mesh:0,scale:[60,60,60],translation:[0,0,-60],rotation:[.7071067811865475,0,0,.7071067811865476]}]}]},plane:{meshes:[{primitives:[{attributes:{POSITION:{array:new Int8Array(Rt$6)},NORMAL:{array:new Int8Array([0,1,0,0,1,0,0,1,0,0,1,0])},TEXCOORD_0:{array:new Int8Array(Ht$5)}},indices:new Uint16Array(Ft$6),mode:4}]}],scenes:[{nodes:[{mesh:0,scale:[60,60,60]}]}]},pyramid:{meshes:[{primitives:[{attributes:{POSITION:{array:new Float32Array(Lt$6.vertices)},NORMAL:{array:new Float32Array(Lt$6.normals)},TEXCOORD_0:{array:new Float32Array(Lt$6.uv)}},indices:new Uint16Array(Lt$6.indices),mode:4}]}],scenes:[{nodes:[{mesh:0,scale:[60,60,60]}]}]}};class Bt$6{constructor(e){this.regl=e,this.resourceMap={}}getGLTF(e){return this.resourceMap[e]}loginGLTF(e,n){if(this.resourceMap[e])this.resourceMap[e].refCount+=1;else{if(kt$6[e]){const n=function(e){let n=null;return kt$6[e]&&(n={meshes:kt$6[e].meshes},n.scenes=JSON.parse(JSON.stringify(kt$6[e].scenes))),n}(e);this.resourceMap[e]=this._exportGLTFResource(n,e,!1)}else this.resourceMap[e]=n?n(e).then((n=>{const t=this._exportGLTFResource(n,e);return this.resourceMap[e]=t,t})):this._loadGLTFModel(e);this.resourceMap[e].refCount=1}}logoutGLTF(e){if(this.resourceMap[e]&&(this.resourceMap[e].refCount-=1,this.resourceMap[e].refCount<1)){const n=this.resourceMap[e].resources;if(n)for(let e=0;e<n.length;e++)n[e].geometry.dispose(),n[e].copyGeometry&&n[e].copyGeometry.dispose(),n[e].material&&n[e].material.dispose();this.resourceMap[e].gltfPack&&this.resourceMap[e].gltfPack.dispose(),delete this.resourceMap[e]}}isSimpleModel(e){return kt$6[e]}addSimpleModel(e,n){!function(e,n){"string"==typeof e&&zt$5.indexOf(e)<0&&(kt$6[e]=n)}(e,n)}removeSimpleModel(e){delete kt$6[e]}_exportGLTFResource(e,n,t=!0){if(!e)return null;const r=It$6(e,t?this.regl:null),i=r.getMeshesInfo();return{bbox:r.getGLTFBBox(),gltfPack:r,resources:i,json:e.json,refCount:this.resourceMap[n]?this.resourceMap[n].refCount:0}}_loadData(e){return Pt$6(e).then((e=>e))}_loadGLTFModel(e){return this._loadData(e).then((n=>(this.resourceMap[e]=this._exportGLTFResource(n,e),this.resourceMap[e])))}}const Gt$5=function(){const e=[0,0,0],t=90*Math.PI/180,r=[0,0,0,0],i=new Array(16);return function(o,a,s,c,l,f){const d=[lookAt([],e,[1,0,0],f&&f[0]||[0,-1,0]),lookAt([],e,[-1,0,0],f&&f[1]||[0,-1,0]),lookAt([],e,[0,1,0],f&&f[2]||[0,0,1]),lookAt([],e,[0,-1,0],f&&f[3]||[0,0,-1]),lookAt([],e,[0,0,1],f&&f[4]||[0,-1,0]),lookAt([],e,[0,0,-1],f&&f[5]||[0,-1,0])],u={context:{viewMatrix:function(e,n,t){return d[t]},projMatrix:perspective(i,t,1,.5,1.1)}};return a&&(u.framebuffer=a.faces?function(e,n,t){return a.faces[t]}:a),o(u)(6,((e,n,t)=>{const i={color:r,depth:1};a&&(i.framebuffer=a.faces?a.faces[t]:a),o.clear(i),s(c),l&&l()})),a}}();var Ut$5={vertices:[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],textures:[1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,0],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]},Vt$5="#define SHADER_NAME CUBE_MAP\nattribute vec3 aPosition;\nvarying vec3 vWorldPos;\nuniform mat4 projMatrix;\nuniform mat4 viewMatrix;\nvoid main() {\n  vWorldPos = aPosition;\n  gl_Position = projMatrix * viewMatrix * vec4(vWorldPos, 1.);\n}",jt$5="precision highp float;\n#define PI 3.1415926\nvarying vec3 vWorldPos;\nuniform sampler2D equirectangularMap;\nconst vec2 c = vec2(.1591, .3183);\nvec2 d(vec3 e) {\n  vec2 f = vec2(atan(e.y, e.x), asin(e.z));\n  f *= c;\n  f += .5;\n  return f;\n}\nvec3 h(const in vec4 i, const in float j) {\n  return j * i.rgb * i.a;\n}\nvec4 k(const in vec3 i, const in float j) {\n  vec4 l;\n  vec3 m = i / j;\n  l.a = clamp(max(max(m.r, m.g), max(m.b, 1e-6)), .0, 1.);\n  l.a = ceil(l.a * 255.) / 255.;\n  l.rgb = m / l.a;\n  return l;\n}\nvoid main() {\n  vec2 f = d(normalize(vWorldPos));\n  vec4 i = texture2D(equirectangularMap, f);\n#ifdef INPUT_RGBM\ngl_FragColor = i;\n#else\ngl_FragColor = vec4(h(i, 7.), 1.);\n#endif\n}";
/*!
	 * from claygl
	 * https://github.com/pissang/claygl/
	 * License: BSD-2-Clause
	 */function Xt$5(e,n){const t=e[0],r=e[1],i=e[2];return 0===n?1:1===n?t:2===n?r:3===n?i:4===n?t*i:5===n?r*i:6===n?t*r:7===n?3*i*i-1:t*t-r*r}const Wt$5={px:[2,1,0,-1,-1,1],nx:[2,1,0,1,-1,-1],py:[0,2,1,1,-1,-1],ny:[0,2,1,1,1,1],pz:[0,1,2,-1,-1,-1],nz:[0,1,2,1,-1,1]},Kt$5=["px","nx","py","ny","pz","nz"],qt$5=on$5.compile(Kn$4);function Yt$5(e,n,t){const r=e({frag:qt$5,vert:Vt$5,attributes:{aPosition:Ut$5.vertices},uniforms:{projMatrix:e.context("projMatrix"),viewMatrix:e.context("viewMatrix"),cubeMap:n,environmentExposure:1,bias:0,size:t,hsv:[0,0,0]},elements:Ut$5.indices}),i=[],o=e.framebuffer(t);return Gt$5(e,o,r,{size:t},(function(){const n=e.read();i.push(new n.constructor(n))})),r.destroy(),o.destroy(),i}const Jt$5=new Int8Array([-1,1,0,-1,-1,0,1,1,0,1,-1,0]),Zt$5=new Int8Array([0,1,0,0,1,1,1,0]);function Qt$5(e,n,t,r){n=n||256;const i=$t$5(t=t||1024,r=r||256),o=e.texture({data:i,width:r,height:t,min:"nearest",mag:"nearest"}),a=e.buffer(Jt$5),s=e.buffer(Zt$5),c=e.framebuffer({radius:n,colorType:"uint8",colorFormat:"rgba",min:"linear",mag:"linear"}),l=e({frag:"precision highp float;\nvarying vec2 vTexCoords;\nuniform sampler2D distributionMap;\nconst float c = 3.14159265359;\nvec4 d(float a, float b) {\n  a *= 65535.;\n  b *= 65535.;\n  vec4 rgba;\n  rgba[0] = mod(a, 255.);\n  rgba[1] = (a - rgba[0]) / 65280.0;\n  rgba[2] = mod(b, 255.);\n  rgba[3] = (b - rgba[2]) / 65280.0;\n  return rgba;\n}\nvec3 e(float f, vec3 h, float i) {\n  vec4 j = texture2D(distributionMap, vec2(i, f));\n  vec3 k = j.xyz;\n  float l = sign(j.w - .5);\n  float m = sign(j.w - clamp(l, .0, 1.) * 200.0 / 255. - .15);\n  k.x *= l;\n  k.y *= m;\n  vec3 n = abs(h.z) < .999 ? vec3(.0, .0, 1.) : vec3(1., .0, .0);\n  vec3 o = normalize(cross(n, h));\n  vec3 u = cross(h, o);\n  vec3 v = o * k.x + u * k.y + h * k.z;\n  return normalize(v);\n}\nfloat A(float B, float i) {\n  float a = i;\n  float C = (a * a) / 2.;\n  float D = B;\n  float E = B * (1. - C) + C;\n  return D / E;\n}\nfloat F(float B, float G, float i) {\n  float I = A(B, i);\n  float J = A(G, i);\n  return J * I;\n}\nvec2 K(float B, float i) {\n  vec3 L;\n  L.x = sqrt(1. - B * B);\n  L.y = .0;\n  L.z = B;\n  float M = .0;\n  float O = .0;\n  vec3 h = vec3(.0, .0, 1.);\n  const int P = 1024;\n  for(int Q = 0; Q < P; ++Q) {\n    vec3 k = e(float(Q) / float(P), h, i);\n    vec3 R = normalize(2. * dot(L, k) * k - L);\n    float G = max(R.z, .0);\n    float S = max(k.z, .0);\n    float T = max(dot(L, k), .0);\n    float B = max(dot(h, L), .0);\n    if(G > .0) {\n      float U = F(B, G, i);\n      float W = (U * T) / (S * B);\n      float X = pow(1. - T, 5.);\n      M += (1. - X) * W;\n      O += X * W;\n    }\n  }\n  M /= float(P);\n  O /= float(P);\n  return vec2(M, O);\n}\nvoid main() {\n  vec2 Y = K(vTexCoords.x, vTexCoords.y);\n  gl_FragColor = d(Y.x, Y.y);\n}",vert:"attribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoords;\nvoid main() {\n  vTexCoords = aTexCoord;\n  gl_Position = vec4(aPosition, 1.);\n}",attributes:{aPosition:{buffer:a},aTexCoord:{buffer:s}},uniforms:{distributionMap:o},framebuffer:c,viewport:{x:0,y:0,width:n,height:n},count:Jt$5.length/3,primitive:"triangle strip"});return l(),l.destroy(),a.destroy(),s.destroy(),o.destroy(),c}function $t$5(e,n){const t=new Array(e*n*4);for(let r=0;r<e;r++){const{x:i,y:o}=er$4(r,e);for(let e=0;e<n;e++){const a=e/n,s=a*a,c=2*Math.PI*i,l=Math.sqrt((1-o)/(1+(s*s-1)*o)),f=Math.sqrt(1-l*l),d=4*(r*n+e),u=f*Math.cos(c),h=f*Math.sin(c);t[d]=Math.abs(255*u),t[d+1]=Math.abs(255*h),t[d+2]=255*l,t[d+3]=(u>0?200:0)+(h>0?55:0)}}return t}function er$4(e,n){let t=(e<<16|e>>>16)>>>0;return t=((1431655765&t)<<1|(2863311530&t)>>>1)>>>0,t=((858993459&t)<<2|(3435973836&t)>>>2)>>>0,t=((252645135&t)<<4|(4042322160&t)>>>4)>>>0,t=(((16711935&t)<<8|(4278255360&t)>>>8)>>>0)/4294967296,{x:e/n,y:t}}var nr$4=Object.freeze({__proto__:null,createIBLMaps:function(e,n={}){const r=n.envTexture,i=n.envCubeSize||512,o=n.sampleSize||1024,a=n.roughnessLevels||256,s=n.prefilterCubeSize||256;let c;if(Array.isArray(r)){const t=e.cube({flipY:!0,faces:r});c=function(e,n,t,r,i){const o=e({frag:"#define ENC_RGBM 1\n"+qt$5,vert:Vt$5,attributes:{aPosition:Ut$5.vertices},uniforms:{hsv:[0,0,0],projMatrix:e.context("projMatrix"),viewMatrix:e.context("viewMatrix"),cubeMap:n,bias:0,size:n.width,environmentExposure:1,rgbmRange:i},elements:Ut$5.indices}),a=e.cube({width:t,height:t,min:"linear",mag:"linear",format:"rgba"}),s=e.framebufferCube({radius:t,color:a});return Gt$5(e,s,o,{size:t},null,[[0,0,-1],[0,0,-1],[0,0,1],[0,0,1],[0,-1,0],[0,-1,0]]),o.destroy(),s}(e,t,i,0,n.rgbmRange),t.destroy()}else c=function(e,n,t,r){t=t||512;const i=e({frag:"#define INPUT_RGBM 1\n"+jt$5,vert:Vt$5,attributes:{aPosition:Ut$5.vertices},uniforms:{projMatrix:e.context("projMatrix"),viewMatrix:e.context("viewMatrix"),equirectangularMap:n},elements:Ut$5.indices}),o=e.cube({width:t,height:t,min:"linear",mag:"linear",format:"rgba"}),a=e.framebufferCube({radius:t,color:o});return Gt$5(e,a,i),i.destroy(),a}(e,r,i);const{prefilterMap:l,prefilterMipmap:f}=function(e,n,t,r,i,o){const a=function(e,n,t,r,i,o){const a=$t$5(i=i||1024,o=o||256),s=e.texture({data:a,width:o,height:i,min:"nearest",mag:"nearest"}),c=e({frag:"#define SHADER_NAME PBR_prefilter\nprecision highp float;\nvarying vec3 vWorldPos;\nuniform samplerCube environmentMap;\nuniform sampler2D distributionMap;\nuniform float roughness;\nuniform float resolution;\nuniform float rgbmRange;\nconst float c = 3.14159265359;\nfloat d(vec3 e, vec3 f, float h) {\n  float a = h * h;\n  float i = a * a;\n  float j = max(dot(e, f), .0);\n  float k = j * j;\n  float l = i;\n  float m = (k * (i - 1.) + 1.);\n  m = c * m * m;\n  return l / m;\n}\nvec3 n(float o, vec3 e, float h) {\n  vec4 u = texture2D(distributionMap, vec2(h, o));\n  vec3 f = u.xyz;\n  float v = sign(u.w - .5);\n  float A = sign(u.w - 200.0 / 255. * clamp(v, .0, 1.) - .15);\n  f.x *= v;\n  f.y *= A;\n  vec3 B = abs(e.z) < .999 ? vec3(.0, .0, 1.) : vec3(1., .0, .0);\n  vec3 C = normalize(cross(B, e));\n  vec3 D = cross(e, C);\n  vec3 E = C * f.x + D * f.y + e * f.z;\n  return normalize(E);\n}\nvec4 F(const in vec3 G, const in float I) {\n  if(I <= .0)\n    return vec4(G, 1.);\n  vec4 J;\n  vec3 K = G / I;\n  J.a = clamp(max(max(K.r, K.g), max(K.b, 1e-6)), .0, 1.);\n  J.a = ceil(J.a * 255.) / 255.;\n  J.rgb = K / J.a;\n  return J;\n}\nvec3 L(const in vec4 G, const in float I) {\n  if(I <= .0)\n    return G.rgb;\n  return I * G.rgb * G.a;\n}\nvoid main() {\n  vec3 e = normalize(vWorldPos);\n  vec3 M = e;\n  vec3 O = M;\n  const int P = 1024;\n  vec3 Q = vec3(.0);\n  float S = .0;\n  for(int T = 0; T < P; ++T) {\n    vec3 f = n(float(T) / float(P), e, roughness);\n    vec3 U = normalize(2. * dot(O, f) * f - O);\n    float W = max(dot(e, U), .0);\n    if(W > .0) {\n      Q += L(textureCube(environmentMap, U), rgbmRange).rgb * W;\n      S += W;\n    }\n  }\n  Q = Q / S;\n  gl_FragColor = F(Q, rgbmRange);\n}",vert:Vt$5,attributes:{aPosition:Ut$5.vertices},uniforms:{projMatrix:e.context("projMatrix"),viewMatrix:e.context("viewMatrix"),environmentMap:n,distributionMap:s,roughness:e.prop("roughness"),resolution:r,rgbmRange:t||7},elements:Ut$5.indices,viewport:{x:0,y:0,width:e.prop("size"),height:e.prop("size")}});let l=r;const f=e.texture({radius:r,min:"linear",mag:"linear"}),d=e.framebuffer({radius:r,color:f}),u=Math.log(l)/Math.log(2),h=[];for(let n=0;n<=u;n++){let t=0;Gt$5(e,d,c,{roughness:n/(u-1),size:l},(function(){const n=e.read({framebuffer:d});h[t]||(h[t]={mipmap:[]}),h[t].mipmap.push(n),t++})),l/=2,d.resize(l)}return s.destroy(),d.destroy(),c.destroy(),h}(e,n,t,r,i,o);return{prefilterMap:e.cube({radius:r,min:"linear mipmap linear",mag:"linear",faces:a}),prefilterMipmap:a}}(e,c,n.rgbmRange,s,o,a);let d;if(!n.ignoreSH){const n=s;d=function(e,n,r){const i=new Array(9),o=[],a=[],s=[];for(let c=0;c<9;c++){const l=[0,0,0];for(let i=0;i<Kt$5.length;i++){const f=e[i],d=[0,0,0];let u=0,h=0;const m=Wt$5[Kt$5[i]];for(let e=0;e<r;e++)for(let i=0;i<n;i++){o[0]=i/(n-1)*2-1,o[1]=e/(r-1)*2-1,o[2]=-1,normalize$4(o,o),s[0]=o[m[0]]*m[3],s[1]=o[m[1]]*m[4],s[2]=o[m[2]]*m[5],a[0]=f[h++]/255,a[1]=f[h++]/255,a[2]=f[h++]/255;const l=f[h++]/255*7;a[0]*=l,a[1]*=l,a[2]*=l,scaleAndAdd$2(d,d,a,Xt$5(s,c)*-o[2]),u+=-o[2]}scaleAndAdd$2(l,l,d,1/u)}i[c]=scale$4(l,l,1/6)}return i}(Yt$5(e,l,n),n,n);const r=[];for(let e=0;e<d.length;e++)r.push(...d[e]);d=r}const u={rgbmRange:n.rgbmRange,envMap:c,prefilterMap:l};return d&&(u.sh=d),"array"===n.format&&(u.envMap={width:c.width,height:c.height,faces:Yt$5(e,c,i)},u.prefilterMap={width:l.width,height:l.height,faces:f},c.destroy(),l.destroy()),u},generateDFGLUT:Qt$5});const tr$4={uvScale:[1,1],uvOffset:[0,0],textureOrigin:null,textureWidth:null,baseColorFactor:[1,1,1,1],emissiveFactor:[0,0,0],baseColorIntensity:1,anisotropyDirection:0,anisotropyFactor:0,clearCoatFactor:0,clearCoatIor:1.4,clearCoatRoughnessFactor:.04,clearCoatThickness:5,emitColorFactor:1,occlusionFactor:1,roughnessFactor:.4,metallicFactor:0,normalMapFactor:1,specularF0:.5,emitMultiplicative:1,normalMapFlipY:0,outputSRGB:1,baseColorTexture:null,normalTexture:null,occlusionTexture:null,metallicRoughnessTexture:null,emissiveTexture:null,uvOrigin:[0,0],noiseTexture:null,clearCoatTint:[.006,.006,.006],specularAAVariance:20,specularAAThreshold:20,hsv:[0,0,0],contrast:1,bumpTexture:null,bumpScale:.05,bumpMinLayers:5,bumpMaxLayers:20,alphaTest:0};class rr$4 extends Ce$5{constructor(e){const n=v$3({},tr$4);(e.metallicRoughnessTexture||e.metallicRoughnessTexture)&&(n.roughnessFactor=1,n.metallicFactor=1),super(e,n)}appendDefines(e,n){super.appendDefines(e,n);const t=this.uniforms;return t.GAMMA_CORRECT_INPUT&&(e.GAMMA_CORRECT_INPUT=1),n.data[n.desc.colorAttribute]&&(e.HAS_COLOR=1),n.data[n.desc.color0Attribute]&&(e.HAS_COLOR0=1,e.COLOR0_SIZE=n.getColor0Size()),n.data[n.desc.tangentAttribute]?e.HAS_TANGENT=1:n.data[n.desc.normalAttribute]&&(e.HAS_NORMAL=1),n.data.aVertexColorType&&(e.HAS_VERTEX_COLOR=1),n.data[n.desc.uv0Attribute]?(t.baseColorTexture&&(e.HAS_ALBEDO_MAP=1),t.metallicRoughnessTexture&&(e.HAS_METALLICROUGHNESS_MAP=1),t.occlusionTexture&&n.data[n.desc.uv1Attribute]&&(e.HAS_AO_MAP=1),t.emissiveTexture&&(e.HAS_EMISSIVE_MAP=1),t.normalTexture&&(e.HAS_NORMAL_MAP=1),t.bumpTexture&&(e.HAS_BUMP_MAP=1),t.skinTexture&&(e.HAS_SKIN_MAP=1),(e.HAS_ALBEDO_MAP||e.HAS_METALLICROUGHNESS_MAP||e.HAS_AO_MAP||e.HAS_EMISSIVE_MAP||e.HAS_NORMAL_MAP||e.HAS_BUMP_MAP||e.HAS_SKIN_MAP)&&(e.HAS_MAP=1),t.noiseTexture&&(e.HAS_RANDOM_TEX=1),n.data[n.desc.tangentAttribute]?e.HAS_TANGENT=1:n.data[n.desc.normalAttribute]&&(e.HAS_NORMAL=1),e):e}}class ir$4 extends(He$5(rr$4)){}function or$4(e,n,t){if(t.ambientUpdate){const{iblTexes:r}=e;if(r){const i=t.target;cr$4(r),e.iblTexes=sr$4(n,i)}else e.iblTexes=sr$4(n,t.target)}}const ar$4=[0,0];function sr$4(e,n){const t=n.getLightManager(),r=t&&t.getAmbientResource();return r?{prefilterMap:e.cube({width:r.prefilterMap.width,height:r.prefilterMap.height,faces:r.prefilterMap.faces,min:"linear mipmap linear",mag:"linear",format:"rgba"}),sh:r.sh,rgbmRange:r.rgbmRange}:null}function cr$4(e){for(const n in e)e[n].destroy&&e[n].destroy(),delete e[n]}var lr$4=Object.freeze({__proto__:null,loginIBLResOnCanvas:function(e,n,t){if(!e.dfgLUT&&(e.dfgLUT=Qt$5(n),e.dfgLUT.mtkRefCount=0,t)){const r=or$4.bind(this,e,n);t.on("updatelights",r),e._iblResListener=r}e.dfgLUT.mtkRefCount++;const r=t.getLightManager();return r&&r.getAmbientResource()?(e.iblTexes||(e.iblTexes=sr$4(n,t)),{dfgLUT:e.dfgLUT,iblTexes:e.iblTexes}):{dfgLUT:e.dfgLUT,iblTexes:null}},getIBLResOnCanvas:function(e){const{dfgLUT:n,iblTexes:t}=e;return{dfgLUT:n,iblTexes:t}},logoutIBLResOnCanvas:function(e,n){let t=!1;e.dfgLUT&&(e.dfgLUT.mtkRefCount--,e.dfgLUT.mtkRefCount<=0)&&(t=!0,n&&n.off("updatelights",e._iblResListener),e.dfgLUT.destroy(),delete e.dfgLUT),e.iblTexes&&t&&(cr$4(e.iblTexes),delete e.iblTexes)},getPBRUniforms:function(e,n,t,r,i){const o=e.viewMatrix,a=e.projMatrix,s=e.cameraPosition,c=e.getRenderer().canvas,l=function(e,n){const t=e.getLightManager(),r=t&&t.getAmbientResource(),i=t&&t.getAmbientLight()||{},o=t&&t.getDirectionalLight()||{};let a;if(r){const e=n.prefilterMap.width,t=Math.log(e)/Math.log(2);a={prefilterMap:n.prefilterMap,diffuseSPH:n.sh,prefilterMiplevel:[t,t],prefilterSize:[e,e],hdrHSV:i.hsv||[0,0,0]}}else a={ambientColor:i.color||[.2,.2,.2]};return a.rgbmRange=r?n.rgbmRange:7,a.environmentExposure=g$1(i.exposure)?i.exposure:1,a.environmentOrientation=i.orientation||0,a.light0_diffuse=[...o.color||[1,1,1],1],a.light0_viewDirection=o.direction||[1,1,-1],a}(e,n),f=v$3({viewMatrix:o,projMatrix:a,projViewMatrix:e.projViewMatrix,cameraPosition:s,outSize:[c.width,c.height],cameraNearFar:[e.cameraNear,e.cameraFar]},l);return f.brdfLUT=t,r&&r.renderUniforms&&v$3(f,r.renderUniforms),f.halton=i||ar$4,f},createIBLTextures:sr$4,disposeIBLTextures:cr$4,isSupported:function(e){return e.hasExtension("EXT_shader_texture_lod")}});class fr$4 extends vn$4{constructor(e){super({vert:"attribute vec3 aPosition;\nuniform mat4 lightProjViewModelMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\nvarying vec4 vPosition;\nvoid main() {\n  mat4 c = getPositionMatrix();\n#ifdef IS_LINE_EXTRUSION\nvec3 d = getLineExtrudePosition(aPosition);\n  vec4 e = getPosition(d);\n#else\nvec4 e = getPosition(aPosition);\n#endif\ngl_Position = lightProjViewModelMatrix * c * e;\n  vPosition = gl_Position;\n}",frag:"#define SHADER_NAME vsm_mapping\n#ifdef USE_VSM\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nvarying vec4 vPosition;\n#ifdef PACK_FLOAT\n#include <common_pack_float>\n#endif\nvoid main() {\n  \n#if defined(USE_VSM)\nfloat c = vPosition.z / vPosition.w;\n  c = c * .5 + .5;\n  float d = c;\n  float e = c * c;\n  float f = dFdx(c);\n  float h = dFdy(c);\n  e += .25 * (f * f + h * h);\n  gl_FragColor = vec4(d, e, c, .0);\n#endif\n#if defined(USE_ESM)\n#ifdef PACK_FLOAT\ngl_FragColor = common_encodeDepth(gl_FragCoord.z);\n#else\ngl_FragColor = vec4(gl_FragCoord.z, .0, .0, 1.);\n#endif\n#endif\n}",uniforms:[{name:"lightProjViewModelMatrix",type:"function",fn:function(e,t){return multiply$5([],t.lightProjViewMatrix,t.modelMatrix)}}],extraCommandProps:{},defines:e})}filter(e){return e.castShadow}}class dr$4 extends Mn$4{constructor({blurOffset:e}){super({vert:An$4,frag:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D textureSource;\nuniform vec2 resolution;\n#include <common_pack_float>\nvoid main() {\n  float c = .0;\n  float d = .0;\n  for(int x = -BOXBLUR_OFFSET; x <= BOXBLUR_OFFSET; ++x)\n    for(int y = -BOXBLUR_OFFSET; y <= BOXBLUR_OFFSET; ++y) {\n      vec2 e = vTexCoord.st + vec2(float(x) / resolution.x, float(y) / resolution.y);\n      e = clamp(e, .0, 1.);\n      float f = common_decodeDepth(texture2D(textureSource, e));\n      float s = max(.0, sign(1. - f));\n      d += sign(f) * s;\n      c += f;\n    }\n  float h = c / max(1., d);\n  gl_FragColor = common_encodeDepth(h);\n}",defines:{BOXBLUR_OFFSET:e||2}}),this._blurOffset=e||2}getMeshCommand(e,n){const t="box_shadow_blur_"+this._blurOffset;return this.commands[t]||(this.commands[t]=this.createREGLCommand(e,null,n.getElements())),this.commands[t]}}let ur$4=null,hr$4=null;class mr$4{constructor(e,{width:n,height:t,blurOffset:r,defines:i}){this.renderer=e,this.width=n||512,this.height=t||512,this.blurOffset=d$2(r)?2:r,this._init(i)}render(e,{cameraProjViewMatrix:n,lightDir:t,farPlane:r,cameraLookAt:i}){return{lightProjViewMatrix:this._renderShadow(e,n,t,r,i),shadowMap:this.blurTex||this.depthTex,depthFBO:this.depthFBO,blurFBO:this.blurFBO}}resize(e,n){return this.depthTex&&(this.depthTex.resize(e,n),this.depthFBO.resize(e,n)),this.blurFBO&&(this.blurTex.resize(e,n),this.blurFBO.resize(e,n)),this}_renderShadow(e,n,t,r,i){const o=this.renderer,a=ur$4(n);if(r)for(let e=4;e<8;e++)a[e]=r[e-4];const s=hr$4(i,a,t);return o.clear({color:[1,0,0,1],depth:1,framebuffer:this.depthFBO}),o.render(this.shadowMapShader,{lightProjViewMatrix:s},e,this.depthFBO),this.blurFBO&&(this.boxBlurShader||(this.boxBlurShader=new dr$4({blurOffset:this.blurOffset})),o.clear({color:[1,0,0,1],depth:1,framebuffer:this.blurFBO}),o.render(this.boxBlurShader,{resolution:[this.depthTex.width,this.depthTex.height],textureSource:this.depthTex},null,this.blurFBO)),s}_init(e){const n=this.renderer.regl,t=this.width,r=this.height;this.depthTex=n.texture({width:t,height:r,format:"rgb",type:"uint8",min:"nearest",mag:"nearest"}),this.shadowMapShader=new fr$4(e),this.shadowMapShader.filter=e=>e.castShadow,this.depthFBO=n.framebuffer({color:this.depthTex}),this.blurOffset<=0||(this.blurTex=n.texture({width:t,height:r,format:"rgb",type:"uint8",min:"linear",mag:"linear"}),this.blurFBO=n.framebuffer({color:this.blurTex}))}dispose(){this.depthTex&&(this.depthTex.destroy(),this.depthFBO.destroy(),delete this.depthTex,delete this.depthFBO),this.blurTex&&(this.blurTex.destroy(),this.blurFBO.destroy(),delete this.blurTex,delete this.blurFBO),this.shadowMapShader&&(this.shadowMapShader.dispose(),delete this.shadowMapShader),this.boxBlurShader&&(this.boxBlurShader.dispose(),delete this.boxBlurShader)}}ur$4=function(){const e=[[-1,-1,-1,1],[1,-1,-1,1],[1,1,-1,1],[-1,1,-1,1],[-1,-1,1,1],[1,-1,1,1],[1,1,1,1],[-1,1,1,1]],t=new Array(16);return function(i){invert$2(t,i);const o=[];for(let n=0;n<e.length;n++){const i=transformMat4$1([],e[n],t);scale$3(i,i,1/i[3]),o.push(i)}return o}}(),hr$4=function(){let e=new Array(4);const i=new Array(3),o=[0,0,0,0],a=[0,1,0],s=new Array(3);let c=new Array(16),l=new Array(16);const f=new Array(16),d=[1,1,1],u=[0,0,0];return function(h,m,v){set$3(o,...h,1),scale$4(i,v,-1),c=lookAt(c,add$4(s,o,normalize$4(s,i)),o,a),transformMat4$1(e,m[0],c);let _=e[2],g=e[2],x=e[0],b=e[0],p=e[1],y=e[1];for(let n=1;n<8;n++)e=transformMat4$1(e,m[n],c),e[2]>g&&(g=e[2]),e[2]<_&&(_=e[2]),e[0]>b&&(b=e[0]),e[0]<x&&(x=e[0]),e[1]>y&&(y=e[1]),e[1]<p&&(p=e[1]);l=ortho(l,-1,1,-1,1,-g,-_);const A=d[0]=2/(b-x),S=d[1]=-2/(y-p);u[0]=-.5*(x+b)*A,u[1]=-.5*(p+y)*S,identity$2(f),translate$1(f,f,u),scale$5(f,f,d);const T=multiply$5(l,f,l);return multiply$5(new Array(16),T,c)}}();class vr$4 extends vn$4{constructor(e){super({vert:"#define SHADER_NAME SHADOW_DISPLAY\nattribute vec3 aPosition;\nuniform mat4 projMatrix;\nuniform mat4 modelViewMatrix;\nuniform vec2 halton;\nuniform vec2 globalTexSize;\nvarying vec4 vPosition;\n#include <vsm_shadow_vert>\nvoid main() {\n  vec4 c = vec4(aPosition, 1.);\n  vec4 d = modelViewMatrix * c;\n  mat4 e = projMatrix;\n  e[2].xy += halton.xy / globalTexSize.xy;\n  gl_Position = e * d;\n  vPosition = gl_Position;\n  shadow_computeShadowPars(c);\n}",frag:"#define SHADER_NAME SHADOW_DISPLAY\nprecision mediump float;\nuniform vec3 color;\n#include <vsm_shadow_frag>\nvoid main() {\n  float c = shadow_computeShadow();\n  float d = 1. - c;\n  gl_FragColor = vec4(color * d, d);\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(e,t){const r=[];return multiply$5(r,t.viewMatrix,t.modelMatrix),r}}],defines:e||{USE_ESM:1},extraCommandProps:{depth:{enable:!0,mask:!1},viewport:{x:0,y:0,width:(e,n)=>n.globalTexSize[0],height:(e,n)=>n.globalTexSize[1]}}})}getMeshCommand(e,n){return this.commands.shadow_display||(this.commands.shadow_display=this.createREGLCommand(e,null,n.getElements())),this.commands.shadow_display}}function _r$4(e){return 256*e[2]*256+256*e[1]+e[0]}const gr$4=new Uint8Array(4),xr$4=new Float32Array(gr$4.buffer);let br$4,pr$4;const yr$4=[1,1],Ar$4="\n    vec3 unpack(highp float f) {\n        highp vec3 color;\n        color.b = floor(f / 65536.0);\n        color.g = floor((f - color.b * 65536.0) / 256.0);\n        color.r = f - floor(color.b * 65536.0) - floor(color.g * 256.0);\n        // now we have a vec3 with the 3 components in range [0..255]. Let's normalize it!\n        return color / 255.0;\n    }\n",Sr$4=`\n    precision highp float;\n\n    varying float vPickingId;\n    varying float vFbo_picking_visible;\n\n    uniform float fbo_picking_meshId;\n\n    ${Ar$4}\n\n    void main() {\n        if (vFbo_picking_visible == 0.0) {\n            discard;\n            return;\n        }\n        gl_FragColor = vec4(unpack(vPickingId), fbo_picking_meshId / 255.0);\n    }\n`,Tr$4=`\n    precision highp float;\n\n    uniform int fbo_picking_meshId;\n    varying float vFbo_picking_visible;\n\n    ${Ar$4}\n\n    void main() {\n        if (vFbo_picking_visible == 0.0) {\n            discard;\n            return;\n        }\n        gl_FragColor = vec4(unpack(float(fbo_picking_meshId)), 1.0);\n        // gl_FragColor = vec4(unpack(float(35)), 1.0);\n    }\n`,Mr$4=`\n    precision highp float;\n\n    varying float vPickingId;\n    varying float vFbo_picking_visible;\n\n    ${Ar$4}\n\n    void main() {\n        if (vFbo_picking_visible == 0.0) {\n            discard;\n            return;\n        }\n        gl_FragColor = vec4(unpack(vPickingId), 1.0);\n    }\n`;class Cr$4{constructor(e,{vert:n,uniforms:t,defines:r,extraCommandProps:i},o,a){this._renderer=e,this._fbo=o,this._map=a,this._clearFbo(o),this._vert=n,this._uniforms=t,this._defines=r,this._extraCommandProps=v$3({},i),delete this._extraCommandProps.blend,delete this._extraCommandProps.stencil,this._currentMeshes=[],this._init()}_init(){const e=[];this._uniforms&&e.push(...this._uniforms);const n={ENABLE_PICKING:1,HAS_PICKING_ID:1};if(this._defines)for(const e in this._defines)n[e]=this._defines[e];const t=this._vert,r=this._extraCommandProps;this._shader0=new vn$4({vert:t,frag:Sr$4,uniforms:e,defines:n,extraCommandProps:r}),this._shader2=new vn$4({vert:t,frag:Mr$4,uniforms:e,defines:n,extraCommandProps:r});const i={ENABLE_PICKING:1,HAS_PICKING_ID:1};if(this._defines)for(const e in this._defines)i[e]=this._defines[e];this._shader1=new vn$4({vert:t,frag:Tr$4,uniforms:e,defines:i,extraCommandProps:r}),this._depthShader=new vn$4({vert:t,frag:"\n    #ifdef GL_ES\n        precision highp float;\n    #endif\n    #if __VERSION__ == 100 && defined(GL_EXT_frag_depth)\n        #extension GL_EXT_frag_depth : enable\n    #endif\n    #include <gl2_frag>\n    #include <common_pack_float>\n    varying float vFbo_picking_viewZ;\n    uniform float logDepthBufFC;\n    varying float vFbo_picking_fragDepth;\n\n    const float PackUpscale = 256. / 255.;\n    const float UnpackDownscale = 255. / 256.;\n    const vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\n    const vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n    const float ShiftRight8 = 1. / 256.;\n    vec4 packDepthToRGBA(const in float v ) {\n        vec4 r = vec4(fract(v * PackFactors), v);\n        r.yzw -= r.xyz * ShiftRight8;\n        return r * PackUpscale;\n    }\n\n    void main() {\n        float fragDepth = vFbo_picking_fragDepth > 1.0 ? vFbo_picking_fragDepth : vFbo_picking_viewZ + 1.0;\n        #if __VERSION__ == 300 || __VERSION__ == 100 && defined(GL_EXT_frag_depth)\n            gl_FragDepthEXT = log2(fragDepth) * logDepthBufFC * 0.5;\n        #endif\n        vec4 depthColor = packDepthToRGBA(fragDepth - 1.0);\n        glFragColor = common_unpackFloat(dot(depthColor, UnpackFactors));\n        #if __VERSION__ == 100\n            gl_FragColor = glFragColor;\n        #endif\n    }\n",uniforms:e,defines:i,extraCommandProps:r}),this._scene=new Ke$5,this._scene1=new Ke$5}filter(){return!0}render(e,n,t=!1){if(!e||!e.length)return this;const r=this._fbo;t&&this.clear(),e=e.filter((e=>e&&e.isValid())),this._scene.setMeshes(e);const i=this._getShader(e,t);i.filter=this.filter,this._currentShader&&i!==this._currentShader&&this.clear(),this._currentShader=i,e.forEach(((e,n)=>{e.setUniform("fbo_picking_meshId",n+this._currentMeshes.length)}));for(let n=0;n<e.length;n++)this._currentMeshes.push(e[n]);return this._renderer.render(i,n,this._scene,r),this}pickAll(e,n,t,r,i){t=Er$4(t);const{meshIds:o,pickingIds:a,coords:s,points:c}=this._pick(e,n,t,r,i),l=[];if(a&&o){const e={};for(let n=0;n<o.length;n++){const t=`${a[n]}_${o[n]}`;null==o[n]||null==a[n]||e[t]||(e[t]=!0,l.push({meshId:o[n],pickingId:a[n],point:c[n]||null,coordinate:s[n]||null}))}}return l}pick(e,n,t,r,i={}){t=Er$4(t);const{meshIds:o,pickingIds:a,width:s,coords:c,points:l}=this._pick(e,n,t,r,i);if(a&&o){const e=[];for(let n=0;n<=t[0];n++)e.push(n),n>0&&e.push(-n);for(let n=0;n<e.length;n++)for(let r=0;r<e.length;r++){const i=(e[r]+t[1])*s+(e[n]+t[0]);if(null!=o[i]&&null!=a[i])return{meshId:o[i],pickingId:a[i],point:l[i]||null,coordinate:c[i]||null}}}return{pickingId:null,meshId:null,point:null}}_pick(e,n,t,r,i={}){const o=this._currentShader,a=this._currentMeshes;if(!o||!a||!a.length)return{pickingId:null,meshId:null,point:null};e=Math.round(e),n=Math.round(n);const s=this._fbo;if(e<=2||e>=s.width-2||n<=2||n>=s.height-2)return{pickingId:null,meshId:null,point:null};const{px:c,py:l,width:f,height:d}=this._getParams(e,n,t,s),u=new Uint8Array(4*f*d),h=this._renderer.regl.read({data:u,x:c,y:l,framebuffer:s,width:f,height:d}),m=[];let v=[];for(let e=0;e<h.length;e+=4){const{pickingId:n,meshId:t}=this._packData(h.subarray(e,e+4),o);m.push(t),v.push(n)}const _={},g=m.filter((e=>null!=e&&!_[e]&&(_[e]=1,!0))).map((e=>a[e]));let x;for(let e=0;e<g.length;e++)if(g[e]&&g[e].geometry){x=g[e];break}if(!x)return{pickingId:null,meshId:null,point:null};const b=x.geometry.desc.pickingIdAttribute;m.length&&o===this._shader1&&(void 0!==x.getUniform("uPickingId")||x.geometry.data[b])&&(v=this._getPickingId(c,l,f,d,u,g,r));const p=[],y=[];if(m.length&&i.returnPoint){const{viewMatrix:t,projMatrix:o}=i,a=this._pickDepth(c,l,f,d,u,g,r);for(let r=0;r<a.length;r++)if(a[r]&&null!=m[r]&&null!=v[r]){const i=this._getWorldPos(e,n,a[r],t,o),s=this._convertPickPoint(i);p.push(i),y.push(s)}else p.push(null),y.push(null)}return{meshIds:m,pickingIds:v,coords:y,points:p,width:f,height:d}}_convertPickPoint(e){const n=this._map;if(!n)return null;const t=n.getGLRes();if(!br$4){const e=n.getCenter();pr$4=new e.constructor(0,0,0);const t=n.coordToPoint(e);br$4=new t.constructor(0,0)}br$4.set(e[0],e[1]);const r=n.pointAtResToCoord(br$4,t,pr$4),i=n.pointAtResToAltitude(e[2],t);return[r.x,r.y,i]}clear(){return this._fbo&&this._clearFbo(this._fbo),this._currentMeshes=[],delete this._currentShader,this}getMeshAt(e){return this._currentMeshes?this._currentMeshes[e]:null}getRenderedMeshes(){return this._currentMeshes}dispose(){this.clear(),this._shader0&&this._shader0.dispose(),this._shader1&&this._shader1.dispose(),this._shader2&&this._shader2.dispose(),this._scene&&this._scene.clear(),this._scene1&&this._scene1.clear()}_getWorldPos(e,t,r,i,o){const a=this._fbo,s=[],c=a.width/2||1,l=a.height/2||1,f=[(e-c)/c,(l-t)/l,0,1],d=[(e-c)/c,(l-t)/l,1,1],u=invert$2(s,o),h=[],m=[];Or$4(h,f,u),Or$4(m,d,u);const v=-h[2],_=(r-v)/(-m[2]-v),b=invert$2(s,multiply$5(s,o,i)),p=Or$4(f,f,b),y=Or$4(d,d,b);return[x$6(p[0],y[0],_),x$6(p[1],y[1],_),x$6(p[2],y[2],_)]}_getPickingId(e,n,t,r,i,o,a){const s=this._renderer.regl,c=this._getFBO1();this._clearFbo(c),this._scene1.setMeshes(o),this._renderer.render(this._shader2,a,this._scene1,c);const l=s.read({data:i,x:e,y:n,framebuffer:c,width:t,height:r}),f=[];for(let e=0;e<l.length;e+=4)f.push(_r$4(l.subarray(e,e+4)));return f}_pickDepth(e,n,t,r,i,o,a){const s=this._renderer.regl,c=this._getFBO1();this._scene1.setMeshes(o),this._clearFbo(c),a.logDepthBufFC=2/(Math.log(this._map.cameraFar+1)/Math.LN2),this._renderer.render(this._depthShader,a,this._scene1,c);const l=s.read({data:i,x:e,y:n,framebuffer:c,width:t,height:r}),f=[];for(let e=0;e<l.length;e+=4)f.push((d=l.subarray(e,e+4),gr$4[0]=d[3],gr$4[1]=d[2],gr$4[2]=d[1],gr$4[3]=d[0],xr$4[0]));var d;return f}_packData(e,n){if(255===e[0]&&255===e[1]&&255===e[2]&&255===e[3])return{meshId:null,pickingId:null};let t=null,r=null;return n===this._shader1?r=_r$4(e):n===this._shader0?(r=e[3],t=_r$4(e)):(r=null,t=_r$4(e)),{meshId:r,pickingId:t}}_clearFbo(e){this._renderer.regl.clear({color:[1,1,1,1],depth:1,stencil:0,framebuffer:e})}_getShader(e,n){return n&&e.length<256?this._shader0:this._shader1}_getFBO1(){const e=this._renderer.regl,n=this._fbo;return this._fbo1?this._fbo1.width===n.width&&this._fbo1.height===n.height||this._fbo1.resize(n.width,n.height):this._fbo1=e.framebuffer(n.width,n.height),this._fbo1}_getParams(e,n,t,r){const i=t[0],o=t[1];n=r.height-n;let a=2*i+1,s=2*o+1;const c=(e-=i)+a,l=(n-=o)+s;return c>r.width&&(a-=c-r.width),l>r.height&&(s-=l-r.height),{px:e=e<0?0:e,py:n=n<0?0:n,width:a,height:s}}getPickingVert(){return this._vert}getUniformDeclares(){return this._uniforms}}function Or$4(e,n,t){const r=n[0],i=n[1],o=n[2],a=1/(t[3]*r+t[7]*i+t[11]*o+t[15]);return e[0]=(t[0]*r+t[4]*i+t[8]*o+t[12])*a,e[1]=(t[1]*r+t[5]*i+t[9]*o+t[13])*a,e[2]=(t[2]*r+t[6]*i+t[10]*o+t[14])*a,e}function Er$4(e){return g$1(e)&&(yr$4[0]=yr$4[1]=e,e=yr$4),e}const Pr$4=e=>e&&e.geometry&&void 0===e.geometry.properties.shaderHash,Ir$4=[],wr$4=[],Dr$4=[{name:"modelViewMatrix",type:"function",fn:(e,t)=>multiply$5(Ir$4,t.viewMatrix,t.modelMatrix)},{name:"modelViewProjMatrix",type:"function",fn:(e,t)=>{const r=multiply$5(Ir$4,t.viewMatrix,t.modelMatrix);return multiply$5(Ir$4,t.projMatrix,r)}},{name:"modelMatrixInverse",type:"function",fn:(e,t)=>invert$2(Ir$4,t.modelMatrix)},{name:"projMatrixInverse",type:"function",fn:(e,t)=>invert$2(Ir$4,t.projMatrix)},{name:"modelViewMatrixInverse",type:"function",fn:(e,t)=>(multiply$5(Ir$4,t.viewMatrix,t.modelMatrix),invert$2(Ir$4,Ir$4))},{name:"modelViewProjMatrixInverse",type:"function",fn:(e,t)=>{const r=multiply$5(Ir$4,t.viewMatrix,t.modelMatrix);return multiply$5(Ir$4,t.projMatrix,r),invert$2(Ir$4,Ir$4)}},{name:"modelInverseTransposeMatrix",type:"function",fn:(e,n)=>{const t=fromMat4$1(wr$4,n.modelMatrix),r=transpose$1(t,t);return invert$3(r,r)}},{name:"modelViewInverseTransposeMatrix",type:"function",fn:(e,t)=>{const r=multiply$5(Ir$4,t.viewMatrix,t.modelMatrix),o=fromMat4$1(wr$4,r),a=transpose$1(o,o);return invert$3(a,a)}}],Rr$4={LOCAL:"positionMatrix",MODEL:"modelMatrix",VIEW:"viewMatrix",PROJECTION:"projMatrix",MODELVIEW:"modelViewMatrix",MODELVIEWPROJECTION:"modelViewProjMatrix",MODELINVERSE:"modelMatrixInverse",VIEWINVERSE:"viewMatrixInverse",PROJECTIONINVERSE:"projMatrixInverse",MODELVIEWINVERSE:"modelViewMatrixInverse",MODELVIEWPROJECTIONINVERSE:"modelViewProjMatrixInverse",MODELINVERSETRANSPOSE:"modelInverseTransposeMatrix",MODELVIEWINVERSETRANSPOSE:"modelViewInverseTransposeMatrix",VIEWPORT:"viewport",JOINTMATRIX:"jointMatrix",ALPHACUTOFF:"alphaCutoff"};class Nr$4{constructor(e,n,t){this._regl=e,this._khrShaders={},this._commandProps=n,this._resLoader=t}getExcludeFilter(){return Pr$4}forEachShader(e){for(const n in this._khrShaders){const t=this._khrShaders[n];e(t.shader,t.filter,t.uniformSemantics)}}createMesh(e,n,t,r){const i=n.extensions.KHR_techniques_webgl,o=n.materials[e.material].extensions.KHR_techniques_webgl,{technique:a,values:s}=o,c=i.techniques[a],l=i.programs[c.program],f=i.shaders[l.vertexShader],d=i.shaders[l.fragmentShader];d.content=function(e){return e&&e.indexOf("precision")<0?"precision mediump float;\n"+e:e}(d.content);const u=I$5(f.content)+"-"+I$5(d.content);this._khrShaders[u]||(this._khrShaders[u]=this._createTechniqueShader(u,i,a,this._commandProps,r));const{attributeSemantics:h}=this._khrShaders[u],m=this._createGeometry(e,h,t,u),_=v$3({},s);for(const e in s)c.uniforms[e]&&35678===c.uniforms[e].type&&(_[e]=this._getTexture(n.textures[s[e].index]));return{geometry:m,material:new Ce$5(_)}}_createGeometry(e,n,t,r){const i=e.attributes;if(i.COLOR_0){const e=i.COLOR_0.array||i.COLOR_0;if(e instanceof Float32Array){const n=new Uint8Array(e.length);for(let t=0;t<n.length;t++)n[t]=Math.round(255*e[t]);i.COLOR_0.array?(i.COLOR_0.array=n,i.COLOR_0.componentType=5121):i.COLOR_0=n}}const o={};for(const e in i){const t=me$5(this._regl,i[e],{dimension:i[e].itemSize}),r=n[e]||e;o[r]={buffer:t},i[e].quantization&&(o[r].quantization=i[e].quantization),r===n.POSITION&&(o[r].array=i[e].array)}const a=new Q$7(o,e.indices.array?e.indices.array:e.indices,0,{positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,textureCoordMatrixAttribute:n.TextureCoordMatrix,primitive:void 0===e.mode?"triangles":ne$5(e.mode)});a.generateBuffers(this._regl,{excludeElementsInVAO:t}),a.properties.shaderHash=r;const s=a.data[a.desc.positionAttribute];return s&&s.array&&delete s.array,a}_getTexture(e){const n={type:e.type?re$5(e.type):"uint8",format:e.format?oe$5(e.format):"rgba",flipY:!!e.flipY},t=e.image;t.array?n.data=t.array:t.mipmap&&(n.mipmap=t.mipmap),n.width=t.width,n.height=t.height;const r=e.sampler||e.texture.sampler;return r&&(r.magFilter&&(n.mag=se$5(r.magFilter)),r.minFilter&&(n.min=le$5(r.minFilter)),r.wrapS&&(n.wrapS=de$5(r.wrapS)),r.wrapT&&(n.wrapT=de$5(r.wrapT))),new en$5(n,this._resLoader)}_createTechniqueShader(e,n,t,r,i){const{techniques:o,programs:a,shaders:s}=n,c=o[t],l=a[c.program],f=s[l.vertexShader].content,d=s[l.fragmentShader].content,u={};for(const e in c.uniforms){const n=c.uniforms[e];n.semantic&&(u[n.semantic]=e)}const h=Dr$4.slice();for(const e in u)h.push({name:u[e],type:"function",fn:(n,t)=>t[Rr$4[e]]});const m=new vn$4({vert:f,frag:d,uniforms:h,extraCommandProps:r});i&&(m.version=300);const v={};for(const e in c.attributes)v[c.attributes[e].semantic]=e;return{shader:m,filter:n=>n&&n.geometry&&n.geometry.properties.shaderHash===e,uniformSemantics:u,attributeSemantics:v}}dispose(){for(const e in this._khrShaders){const{shader:n}=this._khrShaders[e];n.dispose()}this._khrShaders={}}}var Fr$4={exports:{}};function Hr$4(e,n,t){t=t||2;var r,i,o,a,s,c,l,f=n&&n.length,d=f?n[0]*t:e.length,u=Lr$4(e,0,d,t,!0),h=[];if(!u||u.next===u.prev)return h;if(f&&(u=function(e,n,t,r){var i,o,a,s=[];for(i=0,o=n.length;i<o;i++)(a=Lr$4(e,n[i]*r,i<o-1?n[i+1]*r:e.length,r,!1))===a.next&&(a.steiner=!0),s.push(qr$4(a));for(s.sort(jr$4),i=0;i<s.length;i++)t=Xr$4(s[i],t);return t}(e,n,u,t)),e.length>80*t){r=o=e[0],i=a=e[1];for(var m=t;m<d;m+=t)(s=e[m])<r&&(r=s),(c=e[m+1])<i&&(i=c),s>o&&(o=s),c>a&&(a=c);l=0!==(l=Math.max(o-r,a-i))?32767/l:0}return kr$4(u,h,t,r,i,l,0),h}function Lr$4(e,n,t,r,i){var o,a;if(i===si$4(e,n,t,r)>0)for(o=n;o<t;o+=r)a=ii$4(o,e[o],e[o+1],a);else for(o=t-r;o>=n;o-=r)a=ii$4(o,e[o],e[o+1],a);return a&&Qr$4(a,a.next)&&(oi$4(a),a=a.next),a}function zr$4(e,n){if(!e)return e;n||(n=e);var t,r=e;do{if(t=!1,r.steiner||!Qr$4(r,r.next)&&0!==Zr$4(r.prev,r,r.next))r=r.next;else{if(oi$4(r),(r=n=r.prev)===r.next)break;t=!0}}while(t||r!==n);return n}function kr$4(e,n,t,r,i,o,a){if(e){!a&&o&&function(e,n,t,r){var i=e;do{0===i.z&&(i.z=Kr$4(i.x,i.y,n,t,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var n,t,r,i,o,a,s,c,l=1;do{for(t=e,e=null,o=null,a=0;t;){for(a++,r=t,s=0,n=0;n<l&&(s++,r=r.nextZ);n++);for(c=l;s>0||c>0&&r;)0!==s&&(0===c||!r||t.z<=r.z)?(i=t,t=t.nextZ,s--):(i=r,r=r.nextZ,c--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;t=r}o.nextZ=null,l*=2}while(a>1)}(i)}(e,r,i,o);for(var s,c,l=e;e.prev!==e.next;)if(s=e.prev,c=e.next,o?Gr$4(e,r,i,o):Br$4(e))n.push(s.i/t|0),n.push(e.i/t|0),n.push(c.i/t|0),oi$4(e),e=c.next,l=c.next;else if((e=c)===l){a?1===a?kr$4(e=Ur$4(zr$4(e),n,t),n,t,r,i,o,2):2===a&&Vr$4(e,n,t,r,i,o):kr$4(zr$4(e),n,t,r,i,o,1);break}}}function Br$4(e){var n=e.prev,t=e,r=e.next;if(Zr$4(n,t,r)>=0)return!1;for(var i=n.x,o=t.x,a=r.x,s=n.y,c=t.y,l=r.y,f=i<o?i<a?i:a:o<a?o:a,d=s<c?s<l?s:l:c<l?c:l,u=i>o?i>a?i:a:o>a?o:a,h=s>c?s>l?s:l:c>l?c:l,m=r.next;m!==n;){if(m.x>=f&&m.x<=u&&m.y>=d&&m.y<=h&&Yr$4(i,s,o,c,a,l,m.x,m.y)&&Zr$4(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Gr$4(e,n,t,r){var i=e.prev,o=e,a=e.next;if(Zr$4(i,o,a)>=0)return!1;for(var s=i.x,c=o.x,l=a.x,f=i.y,d=o.y,u=a.y,h=s<c?s<l?s:l:c<l?c:l,m=f<d?f<u?f:u:d<u?d:u,v=s>c?s>l?s:l:c>l?c:l,_=f>d?f>u?f:u:d>u?d:u,g=Kr$4(h,m,n,t,r),x=Kr$4(v,_,n,t,r),b=e.prevZ,p=e.nextZ;b&&b.z>=g&&p&&p.z<=x;){if(b.x>=h&&b.x<=v&&b.y>=m&&b.y<=_&&b!==i&&b!==a&&Yr$4(s,f,c,d,l,u,b.x,b.y)&&Zr$4(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,p.x>=h&&p.x<=v&&p.y>=m&&p.y<=_&&p!==i&&p!==a&&Yr$4(s,f,c,d,l,u,p.x,p.y)&&Zr$4(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;b&&b.z>=g;){if(b.x>=h&&b.x<=v&&b.y>=m&&b.y<=_&&b!==i&&b!==a&&Yr$4(s,f,c,d,l,u,b.x,b.y)&&Zr$4(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;p&&p.z<=x;){if(p.x>=h&&p.x<=v&&p.y>=m&&p.y<=_&&p!==i&&p!==a&&Yr$4(s,f,c,d,l,u,p.x,p.y)&&Zr$4(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function Ur$4(e,n,t){var r=e;do{var i=r.prev,o=r.next.next;!Qr$4(i,o)&&$r$4(i,r,r.next,o)&&ti$4(i,o)&&ti$4(o,i)&&(n.push(i.i/t|0),n.push(r.i/t|0),n.push(o.i/t|0),oi$4(r),oi$4(r.next),r=e=o),r=r.next}while(r!==e);return zr$4(r)}function Vr$4(e,n,t,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Jr$4(a,s)){var c=ri$4(a,s);return a=zr$4(a,a.next),c=zr$4(c,c.next),kr$4(a,n,t,r,i,o,0),void kr$4(c,n,t,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function jr$4(e,n){return e.x-n.x}function Xr$4(e,n){var t=function(e,n){var t,r=n,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,t=r.x<r.next.x?r:r.next,s===i))return t}r=r.next}while(r!==n);if(!t)return null;var c,l=t,f=t.x,d=t.y,u=1/0;r=t;do{i>=r.x&&r.x>=f&&i!==r.x&&Yr$4(o<d?i:a,o,f,d,o<d?a:i,o,r.x,r.y)&&(c=Math.abs(o-r.y)/(i-r.x),ti$4(r,e)&&(c<u||c===u&&(r.x>t.x||r.x===t.x&&Wr$4(t,r)))&&(t=r,u=c)),r=r.next}while(r!==l);return t}(e,n);if(!t)return n;var r=ri$4(t,e);return zr$4(r,r.next),zr$4(t,t.next)}function Wr$4(e,n){return Zr$4(e.prev,e,n.prev)<0&&Zr$4(n.next,e,e.next)<0}function Kr$4(e,n,t,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-t)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function qr$4(e){var n=e,t=e;do{(n.x<t.x||n.x===t.x&&n.y<t.y)&&(t=n),n=n.next}while(n!==e);return t}function Yr$4(e,n,t,r,i,o,a,s){return(i-a)*(n-s)>=(e-a)*(o-s)&&(e-a)*(r-s)>=(t-a)*(n-s)&&(t-a)*(o-s)>=(i-a)*(r-s)}function Jr$4(e,n){return e.next.i!==n.i&&e.prev.i!==n.i&&!function(e,n){var t=e;do{if(t.i!==e.i&&t.next.i!==e.i&&t.i!==n.i&&t.next.i!==n.i&&$r$4(t,t.next,e,n))return!0;t=t.next}while(t!==e);return!1}(e,n)&&(ti$4(e,n)&&ti$4(n,e)&&function(e,n){var t=e,r=!1,i=(e.x+n.x)/2,o=(e.y+n.y)/2;do{t.y>o!=t.next.y>o&&t.next.y!==t.y&&i<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next}while(t!==e);return r}(e,n)&&(Zr$4(e.prev,e,n.prev)||Zr$4(e,n.prev,n))||Qr$4(e,n)&&Zr$4(e.prev,e,e.next)>0&&Zr$4(n.prev,n,n.next)>0)}function Zr$4(e,n,t){return(n.y-e.y)*(t.x-n.x)-(n.x-e.x)*(t.y-n.y)}function Qr$4(e,n){return e.x===n.x&&e.y===n.y}function $r$4(e,n,t,r){var i=ni$4(Zr$4(e,n,t)),o=ni$4(Zr$4(e,n,r)),a=ni$4(Zr$4(t,r,e)),s=ni$4(Zr$4(t,r,n));return i!==o&&a!==s||!(0!==i||!ei$4(e,t,n))||!(0!==o||!ei$4(e,r,n))||!(0!==a||!ei$4(t,e,r))||!(0!==s||!ei$4(t,n,r))}function ei$4(e,n,t){return n.x<=Math.max(e.x,t.x)&&n.x>=Math.min(e.x,t.x)&&n.y<=Math.max(e.y,t.y)&&n.y>=Math.min(e.y,t.y)}function ni$4(e){return e>0?1:e<0?-1:0}function ti$4(e,n){return Zr$4(e.prev,e,e.next)<0?Zr$4(e,n,e.next)>=0&&Zr$4(e,e.prev,n)>=0:Zr$4(e,n,e.prev)<0||Zr$4(e,e.next,n)<0}function ri$4(e,n){var t=new ai$4(e.i,e.x,e.y),r=new ai$4(n.i,n.x,n.y),i=e.next,o=n.prev;return e.next=n,n.prev=e,t.next=i,i.prev=t,r.next=t,t.prev=r,o.next=r,r.prev=o,r}function ii$4(e,n,t,r){var i=new ai$4(e,n,t);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function oi$4(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function ai$4(e,n,t){this.i=e,this.x=n,this.y=t,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function si$4(e,n,t,r){for(var i=0,o=n,a=t-r;o<t;o+=r)i+=(e[a]-e[o])*(e[o+1]+e[a+1]),a=o;return i}Fr$4.exports=Hr$4,Fr$4.exports.default=Hr$4,Hr$4.deviation=function(e,n,t,r){var i=n&&n.length,o=Math.abs(si$4(e,0,i?n[0]*t:e.length,t));if(i)for(var a=0,s=n.length;a<s;a++)o-=Math.abs(si$4(e,n[a]*t,a<s-1?n[a+1]*t:e.length,t));var c=0;for(a=0;a<r.length;a+=3){var l=r[a]*t,f=r[a+1]*t,d=r[a+2]*t;c+=Math.abs((e[l]-e[d])*(e[f+1]-e[l+1])-(e[l]-e[f])*(e[d+1]-e[l+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},Hr$4.flatten=function(e){for(var n=e[0][0].length,t={vertices:[],holes:[],dimensions:n},r=0,i=0;i<e.length;i++){for(var o=0;o<e[i].length;o++)for(var a=0;a<n;a++)t.vertices.push(e[i][o][a]);i>0&&t.holes.push(r+=e[i-1].length)}return t};var ci$4=Fr$4.exports;const li$4={parseHDR:$e$5},fi$4={PBRHelper:nr$4,StandardMaterial:rr$4,StandardSpecularGlossinessMaterial:ir$4,StandardShader:class extends vn$4{constructor(e={}){let t=e.extraCommandProps||{};const r=e.uniforms;t=v$3({},t);const o=e.defines||{},a=[],s=[],c=[],l=[],f=[],d=[{name:"modelNormalMatrix",type:"function",fn:(e,n)=>fromMat4$1(a,n.modelMatrix)},{name:"modelViewNormalMatrix",type:"function",fn:(e,t)=>{const r=multiply$5(s,t.viewMatrix,t.modelMatrix),o=invert$2(r,r),a=transpose(o,o);return fromMat4$1(c,a)}},{name:"modelViewMatrix",type:"function",fn:(e,t)=>multiply$5(l,t.viewMatrix,t.modelMatrix)},{name:"uEnvironmentTransform",type:"function",fn:(e,n)=>fromRotation$2(f,Math.PI*(n.environmentOrientation||0)/180)}];r&&d.push(...r),super({vert:e.vert||"#include <gl2_vert>\n#define SHADER_NAME PBR\nprecision highp float;\nattribute vec3 aPosition;\n#if defined(HAS_MAP)\nattribute vec2 aTexCoord;\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\n#ifdef HAS_I3S_UVREGION\nattribute vec4 uvRegion;\nvarying vec4 vUvRegion;\n#endif\n#if defined(HAS_AO_MAP)\nattribute vec2 aTexCoord1;\nvarying vec2 vTexCoord1;\n#endif\n#endif\nvec3 c;\nvec3 d;\nvec4 e;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\nuniform mediump vec3 cameraPosition;\nuniform mat3 modelNormalMatrix;\n#ifdef HAS_SSR\nuniform mat3 modelViewNormalMatrix;\nvarying vec3 vViewNormal;\n#ifdef HAS_TANGENT\nvarying vec4 vViewTangent;\n#endif\n#endif\nvarying vec3 vModelNormal;\nvarying vec4 vViewVertex;\n#if defined(HAS_TANGENT)\nvarying vec4 vModelTangent;\nvarying vec3 vModelBiTangent;\n#endif\nvarying vec3 vModelVertex;\n#if defined(HAS_MAP)\nvarying vec2 vTexCoord;\n#endif\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#ifdef HAS_OPACITY\nattribute float aOpacity;\n#endif\nvarying float vOpacity;\n#include <highlight_vert>\n#if defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nattribute vec3 aColor0;\nvarying vec3 vColor0;\n#else\nattribute vec4 aColor0;\nvarying vec4 vColor0;\n#endif\n#endif\n#include <line_extrusion_vert>\n#include <get_output>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#include <heatmap_render_vert>\n#include <vertex_color_vert>\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nvarying vec3 vTangentViewPos;\nvarying vec3 vTangentFragPos;\n#if __VERSION__ == 100\nmat3 f(in mat3 h) {\n  vec3 i = h[0];\n  vec3 j = h[1];\n  vec3 k = h[2];\n  return mat3(vec3(i.x, j.x, k.x), vec3(i.y, j.y, k.y), vec3(i.z, j.z, k.z));\n}\n#else\nmat3 f(in mat3 h) {\n  return transpose(h);\n}\n#endif\n#endif\nvoid l(const highp vec4 q, out highp vec3 m) {\n  m = vec3(.0, .0, 1.) + vec3(2., -2., -2.) * q.x * q.zwx + vec3(2., 2., -2.) * q.y * q.wzy;\n}\nvoid l(const highp vec4 q, out highp vec3 m, out highp vec3 t) {\n  l(q, m);\n  t = vec3(1., .0, .0) + vec3(-2., 2., -2.) * q.y * q.yxw + vec3(-2., 2., 2.) * q.z * q.zwx;\n}\nconst float o = .5;\nvec2 u(vec2 v, float A) {\n  return vec2(cos(A) * (v.x - o) + sin(A) * (v.y - o) + o, cos(A) * (v.y - o) - sin(A) * (v.x - o) + o);\n}\n#if defined(HAS_MAP)\nvec2 B(vec2 v) {\n  vec2 C = decode_getTexcoord(v);\n  vec2 D = C * uvScale + uvOffset;\n  return D;\n}\n#endif\n#ifdef PICKING_MODE\n#include <fbo_picking_vert>\n#endif\n#include <excavate_vert>\nvoid main() {\n  mat4 E = getPositionMatrix();\n#ifdef IS_LINE_EXTRUSION\nvec3 F = getLineExtrudePosition(aPosition);\n  vec4 G = getPosition(F);\n#else\nvec4 G = getPosition(aPosition);\n#endif\nvModelVertex = (modelMatrix * G).xyz;\n  vec4 H = E * G;\n  vec4 I = modelViewMatrix * H;\n  vViewVertex = I;\n#ifdef HAS_MASK_EXTENT\ngl_Position = projMatrix * getMaskPosition(H, modelMatrix);\n#else\ngl_Position = projMatrix * I;\n#endif\n#ifdef PICKING_MODE\nfloat J = 1.;\n#if defined(HAS_COLOR)\nJ *= aColor.a;\n#endif\n#if defined(HAS_COLOR0) && COLOR0_SIZE == 4\nJ *= aColor0.a;\n#endif\nfbo_picking_setData(gl_Position.w, J != .0);\n#else\n#if defined(HAS_MAP)\nvTexCoord = B(aTexCoord);\n#ifdef HAS_AO_MAP\nvTexCoord1 = B(aTexCoord1);\n#endif\n#ifdef HAS_I3S_UVREGION\nvUvRegion = uvRegion / 65535.;\n#endif\n#endif\n#if defined(HAS_TANGENT) || defined(HAS_NORMAL)\nmat3 K = mat3(E);\n  mat3 L = modelNormalMatrix * K;\n#if defined(HAS_TANGENT)\nvec3 t;\n  l(aTangent, d, t);\n  vModelTangent = vec4(L * t, aTangent.w);\n#else\nd = decode_getNormal(aNormal);\n#endif\nvec3 M = d;\n  vModelNormal = L * M;\n#else\nd = vec3(.0);\n  vModelNormal = vec3(.0);\n#endif\n#if defined(HAS_TANGENT)\nvModelBiTangent = cross(vModelNormal, vModelTangent.xyz) * sign(aTangent.w);\n#endif\n#ifdef HAS_SSR\nmat3 N = modelViewNormalMatrix * K;\n  vViewNormal = N * d;\n#if defined(HAS_TANGENT)\nvec4 O = vec4(t, aTangent.w);\n  vViewTangent = vec4(N * O.xyz, O.w);\n#endif\n#endif\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\nhighlight_setVarying();\n#if defined(HAS_COLOR0)\nvColor0 = aColor0 / 255.;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(H);\n#endif\n#ifdef HAS_HEATMAP\nheatmap_compute(projMatrix * modelViewMatrix * E, G);\n#endif\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nmat3 P = f(mat3(vModelTangent.xyz, vModelBiTangent, vModelNormal));\n  vTangentViewPos = P * cameraPosition;\n  vTangentFragPos = P * vModelVertex;\n#endif\n#ifdef HAS_VERTEX_COLOR\nvertexColor_update();\n#endif\n#ifdef HAS_EXCAVATE_ANALYSIS\nvCoordinateTexcoord = getCoordinateTexcoord();\n  vHeight = getWorldHeight();\n#endif\n#endif\n}",frag:e.frag||"#if __VERSION__ == 100\n#if defined(GL_EXT_shader_texture_lod)\n#extension GL_EXT_shader_texture_lod : enable\n#define textureCubeLod(tex, uv, lod) textureCubeLodEXT(tex, uv, lod)\n#else\n#define textureCubeLod(tex, uv, lod) textureCube(tex, uv, lod)\n#endif\n#if defined(GL_OES_standard_derivatives)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#else\n#define textureCubeLod(tex, uv, lod) textureLod(tex, uv, lod)\n#endif\n#define saturate(x)        clamp(x, 0.0, 1.0)\nprecision mediump float;\n#include <gl2_frag>\n#include <hsv_frag>\nuniform vec3 hsv;\nuniform float contrast;\nconst float c = .04;\nstruct MaterialUniforms {\n  vec2 roughnessMetalness;\n  vec3 albedo;\n  float alpha;\n  vec3 normal;\n  vec3 emit;\n  float ao;\n  vec3 specularColor;\n  float glossiness;\n  vec4 skinColor;\n} d;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\nuniform vec3 cameraPosition;\nuniform float alphaTest;\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nuniform vec4 diffuseFactor;\nuniform vec3 specularFactor;\nuniform float glossinessFactor;\n#if defined(HAS_DIFFUSE_MAP)\nuniform sampler2D diffuseTexture;\n#endif\n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\nuniform vec3 emissiveFactor;\nuniform vec4 baseColorFactor;\nuniform float baseColorIntensity;\nuniform float anisotropyDirection;\nuniform float anisotropyFactor;\nuniform float clearCoatFactor;\nuniform float clearCoatIor;\nuniform float clearCoatRoughnessFactor;\nuniform float clearCoatThickness;\nuniform float emitColorFactor;\nuniform float occlusionFactor;\nuniform float environmentExposure;\nuniform float roughnessFactor;\nuniform float metallicFactor;\nuniform float normalMapFactor;\nuniform float rgbmRange;\nuniform float specularF0;\nuniform int emitMultiplicative;\nuniform int normalMapFlipY;\nuniform int outputSRGB;\nuniform mat3 uEnvironmentTransform;\n#if defined(HAS_ALBEDO_MAP)\nuniform sampler2D baseColorTexture;\n#endif\n#if defined(HAS_METALLICROUGHNESS_MAP)\nuniform sampler2D metallicRoughnessTexture;\n#endif\n#if defined(HAS_EMISSIVE_MAP)\nuniform sampler2D emissiveTexture;\n#endif\n#if defined(HAS_AO_MAP)\nuniform sampler2D occlusionTexture;\nvarying vec2 vTexCoord1;\n#endif\n#if defined(HAS_NORMAL_MAP) && defined(HAS_TANGENT)\nuniform sampler2D normalTexture;\n#endif\n#if defined(HAS_SKIN_MAP)\nuniform sampler2D skinTexture;\n#endif\n#if defined(HAS_ALPHAMODE)\nuniform float alphaCutoff;\n#endif\n#ifdef HAS_RANDOM_TEX\nuniform highp vec2 uvOrigin;\nuniform sampler2D noiseTexture;\n#endif\nuniform sampler2D brdfLUT;\n#if defined(HAS_IBL_LIGHTING)\nuniform vec3 hdrHSV;\nuniform samplerCube prefilterMap;\nuniform vec3 diffuseSPH[9];\nuniform vec2 prefilterMiplevel;\nuniform vec2 prefilterSize;\n#else\nuniform vec3 ambientColor;\n#endif\nuniform vec2 cameraNearFar;\nuniform vec3 clearCoatTint;\nuniform vec3 light0_viewDirection;\nuniform vec4 light0_diffuse;\n#ifdef HAS_SSR\nvarying vec3 vViewNormal;\n#if defined(HAS_TANGENT)\nvarying vec4 vViewTangent;\n#endif\n#endif\nvarying vec3 vModelVertex;\nvarying vec4 vViewVertex;\n#if defined(HAS_MAP)\n#include <computeTexcoord_frag>\n#endif\nvarying vec3 vModelNormal;\n#if defined(HAS_TANGENT)\nvarying vec4 vModelTangent;\nvarying vec3 vModelBiTangent;\n#endif\n#if defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nvarying vec3 vColor0;\n#else\nvarying vec4 vColor0;\n#endif\n#endif\n#if defined(HAS_COLOR)\nvarying vec4 vColor;\n#elif defined(IS_LINE_EXTRUSION)\nuniform vec4 lineColor;\n#else\nuniform vec4 polygonFill;\n#endif\n#ifdef HAS_LAYER_OPACITY\nuniform float layerOpacity;\n#endif\nvarying float vOpacity;\n#ifdef HAS_INSTANCE_COLOR\nvarying vec4 vInstanceColor;\n#endif\n#ifdef IS_LINE_EXTRUSION\nuniform float lineOpacity;\n#else\nuniform float polygonOpacity;\n#endif\n#ifdef HAS_PATTERN\nuniform sampler2D linePatternFile;\nuniform vec2 atlasSize;\nuniform float flipY;\nuniform float currentTime;\nuniform float animSpeedScale;\n#ifdef HAS_PATTERN_ANIM\nvarying float vLinePatternAnimSpeed;\n#else\nuniform float linePatternAnimSpeed;\n#endif\n#ifdef HAS_PATTERN_GAP\nvarying float vLinePatternGap;\n#else\nuniform float linePatternGap;\n#endif\nuniform vec4 linePatternGapColor;\nuniform vec2 uvScale;\nvarying float vPatternHeight;\nvarying float vLinesofar;\nvarying vec4 vTexInfo;\nvarying float vNormalY;\nvec2 e(vec2 f) {\n  vec2 h = mod(f, 1.);\n  vec2 i = vTexInfo.xy;\n  vec2 j = vTexInfo.zw;\n  return (i + h * j) / atlasSize;\n}\n#endif\n#include <heatmap_render_frag>\n#include <snow_frag>\n#include <mask_frag>\n#include <terrain_normal_frag>\n#include <vertex_color_frag>\n#include <excavate_frag>\n#ifdef HAS_RANDOM_TEX\nconst float k = .5;\nvec2 l(vec2 h, float m) {\n  return vec2(cos(m) * (h.x - k) + sin(m) * (h.y - k) + k, cos(m) * (h.y - k) - sin(m) * (h.x - k) + k);\n}\nfloat n(vec3 o) {\n  return o.x + o.y + o.z;\n}\n#endif\nvec4 u(sampler2D A, in vec2 h) {\n  \n#ifdef HAS_RANDOM_TEX\nhighp vec2 B = uvOrigin;\n  highp vec2 C = h + B;\n  float D = texture2D(noiseTexture, .005 * C).x;\n  vec2 E = dFdx(C);\n  vec2 F = dFdx(C);\n  float G = D * 8.;\n  float H = fract(G);\n#if 1\nfloat I = floor(G);\n  float J = I + 1.;\n#else\nfloat I = floor(G + .5);\n  float J = floor(G);\n  H = min(H, 1. - H) * 2.;\n#endif\nvec2 K = sin(vec2(3., 7.) * I);\n  vec2 L = sin(vec2(3., 7.) * J);\n  float M = .5;\n  vec4 N = texture2DGradEXT(A, h + M * K, E, F);\n  vec4 O = texture2DGradEXT(A, h + M * L, E, F);\n  return mix(N, O, smoothstep(.2, .8, H - .1 * n(N.xyz - O.xyz)));\n#else\nreturn texture2D(A, h);\n#endif\n}\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nuniform sampler2D bumpTexture;\nuniform float bumpScale;\nuniform float bumpMaxLayers;\nuniform float bumpMinLayers;\nvec2 P(vec2 h, vec3 Q) {\n  float R = mix(bumpMaxLayers, bumpMinLayers, abs(dot(vec3(.0, .0, 1.), Q)));\n  float S = 1. / R;\n  float T = .0;\n  vec2 U = Q.xy * bumpScale / (Q.z * R);\n  vec2 V = h;\n  float W = u(bumpTexture, V).r;\n  for(int X = 0; X < 30; X++) {\n    T += S;\n    V -= U;\n    W = u(bumpTexture, V).r;\n    if(W < T) {\n      break;\n    }\n  }\n  vec2 Y = V + U;\n  float Z = W - T;\n  float ba = u(bumpTexture, Y).r - T + S;\n  return mix(V, Y, Z / (Z - ba));\n}\nvarying vec3 vTangentViewPos;\nvarying vec3 vTangentFragPos;\n#endif\n#define SHADER_NAME PBR\nvec3 bb(const in vec3 bc) {\n  return vec3(bc.r < .0031308 ? bc.r * 12.92 : 1.055 * pow(bc.r, 1. / 2.4) - .055, bc.g < .0031308 ? bc.g * 12.92 : 1.055 * pow(bc.g, 1. / 2.4) - .055, bc.b < .0031308 ? bc.b * 12.92 : 1.055 * pow(bc.b, 1. / 2.4) - .055);\n}\nvec3 bd(const in vec3 bc) {\n  return vec3(bc.r < .04045 ? bc.r * (1. / 12.92) : pow((bc.r + .055) * (1. / 1.055), 2.4), bc.g < .04045 ? bc.g * (1. / 12.92) : pow((bc.g + .055) * (1. / 1.055), 2.4), bc.b < .04045 ? bc.b * (1. / 12.92) : pow((bc.b + .055) * (1. / 1.055), 2.4));\n}\nvec3 be(const in vec4 bc, const in float bf) {\n  if(bf <= .0)\n    return bc.rgb;\n  return bf * bc.rgb * bc.a;\n}\nvec3 bg() {\n  return d.albedo;\n}\nfloat bh() {\n  \n#if defined(HAS_ALPHAMODE)\nif(d.alpha >= alphaCutoff) {\n    return 1.;\n  } else {\n    return .0;\n  }\n#else\nreturn d.alpha;\n#endif\n}\nfloat bi() {\n  \n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nvec3 bc = d.specularColor;\n  return max(max(bc.r, bc.g), bc.b);\n#else\nreturn d.roughnessMetalness.y;\n#endif\n}\nfloat bj() {\n  return specularF0;\n}\nfloat bk() {\n  \n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nreturn 1. - d.glossiness;\n#else\nreturn d.roughnessMetalness.x;\n#endif\n}\nvec3 bl() {\n  return d.emit;\n}\nvec4 bm() {\n  return d.skinColor;\n}\nvec3 bn() {\n  return d.normal;\n}\nfloat bo() {\n  return clearCoatFactor;\n}\nfloat bp() {\n  return clearCoatRoughnessFactor;\n}\nfloat bq() {\n  return d.ao;\n}\nfloat br(const in vec4 bs) {\n  return bs.r + bs.g / 255.;\n}\nfloat bt(const in vec2 bu, const in float bv) {\n  vec3 bw = vec3(.06711056, .00583715, 52.9829189);\n  return fract(bw.z * fract(dot(bu.xy + bv * vec2(47., 17.) * .695, bw.xy))) * .5;\n}\nvec3 bx(const in float by, in vec3 bz, const in vec3 t, const in vec3 b, in vec3 bA) {\n  bz.xy = by * bz.xy;\n  mat3 bB = mat3(t, b, bA);\n  return normalize(bB * bz);\n}\nvoid bC(const in vec3 bD, const in vec3 bz, const in vec3 bE, out float bF, out vec3 bG, out float bH) {\n  bF = 1.;\n  bG = -bE;\n  bH = dot(bG, bz);\n}\nvec4 bI(const in vec3 bz, const in vec3 bD, const in float bJ) {\n  float bK = clamp(dot(bz, bD), 0., 1.);\n  float bL = bJ * bJ;\n  return vec4(bL, bL * bL, bK, bK * (1. - bL));\n}\nfloat bM(const vec4 bI, const float bN) {\n  float bO = bI.y;\n  float bP = (bN * bO - bN) * bN + 1.;\n  return bO / (3.141593 * bP * bP);\n}\nvec3 bQ(const vec3 bR, const float bS, const in float bT) {\n  float bU = pow(1. - bT, 5.);\n  return bS * bU + (1. - bU) * bR;\n}\nfloat bQ(const float bR, const float bS, const in float bT) {\n  return bR + (bS - bR) * pow(1. - bT, 5.);\n}\nfloat bV(const vec4 bI, const float bW) {\n  float a = bI.x;\n  float bX = bW * (bI.w + a);\n  float bY = bI.z * (bW * (1. - a) + a);\n  return .5 / (bX + bY);\n}\nvec3 bZ(const vec4 bI, const vec3 bz, const vec3 bD, const vec3 bG, const vec3 ca, const float bW, const float bS) {\n  vec3 cb = normalize(bD + bG);\n  float bN = clamp(dot(bz, cb), 0., 1.);\n  float bT = clamp(dot(bG, cb), 0., 1.);\n  float cc = bM(bI, bN);\n  float cd = bV(bI, bW);\n  vec3 ce = bQ(ca, bS, bT);\n  return (cc * cd * 3.141593) * ce;\n}\nvoid cf(const in vec3 bz, const in vec3 bD, const in float bW, const in vec4 bI, const in vec3 cg, const in vec3 ca, const in float bF, const in vec3 ch, const in vec3 bG, const in float bS, out vec3 ci, out vec3 cj, out bool ck) {\n  ck = bW > .0;\n  if(ck == false) {\n    cj = ci = vec3(.0);\n    return;\n  }\n  vec3 cl = bF * bW * ch;\n  cj = cl * bZ(bI, bz, bD, bG, ca, bW, bS);\n  ci = cl * cg;\n}\nfloat cm(float at, float ab, float cn, float co, float cp, float cq, float bK, float bW) {\n  float cr = bW * length(vec3(at * cn, ab * co, bK));\n  float cs = bK * length(vec3(at * cp, ab * cq, bW));\n  return .5 / (cr + cs);\n}\nfloat ct(const float at, const float ab, const float cu, const float cv, const float bN) {\n  float bO = at * ab;\n  vec3 bP = vec3(ab * cu, at * cv, bO * bN);\n  float x = bO / dot(bP, bP);\n  return bO * (x * x) / 3.141593;\n}\nvec3 cw(const vec4 bI, const vec3 bz, const vec3 bD, const vec3 bG, const vec3 ca, const float bW, const float bS, const in vec3 cx, const in vec3 cy, const in float cz) {\n  vec3 cb = normalize(bD + bG);\n  float bN = clamp(dot(bz, cb), 0., 1.);\n  float bK = clamp(dot(bz, bD), 0., 1.);\n  float bT = clamp(dot(bG, cb), 0., 1.);\n  float cn = dot(cx, bD);\n  float co = dot(cy, bD);\n  float cp = dot(cx, bG);\n  float cq = dot(cy, bG);\n  float cu = dot(cx, cb);\n  float cv = dot(cy, cb);\n  float cA = sqrt(1. - abs(cz) * .9);\n  if(cz > .0)\n    cA = 1. / cA;\n  float at = bI.x * cA;\n  float ab = bI.x / cA;\n  float cc = ct(at, ab, cu, cv, bN);\n  float cd = cm(at, ab, cn, co, cp, cq, bK, bW);\n  vec3 ce = bQ(ca, bS, bT);\n  return (cc * cd * 3.141593) * ce;\n}\nvoid cB(const in vec3 bz, const in vec3 bD, const in float bW, const in vec4 bI, const in vec3 cg, const in vec3 ca, const in float bF, const in vec3 ch, const in vec3 bG, const in float bS, const in vec3 cx, const in vec3 cy, const in float cz, out vec3 ci, out vec3 cj, out bool ck) {\n  ck = bW > .0;\n  if(ck == false) {\n    cj = ci = vec3(.0);\n    return;\n  }\n  vec3 cl = bF * bW * ch;\n  cj = cl * cw(bI, bz, bD, bG, ca, bW, bS, cx, cy, cz);\n  ci = cl * cg;\n}\n#if defined(HAS_IBL_LIGHTING)\nvec3 cC(const in vec3 bz) {\n  vec3 bA = uEnvironmentTransform * bz;\n  float x = bA.x;\n  float y = bA.y;\n  float z = bA.z;\n  vec3 cD = (diffuseSPH[0] + diffuseSPH[1] * x + diffuseSPH[2] * y + diffuseSPH[3] * z + diffuseSPH[4] * z * x + diffuseSPH[5] * y * z + diffuseSPH[6] * y * x + diffuseSPH[7] * (3. * z * z - 1.) + diffuseSPH[8] * (x * x - y * y));\n  if(length(hdrHSV) > .0) {\n    cD = hsv_apply(cD, hdrHSV);\n  }\n  return max(cD, vec3(.0));\n}\nfloat cE(const in float cF) {\n  return cF;\n}\nvec3 cG(const in float cH, const in vec3 cI) {\n  vec3 cJ = cI;\n  float cK = prefilterMiplevel.x;\n  float cL = min(cK, cE(cH) * prefilterMiplevel.y);\n  vec3 cM = be(textureCubeLod(prefilterMap, cJ, cL), rgbmRange);\n  if(length(hdrHSV) > .0) {\n    return hsv_apply(cM, hdrHSV);\n  } else {\n    return cM;\n  }\n}\nvec3 cN(const in vec3 cO, const in vec3 cI, const in float cP) {\n  float cQ = 1. - cP;\n  float cR = cQ * (sqrt(cQ) + cP);\n  return mix(cO, cI, cR);\n}\nvec3 cS(const in vec3 bz, const in vec3 bD, const in float bJ, const in vec3 cT) {\n  vec3 cI = reflect(-bD, bz);\n  cI = cN(bz, cI, bJ);\n  vec3 cU = cG(bJ, uEnvironmentTransform * cI);\n  float by = clamp(1. + dot(cI, cT), .0, 1.);\n  cU *= by * by;\n  return cU;\n}\n#else\nvec3 cS(const in vec3 bz, const in vec3 bD, const in float bJ, const in vec3 cT) {\n  return ambientColor;\n}\n#endif\nvec3 cV(const in vec3 ca, const in float bJ, const in float bK, const in float bS) {\n  vec4 rgba = texture2D(brdfLUT, vec2(bK, bJ));\n  float b = (rgba[3] * 65280.0 + rgba[2] * 255.);\n  float a = (rgba[1] * 65280.0 + rgba[0] * 255.);\n  const float cW = 1. / 65535.;\n  return (ca * a + b * bS) * cW;\n}\nvec3 cX(const in vec3 bz, const in vec3 bD, const in float bJ, const in vec3 ca, const in vec3 cT, const in float bS) {\n  float bK = dot(bz, bD);\n  return cS(bz, bD, bJ, cT) * cV(ca, bJ, bK, bS);\n}\nvec3 cY(const float bK, const float bW, const vec3 cZ, const float bP) {\n  return exp(cZ * -bP * ((bW + bK) / max(bW * bK, 1e-3)));\n}\nvec3 da(const in float bK, const in float bW, const in float db) {\n  return mix(vec3(1.), cY(bK, bW, clearCoatTint, clearCoatThickness), db);\n}\nvoid dc(const in float dd, const in vec3 bz, const in vec3 bD, const in float bH, const in vec4 bI, const in float bF, const in vec3 ch, const in vec3 bG, const in float db, out vec3 de, out vec3 df) {\n  if(bH <= .0) {\n    de = vec3(.0);\n    df = vec3(.0);\n    return;\n  }\n  float dg = clamp(dot(bz, -refract(bG, bz, 1. / clearCoatIor)), 0., 1.);\n  vec3 dh = da(dd, dg, db);\n  vec3 cb = normalize(bD + bG);\n  float bN = clamp(dot(bz, cb), 0., 1.);\n  float bT = clamp(dot(bG, cb), 0., 1.);\n  float cc = bM(bI, bN);\n  float cd = bV(bI, dg);\n  float ce = bQ(c, 1., bT);\n  de = (bF * bH * db * cc * cd * 3.141593 * ce) * ch;\n  df = (1. - ce * db) * dh;\n}\nfloat di(const in int dj, const in float dk, const in vec3 bz, const in vec3 bD) {\n  if(dj == 0)\n    return 1.;\n  float bP = dot(bz, bD) + dk;\n  return clamp(bP * bP - 1. + dk, .0, 1.);\n}\nvec3 dl(const in vec3 bz, const in vec3 bD, const in float bJ, const in vec3 cx, const in vec3 cy, const in float cz) {\n  vec3 dm = cz >= .0 ? cy : cx;\n  vec3 dn = cross(dm, bD);\n  vec3 dp = cross(dn, dm);\n  float dq = abs(cz) * clamp(5. * bJ, .0, 1.);\n  return normalize(mix(bz, dp, dq));\n}\nvoid dr() {\n  \n#ifdef HAS_MAP\nvec2 h = computeTexCoord(vTexCoord);\n#endif\n#ifdef HAS_UV_FLIP\nh.y = 1. - h.y;\n#endif\n#if defined(HAS_BUMP_MAP) && defined(HAS_TANGENT)\nh = P(h, normalize(vTangentViewPos - vTangentFragPos));\n#endif\nd.albedo = baseColorIntensity * baseColorFactor.rgb;\n  d.alpha = baseColorFactor.a * vOpacity;\n#if defined(HAS_PATTERN)\nfloat ds = vLinesofar;\n  vec2 j = vTexInfo.zw;\n#ifdef HAS_PATTERN_GAP\nfloat dt = vLinePatternGap;\n#else\nfloat dt = linePatternGap;\n#endif\n#ifdef HAS_PATTERN_ANIM\nfloat du = vLinePatternAnimSpeed;\n#else\nfloat du = linePatternAnimSpeed;\n#endif\nfloat dv = ceil(j.x * vPatternHeight / j.y);\n  float dw = dv * (1. + dt);\n  du /= animSpeedScale;\n  ds += mod(currentTime * -du * .2, dw);\n  float dx = mod(ds / dw, 1.);\n  float dy = mod(flipY * vNormalY, 1.);\n  vec2 h = e(vec2(dx * (1. + dt) * uvScale[0], dy * uvScale[1]));\n  vec4 dz = texture2D(linePatternFile, h);\n  float dA = clamp(sign(1. / (1. + dt) - dx) + .000001, .0, 1.);\n  dz = mix(linePatternGapColor, dz, dA);\n#ifdef IS_SQUARE_TUBE\nfloat o = clamp(sign(abs(vNormalY) - .999999), .0, 1.);\n  dz = mix(dz, vec4(1.), o);\n#endif\nd.albedo *= dz.rgb;\n  d.alpha *= dz.a;\n#endif\n#if defined(HAS_ALBEDO_MAP)\nvec4 dB = u(baseColorTexture, h);\n  d.albedo *= bd(dB.rgb);\n  d.alpha *= dB.a;\n#endif\n#if defined(HAS_SKIN_MAP)\nvec4 dC = u(skinTexture, h);\n  d.skinColor = dC;\n#endif\n#if defined(HAS_COLOR0)\nd.albedo *= vColor0.rgb;\n#if COLOR0_SIZE == 4\nd.alpha *= vColor0.a;\n#endif\n#endif\n#if defined(HAS_COLOR)\nd.albedo *= vColor.rgb;\n  d.alpha *= vColor.a;\n#elif defined(IS_LINE_EXTRUSION)\nd.albedo *= lineColor.rgb;\n  d.alpha *= lineColor.a;\n#else\nd.albedo *= polygonFill.rgb;\n  d.alpha *= polygonFill.a;\n#endif\n#if defined(HAS_INSTANCE_COLOR)\nd.albedo *= vInstanceColor.rgb;\n  d.alpha *= vInstanceColor.a;\n#endif\n#if defined(IS_LINE_EXTRUSION)\nd.alpha *= lineOpacity;\n#else\nd.alpha *= polygonOpacity;\n#endif\n#if defined(HAS_METALLICROUGHNESS_MAP)\nd.roughnessMetalness = u(metallicRoughnessTexture, h).gb * vec2(roughnessFactor, metallicFactor);\n#else\nd.roughnessMetalness = vec2(roughnessFactor, metallicFactor);\n#endif\nd.emit = emissiveFactor;\n#if defined(HAS_EMISSIVE_MAP)\nif(emitMultiplicative == 1) {\n    d.emit *= bd(u(emissiveTexture, h).rgb);\n  } else {\n    d.emit += bd(u(emissiveTexture, h).rgb);\n  }\n#endif\nd.emit *= emitColorFactor;\n#if defined(HAS_AO_MAP)\nvec2 dD = computeTexCoord(vTexCoord1);\n  d.ao = u(occlusionTexture, dD).r;\n#else\nd.ao = 1.;\n#endif\nd.ao *= occlusionFactor;\n#if defined(HAS_NORMAL_MAP) && defined(HAS_TANGENT)\nvec3 dE = u(normalTexture, h).xyz * 2. - 1.;\n  dE.y = normalMapFlipY == 1 ? -dE.y : dE.y;\n  d.normal = dE;\n#else\nd.normal = normalize(vModelNormal);\n#endif\n#if defined(HAS_TERRAIN_NORMAL) && defined(HAS_TANGENT)\nvec3 dE = convertTerrainHeightToNormalMap(h);\n  dE.y = normalMapFlipY == 1 ? -dE.y : dE.y;\n  d.normal = dE;\n#endif\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nd.albedo *= diffuseFactor.rgb;\n  d.alpha *= diffuseFactor.a;\n#if defined(HAS_DIFFUSE_MAP)\nvec4 cg = u(diffuseTexture, h);\n  d.albedo *= bd(cg.rgb);\n  d.alpha *= cg.a;\n#endif\nd.specularColor = specularFactor;\n  d.glossiness = glossinessFactor;\n#if defined(HAS_SPECULARGLOSSINESS_MAP)\nvec4 dF = u(specularGlossinessTexture, h);\n  d.specularColor *= bd(dF.rgb);\n  d.glossiness *= dF.a;\n#endif\n#endif\n}\nvec3 dG(const vec3 x) {\n  const float a = 2.51;\n  const float b = .03;\n  const float dH = 2.43;\n  const float bP = .59;\n  const float dI = .14;\n  return (x * (a * x + b)) / (x * (dH * x + bP) + dI);\n}\nvec3 dJ(vec3 bc) {\n  bc = dG(bc);\n  return bc = pow(bc, vec3(1. / 2.2));\n}\nuniform float specularAAVariance;\nuniform float specularAAThreshold;\nfloat dK(float bJ, const vec3 dL) {\n  \n#if defined(GL_OES_standard_derivatives) || __VERSION__ == 300\nvec3 dM = dFdx(dL);\n  vec3 dN = dFdy(dL);\n  float dO = specularAAVariance * (dot(dM, dM) + dot(dN, dN));\n  float dP = min(2. * dO, specularAAThreshold);\n  float dQ = saturate(bJ * bJ + dP);\n  return sqrt(dQ);\n#else\nreturn bJ;\n#endif\n}\n#ifdef HAS_SSR\nuniform sampler2D TextureDepth;\nuniform highp vec2 outSize;\nuniform float ssrFactor;\nuniform float ssrQuality;\nuniform sampler2D TextureReflected;\nuniform highp mat4 projMatrix;\nuniform mat4 invProjMatrix;\nuniform vec4 outputFovInfo[2];\nuniform mat4 reprojViewProjMatrix;\nvec3 dR(const in mat4 dS, const in vec3 dT) {\n  vec4 dU = dS * vec4(dT, 1.);\n  return vec3(.5 + .5 * dU.xy / dU.w, dU.w);\n}\nvec3 dV(const in float dW, const in vec2 h) {\n  return texture2D(TextureReflected, h).rgb;\n}\nfloat dX(float dY) {\n  highp mat4 dS = projMatrix;\n  highp float z = dY * 2. - 1.;\n  return -dS[3].z / (z + dS[2].z);\n}\nfloat dZ(const vec2 h) {\n  float dY = br(texture2D(TextureDepth, h));\n  return dY;\n}\nvec3 ea(const in float bv, const in vec3 eb, const in vec3 ec, const in vec3 ed, const in vec3 bD, const in float ee) {\n  vec2 ef;\n  ef.x = bt(gl_FragCoord.yx, bv);\n  ef.y = fract(ef.x * 52.9829189);\n  ef.y = mix(ef.y, 1., .7);\n  float eg = 2. * 3.14159 * ef.x;\n  float eh = pow(max(ef.y, .000001), ee / (2. - ee));\n  float ei = sqrt(1. - eh * eh);\n  vec3 ej = vec3(ei * cos(eg), ei * sin(eg), eh);\n  ej = ej.x * eb + ej.y * ec + ej.z * ed;\n  return normalize((2. * dot(bD, ej)) * ej - bD);\n}\nfloat ek(const in float bv) {\n  return (bt(gl_FragCoord.xy, bv) - .5);\n}\nvec3 el(const in vec3 em, const in float en, const in vec3 eo) {\n  vec3 ep = dR(projMatrix, vViewVertex.xyz + eo * en);\n  ep.z = 1. / ep.z;\n  ep -= em;\n  float eq = min(1., .99 * (1. - em.x) / max(1e-5, ep.x));\n  float er = min(1., .99 * (1. - em.y) / max(1e-5, ep.y));\n  float es = min(1., .99 * em.x / max(1e-5, -ep.x));\n  float et = min(1., .99 * em.y / max(1e-5, -ep.y));\n  return ep * min(eq, er) * min(es, et);\n}\nfloat eu(const in vec3 em, const in vec3 ep, inout float ev, inout float ew) {\n  float ex = (ew + ev) * .5;\n  vec3 ey = em + ep * ex;\n  float z = dZ(ey.xy);\n  float dY = dX(z);\n  float ez = -1. / ey.z;\n  ev = dY > ez ? ev : ex;\n  ew = dY > ez ? ex : ew;\n  return ex;\n}\nvec4 eA(const in vec3 em, const in float en, in float eB, const in vec3 eo, const in float bJ, const in float bv) {\n  int eC = 20;\n  float eD = 1. / float(eC);\n  eB *= eD;\n  vec3 ep = el(em, en, eo);\n  float eE = eD;\n  vec3 eF = vec3(.0, eE, 1.);\n  vec3 ey;\n  float z, dY, ez, eG, eH, eI;\n  bool eJ;\n  float eK = 1.;\n  float ex;\n  for(int X = 0; X < eC; X++) {\n    ey = em + ep * eF.y;\n    z = dZ(ey.xy);\n    dY = dX(z);\n    ez = -1. / ey.z;\n    float eL = clamp(sign(.999 - z), .0, 1.);\n    eG = eL * (ez - dY);\n    eG *= clamp(sign(abs(eG) - en * eD * eD), .0, 1.);\n    eJ = abs(eG + eB) < eB;\n    eH = clamp(eF.x / (eF.x - eG), .0, 1.);\n    eI = eJ ? eF.y + eH * eD - eD : 1.;\n    eF.z = min(eF.z, eI);\n    eF.x = eG;\n    if(eJ) {\n      float ev = eF.y - eD;\n      float ew = eF.y;\n      ex = eu(em, ep, ev, ew);\n      ex = eu(em, ep, ev, ew);\n      ex = eu(em, ep, ev, ew);\n      eK = ex;\n      break;\n    }\n    eF.y += eD;\n  }\n  return vec4(em + ep * eK, 1. - eK);\n}\nvec4 eM(in vec4 eN, const in float eO, const in vec3 eP, const in vec3 eQ, const in float bJ) {\n  vec4 eR = mix(outputFovInfo[0], outputFovInfo[1], eN.x);\n  eN.xyz = vec3(mix(eR.xy, eR.zw, eN.y), 1.) * -1. / eN.z;\n  eN.xyz = (reprojViewProjMatrix * vec4(eN.xyz, 1.)).xyw;\n  eN.xy /= eN.z;\n  float eS = clamp(6. - 6. * max(abs(eN.x), abs(eN.y)), .0, 1.);\n  eN.xy = .5 + .5 * eN.xy;\n  vec3 eT = eQ * dV(bJ * (1. - eN.w), eN.xy);\n  return vec4(mix(eP, eT, eO * eS), 1.);\n}\nvec3 ssr(const in vec3 eP, const in vec3 eQ, const in float bJ, const in vec3 bz, const in vec3 bD) {\n  float eU = .0;\n  vec4 cD = vec4(.0);\n  float ee = bJ * bJ;\n  ee = ee * ee;\n  vec3 eV = abs(bz.z) < .999 ? vec3(.0, .0, 1.) : vec3(1., .0, .0);\n  vec3 eb = normalize(cross(eV, bz));\n  vec3 ec = cross(bz, eb);\n  float eO = ssrFactor * clamp(-4. * dot(bD, bz) + 3.8, .0, 1.);\n  eO *= clamp(4.7 - bJ * 5., .0, 1.);\n  vec3 em = dR(projMatrix, vViewVertex.xyz);\n  em.z = 1. / em.z;\n  vec3 eo = ea(eU, eb, ec, bz, bD, ee);\n  float en = mix(cameraNearFar.y + vViewVertex.z, -vViewVertex.z - cameraNearFar.x, eo.z * .5 + .5);\n  float eB = .5 * en;\n  vec4 eN;\n  if(dot(eo, bz) > .001 && eO > .0) {\n    eN = eA(em, en, eB, eo, bJ, eU);\n    if(eN.w > .0)\n      cD += eM(eN, eO, eP, eQ, bJ);\n    \n  }\n  return cD.w > .0 ? cD.rgb / cD.w : eP;\n}\n#endif\n#include <highlight_frag>\nvoid main() {\n  dr();\n  vec3 bD = normalize(cameraPosition - vModelVertex.xyz);\n#if defined(HAS_DOUBLE_SIDE)\nvec3 cT = gl_FrontFacing ? normalize(vModelNormal) : -normalize(vModelNormal);\n#else\nvec3 cT = normalize(vModelNormal);\n#endif\n#if defined(HAS_TANGENT)\nvec4 eW;\n  eW = vModelTangent;\n#if defined(HAS_DOUBLE_SIDE)\neW.xyz = gl_FrontFacing ? normalize(eW.xyz) : -normalize(eW.xyz);\n#else\neW.xyz = normalize(eW.xyz);\n#endif\nvec3 eX = normalize(vModelBiTangent);\n#endif\nfloat bR = .08 * bj();\n  float eY = bi();\n  vec3 eZ = bg();\n#if defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\nvec3 fa = d.specularColor;\n#else\nvec3 fa = mix(vec3(bR), eZ, eY);\n#endif\neZ *= 1. - eY;\n  float fb = clamp(50.0 * fa.g, .0, 1.);\n  float fc = bk();\n  if(specularAAVariance > .0) {\n    fc = dK(fc, cT);\n  }\n  vec3 fd = bl();\n  vec3 fe = bn();\n  vec3 ff = vec3(fe);\n#if defined(HAS_TANGENT) && (defined(HAS_NORMAL_MAP) || defined(HAS_TERRAIN_NORMAL))\nff = bx(normalMapFactor, ff, eW.xyz, eX, cT);\n#endif\nfloat fg = bo();\n  float fh = bp();\n  if(specularAAVariance > .0) {\n    fh = dK(fh, cT);\n  }\n  vec3 fi = cT;\n#if defined(HAS_TANGENT)\nfloat cz;\n  vec3 cx;\n  vec3 cy;\n  if(anisotropyFactor > .0) {\n    cz = anisotropyFactor;\n    eW.xyz = normalize(eW.xyz - ff * dot(eW.xyz, ff));\n    eX = normalize(cross(ff, eW.xyz)) * eW.w;\n    cx = normalize(mix(eW.xyz, eX, anisotropyDirection));\n    cy = normalize(mix(eX, -eW.xyz, anisotropyDirection));\n  }\n#endif\nvec3 cg = vec3(.0);\n  vec3 ca = vec3(.0);\n  vec3 fj;\n#if defined(HAS_TANGENT)\nif(anisotropyFactor > .0) {\n    fj = dl(ff, bD, fc, cx, cy, cz);\n  } else {\n    fj = ff;\n  }\n#else\nfj = ff;\n#endif\n#if defined(HAS_IBL_LIGHTING)\ncg = eZ * cC(ff) * .5;\n#else\ncg = eZ * ambientColor;\n#endif\nca = cX(fj, bD, fc, fa, cT, fb);\n  float dd;\n  if(clearCoatFactor > .0) {\n    dd = clamp(dot(fi, -refract(bD, fi, 1. / clearCoatIor)), 0., 1.);\n    float fk = fg * bQ(c, 1., dd);\n    vec3 fl = da(dd, dd, fg);\n    ca = mix(ca * fl, cS(fi, bD, fh, cT), fk);\n    cg *= fl * (1. - fk);\n  }\n  float fm = 1.;\n  float fn = bq();\n  cg *= environmentExposure * fn;\n#ifdef HAS_IBL_LIGHTING\nfm = di(1, fn, ff, bD);\n#endif\n#ifdef HAS_SSR\nvec3 fo = normalize(gl_FrontFacing ? vViewNormal : -vViewNormal);\n  vec3 fp = fo;\n#if defined(HAS_TANGENT) && (defined(HAS_NORMAL_MAP) || defined(HAS_TERRAIN_NORMAL))\nvec4 fq;\n  fq = vViewTangent;\n  fq = gl_FrontFacing ? fq : -fq;\n  fq.xyz = normalize(fq.xyz);\n  vec3 fr = normalize(cross(fo, fq.xyz)) * fq.w;\n  fp = bx(normalMapFactor, fe, fq.xyz, fr, fo);\n#endif\nca = ssr(ca, fa * fm, fc, fp, -normalize(vViewVertex.xyz));\n#endif\nca *= environmentExposure * fm;\n  float bF, bH;\n  vec3 bG;\n  bool ck;\n  vec3 fs;\n  vec3 ft;\n  vec4 fu = bI(ff, bD, max(.045, fc));\n  vec3 fv = vModelNormal;\n  bC(bD, ff, light0_viewDirection, bF, bG, bH);\n#if defined(HAS_TANGENT)\nif(anisotropyFactor > .0) {\n    cB(ff, bD, bH, fu, eZ, fa, bF, light0_diffuse.rgb, bG, fb, cx, cy, cz, ft, fs, ck);\n  } else {\n    cf(ff, bD, bH, fu, eZ, fa, bF, light0_diffuse.rgb, bG, fb, ft, fs, ck);\n  }\n#else\ncf(ff, bD, bH, fu, eZ, fa, bF, light0_diffuse.rgb, bG, fb, ft, fs, ck);\n#endif\nif(clearCoatFactor > .0) {\n    vec3 fw;\n    vec3 fx;\n    vec4 fy = bI(fi, bD, fh);\n    dc(dd, fi, bD, dot(fi, bG), fy, bF, light0_diffuse.rgb, bG, fg, fw, fx);\n    ft *= fx;\n    fs = fw + fs * fx;\n  }\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat fz = shadow_computeShadow();\n  ft = shadow_blend(ft, fz).rgb;\n  fs = shadow_blend(fs, fz).rgb;\n#endif\nvec3 fA = vec3(ca);\n  vec3 fB = vec3(cg);\n  cg += ft;\n  ca += fs;\n  cg += fd;\n  vec3 fC = ca + cg;\n  if(outputSRGB == 1)\n    fC = bb(fC);\n  \n#ifdef HAS_SKIN_MAP\nvec4 fD = bm();\n  fC.rgb = fC.rgb * (1. - fD.a) + fD.rgb * fD.a;\n#endif\nfloat fE = bh();\n  glFragColor = vec4(fC * fE, fE);\n  if(glFragColor.a < alphaTest) {\n    discard;\n  }\n#ifdef HAS_VERTEX_COLOR\nglFragColor *= vertexColor_get();\n#endif\n#ifdef HAS_EXCAVATE_ANALYSIS\nglFragColor = excavateColor(glFragColor);\n#endif\n#ifdef HAS_HEATMAP\nglFragColor = heatmap_getColor(glFragColor);\n#endif\n#ifdef HAS_SNOW\nglFragColor.rgb = snow(glFragColor, bn(), 1.);\n#endif\nif(contrast != 1.) {\n    glFragColor = contrastMatrix(contrast) * glFragColor;\n  }\n  if(length(hsv) > .0) {\n    glFragColor = hsv_apply(glFragColor, hsv);\n  }\n#ifdef OUTPUT_NORMAL\nglFragColor = vec4(cT, 1.);\n#endif\nglFragColor = highlight_blendColor(glFragColor);\n#ifdef HAS_LAYER_OPACITY\nglFragColor *= layerOpacity;\n#endif\n#ifdef HAS_MASK_EXTENT\nglFragColor = setMask(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:d,extraCommandProps:t,defines:o}),this.version=300}getGeometryDefines(e){const n={};return e.data[e.desc.tangentAttribute]?n.HAS_TANGENT=1:e.data[e.desc.normalAttribute]&&(n.HAS_NORMAL=1),e.data[e.desc.colorAttribute]&&(n.HAS_COLOR=1),e.data[e.desc.color0Attribute]&&(n.HAS_COLOR0=1,n.COLOR0_SIZE=e.getColor0Size()),n}},StandardDepthShader:class extends vn$4{constructor(e={}){const t=[];super({vert:"#define SHADER_NAME depth_vert\nprecision highp float;\nattribute vec3 aPosition;\n#include <line_extrusion_vert>\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\nuniform vec2 outSize;\nuniform vec2 halton;\n#include <get_output>\nvoid main() {\n  mat4 c = getPositionMatrix();\n#ifdef IS_LINE_EXTRUSION\nvec4 d = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 d = getPosition(aPosition);\n#endif\nvec4 e = modelViewMatrix * c * d;\n  mat4 f = projMatrix;\n  f[2].xy += halton.xy / outSize.xy;\n  gl_Position = f * e;\n}",frag:"#define SHADER_NAME depth_frag\nprecision highp float;\nvoid main() {\n  gl_FragColor = vec4(1., .0, .0, 1.);\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:(e,r)=>multiply$5(t,r.viewMatrix,r.modelMatrix)}],extraCommandProps:e.extraCommandProps,defines:e.defines})}},PBRUtils:lr$4};var l$1=Object.freeze({__proto__:null,AbstractTexture:z$6,BloomPass:Un$4,BoundingBox:X$7,BoxBlurShader:class extends Mn$4{constructor({blurOffset:e}){super({vert:An$4,frag:"precision highp float;\nvarying vec2 vTexCoord;\nuniform sampler2D textureSource;\nuniform vec2 resolution;\nuniform float ignoreTransparent;\nvoid main() {\n  vec4 c = vec4(.0);\n  float d = .0;\n  for(int x = -BOXBLUR_OFFSET; x <= BOXBLUR_OFFSET; ++x)\n    for(int y = -BOXBLUR_OFFSET; y <= BOXBLUR_OFFSET; ++y) {\n      vec2 e = vTexCoord.st + vec2(float(x) / resolution.x, float(y) / resolution.y);\n      e = clamp(e, .0, 1.);\n      vec4 f = texture2D(textureSource, e);\n      float h;\n      if(ignoreTransparent == 1.) {\n        h = sign(f.a);\n      } else {\n        h = 1.;\n      }\n      d += h;\n      c += h * f;\n    }\n  gl_FragColor = c / max(d, 1.) * clamp(sign(d - 1.), .0, 1.);\n}",defines:{BOXBLUR_OFFSET:e||2},extraCommandProps:{viewport:{x:0,y:0,width:(e,n)=>n.resolution[0],height:(e,n)=>n.resolution[1]}}}),this._blurOffset=e||2}getMeshCommand(e,n){const t="box_blur_"+this._blurOffset;return this.commands[t]||(this.commands[t]=this.createREGLCommand(e,null,n.getElements())),this.commands[t]}},Constants:L$6,CopyShader:Zn$4,DeferredRenderer:class extends B$6{},EdgeGeometry:Te$5,EdgeShader:Qn$4,ExtentPass:mt$6,FBORayPicking:Cr$4,FogPass:rt$6,FogShader:it$5,FxaaShader:Cn$4,GLTFHelper:Dt$6,GLTFManager:Bt$6,Geometry:Q$7,HDR:li$4,HeatmapDisplayShader:Yn$4,HeatmapShader:Xn$4,InstancedMesh:Ge$5,Jitter:Bn$4,KHRTechniquesWebglManager:Nr$4,Material:Ce$5,Mesh:Be$5,MeshShader:vn$4,PhongMaterial:Ie$5,PhongShader:bn$4,PhongSpecularGlossinessMaterial:Le$5,Plane:tn$5,PointLineShader:class extends vn$4{constructor(e={}){const t=[];super({vert:"attribute vec3 aPosition;\n#ifdef HAS_COLOR0\nattribute vec4 aColor0;\nvarying vec4 vColor;\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 projMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\nuniform float pointSize;\n#if defined(HAS_MAP)\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n#endif\n#include <get_output>\n#include <heatmap_render_vert>\n#ifdef HAS_FLOODANALYSE\nvarying float vHeight;\n#endif\nvoid main() {\n  vec4 c = getPosition(aPosition);\n  mat4 d = getPositionMatrix();\n  gl_PointSize = pointSize;\n#ifdef HAS_MASK_EXTENT\ngl_Position = projMatrix * getMaskPosition(d * c, modelMatrix);\n#else\ngl_Position = projViewModelMatrix * d * c;\n#endif\n#ifdef HAS_COLOR0\nvColor = aColor0 / 255.;\n#endif\n#ifdef HAS_MAP\nvTexCoord = aTexCoord;\n#endif\n#ifdef HAS_HEATMAP\nheatmap_compute(projMatrix * modelViewMatrix * d, c);\n#endif\n}",frag:"precision mediump float;\n#include <gl2_frag>\n#if defined(HAS_COLOR0)\nvarying vec4 vColor;\n#endif\n#include <heatmap_render_frag>\nuniform vec4 baseColorFactor;\n#if defined(HAS_MAP)\n#if defined(HAS_ALBEDO_MAP)\nuniform sampler2D baseColorTexture;\n#endif\n#if defined(HAS_DIFFUSE_MAP)\nuniform sampler2D diffuseTexture;\n#endif\nvarying vec2 vTexCoord;\n#endif\n#include <mask_frag>\nvoid main() {\n  \n#ifdef HAS_COLOR0\nglFragColor = vColor * baseColorFactor;\n#else\nglFragColor = vec4(1.) * baseColorFactor;\n#endif\n#ifdef HAS_MAP\n#ifdef HAS_ALBEDO_MAP\nglFragColor *= texture2D(baseColorTexture, vTexCoord);\n#endif\n#ifdef HAS_DIFFUSE_MAP\nglFragColor *= texture2D(diffuseTexture, vTexCoord);\n#endif\n#endif\n#ifdef HAS_HEATMAP\nglFragColor = heatmap_getColor(glFragColor);\n#endif\n#ifdef HAS_MASK_EXTENT\nglFragColor = setMask(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(e,r)=>multiply$5(t,r.projViewMatrix,r.modelMatrix)}],defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}})}},PostProcessShader:Rn$4,QuadShader:Mn$4,REGLHelper:_e$5,RainRipplesPass:dt$6,Renderer:B$6,ResourceLoader:Ve$5,Scene:Ke$5,Shader:hn$5,ShaderLib:on$5,ShadowDisplayShader:vr$4,ShadowMapShader:fr$4,ShadowPass:mr$4,SkyboxShader:qn$4,SsaoPass:Dn$4,SsrPass:jn$4,StandardLiteMaterial:Ne$5,StandardLiteShader:class extends vn$4{constructor(e={}){const t=[],r=e.uniforms,o=[{name:"viewMatrixInverse",type:"function",fn:(e,t)=>invert$2($n$4,t.viewMatrix)},{name:"modelViewMatrix",type:"function",fn:function(e,r){return multiply$5(t,r.viewMatrix,r.modelMatrix)}},{name:"uEnvironmentTransform",type:"function",fn:(e,n)=>fromRotation$2(et$6,Math.PI*(n.environmentOrientation||0)/180)}];r&&o.push(...r),super({vert:"precision mediump float;\n#include <gl2_vert>\nattribute vec3 aPosition;\n#include <line_extrusion_vert>\n#ifdef HAS_MAP\nuniform vec2 uvScale;\nuniform vec2 uvOffset;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\n#ifdef HAS_I3S_UVREGION\nattribute vec4 uvRegion;\nvarying vec4 vUvRegion;\n#endif\n#endif\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nattribute vec3 aColor0;\n#else\nattribute vec4 aColor0;\n#endif\nvarying vec4 vColor;\n#endif\nuniform mat4 projMatrix;\nuniform mat3 modelNormalMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 positionMatrix;\nuniform vec2 halton;\nuniform vec2 outSize;\nuniform mat4 projViewMatrix;\n#include <get_output>\n#include <heatmap_render_vert>\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\nvarying vec3 vViewPosition;\nvoid main() {\n  \n#ifdef IS_LINE_EXTRUSION\nvec4 c = getPosition(getLineExtrudePosition(aPosition));\n#else\nvec4 c = getPosition(aPosition);\n#endif\nmat4 d = getPositionMatrix();\n  mat4 e = projMatrix;\n  e[2].xy += halton.xy / outSize.xy;\n#ifdef HAS_MASK_EXTENT\ngl_Position = e * getMaskPosition(d * c, modelMatrix);\n#else\ngl_Position = e * modelViewMatrix * d * c;\n#endif\nvec4 f = modelViewMatrix * d * c;\n  vViewPosition = -f.xyz;\n#ifdef HAS_MAP\nvec2 h = decode_getTexcoord(aTexCoord);\n  vTexCoord = h * uvScale + uvOffset;\n#endif\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#elif defined(HAS_COLOR0)\n#if COLOR0_SIZE == 3\nvColor = vec4(aColor0 / 255., 1.);\n#else\nvColor = aColor0 / 255.;\n#endif\n#endif\n}",frag:"#if __VERSION__ == 100\n#if defined(GL_EXT_shader_texture_lod)\n#extension GL_EXT_shader_texture_lod : enable\n#define textureCubeLod(tex, uv, lod) textureCubeLodEXT(tex, uv, lod)\n#else\n#define textureCubeLod(tex, uv, lod) textureCube(tex, uv, lod)\n#endif\n#if defined(GL_OES_standard_derivatives)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#else\n#define textureCubeLod(tex, uv, lod) textureLod(tex, uv, lod)\n#endif\n#define saturate(x)        clamp(x, 0.0, 1.0)\nprecision mediump float;\n#include <gl2_frag>\n#include <hsv_frag>\nuniform vec3 hsv;\n#define GET_BASEMAP(UV) (texture2D(baseColorTexture, (UV)))\nuniform mat4 viewMatrix;\nuniform mat4 projMatrix;\nuniform vec3 cameraPosition;\n#if defined(HAS_IBL_LIGHTING)\nuniform mat4 viewMatrixInverse;\n#endif\nuniform vec4 baseColorFactor;\nuniform vec3 emissiveFactor;\nuniform vec3 specularFactor;\nuniform float opacity;\nuniform float envRotationSin;\nuniform float envRotationCos;\nuniform float rgbmRange;\n#if defined(HAS_MAP)\n#include <computeTexcoord_frag>\n#endif\n#ifdef HAS_BASECOLOR_MAP\nuniform sampler2D baseColorTexture;\n#endif\n#ifdef HAS_NORMAL_MAP\nuniform sampler2D normalTexture;\nvec3 c(vec3 d, vec3 e) {\n  vec3 f = dFdx(d.xyz);\n  vec3 h = dFdy(d.xyz);\n  vec3 i = normalize(f - h);\n  vec3 j = normalize(-f + h);\n  vec3 k = normalize(e);\n  vec3 l = texture2D(normalTexture, computeTexCoord(vTexCoord)).rgb * 2. - 1.;\n  mat3 m = mat3(i, j, k);\n  return normalize(m * l);\n}\n#endif\n#ifdef HAS_EMISSIVE_MAP\nuniform sampler2D emissiveTexture;\n#endif\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\nuniform vec4 diffuseFactor;\n#ifdef HAS_DIFFUSE_MAP\nuniform sampler2D diffuseTexture;\n#endif\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nuniform sampler2D specularGlossinessTexture;\n#endif\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\nvarying vec4 vColor;\n#endif\n#ifdef GAMMA_INPUT\nvec3 n(vec3 o) {\n  return o * o;\n}\nfloat n(float o) {\n  return o * o;\n}\n#else\nvec3 n(vec3 o) {\n  return o;\n}\nfloat n(float o) {\n  return o;\n}\n#endif\nvec3 u() {\n  \n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n#ifdef HAS_SPECULARGLOSSINESS_MAP\nreturn texture2D(specularGlossinessTexture, computeTexCoord(vTexCoord)).rgb;\n#else\nreturn specularFactor;\n#endif\n#else\nreturn specularFactor;\n#endif\n}\nvec3 v() {\n  \n#ifdef HAS_EMISSIVE_MAP\nreturn texture2D(emissiveTexture, computeTexCoord(vTexCoord)).rgb;\n#else\nreturn emissiveFactor;\n#endif\n}\n#if defined(TONEMAP_OUTPUT)\n#if TONEMAP_OUTPUT > 0\nuniform float exposureBias;\nfloat A(vec3 rgb) {\n  return dot(rgb, vec3(.299, .587, .114));\n}\nfloat B(vec3 rgb) {\n  return dot(rgb, vec3(.212671, .715160, .072169));\n}\nvec3 C(vec3 xyz) {\n  vec3 D = vec3(3.240479, -1.53715, -.498535);\n  vec3 E = vec3(-.969256, 1.875992, .041556);\n  vec3 F = vec3(.055648, -.204043, 1.057311);\n  vec3 rgb;\n  rgb.b = dot(xyz, F);\n  rgb.g = dot(xyz, E);\n  rgb.r = dot(xyz, D);\n  return rgb;\n}\nvec3 H(vec3 rgb) {\n  vec3 I = vec3(.412453, .35758, .180423);\n  vec3 J = vec3(.212671, .71516, .0721688);\n  vec3 K = vec3(.0193338, .119194, .950227);\n  vec3 xyz;\n  xyz.x = dot(rgb, I);\n  xyz.y = dot(rgb, J);\n  xyz.z = dot(rgb, K);\n  return xyz;\n}\nvec3 L(vec3 xyz) {\n  float M = xyz.x + xyz.y + xyz.z;\n  M = 1. / M;\n  vec3 O;\n  O.z = xyz.y;\n  O.x = xyz.x * M;\n  O.y = xyz.y * M;\n  return O;\n}\nvec3 P(vec3 O) {\n  float x = O.x;\n  float y = O.y;\n  float J = O.z;\n  vec3 xyz;\n  xyz.y = J;\n  xyz.x = x * (J / y);\n  xyz.z = (1. - x - y) * (J / y);\n  return xyz;\n}\nfloat Q(float x) {\n  float U = pow(x, 1.60525727);\n  float V = ((1.05542877 * 4.68037409) * U) / (4.68037409 * U + 1.);\n  return clamp(V, .0, 1.);\n}\nconst float W = 1. / .18;\nfloat ba(float x) {\n  x *= W;\n  const float bb = .2;\n  const float F = .34;\n  const float bc = .002;\n  const float bd = 1.68;\n  const float be = .0005;\n  const float bf = .252;\n  const float bg = 1. / .833837;\n  return ((x * (bb * x + bc * F) + bd * be) / (x * (bb * x + F) + bd * bf) - be / bf) * bg;\n}\nvec3 bh(vec3 x) {\n  x *= W;\n  const float bb = .27;\n  const float F = .29;\n  const float bc = .052;\n  const float bd = .2;\n  const float bf = .18;\n  const float bg = 1. / .897105;\n  return ((x * (bb * x + bc * F)) / (x * (bb * x + F) + bd * bf)) * bg;\n}\nvec3 bi(vec3 x) {\n  vec3 bj = x.rgb;\n  bj = min(bj, vec3(3.));\n  float bk = B(bj);\n  if(bk > .0) {\n    float bl = Q(bk);\n    bj = bj * (bl / bk);\n    bj = clamp(bj, vec3(.0), vec3(1.));\n  }\n  float bm = 1. / 2.2;\n  bj = pow(bj, vec3(bm));\n  return bj;\n}\n#endif\n#endif\n#if defined(IRR_RGBM) || defined(ENV_RGBM) || defined(ENV_GAMMA) || defined(IRR_GAMMA)\nuniform float envMapExposure;\n#endif\nuniform vec4 themingColor;\nuniform mat3 uEnvironmentTransform;\nvec3 bn(vec3 bo, vec3 bp) {\n  \n#if defined(HAS_SHADOWMAP)\nfloat bq = dot(shadowLightDir, bp);\n  float br = (bq + 1.) / 2.;\n  br = min(1., br * 1.5);\n  float bs = 1.;\n  vec3 bt = bo * min(bs, br);\n  return bt;\n#else\nreturn bo;\n#endif\n}\n#ifdef HAS_IBL_LIGHTING\nuniform float reflectivity;\nuniform vec3 hdrHSV;\nuniform samplerCube prefilterMap;\nuniform vec3 diffuseSPH[9];\nuniform vec2 prefilterMiplevel;\nuniform vec2 prefilterSize;\n#else\nuniform vec3 ambientColor;\n#endif\n#if defined(HAS_IBL_LIGHTING)\nvec3 bu(const in vec3 bv) {\n  vec3 bw = uEnvironmentTransform * bv;\n  float x = bw.x;\n  float y = bw.y;\n  float z = bw.z;\n  vec3 bt = (diffuseSPH[0] + diffuseSPH[1] * x + diffuseSPH[2] * y + diffuseSPH[3] * z + diffuseSPH[4] * z * x + diffuseSPH[5] * y * z + diffuseSPH[6] * y * x + diffuseSPH[7] * (3. * z * z - 1.) + diffuseSPH[8] * (x * x - y * y));\n  if(length(hdrHSV) > .0) {\n    bt = hsv_apply(bt, hdrHSV);\n  }\n  return max(bt, vec3(.0));\n}\nvec3 bx(const in vec4 by, const in float bz) {\n  if(bz <= .0)\n    return by.rgb;\n  return bz * by.rgb * by.a;\n}\nfloat bA(const in float bB) {\n  return bB;\n}\nvec3 bC(const in float bD, const in vec3 D) {\n  vec3 bE = D;\n  float bF = prefilterMiplevel.x;\n  float bG = min(bF, bA(bD) * prefilterMiplevel.y);\n  vec3 bH = bx(textureCubeLod(prefilterMap, bE, bG), rgbmRange);\n  if(length(hdrHSV) > .0) {\n    return hsv_apply(bH, hdrHSV);\n  } else {\n    return bH;\n  }\n}\nvec3 bI(const in vec3 k, const in vec3 D, const in float bJ) {\n  float bK = 1. - bJ;\n  float bL = bK * (sqrt(bK) + bJ);\n  return mix(k, D, bL);\n}\nvec3 bM(const in vec3 bv, const in vec3 bN, const in float bO, const in vec3 bP) {\n  vec3 D = reflect(-bN, bv);\n  D = bI(bv, D, bO);\n  vec3 bQ = bC(bO, uEnvironmentTransform * D);\n  float bR = clamp(1. + dot(D, bP), .0, 1.);\n  bQ *= bR * bR;\n  return bQ;\n}\n#else\nvec3 bM(const in vec3 bv, const in vec3 bN, const in float bO, const in vec3 bP) {\n  return ambientColor;\n}\n#endif\nvarying highp vec3 vViewPosition;\nvec3 bS(vec3 bT, float bU) {\n  float bV = max(1. - bU, .0);\n  return bT + (1. - bT) * pow(bV, 5.);\n}\nfloat bW(float bT, float bU) {\n  float bV = max(1. - bU, .0);\n  return bT + (1. - bT) * pow(bV, 5.);\n}\nvec3 bX(const in vec3 by) {\n  return vec3(by.r < .0031308 ? by.r * 12.92 : 1.055 * pow(by.r, 1. / 2.4) - .055, by.g < .0031308 ? by.g * 12.92 : 1.055 * pow(by.g, 1. / 2.4) - .055, by.b < .0031308 ? by.b * 12.92 : 1.055 * pow(by.b, 1. / 2.4) - .055);\n}\nvoid main() {\n  glFragColor = vec4(vec3(1.), opacity);\n#ifdef HAS_BASECOLOR_MAP\nvec4 bY = GET_BASEMAP(computeTexCoord(vTexCoord));\n#ifdef GAMMA_INPUT\nbY.xyz *= bY.xyz;\n#endif\nglFragColor = glFragColor * bY;\n#endif\n#ifdef ALPHATEST\nif(glFragColor.a < ALPHATEST)\n    discard;\n  \n#endif\nfloat bZ = 1.;\n  vec3 ca = dFdx(vViewPosition);\n  vec3 cb = dFdy(vViewPosition);\n  vec3 bv = normalize(cross(ca, cb));\n  vec3 cc;\n  if(projMatrix[3][3] == .0) {\n    cc = normalize(vViewPosition);\n  } else {\n    cc = vec3(.0, .0, 1.);\n  }\n  bv = faceforward(bv, -cc, bv);\n  vec3 cd = bv;\n#ifdef HAS_NORMAL_MAP\nbv = c(-vViewPosition, bv);\n#endif\nvec3 ce = vec3(.0);\n  vec3 cf = vec3(.0);\n#ifdef HAS_IBL_LIGHTING\nvec3 bp = mat3(viewMatrixInverse) * bv;\n  vec3 cg = glFragColor.rgb * bu(bp) * .5;\n  cg = bn(cg, bp);\n  ce += n(baseColorFactor.rgb) * cg;\n#endif\nvec3 ch = v();\n#ifdef METAL\nglFragColor.xyz = glFragColor.xyz * (n(ch) + ce + n(baseColorFactor.rgb) + cf);\n#else\nglFragColor.xyz = glFragColor.xyz * (n(ch) + ce + n(baseColorFactor.rgb)) + cf;\n#endif\nvec3 ci;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat cj = shadow_computeShadow();\n  ci = shadow_blend(ci, cj).rgb;\n#endif\n#ifdef HAS_COLOR\nglFragColor = glFragColor * vColor;\n#endif\nglFragColor.rgb += ci;\n  glFragColor.rgb = bX(glFragColor.rgb);\n#if defined(HAS_IBL_LIGHTING)\nvec3 ck;\n#if defined(HAS_NORMAL_MAP)\n#ifdef ENVMAP_MODE_REFLECTION\nck = reflect(-cc, bv);\n#else\nck = refract(-cc, bv, 1.);\n#endif\n#else\nck = reflect(-cc, bv);\n#endif\nck = mat3(viewMatrixInverse) * ck;\n  float cl = 1.;\n  vec3 cm;\n#ifdef HAS_IBL_LIGHTING\ncm = vec3(.0);\n#elif\ncm = ambientColor;\n#endif\ncm *= cl;\n  float bV = dot(cc, bv);\n  if(bV < -1e-2 || reflectivity == .0)\n    bV = 1.;\n  else\n    bV = max(1e-6, bV);\n  vec3 cn;\n  vec3 co = u();\n#ifdef METAL\ncn = n(co);\n#else\ncn = bS(n(co), bV) * (1. - envRotationSin);\n  glFragColor.a = mix(glFragColor.a, bW(glFragColor.a, bV), reflectivity) * envRotationCos;\n  float cp = pow(1. - bV * .5, 5.);\n  float cq = (28. / 23.) * (1. - cp) * (1. - cp);\n  glFragColor.rgb *= cq * (1. - n(co));\n#endif\nglFragColor.rgb += cm.rgb * bZ * cn.rgb;\n#endif\n#if defined(TONEMAP_OUTPUT)\n#if TONEMAP_OUTPUT == 1\nglFragColor.rgb = bi(exposureBias * glFragColor.rgb);\n#elif TONEMAP_OUTPUT == 2\nglFragColor.rgb = bh(exposureBias * glFragColor.rgb);\n#endif\n#endif\nglFragColor.rgb = mix(glFragColor.rgb, themingColor.rgb, themingColor.a);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:o,defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}}),this.version=300}},TaaPass:Hn$4,Texture2D:en$5,TextureCube:class extends z$6{onLoad(e){const n=this.config;if(!n)return;const t=this._createFaces(e);n.faces=t.map((e=>e.data)),this._updateREGL()}createREGLTexture(e){return e.cube(this.config)}_createFaces(){return[]}},ToonMaterial:class extends Ie$5{constructor(e){super(e,we$5)}},ToonShader:class extends bn$4{constructor(e={}){super({vert:xn$4,frag:gn$4,defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}})}},Util:N$6,WaterShader:class extends vn$4{constructor(e={}){super({vert:"precision highp float;\nprecision highp sampler2D;\nconst float c = 3.141592653589793;\nuniform mat4 projMatrix;\nuniform mat4 viewMatrix;\nuniform mat4 modelMatrix;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nattribute vec3 aNormal;\nvarying vec2 vuv;\nvarying vec3 vpos;\nvarying vec3 vnormal;\nvarying mat3 vtbnMatrix;\nvec4 d(mat4 e, mat4 f, vec3 h) {\n  return e * modelMatrix * f * vec4(h, 1.);\n}\nvec3 i(in vec3 h, in vec3 j) {\n  return normalize(h + j);\n}\nmat3 k(in vec3 l) {\n  vec3 t = normalize(cross(vec3(.0, .0, 1.), l));\n  vec3 b = normalize(cross(l, t));\n  return mat3(t, b, l);\n}\nvoid m() {\n  \n}\nvoid main(void) {\n  vuv = aTexCoord;\n  vpos = (modelMatrix * vec4(aPosition, 1.)).xyz;\n  vnormal = aNormal;\n  vtbnMatrix = k(vnormal);\n  gl_Position = d(projMatrix, viewMatrix, vpos);\n  m();\n}",frag:"precision highp float;\nprecision highp sampler2D;\nuniform sampler2D texWaveNormal;\nuniform sampler2D texWavePerturbation;\nuniform vec3 octaveTextureRepeat;\nuniform vec4 waveParams;\nuniform vec2 waveDirection;\nuniform vec4 waterColor;\nuniform vec3 lightingDirection;\nuniform vec3 lightingIntensity;\nuniform vec3 camPos;\nuniform float timeElapsed;\nvarying vec2 vuv;\nvarying vec3 vpos;\nvarying vec3 vnormal;\nvarying mat3 vtbnMatrix;\nconst vec2 c = vec2(6. / 25., 5. / 24.);\nvec2 d(sampler2D e, vec2 f) {\n  return 2. * texture2D(e, f).rg - 1.;\n}\nfloat h(vec2 f) {\n  return texture2D(texWavePerturbation, f).b;\n}\nvec3 i(sampler2D e, vec2 f) {\n  return 2. * texture2D(e, f).rgb - 1.;\n}\nfloat j(vec2 f, float k) {\n  return fract(k);\n}\nfloat l(vec2 f, float k) {\n  float m = j(f, k);\n  return 1. - abs(1. - 2. * m);\n}\nvec3 n(sampler2D o, vec2 f, float k, float u) {\n  float v = waveParams[2];\n  float A = waveParams[3];\n  vec2 B = d(o, f) * v;\n  float m = j(f, k + u);\n  float C = l(f, k + u);\n  vec2 D = f;\n  D -= B * (m + A);\n  D += u;\n  D += (k - m) * c;\n  return vec3(D, C);\n}\nconst float E = .3737;\nconst float F = 7.77;\nvec3 G(sampler2D H, sampler2D I, vec2 f, vec2 J, float k) {\n  float K = waveParams[0];\n  vec2 L = k * -J;\n  float M = h(f * E) * F;\n  vec3 N = n(I, f + L, k + M, .0);\n  vec3 O = n(I, f + L, k + M, .5);\n  vec3 P = i(H, N.xy) * N.z;\n  vec3 Q = i(H, O.xy) * O.z;\n  vec3 R = normalize(P + Q);\n  R.xy *= K;\n  R.z = sqrt(1. - dot(R.xy, R.xy));\n  return R;\n}\nvec3 S(vec2 f, float k) {\n  float T = waveParams[1];\n  return G(texWaveNormal, texWavePerturbation, f * T, waveDirection, k);\n}\nconst float U = 3.141592653589793;\nconst float V = 1. / U;\nconst float W = .3183098861837907;\nconst float X = 1.570796326794897;\nstruct PBRShadingWater {\n  float NdotL;\n  float NdotV;\n  float NdotH;\n  float VdotH;\n  float LdotH;\n  float VdotN;\n};\nfloat Y = 2.2;\nvec3 Z(float ba, vec3 bb, float bc) {\n  return bb + (bc - bb) * pow(1. - ba, 5.);\n}\nfloat bd(float be, float bf) {\n  float bg = bf * bf;\n  float bh = be * be;\n  float bi = pow((bh * (bg - 1.) + 1.), Y) * U;\n  return bg / bi;\n}\nfloat bj(float bk) {\n  return .25 / (bk * bk);\n}\nvec3 bl(in PBRShadingWater bm, float bf, vec3 bn, float bo) {\n  vec3 bp = Z(bm.VdotH, bn, bo);\n  float bq = bd(bm.NdotH, bf);\n  float br = bj(bm.LdotH);\n  return (bq * br) * bp;\n}\nvec3 bs(const vec3 x) {\n  return (x * (2.51 * x + .03)) / (x * (2.43 * x + .59) + .14);\n}\nconst float bt = 2.2;\nconst float bu = .4545454545;\nvec4 bv(vec4 bw) {\n  return vec4(pow(bw.rgb, vec3(bu)), bw.w);\n}\nvec3 bx(vec3 bw) {\n  return pow(bw, vec3(bt));\n}\nconst vec3 by = vec3(.02, 1., 5.);\nconst vec2 bz = vec2(.02, .1);\nconst float bf = .06;\nconst vec3 bA = vec3(0, .6, .9);\nconst vec3 bB = vec3(.72, .92, 1.);\nPBRShadingWater bC;\nvec3 bD(in float bE, in vec3 bF, in vec3 bG) {\n  float bH = pow((1. - bE), by[2]);\n  return mix(bG, bF, bH);\n}\nvec3 bI(in vec3 bJ, in vec3 bK, in vec3 bL, vec3 bw, in vec3 bM, in vec3 bN, in float bO) {\n  vec3 bP = bx(bw);\n  vec3 bQ = normalize(bL + bK);\n  bC.NdotL = clamp(dot(bJ, bL), .0, 1.);\n  bC.NdotV = clamp(dot(bJ, bK), .001, 1.);\n  bC.VdotN = clamp(dot(bK, bJ), .001, 1.);\n  bC.NdotH = clamp(dot(bJ, bQ), .0, 1.);\n  bC.VdotH = clamp(dot(bK, bQ), .0, 1.);\n  bC.LdotH = clamp(dot(bL, bQ), .0, 1.);\n  float bR = max(dot(bN, bK), .0);\n  vec3 bS = bx(bB);\n  vec3 bT = bx(bA);\n  vec3 bB = bD(bR, bS, bT);\n  float bU = max(dot(bN, bL), .0);\n  bB *= .1 + bU * .9;\n  float bV = clamp(bO, .8, 1.);\n  vec3 bW = Z(bC.VdotN, vec3(by[0]), by[1]) * bB * bV;\n  vec3 bX = bP * mix(bB, bU * bM * V, 2. / 3.) * bV;\n  vec3 bY = vec3(.0);\n  if(bR > .0 && bU > .0) {\n    vec3 bZ = bl(bC, bf, vec3(bz[0]), bz[1]);\n    vec3 ca = bM * V * bO;\n    bY = bC.NdotL * ca * bZ;\n  }\n  return bs(bW + bX + bY);\n}\nvoid main() {\n  vec3 bN = vnormal;\n  vec3 cb = S(vuv, timeElapsed);\n  vec3 bJ = normalize(vtbnMatrix * cb);\n  vec3 bK = -normalize(vpos - camPos);\n  vec3 bL = normalize(-lightingDirection);\n  float bO = 1.;\n  vec4 cc = vec4(bI(bJ, bK, bL, waterColor.rgb, lightingIntensity, bN, bO), waterColor.w);\n  gl_FragColor = bv(cc);\n}",defines:e.defines||{},extraCommandProps:e.extraCommandProps||{}})}},WireFrameMaterial:class extends Ce$5{constructor(e){super(e,Oe$5)}},WireframeShader:class extends vn$4{constructor(e={}){let t=e.extraCommandProps||{};const r=[];t=v$3({},t,{blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},sample:{alpha:!0}}),super({vert:"#include <gl2_vert>\nattribute vec3 aPosition;\nattribute vec3 aBarycentric;\nvarying vec3 vBarycentric;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 projMatrix;\nuniform mat4 positionMatrix;\nvarying vec3 vPosition;\n#include <get_output>\nvoid main() {\n  mat4 c = getPositionMatrix();\n  vec4 d = getPosition(aPosition);\n#ifdef HAS_MASK_EXTENT\ngl_Position = projMatrix * getMaskPosition(c * d, modelMatrix);\n#else\ngl_Position = projMatrix * modelViewMatrix * c * d;\n#endif\nvBarycentric = aBarycentric;\n  vPosition = aPosition;\n}",frag:"#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#extension GL_OES_standard_derivatives : enable\n#endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nvarying vec3 vBarycentric;\nuniform float time;\nuniform float thickness;\nuniform float secondThickness;\nuniform float dashRepeats;\nuniform float dashLength;\nuniform bool dashOverlap;\nuniform bool dashEnabled;\nuniform bool dashAnimate;\nuniform bool seeThrough;\nuniform bool insideAltColor;\nuniform bool dualStroke;\nuniform bool squeeze;\nuniform float squeezeMin;\nuniform float squeezeMax;\nuniform vec4 stroke;\nuniform vec4 fill;\nuniform float opacity;\nuniform bool noiseEnable;\nvarying vec3 vPosition;\n#ifdef HAS_INSTANCE\nvarying vec4 vInstanceColor;\n#endif\n#include <mask_frag>\n#define F4 0.309016994374947451\n#define halfDist 0.5\nvec4 c(vec4 x) {\n  return x - floor(x * (1. / 289.)) * 289.;\n}\nfloat c(float x) {\n  return x - floor(x * (1. / 289.)) * 289.;\n}\nvec4 d(vec4 x) {\n  return c((x * 34. + 1.) * x);\n}\nfloat d(float x) {\n  return c((x * 34. + 1.) * x);\n}\nvec4 e(vec4 r) {\n  return 1.79284291400159 - .85373472095314 * r;\n}\nfloat e(float r) {\n  return 1.79284291400159 - .85373472095314 * r;\n}\nvec4 f(float h, vec4 i) {\n  const vec4 k = vec4(1., 1., 1., -1.);\n  vec4 p, s;\n  p.xyz = floor(fract(vec3(h) * i.xyz) * 7.) * i.z - 1.;\n  p.w = 1.5 - dot(abs(p.xyz), k.xyz);\n  s = vec4(lessThan(p, vec4(.0)));\n  p.xyz = p.xyz + (s.xyz * 2. - 1.) * s.www;\n  return p;\n}\nfloat l(vec4 m) {\n  const vec4 n = vec4(.138196601125011, .276393202250021, .414589803375032, -.447213595499958);\n  vec4 o = floor(m + dot(m, vec4(F4)));\n  vec4 u = m - o + dot(o, n.xxxx);\n  vec4 A;\n  vec3 B = step(u.yzw, u.xxx);\n  vec3 D = step(u.zww, u.yyz);\n  A.x = B.x + B.y + B.z;\n  A.yzw = 1. - B;\n  A.y += D.x + D.y;\n  A.zw += 1. - D.xy;\n  A.z += D.z;\n  A.w += 1. - D.z;\n  vec4 E = clamp(A, .0, 1.);\n  vec4 F = clamp(A - 1., .0, 1.);\n  vec4 G = clamp(A - 2., .0, 1.);\n  vec4 H = u - G + n.xxxx;\n  vec4 I = u - F + n.yyyy;\n  vec4 J = u - E + n.zzzz;\n  vec4 K = u + n.wwww;\n  o = c(o);\n  float L = d(d(d(d(o.w) + o.z) + o.y) + o.x);\n  vec4 M = d(d(d(d(o.w + vec4(G.w, F.w, E.w, 1.)) + o.z + vec4(G.z, F.z, E.z, 1.)) + o.y + vec4(G.y, F.y, E.y, 1.)) + o.x + vec4(G.x, F.x, E.x, 1.));\n  vec4 i = vec4(1. / 294., 1. / 49., 1. / 7., .0);\n  vec4 N = f(L, i);\n  vec4 O = f(M.x, i);\n  vec4 P = f(M.y, i);\n  vec4 Q = f(M.z, i);\n  vec4 R = f(M.w, i);\n  vec4 S = e(vec4(dot(N, N), dot(O, O), dot(P, P), dot(Q, Q)));\n  N *= S.x;\n  O *= S.y;\n  P *= S.z;\n  Q *= S.w;\n  R *= e(dot(R, R));\n  vec3 T = max(.6 - vec3(dot(u, u), dot(H, H), dot(I, I)), .0);\n  vec2 U = max(.6 - vec2(dot(J, J), dot(K, K)), .0);\n  T = T * T;\n  U = U * U;\n  return 49. * (dot(T * T, vec3(dot(N, u), dot(O, H), dot(P, I))) + dot(U * U, vec2(dot(Q, J), dot(R, K))));\n}\nconst float V = 3.14159265359;\nfloat W(float X, float Y) {\n  float Z = fwidth(Y) * halfDist;\n  return smoothstep(X - Z, X + Z, Y);\n}\nvec4 ba(vec3 bb) {\n  float bc = min(min(bb.x, bb.y), bb.z);\n  float bd = .0;\n  if(noiseEnable)\n    bd += l(vec4(vPosition.xyz * 80.0, time * halfDist)) * .12;\n  bc += bd;\n  float be = max(bb.x, bb.y);\n  if(bb.y < bb.x && bb.y < bb.z) {\n    be = 1. - be;\n  }\n  float bf = thickness;\n  if(squeeze) {\n    bf *= mix(squeezeMin, squeezeMax, (1. - sin(be * V)));\n  }\n  if(dashEnabled) {\n    float bg = 1. / dashRepeats * dashLength / 2.;\n    if(!dashOverlap) {\n      bg += 1. / dashRepeats / 2.;\n    }\n    if(dashAnimate) {\n      bg += time * .22;\n    }\n    float bh = fract((be + bg) * dashRepeats);\n    bf *= 1. - W(dashLength, bh);\n  }\n  float bi = 1. - W(bf, bc);\n#ifdef HAS_INSTANCE\nvec4 bj = vInstanceColor;\n#else\nvec4 bj = stroke;\n#endif\nvec4 bk = vec4(.0);\n  if(seeThrough) {\n    bk = vec4(bj.xyz, bi);\n    if(insideAltColor && !gl_FrontFacing) {\n      bk.rgb = fill.xyz;\n    }\n  } else {\n    vec3 bl = mix(fill.xyz, bj.xyz, bi);\n    bk.a = fill.a;\n    if(dualStroke) {\n      float bm = 1. - W(secondThickness, bc);\n      vec3 bn = mix(fill.xyz, stroke.xyz, abs(bm - bi));\n      bk.rgb = bn;\n    } else {\n      bk.rgb = bl;\n    }\n  }\n  return bk;\n}\nvoid main() {\n  glFragColor = ba(vBarycentric);\n  glFragColor *= halfDist + opacity;\n#ifdef HAS_MASK_EXTENT\nglFragColor = setMask(glFragColor);\n#endif\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:(e,t)=>multiply$5(r,t.viewMatrix,t.modelMatrix)}],extraCommandProps:t}),this.version=300}},earcut:ci$4,pbr:fi$4}),isArray=Array.isArray,keyList=Object.keys,hasProp=Object.prototype.hasOwnProperty,fastDeepEqual=function equal(a,b){if(a===b)return!0;if(a&&b&&"object"==typeof a&&"object"==typeof b){var i,length,key,arrA=isArray(a),arrB=isArray(b);if(arrA&&arrB){if((length=a.length)!=b.length)return!1;for(i=length;0!=i--;)if(!equal(a[i],b[i]))return!1;return!0}if(arrA!=arrB)return!1;var dateA=a instanceof Date,dateB=b instanceof Date;if(dateA!=dateB)return!1;if(dateA&&dateB)return a.getTime()==b.getTime();var regexpA=a instanceof RegExp,regexpB=b instanceof RegExp;if(regexpA!=regexpB)return!1;if(regexpA&&regexpB)return a.toString()==b.toString();var keys=keyList(a);if((length=keys.length)!==keyList(b).length)return!1;for(i=length;0!=i--;)if(!hasProp.call(b,keys[i]))return!1;for(i=length;0!=i--;)if(!equal(a[key=keys[i]],b[key]))return!1;return!0}return a!=a&&b!=b};
/*!
	 * @maptalks/fusiongl v0.6.9
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.com
	 */
function i$2(t){for(let i=1;i<arguments.length;i++){const r=arguments[i];for(const i in r)t[i]=r[i]}return t}function r$1(t,...r){for(let e=0;e<r.length;e++)i$2(t,r[e])}class e$2{constructor(t){this.context=t,this.COLOR_ATTACHMENT0_WEBGL=36064,this.COLOR_ATTACHMENT1_WEBGL=36065,this.COLOR_ATTACHMENT2_WEBGL=36066,this.COLOR_ATTACHMENT3_WEBGL=36067,this.COLOR_ATTACHMENT4_WEBGL=36068,this.COLOR_ATTACHMENT5_WEBGL=36069,this.COLOR_ATTACHMENT6_WEBGL=36070,this.COLOR_ATTACHMENT7_WEBGL=36071,this.COLOR_ATTACHMENT8_WEBGL=36072,this.COLOR_ATTACHMENT9_WEBGL=36073,this.COLOR_ATTACHMENT10_WEBGL=577040,this.COLOR_ATTACHMENT11_WEBGL=577041,this.COLOR_ATTACHMENT12_WEBGL=577042,this.COLOR_ATTACHMENT13_WEBGL=577043,this.COLOR_ATTACHMENT14_WEBGL=577044,this.COLOR_ATTACHMENT15_WEBGL=577045,this.DRAW_BUFFER0_WEBGL=34853,this.DRAW_BUFFER1_WEBGL=34854,this.DRAW_BUFFER2_WEBGL=34855,this.DRAW_BUFFER3_WEBGL=34856,this.DRAW_BUFFER4_WEBGL=34857,this.DRAW_BUFFER5_WEBGL=34858,this.DRAW_BUFFER6_WEBGL=34859,this.DRAW_BUFFER7_WEBGL=34860,this.DRAW_BUFFER8_WEBGL=34861,this.DRAW_BUFFER9_WEBGL=34862,this.DRAW_BUFFER10_WEBGL=34863,this.DRAW_BUFFER11_WEBGL=34864,this.DRAW_BUFFER12_WEBGL=34865,this.DRAW_BUFFER13_WEBGL=34866,this.DRAW_BUFFER14_WEBGL=34867,this.DRAW_BUFFER15_WEBGL=34868,this.MAX_COLOR_ATTACHMENTS_WEBGL=36063,this.MAX_DRAW_BUFFERS_WEBGL=2178}drawBuffersWEBGL(){return this.context.drawBuffers.apply(this.context,arguments)}}class s{constructor(t){this.context=t,this.VERTEX_ARRAY_BINDING_OES=34229}createVertexArrayOES(){return this.context.createVertexArray()}deleteVertexArrayOES(){return this.context.deleteVertexArray.apply(this.context,arguments)}isVertexArrayOES(){return this.context.isVertexArray.apply(this.context,arguments)}bindVertexArrayOES(){return this.context.bindVertexArray.apply(this.context,arguments)}}class h$1{constructor(t){this.context=t,this.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE=35070}drawArraysInstancedANGLE(){return this.context.drawArraysInstanced.apply(this.context,arguments)}drawElementsInstancedANGLE(){return this.context.drawElementsInstanced.apply(this.context,arguments)}vertexAttribDivisorANGLE(){return this.context.vertexAttribDivisor.apply(this.context,arguments)}}const n={webgl_depth_texture:{UNSIGNED_INT_24_8_WEBGL:34042},oes_element_index_uint:{},oes_texture_float:{},oes_texture_half_float:{HALF_FLOAT_OES:36193},ext_color_buffer_float:{},oes_standard_derivatives:{},ext_frag_depth:{},ext_blend_minmax:{MIN_EXT:32775,MAX_EXT:32776},ext_shader_texture_lod:{}},u$2={has(t,i){const r=t.t;return!(!r&&!t.i.getExtension(i))&&(i=i.toLowerCase(),r&&n[i]||"webgl_draw_buffers"===i||"oes_vertex_array_object"===i||"angle_instanced_arrays"===i)},mock:(t,i)=>(i=i.toLowerCase(),n[i]?t.t?("oes_texture_float"!==i&&"oes_texture_half_float"!==i||t.i.getExtension("EXT_color_buffer_float"),n[i]):t.i.getExtension(i):"webgl_draw_buffers"===i?new e$2(t):"oes_vertex_array_object"===i?new s(t):"angle_instanced_arrays"===i?new h$1(t):null),getInternalFormat:(t,i,r)=>6402===i?33190:34041===i?35056:36193===r&&i===t.RGBA?34842:36193===r&&i===t.RGB?34843:r===t.FLOAT&&i===t.RGBA?34836:r===t.FLOAT&&i===t.RGB?34837:i,getTextureType:(t,i)=>36193===i?t.HALF_FLOAT:i};let o=1;class a{constructor(t){this.uid=o++,this.states=function(t){return{scissor:[0,0,t.canvas.width,t.canvas.height],viewport:[0,0,t.canvas.width,t.canvas.height],blendColor:[0,0,0,0],blendEquationSeparate:[t.FUNC_ADD,t.FUNC_ADD],blendFuncSeparate:[t.ONE,t.ZERO,t.ONE,t.ZERO],clearColor:[0,0,0,0],clearDepth:[1],clearStencil:[0],colorMask:[!0,!0,!0,!0],cullFace:[t.BACK],depthFunc:[t.LESS],depthMask:[!0],depthRange:[0,1],capabilities:{3042:!1,2884:!1,2929:!1,3024:!1,32823:!1,32926:!1,32928:!1,3089:!1,2960:!1},frontFace:[t.CCW],hint:{33170:[t.DONT_CARE],35723:[t.DONT_CARE]},lineWidth:[1],pixelStorei:{3333:[4],3317:[4],37440:[!1],37441:[!1],37443:[t.BROWSER_DEFAULT_WEBGL]},polygonOffset:[0,0],sampleCoverage:[1,!1],stencilFuncSeparate:{1028:[t.ALWAYS,0,4294967295],1029:[t.ALWAYS,0,4294967295]},stencilMaskSeparate:{1028:[4294967295],1029:[4294967295]},stencilOpSeparate:{1028:[t.KEEP,t.KEEP,t.KEEP],1029:[t.KEEP,t.KEEP,t.KEEP]},program:null,framebuffer:{36160:null,36008:null,36009:null},renderbuffer:{36161:null},textures:{active:-1,units:function(){const i=[],r=t.getParameter(t.MAX_COMBINED_TEXTURE_IMAGE_UNITS);for(let t=0;t<r;t++)i.push({3553:null,34067:null});return i[-1]={3553:null,34067:null},i}()},attributes:{},arrayBuffer:null,elementArrayBuffer:null}}(t),this.i=t,this.i._fusiongl_drawCalls=0,this.t="undefined"!=typeof WebGL2RenderingContext&&this.i instanceof WebGL2RenderingContext;const i=Object.getPrototypeOf(this);Object.setPrototypeOf(i,this.t?WebGL2RenderingContext.prototype:WebGLRenderingContext.prototype),this.s=t.getParameter(t.MAX_VERTEX_ATTRIBS)}get canvas(){return this.i.canvas}get drawingBufferWidth(){return this.i.drawingBufferWidth}get drawingBufferHeight(){return this.i.drawingBufferHeight}get gl(){return this.i}get buffersOES(){return this.h||(this.h=this.i.getExtension("WEBGL_draw_buffers")),this.h}get vaoOES(){return this.u||(this.u=this.i.getExtension("OES_vertex_array_object")),this.u}get angleOES(){return this.o||(this.o=this.i.getExtension("ANGLE_instanced_arrays")),this.o}get standOES(){return this.l||(this.l=this.i.getExtension("OES_standard_derivatives")),this.l}attachShader(t,i){return this.i.attachShader(t,i)}shaderSource(t,i){return this.i.shaderSource(t,i)}compileShader(t){return this.i.compileShader(t)}createShader(t){return this.i.createShader(t)}createProgram(){return this.i.createProgram()}deleteProgram(t){return this.states.program===t&&(this.states.program=null),this.i.deleteProgram(t)}deleteShader(t){return this.i.deleteShader(t)}detachShader(t,i){return this.i.detachShader(t,i)}getAttachedShaders(t){return this.i.getAttachedShaders(t)}linkProgram(t){return this.i.linkProgram(t)}makeXRCompatible(){return this.i.makeXRCompatible()}getShaderParameter(t,i){return this.i.getShaderParameter(t,i)}getShaderPrecisionFormat(t,i){return this.i.getShaderPrecisionFormat(t,i)}getShaderInfoLog(t){return this.i.getShaderInfoLog(t)}getShaderSource(t){return this.i.getShaderSource(t)}getProgramInfoLog(t){return this.i.getProgramInfoLog(t)}getProgramParameter(t,i){return this.i.getProgramParameter(t,i)}getError(){return this.i.getError()}getContextAttributes(){return this.i.getContextAttributes()}getExtension(t){return u$2.has(this,t)?u$2.mock(this,t):this.i.getExtension(t)}getSupportedExtensions(){return this.i.getSupportedExtensions()}getParameter(t){return this.i.getParameter(t)}isEnabled(t){return this.i.isEnabled(t)}isProgram(t){return this.i.isProgram(t)}isShader(t){return this.i.isShader(t)}validateProgram(t){return this.i.validateProgram(t)}clear(t){return this.m(),this.i.clear(t)}drawArrays(t,i,r){return this.m(),this.states.activeAttribType=0,this.g(),this.i.drawArrays(t,i,r)}drawElements(t,i,r,e){return this.m(),this.states.activeAttribType=0,this.g(),this.i.drawElements(t,i,r,e)}drawBuffers(t){return this.m(),this.states.activeAttribType=0,this.g(),this.t?this.i.drawBuffers(t):this.buffersOES.drawBuffersWEBGL(t)}g(){this.i._fusiongl_drawCalls++}resetDrawCalls(){this.i._fusiongl_drawCalls=0}getDrawCalls(){return this.i._fusiongl_drawCalls}v(){const t=this.i,i=t.getParameter(t.CURRENT_PROGRAM),r=t.getProgramParameter(i,t.ACTIVE_ATTRIBUTES),e=[];for(let i=0;i<r;i++)e.push(t.getVertexAttrib(i,t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING));this._={buffers:e,elements:t.getParameter(t.ELEMENT_ARRAY_BUFFER_BINDING),framebuffer:t.getParameter(t.FRAMEBUFFER_BINDING)},window.DEBUGGING&&(console.log(this.uid,this._),console.log(this.uid,this.states.attributes),console.log(this.states.attributes[0].buffer===this._.buffers[0]),console.log(this.states.attributes[1].buffer===this._.buffers[1]),console.log(this.states.attributes[2].buffer===this._.buffers[2]))}finish(){return this.i.finish()}flush(){return this.m(),this.i.flush()}commit(){return this.m(),this.i.commit()}isContextLost(){return this.i.isContextLost()}getFragDataLocation(t,i){return this.i.getFragDataLocation(t,i)}createSampler(){return this.i.createSampler()}deleteSampler(){return this.i.deleteSampler()}bindSampler(){return this.i.bindSampler()}isSampler(){return this.i.isSampler()}getSamplerParameter(){return this.i.getSamplerParameter()}isQuery(t){return this.i.beginQuery(t)}beginQuery(t,i){return this.i.beginQuery(t,i)}deleteQuery(t){return this.i.query(t)}isTransformFeedback(t){return this.i.isTransformFeedback(t)}beginTransformFeedback(t){return this.i.beginTransformFeedback(t)}deleteTransformFeedback(t){return this.i.deleteTransformFeedback(t)}pauseTransformFeedback(){return this.i.pauseTransformFeedback()}resumeTransformFeedback(){return this.i.resumeTransformFeedback()}transformFeedbackVaryings(t,i,r){return this.i.transformFeedbackVaryings(t,i,r)}bindBufferBase(t,i,r){return this.i.bbindBufferBase(t,i,r)}bindBufferRange(t,i,r,e,s){return this.i.bindBufferRange(t,i,r,e,s)}bindTransformFeedback(t,i){return this.i.bindTransformFeedback(t,i)}fenceSync(t,i){return this.i.fenceSync(t,i)}isSync(t){return this.i.isSync(t)}deleteSync(t){return this.i.deleteSync(t)}clientWaitSync(t,i,r){return this.i.clientWaitSync(t,i,r)}waitSync(t,i,r){return this.i.waitSync(t,i,r)}getSyncParameter(t,i){return this.i.getSyncParameter(t,i)}getIndexedParameter(t,i){return this.i.getIndexedParameter(t,i)}}function f$2(t,i){const r=i.length;for(let e=0;e<r;e++)t[e]=i[e];return t}r$1(a.prototype,{bufferData(...t){return this.m(),this.i.bufferData(...t)},bufferSubData(...t){return this.m(),this.i.bufferSubData(...t)},createBuffer(){return this.i.createBuffer()},deleteBuffer(t){const i=this.states;i.arrayBuffer===t?i.arrayBuffer=null:i.elementArrayBuffer===t&&(i.elementArrayBuffer=null);const r=i.attributes;for(const i in r)r[i].buffer===t&&(r[i].buffer=null);return this.i.deleteBuffer(t)},getBufferParameter(t,i){return this.m(),this.i.getBufferParameter(t,i)},isBuffer(t){return this.i.isBuffer(t)},copyBufferSubData(t,i,r,e,s){return this.i.isBuffer(t,i,r,e,s)},readBuffer(t){return this.i.readBuffer(t)}}),r$1(a.prototype,{checkFramebufferStatus(t){return this.i.checkFramebufferStatus(t)},createFramebuffer(){return this.i.createFramebuffer()},deleteFramebuffer(t){const i=this.states.framebuffer;for(const r in i)i[r]===t&&(i[r]=null);return this.i.deleteFramebuffer(t)},framebufferRenderbuffer(t,i,r,e){return this.m(),this.i.framebufferRenderbuffer(t,i,r,e)},framebufferTexture2D(t,i,r,e,s){return this.m(),this.i.framebufferTexture2D(t,i,r,e,s)},getFramebufferAttachmentParameter(t,i,r){return this.m(),this.i.getFramebufferAttachmentParameter(t,i,r)},isFramebuffer(t){return this.i.isFramebuffer(t)},readPixels(t,i,r,e,s,h,n){return this.m(),this.i.readPixels(t,i,r,e,s,h,n)},blitFramebuffer(t,i,r,e,s,h,n,u,o,a){return this.m(),this.i.blitFramebuffer(t,i,r,e,s,h,n,u,o,a)}}),r$1(a.prototype,{createRenderbuffer(){return this.i.createRenderbuffer()},deleteRenderbuffer(t){const i=this.states.renderbuffer;for(const r in i)i[r]===t&&(i[r]=null);return this.i.deleteRenderbuffer(t)},getRenderbufferParameter(t,i){return this.m(),this.i.getRenderbufferParameter(t,i)},isRenderbuffer(t){return this.i.isRenderbuffer(t)},renderbufferStorage(t,i,r,e){return this.m(),this.i.renderbufferStorage(t,i,r,e)},renderbufferStorageMultisample(t,i,r,e,s){return this.m(),this.i.renderbufferStorageMultisample(t,i,r,e,s)}}),r$1(a.prototype,{scissor(t,i,r,e){this.m();const s=this.states.scissor;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.scissor(t,i,r,e))},viewport(t,i,r,e){this.m();const s=this.states.viewport;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.viewport(t,i,r,e))},blendColor(t,i,r,e){this.m();const s=this.states.blendColor;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.blendColor(t,i,r,e))},blendEquation(t){this.m();const i=this.states.blendEquationSeparate;i[0]===t&&i[1]===t||(i[0]=t,i[1]=t,this.i.blendEquation(t))},blendEquationSeparate(t,i){this.m();const r=this.states.blendEquationSeparate;r[0]===t&&r[1]===i||(r[0]=t,r[1]=i,this.i.blendEquationSeparate(t,i))},blendFunc(t,i){this.m();const r=this.states.blendFuncSeparate;r[0]===t&&r[2]===t&&r[1]===i&&r[3]===i||(r[0]=t,r[1]=i,r[2]=t,r[3]=i,this.i.blendFunc(t,i))},blendFuncSeparate(t,i,r,e){this.m();const s=this.states.blendFuncSeparate;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.blendFuncSeparate(t,i,r,e))},clearColor(t,i,r,e){this.m();const s=this.states.clearColor;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.clearColor(t,i,r,e))},clearDepth(t){this.m();const i=this.states.clearDepth;i[0]!==t&&(i[0]=t,this.i.clearDepth(t))},clearStencil(t){this.m();const i=this.states.clearStencil;i[0]!==t&&(i[0]=t,this.i.clearStencil(t))},colorMask(t,i,r,e){this.m();const s=this.states.colorMask;s[0]===t&&s[1]===i&&s[2]===r&&s[3]===e||(s[0]=t,s[1]=i,s[2]=r,s[3]=e,this.i.colorMask(t,i,r,e))},cullFace(t){this.m();const i=this.states.cullFace;i[0]!==t&&(i[0]=t,this.i.cullFace(t))},depthFunc(t){this.m();const i=this.states.depthFunc;i[0]!==t&&(i[0]=t,this.i.depthFunc(t))},depthMask(t){this.m();const i=this.states.depthMask;i[0]!==t&&(i[0]=t,this.i.depthMask(t))},depthRange(t,i){this.m();const r=this.states.depthRange;r[0]===t&&r[1]===i||(r[0]=t,r[1]=i,this.i.depthRange(t,i))},disable(t){this.m();const i=this.states.capabilities;i[t]&&(i[t]=!1,this.i.disable(t))},enable(t){this.m();const i=this.states.capabilities;i[t]||(i[t]=!0,this.i.enable(t))},frontFace(t){this.m();const i=this.states.frontFace;i[0]!==t&&(i[0]=t,this.i.frontFace(t))},hint(t,i){this.m();const r=this.states.hint;r[t][0]!==i&&(r[t][0]=i,this.i.hint(t,i))},lineWidth(t){this.m();const i=this.states.lineWidth;i[0]!==t&&(i[0]=t,this.i.lineWidth(t))},pixelStorei(t,i){this.m();const r=this.states.pixelStorei;r[t]!==i&&(r[t]&&(r[t][0]=i),this.i.pixelStorei(t,i))},polygonOffset(t,i){this.m();const r=this.states.polygonOffset;r[0]===t&&r[1]===i||(r[0]=t,r[1]=i,this.i.polygonOffset(t,i))},sampleCoverage(t,i){this.m();const r=this.states.sampleCoverage;r[0]===t&&r[1]===i||(r[0]=t,r[1]=i,this.i.sampleCoverage(t,i))},stencilFunc(t,i,r){this.m();const e=this.states.stencilFuncSeparate,s=this.i;e[s.FRONT][0]===t&&e[s.FRONT][1]===i&&e[s.FRONT][2]===r&&e[s.BACK][0]===t&&e[s.BACK][1]===i&&e[s.BACK][2]===r||(e[s.FRONT][0]=e[s.BACK][0]=t,e[s.FRONT][1]=e[s.BACK][1]=i,e[s.FRONT][2]=e[s.BACK][2]=r,this.i.stencilFunc(t,i,r))},stencilFuncSeparate(t,i,r,e){if(this.m(),t===this.i.FRONT_AND_BACK)return void this.stencilFunc(i,r,e);const s=this.states.stencilFuncSeparate;s[t][0]===i&&s[t][1]===r&&s[t][2]===e||(s[t][0]=i,s[t][1]=r,s[t][2]=e,this.i.stencilFuncSeparate(t,i,r,e))},stencilMask(t){this.m();const i=this.i,r=this.states.stencilMaskSeparate;r[i.FRONT][0]===t&&r[i.BACK][0]===t||(r[i.FRONT][0]=t,r[i.BACK][0]=t,this.i.stencilMask(t))},stencilMaskSeparate(t,i){if(this.m(),t===this.i.FRONT_AND_BACK)return void this.stencilMask(i);const r=this.states.stencilMaskSeparate;r[t][0]!==i&&(r[t][0]=i,this.i.stencilMaskSeparate(t,i))},stencilOp(t,i,r){this.m();const e=this.states.stencilOpSeparate,s=this.i;e[s.FRONT][0]===t&&e[s.FRONT][1]===i&&e[s.FRONT][2]===r&&e[s.BACK][0]===t&&e[s.BACK][1]===i&&e[s.BACK][2]===r||(e[s.FRONT][0]=e[s.BACK][0]=t,e[s.FRONT][1]=e[s.BACK][1]=i,e[s.FRONT][2]=e[s.BACK][2]=r,this.i.stencilOp(t,i,r))},stencilOpSeparate(t,i,r,e){if(this.m(),t===this.i.FRONT_AND_BACK)return void this.stencilOp(i,r,e);const s=this.states.stencilOpSeparate;s[t][0]===i&&s[t][1]===r&&s[t][2]===e||(s[t][0]=i,s[t][1]=r,s[t][2]=e,this.i.stencilOpSeparate(t,i,r,e))},bindFramebuffer(t,i){this.m();const r=this.states.framebuffer;r[t]!==i&&(r[t]=i,this.i.bindFramebuffer(t,i))},bindRenderbuffer(t,i){this.m();const r=this.states.renderbuffer;r[t]!==i&&(r[t]=i,this.i.bindRenderbuffer(t,i))},bindTexture(t,i){this.m();const r=this.states.textures;r.units[-1!==r.active?r.active-33984:-1][t]=i,this.i.bindTexture(t,i)},activeTexture(t){this.m();const i=this.i,r=this.states.textures,e=r.active;r.active=t,this.activeUnit!==t&&(i.activeTexture(t),this.activeUnit=t),-1===e&&(r.units[t-33984][i.TEXTURE_2D]=r.units[-1][i.TEXTURE_2D],r.units[t-33984][i.TEXTURE_CUBE_MAP]=r.units[-1][i.TEXTURE_CUBE_MAP],r.units[-1][i.TEXTURE_2D]=null,r.units[-1][i.TEXTURE_CUBE_MAP]=null)},useProgram(t){this.m();const i=this.states;i.program!==t&&(i.program=t,void 0===t.fid&&(t.fid=0),this.S(),this.i.useProgram(t))},S(){const t=this.states.program;if(!t)return;const i=t.cachedUniforms=t.cachedUniforms||{};for(const t in i)Array.isArray(i[t])?i[t].fill(null):i[t]=null},bindBuffer(t,i){this.m();const r=this.i,e=this.states;t===r.ELEMENT_ARRAY_BUFFER?e.elementArrayBuffer=i:e.arrayBuffer=i,r.bindBuffer(t,i)},bindVertexArray(t){this.m();const i=this.i,r=this.states;r.vao!==t&&(r.vao=t,this.t?i.bindVertexArray(t):this.vaoOES.bindVertexArrayOES(t))},vertexAttribPointer(t,i,r,e,s,h){this.m(),this.states.attributes[t]||(this.states.attributes[t]={enable:!0});const n=this.states.attributes[t];return n.buffer=this.states.arrayBuffer,n.args?(n.args[0]=t,n.args[1]=i,n.args[2]=r,n.args[3]=e,n.args[4]=s,n.args[5]=h):n.args=[t,i,r,e,s,h],this.i.vertexAttribPointer(t,i,r,e,s,h)},vertexAttribDivisor(t,i){return this.m(),this.states.attributes[t].divisor=i,this.t?this.i.vertexAttribDivisor(t,i):this.angleOES.vertexAttribDivisorANGLE(t,i)}},{m(){const t=this.i;if(t.p!==this)if(t.p){this.A(t.p.states),t.p=this}else t.p=this},A(i){if(!i)return;delete this.activeUnit;const r=this.states,e=this.i;let s=0;for(const h in r)if("capabilities"!==h&&"textures"!==h&&"attributes"!==h&&"arrayBuffer"!==h&&"elementArrayBuffer"!==h&&"vao"!==h)if("program"===h)r.program!==i.program&&(e.useProgram(r.program),r.program&&(s=e.getProgramParameter(r.program,e.ACTIVE_ATTRIBUTES)));else if("framebuffer"===h)for(const t in r[h])r[h][t]!==i[h][t]&&e.bindFramebuffer(+t,r[h][t]);else if("renderbuffer"===h)for(const t in r[h])r[h][t]!==i[h][t]&&e.bindRenderbuffer(+t,r[h][t]);else if(!fastDeepEqual(r[h],i[h]))if(Array.isArray(i[h]))e[h](...r[h]);else if(i[h])for(const s in r[h])fastDeepEqual(r[h][s],i[h][s])||e[h](+s,...r[h][s]);this.S();for(const t in r.capabilities)r.capabilities[t]!==i.capabilities[t]&&e[r.capabilities[t]?"enable":"disable"](+t);const h=r.textures,u=h.units,o=i.textures.units,a=h.active-e.TEXTURE0;for(let t=0;t<u.length;t++)t===a||u[t][e.TEXTURE_2D]===o[t][e.TEXTURE_2D]&&u[t][e.TEXTURE_CUBE_MAP]===o[t][e.TEXTURE_CUBE_MAP]||(e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,u[t][e.TEXTURE_2D]),e.bindTexture(e.TEXTURE_CUBE_MAP,u[t][e.TEXTURE_CUBE_MAP]));if(h.active>-1){const t=u[a];t[e.TEXTURE_2D]===o[a][e.TEXTURE_2D]&&t[e.TEXTURE_CUBE_MAP]===o[a][e.TEXTURE_CUBE_MAP]||(e.activeTexture(h.active),e.bindTexture(e.TEXTURE_2D,t[e.TEXTURE_2D]),e.bindTexture(e.TEXTURE_CUBE_MAP,t[e.TEXTURE_CUBE_MAP]))}this.t?e.bindVertexArray(null):this.u&&this.u.bindVertexArrayOES(null);const f=this.s;if(this.t||this.angleOES)for(let t=0;t<f;t++)this.t?e.vertexAttribDivisor(t,0):this.angleOES.vertexAttribDivisorANGLE(t,0);e.bindBuffer(e.ARRAY_BUFFER,r.arrayBuffer),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,r.elementArrayBuffer),1===r.activeAttribType?this.F(r,e):this.D(r,e,s)},F(t,i){const r=t.vao;r&&(this.t?i.bindVertexArray(r||null):this.u&&this.u.bindVertexArrayOES(r||null))},D(t,i,r){const e=this.s,s=t.attributes;let h=0;for(let t=0;t<e;t++){const e=s[t];h<r&&e?(e.buffer&&(i.bindBuffer(i.ARRAY_BUFFER,e.buffer),i.vertexAttribPointer(...e.args),e.divisor&&(this.t?i.vertexAttribDivisor(t,e.divisor):this.angleOES.vertexAttribDivisorANGLE(t,e.divisor))),e.enable?(i.enableVertexAttribArray(t),h++):i.disableVertexAttribArray(t)):i.disableVertexAttribArray(t)}}}),r$1(a.prototype,{compressedTexImage2D(t,i,r,e,s,h,n){return this.m(),this.i.compressedTexImage2D(t,i,r,e,s,h,n)},copyTexImage2D(t,i,r,e,s,h,n,u){return this.m(),this.i.copyTexImage2D(t,i,r,e,s,h,n,u)},copyTexSubImage2D(t,i,r,e,s,h,n,u){return this.m(),this.i.copyTexSubImage2D(t,i,r,e,s,h,n,u)},createTexture(){return this.i.createTexture()},deleteTexture(t){const i=this.states.textures.units;for(let r=0;r<i.length;r++)for(const e in i[r])i[r][e]===t&&(i[r][e]=null);return this.i.deleteTexture(t)},generateMipmap(t){return this.m(),this.i.generateMipmap(t)},getTexParameter(t,i){return this.m(),this.i.getTexParameter(t,i)},isTexture(t){return this.i.isTexture(t)},texImage2D(...t){if(this.m(),this.t){const i=t[t.length-2],r=u$2.getInternalFormat(this.i,t[2],i);r!==t[2]&&(t[2]=r);const e=u$2.getTextureType(this.i,i);e!==i&&(t[t.length-2]=e)}return this.i.texImage2D(...t)},texSubImage2D(...t){if(this.m(),this.t){const i=t[t.length-2],r=u$2.getTextureType(this.i,i);r!==i&&(t[t.length-2]=r)}return this.i.texSubImage2D(...t)},texParameterf(t,i,r){return this.m(),this.i.texParameterf(t,i,r)},texParameteri(t,i,r){return this.m(),this.i.texParameteri(t,i,r)},texStorage2D(t,i,r,e,s){return this.m(),this.i.texStorage2D(t,i,r,e,s)},texImage3D(t,i,r,e,s,h,n,u,o,a){return this.m(),this.i.texImage3D(t,i,r,e,s,h,n,u,o,a)},texStorage3D(t,i,r,e,s,h){return this.m(),this.i.texStorage3D(t,i,r,e,s,h)},texSubImage3D(t,i,r,e,s,h,n,u,o,a,f){return this.m(),this.i.texSubImage3D(t,i,r,e,s,h,n,u,o,a,f)},copyTexSubImage3D(t,i,r,e,s,h,n,u,o){return this.m(),this.i.copyTexSubImage3D(t,i,r,e,s,h,n,u,o)},compressedTexSubImage3D(t,i,r,e,s,h,n,u,o,a,f){return this.m(),this.i.compressedTexSubImage3D(t,i,r,e,s,h,n,u,o,a,f)}}),r$1(a.prototype,{bindAttribLocation(t,i,r){return this.i.bindAttribLocation(t,i,r)},enableVertexAttribArray(t){return this.m(),this.states.attributes[t]||(this.states.attributes[t]={}),this.states.attributes[t].enable=!0,this.i.enableVertexAttribArray(t)},disableVertexAttribArray(t){return this.m(),this.states.attributes[t]||(this.states.attributes[t]={}),this.states.attributes[t].enable=!1,this.i.disableVertexAttribArray(t)},getActiveAttrib(t,i){return this.i.getActiveAttrib(t,i)},getActiveUniform(t,i){return this.i.getActiveUniform(t,i)},getAttribLocation(t,i){return this.i.getAttribLocation(t,i)},getUniformLocation(t,i){return this.i.getUniformLocation(t,i)},getVertexAttrib(t,i){return this.m(),this.i.getVertexAttrib(t,i)},getVertexAttribOffset(t,i){return this.m(),this.i.getVertexAttribOffset(t,i)},uniformBlockBinding(t,i,r){return this.m(),this.i.uniformBlockBinding(t,i,r)},T(t,...i){const r=this.states.program;if(!r)return!1;let e=t.fid;void 0===e&&(e=t.fid=r.fid++);const s=r.cachedUniforms[e];return!!function(t,i){if(!t)return!1;const r=i.length;for(let e=0;e<r;e++)if(t[e]&&void 0!==t[e].length){const r=t[e].length;for(let s=0;s<r;s++)if(t[e][s]!==i[e][s])return!1}else if(t[e]!==i[e])return!1;return!0}(s,i)||(r.cachedUniforms[e]=function(t,i){t=t||new Array(i.length);const r=i.length;for(let e=0;e<r;e++)t[e]=void 0!==i[e].length?f$2(t[e]||[],i[e]):i[e];return t}(s,i),!1)},uniformMatrix2fv(t,i,r){this.T(t,i,r)||(this.m(),this.i.uniformMatrix2fv(t,i,r))},uniformMatrix3fv(t,i,r){this.T(t,i,r)||(this.m(),this.i.uniformMatrix3fv(t,i,r))},uniformMatrix4fv(t,i,r){this.T(t,i,r)||this.i.uniformMatrix4fv(t,i,r)},uniform1f(t,i){return this.m(),this.i.uniform1f(t,i)},uniform1i(t,i){return this.m(),this.i.uniform1i(t,i)},uniform2f(t,i,r){return this.m(),this.i.uniform2f(t,i,r)},uniform2i(t,i,r){return this.m(),this.i.uniform2i(t,i,r)},uniform3f(t,i,r,e){return this.m(),this.i.uniform3f(t,i,r,e)},uniform3i(t,i,r,e){return this.m(),this.i.uniform3i(t,i,r,e)},uniform4f(t,i,r,e,s){return this.m(),this.i.uniform4f(t,i,r,e,s)},uniform4i(t,i,r,e,s){return this.m(),this.i.uniform4i(t,i,r,e,s)},uniform1ui(t,i){return this.m(),this.i.uniform1ui(t,i)},uniform2ui(t,i,r){return this.m(),this.i.uniform2ui(t,i,r)},uniform3ui(t,i,r,e){return this.m(),this.i.uniform3ui(t,i,r,e)},uniform4ui(t,i,r,e,s){return this.m(),this.i.uniform4ui(t,i,r,e,s)},uniform1fv(t,i,r,e){this.m(),void 0!==e?this.i.uniform1fv(t,i,r,e):void 0!==r?this.i.uniform1fv(t,i,r):this.i.uniform1fv(t,i)},uniform2fv(t,i,r,e){this.m(),void 0!==e?this.i.uniform2fv(t,i,r,e):void 0!==r?this.i.uniform2fv(t,i,r):this.i.uniform2fv(t,i)},uniform3fv(t,i,r,e){this.m(),void 0!==e?this.i.uniform3fv(t,i,r,e):void 0!==r?this.i.uniform3fv(t,i,r):this.i.uniform3fv(t,i)},uniform4fv(t,i,r,e){this.m(),void 0!==e?this.i.uniform4fv(t,i,r,e):void 0!==r?this.i.uniform4fv(t,i,r):this.i.uniform4fv(t,i)},uniform1iv(t,i,r,e){this.m(),void 0!==e?this.i.uniform1iv(t,i,r,e):void 0!==r?this.i.uniform1iv(t,i,r):this.i.uniform1iv(t,i)},uniform2iv(t,i,r,e){this.m(),void 0!==e?this.i.uniform2iv(t,i,r,e):void 0!==r?this.i.uniform2iv(t,i,r):this.i.uniform2iv(t,i)},uniform3iv(t,i,r,e){this.m(),void 0!==e?this.i.uniform3iv(t,i,r,e):void 0!==r?this.i.uniform3iv(t,i,r):this.i.uniform3iv(t,i)},uniform4iv(t,i,r,e){this.m(),void 0!==e?this.i.uniform4iv(t,i,r,e):void 0!==r?this.i.uniform4iv(t,i,r):this.i.uniform4iv(t,i)},uniform1uiv(t,i,r,e){this.m(),void 0!==e?this.i.uniform1uiv(t,i,r,e):void 0!==r?this.i.uniform1uiv(t,i,r):this.i.uniform1uiv(t,i)},uniform2uiv(t,i,r,e){this.m(),void 0!==e?this.i.uniform2uiv(t,i,r,e):void 0!==r?this.i.uniform2uiv(t,i,r):this.i.uniform2uiv(t,i)},uniform3uiv(t,i,r,e){this.m(),void 0!==e?this.i.uniform3uiv(t,i,r,e):void 0!==r?this.i.uniform3uiv(t,i,r):this.i.uniform3uiv(t,i)},uniform4uiv(t,i,r,e){this.m(),void 0!==e?this.i.uniform4uiv(t,i,r,e):void 0!==r?this.i.uniform4uiv(t,i,r):this.i.uniform4uiv(t,i)},vertexAttrib1f(t,i){return this.m(),this.i.vertexAttrib1f(t,i)},vertexAttrib2f(t,i,r){return this.m(),this.i.vertexAttrib2f(t,i,r)},vertexAttrib3f(t,i,r,e){return this.m(),this.i.vertexAttrib3f(t,i,r,e)},vertexAttrib4f(t,i,r,e,s){return this.m(),this.i.vertexAttrib4f(t,i,r,e,s)},vertexAttrib1fv(t,i){return this.m(),this.i.vertexAttrib1fv(t,i)},vertexAttrib2fv(t,i){return this.m(),this.i.vertexAttrib2fv(t,i)},vertexAttrib3fv(t,i){return this.m(),this.i.vertexAttrib3fv(t,i)},vertexAttrib4fv(t,i){return this.m(),this.i.vertexAttrib4fv(t,i)},vertexAttribI4i(t,i,r,e,s){return this.m(),this.i.vertexAttribI4i(t,i,r,e,s)},vertexAttribI4ui(t,i,r,e,s){return this.m(),this.i.vertexAttribI4ui(t,i,r,e,s)},vertexAttribI4iv(t,i){return this.m(),this.i.vertexAttribI4iv(t,i)},vertexAttribI4uiv(t,i){return this.m(),this.i.vertexAttribI4uiv(t,i)}}),r$1(a.prototype,{createVertexArray(){return this.t?this.i.createVertexArray():this.vaoOES.createVertexArrayOES()},deleteVertexArray(t){const i=this.states;return i.vao===t&&(i.vao=null),this.t?this.i.deleteVertexArray(t):this.vaoOES.deleteVertexArrayOES(t)},isVertexArray(t){return this.t?this.i.isVertexArray(t):this.vaoOES.isVertexArrayOES(t)}}),r$1(a.prototype,{drawArraysInstanced(t,i,r,e){return this.m(),this.states.activeAttribType=1,this.g(),this.t?this.i.drawArraysInstanced(t,i,r,e):this.angleOES.drawArraysInstancedANGLE(t,i,r,e)},drawElementsInstanced(t,i,r,e,s){return this.m(),this.states.activeAttribType=1,this.g(),this.t?this.i.drawElementsInstanced(t,i,r,e,s):this.angleOES.drawElementsInstancedANGLE(t,i,r,e,s)}});
/*!
	 * @maptalks/gl v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.com
	 */
var w$3={exports:{}},x$5={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},M$5={exports:{}},_$5=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},y$3=Array.prototype.concat,b$4=Array.prototype.slice,S$5=M$5.exports=function(t){for(var i=[],e=0,s=t.length;e<s;e++){var n=t[e];_$5(n)?i=y$3.call(i,b$4.call(n)):i.push(n)}return i};S$5.wrap=function(t){return function(){return t(S$5(arguments))}};var C$3=x$5,T$5=M$5.exports,k$5=Object.hasOwnProperty,A$3=Object.create(null);for(var O$5 in C$3)k$5.call(C$3,O$5)&&(A$3[C$3[O$5]]=O$5);var I$4=w$3.exports={to:{},get:{}};function E$5(t,i,e){return Math.min(Math.max(i,t),e)}function L$5(t){var i=Math.round(t).toString(16).toUpperCase();return i.length<2?"0"+i:i}I$4.get=function(t){var i,e;switch(t.substring(0,3).toLowerCase()){case"hsl":i=I$4.get.hsl(t),e="hsl";break;case"hwb":i=I$4.get.hwb(t),e="hwb";break;default:i=I$4.get.rgb(t),e="rgb"}return i?{model:e,value:i}:null},I$4.get.rgb=function(t){if(!t)return null;var i,e,s,n=[0,0,0,1];if(i=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(s=i[2],i=i[1],e=0;e<3;e++){var r=2*e;n[e]=parseInt(i.slice(r,r+2),16)}s&&(n[3]=parseInt(s,16)/255)}else if(i=t.match(/^#([a-f0-9]{3,4})$/i)){for(s=(i=i[1])[3],e=0;e<3;e++)n[e]=parseInt(i[e]+i[e],16);s&&(n[3]=parseInt(s+s,16)/255)}else if(i=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(e=0;e<3;e++)n[e]=parseInt(i[e+1],0);i[4]&&(n[3]=i[5]?.01*parseFloat(i[4]):parseFloat(i[4]))}else{if(!(i=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(i=t.match(/^(\w+)$/))?"transparent"===i[1]?[0,0,0,0]:k$5.call(C$3,i[1])?((n=C$3[i[1]])[3]=1,n):null:null;for(e=0;e<3;e++)n[e]=Math.round(2.55*parseFloat(i[e+1]));i[4]&&(n[3]=i[5]?.01*parseFloat(i[4]):parseFloat(i[4]))}for(e=0;e<3;e++)n[e]=E$5(n[e],0,255);return n[3]=E$5(n[3],0,1),n},I$4.get.hsl=function(t){if(!t)return null;var i=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(i){var e=parseFloat(i[4]);return[(parseFloat(i[1])%360+360)%360,E$5(parseFloat(i[2]),0,100),E$5(parseFloat(i[3]),0,100),E$5(isNaN(e)?1:e,0,1)]}return null},I$4.get.hwb=function(t){if(!t)return null;var i=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(i){var e=parseFloat(i[4]);return[(parseFloat(i[1])%360+360)%360,E$5(parseFloat(i[2]),0,100),E$5(parseFloat(i[3]),0,100),E$5(isNaN(e)?1:e,0,1)]}return null},I$4.to.hex=function(){var t=T$5(arguments);return"#"+L$5(t[0])+L$5(t[1])+L$5(t[2])+(t[3]<1?L$5(Math.round(255*t[3])):"")},I$4.to.rgb=function(){var t=T$5(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},I$4.to.rgb.percent=function(){var t=T$5(arguments),i=Math.round(t[0]/255*100),e=Math.round(t[1]/255*100),s=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+i+"%, "+e+"%, "+s+"%)":"rgba("+i+"%, "+e+"%, "+s+"%, "+t[3]+")"},I$4.to.hsl=function(){var t=T$5(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},I$4.to.hwb=function(){var t=T$5(arguments),i="";return t.length>=4&&1!==t[3]&&(i=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+i+")"},I$4.to.keyword=function(t){return A$3[t.slice(0,3)]};var F$5={exports:{}},R$5=x$5,P$4={};for(var D$5 in R$5)R$5.hasOwnProperty(D$5)&&(P$4[R$5[D$5]]=D$5);var H$5=F$5.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var N$5 in H$5)if(H$5.hasOwnProperty(N$5)){if(!("channels"in H$5[N$5]))throw new Error("missing channels property: "+N$5);if(!("labels"in H$5[N$5]))throw new Error("missing channel labels property: "+N$5);if(H$5[N$5].labels.length!==H$5[N$5].channels)throw new Error("channel and label counts mismatch: "+N$5);var G$5=H$5[N$5].channels,j$5=H$5[N$5].labels;delete H$5[N$5].channels,delete H$5[N$5].labels,Object.defineProperty(H$5[N$5],"channels",{value:G$5}),Object.defineProperty(H$5[N$5],"labels",{value:j$5})}H$5.rgb.hsl=function(t){var i,e,s=t[0]/255,n=t[1]/255,r=t[2]/255,h=Math.min(s,n,r),o=Math.max(s,n,r),a=o-h;return o===h?i=0:s===o?i=(n-r)/a:n===o?i=2+(r-s)/a:r===o&&(i=4+(s-n)/a),(i=Math.min(60*i,360))<0&&(i+=360),e=(h+o)/2,[i,100*(o===h?0:e<=.5?a/(o+h):a/(2-o-h)),100*e]},H$5.rgb.hsv=function(t){var i,e,s,n,r,h=t[0]/255,o=t[1]/255,a=t[2]/255,l=Math.max(h,o,a),c=l-Math.min(h,o,a),u=function(t){return(l-t)/6/c+.5};return 0===c?n=r=0:(r=c/l,i=u(h),e=u(o),s=u(a),h===l?n=s-e:o===l?n=1/3+i-s:a===l&&(n=2/3+e-i),n<0?n+=1:n>1&&(n-=1)),[360*n,100*r,100*l]},H$5.rgb.hwb=function(t){var i=t[0],e=t[1],s=t[2];return[H$5.rgb.hsl(t)[0],1/255*Math.min(i,Math.min(e,s))*100,100*(s=1-1/255*Math.max(i,Math.max(e,s)))]},H$5.rgb.cmyk=function(t){var i,e=t[0]/255,s=t[1]/255,n=t[2]/255;return[100*((1-e-(i=Math.min(1-e,1-s,1-n)))/(1-i)||0),100*((1-s-i)/(1-i)||0),100*((1-n-i)/(1-i)||0),100*i]},H$5.rgb.keyword=function(t){var i=P$4[t];if(i)return i;var e,s,n,r=1/0;for(var h in R$5)if(R$5.hasOwnProperty(h)){var a=(s=t,n=R$5[h],Math.pow(s[0]-n[0],2)+Math.pow(s[1]-n[1],2)+Math.pow(s[2]-n[2],2));a<r&&(r=a,e=h)}return e},H$5.keyword.rgb=function(t){return R$5[t]},H$5.rgb.xyz=function(t){var i=t[0]/255,e=t[1]/255,s=t[2]/255;return[100*(.4124*(i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92)+.3576*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.1805*(s=s>.04045?Math.pow((s+.055)/1.055,2.4):s/12.92)),100*(.2126*i+.7152*e+.0722*s),100*(.0193*i+.1192*e+.9505*s)]},H$5.rgb.lab=function(t){var i=H$5.rgb.xyz(t),e=i[0],s=i[1],n=i[2];return s/=100,n/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116)-16,500*(e-s),200*(s-(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116))]},H$5.hsl.rgb=function(t){var i,e,s,n,r,h=t[0]/360,o=t[1]/100,a=t[2]/100;if(0===o)return[r=255*a,r,r];i=2*a-(e=a<.5?a*(1+o):a+o-a*o),n=[0,0,0];for(var l=0;l<3;l++)(s=h+1/3*-(l-1))<0&&s++,s>1&&s--,n[l]=255*(r=6*s<1?i+6*(e-i)*s:2*s<1?e:3*s<2?i+(e-i)*(2/3-s)*6:i);return n},H$5.hsl.hsv=function(t){var i=t[0],e=t[1]/100,s=t[2]/100,n=e,r=Math.max(s,.01);return e*=(s*=2)<=1?s:2-s,n*=r<=1?r:2-r,[i,100*(0===s?2*n/(r+n):2*e/(s+e)),(s+e)/2*100]},H$5.hsv.rgb=function(t){var i=t[0]/60,e=t[1]/100,s=t[2]/100,n=Math.floor(i)%6,r=i-Math.floor(i),h=255*s*(1-e),o=255*s*(1-e*r),a=255*s*(1-e*(1-r));switch(s*=255,n){case 0:return[s,a,h];case 1:return[o,s,h];case 2:return[h,s,a];case 3:return[h,o,s];case 4:return[a,h,s];case 5:return[s,h,o]}},H$5.hsv.hsl=function(t){var i,e,s,n=t[0],r=t[1]/100,h=t[2]/100,o=Math.max(h,.01);return s=(2-r)*h,e=r*o,[n,100*(e=(e/=(i=(2-r)*o)<=1?i:2-i)||0),100*(s/=2)]},H$5.hwb.rgb=function(t){var i,e,s,n,r,h,o,a=t[0]/360,l=t[1]/100,c=t[2]/100,u=l+c;switch(u>1&&(l/=u,c/=u),s=6*a-(i=Math.floor(6*a)),0!=(1&i)&&(s=1-s),n=l+s*((e=1-c)-l),i){default:case 6:case 0:r=e,h=n,o=l;break;case 1:r=n,h=e,o=l;break;case 2:r=l,h=e,o=n;break;case 3:r=l,h=n,o=e;break;case 4:r=n,h=l,o=e;break;case 5:r=e,h=l,o=n}return[255*r,255*h,255*o]},H$5.cmyk.rgb=function(t){var e=t[1]/100,s=t[2]/100,n=t[3]/100;return[255*(1-Math.min(1,t[0]/100*(1-n)+n)),255*(1-Math.min(1,e*(1-n)+n)),255*(1-Math.min(1,s*(1-n)+n))]},H$5.xyz.rgb=function(t){var i,e,s,n=t[0]/100,r=t[1]/100,h=t[2]/100;return e=-.9689*n+1.8758*r+.0415*h,s=.0557*n+-.204*r+1.057*h,i=(i=3.2406*n+-1.5372*r+-.4986*h)>.0031308?1.055*Math.pow(i,1/2.4)-.055:12.92*i,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:12.92*s,[255*(i=Math.min(Math.max(0,i),1)),255*(e=Math.min(Math.max(0,e),1)),255*(s=Math.min(Math.max(0,s),1))]},H$5.xyz.lab=function(t){var i=t[0],e=t[1],s=t[2];return e/=100,s/=108.883,i=(i/=95.047)>.008856?Math.pow(i,1/3):7.787*i+16/116,[116*(e=e>.008856?Math.pow(e,1/3):7.787*e+16/116)-16,500*(i-e),200*(e-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},H$5.lab.xyz=function(t){var i,e,s;i=t[1]/500+(e=(t[0]+16)/116),s=e-t[2]/200;var r=Math.pow(e,3),h=Math.pow(i,3),o=Math.pow(s,3);return e=r>.008856?r:(e-16/116)/7.787,i=h>.008856?h:(i-16/116)/7.787,s=o>.008856?o:(s-16/116)/7.787,[i*=95.047,e*=100,s*=108.883]},H$5.lab.lch=function(t){var i,e=t[0],s=t[1],n=t[2];return(i=360*Math.atan2(n,s)/2/Math.PI)<0&&(i+=360),[e,Math.sqrt(s*s+n*n),i]},H$5.lch.lab=function(t){var i,s=t[1];return i=t[2]/360*2*Math.PI,[t[0],s*Math.cos(i),s*Math.sin(i)]},H$5.rgb.ansi16=function(t){var i=t[0],e=t[1],s=t[2],n=1 in arguments?arguments[1]:H$5.rgb.hsv(t)[2];if(0===(n=Math.round(n/50)))return 30;var r=30+(Math.round(s/255)<<2|Math.round(e/255)<<1|Math.round(i/255));return 2===n&&(r+=60),r},H$5.hsv.ansi16=function(t){return H$5.rgb.ansi16(H$5.hsv.rgb(t),t[2])},H$5.rgb.ansi256=function(t){var i=t[0],e=t[1],s=t[2];return i===e&&e===s?i<8?16:i>248?231:Math.round((i-8)/247*24)+232:16+36*Math.round(i/255*5)+6*Math.round(e/255*5)+Math.round(s/255*5)},H$5.ansi16.rgb=function(t){var i=t%10;if(0===i||7===i)return t>50&&(i+=3.5),[i=i/10.5*255,i,i];var e=.5*(1+~~(t>50));return[(1&i)*e*255,(i>>1&1)*e*255,(i>>2&1)*e*255]},H$5.ansi256.rgb=function(t){if(t>=232){var i=10*(t-232)+8;return[i,i,i]}var e;return t-=16,[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},H$5.rgb.hex=function(t){var i=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(i.length)+i},H$5.hex.rgb=function(t){var i=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!i)return[0,0,0];var e=i[0];3===i[0].length&&(e=e.split("").map((function(t){return t+t})).join(""));var s=parseInt(e,16);return[s>>16&255,s>>8&255,255&s]},H$5.rgb.hcg=function(t){var i,e=t[0]/255,s=t[1]/255,n=t[2]/255,r=Math.max(Math.max(e,s),n),h=Math.min(Math.min(e,s),n),o=r-h;return i=o<=0?0:r===e?(s-n)/o%6:r===s?2+(n-e)/o:4+(e-s)/o+4,i/=6,[360*(i%=1),100*o,100*(o<1?h/(1-o):0)]},H$5.hsl.hcg=function(t){var s,i=t[1]/100,e=t[2]/100,n=0;return(s=e<.5?2*i*e:2*i*(1-e))<1&&(n=(e-.5*s)/(1-s)),[t[0],100*s,100*n]},H$5.hsv.hcg=function(t){var e=t[2]/100,s=t[1]/100*e,n=0;return s<1&&(n=(e-s)/(1-s)),[t[0],100*s,100*n]},H$5.hcg.rgb=function(t){var e=t[1]/100,s=t[2]/100;if(0===e)return[255*s,255*s,255*s];var n,r=[0,0,0],h=t[0]/360%1*6,o=h%1,a=1-o;switch(Math.floor(h)){case 0:r[0]=1,r[1]=o,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=o;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=o,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return[255*(e*r[0]+(n=(1-e)*s)),255*(e*r[1]+n),255*(e*r[2]+n)]},H$5.hcg.hsv=function(t){var i=t[1]/100,e=i+t[2]/100*(1-i),s=0;return e>0&&(s=i/e),[t[0],100*s,100*e]},H$5.hcg.hsl=function(t){var i=t[1]/100,e=t[2]/100*(1-i)+.5*i,s=0;return e>0&&e<.5?s=i/(2*e):e>=.5&&e<1&&(s=i/(2*(1-e))),[t[0],100*s,100*e]},H$5.hcg.hwb=function(t){var i=t[1]/100,e=i+t[2]/100*(1-i);return[t[0],100*(e-i),100*(1-e)]},H$5.hwb.hcg=function(t){var e=1-t[2]/100,s=e-t[1]/100,n=0;return s<1&&(n=(e-s)/(1-s)),[t[0],100*s,100*n]},H$5.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},H$5.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},H$5.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},H$5.gray.hsl=H$5.gray.hsv=function(t){return[0,0,t[0]]},H$5.gray.hwb=function(t){return[0,100,t[0]]},H$5.gray.cmyk=function(t){return[0,0,0,t[0]]},H$5.gray.lab=function(t){return[t[0],0,0]},H$5.gray.hex=function(t){var i=255&Math.round(t[0]/100*255),e=((i<<16)+(i<<8)+i).toString(16).toUpperCase();return"000000".substring(e.length)+e},H$5.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var B$5=F$5.exports;function z$5(t,i){return function(e){return i(t(e))}}function V$5(t,i){for(var e=[i[t].parent,t],s=B$5[i[t].parent][t],n=i[t].parent;i[n].parent;)e.unshift(i[n].parent),s=z$5(B$5[i[n].parent][n],s),n=i[n].parent;return s.conversion=e,s}var W$5=F$5.exports,q$6=function(t){for(var i=function(t){var i=function(){for(var t={},i=Object.keys(B$5),e=i.length,s=0;s<e;s++)t[i[s]]={distance:-1,parent:null};return t}(),e=[t];for(i[t].distance=0;e.length;)for(var s=e.pop(),n=Object.keys(B$5[s]),r=n.length,h=0;h<r;h++){var o=n[h],a=i[o];-1===a.distance&&(a.distance=i[s].distance+1,a.parent=s,e.unshift(o))}return i}(t),e={},s=Object.keys(i),n=s.length,r=0;r<n;r++){var h=s[r];null!==i[h].parent&&(e[h]=V$5(h,i))}return e},$$5={};Object.keys(W$5).forEach((function(t){$$5[t]={},Object.defineProperty($$5[t],"channels",{value:W$5[t].channels}),Object.defineProperty($$5[t],"labels",{value:W$5[t].labels});var i=q$6(t);Object.keys(i).forEach((function(e){var s=i[e];$$5[t][e]=function(t){var i=function(i){if(null==i)return i;arguments.length>1&&(i=Array.prototype.slice.call(arguments));var e=t(i);if("object"==typeof e)for(var s=e.length,n=0;n<s;n++)e[n]=Math.round(e[n]);return e};return"conversion"in t&&(i.conversion=t.conversion),i}(s),$$5[t][e].raw=function(t){var i=function(i){return null==i?i:(arguments.length>1&&(i=Array.prototype.slice.call(arguments)),t(i))};return"conversion"in t&&(i.conversion=t.conversion),i}(s)}))}));var X$6=w$3.exports,J$6=$$5,Z$6=[].slice,K$6=["keyword","gray","hex"],Q$6={};Object.keys(J$6).forEach((function(t){Q$6[Z$6.call(J$6[t].labels).sort().join("")]=t}));var tt$5={};function it$4(t,i){if(!(this instanceof it$4))return new it$4(t,i);if(i&&i in K$6&&(i=null),i&&!(i in J$6))throw new Error("Unknown model: "+i);var e,s;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof it$4)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var n=X$6.get(t);if(null===n)throw new Error("Unable to parse color from string: "+t);this.model=n.model,this.color=n.value.slice(0,s=J$6[this.model].channels),this.valpha="number"==typeof n.value[s]?n.value[s]:1}else if(t.length){this.model=i||"rgb";var r=Z$6.call(t,0,s=J$6[this.model].channels);this.color=rt$5(r,s),this.valpha="number"==typeof t[s]?t[s]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var h=Object.keys(t);"alpha"in t&&(h.splice(h.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var o=h.sort().join("");if(!(o in Q$6))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Q$6[o];var a=J$6[this.model].labels,l=[];for(e=0;e<a.length;e++)l.push(t[a[e]]);this.color=rt$5(l)}if(tt$5[this.model])for(s=J$6[this.model].channels,e=0;e<s;e++){var c=tt$5[this.model][e];c&&(this.color[e]=c(this.color[e]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function et$5(t,i,e){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(tt$5[t]||(tt$5[t]=[]))[i]=e})),t=t[0],function(s){var n;return arguments.length?(e&&(s=e(s)),(n=this[t]()).color[i]=s,n):(n=this[t]().color[i],e&&(n=e(n)),n)}}function st$5(t){return function(i){return Math.max(0,Math.min(t,i))}}function nt$5(t){return Array.isArray(t)?t:[t]}function rt$5(t,i){for(var e=0;e<i;e++)"number"!=typeof t[e]&&(t[e]=0);return t}it$4.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var i=this.model in X$6.to?this:this.rgb(),e=1===(i=i.round("number"==typeof t?t:1)).valpha?i.color:i.color.concat(this.valpha);return X$6.to[i.model](e)},percentString:function(t){var i=this.rgb().round("number"==typeof t?t:1),e=1===i.valpha?i.color:i.color.concat(this.valpha);return X$6.to.rgb.percent(e)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},i=J$6[this.model].channels,e=J$6[this.model].labels,s=0;s<i;s++)t[e[s]]=this.color[s];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new it$4(this.color.map(function(t){return function(i){return function(t,i){return Number(t.toFixed(i))}(i,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new it$4(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:et$5("rgb",0,st$5(255)),green:et$5("rgb",1,st$5(255)),blue:et$5("rgb",2,st$5(255)),hue:et$5(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:et$5("hsl",1,st$5(100)),lightness:et$5("hsl",2,st$5(100)),saturationv:et$5("hsv",1,st$5(100)),value:et$5("hsv",2,st$5(100)),chroma:et$5("hcg",1,st$5(100)),gray:et$5("hcg",2,st$5(100)),white:et$5("hwb",1,st$5(100)),wblack:et$5("hwb",2,st$5(100)),cyan:et$5("cmyk",0,st$5(100)),magenta:et$5("cmyk",1,st$5(100)),yellow:et$5("cmyk",2,st$5(100)),black:et$5("cmyk",3,st$5(100)),x:et$5("xyz",0,st$5(100)),y:et$5("xyz",1,st$5(100)),z:et$5("xyz",2,st$5(100)),l:et$5("lab",0,st$5(100)),a:et$5("lab",1),b:et$5("lab",2),keyword:function(t){return arguments.length?new it$4(t):J$6[this.model].keyword(this.color)},hex:function(t){return arguments.length?new it$4(t):X$6.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,i=[],e=0;e<t.length;e++){var s=t[e]/255;i[e]=s<=.03928?s/12.92:Math.pow((s+.055)/1.055,2.4)}return.2126*i[0]+.7152*i[1]+.0722*i[2]},contrast:function(t){var i=this.luminosity(),e=t.luminosity();return i>e?(i+.05)/(e+.05):(e+.05)/(i+.05)},level:function(t){var i=this.contrast(t);return i>=7.1?"AAA":i>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),i=0;i<3;i++)t.color[i]=255-t.color[i];return t},lighten:function(t){var i=this.hsl();return i.color[2]+=i.color[2]*t,i},darken:function(t){var i=this.hsl();return i.color[2]-=i.color[2]*t,i},saturate:function(t){var i=this.hsl();return i.color[1]+=i.color[1]*t,i},desaturate:function(t){var i=this.hsl();return i.color[1]-=i.color[1]*t,i},whiten:function(t){var i=this.hwb();return i.color[1]+=i.color[1]*t,i},blacken:function(t){var i=this.hwb();return i.color[2]+=i.color[2]*t,i},grayscale:function(){var t=this.rgb().color,i=.3*t[0]+.59*t[1]+.11*t[2];return it$4.rgb(i,i,i)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var i=this.hsl(),e=i.color[0];return e=(e=(e+t)%360)<0?360+e:e,i.color[0]=e,i},mix:function(t,i){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var e=t.rgb(),s=this.rgb(),n=void 0===i?.5:i,r=2*n-1,h=e.alpha()-s.alpha(),o=((r*h==-1?r:(r+h)/(1+r*h))+1)/2,a=1-o;return it$4.rgb(o*e.red()+a*s.red(),o*e.green()+a*s.green(),o*e.blue()+a*s.blue(),e.alpha()*n+s.alpha()*(1-n))}},Object.keys(J$6).forEach((function(t){if(-1===K$6.indexOf(t)){var i=J$6[t].channels;it$4.prototype[t]=function(){if(this.model===t)return new it$4(this);if(arguments.length)return new it$4(arguments,t);var e="number"==typeof arguments[i]?i:this.valpha;return new it$4(nt$5(J$6[this.model][t].raw(this.color)).concat(e),t)},it$4[t]=function(e){return"number"==typeof e&&(e=rt$5(Z$6.call(arguments),i)),new it$4(e,t)}}}));var ht$5=it$4;const ot$5="function"==typeof Object.assign;function at$5(t){if(ot$5)Object.assign.apply(Object,arguments);else for(let i=1;i<arguments.length;i++){const e=arguments[i];for(const i in e)t[i]=e[i]}return t}function lt$5(t){return null==t}function ct$5(t){return"number"==typeof t&&!isNaN(t)}const ut$5=[];function ft$5(t,i){const e=i._get2DExtentAtRes(i.getGLRes()),s=e.getWidth(),n=e.getHeight(),r=t;return identity$2(r),translate$1(r,r,i.cameraLookAt),scale$5(r,r,set$4(ut$5,s,n,1)),r}function dt$5(t,i){return Object.prototype.hasOwnProperty.call(t,i)}function pt$5(t){for(let i=1;i<arguments.length;i++){const e=arguments[i];if(e)for(let i=0,s=e.length;i<s;i++)t.push(e[i])}return t.length}const gt$5={};function mt$5(t,i){if(!Array.isArray(i)){i=gt$5[i]=gt$5[i]||ht$5(i).array()}for(let e=0;e<i.length;e++)t[e]=i[e];return 3===i.length&&(t[3]=1),t}function vt$5(t,i){if(Array.isArray(i))for(let e=0;e<i.length;e++)t[e]=255*i[e];else{i=gt$5[i]=gt$5[i]||ht$5(i).array();for(let e=0;e<i.length;e++)t[e]=i[e]}return 3===t.length&&t.push(255),t}function wt$5(t,e,s=0){if(!(t&&e instanceof t$1.Coordinate))return null;const n=t.coordinateToPointAtRes(e,t.getGLRes());return[n.x,n.y,s]}const xt$5=[0,0],Mt$5=[0,0,0];let _t$5;class yt$5{static getUniformDeclares(){const t=[],i=[];return i.push({name:"shadow_lightProjViewModelMatrix",type:"function",fn:function(i,e){return multiply$5(t,e.shadow_lightProjViewMatrix,e.modelMatrix)}}),i.push("shadow_shadowMap","shadow_opacity","esm_shadow_threshold","shadow_color","shadow_nearFar"),i}constructor(t,i,e){this.renderer=new B$6(t),this.sceneConfig=i,this.t=.3,this.s=e,this.h()}resize(){const t=this.canvas;t.width=this.s.getRenderer().canvas.width,t.height=this.s.getRenderer().canvas.height}h(){const t=this.sceneConfig.shadow||{};let i=512;const e=t.quality;"high"===e?i=2048:"medium"===e&&(i=1024);const s=this.getDefines();this.o=new mr$4(this.renderer,{width:i,height:i,blurOffset:t.blurOffset,defines:s}),this.u=new vr$4(s),this.p()}getDefines(){return{HAS_SHADOWING:1,PACK_FLOAT:1,USE_ESM:1}}render(t,i,e,s,n,r,h,o,c,u){this.m();const f=this.s.getMap();let d,p;if(u||this.v(f,h,!!t)){this.M=this.M||[],this._=this._||[];const s=multiply$5(this.M,i,e),n=normalize$4(this._,r);_t$5||(_t$5=f.getContainerExtent());let o=f.height;f.getPitch()>62&&(o=f._getVisualHeight(62));const c=_t$5.set(0,f.height-o,f.width,f.height).convertTo((t=>f._containerPointToPointAtRes(t,f.getGLRes()))).toArray();t&&h.addMesh(this.S);const u=c.map((t=>[t.x,t.y,0,1])),{lightProjViewMatrix:g,shadowMap:m,blurFBO:v}=this.o.render(h,{cameraProjViewMatrix:s,lightDir:n,farPlane:u,cameraLookAt:f.cameraLookAt});d=this.C=g,p=this.T=m,this.k=v,this.A=h.getMeshes().reduce(((t,i)=>(i.castShadow&&i.geometry&&(t[i.uuid]={v0:i.version,v1:i.geometry.version}),t)),{}),this.O={count:h.getMeshes().length-+!!t,displayShadow:!!t},this.I=!0}else d=this.C,p=this.T,this.I=!1;return this.L=i,this.F=e,lt$5(n)&&(n=1),t&&h.getMeshes().length&&this.displayShadow(s,n,o,c),{shadow_lightProjViewMatrix:d,shadow_shadowMap:p,shadow_opacity:n,shadow_color:s||Mt$5,esm_shadow_threshold:this.t}}displayShadow(t,i,e,s){const n=this.C,r=this.S,h=this.R||[],o=this.s.getRenderer().canvas,l=this.P=this.P||[];l[0]=o.width,l[1]=o.height,this.renderer.render(this.u,{halton:e||xt$5,globalTexSize:l,projMatrix:this.L,viewMatrix:this.F,shadow_lightProjViewModelMatrix:multiply$5(h,n,r.localTransform),shadow_shadowMap:this.T,esm_shadow_threshold:this.t,shadow_opacity:i,color:t||Mt$5},this.D,s)}dispose(){this.o.dispose(),this.u.dispose(),this.S&&(this.S.geometry.dispose(),this.S.dispose()),delete this.renderer}isUpdated(){return!1!==this.I}v(t,i,e){if(!this.A)return!0;const s=this.O;if(i.getMeshes().length!==s.count||e!==s.displayShadow)return!0;const n=i.getMeshes();for(let t=0;t<n.length;t++){const i=this.A[n[t].uuid];if(n[t].castShadow&&(n[t].hasSkinAnimation()||!i||i.v0!==n[t].version||i.v1!==n[t].geometry.version))return!0}return!1}p(){const t=new tn$5;t.generateBuffers(this.renderer.regl),this.S=new Be$5(t),this.D=new Ke$5([this.S])}m(){const t=this.s.getMap(),i=ft$5(this.S.localTransform,t);this.S.setLocalTransform(i)}}const bt$5=[0,0],St$5=new t__namespace.Coordinate(0,0),Ct$5=new t__namespace.Coordinate(0,0),Tt$5=[],kt$5=[],At$5=[];function Ot$5(t,i,e,s){const n=t.getGLRes(),r=t.distanceToPointAtRes(i,i,n,e?St$5:null,Ct$5);return s?r.y:r.x}const{createIBLTextures:It$5,disposeIBLTextures:Et$5,getPBRUniforms:Lt$5}=fi$4.PBRUtils,Ft$5=[0,0],Rt$5=[1,1],Pt$5=[],Dt$5=[],Ht$4=[],Nt$5=[],Gt$4=[];class jt$4{static getGroundTransform(t,i){return ft$5(t,i)}constructor(t,i){this.H=t,this.renderer=new B$6(t),this.s=i,this.N=new Ve$5,this.G=this.j.bind(this),this.h()}needToRedraw(){const t=this.B();return t&&(t[0]||t[1])}getMap(){return this.s&&this.s.getMap()}getSymbol(){const t=this.s.getGroundConfig();return t&&t.symbol}isEnable(){const t=this.s.getGroundConfig();return t&&t.enable}paint(t){if(!this.isEnable())return!1;const i=this.U();if(this.V(t)&&i===this.W)return!1;const e=this.q(t);e&&this.S.setDefines(e),this.S.material!==this.material&&this.S.setMaterial(this.material);const s=this.s.getGroundConfig();this.S.ssr=(s&&s.symbol).ssr?1:0,this.m();const n=this.$(t);n.offsetFactor=t.offsetFactor,n.offsetUnits=t.offsetUnits;const r=t&&t.renderTarget&&t.renderTarget.fbo;return i===this.W?(this.renderer.render(i,n,this.D,r),this.s.getRenderer().setCanvasUpdated(),!0):(i.filter=t.sceneFilter,this.renderer.render(i,n,this.D,r),this.s.getRenderer().setCanvasUpdated(),!0)}V(t){return!!(this.s.getRenderer().isEnableSSR&&this.s.getRenderer().isEnableSSR()&&t&&t.ssr)}update(){const t=this.s.getGroundConfig();if(!t)return;const i=t&&t.symbol;if(i){this.Y=this.X(i.polygonFill||[1,1,1,1]),this.J=void 0===i.polygonOpacity?1:i.polygonOpacity;const t=i.polygonPatternFile;if(t){if(!this.Z||this.Z._pattern_src!==t){const i=new Image;i.onload=()=>{this.Z&&this.Z.destroy(),this.Z=this.K(i),this.Z._pattern_src=t,this.setToRedraw()},i.src=t}}else this.Z&&(this.Z.destroy(),delete this.Z)}else this.Y=[1,1,1,1],this.J=1,this.Z&&(this.Z.destroy(),delete this.Z);this.tt()}setToRedraw(){const t=this.s.getRenderer();t&&t.setToRedraw()}dispose(){this.material&&(this.material.dispose(),delete this.material),this.S&&(this.S.geometry.dispose(),this.S.material&&this.S.material.dispose(),this.S.dispose(),delete this.S),this.Z&&(this.Z.destroy(),delete this.Z),this.W&&(this.W.dispose(),delete this.W),this.it&&(this.it.dispose(),delete this.it),this.et(),this.st&&(this.st.destroy(),delete this.st);const t=this.getMap();t&&t.off("updatelights",this.nt,this)}U(){const t=this.s.getGroundConfig();if(!t||!t.renderPlugin)return this.W;const i=t.renderPlugin.type;if("lit"===i)return this.it;if("fill"===i)return this.W;throw new Error("unsupported render plugin of "+i+" for layer ground")}$(t){const i=this.rt(t);return i.polygonFill=this.Y,i.polygonOpacity=this.J,this.U()===this.W&&this.Z&&(i.polygonPatternFile=this.Z),i}rt(t){let i;return"lit"===this.s.getGroundConfig().renderPlugin.type?(this.ht||(this.ht=It$5(this.H,this.getMap())),this.st||(this.st=fi$4.PBRHelper.generateDFGLUT(this.H)),i=Lt$5(this.getMap(),this.ht,this.st,t&&t.ssr,t&&t.jitter)):i={projViewMatrix:this.getMap().projViewMatrix},this.ot(i,t),i}ot(t,i){const e=i&&i.includes;if(e)for(const s in e)e[s]&&i[s].renderUniforms&&at$5(t,i[s].renderUniforms)}et(){this.ht&&(Et$5(this.ht),delete this.ht)}h(){this.getMap().on("updatelights",this.nt,this);const t=this.lt(),i=yt$5.getUniformDeclares(),e=[];i.push({name:"projViewModelMatrix",type:"function",fn:function(t,i){return multiply$5(e,i.projViewMatrix,i.modelMatrix)}}),this.W=new vn$4({vert:"attribute vec3 aPosition;\nuniform mat4 projViewModelMatrix;\nuniform mat4 modelMatrix;\n#ifdef HAS_PATTERN\n    attribute vec2 aTexCoord;\n    uniform vec2 uvScale;\n    uniform vec2 uvOffset;\n    varying vec2 vTexCoord;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n    #include <vsm_shadow_vert>\n#endif\nvoid main () {\n    #ifdef HAS_PATTERN\n        vTexCoord = aTexCoord * uvScale + uvOffset;\n    #endif\n    vec3 position = vec3(aPosition);\n    gl_Position = projViewModelMatrix * vec4(position, 1.0);\n    #if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n        shadow_computeShadowPars(vec4(position, 1.0));\n    #endif\n}",frag:"precision mediump float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n    #include <vsm_shadow_frag>\n#endif\n#ifdef HAS_PATTERN\n    uniform sampler2D polygonPatternFile;\n    varying vec2 vTexCoord;\n#endif\nuniform vec4 polygonFill;\nuniform float polygonOpacity;\nvoid main() {\n    #ifdef HAS_PATTERN\n        vec4 color = texture2D(polygonPatternFile, vTexCoord);\n    #else\n        vec4 color = polygonFill;\n    #endif\n    gl_FragColor = color * polygonOpacity;\n    #if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n        float shadowCoeff = shadow_computeShadow();\n        gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, shadowCoeff);\n    #endif\n}",uniforms:i,extraCommandProps:t});const s=yt$5.getUniformDeclares();s.push(...jn$4.getUniformDeclares()),this.it=new fi$4.StandardShader({uniforms:s,extraCommandProps:t}),this.p(),this.update()}lt(){const t=[0,1],i=this.s.getRenderer().canvas;return{viewport:{x:0,y:0,width:()=>i.width,height:()=>i.height},depth:{enable:!0,mask:()=>{const t=this.s.getGroundConfig();return t.depth||void 0===t.depth},range:()=>{const i=this.s.getGroundConfig(),e=i&&i.renderPlugin.sceneConfig;return e&&e.depthRange||t},func:"<="},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:{factor:(t,i)=>i.offsetFactor,units:(t,i)=>i.offsetUnits}}}}ct(){const t=this.getMap().getLightManager();return!(!t||!t.getAmbientResource())}p(){const t=new tn$5;t.data.aTexCoord=new Uint8Array([0,0,1,0,0,1,1,1]),t.createTangent(),t.generateBuffers(this.renderer.regl),this.S=new Be$5(t,null,{castShadow:!1});const i=this.it.getGeometryDefines(t);this.S.setDefines(i),this.D=new Ke$5([this.S])}m(){const t=this.getMap(),i=jt$4.getGroundTransform(this.S.localTransform,t);this.S.setLocalTransform(i);const e=t.getGLRes(),s=t._get2DExtentAtRes(e),n=s.getWidth(),r=s.getHeight(),h=t.cameraLookAt,o=h[0]-n,a=h[1]-r,l=this.Z?this.Z.width/this.Z.height:1,u=this.getSymbol(),f=this.material?this.material.get("textureOrigin"):u.polygonPatternFileOrigin,d=!!(this.material?this.material.get("uvOffsetInMeter"):u.uvOffsetInMeter),p=(this.material?this.material.get("uvOffset"):u.uvOffset)||Ft$5,g=this.material&&this.material.get("uvScale")||Rt$5,m=this.material?this.material.get("textureWidth"):u.polygonPatternFileWidth,v=this.material?m*(g[1]/g[0]):u.polygonPatternFileHeight,w=this.B(),[x,M,_,y,b]=function(t,i,e,s,n,r,h,o,a,l,u){const f=t.getGLRes();s&&(St$5.set(s[0],s[1]),t.coordToPointAtRes(St$5,f,Ct$5),i-=Ct$5.x,e-=Ct$5.y);const d=s?St$5:null;l=copy(kt$5,l);const p=!a&&l||bt$5;let g=a&&l||bt$5;g=copy(Tt$5,g),g[0]&&(g[0]=Ot$5(t,g[0],d)),g[1]&&(g[1]=Ot$5(t,g[1],d,1));let m=.5;n&&(m=Ot$5(t,n,d));let v=m/h;if(r&&(v=Ot$5(t,r,d,1)),u&&(u[0]||u[1])){const i=performance.now()/1e3;let e=u[0],s=u[1];a&&(e=-Ot$5(t,u[0],d),s=-Ot$5(t,u[1],d,1)),u[0]&&(a?g[0]=i*e:p[0]=i*e),u[1]&&(a?g[1]=i*s:p[1]=i*s)}const w=(i+g[0])/(m/o[0]),x=(e-g[1])/(v/o[1]);return At$5[0]=m/o[0],At$5[1]=v/o[1],At$5[2]=w,At$5[3]=x,At$5[4]=p,At$5}(t,o,a,f,m,v,l,g,d,p,w),S=2*s.getWidth()/x,C=2*s.getHeight()/M;if(!this.material)return this.S.setUniform("uvScale",set(Pt$5,S,C)),void this.S.setUniform("uvOffset",set(Dt$5,_%1+b[0],y%1+b[1]));this.S.setUniform("uvScale",set(Gt$4,S,C)),this.S.setUniform("uvOffset",set(Ht$4,_%1+b[0],y%1+b[1])),this.S.setUniform("uvOrigin",set(Nt$5,_-_%1,y-y%1))}q(t){let i=!1;const e=this.S.defines,s=this.s.ut&&this.s.ut(),n=this.s.getGroundConfig();function r(t,s){t?e[s]||(e[s]=1,i=!0):e[s]&&(delete e[s],i=!0)}r(this.ct(),"HAS_IBL_LIGHTING"),r(t&&t.ssr&&n&&n.symbol&&n.symbol.ssr,"HAS_SSR");const h=t&&s&&s.shadow&&s.shadow.enable;return r(h,"HAS_SHADOWING"),r(h,"USE_ESM"),r(!!this.Z,"HAS_PATTERN"),r(t&&t.ssao,"HAS_SSAO"),i?e:null}tt(){const t=this.getSymbol()&&this.getSymbol().material;if(!t)return;const i={};let e=!1;for(const s in t)if(dt$5(t,s))if(s.indexOf("Texture")>0){let n=t[s];if(!n)continue;n="string"==typeof n?{url:n,wrap:"repeat"}:n,n.flipY=!0,n.min="linear mipmap linear",n.mag="linear",n.flipY=!0,i[s]=new en$5(n,this.N),e=!0}else i[s]=t[s];this.material?(this.ft=new fi$4.StandardMaterial(i),this.ft.isReady()?this.j():this.ft.once("complete",this.G)):(this.material=new fi$4.StandardMaterial(i),this.material.once("complete",this.G,this)),e||this.j()}j(){this.ft&&(this.material.dispose(),this.material=this.ft,delete this.ft),this.setToRedraw(!0)}K(t){t=N$6.resizeToPowerOfTwo(t);return this.H.texture({width:t.width,height:t.height,data:t,mag:"linear",min:"linear mipmap linear",flipY:!0,wrap:"repeat"})}nt(t){if(t.ambientUpdate){this.et();const t=this.getMap();t&&(this.ht=It$5(this.H,t))}this.setToRedraw()}X(t){return mt$5([],t)}B(){return this.material&&this.material.get("uvOffsetAnim")}getRenderMeshes(){return this.D.getMeshes()}}const{createIBLTextures:Bt$5,disposeIBLTextures:Ut$4}=fi$4.PBRUtils,zt$4=[0,0,0],Vt$4=[],Wt$4=[];class qt$4{constructor(t,i){this.dt=4,this.H=t,this.renderer=new B$6(t),this.s=i,this.h(),this.pt()}paint(t){if(!this.isEnable()||!this.gt)return;const i=this.$(t);this.renderer.render(this.vt,i,null,t&&t.renderTarget&&t.renderTarget.fbo)}update(){const t=this.getMap();if(!t||!this.isEnable())return;const i=t.getLightManager(),e=i&&i.getAmbientResource();e!==this.gt&&this.ht&&(Ut$4(this.ht),delete this.ht),this.gt=e,this.pt()}dispose(){this.vt.dispose(),Ut$4(this.ht),delete this.vt,delete this.ht,delete this.gt}getMap(){return this.s.getMap()}pt(){if(!this.gt)return;const t=this.s.ut();this.vt.setMode(1,0,t.environment&&t.environment.mode?1:0)}isEnable(){const t=this.s.ut();return this.ct()&&t&&t.environment&&t.environment.enable}ct(){const t=this.getMap().getLightManager();return!(!t||!t.getAmbientResource())}$(){const t=this.getMap(),i=this.getMap().getLightManager(),e=i&&i.getAmbientLight();let s=this.ht;s||(s=this.ht=Bt$5(this.H,t));const n=this.s.getRenderer().canvas,r=this.s.ut().environment||{},h=r.level||0,o=s.prefilterMap.width,a=this.wt=this.wt||[],f=r.brightness||0;return copy$4(Vt$4,e&&e.hsv||zt$4),f&&(Vt$4[2]+=f),Wt$4[0]=n.width,Wt$4[1]=n.height,{rgbmRange:s.rgbmRange,cubeMap:s.prefilterMap,bias:h,size:o/Math.pow(2,Math.max(0,h-1)),environmentExposure:ct$5(e&&e.exposure)?e.exposure:1,diffuseSPH:s.sh,viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,resolution:Wt$4,hsv:Vt$4,transformMatrix:fromRotation$2(a,e&&Math.PI/180*-e.orientation||0)}}h(){const t=this.getMap();if(t.on("updatelights",this.update,this),this.vt=new qn$4,t.options.lights){const t=this.getMap().getLightManager().getAmbientResource();this.gt=t}}}const $t$4=[],Yt$4=[.03,.03,.03],Xt$4=[],Jt$4=[],Zt$4=[],Kt$4=[1,1,1],Qt$4=[-1200,-1200,0],ti$3=[1200,1200,1e3],ii$3={min:[],max:[]},ei$3=fromRotationTranslation$1([],fromEuler([],90,0,0),[0,0,0]);class si$3{constructor(t,i){this.H=t,this.renderer=new B$6(t),this.s=i,this.xt=new ni$3,this.h()}getMap(){return this.s&&this.s.getMap()}h(){const t=this.s.getRenderer().canvas;this.vt=new vn$4({vert:"attribute vec3 aPosition;\nattribute vec3 aNormal;\nattribute vec2 aTexCoord;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform vec3 cameraPosition;\nuniform float top;\nuniform float bottom;\nuniform float time;\nvarying vec2 vTexCoord;\n#include <get_output>\nfloat angle(float x, float y){\n    return atan(y, x);\n}\nvec2 getFoot(vec2 camera, vec2 normal, vec2 pos) {\n    vec2 position = vec2(0.0, 0.0);\n    float distanceLen = distance(pos, normal);\n    float a = angle(camera.x - normal.x, camera.y - normal.y);\n    pos.x > normal.x ? a -= 0.785 : a += 0.785;\n    position.x = cos(a) * distanceLen;\n    position.y = sin(a) * distanceLen;\n    return position + normal;\n    return position;\n}\nvoid main()\n{\n    vec4 localPosition = getPosition(aPosition);\n    mat4 localPositionMatrix = getPositionMatrix();\n    vec2 foot = getFoot(vec2(cameraPosition.x, cameraPosition.z), vec2(aNormal.x, aNormal.z), vec2(localPosition.x, localPosition.z));\n    float height = top - bottom;\n    float y = aNormal.y - bottom - height * time;\n    y = y + (y < 0.0 ? height : 0.0);\n    float ratio = (1.0 - y / height) * (1.0 - y / height);\n    y = height * (1.0 - ratio);\n    y += bottom;\n    y += aPosition.y - aNormal.y;\n    localPosition = vec4( foot.x, y, foot.y , 1.0);\n    gl_Position = projMatrix * modelViewMatrix * localPositionMatrix * localPosition;\n    vTexCoord = aTexCoord;\n}",frag:"precision mediump float;\nvarying vec2 vTexCoord;\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D rainMap;\nvoid main() {\n    vec4 rainColor = texture2D(rainMap, vTexCoord);\n    vec4 diffuseColor = vec4(diffuse, opacity);\n    diffuseColor *= rainColor;\n    gl_FragColor = diffuseColor;\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(t,i){return multiply$5($t$4,i.viewMatrix,i.modelMatrix)}}],extraCommandProps:{viewport:{x:0,y:0,width:()=>t.width,height:()=>t.height},depth:{enable:!0,mask:!1,func:"less",range:[0,1]},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}}),this.Mt()}Mt(){const t=this.H.texture({width:2,height:2});if(this._t=this.yt(),!this._t)return;this.bt=new Ke$5(this._t);const i=this.St();i.rainTexture?this.Ct(i.rainTexture).then((t=>{this._t.material.set("rainMap",t)})):(this._t.material.set("rainMap",t),console.warn("should set rain texture."))}yt(){const t=this.getMap(),i=this.St();if(!i)return null;this.Tt=t.getZoom();const e=this.kt(),s=this.At=i.density,n=this.Ot=i.rainWidth||1,r=this.It=i.rainHeight||1,h=[],o=[],a=[],l=[];for(let t=0;t<s;t++){const i={};i.x=Math.random()*(e.max[0]-e.min[0])+e.min[0],i.y=Math.random()*(e.max[2]-e.min[2])+e.min[2],i.z=Math.random()*(e.max[1]-e.min[1])+e.min[1];const s=(e.max[2]-e.min[2])/37.5*r,c=s/3*n;h.push(i.x+c,i.y+s,i.z,i.x-c,i.y+s,i.z,i.x-c,i.y,i.z,i.x+c,i.y,i.z),o.push(i.x,i.y-s/2,i.z,i.x,i.y-s/2,i.z,i.x,i.y-s/2,i.z,i.x,i.y-s/2,i.z),a.push(1,1,0,1,0,0,1,0),l.push(4*t+0,4*t+1,4*t+2,4*t+0,4*t+2,4*t+3)}const c={};c.POSITION=h,c.NORMAL=o,c.TEXCOORD_0=a;const u=new Q$7(c,l,0,{primitive:"triangles",positionAttribute:"POSITION",normalAttribute:"NORMAL",uv0Attribute:"TEXCOORD_0"});u.generateBuffers(this.renderer.regl);const f=new Ce$5({rainMap:this.H.texture({width:2,height:2}),diffuse:i.color||[1,1,1],opacity:i.opacity||1}),d=new Be$5(u,f);return d.setUniform("top",e.max[2]),d.setUniform("bottom",e.min[2]),this.Et(d),d.transparent=!0,d}Ct(t){const i=new Image;return i.src=this.Lt=t,new Promise(((t,e)=>{i.onload=()=>{const e=this.H.texture({mag:"linear",min:"linear mipmap nearest",wrapS:"clamp",wrapT:"clamp",data:i});t(e)},i.onerror=t=>{e(t)}}))}paint(t){if(!this.bt)return;const i=this.St(),e={},s=this.getMap();e.projMatrix=s.projMatrix,e.viewMatrix=s.viewMatrix,e.cameraPosition=s.cameraPosition;const n=i.speed||1,r=this.xt.getElapsedTime()/(2/n)%1;e.time=r,this._t.material.set("diffuse",i.color||Kt$4),this._t.material.set("opacity",i.opacity||1),this.Et(this._t);this.renderer.render(this.vt,e,this.bt,t&&t.renderTarget&&t.renderTarget.fbo),this.s.getRenderer().setCanvasUpdated()}Et(t){const i=this.getMap(),e=i.coordinateToPointAtRes(i.getCenter(),i.getGLRes()),s=i.getGLScale()/i.getGLScale(this.Tt),n=set$4(Jt$4,s,s,s),r=multiply$4(n,Yt$4,n),h=identity$2(Zt$4),o=this.St(),c=i.getBearing();fromRotationTranslationScale(h,fromEuler(Xt$4,o.windDirectionX||0,o.windDirectionY||0,90-c),[e.x,e.y,0],r),multiply$5(h,h,ei$3),t.setLocalTransform(h)}setToRedraw(){const t=this.s.getRenderer();t&&t.setToRedraw()}update(){const t=this.St();if(t){if(this._t||this.Mt(),t.density!==this.At||t.rainWidth!==this.Ot||t.rainHeight!==this.It){const t=this._t.material.get("rainMap");this._t.geometry.dispose(),this._t.dispose(),this.bt.clear(),this._t=this.yt(),this._t.material.set("rainMap",t),this.bt.setMeshes(this._t)}t.rainTexture!==this.Lt&&this.Ct(t.rainTexture).then((t=>{this._t.material.set("rainMap",t)}))}}dispose(){this._t&&(this._t.geometry.dispose(),this._t.material&&this._t.material.dispose(),this._t.dispose(),delete this._t),this.vt&&(this.vt.dispose(),delete this.vt)}isEnable(){const t=this.St();return t&&t.enable}St(){const t=this.s.getWeatherConfig();return t&&t.rain}kt(){const t=16.685648411389433-this.getMap().getZoom();return scale$4(ii$3.min,Qt$4,Math.pow(2,t)),scale$4(ii$3.max,ti$3,Math.pow(2,t)),ii$3}}class ni$3{constructor(t){this.autoStart=void 0===t||t,this.startTime=0,this.oldTime=0,this.elapsedTime=0,this.running=!1}start(){this.startTime=("undefined"==typeof performance?Date:performance).now(),this.oldTime=this.startTime,this.elapsedTime=0,this.running=!0}stop(){this.getElapsedTime(),this.running=!1,this.autoStart=!1}getElapsedTime(){return this.getDelta(),this.elapsedTime}getDelta(){let t=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){const i=("undefined"==typeof performance?Date:performance).now();t=(i-this.oldTime)/1e3,this.oldTime=i,this.elapsedTime+=t}return 0}}const ri$3=[],hi$3=[.03,.03,.03],oi$3=[],ai$3=[],li$3=[],ci$3=fromRotationTranslation$1([],fromEuler([],90,0,0),[0,0,0]);class ui$3{constructor(t,i){this.H=t,this.s=i,this.h()}h(){const t=this.s.getRenderer().canvas;this.vt=new vn$4({vert:"#include <gl2_vert>\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\n#include <get_output>\nvoid main()\n{\n    mat4 localPositionMatrix = getPositionMatrix();\n    vec4 localPosition = getPosition(aPosition);\n    gl_Position = projMatrix * modelViewMatrix * localPositionMatrix * localPosition;\n    vTexCoord = aTexCoord;\n}",frag:"#if __VERSION__ == 100\n  #ifdef GL_OES_standard_derivatives\n    #extension GL_OES_standard_derivatives : enable\n  #endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nprecision mediump float;\nuniform sampler2D perlinTexture;\nvarying vec2 vTexCoord;\nfloat lerp(float a, float b, float w) {\n    return a + w * (b - a);\n}\nvoid main() {\n    float snowIntense = texture2D(perlinTexture, vTexCoord).r;\n    vec3 fixedC = vec3(1.0, 1.0, 1.0);\n    float r = lerp(0.5, fixedC.x, snowIntense);\n    float g = lerp(0.5, fixedC.y, snowIntense);\n    float b = lerp(0.5, fixedC.z, snowIntense);\n    glFragColor = vec4(r, g, b, 1.0);\n    #if __VERSION__ == 100\n        gl_FragColor = glFragColor;\n    #endif\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(t,i){return multiply$5(ri$3,i.viewMatrix,i.modelMatrix)}}],extraCommandProps:{viewport:{x:0,y:0,width:()=>t.width,height:()=>t.height}}}),this.vt.version=300,this.bt=new Ke$5,this.Ft=this.Rt(),this.bt.setMeshes(this.Ft),this.renderer=new B$6(this.H);const e=this.Pt();e&&(e.snowGroundTexture?this.Dt(e.snowGroundTexture):(this.Ht=this.H.texture({width:2,height:2}),console.warn("should set snow ground texture.")))}render(t){this.Ht&&this.Ft.material.set("perlinTexture",this.Ht);const i=this.s.getMap();this.Nt(i);this.renderer.render(this.vt,{projMatrix:i.projMatrix,viewMatrix:i.viewMatrix,cameraPosition:i.cameraPosition},this.bt,t&&t.renderTarget&&t.renderTarget.fbo),this.s.getRenderer().setCanvasUpdated()}Nt(t){const i=t.coordinateToPointAtRes(t.getCenter(),t.getGLRes()),e=t.getGLScale()/t.getGLScale(this.Tt),s=set$4(ai$3,e,e,e),n=multiply$4(s,hi$3,s),r=identity$2(li$3);fromRotationTranslationScale(r,fromEuler(oi$3,0,0,0),[i.x,i.y,.005],n),multiply$5(r,r,ci$3),this.Ft.setLocalTransform(r)}Dt(t){const i=new Image;i.onload=()=>{this.Ht=this.H.texture({mag:"linear",min:"linear mipmap nearest",wrapS:"repeat",wrapT:"repeat",data:i})},i.onerror=t=>{console.log(t)},i.src=this.Gt=t}Rt(){const t=this.s.getMap();this.Tt=t.getZoom();const i=16e3*Math.pow(2,16.685648411389433-this.Tt),s={};s.POSITION=[-i,0,-i,i,0,-i,-i,0,i,i,0,i],s.NORMAL=[0,1,0,0,1,0,0,1,0,0,1,0],s.TEXCOORD_0=[0,0,1,0,0,1,1,1];const n=new Q$7(s,[3,1,0,0,2,3],0,{positionAttribute:"POSITION",normalAttribute:"NORMAL",uv0Attribute:"TEXCOORD_0"});n.generateBuffers(this.H);const r=new Ce$5({perlinTexture:this.H.texture({with:2,height:2})});return new Be$5(n,r)}getMeshes(){return this.Ft}dispose(){this.Ft&&(this.Ft.geometry.dispose(),this.Ft.material&&this.Ft.material.dispose(),this.Ft.dispose(),delete this.Ft),this.vt&&(this.vt.dispose(),delete this.vt)}update(){const t=this.Pt();t&&t.snowGroundTexture===!this.Gt&&this.Dt(t.snowGroundTexture)}isEnable(){const t=this.St();return t&&t.enable}Pt(){const t=this.s.getWeatherConfig();return t&&t.snow}}
/*!
	 * @maptalks/gltf-loader v0.95.2
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */if(identity$1([]),"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8"),"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8"),"undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}}"undefined"!=typeof document&&document.createElement("canvas");const fi$3=[];class di$3{constructor(t,i,e){this.H=t,this.s=i,this.jt=e,this.h()}h(){this.renderer=new B$6(this.H);const t=this.s.getRenderer(),i=this.Bt={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.Ut=i.width,this.zt=i.height,this.Vt=this.H.framebuffer({color:this.H.texture({width:t.canvas?t.canvas.width:1,height:t.canvas?t.canvas.height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.EMPTY_TEXTURE=this.H.texture({with:2,height:2}),this.Wt=new si$3(this.H,this.s),this.qt=new dt$6(this.H,i),this.$t=new ui$3(this.H,this.s),this.Yt=new rt$6(this.H,i,this.s),this.Xt=new it$5,this.Xt.version=300}getMap(){return this.s&&this.s.getMap()}renderScene(t){this.renderSnowMask(t),this.renderRain(t)}renderRain(t){this.isEnableRain()&&this.Wt.paint(t)}renderSnowMask(t){if(!this.isEnableSnow())return;const i=this.getMap();this.$t.render(t,i)}paint(t,i){if(!i||!i.length)return t;this.Jt();const e=this.s.getWeatherConfig(),s={};var n;if(this.isEnableRain()?(s.ripplesMap=this.Zt(),this.Xt.shaderDefines.HAS_RAIN=1):delete this.Xt.shaderDefines.HAS_RAIN,this.isEnableSnow()?(this.Xt.shaderDefines.HAS_SNOW=1,s.snowIntensity="number"!=typeof(n=e.snow.snowIntensity)||isNaN(n)?.5:e.snow.snowIntensity,i.forEach((t=>{t.defines.HAS_SNOW=1}))):(delete this.Xt.shaderDefines.HAS_SNOW,i.forEach((t=>{delete t.defines.HAS_SNOW}))),this.isEnableFog()){s.fogColor=e.fog.color||[.9,.9,.9],this.Xt.shaderDefines.HAS_FOG=1}else delete this.Xt.shaderDefines.HAS_FOG;return this.Xt.setDefines(this.Xt.shaderDefines),s.mixFactorMap=this.Kt(i)||this.EMPTY_TEXTURE,s.sceneMap=t,s.time=this.Qt()/1e3,s.resolution=set(fi$3,this.Vt.width,this.Vt.height),this.renderer.render(this.Xt,s,null,this.Vt),this.ti=i,this.Vt}Kt(t){const i={},e=this.getMap(),s=e.getZoom(),n=Math.pow(2,16.685648411389433-s),r=this.s.getWeatherConfig(),h=r.fog;if(!h||!h.enable)return null;const o=h.start||.1,a=h.end||100;i.projMatrix=e.projMatrix,i.viewMatrix=e.viewMatrix,i.cameraPosition=e.cameraPosition,i.fogDist=[o*n,a*n],i.rainDepth=e.altitudeToPoint(r.rain&&r.rain.rainDepth||.1,e.getGLRes());const l=this.Yt.render(t,i);return this.s.getRenderer().ii(l)}Zt(){const t=this.getMap(),i=this.s.getWeatherConfig(),e=i.rain.rippleRadius||24,s={};return s.projMatrix=t.projMatrix,s.viewMatrix=t.viewMatrix,s.time=this.Qt()/1e3,s.rippleRadius=e,s.density=i.rain.density||2e3,this.qt.render(t,s)}Qt(){if(!this.s)return 0;if(void 0===this.ei&&(this.ei=0),this.isPlaying()){const t=this.s.getRenderer();this.ei=t.getFrameTime()}return this.ei}isEnable(){const t=this.s.getWeatherConfig();return t&&t.enable}isEnableRain(){const t=this.s.getWeatherConfig();return t&&t.enable&&t.rain&&t.rain.enable}isEnableFog(){const t=this.s.getWeatherConfig();return t&&t.enable&&t.fog&&t.fog.enable}isEnableSnow(){const t=this.s.getWeatherConfig();return t&&t.enable&&t.snow&&t.snow.enable}isPlaying(){const t=this.s.getWeatherConfig();return!!t&&!1!==t.playing}si(){return this.isEnableRain()||this.isEnableFog()||this.isEnableSnow()}update(){!this.isEnable()&&this.ti&&this.ti.forEach((t=>{delete t.defines.HAS_SNOW,delete t.defines.HAS_RAIN,delete t.defines.HAS_FOG})),this.isEnableRain()&&(this.Wt=this.Wt||new si$3(this.H,this.s),this.Wt.update()),this.isEnableSnow()&&(this.$t=this.$t||new ui$3(this.H,this.s),this.$t.update())}getShadowMeshes(){return this.$t.getMeshes()}Jt(){const t=this.Ut(),i=this.zt();!this.Vt||this.Vt.width===t&&this.Vt.height===i||this.Vt.resize(t,i)}dispose(){this.Vt&&this.Vt.destroy(),this.Xt&&(this.Xt.dispose(),delete this.Xt),this.Wt&&(this.Wt.dispose(),delete this.Wt),this.$t&&(this.$t.dispose(),delete this.$t)}}const pi$3=[],gi$3=t=>!!t.bloom,mi$3=t=>!!t.ssr;class vi$3{constructor(t,i,e){this.H=t,this.s=i,this.ni=new B$6(t),this.ri=new Cn$4,this.hi=new Hn$4(this.ni,e),this.oi=new Zn$4,this.ai=new jn$4(this.H)}setContextIncludes(){}bloom(t,i,e,s,n,r,h){this.li||(this.li=new Un$4(this.H));const o=this.s.getRenderer().ii(this.ci);return this.li.render(t,o,s,n,r,i,e,h)}drawBloom(t){const i=this.s.getRenderer(),e=this.H,s=this.ci;if(s){const{width:i,height:n}=t;s.width===i&&s.height===n||s.resize(i,n),e.clear({color:[0,0,0,0],framebuffer:s})}else{const i=this.ui(t);this.ci=e.framebuffer(i)}const n=i.getFrameTime(),r=i.getFrameEvent(),h=i.getFrameContext(),o=h.renderMode,a=h.sceneFilter,l=h.renderTarget;h.isPostProcess=!0,h.renderMode="default",h.sceneFilter=gi$3,h.renderTarget={fbo:this.ci,getFramebuffer:wi$3,getDepthTexture:xi$3};const c=i.glCtx;return c.resetDrawCalls(),i.forEachRenderer(r?t=>{i.clearStencil(t,s),t.drawOnInteracting(r,n,h)}:t=>{i.clearStencil(t,s),t.draw(n,h)}),delete h.isPostProcess,h.renderMode=o,h.sceneFilter=a,h.renderTarget=l,c.getDrawCalls()}genSsrMipmap(t,i){const e=this.s.getMap().projViewMatrix;this.ai.genMipMap(t,i,e)}getPrevSsrProjViewMatrix(){return this.ai&&this.ai.getPrevProjViewMatrix()}drawSSR(t,i,e){e&&this.ai.copyDepthTex(t);const s=this.s.getRenderer(),n=s.getFrameTime(),r=s.getFrameEvent(),h=s.getFrameContext();h.isPostProcess=!0,h.ssr=this.getSSRContext();const o=h.renderMode,a=h.sceneFilter;h.renderMode="default",h.sceneFilter=mi$3,h.renderTarget.fbo=i;const l=s.glCtx;let c=!1;s.forEachRenderer(r?t=>{s.clearStencil(t,i),c||(l.resetDrawCalls(),c=!0),t.drawOnInteracting(r,n,h)}:t=>{s.clearStencil(t,i),c||(l.resetDrawCalls(),c=!0),t.draw(n,h)});const u=s.drawGround();return delete h.ssr,delete h.isPostProcess,h.renderMode=o,h.sceneFilter=a,this.fi=l.getDrawCalls()>0,u}getSSRUniforms(){const t=this.s.ut(),i=t&&t.postProcess,e=this.s.getMap();return this.ai.getSSRUniforms(e,i.ssr.factor,i.ssr.quality)}getSSRContext(){const t=this.s.ut(),i=t&&t.postProcess,e=this.s.getMap(),s=this.ai.getSSRUniforms(e,i.ssr.factor,i.ssr.quality);return s?{renderUniforms:s,defines:{HAS_SSR:1}}:null}taa(t,i,{projMatrix:e,needClear:s}){const n=this.hi;return{outputTex:n.render(t,i,e,s),redraw:n.needToRedraw()}}isTaaNeedRedraw(){return this.hi.needToRedraw()}ssao(t,i,e){return this.di||(this.di=new Dn$4(this.ni),this.s.getRenderer().setToRedraw()),this.di.render({projMatrix:e.projMatrix,cameraNear:e.cameraNear,cameraFar:e.cameraFar,bias:e.ssaoBias,radius:e.ssaoRadius,intensity:e.ssaoIntensity,quality:.6},t,i)}fxaa(t,i,e,s,n,r,h,o,a,l,u,f,d,p,g,m){!t||t.width===i.fbo&&t.height===i.height||t.resize(i.width,i.height);const v={};n?v.HAS_TAA_TEX=1:delete v.HAS_TAA_TEX,r?v.HAS_FXAA_TEX=1:delete v.HAS_FXAA_TEX,f?v.HAS_OUTLINE_TEX=1:delete v.HAS_OUTLINE_TEX,e?v.HAS_NOAA_TEX=1:delete v.HAS_NOAA_TEX,s?v.HAS_POINT_TEX=1:delete v.HAS_POINT_TEX,this.ri.setDefines(v),this.ni.render(this.ri,{textureSource:i,noAaTextureSource:e,pointTextureSource:s,taaTextureSource:n,fxaaTextureSource:r,resolution:set(pi$3,i.width,i.height),enableFXAA:h,enableToneMapping:o,enableSharpen:a,pixelRatio:l,sharpFactor:u,textureOutline:f,highlightFactor:d,outlineFactor:p,outlineWidth:g,outlineColor:m},null,t)}renderFBOToScreen(t,i,e,s){this.pi||(this.pi=[]),this.pi[0]=t.width,this.pi[1]=t.height;const n=this.s.getRenderer();this.ni.render(this.oi,{texture:t.color&&n.ii(t)||t,size:this.pi,enableSharpen:+!!i,sharpFactor:e,pixelRatio:s})}postprocess(t,i,e){this.gi||(this.gi=new Rn$4);const s=this.s&&this.s.getRenderer(),n=e||s.ii(t);return i.resolution=set(pi$3,n.width,n.height),i.textureSource=n,i.timeGrain=performance.now(),this.ni.render(this.gi,i),this.mi}dispose(){this.ci&&(this.ci.destroy(),delete this.ci),this.hi&&(this.hi.dispose(),delete this.hi),this.di&&(this.di.dispose(),delete this.di),this.li&&(this.li.dispose(),delete this.li),this.gi&&(this.gi.dispose(),delete this.gi),this.ri&&(this.ri.dispose(),delete this.ri),this.oi&&(this.oi.dispose(),delete this.oi)}ui(t,i){const{width:e,height:s}=this.s.getRenderer().canvas,n=this.H;let r;r=this.s.getRenderer().vi()?n.renderbuffer({width:e,height:s,samples:this.s.options.multiSamples,format:"rgba8"}):n.texture({min:"nearest",mag:"nearest",format:i||"rgba",width:e,height:s});const h={width:e,height:s,colors:[r]};return t&&(h.depthStencil=t),h}}function wi$3(t){return t._framebuffer.framebuffer}function xi$3(t){return t.depthStencil._texture.texture}class Mi$3 extends Mn$4{constructor(t){super({vert:"#if __VERSION__ == 300\n\t#define attribute in\n\t#define varying out\n#endif\nattribute vec2 aPosition;\nattribute vec2 aTexCoord;\nvarying vec2 vTexCoord;\nvoid main()\n{\n  gl_Position = vec4(aPosition, 0., 1.);\n  vTexCoord = aTexCoord;\n}",frag:"#if __VERSION__ == 100\n  #ifdef GL_OES_standard_derivatives\n    #extension GL_OES_standard_derivatives : enable\n  #endif\n#endif\nprecision mediump float;\n#include <gl2_frag>\nvarying vec2 vTexCoord;\n#ifdef HAS_FLOODANALYSE\n    uniform vec3 flood_waterColor;\n    uniform float flood_waterOpacity;\n    uniform sampler2D floodMap;\n#endif\n#ifdef HAS_SKYLINE\n    uniform sampler2D skylineMap;\n#endif\n#ifdef HAS_VIEWSHED\n    uniform vec4 viewshed_visibleColor;\n    uniform vec4 viewshed_invisibleColor;\n    uniform sampler2D viewshedMap;\n#endif\n#ifdef HAS_INSIGHT\n    uniform vec4 insight_visibleColor;\n    uniform vec4 insight_invisibleColor;\n    uniform sampler2D insightMap;\n#endif\n#ifdef HAS_CUT\n    uniform sampler2D meshesMap;\n    uniform sampler2D invisibleMap;\n#endif\n#ifdef HAS_EXCAVATE\n    uniform sampler2D excavateMap;\n#endif\n#ifdef HAS_CROSSCUT\n    uniform sampler2D crosscutMap;\n    uniform vec4 cutLineColor;\n#endif\n#ifdef HAS_HEIGHTLIMIT\n    uniform vec3 limitColor;\n    uniform sampler2D heightLimitMap;\n#endif\nuniform sampler2D sceneMap;\nvoid main() {\n    vec4 sceneColor = texture2D(sceneMap, vTexCoord);\n    glFragColor = sceneColor;\n    #ifdef HAS_VIEWSHED\n        vec4 viewshedColor = texture2D(viewshedMap, vTexCoord);\n        if (viewshedColor.r > 0.99) {\n            glFragColor = vec4(mix(viewshed_invisibleColor.rgb, sceneColor.rgb, viewshed_invisibleColor.a), sceneColor.a);\n        } else if (viewshedColor.g > 0.99) {\n            glFragColor = vec4(mix(viewshed_visibleColor.rgb, sceneColor.rgb, viewshed_visibleColor.a), sceneColor.a);\n        } else if (viewshedColor.a < 0.01) {\n            glFragColor = vec4(viewshedColor.rgb, 1.0);\n        }\n    #endif\n    #ifdef HAS_FLOODANALYSE\n        vec4 floodColor = texture2D(floodMap, vTexCoord);\n        if (floodColor.r > 0.0) {\n            glFragColor = vec4(mix(glFragColor.rgb, flood_waterColor, flood_waterOpacity), glFragColor.a);\n        }\n    #endif\n    #ifdef HAS_SKYLINE\n        vec4 skylineColor = texture2D(skylineMap, vTexCoord);\n        if (skylineColor.r > 0.0 || skylineColor.g > 0.0 || skylineColor.b > 0.0) {\n            glFragColor = skylineColor;\n        }\n    #endif\n    #ifdef HAS_INSIGHT\n        vec4 insightColor = texture2D(insightMap, vTexCoord);\n        if (insightColor.g > 0.0) {\n            glFragColor = insight_visibleColor;\n        } else if (insightColor.r > 0.0) {\n            glFragColor = insight_invisibleColor;\n        }\n    #endif\n    #ifdef HAS_CUT\n        vec4 cutColor = texture2D(invisibleMap, vTexCoord);\n        vec4 meshesMapColor = texture2D(meshesMap, vTexCoord);\n        if (cutColor.r == 1.0 && cutColor.g == 0.0 && cutColor.b == 0.0) {\n            glFragColor = meshesMapColor;\n        } else if (cutColor.r == 0.0 && cutColor.g == 1.0 && cutColor.b == 0.0) {\n            glFragColor = meshesMapColor;\n        } else if (cutColor.r == 0.0 && cutColor.g == 0.0 && cutColor.b == 1.0) {\n          glFragColor = sceneColor;\n        }\n    #endif\n    #ifdef HAS_EXCAVATE\n        vec4 excavateColor = texture2D(excavateMap, vTexCoord);\n        if (excavateColor.r == 1.0 && excavateColor.g == 0.0 && excavateColor.b == 0.0) {\n          glFragColor = sceneColor;\n        }  else {\n          glFragColor = excavateColor;\n        }\n    #endif\n    #ifdef HAS_CROSSCUT\n        vec4 crosscutColor = texture2D(crosscutMap, vTexCoord);\n        if (crosscutColor.r > 0.0) {\n            glFragColor = vec4(mix(cutLineColor.rgb, glFragColor.rgb, 0.99), glFragColor.a);\n        }\n    #endif\n    #ifdef HAS_HEIGHTLIMIT\n        vec4 heightLimitColor = texture2D(heightLimitMap, vTexCoord);\n        if (heightLimitColor.r > 0.0) {\n            glFragColor = vec4(mix(limitColor, glFragColor.rgb, 0.6), glFragColor.a);\n        }\n    #endif\n    #if __VERSION__ == 100\n        gl_FragColor = glFragColor;\n    #endif\n}",extraCommandProps:{viewport:t,cull:{enable:!0},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}})}}class _i$3{constructor(t,i,e){this.H=t,this.s=i,this.jt=e,this.h()}h(){this.renderer=new B$6(this.H);const t=this.s.getRenderer(),i=this.Bt={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.Vt=this.H.framebuffer({color:this.H.texture({width:t.canvas?t.canvas.width:1,height:t.canvas?t.canvas.height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.vt=new Mi$3(i)}getMap(){return this.s&&this.s.getMap()}paint(t,i){if(!i&&i.length)return t;this.Jt();const e={},s=this.s.wi;if(!this.xi())return t;this.H.clear({color:[0,0,0,0],depth:1,stencil:0,framebuffer:this.Vt}),delete this.vt.shaderDefines.HAS_FLOODANALYSE,delete this.vt.shaderDefines.HAS_VIEWSHED,delete this.vt.shaderDefines.HAS_SKYLINE,delete this.vt.shaderDefines.HAS_INSIGHT,delete this.vt.shaderDefines.HAS_CUT,delete this.vt.shaderDefines.HAS_CROSSCUT,delete this.vt.shaderDefines.HAS_HEIGHTLIMIT;for(let t=0;t<s.length;t++){const n=s[t];if(!n.isEnable())continue;const r=n.getDefines();at$5(this.vt.shaderDefines,r);const h=this.getMap(),o=h.width,a=h.height,l=this.Mi(i,n.getExcludeLayers()),c=n.renderAnalysis(l,o,a);c&&at$5(e,c)}return e.sceneMap=t,this.vt.setDefines(this.vt.shaderDefines),this.renderer.render(this.vt,e,null,this.Vt),this.Vt}Mi(t,i){let e=[];for(let s=0;s<t.length;s++){if(i.indexOf(t[s].getId())>-1)continue;const n=t[s].getRenderer();if(n&&n.getAnalysisMeshes){const t=n.getAnalysisMeshes();t.forEach((t=>{t.setUniform("useAnalysis",1)})),e=e.concat(t)}}return e}Jt(){const t=t$1.Util.isFunction(this.Bt.width.data)?this.Bt.width.data():this.Bt.width,i=t$1.Util.isFunction(this.Bt.height.data)?this.Bt.height.data():this.Bt.height;!this.Vt||this.Vt.width===t&&this.Vt.height===i||this.Vt.resize(t,i)}xi(){const t=this.s&&this.s.wi;if(!t)return!1;for(let i=0;i<t.length;i++)if(t[i].isEnable())return!0;return!1}}const yi$3=[0,0,0,0],bi$3=[1,1,-1],Si$3=[0,0],Ci$3=t=>!t.bloom&&!t.ssr,Ti$3=t=>!t.bloom,ki$3=t=>!t.ssr;function Oi$3(t){return"number"==typeof t&&!isNaN(t)}function Ii$3(t){return t._framebuffer.framebuffer}function Ei$3(t){return t.depthStencil._texture.texture}function Li$3(t,i,e){return null==t[i]?e:t[i]}class Fi$3 extends t__namespace.worker.Actor{constructor(t){super("@maptalks/terrain"),this.mapId=t}checkUrl(i){return i&&t__namespace.Util.isString(i)?t__namespace.Util.getAbsoluteURL(i):i}fetchTerrain(t,i,e){t=this.checkUrl(t);const s={actorId:this.actorId,mapId:this.mapId,command:"fetchTerrain",params:{url:t,origin:location.origin,terrainWidth:i.terrainWidth,type:i.type,accessToken:i.accessToken,cesiumIonTokenURL:i.cesiumIonTokenURL,error:i.error}};this.send(s,null,((t,i)=>{t?e(t):e(t,i)}))}abortTerrain(t,i){this.broadcast({actorId:this.actorId,mapId:this.mapId,command:"abortTerrain",params:{url:t}},null,i)}addLayer(t,i,e){this.broadcast({actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{}},null,e)}createTerrainMesh(t,i){this.send({actorId:this.actorId,command:"createTerrainMesh",params:t},[t.terrainHeights.data.buffer],((t,e)=>{t?i(t):i(t,e)}))}removeLayer(t,i,e){this.broadcast({mapId:this.mapId,layerId:t,command:"removeLayer"},null,e)}}class Ri$3{constructor(t=257){this.gridSize=t;const i=t-1;if(i&i-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=i*i*2-2,this.numParentTriangles=this.numTriangles-i*i,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let e=t+2,s=0,n=0,r=0,h=0,o=0,a=0;for(1&e?r=h=o=i:s=n=a=i;(e>>=1)>1;){const t=s+r>>1,i=n+h>>1;1&e?(r=s,h=n,s=o,n=a):(s=r,n=h,r=o,h=a),o=t,a=i}const l=4*t;this.coords[l+0]=s,this.coords[l+1]=n,this.coords[l+2]=r,this.coords[l+3]=h}}createTile(t){return new Pi$3(t,this)}}class Pi$3{constructor(t,i){const e=i.gridSize;if(t.length!==e*e)throw new Error(`Expected terrain data of length ${e*e} (${e} x ${e}), got ${t.length}.`);this.terrain=t,this.martini=i,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:i,coords:e,gridSize:s}=this.martini,{terrain:n,errors:r}=this;for(let h=t-1;h>=0;h--){const t=4*h,o=e[t+0],a=e[t+1],l=e[t+2],c=e[t+3],u=o+l>>1,f=a+c>>1,d=u+f-a,p=f+o-u,m=f*s+u,v=Math.abs((n[a*s+o]+n[c*s+l])/2-n[m]);if(r[m]=Math.max(r[m],v),h<i){r[m]=Math.max(r[m],r[(a+p>>1)*s+(o+d>>1)],r[(c+p>>1)*s+(l+d>>1)])}}}getMesh(t=0){const{gridSize:i,indices:e}=this.martini,{errors:s}=this;let n=0,r=0;const h=i-1;function o(h,a,l,c,u,f){const d=h+l>>1,p=a+c>>1;Math.abs(h-u)+Math.abs(a-f)>1&&s[p*i+d]>t?(o(u,f,h,a,d,p),o(l,c,u,f,d,p)):(e[a*i+h]=e[a*i+h]||++n,e[c*i+l]=e[c*i+l]||++n,e[f*i+u]=e[f*i+u]||++n,r++)}e.fill(0),o(0,0,h,h,h,0),o(h,h,0,0,0,h);const a=new Uint16Array(2*n),l=new Uint32Array(3*r);let c=0;function u(n,r,h,o,f,d){const p=n+h>>1,g=r+o>>1;if(Math.abs(n-f)+Math.abs(r-d)>1&&s[g*i+p]>t)u(f,d,n,r,p,g),u(h,o,f,d,p,g);else{const t=e[r*i+n]-1,s=e[o*i+h]-1,u=e[d*i+f]-1;a[2*t]=n,a[2*t+1]=r,a[2*s]=h,a[2*s+1]=o,a[2*u]=f,a[2*u+1]=d,l[c++]=t,l[c++]=s,l[c++]=u}}return u(0,0,h,h,h,0),u(h,h,0,0,0,h),{vertices:a,triangles:l}}getMeshWithSkirts(t=0,i){const{gridSize:e,indices:s}=this.martini,{errors:n}=this;let r=0,h=0;const o=e-1;let a,l,c=0;const u=[],f=[],d=[],p=[];function g(i,m,v,w,x,M){const _=i+v>>1,y=m+w>>1;Math.abs(i-x)+Math.abs(m-M)>1&&n[y*e+_]>t?(g(x,M,i,m,_,y),g(v,w,x,M,_,y)):(a=m*e+i,l=w*e+v,c=M*e+x,0===s[a]&&(0===i?u.push(r):i===o&&f.push(r),0===m?d.push(r):m===o&&p.push(r),s[a]=++r),0===s[l]&&(0===v?u.push(r):v===o&&f.push(r),0===w?d.push(r):w===o&&p.push(r),s[l]=++r),0===s[c]&&(0===x?u.push(r):x===o&&f.push(r),0===M?d.push(r):M===o&&p.push(r),s[c]=++r),h++)}let m;s.fill(0),g(0,0,o,o,o,0),g(o,o,0,0,0,o),m=i?2*(r+3*u.length-2+3*f.length-2+3*d.length-2+3*p.length-2):2*(r+u.length+f.length+d.length+p.length);const v=3*(h+2*(u.length-1)+2*(f.length-1)+2*(d.length-1)+2*(p.length-1)),w=new Uint16Array(m),x=new Uint32Array(v);let M=0;function _(i,r,h,o,a,l){const c=i+h>>1,u=r+o>>1;if(Math.abs(i-a)+Math.abs(r-l)>1&&n[u*e+c]>t)_(a,l,i,r,c,u),_(h,o,a,l,c,u);else{const t=s[r*e+i]-1,n=s[o*e+h]-1,c=s[l*e+a]-1;w[2*t]=i,w[2*t+1]=r,w[2*n]=h,w[2*n+1]=o,w[2*c]=a,w[2*c+1]=l,x[M++]=t,x[M++]=n,x[M++]=c}}_(0,0,o,o,o,0),_(o,o,0,0,0,o),u.sort(((t,i)=>w[2*t+1]-w[2*i+1])),f.sort(((t,i)=>w[2*i+1]-w[2*t+1])),d.sort(((t,i)=>w[2*i]-w[2*t])),p.sort(((t,i)=>w[2*t]-w[2*i]));let y,b,S,C,T=2*r,k=0;function A(t){k=t.length;for(let e=0;e<k-1;e++)y=t[e],b=t[e+1],S=T/2,C=(T+(i?6:2))/2,w[T++]=2*y,w[T++]=2*y+1,i&&(w[T++]=2*y,w[T++]=2*y+1,w[T++]=2*b,w[T++]=2*b+1),i?(x[M++]=S+1,x[M++]=S,x[M++]=S+2,x[M++]=S,x[M++]=C,x[M++]=S+2):(x[M++]=y,x[M++]=S,x[M++]=b,x[M++]=S,x[M++]=C,x[M++]=b);w[T++]=2*t[k-1],w[T++]=2*t[k-1]+1}A(u);const O=T;A(f);const I=T;A(d);const E=T;return A(p),{vertices:w,triangles:x,numVerticesWithoutSkirts:r,numTrianglesWithoutSkirts:h,leftSkirtIndex:O,rightSkirtIndex:I,bottomSkirtIndex:E,topSkirtIndex:T}}}const Di$3={};function Hi$3(t,i,e,s){let n=Di$3[e];n||(n=Di$3[e]=new Ri$3(e));const r=n.createTile(i),h=s?r.getMeshWithSkirts(t,!0):r.getMesh(t),{triangles:o,vertices:a,leftSkirtIndex:l,rightSkirtIndex:c,bottomSkirtIndex:u,topSkirtIndex:f}=h;let{numVerticesWithoutSkirts:d,numTrianglesWithoutSkirts:p}=h;d||(d=a.legnth/3,p=o.length/3);const g=a.length/2,m=new Float32Array(3*g),v=new Float32Array(2*g);let w=1/0,x=-1/0;const M=e-1;for(let t=0;t<g;t++){const s=a[2*t],n=a[2*t+1];if(t>=d){const i=s/2*3;let e,n=.001;(t-(t<l/2?d:t<c/2?l/2:t<u/2?c/2:u/2))%3==0?(e=0,n=0):e=m[i+2],m[3*t]=m[i],m[3*t+1]=m[i+1],m[3*t+2]=e,v[2*t]=m[i]/M+n,v[2*t+1]=-m[i+1]/M+n}else m[3*t]=1*s,m[3*t+1]=1*-n,m[3*t+2]=i[n*e+s],v[2*t]=s/M,v[2*t+1]=n/M;const r=m[m.length-1];r<w&&(w=r),r>x&&(x=r)}return{positions:m,texcoords:v,triangles:o,leftSkirtIndex:l,rightSkirtIndex:c,bottomSkirtIndex:u,topSkirtIndex:f,numTrianglesWithoutSkirts:p,numVerticesWithoutSkirts:d,minHeight:w,maxHeight:x,terrainWidth:e}}function Ni$3(t,i,e,s,n,r,h,o,a){const l={};for(let c=0;c<a;c++)l[c+""]=ji$3(t,i,e,s,n,r,h,o,c);return l}const Gi$3=[];function ji$3(t,i,e,s,n,r,h,o,a){if((s-=a)<=0)return Gi$3;const l=t.getTileSize().width,c=t._getTileOffset(s,n),u=r[0]-c[0],f=c[1]-r[1],d=t._getTileConfig(),p=t.getSpatialReference().getResolution(s),g=d.tileSystem.scale.y;let m=0,v=0,w=o/=Math.pow(2,a),x=o;if(u<0?w+=Math.ceil(-u/l-1e-7):u>0&&(m-=Math.ceil(u/l-1e-7)),f>0?v-=Math.ceil(f/l-1e-7):f<0&&(x+=Math.ceil(-f/l-1e-7)),0===m&&0===v&&w<=1&&x<=1){const n=Math.floor(i*o);let r=Math.floor(e*o);const a=r;return g!==h&&(r=zi$3(d,r,p)),[{x:n,y:r,skinY:a,z:s,offset:c,tileSize:l,id:t._getTileId(n,r,s)}]}const M=[];for(let n=m;n<w;n++)for(let r=v;r<x;r++){const a=i*o+n;let u=e*o+r;const f=u;g!==h&&(u=zi$3(d,u,p)),M.push({x:a,y:u,skinY:f,z:s,offset:c,tileSize:l,id:t._getTileId(a,u,s)})}return M}function Bi$3(t,i,e,s){let n=t/e*s/i;return n<1?(n=1/n,n=1/Math.round(n)):n=Math.round(n),n}function Ui$3(t,i,e){const s=t.getResolution(i),n=i-Math.log(e/s)*Math.LOG2E;return{zoom:n,res:t.getResolution(n)}}function zi$3(t,i,e){const s=t.fullExtent,n=t.tileSize.width,r=Math.max(s.top,s.bottom),h=Math.min(s.top,s.bottom);return Math.ceil(r/n/e)-1-Math.floor(h/n/e)-i}function Vi$3(t,i){const e=i*i,s=0!==t?new Float32Array(e):new Uint8Array(e);return s.fill(t),{data:s,width:i,height:i,max:t,min:t}}new t__namespace.Point(0,0);const Wi$3=Vi$3(0,5),qi$3=Hi$3(1,Wi$3.data,Wi$3.width,!0);qi$3.empty=!0;const $i$3=[],Yi$3=[];class Xi$3{constructor(t){this.layer=t,this.regl=t.getRenderer().regl,this.renderer=new B$6(this.regl),this.Ae=new Ke$5;const i=new Uint8Array(16);i.fill(255),this.Oe=this.regl.texture({width:2,height:2,data:i}),this.Ie=new Ve$5(this.Oe),this.Ee()}setToRedraw(){this.layer.getRenderer().setToRedraw()}getMap(){return this.layer.getMap()}startFrame(){this.shader||this.initShader(),this.Ae.clear()}createTerrainMesh(t,i){const{mesh:e,image:s}=i;let n=i.terrainMesh;const{positions:r,texcoords:h,triangles:o,empty:a}=e;if(n&&n.geometry!==this.Le)n.geometry.updateData("aPosition",r),n.geometry.updateData("aTexCoord",h),n.geometry.setElements(o);else{const t=a?this.Le:new Q$7({aPosition:r,aTexCoord:h},o,0);n?n.geometry=t:(n=new Be$5(t,null,{disableVAO:!0}),t.generateBuffers(this.regl))}if(!n.uniforms.skin){const t=this.getEmptyTexture();n.setUniform("skin",t)}return n.setUniform("heightTexture",s),this.prepareMesh(n,t,i),n}Fe(t){const i=this.layer.getRenderer();i&&i.updateMaskDefines(t)}Re(t){const i=this.Pe(100)/100,e=identity$2(t);return scale$5(e,e,[1,1,i]),e}De(t,i,e){const s=this.getMap(),n=this.layer.getTileSize().width,r=i.res/s.getGLRes(),h=n/(e-1),{extent2d:o,offset:c}=i;set$4($i$3,(o.xmin-c[0])*r,(i.extent2d.ymax-c[1])*r,0);const u=identity$2(t);return translate$1(u,u,$i$3),set$4(Yi$3,r*h,r*h,1),scale$5(u,u,Yi$3),u}prepareMesh(t,i,e){if(!t.isValid())return;const{mesh:s}=e;this.Fe(t);const{triangles:n,numTrianglesWithoutSkirts:r,terrainWidth:h}=s;t.localTransform=this.De(t.localTransform||[],i,h),t.positionMatrix=this.Re(t.positionMatrix||[]),t.properties.skirtOffset=3*r,t.properties.skirtCount=n.length-3*r,t.properties.z=i.z,t.properties.minHeight=s.minHeight,t.properties.maxHeight=s.maxHeight,t.properties.terrainWidth=h,t.castShadow=!1,dt$5(t.uniforms,"minAltitude")||Object.defineProperty(t.uniforms,"minAltitude",{enumerable:!0,get:()=>e.minAltitude||0})}addTerrainImage(t,i){const e=i.terrainMesh;e&&e.geometry&&i.skin&&(e.setUniform("skin",i.skin.color[0]),e.setUniform("polygonOpacity",1),this.Ae.addMesh(e))}endFrame(t){this.updateIBLDefines(this.shader);let i=0;const e=this.getUniformValues(),s=this.He(t);return this.shader.filter=t&&t.sceneFilter,i+=this.renderer.render(this.shader,e,this.Ae,s),i}delete(){this.shader&&(this.shader.dispose(),delete this.shader),this.Oe&&(this.Oe.destroy(),delete this.Oe),this.Le&&(this.Le.dispose(),delete this.Le)}deleteMesh(t){if(!t)return;const i=t.geometry;t.dispose(),i!==this.Le&&i.dispose()}initShader(){const t=[],i=[];this.shader=new vn$4({vert:"#define SHADER_NAME TERRAIN_MESH\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nuniform float minAltitude;\nuniform mat4 projViewModelMatrix;\nuniform mat4 projMatrix;\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform float heightScale;\nvarying vec2 vUv;\n#include <mask_vert>\nvoid main() {\n    vec3 position = vec3(aPosition.xy, (aPosition.z + minAltitude) * heightScale);\n    #ifdef HAS_MASK_EXTENT\n        gl_Position = projMatrix * getMaskPosition(positionMatrix * vec4(position, 1.0), modelMatrix);\n    #else\n        gl_Position = projViewModelMatrix * positionMatrix * vec4(position, 1.0);\n    #endif\n    vUv = aTexCoord;\n}",frag:"#define SHADER_NAME TERRAIN_MESH\nprecision mediump float;\nuniform sampler2D skin;\nuniform float polygonOpacity;\nvarying vec2 vUv;\n#include <mask_frag>\nvoid main() {\n    vec2 uv = vec2(vUv);\n    uv.y = 1.0 - uv.y;\n    vec4 color = texture2D(skin, uv);\n    gl_FragColor = color * polygonOpacity;\n    #ifdef HAS_MASK_EXTENT\n      gl_FragColor = setMask(gl_FragColor);\n    #endif\n}",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(t,e){return multiply$5(i,e.viewMatrix,e.modelMatrix)}},{name:"projViewModelMatrix",type:"function",fn:function(i,e){return multiply$5(t,e.projViewMatrix,e.modelMatrix)}}],extraCommandProps:this.getExtraCommandProps()})}getExtraCommandProps(){const t=this.layer.getRenderer().canvas;return{viewport:{x:0,y:0,width:()=>t?t.width:1,height:()=>t?t.height:1},stencil:{enable:!1},cull:{enable:!0,face:"back"},depth:{enable:!0,mask:()=>!!this.layer.options.depthMask,func:this.layer.options.depthFunc||"<="},blend:{enable:!0,func:{src:this.layer.options.blendSrc,dst:this.layer.options.blendDst},equation:"add"}}}He(t){return t&&t.renderTarget&&t.renderTarget.fbo}getUniformValues(){const t=this.getMap(),i=t.projViewMatrix,e=this.layer.getRenderer().getMaskUniforms(),s={viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:i,heightScale:1};return at$5(s,e),s}Pe(t){const i=this.layer.getMap();return i?i.altitudeToPoint(t,i.getGLRes()):null}getEmptyTexture(){return this.Oe}hasIBL(){const t=this.getMap().getLightManager();return!(!t||!t.getAmbientResource())}updateIBLDefines(t){const i=t.shaderDefines;let e=!1;this.hasIBL()?i[["HAS_IBL_LIGHTING"]]||(i.HAS_IBL_LIGHTING=1,e=!0):i[["HAS_IBL_LIGHTING"]]&&(delete i.HAS_IBL_LIGHTING,e=!0),e&&(t.shaderDefines=i)}Ee(){const t=qi$3,{positions:i,texcoords:e,triangles:s}=t;this.Le=new Q$7({aPosition:i,aTexCoord:e},s,0),this.Le.generateBuffers(this.regl)}}const{getIBLResOnCanvas:Ji$3,getPBRUniforms:Zi$3,loginIBLResOnCanvas:Ki$3,logoutIBLResOnCanvas:Qi$3}=fi$4.PBRUtils,te$4={baseColorFactor:[1,1,1,1],emissiveFactor:[0,0,0],baseColorIntensity:1,emitColorFactor:1,roughnessFactor:1,metallicFactor:0,emitMultiplicative:1,outputSRGB:1,hsv:[0,0,0],contrast:1,alphaTest:0};class ie$4 extends Xi$3{constructor(...t){super(...t),this.createIBLTextures(),this.Ne=0}updateMaterial(t,i){this.Ne=i,this.Ge=this.Ge||{},at$5(this.Ge,t),this.setToRedraw()}setMaterial(t,i){this.Ne=i,this.Ge=at$5({},te$4,t),this.setToRedraw()}createIBLTextures(){const t=this.getMap().getRenderer().canvas;Ki$3(t,this.regl,this.getMap()),this.layer.fire("iblupdated")}disposeIBLTextures(){const t=this.getMap().getRenderer().canvas;Qi$3(t,this.getMap())}createTerrainMesh(t,i){const{mesh:e,image:s}=i,{positions:n,texcoords:r,triangles:h,leftSkirtIndex:o,rightSkirtIndex:a,bottomSkirtIndex:l,numVerticesWithoutSkirts:c}=e,u=new Int8Array(n.length);for(let t=2;t<u.length;t+=3)t<3*c?u[t]=1:t<o/2*3?u[t-2]=-1:t<a/2*3?u[t-2]=1:u[t-1]=t<l/2*3?-1:1;const f=new Q$7({aPosition:n,aTexCoord:r,aNormal:u},h,0);let d;f.createTangent(),delete f.data.aNormal,f.generateBuffers(this.regl),d=s?this.regl.texture({width:s.width,height:s.height,data:s,min:"linear",mag:"linear"}):this.getEmptyTexture();const p=this.getEmptyTexture(),m=at$5({},te$4,this.layer.options.material||{});m.skinTexture=p,m.terrainHeightTexture=d;const v=new fi$4.StandardMaterial(m),w=new Be$5(f,v);w.properties.matVer=this.Ne;const x=w.defines;return x.HAS_UV_FLIP=1,x.HAS_TERRAIN_NORMAL=1,x.HAS_MAP=1,w.defines=x,w.setUniform("terrainTileResolution",t.res),this.prepareMesh(w,t,i),w}addTerrainImage(t,i){const e=i.terrainMesh;if(e){if(this.Ge&&e.properties.matVer!==this.Ne){for(const t in this.Ge)e.material.set(t,this.Ge[t]);e.properties.matVer=this.Ne}i.skin&&e.material.set("skinTexture",i.skin),e.setUniform("polygonOpacity",1),this.Ae.addMesh(e)}}getUniformValues(){const t=this.getMap(),i=t.getRenderer().canvas,{iblTexes:e,dfgLUT:s}=Ji$3(i),n=Zi$3(t,e,s),r=this.layer.getTileSize().width,h=this.layer.getRenderer().getMaskUniforms(),o=this.Pe(100)/100;return at$5(n,{viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[i.width,i.height],polygonFill:[1,1,1,1],terrainHeightMapResolution:[r,r],terrainResolution:[i.width,i.height],terrainHeightScale:o,terrainUnpackFactors:[6553.6,25.6,.1,1e4]}),at$5(n,h),n}initShader(){this.shader=new fi$4.StandardShader({extraCommandProps:this.getExtraCommandProps()})}delete(){return this.disposeIBLTextures(),super.delete()}}function ee$4(t,i,e,s){const n=se$4.call(this,e,s);this._projViewMatrix=i;const{colorExtent:r,modeExtent:h}=this._extentPass.render(n,i);this._maskUniforms=this._maskUniforms||{},this._maskUniforms.mask_colorExtent=r,this._maskUniforms.mask_extent=t,this._maskUniforms.mask_modeExtent=h,this._maskUniforms.mask_hasFlatOut=re$4.call(this,"flat-outside"),this._maskUniforms.mask_hasClipOut=re$4.call(this,"clip-outside"),this._maskUniforms.mask_hasVideo=re$4.call(this,"video"),this._maskUniforms.mask_heightRatio=e,this._maskUniforms.mask_heightOffset=s,this.setToRedraw()}function se$4(t,i){const e=[],s=this.layer.getMasks();for(let n=0;n<s.length;n++){const r=s[n].getMesh(this.regl,t,i);r&&e.push(r)}return e}function ne$4(){if(!this._extentPass||!this._maskUniforms)return;const e=se$4.call(this,this._maskUniforms.mask_heightRatio,this._maskUniforms.mask_heightOffset);this._extentPass.render(e,this._projViewMatrix);const s=this.layer.getMasks();for(let t=0;t<s.length;t++)"video"===s[t].getMode()&&s[t].je()}function re$4(t){const i=this.layer.getMasks();for(let e=0;e<i.length;e++)if(i[e].getMode()===t)return 1;return 0}function he$4(){const t=this.layer.getMasks();if(!t)return!1;for(let i=0;i<t.length;i++)if("video"===t[i].getMode()&&t[i].Be())return!0;return!1}function oe$4(t){return class extends t{setMask(t,i,e,s){this.viewport||(this.viewport={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1}),this._extentPass?ee$4.call(this,t,i,e,s):this.regl?(this._extentPass=new mt$6(this.regl,this.viewport),ee$4.call(this,t,i,e,s)):this.layer.once("contextcreate",(()=>{this._extentPass=new mt$6(this.regl,this.viewport),ee$4.call(this,t,i,e,s)}),this)}needToRedraw(){return!!super.needToRedraw()||!!he$4.call(this)}getMaskUniforms(){return he$4.call(this)&&ne$4.call(this),this.layer.updateExtent(),this._maskUniforms}getMaskDefines(){return this._maskDefines||(this._maskDefines={}),this._maskUniforms&&this._maskUniforms.mask_colorExtent?this._maskDefines.HAS_MASK_EXTENT=1:delete this._maskDefines.HAS_MASK_EXTENT,this._maskDefines}updateMaskDefines(t){const i=t.getDefines();delete i.HAS_MASK_EXTENT,at$5(i,this.getMaskDefines()),t.setDefines(i)}_clearMask(){this._deleteMaskUniforms(),this._extentPass&&(this._extentPass.dispose(),delete this._extentPass),this.setToRedraw()}_deleteMaskUniforms(){delete this._maskUniforms}}}class ae$4{constructor(t,i){this.max=t,this.onRemove=i,this.reset()}reset(){if(this.data){const t=this.data.values();for(const i of t)this.onRemove(i)}return this.data=new Map,this}clear(){this.reset(),delete this.onRemove}add(t,i){return i?(this.has(t)?(this.data.delete(t),this.data.set(t,i)):this.data.set(t,i),this):this}keys(){const t=new Array(this.data.size);let i=0;const e=this.data.keys();for(const s of e)t[i++]=s;return t}has(t){return this.data.has(t)}getAndRemove(t){if(!this.has(t))return null;const i=this.data.get(t);return this.data.delete(t),i}get(t){return this.has(t)?this.data.get(t):null}pop(){if(this.data.size<this.max)return null;const t=this.data.keys().next();return this.data.get(t.value).current?(this.max+=Math.ceil(this.max/2),null):this.getAndRemove(t.value)}remove(t){if(!this.has(t))return this;const i=this.data.get(t);return this.data.delete(t),this.onRemove(i),this}resetCurrent(t){this.data&&this.data.forEach((i=>{i.current=t}))}}const le$4=new t__namespace.Point(0,0),ce$4=new t__namespace.Point(0,0),ue$4=new t__namespace.PointExtent(0,0,0,0),fe$4=new t__namespace.Point(0,0),de$4=new t__namespace.Point(20,20),pe$4={color:[0,0,0,0],depth:1,stencil:0};class ge$4 extends(oe$4(t__namespace.renderer.TileLayerCanvasRenderer)){isDrawable(){return!0}getTempTileOnLoading(t,i){if(i.image&&!i.image.reset)return i;const e=this.Ue(t);return e.temp=!0,i.image||(i.image=e),delete i.image.reset,i.current=!0,i.info=t,at$5(i.image,e),this.ze(i.image,t),i}Ve(t,i,e){i.reset=!0,delete i.data,delete i.loadTime,delete i.rendered,delete i.minAltitude;const s=t.id+"-temp",n=i.skinImages;if(n)for(let t=0;t<n.length;t++){const i=n[t];if(i){for(let t=0;t<i.length;t++){const n=i[t];n&&(n.refs.delete(s),n.refs.size||e.push(n))}delete i.currentSkins,delete i.tileIds}}delete i.sourceZoom,delete i.skinImages,delete i.skinStatus,delete i.skinTileIds,i.debugTexture&&(i.debugTexture.destroy(),delete i.debugTexture)}Ue(t,i){for(i=i||this.findParentTile(t);i&&i.image&&-1===i.image.sourceZoom;)i=this.findParentTile(i.info);const e=(i&&i.info||t).res,s=this.getMap().pointAtResToDistance(1,1,e),n=i&&i.image&&i.image.data&&this.We(i,t),r=n&&-1!==i.image.sourceZoom?i.info.z:-1;if(!n||n.width<=1){const e=this.qe(t,i);return{data:Vi$3(e||0,5),minAltitude:e,mesh:qi$3,sourceZoom:r}}return{data:n,mesh:Hi$3(s,n.data,n.width,!0),sourceZoom:r}}qe(t,i){if(i&&i.minAltitude)return i.minAltitude;const{idx:e,idy:s,z:n}=t;for(let t=-1;t<=1;t++)for(let i=-1;i<=1;i++){if(0===t&&0===i)continue;const r=this.layer.getTileId(e+t,s+i,n),h=this.layer.tileInfoCache.get(r);if(h&&h.minAltitude)return h.minAltitude}return 0}consumeTile(t,i){if(t.empty&&!t.mesh){const e=this.findParentTile(i);if(!e||e.image&&e.image.empty){t.mesh=qi$3;const e=this.qe(i);t.data=Vi$3(e||0,5),t.minAltitude=e,t.sourceZoom=-1}else t=this.Ue(i,e)}this.ze(t,i),super.consumeTile(t,i),this.$e(i)}ze(t,i){if(t&&t.mesh){t.terrainMesh=this.Ye.createTerrainMesh(i,t),i.minAltitude=t.data.min,i.maxAltitude=t.data.max,delete t.mesh;const e=this.layer.tileInfoCache;if(e&&i.parent&&!t.empty&&!t.temp){const t=e.get(i.parent);if(t){const{minAltitude:e,maxAltitude:s}=i;(void 0===t.minAltitude||t.minAltitude>e)&&(t.minAltitude=e),(void 0===t.maxAltitude||t.maxAltitude<s)&&(t.maxAltitude=s)}}}}$e(t){const i=this.getMap();if(i.updateCenterAltitude&&void 0===i.centerAltitude&&t.z===this.getCurrentTileZoom()){const e=i._getPrjCenter(),s=i._prjToPointAtRes(e,t.res,fe$4);t.extent2d.contains(s)&&i.updateCenterAltitude()}}draw(t,i){this.Xe(),this.Ye.startFrame(),super.draw(t,i),this.Je(i)}drawTile(t,i){const e=this.getMap();if(!t||!e||!i)return;if(!this.drawingCurrentTiles&&!this.drawingChildTiles)return;let s=this.drawingCurrentTiles?this.getTileOpacity(i):1;s*=this.layer.options.opacity||1,this.Ye.addTerrainImage(t,i,s)}_drawTiles(t,i,e,s,n,r,h){const o=[],a=this.Ze(r,o);this.Ke=0;const l=this.layer.getSkinCount();pt$5(t,a);const c=new Set;for(let t=0;t<l;t++)this.Qe(t,h,c,o);for(let i=0;i<l;i++)this.Qe(i,t,c,o);for(let i=0;i<t.length;i++)this.ts(t[i].info,t[i].image);for(let t=0;t<o.length;t++)o[t]&&o[t].texture&&!o[t].refs.size&&(this.es.delete(o[t].tile.id),this.ss(o[t]));return this.ns(),super._drawTiles(...arguments)}Ze(t,i){const e=[];let s=this.rs;s||(s=this.rs=new ae$4(this.layer.options.tempTileCacheSize,(t=>{const{info:i,image:e}=t;this.hs(i,e)}))),s.resetCurrent(!1);for(let n=0;n<t.length;n++){const r=t[n];let h;s.has(r.id)?h=s.getAndRemove(r.id):(h=s.pop(),h?h.image&&(this.Ve(h.info,h.image,i),h.image.temp=!0):h={info:r}),h.current=!0,s.add(r.id,h),e.push(h)}for(let i=0;i<t.length;i++)this.getTempTileOnLoading(t[i],e[i]);return e}ns(){if(!this.es)return;const t=this.getCurrentTimestamp();if(this.os&&t-this.os<1e3)return;const i=new Set;for(const t of this.tileCache.data.values())this.as(t,i);for(const t in this.tilesInView){this.as(this.tilesInView[t],i)}if(this.rs)for(const t of this.rs.data.values())this.as(t,i);i.size&&(this.es.forEach(((t,e)=>{i.has(e)||(console.log("deleted:",e),this.ss(this.es.get(e)),this.es.delete(e))})),this.os=t)}as(t,i){const e=t.image&&t.image.skinImages;if(e&&e.length)for(let t=0;t<e.length;t++){const s=e[t]&&e.currentSkins;if(s)for(const t of s)i.add(t)}}Qe(t,i,e,s){const n=this.layer.getSkinLayer(t).getRenderer();if(!n)return;const r=[];for(let n=0;n<i.length;n++){const{info:h,image:o}=i[n];if(this.ls(t,h,o,s)){const s=i[n].image.skinImages[t];for(let t=0;t<s.length;t++){const i=s[t].tile.info.id;e.has(i)||(r.push(s[t]),e.add(i))}}}n.renderTerrainSkin(this.regl,this.layer,r)}ls(t,i,e,s){const n=this.getMap();if(delete e.path,!i||!n||!e)return!1;if(!e.terrainMesh)return!1;const r=this.layer.getSkinLayer(t),h=r.getRenderer();if(!h)return!1;e.skinImages||(e.skinImages=[]),e.skinStatus||(e.skinStatus=[]),e.skinTileIds||(e.skinTileIds=[]);const o=h.isAnimating&&h.isAnimating(),a=e.skinStatus[t],l=h.needToRefreshTerrainTileOnZooming&&h.needToRefreshTerrainTileOnZooming(),c=o||l&&e.renderedZoom!==n.getZoom();if(a&&!c)return!1;const u=r.getSpatialReference(),{x:f,y:d,z:p,res:g,offset:m}=i;let v=i.nw;v||(v=i.nw=this.getMap().pointAtResToCoord(i.extent2d.getMin(le$4),i.res));const w=this.layer.getTileSize().width,{res:x,zoom:M}=Ui$3(u,p,g),_=Bi$3(x,r.getTileSize().width,g,w);let y=e.skinTileIds[t];if(!y){const i=this.layer._getTileConfig().tileSystem.scale.y;y=e.skinTileIds[t]=Ni$3(r,f,d,M,v,m,i,_,me$4)}const b=y[0];let S=!0;const C=[];for(let t=0;t<b.length;t++){const i=h.getCachedTile(b[t],!1);if(i)C.push(i);else{S=!1;const i=h.findParentTile(b[t]);i&&C.push(i)}}const T=e.skinImages[t]||[];T.currentSkins=T.currentSkins||new Set;const k=new Set;let A=!1;for(let t=0;t<T.length;t++){if(!T[t].tile){A=!0;continue}k.add(T[t].tile.info.id)}if(!C.length)return T.currentSkins.clear(),e.skinImages[t]=[],!1;const O=C.length?C.map((t=>t.info.id)).join():C[0].info.id;if(!c&&!A&&T.tileIds===O)return!1;T.tileIds=O;let I=!1;T.currentSkins.clear(),T.length=0;const E=T.currentSkins;let L=i.id;e.temp&&(L+="-temp");for(let t=0;t<C.length;t++){const i=C[t].info.id;E.add(i);let e=this.cs(i);e&&(F=e)&&F.texture||(e={tile:at$5({},C[t]),layer:r,refs:new Set,texture:h.createTerrainTexture(this.regl)},this.us(i,e)),e.refs.add(L),T.push(e),I=!0}var F;return this.fs(i,e,k,E,s),I&&this.Ke++,e.skinImages[t]=T,r.fire("renderterrainskin",{tile:i,skinTiles:C}),S&&(e.skinStatus[t]=1),!0}fs(t,i,e,s,n){if(!e.size)return;let r=t.id;i.temp&&(r+="-temp");for(const t of e)if(!s||!s.has(t)){const i=this.cs(t);this.ds(i,r,n)}}cs(t){return this.es||(this.es=new Map),this.es.get(t)}us(t,i){this.es.set(t,i)}ts(t,i){const e=this.getMap();if(!t||!e||!i)return;const s=i.skinImages,n=this.ps(i.renderedZoom);if(i.rendered&&!n)return;i.skin?(pe$4.framebuffer=i.skin,this.regl.clear(pe$4)):i.skin=this.gs(),this.ms();const r=this.layer.options.debug,h=[],o=r&&[],a=this.layer.getTileSize().width;if(s)for(let i=0;i<s.length;i++){const e=s[i];for(let i=0;i<e.length;i++){const{tile:s,texture:n,layer:r}=e[i];if((s.info.offset[0]||s.info.offset[1])&&t.skinTileIds){const i=t.skinTileIds[r.getId()];for(let t=0;t<i.length;t++)if(s.info.x===i[t].x&&s.info.y===i[t].y){s.info.offset=i[t].offset;break}}const o=we$4(t,s,a),l=e[i].skinMesh||new Be$5(this.vs);l.setUniform("skinTexture",n);const c=r.getOpacity();l.setUniform("opacity",lt$5(c)?1:c),l.setUniform("skinDim",o),l.setUniform("tileSize",a),l.setUniform("x",t.x),l.setUniform("y",t.y),e[i].skinMesh=l,h.push(l)}}if(r){const e=i.skinDebugMesh||new Be$5(this.vs);e.setUniform("tileSize",a);const s=i.debugTexture||this.ws(t,a);i.debugTexture=s,i.skinDebugMesh=e,e.setUniform("opacity",1),e.setUniform("skinTexture",s),e.setUniform("skinDim",[0,0,1]),e.setUniform("tileSize",a),o.push(e)}if(h.length){this.xs.setMeshes(h);try{this.renderer.render(this.Ms,null,this.xs,i.skin)}catch(t){throw console.error(i),t}}o&&o.length&&this.layer.options.debug&&(this.xs.setMeshes(o),this.renderer.render(this.Ms,null,this.xs,i.skin)),i.rendered=this._s(i),i.renderedZoom=e.getZoom()}ws(t,i){i*=2;const{x:e,y:s,z:n}=t,r=`terrain:${e}/${s}/${n}`,h=document.createElement("canvas");h.width=i,h.height=i;const o=h.getContext("2d");o.font="40px monospace";const a=this.layer.options.debugOutline;return o.fillStyle=a,o.strokeStyle=a,o.fillText(r,20,i-40),o.beginPath(),o.lineWidth=4,o.moveTo(0,0),o.lineTo(i,0),o.lineTo(i,i),o.lineTo(0,i),o.lineTo(0,0),o.stroke(),this.regl.texture({data:h,flipY:!0,mag:"linear",min:"linear"})}gs(){const t=this.layer.getTileSize().width,i=2*t,e=2*t,s=this.regl,n=s.texture({min:"linear",mag:"linear",type:"uint8",width:i,height:e,flipY:!0}),h=s.framebuffer({width:i,height:e,colors:[n],colorFormat:"rgba",ignoreStatusCheck:!0,depthStencil:!1,depth:!1,stencil:!1});return h.colorTex=n,h}Je(t){this.Ye.endFrame(t)&&!Object.keys(this.tilesLoading).length&&this.layer.fire("terrainreadyandrender")}We(t,i){const{image:e,info:s}=t,n=e.data,r=n.width,{extent2d:h,res:o}=s,{extent2d:a,res:l}=i,c=h.getWidth(),u=h.getHeight();let f=(a.xmin*l/o-h.xmin)/c*(r-1),d=(h.ymax-a.ymax*l/o)/u*(r-1);let g=Math.round((a.xmax*l/o-h.xmin)/c*(r-1)-f);const m=Math.log2(g);g=Math.pow(2,Math.round(m))+1,f=Math.floor(f),d=Math.floor(d);const v=new Float32Array(g*g);let w=1/0,x=-1/0;for(let t=0;t<g;t++)for(let i=0;i<g;i++){let e=t+f,s=i+d;e>r-1?e=r-1:e<0&&(e=0),s>r-1?s=r-1:s<0&&(s=0);const h=n.data[e+s*r];v[t+i*g]=h,h<w&&(w=h),h>x&&(x=h)}return{width:g,height:g,data:v,min:w,max:x}}getTileOpacity(t){return this._s(t)?super.getTileOpacity(t):(this.resetTileLoadTime(t),0)}_s(t){const i=this.layer.getSkinCount();if(!i)return!0;if(!t.skinStatus)return!1;for(let e=0;e<i;e++)if(!t.skinStatus[e])return!1;return!0}ps(t){const i=this.getMap().getZoom(),e=this.layer.getSkinLayers();for(let s=0;s<e.length;s++){const n=e[s]&&e[s].getRenderer();if(n){if(n.isAnimating&&n.isAnimating())return!0;if(n.needToRefreshTerrainTileOnZooming&&n.needToRefreshTerrainTileOnZooming()&&t!==i)return!0}}return!1}isValidCachedTile(t){return t.image&&!t.image.temp&&(!t.image.skinStatus||this._s(t.image))}isTileComplete(t){return t.image&&!t.image.temp&&this._s(t.image)}ys(){const t=this.layer.options;return lt$5(t.terrainWidth)?t.tileSize+1:t.terrainWidth}bs(t,i){const e=this.layer.options.maxAvailableZoom-this.layer.options.zoomOffset,n=Math.pow(2,t.z-e),r=Math.floor(t.x/n),h=Math.floor(t.y/n),o=Math.floor(t.idx/n),a=Math.floor(t.idy/n),l=xe$4(r,h);this.Ss||(this.Ss={});const c=!this.Ss[l];return c&&i&&(this.Ss[l]=new Set,this.Ss[l].url=this.layer.getTileUrl(r,h,e+this.layer.options.zoomOffset)),{x:r,y:h,idx:o,idy:a,requests:this.Ss[l],isFirst:c,key:l}}loadTile(i){const e=this.layer,s=this.ys(),n=e.getSpatialReference().getResolution(i.z);let r=this.getMap().pointAtResToDistance(1,1,n);const o=e.options.maxAvailableZoom&&e.options.maxAvailableZoom-(e.options.zoomOffset||0);if(o&&i.z>o){const t=this.Ue(i);if(-1!==t.sourceZoom)return this.onTileLoad(t,i),t;{const{requests:s,isFirst:n,x:h,y:a,idx:l,idy:c}=this.bs(i,!0);if(s.add(i),!n)return t;const u=i.z-o;r*=Math.pow(2,u);const f=[h,a,o,l,c,i.res*Math.pow(2,u),i.error*Math.pow(2,u)];i=e.createTileNode?e.createTileNode(...f):e.Cs(...f)}}const l={},c=e.options;return this.workerConn.fetchTerrain(i.url,{terrainWidth:s,type:c.type,accessToken:c.accessToken,cesiumIonTokenURL:c.cesiumIonTokenURL,error:r},((e,s)=>{if(this.Ss){const t=xe$4(i.x,i.y),e=this.Ss[t];if(e&&e.size){this.tileCache.add(i.id,{info:i,image:l});for(const t of e)this.removeTileLoading(t)}delete this.Ss[t]}if(e){if(e.canceled)return;return console.warn(e),void this.onTileError(l,i)}t__namespace.Util.extend(l,s),this.onTileLoad(l,i)})),l}deleteTile(t){if(!t||!t.image)return;super.deleteTile(t);const{info:i,image:e}=t;e.temp||(delete i.skinTileIds,this.hs(t.info,e))}hs(t,i){const e=i.skin;e&&(e.destroy(),e.colorTex.destroy(),delete e.colorTex),i.debugTexture&&(i.debugTexture.destroy(),delete i.debugTexture,i.skinDebugMesh.dispose(),delete i.skinDebugMesh);const s=i.skinImages;if(s&&s.length){let e=t.id;i.temp&&(e+="-temp");for(let t=0;t<s.length;t++){const i=s[t];if(i){for(let t=0;t<i.length;t++){if(!i[t]||!i[t].tile)continue;const s=i[t].tile.info.id,n=this.es&&this.es.get(s);n&&this.ds(n,e)}i.length=0}}}i.terrainMesh&&this.Ye.deleteMesh(i.terrainMesh),i.image&&i.image.close&&i.image.close(),delete i.skinImages,delete i.skin,delete i.skinStatus,delete i.skinTileIds,delete i.terrainMesh,delete i.image,delete i.data,delete i.mesh,delete i.rendered}ds(t,i,e){t&&(t.refs.delete(i),t.refs.size||(e?e.push(t):this.ss(t)))}ss(t){if(!t||!t.tile)return;const i=t.tile.info.id,e=t.layer.getRenderer();delete t.canvas,delete t.layer,t.refs.clear(),t.texture&&(e?e.deleteTerrainTexture(t.texture):t.texture.destroy&&t.texture.destroy(),delete t.texture),t.skinMesh&&(t.skinMesh.dispose(),delete t.skinMesh),e&&(e.removeTileCache&&e.removeTileCache(i),e.deleteTile&&e.constructor.prototype.deleteTile.call(e,t.tile)),delete t.tile,this.es.delete(i)}Ts(){if(!this.es)return;const t=this.es.keys();for(const i of t){const t=this.cs(i);this.ss(t)}this.es.clear()}abortTileLoading(t,i){const e=this.layer,s=e.options.maxAvailableZoom&&e.options.maxAvailableZoom-e.options.zoomOffset;if(i)if(s&&i.z>s){const{requests:t,key:e}=this.bs(i);t&&t.size&&(t.delete(i),t.size||(delete this.Ss[e],this.workerConn&&this.workerConn.abortTerrain(t.url)))}else i&&i.url&&this.workerConn&&this.workerConn.abortTerrain(i.url);super.abortTileLoading(t,i)}onTileError(t,i){super.onTileError(t,i)}ks(t){const i=this.getCurrentTileZoom(),e=this.layer.getSpatialReference().getResolution(i),s=this.layer._getTileConfig().getTileIndex(t,e,this.layer.options.repeatWorld);return s.z=i,s}As(t,i,e,s,n){const r=this.layer.getMinZoom(),h=this.Os(i,e.x,e.y,e.z,r);if(h&&h.image&&h.image.data){const i=h.info.extent2d,r=h.info.res/n,a=i.ymax*r-s.y,l=this.Is(h.image.data,(s.x-i.xmin*r)/(i.getWidth()*r),a/(i.getHeight()*r));t[0]=l,t[1]=null===l?0:+(h.info.z===e.z)}else t[0]=null,t[1]=0;return t}Os(t,i,e,s,n){t||(t=this.layer._getTileId(i,e,s));const r=this.tilesInView[t]||this.tileCache.get(t);return!r&&s-1>=n?this.Os(null,Math.floor(i/2),Math.floor(e/2),s-1,n):r}Is(t,i,e){const{width:s,height:n,data:r}=t,h=Math.floor((s-1)*i),o=Math.floor((n-1)*e)*s+h;return void 0===r[o]?null:r[o]}Es(t,i,e){t||(t={tiles:{},dirty:!0,complete:!1});const s=this.layer,n=this.getCurrentTileZoom(),r=s.getSpatialReference().getResolution(n),{xmin:h,ymin:o,xmax:a,ymax:l}=i,c=s._getTileConfig();le$4.set(h,o).Ls(e);const u=c._getTileNum(le$4,e,!0);ce$4.set(a,l).Ls(e);const f=c._getTileNum(ce$4,e,!0),d=Math.min(u.x,f.x),p=Math.max(u.x,f.x),g=Math.min(u.y,f.y),m=Math.max(u.y,f.y),v=e/r;le$4.set(h,o).Ls(v),ce$4.set(a,l).Ls(v);const w=ue$4.set(le$4.x,le$4.y,ce$4.x,ce$4.y),x=s.getTileSize().width+1;w.Fs(w.getWidth()/x),t.array=t.array||new Float32Array(x*x);const M=t.tiles;t.complete=!0,t.array.fill(0);for(let i=d;i<=p;i++)for(let e=g;e<=m;e++){const s=this.layer._getTileId(i,e,n);if(M[s])continue;const r=this.tileCache.get(s);r?(this.Rs(t.array,r,w,x),t.dirty=!0,M[s]=1):(t.dirty=t.dirty||void 0!==t.tiles[s],t.tiles[s]&&delete t.tiles[s],t.complete=!1)}return t}Rs(t,i,e,s){const n=i.info.extent2d,r=n.intersection(e),{xmin:h,ymin:o,xmax:a,ymax:l}=r,{data:c}=i.image,u=c.width,f=e.getWidth()/s,d=Math.floor((h-e.xmin)/f),p=Math.floor((o-e.ymin)/f),g=Math.floor((a-e.xmin)/f)-d,m=Math.floor((l-e.ymin)/f)-p,v=n.getWidth()/u,w=Math.floor((h-n.xmin)/v),x=Math.floor((o-n.ymin)/v),M=Math.floor(f/v);for(let i=0;i<=g;i++)for(let e=0;e<=m;e++){const n=i+d+(p+e)*s;let r=0;for(let t=0;t<M;t++)for(let s=0;s<M;s++){const n=(w+Math.floor(i*M))*u+t+x+Math.floor(e*M)+s;r+=c.data[n]}t[n]=r/Math.max(M,1)}return t}clear(){return this.clearTempResources(),super.clear()}clearTempResources(){this.rs&&(this.rs.reset(),delete this.rs),this.es&&this.Ts()}onAdd(){super.onAdd(),this.prepareWorker()}onRemove(){this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),this.clearTempResources(),this.Ms&&(this.Ms.dispose(),delete this.Ms),this.vs&&(this.vs.dispose(),delete this.vs),delete this.Ss,super.onRemove(),this.Ye&&(this.Ye.delete(),delete this.Ye)}prepareWorker(){const t=this.layer.getMap();this.workerConn||(this.workerConn=new Fi$3(t.id));const i=this.workerConn;if(!i.isActive())return;const e=this.layer.options||{},s=this.layer.getId();i.addLayer(s,e,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.setToRedraw(),this.layer.fire("workerready"))}))}createContext(){this.canvas.gl&&this.canvas.gl.wrap?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):this.Ps(),this.renderer=new B$6(this.regl),this.layer.fire("contextcreate",{regl:this.regl})}Xe(){const t=this.Ye;"lit"===this.layer.options.shader||"pbr"===this.layer.options.shader?(t&&t.constructor===Xi$3||!t)&&(t&&(t.delete(),this.clear(),this.setToRedraw()),this.Ye=new ie$4(this.layer),this.layer.fire("paintercreated")):(t&&t.constructor===ie$4||!t)&&(t&&(t.delete(),this.clear(),this.setToRedraw()),this.Ye=new Xi$3(this.layer),this.layer.fire("paintercreated"))}Ps(){const t=this.layer,i=t.options.glOptions||{alpha:!0,depth:!0,antialias:this.layer.options.antialias};i.preserveDrawingBuffer=!0,i.stencil=!0,this.glOptions=i,this.gl=this.gl||this.Ds(this.canvas,i),this.regl=regl_min.exports.createREGL({gl:this.gl,attributes:i,extensions:["OES_element_index_uint"],optionalExtensions:t.options.glExtensions})}Ds(t,i){const e=["webgl","experimental-webgl"];let s=null;for(let n=0;n<e.length;++n){try{s=t.getContext(e[n],i)}catch(t){}if(s)break}return s}resizeCanvas(t){this.canvas&&super.resizeCanvas(t)}clearCanvas(){this.canvas&&super.clearCanvas()}ms(){if(this.Ms)return;const t=this.layer.getTileSize().width;this.Ms=new vn$4({vert:"#define SHADER_NAME TERRAIN_SKIN\nattribute vec2 aPosition;\nvoid main() {\n    gl_Position = vec4(aPosition, 0.0, 1.0);\n}",frag:"#define SHADER_NAME TERRAIN_SKIN\nprecision mediump float;\nuniform float tileSize;\nuniform sampler2D skinTexture;\nuniform vec3 skinDim;\nuniform float opacity;\nvoid main() {\n    vec2 fragCoord = gl_FragCoord.xy / 2.0;\n    vec2 resolution = vec2(tileSize);\n    vec2 uv = (fragCoord - skinDim.xy) /  (resolution * skinDim.z);\n    if (uv.x >= 0.0 && uv.x <= 1.0 && uv.y >= 0.0 && uv.y <= 1.0) {\n        gl_FragColor = texture2D(skinTexture, uv) * opacity;\n    } else {\n        gl_FragColor = vec4(0.0);\n    }\n}",extraCommandProps:{cull:{enable:!1},viewport:{x:0,y:0,width:2*t,height:2*t},depth:{enable:!1},stencil:{enable:!1},blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"}}});const i=new Int8Array([-1,-1,1,1,-1,1,1,1,-1,-1,1,-1]);this.vs=this.vs||new Q$7({aPosition:i},0,6,{positionSize:2}),this.vs.generateBuffers(this.regl),this.xs=this.xs||new Ke$5}updateMaterial(t){this.Ye&&t&&this.Ye.updateMaterial&&(void 0===this.Ne&&(this.Ne=1),this.Ye.updateMaterial(t,this.Ne++))}setMaterial(t){this.Ye&&t&&this.Ye.setMaterial&&(void 0===this.Ne&&(this.Ne=1),this.Ye.setMaterial(t,this.Ne++))}getAnalysisMeshes(){return this.Ye&&this.Ye.Ae?this.Ye.Ae.getMeshes():[]}}const me$4=1;function ve$4(t,i,e,s,n,r,h,o,a=0){t.font="20px monospace",t.fillStyle=e,de$4.y=o-30,t.globalAlpha=1,t.fillText(i,de$4.x+n,de$4.y+r+a),t.globalAlpha=.6,t.strokeStyle=e,t.lineWidth=s,t.beginPath(),t.moveTo(n,r),t.lineTo(n+h,r),t.lineTo(n+h,r+o),t.lineTo(n,r+o),t.lineTo(n,r),t.stroke(),t.globalAlpha=1}function we$4(t,i,e){const{res:s,extent2d:n,offset:r}=t,{info:h}=i,o=h.res/s,a=h.offset;return[h.extent2d.xmin*o-n.xmin+(r[0]-a[0]),-(n.ymin-h.extent2d.ymin*o+(a[1]-r[1])),o*h.tileSize/e]}function xe$4(t,i){return t+"-"+i}t__namespace.renderer.TileLayerCanvasRenderer.include({renderTerrainSkin(t,i,e){const s=this.layer.getTileSize().width,n=i.options.debug;for(let t=0;t<e.length;t++){const{tile:i,texture:r}=e[t];if(!i.image)continue;const h=document.createElement("canvas");e[t].canvas=h,h.width=s,h.height=s;const o=h.getContext("2d");if(o.drawImage(i.image,0,0),n){const{x:t,y:e,z:n}=i.info;ve$4(o,`${t}/${e}/${n}`,"yellow",1,0,0,s,s,-18)}r({data:h,width:s,height:s,flipY:!0,min:"linear mipmap linear",mag:"linear"})}},createTerrainTexture(t){const i=this.layer.getTileSize().width;return t.texture({width:i,height:i,flipY:!0,min:"linear mipmap linear",mag:"linear",depthStencil:!1,depth:!1,stencil:!1})},deleteTerrainTexture(t){t.destroy()}});var Me$4={exports:{}};function _e$4(t,i,e){e=e||2;var s,n,r,h,o,a,l,c=i&&i.length,u=c?i[0]*e:t.length,f=ye$4(t,0,u,e,!0),d=[];if(!f||f.next===f.prev)return d;if(c&&(f=function(t,i,e,s){var n,r,a,l=[];for(n=0,r=i.length;n<r;n++)(a=ye$4(t,i[n]*s,n<r-1?i[n+1]*s:t.length,s,!1))===a.next&&(a.steiner=!0),l.push(Fe$4(a));for(l.sort(Oe$4),n=0;n<l.length;n++)e=Ie$4(l[n],e);return e}(t,i,f,e)),t.length>80*e){s=r=t[0],n=h=t[1];for(var p=e;p<u;p+=e)(o=t[p])<s&&(s=o),(a=t[p+1])<n&&(n=a),o>r&&(r=o),a>h&&(h=a);l=0!==(l=Math.max(r-s,h-n))?32767/l:0}return Se$4(f,d,e,s,n,l,0),d}function ye$4(t,i,e,s,n){var r,h;if(n===qe$4(t,i,e,s)>0)for(r=i;r<e;r+=s)h=ze$4(r,t[r],t[r+1],h);else for(r=e-s;r>=i;r-=s)h=ze$4(r,t[r],t[r+1],h);return h&&He$4(h,h.next)&&(Ve$4(h),h=h.next),h}function be$4(t,i){if(!t)return t;i||(i=t);var e,s=t;do{if(e=!1,s.steiner||!He$4(s,s.next)&&0!==De$4(s.prev,s,s.next))s=s.next;else{if(Ve$4(s),(s=i=s.prev)===s.next)break;e=!0}}while(e||s!==i);return i}function Se$4(t,i,e,s,n,r,h){if(t){!h&&r&&function(t,i,e,s){var n=t;do{0===n.z&&(n.z=Le$4(n.x,n.y,i,e,s)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,function(t){var i,e,s,n,r,h,o,a,l=1;do{for(e=t,t=null,r=null,h=0;e;){for(h++,s=e,o=0,i=0;i<l&&(o++,s=s.nextZ);i++);for(a=l;o>0||a>0&&s;)0!==o&&(0===a||!s||e.z<=s.z)?(n=e,e=e.nextZ,o--):(n=s,s=s.nextZ,a--),r?r.nextZ=n:t=n,n.prevZ=r,r=n;e=s}r.nextZ=null,l*=2}while(h>1)}(n)}(t,s,n,r);for(var o,a,l=t;t.prev!==t.next;)if(o=t.prev,a=t.next,r?Te$4(t,s,n,r):Ce$4(t))i.push(o.i/e|0),i.push(t.i/e|0),i.push(a.i/e|0),Ve$4(t),t=a.next,l=a.next;else if((t=a)===l){h?1===h?Se$4(t=ke$4(be$4(t),i,e),i,e,s,n,r,2):2===h&&Ae$4(t,i,e,s,n,r):Se$4(be$4(t),i,e,s,n,r,1);break}}}function Ce$4(t){var i=t.prev,e=t,s=t.next;if(De$4(i,e,s)>=0)return!1;for(var n=i.x,r=e.x,h=s.x,o=i.y,a=e.y,l=s.y,c=n<r?n<h?n:h:r<h?r:h,u=o<a?o<l?o:l:a<l?a:l,f=n>r?n>h?n:h:r>h?r:h,d=o>a?o>l?o:l:a>l?a:l,p=s.next;p!==i;){if(p.x>=c&&p.x<=f&&p.y>=u&&p.y<=d&&Re$4(n,o,r,a,h,l,p.x,p.y)&&De$4(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Te$4(t,i,e,s){var n=t.prev,r=t,h=t.next;if(De$4(n,r,h)>=0)return!1;for(var o=n.x,a=r.x,l=h.x,c=n.y,u=r.y,f=h.y,d=o<a?o<l?o:l:a<l?a:l,p=c<u?c<f?c:f:u<f?u:f,g=o>a?o>l?o:l:a>l?a:l,m=c>u?c>f?c:f:u>f?u:f,v=Le$4(d,p,i,e,s),w=Le$4(g,m,i,e,s),x=t.prevZ,M=t.nextZ;x&&x.z>=v&&M&&M.z<=w;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==n&&x!==h&&Re$4(o,c,a,u,l,f,x.x,x.y)&&De$4(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,M.x>=d&&M.x<=g&&M.y>=p&&M.y<=m&&M!==n&&M!==h&&Re$4(o,c,a,u,l,f,M.x,M.y)&&De$4(M.prev,M,M.next)>=0)return!1;M=M.nextZ}for(;x&&x.z>=v;){if(x.x>=d&&x.x<=g&&x.y>=p&&x.y<=m&&x!==n&&x!==h&&Re$4(o,c,a,u,l,f,x.x,x.y)&&De$4(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;M&&M.z<=w;){if(M.x>=d&&M.x<=g&&M.y>=p&&M.y<=m&&M!==n&&M!==h&&Re$4(o,c,a,u,l,f,M.x,M.y)&&De$4(M.prev,M,M.next)>=0)return!1;M=M.nextZ}return!0}function ke$4(t,i,e){var s=t;do{var n=s.prev,r=s.next.next;!He$4(n,r)&&Ne$4(n,s,s.next,r)&&Be$4(n,r)&&Be$4(r,n)&&(i.push(n.i/e|0),i.push(s.i/e|0),i.push(r.i/e|0),Ve$4(s),Ve$4(s.next),s=t=r),s=s.next}while(s!==t);return be$4(s)}function Ae$4(t,i,e,s,n,r){var h=t;do{for(var o=h.next.next;o!==h.prev;){if(h.i!==o.i&&Pe$4(h,o)){var a=Ue$4(h,o);return h=be$4(h,h.next),a=be$4(a,a.next),Se$4(h,i,e,s,n,r,0),void Se$4(a,i,e,s,n,r,0)}o=o.next}h=h.next}while(h!==t)}function Oe$4(t,i){return t.x-i.x}function Ie$4(t,i){var e=function(t,i){var e,s=i,n=t.x,r=t.y,h=-1/0;do{if(r<=s.y&&r>=s.next.y&&s.next.y!==s.y){var o=s.x+(r-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(o<=n&&o>h&&(h=o,e=s.x<s.next.x?s:s.next,o===n))return e}s=s.next}while(s!==i);if(!e)return null;var a,l=e,c=e.x,u=e.y,f=1/0;s=e;do{n>=s.x&&s.x>=c&&n!==s.x&&Re$4(r<u?n:h,r,c,u,r<u?h:n,r,s.x,s.y)&&(a=Math.abs(r-s.y)/(n-s.x),Be$4(s,t)&&(a<f||a===f&&(s.x>e.x||s.x===e.x&&Ee$4(e,s)))&&(e=s,f=a)),s=s.next}while(s!==l);return e}(t,i);if(!e)return i;var s=Ue$4(e,t);return be$4(s,s.next),be$4(e,e.next)}function Ee$4(t,i){return De$4(t.prev,t,i.prev)<0&&De$4(i.next,t,t.next)<0}function Le$4(t,i,e,s,n){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))|(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-s)*n|0)|i<<8))|i<<4))|i<<2))|i<<1))<<1}function Fe$4(t){var i=t,e=t;do{(i.x<e.x||i.x===e.x&&i.y<e.y)&&(e=i),i=i.next}while(i!==t);return e}function Re$4(t,i,e,s,n,r,h,o){return(n-h)*(i-o)>=(t-h)*(r-o)&&(t-h)*(s-o)>=(e-h)*(i-o)&&(e-h)*(r-o)>=(n-h)*(s-o)}function Pe$4(t,i){return t.next.i!==i.i&&t.prev.i!==i.i&&!function(t,i){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==i.i&&e.next.i!==i.i&&Ne$4(e,e.next,t,i))return!0;e=e.next}while(e!==t);return!1}(t,i)&&(Be$4(t,i)&&Be$4(i,t)&&function(t,i){var e=t,s=!1,n=(t.x+i.x)/2,r=(t.y+i.y)/2;do{e.y>r!=e.next.y>r&&e.next.y!==e.y&&n<(e.next.x-e.x)*(r-e.y)/(e.next.y-e.y)+e.x&&(s=!s),e=e.next}while(e!==t);return s}(t,i)&&(De$4(t.prev,t,i.prev)||De$4(t,i.prev,i))||He$4(t,i)&&De$4(t.prev,t,t.next)>0&&De$4(i.prev,i,i.next)>0)}function De$4(t,i,e){return(i.y-t.y)*(e.x-i.x)-(i.x-t.x)*(e.y-i.y)}function He$4(t,i){return t.x===i.x&&t.y===i.y}function Ne$4(t,i,e,s){var n=je$4(De$4(t,i,e)),r=je$4(De$4(t,i,s)),h=je$4(De$4(e,s,t)),o=je$4(De$4(e,s,i));return n!==r&&h!==o||!(0!==n||!Ge$4(t,e,i))||!(0!==r||!Ge$4(t,s,i))||!(0!==h||!Ge$4(e,t,s))||!(0!==o||!Ge$4(e,i,s))}function Ge$4(t,i,e){return i.x<=Math.max(t.x,e.x)&&i.x>=Math.min(t.x,e.x)&&i.y<=Math.max(t.y,e.y)&&i.y>=Math.min(t.y,e.y)}function je$4(t){return t>0?1:t<0?-1:0}function Be$4(t,i){return De$4(t.prev,t,t.next)<0?De$4(t,i,t.next)>=0&&De$4(t,t.prev,i)>=0:De$4(t,i,t.prev)<0||De$4(t,t.next,i)<0}function Ue$4(t,i){var e=new We$4(t.i,t.x,t.y),s=new We$4(i.i,i.x,i.y),n=t.next,r=i.prev;return t.next=i,i.prev=t,e.next=n,n.prev=e,s.next=e,e.prev=s,r.next=s,s.prev=r,s}function ze$4(t,i,e,s){var n=new We$4(t,i,e);return s?(n.next=s.next,n.prev=s,s.next.prev=n,s.next=n):(n.prev=n,n.next=n),n}function Ve$4(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function We$4(t,i,e){this.i=t,this.x=i,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qe$4(t,i,e,s){for(var n=0,r=i,h=e-s;r<e;r+=s)n+=(t[h]-t[r])*(t[r+1]+t[h+1]),h=r;return n}Me$4.exports=_e$4,Me$4.exports.default=_e$4,_e$4.deviation=function(t,i,e,s){var n=i&&i.length,h=Math.abs(qe$4(t,0,n?i[0]*e:t.length,e));if(n)for(var o=0,a=i.length;o<a;o++){h-=Math.abs(qe$4(t,i[o]*e,o<a-1?i[o+1]*e:t.length,e))}var u=0;for(o=0;o<s.length;o+=3){var f=s[o]*e,d=s[o+1]*e,p=s[o+2]*e;u+=Math.abs((t[f]-t[p])*(t[d+1]-t[f+1])-(t[f]-t[d])*(t[p+1]-t[f+1]))}return 0===h&&0===u?0:Math.abs((u-h)/h)},_e$4.flatten=function(t){for(var i=t[0][0].length,e={vertices:[],holes:[],dimensions:i},s=0,n=0;n<t.length;n++){for(var r=0;r<t[n].length;r++)for(var h=0;h<i;h++)e.vertices.push(t[n][r][h]);n>0&&e.holes.push(s+=t[n-1].length)}return e};var $e$4=Me$4.exports;const Ye$4={"clip-inside":.1,"clip-outside":.2,"flat-inside":.3,"flat-outside":.4,color:.5,video:.6,elevate:.7},Xe$4=[],Je$4=[1,1,1],Ze$4={polygonFill:[255,0,0],polygonOpacity:.8},Ke$4=new t$1.Coordinate(0,0),Qe$4=new t$1.Coordinate(0,0),ts$4=[],is$4=new t$1.Coordinate(0,0),es$4=new t$1.Point(0,0),ss$4=new t$1.Point(0,0),ns$4=new t$1.Point(0,0);class rs$4 extends t$1.Polygon{getMode(){return this.Hs}remove(){const t=this.getLayer();return t?(t.removeMask(this),this.Ns(),super.remove(),this):this}getMesh(t,i,e){return this.isVisible()?(this._t||(this._t=this.ze(t,i,e)),this.Gs(this._t,i,e),this._t):null}js(t){const i=this.getMap(),e=this.toGeoJSON(),s=$e$4.flatten(e.geometry.coordinates);for(let t=0;t<s.vertices.length;t+=2){is$4.x=s.vertices[t],is$4.y=s.vertices[t+1];const e=wt$5(i,is$4);s.vertices[t]=e[0],s.vertices[t+1]=e[1]}const n=wt$5(i,this.getCenter()),r=[],h="video"===this.getMode()?4:s.vertices.length/2;for(let t=0;t<h;t++)r.push(s.vertices[2*t]-n[0]),r.push(s.vertices[2*t+1]-n[1]),r.push(0);const o=$e$4(r,s.holes,3),a=new Q$7({POSITION:r,TEXCOORD:this.Bs(s.vertices)},o,0,{positionAttribute:"POSITION",uv0Attribute:"TEXCOORD"});return a.generateBuffers(t),a}Bs(t){const i=[0,0,1,0,1,1,0,1];if(this.hasHoles())for(let e=i.length/2-1;e<t.length;e+=2)i[e]=i[e+1]=0;return i}Us(){this.Ns(),delete this._t}zs(){return Ye$4[this.Hs]}Vs(){const t=this.getSymbol(),{polygonFill:i,polygonOpacity:e}=t||Ze$4,s=mt$5([],i);return s[0]/=255,s[1]/=255,s[2]/=255,s[3]=ct$5(e)?e:Ze$4.polygonOpacity,s}Ws(t=0){const i=this.getMap(),e=i.getGLRes();return i.altitudeToPoint(t,e)}qs(t){const i=wt$5(this.getMap(),this.getCenter()),e=fromRotationTranslationScale(t.localTransform,identity$1(Xe$4),i,Je$4);t.localTransform=e}Ns(){this._t&&(this._t.material&&this._t.material.dispose(),this._t.geometry&&this._t.geometry.dispose(),this._t.dispose(),delete this._t)}containsPoint(t){const i=this.getExtent();if(is$4.x=t[0],is$4.y=t[1],!i.contains(is$4))return!1;const e=this.getHoles();for(let i=0;i<e.length;i++)if(this.$s(e[i],t))return!1;const s=this.getShell();return this.$s(s,t)}$s(t,i){const e=this.Ys(t);let s=0;for(let e=0;e<t.length;e++){Ke$4.x=t[e].x,Ke$4.y=t[e].y;const n=e+1>=t.length?0:e+1;Qe$4.x=t[n].x,Qe$4.y=t[n].y,is$4.x=i[0],is$4.y=i[1],ts$4[0]=is$4,ts$4[1]=Ke$4,ts$4[2]=Qe$4,s+=this.Ys(ts$4)}return!(Math.abs(s-e)>1e-8)}Ys(t){const i=this.getMap();let e=0;const s=i.getGLRes(),n=i.coordToPointAtRes(t[0],s,es$4);for(let a=1;a<t.length-1;a++){const l=i.coordToPointAtRes(t[a],s,ss$4),c=i.coordToPointAtRes(t[a+1],s,ns$4);e+=Math.abs((o=c,((h=l).x-(r=n).x)*(o.y-r.y)-(h.y-r.y)*(o.x-r.x)))/2}var r,h,o;return e}}const hs$4=["shapechange","symbolchange","heightrangechange","flatheightchange"],os$4=new t$1.Coordinate(0,0),as$4=[],ls$4=[];function cs$5(){return this._maskList?(this._maskList.forEach((t=>{t.remove()})),this._maskList=[],this.updateExtent("shapechange"),this):this}function us$4(t){const i=this.getMap(),e=i.getView(),s=i.getFitZoom(t),n=t.getCenter();i.setView({center:n,zoom:s,pitch:0,bearing:0});const r=i.getExtent(),h=copy$5([],i.projViewMatrix);return i.setView(e),{mapExtent:r,projViewMatrix:h}}function fs$4(){for(let t=0;t<this._maskList.length;t++)if(this._maskList[t].isVisible())return!0;return!1}function ds$4(t){return class extends t{removeMask(t){if(!this._maskList)return this;if(!t)return cs$5.call(this),this;const i=Array.isArray(t)?t:[t];for(let t=0;t<i.length;t++){const s=this._maskList.indexOf(i[t]);s>-1&&this._maskList.splice(s,1)}return this.updateExtent("shapechange"),this}setMask(t){return this.removeMask(),this._maskList||(this._maskList=[]),Array.isArray(t)?t.forEach((t=>{this._maskList.push(t)})):this._maskList.push(t),this._maskList.forEach((t=>{t._bindLayer(this),t.Xs&&t.Xs()})),this.updateExtent("shapechange"),this}onAdd(){super.onAdd(),this.updateExtent("shapechange")}getMasks(){return this._maskList||[]}_onGeometryEvent(t){if(!t||!t.target)return;const i=t.type;"shapechange"===i&&t.target instanceof rs$4&&t.target.Us(),t.target instanceof rs$4&&hs$4.indexOf(i)>-1&&this.updateExtent(i),super._onGeometryEvent&&super._onGeometryEvent(t)}identifyMask(t,i){if(!this.getMap())return[];if(!this._maskList||!this._maskList.length)return[];const e=at$5({},i);e.excludeMasks=!0;const s=this.identifyAtPoint(t,e),n=s.length&&s[0].coordinate;return n?this._hitMasks(n):[]}_hitMasks(t){const i=this._maskList;if(!i)return[];const e=[];for(let s=0;s<i.length;s++){const n=i[s].getMode();!i[s].containsPoint(t)||"color"!==n&&"video"!==n||e.push(i[s])}return e}remove(){this._maskList&&this._maskList.length&&this._maskList.forEach((t=>{t.remove()})),super.remove()}updateMask(t){const i=this.getMap(),{projViewMatrix:e,mapExtent:s}=us$4.call(this,t);os$4.x=s.xmin,os$4.y=s.ymin;const n=ps$4(as$4,os$4,i);os$4.x=s.xmax,os$4.y=s.ymax;const r=ps$4(ls$4,os$4,i);return{projViewMatrix:e,extentInWorld:[n[0],n[1],r[0],r[1]]}}updateExtent(t){if(!this._maskList)return;if(!this.getMap())return;const i=this.getRenderer();if(i&&!this._maskList.length)return void i._clearMask();if(i&&!fs$4.call(this))return i._deleteMaskUniforms(),void i.setToRedraw();const e=this.getMaskExtent();if(!e)return;const{extent:s,ratio:n,minHeight:r}=e;if(t||!this._projViewMatrix||!this._projViewMatrix){const{projViewMatrix:t,extentInWorld:i}=this.updateMask(s);this._projViewMatrix=t,this.Js=i}i?i.setMask(this.Js,this._projViewMatrix,n,r):this.once("renderercreate",(t=>{t.renderer.setMask(this.Js,this._projViewMatrix,n,r)}))}getMaskExtent(){let t=1/0,i=1/0,e=-1/0,s=-1/0,n=-1/0,h=1/0,o=!1;for(let r=0;r<this._maskList.length;r++){const a=this._maskList[r];if(!a.isVisible())continue;const l=a.getExtent();if(l&&this.Zs(l)&&(o=!0,l.xmin<t&&(t=l.xmin),l.ymin<i&&(i=l.ymin),l.xmax>e&&(e=l.xmax),l.ymax>s&&(s=l.ymax),a.Ks)){const t=a.Ks();t[0]<h&&(h=t[0]),t[1]>n&&(n=t[1])}}if(!o)return null;const{ratio:a,minHeight:l}=function(t,i){const e=t===1/0?0:t,n=Math.abs((i===-1/0?0:i)-e);return 0===n?{ratio:1,minHeight:0}:{ratio:Math.pow(n,-1),minHeight:e}}(h,n);return{extent:new t$1.Extent(t,i,e,s),ratio:a,minHeight:l}}Zs(t){return this.getMap().getExtent().intersects(t)}}}function ps$4(t,e,s,n=0){if(!(s&&e instanceof t$1.Coordinate))return null;const r=s.coordinateToPointAtRes(e,s.getGLRes());return t[0]=r.x,t[1]=r.y,t[2]=n,t}const gs$4=new t__namespace.Coordinate(0,0),ms$4=new t__namespace.Coordinate(0,0),vs$4=new t__namespace.Point(0,0),ws$4=[],xs$3={tileGrids:[],count:0},Ms$3="01",_s$3="1";class ys$4 extends(ds$4(t__namespace.TileLayer)){constructor(t,i){i&&!i.tileSystem&&("cesium"===i.type||"cesium-ion"===i.type?i.tileSystem=[1,1,-180,-90]:"tianditu"===i.type&&(i.tileSystem=[1,-1,-180,90])),super(t,i)}getTileUrl(t,i,e){let s=super.getTileUrl(t,i,e);return"mapbox"===this.options.type&&this.options.requireSkuToken&&(this.Qs||(this.Qs=this.tn()),s.indexOf("?")>-1?s+="&sku="+this.Qs:s+="?sku="+this.Qs),s}getMaxAvailableZoom(){return this.getSpatialReference().getMaxZoom()}tn(){let t="";for(let i=0;i<10;i++)t+="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[Math.floor(62*Math.random())];return[_s$3,Ms$3,t].join("")}setSkinLayers(t){this.in=t;const i=this.getRenderer();i&&(i.clear(),i.setToRedraw())}getSkinTiles(i){const e=this.getRenderer();if(!e)return xs$3;const s=e.getTileGridsInCurrentFrame().tileGrids[0];if(!s)return xs$3;const n=i.getId(),r=this._getTileConfig().tileSystem.scale,h=i.getTileSize().width,o=s.tiles;if(!o.length)return xs$3;const a=this.getMap(),l=s.parents||ws$4,c=l.length,u=l.concat(o),f=i.getSpatialReference(),d=o[0].extent2d.getWidth(),p=r.x,g=r.y,m=[],v=[],w=new Set,x=this._getTileConfig().tileSystem.scale.y;for(let e=0;e<u.length;e++){const s=u[e],{res:r}=s;let o=s.nw;o||(o=s.nw=a.pointAtResToCoord(s.extent2d.getMin(vs$4),s.res));const{res:l,zoom:M}=Ui$3(f,s.z,r),_=l/r,y=Bi$3(l,h,r,d),{extent2d:b,offset:S}=s,C=y*s.x,T=y*s.y;if(s.skinTileIds||(s.skinTileIds={}),!s.skinTileIds[n]){const e=new Set,r=[],a=ji$3(i,s.x,s.y,M,o,S,g,y,0);for(let s=0;s<a.length;s++){const n=a[s];if(e.has(n.id))continue;n.idx=n.x,n.idy=n.y,n.res=l,n.url=i.getTileUrl(n.x,n.y,n.z+i.options.zoomOffset);const c=g*(n.skinY-T)*h,u=b.xmin*_+p*(n.x-C)*h,f=b.ymax*_+c,d=b.ymin*_+c;n.extent2d=x>0?new t__namespace.PointExtent(u,d,u+h,d+h):new t__namespace.PointExtent(u,f-h,u+h,f),e.add(n.id),r.push(n)}s.skinTileIds[n]=r}const k=s.skinTileIds[n];for(let t=0;t<k.length;t++)w.has(k[t].id)||(e<c?m.push(k[t]):v.push(k[t]),w.add(k[t].id))}return{tileGrids:[{extent:s.extent,tiles:v,parents:m,count:v.length}],count:v.length}}getSkinLayer(t){return this.getSkinLayers()[t]}getSkinLayers(){return this.in||ws$4}getSkinCount(){return this.in&&this.in.length||0}queryTerrainByProjCoord(t,i){i=i||[];const e=this.getRenderer();if(!e)return i[0]=null,i[1]=0,i;const s=this.getMap(),n=e.ks(t);if(!n)return i[0]=null,i[1]=0,i;const r=s._prjToPointAtRes(t,1,vs$4);return e.As(i,n.id,n,r,1)}queryTileTerrainByProjCoord(t,i,e,s){s=s||[];const n=this.getRenderer();if(!n)return s[0]=null,s[1]=0,s;const r=this.getMap()._prjToPointAtRes(t,1,vs$4);return n.As(s,i,e,r,1)}queryTileTerrainByPointAtRes(t,i,e,s,n){n=n||[];const r=this.getRenderer();return r?r.As(n,e,s,t,i):(n[0]=null,n[1]=0,n)}queryTerrain(t,i){if(i=i||[],!this.getRenderer())return i[0]=null,i[1]=0,i;const e=this.getMap().getProjection().project(t,gs$4);return this.queryTerrainByProjCoord(e,i)}queryTileMesh(t,i){const e=this.getRenderer();e&&e.en(t,i)}getTerrainTiles(i){const{x:e,y:s,z:n,res:r,offset:h}=i,o=i.extent2d.getWidth(),a=this._getTileConfig(),l=this.getSpatialReference(),{res:c,zoom:u}=Ui$3(l,n,r),f=this.getTileSize().width,d=Bi$3(c,f,r,o);let p=i.nw;p||(p=i.nw=this.getMap().pointAtResToCoord(i.extent2d.getMin(vs$4),i.res));const g=Ni$3(this,e,s,u,p,h,a.tileSystem.scale.y,d,1)[0];for(let i=0;i<g.length;i++){const{x:e,y:s}=g[i],n=a.getTilePointNW(e,s,c,vs$4);g[i].res=c,g[i].extent2d=new t__namespace.PointExtent(n.x,n.y,n.x+f,n.y-f)}return g}isTerrainTileLoaded(t){const i=this.getRenderer();return!!i&&i.isTileCached(t)}updateMaterial(t){if(!t)return;this.options.material||(this.options.material={}),at$5(this.options.material,t);const i=this.getRenderer();i&&i.updateMaterial(t)}setMaterial(t){if(!t)return;this.options.material=t;const i=this.getRenderer();i&&i.setMaterial(t)}Cs(t,i,e,s,n,r,h,o,a,l){const c=this.getMap(),u=this.options.zoomOffset;a||(a=this._getTileConfig().getTilePrjExtent(t,i,r).convertTo((t=>c._prjToPointAtRes(t,r,ms$4))));const f=this._getTileOffset(e);return{parent:o,layer:this.getId(),x:t,y:i,z:e,idx:s,idy:n,res:r,extent2d:a,id:l||this._getTileId(t,i,e),url:this.getTileUrl(t,i,e+u),offset:f,error:h,children:[]}}}ys$4.mergeOptions({forceRenderOnMoving:!0,forceRenderOnZooming:!0,forceRenderOnRotating:!0,fadeAnimation:!1,fadeDuration:1e3/60*15,tileLimitPerFrame:2,newTerrainTileRenderLimitPerFrameOnInteracting:1,opacity:1,renderer:"gl",pyramidMode:1,tileSize:256,terrainWidth:65,backZoomOffset:0,depthMask:!0,blendSrc:"one",blendDst:"one minus src alpha",requireSkuToken:!0,cesiumIonTokenURL:"https://api.cesium.com/v1/assets/1/endpoint?access_token=",tileRetryCount:0,shader:"default",terrainTileMode:!0,tempTileCacheSize:64,tileStackStartDepth:7,tileStackDepth:6}),ys$4.registerJSONType("TerrainLayer"),ys$4.registerRenderer("gl",ge$4);const bs$4=()=>{},Ss$3=[null,0];class Cs$3 extends t__namespace.Layer{static fromJSON(i){if(!i||"GroupGLLayer"!==i.type)return null;const e=i.layers.map((i=>t__namespace.Layer.fromJSON(i)));return new Cs$3(i.id,e,i.options)}constructor(t,i,e){super(t,e),this.layers=i&&i.slice()||[],this.layers.forEach((t=>{if(t.getMap())throw new Error(`layer(${t.getId()} is already added on map`)})),this.sn(),this.sortLayersByZIndex(),this.nn={}}sortLayersByZIndex(){if(this.layers&&this.layers.length){for(let t=0,i=this.layers.length;t<i;t++)this.layers[t].__group_gl_order=t;this.layers.sort(ks$3)}}setSceneConfig(t){this.options.sceneConfig=t;const i=this.getRenderer();return i&&i.updateSceneConfig(),this}getSceneConfig(){return JSON.parse(JSON.stringify(this.ut()))}ut(){return this.options.sceneConfig||{}}getGroundConfig(){return this.ut().ground}getWeatherConfig(){return this.ut().weather}addLayer(t,i){if(t.getMap())throw new Error(`layer(${t.getId()}) is already added on map`);if("gl"!==t.options.renderer)throw new Error(`layer(${t.getId()})'s renderer is canvas, not supported to be added to GroupGLLayer`);void 0===i?this.layers.push(t):this.layers.splice(i,0,t),this.sn(),this.sortLayersByZIndex();const e=this.getRenderer();return e?(this.rn(t),this.hn(),e.setToRedraw(),this):this}removeLayer(i){t__namespace.Util.isString(i)&&(i=this.getChildLayer(i));const e=this.layers.indexOf(i);if(e<0)return this;const s=i.getRenderer();s&&s.setTerrainHelper&&s.setTerrainHelper(null),i._doRemove(),this.an(i),delete this.nn[i.getId()],this.layers.splice(e,1);const n=this.getRenderer();return n?(this.hn(),n.setToRedraw(),this):this}clearLayers(){const t=this.getLayers();for(let i=0;i<t.length;i++)t[i]&&t[i].remove();return this}ki(){let t=0;for(let i=0;i<this.layers.length;i++)this.layers[i].setPolygonOffset&&this.layers[i].getPolygonOffsetCount&&(t+=this.layers[i].getPolygonOffsetCount());let i=0;for(let e=this.layers.length-1;e>=0;e--)this.layers[e].setPolygonOffset&&this.layers[e].getPolygonOffsetCount&&(this.layers[e].setPolygonOffset(i,t),i+=this.layers[e].getPolygonOffsetCount());this.ln=i}getPolygonOffsetCount(){return this.ln}getLayers(){return this.layers.slice()}ue(){return this.layers}toJSON(){const t=[];if(this.layers)for(let i=0;i<this.layers.length;i++){const e=this.layers[i];e&&e&&e.toJSON&&t.push(e.toJSON())}return{type:this.getJSONType(),id:this.getId(),layers:t,options:this.config()}}onLoadEnd(){this.layers.forEach((t=>{this.rn(t)})),this.options.terrain&&this.cn(),super.onLoadEnd()}rn(t){const i=this.getMap();this.nn[t.getId()]=t,t._canvas=this.getRenderer().canvas,t._bindMap(i),t.once("renderercreate",this.un,this),t.remove=()=>{this.removeLayer(t),t.constructor.prototype.remove.call(t),delete t.remove},t.load(),this.dn(t)}onRemove(){this.pn(),this.layers.forEach((t=>{this.gn(t),t._doRemove(),this.an(t)})),this.nn={},this.clearAnalysis(),super.onRemove()}getChildLayer(t){return this.nn[t]||null}getLayer(t){return this.getChildLayer(t)}dn(t){t.on("show hide",this.mn,this),t.on("idchange",this.vn,this)}an(t){t.off("show hide",this.mn,this),t.off("idchange",this.vn,this)}mn(){const t=this.getRenderer();t&&t.setToRedraw()}vn(t){const i=t.new,e=t.old,s=this.getLayer(e);delete this.nn[e],this.nn[i]=s}un(t){t.renderer.clearCanvas=Ts$3}sn(){const t={};this.layers.forEach((i=>{const e=i.getId();if(t[e])throw new Error(`Duplicate child layer id (${e}) in the GroupGLLayer (${this.getId()})`);t[e]=1}))}addAnalysis(t){this.wi=this.wi||[],this.wi.push(t);const i=this.getRenderer();i&&i.setToRedraw()}removeAnalysis(t){if(this.wi){const i=this.wi.indexOf(t);i>-1&&(this.wi.splice(i,1),t.remove())}const i=this.getRenderer();i&&i.setToRedraw()}clearAnalysis(){this.wi&&(this.wi.forEach((t=>{t.remove()})),this.wi=[]);const t=this.getRenderer();t&&t.setToRedraw()}identify(i,e={}){const s=this.getMap(),n=this.getRenderer();if(!s||!n)return[];const r=s.coordToContainerPoint(new t__namespace.Coordinate(i));return this.identifyAtPoint(r,e)}identifyAtPoint(t,i={}){const e=i.includeInternals,s=this.getLayers(),n=i&&i.childLayers||s,r=this.getMap();if(!r)return[];const h=lt$5(i.count)?1:i.count;let o=[];for(let r=n.length-1;r>=0;r--){const h=n[r];if(s.indexOf(h)<0||!h.identifyAtPoint)continue;const a=h.options.geometryEvents;if(e&&(void 0===a||!1===a||0===a))continue;if(h.isGeometryListening&&e&&i.eventTypes.indexOf("mousemove")>=0&&!h.isGeometryListening(i.eventTypes))continue;let l=h.identifyAtPoint(t,i);if(!l||!l.length)continue;if(i.filter&&(l=l.filter((t=>i.filter(t)))),!l.length)continue;const c=h.getId();for(let t=0;t<l.length;t++)l[t]&&(l[t].layer=c);o.push(...l)}if(i.orderByCamera){const t=r.cameraPosition;o.sort(((i,e)=>e.point?i.point?dist$2(i.point,t)-dist$2(e.point,t):1:-1))}return h&&(o=o.slice(0,h)),o}getTerrain(){return this.options.terrain}setTerrain(t){return this.options.terrain=t,this.getRenderer()?(this.cn(),this.getMap().updateCenterAltitude(),this):this}removeTerrain(){return this.setTerrain(null)}updateTerrainMaterial(t){this.le&&t&&(this.options.terrain.material?at$5(this.options.terrain.material,t):this.options.terrain.material=t,this.le.updateMaterial(t))}cn(){const t=this.getRenderer();t&&t.setToRedraw();const i=this.options.terrain;if(this.le){const t=this.le.options;if(i&&t.urlTemplate===i.urlTemplate&&t.spatialReference===i.spatialReference){for(const t in i)"material"===t?this.le.setMaterial(i[t]):"urlTemplate"!==t&&"spatialReference"!==t&&this.le.config(t,i[t]);return this}this.pn()}if(this.wn(),!i)return this;this.le=new ys$4("__terrain_in_group",i),this.hn(),this.le.on("tileload",this.xn,this),this.rn(this.le);const e=i.masks;return e&&e.length?this.le.setMask(e):this.le.removeMask(),this.fire("terrainlayercreated"),this}queryTerrain(t,i){return this.le?this.le.queryTerrain(t,i):Ss$3}queryTerrainByProjCoord(t,i){return this.le?this.le.queryTerrainByProjCoord(t,i):Ss$3}hn(){if(!this.le)return;const t=this.layers,i=[];for(let e=0;e<t.length;e++){if(!t[e])continue;const s=t[e],n=s.getRenderer();if(n.renderTerrainSkin){if(n.deleteTile===bs$4){i.push(t[e]);continue}s.getTiles=()=>this.le.getSkinTiles(s),n.drawTile=n.drawTileOnTerrain?(...t)=>n.drawTileOnTerrain(...t):bs$4,n.deleteTile=bs$4,i.push(t[e])}n.setTerrainHelper&&n.setTerrainHelper(this.le)}this.le.setSkinLayers(i)}gn(t){if(!function(t){if(!t)return!1;const i=t.getRenderer();return!!i&&!!i.renderTerrainSkin}(t))return;const i=t.getRenderer();i&&(i.setTerrainHelper&&i.setTerrainHelper(null),i.clear&&i.clear(),delete i.drawTile,delete i.deleteTile),delete t.getTiles}wn(){const t=this.layers;for(let i=0;i<t.length;i++)t[i]&&this.gn(t[i])}xn(){const t=this.getRenderer();t&&t.setToRedraw()}pn(){if(this.le){const t=this.le;t.off("tileload",this.xn,this),this.an(t),this.le._doRemove(),delete this.le,this.fire("terrainlayerremoved")}}getTerrainLayer(){return this.le}_bindMap(...t){if(this.options.single){const i=t[0].getLayers();for(let t=0;t<i.length;t++)if(i[t]instanceof Cs$3)throw new Error("Only one GroupGLLayer is allowed in a map instance. Set options.single to false if you want to add two or more GroupGLLayers.")}return super._bindMap(...t)}fire(...t){if("layerload"===t[0]){const t=this.ue();for(const i of t){const t=i.getRenderer();t&&t.isRenderComplete()&&i.fire("layerload")}}super.fire(...t)}}function Ts$3(){}function ks$3(t,i){const e=t.getZIndex()-i.getZIndex();return 0===e?t.__group_gl_order-i.__group_gl_order:e}Cs$3.mergeOptions({renderer:"gl",antialias:!0,extensions:[],single:!0,onlyWebGL1:!1,optionalExtensions:["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","EXT_frag_depth","EXT_texture_filter_anisotropic","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],forceRenderOnZooming:!0,forceRenderOnMoving:!0,forceRenderOnRotating:!0,viewMoveThreshold:100,geometryEvents:!0,multiSamples:4,forceRedrawPerFrame:!1}),Cs$3.registerJSONType("GroupGLLayer"),Cs$3.registerRenderer("gl",class extends t__namespace.renderer.CanvasRenderer{setToRedraw(){this.setRetireFrames(),super.setToRedraw()}onAdd(){super.onAdd(),this.prepareCanvas()}updateSceneConfig(){this._i&&this._i.update(),this.yi&&this.yi.update(),this.bi&&this.bi.update(),this.setToRedraw()}render(...t){this.getMap()&&this.layer.isVisible()&&(this.forEachRenderer((t=>{t._replacedDrawFn||(t.draw=this.Si(t.draw),t.drawOnInteracting=this.Ci(t.drawOnInteracting),t.setToRedraw=this.Ti(t.setToRedraw),t._replacedDrawFn=!0)})),this.prepareRender(),this.prepareCanvas(),this.layer.ki(),this._toRedraw=!1,this.Ai("render",t),this.Oi(),this.Ii())}prepareCanvas(){super.prepareCanvas(),this.forEachRenderer((t=>{t.prepareCanvas()}))}drawOnInteracting(...t){this.getMap()&&this.layer.isVisible()&&(this.layer.ki(),this._toRedraw=!1,this.Ai("drawOnInteracting",t),this.Oi(),this.Ii())}Ai(t,i){this.Ei="default";const e=this.hasRenderTarget(),s=this.Li(i);if(e&&(this.Fi.renderTarget=this.Ri()),this.yi.paint(s),this.drawGround(!0),!e)return void this.Pi("default",null,t,i,!0);const n=this.glCtx,r=this.layer.ut(),h=r&&r.postProcess,o=this.isSSROn(),a=this.isEnableTAA(),l=s.jitter;s.jitter=Si$3;const c=this.layer.getGroundConfig();if(s.hasSSRGround=!!(o&&c&&c.enable&&c.symbol&&c.symbol.ssr),n.resetDrawCalls(),this.Pi(a?"fxaaBeforeTaa":"fxaa",this.Di,t,i),this.Hi=n.getDrawCalls(),o&&this.Ni.drawSSR(this.Gi(),this.Di),a){const e=this.getMap(),r=this.Ni.isTaaNeedRedraw()||this.ji||e.getRenderer().isViewChanged();s.jitter=r?l:this.Bi.getAverage(),s.onlyUpdateDepthInTaa=!r;let o=this.Ui;if(o)o.width===this.Di.width&&o.height===this.Di.height||o.resize(this.Di.width,this.Di.height);else{const t=this.regl,i=this.createFBOInfo(h,this.zi);o=this.Ui=t.framebuffer(i)}n.resetDrawCalls(),this.Pi("taa",o,t,i),this.Vi=n.getDrawCalls(),delete s.onlyUpdateDepthInTaa,s.jitter=Si$3;let a=this.Wi;if(a)a.width===this.Di.width&&a.height===this.Di.height||a.resize(this.Di.width,this.Di.height);else{const t=this.regl,i=this.createFBOInfo(h,this.zi);a=this.Wi=t.framebuffer(i)}n.resetDrawCalls(),this.Pi("fxaaAfterTaa",this.Wi,t,i),this.qi=n.getDrawCalls()}else this.Ui&&(this.Ui.destroy(),this.Wi.destroy(),delete this.Ui,delete this.Wi,delete this.qi);h.bloom&&h.bloom.enable&&(this.$i=this.Ni.drawBloom(this.zi)),2===o&&this.Ni.drawSSR(this.Gi(),this.Di,!0),n.resetDrawCalls(),this.Pi("noAa",this.Yi,t,i),this.Xi=n.getDrawCalls(),n.resetDrawCalls(),this.Pi("point",this.Ji,t,i,!0),this.bi.renderScene(s),this.Zi=n.getDrawCalls()}Pi(t,i,e,s,n){this.Ei=t;const r=this.Li(s);r.renderMode=this.Ei,r.renderTarget&&(r.renderTarget.fbo=i),n&&(r.isFinalRender=!0),this.forEachRenderer(((n,r)=>{r.isVisible()&&("default"===t||!n.supportRenderMode&&("fxaa"===t||"fxaaAfterTaa"===t)||n.supportRenderMode&&n.supportRenderMode(t))&&(this.clearStencil(n,i),n[e].apply(n,s))}))}Li(t){let i=t[0];return Oi$3(i)||(i=t[1]),i!==this.Ki&&(this.forEachRenderer(((t,i)=>{i.isVisible()&&t.needRetireFrames&&t.needRetireFrames()&&this.setRetireFrames()})),this.Fi=this.Qi(i),this.Ki=i,this.te=Oi$3(t[0])?null:t[0]),this.Fi}Oi(){if(!this.isEnableOutline())return;const t=this.ie(),i=this.glCtx;i.resetDrawCalls(),this.forEachRenderer(((i,e)=>{e.isVisible()&&i.drawOutline&&i.drawOutline(t)})),this.ee=i.getDrawCalls()}ie(){const{width:t,height:i}=this.canvas;let e=this.se;if(e)t===e.width&&i===e.height||e.resize(t,i);else{const s=this.regl.texture({width:t,height:i,format:"rgba4"});e=this.se=this.regl.framebuffer({width:t,height:i,colors:[s],depth:!1,stencil:!1})}return e}ii(t){if(this.vi()){const i=this.ne(t);return i.width!==t.width||i.height!==t.height?i.resize(t.width,t.height):this.regl.clear({color:[0,0,0,0],fbo:i}),i.blit(t),i.color[0]}return t.color[0]}Gi(){if(this.zi.subimage)return this.zi;const{width:t,height:i}=this.zi;if(!this.re){const e=this.regl,s={depthStencil:e.texture({min:"nearest",mag:"nearest",mipmap:!1,type:"depth stencil",width:t,height:i,format:"depth stencil"}),colors:[e.renderbuffer({width:t,height:i,format:"rgba4"})],colorFormat:"rgba4",width:t,height:i};this.re=e.framebuffer(s)}return this.re.width===t&&this.re.height===i||this.re.resize(t,i),this.regl.clear({color:[0,0,0,0],depth:1,fbo:this.re}),this.re.blit(this.Di,256,"nearest"),this.re.depthStencil}ne(t){if(this.he||(this.he=[]),!t.oe){const i=this.ae(!0,t.width,t.height),e=this.regl.framebuffer(i);this.he.push(e),t.oe=e}return t.oe}vi(){return 0===this.regl.limits.version.indexOf("WebGL 2.0")&&this.layer.options.antialias}hasRenderTarget(){const t=this.layer.ut(),i=t&&t.postProcess;return!(!i||!i.enable)}testIfNeedRedraw(){if(this.layer.options.forceRedrawPerFrame)return!0;if(this._toRedraw)return this._toRedraw=!1,!0;if(this.getMap().isInteracting()&&(this._i&&this._i.isEnable()||this.yi&&this.yi.isEnable()))return!0;if(this.bi&&this.bi.isEnable())return!0;const t=this.layer.le;if(t){const i=t.getRenderer();if(i&&i.testIfNeedRedraw())return this.ce=!0,!0}const i=this.ue();for(const t of i){const i=t.getRenderer();if(i&&i.testIfNeedRedraw())return this.ce=!0,!0}return!1}isRenderComplete(){const t=this.ue();for(const i of t){const t=i.getRenderer();if(t&&!t.isRenderComplete())return!1}return!0}mustRenderOnInteracting(){const t=this.ue();for(const i of t){const t=i.getRenderer();if(t&&t.mustRenderOnInteracting())return!0}return!1}isCanvasUpdated(){if(super.isCanvasUpdated())return!0;const t=this.ue();for(const i of t){const t=i.getRenderer();if(t&&t.isCanvasUpdated())return!0}return!1}isBlank(){if(this._i&&this._i.isEnable())return!1;if(this.yi&&this.yi.isEnable())return!1;const t=this.layer.getTerrainLayer();if(t){const i=t.getRenderer();if(i&&!i.isBlank())return!1}const i=this.ue();for(const t of i){const i=t.getRenderer();if(i&&!i.isBlank())return!1}return!0}createContext(){const t=this.layer,i=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0};i.preserveDrawingBuffer=!0,i.antialias=!!t.options.antialias,this.glOptions=i;const e=this.gl=function(t,i,e){const s=e?["webgl","experimental-webgl"]:["webgl2","webgl","experimental-webgl"];let n=null;for(let e=0;e<s.length;++e){try{n=t.getContext(s[e],i)}catch(t){}if(n)break}return n||console.error("Browser doesn't support WebGL."),n}(this.canvas,i,t.options.onlyWebGL1);this.fe(e),e.wrap=()=>new a(this.gl),this.glCtx=e.wrap(),this.canvas.gl=this.gl,this.reglGL=e.wrap(),this.regl=a$2({gl:this.reglGL,attributes:i,extensions:t.options.extensions,optionalExtensions:t.options.optionalExtensions}),this.gl.regl=this.regl,this.de=[0,0],this._i=new jt$4(this.regl,this.layer),this.yi=new qt$4(this.regl,this.layer);const s=this.layer.getWeatherConfig();this.bi=new di$3(this.regl,t,s),this.pe=new _i$3(this.regl,t);const n=this.layer.ut()||{},r=n&&n.postProcess;this.Bi=new Bn$4(r&&r.antialias&&r.antialias.jitterRatio||.2),this.Ni=new vi$3(this.regl,this.layer,this.Bi),this.o=new yt$5(this.regl,n,this.layer)}fe(){const t=this.layer,i=this.gl,e=t.options.extensions;e&&e.forEach((t=>{i.getExtension(t)}));const s=t.options.optionalExtensions;s&&s.forEach((t=>{i.getExtension(t)})),this.gl.clearColor(0,0,0,0)}clearCanvas(){super.clearCanvas(),this.ge()}ge(){const t=this.regl;this.Di&&(t.clear({color:yi$3,depth:1,stencil:255,framebuffer:this.Di}),t.clear({color:yi$3,framebuffer:this.Yi}),t.clear({color:yi$3,framebuffer:this.Ji}),this.Ui&&this.Vi&&t.clear({color:yi$3,framebuffer:this.Ui}),this.Wi&&this.qi&&t.clear({color:yi$3,framebuffer:this.Wi})),this.se&&t.clear({color:yi$3,framebuffer:this.se}),t.clear({color:yi$3,depth:1,stencil:255})}resizeCanvas(){const t=this.canvas.width,i=this.canvas.height;!this.Di||this.Di.width===t&&this.Di.height===i||(super.resizeCanvas(),this.Di.resize(t,i),this.Yi.resize(t,i),this.Ji.resize(t,i),this.Ui&&this.Ui.resize(t,i),this.Wi&&this.Wi.resize(t,i),this.ge(),this.forEachRenderer((t=>{t.canvas&&t.resizeCanvas()})))}getCanvasImage(){return this.forEachRenderer((t=>{t.getCanvasImage()})),super.getCanvasImage()}ue(){return this.layer.ue()}forEachRenderer(t){const i=this.ue();for(const e of i){if(!e.isVisible()||!e.options.beneathTerrain)continue;const i=e.getRenderer();i&&t(i,e)}const e=this.layer.le;if(e){const i=e.getRenderer();i&&t(i,e)}for(const e of i){if(!e.isVisible()||e.options.beneathTerrain)continue;const i=e.getRenderer();i&&t(i,e)}}clearStencil(t,i){const e={stencil:t.getStencilValue?t.getStencilValue():255};i&&(e.framebuffer=i),this.regl.clear(e)}onRemove(){this.canvas.pickingFBO&&this.canvas.pickingFBO.destroy&&this.canvas.pickingFBO.destroy(),this.me(),this._i&&(this._i.dispose(),delete this._i),this.yi&&(this.yi.dispose(),delete this.yi),this.o&&(this.o.dispose(),delete this.o),this.Ni&&(this.Ni.dispose(),delete this.Ni),this.se&&(this.se.destroy(),delete this.se),this.bi&&(this.bi.dispose(),delete this.bi),super.onRemove()}me(){if(this.Di&&(this.Di.destroy(),this.Yi.destroy(),this.Ji.destroy(),this.Ui&&(this.Ui.destroy(),delete this.Ui),this.Wi&&(this.Wi.destroy(),delete this.Wi),delete this.Di,delete this.Yi,delete this.Ji,this.ve&&(this.ve.destroy(),delete this.ve),this.re&&(this.re.destroy(),delete this.re),this.he)){for(let t=0;t<this.he.length;t++)this.he[t]&&this.he[t].destroy();delete this.he}}setRetireFrames(){this.ji=!0}getFrameTime(){return this.Ki}getFrameEvent(){return this.te}getFrameContext(){return this.Fi}drawGround(t){const i=this.layer.getGroundConfig();if(!i||!i.enable)return!1;if(!this._i)return!1;const e=this.getFrameContext(),s=e.jitter;e.jitter=Si$3;const n=this.layer.getPolygonOffsetCount();let r;e.offsetFactor=n+1,e.offsetUnits=n+1,t&&(r=e.sceneFilter,delete e.sceneFilter);const h=this._i.paint(e);return this._i.needToRedraw()&&this.setToRedraw(),r&&(e.sceneFilter=r),e.jitter=s,h}Si(t){const i=this;return function(e,s){return(s=s||i.Fi)&&s.renderTarget&&(s.renderTarget.getFramebuffer=Ii$3,s.renderTarget.getDepthTexture=Ei$3),t.call(this,e,s)}}Ci(t){const i=this;return function(e,s,n){return(n=n||i.Fi)&&n.renderTarget&&(n.renderTarget.getFramebuffer=Ii$3,n.renderTarget.getDepthTexture=Ei$3),t.call(this,e,s,n)}}Ti(t){return function(...i){return t.apply(this,i)}}isEnableSSR(){const t=this.layer.ut(),i=t&&t.postProcess;return i&&i.enable&&i.ssr&&i.ssr.enable}isSSROn(){const t=this.isEnableSSR(),i=this.getMap();if(!t||i.getPitch()<=-.001)return 0;const e=i.projViewMatrix,s=this.Ni.getPrevSsrProjViewMatrix();return s&&exactEquals$5(s,e)?1:2}isEnableTAA(){return!1}isEnableSSAO(){const t=this.layer.ut(),i=t&&t.postProcess;return i&&i.enable&&i.ssao&&i.ssao.enable}isEnableOutline(){const t=this.layer.ut(),i=t&&t.postProcess;return i&&i.enable&&i.outline&&i.outline.enable}isEnableWeather(){const t=this.layer.ut(),i=t&&t.weather;return i&&i.enable}we(){const t=this.layer.getMap();if(!this.O){this.O={center:t.getCenter(),bearing:t.getBearing(),pitch:t.getPitch(),res:t.getResolution()};let i=!1;if(t.options.lights){const e=t.getLightManager().getDirectionalLight().direction||bi$3;this.O.lightDirection=copy$4([],e),i=!0}return{viewChanged:!0,lightDirectionChanged:i}}const i=t.getResolution()/this.O.res,e=t.coordToContainerPoint(this.O.center),s=this.layer.options.viewMoveThreshold,n=e._sub(t.width/2,t.height/2).mag()>s||i<.95||i>1.05;let r=!1;if(t.options.lights){const i=t.getLightManager().getDirectionalLight().direction||bi$3;r=!equals$5(this.O.lightDirection,i),r&&(this.O.lightDirection=copy$4([],i))}return n&&(this.O.center=t.getCenter(),this.O.bearing=t.getBearing(),this.O.pitch=t.getPitch(),this.O.res=t.getResolution()),{viewChanged:n,lightDirectionChanged:r}}Qi(t){const i=this.layer.ut(),e=i&&i.postProcess,s=i&&i.weather,n={timestamp:t,renderMode:this.Ei||"default",includes:{},states:this.we(),testSceneFilter:t=>!n.sceneFilter||n.sceneFilter(t),isFinalRender:!1,weather:{fog:s&&s.fog}},h=this.Bi;h&&h.setRatio(e&&e.antialias&&e.antialias.jitterRatio||.2);const o=this.isSSROn();let a;if(e&&e.enable){this.isEnableTAA()?((this.getMap().isInteracting()||this.ji)&&h.reset(),h.getJitter(this.de),h.frame()):set(this.de,0,0),n.jitter=this.de;const t=e.bloom&&e.bloom.enable;t&&o?(n.bloom=1,n.sceneFilter=Ci$3):t?(n.bloom=1,n.sceneFilter=Ti$3):o&&(n.sceneFilter=ki$3),a=this.Ri(),a&&(n.renderTarget=a)}else this.me();return"noAa"!==this.Ei&&(this.xe=this.Me(n),this.xe&&(n.includes.shadow=1),this._e=this.ye(n)),this.xe&&(n.shadow=this.xe,n.includes.shadow=1),n.states.includesChanged=this._e,e&&e.enable&&this.Ni&&this.Ni.setContextIncludes(n),n}be(t){const i=this.ue().filter((t=>t.isVisible()));return this.layer.le&&i.push(this.layer.le),this.pe.paint(t,i)}ye(t){let i=!1;const e=Object.keys(t.includes),s=this.Se;if(s){const t=e.filter((t=>-1===s.indexOf(t))).concat(s.filter((t=>-1===e.indexOf(t))));t.length&&(i=t.reduce(((t,i)=>(t[i]=1,t)),{}))}return this.Se=e,i}Me(t){const i=this.layer.ut();if(!i||!i.shadow||!i.shadow.enable)return this.o&&(this.o.dispose(),delete this.o),null;this.o||(this.o=new yt$5(this.regl,this.layer.ut()||{},this.layer));const e={config:i.shadow,defines:this.o.getDefines(),uniformDeclares:yt$5.getUniformDeclares()};return e.renderUniforms=this.Ce(t),e}Ce(t){const i=t.renderTarget&&t.renderTarget.fbo,e=this.layer.ut(),s=[];let n=t.states.lightDirectionChanged||t.states.viewChanged;this.forEachRenderer(((t,i)=>{if(!t.getShadowMeshes||!i.isVisible())return;const e=t.getShadowMeshes();if(Array.isArray(e))for(let t=0;t<e.length;t++)e[t].needUpdateShadow&&(n=!0),e[t].needUpdateShadow=!1,s.push(e[t])})),this.Te||(this.Te=new Ke$5),this.Te.setMeshes(s);const r=this.getMap(),h=e.shadow,o=r.getLightManager(),a=o&&o.getDirectionalLight().direction||bi$3;return this.o.render(!e.ground||!e.ground.enable,r.projMatrix,r.viewMatrix,h.color,h.opacity,a,this.Te,this.de,i,n)}ke(t){let i=[];if(this.forEachRenderer(((t,e)=>{if(!t.getAnalysisMeshes||!e.isVisible())return;const s=t.getAnalysisMeshes();i=i.concat(s)})),this._i){const t=this._i.getRenderMeshes();i=i.concat(t)}const e=this.layer.getWeatherConfig();return this.bi.paint(t,i,e)}getGroundMesh(){return this._i?this._i.getRenderMeshes():[]}Ri(){const t=this.layer.ut(),i=t&&t.postProcess;if(!this.Di){const t=this.regl;let e=this.zi;(!e||!e._texture||e._texture.refCount<=0)&&(e=null);const s=this.createFBOInfo(i,e);this.zi=s.depth||s.depthStencil,this.Di=t.framebuffer(s);const n=this.createFBOInfo(i,this.zi);this.Yi=t.framebuffer(n);const r=this.createFBOInfo(i,this.zi);this.Ji=t.framebuffer(r),this.ge()}return{fbo:this.Di}}ae(t,i,e){i=i||this.canvas.width,e=e||this.canvas.height;const s=this.regl,n=this.vi();let r;if(!t&&n)r=s.renderbuffer({width:i,height:e,samples:this.layer.options.multiSamples,format:"rgba8"});else{r=s.texture({min:"nearest",mag:"nearest",type:"uint8",width:i,height:e})}return{width:i,height:e,colors:[r],colorFormat:n?"rgba8":"rgba"}}createFBOInfo(t,i){const{width:e,height:s}=this.canvas,n=this.regl,r=this.ae(),h=this.vi(),o=n.hasExtension("WEBGL_depth_texture");if(h){const t=i||n.renderbuffer({width:e,height:s,format:"depth24 stencil8",samples:this.layer.options.multiSamples});r.depthStencil=t}else if(o){const t=i||n.texture({min:"nearest",mag:"nearest",mipmap:!1,type:"depth stencil",width:e,height:s,format:"depth stencil"});r.depthStencil=t}else{const t=i||n.renderbuffer({width:e,height:s,format:"depth stencil"});r.depthStencil=t}return r}Ii(){if(!this.Di)return void(this.ji=!1);const t=this.layer.ut(),i=t&&t.postProcess;if(!i||!i.enable){if(this.isEnableWeather())throw new Error("you must enable the post process to turn on weather");return}this.layer.fire("postprocessstart");const e=this.layer.getMap();let s;if(this.isEnableTAA()){const t=this.ji||e.getRenderer().isViewChanged();t&&this.layer.fire("taastart");const{outputTex:i,redraw:n}=this.Ni.taa(this.ii(this.Ui),this.Gi(),{projMatrix:e.projMatrix,needClear:t});s=i,n?this.setToRedraw():this.layer.fire("taaend"),this.ji=!1}let n=i.sharpen&&i.sharpen.factor;n||0===n||(n=.2);let r=0,h=.2,o=.3,a=1,l=[1,1,0];i.outline&&(r=+!!i.outline.enable,h=Li$3(i.outline,"highlightFactor",h),o=Li$3(i.outline,"outlineFactor",o),a=Li$3(i.outline,"outlineWidth",a),l=Li$3(i.outline,"outlineColor",l));const c=this.isEnableSSAO(),u=i.ssr&&i.ssr.enable,f=i.bloom&&i.bloom.enable,d=f&&this.$i,p=+!(!i.antialias||!i.antialias.enable),g=this.pe.xi(),m=this.bi.si(),v=c||f||u||g||m;let w=this.ve;if(v){if(!w){const t=this.ae();this.vi()&&(t.depthStencil=this.regl.renderbuffer({width:this.canvas.width,height:this.canvas.height,samples:this.layer.options.multiSamples,format:"depth24 stencil8"})),w=this.ve=this.regl.framebuffer(t)}const{width:t,height:i}=this.canvas;w.width===t&&w.height===i||w.resize(t,i)}else w=null,this.ve&&(this.ve.destroy(),delete this.ve);let x=this.ii(this.Di);const M=this.Xi&&this.ii(this.Yi),_=this.Zi&&this.ii(this.Ji);if(this.Ni.fxaa(w,x,!d&&M,!d&&_,s,this.qi&&this.Wi&&this.ii(this.Wi),p,+!(!i.toneMapping||!i.toneMapping.enable),+!(v||!i.sharpen||!i.sharpen.enable),e.getDevicePixelRatio(),n,r&&this.ee>0&&this.ie(),h,o,a,l),w&&(x=this.ii(w)),c&&(this.qi||this.Vi||this.Hi)&&(x=this.Ni.ssao(x,this.Gi(),{projMatrix:e.projMatrix,cameraNear:e.cameraNear,cameraFar:e.cameraFar,ssaoBias:i.ssao&&i.ssao.bias||10,ssaoRadius:i.ssao&&i.ssao.radius||100,ssaoIntensity:i.ssao&&i.ssao.intensity||.5})),f&&this.$i){const t=i.bloom,e=+t.threshold||0,s=Li$3(t,"factor",1),n=Li$3(t,"radius",1);x=this.Ni.bloom(x,M,_,e,s,n,p)}if(u&&(this.Ni.genSsrMipmap(x,this.Gi()),this.ce)){const t=this.ji;this.setToRedraw(),this.ji=t,this.ce=!1}this.pe&&(x=this.be(x)),this.isEnableWeather()&&(x=this.ke(x)),v&&this.Ni.renderFBOToScreen(x,+!(!i.sharpen||!i.sharpen.enable),n,e.getDevicePixelRatio()),this.layer.fire("postprocessend")}}),Cs$3.registerRenderer("canvas",null);class As$3{constructor(t){this.Mn=t,this.N=new Ve$5,this.onHDRLoaded=this._n.bind(this),this.onHDRError=this.yn.bind(this)}getDirectionalLight(){return this.jt&&this.jt.directional||{}}getAmbientLight(){return this.jt&&this.jt.ambient||{}}getAmbientResource(){return this.bn}setConfig(t){const i=this.jt;this.jt=JSON.parse(JSON.stringify(t));let e=!1;if(t&&t.ambient&&t.ambient.resource){if(!(i&&i.ambient&&function(t,i){return!!t.resource&&t.resource.url===i.resource.url}(i.ambient,t.ambient)))return void this.Sn();this.bn&&(t.ambient.prefilterCubeSize!==i.ambient&&i.ambient.prefilterCubeSize&&this._n(),e=!0,t.ambient.resource.sh&&(this.bn.sh=t.ambient.resource.sh))}else this.Cn(),e=i&&i.ambient&&i.ambient.resource;this.Mn.fire("updatelights",{ambientUpdate:e})}Tn(t){const i=t.getLayers();for(let t=0;t<i.length;t++){const e=i[t]&&i[t].getRenderer();if(e&&e.regl)return e.regl}const e=document.createElement("canvas"),s=a$2({canvas:e,attributes:{depth:!1,stencil:!1,alpha:!1}});return s.kn=!0,s}Sn(){const t=this.jt.ambient.resource,i=t&&t.url;if(!i)return;const e=[];let s=0,n=0;const r=()=>{n++,n>=s&&this.An(e)},h=function(){throw new Error(`skybox image with url(${this.src}) failed to load, please check the image's url.`)};if(i.top||i.nx){const{front:t,back:n,right:o,left:a,top:l,bottom:c}=i,{nx:u,ny:f,px:d,py:p,nz:g,pz:m}=i;let v;v=t?[a,o,n,t,l,c]:[u,d,g,m,p,f],s=v.length;for(let t=0;t<s;t++){const i=new Image;i.onload=r,i.onerror=h,i.src=v[t],e[t]=i}}else{this.On=new en$5({url:t.url,arrayBuffer:!0,hdr:!0,flipY:!0},this.N),this.On.once("complete",this.onHDRLoaded),this.On.once("error",this.onHDRError)}}dispose(){this.Cn()}_n(){this.On&&(this.bn=this.In(this.On),this.Mn.fire("updatelights",{ambientUpdate:!0}))}yn(){this.Mn.fire("hdrerror")}An(t){this.bn=this.In(t),this.Mn.fire("updatelights",{ambientUpdate:!0})}In(t){const i=this.jt.ambient.resource,e=i.prefilterCubeSize||128,s=this.Tn(this.Mn),n=fi$4.PBRHelper.createIBLMaps(s,{envTexture:Array.isArray(t)?t:t.getREGLTexture(s),rgbmRange:Array.isArray(t)?9:t.rgbmRange,ignoreSH:!!i.sh,envCubeSize:e,prefilterCubeSize:e,format:"array"});if(i.sh&&(n.sh=i.sh,Array.isArray(n.sh[0]))){const t=n.sh,i=[];for(let e=0;e<t.length;e++)i.push(...t[e]);n.sh=i}return s.kn&&(delete this.On,s.destroy()),n}Cn(){this.On&&(this.On.dispose(),delete this.On),delete this.bn}}let Os$3,Is$3,Es$3,Ls$3,Fs$3;t$1.Map.include({setLights(t){return this.options.lights=t,this.En(),this},getLights(){return this.options.lights},En(){this.Ln||(this.Ln=new As$3(this)),this.Ln.setConfig(this.getLights())},getLightManager(){return this.Ln?this.Ln:(this.Fn||(this.Fn=!0,console.warn("map's light config is not set, use map.setLights(config) to set lights.")),null)}}),t$1.Map.addOnLoadHook((function(){this.options.lights&&this.En()}));const Rs$3={color:[0,0,0,0]},Ps$3={enable:!0};t$1.Map.include({setPostProcessConfig(t){return this.options.postProcessConfig=t,this},getPostProcessConfig(){return this.options.postProcessConfig}});const Ds$3=t$1.renderer.MapCanvasRenderer.prototype.drawLayerCanvas;t$1.renderer.MapCanvasRenderer.prototype.drawLayerCanvas=function(){const t=Ds$3.apply(this,arguments);return t&&Ns$2(this,this.canvas),t};const Hs$2=t$1.renderer.MapCanvasRenderer.prototype.renderFrame;function Ns$2(t,i){const e=t.map.getPostProcessConfig();if(!e||!e.enable)return;var s,n;Os$3||(s=i.width,n=i.height,Os$3=document.createElement("canvas",s,n),Is$3=a$2({canvas:Os$3,attributes:{depth:!1,stencil:!1,alpha:!0,antialias:!1,premultipliedAlpha:!1}}),Es$3=Is$3.texture({mag:"linear",min:"linear",mipmap:!1,flipY:!0,width:s,height:n}),Ls$3=Is$3.texture()),Os$3.width===i.width&&Os$3.height===i.height||(Os$3.width=i.width,Os$3.height=i.height),Is$3.clear(Rs$3);const r=e.filmicGrain||Ps$3;void 0===r.enable&&(r.enable=!0);const h=e.vignette||Ps$3;void 0===h.enable&&(h.enable=!0);const o=e.colorLUT||Ps$3;void 0===o.enable&&(o.enable=!0),t.Rn||(t.Rn={});const a=t.Rn;if(o.enable){const i=o.lut;if(!a.lutTexture||a.lutTexture.url!==i){const e=new Image;e.onload=function(){const s={data:e,min:"linear",mag:"linear"},n=a.lutTexture?a.lutTexture.texture(s):Is$3.texture(s);a.lutTexture={url:i,texture:n},t.setLayerCanvasUpdated()},e.src=i}}const l={enableGrain:+!!r.enable,grainFactor:void 0===r.factor?.15:r.factor,timeGrain:performance.now(),enableVignette:+!!h.enable,lensRadius:h.lensRadius||[.8,.25],frameMod:1,enableLut:+!!o.enable,lookupTable:a.lutTexture?a.lutTexture.texture:Ls$3};Fs$3||(Fs$3=new vi$3(Is$3)),Fs$3.postprocess(null,l,Es$3({width:Os$3.width,height:Os$3.height,data:i,flipY:!0,mag:"linear",min:"linear",mipmap:!1})),r.enable&&t.setLayerCanvasUpdated(),t.context.drawImage(Os$3,0,0,Os$3.width,Os$3.height)}t$1.renderer.MapCanvasRenderer.prototype.renderFrame=function(){const t=Hs$2.apply(this,arguments),i=this.map.getPostProcessConfig(),e=i&&i.filmicGrain;return!e||void 0!==e.enable&&!0!==e.enable||this.setLayerCanvasUpdated(),t};const Gs$3=[];function js$2(t){t.properties.showOnlyTimestamp&&(delete t.properties.showOnlyTimestamp,Us$3(t))}function Bs$3(t,i){const e=t.geometry.properties;e.oldElementsBeforeHighlight||(e.oldElementsBeforeHighlight=t.geometry.elements),e.elements&&(e.oldElementsArrBeforeHighlight||(e.oldElementsArrBeforeHighlight=e.elements),e.elements=i)}function Us$3(t){const i=t.geometry.properties.oldElementsBeforeHighlight;i&&t.geometry.elements!==i&&(t.geometry.deleteElements(),t.geometry.setElements(t.geometry.properties.oldElementsBeforeHighlight),t.geometry.properties.oldElementsArrBeforeHighlight&&(t.geometry.properties.elements=t.geometry.properties.oldElementsArrBeforeHighlight,delete t.geometry.properties.oldElementsArrBeforeHighlight),delete t.geometry.properties.hasInvisible,delete t.geometry.properties.oldElementsBeforeHighlight)}function zs$3(t){if(!t.properties.highlightTimestamp)return;const i=t.defines;delete i.HAS_HIGHLIGHT_COLOR,delete i.HAS_HIGHLIGHT_OPACITY,t.setDefines(i),delete t.properties.highlightTimestamp,Us$3(t),Vs$3(t)}function Vs$3(t){if(!t)return;const{hlBloomMesh:i}=t.properties;if(i){const e=i.geometry;e.elements&&e.elements.destroy&&e.deleteElements(),i.dispose(),delete t.properties.hlBloomMesh}}var Ws$3=Object.freeze({__proto__:null,clearShowOnly:js$2,showOnly:function(t,i,e,s,n){const{showOnlyTimestamp:r}=i.properties;if(!e)return void(r&&js$2(i));if(s===r)return;i.properties.showOnlyTimestamp=s;const h=e.keys(),o=[];for(const t of h){if(!n.has(t))continue;const i=n.get(t);i&&pt$5(o,i)}Bs$3(i,o),i.geometry.elements!==i.geometry.properties.oldElementsBeforeHighlight&&i.geometry.elements.destroy&&i.geometry.deleteElements();const a={data:o,primitive:i.geometry.getPrimitive()};i.geometry.setElements(t.elements(a)),i.geometry.generateBuffers(t)},clearHighlight:zs$3,highlightMesh:function(t,i,e,s,n){const{highlightTimestamp:r}=i.properties;if(!e)return void(r&&zs$3(i));if(s===r)return;const h=i.geometry.getVertexCount();let{aHighlightColor:o,aHighlightOpacity:l}=i.geometry.properties;o&&o.fill(0),l&&l.fill(255);let c=!1,u=!1;const f=e.keys();let p=null,m=null;for(const t of f)if(n.has(t)){const i=e.get(t),{color:s,bloom:r,visible:a}=i;let f,{opacity:g}=i;if(s&&(c||(o||(o=new Uint8Array(4*h)),c=!0),f=vt$5(Gs$3,s)),g=lt$5(g)?1:g,g<1&&(u||(l||(l=new Uint8Array(h),l.fill(255)),u=!0)),!1===a&&(m||(m=new Set),m.add(t)),f||g<1||r){const i=n.get(t);if(i)for(let t=0;t<i.length;t++){const e=i[t];f&&set$3(o.subarray(4*e,4*e+4),...f),g<1&&(l[e]=255*g),r&&(p||(p=[]),p.push(e))}}}const v=i.defines;if(c?(i.geometry.data.aHighlightColor?i.geometry.updateData("aHighlightColor",o):(i.geometry.data.aHighlightColor=o,i.geometry.generateBuffers(t)),i.geometry.properties.aHighlightColor=o,v.HAS_HIGHLIGHT_COLOR=1):v.HAS_HIGHLIGHT_COLOR&&(i.geometry.updateData("aHighlightColor",o),delete v.HAS_HIGHLIGHT_COLOR),u?(i.geometry.data.aHighlightOpacity?i.geometry.updateData("aHighlightOpacity",l):(i.geometry.data.aHighlightOpacity=l,i.geometry.generateBuffers(t)),i.geometry.properties.aHighlightOpacity=l,v.HAS_HIGHLIGHT_OPACITY=1):v.HAS_HIGHLIGHT_OPACITY&&(i.geometry.updateData("aHighlightOpacity",l),delete v.HAS_HIGHLIGHT_OPACITY),m&&m.size>0){let e=[];n.forEach(((t,i)=>{m.has(i)||pt$5(e,t)})),i.geometry.properties.hasInvisible=!0,Bs$3(i,e);const s={data:e,primitive:i.geometry.getPrimitive()};i.geometry.elements!==i.geometry.properties.oldElementsBeforeHighlight&&i.geometry.elements.destroy&&i.geometry.deleteElements(),e=t.elements(s),i.geometry.setElements(e),i.geometry.generateBuffers(t)}else i.geometry.properties.hasInvisible&&Us$3(i);i.setDefines(v),i.properties.highlightTimestamp=s;let w=i.properties.hlBloomMesh;if(p&&p.length){if(w){const t=copy$5(w.localTransform,i.localTransform),e=copy$5(w.positionMatrix,i.positionMatrix);w.setLocalTransform(t),w.setPositionMatrix(e),i.properties.hlBloomMesh.geometry.setElements(p)}else{const e=new Q$7(i.geometry.data,p,0,i.geometry.desc);e.generateBuffers(t);w=new Be$5(e,i.material,i.config);const n=i.uniforms;for(const t in n)Object.defineProperty(w.uniforms,t,{enumerable:!0,get:function(){return i.getUniform(t)}});const r=at$5({},i.defines);r.HAS_BLOOM=1;const h=copy$5([],i.localTransform),o=copy$5([],i.positionMatrix);w.setLocalTransform(h),w.setPositionMatrix(o),at$5(w.properties,i.properties),at$5(e.properties,i.geometry.properties),w.setDefines(r),w.bloom=1}i.properties.hlBloomMesh=w}else w&&Vs$3(i)},deleteHighlightBloomMesh:Vs$3});const qs$2=[0,0,0,0];class $s$2{constructor(t,i,e,s,n,r){this.renderer=new B$6(t),this.sceneConfig=i,this.s=e,this.Pn=s,this.Dn=n,this.ln=r||{factor:0,units:0},this.h(),this.Hn=[]}render(t,i,e){this.Nn();const s=this.s.getMap();this.renderer.regl.clear({color:qs$2,depth:1,stencil:255,framebuffer:this.Gn}),this.renderer.render(this.jn,i,t,this.Gn);const n=this.s.getRenderer().canvas;this.Hn[0]=n.width,this.Hn[1]=n.height;const r=at$5({colorRamp:this.Bn,inputTexture:this.Gn,projViewMatrix:s.projViewMatrix,textureOutputSize:this.Hn},i);return this.m(),this.renderer.render(this.Un,r,this.D,e)}dispose(){this.jn&&(this.jn.dispose(),delete this.jn),this.Un&&(this.Un.dispose(),delete this.Un),this.S&&(this.S.geometry.dispose(),this.S.dispose(),delete this.S,delete this.D),this.Gn&&(this.Gn.destroy(),delete this.Gn)}zn(){const t=this.Pn;let i=this.Vn,e=this.Wn;e?e.clearRect(0,0,256,1):(i=this.Vn=document.createElement("canvas"),i.width=256,i.height=1,e=this.Wn=i.getContext("2d"));const s=e.createLinearGradient(0,0,256,1);for(let i=0;i<t.length;i++)s.addColorStop(t[i][0],t[i][1]);e.fillStyle=s,e.fillRect(0,0,256,1),this.Bn&&this.Bn.destroy();this.Bn=this.renderer.regl.texture({width:256,height:1,data:i,min:"linear",mag:"linear",premultiplyAlpha:!0})}Nn(){const t=this.s.getRenderer().canvas,i=Math.ceil(t.width/4),e=Math.ceil(t.height/4),s=this.Gn;s.width===i&&s.height===e||s.resize(i,e)}h(){this.zn(),this.qn(),this.$n(),this.p()}p(){const t=new tn$5;t.generateBuffers(this.renderer.regl),this.S=new Be$5(t),this.D=new Ke$5([this.S])}m(){const t=this.s.getMap(),i=jt$4.getGroundTransform(this.S.localTransform,t);this.S.setLocalTransform(i)}$n(){const t=this.s.getRenderer().canvas,i=this.renderer.regl,e=i.hasExtension("OES_texture_half_float")?"half float":"float",s=Math.ceil(t.width/4),n=Math.ceil(t.height/4),r=i.texture({width:s,height:n,type:e,min:"linear",mag:"linear",format:"rgba"});this.Gn=i.framebuffer({width:s,height:n,color:[r]})}qn(){const t=this.s.getRenderer().canvas,i=this.sceneConfig.depthRange,e={viewport:{x:0,y:0,width:()=>t?Math.ceil(t.width/4):1,height:()=>t?Math.ceil(t.height/4):1},depth:{enable:!0,func:"always"}};this.Dn&&(e.stencil=this.Dn),this.jn=new Xn$4({extraCommandProps:e}),this.Un=new Yn$4({x:0,y:0,width:()=>t?t.width:1,height:()=>t?t.height:1},{extraCommandProps:{stencil:{enable:!1},depth:{enable:!0,range:i||[0,1],func:"<="},polygonOffset:{enable:!0,offset:this.ln},scissor:{enable:!1}}})}}class Ys$3 extends rs$4{constructor(t,i){super(t,i)}ze(t){const i=this.js(t),e=new Be$5(i);return this.Yn(e),this.qs(e),e}Gs(t,i,e){const s=this.zs();t.setUniform("maskMode",s);const n=this.Vs();if(t.setUniform("maskColor",n),ct$5(i)){const s=this.Ks();s[0]=(s[0]-e)*i,s[1]=(s[1]-e)*i,t.setUniform("heightRange",s)}}setHeightRange(t){this.options.heightRange=t,this._fireEvent("heightrangechange")}getHeightRange(){return this.options.heightRange}Ks(){const t=[0,0];return this.options.heightRange&&(t[0]=this.Ws(this.options.heightRange[0]),t[1]=this.Ws(this.options.heightRange[1])),t}Yn(t){const i=t.getDefines();i.HAS_MASK_COLOR=1,t.setDefines(i)}}class Xs$3 extends Ys$3{constructor(t,i){super(t,i),this.Hs="clip-inside"}}class Js$3 extends Ys$3{constructor(t,i){super(t,i),this.Hs="clip-outside"}}class Zs$3 extends rs$4{constructor(t,i){super(t,i)}setFlatheight(t){this.options.flatHeight=t,this._fireEvent("flatheightchange")}ze(t){const i=this.js(t),e=new Be$5(i);return this.Yn(e),this.qs(e),e}Gs(t){const i=this.zs();t.setUniform("maskMode",i);const e=this.Vs();t.setUniform("maskColor",e);const s=this.Ws(this.options.flatHeight||0);t.setUniform("flatHeight",s)}Yn(t){const i=t.getDefines();i.HAS_MASK_FLAT=1,t.setDefines(i)}Ks(){const t=[0,this.options.flatHeight];return t[1]=this.Ws(t[1]),t}}class Ks$3 extends Zs$3{constructor(t,i){super(t,i),this.Hs="flat-inside"}}class Qs$3 extends Zs$3{constructor(t,i){super(t,i),this.Hs="flat-outside"}}class tn$4 extends rs$4{constructor(t,i){super(t,i),this.Hs="color"}setHeightRange(t){this.options.heightRange=t,this._fireEvent("heightrangechange")}ze(t){const i=this.js(t),e=new Be$5(i);return this.Yn(e),this.qs(e),e}Gs(t,i,e){const s=this.zs();t.setUniform("maskMode",s);const n=this.Vs();if(t.setUniform("maskColor",n),ct$5(i)){const s=this.Ks();s[0]=(s[0]-e)*i,s[1]=(s[1]-e)*i,t.setUniform("heightRange",s)}}Yn(t){const i=t.getDefines();i.HAS_MASK_COLOR=1,t.setDefines(i)}Ks(){const t=[0,0];return this.options.heightRange&&(t[0]=this.Ws(this.options.heightRange[0]),t[1]=this.Ws(this.options.heightRange[1])),t}}class en$4 extends rs$4{constructor(t,i){super(t,i),this.Hs="video"}play(){this.Xn&&this.Xn.play()}pause(){this.Xn&&this.Xn.pause()}setAudio(t){this.Xn&&(this.video.muted=t)}setUrl(t){this.options.url=t,this.Jn(t)}getState(){return this.Zn}ze(t){const i=this.js(t),e=new Be$5(i),s=this.Kn(t);return e.material=new Ce$5({maskTexture:s}),this.Yn(e),this.qs(e),e}Gs(t){const i=this.zs();t.setUniform("maskMode",i);const e=this.Vs();t.setUniform("maskColor",e)}Yn(t){const i=t.getDefines();i.HAS_VIDEO=1,t.setDefines(i)}Kn(t){return this.Jn(),t.texture()}Jn(){this.Zn="stop";const t=this.options.url;let e=document.getElementById(this.options.elementId);if(t&&(e=document.createElement("video"),e.src=t),!e)throw new Error("there is no element or url setting for video mask");e.autoplay=this.options.autoplay||!0,e.loop=this.options.loop||!0,e.muted=this.options.muted||!0,e.play(),e.addEventListener("playing",(()=>{this.Zn="playing"})),e.addEventListener("pause",(()=>{this.Zn="pause"})),this.Xn=e}je(){const t=this._t;if(t&&t.material){const i=t.material.get("maskTexture");i&&this.Xn&&this.Be()&&i(this.Xn)}}Be(){return"playing"===this.Zn}}class sn$4 extends Zs$3{constructor(t,i){super(t,i),this.setElevation(i.elevation),this.Hs="elevate"}setElevation(t){this.options.elevation=t,this.setFlatheight(this.options.elevation)}}const nn$4=new t$1.Point(0,0),rn$4=new t$1.Point(0,0),hn$4=new t$1.Point(0,0),on$4=new t$1.Point(0,0);class an$4 extends Ys$3{constructor(t,i){super([],i),this.Qn=t}setPosition(t){this.Qn=t,this.Xs()}getPosition(){return this.Qn}setWidth(t){this.options.width=t,this.Xs()}setLength(t){this.options.length=t,this.Xs()}setHeight(t){this.options.height=t,this.Xs()}setRotation(t){this.options.rotation=t,this.Xs()}Xs(){const t=this.getLayer();if(!t)return;const i=t.getMap();if(i){const{length:t,width:e,height:s}=this.options,n=this.Qn,r=this.options.rotation||0,{coordinates:h,heightRange:o}=this.tr(i,n,t,e,s,r);this.setCoordinates(h),this.setHeightRange(o)}}tr(t,i,e,s,n,r){const h=t.getGLRes(),o=t.distanceToPointAtRes(s/2,0,h,nn$4),a=t.distanceToPointAtRes(0,e/2,h,rn$4),l=t.coordinateToPointAtRes(i,h,hn$4),c=l.x-o.x,u=l.x+o.x,f=l.y+a.y,d=l.y-a.y,p=this.ir([[c,f],[u,f],[u,d],[c,d]],l,r);on$4.set(p[0][0],p[0][1]);const g=t.pointAtResToCoordinate(on$4,h);on$4.set(p[1][0],p[1][1]);const m=t.pointAtResToCoordinate(on$4,h);on$4.set(p[2][0],p[2][1]);const v=t.pointAtResToCoordinate(on$4,h);on$4.set(p[3][0],p[3][1]);const w=t.pointAtResToCoordinate(on$4,h),x=i.z-n/2;return{coordinates:[[g.x,g.y,x],[m.x,m.y,x],[v.x,v.y,x],[w.x,w.y,x],[g.x,g.y,x]],heightRange:[x,i.z+n/2]}}ir(t,i,e){for(let s=0;s<t.length;s++)rotate(t[s],t[s],[i.x,i.y],e*Math.PI/180);return t}}class ln$4 extends an$4{constructor(t,i){super(t,i),this.Hs="clip-inside"}}class cn$4 extends an$4{constructor(t,i){super(t,i),this.Hs="clip-outside"}}"undefined"!=typeof window&&window.maptalks&&(window.maptalks.GroupGLLayer=Cs$3,window.maptalks.ClipInsideMask=Xs$3,window.maptalks.ClipOutsideMask=Js$3,window.maptalks.FlatInsideMask=Ks$3,window.maptalks.FlatOutsideMask=Qs$3,window.maptalks.ElevateMask=sn$4,window.maptalks.ColorMask=tn$4,window.maptalks.VideoMask=en$4,window.maptalks.BoxInsideClipMask=ln$4,window.maptalks.BoxOutsideClipMask=cn$4);const getGlobal=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},globals=getGlobal(),transcoders=globals.gl_trans__coders=globals.gl_trans__coders||{};transcoders.inject=function(chunk){const fnString=chunk.toString(),prefixIndex=fnString.indexOf("{")+1,prefix=fnString.substring(0,prefixIndex),transcoders=globals.gl_trans__coders=globals.gl_trans__coders||{};let injected=`${prefix}\n    const _____getGlobal = ${getGlobal.toString()};\n    const g___lobals = _____getGlobal()\n    const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const p in transcoders)"inject"!==p&&"getTranscoder"!==p&&"registerTranscoder"!==p&&(injected+='tran_____scoders["'+p+'"] ='+transcoders[p].toString()+"\n;");return injected+="\n"+fnString.substring(prefix.length),injected},transcoders.registerTranscoder=function(name,fn){transcoders[name]=fn},transcoders.getTranscoder=function(name){return transcoders[name]};let canvas;t__namespace.registerWorkerAdapter("@maptalks/terrain",'function(t){var r="undefined"!=typeof Float32Array?Float32Array:Array;function e(){var t=new r(3);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function i(t,e,i){var n=new r(3);return n[0]=t,n[1]=e,n[2]=i,n}function n(t,r){var e=r[0],i=r[1],n=r[2],s=e*e+i*i+n*n;return s>0&&(s=1/Math.sqrt(s),t[0]=r[0]*s,t[1]=r[1]*s,t[2]=r[2]*s),t}function s(t,r,e){var i=r[0],n=r[1],s=r[2],a=e[0],o=e[1],h=e[2];return t[0]=n*h-s*o,t[1]=s*a-i*h,t[2]=i*o-n*a,t}var a=function(t,r,e){return t[0]=r[0]-e[0],t[1]=r[1]-e[1],t[2]=r[2]-e[2],t};function o(){var t=new r(4);return r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}e(),function(){var t,e=(t=new r(4),r!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var h;function c(t,r,e){return t[0]=r,t[1]=e,t}e(),i(1,0,0),i(0,1,0),o(),o(),h=new r(9),r!=Float32Array&&(h[1]=0,h[2]=0,h[3]=0,h[5]=0,h[6]=0,h[7]=0),h[0]=1,h[4]=1,h[8]=1,function(){var t=function(){var t=new r(2);return r!=Float32Array&&(t[0]=0,t[1]=0),t}()}();\n/*!\n   * @maptalks/gltf-loader v0.95.2\n   * LICENSE : UNLICENSED\n   * (c) 2016-2024 maptalks.org\n   */\nlet f=0;!function(t){t[0]=0,t[1]=0,t[2]=0,t[3]=1}([]),"undefined"!=typeof TextDecoder&&new TextDecoder("utf-8");const u={get:function(t,r={}){r||(r={});const e=new AbortController,i=e.signal,n=function(t){for(let r=1;r<arguments.length;r++){const e=arguments[r];for(const r in e)t[r]=e[r]}return t}({},r);n.signal=i,n.method||(n.method="GET");const s=fetch(t,n).then(t=>{const e=this.U(t,r.responseType);return e.message?e:e.then(e=>"arraybuffer"===r.responseType?{data:e,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:e).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return s.xhr=e,s},U:(t,r)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===r?t.arrayBuffer():"json"===r?t.json():t.text(),getArrayBuffer:(t,r={})=>(r||(r={}),r.responseType="arraybuffer",u.get(t,r)),getJSON:function(t,r={}){return r&&r.jsonp?u.jsonp(t):((r=r||{}).responseType="json",u.get(t,r))},jsonp:function(t){const r="_maptalks_jsonp_"+f++;t.match(/\\?/)?t+="&callback="+r:t+="?callback="+r;let e=document.createElement("script");return e.type="text/javascript",e.src=t,new Promise(t=>{window[r]=function(i){document.getElementsByTagName("head")[0].removeChild(e),e=null,delete window[r],t(i)},document.getElementsByTagName("head")[0].appendChild(e)})}};if("undefined"!=typeof TextDecoder&&new TextDecoder("utf-8"),"undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(t){}}"undefined"!=typeof document&&document.createElement("canvas"),function(){function t(t){throw t}var r=void 0,e=!0,i=this;function n(t,e){var n,s=t.split("."),a=i;!(s[0]in a)&&a.execScript&&a.execScript("var "+s[0]);for(;s.length&&(n=s.shift());)s.length||e===r?a=a[n]?a[n]:a[n]={}:a[n]=e}var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function a(r,e){this.index="number"==typeof e?e:0,this.i=0,this.buffer=r instanceof(s?Uint8Array:Array)?r:new(s?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,r=this.buffer,e=r.length,i=new(s?Uint8Array:Array)(e<<1);if(s)i.set(r);else for(t=0;t<e;++t)i[t]=r[t];return this.buffer=i},a.prototype.d=function(t,r,e){var i,n=this.buffer,s=this.index,a=this.i,o=n[s];if(e&&1<r&&(t=8<r?(l[255&t]<<24|l[t>>>8&255]<<16|l[t>>>16&255]<<8|l[t>>>24&255])>>32-r:l[t]>>8-r),8>r+a)o=o<<r|t,a+=r;else for(i=0;i<r;++i)o=o<<1|t>>r-i-1&1,8==++a&&(a=0,n[s++]=l[o],o=0,s===n.length&&(n=this.f()));n[s]=o,this.buffer=n,this.i=a,this.index=s},a.prototype.finish=function(){var t,r=this.buffer,e=this.index;return 0<this.i&&(r[e]<<=8-this.i,r[e]=l[r[e]],e++),s?t=r.subarray(0,e):(r.length=e,t=r),t};var o,h=new(s?Uint8Array:Array)(256);for(o=0;256>o;++o){for(var c=u=o,f=7,u=u>>>1;u;u>>>=1)c<<=1,c|=1&u,--f;h[o]=(c<<f&255)>>>0}var l=h;function y(t){this.buffer=new(s?Uint16Array:Array)(2*t),this.length=0}function d(t){var r,e,i,n,a,o,h,c,f,u,l=t.length,y=0,d=Number.POSITIVE_INFINITY;for(c=0;c<l;++c)t[c]>y&&(y=t[c]),t[c]<d&&(d=t[c]);for(r=1<<y,e=new(s?Uint32Array:Array)(r),i=1,n=0,a=2;i<=y;){for(c=0;c<l;++c)if(t[c]===i){for(o=0,h=n,f=0;f<i;++f)o=o<<1|1&h,h>>=1;for(u=i<<16|c,f=o;f<r;f+=a)e[f]=u;++n}++i,n<<=1,a<<=1}return[e,y,d]}function A(t,r){this.h=b,this.w=0,this.input=s&&t instanceof Array?new Uint8Array(t):t,this.b=0,r&&(r.lazy&&(this.w=r.lazy),"number"==typeof r.compressionType&&(this.h=r.compressionType),r.outputBuffer&&(this.a=s&&r.outputBuffer instanceof Array?new Uint8Array(r.outputBuffer):r.outputBuffer),"number"==typeof r.outputIndex&&(this.b=r.outputIndex)),this.a||(this.a=new(s?Uint8Array:Array)(32768))}y.prototype.getParent=function(t){return 2*((t-2)/4|0)},y.prototype.push=function(t,r){var e,i,n,s=this.buffer;for(e=this.length,s[this.length++]=r,s[this.length++]=t;0<e&&(i=this.getParent(e),s[e]>s[i]);)n=s[e],s[e]=s[i],s[i]=n,n=s[e+1],s[e+1]=s[i+1],s[i+1]=n,e=i;return this.length},y.prototype.pop=function(){var t,r,e,i,n,s=this.buffer;for(r=s[0],t=s[1],this.length-=2,s[0]=s[this.length],s[1]=s[this.length+1],n=0;!((i=2*n+2)>=this.length)&&(i+2<this.length&&s[i+2]>s[i]&&(i+=2),s[i]>s[n]);)e=s[n],s[n]=s[i],s[i]=e,e=s[n+1],s[n+1]=s[i+1],s[i+1]=e,n=i;return{index:t,value:r,length:this.length}};var w,b=2,p={NONE:0,r:1,k:b,N:3},v=[];for(w=0;288>w;w++)switch(!0){case 143>=w:v.push([w+48,8]);break;case 255>=w:v.push([w-144+400,9]);break;case 279>=w:v.push([w-256+0,7]);break;case 287>=w:v.push([w-280+192,8]);break;default:t("invalid literal: "+w)}function k(t,r){this.length=t,this.G=r}A.prototype.j=function(){var i,n,o,h,c=this.input;switch(this.h){case 0:for(o=0,h=c.length;o<h;){var f,u,l,y=n=s?c.subarray(o,o+65535):c.slice(o,o+65535),d=(o+=n.length)===h,A=r,w=r,p=this.a,k=this.b;if(s){for(p=new Uint8Array(this.a.buffer);p.length<=k+y.length+5;)p=new Uint8Array(p.length<<1);p.set(this.a)}if(f=d?1:0,p[k++]=0|f,l=65536+~(u=y.length)&65535,p[k++]=255&u,p[k++]=u>>>8&255,p[k++]=255&l,p[k++]=l>>>8&255,s)p.set(y,k),k+=y.length,p=p.subarray(0,k);else{for(A=0,w=y.length;A<w;++A)p[k++]=y[A];p.length=k}this.b=k,this.a=p}break;case 1:var m=new a(s?new Uint8Array(this.a.buffer):this.a,this.b);m.d(1,1,e),m.d(1,2,e);var U,x,M,S=g(this,c);for(U=0,x=S.length;U<x;U++)if(M=S[U],a.prototype.d.apply(m,v[M]),256<M)m.d(S[++U],S[++U],e),m.d(S[++U],5),m.d(S[++U],S[++U],e);else if(256===M)break;this.a=m.finish(),this.b=this.a.length;break;case b:var I,F,D,z,C,N,O,j,q,W,Z,V,$,_,B,H=new a(s?new Uint8Array(this.a.buffer):this.a,this.b),L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],P=Array(19);for(I=b,H.d(1,1,e),H.d(I,2,e),F=g(this,c),O=T(N=E(this.L,15)),q=T(j=E(this.K,7)),D=286;257<D&&0===N[D-1];D--);for(z=30;1<z&&0===j[z-1];z--);var G,R,Y,J,K,X,Q=D,tt=z,rt=new(s?Uint32Array:Array)(Q+tt),et=new(s?Uint32Array:Array)(316),it=new(s?Uint8Array:Array)(19);for(G=R=0;G<Q;G++)rt[R++]=N[G];for(G=0;G<tt;G++)rt[R++]=j[G];if(!s)for(G=0,J=it.length;G<J;++G)it[G]=0;for(G=K=0,J=rt.length;G<J;G+=R){for(R=1;G+R<J&&rt[G+R]===rt[G];++R);if(Y=R,0===rt[G])if(3>Y)for(;0<Y--;)et[K++]=0,it[0]++;else for(;0<Y;)(X=138>Y?Y:138)>Y-3&&X<Y&&(X=Y-3),10>=X?(et[K++]=17,et[K++]=X-3,it[17]++):(et[K++]=18,et[K++]=X-11,it[18]++),Y-=X;else if(et[K++]=rt[G],it[rt[G]]++,3>--Y)for(;0<Y--;)et[K++]=rt[G],it[rt[G]]++;else for(;0<Y;)(X=6>Y?Y:6)>Y-3&&X<Y&&(X=Y-3),et[K++]=16,et[K++]=X-3,it[16]++,Y-=X}for(i=s?et.subarray(0,K):et.slice(0,K),W=E(it,7),_=0;19>_;_++)P[_]=W[L[_]];for(C=19;4<C&&0===P[C-1];C--);for(Z=T(W),H.d(D-257,5,e),H.d(z-1,5,e),H.d(C-4,4,e),_=0;_<C;_++)H.d(P[_],3,e);for(_=0,B=i.length;_<B;_++)if(V=i[_],H.d(Z[V],W[V],e),16<=V){switch(_++,V){case 16:$=2;break;case 17:$=3;break;case 18:$=7;break;default:t("invalid code: "+V)}H.d(i[_],$,e)}var nt,st,at,ot,ht,ct,ft,ut,lt=[O,N],yt=[q,j];for(ht=lt[0],ct=lt[1],ft=yt[0],ut=yt[1],nt=0,st=F.length;nt<st;++nt)if(at=F[nt],H.d(ht[at],ct[at],e),256<at)H.d(F[++nt],F[++nt],e),ot=F[++nt],H.d(ft[ot],ut[ot],e),H.d(F[++nt],F[++nt],e);else if(256===at)break;this.a=H.finish(),this.b=this.a.length;break;default:t("invalid compression type")}return this.a};var m=function(){function r(r){switch(!0){case 3===r:return[257,r-3,0];case 4===r:return[258,r-4,0];case 5===r:return[259,r-5,0];case 6===r:return[260,r-6,0];case 7===r:return[261,r-7,0];case 8===r:return[262,r-8,0];case 9===r:return[263,r-9,0];case 10===r:return[264,r-10,0];case 12>=r:return[265,r-11,1];case 14>=r:return[266,r-13,1];case 16>=r:return[267,r-15,1];case 18>=r:return[268,r-17,1];case 22>=r:return[269,r-19,2];case 26>=r:return[270,r-23,2];case 30>=r:return[271,r-27,2];case 34>=r:return[272,r-31,2];case 42>=r:return[273,r-35,3];case 50>=r:return[274,r-43,3];case 58>=r:return[275,r-51,3];case 66>=r:return[276,r-59,3];case 82>=r:return[277,r-67,4];case 98>=r:return[278,r-83,4];case 114>=r:return[279,r-99,4];case 130>=r:return[280,r-115,4];case 162>=r:return[281,r-131,5];case 194>=r:return[282,r-163,5];case 226>=r:return[283,r-195,5];case 257>=r:return[284,r-227,5];case 258===r:return[285,r-258,0];default:t("invalid length: "+r)}}var e,i,n=[];for(e=3;258>=e;e++)i=r(e),n[e]=i[2]<<24|i[1]<<16|i[0];return n}(),U=s?new Uint32Array(m):m;function g(e,i){function n(r,e){var i,n,s,a,o=r.G,h=[],c=0;switch(i=U[r.length],h[c++]=65535&i,h[c++]=i>>16&255,h[c++]=i>>24,!0){case 1===o:n=[0,o-1,0];break;case 2===o:n=[1,o-2,0];break;case 3===o:n=[2,o-3,0];break;case 4===o:n=[3,o-4,0];break;case 6>=o:n=[4,o-5,1];break;case 8>=o:n=[5,o-7,1];break;case 12>=o:n=[6,o-9,2];break;case 16>=o:n=[7,o-13,2];break;case 24>=o:n=[8,o-17,3];break;case 32>=o:n=[9,o-25,3];break;case 48>=o:n=[10,o-33,4];break;case 64>=o:n=[11,o-49,4];break;case 96>=o:n=[12,o-65,5];break;case 128>=o:n=[13,o-97,5];break;case 192>=o:n=[14,o-129,6];break;case 256>=o:n=[15,o-193,6];break;case 384>=o:n=[16,o-257,7];break;case 512>=o:n=[17,o-385,7];break;case 768>=o:n=[18,o-513,8];break;case 1024>=o:n=[19,o-769,8];break;case 1536>=o:n=[20,o-1025,9];break;case 2048>=o:n=[21,o-1537,9];break;case 3072>=o:n=[22,o-2049,10];break;case 4096>=o:n=[23,o-3073,10];break;case 6144>=o:n=[24,o-4097,11];break;case 8192>=o:n=[25,o-6145,11];break;case 12288>=o:n=[26,o-8193,12];break;case 16384>=o:n=[27,o-12289,12];break;case 24576>=o:n=[28,o-16385,13];break;case 32768>=o:n=[29,o-24577,13];break;default:t("invalid distance")}for(i=n,h[c++]=i[0],h[c++]=i[1],h[c++]=i[2],s=0,a=h.length;s<a;++s)w[b++]=h[s];v[h[0]]++,k[h[3]]++,p=r.length+e-1,y=null}var a,o,h,c,f,u,l,y,d,A={},w=s?new Uint16Array(2*i.length):[],b=0,p=0,v=new(s?Uint32Array:Array)(286),k=new(s?Uint32Array:Array)(30),m=e.w;if(!s){for(h=0;285>=h;)v[h++]=0;for(h=0;29>=h;)k[h++]=0}for(v[256]=1,a=0,o=i.length;a<o;++a){for(h=f=0,c=3;h<c&&a+h!==o;++h)f=f<<8|i[a+h];if(A[f]===r&&(A[f]=[]),u=A[f],!(0<p--)){for(;0<u.length&&32768<a-u[0];)u.shift();if(a+3>=o){for(y&&n(y,-1),h=0,c=o-a;h<c;++h)d=i[a+h],w[b++]=d,++v[d];break}0<u.length?(l=x(i,a,u),y?y.length<l.length?(d=i[a-1],w[b++]=d,++v[d],n(l,0)):n(y,-1):l.length<m?y=l:n(l,0)):y?n(y,-1):(d=i[a],w[b++]=d,++v[d])}u.push(a)}return w[b++]=256,v[256]++,e.L=v,e.K=k,s?w.subarray(0,b):w}function x(t,r,e){var i,n,s,a,o,h,c=0,f=t.length;a=0,h=e.length;t:for(;a<h;a++){if(i=e[h-a-1],s=3,3<c){for(o=c;3<o;o--)if(t[i+o-1]!==t[r+o-1])continue t;s=c}for(;258>s&&r+s<f&&t[i+s]===t[r+s];)++s;if(s>c&&(n=i,c=s),258===s)break}return new k(c,r-n)}function E(t,r){var e,i,n,a,o,h=t.length,c=new y(572),f=new(s?Uint8Array:Array)(h);if(!s)for(a=0;a<h;a++)f[a]=0;for(a=0;a<h;++a)0<t[a]&&c.push(a,t[a]);if(e=Array(c.length/2),i=new(s?Uint32Array:Array)(c.length/2),1===e.length)return f[c.pop().index]=1,f;for(a=0,o=c.length/2;a<o;++a)e[a]=c.pop(),i[a]=e[a].value;for(n=function(t,r,e){function i(t){var e=d[t][A[t]];e===r?(i(t+1),i(t+1)):--l[e],++A[t]}var n,a,o,h,c,f=new(s?Uint16Array:Array)(e),u=new(s?Uint8Array:Array)(e),l=new(s?Uint8Array:Array)(r),y=Array(e),d=Array(e),A=Array(e),w=(1<<e)-r,b=1<<e-1;for(f[e-1]=r,a=0;a<e;++a)w<b?u[a]=0:(u[a]=1,w-=b),w<<=1,f[e-2-a]=(f[e-1-a]/2|0)+r;for(f[0]=u[0],y[0]=Array(f[0]),d[0]=Array(f[0]),a=1;a<e;++a)f[a]>2*f[a-1]+u[a]&&(f[a]=2*f[a-1]+u[a]),y[a]=Array(f[a]),d[a]=Array(f[a]);for(n=0;n<r;++n)l[n]=e;for(o=0;o<f[e-1];++o)y[e-1][o]=t[o],d[e-1][o]=o;for(n=0;n<e;++n)A[n]=0;for(1===u[e-1]&&(--l[0],++A[e-1]),a=e-2;0<=a;--a){for(h=n=0,c=A[a+1],o=0;o<f[a];o++)(h=y[a+1][c]+y[a+1][c+1])>t[n]?(y[a][o]=h,d[a][o]=r,c+=2):(y[a][o]=t[n],d[a][o]=n,++n);A[a]=0,1===u[a]&&i(a)}return l}(i,i.length,r),a=0,o=e.length;a<o;++a)f[e[a].index]=n[a];return f}function T(t){var r,e,i,n,a=new(s?Uint16Array:Array)(t.length),o=[],h=[],c=0;for(r=0,e=t.length;r<e;r++)o[t[r]]=1+(0|o[t[r]]);for(r=1,e=16;r<=e;r++)h[r]=c,c+=0|o[r],c<<=1;for(r=0,e=t.length;r<e;r++)for(c=h[t[r]],h[t[r]]+=1,i=a[r]=0,n=t[r];i<n;i++)a[r]=a[r]<<1|1&c,c>>>=1;return a}function M(r,e){switch(this.l=[],this.m=32768,this.e=this.g=this.c=this.q=0,this.input=s?new Uint8Array(r):r,this.s=!1,this.n=I,this.B=!1,!e&&(e={})||(e.index&&(this.c=e.index),e.bufferSize&&(this.m=e.bufferSize),e.bufferType&&(this.n=e.bufferType),e.resize&&(this.B=e.resize)),this.n){case S:this.b=32768,this.a=new(s?Uint8Array:Array)(32768+this.m+258);break;case I:this.b=0,this.a=new(s?Uint8Array:Array)(this.m),this.f=this.J,this.t=this.H,this.o=this.I;break;default:t(Error("invalid inflate mode"))}}var S=0,I=1,F={D:S,C:I};M.prototype.p=function(){for(;!this.s;){var i=Y(this,3);switch(1&i&&(this.s=e),i>>>=1){case 0:var n=this.input,a=this.c,o=this.a,h=this.b,c=n.length,f=r,u=o.length,l=r;switch(this.e=this.g=0,a+1>=c&&t(Error("invalid uncompressed block header: LEN")),f=n[a++]|n[a++]<<8,a+1>=c&&t(Error("invalid uncompressed block header: NLEN")),f===~(n[a++]|n[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+f>n.length&&t(Error("input buffer is broken")),this.n){case S:for(;h+f>o.length;){if(f-=l=u-h,s)o.set(n.subarray(a,a+l),h),h+=l,a+=l;else for(;l--;)o[h++]=n[a++];this.b=h,o=this.f(),h=this.b}break;case I:for(;h+f>o.length;)o=this.f({v:2});break;default:t(Error("invalid inflate mode"))}if(s)o.set(n.subarray(a,a+f),h),h+=f,a+=f;else for(;f--;)o[h++]=n[a++];this.c=a,this.b=h,this.a=o;break;case 1:this.o(P,R);break;case 2:var y,A,w,b,p=Y(this,5)+257,v=Y(this,5)+1,k=Y(this,4)+4,m=new(s?Uint8Array:Array)(N.length),U=r,g=r,x=r,E=r,T=r;for(T=0;T<k;++T)m[N[T]]=Y(this,3);if(!s)for(T=k,k=m.length;T<k;++T)m[N[T]]=0;for(y=d(m),U=new(s?Uint8Array:Array)(p+v),T=0,b=p+v;T<b;)switch(g=J(this,y),g){case 16:for(E=3+Y(this,2);E--;)U[T++]=x;break;case 17:for(E=3+Y(this,3);E--;)U[T++]=0;x=0;break;case 18:for(E=11+Y(this,7);E--;)U[T++]=0;x=0;break;default:x=U[T++]=g}A=d(s?U.subarray(0,p):U.slice(0,p)),w=d(s?U.subarray(p):U.slice(p)),this.o(A,w);break;default:t(Error("unknown BTYPE: "+i))}}return this.t()};var D,z,C=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],N=s?new Uint16Array(C):C,O=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,258,258],j=s?new Uint16Array(O):O,q=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0],W=s?new Uint8Array(q):q,Z=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],V=s?new Uint16Array(Z):Z,$=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],_=s?new Uint8Array($):$,B=new(s?Uint8Array:Array)(288);for(D=0,z=B.length;D<z;++D)B[D]=143>=D?8:255>=D?9:279>=D?7:8;var H,L,P=d(B),G=new(s?Uint8Array:Array)(30);for(H=0,L=G.length;H<L;++H)G[H]=5;var R=d(G);function Y(r,e){for(var i,n=r.g,s=r.e,a=r.input,o=r.c,h=a.length;s<e;)o>=h&&t(Error("input buffer is broken")),n|=a[o++]<<s,s+=8;return i=n&(1<<e)-1,r.g=n>>>e,r.e=s-e,r.c=o,i}function J(r,e){for(var i,n,s=r.g,a=r.e,o=r.input,h=r.c,c=o.length,f=e[0],u=e[1];a<u&&!(h>=c);)s|=o[h++]<<a,a+=8;return(n=(i=f[s&(1<<u)-1])>>>16)>a&&t(Error("invalid code length: "+n)),r.g=s>>n,r.e=a-n,r.c=h,65535&i}function K(t){if("string"==typeof t){var r,e,i=t.split("");for(r=0,e=i.length;r<e;r++)i[r]=(255&i[r].charCodeAt(0))>>>0;t=i}for(var n,s=1,a=0,o=t.length,h=0;0<o;){o-=n=1024<o?1024:o;do{a+=s+=t[h++]}while(--n);s%=65521,a%=65521}return(a<<16|s)>>>0}function X(r,e){var i,n;switch(this.input=r,this.c=0,!e&&(e={})||(e.index&&(this.c=e.index),e.verify&&(this.M=e.verify)),i=r[this.c++],n=r[this.c++],15&i){case Q:this.method=Q;break;default:t(Error("unsupported compression method"))}0!=((i<<8)+n)%31&&t(Error("invalid fcheck flag:"+((i<<8)+n)%31)),32&n&&t(Error("fdict flag is not supported")),this.A=new M(r,{index:this.c,bufferSize:e.bufferSize,bufferType:e.bufferType,resize:e.resize})}M.prototype.o=function(t,r){var e=this.a,i=this.b;this.u=t;for(var n,s,a,o,h=e.length-258;256!==(n=J(this,t));)if(256>n)i>=h&&(this.b=i,e=this.f(),i=this.b),e[i++]=n;else for(o=j[s=n-257],0<W[s]&&(o+=Y(this,W[s])),n=J(this,r),a=V[n],0<_[n]&&(a+=Y(this,_[n])),i>=h&&(this.b=i,e=this.f(),i=this.b);o--;)e[i]=e[i++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},M.prototype.I=function(t,r){var e=this.a,i=this.b;this.u=t;for(var n,s,a,o,h=e.length;256!==(n=J(this,t));)if(256>n)i>=h&&(h=(e=this.f()).length),e[i++]=n;else for(o=j[s=n-257],0<W[s]&&(o+=Y(this,W[s])),n=J(this,r),a=V[n],0<_[n]&&(a+=Y(this,_[n])),i+o>h&&(h=(e=this.f()).length);o--;)e[i]=e[i++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=i},M.prototype.f=function(){var t,r,e=new(s?Uint8Array:Array)(this.b-32768),i=this.b-32768,n=this.a;if(s)e.set(n.subarray(32768,e.length));else for(t=0,r=e.length;t<r;++t)e[t]=n[t+32768];if(this.l.push(e),this.q+=e.length,s)n.set(n.subarray(i,i+32768));else for(t=0;32768>t;++t)n[t]=n[i+t];return this.b=32768,n},M.prototype.J=function(t){var r,e,i,n=this.input.length/this.c+1|0,a=this.input,o=this.a;return t&&("number"==typeof t.v&&(n=t.v),"number"==typeof t.F&&(n+=t.F)),2>n?e=(i=(a.length-this.c)/this.u[2]/2*258|0)<o.length?o.length+i:o.length<<1:e=o.length*n,s?(r=new Uint8Array(e)).set(o):r=o,this.a=r},M.prototype.t=function(){var t,r,e,i,n,a=0,o=this.a,h=this.l,c=new(s?Uint8Array:Array)(this.q+(this.b-32768));if(0===h.length)return s?this.a.subarray(32768,this.b):this.a.slice(32768,this.b);for(r=0,e=h.length;r<e;++r)for(i=0,n=(t=h[r]).length;i<n;++i)c[a++]=t[i];for(r=32768,e=this.b;r<e;++r)c[a++]=o[r];return this.l=[],this.buffer=c},M.prototype.H=function(){var t,r=this.b;return s?this.B?(t=new Uint8Array(r)).set(this.a.subarray(0,r)):t=this.a.subarray(0,r):(this.a.length>r&&(this.a.length=r),t=this.a),this.buffer=t},X.prototype.p=function(){var r,e=this.input;return r=this.A.p(),this.c=this.A.c,this.M&&((e[this.c++]<<24|e[this.c++]<<16|e[this.c++]<<8|e[this.c++])>>>0!==K(r)&&t(Error("invalid adler-32 checksum"))),r};var Q=8;function tt(t,r){this.input=t,this.a=new(s?Uint8Array:Array)(32768),this.h=rt.k;var e,i={};for(e in!r&&(r={})||"number"!=typeof r.compressionType||(this.h=r.compressionType),r)i[e]=r[e];i.outputBuffer=this.a,this.z=new A(this.input,i)}var rt=p;function et(t,r){var e,i,s,a;if(Object.keys)e=Object.keys(r);else for(i in e=[],s=0,r)e[s++]=i;for(s=0,a=e.length;s<a;++s)n(t+"."+(i=e[s]),r[i])}tt.prototype.j=function(){var r,e,i,n,a,o,h,c=0;switch(h=this.a,r=Q){case Q:e=Math.LOG2E*Math.log(32768)-8;break;default:t(Error("invalid compression method"))}switch(i=e<<4|r,h[c++]=i,r){case Q:switch(this.h){case rt.NONE:a=0;break;case rt.r:a=1;break;case rt.k:a=2;break;default:t(Error("unsupported compression type"))}break;default:t(Error("invalid compression method"))}return n=a<<6|0,h[c++]=n|31-(256*i+n)%31,o=K(this.input),this.z.b=c,c=(h=this.z.j()).length,s&&((h=new Uint8Array(h.buffer)).length<=c+4&&(this.a=new Uint8Array(h.length+4),this.a.set(h),h=this.a),h=h.subarray(0,c+4)),h[c++]=o>>24&255,h[c++]=o>>16&255,h[c++]=o>>8&255,h[c++]=255&o,h},n("Zlib.Inflate",X),n("Zlib.Inflate.prototype.decompress",X.prototype.p),et("Zlib.Inflate.BufferType",{ADAPTIVE:F.C,BLOCK:F.D}),n("Zlib.Deflate",tt),n("Zlib.Deflate.compress",(function(t,r){return new tt(t,r).j()})),n("Zlib.Deflate.prototype.compress",tt.prototype.j),et("Zlib.Deflate.CompressionType",{NONE:rt.NONE,FIXED:rt.r,DYNAMIC:rt.k})}.call(self);class l{constructor(t=257){this.gridSize=t;const r=t-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let e=t+2,i=0,n=0,s=0,a=0,o=0,h=0;for(1&e?s=a=o=r:i=n=h=r;(e>>=1)>1;){const t=i+s>>1,r=n+a>>1;1&e?(s=i,a=n,i=o,n=h):(i=s,n=a,s=o,a=h),o=t,h=r}const c=4*t;this.coords[c+0]=i,this.coords[c+1]=n,this.coords[c+2]=s,this.coords[c+3]=a}}createTile(t){return new y(t,this)}}class y{constructor(t,r){const e=r.gridSize;if(t.length!==e*e)throw new Error(`Expected terrain data of length ${e*e} (${e} x ${e}), got ${t.length}.`);this.terrain=t,this.martini=r,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:r,coords:e,gridSize:i}=this.martini,{terrain:n,errors:s}=this;for(let a=t-1;a>=0;a--){const t=4*a,o=e[t+0],h=e[t+1],c=e[t+2],f=e[t+3],u=o+c>>1,l=h+f>>1,y=u+l-h,d=l+o-u,A=(n[h*i+o]+n[f*i+c])/2,w=l*i+u,b=Math.abs(A-n[w]);if(s[w]=Math.max(s[w],b),a<r){const t=(h+d>>1)*i+(o+y>>1),r=(f+d>>1)*i+(c+y>>1);s[w]=Math.max(s[w],s[t],s[r])}}}getMesh(t=0){const{gridSize:r,indices:e}=this.martini,{errors:i}=this;let n=0,s=0;const a=r-1;function o(a,h,c,f,u,l){const y=a+c>>1,d=h+f>>1;Math.abs(a-u)+Math.abs(h-l)>1&&i[d*r+y]>t?(o(u,l,a,h,y,d),o(c,f,u,l,y,d)):(e[h*r+a]=e[h*r+a]||++n,e[f*r+c]=e[f*r+c]||++n,e[l*r+u]=e[l*r+u]||++n,s++)}e.fill(0),o(0,0,a,a,a,0),o(a,a,0,0,0,a);const h=new Uint16Array(2*n),c=new Uint32Array(3*s);let f=0;function u(n,s,a,o,l,y){const d=n+a>>1,A=s+o>>1;if(Math.abs(n-l)+Math.abs(s-y)>1&&i[A*r+d]>t)u(l,y,n,s,d,A),u(a,o,l,y,d,A);else{const t=e[s*r+n]-1,i=e[o*r+a]-1,u=e[y*r+l]-1;h[2*t]=n,h[2*t+1]=s,h[2*i]=a,h[2*i+1]=o,h[2*u]=l,h[2*u+1]=y,c[f++]=t,c[f++]=i,c[f++]=u}}return u(0,0,a,a,a,0),u(a,a,0,0,0,a),{vertices:h,triangles:c}}getMeshWithSkirts(t=0,r){const{gridSize:e,indices:i}=this.martini,{errors:n}=this;let s=0,a=0;const o=e-1;let h,c,f=0;const u=[],l=[],y=[],d=[];function A(r,w,b,p,v,k){const m=r+b>>1,U=w+p>>1;Math.abs(r-v)+Math.abs(w-k)>1&&n[U*e+m]>t?(A(v,k,r,w,m,U),A(b,p,v,k,m,U)):(h=w*e+r,c=p*e+b,f=k*e+v,0===i[h]&&(0===r?u.push(s):r===o&&l.push(s),0===w?y.push(s):w===o&&d.push(s),i[h]=++s),0===i[c]&&(0===b?u.push(s):b===o&&l.push(s),0===p?y.push(s):p===o&&d.push(s),i[c]=++s),0===i[f]&&(0===v?u.push(s):v===o&&l.push(s),0===k?y.push(s):k===o&&d.push(s),i[f]=++s),a++)}let w;i.fill(0),A(0,0,o,o,o,0),A(o,o,0,0,0,o),w=r?2*(s+3*u.length-2+3*l.length-2+3*y.length-2+3*d.length-2):2*(s+u.length+l.length+y.length+d.length);const b=3*(a+2*(u.length-1)+2*(l.length-1)+2*(y.length-1)+2*(d.length-1)),p=new Uint16Array(w),v=new Uint32Array(b);let k=0;function m(r,s,a,o,h,c){const f=r+a>>1,u=s+o>>1;if(Math.abs(r-h)+Math.abs(s-c)>1&&n[u*e+f]>t)m(h,c,r,s,f,u),m(a,o,h,c,f,u);else{const t=i[s*e+r]-1,n=i[o*e+a]-1,f=i[c*e+h]-1;p[2*t]=r,p[2*t+1]=s,p[2*n]=a,p[2*n+1]=o,p[2*f]=h,p[2*f+1]=c,v[k++]=t,v[k++]=n,v[k++]=f}}m(0,0,o,o,o,0),m(o,o,0,0,0,o),u.sort((t,r)=>p[2*t+1]-p[2*r+1]),l.sort((t,r)=>p[2*r+1]-p[2*t+1]),y.sort((t,r)=>p[2*r]-p[2*t]),d.sort((t,r)=>p[2*t]-p[2*r]);let U,g,x,E,T=2*s,M=0;function S(t){M=t.length;for(let e=0;e<M-1;e++)U=t[e],g=t[e+1],x=T/2,E=(T+(r?6:2))/2,p[T++]=2*U,p[T++]=2*U+1,r&&(p[T++]=2*U,p[T++]=2*U+1,p[T++]=2*g,p[T++]=2*g+1),r?(v[k++]=x+1,v[k++]=x,v[k++]=x+2,v[k++]=x,v[k++]=E,v[k++]=x+2):(v[k++]=U,v[k++]=x,v[k++]=g,v[k++]=x,v[k++]=E,v[k++]=g);p[T++]=2*t[M-1],p[T++]=2*t[M-1]+1}S(u);const I=T;S(l);const F=T;S(y);const D=T;S(d);return{vertices:p,triangles:v,numVerticesWithoutSkirts:s,numTrianglesWithoutSkirts:a,leftSkirtIndex:I,rightSkirtIndex:F,bottomSkirtIndex:D,topSkirtIndex:T}}}const d={};let A,w=null,b=null;const p={},v=64,k=64,m=3,U=-1e3,g=.001,x=256,E=4,T=.002,M={cesium_request_token:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"},tianditu:{"Accept-Encoding":"gzip, deflate, br"},cesium:{"Accept-Encoding":"gzip, deflate, br",Accept:"application/vnd.quantized-mesh,application/octet-stream;q=0.9,*/*;q=0.01"},mapbox:{Accept:"image/webp,*/*"}};M["cesium-ion"]=M.cesium;let S=null,I=null;function F(t,r){const e=function(t){if(t.length<1e3)return null;const r=new Zlib.Inflate(t);return r?r.decompress():null}(new Uint8Array(t));if(!e)throw new Error((i=new Uint8Array(t),D.decode(i)));var i;const n=function(t,r){const e=r,i=r,n=e+1,s=i+1,a=m,o=U,h=g,c=x,f=T,u=new Float32Array(n*s);let l=0,y=1/0,d=-1/0;for(let r=0;r<n;r++){const n=r>=i?i-1:r;for(let r=0;r<s;r++){let i=0;const s=n*(4*e)+4*(r>=e?e-1:r);for(let r=0;r<a;r++)i=i*c+t[s+r];i=1*(i*h+o),i-=f,u[l]=i,i<y&&(y=i),i>d&&(d=i),l++}}return{data:u,min:y,max:d}}(function(t){const r=t,e=v,i=k,n=new Uint8Array(e*i*E);let s,a,o,h,c;for(let t=0;t<i;t++)for(let f=0;f<e;f++){h=parseInt(149*t/(i-1)),c=parseInt(149*f/(e-1)),a=2*(150*h+c),s=r[a]+256*r[a+1],(s>1e4||s<-2e3)&&(s=0),o=4*(t*e+f);const u=(s+1e3)/g,l=x;n[o]=u/(l*l),n[o+1]=(u-n[o]*l*l)/l,n[o+2]=u-n[o]*l*l-n[o+1]*l,n[o+3]=255}return n}(e),r-1);return n.width=n.height=r,n}const D=new TextDecoder("utf-8");function z(t){return t>>1^-(1&t)}const C=[];function N(t){let r=0;const e=3*Float64Array.BYTES_PER_ELEMENT,i=3*Uint16Array.BYTES_PER_ELEMENT;let n=Uint16Array.BYTES_PER_ELEMENT;const s=new DataView(t);r+=e;const a=s.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT;const o=s.getFloat32(r,!0);r+=Float32Array.BYTES_PER_ELEMENT,r+=e;const h=s.getFloat64(r,!0);r+=Float64Array.BYTES_PER_ELEMENT,r+=e;const c=s.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;const f=new Uint16Array(t,r,3*c);r+=c*i,c>65536&&(n=Uint32Array.BYTES_PER_ELEMENT);!function(t,r,e){const i=t.length;let n=0,s=0,a=0;for(let o=0;o<i;++o)n+=z(t[o]),s+=z(r[o]),t[o]=n,r[o]=s,e&&(a+=z(e[o]),e[o]=a)}(f.subarray(0,c),f.subarray(c,2*c),f.subarray(2*c,3*c)),r%n!=0&&(r+=n-r%n);const u=s.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;const l=c>65536?new Uint32Array(t,r,3*u):new Uint16Array(t,r,3*u);let y=0;const d=l.length;for(let t=0;t<d;++t){const r=l[t];l[t]=y-r,0===r&&++y}const A={minimumHeight:a,maximumHeight:o,quantizedVertices:f,indices:l}.quantizedVertices,w=A.length/3,b=A.subarray(0,w),p=A.subarray(w,2*w),v=A.subarray(2*w,3*w),k=C;for(let t=0;t<w;++t){const r=b[t]/32767,e=p[t]/32767,i=(m=a,U=o,(1-(g=v[t]/32767))*m+g*U);k[3*t]=r,k[3*t+1]=1-e,k[3*t+2]=i}var m,U,g;return{positions:k,radius:h,min:a,max:o,indices:l}}const O=[],j=[],q=[],W=[],Z=[];class V{constructor(t,r,e,i,n){this.p0=[],this.p1=[],this.p2=[],this.normal=[],this.min=[],this.max=[],this.set(t,r,e,i,n)}set(t,r,e,i,o){this.radius=o;let h=3*r,c=3*r+1,f=3*r+2;this.p0[0]=t[h]*o,this.p0[1]=t[c]*o,this.p0[2]=t[f],h=3*e,c=3*e+1,f=3*e+2,this.p1[0]=t[h]*o,this.p1[1]=t[c]*o,this.p1[2]=t[f],h=3*i,c=3*i+1,f=3*i+2,this.p2[0]=t[h]*o,this.p2[1]=t[c]*o,this.p2[2]=t[f],this.min[0]=Math.min(this.p0[0],this.p1[0],this.p2[0]),this.min[1]=Math.min(this.p0[1],this.p1[1],this.p2[1]),this.max[0]=Math.max(this.p0[0],this.p1[0],this.p2[0]),this.max[1]=Math.max(this.p0[1],this.p1[1],this.p2[1]);const u=a(O,this.p1,this.p0),l=a(j,this.p2,this.p1);this.normal=n(this.normal,s(this.normal,u,l))}contains(t,r){if(t<this.min[0]||t>this.max[0]||r<this.min[1]||r>this.max[1])return!1;c(q,this.p0[0],this.p0[1]),c(W,this.p1[0],this.p1[1]),c(Z,this.p2[0],this.p2[1]);const e=H(q[0],q[1],W[0],W[1],Z[0],Z[1]);return H(t,r,q[0],q[1],Z[0],Z[1])+H(t,r,q[0],q[1],W[0],W[1])+H(t,r,W[0],W[1],Z[0],Z[1])-e<=1e-4}getHeight(t,r){const e=this.normal;return this.p0[2]-((t-this.p0[0])*e[0]+(r-this.p0[1])*e[1])/e[2]}}let $=null;function _(t,r,e){if($&&$.contains(r,e))return $.getHeight(r,e);for(let i=0;i<t.length;i++)if(t[i].contains(r,e))return $=t[i],t[i].getHeight(r,e);return 0}const B=[];function H(t,r,e,i,n,s){return.5*Math.abs(t*i+e*s+n*r-t*s-e*r-n*i)}function L(t,r,e,i,n,s){"cesium-ion"===e&&(r.Authorization="Bearer "+S),function(t,r,e){const i={method:"GET",referrer:e,headers:r},n=u.getArrayBuffer(t,i),s=n.xhr;return p[t]=s,n.then(r=>(delete p[t],r))}(t,r,origin).then(t=>{if(!t||t.message)s(t?{empty:!0,originalError:t}:{error:{canceled:!0}});else{const r=t.data;let a=null;if("tianditu"===e){const t=F(r,i);P(n,t,i,null,!0,s)}else if("cesium-ion"===e||"cesium"===e){a=N(r);const t=function(t,r){const{positions:e,min:i,max:n,indices:s,radius:a}=t,o=[];let h=0;for(let t=0;t<s.length;t+=3){let r=B[h];r?r.set(e,s[t],s[t+1],s[t+2],2*a):r=B[h]=new V(e,s[t],s[t+1],s[t+2],2*a),h++,o.push(r)}const c=new Float32Array(r*r);h=0;for(let t=0;t<r;t++)for(let e=0;e<r;e++)c[h++]=_(o,e/r*a*2,t/r*a*2);return{data:c,min:i,max:n,width:r,height:r}}(a,i);P(n,t,i,null,!0,s)}else"mapbox"===e&&(a=function(t){const r=new self.Blob([new Uint8Array(t)]);return self.createImageBitmap(r)}(r),a.then(t=>{const r=function(t,r){const{data:e,width:i}=t;let n=1/0,s=-1/0;const a=new Float32Array(r*r),o=Math.round(i/r);for(let t=0;t<r;t++)for(let h=0;h<r;h++){const c=t+h*r;let f=0,u=0;const l=t,y=h;for(let t=0;t<o;t++)for(let r=0;r<o;r++){let n=l*o+t,s=y*o+r;s>i-1&&(s=i-1),n>i-1&&(n=i-1);const a=n+s*i,h=e[4*a],c=e[4*a+1],d=e[4*a+2];0===e[4*a+3]?u+=1:f+=.1*(256*h*256+256*c+d)-1e4}f/=o*o-u||1,f>s&&(s=f),f<n&&(n=f),a[c]=f}return{data:a,width:r,height:r,min:n,max:s}}(function(t){const{width:r,height:e}=t;w||(w=new OffscreenCanvas(1,1),b=w.getContext("2d",{willReadFrequently:!0}));return w.width=r,w.height=e,b.drawImage(t,0,0,r,e),b.getImageData(0,0,r,e)}(t),i);P(n,r,i,t,!0,s)}))}}).catch(r=>{delete p[t],s({empty:!0,originalError:r})})}function P(t,r,e,i,n,s){const a=function(t,r,e,i){let n=d[e];n||(n=d[e]=new l(e));const s=n.createTile(r),a=i?s.getMeshWithSkirts(t,!0):s.getMesh(t),{triangles:o,vertices:h,leftSkirtIndex:c,rightSkirtIndex:f,bottomSkirtIndex:u,topSkirtIndex:y}=a;let{numVerticesWithoutSkirts:A,numTrianglesWithoutSkirts:w}=a;A||(A=h.legnth/3,w=o.length/3);const b=h.length/2,p=new Float32Array(3*b),v=new Float32Array(2*b);let k=1/0,m=-1/0;const U=e-1;for(let t=0;t<b;t++){const i=h[2*t],n=h[2*t+1];if(t>=A){const r=i/2*3;let e,n=.001;(t-(t<c/2?A:t<f/2?c/2:t<u/2?f/2:u/2))%3==0?(e=0,n=0):e=p[r+2];p[3*t]=p[r],p[3*t+1]=p[r+1],p[3*t+2]=e,v[2*t]=p[r]/U+n,v[2*t+1]=-p[r+1]/U+n}else p[3*t]=1*i,p[3*t+1]=1*-n,p[3*t+2]=r[n*e+i],v[2*t]=i/U,v[2*t+1]=n/U;const s=p[p.length-1];s<k&&(k=s),s>m&&(m=s)}return{positions:p,texcoords:v,triangles:o,leftSkirtIndex:c,rightSkirtIndex:f,bottomSkirtIndex:u,topSkirtIndex:y,numTrianglesWithoutSkirts:w,numVerticesWithoutSkirts:A,minHeight:k,maxHeight:m,terrainWidth:e}}(t,r.data,e,n),o=[a.positions.buffer,a.texcoords.buffer,a.triangles.buffer];i&&o.push(i);const h={mesh:a};h.image=i,h.data=r,o.push(r.data.buffer),s(h,o)}t.initialize=function(){},t.onmessage=function(t,r){const e=t.data;var i;"addLayer"===e.command||"removeLayer"===e.command?(A=t.workerId,self.postMessage({type:"<response>",actorId:e.actorId,workerId:A,params:"ok",callback:t.callback})):"fetchTerrain"===e.command?function(t,r){const{url:e,origin:i,type:n,accessToken:s,terrainWidth:a,error:o}=t,h=t.headers||M[n];if("tianditu"===n)L(e,h,n,a,o,r);else if("cesium-ion"===n){const c=t.cesiumIonTokenURL+s;S?L(e,h,n,a,o,r):(I||(I=fetch(c,{responseType:"json",method:"GET",referrer:i,headers:{Accept:"application/json,*/*;q=0.01","Accept-Encoding":"gzip, deflate, br"}}).then(t=>t.json()).then(t=>{S=t.accessToken,I=null})),I.then(()=>{L(e,h,n,a,o,r)}))}else("cesium"===n||"mapbox"===n)&&L(e,h,n,a,o,r)}(e.params,(t,e)=>{r(t.error,t,e)}):"abortTerrain"===e.command&&(i=e.params.url,p[i]&&(p[i].abort(),delete p[i]))}}');const OPTIONS={width:100,height:10};function getCanvas(){if(!canvas){const{width,height}=OPTIONS;OffscreenCanvas?canvas=new OffscreenCanvas(width,height):(canvas=document.createElement("canvas"),canvas.width=width,canvas.height=height)}return canvas}class ColorIn{constructor(colors,options={}){if(!Array.isArray(colors))return void console.error("colors is not array");if(colors.length<2)return void console.error("colors.length should >1");this.colors=colors;let min=1/0,max=-1/0;for(let i=0,len=colors.length;i<len;i++){const value=colors[i][0];min=Math.min(value,min),max=Math.max(value,max)}this.min=min,this.max=max,this.valueOffset=this.max-this.min,this.options=Object.assign({},OPTIONS,options),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const canvas=getCanvas(),{width,height}=this.options;canvas.width=width,canvas.height=height;const ctx=canvas.getContext("2d");ctx.clearRect(0,0,canvas.width,canvas.height);const gradient=ctx.createLinearGradient(0,0,canvas.width,0),{colors,valueOffset}=this;for(let i=0,len=colors.length;i<len;i++){const[stop,color]=colors[i];gradient.addColorStop((stop-this.min)/valueOffset,color)}ctx.fillStyle=gradient,ctx.fillRect(0,0,canvas.width,canvas.height),this.imgData=ctx.getImageData(0,0,canvas.width,canvas.height)}getColor(stop){stop=Math.max(this.min,stop),stop=Math.min(stop,this.max);let x=Math.round((stop-this.min)/this.valueOffset*this.imgData.width);x=Math.min(x,this.imgData.width-1);const idx=4*x;return[this.imgData.data[idx],this.imgData.data[idx+1],this.imgData.data[idx+2],this.imgData.data[idx+3]]}}var colorInCache;function createFunction(parameters,defaultType){var fun,isFeatureConstant,isZoomConstant;if(isFunctionDefinition(parameters)){var innerFun,zoomAndFeatureDependent=parameters.stops&&"object"==typeof parameters.stops[0][0],zoomDependent=zoomAndFeatureDependent||!(zoomAndFeatureDependent||void 0!==parameters.property),type=parameters.type||defaultType||"exponential";if("exponential"===type)innerFun=evaluateExponentialFunction;else if("interval"===type)innerFun=evaluateIntervalFunction;else if("categorical"===type)innerFun=evaluateCategoricalFunction;else if("identity"===type)innerFun=evaluateIdentityFunction;else{if("color-interpolate"!==type)throw new Error('Unknown function type "'+type+'"');innerFun=evaluateColorInterpolateFunction}if(zoomAndFeatureDependent){var featureFunctions={},featureFunctionStops=[];for(let s=0;s<parameters.stops.length;s++){var stop=parameters.stops[s];void 0===featureFunctions[stop[0].zoom]&&(featureFunctions[stop[0].zoom]={zoom:stop[0].zoom,type:parameters.type,property:parameters.property,default:parameters.default,stops:[]}),featureFunctions[stop[0].zoom].stops.push([stop[0].value,stop[1]])}for(let z in featureFunctions)featureFunctionStops.push([featureFunctions[z].zoom,createFunction(featureFunctions[z])]);fun=function(zoom,feature){const value=evaluateExponentialFunction({stops:featureFunctionStops,base:parameters.base},zoom)(zoom,feature);return"function"==typeof value?value(zoom,feature):value},isFeatureConstant=!1,isZoomConstant=!1}else zoomDependent?(fun=function(zoom){const value=innerFun(parameters,zoom);return"function"==typeof value?value(zoom):value},isFeatureConstant=!0,isZoomConstant=!1):(fun=function(zoom,feature){const value=innerFun(parameters,feature?feature[parameters.property]:null);return"function"==typeof value?value(zoom,feature):value},isFeatureConstant=!1,isZoomConstant=!0)}else fun=function(){return parameters},isFeatureConstant=!0,isZoomConstant=!0;return fun.isZoomConstant=isZoomConstant,fun.isFeatureConstant=isFeatureConstant,fun}function evaluateCategoricalFunction(parameters,input){for(let i=0;i<parameters.stops.length;i++)if(input===parameters.stops[i][0])return parameters.stops[i][1];return parameters.default}function evaluateIntervalFunction(parameters,input){for(var i=0;i<parameters.stops.length&&!(input<parameters.stops[i][0]);i++);return parameters.stops[Math.max(i-1,0)][1]}function evaluateExponentialFunction(parameters,input){for(var base=void 0!==parameters.base?parameters.base:1,i=0;!(i>=parameters.stops.length||input<=parameters.stops[i][0]);)i++;return 0===i?parameters.stops[i][1]:i===parameters.stops.length?parameters.stops[i-1][1]:interpolate(input,base,parameters.stops[i-1][0],parameters.stops[i][0],parameters.stops[i-1][1],parameters.stops[i][1])}"function"==typeof Map&&(colorInCache=new Map);const COLORIN_OPTIONS={width:100,height:1};function evaluateColorInterpolateFunction(parameters,input){const stops=parameters.stops;if(stops&&stops.length>1){let colorIn;if(colorInCache){const key=JSON.stringify(stops);if(!colorInCache.has(key)){const colorIn=new ColorIn(stops,COLORIN_OPTIONS);colorInCache.set(key,colorIn)}colorIn=colorInCache.get(key)}else colorIn=new ColorIn(stops,COLORIN_OPTIONS);const[r,g,b,a]=colorIn.getColor(input);return[r/255,g/255,b/255,a/255]}return stops&&1===stops.length?stops[0][1]:null}function evaluateIdentityFunction(parameters,input){return function(a,b,c){return void 0!==a?a:void 0!==b?b:void 0!==c?c:null}(input,parameters.default)}function interpolate(input,base,inputLower,inputUpper,outputLower,outputUpper){return"function"==typeof outputLower?function(){var evaluatedLower=outputLower.apply(void 0,arguments),evaluatedUpper=outputUpper.apply(void 0,arguments);return interpolate(input,base,inputLower,inputUpper,evaluatedLower,evaluatedUpper)}:outputLower.length?function(input,base,inputLower,inputUpper,outputLower,outputUpper){var output=[];for(let i=0;i<outputLower.length;i++)output[i]=interpolateNumber(input,base,inputLower,inputUpper,outputLower[i],outputUpper[i]);return output}(input,base,inputLower,inputUpper,outputLower,outputUpper):interpolateNumber(input,base,inputLower,inputUpper,outputLower,outputUpper)}function interpolateNumber(input,base,inputLower,inputUpper,outputLower,outputUpper){var ratio,difference=inputUpper-inputLower,progress=input-inputLower;return outputLower*(1-(ratio=1===base?progress/difference:(Math.pow(base,progress)-1)/(Math.pow(base,difference)-1)))+outputUpper*ratio}function isFunctionDefinition(obj){return obj&&"object"==typeof obj&&(obj.stops||obj.property&&"identity"===obj.type)}function hasFunctionDefinition(obj){for(const p in obj)if(isFunctionDefinition(obj[p]))return!0;return!1}function interpolated(parameters){return createFunction1(parameters,"exponential")}function piecewiseConstant(parameters){return createFunction1(parameters,"interval")}function loadFunctionTypes(obj,argFn){if(!obj)return null;var hit=!1;if(Array.isArray(obj)){var loaded,multResult=[];for(let i=0;i<obj.length;i++)loaded=loadFunctionTypes(obj[i],argFn),loaded?(multResult.push(loaded),hit=!0):multResult.push(obj[i]);return hit?multResult:obj}var p,result={__fn_types_loaded:!0},props=[];for(p in obj)obj.hasOwnProperty(p)&&props.push(p);const buildFn=function(p){Object.defineProperty(result,p,{get:function(){return this["__fn_"+p]||(this["__fn_"+p]=interpolated(this["_"+p])),this["__fn_"+p].apply(this,argFn())},set:function(v){this["_"+p]=v},configurable:!0,enumerable:!0})};for(let i=0,len=props.length;i<len;i++)p=props[i],isFunctionDefinition(obj[p])?(hit=!0,result["_"+p]=obj[p],buildFn(p)):result[p]=obj[p];return hit?result:obj}function createFunction1(parameters,defaultType){if(!isFunctionDefinition(parameters))return function(){return parameters};let isZoomConstant=!0,isFeatureConstant=!0;const stops=(parameters=JSON.parse(JSON.stringify(parameters))).stops;if(stops)for(let i=0;i<stops.length;i++)if(isFunctionDefinition(stops[i][1])){const fn=createFunction1(stops[i][1],defaultType);isZoomConstant=isZoomConstant&&fn.isZoomConstant,isFeatureConstant=isFeatureConstant&&fn.isFeatureConstant,stops[i]=[stops[i][0],fn]}const fn=createFunction(parameters,defaultType);return fn.isZoomConstant=isZoomConstant&&fn.isZoomConstant,fn.isFeatureConstant=isFeatureConstant&&fn.isFeatureConstant,fn}var pointGeometry=Point;function Point(x,y){this.x=x,this.y=y}function ShelfPack(w,h,options){options=options||{},this.w=w||64,this.h=h||64,this.autoResize=!!options.autoResize,this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0}function Shelf(y,w,h){this.x=0,this.y=y,this.w=this.free=w,this.h=h}function Bin(id,x,y,w,h,maxw,maxh){this.id=id,this.x=x,this.y=y,this.w=w,this.h=h,this.maxw=maxw||w,this.maxh=maxh||h,this.refcount=0}Point.prototype={clone:function(){return new Point(this.x,this.y)},add:function(p){return this.clone()._add(p)},sub:function(p){return this.clone()._sub(p)},multByPoint:function(p){return this.clone()._multByPoint(p)},divByPoint:function(p){return this.clone()._divByPoint(p)},mult:function(k){return this.clone()._mult(k)},div:function(k){return this.clone()._div(k)},rotate:function(a){return this.clone()._rotate(a)},rotateAround:function(a,p){return this.clone()._rotateAround(a,p)},matMult:function(m){return this.clone()._matMult(m)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(other){return this.x===other.x&&this.y===other.y},dist:function(p){return Math.sqrt(this.distSqr(p))},distSqr:function(p){var dx=p.x-this.x,dy=p.y-this.y;return dx*dx+dy*dy},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(b){return Math.atan2(this.y-b.y,this.x-b.x)},angleWith:function(b){return this.angleWithSep(b.x,b.y)},angleWithSep:function(x,y){return Math.atan2(this.x*y-this.y*x,this.x*x+this.y*y)},_matMult:function(m){var y=m[2]*this.x+m[3]*this.y;return this.x=m[0]*this.x+m[1]*this.y,this.y=y,this},_add:function(p){return this.x+=p.x,this.y+=p.y,this},_sub:function(p){return this.x-=p.x,this.y-=p.y,this},_mult:function(k){return this.x*=k,this.y*=k,this},_div:function(k){return this.x/=k,this.y/=k,this},_multByPoint:function(p){return this.x*=p.x,this.y*=p.y,this},_divByPoint:function(p){return this.x/=p.x,this.y/=p.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var y=this.y;return this.y=this.x,this.x=-y,this},_rotate:function(angle){var cos=Math.cos(angle),sin=Math.sin(angle),y=sin*this.x+cos*this.y;return this.x=cos*this.x-sin*this.y,this.y=y,this},_rotateAround:function(angle,p){var cos=Math.cos(angle),sin=Math.sin(angle),y=p.y+sin*(this.x-p.x)+cos*(this.y-p.y);return this.x=p.x+cos*(this.x-p.x)-sin*(this.y-p.y),this.y=y,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Point.convert=function(a){return a instanceof Point?a:Array.isArray(a)?new Point(a[0],a[1]):a},ShelfPack.prototype.pack=function(bins,options){bins=[].concat(bins),options=options||{};for(var w,h,allocation,results=[],i=0;i<bins.length;i++)if(h=bins[i].h||bins[i].height,(w=bins[i].w||bins[i].width)&&h){if(!(allocation=this.packOne(w,h,bins[i].id)))continue;options.inPlace&&(bins[i].x=allocation.x,bins[i].y=allocation.y,bins[i].id=allocation.id),results.push(allocation)}return this.shrink(),results},ShelfPack.prototype.packOne=function(w,h,id){var bin,shelf,waste,i,h1,h2,w1,w2,best={freebin:-1,shelf:-1,waste:1/0},y=0;if("string"==typeof id||"number"==typeof id){if(bin=this.getBin(id))return this.ref(bin),bin;"number"==typeof id&&(this.maxId=Math.max(id,this.maxId))}else id=++this.maxId;for(i=0;i<this.freebins.length;i++){if(h===(bin=this.freebins[i]).maxh&&w===bin.maxw)return this.allocFreebin(i,w,h,id);h>bin.maxh||w>bin.maxw||h<=bin.maxh&&w<=bin.maxw&&(waste=bin.maxw*bin.maxh-w*h)<best.waste&&(best.waste=waste,best.freebin=i)}for(i=0;i<this.shelves.length;i++)if(y+=(shelf=this.shelves[i]).h,!(w>shelf.free)){if(h===shelf.h)return this.allocShelf(i,w,h,id);h>shelf.h||h<shelf.h&&(waste=(shelf.h-h)*w)<best.waste&&(best.freebin=-1,best.waste=waste,best.shelf=i)}return-1!==best.freebin?this.allocFreebin(best.freebin,w,h,id):-1!==best.shelf?this.allocShelf(best.shelf,w,h,id):h<=this.h-y&&w<=this.w?(shelf=new Shelf(y,this.w,h),this.allocShelf(this.shelves.push(shelf)-1,w,h,id)):this.autoResize?(h1=h2=this.h,((w1=w2=this.w)<=h1||w>w1)&&(w2=2*Math.max(w,w1)),(h1<w1||h>h1)&&(h2=2*Math.max(h,h1)),this.resize(w2,h2),this.packOne(w,h,id)):null},ShelfPack.prototype.allocFreebin=function(index,w,h,id){var bin=this.freebins.splice(index,1)[0];return bin.id=id,bin.w=w,bin.h=h,bin.refcount=0,this.bins[id]=bin,this.ref(bin),bin},ShelfPack.prototype.allocShelf=function(index,w,h,id){var bin=this.shelves[index].alloc(w,h,id);return this.bins[id]=bin,this.ref(bin),bin},ShelfPack.prototype.shrink=function(){if(this.shelves.length>0){for(var w2=0,h2=0,j=0;j<this.shelves.length;j++){var shelf=this.shelves[j];h2+=shelf.h,w2=Math.max(shelf.w-shelf.free,w2)}this.resize(w2,h2)}},ShelfPack.prototype.getBin=function(id){return this.bins[id]},ShelfPack.prototype.ref=function(bin){if(1==++bin.refcount){var h=bin.h;this.stats[h]=1+(0|this.stats[h])}return bin.refcount},ShelfPack.prototype.unref=function(bin){return 0===bin.refcount?0:(0==--bin.refcount&&(this.stats[bin.h]--,delete this.bins[bin.id],this.freebins.push(bin)),bin.refcount)},ShelfPack.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},ShelfPack.prototype.resize=function(w,h){this.w=w,this.h=h;for(var i=0;i<this.shelves.length;i++)this.shelves[i].resize(w);return!0},Shelf.prototype.alloc=function(w,h,id){if(w>this.free||h>this.h)return null;var x=this.x;return this.x+=w,this.free-=w,new Bin(id,x,this.y,w,h,w,this.h)},Shelf.prototype.resize=function(w){return this.free+=w-this.w,this.w=w,!0};var colorString$1={exports:{}},colorName={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},simpleSwizzle={exports:{}},isArrayish=function(obj){return!(!obj||"string"==typeof obj)&&(obj instanceof Array||Array.isArray(obj)||obj.length>=0&&(obj.splice instanceof Function||Object.getOwnPropertyDescriptor(obj,obj.length-1)&&"String"!==obj.constructor.name))},concat=Array.prototype.concat,slice=Array.prototype.slice,swizzle$1=simpleSwizzle.exports=function(args){for(var results=[],i=0,len=args.length;i<len;i++){var arg=args[i];isArrayish(arg)?results=concat.call(results,slice.call(arg)):results.push(arg)}return results};swizzle$1.wrap=function(fn){return function(){return fn(swizzle$1(arguments))}};var colorNames=colorName,swizzle=simpleSwizzle.exports,hasOwnProperty=Object.hasOwnProperty,reverseNames=Object.create(null);for(var name in colorNames)hasOwnProperty.call(colorNames,name)&&(reverseNames[colorNames[name]]=name);var cs$4=colorString$1.exports={to:{},get:{}};function clamp(num,min,max){return Math.min(Math.max(min,num),max)}function hexDouble(num){var str=Math.round(num).toString(16).toUpperCase();return str.length<2?"0"+str:str}cs$4.get=function(string){var val,model;switch(string.substring(0,3).toLowerCase()){case"hsl":val=cs$4.get.hsl(string),model="hsl";break;case"hwb":val=cs$4.get.hwb(string),model="hwb";break;default:val=cs$4.get.rgb(string),model="rgb"}return val?{model,value:val}:null},cs$4.get.rgb=function(string){if(!string)return null;var match,i,hexAlpha,rgb=[0,0,0,1];if(match=string.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(hexAlpha=match[2],match=match[1],i=0;i<3;i++){var i2=2*i;rgb[i]=parseInt(match.slice(i2,i2+2),16)}hexAlpha&&(rgb[3]=parseInt(hexAlpha,16)/255)}else if(match=string.match(/^#([a-f0-9]{3,4})$/i)){for(hexAlpha=(match=match[1])[3],i=0;i<3;i++)rgb[i]=parseInt(match[i]+match[i],16);hexAlpha&&(rgb[3]=parseInt(hexAlpha+hexAlpha,16)/255)}else if(match=string.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(i=0;i<3;i++)rgb[i]=parseInt(match[i+1],0);match[4]&&(rgb[3]=match[5]?.01*parseFloat(match[4]):parseFloat(match[4]))}else{if(!(match=string.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(match=string.match(/^(\w+)$/))?"transparent"===match[1]?[0,0,0,0]:hasOwnProperty.call(colorNames,match[1])?((rgb=colorNames[match[1]])[3]=1,rgb):null:null;for(i=0;i<3;i++)rgb[i]=Math.round(2.55*parseFloat(match[i+1]));match[4]&&(rgb[3]=match[5]?.01*parseFloat(match[4]):parseFloat(match[4]))}for(i=0;i<3;i++)rgb[i]=clamp(rgb[i],0,255);return rgb[3]=clamp(rgb[3],0,1),rgb},cs$4.get.hsl=function(string){if(!string)return null;var match=string.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(match){var alpha=parseFloat(match[4]);return[(parseFloat(match[1])%360+360)%360,clamp(parseFloat(match[2]),0,100),clamp(parseFloat(match[3]),0,100),clamp(isNaN(alpha)?1:alpha,0,1)]}return null},cs$4.get.hwb=function(string){if(!string)return null;var match=string.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(match){var alpha=parseFloat(match[4]);return[(parseFloat(match[1])%360+360)%360,clamp(parseFloat(match[2]),0,100),clamp(parseFloat(match[3]),0,100),clamp(isNaN(alpha)?1:alpha,0,1)]}return null},cs$4.to.hex=function(){var rgba=swizzle(arguments);return"#"+hexDouble(rgba[0])+hexDouble(rgba[1])+hexDouble(rgba[2])+(rgba[3]<1?hexDouble(Math.round(255*rgba[3])):"")},cs$4.to.rgb=function(){var rgba=swizzle(arguments);return rgba.length<4||1===rgba[3]?"rgb("+Math.round(rgba[0])+", "+Math.round(rgba[1])+", "+Math.round(rgba[2])+")":"rgba("+Math.round(rgba[0])+", "+Math.round(rgba[1])+", "+Math.round(rgba[2])+", "+rgba[3]+")"},cs$4.to.rgb.percent=function(){var rgba=swizzle(arguments),r=Math.round(rgba[0]/255*100),g=Math.round(rgba[1]/255*100),b=Math.round(rgba[2]/255*100);return rgba.length<4||1===rgba[3]?"rgb("+r+"%, "+g+"%, "+b+"%)":"rgba("+r+"%, "+g+"%, "+b+"%, "+rgba[3]+")"},cs$4.to.hsl=function(){var hsla=swizzle(arguments);return hsla.length<4||1===hsla[3]?"hsl("+hsla[0]+", "+hsla[1]+"%, "+hsla[2]+"%)":"hsla("+hsla[0]+", "+hsla[1]+"%, "+hsla[2]+"%, "+hsla[3]+")"},cs$4.to.hwb=function(){var hwba=swizzle(arguments),a="";return hwba.length>=4&&1!==hwba[3]&&(a=", "+hwba[3]),"hwb("+hwba[0]+", "+hwba[1]+"%, "+hwba[2]+"%"+a+")"},cs$4.to.keyword=function(rgb){return reverseNames[rgb.slice(0,3)]};var conversions$2={exports:{}},cssKeywords=colorName,reverseKeywords={};for(var key in cssKeywords)cssKeywords.hasOwnProperty(key)&&(reverseKeywords[cssKeywords[key]]=key);var convert$2=conversions$2.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var model in convert$2)if(convert$2.hasOwnProperty(model)){if(!("channels"in convert$2[model]))throw new Error("missing channels property: "+model);if(!("labels"in convert$2[model]))throw new Error("missing channel labels property: "+model);if(convert$2[model].labels.length!==convert$2[model].channels)throw new Error("channel and label counts mismatch: "+model);var channels=convert$2[model].channels,labels=convert$2[model].labels;delete convert$2[model].channels,delete convert$2[model].labels,Object.defineProperty(convert$2[model],"channels",{value:channels}),Object.defineProperty(convert$2[model],"labels",{value:labels})}function comparativeDistance(x,y){return Math.pow(x[0]-y[0],2)+Math.pow(x[1]-y[1],2)+Math.pow(x[2]-y[2],2)}convert$2.rgb.hsl=function(rgb){var h,l,r=rgb[0]/255,g=rgb[1]/255,b=rgb[2]/255,min=Math.min(r,g,b),max=Math.max(r,g,b),delta=max-min;return max===min?h=0:r===max?h=(g-b)/delta:g===max?h=2+(b-r)/delta:b===max&&(h=4+(r-g)/delta),(h=Math.min(60*h,360))<0&&(h+=360),l=(min+max)/2,[h,100*(max===min?0:l<=.5?delta/(max+min):delta/(2-max-min)),100*l]},convert$2.rgb.hsv=function(rgb){var rdif,gdif,bdif,h,s,r=rgb[0]/255,g=rgb[1]/255,b=rgb[2]/255,v=Math.max(r,g,b),diff=v-Math.min(r,g,b),diffc=function(c){return(v-c)/6/diff+.5};return 0===diff?h=s=0:(s=diff/v,rdif=diffc(r),gdif=diffc(g),bdif=diffc(b),r===v?h=bdif-gdif:g===v?h=1/3+rdif-bdif:b===v&&(h=2/3+gdif-rdif),h<0?h+=1:h>1&&(h-=1)),[360*h,100*s,100*v]},convert$2.rgb.hwb=function(rgb){var r=rgb[0],g=rgb[1],b=rgb[2];return[convert$2.rgb.hsl(rgb)[0],100*(1/255*Math.min(r,Math.min(g,b))),100*(b=1-1/255*Math.max(r,Math.max(g,b)))]},convert$2.rgb.cmyk=function(rgb){var k,r=rgb[0]/255,g=rgb[1]/255,b=rgb[2]/255;return[100*((1-r-(k=Math.min(1-r,1-g,1-b)))/(1-k)||0),100*((1-g-k)/(1-k)||0),100*((1-b-k)/(1-k)||0),100*k]},convert$2.rgb.keyword=function(rgb){var reversed=reverseKeywords[rgb];if(reversed)return reversed;var currentClosestKeyword,currentClosestDistance=1/0;for(var keyword in cssKeywords)if(cssKeywords.hasOwnProperty(keyword)){var distance=comparativeDistance(rgb,cssKeywords[keyword]);distance<currentClosestDistance&&(currentClosestDistance=distance,currentClosestKeyword=keyword)}return currentClosestKeyword},convert$2.keyword.rgb=function(keyword){return cssKeywords[keyword]},convert$2.rgb.xyz=function(rgb){var r=rgb[0]/255,g=rgb[1]/255,b=rgb[2]/255;return[100*(.4124*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)+.3576*(g=g>.04045?Math.pow((g+.055)/1.055,2.4):g/12.92)+.1805*(b=b>.04045?Math.pow((b+.055)/1.055,2.4):b/12.92)),100*(.2126*r+.7152*g+.0722*b),100*(.0193*r+.1192*g+.9505*b)]},convert$2.rgb.lab=function(rgb){var xyz=convert$2.rgb.xyz(rgb),x=xyz[0],y=xyz[1],z=xyz[2];return y/=100,z/=108.883,x=(x/=95.047)>.008856?Math.pow(x,1/3):7.787*x+16/116,[116*(y=y>.008856?Math.pow(y,1/3):7.787*y+16/116)-16,500*(x-y),200*(y-(z=z>.008856?Math.pow(z,1/3):7.787*z+16/116))]},convert$2.hsl.rgb=function(hsl){var t1,t2,t3,rgb,val,h=hsl[0]/360,s=hsl[1]/100,l=hsl[2]/100;if(0===s)return[val=255*l,val,val];t1=2*l-(t2=l<.5?l*(1+s):l+s-l*s),rgb=[0,0,0];for(var i=0;i<3;i++)(t3=h+1/3*-(i-1))<0&&t3++,t3>1&&t3--,rgb[i]=255*(val=6*t3<1?t1+6*(t2-t1)*t3:2*t3<1?t2:3*t3<2?t1+(t2-t1)*(2/3-t3)*6:t1);return rgb},convert$2.hsl.hsv=function(hsl){var h=hsl[0],s=hsl[1]/100,l=hsl[2]/100,smin=s,lmin=Math.max(l,.01);return s*=(l*=2)<=1?l:2-l,smin*=lmin<=1?lmin:2-lmin,[h,100*(0===l?2*smin/(lmin+smin):2*s/(l+s)),100*((l+s)/2)]},convert$2.hsv.rgb=function(hsv){var h=hsv[0]/60,s=hsv[1]/100,v=hsv[2]/100,hi=Math.floor(h)%6,f=h-Math.floor(h),p=255*v*(1-s),q=255*v*(1-s*f),t=255*v*(1-s*(1-f));switch(v*=255,hi){case 0:return[v,t,p];case 1:return[q,v,p];case 2:return[p,v,t];case 3:return[p,q,v];case 4:return[t,p,v];case 5:return[v,p,q]}},convert$2.hsv.hsl=function(hsv){var lmin,sl,l,h=hsv[0],s=hsv[1]/100,v=hsv[2]/100,vmin=Math.max(v,.01);return l=(2-s)*v,sl=s*vmin,[h,100*(sl=(sl/=(lmin=(2-s)*vmin)<=1?lmin:2-lmin)||0),100*(l/=2)]},convert$2.hwb.rgb=function(hwb){var i,v,f,n,r,g,b,h=hwb[0]/360,wh=hwb[1]/100,bl=hwb[2]/100,ratio=wh+bl;switch(ratio>1&&(wh/=ratio,bl/=ratio),f=6*h-(i=Math.floor(6*h)),0!=(1&i)&&(f=1-f),n=wh+f*((v=1-bl)-wh),i){default:case 6:case 0:r=v,g=n,b=wh;break;case 1:r=n,g=v,b=wh;break;case 2:r=wh,g=v,b=n;break;case 3:r=wh,g=n,b=v;break;case 4:r=n,g=wh,b=v;break;case 5:r=v,g=wh,b=n}return[255*r,255*g,255*b]},convert$2.cmyk.rgb=function(cmyk){var m=cmyk[1]/100,y=cmyk[2]/100,k=cmyk[3]/100;return[255*(1-Math.min(1,cmyk[0]/100*(1-k)+k)),255*(1-Math.min(1,m*(1-k)+k)),255*(1-Math.min(1,y*(1-k)+k))]},convert$2.xyz.rgb=function(xyz){var r,g,b,x=xyz[0]/100,y=xyz[1]/100,z=xyz[2]/100;return g=-.9689*x+1.8758*y+.0415*z,b=.0557*x+-.204*y+1.057*z,r=(r=3.2406*x+-1.5372*y+-.4986*z)>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,g=g>.0031308?1.055*Math.pow(g,1/2.4)-.055:12.92*g,b=b>.0031308?1.055*Math.pow(b,1/2.4)-.055:12.92*b,[255*(r=Math.min(Math.max(0,r),1)),255*(g=Math.min(Math.max(0,g),1)),255*(b=Math.min(Math.max(0,b),1))]},convert$2.xyz.lab=function(xyz){var x=xyz[0],y=xyz[1],z=xyz[2];return y/=100,z/=108.883,x=(x/=95.047)>.008856?Math.pow(x,1/3):7.787*x+16/116,[116*(y=y>.008856?Math.pow(y,1/3):7.787*y+16/116)-16,500*(x-y),200*(y-(z=z>.008856?Math.pow(z,1/3):7.787*z+16/116))]},convert$2.lab.xyz=function(lab){var x,y,z;x=lab[1]/500+(y=(lab[0]+16)/116),z=y-lab[2]/200;var y2=Math.pow(y,3),x2=Math.pow(x,3),z2=Math.pow(z,3);return y=y2>.008856?y2:(y-16/116)/7.787,x=x2>.008856?x2:(x-16/116)/7.787,z=z2>.008856?z2:(z-16/116)/7.787,[x*=95.047,y*=100,z*=108.883]},convert$2.lab.lch=function(lab){var h,l=lab[0],a=lab[1],b=lab[2];return(h=360*Math.atan2(b,a)/2/Math.PI)<0&&(h+=360),[l,Math.sqrt(a*a+b*b),h]},convert$2.lch.lab=function(lch){var hr,c=lch[1];return hr=lch[2]/360*2*Math.PI,[lch[0],c*Math.cos(hr),c*Math.sin(hr)]},convert$2.rgb.ansi16=function(args){var r=args[0],g=args[1],b=args[2],value=1 in arguments?arguments[1]:convert$2.rgb.hsv(args)[2];if(0===(value=Math.round(value/50)))return 30;var ansi=30+(Math.round(b/255)<<2|Math.round(g/255)<<1|Math.round(r/255));return 2===value&&(ansi+=60),ansi},convert$2.hsv.ansi16=function(args){return convert$2.rgb.ansi16(convert$2.hsv.rgb(args),args[2])},convert$2.rgb.ansi256=function(args){var r=args[0],g=args[1],b=args[2];return r===g&&g===b?r<8?16:r>248?231:Math.round((r-8)/247*24)+232:16+36*Math.round(r/255*5)+6*Math.round(g/255*5)+Math.round(b/255*5)},convert$2.ansi16.rgb=function(args){var color=args%10;if(0===color||7===color)return args>50&&(color+=3.5),[color=color/10.5*255,color,color];var mult=.5*(1+~~(args>50));return[(1&color)*mult*255,(color>>1&1)*mult*255,(color>>2&1)*mult*255]},convert$2.ansi256.rgb=function(args){if(args>=232){var c=10*(args-232)+8;return[c,c,c]}var rem;return args-=16,[Math.floor(args/36)/5*255,Math.floor((rem=args%36)/6)/5*255,rem%6/5*255]},convert$2.rgb.hex=function(args){var string=(((255&Math.round(args[0]))<<16)+((255&Math.round(args[1]))<<8)+(255&Math.round(args[2]))).toString(16).toUpperCase();return"000000".substring(string.length)+string},convert$2.hex.rgb=function(args){var match=args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!match)return[0,0,0];var colorString=match[0];3===match[0].length&&(colorString=colorString.split("").map((function(char){return char+char})).join(""));var integer=parseInt(colorString,16);return[integer>>16&255,integer>>8&255,255&integer]},convert$2.rgb.hcg=function(rgb){var hue,r=rgb[0]/255,g=rgb[1]/255,b=rgb[2]/255,max=Math.max(Math.max(r,g),b),min=Math.min(Math.min(r,g),b),chroma=max-min;return hue=chroma<=0?0:max===r?(g-b)/chroma%6:max===g?2+(b-r)/chroma:4+(r-g)/chroma+4,hue/=6,[360*(hue%=1),100*chroma,100*(chroma<1?min/(1-chroma):0)]},convert$2.hsl.hcg=function(hsl){var s=hsl[1]/100,l=hsl[2]/100,c=1,f=0;return(c=l<.5?2*s*l:2*s*(1-l))<1&&(f=(l-.5*c)/(1-c)),[hsl[0],100*c,100*f]},convert$2.hsv.hcg=function(hsv){var v=hsv[2]/100,c=hsv[1]/100*v,f=0;return c<1&&(f=(v-c)/(1-c)),[hsv[0],100*c,100*f]},convert$2.hcg.rgb=function(hcg){var c=hcg[1]/100,g=hcg[2]/100;if(0===c)return[255*g,255*g,255*g];var mg,pure=[0,0,0],hi=hcg[0]/360%1*6,v=hi%1,w=1-v;switch(Math.floor(hi)){case 0:pure[0]=1,pure[1]=v,pure[2]=0;break;case 1:pure[0]=w,pure[1]=1,pure[2]=0;break;case 2:pure[0]=0,pure[1]=1,pure[2]=v;break;case 3:pure[0]=0,pure[1]=w,pure[2]=1;break;case 4:pure[0]=v,pure[1]=0,pure[2]=1;break;default:pure[0]=1,pure[1]=0,pure[2]=w}return[255*(c*pure[0]+(mg=(1-c)*g)),255*(c*pure[1]+mg),255*(c*pure[2]+mg)]},convert$2.hcg.hsv=function(hcg){var c=hcg[1]/100,v=c+hcg[2]/100*(1-c),f=0;return v>0&&(f=c/v),[hcg[0],100*f,100*v]},convert$2.hcg.hsl=function(hcg){var c=hcg[1]/100,l=hcg[2]/100*(1-c)+.5*c,s=0;return l>0&&l<.5?s=c/(2*l):l>=.5&&l<1&&(s=c/(2*(1-l))),[hcg[0],100*s,100*l]},convert$2.hcg.hwb=function(hcg){var c=hcg[1]/100,v=c+hcg[2]/100*(1-c);return[hcg[0],100*(v-c),100*(1-v)]},convert$2.hwb.hcg=function(hwb){var v=1-hwb[2]/100,c=v-hwb[1]/100,g=0;return c<1&&(g=(v-c)/(1-c)),[hwb[0],100*c,100*g]},convert$2.apple.rgb=function(apple){return[apple[0]/65535*255,apple[1]/65535*255,apple[2]/65535*255]},convert$2.rgb.apple=function(rgb){return[rgb[0]/255*65535,rgb[1]/255*65535,rgb[2]/255*65535]},convert$2.gray.rgb=function(args){return[args[0]/100*255,args[0]/100*255,args[0]/100*255]},convert$2.gray.hsl=convert$2.gray.hsv=function(args){return[0,0,args[0]]},convert$2.gray.hwb=function(gray){return[0,100,gray[0]]},convert$2.gray.cmyk=function(gray){return[0,0,0,gray[0]]},convert$2.gray.lab=function(gray){return[gray[0],0,0]},convert$2.gray.hex=function(gray){var val=255&Math.round(gray[0]/100*255),string=((val<<16)+(val<<8)+val).toString(16).toUpperCase();return"000000".substring(string.length)+string},convert$2.rgb.gray=function(rgb){return[(rgb[0]+rgb[1]+rgb[2])/3/255*100]};var conversions$1=conversions$2.exports;function deriveBFS(fromModel){var graph=function(){for(var graph={},models=Object.keys(conversions$1),len=models.length,i=0;i<len;i++)graph[models[i]]={distance:-1,parent:null};return graph}(),queue=[fromModel];for(graph[fromModel].distance=0;queue.length;)for(var current=queue.pop(),adjacents=Object.keys(conversions$1[current]),len=adjacents.length,i=0;i<len;i++){var adjacent=adjacents[i],node=graph[adjacent];-1===node.distance&&(node.distance=graph[current].distance+1,node.parent=current,queue.unshift(adjacent))}return graph}function link(from,to){return function(args){return to(from(args))}}function wrapConversion(toModel,graph){for(var path=[graph[toModel].parent,toModel],fn=conversions$1[graph[toModel].parent][toModel],cur=graph[toModel].parent;graph[cur].parent;)path.unshift(graph[cur].parent),fn=link(conversions$1[graph[cur].parent][cur],fn),cur=graph[cur].parent;return fn.conversion=path,fn}var conversions=conversions$2.exports,route=function(fromModel){for(var graph=deriveBFS(fromModel),conversion={},models=Object.keys(graph),len=models.length,i=0;i<len;i++){var toModel=models[i];null!==graph[toModel].parent&&(conversion[toModel]=wrapConversion(toModel,graph))}return conversion},convert$1={};Object.keys(conversions).forEach((function(fromModel){convert$1[fromModel]={},Object.defineProperty(convert$1[fromModel],"channels",{value:conversions[fromModel].channels}),Object.defineProperty(convert$1[fromModel],"labels",{value:conversions[fromModel].labels});var routes=route(fromModel);Object.keys(routes).forEach((function(toModel){var fn=routes[toModel];convert$1[fromModel][toModel]=function(fn){var wrappedFn=function(args){if(null==args)return args;arguments.length>1&&(args=Array.prototype.slice.call(arguments));var result=fn(args);if("object"==typeof result)for(var len=result.length,i=0;i<len;i++)result[i]=Math.round(result[i]);return result};return"conversion"in fn&&(wrappedFn.conversion=fn.conversion),wrappedFn}(fn),convert$1[fromModel][toModel].raw=function(fn){var wrappedFn=function(args){return null==args?args:(arguments.length>1&&(args=Array.prototype.slice.call(arguments)),fn(args))};return"conversion"in fn&&(wrappedFn.conversion=fn.conversion),wrappedFn}(fn)}))}));var colorString=colorString$1.exports,convert=convert$1,_slice=[].slice,skippedModels=["keyword","gray","hex"],hashedModelKeys={};Object.keys(convert).forEach((function(model){hashedModelKeys[_slice.call(convert[model].labels).sort().join("")]=model}));var limiters={};function Color(obj,model){if(!(this instanceof Color))return new Color(obj,model);if(model&&model in skippedModels&&(model=null),model&&!(model in convert))throw new Error("Unknown model: "+model);var i,channels;if(null==obj)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(obj instanceof Color)this.model=obj.model,this.color=obj.color.slice(),this.valpha=obj.valpha;else if("string"==typeof obj){var result=colorString.get(obj);if(null===result)throw new Error("Unable to parse color from string: "+obj);this.model=result.model,this.color=result.value.slice(0,channels=convert[this.model].channels),this.valpha="number"==typeof result.value[channels]?result.value[channels]:1}else if(obj.length){this.model=model||"rgb";var newArr=_slice.call(obj,0,channels=convert[this.model].channels);this.color=zeroArray(newArr,channels),this.valpha="number"==typeof obj[channels]?obj[channels]:1}else if("number"==typeof obj)obj&=16777215,this.model="rgb",this.color=[obj>>16&255,obj>>8&255,255&obj],this.valpha=1;else{this.valpha=1;var keys=Object.keys(obj);"alpha"in obj&&(keys.splice(keys.indexOf("alpha"),1),this.valpha="number"==typeof obj.alpha?obj.alpha:0);var hashedKeys=keys.sort().join("");if(!(hashedKeys in hashedModelKeys))throw new Error("Unable to parse color from object: "+JSON.stringify(obj));this.model=hashedModelKeys[hashedKeys];var labels=convert[this.model].labels,color=[];for(i=0;i<labels.length;i++)color.push(obj[labels[i]]);this.color=zeroArray(color)}if(limiters[this.model])for(channels=convert[this.model].channels,i=0;i<channels;i++){var limit=limiters[this.model][i];limit&&(this.color[i]=limit(this.color[i]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function getset(model,channel,modifier){return(model=Array.isArray(model)?model:[model]).forEach((function(m){(limiters[m]||(limiters[m]=[]))[channel]=modifier})),model=model[0],function(val){var result;return arguments.length?(modifier&&(val=modifier(val)),(result=this[model]()).color[channel]=val,result):(result=this[model]().color[channel],modifier&&(result=modifier(result)),result)}}function maxfn(max){return function(v){return Math.max(0,Math.min(max,v))}}function assertArray(val){return Array.isArray(val)?val:[val]}function zeroArray(arr,length){for(var i=0;i<length;i++)"number"!=typeof arr[i]&&(arr[i]=0);return arr}Color.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(places){var self=this.model in colorString.to?this:this.rgb(),args=1===(self=self.round("number"==typeof places?places:1)).valpha?self.color:self.color.concat(this.valpha);return colorString.to[self.model](args)},percentString:function(places){var self=this.rgb().round("number"==typeof places?places:1),args=1===self.valpha?self.color:self.color.concat(this.valpha);return colorString.to.rgb.percent(args)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var result={},channels=convert[this.model].channels,labels=convert[this.model].labels,i=0;i<channels;i++)result[labels[i]]=this.color[i];return 1!==this.valpha&&(result.alpha=this.valpha),result},unitArray:function(){var rgb=this.rgb().color;return rgb[0]/=255,rgb[1]/=255,rgb[2]/=255,1!==this.valpha&&rgb.push(this.valpha),rgb},unitObject:function(){var rgb=this.rgb().object();return rgb.r/=255,rgb.g/=255,rgb.b/=255,1!==this.valpha&&(rgb.alpha=this.valpha),rgb},round:function(places){return places=Math.max(places||0,0),new Color(this.color.map(function(places){return function(num){return function(num,places){return Number(num.toFixed(places))}(num,places)}}(places)).concat(this.valpha),this.model)},alpha:function(val){return arguments.length?new Color(this.color.concat(Math.max(0,Math.min(1,val))),this.model):this.valpha},red:getset("rgb",0,maxfn(255)),green:getset("rgb",1,maxfn(255)),blue:getset("rgb",2,maxfn(255)),hue:getset(["hsl","hsv","hsl","hwb","hcg"],0,(function(val){return(val%360+360)%360})),saturationl:getset("hsl",1,maxfn(100)),lightness:getset("hsl",2,maxfn(100)),saturationv:getset("hsv",1,maxfn(100)),value:getset("hsv",2,maxfn(100)),chroma:getset("hcg",1,maxfn(100)),gray:getset("hcg",2,maxfn(100)),white:getset("hwb",1,maxfn(100)),wblack:getset("hwb",2,maxfn(100)),cyan:getset("cmyk",0,maxfn(100)),magenta:getset("cmyk",1,maxfn(100)),yellow:getset("cmyk",2,maxfn(100)),black:getset("cmyk",3,maxfn(100)),x:getset("xyz",0,maxfn(100)),y:getset("xyz",1,maxfn(100)),z:getset("xyz",2,maxfn(100)),l:getset("lab",0,maxfn(100)),a:getset("lab",1),b:getset("lab",2),keyword:function(val){return arguments.length?new Color(val):convert[this.model].keyword(this.color)},hex:function(val){return arguments.length?new Color(val):colorString.to.hex(this.rgb().round().color)},rgbNumber:function(){var rgb=this.rgb().color;return(255&rgb[0])<<16|(255&rgb[1])<<8|255&rgb[2]},luminosity:function(){for(var rgb=this.rgb().color,lum=[],i=0;i<rgb.length;i++){var chan=rgb[i]/255;lum[i]=chan<=.03928?chan/12.92:Math.pow((chan+.055)/1.055,2.4)}return.2126*lum[0]+.7152*lum[1]+.0722*lum[2]},contrast:function(color2){var lum1=this.luminosity(),lum2=color2.luminosity();return lum1>lum2?(lum1+.05)/(lum2+.05):(lum2+.05)/(lum1+.05)},level:function(color2){var contrastRatio=this.contrast(color2);return contrastRatio>=7.1?"AAA":contrastRatio>=4.5?"AA":""},isDark:function(){var rgb=this.rgb().color;return(299*rgb[0]+587*rgb[1]+114*rgb[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var rgb=this.rgb(),i=0;i<3;i++)rgb.color[i]=255-rgb.color[i];return rgb},lighten:function(ratio){var hsl=this.hsl();return hsl.color[2]+=hsl.color[2]*ratio,hsl},darken:function(ratio){var hsl=this.hsl();return hsl.color[2]-=hsl.color[2]*ratio,hsl},saturate:function(ratio){var hsl=this.hsl();return hsl.color[1]+=hsl.color[1]*ratio,hsl},desaturate:function(ratio){var hsl=this.hsl();return hsl.color[1]-=hsl.color[1]*ratio,hsl},whiten:function(ratio){var hwb=this.hwb();return hwb.color[1]+=hwb.color[1]*ratio,hwb},blacken:function(ratio){var hwb=this.hwb();return hwb.color[2]+=hwb.color[2]*ratio,hwb},grayscale:function(){var rgb=this.rgb().color,val=.3*rgb[0]+.59*rgb[1]+.11*rgb[2];return Color.rgb(val,val,val)},fade:function(ratio){return this.alpha(this.valpha-this.valpha*ratio)},opaquer:function(ratio){return this.alpha(this.valpha+this.valpha*ratio)},rotate:function(degrees){var hsl=this.hsl(),hue=hsl.color[0];return hsl.color[0]=hue=(hue=(hue+degrees)%360)<0?360+hue:hue,hsl},mix:function(mixinColor,weight){if(!mixinColor||!mixinColor.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof mixinColor);var color1=mixinColor.rgb(),color2=this.rgb(),p=void 0===weight?.5:weight,w=2*p-1,a=color1.alpha()-color2.alpha(),w1=((w*a==-1?w:(w+a)/(1+w*a))+1)/2,w2=1-w1;return Color.rgb(w1*color1.red()+w2*color2.red(),w1*color1.green()+w2*color2.green(),w1*color1.blue()+w2*color2.blue(),color1.alpha()*p+color2.alpha()*(1-p))}},Object.keys(convert).forEach((function(model){if(-1===skippedModels.indexOf(model)){var channels=convert[model].channels;Color.prototype[model]=function(){if(this.model===model)return new Color(this);if(arguments.length)return new Color(arguments,model);var newAlpha="number"==typeof arguments[channels]?channels:this.valpha;return new Color(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha),model)},Color[model]=function(color){return"number"==typeof color&&(color=zeroArray(_slice.call(arguments),channels)),new Color(color,model)}}}));var color=Color;
/*!
	    Feature Filter by

	    (c) mapbox 2016 and maptalks 2018
	    www.mapbox.com | www.maptalks.org
	    License: MIT, header required.
	*/const types=["Unknown","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"];function createFilter(filter){return new Function("f",`var p = (f && f.properties || {}); return ${compile(filter)}`)}function isFeatureFilter(filter){if(!0===filter||!1===filter)return!0;if(!Array.isArray(filter)||0===filter.length)return!1;switch(filter[0]){case"has":case"!has":return 2===filter.length&&("string"==typeof filter[1]||filter[1].property&&filter[1].op);case"in":case"!in":return filter.length>=2&&("string"==typeof filter[1]||filter[1].property&&filter[1].op);case"==":case"!=":case">":case">=":case"<":case"<=":return 3===filter.length&&("string"==typeof filter[1]||filter[1].property&&filter[1].op);case"none":case"any":case"all":for(const f of filter.slice(1))if(!isFeatureFilter(f)&&"boolean"!=typeof f)return!1;return!0;case"contains":return!0;default:return!1}}function compile(filter){if(!filter)return"true";const op=filter[0];if(filter.length<=1)return"any"===op?"false":"true";return`(${"=="===op?compileComparisonOp(filter[1],filter[2],"===",!1):"!="===op?compileComparisonOp(filter[1],filter[2],"!==",!1):"<"===op||">"===op||"<="===op||">="===op?compileComparisonOp(filter[1],filter[2],op,!0):"any"===op?compileLogicalOp(filter.slice(1),"||"):"all"===op?compileLogicalOp(filter.slice(1),"&&"):"none"===op?compileNegation(compileLogicalOp(filter.slice(1),"||")):"in"===op?compileInOp(filter[1],filter.slice(2)):"!in"===op?compileNegation(compileInOp(filter[1],filter.slice(2))):"has"===op?compileHasOp(filter[1]):"!has"===op?compileNegation(compileHasOp(filter[1])):"contains"===op?function(property,str,index){const prop=compilePropertyReference(property);return void 0!==index?`(${prop} + '').indexOf("${str}") === ${index}`:`(${prop} + '').indexOf("${str}") >= 0`}(filter[1],filter[2],filter[3]):"true"})`}function compilePropertyReference(property){return"$"===property[0]?"f."+property.substring(1):"p["+JSON.stringify(property)+"]"}function compileComparisonOp(property,value,op,checkType){if("object"==typeof(obj=property)&&obj&&property.op)return function(propertyObj,value,op,checkType){const property=propertyObj.property,funName=propertyObj.op;let left=compilePropertyReference(property);return"length"!==funName?(console.error(`not support ${funName} op`),"false"):(left=`((${left}+='').length)`,getComparisonCode(left,property,value,op,checkType))}(property,value,op,checkType);var obj;return getComparisonCode(compilePropertyReference(property),property,value,op,checkType)}function getComparisonCode(left,property,value,op,checkType){const right="$type"===property?types.indexOf(value):JSON.stringify(value);return(checkType?`typeof ${left}=== typeof ${right}&&`:"")+left+op+right}function compileLogicalOp(expressions,op){return expressions.map(compile).join(op)}function compileInOp(property,values){"$type"===property&&(values=values.map((value=>types.indexOf(value))));const left=JSON.stringify(values.sort(compare)),right=compilePropertyReference(property);return values.length<=200?`${left}.indexOf(${right}) !== -1`:`function(v, a, i, j) {\n        while (i <= j) { var m = (i + j) >> 1;\n            if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\n        }\n    return false; }(${right}, ${left},0,${values.length-1})`}function compileHasOp(property){return"$id"===property?'"id" in f':`${JSON.stringify(property)} in p`}function compileNegation(expression){return`!(${expression})`}function compare(a,b){return a<b?-1:a>b?1:0}function compileStyle(styles){if(!Array.isArray(styles))return compileStyle([styles]);const compiled=[];for(let i=0;i<styles.length;i++){let filter;filter=!0===styles[i].filter?function(){return!0}:createFilter(styles[i].filter),compiled.push(extend$1({},styles[i],{filter}))}return compiled}function extend$1(dest){for(let i=1;i<arguments.length;i++){const src=arguments[i];for(const k in src)dest[k]=src[k]}return dest}var quickselect$1={exports:{}};!function(module,exports){module.exports=function(){function quickselect(arr,k,left,right,compare){quickselectStep(arr,k,left||0,right||arr.length-1,compare||defaultCompare)}function quickselectStep(arr,k,left,right,compare){for(;right>left;){if(right-left>600){var n=right-left+1,m=k-left+1,z=Math.log(n),s=.5*Math.exp(2*z/3),sd=.5*Math.sqrt(z*s*(n-s)/n)*(m-n/2<0?-1:1);quickselectStep(arr,k,Math.max(left,Math.floor(k-m*s/n+sd)),Math.min(right,Math.floor(k+(n-m)*s/n+sd)),compare)}var t=arr[k],i=left,j=right;for(swap(arr,left,k),compare(arr[right],t)>0&&swap(arr,left,right);i<j;){for(swap(arr,i,j),i++,j--;compare(arr[i],t)<0;)i++;for(;compare(arr[j],t)>0;)j--}0===compare(arr[left],t)?swap(arr,left,j):swap(arr,++j,right),j<=k&&(left=j+1),k<=j&&(right=j-1)}}function swap(arr,i,j){var tmp=arr[i];arr[i]=arr[j],arr[j]=tmp}function defaultCompare(a,b){return a<b?-1:a>b?1:0}return quickselect}()}(quickselect$1);var h=quickselect$1.exports;class TinyQueue{constructor(data=[],compare=defaultCompare$1){if(this.data=data,this.length=this.data.length,this.compare=compare,this.length>0)for(let i=(this.length>>1)-1;i>=0;i--)this._down(i)}push(item){this.data.push(item),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const top=this.data[0],bottom=this.data.pop();return this.length--,this.length>0&&(this.data[0]=bottom,this._down(0)),top}peek(){return this.data[0]}_up(pos){const{data,compare}=this,item=data[pos];for(;pos>0;){const parent=pos-1>>1,current=data[parent];if(compare(item,current)>=0)break;data[pos]=current,pos=parent}data[pos]=item}_down(pos){const{data,compare}=this,halfLength=this.length>>1,item=data[pos];for(;pos<halfLength;){let left=1+(pos<<1),best=data[left];const right=left+1;if(right<this.length&&compare(data[right],best)<0&&(left=right,best=data[right]),compare(best,item)>=0)break;data[pos]=best,pos=left}data[pos]=item}}function defaultCompare$1(a,b){return a<b?-1:a>b?1:0}var earcut$1={exports:{}};function earcut(data,holeIndices,dim){dim=dim||2;var minX,minY,maxX,maxY,x,y,invSize,hasHoles=holeIndices&&holeIndices.length,outerLen=hasHoles?holeIndices[0]*dim:data.length,outerNode=linkedList(data,0,outerLen,dim,!0),triangles=[];if(!outerNode||outerNode.next===outerNode.prev)return triangles;if(hasHoles&&(outerNode=function(data,holeIndices,outerNode,dim){var i,len,list,queue=[];for(i=0,len=holeIndices.length;i<len;i++)(list=linkedList(data,holeIndices[i]*dim,i<len-1?holeIndices[i+1]*dim:data.length,dim,!1))===list.next&&(list.steiner=!0),queue.push(getLeftmost(list));for(queue.sort(compareX),i=0;i<queue.length;i++)outerNode=eliminateHole(queue[i],outerNode);return outerNode}(data,holeIndices,outerNode,dim)),data.length>80*dim){minX=maxX=data[0],minY=maxY=data[1];for(var i=dim;i<outerLen;i+=dim)(x=data[i])<minX&&(minX=x),(y=data[i+1])<minY&&(minY=y),x>maxX&&(maxX=x),y>maxY&&(maxY=y);invSize=0!==(invSize=Math.max(maxX-minX,maxY-minY))?32767/invSize:0}return earcutLinked(outerNode,triangles,dim,minX,minY,invSize,0),triangles}function linkedList(data,start,end,dim,clockwise){var i,last;if(clockwise===signedArea(data,start,end,dim)>0)for(i=start;i<end;i+=dim)last=insertNode(i,data[i],data[i+1],last);else for(i=end-dim;i>=start;i-=dim)last=insertNode(i,data[i],data[i+1],last);return last&&equals(last,last.next)&&(removeNode(last),last=last.next),last}function filterPoints(start,end){if(!start)return start;end||(end=start);var again,p=start;do{if(again=!1,p.steiner||!equals(p,p.next)&&0!==area(p.prev,p,p.next))p=p.next;else{if(removeNode(p),(p=end=p.prev)===p.next)break;again=!0}}while(again||p!==end);return end}function earcutLinked(ear,triangles,dim,minX,minY,invSize,pass){if(ear){!pass&&invSize&&function(start,minX,minY,invSize){var p=start;do{0===p.z&&(p.z=zOrder(p.x,p.y,minX,minY,invSize)),p.prevZ=p.prev,p.nextZ=p.next,p=p.next}while(p!==start);p.prevZ.nextZ=null,p.prevZ=null,function(list){var i,p,q,e,tail,numMerges,pSize,qSize,inSize=1;do{for(p=list,list=null,tail=null,numMerges=0;p;){for(numMerges++,q=p,pSize=0,i=0;i<inSize&&(pSize++,q=q.nextZ);i++);for(qSize=inSize;pSize>0||qSize>0&&q;)0!==pSize&&(0===qSize||!q||p.z<=q.z)?(e=p,p=p.nextZ,pSize--):(e=q,q=q.nextZ,qSize--),tail?tail.nextZ=e:list=e,e.prevZ=tail,tail=e;p=q}tail.nextZ=null,inSize*=2}while(numMerges>1)}(p)}(ear,minX,minY,invSize);for(var prev,next,stop=ear;ear.prev!==ear.next;)if(prev=ear.prev,next=ear.next,invSize?isEarHashed(ear,minX,minY,invSize):isEar(ear))triangles.push(prev.i/dim|0),triangles.push(ear.i/dim|0),triangles.push(next.i/dim|0),removeNode(ear),ear=next.next,stop=next.next;else if((ear=next)===stop){pass?1===pass?earcutLinked(ear=cureLocalIntersections(filterPoints(ear),triangles,dim),triangles,dim,minX,minY,invSize,2):2===pass&&splitEarcut(ear,triangles,dim,minX,minY,invSize):earcutLinked(filterPoints(ear),triangles,dim,minX,minY,invSize,1);break}}}function isEar(ear){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var ax=a.x,bx=b.x,cx=c.x,ay=a.y,by=b.y,cy=c.y,x0=ax<bx?ax<cx?ax:cx:bx<cx?bx:cx,y0=ay<by?ay<cy?ay:cy:by<cy?by:cy,x1=ax>bx?ax>cx?ax:cx:bx>cx?bx:cx,y1=ay>by?ay>cy?ay:cy:by>cy?by:cy,p=c.next;p!==a;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&pointInTriangle(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function isEarHashed(ear,minX,minY,invSize){var a=ear.prev,b=ear,c=ear.next;if(area(a,b,c)>=0)return!1;for(var ax=a.x,bx=b.x,cx=c.x,ay=a.y,by=b.y,cy=c.y,x0=ax<bx?ax<cx?ax:cx:bx<cx?bx:cx,y0=ay<by?ay<cy?ay:cy:by<cy?by:cy,x1=ax>bx?ax>cx?ax:cx:bx>cx?bx:cx,y1=ay>by?ay>cy?ay:cy:by>cy?by:cy,minZ=zOrder(x0,y0,minX,minY,invSize),maxZ=zOrder(x1,y1,minX,minY,invSize),p=ear.prevZ,n=ear.nextZ;p&&p.z>=minZ&&n&&n.z<=maxZ;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&p!==a&&p!==c&&pointInTriangle(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,n.x>=x0&&n.x<=x1&&n.y>=y0&&n.y<=y1&&n!==a&&n!==c&&pointInTriangle(ax,ay,bx,by,cx,cy,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}for(;p&&p.z>=minZ;){if(p.x>=x0&&p.x<=x1&&p.y>=y0&&p.y<=y1&&p!==a&&p!==c&&pointInTriangle(ax,ay,bx,by,cx,cy,p.x,p.y)&&area(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;n&&n.z<=maxZ;){if(n.x>=x0&&n.x<=x1&&n.y>=y0&&n.y<=y1&&n!==a&&n!==c&&pointInTriangle(ax,ay,bx,by,cx,cy,n.x,n.y)&&area(n.prev,n,n.next)>=0)return!1;n=n.nextZ}return!0}function cureLocalIntersections(start,triangles,dim){var p=start;do{var a=p.prev,b=p.next.next;!equals(a,b)&&intersects$1(a,p,p.next,b)&&locallyInside(a,b)&&locallyInside(b,a)&&(triangles.push(a.i/dim|0),triangles.push(p.i/dim|0),triangles.push(b.i/dim|0),removeNode(p),removeNode(p.next),p=start=b),p=p.next}while(p!==start);return filterPoints(p)}function splitEarcut(start,triangles,dim,minX,minY,invSize){var a=start;do{for(var b=a.next.next;b!==a.prev;){if(a.i!==b.i&&isValidDiagonal(a,b)){var c=splitPolygon(a,b);return a=filterPoints(a,a.next),c=filterPoints(c,c.next),earcutLinked(a,triangles,dim,minX,minY,invSize,0),void earcutLinked(c,triangles,dim,minX,minY,invSize,0)}b=b.next}a=a.next}while(a!==start)}function compareX(a,b){return a.x-b.x}function eliminateHole(hole,outerNode){var bridge=function(hole,outerNode){var m,p=outerNode,hx=hole.x,hy=hole.y,qx=-1/0;do{if(hy<=p.y&&hy>=p.next.y&&p.next.y!==p.y){var x=p.x+(hy-p.y)*(p.next.x-p.x)/(p.next.y-p.y);if(x<=hx&&x>qx&&(qx=x,m=p.x<p.next.x?p:p.next,x===hx))return m}p=p.next}while(p!==outerNode);if(!m)return null;var tan,stop=m,mx=m.x,my=m.y,tanMin=1/0;p=m;do{hx>=p.x&&p.x>=mx&&hx!==p.x&&pointInTriangle(hy<my?hx:qx,hy,mx,my,hy<my?qx:hx,hy,p.x,p.y)&&(tan=Math.abs(hy-p.y)/(hx-p.x),locallyInside(p,hole)&&(tan<tanMin||tan===tanMin&&(p.x>m.x||p.x===m.x&&sectorContainsSector(m,p)))&&(m=p,tanMin=tan)),p=p.next}while(p!==stop);return m}(hole,outerNode);if(!bridge)return outerNode;var bridgeReverse=splitPolygon(bridge,hole);return filterPoints(bridgeReverse,bridgeReverse.next),filterPoints(bridge,bridge.next)}function sectorContainsSector(m,p){return area(m.prev,m,p.prev)<0&&area(p.next,m,m.next)<0}function zOrder(x,y,minX,minY,invSize){return(x=1431655765&((x=858993459&((x=252645135&((x=16711935&((x=(x-minX)*invSize|0)|x<<8))|x<<4))|x<<2))|x<<1))|(y=1431655765&((y=858993459&((y=252645135&((y=16711935&((y=(y-minY)*invSize|0)|y<<8))|y<<4))|y<<2))|y<<1))<<1}function getLeftmost(start){var p=start,leftmost=start;do{(p.x<leftmost.x||p.x===leftmost.x&&p.y<leftmost.y)&&(leftmost=p),p=p.next}while(p!==start);return leftmost}function pointInTriangle(ax,ay,bx,by,cx,cy,px,py){return(cx-px)*(ay-py)>=(ax-px)*(cy-py)&&(ax-px)*(by-py)>=(bx-px)*(ay-py)&&(bx-px)*(cy-py)>=(cx-px)*(by-py)}function isValidDiagonal(a,b){return a.next.i!==b.i&&a.prev.i!==b.i&&!function(a,b){var p=a;do{if(p.i!==a.i&&p.next.i!==a.i&&p.i!==b.i&&p.next.i!==b.i&&intersects$1(p,p.next,a,b))return!0;p=p.next}while(p!==a);return!1}(a,b)&&(locallyInside(a,b)&&locallyInside(b,a)&&function(a,b){var p=a,inside=!1,px=(a.x+b.x)/2,py=(a.y+b.y)/2;do{p.y>py!=p.next.y>py&&p.next.y!==p.y&&px<(p.next.x-p.x)*(py-p.y)/(p.next.y-p.y)+p.x&&(inside=!inside),p=p.next}while(p!==a);return inside}(a,b)&&(area(a.prev,a,b.prev)||area(a,b.prev,b))||equals(a,b)&&area(a.prev,a,a.next)>0&&area(b.prev,b,b.next)>0)}function area(p,q,r){return(q.y-p.y)*(r.x-q.x)-(q.x-p.x)*(r.y-q.y)}function equals(p1,p2){return p1.x===p2.x&&p1.y===p2.y}function intersects$1(p1,q1,p2,q2){var o1=sign(area(p1,q1,p2)),o2=sign(area(p1,q1,q2)),o3=sign(area(p2,q2,p1)),o4=sign(area(p2,q2,q1));return o1!==o2&&o3!==o4||(!(0!==o1||!onSegment(p1,p2,q1))||(!(0!==o2||!onSegment(p1,q2,q1))||(!(0!==o3||!onSegment(p2,p1,q2))||!(0!==o4||!onSegment(p2,q1,q2)))))}function onSegment(p,q,r){return q.x<=Math.max(p.x,r.x)&&q.x>=Math.min(p.x,r.x)&&q.y<=Math.max(p.y,r.y)&&q.y>=Math.min(p.y,r.y)}function sign(num){return num>0?1:num<0?-1:0}function locallyInside(a,b){return area(a.prev,a,a.next)<0?area(a,b,a.next)>=0&&area(a,a.prev,b)>=0:area(a,b,a.prev)<0||area(a,a.next,b)<0}function splitPolygon(a,b){var a2=new Node(a.i,a.x,a.y),b2=new Node(b.i,b.x,b.y),an=a.next,bp=b.prev;return a.next=b,b.prev=a,a2.next=an,an.prev=a2,b2.next=a2,a2.prev=b2,bp.next=b2,b2.prev=bp,b2}function insertNode(i,x,y,last){var p=new Node(i,x,y);return last?(p.next=last.next,p.prev=last,last.next.prev=p,last.next=p):(p.prev=p,p.next=p),p}function removeNode(p){p.next.prev=p.prev,p.prev.next=p.next,p.prevZ&&(p.prevZ.nextZ=p.nextZ),p.nextZ&&(p.nextZ.prevZ=p.prevZ)}function Node(i,x,y){this.i=i,this.x=x,this.y=y,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function signedArea(data,start,end,dim){for(var sum=0,i=start,j=end-dim;i<end;i+=dim)sum+=(data[j]-data[i])*(data[i+1]+data[j+1]),j=i;return sum}earcut$1.exports=earcut,earcut$1.exports.default=earcut,earcut.deviation=function(data,holeIndices,dim,triangles){var hasHoles=holeIndices&&holeIndices.length,polygonArea=Math.abs(signedArea(data,0,hasHoles?holeIndices[0]*dim:data.length,dim));if(hasHoles)for(var i=0,len=holeIndices.length;i<len;i++){polygonArea-=Math.abs(signedArea(data,holeIndices[i]*dim,i<len-1?holeIndices[i+1]*dim:data.length,dim))}var trianglesArea=0;for(i=0;i<triangles.length;i+=3){var a=triangles[i]*dim,b=triangles[i+1]*dim,c=triangles[i+2]*dim;trianglesArea+=Math.abs((data[a]-data[c])*(data[b+1]-data[a+1])-(data[a]-data[b])*(data[c+1]-data[a+1]))}return 0===polygonArea&&0===trianglesArea?0:Math.abs((trianglesArea-polygonArea)/polygonArea)},earcut.flatten=function(data){for(var dim=data[0][0].length,result={vertices:[],holes:[],dimensions:dim},holeIndex=0,i=0;i<data.length;i++){for(var j=0;j<data[i].length;j++)for(var d=0;d<dim;d++)result.vertices.push(data[i][j][d]);i>0&&result.holes.push(holeIndex+=data[i-1].length)}return result};
/*!
	 * @maptalks/vector-packer v0.92.1
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.com
	 */
const x$4={Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6};function v$2(t,e={}){var n=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)b$3(n,t.features[r],e,r);else b$3(n,"Feature"===t.type?t:{geometry:t},e);return n}function b$3(t,e,n,r){if(e.geometry&&e.geometry.geometry){var i=e.geometry.coordinates,s=e.geometry.type,a=[],o=e.id;if(n.promoteId?o=e.properties[n.promoteId]:n.generateId&&(o=r||0),"Point"===s)w$2(i,a);else if("MultiPoint"===s)for(var l=0;l<i.length;l++)w$2(i[l],a);else if("LineString"===s)A$2([i],a);else if("MultiLineString"===s){if(n.lineMetrics){for(l=0;l<i.length;l++)k$4(i[l],a=[]),t.push(_$4(o,"LineString",a,e.properties));return}A$2(i,a)}else if("Polygon"===s)A$2(i,a);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(l=0;l<e.geometry.geometries.length;l++)b$3(t,{id:o,geometry:e.geometry.geometries[l],properties:e.properties},n,r);return}return void console.warn(`Input data type(${s}) is not a valid GeoJSON geometry type.`)}for(l=0;l<i.length;l++){var h=[];A$2(i[l],h),a.push(h)}}t.push(_$4(o,s,a,e.properties))}}function w$2(e,n){const r=new pointGeometry(e[0],e[1]);r.z=100*(e[2]||0),n.push([r])}function k$4(e,n){for(let r=0;r<e.length;r++){const i=new pointGeometry(e[r][0],e[r][1]);i.z=100*(e[r][2]||0),n.push(i)}}function A$2(t,e,n,r){for(var i=0;i<t.length;i++){var s=[];k$4(t[i],s),e.push(s)}}function _$4(t,e,n,r){return{id:void 0===t?null:t,type:x$4[e],geometry:n,properties:r}}
/*!
	 * Codes from mapbox-gl-js
	 * github.com/mapbox/mapbox-gl-js
	 * MIT License
	 */function F$4(t,{width:e,height:n},r,i){if(i){if(i.length!==e*n*r)throw new RangeError("mismatched image size")}else i=new Uint8Array(e*n*r);return t.width=e,t.height=n,t.data=i,t}function P$3(t,{width:e,height:n},r){if(e===t.width&&n===t.height)return;const i=F$4({},{width:e,height:n},r);z$4(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,e),height:Math.min(t.height,n)},r),t.width=e,t.height=n,t.data=i.data}function z$4(t,e,n,r,i,s){if(0===i.width||0===i.height)return e;if(i.width>t.width||i.height>t.height||n.x>t.width-i.width||n.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>e.width||i.height>e.height||r.x>e.width-i.width||r.y>e.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=t.data,o=e.data;if(a===o)return e;for(let l=0;l<i.height;l++){const h=((n.y+l)*t.width+n.x)*s,u=((r.y+l)*e.width+r.x)*s;for(let t=0;t<i.width*s;t++)o[u+t]=a[h+t]}return e}class M$4{constructor(t,e){F$4(this,t,1,e)}resize(t){P$3(this,t,1)}clone(){return new M$4({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,r,i){z$4(t,e,n,r,i,1)}}class T$4{constructor(t,e){F$4(this,t,4,e)}resize(t){P$3(this,t,4)}clone(){return new T$4({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,e,n,r,i){z$4(t,e,n,r,i,4)}}
/*!
	 * Codes from mapbox-gl-js
	 * github.com/mapbox/mapbox-gl-js
	 * MIT License
	 */class S$4{constructor(t,e,{pixelRatio:n}){this.paddedRect=t,this.pixelRatio=n||1,this.padding=e}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.pixelRatio,(this.paddedRect.h-2*this.padding)/this.pixelRatio]}}class C$2{constructor(t){this.glyphMap=t,this.build()}build(){const t=this.glyphMap,n=Object.keys(t).length,r={},i=new ShelfPack(0,0,{autoResize:!0}),s=[],a=n>1?1:0;for(const e in t){const n=t[e],i={x:0,y:0,w:n.data.width+2*a,h:n.data.height+2*a};s.push(i),r[e]=new S$4(i,a,n)}if(i.pack(s,{inPlace:!0}),!D$4(i.w)||!D$4(i.h)){const t=I$3(i.w),e=I$3(i.h);i.resize(t,e)}const o=new T$4({width:i.w,height:i.h});for(const e in t){const n=t[e],i=r[e].paddedRect;T$4.copy(n.data,o,{x:0,y:0},{x:i.x+a,y:i.y+a},n.data)}this.image=o,this.positions=r}}function D$4(t){return 0==(t&t-1)&&0!==t}function I$3(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}
/*!
	 * Codes from mapbox-gl-js
	 * github.com/mapbox/mapbox-gl-js
	 * MIT License
	 * TODO å‡çº§ä¸ºpotpack
	 */class E$4{constructor(t){this.glyphMap=t,this.build()}build(){const t=this.glyphMap,n={},r=new ShelfPack(0,0,{autoResize:!0}),i=[];for(const e in t){const r=t[e],s=n[e]={};for(const t in r){const e=r[+t];if(!e||0===e.bitmap.width||0===e.bitmap.height)continue;const n={x:0,y:0,w:e.bitmap.width+2,h:e.bitmap.height+2};i.push(n),s[t]={rect:n,metrics:e.metrics}}}r.pack(i,{inPlace:!0});const s=new M$4({width:r.w,height:r.h});for(const e in t){const r=t[e];for(const t in r){const i=r[+t];if(!i||0===i.bitmap.width||0===i.bitmap.height)continue;const a=n[e][t].rect;M$4.copy(i.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},i.bitmap)}}this.image=s,this.positions=n}}function O$4(t){return t<65536?Uint16Array:Uint32Array}function L$4(t){return(t=Math.abs(t))<128?Int8Array:t<32768?Int16Array:Float32Array}function R$4(t){return t<256?Uint8Array:t<65536?Uint16Array:Float32Array}function W$4(t,e){const n=new e(t.length),r=n.length;for(let e=0;e<r;e++)n[e]=t[e];return n}function V$4(t){const e=t.type,n=[];if(1===e||4===e)for(let e=0;e<t.geometry.length;e++)w$2(t.geometry[e],n);else if(2===e)A$2(t.geometry,n);else if(3===e)A$2(t.geometry,n);else if(5===e)A$2(t.geometry,n);else if(6===e)for(let e=0;e<t.geometry.length;e++){const r=[];A$2(t.geometry[e],r),n.push(r)}return t.geometry=n,t}function U$4(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function $$4(t){return null==t}function N$4(t){return"number"==typeof t&&!isNaN(t)}function H$4(t){return"object"==typeof t&&!!t}function j$4(t){return!$$4(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function q$5(t){return!$$4(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}const G$4=Object.prototype.hasOwnProperty;function X$5(t,e){return G$4.call(t,e)}const B$4=Math.PI/180;function J$5(t){return t&&isFunctionDefinition(t)&&t.property}function Z$5(t){const{verticalCentimeterToPoint:e,tileRatio:n}=t;return e*n}const K$5={};function Q$5(t,e){if(!Array.isArray(e)){if(e&&void 0!==e.r&&void 0!==e.g&&void 0!==e.b)return t[0]=255*e.r,t[1]=255*e.g,t[2]=255*e.b,t[3]=void 0!==e.a?255*e.a:255,t;e=K$5[e]=K$5[e]||color(e).unitArray()}for(let n=0;n<e.length;n++)t[n]=255*e[n];return 3===e.length&&(t[3]=255),t}const tt$4={textFill:1,textSize:1,textOpacity:1,textDx:1,textDy:1,markerWidth:1,markerHeight:1,markerOpacity:1,markerDx:1,markerDy:1,lineWidth:1,lineColor:1,lineOpacity:1,polygonFill:1,polygonOpacity:1,polygonPatternFileWidth:1,polygonPatternFileOrigin:1},et$4={textName:1,markerTextFitPadding:1,markerTextFit:1,lineGradientProperty:1};var nt$4=Object.freeze({__proto__:null,now:function(){return Date.now()},extend:U$4,isNil:$$4,isNumber:N$4,isInteger:function(t){return(0|t)===t},isObject:H$4,isString:j$4,isFunction:q$5,hasOwn:X$5,join:function(t,e){return t.join?t.join(e||","):Array.prototype.join.call(t,e||",")},toRadian:function(t){return t*B$4},toDegree:function(t){return t/B$4},evaluate:function(t,e,n){return q$5(t)?t(void 0!==n?n:null,e):t},isFnTypeSymbol:J$5,getAltitudeToLocal:Z$5,getTubeSizeScale:function(t){return"centimeter"===t||"cm"===t?1:"millimeter"===t||"mm"===t?.1:100},normalizeColor:Q$5,checkIfIdentityZoomDependent:function(t,e,i){if(Array.isArray(i)||(i=Object.values(i)),!i||!i.length)return!1;if(!tt$4[t])return!1;for(let t=0;t<i.length;t++){const s=i[t]&&(i[t].feature||i[t]);if(!s)continue;const a=s.properties&&s.properties[e];if(a&&isFunctionDefinition(a)&&!interpolated(a).isZoomConstant)return!0}return!1},checkIfZoomFnTypeSymbol:function(t){return!!tt$4[t]||!!et$4[t]}});function rt$4(t){let e=0;for(let n,r,i=0,s=t.length,a=s-1;i<s;a=i++)if(n=t[i],r=t[a],void 0!==n.x){if(n.z||r.z)return 1;e+=(r.x-n.x)*(n.y+r.y)}else{if(n[2]||r[2])return 1;e+=(r[0]-n[0])*(n[1]+r[1])}return e}function st$4(t,e,n){let r=n;return e&&t&&(r=+t[e]),isNaN(r)&&(r=n||0),100*r}function at$4(t,e,n,r,i,s,a){e||0===e||(e=1);const o=st$4(t.properties,n,r),l=o*e;let h=(s?100*s:0)||o;return i?h=st$4(t.properties,i,s):a&&(h=o-st$4(t.properties,a,s)),h*=e,{altitude:l,height:h}}function ot$4(t,e){return e<1/0&&(t.x<0||t.x>e||t.y<0||t.y>e)}function lt$4(t){return null==t}function ht$4(t,e,n){if(t===n||t===e)return t;const r=n-e;return((t-e)%r+r)%r+e}function ut$4(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],s=t[i];let a=n.get(s);a||(a=[],n.set(s,a)),a.push(i)}return n}class ct$4{constructor(t,e,n,r){this.feature=t,this.symbol=e,this.fnTypes=n,this.options=r}getPolygonResource(){let t=this.symbol.polygonPatternFile;const{polygonPatternFileFn:e}=this.fnTypes;return this._getResource(t,e)}getLineResource(){let t=this.symbol.linePatternFile;const{linePatternFileFn:e}=this.fnTypes;return this._getResource(t,e)}_getResource(t,e){return e&&(t=e(this.options.zoom,this.feature.properties)),t}}function pt$4(t,e,n,r){const i=Math.abs(r)>>15,s=i>>1,a=i%2;let o=r%Math.pow(2,15);const l=e+(s<<14)*Math.sign(e),h=n+(a<<14)*Math.sign(n);return t[0]=l,t[1]=h,o=Math.round(o),t[2]=0===o?r<0?-1:0:o,t}const ft$4=Math.pow(2,14),dt$4=Math.pow(2,15);
/*!
	 * a compact version of mapbox-gl-style-spec
	 * based on mapbox-gl-style-spec@13.28.0
	 * https://github.com/mapbox/mapbox-gl-js/tree/main/src/style-spec
	 * LICENSE : ISC
	 */var yt$4,mt$4,gt$4="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},xt$4={exports:{}};function vt$4(t,...e){for(const n of e)for(const e in n)t[e]=n[e];return t}
/*! https://mths.be/punycode v1.3.2 by @mathias */yt$4=xt$4,mt$4=xt$4.exports,function(t){var e=mt$4&&!mt$4.nodeType&&mt$4,n=yt$4&&!yt$4.nodeType&&yt$4,r="object"==typeof gt$4&&gt$4;r.global!==r&&r.window!==r&&r.self!==r||(t=r);var i,s,a=2147483647,o=/^xn--/,l=/[^\x20-\x7E]/,h=/[\x2E\u3002\uFF0E\uFF61]/g,u={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},c=Math.floor,p=String.fromCharCode;function f(t){throw RangeError(u[t])}function d(t,e){for(var n=t.length,r=[];n--;)r[n]=e(t[n]);return r}function y(t,e){var n=t.split("@"),r="";return n.length>1&&(r=n[0]+"@",t=n[1]),r+d((t=t.replace(h,".")).split("."),e).join(".")}function m(t){for(var e,n,r=[],i=0,s=t.length;i<s;)(e=t.charCodeAt(i++))>=55296&&e<=56319&&i<s?56320==(64512&(n=t.charCodeAt(i++)))?r.push(((1023&e)<<10)+(1023&n)+65536):(r.push(e),i--):r.push(e);return r}function g(t){return d(t,(function(t){var e="";return t>65535&&(e+=p((t-=65536)>>>10&1023|55296),t=56320|1023&t),e+p(t)})).join("")}function x(t,e){return t+22+75*(t<26)-((0!=e)<<5)}function v(t,e,n){var r=0;for(t=n?c(t/700):t>>1,t+=c(t/e);t>455;r+=36)t=c(t/35);return c(r+36*t/(t+38))}function b(t){var e,n,r,i,s,o,l,h,u,p,d,y=[],m=t.length,x=0,b=128,w=72;for((n=t.lastIndexOf("-"))<0&&(n=0),r=0;r<n;++r)t.charCodeAt(r)>=128&&f("not-basic"),y.push(t.charCodeAt(r));for(i=n>0?n+1:0;i<m;){for(s=x,o=1,l=36;i>=m&&f("invalid-input"),((h=(d=t.charCodeAt(i++))-48<10?d-22:d-65<26?d-65:d-97<26?d-97:36)>=36||h>c((a-x)/o))&&f("overflow"),x+=h*o,!(h<(u=l<=w?1:l>=w+26?26:l-w));l+=36)o>c(a/(p=36-u))&&f("overflow"),o*=p;w=v(x-s,e=y.length+1,0==s),c(x/e)>a-b&&f("overflow"),b+=c(x/e),x%=e,y.splice(x++,0,b)}return g(y)}function w(t){var e,n,r,i,s,o,l,h,u,d,y,g,b,w,k,A=[];for(g=(t=m(t)).length,e=128,n=0,s=72,o=0;o<g;++o)(y=t[o])<128&&A.push(p(y));for(r=i=A.length,i&&A.push("-");r<g;){for(l=a,o=0;o<g;++o)(y=t[o])>=e&&y<l&&(l=y);for(l-e>c((a-n)/(b=r+1))&&f("overflow"),n+=(l-e)*b,e=l,o=0;o<g;++o)if((y=t[o])<e&&++n>a&&f("overflow"),y==e){for(h=n,u=36;!(h<(d=u<=s?1:u>=s+26?26:u-s));u+=36)A.push(p(x(d+(k=h-d)%(w=36-d),0))),h=c(k/w);A.push(p(x(h,0))),s=v(n,b,r==i),n=0,++r}++n,++e}return A.join("")}if(i={version:"1.3.2",ucs2:{decode:m,encode:g},decode:b,encode:w,toASCII:function(t){return y(t,(function(t){return l.test(t)?"xn--"+w(t):t}))},toUnicode:function(t){return y(t,(function(t){return o.test(t)?b(t.slice(4).toLowerCase()):t}))}},e&&n)if(yt$4.exports==e)n.exports=i;else for(s in i)i.hasOwnProperty(s)&&(e[s]=i[s]);else t.punycode=i}(gt$4);class bt$4 extends Error{constructor(t,e){super(e),this.message=e,this.key=t}}var wt$4=bt$4;class kt$4{constructor(t,e=[]){this.parent=t,this.bindings={};for(const[t,n]of e)this.bindings[t]=n}concat(t){return new kt$4(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(t+" not found in scope.")}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var At$4=kt$4;const _t$4={kind:"null"},Ft$4={kind:"number"},Pt$4={kind:"string"},zt$3={kind:"boolean"},Mt$4={kind:"color"},Tt$4={kind:"object"},St$4={kind:"value"},Ct$4={kind:"collator"},Dt$4={kind:"formatted"},It$4={kind:"resolvedImage"};function Et$4(t,e){return{kind:"array",itemType:t,N:e}}function Ot$4(t){if("array"===t.kind){const e=Ot$4(t.itemType);return"number"==typeof t.N?`array<${e}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${e}>`}return t.kind}const Lt$4=[_t$4,Ft$4,Pt$4,zt$3,Mt$4,Dt$4,Tt$4,Et$4(St$4),It$4];function Rt$4(t,e){if("error"===e.kind)return null;if("array"===t.kind){if("array"===e.kind&&(0===e.N&&"value"===e.itemType.kind||!Rt$4(t.itemType,e.itemType))&&("number"!=typeof t.N||t.N===e.N))return null}else{if(t.kind===e.kind)return null;if("value"===t.kind)for(const t of Lt$4)if(!Rt$4(t,e))return null}return`Expected ${Ot$4(t)} but found ${Ot$4(e)} instead.`}function Wt$3(t,e){return e.some((e=>e.kind===t.kind))}function Vt$3(t,e){return e.some((e=>"null"===e?null===t:"array"===e?Array.isArray(t):"object"===e?t&&!Array.isArray(t)&&"object"==typeof t:e===typeof t))}var Ut$3,$t$3={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Nt$4(t){return(t=Math.round(t))<0?0:t>255?255:t}function jt$3(t){return Nt$4("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function qt$3(t){return function(t){return t<0?0:t>1?1:t}("%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))}function Gt$3(t,e,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?t+(e-t)*n*6:2*n<1?e:3*n<2?t+(e-t)*(2/3-n)*6:t}try{Ut$3={}.parseCSSColor=function(t){var e,n=t.replace(/ /g,"").toLowerCase();if(n in $t$3)return $t$3[n].slice();if("#"===n[0])return 4===n.length?(e=parseInt(n.substr(1),16))>=0&&e<=4095?[(3840&e)>>4|(3840&e)>>8,240&e|(240&e)>>4,15&e|(15&e)<<4,1]:null:7===n.length&&(e=parseInt(n.substr(1),16))>=0&&e<=16777215?[(16711680&e)>>16,(65280&e)>>8,255&e,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var s=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),o=1;switch(s){case"rgba":if(4!==a.length)return null;o=qt$3(a.pop());case"rgb":return 3!==a.length?null:[jt$3(a[0]),jt$3(a[1]),jt$3(a[2]),o];case"hsla":if(4!==a.length)return null;o=qt$3(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,h=qt$3(a[1]),u=qt$3(a[2]),c=u<=.5?u*(h+1):u+h-u*h,p=2*u-c;return[Nt$4(255*Gt$3(p,c,l+1/3)),Nt$4(255*Gt$3(p,c,l)),Nt$4(255*Gt$3(p,c,l-1/3)),o];default:return null}}return null}}catch(t){}class Xt$3{constructor(t,e,n,r=1){this.r=t,this.g=e,this.b=n,this.a=r}static parse(t){if(!t)return;if(t instanceof Xt$3)return t;if("string"!=typeof t)return;const e=Ut$3(t);return e?new Xt$3(e[0]/255*e[3],e[1]/255*e[3],e[2]/255*e[3],e[3]):void 0}toString(){const[t,e,n,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(e)},${Math.round(n)},${r})`}toArray(){const{r:t,g:e,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*e/r,255*n/r,r]}toArray01(){const{r:t,g:e,b:n,a:r}=this;return 0===r?[0,0,0,0]:[t/r,e/r,n/r,r]}toArray01PremultipliedAlpha(){const{r:t,g:e,b:n,a:r}=this;return[t,e,n,r]}}Xt$3.black=new Xt$3(0,0,0,1),Xt$3.white=new Xt$3(1,1,1,1),Xt$3.transparent=new Xt$3(0,0,0,0),Xt$3.red=new Xt$3(1,0,0,1),Xt$3.blue=new Xt$3(0,0,1,1);var Bt$4=Xt$3;class Jt$3{constructor(t,e,n){this.sensitivity=t?e?"variant":"case":e?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,e){return this.collator.compare(t,e)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Zt$3{constructor(t,e,n,r,i){this.text=t.normalize?t.normalize():t,this.image=e,this.scale=n,this.fontStack=r,this.textColor=i}}class Yt$3{constructor(t){this.sections=t}static fromString(t){return new Yt$3([new Zt$3(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some((t=>0!==t.text.length||t.image&&0!==t.image.name.length))}static factory(t){return t instanceof Yt$3?t:Yt$3.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map((t=>t.text)).join("")}serialize(){const t=["format"];for(const e of this.sections){if(e.image){t.push(["image",e.image.name]);continue}t.push(e.text);const n={};e.fontStack&&(n["text-font"]=["literal",e.fontStack.split(",")]),e.scale&&(n["font-scale"]=e.scale),e.textColor&&(n["text-color"]=["rgba"].concat(e.textColor.toArray())),t.push(n)}return t}}class Kt$3{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new Kt$3({name:t,available:!1}):null}serialize(){return["image",this.name]}}function Qt$3(t,e,n,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof e&&e>=0&&e<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,e,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,e,n,r]:[t,e,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function te$3(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof Bt$4)return!0;if(t instanceof Jt$3)return!0;if(t instanceof Yt$3)return!0;if(t instanceof Kt$3)return!0;if(Array.isArray(t)){for(const e of t)if(!te$3(e))return!1;return!0}if("object"==typeof t){for(const e in t)if(!te$3(t[e]))return!1;return!0}return!1}function ee$3(t){if(null===t)return _t$4;if("string"==typeof t)return Pt$4;if("boolean"==typeof t)return zt$3;if("number"==typeof t)return Ft$4;if(t instanceof Bt$4)return Mt$4;if(t instanceof Jt$3)return Ct$4;if(t instanceof Yt$3)return Dt$4;if(t instanceof Kt$3)return It$4;if(Array.isArray(t)){const e=t.length;let n;for(const e of t){const t=ee$3(e);if(n){if(n===t)continue;n=St$4;break}n=t}return Et$4(n||St$4,e)}return Tt$4}function ne$3(t){const e=typeof t;return null===t?"":"string"===e||"number"===e||"boolean"===e?String(t):t instanceof Bt$4||t instanceof Yt$3||t instanceof Kt$3?t.toString():JSON.stringify(t)}class re$3{constructor(t,e){this.type=t,this.value=e}static parse(t,e){if(2!==t.length)return e.error(`'literal' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!te$3(t[1]))return e.error("invalid value");const n=t[1];let r=ee$3(n);const i=e.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new re$3(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Bt$4?["rgba"].concat(this.value.toArray()):this.value instanceof Yt$3?this.value.serialize():this.value}}var ie$3=re$3,se$3=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const ae$3={string:Pt$4,number:Ft$4,boolean:zt$3,object:Tt$4};class oe$3{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");let n,r=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const n=t[1];if("string"!=typeof n||!(n in ae$3)||"object"===n)return e.error('The item type argument of "array" must be one of string, number, boolean',1);i=ae$3[n],r++}else i=St$4;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return e.error('The length argument to "array" must be a positive integer literal',2);s=t[2],r++}n=Et$4(i,s)}else n=ae$3[i];const s=[];for(;r<t.length;r++){const n=e.parse(t[r],r,St$4);if(!n)return null;s.push(n)}return new oe$3(n,s)}evaluate(t){for(let e=0;e<this.args.length;e++){const n=this.args[e].evaluate(t);if(!Rt$4(this.type,ee$3(n)))return n;if(e===this.args.length-1)throw new se$3(`Expected value to be of type ${Ot$4(this.type)}, but found ${Ot$4(ee$3(n))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=this.type,e=[t.kind];if("array"===t.kind){const n=t.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){e.push(n.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&e.push(r)}}return e.concat(this.args.map((t=>t.serialize())))}}var le$3=oe$3;class he$3{constructor(t){this.type=Dt$4,this.sections=t}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[1];if(!Array.isArray(n)&&"object"==typeof n)return e.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=t.length-1;++n){const s=t[n];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=e.parse(s["font-scale"],1,Ft$4),!t))return null;let n=null;if(s["text-font"]&&(n=e.parse(s["text-font"],1,Et$4(Pt$4)),!n))return null;let a=null;if(s["text-color"]&&(a=e.parse(s["text-color"],1,Mt$4),!a))return null;const o=r[r.length-1];o.scale=t,o.font=n,o.textColor=a}else{const s=e.parse(t[n],1,St$4);if(!s)return null;const a=s.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return e.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:s,scale:null,font:null,textColor:null})}}return new he$3(r)}evaluate(t){return new Yt$3(this.sections.map((e=>{const n=e.content.evaluate(t);return ee$3(n)===It$4?new Zt$3("",n,null,null,null):new Zt$3(ne$3(n),null,e.scale?e.scale.evaluate(t):null,e.font?e.font.evaluate(t).join(","):null,e.textColor?e.textColor.evaluate(t):null)})))}eachChild(t){for(const e of this.sections)t(e.content),e.scale&&t(e.scale),e.font&&t(e.font),e.textColor&&t(e.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const e of this.sections){t.push(e.content.serialize());const n={};e.scale&&(n["font-scale"]=e.scale.serialize()),e.font&&(n["text-font"]=e.font.serialize()),e.textColor&&(n["text-color"]=e.textColor.serialize()),t.push(n)}return t}}class ue$3{constructor(t){this.type=It$4,this.input=t}static parse(t,e){if(2!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,Pt$4);return n?new ue$3(n):e.error("No image name provided.")}evaluate(t){const e=this.input.evaluate(t),n=Kt$3.fromString(e);return n&&t.availableImages&&(n.available=t.availableImages.indexOf(e)>-1),n}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const ce$3={"to-boolean":zt$3,"to-color":Mt$4,"to-number":Ft$4,"to-string":Pt$4};class pe$3{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expected at least one argument.");const n=t[0];if(("to-boolean"===n||"to-string"===n)&&2!==t.length)return e.error("Expected one argument.");const r=ce$3[n],i=[];for(let n=1;n<t.length;n++){const r=e.parse(t[n],n,St$4);if(!r)return null;i.push(r)}return new pe$3(r,i)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let e,n;for(const r of this.args){if(e=r.evaluate(t),n=null,e instanceof Bt$4)return e;if("string"==typeof e){const n=t.parseColor(e);if(n)return n}else if(Array.isArray(e)&&(n=e.length<3||e.length>4?`Invalid rbga value ${JSON.stringify(e)}: expected an array containing either three or four numeric values.`:Qt$3(e[0],e[1],e[2],e[3]),!n))return new Bt$4(e[0]/255,e[1]/255,e[2]/255,e[3])}throw new se$3(n||`Could not parse color from value '${"string"==typeof e?e:String(JSON.stringify(e))}'`)}if("number"===this.type.kind){let e=null;for(const n of this.args){if(e=n.evaluate(t),null===e)return 0;const r=Number(e);if(!isNaN(r))return r}throw new se$3(`Could not convert ${JSON.stringify(e)} to number.`)}return"formatted"===this.type.kind?Yt$3.fromString(ne$3(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?Kt$3.fromString(ne$3(this.args[0].evaluate(t))):ne$3(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){if("formatted"===this.type.kind)return new he$3([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new ue$3(this.args[0]).serialize();const t=["to-"+this.type.kind];return this.eachChild((e=>{t.push(e.serialize())})),t}}var fe$3=pe$3;const de$3=["Unknown","Point","LineString","Polygon"];var ye$3=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?de$3[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,e=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*e-t[0])+this.featureDistanceData.bearing[1]*(r*e-t[1])}return 0}parseColor(t){let e=this._parseColorCache[t];return e||(e=this._parseColorCache[t]=Bt$4.parse(t)),e}};class me$3{constructor(t,e,n,r){this.name=t,this.type=e,this._evaluate=n,this.args=r}evaluate(t){return this._evaluate(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map((t=>t.serialize())))}static parse(t,e){const n=t[0],r=me$3.definitions[n];if(!r)return e.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=s.filter((([e])=>!Array.isArray(e)||e.length===t.length-1));let o=null;for(const[r,s]of a){o=new Ne$3(e.registry,e.path,null,e.scope);const a=[];let l=!1;for(let e=1;e<t.length;e++){const n=t[e],i=Array.isArray(r)?r[e-1]:r.type,s=o.parse(n,1+a.length,i);if(!s){l=!0;break}a.push(s)}if(!l)if(Array.isArray(r)&&r.length!==a.length)o.error(`Expected ${r.length} arguments, but found ${a.length} instead.`);else{for(let t=0;t<a.length;t++){const e=Array.isArray(r)?r[t]:r.type,n=a[t];o.concat(t+1).checkSubtype(e,n.type)}if(0===o.errors.length)return new me$3(n,i,s,a)}}if(1===a.length)e.errors.push(...o.errors);else{const n=(a.length?a:s).map((([t])=>{return e=t,Array.isArray(e)?`(${e.map(Ot$4).join(", ")})`:`(${Ot$4(e.type)}...)`;var e})).join(" | "),r=[];for(let n=1;n<t.length;n++){const i=e.parse(t[n],1+r.length);if(!i)return null;r.push(Ot$4(i.type))}e.error(`Expected arguments of type ${n}, but found (${r.join(", ")}) instead.`)}return null}static register(t,e){me$3.definitions=e;for(const n in e)t[n]=me$3}}var ge$3=me$3;class xe$3{constructor(t,e,n){this.type=Ct$4,this.locale=n,this.caseSensitive=t,this.diacriticSensitive=e}static parse(t,e){if(2!==t.length)return e.error("Expected one argument.");const n=t[1];if("object"!=typeof n||Array.isArray(n))return e.error("Collator options argument must be an object.");const r=e.parse(void 0!==n["case-sensitive"]&&n["case-sensitive"],1,zt$3);if(!r)return null;const i=e.parse(void 0!==n["diacritic-sensitive"]&&n["diacritic-sensitive"],1,zt$3);if(!i)return null;let s=null;return n.locale&&(s=e.parse(n.locale,1,Pt$4),!s)?null:new xe$3(r,i,s)}evaluate(t){return new Jt$3(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}function ve$3(t,e){t[0]=Math.min(t[0],e[0]),t[1]=Math.min(t[1],e[1]),t[2]=Math.max(t[2],e[0]),t[3]=Math.max(t[3],e[1])}function be$3(t,e){return!(t[0]<=e[0]||t[2]>=e[2]||t[1]<=e[1]||t[3]>=e[3])}function we$3(t,e){const n=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,e.z);return[Math.round(n*i*8192),Math.round(r*i*8192)]}function ke$3(t,e,n){const r=t[0]-e[0],i=t[1]-e[1],s=t[0]-n[0],a=t[1]-n[1];return r*a-s*i==0&&r*s<=0&&i*a<=0}function Ae$3(t,e){let n=!1;for(let a=0,o=e.length;a<o;a++){const o=e[a];for(let e=0,a=o.length;e<a-1;e++){if(ke$3(t,o[e],o[e+1]))return!1;(i=o[e])[1]>(r=t)[1]!=(s=o[e+1])[1]>r[1]&&r[0]<(s[0]-i[0])*(r[1]-i[1])/(s[1]-i[1])+i[0]&&(n=!n)}}var r,i,s;return n}function _e$3(t,e){for(let n=0;n<e.length;n++)if(Ae$3(t,e[n]))return!0;return!1}function Fe$3(t,e,n,r){const i=r[0]-n[0],s=r[1]-n[1],a=(t[0]-n[0])*s-i*(t[1]-n[1]),o=(e[0]-n[0])*s-i*(e[1]-n[1]);return a>0&&o<0||a<0&&o>0}function Pe$3(t,e,n){for(const h of n)for(let n=0;n<h.length-1;++n)if(void 0,void 0,0!=(o=[(a=h[n+1])[0]-(s=h[n])[0],a[1]-s[1]])[0]*(l=[(i=e)[0]-(r=t)[0],i[1]-r[1]])[1]-o[1]*l[0]&&Fe$3(r,i,s,a)&&Fe$3(s,a,r,i))return!0;var r,i,s,a,o,l;return!1}function ze$3(t,e){for(let n=0;n<t.length;++n)if(!Ae$3(t[n],e))return!1;for(let n=0;n<t.length-1;++n)if(Pe$3(t[n],t[n+1],e))return!1;return!0}function Me$3(t,e){for(let n=0;n<e.length;n++)if(ze$3(t,e[n]))return!0;return!1}function Te$3(t,e,n){const r=[];for(let i=0;i<t.length;i++){const s=[];for(let r=0;r<t[i].length;r++){const a=we$3(t[i][r],n);ve$3(e,a),s.push(a)}r.push(s)}return r}function Se$3(t,e,n){const r=[];for(let i=0;i<t.length;i++){const s=Te$3(t[i],e,n);r.push(s)}return r}function Ce$3(t,e,n,r){if(t[0]<n[0]||t[0]>n[2]){const e=.5*r;let i=t[0]-n[0]>e?-r:n[0]-t[0]>e?r:0;0===i&&(i=t[0]-n[2]>e?-r:n[2]-t[0]>e?r:0),t[0]+=i}ve$3(e,t)}function De$3(t,e,n,r){const i=8192*Math.pow(2,r.z),s=[8192*r.x,8192*r.y],a=[];if(!t)return a;for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];Ce$3(r,e,n,i),a.push(r)}return a}function Ie$3(t,e,n,r){const i=8192*Math.pow(2,r.z),s=[8192*r.x,8192*r.y],a=[];if(!t)return a;for(const n of t){const t=[];for(const r of n){const n=[r.x+s[0],r.y+s[1]];ve$3(e,n),t.push(n)}a.push(t)}if(e[2]-e[0]<=i/2){(o=e)[0]=o[1]=1/0,o[2]=o[3]=-1/0;for(const t of a)for(const r of t)Ce$3(r,e,n,i)}var o;return a}class Ee$3{constructor(t,e){this.type=zt$3,this.geojson=t,this.geometries=e}static parse(t,e){if(2!==t.length)return e.error(`'within' expression requires exactly one argument, but found ${t.length-1} instead.`);if(te$3(t[1])){const e=t[1];if("FeatureCollection"===e.type)for(let t=0;t<e.features.length;++t){const n=e.features[t].geometry.type;if("Polygon"===n||"MultiPolygon"===n)return new Ee$3(e,e.features[t].geometry)}else if("Feature"===e.type){const t=e.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new Ee$3(e,e.geometry)}else if("Polygon"===e.type||"MultiPolygon"===e.type)return new Ee$3(e,e)}return e.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const s=Te$3(e.coordinates,r,i),a=De$3(t.geometry(),n,r,i);if(!be$3(n,r))return!1;for(const t of a)if(!Ae$3(t,s))return!1}if("MultiPolygon"===e.type){const s=Se$3(e.coordinates,r,i),a=De$3(t.geometry(),n,r,i);if(!be$3(n,r))return!1;for(const t of a)if(!_e$3(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,e){const n=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===e.type){const s=Te$3(e.coordinates,r,i),a=Ie$3(t.geometry(),n,r,i);if(!be$3(n,r))return!1;for(const t of a)if(!ze$3(t,s))return!1}if("MultiPolygon"===e.type){const s=Se$3(e.coordinates,r,i),a=Ie$3(t.geometry(),n,r,i);if(!be$3(n,r))return!1;for(const t of a)if(!Me$3(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var Oe$3=Ee$3;function Le$3(t){if(t instanceof ge$3){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof Oe$3)return!1;let e=!0;return t.eachChild((t=>{e&&!Le$3(t)&&(e=!1)})),e}function Re$3(t){if(t instanceof ge$3&&"feature-state"===t.name)return!1;let e=!0;return t.eachChild((t=>{e&&!Re$3(t)&&(e=!1)})),e}function We$3(t,e){if(t instanceof ge$3&&e.indexOf(t.name)>=0)return!1;let n=!0;return t.eachChild((t=>{n&&!We$3(t,e)&&(n=!1)})),n}class Ve$3{constructor(t,e){this.type=e.type,this.name=t,this.boundExpression=e}static parse(t,e){if(2!==t.length||"string"!=typeof t[1])return e.error("'var' expression requires exactly one string literal argument.");const n=t[1];return e.scope.has(n)?new Ve$3(n,e.scope.get(n)):e.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var Ue$3=Ve$3;class $e$3{constructor(t,e=[],n,r=new At$4,i=[]){this.registry=t,this.path=e,this.key=e.map((t=>`[${t}]`)).join(""),this.scope=r,this.errors=i,this.expectedType=n}parse(t,e,n,r,i={}){return e?this.concat(e,n,r)._parse(t,i):this._parse(t,i)}_parse(t,e){function n(t,e,n){return"assert"===n?new le$3(e,[t]):"coerce"===n?new fe$3(e,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[r];if(i){let r=i.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,i=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(t,i))return null}else r=n(r,t,e.typeAnnotation||"coerce");else r=n(r,t,e.typeAnnotation||"assert")}if(!(r instanceof ie$3)&&"resolvedImage"!==r.type.kind&&function t(e){if(e instanceof Ue$3)return t(e.boundExpression);if(e instanceof ge$3&&"error"===e.name)return!1;if(e instanceof xe$3)return!1;if(e instanceof Oe$3)return!1;const n=e instanceof fe$3||e instanceof le$3;let r=!0;return e.eachChild((e=>{r=n?r&&t(e):r&&e instanceof ie$3})),!!r&&(Le$3(e)&&We$3(e,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"]))}(r)){const t=new ye$3;try{r=new ie$3(r.type,r.evaluate(t))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"'undefined' value invalid. Use null instead.":"object"==typeof t?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof t} instead.`)}concat(t,e,n){const r="number"==typeof t?this.path.concat(t):this.path,i=n?this.scope.concat(n):this.scope;return new $e$3(this.registry,r,e||null,i,this.errors)}error(t,...e){const n=`${this.key}${e.map((t=>`[${t}]`)).join("")}`;this.errors.push(new wt$4(n,t))}checkSubtype(t,e){const n=Rt$4(t,e);return n&&this.error(n),n}}var Ne$3=$e$3;function He$3(t,e){const n=t.length-1;let r,i,s=0,a=n,o=0;for(;s<=a;)if(o=Math.floor((s+a)/2),r=t[o],i=t[o+1],r<=e){if(o===n||e<i)return o;s=o+1}else{if(!(r>e))throw new se$3("Input is not a number.");a=o-1}return 0}class je$3{constructor(t,e,n){this.type=t,this.input=e,this.labels=[],this.outputs=[];for(const[t,e]of n)this.labels.push(t),this.outputs.push(e)}static parse(t,e){if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");const n=e.parse(t[1],1,Ft$4);if(!n)return null;const r=[];let i=null;e.expectedType&&"value"!==e.expectedType.kind&&(i=e.expectedType);for(let n=1;n<t.length;n+=2){const s=1===n?-1/0:t[n],a=t[n+1],o=n,l=n+1;if("number"!=typeof s)return e.error('Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.',o);if(r.length&&r[r.length-1][0]>=s)return e.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',o);const h=e.parse(a,l,i);if(!h)return null;i=i||h.type,r.push([s,h])}return new je$3(i,n,r)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;return r>=e[i-1]?n[i-1].evaluate(t):n[He$3(e,r)].evaluate(t)}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){const t=["step",this.input.serialize()];for(let e=0;e<this.labels.length;e++)e>0&&t.push(this.labels[e]),t.push(this.outputs[e].serialize());return t}}var qe$3=je$3,Ge$3=Xe$3;function Xe$3(t,e,n,r){this.cx=3*t,this.bx=3*(n-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(r-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=e,this.p2x=n,this.p2y=r}function Be$3(t,e,n){return t*(1-n)+e*n}Xe$3.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,e){if(void 0===e&&(e=1e-6),t<0)return 0;if(t>1)return 1;for(var n=t,r=0;r<8;r++){var i=this.sampleCurveX(n)-t;if(Math.abs(i)<e)return n;var s=this.sampleCurveDerivativeX(n);if(Math.abs(s)<1e-6)break;n-=i/s}var a=0,o=1;for(n=t,r=0;r<20&&(i=this.sampleCurveX(n),!(Math.abs(i-t)<e));r++)t>i?a=n:o=n,n=.5*(o-a)+a;return n},solve:function(t,e){return this.sampleCurveY(this.solveCurveX(t,e))}};var Je$3=Object.freeze({__proto__:null,number:Be$3,color:function(t,e,n){return new Bt$4(Be$3(t.r,e.r,n),Be$3(t.g,e.g,n),Be$3(t.b,e.b,n),Be$3(t.a,e.a,n))},array:function(t,e,n){return t.map(((t,r)=>Be$3(t,e[r],n)))}});const Ze$3=6/29,Ye$3=3*Ze$3*Ze$3,Ke$3=Math.PI/180,Qe$3=180/Math.PI;function tn$3(t){return t>.008856451679035631?Math.pow(t,1/3):t/Ye$3+4/29}function en$3(t){return t>Ze$3?t*t*t:Ye$3*(t-4/29)}function nn$3(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function rn$3(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function sn$3(t){const e=rn$3(t.r),n=rn$3(t.g),r=rn$3(t.b),i=tn$3((.4124564*e+.3575761*n+.1804375*r)/.95047),s=tn$3((.2126729*e+.7151522*n+.072175*r)/1);return{l:116*s-16,a:500*(i-s),b:200*(s-tn$3((.0193339*e+.119192*n+.9503041*r)/1.08883)),alpha:t.a}}function an$3(t){let e=(t.l+16)/116,n=isNaN(t.a)?e:e+t.a/500,r=isNaN(t.b)?e:e-t.b/200;return e=1*en$3(e),n=.95047*en$3(n),r=1.08883*en$3(r),new Bt$4(nn$3(3.2404542*n-1.5371385*e-.4985314*r),nn$3(-.969266*n+1.8760108*e+.041556*r),nn$3(.0556434*n-.2040259*e+1.0572252*r),t.alpha)}function on$3(t,e,n){const r=e-t;return t+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const ln$3={forward:sn$3,reverse:an$3,interpolate:function(t,e,n){return{l:Be$3(t.l,e.l,n),a:Be$3(t.a,e.a,n),b:Be$3(t.b,e.b,n),alpha:Be$3(t.alpha,e.alpha,n)}}},hn$3={forward:function(t){const{l:e,a:n,b:r}=sn$3(t),i=Math.atan2(r,n)*Qe$3;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:e,alpha:t.a}},reverse:function(t){const e=t.h*Ke$3,n=t.c;return an$3({l:t.l,a:Math.cos(e)*n,b:Math.sin(e)*n,alpha:t.alpha})},interpolate:function(t,e,n){return{h:on$3(t.h,e.h,n),c:Be$3(t.c,e.c,n),l:Be$3(t.l,e.l,n),alpha:Be$3(t.alpha,e.alpha,n)}}};var un$3=Object.freeze({__proto__:null,lab:ln$3,hcl:hn$3});class cn$3{constructor(t,e,n,r,i){this.type=t,this.operator=e,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[t,e]of i)this.labels.push(t),this.outputs.push(e)}static interpolationFactor(t,e,n,r){let i=0;if("exponential"===t.name)i=pn$3(e,t.base,n,r);else if("linear"===t.name)i=pn$3(e,1,n,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new Ge$3(s[0],s[1],s[2],s[3]).solve(pn$3(e,1,n,r))}return i}static parse(t,e){let[n,r,i,...s]=t;if(!Array.isArray(r)||0===r.length)return e.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return e.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return e.error("Unknown interpolation type "+String(r[0]),1,0);{const t=r.slice(1);if(4!==t.length||t.some((t=>"number"!=typeof t||t<0||t>1)))return e.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return e.error("Expected an even number of arguments.");if(i=e.parse(i,2,Ft$4),!i)return null;const a=[];let o=null;"interpolate-hcl"===n||"interpolate-lab"===n?o=Mt$4:e.expectedType&&"value"!==e.expectedType.kind&&(o=e.expectedType);for(let t=0;t<s.length;t+=2){const n=s[t],r=s[t+1],i=t+3,l=t+4;if("number"!=typeof n)return e.error('Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.',i);if(a.length&&a[a.length-1][0]>=n)return e.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const h=e.parse(r,l,o);if(!h)return null;o=o||h.type,a.push([n,h])}return"number"===o.kind||"color"===o.kind||"array"===o.kind&&"number"===o.itemType.kind&&"number"==typeof o.N?new cn$3(o,n,r,i,a):e.error(`Type ${Ot$4(o)} is not interpolatable.`)}evaluate(t){const e=this.labels,n=this.outputs;if(1===e.length)return n[0].evaluate(t);const r=this.input.evaluate(t);if(r<=e[0])return n[0].evaluate(t);const i=e.length;if(r>=e[i-1])return n[i-1].evaluate(t);const s=He$3(e,r),a=cn$3.interpolationFactor(this.interpolation,r,e[s],e[s+1]),o=n[s].evaluate(t),l=n[s+1].evaluate(t);return"interpolate"===this.operator?Je$3[this.type.kind.toLowerCase()](o,l,a):"interpolate-hcl"===this.operator?hn$3.reverse(hn$3.interpolate(hn$3.forward(o),hn$3.forward(l),a)):ln$3.reverse(ln$3.interpolate(ln$3.forward(o),ln$3.forward(l),a))}eachChild(t){t(this.input);for(const e of this.outputs)t(e)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const e=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)e.push(this.labels[t],this.outputs[t].serialize());return e}}function pn$3(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}var fn$3=cn$3;class dn$3{constructor(t,e){this.type=t,this.args=e}static parse(t,e){if(t.length<2)return e.error("Expectected at least one argument.");let n=null;const r=e.expectedType;r&&"value"!==r.kind&&(n=r);const i=[];for(const r of t.slice(1)){const t=e.parse(r,1+i.length,n,void 0,{typeAnnotation:"omit"});if(!t)return null;n=n||t.type,i.push(t)}const s=r&&i.some((t=>Rt$4(r,t.type)));return new dn$3(s?St$4:n,i)}evaluate(t){let e,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(t),n&&n instanceof Kt$3&&!n.available&&(e||(e=n),n=null,r===this.args.length))return e;if(null!==n)break}return n}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every((t=>t.outputDefined()))}serialize(){const t=["coalesce"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var yn$3=dn$3;class mn$3{constructor(t,e){this.type=e.type,this.bindings=[].concat(t),this.result=e}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const e of this.bindings)t(e[1]);t(this.result)}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const n=[];for(let r=1;r<t.length-1;r+=2){const i=t[r];if("string"!=typeof i)return e.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return e.error("Variable names must contain only alphanumeric characters or '_'.",r);const s=e.parse(t[r+1],r+1);if(!s)return null;n.push([i,s])}const r=e.parse(t[t.length-1],t.length-1,e.expectedType,n);return r?new mn$3(n,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[e,n]of this.bindings)t.push(e,n.serialize());return t.push(this.result.serialize()),t}}var gn$3=mn$3;class xn$3{constructor(t,e,n){this.type=t,this.index=e,this.input=n}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,Ft$4),r=e.parse(t[2],2,Et$4(e.expectedType||St$4));return n&&r?new xn$3(r.type.itemType,n,r):null}evaluate(t){const e=this.index.evaluate(t),n=this.input.evaluate(t);if(e<0)throw new se$3(`Array index out of bounds: ${e} < 0.`);if(e>=n.length)throw new se$3(`Array index out of bounds: ${e} > ${n.length-1}.`);if(e!==Math.floor(e))throw new se$3(`Array index must be an integer, but found ${e} instead.`);return n[e]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var vn$3=xn$3;class bn$3{constructor(t,e){this.type=zt$3,this.needle=t,this.haystack=e}static parse(t,e){if(3!==t.length)return e.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,St$4),r=e.parse(t[2],2,St$4);return n&&r?Wt$3(n.type,[zt$3,Pt$4,Ft$4,_t$4,St$4])?new bn$3(n,r):e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ot$4(n.type)} instead`):null}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(null==n)return!1;if(!Vt$3(e,["boolean","string","number","null"]))throw new se$3(`Expected first argument to be of type boolean, string, number or null, but found ${Ot$4(ee$3(e))} instead.`);if(!Vt$3(n,["string","array"]))throw new se$3(`Expected second argument to be of type array or string, but found ${Ot$4(ee$3(n))} instead.`);return n.indexOf(e)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var wn$3=bn$3;class kn$3{constructor(t,e,n){this.type=Ft$4,this.needle=t,this.haystack=e,this.fromIndex=n}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,St$4),r=e.parse(t[2],2,St$4);if(!n||!r)return null;if(!Wt$3(n.type,[zt$3,Pt$4,Ft$4,_t$4,St$4]))return e.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ot$4(n.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ft$4);return i?new kn$3(n,r,i):null}return new kn$3(n,r)}evaluate(t){const e=this.needle.evaluate(t),n=this.haystack.evaluate(t);if(!Vt$3(e,["boolean","string","number","null"]))throw new se$3(`Expected first argument to be of type boolean, string, number or null, but found ${Ot$4(ee$3(e))} instead.`);if(!Vt$3(n,["string","array"]))throw new se$3(`Expected second argument to be of type array or string, but found ${Ot$4(ee$3(n))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return n.indexOf(e,r)}return n.indexOf(e)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var An$3=kn$3;class _n$3{constructor(t,e,n,r,i,s){this.inputType=t,this.type=e,this.input=n,this.cases=r,this.outputs=i,this.otherwise=s}static parse(t,e){if(t.length<5)return e.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return e.error("Expected an even number of arguments.");let n,r;e.expectedType&&"value"!==e.expectedType.kind&&(r=e.expectedType);const i={},s=[];for(let a=2;a<t.length-1;a+=2){let o=t[a];const l=t[a+1];Array.isArray(o)||(o=[o]);const h=e.concat(a);if(0===o.length)return h.error("Expected at least one branch label.");for(const t of o){if("number"!=typeof t&&"string"!=typeof t)return h.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(n){if(h.checkSubtype(n,ee$3(t)))return null}else n=ee$3(t);if(void 0!==i[String(t)])return h.error("Branch labels must be unique.");i[String(t)]=s.length}const u=e.parse(l,a,r);if(!u)return null;r=r||u.type,s.push(u)}const a=e.parse(t[1],1,St$4);if(!a)return null;const o=e.parse(t[t.length-1],t.length-1,r);return o?"value"!==a.type.kind&&e.concat(1).checkSubtype(n,a.type)?null:new _n$3(n,r,a,i,s,o):null}evaluate(t){const e=this.input.evaluate(t);return(ee$3(e)===this.inputType&&this.outputs[this.cases[e]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every((t=>t.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],e=Object.keys(this.cases).sort(),n=[],r={};for(const t of e){const e=r[this.cases[t]];void 0===e?(r[this.cases[t]]=n.length,n.push([this.cases[t],[t]])):n[e][1].push(t)}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[e,r]of n)t.push(1===r.length?i(r[0]):r.map(i)),t.push(this.outputs[e].serialize());return t.push(this.otherwise.serialize()),t}}var Fn$3=_n$3;class Pn$3{constructor(t,e,n){this.type=t,this.branches=e,this.otherwise=n}static parse(t,e){if(t.length<4)return e.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return e.error("Expected an odd number of arguments.");let n;e.expectedType&&"value"!==e.expectedType.kind&&(n=e.expectedType);const r=[];for(let i=1;i<t.length-1;i+=2){const s=e.parse(t[i],i,zt$3);if(!s)return null;const a=e.parse(t[i+1],i+1,n);if(!a)return null;r.push([s,a]),n=n||a.type}const i=e.parse(t[t.length-1],t.length-1,n);return i?new Pn$3(n,r,i):null}evaluate(t){for(const[e,n]of this.branches)if(e.evaluate(t))return n.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[e,n]of this.branches)t(e),t(n);t(this.otherwise)}outputDefined(){return this.branches.every((([t,e])=>e.outputDefined()))&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild((e=>{t.push(e.serialize())})),t}}var zn$3=Pn$3;class Mn$3{constructor(t,e,n,r){this.type=t,this.input=e,this.beginIndex=n,this.endIndex=r}static parse(t,e){if(t.length<=2||t.length>=5)return e.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const n=e.parse(t[1],1,St$4),r=e.parse(t[2],2,Ft$4);if(!n||!r)return null;if(!Wt$3(n.type,[Et$4(St$4),Pt$4,St$4]))return e.error(`Expected first argument to be of type array or string, but found ${Ot$4(n.type)} instead`);if(4===t.length){const i=e.parse(t[3],3,Ft$4);return i?new Mn$3(n.type,n,r,i):null}return new Mn$3(n.type,n,r)}evaluate(t){const e=this.input.evaluate(t),n=this.beginIndex.evaluate(t);if(!Vt$3(e,["string","array"]))throw new se$3(`Expected first argument to be of type array or string, but found ${Ot$4(ee$3(e))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return e.slice(n,r)}return e.slice(n)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Tn$3=Mn$3;function Sn$3(t,e){return"=="===t||"!="===t?"boolean"===e.kind||"string"===e.kind||"number"===e.kind||"null"===e.kind||"value"===e.kind:"string"===e.kind||"number"===e.kind||"value"===e.kind}function Cn$3(t,e,n,r){return 0===r.compare(e,n)}function Dn$3(t,e,n){const r="=="!==t&&"!="!==t;return class i{constructor(t,e,n){this.type=zt$3,this.lhs=t,this.rhs=e,this.collator=n,this.hasUntypedArgument="value"===t.type.kind||"value"===e.type.kind}static parse(t,e){if(3!==t.length&&4!==t.length)return e.error("Expected two or three arguments.");const n=t[0];let s=e.parse(t[1],1,St$4);if(!s)return null;if(!Sn$3(n,s.type))return e.concat(1).error(`"${n}" comparisons are not supported for type '${Ot$4(s.type)}'.`);let a=e.parse(t[2],2,St$4);if(!a)return null;if(!Sn$3(n,a.type))return e.concat(2).error(`"${n}" comparisons are not supported for type '${Ot$4(a.type)}'.`);if(s.type.kind!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error(`Cannot compare types '${Ot$4(s.type)}' and '${Ot$4(a.type)}'.`);r&&("value"===s.type.kind&&"value"!==a.type.kind?s=new le$3(a.type,[s]):"value"!==s.type.kind&&"value"===a.type.kind&&(a=new le$3(s.type,[a])));let o=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==a.type.kind&&"value"!==s.type.kind&&"value"!==a.type.kind)return e.error("Cannot use collator to compare non-string types.");if(o=e.parse(t[3],3,Ct$4),!o)return null}return new i(s,a,o)}evaluate(i){const s=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const e=ee$3(s),n=ee$3(a);if(e.kind!==n.kind||"string"!==e.kind&&"number"!==e.kind)throw new se$3(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${e.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=ee$3(s),n=ee$3(a);if("string"!==t.kind||"string"!==n.kind)return e(i,s,a)}return this.collator?n(i,s,a,this.collator.evaluate(i)):e(i,s,a)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const e=[t];return this.eachChild((t=>{e.push(t.serialize())})),e}}}const In$3=Dn$3("==",(function(t,e,n){return e===n}),Cn$3),En$3=Dn$3("!=",(function(t,e,n){return e!==n}),(function(t,e,n,r){return!Cn$3(0,e,n,r)})),On$3=Dn$3("<",(function(t,e,n){return e<n}),(function(t,e,n,r){return r.compare(e,n)<0})),Ln$3=Dn$3(">",(function(t,e,n){return e>n}),(function(t,e,n,r){return r.compare(e,n)>0})),Rn$3=Dn$3("<=",(function(t,e,n){return e<=n}),(function(t,e,n,r){return r.compare(e,n)<=0})),Wn$3=Dn$3(">=",(function(t,e,n){return e>=n}),(function(t,e,n,r){return r.compare(e,n)>=0}));class Vn$3{constructor(t,e,n,r,i,s){this.type=Pt$4,this.number=t,this.locale=e,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=s}static parse(t,e){if(3!==t.length)return e.error("Expected two arguments.");const n=e.parse(t[1],1,Ft$4);if(!n)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return e.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=e.parse(r.locale,1,Pt$4),!i))return null;let s=null;if(r.currency&&(s=e.parse(r.currency,1,Pt$4),!s))return null;let a=null;if(r.unit&&(a=e.parse(r.unit,1,Pt$4),!a))return null;let o=null;if(r["min-fraction-digits"]&&(o=e.parse(r["min-fraction-digits"],1,Ft$4),!o))return null;let l=null;return r["max-fraction-digits"]&&(l=e.parse(r["max-fraction-digits"],1,Ft$4),!l)?null:new Vn$3(n,i,s,a,o,l)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class Un$3{constructor(t){this.type=Ft$4,this.input=t}static parse(t,e){if(2!==t.length)return e.error(`Expected 1 argument, but found ${t.length-1} instead.`);const n=e.parse(t[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?e.error(`Expected argument of type string or array, but found ${Ot$4(n.type)} instead.`):new Un$3(n):null}evaluate(t){const e=this.input.evaluate(t);if("string"==typeof e)return e.length;if(Array.isArray(e))return e.length;throw new se$3(`Expected value to be of type string or array, but found ${Ot$4(ee$3(e))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild((e=>{t.push(e.serialize())})),t}}const $n$3={"==":In$3,"!=":En$3,">":Ln$3,"<":On$3,">=":Wn$3,"<=":Rn$3,array:le$3,at:vn$3,boolean:le$3,case:zn$3,coalesce:yn$3,collator:xe$3,format:he$3,image:ue$3,in:wn$3,"index-of":An$3,interpolate:fn$3,"interpolate-hcl":fn$3,"interpolate-lab":fn$3,length:Un$3,let:gn$3,literal:ie$3,match:Fn$3,number:le$3,"number-format":Vn$3,object:le$3,slice:Tn$3,step:qe$3,string:le$3,"to-boolean":fe$3,"to-color":fe$3,"to-number":fe$3,"to-string":fe$3,var:Ue$3,within:Oe$3};function Nn$3(t,[e,n,r,i]){e=e.evaluate(t),n=n.evaluate(t),r=r.evaluate(t);const s=i?i.evaluate(t):1,a=Qt$3(e,n,r,s);if(a)throw new se$3(a);return new Bt$4(e/255*s,n/255*s,r/255*s,s)}function Hn$3(t,e){return t in e}function jn$3(t,e){const n=e[t];return void 0===n?null:n}function qn$3(t){return{type:t}}ge$3.register($n$3,{error:[{kind:"error"},[Pt$4],(t,[e])=>{throw new se$3(e.evaluate(t))}],typeof:[Pt$4,[St$4],(t,[e])=>Ot$4(ee$3(e.evaluate(t)))],"to-rgba":[Et$4(Ft$4,4),[Mt$4],(t,[e])=>e.evaluate(t).toArray()],rgb:[Mt$4,[Ft$4,Ft$4,Ft$4],Nn$3],rgba:[Mt$4,[Ft$4,Ft$4,Ft$4,Ft$4],Nn$3],has:{type:zt$3,overloads:[[[Pt$4],(t,[e])=>Hn$3(e.evaluate(t),t.properties())],[[Pt$4,Tt$4],(t,[e,n])=>Hn$3(e.evaluate(t),n.evaluate(t))]]},get:{type:St$4,overloads:[[[Pt$4],(t,[e])=>jn$3(e.evaluate(t),t.properties())],[[Pt$4,Tt$4],(t,[e,n])=>jn$3(e.evaluate(t),n.evaluate(t))]]},"feature-state":[St$4,[Pt$4],(t,[e])=>jn$3(e.evaluate(t),t.featureState||{})],properties:[Tt$4,[],t=>t.properties()],"geometry-type":[Pt$4,[],t=>t.geometryType()],id:[St$4,[],t=>t.id()],zoom:[Ft$4,[],t=>t.globals.zoom],pitch:[Ft$4,[],t=>t.globals.pitch||0],"distance-from-center":[Ft$4,[],t=>t.distanceFromCenter()],"heatmap-density":[Ft$4,[],t=>t.globals.heatmapDensity||0],"line-progress":[Ft$4,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Ft$4,[],t=>t.globals.skyRadialProgress||0],accumulated:[St$4,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Ft$4,qn$3(Ft$4),(t,e)=>{let n=0;for(const r of e)n+=r.evaluate(t);return n}],"*":[Ft$4,qn$3(Ft$4),(t,e)=>{let n=1;for(const r of e)n*=r.evaluate(t);return n}],"-":{type:Ft$4,overloads:[[[Ft$4,Ft$4],(t,[e,n])=>e.evaluate(t)-n.evaluate(t)],[[Ft$4],(t,[e])=>-e.evaluate(t)]]},"/":[Ft$4,[Ft$4,Ft$4],(t,[e,n])=>e.evaluate(t)/n.evaluate(t)],"%":[Ft$4,[Ft$4,Ft$4],(t,[e,n])=>e.evaluate(t)%n.evaluate(t)],ln2:[Ft$4,[],()=>Math.LN2],pi:[Ft$4,[],()=>Math.PI],e:[Ft$4,[],()=>Math.E],"^":[Ft$4,[Ft$4,Ft$4],(t,[e,n])=>Math.pow(e.evaluate(t),n.evaluate(t))],sqrt:[Ft$4,[Ft$4],(t,[e])=>Math.sqrt(e.evaluate(t))],log10:[Ft$4,[Ft$4],(t,[e])=>Math.log(e.evaluate(t))/Math.LN10],ln:[Ft$4,[Ft$4],(t,[e])=>Math.log(e.evaluate(t))],log2:[Ft$4,[Ft$4],(t,[e])=>Math.log(e.evaluate(t))/Math.LN2],sin:[Ft$4,[Ft$4],(t,[e])=>Math.sin(e.evaluate(t))],cos:[Ft$4,[Ft$4],(t,[e])=>Math.cos(e.evaluate(t))],tan:[Ft$4,[Ft$4],(t,[e])=>Math.tan(e.evaluate(t))],asin:[Ft$4,[Ft$4],(t,[e])=>Math.asin(e.evaluate(t))],acos:[Ft$4,[Ft$4],(t,[e])=>Math.acos(e.evaluate(t))],atan:[Ft$4,[Ft$4],(t,[e])=>Math.atan(e.evaluate(t))],min:[Ft$4,qn$3(Ft$4),(t,e)=>Math.min(...e.map((e=>e.evaluate(t))))],max:[Ft$4,qn$3(Ft$4),(t,e)=>Math.max(...e.map((e=>e.evaluate(t))))],abs:[Ft$4,[Ft$4],(t,[e])=>Math.abs(e.evaluate(t))],round:[Ft$4,[Ft$4],(t,[e])=>{const n=e.evaluate(t);return n<0?-Math.round(-n):Math.round(n)}],floor:[Ft$4,[Ft$4],(t,[e])=>Math.floor(e.evaluate(t))],ceil:[Ft$4,[Ft$4],(t,[e])=>Math.ceil(e.evaluate(t))],"filter-==":[zt$3,[Pt$4,St$4],(t,[e,n])=>t.properties()[e.value]===n.value],"filter-id-==":[zt$3,[St$4],(t,[e])=>t.id()===e.value],"filter-type-==":[zt$3,[Pt$4],(t,[e])=>t.geometryType()===e.value],"filter-<":[zt$3,[Pt$4,St$4],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<i}],"filter-id-<":[zt$3,[St$4],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<r}],"filter->":[zt$3,[Pt$4,St$4],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[zt$3,[St$4],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>r}],"filter-<=":[zt$3,[Pt$4,St$4],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[zt$3,[St$4],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n<=r}],"filter->=":[zt$3,[Pt$4,St$4],(t,[e,n])=>{const r=t.properties()[e.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[zt$3,[St$4],(t,[e])=>{const n=t.id(),r=e.value;return typeof n==typeof r&&n>=r}],"filter-has":[zt$3,[St$4],(t,[e])=>e.value in t.properties()],"filter-has-id":[zt$3,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[zt$3,[Et$4(Pt$4)],(t,[e])=>e.value.indexOf(t.geometryType())>=0],"filter-id-in":[zt$3,[Et$4(St$4)],(t,[e])=>e.value.indexOf(t.id())>=0],"filter-in-small":[zt$3,[Pt$4,Et$4(St$4)],(t,[e,n])=>n.value.indexOf(t.properties()[e.value])>=0],"filter-in-large":[zt$3,[Pt$4,Et$4(St$4)],(t,[e,n])=>function(t,e,n,r){for(;n<=r;){const i=n+r>>1;if(e[i]===t)return!0;e[i]>t?r=i-1:n=i+1}return!1}(t.properties()[e.value],n.value,0,n.value.length-1)],all:{type:zt$3,overloads:[[[zt$3,zt$3],(t,[e,n])=>e.evaluate(t)&&n.evaluate(t)],[qn$3(zt$3),(t,e)=>{for(const n of e)if(!n.evaluate(t))return!1;return!0}]]},any:{type:zt$3,overloads:[[[zt$3,zt$3],(t,[e,n])=>e.evaluate(t)||n.evaluate(t)],[qn$3(zt$3),(t,e)=>{for(const n of e)if(n.evaluate(t))return!0;return!1}]]},"!":[zt$3,[zt$3],(t,[e])=>!e.evaluate(t)],"is-supported-script":[zt$3,[Pt$4],(t,[e])=>{const n=t.globals&&t.globals.isSupportedScript;return!n||n(e.evaluate(t))}],upcase:[Pt$4,[Pt$4],(t,[e])=>e.evaluate(t).toUpperCase()],downcase:[Pt$4,[Pt$4],(t,[e])=>e.evaluate(t).toLowerCase()],concat:[Pt$4,qn$3(St$4),(t,e)=>e.map((e=>ne$3(e.evaluate(t)))).join("")],"resolved-locale":[Pt$4,[Ct$4],(t,[e])=>e.evaluate(t).resolvedLocale()]});var Gn$3=$n$3;function Xn$3(t){return{result:"success",value:t}}function Bn$3(t){return{result:"error",value:t}}function Jn$3(t){return!!t.expression&&t.expression.interpolated}function Zn$3(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function Yn$3(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function Kn$3(t){return t}function Qn$3(t,e,n){return void 0!==t?t:void 0!==e?e:void 0!==n?n:void 0}function tr$3(t,e,n,r,i){return Qn$3(typeof n===i?r[n]:void 0,t.default,e.default)}function er$3(t,e,n){if("number"!==Zn$3(n))return Qn$3(t.default,e.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[r-1][0])return t.stops[r-1][1];const i=He$3(t.stops.map((t=>t[0])),n);return t.stops[i][1]}function nr$3(t,e,n){const r=void 0!==t.base?t.base:1;if("number"!==Zn$3(n))return Qn$3(t.default,e.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(n<=t.stops[0][0])return t.stops[0][1];if(n>=t.stops[i-1][0])return t.stops[i-1][1];const s=He$3(t.stops.map((t=>t[0])),n),a=function(t,e,n,r){const i=r-n,s=t-n;return 0===i?0:1===e?s/i:(Math.pow(e,s)-1)/(Math.pow(e,i)-1)}(n,r,t.stops[s][0],t.stops[s+1][0]),o=t.stops[s][1],l=t.stops[s+1][1];let h=Je$3[e.type]||Kn$3;if(t.colorSpace&&"rgb"!==t.colorSpace){const e=un$3[t.colorSpace];h=(t,n)=>e.reverse(e.interpolate(e.forward(t),e.forward(n),a))}return"function"==typeof o.evaluate?{evaluate(...t){const e=o.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==e&&void 0!==n)return h(e,n,a)}}:h(o,l,a)}function rr$3(t,e,n){return"color"===e.type?n=Bt$4.parse(n):"formatted"===e.type?n=Yt$3.fromString(n.toString()):"resolvedImage"===e.type?n=Kt$3.fromString(n.toString()):Zn$3(n)===e.type||"enum"===e.type&&e.values[n]||(n=void 0),Qn$3(n,t.default,e.default)}class ir$3{constructor(t,e){this.expression=t,this._warningHistory={},this._evaluator=new ye$3,this._defaultValue=e?function(t){return"color"===t.type&&(Yn$3(t.default)||Array.isArray(t.default))?new Bt$4(0,0,0,0):"color"===t.type?Bt$4.parse(t.default)||null:void 0===t.default?null:t.default}(e):null,this._enumValues=e&&"enum"===e.type?e.values:null}evaluateWithoutErrorHandling(t,e,n,r,i,s,a,o){return this._evaluator.globals=t,this._evaluator.feature=e,this._evaluator.featureState=n,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=o||null,this.expression.evaluate(this._evaluator)}evaluate(t,e,n,r,i,s,a,o){this._evaluator.globals=t,this._evaluator.feature=e||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=s||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=o||null;try{const t=this.expression.evaluate(this._evaluator);if(null==t||"number"==typeof t&&t!=t)return this._defaultValue;if(this._enumValues&&!(t in this._enumValues))throw new se$3(`Expected value to be one of ${Object.keys(this._enumValues).map((t=>JSON.stringify(t))).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this._warningHistory[t.message]||(this._warningHistory[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this._defaultValue}}}function sr$3(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in Gn$3}function ar$3(t,e){const n=new Ne$3(Gn$3,[],e?function(t){const e={color:Mt$4,string:Pt$4,number:Ft$4,enum:Pt$4,boolean:zt$3,formatted:Dt$4,resolvedImage:It$4};return"array"===t.type?Et$4(e[t.value]||St$4,t.length):e[t.type]}(e):void 0),r=n.parse(t,void 0,void 0,void 0,e&&"string"===e.type?{typeAnnotation:"coerce"}:void 0);return r?Xn$3(new ir$3(r,e)):Bn$3(n.errors)}class or$3{constructor(t,e){this.kind=t,this._styleExpression=e,this.isStateDependent="constant"!==t&&!Re$3(e.expression)}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._styleExpression.evaluate(t,e,n,r,i,s)}}class lr$3{constructor(t,e,n,r){this.kind=t,this.zoomStops=n,this._styleExpression=e,this.isStateDependent="camera"!==t&&!Re$3(e.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,e,n,r,i,s){return this._styleExpression.evaluateWithoutErrorHandling(t,e,n,r,i,s)}evaluate(t,e,n,r,i,s){return this._styleExpression.evaluate(t,e,n,r,i,s)}interpolationFactor(t,e,n){return this.interpolationType?fn$3.interpolationFactor(this.interpolationType,t,e,n):0}}function hr$3(t,e){if("error"===(t=ar$3(t,e)).result)return t;const n=t.value.expression,r=Le$3(n);if(!r&&!function(t){return"data-driven"===t["property-type"]}(e))return Bn$3([new wt$4("","data expressions not supported")]);const i=We$3(n,["zoom","pitch","distance-from-center"]);if(!i&&!function(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}(e))return Bn$3([new wt$4("","zoom expressions not supported")]);const s=function t(e){let n=null;if(e instanceof gn$3)n=t(e.result);else if(e instanceof yn$3){for(const r of e.args)if(n=t(r),n)break}else(e instanceof qe$3||e instanceof fn$3)&&e.input instanceof ge$3&&"zoom"===e.input.name&&(n=e);return n instanceof wt$4||e.eachChild((e=>{const r=t(e);r instanceof wt$4?n=r:!n&&r?n=new wt$4("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new wt$4("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))})),n}(n);if(!s&&!i)return Bn$3([new wt$4("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof wt$4)return Bn$3([s]);if(s instanceof fn$3&&!Jn$3(e))return Bn$3([new wt$4("",'"interpolate" expressions cannot be used with this property')]);if(!s)return Xn$3(new or$3(r?"constant":"source",t.value));return Xn$3(new lr$3(r?"camera":"composite",t.value,s.labels,s instanceof fn$3?s.interpolation:void 0))}class ur$3{constructor(t,e){this._parameters=t,this._specification=e,vt$4(this,function t(e,n){const r="color"===n.type,i=e.stops&&"object"==typeof e.stops[0][0],s=i||!(i||void 0!==e.property),a=e.type||(Jn$3(n)?"exponential":"interval");if(r&&((e=vt$4({},e)).stops&&(e.stops=e.stops.map((t=>[t[0],Bt$4.parse(t[1])]))),e.default=Bt$4.parse(e.default?e.default:n.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!un$3[e.colorSpace])throw new Error("Unknown color space: "+e.colorSpace);let o,l,h;if("exponential"===a)o=nr$3;else if("interval"===a)o=er$3;else if("categorical"===a){o=tr$3,l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];h=typeof e.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);o=rr$3}if(i){const r={},i=[];for(let t=0;t<e.stops.length;t++){const n=e.stops[t],s=n[0].zoom;void 0===r[s]&&(r[s]={zoom:s,type:e.type,property:e.property,default:e.default,stops:[]},i.push(s)),r[s].stops.push([n[0].value,n[1]])}const s=[];for(const e of i)s.push([r[e].zoom,t(r[e],n)]);const a={name:"linear"};return{kind:"composite",interpolationType:a,interpolationFactor:fn$3.interpolationFactor.bind(void 0,a),zoomStops:s.map((t=>t[0])),evaluate:({zoom:t},r)=>nr$3({stops:s,base:e.base},n,t).evaluate(t,r)}}if(s){const t="exponential"===a?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:t,interpolationFactor:fn$3.interpolationFactor.bind(void 0,t),zoomStops:e.stops.map((t=>t[0])),evaluate:({zoom:t})=>o(e,n,t,l,h)}}return{kind:"source",evaluate(t,r){const i=r&&r.properties?r.properties[e.property]:void 0;return void 0===i?Qn$3(e.default,n.default):o(e,n,i,l,h)}}}(this._parameters,this._specification))}static deserialize(t){return new ur$3(t._parameters,t._specification)}static serialize(t){return{_parameters:t._parameters,_specification:t._specification}}}function cr$3(t){if(Array.isArray(t))return t.map(cr$3);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const e={};for(const n in t)e[n]=cr$3(t[n]);return e}return function(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}(t)}function fr$3(t){if(!Array.isArray(t))return!1;if(function(t){return"pitch"===t||"distance-from-center"===t}(t[0]))return!0;for(let e=1;e<t.length;e++)if(fr$3(t[e]))return!0;return!1}const dr$3=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]),yr$3={StyleExpression:ir$3,isExpression:sr$3,isExpressionFilter:function t(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const n of e.slice(1))if(!t(n)&&"boolean"!=typeof n)return!1;return!0;default:return!0}},createExpression:ar$3,createPropertyExpression:hr$3,normalizePropertyExpression:function(t,e){if(Yn$3(t))return new ur$3(t,e);if(sr$3(t)){const n=hr$3(t,e);if("error"===n.result)throw new Error(n.value.map((t=>`${t.key}: ${t.message}`)).join(", "));return n.value}{let n=t;return"string"==typeof t&&"color"===e.type&&(n=Bt$4.parse(t)),{kind:"constant",evaluate:()=>n}}},ZoomConstantExpression:or$3,ZoomDependentExpression:lr$3,StylePropertyFunction:ur$3},{isExpression:mr$3,createExpression:gr$3}=yr$3,xr$3={};function vr$3(t){if(!0===t)return function(){return!0};if(t&&t.condition){if("any"===t.type){const e=t.condition,n=[];for(let t=0;t<e.length;t++)n.push(vr$3(e[t]));return(t,e)=>{for(let r=0;r<n.length;r++)if(n[r](t,e))return!0;return!1}}const e=vr$3(t.condition);if($$4(t.layer))return e;const n=e=>e.layer===t.layer;return(t,r)=>n(t)&&e(t,r)}if(isFeatureFilter(t))return createFilter(t);{let e=function(t,e="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};const n=t;let r=!0;try{r=function(t){if(!fr$3(t))return t;let e=cr$3(t);return function t(e){let n=!1;const r=[];if("case"===e[0]){for(let t=1;t<e.length-1;t+=2)n=n||fr$3(e[t]),r.push(e[t+1]);r.push(e[e.length-1])}else if("match"===e[0]){n=n||fr$3(e[1]);for(let t=2;t<e.length-1;t+=2)r.push(e[t+1]);r.push(e[e.length-1])}else if("step"===e[0]){n=n||fr$3(e[1]);for(let t=1;t<e.length-1;t+=2)r.push(e[t+1])}n&&(e.length=0,e.push("any",...r));for(let n=1;n<e.length;n++)t(e[n])}(e),e=function t(e){if(!Array.isArray(e))return e;const n=function(t){if(dr$3.has(t[0]))for(let e=1;e<t.length;e++)if(fr$3(t[e]))return!0;return t}(e);return!0===n?n:n.map((e=>t(e)))}(e),e}(n)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n        `)}const i=ar$3(r,null);let s=null;if("error"===i.result)throw new Error(i.value.map((t=>`${t.key}: ${t.message}`)).join(", "));s=(t,e,n)=>i.value.evaluate(t,e,{},n);let a=null,o=null;if(r!==n){const t=ar$3(n,null);if("error"===t.result)throw new Error(t.value.map((t=>`${t.key}: ${t.message}`)).join(", "));a=(e,n,r,i,s)=>t.value.evaluate(e,n,{},r,void 0,void 0,i,s),o=!Le$3(t.value.expression)}return{filter:s,dynamicFilter:a||void 0,needGeometry:function t(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let n=1;n<e.length;n++)if(t(e[n]))return!0;return!1}(r),needFeature:!!o}}(t);return e=e&&e.filter,(t,n)=>(xr$3.zoom=n,e&&e(xr$3,t))}}const br$3={type:"number","property-type":"data-driven",expression:{parameters:["zoom","feature"]}};function wr$3(t,e){br$3.type=e||"number";const n=gr$3(t,br$3);if("success"!==n.result)throw new Error(`Invalid maplibre spec expression: ${JSON.stringify(t)} (${n.value})`);return n.value}function kr$3(t){return mr$3(t)}const Ar$3={lineWidth:1,lineStrokeWidth:1,lineDx:1,lineDy:1,lineOpacity:1,linePatternAnimSpeed:1,markerWidth:1,markerHeight:1,markerDx:1,markerDy:1,markerSpacing:1,markerOpacity:1,markerRotation:1,textWrapWidth:1,textSpacing:1,textSize:1,textHaloRadius:1,textHaloOpacity:1,textDx:1,textDy:1,textOpacity:1,textRotation:1,polygonOpacity:1};function _r$3(t){return Ar$3[t]}const Fr$3={markerPlacement:1,markerFile:1,mergeOnProperty:1,markerTextFit:1,markerType:1,markerHorizontalAlignment:1,markerVerticalAlignment:1,markerRotationAlignment:1,markerPitchAlignment:1,markerFillPatternFile:1,markerLinePatternFile:1,textName:1,textPlacement:1,textFaceName:1,textStyle:1,textHorizontalAlignment:1,textVerticalAlignment:1,textRotationAlignment:1,textPitchAlignment:1,lineJoin:1,lineCap:1,linePatternFile:1,polygonPatternFile:1},Pr$3={lineDasharray:1,markerLineDasharray:1,uvScale:1,uvOffset:1};function zr$3(t){return Fr$3[t]?"string":_r$3(t)?"number":Pr$3[t]?"array":"color"}var Mr$3=Object.freeze({__proto__:null,compileStyle:function(t=[]){return function t(e){if(!Array.isArray(e))return t([e]);const n=[];for(let t=0;t<e.length;t++){let r;r=!0===e[t].filter?function(){return!0}:vr$3(e[t].filter),n.push(U$4({},e[t],{filter:r}))}return n}(t=t.map((t=>{const e=U$4({},t);return e.filter&&e.filter.value&&(e.filter=e.filter.value),e})))},compileFilter:vr$3,createExpression:wr$3,isExpression:kr$3,isInterpolated:_r$3,getExpressionType:zr$3});const Tr$3="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;class Sr$3 extends Array{push(...t){const e=t.length;for(let n=0;n<e;n++)this[this._index++]=t[n]}fill(t,e,n){super.fill(t,e,n),n>this._index&&(this._index=n)}set(t,e){t>=this._index&&(this._index=t+1),this[t]=e}getLength(){return this._index}setLength(t){this._index=t,super.length<t&&(super.length=t)}trySetLength(t){t>this._index&&this.setLength(t)}reset(){this._index=0}}const Cr$3={get:function(t,e){return"length"===e?t.getLength():t[e]}};class Dr$3 extends Array{setLength(t){super.length=t}trySetLength(t){super.length=t}}let Ir$3;class Er$3{static createTypedArray(t,e){return W$4(t,e)}static getInstance(){return Ir$3}constructor(){this._arrays=[],this._index=0}get(){if(!Tr$3)return new Dr$3;const t=this._arrays[this._index]=this._arrays[this._index]||new Proxy(new Sr$3,Cr$3);return t.reset(),this._index++,t}reset(){this._index=0}}Ir$3=new Er$3;const Or$3=[],Lr$3={},Rr$3={},Wr$3={},Vr$3=[],Ur$3=Er$3.getInstance();class $r$3{static isAtlasLoaded(t,e={}){const{iconAtlas:n}=e;return!!(!t||n&&n.positions[t])}static genFnTypes(t){const e={};for(const n in t)if(kr$3(t[n])){const r=(n+"_Fn_0").trim(),i=(n+"Fn").trim(),s=zr$3(n);e[r]=wr$3(t[n],s),e[i]=(t,n)=>{let i;Lr$3.zoom=t,Rr$3.properties=n;try{i=e[r].evaluateWithoutErrorHandling(Lr$3,Rr$3,Wr$3,null,Vr$3)}catch(t){return null}return i}}else if(J$5(t[n])){const s=(n+"_Fn_0").trim(),a=(n+"Fn").trim();_r$3(n)?(e[s]=interpolated(t[n]),e[a]=(t,n)=>{const i=e[s](t,n);return J$5(i)?interpolated(i)(t,n):i}):(e[s]=piecewiseConstant(t[n]),e[a]=(t,n)=>{const r=e[s](t,n);return J$5(r)?piecewiseConstant(r)(t,n):r})}return e}constructor(t,e,n){this.options=n;const i=[];this.symbolDef=e,this.symbol=loadFunctionTypes(e,(()=>(i[0]=n.zoom,i))),this.styledVectors=[],this.properties={},this._fnTypes=n.fnTypes||$r$3.genFnTypes(this.symbolDef),J$5(this.symbolDef.visible)&&(this._visibleFn=interpolated(this.symbolDef.visible)),n.atlas&&(this.iconAtlas=n.atlas.iconAtlas,this.glyphAtlas=n.atlas.glyphAtlas),this.features=this._check(t)}needAltitudeAttribute(){return this.options.forceAltitudeAttribute||this.maxPosZ>=Math.pow(2,17)||this.options.positionType===Float32Array}getPositionFormat(){return this.needAltitudeAttribute()?[{type:Int16Array,width:2,name:"aPosition"},{type:Float32Array,width:1,name:"aAltitude"}]:[{type:Int16Array,width:3,name:"aPosition"}]}fillPosition(t,e,n,r){e<this._minX&&(this._minX=e),e>this._maxX&&(this._maxX=e),n<this._minY&&(this._minY=n),n>this._maxY&&(this._maxY=n),this.needAltitudeAttribute()?(t.aPosition.push(e,n),t.aAltitude.push(r)):(pt$4(Or$3,e,n,r),t.aPosition.push(Or$3[0],Or$3[1],Or$3[2]))}_check(e){if(!e.length)return e;const n="__fea_idx".trim();let r,i=0,s=e[i];for(;!s.geometry;)i++,s=e[i];if(Array.isArray(s.geometry)&&s.properties){let n=s.geometry[0];for(;Array.isArray(n);)n=n[0];n instanceof pointGeometry&&(r=e)}if(!r)if(r=[],Array.isArray(s.geometry))for(let t=0;t<e.length;t++){const n=U$4({},e[t]);r.push(V$4(n))}else for(let t=0;t<e.length;t++){const i=e[t],s=v$2(i);for(let t=0;t<s.length;t++){const e=s[t];e[n]=i[n],r.push(e)}}if(this.maxPosZ=0,!this.options.forceAltitudeAttribute){const t="line"===this.symbolDef.textPlacement;let e=0,n=!1;const{textPitchAlignmentFn:i}=this._fnTypes;!i&&t&&"map"===this.symbolDef.textPitchAlignment&&(n=!0);for(let s=0;s<r.length;s++){const a=Hr$3(r[s]&&r[s].geometry);if(a>e&&(e=a),t&&!n&&i&&r[s].properties){const t=i(null,r[s].properties);"map"===t&&(n=t)}}this.hasMapPitchAlign=n,this.maxPosZ=e}const a=this.options.order;if(a){const t=[];for(let e=0;e<a.length;e++)a[e]&&t.push(vr$3(a[e]));r=r.sort(((e,n)=>{const r=t.length;let i=-1,s=-1;for(let a=0;a<r&&(t[a](e)&&(i=a),t[a](n)&&(s=a),!(i>=0&&i<r&&s>=0&&s<r));a++);return i-s}))}return r}load(t=1){const e="__fea_idx".trim(),n="_debug_info".trim(),r=this._fnTypes,i=this.styledVectors;this.count=0;const a=this.features;if(!a||!a.length)return Promise.resolve(null);const o={},l={},h={zoom:this.options.zoom,isVector3D:!!this.options.center},u=[],c=loadFunctionTypes(this.symbolDef,(()=>(u[0]=h.zoom,u)));let p=0,f=a.length;const d=this.options.debugIndex;try{for(;p<f;p++){const t=a[p];if(!t||!t.geometry)continue;if(N$4(d)&&t[n].index!==d)continue;t.properties||(t.properties={}),t.properties.$layer=t.layer,t.properties.$type=t.type;const s=this.createStyledVector(t,c,r,h,o,l);s&&s.feature.geometry&&(s.featureIdx=void 0===t[e]?p:t[e],this.count++,i.push(s))}}catch(t){return Promise.reject(t)}return this.options.atlas?Promise.resolve(this.pack(t)):this.loadAtlas(o,l).then((()=>this.pack(t)))}loadAtlas(t,e){return new Promise(((n,r)=>{this.fetchAtlas(t,e,((t,e)=>{if(t)r(t);else{if(e){const{icons:t,glyphs:n}=e;if(t&&Object.keys(t).length){for(const e in t){const n=t[e],{width:r,height:i,data:s}=n.data;n.data=new T$4({width:r,height:i},s)}this.iconAtlas=new C$2(t)}if(n&&Object.keys(n).length){for(const t in n){const e=n[t];for(const t in e){const n=e[t],{width:r,height:i,data:s}=n.bitmap;n.bitmap=new M$4({width:r,height:i},s)}}this.glyphAtlas=new E$4(n)}}n({glyphAtlas:this.glyphAtlas,iconAtlas:this.iconAtlas})}}))}))}fetchAtlas(t,e,n){Object.keys(t).length>0||Object.keys(e).length>0?this.options.requestor(t,e,n):n()}pack(t){if(!this.count)return null;if(null==t)throw new Error("layout scale is undefined");const e=this.createDataPack(this.styledVectors,t);if(!e)return null;e.properties=this.properties,this.empty&&(e.empty=!0);const n=e.buffers;delete e.buffers;const r={data:e,buffers:n};if(this.iconAtlas){const t=r.data.iconAtlas=Nr$3(this.iconAtlas);if(t.glyphMap)for(const e in t.glyphMap)n.push(t.glyphMap[e].data.data.buffer);n.push(r.data.iconAtlas.image.data.buffer)}return this.glyphAtlas&&(r.data.glyphAtlas=Nr$3(this.glyphAtlas),n.push(r.data.glyphAtlas.image.data.buffer)),r}createStyledVector(t,e,n,r){return new ct$4(t,e,n,r)}createDataPack(t,e){if(!t||!t.length)return null;this.maxIndex=0,this.maxPos=0,this._minX=this._minY=1/0,this._maxX=this._maxY=-1/0,this.maxAltitude=0,this.dynamicAttrs={};const n=this.data={};this._arrayPool=Ur$3,Ur$3.reset();let r=this.elements=Ur$3.get();const i=this.getFormat(Array.isArray(t[0])?t[0][0].symbol:t[0].symbol),s=this.needAltitudeAttribute()?2:3;for(let t=0;t<i.length;t++)n[i[t].name]=Ur$3.get();let a=Ur$3.get(),o=0;const l=Ur$3.get();let h=0,u=!1,c=!0;const p=new Set;for(let r=0,i=t.length;r<i;r++){if(!t[r].feature.geometry)continue;const i=Array.isArray(t[r])?t[r][0].feature.id:t[r].feature.id;c&&(void 0!==Rr$3.id?p&&(p.has(Rr$3.id)?c=!1:p.add(Rr$3.id)):c=!1),N$4(i)&&(Math.abs(i)>h&&(h=Math.abs(i)),i<0&&(u=!0));const f=this.data.aPosition.length;if(Array.isArray(t[r]))for(let n=0;n<t[r].length;n++)this._placeVector(t[r][n],e);else this._placeVector(t[r],e);const d=(n.aPosition.length-f)/s;for(let e=0;e<d;e++)a.push(t[r].featureIdx),N$4(i)&&l.push(i);o=Math.max(o,t[r].featureIdx)}if(this.countOutOfAngle>0&&console.warn("text anchor along line is ignored as anchor's line angle is bigger than textMaxAngle."),this.hasElements()&&!r.length)return null;const f=this.options.center?Float32Array:R$4(o);a=Er$3.createTypedArray(a,f),i[0].type=this.options.positionType?this.options.positionType:L$4(this.maxPos);const d=this.options.center;if(d&&(d[0]||d[1])){const t=n.aPosition;for(let e=0;e<t.length;e+=s)t[e]-=d[0],t[e+1]-=d[1]}const y=function(t,e){const n={};for(let r=0;r<t.length;r++){const i=t[r],s=i.type,a=i.name;n[a]=s===Array?e[a]:W$4(e[a],s)}return n}(i,n);y.aPickingId=a;const m=[];for(const t in y)m.push(y[t].buffer);const g=O$4(this.maxIndex);r=Er$3.createTypedArray(r,g),m.push(r.buffer);const x={data:y,isIdUnique:c,is2D:0===this.maxPosZ,indices:this.hasElements()?r:null,positionSize:s,positionBounding:[this._minX,this._minY,this._maxX,this._maxY],buffers:m,symbolIndex:this.symbolDef.index||{index:0},dynamicAttributes:this.dynamicAttrs};if(this._packMarkerPlacement&&(x.markerPlacement=this._packMarkerPlacement),this._packTextPlacement&&(x.textPlacement=this._packTextPlacement),l.length){const t=u?L$4(h):R$4(h);x.featureIds=Er$3.createTypedArray(l,t),m.push(x.featureIds.buffer)}else x.featureIds=[];return x.pickingIdIndiceMap=ut$4(a,x.indices),x}_placeVector(t,e){this._visibleFn&&!this._visibleFn(this.options.zoom,t.feature.properties)||this.placeVector(t,e,this.formatWidth)}addElements(...t){this.maxIndex=Math.max(this.maxIndex,...t),this.elements.push(...t)}hasElements(){return!0}getAltitude(t){const{altitudeProperty:e,defaultAltitude:n,altitudeScale:r}=this.options;let i=st$4(t,e,n);return r&&(i*=r),this.maxAltitude=Math.max(this.maxAltitude,Math.abs(i)),i}getIconAtlasMaxValue(){const t=this.iconAtlas.positions;let e=0;for(const n in t)if(X$5(t,n)){const{tl:r,displaySize:i}=t[n],s=Math.max(r[0],r[1],i[0]-1,i[1]-1);s>e&&(e=s)}return e}}function Nr$3(t){let e=t.positions,n=t.image&&t.image.format||"alpha";if(t instanceof C$2){e={};for(const n in t.positions){const r=t.positions[n];e[n]={paddedRect:r.paddedRect,pixelRatio:r.pixelRatio,tl:r.tl,br:r.br,displaySize:r.displaySize}}n="rgba"}const r=t.image;return{image:{width:r.width,height:r.height,data:r.data,format:n},glyphMap:t.glyphMap,positions:e}}function Hr$3(t){if(!t)return 0;let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)if(Array.isArray(t[n])){const r=Hr$3(t[n]);r>e&&(e=r)}else{const r=Math.abs(t[n].z||0);r>e&&(e=r)}else{const n=Math.abs(t.z||0);n>e&&(e=n)}return e}function jr$3(t,e,i,s){const a="__fn_textSize".trim();let o=t.textSize;if($$4(e.textSize))return[16,16];t[a]&&(o=t[a]);const l=[];if(l[0]=q$5(o)?o(s,i):o,isFunctionDefinition(l[0])){const e=l[0].__fn_key=l[0].__fn_key||JSON.stringify(l[0]);t.___fn_in_stops||(t.___fn_in_stops={}),t.___fn_in_stops[e]||(t.___fn_in_stops[e]=interpolated(l[0])),l[0]=(0,t.___fn_in_stops[e])(s,i)}return l[1]=l[0],l}function qr$3(t){const e=t.stops;let n=-1/0;for(let t=0;t<e.length;t++){let r=e[t][1];H$4(e[t][1])&&(r=qr$3(e[t][1])),r>n&&(n=r)}return n}function Gr$3(t,e,n){return[e||"normal",n||"normal","24px",t||"Open Sans Regular"].join(" ")}const Xr$3=/\{[\w-]+(?:\|[\w-]+)*\}/g;function Br$3(t,e){return j$4(t)?t.replace(Xr$3,(function(t){if(!e)return"";if((t=t.substring(1,t.length-1)).indexOf("|")>0){const n=t.split("|");for(let t=0;t<n.length;t++){const r=e[n[t]];if(!$$4(r))return r}return""}const n=e[t];return $$4(n)?"":Array.isArray(n)?n.join():n})):t}var Jr$3=Object.freeze({__proto__:null,getSDFFont:Gr$3,resolveText:Br$3,resolveVarNames:function(t){return t.match(Xr$3)},resolveExpVarNames:function t(e,n){if(2!==n.length||"get"!==n[0])for(let r=0;r<n.length;r++)2===n[r].length&&"get"===n[r][0]?e.push(n[r][1]):Array.isArray(n[r])&&t(e,n[r]);else e.push(n[1])}});const fi$2=t=>t>=11904&&t<=12031,di$2=t=>t>=12032&&t<=12255,yi$2=t=>t>=12272&&t<=12287,mi$2=t=>t>=12288&&t<=12351,gi$2=t=>t>=12352&&t<=12447,xi$2=t=>t>=12448&&t<=12543,vi$2=t=>t>=12544&&t<=12591,ki$2=t=>t>=12704&&t<=12735,Ai$2=t=>t>=12736&&t<=12783,_i$2=t=>t>=12784&&t<=12799,Fi$2=t=>t>=12800&&t<=13055,Pi$2=t=>t>=13056&&t<=13311,zi$2=t=>t>=13312&&t<=19903,Ti$2=t=>t>=19968&&t<=40959,Si$2=t=>t>=40960&&t<=42127,Ci$2=t=>t>=42128&&t<=42191,Li$2=t=>t>=63744&&t<=64255,Ri$2=t=>t>=64336&&t<=65023,Wi$2=t=>t>=65040&&t<=65055,Vi$2=t=>t>=65072&&t<=65103,Ui$2=t=>t>=65104&&t<=65135,$i$2=t=>t>=65136&&t<=65279,Ni$2=t=>t>=65280&&t<=65519;function Hi$2(t){return!((t=>t>=1536&&t<=1791)(t)||(t=>t>=1872&&t<=1919)(t)||(t=>t>=2208&&t<=2303)(t)||Ri$2(t)||$i$2(t))}function ji$2(t){return!!(746===t||747===t||!(t<4352)&&(ki$2(t)||vi$2(t)||Vi$2(t)&&!(t>=65097&&t<=65103)||Li$2(t)||Pi$2(t)||fi$2(t)||Ai$2(t)||!(!mi$2(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||zi$2(t)||Ti$2(t)||Fi$2(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||(t=>t>=44032&&t<=55215)(t)||gi$2(t)||yi$2(t)||(t=>t>=12688&&t<=12703)(t)||di$2(t)||_i$2(t)||xi$2(t)&&12540!==t||!(!Ni$2(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!Ui$2(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||Wi$2(t)||(t=>t>=19904&&t<=19967)(t)||Si$2(t)||Ci$2(t)))}function qi$2(t){return!(ji$2(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||mi$2(t)||xi$2(t)||(t=>t>=57344&&t<=63743)(t)||Vi$2(t)||Ui$2(t)||Ni$2(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Gi$2(t){return t>=1424&&t<=2303||Ri$2(t)||$i$2(t)}const Xi$2=[[9,9],[32,32],[5760,5760],[8192,8198],[8200,8202],[8287,12288],[6158,6158],[8203,8205]];function Bi$2(t){for(const e of Xi$2)if(t>=e[0]&&t<=e[1])return!0;return!1}const Ji$2={"!":"ï¸•","#":"ï¼ƒ",$:"ï¼„","%":"ï¼…","&":"ï¼†","(":"ï¸µ",")":"ï¸¶","*":"ï¼Š","+":"ï¼‹",",":"ï¸","-":"ï¸²",".":"ãƒ»","/":"ï¼",":":"ï¸“",";":"ï¸”","<":"ï¸¿","=":"ï¼",">":"ï¹€","?":"ï¸–","@":"ï¼ ","[":"ï¹‡","\\":"ï¼¼","]":"ï¹ˆ","^":"ï¼¾",_:"ï¸³","`":"ï½€","{":"ï¸·","|":"â€•","}":"ï¸¸","~":"ï½ž","Â¢":"ï¿ ","Â£":"ï¿¡","Â¥":"ï¿¥","Â¦":"ï¿¤","Â¬":"ï¿¢","Â¯":"ï¿£","â€“":"ï¸²","â€”":"ï¸±","â€˜":"ï¹ƒ","â€™":"ï¹„","â€œ":"ï¹","â€":"ï¹‚","â€¦":"ï¸™","â€§":"ãƒ»","â‚©":"ï¿¦","ã€":"ï¸‘","ã€‚":"ï¸’","ã€ˆ":"ï¸¿","ã€‰":"ï¹€","ã€Š":"ï¸½","ã€‹":"ï¸¾","ã€Œ":"ï¹","ã€":"ï¹‚","ã€Ž":"ï¹ƒ","ã€":"ï¹„","ã€":"ï¸»","ã€‘":"ï¸¼","ã€”":"ï¸¹","ã€•":"ï¸º","ã€–":"ï¸—","ã€—":"ï¸˜","ï¼":"ï¸•","ï¼ˆ":"ï¸µ","ï¼‰":"ï¸¶","ï¼Œ":"ï¸","ï¼":"ï¸²","ï¼Ž":"ãƒ»","ï¼š":"ï¸“","ï¼›":"ï¸”","ï¼œ":"ï¸¿","ï¼ž":"ï¹€","ï¼Ÿ":"ï¸–","ï¼»":"ï¹‡","ï¼½":"ï¹ˆ","ï¼¿":"ï¸³","ï½›":"ï¸·","ï½œ":"â€•","ï½":"ï¸¸","ï½Ÿ":"ï¸µ","ï½ ":"ï¸¶","ï½¡":"ï¸’","ï½¢":"ï¹","ï½£":"ï¹‚"};function Ki$2(t,e,n,r,i,s,a,o,l,h){let u=t.trim();2===h&&(u=function(t){let e="";for(let n=0;n<t.length;n++){const r=t.charCodeAt(n+1)||null,i=t.charCodeAt(n-1)||null;e+=r&&qi$2(r)&&!Ji$2[t[n+1]]||i&&qi$2(i)&&!Ji$2[t[n-1]]||!Ji$2[t[n]]?t[n]:Ji$2[t[n]]}return e}(u));const c=[],p={positionedGlyphs:c,text:u,top:o[1],bottom:o[1],left:o[0],right:o[0],writingMode:h};let f;return f=function(t,e){const n=[];let r=0;for(let i=0;i<e.length;i++){const s=e[i];n.push(t.substring(r,s)),r=s}return r<t.length&&n.push(t.substring(r,t.length)),n}(u,function(t,e,n,r){if(!n)return[];if(!t)return[];const i=[],s=function(t,e,n,r){let i=0;for(let n=0;n<t.length;n++){const s=r[t.charCodeAt(n)];s&&(i+=s.metrics.advance+e)}return i/Math.max(1,Math.ceil(i/n))}(t,e,n,r);let a=0;for(let n=0;n<t.length;n++){const l=t.charCodeAt(n),h=r[l];h&&!Qi$2[l]&&(a+=h.metrics.advance+e),n<t.length-1&&(ts$3[l]||!((o=l)<11904)&&(ki$2(o)||vi$2(o)||Vi$2(o)||Li$2(o)||Pi$2(o)||fi$2(o)||Ai$2(o)||mi$2(o)||zi$2(o)||Ti$2(o)||Fi$2(o)||Ni$2(o)||gi$2(o)||yi$2(o)||di$2(o)||_i$2(o)||xi$2(o)||Wi$2(o)||Ci$2(o)||Si$2(o)))&&i.push(rs$3(n+1,a,s,i,ns$3(l,t.charCodeAt(n+1)),!1))}var o;return function t(e){return e?t(e.priorBreak).concat(e.index):[]}(rs$3(t.length,a,s,i,0,!0))}(u,a,n,e)),function(t,e,n,r,i,s,a,o,l,h){let u=0,c=0,p=0;const f=t.positionedGlyphs,d="right"===s?1:"left"===s?0:.5;for(let t=0;t<n.length;t++){let i=n[t];if(i=i.trim(),!i.length){c-=r;continue}const s=f.length;for(let t=0;t<i.length;t++){const n=i.charCodeAt(t),r=e[n];r&&(ji$2(n)&&1!==a?(32!==n&&f.push({glyph:n,x:u,y:0,vertical:!0}),u+=l+o):(32!==n&&f.push({glyph:n,x:u,y:c,vertical:!1}),u+=r.metrics.advance+o))}f.length!==s&&(p=Math.max(u-o,p),ss$3(f,e,s,f.length-1,d)),u=0,c-=r}const{horizontalAlign:y,verticalAlign:m}=is$3(i,void 0);!function(t,e,n,r,i,s,a){const o=(e-n)*i,l=-(-r*a+.5)*s;if(o||l)for(let e=0;e<t.length;e++)t[e].x+=o,t[e].y+=l}(f,d,y,m,p,r,n.length);const g=n.length*r;t.top+=-m*g,t.bottom=t.top+g,t.left+=-y*p,t.right=t.left+p}(p,e,f,r,i,s,h,a,l),!!c.length&&p}const Qi$2={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},ts$3={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function es$3(t,e,n,r){const i=Math.pow(t-e,2);return r?t<e?i/2:2*i:i+Math.abs(n)*n}function ns$3(t,e){let n=0;return 10===t&&(n-=1e4),40!==t&&65288!==t||(n+=50),41!==e&&65289!==e||(n+=50),n}function rs$3(t,e,n,r,i,s){let a=null,o=es$3(e,n,i,s);for(let t=0;t<r.length;t++){const l=r[t],h=es$3(e-l.x,n,i,s)+l.badness;h<=o&&(a=l,o=h)}return{index:t,x:e,priorBreak:a,badness:o}}function is$3(t,e){let n=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":n=e?1:0;break;case"left":case"top-left":case"bottom-left":n=e?0:1}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=e?1:0;break;case"top":case"top-right":case"top-left":r=e?0:1}return{horizontalAlign:n,verticalAlign:r}}function ss$3(t,e,n,r,i){if(!i)return;const s=e[t[r].glyph];if(s){const e=(t[r].x+s.metrics.advance)*i;if(!e)return;for(let i=n;i<=r;i++)t[i].x-=e}}function as$3(t){if(!function(t){for(const e of t)if(Gi$2(e.charCodeAt(0)))return!0;return!1}(t))return t;const e=[],n=[],r=[];let i=0,s=0,a=1,o=1;for(const l of t){const t=l.codePointAt(0);Bi$2(t)?(r.push(l),i++):(a=Gi$2(t)?-1:1,o!==a?(s=i,n.length&&(o>0&&n.reverse(),e.push(...n)),r.length&&(e.splice(s,0,...r),r.length=0),o=a,n.length=0):r.length&&(n.push(...r),r.length=0),n.push(l),i++)}return r.length&&n.push(...r),n.length&&(o>0&&n.reverse(),e.push(...n)),e.reverse().join("")}const os$3=/\{ *([\w_]+) *\}/g;class ls$3{constructor(t,e,n,r,i){this.feature=t,this.symbolDef=e,this.symbol=n,this.options=i,this._thisReplacer=this._replacer.bind(this),this._fnTypes=r}_replacer(t,e){return this.feature.properties[e]||"default"}getShape(t,e){if(this._shape)return this._shape;const{textHorizontalAlignmentFn:n,textVerticalAlignmentFn:r,markerHorizontalAlignmentFn:i,markerVerticalAlignmentFn:s,textWrapWidthFn:a}=this._fnTypes;let o;const l=this.symbol,h=this.getIconAndGlyph(),u=this.feature.properties;if(h&&h.glyph){const{font:t,text:i}=h.glyph;if(""===i)return null;const s=this.size[0]/24,c=24,p=l.textKeepUpright,f="map"===l.textRotationAlignment&&"line"===l.textPlacement&&!l.isIconText,d=e.glyphMap[t],y=hs$3(n?n(null,u):l.textHorizontalAlignment,r?r(null,u):l.textVerticalAlignment),m=1.2*c,g=function(t){for(let e=0;e<t.length;e++)if(!Hi$2(t.charAt(e).charCodeAt(0)))return!1;return!0}(i),x=g&&l.textLetterSpacing/s||0,v=[l.textDx/s||0,l.textDy/s||0],b=((a?a(null,u):l.textWrapWidth)||10*c)/s;o={},o.horizontal=Ki$2(i,d,b,m,y,"center",x,v,c,1),g&&f&&p&&(o.vertical=Ki$2(i,d,b,m,y,"center",x,v,c,2))}else if(h&&h.icon){if(!t.positions[h.icon.url])return null;const e=hs$3(i?i(null,u):l.markerHorizontalAlignment,s?s(null,u):l.markerVerticalAlignment);o=function(t,e,n){let{horizontalAlign:r,verticalAlign:i}=is$3(e,n);n?r=1-r:i=1-i;const s=-2048*r,a=-2048*i;return{image:t,top:a,bottom:a+2048,left:s,right:s+2048}}(t.positions[h.icon.url],e,this.options.isVector3D),this.size||(this.size=o.image.displaySize)}return this._shape=o,o}getIconAndGlyph(){if(this.iconGlyph)return this.iconGlyph;const{markerFileFn:t,markerTypeFn:e,markerPathFn:i,markerWidthFn:s,markerHeightFn:a,markerFillFn:o,markerFillPatternFileFn:l,markerFillOpacityFn:h,markerTextFitFn:u,markerTextFitPaddingFn:c,markerLineColorFn:p,markerLineWidthFn:f,markerLineOpacityFn:d,markerLineDasharrayFn:y,markerLinePatternFileFn:m,markerPathWidthFn:g,markerPathHeightFn:x,textNameFn:v,textFaceNameFn:b,textStyleFn:w,textWeightFn:k}=this._fnTypes,{zoom:A}=this.options,_={},F=this.symbol,P=this.feature.properties,z=t?t(null,P):F.markerFile,M=e?e(null,P):F.markerType,T=z||M||F.markerPath,S=!$$4(this.symbolDef.textName);let C;if(T){C=function(t,e,n,r,i,s){if($$4(e.markerWidth)&&$$4(e.markerHeight))return null;const a="__fn_markerWidth".trim(),o="__fn_markerHeight".trim();let l=e.markerWidth||0,h=e.markerHeight||0;return H$4(l)&&("identity"!==l.type?l=qr$3(l):(l=t.markerWidth,t[a]&&(l=t[a](r,n)),H$4(l)&&(l="identity"===l.type?i(r,n):qr$3(l)))),H$4(h)&&("identity"!==h.type?h=qr$3(h):(h=t.markerHeight,t[o]&&(h=t[o](r,n)),H$4(h)&&(h="identity"===h.type?s(r,n):qr$3(h)))),[l,h]}(F,this.symbolDef,P,A,s,a)||[0,0];let t=F.markerTextFit;if(u&&(t=u(A,P)),t&&F.text&&"none"!==t){const e=F.text.textSize;let i=F.text.textName;isFunctionDefinition(i)&&(i=interpolated(i)(A,P));const s=Br$3(i,P);if(s){const i="__fn_textSize".trim(),a="__fn_textSize_0".trim();isFunctionDefinition(e)&&!F.text[i]&&(F.text[a]=interpolated(e),F.text[i]=(t,e)=>{const i=F.text[a](t,e);return isFunctionDefinition(i)?interpolated(i)(t,e):i});const o=jr$3(F.text,F.text,P,A);if("width"!==t&&"both"!==t||(C[0]=o[0]*s.length),"height"!==t&&"both"!==t||(C[1]=o[1]),o[0]&&o[1]){let t=F.markerTextFitPadding||[0,0,0,0];c&&(t=c(A,P)),C[0]+=t[1]+t[3],C[1]+=t[0]+t[2]}}else C[0]=C[1]=-1}}if(S&&(C=jr$3(F,this.symbolDef,P,A)),!C)return _;if(C[0]=Math.ceil(C[0]),C[1]=Math.ceil(C[1]),this.size=C,T&&C[0]>=0&&C[1]>=0){let t;if(M){const e={};if(e.markerType=M,"path"===M&&(e.markerPath=i?i(null,P):F.markerPath,e.markerPathWidth=g?g(null,P):F.markerPathWidth,e.markerPathHeight=x?x(null,P):F.markerPathHeight),s){const t=s(null,P);$$4(t)||(e.markerWidth=t)}else F.markerWidth>=0&&(e.markerWidth=F.markerWidth);if(a){const t=a(null,P);$$4(t)||(e.markerHeight=t)}else F.markerHeight>=0&&(e.markerHeight=F.markerHeight);if(o){const t=o(null,P);$$4(t)||(e.markerFill=t)}else F.markerFill&&(e.markerFill=F.markerFill);if(l){const t=l(null,P);$$4(t)||(e.markerFillPatternFile=t)}else F.markerFillPatternFile&&(e.markerFillPatternFile=F.markerFillPatternFile);if(h){const t=h(null,P);$$4(t)||(e.markerFillOpacity=t)}else F.markerFillOpacity>=0&&(e.markerFillOpacity=F.markerFillOpacity);if(p){const t=p(null,P);$$4(t)||(e.markerLineColor=t)}else F.markerLineColor&&(e.markerLineColor=F.markerLineColor);if(f){const t=f(null,P);$$4(t)||(e.markerLineWidth=t)}else F.markerLineWidth>=0&&(e.markerLineWidth=F.markerLineWidth);if(d){const t=d(null,P);$$4(t)||(e.markerLineOpacity=t)}else F.markerLineOpacity>=0&&(e.markerLineOpacity=F.markerLineOpacity);if(y){const t=y(null,P);$$4(t)||(e.markerLineDasharray=t)}else F.markerLineDasharray&&(e.markerLineDasharray=F.markerLineDasharray);if(m){const t=m(null,P);$$4(t)||(e.markerLinePatternFile=t)}else F.markerLinePatternFile&&(e.markerLinePatternFile=F.markerLinePatternFile);t="vector://"+JSON.stringify(e)}else t=z?z.replace(os$3,this._thisReplacer):F.markerPath?function(t,e,n){if(!t.markerPath)return null;let r=1;const i=function(t){const e={stroke:{stroke:t.markerLineColor,"stroke-width":t.markerLineWidth,"stroke-opacity":t.markerLineOpacity,"stroke-dasharray":null,"stroke-linecap":"butt","stroke-linejoin":"round"},fill:{fill:t.markerFill,"fill-opacity":t.markerFillOpacity}};return 0===e.stroke["stroke-width"]&&(e.stroke["stroke-opacity"]=0),e}(t);N$4(t.markerOpacity)&&(r=t.markerOpacity),N$4(t.opacity)&&(r*=t.opacity);const s={};if(i){for(const t in i.stroke)X$5(i.stroke,t)&&($$4(i.stroke[t])||(s[t]=i.stroke[t]));for(const t in i.fill)X$5(i.fill,t)&&($$4(i.fill[t])||(s[t]=i.fill[t]))}const a=Array.isArray(t.markerPath)?t.markerPath:[t.markerPath];let o;const l=[];for(let t=0;t<a.length;t++)o=j$4(a[t])?{path:a[t]}:a[t],o=U$4({},o,s),o.d=o.path,delete o.path,l.push(o);const h=['<svg version="1.1"','xmlns="http://www.w3.org/2000/svg"'];r<1&&h.push('opacity="'+r+'"'),t.markerPathWidth&&t.markerPathHeight&&h.push('viewBox="0 0 '+t.markerPathWidth+" "+t.markerPathHeight+'"'),h.push('preserveAspectRatio="none"'),e&&h.push('width="'+e+'"'),n&&h.push('height="'+n+'"'),h.push("><defs></defs>");for(let t=0;t<l.length;t++){let e="<path ";for(const n in l[t])X$5(l[t],n)&&(e+=" "+n+'="'+l[t][n]+'"');e+="></path>",h.push(e)}return h.push("</svg>"),"data:image/svg+xml;base64,"+btoa(h.join(" "))}(F,C[0],C[1]):null;_.icon={url:t,size:C}}if(S){const t=v?v(this.options.zoom,P):F.textName;if(t||0===t){const e=Gr$3(b?b(null,P):F.textFaceName,w?w(null,P):F.textStyle,k?k(null,P):F.textWeight);let n=Br$3(t,P);n&&n.length&&(n=as$3(n),_.glyph={font:e,text:n})}}return this.iconGlyph=_,_}}function hs$3(t,e){e&&"middle"!==e||(e="center"),t&&"middle"!==t||(t="center");let n="center"!==e?e:"";return n+="center"!==t?(n.length?"-":"")+t:"",n
/*!
	 * From mapbox-gl-js
	 * MIT License
	 * https://github.com/mapbox/mapbox-gl-js
	 */}function us$3(e,n,r,i,s){const a=[];let o;for(let l=0;l<e.length;l++){const h=e[l];let u,c=!1;for(let e=0;e<h.length-1;e++){let l=h[e],p=h[e+1];l.x<n&&p.x<n||(l.x<n?(o=l,l=new pointGeometry(n,l.y+(n-l.x)/(p.x-l.x)*(p.y-l.y))._round(),l.z=o.z+(n-o.x)/(p.x-o.x)*(p.z-o.z),c=!0):p.x<n&&(o=p,p=new pointGeometry(n,l.y+(n-l.x)/(p.x-l.x)*(p.y-l.y))._round(),p.z=l.z+(n-l.x)/(o.x-l.x)*(o.z-l.z),c=!0),l.y<r&&p.y<r||(l.y<r?(o=l,l=new pointGeometry(l.x+(r-l.y)/(p.y-l.y)*(p.x-l.x),r)._round(),l.z=o.z+(r-o.y)/(p.y-o.y)*(p.z-o.z),c=!0):p.y<r&&(o=p,p=new pointGeometry(l.x+(r-l.y)/(p.y-l.y)*(p.x-l.x),r)._round(),p.z=l.z+(r-l.y)/(o.y-l.y)*(o.z-l.z),c=!0),l.x>=i&&p.x>=i||(l.x>=i?(o=l,l=new pointGeometry(i,l.y+(i-l.x)/(p.x-l.x)*(p.y-l.y))._round(),l.z=o.z+(i-o.x)/(p.x-o.x)*(p.z-o.z),c=!0):p.x>=i&&(o=p,p=new pointGeometry(i,l.y+(i-l.x)/(p.x-l.x)*(p.y-l.y))._round(),p.z=l.z+(i-l.x)/(o.x-l.x)*(o.z-l.z),c=!0),l.y>=s&&p.y>=s||(l.y>=s?(o=l,l=new pointGeometry(l.x+(s-l.y)/(p.y-l.y)*(p.x-l.x),s)._round(),l.z=o.z+(s-o.y)/(p.y-o.y)*(p.z-o.z),c=!0):p.y>=s&&(o=p,p=new pointGeometry(l.x+(s-l.y)/(p.y-l.y)*(p.x-l.x),s)._round(),p.z=l.z+(s-l.y)/(o.y-l.y)*(o.z-l.z),c=!0),u&&l.equals(u[u.length-1])||(u=[l],a.push(u)),c&&(u.clipped=!0),u.push(p)))))}}return a}class cs$3 extends pointGeometry{constructor(t,e,n,r){super(t,e),this.angle=n,void 0!==r&&(this.segment=r)}clone(){return new cs$3(this.x,this.y,this.angle,this.segment)}}
/*!
	 * From mapbox-gl-js
	 * MIT License
	 * https://github.com/mapbox/mapbox-gl-js
	 */function ps$3(t,e,n,r,i){if(void 0===e.segment)return!0;let s=e,a=e.segment+1,o=0;for(;o>-n/2;){if(a--,a<0)return!1;o-=t[a].dist(s),s=t[a]}o+=t[a].dist(t[a+1]),a++;const l=[];let h=0;for(;o<n/2;){const e=t[a],n=t[a+1];if(!n)return!1;let s=t[a-1].angleTo(e)-e.angleTo(n);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),l.push({distance:o,angleDelta:s}),h+=s;o-l[0].distance>r;)h-=l.shift().angleDelta;if(h>i)return!1;a++,o+=e.dist(n)}return!0}function fs$3(t,e,n,r,i,s,a,o,l,h,u){const c=function(t,e,n){return t?.6*e*n:0}(r,s,a),p=function(t,e){return Math.max(t?t.right-t.left:0,e?e.right-e.left:0)}(r,i),f=0===t[0].x||t[0].x===l||0===t[0].y||t[0].y===l;return e-p*a<e/4&&(e=p*a+e/4),function t(e,n,r,i,s,a,o,l,h,u,c){let p=0;const f=a/2,d=function(t){let e=0;for(let n=0;n<t.length-1;n++)e+=t[n].dist(t[n+1]);return e}(e);let y=0,m=n-r,g=[];for(let t=0;t<e.length-1;t++){const n=e[t],o=e[t+1],l=n.dist(o),x=o.angleTo(n);for(;m+r<y+l;){m+=r;const v=(m-y)/l,b=ds$3(n.x,o.x,v),w=ds$3(n.y,o.y,v),k=ds$3(n.z||0,o.z||0,v);if(b>=0&&b<h&&w>=0&&w<h&&m-f>=0&&m+f<=d){const r=new cs$3(b,w,x,t);r.z=k,u&&(r.axis=[n.y-w,b-n.x],r.angleR=k===(n.z||0)?0:Math.atan(.9*(k-(n.z||0))*c/n.dist(r))),r.line=e,r._round(),!i||ps$3(e,r,a,i,s)?g.push(r):i&&p++}}y+=l}return l||g.length||o||(g=t(e,y/2,r,i,s,a,o,!0,h,u,c)),g.countOutOfAngle=p,g}(t,f?e/2*o%e:(p/2+2*s)*a*o%e,e,c,n,p*a,f,!1,l,h,u)}function ds$3(t,e,n){return t*(1-n)+e*n}function ys$3(t,e){const n=t.length;if(n<=1)return[t];const r=[];let i,s;for(let e=0;e<n;e++){const n=rt$4(t[e]);0!==n&&(t[e].area=Math.abs(n),void 0===s&&(s=n<0),s===n<0?(i&&r.push(i),i=[t[e]]):i.push(t[e]))}if(i&&r.push(i),e>1)for(let t=0;t<r.length;t++)r[t].length<=e||(h(r[t],e,1,r[t].length-1,ms$3),r[t]=r[t].slice(0,e));return r}function ms$3(t,e){return e.area-t.area}function gs$3(t,e,n){const r=e.distSqr(n);if(0===r)return t.distSqr(e);const i=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;return t.distSqr(i<0?e:i>1?n:n.sub(e)._mult(i)._add(e))}function xs$2(e,n=1,r=!1){let i=1/0,s=1/0,a=-1/0,o=-1/0;const l=e[0];for(let t=0;t<l.length;t++){const e=l[t];(!t||e.x<i)&&(i=e.x),(!t||e.y<s)&&(s=e.y),(!t||e.x>a)&&(a=e.x),(!t||e.y>o)&&(o=e.y)}const h=Math.min(a-i,o-s);let c=h/2;const p=new TinyQueue([],vs$3);if(0===h)return new pointGeometry(i,s);for(let t=i;t<a;t+=h)for(let n=s;n<o;n+=h)p.push(new bs$3(t+c,n+c,c,e));let f=function(t){let e=0,n=0,r=0;const i=t[0];for(let t=0,s=i.length,a=s-1;t<s;a=t++){const s=i[t],o=i[a],l=s.x*o.y-o.x*s.y;n+=(s.x+o.x)*l,r+=(s.y+o.y)*l,e+=3*l}return new bs$3(n/e,r/e,0,t)}(e),d=p.length;for(;p.length;){const t=p.pop();(t.d>f.d||!f.d)&&(f=t,r&&console.log("found best %d after %d probes",Math.round(1e4*t.d)/1e4,d)),t.max-f.d<=n||(c=t.h/2,p.push(new bs$3(t.p.x-c,t.p.y-c,c,e)),p.push(new bs$3(t.p.x+c,t.p.y-c,c,e)),p.push(new bs$3(t.p.x-c,t.p.y+c,c,e)),p.push(new bs$3(t.p.x+c,t.p.y+c,c,e)),d+=4)}return r&&(console.log("num probes: "+d),console.log("best distance: "+f.d)),f.p}function vs$3(t,e){return e.max-t.max}function bs$3(e,n,r,i){this.p=new pointGeometry(e,n),this.h=r,this.d=function(t,e){let n=!1,r=1/0;for(let i=0;i<e.length;i++){const s=e[i];for(let e=0,i=s.length,a=i-1;e<i;a=e++){const i=s[e],o=s[a];i.y>t.y!=o.y>t.y&&t.x<(o.x-i.x)*(t.y-i.y)/(o.y-i.y)+i.x&&(n=!n),r=Math.min(r,gs$3(t,i,o))}}return(n?1:-1)*Math.sqrt(r)}(this.p,i),this.max=this.d+this.h*Math.SQRT2}function ws$3(t,e,n,r,i,s,a,o,l,h){const{feature:u,size:c,symbol:p}=t,f=c?24:0,d=i*(c?c[0]/f:1);if("line"===a){const t=[];t.countOutOfAngle=0;let i=u.geometry;s&&(i=us$3(u.geometry,0,0,s,s));for(let a=0;a<i.length;a++){const u=fs$3(i[a],o,n,p.isIconText?null:r&&r.vertical||r&&r.horizontal||r,null,f,p.isIconText?1:d,1,s||1/0,l,h);if(p.textPlacement&&!p.isIconText)for(let t=0;t<u.length;t++)u[t].startIndex=e.length/3;if(t.push.apply(t,u),p.textPlacement&&!p.isIconText)for(let t=0;t<i[a].length;t++)e.push(i[a][t].x,i[a][t].y,i[a][t].z||0);t.countOutOfAngle+=u.countOutOfAngle||0}return t}return function(t,e,n,r,i){const s=[];if(3===t.type){const a=ys$3(t.geometry,0);for(let t=0;t<a.length;t++){const o=a[t];if("vertex"===e)for(let t=0;t<o.length;t++){const e=o[t];for(let a=0;a<e.length;a++)ot$4(e[a],n)||(s.push(e[a]),r&&(0===a?As$2(e[a],e[a],e[t+1],i):As$2(e[a],e[a-1],e[a],i)))}else if("vertex-first"===e){const t=o[0];t&&t[0]&&!ot$4(t[0],n)&&(s.push(t[0]),r&&As$2(t[0],t[0],t[1],i))}else if("vertex-last"===e||"vertex-firstlast"===e){const t=o[0];if("vertex-firstlast"===e&&t&&t[0]&&!ot$4(t[0],n)&&(s.push(t[0]),r&&As$2(t[0],t[0],t[1],i)),t&&t[t.length-1]&&!ot$4(t[t.length-1],n)){const e=t.length-1;s.push(t[e]),r&&As$2(t[e],t[e-1],t[e],i)}}else{const t=xs$2(o,16);ot$4(t,n)||s.push(t)}}}else if(2===t.type)for(let a=0;a<t.geometry.length;a++){const o=t.geometry[a];if("vertex"===e)for(let t=0;t<o.length;t++)ot$4(o[t],n)||(s.push(o[t]),r&&(0===t?As$2(o[t],o[t],o[t+1],i):As$2(o[t],o[t-1],o[t],i)));else if("vertex-last"===e||"vertex-firstlast"===e){if("vertex-firstlast"!==e||ot$4(o[0],n)||(s.push(o[0]),r&&As$2(o[0],o[0],o[1],i)),o&&o[o.length-1]&&!ot$4(o[o.length-1],n)){const t=o.length-1;s.push(o[t]),r&&As$2(o[t],o[t-1],o[t],i)}}else ot$4(o[0],n)||(s.push(o[0]),r&&As$2(o[0],o[0],o[1],i))}else if(1===t.type)for(let e=0;e<t.geometry.length;e++){const i=t.geometry[e];for(let t=0;t<i.length;t++){const e=i[t];ot$4(e,n)||(r&&(e.xRotation=0,e.yRotation=0,e.zRotation=0),s.push(e))}}return s}(u,a,s)}function As$2(t,e,n,r){if(t.xRotation||t.yRotation||t.zRotation)return t;const i=n.x-e.x,s=e.y-n.y,a=(n.z-e.z)*r,o=Math.atan2(s,i);t.zRotation=o;const l=Math.atan2(a,Math.sqrt(i*i+s*s));return t.xyRotation=l,t}function _s$2(t,e){const n={},r={},i=[];let s=0;function a(e){i.push(t[e]),s++}function o(t,e,n){const s=r[t];return delete r[t],r[e]=s,i[s].geometry[0].pop(),i[s].geometry[0]=i[s].geometry[0].concat(n[0]),s}function l(t,e,r){const s=n[e];return delete n[e],n[t]=s,i[s].geometry[0].shift(),i[s].geometry[0]=r[0].concat(i[s].geometry[0]),s}function h(t,e,n){const r=n?e[0][e[0].length-1]:e[0][0];return`${t}:${r.x}:${r.y}`}for(let u=0;u<t.length;u++){const c=t[u],p=c.geometry;if(!p)continue;const f=c.properties[e]?c.properties[e].toString():null;if(!f){a(u);continue}const d=h(f,p),y=h(f,p,!0);if(d in r&&y in n&&r[d]!==n[y]){const t=l(d,y,p),e=o(d,y,i[t].geometry);delete n[d],delete r[y],r[h(f,i[e].geometry,!0)]=e,i[t].geometry=null}else d in r?o(d,y,p):y in n?l(d,y,p):(a(u),n[d]=s-1,r[y]=s-1)}return i.filter((t=>t.geometry))}class Ps$2 extends $r$3{static needMerge(t,e,n){if(!t)return!1;let r="line"===t.textPlacement||"line"===t.markerPlacement;return r||(e.textPlacementFn&&(r="line"===e.textPlacementFn(n)),e.markerPlacementFn&&(r="line"===e.markerPlacementFn(n))),t.mergeOnProperty&&r}static mergeLineFeatures(t,e,n,r){const i="__index".trim();let s=e.textPlacement,a=e.markerPlacement;n.textPlacementFn&&(s=n.textPlacementFn(r)),n.markerPlacementFn&&(a=n.markerPlacementFn(r));const o=function(t,e,n,r,i){const s="__index".trim(),a=$r$3.genFnTypes(e),{mergeOnPropertyFn:o}=a;if(!e.mergeOnProperty||"line"!==r&&"line"!==n)return[];if(!(lt$4(l=e.mergeOnProperty)||"string"!=typeof l&&(null===l.constructor||l.constructor!==String)||"line"!==r&&"line"!==n))return[{features:t,property:e.mergeOnProperty}];var l;const h=[],u={},c=[];for(let a=0;a<t.length;a++){t[a][s]=a;const l=t[a].properties=t[a].properties||{};l.$layer=t[a].layer,l.$type=t[a].type;let p=n;"line"!==p&&(p=r);const f=o?o(i,l):e.mergeOnProperty;"line"!==p||lt$4(f)?c.push(t[a]):(void 0===u[f]&&(u[f]=h.length,h.push({features:[],property:f})),h[u[f]].features.push(t[a]))}return c.length&&h.push({features:c}),h}(t,e,a,s,r);if(o.length){const e=[];for(let n=0;n<o.length;n++)e.push(o[n].property?_s$2(o[n].features,o[n].property):t);if(1===e.length)return e[0];{let t=[];for(let n=0;n<e.length;n++)t=t.concat(e[n]);return t.sort(((t,e)=>t[i]-e[i])),t}}}static splitPointSymbol(t,e=0){const n=[];if(Array.isArray(t)){const e=t;for(let t=0;t<e.length;t++)e[t]&&n.push(...Ps$2.splitPointSymbol(e[t],t));return n}let r=null,i=null;for(const e in t)0===e.indexOf("marker")?(r=r||{},r[e]=t[e]):0===e.indexOf("text")&&(i=i||{},i[e]=t[e]);return r&&(r.isIconText=!0,t.mergeOnProperty&&(r.mergeOnProperty=t.mergeOnProperty),n.push(r)),i&&(r&&(i.textPlacement=r.markerPlacement,i.textSpacing=r.markerSpacing,i.isIconText=!0),t.mergeOnProperty&&(i.mergeOnProperty=t.mergeOnProperty),n.push(i)),void 0!==t.visible&&(r&&(r.visible=t.visible),i&&(i.visible=t.visible)),r&&(r.markerTextFit&&i&&(r.text={},r.text.textName=i.textName,r.text.textSize=i.textSize),r.index={index:e,type:0}),i&&(i.index={index:e,type:1}),n}static isAtlasLoaded(t,e){const{icon:n,glyph:r}=t,{iconAtlas:i,glyphAtlas:s}=e;if(n&&(!i||!i.positions[n.url]))return!1;if(r){if(!s||!s.positions[r.font])return!1;const t=s.positions[r.font],{text:e}=r;for(let n=0;n<e.length;n++)if(!t[e.charCodeAt(n)])return!1}return!0}constructor(t,e,n){super(t,e,n),this._textPlacement=e.textPlacement,this._fnTypes.textPlacementFn&&(this._textPlacement=this._fnTypes.textPlacementFn(this.options.zoom))}createStyledVector(t,e,n,r,i,s){const a=new ls$3(t,this.symbolDef,e,n,r),o=a.getIconAndGlyph();if(o.icon&&!this.options.atlas){const{url:t,size:e}=o.icon;i[t]||(i[t]=o.icon.size),i[t][0]<e[0]&&(i[t][0]=e[0]),i[t][1]<e[1]&&(i[t][1]=e[1])}if(o.glyph&&!this.options.atlas){const{font:t,text:e}=o.glyph,n=s[t]=s[t]||{};for(let t=0;t<e.length;t++)n[e.charCodeAt(t)]=1;"line"===this._textPlacement&&(s.options={isCharsCompact:!1})}return this.options.allowEmptyPack||o.icon||o.glyph?a:null}getFormat(t){const e=void 0!==t.textName,n=e?this.getPackSDFFormat(t):this.getPackMarkerFormat();e?n.push(...this._getTextFnTypeFormats()):n.push(...this._getMarkerFnTypeFormats());const{markerOpacityFn:r,textOpacityFn:i,markerPitchAlignmentFn:s,textPitchAlignmentFn:a,markerRotationAlignmentFn:o,textRotationAlignmentFn:l,markerRotationFn:h,textRotationFn:u,markerAllowOverlapFn:c,textAllowOverlapFn:p,markerIgnorePlacementFn:f,textIgnorePlacementFn:d}=this._fnTypes;return(r||i)&&n.push({type:Uint8Array,width:1,name:"aColorOpacity"}),(s||a)&&n.push({type:Uint8Array,width:1,name:"aPitchAlign"}),(o||l)&&n.push({type:Uint8Array,width:1,name:"aRotationAlign"}),(h||u)&&n.push({type:Uint16Array,width:1,name:"aRotation"}),(c||p||f||d)&&n.push({type:Uint8Array,width:1,name:"aOverlap"}),n}_is3DPitchText(){return this.hasMapPitchAlign}_getTextFnTypeFormats(){const{textFillFn:t,textSizeFn:e,textHaloFillFn:n,textHaloRadiusFn:r,textHaloOpacityFn:i,textDxFn:s,textDyFn:a}=this._fnTypes,o=[];return t&&o.push({type:Uint8Array,width:4,name:"aTextFill"}),e&&o.push({type:Uint8Array,width:1,name:"aTextSize"}),n&&o.push({type:Uint8Array,width:4,name:"aTextHaloFill"}),r&&o.push({type:Uint8Array,width:1,name:"aTextHaloRadius"}),i&&o.push({type:Uint8Array,width:1,name:"aTextHaloOpacity"}),s&&o.push({type:Int8Array,width:1,name:"aTextDx"}),a&&o.push({type:Int8Array,width:1,name:"aTextDy"}),o}_getMarkerFnTypeFormats(){const{markerWidthFn:t,markerHeightFn:e,markerDxFn:n,markerDyFn:r}=this._fnTypes,i=[];return t&&i.push({type:this.options.markerWidthType||Uint8Array,width:1,name:"aMarkerWidth"}),e&&i.push({type:this.options.markerHeightType||Uint8Array,width:1,name:"aMarkerHeight"}),n&&i.push({type:Int8Array,width:1,name:"aMarkerDx"}),r&&i.push({type:Int8Array,width:1,name:"aMarkerDy"}),i}createDataPack(){if(!this.iconAtlas&&!this.glyphAtlas){if(!this.options.allowEmptyPack)return null;this.empty=!0}this.countOutOfAngle=0,this.lineVertex=[];const t=super.createDataPack.apply(this,arguments);return t?(t.lineVertex=new Int16Array(this.lineVertex),t.buffers.push(t.lineVertex.buffer),t):null}placeVector(e,r){const i=e.getShape(this.iconAtlas,this.glyphAtlas);if(!(this.options.allowEmptyPack||i&&i.image||i&&(i.horizontal||i.vertical)))return;const s=this._getAnchors(e,i,r);if(this.countOutOfAngle+=s.countOutOfAngle||0,0===s.length)return;const a=this.data,o=this.needAltitudeAttribute()?2:3;let l=this.data.aPosition.length/o;const h=e.symbol,u=e.feature.properties,c="line"===this._textPlacement&&!h.isIconText,p=void 0!==h.textName,f=p&&c&&function(t){let e=0;for(let n=0;n<t.length;n++)if(ji$2(t.charAt(n).charCodeAt(0)))e=0;else if(e++,e>=1)return!1;return!0}(e.getIconAndGlyph().glyph.text)?1:0,{textFillFn:d,textSizeFn:y,textHaloFillFn:m,textHaloRadiusFn:g,textHaloOpacityFn:x,textDxFn:v,textDyFn:b,textPitchAlignmentFn:w,textRotationAlignmentFn:k,textRotationFn:A,textAllowOverlapFn:_,textIgnorePlacementFn:F,textOpacityFn:P,markerWidthFn:z,markerHeightFn:M,markerDxFn:T,markerDyFn:S,markerPitchAlignmentFn:C,markerRotationAlignmentFn:D,markerRotationFn:I,markerAllowOverlapFn:E,markerIgnorePlacementFn:O,markerOpacityFn:L}=this._fnTypes;let R,W,V,U,$,N,H,j,q,G,X,B,J,Z,Y,K,tt;if(p){const r=e.getIconAndGlyph().glyph.font;R=function(e,n,r){const i=e.positionedGlyphs,s=[];for(let a=0;a<i.length;a++){const o=i[a],l=r[o.glyph];if(!l)continue;const h=l.rect;if(!h)continue;const u=4,c=l.metrics.advance/2,p=l.metrics.height/2,f=n?[o.x+c,0]:[0,0],d=n?[0,o.y-p]:[o.x+c,o.y-p],y=l.metrics.left-u-c+d[0],m=l.metrics.top-u+d[1],g=y+h.w,x=m+h.h,v=new pointGeometry(y,m),b=new pointGeometry(g,m),w=new pointGeometry(y,x),k=new pointGeometry(g,x);if(n&&o.vertical){const e=new pointGeometry(-c,c),n=-Math.PI/2,r=new pointGeometry(5,0);v._rotateAround(n,e)._add(r),b._rotateAround(n,e)._add(r),w._rotateAround(n,e)._add(r),k._rotateAround(n,e)._add(r)}s.push({tl:v,tr:b,bl:w,br:k,tex:h,writingMode:e.writingMode,glyphOffset:f})}return s}(i.horizontal,c,this.glyphAtlas.positions[r]),d&&(W=d(null,u),isFunctionDefinition(W)?(this.dynamicAttrs.aTextFill=1,W=[0,0,0,0]):W=Q$5([],W)),y&&(V=y(this.options.zoom,u),lt$4(V)&&(V=14)),m&&(U=m(null,u),isFunctionDefinition(U)?(this.dynamicAttrs.aTextHaloFill=1,U=[0,0,0,0]):U=Q$5([],U)),g&&($=g(null,u)),x&&(N=255*x(null,u)),v&&(H=v(null,u)||0),b&&(j=b(null,u)||0),w&&(J=+("map"===w(null,u))),k&&(Z=+("map"===k(null,u))),A&&(Y=ht$4(A(null,u),0,360)*Math.PI/180)}else R=i?function(e){const n=e.image,r=e.top-1/n.pixelRatio,i=e.left-1/n.pixelRatio,s=e.bottom+1/n.pixelRatio,a=e.right+1/n.pixelRatio;let o,l,h,u;return o=new pointGeometry(i,r),l=new pointGeometry(a,r),h=new pointGeometry(a,s),u=new pointGeometry(i,s),[{tl:o,tr:l,bl:u,br:h,tex:{x:n.tl[0],y:n.tl[1],w:n.displaySize[0],h:n.displaySize[1]},writingMode:void 0,glyphOffset:[0,0]}]}(i):function(){const e=new pointGeometry(0,0),n=new pointGeometry(0,0),r=new pointGeometry(0,0);return[{tl:e,tr:n,bl:new pointGeometry(0,0),br:r,tex:{x:0,y:0,w:0,h:0},writingMode:void 0,glyphOffset:[0,0]}]}(),z&&(q=z(null,u)),lt$4(q)&&(q=R[0].tex.w),M&&(G=M(null,u)),lt$4(G)&&(G=R[0].tex.h),T&&(X=T(null,u)),S&&(B=S(null,u)),C&&(J=+("map"===C(null,u))),D&&(Z=+("map"===D(null,u))),I&&(Y=ht$4(I(null,u),0,360)*Math.PI/180);isFunctionDefinition(V)&&(this.dynamicAttrs.aTextSize=1),isFunctionDefinition($)&&(this.dynamicAttrs.aTextHaloRadius=1),isFunctionDefinition(N)&&(this.dynamicAttrs.aTextHaloOpacity=1),isFunctionDefinition(H)&&(this.dynamicAttrs.aTextDx=1),isFunctionDefinition(j)&&(this.dynamicAttrs.aTextDy=1),isFunctionDefinition(q)&&(this.dynamicAttrs.aMarkerWidth=1),isFunctionDefinition(G)&&(this.dynamicAttrs.aMarkerHeight=1),isFunctionDefinition(X)&&(this.dynamicAttrs.aMarkerDx=1),isFunctionDefinition(B)&&(this.dynamicAttrs.aMarkerDy=1),isFunctionDefinition(J)&&(this.dynamicAttrs.aPitchAlign=1),isFunctionDefinition(Z)&&(this.dynamicAttrs.aRotationAlign=1),isFunctionDefinition(Y)&&(this.dynamicAttrs.aRotation=1);const et=E||_;et&&(K=et(null,u)||0);const nt=O||F;let rt;nt&&(tt=nt(null,u)||0);const it=P||L;it&&(rt=255*it(this.options.zoom,u));const st=this.options.EXTENT,ut=R.length,{altitudeScale:ct,altitudeProperty:pt,defaultAltitude:ft}=this.options,{altitude:dt}=at$4(e.feature,ct,pt,ft);for(let t=0;t<s.length;t++){const e=s[t],n=e.z||dt||0;if(st!==1/0&&ot$4(e,st))continue;const r=e.x,i=e.y,o=R.length;for(let t=0;t<o;t++){const s=R[t],{tl:o,tr:h,bl:u,br:d,tex:y}=s;this._fillPos(a,r,i,n,10*o.x,10*o.y,y.x,y.y+y.h),p&&this._fillData(a,c,ut,s.glyphOffset,e,f,e.axis,e.angleR),this._fillFnTypeData(a,W,V,U,$,N,H,j,q,G,X,B,rt,J,Z,Y,K,tt),this._fillPos(a,r,i,n,10*h.x,10*h.y,y.x+y.w,y.y+y.h),p&&this._fillData(a,c,ut,s.glyphOffset,e,f,e.axis,e.angleR),this._fillFnTypeData(a,W,V,U,$,N,H,j,q,G,X,B,rt,J,Z,Y,K,tt),this._fillPos(a,r,i,n,10*u.x,10*u.y,y.x,y.y),p&&this._fillData(a,c,ut,s.glyphOffset,e,f,e.axis,e.angleR),this._fillFnTypeData(a,W,V,U,$,N,H,j,q,G,X,B,rt,J,Z,Y,K,tt),this._fillPos(a,r,i,n,10*d.x,10*d.y,y.x+y.w,y.y),p&&this._fillData(a,c,ut,s.glyphOffset,e,f,e.axis,e.angleR),this._fillFnTypeData(a,W,V,U,$,N,H,j,q,G,X,B,rt,J,Z,Y,K,tt),this.addElements(l,l+1,l+2),this.addElements(l+1,l+2,l+3),l+=4;const m=Math.max(Math.abs(r),Math.abs(i),Math.abs(n));m>this.maxPos&&(this.maxPos=m)}}}_fillPos(t,e,n,r,i,s,a,o){this.fillPosition(t,e,n,r),t.aShape.push(i,s),t.aTexCoord.push(a,o)}_fillData(t,e,n,r,i,s,a,o){if(t.aCount.push(n),e){t.aGlyphOffset.push(r[0],r[1]),this._is3DPitchText()&&t.aPitchRotation.push(a[0],a[1],o);const e=i.startIndex;t.aSegment.push(i.segment+e,e,i.line.length),t.aVertical.push(s)}}_fillFnTypeData(t,e,n,r,i,s,a,o,l,h,u,c,p,f,d,y,m,g){const{textFillFn:x,textSizeFn:v,textHaloFillFn:b,textHaloRadiusFn:w,textHaloOpacityFn:k,textDxFn:A,textDyFn:_,textPitchAlignmentFn:F,textRotationAlignmentFn:P,textRotationFn:z,textAllowOverlapFn:M,textIgnorePlacementFn:T,textOpacityFn:S,markerWidthFn:C,markerHeightFn:D,markerDxFn:I,markerDyFn:E,markerPitchAlignmentFn:O,markerRotationAlignmentFn:L,markerRotationFn:R,markerAllowOverlapFn:W,markerIgnorePlacementFn:V,markerOpacityFn:U}=this._fnTypes;x&&t.aTextFill.push(...e),v&&t.aTextSize.push(n),b&&t.aTextHaloFill.push(...r),w&&t.aTextHaloRadius.push(i),k&&t.aTextHaloOpacity.push(s),A&&t.aTextDx.push(a),_&&t.aTextDy.push(o),C&&t.aMarkerWidth.push(l),D&&t.aMarkerHeight.push(h),I&&t.aMarkerDx.push(u),E&&t.aMarkerDy.push(c),(U||S)&&t.aColorOpacity.push(p),(F||O)&&t.aPitchAlign.push(f),(L||P)&&t.aRotationAlign.push(d),(R||z)&&t.aRotation.push(9362*y);const $=W||M,N=V||T;($||N)&&t.aOverlap.push(($?8:0)+4*m+((N?2:0)+g)),i>0&&(this.properties.hasHalo=1)}_getAnchors(t,e,n){const{feature:r,symbol:i}=t,s=this._getPlacement(t,i),a=r.properties,{markerSpacingFn:o,textSpacingFn:l,textMaxAngleFn:h}=this._fnTypes,u=((o?o(null,a):i.markerSpacing)||(l?l(null,a):i.textSpacing)||250)*n;let c=h?h(this.options.zoom,a):i.textMaxAngle;lt$4(c)&&(c=80),c*=Math.PI/180;const p=this.options.EXTENT,f=this.options.altitudeToTileScale,d=this._is3DPitchText();return ws$3(t,this.lineVertex,c,e,n,p,s,u,d,f)}_getPlacement(t,e){let n;return n=this._fnTypes.markerPlacementFn?this._fnTypes.markerPlacementFn(this.options.zoom,t.feature.properties):e.markerPlacement||this._textPlacement,this._packMarkerPlacement||!e.markerPlacement&&!e.isIconText||(this._packMarkerPlacement=n),!this._textPlacement||e.isIconText||this._packTextPlacement||(this._packTextPlacement=n),n}getPackSDFFormat(t){if("line"!==this._textPlacement||t.isIconText)return[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"},{type:Uint8Array,width:1,name:"aCount"}];{const t=[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"},{type:Uint8Array,width:1,name:"aCount"},{type:Int16Array,width:2,name:"aGlyphOffset"},{type:Uint16Array,width:3,name:"aSegment"},{type:Uint8Array,width:1,name:"aVertical"}];return this._is3DPitchText()&&t.push({type:Float32Array,width:3,name:"aPitchRotation"}),t}}getPackMarkerFormat(){return[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"}]}}class zs$2{constructor(t){this.x=t.x,this.y=t.y,this.z=t.z||0}clone(){return new zs$2(this)}_unit(){return this._div(this.mag()),this}_div(t){return this.x/=t,this.y/=t,this.z/=t,this}_perp(){var t=this.y;return this.y=this.x,this.x=-t,this}mag(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}add(t){return this.clone()._add(t)}sub(t){return this.clone()._sub(t)}_add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}_sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}mult(t){return this.clone()._mult(t)}_mult(t){return this.x*=t,this.y*=t,this.z*=t,this}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){var e=t.x-this.x,n=t.y-this.y,r=t.z-this.z;return e*e+n*n+r*r}_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}}const Ms$2=Math.cos(Math.PI/180*37.5),Ts$2=Math.pow(2,16)/1,Ss$2=new pointGeometry,Cs$2=new pointGeometry,Ds$2=new pointGeometry;class Is$2 extends $r$3{constructor(t,e,n){super(t,e,n);let r=!1;const{lineDasharrayFn:i,lineDashColorFn:s}=this._fnTypes;this.hasGradient=this.symbol.lineGradientProperty,i&&(r=function(t,e,n){for(let r=0;r<t.length;r++)if(n(e,t[r].properties))return!0;return!1}(t,this.options.zoom,i),r&&(this.dasharrayFn=i)),this.hasDasharray=Ls$2(this.symbol.lineDasharray)||r,this.hasDasharray&&s&&(this.dashColorFn=s)}createStyledVector(t,e,n,r,i){const s=new ct$4(t,e,n,r),a=s.getLineResource();return!this.options.atlas&&a&&(i[a]=[0,0]),s}getFormat(){const{lineWidthFn:t,lineStrokeWidthFn:e,lineStrokeColorFn:n,lineColorFn:r,lineOpacityFn:i,lineDxFn:s,lineDyFn:a,linePatternAnimSpeedFn:o,linePatternGapFn:l}=this._fnTypes,h=[...this.getPositionFormat()];if(h.push(this.iconAtlas||this.hasDasharray?{type:Int8Array,width:3,name:"aExtrude"}:{type:Int8Array,width:2,name:"aExtrude"}),h.push({type:this.options.positionType||Uint16Array,width:1,name:"aLinesofar"}),t&&h.push({type:Uint8Array,width:1,name:"aLineWidth"}),e&&h.push({type:Uint8Array,width:1,name:"aLineStrokeWidth"}),r&&h.push({type:Uint8Array,width:4,name:"aColor"}),n&&h.push({type:Uint8Array,width:4,name:"aStrokeColor"}),i&&h.push({type:Uint8Array,width:1,name:"aOpacity"}),this.dasharrayFn&&h.push({type:Uint8Array,width:4,name:"aDasharray"}),this.dashColorFn&&h.push({type:Uint8Array,width:4,name:"aDashColor"}),this.iconAtlas){const t=this.getIconAtlasMaxValue();h.push({type:t>255?Uint16Array:Uint8Array,width:4,name:"aTexInfo"})}return(s||a)&&h.push({type:Int8Array,width:2,name:"aLineDxDy"}),(o||l)&&h.push({type:Int8Array,width:2,name:"aLinePattern"}),h}placeVector(t){const{lineJoinFn:e,lineCapFn:r,lineWidthFn:i,lineHeightFn:s,lineStrokeWidthFn:a,lineStrokeColorFn:o,lineColorFn:l,lineOpacityFn:h,lineDxFn:u,lineDyFn:c,linePatternAnimSpeedFn:p,linePatternGapFn:f}=this._fnTypes,d=this.symbol,y=t.feature,m=y.properties;let g=d.lineJoin||"miter",x=d.lineCap||"butt";if(e&&(g=e(this.options.zoom,m)||"miter"),r&&(x=r(this.options.zoom,m)||"butt"),i){let t=i(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLineWidth=1,t=4),$$4(t)&&(t=4),this.feaLineWidth=+t}else this.feaLineWidth=+d.lineWidth;if(s){let t=s(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLineHeight=1),$$4(t)&&(t=this.feaLineWidth),this.feaLineHeight=+t}else this.feaLineHeight=+d.lineHeight||this.feaLineWidth;if(a){let t=a(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLineStrokeWidth=1,t=0),$$4(t)&&(t=0),this.feaLineStrokeWidth=t}else this.feaLineStrokeWidth=d.lineStrokeWidth||0;if(l&&(this.feaColor=l(this.options.zoom,m)||[255,255,255,255],isFunctionDefinition(this.feaColor)?(this.dynamicAttrs.aColor=1,this.feaColor=[0,0,0,0]):this.feaColor=Q$5([],this.feaColor)),o&&(this.feaStrokeColor=o(this.options.zoom,m)||[0,0,0,255],isFunctionDefinition(this.feaStrokeColor)?(this.dynamicAttrs.aStrokeColor=1,this.feaStrokeColor=[0,0,0,0]):this.feaStrokeColor=Q$5([],this.feaStrokeColor)),h){let t=h(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aOpacity=1,t=1),$$4(t)&&(t=1),this.feaOpacity=255*t}if(this.dasharrayFn){let t=this.dasharrayFn(this.options.zoom,m)||[0,0,0,0];if(isFunctionDefinition(t)&&(this.dynamicAttrs.aDasharray=1,t=[0,0,0,0]),t.length<4){const e=t;1===t.length?t=[e[0],e[0],e[0],e[0]]:2===t.length?t=[e[0],e[1],e[0],e[1]]:3===t.length&&(t=[e[0],e[1],e[2],e[2]])}this.feaDash=t}if(this.dashColorFn){let t=(this.dashColorFn?this.dashColorFn(this.options.zoom,m):this.symbol.lineDashColor)||[0,0,0,0];isFunctionDefinition(t)&&(this.dynamicAttrs.aDashColor=1,t=[0,0,0,0]),t=Q$5([],t),this.feaDashColor=t}if(this.iconAtlas){const e=t.getLineResource(),n=this.iconAtlas.glyphMap[e];if(this.feaTexInfo=this.feaTexInfo||[0,0,0,0],n){const{tl:t,displaySize:n}=this.iconAtlas.positions[e];this.feaTexInfo[0]=t[0]+1,this.feaTexInfo[1]=t[1]+1,this.feaTexInfo[2]=n[0]-3,this.feaTexInfo[3]=n[1]-3}else this.feaTexInfo[0]=this.feaTexInfo[1]=this.feaTexInfo[2]=this.feaTexInfo[3]=0}if(u){let t=u(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLineDxDy=1,t=0),$$4(t)&&(t=0),this.feaLineDx=t}if(c){let t=c(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLineDxDy=1,t=0),$$4(t)&&(t=0),this.feaLineDy=t}if(p){let t=p(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLinePatternAnimSpeed=1,t=0),$$4(t)&&(t=0),0!==t&&(this.properties.hasPatternAnim=1),this.feaPatternAnimSpeed=t}if(f){let t=f(this.options.zoom,m);isFunctionDefinition(t)&&(this.dynamicAttrs.aLinePatternGap=1,t=0),$$4(t)&&(t=0),this.feaLinePatternGap=t}const v=this.options.EXTENT;let b=y.geometry;if(v!==1/0){b=[];const t=[];for(let e=0;e<y.geometry.length;e++){t[0]=y.geometry[e];const n=us$3(t,-1,-1,v+1,v+1);if(3===y.type&&n.length>1){const t=n[0],e=n[n.length-1];Us$2(t[0],e[e.length-1])&&(n[0]=e.concat(t.slice(1)),n.length=n.length-1)}b.push(...n)}}const w=this.needAltitudeAttribute()?2:3;for(let t=0;t<b.length;t++)this.offset=this.data.aPosition.length/w,this._addLine(b[t],y,g,x,2,1.05)}_hasPattern(){return this.iconAtlas&&this.feaTexInfo[2]&&this.feaTexInfo[3]}_addLine(t,e,n,r,i,s){const a=this._hasPattern()||Ls$2(this.feaDash)||Ls$2(this.symbol.lineDasharray),o=this.options.isTube;o&&(t=t.map((t=>new zs$2(t)))),this.overscaling=1;const l=this.options.EXTENT;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.prevVertex=null,this.symbol.lineGradientProperty&&e.properties&&N$4(e.properties.mapbox_clip_start)&&N$4(e.properties.mapbox_clip_end)){this.clipStart=+e.properties.mapbox_clip_start,this.clipEnd=+e.properties.mapbox_clip_end;for(let e=0;e<t.length-1;e++)this.totalDistance+=t[e].dist(t[e+1]);this.updateScaledDistance()}const h=3===e.type&&!t.clipped;let u=t.length;for(;u>=2&&Us$2(t[u-1],t[u-2]);)u--;let c=0;for(;c<u-1&&Us$2(t[c],t[c+1]);)c++;if(u<(h?3:2))return;"bevel"===n&&(i=1.05);const p=this.overscaling<=16?15*l/(512*this.overscaling):0,f={vertexLength:0,primitiveLength:0,currentNormal:null};let d,y,m,g,x;this.e1=this.e2=-1,h&&(d=t[u-2],x=t[c].sub(d)._unit()._perp());for(let e=c;e<u;e++){if(m=e===u-1?h?t[c+1]:void 0:t[e+1],m&&Us$2(t[e],m))continue;x&&(g=x),d&&(y=d),d=t[e],m&&d.x===m.x&&d.y===m.y&&(d.x+=1e-4),x=m?m.sub(d)._unit()._perp():g,f.dir=y?d.sub(y)._unit():m.sub(d)._unit(),g=g||x,f.currentNormal=g;let l=g.add(x);0===l.x&&0===l.y||l._unit();const v=g.x*x.x+g.y*x.y,b=l.x*x.x+l.y*x.y,w=0!==b?1/b:1/0,k=2*Math.sqrt(2-2*b),A=b<Ms$2&&y&&m,_=g.x*x.y-g.y*x.x>0;if(!o&&A&&e>c){const t=d.dist(y);if(t>2*p){const e=d.sub(d.sub(y)._mult(p/t)._round());e.z=d.z,this.updateDistance(y,e),this.addCurrentVertex(e,g,0,0,f),y=e}}const F=y&&m;f.middleVertex=F;let P=F?n:h?"butt":r;if(F&&"round"===P&&(w<s?P="miter":w<=2&&(P="fakeround")),"miter"===P&&w>i&&!o&&(P="bevel"),"bevel"===P&&(w>2&&(P="flipbevel"),w<i&&(P="miter")),y&&this.updateDistance(y,d),"miter"===P)o?(this.addCurrentVertex(d,g,0,0,f),f.dir=m.sub(d)._unit(),this.addCurrentVertex(d,x,0,0,f)):(l._mult(w),this.addCurrentVertex(d,l,0,0,f),a&&(f.currentNormal=x,this.addCurrentVertex(d,l,0,0,f)));else if("flipbevel"===P){if(w>100)l=x.mult(-1);else{const t=w*g.add(x).mag()/g.sub(x).mag();l._perp()._mult(t*(_?-1:1))}this.addCurrentVertex(d,l,0,0,f),this.addCurrentVertex(d,l.mult(-1),0,0,f)}else if("bevel"===P||"fakeround"===P){const t=-Math.sqrt(w*w-1),e=_?t:0,n=_?0:t;if(y&&this.addCurrentVertex(d,g,e,n,f),"fakeround"===P){const t=Math.round(180*k/Math.PI/20);for(let e=1;e<t;e++){let n=e/t;if(.5!==n){const t=n-.5;n+=n*t*(n-1)*((1.0904+v*(v*(3.55645-1.43519*v)-3.2452))*t*t+(.848013+v*(.215638*v-1.06021)))}const r=x.sub(g)._mult(n)._add(g)._unit()._mult(_?-1:1);this.addHalfVertex(d,r.x,r.y,!1,_,0,f)}}m&&(f.currentNormal=x,this.addCurrentVertex(d,x,-e,-n,f))}else if("butt"===P)this.addCurrentVertex(d,l,0,0,f);else if("square"===P){const t=y?1:-1;this.addCurrentVertex(d,l,t,t,f)}else"round"===P&&(y&&(this.addCurrentVertex(d,g,0,0,f),this.addCurrentVertex(d,g,1,1,f,!0)),m&&(this.addCurrentVertex(d,x,-1,-1,f,!0),this.addCurrentVertex(d,x,0,0,f)));if(!o&&A&&e<u-1){const t=d.dist(m);if(t>2*p){const e=d.add(m.sub(d)._mult(p/t)._round());e.z=d.z,this.updateDistance(d,e),this.addCurrentVertex(e,x,0,0,f),d=e}}}}addCurrentVertex(t,e,n,r,i,s=!1){const a=e.x+e.y*n,o=e.y-e.x*n,l=e.y*r-e.x,h=-e.y-e.x*r;let u=0,c=0;if(i.middleVertex){Ss$2.x=a,Ss$2.y=o,Cs$2.x=l,Cs$2.y=h;const t=i.currentNormal;if(u=Vs$2(t,Ss$2),0===n&&0===r)c=-u;else{const e=Ds$2;e.x=t.x,e.y=t.y,e._mult(-1),c=Vs$2(e,Cs$2)}}this.addHalfVertex(t,a,o,s,!1,n,i,u),this.addHalfVertex(t,l,h,s,!0,-r,i,c),this.prevVertex&&Us$2(t,this.prevVertex)||(this.prevVertex=t),this.distance>Ts$2/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,e,n,r,i,s))}addHalfVertex({x:t,y:e,z:n},r,i,s,a,o,l,h){this.fillData(this.data,t,e,n||0,r,i,s,a,1*this.scaledDistance,h);const u=l.vertexLength++;this.e1>=0&&this.e2>=0&&(this.addElements(this.e1,this.e2,u),l.primitiveLength++),a?this.e2=u:this.e1=u}fillData(t,e,n,r,i,s,a,o,l,h){const{lineWidthFn:u,lineStrokeWidthFn:c,lineStrokeColorFn:p,lineColorFn:f,lineOpacityFn:d,lineDxFn:y,lineDyFn:m,linePatternAnimSpeedFn:g,linePatternGapFn:x}=this._fnTypes;this.fillPosition(t,e,n,r);let v=63*i;v=(Math.sign(v)||1)*((Math.floor(Math.abs(v))>>1<<1)+ +a);let b=63*s;b=(Math.sign(b)||1)*((Math.floor(Math.abs(b))>>1<<1)+ +o),t.aExtrude.push(v,b),(this.iconAtlas||this.hasDasharray)&&t.aExtrude.push(63*h),t.aLinesofar.push(l),u&&t.aLineWidth.push(Math.round(2*this.feaLineWidth)),c&&t.aLineStrokeWidth.push(Math.round(2*this.feaLineStrokeWidth)),f&&t.aColor.push(...this.feaColor),p&&t.aStrokeColor.push(...this.feaStrokeColor),d&&t.aOpacity.push(this.feaOpacity),this.dasharrayFn&&t.aDasharray.push(...this.feaDash),this.dashColorFn&&t.aDashColor.push(...this.feaDashColor),this.iconAtlas&&t.aTexInfo.push(...this.feaTexInfo),(y||m)&&t.aLineDxDy.push(this.feaLineDx||0,this.feaLineDy||0),(g||x)&&t.aLinePattern.push(127*(this.feaPatternAnimSpeed||0),10*(this.feaLinePatternGap||0)),this.maxPos=Math.max(this.maxPos,Math.abs(e)+1,Math.abs(n)+1)}addElements(t,e,n){super.addElements(this.offset+t,this.offset+e,this.offset+n)}_filterPolygonEdges(t){const e=this.options.EXTENT,n=this.elements;for(let r=0;r<n.length;r+=3)e!==1/0&&(Os$2(this.data.aPosition,n[r],n[r+1],3,e)||Os$2(this.data.aPosition,n[r+1],n[r+2],3,e))||t.push(n[r],n[r+1],n[r+2])}_filterLine(t){if(t.length<=1)return t;const e=[],n=this.options.EXTENT;let r,i=!0;for(r=0;r<t.length-1;r++){const s=Es$2(t[r],t[r+1],n);s&&i||(e.push(t[r]),i=s)}return i||e.push(t[r]),e}updateDistance(t,e){if(this.options.isTube){const n=t.dist(e),r=Z$5(this.options)*(e.z-t.z);this.distance+=Math.sqrt(n*n+r*r)}else this.distance+=t.dist(e);this.updateScaledDistance()}updateScaledDistance(){this.scaledDistance=this.totalDistance>0?(this.clipStart+(this.clipEnd-this.clipStart)*this.distance/this.totalDistance)*(Ts$2-1):this.distance}}function Es$2(t,e,n){return n!==1/0&&(t.x<0&&e.x<0||t.x>n&&e.x>n||t.y<0&&e.y<0||t.y>n&&e.y>n)}function Os$2(t,e,n,r,i){if(i===1/0)return!1;const s=Math.floor(.5*t[e*r]),a=Math.floor(.5*t[e*r+1]),o=Math.floor(.5*t[n*r]),l=Math.floor(.5*t[n*r+1]);return s===o&&(s<0||s>i)&&a!==l||a===l&&(a<0||a>i)&&s!==o}function Ls$2(t){if(!Array.isArray(t))return!1;for(let e=0;e<t.length;e++)if(t[e])return!0;return!1}const Rs$2=new pointGeometry(0,0),Ws$2=new pointGeometry(0,0);function Vs$2(t,e){const n=t.mag(),r=e.mag();Rs$2.x=e.x,Rs$2.y=e.y;const i=t.angleTo(Ws$2),s=e.angleTo(Ws$2);return Math.sign(s-i)*Math.sqrt(r*r-n*n)}function Us$2(t,e){return t.equals(e)&&t.z===e.z}
/*!
	 * from @turf/bboxClip
	 * https://github.com/Turfjs/turf
	 * MIT LICENSE
	 */const Gs$2=[],Xs$2=[];function Bs$2(e,n){var r,i,s,a,o,l,h;for(i=1;i<=8;i*=2){for(r=[],a=!(Zs$2(s=e[e.length-1],n)&i),o=0;o<e.length;o++){if((h=!(Zs$2(l=e[o],n)&i))!==a){const e=Js$2(s,l,i,n);r.push(void 0!==l.x?new pointGeometry(e[0],e[1]):e)}h&&r.push(l),s=l,a=h}if(!(e=r).length)break}return r}function Js$2(t,e,n,r){return Gs$2[0]=void 0===t.x?t[0]:t.x,Gs$2[1]=void 0===t.y?t[1]:t.y,t=Gs$2,Xs$2[0]=void 0===e.x?e[0]:e.x,Xs$2[1]=void 0===e.y?e[1]:e.y,e=Xs$2,8&n?[t[0]+(e[0]-t[0])*(r[3]-t[1])/(e[1]-t[1]),r[3]]:4&n?[t[0]+(e[0]-t[0])*(r[1]-t[1])/(e[1]-t[1]),r[1]]:2&n?[r[2],t[1]+(e[1]-t[1])*(r[2]-t[0])/(e[0]-t[0])]:1&n?[r[0],t[1]+(e[1]-t[1])*(r[0]-t[0])/(e[0]-t[0])]:null}function Zs$2(t,e){Gs$2[0]=void 0===t.x?t[0]:t.x,Gs$2[1]=void 0===t.y?t[1]:t.y;var n=0;return(t=Gs$2)[0]<e[0]?n|=1:t[0]>e[2]&&(n|=2),t[1]<e[1]?n|=4:t[1]>e[3]&&(n|=8),n}const Ys$2=[0,0,0,0];class Qs$2 extends $r$3{constructor(...t){super(...t),this.lineElements=[]}createStyledVector(t,e,n,r,i){const s=new ct$4(t,e,n,r),a=s.getPolygonResource();return!this.options.atlas&&a&&(i[a]=[0,0]),s}getFormat(){const t=[...this.getPositionFormat()],{polygonFillFn:e,polygonOpacityFn:n,uvScaleFn:r,uvOffsetFn:i,polygonPatternUVFn:s}=this._fnTypes;if(this.iconAtlas){const e=this.getIconAtlasMaxValue();t.push({type:e>255?Uint16Array:Uint8Array,width:4,name:"aTexInfo"})}return e&&t.push({type:Uint8Array,width:4,name:"aColor"}),n&&t.push({type:Uint8Array,width:1,name:"aOpacity"}),r&&t.push({type:Uint16Array,width:2,name:"aUVScale"}),i&&t.push({type:Uint8Array,width:2,name:"aUVOffset"}),s&&t.push({type:Float32Array,width:2,name:"aTexCoord"}),t}placeVector(t,e){const n=t.feature;this._addPolygon(n.geometry,n,e)}_addPolygon(t,e){let r,i,s,a;const{polygonFillFn:o,polygonOpacityFn:l,uvScaleFn:h,uvOffsetFn:u,uvOffsetInMeterFn:c,polygonPatternUVFn:d}=this._fnTypes,y=e.properties;o&&(r=o(this.options.zoom,y)||set$3([],255,255,255,255),isFunctionDefinition(r)?(this.dynamicAttrs.aColor=1,r=Ys$2):r=Q$5([],r)),l&&(i=l(this.options.zoom,y),isFunctionDefinition(i)?(this.dynamicAttrs.aOpacity=1,i=255):($$4(i)&&(i=1),i*=255)),h&&(s=h(this.options.zoom,y),isFunctionDefinition(s)?(s=[255,255],this.dynamicAttrs.aUVScale=1):($$4(s)&&(s=[1,1]),s=[255*s[0],255*s[1]])),u&&(c&&c(null,y)?a=[0,0]:(a=u(this.options.zoom,y),isFunctionDefinition(a)?(a=[0,0],this.dynamicAttrs.aUVOffset=1):($$4(a)&&(a=[0,0]),a=[255*a[0],255*a[1]])));const m=!!this.iconAtlas,g=ys$3(t,500),x=[0,0],v=[0,0];if(m){const{polygonPatternFileFn:t}=this._fnTypes,e=t?t(null,y):this.symbol.polygonPatternFile;if(this.iconAtlas.glyphMap[e]){const t=this.iconAtlas.positions[e];x[0]=t.tl[0]+1,x[1]=t.tl[1]+1,v[0]=t.displaySize[0]-3,v[1]=t.displaySize[1]-3}}let b,w=0;d&&(b=d(this.options.zoom,y));const k=this.needAltitudeAttribute()?2:3,A=[-1,-1,e.extent+1,e.extent+1],_=this._flattened=this._flattened||this._arrayPool.get(),F=this._holeIndices=this._holeIndices||this._arrayPool.get();for(let t=0;t<g.length;t++){const e=g[t],n=this.data.aPosition.length/k;_.setLength(0),F.setLength(0);for(let t=0;t<e.length;t++){let n=e[t];if(this.options.EXTENT!==1/0&&0===this.maxPosZ&&(n=Bs$2(n,A)),0!==n.length){0!==t&&F.push(_.length/3);for(let t=0;t<n.length;t++){const e=n[t].x,o=n[t].y,l=n[t].z||0;if(this.fillPosition(this.data,e,o,l),m&&this.data.aTexInfo.push(x[0],x[1],v[0],v[1]),void 0!==r&&this.data.aColor.push(r[0],r[1],r[2],r[3]),void 0!==i&&this.data.aOpacity.push(i),void 0!==s&&this.data.aUVScale.push(s[0],s[1]),void 0!==a&&this.data.aUVOffset.push(a[0],a[1]),d){if(b){const t=$$4(b[2*w])?b[0]:b[2*w],e=$$4(b[2*w]+1)?b[1]:b[2*w+1];this.data.aTexCoord.push(t,e)}else this.data.aTexCoord.push(-9999999,-9999999);w++}const h=Math.abs(e),u=Math.abs(o);h>this.maxPos&&(this.maxPos=h),u>this.maxPos&&(this.maxPos=u),_.push(e,o,l)}}}let o=earcut$1.exports(_,F,3);if(_.length&&!o.length){const t=[];for(let e=0;e<_.length;e+=3)t[e]=_[e],t[e+1]=_[e+2],t[e+2]=_[e+1];if(o=earcut$1.exports(t,F,3),!o.length){for(let e=0;e<_.length;e+=3)t[e]=_[e+1],t[e+1]=_[e+2],t[e+2]=_[e];o=earcut$1.exports(t,F,3)}}for(let t=0;t<o.length;t+=3)this.addElements(n+o[t],n+o[t+1],n+o[t+2])}}}class ya$1{constructor(t){this.max=t,this.reset()}reset(){return this.data={},this.order=[],this}clear(){this.reset()}add(t,e){return this.has(t)?(this.order.splice(this.order.indexOf(t),1),this.data[t]=e,this.order.push(t)):(this.data[t]=e,this.order.push(t),this.order.length>this.max&&this.getAndRemove(this.order[0])),this}has(t){return t in this.data}keys(){return this.order}getAndRemove(t){if(!this.has(t))return null;const e=this.data[t];return delete this.data[t],this.order.splice(this.order.indexOf(t),1),e}get(t){return this.has(t)?this.data[t]:null}remove(t){return this.has(t)?(delete this.data[t],this.order.splice(this.order.indexOf(t),1),this):this}setMaxSize(t){for(this.max=t;this.order.length>this.max;)this.getAndRemove(this.order[0]);return this}}
/*!
	 * based on @mapbox/tiny-sdf
	 * https://github.com/mapbox/tiny-sdf
	 * @License BSD 2-Clause
	 */var ma$1=1e20;function ga$1(t,e,n,r,i,s,a){this.fontSize=t||24,this.buffer=void 0===e?3:e,this.cutoff=r||.25,this.fontFamily=i||"sans-serif",this.fontWeight=s||"normal",this.fontStyle=a||"normal",this.radius=n||8;var o=this.size=this.fontSize+2*this.buffer;this.canvas="undefined"==typeof document?new OffscreenCanvas(o,o):document.createElement("canvas"),this.canvas.width=this.canvas.height=o,this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),this.ctx.font=this.fontStyle+" "+this.fontWeight+" "+this.fontSize+"px "+this.fontFamily,this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.gridOuter=new Float64Array(o*o),this.gridInner=new Float64Array(o*o),this.f=new Float64Array(o),this.z=new Float64Array(o+1),this.v=new Uint16Array(o),this.middle=Math.round(o/2*(navigator.userAgent.indexOf("Gecko/")>=0?1.2:1))}function xa$1(t,e,n,r,i,s){for(var a=0;a<e;a++)va$1(t,a,e,n,r,i,s);for(var o=0;o<n;o++)va$1(t,o*e,1,e,r,i,s)}function va$1(t,e,n,r,i,s,a){var o,l,h,u;for(s[0]=0,a[0]=-ma$1,a[1]=ma$1,o=0;o<r;o++)i[o]=t[e+o*n];for(o=1,l=0,h=0;o<r;o++){do{h=(i[o]-i[u=s[l]]+o*o-u*u)/(o-u)/2}while(h<=a[l]&&--l>-1);s[++l]=o,a[l]=h,a[l+1]=ma$1}for(o=0,l=0;o<r;o++){for(;a[l+1]<o;)l++;t[e+o*n]=i[u=s[l]]+(o-u)*(o-u)}}ga$1.prototype.draw=function(t,e,n){this.ctx.clearRect(0,0,this.size,this.size),this.ctx.textBaseline="top",this.ctx.fillText(t,this.buffer,this.buffer);for(var r=this.ctx.getImageData(0,0,e,n),i=new Uint8ClampedArray(e*n),s=0;s<e*n;s++){var a=r.data[4*s+3]/255;this.gridOuter[s]=1===a?0:0===a?ma$1:Math.pow(Math.max(0,.5-a),2),this.gridInner[s]=1===a?ma$1:0===a?0:Math.pow(Math.max(0,a-.5),2)}for(xa$1(this.gridOuter,e,n,this.f,this.v,this.z),xa$1(this.gridInner,e,n,this.f,this.v,this.z),s=0;s<e*n;s++){var o=Math.sqrt(this.gridOuter[s])-Math.sqrt(this.gridInner[s]);i[s]=Math.round(255-255*(o/this.radius+this.cutoff))}return i};let ba$1=0;class wa$1{constructor(t,e=15,n){this.entries={},this._cachedFont={},this._cache=new ya$1(2048,(function(){})),this._framer=t,this._limit=e,this._isCompactChars=n}getGlyphs(t,e){if(!t||!Object.keys(t).length)return void e(null,{glyphs:null});const n=this.entries,r=t.options;let i=!0;r&&(i=!1!==r.isCharsCompact),i=i||this._isCompactChars;const s=(r,s,o)=>{let l=0,h=0;for(const e in t)if("options"!==e){n[e]=n[e]||{},s[e]=s[e]||{};for(const u in t[e]){if(h++,h<=r)continue;const t=e.split(" "),c=i&&"normal"===t[0]&&!ji$2(+u),p=e+":"+u+":"+c;let f;if(this._cache.has(p)?f=this._cache.get(p):(f=this._tinySDF(n[e],t,u,c),this._cache.add(p,f),l++),f=ka$1(f),s[e][u]=f,o.push(f.bitmap.data.buffer),this._framer&&l>this._limit)return void this._framer(a(h,s,o))}}e(null,{glyphs:s,buffers:o})};function a(t,e,n){return()=>{s(t,e,n)}}s(0,{},[])}_tinySDF(t,e,n,r){const i=e[0],s=e[1],a=e.slice(3).join(" ");let o=t.tinySDF,l="normal"!==i?5:2;const h=r?-1:2;if(!o){let e="400";/bolder/i.test(s)?e="1000":/bold/i.test(s)?e="900":/medium/i.test(s)?e="500":/light/i.test(s)&&(e="200"),o=t.tinySDF=new ga$1(24,l,8,.25,a,e,i)}const u=String.fromCharCode(n),c=o.ctx.measureText(u),p=Math.round(c.width),f=o.draw(String.fromCharCode(n),p+2*l,24+2*l);if(ba$1<4){const t="undefined"!=typeof document&&document.getElementById("sdf-debug-"+ba$1++);t&&(t.width=p+2*l,t.height=o.canvas.height,t.getContext("2d").drawImage(o.canvas,0,0))}return{charCode:n,bitmap:{width:p+2*l,height:24+2*l,data:f},metrics:{width:p,height:24,left:1,top:-l,advance:p+l+h}}}}function ka$1(t){const e={width:t.bitmap.width,height:t.bitmap.height,data:new Uint8ClampedArray(t.bitmap.data)};return{charCode:t.charCode,bitmap:e,metrics:U$4({},t.metrics)}}class Aa$1{constructor(t){this.options=t||{},this._requesting={},this._cache=new ya$1(256,(function(){}));const e=document.createElement("canvas");this.ctx=e.getContext("2d",{willReadFrequently:!0})}getIcons(t,e){if(!t||!Object.keys(t).length)return void e(null,{icons:null});const n=Object.keys(t),r={},i=[];let s=0,a=0;const o=this;function l(t,n){r[t]=o._getCache(t,n),r[t]&&"error"!==r[t]?i.push(r[t].data.data.buffer):delete r[t],a++,a===s&&e(null,{icons:r,buffers:i})}function h(t){const e=o._requesting[t.url];for(let n=0;n<e.length;n++)e[n].call(t,t.url,t.size);delete o._requesting[t.url]}function u(){const t=o.ctx;let e,n;try{e=this.width,n=this.height,this.size[0]=e,this.size[1]=n,o._ensureMaxSize(null,this.size),e=this.size[0],n=this.size[1],t.canvas.width=e,t.canvas.height=n,t.imageSmoothingEnabled=!1,t.drawImage(this,0,0,e,n);const r=t.getImageData(0,0,e,n).data;o._addCache(this.url,r,e,n)}catch(t){console.warn(t)}h(this)}function c(t){console.warn(`failed loading icon(${this.index}) at "${this.url}"`),console.warn(t),o.options.iconErrorUrl?this.src=o.options.iconErrorUrl:(o._addCache(this.url),h(this))}let p,f=!1;for(let e=0;e<n.length;e++){const a=n[e],o=t[a];this._ensureMaxSize(a,o);const h=this._getCache(a,o);if(h&&"error"!==h){r[a]=this._getCache(a,o);continue}if("error"===h)continue;let d,y=a;if(0===a.indexOf("vector://")&&(d=JSON.parse(a.substring("vector://".length)),"path"===d.markerType&&(y=t$1.Util.getMarkerPathBase64(d,d.markerWidth,d.markerHeight))),0===a.indexOf("vector://")&&"path"!==d.markerType){p=p||new t$1.Marker([0,0]);const{markerFill:t,markerLineColor:e}=d;t&&Array.isArray(t)&&(d.markerFill=_a$1(t)),e&&Array.isArray(e)&&(d.markerLineColor=_a$1(e)),delete d.markerHorizontalAlignment,delete d.markerVerticalAlignment,delete d.markerDx,delete d.markerDy,delete d.markerPlacement,delete d.markerFile,d.markerWidth=o[0],d.markerHeight=o[1],p.setSymbol(d);const n=p["_getSprite".trim()]();if(n){const t=n.canvas,e=t.width,s=t.height,o=t.getContext("2d").getImageData(0,0,e,s).data;r[a]={data:{data:new Uint8ClampedArray(o),width:e,height:s},url:a},i.push(r[a].data.data.buffer),this._addCache(a,o,e,s)}}else{if(this._requesting[a]){f=!0,s++,this._requesting[a].push(l);continue}this._requesting[a]=[],this._requesting[a].push(l);const t=new Image;t.index=e,t.size=o,t.onload=u,t.onerror=c,t.onabort=c,t.url=a,t.crossOrigin="Anonymous",f=!0,s++,t.src=y}}f||e(null,{icons:r,buffers:i})}_hasCache(t,e,n){const r=this._cache.get(t);return r&&"error"!==r&&r.data.width>=e&&r.data.height>=n}_addCache(t,e,n,r){this._hasCache(t,n,r)||this._cache.add(t,e?{data:{data:e,width:n,height:r},url:t}:"error")}_getCache(t,e){if(!this._hasCache(t,e[0],e[1]))return null;const n=this._cache.get(t);return n?"error"===n?n:{data:{data:new Uint8ClampedArray(n.data.data),width:n.data.width,height:n.data.height},url:n.url}:null}_ensureMaxSize(t,e){if(!e[0]||!e[1])return;const n=this.options.maxSize||2048;let[r,i]=e;const s=r/i;if(t){const e=this._cache.get(t);if(e&&"error"!==e){const{width:t,height:n}=e.data;t>r&&(r=t),n>i&&(i=n)}}r>n&&(i=n/s,r=n),i>n&&(r=n*s,i=n),e[0]=Math.floor(r),e[1]=Math.floor(i)}}function _a$1(t){return 3===t.length&&t.push(1),t.reduce(((t,e,n)=>t+(n<3?255*e+",":e+")")),"rgba(")}var Fa=Object.freeze({__proto__:null,clipPolygon:Bs$2,calculateSignedArea:rt$4,getFeaAltitudeAndHeight:at$4,generatePickingIndiceIndex:ut$4,convertRTLText:as$3,packPosition:pt$4,unpackPosition:function(t,e,n,r){const i=(Math.sign(e)||1)*(Math.abs(e)%ft$4),s=(Math.sign(n)||1)*(Math.abs(n)%ft$4),a=Math.floor(Math.abs(e)/ft$4),o=Math.floor(Math.abs(n)/ft$4);return t[0]=i,t[1]=s,t[2]=Math.sign(r+1e-5)*(2*a+o)*dt$4+r,t},convertGeometry:V$4,getPosArrayType:L$4,getUnsignedArrayType:R$4,getIndexArrayType:O$4});const Pa$1={},za={},Ma$1=[];var Ta$1=Object.freeze({__proto__:null,loadSymbolFnTypes:function t(e,i){if(!e)return null;var s=!1;if(Array.isArray(e)){var a,o=[];for(let n=0;n<e.length;n++)(a=t(e[n],i))?(o.push(a),s=!0):o.push(e[n]);return s?o:e}var l={__fn_types_loaded:!0};const h=[];for(const t in e)X$5(e,t)&&h.push(t);const u=function(t){Object.defineProperty(l,t,{get:function(){return this["__fn_"+t]||(this["__fn_"+t]=interpolated(this["_"+t])),this["__fn_"+t].apply(this,i())},set:function(e){this["_"+t]=e},configurable:!0,enumerable:!0})},c={},p=function(t,e){Object.defineProperty(l,t,{get:function(){this["__fn_"+t]||(this["__fn_"+t]=wr$3(this["_"+t],e));const n=i()[0];c.zoom=n;try{return this["__fn_"+t].evaluateWithoutErrorHandling(c,Pa$1,za,null,Ma$1)}catch(t){return null}},set:function(e){this["_"+t]=e},configurable:!0,enumerable:!0})};for(let t=0,r=h.length;t<r;t++){const r=h[t];if(isFunctionDefinition(e[r]))s=!0,l["_"+r]=e[r],u(r);else if(kr$3(e[r])){s=!0;const t=zr$3(r);l["_"+r]=e[r],p(r,t)}else l[r]=e[r]}return s?l:e}});const Ca={polygonPatternFile:1,markerFile:1,markerPlacement:1,markerSpacing:1,textName:1,textStyle:1,textFaceName:1,textWeight:1,textPlacement:1,textSpacing:1,lineJoin:1,lineCap:1,linePatternFile:1},Da={visible:1,textHorizontalAlignment:1,textVerticalAlignment:1,textWrapWidth:1,markerHorizontalAlignment:1,markerVerticalAlignment:1},Ia$1={lineDasharray:1,topPolygonFill:1,bottomPolygonFill:1};function quickselect(arr,k,left,right,compare){quickselectStep(arr,k,left||0,right||arr.length-1,compare||defaultCompare)}function quickselectStep(arr,k,left,right,compare){for(;right>left;){if(right-left>600){var n=right-left+1,m=k-left+1,z=Math.log(n),s=.5*Math.exp(2*z/3),sd=.5*Math.sqrt(z*s*(n-s)/n)*(m-n/2<0?-1:1);quickselectStep(arr,k,Math.max(left,Math.floor(k-m*s/n+sd)),Math.min(right,Math.floor(k+(n-m)*s/n+sd)),compare)}var t=arr[k],i=left,j=right;for(swap(arr,left,k),compare(arr[right],t)>0&&swap(arr,left,right);i<j;){for(swap(arr,i,j),i++,j--;compare(arr[i],t)<0;)i++;for(;compare(arr[j],t)>0;)j--}0===compare(arr[left],t)?swap(arr,left,j):swap(arr,++j,right),j<=k&&(left=j+1),k<=j&&(right=j-1)}}function swap(arr,i,j){var tmp=arr[i];arr[i]=arr[j],arr[j]=tmp}function defaultCompare(a,b){return a<b?-1:a>b?1:0}Object.assign(Da,Ca),Object.assign(Ia$1,Ca);class RBush{constructor(maxEntries=9){this._maxEntries=Math.max(4,maxEntries),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}all(){return this._all(this.data,[])}search(bbox){let node=this.data;const result=[];if(!intersects(bbox,node))return result;const toBBox=this.toBBox,nodesToSearch=[];for(;node;){for(let i=0;i<node.children.length;i++){const child=node.children[i],childBBox=node.leaf?toBBox(child):child;intersects(bbox,childBBox)&&(node.leaf?result.push(child):contains(bbox,childBBox)?this._all(child,result):nodesToSearch.push(child))}node=nodesToSearch.pop()}return result}collides(bbox){let node=this.data;if(!intersects(bbox,node))return!1;const nodesToSearch=[];for(;node;){for(let i=0;i<node.children.length;i++){const child=node.children[i],childBBox=node.leaf?this.toBBox(child):child;if(intersects(bbox,childBBox)){if(node.leaf||contains(bbox,childBBox))return!0;nodesToSearch.push(child)}}node=nodesToSearch.pop()}return!1}load(data){if(!data||!data.length)return this;if(data.length<this._minEntries){for(let i=0;i<data.length;i++)this.insert(data[i]);return this}let node=this._build(data.slice(),0,data.length-1,0);if(this.data.children.length)if(this.data.height===node.height)this._splitRoot(this.data,node);else{if(this.data.height<node.height){const tmpNode=this.data;this.data=node,node=tmpNode}this._insert(node,this.data.height-node.height-1,!0)}else this.data=node;return this}insert(item){return item&&this._insert(item,this.data.height-1),this}clear(){return this.data=createNode([]),this}remove(item,equalsFn){if(!item)return this;let node=this.data;const bbox=this.toBBox(item),path=[],indexes=[];let i,parent,goingUp;for(;node||path.length;){if(node||(node=path.pop(),parent=path[path.length-1],i=indexes.pop(),goingUp=!0),node.leaf){const index=findItem(item,node.children,equalsFn);if(-1!==index)return node.children.splice(index,1),path.push(node),this._condense(path),this}goingUp||node.leaf||!contains(node,bbox)?parent?(i++,node=parent.children[i],goingUp=!1):node=null:(path.push(node),indexes.push(i),i=0,parent=node,node=node.children[0])}return this}toBBox(item){return item}compareMinX(a,b){return a.minX-b.minX}compareMinY(a,b){return a.minY-b.minY}toJSON(){return this.data}fromJSON(data){return this.data=data,this}_all(node,result){const nodesToSearch=[];for(;node;)node.leaf?result.push(...node.children):nodesToSearch.push(...node.children),node=nodesToSearch.pop();return result}_build(items,left,right,height){const N=right-left+1;let node,M=this._maxEntries;if(N<=M)return node=createNode(items.slice(left,right+1)),calcBBox(node,this.toBBox),node;height||(height=Math.ceil(Math.log(N)/Math.log(M)),M=Math.ceil(N/Math.pow(M,height-1))),node=createNode([]),node.leaf=!1,node.height=height;const N2=Math.ceil(N/M),N1=N2*Math.ceil(Math.sqrt(M));multiSelect(items,left,right,N1,this.compareMinX);for(let i=left;i<=right;i+=N1){const right2=Math.min(i+N1-1,right);multiSelect(items,i,right2,N2,this.compareMinY);for(let j=i;j<=right2;j+=N2){const right3=Math.min(j+N2-1,right2);node.children.push(this._build(items,j,right3,height-1))}}return calcBBox(node,this.toBBox),node}_chooseSubtree(bbox,node,level,path){for(;path.push(node),!node.leaf&&path.length-1!==level;){let targetNode,minArea=1/0,minEnlargement=1/0;for(let i=0;i<node.children.length;i++){const child=node.children[i],area=bboxArea(child),enlargement=enlargedArea(bbox,child)-area;enlargement<minEnlargement?(minEnlargement=enlargement,minArea=area<minArea?area:minArea,targetNode=child):enlargement===minEnlargement&&area<minArea&&(minArea=area,targetNode=child)}node=targetNode||node.children[0]}return node}_insert(item,level,isNode){const bbox=isNode?item:this.toBBox(item),insertPath=[],node=this._chooseSubtree(bbox,this.data,level,insertPath);for(node.children.push(item),extend(node,bbox);level>=0&&insertPath[level].children.length>this._maxEntries;)this._split(insertPath,level),level--;this._adjustParentBBoxes(bbox,insertPath,level)}_split(insertPath,level){const node=insertPath[level],M=node.children.length,m=this._minEntries;this._chooseSplitAxis(node,m,M);const splitIndex=this._chooseSplitIndex(node,m,M),newNode=createNode(node.children.splice(splitIndex,node.children.length-splitIndex));newNode.height=node.height,newNode.leaf=node.leaf,calcBBox(node,this.toBBox),calcBBox(newNode,this.toBBox),level?insertPath[level-1].children.push(newNode):this._splitRoot(node,newNode)}_splitRoot(node,newNode){this.data=createNode([node,newNode]),this.data.height=node.height+1,this.data.leaf=!1,calcBBox(this.data,this.toBBox)}_chooseSplitIndex(node,m,M){let index,minOverlap=1/0,minArea=1/0;for(let i=m;i<=M-m;i++){const bbox1=distBBox(node,0,i,this.toBBox),bbox2=distBBox(node,i,M,this.toBBox),overlap=intersectionArea(bbox1,bbox2),area=bboxArea(bbox1)+bboxArea(bbox2);overlap<minOverlap?(minOverlap=overlap,index=i,minArea=area<minArea?area:minArea):overlap===minOverlap&&area<minArea&&(minArea=area,index=i)}return index||M-m}_chooseSplitAxis(node,m,M){const compareMinX=node.leaf?this.compareMinX:compareNodeMinX,compareMinY=node.leaf?this.compareMinY:compareNodeMinY;this._allDistMargin(node,m,M,compareMinX)<this._allDistMargin(node,m,M,compareMinY)&&node.children.sort(compareMinX)}_allDistMargin(node,m,M,compare){node.children.sort(compare);const toBBox=this.toBBox,leftBBox=distBBox(node,0,m,toBBox),rightBBox=distBBox(node,M-m,M,toBBox);let margin=bboxMargin(leftBBox)+bboxMargin(rightBBox);for(let i=m;i<M-m;i++){const child=node.children[i];extend(leftBBox,node.leaf?toBBox(child):child),margin+=bboxMargin(leftBBox)}for(let i=M-m-1;i>=m;i--){const child=node.children[i];extend(rightBBox,node.leaf?toBBox(child):child),margin+=bboxMargin(rightBBox)}return margin}_adjustParentBBoxes(bbox,path,level){for(let i=level;i>=0;i--)extend(path[i],bbox)}_condense(path){for(let siblings,i=path.length-1;i>=0;i--)0===path[i].children.length?i>0?(siblings=path[i-1].children,siblings.splice(siblings.indexOf(path[i]),1)):this.clear():calcBBox(path[i],this.toBBox)}}function findItem(item,items,equalsFn){if(!equalsFn)return items.indexOf(item);for(let i=0;i<items.length;i++)if(equalsFn(item,items[i]))return i;return-1}function calcBBox(node,toBBox){distBBox(node,0,node.children.length,toBBox,node)}function distBBox(node,k,p,toBBox,destNode){destNode||(destNode=createNode(null)),destNode.minX=1/0,destNode.minY=1/0,destNode.maxX=-1/0,destNode.maxY=-1/0;for(let i=k;i<p;i++){const child=node.children[i];extend(destNode,node.leaf?toBBox(child):child)}return destNode}function extend(a,b){return a.minX=Math.min(a.minX,b.minX),a.minY=Math.min(a.minY,b.minY),a.maxX=Math.max(a.maxX,b.maxX),a.maxY=Math.max(a.maxY,b.maxY),a}function compareNodeMinX(a,b){return a.minX-b.minX}function compareNodeMinY(a,b){return a.minY-b.minY}function bboxArea(a){return(a.maxX-a.minX)*(a.maxY-a.minY)}function bboxMargin(a){return a.maxX-a.minX+(a.maxY-a.minY)}function enlargedArea(a,b){return(Math.max(b.maxX,a.maxX)-Math.min(b.minX,a.minX))*(Math.max(b.maxY,a.maxY)-Math.min(b.minY,a.minY))}function intersectionArea(a,b){const minX=Math.max(a.minX,b.minX),minY=Math.max(a.minY,b.minY),maxX=Math.min(a.maxX,b.maxX),maxY=Math.min(a.maxY,b.maxY);return Math.max(0,maxX-minX)*Math.max(0,maxY-minY)}function contains(a,b){return a.minX<=b.minX&&a.minY<=b.minY&&b.maxX<=a.maxX&&b.maxY<=a.maxY}function intersects(a,b){return b.minX<=a.maxX&&b.minY<=a.maxY&&b.maxX>=a.minX&&b.maxY>=a.minY}function createNode(children){return{children,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function multiSelect(arr,left,right,n,compare){const stack=[left,right];for(;stack.length;){if((right=stack.pop())-(left=stack.pop())<=n)continue;const mid=left+Math.ceil((right-left)/n/2)*n;quickselect(arr,mid,left,right,compare),stack.push(left,mid,mid,right)}}
/*!
	* Contains code from jquery.easing
	* BSD License
	* https://github.com/gdsmith/jquery.easing/
	*/var pow=Math.pow,sqrt=Math.sqrt,sin=Math.sin,cos=Math.cos,PI=Math.PI,c1=1.70158,c2=1.525*c1,c3=c1+1,c4=2*PI/3,c5=2*PI/4.5;function bounceOut(x){var n1=7.5625,d1=2.75;return x<1/d1?n1*x*x:x<2/d1?n1*(x-=1.5/d1)*x+.75:x<2.5/d1?n1*(x-=2.25/d1)*x+.9375:n1*(x-=2.625/d1)*x+.984375}function X$4(easing,x){switch(easing=easing.toLowerCase()){case"swing":return function(x){return easeInQuad(x)}(x);case"easeinquad":return easeInQuad(x);case"easeoutquad":return function(x){return 1-(1-x)*(1-x)}(x);case"easeinoutquad":return function(x){return x<.5?2*x*x:1-pow(-2*x+2,2)/2}(x);case"easeincubic":return function(x){return x*x*x}(x);case"easeoutcubic":return function(x){return 1-pow(1-x,3)}(x);case"easeinoutcubic":return function(x){return x<.5?4*x*x*x:1-pow(-2*x+2,3)/2}(x);case"easeinquart":return function(x){return x*x*x*x}(x);case"easeoutquart":return function(x){return 1-pow(1-x,4)}(x);case"easeinoutquart":return function(x){return x<.5?8*x*x*x*x:1-pow(-2*x+2,4)/2}(x);case"easeinquint":return function(x){return x*x*x*x*x}(x);case"easeoutquint":return function(x){return 1-pow(1-x,5)}(x);case"easeinoutquint":return function(x){return x<.5?16*x*x*x*x*x:1-pow(-2*x+2,5)/2}(x);case"easeinsine":return function(x){return 1-cos(x*PI/2)}(x);case"easeoutsine":return function(x){return sin(x*PI/2)}(x);case"easeinoutsine":return function(x){return-(cos(PI*x)-1)/2}(x);case"easeinexpo":return function(x){return 0===x?0:pow(2,10*x-10)}(x);case"easeoutexpo":return function(x){return 1===x?1:1-pow(2,-10*x)}(x);case"easeinoutexpo":return function(x){return 0===x?0:1===x?1:x<.5?pow(2,20*x-10)/2:(2-pow(2,-20*x+10))/2}(x);case"easeincirc":return function(x){return 1-sqrt(1-pow(x,2))}(x);case"easeoutcirc":return function(x){return sqrt(1-pow(x-1,2))}(x);case"easeinoutcirc":return function(x){return x<.5?(1-sqrt(1-pow(2*x,2)))/2:(sqrt(1-pow(-2*x+2,2))+1)/2}(x);case"easeinelastic":return function(x){return 0===x?0:1===x?1:-pow(2,10*x-10)*sin((10*x-10.75)*c4)}(x);case"easeoutelastic":return function(x){return 0===x?0:1===x?1:pow(2,-10*x)*sin((10*x-.75)*c4)+1}(x);case"easeinoutelastic":return function(x){return 0===x?0:1===x?1:x<.5?-pow(2,20*x-10)*sin((20*x-11.125)*c5)/2:pow(2,-20*x+10)*sin((20*x-11.125)*c5)/2+1}(x);case"easeinback":return function(x){return c3*x*x*x-c1*x*x}(x);case"easeoutback":return function(x){return 1+c3*pow(x-1,3)+c1*pow(x-1,2)}(x);case"easeinoutback":return function(x){return x<.5?pow(2*x,2)*(7.189819*x-c2)/2:(pow(2*x-2,2)*((c2+1)*(2*x-2)+c2)+2)/2}(x);case"easeinbounce":return function(x){return 1-bounceOut(1-x)}(x);case"easeoutbounce":return function(x){return bounceOut(x)}(x);case"easeinoutbounce":return function(x){return x<.5?(1-bounceOut(1-2*x))/2:(1+bounceOut(2*x-1))/2}(x)}throw new Error("Unsupported easing function:"+easing)}function easeInQuad(x){return x*x}function VectorTilePlugin(){}const parentProto=VectorTilePlugin.prototype;parentProto.getType=function(){return Object.getPrototypeOf(this).constructor.type},parentProto.isVisible=function(){throw new Error("to be implemented.")},parentProto.prepareRender=function(){throw new Error("to be implemented.")},parentProto.updateCollision=function(){throw new Error("to be implemented.")},parentProto.supportRenderMode=function(){throw new Error("to be implemented.")},parentProto.startFrame=function(){throw new Error("to be implemented.")},parentProto.endFrame=function(){throw new Error("to be implemented.")},parentProto.paintTile=function(){throw new Error("to be implemented.")},parentProto.getShadowMeshes=function(){throw new Error("to be implemented.")},parentProto.updateSceneConfig=function(){throw new Error("to be implemented.")},parentProto.updateDataConfig=function(){throw new Error("to be implemented.")},parentProto.updateSymbol=function(){throw new Error("to be implemented.")},parentProto.pick=function(){throw new Error("to be implemented.")},parentProto.resize=function(){throw new Error("to be implemented.")},parentProto.deleteTile=function(){throw new Error("to be implemented.")},parentProto.remove=function(){throw new Error("to be implemented.")},parentProto.needToRedraw=function(){throw new Error("to be implemented.")},parentProto.needToRetireFrames=function(){throw new Error("to be implemented.")},parentProto.outline=function(){throw new Error("to be implemented.")},parentProto.outlineAll=function(){throw new Error("to be implemented.")},parentProto.needPolygonOffset=function(){throw new Error("to be implemented.")},parentProto.constructor=VectorTilePlugin;const hasOwn=Object.prototype.hasOwnProperty;function registerAt(VectorTileLayer){VectorTileLayer.registerPlugin(this)}
/*!
	 * @maptalks/vt v0.92.3
	 * LICENSE : undefined
	 * (c) 2016-2024 maptalks.org
	 */VectorTilePlugin.extend=function(type,props){const clazz=function(){this.init&&this.init()},proto=Object.create(parentProto);proto.constructor=clazz,clazz.prototype=proto,clazz.type=type;for(const p in props)hasOwn.call(props,p)&&(clazz.prototype[p]=props[p]);return clazz.registerAt=registerAt.bind(clazz),clazz};const q$4='function(t){let n;const e={width:100,height:10};function r(){if(!n){const{width:t,height:r}=e;OffscreenCanvas?n=new OffscreenCanvas(t,r):(n=document.createElement("canvas"),n.width=t,n.height=r)}return n}class i{constructor(t,n={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let r=1/0,i=-1/0;for(let n=0,e=t.length;n<e;n++){const e=t[n][0];r=Math.min(e,r),i=Math.max(e,i)}this.min=r,this.max=i,this.valueOffset=this.max-this.min,this.options=Object.assign({},e,n),this.t()}getImageData(){return this.imgData}t(){const t=r(),{width:n,height:e}=this.options;t.width=n,t.height=e;const i=t.getContext("2d");i.clearRect(0,0,t.width,t.height);const s=i.createLinearGradient(0,0,t.width,0),{colors:o,valueOffset:a}=this;for(let t=0,n=o.length;t<n;t++){const[n,e]=o[t],r=(n-this.min)/a;s.addColorStop(r,e)}i.fillStyle=s,i.fillRect(0,0,t.width,t.height),this.imgData=i.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const n=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let e=Math.round(n*this.imgData.width);e=Math.min(e,this.imgData.width-1);const r=4*e;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var s;function o(t,n){for(let e=0;e<t.stops.length;e++)if(n===t.stops[e][0])return t.stops[e][1];return t.default}function a(t,n){for(var e=0;e<t.stops.length&&!(n<t.stops[e][0]);e++);return t.stops[Math.max(e-1,0)][1]}function u(t,n){for(var e=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||n<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:function t(n,e,r,i,s,o){return"function"==typeof s?function(){var a=s.apply(void 0,arguments),u=o.apply(void 0,arguments);return t(n,e,r,i,a,u)}:s.length?function(t,n,e,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=f(t,n,e,r,i[a],s[a]);return o}(n,e,r,i,s,o):f(n,e,r,i,s,o)}(n,e,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(s=new Map);const h={width:100,height:1};function l(t,n){const e=t.stops;if(e&&e.length>1){let t;if(s){const n=JSON.stringify(e);if(!s.has(n)){const t=new i(e,h);s.set(n,t)}t=s.get(n)}else t=new i(e,h);const[r,o,a,u]=t.getColor(n);return[r/255,o/255,a/255,u/255]}return e&&1===e.length?e[0][1]:null}function c(t,n){return function(t,n,e){return void 0!==t?t:void 0!==n?n:void 0!==e?e:null}(n,t.default)}function f(t,n,e,r,i,s){var o,a=r-e,u=t-e;return i*(1-(o=1===n?u/a:(Math.pow(n,u)-1)/(Math.pow(n,a)-1)))+s*o}function d(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function p(t){return g(t,"exponential")}function y(t){return g(t,"interval")}function m(t,n){if(!t)return null;var e=!1;if(Array.isArray(t)){var r,i=[];for(let s=0;s<t.length;s++)(r=m(t[s],n))?(i.push(r),e=!0):i.push(t[s]);return e?i:t}var s,o={__fn_types_loaded:!0},a=[];for(s in t)t.hasOwnProperty(s)&&a.push(s);const u=function(t){Object.defineProperty(o,t,{get:function(){return this["__fn_"+t]||(this["__fn_"+t]=p(this["_"+t])),this["__fn_"+t].apply(this,n())},set:function(n){this["_"+t]=n},configurable:!0,enumerable:!0})};for(let n=0,r=a.length;n<r;n++)d(t[s=a[n]])?(e=!0,o["_"+s]=t[s],u(s)):o[s]=t[s];return e?o:t}function g(t,n){if(!d(t))return function(){return t};let e=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(d(i[t][1])){const s=g(i[t][1],n);e=e&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=function t(n,e){var r,i,s;if(d(n)){var h,f=n.stops&&"object"==typeof n.stops[0][0],p=f||void 0!==n.property,y=f||!p,m=n.type||e||"exponential";if("exponential"===m)h=u;else if("interval"===m)h=a;else if("categorical"===m)h=o;else if("identity"===m)h=c;else{if("color-interpolate"!==m)throw new Error(\'Unknown function type "\'+m+\'"\');h=l}if(f){var g={},v=[];for(let t=0;t<n.stops.length;t++){var b=n.stops[t];void 0===g[b[0].zoom]&&(g[b[0].zoom]={zoom:b[0].zoom,type:n.type,property:n.property,default:n.default,stops:[]}),g[b[0].zoom].stops.push([b[0].value,b[1]])}for(let n in g)v.push([g[n].zoom,t(g[n])]);r=function(t,e){const r=u({stops:v,base:n.base},t)(t,e);return"function"==typeof r?r(t,e):r},i=!1,s=!1}else y?(r=function(t){const e=h(n,t);return"function"==typeof e?e(t):e},i=!0,s=!1):(r=function(t,e){const r=h(n,e?e[n.property]:null);return"function"==typeof r?r(t,e):r},i=!1,s=!0)}else r=function(){return n},i=!0,s=!0;return r.isZoomConstant=s,r.isFeatureConstant=i,r}(t,n);return s.isZoomConstant=e&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}let v=0;const b="function"==typeof Object.assign;function w(t,...n){if(b)return Object.assign(t,...n),t;for(let e=0;e<n.length;e++){const r=n[e];for(const n in r)t[n]=r[n]}return t}function M(t){return!k(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function x(t){return"number"==typeof t&&!isNaN(t)}function F(t){return!k(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function A(t){return!Array.isArray(t)&&"object"==typeof t&&!!t}function k(t){return null==t}function P(t){for(let n=1;n<arguments.length;n++){const e=arguments[n];if(e)for(let n=0,r=e.length;n<r;n++)t.push(e[n])}return t.length}function S(t){return d(t)&&t.property}const _="function"==typeof fetch&&"function"==typeof AbortController,O={jsonp:function(t,n){const e="_maptalks_jsonp_"+v++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let r=document.createElement("script");return r.type="text/javascript",r.src=t,window[e]=function(t){n(null,t),document.getElementsByTagName("head")[0].removeChild(r),r=null,delete window[e]},document.getElementsByTagName("head")[0].appendChild(r),this},get:function(t,n,e){if(F(n)){const t=e;e=n,n=t}(n=n||{}).method&&(n.method=n.method.toUpperCase());const r="POST"===n.method;if(_){const r=new AbortController,i=n;i.signal=r.signal,i.referrerPolicy=i.referrerPolicy||"origin",i.method=i.method||"GET";const s=new Request(t,i);return n.returnJSON&&s.headers.set("Accept","application/json"),fetch(s).then(r=>{const i=this.s(r,n.returnJSON,n.responseType);i.message?(i.url=t,e(i)):i.then(t=>{"arraybuffer"===n.responseType?e(null,{data:t,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires"),contentType:r.headers.get("Content-Type")}):e(null,t)}).catch(n=>{n.code&&n.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,n),e(n))})}).catch(n=>{n.code&&n.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,n),e(n))}),r}{const i=O.o(e);if(i.open(n.method||"GET",t,!0),n){for(const t in n.headers)i.setRequestHeader(t,n.headers[t]);i.withCredentials="include"===n.credentials,n.responseType&&(i.responseType=n.responseType)}return i.send(r?n.body:null),i}},s:(t,n,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():n?t.json():t.text(),u:function(t,n){return function(){if(4===t.readyState)if(200===t.status)if("arraybuffer"===t.responseType){0===t.response.byteLength?n({status:200,statusText:t.statusText,message:"http status 200 returned without content."}):n(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")})}else n(null,t.responseText);else n({status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`})}},o:function(t){let n;try{n=new XMLHttpRequest}catch(t){try{n=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{n=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}}return n.onreadystatechange=O.u(n,t),n},getArrayBuffer(t,n,e){if(F(n)){const t=e;e=n,n=t}return n||(n={}),n.responseType="arraybuffer",O.get(t,n,e)}};function E(t,n,e,r,i,s){let o=i-e,a=s-r;if(0!==o||0!==a){const u=((t-e)*o+(n-r)*a)/(o*o+a*a);u>1?(e=i,r=s):u>0&&(e+=o*u,r+=a*u)}return o=t-e,a=n-r,o*o+a*a}function I(t,n,e,r,i,s){const o={id:null==t?null:t,type:n,geometry:e,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};i&&(o.layer=i);return function(t,n){const e=t.geometry,r=t.type;if("Point"===r||"MultiPoint"===r||"LineString"===r)$(t,e,n);else if("Polygon"===r)$(t,e[0],n);else if("MultiLineString"===r)for(const r of e)$(t,r,n);else if("MultiPolygon"===r)for(const r of e)$(t,r[0],n)}(o,s?4:3),o}function $(t,n,e){for(let r=0;r<n.length;r+=e)t.minX=Math.min(t.minX,n[r]),t.minY=Math.min(t.minY,n[r+1]),t.maxX=Math.max(t.maxX,n[r]),t.maxY=Math.max(t.maxY,n[r+1])}function C(t,n,e,r){if(r.layer=n,"FeatureCollection"===e.type)for(let n=0;n<e.features.length;n++)T(t,e.features[n],r,n);else"Feature"===e.type?T(t,e,r):T(t,{geometry:e},r)}function T(t,n,e,r){if(!n.geometry)return;const i=n.geometry.coordinates,s=n.geometry.type,o=Math.pow(e.tolerance/((1<<e.maxZoom)*e.extent),2);let a=[],u=n.id;if(e.promoteId?u=n.properties[e.promoteId]:e.generateId&&(u=r||0),"Point"===s)z(i,a,e);else if("MultiPoint"===s)for(const t of i)z(t,a,e);else if("LineString"===s)D(i,a,o,!1,e);else if("MultiLineString"===s){if(e.lineMetrics){for(const r of i)a=[],D(r,a,o,!1,e),t.push(I(u,"LineString",a,n.properties,e.layer,e.hasAltitude));return}j(i,a,o,!1,e)}else if("Polygon"===s)j(i,a,o,!0,e);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(const i of n.geometry.geometries)T(t,{id:u,geometry:i,properties:n.properties},e,r);return}throw new Error("Input data is not a valid GeoJSON object.")}for(const t of i){const n=[];j(t,n,o,!0,e),a.push(n)}}t.push(I(u,s,a,n.properties,e.layer,e.hasAltitude))}function z(t,n,e){n.push(U(t[0]),N(t[1],e.projection),0),e.hasAltitude&&(t.length>2?n.push(t[2]):n.push(0))}function D(t,n,e,r,i){let s,o,a=0;for(let e=0;e<t.length;e++){const u=U(t[e][0]),h=N(t[e][1],i.projection);n.push(u,h,0),i.hasAltitude&&(t[e].length>2?n.push(t[e][2]):n.push(0)),e>0&&(a+=r?(s*h-u*o)/2:Math.sqrt(Math.pow(u-s,2)+Math.pow(h-o,2))),s=u,o=h}const u=i.hasAltitude?4:3,h=n.length-u;n[2]=1,function t(n,e,r,i,s=3){let o=i;const a=r-e>>1;let u,h=r-e;const l=n[e],c=n[e+1],f=n[r],d=n[r+1];for(let t=e+s;t<r;t+=s){const e=E(n[t],n[t+1],l,c,f,d);if(e>o)u=t,o=e;else if(e===o){const n=Math.abs(t-a);n<h&&(u=t,h=n)}}o>i&&(u-e>s&&t(n,e,u,i,s),n[u+2]=o,r-u>s&&t(n,u,r,i,s))}(n,0,h,e,u),n[h+2]=1,n.size=Math.abs(a),n.start=0,n.end=n.size}function j(t,n,e,r,i){for(let s=0;s<t.length;s++){const o=[];D(t[s],o,e,r,i),n.push(o)}}function U(t){return t/360+.5}function N(t,n){switch(n){case"EPSG:4326":return(90-t)/360}const e=Math.sin(t*Math.PI/180),r=.5-.25*Math.log((1+e)/(1-e))/Math.PI;return r<0?0:r>1?1:r}function L(t,n,e,r,i,s,o,a){if(r/=n,s>=(e/=n)&&o<r)return t;if(o<e||s>=r)return null;const u=[];for(const n of t){const t=n.geometry;let s=n.type;const o=0===i?n.minX:n.minY,h=0===i?n.maxX:n.maxY;if(o>=e&&h<r){u.push(n);continue}if(h<e||o>=r)continue;let l=[];if("Point"===s||"MultiPoint"===s)V(t,l,e,r,i,a.hasAltitude);else if("LineString"===s)R(t,l,e,r,i,!1,a.lineMetrics,a.hasAltitude);else if("MultiLineString"===s)W(t,l,e,r,i,!1,a.hasAltitude);else if("Polygon"===s)W(t,l,e,r,i,!0,a.hasAltitude);else if("MultiPolygon"===s)for(const n of t){const t=[];W(n,t,e,r,i,!0,a.hasAltitude),t.length&&l.push(t)}if(l.length){if(a.lineMetrics&&"LineString"===s){for(const t of l)u.push(I(n.id,s,t,n.tags,n.layer,a.hasAltitude));continue}"LineString"!==s&&"MultiLineString"!==s||(1===l.length?(s="LineString",l=l[0]):s="MultiLineString"),"Point"!==s&&"MultiPoint"!==s||(s=3===l.length?"Point":"MultiPoint"),u.push(I(n.id,s,l,n.tags,n.layer,a.hasAltitude))}}return u.length?u:null}function V(t,n,e,r,i,s){const o=s?4:3;for(let a=0;a<t.length;a+=o){const o=t[a+i];o>=e&&o<=r&&(q(n,t[a],t[a+1],t[a+2]),s&&n.push(t[a+3]))}}function R(t,n,e,r,i,s,o,a){let u=H(t);const h=0===i?G:B;let l,c,f=t.start;const d=a?4:3,p=s?t.length:t.length-d;for(let y=0;y<p;y+=d){const m=t[y],g=t[y+1],v=t[y+2];let b,w,M,x;s&&y===p-d?(b=t[0],w=t[1]):(b=t[y+d],w=t[y+d+1]),a&&(M=t[y+3],x=s&&y===p-d?t[3]:t[y+d+3]);const F=0===i?m:g,A=0===i?b:w;let k=!1;o&&(l=Math.sqrt(Math.pow(m-b,2)+Math.pow(g-w,2))),F<e?A>e&&(c=h(u,m,g,b,w,e),a&&u.push(J(M,x,c)),o&&(u.start=f+l*c)):F>r?A<r&&(c=h(u,m,g,b,w,r),a&&u.push(J(M,x,c)),o&&(u.start=f+l*c)):(q(u,m,g,v),a&&u.push(M)),A<e&&F>=e&&(c=h(u,m,g,b,w,e),a&&u.push(J(M,x,c)),k=!0),A>r&&F<=r&&(c=h(u,m,g,b,w,r),a&&u.push(J(M,x,c)),k=!0),!s&&k&&(o&&(u.end=f+l*c),n.push(u),u=H(t)),o&&(f+=l)}let y=t.length-d;if(!s){const n=t[y],s=t[y+1],o=t[y+2],h=0===i?n:s;if(h>=e&&h<=r&&q(u,n,s,o),h>=e&&h<=r&&a){const n=t[y+3];u.push(n)}}y=u.length-d,s&&y>=d&&(u[y]!==u[0]||u[y+1]!==u[1])&&(q(u,u[0],u[1],u[2]),a&&u.push(u[3])),u.length&&n.push(u)}function H(t){const n=[];return n.size=t.size,n.start=t.start,n.end=t.end,n}function W(t,n,e,r,i,s,o){for(const a of t)R(a,n,e,r,i,s,!1,o)}function q(t,n,e,r){t.push(n,e,r)}function G(t,n,e,r,i,s){const o=(s-n)/(r-n);return q(t,s,e+(i-e)*o,1),o}function B(t,n,e,r,i,s){const o=(s-e)/(i-e);return q(t,n+(r-n)*o,s,1),o}function J(t,n,e){return t+(n-t)*e}function X(t,n,e){const r=[];for(let i=0;i<t.length;i++){const s=t[i],o=s.type;let a;if("Point"===o||"MultiPoint"===o||"LineString"===o)a=Y(s.geometry,n,e);else if("MultiLineString"===o||"Polygon"===o){a=[];for(const t of s.geometry)a.push(Y(t,n,e))}else if("MultiPolygon"===o){a=[];for(const t of s.geometry){const r=[];for(const i of t)r.push(Y(i,n,e));a.push(r)}}r.push(I(s.id,o,a,s.tags,s.layer,e))}return r}function Y(t,n,e){const r=[];r.size=t.size,void 0!==t.start&&(r.start=t.start,r.end=t.end);const i=e?4:3;for(let s=0;s<t.length;s+=i)r.push(t[s]+n,t[s+1],t[s+2]),e&&r.push(t[s+3]);return r}function Z(t,n,e){if(t.transformed)return t;const r=1<<t.z,i=t.x,s=t.y,o=e?3:2;for(const a of t.features){const t=a.geometry,u=a.type;if(a.geometry=[],1===u)for(let u=0;u<t.length;u+=o)a.geometry.push(K(t[u],t[u+1],n,r,i,s)),e&&a.geometry[a.geometry.length-1].push(t[u+2]);else for(let u=0;u<t.length;u++){const h=[];for(let a=0;a<t[u].length;a+=o)h.push(K(t[u][a],t[u][a+1],n,r,i,s)),e&&h[h.length-1].push(t[u][a+2]);a.geometry.push(h)}}return t.transformed=!0,t}function K(t,n,e,r,i,s){return[Math.round(e*(t*r-i)),Math.round(e*(n*r-s))]}function Q(t,n,e,r,i){const s=n===i.maxZoom?0:i.tolerance/((1<<n)*i.extent),o={features:[],numPoints:0,numSimplified:0,numFeatures:t.length,source:null,x:e,y:r,z:n,transformed:!1,minX:2,minY:1,maxX:-1,maxY:0};for(const n of t)tt(o,n,s,i);return o}function tt(t,n,e,r){const i=n.geometry,s=n.type,o=[],a=r.hasAltitude?4:3;if(t.minX=Math.min(t.minX,n.minX),t.minY=Math.min(t.minY,n.minY),t.maxX=Math.max(t.maxX,n.maxX),t.maxY=Math.max(t.maxY,n.maxY),"Point"===s||"MultiPoint"===s)for(let n=0;n<i.length;n+=a)o.push(i[n],i[n+1]),r.hasAltitude&&o.push(i[n+3]),t.numPoints++,t.numSimplified++;else if("LineString"===s)et(o,i,t,e,!1,!1,r);else if("MultiLineString"===s||"Polygon"===s)for(let n=0;n<i.length;n++)et(o,i[n],t,e,"Polygon"===s,0===n,r);else if("MultiPolygon"===s)for(let n=0;n<i.length;n++){const s=i[n];for(let n=0;n<s.length;n++)et(o,s[n],t,e,!0,0===n,r)}if(o.length){let e=n.tags||null;if("LineString"===s&&r.lineMetrics){e={};for(const t in n.tags)e[t]=n.tags[t];e.mapbox_clip_start=i.start/i.size,e.mapbox_clip_end=i.end/i.size}const a={geometry:o,type:"Polygon"===s||"MultiPolygon"===s?3:"LineString"===s||"MultiLineString"===s?2:1,tags:e};n.layer&&(a.layer=n.layer),null!==n.id&&(a.id=n.id),t.features.push(a)}}function nt(t,n,e){return 0===t[n+2]&&t[n+3]>0&&e}function et(t,n,e,r,i,s,o){const a=r*r,{hasAltitude:u,disableFilter:h}=o,l=u?4:3;if(!h&&r>0&&n.size<(i?a:r))return void(e.numPoints+=n.length/l);const c=[];for(let t=0;t<n.length;t+=l)(0===r||n[t+2]>a||nt(n,t,u))&&(e.numSimplified++,c.push(n[t],n[t+1]),u&&c.push(n[t+3])),e.numPoints++;i&&function(t,n,e){const r=e?3:2;let i=0;for(let n=0,e=t.length,s=e-r;n<e;s=n,n+=r)i+=(t[n]-t[s])*(t[n+1]+t[s+1]);if(i>0===n){const n=r,i=r-1,s=r-2;for(let o=0,a=t.length;o<a/2;o+=r){const r=t[o],u=t[o+1];let h;e&&(h=t[o+2]),t[o]=t[a-n-o],t[o+1]=t[a-i-o],e&&(t[o+2]=t[a-s-o]),t[a-n-o]=r,t[a-i-o]=u,e&&(t[a-s-o]=h)}}}(c,s,u),t.push(c)}O.getJSON=function(t,n,e){if(F(n)){const t=e;e=n,n=t}const r=function(t,n){const r="string"==typeof n?JSON.parse(n):n||null;e(t,r)};return n&&n.jsonp?O.jsonp(t,r):((n=n||{}).returnJSON=!0,O.get(t,n,r))};const rt={maxZoom:14,indexMaxZoom:5,indexMaxPoints:1e5,tolerance:3,extent:4096,buffer:64,lineMetrics:!1,promoteId:null,generateId:!1,hasAltitude:!1,disableFilter:!1,debug:0};class it{constructor(t,n){const e=(n=this.options=function(t,n){for(const e in n)t[e]=n[e];return t}(Object.create(rt),n)).debug;if(e&&console.time("preprocess data"),n.maxZoom<0||n.maxZoom>24)throw new Error("maxZoom should be in the 0-24 range");if(n.promoteId&&n.generateId)throw new Error("promoteId and generateId cannot be used together.");let r=function(t,n){const e=[];if(Array.isArray(t)){for(let r=0;r<t.length;r++)C(e,t[r].layer,t[r].data,n);return e}if("FeatureCollection"===t.type)for(let r=0;r<t.features.length;r++)T(e,t.features[r],n,r);else"Feature"===t.type?T(e,t,n):T(e,{geometry:t},n);return e}(t,n);this.tiles={},this.tileCoords=[],e&&(console.timeEnd("preprocess data"),console.log("index: maxZoom: %d, maxPoints: %d",n.indexMaxZoom,n.indexMaxPoints),console.time("generate tiles"),this.stats={},this.total=0),r=function(t,n){const e=n.buffer/n.extent;let r=t;const i=L(t,1,-1-e,e,0,-1,2,n),s=L(t,1,1-e,2+e,0,-1,2,n);return(i||s)&&(r=L(t,1,-e,1+e,0,-1,2,n)||[],i&&(r=X(i,1,n.hasAltitude).concat(r)),s&&(r=r.concat(X(s,-1,n.hasAltitude)))),r}(r,n),r.length&&this.splitTile(r,0,0,0),e&&(r.length&&console.log("features: %d, points: %d",this.tiles[0].numFeatures,this.tiles[0].numPoints),console.timeEnd("generate tiles"),console.log("tiles generated:",this.total,JSON.stringify(this.stats)))}splitTile(t,n,e,r,i,s,o){const a=[t,n,e,r],u=this.options,h=u.debug;for(;a.length;){r=a.pop(),e=a.pop(),n=a.pop(),t=a.pop();const l=1<<n,c=st(n,e,r);let f=this.tiles[c];if(!f&&(h>1&&console.time("creation"),f=this.tiles[c]=Q(t,n,e,r,u),this.tileCoords.push({z:n,x:e,y:r}),h)){h>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",n,e,r,f.numFeatures,f.numPoints,f.numSimplified),console.timeEnd("creation"));const t="z"+n;this.stats[t]=(this.stats[t]||0)+1,this.total++}if(f.source=t,null==i){if(n===u.indexMaxZoom||f.numPoints<=u.indexMaxPoints)continue}else{if(n===u.maxZoom||n===i)continue;if(null!=i){const t=i-n;if(e!==s>>t||r!==o>>t)continue}}if(f.source=null,0===t.length)continue;h>1&&console.time("clipping");const d=.5*u.buffer/u.extent,p=.5-d,y=.5+d,m=1+d;let g=null,v=null,b=null,w=null,M=L(t,l,e-d,e+y,0,f.minX,f.maxX,u),x=L(t,l,e+p,e+m,0,f.minX,f.maxX,u);t=null,M&&(g=L(M,l,r-d,r+y,1,f.minY,f.maxY,u),v=L(M,l,r+p,r+m,1,f.minY,f.maxY,u),M=null),x&&(b=L(x,l,r-d,r+y,1,f.minY,f.maxY,u),w=L(x,l,r+p,r+m,1,f.minY,f.maxY,u),x=null),h>1&&console.timeEnd("clipping"),a.push(g||[],n+1,2*e,2*r),a.push(v||[],n+1,2*e,2*r+1),a.push(b||[],n+1,2*e+1,2*r),a.push(w||[],n+1,2*e+1,2*r+1)}}getTile(t,n,e){t=+t,n=+n,e=+e;const r=this.options,{extent:i,debug:s}=r,{hasAltitude:o,wrapX:a}=r;if(t<0||t>24)return null;if(a){const e=1<<t;n=n+e&e-1}const u=st(t,n,e);if(this.tiles[u])return Z(this.tiles[u],i,o);s>1&&console.log("drilling down to z%d-%d-%d",t,n,e);let h,l=t,c=n,f=e;for(;!h&&l>0;)l--,c>>=1,f>>=1,h=this.tiles[st(l,c,f)];return h&&h.source?(s>1&&(console.log("found parent tile z%d-%d-%d",l,c,f),console.time("drilling down")),this.splitTile(h.source,l,c,f,t,n,e),s>1&&console.timeEnd("drilling down"),this.tiles[u]?Z(this.tiles[u],i,o):null):null}}function st(t,n,e){return 32*((1<<t)*e+n)+t}function ot(t,n,e,r,i,s,o){const a=e&&Array.isArray(e[0]);for(let u=0,h=e.length;u<h;u++){t[n]=(a?e[u][0]:e[u].x)*r,t[n+1]=(a?e[u][1]:e[u].y)*r,o!==Float32Array&&(t[n]=Math.round(t[n]),t[n+1]=Math.round(t[n+1]));let l=i||0;Array.isArray(i)&&(l=i[u]),l=l?Math.round(r*l):0,t[n+2]=l,n+=3,s&&0!==u&&u!==h-1&&(t[n]=t[n-3],t[n+1]=t[n-2],t[n+2]=t[n-1],n+=3)}return t.trySetLength&&t.trySetLength(n),n}function at(t,n,e,r){const i=t[3*n],s=t[3*n+1],o=t[3*e],a=t[3*e+1];return i===o&&(i<0||i>r)||s===a&&(s<0||s>r)}var ut="undefined"!=typeof Float32Array?Float32Array:Array;function ht(){var t=new ut(3);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function lt(t,n,e){var r=new ut(3);return r[0]=t,r[1]=n,r[2]=e,r}function ct(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t}function ft(t,n,e,r){return t[0]=n,t[1]=e,t[2]=r,t}function dt(t,n,e){return t[0]=n[0]+e[0],t[1]=n[1]+e[1],t[2]=n[2]+e[2],t}function pt(t,n){var e=n[0],r=n[1],i=n[2],s=e*e+r*r+i*i;return s>0&&(s=1/Math.sqrt(s),t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s),t}function yt(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function mt(t,n,e){var r=n[0],i=n[1],s=n[2],o=e[0],a=e[1],u=e[2];return t[0]=i*u-s*a,t[1]=s*o-r*u,t[2]=r*a-i*o,t}var gt=function(t,n,e){return t[0]=n[0]-e[0],t[1]=n[1]-e[1],t[2]=n[2]-e[2],t};function vt(t,n){return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t}function bt(t,n,e,r,i){return t[0]=n,t[1]=e,t[2]=r,t[3]=i,t}function wt(t,n,e){return t[0]=n[0]/e[0],t[1]=n[1]/e[1],t[2]=n[2]/e[2],t[3]=n[3]/e[3],t}function Mt(t,n,e){return t[0]=n[0]*e,t[1]=n[1]*e,t[2]=n[2]*e,t[3]=n[3]*e,t}function xt(t,n){return t[0]===n[0]&&t[1]===n[1]&&t[2]===n[2]&&t[3]===n[3]}function Ft(){var t=new ut(4);return ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function At(t,n){var e=n[0]+n[4]+n[8],r=void 0;if(e>0)r=Math.sqrt(e+1),t[3]=.5*r,r=.5/r,t[0]=(n[5]-n[7])*r,t[1]=(n[6]-n[2])*r,t[2]=(n[1]-n[3])*r;else{var i=0;n[4]>n[0]&&(i=1),n[8]>n[3*i+i]&&(i=2);var s=(i+1)%3,o=(i+2)%3;r=Math.sqrt(n[3*i+i]-n[3*s+s]-n[3*o+o]+1),t[i]=.5*r,r=.5/r,t[3]=(n[3*s+o]-n[3*o+s])*r,t[s]=(n[3*s+i]+n[3*i+s])*r,t[o]=(n[3*o+i]+n[3*i+o])*r}return t}!function(){var t=ht()}(),function(){var t,n=(t=new ut(4),ut!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var kt,Pt=Mt,St=function(t,n){var e=n[0],r=n[1],i=n[2],s=n[3],o=e*e+r*r+i*i+s*s;return o>0&&(o=1/Math.sqrt(o),t[0]=e*o,t[1]=r*o,t[2]=i*o,t[3]=s*o),t};function _t(t,n,e){return t[0]=n,t[1]=e,t}function Ot(t,n){var e=n[0]-t[0],r=n[1]-t[1];return Math.sqrt(e*e+r*r)}ht(),lt(1,0,0),lt(0,1,0),Ft(),Ft(),kt=new ut(9),ut!=Float32Array&&(kt[1]=0,kt[2]=0,kt[3]=0,kt[5]=0,kt[6]=0,kt[7]=0),kt[0]=1,kt[4]=1,kt[8]=1;var Et=function(t){var n=t[0],e=t[1];return Math.sqrt(n*n+e*e)};!function(){var t=function(){var t=new ut(2);return ut!=Float32Array&&(t[0]=0,t[1]=0),t}()}();const It=Math.PI/180,$t=6378137*Math.PI/180;function Ct(t,n,e){if("EPSG:3857"===e)return function(t,n){const e=85.0511287798,r=n[0],i=Math.max(Math.min(e,n[1]),-e);let s;s=0===i?0:Math.log(Math.tan((90+i)*It/2))/It;return t[0]=r*$t,t[1]=s*$t,t}(t,n);if("EPSG:4326"===e||"EPSG:4490"===e||"identity"===e)return Tt(t,n);if("baidu"===e)return Tt(t,n);throw new Error("unsupported projection:"+e)}function Tt(t,n){return t[0]=n[0],t[1]=n[1],t}function zt(t,n,e,r,i,s,o,a,u,h,l,c,f,d,p){0===t?function(t,n,e,r,i,s,o,a,u,h){const l=1/(100*s[0]),c=1/(100*s[1]),f=h&&h[0]||0,d=h&&h[1]||0,p=[0,0];for(let i=t;i<n;i+=3){const t=i/3*2,n=r[i]-f,s=r[i+1]-d;e[t]=p[0]+n/o*l/a,e[t+1]=p[1]-s/o*c/u}}(n,e,r,i,0,o,a,u,h,p):1===t&&function(t,n,e,r,i,s,o,a,u,h,l){if(!t)return;let c,f,d,p;0===t[4]?(c=t[0],f=t[1],d=t[2],p=t[3]):(c=t[1],f=t[2],d=t[3],p=t[0]);const y=Ot(c,f),m=Ot(f,d),g=[],v=[],b=[];for(let t=n;t<e;t+=3){const n=t/3*2,e=(s.x/u+i[t]/o)*a,d=s.y/u*a+(l?i[t+1]:-i[t+1])/o*a;_t(g,e,d),"EPSG:4326"!==h&&"EPSG:4490"!==h||Ct(g,g,"EPSG:3857"),Dt(v,g,c,f),Dt(b,g,p,c),r[n]=Ot(c,v)/y,r[n+1]=Ot(c,b)/m}}(l,n,e,r,i,s,a,c,f,d,!!p)}function Dt(t,n,e,r){const i=e[0]-r[0],s=e[1]-r[1];let o=(n[0]-e[0])*(e[0]-r[0])+(n[1]-e[1])*(e[1]-r[1]);return o/=i*i+s*s,t[0]=e[0]+o*i,t[1]=e[1]+o*s,t}function jt(t,n,e,r,i){const s=3*n[e-1],o=3*n[e-1]+1,a=t[s],u=t[o];return h=r,l=i,c=a,f=u,Math.sqrt((c-h)*(c-h)+(f-l)*(f-l));var h,l,c,f}"undefined"!=typeof undefinedThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof undefined?global:"undefined"!=typeof self&&self;var Ut=Nt;function Nt(t,n){this.x=t,this.y=n}function Lt(t,n,e){e=e||{},this.w=t||64,this.h=n||64,this.autoResize=!!e.autoResize,this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0}function Vt(t,n,e){this.x=0,this.y=t,this.w=this.free=n,this.h=e}function Rt(t,n,e,r,i,s,o){this.id=t,this.x=n,this.y=e,this.w=r,this.h=i,this.maxw=s||r,this.maxh=o||i,this.refcount=0}Nt.prototype={clone:function(){return new Nt(this.x,this.y)},add:function(t){return this.clone().m(t)},sub:function(t){return this.clone().M(t)},multByPoint:function(t){return this.clone().F(t)},divByPoint:function(t){return this.clone().A(t)},mult:function(t){return this.clone().k(t)},div:function(t){return this.clone().P(t)},rotate:function(t){return this.clone().S(t)},rotateAround:function(t,n){return this.clone()._(t,n)},matMult:function(t){return this.clone().O(t)},unit:function(){return this.clone().I()},perp:function(){return this.clone().C()},round:function(){return this.clone().T()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var n=t.x-this.x,e=t.y-this.y;return n*n+e*e},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,n){return Math.atan2(this.x*n-this.y*t,this.x*t+this.y*n)},O:function(t){var n=t[0]*this.x+t[1]*this.y,e=t[2]*this.x+t[3]*this.y;return this.x=n,this.y=e,this},m:function(t){return this.x+=t.x,this.y+=t.y,this},M:function(t){return this.x-=t.x,this.y-=t.y,this},k:function(t){return this.x*=t,this.y*=t,this},P:function(t){return this.x/=t,this.y/=t,this},F:function(t){return this.x*=t.x,this.y*=t.y,this},A:function(t){return this.x/=t.x,this.y/=t.y,this},I:function(){return this.P(this.mag()),this},C:function(){var t=this.y;return this.y=this.x,this.x=-t,this},S:function(t){var n=Math.cos(t),e=Math.sin(t),r=n*this.x-e*this.y,i=e*this.x+n*this.y;return this.x=r,this.y=i,this},_:function(t,n){var e=Math.cos(t),r=Math.sin(t),i=n.x+e*(this.x-n.x)-r*(this.y-n.y),s=n.y+r*(this.x-n.x)+e*(this.y-n.y);return this.x=i,this.y=s,this},T:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},Nt.convert=function(t){return t instanceof Nt?t:Array.isArray(t)?new Nt(t[0],t[1]):t},Lt.prototype.pack=function(t,n){t=[].concat(t),n=n||{};for(var e,r,i,s,o=[],a=0;a<t.length;a++)if(e=t[a].w||t[a].width,r=t[a].h||t[a].height,i=t[a].id,e&&r){if(!(s=this.packOne(e,r,i)))continue;n.inPlace&&(t[a].x=s.x,t[a].y=s.y,t[a].id=s.id),o.push(s)}return this.shrink(),o},Lt.prototype.packOne=function(t,n,e){var r,i,s,o,a,u,h,l,c={freebin:-1,shelf:-1,waste:1/0},f=0;if("string"==typeof e||"number"==typeof e){if(r=this.getBin(e))return this.ref(r),r;"number"==typeof e&&(this.maxId=Math.max(e,this.maxId))}else e=++this.maxId;for(o=0;o<this.freebins.length;o++){if(n===(r=this.freebins[o]).maxh&&t===r.maxw)return this.allocFreebin(o,t,n,e);n>r.maxh||t>r.maxw||n<=r.maxh&&t<=r.maxw&&(s=r.maxw*r.maxh-t*n)<c.waste&&(c.waste=s,c.freebin=o)}for(o=0;o<this.shelves.length;o++)if(f+=(i=this.shelves[o]).h,!(t>i.free)){if(n===i.h)return this.allocShelf(o,t,n,e);n>i.h||n<i.h&&(s=(i.h-n)*t)<c.waste&&(c.freebin=-1,c.waste=s,c.shelf=o)}return-1!==c.freebin?this.allocFreebin(c.freebin,t,n,e):-1!==c.shelf?this.allocShelf(c.shelf,t,n,e):n<=this.h-f&&t<=this.w?(i=new Vt(f,this.w,n),this.allocShelf(this.shelves.push(i)-1,t,n,e)):this.autoResize?(a=u=this.h,((h=l=this.w)<=a||t>h)&&(l=2*Math.max(t,h)),(a<h||n>a)&&(u=2*Math.max(n,a)),this.resize(l,u),this.packOne(t,n,e)):null},Lt.prototype.allocFreebin=function(t,n,e,r){var i=this.freebins.splice(t,1)[0];return i.id=r,i.w=n,i.h=e,i.refcount=0,this.bins[r]=i,this.ref(i),i},Lt.prototype.allocShelf=function(t,n,e,r){var i=this.shelves[t].alloc(n,e,r);return this.bins[r]=i,this.ref(i),i},Lt.prototype.shrink=function(){if(this.shelves.length>0){for(var t=0,n=0,e=0;e<this.shelves.length;e++){var r=this.shelves[e];n+=r.h,t=Math.max(r.w-r.free,t)}this.resize(t,n)}},Lt.prototype.getBin=function(t){return this.bins[t]},Lt.prototype.ref=function(t){if(1==++t.refcount){var n=t.h;this.stats[n]=1+(0|this.stats[n])}return t.refcount},Lt.prototype.unref=function(t){return 0===t.refcount?0:(0==--t.refcount&&(this.stats[t.h]--,delete this.bins[t.id],this.freebins.push(t)),t.refcount)},Lt.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},Lt.prototype.resize=function(t,n){this.w=t,this.h=n;for(var e=0;e<this.shelves.length;e++)this.shelves[e].resize(t);return!0},Vt.prototype.alloc=function(t,n,e){if(t>this.free||n>this.h)return null;var r=this.x;return this.x+=t,this.free-=t,new Rt(e,r,this.y,t,n,t,this.h)},Vt.prototype.resize=function(t){return this.free+=t-this.w,this.w=t,!0};var Ht={exports:{}},Wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},qt={exports:{}},Gt=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},Bt=Array.prototype.concat,Jt=Array.prototype.slice,Xt=qt.exports=function(t){for(var n=[],e=0,r=t.length;e<r;e++){var i=t[e];Gt(i)?n=Bt.call(n,Jt.call(i)):n.push(i)}return n};Xt.wrap=function(t){return function(){return t(Xt(arguments))}};var Yt=Wt,Zt=qt.exports,Kt=Object.hasOwnProperty,Qt=Object.create(null);for(var tn in Yt)Kt.call(Yt,tn)&&(Qt[Yt[tn]]=tn);var nn=Ht.exports={to:{},get:{}};function en(t,n,e){return Math.min(Math.max(n,t),e)}function rn(t){var n=Math.round(t).toString(16).toUpperCase();return n.length<2?"0"+n:n}nn.get=function(t){var n,e;switch(t.substring(0,3).toLowerCase()){case"hsl":n=nn.get.hsl(t),e="hsl";break;case"hwb":n=nn.get.hwb(t),e="hwb";break;default:n=nn.get.rgb(t),e="rgb"}return n?{model:e,value:n}:null},nn.get.rgb=function(t){if(!t)return null;var n,e,r,i=[0,0,0,1];if(n=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=n[2],n=n[1],e=0;e<3;e++){var s=2*e;i[e]=parseInt(n.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(n=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(n=n[1])[3],e=0;e<3;e++)i[e]=parseInt(n[e]+n[e],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(n=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(e=0;e<3;e++)i[e]=parseInt(n[e+1],0);n[4]&&(n[5]?i[3]=.01*parseFloat(n[4]):i[3]=parseFloat(n[4]))}else{if(!(n=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(n=t.match(/^(\\w+)$/))?"transparent"===n[1]?[0,0,0,0]:Kt.call(Yt,n[1])?((i=Yt[n[1]])[3]=1,i):null:null;for(e=0;e<3;e++)i[e]=Math.round(2.55*parseFloat(n[e+1]));n[4]&&(n[5]?i[3]=.01*parseFloat(n[4]):i[3]=parseFloat(n[4]))}for(e=0;e<3;e++)i[e]=en(i[e],0,255);return i[3]=en(i[3],0,1),i},nn.get.hsl=function(t){if(!t)return null;var n=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(n){var e=parseFloat(n[4]);return[(parseFloat(n[1])%360+360)%360,en(parseFloat(n[2]),0,100),en(parseFloat(n[3]),0,100),en(isNaN(e)?1:e,0,1)]}return null},nn.get.hwb=function(t){if(!t)return null;var n=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(n){var e=parseFloat(n[4]);return[(parseFloat(n[1])%360+360)%360,en(parseFloat(n[2]),0,100),en(parseFloat(n[3]),0,100),en(isNaN(e)?1:e,0,1)]}return null},nn.to.hex=function(){var t=Zt(arguments);return"#"+rn(t[0])+rn(t[1])+rn(t[2])+(t[3]<1?rn(Math.round(255*t[3])):"")},nn.to.rgb=function(){var t=Zt(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},nn.to.rgb.percent=function(){var t=Zt(arguments),n=Math.round(t[0]/255*100),e=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+n+"%, "+e+"%, "+r+"%)":"rgba("+n+"%, "+e+"%, "+r+"%, "+t[3]+")"},nn.to.hsl=function(){var t=Zt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},nn.to.hwb=function(){var t=Zt(arguments),n="";return t.length>=4&&1!==t[3]&&(n=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+n+")"},nn.to.keyword=function(t){return Qt[t.slice(0,3)]};var sn={exports:{}},on=Wt,an={};for(var un in on)on.hasOwnProperty(un)&&(an[on[un]]=un);var hn=sn.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var ln in hn)if(hn.hasOwnProperty(ln)){if(!("channels"in hn[ln]))throw new Error("missing channels property: "+ln);if(!("labels"in hn[ln]))throw new Error("missing channel labels property: "+ln);if(hn[ln].labels.length!==hn[ln].channels)throw new Error("channel and label counts mismatch: "+ln);var cn=hn[ln].channels,fn=hn[ln].labels;delete hn[ln].channels,delete hn[ln].labels,Object.defineProperty(hn[ln],"channels",{value:cn}),Object.defineProperty(hn[ln],"labels",{value:fn})}function dn(t,n){return Math.pow(t[0]-n[0],2)+Math.pow(t[1]-n[1],2)+Math.pow(t[2]-n[2],2)}hn.rgb.hsl=function(t){var n,e,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),u=a-o;return a===o?n=0:r===a?n=(i-s)/u:i===a?n=2+(s-r)/u:s===a&&(n=4+(r-i)/u),(n=Math.min(60*n,360))<0&&(n+=360),e=(o+a)/2,[n,100*(a===o?0:e<=.5?u/(a+o):u/(2-a-o)),100*e]},hn.rgb.hsv=function(t){var n,e,r,i,s,o=t[0]/255,a=t[1]/255,u=t[2]/255,h=Math.max(o,a,u),l=h-Math.min(o,a,u),c=function(t){return(h-t)/6/l+.5};return 0===l?i=s=0:(s=l/h,n=c(o),e=c(a),r=c(u),o===h?i=r-e:a===h?i=1/3+n-r:u===h&&(i=2/3+e-n),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*h]},hn.rgb.hwb=function(t){var n=t[0],e=t[1],r=t[2];return[hn.rgb.hsl(t)[0],100*(1/255*Math.min(n,Math.min(e,r))),100*(r=1-1/255*Math.max(n,Math.max(e,r)))]},hn.rgb.cmyk=function(t){var n,e=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-e-(n=Math.min(1-e,1-r,1-i)))/(1-n)||0),100*((1-r-n)/(1-n)||0),100*((1-i-n)/(1-n)||0),100*n]},hn.rgb.keyword=function(t){var n=an[t];if(n)return n;var e,r=1/0;for(var i in on)if(on.hasOwnProperty(i)){var s=dn(t,on[i]);s<r&&(r=s,e=i)}return e},hn.keyword.rgb=function(t){return on[t]},hn.rgb.xyz=function(t){var n=t[0]/255,e=t[1]/255,r=t[2]/255;return[100*(.4124*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.3576*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*n+.7152*e+.0722*r),100*(.0193*n+.1192*e+.9505*r)]},hn.rgb.lab=function(t){var n=hn.rgb.xyz(t),e=n[0],r=n[1],i=n[2];return r/=100,i/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(e-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},hn.hsl.rgb=function(t){var n,e,r,i,s,o=t[0]/360,a=t[1]/100,u=t[2]/100;if(0===a)return[s=255*u,s,s];n=2*u-(e=u<.5?u*(1+a):u+a-u*a),i=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,s=6*r<1?n+6*(e-n)*r:2*r<1?e:3*r<2?n+(e-n)*(2/3-r)*6:n,i[h]=255*s;return i},hn.hsl.hsv=function(t){var n=t[0],e=t[1]/100,r=t[2]/100,i=e,s=Math.max(r,.01);return e*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[n,100*(0===r?2*i/(s+i):2*e/(r+e)),100*((r+e)/2)]},hn.hsv.rgb=function(t){var n=t[0]/60,e=t[1]/100,r=t[2]/100,i=Math.floor(n)%6,s=n-Math.floor(n),o=255*r*(1-e),a=255*r*(1-e*s),u=255*r*(1-e*(1-s));switch(r*=255,i){case 0:return[r,u,o];case 1:return[a,r,o];case 2:return[o,r,u];case 3:return[o,a,r];case 4:return[u,o,r];case 5:return[r,o,a]}},hn.hsv.hsl=function(t){var n,e,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,e=s*a,[i,100*(e=(e/=(n=(2-s)*a)<=1?n:2-n)||0),100*(r/=2)]},hn.hwb.rgb=function(t){var n,e,r,i,s,o,a,u=t[0]/360,h=t[1]/100,l=t[2]/100,c=h+l;switch(c>1&&(h/=c,l/=c),r=6*u-(n=Math.floor(6*u)),0!=(1&n)&&(r=1-r),i=h+r*((e=1-l)-h),n){default:case 6:case 0:s=e,o=i,a=h;break;case 1:s=i,o=e,a=h;break;case 2:s=h,o=e,a=i;break;case 3:s=h,o=i,a=e;break;case 4:s=i,o=h,a=e;break;case 5:s=e,o=h,a=i}return[255*s,255*o,255*a]},hn.cmyk.rgb=function(t){var n=t[0]/100,e=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},hn.xyz.rgb=function(t){var n,e,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return e=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,n=(n=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(n=Math.min(Math.max(0,n),1)),255*(e=Math.min(Math.max(0,e),1)),255*(r=Math.min(Math.max(0,r),1))]},hn.xyz.lab=function(t){var n=t[0],e=t[1],r=t[2];return e/=100,r/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(e=e>.008856?Math.pow(e,1/3):7.787*e+16/116)-16,500*(n-e),200*(e-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},hn.lab.xyz=function(t){var n,e,r,i=t[0];n=t[1]/500+(e=(i+16)/116),r=e-t[2]/200;var s=Math.pow(e,3),o=Math.pow(n,3),a=Math.pow(r,3);return e=s>.008856?s:(e-16/116)/7.787,n=o>.008856?o:(n-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[n*=95.047,e*=100,r*=108.883]},hn.lab.lch=function(t){var n,e=t[0],r=t[1],i=t[2];return(n=360*Math.atan2(i,r)/2/Math.PI)<0&&(n+=360),[e,Math.sqrt(r*r+i*i),n]},hn.lch.lab=function(t){var n,e=t[0],r=t[1];return n=t[2]/360*2*Math.PI,[e,r*Math.cos(n),r*Math.sin(n)]},hn.rgb.ansi16=function(t){var n=t[0],e=t[1],r=t[2],i=1 in arguments?arguments[1]:hn.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(e/255)<<1|Math.round(n/255));return 2===i&&(s+=60),s},hn.hsv.ansi16=function(t){return hn.rgb.ansi16(hn.hsv.rgb(t),t[2])},hn.rgb.ansi256=function(t){var n=t[0],e=t[1],r=t[2];return n===e&&e===r?n<8?16:n>248?231:Math.round((n-8)/247*24)+232:16+36*Math.round(n/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5)},hn.ansi16.rgb=function(t){var n=t%10;if(0===n||7===n)return t>50&&(n+=3.5),[n=n/10.5*255,n,n];var e=.5*(1+~~(t>50));return[(1&n)*e*255,(n>>1&1)*e*255,(n>>2&1)*e*255]},hn.ansi256.rgb=function(t){if(t>=232){var n=10*(t-232)+8;return[n,n,n]}var e;return t-=16,[Math.floor(t/36)/5*255,Math.floor((e=t%36)/6)/5*255,e%6/5*255]},hn.rgb.hex=function(t){var n=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(n.length)+n},hn.hex.rgb=function(t){var n=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!n)return[0,0,0];var e=n[0];3===n[0].length&&(e=e.split("").map((function(t){return t+t})).join(""));var r=parseInt(e,16);return[r>>16&255,r>>8&255,255&r]},hn.rgb.hcg=function(t){var n,e=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(e,r),i),o=Math.min(Math.min(e,r),i),a=s-o;return n=a<=0?0:s===e?(r-i)/a%6:s===r?2+(i-e)/a:4+(e-r)/a+4,n/=6,[360*(n%=1),100*a,100*(a<1?o/(1-a):0)]},hn.hsl.hcg=function(t){var n=t[1]/100,e=t[2]/100,r=1,i=0;return(r=e<.5?2*n*e:2*n*(1-e))<1&&(i=(e-.5*r)/(1-r)),[t[0],100*r,100*i]},hn.hsv.hcg=function(t){var n=t[1]/100,e=t[2]/100,r=n*e,i=0;return r<1&&(i=(e-r)/(1-r)),[t[0],100*r,100*i]},hn.hcg.rgb=function(t){var n=t[0]/360,e=t[1]/100,r=t[2]/100;if(0===e)return[255*r,255*r,255*r];var i,s=[0,0,0],o=n%1*6,a=o%1,u=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=u,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=u,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=u}return i=(1-e)*r,[255*(e*s[0]+i),255*(e*s[1]+i),255*(e*s[2]+i)]},hn.hcg.hsv=function(t){var n=t[1]/100,e=n+t[2]/100*(1-n),r=0;return e>0&&(r=n/e),[t[0],100*r,100*e]},hn.hcg.hsl=function(t){var n=t[1]/100,e=t[2]/100*(1-n)+.5*n,r=0;return e>0&&e<.5?r=n/(2*e):e>=.5&&e<1&&(r=n/(2*(1-e))),[t[0],100*r,100*e]},hn.hcg.hwb=function(t){var n=t[1]/100,e=n+t[2]/100*(1-n);return[t[0],100*(e-n),100*(1-e)]},hn.hwb.hcg=function(t){var n=t[1]/100,e=1-t[2]/100,r=e-n,i=0;return r<1&&(i=(e-r)/(1-r)),[t[0],100*r,100*i]},hn.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},hn.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},hn.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},hn.gray.hsl=hn.gray.hsv=function(t){return[0,0,t[0]]},hn.gray.hwb=function(t){return[0,100,t[0]]},hn.gray.cmyk=function(t){return[0,0,0,t[0]]},hn.gray.lab=function(t){return[t[0],0,0]},hn.gray.hex=function(t){var n=255&Math.round(t[0]/100*255),e=((n<<16)+(n<<8)+n).toString(16).toUpperCase();return"000000".substring(e.length)+e},hn.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var pn=sn.exports;function yn(t){var n=function(){for(var t={},n=Object.keys(pn),e=n.length,r=0;r<e;r++)t[n[r]]={distance:-1,parent:null};return t}(),e=[t];for(n[t].distance=0;e.length;)for(var r=e.pop(),i=Object.keys(pn[r]),s=i.length,o=0;o<s;o++){var a=i[o],u=n[a];-1===u.distance&&(u.distance=n[r].distance+1,u.parent=r,e.unshift(a))}return n}function mn(t,n){return function(e){return n(t(e))}}function gn(t,n){for(var e=[n[t].parent,t],r=pn[n[t].parent][t],i=n[t].parent;n[i].parent;)e.unshift(n[i].parent),r=mn(pn[n[i].parent][i],r),i=n[i].parent;return r.conversion=e,r}var vn=sn.exports,bn=function(t){for(var n=yn(t),e={},r=Object.keys(n),i=r.length,s=0;s<i;s++){var o=r[s];null!==n[o].parent&&(e[o]=gn(o,n))}return e},wn={};Object.keys(vn).forEach((function(t){wn[t]={},Object.defineProperty(wn[t],"channels",{value:vn[t].channels}),Object.defineProperty(wn[t],"labels",{value:vn[t].labels});var n=bn(t);Object.keys(n).forEach((function(e){var r=n[e];wn[t][e]=function(t){var n=function(n){if(null==n)return n;arguments.length>1&&(n=Array.prototype.slice.call(arguments));var e=t(n);if("object"==typeof e)for(var r=e.length,i=0;i<r;i++)e[i]=Math.round(e[i]);return e};return"conversion"in t&&(n.conversion=t.conversion),n}(r),wn[t][e].raw=function(t){var n=function(n){return null==n?n:(arguments.length>1&&(n=Array.prototype.slice.call(arguments)),t(n))};return"conversion"in t&&(n.conversion=t.conversion),n}(r)}))}));var Mn=wn,xn=Ht.exports,Fn=Mn,An=[].slice,kn=["keyword","gray","hex"],Pn={};Object.keys(Fn).forEach((function(t){Pn[An.call(Fn[t].labels).sort().join("")]=t}));var Sn={};function _n(t,n){if(!(this instanceof _n))return new _n(t,n);if(n&&n in kn&&(n=null),n&&!(n in Fn))throw new Error("Unknown model: "+n);var e,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof _n)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=xn.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=Fn[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=n||"rgb",r=Fn[this.model].channels;var s=An.call(t,0,r);this.color=$n(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in Pn))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Pn[a];var u=Fn[this.model].labels,h=[];for(e=0;e<u.length;e++)h.push(t[u[e]]);this.color=$n(h)}if(Sn[this.model])for(r=Fn[this.model].channels,e=0;e<r;e++){var l=Sn[this.model][e];l&&(this.color[e]=l(this.color[e]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function On(t,n,e){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(Sn[t]||(Sn[t]=[]))[n]=e})),t=t[0],function(r){var i;return arguments.length?(e&&(r=e(r)),(i=this[t]()).color[n]=r,i):(i=this[t]().color[n],e&&(i=e(i)),i)}}function En(t){return function(n){return Math.max(0,Math.min(t,n))}}function In(t){return Array.isArray(t)?t:[t]}function $n(t,n){for(var e=0;e<n;e++)"number"!=typeof t[e]&&(t[e]=0);return t}_n.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var n=this.model in xn.to?this:this.rgb(),e=1===(n=n.round("number"==typeof t?t:1)).valpha?n.color:n.color.concat(this.valpha);return xn.to[n.model](e)},percentString:function(t){var n=this.rgb().round("number"==typeof t?t:1),e=1===n.valpha?n.color:n.color.concat(this.valpha);return xn.to.rgb.percent(e)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},n=Fn[this.model].channels,e=Fn[this.model].labels,r=0;r<n;r++)t[e[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new _n(this.color.map(function(t){return function(n){return function(t,n){return Number(t.toFixed(n))}(n,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new _n(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:On("rgb",0,En(255)),green:On("rgb",1,En(255)),blue:On("rgb",2,En(255)),hue:On(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:On("hsl",1,En(100)),lightness:On("hsl",2,En(100)),saturationv:On("hsv",1,En(100)),value:On("hsv",2,En(100)),chroma:On("hcg",1,En(100)),gray:On("hcg",2,En(100)),white:On("hwb",1,En(100)),wblack:On("hwb",2,En(100)),cyan:On("cmyk",0,En(100)),magenta:On("cmyk",1,En(100)),yellow:On("cmyk",2,En(100)),black:On("cmyk",3,En(100)),x:On("xyz",0,En(100)),y:On("xyz",1,En(100)),z:On("xyz",2,En(100)),l:On("lab",0,En(100)),a:On("lab",1),b:On("lab",2),keyword:function(t){return arguments.length?new _n(t):Fn[this.model].keyword(this.color)},hex:function(t){return arguments.length?new _n(t):xn.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,n=[],e=0;e<t.length;e++){var r=t[e]/255;n[e]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*n[0]+.7152*n[1]+.0722*n[2]},contrast:function(t){var n=this.luminosity(),e=t.luminosity();return n>e?(n+.05)/(e+.05):(e+.05)/(n+.05)},level:function(t){var n=this.contrast(t);return n>=7.1?"AAA":n>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),n=0;n<3;n++)t.color[n]=255-t.color[n];return t},lighten:function(t){var n=this.hsl();return n.color[2]+=n.color[2]*t,n},darken:function(t){var n=this.hsl();return n.color[2]-=n.color[2]*t,n},saturate:function(t){var n=this.hsl();return n.color[1]+=n.color[1]*t,n},desaturate:function(t){var n=this.hsl();return n.color[1]-=n.color[1]*t,n},whiten:function(t){var n=this.hwb();return n.color[1]+=n.color[1]*t,n},blacken:function(t){var n=this.hwb();return n.color[2]+=n.color[2]*t,n},grayscale:function(){var t=this.rgb().color,n=.3*t[0]+.59*t[1]+.11*t[2];return _n.rgb(n,n,n)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var n=this.hsl(),e=n.color[0];return e=(e=(e+t)%360)<0?360+e:e,n.color[0]=e,n},mix:function(t,n){if(!t||!t.rgb)throw new Error(\'Argument to "mix" was not a Color instance, but rather an instance of \'+typeof t);var e=t.rgb(),r=this.rgb(),i=void 0===n?.5:n,s=2*i-1,o=e.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,u=1-a;return _n.rgb(a*e.red()+u*r.red(),a*e.green()+u*r.green(),a*e.blue()+u*r.blue(),e.alpha()*i+r.alpha()*(1-i))}},Object.keys(Fn).forEach((function(t){if(-1===kn.indexOf(t)){var n=Fn[t].channels;_n.prototype[t]=function(){if(this.model===t)return new _n(this);if(arguments.length)return new _n(arguments,t);var e="number"==typeof arguments[n]?n:this.valpha;return new _n(In(Fn[this.model][t].raw(this.color)).concat(e),t)},_n[t]=function(e){return"number"==typeof e&&(e=$n(An.call(arguments),n)),new _n(e,t)}}}));var Cn=_n;\n/*!\n        Feature Filter by\n\n        (c) mapbox 2016 and maptalks 2018\n        www.mapbox.com | www.maptalks.org\n        License: MIT, header required.\n    */const Tn=["Unknown","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"];function zn(t){return new Function("f","var p = (f && f.properties || {}); return "+Dn(t))}function Dn(t){if(!t)return"true";const n=t[0];if(t.length<=1)return"any"===n?"false":"true";return`(${"=="===n?Un(t[1],t[2],"===",!1):"!="===n?Un(t[1],t[2],"!==",!1):"<"===n||">"===n||"<="===n||">="===n?Un(t[1],t[2],n,!0):"any"===n?Ln(t.slice(1),"||"):"all"===n?Ln(t.slice(1),"&&"):"none"===n?Hn(Ln(t.slice(1),"||")):"in"===n?Vn(t[1],t.slice(2)):"!in"===n?Hn(Vn(t[1],t.slice(2))):"has"===n?Rn(t[1]):"!has"===n?Hn(Rn(t[1])):"contains"===n?function(t,n,e){const r=jn(t);return void 0!==e?`(${r} + \'\').indexOf("${n}") === ${e}`:`(${r} + \'\').indexOf("${n}") >= 0`}(t[1],t[2],t[3]):"true"})`}function jn(t){return"$"===t[0]?"f."+t.substring(1):"p["+JSON.stringify(t)+"]"}function Un(t,n,e,r){if("object"==typeof(i=t)&&i&&t.op)return function(t,n,e,r){const i=t.property,s=t.op;let o=jn(i);return"length"!==s?(console.error(`not support ${s} op`),"false"):(o=`((${o}+=\'\').length)`,Nn(o,i,n,e,r))}(t,n,e,r);var i;return Nn(jn(t),t,n,e,r)}function Nn(t,n,e,r,i){const s="$type"===n?Tn.indexOf(e):JSON.stringify(e);return(i?`typeof ${t}=== typeof ${s}&&`:"")+t+r+s}function Ln(t,n){return t.map(Dn).join(n)}function Vn(t,n){"$type"===t&&(n=n.map(t=>Tn.indexOf(t)));const e=JSON.stringify(n.sort(Wn)),r=jn(t);return n.length<=200?`${e}.indexOf(${r}) !== -1`:`function(v, a, i, j) {\\n        while (i <= j) { var m = (i + j) >> 1;\\n            if (a[m] === v) return true; if (a[m] > v) j = m - 1; else i = m + 1;\\n        }\\n    return false; }(${r}, ${e},0,${n.length-1})`}function Rn(t){return"$id"===t?\'"id" in f\':JSON.stringify(t)+" in p"}function Hn(t){return`!(${t})`}function Wn(t,n){return t<n?-1:t>n?1:0}var qn={exports:{}};qn.exports=function(){function t(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}function n(t,n){return t<n?-1:t>n?1:0}return function(e,r,i,s,o){!function n(e,r,i,s,o){for(;s>i;){if(s-i>600){var a=s-i+1,u=r-i+1,h=Math.log(a),l=.5*Math.exp(2*h/3),c=.5*Math.sqrt(h*l*(a-l)/a)*(u-a/2<0?-1:1),f=Math.max(i,Math.floor(r-u*l/a+c)),d=Math.min(s,Math.floor(r+(a-u)*l/a+c));n(e,r,f,d,o)}var p=e[r],y=i,m=s;for(t(e,i,r),o(e[s],p)>0&&t(e,i,s);y<m;){for(t(e,y,m),y++,m--;o(e[y],p)<0;)y++;for(;o(e[m],p)>0;)m--}0===o(e[i],p)?t(e,i,m):(m++,t(e,m,s)),m<=r&&(i=m+1),r<=m&&(s=m-1)}}(e,r,i||0,s||e.length-1,o||n)}}();var Gn=qn.exports;class Bn{constructor(t=[],n=Jn){if(this.data=t,this.length=this.data.length,this.compare=n,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this.D(t)}push(t){this.data.push(t),this.length++,this.j(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],n=this.data.pop();return this.length--,this.length>0&&(this.data[0]=n,this.D(0)),t}peek(){return this.data[0]}j(t){const{data:n,compare:e}=this,r=n[t];for(;t>0;){const i=t-1>>1,s=n[i];if(e(r,s)>=0)break;n[t]=s,t=i}n[t]=r}D(t){const{data:n,compare:e}=this,r=this.length>>1,i=n[t];for(;t<r;){let r=1+(t<<1),s=n[r];const o=r+1;if(o<this.length&&e(n[o],s)<0&&(r=o,s=n[o]),e(s,i)>=0)break;n[t]=s,t=r}n[t]=i}}function Jn(t,n){return t<n?-1:t>n?1:0}\n/*!\n     * Contains code from google filament\n     * https://github.com/google/filament/\n     * License Apache-2.0\n     */const Xn=[],Yn=[],Zn=[],Kn=[];function Qn(t,n,e){const r=mt(Yn,n,e);t=At(t,function(t,n,e,r,i,s,o,a,u,h){return t[0]=n,t[1]=e,t[2]=r,t[3]=i,t[4]=s,t[5]=o,t[6]=a,t[7]=u,t[8]=h,t}(Xn,e[0],e[1],e[2],...r,...n));if((t=function(t){return t[3]<0?Pt(t,t,-1):t}(t=St(t,t)))[3]<1/32767){t[3]=1/32767;const n=Math.sqrt(.9999999990686206);t[0]*=n,t[1]*=n,t[2]*=n}const i=e[3]>0?mt(Zn,e,n):mt(Zn,n,e);return yt(mt(Kn,e,n),i)<0&&Pt(t,t,-1),t}const te=[];function ne(t,n,e){const r=e||[];r.setLength&&r.setLength(t.length);const i=te;i.length<t.length/3&&(i.length=t.length/3),i.fill(0,0,t.length/3);const s=void 0===n.length?n:n.length;for(let e=0;e<s/3;e++)void 0===n.length?he(t,3*e,3*e+1,3*e+2,r,i):he(t,n[3*e],n[3*e+1],n[3*e+2],r,i);for(let t=0;t<r.length;t+=3){const n=i[t/3];0!==n?(r[t]/=n,r[t+1]/=n,r[t+2]/=n):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}const ee=[],re=[],ie=[],se=[],oe=[],ae=[],ue=[];function he(t,n,e,r,i,s){ft(se,t[3*n],t[3*n+1],t[3*n+2]),ft(oe,t[3*e],t[3*e+1],t[3*e+2]),ft(ae,t[3*r],t[3*r+1],t[3*r+2]);const o=gt(ee,ae,oe),a=gt(re,se,oe),u=mt(ie,o,a);pt(ue,u),i[3*n]=i[3*n]||0,i[3*e]=i[3*e]||0,i[3*r]=i[3*r]||0,i[3*n+1]=i[3*n+1]||0,i[3*e+1]=i[3*e+1]||0,i[3*r+1]=i[3*r+1]||0,i[3*n+2]=i[3*n+2]||0,i[3*e+2]=i[3*e+2]||0,i[3*r+2]=i[3*r+2]||0,i[3*n]+=ue[0],i[3*e]+=ue[0],i[3*r]+=ue[0],i[3*n+1]+=ue[1],i[3*e+1]+=ue[1],i[3*r+1]+=ue[1],i[3*n+2]+=ue[2],i[3*e+2]+=ue[2],i[3*r+2]+=ue[2],s[n]+=1,s[e]+=1,s[r]+=1}\n/*!\n     * Contains code from THREE.JS\n     * https://github.com/mrdoob/three.js/\n     * License MIT\n     * \n     * Generate tangents per vertex.\n     */function le(t,n,e){return t[0]=n[e],t[1]=n[e+1],t[2]=n[e+2],t}function ce(t,n,e){return t[0]=n[e],t[1]=n[e+1],t}var fe={exports:{}};function de(t,n,e){e=e||2;var r,i,s,o,a,u,h,l=n&&n.length,c=l?n[0]*e:t.length,f=pe(t,0,c,e,!0),d=[];if(!f||f.next===f.prev)return d;if(l&&(f=function(t,n,e,r){var i,s,o,a,u,h=[];for(i=0,s=n.length;i<s;i++)o=n[i]*r,a=i<s-1?n[i+1]*r:t.length,(u=pe(t,o,a,r,!1))===u.next&&(u.steiner=!0),h.push(ke(u));for(h.sort(Me),i=0;i<h.length;i++)e=xe(h[i],e);return e}(t,n,f,e)),t.length>80*e){r=s=t[0],i=o=t[1];for(var p=e;p<c;p+=e)(a=t[p])<r&&(r=a),(u=t[p+1])<i&&(i=u),a>s&&(s=a),u>o&&(o=u);h=0!==(h=Math.max(s-r,o-i))?32767/h:0}return me(f,d,e,r,i,h,0),d}function pe(t,n,e,r,i){var s,o;if(i===Ue(t,n,e,r)>0)for(s=n;s<e;s+=r)o=ze(s,t[s],t[s+1],o);else for(s=e-r;s>=n;s-=r)o=ze(s,t[s],t[s+1],o);return o&&Oe(o,o.next)&&(De(o),o=o.next),o}function ye(t,n){if(!t)return t;n||(n=t);var e,r=t;do{if(e=!1,r.steiner||!Oe(r,r.next)&&0!==_e(r.prev,r,r.next))r=r.next;else{if(De(r),(r=n=r.prev)===r.next)break;e=!0}}while(e||r!==n);return n}function me(t,n,e,r,i,s,o){if(t){!o&&s&&function(t,n,e,r){var i=t;do{0===i.z&&(i.z=Ae(i.x,i.y,n,e,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var n,e,r,i,s,o,a,u,h=1;do{for(e=t,t=null,s=null,o=0;e;){for(o++,r=e,a=0,n=0;n<h&&(a++,r=r.nextZ);n++);for(u=h;a>0||u>0&&r;)0!==a&&(0===u||!r||e.z<=r.z)?(i=e,e=e.nextZ,a--):(i=r,r=r.nextZ,u--),s?s.nextZ=i:t=i,i.prevZ=s,s=i;e=r}s.nextZ=null,h*=2}while(o>1)}(i)}(t,r,i,s);for(var a,u,h=t;t.prev!==t.next;)if(a=t.prev,u=t.next,s?ve(t,r,i,s):ge(t))n.push(a.i/e|0),n.push(t.i/e|0),n.push(u.i/e|0),De(t),t=u.next,h=u.next;else if((t=u)===h){o?1===o?me(t=be(ye(t),n,e),n,e,r,i,s,2):2===o&&we(t,n,e,r,i,s):me(ye(t),n,e,r,i,s,1);break}}}function ge(t){var n=t.prev,e=t,r=t.next;if(_e(n,e,r)>=0)return!1;for(var i=n.x,s=e.x,o=r.x,a=n.y,u=e.y,h=r.y,l=i<s?i<o?i:o:s<o?s:o,c=a<u?a<h?a:h:u<h?u:h,f=i>s?i>o?i:o:s>o?s:o,d=a>u?a>h?a:h:u>h?u:h,p=r.next;p!==n;){if(p.x>=l&&p.x<=f&&p.y>=c&&p.y<=d&&Pe(i,a,s,u,o,h,p.x,p.y)&&_e(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function ve(t,n,e,r){var i=t.prev,s=t,o=t.next;if(_e(i,s,o)>=0)return!1;for(var a=i.x,u=s.x,h=o.x,l=i.y,c=s.y,f=o.y,d=a<u?a<h?a:h:u<h?u:h,p=l<c?l<f?l:f:c<f?c:f,y=a>u?a>h?a:h:u>h?u:h,m=l>c?l>f?l:f:c>f?c:f,g=Ae(d,p,n,e,r),v=Ae(y,m,n,e,r),b=t.prevZ,w=t.nextZ;b&&b.z>=g&&w&&w.z<=v;){if(b.x>=d&&b.x<=y&&b.y>=p&&b.y<=m&&b!==i&&b!==o&&Pe(a,l,u,c,h,f,b.x,b.y)&&_e(b.prev,b,b.next)>=0)return!1;if(b=b.prevZ,w.x>=d&&w.x<=y&&w.y>=p&&w.y<=m&&w!==i&&w!==o&&Pe(a,l,u,c,h,f,w.x,w.y)&&_e(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;b&&b.z>=g;){if(b.x>=d&&b.x<=y&&b.y>=p&&b.y<=m&&b!==i&&b!==o&&Pe(a,l,u,c,h,f,b.x,b.y)&&_e(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;w&&w.z<=v;){if(w.x>=d&&w.x<=y&&w.y>=p&&w.y<=m&&w!==i&&w!==o&&Pe(a,l,u,c,h,f,w.x,w.y)&&_e(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function be(t,n,e){var r=t;do{var i=r.prev,s=r.next.next;!Oe(i,s)&&Ee(i,r,r.next,s)&&Ce(i,s)&&Ce(s,i)&&(n.push(i.i/e|0),n.push(r.i/e|0),n.push(s.i/e|0),De(r),De(r.next),r=t=s),r=r.next}while(r!==t);return ye(r)}function we(t,n,e,r,i,s){var o=t;do{for(var a=o.next.next;a!==o.prev;){if(o.i!==a.i&&Se(o,a)){var u=Te(o,a);return o=ye(o,o.next),u=ye(u,u.next),me(o,n,e,r,i,s,0),void me(u,n,e,r,i,s,0)}a=a.next}o=o.next}while(o!==t)}function Me(t,n){return t.x-n.x}function xe(t,n){var e=function(t,n){var e,r=n,i=t.x,s=t.y,o=-1/0;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){var a=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>o&&(o=a,e=r.x<r.next.x?r:r.next,a===i))return e}r=r.next}while(r!==n);if(!e)return null;var u,h=e,l=e.x,c=e.y,f=1/0;r=e;do{i>=r.x&&r.x>=l&&i!==r.x&&Pe(s<c?i:o,s,l,c,s<c?o:i,s,r.x,r.y)&&(u=Math.abs(s-r.y)/(i-r.x),Ce(r,t)&&(u<f||u===f&&(r.x>e.x||r.x===e.x&&Fe(e,r)))&&(e=r,f=u)),r=r.next}while(r!==h);return e}(t,n);if(!e)return n;var r=Te(e,t);return ye(r,r.next),ye(e,e.next)}function Fe(t,n){return _e(t.prev,t,n.prev)<0&&_e(n.next,t,t.next)<0}function Ae(t,n,e,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=(n-r)*i|0)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function ke(t){var n=t,e=t;do{(n.x<e.x||n.x===e.x&&n.y<e.y)&&(e=n),n=n.next}while(n!==t);return e}function Pe(t,n,e,r,i,s,o,a){return(i-o)*(n-a)>=(t-o)*(s-a)&&(t-o)*(r-a)>=(e-o)*(n-a)&&(e-o)*(s-a)>=(i-o)*(r-a)}function Se(t,n){return t.next.i!==n.i&&t.prev.i!==n.i&&!function(t,n){var e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==n.i&&e.next.i!==n.i&&Ee(e,e.next,t,n))return!0;e=e.next}while(e!==t);return!1}(t,n)&&(Ce(t,n)&&Ce(n,t)&&function(t,n){var e=t,r=!1,i=(t.x+n.x)/2,s=(t.y+n.y)/2;do{e.y>s!=e.next.y>s&&e.next.y!==e.y&&i<(e.next.x-e.x)*(s-e.y)/(e.next.y-e.y)+e.x&&(r=!r),e=e.next}while(e!==t);return r}(t,n)&&(_e(t.prev,t,n.prev)||_e(t,n.prev,n))||Oe(t,n)&&_e(t.prev,t,t.next)>0&&_e(n.prev,n,n.next)>0)}function _e(t,n,e){return(n.y-t.y)*(e.x-n.x)-(n.x-t.x)*(e.y-n.y)}function Oe(t,n){return t.x===n.x&&t.y===n.y}function Ee(t,n,e,r){var i=$e(_e(t,n,e)),s=$e(_e(t,n,r)),o=$e(_e(e,r,t)),a=$e(_e(e,r,n));return i!==s&&o!==a||(!(0!==i||!Ie(t,e,n))||(!(0!==s||!Ie(t,r,n))||(!(0!==o||!Ie(e,t,r))||!(0!==a||!Ie(e,n,r)))))}function Ie(t,n,e){return n.x<=Math.max(t.x,e.x)&&n.x>=Math.min(t.x,e.x)&&n.y<=Math.max(t.y,e.y)&&n.y>=Math.min(t.y,e.y)}function $e(t){return t>0?1:t<0?-1:0}function Ce(t,n){return _e(t.prev,t,t.next)<0?_e(t,n,t.next)>=0&&_e(t,t.prev,n)>=0:_e(t,n,t.prev)<0||_e(t,t.next,n)<0}function Te(t,n){var e=new je(t.i,t.x,t.y),r=new je(n.i,n.x,n.y),i=t.next,s=n.prev;return t.next=n,n.prev=t,e.next=i,i.prev=e,r.next=e,e.prev=r,s.next=r,r.prev=s,r}function ze(t,n,e,r){var i=new je(t,n,e);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function De(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function je(t,n,e){this.i=t,this.x=n,this.y=e,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Ue(t,n,e,r){for(var i=0,s=n,o=e-r;s<e;s+=r)i+=(t[o]-t[s])*(t[s+1]+t[o+1]),o=s;return i}fe.exports=de,fe.exports.default=de,de.deviation=function(t,n,e,r){var i=n&&n.length,s=i?n[0]*e:t.length,o=Math.abs(Ue(t,0,s,e));if(i)for(var a=0,u=n.length;a<u;a++){var h=n[a]*e,l=a<u-1?n[a+1]*e:t.length;o-=Math.abs(Ue(t,h,l,e))}var c=0;for(a=0;a<r.length;a+=3){var f=r[a]*e,d=r[a+1]*e,p=r[a+2]*e;c+=Math.abs((t[f]-t[p])*(t[d+1]-t[f+1])-(t[f]-t[d])*(t[p+1]-t[f+1]))}return 0===o&&0===c?0:Math.abs((c-o)/o)},de.flatten=function(t){for(var n=t[0][0].length,e={vertices:[],holes:[],dimensions:n},r=0,i=0;i<t.length;i++){for(var s=0;s<t[i].length;s++)for(var o=0;o<n;o++)e.vertices.push(t[i][s][o]);i>0&&(r+=t[i-1].length,e.holes.push(r))}return e};var Ne=fe.exports;\n/*!\n     * @maptalks/vector-packer v0.92.1\n     * LICENSE : UNLICENSED\n     * (c) 2016-2024 maptalks.com\n     */const Le={Point:1,LineString:2,Polygon:3,MultiPoint:4,MultiLineString:5,MultiPolygon:6};function Ve(t,n={}){var e=[];if("FeatureCollection"===t.type)for(var r=0;r<t.features.length;r++)Re(e,t.features[r],n,r);else Re(e,"Feature"===t.type?t:{geometry:t},n);return e}function Re(t,n,e,r){if(n.geometry&&n.geometry.geometry){var i=n.geometry.coordinates,s=n.geometry.type,o=[],a=n.id;if(e.promoteId?a=n.properties[e.promoteId]:e.generateId&&(a=r||0),"Point"===s)He(i,o);else if("MultiPoint"===s)for(var u=0;u<i.length;u++)He(i[u],o);else if("LineString"===s)qe([i],o);else if("MultiLineString"===s){if(e.lineMetrics){for(u=0;u<i.length;u++)We(i[u],o=[]),t.push(Ge(a,"LineString",o,n.properties));return}qe(i,o)}else if("Polygon"===s)qe(i,o);else{if("MultiPolygon"!==s){if("GeometryCollection"===s){for(u=0;u<n.geometry.geometries.length;u++)Re(t,{id:a,geometry:n.geometry.geometries[u],properties:n.properties},e,r);return}return void console.warn(`Input data type(${s}) is not a valid GeoJSON geometry type.`)}for(u=0;u<i.length;u++){var h=[];qe(i[u],h),o.push(h)}}t.push(Ge(a,s,o,n.properties))}}function He(t,n){const e=new Ut(t[0],t[1]);e.z=100*(t[2]||0),n.push([e])}function We(t,n){for(let e=0;e<t.length;e++){const r=new Ut(t[e][0],t[e][1]);r.z=100*(t[e][2]||0),n.push(r)}}function qe(t,n,e,r){for(var i=0;i<t.length;i++){var s=[];We(t[i],s),n.push(s)}}function Ge(t,n,e,r){return{id:void 0===t?null:t,type:Le[n],geometry:e,properties:r}}\n/*!\n     * Codes from mapbox-gl-js\n     * github.com/mapbox/mapbox-gl-js\n     * MIT License\n     */function Be(t,{width:n,height:e},r,i){if(i){if(i.length!==n*e*r)throw new RangeError("mismatched image size")}else i=new Uint8Array(n*e*r);return t.width=n,t.height=e,t.data=i,t}function Je(t,{width:n,height:e},r){if(n===t.width&&e===t.height)return;const i=Be({},{width:n,height:e},r);Xe(t,i,{x:0,y:0},{x:0,y:0},{width:Math.min(t.width,n),height:Math.min(t.height,e)},r),t.width=n,t.height=e,t.data=i.data}function Xe(t,n,e,r,i,s){if(0===i.width||0===i.height)return n;if(i.width>t.width||i.height>t.height||e.x>t.width-i.width||e.y>t.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>n.width||i.height>n.height||r.x>n.width-i.width||r.y>n.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const o=t.data,a=n.data;if(o===a)return n;for(let u=0;u<i.height;u++){const h=((e.y+u)*t.width+e.x)*s,l=((r.y+u)*n.width+r.x)*s;for(let t=0;t<i.width*s;t++)a[l+t]=o[h+t]}return n}class Ye{constructor(t,n){Be(this,t,1,n)}resize(t){Je(this,t,1)}clone(){return new Ye({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,n,e,r,i){Xe(t,n,e,r,i,1)}}class Ze{constructor(t,n){Be(this,t,4,n)}resize(t){Je(this,t,4)}clone(){return new Ze({width:this.width,height:this.height},new Uint8Array(this.data))}static copy(t,n,e,r,i){Xe(t,n,e,r,i,4)}}\n/*!\n     * Codes from mapbox-gl-js\n     * github.com/mapbox/mapbox-gl-js\n     * MIT License\n     */class Ke{constructor(t,n,{pixelRatio:e}){this.paddedRect=t,this.pixelRatio=e||1,this.padding=n}get tl(){return[this.paddedRect.x+this.padding,this.paddedRect.y+this.padding]}get br(){return[this.paddedRect.x+this.paddedRect.w-this.padding,this.paddedRect.y+this.paddedRect.h-this.padding]}get displaySize(){return[(this.paddedRect.w-2*this.padding)/this.pixelRatio,(this.paddedRect.h-2*this.padding)/this.pixelRatio]}}class Qe{constructor(t){this.glyphMap=t,this.build()}build(){const t=this.glyphMap,n=Object.keys(t).length,e={},r=new Lt(0,0,{autoResize:!0}),i=[],s=n>1?1:0;for(const n in t){const r=t[n],o={x:0,y:0,w:r.data.width+2*s,h:r.data.height+2*s};i.push(o),e[n]=new Ke(o,s,r)}if(r.pack(i,{inPlace:!0}),!tr(r.w)||!tr(r.h)){const t=nr(r.w),n=nr(r.h);r.resize(t,n)}const o=new Ze({width:r.w,height:r.h});for(const n in t){const r=t[n],i=e[n].paddedRect;Ze.copy(r.data,o,{x:0,y:0},{x:i.x+s,y:i.y+s},r.data)}this.image=o,this.positions=e}}function tr(t){return 0==(t&t-1)&&0!==t}function nr(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}\n/*!\n     * Codes from mapbox-gl-js\n     * github.com/mapbox/mapbox-gl-js\n     * MIT License\n     * TODO å‡çº§ä¸ºpotpack\n     */class er{constructor(t){this.glyphMap=t,this.build()}build(){const t=this.glyphMap,n={},e=new Lt(0,0,{autoResize:!0}),r=[];for(const e in t){const i=t[e],s=n[e]={};for(const t in i){const n=i[+t];if(!n||0===n.bitmap.width||0===n.bitmap.height)continue;const e={x:0,y:0,w:n.bitmap.width+2,h:n.bitmap.height+2};r.push(e),s[t]={rect:e,metrics:n.metrics}}}e.pack(r,{inPlace:!0});const i=new Ye({width:e.w,height:e.h});for(const e in t){const r=t[e];for(const t in r){const s=r[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const o=n[e][t].rect;Ye.copy(s.bitmap,i,{x:0,y:0},{x:o.x+1,y:o.y+1},s.bitmap)}}this.image=i,this.positions=n}}function rr(t){return t<65536?Uint16Array:Uint32Array}function ir(t){return(t=Math.abs(t))<128?Int8Array:t<32768?Int16Array:Float32Array}function sr(t){return t<256?Uint8Array:t<65536?Uint16Array:Float32Array}function or(t,n){const e=new n(t.length),r=e.length;for(let n=0;n<r;n++)e[n]=t[n];return e}function ar(t){const n=t.type,e=[];if(1===n||4===n)for(let n=0;n<t.geometry.length;n++)He(t.geometry[n],e);else if(2===n)qe(t.geometry,e);else if(3===n)qe(t.geometry,e);else if(5===n)qe(t.geometry,e);else if(6===n)for(let n=0;n<t.geometry.length;n++){const r=[];qe(t.geometry[n],r),e.push(r)}return t.geometry=e,t}function ur(t){for(let n=1;n<arguments.length;n++){const e=arguments[n];for(const n in e)t[n]=e[n]}return t}function hr(t){return null==t}function lr(t){return"number"==typeof t&&!isNaN(t)}function cr(t){return"object"==typeof t&&!!t}function fr(t){return!hr(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function dr(t){return!hr(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}const pr=Object.prototype.hasOwnProperty;function yr(t,n){return pr.call(t,n)}const mr=Math.PI/180;function gr(t){return t&&d(t)&&t.property}function vr(t){const{verticalCentimeterToPoint:n,tileRatio:e}=t;return n*e}function br(t){return"centimeter"===t||"cm"===t?1:"millimeter"===t||"mm"===t?.1:100}const wr={};function Mr(t,n){if(!Array.isArray(n)){if(n&&void 0!==n.r&&void 0!==n.g&&void 0!==n.b)return t[0]=255*n.r,t[1]=255*n.g,t[2]=255*n.b,t[3]=void 0!==n.a?255*n.a:255,t;n=wr[n]=wr[n]||Cn(n).unitArray()}for(let e=0;e<n.length;e++)t[e]=255*n[e];return 3===n.length&&(t[3]=255),t}const xr={textFill:1,textSize:1,textOpacity:1,textDx:1,textDy:1,markerWidth:1,markerHeight:1,markerOpacity:1,markerDx:1,markerDy:1,lineWidth:1,lineColor:1,lineOpacity:1,polygonFill:1,polygonOpacity:1,polygonPatternFileWidth:1,polygonPatternFileOrigin:1},Fr={textName:1,markerTextFitPadding:1,markerTextFit:1,lineGradientProperty:1};var Ar=Object.freeze({__proto__:null,now:function(){return Date.now()},extend:ur,isNil:hr,isNumber:lr,isInteger:function(t){return(0|t)===t},isObject:cr,isString:fr,isFunction:dr,hasOwn:yr,join:function(t,n){return t.join?t.join(n||","):Array.prototype.join.call(t,n||",")},toRadian:function(t){return t*mr},toDegree:function(t){return t/mr},evaluate:function(t,n,e){return dr(t)?t(void 0!==e?e:null,n):t},isFnTypeSymbol:gr,getAltitudeToLocal:vr,getTubeSizeScale:br,normalizeColor:Mr,checkIfIdentityZoomDependent:function(t,n,e){if(Array.isArray(e)||(e=Object.values(e)),!e||!e.length)return!1;if(!xr[t])return!1;for(let t=0;t<e.length;t++){const r=e[t]&&(e[t].feature||e[t]);if(!r)continue;const i=r.properties&&r.properties[n];if(i&&d(i)&&!p(i).isZoomConstant)return!0}return!1},checkIfZoomFnTypeSymbol:function(t){return!!xr[t]||!!Fr[t]}});function kr(t){let n=0;for(let e,r,i=0,s=t.length,o=s-1;i<s;o=i++)if(e=t[i],r=t[o],void 0!==e.x){if(e.z||r.z)return 1;n+=(r.x-e.x)*(e.y+r.y)}else{if(e[2]||r[2])return 1;n+=(r[0]-e[0])*(e[1]+r[1])}return n}function Pr(t,n,e,r,i){const s=t[n*r],o=t[n*r+1],a=t[e*r],u=t[e*r+1];return s===a&&(s<0||s>i)&&o!==u||o===u&&(o<0||o>i)&&s!==a}function Sr(t,n,e){let r=e;return n&&t&&(r=+t[n]),isNaN(r)&&(r=e||0),100*r}function _r(t,n,e,r,i,s,o){n||0===n||(n=1);const a=Sr(t.properties,e,r),u=a*n;let h=(s?100*s:0)||a;return i?h=Sr(t.properties,i,s):o&&(h=a-Sr(t.properties,o,s)),h*=n,{altitude:u,height:h}}function Or(t,n){return n<1/0&&(t.x<0||t.x>n||t.y<0||t.y>n)}function Er(t){return null==t}function Ir(t,n,e){if(t===e||t===n)return t;const r=e-n;return((t-n)%r+r)%r+n}function $r(t,n){if(!n)return null;const e=new Map;for(let r=0;r<n.length;r++){const i=n[r],s=t[i];let o=e.get(s);o||(o=[],e.set(s,o)),o.push(i)}return e}class Cr{constructor(t,n,e,r){this.feature=t,this.symbol=n,this.fnTypes=e,this.options=r}getPolygonResource(){let t=this.symbol.polygonPatternFile;const{polygonPatternFileFn:n}=this.fnTypes;return this.U(t,n)}getLineResource(){let t=this.symbol.linePatternFile;const{linePatternFileFn:n}=this.fnTypes;return this.U(t,n)}U(t,n){return n&&(t=n(this.options.zoom,this.feature.properties)),t}}function Tr(t,n,e,r){const i=Math.abs(r)>>15,s=i>>1,o=i%2;let a=r%Math.pow(2,15);const u=n+(s<<14)*Math.sign(n),h=e+(o<<14)*Math.sign(e);return t[0]=u,t[1]=h,a=Math.round(a),t[2]=0===a?r<0?-1:0:a,t}const zr=Math.pow(2,14),Dr=Math.pow(2,15);\n/*!\n     * a compact version of mapbox-gl-style-spec\n     * based on mapbox-gl-style-spec@13.28.0\n     * https://github.com/mapbox/mapbox-gl-js/tree/main/src/style-spec\n     * LICENSE : ISC\n     */var jr,Ur,Nr="undefined"!=typeof undefinedThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof undefined?global:"undefined"!=typeof self?self:{},Lr={exports:{}};function Vr(t,...n){for(const e of n)for(const n in e)t[n]=e[n];return t}\n/*! https://mths.be/punycode v1.3.2 by @mathias */jr=Lr,Ur=Lr.exports,function(t){var n=Ur&&!Ur.nodeType&&Ur,e=jr&&!jr.nodeType&&jr,r="object"==typeof Nr&&Nr;r.global!==r&&r.window!==r&&r.self!==r||(t=r);var i,s,o=2147483647,a=/^xn--/,u=/[^\\x20-\\x7E]/,h=/[\\x2E\\u3002\\uFF0E\\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},c=Math.floor,f=String.fromCharCode;function d(t){throw RangeError(l[t])}function p(t,n){for(var e=t.length,r=[];e--;)r[e]=n(t[e]);return r}function y(t,n){var e=t.split("@"),r="";return e.length>1&&(r=e[0]+"@",t=e[1]),r+p((t=t.replace(h,".")).split("."),n).join(".")}function m(t){for(var n,e,r=[],i=0,s=t.length;i<s;)(n=t.charCodeAt(i++))>=55296&&n<=56319&&i<s?56320==(64512&(e=t.charCodeAt(i++)))?r.push(((1023&n)<<10)+(1023&e)+65536):(r.push(n),i--):r.push(n);return r}function g(t){return p(t,(function(t){var n="";return t>65535&&(n+=f((t-=65536)>>>10&1023|55296),t=56320|1023&t),n+f(t)})).join("")}function v(t,n){return t+22+75*(t<26)-((0!=n)<<5)}function b(t,n,e){var r=0;for(t=e?c(t/700):t>>1,t+=c(t/n);t>455;r+=36)t=c(t/35);return c(r+36*t/(t+38))}function w(t){var n,e,r,i,s,a,u,h,l,f,p,y=[],m=t.length,v=0,w=128,M=72;for((e=t.lastIndexOf("-"))<0&&(e=0),r=0;r<e;++r)t.charCodeAt(r)>=128&&d("not-basic"),y.push(t.charCodeAt(r));for(i=e>0?e+1:0;i<m;){for(s=v,a=1,u=36;i>=m&&d("invalid-input"),((h=(p=t.charCodeAt(i++))-48<10?p-22:p-65<26?p-65:p-97<26?p-97:36)>=36||h>c((o-v)/a))&&d("overflow"),v+=h*a,!(h<(l=u<=M?1:u>=M+26?26:u-M));u+=36)a>c(o/(f=36-l))&&d("overflow"),a*=f;M=b(v-s,n=y.length+1,0==s),c(v/n)>o-w&&d("overflow"),w+=c(v/n),v%=n,y.splice(v++,0,w)}return g(y)}function M(t){var n,e,r,i,s,a,u,h,l,p,y,g,w,M,x,F=[];for(g=(t=m(t)).length,n=128,e=0,s=72,a=0;a<g;++a)(y=t[a])<128&&F.push(f(y));for(r=i=F.length,i&&F.push("-");r<g;){for(u=o,a=0;a<g;++a)(y=t[a])>=n&&y<u&&(u=y);for(u-n>c((o-e)/(w=r+1))&&d("overflow"),e+=(u-n)*w,n=u,a=0;a<g;++a)if((y=t[a])<n&&++e>o&&d("overflow"),y==n){for(h=e,l=36;!(h<(p=l<=s?1:l>=s+26?26:l-s));l+=36)F.push(f(v(p+(x=h-p)%(M=36-p),0))),h=c(x/M);F.push(f(v(h,0))),s=b(e,w,r==i),e=0,++r}++e,++n}return F.join("")}if(i={version:"1.3.2",ucs2:{decode:m,encode:g},decode:w,encode:M,toASCII:function(t){return y(t,(function(t){return u.test(t)?"xn--"+M(t):t}))},toUnicode:function(t){return y(t,(function(t){return a.test(t)?w(t.slice(4).toLowerCase()):t}))}},n&&e)if(jr.exports==n)e.exports=i;else for(s in i)i.hasOwnProperty(s)&&(n[s]=i[s]);else t.punycode=i}(Nr);class Rr extends Error{constructor(t,n){super(n),this.message=n,this.key=t}}var Hr=Rr;class Wr{constructor(t,n=[]){this.parent=t,this.bindings={};for(const[t,e]of n)this.bindings[t]=e}concat(t){return new Wr(this,t)}get(t){if(this.bindings[t])return this.bindings[t];if(this.parent)return this.parent.get(t);throw new Error(t+" not found in scope.")}has(t){return!!this.bindings[t]||!!this.parent&&this.parent.has(t)}}var qr=Wr;const Gr={kind:"null"},Br={kind:"number"},Jr={kind:"string"},Xr={kind:"boolean"},Yr={kind:"color"},Zr={kind:"object"},Kr={kind:"value"},Qr={kind:"collator"},ti={kind:"formatted"},ni={kind:"resolvedImage"};function ei(t,n){return{kind:"array",itemType:t,N:n}}function ri(t){if("array"===t.kind){const n=ri(t.itemType);return"number"==typeof t.N?`array<${n}, ${t.N}>`:"value"===t.itemType.kind?"array":`array<${n}>`}return t.kind}const ii=[Gr,Br,Jr,Xr,Yr,ti,Zr,ei(Kr),ni];function si(t,n){if("error"===n.kind)return null;if("array"===t.kind){if("array"===n.kind&&(0===n.N&&"value"===n.itemType.kind||!si(t.itemType,n.itemType))&&("number"!=typeof t.N||t.N===n.N))return null}else{if(t.kind===n.kind)return null;if("value"===t.kind)for(const t of ii)if(!si(t,n))return null}return`Expected ${ri(t)} but found ${ri(n)} instead.`}function oi(t,n){return n.some(n=>n.kind===t.kind)}function ai(t,n){return n.some(n=>"null"===n?null===t:"array"===n?Array.isArray(t):"object"===n?t&&!Array.isArray(t)&&"object"==typeof t:n===typeof t)}var ui,hi={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function li(t){return(t=Math.round(t))<0?0:t>255?255:t}function ci(t){return li("%"===t[t.length-1]?parseFloat(t)/100*255:parseInt(t))}function fi(t){return function(t){return t<0?0:t>1?1:t}("%"===t[t.length-1]?parseFloat(t)/100:parseFloat(t))}function di(t,n,e){return e<0?e+=1:e>1&&(e-=1),6*e<1?t+(n-t)*e*6:2*e<1?n:3*e<2?t+(n-t)*(2/3-e)*6:t}try{ui={}.parseCSSColor=function(t){var n,e=t.replace(/ /g,"").toLowerCase();if(e in hi)return hi[e].slice();if("#"===e[0])return 4===e.length?(n=parseInt(e.substr(1),16))>=0&&n<=4095?[(3840&n)>>4|(3840&n)>>8,240&n|(240&n)>>4,15&n|(15&n)<<4,1]:null:7===e.length&&(n=parseInt(e.substr(1),16))>=0&&n<=16777215?[(16711680&n)>>16,(65280&n)>>8,255&n,1]:null;var r=e.indexOf("("),i=e.indexOf(")");if(-1!==r&&i+1===e.length){var s=e.substr(0,r),o=e.substr(r+1,i-(r+1)).split(","),a=1;switch(s){case"rgba":if(4!==o.length)return null;a=fi(o.pop());case"rgb":return 3!==o.length?null:[ci(o[0]),ci(o[1]),ci(o[2]),a];case"hsla":if(4!==o.length)return null;a=fi(o.pop());case"hsl":if(3!==o.length)return null;var u=(parseFloat(o[0])%360+360)%360/360,h=fi(o[1]),l=fi(o[2]),c=l<=.5?l*(h+1):l+h-l*h,f=2*l-c;return[li(255*di(f,c,u+1/3)),li(255*di(f,c,u)),li(255*di(f,c,u-1/3)),a];default:return null}}return null}}catch(t){}class pi{constructor(t,n,e,r=1){this.r=t,this.g=n,this.b=e,this.a=r}static parse(t){if(!t)return;if(t instanceof pi)return t;if("string"!=typeof t)return;const n=ui(t);return n?new pi(n[0]/255*n[3],n[1]/255*n[3],n[2]/255*n[3],n[3]):void 0}toString(){const[t,n,e,r]=this.toArray();return`rgba(${Math.round(t)},${Math.round(n)},${Math.round(e)},${r})`}toArray(){const{r:t,g:n,b:e,a:r}=this;return 0===r?[0,0,0,0]:[255*t/r,255*n/r,255*e/r,r]}toArray01(){const{r:t,g:n,b:e,a:r}=this;return 0===r?[0,0,0,0]:[t/r,n/r,e/r,r]}toArray01PremultipliedAlpha(){const{r:t,g:n,b:e,a:r}=this;return[t,n,e,r]}}pi.black=new pi(0,0,0,1),pi.white=new pi(1,1,1,1),pi.transparent=new pi(0,0,0,0),pi.red=new pi(1,0,0,1),pi.blue=new pi(0,0,1,1);var yi=pi;class mi{constructor(t,n,e){this.sensitivity=t?n?"variant":"case":n?"accent":"base",this.locale=e,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(t,n){return this.collator.compare(t,n)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class gi{constructor(t,n,e,r,i){this.text=t.normalize?t.normalize():t,this.image=n,this.scale=e,this.fontStack=r,this.textColor=i}}class vi{constructor(t){this.sections=t}static fromString(t){return new vi([new gi(t,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(t=>0!==t.text.length||t.image&&0!==t.image.name.length)}static factory(t){return t instanceof vi?t:vi.fromString(t)}toString(){return 0===this.sections.length?"":this.sections.map(t=>t.text).join("")}serialize(){const t=["format"];for(const n of this.sections){if(n.image){t.push(["image",n.image.name]);continue}t.push(n.text);const e={};n.fontStack&&(e["text-font"]=["literal",n.fontStack.split(",")]),n.scale&&(e["font-scale"]=n.scale),n.textColor&&(e["text-color"]=["rgba"].concat(n.textColor.toArray())),t.push(e)}return t}}class bi{constructor(t){this.name=t.name,this.available=t.available}toString(){return this.name}static fromString(t){return t?new bi({name:t,available:!1}):null}serialize(){return["image",this.name]}}function wi(t,n,e,r){return"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255&&"number"==typeof e&&e>=0&&e<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[t,n,e,r].join(", ")}]: \'a\' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[t,n,e,r]:[t,n,e]).join(", ")}]: \'r\', \'g\', and \'b\' must be between 0 and 255.`}function Mi(t){if(null===t)return!0;if("string"==typeof t)return!0;if("boolean"==typeof t)return!0;if("number"==typeof t)return!0;if(t instanceof yi)return!0;if(t instanceof mi)return!0;if(t instanceof vi)return!0;if(t instanceof bi)return!0;if(Array.isArray(t)){for(const n of t)if(!Mi(n))return!1;return!0}if("object"==typeof t){for(const n in t)if(!Mi(t[n]))return!1;return!0}return!1}function xi(t){if(null===t)return Gr;if("string"==typeof t)return Jr;if("boolean"==typeof t)return Xr;if("number"==typeof t)return Br;if(t instanceof yi)return Yr;if(t instanceof mi)return Qr;if(t instanceof vi)return ti;if(t instanceof bi)return ni;if(Array.isArray(t)){const n=t.length;let e;for(const n of t){const t=xi(n);if(e){if(e===t)continue;e=Kr;break}e=t}return ei(e||Kr,n)}return Zr}function Fi(t){const n=typeof t;return null===t?"":"string"===n||"number"===n||"boolean"===n?String(t):t instanceof yi||t instanceof vi||t instanceof bi?t.toString():JSON.stringify(t)}class Ai{constructor(t,n){this.type=t,this.value=n}static parse(t,n){if(2!==t.length)return n.error(`\'literal\' expression requires exactly one argument, but found ${t.length-1} instead.`);if(!Mi(t[1]))return n.error("invalid value");const e=t[1];let r=xi(e);const i=n.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Ai(r,e)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof yi?["rgba"].concat(this.value.toArray()):this.value instanceof vi?this.value.serialize():this.value}}var ki=Ai,Pi=class{constructor(t){this.name="ExpressionEvaluationError",this.message=t}toJSON(){return this.message}};const Si={string:Jr,number:Br,boolean:Xr,object:Zr};class _i{constructor(t,n){this.type=t,this.args=n}static parse(t,n){if(t.length<2)return n.error("Expected at least one argument.");let e,r=1;const i=t[0];if("array"===i){let i,s;if(t.length>2){const e=t[1];if("string"!=typeof e||!(e in Si)||"object"===e)return n.error(\'The item type argument of "array" must be one of string, number, boolean\',1);i=Si[e],r++}else i=Kr;if(t.length>3){if(null!==t[2]&&("number"!=typeof t[2]||t[2]<0||t[2]!==Math.floor(t[2])))return n.error(\'The length argument to "array" must be a positive integer literal\',2);s=t[2],r++}e=ei(i,s)}else e=Si[i];const s=[];for(;r<t.length;r++){const e=n.parse(t[r],r,Kr);if(!e)return null;s.push(e)}return new _i(e,s)}evaluate(t){for(let n=0;n<this.args.length;n++){const e=this.args[n].evaluate(t);if(!si(this.type,xi(e)))return e;if(n===this.args.length-1)throw new Pi(`Expected value to be of type ${ri(this.type)}, but found ${ri(xi(e))} instead.`)}return null}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=this.type,n=[t.kind];if("array"===t.kind){const e=t.itemType;if("string"===e.kind||"number"===e.kind||"boolean"===e.kind){n.push(e.kind);const r=t.N;("number"==typeof r||this.args.length>1)&&n.push(r)}}return n.concat(this.args.map(t=>t.serialize()))}}var Oi=_i;class Ei{constructor(t){this.type=ti,this.sections=t}static parse(t,n){if(t.length<2)return n.error("Expected at least one argument.");const e=t[1];if(!Array.isArray(e)&&"object"==typeof e)return n.error("First argument must be an image or text section.");const r=[];let i=!1;for(let e=1;e<=t.length-1;++e){const s=t[e];if(i&&"object"==typeof s&&!Array.isArray(s)){i=!1;let t=null;if(s["font-scale"]&&(t=n.parse(s["font-scale"],1,Br),!t))return null;let e=null;if(s["text-font"]&&(e=n.parse(s["text-font"],1,ei(Jr)),!e))return null;let o=null;if(s["text-color"]&&(o=n.parse(s["text-color"],1,Yr),!o))return null;const a=r[r.length-1];a.scale=t,a.font=e,a.textColor=o}else{const s=n.parse(t[e],1,Kr);if(!s)return null;const o=s.type.kind;if("string"!==o&&"value"!==o&&"null"!==o&&"resolvedImage"!==o)return n.error("Formatted text type must be \'string\', \'value\', \'image\' or \'null\'.");i=!0,r.push({content:s,scale:null,font:null,textColor:null})}}return new Ei(r)}evaluate(t){return new vi(this.sections.map(n=>{const e=n.content.evaluate(t);return xi(e)===ni?new gi("",e,null,null,null):new gi(Fi(e),null,n.scale?n.scale.evaluate(t):null,n.font?n.font.evaluate(t).join(","):null,n.textColor?n.textColor.evaluate(t):null)}))}eachChild(t){for(const n of this.sections)t(n.content),n.scale&&t(n.scale),n.font&&t(n.font),n.textColor&&t(n.textColor)}outputDefined(){return!1}serialize(){const t=["format"];for(const n of this.sections){t.push(n.content.serialize());const e={};n.scale&&(e["font-scale"]=n.scale.serialize()),n.font&&(e["text-font"]=n.font.serialize()),n.textColor&&(e["text-color"]=n.textColor.serialize()),t.push(e)}return t}}class Ii{constructor(t){this.type=ni,this.input=t}static parse(t,n){if(2!==t.length)return n.error("Expected two arguments.");const e=n.parse(t[1],1,Jr);return e?new Ii(e):n.error("No image name provided.")}evaluate(t){const n=this.input.evaluate(t),e=bi.fromString(n);return e&&t.availableImages&&(e.available=t.availableImages.indexOf(n)>-1),e}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const $i={"to-boolean":Xr,"to-color":Yr,"to-number":Br,"to-string":Jr};class Ci{constructor(t,n){this.type=t,this.args=n}static parse(t,n){if(t.length<2)return n.error("Expected at least one argument.");const e=t[0];if(("to-boolean"===e||"to-string"===e)&&2!==t.length)return n.error("Expected one argument.");const r=$i[e],i=[];for(let e=1;e<t.length;e++){const r=n.parse(t[e],e,Kr);if(!r)return null;i.push(r)}return new Ci(r,i)}evaluate(t){if("boolean"===this.type.kind)return Boolean(this.args[0].evaluate(t));if("color"===this.type.kind){let n,e;for(const r of this.args){if(n=r.evaluate(t),e=null,n instanceof yi)return n;if("string"==typeof n){const e=t.parseColor(n);if(e)return e}else if(Array.isArray(n)&&(e=n.length<3||n.length>4?`Invalid rbga value ${JSON.stringify(n)}: expected an array containing either three or four numeric values.`:wi(n[0],n[1],n[2],n[3]),!e))return new yi(n[0]/255,n[1]/255,n[2]/255,n[3])}throw new Pi(e||`Could not parse color from value \'${"string"==typeof n?n:String(JSON.stringify(n))}\'`)}if("number"===this.type.kind){let n=null;for(const e of this.args){if(n=e.evaluate(t),null===n)return 0;const r=Number(n);if(!isNaN(r))return r}throw new Pi(`Could not convert ${JSON.stringify(n)} to number.`)}return"formatted"===this.type.kind?vi.fromString(Fi(this.args[0].evaluate(t))):"resolvedImage"===this.type.kind?bi.fromString(Fi(this.args[0].evaluate(t))):Fi(this.args[0].evaluate(t))}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Ei([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Ii(this.args[0]).serialize();const t=["to-"+this.type.kind];return this.eachChild(n=>{t.push(n.serialize())}),t}}var Ti=Ci;const zi=["Unknown","Point","LineString","Polygon"];var Di=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this.L={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?zi[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const t=this.featureDistanceData.center,n=this.featureDistanceData.scale,{x:e,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(e*n-t[0])+this.featureDistanceData.bearing[1]*(r*n-t[1])}return 0}parseColor(t){let n=this.L[t];return n||(n=this.L[t]=yi.parse(t)),n}};class ji{constructor(t,n,e,r){this.name=t,this.type=n,this.V=e,this.args=r}evaluate(t){return this.V(t,this.args)}eachChild(t){this.args.forEach(t)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(t=>t.serialize()))}static parse(t,n){const e=t[0],r=ji.definitions[e];if(!r)return n.error(`Unknown expression "${e}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,s=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,o=s.filter(([n])=>!Array.isArray(n)||n.length===t.length-1);let a=null;for(const[r,s]of o){a=new hs(n.registry,n.path,null,n.scope);const o=[];let u=!1;for(let n=1;n<t.length;n++){const e=t[n],i=Array.isArray(r)?r[n-1]:r.type,s=a.parse(e,1+o.length,i);if(!s){u=!0;break}o.push(s)}if(!u)if(Array.isArray(r)&&r.length!==o.length)a.error(`Expected ${r.length} arguments, but found ${o.length} instead.`);else{for(let t=0;t<o.length;t++){const n=Array.isArray(r)?r[t]:r.type,e=o[t];a.concat(t+1).checkSubtype(n,e.type)}if(0===a.errors.length)return new ji(e,i,s,o)}}if(1===o.length)n.errors.push(...a.errors);else{const e=(o.length?o:s).map(([t])=>{return n=t,Array.isArray(n)?`(${n.map(ri).join(", ")})`:`(${ri(n.type)}...)`;var n}).join(" | "),r=[];for(let e=1;e<t.length;e++){const i=n.parse(t[e],1+r.length);if(!i)return null;r.push(ri(i.type))}n.error(`Expected arguments of type ${e}, but found (${r.join(", ")}) instead.`)}return null}static register(t,n){ji.definitions=n;for(const e in n)t[e]=ji}}var Ui=ji;class Ni{constructor(t,n,e){this.type=Qr,this.locale=e,this.caseSensitive=t,this.diacriticSensitive=n}static parse(t,n){if(2!==t.length)return n.error("Expected one argument.");const e=t[1];if("object"!=typeof e||Array.isArray(e))return n.error("Collator options argument must be an object.");const r=n.parse(void 0!==e["case-sensitive"]&&e["case-sensitive"],1,Xr);if(!r)return null;const i=n.parse(void 0!==e["diacritic-sensitive"]&&e["diacritic-sensitive"],1,Xr);if(!i)return null;let s=null;return e.locale&&(s=n.parse(e.locale,1,Jr),!s)?null:new Ni(r,i,s)}evaluate(t){return new mi(this.caseSensitive.evaluate(t),this.diacriticSensitive.evaluate(t),this.locale?this.locale.evaluate(t):null)}eachChild(t){t(this.caseSensitive),t(this.diacriticSensitive),this.locale&&t(this.locale)}outputDefined(){return!1}serialize(){const t={};return t["case-sensitive"]=this.caseSensitive.serialize(),t["diacritic-sensitive"]=this.diacriticSensitive.serialize(),this.locale&&(t.locale=this.locale.serialize()),["collator",t]}}function Li(t,n){t[0]=Math.min(t[0],n[0]),t[1]=Math.min(t[1],n[1]),t[2]=Math.max(t[2],n[0]),t[3]=Math.max(t[3],n[1])}function Vi(t,n){return!(t[0]<=n[0]||t[2]>=n[2]||t[1]<=n[1]||t[3]>=n[3])}function Ri(t,n){const e=(180+t[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+t[1]*Math.PI/360)))/360,i=Math.pow(2,n.z);return[Math.round(e*i*8192),Math.round(r*i*8192)]}function Hi(t,n,e){const r=t[0]-n[0],i=t[1]-n[1],s=t[0]-e[0],o=t[1]-e[1];return r*o-s*i==0&&r*s<=0&&i*o<=0}function Wi(t,n){let e=!1;for(let o=0,a=n.length;o<a;o++){const a=n[o];for(let n=0,o=a.length;n<o-1;n++){if(Hi(t,a[n],a[n+1]))return!1;(i=a[n])[1]>(r=t)[1]!=(s=a[n+1])[1]>r[1]&&r[0]<(s[0]-i[0])*(r[1]-i[1])/(s[1]-i[1])+i[0]&&(e=!e)}}var r,i,s;return e}function qi(t,n){for(let e=0;e<n.length;e++)if(Wi(t,n[e]))return!0;return!1}function Gi(t,n,e,r){const i=r[0]-e[0],s=r[1]-e[1],o=(t[0]-e[0])*s-i*(t[1]-e[1]),a=(n[0]-e[0])*s-i*(n[1]-e[1]);return o>0&&a<0||o<0&&a>0}function Bi(t,n,e){for(const h of e)for(let e=0;e<h.length-1;++e)if(void 0,void 0,0!=(a=[(o=h[e+1])[0]-(s=h[e])[0],o[1]-s[1]])[0]*(u=[(i=n)[0]-(r=t)[0],i[1]-r[1]])[1]-a[1]*u[0]&&Gi(r,i,s,o)&&Gi(s,o,r,i))return!0;var r,i,s,o,a,u;return!1}function Ji(t,n){for(let e=0;e<t.length;++e)if(!Wi(t[e],n))return!1;for(let e=0;e<t.length-1;++e)if(Bi(t[e],t[e+1],n))return!1;return!0}function Xi(t,n){for(let e=0;e<n.length;e++)if(Ji(t,n[e]))return!0;return!1}function Yi(t,n,e){const r=[];for(let i=0;i<t.length;i++){const s=[];for(let r=0;r<t[i].length;r++){const o=Ri(t[i][r],e);Li(n,o),s.push(o)}r.push(s)}return r}function Zi(t,n,e){const r=[];for(let i=0;i<t.length;i++){const s=Yi(t[i],n,e);r.push(s)}return r}function Ki(t,n,e,r){if(t[0]<e[0]||t[0]>e[2]){const n=.5*r;let i=t[0]-e[0]>n?-r:e[0]-t[0]>n?r:0;0===i&&(i=t[0]-e[2]>n?-r:e[2]-t[0]>n?r:0),t[0]+=i}Li(n,t)}function Qi(t,n,e,r){const i=8192*Math.pow(2,r.z),s=[8192*r.x,8192*r.y],o=[];if(!t)return o;for(const r of t)for(const t of r){const r=[t.x+s[0],t.y+s[1]];Ki(r,n,e,i),o.push(r)}return o}function ts(t,n,e,r){const i=8192*Math.pow(2,r.z),s=[8192*r.x,8192*r.y],o=[];if(!t)return o;for(const e of t){const t=[];for(const r of e){const e=[r.x+s[0],r.y+s[1]];Li(n,e),t.push(e)}o.push(t)}if(n[2]-n[0]<=i/2){(a=n)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const t of o)for(const r of t)Ki(r,n,e,i)}var a;return o}class ns{constructor(t,n){this.type=Xr,this.geojson=t,this.geometries=n}static parse(t,n){if(2!==t.length)return n.error(`\'within\' expression requires exactly one argument, but found ${t.length-1} instead.`);if(Mi(t[1])){const n=t[1];if("FeatureCollection"===n.type)for(let t=0;t<n.features.length;++t){const e=n.features[t].geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new ns(n,n.features[t].geometry)}else if("Feature"===n.type){const t=n.geometry.type;if("Polygon"===t||"MultiPolygon"===t)return new ns(n,n.geometry)}else if("Polygon"===n.type||"MultiPolygon"===n.type)return new ns(n,n)}return n.error("\'within\' expression requires valid geojson object that contains polygon geometry type.")}evaluate(t){if(null!=t.geometry()&&null!=t.canonicalID()){if("Point"===t.geometryType())return function(t,n){const e=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===n.type){const s=Yi(n.coordinates,r,i),o=Qi(t.geometry(),e,r,i);if(!Vi(e,r))return!1;for(const t of o)if(!Wi(t,s))return!1}if("MultiPolygon"===n.type){const s=Zi(n.coordinates,r,i),o=Qi(t.geometry(),e,r,i);if(!Vi(e,r))return!1;for(const t of o)if(!qi(t,s))return!1}return!0}(t,this.geometries);if("LineString"===t.geometryType())return function(t,n){const e=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],i=t.canonicalID();if(!i)return!1;if("Polygon"===n.type){const s=Yi(n.coordinates,r,i),o=ts(t.geometry(),e,r,i);if(!Vi(e,r))return!1;for(const t of o)if(!Ji(t,s))return!1}if("MultiPolygon"===n.type){const s=Zi(n.coordinates,r,i),o=ts(t.geometry(),e,r,i);if(!Vi(e,r))return!1;for(const t of o)if(!Xi(t,s))return!1}return!0}(t,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}serialize(){return["within",this.geojson]}}var es=ns;function rs(t){if(t instanceof Ui){if("get"===t.name&&1===t.args.length)return!1;if("feature-state"===t.name)return!1;if("has"===t.name&&1===t.args.length)return!1;if("properties"===t.name||"geometry-type"===t.name||"id"===t.name)return!1;if(/^filter-/.test(t.name))return!1}if(t instanceof es)return!1;let n=!0;return t.eachChild(t=>{n&&!rs(t)&&(n=!1)}),n}function is(t){if(t instanceof Ui&&"feature-state"===t.name)return!1;let n=!0;return t.eachChild(t=>{n&&!is(t)&&(n=!1)}),n}function ss(t,n){if(t instanceof Ui&&n.indexOf(t.name)>=0)return!1;let e=!0;return t.eachChild(t=>{e&&!ss(t,n)&&(e=!1)}),e}class os{constructor(t,n){this.type=n.type,this.name=t,this.boundExpression=n}static parse(t,n){if(2!==t.length||"string"!=typeof t[1])return n.error("\'var\' expression requires exactly one string literal argument.");const e=t[1];return n.scope.has(e)?new os(e,n.scope.get(e)):n.error(`Unknown variable "${e}". Make sure "${e}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(t){return this.boundExpression.evaluate(t)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var as=os;class us{constructor(t,n=[],e,r=new qr,i=[]){this.registry=t,this.path=n,this.key=n.map(t=>`[${t}]`).join(""),this.scope=r,this.errors=i,this.expectedType=e}parse(t,n,e,r,i={}){return n?this.concat(n,e,r).R(t,i):this.R(t,i)}R(t,n){function e(t,n,e){return"assert"===e?new Oi(n,[t]):"coerce"===e?new Ti(n,[t]):t}if(null!==t&&"string"!=typeof t&&"boolean"!=typeof t&&"number"!=typeof t||(t=["literal",t]),Array.isArray(t)){if(0===t.length)return this.error(\'Expected an array with at least one element. If you wanted a literal array, use ["literal", []].\');const r=t[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[r];if(i){let r=i.parse(t,this);if(!r)return null;if(this.expectedType){const t=this.expectedType,i=r.type;if("string"!==t.kind&&"number"!==t.kind&&"boolean"!==t.kind&&"object"!==t.kind&&"array"!==t.kind||"value"!==i.kind)if("color"!==t.kind&&"formatted"!==t.kind&&"resolvedImage"!==t.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(t,i))return null}else r=e(r,t,n.typeAnnotation||"coerce");else r=e(r,t,n.typeAnnotation||"assert")}if(!(r instanceof ki)&&"resolvedImage"!==r.type.kind&&function t(n){if(n instanceof as)return t(n.boundExpression);if(n instanceof Ui&&"error"===n.name)return!1;if(n instanceof Ni)return!1;if(n instanceof es)return!1;const e=n instanceof Ti||n instanceof Oi;let r=!0;return n.eachChild(n=>{r=e?r&&t(n):r&&n instanceof ki}),!!r&&(rs(n)&&ss(n,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"]))}(r)){const n=new Di;try{r=new ki(r.type,r.evaluate(n))}catch(t){return this.error(t.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===t?"\'undefined\' value invalid. Use null instead.":"object"==typeof t?\'Bare objects invalid. Use ["literal", {...}] instead.\':`Expected an array, but found ${typeof t} instead.`)}concat(t,n,e){const r="number"==typeof t?this.path.concat(t):this.path,i=e?this.scope.concat(e):this.scope;return new us(this.registry,r,n||null,i,this.errors)}error(t,...n){const e=`${this.key}${n.map(t=>`[${t}]`).join("")}`;this.errors.push(new Hr(e,t))}checkSubtype(t,n){const e=si(t,n);return e&&this.error(e),e}}var hs=us;function ls(t,n){const e=t.length-1;let r,i,s=0,o=e,a=0;for(;s<=o;)if(a=Math.floor((s+o)/2),r=t[a],i=t[a+1],r<=n){if(a===e||n<i)return a;s=a+1}else{if(!(r>n))throw new Pi("Input is not a number.");o=a-1}return 0}class cs{constructor(t,n,e){this.type=t,this.input=n,this.labels=[],this.outputs=[];for(const[t,n]of e)this.labels.push(t),this.outputs.push(n)}static parse(t,n){if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error("Expected an even number of arguments.");const e=n.parse(t[1],1,Br);if(!e)return null;const r=[];let i=null;n.expectedType&&"value"!==n.expectedType.kind&&(i=n.expectedType);for(let e=1;e<t.length;e+=2){const s=1===e?-1/0:t[e],o=t[e+1],a=e,u=e+1;if("number"!=typeof s)return n.error(\'Input/output pairs for "step" expressions must be defined using literal numeric values (not computed expressions) for the input values.\',a);if(r.length&&r[r.length-1][0]>=s)return n.error(\'Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.\',a);const h=n.parse(o,u,i);if(!h)return null;i=i||h.type,r.push([s,h])}return new cs(i,e,r)}evaluate(t){const n=this.labels,e=this.outputs;if(1===n.length)return e[0].evaluate(t);const r=this.input.evaluate(t);if(r<=n[0])return e[0].evaluate(t);const i=n.length;return r>=n[i-1]?e[i-1].evaluate(t):e[ls(n,r)].evaluate(t)}eachChild(t){t(this.input);for(const n of this.outputs)t(n)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){const t=["step",this.input.serialize()];for(let n=0;n<this.labels.length;n++)n>0&&t.push(this.labels[n]),t.push(this.outputs[n].serialize());return t}}var fs=cs,ds=ps;function ps(t,n,e,r){this.cx=3*t,this.bx=3*(e-t)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*n,this.by=3*(r-n)-this.cy,this.ay=1-this.cy-this.by,this.p1x=t,this.p1y=n,this.p2x=e,this.p2y=r}function ys(t,n,e){return t*(1-e)+n*e}ps.prototype={sampleCurveX:function(t){return((this.ax*t+this.bx)*t+this.cx)*t},sampleCurveY:function(t){return((this.ay*t+this.by)*t+this.cy)*t},sampleCurveDerivativeX:function(t){return(3*this.ax*t+2*this.bx)*t+this.cx},solveCurveX:function(t,n){if(void 0===n&&(n=1e-6),t<0)return 0;if(t>1)return 1;for(var e=t,r=0;r<8;r++){var i=this.sampleCurveX(e)-t;if(Math.abs(i)<n)return e;var s=this.sampleCurveDerivativeX(e);if(Math.abs(s)<1e-6)break;e-=i/s}var o=0,a=1;for(e=t,r=0;r<20&&(i=this.sampleCurveX(e),!(Math.abs(i-t)<n));r++)t>i?o=e:a=e,e=.5*(a-o)+o;return e},solve:function(t,n){return this.sampleCurveY(this.solveCurveX(t,n))}};var ms=Object.freeze({__proto__:null,number:ys,color:function(t,n,e){return new yi(ys(t.r,n.r,e),ys(t.g,n.g,e),ys(t.b,n.b,e),ys(t.a,n.a,e))},array:function(t,n,e){return t.map((t,r)=>ys(t,n[r],e))}});const gs=6/29*3*(6/29),vs=Math.PI/180,bs=180/Math.PI;function ws(t){return t>.008856451679035631?Math.pow(t,1/3):t/gs+4/29}function Ms(t){return t>6/29?t*t*t:gs*(t-4/29)}function xs(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Fs(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function As(t){const n=Fs(t.r),e=Fs(t.g),r=Fs(t.b),i=ws((.4124564*n+.3575761*e+.1804375*r)/.95047),s=ws((.2126729*n+.7151522*e+.072175*r)/1);return{l:116*s-16,a:500*(i-s),b:200*(s-ws((.0193339*n+.119192*e+.9503041*r)/1.08883)),alpha:t.a}}function ks(t){let n=(t.l+16)/116,e=isNaN(t.a)?n:n+t.a/500,r=isNaN(t.b)?n:n-t.b/200;return n=1*Ms(n),e=.95047*Ms(e),r=1.08883*Ms(r),new yi(xs(3.2404542*e-1.5371385*n-.4985314*r),xs(-.969266*e+1.8760108*n+.041556*r),xs(.0556434*e-.2040259*n+1.0572252*r),t.alpha)}function Ps(t,n,e){const r=n-t;return t+e*(r>180||r<-180?r-360*Math.round(r/360):r)}const Ss={forward:As,reverse:ks,interpolate:function(t,n,e){return{l:ys(t.l,n.l,e),a:ys(t.a,n.a,e),b:ys(t.b,n.b,e),alpha:ys(t.alpha,n.alpha,e)}}},_s={forward:function(t){const{l:n,a:e,b:r}=As(t),i=Math.atan2(r,e)*bs;return{h:i<0?i+360:i,c:Math.sqrt(e*e+r*r),l:n,alpha:t.a}},reverse:function(t){const n=t.h*vs,e=t.c;return ks({l:t.l,a:Math.cos(n)*e,b:Math.sin(n)*e,alpha:t.alpha})},interpolate:function(t,n,e){return{h:Ps(t.h,n.h,e),c:ys(t.c,n.c,e),l:ys(t.l,n.l,e),alpha:ys(t.alpha,n.alpha,e)}}};var Os=Object.freeze({__proto__:null,lab:Ss,hcl:_s});class Es{constructor(t,n,e,r,i){this.type=t,this.operator=n,this.interpolation=e,this.input=r,this.labels=[],this.outputs=[];for(const[t,n]of i)this.labels.push(t),this.outputs.push(n)}static interpolationFactor(t,n,e,r){let i=0;if("exponential"===t.name)i=Is(n,t.base,e,r);else if("linear"===t.name)i=Is(n,1,e,r);else if("cubic-bezier"===t.name){const s=t.controlPoints;i=new ds(s[0],s[1],s[2],s[3]).solve(Is(n,1,e,r))}return i}static parse(t,n){let[e,r,i,...s]=t;if(!Array.isArray(r)||0===r.length)return n.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const t=r[1];if("number"!=typeof t)return n.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:t}}else{if("cubic-bezier"!==r[0])return n.error("Unknown interpolation type "+String(r[0]),1,0);{const t=r.slice(1);if(4!==t.length||t.some(t=>"number"!=typeof t||t<0||t>1))return n.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:t}}}if(t.length-1<4)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if((t.length-1)%2!=0)return n.error("Expected an even number of arguments.");if(i=n.parse(i,2,Br),!i)return null;const o=[];let a=null;"interpolate-hcl"===e||"interpolate-lab"===e?a=Yr:n.expectedType&&"value"!==n.expectedType.kind&&(a=n.expectedType);for(let t=0;t<s.length;t+=2){const e=s[t],r=s[t+1],i=t+3,u=t+4;if("number"!=typeof e)return n.error(\'Input/output pairs for "interpolate" expressions must be defined using literal numeric values (not computed expressions) for the input values.\',i);if(o.length&&o[o.length-1][0]>=e)return n.error(\'Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.\',i);const h=n.parse(r,u,a);if(!h)return null;a=a||h.type,o.push([e,h])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Es(a,e,r,i,o):n.error(`Type ${ri(a)} is not interpolatable.`)}evaluate(t){const n=this.labels,e=this.outputs;if(1===n.length)return e[0].evaluate(t);const r=this.input.evaluate(t);if(r<=n[0])return e[0].evaluate(t);const i=n.length;if(r>=n[i-1])return e[i-1].evaluate(t);const s=ls(n,r),o=Es.interpolationFactor(this.interpolation,r,n[s],n[s+1]),a=e[s].evaluate(t),u=e[s+1].evaluate(t);return"interpolate"===this.operator?ms[this.type.kind.toLowerCase()](a,u,o):"interpolate-hcl"===this.operator?_s.reverse(_s.interpolate(_s.forward(a),_s.forward(u),o)):Ss.reverse(Ss.interpolate(Ss.forward(a),Ss.forward(u),o))}eachChild(t){t(this.input);for(const n of this.outputs)t(n)}outputDefined(){return this.outputs.every(t=>t.outputDefined())}serialize(){let t;t="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const n=[this.operator,t,this.input.serialize()];for(let t=0;t<this.labels.length;t++)n.push(this.labels[t],this.outputs[t].serialize());return n}}function Is(t,n,e,r){const i=r-e,s=t-e;return 0===i?0:1===n?s/i:(Math.pow(n,s)-1)/(Math.pow(n,i)-1)}var $s=Es;class Cs{constructor(t,n){this.type=t,this.args=n}static parse(t,n){if(t.length<2)return n.error("Expectected at least one argument.");let e=null;const r=n.expectedType;r&&"value"!==r.kind&&(e=r);const i=[];for(const r of t.slice(1)){const t=n.parse(r,1+i.length,e,void 0,{typeAnnotation:"omit"});if(!t)return null;e=e||t.type,i.push(t)}const s=r&&i.some(t=>si(r,t.type));return new Cs(s?Kr:e,i)}evaluate(t){let n,e=null,r=0;for(const i of this.args){if(r++,e=i.evaluate(t),e&&e instanceof bi&&!e.available&&(n||(n=e),e=null,r===this.args.length))return n;if(null!==e)break}return e}eachChild(t){this.args.forEach(t)}outputDefined(){return this.args.every(t=>t.outputDefined())}serialize(){const t=["coalesce"];return this.eachChild(n=>{t.push(n.serialize())}),t}}var Ts=Cs;class zs{constructor(t,n){this.type=n.type,this.bindings=[].concat(t),this.result=n}evaluate(t){return this.result.evaluate(t)}eachChild(t){for(const n of this.bindings)t(n[1]);t(this.result)}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found ${t.length-1} instead.`);const e=[];for(let r=1;r<t.length-1;r+=2){const i=t[r];if("string"!=typeof i)return n.error(`Expected string, but found ${typeof i} instead.`,r);if(/[^a-zA-Z0-9_]/.test(i))return n.error("Variable names must contain only alphanumeric characters or \'_\'.",r);const s=n.parse(t[r+1],r+1);if(!s)return null;e.push([i,s])}const r=n.parse(t[t.length-1],t.length-1,n.expectedType,e);return r?new zs(e,r):null}outputDefined(){return this.result.outputDefined()}serialize(){const t=["let"];for(const[n,e]of this.bindings)t.push(n,e.serialize());return t.push(this.result.serialize()),t}}var Ds=zs;class js{constructor(t,n,e){this.type=t,this.index=n,this.input=e}static parse(t,n){if(3!==t.length)return n.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const e=n.parse(t[1],1,Br),r=n.parse(t[2],2,ei(n.expectedType||Kr));return e&&r?new js(r.type.itemType,e,r):null}evaluate(t){const n=this.index.evaluate(t),e=this.input.evaluate(t);if(n<0)throw new Pi(`Array index out of bounds: ${n} < 0.`);if(n>=e.length)throw new Pi(`Array index out of bounds: ${n} > ${e.length-1}.`);if(n!==Math.floor(n))throw new Pi(`Array index must be an integer, but found ${n} instead.`);return e[n]}eachChild(t){t(this.index),t(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Us=js;class Ns{constructor(t,n){this.type=Xr,this.needle=t,this.haystack=n}static parse(t,n){if(3!==t.length)return n.error(`Expected 2 arguments, but found ${t.length-1} instead.`);const e=n.parse(t[1],1,Kr),r=n.parse(t[2],2,Kr);return e&&r?oi(e.type,[Xr,Jr,Br,Gr,Kr])?new Ns(e,r):n.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(e.type)} instead`):null}evaluate(t){const n=this.needle.evaluate(t),e=this.haystack.evaluate(t);if(null==e)return!1;if(!ai(n,["boolean","string","number","null"]))throw new Pi(`Expected first argument to be of type boolean, string, number or null, but found ${ri(xi(n))} instead.`);if(!ai(e,["string","array"]))throw new Pi(`Expected second argument to be of type array or string, but found ${ri(xi(e))} instead.`);return e.indexOf(n)>=0}eachChild(t){t(this.needle),t(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Ls=Ns;class Vs{constructor(t,n,e){this.type=Br,this.needle=t,this.haystack=n,this.fromIndex=e}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const e=n.parse(t[1],1,Kr),r=n.parse(t[2],2,Kr);if(!e||!r)return null;if(!oi(e.type,[Xr,Jr,Br,Gr,Kr]))return n.error(`Expected first argument to be of type boolean, string, number or null, but found ${ri(e.type)} instead`);if(4===t.length){const i=n.parse(t[3],3,Br);return i?new Vs(e,r,i):null}return new Vs(e,r)}evaluate(t){const n=this.needle.evaluate(t),e=this.haystack.evaluate(t);if(!ai(n,["boolean","string","number","null"]))throw new Pi(`Expected first argument to be of type boolean, string, number or null, but found ${ri(xi(n))} instead.`);if(!ai(e,["string","array"]))throw new Pi(`Expected second argument to be of type array or string, but found ${ri(xi(e))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(t);return e.indexOf(n,r)}return e.indexOf(n)}eachChild(t){t(this.needle),t(this.haystack),this.fromIndex&&t(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const t=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),t]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var Rs=Vs;class Hs{constructor(t,n,e,r,i,s){this.inputType=t,this.type=n,this.input=e,this.cases=r,this.outputs=i,this.otherwise=s}static parse(t,n){if(t.length<5)return n.error(`Expected at least 4 arguments, but found only ${t.length-1}.`);if(t.length%2!=1)return n.error("Expected an even number of arguments.");let e,r;n.expectedType&&"value"!==n.expectedType.kind&&(r=n.expectedType);const i={},s=[];for(let o=2;o<t.length-1;o+=2){let a=t[o];const u=t[o+1];Array.isArray(a)||(a=[a]);const h=n.concat(o);if(0===a.length)return h.error("Expected at least one branch label.");for(const t of a){if("number"!=typeof t&&"string"!=typeof t)return h.error("Branch labels must be numbers or strings.");if("number"==typeof t&&Math.abs(t)>Number.MAX_SAFE_INTEGER)return h.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof t&&Math.floor(t)!==t)return h.error("Numeric branch labels must be integer values.");if(e){if(h.checkSubtype(e,xi(t)))return null}else e=xi(t);if(void 0!==i[String(t)])return h.error("Branch labels must be unique.");i[String(t)]=s.length}const l=n.parse(u,o,r);if(!l)return null;r=r||l.type,s.push(l)}const o=n.parse(t[1],1,Kr);if(!o)return null;const a=n.parse(t[t.length-1],t.length-1,r);return a?"value"!==o.type.kind&&n.concat(1).checkSubtype(e,o.type)?null:new Hs(e,r,o,i,s,a):null}evaluate(t){const n=this.input.evaluate(t);return(xi(n)===this.inputType&&this.outputs[this.cases[n]]||this.otherwise).evaluate(t)}eachChild(t){t(this.input),this.outputs.forEach(t),t(this.otherwise)}outputDefined(){return this.outputs.every(t=>t.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["match",this.input.serialize()],n=Object.keys(this.cases).sort(),e=[],r={};for(const t of n){const n=r[this.cases[t]];void 0===n?(r[this.cases[t]]=e.length,e.push([this.cases[t],[t]])):e[n][1].push(t)}const i=t=>"number"===this.inputType.kind?Number(t):t;for(const[n,r]of e)t.push(1===r.length?i(r[0]):r.map(i)),t.push(this.outputs[n].serialize());return t.push(this.otherwise.serialize()),t}}var Ws=Hs;class qs{constructor(t,n,e){this.type=t,this.branches=n,this.otherwise=e}static parse(t,n){if(t.length<4)return n.error(`Expected at least 3 arguments, but found only ${t.length-1}.`);if(t.length%2!=0)return n.error("Expected an odd number of arguments.");let e;n.expectedType&&"value"!==n.expectedType.kind&&(e=n.expectedType);const r=[];for(let i=1;i<t.length-1;i+=2){const s=n.parse(t[i],i,Xr);if(!s)return null;const o=n.parse(t[i+1],i+1,e);if(!o)return null;r.push([s,o]),e=e||o.type}const i=n.parse(t[t.length-1],t.length-1,e);return i?new qs(e,r,i):null}evaluate(t){for(const[n,e]of this.branches)if(n.evaluate(t))return e.evaluate(t);return this.otherwise.evaluate(t)}eachChild(t){for(const[n,e]of this.branches)t(n),t(e);t(this.otherwise)}outputDefined(){return this.branches.every(([t,n])=>n.outputDefined())&&this.otherwise.outputDefined()}serialize(){const t=["case"];return this.eachChild(n=>{t.push(n.serialize())}),t}}var Gs=qs;class Bs{constructor(t,n,e,r){this.type=t,this.input=n,this.beginIndex=e,this.endIndex=r}static parse(t,n){if(t.length<=2||t.length>=5)return n.error(`Expected 3 or 4 arguments, but found ${t.length-1} instead.`);const e=n.parse(t[1],1,Kr),r=n.parse(t[2],2,Br);if(!e||!r)return null;if(!oi(e.type,[ei(Kr),Jr,Kr]))return n.error(`Expected first argument to be of type array or string, but found ${ri(e.type)} instead`);if(4===t.length){const i=n.parse(t[3],3,Br);return i?new Bs(e.type,e,r,i):null}return new Bs(e.type,e,r)}evaluate(t){const n=this.input.evaluate(t),e=this.beginIndex.evaluate(t);if(!ai(n,["string","array"]))throw new Pi(`Expected first argument to be of type array or string, but found ${ri(xi(n))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(t);return n.slice(e,r)}return n.slice(e)}eachChild(t){t(this.input),t(this.beginIndex),this.endIndex&&t(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const t=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),t]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var Js=Bs;function Xs(t,n){return"=="===t||"!="===t?"boolean"===n.kind||"string"===n.kind||"number"===n.kind||"null"===n.kind||"value"===n.kind:"string"===n.kind||"number"===n.kind||"value"===n.kind}function Ys(t,n,e,r){return 0===r.compare(n,e)}function Zs(t,n,e){const r="=="!==t&&"!="!==t;return class i{constructor(t,n,e){this.type=Xr,this.lhs=t,this.rhs=n,this.collator=e,this.hasUntypedArgument="value"===t.type.kind||"value"===n.type.kind}static parse(t,n){if(3!==t.length&&4!==t.length)return n.error("Expected two or three arguments.");const e=t[0];let s=n.parse(t[1],1,Kr);if(!s)return null;if(!Xs(e,s.type))return n.concat(1).error(`"${e}" comparisons are not supported for type \'${ri(s.type)}\'.`);let o=n.parse(t[2],2,Kr);if(!o)return null;if(!Xs(e,o.type))return n.concat(2).error(`"${e}" comparisons are not supported for type \'${ri(o.type)}\'.`);if(s.type.kind!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return n.error(`Cannot compare types \'${ri(s.type)}\' and \'${ri(o.type)}\'.`);r&&("value"===s.type.kind&&"value"!==o.type.kind?s=new Oi(o.type,[s]):"value"!==s.type.kind&&"value"===o.type.kind&&(o=new Oi(s.type,[o])));let a=null;if(4===t.length){if("string"!==s.type.kind&&"string"!==o.type.kind&&"value"!==s.type.kind&&"value"!==o.type.kind)return n.error("Cannot use collator to compare non-string types.");if(a=n.parse(t[3],3,Qr),!a)return null}return new i(s,o,a)}evaluate(i){const s=this.lhs.evaluate(i),o=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const n=xi(s),e=xi(o);if(n.kind!==e.kind||"string"!==n.kind&&"number"!==n.kind)throw new Pi(`Expected arguments for "${t}" to be (string, string) or (number, number), but found (${n.kind}, ${e.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const t=xi(s),e=xi(o);if("string"!==t.kind||"string"!==e.kind)return n(i,s,o)}return this.collator?e(i,s,o,this.collator.evaluate(i)):n(i,s,o)}eachChild(t){t(this.lhs),t(this.rhs),this.collator&&t(this.collator)}outputDefined(){return!0}serialize(){const n=[t];return this.eachChild(t=>{n.push(t.serialize())}),n}}}const Ks=Zs("==",(function(t,n,e){return n===e}),Ys),Qs=Zs("!=",(function(t,n,e){return n!==e}),(function(t,n,e,r){return!Ys(0,n,e,r)})),to=Zs("<",(function(t,n,e){return n<e}),(function(t,n,e,r){return r.compare(n,e)<0})),no=Zs(">",(function(t,n,e){return n>e}),(function(t,n,e,r){return r.compare(n,e)>0})),eo=Zs("<=",(function(t,n,e){return n<=e}),(function(t,n,e,r){return r.compare(n,e)<=0})),ro=Zs(">=",(function(t,n,e){return n>=e}),(function(t,n,e,r){return r.compare(n,e)>=0}));class io{constructor(t,n,e,r,i,s){this.type=Jr,this.number=t,this.locale=n,this.currency=e,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=s}static parse(t,n){if(3!==t.length)return n.error("Expected two arguments.");const e=n.parse(t[1],1,Br);if(!e)return null;const r=t[2];if("object"!=typeof r||Array.isArray(r))return n.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=n.parse(r.locale,1,Jr),!i))return null;let s=null;if(r.currency&&(s=n.parse(r.currency,1,Jr),!s))return null;let o=null;if(r.unit&&(o=n.parse(r.unit,1,Jr),!o))return null;let a=null;if(r["min-fraction-digits"]&&(a=n.parse(r["min-fraction-digits"],1,Br),!a))return null;let u=null;return r["max-fraction-digits"]&&(u=n.parse(r["max-fraction-digits"],1,Br),!u)?null:new io(e,i,s,o,a,u)}evaluate(t){return new Intl.NumberFormat(this.locale?this.locale.evaluate(t):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(t):void 0,unit:this.unit?this.unit.evaluate(t):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(t):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(t):void 0}).format(this.number.evaluate(t))}eachChild(t){t(this.number),this.locale&&t(this.locale),this.currency&&t(this.currency),this.unit&&t(this.unit),this.minFractionDigits&&t(this.minFractionDigits),this.maxFractionDigits&&t(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const t={};return this.locale&&(t.locale=this.locale.serialize()),this.currency&&(t.currency=this.currency.serialize()),this.unit&&(t.unit=this.unit.serialize()),this.minFractionDigits&&(t["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(t["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),t]}}class so{constructor(t){this.type=Br,this.input=t}static parse(t,n){if(2!==t.length)return n.error(`Expected 1 argument, but found ${t.length-1} instead.`);const e=n.parse(t[1],1);return e?"array"!==e.type.kind&&"string"!==e.type.kind&&"value"!==e.type.kind?n.error(`Expected argument of type string or array, but found ${ri(e.type)} instead.`):new so(e):null}evaluate(t){const n=this.input.evaluate(t);if("string"==typeof n)return n.length;if(Array.isArray(n))return n.length;throw new Pi(`Expected value to be of type string or array, but found ${ri(xi(n))} instead.`)}eachChild(t){t(this.input)}outputDefined(){return!1}serialize(){const t=["length"];return this.eachChild(n=>{t.push(n.serialize())}),t}}const oo={"==":Ks,"!=":Qs,">":no,"<":to,">=":ro,"<=":eo,array:Oi,at:Us,boolean:Oi,case:Gs,coalesce:Ts,collator:Ni,format:Ei,image:Ii,in:Ls,"index-of":Rs,interpolate:$s,"interpolate-hcl":$s,"interpolate-lab":$s,length:so,let:Ds,literal:ki,match:Ws,number:Oi,"number-format":io,object:Oi,slice:Js,step:fs,string:Oi,"to-boolean":Ti,"to-color":Ti,"to-number":Ti,"to-string":Ti,var:as,within:es};function ao(t,[n,e,r,i]){n=n.evaluate(t),e=e.evaluate(t),r=r.evaluate(t);const s=i?i.evaluate(t):1,o=wi(n,e,r,s);if(o)throw new Pi(o);return new yi(n/255*s,e/255*s,r/255*s,s)}function uo(t,n){return t in n}function ho(t,n){const e=n[t];return void 0===e?null:e}function lo(t){return{type:t}}Ui.register(oo,{error:[{kind:"error"},[Jr],(t,[n])=>{throw new Pi(n.evaluate(t))}],typeof:[Jr,[Kr],(t,[n])=>ri(xi(n.evaluate(t)))],"to-rgba":[ei(Br,4),[Yr],(t,[n])=>n.evaluate(t).toArray()],rgb:[Yr,[Br,Br,Br],ao],rgba:[Yr,[Br,Br,Br,Br],ao],has:{type:Xr,overloads:[[[Jr],(t,[n])=>uo(n.evaluate(t),t.properties())],[[Jr,Zr],(t,[n,e])=>uo(n.evaluate(t),e.evaluate(t))]]},get:{type:Kr,overloads:[[[Jr],(t,[n])=>ho(n.evaluate(t),t.properties())],[[Jr,Zr],(t,[n,e])=>ho(n.evaluate(t),e.evaluate(t))]]},"feature-state":[Kr,[Jr],(t,[n])=>ho(n.evaluate(t),t.featureState||{})],properties:[Zr,[],t=>t.properties()],"geometry-type":[Jr,[],t=>t.geometryType()],id:[Kr,[],t=>t.id()],zoom:[Br,[],t=>t.globals.zoom],pitch:[Br,[],t=>t.globals.pitch||0],"distance-from-center":[Br,[],t=>t.distanceFromCenter()],"heatmap-density":[Br,[],t=>t.globals.heatmapDensity||0],"line-progress":[Br,[],t=>t.globals.lineProgress||0],"sky-radial-progress":[Br,[],t=>t.globals.skyRadialProgress||0],accumulated:[Kr,[],t=>void 0===t.globals.accumulated?null:t.globals.accumulated],"+":[Br,lo(Br),(t,n)=>{let e=0;for(const r of n)e+=r.evaluate(t);return e}],"*":[Br,lo(Br),(t,n)=>{let e=1;for(const r of n)e*=r.evaluate(t);return e}],"-":{type:Br,overloads:[[[Br,Br],(t,[n,e])=>n.evaluate(t)-e.evaluate(t)],[[Br],(t,[n])=>-n.evaluate(t)]]},"/":[Br,[Br,Br],(t,[n,e])=>n.evaluate(t)/e.evaluate(t)],"%":[Br,[Br,Br],(t,[n,e])=>n.evaluate(t)%e.evaluate(t)],ln2:[Br,[],()=>Math.LN2],pi:[Br,[],()=>Math.PI],e:[Br,[],()=>Math.E],"^":[Br,[Br,Br],(t,[n,e])=>Math.pow(n.evaluate(t),e.evaluate(t))],sqrt:[Br,[Br],(t,[n])=>Math.sqrt(n.evaluate(t))],log10:[Br,[Br],(t,[n])=>Math.log(n.evaluate(t))/Math.LN10],ln:[Br,[Br],(t,[n])=>Math.log(n.evaluate(t))],log2:[Br,[Br],(t,[n])=>Math.log(n.evaluate(t))/Math.LN2],sin:[Br,[Br],(t,[n])=>Math.sin(n.evaluate(t))],cos:[Br,[Br],(t,[n])=>Math.cos(n.evaluate(t))],tan:[Br,[Br],(t,[n])=>Math.tan(n.evaluate(t))],asin:[Br,[Br],(t,[n])=>Math.asin(n.evaluate(t))],acos:[Br,[Br],(t,[n])=>Math.acos(n.evaluate(t))],atan:[Br,[Br],(t,[n])=>Math.atan(n.evaluate(t))],min:[Br,lo(Br),(t,n)=>Math.min(...n.map(n=>n.evaluate(t)))],max:[Br,lo(Br),(t,n)=>Math.max(...n.map(n=>n.evaluate(t)))],abs:[Br,[Br],(t,[n])=>Math.abs(n.evaluate(t))],round:[Br,[Br],(t,[n])=>{const e=n.evaluate(t);return e<0?-Math.round(-e):Math.round(e)}],floor:[Br,[Br],(t,[n])=>Math.floor(n.evaluate(t))],ceil:[Br,[Br],(t,[n])=>Math.ceil(n.evaluate(t))],"filter-==":[Xr,[Jr,Kr],(t,[n,e])=>t.properties()[n.value]===e.value],"filter-id-==":[Xr,[Kr],(t,[n])=>t.id()===n.value],"filter-type-==":[Xr,[Jr],(t,[n])=>t.geometryType()===n.value],"filter-<":[Xr,[Jr,Kr],(t,[n,e])=>{const r=t.properties()[n.value],i=e.value;return typeof r==typeof i&&r<i}],"filter-id-<":[Xr,[Kr],(t,[n])=>{const e=t.id(),r=n.value;return typeof e==typeof r&&e<r}],"filter->":[Xr,[Jr,Kr],(t,[n,e])=>{const r=t.properties()[n.value],i=e.value;return typeof r==typeof i&&r>i}],"filter-id->":[Xr,[Kr],(t,[n])=>{const e=t.id(),r=n.value;return typeof e==typeof r&&e>r}],"filter-<=":[Xr,[Jr,Kr],(t,[n,e])=>{const r=t.properties()[n.value],i=e.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[Xr,[Kr],(t,[n])=>{const e=t.id(),r=n.value;return typeof e==typeof r&&e<=r}],"filter->=":[Xr,[Jr,Kr],(t,[n,e])=>{const r=t.properties()[n.value],i=e.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[Xr,[Kr],(t,[n])=>{const e=t.id(),r=n.value;return typeof e==typeof r&&e>=r}],"filter-has":[Xr,[Kr],(t,[n])=>n.value in t.properties()],"filter-has-id":[Xr,[],t=>null!==t.id()&&void 0!==t.id()],"filter-type-in":[Xr,[ei(Jr)],(t,[n])=>n.value.indexOf(t.geometryType())>=0],"filter-id-in":[Xr,[ei(Kr)],(t,[n])=>n.value.indexOf(t.id())>=0],"filter-in-small":[Xr,[Jr,ei(Kr)],(t,[n,e])=>e.value.indexOf(t.properties()[n.value])>=0],"filter-in-large":[Xr,[Jr,ei(Kr)],(t,[n,e])=>function(t,n,e,r){for(;e<=r;){const i=e+r>>1;if(n[i]===t)return!0;n[i]>t?r=i-1:e=i+1}return!1}(t.properties()[n.value],e.value,0,e.value.length-1)],all:{type:Xr,overloads:[[[Xr,Xr],(t,[n,e])=>n.evaluate(t)&&e.evaluate(t)],[lo(Xr),(t,n)=>{for(const e of n)if(!e.evaluate(t))return!1;return!0}]]},any:{type:Xr,overloads:[[[Xr,Xr],(t,[n,e])=>n.evaluate(t)||e.evaluate(t)],[lo(Xr),(t,n)=>{for(const e of n)if(e.evaluate(t))return!0;return!1}]]},"!":[Xr,[Xr],(t,[n])=>!n.evaluate(t)],"is-supported-script":[Xr,[Jr],(t,[n])=>{const e=t.globals&&t.globals.isSupportedScript;return!e||e(n.evaluate(t))}],upcase:[Jr,[Jr],(t,[n])=>n.evaluate(t).toUpperCase()],downcase:[Jr,[Jr],(t,[n])=>n.evaluate(t).toLowerCase()],concat:[Jr,lo(Kr),(t,n)=>n.map(n=>Fi(n.evaluate(t))).join("")],"resolved-locale":[Jr,[Qr],(t,[n])=>n.evaluate(t).resolvedLocale()]});var co=oo;function fo(t){return{result:"success",value:t}}function po(t){return{result:"error",value:t}}function yo(t){return!!t.expression&&t.expression.interpolated}function mo(t){return t instanceof Number?"number":t instanceof String?"string":t instanceof Boolean?"boolean":Array.isArray(t)?"array":null===t?"null":typeof t}function go(t){return"object"==typeof t&&null!==t&&!Array.isArray(t)}function vo(t){return t}function bo(t,n,e){return void 0!==t?t:void 0!==n?n:void 0!==e?e:void 0}function wo(t,n,e,r,i){return bo(typeof e===i?r[e]:void 0,t.default,n.default)}function Mo(t,n,e){if("number"!==mo(e))return bo(t.default,n.default);const r=t.stops.length;if(1===r)return t.stops[0][1];if(e<=t.stops[0][0])return t.stops[0][1];if(e>=t.stops[r-1][0])return t.stops[r-1][1];const i=ls(t.stops.map(t=>t[0]),e);return t.stops[i][1]}function xo(t,n,e){const r=void 0!==t.base?t.base:1;if("number"!==mo(e))return bo(t.default,n.default);const i=t.stops.length;if(1===i)return t.stops[0][1];if(e<=t.stops[0][0])return t.stops[0][1];if(e>=t.stops[i-1][0])return t.stops[i-1][1];const s=ls(t.stops.map(t=>t[0]),e),o=function(t,n,e,r){const i=r-e,s=t-e;return 0===i?0:1===n?s/i:(Math.pow(n,s)-1)/(Math.pow(n,i)-1)}(e,r,t.stops[s][0],t.stops[s+1][0]),a=t.stops[s][1],u=t.stops[s+1][1];let h=ms[n.type]||vo;if(t.colorSpace&&"rgb"!==t.colorSpace){const n=Os[t.colorSpace];h=(t,e)=>n.reverse(n.interpolate(n.forward(t),n.forward(e),o))}return"function"==typeof a.evaluate?{evaluate(...t){const n=a.evaluate.apply(void 0,t),e=u.evaluate.apply(void 0,t);if(void 0!==n&&void 0!==e)return h(n,e,o)}}:h(a,u,o)}function Fo(t,n,e){return"color"===n.type?e=yi.parse(e):"formatted"===n.type?e=vi.fromString(e.toString()):"resolvedImage"===n.type?e=bi.fromString(e.toString()):mo(e)===n.type||"enum"===n.type&&n.values[e]||(e=void 0),bo(e,t.default,n.default)}class Ao{constructor(t,n){this.expression=t,this.H={},this.W=new Di,this.q=n?function(t){return"color"===t.type&&(go(t.default)||Array.isArray(t.default))?new yi(0,0,0,0):"color"===t.type?yi.parse(t.default)||null:void 0===t.default?null:t.default}(n):null,this.G=n&&"enum"===n.type?n.values:null}evaluateWithoutErrorHandling(t,n,e,r,i,s,o,a){return this.W.globals=t,this.W.feature=n,this.W.featureState=e,this.W.canonical=r||null,this.W.availableImages=i||null,this.W.formattedSection=s,this.W.featureTileCoord=o||null,this.W.featureDistanceData=a||null,this.expression.evaluate(this.W)}evaluate(t,n,e,r,i,s,o,a){this.W.globals=t,this.W.feature=n||null,this.W.featureState=e||null,this.W.canonical=r||null,this.W.availableImages=i||null,this.W.formattedSection=s||null,this.W.featureTileCoord=o||null,this.W.featureDistanceData=a||null;try{const t=this.expression.evaluate(this.W);if(null==t||"number"==typeof t&&t!=t)return this.q;if(this.G&&!(t in this.G))throw new Pi(`Expected value to be one of ${Object.keys(this.G).map(t=>JSON.stringify(t)).join(", ")}, but found ${JSON.stringify(t)} instead.`);return t}catch(t){return this.H[t.message]||(this.H[t.message]=!0,"undefined"!=typeof console&&console.warn(t.message)),this.q}}}function ko(t){return Array.isArray(t)&&t.length>0&&"string"==typeof t[0]&&t[0]in co}function Po(t,n){const e=new hs(co,[],n?function(t){const n={color:Yr,string:Jr,number:Br,enum:Jr,boolean:Xr,formatted:ti,resolvedImage:ni};return"array"===t.type?ei(n[t.value]||Kr,t.length):n[t.type]}(n):void 0),r=e.parse(t,void 0,void 0,void 0,n&&"string"===n.type?{typeAnnotation:"coerce"}:void 0);return r?fo(new Ao(r,n)):po(e.errors)}class So{constructor(t,n){this.kind=t,this.B=n,this.isStateDependent="constant"!==t&&!is(n.expression)}evaluateWithoutErrorHandling(t,n,e,r,i,s){return this.B.evaluateWithoutErrorHandling(t,n,e,r,i,s)}evaluate(t,n,e,r,i,s){return this.B.evaluate(t,n,e,r,i,s)}}class _o{constructor(t,n,e,r){this.kind=t,this.zoomStops=e,this.B=n,this.isStateDependent="camera"!==t&&!is(n.expression),this.interpolationType=r}evaluateWithoutErrorHandling(t,n,e,r,i,s){return this.B.evaluateWithoutErrorHandling(t,n,e,r,i,s)}evaluate(t,n,e,r,i,s){return this.B.evaluate(t,n,e,r,i,s)}interpolationFactor(t,n,e){return this.interpolationType?$s.interpolationFactor(this.interpolationType,t,n,e):0}}function Oo(t,n){if("error"===(t=Po(t,n)).result)return t;const e=t.value.expression,r=rs(e);if(!r&&!function(t){return"data-driven"===t["property-type"]}(n))return po([new Hr("","data expressions not supported")]);const i=ss(e,["zoom","pitch","distance-from-center"]);if(!i&&!function(t){return!!t.expression&&t.expression.parameters.indexOf("zoom")>-1}(n))return po([new Hr("","zoom expressions not supported")]);const s=function t(n){let e=null;if(n instanceof Ds)e=t(n.result);else if(n instanceof Ts){for(const r of n.args)if(e=t(r),e)break}else(n instanceof fs||n instanceof $s)&&n.input instanceof Ui&&"zoom"===n.input.name&&(e=n);return e instanceof Hr||n.eachChild(n=>{const r=t(n);r instanceof Hr?e=r:!e&&r?e=new Hr("",\'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.\'):e&&r&&e!==r&&(e=new Hr("",\'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.\'))}),e}(e);if(!s&&!i)return po([new Hr("",\'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.\')]);if(s instanceof Hr)return po([s]);if(s instanceof $s&&!yo(n))return po([new Hr("",\'"interpolate" expressions cannot be used with this property\')]);if(!s)return fo(new So(r?"constant":"source",t.value));const o=s instanceof $s?s.interpolation:void 0;return fo(new _o(r?"camera":"composite",t.value,s.labels,o))}class Eo{constructor(t,n){this.J=t,this.X=n,Vr(this,function t(n,e){const r="color"===e.type,i=n.stops&&"object"==typeof n.stops[0][0],s=i||!(i||void 0!==n.property),o=n.type||(yo(e)?"exponential":"interval");if(r&&((n=Vr({},n)).stops&&(n.stops=n.stops.map(t=>[t[0],yi.parse(t[1])])),n.default=yi.parse(n.default?n.default:e.default)),n.colorSpace&&"rgb"!==n.colorSpace&&!Os[n.colorSpace])throw new Error("Unknown color space: "+n.colorSpace);let a,u,h;if("exponential"===o)a=xo;else if("interval"===o)a=Mo;else if("categorical"===o){a=wo,u=Object.create(null);for(const t of n.stops)u[t[0]]=t[1];h=typeof n.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);a=Fo}if(i){const r={},i=[];for(let t=0;t<n.stops.length;t++){const e=n.stops[t],s=e[0].zoom;void 0===r[s]&&(r[s]={zoom:s,type:n.type,property:n.property,default:n.default,stops:[]},i.push(s)),r[s].stops.push([e[0].value,e[1]])}const s=[];for(const n of i)s.push([r[n].zoom,t(r[n],e)]);const o={name:"linear"};return{kind:"composite",interpolationType:o,interpolationFactor:$s.interpolationFactor.bind(void 0,o),zoomStops:s.map(t=>t[0]),evaluate:({zoom:t},r)=>xo({stops:s,base:n.base},e,t).evaluate(t,r)}}if(s){const t="exponential"===o?{name:"exponential",base:void 0!==n.base?n.base:1}:null;return{kind:"camera",interpolationType:t,interpolationFactor:$s.interpolationFactor.bind(void 0,t),zoomStops:n.stops.map(t=>t[0]),evaluate:({zoom:t})=>a(n,e,t,u,h)}}return{kind:"source",evaluate(t,r){const i=r&&r.properties?r.properties[n.property]:void 0;return void 0===i?bo(n.default,e.default):a(n,e,i,u,h)}}}(this.J,this.X))}static deserialize(t){return new Eo(t.J,t.X)}static serialize(t){return{J:t.J,X:t.X}}}function Io(t){if(Array.isArray(t))return t.map(Io);if(t instanceof Object&&!(t instanceof Number||t instanceof String||t instanceof Boolean)){const n={};for(const e in t)n[e]=Io(t[e]);return n}return function(t){return t instanceof Number||t instanceof String||t instanceof Boolean?t.valueOf():t}(t)}function $o(t){if(!Array.isArray(t))return!1;if(function(t){return"pitch"===t||"distance-from-center"===t}(t[0]))return!0;for(let n=1;n<t.length;n++)if($o(t[n]))return!0;return!1}const Co=new Set(["in","==","!=",">",">=","<","<=","to-boolean"]),To={StyleExpression:Ao,isExpression:ko,isExpressionFilter:function t(n){if(!0===n||!1===n)return!0;if(!Array.isArray(n)||0===n.length)return!1;switch(n[0]){case"has":return n.length>=2&&"$id"!==n[1]&&"$type"!==n[1];case"in":return n.length>=3&&("string"!=typeof n[1]||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==n.length||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const e of n.slice(1))if(!t(e)&&"boolean"!=typeof e)return!1;return!0;default:return!0}},createExpression:Po,createPropertyExpression:Oo,normalizePropertyExpression:function(t,n){if(go(t))return new Eo(t,n);if(ko(t)){const e=Oo(t,n);if("error"===e.result)throw new Error(e.value.map(t=>`${t.key}: ${t.message}`).join(", "));return e.value}{let e=t;return"string"==typeof t&&"color"===n.type&&(e=yi.parse(t)),{kind:"constant",evaluate:()=>e}}},ZoomConstantExpression:So,ZoomDependentExpression:_o,StylePropertyFunction:Eo},{isExpression:zo,createExpression:Do}=To,jo={};function Uo(t){if(!0===t)return function(){return!0};if(t&&t.condition){if("any"===t.type){const n=t.condition,e=[];for(let t=0;t<n.length;t++)e.push(Uo(n[t]));return(t,n)=>{for(let r=0;r<e.length;r++)if(e[r](t,n))return!0;return!1}}const n=Uo(t.condition);if(hr(t.layer))return n;const e=n=>n.layer===t.layer;return(t,r)=>e(t)&&n(t,r)}if(function t(n){if(!0===n||!1===n)return!0;if(!Array.isArray(n)||0===n.length)return!1;switch(n[0]){case"has":case"!has":return 2===n.length&&("string"==typeof n[1]||n[1].property&&n[1].op);case"in":case"!in":return n.length>=2&&("string"==typeof n[1]||n[1].property&&n[1].op);case"==":case"!=":case">":case">=":case"<":case"<=":return 3===n.length&&("string"==typeof n[1]||n[1].property&&n[1].op);case"none":case"any":case"all":for(const e of n.slice(1))if(!t(e)&&"boolean"!=typeof e)return!1;return!0;case"contains":return!0;default:return!1}}(t))return zn(t);{let n=function(t,n="fill"){if(null==t)return{filter:()=>!0,needGeometry:!1,needFeature:!1};const e=t;let r=!0;try{r=function(t){if(!$o(t))return t;let n=Io(t);return function t(n){let e=!1;const r=[];if("case"===n[0]){for(let t=1;t<n.length-1;t+=2)e=e||$o(n[t]),r.push(n[t+1]);r.push(n[n.length-1])}else if("match"===n[0]){e=e||$o(n[1]);for(let t=2;t<n.length-1;t+=2)r.push(n[t+1]);r.push(n[n.length-1])}else if("step"===n[0]){e=e||$o(n[1]);for(let t=1;t<n.length-1;t+=2)r.push(n[t+1])}e&&(n.length=0,n.push("any",...r));for(let e=1;e<n.length;e++)t(n[e])}(n),n=function t(n){if(!Array.isArray(n))return n;const e=function(t){if(Co.has(t[0]))for(let n=1;n<t.length;n++)if($o(t[n]))return!0;return t}(n);return!0===e?e:e.map(n=>t(n))}(n),n}(e)}catch(t){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\\nand paste the contents of this message in the report.\\nThank you!\\nFilter Expression:\\n${JSON.stringify(e,null,2)}\\n        `)}const i=Po(r,null);let s=null;if("error"===i.result)throw new Error(i.value.map(t=>`${t.key}: ${t.message}`).join(", "));s=(t,n,e)=>i.value.evaluate(t,n,{},e);let o=null,a=null;if(r!==e){const t=Po(e,null);if("error"===t.result)throw new Error(t.value.map(t=>`${t.key}: ${t.message}`).join(", "));o=(n,e,r,i,s)=>t.value.evaluate(n,e,{},r,void 0,void 0,i,s),a=!rs(t.value.expression)}return s=s,{filter:s,dynamicFilter:o||void 0,needGeometry:function t(n){if(!Array.isArray(n))return!1;if("within"===n[0])return!0;for(let e=1;e<n.length;e++)if(t(n[e]))return!0;return!1}(r),needFeature:!!a}}(t);return n=n&&n.filter,(t,e)=>(jo.zoom=e,n&&n(jo,t))}}const No={type:"number","property-type":"data-driven",expression:{parameters:["zoom","feature"]}};function Lo(t,n){No.type=n||"number";const e=Do(t,No);if("success"!==e.result)throw new Error(`Invalid maplibre spec expression: ${JSON.stringify(t)} (${e.value})`);return e.value}function Vo(t){return zo(t)}const Ro={lineWidth:1,lineStrokeWidth:1,lineDx:1,lineDy:1,lineOpacity:1,linePatternAnimSpeed:1,markerWidth:1,markerHeight:1,markerDx:1,markerDy:1,markerSpacing:1,markerOpacity:1,markerRotation:1,textWrapWidth:1,textSpacing:1,textSize:1,textHaloRadius:1,textHaloOpacity:1,textDx:1,textDy:1,textOpacity:1,textRotation:1,polygonOpacity:1};function Ho(t){return Ro[t]}const Wo={markerPlacement:1,markerFile:1,mergeOnProperty:1,markerTextFit:1,markerType:1,markerHorizontalAlignment:1,markerVerticalAlignment:1,markerRotationAlignment:1,markerPitchAlignment:1,markerFillPatternFile:1,markerLinePatternFile:1,textName:1,textPlacement:1,textFaceName:1,textStyle:1,textHorizontalAlignment:1,textVerticalAlignment:1,textRotationAlignment:1,textPitchAlignment:1,lineJoin:1,lineCap:1,linePatternFile:1,polygonPatternFile:1},qo={lineDasharray:1,markerLineDasharray:1,uvScale:1,uvOffset:1};function Go(t){return Wo[t]?"string":Ho(t)?"number":qo[t]?"array":"color"}var Bo=Object.freeze({__proto__:null,compileStyle:function(t=[]){return function t(n){if(!Array.isArray(n))return t([n]);const e=[];for(let t=0;t<n.length;t++){let r;r=!0===n[t].filter?function(){return!0}:Uo(n[t].filter),e.push(ur({},n[t],{filter:r}))}return e}(t=t.map(t=>{const n=ur({},t);return n.filter&&n.filter.value&&(n.filter=n.filter.value),n}))},compileFilter:Uo,createExpression:Lo,isExpression:Vo,isInterpolated:Ho,getExpressionType:Go});const Jo="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;class Xo extends Array{push(...t){const n=t.length;for(let e=0;e<n;e++)this[this.Y++]=t[e]}fill(t,n,e){super.fill(t,n,e),e>this.Y&&(this.Y=e)}set(t,n){t>=this.Y&&(this.Y=t+1),this[t]=n}getLength(){return this.Y}setLength(t){this.Y=t,super.length<t&&(super.length=t)}trySetLength(t){t>this.Y&&this.setLength(t)}reset(){this.Y=0}}const Yo={get:function(t,n){return"length"===n?t.getLength():t[n]}};class Zo extends Array{setLength(t){super.length=t}trySetLength(t){super.length=t}}let Ko;class Qo{static createTypedArray(t,n){return or(t,n)}static getInstance(){return Ko}constructor(){this.Z=[],this.Y=0}get(){if(!Jo)return new Zo;const t=this.Z[this.Y]=this.Z[this.Y]||new Proxy(new Xo,Yo);return t.reset(),this.Y++,t}reset(){this.Y=0}}Ko=new Qo;const ta=[],na={},ea={},ra={},ia=[],sa=Qo.getInstance();class oa{static isAtlasLoaded(t,n={}){const{iconAtlas:e}=n;return!!(!t||e&&e.positions[t])}static genFnTypes(t){const n={};for(const e in t)if(Vo(t[e])){const r=(e+"_Fn_0").trim(),i=(e+"Fn").trim(),s=Go(e);n[r]=Lo(t[e],s),n[i]=(t,e)=>{let i;na.zoom=t,ea.properties=e;try{i=n[r].evaluateWithoutErrorHandling(na,ea,ra,null,ia)}catch(t){return null}return i}}else if(gr(t[e])){const r=(e+"_Fn_0").trim(),i=(e+"Fn").trim();Ho(e)?(n[r]=p(t[e]),n[i]=(t,e)=>{const i=n[r](t,e);return gr(i)?p(i)(t,e):i}):(n[r]=y(t[e]),n[i]=(t,e)=>{const i=n[r](t,e);return gr(i)?y(i)(t,e):i})}return n}constructor(t,n,e){this.options=e;const r=[];this.symbolDef=n,this.symbol=m(n,()=>(r[0]=e.zoom,r)),this.styledVectors=[],this.properties={},this.K=e.fnTypes||oa.genFnTypes(this.symbolDef),gr(this.symbolDef.visible)&&(this.tt=p(this.symbolDef.visible)),e.atlas&&(this.iconAtlas=e.atlas.iconAtlas,this.glyphAtlas=e.atlas.glyphAtlas),this.features=this.nt(t)}needAltitudeAttribute(){return this.options.forceAltitudeAttribute||this.maxPosZ>=Math.pow(2,17)||this.options.positionType===Float32Array}getPositionFormat(){return this.needAltitudeAttribute()?[{type:Int16Array,width:2,name:"aPosition"},{type:Float32Array,width:1,name:"aAltitude"}]:[{type:Int16Array,width:3,name:"aPosition"}]}fillPosition(t,n,e,r){n<this.et&&(this.et=n),n>this.rt&&(this.rt=n),e<this.it&&(this.it=e),e>this.st&&(this.st=e),this.needAltitudeAttribute()?(t.aPosition.push(n,e),t.aAltitude.push(r)):(Tr(ta,n,e,r),t.aPosition.push(ta[0],ta[1],ta[2]))}nt(t){if(!t.length)return t;const n="__fea_idx".trim();let e,r=0,i=t[r];for(;!i.geometry;)r++,i=t[r];if(Array.isArray(i.geometry)&&i.properties){let n=i.geometry[0];for(;Array.isArray(n);)n=n[0];n instanceof Ut&&(e=t)}if(!e)if(e=[],Array.isArray(i.geometry))for(let n=0;n<t.length;n++){const r=ur({},t[n]);e.push(ar(r))}else for(let r=0;r<t.length;r++){const i=t[r],s=Ve(i);for(let t=0;t<s.length;t++){const r=s[t];r[n]=i[n],e.push(r)}}if(this.maxPosZ=0,!this.options.forceAltitudeAttribute){const t="line"===this.symbolDef.textPlacement;let n=0,r=!1;const{textPitchAlignmentFn:i}=this.K;!i&&t&&"map"===this.symbolDef.textPitchAlignment&&(r=!0);for(let s=0;s<e.length;s++){const o=ua(e[s]&&e[s].geometry);if(o>n&&(n=o),t&&!r&&i&&e[s].properties){const t=i(null,e[s].properties);"map"===t&&(r=t)}}this.hasMapPitchAlign=r,this.maxPosZ=n}const s=this.options.order;if(s){const t=[];for(let n=0;n<s.length;n++)s[n]&&t.push(Uo(s[n]));e=e.sort((n,e)=>{const r=t.length;let i=-1,s=-1;for(let o=0;o<r&&(t[o](n)&&(i=o),t[o](e)&&(s=o),!(i>=0&&i<r&&s>=0&&s<r));o++);return i-s})}return e}load(t=1){const n="__fea_idx".trim(),e="_debug_info".trim(),r=this.K,i=this.styledVectors;this.count=0;const s=this.features;if(!s||!s.length)return Promise.resolve(null);const o={},a={},u={zoom:this.options.zoom,isVector3D:!!this.options.center},h=[],l=m(this.symbolDef,()=>(h[0]=u.zoom,h));let c=0,f=s.length;const d=this.options.debugIndex;try{for(;c<f;c++){const t=s[c];if(!t||!t.geometry)continue;if(lr(d)&&t[e].index!==d)continue;t.properties||(t.properties={}),t.properties.$layer=t.layer,t.properties.$type=t.type;const h=this.createStyledVector(t,l,r,u,o,a);h&&h.feature.geometry&&(h.featureIdx=void 0===t[n]?c:t[n],this.count++,i.push(h))}}catch(t){return Promise.reject(t)}return this.options.atlas?Promise.resolve(this.pack(t)):this.loadAtlas(o,a).then(()=>this.pack(t))}loadAtlas(t,n){return new Promise((e,r)=>{this.fetchAtlas(t,n,(t,n)=>{if(t)r(t);else{if(n){const{icons:t,glyphs:e}=n;if(t&&Object.keys(t).length){for(const n in t){const e=t[n],{width:r,height:i,data:s}=e.data;e.data=new Ze({width:r,height:i},s)}this.iconAtlas=new Qe(t)}if(e&&Object.keys(e).length){for(const t in e){const n=e[t];for(const t in n){const e=n[t],{width:r,height:i,data:s}=e.bitmap;e.bitmap=new Ye({width:r,height:i},s)}}this.glyphAtlas=new er(e)}}e({glyphAtlas:this.glyphAtlas,iconAtlas:this.iconAtlas})}})})}fetchAtlas(t,n,e){Object.keys(t).length>0||Object.keys(n).length>0?this.options.requestor(t,n,e):e()}pack(t){if(!this.count)return null;if(null==t)throw new Error("layout scale is undefined");const n=this.createDataPack(this.styledVectors,t);if(!n)return null;n.properties=this.properties,this.empty&&(n.empty=!0);const e=n.buffers;delete n.buffers;const r={data:n,buffers:e};if(this.iconAtlas){const t=r.data.iconAtlas=aa(this.iconAtlas);if(t.glyphMap)for(const n in t.glyphMap)e.push(t.glyphMap[n].data.data.buffer);e.push(r.data.iconAtlas.image.data.buffer)}return this.glyphAtlas&&(r.data.glyphAtlas=aa(this.glyphAtlas),e.push(r.data.glyphAtlas.image.data.buffer)),r}createStyledVector(t,n,e,r){return new Cr(t,n,e,r)}createDataPack(t,n){if(!t||!t.length)return null;this.maxIndex=0,this.maxPos=0,this.et=this.it=1/0,this.rt=this.st=-1/0,this.maxAltitude=0,this.dynamicAttrs={};const e=this.data={};this.ot=sa,sa.reset();let r=this.elements=sa.get();const i=this.getFormat(Array.isArray(t[0])?t[0][0].symbol:t[0].symbol),s=this.needAltitudeAttribute()?2:3;for(let t=0;t<i.length;t++)e[i[t].name]=sa.get();let o=sa.get(),a=0;const u=sa.get();let h=0,l=!1,c=!0;const f=new Set;for(let r=0,i=t.length;r<i;r++){if(!t[r].feature.geometry)continue;const i=Array.isArray(t[r])?t[r][0].feature.id:t[r].feature.id;c&&(void 0!==ea.id?f&&(f.has(ea.id)?c=!1:f.add(ea.id)):c=!1),lr(i)&&(Math.abs(i)>h&&(h=Math.abs(i)),i<0&&(l=!0));const d=this.data.aPosition.length;if(Array.isArray(t[r]))for(let e=0;e<t[r].length;e++)this.ut(t[r][e],n);else this.ut(t[r],n);const p=(e.aPosition.length-d)/s;for(let n=0;n<p;n++)o.push(t[r].featureIdx),lr(i)&&u.push(i);a=Math.max(a,t[r].featureIdx)}if(this.countOutOfAngle>0&&console.warn("text anchor along line is ignored as anchor\'s line angle is bigger than textMaxAngle."),this.hasElements()&&!r.length)return null;const d=this.options.center?Float32Array:sr(a);o=Qo.createTypedArray(o,d),i[0].type=this.options.positionType?this.options.positionType:ir(this.maxPos);const p=this.options.center;if(p&&(p[0]||p[1])){const t=e.aPosition;for(let n=0;n<t.length;n+=s)t[n]-=p[0],t[n+1]-=p[1]}const y=function(t,n){const e={};for(let r=0;r<t.length;r++){const i=t[r],s=i.type,o=i.name;e[o]=s===Array?n[o]:or(n[o],s)}return e}(i,e);y.aPickingId=o;const m=[];for(const t in y)m.push(y[t].buffer);const g=rr(this.maxIndex);r=Qo.createTypedArray(r,g),m.push(r.buffer);const v={data:y,isIdUnique:c,is2D:0===this.maxPosZ,indices:this.hasElements()?r:null,positionSize:s,positionBounding:[this.et,this.it,this.rt,this.st],buffers:m,symbolIndex:this.symbolDef.index||{index:0},dynamicAttributes:this.dynamicAttrs};if(this.ht&&(v.markerPlacement=this.ht),this.lt&&(v.textPlacement=this.lt),u.length){const t=l?ir(h):sr(h);v.featureIds=Qo.createTypedArray(u,t),m.push(v.featureIds.buffer)}else v.featureIds=[];return v.pickingIdIndiceMap=$r(o,v.indices),v}ut(t,n){this.tt&&!this.tt(this.options.zoom,t.feature.properties)||this.placeVector(t,n,this.formatWidth)}addElements(...t){this.maxIndex=Math.max(this.maxIndex,...t),this.elements.push(...t)}hasElements(){return!0}getAltitude(t){const{altitudeProperty:n,defaultAltitude:e,altitudeScale:r}=this.options;let i=Sr(t,n,e);return r&&(i*=r),this.maxAltitude=Math.max(this.maxAltitude,Math.abs(i)),i}getIconAtlasMaxValue(){const t=this.iconAtlas.positions;let n=0;for(const e in t)if(yr(t,e)){const{tl:r,displaySize:i}=t[e],s=Math.max(r[0],r[1],i[0]-1,i[1]-1);s>n&&(n=s)}return n}}function aa(t){let n=t.positions,e=t.image&&t.image.format||"alpha";if(t instanceof Qe){n={};for(const e in t.positions){const r=t.positions[e];n[e]={paddedRect:r.paddedRect,pixelRatio:r.pixelRatio,tl:r.tl,br:r.br,displaySize:r.displaySize}}e="rgba"}const r=t.image;return{image:{width:r.width,height:r.height,data:r.data,format:e},glyphMap:t.glyphMap,positions:n}}function ua(t){if(!t)return 0;let n=0;if(Array.isArray(t))for(let e=0;e<t.length;e++)if(Array.isArray(t[e])){const r=ua(t[e]);r>n&&(n=r)}else{const r=Math.abs(t[e].z||0);r>n&&(n=r)}else{const e=Math.abs(t.z||0);e>n&&(n=e)}return n}function ha(t,n,e,r){const i="__fn_textSize".trim();let s=t.textSize;if(hr(n.textSize))return[16,16];t[i]&&(s=t[i]);const o=[];if(o[0]=dr(s)?s(r,e):s,d(o[0])){const n=o[0].ct=o[0].ct||JSON.stringify(o[0]);t.ft||(t.ft={}),t.ft[n]||(t.ft[n]=p(o[0])),o[0]=(0,t.ft[n])(r,e)}return o[1]=o[0],o}function la(t){const n=t.stops;let e=-1/0;for(let t=0;t<n.length;t++){let r=n[t][1];cr(n[t][1])&&(r=la(n[t][1])),r>e&&(e=r)}return e}function ca(t,n,e){return[n||"normal",e||"normal","24px",t||"Open Sans Regular"].join(" ")}const fa=/\\{[\\w-]+(?:\\|[\\w-]+)*\\}/g;function da(t,n){return fr(t)?t.replace(fa,(function(t){if(!n)return"";if((t=t.substring(1,t.length-1)).indexOf("|")>0){const e=t.split("|");for(let t=0;t<e.length;t++){const r=n[e[t]];if(!hr(r))return r}return""}const e=n[t];return hr(e)?"":Array.isArray(e)?e.join():e})):t}var pa=Object.freeze({__proto__:null,getSDFFont:ca,resolveText:da,resolveVarNames:function(t){return t.match(fa)},resolveExpVarNames:function t(n,e){if(2!==e.length||"get"!==e[0])for(let r=0;r<e.length;r++)2===e[r].length&&"get"===e[r][0]?n.push(e[r][1]):Array.isArray(e[r])&&t(n,e[r]);else n.push(e[1])}});const ya=t=>t>=11904&&t<=12031,ma=t=>t>=12032&&t<=12255,ga=t=>t>=12272&&t<=12287,va=t=>t>=12288&&t<=12351,ba=t=>t>=12352&&t<=12447,wa=t=>t>=12448&&t<=12543,Ma=t=>t>=12544&&t<=12591,xa=t=>t>=12704&&t<=12735,Fa=t=>t>=12736&&t<=12783,Aa=t=>t>=12784&&t<=12799,ka=t=>t>=12800&&t<=13055,Pa=t=>t>=13056&&t<=13311,Sa=t=>t>=13312&&t<=19903,_a=t=>t>=19968&&t<=40959,Oa=t=>t>=40960&&t<=42127,Ea=t=>t>=42128&&t<=42191,Ia=t=>t>=63744&&t<=64255,$a=t=>t>=64336&&t<=65023,Ca=t=>t>=65040&&t<=65055,Ta=t=>t>=65072&&t<=65103,za=t=>t>=65104&&t<=65135,Da=t=>t>=65136&&t<=65279,ja=t=>t>=65280&&t<=65519;function Ua(t){return!((t=>t>=1536&&t<=1791)(t)||(t=>t>=1872&&t<=1919)(t)||(t=>t>=2208&&t<=2303)(t)||$a(t)||Da(t))}function Na(t){return!!(746===t||747===t||!(t<4352)&&(xa(t)||Ma(t)||Ta(t)&&!(t>=65097&&t<=65103)||Ia(t)||Pa(t)||ya(t)||Fa(t)||!(!va(t)||t>=12296&&t<=12305||t>=12308&&t<=12319||12336===t)||Sa(t)||_a(t)||ka(t)||(t=>t>=12592&&t<=12687)(t)||(t=>t>=43360&&t<=43391)(t)||(t=>t>=55216&&t<=55295)(t)||(t=>t>=4352&&t<=4607)(t)||(t=>t>=44032&&t<=55215)(t)||ba(t)||ga(t)||(t=>t>=12688&&t<=12703)(t)||ma(t)||Aa(t)||wa(t)&&12540!==t||!(!ja(t)||65288===t||65289===t||65293===t||t>=65306&&t<=65310||65339===t||65341===t||65343===t||t>=65371&&t<=65503||65507===t||t>=65512&&t<=65519)||!(!za(t)||t>=65112&&t<=65118||t>=65123&&t<=65126)||(t=>t>=5120&&t<=5759)(t)||(t=>t>=6320&&t<=6399)(t)||Ca(t)||(t=>t>=19904&&t<=19967)(t)||Oa(t)||Ea(t)))}function La(t){return!(Na(t)||function(t){return!!((t=>t>=128&&t<=255)(t)&&(167===t||169===t||174===t||177===t||188===t||189===t||190===t||215===t||247===t)||(t=>t>=8192&&t<=8303)(t)&&(8214===t||8224===t||8225===t||8240===t||8241===t||8251===t||8252===t||8258===t||8263===t||8264===t||8265===t||8273===t)||(t=>t>=8448&&t<=8527)(t)||(t=>t>=8528&&t<=8591)(t)||(t=>t>=8960&&t<=9215)(t)&&(t>=8960&&t<=8967||t>=8972&&t<=8991||t>=8996&&t<=9e3||9003===t||t>=9085&&t<=9114||t>=9150&&t<=9165||9167===t||t>=9169&&t<=9179||t>=9186&&t<=9215)||(t=>t>=9216&&t<=9279)(t)&&9251!==t||(t=>t>=9280&&t<=9311)(t)||(t=>t>=9312&&t<=9471)(t)||(t=>t>=9632&&t<=9727)(t)||(t=>t>=9728&&t<=9983)(t)&&!(t>=9754&&t<=9759)||(t=>t>=11008&&t<=11263)(t)&&(t>=11026&&t<=11055||t>=11088&&t<=11097||t>=11192&&t<=11243)||va(t)||wa(t)||(t=>t>=57344&&t<=63743)(t)||Ta(t)||za(t)||ja(t)||8734===t||8756===t||8757===t||t>=9984&&t<=10087||t>=10102&&t<=10131||65532===t||65533===t)}(t))}function Va(t){return t>=1424&&t<=2303||$a(t)||Da(t)}const Ra=[[9,9],[32,32],[5760,5760],[8192,8198],[8200,8202],[8287,12288],[6158,6158],[8203,8205]];function Ha(t){for(const n of Ra)if(t>=n[0]&&t<=n[1])return!0;return!1}const Wa={"!":"ï¸•","#":"ï¼ƒ",$:"ï¼„","%":"ï¼…","&":"ï¼†","(":"ï¸µ",")":"ï¸¶","*":"ï¼Š","+":"ï¼‹",",":"ï¸","-":"ï¸²",".":"ãƒ»","/":"ï¼",":":"ï¸“",";":"ï¸”","<":"ï¸¿","=":"ï¼",">":"ï¹€","?":"ï¸–","@":"ï¼ ","[":"ï¹‡","\\\\":"ï¼¼","]":"ï¹ˆ","^":"ï¼¾",dt:"ï¸³","`":"ï½€","{":"ï¸·","|":"â€•","}":"ï¸¸","~":"ï½ž","Â¢":"ï¿ ","Â£":"ï¿¡","Â¥":"ï¿¥","Â¦":"ï¿¤","Â¬":"ï¿¢","Â¯":"ï¿£","â€“":"ï¸²","â€”":"ï¸±","â€˜":"ï¹ƒ","â€™":"ï¹„","â€œ":"ï¹","â€":"ï¹‚","â€¦":"ï¸™","â€§":"ãƒ»","â‚©":"ï¿¦","ã€":"ï¸‘","ã€‚":"ï¸’","ã€ˆ":"ï¸¿","ã€‰":"ï¹€","ã€Š":"ï¸½","ã€‹":"ï¸¾","ã€Œ":"ï¹","ã€":"ï¹‚","ã€Ž":"ï¹ƒ","ã€":"ï¹„","ã€":"ï¸»","ã€‘":"ï¸¼","ã€”":"ï¸¹","ã€•":"ï¸º","ã€–":"ï¸—","ã€—":"ï¸˜","ï¼":"ï¸•","ï¼ˆ":"ï¸µ","ï¼‰":"ï¸¶","ï¼Œ":"ï¸","ï¼":"ï¸²","ï¼Ž":"ãƒ»","ï¼š":"ï¸“","ï¼›":"ï¸”","ï¼œ":"ï¸¿","ï¼ž":"ï¹€","ï¼Ÿ":"ï¸–","ï¼»":"ï¹‡","ï¼½":"ï¹ˆ","ï¼¿":"ï¸³","ï½›":"ï¸·","ï½œ":"â€•","ï½":"ï¸¸","ï½Ÿ":"ï¸µ","ï½ ":"ï¸¶","ï½¡":"ï¸’","ï½¢":"ï¹","ï½£":"ï¹‚"};function qa(t,n,e,r,i,s,o,a,u,h){let l=t.trim();2===h&&(l=function(t){let n="";for(let e=0;e<t.length;e++){const r=t.charCodeAt(e+1)||null,i=t.charCodeAt(e-1)||null;n+=r&&La(r)&&!Wa[t[e+1]]||i&&La(i)&&!Wa[t[e-1]]||!Wa[t[e]]?t[e]:Wa[t[e]]}return n}(l));const c=[],f={positionedGlyphs:c,text:l,top:a[1],bottom:a[1],left:a[0],right:a[0],writingMode:h};let d;return d=function(t,n){const e=[];let r=0;for(let i=0;i<n.length;i++){const s=n[i];e.push(t.substring(r,s)),r=s}return r<t.length&&e.push(t.substring(r,t.length)),e}(l,function(t,n,e,r){if(!e)return[];if(!t)return[];const i=[],s=function(t,n,e,r){let i=0;for(let e=0;e<t.length;e++){const s=r[t.charCodeAt(e)];s&&(i+=s.metrics.advance+n)}return i/Math.max(1,Math.ceil(i/e))}(t,n,e,r);let o=0;for(let e=0;e<t.length;e++){const u=t.charCodeAt(e),h=r[u];h&&!Ga[u]&&(o+=h.metrics.advance+n),e<t.length-1&&(Ba[u]||!((a=u)<11904)&&(xa(a)||Ma(a)||Ta(a)||Ia(a)||Pa(a)||ya(a)||Fa(a)||va(a)||Sa(a)||_a(a)||ka(a)||ja(a)||ba(a)||ga(a)||ma(a)||Aa(a)||wa(a)||Ca(a)||Ea(a)||Oa(a)))&&i.push(Ya(e+1,o,s,i,Xa(u,t.charCodeAt(e+1)),!1))}var a;return function t(n){return n?t(n.priorBreak).concat(n.index):[]}(Ya(t.length,o,s,i,0,!0))}(l,o,e,n)),function(t,n,e,r,i,s,o,a,u,h){let l=0,c=0,f=0;const d=t.positionedGlyphs,p="right"===s?1:"left"===s?0:.5;for(let t=0;t<e.length;t++){let i=e[t];if(i=i.trim(),!i.length){c-=r;continue}const s=d.length;for(let t=0;t<i.length;t++){const e=i.charCodeAt(t),r=n[e];r&&(Na(e)&&1!==o?(32!==e&&d.push({glyph:e,x:l,y:0,vertical:!0}),l+=u+a):(32!==e&&d.push({glyph:e,x:l,y:c,vertical:!1}),l+=r.metrics.advance+a))}d.length!==s&&(f=Math.max(l-a,f),Ka(d,n,s,d.length-1,p)),l=0,c-=r}const{horizontalAlign:y,verticalAlign:m}=Za(i,void 0);!function(t,n,e,r,i,s,o){const a=(n-e)*i,u=-(-r*o+.5)*s;if(a||u)for(let n=0;n<t.length;n++)t[n].x+=a,t[n].y+=u}(d,p,y,m,f,r,e.length);const g=e.length*r;t.top+=-m*g,t.bottom=t.top+g,t.left+=-y*f,t.right=t.left+f}(f,n,d,r,i,s,h,o,u),!!c.length&&f}const Ga={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Ba={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function Ja(t,n,e,r){const i=Math.pow(t-n,2);return r?t<n?i/2:2*i:i+Math.abs(e)*e}function Xa(t,n){let e=0;return 10===t&&(e-=1e4),40!==t&&65288!==t||(e+=50),41!==n&&65289!==n||(e+=50),e}function Ya(t,n,e,r,i,s){let o=null,a=Ja(n,e,i,s);for(let t=0;t<r.length;t++){const u=r[t],h=Ja(n-u.x,e,i,s)+u.badness;h<=a&&(o=u,a=h)}return{index:t,x:n,priorBreak:o,badness:a}}function Za(t,n){let e=.5,r=.5;switch(t){case"right":case"top-right":case"bottom-right":e=n?1:0;break;case"left":case"top-left":case"bottom-left":e=n?0:1}switch(t){case"bottom":case"bottom-right":case"bottom-left":r=n?1:0;break;case"top":case"top-right":case"top-left":r=n?0:1}return{horizontalAlign:e,verticalAlign:r}}function Ka(t,n,e,r,i){if(!i)return;const s=n[t[r].glyph];if(s){const n=(t[r].x+s.metrics.advance)*i;if(!n)return;for(let i=e;i<=r;i++)t[i].x-=n}}function Qa(t){if(!function(t){for(const n of t)if(Va(n.charCodeAt(0)))return!0;return!1}(t))return t;const n=[],e=[],r=[];let i=0,s=0,o=1,a=1;for(const u of t){const t=u.codePointAt(0);Ha(t)?(r.push(u),i++):(o=Va(t)?-1:1,a!==o?(s=i,e.length&&(a>0&&e.reverse(),n.push(...e)),r.length&&(n.splice(s,0,...r),r.length=0),a=o,e.length=0):r.length&&(e.push(...r),r.length=0),e.push(u),i++)}return r.length&&e.push(...r),e.length&&(a>0&&e.reverse(),n.push(...e)),n.reverse().join("")}const tu=/\\{ *([\\w_]+) *\\}/g;class nu{constructor(t,n,e,r,i){this.feature=t,this.symbolDef=n,this.symbol=e,this.options=i,this.pt=this.yt.bind(this),this.K=r}yt(t,n){return this.feature.properties[n]||"default"}getShape(t,n){if(this.gt)return this.gt;const{textHorizontalAlignmentFn:e,textVerticalAlignmentFn:r,markerHorizontalAlignmentFn:i,markerVerticalAlignmentFn:s,textWrapWidthFn:o}=this.K;let a;const u=this.symbol,h=this.getIconAndGlyph(),l=this.feature.properties;if(h&&h.glyph){const{font:t,text:i}=h.glyph;if(""===i)return null;const s=this.size[0]/24,c=24,f=u.textKeepUpright,d="map"===u.textRotationAlignment&&"line"===u.textPlacement&&!u.isIconText,p=n.glyphMap[t],y=eu(e?e(null,l):u.textHorizontalAlignment,r?r(null,l):u.textVerticalAlignment),m=1.2*c,g=function(t){for(let n=0;n<t.length;n++)if(!Ua(t.charAt(n).charCodeAt(0)))return!1;return!0}(i),v=g&&u.textLetterSpacing/s||0,b=[u.textDx/s||0,u.textDy/s||0],w=((o?o(null,l):u.textWrapWidth)||10*c)/s;a={},a.horizontal=qa(i,p,w,m,y,"center",v,b,c,1),g&&d&&f&&(a.vertical=qa(i,p,w,m,y,"center",v,b,c,2))}else if(h&&h.icon){if(!t.positions[h.icon.url])return null;const n=eu(i?i(null,l):u.markerHorizontalAlignment,s?s(null,l):u.markerVerticalAlignment);a=function(t,n,e){let{horizontalAlign:r,verticalAlign:i}=Za(n,e);e?r=1-r:i=1-i;const s=-2048*r,o=-2048*i;return{image:t,top:o,bottom:o+2048,left:s,right:s+2048}}(t.positions[h.icon.url],n,this.options.isVector3D),this.size||(this.size=a.image.displaySize)}return this.gt=a,a}getIconAndGlyph(){if(this.iconGlyph)return this.iconGlyph;const{markerFileFn:t,markerTypeFn:n,markerPathFn:e,markerWidthFn:r,markerHeightFn:i,markerFillFn:s,markerFillPatternFileFn:o,markerFillOpacityFn:a,markerTextFitFn:u,markerTextFitPaddingFn:h,markerLineColorFn:l,markerLineWidthFn:c,markerLineOpacityFn:f,markerLineDasharrayFn:y,markerLinePatternFileFn:m,markerPathWidthFn:g,markerPathHeightFn:v,textNameFn:b,textFaceNameFn:w,textStyleFn:M,textWeightFn:x}=this.K,{zoom:F}=this.options,A={},k=this.symbol,P=this.feature.properties,S=t?t(null,P):k.markerFile,_=n?n(null,P):k.markerType,O=S||_||k.markerPath,E=!hr(this.symbolDef.textName);let I;if(O){I=function(t,n,e,r,i,s){if(hr(n.markerWidth)&&hr(n.markerHeight))return null;const o="__fn_markerWidth".trim(),a="__fn_markerHeight".trim();let u=n.markerWidth||0,h=n.markerHeight||0;return cr(u)&&("identity"!==u.type?u=la(u):(u=t.markerWidth,t[o]&&(u=t[o](r,e)),cr(u)&&(u="identity"===u.type?i(r,e):la(u)))),cr(h)&&("identity"!==h.type?h=la(h):(h=t.markerHeight,t[a]&&(h=t[a](r,e)),cr(h)&&(h="identity"===h.type?s(r,e):la(h)))),[u,h]}(k,this.symbolDef,P,F,r,i)||[0,0];let t=k.markerTextFit;if(u&&(t=u(F,P)),t&&k.text&&"none"!==t){const n=k.text.textSize;let e=k.text.textName;d(e)&&(e=p(e)(F,P));const r=da(e,P);if(r){const e="__fn_textSize".trim(),i="__fn_textSize_0".trim();d(n)&&!k.text[e]&&(k.text[i]=p(n),k.text[e]=(t,n)=>{const e=k.text[i](t,n);return d(e)?p(e)(t,n):e});const s=ha(k.text,k.text,P,F);if("width"!==t&&"both"!==t||(I[0]=s[0]*r.length),"height"!==t&&"both"!==t||(I[1]=s[1]),s[0]&&s[1]){let t=k.markerTextFitPadding||[0,0,0,0];h&&(t=h(F,P)),I[0]+=t[1]+t[3],I[1]+=t[0]+t[2]}}else I[0]=I[1]=-1}}if(E&&(I=ha(k,this.symbolDef,P,F)),!I)return A;if(I[0]=Math.ceil(I[0]),I[1]=Math.ceil(I[1]),this.size=I,O&&I[0]>=0&&I[1]>=0){let t;if(_){const n={};if(n.markerType=_,"path"===_&&(n.markerPath=e?e(null,P):k.markerPath,n.markerPathWidth=g?g(null,P):k.markerPathWidth,n.markerPathHeight=v?v(null,P):k.markerPathHeight),r){const t=r(null,P);hr(t)||(n.markerWidth=t)}else k.markerWidth>=0&&(n.markerWidth=k.markerWidth);if(i){const t=i(null,P);hr(t)||(n.markerHeight=t)}else k.markerHeight>=0&&(n.markerHeight=k.markerHeight);if(s){const t=s(null,P);hr(t)||(n.markerFill=t)}else k.markerFill&&(n.markerFill=k.markerFill);if(o){const t=o(null,P);hr(t)||(n.markerFillPatternFile=t)}else k.markerFillPatternFile&&(n.markerFillPatternFile=k.markerFillPatternFile);if(a){const t=a(null,P);hr(t)||(n.markerFillOpacity=t)}else k.markerFillOpacity>=0&&(n.markerFillOpacity=k.markerFillOpacity);if(l){const t=l(null,P);hr(t)||(n.markerLineColor=t)}else k.markerLineColor&&(n.markerLineColor=k.markerLineColor);if(c){const t=c(null,P);hr(t)||(n.markerLineWidth=t)}else k.markerLineWidth>=0&&(n.markerLineWidth=k.markerLineWidth);if(f){const t=f(null,P);hr(t)||(n.markerLineOpacity=t)}else k.markerLineOpacity>=0&&(n.markerLineOpacity=k.markerLineOpacity);if(y){const t=y(null,P);hr(t)||(n.markerLineDasharray=t)}else k.markerLineDasharray&&(n.markerLineDasharray=k.markerLineDasharray);if(m){const t=m(null,P);hr(t)||(n.markerLinePatternFile=t)}else k.markerLinePatternFile&&(n.markerLinePatternFile=k.markerLinePatternFile);t="vector://"+JSON.stringify(n)}else t=S?S.replace(tu,this.pt):k.markerPath?function(t,n,e){if(!t.markerPath)return null;let r=1;const i=function(t){const n={stroke:{stroke:t.markerLineColor,"stroke-width":t.markerLineWidth,"stroke-opacity":t.markerLineOpacity,"stroke-dasharray":null,"stroke-linecap":"butt","stroke-linejoin":"round"},fill:{fill:t.markerFill,"fill-opacity":t.markerFillOpacity}};return 0===n.stroke["stroke-width"]&&(n.stroke["stroke-opacity"]=0),n}(t);lr(t.markerOpacity)&&(r=t.markerOpacity),lr(t.opacity)&&(r*=t.opacity);const s={};if(i){for(const t in i.stroke)yr(i.stroke,t)&&(hr(i.stroke[t])||(s[t]=i.stroke[t]));for(const t in i.fill)yr(i.fill,t)&&(hr(i.fill[t])||(s[t]=i.fill[t]))}const o=Array.isArray(t.markerPath)?t.markerPath:[t.markerPath];let a;const u=[];for(let t=0;t<o.length;t++)a=fr(o[t])?{path:o[t]}:o[t],a=ur({},a,s),a.d=a.path,delete a.path,u.push(a);const h=[\'<svg version="1.1"\',\'xmlns="http://www.w3.org/2000/svg"\'];r<1&&h.push(\'opacity="\'+r+\'"\'),t.markerPathWidth&&t.markerPathHeight&&h.push(\'viewBox="0 0 \'+t.markerPathWidth+" "+t.markerPathHeight+\'"\'),h.push(\'preserveAspectRatio="none"\'),n&&h.push(\'width="\'+n+\'"\'),e&&h.push(\'height="\'+e+\'"\'),h.push("><defs></defs>");for(let t=0;t<u.length;t++){let n="<path ";for(const e in u[t])yr(u[t],e)&&(n+=" "+e+\'="\'+u[t][e]+\'"\');n+="></path>",h.push(n)}return h.push("</svg>"),"data:image/svg+xml;base64,"+btoa(h.join(" "))}(k,I[0],I[1]):null;A.icon={url:t,size:I}}if(E){const t=b?b(this.options.zoom,P):k.textName;if(t||0===t){const n=ca(w?w(null,P):k.textFaceName,M?M(null,P):k.textStyle,x?x(null,P):k.textWeight);let e=da(t,P);e&&e.length&&(e=Qa(e),A.glyph={font:n,text:e})}}return this.iconGlyph=A,A}}function eu(t,n){n&&"middle"!==n||(n="center"),t&&"middle"!==t||(t="center");let e="center"!==n?n:"";return e+="center"!==t?(e.length?"-":"")+t:"",e\n/*!\n     * From mapbox-gl-js\n     * MIT License\n     * https://github.com/mapbox/mapbox-gl-js\n     */}function ru(t,n,e,r,i){const s=[];let o;for(let a=0;a<t.length;a++){const u=t[a];let h,l=!1;for(let t=0;t<u.length-1;t++){let a=u[t],c=u[t+1];a.x<n&&c.x<n||(a.x<n?(o=a,a=new Ut(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y)).T(),a.z=o.z+(n-o.x)/(c.x-o.x)*(c.z-o.z),l=!0):c.x<n&&(o=c,c=new Ut(n,a.y+(n-a.x)/(c.x-a.x)*(c.y-a.y)).T(),c.z=a.z+(n-a.x)/(o.x-a.x)*(o.z-a.z),l=!0),a.y<e&&c.y<e||(a.y<e?(o=a,a=new Ut(a.x+(e-a.y)/(c.y-a.y)*(c.x-a.x),e).T(),a.z=o.z+(e-o.y)/(c.y-o.y)*(c.z-o.z),l=!0):c.y<e&&(o=c,c=new Ut(a.x+(e-a.y)/(c.y-a.y)*(c.x-a.x),e).T(),c.z=a.z+(e-a.y)/(o.y-a.y)*(o.z-a.z),l=!0),a.x>=r&&c.x>=r||(a.x>=r?(o=a,a=new Ut(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y)).T(),a.z=o.z+(r-o.x)/(c.x-o.x)*(c.z-o.z),l=!0):c.x>=r&&(o=c,c=new Ut(r,a.y+(r-a.x)/(c.x-a.x)*(c.y-a.y)).T(),c.z=a.z+(r-a.x)/(o.x-a.x)*(o.z-a.z),l=!0),a.y>=i&&c.y>=i||(a.y>=i?(o=a,a=new Ut(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i).T(),a.z=o.z+(i-o.y)/(c.y-o.y)*(c.z-o.z),l=!0):c.y>=i&&(o=c,c=new Ut(a.x+(i-a.y)/(c.y-a.y)*(c.x-a.x),i).T(),c.z=a.z+(i-a.y)/(o.y-a.y)*(o.z-a.z),l=!0),h&&a.equals(h[h.length-1])||(h=[a],s.push(h)),l&&(h.clipped=!0),h.push(c)))))}}return s}class iu extends Ut{constructor(t,n,e,r){super(t,n),this.angle=e,void 0!==r&&(this.segment=r)}clone(){return new iu(this.x,this.y,this.angle,this.segment)}}\n/*!\n     * From mapbox-gl-js\n     * MIT License\n     * https://github.com/mapbox/mapbox-gl-js\n     */function su(t,n,e,r,i){if(void 0===n.segment)return!0;let s=n,o=n.segment+1,a=0;for(;a>-e/2;){if(o--,o<0)return!1;a-=t[o].dist(s),s=t[o]}a+=t[o].dist(t[o+1]),o++;const u=[];let h=0;for(;a<e/2;){const n=t[o],e=t[o+1];if(!e)return!1;let s=t[o-1].angleTo(n)-n.angleTo(e);for(s=Math.abs((s+3*Math.PI)%(2*Math.PI)-Math.PI),u.push({distance:a,angleDelta:s}),h+=s;a-u[0].distance>r;)h-=u.shift().angleDelta;if(h>i)return!1;o++,a+=n.dist(e)}return!0}function ou(t,n,e,r,i,s,o,a,u,h,l){const c=function(t,n,e){return t?.6*n*e:0}(r,s,o),f=function(t,n){return Math.max(t?t.right-t.left:0,n?n.right-n.left:0)}(r,i),d=0===t[0].x||t[0].x===u||0===t[0].y||t[0].y===u;return n-f*o<n/4&&(n=f*o+n/4),function t(n,e,r,i,s,o,a,u,h,l,c){let f=0;const d=o/2,p=function(t){let n=0;for(let e=0;e<t.length-1;e++)n+=t[e].dist(t[e+1]);return n}(n);let y=0,m=e-r,g=[];for(let t=0;t<n.length-1;t++){const e=n[t],a=n[t+1],u=e.dist(a),v=a.angleTo(e);for(;m+r<y+u;){m+=r;const b=(m-y)/u,w=au(e.x,a.x,b),M=au(e.y,a.y,b),x=au(e.z||0,a.z||0,b);if(w>=0&&w<h&&M>=0&&M<h&&m-d>=0&&m+d<=p){const r=new iu(w,M,v,t);r.z=x,l&&(r.axis=[e.y-M,w-e.x],r.angleR=x===(e.z||0)?0:Math.atan(.9*(x-(e.z||0))*c/e.dist(r))),r.line=n,r.T(),!i||su(n,r,o,i,s)?g.push(r):i&&f++}}y+=u}return u||g.length||a||(g=t(n,y/2,r,i,s,o,a,!0,h,l,c)),g.countOutOfAngle=f,g}(t,d?n/2*a%n:(f/2+2*s)*o*a%n,n,c,e,f*o,d,!1,u,h,l)}function au(t,n,e){return t*(1-e)+n*e}function uu(t,n){const e=t.length;if(e<=1)return[t];const r=[];let i,s;for(let n=0;n<e;n++){const e=kr(t[n]);0!==e&&(t[n].area=Math.abs(e),void 0===s&&(s=e<0),s===e<0?(i&&r.push(i),i=[t[n]]):i.push(t[n]))}if(i&&r.push(i),n>1)for(let t=0;t<r.length;t++)r[t].length<=n||(Gn(r[t],n,1,r[t].length-1,hu),r[t]=r[t].slice(0,n));return r}function hu(t,n){return n.area-t.area}function lu(t,n,e){const r=n.distSqr(e);if(0===r)return t.distSqr(n);const i=((t.x-n.x)*(e.x-n.x)+(t.y-n.y)*(e.y-n.y))/r;return t.distSqr(i<0?n:i>1?e:e.sub(n).k(i).m(n))}function cu(t,n=1,e=!1){let r=1/0,i=1/0,s=-1/0,o=-1/0;const a=t[0];for(let t=0;t<a.length;t++){const n=a[t];(!t||n.x<r)&&(r=n.x),(!t||n.y<i)&&(i=n.y),(!t||n.x>s)&&(s=n.x),(!t||n.y>o)&&(o=n.y)}const u=Math.min(s-r,o-i);let h=u/2;const l=new Bn([],fu);if(0===u)return new Ut(r,i);for(let n=r;n<s;n+=u)for(let e=i;e<o;e+=u)l.push(new du(n+h,e+h,h,t));let c=function(t){let n=0,e=0,r=0;const i=t[0];for(let t=0,s=i.length,o=s-1;t<s;o=t++){const s=i[t],a=i[o],u=s.x*a.y-a.x*s.y;e+=(s.x+a.x)*u,r+=(s.y+a.y)*u,n+=3*u}return new du(e/n,r/n,0,t)}(t),f=l.length;for(;l.length;){const r=l.pop();(r.d>c.d||!c.d)&&(c=r,e&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,f)),r.max-c.d<=n||(h=r.h/2,l.push(new du(r.p.x-h,r.p.y-h,h,t)),l.push(new du(r.p.x+h,r.p.y-h,h,t)),l.push(new du(r.p.x-h,r.p.y+h,h,t)),l.push(new du(r.p.x+h,r.p.y+h,h,t)),f+=4)}return e&&(console.log("num probes: "+f),console.log("best distance: "+c.d)),c.p}function fu(t,n){return n.max-t.max}function du(t,n,e,r){this.p=new Ut(t,n),this.h=e,this.d=function(t,n){let e=!1,r=1/0;for(let i=0;i<n.length;i++){const s=n[i];for(let n=0,i=s.length,o=i-1;n<i;o=n++){const i=s[n],a=s[o];i.y>t.y!=a.y>t.y&&t.x<(a.x-i.x)*(t.y-i.y)/(a.y-i.y)+i.x&&(e=!e),r=Math.min(r,lu(t,i,a))}}return(e?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}function pu(t,n,e,r,i,s,o,a,u,h){const{feature:l,size:c,symbol:f}=t,d=c?24:0,p=i*(c?c[0]/d:1);if("line"===o){const t=[];t.countOutOfAngle=0;let i=l.geometry;s&&(i=ru(l.geometry,0,0,s,s));for(let o=0;o<i.length;o++){const l=ou(i[o],a,e,f.isIconText?null:r&&r.vertical||r&&r.horizontal||r,null,d,f.isIconText?1:p,1,s||1/0,u,h);if(f.textPlacement&&!f.isIconText)for(let t=0;t<l.length;t++)l[t].startIndex=n.length/3;if(t.push.apply(t,l),f.textPlacement&&!f.isIconText)for(let t=0;t<i[o].length;t++)n.push(i[o][t].x,i[o][t].y,i[o][t].z||0);t.countOutOfAngle+=l.countOutOfAngle||0}return t}return yu(l,o,s)}function yu(t,n,e,r,i){const s=[];if(3===t.type){const o=uu(t.geometry,0);for(let t=0;t<o.length;t++){const a=o[t];if("vertex"===n)for(let t=0;t<a.length;t++){const n=a[t];for(let o=0;o<n.length;o++)Or(n[o],e)||(s.push(n[o]),r&&(0===o?mu(n[o],n[o],n[t+1],i):mu(n[o],n[o-1],n[o],i)))}else if("vertex-first"===n){const t=a[0];t&&t[0]&&!Or(t[0],e)&&(s.push(t[0]),r&&mu(t[0],t[0],t[1],i))}else if("vertex-last"===n||"vertex-firstlast"===n){const t=a[0];if("vertex-firstlast"===n&&t&&t[0]&&!Or(t[0],e)&&(s.push(t[0]),r&&mu(t[0],t[0],t[1],i)),t&&t[t.length-1]&&!Or(t[t.length-1],e)){const n=t.length-1;s.push(t[n]),r&&mu(t[n],t[n-1],t[n],i)}}else{const t=cu(a,16);Or(t,e)||s.push(t)}}}else if(2===t.type)for(let o=0;o<t.geometry.length;o++){const a=t.geometry[o];if("vertex"===n)for(let t=0;t<a.length;t++)Or(a[t],e)||(s.push(a[t]),r&&(0===t?mu(a[t],a[t],a[t+1],i):mu(a[t],a[t-1],a[t],i)));else if("vertex-last"===n||"vertex-firstlast"===n){if("vertex-firstlast"!==n||Or(a[0],e)||(s.push(a[0]),r&&mu(a[0],a[0],a[1],i)),a&&a[a.length-1]&&!Or(a[a.length-1],e)){const t=a.length-1;s.push(a[t]),r&&mu(a[t],a[t-1],a[t],i)}}else Or(a[0],e)||(s.push(a[0]),r&&mu(a[0],a[0],a[1],i))}else if(1===t.type)for(let n=0;n<t.geometry.length;n++){const i=t.geometry[n];for(let t=0;t<i.length;t++){const n=i[t];Or(n,e)||(r&&(n.xRotation=0,n.yRotation=0,n.zRotation=0),s.push(n))}}return s}function mu(t,n,e,r){if(t.xRotation||t.yRotation||t.zRotation)return t;const i=e.x-n.x,s=n.y-e.y,o=(e.z-n.z)*r,a=Math.atan2(s,i);t.zRotation=a;const u=Math.atan2(o,Math.sqrt(i*i+s*s));return t.xyRotation=u,t}function gu(t,n){const e={},r={},i=[];let s=0;function o(n){i.push(t[n]),s++}function a(t,n,e){const s=r[t];return delete r[t],r[n]=s,i[s].geometry[0].pop(),i[s].geometry[0]=i[s].geometry[0].concat(e[0]),s}function u(t,n,r){const s=e[n];return delete e[n],e[t]=s,i[s].geometry[0].shift(),i[s].geometry[0]=r[0].concat(i[s].geometry[0]),s}function h(t,n,e){const r=e?n[0][n[0].length-1]:n[0][0];return`${t}:${r.x}:${r.y}`}for(let l=0;l<t.length;l++){const c=t[l],f=c.geometry;if(!f)continue;const d=c.properties[n]?c.properties[n].toString():null;if(!d){o(l);continue}const p=h(d,f),y=h(d,f,!0);if(p in r&&y in e&&r[p]!==e[y]){const t=u(p,y,f),n=a(p,y,i[t].geometry);delete e[p],delete r[y],r[h(d,i[n].geometry,!0)]=n,i[t].geometry=null}else p in r?a(p,y,f):y in e?u(p,y,f):(o(l),e[p]=s-1,r[y]=s-1)}return i.filter(t=>t.geometry)}class vu extends oa{static needMerge(t,n,e){if(!t)return!1;let r="line"===t.textPlacement||"line"===t.markerPlacement;return r||(n.textPlacementFn&&(r="line"===n.textPlacementFn(e)),n.markerPlacementFn&&(r="line"===n.markerPlacementFn(e))),t.mergeOnProperty&&r}static mergeLineFeatures(t,n,e,r){const i="__index".trim();let s=n.textPlacement,o=n.markerPlacement;e.textPlacementFn&&(s=e.textPlacementFn(r)),e.markerPlacementFn&&(o=e.markerPlacementFn(r));const a=function(t,n,e,r,i){const s="__index".trim(),o=oa.genFnTypes(n),{mergeOnPropertyFn:a}=o;if(!n.mergeOnProperty||"line"!==r&&"line"!==e)return[];if(!(Er(u=n.mergeOnProperty)||"string"!=typeof u&&(null===u.constructor||u.constructor!==String)||"line"!==r&&"line"!==e))return[{features:t,property:n.mergeOnProperty}];var u;const h=[],l={},c=[];for(let o=0;o<t.length;o++){t[o][s]=o;const u=t[o].properties=t[o].properties||{};u.$layer=t[o].layer,u.$type=t[o].type;let f=e;"line"!==f&&(f=r);const d=a?a(i,u):n.mergeOnProperty;"line"!==f||Er(d)?c.push(t[o]):(void 0===l[d]&&(l[d]=h.length,h.push({features:[],property:d})),h[l[d]].features.push(t[o]))}return c.length&&h.push({features:c}),h}(t,n,o,s,r);if(a.length){const n=[];for(let e=0;e<a.length;e++)n.push(a[e].property?gu(a[e].features,a[e].property):t);if(1===n.length)return n[0];{let t=[];for(let e=0;e<n.length;e++)t=t.concat(n[e]);return t.sort((t,n)=>t[i]-n[i]),t}}}static splitPointSymbol(t,n=0){const e=[];if(Array.isArray(t)){const n=t;for(let t=0;t<n.length;t++)n[t]&&e.push(...vu.splitPointSymbol(n[t],t));return e}let r=null,i=null;for(const n in t)0===n.indexOf("marker")?(r=r||{},r[n]=t[n]):0===n.indexOf("text")&&(i=i||{},i[n]=t[n]);return r&&(r.isIconText=!0,t.mergeOnProperty&&(r.mergeOnProperty=t.mergeOnProperty),e.push(r)),i&&(r&&(i.textPlacement=r.markerPlacement,i.textSpacing=r.markerSpacing,i.isIconText=!0),t.mergeOnProperty&&(i.mergeOnProperty=t.mergeOnProperty),e.push(i)),void 0!==t.visible&&(r&&(r.visible=t.visible),i&&(i.visible=t.visible)),r&&(r.markerTextFit&&i&&(r.text={},r.text.textName=i.textName,r.text.textSize=i.textSize),r.index={index:n,type:0}),i&&(i.index={index:n,type:1}),e}static isAtlasLoaded(t,n){const{icon:e,glyph:r}=t,{iconAtlas:i,glyphAtlas:s}=n;if(e&&(!i||!i.positions[e.url]))return!1;if(r){if(!s||!s.positions[r.font])return!1;const t=s.positions[r.font],{text:n}=r;for(let e=0;e<n.length;e++)if(!t[n.charCodeAt(e)])return!1}return!0}constructor(t,n,e){super(t,n,e),this.vt=n.textPlacement,this.K.textPlacementFn&&(this.vt=this.K.textPlacementFn(this.options.zoom))}createStyledVector(t,n,e,r,i,s){const o=new nu(t,this.symbolDef,n,e,r),a=o.getIconAndGlyph();if(a.icon&&!this.options.atlas){const{url:t,size:n}=a.icon;i[t]||(i[t]=a.icon.size),i[t][0]<n[0]&&(i[t][0]=n[0]),i[t][1]<n[1]&&(i[t][1]=n[1])}if(a.glyph&&!this.options.atlas){const{font:t,text:n}=a.glyph,e=s[t]=s[t]||{};for(let t=0;t<n.length;t++)e[n.charCodeAt(t)]=1;"line"===this.vt&&(s.options={isCharsCompact:!1})}return this.options.allowEmptyPack||a.icon||a.glyph?o:null}getFormat(t){const n=void 0!==t.textName,e=n?this.getPackSDFFormat(t):this.getPackMarkerFormat();n?e.push(...this.bt()):e.push(...this.wt());const{markerOpacityFn:r,textOpacityFn:i,markerPitchAlignmentFn:s,textPitchAlignmentFn:o,markerRotationAlignmentFn:a,textRotationAlignmentFn:u,markerRotationFn:h,textRotationFn:l,markerAllowOverlapFn:c,textAllowOverlapFn:f,markerIgnorePlacementFn:d,textIgnorePlacementFn:p}=this.K;return(r||i)&&e.push({type:Uint8Array,width:1,name:"aColorOpacity"}),(s||o)&&e.push({type:Uint8Array,width:1,name:"aPitchAlign"}),(a||u)&&e.push({type:Uint8Array,width:1,name:"aRotationAlign"}),(h||l)&&e.push({type:Uint16Array,width:1,name:"aRotation"}),(c||f||d||p)&&e.push({type:Uint8Array,width:1,name:"aOverlap"}),e}Mt(){return this.hasMapPitchAlign}bt(){const{textFillFn:t,textSizeFn:n,textHaloFillFn:e,textHaloRadiusFn:r,textHaloOpacityFn:i,textDxFn:s,textDyFn:o}=this.K,a=[];return t&&a.push({type:Uint8Array,width:4,name:"aTextFill"}),n&&a.push({type:Uint8Array,width:1,name:"aTextSize"}),e&&a.push({type:Uint8Array,width:4,name:"aTextHaloFill"}),r&&a.push({type:Uint8Array,width:1,name:"aTextHaloRadius"}),i&&a.push({type:Uint8Array,width:1,name:"aTextHaloOpacity"}),s&&a.push({type:Int8Array,width:1,name:"aTextDx"}),o&&a.push({type:Int8Array,width:1,name:"aTextDy"}),a}wt(){const{markerWidthFn:t,markerHeightFn:n,markerDxFn:e,markerDyFn:r}=this.K,i=[];return t&&i.push({type:this.options.markerWidthType||Uint8Array,width:1,name:"aMarkerWidth"}),n&&i.push({type:this.options.markerHeightType||Uint8Array,width:1,name:"aMarkerHeight"}),e&&i.push({type:Int8Array,width:1,name:"aMarkerDx"}),r&&i.push({type:Int8Array,width:1,name:"aMarkerDy"}),i}createDataPack(){if(!this.iconAtlas&&!this.glyphAtlas){if(!this.options.allowEmptyPack)return null;this.empty=!0}this.countOutOfAngle=0,this.lineVertex=[];const t=super.createDataPack.apply(this,arguments);return t?(t.lineVertex=new Int16Array(this.lineVertex),t.buffers.push(t.lineVertex.buffer),t):null}placeVector(t,n){const e=t.getShape(this.iconAtlas,this.glyphAtlas);if(!(this.options.allowEmptyPack||e&&e.image||e&&(e.horizontal||e.vertical)))return;const r=this.xt(t,e,n);if(this.countOutOfAngle+=r.countOutOfAngle||0,0===r.length)return;const i=this.data,s=this.needAltitudeAttribute()?2:3;let o=this.data.aPosition.length/s;const a=t.symbol,u=t.feature.properties,h="line"===this.vt&&!a.isIconText,l=void 0!==a.textName,c=l&&h&&function(t){let n=0;for(let e=0;e<t.length;e++)if(Na(t.charAt(e).charCodeAt(0)))n=0;else if(n++,n>=1)return!1;return!0}(t.getIconAndGlyph().glyph.text)?1:0,{textFillFn:f,textSizeFn:p,textHaloFillFn:y,textHaloRadiusFn:m,textHaloOpacityFn:g,textDxFn:v,textDyFn:b,textPitchAlignmentFn:w,textRotationAlignmentFn:M,textRotationFn:x,textAllowOverlapFn:F,textIgnorePlacementFn:A,textOpacityFn:k,markerWidthFn:P,markerHeightFn:S,markerDxFn:_,markerDyFn:O,markerPitchAlignmentFn:E,markerRotationAlignmentFn:I,markerRotationFn:$,markerAllowOverlapFn:C,markerIgnorePlacementFn:T,markerOpacityFn:z}=this.K;let D,j,U,N,L,V,R,H,W,q,G,B,J,X,Y,Z,K;if(l){const n=t.getIconAndGlyph().glyph.font;D=function(t,n,e){const r=t.positionedGlyphs,i=[];for(let s=0;s<r.length;s++){const o=r[s],a=e[o.glyph];if(!a)continue;const u=a.rect;if(!u)continue;const h=4,l=a.metrics.advance/2,c=a.metrics.height/2,f=n?[o.x+l,0]:[0,0],d=n?[0,o.y-c]:[o.x+l,o.y-c],p=a.metrics.left-h-l+d[0],y=a.metrics.top-h+d[1],m=p+u.w,g=y+u.h,v=new Ut(p,y),b=new Ut(m,y),w=new Ut(p,g),M=new Ut(m,g);if(n&&o.vertical){const t=new Ut(-l,l),n=-Math.PI/2,e=new Ut(5,0);v._(n,t).m(e),b._(n,t).m(e),w._(n,t).m(e),M._(n,t).m(e)}i.push({tl:v,tr:b,bl:w,br:M,tex:u,writingMode:t.writingMode,glyphOffset:f})}return i}(e.horizontal,h,this.glyphAtlas.positions[n]),f&&(j=f(null,u),d(j)?(this.dynamicAttrs.aTextFill=1,j=[0,0,0,0]):j=Mr([],j)),p&&(U=p(this.options.zoom,u),Er(U)&&(U=14)),y&&(N=y(null,u),d(N)?(this.dynamicAttrs.aTextHaloFill=1,N=[0,0,0,0]):N=Mr([],N)),m&&(L=m(null,u)),g&&(V=255*g(null,u)),v&&(R=v(null,u)||0),b&&(H=b(null,u)||0),w&&(J=+("map"===w(null,u))),M&&(X=+("map"===M(null,u))),x&&(Y=Ir(x(null,u),0,360)*Math.PI/180)}else D=e?function(t){const n=t.image,e=t.top-1/n.pixelRatio,r=t.left-1/n.pixelRatio,i=t.bottom+1/n.pixelRatio,s=t.right+1/n.pixelRatio;let o,a,u,h;return o=new Ut(r,e),a=new Ut(s,e),u=new Ut(s,i),h=new Ut(r,i),[{tl:o,tr:a,bl:h,br:u,tex:{x:n.tl[0],y:n.tl[1],w:n.displaySize[0],h:n.displaySize[1]},writingMode:void 0,glyphOffset:[0,0]}]}(e):function(){const t=new Ut(0,0),n=new Ut(0,0),e=new Ut(0,0);return[{tl:t,tr:n,bl:new Ut(0,0),br:e,tex:{x:0,y:0,w:0,h:0},writingMode:void 0,glyphOffset:[0,0]}]}(),P&&(W=P(null,u)),Er(W)&&(W=D[0].tex.w),S&&(q=S(null,u)),Er(q)&&(q=D[0].tex.h),_&&(G=_(null,u)),O&&(B=O(null,u)),E&&(J=+("map"===E(null,u))),I&&(X=+("map"===I(null,u))),$&&(Y=Ir($(null,u),0,360)*Math.PI/180);d(U)&&(this.dynamicAttrs.aTextSize=1),d(L)&&(this.dynamicAttrs.aTextHaloRadius=1),d(V)&&(this.dynamicAttrs.aTextHaloOpacity=1),d(R)&&(this.dynamicAttrs.aTextDx=1),d(H)&&(this.dynamicAttrs.aTextDy=1),d(W)&&(this.dynamicAttrs.aMarkerWidth=1),d(q)&&(this.dynamicAttrs.aMarkerHeight=1),d(G)&&(this.dynamicAttrs.aMarkerDx=1),d(B)&&(this.dynamicAttrs.aMarkerDy=1),d(J)&&(this.dynamicAttrs.aPitchAlign=1),d(X)&&(this.dynamicAttrs.aRotationAlign=1),d(Y)&&(this.dynamicAttrs.aRotation=1);const Q=C||F;Q&&(Z=Q(null,u)||0);const tt=T||A;let nt;tt&&(K=tt(null,u)||0);const et=k||z;et&&(nt=255*et(this.options.zoom,u));const rt=this.options.EXTENT,it=D.length,{altitudeScale:st,altitudeProperty:ot,defaultAltitude:at}=this.options,{altitude:ut}=_r(t.feature,st,ot,at);for(let t=0;t<r.length;t++){const n=r[t],e=n.z||ut||0;if(rt!==1/0&&Or(n,rt))continue;const s=n.x,a=n.y,u=D.length;for(let t=0;t<u;t++){const r=D[t],{tl:u,tr:f,bl:d,br:p,tex:y}=r;this.Ft(i,s,a,e,10*u.x,10*u.y,y.x,y.y+y.h),l&&this.At(i,h,it,r.glyphOffset,n,c,n.axis,n.angleR),this.kt(i,j,U,N,L,V,R,H,W,q,G,B,nt,J,X,Y,Z,K),this.Ft(i,s,a,e,10*f.x,10*f.y,y.x+y.w,y.y+y.h),l&&this.At(i,h,it,r.glyphOffset,n,c,n.axis,n.angleR),this.kt(i,j,U,N,L,V,R,H,W,q,G,B,nt,J,X,Y,Z,K),this.Ft(i,s,a,e,10*d.x,10*d.y,y.x,y.y),l&&this.At(i,h,it,r.glyphOffset,n,c,n.axis,n.angleR),this.kt(i,j,U,N,L,V,R,H,W,q,G,B,nt,J,X,Y,Z,K),this.Ft(i,s,a,e,10*p.x,10*p.y,y.x+y.w,y.y),l&&this.At(i,h,it,r.glyphOffset,n,c,n.axis,n.angleR),this.kt(i,j,U,N,L,V,R,H,W,q,G,B,nt,J,X,Y,Z,K),this.addElements(o,o+1,o+2),this.addElements(o+1,o+2,o+3),o+=4;const m=Math.max(Math.abs(s),Math.abs(a),Math.abs(e));m>this.maxPos&&(this.maxPos=m)}}}Ft(t,n,e,r,i,s,o,a){this.fillPosition(t,n,e,r),t.aShape.push(i,s),t.aTexCoord.push(o,a)}At(t,n,e,r,i,s,o,a){if(t.aCount.push(e),n){t.aGlyphOffset.push(r[0],r[1]),this.Mt()&&t.aPitchRotation.push(o[0],o[1],a);const n=i.startIndex;t.aSegment.push(i.segment+n,n,i.line.length),t.aVertical.push(s)}}kt(t,n,e,r,i,s,o,a,u,h,l,c,f,d,p,y,m,g){const{textFillFn:v,textSizeFn:b,textHaloFillFn:w,textHaloRadiusFn:M,textHaloOpacityFn:x,textDxFn:F,textDyFn:A,textPitchAlignmentFn:k,textRotationAlignmentFn:P,textRotationFn:S,textAllowOverlapFn:_,textIgnorePlacementFn:O,textOpacityFn:E,markerWidthFn:I,markerHeightFn:$,markerDxFn:C,markerDyFn:T,markerPitchAlignmentFn:z,markerRotationAlignmentFn:D,markerRotationFn:j,markerAllowOverlapFn:U,markerIgnorePlacementFn:N,markerOpacityFn:L}=this.K;v&&t.aTextFill.push(...n),b&&t.aTextSize.push(e),w&&t.aTextHaloFill.push(...r),M&&t.aTextHaloRadius.push(i),x&&t.aTextHaloOpacity.push(s),F&&t.aTextDx.push(o),A&&t.aTextDy.push(a),I&&t.aMarkerWidth.push(u),$&&t.aMarkerHeight.push(h),C&&t.aMarkerDx.push(l),T&&t.aMarkerDy.push(c),(L||E)&&t.aColorOpacity.push(f),(k||z)&&t.aPitchAlign.push(d),(D||P)&&t.aRotationAlign.push(p),(j||S)&&t.aRotation.push(9362*y);const V=U||_,R=N||O;(V||R)&&t.aOverlap.push((V?8:0)+4*m+((R?2:0)+g)),i>0&&(this.properties.hasHalo=1)}xt(t,n,e){const{feature:r,symbol:i}=t,s=this.Pt(t,i),o=r.properties,{markerSpacingFn:a,textSpacingFn:u,textMaxAngleFn:h}=this.K,l=((a?a(null,o):i.markerSpacing)||(u?u(null,o):i.textSpacing)||250)*e;let c=h?h(this.options.zoom,o):i.textMaxAngle;Er(c)&&(c=80),c*=Math.PI/180;const f=this.options.EXTENT,d=this.options.altitudeToTileScale,p=this.Mt();return pu(t,this.lineVertex,c,n,e,f,s,l,p,d)}Pt(t,n){let e;return e=this.K.markerPlacementFn?this.K.markerPlacementFn(this.options.zoom,t.feature.properties):n.markerPlacement||this.vt,this.ht||!n.markerPlacement&&!n.isIconText||(this.ht=e),!this.vt||n.isIconText||this.lt||(this.lt=e),e}getPackSDFFormat(t){if("line"!==this.vt||t.isIconText)return[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"},{type:Uint8Array,width:1,name:"aCount"}];{const t=[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"},{type:Uint8Array,width:1,name:"aCount"},{type:Int16Array,width:2,name:"aGlyphOffset"},{type:Uint16Array,width:3,name:"aSegment"},{type:Uint8Array,width:1,name:"aVertical"}];return this.Mt()&&t.push({type:Float32Array,width:3,name:"aPitchRotation"}),t}}getPackMarkerFormat(){return[...this.getPositionFormat(),{type:Int16Array,width:2,name:"aShape"},{type:Uint16Array,width:2,name:"aTexCoord"}]}}class bu{constructor(t){this.x=t.x,this.y=t.y,this.z=t.z||0}clone(){return new bu(this)}I(){return this.P(this.mag()),this}P(t){return this.x/=t,this.y/=t,this.z/=t,this}C(){var t=this.y;return this.y=this.x,this.x=-t,this}mag(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}add(t){return this.clone().m(t)}sub(t){return this.clone().M(t)}m(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}M(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}equals(t){return this.x===t.x&&this.y===t.y&&this.z===t.z}mult(t){return this.clone().k(t)}k(t){return this.x*=t,this.y*=t,this.z*=t,this}dist(t){return Math.sqrt(this.distSqr(t))}distSqr(t){var n=t.x-this.x,e=t.y-this.y,r=t.z-this.z;return n*n+e*e+r*r}T(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}angleTo(t){return Math.atan2(this.y-t.y,this.x-t.x)}}const wu=Math.cos(Math.PI/180*37.5),Mu=Math.pow(2,16)/1,xu=new Ut,Fu=new Ut,Au=new Ut;class ku extends oa{constructor(t,n,e){super(t,n,e);let r=!1;const{lineDasharrayFn:i,lineDashColorFn:s}=this.K;this.hasGradient=this.symbol.lineGradientProperty,i&&(r=function(t,n,e){for(let r=0;r<t.length;r++)if(e(n,t[r].properties))return!0;return!1}(t,this.options.zoom,i),r&&(this.dasharrayFn=i)),this.hasDasharray=_u(this.symbol.lineDasharray)||r,this.hasDasharray&&s&&(this.dashColorFn=s)}createStyledVector(t,n,e,r,i){const s=new Cr(t,n,e,r),o=s.getLineResource();return!this.options.atlas&&o&&(i[o]=[0,0]),s}getFormat(){const{lineWidthFn:t,lineStrokeWidthFn:n,lineStrokeColorFn:e,lineColorFn:r,lineOpacityFn:i,lineDxFn:s,lineDyFn:o,linePatternAnimSpeedFn:a,linePatternGapFn:u}=this.K,h=[...this.getPositionFormat()];if(h.push(this.iconAtlas||this.hasDasharray?{type:Int8Array,width:3,name:"aExtrude"}:{type:Int8Array,width:2,name:"aExtrude"}),h.push({type:this.options.positionType||Uint16Array,width:1,name:"aLinesofar"}),t&&h.push({type:Uint8Array,width:1,name:"aLineWidth"}),n&&h.push({type:Uint8Array,width:1,name:"aLineStrokeWidth"}),r&&h.push({type:Uint8Array,width:4,name:"aColor"}),e&&h.push({type:Uint8Array,width:4,name:"aStrokeColor"}),i&&h.push({type:Uint8Array,width:1,name:"aOpacity"}),this.dasharrayFn&&h.push({type:Uint8Array,width:4,name:"aDasharray"}),this.dashColorFn&&h.push({type:Uint8Array,width:4,name:"aDashColor"}),this.iconAtlas){const t=this.getIconAtlasMaxValue();h.push({type:t>255?Uint16Array:Uint8Array,width:4,name:"aTexInfo"})}return(s||o)&&h.push({type:Int8Array,width:2,name:"aLineDxDy"}),(a||u)&&h.push({type:Int8Array,width:2,name:"aLinePattern"}),h}placeVector(t){const{lineJoinFn:n,lineCapFn:e,lineWidthFn:r,lineHeightFn:i,lineStrokeWidthFn:s,lineStrokeColorFn:o,lineColorFn:a,lineOpacityFn:u,lineDxFn:h,lineDyFn:l,linePatternAnimSpeedFn:c,linePatternGapFn:f}=this.K,p=this.symbol,y=t.feature,m=y.properties;let g=p.lineJoin||"miter",v=p.lineCap||"butt";if(n&&(g=n(this.options.zoom,m)||"miter"),e&&(v=e(this.options.zoom,m)||"butt"),r){let t=r(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLineWidth=1,t=4),hr(t)&&(t=4),this.feaLineWidth=+t}else this.feaLineWidth=+p.lineWidth;if(i){let t=i(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLineHeight=1),hr(t)&&(t=this.feaLineWidth),this.feaLineHeight=+t}else this.feaLineHeight=+p.lineHeight||this.feaLineWidth;if(s){let t=s(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLineStrokeWidth=1,t=0),hr(t)&&(t=0),this.feaLineStrokeWidth=t}else this.feaLineStrokeWidth=p.lineStrokeWidth||0;if(a&&(this.feaColor=a(this.options.zoom,m)||[255,255,255,255],d(this.feaColor)?(this.dynamicAttrs.aColor=1,this.feaColor=[0,0,0,0]):this.feaColor=Mr([],this.feaColor)),o&&(this.feaStrokeColor=o(this.options.zoom,m)||[0,0,0,255],d(this.feaStrokeColor)?(this.dynamicAttrs.aStrokeColor=1,this.feaStrokeColor=[0,0,0,0]):this.feaStrokeColor=Mr([],this.feaStrokeColor)),u){let t=u(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aOpacity=1,t=1),hr(t)&&(t=1),this.feaOpacity=255*t}if(this.dasharrayFn){let t=this.dasharrayFn(this.options.zoom,m)||[0,0,0,0];if(d(t)&&(this.dynamicAttrs.aDasharray=1,t=[0,0,0,0]),t.length<4){const n=t;1===t.length?t=[n[0],n[0],n[0],n[0]]:2===t.length?t=[n[0],n[1],n[0],n[1]]:3===t.length&&(t=[n[0],n[1],n[2],n[2]])}this.feaDash=t}if(this.dashColorFn){let t=(this.dashColorFn?this.dashColorFn(this.options.zoom,m):this.symbol.lineDashColor)||[0,0,0,0];d(t)&&(this.dynamicAttrs.aDashColor=1,t=[0,0,0,0]),t=Mr([],t),this.feaDashColor=t}if(this.iconAtlas){const n=t.getLineResource(),e=this.iconAtlas.glyphMap[n];if(this.feaTexInfo=this.feaTexInfo||[0,0,0,0],e){const{tl:t,displaySize:e}=this.iconAtlas.positions[n];this.feaTexInfo[0]=t[0]+1,this.feaTexInfo[1]=t[1]+1,this.feaTexInfo[2]=e[0]-3,this.feaTexInfo[3]=e[1]-3}else this.feaTexInfo[0]=this.feaTexInfo[1]=this.feaTexInfo[2]=this.feaTexInfo[3]=0}if(h){let t=h(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLineDxDy=1,t=0),hr(t)&&(t=0),this.feaLineDx=t}if(l){let t=l(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLineDxDy=1,t=0),hr(t)&&(t=0),this.feaLineDy=t}if(c){let t=c(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLinePatternAnimSpeed=1,t=0),hr(t)&&(t=0),0!==t&&(this.properties.hasPatternAnim=1),this.feaPatternAnimSpeed=t}if(f){let t=f(this.options.zoom,m);d(t)&&(this.dynamicAttrs.aLinePatternGap=1,t=0),hr(t)&&(t=0),this.feaLinePatternGap=t}const b=this.options.EXTENT;let w=y.geometry;if(b!==1/0){w=[];const t=[];for(let n=0;n<y.geometry.length;n++){t[0]=y.geometry[n];const e=ru(t,-1,-1,b+1,b+1);if(3===y.type&&e.length>1){const t=e[0],n=e[e.length-1];$u(t[0],n[n.length-1])&&(e[0]=n.concat(t.slice(1)),e.length=e.length-1)}w.push(...e)}}const M=this.needAltitudeAttribute()?2:3;for(let t=0;t<w.length;t++)this.offset=this.data.aPosition.length/M,this.St(w[t],y,g,v,2,1.05)}_t(){return this.iconAtlas&&this.feaTexInfo[2]&&this.feaTexInfo[3]}St(t,n,e,r,i,s){const o=this._t()||_u(this.feaDash)||_u(this.symbol.lineDasharray),a=this.options.isTube;a&&(t=t.map(t=>new bu(t))),this.overscaling=1;const u=this.options.EXTENT;if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.prevVertex=null,this.symbol.lineGradientProperty&&n.properties&&lr(n.properties.mapbox_clip_start)&&lr(n.properties.mapbox_clip_end)){this.clipStart=+n.properties.mapbox_clip_start,this.clipEnd=+n.properties.mapbox_clip_end;for(let n=0;n<t.length-1;n++)this.totalDistance+=t[n].dist(t[n+1]);this.updateScaledDistance()}const h=3===n.type&&!t.clipped;let l=t.length;for(;l>=2&&$u(t[l-1],t[l-2]);)l--;let c=0;for(;c<l-1&&$u(t[c],t[c+1]);)c++;if(l<(h?3:2))return;"bevel"===e&&(i=1.05);const f=this.overscaling<=16?15*u/(512*this.overscaling):0,d={vertexLength:0,primitiveLength:0,currentNormal:null};let p,y,m,g,v;this.e1=this.e2=-1,h&&(p=t[l-2],v=t[c].sub(p).I().C());for(let n=c;n<l;n++){if(m=n===l-1?h?t[c+1]:void 0:t[n+1],m&&$u(t[n],m))continue;v&&(g=v),p&&(y=p),p=t[n],m&&p.x===m.x&&p.y===m.y&&(p.x+=1e-4),v=m?m.sub(p).I().C():g,d.dir=y?p.sub(y).I():m.sub(p).I(),g=g||v,d.currentNormal=g;let u=g.add(v);0===u.x&&0===u.y||u.I();const b=g.x*v.x+g.y*v.y,w=u.x*v.x+u.y*v.y,M=0!==w?1/w:1/0,x=2*Math.sqrt(2-2*w),F=w<wu&&y&&m,A=g.x*v.y-g.y*v.x>0;if(!a&&F&&n>c){const t=p.dist(y);if(t>2*f){const n=p.sub(p.sub(y).k(f/t).T());n.z=p.z,this.updateDistance(y,n),this.addCurrentVertex(n,g,0,0,d),y=n}}const k=y&&m;d.middleVertex=k;let P=k?e:h?"butt":r;if(k&&"round"===P&&(M<s?P="miter":M<=2&&(P="fakeround")),"miter"===P&&M>i&&!a&&(P="bevel"),"bevel"===P&&(M>2&&(P="flipbevel"),M<i&&(P="miter")),y&&this.updateDistance(y,p),"miter"===P)a?(this.addCurrentVertex(p,g,0,0,d),d.dir=m.sub(p).I(),this.addCurrentVertex(p,v,0,0,d)):(u.k(M),this.addCurrentVertex(p,u,0,0,d),o&&(d.currentNormal=v,this.addCurrentVertex(p,u,0,0,d)));else if("flipbevel"===P){if(M>100)u=v.mult(-1);else{const t=M*g.add(v).mag()/g.sub(v).mag();u.C().k(t*(A?-1:1))}this.addCurrentVertex(p,u,0,0,d),this.addCurrentVertex(p,u.mult(-1),0,0,d)}else if("bevel"===P||"fakeround"===P){const t=-Math.sqrt(M*M-1),n=A?t:0,e=A?0:t;if(y&&this.addCurrentVertex(p,g,n,e,d),"fakeround"===P){const t=Math.round(180*x/Math.PI/20);for(let n=1;n<t;n++){let e=n/t;if(.5!==e){const t=e-.5;e+=e*t*(e-1)*((1.0904+b*(b*(3.55645-1.43519*b)-3.2452))*t*t+(.848013+b*(.215638*b-1.06021)))}const r=v.sub(g).k(e).m(g).I().k(A?-1:1);this.addHalfVertex(p,r.x,r.y,!1,A,0,d)}}m&&(d.currentNormal=v,this.addCurrentVertex(p,v,-n,-e,d))}else if("butt"===P)this.addCurrentVertex(p,u,0,0,d);else if("square"===P){const t=y?1:-1;this.addCurrentVertex(p,u,t,t,d)}else"round"===P&&(y&&(this.addCurrentVertex(p,g,0,0,d),this.addCurrentVertex(p,g,1,1,d,!0)),m&&(this.addCurrentVertex(p,v,-1,-1,d,!0),this.addCurrentVertex(p,v,0,0,d)));if(!a&&F&&n<l-1){const t=p.dist(m);if(t>2*f){const n=p.add(m.sub(p).k(f/t).T());n.z=p.z,this.updateDistance(p,n),this.addCurrentVertex(n,v,0,0,d),p=n}}}}addCurrentVertex(t,n,e,r,i,s=!1){const o=n.x+n.y*e,a=n.y-n.x*e,u=n.y*r-n.x,h=-n.y-n.x*r;let l=0,c=0;if(i.middleVertex){xu.x=o,xu.y=a,Fu.x=u,Fu.y=h;const t=i.currentNormal;if(l=Iu(t,xu),0===e&&0===r)c=-l;else{const n=Au;n.x=t.x,n.y=t.y,n.k(-1),c=Iu(n,Fu)}}this.addHalfVertex(t,o,a,s,!1,e,i,l),this.addHalfVertex(t,u,h,s,!0,-r,i,c),this.prevVertex&&$u(t,this.prevVertex)||(this.prevVertex=t),this.distance>Mu/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(t,n,e,r,i,s))}addHalfVertex({x:t,y:n,z:e},r,i,s,o,a,u,h){this.fillData(this.data,t,n,e||0,r,i,s,o,1*this.scaledDistance,h);const l=u.vertexLength++;this.e1>=0&&this.e2>=0&&(this.addElements(this.e1,this.e2,l),u.primitiveLength++),o?this.e2=l:this.e1=l}fillData(t,n,e,r,i,s,o,a,u,h){const{lineWidthFn:l,lineStrokeWidthFn:c,lineStrokeColorFn:f,lineColorFn:d,lineOpacityFn:p,lineDxFn:y,lineDyFn:m,linePatternAnimSpeedFn:g,linePatternGapFn:v}=this.K;this.fillPosition(t,n,e,r);let b=63*i;b=(Math.sign(b)||1)*((Math.floor(Math.abs(b))>>1<<1)+ +o);let w=63*s;w=(Math.sign(w)||1)*((Math.floor(Math.abs(w))>>1<<1)+ +a),t.aExtrude.push(b,w),(this.iconAtlas||this.hasDasharray)&&t.aExtrude.push(63*h),t.aLinesofar.push(u),l&&t.aLineWidth.push(Math.round(2*this.feaLineWidth)),c&&t.aLineStrokeWidth.push(Math.round(2*this.feaLineStrokeWidth)),d&&t.aColor.push(...this.feaColor),f&&t.aStrokeColor.push(...this.feaStrokeColor),p&&t.aOpacity.push(this.feaOpacity),this.dasharrayFn&&t.aDasharray.push(...this.feaDash),this.dashColorFn&&t.aDashColor.push(...this.feaDashColor),this.iconAtlas&&t.aTexInfo.push(...this.feaTexInfo),(y||m)&&t.aLineDxDy.push(this.feaLineDx||0,this.feaLineDy||0),(g||v)&&t.aLinePattern.push(127*(this.feaPatternAnimSpeed||0),10*(this.feaLinePatternGap||0)),this.maxPos=Math.max(this.maxPos,Math.abs(n)+1,Math.abs(e)+1)}addElements(t,n,e){super.addElements(this.offset+t,this.offset+n,this.offset+e)}Ot(t){const n=this.options.EXTENT,e=this.elements;for(let r=0;r<e.length;r+=3)n!==1/0&&(Su(this.data.aPosition,e[r],e[r+1],3,n)||Su(this.data.aPosition,e[r+1],e[r+2],3,n))||t.push(e[r],e[r+1],e[r+2])}Et(t){if(t.length<=1)return t;const n=[],e=this.options.EXTENT;let r,i=!0;for(r=0;r<t.length-1;r++){const s=Pu(t[r],t[r+1],e);s&&i||(n.push(t[r]),i=s)}return i||n.push(t[r]),n}updateDistance(t,n){if(this.options.isTube){const e=t.dist(n),r=vr(this.options)*(n.z-t.z);this.distance+=Math.sqrt(e*e+r*r)}else this.distance+=t.dist(n);this.updateScaledDistance()}updateScaledDistance(){this.scaledDistance=this.totalDistance>0?(this.clipStart+(this.clipEnd-this.clipStart)*this.distance/this.totalDistance)*(Mu-1):this.distance}}function Pu(t,n,e){return e!==1/0&&(t.x<0&&n.x<0||t.x>e&&n.x>e||t.y<0&&n.y<0||t.y>e&&n.y>e)}function Su(t,n,e,r,i){if(i===1/0)return!1;const s=Math.floor(.5*t[n*r]),o=Math.floor(.5*t[n*r+1]),a=Math.floor(.5*t[e*r]),u=Math.floor(.5*t[e*r+1]);return s===a&&(s<0||s>i)&&o!==u||o===u&&(o<0||o>i)&&s!==a}function _u(t){if(!Array.isArray(t))return!1;for(let n=0;n<t.length;n++)if(t[n])return!0;return!1}const Ou=new Ut(0,0),Eu=new Ut(0,0);function Iu(t,n){const e=t.mag(),r=n.mag();Ou.x=n.x,Ou.y=n.y;const i=t.angleTo(Eu),s=n.angleTo(Eu);return Math.sign(s-i)*Math.sqrt(r*r-e*e)}function $u(t,n){return t.equals(n)&&t.z===n.z}class Cu extends ku{constructor(t,n,e){super(t,n,e),this.It=e.altitudeProperty}getFormat(){const{lineColorFn:t,lineWidthFn:n}=this.K,e=[{type:this.maxPosZ>=Math.pow(2,15)?Float32Array:Int16Array,width:3,name:"aPosition"},{type:Uint16Array,width:1,name:"aLinesofar"},{type:Uint8Array,width:1,name:"aUp"},{type:Int16Array,width:3,name:"aExtrudedPosition"},{type:Int8Array,width:2,name:"aExtrude"}];return t&&e.push({type:Uint8Array,width:4,name:"aColor"}),n&&e.push({type:Uint8Array,width:1,name:"aLineWidth"}),this.It&&e.push({type:Array,width:1,name:"aLineHeight"}),e}placeVector(t){const n=t.feature;if(this.It){const{altitudeScale:t,altitudeProperty:e,defaultAltitude:r,heightProperty:i,defaultHeight:s,minHeightProperty:o}=this.options,{altitude:a,height:u}=_r(n,t,e,r,i,s,o);this.feaAltitude=a,this.feaMinHeight=(a-u)/a*32767,a>this.maxAltitude&&(this.maxAltitude=a)}return super.placeVector(t)}needAltitudeAttribute(){return!1}St(t,n,e,r,i,s){const o=this.data.aPosition.length/3;super.St(t,n,e,r,i,s);const a=this.data.aPosition.length/3,u=this.data.aPosition.length/3-this.offset;if(3!==n.type&&u>0&&!1!==this.options.side){const t=!1!==this.options.top?1:0,n=t+4;let e=this.data.aPosition.length/3;for(const t in this.data){const n=this.data[t],r=n.length/e;for(let t=0;t<r;t++)n.push(n[o*r+3*r+t])}e=this.data.aPosition.length/3;for(const t in this.data){const r=this.data[t],i=r.length/e;for(let t=0;t<i;t++)r.push(r[o*i+i*n+t])}e=this.data.aPosition.length/3;for(const t in this.data){const r=this.data[t],i=r.length/e;for(let t=0;t<i;t++)r.push(r[o*i+i*(n+3)+t])}super.addElements(t+1,u+1,u),super.addElements(u,u+1,u+2);const r=this.data.aPosition.length/3-this.offset;e=this.data.aPosition.length/3;for(const t in this.data){const n=this.data[t],r=n.length/e;for(let t=0;t<r;t++)n.push(n[a*r-r+t])}e=this.data.aPosition.length/3;for(const t in this.data){const r=this.data[t],i=r.length/e;for(let t=0;t<i;t++)r.push(r[a*i-n*i-i+t])}e=this.data.aPosition.length/3;for(const t in this.data){const r=this.data[t],i=r.length/e;for(let t=0;t<i;t++)r.push(r[a*i-n*i-3*i+t])}super.addElements(r,u-3,r+1),super.addElements(u-3,r+2,r+1)}}fillData(t,n,e,r,i,s,o,a,u){const h=!1!==this.options.top,l=!1!==this.options.side,c=this.feaLineWidth||this.symbol.lineWidth/2*(this.options.EXTENT/this.options.tileSize),f=63*i,d=63*s,p=c*i+n,y=c*s+e;this.$t(t,n,e,i,s,o,a,u,p,y,f,d),l&&(h&&this.$t(t,n,e,i,s,o,a,u,p,y,f,d),this.$t(t,n,e,i,s,o,a,u,p,y,f,d),this.Ct(t,n,e,i,s,o,a,u,p,y,f,d),this.Ct(t,n,e,i,s,o,a,u,p,y,f,d)),this.maxPos=Math.max(this.maxPos,Math.abs(n),Math.abs(e))}$t(t,n,e,r,i,s,o,a,u,h,l,c){const{lineColorFn:f,lineWidthFn:d}=this.K;t.aPosition.push(n,e,32767),t.aLinesofar.push(a),t.aUp.push(+o),t.aExtrudedPosition.push(u,h,1),t.aExtrude.push(l,c),f&&t.aColor.push(...this.feaColor),d&&t.aLineWidth.push(Math.round(2*this.feaLineWidth)),this.It&&t.aLineHeight.push(this.feaAltitude)}Ct(t,n,e,r,i,s,o,a,u,h,l,c){const{lineColorFn:f,lineWidthFn:d}=this.K;t.aPosition.push(n,e,this.feaMinHeight||0),t.aLinesofar.push(a),t.aUp.push(+o),t.aExtrudedPosition.push(u,h,1),t.aExtrude.push(l,c),f&&t.aColor.push(...this.feaColor),d&&t.aLineWidth.push(Math.round(2*this.feaLineWidth)),this.It&&t.aLineHeight.push(this.feaAltitude)}addElements(t,n,e){const r=!1!==this.options.top,i=!1!==this.options.side,s=(r?1:0)+(i?4:0);if(t*=s,n*=s,this.data.aUp[this.offset+(e*=s)+4]){if(r&&super.addElements(n,t,e),i){const t=r?1:0;super.addElements(n+t,e+t,e+t+2),super.addElements(n+t+1,e+t+1+2,n+t+1+2)}}else if(r&&super.addElements(t,e,n),i){const n=r?1:0;super.addElements(t+n,t+n+2,e+n),super.addElements(t+n+1+2,e+n+1+2,e+n+1)}}createDataPack(t,n){this.maxAltitude=0;const e=super.createDataPack(t,n);if(!e)return e;const{data:r,indices:i}=e;this.getFormat().reduce((t,n)=>(t[n.name]={size:n.width},t),{}).aPickingId={size:1};const{aExtrudedPosition:s,aPosition:o,aLinesofar:a,aUp:u,aExtrude:h,aColor:l,aLineHeight:c,aLineWidth:f}=r,d={},p=ne(s,i);let y,m=!0;for(let t=0;t<p.length;t++)p[t]=-p[t],p[t]%1!=0&&(m=!1);if(!1!==this.options.top&&this.symbol.material&&function(t){for(const n in t)if(n.indexOf("Texture")>=0&&t[n])return!0;return!1}(this.symbol.material)&&(y=function(t,n,e){const r=[];for(let i=0;i<t.length;i+=3){const t=n[i/3];r.push(t/256,e[i/3]?1:0)}return r}(s,a,u)),d.aPosition=o,y&&(d.aTexCoord0=new Float32Array(y)),d.aNormal=m?new Int8Array(p):new Float32Array(p),d.aPickingId=r.aPickingId,d.aExtrude=h,l&&(d.aColor=l),f&&(d.aLineWidth=f),c){const t=ir(this.maxAltitude);d.aLineHeight=new t(c)}const g=[];for(const t in d)g.push(d[t].buffer);return e.data=d,e.buffers=g,e}}const Tu=Math.pow(2,16)/1;class zu extends oa{getFormat(){return[...this.getPositionFormat()]}placeVector(t){const n=t.feature,e=3===n.type,r=n.geometry,i=this.elements;e&&(this.elements=[]);const s=this.needAltitudeAttribute()?2:3;for(let t=0;t<r.length;t++)this.offset=this.data.aPosition.length/s,this.St(r[t],n),e&&(this.Ot(i),this.elements=[]);e&&(this.elements=i)}St(t,n){const e=3===n.type;let r=t.length;for(;r>=2&&t[r-1].equals(t[r-2]);)r--;let i,s,o,a=0;for(;a<r-1&&t[a].equals(t[a+1]);)a++;if(!(r<(e?3:2))){this.distance=0,this.vertexLength=0,this.primitiveLength=0,this.e1=this.e2=this.e3=-1,e&&(i=t[r-2]);for(let n=a;n<r;n++)o=e&&n===r-1?t[a+1]:t[n+1],o&&t[n].equals(o)||(i&&(s=i),i=t[n],s&&(this.distance+=i.dist(s)),this.addCurrentVertex(i,this.distance))}}addCurrentVertex(t,n){const e=this.vertexLength++;this.addLineVertex(this.data,t,n),e>=1&&this.addElements(e-1,e),n>Tu&&(this.distance=0,this.addCurrentVertex(t,this.distance))}addLineVertex(t,n){this.fillPosition(t,n.x,n.y,n.z||0),this.maxPos=Math.max(this.maxPos,Math.abs(n.x),Math.abs(n.y))}addElements(t,n){super.addElements(this.offset+t,this.offset+n)}Ot(t){const n=this.options.EXTENT,e=this.elements;for(let r=0;r<e.length;r+=2)Pr(this.data.aPosition,e[r],e[r+1],3,n)||t.push(e[r],e[r+1])}}const Du=45*Math.PI/100;class ju extends oa{getFormat(){const{markerFillFn:t}=this.K;let n;return n="line"===this.symbol.markerRotationAlignment?[...this.getPositionFormat(),{type:Float32Array,width:1,name:"aXYRotation"},{type:Float32Array,width:1,name:"aZRotation"}]:[...this.getPositionFormat()],t&&n.push({type:Uint8Array,width:4,name:"aColor"}),n}placeVector(t){const n=t.feature.properties,{markerFillFn:e}=this.K;let r;e&&(r=e(this.options.zoom,n)||[255,255,255,255],d(r)?(this.dynamicAttrs.aColor=1,r=[0,0,0,0]):r=Mr([],r));const i="line"===this.symbol.markerRotationAlignment,s=this.xt(t,this.symbol.markerSpacing||250,this.symbol.markerPlacement||"point",i);for(let t=0;t<s.length;t++){const n=s[t];this.fillPosition(this.data,n.x,n.y,n.z),i&&(this.data.aXYRotation.push(n.xyRotation||0),this.data.aZRotation.push(n.zRotation||0)),r&&this.data.aColor.push(...r);const e=Math.max(Math.abs(n.x),Math.abs(n.y));e>this.maxPos&&(this.maxPos=e)}}xt(t,n,e,r){const i=t.feature,s=this.options.EXTENT;if("line"===e){const t=[];let e=i.geometry;s&&(e=ru(i.geometry,0,0,s,s));for(let r=0;r<e.length;r++){const i=ou(e[r],n,Du,null,null,24,1,1,s||1/0);t.push.apply(t,i)}return t}return yu(i,e,s,r,this.options.altitudeToTileScale)}hasElements(){return!1}}\n/*!\n     * from @turf/bboxClip\n     * https://github.com/Turfjs/turf\n     * MIT LICENSE\n     */const Uu=[],Nu=[];function Lu(t,n){var e,r,i,s,o,a,u;for(r=1;r<=8;r*=2){for(e=[],s=!(Ru(i=t[t.length-1],n)&r),o=0;o<t.length;o++){if((u=!(Ru(a=t[o],n)&r))!==s){const t=Vu(i,a,r,n);e.push(void 0!==a.x?new Ut(t[0],t[1]):t)}u&&e.push(a),i=a,s=u}if(!(t=e).length)break}return e}function Vu(t,n,e,r){return Uu[0]=void 0===t.x?t[0]:t.x,Uu[1]=void 0===t.y?t[1]:t.y,t=Uu,Nu[0]=void 0===n.x?n[0]:n.x,Nu[1]=void 0===n.y?n[1]:n.y,n=Nu,8&e?[t[0]+(n[0]-t[0])*(r[3]-t[1])/(n[1]-t[1]),r[3]]:4&e?[t[0]+(n[0]-t[0])*(r[1]-t[1])/(n[1]-t[1]),r[1]]:2&e?[r[2],t[1]+(n[1]-t[1])*(r[2]-t[0])/(n[0]-t[0])]:1&e?[r[0],t[1]+(n[1]-t[1])*(r[0]-t[0])/(n[0]-t[0])]:null}function Ru(t,n){Uu[0]=void 0===t.x?t[0]:t.x,Uu[1]=void 0===t.y?t[1]:t.y;var e=0;return(t=Uu)[0]<n[0]?e|=1:t[0]>n[2]&&(e|=2),t[1]<n[1]?e|=4:t[1]>n[3]&&(e|=8),e}const Hu=[0,0,0,0];class Wu extends oa{constructor(...t){super(...t),this.lineElements=[]}createStyledVector(t,n,e,r,i){const s=new Cr(t,n,e,r),o=s.getPolygonResource();return!this.options.atlas&&o&&(i[o]=[0,0]),s}getFormat(){const t=[...this.getPositionFormat()],{polygonFillFn:n,polygonOpacityFn:e,uvScaleFn:r,uvOffsetFn:i,polygonPatternUVFn:s}=this.K;if(this.iconAtlas){const n=this.getIconAtlasMaxValue();t.push({type:n>255?Uint16Array:Uint8Array,width:4,name:"aTexInfo"})}return n&&t.push({type:Uint8Array,width:4,name:"aColor"}),e&&t.push({type:Uint8Array,width:1,name:"aOpacity"}),r&&t.push({type:Uint16Array,width:2,name:"aUVScale"}),i&&t.push({type:Uint8Array,width:2,name:"aUVOffset"}),s&&t.push({type:Float32Array,width:2,name:"aTexCoord"}),t}placeVector(t,n){const e=t.feature;this.Tt(e.geometry,e,n)}Tt(t,n){let e,r,i,s;const{polygonFillFn:o,polygonOpacityFn:a,uvScaleFn:u,uvOffsetFn:h,uvOffsetInMeterFn:l,polygonPatternUVFn:c}=this.K,f=n.properties;o&&(e=o(this.options.zoom,f)||bt([],255,255,255,255),d(e)?(this.dynamicAttrs.aColor=1,e=Hu):e=Mr([],e)),a&&(r=a(this.options.zoom,f),d(r)?(this.dynamicAttrs.aOpacity=1,r=255):(hr(r)&&(r=1),r*=255)),u&&(i=u(this.options.zoom,f),d(i)?(i=[255,255],this.dynamicAttrs.aUVScale=1):(hr(i)&&(i=[1,1]),i=[255*i[0],255*i[1]])),h&&(l&&l(null,f)?s=[0,0]:(s=h(this.options.zoom,f),d(s)?(s=[0,0],this.dynamicAttrs.aUVOffset=1):(hr(s)&&(s=[0,0]),s=[255*s[0],255*s[1]])));const p=!!this.iconAtlas,y=uu(t,500),m=[0,0],g=[0,0];if(p){const{polygonPatternFileFn:t}=this.K,n=t?t(null,f):this.symbol.polygonPatternFile;if(this.iconAtlas.glyphMap[n]){const t=this.iconAtlas.positions[n];m[0]=t.tl[0]+1,m[1]=t.tl[1]+1,g[0]=t.displaySize[0]-3,g[1]=t.displaySize[1]-3}}let v,b=0;c&&(v=c(this.options.zoom,f));const w=this.needAltitudeAttribute()?2:3,M=[-1,-1,n.extent+1,n.extent+1],x=this.zt=this.zt||this.ot.get(),F=this.Dt=this.Dt||this.ot.get();for(let t=0;t<y.length;t++){const n=y[t],o=this.data.aPosition.length/w;x.setLength(0),F.setLength(0);for(let t=0;t<n.length;t++){let o=n[t];if(this.options.EXTENT!==1/0&&0===this.maxPosZ&&(o=Lu(o,M)),0!==o.length){0!==t&&F.push(x.length/3);for(let t=0;t<o.length;t++){const n=o[t].x,a=o[t].y,u=o[t].z||0;if(this.fillPosition(this.data,n,a,u),p&&this.data.aTexInfo.push(m[0],m[1],g[0],g[1]),void 0!==e&&this.data.aColor.push(e[0],e[1],e[2],e[3]),void 0!==r&&this.data.aOpacity.push(r),void 0!==i&&this.data.aUVScale.push(i[0],i[1]),void 0!==s&&this.data.aUVOffset.push(s[0],s[1]),c){if(v){const t=hr(v[2*b])?v[0]:v[2*b],n=hr(v[2*b]+1)?v[1]:v[2*b+1];this.data.aTexCoord.push(t,n)}else this.data.aTexCoord.push(-9999999,-9999999);b++}const h=Math.abs(n),l=Math.abs(a);h>this.maxPos&&(this.maxPos=h),l>this.maxPos&&(this.maxPos=l),x.push(n,a,u)}}}let a=Ne(x,F,3);if(x.length&&!a.length){const t=[];for(let n=0;n<x.length;n+=3)t[n]=x[n],t[n+1]=x[n+2],t[n+2]=x[n+1];if(a=Ne(t,F,3),!a.length){for(let n=0;n<x.length;n+=3)t[n]=x[n+1],t[n+1]=x[n+2],t[n+2]=x[n];a=Ne(t,F,3)}}for(let t=0;t<a.length;t+=3)this.addElements(o+a[t],o+a[t+1],o+a[t+2])}}}const qu=[{type:Int16Array,width:3,name:"aPosition"}];class Gu extends oa{getFormat(){return qu}placeVector(t,n){const e=this.xt(t,n);if(0===e.length)return;const r=this.data,i=this.getAltitude(t.feature.properties);let s=r.aPosition.length/qu[0].width;for(let t=0;t<e.length;t++){const n=e[t];r.aPosition.push(2*n.x+0,2*n.y+0,i),r.aPosition.push(2*n.x+1,2*n.y+0,i),r.aPosition.push(2*n.x+1,2*n.y+1,i),r.aPosition.push(2*n.x+0,2*n.y+1,i),this.addElements(s,s+1,s+2),this.addElements(s,s+2,s+3),s+=4;const o=Math.max(Math.abs(2*n.x+1),Math.abs(2*n.y+1));o>this.maxPos&&(this.maxPos=o)}}xt(t,n){const{feature:e,symbol:r}=t,i=this.Pt(t,r),s=e.properties,{markerSpacingFn:o}=this.K,a=((o?o(null,s):r.markerSpacing)||250)*n;return pu(t,null,null,n,this.options.EXTENT,i,a)}Pt(t,n){return this.K.markerPlacementFn?this.K.markerPlacementFn(this.options.zoom,t.feature.properties):n.markerPlacement}}class Bu extends ku{constructor(t,n,e){(n=ur({},n)).lineJoin="miter",n.lineCap="butt",super(t,n,e),this.options.radialSegments%2==1&&this.options.radialSegments--}getFormat(){const{lineWidthFn:t,lineColorFn:n,lineOpacityFn:e,linePatternAnimSpeedFn:r,linePatternGapFn:i}=this.K,s=[...this.getPositionFormat(),{type:Int8Array,size:4,name:"aTubeNormal"},{type:this.options.positionType||Uint16Array,width:1,name:"aLinesofar"}];if(this.iconAtlas){s.push({type:Int8Array,width:1,name:"aNormalDistance"});const t=this.getIconAtlasMaxValue();s.push({type:t>255?Uint16Array:Uint8Array,width:4,name:"aTexInfo"})}return t&&s.push({type:Uint16Array,width:1,name:"aLineWidth"}),n&&s.push({type:Uint8Array,width:4,name:"aColor"}),e&&s.push({type:Uint8Array,width:1,name:"aOpacity"}),r&&s.push({type:Int8Array,width:1,name:"aLinePatternAnimSpeed"}),i&&s.push({type:Int8Array,width:1,name:"aLinePatternGap"}),s}addHalfVertex(t,n,e,r,i,s,o,a){const{x:u,y:h,z:l}=t,c=1*this.scaledDistance,f=this.options.radialSegments/2,{x:d,y:p,z:y}=o.dir,m=function(t,n,e,r,i,s,o,a){ft(Ju,e,r,i),ft(Xu,s,o,0),mt(Yu,Ju,Xu),pt(Xu,Xu),pt(Yu,Yu),Zu[n]||(Zu[n]=[]);const u=Zu[n];for(var h=0;h<n;h++){const t=Math.PI*h/n,e=1-Math.abs(t-0)/(Math.PI/2);u[h]=u[h]||[],Ku(Xu,Yu,u[h],1,t,e*(a?-1:1))}return u}(0,f,d,p,y,n,e,i);this.prevVertex&&this.fillTubeElements(i),this.fillData(this.data,u,h,l||0,m,i,c,a)}fillTubeElements(t){const n=this.options.radialSegments/2,e=this.needAltitudeAttribute()?2:3,r=this.data.aPosition.length/e;for(let e=0;e<n;e++){const i=e+r-2*n;let s,o;e===n-1&&t?(s=e+r-2*n+1,o=e+r-2*n-2*n+1):(s=e+r+1,o=e+r+1-2*n),super.addElements(e+r-this.offset,s-this.offset,i-this.offset),super.addElements(i-this.offset,s-this.offset,o-this.offset)}}fillData(t,n,e,r,i,s,o,a){const{lineWidthFn:u,lineColorFn:h,lineOpacityFn:l,linePatternAnimSpeedFn:c,linePatternGapFn:f}=this.K,d=i.length;for(let s=0;s<d;s++){if(this.fillPosition(t,n,e,r),Mt(i[s],i[s],63),t.aTubeNormal.push(...i[s]),t.aLinesofar.push(o),this.iconAtlas&&(t.aNormalDistance.push(63*a),t.aTexInfo.push(...this.feaTexInfo)),u){const n=br(this.options.metric);let e=this.feaLineWidth*n;isNaN(e)&&(e=0),t.aLineWidth.push(Math.round(e))}h&&t.aColor.push(...this.feaColor),l&&t.aOpacity.push(this.feaOpacity),c&&t.aLinePatternAnimSpeed.push(127*(this.feaPatternAnimSpeed||0)),f&&t.aLinePatternGap.push(10*(this.feaLinePatternGap||0))}this.maxPos=Math.max(this.maxPos,Math.abs(n)+1,Math.abs(e)+1)}createDataPack(t,n){const e=super.createDataPack(t,n);return e&&(e.is2D=!1),e}}const Ju=[],Xu=[],Yu=[],Zu={};function Ku(t,n,e,r,i,s){return bt(e,r*(Math.cos(i)*t[0]+Math.sin(i)*n[0]),r*(Math.cos(i)*t[1]+Math.sin(i)*n[1]),r*(Math.cos(i)*t[2]+Math.sin(i)*n[2]),s),e}class Qu extends Bu{addHalfVertex(t,n,e,r,i,s,o,a){const{x:u,y:h,z:l}=t,c=1*this.scaledDistance,{x:f,y:d,z:p}=o.dir,y=function(t,n,e,r,i,s,o,a){ft(nh,e,r,i),ft(eh,s,o,0),mt(rh,nh,eh),pt(eh,eh),pt(rh,rh),_t(th,t,n);const u=Et(th)/t,h=Math.atan(n/t);let l=Math.PI/2+(Math.PI/2-h);return ih[0]||(ih[0]=[]),Ku(eh,rh,ih[0],u,l,a?1:-1),l+=2*h,ih[1]||(ih[1]=[]),Ku(eh,rh,ih[1],u,l,a?1:-1),ih}(this.feaLineWidth,this.feaLineHeight,f,d,p,n,e,i);this.prevVertex&&this.fillTubeElements(i),this.fillData(this.data,u,h,l||0,y,i,c,a)}}const th=[],nh=[],eh=[],rh=[],ih=[];class sh{constructor(t){this.max=t,this.reset()}reset(){return this.data={},this.order=[],this}clear(){this.reset()}add(t,n){return this.has(t)?(this.order.splice(this.order.indexOf(t),1),this.data[t]=n,this.order.push(t)):(this.data[t]=n,this.order.push(t),this.order.length>this.max&&this.getAndRemove(this.order[0])),this}has(t){return t in this.data}keys(){return this.order}getAndRemove(t){if(!this.has(t))return null;const n=this.data[t];return delete this.data[t],this.order.splice(this.order.indexOf(t),1),n}get(t){return this.has(t)?this.data[t]:null}remove(t){return this.has(t)?(delete this.data[t],this.order.splice(this.order.indexOf(t),1),this):this}setMaxSize(t){for(this.max=t;this.order.length>this.max;)this.getAndRemove(this.order[0]);return this}}\n/*!\n     * based on @mapbox/tiny-sdf\n     * https://github.com/mapbox/tiny-sdf\n     * @License BSD 2-Clause\n     */var oh=1e20;function ah(t,n,e,r,i,s,o){this.fontSize=t||24,this.buffer=void 0===n?3:n,this.cutoff=r||.25,this.fontFamily=i||"sans-serif",this.fontWeight=s||"normal",this.fontStyle=o||"normal",this.radius=e||8;var a=this.size=this.fontSize+2*this.buffer;this.canvas="undefined"==typeof document?new OffscreenCanvas(a,a):document.createElement("canvas"),this.canvas.width=this.canvas.height=a,this.ctx=this.canvas.getContext("2d",{willReadFrequently:!0}),this.ctx.font=this.fontStyle+" "+this.fontWeight+" "+this.fontSize+"px "+this.fontFamily,this.ctx.textBaseline="middle",this.ctx.fillStyle="black",this.gridOuter=new Float64Array(a*a),this.gridInner=new Float64Array(a*a),this.f=new Float64Array(a),this.z=new Float64Array(a+1),this.v=new Uint16Array(a),this.middle=Math.round(a/2*(navigator.userAgent.indexOf("Gecko/")>=0?1.2:1))}function uh(t,n,e,r,i,s){for(var o=0;o<n;o++)hh(t,o,n,e,r,i,s);for(var a=0;a<e;a++)hh(t,a*n,1,n,r,i,s)}function hh(t,n,e,r,i,s,o){var a,u,h,l;for(s[0]=0,o[0]=-oh,o[1]=oh,a=0;a<r;a++)i[a]=t[n+a*e];for(a=1,u=0,h=0;a<r;a++){do{h=(i[a]-i[l=s[u]]+a*a-l*l)/(a-l)/2}while(h<=o[u]&&--u>-1);s[++u]=a,o[u]=h,o[u+1]=oh}for(a=0,u=0;a<r;a++){for(;o[u+1]<a;)u++;t[n+a*e]=i[l=s[u]]+(a-l)*(a-l)}}ah.prototype.draw=function(t,n,e){this.ctx.clearRect(0,0,this.size,this.size),this.ctx.textBaseline="top",this.ctx.fillText(t,this.buffer,this.buffer);for(var r=this.ctx.getImageData(0,0,n,e),i=new Uint8ClampedArray(n*e),s=0;s<n*e;s++){var o=r.data[4*s+3]/255;this.gridOuter[s]=1===o?0:0===o?oh:Math.pow(Math.max(0,.5-o),2),this.gridInner[s]=1===o?oh:0===o?0:Math.pow(Math.max(0,o-.5),2)}for(uh(this.gridOuter,n,e,this.f,this.v,this.z),uh(this.gridInner,n,e,this.f,this.v,this.z),s=0;s<n*e;s++){var a=Math.sqrt(this.gridOuter[s])-Math.sqrt(this.gridInner[s]);i[s]=Math.round(255-255*(a/this.radius+this.cutoff))}return i};let lh=0;class ch{constructor(t,n=15,e){this.entries={},this.jt={},this.Ut=new sh(2048,(function(){})),this.Nt=t,this.Lt=n,this.Vt=e}getGlyphs(t,n){if(!t||!Object.keys(t).length)return void n(null,{glyphs:null});const e=this.entries,r=t.options;let i=!0;r&&(i=!1!==r.isCharsCompact),i=i||this.Vt;const s=(r,s,a)=>{let u=0,h=0;for(const n in t)if("options"!==n){e[n]=e[n]||{},s[n]=s[n]||{};for(const l in t[n]){if(h++,h<=r)continue;const t=n.split(" "),c=i&&"normal"===t[0]&&!Na(+l),f=n+":"+l+":"+c;let d;if(this.Ut.has(f)?d=this.Ut.get(f):(d=this.Rt(e[n],t,l,c),this.Ut.add(f,d),u++),d=fh(d),s[n][l]=d,a.push(d.bitmap.data.buffer),this.Nt&&u>this.Lt)return void this.Nt(o(h,s,a))}}n(null,{glyphs:s,buffers:a})};function o(t,n,e){return()=>{s(t,n,e)}}s(0,{},[])}Rt(t,n,e,r){const i=n[0],s=n[1],o=n.slice(3).join(" ");let a=t.tinySDF,u="normal"!==i?5:2;const h=r?-1:2;if(!a){let n="400";/bolder/i.test(s)?n="1000":/bold/i.test(s)?n="900":/medium/i.test(s)?n="500":/light/i.test(s)&&(n="200"),a=t.tinySDF=new ah(24,u,8,.25,o,n,i)}const l=String.fromCharCode(e),c=a.ctx.measureText(l),f=Math.round(c.width),d=a.draw(String.fromCharCode(e),f+2*u,24+2*u);if(lh<4){const t="undefined"!=typeof document&&document.getElementById("sdf-debug-"+lh++);t&&(t.width=f+2*u,t.height=a.canvas.height,t.getContext("2d").drawImage(a.canvas,0,0))}return{charCode:e,bitmap:{width:f+2*u,height:24+2*u,data:d},metrics:{width:f,height:24,left:1,top:-u,advance:f+u+h}}}}function fh(t){const n={width:t.bitmap.width,height:t.bitmap.height,data:new Uint8ClampedArray(t.bitmap.data)};return{charCode:t.charCode,bitmap:n,metrics:ur({},t.metrics)}}var dh=Object.freeze({__proto__:null,clipPolygon:Lu,calculateSignedArea:kr,getFeaAltitudeAndHeight:_r,generatePickingIndiceIndex:$r,convertRTLText:Qa,packPosition:Tr,unpackPosition:function(t,n,e,r){const i=(Math.sign(n)||1)*(Math.abs(n)%zr),s=(Math.sign(e)||1)*(Math.abs(e)%zr),o=Math.floor(Math.abs(n)/zr),a=Math.floor(Math.abs(e)/zr);return t[0]=i,t[1]=s,t[2]=Math.sign(r+1e-5)*(2*o+a)*Dr+r,t},convertGeometry:ar,getPosArrayType:ir,getUnsignedArrayType:sr,getIndexArrayType:rr});const ph={},yh={},mh=[];Object.freeze({__proto__:null,loadSymbolFnTypes:function t(n,e){if(!n)return null;var r=!1;if(Array.isArray(n)){var i,s=[];for(let o=0;o<n.length;o++)(i=t(n[o],e))?(s.push(i),r=!0):s.push(n[o]);return r?s:n}var o={__fn_types_loaded:!0};const a=[];for(const t in n)yr(n,t)&&a.push(t);const u=function(t){Object.defineProperty(o,t,{get:function(){return this["__fn_"+t]||(this["__fn_"+t]=p(this["_"+t])),this["__fn_"+t].apply(this,e())},set:function(n){this["_"+t]=n},configurable:!0,enumerable:!0})},h={},l=function(t,n){Object.defineProperty(o,t,{get:function(){this["__fn_"+t]||(this["__fn_"+t]=Lo(this["_"+t],n));const r=e()[0];h.zoom=r;try{return this["__fn_"+t].evaluateWithoutErrorHandling(h,ph,yh,null,mh)}catch(t){return null}},set:function(n){this["_"+t]=n},configurable:!0,enumerable:!0})};for(let t=0,e=a.length;t<e;t++){const e=a[t];if(d(n[e]))r=!0,o["_"+e]=n[e],u(e);else if(Vo(n[e])){r=!0;const t=Go(e);o["_"+e]=n[e],l(e,t)}else o[e]=n[e]}return r?o:n}});const gh={polygonPatternFile:1,markerFile:1,markerPlacement:1,markerSpacing:1,textName:1,textStyle:1,textFaceName:1,textWeight:1,textPlacement:1,textSpacing:1,lineJoin:1,lineCap:1,linePatternFile:1};Object.assign({visible:1,textHorizontalAlignment:1,textVerticalAlignment:1,textWrapWidth:1,markerHorizontalAlignment:1,markerVerticalAlignment:1},gh),Object.assign({lineDasharray:1,topPolygonFill:1,bottomPolygonFill:1},gh);new Float32Array([-1e12])[0];const vh="maptalks_ombb";function bh(t,n,e,r,i,s,o,a,u,h,l,c,f,d,p,y,m){const g=n.length,v=i/3;for(let e=2,r=g;e<r;e+=3)t[i+e-2]=n[e-2],t[i+e-1]=n[e-1],t[i+e-0]=n[e]-o;i+=g;for(let e=2,r=g;e<r;e+=3)t[i+e-2]=n[e-2],t[i+e-1]=n[e-1],t[i+e-0]=n[e]-a;i+=g,t.trySetLength(i+g),t.copyWithin(i,i-2*g,i-g),i+=g,t.trySetLength(i+g),t.copyWithin(i,i-2*g,i-g),i+=g,(e=e||[]).push(g/3);for(let n=0;n<e.length;n++){wh(v+(e[n-1]||0),v+e[n],t,g/3,u,r,h,l,c,f,s,d,p,y,m)}return i}function wh(t,n,e,r,i,s,o,a,u,h,l,c,f,d,p){const y=s.length;let m,g;for(let o=t,a=n;o<a-1;o++)m=o,g=o+1,i!==1/0&&at(e,m,g,i)||((o-t)%2==1&&(m+=2*r,g+=2*r),p?(s.push(m+r,g,m),s.push(g+r,g,m+r)):(s.push(m+r,m,g),s.push(g,g+r,m+r)));o&&function(t,n,e,r,i,s,o,a,u,h,l){let c,f=0,d=0,p=0,y=0;const m=l?[1,3,4]:[2,3,4];for(let l=s.length-1;l>=0;l--){const g=s[l],v=3*g+1,b=3*g+2,w=i[3*g],M=i[v],x=i[b];f||d||(f=Math.max(i[b],i[3*s[l-3]+2]),d=Math.min(i[b],i[3*s[l-3]+2]),c=f-d);let F=p;const A=l%6;0===t?(5===A&&(y=jt(i,s,l,w,M)),F=A===m[0]||A===m[1]||A===m[2]?p:p+y):1===t&&(A===m[0]||A===m[1]||A===m[2]?F=0:5===A?(y=jt(i,s,l,w,M),F=y):F=y);const k=F/u*(1/(100*h))/o;let P;P=1===n?x===f?1:0:"bottom"===e?x===f?c/100/a:0:x===f?0:-c/100/a,r[2*g]=k,r[2*g+1]=P,0===A&&(p+=y)}}(a,u,h,l,e,s.slice(y,s.length),c[0],c[1],f,d,p)}function Mh(t){const n=[t[0]];let e=t[0];for(let r=1;r<t.length;r++)Array.isArray(t[r])?t[r][0]===e[0]&&t[r][1]===e[1]&&t[r][2]===e[2]||n.push(t[r]):t[r].x===e.x&&t[r].y===e.y&&t[r].z===e.z||n.push(t[r]),e=t[r];return n}const xh=Qo.getInstance();function Fh(t,n,e,r,i,s,o,a,u,h,l,c,f,m,g,v){void 0===n.top&&(n.top=!0),void 0===n.side&&(n.side=!0),xh.reset();const{altitudeScale:b,altitudeProperty:w,defaultAltitude:M,heightProperty:F,minHeightProperty:A,defaultHeight:k,tangent:_,uv:O,topUVMode:E,sideUVMode:I,sideVerticalUVMode:$,top:C,side:T,textureYOrigin:z,topThickness:D}=n,j=!!v,U=function(t,n,{altitudeScale:e,altitudeProperty:r,defaultAltitude:i,heightProperty:s,minHeightProperty:o,defaultHeight:a},{center:u,side:h,top:l,topThickness:c,uvOrigin:f,uv:d,uvSize:p,topUVMode:y,sideUVMode:m,sideVerticalUVMode:g,textureYOrigin:v,tileRatio:b,centimeterToPoint:w,verticalCentimeterToPoint:M,positionType:F,res:A,glScale:k,projectionCode:S},_,O){let E=n/t[0].extent;n===1/0&&(E=1);const I=n===1/0,$=O.get(),C=O.get(),T=O.get(),z=O.get(),D=O.get(),j=O.get(),U=O.get(),N=!!d,L=!!l,V=!!h,R=N?O.get():null;function H(t,e,r,i,s,o){let a=e;if(L){const i=Ne(z,r,3);if(0===i.length)return e;if(P(D,z),e+=z.length,o)for(let n=2,e=i.length;n<e;n+=3)i[n]+=t/3,i[n-1]+=t/3,i[n-2]+=t/3;else{let n;for(let e=2,r=i.length;e<r;e+=3)n=i[e-1],i[e-1]=i[e]+t/3,i[e]=n+t/3,i[e-2]+=t/3}P(j,i),N&&zt(y||0,t,e,R,D,f,w,b,p[0],p[1],s,A,k,S,u),c>0&&!V&&(e=bh(D,z,r,j,e,R,0,c,n,N,m||0,g||0,v,p,b,M,o)),U.setLength(e/3),U.fill(1,a/3,e/3)}if(V){L&&(c=0),a=e,e=bh(D,z,r,j,e,R,c,i,n,N,m||0,g||0,v,p,b,M,o),U.setLength(e/3);const t=z.length/3;U.fill(1,a/3,a/3+t),U.fill(0,a/3+t,a/3+2*t),U.fill(1,a/3+2*t,a/3+3*t),U.fill(0,a/3+3*t,e/3)}return e}let W=0,q=0;const G=[-1,-1,n+1,n+1];let B=0,J=t.length;x(_)&&(B=_,J=_+1);let X=0,Y=!1;const Z=O.get();for(;B<J;B++){const u=t[B],h=u.id;x(h)&&(Math.abs(h)>X&&(X=Math.abs(h)),h<0&&(Y=!0));const l=u.geometry,c=u.properties[vh];let f=Array.isArray(c&&c[0]&&c[0][0])?c[0]:c;const{altitude:d,height:p}=dh.getFeaAltitudeAndHeight(u,e,r,i,s,a,o);W=Math.max(Math.abs(d),W);const y=D.length;let m=0,g=q;Z.setLength(0),z.setLength(0);const v=dh.calculateSignedArea(l[0])<0;for(let t=0,e=l.length;t<e;t++){let r=l[t];v&&(r=r.reverse()),r=Mh(r);const i=dh.calculateSignedArea(r)<0;if(!i&&t>0&&(m++,f=c&&c[m],q=H(g,q,Z,p*E,f,I),z.setLength(0),Z.setLength(0),g=q),n!==1/0&&(r=dh.clipPolygon(r,G)),!r.length){t===e-1&&(q=H(g,q,Z,p*E,f,I));continue}const s=r.length;Array.isArray(r[0])?r[0][0]===r[s-1][0]&&r[0][1]===r[s-1][1]||r.push([r[0][0],r[0][1]]):r[0].x===r[s-1].x&&r[0].y===r[s-1].y||r.push(r[0]),i&&Z.push(z.length/3),ot(z,z.length,r,E,d,!1,F),t===e-1&&(q=H(g,q,Z,p*E,f,I))}const b=D.length-y,w="__fea_idx".trim();for(let t=0;t<b/3;t++)C.push(void 0===u[w]?B:u[w]),$.push(B),x(h)&&T.push(h)}const K=dh.getUnsignedArrayType(C.length?C[C.length-1]:0),Q={maxAltitude:W,vertices:D,verticeTypes:U,indices:j,pickingIds:Qo.createTypedArray(C,K),featureIndexes:$};if(T.length){const t=Y?dh.getPosArrayType(X):dh.getUnsignedArrayType(X);Q.featureIds=Qo.createTypedArray(T,t)}else Q.featureIds=[];return R&&(R.setLength(D.length/3*2),Q.uvs=R),Q}(t,e,{altitudeScale:b,altitudeProperty:w,defaultAltitude:M||0,heightProperty:F,minHeightProperty:A,defaultHeight:k||0},{center:v,top:C,side:T,topThickness:10*D||0,uv:O||_,uvSize:[i,i],uvOrigin:r,topUVMode:E,sideUVMode:I,sideVerticalUVMode:$,textureYOrigin:z,tileRatio:a,centimeterToPoint:u,verticalCentimeterToPoint:h,positionType:g,res:s,glScale:o,projectionCode:f},m,xh),N=[],L=U.vertices.length/3,V=dh.getIndexArrayType(L),R=Qo.createTypedArray(U.indices,V);delete U.indices,N.push(R.buffer,U.pickingIds.buffer);const H=_?xh.get():new Float32Array(3*L);H.setLength&&H.setLength(3*L);const W=ne(U.vertices,R,H);let q=!0;for(let t=0;t<W.length;t++){j||(W[t]=-W[t]);const n=W[t]%1;1-Math.abs(n)>1e-6?q=!1:0!==n&&(W[t]=Math.round(W[t]))}if(U.normals=W,_){let t=xh.get();t.setLength(4*L),t=function(t,n,e,r,i){const s=t.length/3,o=i||new Array(4*s),a=[],u=[];for(let t=0;t<s;t++)a[t]=[0,0,0],u[t]=[0,0,0];const h=[0,0,0],l=[0,0,0],c=[0,0,0],f=[0,0],d=[0,0],p=[0,0],y=[0,0,0],m=[0,0,0];function g(n,r,i){le(h,t,3*n),le(l,t,3*r),le(c,t,3*i),ce(f,e,2*n),ce(d,e,2*r),ce(p,e,2*i);const s=l[0]-h[0],o=c[0]-h[0],g=l[1]-h[1],v=c[1]-h[1],b=l[2]-h[2],w=c[2]-h[2],M=d[0]-f[0],x=p[0]-f[0],F=d[1]-f[1],A=p[1]-f[1],k=1/(M*A-x*F);ft(y,(A*s-F*o)*k,(A*g-F*v)*k,(A*b-F*w)*k),ft(m,(M*o-x*s)*k,(M*v-x*g)*k,(M*w-x*b)*k),dt(a[n],a[n],y),dt(a[r],a[r],y),dt(a[i],a[i],y),dt(u[n],u[n],m),dt(u[r],u[r],m),dt(u[i],u[i],m)}for(let t=0,n=r.length;t<n;t+=3)g(r[t+0],r[t+1],r[t+2]);const v=[],b=[],w=[],M=[];let x,F,A;function k(t){le(w,n,3*t),ct(M,w),F=a[t],ct(v,F),gt(v,v,function(t,n,e){return t[0]=n[0]*e,t[1]=n[1]*e,t[2]=n[2]*e,t}(w,w,yt(w,F))),pt(v,v),mt(b,M,F),A=yt(b,u[t]),x=A<0?-1:1,o[4*t]=v[0],o[4*t+1]=v[1],o[4*t+2]=v[2],o[4*t+3]=x}for(let t=0,n=r.length;t<n;t+=3)k(r[t+0]),k(r[t+1]),k(r[t+2]);return o}(U.vertices,U.normals,U.uvs,R,t),t=function(t,n){const e=new Float32Array(n.length),r=[],i=[],s=[];for(let o=0;o<n.length;o+=4){const a=o/4*3;ft(i,t[a]||0,t[a+1]||0,t[a+2]||0),bt(r,n[o]||0,n[o+1]||0,n[o+2]||0,n[o+3]||0),Qn(s,i,r),vt(e.subarray(o,o+4),s)}return e}(U.normals,t),U.tangents=t,N.push(t.buffer),delete U.normals}if(U.normals&&(q&&(U.normals=Qo.createTypedArray(U.normals,Int8Array)),N.push(U.normals.buffer)),U.uvs){const t=U.uvs;U.uvs=Qo.createTypedArray(t,Float32Array),N.push(U.uvs.buffer)}if(v){const t=U.vertices;for(let n=0;n<t.length;n+=3)t[n]-=v[0],t[n+1]-=v[1]}const G=g||dh.getPosArrayType(Math.max(512,U.maxAltitude)),B=function(t,n,e,r){const i={},s={};if(S(n.polygonFill)){let o=y(n.polygonFill);const a=new Uint8Array(4*r.length);a.fill(255);for(let n=0;n<r.length;n++){const s=t[r[n]],u=s.properties||{};u.$layer=s.layer,u.$type=s.type;let h=o(e,u);d(h)&&(i.aColor=1,o=y(h),h=o(e,u)),delete u.$layer,delete u.$type,Ar.normalizeColor(Ah,h),a[4*n]=Ah[0],a[4*n+1]=Ah[1],a[4*n+2]=Ah[2],a[4*n+3]=Ah[3]}s.aColor=a}if(S(n.polygonOpacity)){let o=p(n.polygonOpacity);const a=new Uint8Array(r.length);a.fill(255);for(let n=0;n<r.length;n++){const s=t[r[n]],u=s.properties||{};u.$layer=s.layer,u.$type=s.type;let h=o(e,u);d(h)&&(i.aOpacity=1,o=y(h),h=o(e,u)),delete u.$layer,delete u.$type,a[n]=255*h}s.aOpacity=a}return s.dynamicAttributes=i,s}(t,l,c,U.featureIndexes),J=function(t,n,e,r,i){const s=[[],[]],o=S(r.topPolygonFill),a=S(r.bottomPolygonFill),u=[255,255,255,255];if(o||a){let h=o&&y(r.topPolygonFill),l=a&&y(r.bottomPolygonFill),c=null,f=null,p=null,m=null;for(let r=0;r<n.length;r++){if(1===t[r]&&!o||0===t[r]&&!a)continue;const g=1===t[r];if(g&&n[r]===c){t[r]=p;continue}if(!g&&n[r]===f){t[r]=m;continue}const v=e[n[r]],b=v.properties||{};b.$layer=v.layer,b.$type=v.type;let w=g?h:l,M=w(i,b);d(M)&&(w=y(M),M=w(i,b)),delete b.$layer,delete b.$type,Ar.normalizeColor(Ah,M),wt(Ah,Ah,u);let x=kh(s,Ah);x<0&&(x=s.length,s.push(vt([],Ah))),t[r]=x,g?(c=n[r],p=x):(f=n[r],m=x)}}return s.slice(2)}(U.verticeTypes,U.featureIndexes,t,l,c),X={data:{data:{aVertexColorType:J.length<=252?Qo.createTypedArray(U.verticeTypes,Uint8Array):Qo.createTypedArray(U.verticeTypes,Uint16Array),aPosition:Qo.createTypedArray(U.vertices,G),aNormal:U.normals,aTexCoord0:U.uvs,aTangent:U.tangents,aPickingId:U.pickingIds},indices:R,properties:{maxAltitude:U.maxAltitude},dynamicAttributes:B.dynamicAttributes,vertexColors:J},buffers:N};return U.featureIds.length?(X.data.featureIds=U.featureIds,N.push(X.data.featureIds.buffer)):X.data.featureIds=[],B.aColor&&(X.data.data.aColor=B.aColor,X.buffers.push(B.aColor.buffer)),B.aOpacity&&(X.data.data.aOpacity=B.aOpacity,X.buffers.push(B.aOpacity.buffer)),X.buffers.push(X.data.data.aPosition.buffer),X.data.pickingIdIndiceMap=dh.generatePickingIndiceIndex(X.data.data.aPickingId,X.data.indices),X}const Ah=[];function kh(t,n){for(let e=0;e<t.length;e++)if(xt(n,t[e]))return e;return-1}function Ph(t,n,e,r,{altitudeScale:i,altitudeProperty:s,defaultAltitude:o,heightProperty:a,minHeightProperty:u,defaultHeight:h,bottom:l}){const c=l,f=n/t[0].extent,p=2*function(t,n){let e=0;for(let r=0,i=t.length;r<i;r++){const i=t[r];if(x(i.geometry[0][0])){const t=3*i.geometry.length;e+=n?2*t-6:t}else for(let t=0,r=i.geometry.length;t<r;t++){let r=3*i.geometry[t].length;3===i.type&&(r-=3),e+=n?2*r-6:r}}return e}(t)+3*t.length*2,y=[],m=new Int16Array(p),g=new Uint8Array(m.length/3*4);d(e)&&(e=Bo.compileFilter(e));const v=[];function b(t,e,r){const i=e-t,s=m.subarray(t,e),o=m.subarray(e,e+i);o.set(s);for(let t=2,n=o.length;t<n;t+=3)o[t]=s[t]-r;const a=t/3,u=i/3;let h,l;for(let t=a,e=u+a;t<e;t++)t<e-1?(h=t,l=t+1):(h=t,l=a),at(m,h,l,n)||(v.push(h,l),c&&v.push(h+u,l+u),Sh(m,h,n)||v.push(h,h+u));return e+i}let w=0,M=0;const F="__fea_idx".trim(),A=[];for(let n=0,l=t.length;n<l;n++){const l=t[n],c=l.geometry;if(e){let t;t="function"==typeof e?e(l&&l.properties):e,Ar.normalizeColor(A,t)}else ft(A,255,255,255);const d=w/3*4,{altitude:p,height:x}=dh.getFeaAltitudeAndHeight(l,i,s,o,a,h,u);M=Math.max(Math.abs(p),M);let k=w;for(let t=0,n=c.length;t<n;t++){let n=c[t];const e=n.length;n[0][0]===n[e-1][0]&&n[0][1]===n[e-1][1]&&(n=n.slice(0,e-1)),w=ot(m,k,n,f,p),w=b(k,w,x*f),k=w}const P=k/3*4;for(let t=d;t<P;t+=4)g[t]=A[0],g[t+1]=A[1],g[t+2]=A[2],g[t+3]=255*(r||1);const S=v.length-y.length;for(let t=0;t<S;t++)y.push(l[F])}const k=v.reduce((t,n)=>Math.max(t,n),0),P=new(dh.getIndexArrayType(k))(v),S=dh.getUnsignedArrayType(t.length);return{aPosition:new(dh.getPosArrayType(Math.max(512,M)))(m),indices:P,aPickingId:new S(y),aColor:g}}function Sh(t,n,e){const r=t[3*n],i=t[3*n+1];return r<0||r>e||i<0||i>e}function _h(t,n,e,r){const i=Ph(t,n,e.lineColor,e.lineOpacity,r),s=[i.aPosition.buffer,i.indices.buffer,i.aPickingId.buffer],o=i.indices;return delete i.indices,{data:{data:i,indices:o},buffers:s}}let Oh=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),Oh=!0}catch(t){Oh=!1}var Eh=Oh;const Ih="__original_properties",$h="__fn-type_properties";class Ch{constructor(t,n,e,r,i){this.id=t,this.options=n,this.upload=e,this.Ht(n.style),this.requests={},this.Ut=r,this.Wt=0,this.loadings=i}updateStyle(t,n){this.options.style=t,this.Wt=t.styleCounter,this.Ht(t),n()}updateOptions(t,n){this.options=w(this.options,t),n()}loadTile(t,n){const e=this.loadings,r=t.tileInfo.url,i=this.options.debugTile;if(i){const{x:e,y:r,z:s}=t.tileInfo;let o=!1;for(let t=0;t<i.length;t++)if(e===i[t].x&&r===i[t].y&&s===i[t].z){o=!0;break}if(!o)return void n()}if(e[r])return void e[r].push({context:t,callback:n,ref:this});e[r]=[{context:t,callback:n,ref:this}];const s=this.options.featureIdProperty;this.requests[r]=this.getTileFeatures(t,(n,i,o,a)=>{const u=e[r];if(delete e[r],this.checkIfCanceled(r))return delete this.requests[r],void this.qt(u,null,{canceled:!0});if(delete this.requests[r],(this.options.debug||s)&&i)for(let n=0;n<i.length;n++)if(this.options.debug&&(i[n]._debug_info={index:n,id:i[n].id,tileId:t.tileInfo.id}),s){const t=A(s)?s[i[n].layer]:s,e=i[n].properties;i[n].id=e&&e[t]||null}if(n)this.qt(u,n);else if(i&&i.length){if(u)for(let t=0;t<u.length;t++)this.Gt.call(u[t].ref,u[t].context,u[t].callback,r,o,i,a)}else this.qt(u)})}Gt(t,n,e,r,i,s){this.Bt(r,i,t).then(e=>{e.canceled?n(null,{canceled:!0}):(e.data.style=t.styleCounter,s&&w(e.data,s),n(null,e.data,e.buffers))}).catch(t=>{n(t)})}abortTile(t,n){delete this.requests[t],this.Jt(t),n()}Jt(t){const n=this.loadings[t];if(n)for(let t=0;t<n.length;t++)n[t].callback(null,{canceled:!0});delete this.loadings[t]}qt(t,n,e){if(t)for(let r=0;r<t.length;r++)t[r].callback(n,e)}checkIfCanceled(t){return!this.requests[t]}onRemove(){this.loadings={},delete this.Ut,this.requests={}}fetchIconGlyphs(t,n,e){if(this.options.workerGlyph&&Eh){const r=[];if(t&&Object.keys(t).length){const n=new Promise(n=>{this.upload("fetchIconGlyphs",{icons:t},null,(t,e)=>{n({err:t,iconData:e})})});r.push(n)}if(n&&Object.keys(n).length){const t=new Promise(t=>{this.Xt||(this.Xt=new ch),this.Xt.getGlyphs(n,(n,e)=>{t({err:n,glyphData:e})})});r.push(t)}Promise.all(r).then(t=>{const n={icons:null,glyphs:null};for(let r=0;r<t.length;r++){if(t[r].err)return void e(t[r].err);t[r].iconData?n.icons=t[r].iconData.icons:t[r].glyphData&&(n.glyphs=t[r].glyphData.glyphs)}return n}).then(t=>{e(null,t)})}else this.upload("fetchIconGlyphs",{icons:t,glyphs:n},null,e)}Bt(t,n,e){if(!n.length)return Promise.resolve({data:null,buffers:[]});const{glScale:r,tileInfo:i}=e,s=!this.options.style.style.length&&!this.options.style.featureStyle.length;let o=this.pluginConfig.slice(0);s&&(o=this.Yt(t)),this.featurePlugins&&P(o,this.featurePlugins);const a={};for(let t=0;t<o.length;t++)Lh(n,e.tileInfo.z,o[t],a);const u=[],h=[];for(let t=0;t<n.length;t++){const e=n[t],r=a[t];if(r){h.fill(null);let t=0;for(const n in r){let i=0;const s=r[n].values();for(const t of s){let r=h[i];r||(r=Wh(e),h[i]=r),r.properties[n]=t,i++}i>t&&(t=i)}for(let n=0;n<t;n++)u.push(h[n])}else u.push(e)}const l=(n=u)[0].extent,c=i.z,f={x:i.extent2d.xmin*r,y:i.extent2d.ymax*r},d=[],p=[],y=[],m=this.options,g=[],v={},b=[Promise.resolve(e.styleCounter)];let M=0,x=-1;const F=[];let A=!1;for(let t=0;t<o.length;t++){x++;const r=o[t];r.type!==M&&(x=0,M=r.type);const a=0===r.type?d:p;if(r.symbol&&!1===r.symbol.visible){a[x]=null;continue}Bh(r.symbol,F,t),A=A||F[t]&&F[t].size>0;const{tileFeatures:u,tileFeaIndexes:h}=this.Zt(c,r.type,r.filter,n,v,t);if(!u.length){a[x]=null;continue}const m=h[h.length-1],k=dh.getIndexArrayType(m);a[x]={styledFeatures:new k(h)},y.push({idx:t,typeIdx:x}),g.push(a[x].styledFeatures.buffer);const P=w({},e,{extent:l,zoom:c,tilePoint:f});if(this.options.debugTile){const t=this.options.debugTile;for(let n=0;n<t.length;n++){const{x:e,y:r,z:s}=t[n];if(i.x===e&&i.y===r&&i.z===s){P.debugIndex=t[n].index;break}}}let S=this.Kt(u,r,P);s&&(S=S.then(t=>{if(!t)return null;if(t.data)t.data.layer=u[0].layer;else if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&t[n].data&&(t[n].data.layer=u[0].layer);return t})),b.push(S)}return Promise.all(b).then(([e,...r])=>{function i(t,n){if(void 0===t.data.ref&&(t.data.type=o[y[n].idx].renderPlugin.dataConfig.type,t.data.filter=o[y[n].idx].filter.def,t.buffers&&t.buffers.length))for(let n=0;n<t.buffers.length;n++)g.push(t.buffers[n])}if(e!==this.Wt)return{canceled:!0};for(let t=0;t<r.length;t++){if(!r[t])continue;const n=r[t],e=0===o[y[t].idx].type?d:p;if(Array.isArray(n)){const r=[];for(let e=0;e<n.length;e++)n[e]&&(i(n[e],t),(void 0===n[e].data.ref||n[n[e].data.ref])&&r.push(n[e].data));r.length&&(e[y[t].typeIdx].data=r)}else i(n,t),e[y[t].typeIdx].data=n.data}const s={},a=t;if(m.features||m.schema||A){let t,e=!1;for(let r=0,i=n.length;r<i;r++)if(t=n[r],a[t.layer].properties||(a[t.layer].properties=Dh(t.properties)),t&&(m.features||A&&v[r]))if("id"===m.features)s[r]=t.id;else{m.pickingGeometry||delete t.geometry,delete t.extent,delete t.properties.$layer,delete t.properties.$type,delete t.__index;const n=t.originalFeature;if(n){const n=t.properties,e=w({},t.originalFeature);delete n[Ih],e.customProps=w({},n),t=e}const i=w({},t);if(!m.features){const i=v[r];for(let r=0;r<i.length;r++){const i=F[r];i&&i.forEach(r=>{const i=n?n.properties:t.properties;i[$h]||(i[$h]=new Set),i[$h].add(r),e=!0})}}s[r]=i}if(e)for(const t in s){const n=s[t];if(n.properties[$h]){const t=n.properties[$h];delete n.properties[$h];for(const e in n.properties)t.has(e)||delete n.properties[e]}}}return{data:{schema:a,data:d,featureData:p,extent:l,features:s},buffers:g}}).catch(t=>{console.error(t)})}Kt(t,n,e){let r=t;const i=n.renderPlugin.dataConfig,s=n.symbol,o=this.options.tileSize,{extent:a,glScale:u,zScale:h,zoom:l,tilePoint:c,centimeterToPoint:f,verticalCentimeterToPoint:d}=e,p=a/o,y=i.type,m=e.debugIndex;let g=w({},i,{EXTENT:a,zoom:l,debugIndex:m,features:this.options.features});if("3d-extrusion"===y){const t=jh(s);t&&(i.uv=1,2===t&&(i.tangent=1));const n=this.options.projectionCode,o=s.material&&s.material.textureWidth||23.25;return Promise.all([Promise.resolve(Fh(r,i,a,c,o,e.tileInfo.res,u,a/this.options.tileSize,f,d,s,l,n,m))])}if("3d-wireframe"===y)return Promise.all([Promise.resolve(_h(r,a,s,i))]);if("point"===y){g=w(g,{requestor:this.fetchIconGlyphs.bind(this),altitudeToTileScale:h*a/this.options.tileSize/u});const t=vu.splitPointSymbol(s),n=oa.genFnTypes(t[0]);return vu.needMerge(t[0],n,l)&&(r=vu.mergeLineFeatures(r,t[0],n,l)),Promise.all(t.map((t,e)=>(0===e?g.fnTypes=n:delete g.fnTypes,new vu(r,t,g).load(p))))}if("native-point"===y){const t=h*a/this.options.tileSize/u;return g.altitudeToTileScale=t,Uh(r,s,g,ju,a/o)}if("line"===y)return g=w(g,{requestor:this.fetchIconGlyphs.bind(this),tileRatio:p}),Uh(r,s,g,ku);if("native-line"===y)return Uh(r,s,g,zu);if("fill"===y)return g=w(g,{requestor:this.fetchIconGlyphs.bind(this)}),Uh(r,s,g,Wu);if("line-extrusion"===y){delete s.lineGradientProperty,s.lineJoin="miter",s.lineCap="butt";const t=jh(s);if(t&&(i.uv=1,2===t&&(i.tangent=1)),g=w(g,{tileSize:o,zScale:h,glScale:u}),t){const t=[];if(!1!==i.top){const n=w({},g);n.side=!1,t.push(new Cu(r,s,n))}return!1!==i.side&&(g.side=!0,g.top=!1,t.push(new Cu(r,s,g))),Promise.all(t.map(t=>t.load()))}return Promise.all([new Cu(r,s,g).load()])}if("circle"===y)return Uh(r,s,g,Gu);if("round-tube"===y||"square-tube"===y){const t="round-tube"===y?Bu:Qu;return g=w(g,{requestor:this.fetchIconGlyphs.bind(this),radialSegments:"round-tube"===y?i.radialSegments||8:4,centimeterToPoint:f,verticalCentimeterToPoint:d,tileRatio:p,isTube:!0}),Uh(r,s,g,t)}return Promise.resolve([])}Zt(t,n,e,r,i,s){const o="__fea_idx".trim(),a=[],u=[],h=r.length;for(let l=0;l<h;l++)if((1===n||void 0===r[l].id||!this.styledFeatures[r[l].id])&&((!e.def||"default"===e.def)&&!i[l]||!0===e.def||e.def&&(void 0!==e.def.condition||Array.isArray(e.def))&&e(r[l],t))){const t=r[l];if(void 0===t[o]&&(t[o]=l),i[l]||(i[l]=[]),i[l].push(s),u.push(t),a.push(l),1===n)break}return{tileFeatures:u,tileFeaIndexes:a}}Ht(t){const{style:n,featureStyle:e}=t,r={};e.forEach(t=>{Array.isArray(t.id)?(t.id.forEach(t=>{r[t]=1}),t.filter=["in","$id",...t.id]):(r[t.id]=1,t.filter=["==","$id",t.id])});const i=Bo.compileStyle(n);for(let t=0;t<n.length;t++)i[t].filter&&(i[t].filter.def=n[t].filter?n[t].filter.value||n[t].filter:void 0),i[t].type=0;const s=[],o=Bo.compileStyle(e);for(let t=0;t<e.length;t++)o[t].type=1,o[t].filter.def=e[t].filter?e[t].filter.value||e[t].filter:void 0,o[t].renderPlugin&&s.push(o[t]);this.pluginConfig=i,this.featurePlugins=s,this.styledFeatures=r}Yt(t){let n=this.Qt;this.Qt||(n=this.Qt={});const e=["","Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"],r=[];for(const i in t){const s=i;if(!n[i]){const r=[];for(let n=0;n<t[i].types.length;n++){const o=t[i].types[n],a=["all",["==","$layer",s],["==","$type",e[o]]],u={filter:zn(a),renderPlugin:Th(o),symbol:zh(o)};u.filter.def=a,u.type=0,r.push(u)}n[s]=r}r.push(...n[s])}return r}}function Th(t){switch(t){case 1:return{type:"native-point",dataConfig:{type:"native-point",only2D:!0}};case 2:return{type:"native-line",dataConfig:{type:"native-line",only2D:!0}};case 3:return{type:"fill",dataConfig:{type:"fill",only2D:!0}}}return null}function zh(t){switch(t){case 1:return{markerFill:"#f00",markerSize:10};case 2:return{lineColor:"#fff"};case 3:return{polygonFill:"#00f",polygonOpacity:.4}}return null}function Dh(t){if(Array.isArray(t)||!A(t))return{};const n={};for(const e in t){const r=t[e];M(r)?n[e]="string":x(r)?n[e]="number":!0===r||!1===r?n[e]="boolean":Array.isArray(r)?n[e]="array":n[e]="object"}return n}function jh(t){if(!t)return 0;let n=0;for(const e in t){if(("normalTexture"===e||"bumpTexture"===e)&&t[e])return 2;if(e.indexOf("Texture")>0&&t[e])n=1;else if(A(t[e])){const r=jh(t[e]);if(2===r)return r;1===r&&(n=1)}}return n}function Uh(t,n,e,r,i){const s={},o=Array.isArray(n)?n:[n];let a=-1;for(let t=0;t<o.length;t++)s[t]=Nh(o[t]),!s[t]&&o[t]&&-1===a&&(a=t);const u=[];for(let n=0;n<o.length;n++)o[n]&&(o[n].index={index:n},s[n]||n===a?u.push(new r(t,o[n],e).load(i)):u.push({data:{ref:a,symbolIndex:{index:n}}}));return Promise.all(u)}function Nh(t){if(!t)return 0;for(const n in t)if(S(t[n]))return 1;return 0}function Lh(t,n,e,r){const i=e.customProperties;if(!i)return t;if(i)for(let t=0;t<i.length;t++)i[t].fn=Bo.compileFilter(i[t].filter);for(let e=0;e<i.length;e++)for(let s=0,o=t.length;s<o;s++)if(i[e].fn(t[s],n))for(const t in i[e].properties){const n=i[e].properties[t];k(n)||(r[s]||(r[s]={}),r[s][t]||(r[s][t]=new Set),r[s][t].add(n))}}const Vh={get:(t,n)=>n in t?t[n]:t.originalFeature[n],has:(t,n)=>n in t||n in t.originalFeature},Rh={get:function(t,n){return n in t?t[n]:t[Ih][n]},has:(t,n)=>n in t||n in t[Ih]},Hh={};function Wh(t){const n={};n.originalFeature=t;const e=new Proxy(n,Vh);return e.properties=new Proxy({},Rh),e.properties[Ih]=t.properties||Hh,e}function qh(t,n,e){t[n]||(t[n]=new Set),t[n].add(e)}const Gh=[];function Bh(t,n,e){if(!t)return Gh;for(const r in t){if(!t[r]||!Ar.checkIfZoomFnTypeSymbol(r))continue;if(S(t[r]))qh(n,e,t[r].property);else{if("lineGradientProperty"===r){qh(n,e,t[r]);continue}if("textName"===r)if(M(t[r])){const i=pa.resolveVarNames(t[r]);if(i)for(let t=0;t<i.length;t++)qh(n,e,i[t])}else if(Bo.isExpression(t[r])){const i=[];pa.resolveExpVarNames(i,t[r]);for(let t=0;t<i.length;t++)qh(n,e,i[t])}}const i=t[r].stops;if(i&&i.length)for(let t=0;t<i.length;t++)S(i[t][1])&&qh(n,t,i[t][1].property)}return n[e]}function Jh(t,n){Xh(t.geometry,n)}function Xh(t,n){if(t)switch(t.type){case"Point":Yh(t.coordinates,n);break;case"MultiPoint":case"LineString":Zh(t.coordinates,n);break;case"MultiLineString":!function(t,n){for(let e=0,r=t.length;e<r;e++)Zh(t[e],n)}(t.coordinates,n);break;case"Polygon":Kh(t.coordinates,n);break;case"MultiPolygon":!function(t,n){for(let e=0,r=t.length;e<r;e++)Kh(t[e],n)}(t.coordinates,n);break;case"GeometryCollection":const e=t.geometries.length;for(let r=0;r<e;r++)Xh(t.geometries[r],n)}}function Yh(t,n){n[0]=Math.min(n[0],t[0]),n[1]=Math.min(n[1],t[1]),n[2]=Math.max(n[2],t[0]),n[3]=Math.max(n[3],t[1])}function Zh(t,n){for(let e=0,r=t.length;e<r;e++)Yh(t[e],n)}function Kh(t,n){t.length&&Zh(t[0],n)}function Qh(t,n,e,r,i){!function t(n,e,r,i,s){for(;i>r;){if(i-r>600){var o=i-r+1,a=e-r+1,u=Math.log(o),h=.5*Math.exp(2*u/3),l=.5*Math.sqrt(u*h*(o-h)/o)*(a-o/2<0?-1:1),c=Math.max(r,Math.floor(e-a*h/o+l)),f=Math.min(i,Math.floor(e+(o-a)*h/o+l));t(n,e,c,f,s)}var d=n[e],p=r,y=i;for(tl(n,r,e),s(n[i],d)>0&&tl(n,r,i);p<y;){for(tl(n,p,y),p++,y--;s(n[p],d)<0;)p++;for(;s(n[y],d)>0;)y--}0===s(n[r],d)?tl(n,r,y):(y++,tl(n,y,i)),y<=e&&(r=y+1),e<=y&&(i=y-1)}}(t,n,e||0,r||t.length-1,i||nl)}function tl(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}function nl(t,n){return t<n?-1:t>n?1:0}class el{constructor(t=9){this.tn=Math.max(4,t),this.nn=Math.max(2,Math.ceil(.4*this.tn)),this.clear()}all(){return this.en(this.data,[])}search(t){let n=this.data;const e=[];if(!pl(t,n))return e;const r=this.toBBox,i=[];for(;n;){for(let s=0;s<n.children.length;s++){const o=n.children[s],a=n.leaf?r(o):o;pl(t,a)&&(n.leaf?e.push(o):dl(t,a)?this.en(o,e):i.push(o))}n=i.pop()}return e}collides(t){let n=this.data;if(!pl(t,n))return!1;const e=[];for(;n;){for(let r=0;r<n.children.length;r++){const i=n.children[r],s=n.leaf?this.toBBox(i):i;if(pl(t,s)){if(n.leaf||dl(t,s))return!0;e.push(i)}}n=e.pop()}return!1}load(t){if(!t||!t.length)return this;if(t.length<this.nn){for(let n=0;n<t.length;n++)this.insert(t[n]);return this}let n=this.rn(t.slice(),0,t.length-1,0);if(this.data.children.length)if(this.data.height===n.height)this.sn(this.data,n);else{if(this.data.height<n.height){const t=this.data;this.data=n,n=t}this.an(n,this.data.height-n.height-1,!0)}else this.data=n;return this}insert(t){return t&&this.an(t,this.data.height-1),this}clear(){return this.data=yl([]),this}remove(t,n){if(!t)return this;let e=this.data;const r=this.toBBox(t),i=[],s=[];let o,a,u;for(;e||i.length;){if(e||(e=i.pop(),a=i[i.length-1],o=s.pop(),u=!0),e.leaf){const r=rl(t,e.children,n);if(-1!==r)return e.children.splice(r,1),i.push(e),this.un(i),this}u||e.leaf||!dl(e,r)?a?(o++,e=a.children[o],u=!1):e=null:(i.push(e),s.push(o),o=0,a=e,e=e.children[0])}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}en(t,n){const e=[];for(;t;)t.leaf?n.push(...t.children):e.push(...t.children),t=e.pop();return n}rn(t,n,e,r){const i=e-n+1;let s,o=this.tn;if(i<=o)return s=yl(t.slice(n,e+1)),il(s,this.toBBox),s;r||(r=Math.ceil(Math.log(i)/Math.log(o)),o=Math.ceil(i/Math.pow(o,r-1))),s=yl([]),s.leaf=!1,s.height=r;const a=Math.ceil(i/o),u=a*Math.ceil(Math.sqrt(o));ml(t,n,e,u,this.compareMinX);for(let i=n;i<=e;i+=u){const n=Math.min(i+u-1,e);ml(t,i,n,a,this.compareMinY);for(let e=i;e<=n;e+=a){const i=Math.min(e+a-1,n);s.children.push(this.rn(t,e,i,r-1))}}return il(s,this.toBBox),s}hn(t,n,e,r){for(;r.push(n),!n.leaf&&r.length-1!==e;){let e,r=1/0,i=1/0;for(let s=0;s<n.children.length;s++){const o=n.children[s],a=hl(o),u=cl(t,o)-a;u<i?(i=u,r=a<r?a:r,e=o):u===i&&a<r&&(r=a,e=o)}n=e||n.children[0]}return n}an(t,n,e){const r=e?t:this.toBBox(t),i=[],s=this.hn(r,this.data,n,i);for(s.children.push(t),ol(s,r);n>=0&&i[n].children.length>this.tn;)this.cn(i,n),n--;this.dn(r,i,n)}cn(t,n){const e=t[n],r=e.children.length,i=this.nn;this.pn(e,i,r);const s=this.yn(e,i,r),o=yl(e.children.splice(s,e.children.length-s));o.height=e.height,o.leaf=e.leaf,il(e,this.toBBox),il(o,this.toBBox),n?t[n-1].children.push(o):this.sn(e,o)}sn(t,n){this.data=yl([t,n]),this.data.height=t.height+1,this.data.leaf=!1,il(this.data,this.toBBox)}yn(t,n,e){let r,i=1/0,s=1/0;for(let o=n;o<=e-n;o++){const n=sl(t,0,o,this.toBBox),a=sl(t,o,e,this.toBBox),u=fl(n,a),h=hl(n)+hl(a);u<i?(i=u,r=o,s=h<s?h:s):u===i&&h<s&&(s=h,r=o)}return r||e-n}pn(t,n,e){const r=t.leaf?this.compareMinX:al,i=t.leaf?this.compareMinY:ul;this.mn(t,n,e,r)<this.mn(t,n,e,i)&&t.children.sort(r)}mn(t,n,e,r){t.children.sort(r);const i=this.toBBox,s=sl(t,0,n,i),o=sl(t,e-n,e,i);let a=ll(s)+ll(o);for(let r=n;r<e-n;r++){const n=t.children[r];ol(s,t.leaf?i(n):n),a+=ll(s)}for(let r=e-n-1;r>=n;r--){const n=t.children[r];ol(o,t.leaf?i(n):n),a+=ll(o)}return a}dn(t,n,e){for(let r=e;r>=0;r--)ol(n[r],t)}un(t){for(let n,e=t.length-1;e>=0;e--)0===t[e].children.length?e>0?(n=t[e-1].children,n.splice(n.indexOf(t[e]),1)):this.clear():il(t[e],this.toBBox)}}function rl(t,n,e){if(!e)return n.indexOf(t);for(let r=0;r<n.length;r++)if(e(t,n[r]))return r;return-1}function il(t,n){sl(t,0,t.children.length,n,t)}function sl(t,n,e,r,i){i||(i=yl(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(let s=n;s<e;s++){const n=t.children[s];ol(i,t.leaf?r(n):n)}return i}function ol(t,n){return t.minX=Math.min(t.minX,n.minX),t.minY=Math.min(t.minY,n.minY),t.maxX=Math.max(t.maxX,n.maxX),t.maxY=Math.max(t.maxY,n.maxY),t}function al(t,n){return t.minX-n.minX}function ul(t,n){return t.minY-n.minY}function hl(t){return(t.maxX-t.minX)*(t.maxY-t.minY)}function ll(t){return t.maxX-t.minX+(t.maxY-t.minY)}function cl(t,n){return(Math.max(n.maxX,t.maxX)-Math.min(n.minX,t.minX))*(Math.max(n.maxY,t.maxY)-Math.min(n.minY,t.minY))}function fl(t,n){const e=Math.max(t.minX,n.minX),r=Math.max(t.minY,n.minY),i=Math.min(t.maxX,n.maxX),s=Math.min(t.maxY,n.maxY);return Math.max(0,i-e)*Math.max(0,s-r)}function dl(t,n){return t.minX<=n.minX&&t.minY<=n.minY&&n.maxX<=t.maxX&&n.maxY<=t.maxY}function pl(t,n){return n.minX<=t.maxX&&n.minY<=t.maxY&&n.maxX>=t.minX&&n.maxY>=t.minY}function yl(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ml(t,n,e,r,i){const s=[n,e];for(;s.length;){if((e=s.pop())-(n=s.pop())<=r)continue;const o=n+Math.ceil((e-n)/r/2)*r;Qh(t,o,n,e,i),s.push(n,o,o,e)}}var gl={exports:{}},vl=function(t,n,e,r){var i=t[0],s=t[1],o=!1;void 0===e&&(e=0),void 0===r&&(r=n.length);for(var a=(r-e)/2,u=0,h=a-1;u<a;h=u++){var l=n[e+2*u+0],c=n[e+2*u+1],f=n[e+2*h+0],d=n[e+2*h+1];c>s!=d>s&&i<(f-l)*(s-c)/(d-c)+l&&(o=!o)}return o},bl=function(t,n,e,r){var i=t[0],s=t[1],o=!1;void 0===e&&(e=0),void 0===r&&(r=n.length);for(var a=r-e,u=0,h=a-1;u<a;h=u++){var l=n[u+e][0],c=n[u+e][1],f=n[h+e][0],d=n[h+e][1];c>s!=d>s&&i<(f-l)*(s-c)/(d-c)+l&&(o=!o)}return o};gl.exports=function(t,n,e,r){return n.length>0&&Array.isArray(n[0])?bl(t,n,e,r):vl(t,n,e,r)};var wl=gl.exports.nested=bl;gl.exports.flat=vl;function Ml(t,n,e,r,i){let s,o,a,u,h=n[0],l=r[0],c=0,f=0;l>h==l>-h?(s=h,h=n[++c]):(s=l,l=r[++f]);let d=0;if(c<t&&f<e)for(l>h==l>-h?(o=h+s,a=s-(o-h),h=n[++c]):(o=l+s,a=s-(o-l),l=r[++f]),s=o,0!==a&&(i[d++]=a);c<t&&f<e;)l>h==l>-h?(o=s+h,u=o-s,a=s-(o-u)+(h-u),h=n[++c]):(o=s+l,u=o-s,a=s-(o-u)+(l-u),l=r[++f]),s=o,0!==a&&(i[d++]=a);for(;c<t;)o=s+h,u=o-s,a=s-(o-u)+(h-u),h=n[++c],s=o,0!==a&&(i[d++]=a);for(;f<e;)o=s+l,u=o-s,a=s-(o-u)+(l-u),l=r[++f],s=o,0!==a&&(i[d++]=a);return 0===s&&0!==d||(i[d++]=s),d}function xl(t){return new Float64Array(t)}const Fl=xl(4),Al=xl(8),kl=xl(12),Pl=xl(16),Sl=xl(4);function _l(t,n,e,r,i,s){const o=(n-s)*(e-i),a=(t-i)*(r-s),u=o-a;if(0===o||0===a||o>0!=a>0)return u;const h=Math.abs(o+a);return Math.abs(u)>=33306690738754716e-32*h?u:-function(t,n,e,r,i,s,o){let a,u,h,l,c,f,d,p,y,m,g,v,b,w,M,x,F,A;const k=t-i,P=e-i,S=n-s,_=r-s;w=k*_,f=134217729*k,d=f-(f-k),p=k-d,f=134217729*_,y=f-(f-_),m=_-y,M=p*m-(w-d*y-p*y-d*m),x=S*P,f=134217729*S,d=f-(f-S),p=S-d,f=134217729*P,y=f-(f-P),m=P-y,F=p*m-(x-d*y-p*y-d*m),g=M-F,c=M-g,Fl[0]=M-(g+c)+(c-F),v=w+g,c=v-w,b=w-(v-c)+(g-c),g=b-x,c=b-g,Fl[1]=b-(g+c)+(c-x),A=v+g,c=A-v,Fl[2]=v-(A-c)+(g-c),Fl[3]=A;let O=function(t,n){let e=n[0];for(let r=1;r<t;r++)e+=n[r];return e}(4,Fl),E=22204460492503146e-32*o;if(O>=E||-O>=E)return O;if(c=t-k,a=t-(k+c)+(c-i),c=e-P,h=e-(P+c)+(c-i),c=n-S,u=n-(S+c)+(c-s),c=r-_,l=r-(_+c)+(c-s),0===a&&0===u&&0===h&&0===l)return O;if(E=11093356479670487e-47*o+33306690738754706e-32*Math.abs(O),O+=k*l+_*a-(S*h+P*u),O>=E||-O>=E)return O;w=a*_,f=134217729*a,d=f-(f-a),p=a-d,f=134217729*_,y=f-(f-_),m=_-y,M=p*m-(w-d*y-p*y-d*m),x=u*P,f=134217729*u,d=f-(f-u),p=u-d,f=134217729*P,y=f-(f-P),m=P-y,F=p*m-(x-d*y-p*y-d*m),g=M-F,c=M-g,Sl[0]=M-(g+c)+(c-F),v=w+g,c=v-w,b=w-(v-c)+(g-c),g=b-x,c=b-g,Sl[1]=b-(g+c)+(c-x),A=v+g,c=A-v,Sl[2]=v-(A-c)+(g-c),Sl[3]=A;const I=Ml(4,Fl,4,Sl,Al);w=k*l,f=134217729*k,d=f-(f-k),p=k-d,f=134217729*l,y=f-(f-l),m=l-y,M=p*m-(w-d*y-p*y-d*m),x=S*h,f=134217729*S,d=f-(f-S),p=S-d,f=134217729*h,y=f-(f-h),m=h-y,F=p*m-(x-d*y-p*y-d*m),g=M-F,c=M-g,Sl[0]=M-(g+c)+(c-F),v=w+g,c=v-w,b=w-(v-c)+(g-c),g=b-x,c=b-g,Sl[1]=b-(g+c)+(c-x),A=v+g,c=A-v,Sl[2]=v-(A-c)+(g-c),Sl[3]=A;const $=Ml(I,Al,4,Sl,kl);w=a*l,f=134217729*a,d=f-(f-a),p=a-d,f=134217729*l,y=f-(f-l),m=l-y,M=p*m-(w-d*y-p*y-d*m),x=u*h,f=134217729*u,d=f-(f-u),p=u-d,f=134217729*h,y=f-(f-h),m=h-y,F=p*m-(x-d*y-p*y-d*m),g=M-F,c=M-g,Sl[0]=M-(g+c)+(c-F),v=w+g,c=v-w,b=w-(v-c)+(g-c),g=b-x,c=b-g,Sl[1]=b-(g+c)+(c-x),A=v+g,c=A-v,Sl[2]=v-(A-c)+(g-c),Sl[3]=A;const C=Ml($,kl,4,Sl,Pl);return Pl[C-1]}(t,n,e,r,i,s,h)}function Ol(t,n,e){n=Math.max(0,void 0===n?2:n),e=e||0;var r=function(t){for(var n=t[0],e=t[0],r=t[0],i=t[0],s=0;s<t.length;s++){var o=t[s];o[0]<n[0]&&(n=o),o[0]>r[0]&&(r=o),o[1]<e[1]&&(e=o),o[1]>i[1]&&(i=o)}var a=[n,e,r,i],u=a.slice();for(s=0;s<t.length;s++)wl(t[s],a)||u.push(t[s]);return function(t){t.sort(Vl);for(var n=[],e=0;e<t.length;e++){for(;n.length>=2&&zl(n[n.length-2],n[n.length-1],t[e])<=0;)n.pop();n.push(t[e])}for(var r=[],i=t.length-1;i>=0;i--){for(;r.length>=2&&zl(r[r.length-2],r[r.length-1],t[i])<=0;)r.pop();r.push(t[i])}return r.pop(),n.pop(),n.concat(r)}(u)}(t),i=new el(16);i.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},i.compareMinX=function(t,n){return t[0]-n[0]},i.compareMinY=function(t,n){return t[1]-n[1]},i.load(t);for(var s,o=[],a=0;a<r.length;a++){var u=r[a];i.remove(u),s=jl(u,s),o.push(s)}var h=new el(16);for(a=0;a<o.length;a++)h.insert(Dl(o[a]));for(var l=n*n,c=e*e;o.length;){var f=o.shift(),d=f.p,p=f.next.p,y=Ul(d,p);if(!(y<c)){var m=y/l;(u=El(i,f.prev.p,d,p,f.next.next.p,m,h))&&Math.min(Ul(u,d),Ul(u,p))<=m&&(o.push(f),o.push(jl(u,f)),i.remove(u),h.remove(f),h.insert(Dl(f)),h.insert(Dl(f.next)))}}f=s;var g=[];do{g.push(f.p),f=f.next}while(f!==s);return g.push(f.p),g}function El(t,n,e,r,i,s,o){for(var a=new Bn([],Il),u=t.data;u;){for(var h=0;h<u.children.length;h++){var l=u.children[h],c=u.leaf?Nl(l,e,r):$l(e,r,l);c>s||a.push({node:l,dist:c})}for(;a.length&&!a.peek().node.children;){var f=a.pop(),d=f.node,p=Nl(d,n,e),y=Nl(d,r,i);if(f.dist<p&&f.dist<y&&Tl(e,d,o)&&Tl(r,d,o))return d}(u=a.pop())&&(u=u.node)}return null}function Il(t,n){return t.dist-n.dist}function $l(t,n,e){if(Cl(t,e)||Cl(n,e))return 0;var r=Ll(t[0],t[1],n[0],n[1],e.minX,e.minY,e.maxX,e.minY);if(0===r)return 0;var i=Ll(t[0],t[1],n[0],n[1],e.minX,e.minY,e.minX,e.maxY);if(0===i)return 0;var s=Ll(t[0],t[1],n[0],n[1],e.maxX,e.minY,e.maxX,e.maxY);if(0===s)return 0;var o=Ll(t[0],t[1],n[0],n[1],e.minX,e.maxY,e.maxX,e.maxY);return 0===o?0:Math.min(r,i,s,o)}function Cl(t,n){return t[0]>=n.minX&&t[0]<=n.maxX&&t[1]>=n.minY&&t[1]<=n.maxY}function Tl(t,n,e){for(var r,i,s,o,a=Math.min(t[0],n[0]),u=Math.min(t[1],n[1]),h=Math.max(t[0],n[0]),l=Math.max(t[1],n[1]),c=e.search({minX:a,minY:u,maxX:h,maxY:l}),f=0;f<c.length;f++)if(r=c[f].p,i=c[f].next.p,s=t,r!==(o=n)&&i!==s&&zl(r,i,s)>0!=zl(r,i,o)>0&&zl(s,o,r)>0!=zl(s,o,i)>0)return!1;return!0}function zl(t,n,e){return _l(t[0],t[1],n[0],n[1],e[0],e[1])}function Dl(t){var n=t.p,e=t.next.p;return t.minX=Math.min(n[0],e[0]),t.minY=Math.min(n[1],e[1]),t.maxX=Math.max(n[0],e[0]),t.maxY=Math.max(n[1],e[1]),t}function jl(t,n){var e={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return n?(e.next=n.next,e.prev=n,n.next.prev=e,n.next=e):(e.prev=e,e.next=e),e}function Ul(t,n){var e=t[0]-n[0],r=t[1]-n[1];return e*e+r*r}function Nl(t,n,e){var r=n[0],i=n[1],s=e[0]-r,o=e[1]-i;if(0!==s||0!==o){var a=((t[0]-r)*s+(t[1]-i)*o)/(s*s+o*o);a>1?(r=e[0],i=e[1]):a>0&&(r+=s*a,i+=o*a)}return(s=t[0]-r)*s+(o=t[1]-i)*o}function Ll(t,n,e,r,i,s,o,a){var u,h,l,c,f=e-t,d=r-n,p=o-i,y=a-s,m=t-i,g=n-s,v=f*f+d*d,b=f*p+d*y,w=p*p+y*y,M=f*m+d*g,x=p*m+y*g,F=v*w-b*b,A=F,k=F;0===F?(h=0,A=1,c=x,k=w):(c=v*x-b*M,(h=b*x-w*M)<0?(h=0,c=x,k=w):h>A&&(h=A,c=x+b,k=w)),c<0?(c=0,-M<0?h=0:-M>v?h=A:(h=-M,A=v)):c>k&&(c=k,-M+b<0?h=0:-M+b>v?h=A:(h=-M+b,A=v));var P=(1-(l=0===c?0:c/k))*i+l*o-((1-(u=0===h?0:h/A))*t+u*e),S=(1-l)*s+l*a-((1-u)*n+u*r);return P*P+S*S}function Vl(t,n){return t[0]===n[0]?t[1]-n[1]:t[0]-n[0]}class Rl{constructor(t,n){this.x=t,this.y=n}clone(){return new Rl(this.x,this.y)}normalize(){const t=this.length();this.x/=t,this.y/=t}negate(){this.x=-this.x,this.y=-this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}diff(t){return new Rl(this.x-t.x,this.y-t.y)}distance(t){const n=this.x-t.x,e=this.y-t.y;return Math.sqrt(n*n+e*e)}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}orthogonal(){return new Rl(this.y,-this.x)}}function Hl(t,n,e,r){const i=n.x*r.y-n.y*r.x,s=e.x-t.x,o=e.y-t.y,a=(s*r.y-o*r.x)/i;return new Rl(t.x+a*n.x,t.y+a*n.y)}const Wl=[],ql=[];function Gl(t){if(x(t[0]&&t[0].x)){const n=[];let e=0;for(let r=0;r<t.length;r++)ql[e]?(ql[e][0]=t[r].x,ql[e][1]=t[r].y):ql[e]=[t[r].x,t[r].y],n.push(ql[e]),e++;t=n}try{const n=Ol(t,1/0);let e=[1/0,1/0],r=[-1/0,-1/0];for(let t=0;t<n.length;t++)n[t][0]<e[0]&&(e[0]=n[t][0]),n[t][0]>r[0]&&(r[0]=n[t][0]),n[t][1]<e[1]&&(e[1]=n[t][1]),n[t][1]>r[1]&&(r[1]=n[t][1]);const i=[];let s=[],o=0;for(let t=0;t<n.length;t++)t===n.length-1&&n[t][0]===n[0][0]&&n[t][1]===n[0][1]||(Ct(i,n[t],"EPSG:3857"),Wl[o]?(Wl[o].x=i[0],Wl[o].y=i[1]):Wl[o]=new Rl(i[0],i[1]),s.push(Wl[o]),o++);dh.calculateSignedArea(s)<0&&(s=s.reverse());const a=function(t){let n,e=Number.MAX_VALUE;const r=function(t,r,i,s,o,a,u,h){var l=Hl(t,r,o,a),c=Hl(i,s,o,a),f=Hl(u,h,t,r),d=Hl(u,h,i,s),p=l.distance(c)*l.distance(f);0!==p&&p<e&&(n=[l,f,d,c],e=p)};var i=[];for(let n=0;n<t.length;n++)i.push(t[(n+1)%t.length].diff(t[n])),i[n].normalize();var s,o,a,u,h=new Rl(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),l=new Rl(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let n=0;n<t.length;n++){var c=t[n];c.x<h.x&&(h.x=c.x,s=n),c.x>l.x&&(l.x=c.x,o=n),c.y<h.y&&(h.y=c.y,u=n),c.y>l.y&&(l.y=c.y,a=n)}var f=new Rl(0,-1),d=new Rl(0,1),p=new Rl(-1,0),y=new Rl(1,0);for(let n=0;n<t.length;n++){var m=[Math.acos(f.dot(i[s])),Math.acos(d.dot(i[o])),Math.acos(p.dot(i[a])),Math.acos(y.dot(i[u]))];switch(m.indexOf(Math.min.apply(Math,m))){case 0:(d=(f=i[s].clone()).clone()).negate(),(y=(p=f.orthogonal()).clone()).negate(),s=(s+1)%t.length;break;case 1:(f=(d=i[o].clone()).clone()).negate(),(y=(p=f.orthogonal()).clone()).negate(),o=(o+1)%t.length;break;case 2:(y=(p=i[a].clone()).clone()).negate(),(d=(f=y.orthogonal()).clone()).negate(),a=(a+1)%t.length;break;case 3:(p=(y=i[u].clone()).clone()).negate(),(d=(f=y.orthogonal()).clone()).negate(),u=(u+1)%t.length}r(t[s],f,t[o],d,t[a],p,t[u],y)}return n}(s);if(!a||4!==a.length)return null;const u=a[0].distance(a[1]),h=a[1].distance(a[2]),l=a.map(t=>[t.x,t.y]);return l.push(+(h>u)),l}catch(t){return null}}const Bl=[];function Jl(t,n){const e=Array.isArray(t&&t[0]&&t[0][0]);for(let r=0;r<t.length;r++)e?t[r]=Jl(t[r]):(Ct(Bl,t[r],n),t[r][0]=Bl[0],t[r][1]=Bl[1]);return t}class Xl extends Ch{constructor(t,n,e,r,i,s){super(t,n,e,r,i),(n=n||{}).extent||(n.extent=8192),this.zoomOffset=0,n.tileSize&&(this.zoomOffset=-function(t){if(Math.log2)return Math.log2(t);const n=Math.log(t)*Math.LOG2E,e=Math.round(n);return Math.abs(e-n)<1e-14?e:n}(n.tileSize/256)),this.setData(n.data,s)}setData(t,n){if(delete this.index,!t)return void n();const e={maxZoom:24,tolerance:this.options.simplifyTolerance,extent:this.options.extent,buffer:x(this.options.tileBuffer)?this.options.tileBuffer:64,hasAltitude:!!this.options.hasAltitude,debug:0,lineMetrics:!0,indexMaxZoom:5,indexMaxPoints:1e5,disableFilter:!0};if(this.options.projection&&(e.projection=this.options.projection,"EPSG:4490"===e.projection&&(e.projection="EPSG:4326")),M(t)&&"{"!=t.substring(0,1)||t.url){const r=t.url?t.url:t;O.getJSON(r,t.url?t:{},(t,i)=>{if(t&&(console.error("Failed to fetch geojson:"+r),n(t)),!i)return void n(null,{extent:null,idMap:{}});let s=i;if(this.options.convertFn){s=new Function("data",this.options.convertFn+"\\nreturn convert(data)")(s)}const o=Array.isArray(s)?s:s.features;this.gn(o);const{first1000:a,idMap:u}=this.vn(o);this.bn(a,u,s,e,n)})}else{"string"==typeof t&&(t=JSON.parse(t));const r=Array.isArray(t)?t:t.features;this.gn(r);let i=r;r&&r.length>1e3&&(i=r.slice(0,1e3)),this.bn(i,null,t,e,n)}}gn(t){if(this.options.generateOMBB&&t)for(let n=0;n<t.length;n++){const e=t[n];if(e&&e.geometry&&e.geometry.coordinates)if("Polygon"===e.geometry.type){const t=e.geometry.coordinates[0];if(!t)continue;const n=Gl(t,t.length);e.properties=e.properties||{},e.properties[vh]=n}else if("MultiPolygon"===e.geometry.type){const t=e.geometry.coordinates;for(let n=0;n<t.length;n++){if(!t[n])continue;const r=t[n][0];if(!r)continue;const i=Gl(r,r.length);e.properties=e.properties||{},e.properties[vh]=e.properties[vh]||[],e.properties[vh][n]=i}}}}bn(t,n,e,r,i){try{const s=t&&t.length?function(t){let n=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];switch(t.type){case"FeatureCollection":const e=t.features.length;for(let r=0;r<e;r++)Jh(t.features[r],n);break;case"Feature":Jh(t,n);break;default:Xh(t,n)}return n}({type:"FeatureCollection",features:t}):null;this.index=function(t,n){return new it(t,n)}(e,this.options.geojsonvt||r),i(null,{extent:s,idMap:n})}catch(t){console.warn(t),i({error:t.message})}}vn(t){const n=[],e={};let r=0;const i=this.options.featureIdProperty;return t&&t.forEach(t=>{!function(t){if(t&&("Feature"!==t.type||t.geometry)){if(x(t.id)||(t.id=r++),i){let n=i;A(i)&&(n=i[t.layer||"0"]),t.id=t.properties[n]}e[t.id]=w({},t),t.geometry?(e[t.id].geometry=w({},t.geometry),e[t.id].geometry.coordinates=null):t.coordinates&&(e[t.id].coordinates=null),n.length<1e3&&n.push(t)}}(t)}),{first1000:n,idMap:e}}getTileFeatures(t,n){const e=t.tileInfo,r=[];if(!this.index)return setTimeout((function(){n({loading:!0})}),1),1;const i=this.index.getTile(e.z+this.zoomOffset,e.x,e.y);if(!i||0===i.features.length)return setTimeout((function(){n(null,r,[])}),1),1;const s=[];for(let t=0,n=i.features.length;t<n;t++){const n=i.features[t];let e=n.layer;void 0===e&&(e="0"),s[e]={types:{}};s[e].types[n.type]=1,n.tags=n.tags||{},n.geometry.converted||(dh.convertGeometry(n),n.geometry.converted=1),r.push({type:n.type,layer:e,id:n.id,geometry:n.geometry,properties:n.tags,extent:this.options.extent})}for(const t in s)s[t].types=Object.keys(s[t].types).map(t=>+t);return setTimeout((function(){n(null,r,s)}),1),1}onRemove(){super.onRemove(),delete this.index}}var Yl={\n/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */\nread:function(t,n,e,r,i){var s,o,a=8*i-r-1,u=(1<<a)-1,h=u>>1,l=-7,c=e?i-1:0,f=e?-1:1,d=t[n+c];for(c+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+t[n+c],c+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=r;l>0;o=256*o+t[n+c],c+=f,l-=8);if(0===s)s=1-h;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=h}return(d?-1:1)*o*Math.pow(2,s-r)},write:function(t,n,e,r,i,s){var o,a,u,h=8*s-i-1,l=(1<<h)-1,c=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?1:-1,y=n<0||0===n&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(a=isNaN(n)?1:0,o=l):(o=Math.floor(Math.log(n)/Math.LN2),n*(u=Math.pow(2,-o))<1&&(o--,u*=2),(n+=o+c>=1?f/u:f*Math.pow(2,1-c))*u>=2&&(o++,u/=2),o+c>=l?(a=0,o=l):o+c>=1?(a=(n*u-1)*Math.pow(2,i),o+=c):(a=n*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;t[e+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,h+=i;h>0;t[e+d]=255&o,d+=p,o/=256,h-=8);t[e+d-p]|=128*y}},Zl=Ql,Kl=Yl;function Ql(t){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(t)?t:new Uint8Array(t||0),this.pos=0,this.type=0,this.length=this.buf.length}Ql.Varint=0,Ql.Fixed64=1,Ql.Bytes=2,Ql.Fixed32=5;var tc="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function nc(t){return t.type===Ql.Bytes?t.readVarint()+t.pos:t.pos+1}function ec(t,n,e){return e?4294967296*n+(t>>>0):4294967296*(n>>>0)+(t>>>0)}function rc(t,n,e){var r=n<=16383?1:n<=2097151?2:n<=268435455?3:Math.floor(Math.log(n)/(7*Math.LN2));e.realloc(r);for(var i=e.pos-1;i>=t;i--)e.buf[i+r]=e.buf[i]}function ic(t,n){for(var e=0;e<t.length;e++)n.writeVarint(t[e])}function sc(t,n){for(var e=0;e<t.length;e++)n.writeSVarint(t[e])}function oc(t,n){for(var e=0;e<t.length;e++)n.writeFloat(t[e])}function ac(t,n){for(var e=0;e<t.length;e++)n.writeDouble(t[e])}function uc(t,n){for(var e=0;e<t.length;e++)n.writeBoolean(t[e])}function hc(t,n){for(var e=0;e<t.length;e++)n.writeFixed32(t[e])}function lc(t,n){for(var e=0;e<t.length;e++)n.writeSFixed32(t[e])}function cc(t,n){for(var e=0;e<t.length;e++)n.writeFixed64(t[e])}function fc(t,n){for(var e=0;e<t.length;e++)n.writeSFixed64(t[e])}function dc(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16)+16777216*t[n+3]}function pc(t,n,e){t[e]=n,t[e+1]=n>>>8,t[e+2]=n>>>16,t[e+3]=n>>>24}function yc(t,n){return(t[n]|t[n+1]<<8|t[n+2]<<16)+(t[n+3]<<24)}Ql.prototype={destroy:function(){this.buf=null},readFields:function(t,n,e){for(e=e||this.length;this.pos<e;){var r=this.readVarint(),i=r>>3,s=this.pos;this.type=7&r,t(i,n,this),this.pos===s&&this.skip(r)}return n},readMessage:function(t,n){return this.readFields(t,n,this.readVarint()+this.pos)},readFixed32:function(){var t=dc(this.buf,this.pos);return this.pos+=4,t},readSFixed32:function(){var t=yc(this.buf,this.pos);return this.pos+=4,t},readFixed64:function(){var t=dc(this.buf,this.pos)+4294967296*dc(this.buf,this.pos+4);return this.pos+=8,t},readSFixed64:function(){var t=dc(this.buf,this.pos)+4294967296*yc(this.buf,this.pos+4);return this.pos+=8,t},readFloat:function(){var t=Kl.read(this.buf,this.pos,!0,23,4);return this.pos+=4,t},readDouble:function(){var t=Kl.read(this.buf,this.pos,!0,52,8);return this.pos+=8,t},readVarint:function(t){var n,e,r=this.buf;return n=127&(e=r[this.pos++]),e<128?n:(n|=(127&(e=r[this.pos++]))<<7,e<128?n:(n|=(127&(e=r[this.pos++]))<<14,e<128?n:(n|=(127&(e=r[this.pos++]))<<21,e<128?n:function(t,n,e){var r,i,s=e.buf;if(i=s[e.pos++],r=(112&i)>>4,i<128)return ec(t,r,n);if(i=s[e.pos++],r|=(127&i)<<3,i<128)return ec(t,r,n);if(i=s[e.pos++],r|=(127&i)<<10,i<128)return ec(t,r,n);if(i=s[e.pos++],r|=(127&i)<<17,i<128)return ec(t,r,n);if(i=s[e.pos++],r|=(127&i)<<24,i<128)return ec(t,r,n);if(i=s[e.pos++],r|=(1&i)<<31,i<128)return ec(t,r,n);throw new Error("Expected varint not more than 10 bytes")}(n|=(15&(e=r[this.pos]))<<28,t,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var t=this.readVarint()+this.pos,n=this.pos;return this.pos=t,t-n>=12&&tc?function(t,n,e){return tc.decode(t.subarray(n,e))}(this.buf,n,t):function(t,n,e){var r="",i=n;for(;i<e;){var s,o,a,u=t[i],h=null,l=u>239?4:u>223?3:u>191?2:1;if(i+l>e)break;1===l?u<128&&(h=u):2===l?128==(192&(s=t[i+1]))&&(h=(31&u)<<6|63&s)<=127&&(h=null):3===l?(s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&((h=(15&u)<<12|(63&s)<<6|63&o)<=2047||h>=55296&&h<=57343)&&(h=null)):4===l&&(s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&((h=(15&u)<<18|(63&s)<<12|(63&o)<<6|63&a)<=65535||h>=1114112)&&(h=null)),null===h?(h=65533,l=1):h>65535&&(h-=65536,r+=String.fromCharCode(h>>>10&1023|55296),h=56320|1023&h),r+=String.fromCharCode(h),i+=l}return r}(this.buf,n,t)},readBytes:function(){var t=this.readVarint()+this.pos,n=this.buf.subarray(this.pos,t);return this.pos=t,n},readPackedVarint:function(t,n){if(this.type!==Ql.Bytes)return t.push(this.readVarint(n));var e=nc(this);for(t=t||[];this.pos<e;)t.push(this.readVarint(n));return t},readPackedSVarint:function(t){if(this.type!==Ql.Bytes)return t.push(this.readSVarint());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readSVarint());return t},readPackedBoolean:function(t){if(this.type!==Ql.Bytes)return t.push(this.readBoolean());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readBoolean());return t},readPackedFloat:function(t){if(this.type!==Ql.Bytes)return t.push(this.readFloat());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readFloat());return t},readPackedDouble:function(t){if(this.type!==Ql.Bytes)return t.push(this.readDouble());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readDouble());return t},readPackedFixed32:function(t){if(this.type!==Ql.Bytes)return t.push(this.readFixed32());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readFixed32());return t},readPackedSFixed32:function(t){if(this.type!==Ql.Bytes)return t.push(this.readSFixed32());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readSFixed32());return t},readPackedFixed64:function(t){if(this.type!==Ql.Bytes)return t.push(this.readFixed64());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readFixed64());return t},readPackedSFixed64:function(t){if(this.type!==Ql.Bytes)return t.push(this.readSFixed64());var n=nc(this);for(t=t||[];this.pos<n;)t.push(this.readSFixed64());return t},skip:function(t){var n=7&t;if(n===Ql.Varint)for(;this.buf[this.pos++]>127;);else if(n===Ql.Bytes)this.pos=this.readVarint()+this.pos;else if(n===Ql.Fixed32)this.pos+=4;else{if(n!==Ql.Fixed64)throw new Error("Unimplemented type: "+n);this.pos+=8}},writeTag:function(t,n){this.writeVarint(t<<3|n)},realloc:function(t){for(var n=this.length||16;n<this.pos+t;)n*=2;if(n!==this.length){var e=new Uint8Array(n);e.set(this.buf),this.buf=e,this.length=n}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(t){this.realloc(4),pc(this.buf,t,this.pos),this.pos+=4},writeSFixed32:function(t){this.realloc(4),pc(this.buf,t,this.pos),this.pos+=4},writeFixed64:function(t){this.realloc(8),pc(this.buf,-1&t,this.pos),pc(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeSFixed64:function(t){this.realloc(8),pc(this.buf,-1&t,this.pos),pc(this.buf,Math.floor(t*(1/4294967296)),this.pos+4),this.pos+=8},writeVarint:function(t){(t=+t||0)>268435455||t<0?function(t,n){var e,r;t>=0?(e=t%4294967296|0,r=t/4294967296|0):(r=~(-t/4294967296),4294967295^(e=~(-t%4294967296))?e=e+1|0:(e=0,r=r+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn\'t fit into 10 bytes");n.realloc(10),function(t,n,e){e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos]=127&t}(e,0,n),function(t,n){var e=(7&t)<<4;if(n.buf[n.pos++]|=e|((t>>>=3)?128:0),!t)return;if(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(n.buf[n.pos++]=127&t|((t>>>=7)?128:0),!t)return;n.buf[n.pos++]=127&t}(r,n)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))},writeSVarint:function(t){this.writeVarint(t<0?2*-t-1:2*t)},writeBoolean:function(t){this.writeVarint(Boolean(t))},writeString:function(t){t=String(t),this.realloc(4*t.length),this.pos++;var n=this.pos;this.pos=function(t,n,e){for(var r,i,s=0;s<n.length;s++){if((r=n.charCodeAt(s))>55295&&r<57344){if(!i){r>56319||s+1===n.length?(t[e++]=239,t[e++]=191,t[e++]=189):i=r;continue}if(r<56320){t[e++]=239,t[e++]=191,t[e++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(t[e++]=239,t[e++]=191,t[e++]=189,i=null);r<128?t[e++]=r:(r<2048?t[e++]=r>>6|192:(r<65536?t[e++]=r>>12|224:(t[e++]=r>>18|240,t[e++]=r>>12&63|128),t[e++]=r>>6&63|128),t[e++]=63&r|128)}return e}(this.buf,t,this.pos);var e=this.pos-n;e>=128&&rc(n,e,this),this.pos=n-1,this.writeVarint(e),this.pos+=e},writeFloat:function(t){this.realloc(4),Kl.write(this.buf,t,this.pos,!0,23,4),this.pos+=4},writeDouble:function(t){this.realloc(8),Kl.write(this.buf,t,this.pos,!0,52,8),this.pos+=8},writeBytes:function(t){var n=t.length;this.writeVarint(n),this.realloc(n);for(var e=0;e<n;e++)this.buf[this.pos++]=t[e]},writeRawMessage:function(t,n){this.pos++;var e=this.pos;t(n,this);var r=this.pos-e;r>=128&&rc(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeMessage:function(t,n,e){this.writeTag(t,Ql.Bytes),this.writeRawMessage(n,e)},writePackedVarint:function(t,n){n.length&&this.writeMessage(t,ic,n)},writePackedSVarint:function(t,n){n.length&&this.writeMessage(t,sc,n)},writePackedBoolean:function(t,n){n.length&&this.writeMessage(t,uc,n)},writePackedFloat:function(t,n){n.length&&this.writeMessage(t,oc,n)},writePackedDouble:function(t,n){n.length&&this.writeMessage(t,ac,n)},writePackedFixed32:function(t,n){n.length&&this.writeMessage(t,hc,n)},writePackedSFixed32:function(t,n){n.length&&this.writeMessage(t,lc,n)},writePackedFixed64:function(t,n){n.length&&this.writeMessage(t,cc,n)},writePackedSFixed64:function(t,n){n.length&&this.writeMessage(t,fc,n)},writeBytesField:function(t,n){this.writeTag(t,Ql.Bytes),this.writeBytes(n)},writeFixed32Field:function(t,n){this.writeTag(t,Ql.Fixed32),this.writeFixed32(n)},writeSFixed32Field:function(t,n){this.writeTag(t,Ql.Fixed32),this.writeSFixed32(n)},writeFixed64Field:function(t,n){this.writeTag(t,Ql.Fixed64),this.writeFixed64(n)},writeSFixed64Field:function(t,n){this.writeTag(t,Ql.Fixed64),this.writeSFixed64(n)},writeVarintField:function(t,n){this.writeTag(t,Ql.Varint),this.writeVarint(n)},writeSVarintField:function(t,n){this.writeTag(t,Ql.Varint),this.writeSVarint(n)},writeStringField:function(t,n){this.writeTag(t,Ql.Bytes),this.writeString(n)},writeFloatField:function(t,n){this.writeTag(t,Ql.Fixed32),this.writeFloat(n)},writeDoubleField:function(t,n){this.writeTag(t,Ql.Fixed64),this.writeDouble(n)},writeBooleanField:function(t,n){this.writeVarintField(t,Boolean(n))}};var mc=Ut,gc=vc;function vc(t,n,e,r,i){this.properties={},this.extent=e,this.type=0,this.wn=t,this.Mn=-1,this.xn=r,this.Fn=i,t.readFields(bc,this,n)}function bc(t,n,e){1==t?n.id=e.readVarint():2==t?function(t,n){var e=t.readVarint()+t.pos;for(;t.pos<e;){var r=n.xn[t.readVarint()],i=n.Fn[t.readVarint()];n.properties[r]=i}}(e,n):3==t?n.type=e.readVarint():4==t&&(n.Mn=e.pos)}function wc(t){for(var n,e,r=0,i=0,s=t.length,o=s-1;i<s;o=i++)n=t[i],r+=((e=t[o]).x-n.x)*(n.y+e.y);return r}vc.types=["Unknown","Point","LineString","Polygon"],vc.prototype.loadGeometry=function(){var t=this.wn;t.pos=this.Mn;for(var n,e=t.readVarint()+t.pos,r=1,i=0,s=0,o=0,a=[];t.pos<e;){if(i<=0){var u=t.readVarint();r=7&u,i=u>>3}if(i--,1===r||2===r)s+=t.readSVarint(),o+=t.readSVarint(),1===r&&(n&&a.push(n),n=[]),n.push(new mc(s,o));else{if(7!==r)throw new Error("unknown command "+r);n&&n.push(n[0].clone())}}return n&&a.push(n),a},vc.prototype.bbox=function(){var t=this.wn;t.pos=this.Mn;for(var n=t.readVarint()+t.pos,e=1,r=0,i=0,s=0,o=1/0,a=-1/0,u=1/0,h=-1/0;t.pos<n;){if(r<=0){var l=t.readVarint();e=7&l,r=l>>3}if(r--,1===e||2===e)(i+=t.readSVarint())<o&&(o=i),i>a&&(a=i),(s+=t.readSVarint())<u&&(u=s),s>h&&(h=s);else if(7!==e)throw new Error("unknown command "+e)}return[o,u,a,h]},vc.prototype.toGeoJSON=function(t,n,e){var r,i,s=this.extent*Math.pow(2,e),o=this.extent*t,a=this.extent*n,u=this.loadGeometry(),h=vc.types[this.type];function l(t){for(var n=0;n<t.length;n++){var e=t[n],r=180-360*(e.y+a)/s;t[n]=[360*(e.x+o)/s-180,360/Math.PI*Math.atan(Math.exp(r*Math.PI/180))-90]}}switch(this.type){case 1:var c=[];for(r=0;r<u.length;r++)c[r]=u[r][0];l(u=c);break;case 2:for(r=0;r<u.length;r++)l(u[r]);break;case 3:for(u=function(t){var n=t.length;if(n<=1)return[t];for(var e,r,i=[],s=0;s<n;s++){var o=wc(t[s]);0!==o&&(void 0===r&&(r=o<0),r===o<0?(e&&i.push(e),e=[t[s]]):e.push(t[s]))}e&&i.push(e);return i}(u),r=0;r<u.length;r++)for(i=0;i<u[r].length;i++)l(u[r][i])}1===u.length?u=u[0]:h="Multi"+h;var f={type:"Feature",geometry:{type:h,coordinates:u},properties:this.properties};return"id"in this&&(f.id=this.id),f};var Mc=gc,xc=Fc;function Fc(t,n){this.version=1,this.name=null,this.extent=4096,this.length=0,this.wn=t,this.xn=[],this.Fn=[],this.An=[],t.readFields(Ac,this,n),this.length=this.An.length}function Ac(t,n,e){15===t?n.version=e.readVarint():1===t?n.name=e.readString():5===t?n.extent=e.readVarint():2===t?n.An.push(e.pos):3===t?n.xn.push(e.readString()):4===t&&n.Fn.push(function(t){var n=null,e=t.readVarint()+t.pos;for(;t.pos<e;){var r=t.readVarint()>>3;n=1===r?t.readString():2===r?t.readFloat():3===r?t.readDouble():4===r?t.readVarint64():5===r?t.readVarint():6===r?t.readSVarint():7===r?t.readBoolean():null}return n}(e))}Fc.prototype.feature=function(t){if(t<0||t>=this.An.length)throw new Error("feature index out of bounds");this.wn.pos=this.An[t];var n=this.wn.readVarint()+this.wn.pos;return new Mc(this.wn,n,this.extent,this.xn,this.Fn)};var kc=xc;function Pc(t,n,e){if(3===t){var r=new kc(e,e.readVarint()+e.pos);r.length&&(n[r.name]=r)}}var Sc=function(t,n){this.layers=t.readFields(Pc,{},n)};class _c extends Ch{constructor(t,n,e,r,i,s){super(t,n,e,r,i),n=n||{},s()}getTileFeatures(t,n){const e=t.tileInfo.url,r=t.fetchOptions||{};if(this.Ut.has(e)){const{err:t,data:r}=this.Ut.get(e);return setTimeout(()=>{this.kn(e,t,r,n)},1)}return r.referrer=t.referrer,O.getArrayBuffer(e,r,(t,r)=>{this.Ut&&(t?t.loading||this.Ut.add(e,{err:t,data:r&&r.data}):r&&r.data&&this.Ut.add(e,{err:null,data:r.data}),this.kn(e,t,r&&r.data,n))})}kn(t,n,e,r){if(n)return void r(n);let i;try{i=new Sc(new Zl(e))}catch(n){return void r(n.message,[],[])}const s=[];if(!i.layers)return void r(null,s,[]);const o={};let a;for(const t in i.layers)if(u=i.layers,h=t,Object.prototype.hasOwnProperty.call(u,h)){o[t]={types:{}};const e=o[t].types;for(let r=0,o=i.layers[t].length;r<o;r++)try{a=i.layers[t].feature(r),e[a.type]=1;const n={type:a.type,layer:t,geometry:a.loadGeometry(),properties:a.properties,extent:a.extent};void 0!==a.id&&(n.id=a.id);let o=n.properties[vh];o&&(M(o)&&(o=JSON.parse(o)),n.properties[vh]=Jl(o,"EPSG:3857")),s.push(n)}catch(n){console.warn("error when load vt geometry:",n)}}var u,h;for(const t in o)o[t].types=Object.keys(o[t].types).map(t=>+t);r(null,s,o,{byteLength:e.byteLength})}abortTile(t,n){const e=this.requests[t];delete this.requests[t],e&&e.abort&&e.abort(),this.Jt(t),n()}onRemove(){super.onRemove();for(const t in this.requests){const n=this.requests[t];n&&n.abort&&n.abort()}this.requests={}}}let Oc=0;const Ec=new sh(128);class Ic{constructor(t){this.Pn={},this.Sn={},this.workerId=t}addLayer({actorId:t,mapId:n,layerId:e,params:r},i){if(this._n(n,e))return;const s=this.On(n,e),o=r.type,a=r.options,u=this.send.bind(this,t);this.Pn[s]="GeoJSONVectorTileLayer"===o?new Xl(e,a,u,Ec,{},i):new _c(e,a,u,Ec,{},i)}removeLayer({mapId:t,layerId:n},e){const r=this._n(t,n),i=this.On(t,n);delete this.Pn[i],r&&r.onRemove(e)}loadTile({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.loadTile(e,r)}abortTile({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.abortTile&&i.abortTile(e.url,r)}removeTile({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.removeTile(e,r)}updateStyle({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.updateStyle(e,r)}updateOptions({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.updateOptions(e,r)}setData({mapId:t,layerId:n,params:e},r){const i=this._n(t,n);i&&i.setData(e.data,r)}receive(t){const n=t.callback,e=this.Sn[n];delete this.Sn[n],e&&t.error?e(new Error(t.error)):e&&e(null,t.data)}send(t,n,e,r,i){const s=i?`${t}-${Oc++}`:null;i&&(this.Sn[s]=i),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:n,params:e,callback:String(s)},r||[])}On(t,n){return`${t}-${n}`}_n(t,n){const e=this.On(t,n);return this.Pn[e]}En(){Ec.reset()}}t.initialize=function(){},t.onmessage=function(t,n){const e=t.data;if(this.dispatcher||(this.dispatcher=new Ic(t.workerId)),"<response>"===t.type)this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t);else{const r=e.command;this.dispatcher[r]({actorId:t.actorId,mapId:e.mapId,layerId:e.layerId,params:e.params},(t,e,i)=>{t&&404!==t.status&&204!==t.status&&console.error(r,t),n(t,e,i)})}},Object.defineProperty(t,"In",{value:!0})}';let J$4=0;function K$4(){return J$4++}const Z$4="function"==typeof Object.assign;function Q$4(t,...e){if(Z$4)return Object.assign(t,...e),t;for(let n=0;n<e.length;n++){const i=e[n];for(const e in i)t[e]=i[e]}return t}function tt$3(t){return!rt$3(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function et$3(t){return"number"==typeof t&&!isNaN(t)}function nt$3(t){return!rt$3(t)&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function it$3(t){return!Array.isArray(t)&&"object"==typeof t&&!!t}function rt$3(t){return null==t}function st$3(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,i=n.length;e<i;e++)t.push(n[e])}return t.length}function ot$3(t){return isFunctionDefinition(t)&&t.property}function at$3(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function lt$3(t,e){let n;if(e.altitudeToPoint){n=e.altitudeToPoint(100,t);const i=e.options.heightFactor;i&&1!==i&&(n/=i)}else n=e.distanceToPointAtRes(100,0,t).x;return n/100/100}const ht$3=["GeoJSONVectorTileLayer"];class ut$3 extends t__namespace.worker.Actor{constructor(t,e){super(t);const n=e.getMap().id;this.t=e,this.i=n,this.s="vt_"+K$4();const i=e.getJSONType();this.o=ht$3.indexOf(i)>=0,this.l={},this.h=new Aa$1({iconErrorUrl:e.options.iconErrorUrl,maxSize:e.options.maxIconSize});const r=!e.getRenderer().isEnableWorkAround("win-intel-gpu-crash");this.u=new wa$1((t=>{e.getMap().getRenderer().callInNextFrame(t)}),e.options.glyphSdfLimitPerFrame,r)}initialize(t){t(null)}addLayer(t){const e=this.t,n=e.getWorkerOptions()||{},i=this.s,r=e.getJSONType(),s={mapId:this.i,layerId:i,command:"addLayer",params:{type:r,options:n}};this.o?(void 0===this.l[i]&&(this.l[i]=this.getDedicatedWorker()),this.send(s,null,t,this.l[i])):this.broadcast(s,null,t)}abortTile(t,e){const n=this.s,i={mapId:this.i,layerId:n,command:"abortTile",params:{url:t}};this.o?(void 0===this.l[n]&&(this.l[n]=this.getDedicatedWorker()),this.send(i,null,e,this.l[n])):this.broadcast(i,null,e)}removeLayer(t){const e=this.s,n={mapId:this.i,layerId:e,command:"removeLayer"};this.o?(void 0!==this.l[e]&&this.send(n,null,t,this.l[e]),delete this.l[e]):this.broadcast(n,null,t)}updateStyle(t,e){const n=this.s,i={mapId:this.i,layerId:n,command:"updateStyle",params:t};this.o?void 0!==this.l[n]&&this.send(i,null,e,this.l[n]):this.broadcast(i,null,e)}updateOptions(t,e){const n=this.s,i={mapId:this.i,layerId:n,command:"updateOptions",params:t};this.o?void 0!==this.l[n]&&this.send(i,null,e,this.l[n]):this.broadcast(i,null,e)}loadTile(t,e){const n=Q$4({},t);n.tileInfo=function(t){const e={};for(const n in t)null!=t[n]&&(e[n]=t[n].toJSON?t[n].toJSON():t[n]);return e}(t.tileInfo);const i=this.s,r={mapId:this.i,layerId:i,command:"loadTile",params:n},{x:s,y:o}=t.tileInfo;this.send(r,null,e,void 0===this.l[i]?this.workers[(s+o)%this.workers.length].id:this.l[i])}remove(){super.remove(),this.l={}}fetchIconGlyphs({icons:t,glyphs:e},n){this.u.getGlyphs(e,((e,i)=>{if(e)throw e;const r=i.buffers||[];this.h.getIcons(t,((t,e)=>{if(t)throw t;e.buffers&&e.buffers.length&&r.push(...e.buffers),n(null,{icons:e.icons,glyphs:i.glyphs},r)}))}))}setData(t,e){const n=this.s;this.send({mapId:this.i,layerId:n,command:"setData",params:{data:t}},null,e,this.l[n])}m(t){return t.id}}const ct$3={},ft$3={collision:!0,fading:!1,fadingDuration:224,fadeInDelay:600,fadeOutDelay:100,uniquePlacement:!1,depthFunc:"always"};class dt$3{constructor(t,e,n){this.v=t,this.A=e,this._=n||[0,1,0]}draw(t,e,n,i,r){if(this.S||this.M(),!this.P){this.P=this.v.buffer(pt$3(i));this.T=this.v.buffer(mt$3(i,i/n))}if(i!==this.k){const t=i/n;this.P(pt$3(i)),this.T(mt$3(i,t))}this.k=i;let s=this.O;if(!s){const t=this.A.getDevicePixelRatio()>1?2:1;s=this.O=document.createElement("canvas"),s.width=512*t,s.height=64*t;const e=s.getContext("2d");e.font="36px monospace",e.scale(t,t),this.I=this.v.texture({width:s.width,height:s.height,data:s})}const o=s.getContext("2d");o.clearRect(0,0,s.width,s.height),o.fillStyle=`rgba(${this._.map((t=>255*t)).join()})`,o.fillText(t,20,36),this.I({width:s.width,height:s.height,data:s}),this.S({transform:e,data:this.P,texData:this.F,debugLine:1,primitive:"lines",framebuffer:r||null,image:this.I,count:8}),this.S({transform:e,data:this.T,texData:this.F,debugLine:0,primitive:"triangle strip",framebuffer:r||null,image:this.I,count:4})}delete(){this.I&&(this.I.destroy(),delete this.I),this.F&&(this.F.destroy(),delete this.F),this.P&&(this.P.destroy(),this.T.destroy(),delete this.P,delete this.T),this.S&&(this.S.destroy(),delete this.S)}M(){this.F=this.v.buffer(new Uint8Array([0,0,0,1,1,0,1,1,0,0,0,1,1,0,1,1])),this.S=this.v({vert:"\n                attribute vec2 aPosition;\n                attribute vec2 aTexCoord;\n                uniform mat4 transform;\n\n                varying vec2 vTexCoord;\n                void main()\n                {\n                    gl_Position = transform * vec4(aPosition, 0.0, 1.0);\n                    vTexCoord = aTexCoord;\n                }\n            ",frag:"\n                precision mediump float;\n                uniform sampler2D uImage;\n                uniform vec3 uColor;\n                uniform float uOpacity;\n                uniform float uDebugLine;\n\n                varying vec2 vTexCoord;\n\n                void main()\n                {\n                    if (uDebugLine == 1.) {\n                        gl_FragColor = vec4(uColor, 1.0) * uOpacity;\n                    } else {\n                        gl_FragColor = texture2D(uImage, vTexCoord) * uOpacity;\n                    }\n                    gl_FragColor *= gl_FragColor.a;\n                }\n            ",attributes:{aPosition:this.v.prop("data"),aTexCoord:this.v.prop("texData")},uniforms:{transform:this.v.prop("transform"),uColor:this._,uOpacity:1,uDebugLine:this.v.prop("debugLine"),uImage:this.v.prop("image")},count:this.v.prop("count"),primitive:this.v.prop("primitive"),depth:{enable:!1,mask:!1},blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},stencil:{enable:!1},viewport:{x:0,y:0,width:()=>this.A.getRenderer().canvas.width,height:()=>this.A.getRenderer().canvas.height},framebuffer:this.v.prop("framebuffer")})}}function pt$3(t){return new Uint16Array([0,0,0,t,0,t,t,t,t,t,t,0,t,0,0,0])}function mt$3(t,e){return new Uint16Array([0,t-64*e,0,t,512*e,t-64*e,512*e,t])}const yt$3=new Uint8Array([0,0,0,1,1,0,1,0,0,1,1,1]),gt$3=[];class vt$3{constructor(t,e,i){this.v=t,(this.C=new Q$7({aPosition:yt$3},null,yt$3.length/2,{positionSize:2})).generateBuffers(t),this.D=new Ke$5,this.R=[],this.L=0,this.N=e,this.A=i,this.M(t)}start(){this.L=0,this.D.clear()}add(t,e,n){const s=this.H(n);s.setUniform("ref",t),set$4(gt$3,e,e,1);const o=s.localTransform;fromScaling(o,gt$3),mul$5(o,n,o),s.setLocalTransform(o),this.D.addMesh(s)}render(t){this.V.render(this.U,{projViewMatrix:this.A.projViewMatrix},this.D,t)}H(){const t=this.L++;return this.R[t]||(this.R[t]=new Be$5(this.C)),this.R[t]}M(t){const e=this.N,i={viewport:{x:0,y:0,width:()=>e.width,height:()=>e.height},stencil:{enable:!0,mask:255,func:{cmp:"always",ref:(t,e)=>e.ref,mask:255},op:{fail:"replace",zfail:"replace",zpass:"replace"}},depth:{enable:!0,func:"always",mask:!1},colorMask:[!1,!1,!1,!1]};this.U=new vn$4({vert:"\n#define SHADER_NAME TILE_STENCIL_VERT\nattribute vec2 aPosition;\nuniform mat4 projViewModelMatrix;\n\nvoid main()\n{\n    gl_Position = projViewModelMatrix * vec4(aPosition, 0.0, 1.0);\n}\n",frag:"\n#define SHADER_NAME TILE_STENCIL_FRAG\nvoid main()\n{\n    gl_FragColor = vec4(1.0, 0.0, 0.0, 0.1);\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],extraCommandProps:i}),this.V=new B$6(t)}remove(){this.C.dispose();for(let t=0;t<this.R.length;t++)this.R[t].dispose();this.R.length=0,this.U.dispose()}}const xt$3=new Float32Array([-1e12])[0],bt$3="__fea_idx".trim();function At$3(e,n,i,r,s,o){const a={};if(function(t){if(!t)return!1;for(const e in t)if(null!=t[e])return!0;return!1}(e))for(let l=0,h=(n||e).length;l<h;l++){let h=n?e[n[l]]:e[l];"id"===s.options.features&&s.getFeature&&(h=s.getFeature(h),h.layer=i),s instanceof t__namespace.TileLayer&&(h=Pt$3(h,o)),a[n?n[l]:h[bt$3]]={feature:h,symbol:r}}return a}const wt$3="__original_properties",_t$3="__external_properties",St$3={get:function(t,e){return e in t?t[e]:t[wt$3][e]||t[_t$3]&&t[_t$3][e]},has:function(t,e){return e in t||e in t[wt$3]||t[_t$3]&&e in t[_t$3]}},Mt$3={};function Pt$3(t,e){const n=t.properties;if(n&&n[wt$3])return t;e&&(t=Q$4({},t)),t.customProps=t.customProps||{};const i=t.customProps;return i.$layer=t.layer,i.$type=t.type,i[wt$3]=n||Mt$3,t.properties=new Proxy(i,St$3),t}function Tt$3(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function kt$3(t,e,n){return Math.min(n,Math.max(e,t))}function Ot$3(t,e,n){if(t===n||t===e)return t;const i=n-e;return((t-e)%i+i)%i+e}function It$3(t){return null==t}function Ft$3(t){return JSON.parse(JSON.stringify(t))}function Ct$3(t,e,n,i,r,s){e in t||Object.defineProperty(t,e,{enumerable:!0,get:function(){const t=It$3(n[i])||isFunctionDefinition(n[i])?r:n[i];return s?s(t):t}})}const Et$3=[];function Dt$3(t){for(let e=0;e<t.length;e++)Et$3[e]=t[e],Et$3[e]*=255;return 3===t.length&&(Et$3[3]=255),Et$3}function Rt$3(t,e=4){return Lt$3.bind(this,t,e)}function Lt$3(t,e,n){if(Array.isArray(n))return 3===n.length&&4===e&&n.push(1),n;if(t&&t[n])return t[n];if(void 0!==n.r&&void 0!==n.g&&void 0!==n.b&&void 0!==n.a)return[n.r,n.g,n.b,n.a];const i=color(n).unitArray();return 3===i.length&&4===e&&i.push(1),t&&(t[n]=i),i}function Nt$3(t,e,n,i){if(t.fill)t.fill(e,n,i);else for(let r=n;r<i;r++)t[r]=e}function Ht$2(t){return"number"==typeof t&&!isNaN(t)}function zt$2(t){return t&&(t.markerFile||t.markerType)&&void 0!==t.textName}function Vt$2(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Ut$2(t){const e=[t[0]];let n=t[0];for(let i=1;i<t.length;i++)t[i]!==n&&(e.push(t[i]),n=t[i]);return e}const jt$2=new t__namespace.Coordinate(0,0);function Bt$3(t,e,n,i,r){const s=t.distanceToPointAtRes(e,e,i,n,jt$2);return r?s.y:s.x}const Gt$2=[],Wt$2=[0,0,0,0],Xt$2=new t__namespace.Point(0,0),Yt$2={color:Wt$2,depth:1,stencil:0},$t$2=t=>t.isTerrainSkin(),qt$2=t=>t.isTerrainVector();class Jt$2 extends t__namespace.renderer.TileLayerCanvasRenderer{supportRenderMode(){return!0}constructor(t){super(t),this.ready=!1,this.j=0,this.B={},this.G={},this.W={}}getTileLevelValue(t,e){if(this.isBackTile(t.id)){const n=t.z,i=5;return n-e>=0?e+i-n:i+(e-n)}return 0}getWorkerConnection(){return this.X}getStyleCounter(){return this.j}setStyle(t){if(this.Y&&this.Y.update(),this.X){this.j++,this.$();const e=this.layer.q();e.styleCounter=this.j,this.X.updateStyle(e,(e=>{if(e)throw new Error(e);t||(this.J=!0,this.K(),this.setToRedraw()),this.layer.fire("refreshstyle")}))}else this.K()}$(){if(this.Z)for(const t in this.Z){const e=this.Z[t];e&&this.deleteTile(e)}this.Z=this.tilesInView;const t=this.tileCache;for(const e in this.Z){const n=this.Z[e];n&&n.info&&t.getAndRemove(n.info.id)}t.reset(),this.tilesInView={},this.tilesLoading={},this.B={},this._parentTiles=[],this._childTiles=[]}updateOptions(t){this.X&&this.X.updateOptions(this.layer.getWorkerOptions(),(e=>{if(e)throw new Error(e);(t.features||t.pickingGeometry||t.altitudeProperty)&&(this.clear(),this.tt(),this.K()),this.setToRedraw()}))}updateSceneConfig(t,e,n){const i=0===t?this.et():this.nt();if(!i||!i[e])return;this.J=!0;const r=this.layer.q(),s=this.layer.it(t,r);i[e].config=s[e].renderPlugin,i[e].updateSceneConfig({sceneConfig:n}),this.setToRedraw()}updateDataConfig(t,e,n,i){const r=0===t?this.et():this.nt();r&&r[e]&&(this.J=!0,r[e].updateDataConfig(n,i)?this.setStyle():this.setToRedraw())}updateSymbol(t,e,n){const i=0===t?this.et():this.nt();if(!i||!i[e])return!1;const r=this.layer.q(),s=this.layer.it(t,r),o=i[e];o.style=s[e];const a=o.updateSymbol(n,s[e].symbol);return!a&&function t(e){if(Array.isArray(e)){const n=e;for(let e=0;e<n.length;e++)if(t(n[e]))return!0}for(const t in e)if(isFunctionDefinition(e[t])||Mr$3.isExpression(e[t]))return!0;return!1}(n)&&this.setStyle(!0),this.setToRedraw(),a}needToRedraw(){const t=super.needToRedraw();if(!t){const t=this.rt();for(let e=0;e<t.length;e++)if(t[e]&&t[e].needToRedraw())return!0}return t}needRetireFrames(){if(this.J)return!0;const t=this.rt();for(let e=0;e<t.length;e++)if(t[e]&&t[e].needToRetireFrames())return!0;return!1}isAnimating(){const t=this.rt();for(let e=0;e<t.length;e++)if(t[e]&&t[e].isAnimating())return!0;return!1}needToRefreshTerrainTileOnZooming(){const t=this.rt();for(let e=0;e<t.length;e++)if(t[e]&&t[e].needToRefreshTerrainTileOnZooming())return!0;return!1}st(){return!!(this.canvas&&this.canvas.gl&&this.canvas.gl.wrap)}createContext(){const t=this.canvas.gl&&this.canvas.gl.wrap;if(t)this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl;else{const{gl:t,regl:e,attributes:n}=this.ot(this.canvas);this.gl=t,this.regl=e,this.glOptions=n}if(t&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.lt=new dt$3(this.regl,this.getMap()),this.ht(),this.Y=new jt$4(this.regl,this.layer),!this.consumeTile){const t=this.getMap().VERSION;throw new Error(`Incompatible version of maptalks: ${t}, upgrade maptalks >= v1.0.0-rc.14`)}}ot(t){const e=this.layer,n=e.options.glOptions||{alpha:!0,depth:!0,antialias:this.layer.options.antialias};n.preserveDrawingBuffer=!0,n.stencil=!0;const i=this.ut(t,n);return{gl:i,attributes:n,regl:a$2({gl:i,attributes:n,extensions:["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives"],optionalExtensions:e.options.glExtensions||["OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_draw_buffers","EXT_shader_texture_lod","EXT_frag_depth"]})}}ht(){this.X||(this.X=new ut$3("@maptalks/vt",this.layer)),this.X.addLayer(((t,e)=>{this.layer&&(this.ready=!0,this.layer.onWorkerReady(t,e),this.layer.fire("workerready"),this.setToRedraw())}))}clearCanvas(){super.clearCanvas(),this.regl&&this.regl.clear(this.glOptions.depth?{color:Wt$2,depth:1,stencil:0}:{color:Wt$2,stencil:0})}isDrawable(){return!0}checkResources(){return Gt$2}_drawTiles(t,e,n,i,r){if(super._drawTiles(t,e,n,i,r),this.Z)if(Object.keys(this.Z).length)for(const t in this.Z){const e=this.Z[t];this.tileCache.has(e.id)||this._drawTile(e.info,e.image,r)}else this.ct(),delete this.Z}ct(){const t=this.j,e=[],n=[];for(const n in this.G)+n!==t&&(e.push(n),this.et(n).forEach((t=>{t.remove()})));for(const e in this.W)+e!==t&&(n.push(e),this.nt(e).forEach((t=>{t.remove()})));for(let t=0;t<e.length;t++)delete this.G[e[t]];for(let t=0;t<n.length;t++)delete this.W[n[t]]}draw(t,e){this.ft!==t&&(this.J=!1,this.dt());const n=this.layer;if(this.prepareCanvas(),!this.ready||!n.ready)return void this.completeRender();let i=this.G[this.j];i||(this.K(),this.dt(),i=this.et());const r=this.nt();n.isDefaultRender()||i.length||r.length?(n.options.collision&&n.clearCollisionIndex(),this.pt=t,this.yt=this.gt(this.getMap().getGLRes()),this.vt=e||{},this.xt(t),super.draw(t),this.ft!==t&&this.bt(t),this.At(t),this.completeRender(),this.ft=t):this.completeRender()}dt(){this.rt().forEach(((t,e)=>{t&&(t.renderIndex=e)}))}bt(){const t=this.rt();this.wt=this.wt||[];let e=0;for(let n=t.length-1;n>=0;n--){const i=t[n];i.isVisible()&&i.hasMesh()&&(this.wt[n]=e,i.needPolygonOffset()&&e++)}this.Y.isEnable()&&e++,this._t=e}getFrameTimestamp(){return this.pt}drawOnInteracting(t,e,n){this.draw(e,n)}drawOutline(t){(this.St||this.Mt)&&(this.Mt?this.paintOutlineAll(t):this.St.forEach((e=>{this[e[0]](t,...e[1])})))}getAnalysisMeshes(){return this.getShadowMeshes()}getShadowMeshes(){const t=[];return this.Pt().forEach((e=>{if(!e)return;if(!this.Tt(e))return;const n=e.getShadowMeshes();if(Array.isArray(n))for(let e=0;e<n.length;e++)t.push(n[e])})),t}isForeground(t){return!(!this.kt||!this.kt[t.properties.tile.id])}Ot(e){const n=this.layer;let i=n._getTileZoom(this.getMap().getZoom());const r=n.getMinZoom(),s=n.getMaxZoom();return i=t__namespace.Util.clamp(i,r,s),i-e.properties.tile.z}isTileNearCamera(t){return this.Ot(t)<=1}isBackTile(t){return!(!this.It||!this.It[t])}loadTile(e){const{url:n}=e,i=this.B[n];if(i)i.keys[e.id]||(i.tiles.push(e),i.keys[e.id]=1);else{const i=this.getMap(),r=Xt$2.set(e.extent2d.xmin,e.extent2d.ymax),s=i.pointAtResToCoord(new t__namespace.Point(r),e.res),o=[Bt$3(i,1,s,e.res)/100,Bt$3(i,1,s,e.res,1)/100],a=this.getCentimeterToPoint(e.z),l=this.getTileGLScale(e.z);this.B[n]={keys:{},tiles:[e]},this.B[n].keys[e.id]=1;const u=window&&window.location.href;this.X.loadTile({tileInfo:{res:e.res,x:e.x,y:e.y,z:e.z,url:e.url,id:e.id,extent2d:e.extent2d},glScale:l,zScale:this.yt,centimeterToPoint:o,verticalCentimeterToPoint:a,fetchOptions:this.layer.options.fetchOptions,styleCounter:this.j,referrer:u},this.Ft.bind(this,n))}return{}}getTileGLScale(t){const e=this.getMap();return this.layer.getSpatialReference().getResolution(t)/e.getGLRes()}getCentimeterToPoint(t){const e=this.getMap();return lt$3(this.layer.getSpatialReference().getResolution(t),e)}getRenderedFeatures(){const t=[],e=this.tileCache.keys();for(let n=0;n<e.length;n++){const i=this.tileCache.get(e[n]);if(!i||!i.info||!i.image)continue;const{info:r,image:s}=i,o=ee$2(s);t.push({tile:{id:r.id,x:r.x,y:r.y,z:r.z,url:r.url},current:!!this.tilesInView[r.id],features:o})}return t}Ft(t,e,n){if(this.setToRedraw(),!this.B[t])return;if(n&&n.canceled)return;const i=this.layer,r=i.isDefaultRender(),{tiles:s}=this.B[t];if(delete this.B[t],e){if(e.status&&(404===e.status||204===e.status))for(let t=0;t<s.length;t++){this.onTileError(ct$3,s[t])}return}if(!n){for(let t=0;t<s.length;t++){this.consumeTile({Ct:!0},s[t])}return}if(n.style!==this.j)return;let o=!1;const a=n.features,l=[];for(let t=0;t<n.data.length;t++){const e=n.data[t];if(!e||!e.data||!e.styledFeatures.length)continue;const{isUpdated:i,layer:r}=this.Et(0,t,e,a,l);l.push(r),i&&(o=i)}for(let t=0;t<n.featureData.length;t++){const e=n.featureData[t];e&&e.data&&e.styledFeatures.length&&this.Et(1,t,e,a)}o&&i.Dt();const u=this.layer.getDataSchema(s[0].z);if(this.Rt(u,n.schema),delete n.features,r&&n.data.length!==l.length){const t=n.data;n.data=[];for(let e=0;e<t.length;e++)t[e]&&t[e].features&&n.data.push(t[e])}n.layers=l;for(let t=0;t<s.length;t++){const e=s[t];if(0===t&&i.options.debugTileData){const{x:t,y:n,z:r}=e;console.log("tile",{layerId:i.getId(),x:t,y:n,z:r,layers:Qt$2(Object.values(a))})}const r=0===t?n:Kt$2(n);for(let t=0;t<r.data.length;t++){if(!r.data[t])continue;const n=r.data[t].features;for(const t in n)n[t].tile=e}e.extent=r&&r.extent,this.onTileLoad(r,e)}this.layer.fire("datareceived",{url:t})}Et(t,e,n,i){const{style:r,isUpdated:s}=this.Lt(t,e,n.data),o=this.layer,a=o.isDefaultRender(),h=At$3(i,n.styledFeatures,e,r.symbol,o,!(!o.getData||!o.getData()));delete n.styledFeatures,n.features=h;let u=n.data;return Array.isArray(u)&&(u=u[0]),{isUpdated:s,layer:a?{layer:u.layer,type:u.type}:null}}Rt(t,e){for(const n in e){t[n]||(t[n]={types:e[n].types,properties:{}});const i=e[n].properties,r=t[n].properties;for(const t in i)(!r[t]||r[t]&&"object"!==i[t]&&"object"===r[t])&&(r[t]=i[t])}}Lt(t,e,n){Array.isArray(n)&&(n=n[0]);const i=this.layer;let r,s=!1;if(i.isDefaultRender()&&0===t){let t=this.Nt;t||(t=this.Nt={});const e=n.layer,i=n.type;t[e]||(t[e]=[]);const o=("plugin_"+i).trim();t[e][o]?r=t[e][o]:(r=this.Ht(i),r.filter=n.filter,t[e].push(r),t[e][o]=r,s=!0)}else{const o=i.q(),a=i.it(t,o),l=this.et();if(r=a[e],!r.renderPlugin){s=!0;const{plugin:t,symbol:i,renderPlugin:o}=this.Ht(n.type);l[e]=t,r.symbol=i,r.renderPlugin=o}}return{style:r,isUpdated:s}}rt(t){const e=t&&t.style;let n=this.et(e)||[];this.layer.isDefaultRender()&&this.Nt&&(n=[],t?t.layers&&t.layers.forEach((t=>{if(!t)return;const e=("plugin_"+t.type).trim();n.push(this.Nt[t.layer][e].plugin)})):Object.keys(this.Nt).forEach((t=>{for(let e=0;e<this.Nt[t].length;e++)n.push(this.Nt[t][e].plugin)})));const i=this.nt(e);return i&&i.length&&(n=n.slice(),st$3(n,i)),n}Pt(){if(this.layer.isDefaultRender()&&this.Nt){const t=[];return Object.keys(this.Nt).forEach((e=>{for(let n=0;n<this.Nt[e].length;n++)t.push(this.Nt[e][n].plugin)})),t}const t=[];for(const e in this.G)t.push(...this.G[e]);for(const e in this.W)t.push(...this.W[e]);return t}et(t){return rt$3(t)&&(t=this.j),this.G[t]||Gt$2}nt(t){return rt$3(t)&&(t=this.j),this.W[t]||Gt$2}xt(t,e){const n=!!this.zt,i=this.layer.isDefaultRender()&&this.Nt,r=this.vt;this.Pt().forEach(((s,o)=>{if(!s||e&&!e(s))return;if(!this.Tt(o))return;const u={regl:this.regl,layer:this.layer,symbol:i?s.defaultSymbol:s.style&&s.style.symbol,gl:this.gl,isRenderingTerrain:n,sceneConfig:s.config?s.config.sceneConfig:null,dataConfig:s.config?s.config.dataConfig:null,pluginIndex:o,timestamp:t};r&&Q$4(u,r),s.startFrame(u)}))}At(t){const e=this.vt,n=e.renderMode,i=e&&e.renderTarget&&e.renderTarget.fbo,r=this.getMap().cameraPosition,s=this.Pt(),o=!!this.zt,a=!e.timestamp||e.isFinalRender;s.forEach(this.layer.options.collision&&!e.isPostProcess?e=>{if(!this.Tt(e)||!e.hasMesh())return;if(n&&"default"!==n&&!e.supportRenderMode(n))return;if(o&&!qt$2(e))return;const i=this.Vt(e,0,r,t);e.prepareRender(i),e.updateCollision(i)}:e=>{if(!this.Tt(e)||!e.hasMesh())return;if(n&&"default"!==n&&!e.supportRenderMode(n))return;if(o&&!qt$2(e))return;const i=this.Vt(e,0,r,t);e.prepareRender(i)});let h=!1;if(this.ft!==e.timestamp&&!o){const e=this.layer.getPolygonOffset()+this.layer.getPolygonOffsetCount(),n=this.Vt(null,e,r,t);n.offsetFactor=e,n.offsetUnits=e,this.Y.paint(n)}s.forEach(((e,s)=>{if(!this.Ut(e))return;if(n&&"default"!==n&&!e.supportRenderMode(n))return;if(o&&!qt$2(e))return;this.regl.clear({stencil:255,framebuffer:i}),this.isEnableTileStencil()&&e.painter&&!e.painter.needClearStencil()&&this.jt(i);const l=this.Vt(e,this.wt[s]||0,r,t),u=e.endFrame(l);u&&u.redraw&&this.setToRedraw(),h=!0})),h&&this.layer.fire("canvasisdirty"),a&&this.Bt()}getPolygonOffsetCount(){return this._t||0}Bt(){if(this.layer.options.debug){const t=this.vt,e=[],n=this.getMap().projViewMatrix;for(const i in this.tilesInView){const s=this.tilesInView[i].info,o=s.transform,a=this.tilesInView[i].image.extent,l=t&&t.renderTarget;if(o&&a){const t=this.getDebugInfo(s.id),i=multiply$5(e,n,o),h=this.layer.getTileSize().width;this.lt.draw(t,i,h,a,l&&l.fbo)}}}}Ut(t){if(!t)return!0;const e=this.vt,n=this.Tt(t),i=e&&e.states&&e.states.includesChanged,r=this.Gt(t.painter.scene.getMeshes());return n&&(i||r)?r?2:1:0}Vt(t,e,n,i){const r=!!this.zt,s=r&&t&&$t$2(t),l={regl:this.regl,layer:this.layer,gl:this.gl,isRenderingTerrain:r,isRenderingTerrainSkin:s,sceneConfig:t&&t.config.sceneConfig,pluginIndex:t&&t.renderIndex,polygonOffsetIndex:e,cameraPosition:n,timestamp:i},h=this.vt;return h&&Q$4(l,h),l}Gt(t){if(!t)return!1;const e=this.vt&&this.vt.sceneFilter;return e?t.filter((t=>e(t)||t.properties.hlBloomMesh&&e(t.properties.hlBloomMesh))).length>0:t.length>0}jt(t){const e=this.isEnableTileStencil(),n=this.getCurrentTileZoom();let i=this.Wt;i||(i=this.Wt=new vt$3(this.regl,this.canvas,this.getMap())),i.start();const{tiles:r}=this.Xt;let{parentTiles:s,childTiles:o}=this.Xt,a=1;o=o.sort(Zt$2);for(let t=0;t<o.length;t++)this.Yt(o[t].info,e?a:this.getTileLevelValue(o[t].info.z,n)),a++;s=s.sort(Zt$2);for(let t=0;t<s.length;t++)this.Yt(s[t].info,e?a:this.getTileLevelValue(s[t].info.z,n)),a++;const l=r.sort(Zt$2);for(let t=l.length-1;t>=0;t--)this.Yt(l[t].info,e?a:this.getTileLevelValue(l[t].info.z,n)),a++;i.render(t)}Yt(t,e){const n=Xt$2.set(t.extent2d.xmin,t.extent2d.ymax),i=t.transform=t.transform||this.calculateTileMatrix(n,t.z,t.extent);t.stencilRef=e,this.Wt.add(e,t.extent,i)}onDrawTileStart(t){super.onDrawTileStart(t);const{tiles:e,childTiles:n,parentTiles:i}=t;this.kt={},this.It={};for(let t=0;t<e.length;t++)this.kt[e[t].info.id]=1;for(let t=0;t<n.length;t++)this.It[n[t].info.id]=1;for(let t=0;t<i.length;t++)this.It[i[t].info.id]=1;this.Xt=t}isEnableTileStencil(){if(this.layer.options.altitude)return!1;const t=this.rt();for(let e=0;e<t.length;e++)if(t[e]&&t[e].painter&&!t[e].painter.isOnly2D())return!1;return!0}setTerrainHelper(t){this.zt=t}getTerrainHelper(){return this.zt}drawTileOnTerrain(...t){Jt$2.prototype.drawTile.call(this,...t)}createTerrainTexture(t){const e=this.layer.getTileSize().width,n=2*e,i=2*e,r=t.texture({min:"linear",mag:"linear",type:"uint8",width:n,height:i});this.$t||(this.$t=t.renderbuffer({width:n,height:i,format:"depth24 stencil8"}));const s={width:n,height:i,colors:[r],colorFormat:"rgba",ignoreStatusCheck:!0};s.depthStencil=this.$t;const o=t.framebuffer(s);return o.colorTex=r,o}deleteTerrainTexture(t){t.destroy(),t.colorTex&&(t.colorTex.destroy(),delete t.colorTex)}renderTerrainSkin(t,e,n){const i=this.ft,r=this.vt,s=this.layer.getTileSize().width;this.xt(i);for(let e=0;e<n.length;e++){const i=n[e].texture;this.vt={renderTarget:{fbo:i}},Yt$2.framebuffer=i,t.clear(Yt$2),this.vt.viewport=te$2(s),this.qt(n[e].tile,i)}this.Jt(n),this.vt=r}qt(t){const{info:e,image:n}=t;this.drawTile(e,n,$t$2)}Jt(t){const e=this.Pt(),n=this.getMap().cameraPosition,i=this.ft||0;e.forEach(this.layer.options.collision?t=>{if(!this.Tt(t)||!t.hasMesh())return;if(!$t$2(t)||!this.layer.options.awareOfTerrain)return;const e=this.Vt(t,0,n,i);e.isRenderingTerrainSkin=!0,t.prepareRender(e),t.updateCollision(e)}:t=>{if(!this.Tt(t)||!t.hasMesh())return;if(!$t$2(t)||!this.layer.options.awareOfTerrain)return;const e=this.Vt(t,0,n,i);e.isRenderingTerrainSkin=!0,t.prepareRender(e)}),e.forEach(((e,n)=>{if(!this.Ut(e)||!$t$2(e))return;for(let e=0;e<t.length;e++){this.regl.clear({stencil:255,framebuffer:t[e].texture})}const r=this.Vt(e,this.wt[n]||0,[0,0,0],this.ft);r.isRenderingTerrainSkin=!0,e.endFrame(r)}))}drawTile(t,e,n){if(!e.cache)return;const i=!!this.zt,r=e.cache,s=Xt$2.set(t.extent2d.xmin,t.extent2d.ymax),o=t.transform=t.transform||this.calculateTileMatrix(s,t.z,t.extent),a=t.tileTranslationMatrix=t.tileTranslationMatrix||this.calculateTileTranslationMatrix(s,t.z),l=t.terrainTransform=t.terrainTransform||this.calculateTerrainTileMatrix(s,t.z,t.extent),h=this.vt,u=[];st$3(u,e.data),st$3(u,e.featureData),this.rt(e).forEach(((s,c)=>{if(!s||n&&!n(s))return;if(!u[c])return;if(!r[c])return;const f=i&&$t$2(s),m={regl:this.regl,layer:this.layer,gl:this.gl,sceneConfig:s.config.sceneConfig,pluginIndex:c,tileCache:r[c],tileData:u[c],tileTransform:f?l:o,tileVectorTransform:o,tileTranslationMatrix:a,tileExtent:e.extent,timestamp:this.pt,tileInfo:t,tileZoom:this._tileZoom,bloom:this.vt&&this.vt.bloom,isRenderingTerrain:i,isRenderingTerrainSkin:f};f&&h&&h.renderTarget&&(m.renderTarget=h.renderTarget);const y=s.paintTile(m);!this.J&&(y.retire||y.redraw)&&s.supportRenderMode("taa")&&(this.J=!0),y.redraw&&this.setToRedraw()})),e&&e.style===this.j&&this.Kt(t),this.setCanvasUpdated()}Zt(t,e){if(!e.loadTime||e.Ct)return;let n=e.cache;n||(n=e.cache={});const i=!!this.zt,r=Xt$2.set(t.extent2d.xmin,t.extent2d.ymax),s=t.transform=t.transform||this.calculateTileMatrix(r,t.z,e.extent),o=t.tileTranslationMatrix=t.tileTranslationMatrix||this.calculateTileTranslationMatrix(r,t.z),a=t.terrainTransform=t.terrainTransform||this.calculateTerrainTileMatrix(r,t.z,t.extent),l=[];st$3(l,e.data),st$3(l,e.featureData),this.rt(e).forEach(((r,h)=>{if(!r)return;if(!l[h])return;const u=i&&$t$2(r),c=this.regl,f=this.gl;n[h]||(n[h]={});const p=r.createTile({regl:c,layer:this.layer,gl:f,sceneConfig:r.config.sceneConfig,pluginIndex:h,tileCache:n[h],tileData:l[h],tileTransform:u?a:s,tileVectorTransform:s,isRenderingTerrain:i,isRenderingTerrainSkin:u,tileTranslationMatrix:o,tileExtent:e.extent,timestamp:this.pt,tileInfo:t,tileZoom:this._tileZoom});n[h].geometry&&(e.data[h]=1),!this.J&&p.retire&&r.supportRenderMode("taa")&&(this.J=!0)}))}checkTileInQueue(t){return t.style===this.j}pick(t,e,n){const i=[];return this.layer.isVisible()?(this.rt().forEach((r=>{if(!r)return;if(!this.Tt(r))return;const s=r.pick(t,e,n.tolerance);s&&(s.type=r.getType(),i.push(s))})),i):i}deleteTile(t){if(t){if(t.image&&!t.image.Ct){const n=this.et(t.image&&t.image.style);n&&n.forEach(((e,n)=>{e&&e.deleteTile({pluginIndex:n,regl:this.regl,layer:this.layer,gl:this.gl,tileCache:t.image.cache?t.image.cache[n]:{},tileInfo:t.info,tileData:t.image})})),t.image.cache={}}t.info&&(delete t.info.completeTerrainQuery,delete t.info.terrainQueryStatus),super.deleteTile(t)}}abortTileLoading(t,e){e&&e.url&&(this.X&&this.X.abortTile(e.url),delete this.B[e.url]),super.abortTileLoading(t,e)}resizeCanvas(t){super.resizeCanvas(t);const e=this.canvas;e&&(!this.pickingFBO||this.pickingFBO.width===e.width&&this.pickingFBO.height===e.height||(this.pickingFBO.resize(e.width,e.height),this.rt().forEach((t=>{t&&t.resize(e.width,e.height)}))))}onRemove(){this.Wt&&this.Wt.remove(),this.X&&(this.X.removeLayer((t=>{if(t)throw t})),this.X.remove(),delete this.X),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.lt&&(this.lt.delete(),delete this.lt),this.$t&&(this.$t.destroy(),delete this.$t),this.Y&&(this.Y.dispose(),delete this.Y),super.onRemove&&super.onRemove(),this.tt()}tt(){this.Pt().forEach((t=>{t.remove()})),this.plugins={}}hitDetect(t){if(!this.gl||!this.layer.options.hitDetect)return!1;const e=this.gl,n=new Uint8Array(4);return e.readPixels(t.x,this.canvas.height-t.y,1,1,e.RGBA,e.UNSIGNED_BYTE,n),n[3]>0}K(){const{style:t,featureStyle:e}=this.layer.q(),n=t.map(((t,e)=>{const n=t.renderPlugin;if(!n)return null;if(!n.type)throw new Error("invalid plugin type for style at "+e);const i=this.Qt(n);return i.styleCounter=this.j,i.style=t,i})),i=[];e.forEach(((t,e)=>{const n=t.renderPlugin;if(!n)return null;if(!n.type)throw new Error("invalid plugin type for features at "+e);const r=this.Qt(n);return r.style=t,r.styleCounter=this.j,i.push(r),r}));const r=this.j;return this.G[r]=n,this.W[r]=i,this.layer.fire("pluginsinited"),(this.te&&this.te.size||this.layer.te)&&(this.layer.te&&this.layer.ee(),this.getMap().getRenderer().callInNextFrame((()=>{this.rt().forEach((t=>{t.highlight(this.te)}))}))),n}Qt(t){const e=this.layer.constructor.getPlugins()[t.type];if(!e)throw new Error(`Plugin for (${t.type}) is not loaded.`);const n=new e;return n.config=t,n.config.sceneConfig||(n.config.sceneConfig={}),n}ut(t,e){const n=["webgl","experimental-webgl"];let i=null;for(let r=0;r<n.length;++r){try{i=t.getContext(n[r],e)}catch(t){}if(i)break}return i}gt(t){return lt$3(t,this.getMap())}debugFBO(t,e){const n=document.getElementById(t),i=e.width,r=e.height;n.width=i,n.height=r;const s=n.getContext("2d"),o=this.regl.read({framebuffer:e}),a=r/2|0,l=4*i;for(let t=0;t<o.length;t++)o[t]*=255;const h=new Uint8Array(4*i);for(let t=0;t<a;++t){const e=t*l,n=(r-t-1)*l;h.set(o.subarray(e,e+l)),o.copyWithin(e,n,n+l),o.set(h,n)}const u=new ImageData(i,r);u.data.set(o),s.putImageData(u,0,0)}Ht(t){let e;switch(t){case"native-line":e={type:"native-line",dataConfig:{type:"native-line",only2D:!0}};break;case"native-point":e={type:"native-point",dataConfig:{type:"native-point",only2D:!0}};break;case"fill":e={type:"fill",dataConfig:{type:"fill",only2D:!0},sceneConfig:{antialias:!0}};break;default:e=null}const n=function(t){switch(t){case"native-point":return{markerFill:"#f00",markerSize:6,markerOpacity:.5};case"native-line":return{lineColor:"#bbb",lineOpacity:.5};case"fill":return{polygonFill:"#76a6f0",polygonOpacity:.8}}return null}(t),i=this.Qt(e);return i.defaultSymbol=n,{plugin:i,symbol:n,renderPlugin:e}}Tt(){return!0}isEnableWorkAround(t){return"win-intel-gpu-crash"===t&&this.layer.options.workarounds["win-intel-gpu-crash"]&&function(t){const e=t.getExtension("WEBGL_debug_renderer_info");if(e&&"undefined"!=typeof navigator){const n=t.getParameter(e.UNMASKED_RENDERER_WEBGL),i="Win32"===navigator.platform||"Win64"===navigator.platform;if(n&&n.toLowerCase().indexOf("intel")>=0&&i)return!0}return!1}(this.gl)}getZScale(){return this.yt}outline(t,e){e&&(Array.isArray(e)||(e=[e]),this.St||(this.St=[]),this.St.push(["paintOutline",[t,e]]),this.setToRedraw())}outlineFeatures(t){t&&(Array.isArray(t)||(t=[t]),this.St||(this.St=[]),this.St.push(["paintOutline",[null,t]]),this.setToRedraw())}outlineBatch(t){this.St||(this.St=[]),this.St.push(["paintBatchOutline",[t]]),this.setToRedraw()}outlineAll(){this.Mt=!0,this.setToRedraw()}paintOutlineAll(t){const e=this.rt();for(let n=0;n<e.length;n++)e[n].outlineAll(t)}paintOutline(t,e,n){if(!rt$3(e)){const i=e,r=this.rt();if(!r[i]||r[i].painter&&!r[i].painter.isVisible())return;return void r[i].outline(t,n)}const i=this.rt();for(let e=0;e<n.length;e++){const r=n[e];for(let e=0;e<i.length;e++)i[e].style&&i[e].style.id===r&&i[e].outline(t,[r])}}paintBatchOutline(t,e){const n=this.rt();!n[e]||n[e].painter&&!n[e].painter.isVisible()||n[e].outlineAll(t)}cancelOutline(){delete this.St,delete this.Mt,this.setToRedraw()}setZIndex(){return this.setToRedraw(),this.J=!0,super.setZIndex.apply(this,arguments)}consumeTile(t,e){this.Kt(e),super.consumeTile(t,e),this.Zt(e,t)}onTileError(t,e){this.Kt(e),super.onTileError(t,e)}Kt(t){const{id:e}=t;if(this.Z&&this.Z[e]){this.deleteTile(this.Z[e]),delete this.Z[e]}}highlight(t){if(this.te||(this.te=new Map),Array.isArray(t))for(let e=0;e<t.length;e++)rt$3(t[e].name)&&!rt$3(t[e].id)&&(t[e]=Q$4({},t[e]),t[e].name=t[e].id),this.te.set(t[e].name,t[e]);else rt$3(t.name)&&!rt$3(t.id)&&((t=Q$4({},t)).name=t.id),this.te.set(t.name,t);this.rt().forEach((t=>{t.highlight(this.te)}))}cancelHighlight(t){if(this.te){if(Array.isArray(t))for(let e=0;e<t.length;e++)this.te.delete(t[e]);else this.te.delete(t);this.rt().forEach((t=>{t.highlight(this.te)}))}}cancelAllHighlight(){delete this.te,this.rt().forEach((t=>{t.cancelAllHighlight()}))}ne(){const t=this.layer.options.opacity;return this.st()?rt$3(t)?1:t:1}}function Kt$2(t){let e;Array.isArray(t.data)?(e=[],st$3(e,t.data)):(e={},Q$4(e,t.data));const n=Q$4({},t);return n.data=e,n}function Zt$2(t,e){return e.info.z-t.info.z}function Qt$2(t){const e={};for(let n=0;n<t.length;n++){const i=t[n].layer||"default";e[i]||(e[i]=[]),e[i].push(t[n])}return e}function te$2(t){return{x:0,y:0,width:2*t,height:2*t}}function ee$2(t){if(!t.cache)return[];for(const e in t.cache){const n=t.cache[e];if(n.geometry)for(let t=0;t<n.geometry.length;t++){const e=n.geometry[t]&&n.geometry[t].geometry;if(e&&e.properties&&e.properties.features){const t=e.properties.features.empty;delete e.properties.features.empty;const n=Object.values(e.properties.features);return void 0!==t&&(e.properties.features.empty=t),n}}}return[]}function ne$2(t,e,n){for(let i=0;i<t.length;i++){const r=t[i],s=Q$4({},r),{renderPlugin:o}=r,a=Q$4({},o);a.sceneConfig&&!Object.keys(a.sceneConfig).length&&delete a.sceneConfig;let l=-1;for(let t=n.length-1;t>=0;t--)if(fastDeepEqual(a,n[t])){l=t;break}l<0&&(l=n.length,n.push(a)),s.renderPlugin=l,e.push(s)}}Jt$2.include({calculateTileMatrix:function(){const t=new Array(3),e=new Array(3),n=new Array(3);return function(s,o,a){const l=this.getTileGLScale(o),h=s,u=this.layer.getTileSize().width,c=identity$2([]);return scale$5(c,c,set$4(t,l,l,this.yt)),translate$1(c,c,set$4(e,h.x,h.y,0)),scale$5(c,c,set$4(n,u/a,-u/a,1)),c}}(),calculateTerrainTileMatrix:function(){const t=new Array(3);return function(e,n,s){const o=identity$2([]),a=s/2;return scale$5(o,o,set$4(t,1/a,-1/a,0)),translate$1(o,o,set$4(t,-a,-a,0)),o}}(),calculateTileTranslationMatrix:function(){const t=new Array(3);return function(e,n){const s=this.getTileGLScale(n),o=e,a=identity$2([]);return translate$1(a,a,set$4(t,o.x*s,o.y*s,0)),a}}()});const ie$2="function"==typeof fetch&&"function"==typeof AbortController,re$2={jsonp:function(t,e){const n="_maptalks_jsonp_"+K$4();t.match(/\?/)?t+="&callback="+n:t+="?callback="+n;let i=document.createElement("script");return i.type="text/javascript",i.src=t,window[n]=function(t){e(null,t),document.getElementsByTagName("head")[0].removeChild(i),i=null,delete window[n]},document.getElementsByTagName("head")[0].appendChild(i),this},get:function(t,e,n){if(nt$3(e)){const t=n;n=e,e=t}(e=e||{}).method&&(e.method=e.method.toUpperCase());const i="POST"===e.method;if(ie$2){const i=new AbortController,r=e;r.signal=i.signal,r.referrerPolicy=r.referrerPolicy||"origin",r.method=r.method||"GET";const s=new Request(t,r);return e.returnJSON&&s.headers.set("Accept","application/json"),fetch(s).then((i=>{const r=this.ie(i,e.returnJSON,e.responseType);r.message?(r.url=t,n(r)):r.then((t=>{n(null,"arraybuffer"===e.responseType?{data:t,cacheControl:i.headers.get("Cache-Control"),expires:i.headers.get("Expires"),contentType:i.headers.get("Content-Type")}:t)})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))}))})).catch((e=>{e.code&&e.code===DOMException.ABORT_ERR||(console.error("Fetch error:",t,e),n(e))})),i}{const r=re$2.re(n);if(r.open(e.method||"GET",t,!0),e){for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);r.withCredentials="include"===e.credentials,e.responseType&&(r.responseType=e.responseType)}return r.send(i?e.body:null),r}},ie:(t,e,n)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===n?t.arrayBuffer():e?t.json():t.text(),se:function(t,e){return function(){4===t.readyState&&(200===t.status?"arraybuffer"===t.responseType?0===t.response.byteLength?e({status:200,statusText:t.statusText,message:"http status 200 returned without content."}):e(null,{data:t.response,cacheControl:t.getResponseHeader("Cache-Control"),expires:t.getResponseHeader("Expires"),contentType:t.getResponseHeader("Content-Type")}):e(null,t.responseText):e({status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}))}},re:function(t){let e;try{e=new XMLHttpRequest}catch(t){try{e=new ActiveXObject("Msxml2.XMLHTTP")}catch(t){try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}}return e.onreadystatechange=re$2.se(e,t),e},getArrayBuffer(t,e,n){if(nt$3(e)){const t=n;n=e,e=t}return e||(e={}),e.responseType="arraybuffer",re$2.get(t,e,n)},getJSON:function(t,e,n){if(nt$3(e)){const t=n;n=e,e=t}const i=function(t,e){const i="string"==typeof e?JSON.parse(e):e||null;n(t,i)};return e&&e.jsonp?re$2.jsonp(t,i):((e=e||{}).returnJSON=!0,re$2.get(t,e,i))}},se$2=new t__namespace.Point(0,0),oe$2=new t__namespace.Coordinate(0,0),ae$2=[null,0],le$2=[];class he$2 extends t__namespace.TileLayer{static loadFrom(t,e){return fetch(t,e||{}).then((t=>t.json())).then((t=>he$2.fromJSON(t)))}constructor(t,e){super(t,e),this.VERSION=he$2.VERSION;this.setStyle(e&&e.style)}onAdd(){const t=this.getMap();this.oe();const e=this.getSpatialReference().toJSON().projection,n=t.getSpatialReference().toJSON().projection;if((e&&e.toLowerCase())!==(n&&n.toLowerCase()))throw new Error(`VectorTileLayer's projection(${e}) must be the same with map(${n}).`)}setFeatureState(t,e){if(rt$3(t.id))throw new Error("missing id in first parameter of setFeatureState.");this.ae||(this.ae={});const n=t.layer||"0";let i=this.ae[n];return this.ae[n]||(i=this.ae[n]=new Map),i.set(t.id,e),this.le(),this}removeFeatureState(t,e){if(rt$3(t.id))throw new Error("missing id in first parameter of removeFeatureState.");if(!this.ae)return this;const i=this.ae[t.layer||"0"];if(!i)return this;if(e){const n=i.get(t.id);if(it$3(e))for(const t in e)delete n[t];else delete n[e];i.set(t.id,n)}else i.delete(t.id);return this.le(),this}getFeatureState(t){if(rt$3(t.id))throw new Error("missing id in first parameter of getFeatureState.");if(!this.ae)return null;return this.ae[t.layer||"0"].get(t.id)}le(){const t=this.getRenderer();if(!t)return;const e=t.getFrameTimestamp();this.he=e}ue(){return this.he}ce(t){return this.he&&this.he!==t}oe(){const t=this.getMap().getProjection(),e="EPSG:4326"===t.code||"EPSG:4490"===t.code,n="EPSG:3857"===t.code;this.options.spatialReference||512===this.getTileSize().width&&(n?this.options.spatialReference="preset-vt-3857":e&&(this.options.spatialReference="preset-vt-4326")),this.options.tileSystem||(this.options.tms?n?this.options.tileSystem=[1,1,-6378137*Math.PI,-6378137*Math.PI]:e&&(this.options.tileSystem=[1,1,-180,-90]):e&&(this.options.tileSystem=[1,-1,-180,90]))}onWorkerReady(){}onConfig(t){const e=this.getRenderer();e&&e.updateOptions(t)}getWorkerOptions(){const t=this.getMap();return{debug:this.options.debug,debugTile:this.options.debugTile,altitudeProperty:this.options.altitudeProperty,tileSize:this.getTileSize().width,baseRes:t.getGLRes(),style:this.isDefaultRender()?{style:[],featureStyle:[]}:this.q(),features:this.options.debugTileData||this.options.features,schema:this.options.schema,pickingGeometry:this.options.pickingGeometry,projectionCode:this.getSpatialReference().getProjection().code,workerGlyph:this.options.workerGlyph,featureIdProperty:this.options.featureIdProperty}}setStyle(t){if(t&&(tt$3(t)||t.url)){const e=t,n=e.lastIndexOf("/"),i=n<0?".":e.substring(0,n);return this.ready=!1,re$2.getJSON(t.url?t.url:t,t.url?t:{},((t,n)=>{if(t)throw this.setStyle([]),t;let r;n.style?(r=n,r.$root||(r.$root=i)):r={$root:i,style:n},this.options.style=e,this.fe(r)})),this}return this.options.style=t,this.fe(t),this}de(t,e,n,i){const r=i/this.getTileSize().width;return t.set(n.x+e.x/r,n.y-e.y/r)}queryTilePointTerrain(t,e,n,i,r){const s=this.getRenderer(),o=s&&s.getTerrainHelper();if(!s||!o)return ae$2[0]=null,ae$2[1]=0,ae$2;const a=this.de(se$2,t,n,i);return e&&o.queryTileTerrainByPointAtRes?o.queryTileTerrainByPointAtRes(a,r,e.id,e,le$2):(ae$2[0]=null,ae$2[1]=0,ae$2)}queryTerrainTiles(t){const e=this.getRenderer(),n=e&&e.getTerrainHelper();return e&&n?n.getTerrainTiles(t):null}fe(t){if(this.pe=null,t&&t.$root){let e=t.$root;e&&"/"===e[e.length-1]&&(e=e.substring(0,e.length-1)),this.pe=e,this.me=function(t){return"{$root}"===t?e:null}}this.ready=!0,t=t||[],Array.isArray(t)?t={style:t}:t.renderPlugin&&(t={style:[t]}),t=function(t){if(!t.plugins)return t;const{plugins:e,styles:n}=t;let{style:i,featureStyle:r}=n;i=i||[],r=r||[];const s=new Array(i.length);for(let t=0;t<i.length;t++)s[t]=Q$4({},i[t]),s[t].renderPlugin=e[i[t].renderPlugin];const o=new Array(r.length);for(let t=0;t<r.length;t++)o[t]=Q$4({},r[t]),o[t].renderPlugin=e[r[t].renderPlugin];const a={style:s,featureStyle:o};return t.$root&&(a.$root=t.$root),a}(t=JSON.parse(JSON.stringify(t))),this.ye=t.featureStyle||[],this.ge=function(t){if(!t||!Array.isArray(t))return[];const e=[];for(let n=0;n<t.length;n++){const i=t[n].style;if(i&&Array.isArray(i)&&i.length)for(let r=0;r<i.length;r++){const s=Q$4({},t[n],i[r]);i[r].ve=e.length,delete s.style,e.push(s)}else e.push(Q$4({},t[n]))}return e}(t.featureStyle),this.xe=t.style||[];const e=t.background||{};this.be={enable:e.enable||!1,color:ce$2(e.color)||[0,0,0,0],opacity:fe$2(e.opacity,1),patternFile:e.patternFile,depthRange:e.depthRange},this.validateStyle(),this.me&&this.Ae(),this.Dt();const n=this.getRenderer();n&&n.setStyle(),this.fire("setstyle",{style:this.getStyle(),computedStyle:this.getComputedStyle()})}getPolygonOffsetCount(){const t=this.getRenderer();return t?t.getPolygonOffsetCount():0}getPolygonOffset(){return this.we||0}setPolygonOffset(t,e){return this.we=t,this._e=e,this}getTotalPolygonOffset(){return this._e}getRenderedFeatures(){const t=this.getRenderer();return t?t.getRenderedFeatures():[]}outlineAll(){const t=this.getRenderer();return t?(t.outlineAll(),this):this}outline(t,e){const n=this.getRenderer();return n?(n.outline(t,e),this):this}outlineBatch(t){const e=this.getRenderer();return e?(e.outlineBatch(t),this):this}outlineFeatures(t){const e=this.getRenderer();return e?(e.outlineFeatures(t),this):this}cancelOutline(){const t=this.getRenderer();return t?(t.cancelOutline(),this):this}highlight(t){this.Se(t);const e=this.getRenderer();return e?(e.highlight(t),this):(this.te||(this.te=[]),this.te.push(t),this)}Se(t){if(Array.isArray(t))for(let e=0;e<t.length;e++)this.Se(t[e]);else{if(t.filter){if(!this.options.features)throw new Error("options.features must be turned on to support filter in highlight");if(!t.name)throw new Error("A name is required for highlight with filter")}if(rt$3(t.filter)&&rt$3(t.id))throw new Error("id or filter must be provided for highlight")}}ee(){if(this.te){for(let t=0;t<this.te.length;t++)this.highlight(this.te[t]);delete this.te}}cancelHighlight(t){const e=this.getRenderer();return e?(e.cancelHighlight(t),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}Ae(){t__namespace.Util.convertStylePath(this.xe,this.me),t__namespace.Util.convertStylePath(this.ge,this.me)}updateSceneConfig(t,e){return tt$3(t)&&(t=this.Me(t)),this.Pe(0,t,e)}updateFeatureSceneConfig(t,e,n){return this.Pe(1,t,n,e)}Pe(t,e,n,i){const r=this.it(t);if(!r)return this;let s,o=e;if(r[e].renderPlugin.sceneConfig||(r[e].renderPlugin.sceneConfig={}),Q$4(r[e].renderPlugin.sceneConfig,n),void 0!==i){de$2(this.ye,e,i),o=this.ye[e].style[i].ve;const t=r[o].renderPlugin;t.sceneConfig||(t.sceneConfig={}),s=t.sceneConfig}else pe$2(r,e),s=r[e].renderPlugin.sceneConfig;if(Q$4(s,n),Array.isArray(this.options.style)){const t=this.options.style[e].renderPlugin;t.sceneConfig||(t.sceneConfig={}),Q$4(t.sceneConfig,n)}else{const r=this.it(t,this.options.style);let s;void 0!==i?(de$2(r,e,i),s=r[e].style[i].renderPlugin):(pe$2(r,e),s=r[e].renderPlugin),s.sceneConfig||(s.sceneConfig={}),Q$4(s.sceneConfig,n)}const a=this.getRenderer();return a&&a.updateSceneConfig(t,o,n),0===t?this.fire("updatesceneconfig",{index:e,sceneConfig:n}):1===t&&this.fire("updatefeaturesceneconfig",{index:e,styleIdx:i,sceneConfig:n}),this}updateDataConfig(t,e){return tt$3(t)&&(t=this.Me(t)),this.Te(0,t,e)}updateFeatureDataConfig(t,e,n){return this.Te(1,t,n,e)}Te(t,e,n,i){const r=this.it(t);if(!r)return this;let s,o=e;void 0!==i?(de$2(this.ye,e,i),o=this.ye[e].style[i].ve,s=r[o].renderPlugin.dataConfig):(pe$2(r,e),s=r[e].renderPlugin.dataConfig);const a=Q$4({},s);if(Q$4(s,n),Array.isArray(this.options.style))Q$4(this.options.style[e].renderPlugin.dataConfig,n);else{const r=this.it(t,this.options.style);let s;void 0!==i?(de$2(r,e,i),s=r[e].style[i].renderPlugin):(pe$2(r,e),s=r[e].renderPlugin),s.dataConfig||(s.dataConfig={}),Q$4(s.dataConfig,n)}const l=this.getRenderer();return l&&l.updateDataConfig(t,o,n,a),0===t?this.fire("updatedataconfig",{index:e,dataConfig:n}):1===t&&this.fire("updatefeaturedataconfig",{index:e,styleIdx:i,dataConfig:n}),this}updateSymbol(t,e){return tt$3(t)&&(t=this.Me(t)),this.ke(0,t,e)}updateFeatureSymbol(t,e,n){return this.ke(1,t,n,e)}ke(e,n,i,r){const s=this.it(e);if(!s)return this;let o=n;void 0!==r&&(de$2(this.ye,n,r),o=this.ye[n].style[r].ve);const a=s[o];if(!a)throw new Error("No style defined at "+n);const l=this,h=this.me;function u(i,s,o){if(!i)return!1;h&&(i=JSON.parse(JSON.stringify(i)),t__namespace.Util.parseSymbolPath(i,h));const a=Object.keys(i);let u=!1;for(let t=0;t<a.length;t++){const e=a[t];if(ue$2(s[e])||ue$2(i[e])){u=!0;break}}for(const e in i)at$3(i,e)&&(!t__namespace.Util.isObject(i[e])||Array.isArray(i[e])||isFunctionDefinition(i[e])?s[e]=i[e]:(s[e]||(s[e]={}),Q$4(s[e],i[e])));let c=l.options.style;if(tt$3(c))return u;Array.isArray(c)||(c=l.it(e,l.options.style));const f=JSON.parse(JSON.stringify(s));return void 0!==r?(de$2(c,n,r),void 0===o?c[n].style[r].symbol=f:c[n].style[r].symbol[o]=f):(pe$2(c,n),void 0===o?c[n].symbol=f:c[n].symbol[o]=f),u}const c=this.getRenderer();if(!c)return u(),this.Dt(),this;let f=!1;const d=a.symbol;if(Array.isArray(i))for(let t=0;t<i.length;t++){const e=u(i[t],d[t],t);e&&(f=e)}else u(i,d);return this.Dt(),f?c.setStyle():(f=c.updateSymbol(e,o,i),f&&c.setStyle()),0===e?this.fire("updatesymbol",{index:n,symbol:i}):1===e&&this.fire("updatefeaturesymbol",{index:n,featureStyleIndex:r,symbol:i}),this}it(t,e){return e?0===t?e.style:e.featureStyle:0===t?this.xe:this.ge}isDefaultRender(){return!!this.Oe&&this.options.defaultRendering}validateStyle(){this.Oe=!1;let t=this.xe;this.options.style||(this.Oe=!0,t=this.xe=[]),Array.isArray(t)||(t=this.xe=[t]);for(let e=0;e<t.length;e++){let n=t[e].filter;if(n&&n.value&&(n=n.value),n||console.warn(`render plugin at ${e} doesn't define filter, its filter will be set to 'default' by default.`),void 0!==n&&"default"!==n&&!0!==n&&!Array.isArray(n)&&void 0===n.condition)throw new Error(`Invalid filter at ${e} : ${JSON.stringify(n)}`)}}getStyle(){return this.options.style?JSON.parse(JSON.stringify(this.options.style)):null}Me(t){const e=this.xe;if(!e)return-1;for(let n=0;n<e.length;n++)if(e[n].name===t)return n;throw new Error("No style defined with name: "+t)}getGroundConfig(){this.Ie||(this.Ie={enable:!0,renderPlugin:{type:"fill",sceneConfig:{}},symbol:{polygonFill:[0,0,0,0],polygonOpacity:1}});const t=this.q().background||{};return this.Ie.enable=t.enable,this.Ie.symbol.polygonFill=t.color,this.Ie.symbol.polygonOpacity=t.opacity,this.Ie.symbol.polygonPatternFile=t.patternFile,this.Ie.renderPlugin.sceneConfig.depthRange=t.depthRange,this.Ie}getComputedStyle(){return JSON.parse(JSON.stringify(this.q()))}q(){return{background:this.be,style:this.xe||[],featureStyle:this.ge||[]}}identify(e,n={}){const i=this.getMap(),r=this.getRenderer();if(!i||!r)return[];const s=i.coordToContainerPoint(new t__namespace.Coordinate(e));return this.identifyAtPoint(s,n)}identifyAtPoint(t,e={}){const n=this.getMap(),i=this.getRenderer();if(!n||!i)return[];const r=n.getDevicePixelRatio(),s=i.pick(t.x*r,t.y*r,e);return this.options.features&&"id"!==this.options.features?this.Fe(s):s}Fe(t){if(!this.getRenderer())return t;const e=this._getTileConfig(),n=this.getSpatialReference();for(let i=0;i<t.length;i++){let r=t[i];if(!r||!r.data)continue;const{tile:s}=r.data,{x:o,y:a,z:l,extent:h}=s,u=n.getResolution(l),c=e.getTilePointNW(o,a,u),f=r.data.feature&&r.data.feature.geometry;if(f){r.data=Q$4({},r.data),r.data.feature=Q$4({},r.data.feature);const t=r.data.feature.type;r.data.feature.type="Feature",r.data.feature.geometry=this.Ce(t,f,c,h,u)}}return t}Ce(t,e,n,i,r){let s,o;if(1===t)e.length<=1?(s="Point",o=this.Ee(e,n,i,r)[0]||[]):(s="MultiPoint",o=this.Ee(e,n,i,r));else if(2===t)e.length<=1?(s="LineString",o=this.Ee(e,n,i,r)[0]||[]):(s="MultiLineString",o=this.Ee(e,n,i,r));else if(3===t){let t;o=[];let a=0;for(let s=0;s<e.length;s++)Fa.calculateSignedArea(e[s])>0&&(a++,t&&t.length&&o.push(t),t=[]),t.push(this.Ee(e[s],n,i,r));t.length&&o.push(t),a<=1?(s="Polygon",o=o[0]):s="MultiPolygon"}return{type:s,coordinates:o}}Ee(t,e,n,i){const r=n/this.getTileSize().width,s=this.getMap(),o=[];for(let a=0;a<t.length;a++)Array.isArray(t[a])?o.push(this.Ee(t[a],e,n,i)):(se$2.x=e.x+t[a].x/r,se$2.y=e.y-t[a].y/r,s.pointAtResToCoord(se$2,i,oe$2),o.push(oe$2.toArray()));return o}getDataSchema(t){return this.De||(this.De={}),rt$3(t)||this.De[t]||(this.De[t]={}),rt$3(t)?this.De:this.De[t]}onRemove(){super.onRemove()}static fromJSON(t){return t&&"VectorTileLayer"===t.type?new he$2(t.id,t.options):null}Dt(){}static registerPlugin(t){he$2.plugins||(he$2.plugins={}),he$2.plugins[t.type]=t}static getPlugins(){return he$2.plugins||{}}static compressStyleJSON(t){return Array.isArray(t)&&t.length?function(t){Array.isArray(t)&&(t={style:t,featureStyle:[]});const e=[],n=[],i=[];ne$2(t.style,e,i),ne$2(t.featureStyle,n,i);const r={plugins:i,styles:{style:e,featureStyle:n}};return t.$root&&(r.$root=t.$root),r}(t):t}}function ue$2(t){return!(!t||!t.properties)}function ce$2(t){return t?(Array.isArray(t)||(t=color(t).unitArray()),3===t.length&&t.push(1),t):null}function fe$2(t,e){return null==t?e:t}function de$2(t,e,n){if(!t[e]||!t[e].style||!t[e].style[n])throw new Error(`No plugin defined at feature style of ${e} - ${n}`)}function pe$2(t,e){if(!t[e])throw new Error("No plugin defined at style of "+e)}he$2.prototype._getTileZoom=function(e){return e=Math.floor(e),t__namespace.TileLayer.prototype._getTileZoom.call(this,e)},he$2.registerJSONType("VectorTileLayer"),he$2.mergeOptions({renderer:"gl",altitudeProperty:"altitude",forceRenderOnZooming:!0,forceRenderOnMoving:!0,forceRenderOnRotating:!0,tileSize:512,features:!1,schema:!1,cascadeTiles:!0,collision:!0,collisionBuffserSize:0,picking:!0,pickingPoint:!0,pickingGeometry:!1,glyphSdfLimitPerFrame:15,tileLimitPerFrame:1,loadingLimitOnInteracting:5,loadingLimit:0,antialias:!1,iconErrorUrl:null,collisionFrameLimit:1.5,defaultRendering:!0,textGamma:1,maxIconSize:254,workarounds:{"win-intel-gpu-crash":!1},pyramidMode:1,styleScale:1,enableAltitude:!0,fadeAnimation:!1,debugTileData:!1,fetchOptions:null,awareOfTerrain:!0,altitudeQueryTimeLimitPerFrame:3,workerGlyph:!0,featureIdProperty:null}),he$2.registerRenderer("gl",Jt$2),he$2.registerRenderer("canvas",null);const me$2={projection:"EPSG:4326",fullExtent:{top:90,left:-180,bottom:-90,right:180},resolutions:function(){const t=[];for(let e=0;e<22;e++)t[e]=45/(128*Math.pow(2,e));return t}()};t__namespace.SpatialReference.registerPreset("preset-vt-4326",me$2),t__namespace.SpatialReference.registerPreset("preset-4326-512",me$2);class ye$2 extends he$2{getTileUrl(t,e,n){const i=this.getMap().getResolution(n);return super.getTileUrl(t,e,function(t){return 19-Math.log(t/ge$2)/Math.LN2}(i))}static fromJSON(t){return t&&"MapboxVectorTileLayer"===t.type?new ye$2(t.id,t.options):null}}ye$2.registerJSONType("MapboxVectorTileLayer");const ge$2=12756274*Math.PI/(256*Math.pow(2,20));class ve$2 extends he$2{constructor(t,e={}){e.spatialReference=null,super(t,e),this.setData(e.data)}oe(){}getWorkerOptions(){const t=super.getWorkerOptions();let e=this.options.data;return e=tt$3(e)||e&&e.url?be$2(e):this.features,t.data=e,t.tileBuffer=this.options.tileBuffer,t.extent=this.options.extent,t.hasAltitude=this.options.enableAltitude,t.simplifyTolerance=this.options.simplifyTolerance,t.projection=this.getSpatialReference().getProjection().code,t.generateOMBB=this.options.generateOMBB,t.convertFn=this.options.convertFn?this.options.convertFn+"":null,t}_initTileConfig(){const t=this.getSpatialReference();t&&t.getProjection()&&("EPSG:4326"===t.getProjection().code||"EPSG:4490"===t.getProjection().code)&&(this.options.tileSystem=[1,-1,-180,90]),super._initTileConfig()}setData(t){return this.options.data=t,t&&(tt$3(t)||t.url)?(!!this.getRenderer()&&this.Re(),this):(this.Le(t),this.Re(),this)}Le(t){return this.options.convertFn&&(t=new Function("data",this.options.convertFn+"\nreturn convert(data)")(t)),this.features=t,this.Ne(),this}Re(){const t=this.getRenderer();if(t){const e=t.getWorkerConnection();if(e){let n=this.options.data;n=tt$3(n)||n.url?be$2(n):this.features,e.setData(n,((e,n)=>{t.clear(),this.onWorkerReady(null,n),t.setToRedraw(),setTimeout((()=>{t.setToRedraw()}),500)}))}}}getExtent(){return this.He}onWorkerReady(t,e){t?this.fire("dataerror",{error:t}):(e&&(e.extent&&this.ze(e.extent),e.idMap&&(this.Ve=e.idMap)),this.fire("dataload",{extent:e&&e.extent}))}ze(e){this.He=new t__namespace.Extent(...e)}Ue(t,e){tt$3(t)?re$2.getJSON(t,e):re$2.getJSON(t.url,t,e)}getData(){return this.features||null}getTileUrl(t,e,n){return this.getId()+","+t+","+e+","+n}getFeature(t){return this.Ve[t]}static fromJSON(t){return t&&"GeoJSONVectorTileLayer"===t.type?new ve$2(t.id,t.options):null}Ne(){if(!this.features)return;if(this.features=JSON.parse(JSON.stringify(this.features)),!this.features)return;let t=0;this.Ve={};const e=this.options.featureIdProperty,n=this.features;Array.isArray(n)?n.forEach((n=>{if(n){if(et$3(n.id)||(n.id=t++),e){let t=e;it$3(e)&&(t=e[n.layer||"0"]),n.id=n.properties[t]}this.Ve[n.id]=n}})):n.features&&n.features.forEach((n=>{if(n){if(et$3(n.id)||(n.id=t++),e){let t=e;it$3(e)&&(t=e[n.layer||"0"]),n.id=n.properties[t]}this.Ve[n.id]=n}}))}}function xe$2(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function be$2(t){return t.url?t.url=xe$2(t.url):t=xe$2(t),t}ve$2.registerJSONType("GeoJSONVectorTileLayer"),ve$2.mergeOptions({features:"id",tileBuffer:64,extent:8192,pyramidMode:1,simplifyTolerance:3,tileStackDepth:0,generateOMBB:!0});const Ae$2=new t__namespace.Size(1,1);class we$2 extends t__namespace.OverlayLayer{static registerPainter(t,e){we$2.painters||(we$2.painters={}),we$2.painters[t]=e}static get3DPainterClass(t){return we$2.painters[t]}getEvents(){let t;return t=super.getEvents?super.getEvents():{},t.spatialreferencechange=this.je,t}onConfig(t){if(super.onConfig(t),void 0!==t.enableBloom){const e=this.getRenderer();e&&e.updateBloom(t.enableBloom)}}updateSymbol(t,e){if(!this.options.style)throw new Error("can't call update symbol when style is not set");const n=Array.isArray(this.options.style)?this.options.style:this.options.style.style;if(!n[t])throw new Error("invalid style at "+t);return Q$4(n[t].symbol,e),this.setStyle(this.options.style),this}getPolygonOffsetCount(){return this.isEmpty()||this.options.altitude?0:1}getPolygonOffset(){return this.options.altitude?0:this.we||0}setPolygonOffset(t,e){return this.we=t,this._e=e,this}getTotalPolygonOffset(){return this._e}identify(e,n={}){const i=this.getMap(),r=this.getRenderer();if(!i||!r)return[];const s=i.coordToContainerPoint(new t__namespace.Coordinate(e));return this.identifyAtPoint(s,n)}identifyAtPoint(t,e={}){const n=this.getMap(),i=this.getRenderer();if(!n||!i)return[];const r=this.getMap().getDevicePixelRatio();return i.pick(t.x*r,t.y*r,e)}getComputedStyle(){return{style:this.getStyle()||[]}}outlineAll(){const t=this.getRenderer();return t?(t.outlineAll(),this):this}outline(t){if(!Array.isArray(t)||!t.length)return this;const e=this.getRenderer();return e?(e.outline(t),this):this}cancelOutline(){const t=this.getRenderer();return t?(t.cancelOutline(),this):this}toJSON(){const t={type:this.getJSONType(),id:this.getId(),options:this.config(),geometries:[]},e=this.getGeometries();for(let n=0,i=e.length;n<i;n++){const i=e[n].toJSON();t.geometries.push(i)}return t}getTileSize(){return Ae$2}je(){const t=this.getRenderer();t&&t.je()}}we$2.mergeOptions({picking:!0,pickingPoint:!0,renderer:"gl",collision:!1,collisionBufferSize:0,textGamma:1,geometryEvents:!0,styleScale:1,forceRenderOnZooming:!0,forceRenderOnMoving:!0,forceRenderOnRotating:!0,meshRenderOrder:0,enableBloom:!1,enableAltitude:!0,workarounds:{"win-intel-gpu-crash":!0}});const _e$2={markerFile:{type:"identity",default:null,property:"_symbol_markerFile"},markerWidth:{type:"identity",default:null,property:"_symbol_markerWidth"},markerHeight:{type:"identity",default:null,property:"_symbol_markerHeight"},markerPathWidth:{type:"identity",default:20,property:"_symbol_markerPathWidth"},markerPathHeight:{type:"identity",default:20,property:"_symbol_markerPathHeight"},markerDx:{type:"identity",default:null,property:"_symbol_markerDx"},markerDy:{type:"identity",default:null,property:"_symbol_markerDy"},markerType:{type:"identity",default:null,property:"_symbol_markerType"},markerPath:{type:"identity",default:null,property:"_symbol_markerPath"},markerFill:{type:"identity",default:null,property:"_symbol_markerFill"},markerFillPatternFile:{type:"identity",default:null,property:"_symbol_markerFillPatternFile"},markerFillOpacity:{type:"identity",default:null,property:"_symbol_markerFillOpacity"},markerLineColor:{type:"identity",default:null,property:"_symbol_markerLineColor"},markerLineWidth:{type:"identity",default:null,property:"_symbol_markerLineWidth"},markerLineOpacity:{type:"identity",default:null,property:"_symbol_markerLineOpacity"},markerLineDasharray:{type:"identity",default:null,property:"_symbol_markerLineDasharray"},markerLinePatternFile:{type:"identity",default:null,property:"_symbol_markerLinePatternFile"},markerVerticalAlignment:{type:"identity",default:"top",property:"_symbol_markerVerticalAlignment"},markerHorizontalAlignment:{type:"identity",default:"middle",property:"_symbol_markerHorizontalAlignment"},markerOpacity:{type:"identity",default:1,property:"_symbol_markerOpacity"},markerPitchAlignment:{type:"identity",default:"viewport",property:"_symbol_markerPitchAlignment"},markerRotationAlignment:{type:"identity",default:"viewport",property:"_symbol_markerRotationAlignment"},markerRotation:{type:"identity",default:0,property:"_symbol_markerRotation"},markerAllowOverlap:{type:"identity",default:0,property:"_symbol_markerAllowOverlap"},markerIgnorePlacement:{type:"identity",default:0,property:"_symbol_markerIgnorePlacement"},markerTextFit:{type:"identity",default:null,property:"_symbol_markerTextFit"},markerSpacing:{type:"identity",default:250,property:"_symbol_markerSpacing"},markerTextFitPadding:{type:"identity",default:null,property:"_symbol_markerTextFitPadding"},markerPlacement:{type:"identity",default:"point",property:"_symbol_markerPlacement"}},Se$2={textName:{type:"identity",default:null,property:"_symbol_textName"},textFaceName:{type:"identity",default:null,property:"_symbol_textFaceName"},textWeight:{type:"identity",default:null,property:"_symbol_textWeight"},textStyle:{type:"identity",default:null,property:"_symbol_textStyle"},textWrapWidth:{type:"identity",default:null,property:"_symbol_textWrapWidth"},textHorizontalAlignment:{type:"identity",default:null,property:"_symbol_textHorizontalAlignment"},textVerticalAlignment:{type:"identity",default:null,property:"_symbol_textVerticalAlignment"},textFill:{type:"identity",default:null,property:"_symbol_textFill"},textSize:{type:"identity",default:null,property:"_symbol_textSize"},textHaloRadius:{type:"identity",default:null,property:"_symbol_textHaloRadius"},textHaloFill:{type:"identity",default:null,property:"_symbol_textHaloFill"},textHaloOpacity:{type:"identity",default:1,property:"_symbol_textHaloOpacity"},textDx:{type:"identity",default:0,property:"_symbol_textDx"},textDy:{type:"identity",default:0,property:"_symbol_textDy"},textOpacity:{type:"identity",default:1,property:"_symbol_textOpacity"},textPitchAlignment:{type:"identity",default:"viewport",property:"_symbol_textPitchAlignment"},textRotationAlignment:{type:"identity",default:"viewport",property:"_symbol_textRotationAlignment"},textRotation:{type:"identity",default:0,property:"_symbol_textRotation"},textAllowOverlap:{type:"identity",default:0,property:"_symbol_textAllowOverlap"},textIgnorePlacement:{type:"identity",default:0,property:"_symbol_textIgnorePlacement"},textSpacing:{type:"identity",default:250,property:"_symbol_textSpacing"},textPlacement:{type:"identity",default:"point",property:"_symbol_textPlacement"}},Me$2={lineWidth:{type:"identity",default:2,property:"_symbol_lineWidth"},lineStrokeWidth:{type:"identity",default:0,property:"_symbol_lineStrokeWidth"},lineColor:{type:"identity",default:[1,1,1,1],property:"_symbol_lineColor"},lineStrokeColor:{type:"identity",default:[0,0,0,0],property:"_symbol_lineStrokeColor"},lineDx:{type:"identity",default:0,property:"_symbol_lineDx"},lineDy:{type:"identity",default:0,property:"_symbol_lineDy"},linePatternFile:{type:"identity",default:null,property:"_symbol_linePatternFile"},linePatternAnimSpeed:{type:"identity",default:0,property:"_symbol_linePatternAnimSpeed"},linePatternGap:{type:"identity",default:0,property:"_symbol_linePatternGap"},lineOpacity:{type:"identity",default:1,property:"_symbol_lineOpacity"},lineJoin:{type:"identity",default:null,property:"_symbol_lineJoin"},lineCap:{type:"identity",default:null,property:"_symbol_lineCap"},lineDasharray:{type:"identity",default:null,property:"_symbol_lineDasharray"},lineDashColor:{type:"identity",default:null,property:"_symbol_lineDashColor"}},Pe$2=new t__namespace.Point(0,0),Te$2="_vector3dlayer_id",ke$2="_line_gradient_property".trim();function Oe$2(e,n,i){const r="__fea_idx".trim(),s=e.getMap(),o=s.getGLRes();let a=e.getCoordinates();const l=[],h=[];let u=1;if(e instanceof t__namespace.Marker||e instanceof t__namespace.MultiPoint){e instanceof t__namespace.Marker&&(a=[a]);for(let t=0;t<a.length;t++)s.coordToPointAtRes(a[t],o,Pe$2),l.push([Pe$2.x,Pe$2.y,a[t].z||0]),h.push([a[t].x,a[t].y])}else if(e instanceof t__namespace.LineString||e instanceof t__namespace.MultiLineString){u=2,e instanceof t__namespace.LineString&&(a=[a]);for(let t=0;t<a.length;t++){l[t]=[],h[t]=[];for(let e=0;e<a[t].length;e++)s.coordToPointAtRes(a[t][e],o,Pe$2),l[t].push([Pe$2.x,Pe$2.y,a[t][e].z||0]),h[t].push([a[t][e].x,a[t][e].y])}}else if(e instanceof t__namespace.Polygon||e instanceof t__namespace.MultiPolygon){u=3,e instanceof t__namespace.Circle||e instanceof t__namespace.Rectangle||e instanceof t__namespace.Ellipse||e instanceof t__namespace.Sector?a=[[e.getShell()]]:e instanceof t__namespace.Polygon&&(a=[a]);let n=0;for(let t=0;t<a.length;t++)for(let e=0;e<a[t].length;e++){l[n]=[],h[n]=[];for(let i=0;i<a[t][e].length;i++)s.coordToPointAtRes(a[t][e][i],o,Pe$2),l[n].push([Pe$2.x,Pe$2.y,a[t][e][i].z||0]),h[n].push([a[t][e][i].x,a[t][e][i].y]);n++}}const c=e.getProperties()?Object.assign({},e.getProperties()):{},f=e._getInternalSymbol()||function(e){return e instanceof t__namespace.Marker||e instanceof t__namespace.MultiPoint?{markerType:"ellipse",markerWidth:8,markerHeight:0,markerFill:"#000"}:e instanceof t__namespace.LineString||e instanceof t__namespace.MultiLineString?{lineColor:"#000",lineWidth:1}:e instanceof t__namespace.Polygon||e instanceof t__namespace.MultiPolygon?{polygonFill:"#fff",lineColor:"#000",lineWidth:1}:void 0}(e),d=i?Array.isArray(i)?i[0].id:i.id:n.id++;if(Array.isArray(f)&&f.length){const t=[],s=f.length;for(let o=0;o<s;o++){const a=o===s-1?c:Q$4({},c),p=Ie$2(f[o],a);for(const t in f[o])at$3(f[o],t)&&(a[("_symbol_"+t).trim()]=f[o][t]);p&&(f[o].lineGradientProperty=p);const m=i&&i[o]?i[o][r]:n.pickingId++,y={type:u,id:d,properties:a,visible:e.isVisible(),geometry:l,coordinates:h,extent:1/0};y[r]=m,t.push(y)}return t}if(f){const t=Ie$2(f,c);for(const t in f)at$3(f,t)&&(c[("_symbol_"+t).trim()]=f[t]);t&&(f.lineGradientProperty=t)}const p=i?i.id:n.pickingId++,m={type:u,id:d,properties:c,visible:e.isVisible(),geometry:l,coordinates:h,extent:1/0};return m[r]=p,m}function Ie$2(t,e){const n=t.lineGradientProperty;return n&&(e[ke$2]=e[n],e.mapbox_clip_start=0,e.mapbox_clip_end=1,delete e[n]),n}let Fe$2=1;const Ce$2="_symbol_".trim(),Ee$2="__fea_idx".trim();let De$2=new Float32Array(1);const Re$2=[];class Le$2 extends t__namespace.renderer.CanvasRenderer{constructor(...t){super(...t),this.features={},this.Be={},this.L=0,this.Ge={},this.We={},this.Xe={},this.Ye={},this.$e={},this.qe=!0,this.Je={id:0,pickingId:0},this.Ke={}}hasNoAARendering(){return!0}needToRedraw(){return super.needToRedraw()||this.painter&&this.painter.needToRedraw()||this.Ze&&this.Ze.needToRedraw()||this.Qe&&this.Qe.needToRedraw()}getAnalysisMeshes(){return this.painter&&this.painter.getAnalysisMeshes()||Re$2}getRayCastData(){return null}draw(t,e){this.pt=t;const n=this.layer;this.prepareCanvas(),this.yt=this.gt(this.getMap().getGLRes()),this.vt=e||{};const i=this.vt.renderMode,r=this.tn();if(this.xt(r,i),this.qe)this.buildMesh(),this.en(),this.nn(),this.Ke={},this.in=!1,this.qe=!1,this.rn=!1;else if(this.in){const t=this.atlas,e=this.sn,n=this.an;delete this.atlas,delete this.sn,delete this.an,this.buildMesh(t),this.en(e),this.nn(n),this.in=!1,this.rn=!1}else if(this.rn){const t=this.an;delete this.an,this.nn(t),this.rn=!1}if(!this.meshes&&!this.ln&&!this.hn)return void this.completeRender();this.un&&(this.cn(),this.un=!1),this.dn();const s=!i||"default"===i;let o=0;0===this.layer.options.meshRenderOrder&&this.pn(r,o,i);let a=0;if(this.hn&&(s||this.Qe.supportRenderMode(i))){this.Qe.startFrame(r),this.Qe.addMesh(this.hn,null,{bloom:this.vt.bloom}),this.Qe.prepareRender(r);const t=r.polygonOffsetIndex||0;o=this.meshes&&this.meshes.length?o-1:o,r.polygonOffsetIndex=(r.polygonOffsetIndex||0)+o,a=this.Qe.render(r).drawCount,r.polygonOffsetIndex=t}if(1===this.layer.options.meshRenderOrder&&this.pn(r,a?o-1:o,i),this.ln&&(s||this.Ze.supportRenderMode(i))){const e=!this.vt.timestamp||this.vt.isFinalRender,i=!this.mn||this.mn!==t;n.options.collision&&i&&n.clearCollisionIndex();const s=this.layer.options.sceneConfig;this.Ze.sceneConfig.collision=!s||!!rt$3(s.collision)||s.collision,this.Ze.startFrame(r),this.Ze.addMesh(this.ln,null,{bloom:this.vt.bloom}),this.Ze.prepareRender(r),n.options.collision&&i&&(this.Ze.updateCollision(r),e&&(this.mn=t)),this.Ze.render(r)}(s||e&&e.isFinalRender)&&(this.completeRender(),this.layer.fire("canvasisdirty"))}xt(t,e){this.painter&&(!e||"default"===e||this.painter.supportRenderMode(e))&&this.painter.startFrame(t)}pn(t,e,n){return this.painter&&this.meshes&&(!n||"default"===n||this.painter.supportRenderMode(n))?(this.painter.addMesh(this.meshes,null,{bloom:t&&t.bloom}),this.painter.prepareRender(t),t.polygonOffsetIndex=(t.polygonOffsetIndex||0)+e,this.painter.render(t)):{redraw:!1,drawCount:0}}supportRenderMode(){return!0}isForeground(){return!0}tn(){const t={regl:this.regl,layer:this.layer,symbol:this.yn,gl:this.gl,sceneConfig:this.layer.options.sceneConfig,pluginIndex:0,cameraPosition:this.getMap().cameraPosition,timestamp:this.getFrameTimestamp()};return this.vt&&Q$4(t,this.vt),t}drawOnInteracting(t,e,n){this.draw(e,n)}getFrameTimestamp(){return this.pt}gn(t,e){(t=t||e)===e&&(e=null);const n=[],i=[0,0,0,0];this.layer._sortGeometries();const r=this.layer.getGeometries();for(let s=0;s<r.length;s++){const o=r[s][Te$2];if(!this.features[o])continue;const a=this.features[o];if(Array.isArray(a))for(let r=0;r<a.length;r++){const s=a[r],o=s[Ee$2];(!t||t[o]||e&&(!e||e[o]))&&(s.visible||(this.un=!0),this.vn(s.geometry,i,s.coordinates),n.push(s))}else{a.visible||(this.un=!0);const r=a[Ee$2];if(t&&!t[r]&&(!e||e&&!e[r]))continue;this.vn(a.geometry,i,a.coordinates),n.push(a)}}if(n.length||(this.meshes&&this.painter&&(this.painter.deleteMesh(this.meshes),delete this.meshes),this.ln&&(this.Ze.deleteMesh(this.ln),delete this.ln),this.hn&&(this.Qe.deleteMesh(this.hn),delete this.hn)),i[3]&&(i[0]/=i[3],i[1]/=i[3]),isNaN(i[0])||isNaN(i[1]))throw new Error("invalid geometry coordinates for "+this.layer.getJSONType());return{features:n,center:i}}buildMesh(){}createVectorPacks(t,e,n,i,r,s){return t&&i&&i.length?new e(i,n,{zoom:this.getMap().getZoom(),EXTENT:1/0,requestor:this.requestor,atlas:r,center:s,positionType:Float32Array}).load():Promise.resolve(null)}createMesh(t,e,n,i,r,s){return this.createVectorPacks(t,e,n,i,r,s).then((o=>this.xn(o,t,e,n,i,r,s)))}xn(t,e,n,s,o,a,l){if(!t)return null;const h=e.createGeometries([t.data],At$3(o,null,0,s,this.layer));for(let t=0;t<h.length;t++)h[t]&&this.bn(h[t].geometry);const u=identity$2([]);translate$1(u,u,set$4([],l[0],l[1],0)),scale$5(u,u,set$4([],1,1,this.yt));const c=e.createMeshes(h,u,{tilePoint:[l[0],l[1]]});for(let t=0;t<c.length;t++){const e=c[t];e.properties.level=0,e.properties.tileTransform=u;const n=e.defines;n.ENABLE_TILE_STENCIL=1,e.setDefines(n),e.properties.meshKey=this.layer.getId()}return{meshes:c,atlas:{iconAtlas:t.data.iconAtlas}}}vn(t,e,n){for(let i=0;i<t.length;i++)if(Array.isArray(t[i][0]))for(let r=0;r<t[i].length;r++)if(Array.isArray(t[i][r][0]))for(let s=0;s<t[i][r].length;s++)isNaN(+t[i][r][s][0])||isNaN(+t[i][r][s][1])||this.An(e,t[i][r][s][0],t[i][r][s][1],t[i][r][s][2],1,n[i][r][s]);else isNaN(+t[i][r][0])||isNaN(+t[i][r][1])||this.An(e,t[i][r][0],t[i][r][1],t[i][r][2],1,n[i][r]);else isNaN(+t[i][0])||isNaN(+t[i][1])||this.An(e,t[i][0],t[i][1],t[i][2],1,n[i])}An(t,e,n,i,r,s){let o=!1;(s[0]>180||s[0]<-180)&&(o=!0,console.warn(`Layer(${this.layer.getId()}) has invalid longitude value: ${s[0]}`)),(s[1]>90||s[1]<-90)&&(o=!0,console.warn(`Layer(${this.layer.getId()}) has invalid latitude value: ${s[1]}`)),o||(t[0]+=e,t[1]+=n,t[2]+=i||0,t[3]+=r)}bn(t){const e=this.getMap(),n=t.properties;Object.defineProperty(n,"tileResolution",{enumerable:!0,get:function(){return e.getGLRes()}}),n.tileRatio=1,n.z=1,n.tileExtent=1,n.elements=t.elements,n.aPickingId=t.data.aPickingId}wn(t){return"win-intel-gpu-crash"===t&&this.layer.options.workarounds["win-intel-gpu-crash"]&&He$2(this.gl)}prepareRequestors(){if(this.h)return;const t=this.layer;this.h=new Aa$1({iconErrorUrl:t.options.iconErrorUrl});const e=!this.wn("win-intel-gpu-crash");this.u=new wa$1((e=>{t.getMap().getRenderer().callInNextFrame(e)}),t.options.glyphSdfLimitPerFrame,e),this.requestor=this._n.bind(this),this.Sn=this.Mn.bind(this)}_n(t,e,n){const i=[];this.h.getIcons(t,((t,e)=>{if(t)throw t;e.buffers&&i.push(...e.buffers),n(null,{icons:e.icons},i)}))}Mn(t,e,n){this.u.getGlyphs(e,((e,i)=>{if(e)throw e;const r=i.buffers||[];this.h.getIcons(t,((t,e)=>{if(t)throw t;e.buffers&&e.buffers.length&&r.push(...e.buffers),n(null,{icons:e.icons,glyphs:i.glyphs},r)}))}))}en(t){const e=Object.keys(this.Xe),n=Object.keys(this.Ye);if(!e.length&&!n.length)return void(this.ln&&(this.Ze.deleteMesh(this.ln),delete this.ln));const{features:s,center:o}=this.gn(this.Xe,this.Ye),a=[],l=[];for(let t=0;t<s.length;t++){const e=s[t][Ee$2];this.Xe[e]&&a.push(s[t]),this.Ye[e]&&l.push(s[t])}if(!a.length&&!l.length)return void(this.ln&&(this.Ze.deleteMesh(this.ln),delete this.ln));const h=this.un;this.Pn=o;const u=this.Tn(a,l,t,o);this.sn={};const c=[],f=[];this.kn=!0,Promise.all(u).then((t=>{if(this.ln&&(this.Ze.deleteMesh(this.ln),delete this.ln),!t||!t.length)return void this.setToRedraw();const e=this.Ze.createGeometries(t.map((t=>(t&&t.data&&(t.data.isIdUnique=!0),t&&t.data))),this.Ge);for(let n=0;n<e.length;n++)this.bn(e[n].geometry,t[n]&&t[n].data);const n=t[0]&&t[0].data.iconAtlas,s=t[0]&&t[0].data.glyphAtlas||t[1]&&t[1].data.glyphAtlas;n&&(this.sn.iconAtlas=n),s&&(this.sn.glyphAtlas=s);const a=identity$2([]);translate$1(a,a,set$4(f,o[0],o[1],0)),scale$5(a,a,set$4(c,1,1,this.yt));const l=this.Ze.createMeshes(e,a);for(let t=0;t<l.length;t++)l[t].geometry.properties.originElements=l[t].geometry.properties.elements.slice(),l[t].properties.level=0,l[t].material.set("flipY",1),l[t].properties.meshKey=Fe$2++;this.ln=l,h&&(this.un=!0),this.kn=!1,this.setToRedraw(),this.layer.fire("buildmarkermesh")}))}cn(){if(this.ln&&(this.On(this.ln[0],this.Xe),this.On(this.ln[1],this.Ye),this.ln[0]&&this.Ze.prepareCollideIndex(this.ln[0].geometry),this.ln[1]&&this.Ze.prepareCollideIndex(this.ln[1].geometry)),this.hn)for(let t=0;t<this.hn.length;t++)this.On(this.hn[t],this.$e);if(this.meshes)for(let t=0;t<this.meshes.length;t++)this.On(this.meshes[t],this.Ge)}On(t,e){if(!t)return;const{aPickingId:n,originElements:i}=t.geometry.properties,r=[];for(let t=0;t<i.length;t++){const s=n[i[t]];e[s]&&e[s].feature.visible&&r.push(i[t])}const s=t.geometry.properties.elements=new i.constructor(r);t.geometry.setElements(s)}Tn(t,e,n,i){const r={zoom:this.getMap().getZoom(),EXTENT:1/0,requestor:this.Sn,atlas:n,center:i,positionType:Float32Array,defaultAltitude:0,forceAltitudeAttribute:!0,markerWidthType:Uint16Array,markerHeightType:Uint16Array},s=Q$4({},r);return r.allowEmptyPack=1,Ps$2.splitPointSymbol(this.In).map(((n,i)=>new Ps$2(0===i?t:e,n,0===i?r:s).load()))}updateMesh(){}Fn(t){const e=t._getInternalSymbol(),n={zoom:this.getMap().getZoom(),isVector3D:!0},i=this.Cn(t);if(!this.ln)return!1;let r=this.features[i];Array.isArray(r)||(r=[r]);const s=[],o=[],a=[],l=this.getMap().getZoom();let h,u;h=Array.isArray(e)?e.map((t=>t?loadFunctionTypes(t,(()=>(s[0]=l,s))):t)):loadFunctionTypes(e,(()=>(s[0]=l,s))),u=Array.isArray(e)?e.map((t=>t?$r$3.genFnTypes(t):t)):$r$3.genFnTypes(e);for(let t=0;t<r.length;t++){if(!r[t])continue;const i=Array.isArray(e)?e[t]:e,s=Array.isArray(h)?h[t]:h,o=Array.isArray(u)?u[t]:u,a=new ls$3(r,i,s,o,n).getIconAndGlyph();if(!this.sn||!Ps$2.isAtlasLoaded(a,this.sn))return this.En(),this.setToRedraw(),!1}for(let t=0;t<r.length;t++){const e=r[t][Ee$2];this.Xe[e]&&o.push(r[t]),this.Ye[e]&&a.push(r[t])}const c=r[0].id,f=this.Tn(o,a,this.sn,this.Pn),d=this.ln;return Promise.all(f).then((t=>{for(let e=0;e<t.length;e++){if(!t[e])continue;t[e].data&&(t[e].data.isIdUnique=!0);const n=d[e],i=n.geometry.properties.aFeaIds.indexOf(c);if(i<0)continue;const r=t[e].data.featureIds.length,s=t[e].data.dynamicAttributes;for(const o in t[e].data.data){if("aPickingId"===o)continue;if(s[o])continue;const a=t[e].data.data[o];a&&n.geometry.updateSubData(o,a,i*a.length/r)}}this.setToRedraw()})),!0}Dn(t){return this.Rn(t,this.hn,this.an,this.Ln,this.Qe,Is$2,Me$2,this.Nn)}Rn(t,e,n,i,r,s,o,a){if(!e)return!1;if(!n)return this.En(),this.setToRedraw(),!1;const l=t._getInternalSymbol(),h={zoom:this.getMap().getZoom()};let c=this.features[t[Te$2]];Array.isArray(c)||(c=[c]);const f=[];for(let t=0;t<c.length;t++){const e=c[t];if(!e)continue;const i=Array.isArray(l)?l[t]:l,r=$r$3.genFnTypes(i),o=new ct$4(c,i,r,h),a=s===Is$2?o.getLineResource():o.getPolygonResource();if(!$r$3.isAtlasLoaded(a,n[t]))return this.En(),this.setToRedraw(),!1;f.push(e)}const d=c[0].id,p=a.call(this,f);for(let t=0;t<p.length;t++)if(p[t].length){const n=e.filter((e=>e.feaGroupIndex===t));if(!n.length)return this.En(),this.setToRedraw(),!1;if(n[0].geometry.properties.aFeaIds.indexOf(d)<0)return this.En(),this.setToRedraw(),!1}const m=Q$4({},o),y=p.map((t=>this.createVectorPacks(r,s,m,t,n[0],i)));return Promise.all(y).then((t=>{for(let n=0;n<t.length;n++){let i;if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(e[t].feaGroupIndex===n){i=e[t];break}}else i=e;i&&this.Hn(i,d,t[n])}})),!0}Hn(t,e,n){const i=t.geometry.properties.aFeaIds,r=i.indexOf(e);if(!(r<0)){if(n){const e=n.data.dynamicAttributes,i=n.data.featureIds.length,s=n.data.data;for(const n in s)if(!e[n]&&at$3(s,n)&&s[n]){const e=s[n];t.geometry.updateSubData(n,e,r*e.length/i)}}else{let n=r+1;for(;i[n]===e;)n++;const s=n-r,o=t.geometry.desc.positionSize;De$2.length!==3*s&&(De$2=new Float32Array(s*o),De$2.fill(-1/0,0)),t.geometry.updateSubData(t.geometry.desc.positionAttribute,De$2,r*o)}this.layer.fire("updatemesh"),this.setToRedraw()}}nn(t){if(!Object.keys(this.$e).length)return void(this.hn&&(this.Qe.deleteMesh(this.hn),delete this.hn));const{features:e,center:n}=this.gn(this.$e);if(!e.length)return;const i=this.un;this.Ln=n;const r=this.Nn(e),s=Q$4({},Me$2),o=r.map(((e,i)=>this.createMesh(this.Qe,Is$2,s,e,t&&t[i],n)));this.zn=!0,Promise.all(o).then((t=>{this.hn&&this.Qe.deleteMesh(this.hn);const e=[],n=[];for(let i=0;i<t.length;i++){const r=t[i]&&t[i].meshes;if(r){for(let t=0;t<r.length;t++){const n=r[t];n.feaGroupIndex=i,e.push(n),n.geometry.properties.originElements=n.geometry.properties.elements.slice()}n[i]=t[i].atlas}}this.hn=e,this.an=n,i&&(this.un=i),this.zn=!1,this.setToRedraw(),this.layer.fire("buildlinemesh")}))}Nn(t){const e=(Ce$2+"lineDasharray").trim(),n=(Ce$2+"linePatternFile").trim(),i=[],r=[],s=[];for(let o=0;o<t.length;o++){const a=t[o],l=a.properties&&a.properties[e];l&&Ge$2(l)?s.push(a):a.properties&&a.properties[n]?r.push(a):i.push(a)}return[i,r,s]}Vn(){this.in=!0,this.setToRedraw()}En(){this.qe=!0,this.setToRedraw()}Un(t){const e=this.layer.getId();for(let n=0;n<t.length;n++){const i=t[n];let r=!1;for(let t=0;t<this.GeometryTypes.length;t++)if(i instanceof this.GeometryTypes[t]){r=!0;break}if(!r)throw new Error(`${i.getJSONType()} can't be added to ${this.layer.getJSONType()}(id:${e}).`);this.Cn(i)}}Cn(t){void 0===t[Te$2]&&(t[Te$2]=this.L++);const e=t[Te$2];this.features[e]&&this.jn(e),this.features[e]=Oe$2(t,this.Je,this.features[e]);return this.Bn(this.features[e],e),this.Be[e]=t,e}Bn(t,e){if(!t)return;const n=Array.isArray(t)?t[0].id:t.id;if(this.We[n]=t,Array.isArray(t))for(let n=0;n<t.length;n++){const i=t[n][Ee$2];if(t[n][Te$2]=e,this.Ge[i]={feature:t[n]},this.Ge[i][Te$2]=e,!this.needCheckPointLineSymbols())continue;const r={feature:t[n]};(ze$2(t[n])||Ve$2(t[n]))&&(this.Xe[i]=r),Ve$2(t[n])&&(this.Ye[i]=r),Be$2(t[n])&&(this.$e[i]=r)}else{t[Te$2]=e;const n={feature:t},i=t[Ee$2];if(this.Ge[i]=n,!this.needCheckPointLineSymbols())return;(ze$2(t)||Ve$2(t))&&(this.Xe[i]=n),Ve$2(t)&&(this.Ye[i]=n),Be$2(t)&&(this.$e[i]=n)}}needCheckPointLineSymbols(){return!0}jn(t){const e=this.features[t];if(e)if(Array.isArray(e))for(let t=0;t<e.length;t++){const n=e[t][Ee$2];delete this.We[e[t].id],delete this.Ge[n],delete this.Xe[n],delete this.Ye[n],delete this.$e[n]}else{const t=e[Ee$2];delete this.We[e.id],delete this.Ge[t],delete this.Xe[t],delete this.Ye[t],delete this.$e[t]}}pick(t,e,n){const i=[];return this.layer.isVisible()?([this.painter,this.Ze,this.Qe].forEach((r=>{if(!r)return;const s=r.pick(t,e,n.tolerance);if(s&&s.data&&s.data.feature){const e=this.Be[s.data.feature[Te$2]];n&&n.includeInternals?i.push(e):(s.geometry=e,delete s.plugin,delete s.data,delete s.point,i.push(s))}})),i):i}Gn(t){const n=this.features[t[Te$2]];return Array.isArray(n)?n[0][Ee$2]:n[Ee$2]}dn(){let t=!1;for(const e in this.Ke){const n=this.Ke[e],i=this.Gn(n);if(!this.kn&&(this.Xe[i]||this.Ye[i])){const e=this.Fn(n);t=t||e}if(!this.zn&&this.$e[i]){const e=this.Dn(n);t=t||e}if(!this.Wn){const e=this.updateMesh(n);t=t||e}}this.Ke={},t&&(Ne$2(this),this.layer.fire("partialupdate"))}Xn(t){this.Cn(t),this.En(),Ne$2(this)}onGeometryAdd(t){this.setToRedraw(),this.canvas&&t&&t.length&&(this.Un(t),this.En(),Ne$2(this))}onGeometryRemove(t){if(t&&t.length){for(let e=0;e<t.length;e++){const n=t[e][Te$2];void 0!==n&&(delete this.Be[n],this.jn(n),delete this.features[n])}this.En(),Ne$2(this)}}onGeometrySymbolChange(t){const e=t.target._getParent()||t.target,n=e[Te$2];if(void 0===n)return;let i=t.properties;if(Array.isArray(i)){const t={};for(let e=0;e<i.length;e++)i[e]&&Q$4(t,i[e]);i=t}else if(i&&void 0!==i[0]){const t={};for(const e in i)i[e]&&Q$4(t,i[e]);i=t}for(const t in i)if(at$3(i,t)&&Ia$1[t])return void this.Xn(e);const r=e._getInternalSymbol(),s=this.features[n];if(this.Cn(e),s)if(function(t,e){return Array.isArray(t)?!!Array.isArray(e)&&t.length===e.length:!Array.isArray(e)}(r,s)){if(Array.isArray(r)){for(let t=0;t<r.length;t++)if(!We$2(r[t],s[t]))return void this.Xn(e)}else if(!We$2(r,s))return void this.Xn(e);this.onGeometryPositionChange(t)}else this.Xn(e);else this.Xn(e)}onGeometryShapeChange(t){const e=t.target._getParent()||t.target;void 0!==e[Te$2]&&(this.Un([e]),this.Vn(),Ne$2(this))}onGeometryPositionChange(t){const e=t.target._getParent()||t.target,n=e[Te$2];void 0!==n&&(this.Un([e]),this.Ke[n]=e,Ne$2(this))}onGeometryZIndexChange(t){void 0!==(t.target._getParent()||t.target)[Te$2]&&this.En()}onGeometryShow(t){void 0!==(t.target._getParent()||t.target)[Te$2]&&this.Yn(t)}onGeometryHide(t){void 0!==(t.target._getParent()||t.target)[Te$2]&&this.Yn(t)}Yn(t){const e=t.target,i=this.features[e[Te$2]];if(i){const t=e.isVisible();if(Array.isArray(i)){if(t===i[0].visible)return;for(let e=0;e<i.length;e++)i[e].visible=t}else{if(t===i.visible)return;i.visible=t}this.$n(),Ne$2(this)}}$n(){this.un=!0}onGeometryPropertiesChange(t){const e=t.target._getParent()||t.target,n=e[Te$2];void 0!==n&&(this.features[n]=Oe$2(e,this.Je),this.Bn(this.features[n],n),this.En(),Ne$2(this))}createContext(){const t=this.canvas.gl&&this.canvas.gl.wrap;t?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):this.ot(),t&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.prepareRequestors(),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=this.createPainter();const e=we$2.get3DPainterClass("icon");let n=e.getBloomSymbol();const i=Q$4({},_e$2,Se$2);i.markerPerspectiveRatio=this.layer.options.markerPerspectiveRatio||0,this.qn(i,n),this.In=i;const r=Q$4({},ft$3,this.layer.options.sceneConfig||{});this.Ze=new e(this.regl,this.layer,i,r,0),this.Ze.setTextShaderDefines({REVERSE_MAP_ROTATION_ON_PITCH:1});const s=we$2.get3DPainterClass("line"),o=Q$4({},Me$2);n=s.getBloomSymbol(),this.qn(o,n),this.Jn=o;const a=Q$4({},this.layer.options.sceneConfig||{});void 0===a.depthMask&&(a.depthMask=!0),this.Qe=new s(this.regl,this.layer,o,a,0),this.layer.getGeometries()&&this.onGeometryAdd(this.layer.getGeometries())}st(){return!!(this.canvas&&this.canvas.gl&&this.canvas.gl.wrap)}qn(t,e){for(let n=0;n<e.length;n++)t[e[n]]=this.layer.options.enableBloom}updateBloom(t){this.Ze&&this.Kn(this.Ze,this.In,t),this.Qe&&this.Kn(this.Qe,this.Jn,t),this.painter&&this.Kn(this.painter,this.painterSymbol,t)}Kn(t,e,n){const i=t.constructor.getBloomSymbol().reduce(((t,i)=>(t[i]=n,e[i]=n,t)),{});t.updateSymbol(i,e)}createPainter(){}ot(){const t=this.layer.options.glOptions||{alpha:!0,depth:!0,stencil:!0,antialias:!1};t.preserveDrawingBuffer=!0,t.stencil=!0,this.glOptions=t,this.gl=this.gl||this.ut(this.canvas,t),this.regl=a$2({gl:this.gl,attributes:t,extensions:L$6.WEBGL_EXTENSIONS,optionalExtensions:L$6.WEBGL_OPTIONAL_EXTENSIONS})}ut(t,e){const n=["webgl","experimental-webgl"];let i=null;for(let r=0;r<n.length;++r){try{i=t.getContext(n[r],e)}catch(t){}if(i)break}return i}clearCanvas(){super.clearCanvas(),this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:255})}resizeCanvas(t){super.resizeCanvas(t);const e=this.canvas;e&&(!this.pickingFBO||this.pickingFBO.width===e.width&&this.pickingFBO.height===e.height||this.pickingFBO.resize(e.width,e.height),this.painter&&this.painter.resize(e.width,e.height))}onRemove(){super.onRemove(),this.painter&&(this.painter.delete(),delete this.painter),this.Ze&&(this.Ze.delete(),delete this.Ze),this.Qe&&(this.Qe.delete(),delete this.Qe)}drawOutline(t){if(this.Mt&&(this.painter&&this.painter.outlineAll(t),this.Ze.outlineAll(t),this.Qe.outlineAll(t)),this.Zn)for(let e=0;e<this.Zn.length;e++)this.painter&&this.painter.outline(t,this.Zn[e]),this.Ze.outline(t,this.Zn[e]),this.Qe.outline(t,this.Zn[e])}outlineAll(){this.Mt=!0,this.setToRedraw()}outline(t){this.Zn||(this.Zn=[]);const e=[];for(let n=0;n<t.length;n++){const i=this.layer.getGeometryById(t[n]);if(i){const t=this.features[i[Te$2]];if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n].id);else e.push(t.id)}}this.Zn.push(e),this.setToRedraw()}cancelOutline(){delete this.Mt,delete this.Zn,this.setToRedraw()}isEnableWorkAround(t){return"win-intel-gpu-crash"===t&&this.layer.options.workarounds["win-intel-gpu-crash"]&&He$2(this.gl)}gt(t){return lt$3(t,this.getMap())}je(){const t=this.layer.getGeometries();t&&this.Un(t),this.En()}ne(){const t=this.layer.options.opacity;return this.st()?rt$3(t)?1:t:1}}function Ne$2(t){t.setToRedraw()}function He$2(t){const e=t.getExtension("WEBGL_debug_renderer_info");if(e&&"undefined"!=typeof navigator){const n=t.getParameter(e.UNMASKED_RENDERER_WEBGL),i="Win32"===navigator.platform||"Win64"===navigator.platform;if(n&&n.toLowerCase().indexOf("intel")>=0&&i)return!0}return!1}function ze$2({properties:t}){const e=(Ce$2+"markerFile").trim(),n=(Ce$2+"markerType").trim();return t[e]||t[n]}function Ve$2({properties:t}){return t[(Ce$2+"textName").trim()]}const Ue$2=(Ce$2+"lineWidth").trim(),je$2="_line_gradient_property".trim();function Be$2(t){return 2===t.type&&!t.properties[je$2]||3===t.type&&void 0!==t.properties[Ue$2]}function Ge$2(t){if(!Array.isArray(t))return 0;let e=0;for(let n=0;n<t.length;n++)e+=t[n];return e}function We$2(t,e){if(Object.keys(t).sort().join()!==Object.keys(e.properties||{}).filter((t=>0===t.indexOf(Ce$2))).map((t=>t.substring(Ce$2.length))).sort().join())return!1;for(const n in t)if(at$3(t,n)){const i=(Ce$2+n).trim();if(isFunctionDefinition(t[n])!==isFunctionDefinition(e.properties[i]))return!1}return!0}function Xe$2(e,n,i){if(!e||e.type!==n)return null;const r=new i(e.id,e.options),s=e.geometries,o=[];for(let e=0;e<s.length;e++){const n=t__namespace.Geometry.fromJSON(s[e]);n&&o.push(n)}return r.addGeometry(o),r}class Ye$2 extends we$2{static fromJSON(t){return Xe$2(t,"PointLayer",Ye$2)}constructor(...t){super(...t),this.options.sceneConfig||(this.options.sceneConfig=Q$4({},ft$3))}getPolygonOffsetCount(){return 0}getPolygonOffset(){return 0}}Ye$2.mergeOptions({glyphSdfLimitPerFrame:15,iconErrorUrl:null,workarounds:{"win-intel-gpu-crash":!0},collision:!1,collisionFrameLimit:1}),Ye$2.registerJSONType("PointLayer"),Ye$2.registerRenderer("canvas",null),Ye$2.registerRenderer("gl",class extends Le$2{constructor(...e){super(...e),this.GeometryTypes=[t__namespace.Marker,t__namespace.MultiPoint]}onGeometryAdd(t){t&&(Array.isArray(t)?t.forEach((t=>{t.options.maxMarkerWidth=t.options.maxMarkerHeight=255})):t.options.maxMarkerWidth=t.options.maxMarkerHeight=255,super.onGeometryAdd(t))}});class $e$2 extends we$2{static fromJSON(t){return Xe$2(t,"LineStringLayer",$e$2)}}$e$2.mergeOptions({meshRenderOrder:1}),$e$2.registerJSONType("LineStringLayer");const qe$2="_line_gradient_property".trim();$e$2.registerRenderer("gl",class extends Le$2{constructor(...e){super(...e),this.GeometryTypes=[t__namespace.LineString,t__namespace.MultiLineString]}createPainter(){const t=we$2.get3DPainterClass("line-gradient");this.painterSymbol=Q$4({},{lineGradientProperty:qe$2},Me$2),this.qn(this.painterSymbol,t.getBloomSymbol());const e=Q$4({},this.layer.options.sceneConfig||{});return void 0===e.depthMask&&(e.depthMask=!0),new t(this.regl,this.layer,this.painterSymbol,e,0)}buildMesh(){let{features:t,center:e}=this.gn();if(t=t.filter((t=>!!t.properties[qe$2])),!t.length)return;const n=this.un;this.Qn=e;const i=Q$4({},this.painterSymbol),r=this.createMesh(this.painter,Is$2,i,t,null,e);this.Wn=!0,r.then((t=>{this.meshes&&this.painter.deleteMesh(this.meshes);const e=[],i=t&&t.meshes;if(i){e.push(...i);for(let t=0;t<i.length;t++)i[t].feaGroupIndex=0,i[t].geometry.properties.originElements=i[t].geometry.properties.elements.slice()}this.meshes=e,n&&(this.un=n),this.Wn=!1,this.setToRedraw()}))}}),$e$2.registerRenderer("canvas",null);class Je$2 extends we$2{static fromJSON(t){return Xe$2(t,"PolygonLayer",Je$2)}}Je$2.registerJSONType("PolygonLayer");const Ke$2={polygonFill:{type:"identity",default:[1,1,1,1],property:"_symbol_polygonFill"},polygonPatternFile:{type:"identity",default:void 0,property:"_symbol_polygonPatternFile"},polygonOpacity:{type:"identity",default:1,property:"_symbol_polygonOpacity"},uvScale:{type:"identity",default:[1,1],property:"_symbol_uvScale"},uvOffset:{type:"identity",default:[0,0],property:"_symbol_uvOffset"},uvOffsetInMeter:{type:"identity",default:!1,property:"_symbol_uvOffsetInMeter"},polygonPatternFileWidth:{type:"identity",default:void 0,property:"_symbol_polygonPatternFileWidth"},polygonPatternFileHeight:{type:"identity",default:void 0,property:"_symbol_polygonPatternFileHeight"},polygonPatternFileOrigin:{type:"identity",default:void 0,property:"_symbol_polygonPatternFileOrigin"},polygonPatternUV:{type:"identity",default:void 0,property:"_symbol_polygonPatternUV"}};class Ze$2 extends Le$2{constructor(...e){super(...e),this.GeometryTypes=[t__namespace.Polygon,t__namespace.MultiPolygon]}getPolygonOffsetCount(){return this.options.altitude>0?0:2}buildMesh(t){const{features:e,center:n}=this.gn();if(!e.length)return;const i=this.un;this.Qn=n;const r=this.ti(e),s=Q$4({},Ke$2),o=r.map(((e,i)=>this.createMesh(this.painter,Qs$2,s,e,t&&t[i],n)));this.Wn=!0,Promise.all(o).then((t=>{this.meshes&&this.painter.deleteMesh(this.meshes),t=function(t){const e=[];for(let n=0;n<t.length;n++)Array.isArray(t[n])?e.push(...t[n]):e.push(t[n]);return e}(t);const e=[],n=[];for(let i=0;i<t.length;i++){const r=t[i]&&t[i].meshes;if(r){e.push(...r);for(let t=0;t<r.length;t++)r[t].feaGroupIndex=i,r[t].geometry.properties.originElements=r[t].geometry.properties.elements.slice(),1===i&&(r[t].transparent=!0);n[i]=t[i].atlas}}this.meshes=e,this.atlas=n,i&&(this.un=i),this.Wn=!1,this.setToRedraw(),this.layer.fire("buildmesh")}))}getRayCastData(t,e){const n=this.painter.getRayCastData(t,e);if(!n||!n.feature)return null;return this.Be[n.feature[Te$2]]}ti(t){const e=[],n=[];for(let i=0;i<t.length;i++){const r=t[i];r.properties&&r.properties._symbol_polygonOpacity<1?n.push(r):e.push(r)}return[e,n]}createPainter(){const t=we$2.get3DPainterClass("fill"),e=this.painterSymbol=Q$4({},Ke$2);return this.qn(e,t.getBloomSymbol()),new t(this.regl,this.layer,e,this.layer.options.sceneConfig,0)}updateMesh(t){return this.Rn(t,this.meshes,this.atlas,this.Qn,this.painter,Qs$2,Ke$2,this.ti)}}function Qe$2(t,e,n,i,r,s,o){const a=n&&Array.isArray(n[0]);for(let l=0,h=n.length;l<h;l++){t[e]=(a?n[l][0]:n[l].x)*i,t[e+1]=(a?n[l][1]:n[l].y)*i,o!==Float32Array&&(t[e]=Math.round(t[e]),t[e+1]=Math.round(t[e+1]));let u=r||0;Array.isArray(r)&&(u=r[l]),u=u?Math.round(i*u):0,t[e+2]=u,e+=3,s&&0!==l&&l!==h-1&&(t[e]=t[e-3],t[e+1]=t[e-2],t[e+2]=t[e-1],e+=3)}return t.trySetLength&&t.trySetLength(e),e}function tn$2(t,e,n,i){const r=t[3*e],s=t[3*e+1];return r===t[3*n]&&(r<0||r>i)||s===t[3*n+1]&&(s<0||s>i)}Je$2.registerRenderer("gl",Ze$2),Je$2.registerRenderer("canvas",null);const en$2=Math.PI/180,nn$2=6378137*Math.PI/180;function rn$2(t,e,n){if("EPSG:3857"===n)return function(t,e){const n=85.0511287798,i=e[0],r=Math.max(Math.min(n,e[1]),-n);let s;return s=0===r?0:Math.log(Math.tan((90+r)*en$2/2))/en$2,t[0]=i*nn$2,t[1]=s*nn$2,t}(t,e);if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return sn$2(t,e);if("baidu"===n)return sn$2(t,e);throw new Error("unsupported projection:"+n)}function sn$2(t,e){return t[0]=e[0],t[1]=e[1],t}function an$2(t,e,n,i){const r=n[0]-i[0],s=n[1]-i[1];let o=(e[0]-n[0])*(n[0]-i[0])+(e[1]-n[1])*(n[1]-i[1]);return o/=r*r+s*s,t[0]=n[0]+o*r,t[1]=n[1]+o*s,t}function ln$2(t,e,n,i,r){return h=i,u=r,c=t[3*e[n-1]],f=t[3*e[n-1]+1],Math.sqrt((c-h)*(c-h)+(f-u)*(f-u));var h,u,c,f}function hn$2(t,e,n,i,r,s,o,a,l,h,u,c,f,d,p,m,y){const g=e.length,v=r/3;for(let n=2,i=g;n<i;n+=3)t[r+n-2]=e[n-2],t[r+n-1]=e[n-1],t[r+n-0]=e[n]-o;r+=g;for(let n=2,i=g;n<i;n+=3)t[r+n-2]=e[n-2],t[r+n-1]=e[n-1],t[r+n-0]=e[n]-a;t.trySetLength((r+=g)+g),t.copyWithin(r,r-2*g,r-g),t.trySetLength((r+=g)+g),t.copyWithin(r,r-2*g,r-g),r+=g,(n=n||[]).push(g/3);for(let e=0;e<n.length;e++)un$2(v+(n[e-1]||0),v+n[e],t,g/3,l,i,h,u,c,f,s,d,p,m,y);return r}function un$2(t,e,n,i,r,s,o,a,l,h,u,c,f,d,p){const m=s.length;let y,g;for(let o=t,a=e;o<a-1;o++)y=o,g=o+1,r!==1/0&&tn$2(n,y,g,r)||((o-t)%2==1&&(y+=2*i,g+=2*i),p?(s.push(y+i,g,y),s.push(g+i,g,y+i)):(s.push(y+i,y,g),s.push(g,g+i,y+i)));o&&function(t,e,n,i,r,s,o,a,l,h,u){let c,f=0,d=0,p=0,m=0;const y=u?[1,3,4]:[2,3,4];for(let u=s.length-1;u>=0;u--){const g=s[u],x=3*g+2,b=r[3*g],A=r[3*g+1],w=r[x];f||d||(f=Math.max(r[x],r[3*s[u-3]+2]),d=Math.min(r[x],r[3*s[u-3]+2]),c=f-d);let _=p;const S=u%6;0===t?(5===S&&(m=ln$2(r,s,u,b,A)),_=S===y[0]||S===y[1]||S===y[2]?p:p+m):1===t&&(S===y[0]||S===y[1]||S===y[2]?_=0:5===S?(m=ln$2(r,s,u,b,A),_=m):_=m);let P;P=1===e?w===f?1:0:"bottom"===n?w===f?c/100/a:0:w===f?0:-c/100/a,i[2*g]=_/l*(1/(100*h))/o,i[2*g+1]=P,0===S&&(p+=m)}}(a,l,h,u,n,s.slice(m,s.length),c[0],c[1],f,d,p)}function cn$2(t){const e=[t[0]];let n=t[0];for(let i=1;i<t.length;i++)Array.isArray(t[i])?t[i][0]===n[0]&&t[i][1]===n[1]&&t[i][2]===n[2]||e.push(t[i]):t[i].x===n.x&&t[i].y===n.y&&t[i].z===n.z||e.push(t[i]),n=t[i];return e}const fn$2=Er$3.getInstance();function dn$2(t,e,n,i,r,s,o,a,l,h,u,c,f,d,m,v){void 0===e.top&&(e.top=!0),void 0===e.side&&(e.side=!0),fn$2.reset();const{altitudeScale:x,altitudeProperty:b,defaultAltitude:w,heightProperty:_,minHeightProperty:S,defaultHeight:M,tangent:P,uv:T,topUVMode:k,sideUVMode:F,sideVerticalUVMode:C,top:E,side:D,textureYOrigin:R,topThickness:L}=e,N=!!v,H=function(t,e,{altitudeScale:n,altitudeProperty:i,defaultAltitude:r,heightProperty:s,minHeightProperty:o,defaultHeight:a},{center:l,side:h,top:u,topThickness:c,uvOrigin:f,uv:d,uvSize:p,topUVMode:m,sideUVMode:y,sideVerticalUVMode:g,textureYOrigin:v,tileRatio:x,centimeterToPoint:b,verticalCentimeterToPoint:w,positionType:_,res:S,glScale:M,projectionCode:P},T,k){let I=e/t[0].extent;e===1/0&&(I=1);const F=e===1/0,C=k.get(),E=k.get(),D=k.get(),R=k.get(),L=k.get(),N=k.get(),H=k.get(),z=!!d,V=!!u,j=!!h,B=z?k.get():null;function G(t,n,i,r,s,o){let a=n;if(V){const r=earcut$1.exports(R,i,3);if(0===r.length)return n;if(st$3(L,R),n+=R.length,o)for(let e=2,n=r.length;e<n;e+=3)r[e]+=t/3,r[e-1]+=t/3,r[e-2]+=t/3;else{let e;for(let n=2,i=r.length;n<i;n+=3)e=r[n-1],r[n-1]=r[n]+t/3,r[n]=e+t/3,r[n-2]+=t/3}st$3(N,r),z&&function(t,e,n,i,r,s,o,a,l,h,u,c,f,d,p){0===t?function(t,e,n,i,r,s,o,a,l,h){const u=1/(100*s[0]),c=1/(100*s[1]),f=h&&h[0]||0,d=h&&h[1]||0,p=[0,0];for(let r=t;r<e;r+=3){const t=r/3*2,s=i[r+1]-d;n[t]=p[0]+(i[r]-f)/o*u/a,n[t+1]=p[1]-s/o*c/l}}(e,n,i,r,0,o,a,l,h,p):1===t&&function(t,e,n,i,r,s,o,a,l,h,u){if(!t)return;let c,f,d,p;0===t[4]?(c=t[0],f=t[1],d=t[2],p=t[3]):(c=t[1],f=t[2],d=t[3],p=t[0]);const m=distance(c,f),y=distance(f,d),g=[],v=[],x=[];for(let t=e;t<n;t+=3){const e=t/3*2;set(g,(s.x/l+r[t]/o)*a,s.y/l*a+(u?r[t+1]:-r[t+1])/o*a),"EPSG:4326"!==h&&"EPSG:4490"!==h||rn$2(g,g,"EPSG:3857"),an$2(v,g,c,f),an$2(x,g,p,c),i[e]=distance(c,v)/m,i[e+1]=distance(c,x)/y}}(u,e,n,i,r,s,a,c,f,d,!!p)}(m||0,t,n,B,L,f,b,x,p[0],p[1],s,S,M,P,l),c>0&&!j&&(n=hn$2(L,R,i,N,n,B,0,c,e,z,y||0,g||0,v,p,x,w,o)),H.setLength(n/3),H.fill(1,a/3,n/3)}if(j){V&&(c=0),a=n,n=hn$2(L,R,i,N,n,B,c,r,e,z,y||0,g||0,v,p,x,w,o),H.setLength(n/3);const t=R.length/3;H.fill(1,a/3,a/3+t),H.fill(0,a/3+t,a/3+2*t),H.fill(1,a/3+2*t,a/3+3*t),H.fill(0,a/3+3*t,n/3)}return n}let W=0,X=0;const Y=[-1,-1,e+1,e+1];let $=0,q=t.length;et$3(T)&&($=T,q=T+1);let J=0,K=!1;const Z=k.get();for(;$<q;$++){const l=t[$],h=l.id;et$3(h)&&(Math.abs(h)>J&&(J=Math.abs(h)),h<0&&(K=!0));const u=l.geometry,c=l.properties.maptalks_ombb;let f=Array.isArray(c&&c[0]&&c[0][0])?c[0]:c;const{altitude:d,height:p}=Fa.getFeaAltitudeAndHeight(l,n,i,r,s,a,o);W=Math.max(Math.abs(d),W);const m=L.length;let y=0,g=X;Z.setLength(0),R.setLength(0);const v=Fa.calculateSignedArea(u[0])<0;for(let t=0,n=u.length;t<n;t++){let i=u[t];v&&(i=i.reverse()),i=cn$2(i);const r=Fa.calculateSignedArea(i)<0;if(!r&&t>0&&(y++,f=c&&c[y],X=G(g,X,Z,p*I,f,F),R.setLength(0),Z.setLength(0),g=X),e!==1/0&&(i=Fa.clipPolygon(i,Y)),!i.length){t===n-1&&(X=G(g,X,Z,p*I,f,F));continue}const s=i.length;Array.isArray(i[0])?i[0][0]===i[s-1][0]&&i[0][1]===i[s-1][1]||i.push([i[0][0],i[0][1]]):i[0].x===i[s-1].x&&i[0].y===i[s-1].y||i.push(i[0]),r&&Z.push(R.length/3),Qe$2(R,R.length,i,I,d,!1,_),t===n-1&&(X=G(g,X,Z,p*I,f,F))}const x=L.length-m,b="__fea_idx".trim();for(let t=0;t<x/3;t++)E.push(void 0===l[b]?$:l[b]),C.push($),et$3(h)&&D.push(h)}const Q=Fa.getUnsignedArrayType(E.length?E[E.length-1]:0),tt={maxAltitude:W,vertices:L,verticeTypes:H,indices:N,pickingIds:Er$3.createTypedArray(E,Q),featureIndexes:C};if(D.length){const t=K?Fa.getPosArrayType(J):Fa.getUnsignedArrayType(J);tt.featureIds=Er$3.createTypedArray(D,t)}else tt.featureIds=[];return B&&(B.setLength(L.length/3*2),tt.uvs=B),tt}(t,n,{altitudeScale:x,altitudeProperty:b,defaultAltitude:w||0,heightProperty:_,minHeightProperty:S,defaultHeight:M||0},{center:v,top:E,side:D,topThickness:10*L||0,uv:T||P,uvSize:[r,r],uvOrigin:i,topUVMode:k,sideUVMode:F,sideVerticalUVMode:C,textureYOrigin:R,tileRatio:a,centimeterToPoint:l,verticalCentimeterToPoint:h,positionType:m,res:s,glScale:o,projectionCode:f},d,fn$2),W=[],X=H.vertices.length/3,Y=Fa.getIndexArrayType(X),$=Er$3.createTypedArray(H.indices,Y);delete H.indices,W.push($.buffer,H.pickingIds.buffer);const q=P?fn$2.get():new Float32Array(3*X);q.setLength&&q.setLength(3*X);const J=buildNormals(H.vertices,$,q);let K=!0;for(let t=0;t<J.length;t++){N||(J[t]=-J[t]);const e=J[t]%1;1-Math.abs(e)>1e-6?K=!1:0!==e&&(J[t]=Math.round(J[t]))}if(H.normals=J,P){let t=fn$2.get();t.setLength(4*X),t=buildTangents(H.vertices,H.normals,H.uvs,$,t),t=function(t,e){const n=new Float32Array(e.length),i=[],r=[],s=[];for(let o=0;o<e.length;o+=4){const a=o/4*3;set$4(r,t[a]||0,t[a+1]||0,t[a+2]||0),set$3(i,e[o]||0,e[o+1]||0,e[o+2]||0,e[o+3]||0),packTangentFrame(s,r,i),copy$3(n.subarray(o,o+4),s)}return n}(H.normals,t),H.tangents=t,W.push(t.buffer),delete H.normals}if(H.normals&&(K&&(H.normals=Er$3.createTypedArray(H.normals,Int8Array)),W.push(H.normals.buffer)),H.uvs){H.uvs=Er$3.createTypedArray(H.uvs,Float32Array),W.push(H.uvs.buffer)}if(v){const t=H.vertices;for(let e=0;e<t.length;e+=3)t[e]-=v[0],t[e+1]-=v[1]}const Z=m||Fa.getPosArrayType(Math.max(512,H.maxAltitude)),Q=function(t,e,n,i){const r={},s={};if(ot$3(e.polygonFill)){let o=piecewiseConstant(e.polygonFill);const a=new Uint8Array(4*i.length);a.fill(255);for(let e=0;e<i.length;e++){const s=t[i[e]],l=s.properties||{};l.$layer=s.layer,l.$type=s.type;let h=o(n,l);isFunctionDefinition(h)&&(r.aColor=1,o=piecewiseConstant(h),h=o(n,l)),delete l.$layer,delete l.$type,nt$4.normalizeColor(pn$2,h),a[4*e]=pn$2[0],a[4*e+1]=pn$2[1],a[4*e+2]=pn$2[2],a[4*e+3]=pn$2[3]}s.aColor=a}if(ot$3(e.polygonOpacity)){let o=interpolated(e.polygonOpacity);const a=new Uint8Array(i.length);a.fill(255);for(let e=0;e<i.length;e++){const s=t[i[e]],l=s.properties||{};l.$layer=s.layer,l.$type=s.type;let h=o(n,l);isFunctionDefinition(h)&&(r.aOpacity=1,o=piecewiseConstant(h),h=o(n,l)),delete l.$layer,delete l.$type,a[e]=255*h}s.aOpacity=a}return s.dynamicAttributes=r,s}(t,u,c,H.featureIndexes),tt=function(t,e,n,i,r){const s=[[],[]],o=ot$3(i.topPolygonFill),a=ot$3(i.bottomPolygonFill),l=[255,255,255,255];if(o||a){let h=o&&piecewiseConstant(i.topPolygonFill),u=a&&piecewiseConstant(i.bottomPolygonFill),c=null,f=null,d=null,m=null;for(let i=0;i<e.length;i++){if(1===t[i]&&!o||0===t[i]&&!a)continue;const g=1===t[i];if(g&&e[i]===c){t[i]=d;continue}if(!g&&e[i]===f){t[i]=m;continue}const v=n[e[i]],x=v.properties||{};x.$layer=v.layer,x.$type=v.type;let b=g?h:u,A=b(r,x);isFunctionDefinition(A)&&(b=piecewiseConstant(A),A=b(r,x)),delete x.$layer,delete x.$type,nt$4.normalizeColor(pn$2,A),divide$1(pn$2,pn$2,l);let w=mn$2(s,pn$2);w<0&&(w=s.length,s.push(copy$3([],pn$2))),t[i]=w,g?(c=e[i],d=w):(f=e[i],m=w)}}return s.slice(2)}(H.verticeTypes,H.featureIndexes,t,u,c),nt={data:{data:{aVertexColorType:Er$3.createTypedArray(H.verticeTypes,tt.length<=252?Uint8Array:Uint16Array),aPosition:Er$3.createTypedArray(H.vertices,Z),aNormal:H.normals,aTexCoord0:H.uvs,aTangent:H.tangents,aPickingId:H.pickingIds},indices:$,properties:{maxAltitude:H.maxAltitude},dynamicAttributes:Q.dynamicAttributes,vertexColors:tt},buffers:W};return H.featureIds.length?(nt.data.featureIds=H.featureIds,W.push(nt.data.featureIds.buffer)):nt.data.featureIds=[],Q.aColor&&(nt.data.data.aColor=Q.aColor,nt.buffers.push(Q.aColor.buffer)),Q.aOpacity&&(nt.data.data.aOpacity=Q.aOpacity,nt.buffers.push(Q.aOpacity.buffer)),nt.buffers.push(nt.data.data.aPosition.buffer),nt.data.pickingIdIndiceMap=Fa.generatePickingIndiceIndex(nt.data.data.aPickingId,nt.data.indices),nt}const pn$2=[];function mn$2(t,e){for(let n=0;n<t.length;n++)if(exactEquals$3(e,t[n]))return n;return-1}class yn$2{constructor(t=[],e=gn$2){if(this.data=t,this.length=this.data.length,this.compare=e,this.length>0)for(let t=(this.length>>1)-1;t>=0;t--)this.ei(t)}push(t){this.data.push(t),this.length++,this.ni(this.length-1)}pop(){if(0===this.length)return;const t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this.ei(0)),t}peek(){return this.data[0]}ni(t){const{data:e,compare:n}=this,i=e[t];for(;t>0;){const r=t-1>>1,s=e[r];if(n(i,s)>=0)break;e[t]=s,t=r}e[t]=i}ei(t){const{data:e,compare:n}=this,i=this.length>>1,r=e[t];for(;t<i;){let i=1+(t<<1),s=e[i];const o=i+1;if(o<this.length&&n(e[o],s)<0&&(i=o,s=e[o]),n(s,r)>=0)break;e[t]=s,t=i}e[t]=r}}function gn$2(t,e){return t<e?-1:t>e?1:0}var vn$2={exports:{}},xn$2=function(t,e,n,i){var r=t[0],s=t[1],o=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=(i-n)/2,l=0,h=a-1;l<a;h=l++){var u=e[n+2*l+0],c=e[n+2*l+1],d=e[n+2*h+1];c>s!=d>s&&r<(e[n+2*h+0]-u)*(s-c)/(d-c)+u&&(o=!o)}return o},bn$2=function(t,e,n,i){var r=t[0],s=t[1],o=!1;void 0===n&&(n=0),void 0===i&&(i=e.length);for(var a=i-n,l=0,h=a-1;l<a;h=l++){var u=e[l+n][0],c=e[l+n][1],d=e[h+n][1];c>s!=d>s&&r<(e[h+n][0]-u)*(s-c)/(d-c)+u&&(o=!o)}return o};vn$2.exports=function(t,e,n,i){return e.length>0&&Array.isArray(e[0])?bn$2(t,e,n,i):xn$2(t,e,n,i)};var An$2=vn$2.exports.nested=bn$2;function wn$2(t,e,n,i,r){let s,o,a,l,h=e[0],u=i[0],c=0,f=0;u>h==u>-h?(s=h,h=e[++c]):(s=u,u=i[++f]);let d=0;if(c<t&&f<n)for(u>h==u>-h?(o=h+s,a=s-(o-h),h=e[++c]):(o=u+s,a=s-(o-u),u=i[++f]),s=o,0!==a&&(r[d++]=a);c<t&&f<n;)u>h==u>-h?(o=s+h,l=o-s,a=s-(o-l)+(h-l),h=e[++c]):(o=s+u,l=o-s,a=s-(o-l)+(u-l),u=i[++f]),s=o,0!==a&&(r[d++]=a);for(;c<t;)o=s+h,l=o-s,a=s-(o-l)+(h-l),h=e[++c],s=o,0!==a&&(r[d++]=a);for(;f<n;)o=s+u,l=o-s,a=s-(o-l)+(u-l),u=i[++f],s=o,0!==a&&(r[d++]=a);return 0===s&&0!==d||(r[d++]=s),d}function _n$2(t){return new Float64Array(t)}vn$2.exports.flat=xn$2;const Sn$2=_n$2(4),Mn$2=_n$2(8),Pn$2=_n$2(12),Tn$2=_n$2(16),kn$2=_n$2(4);function Fn$2(t,e,n,i,r,s,o){for(var a=new yn$2([],Cn$2),l=t.data;l;){for(var h=0;h<l.children.length;h++){var u=l.children[h],c=l.leaf?Vn$2(u,n,i):En$2(n,i,u);c>s||a.push({node:u,dist:c})}for(;a.length&&!a.peek().node.children;){var f=a.pop(),d=f.node,p=Vn$2(d,e,n),m=Vn$2(d,i,r);if(f.dist<p&&f.dist<m&&Rn$2(n,d,o)&&Rn$2(i,d,o))return d}(l=a.pop())&&(l=l.node)}return null}function Cn$2(t,e){return t.dist-e.dist}function En$2(t,e,n){if(Dn$2(t,n)||Dn$2(e,n))return 0;var i=Un$2(t[0],t[1],e[0],e[1],n.minX,n.minY,n.maxX,n.minY);if(0===i)return 0;var r=Un$2(t[0],t[1],e[0],e[1],n.minX,n.minY,n.minX,n.maxY);if(0===r)return 0;var s=Un$2(t[0],t[1],e[0],e[1],n.maxX,n.minY,n.maxX,n.maxY);if(0===s)return 0;var o=Un$2(t[0],t[1],e[0],e[1],n.minX,n.maxY,n.maxX,n.maxY);return 0===o?0:Math.min(i,r,s,o)}function Dn$2(t,e){return t[0]>=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function Rn$2(t,e,n){for(var i,r,s,o,a=Math.min(t[0],e[0]),l=Math.min(t[1],e[1]),h=Math.max(t[0],e[0]),u=Math.max(t[1],e[1]),c=n.search({minX:a,minY:l,maxX:h,maxY:u}),f=0;f<c.length;f++)if(r=c[f].next.p,s=t,(i=c[f].p)!==(o=e)&&r!==s&&Ln$2(i,r,s)>0!=Ln$2(i,r,o)>0&&Ln$2(s,o,i)>0!=Ln$2(s,o,r)>0)return!1;return!0}function Ln$2(t,e,n){return function(t,e,n,i,r,s){const o=(e-s)*(n-r),a=(t-r)*(i-s),l=o-a;if(0===o||0===a||o>0!=a>0)return l;const h=Math.abs(o+a);return Math.abs(l)>=33306690738754716e-32*h?l:-function(t,e,n,i,r,s,o){let a,l,h,u,c,f,d,p,m,y,g,v,x,b,A,w,_,S;const M=t-r,P=n-r,T=e-s,k=i-s;b=M*k,f=134217729*M,d=f-(f-M),p=M-d,f=134217729*k,m=f-(f-k),y=k-m,A=p*y-(b-d*m-p*m-d*y),w=T*P,f=134217729*T,d=f-(f-T),p=T-d,f=134217729*P,m=f-(f-P),y=P-m,_=p*y-(w-d*m-p*m-d*y),g=A-_,c=A-g,Sn$2[0]=A-(g+c)+(c-_),v=b+g,c=v-b,x=b-(v-c)+(g-c),g=x-w,c=x-g,Sn$2[1]=x-(g+c)+(c-w),S=v+g,c=S-v,Sn$2[2]=v-(S-c)+(g-c),Sn$2[3]=S;let O=function(t,e){let n=e[0];for(let i=1;i<4;i++)n+=e[i];return n}(0,Sn$2),I=22204460492503146e-32*o;if(O>=I||-O>=I)return O;if(c=t-M,a=t-(M+c)+(c-r),c=n-P,h=n-(P+c)+(c-r),c=e-T,l=e-(T+c)+(c-s),c=i-k,u=i-(k+c)+(c-s),0===a&&0===l&&0===h&&0===u)return O;if(I=11093356479670487e-47*o+33306690738754706e-32*Math.abs(O),O+=M*u+k*a-(T*h+P*l),O>=I||-O>=I)return O;b=a*k,f=134217729*a,d=f-(f-a),p=a-d,f=134217729*k,m=f-(f-k),y=k-m,A=p*y-(b-d*m-p*m-d*y),w=l*P,f=134217729*l,d=f-(f-l),p=l-d,f=134217729*P,m=f-(f-P),y=P-m,_=p*y-(w-d*m-p*m-d*y),g=A-_,c=A-g,kn$2[0]=A-(g+c)+(c-_),v=b+g,c=v-b,x=b-(v-c)+(g-c),g=x-w,c=x-g,kn$2[1]=x-(g+c)+(c-w),S=v+g,c=S-v,kn$2[2]=v-(S-c)+(g-c),kn$2[3]=S;const F=wn$2(4,Sn$2,4,kn$2,Mn$2);b=M*u,f=134217729*M,d=f-(f-M),p=M-d,f=134217729*u,m=f-(f-u),y=u-m,A=p*y-(b-d*m-p*m-d*y),w=T*h,f=134217729*T,d=f-(f-T),p=T-d,f=134217729*h,m=f-(f-h),y=h-m,_=p*y-(w-d*m-p*m-d*y),g=A-_,c=A-g,kn$2[0]=A-(g+c)+(c-_),v=b+g,c=v-b,x=b-(v-c)+(g-c),g=x-w,c=x-g,kn$2[1]=x-(g+c)+(c-w),S=v+g,c=S-v,kn$2[2]=v-(S-c)+(g-c),kn$2[3]=S;const C=wn$2(F,Mn$2,4,kn$2,Pn$2);b=a*u,f=134217729*a,d=f-(f-a),p=a-d,f=134217729*u,m=f-(f-u),y=u-m,A=p*y-(b-d*m-p*m-d*y),w=l*h,f=134217729*l,d=f-(f-l),p=l-d,f=134217729*h,m=f-(f-h),y=h-m,_=p*y-(w-d*m-p*m-d*y),g=A-_,c=A-g,kn$2[0]=A-(g+c)+(c-_),v=b+g,c=v-b,x=b-(v-c)+(g-c),g=x-w,c=x-g,kn$2[1]=x-(g+c)+(c-w),S=v+g,c=S-v,kn$2[2]=v-(S-c)+(g-c),kn$2[3]=S;const E=wn$2(C,Pn$2,4,kn$2,Tn$2);return Tn$2[E-1]}(t,e,n,i,r,s,h)}(t[0],t[1],e[0],e[1],n[0],n[1])}function Nn$2(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function Hn$2(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function zn$2(t,e){var n=t[0]-e[0],i=t[1]-e[1];return n*n+i*i}function Vn$2(t,e,n){var i=e[0],r=e[1],s=n[0]-i,o=n[1]-r;if(0!==s||0!==o){var a=((t[0]-i)*s+(t[1]-r)*o)/(s*s+o*o);a>1?(i=n[0],r=n[1]):a>0&&(i+=s*a,r+=o*a)}return(s=t[0]-i)*s+(o=t[1]-r)*o}function Un$2(t,e,n,i,r,s,o,a){var l,h,u,c,f=n-t,d=i-e,p=o-r,m=a-s,y=t-r,g=e-s,v=f*f+d*d,x=f*p+d*m,b=p*p+m*m,A=f*y+d*g,w=p*y+m*g,_=v*b-x*x,S=_,M=_;0===_?(h=0,S=1,c=w,M=b):(c=v*w-x*A,(h=x*w-b*A)<0?(h=0,c=w,M=b):h>S&&(h=S,c=w+x,M=b)),c<0?(c=0,-A<0?h=0:-A>v?h=S:(h=-A,S=v)):c>M&&(c=M,-A+x<0?h=0:-A+x>v?h=S:(h=-A+x,S=v));var P=(1-(u=0===c?0:c/M))*r+u*o-((1-(l=0===h?0:h/S))*t+l*n),T=(1-u)*s+u*a-((1-l)*e+l*i);return P*P+T*T}function jn$2(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}class Bn$2{constructor(t,e){this.x=t,this.y=e}clone(){return new Bn$2(this.x,this.y)}normalize(){const t=this.length();this.x/=t,this.y/=t}negate(){this.x=-this.x,this.y=-this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}diff(t){return new Bn$2(this.x-t.x,this.y-t.y)}distance(t){const e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}dot(t){return this.x*t.x+this.y*t.y}equals(t){return this.x===t.x&&this.y===t.y}orthogonal(){return new Bn$2(this.y,-this.x)}}function Gn$2(t,e,n,i){const a=((n.x-t.x)*i.y-(n.y-t.y)*i.x)/(e.x*i.y-e.y*i.x);return new Bn$2(t.x+a*e.x,t.y+a*e.y)}const Wn$2=[],Xn$2=[];function Yn$2(t){if(et$3(t[0]&&t[0].x)){const e=[];let n=0;for(let i=0;i<t.length;i++)Xn$2[n]?(Xn$2[n][0]=t[i].x,Xn$2[n][1]=t[i].y):Xn$2[n]=[t[i].x,t[i].y],e.push(Xn$2[n]),n++;t=e}try{const e=function(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;var i=function(t){for(var e=t[0],n=t[0],i=t[0],r=t[0],s=0;s<t.length;s++){var o=t[s];o[0]<e[0]&&(e=o),o[0]>i[0]&&(i=o),o[1]<n[1]&&(n=o),o[1]>r[1]&&(r=o)}var a=[e,n,i,r],l=a.slice();for(s=0;s<t.length;s++)An$2(t[s],a)||l.push(t[s]);return function(t){t.sort(jn$2);for(var e=[],n=0;n<t.length;n++){for(;e.length>=2&&Ln$2(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var i=[],r=t.length-1;r>=0;r--){for(;i.length>=2&&Ln$2(i[i.length-2],i[i.length-1],t[r])<=0;)i.pop();i.push(t[r])}return i.pop(),e.pop(),e.concat(i)}(l)}(t),r=new RBush(16);r.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},r.compareMinX=function(t,e){return t[0]-e[0]},r.compareMinY=function(t,e){return t[1]-e[1]},r.load(t);for(var s,o=[],a=0;a<i.length;a++){var l=i[a];r.remove(l),s=Hn$2(l,s),o.push(s)}var h=new RBush(16);for(a=0;a<o.length;a++)h.insert(Nn$2(o[a]));for(var u=e*e,c=n*n;o.length;){var f=o.shift(),d=f.p,p=f.next.p,m=zn$2(d,p);if(!(m<c)){var y=m/u;(l=Fn$2(r,f.prev.p,d,p,f.next.next.p,y,h))&&Math.min(zn$2(l,d),zn$2(l,p))<=y&&(o.push(f),o.push(Hn$2(l,f)),r.remove(l),h.remove(f),h.insert(Nn$2(f)),h.insert(Nn$2(f.next)))}}f=s;var g=[];do{g.push(f.p),f=f.next}while(f!==s);return g.push(f.p),g}(t,1/0);let n=[1/0,1/0],i=[-1/0,-1/0];for(let t=0;t<e.length;t++)e[t][0]<n[0]&&(n[0]=e[t][0]),e[t][0]>i[0]&&(i[0]=e[t][0]),e[t][1]<n[1]&&(n[1]=e[t][1]),e[t][1]>i[1]&&(i[1]=e[t][1]);const r=[];let s=[],o=0;for(let t=0;t<e.length;t++)t===e.length-1&&e[t][0]===e[0][0]&&e[t][1]===e[0][1]||(rn$2(r,e[t],"EPSG:3857"),Wn$2[o]?(Wn$2[o].x=r[0],Wn$2[o].y=r[1]):Wn$2[o]=new Bn$2(r[0],r[1]),s.push(Wn$2[o]),o++);Fa.calculateSignedArea(s)<0&&(s=s.reverse());const a=function(t){let e,n=Number.MAX_VALUE;const i=function(t,i,r,s,o,a,l,h){var u=Gn$2(t,i,o,a),c=Gn$2(r,s,o,a),f=Gn$2(l,h,t,i),d=Gn$2(l,h,r,s),p=u.distance(c)*u.distance(f);0!==p&&p<n&&(e=[u,f,d,c],n=p)};var r=[];for(let e=0;e<t.length;e++)r.push(t[(e+1)%t.length].diff(t[e])),r[e].normalize();var s,o,a,l,h=new Bn$2(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),u=new Bn$2(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let e=0;e<t.length;e++){var c=t[e];c.x<h.x&&(h.x=c.x,s=e),c.x>u.x&&(u.x=c.x,o=e),c.y<h.y&&(h.y=c.y,l=e),c.y>u.y&&(u.y=c.y,a=e)}var f=new Bn$2(0,-1),d=new Bn$2(0,1),p=new Bn$2(-1,0),m=new Bn$2(1,0);for(let e=0;e<t.length;e++){var y=[Math.acos(f.dot(r[s])),Math.acos(d.dot(r[o])),Math.acos(p.dot(r[a])),Math.acos(m.dot(r[l]))];switch(y.indexOf(Math.min.apply(Math,y))){case 0:(d=(f=r[s].clone()).clone()).negate(),(m=(p=f.orthogonal()).clone()).negate(),s=(s+1)%t.length;break;case 1:(f=(d=r[o].clone()).clone()).negate(),(m=(p=f.orthogonal()).clone()).negate(),o=(o+1)%t.length;break;case 2:(m=(p=r[a].clone()).clone()).negate(),(d=(f=m.orthogonal()).clone()).negate(),a=(a+1)%t.length;break;case 3:(p=(m=r[l].clone()).clone()).negate(),(d=(f=m.orthogonal()).clone()).negate(),l=(l+1)%t.length}i(t[s],f,t[o],d,t[a],p,t[l],m)}return e}(s);if(!a||4!==a.length)return null;const l=a[0].distance(a[1]),h=a[1].distance(a[2]),u=a.map((t=>[t.x,t.y]));return u.push(+(h>l)),u}catch(t){return null}}class $n$2 extends we$2{static fromJSON(t){return Xe$2(t,"ExtrudePolygonLayer",$n$2)}getPolygonOffsetCount(){return 0}getPolygonOffset(){return 0}onConfig(t){const e=this.getRenderer();return e&&e.onConfig(t),super.onConfig(t)}updateMaterial(t){this.options.material||(this.options.material={}),t?Q$4(this.options.material,t):this.options.material=null;const e=this.getRenderer();return e&&e.updateMaterial(t),this}updateSideMaterial(t){let e=!1;this.options.sideMaterial||(this.options.sideMaterial={},e=!0),t?Q$4(this.options.sideMaterial,t):this.options.sideMaterial=null;const n=this.getRenderer();return n&&(e&&n.ii(),n.updateSideMaterial(t)),this}updateDataConfig(t){if(!t)return this;this.options.dataConfig||(this.options.dataConfig={});const e=JSON.parse(JSON.stringify(this.options.dataConfig));Q$4(this.options.dataConfig,t);const n=this.getRenderer();return n&&n.updateDataConfig(t,e),this}}$n$2.registerJSONType("ExtrudePolygonLayer"),$n$2.mergeOptions({cullFace:!1,castShadow:!0});const qn$2={polygonFill:{type:"identity",default:[1,1,1,1],property:"_symbol_polygonFill"},polygonOpacity:{type:"identity",default:1,property:"_symbol_polygonOpacity"},topPolygonFill:{type:"identity",default:[1,1,1,1],property:"_symbol_topPolygonFill"},bottomPolygonFill:{type:"identity",default:[1,1,1,1],property:"_symbol_bottomPolygonFill"}},Jn$2={defaultAltitude:20},Kn$2=t=>1===t.properties.top;$n$2.registerRenderer("gl",class extends Ze$2{constructor(...e){super(...e),this.GeometryTypes=[t__namespace.Polygon,t__namespace.MultiPolygon]}ti(t){return[t]}onConfig(t){this.painter&&(rt$3(t.cullFace)||this.painter.updateSceneConfig({cullFace:t.cullFace}))}updateMaterial(t){this.painter&&(this.painter.ri(t),this.layer.options.sideMaterial||this.sidePainter.ri(t),this.setToRedraw())}ii(){this.sidePainter&&this.sidePainter.deleteMaterial()}updateSideMaterial(t){this.sidePainter&&(t?this.sidePainter.ri(t):(this.sidePainter.deleteMaterial(),this.sidePainter.ri(this.layer.options.material)),this.setToRedraw())}updateDataConfig(t,e){this.painter&&(this.painter.updateDataConfig(t,e),this.En())}updateBloom(t){super.updateBloom(t),this.sidePainter&&this.Kn(this.sidePainter,this.sidePainterSymbol,t)}needCheckPointLineSymbols(){return!1}draw(t,e){return super.draw(t,e)}createPainter(){const t=we$2.get3DPainterClass("lit");this.painterSymbol=Q$4({},qn$2),this.sidePainterSymbol=Q$4({},qn$2),this.qn(this.painterSymbol,t.getBloomSymbol());const e=Q$4({},Jn$2,this.layer.options.dataConfig||{});this.layer.options.material&&(this.painterSymbol.material=this.layer.options.material),this.sidePainterSymbol.material=this.layer.options.sideMaterial?this.layer.options.sideMaterial:this.layer.options.material;const n={cullFace:this.layer.options.cullFace};Object.defineProperty(n,"castShadow",{enumerable:!0,get:()=>this.layer.options.castShadow});const i=Q$4({},e);i.upsideUpTexture=!0;const r=new t(this.regl,this.layer,this.painterSymbol,n,0,i);return this.sidePainter=new t(this.regl,this.layer,this.sidePainterSymbol,n,0,e),r}xt(...t){super.xt(...t);const e=this.painter;this.painter=this.sidePainter,super.xt(...t),this.painter=e}pn(...t){const e=t[0],n=e.sceneFilter;e.sceneFilter=t=>(!n||n(t))&&Kn$2(t);const i=super.pn(...t);e.sceneFilter=t=>(!n||n(t))&&Kn$2(t);const r=this.painter;this.painter=this.sidePainter;const s=e.sceneFilter=t=>(!n||n(t))&&(t=>1===t.properties.side)(t);return super.pn(...t),this.painter=r,e.sceneFilter=n,{redraw:i.redraw||s.redraw,drawCount:(i.drawCount||0)+(s.drawCount||0)}}createMesh(t,e,n,i,r,s){const o=[];this.si=s;const a=this.oi(i,n,!0,!1),l=this.oi(i,n,!1,!0);if(a){const r=this.xn(a,t,e,n,i,null,s);r.meshes[0].properties.top=1,o.push(r)}if(l){const r=this.xn(l,t,e,n,i,null,s);r.meshes[0].properties.side=1,o.push(r)}return o}oi(e,n,i,r){const s=this.getMap();n=qn$2;const o=this.si,a=s.getZoom(),l=new t__namespace.Point(0,0),h=new t__namespace.Coordinate(0,0),u=Q$4({},Jn$2,this.layer.options.dataConfig);if(u.tangent=1,u.top&&(u.top=i),u.side&&(u.side=r),!1===u.top&&!1===u.side)return null;if(!e.length)return null;const c=s.getGLRes(),f=s.getProjection().code,d=i?this.painterSymbol&&this.painterSymbol.material:this.sidePainterSymbol&&this.sidePainterSymbol.material,p=d&&d.textureWidth||23.25,m=[Bt$3(s,1,h,c)/100,Bt$3(s,1,h,c,1)/100];return dn$2(e,u,1/0,l,p,s.getGLRes(),1,1,m,this.yt,n,a,f,void 0,Float32Array,o)}updateMesh(t){let n=this.features[t[Te$2]];if(!n)return;const i=this.oi([n],this.painterSymbol,!0,!1);let r=0;i&&i.data&&this.Hn(this.meshes[r++],n.id,i);const s=this.oi([n],this.painterSymbol,!1,!0);s&&s.data&&this.Hn(this.meshes[r++],n.id,s)}Cn(e){if(e.getProperties()||e.setProperties({}),!e.getProperties().maptalks_ombb){const n=e.getCoordinates();if(e instanceof t__namespace.MultiPolygon){const t=[];for(let e=0;e<n.length;e++){t[e]=Yn$2(n[e]&&n[e][0])}e.getProperties().maptalks_ombb=t}else{const t=Yn$2(n[0]);e.getProperties().maptalks_ombb=t}}return super.Cn(e)}resizeCanvas(t){super.resizeCanvas(t),this.sidePainter&&this.sidePainter.resize(this.canvas.width,this.canvas.height)}onRemove(){super.onRemove(),this.sidePainter&&(this.sidePainter.delete(),delete this.sidePainter)}drawOutline(t){if(super.drawOutline(t),this.Mt&&this.sidePainter&&this.sidePainter.outlineAll(t),this.Zn)for(let e=0;e<this.Zn.length;e++)this.sidePainter&&this.sidePainter.outline(t,this.Zn[e])}getShadowMeshes(){return this.painter?this.painter.getShadowMeshes():[]}}),$n$2.registerRenderer("canvas",null);const Zn$2={redraw:!1,retire:!1},Qn$2=[];let ti$1=1;function ei$1(t,e){return VectorTilePlugin.extend(t,{init:function(){this.ai={}},isVisible(){return this.painter&&this.painter.isVisible()},supportRenderMode:function(t){return this.painter.supportRenderMode(t)},hasMesh(){return this.painter&&this.painter.hasMesh()},startFrame:function(t){const r=t.sceneConfig;let a=this.painter;if(!a){a=this.painter=new e(t.regl,t.layer,t.symbol,r,t.pluginIndex,t.dataConfig)}this.ai||(this.ai={});const l=r.excludes;this.li?l!==this.li&&(this.hi=l?createFilter(l):null,this.li=l):l&&(this.li=l),a.startFrame(t),this.ui={}},updateCollision:function(t){const e=this.painter;return e&&e.isVisible()?e.updateCollision(t):null},prepareRender:function(t){const e=this.painter;return e&&e.isVisible()?e.prepareRender(t):null},endFrame:function(t){const e=this.painter;return e&&e.isVisible()?e.render(t):null},getShadowMeshes(){const t=this.painter;return t&&t.getShadowMeshes&&t.getShadowMeshes()||Qn$2},createTile:function(t){const{tileCache:e,tileData:n}=t;let i=!1;const r=this.painter;if(!r)return{retire:i};const s=this.ci(t);let o=e.geometry;if(!o){const s=n.features,a=n.data;if(!a||!a.length)return{retire:i};const l=a;if(this.painter.colorSymbol&&!function(t){if(!t)return!0;for(const e in t)return!1;return!0}(s))for(let t=0;t<a.length;t++){const e=this.fi(s,a[t].data.aPickingId,a[t].indices,a[t].data.aPosition,a[t].positionSize);a[t].data.aColor=e}o=e.geometry=r.createGeometries(l,s);for(let e=0;e<o.length;e++)o[e]&&o[e].geometry&&(i=!0,o[e].geometry.properties.features=s,this.bn(o[e].geometry,t))}let a=this.H(s);if(!a){const{meshes:e,retire:n}=this.di(o,t);i||(i=n),a=e}return{retire:i}},di(t,e){const{layer:n,tileInfo:i,tileExtent:r,tileTransform:s,tileTranslationMatrix:o,tileVectorTransform:a,tileZoom:l,sceneConfig:h}=e;let u=!1;const d=this.painter.createMeshes(t,s,{tileExtent:r,tilePoint:[i.extent2d.xmin,i.extent2d.ymax],tileZoom:l,tileTranslationMatrix:o,tileVectorTransform:a},e);if(d.length){const t=n.getRenderer().isEnableTileStencil();for(let n=0;n<d.length;n++)d[n]&&(u=!0,this.pi(d[n],s,e.timestamp,ti$1++,t));h.animation&&(d.mi=e.timestamp);const i=this.ci(e);this.ai[i]=d}return{meshes:d,retire:u}},paintTile:function(t){const{tileCache:e,tileInfo:n,tileZoom:i,sceneConfig:r}=t,s=this.painter;if(!s)return Zn$2;let o=e.geometry;if(!o)return Zn$2;let a=!1;const l=this.ci(t);let h=this.H(l);if(!h){const{meshes:e,retire:n}=this.di(o,t);a||(a=n),h=e}if(!h.length)return Zn$2;const u=s.getTileLevelValue(n,i);h.forEach((t=>{t.properties.tile=n,t.properties.level=u}));let c=!1;if(!this.ui[l]){let e=null,n=r.animation;if(n){const i=t.sceneConfig.animationDuration||800,r=(t.timestamp-h.mi)/i;h.mi-h[0].properties.createTime<i&&r<1&&(!0!==n&&1!==n||(n="linear"),e="linear"===n?r:X$4(n,r),c=!0)}s.addMesh(h,e,t),this.ui[l]=1}return{redraw:c,retire:a}},pi:function(t,e,n,i,r){if(t.properties.tileTransform=e,t.properties.createTime=n,t.properties.meshKey=i,t.needUpdateShadow=!0,r){const e=t.defines||{};e.ENABLE_TILE_STENCIL=1,t.setDefines(e),"stencilRef"in t.uniforms||Object.defineProperty(t.uniforms,"stencilRef",{enumerable:!0,get:function(){return t.properties.tile&&void 0!==t.properties.tile.stencilRef?t.properties.tile.stencilRef:t.properties.level}})}},bn:function(t,e){const{layer:n,tileInfo:i}=e,r=n.getMap(),s=(n.getSpatialReference?n.getSpatialReference():r.getSpatialReference()).getResolution(i.z),o=e.tileExtent/n.getTileSize().width;t.properties.tileResolution=s,t.properties.tileRatio=o,t.properties.z=i.z,t.properties.tileExtent=e.tileExtent},updateSceneConfig:function(t){const e=this.painter;e&&e.updateSceneConfig(t.sceneConfig)},updateDataConfig:function(t,e){const n=this.painter;return!n||n.updateDataConfig(t,e)},updateSymbol:function(t,e){const n=this.painter;if(!n)return!1;if(n.shouldDeleteMeshOnUpdateSymbol(t)){if(this.ai)for(const t in this.ai)n.deleteMesh(this.ai[t],!0);delete this.ai,delete this.ui}return n.updateSymbol(t,e)},pick:function(t,e,n){return this.painter&&this.painter.pick?this.painter.pick(t,e,n):null},deleteTile:function(t){if(!this.ai)return;const e=this.ci(t),n=this.ai[e];n&&this.painter&&this.painter.deleteMesh(n),delete this.ai[e],this.ui&&delete this.ui[e]},remove:function(){const t=this.painter;if(t&&this.ai){for(const e in this.ai)t.deleteMesh(this.ai[e]);t.delete(),delete this.painter}delete this.ai,delete this.ui},resize:function(t,e){const n=this.painter;n&&n.resize(t,e)},needToRedraw:function(){return!!this.painter&&this.painter.needToRedraw()},needToRetireFrames:function(){return!!this.painter&&this.painter.needToRetireFrames()},isAnimating(){return!!this.painter&&this.painter.isAnimating()},needToRefreshTerrainTileOnZooming:function(){return!!this.painter&&this.painter.needToRefreshTerrainTileOnZooming()},isTerrainSkin:function(){return!!this.painter&&this.painter.isTerrainSkin()},isTerrainVector:function(){return!!this.painter&&this.painter.isTerrainVector()},fi:function(t,e,n,i,r=3){if(!i||!t||!e.length)return null;const s=new Uint8Array(i.length/r*4);let o,a;const l=this.painter.colorSymbol,h={};let u;for(let n=0,i=e.length;n<i;n++){const i=e[n];if(o=t[i].symbol,a=h[i],!a)if(l){let e;e="function"==typeof l?l(t[i].feature&&t[i].feature.properties):l,e=color(e),a=h[i]=e.array()}else a=h[i]=[255,255,255];u=4*n,s[u]=a[0],s[u+1]=a[1],s[u+2]=a[2],s[u+3]=255*(o[this.painter.opacitySymbol]||1)}return s},ci:function(t){const e=t.tileInfo;return e.meshKey||(e.meshKey=ti$1++),e.meshKey},H:function(t){return this.ai[t]},yi(t,e){if(Array.isArray(t))t.forEach(((t,n)=>{const{features:i}=t.properties;this.gi(t,e[n],i)}));else{const{features:n}=t.properties;this.gi(t,Array.isArray(e)?e[0]:e,n)}},gi(t,e,n){const i=e.featureIndexes||e.data.featureIndexes;if(i)if(this.hi){const r=e.indices;let s=null,o=!1;const a=[];for(let t=0;t<r.length;t++){const e=n[i[r[t]]];null!==s&&s===r[t]||(o=this.hi(e.feature),s=r[t]),o||a.push(r[t])}t.setElements(new e.indices.constructor(a))}else t.setElements(e.indices)},outline(t,e){const n=this.painter;n&&n.outline(t,e)},outlineAll(t){const e=this.painter;e&&e.outlineAll(t)},needPolygonOffset(){const t=this.painter;return t&&t.needPolygonOffset()},highlight(t){const e=this.painter,n=this.style.name,i=this.renderIndex;if(t){const e=[];if(t.forEach(((t,r)=>{null!=t.plugin&&(Array.isArray(t.plugin)?t.plugin.length&&t.plugin.indexOf(n)<0&&t.plugin.indexOf(i)<0&&e.push(r):t.plugin!==n&&t.plugin!==i&&e.push(r))})),e.length){const n=new Map(t);for(let t=0;t<e.length;t++)n.delete(e[t]);t=n}}return e&&e.highlight(t)},cancelAllHighlight(){const t=this.painter;return t&&t.cancelAllHighlight()}})}class ni$1{constructor(){this.vi=1}write(t,e){const n=t.gl,i=this.vi++;return t.stencilFunc(n.ALWAYS,i,255),t.draw(e),i}start(t){const e=t.gl;e.clearStencil(255),e.clear(e.STENCIL_BUFFER_BIT),this.vi=1,t.start()}end(t){t.end()}}function ii$1(t){return!t||(void 0!==t.empty||(t.empty=function(t){for(const e in t)return!1;return!0}(t)),t.empty)}const ri$1="_fn_type_";function si$1(t,e,n){if(!ii$1(t.properties.features))for(let i=0;i<n.length;i++){const{symbolName:r}=n[i];(t.xi=t.xi||{})[r]=e[r],oi$1(t,e,n[i])}}function oi$1(t,e,n){const i=function(t){const e=t.properties;let n=e.aPickingId;return n||(n=e.aPickingId=new t.data.aPickingId.constructor(t.data.aPickingId)),n}(t),{attrName:r,symbolName:s,related:o}=n;let a=t.data[r];return a?yi$1(e[s])||function(t,e){if(!Array.isArray(t))return!1;for(let n=0;n<t.length;n++)if(yi$1(e[t[n]]))return!0;return!1}(o,e)?(yi$1(e[s])&&ai$1(t,e,n),a):(t.deleteData(r),li$1(t,r),null):yi$1(e[s])?(a=t.data[r]=new n.type(n.width*i.length),function(t,e,n,i){const{attrName:r}=i,s=(ri$1+r+"Index").trim();ai$1(e,n,i);di$1(e,e.properties[s],i)}(0,t,e,n),a):null}function ai$1(t,e,n){const{attrName:i,symbolName:r}=n,s=t.properties,o=(ri$1+i+"Index").trim(),a=(ri$1+i).trim();if(s[o]&&s[a])return;const l=function(t){if(!t)return fi$1;const e=[];for(let n=0;n<t.length;n++)isFunctionDefinition(t[n][1])&&!interpolated(t[n][1]).isZoomConstant&&e.push(t[n][0]);return e}(e[r].stops),h="identity"===e[r].type&&nt$4.checkIfIdentityZoomDependent(r,e[r].property,s.features);if(!h&&!l.length)return void li$1(t,i);const{features:u,aPickingId:c}=s,f=function(t,e,n,i,r){const s=[];let o=0,a=e[0];for(let l=1,h=e.length;l<h;l++)e[l]===a&&l!==h-1||((r||ci$1(t[a].feature,n,i))&&s.push(o,l===h-1?h:l),a=e[l],o=l);return s}(u,c,e[r].property,l,h);if(!f.length)return void li$1(t,i);const d=t.data[i];s[o]=f,s[a]=d.BYTES_PER_ELEMENT?new d.constructor(d):new n.type(d.length)}function li$1(t,e){const n=t.properties,i=(ri$1+e+"Index").trim(),r=(ri$1+e).trim();delete n[i],delete n[r]}function hi$1(t,e,n,i,r){if(!i)return;const s=i.geometry;if(!s)return;if(ii$1(s.properties.features))return;const o=i.geometry.properties.layer;for(let a=0;a<n.length;a++){const l=n[a],h=l.attrName;if(!(ui$1(s,e,l)||o.ce&&o.ce(i.geometry.bi))){const{aPickingId:t}=s.properties;if(!t||s.Ai===r)continue;const e=(ri$1+h+"Index").trim(),n=s.properties[e];if(!n)continue;di$1(s,n,l);continue}const u=oi$1(s,e,l),c=l.define;if(u){const e=(ri$1+h+"Index").trim();if(di$1(s,s.properties[e],l),o.ue&&(s.bi=o.ue()),c){const t=i.defines;t[c]=1,i.setDefines(t)}s.generateBuffers(t)}else if(c){const t=i.defines;t[c]&&(delete t[c],i.setDefines(t))}}s.Ai=r}function ui$1(t,e,n){const i=e[n.symbolName],r=t.xi;return!fastDeepEqual(i,r[n.symbolName])&&(r[n.symbolName]=i,!0)}function ci$1(t,e,n){for(let i=0;i<n.length;i++)if("$"===e[0]&&t[e.substring(1)]===n[i]||t.properties[e]===n[i])return!0;return!1}const fi$1=[];function di$1(t,e,n){const{attrName:i,evaluate:r}=n,{aPickingId:s,features:o}=t.properties;let a;if(e){const n=(ri$1+i).trim();a=t.properties[n];const l=a.length/s.length,h=e.length;for(let n=0;n<h;n+=2){const i=e[n],h=e[n+1];let u=o[s[i]];u&&u.feature&&mi$1(a,u,r,i,h,l,t)}}else{if(a=t.data[i],function(t){return Array.isArray(t)||t.constructor===Float32Array||t.constructor===Float64Array||t.constructor===Uint8Array||t.constructor===Int8Array||t.constructor===Uint16Array||t.constructor===Int16Array||t.constructor===Uint32Array||t.constructor===Int32Array||t.constructor===Uint8ClampedArray}(a))a.dirty=!0;else{const e=(ri$1+i).trim();a=t.properties[e],a||(a=t.properties[e]=new n.type(n.width*s.length),a.dirty=!0)}const e=a.length/s.length,l=s.length;let h=0;for(let n=0;n<l;n++){if(s[n]===s[h]&&n<l-1)continue;let i=o[s[h]];i&&i.feature&&(mi$1(a,i,r,h,n===l-1?l:n,e,t),h=n)}}a.dirty&&(t.updateData(i,a),a.dirty=!1)}const pi$1={};function mi$1(t,e,n,i,r,s,o){const a=(e=e.feature).properties||{};void 0===a.$layer&&(e.properties||(e.properties=a),a.$layer=e.layer,a.$type=e.type);const l=o.properties.layer;if(l.getFeatureState&&(pi$1.layer=e.layer,pi$1.id=e.id,e[_t$3]&&(e[_t$3]=null),!It$3(e.id))){const t=l.getFeatureState(pi$1);e.properties[_t$3]=t}const h=n(a,o,t,i*s);if(Array.isArray(h)){let e=!1;for(let n=0;n<s;n++)if(t[i*s+n]!==h[n]){e=!0;break}if(e){for(let e=i*s;e<r*s;e+=s)t.set(h,e);t.dirty=!0}}else t[i]!==h&&(Nt$3(t,h,i,r),t.dirty=!0)}function yi$1(t){return nt$4.isFnTypeSymbol(t)}var gi$1=vi$1;function vi$1(t,e){this.x=t,this.y=e}vi$1.prototype={clone:function(){return new vi$1(this.x,this.y)},add:function(t){return this.clone().wi(t)},sub:function(t){return this.clone()._i(t)},multByPoint:function(t){return this.clone().Si(t)},divByPoint:function(t){return this.clone().Mi(t)},mult:function(t){return this.clone().Pi(t)},div:function(t){return this.clone().Ti(t)},rotate:function(t){return this.clone().ki(t)},rotateAround:function(t,e){return this.clone().Oi(t,e)},matMult:function(t){return this.clone().Ii(t)},unit:function(){return this.clone().Fi()},perp:function(){return this.clone().Ci()},round:function(){return this.clone().Ei()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(t){return this.x===t.x&&this.y===t.y},dist:function(t){return Math.sqrt(this.distSqr(t))},distSqr:function(t){var e=t.x-this.x,n=t.y-this.y;return e*e+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(t){return Math.atan2(this.y-t.y,this.x-t.x)},angleWith:function(t){return this.angleWithSep(t.x,t.y)},angleWithSep:function(t,e){return Math.atan2(this.x*e-this.y*t,this.x*t+this.y*e)},Ii:function(t){var n=t[2]*this.x+t[3]*this.y;return this.x=t[0]*this.x+t[1]*this.y,this.y=n,this},wi:function(t){return this.x+=t.x,this.y+=t.y,this},_i:function(t){return this.x-=t.x,this.y-=t.y,this},Pi:function(t){return this.x*=t,this.y*=t,this},Ti:function(t){return this.x/=t,this.y/=t,this},Si:function(t){return this.x*=t.x,this.y*=t.y,this},Mi:function(t){return this.x/=t.x,this.y/=t.y,this},Fi:function(){return this.Ti(this.mag()),this},Ci:function(){var t=this.y;return this.y=this.x,this.x=-t,this},ki:function(t){var e=Math.cos(t),n=Math.sin(t),r=n*this.x+e*this.y;return this.x=e*this.x-n*this.y,this.y=r,this},Oi:function(t,e){var n=Math.cos(t),i=Math.sin(t),s=e.y+i*(this.x-e.x)+n*(this.y-e.y);return this.x=e.x+n*(this.x-e.x)-i*(this.y-e.y),this.y=s,this},Ei:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},vi$1.convert=function(t){return t instanceof vi$1?t:Array.isArray(t)?new vi$1(t[0],t[1]):t};const xi$1=[];function bi$1(t,e,n,i,r){return set$3(xi$1,e[0],e[1],e[2],1),transformMat4$1(xi$1,xi$1,n),t[2]=xi$1[3],scale$3(xi$1,xi$1,1/xi$1[3]),t[0]=(xi$1[0]+1)*i/2,t[1]=(1-xi$1[1])*r/2,t}const Ai$1=[],wi$1=[],_i$1=[],Si$1=[-99999,-99999],Mi$1=new t__namespace.Point(0,0),Pi$1=[];function Ti$1(t,e,n,r,s,o,a,l){const{res:h,extent:u,extent2d:c}=n.properties.tile,{xmin:f,ymax:d}=c,p=f+r.x*s,m=d-r.y*s;let y=null;if(l)for(let t=0;t<l.length;t++)if(ki$1(l[t],p,m,h)){y=l[t];break}if(!y)return Si$1;const g=Mi$1.set(f,d),v=o.queryTilePointTerrain(r,y,g,u,h),x=null===v[0]?xt$3:v[0];if(x){let n=set$4(Pi$1,r.x,r.y,0);return n[2]+=100*x,n=bi$1(t,n,a,e.width,e.height),n}return t[0]=r.x,t[1]=r.y,t}function ki$1(t,e,n,i){const r=Mi$1.set(e,n)._multi(i/t.res);return t.extent2d.contains(r)}const{loginIBLResOnCanvas:Oi$1,logoutIBLResOnCanvas:Ii$1,getIBLResOnCanvas:Fi$1}=fi$4.PBRUtils,Ci$1=[],Ei$1=[],Di$1=new t__namespace.Point(0,0),Ri$1=new t__namespace.Point(0,0),Li$1=new Float32Array(1),Ni$1=[],Hi$1=t=>0===t.properties.level,zi$1=t=>t.properties.level>0;class Vi$1{static getBloomSymbol(){return["bloom"]}constructor(t,e,i,r,s,o){this.Di=!0,this.regl=t,this.layer=e,this.canvas=t._gl.canvas,this.sceneConfig=r||{},this.dataConfig=o||{},this.pluginIndex=s,this.scene=new Ke$5,this.pickingFBO=e.getRenderer().pickingFBO,this.Ri=new ni$1,this.level0Filter=Hi$1,this.levelNFilter=zi$1,this.loginTextureCache(),this.symbolDef=Array.isArray(i)?i.map((t=>Ft$3(t))):[Ft$3(i)],this.Li(),this.pickingViewport={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1},this.sortByCommandKey=Ui$1.bind(this),this.colorCache={},this.Ni=this.symbolDef.map((t=>!(!t||!1!==t.visible)))}hasMesh(){const t=this.scene&&this.scene.getMeshes();return this.isVisible()&&t&&!!t.length}getMap(){return this.layer?this.layer.getMap():null}getTileLevelValue(t,e){const n=this.layer.getRenderer();return n.getTileLevelValue&&n.getTileLevelValue(t,e)||0}getAnalysisMeshes(){return this.getShadowMeshes?this.getShadowMeshes():Ni$1}isVisible(){const{minZoom:t,maxZoom:e}=this.sceneConfig,n=this.getMap().getZoom();if(!It$3(t)&&n<t)return!1;if(!It$3(e)&&n>e)return!1;const i=this.Hi;if(i.length)for(let t=0;t<i.length;t++)if(i[t]&&!i[t].isFeatureConstant)return!0;const r=this.getSymbols();for(let t=0;t<r.length;t++){const e=r[t].visible;if(!1!==e&&0!==e)return!0}return!1}isMeshVisible(t){const e=t&&t.properties&&t.properties.symbolIndex;if(!e)return!1;const n=this.Hi,i=e.index;let r;if(n[i]){if(!n[i].isFeatureConstant)return!0;r=n[i](this.getMap().getZoom())}else r=this.getSymbol(e).visible;return!1!==r&&0!==r}isAnimating(){return!1}needToRedraw(){return this.isAnimating()||this.zi}needToRetireFrames(){return this.J}needToRefreshTerrainTileOnZooming(){return!0}isTerrainSkin(){return this.layer.options.awareOfTerrain}isTerrainVector(){return!1}isShadowIncludeChanged(t){const e=t&&t.isRenderingTerrain&&this.isTerrainSkin();return t&&t.states&&t.states.includesChanged.shadow||e&&this.Vi}fillIncludes(t,e,n){if(delete this.Vi,n&&n.isRenderingTerrain&&this.isTerrainSkin())return;const i=n&&n.includes;if(i){let r="";for(const s in i)i[s]&&(r+=s,n[s].uniformDeclares&&e.push(...n[s].uniformDeclares),n[s].defines&&Tt$3(t,n[s].defines));this.Vi=r}}setIncludeUniformValues(t,e){if(e&&e.isRenderingTerrain&&this.isTerrainSkin())return;const n=e&&e.includes;if(n)for(const i in n)n[i]&&e[i].renderUniforms&&Tt$3(t,e[i].renderUniforms)}createGeometries(t,e){if(!t.length)return Ni$1;const n=[];for(let i=0;i<t.length;i++)if(t[i])if(void 0!==t[i].ref)n.push(n[t[i].ref]?{geometry:n[t[i].ref].geometry,symbolIndex:t[i].symbolIndex,ref:t[i].ref}:null);else{t[i]&&!t[i].is2D&&(this.Di=!1);const r=this.createGeometry(t[i],e,i);if(r&&r.geometry){const s=r.geometry.properties,{pickingIdMap:o,idPickingMap:a,hasFeaIds:l}=this.Ui(t[i]);l&&(s.feaIdPickingMap=o,s.feaPickingIdMap=a),s.symbolIndex=r.symbolIndex,s.features=e,s.is2D=t[i].is2D,s.layer=this.layer,s.positionBounding=t[i].positionBounding,this.postCreateGeometry(r,n)}n.push(r)}return n}isOnly2D(){return this.Di}postCreateGeometry(){}Ui(t){if(!t)return{};if(Array.isArray(t)&&!(t=t[0]))return{};const e=t.featureIds,n={},i={},r=e&&e.length;if(r)for(let r=0;r<e.length;r++){const s=t.data.aPickingId[r];void 0===n[s]&&(n[s]=e[r],i[e[r]]||(i[e[r]]=[]),i[e[r]].push(t.data.aPickingId[r]))}return{hasFeaIds:r,idPickingMap:n,pickingIdMap:i}}createGeometry(){throw new Error("not implemented")}createMeshes(t,e,n,i){const r=this.layer.options.awareOfTerrain,s=[];for(let o=0;o<t.length;o++){if(!t[o])continue;if(r&&i&&i.isRenderingTerrain&&this.isTerrainVector()){const e=t[o],n=e&&e.geometry;this.ji(n,n.data,n.properties,n.positionSize||n.desc.positionSize,i)}let a=this.createMesh(t[o],e,n,i||{});Array.isArray(a)?(a=a.filter((t=>!!t)),s.push(...a)):a&&s.push(a)}return s}createMesh(){throw new Error("not implemented")}getAltitudeOffsetMatrix(){const t=100*(this.dataConfig.altitudeOffset||0),e=identity$2([]);return set$4(Ei$1,0,0,t),translate$1(e,e,Ei$1),e}isBloom(t){return!!this.getSymbol(t.properties.symbolIndex).bloom}forbiddenTerrainUpscale(){return!0}addMesh(t,e,n){if(n.isRenderingTerrain&&this.isTerrainSkin()&&this.forbiddenTerrainUpscale()){const t=this.getMap().getResolution();if(n.tileInfo.res/t>3)return}const i=n.isRenderingTerrain&&this.isTerrainVector(),r=this.getRenderFBO(n);t=t.filter((t=>this.isMeshVisible(t))),i&&(t=t.filter((t=>t.geometry&&t.geometry.data.aTerrainAltitude)));const s=void 0===this.sceneConfig.castShadow||!!this.sceneConfig.castShadow,o=!(!n||!n.bloom);t.forEach((t=>{const e=this.isBloom(t)&&o;t.bloom=e,t.castShadow=s;let a=!1;const l=t.defines||{};if(!!l.HAS_BLOOM!==e&&(a=!0,e?l.HAS_BLOOM=1:delete l.HAS_BLOOM),i){if(t.geometry.data.aTerrainAltitude){const e=t.geometry;this.ji(e,e.data,e.properties,e.desc.positionSize,n)}t.geometry.data.aTerrainAltitude&&!l.HAS_TERRAIN_ALTITUDE&&(l.HAS_TERRAIN_ALTITUDE=1,a=!0)}else l.HAS_TERRAIN_ALTITUDE&&(delete l.HAS_TERRAIN_ALTITUDE,a=!0);a&&t.setDefines(l),r?t.setUniform("targetFramebuffer",r):t.uniforms.targetFramebuffer&&(t.uniforms.targetFramebuffer=null),this.Bi(t)})),this.scene.addMesh(t)}updateCollision(){}render(t){return this.pluginIndex=t.pluginIndex,this.polygonOffsetIndex=t.polygonOffsetIndex,this.paint(t),{redraw:this.zi,drawCount:this.Gi}}prepareRender(t){if(this.ft===t.timestamp)return;if(!this.createFnTypeConfig)return;const e=this.scene.getMeshes();if(!e||!e.length)return;const n=t&&t.sceneFilter,i=this.getMap().getZoom();for(let r=0;r<e.length;r++){if(!e[r]||!e[r].geometry)continue;if(n&&!n(e[r]))continue;const{symbolIndex:s}=e[r].properties,o=this.getSymbolDef(s);if(!o)continue;this.ft=t.timestamp;const a=this.getFnTypeConfig(s);hi$1(this.regl,o,a,e[r],i)}}paint(t){const e=this.layer.getMap();if(!e)return{redraw:!1};this.Wi=t;const n=this.getUniformValues(e,t);return this.callShader(n,t),{redraw:this.zi}}setToRedraw(t){t&&(this.J=t),this.zi=!0}callShader(t,e){this.callCurrentTileShader(t,e),this.callBackgroundTileShader(t,e)}callCurrentTileShader(t,e){this.shader&&(this.shader.filter=e&&e.sceneFilter?[this.level0Filter,e.sceneFilter]:this.level0Filter),this.callRenderer(this.shader,t,e)}callBackgroundTileShader(t,e){this.shader&&(this.shader.filter=e&&e.sceneFilter?[this.levelNFilter,e.sceneFilter]:this.levelNFilter),this.scene.getMeshes().sort(ji$1),this.callRenderer(this.shader,t,e)}callRenderer(t,e,n){const i=this.scene.getMeshes(),r=[];i.forEach((t=>{t.properties.hlBloomMesh&&n&&n.bloom&&r.push(t.properties.hlBloomMesh),r.push(t)})),this.Xi(e),this.scene.setMeshes(r),this.Gi+=this.renderer.render(t,e,this.scene,this.getRenderFBO(n)),this.scene.setMeshes(i)}Xi(t){const e=this.layer.options.altitude||0,n=this.layer.getRenderer();t.layerOpacity=n.ne(),t.minAltitude=e}getRenderFBO(t){return t&&t.renderTarget&&t.renderTarget.fbo}needPolygonOffset(){return!1}getPolygonOffset(){const t=this.layer;return{factor:()=>t.getPolygonOffset()+(this.polygonOffsetIndex||0),units:()=>t.getPolygonOffset()+(this.polygonOffsetIndex||0)}}getBlendFunc(){return{src:()=>this.sceneConfig.blendSrc||"one",dst:()=>this.sceneConfig.blendDst||"one minus src alpha"}}pick(t,e,n=3){if(!this.layer.options.picking||!1===this.sceneConfig.picking)return null;if(!this.pickingFBO||!this.picking)return null;const i=this.getMap(),r=this.getUniformValues(i);this.Xi(r);for(let s=0;s<this.picking.length;s++){const o=this.picking[s];o.render(this.scene.getMeshes(),r,!0);let a={};o.getRenderedMeshes().length&&(a=o.pick(t,e,n,r,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:this.layer.options.pickingPoint&&!1!==this.sceneConfig.pickingPoint,logDepthBufFC:2/(Math.log(i.cameraFar+1)/Math.LN2)}));const{meshId:l,pickingId:h,point:u}=a,c=(0===l||l)&&o.getMeshAt(l);if(!c||!c.geometry)continue;let f=c.geometry.properties;return f.features||(f=c.properties),u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5),{data:this.Yi(f&&f.features&&f.features[h]),point:u,coordinate:a.coordinate,plugin:this.pluginIndex}}return null}Yi(t){const e=t&&t.feature;if(!e||!e.customProps)return t;const n=Tt$3({},t);return n.feature=Tt$3({},t.feature),delete n.feature.customProps,n.feature.properties=Tt$3({},e.properties,e.properties[wt$3],e.properties[_t$3]),delete n.feature.properties[_t$3],delete n.feature.properties[wt$3],delete n.feature.properties.$layer,delete n.feature.properties.$type,n}updateSceneConfig(){}updateDataConfig(t){return Tt$3(this.dataConfig,t),!0}deleteMesh(t,e){if(t)if(this.scene.removeMesh(t),Array.isArray(t))for(let n=0;n<t.length;n++){if(!t[n].isValid())continue;const i=t[n].geometry;!e&&i&&i.dispose(),t[n].material&&t[n].material.dispose(),t[n].dispose(),Ws$3.deleteHighlightBloomMesh(t[n])}else{if(!t.isValid())return;!e&&t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),t.dispose(),Ws$3.deleteHighlightBloomMesh(t)}}startFrame(t){this.$i||(this.init(t),this.$i=!0),this.ft!==t.timestamp&&(this.zi=!1,this.J=!1,this.Gi=0),this.scene.clear()}resize(){}delete(){if(this.scene.clear(),this.shader&&this.shader.dispose(),this.picking){for(let t=0;t<this.picking.length;t++)this.picking[t].dispose();delete this.picking}if(this.qi){for(let t=0;t<this.qi.length;t++)this.qi[t].dispose();delete this.qi}delete this.Ji,this.logoutTextureCache()}updateSymbol(t,e){Array.isArray(t)||(t=[t],e=[e]);let n=!1;for(let i=0;i<t.length;i++)if(t[i]){const r=this.Ki(i,t[i],e[i]);r&&(n=r)}return delete this.Zi,this.setToRedraw(!1),n}Qi(t,e){for(const n in e)if(Vt$2(e,n)){if(nt$4.isFnTypeSymbol(e[n])&&!this.layer.options.features&&(!t[n]||t[n].property!==e[n].property))return!0;if(Da[n]&&!fastDeepEqual(e[n],t[n]))return!0}return!1}Ki(t,e,n){if(!this.tr)return!1;const i=this.Qi(this.symbolDef[t]||{},n);if(this.Ni[t]&&!1!==n.visible)return this.Ni[t]=!1,!0;this.symbolDef[t]=Ft$3(n);const r=this.tr[t];for(const t in r)delete r[t];const s=this.getMap(),o=[],a=Ta$1.loadSymbolFnTypes(this.symbolDef[t],(()=>(o[0]=s.getZoom(),o)));for(const t in a){const e=Object.getOwnPropertyDescriptor(a,t);e.get?Object.defineProperty(r,t,{get:e.get,set:e.set,configurable:!0,enumerable:!0}):r[t]=a[t]}return isFunctionDefinition(n.visible)&&(this.Hi[t]=interpolated(n.visible)),i}getSymbolDef(t){return this.symbolDef[t.index]}getSymbols(){return this.tr}getSymbol(t){return this.tr[t.index]}Li(){const t=this.getMap(),e=[],n=()=>(e[0]=t.getZoom(),e);this.tr=[],this.Hi=[];for(let t=0;t<this.symbolDef.length;t++)this.tr[t]=Ta$1.loadSymbolFnTypes(Tt$3({},this.symbolDef[t]),n),this.symbolDef[t]&&isFunctionDefinition(this.symbolDef[t].visible)&&(this.Hi[t]=interpolated(this.symbolDef[t].visible))}getFnTypeConfig(t){this.Zi||(this.Zi=[]);const e=t.index;if(!this.Zi[e]){const n=this.getSymbolDef(t),i=this.getMap();this.Zi[e]=this.createFnTypeConfig(i,n)}return this.Zi[e]}er(){delete this.Zi}loginTextureCache(){const t="__gl_textures".trim(),e=this.getMap();e[t]||(e[t]={count:0}),e[t].count++}logoutTextureCache(){const t="__gl_textures".trim(),e=this.getMap(),n=this.nr;if(n)for(const i in n)Vt$2(n,i)&&e[t][i]&&(e[t][i].count--,e[t][i].count<=0&&delete e[t][i]);e[t].count--,e[t].count<=0&&(e[t]={})}getCachedTexture(t){const e="__gl_textures".trim(),n=this.getMap()[e][t];return n?n.data:null}addCachedTexture(t,e){const n="__gl_textures".trim(),i=this.getMap();let r=i[n][t];r?r.data=e:r=i[n][t]={data:e,count:0},this.nr||(this.nr={}),r.data.then||this.nr[t]||(r.count++,this.nr[t]=1)}disposeCachedTexture(t){let e;if(e="string"==typeof t?t:t.url,!this.nr||!this.nr[e])return;const n="__gl_textures".trim();delete this.nr[e];const i=this.getMap();i[n][e]&&(i[n][e].count--,i[n][e].count<=0&&delete i[n][e])}shouldDeleteMeshOnUpdateSymbol(){return!1}needClearStencil(){return!1}supportRenderMode(t){return"taa"===t||"fxaa"===t}ir(t){const e=this.scene.getMeshes();if(!e.length)return;const n=e.map((t=>({transform:t.localTransform,level:t.properties.level,mesh:t}))).sort(this.rr),i=this.getMap().projViewMatrix;this.Ri.start(t);const s={};for(let e=0;e<n.length;e++){const o=n[e].mesh;let a=s[o.properties.tile.id];void 0===a&&(multiply$5(Ci$1,i,n[e].transform),a=this.Ri.write(t,Ci$1),s[o.properties.tile.id]=a),o.setUniform("ref",a)}this.Ri.end(t),this.regl.sr()}rr(t,e){return e.level-t.level}outline(t,e){const n={};for(let i=0;i<e.length;i++)It$3(e[i])||n[e[i]]||(this.or(t,e[i]),n[e[i]]=1)}or(t,e){if(!this.picking)return;if(this.ar||(this.ar=new Ke$5),!this.qi&&(this.lr(),!this.qi))return void console.warn(`Plugin at ${this.pluginIndex} doesn't support outline.`);const i=this.getUniformValues(this.getMap(),this.Wi);this.Xi(i);const r=this.hr(e);if(r.length)for(let n=0;n<r.length;n++){const s=r[n].geometry.properties.feaIdPickingMap;if(s){const o=s[e];if(o){const e={};this.ar.setMeshes(r[n]);for(let n=0;n<o.length;n++){const r=o[n];if(!e[r]){e[r]=1,i.highlightPickingId=r;for(let e=0;e<this.qi.length;e++)this.renderer.render(this.qi[e],i,this.ar,t)}}}}}}hr(t){const e=[],n=this.scene.getMeshes();for(let i=0;i<n.length;i++){const r=n[i],s=r.geometry.properties.feaIdPickingMap;s&&void 0!==s[t]&&e.push(r)}return e}outlineAll(t){if(!this.picking)return;if(!this.qi&&(this.lr(),!this.qi))return void console.warn(`Plugin at ${this.pluginIndex} doesn't support outline.`);const e=this.getUniformValues(this.getMap(),this.Wi);this.Xi(e),e.highlightPickingId=-1;for(let n=0;n<this.qi.length;n++)this.renderer.render(this.qi[n],e,this.scene,t)}lr(){if(!this.picking)return;const t=this.layer.getRenderer().canvas;this.qi=[];for(let e=0;e<this.picking.length;e++){const i=this.picking[e].getPickingVert(),r={ENABLE_PICKING:1,HAS_PICKING_ID:1},s=this.picking[e].getUniformDeclares().slice(0);void 0!==s.uPickingId&&(r.HAS_PICKING_ID=2),this.qi[e]=new vn$4({vert:i,frag:"precision highp float;\nuniform float highlightPickingId;\nvarying float vPickingId;\nvoid main() {\n  if(highlightPickingId < .0 || floor(highlightPickingId + .5) == floor(vPickingId + .5)) {\n    gl_FragColor = vec4(1.);\n  } else {\n    discard;\n  }\n}",uniforms:s,defines:r,extraCommandProps:{viewport:{x:0,y:0,width:()=>t.width,height:()=>t.height},depth:{enable:!0,mask:!1,func:"always"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}}),this.qi[e].filter=this.picking[e].filter}}hasIBL(){const t=this.getMap().getLightManager();return!(!t||!t.getAmbientResource())}updateIBLDefines(t){const e=t.shaderDefines;let n=!1;this.hasIBL()?e[["HAS_IBL_LIGHTING"]]||(e.HAS_IBL_LIGHTING=1,n=!0):e[["HAS_IBL_LIGHTING"]]&&(delete e.HAS_IBL_LIGHTING,n=!0),n&&(t.shaderDefines=e)}getIBLRes(){const t=this.layer.getRenderer().canvas;return Fi$1(t)}createIBLTextures(){const t=this.layer.getRenderer().canvas;Oi$1(t,this.regl,this.getMap()),this.setToRedraw(!0),this.layer.fire("iblupdated")}disposeIBLTextures(){const t=this.layer.getRenderer().canvas;Ii$1(t,this.getMap())}evaluateInFnTypeConfig(t,e,n,i,r){let s=this.ur;s||(s=this.ur={});const o=function(t){let e=0;const n=t&&t.length||0;if(!n)return e;let i;for(let r=0;r<n;r++)i=t.charCodeAt(r),e=(e<<5)-e+i,e&=e;return e}(JSON.stringify(t));let a=s[o];return a||(a=s[o]=r?piecewiseConstant(t):interpolated(t)),a(n.getZoom(),i)}highlight(t){this.te=t,this.cr=this.layer.getRenderer().getFrameTimestamp(),this.setToRedraw(!0)}cancelAllHighlight(){this.te=null,this.cr=this.layer.getRenderer().getFrameTimestamp(),this.setToRedraw(!0)}dr(t,e){const{featureIds:n,pickingIdIndiceMap:i}=e;t.properties.aFeaIds=n,t.properties.pickingIdIndiceMap=i}Bi(t){if(t&&t.properties.isHalo)return;const{pickingIdIndiceMap:e}=t.geometry.properties,n=this.te?function(t,e,n){const{aPickingId:i,feaIdPickingMap:r,features:s}=t.geometry.properties,o=new Map,a=n.keys();for(const t of a){const a=n.get(t);if(a)if(It$3(a.id)){if(a.filter&&i){let t=null;for(let n=0;n<i.length;n++){i[n]!==t&&(t=i[n]);const r=s[t];a.filter(r&&r.feature,e)&&o.set(t,a)}}}else{const t=r[a.id];if(!t||!t.length)continue;for(let e=0;e<t.length;e++)o.set(t[e],a)}}return o}(t,this.layer,this.te):null;Ws$3.highlightMesh(this.regl,t,n,this.cr,e)}ji(t,e,n,i,r){let s=n.aAnchor;if(!s){const{aPosition:t}=e;s=n.aAnchor=t.slice(0)}let o=n.aTerrainAltitude;o||(o=n.aTerrainAltitude=new Float32Array(s.length/i),o.fill(xt$3)),this.pr(o,s,r.tileInfo,0,o.length-1),e.aTerrainAltitude?o.dirty&&this.mr(t,o):e.aTerrainAltitude=o,o.dirty=!1}mr(t,e){t&&t.updateData&&t.updateData("aTerrainAltitude",e)}pr(e,n,i,r,s){const{res:o,extent:a,extent2d:l,id:h}=i,u=this.pluginIndex,c=h+"-"+u;if(i.completeTerrainQuery||(i.completeTerrainQuery=[]),i.completeTerrainQuery[u])return;if(!i.completeTerrainQuery[u]&&this.Ji&&this.Ji.has(c)){const t=this.Ji.getAndRemove(c);return this.Ji.add(c,t),e.set(t.altitudeData),i.terrainTileInfos=t.terrainTileInfos,e.dirty=!0,void(i.completeTerrainQuery[u]=!0)}const f=this.layer,d=f.getMap(),p=f.getRenderer(),m=p&&p.getTerrainHelper();let y=i.terrainTileInfos;y||(y=i.terrainTileInfos=this.layer.queryTerrainTiles(i)),i.terrainQueryStatus||(i.terrainQueryStatus=[]);let g=!1,v=[];for(let t=0;t<i.terrainTileInfos.length;t++)if(v[t]=+m.isTerrainTileLoaded(i.terrainTileInfos[t].id),v[t]&&i.terrainQueryStatus[u]&&!i.terrainQueryStatus[u][t]){g=!0;break}if(!g&&i.terrainQueryStatus[u])return;const x=f.constructor;if(d.isInteracting()){const t=p.getFrameTimestamp();x.altitudeQueryFrameTimestamp!==t&&(x.altitudeQueryFrameTimestamp=t,x.altitudeQueryFrameTime=0);if(x.altitudeQueryFrameTime>f.options.altitudeQueryTimeLimitPerFrame)return}const b=performance.now();i.terrainQueryStatus[u]=v;const{xmin:A,ymax:w}=l,_=Di$1.set(A,w),S=this.layer.getTileSize().width/i.extent,M=n.length/e.length;let P=e.queryResult;P||(P=e.queryResult=new Map);let T=!0;for(let t=r;t<=s;t++){let i=n[t*M];i<0?i=0:i>a&&(i=a);let r=n[t*M+1];r<0?r=0:r>a&&(r=a);const s=i+r*a;let l,h,u=P.get(s);if(u||0===u)e[t]!==u&&(e[t]=u,e.dirty=!0);else{for(let t=0;t<y.length;t++)if(ki$1(y[t],A+S*i,w-S*r,o)){l=y[t];break}l&&(m.getRenderer().isTileCached(l.id)||e[t]===xt$3)&&(Ri$1.set(i,r),h=this.layer.queryTilePointTerrain(Ri$1,l,_,a,o)),u=e[t],h&&(u=null===h[0]?xt$3:h[0],Li$1[0]=u,u=Li$1[0]),e[t]!==u&&(e[t]=u,e.dirty=!0),h&&h[1]?P.set(s,u):T=!1}}x.altitudeQueryFrameTime=(x.altitudeQueryFrameTime||0)+(performance.now()-b),i.completeTerrainQuery[u]=T,T&&(this.Ji||(this.Ji=new t__namespace.LRUCache(4*this.layer.options.maxCacheSize)),this.Ji.add(c,{altitudeData:e,terrainTileInfos:y}))}}function Ui$1(t,e){const n=t&&t.getCommandKey(this.regl)||"",i=e&&e.getCommandKey(this.regl)||"";return n.localeCompare(i)}function ji$1(t,e){return t.properties.level-e.properties.level}class Bi$1 extends Vi$1{createGeometry(t,e){if(!t.data)return{geometry:null,symbolIndex:t.symbolIndex};t.iconAtlas&&t.iconAtlas.image&&(t.iconAtlas.image.dataType=t.type,t.iconAtlas.image.type="icon"),t.glyphAtlas&&t.glyphAtlas.image&&(t.glyphAtlas.image.type="glyph");const i=Tt$3({},t.data),r={primitive:this.getPrimitive(),positionSize:t.positionSize};i.aAltitude&&(r.altitudeAttribute="aAltitude");const s=new Q$7(i,t.indices,0,r);return s.properties={features:e},t.iconAtlas&&(s.properties.iconAtlas=t.iconAtlas.image,s.properties.iconPositions=t.iconAtlas.positions),t.glyphAtlas&&(s.properties.glyphAtlas=t.glyphAtlas.image),ii$1(e)||(s.properties.aFeaIds=t.featureIds,this.dr(s,t)),t.markerPlacement&&(s.properties.markerPlacement=t.markerPlacement),t.textPlacement&&(s.properties.textPlacement=t.textPlacement),Tt$3(s.properties,t.properties),{geometry:s,symbolIndex:t.symbolIndex}}getRayCastData(t,e){const{features:n,aFeaIds:i}=t.geometry.properties;return n&&i?n[i[e]]:null}getPrimitive(){return"triangles"}getRenderFBO(t){return t&&t.renderTarget&&t.renderTarget.fbo}supportRenderMode(t){return"noAa"===t}drawDebugAtlas(t){if(document.getElementById("MAPTALKS_ICON_DEBUG")){const e=document.getElementById("MAPTALKS_ICON_DEBUG");let n;if(e.width=t.width,e.height=t.height,e.style.width=t.width+"px",e.style.height=t.height+"px","alpha"===t.format){n=new Uint8ClampedArray(4*t.data.length);for(let e=0;e<t.data.length;e++)n[4*e+3]=t.data[e]}else n=new Uint8ClampedArray(t.data);const i=e.getContext("2d");i.imageSmoothingEnabled=!1,i.putImageData(new ImageData(n,t.width,t.height),0,0)}}}var Gi$1="#include <gl2_vert>\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nuniform mat4 projViewModelMatrix;\n#include <fbo_picking_vert>\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n  gl_Position = projViewModelMatrix * vec4(c, 1.);\n  fbo_picking_setData(gl_Position.w, true);\n}";function Wi$1(t,e,i,r){if(r){const t=N$6.resizeToPowerOfTwo(e.data,e.width,e.height);e.data=t}const o={width:e.width,height:e.height,data:e.data,format:e.format,mag:"linear",min:r?"linear mipmap linear":"linear",flipY:i,premultiplyAlpha:!0};if("icon"===e.type){const t="point"!==e.dataType?"repeat":"clamp";o.wrapS=t,o.wrapT=t}return t.texture(o)}const Xi$1=[0,0],Yi$1=[];function $i$1(t){if(!t.properties.iconPositions)return Xi$1;let e,n=0;for(const i in t.properties.iconPositions)if(e=i,n++,n>1)return Xi$1;if(!e)return Xi$1;const i=t.properties.iconPositions[e],s=i.displaySize[1];return Yi$1[0]=i.displaySize[0],Yi$1[1]=s,Yi$1}const qi$1=identity$2([]),Ji$1={polygonFill:[1,1,1,1],polygonOpacity:1,uvScale:[1,1],uvOffset:[0,0],patternWidth:[0,0],patternOffset:[0,0]},Ki$1=[],Zi$1=new t__namespace.Coordinate(0,0),Qi$1=new t__namespace.Coordinate(0,0),tr$2=new t__namespace.Coordinate(0,0),er$2=[];class nr$2 extends Bi$1{static getBloomSymbol(){return["polygonBloom"]}prepareSymbol(t){const e=t.polygonFill;Array.isArray(e)&&(3===e.length&&e.push(1),t.polygonFill=e.map((t=>255*t)))}supportRenderMode(t){return this.sceneConfig.antialias||void 0===this.sceneConfig.antialias?"fxaa"===t||"fxaaBeforeTaa"===t:super.supportRenderMode(t)}isBloom(t){return!!this.getSymbol(t.properties.symbolIndex)[nr$2.getBloomSymbol()[0]]}forbiddenTerrainUpscale(){return!0}needPolygonOffset(){return!0}getAnalysisMeshes(){return this.isVisible()?this.scene.getMeshes().filter((t=>0===t.properties.level)):Ki$1}createMesh(e,i,r){const s=this.getMap(),{tilePoint:o}=r,{geometry:a,symbolIndex:l,ref:u}=e,c=this.layer instanceof t__namespace.TileLayer,f=this.layer.getTileSize().width,d=a.properties.tileExtent/f,m=a.properties.tileResolution,y=s.pointAtResToCoord(Zi$1.set(o[0],o[1]),m),g={tileExtent:a.properties.tileExtent,tileRatio:d},v=this.getSymbol(l),x=this.getSymbolDef(l);if(isFunctionDefinition(x.polygonPatternFileOrigin)&&this.yr(x,e,c?[0,0]:o,m),(isFunctionDefinition(x.polygonPatternFileWidth)||isFunctionDefinition(x.polygonPatternFileWidth))&&this.gr(x,e,c?d:1,y,m),x.uvOffsetInMeter&&isFunctionDefinition(x.uvOffset)&&this.vr(x,e,y,m),Ct$3(g,"polygonFill",v,"polygonFill",Ji$1.polygonFill,Rt$3(this.colorCache)),Ct$3(g,"polygonOpacity",v,"polygonOpacity",Ji$1.polygonOpacity),Ct$3(g,"uvScale",v,"uvScale",Ji$1.uvScale),void 0===u){const t=this.getFnTypeConfig(l);si$1(a,x,t),a.generateBuffers(this.regl)}const b=a.properties.iconAtlas;if(b&&a.data.aTexInfo){const t=[];Object.defineProperty(g,"uvOrigin",{enumerable:!0,get:()=>{if(a.data.aPatternOrigin)return o;const e=v.polygonPatternFileOrigin;return e?(Zi$1.set(e[0],e[1]),s.coordToPointAtRes(Zi$1,m,Qi$1),set(t,o[0]-Qi$1.x,o[1]-Qi$1.y)):o}});const e=[];Object.defineProperty(g,"patternWidth",{enumerable:!0,get:()=>{if(a.data.aPatternWidth)return Ji$1.patternWidth;const t=x.polygonPatternFileWidth,n=x.polygonPatternFileHeight;if(!t&&!n)return Ji$1.patternWidth;const[i,r]=this.xr(er$2,t,n,c?d:1,y,m);return set(e,i,r)}}),Object.defineProperty(g,"uvOffset",{enumerable:!0,get:()=>a.data.aPatternOffset||x.uvOffsetInMeter?Ji$1.uvOffset:v.uvOffset||Ji$1.uvOffset});const n=[];Object.defineProperty(g,"patternOffset",{enumerable:!0,get:()=>{if(a.data.aPatternOffset)return Ji$1.uvOffset;if(!x.uvOffsetInMeter)return Ji$1.uvOffset;const t=x.uvOffset;if(!t)return Ji$1.uvOffset;const e=Bt$3(s,t[0],y,m),i=Bt$3(s,t[1],y,m);return set(n,e,i)}}),Object.defineProperty(g,"tileScale",{enumerable:!0,get:function(){return x.polygonPatternFileWidth||x.polygonPatternFileHeight?1:a.properties.tileResolution/s.getResolution()}}),g.polygonPatternFile=Wi$1(this.regl,b,!1,!1),g.atlasSize=[b.width,b.height],this.drawDebugAtlas(b)}const A=new Ce$5(g,Ji$1),w=new Be$5(a,A,{castShadow:!1,picking:!0}),_={};return b&&a.data.aTexInfo&&(_.HAS_PATTERN=1),b&&a.data.aTexCoord&&(_.HAS_TEX_COORD=1,_.INVALID_TEX_COORD="-9999999.0"),a.data.aAltitude&&(_.HAS_ALTITUDE=1),a.data.aColor&&(_.HAS_COLOR=1),a.data.aOpacity&&(_.HAS_OPACITY=1),a.data.aUVScale&&(_.HAS_UV_SCALE=1),a.data.aUVOffset&&(_.HAS_UV_OFFSET=1),a.data.aPatternOrigin&&(_.HAS_PATTERN_ORIGIN=1),a.data.aPatternWidth&&(_.HAS_PATTERN_WIDTH=1),a.data.aPatternOffset&&(_.HAS_PATTERN_OFFSET=1),c&&(_.IS_VT=1),w.setDefines(_),w.setLocalTransform(i),w.properties.symbolIndex=l,w}gr(t,e,n,i,r){if(!(e=e&&e.geometry))return;const s=e.properties.features;if(ii$1(s))return;const o=t.polygonPatternFileWidth,a=t.polygonPatternFileHeight,l=interpolated(t.polygonPatternFileOrigin);let h,u;isFunctionDefinition(o)&&(h=interpolated(o)),isFunctionDefinition(a)&&(u=interpolated(a));const{aPickingId:c,aPatternOrigin:f}=e.data,m=new Float32Array(2*c.length);let y,v,x;for(let t=0,e=c.length;t<e;t++){let e,d;if(c[t]===y){m[2*t]=v,m[2*t+1]=x;continue}const p=s[c[t]];if(e=h?h(null,p.feature.properties):o,d=u?u(null,p.feature.properties):a,y=c[t],e||d){let s=i;if(f){const t=l(null,p.feature.properties);t&&(s=tr$2.set(t[0],t[1]))}const[o,a]=this.xr(er$2,e,d,n,s,r);v=m[2*t]=o,x=m[2*t+1]=a}else v=m[2*t]=0,x=m[2*t+1]=0}e.data.aPatternWidth=m}vr(t,e,n,i){if(!(e=e&&e.geometry))return;const r=e.properties.features;if(ii$1(r))return;const s=this.getMap();let o=isFunctionDefinition(t.uvOffsetInMeter)&&piecewiseConstant(t.uvOffsetInMeter);const a=interpolated(t.uvOffset),l=interpolated(t.polygonPatternFileOrigin),{aPickingId:h,aPatternOrigin:u}=e.data,f=new Float32Array(2*h.length);let d,m,v;for(let t=0,e=h.length;t<e;t++){if(h[t]===d){f[2*t]=m,f[2*t+1]=v;continue}const e=r[h[t]],c=a(null,e.feature.properties);let p=!0;if(o&&(p=o(null,e.feature.properties)),d=h[t],c&&p){let r=n;if(u){const t=l(null,e.feature.properties);t&&(r=tr$2.set(t[0],t[1]))}const o=Bt$3(s,c[0],r,i),a=Bt$3(s,c[0],r,i);m=f[2*t]=o,v=f[2*t+1]=a}else m=f[2*t]=0,v=f[2*t+1]=0}e.data.aPatternOffset=f}yr(t,e,n,i){if(!(e=e&&e.geometry))return;const r=e.properties.features;if(ii$1(r))return;const s=this.getMap(),o=interpolated(t.polygonPatternFileOrigin),a=e.data.aPickingId,h=new Float32Array(2*a.length);let u,c,f;for(let t=0,e=a.length;t<e;t++){if(a[t]===u){h[2*t]=c,h[2*t+1]=f;continue}u=a[t];const e=o(null,r[u].feature.properties);e?(Zi$1.set(e[0],e[1]),s.coordToPointAtRes(Zi$1,i,Qi$1),c=h[2*t]=Qi$1.x,f=h[2*t+1]=Qi$1.y):(c=h[2*t]=n[0],f=h[2*t+1]=n[1])}e.data.aPatternOrigin=h}createFnTypeConfig(t,e){const n=piecewiseConstant(e.polygonFill),i=interpolated(e.polygonOpacity),r=interpolated(e.uvScale),s=interpolated(e.uvOffset),o=new Uint8Array(1),a=new Uint16Array(2),l=new Uint8Array(2);return[{attrName:"aColor",symbolName:"polygonFill",type:Uint8Array,width:4,define:"HAS_COLOR",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=this.colorCache[r]=this.colorCache[r]||color(r).unitArray()),r=Dt$3(r),r}},{attrName:"aOpacity",symbolName:"polygonOpacity",type:Uint8Array,width:1,define:"HAS_OPACITY",evaluate:(e,n)=>{let r=i(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,n,t,e)),o[0]=255*r,o[0]}},{attrName:"aUVScale",symbolName:"uvScale",type:Uint16Array,width:2,define:"HAS_UV_SCALE",evaluate:e=>{const n=r(t.getZoom(),e);return a[0]=255*n[0],a[1]=255*n[1],a}},{attrName:"aUVOffset",symbolName:"uvOffset",type:Uint8Array,width:2,define:"HAS_UV_OFFSET",evaluate:e=>{const n=s(t.getZoom(),e);return l[0]=255*n[0],l[1]=255*n[1],l}}]}paint(t){this.isShadowIncludeChanged(t)&&(this.shader.dispose(),this.br(t)),super.paint(t)}isEnableStencil(t){const e=this.layer.getRenderer();return!(t&&t.isRenderingTerrain&&this.isTerrainSkin()||!e.isEnableTileStencil||!e.isEnableTileStencil())&&"VectorTileLayer"===this.layer.getJSONType()}init(t){const i=this.canvas,s={x:(t,e)=>e.viewport?e.viewport.x:0,y:(t,e)=>e.viewport?e.viewport.y:0,width:(t,e)=>e.viewport?e.viewport.width:i?i.width:1,height:(t,e)=>e.viewport?e.viewport.height:i?i.height:1};this.renderer=new B$6(this.regl);const o=this.layer.getRenderer(),a={viewport:s,stencil:{enable:()=>this.isEnableStencil(t),func:{cmp:()=>o.isEnableTileStencil&&o.isEnableTileStencil()?"=":"<=",ref:(t,e)=>o.isEnableTileStencil&&o.isEnableTileStencil()?e.stencilRef:e.level},op:{fail:"keep",zfail:"keep",zpass:()=>o.isEnableTileStencil&&o.isEnableTileStencil()?"zero":"replace"}},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],mask:(t,e)=>{if(!It$3(this.sceneConfig.depthMask))return!!this.sceneConfig.depthMask;if(e.hasSSRGround)return!0;if(e.meshConfig.transparent)return!1;const n=e.polygonOpacity;return!(Ht$2(n)&&n<1)},func:this.sceneConfig.depthFunc||"<="},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}};if(this.br(t,a),this.pickingFBO){const t=[];this.picking=[new Cr$4(this.renderer,{vert:Gi$1,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(e,n){return multiply$5(t,n.projViewMatrix,n.modelMatrix),t}}],extraCommandProps:a},this.pickingFBO,this.getMap())]}}br(t,e){const i=[],s=[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5(i,e.projViewMatrix,e.modelMatrix),i}}],o={};this.fillIncludes(o,s,t),this.shader=new vn$4({vert:"#define SHADER_NAME FILL\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\n#ifdef HAS_COLOR\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#ifdef HAS_OPACITY\nattribute float aOpacity;\nvarying float vOpacity;\n#endif\nuniform mat4 projViewModelMatrix;\n#ifndef IS_VT\nuniform mat4 modelMatrix;\n#endif\n#ifdef HAS_PATTERN\n#ifdef HAS_TEX_COORD\nattribute vec2 aTexCoord;\n#endif\nattribute vec4 aTexInfo;\nuniform vec2 patternWidth;\nuniform vec2 patternOffset;\nuniform vec2 uvOrigin;\nuniform vec2 uvScale;\n#ifdef IS_VT\nuniform float tileRatio;\nuniform float tileScale;\n#else\nuniform float glScale;\n#endif\n#ifdef HAS_UV_SCALE\nattribute vec2 aUVScale;\nvarying vec2 vUVScale;\n#endif\n#ifdef HAS_UV_OFFSET\nattribute vec2 aUVOffset;\nvarying vec2 vUVOffset;\n#endif\n#ifdef HAS_PATTERN_WIDTH\nattribute vec2 aPatternWidth;\n#endif\n#ifdef HAS_PATTERN_ORIGIN\nattribute vec2 aPatternOrigin;\n#endif\n#ifdef HAS_PATTERN_OFFSET\nattribute vec2 aPatternOffset;\n#endif\nvarying vec2 vTexCoord;\nvarying vec4 vTexInfo;\nvec2 c(vec2 d, vec2 e) {\n  \n#ifdef IS_VT\nfloat f = d.x / e.x;\n  float h = d.y / e.y;\n  return vec2(f, h);\n#else\nfloat i = glScale;\n#ifdef HAS_PATTERN_WIDTH\nfloat j = sign(length(aPatternWidth));\n  i = mix(glScale, 1., j);\n#endif\nvec2 k = uvOrigin;\n#ifdef HAS_PATTERN_ORIGIN\nk = aPatternOrigin;\n#endif\n#ifdef HAS_PATTERN_OFFSET\nvec2 l = aPatternOffset;\n#else\nvec2 l = patternOffset;\n#endif\nk += l;\n  float f = (d.x - k.x) * i / e.x;\n  float h = (d.y - k.y) * i / e.y;\n  return vec2(f, -h);\n#endif\n}\nvec2 m(vec4 n, vec2 o) {\n  \n#ifdef IS_VT\n#ifdef HAS_PATTERN_OFFSET\nvec2 l = aPatternOffset;\n#else\nvec2 l = patternOffset;\n#endif\nvec2 k = uvOrigin + l;\n#ifdef HAS_PATTERN_ORIGIN\nk = k - aPatternOrigin;\n#endif\nfloat j = sign(length(patternWidth));\n  vec2 A = mix(o, patternWidth, j);\n#ifdef HAS_PATTERN_WIDTH\nA = aPatternWidth;\n#endif\n#ifdef HAS_UV_SCALE\nvec2 B = aUVScale / 255.;\n#else\nvec2 B = uvScale;\n#endif\nvec2 C = k * tileScale * B * vec2(1., -1.) / A;\n  return C / B + c(n.xy * tileScale / tileRatio, A);\n#else\nvec2 A = o;\n#ifdef HAS_PATTERN_WIDTH\nfloat j = sign(length(aPatternWidth));\n  A = mix(o, aPatternWidth, j);\n#endif\nvec4 D = modelMatrix * n;\n  return c(D.xy, A);\n#endif\n}\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#include <vt_position_vert>\n#include <highlight_vert>\nvoid main() {\n  vec3 E = unpackVTPosition();\n  vec4 n = vec4(E, 1.);\n  gl_Position = projViewModelMatrix * n;\n#ifdef HAS_PATTERN\nvec2 o = aTexInfo.zw + 1.;\n  vTexInfo = vec4(aTexInfo.xy, o);\n#ifdef HAS_TEX_COORD\nif(aTexCoord.x == INVALID_TEX_COORD) {\n    vTexCoord = m(n, o);\n  } else {\n    vTexCoord = aTexCoord;\n  }\n#else\nvTexCoord = m(n, o);\n#endif\n#ifdef HAS_UV_SCALE\nvUVScale = aUVScale / 255.;\n#endif\n#ifdef HAS_UV_OFFSET\nvUVOffset = aUVOffset / 255.;\n#endif\n#endif\n#ifdef HAS_COLOR\nvColor = aColor / 255.;\n#endif\nhighlight_setVarying();\n#ifdef HAS_OPACITY\nvOpacity = aOpacity / 255.;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(n);\n#endif\n}",frag:"#define SHADER_NAME FILL\nprecision mediump float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#ifdef HAS_PATTERN\n#ifdef HAS_UV_SCALE\nvarying vec2 vUVScale;\n#else\nuniform highp vec2 uvScale;\n#endif\n#ifdef HAS_UV_OFFSET\nvarying vec2 vUVOffset;\n#else\nuniform vec2 uvOffset;\n#endif\n#endif\n#ifdef HAS_PATTERN\nuniform sampler2D polygonPatternFile;\nuniform vec2 atlasSize;\nvarying vec2 vTexCoord;\nvarying vec4 vTexInfo;\nvec2 c() {\n  \n#ifdef HAS_UV_SCALE\nvec2 d = vUVScale;\n#else\nvec2 d = uvScale;\n#endif\n#ifdef HAS_UV_OFFSET\nvec2 e = vUVOffset;\n#else\nvec2 e = uvOffset;\n#endif\nvec2 f = mod(vTexCoord * d + e, 1.);\n  vec2 h = vTexInfo.xy;\n  vec2 i = vTexInfo.zw;\n  return (h + f * i) / atlasSize;\n}\n#endif\n#ifdef HAS_COLOR\nvarying vec4 vColor;\n#else\nuniform vec4 polygonFill;\n#endif\n#include <highlight_frag>\n#ifdef HAS_OPACITY\nvarying float vOpacity;\n#else\nuniform lowp float polygonOpacity;\n#endif\nuniform float layerOpacity;\nuniform float tileExtent;\nvoid main() {\n  \n#ifdef HAS_COLOR\nvec4 j = vColor;\n#else\nvec4 j = polygonFill;\n#endif\n#ifdef HAS_PATTERN\nif(vTexInfo.z * vTexInfo.w > 1.) {\n    vec2 f = c();\n    j = texture2D(polygonPatternFile, f);\n  }\n#endif\n#ifdef HAS_OPACITY\ngl_FragColor = j * vOpacity;\n#else\ngl_FragColor = j * polygonOpacity;\n#endif\ngl_FragColor *= layerOpacity;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat k = shadow_computeShadow();\n  gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, k);\n#endif\ngl_FragColor = highlight_blendColor(gl_FragColor);\n}",uniforms:s,defines:o,extraCommandProps:e})}getUniformValues(t,e){const n=e&&e.isRenderingTerrainSkin,i={projViewMatrix:n?qi$1:t.projViewMatrix,glScale:e&&e.isRenderingTerrainSkin?1:1/t.getGLScale(),viewport:n&&e&&e.viewport,hasSSRGround:e&&e.hasSSRGround};return this.setIncludeUniformValues(i,e),i}xr(t,e,n,i,r,s){let o,a;const l=this.getMap();return e&&(o=Bt$3(l,e,r,s)),n&&(a=Bt$3(l,n,r,s,1)),o=o||a,a=a||o,t[0]=o,t[1]=a,t}}var ir$2="#define SHADER_NAME LINE\n#define AA_CLIP_LIMIT 2.0\n#define AA_LINE_WIDTH 16.0\n#define DEVICE_PIXEL_RATIO 1.0\n#define ANTIALIASING 1.0 / DEVICE_PIXEL_RATIO / 2.0\n#define EXTRUDE_SCALE 63.0\n#define EXTRUDE_MOD 64.0\n#define MAX_LINE_DISTANCE 65535.0\n#ifdef PICKING_MODE\n#include <gl2_vert>\n#endif\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\n#if defined(HAS_PATTERN) || defined(HAS_DASHARRAY)\nattribute vec3 aExtrude;\n#else\nattribute vec2 aExtrude;\n#endif\n#if defined(HAS_PATTERN) || defined(HAS_DASHARRAY) || defined(HAS_GRADIENT) || defined(HAS_TRAIL)\nattribute float aLinesofar;\nvarying highp float vLinesofar;\n#endif\nuniform float cameraToCenterDistance;\n#if defined(HAS_STROKE_WIDTH)\nattribute float aLineStrokeWidth;\n#else\nuniform float lineStrokeWidth;\n#endif\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\nuniform mat4 modelMatrix;\nuniform float tileResolution;\nuniform float resolution;\nuniform float tileRatio;\nuniform float isRenderingTerrain;\n#if defined(HAS_LINE_DX) || defined(HAS_LINE_DY)\nattribute vec2 aLineDxDy;\n#endif\n#ifndef HAS_LINE_DX\nuniform float lineDx;\n#endif\n#ifndef HAS_LINE_DY\nuniform float lineDy;\n#endif\nuniform vec2 canvasSize;\nuniform float layerScale;\nvarying vec2 vNormal;\nvarying vec2 vWidth;\nvarying float vGammaScale;\n#ifndef ENABLE_TILE_STENCIL\nvarying vec2 vPosition;\n#endif\n#ifdef USE_LINE_OFFSET\nattribute vec2 aExtrudeOffset;\n#endif\n#ifdef HAS_LINE_WIDTH\nattribute float aLineWidth;\n#else\nuniform float lineWidth;\n#endif\n#ifndef PICKING_MODE\n#ifndef HAS_GRADIENT\n#ifdef HAS_COLOR\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#ifdef HAS_PATTERN\n#if defined(HAS_PATTERN_ANIM) || defined(HAS_PATTERN_GAP)\nattribute vec2 aLinePattern;\n#endif\n#ifdef HAS_PATTERN_ANIM\nvarying float vLinePatternAnimSpeed;\n#endif\n#ifdef HAS_PATTERN_GAP\nvarying float vLinePatternGap;\n#endif\nattribute vec4 aTexInfo;\nvarying vec4 vTexInfo;\n#endif\n#ifdef HAS_DASHARRAY\n#ifdef HAS_DASHARRAY_ATTR\nattribute vec4 aDasharray;\nvarying vec4 vDasharray;\n#endif\n#ifdef HAS_DASHARRAY_COLOR\nattribute vec4 aDashColor;\nvarying vec4 vDashColor;\n#endif\n#endif\n#endif\n#ifdef HAS_STROKE_COLOR\nattribute vec4 aStrokeColor;\nvarying vec4 vStrokeColor;\n#endif\n#ifdef HAS_OPACITY\nattribute float aOpacity;\nvarying float vOpacity;\n#endif\n#ifdef HAS_GRADIENT\nattribute float aGradIndex;\nvarying float vGradIndex;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#include <highlight_vert>\n#else\n#include <fbo_picking_vert>\n#endif\nvarying vec3 vVertex;\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n  float d = mod(abs(aExtrude.x), 2.);\n  float e = mod(abs(aExtrude.y), 2.);\n  vNormal = vec2(d, e * 2. - 1.);\n  vec4 f = vec4(c, 1.);\n  vec4 h = projViewModelMatrix * positionMatrix * f;\n  if(isRenderingTerrain == 1.) {\n    vVertex = (positionMatrix * f).xyz;\n  } else {\n    vVertex = (modelMatrix * positionMatrix * f).xyz;\n  }\n#ifdef HAS_STROKE_WIDTH\nfloat i = aLineStrokeWidth / 2. * layerScale;\n#else\nfloat i = lineStrokeWidth;\n#endif\n#ifdef HAS_LINE_WIDTH\nfloat j = aLineWidth / 2. * layerScale;\n#else\nfloat j = lineWidth * layerScale;\n#endif\nfloat k = j / 2. + i;\n  float l = sign(i) * j / 2.;\n  float m = l + sign(l) * ANTIALIASING;\n  float n = k + sign(k) * ANTIALIASING;\n#ifdef USE_LINE_OFFSET\nvec2 o = lineOffset * (vNormal.y * (aExtrude.xy - aExtrudeOffset) + aExtrudeOffset);\n  vec2 u = (n * aExtrude.xy + o) / EXTRUDE_SCALE;\n#else\nvec2 v = aExtrude.xy / EXTRUDE_SCALE;\n  vec2 u = n * v;\n#endif\nfloat A = tileResolution / resolution;\n  vec4 B = vec4(c + vec3(u, .0) * tileRatio / A, 1.);\n  gl_Position = projViewModelMatrix * positionMatrix * B;\n  if(isRenderingTerrain == .0) {\n    float C = min(AA_CLIP_LIMIT / canvasSize.x, AA_CLIP_LIMIT / canvasSize.y);\n    float D = distance(gl_Position.xy / gl_Position.w, h.xy / h.w) - C;\n    if(D * j < .0) {\n      float E = -D / C;\n      float F = E * E * E * E * AA_LINE_WIDTH;\n      u += F * v;\n      n += F / 6.;\n      B = vec4(c + vec3(u, .0) * tileRatio / A, 1.);\n      gl_Position = projViewModelMatrix * positionMatrix * B;\n    }\n  }\n#ifdef HAS_LINE_DX\nfloat G = aLineDxDy[0];\n#else\nfloat G = lineDx;\n#endif\n#ifdef HAS_LINE_DY\nfloat H = aLineDxDy[1];\n#else\nfloat H = lineDy;\n#endif\nfloat I = gl_Position.w;\n  gl_Position.xy += vec2(G, H) * 2. / canvasSize * I;\n#ifndef PICKING_MODE\nvWidth = vec2(n, m);\n  if(isRenderingTerrain == 1.) {\n    vGammaScale = 1.;\n  } else {\n    vGammaScale = I / cameraToCenterDistance;\n  }\n#ifndef ENABLE_TILE_STENCIL\nvPosition = c.xy;\n#ifdef USE_LINE_OFFSET\nvPosition += tileRatio * o / EXTRUDE_SCALE;\n#endif\n#endif\n#if defined(HAS_PATTERN) || defined(HAS_DASHARRAY) || defined(HAS_GRADIENT)\n#ifdef HAS_GRADIENT\nvLinesofar = aLinesofar / MAX_LINE_DISTANCE;\n  vGradIndex = aGradIndex;\n#else\nfloat J = aLinesofar - k * aExtrude.z / EXTRUDE_SCALE / A * tileRatio;\n  vLinesofar = J / tileRatio * A;\n#endif\n#endif\n#ifndef HAS_GRADIENT\n#ifdef HAS_COLOR\nvColor = aColor;\n#endif\n#ifdef HAS_DASHARRAY\n#ifdef HAS_DASHARRAY_ATTR\nvDasharray = aDasharray;\n#endif\n#ifdef HAS_DASHARRAY_COLOR\nvDashColor = aDashColor / 255.;\n#endif\n#endif\n#ifdef HAS_PATTERN\nvTexInfo = vec4(aTexInfo.xy, aTexInfo.zw + 1.);\n#ifdef HAS_PATTERN_ANIM\nvLinePatternAnimSpeed = aLinePattern[0] / 127.;\n#endif\n#ifdef HAS_PATTERN_GAP\nvLinePatternGap = aLinePattern[1] / 10.0;\n#endif\n#endif\n#endif\n#ifdef HAS_STROKE_COLOR\nvStrokeColor = aStrokeColor;\n#endif\n#ifdef HAS_OPACITY\nvOpacity = aOpacity / 255.;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(B);\n#endif\nhighlight_setVarying();\n#else\nfbo_picking_setData(I, true);\n#endif\n}";const rr$2=identity$2([]),sr$2=[];class or$2 extends Bi$1{static getBloomSymbol(){return["lineBloom"]}prepareSymbol(t){const e=t.lineColor;Array.isArray(e)&&(3===e.length&&e.push(1),t.lineColor=e.map((t=>255*t)));const n=t.lineStrokeColor;Array.isArray(n)&&(3===n.length&&n.push(1),t.lineStrokeColor=n.map((t=>255*t)));const i=t.lineDashColor;Array.isArray(i)&&(3===i.length&&i.push(1),t.lineDashColor=i.map((t=>255*t)))}isAnimating(){if(this.Ar)return!0;const t=this.getSymbols(),e=this.sceneConfig.trailAnimation;if(e&&e.enable)return!0;for(let e=0;e<t.length;e++)if(t[e].linePatternFile&&t[e].linePatternAnimSpeed)return!0;return!1}needToRedraw(){return!!super.needToRedraw()||!!this.isAnimating()}isBloom(t){return!!this.getSymbol(t.properties.symbolIndex)[or$2.getBloomSymbol()[0]]}needPolygonOffset(){return!0}createMesh(e,i){if(!e.geometry)return null;const{geometry:r,symbolIndex:s,ref:o}=e,a=this.getSymbolDef(s);void 0===o&&si$1(r,a,this.getFnTypeConfig(s));const l=this.getSymbol(s),h={tileResolution:r.properties.tileResolution,tileRatio:r.properties.tileRatio,tileExtent:r.properties.tileExtent};this.setLineUniforms(l,h),Ct$3(h,"lineColor",l,"lineColor","#fff",Rt$3(this.colorCache)),Ct$3(h,"linePatterGapColor",l,"linePatterGapColor",[0,0,0,0],Rt$3(this.colorCache)),Ct$3(h,"lineStrokeColor",l,"lineStrokeColor",[0,0,0,0],Rt$3(this.colorCache)),Ct$3(h,"lineDasharray",l,"lineDasharray",[0,0,0,0],(t=>{let e;if(t&&t.length){const n=t;1===t.length?e=[n[0],n[0],n[0],n[0]]:2===t.length?e=[n[0],n[1],n[0],n[1]]:3===t.length?e=[n[0],n[1],n[2],n[2]]:4===t.length?e=t:t.length>4&&(e=t.slice(0,4))}return e||[0,0,0,0]})),Ct$3(h,"lineDashColor",l,"lineDashColor",[0,0,0,0],Rt$3(this.colorCache));const u=r.properties.iconAtlas,c=this.layer instanceof t__namespace.TileLayer;u&&(h.linePatternFile=Wi$1(this.regl,u,!1,!1),h.atlasSize=u?[u.width,u.height]:[0,0],h.flipY=c?-1:1,this.drawDebugAtlas(u)),void 0===o&&r.generateBuffers(this.regl);const f=new Ce$5(h),d=new Be$5(r,f,{castShadow:!1,picking:!0});d.setLocalTransform(i),d.positionMatrix=this.getAltitudeOffsetMatrix();const p={};return u&&(p.HAS_PATTERN=1),d.properties.symbolIndex=s,this.wr(d,p),r.data.aColor&&(p.HAS_COLOR=1),r.data.aStrokeColor&&(p.HAS_STROKE_COLOR=1),this.setMeshDefines(p,r,a),r.data.aAltitude&&(p.HAS_ALTITUDE=1),d.setDefines(p),d}addMesh(...t){delete this.Ar;const e=t[0];Array.isArray(e)&&e.forEach((t=>{this._r(t)})),super.addMesh(...t)}_r(t){if(!t.geometry.aLineWidth&&t.material.get("lineWidth")<=0||!t.geometry.aOpacity&&t.material.get("lineOpacity")<=0)return;const e=t.defines;this.wr(t,e),t.setDefines(e),t.geometry.properties.hasPatternAnim&&(this.Ar=1)}wr(t,e){const n=t.geometry,i=this.getSymbol(t.properties.symbolIndex);n.data.aDasharray||Array.isArray(i.lineDasharray)&&i.lineDasharray.reduce(((t,e)=>t+e),0)>0?(e.HAS_DASHARRAY=1,n.data.aDasharray&&(e.HAS_DASHARRAY_ATTR=1),n.data.aDashColor&&(e.HAS_DASHARRAY_COLOR=1)):e.HAS_DASHARRAY&&delete e.HAS_DASHARRAY}setLineUniforms(t,e){Ct$3(e,"lineWidth",t,"lineWidth",2),Ct$3(e,"lineOpacity",t,"lineOpacity",1),Ct$3(e,"lineStrokeWidth",t,"lineStrokeWidth",0),Ct$3(e,"lineBlur",t,"lineBlur",.7),Ct$3(e,"lineOffset",t,"lineOffset",0),Ct$3(e,"lineDx",t,"lineDx",0),Ct$3(e,"lineDy",t,"lineDy",0),Ct$3(e,"linePatternAnimSpeed",t,"linePatternAnimSpeed",0),Ct$3(e,"linePatternGap",t,"linePatternGap",0)}setMeshDefines(t,e,n){e.data.aOpacity&&(t.HAS_OPACITY=1),e.data.aLineWidth&&(t.HAS_LINE_WIDTH=1),e.data.aLineStrokeWidth&&(t.HAS_STROKE_WIDTH=1),yi$1(n.lineDx)&&(t.HAS_LINE_DX=1),yi$1(n.lineDy)&&(t.HAS_LINE_DY=1),yi$1(n.linePatternAnimSpeed)&&(t.HAS_PATTERN_ANIM=1),yi$1(n.linePatternGap)&&(t.HAS_PATTERN_GAP=1)}paint(t){this.isShadowIncludeChanged(t)&&(this.shader.dispose(),this.createShader(t)),super.paint(t)}createFnTypeConfig(t,e){const n=piecewiseConstant(e.lineColor),i=piecewiseConstant(e.aLinePatternAnimSpeed),r=piecewiseConstant(e.aLinePatternGap),s=this.createShapeFnTypeConfigs(t,e),o=new Int8Array(2);return[{attrName:"aColor",symbolName:"lineColor",type:Uint8Array,width:4,define:"HAS_COLOR",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=this.colorCache[r]=this.colorCache[r]||color(r).unitArray()),r=Dt$3(r),r}},{attrName:"aLinePattern",symbolName:"linePatternAnimSpeed",type:Int8Array,width:2,related:["linePatternGap"],define:"HAS_LINE_PATTERN",evaluate:(e,n,r,s)=>{let a=i(t.getZoom(),e);return It$3(a)&&(a=0),0!==a&&(n.properties.hasPatternAnim=1),o[0]=a/127,o[1]=r[s+1],o}},{attrName:"aLinePattern",symbolName:"linePatternGap",type:Int8Array,width:2,related:["linePatternAnimSpeed"],define:"HAS_LINE_PATTERN",evaluate:(e,n,i,s)=>{let a=r(t.getZoom(),e);return It$3(a)&&(a=0),o[1]=10*a,o[0]=i[s],o}}].concat(s)}createShapeFnTypeConfigs(t,e){const n=interpolated(e.lineWidth),i=interpolated(e.lineOpacity),r=interpolated(e.lineStrokeWidth),s=interpolated(e.lineDx),o=interpolated(e.lineDy),a=new Uint16Array(1),l=new Int8Array(1);return[{attrName:"aLineWidth",symbolName:"lineWidth",type:Uint8Array,width:1,define:"HAS_LINE_WIDTH",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e)),a[0]=Math.round(2*r),a[0]}},{attrName:"aLineStrokeWidth",symbolName:"lineStrokeWidth",type:Uint8Array,width:1,define:"HAS_STROKE_WIDTH",evaluate:e=>{const n=r(t.getZoom(),e);return a[0]=Math.round(2*n),a[0]}},{attrName:"aLineDxDy",symbolName:"lineDx",type:Int8Array,width:2,define:"HAS_LINE_DX",evaluate:e=>{const n=s(t.getZoom(),e);return l[0]=n,l[0]}},{attrName:"aLineDxDy",symbolName:"lineDy",type:Int8Array,width:2,define:"HAS_LINE_DY",evaluate:e=>{const n=o(t.getZoom(),e);return l[0]=n,l[0]}},{attrName:"aOpacity",symbolName:"lineOpacity",type:Uint8Array,width:1,define:"HAS_OPACITY",evaluate:(e,n)=>{let r=i(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,n,t,e)),a[0]=255*r,a[0]}}]}updateSceneConfig(t){t.trailAnimation&&this.createShader(this.Sr)}init(t){this.renderer=new B$6(this.regl),this.createShader(t),this.pickingFBO&&(this.picking=[new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+ir$2,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],extraCommandProps:this.getExtraCommandProps()},this.pickingFBO,this.getMap())])}createShader(t){this.Sr=t;const e=[],i={};this.fillIncludes(i,e,t),this.sceneConfig.trailAnimation&&this.sceneConfig.trailAnimation.enable&&(i.HAS_TRAIL=1);const s=[];e.push({name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5(s,e.projViewMatrix,e.modelMatrix),s}}),this.shader=new vn$4({vert:ir$2,frag:"#define SHADER_NAME LINE\n#define DEVICE_PIXEL_RATIO 1.0\nprecision highp float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\nuniform lowp float blendSrcIsOne;\nuniform lowp float lineBlur;\nuniform float isRenderingTerrain;\n#ifdef HAS_COLOR\nvarying vec4 vColor;\n#else\nuniform lowp vec4 lineColor;\n#endif\n#include <highlight_frag>\n#ifdef HAS_STROKE_COLOR\nvarying vec4 vStrokeColor;\n#else\nuniform lowp vec4 lineStrokeColor;\n#endif\n#ifdef HAS_OPACITY\nvarying float vOpacity;\n#else\nuniform lowp float lineOpacity;\n#endif\nuniform float layerOpacity;\n#ifdef HAS_PATTERN\nuniform sampler2D linePatternFile;\nuniform vec2 atlasSize;\nuniform float flipY;\n#ifdef HAS_PATTERN_ANIM\nvarying float vLinePatternAnimSpeed;\n#else\nuniform float linePatternAnimSpeed;\n#endif\n#ifdef HAS_PATTERN_GAP\nvarying float vLinePatternGap;\n#else\nuniform float linePatternGap;\n#endif\nuniform vec4 linePatterGapColor;\nvarying vec4 vTexInfo;\nvec2 c(vec2 d) {\n  vec2 e = mod(d, 1.);\n  vec2 f = vTexInfo.xy;\n  vec2 h = vTexInfo.zw;\n  return (f + e * h) / atlasSize;\n}\n#endif\nvarying vec2 vNormal;\nvarying vec2 vWidth;\nvarying float vGammaScale;\n#ifndef ENABLE_TILE_STENCIL\nvarying vec2 vPosition;\n#endif\nuniform float tileExtent;\n#ifdef HAS_DASHARRAY\n#ifdef HAS_DASHARRAY_ATTR\nvarying vec4 vDasharray;\n#else\nuniform vec4 lineDasharray;\n#endif\n#ifdef HAS_DASHARRAY_COLOR\nvarying vec4 vDashColor;\n#else\nuniform vec4 lineDashColor;\n#endif\n#endif\n#if defined(HAS_PATTERN) || defined(HAS_DASHARRAY) || defined(HAS_GRADIENT) || defined(HAS_TRAIL)\nvarying highp float vLinesofar;\n#endif\n#ifdef HAS_TRAIL\nuniform float trailSpeed;\nuniform float trailLength;\nuniform float trailCircle;\n#endif\n#if defined(HAS_TRAIL) || defined(HAS_PATTERN)\nuniform float currentTime;\n#endif\nfloat i(float j, float k) {\n  float l = k / 2.;\n  float m = abs(j - l);\n  float n = (.1 + 1. / DEVICE_PIXEL_RATIO) * vGammaScale;\n  return clamp(min(m + n, l - m) / n, .0, 1.);\n}\nvarying vec3 vVertex;\nuniform vec3 cameraPosition;\nuniform float cameraToCenterDistance;\nvoid main() {\n  \n#ifndef ENABLE_TILE_STENCIL\nfloat o = sign(tileExtent - min(tileExtent, abs(vPosition.x))) * sign(1. + sign(vPosition.x)) * sign(tileExtent - min(tileExtent, abs(vPosition.y))) * sign(1. + sign(vPosition.y));\n  if(o == .0) {\n    discard;\n  }\n#endif\n#if defined(HAS_PATTERN) || defined(HAS_DASHARRAY) || defined(HAS_GRADIENT) || defined(HAS_TRAIL)\nfloat u = vLinesofar;\n#endif\nfloat v = length(vNormal) * vWidth.s;\n#ifdef HAS_PATTERN\nvec2 h = vTexInfo.zw;\n  float A = sign(h.x * h.y);\n  float B = mix(lineBlur, .0, A);\n#else\nfloat B = lineBlur;\n#endif\nfloat n = (B + 1. / DEVICE_PIXEL_RATIO) * vGammaScale;\n  float C = clamp(min(v - (vWidth.t - n), vWidth.s - v) / n, .0, 1.);\n#ifdef HAS_COLOR\nvec4 D = vColor / 255.;\n#else\nvec4 D = lineColor;\n#endif\n#ifdef HAS_PATTERN\nif(A == 1.) {\n    \n#ifdef HAS_PATTERN_GAP\nfloat E = vLinePatternGap;\n#else\nfloat E = linePatternGap;\n#endif\n#ifdef HAS_PATTERN_ANIM\nfloat F = vLinePatternAnimSpeed;\n#else\nfloat F = linePatternAnimSpeed;\n#endif\nfloat G = h.x * vWidth.s * 2. / h.y;\n    float H = G * (1. + E);\n    u += mod(currentTime * -F * .2, H);\n    float I = mod(u / H, 1.);\n    float J = mod((flipY * vNormal.y + 1.) / 2., 1.);\n    vec4 K = texture2D(linePatternFile, c(vec2(I * (1. + E), J)));\n    float L = clamp(sign(1. / (1. + E) - I) + .000001, .0, 1.);\n    K = mix(linePatterGapColor, K, L);\n    D *= K;\n  }\n#endif\n#ifdef HAS_DASHARRAY\n#ifdef HAS_DASHARRAY_ATTR\nvec4 M = vDasharray;\n#else\nvec4 M = lineDasharray;\n#endif\n#ifdef HAS_DASHARRAY_COLOR\nvec4 N = vDashColor;\n#else\nvec4 N = lineDashColor;\n#endif\nfloat k = M[0] + M[1] + M[2] + M[3];\n  float j = mod(u, k);\n  float O = max(sign(M[0] - j), .0);\n  float P = j - M[0] - M[1];\n  float Q = max(sign(P), .0) * max(sign(M[2] - P), .0);\n  float R = O + Q;\n  float S = i(j, M[0]);\n  float T = i(P, M[2]);\n  float U = S * O + T * Q;\n  D = D * (1. - U) + N * U;\n#endif\n#ifdef HAS_STROKE_COLOR\nvec4 V = vStrokeColor / 255.;\n#else\nvec4 V = lineStrokeColor;\n#endif\nV = mix(D, V, sign(vWidth.t));\n  D = V * C + max(sign(vWidth.t - v), .0) * D * (1. - C);\n#ifdef HAS_TRAIL\nfloat W = mod(u - currentTime * trailSpeed * .1, trailCircle);\n  float X = W < trailLength ? mix(.0, 1., W / trailLength) : .0;\n  D *= X;\n#endif\n#ifdef HAS_OPACITY\nfloat Y = vOpacity;\n#else\nfloat Y = lineOpacity;\n#endif\ngl_FragColor = D * Y * layerOpacity;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat Z = shadow_computeShadow();\n  gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, Z);\n#endif\nfloat ba;\n  if(isRenderingTerrain == 1.) {\n    ba = 1.;\n  } else {\n    ba = clamp(cameraToCenterDistance * 1.5 / distance(vVertex, cameraPosition), .0, 1.);\n  }\n  gl_FragColor *= ba;\n  gl_FragColor = highlight_blendColor(gl_FragColor);\n}",uniforms:e,defines:i,extraCommandProps:this.getExtraCommandProps()})}getExtraCommandProps(){const t=this.layer.getRenderer().isEnableTileStencil&&this.layer.getRenderer().isEnableTileStencil(),e=this.canvas;return{viewport:{x:(t,e)=>e.viewport?e.viewport.x:0,y:(t,e)=>e.viewport?e.viewport.y:0,width:(t,n)=>n.viewport?n.viewport.width:e?e.width:1,height:(t,n)=>n.viewport?n.viewport.height:e?e.height:1},stencil:{enable:!1,func:{cmp:()=>t?"=":"<=",ref:(e,n)=>t?n.stencilRef:n.level},op:{fail:"keep",zfail:"keep",zpass:()=>t?"zero":"replace"}},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],mask:this.sceneConfig.depthMask||!1,func:this.sceneConfig.depthFunc||"<="},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}}getUniformValues(t,e){const n=e&&e.isRenderingTerrainSkin,i=this.layer.getTileSize().width,r=n?rr$2:t.projViewMatrix,s=t.viewMatrix,o=t.cameraToCenterDistance,a=t.getResolution(),l=set(sr$2,t.width,t.height);n&&set(l,i,i);const u=this.getBlendFunc().src(),c=this.sceneConfig.trailAnimation||{},f={layerScale:this.layer.options.styleScale||1,projViewMatrix:r,viewMatrix:s,cameraToCenterDistance:o,resolution:a,canvasSize:l,trailSpeed:c.speed||1,trailLength:c.trailLength||500,trailCircle:c.trailCircle||1e3,currentTime:this.layer.getRenderer().getFrameTimestamp()||0,blendSrcIsOne:+!(1!==u&&"one"!==u),cameraPosition:t.cameraPosition,viewport:n&&e&&e.viewport,isRenderingTerrain:+!!n};return this.setIncludeUniformValues(f,e),f}}class ar$2 extends or$2{postCreateGeometry(t){const{symbolIndex:e,geometry:n}=t,{features:i}=n.properties,r=this.getSymbol(e).lineGradientProperty,s=n.data.aPickingId,o=new Uint8Array(s.length),a=[];let l=s[0];const h=i[l].feature.properties;a.push(h&&h[r]||0);for(let t=1;t<s.length;t++)s[t]!==l&&(l=s[t],a.push(h&&h[r]||0)),o[t]=a.length-1;n.data.aGradIndex=o,n.properties.gradients=a}createMesh(t,e){const{geometry:i,symbolIndex:r,ref:s}=t,o=this.getSymbolDef(r);void 0===s&&si$1(i,o,this.getFnTypeConfig(r));const a={tileResolution:i.properties.tileResolution,tileRatio:i.properties.tileRatio,tileExtent:i.properties.tileExtent},l=this.getSymbol(r);this.setLineUniforms(l,a);const h=i.properties.gradients;let u=2*h.length;hr$2(u)||(u=ur$2(u));const c=this.regl.texture({width:256,height:u,data:lr$2(h),format:"rgba",mag:"linear",min:"linear",flipY:!1});a.lineGradientTexture=c,a.lineGradientTextureHeight=c.height,void 0===s&&i.generateBuffers(this.regl);const f=new Ce$5(a),d=new Be$5(i,f,{castShadow:!1,picking:!0});d.setLocalTransform(e);const p={HAS_GRADIENT:1};return i.data.aAltitude&&(p.HAS_ALTITUDE=1),this.setMeshDefines(p,i,o),d.setDefines(p),d.properties.symbolIndex=r,d}createFnTypeConfig(t,e){return this.createShapeFnTypeConfigs(t,e)}createShader(t){this.Sr=t;const e=[],i={};this.fillIncludes(i,e,t),this.sceneConfig.trailAnimation&&this.sceneConfig.trailAnimation.enable&&(i.HAS_TRAIL=1);const s=[];e.push({name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5(s,e.projViewMatrix,e.modelMatrix),s}}),this.shader=new vn$4({vert:ir$2,frag:"#define SHADER_NAME LINE_GRADIENT\n#define DEVICE_PIXEL_RATIO 1.0\n#define MAX_LINE_COUNT 128.0\nprecision mediump float;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_frag>\n#endif\n#ifdef HAS_OPACITY\nvarying float vOpacity;\n#else\nuniform lowp float lineOpacity;\n#endif\nuniform float layerOpacity;\nuniform lowp float lineBlur;\nuniform float lineGradientTextureHeight;\nuniform float tileExtent;\nuniform sampler2D lineGradientTexture;\nvarying vec2 vNormal;\nvarying vec2 vWidth;\nvarying float vGammaScale;\nvarying highp float vLinesofar;\nvarying float vGradIndex;\n#ifndef ENABLE_TILE_STENCIL\nvarying vec2 vPosition;\n#endif\n#ifdef HAS_TRAIL\nuniform float trailSpeed;\nuniform float trailLength;\nuniform float trailCircle;\nuniform float currentTime;\n#endif\n#include <highlight_frag>\nvoid main() {\n  \n#ifndef ENABLE_TILE_STENCIL\nfloat c = sign(tileExtent - min(tileExtent, abs(vPosition.x))) * sign(1. + sign(vPosition.x)) * sign(tileExtent - min(tileExtent, abs(vPosition.y))) * sign(1. + sign(vPosition.y));\n  if(c == .0) {\n    discard;\n  }\n#endif\nfloat d = length(vNormal) * vWidth.s;\n  float e = (lineBlur + 1. / DEVICE_PIXEL_RATIO) * vGammaScale;\n  float f = clamp(min(d - (vWidth.t - e), vWidth.s - d) / e, .0, 1.);\n  float h = vLinesofar;\n  vec4 i = texture2D(lineGradientTexture, vec2(h, (vGradIndex * 2. + .5) / lineGradientTextureHeight)) * f;\n  i *= max(sign(MAX_LINE_COUNT - vGradIndex), .0);\n#ifdef HAS_TRAIL\nfloat j = mod(h - currentTime * trailSpeed * .1, trailCircle);\n  float k = j < trailLength ? mix(.0, 1., j / trailLength) : .0;\n  i *= k;\n#endif\n#ifdef HAS_OPACITY\nfloat l = vOpacity;\n#else\nfloat l = lineOpacity;\n#endif\ngl_FragColor = i * l * layerOpacity;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nfloat m = shadow_computeShadow();\n  gl_FragColor.rgb = shadow_blend(gl_FragColor.rgb, m);\n#endif\ngl_FragColor = highlight_blendColor(gl_FragColor);\n}",uniforms:e,defines:i,extraCommandProps:this.getExtraCommandProps()})}}function lr$2(t){t.length>128&&(console.warn("Line count in a tile exceeds maximum limit (128) for line-gradient render plugin."),t=t.slice(0,128));const e=document.createElement("canvas"),n=e.getContext("2d");e.width=256,e.height=2*t.length,hr$2(e.height)||(e.height=ur$2(2*t.length));for(let e=0;e<t.length;e++){const i=t[e],r=n.createLinearGradient(0,0,256,0);for(let t=0;t<i.length;t+=2)r.addColorStop(+i[t],i[t+1]);n.fillStyle=r;const s=e%256;n.fillRect(0,2*s,256,2*s+2)}return n.canvas}function hr$2(t){return 0==(t&t-1)&&0!==t}function ur$2(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))}class cr$2{constructor(t){this.R=t||[],this.properties={}}set meshes(t){this.R=t}get meshes(){return this.R}}const mr$2=new Uint8Array(1),yr$2=[],gr$2={collides:0,boxes:[]},vr$2=[],xr$2=[];class br$2 extends Bi$1{createGeometry(...t){const e=super.createGeometry(...t);if(!e||!e.geometry)return e;const{geometry:n}=e,i=t[0];return n.properties.collideIds=i.featureIds&&i.featureIds.length&&i.isIdUnique?i.featureIds:i.data.aPickingId,n.properties.uniqueCollideIds=Ut$2(n.properties.collideIds),e}supportRenderMode(t){const e=this.sceneConfig.renderToPointRenderTarget;return e||void 0===e?"point"===t:"fxaa"===t||"fxaaAfterTaa"===t}addMesh(t,e,n){if(t&&!this.isEnableCollision()){let e=t;Array.isArray(e)||(vr$2[0]=t,e=vr$2);for(let t=0;t<e.length;t++){const n=e[t].defines;delete n.ENABLE_COLLISION,e[t].setDefines(n);const{elements:i,visElemts:r}=e[t].geometry.properties;r&&void 0!==r.count&&r.count!==i.length&&(e[t].geometry.setElements(i),r.count=i.length)}}return super.addMesh(t,e,n)}startMeshCollision(t){const{meshKey:e}=t.properties,{renderer:n}=this.Mr,i=n.isForeground(t instanceof cr$2?t.meshes[0]:t);if(t.properties.isForeground=i,t instanceof cr$2&&t.meshes.length)for(let e=0;e<t.meshes.length;e++)t.meshes[e].properties.isForeground=i;this.Pr=performance.now(),this.Tr=this.kr(),this.Or=this.Ir(e)}endMeshCollision(e){const n=this.Fr.tags[e];if(this.Tr&&n&&this.Or){const e=this.getMap();this.Cr||(this.Cr=new t__namespace.Coordinate(0,0),this.Er=new t__namespace.Coordinate(0,0)),n.anchor0=e.containerPointToCoord(this.Dr,this.Cr),n.anchor1=e.containerPointToCoord(this.Rr,this.Er),n.anchor0.z=e.getZoom(),n.anchor0.width=e.width,n.anchor0.height=e.height}this.getMap().collisionFrameTime+=performance.now()-this.Pr}Ir(t){const e=this.getMap(),n=e.getZoom(),[i,r]=this.Lr(t);return!i||!r||i.z!==n||i.width!==e.width||i.height!==e.height||i.distanceTo(this.Dr)>3||r.distanceTo(this.Rr)>3}Nr(){const e=this.getMap();this.Hr={},this.Dr=new t__namespace.Point(e.width/2,e.height/3),this.Rr=new t__namespace.Point(e.width/2,2*e.height/3),delete this.Tr,this.Fr||(this.Fr={tags:{}}),this.Mr={layer:this.layer,renderer:this.layer.getRenderer(),frameTimestamp:this.layer.getRenderer().getFrameTimestamp(),map:this.getMap(),zoom:e.getZoom(),collisionTags:this.Fr.tags,isEnableUniquePlacement:this.isEnableUniquePlacement()}}zr(){}Vr(t,e){const n=this.Fr;return n.tags[t]&&n.tags[t][e]}Ur(t,e,n){const i=this.Fr;i.tags[t]=i.tags[t]||[],i.tags[t][e]=n}kr(){const t=this.getMap();if(!t.isInteracting())return!0;return t.collisionFrameTime<=this.layer.options.collisionFrameLimit}Lr(t){const e="__meshAnchorKey".trim(),n=this.Fr.tags[t];if(n&&n.anchor0){const{anchor0:t,anchor1:i}=n,r=t[e]=t[e]||t.x+","+t.y,s=i[e]=i[e]||i.x+","+i.y;let o=this.Hr[r],a=this.Hr[s];if(!o||!a){const e=this.getMap();o=this.Hr[r]=e.coordToContainerPoint(t),a=this.Hr[s]=e.coordToContainerPoint(i)}return o.z=t.z,yr$2[0]=o,yr$2[1]=a,o.width=t.width,o.height=t.height,yr$2}return yr$2[0]=yr$2[1]=null,yr$2}updateBoxCollisionFading(t,e,n,i,r){const{layer:s,renderer:o,zoom:a,collisionTags:l,isEnableUniquePlacement:h}=this.Mr,{meshKey:u,isForeground:c}=e.properties;if(h&&this.jr(u,r))return!1;const f=n.length;let d=l[u]&&l[u][r];const p=d,m=this.Br&&d;if((!m||0===d.collides)&&t){const t=m&&0===d.collides;if(this.Tr||t)if((this.Or||d&&d.z!==a)&&(d=null),d){if(d.boxes&&d.boxes.length){const{boxes:t,isAllowOverlap:e}=d;let n=0;if(!e){let e=0;for(let i=0;i<t.length;i++)if(!n){const r=this.isCollides(t[i]);if(-1===r)e++;else if(1===r){n=1;break}}e===t.length&&(n=-1)}d.collides=n}}else{d=p||{collides:0,boxes:[]},d.boxes.length=0,d.z=a;let t=0;for(let e=0;e<f;e++){const{mesh:s,allElements:o,boxCount:a,start:l,end:h}=n[e],u=this.Gr(s,o,a,l,h,i,r);u.isAllowOverlap&&(d.isAllowOverlap=1),0===t&&(t=u.collides),u.boxes&&d.boxes.push(...u.boxes)}d.collides=t,this.Ur(u,r,d)}}let y=t&&d&&0===d.collides,g=1,v=!1;if(this.sceneConfig.fading){const t=this.Wr(e);if(this.Xr)t[r]=y?1:-1;else if(c&&delete e.Yr,g=this.$r(c,y,t,r),c?(g>0&&(y=!0),v=this.isBoxFading(e,r),v&&this.setToRedraw()):y||(this.qr(t,r),g=0),y){const n=e.Yr;if(n&&1===g&&t[r]>0){let{fadeOutDelay:t,fadingDuration:e}=this.sceneConfig;It$3(e)&&(e=224),It$3(t)&&(t=100);const i=kt$3(1-(o.getFrameTimestamp()-n-t)/e,0,1);g*=i,i>0&&this.setToRedraw()}}}if(d&&s.options.debugCollision&&this.addCollisionDebugBox(d.boxes,d.collides?0:1),y||v){const{mesh:t,start:e}=n[0],i=this.getSymbol(t.properties.symbolIndex);!this.Jr(i,t,e)&&d&&d.boxes&&this.Kr(d.boxes,t)}if(y){const t=mr$2[0]=255*g;for(let e=0;e<f;e++){const{mesh:i,allElements:r,start:s,end:o,boxIndex:a}=n[e];this.setCollisionOpacity(i,r,t,s,o,a)}}return y&&g>0}isMeshIterable(){return!0}setCollisionOpacity(t,e,n,i,r){this.Zr(t,n,e[i],e[r-1])}Zr(t,e,n,i){const{aOpacity:r}=t.geometry.properties;if(!r)return;const s=n;if(r[s]!==e){const t=i;for(let n=s;n<=t;n++)r[n]=e;r.dirty=!0}}isBoxFading(t,e){const{frameTimestamp:n}=this.Mr;let i=this.sceneConfig.fadingDuration;return It$3(i)&&(i=224),n-Math.abs(this.Wr(t)[e])<i}Gr(t,e,n,i,r,s,o){const a=this.getSymbol(t.properties.symbolIndex),l=this.Jr(a,t,e[i]),h=this.Qr(a,t,e[i]);if(!this.isEnableCollision()||l&&h)return gr$2;const u=this.isBoxCollides(t,e,n,i,r,s,o);return h&&(u.collides=0,u.isAllowOverlap=1),u}Jr(t,e,n){if(!this.isEnableCollision())return!0;const i=e.geometry.properties.aOverlap;if(!i)return 1==+t[this.propIgnorePlacement];const r=i[n];return r<2?1==+t[this.propIgnorePlacement]:r%8%2}Qr(t,e,n){if(!this.isEnableCollision())return!0;const i=e.geometry.properties.aOverlap;if(!i)return 1==+t[this.propAllowOverlap];const r=i[n];return r<2?1==+t[this.propAllowOverlap]:(r>>2)%2}Kr(t){if(Array.isArray(t[0]))for(let e=0;e<t.length;e++)this.insertCollisionBox(t[e]);else this.insertCollisionBox(t)}$r(t,e,n,i){let{fadingDuration:r,fadeInDelay:s,fadeOutDelay:o}=this.sceneConfig;It$3(r)&&(r=224),It$3(s)&&(s=600),It$3(o)&&(o=100);const{frameTimestamp:a}=this.Mr;let l=n[i],h=e?1:0;if(!l)return e&&t&&(n[i]=a+s),0;if(a<Math.abs(l)&&(!e&&l>0||e&&l<0)){const t=a-r;n[i]=l=e?t:-t}return a-Math.abs(l)<r?h=l>0?(a-l)/r:1-(a+l)/r:e?(l<0&&(n[i]=l=a+s),h=(a-l)/r):(l>0&&(n[i]=l=-(a+o)),h=1-(a+l)/r),(h<0||h>1)&&(h=kt$3(h,0,1)),h}Wr(t){this.ts||(this.ts={});const{meshKey:e}=t.properties;if(!this.ts[e]){const{frameTimestamp:t}=this.Mr;this.ts[e]={timestamp:t}}return this.ts[e]}es(t){if(!this.ns)return void(this.ns=t);const e=this.scene.getMeshes();if(e&&e.length){for(let n=0;n<e.length;n++){const i=this.Wr(e[n]);i.timestamp<this.ns?delete e[n]._fading_timestamps:i.timestamp=t}this.ns=t}}qr(t,e){if(!t)return;const{frameTimestamp:n}=this.Mr;let{fadingDuration:i}=this.sceneConfig;It$3(i)&&(i=224),t[e]=-(n-i-1)}deleteMesh(t,e){if(t){if(Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].properties.meshKey;this.Fr&&delete this.Fr.tags[n],this.ts&&delete this.ts[n]}else{const e=t.properties.meshKey;this.Fr&&delete this.Fr.tags[e],this.ts&&delete this.ts[e]}super.deleteMesh(t,e)}}delete(t){this.rs&&(this.rs.geometry.dispose(),this.ss.dispose(),this.rs.dispose(),delete this.rs,delete this.ss,delete this.os),delete this.Fr,super.delete(t)}isCollides(t){const e=this.layer,n=e.getMap(),i=n.getDevicePixelRatio();if(scale$3(xr$2,t,1/i),n.isOffscreen(xr$2))return-1;const r=e.getCollisionIndex(),s=this.sceneConfig.collisionBufferSize||e.options.collisionBufferSize||0;return s&&(t=_r$2(xr$2,t,s)),+r.collides(t)}insertCollisionBox(t){const e=this.layer,n=e.getCollisionIndex(),i=this.sceneConfig.collisionBufferSize||e.options.collisionBufferSize||0;let r=t;i&&(r=t.as=t.as||[],t=_r$2(r,t,i)),n.insertBox(r)}addCollisionDebugBox(t,e){if(t&&t.length)if(Array.isArray(t[0]))for(let n=0;n<t.length;n++){this.ls(t[n],e)}else this.ls(t,e)}ls(t,e){if(!t)return;const n=this.hs=this.hs||{aPosition:[],aVisible:[],indices:[]},i=this.sceneConfig.collisionBufferSize||this.layer.options.collisionBufferSize||0;i&&(t=_r$2(xr$2,t,i));const r=this.getMap(),s=r.getDevicePixelRatio();if(scale$3(xr$2,t,1/s),r.isOffscreen(xr$2))return;const o=n.aPosition.length/2;n.aPosition.push(t[0],t[1],t[2],t[1],t[2],t[3],t[0],t[3]),n.aVisible.push(e,e,e,e),n.indices.push(o,o+1,o+1,o+2,o+2,o+3,o+3,o)}updateCollision(t){super.updateCollision(t),this.Nr(),this.us(),this.cs&&this.cs.length&&(this.fs(),this.cs&&(this.setToRedraw(),this.scene.addMesh(this.cs))),(this.getMap().isZooming()||this.cs&&this.cs.length)&&(this.ds(),this.ps(this.scene.getMeshes()))}paint(t){const e=super.paint(t);return this.ms(t),!1===this.Tr&&this.setToRedraw(),e}shouldIgnoreBackground(){return!this.getMap().isZooming()&&!this.cs}us(){const t=this.getMap(),e=t.isZooming();if(!e&&this.Br){const t=this.layer.getRenderer();this.cs=this.scene.getMeshes().filter((e=>!t.isForeground(e)&&!e.properties.isLinePlacement))}else e&&!this.Br&&(this.ys=t.getResolution());if(e)this.gs&&(clearTimeout(this.gs),delete this.Xr,delete this.gs),this.Xr=this.ys&&t.getResolution()>this.ys;else if(this.Br&&!this.gs){let{fadeOutDelay:t,fadingDuration:e}=this.sceneConfig;It$3(t)&&(t=100),It$3(e)&&(e=224),this.gs=setTimeout((()=>{delete this.Xr,delete this.gs}),t+e+1)}this.Br=e}ms(t){if(!this.hs||!this.layer.options.debugCollision)return;this.os||this.vs();const{aPosition:e,aVisible:i,indices:r}=this.hs;if(!this.rs){const t=new Q$7({aPosition:[],aVisible:[]},[],0,{positionSize:2,primitive:"lines"});this.rs=new Be$5(t),this.xs=new Ke$5,this.xs.addMesh(this.rs)}const s=this.rs.geometry;s.updateData("aPosition",new Float32Array(e)),s.updateData("aVisible",new Uint8Array(i)),s.setElements(r),this.os.render(this.ss,{size:[this.canvas.width,this.canvas.height]},this.xs,this.getRenderFBO(t)),delete this.hs}vs(){this.os=new B$6(this.regl);const e=this.canvas;this.ss=new vn$4({vert:"attribute vec2 aPosition;\nattribute float aVisible;\nuniform vec2 size;\nvarying vec4 vColor;\nvoid main() {\n  vec2 c = (aPosition / size - .5) * 2. * vec2(1., -1.);\n  gl_Position = vec4(c, .0, 1.);\n  vColor = mix(vec4(1., .0, .0, 1.5) * .5, vec4(.0, 1., .0, 1.) * .4, aVisible);\n}",frag:"precision mediump float;\nvarying vec4 vColor;\nvoid main() {\n  gl_FragColor = vec4(vColor.rgb, .5);\n}",uniforms:["size"],extraCommandProps:{viewport:{x:0,y:0,width:()=>e?e.width:1,height:()=>e?e.height:1},depth:{enable:!1},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}})}fs(){let{fadeOutDelay:t,fadingDuration:e}=this.sceneConfig;It$3(t)&&(t=100),It$3(e)&&(e=224);const n=this.layer.getRenderer(),i=n.getCurrentTileZoom(),r=n.getFrameTimestamp(),s=[];for(let o=0;o<this.cs.length;o++){const a=this.cs[o],l=a.properties.tile;!a.Yr&&n.isBackTile(l.id)&&(a.Yr=r);a.properties.level=l.z-i>0?2*(l.z-i)-1:2*(i-l.z),n.isForeground(a)||a.Yr&&r-a.Yr>t+e?delete a.Yr:s.push(a)}delete this.cs,s.length&&(this.cs=s)}isEnableCollision(){return this.layer.options.collision&&!!this.sceneConfig.collision}isEnableUniquePlacement(){return this.isEnableCollision()&&this.sceneConfig.uniquePlacement}isMeshUniquePlaced(t){return this.isMeshIterable(t)}ds(){if(!this.isEnableUniquePlacement())return;const t=this.scene.getMeshes(),e=(t,e,n,i)=>{const{start:r,end:s}=e[0],o=t.geometry.properties,a=o.elements;let l=o.uniquePlacements;if(l||(l=o.uniquePlacements=[]),void 0===l[i]){const e=this.getUniqueEntryKey(t,a[r],i);l[i]=e?{key:e,index:i,start:a[r],end:a[s-1]}:null}};for(let n=0;n<t.length;n++){const i=t[n];this.isMeshUniquePlaced(i)&&this.forEachBox(i,e)}}ps(t){if(!this.isEnableUniquePlacement())return;const e=this.getMap().getZoom();let n=!this.bs||this.As!==e;if(!n)for(let e=0;e<t.length;e++)if(!this.bs[t[e].properties.meshKey]){n=!0;break}if(!n)return;this.As=e,this.ws={},this.bs={},t=t.sort(wr$2);const i=this.getMap().getGLScale(),r={};for(let e=0;e<t.length;e++){const n=t[e];if(!n.geometry)continue;const{meshKey:s}=n.properties;this.bs[s]=1;const{uniquePlacements:o}=n.geometry.properties;if(o)for(let t=0;t<o.length;t++){if(!o[t])continue;const{key:e,index:s}=o[t],a=this.Wr(n),l=Ar$2(e,i),h=r[l];if(h){const t=h.length,e=h[t-3].properties.meshKey,i=h[t-2],r=h[t-1];this.ws[e]=this.ws[e]||{},this.ws[e][r]=1,this._s(a,s,i,r),h.push(n,a,s)}else r[l]=[n,a,s]}}for(const t in r){const e=r[t];if(e.length<=6)continue;const n=e.length,i=e[n-2][e[n-1]];if(e[1][e[2]]!==i)for(let t=0;t<n-6;t+=3)e[t+1][e[t+2]]=i}}_s(t,e,n,i){if(void 0!==n[i])if(void 0===t[e])t[e]=n[i];else{let r=t[e];Math.abs(n[i])>Math.abs(r)?t[e]=n[i]:n[i]=t[e]}else void 0!==t[e]&&(n[i]=t[e])}jr(t,e){return this.ws&&this.ws[t]&&this.ws[t][e]}Ss(t,e){const{symbolIndex:n}=t.properties,i=n.type||0;let r=t.properties._collidesBoxes;r||(r=t.properties._collidesBoxes=[]);let s=r[n.index];s||(s=t.properties._collidesBoxes=[]),s[i]||(s[i]=[]),s=s[i];const o=e/6;if(!s[o]){const t=[];s[o]={boxes:t,collision:{boxes:t}}}return s[o]}Ms(t){let e=this.Ps;if(e||(e=this.Ps=[]),!e[t]){e[t]=[];for(let n=0;n<t;n++)e[t][n]={}}return e[t]}Ts(t){return!t||!t.geometry||!(!t.geometry.properties.glyphAtlas||!t.material.get("isHalo")||t.geometry.data.aTextHaloRadius&&t.geometry.properties.hasHalo)&&(!(!t.geometry.data.aTextHaloRadius||t.geometry.properties.hasHalo)||!this.getSymbol(t.geometry.properties.symbolIndex).textHaloRadius)}}function Ar$2(t,e){return Math.round(t[0]/e/10)*Math.round(t[1]/e/10)*(t[2]?Math.round(t[2]/10):1)+"-"+t[3]}function wr$2(t,e){const n=e.properties.level-t.properties.level;return 0===n?t.properties.meshKey-e.properties.meshKey:n}function _r$2(t,e,n){return t[0]=e[0]-n,t[1]=e[1]-n,t[2]=e[2]+n,t[3]=e[3]+n,t}var Sr$2="#include <gl2_vert>\n#define SHADER_NAME MARKER\n#define RAD 0.0174532925\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nattribute vec2 aShape;\nattribute vec2 aTexCoord;\n#ifdef ENABLE_COLLISION\nattribute float aOpacity;\n#endif\n#ifdef HAS_OPACITY\nattribute float aColorOpacity;\n#endif\n#ifdef HAS_MARKER_WIDTH\nattribute float aMarkerWidth;\n#else\nuniform float markerWidth;\n#endif\n#ifdef HAS_MARKER_HEIGHT\nattribute float aMarkerHeight;\n#else\nuniform float markerHeight;\n#endif\n#ifdef HAS_MARKER_DX\nattribute float aMarkerDx;\n#else\nuniform float markerDx;\n#endif\n#ifdef HAS_MARKER_DY\nattribute float aMarkerDy;\n#else\nuniform float markerDy;\n#endif\n#if defined(HAS_PITCH_ALIGN)\nattribute float aPitchAlign;\n#else\nuniform float pitchWithMap;\n#endif\n#if defined(HAS_ROTATION_ALIGN)\nattribute float aRotationAlign;\n#else\nuniform float rotateWithMap;\n#endif\nuniform float flipY;\n#ifdef HAS_ROTATION\nattribute float aRotation;\n#else\nuniform float markerRotation;\n#endif\n#ifdef HAS_PAD_OFFSET\nattribute float aPadOffsetX;\nattribute float aPadOffsetY;\n#endif\nuniform float cameraToCenterDistance;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\nuniform float markerPerspectiveRatio;\nuniform vec2 iconSize;\nuniform vec2 texSize;\nuniform vec2 canvasSize;\nuniform float mapPitch;\nuniform float mapRotation;\nuniform float zoomScale;\nuniform float tileRatio;\nuniform float layerScale;\nuniform float isRenderingTerrain;\n#include <vt_position_vert>\n#ifndef PICKING_MODE\nvarying vec2 vTexCoord;\nvarying float vOpacity;\n#include <highlight_vert>\n#else\n#include <fbo_picking_vert>\n#endif\nvoid main() {\n  vec3 c = unpackVTPosition();\n#ifdef HAS_MARKER_WIDTH\nfloat d = aMarkerWidth;\n#else\nfloat d = markerWidth;\n#endif\n#ifdef HAS_MARKER_HEIGHT\nfloat e = aMarkerHeight;\n#else\nfloat e = markerHeight;\n#endif\n#ifdef HAS_MARKER_DX\nfloat f = aMarkerDx;\n#else\nfloat f = markerDx;\n#endif\n#ifdef HAS_MARKER_DY\nfloat h = aMarkerDy;\n#else\nfloat h = markerDy;\n#endif\n#if defined(HAS_PITCH_ALIGN)\nfloat i = aPitchAlign;\n#else\nfloat i = pitchWithMap;\n#endif\n#if defined(HAS_ROTATION_ALIGN)\nfloat j = aRotationAlign;\n#else\nfloat j = rotateWithMap;\n#endif\ngl_Position = projViewModelMatrix * positionMatrix * vec4(c, 1.);\n  float k = gl_Position.w;\n  float l;\n  if(isRenderingTerrain == 1. && i == 1.) {\n    l = 1.;\n  } else {\n    float m = (1. - cameraToCenterDistance / k) * markerPerspectiveRatio;\n    l = clamp(.5 + .5 * (1. - m), .0, 4.);\n  }\n#ifdef HAS_ROTATION\nfloat n = -aRotation / 9362. - mapRotation * j;\n#else\nfloat n = -markerRotation - mapRotation * j;\n#endif\nif(i == 1.) {\n    n += mapRotation;\n  }\n  float o = sin(n);\n  float u = cos(n);\n  mat2 v = mat2(u, -1. * o, o, u);\n  vec2 A = (aShape / 10.0);\n  if(i == 1. && flipY == .0) {\n    A *= vec2(1., -1.);\n  }\n#ifdef HAS_PAD_OFFSET\nA = (A / iconSize * vec2(d, e) + vec2(aPadOffsetX - 1., aPadOffsetY)) * layerScale;\n#else\nA = A / iconSize * vec2(d, e) * layerScale;\n#endif\nA = v * A;\n  if(i == .0) {\n    vec2 B = A * 2. / canvasSize;\n    gl_Position.xy += B * l * k;\n  } else {\n    float C;\n    if(isRenderingTerrain == 1.) {\n      C = 1.;\n    } else {\n      C = k / cameraToCenterDistance;\n    }\n    vec2 B = A;\n    gl_Position = projViewModelMatrix * positionMatrix * vec4(c + vec3(B, .0) * tileRatio / zoomScale * C * l, 1.);\n  }\n  gl_Position.xy += vec2(f, -h) * 2. / canvasSize * k;\n#ifndef PICKING_MODE\nvTexCoord = aTexCoord / texSize;\n#ifdef ENABLE_COLLISION\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity *= aColorOpacity / 255.;\n#endif\nhighlight_setVarying();\n#else\n#ifdef ENABLE_COLLISION\nbool D = aOpacity == 255.;\n#else\nbool D = true;\n#endif\nfbo_picking_setData(gl_Position.w, D);\n#endif\n}";const Mr$2=[],Pr$2=[],Tr$2=[],kr$2=[],Or$2=[],Ir$2=[];function Fr$2(t,e,n,r,s,o,l,u,c,f,d,p,m,y){const{tileRatio:g,tileResolution:v}=c,x=g/(v/f.getResolution())*(d/f.cameraToCenterDistance)*p;scale(n,n,x),scale(r,r,x),scale(s,s,x),scale(o,o,x),set$4(Mr$2,n[0],n[1],m?n[2]/y:0),set$4(Pr$2,r[0],r[1],m?r[2]/y:0),set$4(Tr$2,s[0],s[1],m?s[2]/y:0),set$4(kr$2,o[0],o[1],m?o[2]/y:0),add$4(Mr$2,Mr$2,e),add$4(Pr$2,Pr$2,e),add$4(Tr$2,Tr$2,e),add$4(kr$2,kr$2,e),bi$1(n,Mr$2,l,f.width,f.height),bi$1(r,Pr$2,l,f.width,f.height),bi$1(s,Tr$2,l,f.width,f.height),bi$1(o,kr$2,l,f.width,f.height),set(Or$2,Math.min(n[0],r[0],s[0],o[0]),Math.min(n[1],r[1],s[1],o[1])),set(Ir$2,Math.max(n[0],r[0],s[0],o[0]),Math.max(n[1],r[1],s[1],o[1])),set$3(t,Or$2[0]+u[0],Or$2[1]+u[1],Ir$2[0]+u[0],Ir$2[1]+u[1])}function Cr$2(t,e,n,i,r,s,o,l){1!==l&&(scale(n,n,l),scale(i,i,l),scale(r,r,l),scale(s,s,l)),set(Or$2,Math.min(n[0],i[0],r[0],s[0]),Math.min(n[1],i[1],r[1],s[1])),set(Ir$2,Math.max(n[0],i[0],r[0],s[0]),Math.max(n[1],i[1],r[1],s[1])),set$3(t,e[0]+Or$2[0]+o[0],e[1]+Or$2[1]-o[1],e[0]+Ir$2[0]+o[0],e[1]+Ir$2[1]-o[1])}function Er$2(t,e,n,i,r){e-=n*i,1===r&&(e+=n);const s=Math.sin(e),o=Math.cos(e);return set$8(t,o,-s,s,o)}const Dr$2=[],Rr$2=[],Lr$2=[],Nr$2=[],Hr$2=[],zr$2=[],Vr$2=[],Ur$2=[],jr$2=[1,-1],Br$2=[1,1];function Gr$2(t,e,n,r,s){const o=e.material.uniforms,a=s.cameraToCenterDistance,l=e.geometry.properties,u=this.getSymbol(l.symbolIndex),c=e.geometry.desc.positionSize,f=l.aAnchor,d=set$4(Dr$2,f[n*c],f[n*c+1],2===c?0:f[n*c+2]),{aTerrainAltitude:p}=l;if(p){const t=100*p[2*n];t&&(d[2]+=t)}let m=bi$1(Rr$2,d,r,s.width,s.height);const y=m[2];let g=1;o.markerPerspectiveRatio&&(g=kt$3(.5+.5*(1-(1-a/y)*o.markerPerspectiveRatio),0,4));const{aShape:v,aMarkerDx:x,aMarkerDy:b,aMarkerWidth:A,aMarkerHeight:w,aPitchAlign:_,aRotationAlign:S,aRotation:M}=l,k=_?_[n]:o.pitchWithMap,O=S?S[n]:o.rotateWithMap,I=set(Ur$2,(x?x[n]:u.markerDx)||0,-((b?b[n]:u.markerDy)||0));let F=set(Nr$2,v[2*n]/10,v[2*n+1]/10),C=set(Hr$2,v[2*n+2]/10,v[2*n+3]/10),E=set(zr$2,v[2*n+4]/10,v[2*n+5]/10),D=set(Vr$2,v[2*n+6]/10,v[2*n+7]/10);0===o.flipY&&1===k&&(multiply(F,F,jr$2),multiply(C,C,jr$2),multiply(E,E,jr$2),multiply(D,D,jr$2));const[R,L]=$i$1(e.geometry);let N=A?A[n]:u.markerWidth;It$3(N)&&(N=R||15);let H=w?w[n]:u.markerHeight;It$3(H)&&(H=L||15);const z=set(Br$2,N/2048,H/2048);mul(F,F,z),mul(C,C,z),mul(E,E,z),mul(D,D,z);const V=-(M?M[n]/9362:-(u.markerRotation||0)*Math.PI/180),U=s.getBearing()*Math.PI/180;if(U*O||V){const t=Er$2(Lr$2,V,U,O,k);F=transformMat2(F,F,t),C=transformMat2(C,C,t),E=transformMat2(E,E,t),D=transformMat2(D,D,t)}1===k?Fr$2(t,d,F,C,E,D,r,I,o,s,y,g):(multiply(F,F,jr$2),multiply(C,C,jr$2),multiply(E,E,jr$2),multiply(D,D,jr$2),Cr$2(t,m,F,C,E,D,I,g));const j=this.getMap().getDevicePixelRatio();return 1!==j&&(t[0]*=j,t[1]*=j,t[2]*=j,t[3]*=j),t}const Wr$2=[],Xr$2=[],Yr$2=[],$r$2=[],qr$2=[],Jr$2=[],Kr$2=[1,-1];function Zr$2(t,e,n,r,s,o,a,l,u){const c=r.material.uniforms,f=u.cameraToCenterDistance,d=r.geometry.properties,p=this.getSymbol(d.symbolIndex),m="line"===p.textPlacement&&!zt$2(p),y=n[2];let g=1;c.textPerspectiveRatio&&(g=kt$3(.5+.5*(1-(1-f/y)*c.textPerspectiveRatio),0,4));const{aTextDx:v,aTextDy:x,aPitchAlign:b,aRotationAlign:A,aRotation:w}=r.geometry.properties,M=b?b[a]:c.pitchWithMap,P=A?A[a]:c.rotateWithMap,T=set(Jr$2,(v?v[a]:p.textDx)||0,-((x?x[a]:p.textDy)||0));if(m){const{aOffset:r,aShape:s}=d,o=r.length!==s.length;let f,p,m,v;if(o?(f=set$4(Xr$2,r[3*a]/10,r[3*a+1]/10,r[3*a+2]/10),p=set$4(Yr$2,r[3*a+3]/10,r[3*a+4]/10,r[3*a+5]/10),m=set$4($r$2,r[3*a+6]/10,r[3*a+7]/10,r[3*a+8]/10),v=set$4(qr$2,r[3*a+9]/10,r[3*a+10]/10,r[3*a+11]/10)):(f=set(Xr$2,r[2*a]/10,r[2*a+1]/10),p=set(Yr$2,r[2*a+2]/10,r[2*a+3]/10),m=set($r$2,r[2*a+4]/10,r[2*a+5]/10),v=set(qr$2,r[2*a+6]/10,r[2*a+7]/10)),1===M){const n=lt$3(u.getResolution(),u);Fr$2(t,e,f,p,m,v,l,T,c,u,y,g,o,n)}else multiply(f,f,Kr$2),multiply(p,p,Kr$2),multiply(m,m,Kr$2),multiply(v,v,Kr$2),Cr$2(t,n,f,p,m,v,T,g)}else{const{aShape:i}=d;let r=set(Xr$2,i[2*a]/10,-i[2*a+1]/10),o=set(Yr$2,i[2*a+2]/10,-i[2*a+3]/10),f=set($r$2,i[2*a+4]/10,-i[2*a+5]/10),v=set(qr$2,i[2*a+6]/10,-i[2*a+7]/10);0===c.flipY&&1===M&&(multiply(r,r,Kr$2),multiply(o,o,Kr$2),multiply(f,f,Kr$2),multiply(v,v,Kr$2));const x=w?w[a]/9362:(p.textRotation||0)*Math.PI/180,b=m?0:u.getBearing()*Math.PI/180;if(x||b){const t=Er$2(Wr$2,x,b,P,M);r=transformMat2(r,r,t),o=transformMat2(o,o,t),f=transformMat2(f,f,t),v=transformMat2(v,v,t)}const A=s/24;scale(r,r,A),scale(o,o,A),scale(f,f,A),scale(v,v,A),1===M?Fr$2(t,e,r,o,f,v,l,T,c,u,y,g):Cr$2(t,n,r,o,f,v,T,g)}t[0]-=(o=o||0)+1,t[1]-=o+1,t[2]+=o+1,t[3]+=o+1;const k=this.getMap().getDevicePixelRatio();return 1!==k&&(t[0]*=k,t[1]*=k,t[2]*=k,t[3]*=k),t}function Qr$2(t,e,n){const r=e.geometry.desc.positionSize,{aAnchor:s,aAltitude:o,aTerrainAltitude:a}=e.geometry.properties,l=n*r;if(o?set$4(t,s[l],s[l+1],o[n]):3===r?Fa.unpackPosition(t,s[l],s[l+1],s[l+2]):set$4(t,s[l],s[l+1],0),a){const e=100*a[2*n];e&&(t[2]+=e)}return t}const ts$2={textFill:[0,0,0,1],textOpacity:1,textPitchAlignment:0,textRotationAlignment:0,textHaloRadius:0,textHaloFill:[1,1,1,1],textHaloBlur:0,textHaloOpacity:1,textPerspectiveRatio:0,textSize:14,textDx:0,textDy:0,textRotation:0};function es$2(t,e,i,r,s,o,a,l,h){const u=[];if(e.isDisposed()||0===e.data.aPosition.length)return u;const c=e.properties.glyphAtlas;if(!c)return u;if(0===r.textSize||0===r.textOpacity)return u;if(si$1(e,r,o),!e.properties.aCount){ns$2.call(this,e,a||h,l);const{aTextSize:t,aTextDx:n,aTextDy:i,aPitchAlign:r,aRotationAlign:s,aRotation:o,aOverlap:u,aAltitude:c}=e.data;if(t){const n=(ri$1+"aTextSize").trim();e.properties.aTextSize=e.properties[n]||new t.constructor(t)}if(n){const t=(ri$1+"aTextDx").trim();e.properties.aTextDx=e.properties[t]||new n.constructor(n)}if(i){const t=(ri$1+"aTextDy").trim();e.properties.aTextDy=e.properties[t]||new i.constructor(i)}if(r){const t=(ri$1+"aPitchAlign").trim();e.properties.aPitchAlign=e.properties[t]||new r.constructor(r)}if(s){const t=(ri$1+"aRotationAlign").trim();e.properties.aRotationAlign=e.properties[t]||new s.constructor(s)}if(o){const t=(ri$1+"aRotation").trim();e.properties.aRotation=e.properties[t]||new o.constructor(o)}if(u){const t=(ri$1+"aOverlap").trim();e.properties.aOverlap=e.properties[t]||new u.constructor(u)}if(c){const t=(ri$1+"aAltitude").trim();e.properties.aAltitude=e.properties[t]||new c.constructor(c)}}const f=Wi$1(t,c,!1),d={flipY:0,tileResolution:e.properties.tileResolution,tileRatio:e.properties.tileRatio,texture:f,texSize:[c.width,c.height]};is$2(e,d,s);let p=!1;s.textOpacity<1&&(p=!0),e.properties.memorySize=e.getMemorySize(),e.generateBuffers(t,{excludeElementsInVAO:!0});const m=new Ce$5(d,ts$2),y=new Be$5(e,m,{disableVAO:!0,transparent:p,castShadow:!1,picking:!0});if(y.setLocalTransform(i),y.setUniform("alphaTest",.01),d.isHalo&&(y.properties.isHalo=!0),a&&y.setDefines({ENABLE_COLLISION:1}),u.push(y),d.isHalo){const t={flipY:0,tileResolution:e.properties.tileResolution,tileRatio:e.properties.tileRatio,texture:f,texSize:[c.width,c.height],isHalo:0};is$2(e,t,s);const r=new Ce$5(t,ts$2),o=new Be$5(e,r,{disableVAO:!0,transparent:p,castShadow:!1,picking:!0});o.setUniform("alphaTest",.01),o.properties.haloMesh=y,Object.defineProperty(o.properties,"textSize",{enumerable:!0,get:function(){return t.textSize}}),a&&o.setDefines({ENABLE_COLLISION:1}),o.setLocalTransform(i),u.push(o)}return u.forEach((t=>{const n=t.defines||{};e.data.aTextFill&&(n.HAS_TEXT_FILL=1),e.data.aTextSize&&(n.HAS_TEXT_SIZE=1),e.data.aColorOpacity&&(n.HAS_OPACITY=1),e.data.aTextHaloFill&&t.material.uniforms.isHalo&&(n.HAS_TEXT_HALO_FILL=1),e.data.aTextHaloRadius&&t.material.uniforms.isHalo&&(n.HAS_TEXT_HALO_RADIUS=1),e.data.aTextHaloOpacity&&t.material.uniforms.isHalo&&(n.HAS_TEXT_HALO_OPACITY=1),e.data.aTextDx&&(n.HAS_TEXT_DX=1),e.data.aTextDy&&(n.HAS_TEXT_DY=1),e.data.aPitchAlign&&(n.HAS_PITCH_ALIGN=1),e.data.aRotationAlign&&(n.HAS_ROTATION_ALIGN=1),e.data.aRotation&&(n.HAS_ROTATION=1),e.data.aAltitude&&(n.HAS_ALTITUDE=1),e.properties.aOffset&&e.properties.aShape&&e.properties.aOffset.length!==e.properties.aShape.length&&(n.HAS_OFFSET_Z=1),t.setDefines(n),t.properties.symbolIndex=e.properties.symbolIndex})),u}function ns$2(t,e,n){const i=this.getSymbol(t.properties.symbolIndex),r="line"===t.properties.textPlacement&&!zt$2(i),{aPosition:s,aShape:o}=t.data,a=s.length/t.desc.positionSize;if(t.properties.aPickingId=t.data.aPickingId,t.properties.aCount=t.data.aCount,delete t.data.aCount,(e||r)&&(t.properties.aAnchor=s,t.properties.aShape=o),t.properties.visElemts||(t.properties.elements=t.elements,t.properties.visElemts=new t.elements.constructor(t.elements.length)),r){const{aVertical:e,aSegment:n,aGlyphOffset:i,aPitchRotation:r}=t.data,s=!!r;t.properties.aGlyphOffset=i,t.properties.aPitchRotation=r,t.properties.aSegment=n,t.properties.aVertical=e,delete t.data.aSegment,delete t.data.aVertical,delete t.data.aGlyphOffset,delete t.data.aPitchRotation;const a=o.length/2*(s?3:2);t.data.aOffset={usage:"dynamic",data:new Int16Array(a)},t.properties.aOffset=new Int16Array(a)}if(e){t.data.aOpacity={usage:"dynamic",data:new Uint8Array(a)},t.properties.aOpacity=new Uint8Array(a),n&&(t.properties.aOpacity.fill(255,0),t.data.aOpacity.data.fill(255,0));const{aTextHaloRadius:e}=t.data;if(e&&!t.properties.aTextHaloRadius){const n=(ri$1+"aTextHaloRadius").trim();t.properties.aTextHaloRadius=t.properties[n]||new e.constructor(e)}}}function is$2(t,e,n){void 0===e.isHalo&&(e.isHalo=1),Ct$3(e,"textOpacity",n,"textOpacity",ts$2.textOpacity),Ct$3(e,"textFill",n,"textFill",ts$2.textFill,Rt$3()),Ct$3(e,"textHaloFill",n,"textHaloFill",ts$2.textHaloFill,Rt$3()),Ct$3(e,"textHaloBlur",n,"textHaloBlur",ts$2.textHaloBlur),Ct$3(e,"textHaloRadius",n,"textHaloRadius",ts$2.textHaloRadius),Ct$3(e,"textHaloOpacity",n,"textHaloOpacity",ts$2.textHaloOpacity),Ct$3(e,"textPerspectiveRatio",n,"textPerspectiveRatio",ts$2.textPerspectiveRatio,(e=>"line"===t.properties.textPlacement?1:e)),Ct$3(e,"rotateWithMap",n,"textRotationAlignment",ts$2.textRotationAlignment,(t=>+("map"===t))),Ct$3(e,"pitchWithMap",n,"textPitchAlignment",ts$2.textPitchAlignment,(t=>+("map"===t))),Ct$3(e,"textSize",n,"textSize",ts$2.textSize),Ct$3(e,"textDx",n,"textDx",ts$2.textDx),Ct$3(e,"textDy",n,"textDy",ts$2.textDy),Ct$3(e,"textRotation",n,"textRotation",ts$2.textRotation,(t=>t*Math.PI/180))}function rs$2(t,e){const n=[];return{uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5(n,e.projViewMatrix,e.modelMatrix)}},{name:"zoomScale",type:"function",fn:function(t,e){return e.tileResolution/e.resolution}}],extraCommandProps:{viewport:{x:0,y:0,width:()=>t?t.width:1,height:()=>t?t.height:1},stencil:{enable:!1,mask:255,func:{cmp:"<",ref:(t,e)=>2*e.level+(e.isHalo||0)+1,mask:255},op:{fail:"keep",zfail:"keep",zpass:"replace"}},blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:e.depthRange||[0,1],func:e.depthFunc||"always",mask:!1},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}}}function ss$2(t,e){const n=interpolated(e.textFill),i=interpolated(e.textSize),r=interpolated(e.textHaloFill),s=interpolated(e.textHaloRadius),o=interpolated(e.textHaloOpacity),a=interpolated(e.textDx),l=interpolated(e.textDy),h=interpolated(e.textOpacity),u=piecewiseConstant(e.textPitchAlignment),c=piecewiseConstant(e.textRotationAlignment),f=interpolated(e.textRotation),d=piecewiseConstant(e.textAllowOverlapFn),m=piecewiseConstant(e.textIgnorePlacement),v={},x=new Int16Array(1),b=new Uint16Array(1);return[{attrName:"aTextFill",symbolName:"textFill",define:"HAS_TEXT_FILL",type:Uint8Array,width:4,evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=v[r]=v[r]||color(r).unitArray()),r=Dt$3(r),r}},{attrName:"aTextSize",symbolName:"textSize",define:"HAS_TEXT_SIZE",type:Uint8Array,width:1,evaluate:(e,n)=>{let r=i(t.getZoom(),e)||ts$2.textSize;return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,n,t,e)),x[0]=r,x[0]}},{attrName:"aTextHaloFill",symbolName:"textHaloFill",define:"HAS_TEXT_HALO_FILL",type:Uint8Array,width:4,evaluate:e=>{let n=r(t.getZoom(),e);return Array.isArray(n)||(n=v[n]=v[n]||color(n).unitArray()),n=Dt$3(n),n}},{attrName:"aTextHaloRadius",symbolName:"textHaloRadius",define:"HAS_TEXT_HALO_RADIUS",type:Uint8Array,width:1,evaluate:e=>{const n=s(t.getZoom(),e);return x[0]=n,x[0]}},{attrName:"aTextHaloOpacity",symbolName:"textHaloOpacity",define:"HAS_TEXT_HALO_OPACITY",type:Uint8Array,width:1,evaluate:e=>{const n=o(t.getZoom(),e);return x[0]=n,x[0]}},{attrName:"aTextDx",symbolName:"textDx",define:"HAS_TEXT_DX",type:Uint8Array,width:1,evaluate:(e,n)=>{let i=a(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),x[0]=i,x[0]}},{attrName:"aTextDy",symbolName:"textDy",define:"HAS_TEXT_DY",type:Uint8Array,width:1,evaluate:(e,n)=>{let i=l(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),x[0]=i,x[0]}},{attrName:"aColorOpacity",symbolName:"textOpacity",define:"HAS_OPACITY",type:Uint8Array,width:1,evaluate:(e,n)=>{let i=h(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),x[0]=255*i,x[0]}},{attrName:"aPitchAlign",symbolName:"textPitchAlignment",type:Uint8Array,width:1,define:"HAS_PITCH_ALIGN",evaluate:e=>+("map"===u(t.getZoom(),e))},{attrName:"aRotationAlign",symbolName:"textRotationAlignment",type:Uint8Array,width:1,define:"HAS_ROTATION_ALIGN",evaluate:e=>+("map"===c(t.getZoom(),e))},{attrName:"aRotation",symbolName:"textRotation",type:Uint16Array,width:1,define:"HAS_ROTATION",evaluate:e=>{const n=Ot$3(f(t.getZoom(),e),0,360)*Math.PI/180;return b[0]=9362*n,b[0]}},{attrName:"aOverlap",symbolName:"textAllowOverlap",type:Uint8Array,width:1,evaluate:n=>{let i=d(t.getZoom(),n)||0,r=(m?m(t.getZoom(),n):e.textIgnorePlacement)||0;return i=1<<3+4*i,r=(m?2:0)+r,i+r}},{attrName:"aOverlap",symbolName:"textIgnorePlacement",type:Uint8Array,width:1,evaluate:n=>{let i=(d?d(t.getZoom(),n):e.textAllowOverlap)||0,r=m(t.getZoom(),n)||0;return i=(d?8:0)+4*i,r=1<<1+r,i+r}}]}const os$2=[],as$2=[],ls$2=[],hs$2=[];function us$2(t,e,n,i,r,s,o){t=1===t?1:0;const a=this.getMap(),l=e.geometry.properties,h=this.getSymbol(l.symbolIndex),u="line"===l.textPlacement&&!zt$2(h),{aTextSize:c,aTextHaloRadius:f,aShape:d}=l;let p=c?c[n[r]]:e.properties.textSize;null==p&&(p=ts$2.textSize);const m=f?f[n[r]]:e.properties.textHaloRadius,y=Qr$2(ls$2,e,n[r]),{aProjectedAnchor:g}=e.geometry.properties;let v=hs$2;const x=3*n[r];g&&-999999!==g[x]?(hs$2[0]=g[x],hs$2[1]=g[x+1],hs$2[2]=g[x+2]):v=bi$1(hs$2,y,o,a.width,a.height);const b=i,{boxes:A,collision:w}=this.Ss(e,r);let _=0;if(u||1===e.material.uniforms.rotateWithMap||h.textRotation){let i=0;for(let s=r;s<r+6*b;s+=6){const r=A[_]=A[_]||[];_++;const l=Zr$2.call(this,r,y,v,e,p,m,n[s],o,a);if(!t){const e=this.isCollides(l);1===e?t=1:-1===e&&i++}}i===b&&(t=-1)}else{let i=n[r],l=d[2*i+1];for(let h=r;h<s;h+=6){const r=d[2*n[h]+1];if(l!==r||h===s-6){const u=n[h===s-6?h:h-6],c=Zr$2.call(this,os$2,y,v,e,p,m,i,o,a),f=Zr$2.call(this,as$2,y,v,e,p,m,u,o,a),d=A[_]=A[_]||[];_++,d[0]=Math.min(c[0],f[0]),d[1]=Math.min(c[1],f[1]),d[2]=Math.max(c[2],f[2]),d[3]=Math.max(c[3],f[3]),i=n[h],l=r,!t&&this.isCollides(d)&&(t=1)}}}return w.collides=t,w}function cs$2(t,e){const n=function(t,e){const{aPickingId:n,features:i}=t.geometry.properties,r=n[e];return(i&&i[r]&&i[r].feature).label}(t,e);return n?function(t,e,n){if(!n)return null;const i=t.localTransform,r=Qr$2(fs$2,t,e);set$3(ds$2,r[0],r[1],r[2],1);const s=transformMat4$1(ds$2,ds$2,i);let o=0;for(let t=0;t<n.length;t++)o+=n.charCodeAt(t);return[Math.floor(s[0]),Math.floor(s[1]),Math.floor(s[2]),o]}(t,e,n):null}const fs$2=[],ds$2=[];var ps$2="#define SHADER_NAME TEXT_VERT\n#define RAD 0.0174532925\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nattribute vec2 aShape;\nattribute vec2 aTexCoord;\n#ifdef ENABLE_COLLISION\nattribute float aOpacity;\n#endif\n#ifdef HAS_OPACITY\nattribute float aColorOpacity;\n#endif\n#ifdef HAS_TEXT_SIZE\nattribute float aTextSize;\n#else\nuniform float textSize;\n#endif\n#ifdef HAS_TEXT_DX\nattribute float aTextDx;\n#else\nuniform float textDx;\n#endif\n#ifdef HAS_TEXT_DY\nattribute float aTextDy;\n#else\nuniform float textDy;\n#endif\n#if defined(HAS_PITCH_ALIGN)\nattribute float aPitchAlign;\n#else\nuniform float pitchWithMap;\n#endif\n#if defined(HAS_ROTATION_ALIGN)\nattribute float aRotationAlign;\n#else\nuniform float rotateWithMap;\n#endif\nuniform float flipY;\n#if defined(HAS_ROTATION)\nattribute float aRotation;\n#else\nuniform float textRotation;\n#endif\nuniform float cameraToCenterDistance;\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\nuniform float textPerspectiveRatio;\nuniform vec2 texSize;\nuniform vec2 canvasSize;\nuniform float glyphSize;\nuniform float mapPitch;\nuniform float mapRotation;\nuniform float zoomScale;\nuniform float tileRatio;\nuniform float layerScale;\nuniform float isRenderingTerrain;\n#ifndef PICKING_MODE\nvarying vec2 vTexCoord;\nvarying float vGammaScale;\nvarying float vSize;\nvarying float vOpacity;\n#ifdef HAS_TEXT_FILL\nattribute vec4 aTextFill;\nvarying vec4 vTextFill;\n#endif\n#ifdef HAS_TEXT_HALO_FILL\nattribute vec4 aTextHaloFill;\nvarying vec4 vTextHaloFill;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nattribute float aTextHaloRadius;\nvarying float vTextHaloRadius;\n#endif\n#ifdef HAS_TEXT_HALO_OPACITY\nattribute float aTextHaloOpacity;\nvarying float vTextHaloOpacity;\n#endif\n#include <highlight_vert>\n#else\n#include <fbo_picking_vert>\n#endif\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n#ifdef HAS_TEXT_SIZE\nfloat d = aTextSize * layerScale;\n#else\nfloat d = textSize * layerScale;\n#endif\n#ifdef HAS_TEXT_DX\nfloat e = aTextDx;\n#else\nfloat e = textDx;\n#endif\n#ifdef HAS_TEXT_DY\nfloat f = aTextDy;\n#else\nfloat f = textDy;\n#endif\n#if defined(HAS_PITCH_ALIGN)\nfloat h = aPitchAlign;\n#else\nfloat h = pitchWithMap;\n#endif\n#if defined(HAS_ROTATION_ALIGN)\nfloat i = aRotationAlign;\n#else\nfloat i = rotateWithMap;\n#endif\nvec2 j = aShape / 10.0;\n  if(h == 1. && flipY == .0) {\n    j = j * vec2(1., -1.);\n  }\n  vec2 k = aTexCoord;\n  gl_Position = projViewModelMatrix * positionMatrix * vec4(c, 1.);\n  float l = gl_Position.w;\n  float m;\n  if(isRenderingTerrain == 1. && h == 1.) {\n    m = 1.;\n  } else {\n    float n = (1. - cameraToCenterDistance / l) * textPerspectiveRatio;\n    m = clamp(.5 + .5 * (1. - n), .0, 4.);\n  }\n#ifdef HAS_ROTATION\nfloat o = -aRotation / 9362. - mapRotation * i;\n#else\nfloat o = -textRotation - mapRotation * i;\n#endif\nif(h == 1.) {\n    \n#ifdef REVERSE_MAP_ROTATION_ON_PITCH\no += mapRotation;\n#else\no -= mapRotation;\n#endif\n  }\n  float u = sin(o);\n  float v = cos(o);\n  mat2 A = mat2(v, -1. * u, u, v);\n  j = A * (j / glyphSize * d);\n  float B;\n  if(isRenderingTerrain == 1.) {\n    B = 1.;\n  } else {\n    B = l / cameraToCenterDistance;\n  }\n  if(h == .0) {\n    vec2 C = j * 2. / canvasSize;\n    gl_Position.xy += C * m * l;\n  } else {\n    float D;\n    if(isRenderingTerrain == 1.) {\n      D = tileRatio / zoomScale;\n    } else {\n      D = tileRatio / zoomScale * B * m;\n    }\n    vec2 C = j;\n    gl_Position = projViewModelMatrix * positionMatrix * vec4(c + vec3(C, .0) * D, 1.);\n  }\n  gl_Position.xy += vec2(e, -f) * 2. / canvasSize * l;\n#ifndef PICKING_MODE\nif(h == .0) {\n    vGammaScale = mix(1., B, textPerspectiveRatio);\n  } else {\n    vGammaScale = B + mapPitch / 4.;\n  }\n  vTexCoord = k / texSize;\n  vGammaScale = clamp(vGammaScale, .0, 1.);\n  vSize = d;\n#ifdef ENABLE_COLLISION\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity *= aColorOpacity / 255.;\n#endif\n#ifdef HAS_TEXT_FILL\nvTextFill = aTextFill / 255.;\n#endif\n#ifdef HAS_TEXT_HALO_FILL\nvTextHaloFill = aTextHaloFill / 255.;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nvTextHaloRadius = aTextHaloRadius;\n#endif\n#ifdef HAS_TEXT_HALO_OPACITY\nvTextHaloOpacity = aTextHaloOpacity;\n#endif\nhighlight_setVarying();\n#else\n#ifdef ENABLE_COLLISION\nbool E = aOpacity == 255.;\n#else\nbool E = true;\n#endif\nfbo_picking_setData(gl_Position.w, E);\n#endif\n}",ms$2="#define SHADER_NAME TEXT_FRAG\n#define HAS_HIGHLIGHT_COLOR_POINT 1\n#define SDF_PX 8.0\n#define DEVICE_PIXEL_RATIO 1.0\n#define EDGE_GAMMA 0.105 / DEVICE_PIXEL_RATIO\nprecision mediump float;\nuniform sampler2D texture;\nuniform float textOpacity;\nuniform highp float gammaScale;\nuniform int isHalo;\nuniform highp float textHaloBlur;\nuniform float alphaTest;\n#ifdef HAS_TEXT_HALO_OPACITY\nvarying float vTextHaloOpacity;\n#else\nuniform float textHaloOpacity;\n#endif\nuniform float layerOpacity;\nvarying vec2 vTexCoord;\nvarying float vSize;\nvarying float vGammaScale;\nvarying float vOpacity;\n#ifdef HAS_TEXT_FILL\nvarying vec4 vTextFill;\n#else\nuniform vec4 textFill;\n#endif\n#ifdef HAS_TEXT_HALO_FILL\nvarying vec4 vTextHaloFill;\n#else\nuniform vec4 textHaloFill;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nvarying float vTextHaloRadius;\n#else\nuniform highp float textHaloRadius;\n#endif\n#include <highlight_frag>\nvoid main() {\n  \n#ifdef HAS_TEXT_FILL\nvec4 c = vTextFill;\n#else\nvec4 c = textFill;\n#endif\nfloat d = vSize / 24.;\n  lowp vec4 e = c;\n  highp float f = EDGE_GAMMA / (d * gammaScale);\n  lowp float h = 185. / 256.;\n  if(isHalo == 1) {\n    \n#ifdef HAS_TEXT_HALO_FILL\nvec4 i = vTextHaloFill;\n#else\nvec4 i = textHaloFill;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nfloat j = vTextHaloRadius;\n#else\nfloat j = textHaloRadius;\n#endif\ne = i;\n    f = (textHaloBlur * 1.19 / SDF_PX + EDGE_GAMMA) / (d * gammaScale);\n    h = (6. - j / d) / SDF_PX;\n#ifdef HAS_TEXT_HALO_OPACITY\nfloat k = vTextHaloOpacity / 255.;\n#else\nfloat k = textHaloOpacity;\n#endif\ne *= k * 1.25;\n  }\n  float l = texture2D(texture, vTexCoord).a;\n  highp float m = f * vGammaScale * .7;\n  float n = clamp(smoothstep(h - m, h + m, l), .0, 1.);\n  gl_FragColor = e * (n * textOpacity * vOpacity * layerOpacity);\n  if(gl_FragColor.a < alphaTest) {\n    discard;\n  }\n  gl_FragColor = highlight_blendColor(gl_FragColor);\n}";const ys$2=new Uint16Array(1),gs$2=new Int8Array(1);function xs$1(t,e){const n=interpolated(e.markerWidth),i=interpolated(e.markerHeight),r=interpolated(e.markerDx),s=interpolated(e.markerDy),o=interpolated(e.markerOpacity),a=interpolated(e.markerTextFit),l=piecewiseConstant(e.markerPitchAlignment),h=piecewiseConstant(e.markerRotationAlignment),u=interpolated(e.markerRotation),c=piecewiseConstant(e.markerAllowOverlapFn),f=piecewiseConstant(e.markerIgnorePlacement),d=new Int16Array(1),m=new Uint16Array(1);return[{attrName:"aMarkerWidth",symbolName:"markerWidth",type:Uint16Array,width:1,define:"HAS_MARKER_WIDTH",evaluate:(i,r,s,o)=>{const l=s[o],h=e.markerTextFit,u=a?a(t.getZoom(),i):h;if("both"===u||"width"===u)return l;let c=n(t.getZoom(),i);return isFunctionDefinition(c)&&(c=this.evaluateInFnTypeConfig(c,r,t,i)),d[0]=c,d[0]}},{attrName:"aMarkerHeight",symbolName:"markerHeight",type:Uint16Array,width:1,define:"HAS_MARKER_HEIGHT",evaluate:(n,r,s,o)=>{const l=s[o],h=e.markerTextFit,u=a?a(t.getZoom(),n):h;if("both"===u||"height"===u)return l;let c=i(t.getZoom(),n);return isFunctionDefinition(c)&&(c=this.evaluateInFnTypeConfig(c,r,t,n)),d[0]=c,d[0]}},{attrName:"aMarkerDx",symbolName:"markerDx",type:Uint8Array,width:1,define:"HAS_MARKER_DX",evaluate:(e,n)=>{let i=r(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),d[0]=i,d[0]}},{attrName:"aMarkerDy",symbolName:"markerDy",type:Uint8Array,width:1,define:"HAS_MARKER_DY",evaluate:(e,n)=>{let i=s(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),d[0]=i,d[0]}},{attrName:"aColorOpacity",symbolName:"markerOpacity",type:Uint8Array,width:1,define:"HAS_OPACITY",evaluate:(e,n)=>{let i=o(t.getZoom(),e);return isFunctionDefinition(i)&&(i=this.evaluateInFnTypeConfig(i,n,t,e)),d[0]=255*i,d[0]}},{attrName:"aPitchAlign",symbolName:"markerPitchAlignment",type:Uint8Array,width:1,define:"HAS_PITCH_ALIGN",evaluate:e=>+("map"===l(t.getZoom(),e))},{attrName:"aRotationAlign",symbolName:"markerRotationAlignment",type:Uint8Array,width:1,define:"HAS_ROTATION_ALIGN",evaluate:e=>+("map"===h(t.getZoom(),e))},{attrName:"aRotation",symbolName:"markerRotation",type:Uint16Array,width:1,define:"HAS_ROTATION",evaluate:e=>{const n=Ot$3(u(t.getZoom(),e),0,360)*Math.PI/180;return m[0]=9362*n,m[0]}},{attrName:"aOverlap",symbolName:"markerAllowOverlap",type:Uint8Array,width:1,evaluate:n=>{let i=c(t.getZoom(),n)||0,r=(f?f(t.getZoom(),n):e.markerIgnorePlacement)||0;return i=1<<3+4*i,r=(f?2:0)+r,i+r}},{attrName:"aOverlap",symbolName:"markerIgnorePlacement",type:Uint8Array,width:1,evaluate:n=>{let i=(c?c(t.getZoom(),n):e.markerAllowOverlap)||0,r=f(t.getZoom(),n)||0;return i=(c?8:0)+4*i,r=2+r,i+r}}]}function bs$2(t,e,n,i){if(!n||!i||"none"===i)return;const r=function(t,e,n){let i=t.properties.textFitFn;isFunctionDefinition(n)&&(i=t.properties.textFitFn=piecewiseConstant(n));const r="none"!==n,s=[],o=t.getElements(),a=t.data.aPickingId;let l,h,u;e&&(l=e.getElements(),h=e.data.aPickingId,u=e.data.aCount);const c=t.properties.features;let f;if(e){let t=l[0];f={pickingId:h[t],start:0,end:6*u[t]}}let d=!1,m=!1,g=0;const v=new Set;for(let t=0;t<o.length;t+=6){const p=a[o[t]];if(!d&&f)for(;f.pickingId<p&&f.end<l.length;){const t=f.end,e=l[t];f.start=t,f.end=t+6*u[e],f.pickingId=h[e]}if(!d&&f&&f.pickingId<p&&(d=!0,!r)){if(!m)return[];for(let e=t;e<o.length;e+=6)s[g++]=[-1,-1];return s}const y=c[p]&&c[p].feature,x=y&&y.properties||{},b=i?i(null,x):n;if(f&&p===f.pickingId){s[g++]=[f.start,f.end];const t=f.end,e=l[t];f.start=t,f.end=t+6*u[e],f.pickingId=h[e],m=!0}else if(b&&"none"!==b)for(let e=t;e<t+6;e++)v.add(e);else s[g++]=[-1,-1]}if(v.size)if(v.size===o.length)t.setElements([]);else{const e=[];for(let t=0;t<o.length;t++)v.has(t)||e.push(o[t]);t.setElements(new o.constructor(e))}return m?s:[]}(e,n,i);if(e.getElements().length&&r.length&&(e.properties.labelIndex=r,r.length&&i&&"none"!==i&&n)){const i=function(t,e){const n=[],i=t.properties.labelIndex,{aShape:r}=e.data;let s=!1;for(let t=0;t<i.length;t++){const[o,a]=i[t];if(-1===o)n.push(0,0,0,0);else{s=!0;let t=1/0,i=1/0,l=-1/0,h=-1/0;const u=e.elements;for(let e=o;e<a;e++){const n=u[e],s=r[2*n],o=r[2*n+1];s<t&&(t=s),s>l&&(l=s),o<i&&(i=o),o>h&&(h=o)}n.push(t,i,l,h)}}return s?n:[]}(e,n);i.length&&(e.properties.labelShape=i,As$1.call(this,t,e,n))}}function As$1(t,e){const n=this.getSymbolDef(e.properties.symbolIndex),i=n.markerTextFit,r=e.properties;let s="both"===i||"width"===i,o="both"===i||"height"===i;if(isFunctionDefinition(n.markerTextFit)){let t=e.properties.textFitFn;t||(t=e.properties.textFitFn=interpolated(n.markerTextFit));const{features:i}=e.properties,a=e.properties.elements||e.elements,{aPickingId:l}=e.data,h=[],u=[];let c=!0;for(let e=0;e<a.length;e+=6){const n=i[l[a[e]]],r=(n&&n.feature||{}).properties||{};let s=t(null,r);isFunctionDefinition(s)&&(s=(r.textFitFn=r.textFitFn||interpolated(s))(null,r)),"both"===s?(h.push(e/6),u.push(e/6)):"width"===s?(c=!1,h.push(e/6)):"height"===s&&(c=!1,u.push(e/6))}c?(r.fitIcons=h,s=!0,o=!0):(h.length&&(r.fitWidthIcons=h,s=!0),u.length&&(r.fitHeightIcons=u,o=!0))}r.aPickingId||(r.aPickingId=new e.data.aPickingId.constructor(e.data.aPickingId));const{aMarkerWidth:a,aMarkerHeight:l,aPickingId:h}=r,u=h.length;if(s)if(a){const t=e.data.aMarkerWidth;e.data.aMarkerWidth=new Uint16Array(t),r.aMarkerWidth=new Uint16Array(t);const n=(ri$1+"aMarkerWidth").trim();r[n]&&(r[n]=r.aMarkerWidth)}else{const t=this.getSymbol(e.properties.symbolIndex).markerWidth||0;r.aMarkerWidth=new Uint16Array(u),r.aMarkerWidth.fill(t),t&&(r.aMarkerWidth.dirty=!0),e.data.aMarkerWidth=new Uint16Array(u)}if(o)if(l){const t=e.data.aMarkerHeight;e.data.aMarkerHeight=new Uint16Array(t),r.aMarkerHeight=new Uint16Array(t);const n=(ri$1+"aMarkerHeight").trim();r[n]&&(r[n]=r.aMarkerHeight)}else{const t=this.getSymbol(e.properties.symbolIndex).markerHeight||0;r.aMarkerHeight=new Uint16Array(u),r.aMarkerHeight.fill(t),t&&(r.aMarkerHeight.dirty=!0),e.data.aMarkerHeight=new Uint16Array(u)}const c=this.getSymbolDef(e.properties.textGeo.properties.symbolIndex),f=interpolated(c.textSize);_s$1.call(this,t,e),(!isFunctionDefinition(c.textSize)||f.isZoomConstant&&f.isFeatureConstant)&&(r.isFitConstant=!0)}const ws$2=[0,0,0,0];function _s$1(t,e){const n=e.properties.textGeo;if(!n)return;const i=n.properties,r=e.properties;if(r.isFitConstant||!r.labelShape||!r.labelShape.length)return;const s=this.getSymbolDef(e.properties.symbolIndex),o=this.getSymbolDef(n.properties.symbolIndex).textSize;let a;isFunctionDefinition(o)&&(a=i.ks?i.ks:i.ks=interpolated(o));const l=s.markerTextFitPadding||ws$2;let h;isFunctionDefinition(l)&&(h=r.Os?r.Os:r.Os=piecewiseConstant(l));const u=t.getZoom(),{fitIcons:c,fitWidthIcons:f,fitHeightIcons:d}=r,{aMarkerWidth:m,aMarkerHeight:v,labelShape:x}=r,b=r.elements||e.elements,{features:A,aPickingId:w}=r,_=(t,e,n,i)=>{const s=x[4*e],c=x[4*e+1],f=x[4*e+2],d=x[4*e+3];if(!(s||c||f||d))return;const b=w[t],_=A[b]&&A[b].feature,S=_&&_.properties||{};let M=a?a(u,S):o;isFunctionDefinition(M)&&(M=(S.textSizeFn=S.textSizeFn||interpolated(M))(u,S)),M/=24;let P,T,k=h&&h(u,S)||l;if(isFunctionDefinition(k)&&(k=(S.fitPaddingFn=S.fitPaddingFn||piecewiseConstant(k))(u,S)),k=k||ws$2,k[0]===k[2]&&k[1]===k[3]||(P=r.aPadOffsetX,T=r.aPadOffsetY,P||(P=r.aPadOffsetX=new Int8Array(m.length),T=r.aPadOffsetY=new Int8Array(m.length))),m&&n){const e=Math.abs((f-s)/10*M)+(k[1]+k[3]||0);if(ys$2[0]=e,m[t]!==ys$2[0]&&(Nt$3(m,ys$2[0],t,t+4),m.dirty=!0),P){const e=(k[1]+k[3])/2-k[3];gs$2[0]=e,P[t]!==gs$2[0]&&(Nt$3(P,e,t,t+4),P.dirty=!0)}}if(v&&i){const e=Math.abs((d-c)/10*M)+(k[0]+k[2]||0);if(ys$2[0]=e,v[t]!==ys$2[0]&&(Nt$3(v,ys$2[0],t,t+4),v.dirty=!0),T){const e=k[0]-(k[0]+k[2])/2;gs$2[0]=e,T[t]!==gs$2[0]&&(Nt$3(T,e,t,t+4),T.dirty=!0)}}};if(c||f||d){if(c)for(let t=0;t<c.length;t++){const e=c[t];_(b[6*e],e,!0,!0)}else if(f||d){if(f)for(let t=0;t<f.length;t++){const e=f[t];_(b[6*e],e,!0,!1)}if(d)for(let t=0;t<d.length;t++){const e=d[t];_(b[6*e],e,!1,!0)}}}else for(let t=0;t<b.length;t+=6){_(b[t],t/6,!0,!0)}const{aPadOffsetX:S,aPadOffsetY:M}=r;S&&(e.data.aPadOffsetX=S,e.data.aPadOffsetY=M)}const Ss$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&e.isForeground(t)&&!!t.geometry.properties.iconAtlas&&!t.geometry.properties.isEmpty},Ms$1=function(t){const e=this.layer.getRenderer();return!(this.Ts(t)||e.isForeground(t)||!t.geometry.properties.iconAtlas||t.geometry.properties.isEmpty)},Ps$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&e.isForeground(t)&&!!t.geometry.properties.glyphAtlas},Ts$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&!e.isForeground(t)&&!!t.geometry.properties.glyphAtlas},ks$1=[],Os$1={collides:-1},Is$1=[2048,2048],Fs$1=identity$2([]),Cs$1=[];class Es$1 extends br$2{static getBloomSymbol(){return["markerBloom","textBloom"]}constructor(t,e,n,i,r,s){super(t,e,n,i,r,s),this.propAllowOverlap="markerAllowOverlap",this.propIgnorePlacement="markerIgnorePlacement",this.Zi={},this.isLabelCollides=us$2.bind(this),this.Is=Ss$1.bind(this),this.Fs=Ms$1.bind(this),this.Cs=Ps$1.bind(this),this.Es=Ts$1.bind(this),this.Ds=[]}needToRefreshTerrainTileOnZooming(){for(let t=0;t<this.symbolDef.length;t++){const e=this.symbolDef[t].markerPitchAlignment;if("map"===e||isFunctionDefinition(e)||Mr$3.isExpression(e))return!0}return!1}isTerrainVector(){return this.layer.options.awareOfTerrain&&!this.needToRefreshTerrainTileOnZooming()}isTerrainSkin(){return super.isTerrainSkin()&&this.needToRefreshTerrainTileOnZooming()}setTextShaderDefines(t){this.Rs=t}createFnTypeConfig(t,e){return{icon:xs$1.call(this,t,e),text:ss$2.call(this,t,e)}}startFrame(...t){return this.Ds.length=0,super.startFrame(...t)}createGeometry(t,e){return t&&t.empty&&(t.data={aPosition:new Uint8Array(t.data.aPosition),aPickingId:t.data.aPickingId}),super.createGeometry(t,e)}postCreateGeometry(t,e){const{geometry:n,symbolIndex:i}=t,r=this.getSymbolDef(i),s=this.getFnTypeConfig(i);if(this.Ls(n))n.properties.iconAtlas?this.drawDebugAtlas(n.properties.iconAtlas):n.properties.isEmpty=!0,function(t,e,n){si$1(t,e,n),function(t){const{aMarkerWidth:e,aMarkerHeight:n,aMarkerDx:i,aMarkerDy:r,aPitchAlign:s,aRotationAlign:o,aRotation:a,aOverlap:l}=t.data;if(e){const n=(ri$1+"aMarkerWidth").trim();t.properties.aMarkerWidth=t.properties[n]||new e.constructor(e)}if(n){const e=(ri$1+"aMarkerHeight").trim();t.properties.aMarkerHeight=t.properties[e]||new n.constructor(n)}if(i){const e=(ri$1+"aMarkerDx").trim();t.properties.aMarkerDx=t.properties[e]||new i.constructor(i)}if(r){const e=(ri$1+"aMarkerDy").trim();t.properties.aMarkerDy=t.properties[e]||new r.constructor(r)}if(s){const e=(ri$1+"aPitchAlign").trim();t.properties.aPitchAlign=t.properties[e]||new s.constructor(s)}if(o){const e=(ri$1+"aRotationAlign").trim();t.properties.aRotationAlign=t.properties[e]||new o.constructor(o)}if(a){const e=(ri$1+"aRotation").trim();t.properties.aRotation=t.properties[e]||new a.constructor(a)}if(l){const e=(ri$1+"aOverlap").trim();t.properties.aOverlap=t.properties[e]||new l.constructor(l)}}(t)}(n,r,s.icon);else if(this.Ns(n)&&zt$2(r)){const t=e[e.length-1];if(t){const{geometry:e,symbolIndex:s}=t;if(e&&s.index===i.index){const t=this.getMap(),i=r.markerTextFit;e.properties.textGeo=n,bs$2.call(this,t,e,n,i)}}}}prepareCollideIndex(t){const{collideIds:e,elements:n,aCount:i}=t.properties;if(!e)return;const r=e,s={};if(!n)return void(t.properties.collideBoxIndex=s);let o=0,a=n[0],l=0,h=r[a],u=1;i&&(u=i[n[l]]);for(let t=0;t<=n.length;t+=6)a=n[t],r[a]===h&&t!==n.length||(s[h]=[l,t,(t-l)/(6*u),o++],h=r[a],l=t,i&&(u=i[n[l]]));t.properties.collideBoxIndex=s}createMesh(t,e,i,r){const s=this.isEnableCollision(),o=this.layer,{geometry:a,symbolIndex:l}=t;a.properties.symbolIndex=l;const h=this.getSymbolDef(l),u=this.getSymbol(l),c=this.getFnTypeConfig(l),f=[];if(this.Ls(a)){const t=function(t,e,i,r,s,o,a,l){if(e.isDisposed()||0===e.data.aPosition.length)return null;const h=e.properties.iconAtlas;if(!h&&!e.properties.isEmpty)return null;const u={flipY:0,tileResolution:e.properties.tileResolution,tileRatio:e.properties.tileRatio};
//!geometry.properties.aShape ä»¥é¿å…é‡å¤åˆ›å»ºcollisionæ•°æ®
if(!e.properties.aShape){const{aPosition:t,aShape:n}=e.data,i=e.data.aPosition.length/e.desc.positionSize,r=new Uint8Array(i);l&&r.fill(255,0),e.data.aOpacity={usage:"dynamic",data:r},e.properties.aOpacity=new Uint8Array(i),l&&e.properties.aOpacity.fill(255,0),e.properties.aAnchor=t,e.properties.aShape=n}e.properties.visElemts||(e.properties.elements=e.elements,e.properties.visElemts=new e.elements.constructor(e.elements.length));const[c,f]=$i$1(e);Ct$3(u,"markerOpacity",s,"markerOpacity",1),Ct$3(u,"markerPerspectiveRatio",s,"markerPerspectiveRatio",s.markerTextFit?0:1),Ct$3(u,"markerWidth",s,"markerWidth",c||15),Ct$3(u,"markerHeight",s,"markerHeight",f||15),Ct$3(u,"markerDx",s,"markerDx",0),Ct$3(u,"markerDy",s,"markerDy",0),Ct$3(u,"markerRotation",s,"markerRotation",0,(t=>t*Math.PI/180)),Ct$3(u,"pitchWithMap",s,"markerPitchAlignment",0,(t=>"map"===t?1:0)),Ct$3(u,"rotateWithMap",s,"markerRotationAlignment",0,(t=>"map"===t?1:0)),u.iconTex=h?Wi$1(t,h,!1):null,u.texSize=h?[h.width,h.height]:[0,0],e.generateBuffers(t,{excludeElementsInVAO:!0});const d=new Ce$5(u),p=new Be$5(e,d,{disableVAO:!0,transparent:!0,castShadow:!1,picking:!0}),m={};return a&&(m.ENABLE_COLLISION=1),e.data.aMarkerWidth&&(m.HAS_MARKER_WIDTH=1),e.data.aMarkerHeight&&(m.HAS_MARKER_HEIGHT=1),e.data.aColorOpacity&&(m.HAS_OPACITY=1),e.data.aMarkerDx&&(m.HAS_MARKER_DX=1),e.data.aMarkerDy&&(m.HAS_MARKER_DY=1),e.data.aPitchAlign&&(m.HAS_PITCH_ALIGN=1),e.data.aRotationAlign&&(m.HAS_ROTATION_ALIGN=1),e.data.aRotation&&(m.HAS_ROTATION=1),e.data.aPadOffsetX&&(m.HAS_PAD_OFFSET=1),e.data.aAltitude&&(m.HAS_ALTITUDE=1),p.setDefines(m),p.setUniform("alphaTest",.01),p.setLocalTransform(i),p.properties.symbolIndex=e.properties.symbolIndex,p}(this.regl,a,e,0,u,0,o.options.collision,!s,this.isEnableUniquePlacement());t&&(t.positionMatrix=this.getAltitudeOffsetMatrix(),delete t.geometry.properties.glyphAtlas,f.push(t))}else if(this.Ns(a)){const t=es$2.call(this,this.regl,a,e,h,u,c.text,o.options.collision,!s,this.isEnableUniquePlacement());t.length&&(t.forEach((t=>{t.positionMatrix=this.getAltitudeOffsetMatrix(),delete t.geometry.properties.iconAtlas})),f.push(...t))}return"line"===a.properties.markerPlacement&&this.Hs(a,r),"line"===a.properties.markerPlacement&&f.forEach((t=>t.properties.isLinePlacement=!0)),this.prepareCollideIndex(a),f}Hs(t,e){const{collideIds:n}=t.properties,i=new Uint16Array(n.length);if(this.Ls(t)){let r=0;for(let t=0;t<n.length;t+=4)i.fill(r++,t,t+4);t.properties.collideIds=i,t.properties.uniqueCollideIds=Ut$2(i),e.markerCollideMap={old:n,new:i}}else if(this.Ns(t)){const{collideIds:n,aCount:i}=t.properties;if(!i)return;if(e.markerCollideMap){const{markerCollideMap:r}=e;let s=r.new[r.new.length-1],o=0,a=n[0],l=e.markerCollideMap.old.indexOf(a),h=i[0];for(let t=0;t<n.length;){const r=n[t];a!==r&&(a=r,l=e.markerCollideMap.old.indexOf(a),o=0);const u=-1===l?++s:e.markerCollideMap.new[l+4*o],c=t+4*h;n.fill(u,t,c),t+=4*h,o++,c<n.length&&(h=i[c])}t.properties.uniqueCollideIds=Ut$2(n)}else{let e=0,r=i[0];for(let t=0;t<n.length;){const s=t+4*r;n.fill(e++,t,s),t+=4*r,s<n.length&&(r=i[s])}t.properties.uniqueCollideIds=Ut$2(n)}}}addMesh(t){if(this.isEnableCollision()&&t.length>0){const e=new cr$2(t);e.properties.uniqueCollideIds=t[0].geometry.properties.uniqueCollideIds,e.properties.meshKey=t[0].properties.meshKey,e.properties.level=t[0].properties.level,this.Ds.push(e)}for(let e=0;e<t.length;e++){if(!this.isMeshIterable(t[e]))continue;const n=t[e].geometry,{symbolIndex:i}=n.properties;zt$2(this.getSymbolDef(i))&&_s$1.call(this,this.getMap(),n)}const e=this.getMap().getZoom();for(let n=0;n<t.length;n++){if(!this.isMeshIterable(t[n]))continue;const i=t[n].geometry,{symbolIndex:r}=i.properties,s=this.getSymbolDef(r),o=this.getFnTypeConfig(r);hi$1(this.regl,s,0===r.type?o.icon:o.text,t[n],e);const{aMarkerWidth:a,aMarkerHeight:l,aPadOffsetX:h,aPadOffsetY:u}=i.properties;a&&a.dirty&&(i.updateData("aMarkerWidth",a),a.dirty=!1),l&&l.dirty&&(i.updateData("aMarkerHeight",l),l.dirty=!1),h&&h.dirty&&(i.updateData("aPadOffsetX",h),h.dirty=!1),u&&u.dirty&&(i.updateData("aPadOffsetY",u),u.dirty=!1)}super.addMesh(...arguments)}updateCollision(t){if(!this.isEnableCollision())return;super.updateCollision(t);const e=this.scene.getMeshes();e&&e.length?(this.zs(t.timestamp),this.Ds=[],this.zr()):this.zr()}callCurrentTileShader(t,e){this.shader.filter=e.sceneFilter?[this.Is,e.sceneFilter]:this.Is,this.callRenderer(this.shader,t,e),this.Vs.filter=e.sceneFilter?[this.Cs,e.sceneFilter]:this.Cs,this.callRenderer(this.Vs,t,e)}callBackgroundTileShader(t,e){this.shader.filter=e.sceneFilter?[this.Fs,e.sceneFilter]:this.Fs,this.callRenderer(this.shader,t,e),this.Vs.filter=e.sceneFilter?[this.Es,e.sceneFilter]:this.Es,this.callRenderer(this.Vs,t,e)}isMeshIterable(t){return t&&t.geometry&&!t.geometry.properties.isEmpty&&t.material&&!t.material.get("isHalo")&&this.isMeshVisible(t)&&!(this.shouldIgnoreBackground()&&!this.layer.getRenderer().isForeground(t))}zs(){if(!this.isEnableCollision())return;let t=this.Ds;t&&t.length&&this.Us(t)}js(t,e,n,i){return this.updateBoxCollisionFading(!0,t,e,n,i)}isEnableUniquePlacement(){return this.isEnableCollision()&&!0===this.sceneConfig.uniquePlacement}Us(t){const e=this.layer.getRenderer();t=t.sort(Ds$1);for(let n=0;n<t.length;n++){const i=t[n];if(!i||!i.meshes.length)continue;let r=!1;if(1===i.meshes.length)r=this.isMeshIterable(i.meshes[0]);else for(let t=0;t<i.meshes.length;t++)if(this.isMeshIterable(i.meshes[t])){r=!0;break}if(!r)continue;const s=e.isForeground(i.meshes[0]);if(this.shouldIgnoreBackground()&&!s)continue;const o=i.properties.meshKey;this.startMeshCollision(i),this.Bs(i),this.forEachBox(i,this.js),this.Gs(i),this.endMeshCollision(o);for(let t=0;t<i.meshes.length;t++)this.Ws(i.meshes[t])}}Ws(t){const e=t&&t.geometry&&t.geometry.properties.aOpacity;e&&e.dirty&&(t.geometry.updateData("aOpacity",e),e.dirty=!1)}forEachBox(t,e){const n=t.properties.uniqueCollideIds;if(!n)return;const i={boxIndex:0},r=n.length;for(let s=0;s<r;s++)this.Xs(t,n[s],e,i)}Xs(t,e,n,i){const s=this.getMap(),{collideBoxIndex:o}=t.meshes[0].geometry.properties;if(!o||!o[e])return!1;const a=multiply$5(ks$1,s.projViewMatrix,t.meshes[0].localTransform);let l,h=!1;const u=t.meshes;let c=0;for(let t=0;t<u.length;t++){if(!this.isMeshIterable(u[t]))continue;const{collideBoxIndex:n}=u[t].geometry.properties;n[e]&&c++}if(!c)return!1;l=this.Ms(c);let f=0;for(let t=0;t<u.length;t++){if(!this.isMeshIterable(u[t]))continue;h=!0;const i=u[t].geometry.properties,{elements:r,aCount:s,collideBoxIndex:o}=i,a=o[e];if(!a)continue;const[c,d,p]=a;let m=1;s&&(m=s[r[c]]);const y=c+0*m*6;l[f].mesh=u[t],l[f].start=y,l[f].end=d,l[f].boxCount=i.glyphAtlas?m:p,l[f].allElements=r,f++}return!!h&&(n.call(this,t,l,a,i.boxIndex++)&&this.Ys(t,e),!0)}Bs(t){const e=t.meshes;for(let t=0;t<e.length;t++){const n=e[t],i=n&&n.geometry;i&&(i.properties.visElemts.count=0)}}Ys(t,e){const n=t.meshes;for(let t=0;t<n.length;t++){const i=n[t];if(i.properties.isHalo)continue;const r=i&&i.geometry;if(!r||r.properties.isEmpty)continue;const{collideBoxIndex:s,elements:o,visElemts:a}=r.properties,l=s[e];if(!l)continue;const[h,u]=l;let c=a.count;for(let t=h;t<u;t++)a[c++]=o[t];a.count=c}}Gs(t){const e=t.meshes;for(let t=0;t<e.length;t++){const n=e[t],i=n&&n.geometry;if(!i)continue;const{visElemts:r}=i.properties;i.setElements(r,r.count)}}isBoxCollides(t,e,n,i,r,s){if(this.Ns(t.geometry))return us$2.call(this,0,t,e,n,i,r,s);if(t.geometry.properties.isEmpty)return Os$1;const{aTerrainAltitude:o}=t.geometry.properties;if(o&&o[2*e[i]]===xt$3)return Os$1;const a=this.getMap(),{boxes:l,collision:h}=this.Ss(t,i);let u=0,c=0,f=0;for(let n=i;n<r;n+=6){const i=l[f]=l[f]||[];f++;const r=Gr$2.call(this,i,t,e[n],s,a);if(!u){const t=this.isCollides(r);1===t?u=1:-1===t&&c++}}return c===n&&(u=-1),h.collides=u,h}deleteMesh(t,e){t&&(t instanceof cr$2&&(t=t.meshes),e&&(Array.isArray(t)?t.forEach((t=>{t&&t.material&&delete t.material.uniforms.iconTex})):t.material&&delete t.material.uniforms.iconTex),super.deleteMesh(t,e))}isBloom(t){const e=t&&t.material&&!It$3(t.material.get("markerOpacity")),n=this.getSymbol(t.properties.symbolIndex);return!!(e?n.markerBloom:n.textBloom)}init(){const e=this.canvas;this.renderer=new B$6(this.regl);const i={viewport:{x:(t,e)=>e.viewport?e.viewport.x:0,y:(t,e)=>e.viewport?e.viewport.y:0,width:(t,n)=>n.viewport?n.viewport.width:e?e.width:1,height:(t,n)=>n.viewport?n.viewport.height:e?e.height:1},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},depth:{enable:!0,range:()=>this.sceneConfig.depthRange||[0,1],func:()=>this.sceneConfig.depthFunc||"always",mask:!!It$3(this.sceneConfig.depthMask)||this.sceneConfig.depthMask},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}};this.shader=new vn$4({vert:Sr$2,frag:"#define SHADER_NAME MARKER\n#define HAS_HIGHLIGHT_COLOR_POINT 1\nprecision mediump float;\n#include <gl2_frag>\nuniform float alphaTest;\nuniform sampler2D iconTex;\nuniform lowp float markerOpacity;\nuniform lowp float blendSrcIsOne;\nuniform float layerOpacity;\n#include <highlight_frag>\nvarying vec2 vTexCoord;\nvarying float vOpacity;\nvoid main() {\n  vec4 c = texture2D(iconTex, vTexCoord) * markerOpacity * vOpacity * layerOpacity;\n  if(c.a < .05) {\n    discard;\n  }\n  glFragColor = c;\n  glFragColor = highlight_blendColor(glFragColor);\n  if(glFragColor.a < alphaTest) {\n    discard;\n  }\n  glFragColor = highlight_blendColor(glFragColor);\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5([],e.projViewMatrix,e.modelMatrix)}},{name:"zoomScale",type:"function",fn:function(t,e){return e.tileResolution/e.resolution}}],extraCommandProps:i}),this.shader.version=300;const{uniforms:s,extraCommandProps:o}=rs$2.call(this,e,this.sceneConfig);if(this.Vs=new vn$4({vert:ps$2,frag:ms$2,uniforms:s,extraCommandProps:o,defines:this.Rs||{}}),this.pickingFBO){const t=new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+Sr$2,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5([],e.projViewMatrix,e.modelMatrix)}},{name:"zoomScale",type:"function",fn:function(t,e){return e.tileResolution/e.resolution}}],extraCommandProps:i},this.pickingFBO,this.getMap());t.filter=t=>!!t.geometry.properties.iconAtlas;const e=new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+ps$2,uniforms:s,extraCommandProps:o},this.pickingFBO,this.getMap());e.filter=t=>!!t.geometry.properties.glyphAtlas,this.picking=[t,e]}}getUniformValues(e,n){const i=n&&n.isRenderingTerrainSkin,r=this.layer.getTileSize().width,s=i?Fs$1:e.projViewMatrix,o=e.cameraToCenterDistance,a=set(Cs$1,e.width,e.height);i&&set(a,r,r);const l=this.getBlendFunc(),u=t__namespace.Util.isFunction(l.src)?l.src():l.src;return{layerScale:this.layer.options.styleScale||1,mapPitch:e.getPitch()*Math.PI/180,mapRotation:e.getBearing()*Math.PI/180,projViewMatrix:s,cameraToCenterDistance:o,canvasSize:a,iconSize:Is$1,resolution:e.getResolution(),glyphSize:24,gammaScale:1,blendSrcIsOne:+!("one"!==u&&1!==u),viewport:i&&n&&n.viewport,isRenderingTerrain:+!!i}}getUniqueEntryKey(t,e){if(!this.Ns(t.geometry))return null;const{elements:n}=t.geometry.properties;return cs$2(t,n[e])}Ls(t){const{symbolIndex:e}=t.properties;return 0===e.type}Ns(t){const{symbolIndex:e}=t.properties;return 1===e.type}}function Ds$1(t,e){return t.properties.level-e.properties.level||t.properties.meshKey-e.properties.meshKey}const Rs$1=[],Ls$1=[],Ns$1=[];function Hs$1(t,e,n,r,s,o,a,l,u,c,f,d,p){const{aGlyphOffset:m,aSegment:y,aTextDx:g,aTextDy:v,symbolIndex:x}=e.geometry.properties,b=this.getSymbol(x),_=set(Ns$1,(g?g[s]:b.textDx)||0,(v?v[s]:b.textDy)||0),S=set(Rs$1,m[2*s],m[2*s+1]),M=set$4(Ls$1,y[3*s],y[3*s+1],y[3*s+2]);return function(t,e,n,i,r,s,o,a,l,h,u,c,f,d,p,m,y,g){p||(p=i);const v=e.geometry.properties.line,x=s[0]*c,b=f?x-o:x+o;let A=b>0?1:-1,w=0;f&&(A*=-1,w=Math.PI),A<0&&(w+=Math.PI);const _=h+u,S=Math.abs(b);let M=A>0?l:l+1,P=gi$1.convert(i),T=gi$1.convert(i),k=gi$1.convert(r),O=gi$1.convert(r),I=0,F=0;for(;I+F<=S;){if(M+=A,M<h||M>=_)return null;T.x=P.x,T.y=P.y,O.x=k.x,O.y=k.y,P.x=n[3*M],P.y=n[3*M+1],k.x=v[3*M],k.y=v[3*M+1],I+=F,F=T.dist(P)/d}const C=(S-I)/F,E=m&&m.getRenderer(),D=E&&E.getTerrainHelper(),R=e.properties.tile.terrainTileInfos;if(!g&&D){const{extent:n}=e.properties.tile,i=m.getTileSize().width/n,r=m.getMap();let s=k.sub(O).mult(C).wi(O);P=Ti$1(Ai$1,r,e,k,i,m,y,R),T=Ti$1(wi$1,r,e,O,i,m,y,R),s=Ti$1(_i$1,r,e,s,i,m,y,R);const o=w+Math.atan2(P[1]-T[1],P[0]-T[0]);return t[0]=(s[0]-p[0])/d,t[1]=(s[1]-p[1])/d,t[2]=o,t}const L=P.sub(T),N=L.mult(C).wi(T);N.wi(L.Fi().Ci().Pi(a*A));const H=w+Math.atan2(P.y-T.y,P.x-T.x);return t[0]=(N.x-i[0])/d,t[1]=(N.y-i[1])/d,t[2]=H,t}(t,e,r,o,a,S,_[0],_[1],M[0],M[1],M[2],n/24,u,l,c,f,d,p)}const zs$1=[],Vs$1=[];function Us$1(t,e,n,r,s,o,a,l,u,c,f,d){const{aVertical:p}=n.geometry.properties,m=p[o];let y,g,v=Hs$1.call(this,zs$1,n,r,s,o,l,u,c,!1);if(!v)return null;if(copy$4(t,v),v=Hs$1.call(this,Vs$1,n,r,s,a,l,u,c,!1),!v)return null;if(copy$4(e,v),d&&(transformMat2(zs$1,zs$1,d),transformMat2(Vs$1,Vs$1,d)),m){const t=Math.abs(Vs$1[1]-zs$1[1]),e=Math.abs(Vs$1[0]-zs$1[0])*f;g=zs$1[0]>Vs$1[0]?1:0,t>e?(y=1,g=zs$1[1]<Vs$1[1]?0:1):y=0}else y=0,g=zs$1[0]>Vs$1[0]?1:0;return 2*g+y}var js$1="#define SHADER_NAME TEXT_LINE\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nattribute vec2 aTexCoord;\n#ifdef HAS_OFFSET_Z\nattribute vec3 aOffset;\nuniform float altitudeScale;\n#else\nattribute vec2 aOffset;\n#endif\n#ifdef ENABLE_COLLISION\nattribute float aOpacity;\n#endif\n#ifdef HAS_OPACITY\nattribute float aColorOpacity;\n#endif\n#ifdef HAS_TEXT_SIZE\nattribute float aTextSize;\n#else\nuniform float textSize;\n#endif\n#ifdef HAS_TEXT_DX\nattribute float aTextDx;\n#else\nuniform float textDx;\n#endif\n#ifdef HAS_TEXT_DY\nattribute float aTextDy;\n#else\nuniform float textDy;\n#endif\n#if defined(HAS_PITCH_ALIGN)\nattribute float aPitchAlign;\n#else\nuniform float pitchWithMap;\n#endif\nuniform float zoomScale;\nuniform float cameraToCenterDistance;\nuniform mat4 projViewModelMatrix;\nuniform float textPerspectiveRatio;\nuniform float mapPitch;\nuniform vec2 texSize;\nuniform vec2 canvasSize;\nuniform float tileRatio;\nuniform float layerScale;\nuniform float isRenderingTerrain;\nuniform float textPitchFilter;\n#ifndef PICKING_MODE\nvarying vec2 vTexCoord;\nvarying float vGammaScale;\nvarying float vSize;\nvarying float vOpacity;\n#ifdef HAS_TEXT_FILL\nattribute vec4 aTextFill;\nvarying vec4 vTextFill;\n#endif\n#ifdef HAS_TEXT_HALO_FILL\nattribute vec4 aTextHaloFill;\nvarying vec4 vTextHaloFill;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nattribute float aTextHaloRadius;\nvarying float vTextHaloRadius;\n#endif\n#ifdef HAS_TEXT_HALO_OPACITY\nattribute float aTextHaloOpacity;\nvarying float vTextHaloOpacity;\n#endif\n#include <highlight_vert>\n#else\n#include <fbo_picking_vert>\n#endif\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n#ifdef HAS_TEXT_DX\nfloat d = aTextDx;\n#else\nfloat d = textDx;\n#endif\n#ifdef HAS_TEXT_DY\nfloat e = aTextDy;\n#else\nfloat e = textDy;\n#endif\n#ifdef HAS_TEXT_SIZE\nfloat f = aTextSize * layerScale;\n#else\nfloat f = textSize * layerScale;\n#endif\n#ifdef HAS_PITCH_ALIGN\nfloat h = aPitchAlign;\n#else\nfloat h = pitchWithMap;\n#endif\ngl_Position = projViewModelMatrix * vec4(c, 1.);\n  float i = gl_Position.w;\n  float j = i / cameraToCenterDistance;\n  float k;\n  if(isRenderingTerrain == 1.) {\n    k = 1.;\n  } else {\n    float l = (1. - cameraToCenterDistance / i) * textPerspectiveRatio;\n    k = clamp(.5 + .5 * (1. - l), .0, 4.);\n  }\n#ifdef HAS_OFFSET_Z\nvec3 m = aOffset / 10.0;\n  m[2] /= altitudeScale;\n#else\nvec3 m = vec3(aOffset / 10.0, .0);\n#endif\nvec2 n = aTexCoord;\n  if(h == 1.) {\n    float o;\n    if(isRenderingTerrain == 1.) {\n      o = tileRatio;\n    } else {\n      o = tileRatio / zoomScale * j * k;\n    }\n    m.xy *= o;\n    gl_Position = projViewModelMatrix * vec4(c + m, 1.);\n  } else {\n    gl_Position.xy += m.xy * 2. / canvasSize * k * i;\n  }\n  gl_Position.xy += vec2(d, -e) * 2. / canvasSize * i;\n  if(textPitchFilter > .0) {\n    if(textPitchFilter == 1. && h == .0 || textPitchFilter == 2. && h == 1.) {\n      gl_Position = vec4(-9999., -9999., .0, 1.);\n    }\n  }\n#ifndef PICKING_MODE\nif(h == 1.) {\n    vGammaScale = j + mapPitch / 4.;\n  } else {\n    vGammaScale = mix(1., j, textPerspectiveRatio);\n  }\n  vGammaScale = clamp(vGammaScale, .0, 1.);\n  vTexCoord = n / texSize;\n  vSize = f;\n#ifdef ENABLE_COLLISION\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity *= aColorOpacity / 255.;\n#endif\n#ifdef HAS_TEXT_FILL\nvTextFill = aTextFill / 255.;\n#endif\n#ifdef HAS_TEXT_HALO_FILL\nvTextHaloFill = aTextHaloFill / 255.;\n#endif\n#ifdef HAS_TEXT_HALO_RADIUS\nvTextHaloRadius = aTextHaloRadius;\n#endif\n#ifdef HAS_TEXT_HALO_OPACITY\nvTextHaloOpacity = aTextHaloOpacity;\n#endif\nhighlight_setVarying();\n#else\n#ifdef ENABLE_COLLISION\nbool u = aOpacity == 255.;\n#else\nbool u = true;\n#endif\nfbo_picking_setData(gl_Position.w, u);\n#endif\n}";const Bs$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&e.isTileNearCamera(t)&&"line"!==t.geometry.properties.textPlacement},Gs$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&!e.isForeground(t)&&"line"!==t.geometry.properties.textPlacement},Ws$1=function(t){const e=this.layer.getRenderer();return!this.Ts(t)&&e.isTileNearCamera(t)&&"line"===t.geometry.properties.textPlacement},Xs$1=function(t){const e=this.layer.getRenderer(),n=t.properties.tile.z,i=e.getCurrentTileZoom();return!this.Ts(t)&&!e.isForeground(t)&&"line"===t.geometry.properties.textPlacement&&n<i},Ys$1=[0,0,3],$s$1=[],qs$1=[],Js$1=[],Ks$1=[],Zs$1=[],Qs$1=[],to$1=[],eo$1=[],no$1=[1,-1],io$1=new Int16Array(3),ro$1=[],so$1=[],oo$1=[],ao$1=[],lo$1=[],ho$1=[],uo$1=[],co$1={},fo$1={},po$1={},mo$1=[],yo$1=[],go$1=identity$2([]),vo$1=[];class xo$1 extends br$2{static getBloomSymbol(){return["textBloom"]}constructor(t,e,n,i,r,s){super(t,e,n,i,r,s),this.propAllowOverlap="textAllowOverlap",this.propIgnorePlacement="textIgnorePlacement",this.colorCache={},this.$s=Bs$1.bind(this),this.qs=Gs$1.bind(this),this.Js=Ws$1.bind(this),this.Ks=Xs$1.bind(this),this.isLabelCollides=us$2.bind(this),this.Zs()}prepareRender(...t){super.prepareRender(...t);const e=this.scene.getMeshes();if(e&&e.length)for(let t=0;t<e.length;t++){if(e[t].properties.isHalo)continue;const{haloMesh:n}=e[t].properties;n.dirtyDefines&&e[t].setDefines(n.defines)}}updateSymbol(...t){this.Qs=void 0,this.to=void 0;const e=super.updateSymbol(...t);return this.Zs(),e}isTerrainVector(){if(!super.isTerrainSkin())return!1;if(void 0!==this.Qs)return this.Qs;for(let t=0;t<this.symbolDef.length;t++)if("map"!==this.symbolDef[t].textPitchAlignment)return this.Qs=!0,!0;return this.Qs=!1,!1}isTerrainSkin(){if(!super.isTerrainSkin())return!1;if(void 0!==this.to)return this.to;for(let t=0;t<this.symbolDef.length;t++){const e=this.symbolDef[t].textPitchAlignment;if("map"===e||isFunctionDefinition(e)||Mr$3.isExpression(e))return this.to=!0,!0}return this.to=!1,!1}Zs(){this.eo=[];for(let t=0;t<this.symbolDef.length;t++){const e=this.symbolDef[t];if(Mr$3.isExpression(e.textName)){const n=Mr$3.createExpression(e.textName,"string");this.eo[t]=(t,e)=>{let i;co$1.zoom=t,fo$1.properties=e;try{i=n.evaluateWithoutErrorHandling(co$1,fo$1,po$1,null,mo$1)}catch(t){i=null}return i}}else isFunctionDefinition(e.textName)&&(this.eo[t]=interpolated(e.textName))}}shouldDeleteMeshOnUpdateSymbol(t){if(!Array.isArray(t))return(0===t.textHaloRadius||0===this.symbolDef[0].textHaloRadius)&&t.textHaloRadius!==this.symbolDef[0].textHaloRadius;for(let e=0;e<t.length;e++)if(t[e]&&(0===t[e].textHaloRadius||0===this.symbolDef[e].textHaloRadius)&&t[e].textHaloRadius!==this.symbolDef[e].textHaloRadius)return!0;return!1}createFnTypeConfig(t,e){return ss$2(t,e)}isBloom(t){return!!this.getSymbol(t.properties.symbolIndex)[xo$1.getBloomSymbol()[0]]}createGeometry(t,e,n){const i=t;if(!i.glyphAtlas)return null;const r=super.createGeometry(i,e);if(!r||!r.geometry)return null;const{geometry:s}=r;return s.properties.glyphAtlas&&this.drawDebugAtlas(s.properties.glyphAtlas),s&&i.lineVertex&&(s.properties.line=i.lineVertex,s.properties.line.id=n),r}createMesh(t,e,{tileVectorTransform:n}){const i=this.isEnableCollision(),r=this.isEnableUniquePlacement(),{geometry:s,symbolIndex:o}=t;s.properties.symbolIndex=o;const a=this.getSymbol(o),l=this.getSymbolDef(o),h=this.getFnTypeConfig(o),u=es$2.call(this,this.regl,s,e,l,a,h,this.layer.options.collision,!i,r);return u.length&&("line"===s.properties.textPlacement?this.no=!0:this.io=!0),u.forEach((t=>{t.positionMatrix=this.getAltitudeOffsetMatrix(),t.properties.tileVectorTransform=n})),u}updateCollision(t){super.updateCollision(t);const e=this.scene.getMeshes();e&&e.length?(this.ro={},this.so(t.timestamp),this.zr()):this.zr()}callCurrentTileShader(t,e){this.shader.filter=e.sceneFilter?[this.$s,e.sceneFilter]:this.$s,this.callRenderer(this.shader,t,e),this.oo.filter=e.sceneFilter?[this.Js,e.sceneFilter]:this.Js,this.callRenderer(this.oo,t,e)}callBackgroundTileShader(t,e){this.shader.filter=e.sceneFilter?[this.qs,e.sceneFilter]:this.qs,this.callRenderer(this.shader,t,e),this.oo.filter=e.sceneFilter?[this.Ks,e.sceneFilter]:this.Ks,this.callRenderer(this.oo,t,e)}callRenderer(t,e,n){n&&n.isRenderingTerrain&&isFunctionDefinition(this.symbolDef.textPitchAlignment)&&(e.textPitchFilter=n.isRenderingTerrainSkin?1:2),super.callRenderer(t,e,n)}so(){let t=this.scene.getMeshes();if(!t||!t.length)return;const e=-this.getMap().getBearing()*Math.PI/180,n=fromRotation$4(Js$1,e),i=(t,e,n,i)=>{const{start:r,end:s,mesh:o,allElements:a}=e[0];if(this.updateBoxCollisionFading(!0,o,e,n,i)){let e=t.count;for(let n=r;n<s;n++)t[e++]=a[n];t.count=e}},r=this.isEnableCollision(),s=this.layer.getRenderer();t=t.sort(Ao$1);for(let e=0;e<t.length;e++){const o=t[e];if(!this.isMeshIterable(o))continue;if(!s.isTileNearCamera(o)){const{visElemts:t}=o.geometry.properties;t&&(t.count=0),o.geometry.setElements(t,0);continue}const a=o.geometry,l=this.getSymbol(o.properties.symbolIndex);o.properties.textHaloRadius=It$3(l.textHaloRadius)?ts$2.textHaloRadius:l.textHaloRadius;const h=o.properties.meshKey;if("line"===a.properties.textPlacement){if(!a.properties.line)continue;r&&this.startMeshCollision(o),this.ao(o,n);const{aOffset:t,aOpacity:e}=a.properties;t.dirty&&(a.updateData("aOffset",t),t.dirty=!1),e&&e.dirty&&(a.updateData("aOpacity",e),e.dirty=!1),r&&this.endMeshCollision(h)}else if(r){this.startMeshCollision(o);const{elements:t,aOpacity:e,visElemts:n}=a.properties;n.count=0,this.forEachBox(o,((t,e,r,s,o)=>{i(n,e,r,s)})),e&&e.dirty&&a.updateData("aOpacity",e);const s=!n.count&&!a.count;n.count===t.length&&a.count===t.length||s||a.setElements(n,n.count),this.endMeshCollision(h)}}}isMeshIterable(t){return t.isValid()&&t.material&&!t.material.get("isHalo")&&!(this.shouldIgnoreBackground()&&!this.layer.getRenderer().isForeground(t))}isMeshUniquePlaced(t){return!!this.isMeshIterable(t)&&"line"!==this.getSymbol(t.properties.symbolIndex).textPlacement}getUniqueEntryKey(t,e){return cs$2(t,e)}ao(t,e){const n=this.getMap(),i=t.geometry,s=i.properties;let o=s.line;if(!o)return;const a=n.getPitch(),l=n.getBearing(),{lineTextPitch:h,lineTextBearing:u}=t.properties,c=1===t.material.uniforms.pitchWithMap,f=s.elements;if(!c){const e=multiply$5($s$1,n.projViewMatrix,t.localTransform),i=o.id+"-"+e.join();let a;this.ro[i]?o=this.ro[i]:(a=s.projectedLine=s.projectedLine||new Array(o.length),o=this.lo(a,o,e,n.width,n.height),this.ro[i]=a)}const d=this.isEnableCollision(),p=i.properties.visElemts=i.properties.visElemts||new f.constructor(f.length),m=i.properties.visCache=i.properties.visCache||[];d&&(p.count=0);const y=void 0===h||Math.abs(a-h)>2||Math.abs(l-u)>2;this.forEachBox(t,((t,n,i,r)=>{const{start:s,end:a}=n[0];let l=m[r];if((void 0===l||y)&&(l=this.ho(t,f,s,a,o,i,c?e:null,r)),m[r]=l,d&&(l=this.updateBoxCollisionFading(l,t,n,i,r),l)){let t=p.count;for(let e=s;e<a;e++)p[t++]=f[e];p.count=t}})),y&&(t.properties.lineTextPitch=a,t.properties.lineTextBearing=l);const g=t.geometry.properties.aAltitude;g&&g.dirty&&(i.updateData("aAltitude",g),g.dirty=!1),!d||p.count===f.length&&i.count===p.count||i.setElements(p,p.count)}lo(t,e,n,i,r){return function(t,e,n,i,r){for(let s=0;s<e.length;s+=3)set$3(xi$1,e[s],e[s+1],e[s+2],1),bi$1(xi$1,xi$1,n,i,r),t[s]=xi$1[0],t[s+1]=xi$1[1],t[s+2]=e[s+2];return t}(t,e,n,i,r)}forEachBox(t,e){const n=this.getMap(),i=multiply$5($s$1,n.projViewMatrix,t.properties.tileVectorTransform),{collideIds:s,aCount:o,features:a,elements:l}=t.geometry.properties,h=s;if(!h)return;const u=this.isEnableUniquePlacement(),c=this.Ms(1);c[0].allElements=l,c[0].mesh=t;let f=0,d=l[0],p=0,m=h[d];for(let n=0;n<=l.length;n+=6)if(d=l[n],h[d]!==m||n===l.length){const r=a[m]&&a[m].feature;if(u&&this.isMeshUniquePlaced(t)&&r&&!r.label){const e=r.properties||{},{symbolIndex:n}=t.properties,i=n&&this.eo[n.index]?this.eo[n.index](t.properties.z,e):this.getSymbol(t.properties.symbolIndex).textName,s=Jr$3.resolveText(i,e);r.label=s}const s=n,y=o[l[p]];for(let n=p;n<s;n+=6*y)c[0].start=n,c[0].end=n+6*y,c[0].boxCount=y,e.call(this,t,c,i,f++);m=h[d],p=n}}ho(t,e,n,s,o,l,u){const f=this.layer.getRenderer(),d=t.material.uniforms,p=1===d.pitchWithMap,m=!p&&f.getTerrainHelper&&f.getTerrainHelper(),y=this.isEnableCollision(),g=this.getMap(),v=t.geometry,x=v.desc.positionSize,{aShape:b,aOffset:w,aAnchor:_,aAltitude:S,aPitchRotation:M}=v.properties;let{aProjectedAnchor:P}=v.properties;P||(P=v.properties.aProjectedAnchor=new Array(_.length/x*3));const T=v.properties.aTextSize,k=!u,O=e[n],I=O*x;let F;F=v.data.aAltitude?set$4(Ks$1,_[I],_[I+1],S[O]):Fa.unpackPosition(Ks$1,_[I],_[I+1],_[I+2]);const C=bi$1(Zs$1,F,l,g.width,g.height),E=v.properties.aTerrainAltitude;let D;if(E){const t=E[O];if(t===xt$3)return P[3*O]=-999999,P[3*O+1]=-999999,P[3*O+2]=-999999,!1;t?(D=set$4(yo$1,...F),D[2]=100*t,D=bi$1(D,D,l,g.width,g.height)):D=C}else D=C;const R=g.getDevicePixelRatio();if(scale$3(vo$1,D,1/R),g.isOffscreen(vo$1))return y||bo$1(w,e,n,s),P[3*O]=-999999,P[3*O+1]=-999999,P[3*O+2]=-999999,!1;k&&(F=C),P[3*O]=D[0],P[3*O+1]=D[1],P[3*O+2]=D[2];const L=k?1:v.properties.tileExtent/this.layer.getTileSize().width;let N=!0;const H=e[n],z=e[s-1],V=T?T[H]:t.properties.textSize,U=this.uo(t,V,o,H,z,F,Ks$1,L,u);if(null===U)return bo$1(w,e,n,s),!1;const j=z-H<=3,B=Math.floor(U/2),G=U%2;for(let a=n;a<s;a+=6){const u=e[a];let f;if(f=B||a!==n||j||m?B||a!==s-6||j||m?Hs$1.call(this,qs$1,t,V,o,u,F,Ks$1,L,B,D,this.layer,l,p):uo$1:ho$1,!f){N=!1,y||bo$1(w,e,n,s);break}let g=f[2];G&&(g-=Math.PI/2);const v=Er$2(Qs$1,g,0,d.rotateWithMap,d.pitchWithMap),x=w.length>b.length;let A;if(x){set$4(ao$1,M[3*u],M[3*u+1],0);const t=normalize$4(ao$1,ao$1),e=-M[3*u+2];if(e){const n=setAxisAngle(ro$1,t,e);fromTranslation$1(so$1,Ys$1),fromQuat(oo$1,n),A=multiply$5(oo$1,oo$1,so$1)}}for(let t=0;t<4;t++){const e=2*(u+t);set(to$1,b[e]/10,b[e+1]/10),scale(to$1,to$1,V/24),transformMat2(to$1,to$1,v),p?(multiply(to$1,to$1,no$1),add(eo$1,to$1,f),x&&(eo$1[2]=0,A&&transformMat4$2(eo$1,eo$1,A))):(multiply(eo$1,f,no$1),add(eo$1,to$1,eo$1)),io$1[0]=10*eo$1[0],io$1[1]=10*eo$1[1],x&&(io$1[2]=10*eo$1[2]);const n=(x?3:2)*(u+t);(w[n]!==io$1[0]||w[n+1]!==io$1[1]||x&&w[n+2]!==io$1[2])&&(w.dirty=!0,w[n]=io$1[0],w[n+1]=io$1[1],x&&(w[n+2]=io$1[2]))}}return N}uo(t,e,n,i,r,s,o,a,l){const h=r-i<=3,u=this.getMap();return h?0:Us$1.call(this,ho$1,uo$1,t,e,n,i,r,s,o,a,u.width/u.height,l)}isBoxCollides(t,e,n,i,r,s){return this.isLabelCollides(0,t,e,n,i,r,s)}deleteMesh(t,e){t&&(e&&(Array.isArray(t)?t.forEach((t=>{t&&t.material&&delete t.material.uniforms.texture})):t.material&&delete t.material.uniforms.texture),super.deleteMesh(t,e))}delete(){super.delete(),this.oo.dispose(),delete this.ro,this.co&&this.co.dispose()}needClearStencil(){return!0}init(){this.renderer=new B$6(this.regl);const{uniforms:e,extraCommandProps:i}=rs$2.call(this,this.canvas,this.sceneConfig),r=this.canvas,s={x:(t,e)=>e.viewport?e.viewport.x:0,y:(t,e)=>e.viewport?e.viewport.y:0,width:(t,e)=>e.viewport?e.viewport.width:r?r.width:1,height:(t,e)=>e.viewport?e.viewport.height:r?r.height:1};i.viewport=s,this.shader=new vn$4({vert:ps$2,frag:ms$2,uniforms:e,extraCommandProps:i});let o=i;if(this.layer.getRenderer().isEnableWorkAround("win-intel-gpu-crash")&&(o=Tt$3({},i),o.stencil=Tt$3({},i.stencil),o.stencil.enable=!0),this.oo=new vn$4({vert:js$1,frag:ms$2,uniforms:e,extraCommandProps:o}),this.pickingFBO){const t=new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+ps$2,uniforms:e,extraCommandProps:{viewport:this.pickingViewport}},this.pickingFBO,this.getMap());t.filter=t=>"line"!==this.getSymbol(t.properties.symbolIndex).textPlacement;const i=new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+js$1,uniforms:e,extraCommandProps:{viewport:this.pickingViewport}},this.pickingFBO,this.getMap());i.filter=t=>"line"===t.geometry.properties.textPlacement,this.picking=[t,i]}}getUniformValues(t,e){const n=e&&e.isRenderingTerrainSkin,i=this.layer.getTileSize().width,r=n?go$1:t.projViewMatrix,s=t.cameraToCenterDistance,o=set(lo$1,t.width,t.height);n&&set(o,i,i);const a=lt$3(t.getResolution(),t);return{layerScale:this.layer.options.styleScale||1,mapPitch:t.getPitch()*Math.PI/180,mapRotation:t.getBearing()*Math.PI/180,projViewMatrix:r,viewMatrix:t.viewMatrix,cameraToCenterDistance:s,canvasSize:o,glyphSize:24,gammaScale:1*(this.layer.options.textGamma||1),resolution:t.getResolution(),altitudeScale:a,viewport:n&&e&&e.viewport,textPitchFilter:0,isRenderingTerrain:+!!n}}}function bo$1(t,e,n,i){for(let r=n;r<i;r+=6){const n=e[r];for(let e=0;e<4;e++){const i=3*(n+e);(t[i]||t[i+1]||t[i+2])&&(t.dirty=!0,t[i]=0,t[i+1]=0,t[i+2]=0)}}}function Ao$1(t,e){const n=t.properties.level-e.properties.level;return 0===n?t.properties.meshKey-e.properties.meshKey:n}var wo$1="#define SHADER_NAME NATIVE_POINT\n#include <gl2_vert>\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\n#ifdef HAS_COLOR\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\nuniform mat4 positionMatrix;\nuniform mat4 projViewModelMatrix;\nuniform float markerSize;\n#ifdef PICKING_MODE\n#include <fbo_picking_vert>\n#endif\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n  gl_Position = projViewModelMatrix * positionMatrix * vec4(c, 1.);\n  gl_PointSize = markerSize;\n#ifdef HAS_COLOR\nvColor = aColor / 255.;\n#endif\n#ifdef PICKING_MODE\nfbo_picking_setData(gl_Position.w, true);\n#endif\n}";const _o$1={markerFill:[0,0,0],markerOpacity:1,markerSize:10};class So$1 extends Bi$1{getPrimitive(){return"points"}isTerrainSkin(){return!1}isTerrainVector(){return this.layer.options.awareOfTerrain}createMesh(t,e){const{geometry:i,symbolIndex:r,ref:s}=t,o=this.getSymbol(r);void 0===s&&(si$1(i,this.getSymbolDef(r),this.getFnTypeConfig(r)),i.generateBuffers(this.regl));const a={};Ct$3(a,"markerOpacity",o,"markerOpacity",1),Ct$3(a,"markerSize",o,"markerSize",10),Ct$3(a,"markerFill",o,"markerFill","#000",Rt$3(this.colorCache,3));const l=new Ce$5(a,_o$1);l.createDefines=()=>"square"!==o.markerType?{USE_CIRCLE:1}:null,l.appendDefines=t=>("square"!==o.markerType&&(t.USE_CIRCLE=1),t);const h=new Be$5(i,l,{castShadow:!1,picking:!0}),u={};return h.geometry.data.aAltitude&&(u.HAS_ALTITUDE=1),i.data.aColor&&(u.HAS_COLOR=1),h.setDefines(u),h.positionMatrix=this.getAltitudeOffsetMatrix(),h.setLocalTransform(e),h.properties.symbolIndex=r,h}createFnTypeConfig(t,e){const n=piecewiseConstant(e.markerFill);return[{attrName:"aColor",symbolName:"markerFill",type:Uint8Array,width:4,define:"HAS_COLOR",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=this.colorCache[r]=this.colorCache[r]||color(r).unitArray()),r=Dt$3(r),r}}]}init(){this.renderer=new B$6(this.regl);const e=[],i={vert:wo$1,frag:"#define SHADER_NAME NATIVE_POINT\nprecision mediump float;\n#include <gl2_frag>\n#ifdef USE_CIRCLE\n#if __VERSION__ == 100\n#ifdef GL_OES_standard_derivatives\n#define STANDARD_DERIVATIVES_ENABLED 1\n#extension GL_OES_standard_derivatives : enable\n#endif\n#else\n#define STANDARD_DERIVATIVES_ENABLED 1\n#endif\n#endif\n#ifdef HAS_COLOR\nvarying vec4 vColor;\n#else\nuniform vec3 markerFill;\n#endif\nuniform float markerOpacity;\nuniform float layerOpacity;\nvoid main() {\n  float c = 1.;\n#ifdef USE_CIRCLE\nfloat r = .0, d = .0;\n  vec2 e = 2. * gl_PointCoord - 1.;\n  r = dot(e, e);\n  if(r > 1.) {\n    discard;\n  }\n#ifdef STANDARD_DERIVATIVES_ENABLED\nd = fwidth(r);\n  c = 1. - smoothstep(1. - d, 1. + d, r);\n#endif\n#endif\n#ifdef HAS_COLOR\nvec4 f = vColor;\n#else\nvec4 f = vec4(markerFill, 1.);\n#endif\nglFragColor = f * markerOpacity * c * layerOpacity;\n#if __VERSION__ == 100\ngl_FragColor = glFragColor;\n#endif\n}",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,n){return multiply$5(e,n.projViewMatrix,n.modelMatrix),e}}],defines:null,extraCommandProps:{viewport:{x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1},depth:{enable:!0,mask:!1,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"always"},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"}}};if(this.shader=new vn$4(i),this.shader.version=300,this.pickingFBO){const t=[];this.picking=[new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+wo$1,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(e,n){return multiply$5(t,n.projViewMatrix,n.modelMatrix),t}}],extraCommandProps:{viewport:this.pickingViewport}},this.pickingFBO,this.getMap())]}}getUniformValues(t){return{projViewMatrix:t.projViewMatrix}}}var Mo$1="#define SHADER_NAME NATIVE_LINE\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nuniform mat4 projViewModelMatrix;\n#ifndef PICKING_MODE\n#if defined(HAS_COLOR)\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#else\n#include <fbo_picking_vert>\n#endif\n#include <vt_position_vert>\nvoid main() {\n  vec3 c = unpackVTPosition();\n  gl_Position = projViewModelMatrix * vec4(c, 1.);\n#ifndef PICKING_MODE\n#if defined(HAS_COLOR)\nvColor = aColor / 255.;\n#endif\n#else\nfbo_picking_setData(gl_Position.w, true);\n#endif\n}";const Po$1=identity$2([]);class To$1 extends Bi$1{constructor(t,e,n,i,r,s){if(super(t,e,n,i,r,s),this.primitive="lines",isFunctionDefinition(this.symbolDef.lineColor)){const t=e.getMap(),n=piecewiseConstant(this.symbolDef.lineColor);this.colorSymbol=e=>n(t.getZoom(),e)}}needPolygonOffset(){return!0}createMesh(t,e){const{geometry:i,symbolIndex:r,ref:s}=t,o=this.getSymbol(r),a=this.getMeshUniforms(i,o);void 0===s&&i.generateBuffers(this.regl);const l=new Ce$5(a),h=new Be$5(i,l,{castShadow:!1,picking:!0});h.setLocalTransform(e),h.properties.symbolIndex=r;const u={};return h.geometry.data.aAltitude&&(u.HAS_ALTITUDE=1),h.setDefines(u),h}getMeshUniforms(t,e){const n={};return Ct$3(n,"lineColor",e,"lineColor","#000",Rt$3(this.colorCache)),Ct$3(n,"lineOpacity",e,"lineOpacity",1),n}init(t){const e=this.layer.getRenderer().isEnableTileStencil()&&(!t||!t.isRenderingTerrain||!this.isTerrainSkin());this.renderer=new B$6(this.regl);const s=this.canvas,o={x:(t,e)=>e.viewport?e.viewport.x:0,y:(t,e)=>e.viewport?e.viewport.y:0,width:(t,e)=>e.viewport?e.viewport.width:s?s.width:1,height:(t,e)=>e.viewport?e.viewport.height:s?s.height:1},a=[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],h={vert:Mo$1,frag:"#define SHADER_NAME NATIVE_LINE\nprecision mediump float;\nuniform float lineOpacity;\nuniform vec4 lineColor;\nuniform float layerOpacity;\n#if defined(HAS_COLOR)\nvarying vec4 vColor;\n#endif\nvoid main() {\n  gl_FragColor = lineColor * lineOpacity;\n#if defined(HAS_COLOR)\ngl_FragColor *= vColor;\n#endif\ngl_FragColor *= layerOpacity;\n}",uniforms:a,defines:null,extraCommandProps:{viewport:o,stencil:{enable:!0,mask:255,func:{cmp:()=>e?"=":"<=",ref:(t,n)=>e?n.stencilRef:n.level,mask:255},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"<="},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}};this.shader=new vn$4(h),this.pickingFBO&&(this.picking=[new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+Mo$1,uniforms:a,extraCommandProps:{viewport:this.pickingViewport}},this.pickingFBO,this.getMap())])}getUniformValues(t,e){const n=e&&e.isRenderingTerrainSkin;return{projViewMatrix:n?Po$1:t.projViewMatrix,viewport:n&&e&&e.viewport}}getPrimitive(){return"lines"}}const ko$1=[0,0],Oo$1=[1,1,1],Io$1=[1,1,1,1],Fo$1=[0,0],Co$1=[1,1],Eo$1=[],Do$1=new t__namespace.Coordinate(0,0),Ro$1=new t__namespace.Coordinate(0,0),Lo$1=[],No$1=[];class Ho$1 extends Vi$1{supportRenderMode(t){return this.isAnimating()?"fxaa"===t||"fxaaAfterTaa"===t:"taa"===t||"fxaa"===t}isTerrainSkin(){return!1}isTerrainVector(){return this.layer.options.awareOfTerrain}isAnimating(){return!1}createMesh(e,i,{tilePoint:s}){if(!this.material)return this.setToRedraw(),null;const{geometry:o,symbolIndex:a}=e,l=this.layer instanceof t__namespace.TileLayer,u=new Be$5(o,this.material);if(this.sceneConfig.animation){Oo$1[2]=.01;const t=[];fromScaling(t,Oo$1),multiply$5(t,i,t),i=t}const c=this.getSymbolDef(a),f=this.getFnTypeConfig(a);si$1(o,c,f);const d=this.getShader(),p=d.getGeometryDefines?d.getGeometryDefines(o):{},m=this.getSymbol(a),y=Rt$3(this.colorCache);if(o.data.aExtrude){p.IS_LINE_EXTRUSION=1;const{tileResolution:t,tileRatio:e}=o.properties,n=this.getMap();Object.defineProperty(u.uniforms,"linePixelScale",{enumerable:!0,get:function(){return e*n.getResolution()/t}}),Ct$3(u.uniforms,"lineWidth",m,"lineWidth",4),Ct$3(u.uniforms,"lineOpacity",m,"lineOpacity",1),Ct$3(u.uniforms,"lineColor",m,"lineColor","#fff",y),Object.defineProperty(u.uniforms,"lineHeight",{enumerable:!0,get:()=>{const t=this.dataConfig.defaultAltitude*(this.dataConfig.altitudeScale||1);return Ht$2(t)?t:0}})}else{Ct$3(u.uniforms,"polygonFill",m,"polygonFill",Io$1,y),Ct$3(u.uniforms,"polygonOpacity",m,"polygonOpacity",1);const t=[];Object.defineProperty(u.uniforms,"vertexColorsOfType",{enumerable:!0,get:()=>{const e=y(m.bottomPolygonFill||Io$1),n=y(m.topPolygonFill||Io$1);t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=n[0],t[5]=n[1],t[6]=n[2],t[7]=n[3];const i=u.geometry.properties.vertexColors;if(i){let e=8;t.length=8+i.length;for(let n=0;n<i.length;n++)t[e++]=i[n][0],t[e++]=i[n][1],t[e++]=i[n][2],t[e++]=i[n][3]}return t}})}if(o.data.aColor&&(p.HAS_COLOR=1),o.data.aOpacity&&(p.HAS_OPACITY=1),o.data.aLineWidth&&(p.HAS_LINE_WIDTH=1),o.data.aLineHeight&&(p.HAS_LINE_HEIGHT=1),o.data.aTerrainAltitude&&(p.HAS_TERRAIN_ALTITUDE=1),o.data.aVertexColorType){const t=u.geometry.properties.vertexColors;let e=2;t&&(e+=t.length),p.VERTEX_TYPES_COUNT=e}if(o.data.aOpacity){const t=o.data.aOpacity;for(let e=0;e<t.length;e++)if(t[e]<255){o.properties.hasAlpha=!0;break}}p.HAS_MIN_ALTITUDE=1,p.HAS_LAYER_OPACITY=1,o.generateBuffers(this.regl),u.setDefines(p),u.setPositionMatrix(this.getAltitudeOffsetMatrix()),u.setLocalTransform(i),(o.properties.maxAltitude<=0||u.properties.level>=3)&&(u.castShadow=!1),u.setUniform("maxAltitude",u.geometry.properties.maxAltitude),Object.defineProperty(u.uniforms,"minAltitude",{enumerable:!0,get:()=>this.layer.options.altitude||0});const{tileResolution:g}=o.properties,v=this.getMap(),x=this.layer.getRenderer(),b=v.pointAtResToCoord(new t__namespace.Point(s),g),A=function(t,e,n,i,r){return t.pointAtResToDistance(1,0,i,n)}(v,0,b,g),w=[];Object.defineProperty(u.uniforms,"uvOrigin",{enumerable:!0,get:()=>{const t=this.fo(_,a,s,g,A,l);return set(w,t[0]-t[0]%1,t[1]-t[1]%1)}});const _=[];Object.defineProperty(u.uniforms,"uvOffset",{enumerable:!0,get:()=>{const t=this.fo(_,a,s,g,A,l);return set(w,t[0]%1,t[1]%1)}}),Object.defineProperty(u.uniforms,"hasAlpha",{enumerable:!0,get:()=>{const t=this.getSymbol(a);return o.properties.hasAlpha||t.polygonOpacity<1||t.lineOpacity<1||u.material&&(u.material.uniforms.baseColorTexture||u.material.uniforms.emissiveTexture)}});const S=this.layer.getMap().getMaxNativeZoom();return Object.defineProperty(u.uniforms,"stencilRef",{enumerable:!0,get:()=>x.isForeground(u)?0:S-u.properties.tile.z}),u.properties.symbolIndex=a,u}fo(t,e,n,i,r,s){if(1===this.dataConfig.topUVMode)return ko$1;const o=this.getMap(),a=this.getSymbol(e).material;let l=n;!this.dataConfig.side&&a&&a.textureOrigin&&(Do$1.set(a.textureOrigin[0],a.textureOrigin[1]),o.coordToPointAtRes(Do$1,i,Ro$1),l=set(Lo$1,n[0]-Ro$1.x,n[1]-Ro$1.y));const u=!!a&&a.uvOffsetInMeter;let c=a&&a.uvOffset||Fo$1;const f=this.getUVOffsetAnim();f&&(c=this.getUVOffset(f));const d=a&&a.uvScale||Co$1;let p=this.dataConfig.side?0:l[0],m=this.dataConfig.side?0:l[1];const y=a&&a.textureWidth||23.25;u&&(p+=c[0]/r,m+=c[1]/r);const b=set(t,p*r*d[0]/y+(u?0:c[0]),m*r*d[1]/(y*d[1]/d[0])+(u?0:c[1]));return s||(b[1]*=-1),b}callShader(t,e){const n=this.sceneConfig.cullFace;this.sceneConfig.cullFace="front",this.callBackgroundTileShader(t,e),void 0===n?delete this.sceneConfig.cullFace:this.sceneConfig.cullFace=n,super.callShader(t,e)}getShadowMeshes(){if(!this.isVisible())return Eo$1;this.shadowCount=this.scene.getMeshes().length;const t=this.scene.getMeshes().filter((t=>0===t.properties.level));for(let e=0;e<t.length;e++){const n=t[e];n.material!==this.material&&n.setMaterial(this.material)}return t}getUVOffsetAnim(){const t=this.getSymbols()[0];return t.material&&t.material.uvOffsetAnim}getUVOffset(t){const e=this.getSymbols()[0],n=e.material&&e.material.uvOffset||Fo$1,i=!!e.material&&e.material.uvOffsetInMeter,r=performance.now()/1e3,s=set(No$1,n[0],n[1]);return s[0]=r*t[0],s[1]=r*t[0],i||(s[0]%=1,s[1]%=1),s}needPolygonOffset(){return this.do}startFrame(...t){return delete this.do,super.startFrame(...t)}addMesh(t,e){t.forEach((t=>{this._r(t,e)})),super.addMesh(...arguments)}_r(t,e){if(null!==e){const n=t.localTransform;0===e&&(e=.01),Oo$1[2]=e,fromScaling(n,Oo$1),multiply$5(n,t.properties.tileTransform,n),t.setLocalTransform(n)}else t.setLocalTransform(t.properties.tileTransform);t.material!==this.material&&t.setMaterial(this.material),t.geometry.properties.maxAltitude<=0&&(this.do=!0),t.ssr=this.getSymbol(t.properties.symbolIndex).ssr?1:0}deleteMaterial(){this.material&&(this.material.dispose(),delete this.material)}deleteMesh(t,e){if(t)if(this.scene.removeMesh(t),Array.isArray(t))for(let n=0;n<t.length;n++)e||(t[n].geometry.dispose(),delete t[n].geometry.properties.layer),t[n].dispose();else e||(t.geometry.dispose(),delete t.geometry.properties.layer),t.dispose()}updateDataConfig(t,e){return!("line-extrusion"===this.dataConfig.type&&!t.altitudeProperty&&!e.altitudeProperty)}createFnTypeConfig(t,e){const n=piecewiseConstant(e.polygonFill||e.lineColor),i=interpolated(e.polygonOpacity||e.lineOpacity),r=interpolated(e.lineWidth),s=new Uint8Array(1),o=new Uint16Array(1);return[{attrName:"aColor",type:Uint8Array,width:4,symbolName:e.polygonFill?"polygonFill":e.lineColor?"lineColor":"polygonFill",define:"HAS_COLOR",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=this.colorCache[r]=this.colorCache[r]||color(r).unitArray()),r=Dt$3(r),r}},{attrName:"aOpacity",type:Uint8Array,width:1,symbolName:e.polygonOpacity?"polygonOpacity":e.lineOpacity?"lineOpacity":"polygonOpacity",evaluate:(e,n)=>{let r=i(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,n,t,e,!1)),s[0]=255*r,s[0]<255&&(n.properties.hasAlpha=!0),s[0]}},{attrName:"aLineWidth",type:Uint8Array,width:1,symbolName:"lineWidth",define:"HAS_LINE_WIDTH",evaluate:e=>{const n=r(t.getZoom(),e);return o[0]=Math.round(2*n),o[0]}}]}updateSymbol(t,e){let n=!1;t&&t.material&&(n=function(t,e){for(const n in e)if(Vo$1[n]&&e[n]!==t[n]&&(!t[n]||!e[n]))return!0;return!1}(this.symbolDef[0].material||{},t.material));const i=super.updateSymbol(t,e);return t&&t.material&&this.ri(t.material),n||i}Qi(t,e){return zo$1(t)!==zo$1(e)}}function zo$1(t){if(!t||!t.material)return!1;for(const e in t.material)if(e.indexOf("Texture")>0&&t.material[e])return!0;return!1}const Vo$1={normalTexture:1,bumpTexture:1};class Uo$1 extends Ho$1{createGeometry(t){const e=t.data,i=this.getSymbols()[0];if(i.material&&i.material.extrusionOpacity){const t=new Uint8Array(e.aPosition.length/3);for(let n=0;n<e.aPosition.length;n+=3)t[n/3]=e.aPosition[n+2]>0?0:1;e.aExtrusionOpacity=t}const r=new Q$7(e,t.indices);return Tt$3(r.properties,t.properties),this.dr(r,t),{geometry:r,symbolIndex:{index:0}}}updateSceneConfig(t){let e;if(this.sceneConfig.cullFace!==t.cullFace&&(e=!0),Tt$3(this.sceneConfig,t),e){const t=this.getShaderConfig();this.shader.dispose(),this.shader=new bn$4(t)}this.setToRedraw()}getShader(){return this.shader}delete(t){this.getMap().off("updatelights",this.po,this),super.delete(t),this.material.dispose()}init(){this.getMap().on("updatelights",this.po,this);this.renderer=new B$6(this.regl);const e=this.getShaderConfig();this.shader=new bn$4(e),this.ri();const i={vert:this.getPickingVert(),uniforms:["projViewMatrix","modelMatrix","positionMatrix",{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5([],e.projViewMatrix,e.modelMatrix)}}],extraCommandProps:{viewport:this.pickingViewport}};this.picking=[new Cr$4(this.renderer,i,this.layer.getRenderer().pickingFBO,this.getMap())]}po(){this.setToRedraw()}getShaderConfig(){const t=this.canvas,e={x:0,y:0,width:()=>t?t.width:1,height:()=>t?t.height:1};return{extraCommandProps:{cull:{enable:()=>void 0===this.sceneConfig.cullFace||!!this.sceneConfig.cullFace,face:()=>{let t=this.sceneConfig.cullFace;return!0===t&&(t="back"),t||"back"}},stencil:{enable:!0,func:{cmp:"<=",ref:(t,e)=>e.level},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"<="},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},viewport:e,polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}}}ri(){this.material&&this.material.dispose();const t=this.getSymbols()[0].material,e={};for(const n in t)Vt$2(t,n)&&(e[n]=t[n]);this.material=new Ie$5(e)}getUniformValues(t,e){const n=t.viewMatrix,i=t.projMatrix,r=t.cameraPosition,s=this.mo(),o=Tt$3({viewMatrix:n,projMatrix:i,cameraPosition:r,projViewMatrix:t.projViewMatrix},s);o.halton=e&&e.jitter?e.jitter:[0,0];const a=this.layer.getRenderer().canvas;return o.outSize=[a.width,a.height],o}getPickingVert(){return"\n            attribute vec3 aPosition;\n            uniform mat4 projViewModelMatrix;\n            uniform mat4 modelMatrix;\n            uniform mat4 positionMatrix;\n            //å¼•å…¥fbo pickingçš„vertç›¸å…³å‡½æ•°\n            #include <fbo_picking_vert>\n            #include <get_output>\n            void main()\n            {\n                mat4 localPositionMatrix = getPositionMatrix();\n                vec4 localPosition = getPosition(aPosition);\n\n                gl_Position = projViewModelMatrix * localPositionMatrix * localPosition;\n                //ä¼ å…¥gl_Positionçš„depthå€¼\n                fbo_picking_setData(gl_Position.w, true);\n            }\n        "}mo(){const t=this.getMap().getLightManager(),e=t&&t.getAmbientLight()||{},n=t&&t.getDirectionalLight()||{};return{ambientColor:e.color||[.2,.2,.2],light0_diffuse:[...n.color||[.1,.1,.1],1],lightSpecular:n.specular||[.8,.8,.8],light0_viewDirection:n.direction||[1,1,-1]}}}const jo$1=[1,1,1];class Bo$1 extends Vi$1{createGeometry(t){const{data:e,indices:i}=t,r=new Q$7(e,i,0,{primitive:"lines"});return r.generateBuffers(this.regl),{geometry:r,symbolIndex:{index:0}}}createMesh(t,e){const{geometry:i}=t,s=new Be$5(i);if(s.castShadow=!1,this.sceneConfig.animation){jo$1[2]=.01;const t=[];fromScaling(t,jo$1),multiply$5(t,e,t),e=t}return s.setLocalTransform(e),s.properties.symbolIndex={index:0},s}addMesh(t,e){if(!t.length)return this;let n;null!==e?(0===e&&(e=.01),n=t[0].localTransform,jo$1[2]=e,fromScaling(n,jo$1),multiply$5(n,t[0].properties.tileTransform,n)):n=t[0].properties.tileTransform;for(let e=0;e<t.length;e++)t[e].setLocalTransform(n);return this.scene.addMesh(t),this}init(){const t=this.regl;this.scene=new Ke$5,this.renderer=new B$6(t);const e={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1},i={vert:"\n    attribute vec3 aPosition;\n    attribute vec4 aColor;\n\n    uniform mat4 projViewModelMatrix;\n    uniform vec2 outSize;\n\n    varying vec4 vColor;\n\n    void main()\n    {\n        gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n        vColor = aColor / 255.0;\n    }\n",frag:"\n    #ifdef GL_ES\n        precision lowp float;\n    #endif\n\n    uniform float opacity;\n\n    varying vec4 vColor;\n\n    void main()\n    {\n        gl_FragColor = vColor * opacity;\n    }\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],extraCommandProps:{stencil:{enable:!0,func:{cmp:"<=",ref:(t,e)=>e.level},op:{fail:"keep",zfail:"keep",zpass:"replace"}},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},viewport:e}};this.shader=new vn$4(i)}getUniformValues(t){const e=this.sceneConfig.opacity||.3,n=this.layer.getRenderer().canvas;return{projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],opacity:e}}}const{getPBRUniforms:Go$1}=fi$4.PBRUtils;class Wo$1 extends Ho$1{constructor(...t){super(...t),this.yo=new Ve$5,this.scene.sortFunction=this.sortByCommandKey}supportRenderMode(t){return this.getSymbols()[0].ssr?"fxaa"===t||"fxaaAfterTaa"===t:super.supportRenderMode(t)}isAnimating(){const t=this.vo();if(t&&(t[0]||t[1]))return!0}needToRedraw(){const t=this.vo();return!(!t||!t[0]&&!t[1])||super.needToRedraw()}vo(){const t=this.getSymbols()[0];return t.material&&t.material.uvOffsetAnim}createGeometry(t){if(!t.data||!t.data.aPosition||!t.data.aPosition.length)return null;const e={uv0Attribute:"aTexCoord0"};t.aAltitude&&(e.altitudeAttribute="aAltitude");const i=new Q$7(t.data,t.indices,0,e);return Tt$3(i.properties,t.properties),t.vertexColors&&(i.properties.vertexColors=t.vertexColors),this.material.uniforms.normalTexture&&!i.data[i.desc.tangentAttribute]&&i.data[i.desc.uv0Attribute]&&(i.data[i.desc.normalAttribute]||i.createNormal(),i.createTangent()),this.dr(i,t),{geometry:i,symbolIndex:{index:0}}}paint(t){const e=!!t.shadow;t.states&&t.states.includesChanged&&(this.shader.dispose(),delete this.shader,this.xo.dispose(),delete this.xo,this.br(t));let n=!!t.ssr&&this.getSymbols()[0].ssr;const i=this.shader,r=i.shaderDefines;if(n){const e=Tt$3({},r,t.ssr.defines);i.shaderDefines=e}if(t.onlyUpdateDepthInTaa&&(this.shader=this.xo,!n&&this.bo&&(this.shader=i,this.setToRedraw(!0))),this.updateIBLDefines(i),super.paint(t),void 0!==this.shadowCount&&e){const t=this.scene.getMeshes().length;this.shadowCount!==t&&this.setToRedraw()}this.shader=i,n&&(i.shaderDefines=r),delete this.shadowCount,this.bo=n}updateSceneConfig(t){Tt$3(this.sceneConfig,t),this.setToRedraw()}delete(){super.delete(),this.disposeIBLTextures(),this.material.dispose(),this.xo&&(this.xo.dispose(),delete this.xo)}init(t){this.getMap().on("updatelights",this.Ao,this),this.createIBLTextures(),this.Sr=this.Sr||t;this.renderer=new B$6(this.regl),this.wo=this._o.bind(this),this.So=this.disposeCachedTexture.bind(this),this.Mo=this.Po.bind(this),this.ri(),this.br(t);const i={vert:"\n                #include <gl2_vert>\n                attribute vec3 aPosition;\n                uniform mat4 projViewModelMatrix;\n                uniform mat4 positionMatrix;\n                //å¼•å…¥fbo pickingçš„vertç›¸å…³å‡½æ•°\n                #include <line_extrusion_vert>\n                #include <get_output>\n                #include <fbo_picking_vert>\n                void main() {\n                    mat4 localPositionMatrix = getPositionMatrix();\n                    #ifdef IS_LINE_EXTRUSION\n                        vec3 linePosition = getLineExtrudePosition(aPosition);\n                        vec4 localVertex = getPosition(linePosition);\n                    #else\n                        vec4 localVertex = getPosition(aPosition);\n                    #endif\n\n                    gl_Position = projViewModelMatrix * localPositionMatrix * localVertex;\n                    fbo_picking_setData(gl_Position.w, true);\n                }\n            ",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>multiply$5([],e.projViewMatrix,e.modelMatrix)}],extraCommandProps:{viewport:this.pickingViewport,depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"<=",mask:!!It$3(this.sceneConfig.depthMask)||this.sceneConfig.depthMask}}};this.picking=[new Cr$4(this.renderer,i,this.layer.getRenderer().pickingFBO,this.getMap())]}br(t){const e={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1},i={},r=[];r.push(...jn$4.getUniformDeclares()),this.fillIncludes(i,r,t);const s={cull:{enable:()=>void 0===this.sceneConfig.cullFace||!!this.sceneConfig.cullFace,face:()=>this.sceneConfig.cullFace||"back"},stencil:{enable:(t,e)=>void 0===e.hasAlpha||!!e.hasAlpha,func:{cmp:"<=",ref:(t,e)=>e.stencilRef},op:{fail:"keep",zfail:"keep",zpass:"replace"}},viewport:e,depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"<="},blend:{enable:(t,e)=>void 0===e.hasAlpha||!!e.hasAlpha,func:this.getBlendFunc(),equation:"add"},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}},o={uniforms:r,defines:this.To(i),extraCommandProps:s};this.shader=new fi$4.StandardShader(o),o.frag="\n            precision mediump float;\n            #include <gl2_frag>\n            void main() {\n                glFragColor = vec4(0.0);\n                #if __VERSION__ == 100\n                    gl_FragColor = glFragColor;\n                #endif\n            }\n        ",this.xo=new fi$4.StandardShader(o)}_o({resources:t}){for(let e=0;e<t.length;e++)this.addCachedTexture(t[e].url,t[e].data);this.setToRedraw(!0)}Po(){this.setToRedraw(!0)}ri(t){if(t){const e=this.getSymbols()[0].material;e&&Tt$3(e,t)}const e=this.dataConfig,i=t||this.getSymbols()[0].material,r={};let s=!1;for(const t in i)if(Vt$2(i,t))if(t.indexOf("Texture")>0){let o=i[t];if(!o){r[t]=void 0;continue}const a="string"==typeof o?o:o.url,l=this.getCachedTexture(a);l?l.then?a===o?o={promise:l,wrap:"repeat"}:o.promise=l:a===o?o={data:l,wrap:"repeat"}:o.data=l:a===o&&(o={url:a,wrap:"repeat"}),o.flipY=!e.upsideUpTexture,o.min="linear mipmap linear",o.mag="linear",r[t]=new en$5(o,this.yo),r[t].once("complete",this.wo),r[t].once("disposed",this.So),r[t].promise&&this.addCachedTexture(a,r[t].promise),s=!0}else r[t]=i[t];if(void 0===r.alphaTest&&this.getMaterialClazz&&(r.alphaTest=.05),this.material){for(let t in r)this.material.set(t,r[t]);this.setToRedraw(!0)}else this.material=new fi$4.StandardMaterial(r),this.material.once("complete",this.Mo);s||this.Po()}getShader(){return this.shader}getUniformValues(t,e){const{iblTexes:n,dfgLUT:i}=this.getIBLRes(),r=Go$1(t,n,i,e&&e.ssr,e&&e.jitter);return this.setIncludeUniformValues(r,e),r}To(t){return this.hasIBL()?t.HAS_IBL_LIGHTING=1:delete t.HAS_IBL_LIGHTING,t}Ao(){if(!this.shader)return;const t=this.shader.shaderDefines;this.To(t),this.shader.shaderDefines=t}}var Xo$1="#include <gl2_vert>\n#define EXTRUDE_SCALE 63.0\n#define EXTRUDE_MOD 64.0\n#define MAX_LINE_DISTANCE 65535.0\nuniform mat4 projViewModelMatrix;\nuniform vec2 centiMeterToLocal;\n#ifdef HAS_ALTITUDE\nattribute vec2 aPosition;\nattribute float aAltitude;\n#else\nattribute vec3 aPosition;\n#endif\nattribute vec4 aTubeNormal;\n#ifdef HAS_LINE_WIDTH\nattribute float aLineWidth;\n#else\nuniform float lineWidth;\n#endif\n#include <vt_position_vert>\n#ifdef PICKING_MODE\n#include <fbo_picking_vert>\n#else\nuniform mat4 modelViewMatrix;\nuniform mat3 modelNormalMatrix;\nuniform mat4 modelMatrix;\n#if defined(HAS_PATTERN)\nuniform float resolution;\nuniform float tileResolution;\nuniform float tileRatio;\nattribute float aLinesofar;\nvarying highp float vLinesofar;\nattribute vec4 aTexInfo;\nvarying vec4 vTexInfo;\nvarying float vNormalY;\nvarying float vPatternHeight;\nattribute float aNormalDistance;\n#if defined(HAS_PATTERN_ANIM)\nattribute float aLinePatternAnimSpeed;\nvarying float vLinePatternAnimSpeed;\n#endif\n#if defined(HAS_PATTERN_GAP)\nattribute float aLinePatternGap;\nvarying float vLinePatternGap;\n#endif\n#endif\n#ifdef HAS_COLOR\nattribute vec4 aColor;\nvarying vec4 vColor;\n#endif\n#ifdef HAS_OPACITY\nattribute float aOpacity;\n#endif\nvarying float vOpacity;\nvarying vec3 vModelNormal;\nvarying vec4 vViewVertex;\nvarying vec3 vModelVertex;\n#endif\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n#include <vsm_shadow_vert>\n#endif\n#include <highlight_vert>\nvoid main() {\n  \n#ifdef HAS_LINE_WIDTH\nfloat c = aLineWidth;\n#else\nfloat c = lineWidth;\n#endif\nfloat d = c / 2.;\n  vec3 e = aTubeNormal.xyz / EXTRUDE_SCALE;\n  vec3 f = unpackVTPosition();\n  vec4 h = vec4(f, 1.);\n  h.xy += e.xy * d * centiMeterToLocal;\n  h.z += e.z * d;\n  gl_Position = projViewModelMatrix * h;\n#ifdef PICKING_MODE\nfbo_picking_setData(gl_Position.w, true);\n#else\nvViewVertex = modelViewMatrix * h;\n  vec3 i = normalize(e);\n  vModelNormal = modelNormalMatrix * i;\n  vModelVertex = (modelMatrix * h).xyz;\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\nshadow_computeShadowPars(h);\n#endif\n#ifdef HAS_COLOR\nvColor = aColor / 255.;\n#endif\n#ifdef HAS_OPACITY\nvOpacity = aOpacity / 255.;\n#else\nvOpacity = 1.;\n#endif\n#ifdef HAS_PATTERN\nfloat j = tileResolution / resolution;\n  float k = aLinesofar - d * centiMeterToLocal.y * aNormalDistance / EXTRUDE_SCALE;\n  vLinesofar = k / tileRatio * j;\n  vTexInfo = vec4(aTexInfo.xy, aTexInfo.zw + 1.);\n  vPatternHeight = c * centiMeterToLocal.x / tileRatio * j;\n  vNormalY = aTubeNormal.w / EXTRUDE_SCALE;\n#if defined(HAS_PATTERN_ANIM)\nvLinePatternAnimSpeed = aLinePatternAnimSpeed / 127.;\n#endif\n#if defined(HAS_PATTERN_GAP)\nvLinePatternGap = aLinePatternGap / 10.0;\n#endif\n#endif\nhighlight_setVarying();\n#endif\n}";const{getPBRUniforms:Yo$1}=fi$4.PBRUtils;class $o$1 extends Bi$1{needToRedraw(){return super.needToRedraw()||this.isAnimating()}isTerrainSkin(){return!1}isTerrainVector(){return!0}supportRenderMode(t){return this.isAnimating()?"fxaa"===t||"fxaaAfterTaa"===t:"taa"===t||"fxaa"===t}isAnimating(){if(this.Ar)return!0;const t=this.getSymbols();for(let e=0;e<t.length;e++)if(t[e].linePatternFile&&t[e].linePatternAnimSpeed)return!0;return!1}isBloom(t){return!!this.getSymbol(t.properties.symbolIndex).lineBloom}createMesh(e,i){if(!e.geometry)return null;const r=this.getMap(),{geometry:s,symbolIndex:o,ref:a}=e,l=this.getSymbolDef(o);void 0===a&&si$1(s,l,this.getFnTypeConfig(o));const h=this.getSymbol(o),{tileResolution:u,tileRatio:c}=s.properties,f={tileResolution:u,tileRatio:c};Ct$3(f,"lineColor",h,"lineColor","#fff",Rt$3(this.colorCache)),Ct$3(f,"linePatternGapColor",h,"linePatternGapColor",[1,1,1,1],Rt$3(this.colorCache)),Ct$3(f,"lineWidth",h,"lineWidth",2,(t=>nt$4.getTubeSizeScale(this.dataConfig.metric)*t)),Ct$3(f,"lineOpacity",h,"lineOpacity",1),Ct$3(f,"linePatternAnimSpeed",h,"linePatternAnimSpeed",0),Ct$3(f,"linePatternGap",h,"linePatternGap",0),Ct$3(f,"metallicFactor",h,"metallicFactor",0),Ct$3(f,"roughnessFactor",h,"roughnessFactor",.4),Ct$3(f,"emissiveFactor",h,"emissiveFactor",[0,0,0]),Ct$3(f,"uvScale",h,"uvScale",[1,1]);const d=s.properties.iconAtlas,p=this.layer instanceof t__namespace.TileLayer;d&&(f.linePatternFile=Wi$1(this.regl,d,!1),f.atlasSize=d?[d.width,d.height]:[0,0],f.flipY=p?-1:1,this.drawDebugAtlas(d)),void 0===a&&s.generateBuffers(this.regl),f.alphaTest=-1;const m=new fi$4.StandardMaterial(f),y=new Be$5(s,m,{castShadow:!1,picking:!0}),g=r.distanceToPointAtRes(100,100,s.properties.tileResolution)._multi(c/1e4).toArray();y.setUniform("centiMeterToLocal",g);const v=r.getResolution(r.getMaxNativeZoom());y.setUniform("animSpeedScale",u/v),y.setLocalTransform(i);const x={IS_LINE_EXTRUSION:1,HAS_LAYER_OPACITY:1};return"square-tube"===this.dataConfig.type&&(x.IS_SQUARE_TUBE=1),d&&(x.HAS_PATTERN=1),y.properties.symbolIndex=o,s.data.aColor&&(x.HAS_COLOR=1),this.setMeshDefines(x,s,l),s.data.aAltitude&&(x.HAS_ALTITUDE=1),y.setDefines(x),y}setMeshDefines(t,e,n){e.data.aOpacity&&(t.HAS_OPACITY=1),e.data.aLineWidth&&(t.HAS_LINE_WIDTH=1),yi$1(n.linePatternAnimSpeed)&&(t.HAS_PATTERN_ANIM=1),yi$1(n.linePatternGap)&&(t.HAS_PATTERN_GAP=1)}paint(t){t.states&&t.states.includesChanged.shadow&&(this.shader.dispose(),this.createShader(t)),super.paint(t)}init(t){this.getMap().on("updatelights",this.Ao,this),this.createIBLTextures();if(this.renderer=new B$6(this.regl),this.createShader(t),this.pickingFBO){const t=[];this.picking=[new Cr$4(this.renderer,{vert:"#define PICKING_MODE 1\n"+Xo$1,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}},{name:"modelNormalMatrix",type:"function",fn:(e,n)=>fromMat4$1(t,n.modelMatrix)}],extraCommandProps:this.getExtraCommandProps()},this.pickingFBO,this.getMap())]}}createShader(t){this.Sr=t;const e=[],i={};this.fillIncludes(i,e,t),e.push({name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}),this.shader=new fi$4.StandardShader({vert:Xo$1,uniforms:e,defines:this.To(i),extraCommandProps:this.getExtraCommandProps()})}getExtraCommandProps(){const t=this.canvas;return{viewport:{x:0,y:0,width:()=>t?t.width:1,height:()=>t?t.height:1},stencil:{enable:!0,func:{cmp:()=>"<=",ref:(t,e)=>e.level},op:{fail:"keep",zfail:"keep",zpass:"replace"}},cull:{enable:()=>!!this.sceneConfig.cullFace,face:this.sceneConfig.cullFace||"back"},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],mask:this.sceneConfig.depthMask||!0,func:this.sceneConfig.depthFunc||"<="},blend:{enable:!0,func:this.getBlendFunc(),equation:"add"},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}}getUniformValues(t,e){const{iblTexes:n,dfgLUT:i}=this.getIBLRes(),r=Yo$1(t,n,i,null,e&&e.jitter),o=t.viewMatrix;return r.projViewMatrix=t.projViewMatrix,r.viewMatrix=o,r.resolution=t.getResolution(),r.currentTime=this.layer.getRenderer().getFrameTimestamp()||0,this.setIncludeUniformValues(r,e),r}createFnTypeConfig(t,e){const n=piecewiseConstant(e.lineColor),i=piecewiseConstant(e.aLinePatternAnimSpeed),r=piecewiseConstant(e.aLinePatternGap),s=this.createShapeFnTypeConfigs(t,e),o=new Int8Array(2);return[{attrName:"aColor",symbolName:"lineColor",type:Uint8Array,width:4,define:"HAS_COLOR",evaluate:(e,i)=>{let r=n(t.getZoom(),e);return isFunctionDefinition(r)&&(r=this.evaluateInFnTypeConfig(r,i,t,e,!0)),Array.isArray(r)||(r=this.colorCache[r]=this.colorCache[r]||color(r).unitArray()),r=Dt$3(r),r}},{attrName:"aLinePattern",symbolName:"linePatternAnimSpeed",type:Int8Array,width:2,related:["linePatternGap"],define:"HAS_LINE_PATTERN",evaluate:(e,n,r,s)=>{let a=i(t.getZoom(),e);return It$3(a)&&(a=0),0!==a&&(n.properties.hasPatternAnim=1),o[0]=a/127,o[1]=r[s+1],o}},{attrName:"aLinePattern",symbolName:"linePatternGap",type:Int8Array,width:2,related:["linePatternAnimSpeed"],define:"HAS_LINE_PATTERN",evaluate:(e,n,i,s)=>{let a=r(t.getZoom(),e);return It$3(a)&&(a=0),o[1]=10*a,o[0]=i[s],o}}].concat(s)}createShapeFnTypeConfigs(t,e){const n=interpolated(e.lineWidth),i=interpolated(e.lineOpacity),r=new Uint16Array(1);return[{attrName:"aLineWidth",symbolName:"lineWidth",type:Uint8Array,width:1,define:"HAS_LINE_WIDTH",evaluate:(e,i)=>{let s=n(t.getZoom(),e);return isFunctionDefinition(s)&&(s=this.evaluateInFnTypeConfig(s,i,t,e)),r[0]=Math.round(2*s),r[0]}},{attrName:"aOpacity",symbolName:"lineOpacity",type:Uint8Array,width:1,define:"HAS_OPACITY",evaluate:(e,n)=>{let s=i(t.getZoom(),e);return isFunctionDefinition(s)&&(s=this.evaluateInFnTypeConfig(s,n,t,e)),r[0]=255*s,r[0]}}]}To(t){return this.hasIBL()?t.HAS_IBL_LIGHTING=1:delete t.HAS_IBL_LIGHTING,t}Ao(){if(!this.shader)return;const t=this.shader.shaderDefines;this.To(t),this.shader.shaderDefines=t}delete(){super.delete(),this.disposeIBLTextures(),this.shader&&(this.shader.dispose(),delete this.shader)}}const qo$1=[],Jo$1=[],Ko$1=[],Zo$1=[],Qo$1=[],ta=[0,0,0],ea=[0,0,0],na=[1,1,1],ia=[],ra=[1,1,1,1],sa=[],oa=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],aa=t=>class extends t{constructor(t,e,i,r,s,o){super(t,e,i,r,s,o),this.ko=!1,this.scene.sortFunction=this.sortByCommandKey,this.Oo=new Bt$6(t),this.Io(),this.Fo()}isAnimating(){const t=this.getSymbols();for(let e=0;e<t.length;e++)if(t[e]&&this.Co[e]&&this.Eo(e))return!0;return!1}createGeometry(t,e){const{data:n,positionSize:i}=t;return{geometry:{properties:Tt$3({},t.properties),data:n,positionSize:i,features:e},symbolIndex:t.symbolIndex}}getFnTypeConfig(){return ia}createMesh(t,e,{tileTranslationMatrix:s,tileExtent:o},{timestamp:a}){if(!this.ko)return null;const l=this.getMap(),{geometry:h}=t,{positionSize:u,features:c}=h,{aPosition:f,aPickingId:d,aXYRotation:p,aZRotation:m,aAltitude:y}=h.data,g=f.length/u;if(0===g)return null;const v={instance_vectorA:new Float32Array(4*g),instance_vectorB:new Float32Array(4*g),instance_vectorC:new Float32Array(4*g),aPickingId:[]},x=this.Do(v,s,o,h.properties.z,f,y,p,m,u,d,c);h.data.aTerrainAltitude&&(v.aTerrainAltitude=h.data.aTerrainAltitude);const b={};for(const t in v)b[t]={buffer:this.regl.buffer({dimension:v[t].length/g,data:v[t]}),divisor:1};const A=this.Ro(),w=this.Lo(),_=identity$2([]);scale$5(_,_,[w,w,w]);const S=[],M=this.getSymbols();for(let t=0;t<M.length;t++){const e=M[t],o=this.No[t];if(!o)continue;const u=this.Co[t][0],{fixSizeOnZoom:c}=e;let f=identity$2([]);A||(f=this.Ho(f));let d=0;o.forEach((t=>{const{geometry:n,nodeMatrix:i}=t;multiply$5(sa,oa,i),multiply$5(sa,f,sa);const s=multiply$5(sa,_,sa),o=n.boundingBox.copy();o.transform(s);const a=this.zo(o,e);Math.abs(a)>Math.abs(d)&&(d=a)}));const p=[0,0,d],m=o.map(((o,m)=>{const{geometry:y,materialInfo:A,morphWeights:w,extraInfo:S,nodeIndex:M}=o;e.alphaTest&&(A.alphaTest=e.alphaTest);const P=new(this.getMaterialClazz(A))(A),T={},k=new Ge$5(b,g,y,P,{transparent:!1,picking:!0});if(u.hasSkinAnimation()){const e=this.Vo(k,t,0)[M];k.setUniform("jointTexture",e.jointTexture),k.setUniform("jointTextureSize",e.jointTextureSize),k.setUniform("numJoints",e.numJoints),k.setUniform("skinAnimation",+this.Eo(t)),k.properties.startTime=a,T.HAS_SKIN=1}w&&(k.setUniform("morphWeights",w),T.HAS_MORPH=1),k.setUniform("hasAlpha",S.alphaMode&&"BLEND"===S.alphaMode.toUpperCase()),Ct$3(k.uniforms,"polygonFill",e,"markerFill",ra,Rt$3(this.colorCache)),Ct$3(k.uniforms,"polygonOpacity",e,"markerOpacity",1);const O=[];k.setPositionMatrix((()=>{const e=this.Uo(t,m,M);multiply$5(O,oa,e),this.Ho(f),multiply$5(O,f,O),multiply$5(O,_,O);const n=identity$2(sa);if(0!==d&&(fromTranslation$1(n,p),multiply$5(O,n,O)),Ht$2(c)){const t=l.getGLScale()/l.getGLScale(c);return set$4(qo$1,t,t,t),fromScaling(n,qo$1),multiply$5(n,n,O)}return O}));const I=this.layer.getRenderer().getZScale(),F=[],C=[];return k.setLocalTransform((()=>{const t=this.layer.options.altitude||0;return copy$4(C,x),C[2]+=100*t*I,translate$1(F,s,C),F})),y.generateBuffers(this.regl,{excludeElementsInVAO:!0}),v.instance_color&&(T.HAS_INSTANCE_COLOR=1),v.aTerrainAltitude&&(T.HAS_INSTANCE_TERRAIN_ALTITUDE=1,k.setUniform("terrainAltitudeScale",100*this.layer.getRenderer().getZScale())),T.HAS_LAYER_OPACITY=1,Tt$3(k.properties,h.properties),k.setDefines(T),k.properties.symbolIndex={index:t},k}));S.push(...m)}return S.insContext={instanceData:v,tileTranslationMatrix:s,tileExtent:o,aPosition:f,positionSize:u},S}Uo(t,e,n){const r=this.No[t][e];return this.Eo(t)&&this.jo&&this.jo[n]||r.nodeMatrix}Vo(t,e,n){if(!this.Co)return;const i=this.Co[e][0];this.Bo||(this.Bo={}),this.jo={},this.Bo[t.uuid]||(this.Bo[t.uuid]={});const r=this.getSymbols()[e],s=this.Go[e],{loop:o,speed:a,animationName:l}=r;return i.updateAnimation(n,o||!1,a||1,l||s.animations[0].name,t.properties.startTime||0,this.jo,this.Bo[t.uuid]),this.Bo[t.uuid]}zo(t,e){const n=e.anchorZ||"center";let i=0;const r=t.max[2]-t.min[2];return"bottom"===n?i=r/2:"top"===n&&(i=-r/2),i}addMesh(t,e,n){if(!t)return null;if(t[0].properties.level>2)return null;const i=n.timestamp;for(let e=0;e<t.length;e++){if(!t[e]||!t[e].geometry)continue;t[e].instancedData.aTerrainAltitude&&this.ji(t[e],t[e].instancedData,t[e].properties,3,n);const r=t[e].properties.symbolIndex.index,s=this.Eo(r);s&&this.Vo(t[e],r,i),t[e].setUniform("skinAnimation",+s)}return this.scene.addMesh(t),this}mr(t,e){t&&t.updateInstancedData&&t.updateInstancedData("aTerrainAltitude",e)}prepareRender(t){const e=this.getSymbols();let n=!1;for(let t=0;t<e.length;t++)if(e[t]&&this.Co[t]&&this.Eo(t)&&this.Co[t]&&!n){n=!0;break}n&&this.setToRedraw(!0),super.prepareRender(t)}getShadowMeshes(){return this.isVisible()?(this.shadowCount=this.scene.getMeshes().length,this.scene.getMeshes().filter((t=>0===t.properties.level))):ia}Eo(t){const e=this.getSymbols()[t];return!!(e&&e.animation&&this.Co[t]&&this.Co[t][0]&&this.Co[t][0].hasSkinAnimation())}Do(t,e,n,s,o,a,l,h,u,c,f){function d(e,n,i,r){t[e][4*n]=i[r],t[e][4*n+1]=i[r+4],t[e][4*n+2]=i[r+8],t[e][4*n+3]=i[r+12]}const p=o.length/u,m=this.layer.getTileSize().width/n*this.layer.getRenderer().getTileGLScale(s),y=this.layer.getRenderer().getZScale(),g=100*(this.dataConfig.altitudeOffset||0);let v=1/0,x=1/0,b=1/0,w=-1/0,_=-1/0,S=-1/0;const M=[],P=[];for(let t=0;t<p;t++){a?set$4(P,o[t*u],o[t*u+1],a[t]):Fa.unpackPosition(P,o[t*u],o[t*u+1],o[t*u+2]);const e=set$4(M,P[0]*m,-P[1]*m,(P[2]+g)*y);e[0]<v&&(v=e[0]),e[0]>w&&(w=e[0]),e[1]<x&&(x=e[1]),e[1]>_&&(_=e[1]),e[2]<b&&(b=e[2]),e[2]>S&&(S=e[2])}const T=(v+w)/2,k=(x+_)/2,O=(b+S)/2,I=[],F=this.Ro(),C=[0,0,1];for(let e=0;e<p;e++){a?set$4(P,o[e*u],o[e*u+1],a[e]):Fa.unpackPosition(P,o[e*u],o[e*u+1],o[e*u+2]);const n=P[0],s=P[1],p=set$4(M,n*m-T,-s*m-k,(P[2]+g)*y-O),v=l&&l[e]||0,x=h&&h[e]||0;if(v||x){fromRotation$1(I,x,C);const t=set$4(qo$1,n,s,0);rotate$1(I,I,v,normalize$4(t,cross$1(t,t,C)));multiply$5(I,fromTranslation$1(sa,p),I)}else fromTranslation$1(I,p);if(F){multiply$5(I,I,this.Ho(sa,f,c,e))}d("instance_vectorA",e,I,0),d("instance_vectorB",e,I,1),d("instance_vectorC",e,I,2),t.aPickingId[e]=e}return set$4(M,T,k,O),M}Lo(){if(!this.Wo){const t=this.getMap();this.Wo=100*lt$3(t.getGLRes(),t)}return this.Wo}Ho(t,e,n,r){const s=this.getMap(),o=this.symbolDef[0],a=this.Lo();let l=o.translationX||0,h=o.translationY||0,u=o.translationZ||0,c=o.rotationX||0,f=o.rotationY||0,d=o.rotationZ||0,p=o.scaleX||1,m=o.scaleY||1,y=o.scaleZ||1;const v=e&&e[n&&n[r]],x=s.getZoom(),b=v&&v.feature&&v.feature.properties,A=this.Xo(x,b);this.Yo&&(l=this.Yo(x,b)),this.$o&&(h=this.$o(x,b)),this.qo&&(u=this.qo(x,b));const w=set$4(Jo$1,l*a,h*a,u*a);this.Jo&&(c=this.Jo(x,b)),this.Ko&&(f=this.Ko(x,b)),this.Zo&&(d=this.Zo(x,b));const _=set$4(Ko$1,c,f,d);this.Qo&&(p=this.Qo(x,b)),this.ta&&(m=this.ta(x,b)),this.ea&&(y=this.ea(x,b));const S=set$4(Zo$1,p*A,m*A,y*A);return this.na(t,w,_,S)}Xo(t,e){const n=this.symbolDef[0];let i=this.ia?this.ia(t,e):n.modelHeight;if(rt$3(i))return 1;const r=this.ra[0];return i/Math.abs(r.max[1]-r.min[1])}getShaderConfig(){const t=super.getShaderConfig();return t.positionAttribute="POSITION",t.normalAttribute="NORMAL",t}init(t){super.init(t),this.Fo()}Io(){const t=this.symbolDef[0];isFunctionDefinition(t.modelHeight)&&(this.ia=interpolated(t.modelHeight)),isFunctionDefinition(t.translationX)&&(this.Yo=interpolated(t.translationX)),isFunctionDefinition(t.translationY)&&(this.$o=interpolated(t.translationY)),isFunctionDefinition(t.translationZ)&&(this.qo=interpolated(t.translationZ)),isFunctionDefinition(t.rotationX)&&(this.Jo=interpolated(t.rotationX)),isFunctionDefinition(t.rotationY)&&(this.Ko=interpolated(t.rotationY)),isFunctionDefinition(t.rotationZ)&&(this.Zo=interpolated(t.rotationZ)),isFunctionDefinition(t.scaleX)&&(this.Qo=interpolated(t.scaleX)),isFunctionDefinition(t.scaleY)&&(this.ta=interpolated(t.scaleY)),isFunctionDefinition(t.scaleZ)&&(this.ea=interpolated(t.scaleZ))}Ro(){return!!(this.ia&&!this.ia.isFeatureConstant||this.Yo&&!this.Yo.isFeatureConstant||this.$o&&!this.$o.isFeatureConstant||this.qo&&!this.qo.isFeatureConstant||this.Jo&&!this.Jo.isFeatureConstant||this.Ko&&!this.Ko.isFeatureConstant||this.Zo&&!this.Zo.isFeatureConstant||this.Qo&&!this.Qo.isFeatureConstant||this.ta&&!this.ta.isFeatureConstant||this.ea&&!this.ea.isFeatureConstant)}Fo(){if(this.Co)return;this.Co=[],this.Go=[],this.ra=[],this.No=[];const t=this.getSymbols();this.sa=0;for(let e=0;e<t.length;e++){const n=t[e].url||"pyramid";this.Oo.loginGLTF(n);const i=this.Oo.getGLTF(n);if(i.then)i.then((n=>{if(!n.gltfPack)return this.sa++,void(this.sa>=t.length&&(this.ko=!0,this.setToRedraw(!0)));const{gltfPack:i,json:r,bbox:s}=n;this.Co[e]=[i],this.No[e]=i.getMeshesInfo(),this.Go[e]=r,this.ra[e]=s,this.sa++,this.sa>=t.length&&(this.ko=!0),this.setToRedraw(!0)}));else{const{gltfPack:t,json:n,bbox:r}=i;t&&(this.Co[e]=[t],this.No[e]=t.getMeshesInfo(),this.Go[e]=n,this.ra[e]=r,this.sa++)}}this.sa>=t.length&&(this.ko=!0)}getPickingVert(){return"\n    attribute vec3 aPosition;\n    uniform mat4 projViewModelMatrix;\n    uniform mat4 modelMatrix;\n    uniform mat4 positionMatrix;\n    //å¼•å…¥fbo pickingçš„vertç›¸å…³å‡½æ•°\n    #include <fbo_picking_vert>\n    #include <get_output>\n    void main()\n    {\n        mat4 localPositionMatrix = getPositionMatrix();\n        vec4 localPosition = getPosition(aPosition);\n\n        gl_Position = projViewModelMatrix * localPositionMatrix * localPosition;\n        //ä¼ å…¥gl_Positionçš„depthå€¼\n        fbo_picking_setData(gl_Position.w, true);\n    }"}deleteMesh(t){if(t){this.scene.removeMesh(t);for(let e=0;e<t.length;e++){const n=this.Bo&&this.Bo[t[e].uuid];if(n){for(const t in n)n[t].jointTexture&&n[t].jointTexture.destroy();delete this.Bo[t[e].uuid]}t[e].disposeInstanceData(),t[e].dispose()}}}delete(){super.delete();const t=this.getSymbols();for(let e=0;e<t.length;e++){this.Oo.logoutGLTF(t[e].url||"pyramid")}if(this.Bo){for(const t in this.Bo){const e=this.Bo[t];for(const t in e)e[t].jointTexture&&e[t].jointTexture.destroy()}delete this.Bo}delete this.jo}na(t,e,n,s){const o=set$4(qo$1,...e||ta),a=n||ea,l=s||na;return fromRotationTranslationScale(t,fromEuler(Qo$1,a[0],a[1],a[2]),o,l)}};class la extends(aa(Uo$1)){getMaterialClazz(t){return t.diffuseFactor?Le$5:Ie$5}}class ha extends(aa(Wo$1)){getMaterialClazz(t){return t.specularGlossinessTexture||t.diffuseTexture?fi$4.StandardSpecularGlossinessMaterial:fi$4.StandardMaterial}}const{getPBRUniforms:ua}=fi$4.PBRUtils,ca={color:[2.0303,2.028,2.028],direction:[0,-.2717,-1]},fa={index:0},da=[0,0,0],pa=[2,2];class ma extends Bi$1{supportRenderMode(t){return"fxaa"===t||"fxaaBeforeTaa"===t}needPolygonOffset(){return!0}isTerrainSkin(){return!1}isTerrainVector(){return!0}needToRedraw(){return!!super.needToRedraw()||this.getSymbol(fa).animation}createMesh(t,e){const{geometry:i}=t;i.generateBuffers(this.regl);const r=new Be$5(i,null,{castShadow:!1,picking:!0});return r.properties.symbolIndex=fa,r.setLocalTransform(e),r}callShader(t,e){super.callShader(t,e),this.transformWater();const n=this.oa(this.getMap(),e);this.Gi+=this.renderer.render(this.aa,n,this.la,this.getRenderFBO(e))}addMesh(t,e){this._r(t,e),super.addMesh(...arguments)}_r(t){const e=this.getSymbol(fa).ssr;for(let n=0;n<t.length;n++)t[n].ssr=e?1:0}paint(t){t.states&&t.states.includesChanged&&(this.shader.dispose(),this.aa.dispose(),this.br(t));const e=!!t.ssr&&this.getSymbol(fa).ssr,n=this.aa,i=n.shaderDefines;if(e){const e=Tt$3({},i,t.ssr.defines);n.shaderDefines=e}this.updateIBLDefines(n),this.ha.ssr=e?1:0,super.paint(t),e&&(n.shaderDefines=i)}init(t){this.createIBLTextures();this.renderer=new B$6(this.regl),this.createGround(),this.br(t),this.pickingFBO&&(this.picking=[new Cr$4(this.renderer,{vert:Gi$1,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],extraCommandProps:{viewport:this.pickingViewport}},this.pickingFBO,this.getMap())]),this.ua()}ua(){const t=this.regl;this.ca||(this.ca=t.texture(2));const e=this.getSymbol({index:0}),n=e.texWaveNormal,i=this.getCachedTexture(n),r=this;if(i)this.fa||(i.isLoading?setTimeout((()=>{this.shader&&this.ua()}),20):this.fa=this.da(t,i));else{const e=new Image;e.isLoading=!0,e.onload=function(){delete this.isLoading,r.fa=r.da(t,this),r.setToRedraw()},e.onerror=()=>{console.error("invalid water wave normal texture:"+n)},this.addCachedTexture(n,e),e.src=n}const s=e.texWavePerturbation,o=this.getCachedTexture(s);if(o)this.pa||(o.isLoading?setTimeout((()=>{this.ua()}),20):this.pa=this.da(t,o));else{const e=new Image;e.isLoading=!0,e.onload=function(){delete this.isLoading,r.pa=r.da(t,this),r.setToRedraw()},e.onerror=()=>{console.error("invalid water wave perturbation texture:"+s)},this.addCachedTexture(s,e),e.src=s}}da(t,e){return this.ca?t.texture({width:e.width,height:e.height,mag:"linear",min:"linear mipmap linear",wrapS:"repeat",wrapT:"repeat",flipY:!0,data:e}):null}br(t){const e=this.canvas,i=[],s=[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}},{name:"modelViewNormalMatrix",type:"function",fn:(t,e)=>{const n=multiply$5([],e.viewMatrix,e.modelMatrix),i=invert$2(n,n);return fromMat4$1([],transpose(i,i))}},{name:"modelViewMatrix",type:"function",fn:(t,e)=>multiply$5([],e.viewMatrix,e.modelMatrix)},{name:"uEnvironmentTransform",type:"function",fn:(t,e)=>fromRotation$2(i,Math.PI*(e.environmentOrientation||0)/180)}],o={TIME_NOISE_TEXTURE_REPEAT:.3737};this.fillIncludes(o,s,t);const a={x:0,y:0,width:()=>e?e.width:1,height:()=>e?e.height:1};this.shader=new vn$4({vert:"\n                attribute vec3 aPosition;\n\n                uniform mat4 projViewModelMatrix;\n\n                void main() {\n                    gl_Position = projViewModelMatrix * vec4(aPosition, 1.);\n                }\n            ",frag:"\n    #define SHADER_NAME WATER_STENCIL\n    precision mediump float;\n    void main() {\n        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n    }\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){const n=[];return multiply$5(n,e.projViewMatrix,e.modelMatrix),n}}],extraCommandProps:{viewport:a,colorMask:[!1,!1,!1,!1],stencil:{enable:!0,mask:255,func:{cmp:"<=",ref:254,mask:255},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:this.sceneConfig.depthRange||[0,1],func:this.sceneConfig.depthFunc||"<="},polygonOffset:{enable:!0,offset:this.getPolygonOffset()}}});const h={viewport:a,stencil:{enable:!0,mask:255,func:{cmp:"==",ref:254,mask:255},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!1}};s.push(...jn$4.getUniformDeclares()),this.aa=new vn$4({vert:"#define SHADER_NAME WATER\nuniform mat4 modelMatrix;\nuniform mat4 projViewModelMatrix;\nattribute vec3 aPosition;\nattribute vec2 aTexCoord;\nuniform vec2 uvOffset;\nuniform vec2 noiseUvOffset;\nuniform vec2 uvScale;\nvarying vec2 vUv;\nvarying vec2 vNoiseUv;\nvarying vec3 vPos;\nvarying mat3 vTbnMatrix;\n#ifdef HAS_SSR\nuniform mat4 modelViewMatrix;\nvarying vec4 vViewVertex;\n#endif\n#include <highlight_vert>\nmat3 c(in vec3 d) {\n  vec3 t = normalize(cross(d, vec3(.0, 1., .0)));\n  vec3 e = normalize(cross(d, t));\n  return mat3(t, e, d);\n}\n#if defined(HAS_SHADOWING)\n#include <vsm_shadow_vert>\n#endif\nconst vec3 f = vec3(0., 0., 1.);\nvoid main(void) {\n  vec4 h = vec4(aPosition, 1.);\n  vec4 i = modelMatrix * h;\n  vPos = i.xyz;\n  vTbnMatrix = c(f);\n  gl_Position = projViewModelMatrix * h;\n  vUv = aTexCoord * uvScale + uvOffset;\n  vNoiseUv = aTexCoord * uvScale * TIME_NOISE_TEXTURE_REPEAT + noiseUvOffset;\n#ifdef HAS_SSR\nvec4 j = modelViewMatrix * h;\n  vViewVertex = j;\n#endif\n#if defined(HAS_SHADOWING)\nshadow_computeShadowPars(h);\n#endif\nhighlight_setVarying();\n}",frag:"#define SHADER_NAME WATER\nprecision highp float;\nprecision highp sampler2D;\n#include <hsv_frag>\nuniform vec3 hsv;\nuniform float contrast;\nuniform float layerOpacity;\n#if defined(HAS_SHADOWING)\n#include <vsm_shadow_frag>\n#endif\n#include <highlight_frag>\n#if defined(HAS_IBL_LIGHTING)\nuniform vec3 hdrHSV;\nuniform samplerCube prefilterMap;\nuniform sampler2D brdfLUT;\nuniform float rgbmRange;\nuniform mat3 uEnvironmentTransform;\nuniform vec3 diffuseSPH[9];\nvec3 c(const in vec3 d) {\n  vec3 e = uEnvironmentTransform * d;\n  float x = e.x;\n  float y = e.y;\n  float z = e.z;\n  vec3 f = (diffuseSPH[0] + diffuseSPH[1] * x + diffuseSPH[2] * y + diffuseSPH[3] * z + diffuseSPH[4] * z * x + diffuseSPH[5] * y * z + diffuseSPH[6] * y * x + diffuseSPH[7] * (3. * z * z - 1.) + diffuseSPH[8] * (x * x - y * y));\n  if(length(hdrHSV) > .0) {\n    f = hsv_apply(f, hdrHSV);\n  }\n  return max(f, vec3(.0));\n}\nvec3 h(const in vec3 i, const in float j, const in float k, const in float l) {\n  vec4 rgba = texture2D(brdfLUT, vec2(k, j));\n  float b = (rgba[3] * 65280.0 + rgba[2] * 255.);\n  float a = (rgba[1] * 65280.0 + rgba[0] * 255.);\n  const float m = 1. / 65535.;\n  return (i * a + b * l) * m;\n}\n#else\nuniform vec3 ambientColor;\n#endif\nstruct PBRShadingWater {\n  float NdotL;\n  float NdotV;\n  float NdotH;\n  float VdotH;\n  float LdotH;\n  float VdotN;\n};\nvec3 o(const in vec4 u, const in float v) {\n  if(v <= .0)\n    return u.rgb;\n  return v * u.rgb * u.a;\n}\n#ifdef HAS_SSR\nvarying vec4 vViewVertex;\nuniform mat3 modelViewNormalMatrix;\nuniform sampler2D TextureDepth;\nuniform highp vec2 outSize;\nuniform float ssrFactor;\nuniform float ssrQuality;\nuniform sampler2D TextureReflected;\nuniform highp mat4 projMatrix;\nuniform mat4 invProjMatrix;\nuniform vec4 outputFovInfo[2];\nuniform mat4 reprojViewProjMatrix;\nuniform vec2 cameraNearFar;\nfloat A(const in vec4 B) {\n  return B.r + B.g / 255.;\n}\nfloat C(const in vec2 D, const in float E) {\n  vec3 F = vec3(.06711056, .00583715, 52.9829189);\n  return fract(F.z * fract(dot(D.xy + E * vec2(47., 17.) * .695, F.xy))) * .5;\n}\nvec3 G(const in float H, const in float I, const in vec2 J) {\n  float K = min(I - .01, H);\n  float L = floor(K);\n  float M = min(I, L + 1.);\n  float N = pow(2., M);\n  vec2 O = 2. * N / J;\n  if(K - L > .5)\n    N *= 2.;\n  return vec3(O, N);\n}\nvec2 P(const in vec2 Q, const in vec3 R) {\n  vec2 S = max(R.xy, min(1. - R.xy, Q));\n  return vec2(2. * S.x, R.z - 1. - S.y) / R.z;\n}\nvec3 T(const in mat4 U, const in vec3 V) {\n  vec4 W = U * vec4(V, 1.);\n  return vec3(.5 + .5 * W.xy / W.w, W.w);\n}\nvec3 X(const in float Y, const in vec2 S) {\n  return texture2D(TextureReflected, S).rgb;\n}\nfloat Z(float ba) {\n  highp mat4 U = projMatrix;\n  highp float z = ba * 2. - 1.;\n  return -U[3].z / (z + U[2].z);\n}\nfloat bb(const vec2 S) {\n  float ba = A(texture2D(TextureDepth, S));\n  return ba;\n}\nvec3 bc(const in float E, const in vec3 bd, const in vec3 be, const in vec3 bf, const in vec3 bg, const in float bh) {\n  vec2 bi;\n  bi.x = C(gl_FragCoord.yx, E);\n  bi.y = fract(bi.x * 52.9829189);\n  bi.y = mix(bi.y, 1., .7);\n  float bj = 2. * 3.14159 * bi.x;\n  float bk = pow(max(bi.y, .000001), bh / (2. - bh));\n  float bl = sqrt(1. - bk * bk);\n  vec3 bm = vec3(bl * cos(bj), bl * sin(bj), bk);\n  bm = bm.x * bd + bm.y * be + bm.z * bf;\n  return normalize((2. * dot(bg, bm)) * bm - bg);\n}\nfloat bn(const in float E) {\n  return (C(gl_FragCoord.xy, E) - .5);\n}\nvec3 bo(const in vec3 bp, const in float bq, const in vec3 br) {\n  vec3 bs = T(projMatrix, vViewVertex.xyz + br * bq);\n  bs.z = 1. / bs.z;\n  bs -= bp;\n  float bt = min(1., .99 * (1. - bp.x) / max(1e-5, bs.x));\n  float bu = min(1., .99 * (1. - bp.y) / max(1e-5, bs.y));\n  float bv = min(1., .99 * bp.x / max(1e-5, -bs.x));\n  float bw = min(1., .99 * bp.y / max(1e-5, -bs.y));\n  return bs * min(bt, bu) * min(bv, bw);\n}\nfloat bx(const in vec3 bp, const in vec3 bs, inout float by, inout float bz) {\n  float bA = (bz + by) * .5;\n  vec3 bB = bp + bs * bA;\n  float z = bb(bB.xy);\n  float ba = Z(z);\n  float bC = -1. / bB.z;\n  by = ba > bC ? by : bA;\n  bz = ba > bC ? bA : bz;\n  return bA;\n}\nvec4 bD(const in vec3 bp, const in float bq, in float bE, const in vec3 br, const in float j, const in float E) {\n  const int bF = 20;\n  float bG = 1. / float(bF);\n  bE *= bG;\n  vec3 bs = bo(bp, bq, br);\n  float bH = bG;\n  vec3 bI = vec3(.0, bH, 1.);\n  vec3 bB;\n  float z, ba, bC, bJ, bK, bL;\n  bool bM;\n  float bN = 1.;\n  float bA;\n  for(int bO = 0; bO < bF; bO++) {\n    bB = bp + bs * bI.y;\n    z = bb(bB.xy);\n    ba = Z(z);\n    bC = -1. / bB.z;\n    bJ = bC - ba;\n    bJ *= clamp(sign(abs(bJ) - bq * bG * bG), .0, 1.);\n    bM = abs(bJ + bE) < bE;\n    bK = clamp(bI.x / (bI.x - bJ), .0, 1.);\n    bL = bM ? bI.y + bK * bG - bG : 1.;\n    bI.z = min(bI.z, bL);\n    bI.x = bJ;\n    if(bM) {\n      float by = bI.y - bG;\n      float bz = bI.y;\n      bA = bx(bp, bs, by, bz);\n      bA = bx(bp, bs, by, bz);\n      bA = bx(bp, bs, by, bz);\n      bN = bA;\n      break;\n    }\n    bI.y += bG;\n  }\n  return vec4(bp + bs * bN, 1. - bN);\n}\nvec3 bP(in vec4 bQ, const in float bR, const in vec3 bS, const in vec3 bT, const in float j) {\n  vec4 bU = mix(outputFovInfo[0], outputFovInfo[1], bQ.x);\n  bQ.xyz = vec3(mix(bU.xy, bU.zw, bQ.y), 1.) * -1. / bQ.z;\n  bQ.xyz = (reprojViewProjMatrix * vec4(bQ.xyz, 1.)).xyw;\n  bQ.xy /= bQ.z;\n  float bV = clamp(6. - 6. * max(abs(bQ.x), abs(bQ.y)), .0, 1.);\n  bQ.xy = .5 + .5 * bQ.xy;\n  return vec3(bQ.xy, 1.);\n}\nvec3 ssr(const in vec3 bS, const in vec3 bT, const in float j, const in vec3 d, const in vec3 bg) {\n  float bW = .0;\n  vec4 f = vec4(.0);\n  float bh = j * j;\n  bh = bh * bh;\n  vec3 bX = abs(d.z) < .999 ? vec3(.0, .0, 1.) : vec3(1., .0, .0);\n  vec3 bd = normalize(cross(bX, d));\n  vec3 be = cross(d, bd);\n  float bR = ssrFactor * clamp(-4. * dot(bg, d) + 3.8, .0, 1.);\n  bR *= clamp(4.7 - j * 5., .0, 1.);\n  vec3 bp = T(projMatrix, vViewVertex.xyz);\n  bp.z = 1. / bp.z;\n  vec3 br = bc(bW, bd, be, d, bg, bh);\n  float bq = mix(cameraNearFar.y + vViewVertex.z, -vViewVertex.z - cameraNearFar.x, br.z * .5 + .5);\n  float bE = .5 * bq;\n  vec4 bQ;\n  if(dot(br, d) > .001 && bR > .0) {\n    bQ = bD(bp, bq, bE, br, j, bW);\n    if(bQ.w > .0)\n      return bP(bQ, bR, bS, bT, j);\n    \n  }\n  return vec3(.0);\n}\n#endif\nconst vec3 bY = vec3(0., 0., 1.);\nuniform mat4 viewMatrix;\nuniform sampler2D normalTexture;\nuniform sampler2D heightTexture;\nuniform vec4 waveParams;\nuniform vec2 waterDir;\nuniform vec4 waterBaseColor;\nuniform vec3 lightDirection;\nuniform vec3 lightColor;\nuniform vec3 camPos;\nuniform float timeElapsed;\nvarying vec2 vUv;\nvarying vec2 vNoiseUv;\nvarying vec3 vPos;\nvarying mat3 vTbnMatrix;\nfloat bZ(vec3 e, float ca) {\n  float cb = max(.015, ca);\n  return max((e.x + e.y) * .3303545 / cb + .3303545, .0);\n}\nconst vec2 cc = vec2(6. / 25., 5. / 24.);\nvec2 cd(sampler2D ce, vec2 S) {\n  return 2. * texture2D(ce, S).rg - 1.;\n}\nfloat cf(vec2 S) {\n  return texture2D(heightTexture, S).b;\n}\nvec3 cg(sampler2D ce, vec2 S) {\n  return 2. * texture2D(ce, S).rgb - 1.;\n}\nfloat ch(vec2 S, float ci) {\n  return fract(ci);\n}\nfloat cj(vec2 S, float ci) {\n  float ck = ch(S, ci);\n  return 1. - abs(1. - 2. * ck);\n}\nvec3 cl(sampler2D cm, vec2 S, float ci, float cn) {\n  float co = waveParams[2];\n  float cp = waveParams[3];\n  vec2 cq = cd(cm, S) * co;\n  float ck = ch(S, ci + cn);\n  float cr = cj(S, ci + cn);\n  vec2 f = S;\n  f -= cq * (ck + cp);\n  f += cn;\n  f += (ci - ck) * cc;\n  return vec3(f, cr);\n}\nconst float cs = 7.77;\nvec3 ct(sampler2D cu, sampler2D cv, vec2 cw, vec2 cx, float ci) {\n  float ca = waveParams[0];\n  vec2 cy = ci * -cx;\n  float cz = cf(vNoiseUv) * cs;\n  vec3 cA = cl(cv, cw + cy, ci + cz, .0);\n  vec3 cB = cl(cv, cw + cy, ci + cz, .5);\n  vec3 cC = cg(cu, cA.xy) * cA.z;\n  vec3 cD = cg(cu, cB.xy) * cB.z;\n  vec3 cE = normalize(cC + cD);\n  cE.xy *= ca;\n  cE.z = sqrt(1. - dot(cE.xy, cE.xy));\n  return cE;\n}\nvec4 cF(vec2 cw, float cG) {\n  float cH = waveParams[1];\n  vec3 d = ct(normalTexture, heightTexture, cw * cH, waterDir, cG);\n  float cI = bZ(d, waveParams[0]);\n  return vec4(d, cI);\n}\nconst float cJ = 3.141592653589793;\nconst float cK = 1. / cJ;\nconst float cL = .3183098861837907;\nconst float cM = 1.570796326794897;\nconst float cN = .4;\nfloat cO = 2.2;\nvec3 cP(float cQ, vec3 cR, float l) {\n  return cR + (l - cR) * pow(1. - cQ, 5.);\n}\nfloat cS(float cT, float j) {\n  float cU = j * j;\n  float cV = cT * cT;\n  float cW = pow((cV * (cU - 1.) + 1.), cO) * cJ;\n  return cU / cW;\n}\nfloat cX(float cY) {\n  return .25 / (cY * cY);\n}\nvec3 cZ(const vec3 x) {\n  return (x * (2.51 * x + .03)) / (x * (2.43 * x + .59) + .14);\n}\nconst float da = 2.2;\nconst float db = .4545454545;\nvec4 dc(vec4 u) {\n  return vec4(pow(u.rgb, vec3(db)), u.w);\n}\nvec3 dd(vec3 u) {\n  return pow(u, vec3(da));\n}\nconst vec3 de = vec3(.02, 1., 5.);\nconst vec2 df = vec2(.02, .1);\nconst float j = .06;\nconst float dg = 1.7;\nconst vec3 dh = vec3(0, .6, .9);\nconst vec3 di = vec3(.72, .92, 1.);\nconst float dj = .65;\nconst float dk = 300000.0;\nconst float dl = 500000.0;\nconst float dm = .775;\nconst float dn = .8;\nPBRShadingWater dp;\nvec3 dq(in PBRShadingWater dr, float j, vec3 ds, float dt) {\n  vec3 du = cP(dr.VdotH, ds, dt);\n  float dv = cS(dr.NdotH, j);\n  float dw = cX(dr.LdotH);\n  float dx = mix(j + .045, j + .385, 1. - dr.VdotH);\n  float dy = 1.2;\n  float dz = cS(dr.NdotH, dx) * dy;\n  return ((dv + dz) * dw) * du;\n}\nvec3 dA(float dg, float dB, vec3 dh, float dC) {\n  return dg * (.075 * dh * pow(dB, 4.) + 50. * pow(dB, 23.)) * dC;\n}\nvec3 dD(in float bk, in vec3 dE, in vec3 dF) {\n  float dG = pow((1. - bk), de[2]);\n  return mix(dF, dE, dG);\n}\nvec3 dH(in vec3 e, in vec3 dI, in float dJ, in float j) {\n  \n#ifdef HAS_IBL_LIGHTING\nvec3 dK = reflect(-dI, e);\n  vec4 dL = textureCube(prefilterMap, uEnvironmentTransform * dK);\n  float dM = clamp(1. + dot(dK, e), .0, 1.);\n  dL *= dM * dM;\n  vec3 i = o(dL, rgbmRange);\n  vec3 dN = c(e);\n  float l = clamp(50.0 * waterBaseColor.g, .0, 1.);\n  vec3 dO = h(waterBaseColor.rgb, j, dot(e, dI), l);\n  return i * dO + dN;\n#else\nvec3 dP = dd(di);\n  vec3 dQ = dd(dh);\n  vec3 di = dD(dJ, dP, dQ);\n  return di;\n#endif\n}\nvec3 dR(in vec3 e, in vec3 dI, in vec3 dS, vec3 u, in vec3 dT, in vec3 dU, in float dV, float dW, vec3 dX) {\n  float dY = 0.;\n  vec3 dZ = dd(u);\n  vec3 bm = normalize(dS + dI);\n  dp.NdotL = clamp(dot(e, dS), .0, 1.);\n  dp.NdotV = clamp(dot(e, dI), .001, 1.);\n  dp.VdotN = clamp(dot(dI, e), .001, 1.);\n  dp.NdotH = clamp(dot(e, bm), .0, 1.);\n  dp.VdotH = clamp(dot(dI, bm), .0, 1.);\n  dp.LdotH = clamp(dot(dS, bm), .0, 1.);\n  float dJ = max(dot(dU, dI), .0);\n  vec3 di = dH(e, dI, dJ, j);\n  float ea = max(dot(dU, dS), .0);\n  float eb = .1 + ea * .9;\n  di *= eb;\n  float ec = clamp(dV, .8, 1.);\n  vec3 ed = cP(dp.VdotN, vec3(de[0]), de[1]);\n  vec3 ee = ed * di * ec;\n  vec3 ef = dZ * mix(di, ea * dT * cK, 2. / 3.) * ec;\n  vec3 i = vec3(.0);\n  if(dJ > .0 && ea > .0) {\n    vec3 eg = dq(dp, j, vec3(df[0]), df[1]);\n    vec3 eh = dT * cK * dV;\n    i = dp.NdotL * eh * eg;\n  }\n  vec3 cI = vec3(.0);\n  if(dJ > .0) {\n    cI = dA(dg, dW, dh, eb);\n  }\n  vec3 ei = vec3(.0);\n#ifdef HAS_SSR\nfloat ej = smoothstep(dl, dk, -dX.z);\n  mat4 ek = viewMatrix;\n  vec4 el = vec4(dX.xyz, 1.);\n  vec3 em = normalize(el.xyz);\n  vec4 en = ek * vec4(e, .0);\n  vec3 eo = normalize(en.xyz);\n  vec4 ep = ek * vec4(dU, .0);\n  float eq = pow(max(dot(-em, ep.xyz), .0), cN);\n  vec3 er = mix(ep.xyz, eo, eq);\n  vec3 es = ssr(vec3(.0), vec3(1.), j, normalize(er), -normalize(vViewVertex.xyz));\n  if(es.z > .0) {\n    vec2 et = smoothstep(.3, .6, abs(vec2(.5) - es.xy));\n    dY = dm * clamp(1. - 1.3 * et.y, .0, 1.) * ej;\n    vec3 eu = X(.0, es.xy);\n    ei = dd(eu) * dY * ed.y * dj;\n  }\n#endif\nfloat ev = mix(dn, dn * .5, dY);\n  return cZ((1. - dY) * ee + ei + ef * ev + i + cI);\n}\nvoid main() {\n  vec3 dU = bY;\n  vec4 ew = cF(vUv, timeElapsed);\n  vec3 e = normalize(vTbnMatrix * ew.xyz);\n  vec3 dI = -normalize(vPos - camPos);\n  vec3 dS = normalize(-lightDirection);\n#if defined(HAS_SHADOWING)\nfloat dV = shadow_computeShadow();\n#else\nfloat dV = 1.;\n#endif\nvec4 ex = viewMatrix * vec4(vPos, 1.);\n  vec4 ey = vec4(dR(e, dI, dS, waterBaseColor.rgb, lightColor, dU, dV, ew.w, ex.xyz), waterBaseColor.a);\n  gl_FragColor = dc(ey);\n  if(contrast != 1.) {\n    gl_FragColor = contrastMatrix(contrast) * gl_FragColor;\n  }\n  if(length(hsv) > .0) {\n    gl_FragColor = hsv_apply(gl_FragColor, hsv);\n  }\n  gl_FragColor = highlight_blendColor(gl_FragColor) * layerOpacity;\n}",defines:o,uniforms:s,extraCommandProps:h})}needClearStencil(){return!0}getUniformValues(t){return{projViewMatrix:t.projViewMatrix}}oa(t,e){const{iblTexes:n,dfgLUT:i}=this.getIBLRes(),r=ua(t,n,i,e&&e.ssr,e&&e.jitter),s=t.getLightManager();let o=s&&s.getDirectionalLight()||{};const l=s&&s.getAmbientLight()||{},h=this.getSymbol(fa),u=this.ma=this.ma||[],c=this.ya=this.ya||[];set$3(c,.09,h.uvScale||3,.03,-.5),Tt$3(r,{ambientColor:l.color||[.2,.2,.2],viewMatrix:t.viewMatrix,lightDirection:o.direction||ca.direction,lightColor:o.color||ca.color,camPos:t.cameraPosition,timeElapsed:h.animation?(this.layer.getRenderer().getFrameTimestamp()||0)/(1/(h.waterSpeed||1)*1e4):0,normalTexture:this.fa||this.ca,heightTexture:this.pa||this.ca,waveParams:c,waterDir:ya(u,h.waterDirection||0),waterBaseColor:h.waterBaseColor||[.1451,.2588,.4863,1],contrast:h.contrast||1,hsv:h.hsv||da});const f=this.layer.getRenderer();return r.layerOpacity=f.ne(),this.setIncludeUniformValues(r,e),e&&e.ssr&&e.ssr.renderUniforms&&Tt$3(r,e.ssr.renderUniforms),r}delete(){super.delete(),this.ca&&(this.ca.destroy(),delete this.ca),this.fa&&this.fa.destroy(),this.pa&&this.pa.destroy(),this.shader&&(this.shader.dispose(),delete this.shader),this.aa&&this.aa.dispose(),this.ha&&(this.ha.geometry.dispose(),this.ha.material&&this.ha.material.dispose(),this.ha.dispose(),delete this.ha),this.disposeIBLTextures()}createGround(){const t=new tn$5;t.data.aTexCoord=new Uint8Array([0,1,1,1,0,0,1,0]),t.generateBuffers(this.renderer.regl),this.ha=new Be$5(t,null,{castShadow:!1}),this.la=new Ke$5([this.ha])}transformWater(){const t=this.getMap(),e=jt$4.getGroundTransform(this.ha.localTransform,t);this.ha.setLocalTransform(e);const n=t._get2DExtentAtRes(t.getGLRes()),i=n.getWidth(),r=n.getHeight(),o=t.cameraLookAt,h=(o[0]-i)/pa[0],u=(o[1]+r)/pa[1],d=.3737*h%1,p=.3737*u%1,m=i/pa[0]*2,y=r/pa[1]*2;this.ha.setUniform("uvOffset",[h%1,u%1]),this.ha.setUniform("noiseUvOffset",[d,p]),this.ha.setUniform("uvScale",[m,-y])}}function ya(t,e){return e=Math.PI*e/180,t[0]=Math.sin(e),t[1]=Math.cos(e),t}const ga=ei$1("fill",nr$2);ga.registerAt(he$2);const va=ei$1("line",or$2);va.registerAt(he$2);const xa=ei$1("line-gradient",ar$2);xa.registerAt(he$2);const ba=ei$1("icon",Es$1);ba.registerAt(he$2);const Aa=ei$1("text",xo$1);Aa.registerAt(he$2);const wa=ei$1("native-line",To$1);wa.registerAt(he$2),ei$1("native-point",So$1).registerAt(he$2);const _a=ei$1("phong",Uo$1);_a.registerAt(he$2);const Sa=ei$1("wireframe",Bo$1);Sa.registerAt(he$2);const Ma=ei$1("lit",Wo$1);Ma.registerAt(he$2);const Pa=ei$1("tube",$o$1);Pa.registerAt(he$2);const Ta=ei$1("gltf-phong",la);Ta.registerAt(he$2);const ka=ei$1("gltf-lit",ha);ka.registerAt(he$2);const Oa=ei$1("heatmap",class extends Bi$1{createFnTypeConfig(t,e){const n=interpolated(e.heatmapWeight),i=new Int16Array(1);return[{attrName:"aWeight",symbolName:"heatmapWeight",type:Int16Array,width:1,define:"HAS_HEAT_WEIGHT",evaluate:e=>{const r=n(t.getZoom(),e);return i[0]=255*r,i[0]}}]}createMesh(t,e){const{geometry:i,symbolIndex:r,ref:s}=t;void 0===s&&si$1(i,this.getSymbolDef(r),this.getFnTypeConfig(r));const o=this.getSymbol(r),a={tileRatio:i.properties.tileRatio,dataResolution:i.properties.tileResolution};Ct$3(a,"heatmapIntensity",o,"heatmapIntensity",1),Ct$3(a,"heatmapRadius",o,"heatmapRadius",6),Ct$3(a,"heatmapWeight",o,"heatmapWeight",1),Ct$3(a,"heatmapOpacity",o,"heatmapOpacity",1),i.generateBuffers(this.regl);const l=new Ce$5(a),h=new Be$5(i,l,{transparent:!0,castShadow:!1,picking:!0}),u={};return i.data.aWeight&&(u.HAS_HEAT_WEIGHT=1),h.setDefines(u),h.setLocalTransform(e),h.properties.symbolIndex=r,h}callRenderer(t,e,n){const i=this.getRenderFBO(n);this.Gi+=this.ga.render(this.scene,e,i)}getUniformValues(t){const e=this.getSymbol({index:0}),{projViewMatrix:n}=t;return{glScale:1/t.getGLScale(),resolution:t.getResolution(),projViewMatrix:n,heatmapOpacity:e.heatmapOpacity}}getHeatmapMeshes(){return this.scene.getMeshes()}delete(){super.delete(...arguments),this.ga.dispose(),delete this.ga}init(){this.renderer=new B$6(this.regl);const e=this.getPolygonOffset(),i=this.getSymbols()[0];this.ga=new $s$2(this.regl,this.sceneConfig,this.layer,i.heatmapColor,null,e)}});Oa.registerAt(he$2);const Ia=ei$1("water",ma);if(Ia.registerAt(he$2),we$2.registerPainter("lit",Wo$1),we$2.registerPainter("icon",Es$1),we$2.registerPainter("fill",nr$2),we$2.registerPainter("line",or$2),we$2.registerPainter("line-gradient",ar$2),we$2.registerPainter("water",ma),we$2.registerPainter("tube",$o$1),on$5.register("vt_position_vert","#ifdef HAS_TERRAIN_ALTITUDE\n    attribute float aTerrainAltitude;\n#endif\nuniform float minAltitude;\n#ifdef HAS_ALTITUDE\n    vec3 unpackVTPosition() {\n        float altitude = aAltitude;\n        #ifdef HAS_TERRAIN_ALTITUDE\n            altitude += aTerrainAltitude * 100.0;\n        #endif\n        altitude += minAltitude * 100.0;\n        return vec3(aPosition, altitude);\n    }\n#else\n    float position_modValue = 16384.0;\n    float position_delta = 0.00001;\n    vec3 unpackVTPosition() {\n        float z = aPosition.z;\n        vec2 pos = sign(aPosition.xy + position_delta) * mod(abs(aPosition.xy), position_modValue);\n        vec2 highs = floor(abs(aPosition.xy) / position_modValue);\n        float altitude = sign(z + position_delta) * (highs.x * 2.0 + highs.y) * pow(2.0, 15.0) + z;\n        #ifdef HAS_TERRAIN_ALTITUDE\n            altitude += aTerrainAltitude * 100.0;\n        #endif\n        altitude += minAltitude * 100.0;\n        return vec3(pos, altitude);\n    }\n#endif"),he$2.VERSION="0.92.3",we$2.VERSION="0.92.3",create$5(),transcoders){const n=t__namespace.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=transcoders.inject(q$4);t__namespace.registerWorkerAdapter("@maptalks/vt",n)}else t__namespace.registerWorkerAdapter("@maptalks/vt",(function(){return transcoders.inject(q$4)}))}else t__namespace.registerWorkerAdapter("@maptalks/vt",q$4);for(
/*!
	* Contains code from THREE.js
	* MIT License
	* https://github.com/mrdoob/three.js
	*/
var planes$1=[],i$1=0;i$1<6;i$1++)planes$1[i$1]=[];var p$4=[];function intersectsBox$1(matrix,box,mask){setPlanes$1(matrix);for(var i=0;i<6;i++)if(!mask||"0"!==mask.charAt(i)){var plane=planes$1[i];if(p$4[0]=plane[0]>0?box[1][0]:box[0][0],p$4[1]=plane[1]>0?box[1][1]:box[0][1],p$4[2]=plane[2]>0?box[1][2]:box[0][2],distanceToPoint$1(plane,p$4)<0)return!1}return!0}function intersectsPlane(plane,box){var center=box,halfAxes=box,normalX=plane[0],normalY=plane[1],normalZ=plane[2],radEffective=Math.abs(normalX*halfAxes[3]+normalY*halfAxes[6]+normalZ*halfAxes[9])+Math.abs(normalX*halfAxes[4]+normalY*halfAxes[7]+normalZ*halfAxes[10])+Math.abs(normalX*halfAxes[5]+normalY*halfAxes[8]+normalZ*halfAxes[11]),distanceToPlane=distanceToPoint$1(plane,center);return!(distanceToPlane<=-radEffective)}function setPlanes$1(m){var me0=m[0],me1=m[1],me2=m[2],me3=m[3],me4=m[4],me5=m[5],me6=m[6],me7=m[7],me8=m[8],me9=m[9],me10=m[10],me11=m[11],me12=m[12],me13=m[13],me14=m[14],me15=m[15];setComponents$1(planes$1[0],me3-me0,me7-me4,me11-me8,me15-me12),setComponents$1(planes$1[1],me3+me0,me7+me4,me11+me8,me15+me12),setComponents$1(planes$1[2],me3+me1,me7+me5,me11+me9,me15+me13),setComponents$1(planes$1[3],me3-me1,me7-me5,me11-me9,me15-me13),setComponents$1(planes$1[4],me3-me2,me7-me6,me11-me10,me15-me14),setComponents$1(planes$1[5],me3+me2,me7+me6,me11+me10,me15+me14)}function setComponents$1(out,x,y,z,w){var inverseNormalLength=1/Math.sqrt(x*x+y*y+z*z);return out[0]=x*inverseNormalLength,out[1]=y*inverseNormalLength,out[2]=z*inverseNormalLength,out[3]=w*inverseNormalLength,out}function distanceToPoint$1(plane,p){return plane[0]*p[0]+plane[1]*p[1]+plane[2]*p[2]+plane[3]}
/*!
	 * @maptalks/3dtiles v0.95.7
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */const T$3='function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}function r(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],f=e[7],h=e[8],l=e[9],d=e[10],y=e[11],m=e[12],b=e[13],p=e[14],w=e[15],g=n[0],v=n[1],M=n[2],T=n[3];return t[0]=g*r+v*a+M*h+T*m,t[1]=g*s+v*c+M*l+T*b,t[2]=g*i+v*u+M*d+T*p,t[3]=g*o+v*f+M*y+T*w,g=n[4],v=n[5],M=n[6],T=n[7],t[4]=g*r+v*a+M*h+T*m,t[5]=g*s+v*c+M*l+T*b,t[6]=g*i+v*u+M*d+T*p,t[7]=g*o+v*f+M*y+T*w,g=n[8],v=n[9],M=n[10],T=n[11],t[8]=g*r+v*a+M*h+T*m,t[9]=g*s+v*c+M*l+T*b,t[10]=g*i+v*u+M*d+T*p,t[11]=g*o+v*f+M*y+T*w,g=n[12],v=n[13],M=n[14],T=n[15],t[12]=g*r+v*a+M*h+T*m,t[13]=g*s+v*c+M*l+T*b,t[14]=g*i+v*u+M*d+T*p,t[15]=g*o+v*f+M*y+T*w,t}function i(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}function o(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function a(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,u=n*o,f=r*o,h=r*a,l=s*o,d=s*a,y=s*c,m=i*o,b=i*a,p=i*c;return t[0]=1-h-y,t[1]=f+p,t[2]=l-b,t[3]=0,t[4]=f-p,t[5]=1-u-y,t[6]=d+m,t[7]=0,t[8]=l+b,t[9]=d-m,t[10]=1-u-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function c(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function u(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function f(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function h(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function l(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function d(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function y(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function m(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function b(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function p(t,e){var n=e[0],r=e[1],s=e[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i),t[0]=e[0]*i,t[1]=e[1]*i,t[2]=e[2]*i),t}function w(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function g(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[0],a=n[1],c=n[2];return t[0]=s*c-i*a,t[1]=i*o-r*c,t[2]=r*a-s*o,t}function v(t,e,n){var r=e[0],s=e[1],i=e[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,t[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,t[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,t[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,t}var M=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},T=m,A=f;function _(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function O(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function x(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function S(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function I(t,e,n,r){var s=e[0],i=e[1],o=e[2],a=e[3],c=n[0],u=n[1],f=n[2],h=n[3],l=void 0,d=void 0,y=void 0,m=void 0,b=void 0;return(d=s*c+i*u+o*f+a*h)<0&&(d=-d,c=-c,u=-u,f=-f,h=-h),1-d>1e-6?(l=Math.acos(d),y=Math.sin(l),m=Math.sin((1-r)*l)/y,b=Math.sin(r*l)/y):(m=1-r,b=r),t[0]=m*s+b*c,t[1]=m*i+b*u,t[2]=m*o+b*f,t[3]=m*a+b*h,t}u(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var k,E=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};u(),h(1,0,0),h(0,1,0),x(),x(),k=new e(9),e!=Float32Array&&(k[1]=0,k[2]=0,k[3]=0,k[5]=0,k[6]=0,k[7]=0),k[0]=1,k[4]=1,k[8]=1;\n/*!\n   * @maptalks/gltf-loader v0.95.2\n   * LICENSE : UNLICENSED\n   * (c) 2016-2024 maptalks.org\n   */\nlet C=0;function U(t){return null==t}function F(t){return!U(t)}function N(t){return!U(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function P(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function B(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function D(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function R(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const L=[],z=[],j=[],V=[0,0,0],q=S([]),G=[1,1,1];function $(t,e,n,r,s,i,o){const a=B(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(u),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const X="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function H(t,e,n){const r=new Uint8Array(t,e,n);return X.decode(r)}const J={get:function(t,e={}){e||(e={});const n=new AbortController,r=n.signal,s=P({},e);s.signal=r,s.method||(s.method="GET");const i=fetch(t,s).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return i.xhr=n,i},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",J.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?J.jsonp(t):((e=e||{}).responseType="json",J.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+C++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class K{constructor(t,e,n,r){this.s=t,this.decoders=e,this.i=n,this.images={},this.o={},this.u=r||{}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)}if(this.o[t.id])return this.o[t.id].then(()=>{const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)});if(D(t.uri)){const r=this.buffers[t.id]=R(t.uri),s=this.h(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.o[t.id]=J.getArrayBuffer(r,this.u).then(r=>{const s=this.buffers[t.id]=r.data,i=this.h(e,s);return this.getImageByBuffer(i,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.i}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.m(e.id,t)}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.o[t.id]?this.o[t.id].then(()=>this.images[t.id]):this.o[t.id]=this.m(t.id,e)}m(t,e){return new Promise((n,r)=>{this.s(e,this.u,(s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))})})}}const Y=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],Q=[];class W{constructor(t,e,n,r){this.rootPath=t,this.gltf=e,this.p=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.v(),this.u=r}M(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this.T(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.A(s).then(n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this.T(t,e,s,i)})}A(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(D(e.uri)){const t=this.buffers[e.id]=R(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=J.getArrayBuffer(t,this.u).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}T(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this._(i.type),u=B(i.componentType),f=o.byteStride||0,h={array:void 0,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(h.min=i.min),i.max&&(h.max=i.max),n)if(this.p)h.byteStride=f,h.byteOffset=a+(i.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(h.array=this.O(n,i.count,c,a+(i.byteOffset||0),u),h.array.buffer.byteLength===h.byteLength&&(h.byteOffset=0)):h.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){h.byteStride=0,h.byteOffset=0;const t=new u(i.count*c);if(h.array=$(t,n,i.count,c,f,a+(i.byteOffset||0),i.componentType),h.extensions&&h.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(h.array.length),{decodeMatrix:e}=h.extensions.WEB3D_quantized_attributes;for(let n=0;n<h.array.length;n+=c){Q[0]=h.array[n],Q[1]=h.array[n+1],Q[2]=h.array[n+2],Q[3]=1;const r=O(Q,Q,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}h.componentType=5126,h.array=t}}else h.byteStride=0,h.array=this.O(n,i.count,c,a+(i.byteOffset||0),u),h.byteOffset=h.array.byteOffset;else{h.array=new u(i.count);const t=h.min||h.max;t&&(h.array[0]=t[0],h.array[1]=t[1],h.array[2]=t[2])}return h}v(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}O(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}_(t){const e=Y.indexOf(t);return Y[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.A(e).then(r=>{const{buffer:s,byteOffset:i}=r,o=H(s,i+(e.byteOffset||0),n);return t.content=o,t})}if(t.uri){if(D(t.uri)){const e=R(t.uri),n=H(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return J.get(e,this.u).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class Z extends K{constructor(t,e,n,r,s,i,o){super(r,s,i,o),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new W(t,e,n,o)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(F(t.name)&&(e.name=t.name),F(t.children)&&(e.children=t.children),F(t.jointName)&&(e.jointName=t.jointName),F(t.matrix)&&(e.matrix=t.matrix),F(t.rotation)&&(e.rotation=t.rotation),F(t.scale)&&(e.scale=t.scale),F(t.translation)&&(e.translation=t.translation),F(t.extras)&&(e.extras=t.extras),F(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const n=i(L,e.translation||V),r=a(z,e.rotation||q),c=o(j,e.scale||G);return s(c,r,c),s(t,n,c)}return r(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}S(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}I(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}k(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.I(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class tt extends K{constructor(t,e,n,r,s,i,o){super(r,s,i,o),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new W(t,e,n,o)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return P(e,t),!F(t.weights)&&this.gltf.meshes&&F(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}k(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!F(n))return null;const r=this.gltf.images[n];return this.I(r).then(t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};P(n,e);const s=F(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}I(t){if(!F(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.C(e,t)}return null}C(t,e){const n=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}h(t,e,n){n=n||0;const r=t.byteOffset+n,s=t.byteLength;return new Uint8Array(e,r,s)}U(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(F(t[n].input)||F(t[n].output))&&(e.push(this.accessor.M("input",t[n].input)),e.push(this.accessor.M("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const et="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class nt{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return nt.readV1(r,e);if(2===s)return nt.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const s=rt(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=rt(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function rt(t,e,n){if(et){const r=new Uint8Array(t,e,n);return et.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=st[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const st=[1,1,1,1,2,2,3,0],it=[0,0,0],ot=[0,0,0,1],at=[1,1,1],ct={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},ut={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},ft={F(t,e,n,r,s,i,o,a){const c=F(t)?e.animations:[e.animations[0]],u={};for(let e=0;e<c.length;e++){const f=c[e],h=f.name||e;if(F(t)&&h!==t)continue;const d=f.channelsMap[n];if(d)for(let t=0;t<d.length;t++){const e=d[t];"translation"===e.target.path?(this.N(s,f.samplers[e.sampler],r,1),u.translation=l(it,s)):"rotation"===e.target.path?(this.P(i,f.samplers[e.sampler],r,1),u.rotation=E(ot,i)):"scale"===e.target.path?(this.N(o,f.samplers[e.sampler],r,1),u.scale=l(at,o)):"weights"===e.target.path&&a&&(this.N(a,f.samplers[e.sampler],r,a.length),u.weights=a)}}return u},N(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.B(ut,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.B(ut,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.B(ut,e,n,3*r);s&&(t=this.D(t,s,e.input.array,3*r));break}}return t},P(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.B(ut,e,n,1);r&&I(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.B(ut,e,n,1);r&&(t=_(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.B(ut,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.D(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},R(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},B(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.R(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:f}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=f;const h=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*h,(t.PREINDEX+1)*h),t.NEXT=i.subarray(t.NEXTINDEX*h,(t.NEXTINDEX+1)*h),t},D(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],f=(o-i)*e.NEXT[n],h=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*f;t[n]=h}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return d(it,...ct.TRANSLATION),_(ot,...ct.ROTATION),d(at,...ct.SCALE),this.F(r,t,e,n,it,ot,at,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?F(e)?n[e]:n[Object.keys(n)[0]]:null}};let ht=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(Qe){}t&&"undefined"!=typeof createImageBitmap&&(ht=!0)}const lt="undefined"==typeof document?null:document.createElement("canvas");class dt{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.u=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=nt.read(e.buffer,e.byteOffset,e.byteLength);this.L(t,n,r)}else this.L(t,e);this.j=new W(this.rootPath,this.gltf,this.glbBuffer,this.u),this.V()}V(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}q(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.j.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.G(t),n=this.$(),r=this.X(),s=this.q();return Promise.all([e,n,r,s]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return ft.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return ft.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return B(t)}static readInterleavedArray(t,e,n,r,s,i,o){return $(t,e,n,r,s,i,o)}L(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=ht?pt.bind(this):this.options.requestImage||yt,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new tt(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new Z(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}H(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||N(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.H(n,e)});t.children=r}var n;return t}G(t){return this.J(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.H(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=i),e.push(o)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.S(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r})}J(t){return this.K(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}Y(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.W(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}W(t){const e=t.inverseBindMatrices;return this.adapter.accessor.M("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}$(){const t=this.gltf.animations;return F(t)?this.adapter.getAnimations(t):null}K(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.Z(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.Y()),Promise.all(e)}Z(t,e){const n=t.primitives.map(t=>this.tt(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return P(n,t),n.primitives=e,n})}X(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.k(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}tt(t,e){let n;const r=[],s=t.extensions;if(F(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.M(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.j.A(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const u=new DataView(r,s+i,c),f={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,f).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.M(t,e[t]);n&&r.push(n)}if(F(t.indices)){const e=this.adapter.accessor.M("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;b(t,t,s),y(t,t,i),b(n,n,s),y(n,n,i)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=F(t.mode)?t.mode:4,F(t.extras)&&(i.extras=t.extras),i})}}function yt(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!lt)return void n(new Error("There is no canvas to draw image!"));lt.width=r.width,lt.height=r.height;const t=lt.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}let mt,bt;function pt(t,e,n){mt||(mt=new OffscreenCanvas(2,2),bt=mt.getContext("2d",{willReadFrequently:!0}));let r=null;if(N(t))r=fetch(t,e).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)});else{const e=new Blob([t]);r=createImageBitmap(e)}r.then(wt.bind(this)).then(t=>{n(null,t)}).catch(t=>{console.warn(t),n(t)})}function wt(t){let{width:e,height:n}=t;gt(e)||(e=vt(e)),gt(n)||(n=vt(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),mt.width=e,mt.height=n,bt.drawImage(t,0,0,e,n),t.close();const s=bt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function gt(t){return 0==(t&t-1)&&0!==t}function vt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var Mt={exports:{}},Tt={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},At={exports:{}},_t=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},Ot=Array.prototype.concat,xt=Array.prototype.slice,St=At.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];_t(s)?e=Ot.call(e,xt.call(s)):e.push(s)}return e};St.wrap=function(t){return function(){return t(St(arguments))}};var It=Tt,kt=At.exports,Et=Object.hasOwnProperty,Ct=Object.create(null);for(var Ut in It)Et.call(It,Ut)&&(Ct[It[Ut]]=Ut);var Ft=Mt.exports={to:{},get:{}};function Nt(t,e,n){return Math.min(Math.max(e,t),n)}function Pt(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}Ft.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=Ft.get.hsl(t),n="hsl";break;case"hwb":e=Ft.get.hwb(t),n="hwb";break;default:e=Ft.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},Ft.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:Et.call(It,e[1])?((s=It[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?s[3]=.01*parseFloat(e[4]):s[3]=parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=Nt(s[n],0,255);return s[3]=Nt(s[3],0,1),s},Ft.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Nt(parseFloat(e[2]),0,100),Nt(parseFloat(e[3]),0,100),Nt(isNaN(n)?1:n,0,1)]}return null},Ft.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,Nt(parseFloat(e[2]),0,100),Nt(parseFloat(e[3]),0,100),Nt(isNaN(n)?1:n,0,1)]}return null},Ft.to.hex=function(){var t=kt(arguments);return"#"+Pt(t[0])+Pt(t[1])+Pt(t[2])+(t[3]<1?Pt(Math.round(255*t[3])):"")},Ft.to.rgb=function(){var t=kt(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},Ft.to.rgb.percent=function(){var t=kt(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},Ft.to.hsl=function(){var t=kt(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},Ft.to.hwb=function(){var t=kt(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},Ft.to.keyword=function(t){return Ct[t.slice(0,3)]};var Bt={exports:{}},Dt=Tt,Rt={};for(var Lt in Dt)Dt.hasOwnProperty(Lt)&&(Rt[Dt[Lt]]=Lt);var zt=Bt.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var jt in zt)if(zt.hasOwnProperty(jt)){if(!("channels"in zt[jt]))throw new Error("missing channels property: "+jt);if(!("labels"in zt[jt]))throw new Error("missing channel labels property: "+jt);if(zt[jt].labels.length!==zt[jt].channels)throw new Error("channel and label counts mismatch: "+jt);var Vt=zt[jt].channels,qt=zt[jt].labels;delete zt[jt].channels,delete zt[jt].labels,Object.defineProperty(zt[jt],"channels",{value:Vt}),Object.defineProperty(zt[jt],"labels",{value:qt})}function Gt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}zt.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},zt.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,u=Math.max(o,a,c),f=u-Math.min(o,a,c),h=function(t){return(u-t)/6/f+.5};return 0===f?s=i=0:(i=f/u,e=h(o),n=h(a),r=h(c),o===u?s=r-n:a===u?s=1/3+e-r:c===u&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*u]},zt.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[zt.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},zt.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},zt.rgb.keyword=function(t){var e=Rt[t];if(e)return e;var n,r=1/0;for(var s in Dt)if(Dt.hasOwnProperty(s)){var i=Gt(t,Dt[s]);i<r&&(r=i,n=s)}return n},zt.keyword.rgb=function(t){return Dt[t]},zt.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},zt.rgb.lab=function(t){var e=zt.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},zt.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var u=0;u<3;u++)(r=o+1/3*-(u-1))<0&&r++,r>1&&r--,i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,s[u]=255*i;return s},zt.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),100*((r+n)/2)]},zt.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},zt.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},zt.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,u=t[1]/100,f=t[2]/100,h=u+f;switch(h>1&&(u/=h,f/=h),r=6*c-(e=Math.floor(6*c)),0!=(1&e)&&(r=1-r),s=u+r*((n=1-f)-u),e){default:case 6:case 0:i=n,o=s,a=u;break;case 1:i=s,o=n,a=u;break;case 2:i=u,o=n,a=s;break;case 3:i=u,o=s,a=n;break;case 4:i=s,o=u,a=n;break;case 5:i=n,o=u,a=s}return[255*i,255*o,255*a]},zt.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,e*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},zt.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},zt.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},zt.lab.xyz=function(t){var e,n,r,s=t[0];e=t[1]/500+(n=(s+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},zt.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},zt.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},zt.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:zt.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},zt.hsv.ansi16=function(t){return zt.rgb.ansi16(zt.hsv.rgb(t),t[2])},zt.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},zt.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},zt.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},zt.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},zt.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},zt.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},zt.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},zt.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},zt.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return s=(1-n)*r,[255*(n*i[0]+s),255*(n*i[1]+s),255*(n*i[2]+s)]},zt.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},zt.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},zt.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},zt.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},zt.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},zt.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},zt.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},zt.gray.hsl=zt.gray.hsv=function(t){return[0,0,t[0]]},zt.gray.hwb=function(t){return[0,100,t[0]]},zt.gray.cmyk=function(t){return[0,0,0,t[0]]},zt.gray.lab=function(t){return[t[0],0,0]},zt.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},zt.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var $t=Bt.exports;function Xt(t){var e=function(){for(var t={},e=Object.keys($t),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys($t[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Ht(t,e){return function(n){return e(t(n))}}function Jt(t,e){for(var n=[e[t].parent,t],r=$t[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=Ht($t[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var Kt=Bt.exports,Yt=function(t){for(var e=Xt(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=Jt(o,e))}return n},Qt={};Object.keys(Kt).forEach((function(t){Qt[t]={},Object.defineProperty(Qt[t],"channels",{value:Kt[t].channels}),Object.defineProperty(Qt[t],"labels",{value:Kt[t].labels});var e=Yt(t);Object.keys(e).forEach((function(n){var r=e[n];Qt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),Qt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var Wt=Qt,Zt=Mt.exports,te=Wt,ee=[].slice,ne=["keyword","gray","hex"],re={};Object.keys(te).forEach((function(t){re[ee.call(te[t].labels).sort().join("")]=t}));var se={};function ie(t,e){if(!(this instanceof ie))return new ie(t,e);if(e&&e in ne&&(e=null),e&&!(e in te))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ie)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=Zt.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,r=te[this.model].channels,this.color=s.value.slice(0,r),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb",r=te[this.model].channels;var i=ee.call(t,0,r);this.color=ue(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in re))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=re[a];var c=te[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ue(u)}if(se[this.model])for(r=te[this.model].channels,n=0;n<r;n++){var f=se[this.model][n];f&&(this.color[n]=f(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function oe(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(se[t]||(se[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function ae(t){return function(e){return Math.max(0,Math.min(t,e))}}function ce(t){return Array.isArray(t)?t:[t]}function ue(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function fe(t){return null==t}function he(t){return"object"==typeof t&&!!t}function le(t){return t/Math.PI*180}function de(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}ie.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in Zt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return Zt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return Zt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=te[this.model].channels,n=te[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ie(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ie(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:oe("rgb",0,ae(255)),green:oe("rgb",1,ae(255)),blue:oe("rgb",2,ae(255)),hue:oe(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:oe("hsl",1,ae(100)),lightness:oe("hsl",2,ae(100)),saturationv:oe("hsv",1,ae(100)),value:oe("hsv",2,ae(100)),chroma:oe("hcg",1,ae(100)),gray:oe("hcg",2,ae(100)),white:oe("hwb",1,ae(100)),wblack:oe("hwb",2,ae(100)),cyan:oe("cmyk",0,ae(100)),magenta:oe("cmyk",1,ae(100)),yellow:oe("cmyk",2,ae(100)),black:oe("cmyk",3,ae(100)),x:oe("xyz",0,ae(100)),y:oe("xyz",1,ae(100)),z:oe("xyz",2,ae(100)),l:oe("lab",0,ae(100)),a:oe("lab",1),b:oe("lab",2),keyword:function(t){return arguments.length?new ie(t):te[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ie(t):Zt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ie.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error(\'Argument to "mix" was not a Color instance, but rather an instance of \'+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return ie.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(te).forEach((function(t){if(-1===ne.indexOf(t)){var e=te[t].channels;ie.prototype[t]=function(){if(this.model===t)return new ie(this);if(arguments.length)return new ie(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new ie(ce(te[this.model][t].raw(this.color)).concat(n),t)},ie[t]=function(n){return"number"==typeof n&&(n=ue(ee.call(arguments),e)),new ie(n,t)}}}));const ye=[1,1,1,1,2,2,3,0];function me(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=ye[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}new Array(3),new Array(3);const be=[1/6378137,1/6378137,1/6356752.314245179],pe=[1/40680631590769,1/40680631590769,1/40408299984661.445],we=new Array(3),ge=new Array(3),ve=new Array(3);function Me(t,e){const n=pe,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],u=n[1],f=n[2],h=i*i*c*c,l=o*o*u*u,d=a*a*f*f,y=h+l+d,m=Math.sqrt(1/y),p=b(Te,e,m);if(y<s)return isFinite(m)?p:void 0;const w=r[0],g=r[1],v=r[2],M=Ae;M[0]=p[0]*w*2,M[1]=p[1]*g*2,M[2]=p[2]*v*2;let T,A,_,O,x,S,I,k,E,C,U,F=(1-m)*_e(e)/(.5*_e(M)),N=0;do{F-=N,_=1/(1+F*w),O=1/(1+F*g),x=1/(1+F*v),S=_*_,I=O*O,k=x*x,E=S*_,C=I*O,U=k*x,T=h*S+l*I+d*k-1,A=h*E*w+l*C*g+d*U*v;N=T/(-2*A)}while(Math.abs(T)>1e-12);return t[0]=i*_,t[1]=o*O,t[2]=a*x,t}(we,e,be,n,.1);let s=T(ge,r,n);s=function(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i);return t}(s,s);const i=M(ve,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=de(w(i,e))*_e(i);return t[0]=le(o),t[1]=le(a),t[2]=c,t}const Te=new Array(3),Ae=new Array(3);function _e(t){return f(t)}function Oe(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function xe(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const Se="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ie(t,e,n){const r=new Uint8Array(t,e,n);return Se?JSON.parse(Se.decode(r)):JSON.parse(me(r))}function ke(t,e,n){const r=new Uint8Array(t,e,n);return Se?JSON.parse(Se.decode(r)):JSON.parse(me(r))}function Ee(t,e,n){return{offset:e,byteLength:n}}function Ce(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=function(t){return Ne[t]}(i||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Fe[t]}(o);return{byteStride:0,byteOffset:s+n,itemSize:u,count:r*u,componentType:c,array:new a(e,n+s,r*u)}}function Ue(t,e,n,r){const s=Ce(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}const Fe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ne={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Pe(t){for(const e in Ne)if(t===Ne[e].ctor)return Ne[e].type;throw new Error("unrecognized ctor:"+t)}function Be(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function De(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,u={},f={},h=null;r>0&&(u=Ie(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(f=ke(a,e,i),e+=i);const l=Ee(0,e,o);return h=a.slice(l.offset,l.offset+l.byteLength),n.push(h),{featureTable:u,featureTableBin:c,batchTable:f,batchTableBin:h}}const Re={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Le={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},ze={},je={east:[],north:[],up:[],west:[],south:[],down:[]};let Ve=[],qe=[],Ge=[];const $e=[0,0,0];const Xe=function(t,e){const n=Re[t][e];let r;const s=t+e;return ze[s]?r=ze[s]:(r=function(r,s,i){if(function(t,e){var n=t[0],r=t[1],s=t[2],i=e[0],o=e[1],a=e[2];return Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}(r,$e))l(Ve,Le[t]),l(qe,Le[e]),l(Ge,Le[n]);else if(Oe(r[0],0,1e-14)&&Oe(r[1],0,1e-14)){const s=de(r[2]);l(Ve,Le[t]),"east"!==t&&"west"!==t&&b(Ve,Ve,s),l(qe,Le[e]),"east"!==e&&"west"!==e&&b(qe,qe,s),l(Ge,Le[n]),"east"!==n&&"west"!==n&&b(Ge,Ge,s)}else{!function(t,e){m(e,t,pe),p(e,e)}(r,je.up);const s=je.up,i=je.east;i[0]=-r[1],i[1]=r[0],i[2]=0,p(je.east,i),g(je.north,s,i),b(je.down,je.up,-1),b(je.west,je.east,-1),b(je.south,je.north,-1),Ve=je[t],qe=je[e],Ge=je[n]}return i[0]=Ve[0],i[1]=Ve[1],i[2]=Ve[2],i[3]=0,i[4]=qe[0],i[5]=qe[1],i[6]=qe[2],i[7]=0,i[8]=Ge[0],i[9]=Ge[1],i[10]=Ge[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},ze[s]=r),r}("east","north"),He={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Je(t){for(const e in He)if(t===He[e])return+e;throw new Error("unrecognized ctor:"+t)}\n/*!\n   * @maptalks/gl v0.95.6\n   * LICENSE : UNLICENSED\n   * (c) 2016-2024 maptalks.com\n   */const Ke=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},Ye=Ke(),Qe=Ye.gl_trans__coders=Ye.gl_trans__coders||{};Qe.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Ye.gl_trans__coders=Ye.gl_trans__coders||{};let i=`${r}\\n    const _____getGlobal = ${Ke.toString()};\\n    const g___lobals = _____getGlobal()\\n    const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+=\'tran_____scoders["\'+t+\'"] =\'+s[t].toString()+"\\n;");return i+="\\n"+e.substring(r.length),i},Qe.registerTranscoder=function(t,e){Qe[t]=e},Qe.getTranscoder=function(t){return Qe[t]};let We=null;function Ze(){return We||(We={"image/crn":Qe.crn&&Qe.crn(),"image/ktx2":Qe.ktx2&&Qe.ktx2(),"image/cttf":Qe.ktx2&&Qe.ktx2(),"draco":Qe.draco&&Qe.draco()}),We}class tn{constructor(t,e,n){this.s=t,this.et=e||dt,this.i=n,this.nt=Ze()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.rt(t,e,n,r,s)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.rt(t,s,n,r)})}rt(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.st(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.et(a,o.glb,{transferable:!0,requestImage:this.s,decoders:this.nt,supportedFormats:this.i,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then(e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}})}st(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm\'s byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),u=s.getUint32(20,!0),f=s.getUint32(24,!0),h=28+e;u>=570425344?(h-=8,o=a,u=c,f=0,a=0,c=0):f>=570425344&&(h-=4,o=u,u=a,f=c,a=0,c=0);const l=[t];let d,y,m;if(a>0?(d=Ie(t,h,a),h+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(h+=c),u>0&&(y=ke(t,h,u),h+=u,f>0)){const e=Ee(0,h,f);m=t.slice(e.offset,e.offset+e.byteLength),h+=f,l.push(m)}const b=d.BATCH_LENGTH,p={};if(d&&d.BATCH_ID){p.BATCH_ID=Ue(d.BATCH_ID,t,(void 0).offset,b);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&l.indexOf(e)<0&&l.push(e)}return{count:o,transferables:l,featureTable:d,batchTable:y,batchTableBin:m,b3dm:p,glb:{buffer:t,byteOffset:h,byteLength:s.byteLength+s.byteOffset-h}}}it(){return null}}class en{constructor(t,e,n,r){this.s=t,this.et=e||dt,this.i=n,this.nt=Ze(),this.ot=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.rt(t,e,n,r,s)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.rt(t,s,n,r)})}rt(t,e,n,r,s){return this.ct(t,e,n,r,s).then(({gltf:s,transferables:i})=>{const o=this.ut(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})})}ct(t,e,n,r,s){const i=s&&s.maxTextureSize,o={transferable:!0,requestImage:this.s,decoders:this.nt,supportedFormats:this.i,maxTextureSize:i},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=me(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?J.getArrayBuffer(r,{}).then(t=>this.ft(r,{buffer:t.data,byteOffset:0},o)):J.getJSON(r,{}).then(t=>this.ft(r,t,o))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.ft(t,r,o)}}ft(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.et(r,e,n);return s.load({skipAttributeTransform:!0}).then(n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}})}ut(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=De(s,32+e,o),h={},l=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;h.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.ht(new Uint16Array(t,r+c.offset,3*l),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Ue(a.BATCH_ID,t,c.offset,l);const e=h.BATCH_ID.array&&h.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.lt(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:this.lt(new Uint16Array(t,e+c.offset,2*l))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,l).slice()},o.push(h.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;h.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:l,componentType:5126,array:new Float32Array(t,e+c.offset,3*l).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:l,batchTable:u,batchTableBin:f,featureTable:a,i3dm:h,transferables:o}}lt(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)nn(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}ht(t,e,n){return Be(new Float32Array(t.length),t,e,n)}it(){return null}}function nn(t,e,n,r){if(t[0]=rn(e,r),t[1]=rn(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*sn(e),t[1]=(1-Math.abs(e))*sn(t[1])}return p(t,t)}function rn(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function sn(t){return t<0?-1:1}class on{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.rt(t,e,n,r)):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return r||(r=s.byteLength),this.rt(t,s,n,r)})}rt(t,e,n,r){return this.dt(e,n,r,t).then(t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts})}dt(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts\'s byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:u,batchTableBin:f}=De(s,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,l=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let y,m={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){m=a.extensions["3DTILES_draco_point_compression"],y=new DataView(t,m.byteOffset+c.offset,m.byteLength);const e={attributes:m.properties,useUniqueIDs:!1};return this.yt||(this.yt=Ze().draco),this.yt(y,e).then(e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.bt(t,e.attributes,c.offset,d,o,h,l);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Pe(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?r.BATCH_ID=Ue(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=an(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:r,transferables:o}})}const b=this.bt(t,a,c.offset,d,o,h,l);if(a.BATCH_ID||Object.keys(u).length){a.BATCH_ID?b.BATCH_ID=Ue(a.BATCH_ID,t,c.offset,d):b.BATCH_ID=an(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:u,batchTableBin:f,featureTable:a,pnts:b,transferables:o})}bt(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const f=u?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.ht(u||new Uint16Array(t,c+f,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}ht(t,e,n){return Be(new Float32Array(t.length),t,e,n)}it(){return null}}function an(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Pe(e),array:r}}class cn{constructor(t,e,n,r){this.i=n,this.s=t,this.et=e||dt,this.ot=r}load(t,e,n=0,r=0,s){return e?this.rt(t,e,n,r,s):J.getArrayBuffer(t,{}).then(e=>{const s=e.data;return this.rt(t,s,n,r)})}rt(t,e,n,r,s){r||(r=e.byteLength);const i=this.pt(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new tn(this.s,this.et,this.i);else if("i3dm"===i[n].magic)r=new en(this.s,this.et,this.i,this.ot);else if("pnts"===i[n].magic)r=new on;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new cn(this.s,this.et,this.i,this.ot)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then(t=>t))}return Promise.all(o).then(t=>({magic:"cmpt",tiles:t}))}pt(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=xe(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}function un(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){const s=[];bn(r[n],s,t,e)}}}const fn=[],hn=[],ln=[],dn=[0,0,0],yn=S([]),mn=[1,1,1];function bn(t,e,n,r){const c=e.slice(0);if(t.matrix)c.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=i(fn,t.translation||dn),n=a(hn,t.rotation||yn),r=o(ln,t.scale||mn);s(r,n,r);const u=s([],e,r);c.push(u)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)bn(t.children[e],c,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=c.slice(0),i=s.primitives;for(let s=0,o=i.length;s<o;s++){const o=i[s];o&&(o.matrices=t,r(o,e,s,n))}}}}function pn(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?dt.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o)}return}const u=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);u.set(s);e(new c(u.buffer),t),s.set(u)}}var wn=An("DXT1"),gn=An("DXT3"),vn=An("DXT5"),Mn=An("DX10"),Tn=function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var s=r[21];switch(s){case wn:e=8,n="dxt1";break;case gn:e=16,n="dxt3";break;case vn:e=16,n="dxt5";break;case 116:n="rgba32f";break;case Mn:var i=new Uint32Array(t.slice(128,148));n=i[0];var o=i[1];if(i[2],i[3],i[4],3!==o||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(a=s,String.fromCharCode(255&a,a>>8&255,a>>16&255,a>>24&255)))}var a;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var f=!1;512&r[28]&&(f=!0);var h,l=r[4],d=r[3],y=r[1]+4,m=l,b=d,p=[];s===Mn&&(y+=20);if(f)for(var w=0;w<6;w++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");l=m,d=b;for(var g=Math.log(l)/Math.log(2)+1,v=0;v<g;v++)h=l*d*16,p.push({offset:y,length:h,shape:[l,d]}),v<u&&(y+=h),l=Math.floor(l/2),d=Math.floor(d/2)}else for(v=0;v<u;v++)h=Math.max(4,l)/4*Math.max(4,d)/4*e,p.push({offset:y,length:h,shape:[l,d]}),y+=h,l=Math.floor(l/2),d=Math.floor(d/2);return{shape:[m,b],images:p,format:n,flags:c,cubemap:f}};function An(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var _n=Math.abs,On=Math.sin,xn=Math.cos,Sn=Math.tan,In=Math.atan,kn=Math.atan2,En=Math.sqrt,Cn=Math.log,Un=Math.hypot,Fn=Math.sinh,Nn=Math.cosh;function Pn(t){var e,n,r,s,i,o,a=[],c=[],u=[],f=[];function h(t,e){for(var n,r=2*xn(2*e),s=t.length-1,i=t[s],o=0;--s>=0;)n=r*i-o+t[s],o=i,i=n;return e+n*On(2*e)}function l(t,e,n){for(var r,s,i=On(e),o=xn(e),a=Fn(n),c=Nn(n),u=2*o*c,f=-2*i*a,h=t.length-1,l=t[h],d=0,y=0,m=0;--h>=0;)r=y,s=d,l=u*(y=l)-r-f*(d=m)+t[h],m=f*y-s+u*d;return[(u=i*c)*l-(f=o*a)*m,u*m+f*l]}t.es,i=s=(r=t.es/(1+En(1-t.es)))/(2-r),a[0]=s*(2+s*(-2/3+s*(s*(116/45+s*(26/45+s*(-2854/675)))-2))),c[0]=s*(s*(2/3+s*(4/3+s*(-82/45+s*(32/45+s*(4642/4725)))))-2),i*=s,a[1]=i*(7/3+s*(s*(-227/45+s*(2704/315+s*(2323/945)))-1.6)),c[1]=i*(5/3+s*(-16/15+s*(-13/9+s*(904/315+s*(-1522/945))))),i*=s,a[2]=i*(56/15+s*(-136/35+s*(-1262/105+s*(73814/2835)))),c[2]=i*(-26/15+s*(34/21+s*(1.6+s*(-12686/2835)))),i*=s,a[3]=i*(4279/630+s*(-332/35+s*(-399572/14175))),c[3]=i*(1237/630+s*(s*(-24832/14175)-2.4)),i*=s,a[4]=i*(4174/315+s*(-144838/6237)),c[4]=i*(-734/315+s*(109598/31185)),i*=s,a[5]=i*(601676/22275),c[5]=i*(444337/155925),i=s*s,e=t.k0/(1+s)*(1+i*(1/4+i*(1/64+i/256))),u[0]=s*(s*(2/3+s*(-37/96+s*(1/360+s*(81/512+s*(-96199/604800)))))-.5),f[0]=s*(.5+s*(-2/3+s*(5/16+s*(41/180+s*(-127/288+s*(7891/37800)))))),u[1]=i*(-1/48+s*(-1/15+s*(437/1440+s*(-46/105+s*(1118711/3870720))))),f[1]=i*(13/48+s*(s*(557/1440+s*(281/630+s*(-1983433/1935360)))-.6)),i*=s,u[2]=i*(-17/480+s*(37/840+s*(209/4480+s*(-5569/90720)))),f[2]=i*(61/240+s*(-103/140+s*(15061/26880+s*(167603/181440)))),i*=s,u[3]=i*(-4397/161280+s*(11/504+s*(830251/7257600))),f[3]=i*(49561/161280+s*(-179/168+s*(6601661/7257600))),i*=s,u[4]=i*(-4583/161280+s*(108847/3991680)),f[4]=i*(34729/80640+s*(-3418889/1995840)),i*=s,u[5]=i*(-20648693/638668800),f[5]=.6650675310896665*i,o=h(c,t.phi0),n=-e*(o+function(t,e){var n,r=2*xn(e),s=t.length-1,i=t[s],o=0;for(;--s>=0;)n=r*i-o+t[s],o=i,i=n;return On(e)*n}(f,2*o)),t.fwd=function(t,r){var s,i,o,a,u,d=t.phi,y=t.lam;d=h(c,d),s=On(d),i=xn(d),a=On(y),o=xn(y),d=kn(s,o*i),y=kn(a*i,Un(s,i*o)),y=function(t){var e=_n(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Cn(e)/n}(e*(1+e/(Un(1,e)+1))),t<0?-e:e}(Sn(y)),u=l(f,2*d,2*y),d+=u[0],y+=u[1],_n(y)<=2.623395162778?(r.y=e*d+n,r.x=e*y):r.x=r.y=1/0},t.inv=function(t,r){var s,i,o,c,f,d=t.y,y=t.x;d=(d-n)/e,_n(y/=e)<=2.623395162778?(f=l(u,2*d,2*y),d+=f[0],y+=f[1],y=In(Fn(y)),s=On(d),i=xn(d),c=On(y),o=xn(y),y=kn(c,o*i),d=kn(s*o,Un(c,o*i)),r.phi=h(a,d),r.lam=y):r.phi=r.lam=1/0}}const Bn=Math.PI/180,Dn=6378137*Math.PI/180,Rn={};function Ln(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=85.0511287798,r=e[0],s=Math.max(Math.min(n,e[1]),-n);let i;i=0===s?0:Math.log(Math.tan((90+s)*Bn/2))/Bn;return t[0]=r*Dn,t[1]=i*Dn,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return zn(t,e);if("baidu"===n)return zn(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const s=JSON.stringify(n);let i=Rn[s];return i||(i=Rn[s]=function(t){const e={a:6378137,es:.0066943799901413165,x0:fe(t.falseEasting)?5e5:t.falseEasting,y0:fe(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*jn,phi0:(t.latitudeOfOrigin||0)*jn,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Pn(e);const n={lam:0,phi:0},r={};let s=0,i=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*jn-e.lam0,n.phi=e.originPhi0*jn,e.fwd(n,r),s=e.a*r.x+e.x0,i=e.a*r.y+e.y0);return{project:function(t,o){n.lam=t[0]*jn-e.lam0,n.phi=t[1]*jn,e.fwd(n,r);const a=e.a*r.x+e.x0-s,c=e.a*r.y+e.y0-i;return o[0]=a,o[1]=c,o}}}(n)),i.project(e,t)}}function zn(t,e){return t[0]=e[0],t[1]=e[1],t}const jn=.017453292519943295;const Vn=r([]),qn=Ze().draco,Gn=Ze().ktx2,$n={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Xn={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Hn(t,e,n,s,i,o){const a=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],s=J.getArrayBuffer(n.url,o);s.xhr.url=n.url,u.push(s.xhr);const i=s.then(t=>({buffer:t}));a.push(i);const f=[];if(tr(r,f),f.length){const t=f.map(t=>{const e=J.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then(e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format})});a.push(...t)}c[e]=f.length}const f=Promise.all(a).then(o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const a=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];a.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map(t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format}))}),u+=1+e}return function(t,e,n,s,i,o){const a={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:f}=t.meshes[u];const{geometry:h}=t.meshes[u];let l;const d=e[u].geoBuffer.data;if(!d)continue;const y=or(d);l=y?Kn(a,u,h,d,t.transform,t.center,i,o):Qn(a,u,h,d,t.transform,t.center,i,o),c.push(l),a.nodes[u]={mesh:u,nodeIndex:u,matrix:r([])},a.scenes[0].nodes[u]=a.nodes[u],f||(f=$n);const m=Zn(u,a,f,e[u].textureBuffers,n,s);c.push(m)}return Promise.all(c).then(()=>({gltf:a,featureTable:{BATCH_LENGTH:0},transferables:a.transferables}))}(t,a,e,i,n,s)});return f.xhr=u,f}const Jn={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Kn(t,e,n,r,s,i,o,a){const c=n.info.compressedAttributes.attributes.reduce((t,e,n)=>{const r=Xn[e];if(!r)return t;return t[r.name||e]=n,t},{});return qn(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then(n=>Wn(n,t,e,s,i,o,a))}const Yn={position:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.position={array:s,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,s=new Float32Array(e,n,r);return t.normal={array:s,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,s=new Float32Array(e,n,r);return t.uv0={array:s,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,s=new Uint8Array(e,n,r);return t.color={array:s,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,s=new Uint32Array(e,n,r);return t.faceRange={array:s,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,s=new Uint16Array(e,n,r);return t["uv-region"]={array:s,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Qn(t,e,n,r,s,i,o,a){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Yn[n[e]]?t=Yn[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let s=e.ordering,i=e.featureAttributeOrder;const o=null;o&&o.geometryData&&o.geometryData[0]&&o.geometryData[0].params;for(let e=0;e<s.length;e++){const n=Yn[s[e]];n||console.log(s[e]),t=n(c,r,t)}for(let e=0;e<i.length;e++){const n=Yn[i[e]];n||console.log(i[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const f={};for(const t in c){const e=Xn[t]&&Xn[t].name;e&&(f[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(h=e)<=255?Uint8Array:h<=65535?Uint16Array:Uint32Array,r=new n(f.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,s=t[e],i=t[e+1];for(let t=s;t<=i;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}f._BATCHID={componentType:Je(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var h;return Wn({attributes:f},t,e,s,i,o,a)}function Wn(t,e,n,r,s,i,o){const a={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,s){let i,o=[0,0,0,1];const a=[0,0],u=Ln([],n,r,s);u[2]=n[2];const f=e&&c(Vn,e);return pn(t,t=>(o[0]=t[0],o[1]=t[1],o[2]=t[2],f||(o=v(o,o,e)),n&&y(o,o,n),Ln(a,o,r,s),i=o[2],t[0]=a[0]-u[0],t[1]=a[1]-u[1],t[2]=i-u[2],t)),u}(t.attributes.POSITION,r,s,i,o);e.meshes[n]={primitives:[a],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:s};for(const n in t.attributes)ir(e.transferables,t.attributes[n].array.buffer);return t.indices&&ir(e.transferables,t.indices.array.buffer),a}function Zn(t,e,n,r,s,i){const o=r.map(t=>function(t,e,n,r,s){if("dds"===e){const e=Tn(t),r=e.images.map(e=>new Uint8Array(t,e.offset,e.length)),s="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Jn,format:s})}if("png"===e||"jpg"===e)return function(t,e){er||(er=new OffscreenCanvas(2,2),nr=er.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then(t=>{let{width:n,height:r}=t;rr(n)||(n=sr(n)),rr(r)||(r=sr(r));const s=e;s&&(n=Math.min(s,n),r=Math.min(s,r)),er.width=n,er.height=r,nr.drawImage(t,0,0,n,r),t.close();const i=nr.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(i.data)}}).catch(()=>({width:2,height:2,array:new Uint8Array(4)}))}(t,s).then(t=>{t.mimeType=n;return{image:t,sampler:Jn,format:6408}});if("ktx2"===e)return Gn(t,r).then(t=>(t.mimeType=n,{image:t,sampler:Jn,format:t.format}));return null}(t.data,t.format,t.mimeType,s,i).then(t=>{if(t.image)if(t.image.array)ir(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)ir(e.transferables,t.image.mipmap[n].buffer);return t}));return Promise.all(o).then(r=>{!function t(e,n,r,s){const i=JSON.parse(JSON.stringify(r)),o=n.textures;s.ptr||(s.ptr=0);for(const e in r)r[e]&&r[e].url?(o.push(s[s.ptr++]),i[e]={index:o.length-1},void 0!==r[e].factor&&(i[e].scale=r[e].factor)):he(r[e])&&(i[e]=t(-1,n,r[e],s));e>=0&&(n.materials[e]=i);return i}(t,e,n,r)})}function tr(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):he(t[n])&&tr(t[n],e)}let er,nr;function rr(t){return 0==(t&t-1)&&0!==t}function sr(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function ir(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function or(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}const ar=[];const cr=[],ur=[],fr=[],hr=[],lr=[],dr=[],yr=[];function mr(t,e,n,r,s,i){d(hr,t[3*e],t[3*e+1],t[3*e+2]),d(lr,t[3*n],t[3*n+1],t[3*n+2]),d(dr,t[3*r],t[3*r+1],t[3*r+2]);const o=M(cr,dr,lr),a=M(ur,hr,lr),c=g(fr,o,a);p(yr,c),s[3*e]=s[3*e]||0,s[3*n]=s[3*n]||0,s[3*r]=s[3*r]||0,s[3*e+1]=s[3*e+1]||0,s[3*n+1]=s[3*n+1]||0,s[3*r+1]=s[3*r+1]||0,s[3*e+2]=s[3*e+2]||0,s[3*n+2]=s[3*n+2]||0,s[3*r+2]=s[3*r+2]||0,s[3*e]+=yr[0],s[3*n]+=yr[0],s[3*r]+=yr[0],s[3*e+1]+=yr[1],s[3*n+1]+=yr[1],s[3*r+1]+=yr[1],s[3*e+2]+=yr[2],s[3*n+2]+=yr[2],s[3*r+2]+=yr[2],i[e]+=1,i[n]+=1,i[r]+=1}const br=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],pr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],wr=2*Math.PI*6378137/360,gr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let vr,Mr=!1;if("undefined"!=typeof OffscreenCanvas){try{vr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}vr&&"undefined"!=typeof createImageBitmap&&(Mr=!0)}const Tr=r([]),Ar=[0,0,0],_r=[],Or=[],xr=[],Sr=[],Ir={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},kr={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};class Er{constructor(t,e,n,r){this.id=t,this.options=e,this.wt=this.requestImage.bind(this),this.gt=n,this.vt={},r(null,{},[])}Mt(t){this.Tt||(this.i=t,this.At=new on,this.Tt=new tn(this.wt,dt,t),this._t=new en(this.wt,dt,t))}requestImage(t,e){Mr?fetch(t).then(t=>t.arrayBuffer()).then(t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)}).then(t=>{(void 0).width=t.width,(void 0).height=t.height,vr.drawImage(t,0,0);const n=vr.getImageData(0,0,(void 0).width,(void 0).height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})}):this.gt("requestImage",{url:t},null,e)}loadTile(t,e){this.Mt(t.supportedFormats);const n=t.service,r=t.url,s=t.arraybuffer,i=n.fetchOptions||{};if(i.referrer=t.referrer,i.referrerPolicy=i.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const s=t.i3sInfo,o=n.maxTextureSize||1024,a=Hn(s,t.supportedFormats,this.options.projection,t.projection,o,i);return a.then(t=>{if(delete this.vt[r],!t)return void e({status:404,url:r,i3sInfo:s});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:s});t.gltf.url=r;const{transferables:n}=t;t.magic="b3dm",this.Ot(t.gltf),e(null,t,n)}),void(this.vt[r]=a.xhr)}if(s){delete this.vt[r];const n=xe(new DataView(s),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(gr){const r=new Uint8Array(t,e,n);return gr.decode(r)}return me(new Uint8Array(t,e,n))}(s,0,s.byteLength),i=JSON.parse(n);i.accessors?this.xt(i,r,t,"gltf",e):this.St(t.rootIdx,i,s,r,e)}else this.xt(s,r,t,n,e)}else{let s=n.urlParams;s&&(s=(r.indexOf("?")>0?"&":"?")+s);const o=r.replace(/\\+/g,"%2B");let a=J.getArrayBuffer(o+(s||""),i);const c=a.xhr;a=a.then(n=>{delete this.vt[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))}).catch(t=>{delete this.vt[r],e(t)}),this.vt[r]=c}}xt(t,e,n,r,s){r=r&&r.toLowerCase();const i=n.service;if("b3dm"===r){this.Tt.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{if(t.error)return void s(t);const{content:e,transferables:r}=this.It(t,n);this.Ot(e.gltf),s(null,e,r)}).catch(t=>{s(t)})}else if("pnts"===r){const r=n.transform||Tr;this.At.load(e,t).then(t=>{const{content:e,transferables:i}=this.kt(t,r,n.rootIdx);this.Et(e),s(null,e,i)})}else if("i3dm"===r){const r=n.transform||Tr;this._t.load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:i}=this.Ct(t,r,n.rootIdx);this.Ot(e.gltf),s(null,e,i)})}else if("cmpt"===r){new cn(this.wt,dt,this.i,i.maxTextureSize||1024).load(e,t,0,0,{maxTextureSize:i.maxTextureSize||1024}).then(t=>{const{content:e,transferables:r}=this.Ut(t,n);this.Ft(e),s(null,e,r)}).catch(t=>{s(t)})}else if("gltf"===r){this.nt||(this.nt=Ze());const r=e.substring(0,e.lastIndexOf("/")),o=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t,a=new dt(r,o,{transferable:!0,requestImage:this.wt,decoders:this.nt,supportedFormats:this.i,maxTextureSize:i.maxTextureSize||1024});a.load({skipAttributeTransform:!1}).then(t=>{t.url=e,this.Nt(t,null,n),this.Ot(t),s(null,{magic:"gltf",gltf:t},a.transferables)})}else s(new Error("unsupported tile format: "+r))}Ft(t){t.content?t.content.forEach(t=>{this.Ft(t)}):this.Ot(t.gltf)}Pt(t,e){const n=e.materials[t.material];if(n&&n.extensions&&n.extensions.KHR_materials_unlit)return;if(t.attributes.TANGENT)return;if(t.attributes.TEXCOORD_0&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const s=ar;s.length<t.length/3&&(s.length=t.length/3),s.fill(0,0,t.length/3);const i=void 0===e.length?e:e.length;for(let n=0;n<i/3;n++)void 0===e.length?mr(t,3*n,3*n+1,3*n+2,r,s):mr(t,e[3*n],e[3*n+1],e[3*n+2],r,s);for(let t=0;t<r.length;t+=3){const e=s[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(e,t.indices.array,new Float32Array(e.length));t.attributes.NORMAL={array:n,byteLength:n.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:n.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}Ot(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach(e=>{this.Pt(e,t),e.compressed_int16_params={};const n=e.attributes;for(const t in n)if(Ir[t]&&n[t].array&&n[t].array instanceof Float32Array){const r=this.options.projection;let s=1;"EPSG:4326"!==r&&"EPSG:4490"!==r||"POSITION"!==t||(s=wr,e.compressed_int16_params.compressed_ratio=s);const i=Br(n[t].array,s,n[t].min,n[t].max,t);if(!i)continue;const{array:o,range:a}=i;n[t].array=o,e.compressed_int16_params[t]=a}})}}Et(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(Ir[n]&&e[n].array&&e[n].array instanceof Float32Array){const r=this.options.projection;let s=1;"EPSG:4326"!==r&&"EPSG:4490"!==r||"POSITION"!==n||(s=wr,t.compressed_int16_params.compressed_ratio=s);const{array:i,range:o}=Br(e[n].array,s,e[n].min,e[n].max,n);e[n].array=i,t.compressed_int16_params[n]=o}}Bt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const s={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(s)}return e}St(t,e,n,r,s){return e.capabilities,void s(null,e)}Ut(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},s=[];for(let t=0;t<n.length;t++){const{magic:i}=n[t];if("b3dm"===i){const{content:i,transferables:o}=this.It(n[t],e);Nr(s,o),r.content.push(i)}else if("i3dm"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.Ct(n[t],i,o);Nr(s,c),r.content.push(a)}else if("pnts"===i){const{transform:i,rootIdx:o}=e,{content:a,transferables:c}=this.kt(n[t],i,o);Nr(s,c),r.content.push(a)}else if("cmpt"===i){const{content:i,transferables:o}=this.Ut(n[t],e);Nr(s,o),r.content.push(i)}}return{content:r,transferables:s}}It(t,e){const{gltf:n,transferables:r,featureTable:s}=t;return this.Nt(n,s,e),delete t.transferables,{content:t,transferables:r}}Nt(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;let e=1;const n=[];for(const r in t.meshes){const s=t.meshes[r],{primitives:i}=s;if(i)for(let t=0;t<i.length;t++){const r=i[t].attributes&&i[t].attributes.POSITION;if(!r||!r.array)continue;r.array.buffer.visited||(r.array.buffer.visited=e++);const s=e-1+"-"+(r.byteOffset||0);if(n.indexOf(s)>=0)return!0;n.push(s)}}return!1}(t);this.Dt(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.Rt(t,e,n.upAxis,n.transform)):this.Lt(t,e,n.upAxis,n.transform)}Ct(t,e,r){const{featureTable:s}=t,i=t.i3dm,o=s&&s.RTC_CENTER||[0,0,0];if(s.EAST_NORTH_UP&&!i.NORMAL_UP&&!i.NORMAL_UP_OCT32P){const e=new Float32Array(3*i.POSITION.array.length),r=[],s=[],a=[];pn(i.POSITION,(t,i)=>{y(a,t,o),Xe(a,null,r),n(s,r);!function(t,e){t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8]}(e.subarray(9*i,9*(i+1)),s)}),i.INSTANCE_ROTATION={byteStride:0,byteOffset:0,itemSize:9,componentType:5126,array:e},t.transferables.push(e.buffer)}const a={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ur(i.POSITION.array,3,o,Tr,a);const c=Fr(a),u=l([],c),f=[1/0,1/0,1/0],h=[-1/0,-1/0,-1/0];pn(i.POSITION,t=>{t[0]=t[0]+o[0]-u[0],t[1]=t[1]+o[1]-u[1],t[2]=t[2]+o[2]-u[2],t[0]<f[0]&&(f[0]=t[0]),t[1]<f[1]&&(f[1]=t[1]),t[2]<f[2]&&(f[2]=t[2]),t[0]>h[0]&&(h[0]=t[0]),t[1]>h[1]&&(h[1]=t[1]),t[2]>h[2]&&(h[2]=t[2])}),i.POSITION.min=f,i.POSITION.max=h,e&&v(c,c,e);const d=this.zt(c);t.rtcCenter=u,t.rtcCoord=d,t.rootIdx=r;const m=t.transferables;return delete t.transferables,{content:t,transferables:m}}kt(t,e,n){const{featureTable:r}=t,s=t.pnts,i=r&&r.RTC_CENTER||[0,0,0],o=this.options.projection,a=e&&c(Tr,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Ur(s.POSITION.array,3,i,e,u);const f=Fr(u),h=this.jt(f),y=l([],f),m=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let p=[0,0,0,1];const w=[0,0,0],g=[0,0];pn(s.POSITION,t=>(p[0]=t[0]+i[0],p[1]=t[1]+i[1],p[2]=t[2]+i[2],e&&!a&&(p=v(p,p,e)),0===A(p)?d(w,0,0,-6378137):Me(w,p),Ln(g,w,o),t[0]=g[0]-h[0],t[1]=g[1]-h[1],t[2]=w[2]-h[2],t[0]<m[0]&&(m[0]=t[0]),t[1]<m[1]&&(m[1]=t[1]),t[2]<m[2]&&(m[2]=t[2]),t[0]>b[0]&&(b[0]=t[0]),t[1]>b[1]&&(b[1]=t[1]),t[2]>b[2]&&(b[2]=t[2]),t)),s.POSITION.min=m,s.POSITION.max=b,e&&v(f,f,e);const M=this.zt(f);t.rtcCenter=y,t.projCenter=h,t.rtcCoord=M,t.rootIdx=n;const T=t.transferables;return delete t.transferables,{content:t,transferables:T}}Dt(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],s=n[1],i=n[2],o=n[3];let a=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==s||n[t+2]!==i||n[t+3]!==o){a=!1;break}a&&(e[t].image.color=[r/255,s/255,i/255,o/255],delete e[t].image.array)}}}abortTileLoading(t,e){const n=this.vt[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.vt[t.url],e(null)}Vt(t,e,n,i){const o=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let a=br;"X"===(n=n&&n.toUpperCase())?a=pr:"Z"===n&&(a=Tr),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),o&&(t.extensions.CESIUM_RTC.center=o),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};un(t,t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=r(_r);t.matrices&&Pr(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,a,e),i&&s(e,i,e),Ur(n,u,o||Ar,e,c,t.compressUniforms)});const u=Fr(c);return{rtcCenter:o,modelCenter:u,upAxisTransform:a}}Rt(t,e,n,i){const{modelCenter:o,upAxisTransform:a,rtcCenter:c}=this.Vt(t,e,n),u=l([],o);i&&v(o,o,i),t.extensions.CESIUM_RTC.rtcCoord=this.zt(o),c||(un(t,t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=r(_r);t.matrices&&Pr(n,t.matrices),s(n,a,n);const i=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],a=e[5],c=e[6],u=e[7],f=e[8],h=e[9],l=e[10],d=e[11],y=e[12],m=e[13],b=e[14],p=e[15],w=n*a-r*o,g=n*c-s*o,v=n*u-i*o,M=r*c-s*a,T=r*u-i*a,A=s*u-i*c,_=f*m-h*y,O=f*b-l*y,x=f*p-d*y,S=h*b-l*m,I=h*p-d*m,k=l*p-d*b,E=w*k-g*I+v*S+M*x-T*O+A*_;return E?(E=1/E,t[0]=(a*k-c*I+u*S)*E,t[1]=(s*I-r*k-i*S)*E,t[2]=(m*A-b*T+p*M)*E,t[3]=(l*T-h*A-d*M)*E,t[4]=(c*x-o*k-u*O)*E,t[5]=(n*k-s*x+i*O)*E,t[6]=(b*v-y*A-p*g)*E,t[7]=(f*A-l*v+d*g)*E,t[8]=(o*I-a*x+u*_)*E,t[9]=(r*x-n*I-i*_)*E,t[10]=(y*T-m*v+p*w)*E,t[11]=(h*v-f*T-d*w)*E,t[12]=(a*O-o*S-c*_)*E,t[13]=(n*S-r*O+s*_)*E,t[14]=(m*g-y*M-b*w)*E,t[15]=(f*M-h*g+l*w)*E,t):null}(Or,n),o=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];pn(e,t=>{v(t,t,n),t[0]=t[0]-u[0],t[1]=t[1]-u[1],t[2]=t[2]-u[2],v(t,t,i),t[0]<o[0]&&(o[0]=t[0]),t[1]<o[1]&&(o[1]=t[1]),t[2]<o[2]&&(o[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])}),e.min=o,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}}),t.extensions.CESIUM_RTC.center=u)}Lt(t,e,n,r){const{modelCenter:s,rtcCenter:i}=this.Vt(t,e,n,r),o=this.jt(s);t.extensions.MAPTALKS_RTC.projCenter=o,t.extensions.CESIUM_RTC.rtcCoord=this.zt(s),un(t,e=>{if(e.attributes&&e.attributes.POSITION){e.attributes.NORMAL&&this.qt(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.qt(e.attributes.TANGENT,e.matrices,n);const{newPositions:s}=this.Gt(e.attributes.POSITION,e.matrices,i,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms),{componentType:o}=e.attributes.POSITION;5126!==o&&(e.attributes.POSITION.array=new Float32Array(s))}});for(const e in t.nodes){t.nodes[e].matrix=Tr}}jt(t){0===A(t)?d(xr,0,0,-6378137):Me(xr,t);const e=this.options.projection;Ln(Sr,xr,e);const n=xr[2],r=[];return r[0]=Sr[0],r[1]=Sr[1],r[2]=n,r}qt(t,e,r){let s;s="Y"===r?br:"X"===r?pr:Tr;const i=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],s);if(Pr(i,e),c(i,Tr))return;const o=n([],i),a=[];pn(t,t=>(function(t,e,n){var r=e[0],s=e[1],i=e[2];t[0]=r*n[0]+s*n[3]+i*n[6],t[1]=r*n[1]+s*n[4]+i*n[7],t[2]=r*n[2]+s*n[5]+i*n[8]}(a,t,o),p(a,a),l(t,a),a))}Gt(t,e,n,s,i,o,a){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const u=r([]);Pr(u,e);const f=this.options.projection;i=i&&i.toUpperCase();const h=n;let l=null;"Y"===i?l=br:"X"===i&&(l=pr);let m=[0,0,0,1];const b=[0,0,0],p=[0,0],w=s.projCenter,g=o&&c(Tr,o),M=t.min=t.min||[],T=t.max=t.max||[];d(M,1/0,1/0,1/0),d(T,-1/0,-1/0,-1/0);const _=a||{},{decode_position_min:O,decode_position_normConstant:x}=_;let S=[0,0,0,0],I=1;O&&(S=O),x&&(I=x);const k=[];return pn(t,e=>{if(m[0]=e[0]*I+S[0],m[1]=e[1]*I+S[1],m[2]=e[2]*I+S[2],m=v(m,m,u),l&&(m=v(m,m,l)),h&&y(m,m,h),o&&!g&&(m=v(m,m,o)),0===A(m)?d(b,0,0,-6378137):Me(b,m),Ln(p,b,f),e instanceof Float32Array)e[0]=p[0]-w[0],e[1]=p[1]-w[1],e[2]=b[2]-w[2];else{const n=p[0]-w[0],r=p[1]-w[1],s=b[2]-w[2];5126!==t.componentType&&(k.push(n),k.push(r),k.push(s),k.push(e[3]))}return e[0]<M[0]&&(M[0]=e[0]),e[1]<M[1]&&(M[1]=e[1]),e[2]<M[2]&&(M[2]=e[2]),e[0]>T[0]&&(T[0]=e[0]),e[1]>T[1]&&(T[1]=e[1]),e[2]>T[2]&&(T[2]=e[2]),e}),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:w,newPositions:k}}zt(t){return 0===A(t)?d([],0,0,-6378137):Me([],t)}onRemove(){}}const Cr=[];function Ur(t,e,n,r,s,i){const o=i||{},{decode_position_min:a,decode_position_normConstant:c}=o;let u=[0,0,0,0],f=1;a&&(u=a),c&&(f=c);for(let i=0,o=t.length;i<o;i+=e){const{xmin:o,ymin:a,xmax:c,ymax:h,hmin:l,hmax:m}=s;d(Cr,t[i]*f+u[0],t[i+1]*f+u[1],t[i+2]*f+u[2]),v(Cr,Cr,r);const b=y(Cr,n,Cr);b[0]<o&&(s.xmin=b[0]),b[0]>c&&(s.xmax=b[0]),b[1]<a&&(s.ymin=b[1]),b[1]>h&&(s.ymax=b[1]),e>2&&(b[2]<l&&(s.hmin=b[2]),b[2]>m&&(s.hmax=b[2]))}}function Fr(t){const{xmax:e,ymax:n,xmin:r,ymin:s,hmin:i,hmax:o}=t,a=[(r+e)/2,(s+n)/2,(i+o)/2];return e===-1/0&&(a[0]=0),n===-1/0&&(a[1]=0),o===-1/0&&(a[2]=0),isNaN(a[2])&&(a[2]=0),a}function Nr(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function Pr(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Br(t,e,n,r,s){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let i,o;if(n&&r&&1===e)i=Math.min(...n),o=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);i=e,o=n}return!function(t,e,n,r){for(let s=0;s<t.length;s++){const i=Dr(Rr(t[s],e,n),e,n);if(Math.abs(i-t[s])>kr[r])return!1}return!0}(t,i,o,s)&&kr[s]?null:function(t,e,n){const r=new Int16Array(t.length);for(let s=0;s<t.length;s++)r[s]=Rr(t[s],e,n);return{array:r,range:[e,n]}}(t,i,o)}function Dr(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Rr(t,e,n){const r=2*(t-e)/(n-e)-1,s=Math.max(-1,Math.min(1,r));return s<0?32768*s:32767*s}let Lr=0;class zr{constructor(t){this.workerId=t,this.workers={},this.$t={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},s){if(this.Xt(e,n))return;const i=this.Ht(e,n),o=r.options,a=this.send.bind(this,t);this.workers[i]=new Er(n,o,a,s)}removeLayer({mapId:t,layerId:e},n){const r=this.Xt(t,e),s=this.Ht(t,e);delete this.workers[s],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const s=this.Xt(t,e);s&&s.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const s=this.Xt(t,e);s&&s.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.$t[e];delete this.$t[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,s){const i=s?`${t}-${Lr++}`:null;s&&(this.$t[i]=s),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(i)},r||[])}Ht(t,e){return`${t}-${e}`}Xt(t,e){const n=this.Ht(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new zr(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},(t,n,r)=>{t&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)})},Object.defineProperty(t,"Jt",{value:!0})}';var O$3={exports:{}},_$3={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},M$3={exports:{}},x$3=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},A$1=Array.prototype.concat,I$2=Array.prototype.slice,S$3=M$3.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var s=t[n];x$3(s)?e=A$1.call(e,I$2.call(s)):e.push(s)}return e};S$3.wrap=function(t){return function(){return t(S$3(arguments))}};var E$3=_$3,N$3=M$3.exports,C$1=Object.hasOwnProperty,P$2=Object.create(null);for(var R$3 in E$3)C$1.call(E$3,R$3)&&(P$2[E$3[R$3]]=R$3);var L$3=O$3.exports={to:{},get:{}};function k$3(t,e,n){return Math.min(Math.max(e,t),n)}function B$3(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L$3.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L$3.get.hsl(t),n="hsl";break;case"hwb":e=L$3.get.hwb(t),n="hwb";break;default:e=L$3.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L$3.get.rgb=function(t){if(!t)return null;var e,n,r,s=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var i=2*n;s[n]=parseInt(e.slice(i,i+2),16)}r&&(s[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)s[n]=parseInt(e[n]+e[n],16);r&&(s[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)s[n]=parseInt(e[n+1],0);e[4]&&(s[3]=e[5]?.01*parseFloat(e[4]):parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:C$1.call(E$3,e[1])?((s=E$3[e[1]])[3]=1,s):null:null;for(n=0;n<3;n++)s[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(s[3]=e[5]?.01*parseFloat(e[4]):parseFloat(e[4]))}for(n=0;n<3;n++)s[n]=k$3(s[n],0,255);return s[3]=k$3(s[3],0,1),s},L$3.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,k$3(parseFloat(e[2]),0,100),k$3(parseFloat(e[3]),0,100),k$3(isNaN(n)?1:n,0,1)]}return null},L$3.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,k$3(parseFloat(e[2]),0,100),k$3(parseFloat(e[3]),0,100),k$3(isNaN(n)?1:n,0,1)]}return null},L$3.to.hex=function(){var t=N$3(arguments);return"#"+B$3(t[0])+B$3(t[1])+B$3(t[2])+(t[3]<1?B$3(Math.round(255*t[3])):"")},L$3.to.rgb=function(){var t=N$3(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L$3.to.rgb.percent=function(){var t=N$3(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L$3.to.hsl=function(){var t=N$3(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L$3.to.hwb=function(){var t=N$3(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L$3.to.keyword=function(t){return P$2[t.slice(0,3)]};var U$3={exports:{}},F$3=_$3,D$3={};for(var z$3 in F$3)F$3.hasOwnProperty(z$3)&&(D$3[F$3[z$3]]=z$3);var j$3=U$3.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var G$3 in j$3)if(j$3.hasOwnProperty(G$3)){if(!("channels"in j$3[G$3]))throw new Error("missing channels property: "+G$3);if(!("labels"in j$3[G$3]))throw new Error("missing channel labels property: "+G$3);if(j$3[G$3].labels.length!==j$3[G$3].channels)throw new Error("channel and label counts mismatch: "+G$3);var H$3=j$3[G$3].channels,V$3=j$3[G$3].labels;delete j$3[G$3].channels,delete j$3[G$3].labels,Object.defineProperty(j$3[G$3],"channels",{value:H$3}),Object.defineProperty(j$3[G$3],"labels",{value:V$3})}j$3.rgb.hsl=function(t){var e,n,r=t[0]/255,s=t[1]/255,i=t[2]/255,o=Math.min(r,s,i),a=Math.max(r,s,i),c=a-o;return a===o?e=0:r===a?e=(s-i)/c:s===a?e=2+(i-r)/c:i===a&&(e=4+(r-s)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},j$3.rgb.hsv=function(t){var e,n,r,s,i,o=t[0]/255,a=t[1]/255,c=t[2]/255,h=Math.max(o,a,c),u=h-Math.min(o,a,c),l=function(t){return(h-t)/6/u+.5};return 0===u?s=i=0:(i=u/h,e=l(o),n=l(a),r=l(c),o===h?s=r-n:a===h?s=1/3+e-r:c===h&&(s=2/3+n-e),s<0?s+=1:s>1&&(s-=1)),[360*s,100*i,100*h]},j$3.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[j$3.rgb.hsl(t)[0],1/255*Math.min(e,Math.min(n,r))*100,100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},j$3.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-s)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-s-e)/(1-e)||0),100*e]},j$3.rgb.keyword=function(t){var e=D$3[t];if(e)return e;var n,r,s,i=1/0;for(var o in F$3)if(F$3.hasOwnProperty(o)){var c=(r=t,s=F$3[o],Math.pow(r[0]-s[0],2)+Math.pow(r[1]-s[1],2)+Math.pow(r[2]-s[2],2));c<i&&(i=c,n=o)}return n},j$3.keyword.rgb=function(t){return F$3[t]},j$3.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},j$3.rgb.lab=function(t){var e=j$3.rgb.xyz(t),n=e[0],r=e[1],s=e[2];return r/=100,s/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(s=s>.008856?Math.pow(s,1/3):7.787*s+16/116))]},j$3.hsl.rgb=function(t){var e,n,r,s,i,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[i=255*c,i,i];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),s=[0,0,0];for(var h=0;h<3;h++)(r=o+1/3*-(h-1))<0&&r++,r>1&&r--,s[h]=255*(i=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e);return s},j$3.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,s=n,i=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,s*=i<=1?i:2-i,[e,100*(0===r?2*s/(i+s):2*n/(r+n)),(r+n)/2*100]},j$3.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,s=Math.floor(e)%6,i=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*i),c=255*r*(1-n*(1-i));switch(r*=255,s){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},j$3.hsv.hsl=function(t){var e,n,r,s=t[0],i=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-i)*o,n=i*a,[s,100*(n=(n/=(e=(2-i)*a)<=1?e:2-e)||0),100*(r/=2)]},j$3.hwb.rgb=function(t){var e,n,r,s,i,o,a,c=t[0]/360,h=t[1]/100,u=t[2]/100,l=h+u;switch(l>1&&(h/=l,u/=l),r=6*c-(e=Math.floor(6*c)),0!=(1&e)&&(r=1-r),s=h+r*((n=1-u)-h),e){default:case 6:case 0:i=n,o=s,a=h;break;case 1:i=s,o=n,a=h;break;case 2:i=h,o=n,a=s;break;case 3:i=h,o=s,a=n;break;case 4:i=s,o=h,a=n;break;case 5:i=n,o=h,a=s}return[255*i,255*o,255*a]},j$3.cmyk.rgb=function(t){var n=t[1]/100,r=t[2]/100,s=t[3]/100;return[255*(1-Math.min(1,t[0]/100*(1-s)+s)),255*(1-Math.min(1,n*(1-s)+s)),255*(1-Math.min(1,r*(1-s)+s))]},j$3.xyz.rgb=function(t){var e,n,r,s=t[0]/100,i=t[1]/100,o=t[2]/100;return n=-.9689*s+1.8758*i+.0415*o,r=.0557*s+-.204*i+1.057*o,e=(e=3.2406*s+-1.5372*i+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},j$3.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},j$3.lab.xyz=function(t){var e,n,r;e=t[1]/500+(n=(t[0]+16)/116),r=n-t[2]/200;var i=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=i>.008856?i:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},j$3.lab.lch=function(t){var e,n=t[0],r=t[1],s=t[2];return(e=360*Math.atan2(s,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+s*s),e]},j$3.lch.lab=function(t){var e,r=t[1];return e=t[2]/360*2*Math.PI,[t[0],r*Math.cos(e),r*Math.sin(e)]},j$3.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],s=1 in arguments?arguments[1]:j$3.rgb.hsv(t)[2];if(0===(s=Math.round(s/50)))return 30;var i=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===s&&(i+=60),i},j$3.hsv.ansi16=function(t){return j$3.rgb.ansi16(j$3.hsv.rgb(t),t[2])},j$3.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},j$3.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},j$3.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},j$3.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},j$3.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},j$3.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,s=t[2]/255,i=Math.max(Math.max(n,r),s),o=Math.min(Math.min(n,r),s),a=i-o;return e=a<=0?0:i===n?(r-s)/a%6:i===r?2+(s-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},j$3.hsl.hcg=function(t){var r,e=t[1]/100,n=t[2]/100,s=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(s=(n-.5*r)/(1-r)),[t[0],100*r,100*s]},j$3.hsv.hcg=function(t){var n=t[2]/100,r=t[1]/100*n,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},j$3.hcg.rgb=function(t){var n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var s,i=[0,0,0],o=t[0]/360%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:i[0]=1,i[1]=a,i[2]=0;break;case 1:i[0]=c,i[1]=1,i[2]=0;break;case 2:i[0]=0,i[1]=1,i[2]=a;break;case 3:i[0]=0,i[1]=c,i[2]=1;break;case 4:i[0]=a,i[1]=0,i[2]=1;break;default:i[0]=1,i[1]=0,i[2]=c}return[255*(n*i[0]+(s=(1-n)*r)),255*(n*i[1]+s),255*(n*i[2]+s)]},j$3.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},j$3.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},j$3.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},j$3.hwb.hcg=function(t){var n=1-t[2]/100,r=n-t[1]/100,s=0;return r<1&&(s=(n-r)/(1-r)),[t[0],100*r,100*s]},j$3.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},j$3.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},j$3.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},j$3.gray.hsl=j$3.gray.hsv=function(t){return[0,0,t[0]]},j$3.gray.hwb=function(t){return[0,100,t[0]]},j$3.gray.cmyk=function(t){return[0,0,0,t[0]]},j$3.gray.lab=function(t){return[t[0],0,0]},j$3.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},j$3.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var q$3=U$3.exports;function X$3(t,e){return function(n){return e(t(n))}}function J$3(t,e){for(var n=[e[t].parent,t],r=q$3[e[t].parent][t],s=e[t].parent;e[s].parent;)n.unshift(e[s].parent),r=X$3(q$3[e[s].parent][s],r),s=e[s].parent;return r.conversion=n,r}var Q$3=U$3.exports,K$3=function(t){for(var e=function(t){var e=function(){for(var t={},e=Object.keys(q$3),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),s=Object.keys(q$3[r]),i=s.length,o=0;o<i;o++){var a=s[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}(t),n={},r=Object.keys(e),s=r.length,i=0;i<s;i++){var o=r[i];null!==e[o].parent&&(n[o]=J$3(o,e))}return n},Z$3={};Object.keys(Q$3).forEach((function(t){Z$3[t]={},Object.defineProperty(Z$3[t],"channels",{value:Q$3[t].channels}),Object.defineProperty(Z$3[t],"labels",{value:Q$3[t].labels});var e=K$3(t);Object.keys(e).forEach((function(n){var r=e[n];Z$3[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,s=0;s<r;s++)n[s]=Math.round(n[s]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),Z$3[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var W$3=O$3.exports,tt$2=Z$3,et$2=[].slice,nt$2=["keyword","gray","hex"],rt$2={};Object.keys(tt$2).forEach((function(t){rt$2[et$2.call(tt$2[t].labels).sort().join("")]=t}));var st$2={};function it$2(t,e){if(!(this instanceof it$2))return new it$2(t,e);if(e&&e in nt$2&&(e=null),e&&!(e in tt$2))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof it$2)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var s=W$3.get(t);if(null===s)throw new Error("Unable to parse color from string: "+t);this.model=s.model,this.color=s.value.slice(0,r=tt$2[this.model].channels),this.valpha="number"==typeof s.value[r]?s.value[r]:1}else if(t.length){this.model=e||"rgb";var i=et$2.call(t,0,r=tt$2[this.model].channels);this.color=ht$2(i,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in rt$2))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=rt$2[a];var c=tt$2[this.model].labels,h=[];for(n=0;n<c.length;n++)h.push(t[c[n]]);this.color=ht$2(h)}if(st$2[this.model])for(r=tt$2[this.model].channels,n=0;n<r;n++){var u=st$2[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ot$2(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st$2[t]||(st$2[t]=[]))[e]=n})),t=t[0],function(r){var s;return arguments.length?(n&&(r=n(r)),(s=this[t]()).color[e]=r,s):(s=this[t]().color[e],n&&(s=n(s)),s)}}function at$2(t){return function(e){return Math.max(0,Math.min(t,e))}}function ct$2(t){return Array.isArray(t)?t:[t]}function ht$2(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}it$2.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in W$3.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return W$3.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return W$3.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=tt$2[this.model].channels,n=tt$2[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new it$2(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new it$2(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ot$2("rgb",0,at$2(255)),green:ot$2("rgb",1,at$2(255)),blue:ot$2("rgb",2,at$2(255)),hue:ot$2(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ot$2("hsl",1,at$2(100)),lightness:ot$2("hsl",2,at$2(100)),saturationv:ot$2("hsv",1,at$2(100)),value:ot$2("hsv",2,at$2(100)),chroma:ot$2("hcg",1,at$2(100)),gray:ot$2("hcg",2,at$2(100)),white:ot$2("hwb",1,at$2(100)),wblack:ot$2("hwb",2,at$2(100)),cyan:ot$2("cmyk",0,at$2(100)),magenta:ot$2("cmyk",1,at$2(100)),yellow:ot$2("cmyk",2,at$2(100)),black:ot$2("cmyk",3,at$2(100)),x:ot$2("xyz",0,at$2(100)),y:ot$2("xyz",1,at$2(100)),z:ot$2("xyz",2,at$2(100)),l:ot$2("lab",0,at$2(100)),a:ot$2("lab",1),b:ot$2("lab",2),keyword:function(t){return arguments.length?new it$2(t):tt$2[this.model].keyword(this.color)},hex:function(t){return arguments.length?new it$2(t):W$3.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return it$2.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),s=void 0===e?.5:e,i=2*s-1,o=n.alpha()-r.alpha(),a=((i*o==-1?i:(i+o)/(1+i*o))+1)/2,c=1-a;return it$2.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*s+r.alpha()*(1-s))}},Object.keys(tt$2).forEach((function(t){if(-1===nt$2.indexOf(t)){var e=tt$2[t].channels;it$2.prototype[t]=function(){if(this.model===t)return new it$2(this);if(arguments.length)return new it$2(arguments,t);var n="number"==typeof arguments[e]?e:this.valpha;return new it$2(ct$2(tt$2[this.model][t].raw(this.color)).concat(n),t)},it$2[t]=function(n){return"number"==typeof n&&(n=ht$2(et$2.call(arguments),e)),new it$2(n,t)}}}));var ut$2=it$2;function lt$2(t){return null==t}function ft$2(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function dt$2(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function mt$2(t){return"object"==typeof t&&!!t}function pt$2(t){return"number"==typeof t&&!isNaN(t)}function bt$2(t){return t*Math.PI/180}function gt$2(t){return t/Math.PI*180}function yt$2(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function wt$2(t){return Math.sign?Math.sign(t):0==(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const vt$2=[1,1,1,1,2,2,3,0];function Tt$2(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=vt$2[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}function Ot$2(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function _t$2(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function Mt$2(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function xt$2(t){return 0===t.indexOf("data:")}function At$2(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),s=r.length,i=new Uint8Array(s);for(let t=0;t<s;t++)i[t]=r.charCodeAt(t);return i.buffer}function It$2(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const St$2={};function Et$2(t,e){if(!Array.isArray(e)){e=St$2[e]=St$2[e]||ut$2(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Nt$2=Object.freeze({__proto__:null,isNil:lt$2,extend:ft$2,isFunction:dt$2,isObject:mt$2,isNumber:pt$2,toRadian:bt$2,toDegree:gt$2,getAbsoluteURL:yt$2,sign:wt$2,stringFromUTF8Array:Tt$2,setColumn3:Ot$2,flatArr:_t$2,getBatchIdArrayType:Mt$2,isBase64:xt$2,base64URLToArrayBuffer:At$2,pushIn:It$2,normalizeColor:Et$2});function Ct$2(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Pt$2(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Rt$2="undefined"==typeof document?null:document.createElement("canvas");class Lt$2 extends t__namespace.worker.Actor{constructor(t,e){super(t),this.mapId=e}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);this.send({mapId:this.mapId,layerId:t,command:"loadTile",params:e},r,n)}abortTileLoading(t,e,n){this.broadcast({mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}},null,n)}addLayer(t,e,n){this.broadcast({actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}},null,n)}removeLayer(t,e){this.broadcast({mapId:this.mapId,layerId:t,command:"removeLayer"},null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!Rt$2)return void e(new Error("There is no canvas to draw image!"));const t=function(t){if(kt$2(t.width)&&kt$2(t.height))return t;let e=t.width,n=t.height;kt$2(e)||(e=Bt$2(e)),kt$2(n)||(n=Bt$2(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const s=t.src,i=s.lastIndexOf("/")+1,o=s.substring(i);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);Rt$2.width=t.width,Rt$2.height=t.height;const r=Rt$2.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const s=r.getImageData(0,0,t.width,t.height),i={width:t.width,height:t.height,data:new Uint8Array(s.data)};e(null,i,[i.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function kt$2(t){return 0==(t&t-1)&&0!==t}function Bt$2(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function Ut$1(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,s=r.length;n<s;n++){Vt$1(r[n],[],t,e)}}}const Ft$2=[],Dt$2=[],zt$1=[],jt$1=[0,0,0],Gt$1=identity$1([]),Ht$1=[1,1,1];function Vt$1(t,e,n,r){const s=e.slice(0);if(t.matrix)s.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=fromTranslation$1(Ft$2,t.translation||jt$1),n=fromQuat(Dt$2,t.rotation||Gt$1),r=fromScaling(zt$1,t.scale||Ht$1);multiply$5(r,n,r);const i=multiply$5([],e,r);s.push(i)}if(t.children&&t.children.length)for(let e=0,i=t.children.length;e<i;e++)Vt$1(t.children[e],s,n,r);if(void 0!==t.mesh){const e=t.mesh,i=n.meshes[e];if(i){const t=s.slice(0),o=i.primitives;for(let s=0,i=o.length;s<i;s++){const i=o[s];i&&(i.matrices=t,r(i,e,s,n))}}}}function qt$1(t,e,n){let{byteOffset:r,byteStride:s}=e;const{componentType:i,itemSize:o}=e,a=e.array.buffer,c=i?X$8.getTypedArrayCtor(i):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,s=s||0,!s||s===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}s||(s=o*c.BYTES_PER_ELEMENT);const h=new Uint8Array(a,s*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(h),t}function $t$1(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Xt$1="#include <gl2_vert>\n\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\n\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\n\nconst float SHIFT_LEFT_11 = 2048.0;\n\nconst float SHIFT_LEFT_5 = 32.0;\n\nconst float NORMALIZE_6 = 1.0 / 64.0;\n\nconst float NORMALIZE_5 = 1.0 / 32.0;\n\n\n\n#ifdef HAS_POSITION\n\n    attribute vec3 POSITION;\n\n#endif\n\n\n\n#if defined(HAS_RGB)\n\n    attribute vec3 RGB;\n\n#elif defined(HAS_RGBA)\n\n    attribute vec4 RGBA;\n\n#elif defined(HAS_RGB565)\n\n    attribute float RGB565;\n\n#endif\n\n\n\nuniform vec4 pointColor;\n\nuniform float pointSize;\n\n\n\nuniform mat4 projViewModelMatrix;\n\nuniform float pointOpacity;\n\n\n\nvarying vec4 vColor;\n\n\n\n#ifdef HAS_NORMAL\n\n    #ifdef HAS_NORMAL_OCT16P\n\n        attribute vec2 NORMAL_OCT16P;\n\n        float signNotZero(float value) {\n\n            return value >= 0.0 ? 1.0 : -1.0;\n\n        }\n\n        vec2 signNotZero(vec2 value) {\n\n            return vec2(signNotZero(value.x), signNotZero(value.y));\n\n        }\n\n        vec3 octDecode(vec2 encoded, float range) {\n\n            if (encoded.x == 0.0 && encoded.y == 0.0) {\n\n                return vec3(0.0, 0.0, 0.0);\n\n            }\n\n            encoded = encoded / range * 2.0 - 1.0;\n\n            vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n\n            if (v.z < 0.0) {\n\n                v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n\n            }\n\n            return normalize(v);\n\n        }\n\n        vec3 octDecode(vec2 encoded) {\n\n            return octDecode(encoded, 255.0);\n\n        }\n\n    #else\n\n        attribute vec3 NORMAL;\n\n    #endif\n\n    uniform vec3 lightDir;\n\n    uniform mat3 modelNormalMatrix;\n\n    uniform mat4 positionMatrix;\n\n    float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n\n        return max(dot(-lightDir, normal), 0.0);\n\n    }\n\n#endif\n\n#ifdef PICKING_MODE\n\n    #include <fbo_picking_vert>\n\n#endif\n\n#include <draco_decode_vert>\n\nvoid main() {\n\n    #ifdef HAS_POSITION\n\n        vec3 localPos = decode_getPosition(POSITION);\n\n    #endif\n\n    gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n\n    gl_PointSize = pointSize;\n\n\n\n    #ifdef PICKING_MODE\n\n        fbo_picking_setData(gl_Position.w, true);\n\n    #else\n\n        #if defined(HAS_RGB)\n\n            vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n\n        #elif defined(HAS_RGBA)\n\n            vColor = RGBA / 255.0 * pointOpacity;\n\n        #elif defined(HAS_RGB565)\n\n            float compressed = RGB565;\n\n            float r = floor(compressed * SHIFT_RIGHT_11);\n\n            compressed -= r * SHIFT_LEFT_11;\n\n            float g = floor(compressed * SHIFT_RIGHT_5);\n\n            compressed -= g * SHIFT_LEFT_5;\n\n            float b = compressed;\n\n            vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n\n            vColor = vec4(rgb, 1.0);\n\n        #else\n\n            vColor = pointColor;\n\n        #endif\n\n\n\n        #ifdef HAS_NORMAL\n\n            mat3 positionNormalMatrix = mat3(positionMatrix);\n\n            mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n\n            #ifdef HAS_NORMAL_OCT16P\n\n                vec3 localNormal = octDecode(NORMAL_OCT16P);\n\n            #else\n\n                vec3 localNormal = NORMAL;\n\n            #endif\n\n            vec3 normal = normalize(normalMatrix * localNormal);\n\n            float colorStrength = getLambertDiffuse(lightDir, normal);\n\n            colorStrength = max(colorStrength, 0.5);\n\n            vColor *= colorStrength;\n\n        #endif\n\n    #endif\n\n\n\n\n\n\n\n\n\n}\n\n";const Jt$1=new Array(3),Qt$1=new Array(3),Kt$1=[40680631590769,40680631590769,40408299984661.445];function Zt$1(t,e,n,r){const s=Kt$1,i=Math.cos(n);Jt$1[0]=i*Math.cos(e),Jt$1[1]=i*Math.sin(e),Jt$1[2]=Math.sin(n),ae$1(Jt$1,Jt$1),multiply$4(Qt$1,s,Jt$1);const o=Math.sqrt(dot$4(Jt$1,Qt$1));var a,c,h;return(a=Qt$1)[0]=(c=Qt$1)[0]/(h=o),a[1]=c[1]/h,a[2]=c[2]/h,scale$4(Jt$1,Jt$1,r),add$4(t,Qt$1,Jt$1)}const Yt$1=[1/6378137,1/6378137,1/6356752.314245179],Wt$1=[1/40680631590769,1/40680631590769,1/40408299984661.445],te$1=new Array(3),ee$1=new Array(3),ne$1=new Array(3);function re$1(t,e){const n=Wt$1,r=function(t,e,n,r,s){const i=e[0],o=e[1],a=e[2],c=n[0],h=n[1],u=n[2],l=i*i*c*c,f=o*o*h*h,d=a*a*u*u,m=l+f+d,p=Math.sqrt(1/m),b=scale$4(se$1,e,p);if(m<.1)return isFinite(p)?b:void 0;const g=r[0],y=r[1],v=r[2],T=ie$1;T[0]=b[0]*g*2,T[1]=b[1]*y*2,T[2]=b[2]*v*2;let O,_,M,x,A,I,S,E,N,C,P,R=(1-p)*oe$1(e)/(.5*oe$1(T)),L=0;do{R-=L,M=1/(1+R*g),x=1/(1+R*y),A=1/(1+R*v),I=M*M,S=x*x,E=A*A,N=I*M,C=S*x,P=E*A,O=l*I+f*S+d*E-1,_=l*N*g+f*C*y+d*P*v,L=O/(-2*_)}while(Math.abs(O)>1e-12);return t[0]=i*M,t[1]=o*x,t[2]=a*A,t}(te$1,e,Yt$1,n);let s=mul$4(ee$1,r,n);s=ae$1(s,s);const i=sub$2(ne$1,e,r),o=Math.atan2(s[1],s[0]),a=Math.asin(s[2]),c=wt$2(dot$4(i,e))*oe$1(i);return t[0]=gt$2(o),t[1]=gt$2(a),t[2]=c,t}const se$1=new Array(3),ie$1=new Array(3);function oe$1(t){return length$4(t)}function ae$1(t,e){const n=e[0],r=e[1],s=e[2];let i=n*n+r*r+s*s;return i>0&&(i=Math.sqrt(i),t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t}function ce$1(t,e){return multiply$4(e,t,Wt$1),normalize$4(e,e)}function he$1(t,e){const n=t[0],r=t[1],s=Math.cos(r),i=s*Math.cos(n),o=s*Math.sin(n),a=Math.sin(r);return e.x=i,e.y=o,e.z=a,normalize$4(e,e)}var ue$1=Object.freeze({__proto__:null,radianToCartesian3:Zt$1,cartesian3ToDegree:re$1,normalizeCartesian:ae$1,geodeticSurfaceNormal:ce$1,geodeticSurfaceNormalCartographic:he$1});function le$1(t,e,n,r){n=n||0,r=r||n;const s=Math.abs(t-e);return s<=r||s<=n*Math.max(Math.abs(t),Math.abs(e))}function fe$1(t,e){let n="";for(let r=0;r<4;r++){const s=t.getUint8(e+r);n+=String.fromCharCode(s)}return n}const de$1="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function me$1(t,e,n){const r=new Uint8Array(t,e,n);return de$1?JSON.parse(de$1.decode(r)):JSON.parse(Tt$2(r))}function pe$1(t,e,n){const r=new Uint8Array(t,e,n);return de$1?JSON.parse(de$1.decode(r)):JSON.parse(Tt$2(r))}function be$1(t,e,n){return{offset:e,byteLength:n}}function ge$1(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a,type:c}=_e$1(i||"UNSIGNED_SHORT"),h=Te$1(o);return{byteStride:0,byteOffset:s+n,itemSize:h,count:r*h,componentType:c,array:new a(e,n+s,r*h)}}function ye$1(t,e,n,r){const s=ge$1(t,e,n,r);return s.array.buffer.byteLength!==e.byteLength&&(s.array=s.array.slice()),s}function we$1(t,e,n,r){const{byteOffset:s,componentType:i,type:o}=t,{ctor:a}=_e$1(i||"UNSIGNED_SHORT"),c=Te$1(o),h=new a(e,s,n*c);return 1===c?h[r]:h.subarray(r*c,r*c+c)}const ve$1={SCALAR:1,VEC2:2,VEC3:3,VEC4:4};function Te$1(t){return t?ve$1[t]:1}const Oe$1={BYTE:{ctor:Int8Array,type:5120,name:"Int8Array"},UNSIGNED_BYTE:{ctor:Uint8Array,type:5121,name:"Uint8Array"},SHORT:{ctor:Int16Array,type:5122,name:"Int16Array"},UNSIGNED_SHORT:{ctor:Uint16Array,type:5123,name:"Uint16Array"},INT:{ctor:Int32Array,type:5124,name:"Int32Array"},UNSIGNED_INT:{ctor:Uint32Array,type:5125,name:"Uint32Array"},FLOAT:{ctor:Float32Array,type:5126,name:"Float32Array"},DOUBLE:{ctor:Float64Array,type:5126,name:"Float64Array"}};function _e$1(t){return Oe$1[t]}function Me$1(t){for(const e in Oe$1)if(t===Oe$1[e].ctor)return Oe$1[e].type;throw new Error("unrecognized ctor:"+t)}function xe$1(t,e,n,r){const s=t,i=e.length/3;for(let t=0;t<i;t++)s[3*t]=e[3*t]/65535*r[0]+n[0],s[3*t+1]=e[3*t+1]/65535*r[1]+n[1],s[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return s}function Ae$1(t,e,n){const r=t.getUint32(12,!0),s=t.getUint32(16,!0),i=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,h={},u={},l=null;r>0&&(h=me$1(a,e,r),e+=r),s>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,s),e+=s),i>0&&(u=pe$1(a,e,i),e+=i);const f=be$1(0,e,o);return l=a.slice(f.offset,f.offset+f.byteLength),n.push(l),{featureTable:h,featureTableBin:c,batchTable:u,batchTableBin:l}}const Ie$1={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},Se$1={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Ee$1={},Ne$1={east:[],north:[],up:[],west:[],south:[],down:[]};let Ce$1=[],Pe$1=[],Re$1=[];const Le$1=[0,0,0];function ke$1(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const Be$1=function(t,e){const n=Ie$1[t][e];let r;const s=t+e;return Ee$1[s]?r=Ee$1[s]:(r=function(r,s,i){if(equals$5(r,Le$1))copy$4(Ce$1,Se$1[t]),copy$4(Pe$1,Se$1[e]),copy$4(Re$1,Se$1[n]);else if(le$1(r[0],0,1e-14)&&le$1(r[1],0,1e-14)){const s=wt$2(r[2]);copy$4(Ce$1,Se$1[t]),copy$4(Pe$1,Se$1[e]),scale$4(Pe$1,Pe$1,s),copy$4(Re$1,Se$1[n]),"east"!==n&&"west"!==n&&scale$4(Re$1,Re$1,s)}else{ce$1(r,Ne$1.up);const s=Ne$1.up,i=Ne$1.east;i[0]=-r[1],i[1]=r[0],i[2]=0,normalize$4(Ne$1.east,i),cross$1(Ne$1.north,s,i),scale$4(Ne$1.down,Ne$1.up,-1),scale$4(Ne$1.west,Ne$1.east,-1),scale$4(Ne$1.south,Ne$1.north,-1),Ce$1=Ne$1[t],Pe$1=Ne$1[e],Re$1=Ne$1[n]}return i[0]=Ce$1[0],i[1]=Ce$1[1],i[2]=Ce$1[2],i[3]=0,i[4]=Pe$1[0],i[5]=Pe$1[1],i[6]=Pe$1[2],i[7]=0,i[8]=Re$1[0],i[9]=Re$1[1],i[10]=Re$1[2],i[11]=0,i[12]=r[0],i[13]=r[1],i[14]=r[2],i[15]=1,i},Ee$1[s]=r),r}("east","north"),Ue$1=[],Fe$1=[],De$1=[],ze$1=[],je$1=[],Ge$1=[],He$1=[],Ve$1={x:0,y:0},qe$1={x:0,y:0},$e$1=Math.PI/180;let Xe$1;const Je$1={width:100,height:10};class Ke$1{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,s=t.length;e<s;e++){const s=t[e][0];n=Math.min(s,n),r=Math.max(s,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},Je$1,e),this.t()}getImageData(){return this.imgData}t(){const t=function(){if(!Xe$1){const{width:t,height:e}=Je$1;OffscreenCanvas?Xe$1=new OffscreenCanvas(t,e):(Xe$1=document.createElement("canvas"),Xe$1.width=t,Xe$1.height=e)}return Xe$1}(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const s=r.createLinearGradient(0,0,t.width,0),{colors:i,valueOffset:o}=this;for(let t=0,e=i.length;t<e;t++){const[e,n]=i[t];s.addColorStop((e-this.min)/o,n)}r.fillStyle=s,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var Ze$1;function Ye$1(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function We$1(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function tn$1(t,e){for(var n=void 0!==t.base?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:function t(e,n,r,s,i,o){return"function"==typeof i?function(){var a=i.apply(void 0,arguments),c=o.apply(void 0,arguments);return t(e,n,r,s,a,c)}:i.length?function(t,e,n,r,s,i){var o=[];for(let a=0;a<s.length;a++)o[a]=sn$1(t,e,n,r,s[a],i[a]);return o}(e,n,r,s,i,o):sn$1(e,n,r,s,i,o)}(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(Ze$1=new Map);const en$1={width:100,height:1};function nn$1(t,e){const n=t.stops;if(n&&n.length>1){let t;if(Ze$1){const e=JSON.stringify(n);if(!Ze$1.has(e)){const t=new Ke$1(n,en$1);Ze$1.set(e,t)}t=Ze$1.get(e)}else t=new Ke$1(n,en$1);const[r,s,i,o]=t.getColor(e);return[r/255,s/255,i/255,o/255]}return n&&1===n.length?n[0][1]:null}function rn$1(t,e){return r=t.default,void 0!==(n=e)?n:void 0!==r?r:null;var n,r}function sn$1(t,e,n,r,s,i){var o,a=r-n,c=t-n;return s*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+i*o}function on$1(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type)}function an$1(t){return function t(e,n){if(!on$1(e))return function(){return e};let r=!0,s=!0;const i=(e=JSON.parse(JSON.stringify(e))).stops;if(i)for(let e=0;e<i.length;e++)if(on$1(i[e][1])){const o=t(i[e][1],n);r=r&&o.isZoomConstant,s=s&&o.isFeatureConstant,i[e]=[i[e][0],o]}const o=function t(e,n){var r,s,i;if(on$1(e)){var o,a=e.stops&&"object"==typeof e.stops[0][0],h=a||!(a||void 0!==e.property),u=e.type||n||"exponential";if("exponential"===u)o=tn$1;else if("interval"===u)o=We$1;else if("categorical"===u)o=Ye$1;else if("identity"===u)o=rn$1;else{if("color-interpolate"!==u)throw new Error('Unknown function type "'+u+'"');o=nn$1}if(a){var l={},f=[];for(let t=0;t<e.stops.length;t++){var d=e.stops[t];void 0===l[d[0].zoom]&&(l[d[0].zoom]={zoom:d[0].zoom,type:e.type,property:e.property,default:e.default,stops:[]}),l[d[0].zoom].stops.push([d[0].value,d[1]])}for(let e in l)f.push([l[e].zoom,t(l[e])]);r=function(t,n){const r=tn$1({stops:f,base:e.base},t)(t,n);return"function"==typeof r?r(t,n):r},s=!1,i=!1}else h?(r=function(t){const n=o(e,t);return"function"==typeof n?n(t):n},s=!0,i=!1):(r=function(t,n){const r=o(e,n?n[e.property]:null);return"function"==typeof r?r(t,n):r},s=!1,i=!0)}else r=function(){return e},s=!0,i=!0;return r.isZoomConstant=i,r.isFeatureConstant=s,r}(e,n);return o.isZoomConstant=r&&o.isZoomConstant,o.isFeatureConstant=s&&o.isFeatureConstant,o}(t,"exponential")}const{getTextureMagFilter:cn$1,getTextureMinFilter:hn$1,getTextureWrap:un$1,getMaterialType:ln$1,getMaterialFormat:fn$1,getPrimitive:dn$1,getUniqueREGLBuffer:mn$1}=_e$5,pn$1=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],bn$1=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:gn$1,logoutIBLResOnCanvas:yn$1,getIBLResOnCanvas:wn$1,getPBRUniforms:vn$1}=fi$4.PBRUtils,Tn$1={factor:0,units:0},On$1=[1,1,1,1],_n$1=[0,0,0],Mn$1={specularStrength:0,materialShininess:1},xn$1=[1,1,1],An$1=identity$2([]),In$1=[0,0],Sn$1=t=>t.material instanceof Ie$5,En$1=t=>t.material instanceof fi$4.StandardMaterial,Nn$1=[],Cn$1=new t__namespace.Coordinate(0,0),Pn$1=new t__namespace.Point(0,0),Rn$1=new t__namespace.Point(0,0),Ln$1=new t__namespace.Point(0,0),kn$1=[],Bn$1=[],Un$1=[],Fn$1=[],Dn$1=[],zn$1=[],jn$1=[],Gn$1=[0,0,0],Hn$1=[],Vn$1=[],qn$1={POSITION:"POSITION",NORMAL:"NORMAL",TEXCOORD_0:"TEXCOORD_0",TEXCOORD_1:"TEXCOORD_1",COLOR_0:"COLOR_0",TANGENT:"TANGENT",_BATCHID:"_BATCHID"},$n$1=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Xn$1=function(t,e){const n=2*Math.PI/t,r=[],s=[];for(let s=0;s<=t;s++){const t=1*Math.cos(n*s),i=1*Math.sin(n*s),o=0;r[3*s]=t,r[3*s+1]=i,r[3*s+2]=o}for(let s=t;s<=200;s++){const t=1*Math.cos(n*s),i=1*Math.sin(n*s);r[3*s]=0,r[3*s+1]=t,r[3*s+2]=i}for(let s=200;s<=300;s++){const t=1*Math.cos(n*s),i=1*Math.sin(n*s),o=0;r[3*s]=t,r[3*s+1]=o,r[3*s+2]=i}const i=r.length/3-1;for(let e=0;e<i;e++)99!==e&&199!==e&&(s[2*e]=e,s[2*e+1]=e+1);return r.push(0,0,0),r.push(1,0,0),r.push(0,1,0),r.push(0,0,1),s.push(i+1,i+2),s.push(i+1,i+3),s.push(i+1,i+4),{vertices:r,indices:s}}
/*!
	 * @maptalks/gl v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.com
	 */(100),Jn$1=[0,0,0,1],Qn$1=[1,1,1];class Kn$1{constructor(e,r){this.s=r,this.i=r.getRenderer().canvas,this.pickingFBO=r.getRenderer().pickingFBO,this.o=new t__namespace.SpatialReference,this.h=e,this.u=new B$6(e),this.m={},this.p={},this.v={},this.T={},this.O={},this._={},this.M=new Ke$5,this.A=new Ke$5,this.I=new Ke$5,this.S=new Ke$5,this.N=new Ve$5(e.texture(2)),this.C=this.P.bind(this),this.R=new Ie$5({baseColorFactor:[1,1,1,1]}),this.L(),this.k=new Nr$4(this.h,this.B(),this.N);const s=this.getMap();s.altitudeToPoint&&(this.U=s.altitudeToPoint(100,s.getGLRes())/100)}getI3DMMeshes(){return this.T}getPNTSMeshes(){return this.v}getB3DMMeshes(){return this.p}getPaintedMeshes(){return this.F}getMap(){return this.s.getMap()}paint(t,e,n){const i=n&&n.renderTarget,o=n&&n.sceneFilter,a=this.getMap();if(!t.length||!a)return null;const c=this.D(),h=a.projViewMatrix,u=[],l=[],d=[],m=[],p=[],b=this.j(t),g=[];for(let i=0,o=t.length;i<o;i++){const o=t[i].data.node;let a=this.G(o);if(!a)continue;const c=this.s.H(o.V);o.q&&c.debugShowBoundingVolume&&g.push(o.q);const y=c.heightOffset||0,w=c.coordOffset||In$1;this.O[o.id]&&(a=this.O[o.id],a=_t$2(a));let v=c.polygonOffset||Tn$1;dt$2(v)&&(v=v()),Array.isArray(a)||(u[0]=a,a=u);for(let t=0,i=a.length;t<i;t++){const i=a[t].properties.magic;if(a[t].properties.heightOffset===y&&a[t].properties.coordOffset[0]===w[0]&&a[t].properties.coordOffset[1]===w[1]||(this.$(a[t]),a[t].X=copy$5([],a[t].localTransform)),"b3dm"===i){if(a[t].getBoundingBox&&!intersectsBox$1(h,a[t].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:r}=a[t].geometry.properties;if(e&&r){const e=a[t].properties.node.V;this.J&&this.J[e]?Ws$3.highlightMesh(this.h,a[t],this.J[e],this.K,r):this.J&&this.J[e]||Ws$3.highlightMesh(this.h,a[t],null,this.K,r),Ws$3.showOnly(this.h,a[t],this.Z&&this.Z[e],this.Y,r)}n&&n.bloom&&a[t].properties.hlBloomMesh&&(a[t].properties.hlBloomMesh.properties.depthFunc="always",a[t].properties.hlBloomMesh.properties.polygonOffset=v,d.push(a[t].properties.hlBloomMesh)),d.push(a[t])}else"pnts"===i?m.push(a[t]):"i3dm"===i&&p.push(a[t]);a[t].properties.isLeaf=!!e[o.id],a[t].properties.level=b.get(o.W),a[t].properties.polygonOffset=v,a[t].tt=o,e[o.id]||l.push(a[t]),this.et(a[t]),this.nt(a[t],o)}}let y=0;const w=this.k.getExcludeFilter();y+=this.rt(this.st,c,[o,Sn$1,w],i,l,d,p),y+=this.rt(this.it,c,[o,En$1,w],i,l,d,p),this.k.forEachShader(((t,e,n)=>{const r=this.D(n);y+=this.rt(t,r,[o,e],i,l,d,p)})),this.A.setMeshes(m);const v=this.ot();return y+=this.u.render(this.ct,v,this.A,i&&i.fbo),this.F={pntsMeshes:m,i3dmMeshes:p,b3dmMeshes:d},g.forEach((t=>{this.ht(t)})),this.S.setMeshes(g),this.u.render(this.ut,c,this.S,i&&i.fbo),y}ht(t){const e=t.properties.node,n=this.s.H(e.V),s=this.s.lt(e.V),a=n.heightOffset||0,c=this.ft(),u=set$4(Hn$1,0,0,c*(a-s.dt));let l=n.rotation||[0,0,0];l=fromEuler(zn$1,l[0],l[1],l[2]);const d=fromRotationTranslationScale(Dn$1,l,u,n.scale||[1,1,1]);multiply$5(t.localTransform,t.X,d)}rt(t,e,n,r,s,i,o){t.filter=n.filter((t=>!!t)),e.debug=!1,e.debug=!1;let a=0;return this.M.setMeshes(i),a+=this.u.render(t,e,this.M,r&&r.fbo),this.I.setMeshes(o),a+=this.u.render(t,e,this.I,r&&r.fbo),a}pt(t,e){return e.tt.bt-t.tt.bt}deleteTile(t){const e=t.node;e.q&&(e.q.geometry.dispose(),e.q.dispose(),delete e.q);this.gt(e.id)}gt(t){const e=this.p[t]||this.v[t]||this.T[t]||this.O[t]||this.m[t];this.O[t]?this.yt(t):e&&(this.wt(e),delete this.p[t],delete this.v[t],delete this.T[t],delete this.m[t])}yt(t){let e=this.O[t];e=_t$2(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.gt(n)}delete this.O[t]}wt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.wt(t[e]);else{Ws$3.showOnly(this.h,t),Ws$3.highlightMesh(this.h,t);const e=t.geometry.properties.url;if(e){const n=this._[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this._[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.s;yn$1(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.yt(t);this.O={};for(const t in this.p)this.gt(t);this.p={};for(const t in this.v)this.gt(t);this.v={};for(const t in this.T)this.gt(t);this.T={};for(const t in this.m)this.gt(t);this.m={},this.st&&(this.st.dispose(),delete this.st),this.it&&(this.it.dispose(),delete this.it),this.ct&&(this.ct.dispose(),delete this.ct),this.ut&&(this.ut.dispose(),delete this.ut),this.k.dispose(),this.picking&&this.picking.dispose()}G(t){return this.p[t.id]||this.v[t.id]||this.T[t.id]||this.O[t.id]}has(t){return this.G(t)||this.m[t.id]}$(t){const e=t.properties.magic;"b3dm"===e?this.vt(t):"i3dm"===e?this.Tt(t):"pnts"===e&&this.Ot(t)}createPntsMesh(t,e,s,i){if(this.v[e]){const t=this.v[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:o,featureTable:a,rootIdx:c,compressed_int16_params:h}=t,u=a.POINTS_LENGTH;o.BATCH_ID||(o.BATCH_ID=new Uint8Array(u),o.BATCH_ID.fill(0));const l=new Q$7(o,null,u,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});l.generateBuffers(this.h);const f={};o.POSITION?f.HAS_POSITION=1:o.POSITION_QUANTIZED&&(f.HAS_POSITION_QUANTIZED=1),o.RGB?f.HAS_RGB=1:o.RGBA?f.HAS_RGBA=1:o.RGB565&&(f.HAS_RGB565=1),(o.NORMAL||o.NORMAL_OCT16P)&&(f.HAS_NORMAL=1,o.NORMAL_OCT16P&&(f.HAS_NORMAL_OCT16P=1)),this._t(f,h),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:d,rtcCoord:m,projCenter:p}=t,b=this.s.H(c),g=new Be$5(l);g.properties.magic="pnts",g.properties.id=e,g.properties.node=s,g.properties.count=u,g.properties.batchTable=t.batchTable,g.properties.batchTableBin=t.batchTableBin,g.properties.serviceIndex=c,g.properties.rtcCoord=m,g.properties.rtcCenter=d,g.properties.projCenter=p,g.setDefines(f),Object.defineProperty(g.uniforms,"pointColor",{enumerable:!0,get:function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:b&&b.pointColor||[1,1,1,1]}});const y=this.getMap();let w=null,v=null;Object.defineProperty(g.uniforms,"pointSize",{enumerable:!0,get:function(){if(!b)return 2;if(on$1(b.pointSize)){const t=JSON.stringify(b.pointSize);return t!==w&&(v=an$1(b.pointSize),w=t),v(y.getZoom())}return b.pointSize||2}});let T=null,O=null;return Object.defineProperty(g.uniforms,"pointOpacity",{enumerable:!0,get:function(){if(!b)return 1;if(on$1(b.pointOpacity)){const t=JSON.stringify(b.pointOpacity);return t!==T&&(O=an$1(b.pointOpacity),T=t),O(y.getZoom())}return b.pointOpacity||1}}),this.Mt(g,h),this.Ot(g),g.X=copy$5([],g.localTransform),this.v[e]=g,i(null,{id:e,mesh:[g]}),[g]}Ot(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:s}=t.properties;this.xt(e,n,s,r.V),t.setLocalTransform(e)}createI3DMMesh(t,e,s,a){if(this.T[e]){const t=this.T[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.m[e]||a(null,{id:e,mesh:t}),t}const c=this.s.H(s.V),h=this.At(s.It),{i3dm:u,featureTable:l,gltf:f,batchTable:d,batchTableBin:m,count:b}=t,g=l.INSTANCES_LENGTH,{rtcCenter:y,rtcCoord:w}=t,v=this.St(Un$1,w),T=this.Et(Fn$1,s,y,w);multiply$5(v,T,v);const{POSITION:O,NORMAL_UP:_,NORMAL_RIGHT:M,SCALE:x,SCALE_NON_UNIFORM:A,INSTANCE_ROTATION:I}=u,S={instance_vectorA:new Float32Array(4*g),instance_vectorB:new Float32Array(4*g),instance_vectorC:new Float32Array(4*g),aPickingId:new Uint16Array(g)};for(let t=0;t<g;t++)S.aPickingId[t]=t;const E=new Float32Array(3),N=new Float32Array(3),C=[],P=new Float32Array(1),R=new Float32Array(3),L=[],k=[],B=[],U=[],F=new Float32Array(9);!function(t,e){let{byteOffset:n,byteStride:r,count:s}=t;const{componentType:i,itemSize:o}=t,a=t.array.buffer,c=i?X$8.getTypedArrayCtor(i):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,s=s||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,s*o);for(let r=0;r<s*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const h=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<s;t++){const s=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);h.set(s),e(new c(h.buffer),t),s.set(h)}}(O,((t,e)=>{_?(qt$1(N,M,e),qt$1(E,_,e),cross$1(C,N,E),normalize$4(C,C),Ot$2(L,N,0),Ot$2(L,E,1),Ot$2(L,C,2),fromMat3(k,L)):I?(qt$1(F,I,e),fromMat3(k,F)):identity$1(k),x?(qt$1(P,x,e),set$4(B,P[0],P[0],P[0])):A?(qt$1(R,A,e),set$4(B,...R)):set$4(B,1,1,1),fromRotationTranslationScale(U,k,t,B),$t$1(S.instance_vectorA,e,U,0),$t$1(S.instance_vectorB,e,U,1),$t$1(S.instance_vectorC,e,U,2)}));const D={};for(const t in S)D[t]={buffer:this.h.buffer({dimension:S[t].length/g,data:S[t]}),divisor:1};const z=c.shader||"pbr";let j=0,G=!0;const H=[],V=[];return Ut$1(f,((t,i,o,a)=>{const c=this.Nt(t,i,o,a,s,!0,z,V),{geometry:u,material:l}=c;l&&!l.isReady()&&(G=!1,j++);const f=new Ge$5(D,g,u,l);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(f.uuid)),f.properties.magic="i3dm",f.properties.id=e,f.properties.count=b,f.properties.batchTable=d,f.properties.batchTableBin=m,f.properties.serviceIndex=s.V,f.properties.rtcCoord=w,f.properties.rtcCenter=y,f.properties.node=s;const p=this.Ct(t,u,l,s.V,a);t.compressed_int16_params&&this.Mt(f,t.compressed_int16_params),this.Pt(f,t.attributes);const T=identity$2([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)multiply$5(T,T,t.matrices[e]);multiply$5(T,h,T),f.setPositionMatrix(T),this.Tt(f,v),f.setDefines(p),f.properties.polygonOffset={offset:0,factor:0},H.push(f),delete t.attributes,f.X=copy$5([],f.localTransform)})),Zn$1(V),G?(this.T[e]=H,a(null,{id:e,mesh:H})):(this.m[e]={meshes:H,count:j},H.Rt=a),H}Tt(t,e){const{rtcCenter:n,rtcCoord:s,node:i}=t.properties;if(!e){multiply$5(e=this.St(Un$1,s),this.Et(Fn$1,i,n,s),e)}const o=this.s.H(i.V),a=t.localTransform||[];if(o.coordOffset){multiply$5(a,this.Lt(Fn$1,i.V,s),e)}else copy$5(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||In$1}createB3DMMesh(e,s,i,o){if(e.gltf&&(e.gltf.transferables=null),this.p[s]||this.m[s]){const t=this.p[s];return console.warn(`mesh with id(${s}) was already created.`),this.m[s]||o(null,{id:s,mesh:t}),t}let a;if(i.maxExtent){const e=new t__namespace.Extent(i.maxExtent).convertTo((t=>this._pointToPrj(t)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const c=e.gltf,{projCenter:h}=c.extensions.MAPTALKS_RTC,{rtcCoord:u,center:l}=c.extensions.CESIUM_RTC,f=c.asset.sharePosition,d=this.At(i.It);let m;m=f?this.St(Un$1,u):this.xt(Un$1,u,h,i.V);const p=this.s.H(i.V);let b=p.shader||"pbr";if(p.unlit)b="phong";else if(c.materials)for(let t=0;t<c.materials.length;t++)if(c.materials[t]&&c.materials[t].extensions&&c.materials[t].extensions.KHR_materials_unlit){b="phong";break}const g=[],y=[];let w=0,v=!0;return Ut$1(c,((t,o,c,T)=>{const O=this.Nt(t,o,c,T,i,!1,b,g),{geometry:_,material:M}=O;M&&!M.isReady()&&(v=!1,w++);const x=new Be$5(_,M);O.refMeshes||(O.refMeshes=new Set,O.refMeshes.add(x.uuid)),x.properties.magic="b3dm",x.properties.id=s,x.properties.node=i,e.batchTable&&(x.properties.batchTable=e.batchTable,x.properties.batchTableBin=e.batchTableBin),x.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,x.properties.serviceIndex=i.V;const A=this.Ct(t,_,M,i.V,T);x.setDefines(A);const I=t.compressUniforms;if(I)for(const t in I)x.setUniform(t,I[t]);t.compressed_int16_params&&this.Mt(x,t.compressed_int16_params),this.Pt(x,t.attributes),a&&(A.USE_MAX_EXTENT=1,x.setUniform("maxPrjExtent",a)),Object.prototype.hasOwnProperty.call(x.uniforms,"polygonOpacity")||Object.defineProperty(x.uniforms,"polygonOpacity",{enumerable:!0,get:function(){return pt$2(p.opacity)?p.opacity:1}}),Object.prototype.hasOwnProperty.call(x.uniforms,"polygonFill")||Object.defineProperty(x.uniforms,"polygonFill",{enumerable:!0,get:function(){return Et$2([],p.polygonFill||On$1)}}),Object.prototype.hasOwnProperty.call(x.material.uniforms,"hsv")||Object.defineProperty(x.material.uniforms,"hsv",{enumerable:!0,get:function(){return p.hsv||_n$1}});const S=identity$2([]);if(f&&t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)multiply$5(S,S,t.matrices[e]);f&&multiply$5(S,d,S),x.properties.node=i,x.properties.projCenter=h,x.properties.nodeMatrix=S,x.properties.isSharedPosition=f,x.properties.rtcCoord=u,x.properties.rtcCenter=l,this.vt(x,m),y.push(x),delete t.attributes,x.X=copy$5([],x.localTransform)})),Zn$1(g),v?(this.p[s]=y,o(null,{id:s,mesh:y})):(this.m[s]={meshes:y,count:w},y.Rt=o),y}kt(t){const e=this.s.Bt[t.id];if(!e)return;let s,i,o,a;if(e.length){if(2===e.length){const n=e[1];s=Xn$1.vertices,i=Xn$1.indices,o=e[0],a=[n,n,n]}}else s=e.boxPosition,i=$n$1,o=this.s.lt(t.V).Ut,a=Qn$1;const c=new Q$7({POSITION:s},i,0,{primitive:"lines",positionAttribute:"POSITION"}),h=new Be$5(c,new Ce$5({lineColor:[.8,.8,.1,1],lineOpacity:1})),u=identity$2([]);fromRotationTranslationScale(u,Jn$1,o,a),h.localTransform=u,h.X=copy$5([],u),h.properties.node=t,t.q=h}Mt(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}vt(t,e){const{isSharedPosition:n,rtcCoord:s,rtcCenter:i,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=n?this.St(Un$1,s):this.xt(Un$1,s,o,c.V));const h=t.localTransform||identity$2([]);if(n){const t=this.Et(Fn$1,c,i,s);multiply$5(h,e,a),multiply$5(h,t,h)}else multiply$5(h,e,a);const u=this.s.H(c.V);if(u.coordOffset){multiply$5(h,this.Lt(Fn$1,c.V,s),h)}t.setLocalTransform(h),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||In$1}Pt(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){t.setUniform("decodeMatrix",e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix)}}Et(e,n,s,o){const a=this.getMap(),c=this.s.H(n.V).heightOffset||0,h=new t__namespace.Coordinate(o);let u;u=a.altitudeToPoint?this.U:a.distanceToPointAtRes(100,100,a.getGLRes(),h).y/100;const l=n.matrix?copy$5(e,n.matrix):identity$2(e);s&&ke$1(l,transformMat4$2(Nn$1,s,l),l);const f=function(t,e,n,r,s,i,o){e=copy$4(Ue$1,e);const a=Zt$1(Ue$1,e[0]*$e$1,e[1]*$e$1,e[2]),c=getTranslation$1(Fe$1,n),h=r.ellipsoid;let u;u=0===len$4(c)?set$4(De$1,0,0,-6378137):re$1(De$1,c),Ve$1.x=u[0],Ve$1.y=u[1];const l=r.project(Ve$1,qe$1);ze$1[0]=l.x/s,ze$1[1]=l.y/s,ze$1[2]=(u[2]+o)*i;const f=Be$1(a,h,je$1),d=function(t,e,n){const r=t[0],s=t[1],i=t[2],o=t[4],a=t[5],c=t[6],h=t[8],u=t[9],l=t[10],f=e[0],d=e[1],m=e[2],p=e[3],b=e[4],g=e[5],y=e[6],w=e[7],v=e[8],O=s*f+a*d+u*m,_=i*f+c*d+l*m,M=r*p+o*b+h*g,x=s*p+a*b+u*g,A=i*p+c*b+l*g,I=r*y+o*w+h*v,S=s*y+a*w+u*v,E=i*y+c*w+l*v;return n[0]=r*f+o*d+h*m,n[1]=O,n[2]=_,n[3]=0,n[4]=M,n[5]=x,n[6]=A,n[7]=0,n[8]=I,n[9]=S,n[10]=E,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(invert$2(Ge$1,f),fromMat4$1(He$1,n),t);return ke$1(t,ze$1,d),t}(l,o,l,a.getProjection(),a.getGLRes(),u,c),d=function(t,e){return set$4(t,e[12],e[13],e[14]),t}(Bn$1,f);let m=this.s.options.offset;if(dt$2(m)){const t=this.s.Ft(n.id).center;m=m.call(this.s,t)}return set$4(kn$1,m[0],m[1],0),sub$2(d,d,kn$1),ke$1(f,d,f),f}Lt(t,e,n){const s=this.s.H(e);if(!s.coordOffset)return null;const o=this.getMap(),a=o.getGLRes();Cn$1.set(n[0],n[1]);const c=o.coordToPointAtRes(Cn$1,a,Rn$1),h=s.coordOffset,u=Cn$1.set(n[0]+h[0],n[1]+h[1]),l=o.coordToPointAtRes(u,a,Ln$1),f=l.x-c.x,d=l.y-c.y,m=this.ft();return fromTranslation$1(t,set$4(kn$1,f,d,(h[2]||0)*m))}ft(){const t=this.getMap();let e;return e=t.altitudeToPoint?this.U:t.distanceToPointAtRes(100,100,t.getGLRes(),Cn$1).y/100,e}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:s}=t,i=[];for(let t=0;t<s.length;t++){const{magic:r}=s[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"i3dm"===r?this.createI3DMMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"pnts"===r?this.createPntsMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)})):"cmpt"===r&&this.createCMPTMesh(s[t],o,n,((t,{mesh:e})=>{i.push(e)}))}return this.O[e]=i,r(null,{id:e,mesh:i}),i}Ct(t,e,n,r,s){const i=("phong"===(this.s.H(r).shader||"pbr")?this.st:this.it).getGeometryDefines(e);return s.asset&&"S3M"===s.asset.generator&&this.Dt(i,e),e.data.uvRegion&&(i.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(i.VertexNormal=1),e.data[e.desc.color0Attribute]&&(i.VertexColor=1),e.data[e.desc.uv0Attribute]&&(i.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(i.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(i.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(i.TexCoord2=1),"MESHOPT"===this.s.zt&&(i.MeshOPT_Compress=1),this.hasIBL()&&(i.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(i.HAS_WEB3D_quantized_attributes_TEXCOORD=1),i.HAS_MIN_ALTITUDE=1,i.HAS_LAYER_OPACITY=1,this._t(i,t.compressed_int16_params),ft$2(i,t.compressDefines),i}_t(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}et(t){const e=this.s.getRenderer();e&&e.updateMaskDefines(t)}Dt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,n,r,s,i,o,a){let c=!1;r.asset&&"S3M"===r.asset.generator&&(c=!0,r.extensions=r.extensions||{});const h=r.url+"-"+e+"-"+n;if(this._[h])return this._[h];let u,l;a.push(t);const f=r.materials&&r.materials[t.material],d=r.extensions&&r.extensions.KHR_techniques_webgl,m=this.s.H(s.V);if(d&&f.extensions&&f.extensions.KHR_techniques_webgl){const e=this.jt(t,r,i,c);u=e.material,l=e.geometry,m.fillEmptyDataInMissingAttribute&&(l.desc.fillEmptyDataInMissingAttribute=!0)}else{l=this.Gt(t,i,qn$1);const e=m.ambientLight;let n=m.environmentExposure;const s=m.material,c=this.getMap().getLightManager(),h=c&&c.getAmbientLight();if(e&&(!h||h.color)&&void 0===n){n=e[0]/(h&&h.color?h.color[0]:.2)}u=this.Ht(t.material,r,o,s||Mn$1,n||1,a,m)}u&&Object.defineProperty(u.uniforms,"alphaTest",{enumerable:!0,get:function(){const t=m.alphaTest;return lt$2(t)?.1:t}}),u&&!u.isReady()?u.Vt=s.id:u||(u=this.R);const p={geometry:l,material:u};return l.properties.url=h,this._[h]=p,p}jt(t,e,n,r){const{geometry:s,material:i}=this.k.createMesh(t,e,n,r);return{geometry:s,material:i}}Gt(t,e,r){const s=t.attributes;let i=s._BATCHID&&s._BATCHID.array;if(i&&i.byteOffset&&(i=new i.constructor(i)),s.COLOR_0){const t=s.COLOR_0.array||s.COLOR_0;if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s.COLOR_0.array?(s.COLOR_0.array=e,s.COLOR_0.componentType=5121):s.COLOR_0=e}}const o={};for(const t in s){const e=mn$1(this.h,s[t],{dimension:s[t].itemSize}),n=r[t]||t;o[n]={buffer:e},s[t].quantization&&(o[n].quantization=s[t].quantization),n===r.POSITION&&(o[n].array=s[t].array,o[n].min=s[t].min,o[n].max=s[t].max)}const a=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,c=new Q$7(o,a,0,{static:!0,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":dn$1(t.mode)});return i&&a&&(c.properties.batchIdData=i,c.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const s=e[r],i=t[s];let o=n.get(i);o||(o=[],n.set(i,o)),o.push(s)}return n}(i,a)),c.generateBuffers(this.h,{excludeElementsInVAO:e}),c}xt(t,e,n,s){const o=identity$2(t),a=this.getMap();Cn$1.x=n[0],Cn$1.y=n[1];const c=this._prjToPoint(Cn$1),h=this.qt(),u=1/(a.getGLZoom?a.getResolution(a.getGLZoom()):a.getGLRes());Cn$1.x=e[0],Cn$1.y=e[1];const l=this.ft();let f=this.s.options.offset;dt$2(f)&&(f=f.call(this.s,Cn$1));const d=this.s.H(s).heightOffset||0;return set$4(Bn$1,c.x-f[0],c.y-f[1],l*n[2]+l*d),translate$1(o,o,Bn$1),set$4(h,u,u,l),scale$5(o,o,h),o}nt(t,e){const n=this.s.H(e.V),s=this.s.lt(e.V).Ut;let a=n.rotation||[0,0,0];a=fromEuler(jn$1,a[0],a[1],a[2]);const h=fromRotationTranslationScale([],a,Gn$1,n.scale||[1,1,1]),u=identity$2([]),l=identity$2([]);translate$1(u,u,scale$4(Vn$1,s,-1)),translate$1(l,l,s);const f=multiply$5(u,u,t.X);multiply$5(h,h,f);const d=multiply$5(l,l,h);t.localTransform=d}St(t,e){const n=identity$2(t),s=this.getMap(),o=this.qt();Cn$1.x=e[0],Cn$1.y=e[1];const a=s.distanceToPointAtRes(100,100,s.getGLRes(),Cn$1);let c;return c=s.altitudeToPoint?this.U:a.y/100,set$4(o,a.x/100*1.01,a.y/100*1.01,c),scale$5(n,n,o),n}L(){const e=[],s=[];this.ct=new vn$4({vert:Xt$1,frag:"#define SHADER_NAME PNTS\n\nprecision mediump float;\n\n\n\nvarying vec4 vColor;\n\n\n\nvoid main() {\n\n    vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n\n    if (dot(circCoord, circCoord) > 1.0) {\n\n        discard;\n\n    } else {\n\n        gl_FragColor = vColor;\n\n    }\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>multiply$5(s,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,n)=>fromMat4$1(e,n.modelMatrix)}],extraCommandProps:{viewport:{x:0,y:0,width:()=>this.i?this.i.width:1,height:()=>this.i?this.i.height:1},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,range:[0,1],func:"<"}}});const i=this.B();this.st=new bn$4({extraCommandProps:i}),this.it=new fi$4.StandardShader({extraCommandProps:i}),this.ut=new Qn$4({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.i?this.i.width:1,height:()=>this.i?this.i.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const o=this.s;gn$1(o.getRenderer().canvas,this.h,o.getMap()),this.picking=new Cr$4(this.u,{vert:this.it.vert,extraCommandProps:i,uniforms:this.it.uniforms,defines:{PICKING_MODE:1,ENABLE_PICKING:1,HAS_PICKING_ID:1}},this.pickingFBO,this.getMap()),this.$t=new Cr$4(this.u,{vert:Xt$1,extraCommandProps:i,uniforms:this.ct.uniforms,defines:{PICKING_MODE:1,ENABLE_PICKING:1,HAS_PICKING_ID:1}},this.pickingFBO,this.getMap())}B(){return{viewport:{x:0,y:0,width:()=>this.i?this.i.width:1,height:()=>this.i?this.i.height:1},cull:{enable:!0},stencil:{enable:!0,func:{cmp:(t,e)=>e.meshProperties.isLeaf?"always":">=",ref:(t,e)=>e.meshProperties.level},opFront:{fail:"keep",zfail:"keep",zpass:"replace"},opBack:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,range:[0,1],func:(t,e)=>e.meshProperties.depthFunc||"<"},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}ot(t){const e=this.getMap(),n=e.getLightManager(),r=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1];return{projViewMatrix:e.projViewMatrix,pointOpacity:t&&t.pointOpacity||1,lightDir:normalize$4(r,r)}}D(){const t=this.getMap(),e=this.s,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:s}=wn$1(n),i=vn$1(t,r,s),o=this.s.getRenderer(),a=o.getMaskUniforms();i.minAltitude=e.options.altitude||0;return i.layerOpacity=o.canvas.gl&&o.canvas.gl.wrap?e.options.opacity||0:1,ft$2(i,{czm_lightDirectionEC:i.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),ft$2(i,a),i}Ht(t,e,r,s,i,o,a){const h=e.materials&&e.materials[t];if(!h||!h.baseColorTexture&&!h.pbrMetallicRoughness)return null;const u=ft$2({},s);if(h.baseColorTexture){const t=e.textures[h.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Xt(t,o)),u.baseColorFactor=t&&t.image.color||h.baseColorFactor||[1,1,1,1],n&&(u.baseColorTexture=n)}else{if(h.normalTexture){const t=this.Xt(e.textures[h.normalTexture.index],o);if(t){const e=h.normalTexture.scale||1;u.normalTexture=t,u.normalMapFactor=e}}if(h.occlusionTexture){const t=this.Xt(e.textures[h.occlusionTexture.index],o);if(t){const e=h.occlusionTexture.strength||1;u.occlusionTexture=t,u.occlusionFactor=e}}if(h.emissiveTexture){const t=this.Xt(e.textures[h.emissiveTexture.index],o);t&&(u.emissiveTexture=t)}h.emissiveFactor&&(u.emissiveFactor=h.emissiveFactor);const t=h.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(u.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const n=e.textures[t.baseColorTexture.index];if(n.image&&n.image.color)u.baseColorFactor=u.baseColorFactor?multiply$3(u.baseColorFactor,u.baseColorFactor,n.image.color):n.image.color;else{const t=this.Xt(n,o);t&&(u.baseColorTexture=t,u.baseColorTexture.getREGLTexture(this.h))}}if(lt$2(t.metallicFactor)||(u.metallicFactor=t.metallicFactor),lt$2(t.roughnessFactor)||(u.roughnessFactor=t.roughnessFactor),h.metallicRoughnessTexture){const t=this.Xt(e.textures[h.metallicRoughnessTexture.index],o);t&&(u.metallicRoughnessTexture=t)}}}if(h.s3mMaterial)return new Ce$5(u);if(u.environmentExposure=i,u.alphaTest=.1,a.unlit||h.extensions&&h.extensions.KHR_materials_unlit)return u.ambientColor=[1,1,1],u.light0_diffuse=[0,0,0,0],u.lightSpecular=[0,0,0],new Ie$5(u);let l=new fi$4.StandardMaterial(u);"phong"===r&&(l=Ie$5.convertFrom(l));const f=h.pbrMetallicRoughness,d=f&&f.baseColorTexture&&f.baseColorTexture.extensions;return d&&d.KHR_texture_transform&&(l.set("khr_offset",d.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",d.KHR_texture_transform.rotation||0),l.set("khr_scale",d.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!a.doubleSided&&!h.doubleSided),l.once("complete",this.C),l}Xt(t,e){const r={type:t.type?ln$1(t.type):"uint8",format:t.format?fn$1(t.format):"rgba",flipY:!!t.flipY},s=t.image;if(e.push(s),s.array?r.data=s.array:s.mipmap&&(r.mipmap=s.mipmap),!r.data&&!r.mipmap)return null;if(r.width=s.width,r.height=s.height,r.mipmap&&(r.width<4||r.height<4))return null;const i=t.sampler||t.texture&&t.texture.sampler;return i&&(i.magFilter&&(r.mag=cn$1(i.magFilter)),i.minFilter&&(r.min=hn$1(i.minFilter)),i.wrapS&&(r.wrapS=un$1(i.wrapS)),i.wrapT&&(r.wrapT=un$1(i.wrapT))),new en$5(r,this.N)}P({target:t}){const e=t.Vt,n=this.m[e];if(n.count--,!n.count){const t=n.meshes;this.p[e]=t,delete this.m[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}qt(){return xn$1}Jt(t){return this.s.Jt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),Pn$1)}At(t){return"Y"===t?pn$1:"X"===t?bn$1:An$1}pick(t,e,n=3){const r=this.s;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const s=[],i=this.D(),o=this.Qt(this.picking,i,this.M,t,e,n);o&&s.push(o);const a=this.Qt(this.picking,i,this.I,t,e,n);a&&s.push(a);const c=this.ot(),h=this.Qt(this.$t,c,this.A,t,e,n);return h&&s.push(h),s}Qt(t,e,n,r,s,i){if(!n.getMeshes().length)return null;const o=this.s,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,s,i,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:h,pickingId:u,point:l,coordinate:f}=c,d=(0===h||h)&&t.getMeshAt(h);if(!d||!d.geometry)return null;const m=d.properties;l&&l.length&&(l[0]=Math.round(1e5*l[0])/1e5,l[1]=Math.round(1e5*l[1])/1e5,l[2]=Math.round(1e5*l[2])/1e5);const p={batchId:u};if(o.options.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const s in t)p[s]=void 0!==t[s].byteOffset?we$1(t[s],e,n,r):t[s][r]}return{service:d.properties.serviceIndex,data:p,point:l,coordinate:f}}j(t){let e=new Set;for(let n=0,r=t.length;n<r;n++){const r=t[n].data.node;this.G(r)&&e.add(r.W)}e=Array.from(e),e.sort();const n=new Map,r=e.length;for(let t=0;t<r;t++)n.set(e[t],t);return n}highlight(t){this.J=t;const e=this.s.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.s.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.s.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.s.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}Kt(){if(!this.F)return[];const t={},e=[];for(const n in this.F){const r=this.F[n];if(r)for(let n=0;n<r.length;n++){const s=r[n],i=s&&s.geometry;if(!s||!i)continue;const o=s.properties.serviceIndex;t[o]||(t[o]=new Set);const a=i.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!(!t||!t.getAmbientResource())}}function Zn$1(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}const Yn$1=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Wn$1=Yn$1(),tr$1=Wn$1.gl_trans__coders=Wn$1.gl_trans__coders||{};function er$1(t,e){if(e)for(let n=0;n<e.length;n++)t[e[n].id||e[n].index]=e[n]}tr$1.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=Wn$1.gl_trans__coders=Wn$1.gl_trans__coders||{};let i=`${r}\n    const _____getGlobal = ${Yn$1.toString()};\n    const g___lobals = _____getGlobal()\n    const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+='tran_____scoders["'+t+'"] ='+s[t].toString()+"\n;");return i+="\n"+e.substring(r.length),i},tr$1.registerTranscoder=function(t,e){tr$1[t]=e},tr$1.getTranscoder=function(t){return tr$1[t]};const nr$1=[];class rr$1{constructor(t,e,n,r,s){this.s=r,this.Zt=t,this.V=e,this.Yt=s,this.Wt=n.version,t.indexOf("i3s:tileset:")<0?(this.te=this.Wt<=1.6?"root":0,n.version=this.Wt):(this.te=t.substring("i3s:tileset:".length),this.Wt>1.6&&(this.te=parseInt(this.te))),this.Zt=t,this.ee=n}load(){const t=this.ee,e=t.layerScene.baseUrl;if(this.Wt<=1.6)return t[this.te]&&t[this.te].lodSelection?(this.ne=t[this.te],this.re()):new Promise((n=>{let r=e+"/nodes/"+this.te;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Yt(this.V,r,(()=>{this.ne=t[this.te],n(this.re())}))}));if(this.Wt>=1.7){if(t[this.te])return this.ne=t[this.te],this.re();const n=Math.floor(this.te/t.nodesPerPage);return new Promise((r=>{let s=e+"/nodepages/"+n;t.layerScene.eslpk&&(s+=".json"),this.Yt(this.V,s,(()=>{this.ne=t[this.te],r(this.re())}))}))}return null}getTileset(){return this.se}getChildrenURL(){return this.ie}re(){const t=this.ee,e=t.layerScene.baseUrl,n=this.ne.children,r=[],s={};if(n)for(let i=0;i<n.length;i++)if(this.Wt<=1.6){const o=n[i].id;if(t[o])continue;const a=o;s[a]||(s[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.Yt(this.V,r,(()=>{n()}))})),r.push(s[a]))}else{const o=n[i];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);s[a]||(s[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.Yt(this.V,r,(()=>{n()}))})),r.push(s[a]))}return r.length?Promise.all(r).then((()=>this.oe())):this.oe()}oe(){return Promise.resolve(this.ae())}ce(t){er$1(this.ee,t)}ae(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ne,!0)}}he(t){const e=this.s.getRenderer(),n=this.ee.projection,r=!n||n&&4326===n.wkid,s=this.Wt,i=this.ee,o=t,a=o.obb,c=o.mbs,h={};let u;if(c)u=set$4([],c[0],c[1],c[2]),r||(u=e.ue(u,u)),u=sr$1([],u[0],u[1],u[2]),h.sphere=[...u,c[3]];else if(a){u=set$4([],a.center[0],a.center[1],a.center[2]),r||(u=e.ue(u,u)),u=sr$1([],u[0],u[1],u[2]);const t=function(t,e,n){const r=fromQuat$1([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion);set$4(nr$1,t[3]+t[6]+t[9],t[4]+t[7]+t[10],t[5]+t[8]+t[11]);const o=len$4(nr$1);h.sphere=[...u,o]}let l=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)"maxScreenThresholdSQ"===i.lodSelectionMetricType?l=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI)):console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(l=f/o.lodSelection[t].maxError);(l===1/0||isNaN(l))&&(l=1e5);const d=16*l,m=identity$2([]),p=o.children;let b;if(p){b=[];const t=this.ee;for(let e=0;e<p.length;e++){const n=s<=1.6?p[e].id:p[e];if(!t[n]){b=null;break}b.push(this.he(t[n]))}}const g={refine:"REPLACE",boundingVolume:h,transform:m,geometricError:d};return s<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:p&&p.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.ne}}function sr$1(t,e,n,r){return Zt$1(t,bt$2(e),bt$2(n),r)}const ir$1=!!tr$1.ktx2,or$1=identity$2([]),ar$1=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function cr$1(t){return t.indexOf("i3s:mesh")>=0}const hr$1="i3s:mesh:".length;function lr$1(t,e){for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&ir$1)return t[n]}return null}const fr$1=new t__namespace.Coordinate(0,0),dr$1=new t__namespace.Coordinate(0,0),mr$1=new Set,pr$1=[],br$1=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.le(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){let t=!1;const e=this.data.keys();let n=e.next();for(;this.currentSize>this.max&&void 0!==n.value;){!t&&this.data.get(n.value).current&&(t=!0,console.warn(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`));const r=this.getAndRemove(n.value);r&&this.onRemove(r),n=e.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.le(t,e),this}le(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(t__namespace.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let gr$1=0;class yr$1 extends(oe$4(t__namespace.renderer.CanvasRenderer)){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>br$1.max&&br$1.setMaxSize(e),this.tileCache=br$1,gr$1++,this.prepareWorker(),this.tilesLoading={},this.fe={},this.de=[],this.Yt=this.me.bind(this)}getAnalysisMeshes(){if(!this.painter)return pr$1;const t=this.painter.getPaintedMeshes();if(!t)return pr$1;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:s}=t;return n.length&&It$2(e,n),r.length&&It$2(e,r),s.length&&It$2(e,s),e}needToRedraw(){return!!this.getMap().isInteracting()||!!this.de.length||super.needToRedraw()}getFrameTimestamp(){return this.pe}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.pe=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:s}=this.layer.getTiles();if(!s||!s.length)return void this.completeRender();this.be(),this.ge();const{selectedTiles:o,leaves:a,requests:c}=this.ye(r,s);c.length&&this.loadTiles(c),this.we(o,a,e),this.ve(),c.length||this.completeRender()}ye(t,e){const n=this.layer.getRootTiles();let r=[];this.Te();let s=0;const i=this.Oe(),o={};let a=!1,c=!1;for(let t=0;t<e.length;t++){const i=e[t],h=i.node;if(o[h.id])continue;const u=n[h.V];o[h.id]=1;let l=!1;const f=this.getCachedTile(h.id);(this._e(h.id)?(s++,l=c=!0,this.tilesLoading[h.id].current=!0):f?(this.getTileOpacity(f)<1&&(l=c=!0),(!i.node.Me||u.isS3M||!i.node.children||i.node.Me<=500)&&(a=!0,i.selected=!0,i.data=f)):this.painter.has(h)||(l=c=!0,r.push(h)),l)&&((this.xe(i)||this.Ae(i).length)&&(a=!0))}let h=[],u={};if(a&&({selectedTiles:h,leaves:u}=this.Ie(t)),r.length>1&&(r.sort(wr$1),i)){const t=i-s;r=t>0?r.slice(0,t):[]}return{loading:c,requests:r,selectedTiles:h,leaves:u}}Ie(t){const e=[],n={};let r;const s=[t],i=[];for(;s.length>0||i.length>0;){if(i.length>0){const t=i[i.length-1];if(t.Se===s.length){i.pop(),t===r&&(t.leave=!0,n[t.node.id]=1),e.push(t);continue}}const t=s.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)n[t.node.id]=1,t.selectionDepth=i.length,e.push(t);else{if(t.selectionDepth=i.length,r=t,0===o.length){t.leave=!0,n[t.node.id]=1,e.push(t);continue}i.push(t),t.Se=s.length}for(let t=0;t<o.length;t++)s.push(o[t])}return{selectedTiles:e,leaves:n}}xe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ae(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.W+1,r=[t.node];for(;r.length>0;){const s=r.pop().children;for(let i=0,o=s.length;i<o;i++){if((!s[i].content||!s[i].content.url)&&s[i].children&&s[i].children.length){r.push(s[i]);continue}const o=s[i].id;if(this.tileCache.has(o)){const n=this.layer.Ee(s[i],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else s[i].W<=n&&r.push(s[i])}}return e}we(t,e,n){this.tileCache.markAll(this,!1);for(let e=0,n=t.length;e<n;e++){const n=t[e].data;n.current=!0,n.renderer=this,this.tileCache.add(t[e].node.id,n)}this.tileCache.shrink();const r={tiles:t,leaves:e};this.onDrawTileStart(r);const s=this.painter.paint(t,e,n);this.onDrawTileEnd(r),s&&this.layer.fire("canvasisdirty",{renderCount:s})}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(xt$2(e)){const n=At$2(e);return this.Ne(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.V;return new rr$1(e,n,this.Ce[n],this.layer,this.Yt).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Ct$2(e)&&!cr$1(e)&&(e=t.baseUrl+e),this.Ne(e,null,t),null}Ne(t,e,r){let s=this.Pe;s||(s=N$6.getSupportedFormats(this.gl.gl||this.gl),this.Pe=s);const i=this.layer.H(r.V);i.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length).split("/"),r=[];for(let t=0;t<n.length;t++)r.push(encodeURIComponent(n[t]));return e+r.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,r.baseUrl,this.layer.Re[r.V]),arraybuffer:e,rootIdx:r.V,upAxis:r.It,transform:r.matrix,supportedFormats:s};if(cr$1(t)){const e=this.Ce[r.V];if(o.projection=e.projection,o.i3sInfo=function(t,e,n,r,s){const i=e.layerScene.eslpk,o=function(t,e){const n=e.substring(hr$1);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,h=[];let u=!1;const l=or$1;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;i&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let s=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(s){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",i&&(s+="."+n),r.material={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+s,factor:1,format:n,mimeType:t},metallicFactor:0}}}h.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions[f.definition],{geometryBuffers:o}=t;u=r&&2===o.length;let p=c+`/nodes/${f.resource}/geometries/`+(tr$1.draco&&u?1:0);i&&(p+=".bin");const b={geometry:{url:p,info:tr$1.draco&&u?o[1]:o[0]}};if(s&&ar$1&&u&&!tr$1.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const g=e.layerScene.materialDefinitions,y=e.layerScene.textureSetDefinitions;let w,v=0;d&&(v=g[d.definition]),w=g?function(t,e,n,r,s,i){const o=JSON.parse(JSON.stringify(t));return function t(e,n,r,s,i,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const t=n[e[a].textureSetDefinitionId],c="images/"+t.formats[0].format,h=lr$1(t.formats,i),u={url:r+`/nodes/${s}/textures/${h.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:h.format,mimeType:c};if(o){let t="";switch(h.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=h.format}u.url+="."+t}e[a]=u}else mt$2(e[a])&&t(e[a],n,r,s,i,o)}(o,e,n,r,s,i),o}(v,y,c,d.resource,n,e.layerScene.eslpk):{pbrMetallicRoughness:{metallicFactor:0}},b.material=w,h.push(b)}return{dracoCompression:u,meshes:h,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:l}}(t,e,this.regl,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=ft$2({},i),i.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:s}=n;"b3dm"===s||"pnts"===s||"i3dm"===s||"cmpt"===s||"gltf"===s?(this.de.push({data:n,tile:r}),i.debugShowBoundingVolume&&this.painter.kt(r)):this.onTilesetLoad(n,r,t)}))}ge(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.de.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.de.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Le(t,e,n,r)})),n++}}Le(t,e,n,r){if(n)this.onTileError(n,e);else{const n=this.ke(r);e.memorySize=n,this.onTileLoad(t,e)}}ke(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.ke(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Be(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.Ue(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;mr$1.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),mr$1.add(s)),delete this.tilesLoading[e.id],this.Fe(e,t),this.setToRedraw(),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}Fe(e,n){const r={loadTime:t__namespace.Util.now(),current:!0,error:n,node:e};r.renderer=this,this.tileCache.add(e.id,r)}Be(e){const n={loadTime:t__namespace.Util.now(),current:!0,node:e};n.renderer=this,this.tileCache.add(e.id,n)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.fe[e]}Te(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}createContext(){const t=this.layer,e=t.options.glOptions||{alpha:!0,depth:!0,stencil:!0,preserveDrawingBuffer:!0,antialias:t.options.antialias},n=this.canvas.gl&&this.canvas.gl.wrap;n?(this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl):(this.glOptions=e,this.gl=this.De(this.canvas,e)),this.regl=this.regl||a$2({gl:this.gl,attributes:e,extensions:["OES_element_index_uint"],optionalExtensions:t.options.optionalExtensions||[]}),n&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Kn$1(this.regl,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:this.regl})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new Lt$2("@maptalks/3dtiles",t.id));const e=this.workerConn;if(!e.isActive())return;let n=this.layer.options||{};n=ft$2({},n),delete n.offset;const r=t.options.spatialReference;n.projection=r&&r.coordType||r&&r.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,n,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),gr$1--,gr$1||br$1.reset(),this.clear(),delete this.tileCache,super.onRemove()}clear(){this.ve(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}clearCanvas(){this.regl&&this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas()}getTileOpacity(){return 1}getStencilValue(){return 0}ve(t){this.je||(this.je=Date.now());const e=Date.now();if(!t&&e-this.je<this.layer.options.retireInterval)return;this.je=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}De(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let s=0;s<n.length;++s){try{r=t.getContext(n[s],e)}catch(t){}if(r)break}return r}_e(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return ge$1(t,e,0,n)}be(){if(!this.Ge)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.Ge){const s=this.Ge[r];if("pending"===s.status)continue;s.status="pending";const i=s.rootIdx,o=Pt$2(this.layer.H(i).fetchOptions);if(n.push(w$5.getJSON(r,o).then((t=>{delete this.Ge[r];const e=this.Ce[i];if(e){t.nodes?er$1(e,t.nodes):(e[t.id]=t,er$1(e,t.children));for(let t=0;t<s.length;t++)s[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}me(t,e,n){this.Ge||(this.Ge={}),this.Ge[e]=this.Ge[e]||[],this.Ge[e].rootIdx=t,this.Ge[e].push(n),this.setToRedraw()}Ue(t,e,n){this.Ce||(this.Ce=[]);const r=e.V;this.Ce[r]||(this.Ce[r]={});const s=this.Ce[r],i=this.layer.H(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),s.version=+(i.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),s.projection=t.spatialReference,function(t,e,n,r,s,i,o){if(!i.layerScene){i.layerScene=e,i.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,i.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=s;if(i.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=s.lastIndexOf("/");t=e<0?"./":s.substring(0,e)}i.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new rr$1(s,n,i,t,o).load()}(this.layer,t,r,0,n,s,this.Yt).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:s,height:i}=this.canvas;return!this.pickingFBO||r.width===s&&r.height===i||r.resize(s,i),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Kt(){return this.painter?this.painter.Kt():[]}ue(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.He();return fr$1.x=e[0],fr$1.y=e[1],n.unproject(fr$1,dr$1),t[0]=dr$1.x,t[1]=dr$1.y,t}return fr$1.x=e[0],fr$1.y=e[1],n.getProjection().unproject(fr$1,dr$1),t[0]=dr$1.x,t[1]=dr$1.y,t}Ve(t,e){const n=this.He();return fr$1.x=e[0],fr$1.y=e[1],n.project(fr$1,dr$1),t[0]=dr$1.x,t[1]=dr$1.y,t}qe(t,e){const n=this.He();return fr$1.x=e[0],fr$1.y=e[1],n.unproject(fr$1,dr$1),t[0]=dr$1.x,t[1]=dr$1.y,t}He(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this.$e||(this.$e=t__namespace.SpatialReference.getProjectionInstance(e)),this.$e}}function wr$1(t,e){return t.bt-e.bt}function vr$1(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}const Or$1=[],_r$1=[],Mr$1=[],xr$1=[],Ar$1=[],Ir$1=2*Math.PI;class Sr$1{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],s=t.west;let i=t.east;return i<s&&(i+=Ir$1,n<0&&(n+=Ir$1)),(n>s||le$1(n,s,1e-14))&&(n<i||le$1(n,i,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const Er$1=[0,0,1];function Nr$1(t,e){return Zt$1(e,t[0],t[1],t[2])}class Cr$1{constructor(t,e){this.normal=copy$4([],t),this.distance=e}static fromPointNormal(t,e,n){const r=-dot$4(e,t);return copy$4(n.normal,e),n.distance=r,n}}const Pr$1=[],Rr$1=[],Lr$1=[],kr$1=[],Br$1=[],Ur$1=[],Fr$1=[],Dr$1=[],zr$1=[],jr$1=[],Gr$1=new Cr$1([1,0,0],0),Hr$1=[];class Vr$1{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new Sr$1(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let n=0;if(!Sr$1.contains(this.rectangle,e)){const r=this.northeastCornerCartesian,s=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,h=subtract$2(Hr$1,t,this.southwestCornerCartesian),u=dot$4(h,s),l=dot$4(h,o),f=subtract$2(Hr$1,t,r),d=dot$4(f,a),m=dot$4(f,c);u>0?n+=u*u:d>0&&(n+=d*d),l>0?n+=l*l:m>0&&(n+=m*m)}const r=e[2],s=this.minimumHeight,o=this.maximumHeight;if(r>o){const t=r-o;n+=t*t}else if(r<s){const t=s-r;n+=t*t}return Math.sqrt(n)}computeBox(t){const e=this;Nr$1(Sr$1.southwest(t,Rr$1),e.southwestCornerCartesian),Nr$1(Sr$1.northeast(t,Rr$1),e.northeastCornerCartesian),Pr$1[0]=t.west,Pr$1[1]=.5*(t.south+t.north),Pr$1[2]=0;const n=Nr$1(Pr$1,Lr$1),r=cross$1(Br$1,n,Er$1);normalize$4(e.westNormal,r),Pr$1[0]=t.east;const s=Nr$1(Pr$1,Dr$1),o=cross$1(Br$1,Er$1,s);normalize$4(e.eastNormal,o);const a=subtract$2(Br$1,n,s),c=normalize$4(kr$1,a),h=t.south;let u;if(h>0){Pr$1[0]=.5*(t.west+t.east),Pr$1[1]=h;const n=Nr$1(Pr$1,zr$1);copy$4(jr$1,c);const r=Cr$1.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Gr$1);qr$1(zr$1,jr$1,r,e.southwestCornerCartesian),u=ce$1(n,Ur$1)}else u=he$1(Sr$1.southeast(t,Rr$1),Ur$1);const l=cross$1(Fr$1,u,a);normalize$4(e.southNormal,l);const f=t.north;let d;if(f<0){Pr$1[0]=.5*(t.west+t.east),Pr$1[1]=f;const n=Nr$1(Pr$1,zr$1);scale$4(jr$1,c,-1);const r=Cr$1.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Gr$1);qr$1(zr$1,jr$1,r,e.northeastCornerCartesian),d=ce$1(n,Ur$1)}else d=he$1(Sr$1.northwest(t,Rr$1),Ur$1);const m=cross$1(Fr$1,a,d);normalize$4(e.northNormal,m)}}function qr$1(t,e,n,r){const s=t,o=e,a=n.normal,c=dot$4(a,o);if(Math.abs(c)<1e-15)return;const h=(-n.distance-dot$4(a,s))/c;return h<0?void 0:add$4(r=scale$4(r,o,h),s,r)}const $r$1={maxGPUMemory:t__namespace.Browser.mobile?32:1536,retireInterval:2e3,loadingLimitOnInteracting:5,loadingLimit:10,renderer:"gl",forceRenderOnZooming:!0,forceRenderOnRotating:!0,forceRenderOnMoving:!0,debug:!1,meshLimitPerFrame:1,i3sNodepageLimitPerFrame:1,enableI3SCompressedGeometry:!0,forceI3SCompressedGeometry:!0,picking:!0,pickingPoint:!0,geometryEvents:!1,antialias:!1,optionalExtensions:["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"],offset:[0,0]},Xr$1=new t__namespace.Extent(0,0,0,0),Jr$1=[],Qr$1=[],Kr$1=[],Zr$1=[],Yr$1=[],Wr$1=new t__namespace.Coordinate(0,0),ts$1=new t__namespace.Point(0,0),es$1=[],ns$1=new t__namespace.Coordinate(0,0),rs$1=identity$2([]),ss$1=[0,0],is$1=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class os$1 extends(ds$4(t__namespace.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new os$1(t.id,t.options):null}constructor(t,e){super(t,e),this.Xe(),this.fe={},this.Bt=[]}Xe(){const t=this.options.services.map((t=>t.url));this.Je=this.Je||{},this.Re=this.Re||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.Je[n];void 0===r&&(r=this.Je[n]=this.Re.length),this.Re[r]=hs$1(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Re.slice(0)})}showService(t){return this.updateService(t,{visible:1}),this}hideService(t){return this.updateService(t,{visible:0}),this}setToRedraw(){const t=this.getRenderer();t&&t.setToRedraw()}addService(t){this.options.services=this.options.services||[],this.options.services.push(t),this.Xe();const e=this.getRenderer();return e&&e.setToRedraw(),this}updateService(t,e){if(!e)return this;const n=this.options.services;if(n&&n[t]&&ft$2(n[t],e),!lt$2(e.visible)){const s=this.Je[n[t].url];this.Re&&this.Re[s]&&(this.Re[s].visible=e.visible)}const r=this.getRenderer();return r&&r.setToRedraw(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.Je[n];this.Re[r]&&(this.Re[r]=null),delete this.Je[n],e.splice(t,1)}const n=this.getRenderer();return n&&n.setToRedraw(),this}getTileUrl(t,e,n){const r=n&&n.service&&n.service.subdomains;if(r&&n.domainKey){const e=r.length;if(e){const s=[...t].reduce(((t,e)=>t+e.charCodeAt()),0)%e;return t.replace(n.domainKey,r[s])}}return t}getExtent(e){if(!e&&0!==e){const e=new t__namespace.Extent;for(let t=0;t<this.Re.length;t++)if(this.Re[t].boundingVolume){const n=this.boundingVolumeToExtent(this.Re[t]);e._combine(n)}return e}return this.Re[e]&&this.Re[e].boundingVolume?this.boundingVolumeToExtent(this.Re[e]):null}boundingVolumeToExtent(e){const n=e.boundingVolume.Qe?rs$1:e.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(e.boundingVolume.region){const n=e.boundingVolume.region;return new t__namespace.Extent(gt$2(n[0]),gt$2(n[1]),gt$2(n[2]),gt$2(n[3]))}if(e.boundingVolume.sphere){const a=e.boundingVolume.sphere,c=re$1([],transformMat4$2([],a,n));s&&o.Ve(c,c);const h=a[3],u=r.locate(c,-h,h),l=r.locate(c,h,-h);return new t__namespace.Extent(u,l)}if(e.boundingVolume.box){const c=e.boundingVolume.box,h=transformMat4$2([],c,n),u=new t__namespace.Coordinate(re$1([],h));s&&o.Ve(u,u);const l=c.slice(3);multiply$6(l,fromMat4$1([],e.matrix),l);const f=length$4(l.slice(0,3)),d=length$4(l.slice(3,6)),m=length$4(l.slice(6,9)),p=Math.max(f,d,m),b=r.locate(u,-p,p),g=r.locate(u,p,-p);return new t__namespace.Extent(b,g)}return null}getRootTiles(){return this.Re}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Ke(),{tiles:Yr$1};const e=this.getMap(),n=e.cameraPosition,r=e.pointAtResToDistance(n[2],0,e.getGLRes()),s=this.Ze(n);this.Ye=this.Ye||[],set$4(this.Ye,bt$2(s.x),bt$2(s.y),r),this.We=Zt$1(this.We||[],this.Ye[0],this.Ye[1],this.Ye[2]),this.tn=2*Math.tan(.5*bt$2(e.getFov()));const o=e.projViewMatrix,a={children:[],level:-1};let c=a;const h=[];for(let e=0;e<this.Re.length;e++){const n=this.Re[e];if(!n||!n.visible)continue;let r=1/0;const s=[n],i=this.nn(e);for(;s.length>0;){const e=s.pop();for(e.id||this.rn(e);c.level>=e.W;)c=c.parent;const n=this.sn(e,i,o);if(n<1){let t=c;for(;t&&!t.content;)t=t.parent;if(0===n&&t&&t.content&&this.in(h,t),!1===this.options.services[e.V].alwaysShow)continue;if(!(0===n&&e.W<=r))continue;e.content&&(r=e.W)}e.bt<1/0&&this.an(e);const a=this.Ee(e,c);c.children.push(a);const u=e.children,l=u&&u.length,f=a.content;if(!l&&f&&this.in(h,a),l){f&&"add"===e.refine&&this.in(h,a),c=a;const n=u[0].parent;let r=!1;for(let i=0,o=u.length;i<o;i++){if(n){const e=t.getCachedTile(u[i].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,u[i].parent=e,u[i].It=e.It,u[i].baseUrl=e.baseUrl;const t=u[i].content&&(u[i].content.url||u[i].content.uri);t&&(xt$2(t)||t.indexOf("i3s:")>=0?u[i].baseUrl=e.baseUrl:Ct$2(t)?u[i].content.url=e.baseUrl+t:u[i].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}s.push(u[i])}!r&&f&&this.in(h,a)}}}return{root:a,tiles:h}}in(t,e){const{viewerRequestVolume:n}=e.node;n&&!function(t,e,n){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return as$1(n,e);if(n.box)return 0===cs$1(n,e)}return!1}(this.Ye,this.We,n)||t.push(e)}Ee(t,e){return{id:t.id,node:t,children:[],level:t.W,parent:e,content:t.content&&t.content.url}}rn(e){const n=this.getId();e.id=n+":"+t__namespace.Util.GUID(),e.matrix=e.transform||identity$2([]),e.cn=this.hn(e),e.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=multiply$5(e.matrix,e.parent.matrix,e.matrix)),e.V=e.parent.V,void 0===e.W&&(e.W=e.parent.W+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}H(t){return this.Re[t].service}un(t){const e=t.boundingVolume;if(!e||e.Qe&&!this.ln(t))return;const n=this.H(t.V),s=n.heightOffset||0,o=this.options.offset,a=dt$2(o)||o[0]||o[1],c=n.coordOffset||ss$1;if(!Array.isArray(c))throw new Error("service.coordOffset must be an array");if(!e.Qe&&(!t.boundingVolume||!s&&exactEquals$5(t.matrix,rs$1)&&!a&&c===ss$1))return;e.box&&e.region&&delete e.region;const{region:h,box:u,sphere:l}=e;if(e.coordOffset=[c[0],c[1]],e.heightOffset=s,h){e.originalVolume||(e.originalVolume=h.slice(0));const t=e.originalVolume,n=this.dn([gt$2(t[0]),gt$2(t[1])]);h[0]=bt$2(n.x+c[0]),h[1]=bt$2(n.y+c[1]);const r=this.dn([gt$2(t[2]),gt$2(t[3])]);h[2]=bt$2(r.x+c[0]),h[3]=bt$2(r.y+c[1]),h[4]=t[4]+s+(c[2]||0),h[5]=t[5]+s+(c[2]||0)}else if(u||l){e.originalVolume||(e.originalVolume=(u||l).slice(0));const n=u||l,o=transformMat4$2(Jr$1,e.originalVolume,t.matrix),a=re$1(Qr$1,o),h=this.dn([a[0]+c[0],a[1]+c[1]]);a[0]=h.x,a[1]=h.y,a[2]+=s+(c[2]||0),Zt$1(n,bt$2(a[0]),bt$2(a[1]),a[2])}e.Qe=!0}ln(t){const e=t.boundingVolume,n=this.H(t.V),s=n.coordOffset||ss$1;return e.coordOffset[0]!==s[0]||e.coordOffset[1]!==s[1]||e.heightOffset!==(n.heightOffset||0)}hn(t){return void 0===t.geometricError||!t.boundingVolume}an(t){let e=t.parent;for(;e&&e.cn&&!(e.bt<=t.bt);)e.bt=t.bt,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const r=this.getRenderer();r&&r.setToRedraw()}}onTilesetLoad(t,e,n){if(!t)return void console.warn("invalid tileset at : "+n);const s=this.H(e.V),i=(t.asset&&t.asset.gltfUpAxis||e&&e.It||s.upAxis||"Y").toUpperCase();t.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const o=n.indexOf("realspace/")>-1;0===e.W&&(t.asset&&t.asset.s3mType&&o||s.isSuperMapiServer)&&(t.root.baseUrl+="data/path/");const a=t.asset.i3s,c=!!t.asset.s3mType;if(t.root.It=i,e){const s=this.Re[e.V];c&&!s.isS3M&&(s.isS3M=c);const i=e.boundingVolume;ft$2(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",i&&(e.boundingVolume=i);const o=t.root.transform;o&&(e.parent?a||(e.matrix=multiply$5([],e.parent.matrix,o)):e.matrix=o),e.mn=e.content,delete e.content,t.root.content&&(e.content=t.root.content),e.cn=this.hn(e);const h=e.content&&(e.content.url||e.content.uri);h&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!a&&h&&!xt$2(h)&&Ct$2(h)&&(e.content.url=e.baseUrl+h),t.root&&!e.parent&&this.pn(e)}this.Ke(),this.fire("loadtileset",{tileset:t,index:e&&e.V,url:n})}sn(t,e,n){if(t.bt=1/0,0===t.W||t.cn)return this.pn(t),1;if(this.un(t),!this.bn(t,e,n))return-1;if(0===t.geometricError)return 1;let r=this.H(t.V).maximumScreenSpaceError;null==r&&(r=16);let s=this.gn(t);return 0===s&&t.parent&&(s=.5*(t.parent.Me||0)),s>=r?1:0}Jt(e,n){n||(n=new t__namespace.Point(0,0));const r=this.getMap();return r.getGLZoom?r.coordToPoint(e,r.getGLZoom(),n):r.coordToPointAtRes(e,r.getGLRes(),n)}bn(e,n,r){const s=e.id;let i=this.Bt[s]&&this.Bt[s].obbox;const{boundingVolume:o}=e,a=o.region,c=o.box,h=o.sphere;if(!i)if(a)this.Bt[s]=this.yn(e),i=this.Bt[s].bbox,i.center=this.Bt[s].coordCenter;else if(c)this.Bt[s]=this.wn(e),i=this.Bt[s].obbox,i.center=this.Bt[s].coordCenter;else if(h){i=this.Bt[s]=this.vn(e);const n=re$1(Jr$1,h),r=new t__namespace.Coordinate(n);i.center=r}if(n){if(a)Xr$1.xmin=i[0][0],Xr$1.ymin=i[0][1],Xr$1.xmax=i[1][0],Xr$1.ymax=i[1][1];else if(h){const t=i[2];Xr$1.xmin=i[0][0]-t,Xr$1.ymin=i[0][1]-t,Xr$1.xmax=i[0][0]+t,Xr$1.ymax=i[0][1]+t}else if(c){const t=i[1],e=i[2];Xr$1.xmin=i[0][0]-t,Xr$1.ymin=i[0][1]-e,Xr$1.xmax=i[0][0]+t,Xr$1.ymax=i[0][1]+e}if(!n.intersects(Xr$1))return!1}return a?intersectsBox$1(r,i):h?function(matrix,sphere,mask){setPlanes$1(matrix);for(var center=sphere[0],negRadius=-sphere[1],i=0;i<6;i++)if((!mask||"0"!==mask.charAt(i))&&distanceToPoint$1(planes$1[i],center)<negRadius)return!1;return!0}(r,i):!!c&&function(matrix,box,mask){setPlanes$1(matrix);for(var i=0;i<6;i++)if(!(mask&&"0"===mask.charAt(i)||intersectsPlane(planes$1[i],box)))return!1;return!0}(r,i)}yn(e){const n=this.getMap(),r=n.getGLRes(),s=e.boundingVolume.region;let{ws:i,en:o}=function(t){const r=t[2],s=t[3],o=t[5],a=Zt$1([],t[0],t[1],t[4]),c=Zt$1([],r,s,o);return{ws:re$1(a,a),en:re$1(c,c)}}(s);i=new t__namespace.Coordinate(i),o=new t__namespace.Coordinate(o);const a=n.coordToPointAtRes(i,r);a.z=n.altitudeToPoint(i.z,r);const c=n.coordToPointAtRes(o,r);c.z=n.altitudeToPoint(o.z,r);const h=[c.x,a.y,c.z,c.x,c.y,c.z,a.x,c.y,c.z,a.x,a.y,c.z,c.x,a.y,a.z,c.x,c.y,a.z,a.x,c.y,a.z,a.x,a.y,a.z],u=[(h[0]+h[18])/2,(h[1]+h[19])/2,(h[2]+h[20])/2],l=n.pointAtResToCoord(new t__namespace.Point(u),r);l.z=(i.z+o.z)/2;const f=this.lt(e.V).Ut,d=[h.slice(21,24),h.slice(3,6)];if(f)for(let t=0;t<h.length;t+=3)h[t]-=f[0],h[t+1]-=f[1],h[t+2]-=f[2];return{bbox:d,boxPosition:h,pointCenter:u,coordCenter:l}}wn(t){const e=this.getRenderer(),n=this.getMap(),r="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),o=t.boundingVolume.box,a=o.slice(0,3),h=new us$1((u=this.Tn(o,t.matrix))[0],u[3],u[6],(l=a)[0],u[1],u[4],u[7],l[1],u[2],u[5],u[8],l[2],0,0,0,1);var u,l;const f=this.On(t),d=[],m=this.lt(t.V).Ut;ts$1.set(m[0],m[1]);const p=n.pointAtResToCoord(ts$1,s),b=Jr$1;for(let t=0;t<is$1.length;t+=3){b[0]=is$1[t],b[1]=is$1[t+1],b[2]=is$1[t+2],transformMat4$2(b,b,h),re$1(b,b),r&&e.Ve(b,b);const o=Wr$1.set(...b);let a=n.coordToPointAtRes(o,s,ts$1);a=set$4(b,a.x,a.y,n.altitudeToPoint(o.z,s)),d[t]=a[0]-m[0],d[t+1]=a[1]-m[1],d[t+2]=a[2]-m[2]}return{obbox:this._n(d,m,f),boxPosition:d,boxCenter:f,coordCenter:p}}vn(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=e.boundingVolume.sphere;let a=Jr$1;0===i[0]&&0===i[1]&&0===i[2]?a=[0,0,-6378137]:re$1(a,i),s&&r.Ve(a,a);const c=new t__namespace.Coordinate(a),h=this.Jt(c,ts$1).toArray();h[2]=n.altitudeToPoint(c.z,n.getGLRes());const u=this.Mn(c);return[h,i[3]*u[2]]}_n(t,e,n){const[r,s,o]=e,a=set$4(Jr$1,(t[3]+t[12])/2+r,(t[4]+t[13])/2+s,(t[5]+t[14])/2+o),c=set$4(Qr$1,(t[3]+t[18])/2+r,(t[4]+t[19])/2+s,(t[5]+t[20])/2+o),h=set$4(Kr$1,(t[3]+t[9])/2+r,(t[4]+t[10])/2+s,(t[5]+t[11])/2+o),u=n.slice(0);return u[3]=a[0]-n[0],u[4]=a[1]-n[1],u[5]=a[2]-n[2],u[6]=c[0]-n[0],u[7]=c[1]-n[1],u[8]=c[2]-n[2],u[9]=h[0]-n[0],u[10]=h[1]-n[1],u[11]=h[2]-n[2],u}On(e){const n=this.getMap(),r=this.getRenderer(),s="identity"===n.getProjection().code.toLowerCase(),i=n.getGLRes(),o=e.boundingVolume.box.slice(0,3);re$1(o,o),s&&r.Ve(o,o);const a=new t__namespace.Coordinate(o),c=n.coordToPointAtRes(a,i);return[c.x,c.y,n.altitudeToPoint(a.z,i)]}pn(t){const e=this.H(t.V);if(!t.boundingVolume||this.xn(t,e))return;const r=t.boundingVolume.region,s=t.boundingVolume.sphere;let i=null;t.boundingVolume.box?i=this.An(t).pointCenter:r?i=this.In(t).pointCenter:s&&(i=this.vn(t)[0]);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Sn=[a[0]||0,a[1]||0],t.dt=o,t.Ut=i}xn(t,e){if(!t.Sn)return!1;const n=e.coordOffset||ss$1;return t.Sn[0]===n[0]&&t.Sn[1]===n[1]&&t.dt===(e.heightOffset||0)}In(t){return t.boundingVolume?(this.un(t),this.yn(t)):null}An(e){if(!e.boundingVolume)return null;this.un(e);const n=e.boundingVolume.box.slice(0,3);re$1(n,n);const r=new t__namespace.Coordinate(n);return{pointCenter:this.On(e),coordCenter:r}}Tn(t,e){let n=t.slice(3,12);return n=function(t,e,n){const s=t[1]*e[0]+t[4]*e[1]+t[7]*e[2],i=t[2]*e[0]+t[5]*e[1]+t[8]*e[2],o=t[0]*e[3]+t[3]*e[4]+t[6]*e[5],a=t[1]*e[3]+t[4]*e[4]+t[7]*e[5],c=t[2]*e[3]+t[5]*e[4]+t[8]*e[5],h=t[0]*e[6]+t[3]*e[7]+t[6]*e[8],u=t[1]*e[6]+t[4]*e[7]+t[7]*e[8],l=t[2]*e[6]+t[5]*e[7]+t[8]*e[8];return n[0]=t[0]*e[0]+t[3]*e[1]+t[6]*e[2],n[1]=s,n[2]=i,n[3]=o,n[4]=a,n[5]=c,n[6]=h,n[7]=u,n[8]=l,n}(this.En(e,[]),n,n),n}En(t,e){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}Mn(t){const e=this.getMap(),n=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let r;return r=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:n.y/100,set$4(Zr$1,n.x/100*1.01,n.y/100*1.01,r),Zr$1}dn(e){Array.isArray(e)&&(e=new t__namespace.Coordinate(e));let n=this.options.offset;if(dt$2(n)&&(n=n.call(this,Array.isArray(e)?new t__namespace.Coordinate(e):e)),n[0]||n[1]){const t=this.getMap(),r=t.getGLRes(),s=t.coordToPointAtRes(e,r);return s._sub(n),t.pointAtResToCoord(s,r)}return e}lt(t){return this.Re[t]}nn(e){const n=this.H(e).maxExtent;if(!n)return null;const r=this.Re[e];return r.maxExtent||(r.maxExtent=new t__namespace.Extent(n).convertTo((t=>this.Jt(t)))),r.maxExtent}gn(t){const e=this.tn,n=t.geometricError;if(0===n)return t.Me=0,0;const r=this.getMap();let s;t.boundingVolume.region?s=function(t,e,n){return t.Nn||(t.Nn=new Vr$1(t.boundingVolume.region)),t.Nn.distanceToCamera(e,n)}(t,this.We,this.Ye):t.boundingVolume.sphere?s=as$1(t.boundingVolume,this.We):t.boundingVolume.box&&(s=cs$1(t.boundingVolume,this.We));const i=Math.max(Math.abs(s),1e-7),o=n*r.height/(i*e);return t.bt=s,t.Me=o,o}Ke(){const t=this.getRenderer();t&&t.setToRedraw()}Ft(t){return this.Bt[t]}identify(e,n={}){const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.coordToContainerPoint(new t__namespace.Coordinate(e));return this.identifyAtPoint(i,n)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&It$2(n,r)}const r=this.getMap(),s=this.getRenderer();if(!r||!s)return[];const i=r.getDevicePixelRatio();return It$2(n,s.pick(t.x*i,t.y*i,e)),n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Kt():[]}highlight(t){const e=this.getRenderer();return e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}Cn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}setServiceDebugBoundingVolume(t,e){const n=this.options.services[t];n&&(n.debugShowBoundingVolume=e);const r=this.getRenderer();return r?(r.setToRedraw(),this):this}Ze(t){const e=this.getMap(),n=e.getGLRes();ns$1.set(t[0],t[1]);const r=e.pointAtResToCoord(ns$1,n);return"identity"===e.getProjection().code.toLowerCase()?(Qr$1[0]=r.x,Qr$1[1]=r.y,this.getRenderer().qe(Jr$1,Qr$1),r.set(Jr$1[0],Jr$1[1]),r):r}toJSON(){return{type:this.getJSONType(),id:this.getId(),options:this.config()}}}function as$1(t,e){const r=dist$2(t.sphere,e),s=t.sphere[3];return r<s?0:r-s}function cs$1(t,e){const n=t.box;return function(t,e,n){return Math.sqrt(function(t,e,n){const r=subtract$2(Or$1,n,t),s=vr$1(_r$1,e,0),i=vr$1(Mr$1,e,1),o=vr$1(xr$1,e,2),a=len$4(s),c=len$4(i),h=len$4(o);normalize$4(s,s),normalize$4(i,i),normalize$4(o,o);const u=Ar$1;u[0]=dot$4(r,s),u[1]=dot$4(r,i),u[2]=dot$4(r,o);let l,f=0;return u[0]<-a?(l=u[0]+a,f+=l*l):u[0]>a&&(l=u[0]-a,f+=l*l),u[1]<-c?(l=u[1]+c,f+=l*l):u[1]>c&&(l=u[1]-c,f+=l*l),u[2]<-h?(l=u[2]+h,f+=l*l):u[2]>h&&(l=u[2]-h,f+=l*l),f}(t,e,n))}(set$4(Jr$1,n[0],n[1],n[2]),set$6(es$1,n[3],n[4],n[5],n[6],n[7],n[8],n[9],n[10],n[11]),e)}function hs$1(t,e,n){const s=(t=yt$2(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{service:n,visible:lt$2(n.visible)?1:n.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:identity$2([]),V:e,W:0,domainKey:s}}function us$1(t,e,n,r,s,i,o,a,c,h,u,l,f,d,m,p){this[0]=t||0,this[1]=s||0,this[2]=c||0,this[3]=f||0,this[4]=e||0,this[5]=i||0,this[6]=h||0,this[7]=d||0,this[8]=n||0,this[9]=o||0,this[10]=u||0,this[11]=m||0,this[12]=r||0,this[13]=a||0,this[14]=l||0,this[15]=p||0}os$1.mergeOptions($r$1),os$1.registerRenderer("gl",yr$1),os$1.registerJSONType("Geo3DTilesLayer");let ls$1=null;function fs$1(){return ls$1||(ls$1={"image/crn":tr$1.crn&&tr$1.crn(),"image/ktx2":tr$1.ktx2&&tr$1.ktx2(),"image/cttf":tr$1.ktx2&&tr$1.ktx2(),draco:tr$1.draco&&tr$1.draco()}),ls$1}class ds$1{constructor(t,e,n){this.Pn=t,this.Rn=e||X$8,this.Pe=n,this.Ln=fs$1()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.kn(t,e,n,r,s)):w$5.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.kn(t,s,n,r)}))}kn(t,e,n,r,s){const i=s&&s.maxTextureSize,o=this.Bn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/")),c=new this.Rn(a,o.glb,{transferable:!0,requestImage:this.Pn,decoders:this.Ln,supportedFormats:this.Pe,maxTextureSize:i});return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const s=c.transferables;for(let t=0;t<o.transferables.length;t++)s.indexOf(o.transferables[t])<0&&s.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:s,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Bn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported b3dm version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=s.getUint32(12,!0),c=s.getUint32(16,!0),h=s.getUint32(20,!0),u=s.getUint32(24,!0),l=28+e;h>=570425344?(l-=8,o=a,h=c,u=0,a=0,c=0):u>=570425344&&(l-=4,o=h,h=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=me$1(t,l,a),l+=a,o=d.BATCH_LENGTH):d={BATCH_LENGTH:o},c>0&&(l+=c),h>0&&(m=pe$1(t,l,h),l+=h,u>0)){const e=be$1(0,l,u);p=t.slice(e.offset,e.offset+e.byteLength),l+=u,f.push(p)}const b=d.BATCH_LENGTH,g={};if(d&&d.BATCH_ID){g.BATCH_ID=ye$1(d.BATCH_ID,t,(void 0).offset,b);const e=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:g,glb:{buffer:t,byteOffset:l,byteLength:s.byteLength+s.byteOffset-l}}}Un(){return null}}class ms$1{constructor(t,e,n,r){this.Pn=t,this.Rn=e||X$8,this.Pe=n,this.Ln=fs$1(),this.Fn=r}load(t,e,n=0,r=0,s){return e?(r||(r=e.byteLength),this.kn(t,e,n,r,s)):w$5.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.kn(t,s,n,r)}))}kn(t,e,n,r,s){return this.Dn(t,e,n,r,s).then((({gltf:s,transferables:i})=>{const o=this.zn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<i.length;t++)-1===o.transferables.indexOf(i[t])&&o.transferables.push(i[t]);return delete s.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:s})}))}Dn(t,e,n,r,s){const o={transferable:!0,requestImage:this.Pn,decoders:this.Ln,supportedFormats:this.Pe,maxTextureSize:s&&s.maxTextureSize},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=Tt$2(new Uint8Array(e,c+n,a.byteLength-c));return-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r),r.indexOf(".glb")>0?w$5.getArrayBuffer(r,{}).then((t=>this.jn(r,{buffer:t.data,byteOffset:0},o))):w$5.getJSON(r,{}).then((t=>this.jn(r,t,o)))}return this.jn(t,{buffer:e,byteOffset:c+n,byteLength:a.byteLength-c},o)}jn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),s=new this.Rn(r,e,n);return s.load({skipAttributeTransform:!0}).then((n=>{let r=0,i=0;return e.buffer&&(r=e.byteOffset||0,i=e.byteLength||0),n.url=`${t}-${r}-${i}`,{transferables:s.transferables,gltf:n}}))}zn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=Ae$1(s,32+e,o),l={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;l.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;l.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Gn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(l.POSITION.array.buffer)}if(a.BATCH_ID){l.BATCH_ID=ye$1(a.BATCH_ID,t,c.offset,f);const e=l.BATCH_ID.array&&l.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;l.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Hn(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,l.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Hn(new Uint16Array(t,e+c.offset,2*f))},o.push(l.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;l.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(l.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;l.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(l.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:h,batchTableBin:u,featureTable:a,i3dm:l,transferables:o}}Hn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let s=0;s<e;s++)ps$1(r,t[2*s],t[2*s+1],65535),n[3*s]=r[0],n[3*s+1]=r[1],n[3*s+2]=r[2];return n}Gn(t,e,n){return xe$1(new Float32Array(t.length),t,e,n)}Un(){return null}}function ps$1(t,e,n,r){if(t[0]=bs$1(e,r),t[1]=bs$1(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*gs$1(e),t[1]=(1-Math.abs(e))*gs$1(t[1])}return normalize$4(t,t)}function bs$1(t,e){return function(t,e,n){return t<0?0:t>n?n:t}(t,0,e=function(t,e){return null!=t?t:255}(e))/e*2-1}function gs$1(t){return t<0?-1:1}class ys$1{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.kn(t,e,n,r)):w$5.getArrayBuffer(t,{}).then((e=>{const s=e.data;return r||(r=s.byteLength),this.kn(t,s,n,r)}))}kn(t,e,n,r){return this.Vn(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}Vn(t,e,n,r){const s=new DataView(t,e,n),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported pnts version: "+i+", url:"+r;return console.warn(t),{error:t}}if(s.getUint32(8,!0)!==s.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:h,batchTableBin:u}=Ae$1(s,e+28,o),l=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.qn||(this.qn=fs$1().draco),this.qn(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.$n(t,e.attributes,c.offset,d,o,l,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Me$1(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(h).length){r.BATCH_ID=a.BATCH_ID?ye$1(a.BATCH_ID,t,c.offset,d):ws$1(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:r,transferables:o}}))}const b=this.$n(t,a,c.offset,d,o,l,f);if(a.BATCH_ID||Object.keys(h).length){b.BATCH_ID=a.BATCH_ID?ye$1(a.BATCH_ID,t,c.offset,d):ws$1(d);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:h,batchTableBin:u,featureTable:a,pnts:b,transferables:o})}$n(t,e,n,r,s,i,o){const a={};if(e.POSITION){let{byteOffset:i,array:o}=e.POSITION;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:h}=e.POSITION_QUANTIZED;c=c||0;const u=h?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Gn(h||new Uint16Array(t,c+u,3*r),i,o)},s.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:i,array:o}=e.RGBA;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB){let{byteOffset:i,array:o}=e.RGB;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},s.push(o.buffer)}else if(e.RGB565){let{byteOffset:i,array:o}=e.RGB565;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},s.push(o.buffer)}if(e.NORMAL){let{byteOffset:i,array:o}=e.NORMAL;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},s.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:i,array:o}=e.NORMAL_OCT16P;i=i||0;const c=o?0:n;if(!o){const e=t.slice(i+c,i+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},s.push(o.buffer)}return a}Gn(t,e,n){return xe$1(new Float32Array(t.length),t,e,n)}Un(){return null}}function ws$1(t){const e=Mt$2(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Me$1(e),array:n}}class vs$1{constructor(t,e,n,r){this.Pe=n,this.Pn=t,this.Rn=e||X$8,this.Fn=r}load(t,e,n=0,r=0,s){return e?this.kn(t,e,n,r,s):w$5.getArrayBuffer(t,{}).then((e=>this.kn(t,e.data,n,r)))}kn(t,e,n,r,s){r||(r=e.byteLength);const i=this.Xn(e,t,n,r),o=[];for(let n=0;n<i.length;n++){let r;if("b3dm"===i[n].magic)r=new ds$1(this.Pn,this.Rn,this.Pe);else if("i3dm"===i[n].magic)r=new ms$1(this.Pn,this.Rn,this.Pe,this.Fn);else if("pnts"===i[n].magic)r=new ys$1;else{if("cmpt"!==i[n].magic){console.warn("Unsupported magic in CMPT tile:",i[n].magic);continue}r=new vs$1(this.Pn,this.Rn,this.Pe,this.Fn)}o.push(r.load(t,e,i[n].offset,i[n].byteLength,s).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}Xn(t,e,n,r){const s=new DataView(t,n,r),i=s.getUint32(4,!0);if(1!==i){const t="Unsupported cmpt version: "+i+", url:"+e;return console.warn(t),{error:t}}if(16===s.byteLength)return[];const o=[],a=s.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=fe$1(s,c),r=s.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(transcoders){const n=t__namespace.Map.VERSION;if(n.indexOf("1.0.0-beta")>=0||n.indexOf("1.0.0-alpha")>=0){const n=transcoders.inject(T$3);t__namespace.registerWorkerAdapter("@maptalks/3dtiles",n)}else t__namespace.registerWorkerAdapter("@maptalks/3dtiles",(function(){return transcoders.inject(T$3)}))}else t__namespace.registerWorkerAdapter("@maptalks/3dtiles",T$3);for(
/*!
	* Contains code from THREE.js
	* MIT License
	* https://github.com/mrdoob/three.js
	*/
var planes=[],i=0;i<6;i++)planes[i]=[];var p$3=[];function intersectsBox(matrix,box,mask){!function(m){var me0=m[0],me1=m[1],me2=m[2],me3=m[3],me4=m[4],me5=m[5],me6=m[6],me7=m[7],me8=m[8],me9=m[9],me10=m[10],me11=m[11],me12=m[12],me13=m[13],me14=m[14],me15=m[15];setComponents(planes[0],me3-me0,me7-me4,me11-me8,me15-me12),setComponents(planes[1],me3+me0,me7+me4,me11+me8,me15+me12),setComponents(planes[2],me3+me1,me7+me5,me11+me9,me15+me13),setComponents(planes[3],me3-me1,me7-me5,me11-me9,me15-me13),setComponents(planes[4],me3-me2,me7-me6,me11-me10,me15-me14),setComponents(planes[5],me3+me2,me7+me6,me11+me10,me15+me14)}(matrix);for(var i=0;i<6;i++)if(!mask||"0"!==mask.charAt(i)){var plane=planes[i];if(p$3[0]=plane[0]>0?box[1][0]:box[0][0],p$3[1]=plane[1]>0?box[1][1]:box[0][1],p$3[2]=plane[2]>0?box[1][2]:box[0][2],distanceToPoint(plane,p$3)<0)return!1}return!0}function setComponents(out,x,y,z,w){var inverseNormalLength=1/Math.sqrt(x*x+y*y+z*z);return out[0]=x*inverseNormalLength,out[1]=y*inverseNormalLength,out[2]=z*inverseNormalLength,out[3]=w*inverseNormalLength,out}function distanceToPoint(plane,p){return plane[0]*p[0]+plane[1]*p[1]+plane[2]*p[2]+plane[3]}
/*!
	 * @maptalks/gltf-layer v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */const T$2='function(t){var e="undefined"!=typeof Float32Array?Float32Array:Array;function n(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3],a=e[4],c=e[5],u=e[6],h=e[7],f=e[8],l=e[9],d=e[10],m=e[11],g=e[12],p=e[13],_=e[14],b=e[15],y=n[0],w=n[1],A=n[2],x=n[3];return t[0]=y*r+w*a+A*f+x*g,t[1]=y*s+w*c+A*l+x*p,t[2]=y*i+w*u+A*d+x*_,t[3]=y*o+w*h+A*m+x*b,y=n[4],w=n[5],A=n[6],x=n[7],t[4]=y*r+w*a+A*f+x*g,t[5]=y*s+w*c+A*l+x*p,t[6]=y*i+w*u+A*d+x*_,t[7]=y*o+w*h+A*m+x*b,y=n[8],w=n[9],A=n[10],x=n[11],t[8]=y*r+w*a+A*f+x*g,t[9]=y*s+w*c+A*l+x*p,t[10]=y*i+w*u+A*d+x*_,t[11]=y*o+w*h+A*m+x*b,y=n[12],w=n[13],A=n[14],x=n[15],t[12]=y*r+w*a+A*f+x*g,t[13]=y*s+w*c+A*l+x*p,t[14]=y*i+w*u+A*d+x*_,t[15]=y*o+w*h+A*m+x*b,t}function r(){var t=new e(3);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function s(t,n,r){var s=new e(3);return s[0]=t,s[1]=n,s[2]=r,s}function i(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function o(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function a(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function c(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function u(t,e,n,r,s){return t[0]=e,t[1]=n,t[2]=r,t[3]=s,t}function h(t,e,n){var r=e[0],s=e[1],i=e[2],o=e[3];return t[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,t[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,t[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,t[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,t}function f(){var t=new e(4);return e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}function l(t,e,n,r){var s=e[0],i=e[1],o=e[2],a=e[3],c=n[0],u=n[1],h=n[2],f=n[3],l=void 0,d=void 0,m=void 0,g=void 0,p=void 0;return(d=s*c+i*u+o*h+a*f)<0&&(d=-d,c=-c,u=-u,h=-h,f=-f),1-d>1e-6?(l=Math.acos(d),m=Math.sin(l),g=Math.sin((1-r)*l)/m,p=Math.sin(r*l)/m):(g=1-r,p=r),t[0]=g*s+p*c,t[1]=g*i+p*u,t[2]=g*o+p*h,t[3]=g*a+p*f,t}r(),function(){var t,n=(t=new e(4),e!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var d,m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t};r(),s(1,0,0),s(0,1,0),f(),f(),d=new e(9),e!=Float32Array&&(d[1]=0,d[2]=0,d[3]=0,d[5]=0,d[6]=0,d[7]=0),d[0]=1,d[4]=1,d[8]=1;\n/*!\n   * @maptalks/gltf-loader v0.95.2\n   * LICENSE : UNLICENSED\n   * (c) 2016-2024 maptalks.org\n   */\nlet g=0;function p(t){return null==t}function _(t){return!p(t)}function b(t){return!p(t)&&("string"==typeof t||null!==t.constructor&&t.constructor===String)}function y(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function w(t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5124:return Int32Array;case 5125:return Uint32Array;case 5126:return Float32Array}throw new Error("unsupported bufferView\'s component type: "+t)}function A(t){return 0===t.indexOf("data:")&&t.indexOf("base64,")>0}function x(t){const e=function(t){return"undefined"!=typeof self?self.atob(t):window.atob(t)}(t.substring(t.indexOf(",")+1)),n=e.length,r=new Uint8Array(n);for(let t=0;t<n;t++)r[t]=e.charCodeAt(t);return r.buffer}const I=[],T=[],M=[],v=[0,0,0],O=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),E=[1,1,1];function P(t,e,n,r,s,i,o){const a=w(o);if((0===s||s===r*a.BYTES_PER_ELEMENT)&&i%a.BYTES_PER_ELEMENT==0){const s=new a(e,i,n*r);return t.set(s),t}0===s&&(s=r*a.BYTES_PER_ELEMENT);const c=new Uint8Array(r*a.BYTES_PER_ELEMENT);for(let o=0;o<n;o++){let n=null;const u=new Uint8Array(e,s*o+i,r*a.BYTES_PER_ELEMENT);c.set(u),n=new a(c.buffer,0,r);for(let e=0;e<r;e++)t[o*r+e]=n[e]}return t}const k="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function N(t,e,n){const r=new Uint8Array(t,e,n);return k.decode(r)}const S={get:function(t,e={}){e||(e={});const n=new AbortController,r=n.signal,s=y({},e);s.signal=r,s.method||(s.method="GET");const i=fetch(t,s).then(t=>{const n=this.t(t,e.responseType);return n.message?n:n.then(n=>"arraybuffer"===e.responseType?{data:n,cacheControl:t.headers.get("Cache-Control"),expires:t.headers.get("Expires"),contentType:t.headers.get("Content-Type")}:n).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t})}).catch(t=>{if(!t.code||t.code!==DOMException.ABORT_ERR)throw t});return i.xhr=n,i},t:(t,e)=>200!==t.status?{status:t.status,statusText:t.statusText,message:`incorrect http request with status code(${t.status}): ${t.statusText}`}:"arraybuffer"===e?t.arrayBuffer():"json"===e?t.json():t.text(),getArrayBuffer:(t,e={})=>(e||(e={}),e.responseType="arraybuffer",S.get(t,e)),getJSON:function(t,e={}){return e&&e.jsonp?S.jsonp(t):((e=e||{}).responseType="json",S.get(t,e))},jsonp:function(t){const e="_maptalks_jsonp_"+g++;t.match(/\\?/)?t+="&callback="+e:t+="?callback="+e;let n=document.createElement("script");return n.type="text/javascript",n.src=t,new Promise(t=>{window[e]=function(r){document.getElementsByTagName("head")[0].removeChild(n),n=null,delete window[e],t(r)},document.getElementsByTagName("head")[0].appendChild(n)})}};class B{constructor(t,e,n,r){this.s=t,this.decoders=e,this.i=n,this.images={},this.o={},this.u=r||{}}requestImageFromBufferURI(t,e,n){if(this.buffers[t.id]){const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)}if(this.o[t.id])return this.o[t.id].then(()=>{const r=this.buffers[t.id],s=this.h(e,r);return this.getImageByBuffer(s,n)});if(A(t.uri)){const r=this.buffers[t.id]=x(t.uri),s=this.h(e,r);return this.getImageByBuffer(s,n)}let r;const s=t.uri.indexOf("blob:")>=0;return r=t.uri.indexOf("://")>0||s?t.uri:this.rootPath+"/"+t.uri,this.o[t.id]=S.getArrayBuffer(r,this.u).then(r=>{const s=this.buffers[t.id]=r.data,i=this.h(e,s);return this.getImageByBuffer(i,n)})}getImageByBuffer(t,e){if(this.images[e.id])return Promise.resolve(this.images[e.id]);const n=this.decoders;return n[e.mimeType]?n[e.mimeType](t,{supportedFormats:this.i}):"image/crn"===e.mimeType||"image/ktx2"===e.mimeType||"image/cttf"===e.mimeType?(console.warn("missing transcoder for "+e.mimeType,", visit https://maptalks.com/docs/transcoders for details"),Promise.resolve(null)):this.l(e.id,t)}requestExternalImage(t){if(this.images[t.id])return Promise.resolve(this.images[t.id]);const e=0===t.uri.indexOf("data:image/")?t.uri:this.rootPath+"/"+t.uri;return this.o[t.id]?this.o[t.id].then(()=>this.images[t.id]):this.o[t.id]=this.l(t.id,e)}l(t,e){return new Promise((n,r)=>{this.s(e,this.u,(s,i)=>{s?r(s):(URL.revokeObjectURL(e),this.images[t]=i,n(this.images[t]))})})}}const R=["SCALAR",1,"VEC2",2,"VEC3",3,"VEC4",4,"MAT2",4,"MAT3",9,"MAT4",16],C=[];class U{constructor(t,e,n,r){this.rootPath=t,this.gltf=e,this.m=!1,this.glbBuffer=n,this.buffers={},this.requests={},this.accessors={},this.g(),this.u=r}p(t,e){const n=this.gltf,r=n.accessors[e];if(void 0===r.bufferView)return this.accessors[r.id]=this._(t,e,null,0),Promise.resolve(this.accessors[r.id]);if(r&&this.accessors[r.id])return Promise.resolve(this.accessors[r.id]);const s=n.bufferViews[r.bufferView];return this.A(s).then(n=>{const{buffer:s,byteOffset:i}=n;return this.accessors[r.id]=this._(t,e,s,i)})}A(t){const e=this.gltf.buffers[t.buffer];if(this.buffers[e.id]){const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})}if(this.requests[e.id])return this.requests[e.id].then(()=>{const t=this.buffers[e.id];return Promise.resolve({buffer:t,byteOffset:0})});if("binary_glTF"!==t.buffer&&"KHR_binary_glTF"!==t.buffer&&e.uri){if(A(e.uri)){const t=this.buffers[e.id]=x(e.uri);return Promise.resolve({buffer:t,byteOffset:0})}let t;const n=e.uri.indexOf("blob:")>=0;return t=e.uri.indexOf("://")>0||n?e.uri:this.rootPath+"/"+e.uri,this.requests[e.id]=S.getArrayBuffer(t,this.u).then(r=>(n&&URL.revokeObjectURL(t),{buffer:this.buffers[e.id]=r.data,byteOffset:0}))}return Promise.resolve({buffer:this.glbBuffer.buffer,byteOffset:this.glbBuffer.byteOffset})}_(t,e,n,r=0){const s=this.gltf,i=s.accessors[e],o=void 0!==i.bufferView?s.bufferViews[i.bufferView]:{},a=(o.byteOffset||0)+r,c=this.I(i.type),u=w(i.componentType),f=o.byteStride||0,l={array:void 0,name:t,accessorName:e,byteLength:i.count*c*u.BYTES_PER_ELEMENT,componentType:i.componentType,count:i.count,type:i.type,itemSize:c,max:i.max,min:i.min,extensions:i.extensions};if(i.min&&(l.min=i.min),i.max&&(l.max=i.max),n)if(this.m)l.byteStride=f,l.byteOffset=a+(i.byteOffset||0),!f||f===c*u.BYTES_PER_ELEMENT||"indices"===t||"input"===t||"output"===t||t.indexOf("morph")>=0?(l.array=this.T(n,i.count,c,a+(i.byteOffset||0),u),l.array.buffer.byteLength===l.byteLength&&(l.byteOffset=0)):l.array=new Uint8Array(n,a,o.byteLength);else if(i.interleaved){l.byteStride=0,l.byteOffset=0;const t=new u(i.count*c);if(l.array=P(t,n,i.count,c,f,a+(i.byteOffset||0),i.componentType),l.extensions&&l.extensions.WEB3D_quantized_attributes&&c>2){const t=new Float32Array(l.array.length),{decodeMatrix:e}=l.extensions.WEB3D_quantized_attributes;for(let n=0;n<l.array.length;n+=c){C[0]=l.array[n],C[1]=l.array[n+1],C[2]=l.array[n+2],C[3]=1;const r=h(C,C,e);t[n]=r[0],t[n+1]=r[1],t[n+2]=r[2]}l.componentType=5126,l.array=t}}else l.byteStride=0,l.array=this.T(n,i.count,c,a+(i.byteOffset||0),u),l.byteOffset=l.array.byteOffset;else{l.array=new u(i.count);const t=l.min||l.max;t&&(l.array[0]=t[0],l.array[1]=t[1],l.array[2]=t[2])}return l}g(){const t=this.gltf.accessors;if(Array.isArray(t))for(let e=0;e<t.length;e++)for(let n=0;n<t.length;n++)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0);else for(const e in t)for(const n in t)e!==n&&t[e].bufferView===t[n].bufferView&&(t[e].interleaved=t[n].interleaved=!0)}T(t,e,n,r,s){return r%s.BYTES_PER_ELEMENT!=0&&(t=t.slice(r,r+e*n*s.BYTES_PER_ELEMENT),r=0),new s(t,r,n*e)}I(t){const e=R.indexOf(t);return R[e+1]}requestKHRTechniquesWebgl(t){const{shaders:e}=t,n=e.map(t=>{if(void 0!==t.bufferView){const e=this.gltf.bufferViews[t.bufferView],{byteLength:n}=e;return this.A(e).then(r=>{const{buffer:s,byteOffset:i}=r,o=N(s,i+(e.byteOffset||0),n);return t.content=o,t})}if(t.uri){if(A(t.uri)){const e=x(t.uri),n=N(e,0,e.byteLength);return t.content=n,Promise.resolve(t)}{const e=this.rootPath+"/"+t.uri;return S.get(e,this.u).then(e=>(t.content=e,t))}}return Promise.resolve(t)});return Promise.all(n).then(()=>t)}}class L extends B{constructor(t,e,n,r,s,i,o){super(r,s,i,o),this.rootPath=t,this.gltf=e,this.requests={},this.buffers={},this.glbBuffer=n,this.accessor=new U(t,e,n,o)}iterate(t,e){const n=this.gltf[e];if(!n)return;let r=0;for(const e in n)t(e,n[e],r++)}createNode(t){const e={};if(_(t.name)&&(e.name=t.name),_(t.children)&&(e.children=t.children),_(t.jointName)&&(e.jointName=t.jointName),_(t.matrix)&&(e.matrix=t.matrix),_(t.rotation)&&(e.rotation=t.rotation),_(t.scale)&&(e.scale=t.scale),_(t.translation)&&(e.translation=t.translation),_(t.extras)&&(e.extras=t.extras),_(t.meshes)&&(e.mesh=t.meshes[0]),e.translation||e.rotation||e.scale){const t=function(t,e){if(e.matrix)return e.matrix;if(e.translation||e.scale||e.rotation){const r=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(I,e.translation||v),s=function(t,e){var n=e[0],r=e[1],s=e[2],i=e[3],o=n+n,a=r+r,c=s+s,u=n*o,h=r*o,f=r*a,l=s*o,d=s*a,m=s*c,g=i*o,p=i*a,_=i*c;return t[0]=1-f-m,t[1]=h+_,t[2]=l-p,t[3]=0,t[4]=h-_,t[5]=1-u-m,t[6]=d+g,t[7]=0,t[8]=l+p,t[9]=d-g,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(T,e.rotation||O),i=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(M,e.scale||E);return n(i,s,i),n(t,r,i)}return function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(t)}([],e);delete e.translation,delete e.rotation,delete e.scale,e.matrix=t}return e}M(t){const e={};for(const n in t){const r=t[n];let s,i;r.instanceTechnique&&r.instanceTechnique.values?(s=r.instanceTechnique,i=s.values.diffuse):(s=r,i=s.values.tex||s.values.diffuseTex||s.values.diffuse);const o={baseColorTexture:{index:i}};r.name&&(o.name=r.name),r.extensions&&(o.extensions=r.extensions),r.extras&&(o.extras=r.extras),e[n]=o}return e}v(t){if(t.bufferView||t.extensions&&(t.extensions.KHR_binary_glTF||t.extensions.binary_glTF)){const e=t.bufferView?t:t.extensions.KHR_binary_glTF||t.extensions.binary_glTF;t.extensions&&(t.mimeType=e.mimeType,t.width=e.width,t.height=e.height);const n=this.gltf.bufferViews[e.bufferView],r=(n.byteOffset||0)+this.glbBuffer.byteOffset,s=n.byteLength,i=this.buffers[e.bufferView]=new Uint8Array(this.glbBuffer.buffer,r,s);return this.getImageByBuffer(i,t)}return this.requestExternalImage(t)}O(t){const e=this.gltf.textures[t];if(!e)return null;const n=this.gltf.images[e.source];return this.v(n).then(t=>{const r=this.gltf.samplers[e.sampler];return{image:{array:t.data,width:t.width,height:t.height,index:e.source,mimeType:n.mimeType,name:n.name,extras:n.extras},sampler:r}})}getBaseColorTexture(t){const e=this.gltf.materials[t];let n,r;if(e.instanceTechnique&&e.instanceTechnique.values?(n=e.instanceTechnique,r=n.values.diffuse):(n=e,r=n.values.tex||n.values.diffuseTex||n.values.diffuse),void 0===r||void 0===this.gltf.textures)return null;const s=this.gltf.textures[r];if(!s)return null;const i=this.gltf.samplers[s.sampler];return{format:s.format||6408,internalFormat:s.internalFormat||6408,type:s.type||5121,sampler:i,source:this.gltf.images[s.source]}}getMaterial(){return null}getAnimations(){return null}}class D extends B{constructor(t,e,n,r,s,i,o){super(r,s,i,o),this.rootPath=t,this.gltf=e,this.glbBuffer=n,this.buffers={},this.requests={},this.accessor=new U(t,e,n,o)}iterate(t,e){const n=this.gltf[e];if(n)for(let e=0;e<n.length;e++)t(e,n[e],e)}createNode(t){const e={};return y(e,t),!_(t.weights)&&this.gltf.meshes&&_(e.mesh)?e.weights=this.gltf.meshes[e.mesh].weights:t.weights&&(e.weights=t.weights),e}O(t){const e=this.gltf.textures[t];if(!e)return null;let n=e.source;if(e.extensions&&e.extensions.EXT_texture_webp&&(n=e.extensions.EXT_texture_webp.source),!_(n))return null;const r=this.gltf.images[n];return this.v(r).then(t=>{if(!t)return null;const n={image:{array:t.data,mipmap:t.mipmap,width:t.width,height:t.height,index:e.source,mimeType:r.mimeType,name:r.name,extensions:r.extensions,extras:r.extras}};y(n,e);const s=_(e.sampler)?this.gltf.samplers[e.sampler]:void 0;return s&&(n.sampler=s,n.sampler.magFilter=s.magFilter||9729,n.sampler.minFilter=s.minFilter||9729,n.sampler.wrapS=s.wrapS||10497,n.sampler.wrapT=s.wrapT||10497),t.format&&(n.format=t.format),n})}v(t){if(!_(t.bufferView))return this.requestExternalImage(t);{const e=this.gltf.bufferViews[t.bufferView],n=this.gltf.buffers[e.buffer];if(n.uri)return this.requestImageFromBufferURI(n,e,t);if(this.glbBuffer)return this.P(e,t)}return null}P(t,e){const n=this.h(t,this.glbBuffer.buffer,this.glbBuffer.byteOffset);return this.getImageByBuffer(n,e)}h(t,e,n){n=n||0;const r=t.byteOffset+n,s=t.byteLength;return new Uint8Array(e,r,s)}k(t,e){const n=new Array(t.byteLength);for(let e=0;e<t.byteLength;e++)n[e]=String.fromCharCode(t[e]);return n.join(""),"data:"+(e=e||"image/png")+";base64,"+function(t){return"undefined"!=typeof self?self.btoa(t):window.btoa(t)}(unescape(encodeURIComponent(n)))}getAnimations(t){const e=[];return t.forEach(t=>{e.push(this.getSamplers(t.samplers))}),Promise.all(e).then(e=>{for(let n=0;n<e.length;n++)t[n].samplers=e[n];return t})}getSamplers(t){const e=[];for(let n=0;n<t.length;n++)(_(t[n].input)||_(t[n].output))&&(e.push(this.accessor.p("input",t[n].input)),e.push(this.accessor.p("output",t[n].output)));return Promise.all(e).then(e=>{for(let n=0;n<e.length/2;n++)t[n].input=e[2*n],t[n].output=e[2*n+1],t[n].interpolation||(t[n].interpolation="LINEAR");return t})}}const q="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;class F{static read(t,e=0,n=0){n||(n=t.byteLength);const r=new DataView(t,e,n),s=r.getUint32(4,!0);if(1===s)return F.readV1(r,e);if(2===s)return F.readV2(t,e);throw new Error("Unsupported glb version : "+s)}static readV1(t,e){const n=t.getUint32(8,!0),r=t.getUint32(12,!0);if(n!==t.byteLength)throw new Error("Length in GLB header is inconsistent with glb\'s byte length.");const s=j(t.buffer,20+e,r);return{json:JSON.parse(s),glbBuffer:{byteOffset:20+e+r,buffer:t.buffer,byteLength:n}}}static readV2(t,e){let n,r,s;const i=new DataView(t,e+12);let o=0;for(;o<i.byteLength;){const a=i.getUint32(o,!0);o+=4;const c=i.getUint32(o,!0);if(o+=4,1313821514===c)n=j(t,e+12+o,a);else if(5130562===c){s=e+12+o,r=a;break}o+=a}return{json:JSON.parse(n),glbBuffer:{byteOffset:s,buffer:t,byteLength:r}}}}function j(t,e,n){if(q){const r=new Uint8Array(t,e,n);return q.decode(r)}return function(t){const e=t.length;let n="";for(let r=0;r<e;){let s=t[r++];if(128&s){let n=V[s>>3&7];if(!(64&s)||!n||r+n>e)return null;for(s&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;s=s<<6|63&e}}n+=String.fromCharCode(s)}return n}(new Uint8Array(t,e,n))}const V=[1,1,1,1,2,2,3,0],H=[0,0,0],K=[0,0,0,1],$=[1,1,1],G={TRANSLATION:[0,0,0],ROTATION:[0,0,0,1],SCALE:[1,1,1]},X={PREVIOUS:null,NEXT:null,PREINDEX:null,NEXTINDEX:null,INTERPOLATION:null},z={N(t,e,n,r,s,o,a,c){const u=_(t)?e.animations:[e.animations[0]],h={};for(let e=0;e<u.length;e++){const f=u[e],l=f.name||e;if(_(t)&&l!==t)continue;const d=f.channelsMap[n];if(d)for(let t=0;t<d.length;t++){const e=d[t];"translation"===e.target.path?(this.S(s,f.samplers[e.sampler],r,1),h.translation=i(H,s)):"rotation"===e.target.path?(this.B(o,f.samplers[e.sampler],r,1),h.rotation=m(K,o)):"scale"===e.target.path?(this.S(a,f.samplers[e.sampler],r,1),h.scale=i($,a)):"weights"===e.target.path&&c&&(this.S(c,f.samplers[e.sampler],r,c.length),h.weights=c)}}return h},S(t,e,n,r){switch(e.interpolation){case"LINEAR":{const s=this.R(X,e,n,1*r);s&&(t=function(t,e,n,r){for(let s=0;s<t.length;s++)t[s]=e[s]+r*(n[s]-e[s]);return t}(t,s.PREVIOUS,s.NEXT,s.INTERPOLATION));break}case"STEP":{const s=this.R(X,e,n,1*r);s&&(t=function(t,e){for(let n=0;n<t.length;n++)t[n]=e[n];return t}(t,...s.PREVIOUS));break}case"CUBICSPLINE":{const s=this.R(X,e,n,3*r);s&&(t=this.C(t,s,e.input.array,3*r));break}}return t},B(t,e,n){switch(e.interpolation){case"LINEAR":{const r=this.R(X,e,n,1);r&&l(t,r.PREVIOUS,r.NEXT,r.INTERPOLATION);break}case"STEP":{const r=this.R(X,e,n,1);r&&(t=u(t,...r.PREVIOUS));break}case"CUBICSPLINE":{const r=this.R(X,e,n,3);if(r){for(let t=0;t<r.PREVIOUS.length;t++)r.PREVIOUS[t]=Math.acos(r.PREVIOUS[t]),r.NEXT[t]=Math.acos(r.NEXT[t]);t=this.C(t,r,e.input.array,3);for(let e=0;e<t.length;e++)t[e]=Math.cos(t[e])}break}}return t},U(t,e){const n=t.length;let r,s,i,o=0,a=n-1,c=Math.floor((o+a)/2);for(;o<=n-1&&a>=0;){if(o===a)return null;if(t[c]<=e&&e<=t[c+1]){const n=t[c];return r=c,s=c+1,i=(e-n)/(t[c+1]-n),{preIndx:r,nextIndex:s,interpolation:i}}e<t[c]?(a=c,c=Math.floor((o+a)/2)):t[c+1]<e&&(o=c,c=Math.floor((o+a)/2))}return null},R(t,e,n,r){const s=e.input.array,i=e.output.array,o=e.output.itemSize;(n<s[0]||n>s[s.length-1])&&(n=Math.max(s[0],Math.min(s[s.length-1],n))),n===s[s.length-1]&&(n=s[0]);const a=this.U(s,n);if(!a||!a.nextIndex)return null;const{preIndx:c,nextIndex:u,interpolation:h}=a;t.PREINDEX=c,t.NEXTINDEX=u,t.INTERPOLATION=h;const f=o*r;return t.PREVIOUS=i.subarray(t.PREINDEX*f,(t.PREINDEX+1)*f),t.NEXT=i.subarray(t.NEXTINDEX*f,(t.NEXTINDEX+1)*f),t},C(t,e,n,r){const s=e.INTERPOLATION,i=n[e.PREINDEX],o=n[e.NEXTINDEX];for(let n=0;n<3;n++){const a=e.PREVIOUS[r+n],c=(o-i)*e.PREVIOUS[2*r+n],u=e.NEXT[3+n],h=(o-i)*e.NEXT[n],f=(2*Math.pow(s,3)-3*Math.pow(s,2)+1)*a+(Math.pow(s,3)-2*Math.pow(s,2)+s)*c+(2*-Math.pow(s,3)+3*Math.pow(s,2))*u+(Math.pow(s,3)-Math.pow(s,2))*h;t[n]=f}return t},getAnimationClip(t,e,n,r){const s=t.nodes[e]&&t.nodes[e].weights;return o(H,...G.TRANSLATION),u(K,...G.ROTATION),o($,...G.SCALE),this.N(r,t,e,n,H,K,$,s)},getTimeSpan(t){if(!t.animations)return null;if(t.timeSpan)return t.timeSpan;const e=t.animations;return t.timeSpan={},e.forEach((e,n)=>{let r=-1/0,s=1/0;const i=e.channels;for(let t=0;t<i.length;t++){const n=i[t],o=e.samplers[n.sampler].input.array;o[o.length-1]>r&&(r=o[o.length-1]),o[0]<s&&(s=o[0])}const o=e.name||n;t.timeSpan[o]={max:r,min:s}}),t.timeSpan},getTimeSpanByName(t,e){const n=this.getTimeSpan(t);return n?_(e)?n[e]:n[Object.keys(n)[0]]:null}};let J=!1;if("undefined"!=typeof OffscreenCanvas){let t;try{t=new OffscreenCanvas(2,2).getContext("2d")}catch(at){}t&&"undefined"!=typeof createImageBitmap&&(J=!0)}const W="undefined"==typeof document?null:document.createElement("canvas");class Q{constructor(t,e,n){if(this.options=n||{},this.options.decoders||(this.options.decoders={}),this.u=this.options.fetchOptions||{},e.buffer instanceof ArrayBuffer){const{json:n,glbBuffer:r}=F.read(e.buffer,e.byteOffset,e.byteLength);this.L(t,n,r)}else this.L(t,e);this.D=new U(this.rootPath,this.gltf,this.glbBuffer,this.u),this.q()}q(){const t=this.gltf.extensionsRequired;if(t){if(t.indexOf("KHR_draco_mesh_compression")>=0&&!this.options.decoders.draco)throw new Error("KHR_draco_mesh_compression is required but @maptalks/transcoders.draco is not loaded");if(t.indexOf("KHR_texture_basisu")>=0&&!this.options.decoders.ktx2)throw new Error("KHR_texture_basisu is required but @maptalks/transcoders.ktx2 is not loaded")}}F(){const t=this.gltf.extensions;return t&&t.KHR_techniques_webgl?this.D.requestKHRTechniquesWebgl(t.KHR_techniques_webgl).then(e=>(t.KHR_techniques_webgl=e,t)):Promise.resolve(t)}load(t){t=t||{};const e=this.j(t),n=this.V(),r=this.H(),s=this.F();return Promise.all([e,n,r,s]).then(t=>(t[0].animations=t[1],t[0].textures=t[2],t[0].extensions=t[3],t[0].transferables=this.transferables||[],this.createChannelsMap(t[0]),t[0]))}createChannelsMap(t){const e=t.animations;if(e)for(let t=0;t<e.length;t++){const n=e[t];n.channelsMap={};for(let t=0;t<n.channels.length;t++){const e=n.channels[t];n.channelsMap[e.target.node]||(n.channelsMap[e.target.node]=[]),n.channelsMap[e.target.node].push(e)}}}getExternalResources(){const t=[];if(this.gltf){const{buffers:e,images:n}=this.gltf;for(let n=0;n<e.length;n++)e[n].uri&&e[n].uri.indexOf("data:application/octet-stream;base64")<0&&t.push({type:"buffer",uri:e[n].uri});for(let e=0;e<n.length;e++)n[e].uri&&n[e].uri.indexOf("data:image/")<0&&t.push({type:"image",uri:n[e].uri})}return t}static getAnimationClip(t,e,n,r){return z.getAnimationClip(t,e,n,r)}static getAnimationTimeSpan(t,e){return z.getTimeSpanByName(t,e)}static getTypedArrayCtor(t){return w(t)}static readInterleavedArray(t,e,n,r,s,i,o){return P(t,e,n,r,s,i,o)}L(t,e,n){this.gltf=e,this.glbBuffer=n,this.version=e.asset?+e.asset.version:1,this.rootPath=t,this.buffers={},this.requests={},this.options.requestImage=J?et.bind(this):this.options.requestImage||Y,this.options.transferable&&(this.transferables=[]),2===this.version?(this.adapter=new D(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u),this.adapter.iterate((t,e,n)=>{e.id="buffer_"+n},"buffers"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors")):(this.adapter=new L(t,e,n,this.options.requestImage,this.options.decoders||{},this.options.supportedFormats||{},this.u),this.adapter.iterate((t,e,n)=>{e.id="accessor_"+n},"accessors"),this.adapter.iterate((t,e,n)=>{e.id="image_"+n},"images"))}K(t,e){if(t.children&&t.children.length>0){if(!("number"==typeof(n=t.children[0])&&isFinite(n)||b(t.children[0])))return t;const r=t.children.map(t=>{const n=e[t];return n.nodeIndex=t,this.K(n,e)});t.children=r}var n;return t}j(t){return this.$(t).then(t=>{const e=this.scenes=[];let n;for(const e in t)t[e]=this.K(t[e],t),t[e].nodeIndex=Number(e)?Number(e):e;this.adapter.iterate((r,s,i)=>{const o={};s.name&&(o.name=s.name),s.nodes&&(o.nodes=s.nodes.map(e=>t[e])),this.gltf.scene===r&&(n=i),e.push(o)},"scenes");const r={textures:this.gltf.textures,asset:this.gltf.asset,scene:n,scenes:e,nodes:t,meshes:this.meshes,materials:this.gltf.materials,skins:this.skins,extensionsRequired:this.gltf.extensionsRequired,extensionsUsed:this.gltf.extensionsUsed};if(this.gltf.extensions&&(r.extensions=this.gltf.extensions),1===this.version){const t=this.adapter.M(this.gltf.materials);r.materials=t}return delete this.gltf.buffers,r.json=this.gltf,r})}$(t){return this.G(t).then(()=>{const t=this.nodes={};return this.adapter.iterate((e,n)=>{const r=this.adapter.createNode(n,this.meshes,this.skins);t[e]=r},"nodes"),t})}X(){this.skins=[];const t=[];return this.adapter.iterate((e,n,r)=>{t.push(this.J(n).then(t=>{t.index=r,this.skins.push(t)}))},"skins"),t}J(t){const e=t.inverseBindMatrices;return this.adapter.accessor.p("inverseBindMatrices",e).then(e=>(t.inverseBindMatrices=e,e&&e.buffer&&this.transferables&&this.transferables.indexOf(e.buffer)<0&&this.transferables.push(e.buffer),t))}V(){const t=this.gltf.animations;return _(t)?this.adapter.getAnimations(t):null}G(t){this.meshes={};let e=[];return this.adapter.iterate((n,r,s)=>{e.push(this.W(r,t).then(t=>{t.index=s,this.meshes[n]=t}))},"meshes"),e=e.concat(this.X()),Promise.all(e)}W(t,e){const n=t.primitives.map(t=>this.Y(t,e)).filter(t=>!!t);return Promise.all(n).then(e=>{const n={};return y(n,t),n.primitives=e,n})}H(){const t=this.gltf.textures;if(!t)return null;const e=[];for(const n in t)e.push(this.adapter.O(n));return Promise.all(e).then(e=>{if(this.transferables)for(let t=0;t<e.length;t++){const n=e[t].image.array;if(e[t]&&n){let t;t=n instanceof ImageBitmap?n:n.buffer,t&&this.transferables.indexOf(t)<0&&this.transferables.push(t)}}if(!Array.isArray(t)){const n={},r=Object.keys(t);for(let t=0;t<e.length;t++)e[t]&&(n[r[t]]=e[t]);return n}return e})}Y(t,e){let n;const r=[],s=t.extensions;if(_(t.targets))for(let e=0;e<t.targets.length;e++){const n=t.targets[e];for(const t in n){const s=this.adapter.accessor.p(`morphTargets_${t}_${e}`,n[t]);s&&r.push(s)}}if(s&&s.KHR_draco_mesh_compression){if(!this.options.decoders.draco&&(!this.gltf.extensionsRequired||!this.gltf.extensionsRequired.indexOf("KHR_draco_mesh_compression")<0))return null;const t=this.options.decoders.draco,{bufferView:i,attributes:o}=s.KHR_draco_mesh_compression,a=this.gltf.bufferViews[i],c=this.D.A(a).then(n=>{const{buffer:r,byteOffset:s}=n;let{byteOffset:i}=a;const c=a.byteLength;i||(i=0);const u=new DataView(r,s+i,c),h={attributes:o,useUniqueIDs:!1,skipAttributeTransform:e.skipAttributeTransform};return t(u,h).then(t=>{const e=Object.values(t.attributes);return t.indices&&e.push(t.indices),e})});r.push(c),n=Promise.all(r)}else{const e=t.attributes;for(const t in e){const n=this.adapter.accessor.p(t,e[t]);n&&r.push(n)}if(_(t.indices)){const e=this.adapter.accessor.p("indices",t.indices);e&&r.push(e)}n=Promise.all(r)}return n.then(e=>{if(s&&s.KHR_draco_mesh_compression){const n=t.targets?t.targets.length:0;e[n]=e[n].concat(e.slice(0,n)),e=e[n]}let n,r;const i={attributes:e.reduce((t,e)=>{if("indices"===e.name)n=e;else if(e.name.indexOf("morphTargets_")>-1)r=r||{},r[e.name.slice(13)]=e;else{if(!("POSITION"!==e.name||e.min&&e.max)){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0],{itemSize:r,array:s}=e,i=s.length/r;for(let e=0;e<i;e++)for(let i=0;i<r;i++){const o=e*r+i;s[o]<t[i]&&(t[i]=s[o]),s[o]>n[i]&&(n[i]=s[o])}if(e.quantization){const r=e.quantization,s=r.range/(1<<r.quantizationBits),i=r.minValues;c(t,t,s),a(t,t,i),c(n,n,s),a(n,n,i)}e.min=t,e.max=n}t[e.name]=e}return this.transferables&&e.array.buffer&&this.transferables.indexOf(e.array.buffer)<0&&this.transferables.push(e.array.buffer),t},{}),material:t.material};return n&&(i.indices=n),r&&(i.morphTargets=r),i.mode=_(t.mode)?t.mode:4,_(t.extras)&&(i.extras=t.extras),i})}}function Y(t,e,n){const r=new Image;r.crossOrigin="",r.onload=()=>{if(!W)return void n(new Error("There is no canvas to draw image!"));W.width=r.width,W.height=r.height;const t=W.getContext("2d",{willReadFrequently:!0});t.drawImage(r,0,0,r.width,r.height);const e=t.getImageData(0,0,r.width,r.height),s={width:r.width,height:r.height,data:new Uint8Array(e.data)};n(null,s)},r.onerror=function(t){n(t)},r.src=t}let Z,tt;function et(t,e,n){Z||(Z=new OffscreenCanvas(2,2),tt=Z.getContext("2d",{willReadFrequently:!0}));let r=null;if(b(t))r=fetch(t,e).then(t=>t.arrayBuffer()).then(t=>{const e=new Blob([new Uint8Array(t)]);return createImageBitmap(e)});else{const e=new Blob([t]);r=createImageBitmap(e)}r.then(nt.bind(this)).then(t=>{n(null,t)}).catch(t=>{console.warn(t),n(t)})}function nt(t){let{width:e,height:n}=t;rt(e)||(e=st(e)),rt(n)||(n=st(n));const r=this.options.maxTextureSize;r&&(e=Math.min(r,e),n=Math.min(r,n)),Z.width=e,Z.height=n,tt.drawImage(t,0,0,e,n),t.close();const s=tt.getImageData(0,0,e,n);return{width:e,height:n,data:new Uint8Array(s.data)}}function rt(t){return 0==(t&t-1)&&0!==t}function st(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}\n/*!\n   * @maptalks/gl v0.95.6\n   * LICENSE : UNLICENSED\n   * (c) 2016-2024 maptalks.com\n   */const it=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},ot=it(),at=ot.gl_trans__coders=ot.gl_trans__coders||{};at.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),s=ot.gl_trans__coders=ot.gl_trans__coders||{};let i=`${r}\\n    const _____getGlobal = ${it.toString()};\\n    const g___lobals = _____getGlobal()\\n    const tran_____scoders = g___lobals[\'gl_trans__coders\'] = g___lobals[\'gl_trans__coders\'] || {};`;for(const t in s)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(i+=\'tran_____scoders["\'+t+\'"] =\'+s[t].toString()+"\\n;");return i+="\\n"+e.substring(r.length),i},at.registerTranscoder=function(t,e){at[t]=e},at.getTranscoder=function(t){return at[t]};const ct={"image/crn":at.crn&&at.crn(),"image/ktx2":at.ktx2&&at.ktx2(),"image/cttf":at.ktx2&&at.ktx2(),"draco":at.draco&&at.draco()};let ut;const ht={};function ft(t,e,n){return new Q(t,e,n).load({skipAttributeTransform:!0})}function lt(t,e,n){const r=e.lastIndexOf("/"),s=e.slice(0,r),i=dt.bind(this,t);return function(t,e){return S.getArrayBuffer(t,e)}(e,n).then(t=>{if(t.message)return t;const r=t.data;return new DataView(r,r.byteOffset,r.byteLength).getUint32(4,!0)>2?function(t,e){return S.getJSON(t,e)}(e,n).then(t=>t.message?t:ft(s,t,{requestImage:i,decoders:ct,transferable:!0,fetchOptions:n})):ft(s,{buffer:t.data,byteOffset:0},{requestImage:i,decoders:ct,transferable:!0,fetchOptions:n})})}function dt(t,e,n,r){ht[e]?ht[e].push(r):(ht[e]=[r],self.postMessage({type:"<request>",command:"sendImageData",actorId:t,workerId:ut,params:e}))}t.onmessage=function(t){const e=t.data,n=e.url;if("addLayer"===e.command||"removeLayer"===e.command)ut=t.workerId,self.postMessage({type:"<response>",actorId:e.actorId,workerId:ut,params:"ok"});else if(n)!function(t){const e=t.data,n=t.callback,r=t.actorId,s=e.url,i=e.fetchOptions||{};i.referrerPolicy=i.referrerPolicy||"origin",i.referrer=e.referrer,lt(r,s,i).then(t=>{t.message?self.postMessage({callback:n,error:t}):self.postMessage({callback:n,data:t},t.transferables)}).catch(t=>{self.postMessage({callback:n,error:t})}),ht.receive=n}(t);else if(e.imageUrl){const t=ht[e.imageUrl];if(delete ht[e.imageUrl],t)for(let n=0;n<t.length;n++)t[n](null,e.result)}},Object.defineProperty(t,"Z",{value:!0})}';function M$2(t){return null==t}function O$2(t){return!M$2(t)}function S$2(t,s){if(!t||!s)return null;let i=s;if(Array.isArray(s)){if(!t$1.Util.isNumber(s[0]))return null;i=new t$1.Coordinate(s)}const r=t.coordinateToPointAtRes(i,t.getGLRes()),o=t.altitudeToPoint(i.z||0,t.getGLRes());return[r.x,r.y,o]}function A(t,e){return Math.abs(t)*Math.sign(e)}function E$2(t,n,i){const r=t$1.measurer.Measurer.getInstance().measureLenBetween(t,n);let a=i.count;a&&i.snapToEndVertexes&&(a-=1);const h=a>0?r/a:i.gapLength+i.bboxWidth,c=Math.floor(r/h),u=[],f=i.rotateAlongLine?function(t,n,s){const i=s.getGLRes(),r=s.coordinateToPointAtRes(t,i),o=s.coordinateToPointAtRes(n,i);return t$1.Util.computeDegree(o.x,o.y,r.x,r.y)/Math.PI*180}(t,n,i.map):0;if(c>=1){const e=0,s=c;if(i.snapToEndVertexes)for(let i=e;i<=s;i++){const e={coordinates:P$1(t,n,h*i/r),scale:[1,1,1],rotation:[0,0,f]};u.push(e)}else for(let i=e+1;i<=s;i++){const e={coordinates:P$1(t,n,h*(i-.5)/r),scale:[1,1,1],rotation:[0,0,f]};u.push(e)}if(i.scaleEndModel){const e=(r-h*c)/h,s={coordinates:P$1(t,n,(h*c+(r-h*c)/2)/r),scale:[e,1,1],rotation:[0,0,f]};u.push(s)}}else if(i.scaleEndModel){const e=r/h,s={coordinates:P$1(t,n,.5),scale:[e,1,1],rotation:[0,0,f]};u.push(s)}return u}function P$1(t,e,s){const i=I$1(t.x,e.x,s),r=I$1(t.y,e.y,s);return new t$1.Coordinate(i,r)}function I$1(t,e,n){return t+n*(e-t)}const C={},k$2="undefined"==typeof document?null:document.createElement("canvas");class N$2 extends t__namespace.worker.Actor{constructor(t,e){super(t),this.mapId=e.getMap().id,this.t=e}loadGLTF(t){const e={url:function(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}(t),referrer:window&&window.location.href,fetchOptions:this.t.options.fetchOptions};return new Promise(((t,n)=>{this.send(e,null,((e,s)=>{e?n(e):t(s)}))}))}sendImageData(t,e){!function(t,e){const n=new Image;n.onload=()=>{if(!k$2)return void e(new Error("There is no canvas to draw image!"));k$2.width=n.width,k$2.height=n.height;const t=k$2.getContext("2d");t.drawImage(n,0,0,n.width,n.height);const s=t.getImageData(0,0,n.width,n.height),i={width:n.width,height:n.height,data:new Uint8Array(s.data)};e(null,i)},n.onerror=function(t){e(t)},n.src=t}(t,((n,s)=>{n||this.isActive()&&e(null,{result:s,imageUrl:t})}))}addLayer(t,e,n){this.broadcast({actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}},null,n)}removeLayer(t,e,n){this.broadcast({mapId:this.mapId,layerId:t,command:"removeLayer"},null,n)}}const R$2=[],L$2=[],B$2=["points","lines","line strip","line loop"];class F$2 extends(oe$4(t__namespace.renderer.OverlayLayerCanvasRenderer)){constructor(t){super(t),this.s={},this.i=[]}onAdd(){super.onAdd(),this.prepareWorker()}draw(t,e){this.prepareCanvas(),this.o(e,t)}drawOnInteracting(t,e,n){this.o(n,e)}o(e,n){let s=0;this.h(e),this.u={},this.l(e);const i=this.m(e);this.p(n);const r=e&&e.renderTarget?e.renderTarget.fbo:null;let o=0;for(const n in this.s){if("pointline"===n)continue;if(e&&e.includes){const{newShader:s,uniforms:r}=this.g(e,n);this.s[n].shader=s,t__namespace.Util.extend(i,r)}const a=this._(n),h=this.s[n].shader;h.filter=e&&e.sceneFilter||null,o+=this.renderer.render(h,i,a,r),s++}const a=this._("pointline");if(a.getMeshes().length){i.pointSize=this.layer.options.pointSize||1;const t=this.s.pointline.shader;t.filter=e&&e.sceneFilter||null,o+=this.renderer.render(t,i,a,r),s++}this.v(i,r),o&&this.layer.fire("canvasisdirty",{renderCount:o}),this.T=!0,(!e||e&&e.isFinalRender)&&(this.completeRender(),this.layer.fire("rendercomplete-debug",{count:s})),this.M=e,this.O=n}v(t,e){this.S||(this.S=new Ke$5);const n=this.layer.getGeometries(),s=[];for(let t=0;t<n.length;t++){if(!n[t].options.showDebugBoundingBox)continue;const e=n[t].A();e&&s.push(e)}s.length&&(this.S.setMeshes(s),this.renderer.render(this.s.wireframe.shader,t,this.S,e))}p(e){this.i.length=0;const n=this.layer.getGeometries();for(let s=0;s<n.length;s++){const i=n[s],r=i.getMeshes(this.P,this.regl,e),o=i.getShader();if(r.length){this.i.push(i),this.u[o]=this.u[o]||[],t__namespace.Util.pushIn(this.u[o],r);for(let t=0;t<r.length;t++)r[t].properties.bloomMesh&&this.u[o].push(r[t].properties.bloomMesh)}}}m(){const e={};this.I.outSize=[this.canvas.width,this.canvas.height],this.I.halton=[0,0];e.layerOpacity=this.canvas.gl&&this.canvas.gl.wrap?this.layer.options.opacity||0:1,t__namespace.Util.extend(e,this.I);const s=this.getMaskUniforms();return t__namespace.Util.extend(e,s),e}_(t){const e=[],n=[];if("pointline"===t){for(const t in this.u)"wireframe"!==t&&this.u[t].forEach((t=>{B$2.indexOf(t.geometry.desc.primitive)>-1&&e.push(t)}));const t=new Ke$5(e);return t.sortMeshes(this.I.cameraPosition),t}for(const e in this.u){const s=this.u[e];e===t&&s.forEach((e=>{(B$2.indexOf(e.geometry.desc.primitive)<0||"wireframe"===t)&&n.push(e)}))}const s=new Ke$5(n);return s.sortMeshes(this.I.cameraPosition),s}needToRedraw(){if(super.needToRedraw())return!0;const t=this.layer.getGeometries();for(let e=0;e<t.length;e++)if(this.i.indexOf(t[e])>-1&&(t[e].isDirty()||t[e].isAnimated()))return!0;return!1}onRemove(){this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),super.onRemove()}hitDetect(){return!1}createContext(){const t=this.canvas.gl&&this.canvas.gl.wrap;if(t)this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl;else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,stencil:!0};this.glOptions=t,this.gl=this.gl||this.C(this.canvas,t),this.regl=a$2({gl:this.gl,optionalExtensions:["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_s3tc"]})}t&&(this.canvas.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height)),this.pickingFBO=this.canvas.pickingFBO||this.regl.framebuffer(this.canvas.width,this.canvas.height),this.P=this.regl.gltfManager=this.regl.gltfManager||this.k(),this.N(),this.R&&this.R.forEach((t=>{t.generateInstancedBuffers(this.regl)})),this.L&&this.L.forEach((t=>{t.generateBuffers(this.regl)})),this.layer.fire("contextcreate",{regl:this.regl})}getGLTFManager(){return this.P}k(){return new Bt$6(this.regl)}N(){const t=this.layer.getMap(),e=new B$6(this.regl);this.renderer=e,this.I={projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,viewMatrix:t.viewMatrix,cameraPosition:t.cameraPosition,altitudeScale:1},fi$4.PBRUtils.loginIBLResOnCanvas(this.canvas,this.regl,t),this.B=new Cr$4(e,{vert:"#include <gl2_vert>\n\nattribute vec3 aPosition;\n\nuniform mat4 projViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform float pointSize;\n\n#include <fbo_picking_vert>\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    gl_Position = projViewMatrix * modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    gl_PointSize = pointSize;\n\n    fbo_picking_setData(gl_Position.w, true);\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5([],e.projViewMatrix,e.modelMatrix)}}]},this.pickingFBO,t)}prepareWorker(){this.workerConn||(this.workerConn=new N$2("@maptalks/gltf-layer",this.layer));const t=this.workerConn;if(!t.isActive())return;const e=this.layer.options||{},n=this.layer.getId();t.addLayer(n,{markerType:e.markerTypes,pointSize:e.pointSize},(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}F(t){return this.workerConn.loadGLTF(t).then((t=>(this.setToRedraw(),this.D=!0,t))).catch((e=>{console.error(e),this.layer.fire("modelerror",{type:"modelerror",url:t,info:e})}))}l(t){const e=C;for(const n in e){if(this.s[n])continue;const s=e[n];this.U(t,s.name,s.type,s.config)}}U(e,n,s,i){this.viewport||(this.viewport={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1}),i.extraCommandProps||(i.extraCommandProps={});const r={};e&&this.V(r,R$2,e);const o=t__namespace.Util.extend({},i);o.extraCommandProps=t__namespace.Util.extend({},i.extraCommandProps),o.extraCommandProps.viewport=this.viewport,o.uniforms=t__namespace.Util.extend([],i.uniforms,R$2),o.defines=t__namespace.Util.extend({},o.defines,r),s.indexOf(".")>-1?(s=s.split("."),this.s[n]={shader:new l$1[s[0]][s[1]](o),type:s}):this.s[n]={shader:new l$1[s](o),type:s}}remove(){this.q();const t=this.s;for(const e in t)t[e].shader.dispose();this.extentShader&&this.extentShader.dispose(),super.remove()}clearCanvas(){this.canvas&&(this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas())}resizeCanvas(t){super.resizeCanvas(t),this.pickingFBO&&this.pickingFBO.resize(this.canvas.width,this.canvas.height),this.layer.fire("resizecanvas",{size:t})}getFrameTimestamp(){return this.O}getFrameContext(){return this.M}supportRenderMode(){return!0}needRetireFrames(){return this.D}V(e,n,s){const i=s&&s.includes;if(i)for(const r in i)i[r]&&(s[r].uniformDeclares&&(n.length=0,n.push(...s[r].uniformDeclares)),s[r].defines&&t__namespace.Util.extend(e,s[r].defines))}j(e,n){const s=n&&n.includes;if(s)for(const i in s)s[i]&&n[i].renderUniforms&&t__namespace.Util.extend(e,n[i].renderUniforms)}g(e,n){const{shader:s,type:i}=this.s[n],r={},o={};this.V(r,R$2,e),this.j(o,e);const a={vert:s.vert,frag:s.frag,uniforms:s.uniforms,extraCommandProps:s.extraCommandProps};a.defines=r,a.uniforms=t__namespace.Util.extend([],a.uniforms,R$2);let h=null;return e.states.includesChanged?(h=Array.isArray(i)?new l$1[i[0]][i[1]](a):new l$1[i](a),s.dispose()):h=s,{uniforms:o,newShader:h}}G(e,n,s){if(e.viewshed){for(const t in e.viewshed.renderUniforms)s[t]=e.viewshed.renderUniforms[t];t__namespace.Util.extend(n.shaderDefines,e.viewshed.defines)}if(e.floodAnalysis){for(const t in e.floodAnalysis.renderUniforms)s[t]=e.floodAnalysis.renderUniforms[t];t__namespace.Util.extend(n.shaderDefines,e.floodAnalysis.defines)}return s}getShadowMeshes(){const e=[];if(!this.layer||!this.layer.isVisible()||!this.u)return e;const n=this.layer.getGeometries();for(let s=0;s<n.length;s++)if(n[s].isCastShadow()&&n[s].isVisible()&&n[s].X()){t__namespace.Util.pushIn(e,n[s].H||[])}return e}J(){const e=[];if(!this.u||!Object.keys(this.u).length)return e;for(const n in this.u)t__namespace.Util.pushIn(e,this.u[n]);return e}getAnalysisMeshes(){return this.J()}getRayCastData(t){const e=this.layer.getGeometries();for(let n=0;n<e.length;n++){const s=e[n].H;if(s&&s.indexOf(t)>-1)return e[n]}return null}drawOutline(t){this.extentShader||(this.extentShader=new vn$4({vert:"attribute vec3 aPosition;\n\nattribute float aOutline;\n\nuniform mat4 projViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform float instance;\n\n#include <get_output>\n\n\n\nvarying float vOutline;\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    gl_Position = projViewMatrix * modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    if (instance == 0.0) {\n\n        vOutline = 1.0;\n\n    } else {\n\n        vOutline = aOutline;\n\n    }\n\n}\n\n",frag:"precision highp float;\n\nvarying float vOutline;\n\nvoid main() {\n\n    gl_FragColor = vec4(vOutline);\n\n}\n\n",positionAttribute:"POSITION",extraCommandProps:{viewport:this.viewport,cull:{enable:!1},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}}));const e=this.getOutlineMeshes();e.length&&(this.W=this.W||new Ke$5,this.W.setMeshes(e),this.renderer.render(this.extentShader,{projViewMatrix:this.I.projViewMatrix},this.W,t))}getOutlineMeshes(){const e=[];if(!this.layer)return e;const n=this.layer.getGeometries();for(let s=0;s<n.length;s++){const i=n[s].Y();t__namespace.Util.pushIn(e,i)}return e}q(){this.canvas&&fi$4.PBRUtils.logoutIBLResOnCanvas(this.canvas,this.getMap())}h(e){const n=this.layer.getMap(),{iblTexes:s,dfgLUT:i}=fi$4.PBRUtils.getIBLResOnCanvas(this.canvas);if(n&&n.getLights()){const r=fi$4.PBRUtils.getPBRUniforms(n,s,i,e&&e.ssr,e&&e.jitter),o=n.getLights();this.I.ambientColor=o.ambient&&o.ambient.color?o.ambient.color:[.2,.2,.2],r&&t__namespace.Util.extend(this.I,r)}else{const s=fi$4.PBRUtils.getPBRUniforms(n,null,i,e&&e.ssr,e&&e.jitter);t__namespace.Util.extend(this.I,s)}}C(t,e){const n=["webgl","experimental-webgl"];let s=null;for(let i=0;i<n.length;++i){try{s=t.getContext(n[i],e)}catch(t){}if(s)break}return s}Z(e,n,s={}){if(!this.B||!this.layer.isVisible())return null;const i=this.layer.getMap();if(this.T||this.canvas.gl&&this.canvas.gl.wrap){if(!this.u||!Object.keys(this.u).length)return null;const e=this.J(),n=t__namespace.Util.extend({},this.I);n.pointSize=this.layer.options.pointSize||1,this.B.render(e,n,!0),this.T=!1}const a=this.B[s.returnAll?"pickAll":"pick"](e,n,s.tolerance||3,{projViewMatrix:i.projViewMatrix,pointSize:this.layer.options.pointSize||1},{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:!0});if(a.length){const t={},e=[];for(let n=0;n<a.length;n++)if(!t[a[n].pickingId]){const s=this.K(a[n]);t[a[n].pickingId]=!0,e.push(s)}return e}return this.K(a)}K(t){const{meshId:e,pickingId:n,point:s,coordinate:i}=t,r=this.J()[e],o=this.$(n);return{meshId:e,mesh:r,data:this.layer.tt()[o],pickingId:n,point:s,coordinate:i,index:n-o,nodeIndex:this.et(e)}}et(t){const e=this.J()[t];return e&&e.properties.nodeIndex}$(t){if(!O$2(t))return null;if(this.layer.tt()[t])return t;const e=Object.keys(this.layer.tt()),n=e.length;let s=0,i=n-1,r=Math.floor((s+i)/2);for(;s<=n-1&&i>=0;){if(s===i)return e[s];if(e[r]<=t&&t<e[r+1])return e[r];t<e[r]?(i=r-1,r=Math.floor((s+i)/2)):e[r+1]<t&&(s=r+1,r=Math.floor((s+i)/2))}return null}isInFrustum(t){const e=this.layer.getMap(),n=t.getBoundingBox();if(!n||"multigltfmarker"===t.getGLTFMarkerType())return!0;const s=set(L$2,n.min,n.max);return!!intersectsBox(e.projViewMatrix,s)}getRenderMeshesTest(){return this.J()}isMarkerTransparent(t){return t.nt()}getMarkerFitSizeScale(t){return t.st()}getMarkerFitTranslate(t){return t.it()}getFBORayPicking(){return this.B}getShaderList(){return this.s}}const D$2=[],U$2=[],V$2=[],q$2=[],j$2=[1,1,1],G$2=[],X$2=[],H$2=[1,1,1],z$2=new X$7,J$2=function(t,e){const n=[];return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=0,n[4]=t[3],n[5]=t[4],n[6]=t[5],n[7]=0,n[8]=t[6],n[9]=t[7],n[10]=t[8],n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}(function(t){const e=Math.cos(t),n=Math.sin(t),s=[];return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=e,s[5]=n,s[6]=0,s[7]=-n,s[8]=e,s}(.5*Math.PI),[0,0,0]),W$2=new t$1.Point(0,0),Y$2=[186/255,186/255,186/255,1],Z$2={lightAmbient:[1,1,1],lightDiffuse:[1,1,1],lightSpecular:[1,1,1],lightDirection:[1,1,1]},K$2=new Set(["url","translationX","translationY","translationZ","rotationX","rotationY","rotationZ","scaleX","scaleY","scaleZ","anchorZ","markerPixelHeight","modelHeight"]),$$2=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1],Q$2=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],tt$1=[.8,.8,.1,1];class et$1 extends t$1.Marker{constructor(t,n){const s=t$1.Util.extend({},n),i=s.symbol;super(t,s),this.options.symbol=i,this.rt=!1,this.ot=identity$2([]),this.ht="gltfmarker",this.ct=!0,this.ut=!0,this.lt={get translation(){return[0,0,0]},get rotation(){return[0,0,0]},get scale(){return[1,1,1]}},this.ft()}static parseJSONData(t){const e=et$1.fromJSON(t);return e.setZoomOnAdded(t.zoomOnAdded),e}static fromJSON(t){return new et$1(t.coordinates,t.options)}static getGLTFAnchorsAlongLineString(t,n,s,i){const r=[];for(let o=0;o<t.length-1;o++){const a=E$2(t[o],t[o+1],{map:s,bboxWidth:n,gapLength:i.gapLength||0,count:i.count,rotateAlongLine:i.rotateAlongLine,snapToEndVertexes:i.snapToEndVertexes,scaleEndModel:i.scaleEndModel});t$1.Util.pushIn(r,a)}return r}static combineGLTFBoundingBox(t){const e=[];for(let n=0;n<t.length;n++){const s=t[n].getBoundingBox();e.push([s.min,s.max])}const n=e[0];if(!n)return null;const s=copy$4([],n[0]),i=copy$4([],n[1]);for(let t=1;t<e.length;t++){const n=e[t],r=copy$4([],n[0]),o=copy$4([],n[1]);r[0]<s[0]&&(s[0]=r[0]),r[1]<s[1]&&(s[1]=r[1]),r[2]<s[2]&&(s[2]=r[2]),o[0]>i[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}return{min:s,max:i}}setTransformOrigin(t){this.dt=t}getTransformOrigin(){return this.dt||this.getCenter()}getMeshes(t,e,n){let s=[];const i=this.getMap();if(e&&(this.regl=e),this.getLayer().isVisible()&&this.isVisible()&&this.X()){if(!this.H)return this.pt(t,e),s;let r=this.isAnimated()||this.gt()&&i.isZooming()||this.ut||"multigltfmarker"===this.getGLTFMarkerType()&&this.ct;if(!r){const t=this.ot;copy$5(G$2,t),this.ft(),r=!exactEquals$5(t,G$2)}r&&this.yt(this.H,n),s=this.H.filter((t=>!!(intersectsBox(i.projViewMatrix,t.getBoundingBox())||t instanceof Ge$5)&&(this.bt(t),this.xt(t),!0))),this.ct=!1}return s}getGLTFJSON(){return this._t}getAllMeshes(){return this.H}wt(){return this._t}vt(t){this._t=t}Tt(t,e){this._externSymbol=this._externSymbol||{},this._externSymbol[t]=e,"uniforms"===t&&(this.Mt=!0)}setUrl(t){return this.updateSymbol({url:t}),this}setSymbol(t){const e=this.getUrl();super.setSymbol(t);const n=this.getShader(),s=this.P;s&&t.url!==e&&(s.logoutGLTF(e),this.Ot=!1,this.St(!1),delete this.H),this.At&&this.At!==n&&this.Et(s,this.regl),this.At=n,this.Mt=!0,this.ct=!0}getCenter(){const t=this.getMap();if(!t)return null;const e=S$2(t,super.getCenter()||this.getCoordinates());if(!e)return null;const n=this.Pt(),s=new t$1.Point([e[0]+n[0],e[1]+n[1],e[2]+n[2]]),r=t.getGLRes(),o=t.pointAtResToCoord(s,r);return o.z=s.z/t.altitudeToPoint(100,r)*100,o}getPointZ(){const t=this.getCoordinates(),e=this.getMap();return e&&t?e.altitudeToPoint(t.z||0,e.getGLRes()):null}getUrl(){const t=this._getInternalSymbol();return t&&t.url||"pyramid"}addTo(t){if(this.getLayer())throw new Error("GLTFMarker cannot be added to two or more layers at the same time.");return t.addGeometry(this),this}pt(t,e){const n=this.getUrl();if(this.P=t,!this.Ot){if(!this.It){const t=this.getLayer().getRenderer();this.It=t.F.bind(t)}t.loginGLTF(n,this.It),this.Ot=!0}const s=t.getGLTF(n);s&&!s.then&&(this.St(!0),this.Ct(s,t,e))}bt(t,e){"effectmarker"===this.getGLTFMarkerType()?this.updateUV(e):"glowmarker"===this.getGLTFMarkerType()&&this.kt();const n=this.getUniforms();if(n&&this.isDirty()&&this.Nt())for(const e in n)t.setUniform(e,n[e]);this.nt()&&(t.transparent=!0),t.bloom=t.bloom||+!!this.isBloom(),t.setUniform("uPickingId",this.Rt()),t.properties.isAnimated=this.isAnimated()}xt(t){const e=this.getShader(),n=t.getDefines();let s=!1;if("pbr"===e||"pbr-lite"===e){const t=this.getLayer(),{iblTexes:e}=fi$4.PBRUtils.getIBLResOnCanvas(t.getRenderer().canvas);e?n.HAS_IBL_LIGHTING||(n.HAS_IBL_LIGHTING=1,s=!0):n.HAS_IBL_LIGHTING&&(s=!0,delete n.HAS_IBL_LIGHTING)}s&&t.setDefines(n);const i=this.getLayer().getRenderer();i&&i.updateMaskDefines(t)}Et(t){const e=this.getUrl(),n=this.H;t&&n&&(t.isSimpleModel(e)?this.Lt(n):t.getGLTF(e)&&(n.forEach((t=>{this.bt(t)})),this.Lt(n)))}Lt(t){const e=this.getShader();t.forEach((t=>{const n=this.Bt(t.properties.geometryResource);"wireframe"===e?(t.properties.geometryResource&&!t.properties.geometryResource.copyGeometry&&t.properties.geometryResource.copyEdgeGeometry(),t.geometry=t.properties.geometryResource.copyGeometry):t.geometry=t.properties.geometryResource.geometry,t.material=n}))}yt(t,e){set$4(j$2,1,1,1);const n=identity$2(G$2),s=this.isAnimated();this.ft();const i=this.getModelMatrix(),{nodeMatrixMap:r,skinMap:o}=this.Ft(e);this.Dt(j$2);let a=0;t.forEach((t=>{const e=t.properties.geometryResource.nodeIndex,h=r[e],c=s&&h?h:t.nodeMatrix;scale$5(n,i,j$2),multiply$5(n,n,J$2),t instanceof Ge$5?(t.positionMatrix=multiply$5(t.positionMatrix,n,c),t.localTransform=this.Ut(),this.Vt(t)):t.localTransform=multiply$5(t.localTransform,n,c);const u=t.geometry.boundingBox.copy(z$2);u.transform(t.positionMatrix,t.localTransform);const f=this.qt(u);if(Math.abs(f)>Math.abs(a)&&(a=f),s){const n=o[e];n&&(t.material.set("skinAnimation",1),t.material.set("jointTextureSize",n.jointTextureSize),t.material.set("numJoints",n.numJoints),t.material.set("jointTexture",n.jointTexture));const s=t.geometry.properties.morphWeights;s&&this.jt(s,t.material)}else t.material.set("skinAnimation",0)}));const h=this.A();if(h&&(scale$5(n,i,j$2),multiply$5(n,n,J$2),this.Gt.localTransform=multiply$5(this.Gt.localTransform,n,this.Gt.Xt)),0!==a){set$4(X$2,0,0,a);const e=fromTranslation$1(G$2,X$2);t.forEach((t=>{if(t instanceof Ge$5)t.positionMatrix=multiply$5(t.positionMatrix,e,t.positionMatrix),this.Vt(t);else{const n=multiply$5(t.localTransform,e,t.localTransform);t.localTransform=n}})),h&&(this.Gt.localTransform=multiply$5(this.Gt.localTransform,e,this.Gt.localTransform))}t.forEach((t=>{t instanceof Ge$5&&this.Vt(t)})),this.fire("updatematrix",{target:this})}getBoundingBoxCenter(){const t=this.Ht,e=this.getMap();if(!t||!this.Gt||!e)return null;const n=e.getGLRes(),{min:s,max:r}=t,o=add$4([],s,r);scale$4(o,o,.5),transformMat4$2(o,o,this.Gt.localTransform);const a=new t$1.Point(o),h=e.pointAtResToCoordinate(a,n);return h.z=100/e.altitudeToPoint(100,n)*o[2],h}getBoundingBoxWidth(t){const e=this.Ht;if(!e)return 0;const n=t||0,{min:s,max:i}=e,r=this.zt()[n];return(i[n]-s[n])*r}getAxisXWidth(){return this.getBoundingBoxWidth(0)}getAxisYWidth(){return this.getBoundingBoxWidth(1)}Dt(t){const e=this.getMap(),n=e.getGLRes(),s=e.altitudeToPoint(100,n);return t[0]*=s/100,t[1]*=s/100,t[2]*=s/100,t}Jt(t){const e=this.getSymbol().modelHeight,n=this.Ht,s=e/Math.abs(n.max[1]-n.min[1]);return set$4(t,s,s,s)}Wt(t){const e=this.Ht,n=this.getSymbol().markerPixelHeight;if(!n||n<0||!e)return t;const s=this.getMap(),i=Math.abs(e.max[1]-e.min[1]),r=s.altitudeToPoint(i,s.getGLRes()),o=n*s.getGLScale()/r;return set$4(t,o,o,o)}getCurrentPixelHeight(){const t=this.getBoundingBox();return Math.abs(t.max[2]-t.min[2])/this.getMap().getGLScale()}getFitTranslate(t){const e=this.Ht,n=set$4(t,(e.min[0]+e.max[0])/2,(e.min[1]+e.max[1])/2,(e.min[2]+e.max[2])/2);return scale$4(n,n,-1)}qt(t){const e=this.getSymbol(),n=e&&e.anchorZ||"center";let s=0;const i=t.max[2]-t.min[2];return"bottom"===n?s=i/2:"top"===n&&(s=-i/2),s}Ft(t){const e=this.isAnimated(),n=this.Yt(),s={},i=this.Zt();if(t&&e&&this.gltfPack&&n){const e=this.Kt();if(O$2(e)){this.$t(t);const n=this.Qt(),r=this.isAnimationLooped(),o=this.getAnimationSpeed(),a=this.getSymbol(),h=a&&a.animationNodes;for(let a=0;a<e.length;a++)this.gltfPack.updateAnimation(t,r,o,e[a],n,s,i,h)}else console.warn("animation specified does not exist!")}return{nodeMatrixMap:s,skinMap:i}}Ct(t,e,n){const s=this.getUrl();this.vt(t.json),this.te(s,e,n),this.Et(e,n),this.fire("load",{data:t.json}),this.fire("setUrl-debug"),this._fireEvent("meshcreate",{url:s})}te(t,e,n){const s=[],i=this.getShader(),r=e.getGLTF(t);if(r&&r.resources){if(!r.resources.length)return void this._fireEvent("modelerror",{url:t,info:"there are no geomtries in the gltf model"});this.gltfPack=r.gltfPack,r.resources.forEach((t=>{const e=this.ee(t,i,n);s.push(e)}))}this.H=s,this.Ht=this.ne(),this.se(this.H),this.fire("createscene-debug",{meshes:this.H})}se(t){this.yt(t);const e=this.getBoundingBox();if(!e)return;const n=this.getMap(),{max:s,min:i}=e;length$4([s[0]-i[0],s[1]-i[1],s[2]-i[2]])/n.getGLScale()<20&&(console.warn("Model's size on screen is too small, try to increase its symbol.scaleX/Y/Z"),this.fire("smallonscreen"))}A(){if(this.Gt)return this.Gt.material.set("lineColor",this.ie||tt$1),this.Gt.material.set("lineOpacity",this.re||1),this.Gt;const t=this.Ht;if(!t)return null;const{min:e,max:n}=t;$$2[0]=n[0],$$2[1]=e[1],$$2[2]=n[2],$$2[3]=n[0],$$2[4]=n[1],$$2[5]=n[2],$$2[6]=e[0],$$2[7]=n[1],$$2[8]=n[2],$$2[9]=e[0],$$2[10]=e[1],$$2[11]=n[2],$$2[12]=n[0],$$2[13]=e[1],$$2[14]=e[2],$$2[15]=n[0],$$2[16]=n[1],$$2[17]=e[2],$$2[18]=e[0],$$2[19]=n[1],$$2[20]=e[2],$$2[21]=e[0],$$2[22]=e[1],$$2[23]=e[2];const s=new Q$7({POSITION:$$2},Q$2,0,{primitive:"lines",positionAttribute:"POSITION"});s.generateBuffers(this.regl);const i=new Be$5(s,new Ce$5({lineColor:this.ie||tt$1,lineOpacity:this.re||1}));return this.Gt=i,this.Gt.Xt=copy$5([],i.localTransform),i}showBoundingBox(t){this.options.showDebugBoundingBox=!0,this.ie=t&&t.lineColor,this.re=t&&t.lineOpacity,this.ct=!0}hideBoundingBox(){this.options.showDebugBoundingBox=!1,this.ct=!0}getBoundingBox(){const t=this.H;if(!t||!t.length)return null;if(!this.ut)return this.oe;"multigltfmarker"===this.getGLTFMarkerType()&&t.forEach((t=>{this.Vt(t),t.updateBoundingBox()}));const e=t[0].getBoundingBox(),n=copy$4([],e[0]),s=copy$4([],e[1]);for(let e=1;e<t.length;e++){const i=t[e].getBoundingBox(),r=copy$4([],i[0]),o=copy$4([],i[1]);r[0]<n[0]&&(n[0]=r[0]),r[1]<n[1]&&(n[1]=r[1]),r[2]<n[2]&&(n[2]=r[2]),o[0]>s[0]&&(s[0]=o[0]),o[1]>s[1]&&(s[1]=o[1]),o[2]>s[2]&&(s[2]=o[2])}const i={min:n,max:s};return this.oe=i,this.ut=!1,i}ne(){return this.gltfPack.getGLTFBBox()}ee(t,e,n){const s=t,i=this.ae(s,e,n),r=i.getDefines();return i instanceof Ge$5?(r.HAS_PICKING_ID=1,r.HAS_INSTANCE_COLOR=1):r.HAS_PICKING_ID=2,i.geometry.data.COLOR_0&&(r.HAS_COLOR0=1),s.extraInfo&&"MASK"===s.extraInfo.alphaMode&&(r.HAS_ALPHAMODE=1),r.HAS_MIN_ALTITUDE=1,r.HAS_LAYER_OPACITY=1,i.setDefines(r),i}ae(t,e,n){const s=this.getGLTFMarkerType();let i=null;const r=this.Bt(t);let o=t.geometry;if("wireframe"===e&&(t.copyEdgeGeometry(),o=t.copyGeometry),n?o.generateBuffers(n):(this.L=this.L||[],this.L.push(o)),"multigltfmarker"===s){this.he();const t=this.ce(identity$2(q$2)),e=this.ue();i=new Ge$5(t.attributesData,e,o,r),i.setUniform("instance",1),n?i.generateInstancedBuffers(n):(this.R=this.R||[],this.R.push(i))}else i=new Be$5(o,r),i.setUniform("instance",0);i.nodeMatrix=copy$5([],t.nodeMatrix),i.properties.geometryResource=t,i.properties.nodeIndex=t.nodeIndex,this.isBloom()&&(i.bloom=1),i.transparent=this.nt();const a=t.extraInfo;"BLEND"!==a.alphaMode&&"MASK"!==a.alphaMode||(i.transparent=!0),i.properties.pickingId=this.Rt(),this.le(i);const h=this.getLayer();return Object.defineProperty(i.uniforms,"minAltitude",{enumerable:!0,get:()=>h.options.altitude||0}),i}Bt(t){let e=null;const n=this.getShader(),s=this.getUniforms()||{},i=t.materialInfo||{},r=this.getLayer().getRenderer();if("phong"===n)if("pbrSpecularGlossiness"===i.name)e=new Le$5(i);else{for(const t in Z$2)s[t]=s[t]||Z$2[t];e=new Ie$5(i)}else if("pbr"===n){if(e="pbrSpecularGlossiness"===i.name?new fi$4.StandardSpecularGlossinessMaterial(i):new fi$4.StandardMaterial(i),r.regl&&!fi$4.PBRUtils.isSupported(r.regl)){e=Ie$5.convertFrom(e);for(const t in Z$2)s[t]=s[t]||Z$2[t]}}else e="pbr-lite"===n?new Ne$5(i):new Ce$5(i);const o=this.getSymbol();e.doubleSided=+!!(o&&o.doubleSided||t.extraInfo&&t.extraInfo.doubleSided);for(const t in s)e.set(t,s[t]);return t.morphWeights&&this.jt(t.morphWeights,e),t.skin&&e.set("skinAnimation",0),e}jt(t,e){const n=e.get("morphWeights1")||[],s=e.get("morphWeights2")||[];for(let e=0;e<4;e++)n[e]=t[e]||0,s[e]=t[e+4]||0;e.set("morphWeights1",n),e.set("morphWeights2",s)}le(t){const e=this.getSymbol();e&&e.uniforms?(t.setUniform("polygonFill",e.uniforms.polygonFill||Y$2),t.setUniform("polygonOpacity",void 0===e.uniforms.polygonOpacity?1:e.uniforms.polygonOpacity),t.setUniform("lineColor",e.uniforms.lineColor||Y$2),t.setUniform("lineOpacity",void 0===e.uniforms.lineOpacity?1:e.uniforms.lineOpacity)):(t.setUniform("polygonFill",Y$2),t.setUniform("polygonOpacity",1),t.setUniform("lineColor",Y$2),t.setUniform("lineOpacity",1))}fe(){const t=this.getLayer();if(!t)return null;const e=t.getMap();if(!e)return null;const n=this.getBoundingBox();if(!n)return null;const s=this.getPointZ()||0,i=n.min,r=n.max,a=set$3(U$2,(i[0]+r[0])/2,(i[1]+r[1])/2,i[2]+s,1),h=set$3(V$2,(i[0]+r[0])/2,(i[1]+r[1])/2,r[2]+s,1),c=transformMat4$1(a,a,e.projViewMatrix),u=transformMat4$1(h,h,e.projViewMatrix),l=(c[0]/c[3]+1)*e.width/2,f=(1-c[1]/c[3])*e.height/2,d=(u[0]/u[3]+1)*e.width/2,m=(1-u[1]/u[3])*e.height/2,p=Math.min(l,d),y=Math.max(l,d),b=Math.min(f,m),x=Math.max(f,m);return new t$1.Extent({xmin:p,ymin:b,xmax:y,ymax:x})}onAdd(){const t=this.getLayer().getMap();if(t&&!O$2(this.de)){const e=t.getZoom();this.de=e}delete this.It}onRemove(){this.me()}remove(){const t=this.getUrl();if(this.P&&(delete this.H,this.P.logoutGLTF(t),delete this.P),this.pe){for(const t in this.pe)this.pe[t]&&this.pe[t].jointTexture&&this.pe[t].jointTexture.destroy();delete this.pe}this.Gt&&(this.Gt.geometry.dispose(),this.Gt.dispose(),delete this.Gt),this.H&&this.H.forEach((t=>{t.dispose(),t.properties.bloomMesh&&(t.properties.bloomMesh.dispose(),delete t.properties.bloomMesh)})),this.Ot=!1,delete this._t,delete this.gltfPack,super.remove()}show(){return super.updateSymbol({visible:!0}),this}hide(){super.updateSymbol({visible:!1})}setBloom(t){return super.updateSymbol({bloom:t}),this}isBloom(){const t=this._getInternalSymbol();return t&&t.bloom}setCastShadow(t){return super.updateSymbol({shadow:t}),this}isCastShadow(){const t=this._getInternalSymbol();return t&&t.shadow}outlineNodes(t){const e=this.H;return e?(e.forEach((e=>{t.indexOf(e.properties.nodeIndex)>-1&&(e.properties.outline=!0)})),this.ct=!0,this):this}outline(){const t=this.H;return t?(t.forEach((t=>{t.properties.outline=!0})),this.ct=!0,this):this}cancelOutline(t){const e=this.H;return e?(e.forEach((e=>{t?t.indexOf(e.properties.nodeIndex)>-1&&(e.properties.outline=!1):e.properties.outline=!1})),this.ct=!0,this):this}isVisible(){const t=this._getInternalSymbol();return!t||!O$2(t.visible)||t.visible}setCoordinates(t){return super.setCoordinates(t),this.ct=!0,this.ut=!0,this}copy(){const t=this.toJSON(),e=et$1.fromJSON(t);return e.setZoomOnAdded(this.de),e}setShader(t){return super.updateSymbol({shader:t}),this}getShader(){const t=this._getInternalSymbol();return t&&t.shader||"pbr"}setUniforms(t){return super.updateSymbol({uniforms:t}),this.Mt=!0,this}getUniforms(){const t=this._getInternalSymbol();return t&&t.uniforms}setUniform(t,e){const n=this.getUniforms()||{};return n[t]=e,super.updateSymbol({uniforms:n}),this.Mt=!0,this}getUniform(t){const e=this._getInternalSymbol();return e&&e.uniforms&&e.uniforms[t]}isAnimated(){const t=this._getInternalSymbol();return t&&t.animation&&this._t&&this._t.animations}isDashAnimated(){const t=this._getInternalSymbol();return t&&t.uniforms&&t.uniforms.dashEnabled&&t.uniforms.dashAnimate}setAnimation(t){return super.updateSymbol({animation:t}),delete this.ge,this}setAnimationLoop(t){return super.updateSymbol({loop:t}),delete this.ge,this.ct=!0,this}isAnimationLooped(){const t=this._getInternalSymbol();return t&&t.loop}getAnimationSpeed(){const t=this._getInternalSymbol();return t&&O$2(t.speed)?t.speed:1}setAnimationSpeed(t){return super.updateSymbol({speed:t}),this}ye(t){const e=this.getMap();return e?S$2(e,t||this.getCoordinates()):null}setTRS(t,e,n){const s=t||this.lt.translation;return this.updateSymbol({translationX:s[0],translationY:s[1],translationZ:s[2],rotationX:e[0],rotationY:e[1],rotationZ:e[2],scaleX:n[0],scaleY:n[1],scaleZ:n[2]}),this}be(){const t=this.Pt(),e=this.ye();return e?add$4(t,t,e):t}updateSymbol(t){for(const e in t)if(K$2.has(e)){this.ut=!0;break}return super.updateSymbol(t)}setTranslation(t,e,n){return this.updateSymbol({translationX:t,translationY:e,translationZ:n}),this}setRotation(t,e,n){return this.updateSymbol({rotationX:t,rotationY:e,rotationZ:n}),this}rotateAround(t,e){const n=this.getMap();if(!n)return;const s=n.getGLRes();let i=this.getCoordinates();const r=n.coordinateToPointAtRes(i,s),o=n.coordinateToPointAtRes(t,s),a=r.x-o.x,h=r.y-o.y,c=180*Math.atan2(h,a)/Math.PI+e,u=Math.sqrt(a*a+h*h),l=Math.PI*c/180,f=u*Math.cos(l)+o.x,d=u*Math.sin(l)+o.y;W$2.set(f,d),i=n.pointAtResToCoordinate(W$2,s),this.setCoordinates(i),this.updateSymbol({rotationZ:c})}setScale(t,e,n){return this.updateSymbol({scaleX:t,scaleY:e,scaleZ:n}),this}getTranslation(){const t=this._getInternalSymbol();return set$4(this.lt.translation,t&&t.translationX||0,t&&t.translationY||0,t&&t.translationZ||0)}Pt(){const t=this.getTranslation();return this.getMap()?this.xe(t):this.lt.translation}xe(t){const e=this.getMap(),n=e.distanceToPointAtRes(t[0],t[1],e.getGLRes()),s=e.altitudeToPoint(t[2],e.getGLRes());return set$4([],A(n.x,t[0]),A(n.y,t[1]),A(s,t[2]))}getRotation(){const t=this._getInternalSymbol();return set$4(this.lt.rotation,t&&t.rotationX||0,t&&t.rotationY||0,t&&t.rotationZ||0)}getScale(){const t=this._getInternalSymbol();return set$4(this.lt.scale,t&&t.scaleX||1,t&&t.scaleY||1,t&&t.scaleZ||1)}zt(){const t=this.getScale();if(this.Ht){const e=this.gt(),n=this.getModelHeight();if(e&&e>0){const e=this.Wt(H$2);return multiply$4(e,e,t)}if(n){const e=this.Jt(H$2);return multiply$4(e,e,t)}}return t}cancelMarkerPixelHeight(){return this.updateSymbol({markerPixelHeight:null})}setAnchorZ(t){return this.updateSymbol({anchorZ:t}),this}getAnchorZ(){const t=this._getInternalSymbol();return t&&t.anchorZ||"bottom"}_setExternSymbol(t){return this.ct=!0,super._setExternSymbol(t)}_e(t){return loadFunctionTypes(t,(()=>{const t=this.getMap();return t?[t.getZoom()]:null}))}_prepareSymbol(t){super._prepareSymbol(t);const e=this._e(t);return e&&e.uniforms&&(e.uniforms=this._e(t.uniforms)),delete this.we,e}hasFunctionDefinition(){if(O$2(this.we))return this.we;const t=this._getInternalSymbol();return this.we=hasFunctionDefinition(t)||t&&t.uniforms&&hasFunctionDefinition(t.uniforms),this.we}setModelMatrix(t){const e=getTranslation$1(this.lt.translation,t),n=getRotation(this.lt.rotation,t),s=getScaling(this.lt.scale,t);return this.setTranslation(e[0],e[1],e[2]),this.setRotation(n[0],n[1],n[2]),this.setScale(s[0],s[1],s[2]),this}getModelMatrix(){return this.ot}ft(){const t=this.be(),e=this.getRotation(),n=fromEuler(D$2,e[0],e[1],e[2]),s=this.zt();this.ot=fromRotationTranslationScale(this.ot,n,t,s)}isDirty(){return this.ct}ve(t){return this.ct=t,this}Te(){const t=this.toJSON();return t.zoomOnAdded=this.de,t}toJSON(){const t=JSON.parse(JSON.stringify({coordinates:this.getCoordinates(),options:this.options||{}})),n=this.getId();t$1.Util.isNil(n)||(t.options.id=n);const s=this.getProperties();s&&(t.options.properties=JSON.parse(JSON.stringify(s)));const i=this.getSymbol();return i&&(t.options.symbol=JSON.parse(JSON.stringify(i))),t}setZoomOnAdded(t){this.de=t}getZoomOnAdded(){return this.de}nt(){return this.X()<1}X(){const t=this.getUniforms(),e=this.getShader();return"pbr"===e||"phong"===e?t&&O$2(t.polygonOpacity)?t.polygonOpacity:1:"wireframe"===e&&t&&O$2(t.lineOpacity)?t.lineOpacity:1}St(t){this.rt=t}isLoaded(){return this.rt}getGLTFMarkerType(){return this.ht}Me(t){this.Oe=t}Rt(){return this.Oe}getCount(){return 1}getContainerExtent(){return this.fe()}getGLTFAsset(){return this._t&&this._t.asset}openInfoWindow(t){this._t?super.openInfoWindow(t):this.once("load",(()=>{super.openInfoWindow(t)}))}getAnimations(){if(!this._t)return null;const t=this._t,e=t.animations?t.animations.map(((t,e)=>({name:O$2(t.name)?t.name:e}))):null;return e?e.map(((t,e)=>t.name||e)):null}getCurrentAnimation(){const t=this._getInternalSymbol();return t&&t.animationName}Kt(){const t=this.getAnimations();if(!t)return null;let e=this.getCurrentAnimation();if(!O$2(e))return t.slice(0,1);const n=[];e=Array.isArray(e)?e:[e];for(let s=0;s<e.length;s++)t.indexOf(e[s])>-1&&n.push(e[s]);return n.length?n:null}setCurrentAnimation(t){this.updateSymbol({animationName:t})}$t(t){O$2(this.ge)||(this.ge=t)}Qt(){return this.ge||0}Zt(){return this.pe=this.pe||{},this.pe}gt(){const t=this._getInternalSymbol();return t&&t.markerPixelHeight}setModelHeight(t){return this.updateSymbol({modelHeight:t}),this}getModelHeight(){const t=this._getInternalSymbol();return t&&t.modelHeight}getGLTFBBox(){return this.Ht}zoomTo(t,e={animation:!1}){const n=this.getBoundingBox(),s=this.getMap();if(!s||!n)return;const{min:i,max:r}=n;W$2.set(i[0],i[1]);const a=s.pointAtResToCoordinate(W$2,s.getGLRes());W$2.set(r[0],r[1]);const h=s.pointAtResToCoordinate(W$2,s.getGLRes()),c=new t$1.Extent(a,h);s.fitExtent(c,t,e,(t=>{"finished"===t.state.playState&&this.Se(i,r,c)})),!1===e.animation&&this.Se(i,r,c)}Se(t,e,n){const s=this.getMap(),r=s.getGLRes(),o=(t[2]+e[2])/2/s.altitudeToPoint(1,r),a=s.cameraPosition,h=s.pointAtResToCoordinate(new t$1.Point(a),r),c=a[2]/s.altitudeToPoint(1,r);h.z=c+o,s.setCameraPosition({position:[h.x,h.y,h.z],pitch:s.getPitch(),bearing:s.getBearing()}),this.fire("zoomtoend",{target:this,extent:n})}Nt(){return this.Mt}Ae(){this.Mt=!1}setAnimationTimeframe(t){const e=this.Qt(),n=this.Zt();this.gltfPack.updateAnimation(t,this.isAnimationLooped(),this.getAnimationSpeed(),e,{},n)}me(){delete this.oe,delete this.de}Yt(){return"effectmarker"!==this.getGLTFMarkerType()&&"glowmarker"!==this.getGLTFMarkerType()}_onEvent(t,e){const n=this.getLayer();if(!n)return;const s=n.getId();this.Ee=t.gltfPickingInfo&&t.gltfPickingInfo[s]||{},super._onEvent(t,e)}_fireEvent(t,e){for(const t in this.Ee)e[t]=this.Ee[t];delete this.Ee,super._fireEvent(t,e)}Y(){let t=[];return this.H&&this.isVisible()&&this.X()?this.isOutline&&this.isOutline()?this.H:(t=this.H.filter((t=>t.properties.outline)),t):t}highlightNodes(t){const e=this.getLayer();if(!e)return;const n=e.getRenderer();if(!n)return;const s=this.H;s&&(t.forEach((t=>{s.forEach((e=>{e.properties.nodeIndex===t.nodeIndex&&this.Pe(e,t.color,t.opacity,t.bloom)}))})),n.setToRedraw())}highlight(t){const e=this.getLayer();if(!e)return;const n=e.getRenderer();if(!n)return;const{color:s,opacity:i,bloom:r}=t,o=this.H;o&&(o.forEach((t=>{this.Pe(t,s,i,r)})),n.setToRedraw())}Pe(t,e,n,s){t.properties.polygonFill||(t.properties.polygonFill=t.getUniform("polygonFill")||Y$2),t.properties.polygonOpacity||(t.properties.polygonOpacity=t.getUniform("polygonOpacity")||1),t.setUniform("polygonFill",e||Y$2),t.setUniform("polygonOpacity",n||1),t.bloom=s}Ie(){if(this.Ce)if(Array.isArray(this.Ce)){const t=this.Ce.map((t=>t.nodeIndex));this.cancelHighlight(t)}else this.cancelHighlight(this.Ce.nodeIndex)}cancelHighlight(t){const e=this.getLayer();if(!e)return;const n=e.getRenderer();if(!n)return;let s=this.H;if(s){if(t){let e=t;Array.isArray(e)||(e=[e]),s=s.filter((t=>e.indexOf(t.properties.nodeIndex)>-1))}s.forEach((t=>{const{polygonFill:e,polygonOpacity:n}=t.properties;t.setUniform("polygonFill",e),t.setUniform("polygonOpacity",n),t.bloom=!1})),n.setToRedraw()}}}et$1.mergeOptions({symbol:null}),et$1.registerJSONType("GLTFMarker");const nt$1=/\{ *([\w_]+) *\}/g;class st$1 extends et$1{constructor(t,e){super(t,e),this.ht="effectmarker"}static fromJSON(t){return new st$1(t.coordinates,t.options)}isAnimated(){const t=this._getInternalSymbol();return t&&t.animation}setTexture(t){const e=this.getLayer()&&this.getLayer().getRenderer();if(e){const n=this.getTextureUrl();e.ke(n),e.Ne(t)}return super.updateSymbol({textureUrl:t}),this}Re(t){const e=this.getTextureUrl(),n=this.getLayer()&&this.getLayer().getRenderer();if(n){let s=e;const i=this.Le();if(i){const n=this.isAnimationLooped(),r=this.getAnimationSpeed()||1,o=n?Math.floor(.01*t*r)%i.length:Math.floor(.01*t);s=e.replace(nt$1,i[o]),this.setUniform("width",1),this.setUniform("height",1),this.setUniform("uvOffset",[0,0])}return n.Be(s,this.Rt())}return null}Le(){const t=this._getInternalSymbol();return t&&t.textureNames}getTextureUrl(){const t=this._getInternalSymbol();return t&&t.textureUrl||"default"}getUrl(){return"plane"}getShader(){return"effect"}setTransparent(t){return this.options.symbol.transparent=t,this}isTransparent(){return this.options.symbol.transparent}updateUV(t){const e=this.isAnimationLooped(),n=this.getAnimationSpeed()||1,s=this.getUniforms()||{},i=s.width||1,r=s.height||1;let o;const a=this.getEffectType();"uv"===a?o=e?.01*t*n%(i*r):.01*t:"sequence"===a&&(o=e?Math.floor(.01*t*n)%(i*r):Math.floor(.01*t));const h=Number(o%i),c=Math.floor(o/i),u=this.Re(t);this._getSymbol()?(this.setUniform("uvOffset",[h,c]),this.setUniform("width",i),this.setUniform("height",r),this.setUniform("texture",u)):this.Tt("uniforms",{uvOffset:[h,c],width:i,height:r,texture:u})}_setExternSymbol(t){super._setExternSymbol(t);const e=this.getLayer()&&this.getLayer().getRenderer();if(e){const t=this.getTextureUrl();e.Ne(t)}}getEffectType(){const t=this._getInternalSymbol();return t&&t.effect||"uv"}setEffectType(t){return this._getInternalSymbol().effect=t,this}remove(){const t=this.getLayer()&&this.getLayer().getRenderer();if(t){const e=this.getTextureUrl();t.ke(e)}super.remove()}}const it$1=["Point","Polygon","LineString","MultiPoint","MultiPolygon","MultiLineString","GeometryCollection","Feature","FeatureCollection"].reduce(((t,e)=>(t[e]=!0,t)),{}),rt$1={toGeometry:function(t,n){if(t$1.Util.isString(t)&&(t=t$1.Util.parseJSON(t)),Array.isArray(t)){const s=[];for(let i=0,r=t.length;i<r;i++){const r=rt$1.Fe(t[i],n);Array.isArray(r)?t$1.Util.pushIn(s,r):s.push(r)}return s}return rt$1.Fe(t,n)},Fe:function(t,n){if(!t||t$1.Util.isNil(t.type))return null;const s=t.type;if("Feature"===s){const s=rt$1.Fe(t.geometry,n);return s?(s.setId(t.id),s.setProperties(t.properties),s):null}if("FeatureCollection"===s){const e=t.features;return e?rt$1.toGeometry(e,n):null}if("Point"===s)return function(t,e){return"EffectLayer"===e?new st$1(t):new et$1(t)}(t.coordinates,n);if("GeometryCollection"===s){const e=t.geometries,s=[],i=e.length;for(let t=0;t<i;t++)s.push(rt$1.Fe(e[t],n));return s}throw new Error("geometry's type is invalid, only support type of Point")},isGeoJSON:function(t){return!(!t||"object"!=typeof t||!t.type||!it$1[t.type]||t instanceof t$1.Geometry)}},ot$1=/\{*(\$root)*\}/g;class at$1 extends t__namespace.OverlayLayer{constructor(e,n,s){!n||n instanceof t__namespace.Geometry||Array.isArray(n)||it$1[n.type]||(s=n,n=null),super(e,null,s),this.pickingId=0,this.De={},this.Ue={},this.Ve={};this.setStyle(s&&s.style),n&&this.addGeometry(n)}static registerShader(t,e,n,s){C[t]={name:t,type:e,config:n,uniforms:s}}static removeShader(t){delete C[t]}static getShaders(){const t=[];for(const e in C)t.push({shader:e,uniforms:C[e].uniforms});return t}static getShaderMap(){return C}addGeometry(t,e){let n=rt$1.isGeoJSON(t)?rt$1.toGeometry(t,this.getJSONType()):t;n=Array.isArray(n)?n:[n];for(let t=0;t<n.length;t++)if(!this.qe(n[t]))return void console.error("type of geometry is invalid");super.addGeometry(n,e),Array.isArray(n)&&this.addMarker(n)}addMarker(t){for(let e=0;e<t.length;e++){const n=t[e];n.Me(this.pickingId),this.De[this.pickingId]=n;const s=n.getId();if(s&&(this.Ve[s]=n),n.fire("add",{type:"add",target:n,layer:this}),"multigltfmarker"===n.getGLTFMarkerType()){const t=n.getCount()||1;this.pickingId+=t}else this.pickingId++}}je(t){const e=this.getRenderer();e&&e.loginGLTFMarker(t)}toJSON(t){t||(t={});const e={type:this.getJSONType(),id:this.getId(),options:this.config()};if((M$2(t.style)||t.style)&&(e.style=this.getStyle()),M$2(t.geometries)||t.geometries){const t=[],n=this._geoList;for(let e=0;e<n.length;e++){const s=n[e].Te();t.push(s)}e.geometries=t}return e}qe(t){return!!t.getGLTFMarkerType&&this.options.markerTypes.indexOf(t.getGLTFMarkerType())>-1}setStyle(t){return t?(this.options.style=t,this.Ge=JSON.parse(JSON.stringify(t)),this.Xe(),this.fire("setstyle",{target:this,style:this.Ge}),this):(delete this.Ge,delete this.options.style,this)}getStyle(){return this.options.style}updateSymbol(t,e){const n=this.getStyle();this.He(t,e,n),this.He(t,e,this.Ge),this.Xe(),this.fire("updatesymbol",{target:this,index:t,symbol:e})}He(t,e,n){if(!n)return;const s=(n.style?n.style:n)[t].symbol||{};for(const t in e)s[t]=e[t]}Xe(){this._processRootUrl(this.Ge);this.ze=compileStyle(this.Ge.style?this.Ge.style:this.Ge),this._geoList.forEach((function(t){this.Je(t)}),this)}getGLTFUrls(){return Object.keys(this.Ue)}_processRootUrl(e){t__namespace.Util.isString(e.$root)&&e.style.forEach((t=>{const n=t.symbol.url;n&&n.indexOf("{$root}")>-1&&(t.symbol.url=n.replace(ot$1,e.$root))}))}Je(t){if(!this.ze)return!1;for(let e=0,n=this.ze.length;e<n;e++)if(!0===this.ze[e].filter({properties:t.getProperties()})){const n=this.ze[e].symbol;return t.Tt("url",n.url),t.updateSymbol(n),!0}return!1}We(t){if(this.ze)for(let e=0,n=this.ze.length;e<n;e++)!0===this.ze[e].filter({properties:t.getProperties()})&&this.ze[e].outline&&t.outline()}Ye(e){const n=t__namespace.Util.isString(e)?this.Ve[e].Rt():e.Rt(),s=this.getRenderer();s&&s.Ze(n),delete this.De[n],delete this.Ve[e]}clear(){return super.clear(),this.De={},this.Ve={},this}tt(){return this.De}Z(t,e,n){const s=this.getRenderer();return s?s.Z(t,e,n):null}_isModelsLoadComplete(){const t=this._geoList;for(let e=0;e<t.length;e++)if(!t[e].isLoaded())return!1;return!0}fe(t){const e=this.getRenderer();return e?e.fe(t):null}Et(t){const e=this.getRenderer();e&&e.Et(t)}outlineBatch(t){const e=this.Ge.style?this.Ge.style:this.Ge;e[t].outline=!0,this.ze=compileStyle(e),this._geoList.forEach((t=>{this.We(t)}))}outlineAll(){this._geoList.forEach((t=>{t.outline()}))}cancelOutline(){this.Ge&&(this.Ge.style?this.Ge.style:this.Ge).forEach((t=>{delete t.outline})),this._geoList.forEach((t=>{t.cancelOutline()}))}}at$1.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,markerEvents:!0,forceRenderOnZooming:!0,forceRenderOnMoving:!0,forceRenderOnRotating:!0});class ht$1 extends(ds$4(at$1)){static initDefaultShader(){const t={shader:{positionAttribute:"POSITION",normalAttribute:"NORMAL",extraCommandProps:{blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}},material:new Ie$5};ht$1.registerShader("phong","PhongShader",t.shader,t.material.getUniforms());const e={shader:{positionAttribute:"POSITION",normalAttribute:"NORMAL",tangentAttribute:"TANGENT",colorAttribute:"COLOR_0",uv0Attribute:"TEXCOORD_0",uv1Attribute:"TEXCOORD_1",extraCommandProps:{cull:{enable:!0},frontFace:"ccw",blend:{enable:(t,e)=>!!e.meshConfig.transparent,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}},material:new fi$4.StandardMaterial({})};ht$1.registerShader("pbr","pbr.StandardShader",e.shader,e.material.getUniforms()),ht$1.registerShader("depth","pbr.StandardDepthShader",e.shader,e.material.getUniforms());const n={shader:{positionAttribute:"POSITION",color0Attribute:"COLOR_0",extraCommandProps:{blend:{enable:!1,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}},material:new Ce$5};ht$1.registerShader("pointline","PointLineShader",n.shader,n.material.getUniforms());const s={shader:{positionAttribute:"POSITION",extraCommandProps:{blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}},material:new Ce$5({lineColor:[0,0,0,1],lineOpacity:1})};ht$1.registerShader("wireframe","EdgeShader",s.shader,s.material.getUniforms());const i={shader:{positionAttribute:"POSITION",normalAttribute:"NORMAL",extraCommandProps:{blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}},material:new Ne$5};ht$1.registerShader("pbr-lite","StandardLiteShader",i.shader,i.material.getUniforms())}static fromJSON(t){if(!t||"GLTFLayer"!==t.type)return null;const e=new ht$1(t.id,t.options),n=t.geometries,s=[];for(let t=0;t<n.length;t++){const e=et$1.parseJSONData(n[t]);e&&s.push(e)}return e.addGeometry(s),t.style&&e.setStyle(t.style),e}onAdd(){const t=this.getMap();this._geoList.forEach((e=>{O$2(e.getZoomOnAdded())||e.setZoomOnAdded(t.getZoom())})),super.onAdd()}onRemove(){super.onRemove(),this.clear()}identify(e,n){const s=this.getMap();if(!s)return[];const i=s.coordinateToContainerPoint(new t__namespace.Coordinate(e));return this.identifyAtPoint(i,n)}identifyAtPoint(e,n={}){const s=[];if(!n.excludeMasks){const i=this.identifyMask(e,n);i&&i.length&&t__namespace.Util.pushIn(s,i)}const i=this.getMap();if(!i)return[];const r=i.getDevicePixelRatio(),h=this.Z(e.x*r,e.y*r,n);if(h&&(h.data||h.length))if(n.includeInternals&&!n.excludeMasks){s.push(h.data);const t=n.domEvent;t&&(t.gltfPickingInfo=t.gltfPickingInfo||{},t.gltfPickingInfo[this.getId()]=h)}else s.push(h);return s}Ke(){this.pickingId=0;const t={};for(const e in this.De){const n=this.De[e];n.Me(this.pickingId),t[this.pickingId]=n;const s=n.getCount()||1;this.pickingId+=s}this.De=t}_onGeometryEvent(t){if(!t||!t.target)return;const e=t.type;if("meshcreate"===e)this.$e(t);else if("modelerror"===e)this.Qe(t);else if("positionchange"===e){const t=this.getRenderer();t&&t.setToRedraw()}super._onGeometryEvent(t)}Qe(t){const{url:e,info:n}=t;console.error(n),this.fire("modelerror",{type:"modelerror",url:e,info:n})}$e(t){this.Ue[t.url]=1,this.getRenderer().setToRedraw(),this._isModelsLoadComplete()&&this.fire("modelload",{models:this.getGLTFUrls()})}}ht$1.initDefaultShader(),ht$1.mergeOptions({markerTypes:["gltfmarker","multigltfmarker"],pointSize:1}),ht$1.registerJSONType("GLTFLayer"),ht$1.registerRenderer("gl",F$2);const ut$1=new t$1.Coordinate(0,0),lt$1=new t$1.Point(0,0),ft$1=new t$1.Point(0,0),dt$1=new t$1.Point(0,0);const pt$1=[1,1,1,1],gt$1=[],yt$1=[],bt$1=[1,1,1],xt$1=new t$1.Coordinate(0,0);class _t$1 extends et$1{constructor(t,e){super(null,e),this.tn=t||[],this.en=[],this.nn=[0,0,0],this.sn=identity$2([]),this.ht="multigltfmarker",this.in=[]}static fromJSON(t){return new _t$1(t.data,t.options)}setCoordinates(t){return this.rn=Array.isArray(t[0])?t.map((t=>new t$1.Coordinate(t))):t,this.updateAllData("coordinates",this.rn),this.ct=!0,this}getCoordinates(t){if(t&&this.tn&&this.tn.length){return this.tn[t.index].coordinates}return null}addData(t){this.tn||(this.tn=[]),this.tn.push(t);const e=this.getLayer();return e&&e.Ke(),this.ct=!0,this}removeData(t){this.tn.splice(t,1),this.en&&this.en.splice(t,1);const e=this.getLayer();return e&&e.Ke(),this.ct=!0,this}getData(t){return this.tn[t]}updateData(t,e,n){return this.tn[t][e]=n,this.ct=!0,this}getAllData(){return this.tn}updateAllData(t,e){for(let n=0;n<this.tn.length;n++)this.updateData(n,t,e[n]);return this}removeAllData(){this.tn&&(this.tn=[],this.en=[])}he(){const t=this.getMap();if(this.tn&&t){this.an(),this.en=this.en||[];for(let t=0;t<this.tn.length;t++){const e=this.hn(t);this.en[t]=e}}}openInfoWindow(t){let e=null;e=O$2(t)&&this.tn[t]?this.tn[t].coordinates:this.getCenter(),super.openInfoWindow(e)}getCenter(){let t=0,e=0,s=0,i=0;for(let r=0,o=this.tn.length;r<o;r++){let o=this.tn[r].coordinates;o instanceof t$1.Coordinate&&(o=o.toArray()),t+=o[0],e+=o[1],s+=o[2]||0,i++}return 0===i?null:xt$1.set(t/i,e/i,s/i)}an(){const t=this.getMap(),e=this.getCenter();if(!e)return;this.nn=S$2(t,e);const n=fromEuler(yt$1,0,0,0);fromRotationTranslationScale(this.sn,n,this.nn,bt$1)}hn(t){const e=this.tn[t],n=this.ye(e.coordinates);if(!n)return null;const s=sub$2(gt$1,n,this.nn),i=this.xe(e.translation||this.lt.translation),r=add$4(gt$1,i||this.lt.translation,s||this.lt.translation),o=e.rotation||this.lt.rotation,a=e.scale||this.lt.scale,h=fromEuler(yt$1,o[0]||0,o[1]||0,o[2]||0);return fromRotationTranslationScale(this.en[t]||[],h,r,a)}ft(){super.ft(),this.he()}cn(){this.un={instance_vectorA:[],instance_vectorB:[],instance_vectorC:[],instance_color:[],aPickingId:[],aOutline:[],aBloom:[]},this.ln={instance_vectorA:[],instance_vectorB:[],instance_vectorC:[],instance_color:[],aPickingId:[],aOutline:[],aBloom:[]};for(let t=0;t<this.en.length;t++){let e=this.un;this.tn[t].bloom&&(e=this.ln);const n=this.en[t],s=e.instance_vectorA.length/4;this.dn(e,"instance_vectorA",s,n,0),this.dn(e,"instance_vectorB",s,n,1),this.dn(e,"instance_vectorC",s,n,2);const i=this.tn[t].color||pt$1;e.instance_color[4*s]=i[0],e.instance_color[4*s+1]=i[1],e.instance_color[4*s+2]=i[2],e.instance_color[4*s+3]=i[3],e.aPickingId[s]=this.Rt()+t,e.aOutline[s]=this.tn[t].outline?1:0,e.aBloom[s]=this.tn[t].bloom?1:0}return{attributesData:this.un,bloomAttributesData:this.ln}}Vt(t){const{attributesData:e,bloomAttributesData:n}=this.ce();for(const n in e)t.updateInstancedData(n,e[n]);if(this.regl?t.generateInstancedBuffers(this.regl):(this.R=this.R||[],this.R.push(t)),t.instanceCount=this.un.instance_vectorA.length/4,this.mn()){const e=n,s=e.aBloom.length;t.properties.bloomMesh=t.properties.bloomMesh||new Ge$5(e,s,t.geometry,t.material);const i=t.properties.bloomMesh;i.positionMatrix=t.positionMatrix,i.localTransform=t.localTransform;for(const t in e)i.updateInstancedData(t,e[t]);i.generateInstancedBuffers(this.regl);const r=t.getDefines();i.setDefines(r),i.uniforms=t.uniforms,i.bloom=1,i.instanceCount=s}else t.properties.bloomMesh&&(t.properties.bloomMesh.dispose(),delete t.properties.bloomMesh)}pn(t,e,n,s){this.ln[t]&&n&&(this.ln[t][4*e]=n[s],this.ln[t][4*e+1]=n[s+4],this.ln[t][4*e+2]=n[s+8],this.ln[t][4*e+3]=n[s+12])}mn(){return this.ln&&this.ln.aBloom.length}dn(t,e,n,s,i){t[e]&&s&&(t[e][4*n]=s[i],t[e][4*n+1]=s[i+4],t[e][4*n+2]=s[i+8],t[e][4*n+3]=s[i+12])}ce(t){return!this.ct&&this.un?{attributesData:this.un,bloomAttributesData:this.ln}:this.cn(t)}Ut(){return this.sn}getCount(){return this.tn.length}gn(){return this.he(),this.ln?this.ln.aBloom.length:0}ue(){return this.getCount()-this.gn()}toJSON(){const t=JSON.parse(JSON.stringify({data:this.tn,options:this.options})),e=this.getProperties();return t.options&&(t.options.properties=e),t}getIndexByPickingId(t){return t-this.Rt()}outline(t){return O$2(t)&&this.updateData(t,"outline",!0),this}cancelOutline(t){return O$2(t)&&this.updateData(t,"outline",!1),this}isOutline(){if(!this.tn||!this.tn.length)return!1;for(let t=0;t<this.tn.length;t++)if(this.tn[t].outline)return!0;return!1}nt(){const t=this.getAllData();for(let e=0;e<t.length;e++){const n=t[e].color;if(n&&n[3]<1)return!0}return!1}}const wt$1=[];class vt$1 extends _t$1{constructor(t,e){super(null,e),this.on("load",(()=>{this.setCoordinates(t)}))}setCoordinates(t){this.rn=t,this.yn()}getCoordinates(){return this.rn}yn(){const t=this.rn;if(t){this.removeAllData();for(let e=0;e<t.length-1;e++){const n=this.bn(t[e]),s=this.bn(t[e+1]);this.xn(n,s).forEach((t=>{this.addData(t)}))}this.ct=!0}}xn(t,e){const n=[],s=this.getMap();if(!s)return n;const i=s.getProjection().measureLenBetween(t,e),r=this._n(t,e),o=Math.floor(i/r),a=this.wn(t,e);if(o>=1){for(let s=1;s<=o;s++){const h={coordinates:this.vn(t,e,r*(s-.5)/i),scale:[1,1,1],rotation:[0,0,a]};n.push(h)}if(this.options.scaleVertex){const h=(i-r*o)/r,c={coordinates:this.vn(t,e,(r*o+(i-r*o)/2)/i),scale:[h,1,1],rotation:[0,0,a]};n.push(c)}}else if(this.options.scaleVertex){const s=i/r,o={coordinates:this.vn(t,e,.5),scale:[s,1,1],rotation:[0,0,a]};n.push(o)}return n}vn(t,e,s){const i=Tt$1(t.x,e.x,s),r=Tt$1(t.y,e.y,s);return new t$1.Coordinate(i,r)}_n(t,e){const s=this.getMap(),i=s.getGLRes(),r=new t$1.Coordinate(0,(t.y+e.y)/2),o=s.altitudeToPoint(100,i,r)/s.altitudeToPoint(100,i),a=this.getGLTFBBox(),h=this.options.direction||0,c=[1,1,1];if(this.getModelHeight())this.Jt(c);else{const t=this.getSymbol();set$4(c,t.scaleX||1,t.scaleY||1,t.scaleZ||1)}const u=sub$2(wt$1,a.max,a.min);multiply$4(u,u,c);return u[h]/o+this.options.gapLength}wn(t,n){const s=this.getMap(),i=s.getGLRes(),r=s.coordinateToPointAtRes(t,i),o=s.coordinateToPointAtRes(n,i);return t$1.Util.computeDegree(o.x,o.y,r.x,r.y)/Math.PI*180}bn(t){return Array.isArray(t)?new t$1.Coordinate(t):t}}function Tt$1(t,e,n){return t+n*(e-t)}vt$1.mergeOptions({direction:0,gapLength:0,scaleVertex:!0}),vt$1.registerJSONType("GLTFLineString");const Mt$1=new en$5({url:void 0,mag:"linear"});class Ot$1 extends F$2{constructor(t){super(t),this._textureMap={}}Be(t){return this.regl&&this._textureMap[t]?this._textureMap[t].texture.getREGLTexture(this.regl):Mt$1}Ne(t){if(this._textureMap[t])this._textureMap[t].count++;else{this.Tn=this.Tn||new Ve$5;const n=new en$5({url:"default"===t?void 0:t,mag:"linear"},this.Tn);n.once("complete",(()=>{this.setToRedraw()}),this),this._textureMap[t]={count:1,texture:n}}}ke(t){this._textureMap[t]&&(this._textureMap[t].count--,this._textureMap[t].count<1&&(this._textureMap[t].texture.dispose(),delete this._textureMap[t]))}}class St$1 extends at$1{static initDefaultShader(){const t={shader:{vert:"\n        attribute vec3 aPosition;\n        attribute vec2 aTexCoord;\n        uniform mat4 projViewMatrix;\n        uniform mat4 modelMatrix;\n        uniform vec2 uvOffset;\n        uniform float width;\n        uniform float height;\n        varying vec2 vTexCoords;\n        void main()\n        {\n            gl_Position = projViewMatrix * modelMatrix * vec4(aPosition, 1.0);\n            vTexCoords = (uvOffset + aTexCoord) * vec2(1.0 / width, 1.0 / height);\n        }\n    ",frag:"\n        precision mediump float;\n        uniform sampler2D texture;\n\n        varying vec2 vTexCoords;\n        void main() {\n            vec4 color = texture2D(texture, vTexCoords);\n            gl_FragColor = vec4(color.rgb, color.a) * color.a;\n        }\n    ",positionAttribute:"POSITION",extraCommandProps:{blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"}}},material:new Ce$5};St$1.registerShader("effect","MeshShader",t.shader,t.material.getUniforms())}onAddGeometry(t){super.onAddGeometry(t);const e=t.getTextureUrl(),n=this.getRenderer();n?n.Ne(e):this.on("renderercreate",(t=>{t.renderer.Ne(e)}))}remove(){const t=this.getRenderer();t&&this._geoList.forEach((e=>{const n=e.getTextureUrl();t.ke(n)})),super.remove()}clear(){const t=this.getRenderer();t&&this._geoList.forEach((e=>{const n=e.getTextureUrl();t.ke(n)})),super.clear()}getTextureMapTest(){const t=this.getRenderer();return t?t._textureMap:null}}St$1.initDefaultShader(),St$1.mergeOptions({markerTypes:["effectmarker"]}),St$1.registerJSONType("EffectLayer"),St$1.registerRenderer("gl",Ot$1);class At$1 extends et$1{constructor(t,e){super(t,e),this.ht="glowmarker"}static fromJSON(t){return new At$1(t.coordinates,t.options)}getUrl(){return"plane"}setSpeed(t){this.setUniform("speed",t)}getSpeed(){return this._getInternalSymbol().uniforms.speed}getShader(){return"glowmarker"}isAnimated(){const t=this._getInternalSymbol();return t&&t.animation}kt(){let t=this._getInternalSymbol().uniforms.time||0;t+=.01,this.setUniform("time",t)}}At$1.mergeOptions({visible:!0});class Et$1 extends at$1{static initDefaultShader(){const t=function(){const t={vert:"\n        #ifdef GL_ES\n            precision highp float;\n        #endif\n        attribute vec3 aPosition;\n        uniform mat4 projViewModelMatrix;\n        uniform mat4 modelMatrix;\n        uniform mat4 positionMatrix;\n        varying vec3 v_FragPos;\n        varying vec3 v_center;\n        #include <get_output>\n        void main(){\n            mat4 localPositionMatrix = getPositionMatrix();\n            vec4 localVertex = getPosition(aPosition);\n            vec4 position = localPositionMatrix * localVertex;\n            gl_Position = projViewModelMatrix * position;\n            vec4 worldPos = modelMatrix * position;\n            v_FragPos = worldPos.xyz;\n            v_center = (modelMatrix * vec4(0.0, 0.0, 0.0, 1.0)).xyz;\n        }\n    ",frag:"\n        #ifdef GL_ES\n            precision highp float;\n        #endif\n        #define pi 3.14159\n        const float dotsnb = 30.0; // Number of dots\n\n        varying vec3 v_FragPos;\n        varying vec3 v_center;\n        uniform float time;\n        uniform float radius;\n        uniform vec3 color;\n        uniform float speed;\n        vec3 hsb2rgb(in vec3 c)\n        {\n            vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0,0.0,1.0 );\n            rgb = rgb*rgb*(4.0-2.0*rgb);\n            return c.z * mix( vec3(1.0), rgb, c.y);\n        }\n\n        void main()\n        {\n            float r = length(v_FragPos - v_center);\n            r = r*2.-1.;\n            if(r>radius) {\n                gl_FragColor = vec4(1.0,1.0,1.0, 0.0);\n            } else {\n                //vec3 color = hsb2rgb(vec3(fract(time*.1),.7,.4));\n                vec3 color = color;\n                float s = abs(sin(pow(r+5.0, 1.5)-time*speed+sin(r*0.9))*sin(r+.99));\n                color *= (abs(1./(s*10.8))-.01);\n                gl_FragColor = vec4(color, (color.x + color.y + color.z) / 1.0);\n            }\n        }\n    ",uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(t,e){return multiply$5([],e.projViewMatrix,e.modelMatrix)}}],positionAttribute:"POSITION",extraCommandProps:{blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one",dstAlpha:1},equation:{rgb:"add",alpha:"add"},color:[0,0,0,0]}}};return{shader:t,material:new Ce$5}}();Et$1.registerShader("glowmarker","MeshShader",t.shader,t.material.getUniforms())}}Et$1.initDefaultShader(),Et$1.mergeOptions({markerTypes:["glowmarker"]}),Et$1.registerJSONType("GlowMarkerLayer"),Et$1.registerRenderer("gl",F$2);const Pt$1={url:"plane",animation:!0,loop:!0,rotation:[0,0,0],translation:[0,0,30],scale:[1,1,30]},It$1={width:1,height:1,modelHeight:60,startOpacity:0,endOpacity:1};class kt$1 extends at$1{static initDefaultShader(){const t={shader:{vert:"\n        attribute vec3 aPosition;\n        attribute vec2 aTexCoord;\n        uniform mat4 projViewMatrix;\n        uniform mat4 modelMatrix;\n        uniform vec2 uvOffset;\n        uniform float width;\n        uniform float height;\n        varying vec2 vTexCoords;\n        varying float vHeight;\n        void main()\n        {\n            vec4 worldPosition = modelMatrix * vec4(aPosition, 1.0);\n            gl_Position = projViewMatrix * worldPosition;\n            vHeight = worldPosition.z;\n            vTexCoords = (uvOffset + aTexCoord) * vec2(1.0 / width, 1.0 / height);\n        }\n    ",frag:"\n        precision mediump float;\n        uniform sampler2D texture;\n        uniform float modelHeight;\n        uniform float startOpacity;\n        uniform float endOpacity;\n        varying float vHeight;\n        varying vec2 vTexCoords;\n        void main() {\n            vec4 color = texture2D(texture, vTexCoords);\n            float opacity = (endOpacity - startOpacity) * (1.0 - vHeight / modelHeight);\n            gl_FragColor = vec4(color.rgb, color.a) * color.a * opacity;\n        }\n    ",positionAttribute:"POSITION",extraCommandProps:{blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"}}},material:new Ce$5};kt$1.registerShader("effectline","MeshShader",t.shader)}}kt$1.initDefaultShader(),kt$1.mergeOptions({markerTypes:["effectmarker"]}),kt$1.registerJSONType("EffectLineLayer"),kt$1.registerRenderer("gl",Ot$1);const Nt$1={offsetX:0,offsetY:0,uReflectivity:.8,opacity:.9,color:[.9,0,0,1]};class Lt$1 extends at$1{static initDefaultShader(){const t=function(){const t={vert:"\n        attribute vec3 aPosition;\n        attribute vec2 aTexCoord;\n        attribute vec3 aNormal;\n        uniform mat4 projViewMatrix;\n        uniform mat4 modelMatrix;\n        uniform mat4 normalMatrix;\n        uniform float offsetX;\n        uniform float offsetY;\n        varying vec2 uv;\n        void main()\n        {\n            gl_Position = projViewMatrix * modelMatrix * vec4(aPosition, 1.0);\n            uv = vec2(aTexCoord.x + offsetX, aTexCoord.y + offsetY);\n        }\n    ",frag:"\n        precision mediump float;\n        uniform sampler2D effectTexture;\n        uniform vec3 uCameraPosition;\n        uniform mat4 viewMatrix;\n        uniform float uReflectivity;\n        uniform vec4 color;\n        uniform float opacity;\n\n        varying vec2 uv;\n\n        vec3 inverseTransformDirection(in vec3 dir, in mat4 matrix) {\n            return normalize((vec4(dir, 0.0) * matrix).xyz);\n        }\n\n        const float GAMMA_FACTOR = 2.0;\n        vec4 GammaToLinear(in vec4 value, in float gammaFactor) {\n            return vec4(pow(value.xyz, vec3(gammaFactor)), value.w);\n        }\n\n        vec4 mixTexelToLinear(vec4 value) {\n            return GammaToLinear(value, float(GAMMA_FACTOR));\n        }\n\n        void main() {\n            vec4 texColor = texture2D(effectTexture, uv);\n            if (color.a == 0.0) {\n                discard;\n            }\n            vec4 mixColor = mixTexelToLinear(color);\n            texColor.rgb += mixColor.xyz * uReflectivity;\n            texColor.a*= opacity;\n            gl_FragColor = texColor;\n        }\n    ",uniforms:[{name:"normalMatrix",type:"function",fn:function(t,e){const n=[];return invert$2(n,e.modelMatrix),transpose(n,n),n}}],positionAttribute:"POSITION",extraCommandProps:{depth:{enable:!0,mask:!1},blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"}}};return{shader:t,material:new Ce$5}}();Lt$1.registerShader("effectring","MeshShader",t.shader)}}Lt$1.initDefaultShader(),Lt$1.mergeOptions({markerTypes:["effectring"]}),Lt$1.registerJSONType("EffectRingLayer"),Lt$1.registerRenderer("gl",F$2);const Bt$1={animation:!0,loop:!0,url:"plane",effect:"sequence",speed:1,scale:[1,1,1],rotation:[90,0,0]},Ft$1={width:9,height:5};if(transcoders){const e=t__namespace.Map.VERSION;if(e.indexOf("1.0.0-beta")>=0||e.indexOf("1.0.0-alpha")>=0){const e=transcoders.inject(T$2);t__namespace.registerWorkerAdapter("@maptalks/gltf-layer",e)}else t__namespace.registerWorkerAdapter("@maptalks/gltf-layer",(function(){return transcoders.inject(T$2)}))}else t__namespace.registerWorkerAdapter("@maptalks/gltf-layer",T$2);
/*!
	 * @maptalks/transform-control v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */
const w$1={yuanhuan:{accessors:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½_1_0_positions",componentType:5126,count:104,min:[-5.407599925994873,-5.404099941253662,0],max:[5.405200004577637,5.406300067901611,0],type:"VEC3",bufferView:0,byteOffset:0},{name:"ï¿½ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½_1_0_normals",componentType:5126,count:104,min:[0,0,1],max:[0,0,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"ï¿½ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½_1_0_indices",componentType:5123,count:288,min:[0],max:[103],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"ç¼©æ”¾åœˆ-æ–°",byteLength:3072,uri:"data:application/octet-stream;base64, "}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:1248,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:1248,byteOffset:1248,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:576,byteOffset:2496,target:34963}],materials:[{name:"SVGMat_001",pbrMetallicRoughness:{baseColorFactor:[.5,.5,.5,1],metallicFactor:0,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡ï¿½ï¿½",mesh:0}],scene:0,scenes:[{nodes:[0]}]},yuanhuan41:{accessors:[{name:"Ô²ï¿½ï¿½_1_0_positions",componentType:5126,count:39,min:[0,0,0],max:[5.489999771118164,0,5.488900184631348],type:"VEC3",bufferView:0,byteOffset:0},{name:"Ô²ï¿½ï¿½_1_0_normals",componentType:5126,count:39,min:[0,-.999939501285553,-1],max:[.13969914615154266,1,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"Ô²ï¿½ï¿½_1_0_indices",componentType:5123,count:105,min:[0],max:[38],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"yh41",byteLength:1148,uri:"data:application/octet-stream;base64,8tKXQAAAAACoNU09FK6vQAAAAAB1Ako/FK6vQAAAAAAAAACATfOAQAAAAAACmkg+K4dWQAAAAAAIrNw+WvUtQAAAAABbsT8/X5gIQAAAAACMSpI/OUWbQAAAAAD0/VQ/LbKHQAAAAAD0/XQ/W0JqQAAAAAC6SZQ/dLXNPwAAAACfq80/H4VHQAAAAAB0JLc/ZognQAAAAAA1XuI/YVSSPwAAAAAukAhABaMKQAAAAAB4nApABcU/PwAAAACF6y1Aw2TiPwAAAACRfidASS63PwAAAABKe0dAJLncPgAAAACze1ZAj1OUPwAAAADjNmpAAppIPgAAAADu64BAnRF1PwAAAAD8qYdAqDVNPQAAAADBypdAgQRVPwAAAAAIPZtAAAAAAAAAAAASpa9AAwlKPwAAAAASpa9AJJd/PAAAAAASpa9AAwlKPwAAAAASpa9AAAAAAAAAAAASpa9Asp1vPQAAAAASpa9AJLn8PQAAAAASpa9AqoJRPgAAAAASpa9ARwOYPgAAAAASpa9AHhbKPgAAAAASpa9A2hv8PgAAAAASpa9A5q4VPwAAAAASpa9A+n4qPwAAAAASpa9AQxw7PwAAAAASpa9AwhdGPwAAAAASpa9AAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAJ5X/OwL+fz8AAACAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/Kzs0PAn8f78AAACApLK/PA7uf78AAACAeJkZPefRfz8AAACA+ZldPQSgf78AAACA6XSTPelVfz8AAACALLO3PdT3fr8AAACAfkjZPR2Ofr8AAACANf32Paohfj8AAACAeUYHPqDBfT8AAACASw0PPlt9fb8AAACAAAABAAIAAwABAAAABAABAAMABQABAAQABgAHAAUABwABAAUABgAIAAcABgAJAAgACgAJAAYACgALAAkACgAMAAsADQAMAAoADQAOAAwADwAOAA0ADwAQAA4ADwARABAAEgARAA8AEgATABEAFAATABIAFAAVABMAFgAVABQAFgAXABUAGAAXABYAGAAZABcAGgAbABwAHQAbABoAHgAbAB0AHwAbAB4AIAAbAB8AIQAbACAAIgAbACEAIwAbACIAJAAbACMAJQAbACQAJgAbACUAAAA="}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:468,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:468,byteOffset:468,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:212,byteOffset:936,target:34963}],materials:[{name:"SVGMat_002",pbrMetallicRoughness:{baseColorFactor:[.588,.588,.588,1],metallicFactor:0,roughnessFactor:.99},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"Ô²ï¿½ï¿½_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"Ô²ï¿½ï¿½",mesh:0}],scene:0,scenes:[{nodes:[0]}]},yuanhuan411:{accessors:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡È¦_1_0_positions",componentType:5126,count:28,min:[.026000000536441803,-4.6834001541137695,0],max:[4.696700096130371,-.014800000004470348,0],type:"VEC3",bufferView:0,byteOffset:0},{name:"ï¿½ï¿½ï¿½ï¿½Ð¡È¦_1_0_normals",componentType:5126,count:28,min:[0,0,1],max:[0,0,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"ï¿½ï¿½ï¿½ï¿½Ð¡È¦_1_0_indices",componentType:5123,count:78,min:[0],max:[27],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"yuanhuan411",byteLength:828,uri:"data:application/octet-stream;base64,ufwXQLN7Mr8AAAAAObRAQLFQK78AAAAA1ediQMWP8b4AAAAAGQQ6QCv2174AAAAAqFdeQHUCWr4AAAAA7FGCQL6fmr0AAAAAHHyDQDLmrr4AAAAAXkuWQJf/kL4AAAAAXkuWQLN7crwAAAAAMCrxP2RdhL8AAAAA/BgDQJeQn78AAAAADeARQAg9i78AAAAAukkIQISeXb8AAAAAZaogQH/Zbb8AAAAA7Q3ePr4wOcAAAAAA5IMuP9/gP8AAAAAAJQZxPwrXH8AAAAAAPZs1P6UsF8AAAAAAdy2hP0VHAsAAAAAAb/CFP5eQ778AAAAA0ES4P32utr8AAAAAAprQPyL9zr8AAAAAi/1lPqqCXcAAAAAA9dv3PtcSYsAAAAAADi2yPZvmgcAAAAAAYTK1PssQg8AAAAAA9P3UPGrelcAAAAAA4liXPmrelcAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAABAAIAAAACAAMAAwACAAQABQAGAAcABQAHAAgABAACAAYABAAGAAUACQAKAAsACQALAAwAAAANAAEADgAPABAADgAQABEAEQAQABIAEQASABMAFAAVAAoAFAAKAAkADAALAA0ADAANAAAAFgAXAA8AFgAPAA4AGAAZABcAGAAXABYAGgAZABgAGgAbABkAEwASABUAEwAVABQA"}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:336,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:336,byteOffset:336,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:156,byteOffset:672,target:34963}],materials:[{name:"SVGMat",pbrMetallicRoughness:{baseColorFactor:[.588,.588,.588,1],metallicFactor:0,roughnessFactor:.99},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡È¦_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"ï¿½ï¿½ï¿½ï¿½Ð¡È¦",mesh:0}],scene:0,scenes:[{nodes:[0]}]},yuanpan:{accessors:[{name:"Circle001_1_0_positions",componentType:5126,count:28,min:[-1.9510999917984009,0,-1.9510999917984009],max:[1.9510999917984009,0,1.9510999917984009],type:"VEC3",bufferView:0,byteOffset:0},{name:"Circle001_1_0_normals",componentType:5126,count:28,min:[0,1,0],max:[0,1,0],type:"VEC3",bufferView:1,byteOffset:0},{name:"Circle001_1_0_indices",componentType:5123,count:78,min:[0],max:[27],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"yuanpan",byteLength:828,uri:"data:application/octet-stream;base64,S+rkvgAAAADRIvM/AAAAAAAAAAClvfk/S+rkPgAAAADRIvM/0SLzvwAAAABL6uQ+MlXgvwAAAACsi1s/c9fCvwAAAACvJZw/pb35vwAAAAAAAAAA0SLzvwAAAABL6uS+MlXgvwAAAACsi1u/c9fCvwAAAACvJZy/ryWcvwAAAABz18K/rItbvwAAAAAyVeC/S+rkvgAAAADRIvO/AAAAgAAAAAClvfm/S+rkPgAAAADRIvO/rItbPwAAAAAyVeC/ryWcPwAAAABz18K/c9fCPwAAAACvJZy/MlXgPwAAAACsi1u/0SLzPwAAAABL6uS+pb35PwAAAAAAAACA0SLzPwAAAABL6uQ+MlXgPwAAAACsi1s/c9fCPwAAAACvJZw/ryWcvwAAAABz18I/ryWcPwAAAABz18I/rItbvwAAAAAyVeA/rItbPwAAAAAyVeA/AAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAAAAAAAgD8AAACAAAABAAIAAwAEAAUABgADAAUABwAGAAUACAAHAAUACQAIAAUACgAJAAUACwAKAAUADAALAAUADQAMAAUADgANAAUADwAOAAUAEAAPAAUAEQAQAAUAEgARAAUAEwASAAUAFAATAAUAFQAUAAUAFgAVAAUAFwAWAAUAFwAFABgAGQAXABgAGQAYABoAGwAZABoAAgAbABoAAAACABoA"}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:336,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:336,byteOffset:336,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:156,byteOffset:672,target:34963}],materials:[{name:"wire_008110135",pbrMetallicRoughness:{baseColorFactor:[.0314,.4314,.5294,1],metallicFactor:0,roughnessFactor:.968},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"Circle001_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"Circle001",mesh:0}],scene:0,scenes:[{nodes:[0]}]},zzhou:{accessors:[{name:"Cube.001-Mesh_0_positions",componentType:5126,count:45,min:[-.2711470127105713,-5.473427772521973,-.2711470127105713],max:[.2711470127105713,.46298399567604065,.2711470127105713],type:"VEC3",bufferView:0,byteOffset:0},{name:"Cube.001-Mesh_0_normals",componentType:5126,count:45,min:[-1,-1,-1],max:[1,1,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"Cube.001-Mesh_0_texcoords",componentType:5126,count:45,min:[.125,0],max:[.875,1],type:"VEC2",bufferView:2,byteOffset:0},{name:"Cube.001-Mesh_0_indices",componentType:5123,count:72,min:[0],max:[44],type:"SCALAR",bufferView:3,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"Z",byteLength:1584,uri:"data:application/octet-stream;base64,/waNvZMdK77/Bo09/waNPZMdK77/Bo09/waNPR4Kr8D/Bo09l+KKPVImr8D/Bo09/waNvVImr8D/Bo09yNOKPsjTir7I04o+AAAAAD0M7T4AAAAAyNOKvsjTir7I04o+yNOKvsjTir7I04o+AAAAAD0M7T4AAAAAyNOKvsjTir7I04q+yNOKvsjTir7I04q+yNOKPsjTir7I04q+yNOKPsjTir7I04o+yNOKvsjTir7I04o+yNOKPsjTir7I04q+AAAAAD0M7T4AAAAAyNOKPsjTir7I04o+yNOKvsjTir7I04q+AAAAAD0M7T4AAAAAyNOKPsjTir7I04q+/waNPZMdK77/Bo09/waNPZMdK77/Bo29/waNPVImr8D/Bo29/waNPVImr8D/Bo09/waNPR4Kr8D/Bo09/waNvZMdK77/Bo09/waNvVImr8D/Bo09/waNvVImr8D/Bo29/waNvZMdK77/Bo29/waNvZMdK77/Bo29/waNvVImr8D/Bo29/waNPVImr8D/Bo29/waNPZMdK77/Bo29/waNPZMdK77/Bo09/waNvZMdK77/Bo09/waNvZMdK77/Bo29/waNPZMdK77/Bo29/waNvVImr8D/Bo09cooOO1Imr8BAMTI7/waNvVImr8D/Bo29/waNPVImr8D/Bo29/waNPVImr8D/Bo09l+KKPVImr8D/Bo09/waNPVImr8D/Bo09AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAFFmsT5wJHA/AAAAAFFmsT5wJHA/AAAAAFFmsT5wJHA/cCRwv1FmsT4AAAAAcCRwv1FmsT4AAAAAcCRwv1FmsT4AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAcCRwP1FmsT4AAAAAcCRwP1FmsT4AAAAAcCRwP1FmsT4AAAAAAAAAAFFmsT5wJHC/AAAAAFFmsT5wJHC/AAAAAFFmsT5wJHC/AACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIC/AAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAADAPgAAQD8AAMA+AACAP2L1Hz8AAIA/AAAgP3uDfz8AACA/AABAPwAAwD4AAIA+AAAgPwAAAAAAAMA+AAAAAAAAwD4AAIA/AAAgPwAAQD8AAMA+AABAPwAAAD4AAAA/AADAPgAAAD8AAMA+AACAPgAAAD4AAIA+AADAPgAAAD8AACA/AACAPgAAwD4AAIA+AADAPgAAQD8AACA/AAAAPwAAwD4AAAA/AADAPgAAAD8AAMA+AABAPwAAID8AAEA/AAAgPwAAAD9i9R8/AAAAPwAAwD4AAAA/AAAgPwAAAD8AACA/AACAPgAAwD4AAIA+AADAPgAAgD4AACA/AACAPgAAID8AAAAAAADAPgAAAAAAAAA+AAAAPwAAwD4AAAA/AADAPgAAgD4AAAA+AACAPgAAID8AAAA/vAJBP/mGwj4AACA/AACAPgAAYD8AAIA+AAAgPwAAgD97g18/AAAAPwAAYD8AAAA/AAABAAIAAgADAAQAAgAEAAAABQAGAAcACAAJAAoACwAMAA0ACwANAA4ADwAQABEAEgATABQAFQAWABcAFwAYABkAFwAZABUAGgAbABwAGgAcAB0AHgAfACAAHgAgACEAIgAjACQAIgAkACUAJgAnACgAKAAnACkAAwACACoAKQAnACsAKQArACwAJwAmACsA"}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:540,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:540,byteOffset:540,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:360,byteOffset:1080,byteStride:8,target:34962},{name:"bufferView_3",buffer:0,byteLength:144,byteOffset:1440,target:34963}],materials:[{name:"Material.001",pbrMetallicRoughness:{baseColorFactor:[.8,.8,.8,1],metallicFactor:0,roughnessFactor:.676000006},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"Cube.001-Mesh",primitives:[{attributes:{POSITION:0,NORMAL:1,TEXCOORD_0:2},indices:3,material:0,mode:4}]}],nodes:[{name:"Cube.001",mesh:0}],scene:0,scenes:[{nodes:[0]}]},jiantou:{accessors:[{name:"ï¿½ï¿½Í·_1_0_positions",componentType:5126,count:7,min:[-.47690001130104065,-.8044000267982483,0],max:[.47780001163482666,0,0],type:"VEC3",bufferView:0,byteOffset:0},{name:"ï¿½ï¿½Í·_1_0_normals",componentType:5126,count:7,min:[0,0,1],max:[0,0,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"ï¿½ï¿½Í·_1_0_indices",componentType:5123,count:15,min:[0],max:[6],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"jiantou",byteLength:200,uri:"data:application/octet-stream;base64,bxIDOintTb8AAAAAH/RsvsKGp74AAAAAPSz0vsKGp74AAAAANs17PsKGp74AAAAANKL0PsKGp74AAAAANs17PgAAAAAAAAAAH/RsvgAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAABAAIAAAADAAEAAAAEAAMAAQAFAAYAAQADAAUAAAA="}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:84,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:84,byteOffset:84,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:32,byteOffset:168,target:34963}],materials:[{name:"SVGMat_003",pbrMetallicRoughness:{baseColorFactor:[.588,.588,.588,1],metallicFactor:0,roughnessFactor:.99},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"ï¿½ï¿½Í·_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"ï¿½ï¿½Í·",mesh:0}],scene:0,scenes:[{nodes:[0]}]},xuanzhuan:{accessors:[{name:"ï¿½ï¿½×ª001_1_0_positions",componentType:5126,count:369,min:[-6.572299957275391,-7.298999786376953,0],max:[6.5742998123168945,7.298299789428711,0],type:"VEC3",bufferView:0,byteOffset:0},{name:"ï¿½ï¿½×ª001_1_0_normals",componentType:5126,count:369,min:[0,-1,0],max:[0,0,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"ï¿½ï¿½×ª001_1_0_indices",componentType:5123,count:1089,min:[0],max:[368],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"æ—‹è½¬-æ–°",byteLength:11036,uri:"data:application/octet-stream;base64, "}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:4428,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:4428,byteOffset:4428,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:2180,byteOffset:8856,target:34963}],materials:[{name:"SVGMat",pbrMetallicRoughness:{baseColorFactor:[.5,.5,.5,1],metallicFactor:0,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"ï¿½ï¿½×ª001_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"ï¿½ï¿½×ª001",mesh:0}],scene:0,scenes:[{nodes:[0]}]},plane:{accessors:[{name:"Rectangle001_1_0_positions",componentType:5126,count:4,min:[-5,-5,0],max:[5,5,0],type:"VEC3",bufferView:0,byteOffset:0},{name:"Rectangle001_1_0_normals",componentType:5126,count:4,min:[0,0,1],max:[0,0,1],type:"VEC3",bufferView:1,byteOffset:0},{name:"Rectangle001_1_0_indices",componentType:5123,count:6,min:[0],max:[3],type:"SCALAR",bufferView:2,byteOffset:0}],asset:{generator:"obj2gltf",version:"2.0"},buffers:[{name:"plane",byteLength:108,uri:"data:application/octet-stream;base64,AACgQAAAoEAAAAAAAACgwAAAoEAAAAAAAACgwAAAoMAAAAAAAACgQAAAoMAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAABAAIAAgADAAAA"}],bufferViews:[{name:"bufferView_0",buffer:0,byteLength:48,byteOffset:0,byteStride:12,target:34962},{name:"bufferView_1",buffer:0,byteLength:48,byteOffset:48,byteStride:12,target:34962},{name:"bufferView_2",buffer:0,byteLength:12,byteOffset:96,target:34963}],materials:[{name:"wire_225198087",pbrMetallicRoughness:{baseColorFactor:[.8824,.7765,.3412,1],metallicFactor:0,roughnessFactor:.968},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",doubleSided:!1}],meshes:[{name:"Rectangle001_1",primitives:[{attributes:{POSITION:0,NORMAL:1},indices:2,material:0,mode:4}]}],nodes:[{name:"Rectangle001",mesh:0}],scene:0,scenes:[{nodes:[0]}]},xyzScale:{asset:{generator:"Khronos glTF Blender I/O v1.6.16",version:"2.0"},scene:0,scenes:[{name:"Scene",nodes:[0,1,2,3,4,5,6]}],nodes:[{mesh:0,name:"Cube",scale:[.7008190751075745,.014999999664723873,.014999999664723873]},{mesh:1,name:"Cube.001",scale:[.10000000149011612,.10000000149011612,.10000000149011612]},{mesh:2,name:"Cube.004",rotation:[0,-.7071068286895752,0,.7071068286895752],scale:[.7008190751075745,.014999999664723873,.014999999664723873]},{mesh:3,name:"Cube.003",rotation:[0,-.7071068286895752,0,.7071068286895752],scale:[.10000000149011612,.10000000149011612,.10000000149011612]},{mesh:4,name:"Cube.006",rotation:[0,0,.7071068286895752,.7071068286895752],scale:[.7008190751075745,.014999999664723873,.014999999664723873]},{mesh:5,name:"Cube.005",rotation:[0,0,.7071068286895752,.7071068286895752],scale:[.10000000149011612,.10000000149011612,.10000000149011612]},{mesh:6,name:"Cube.002",scale:[.10000000149011612,.10000000149011612,.10000000149011612]}],materials:[{doubleSided:!0,name:"Material",pbrMetallicRoughness:{baseColorFactor:[.6938720345497131,.020288480445742607,.011612260714173317,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.001",pbrMetallicRoughness:{baseColorFactor:[.6938720345497131,.020288480445742607,.011612260714173317,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.002",pbrMetallicRoughness:{baseColorFactor:[.226582869887352,.226582869887352,.226582869887352,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.006",pbrMetallicRoughness:{baseColorFactor:[.11193240433931351,.5583405494689941,.033104799687862396,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.005",pbrMetallicRoughness:{baseColorFactor:[.11193240433931351,.5583405494689941,.033104799687862396,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.010",pbrMetallicRoughness:{baseColorFactor:[.004391402006149292,.21223078668117523,.5209956169128418,1],metallicFactor:0,roughnessFactor:.4000000059604645}},{doubleSided:!0,name:"Material.009",pbrMetallicRoughness:{baseColorFactor:[.004391402006149292,.21223078668117523,.5209956169128418,1],metallicFactor:0,roughnessFactor:.4000000059604645}}],meshes:[{name:"Cube",primitives:[{attributes:{POSITION:0,NORMAL:1,TEXCOORD_0:2},indices:3,material:0}]},{name:"Cube.001",primitives:[{attributes:{POSITION:4,NORMAL:5,TEXCOORD_0:6},indices:3,material:1}]},{name:"Cube.006",primitives:[{attributes:{POSITION:10,NORMAL:11,TEXCOORD_0:12},indices:3,material:3}]},{name:"Cube.005",primitives:[{attributes:{POSITION:13,NORMAL:14,TEXCOORD_0:15},indices:3,material:4}]},{name:"Cube.010",primitives:[{attributes:{POSITION:16,NORMAL:17,TEXCOORD_0:18},indices:3,material:5}]},{name:"Cube.009",primitives:[{attributes:{POSITION:19,NORMAL:20,TEXCOORD_0:21},indices:3,material:6}]},{name:"Cube.002",primitives:[{attributes:{POSITION:7,NORMAL:8,TEXCOORD_0:9},indices:3,material:2}]}],accessors:[{bufferView:0,componentType:5126,count:24,max:[2.0003609657287598,1,1],min:[.0003610849380493164,-1,-1],type:"VEC3"},{bufferView:1,componentType:5126,count:24,type:"VEC3"},{bufferView:2,componentType:5126,count:24,type:"VEC2"},{bufferView:3,componentType:5123,count:36,type:"SCALAR"},{bufferView:4,componentType:5126,count:24,max:[14.549108505249023,1,1],min:[12.549108505249023,-1,-1],type:"VEC3"},{bufferView:5,componentType:5126,count:24,type:"VEC3"},{bufferView:6,componentType:5126,count:24,type:"VEC2"},{bufferView:7,componentType:5126,count:24,max:[1,1,1],min:[-1,-1,-1],type:"VEC3"},{bufferView:8,componentType:5126,count:24,type:"VEC3"},{bufferView:9,componentType:5126,count:24,type:"VEC2"},{bufferView:10,componentType:5126,count:24,max:[2.0003609657287598,1,1],min:[.0003610849380493164,-1,-1],type:"VEC3"},{bufferView:11,componentType:5126,count:24,type:"VEC3"},{bufferView:12,componentType:5126,count:24,type:"VEC2"},{bufferView:13,componentType:5126,count:24,max:[14.549108505249023,1,1],min:[12.549108505249023,-1,-1],type:"VEC3"},{bufferView:14,componentType:5126,count:24,type:"VEC3"},{bufferView:15,componentType:5126,count:24,type:"VEC2"},{bufferView:16,componentType:5126,count:24,max:[2.0003609657287598,1,1],min:[.0003610849380493164,-1,-1],type:"VEC3"},{bufferView:17,componentType:5126,count:24,type:"VEC3"},{bufferView:18,componentType:5126,count:24,type:"VEC2"},{bufferView:19,componentType:5126,count:24,max:[14.549108505249023,1,1],min:[12.549108505249023,-1,-1],type:"VEC3"},{bufferView:20,componentType:5126,count:24,type:"VEC3"},{bufferView:21,componentType:5126,count:24,type:"VEC2"}],bufferViews:[{buffer:0,byteLength:288,byteOffset:0},{buffer:0,byteLength:288,byteOffset:288},{buffer:0,byteLength:192,byteOffset:576},{buffer:0,byteLength:72,byteOffset:768},{buffer:0,byteLength:288,byteOffset:840},{buffer:0,byteLength:288,byteOffset:1128},{buffer:0,byteLength:192,byteOffset:1416},{buffer:0,byteLength:288,byteOffset:1608},{buffer:0,byteLength:288,byteOffset:1896},{buffer:0,byteLength:192,byteOffset:2184},{buffer:0,byteLength:288,byteOffset:2376},{buffer:0,byteLength:288,byteOffset:2664},{buffer:0,byteLength:192,byteOffset:2952},{buffer:0,byteLength:288,byteOffset:3144},{buffer:0,byteLength:288,byteOffset:3432},{buffer:0,byteLength:192,byteOffset:3720},{buffer:0,byteLength:288,byteOffset:3912},{buffer:0,byteLength:288,byteOffset:4200},{buffer:0,byteLength:192,byteOffset:4488},{buffer:0,byteLength:288,byteOffset:4680},{buffer:0,byteLength:288,byteOffset:4968},{buffer:0,byteLength:192,byteOffset:5256}],buffers:[{byteLength:5448,uri:"data:application/octet-stream;base64, "}]}};function Q$1(s,i,n,I,o,g){const r=[],a=fromRotationTranslationScale([],fromEuler([],n[0],n[1],n[2]),i,I);return function(A){return new X$8("",JSON.parse(JSON.stringify(w$1[A]))).load().then((A=>A))}(s).then((A=>{Dt$6.exportGLTFPack(A).getMeshesInfo().forEach(((A,s)=>{const C=new Ce$5({color:o||A.materialInfo.baseColorFactor}),h=new Be$5(A.geometry,C);h.setUniform("uPickingId",g+s);const w=h.getDefines();w.HAS_PICKING_ID=2,h.setDefines(w),h.translate=i,h.rotation=n,h.scaling=I,multiply$5(h.localTransform,a,A.nodeMatrix),h.originTransform=copy$5([],h.localTransform),h.originColor=o||A.materialInfo.baseColorFactor,r.push(h)})),g>100&&(r[0].properties.relatedMeshes=r.slice(1,2),r[1].properties.relatedMeshes=r.slice(0,1),r[2].properties.relatedMeshes=r.slice(3,4),r[3].properties.relatedMeshes=r.slice(2,3),r[4].properties.relatedMeshes=r.slice(5,6),r[5].properties.relatedMeshes=r.slice(4,5),r[6].properties.relatedMeshes=r.slice(0,6))})),r}function f$1(A,e){return Math.abs(A)*Math.sign(e)}function l(A,t){const i=A.getCoordinates(),n=t.coordinateToPointAtRes(i,t.getGLRes()),o=[n.x,n.y,0];add$4(o,o,P(t,A.getTranslation()));const r=function(A,e,t,s){return A._pointAtResToContainerPoint(e,t,void 0)}(t,new t__namespace.Point(o[0],o[1]),t.getGLRes());r.x+=85;const C=function(A,t,i,n){{const e=A.containerPointToCoordinate(t);return A.coordinateToPointAtRes(e,i)}}(t,r,t.getGLRes());return Math.sqrt(Math.pow(C.x-o[0],2)+Math.pow(C.y-o[1],2))/5.272881136101205}function P(A,e){if(!A)return e;const t=A.distanceToPointAtRes(e[0],e[1],A.getGLRes()),i=A.altitudeToPoint(e[2],A.getGLRes());return set$4([],f$1(t.x,e[0]),f$1(t.y,e[1]),f$1(i,e[2]))}class D$1{constructor(A){this.A=A,this._meshes=this.t()}setCoordinate(A){this.A=A}t(){const A=[],e=340/177,t=Q$1("jiantou",[1.2*e,0,0],[0,0,90],[e,e,e],[89/255,206/255,147/255,0],7),s=Q$1("jiantou",[0,1.2*e,0],[0,0,180],[e,e,e],[89/255,206/255,147/255,0],8),i=Q$1("jiantou",[-1.2*e,0,0],[0,0,270],[e,e,e],[89/255,206/255,147/255,0],9),n=Q$1("jiantou",[0,-1.2*e,0],[0,0,0],[e,e,e],[89/255,206/255,147/255,0],10);return A.push(t,s,i,n),A}getMeshes(){return this._meshes}}class u$1{constructor(A){this.A=A,this._meshes=this.t()}setCoordinate(A){this.A=A}t(){const A=[],e=Q$1("xuanzhuan",[0,0,0],[180,0,0],[340/177*.5,340/177*.5,340/177*.5],[50/255,130/255,184/255,.8],11);return A.push(e),A}getMeshes(){return this._meshes}}class m$2{constructor(A){this.A=A,this._meshes=this.t()}setCoordinate(A){this.A=A}t(){const A=[],e=Q$1("yuanhuan",[0,0,0],[0,0,0],[340/177*.5,340/177*.5,340/177*.5],[149/255,179/255,199/255,.5],12);return A.push(e),A}getMeshes(){return this._meshes}}class b$2{constructor(A){this.A=A,this._meshes=this.t()}setCoordinate(A){this.A=A}t(){const A=[],e=Q$1("plane",[0,0,0],[0,0,0],[10,10,10],[1,0,0,.5],16);return A.push(e),A}getMeshes(){return this._meshes}}class B$1{constructor(A){this.A=A,this._meshes=this.t()}setCoordinate(A){this.A=A}t(){const A=[],e=Q$1("xyzScale",[0,0,0],[0,0,0],[2,2,2],null,113);return A.push(e),A}getMeshes(){return this._meshes}}const y$2=[],p$2=[],v$1=[],L$1=[],M$1=[],d$1=[177/170,177/170,177/170],E$1=[],O$1=[1,2,3,4,12];class F$1{constructor(){this.translate=new D$1,this.rotation=new u$1,this.scaling=new m$2,this.planeHelper=new b$2,this.xyzScaleHelper=new B$1,this._meshes=this.t(),this.s=!0}t(){const A={};A.translate=this.translate.getMeshes(),A.rotation=this.rotation.getMeshes(),A.scaling=this.scaling.getMeshes(),A.planeHelper=this.planeHelper.getMeshes(),A.xyzScale=this.xyzScaleHelper.getMeshes();const e=340/177,t=Q$1("yuanhuan41",[-2.745*e,2.745*e,0],[90,0,0],[.5*e,.5*e,.5*e],[149/255,179/255,199/255,.6],1),s=Q$1("yuanhuan41",[2.745*e,2.745*e,0],[-90,0,180],[.5*e,.5*e,.5*e],[50/255,130/255,184/255,.5],2),i=Q$1("yuanhuan41",[2.745*e,-2.745*e,0],[90,0,180],[.5*e,.5*e,.5*e],[149/255,179/255,199/255,.6],3),n=Q$1("yuanhuan41",[-2.745*e,-2.745*e,0],[-90,0,0],[.5*e,.5*e,.5*e],[50/255,130/255,184/255,.5],4),I=Q$1("yuanpan",[0,0,0],[90,0,0],[.5*e,.5*e,.5*e],[89/255,206/255,147/255,.5],5),o=Q$1("zzhou",[0,0,6.5],[90,0,0],[1,1,1],[14/255,127/255,191/255,1],6);return A.translate.push(t,s,i,n,I,o),A}updateMatrix(t,i,n,I,o){const g=i.getCoordinates(),r=t.coordinateToPointAtRes(g,t.getGLRes()),C=i.i();set$4(p$2,r.x,r.y,C);const a=copy$4(y$2,o),h=P(t,i.getTranslation());add$4(p$2,p$2,h),add$4(p$2,p$2,a);for(const o in this._meshes)for(let g=0;g<this._meshes[o].length;g++){const r=this._meshes[o][g];for(let g=0;g<r.length;g++){const C=r[g],a=C.getUniform("uPickingId"),h=copy$4(y$2,C.translate);let w=copy$4(E$1,C.rotation);const c=C.scaling;if(11===a&&(this.s?(w[2]+=n,C.rotation[2]+=n):this.s||(w[2]+=n,C.rotation[2]+=n,w[0]=360,w[2]-=90)),a>100&&1===i.getTargets().length&&(w=i.getTargets()[0].getRotation()),O$1.indexOf(a)>-1)if(12!==a)c[0]+=I,c[1]+=I,c[2]+=I;else{const A=this._meshes.translate[4][0];c[0]=1.2*A.scaling[0],c[1]=1.2*A.scaling[0],c[2]=1.2*A.scaling[0]}let Q=l(i,t);if(Q=set$4(v$1,Q,Q,Q),multiply$4(h,h,Q),multiply$4(Q,Q,c),1===a||2===a||3===a||4===a){const A=multiply$4(M$1,c,d$1);multiply$4(h,h,A)}const f=fromEuler(L$1,w[0],w[1],w[2]);if(add$4(h,h,p$2),"xyzScale"===o){const A=fromRotationTranslationScale([],f,h,Q);multiply$5(C.localTransform,A,C.originTransform)}else fromRotationTranslationScale(C.localTransform,f,h,Q)}}}getMeshes(A){const e={};return A?("xyzScale"===A?e[A]=this._meshes[A]:(e.translate=this._meshes.translate,"translate"!==A&&(e[A]=this._meshes[A])),e):e}I(A){this.s=A}dispose(){for(const A in this._meshes)for(let e=0;e<this._meshes[A].length;e++){const t=this._meshes[A][e];for(let A=0;A<t.length;A++){const e=t[A];e.geometry.dispose(),e.dispose()}}}}const x$2=[],U$1=[],V$1=[],S$1=new t$1.Point(0,0),k$1=[],T$1=[],H$1=[],J$1=[0,0,0];class N$1{constructor(){this.o=[],this.g=[0,0,0],this.C=[1,1,1],this.h=[0,0,0]}l(A){Array.isArray(A)?A.forEach((A=>{this.l(A)})):(A.on("remove",this.P,this),A.D={coordinate:A.getCoordinates(),translation:A.getTranslation(),rotation:A.getRotation(),scale:A.getScale()},this.o.push(A))}u(){this.o.forEach((A=>{A.off("remove",this.P,this)})),this.o=[]}m(A,e,t,i,n,I,o){for(let o=0;o<this.o.length;o++){const g=this.o[o],r=g.getRotation(),C=g.getScale(),a=this.B(I,g,i,t,e);let h=null;h=i>=0?i:i*(this.options&&this.options.scaleStrength||1);const w=add$4(H$1,set$4(x$2,h*C[0],h*C[1],h*C[2]),C),c=Math.min(...w);if(Math.abs(c)<n){const A=Math.abs(c);w[0]=w[0]*(n/A),w[1]=w[1]*(n/A),w[2]=w[2]*(n/A)}const Q=add$4(r,t,r);g.setCoordinates(a),this.p(A,w,C);const f=g.getTranslation();g.setTRS(f,Q,w)}set$4(H$1,i,i,i),add$4(this.h,t,this.h),add$4(this.C,H$1,this.C),add$4(this.g,e,this.g),A.indexOf("translate")>-1?o.fire("positionchange",{action:A,type:"positionchange",target:this.o,center:this.getCoordinates(),scale:this.C,rotation:this.h,translation:this.g,deltaTranslate:e,deltaRotation:t,deltaScale:i}):o.fire("transforming",{action:A,type:"transforming",target:this.o,center:this.o[0].getTransformOrigin(),scale:this.C,rotation:this.h,translation:this.g,deltaTranslate:e,deltaRotation:t,deltaScale:i})}B(t,i,n,I,o){const g=i.getCenter(),r=i.getTransformOrigin(),C=t.getGLRes(),a=t.coordinateToPointAtRes(g,C,S$1);a.z=t.altitudeToPoint(g.z,C),set$4(k$1,a.x,a.y,a.z||0);const h=t.coordinateToPointAtRes(r,C,S$1);h.z=t.altitudeToPoint(r.z,C),set$4(T$1,h.x,h.y,h.z||0);const w=sub$2(x$2,k$1,T$1),c=fromEuler(U$1,0,0,I[2]);set$4(H$1,n+1,n+1,n+1);transformMat4$2(w,w,fromRotationTranslationScale(V$1,c,o,H$1)),add$4(w,w,T$1),S$1.set(w[0],w[1]);const f=t.pointAtResToCoordinate(S$1,C);return f.z=w[2]/t.altitudeToPoint(1,C),f}p(A,e,t){return"x-scale"===A&&(e[1]=t[1],e[2]=t[2]),"y-scale"===A&&(e[0]=t[0],e[2]=t[2]),"z-scale"===A&&(e[0]=t[0],e[1]=t[1]),e}v(){this.o.forEach((A=>{if(A.D){const{coordinate:e,translation:t,rotation:s,scale:i}=A.D;A.setCoordinates(e),A.setTRS(t,s,i)}}))}getScale(){return this.C}getTranslation(){return 1===this.o.length&&this.o[0].getTranslation()||J$1}getRotation(){return this.h}L(){return this.o[0]?this.o[0].getLayer():null}getCoordinates(){let A=0,e=0,t=0;const s=this.o.length;if(!s)return null;for(let i=0;i<s;i++){const s=this.o[i].getCenter();A+=s.x,e+=s.y,t+=s.z||0}A/=s,e/=s,t/=s;const i=new t$1.Coordinate(A,e,t);for(let A=0;A<s;A++)this.o[A].setTransformOrigin(i);return i}P(A){const e=A.target,t=this.o.indexOf(e);t>-1&&(delete e.D,this.o.splice(t,1))}getTargets(){return this.o}i(){let A=0;const e=this.o.length;for(let t=0;t<e;t++)A+=this.o[t].getPointZ();return A/=e,A}M(){for(let A=0;A<this.o.length;A++)if(this.o[A].isVisible())return!0;return!1}}const R$1=[5,6,7,8,9,10],_$2=[5,7,8,9,10],K$1=[2,4,11],z$1=[1,3,12],G$1=[12,16],j$1=[1,2,3,4],Z$1=[1,2,3,4,12],Y$1=[],W$1=[],q$1=[],X$1=[],$$1=[],AA$1=[],eA$1=[];class tA$1 extends(t$1.Eventable(t$1.Handlerable(t$1.Class))){constructor(A={}){super(A),this.options=A,this.mouseAction="moving",this.O=this.options.mode||"translate",this.F=!0,this.TransformHelper=new F$1,this.U=new N$1,this.helperScene=new Ke$5([]),this.addToMapCount=0}enable(){return this.F=!0,this.layerRenderer&&this.layerRenderer.setToRedraw(),this}disable(){return this.F=!1,this.layerRenderer&&this.layerRenderer.setToRedraw(),this.map&&this.map.resetCursor(),this}setMode(A){this.O=A,this.V(),this.layerRenderer&&this.layerRenderer.setToRedraw(),this.fire("modechange",{mode:A,type:"modechange"})}getMode(){return this.O}isEnable(){return this.F}S(A){R$1.indexOf(A)>-1?this.O="translate":K$1.indexOf(A)>-1?this.O="rotation":z$1.indexOf(A)>-1?this.O="scaling":"xyzScale"!==this.O&&(this.O="translate")}k(){return this.O}addTo(A){this.map&&(this.T(),console.warn("transform control has been added to a map, it suggest remove from the map before")),this.addToMapCount++,this.map=A,this.container=A.getContainer(),A.on("dom:mousemove",this.H,this),A.on("dom:mousedown",this.J,this),A.on("dom:mouseup",this.N,this),A.on("zooming moving dragrotating",this.R,this),this._()}remove(){this.map&&this.container&&this.layerRenderer&&(this.T(),this.TransformHelper.dispose(),this.layerRenderer.setToRedraw(),delete this.map,delete this.layer,delete this.layerRenderer,delete this.container,delete this.U)}T(){this.container&&this.map&&(this.map.off("dom:mousemove",this.H,this),this.map.off("dom:mousedown",this.J,this),this.map.off("dom:mouseup",this.N,this),this.map.off("zooming moving dragrotating",this.R,this),this.layer&&this.layer.off("renderend",this.render,this))}H(A){if(this.K()){if(this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},"moving"===this.mouseAction){const A=this.G();this.currentPickingObject=this.j(this.currentMousePosition,A,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.pickingId?(this.S(this.currentPickingObject.pickingId),this.Z(6===this.currentPickingObject.pickingId)):(this.Z(!1),this.S()),this.Y()}this.W(this.currentMousePosition)}}J(A){if(!this.K()||0!==A.domEvent.button)return;const e=this.G();this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y},this.q=!0,this.currentPickingObject=this.j(this.currentMousePosition,e,"meshes"),this.firstDownPoint=this.j(this.currentMousePosition,e,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.meshId?(this.mouseAction="transform",this.X(this.currentPickingObject.pickingId),this.map.config("zoomable",!1),this.map.config("draggable",!1),this.layerRenderer&&this.layerRenderer.setToRedraw()):(this.mouseAction="pan",this.map.config("zoomable",!0),this.map.config("draggable",!0),this.V()),this.lastMousePosition=this.currentMousePosition,this.lastPickingObject=this.currentPickingObject,this.lastPickingMesh=e[this.currentPickingObject.meshId]}N(){"transform"===this.mouseAction&&(this.firstDownPoint=null,this.V(),this.q=!0,this.fire("transformend",{action:this.$,type:"transformend"})),this.mouseAction="moving","xyzScale"!==this.O&&(this.O="translate"),this.map.config("zoomable",!0),this.map.config("draggable",!0),this.layerRenderer&&this.layerRenderer.setToRedraw()}R(){const A=this.TransformHelper.planeHelper.getMeshes()[0][0],e=this.map.getBearing();A.rotation[2]=-e,this.AA()}AA(){this.K()&&(this.TransformHelper.updateMatrix(this.map,this.U,0,0,[0,0,0]),this.q=!0)}picked(A){if(!this.layerRenderer)return!1;const e=this.G();let s=A;A instanceof t$1.Point||(s=this.map.coordinateToContainerPoint(new t$1.Coordinate(A)));const i=this.j(s,e,"picked");return!(!i||null===i.meshId)}V(){const A=this.TransformHelper.getMeshes("scaling").scaling[0][0];A.scaling=[340/177*.6,340/177*.6,340/177*.6],this.layerRenderer&&(this.eA(A),this.tA())}tA(){this.TransformHelper._meshes.translate.forEach((A=>{for(let e=0;e<A.length;e++){const t=A[e];j$1.indexOf(t.getUniform("uPickingId"))>-1&&t.material.set("color",t.originColor)}}))}eA(t){const i=this.U.getCoordinates(),n=this.map.coordinateToPointAtRes(i,this.map.getGLRes()),I=[n.x,n.y,0],o=P(this.map,this.U.getTranslation());add$4(I,I,o);const g=copy$4([],t.translate),r=t.scaling;let C=l(this.U,this.map);C=set$4([],C,C,C),multiply$4(g,g,C),multiply$4(C,C,r),add$4(g,g,I),fromRotationTranslationScale(t.localTransform,[0,0,0,1],g,C),this.G().forEach((t=>{const i=t.getUniform("uPickingId");if(1===i||3===i||2===i||4===i){const i=copy$4([],t.translate),n=170/177;t.scaling=[n,n,n];const o=t.scaling,g=t.rotation;let r=l(this.U,this.map);r=set$4([],r,r,r),multiply$4(i,i,r),multiply$4(r,r,o),add$4(i,i,I);const C=fromEuler([],g[0],g[1],g[2]);fromRotationTranslationScale(t.localTransform,C,i,r)}}))}sA(A){const e=this.map.containerPointToCoordinate(A),t=this.map.coordinateToPointAtRes(e,this.map.getGLRes());return{point:[t.x,t.y]}}W(A){if("transform"===this.mouseAction){const A=this.k(),e=P(this.map,this.U.getTranslation()),t=this.U.i();let s=null,n=null;if(e[2]+t<.01&&"z-translate"!==this.$)s=this.sA(this.currentMousePosition),n=this.sA(this.lastMousePosition);else{const A=this.TransformHelper.planeHelper.getMeshes()[0];if(s=this.j(this.currentMousePosition,A,"plane"),n=this.j(this.lastMousePosition,A,"plane"),!s||null===s.meshId||!n||null===n.meshId)return}const I=[0,0,0],g=[0,0,0];let r=0,C=0,a=0;if("translate"===A){if("xy-translate"===this.$){const e=s.point[1]-n.point[1];I[0]=s.point[0]-n.point[0],I[1]=e}else if("x-translate"===this.$){I[0]=s.point[0]-n.point[0]}else if("y-translate"===this.$){I[1]=s.point[1]-n.point[1]}else if("z-translate"===this.$){let A=0;if(this.iA()){const e=this.map.getGLRes(),t=this.map._pointAtResToContainerPoint(new t$1.Point(n.point[0],n.point[1]),e),I=this.map._pointAtResToContainerPoint(new t$1.Point(s.point[0],s.point[1]),e),g=length(set(X$1,s.point[0]-n.point[0],s.point[1]-n.point[1]));A=I.y<t.y?g:-g}else A=s.point[2]-n.point[2];I[2]=A}}else if("rotation"===A)C=this.nA(s.point,n.point),this.TransformHelper.I(C>=0),g[2]+=C;else if("scaling"===A||"xyzScale"===A){const A=this.IA(),e=length(set(X$1,this.firstDownPoint.point[0]-A[0],this.firstDownPoint.point[1]-A[1])),t=length(set(X$1,n.point[0]-A[0],n.point[1]-A[1]));r=this.oA(s.point,n.point,A,t),a=this.oA(s.point,n.point,A,e)}this.TransformHelper.updateMatrix(this.map,this.U,C,a,I),this.U.m(this.$,I,g,r,.01,this.map,this)}this.lastMousePosition=A,this.lastPickingObject=this.currentPickingObject;const e=this.G();this.lastPickingMesh=e[this.currentPickingObject.meshId]}oA(A,e,t,s,n){const I=(length(set(X$1,A[0]-t[0],A[1]-t[1]))-length(set(X$1,e[0]-t[0],e[1]-t[1])))/s;return n?(n[0]-.01)*I:I}IA(){const A=this.map,e=this.U.getCoordinates(),t=A.coordinateToPointAtRes(e,A.getGLRes()),i=set$4($$1,t.x,t.y,0);return add$4(i,i,P(A,this.U.getTranslation())),i}Z(t){const i=this.TransformHelper.planeHelper.getMeshes()[0][0],n=getTranslation$1(q$1,i.localTransform),I=getScaling(W$1,i.localTransform);let o=fromEuler(Y$1,0,0,0);const g=this.map.getBearing();t&&!this.iA()?(o=fromEuler(Y$1,90,0,-g),0===i.rotation[0]&&(this.q=!0),set$4(i.rotation,90,0,-g)):(90===i.rotation[0]&&(this.q=!0),set$4(i.rotation,0,0,-g)),fromRotationTranslationScale(i.localTransform,o,n,I)}iA(){if(this.map.getPitch())return!1;const A=this.map.cameraPosition,e=this.map.coordinateToPointAtRes(this.map.getCenter(),this.map.getGLRes());set$4(e,e.x,e.y,0);const t=this.U.getCoordinates(),i=this.map.coordinateToPointAtRes(t,this.map.getGLRes()),n=P(this.map,this.U.getTranslation()),I=set$4(q$1,i.x,i.y,0);return angle$1(subtract$2([],A,add$4(I,I,n)),subtract$2([],A,e))<1/180*Math.PI}Y(){const A=this.G();if(this.currentPickingObject&&null!=this.currentPickingObject.meshId){this.gA(),this.lastPickingObject&&null!=this.lastPickingObject.meshId&&this.lastPickingObject.meshId!==this.currentPickingObject.meshId&&this.rA();const e=A[this.currentPickingObject.meshId];if(e&&G$1.indexOf(this.currentPickingObject.pickingId)<0)if(this.currentPickingObject.pickingId>100)this.CA(e);else{e.material.set("color",[e.originColor[0],e.originColor[1],e.originColor[2],.8]),this.aA(e,.5)}this.layerRenderer.setToRedraw()}else this.lastPickingObject&&null!=this.lastPickingObject.meshId&&(this.map.resetCursor(),this.rA(),this.layerRenderer.setToRedraw())}CA(A){const e=[1,179/255,2/255,1];A.material.set("color",e),A.properties.relatedMeshes&&A.properties.relatedMeshes.forEach((A=>{A.material.set("color",e)}))}gA(){6===this.currentPickingObject.pickingId?this.map.setCursor("ns-resize"):_$2.indexOf(this.currentPickingObject.pickingId)>-1?this.map.setCursor("move"):this.map.setCursor("pointer")}rA(){const A=this.lastPickingMesh;if(!A)return;const e=A.getUniform("uPickingId"),t=this.G();_$2.indexOf(e)>-1?t.forEach((A=>{_$2.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})):Z$1.indexOf(e)>-1?t.forEach((A=>{const e=A.getUniform("uPickingId");j$1.indexOf(e)>-1&&A.material.set("color",A.originColor)})):11===e&&t.forEach((A=>{j$1.indexOf(A.getUniform("uPickingId"))>-1&&A.material.set("color",A.originColor)})),A.material.set("color",A.originColor),A.properties.relatedMeshes&&A.properties.relatedMeshes.forEach((A=>{A.material.set("color",A.originColor)}))}aA(A,e){const t=A.getUniform("uPickingId"),s=this.G();_$2.indexOf(t)>-1?s.forEach((t=>{if(_$2.indexOf(t.getUniform("uPickingId"))>-1&&t.getUniform("uPickingId")!==A.getUniform("uPickingId")){t.material.set("color",[t.originColor[0],t.originColor[1],t.originColor[2],e])}})):"scaling"===this.O?s.forEach((A=>{const e=A.getUniform("uPickingId");if(1===e||3===e||2===e||4===e){A.material.set("color",[149/255,179/255,199/255,.8])}})):"rotation"===this.O&&s.forEach((A=>{const e=A.getUniform("uPickingId");if(1===e||3===e||2===e||4===e){const e=A.originColor;A.material.set("color",[e[0],e[1],e[2],0])}}))}reset(){this.map&&this.U&&(this.U.v(),this.TransformHelper.updateMatrix(this.map,this.U,0,0,[0,0,0]))}nA(A,e){const t=this.IA(),s=set(AA$1,e[0]-t[0],e[1]-t[1]),n=set(eA$1,A[0]-t[0],A[1]-t[1]),I=Math.atan2(s[1],s[0]);return(Math.atan2(n[1],n[0])-I)/Math.PI*180}X(A){return this.$=113===A||114===A?"x-scale":115===A||116===A?"z-scale":117===A||118===A?"y-scale":119===A?"xyz-scale":5===A?"xy-translate":6===A?"z-translate":7===A||9===A?"x-translate":8===A||10===A?"y-translate":11===A?"z-rotate":"scale",this.$}transform(A){if(!A)return;if(this.layerRenderer&&this.layerRenderer.layer&&(this.layerRenderer.layer.off("renderend",this.render),this.layerRenderer.layer.off("resizeCanvas",this.hA)),!this.map)return void console.error("should add to a target first");if(this.U&&(this.U.u(),this.U.l(A)),!this.U.getTargets().length)return;this.TransformHelper.updateMatrix(this.map,this.U,0,0,[0,0,0]),this.wA(),this.q=!0}getTransformTarget(){return this.U}P(){delete this.U}wA(){const A=this.U.L();A&&(A.off("renderend",this.render),A.off("resizeCanvas",this.hA));const e=this.map.getLayers();let t=null;for(let A=0;A<e.length;A++)if(e[A]instanceof Cs$3){t=e[A];break}if(!t)return;const s=t.getLayers(),i=s.indexOf(A);if(i<0)return;s.splice(i,1),s.push(A);const I=this.map,o=A.getRenderer();this.layerRenderer=o,this.regl=o.regl,this.renderer=o.renderer,this.cA=this.layerRenderer.getFBORayPicking(),this.QA={projViewMatrix:I.projViewMatrix},A.on("renderend",this.render,this),A.on("resizeCanvas",this.hA,this),o.setToRedraw()}hA(){this.cA.clear(),this.q=!0}j(A,e,t){const s=this.map;if(!(s&&this.cA&&this.layerRenderer&&this.layerRenderer.canvas))return null;const i=s.getDevicePixelRatio(),n=A.x*i,I=A.y*i,o={projViewMatrix:this.map.projViewMatrix,pointSize:1};return(this.q||this.layerRenderer.canvas.gl&&this.layerRenderer.canvas.gl.wrap||!this.fA||this.fA!==t)&&(this.cA.render(e,o,!0),this.fA=t,this.q=!1),this.cA.pick(n,I,10,o,{viewMatrix:this.map.viewMatrix,projMatrix:this.map.projMatrix,returnPoint:!0})}_(){const A=this.map.getDevicePixelRatio();this.lA=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewModelMatrix;\n\n\n\nvoid main()\n\n{\n\n    gl_Position = projViewModelMatrix * vec4(aPosition, 1.0);\n\n\n\n}\n\n",frag:"precision mediump float;\n\nuniform vec4 color;\n\n\n\nvoid main() {\n\n    gl_FragColor = color;\n\n}\n\n",uniforms:["color",{name:"projViewModelMatrix",type:"function",fn:function(A,t){return multiply$5([],t.projViewMatrix,t.modelMatrix)}}],extraCommandProps:{viewport:{x:0,y:0,width:()=>this.map?this.map.width*A:1,height:()=>this.map?this.map.height*A:1},depth:{enable:!0,func:"always",mask:!0,range:[0,0]},blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}},defines:{}})}render(){if(!this.K())return;const A=this.G();this.helperScene.setMeshes(A);const e=this.layerRenderer.getFrameContext();if(e&&e.renderTarget&&this.layerRenderer.getFrameTimestamp()!==e.timestamp)return;this.AA(),this.lA.filter=e&&e.sceneFilter;this.renderer.render(this.lA,this.QA,this.helperScene,e&&e.renderTarget&&e.renderTarget.fbo)}G(){let A=[];const e=this.TransformHelper.getMeshes(this.O);for(const t in e){if("translate"===t)continue;const s=e[t];for(let e=0;e<s.length;e++)A=A.concat(s[e])}const t=e.translate;if(t)for(let e=0;e<t.length;e++)A=A.concat(t[e]);return A}K(){const A=this.layerRenderer,e=A&&A.layer;return A&&this.U&&e&&e.isVisible()&&this.U.M()&&this.regl&&this.F}}tA$1.mergeOptions({scaleStrength:2});
/*!
	 * @maptalks/msd-json-loader v0.1.0
	 * LICENSE : BSD-3-Clause
	 * (c) 2016-2022 maptalks.com
	 */
class t{constructor(t){this.t=t||{}}getJSON(){return e(this.t)}getId(){return this.t.id}getStyle(){return this.t.options?e(this.t.options.style):null}getData(){return this.t.options?e(this.t.options.data):null}getGeometryById(t){const r=this.t.geometries;if(!r)return null;for(let i=0;i<r.length;i++)if(r[i]&&r[i].options&&r[i].options.id===t)return e(r[i]);return null}getGeometries(){return this.t.geometries?e(this.t.geometries):[]}}function e(t){return t?JSON.parse(JSON.stringify(t)):null}
/*!
	 * @maptalks/video-layer v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */
/*!
	* Contains code from THREE.js
	* MIT License
	* https://github.com/mrdoob/three.js
	*/for(var c=[],u=0;u<6;u++)c[u]=[];var p$1=[];function f(t,e,i){var s,r,o,n,a,h,l,d,u,f,_,g,x,w,y,b,O;r=(s=t)[0],o=s[1],n=s[2],l=s[5],d=s[6],_=s[9],g=s[10],y=s[13],b=s[14],m$1(c[0],(a=s[3])-r,(u=s[7])-(h=s[4]),(x=s[11])-(f=s[8]),(O=s[15])-(w=s[12])),m$1(c[1],a+r,u+h,x+f,O+w),m$1(c[2],a+o,u+l,x+_,O+y),m$1(c[3],a-o,u-l,x-_,O-y),m$1(c[4],a-n,u-d,x-g,O-b),m$1(c[5],a+n,u+d,x+g,O+b);for(var S=0;S<6;S++)if(!i||"0"!==i.charAt(S)){var T=c[S];if(p$1[0]=T[0]>0?e[1][0]:e[0][0],p$1[1]=T[1]>0?e[1][1]:e[0][1],p$1[2]=T[2]>0?e[1][2]:e[0][2],v(T,p$1)<0)return!1}return!0}function m$1(t,e,i,s,r){var o=1/Math.sqrt(e*e+i*i+s*s);return t[0]=e*o,t[1]=i*o,t[2]=s*o,t[3]=r*o,t}function v(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}const _$1={vert:"\n    attribute vec3 aPosition;\n    attribute vec2 aTexCoord;\n    uniform mat4 projViewModelMatrix;\n    uniform mat4 positionMatrix;\n    uniform mat4 modelMatrix;\n    varying vec2 vTexCoords;\n    #include <get_output>\n    void main()\n    {\n        mat4 localPositionMatrix = getPositionMatrix();\n        vec4 localPosition = getPosition(aPosition);\n        gl_Position = projViewModelMatrix * localPositionMatrix * localPosition;\n        vTexCoords = aTexCoord;\n    }\n",frag:"\n    precision mediump float;\n    uniform sampler2D videoTexture;\n    uniform float opacity;\n\n    varying vec2 vTexCoords;\n    void main() {\n        vec4 color = texture2D(videoTexture, vTexCoords);\n        gl_FragColor = color * opacity;\n    }\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>multiply$5([],e.projViewMatrix,e.modelMatrix)},"texture","opacity"],positionAttribute:"POSITION",extraCommandProps:{depth:{enable:!0,func:"always"},cull:{enable:!1,face:"back"},frontFace:"cw",blend:{enable:!0,func:{src:"src alpha",dst:"one minus src alpha"},equation:"add"}}},g=[1,0,3,3,2,1];function w(t,e,i){if(!t)return null;const s=t.coordinateToPointAtRes(e,t.getGLRes());return[s.x,s.y,i]}class y$1 extends(t$1.Eventable(t$1.Handlerable(t$1.Class))){constructor(t,e){super(e),this.setCoordinates(t),this.A(this.options.url)}setCoordinates(t){this.k=t}getCoordinates(){return this.k}setVideo(t){this.I="stop",this.options.url=t,delete this.options.elementId,this.A()}setElementId(t){this.I="stop",this.options.elementId=t,delete this.options.url,this.A()}A(){this.I="stop";const t=this.options.url;let i=document.getElementById(this.options.elementId);if(t&&(i=document.createElement("video"),i.src=t),!i)throw new Error("there is no element or url setting for video mask");i.autoplay=!0,i.loop=!0,i.muted=!0,i.play(),i.addEventListener("playing",(()=>{this.I="playing",this.fire("playing",{state:this.I,url:t})})),i.addEventListener("pause",(()=>{this.I="pause",this.fire("pause",{state:this.I,url:t})})),i.addEventListener("error",(()=>{throw this.I="pause",this.fire("error",{state:this.I,url:t}),new Error("video resource load error")})),this.video=i}getVideo(){return this.video}R(t){this.D=t}S(){return this.D}addTo(t){if(this.L)throw new Error("VideoSurface cannot be added to two or more layers at the same time.");return t.addSurfaces(this),this}show(){return this.options.visible=!0,this}hide(){return this.options.visible=!1,this}isVisible(){return this.options.visible}play(){this.video&&this.video.play()}pause(){this.video&&this.video.pause()}setAudio(t){this.video.muted=t}setOpacity(t){this.options.opacity=t}getOpacity(){return this.options.opacity}remove(){delete this.video;const t=this.getLayer();t&&t.removeVideoSurfaces(this),this.endEdit()}getLayer(){return this.L}P(){return"playing"===this.I}startEdit(){const t=this.getLayer();if(!t)return void console.warn("videosurface should be added to a map before edit");const e=t.getMap();if(!e)return void console.warn("videosurface should be added to a map before edit");if(this.j(),!this.F){const i=t.getId();this.F=new t$1.VectorLayer(`internal_${i}_edit`,{enableAltitude:!0}).addTo(e)}const i=this.getCoordinates();this.N=new t$1.Polygon(i,{symbol:{lineColor:"#34495e",lineWidth:2,polygonFill:"rgb(135,196,240)",polygonOpacity:.1}}).addTo(this.F),this.N.startEdit({newVertexHandleSymbol:{polygonFill:"rgba(0, 0, 0, 0)",polygonOpacity:0,markerType:"ellipse",markerWidth:1,markerHeight:1}}),this.N.on("shapechange",(e=>{const i=e.target.getCoordinates()[0].slice(0,4).map((t=>[t.x,t.y,0]));this.setCoordinates(i),t.getRenderer().T(this)}),this)}endEdit(){this.F&&(this.N.endEdit(),this.N.remove(),this.F.remove()),delete this.F,delete this.N}j(){this.F&&this.F.clear(),delete this.N}}y$1.mergeOptions({opacity:1,visible:!0});class b$1 extends t$1.Layer{constructor(t,e,i){!e||Array.isArray(e)||e instanceof y$1||(i=e,e=null),super(t,i),this.G={},this.videoId=0,e&&this.addSurfaces(e)}addSurfaces(t){if(t)if(Array.isArray(t))t.forEach((t=>{this.addMarker(t)}));else{t.L=this,this.G[this.videoId]=t,t.R(this.videoId);const e=this.getRenderer();e?e.p()&&e.l(t):this.on("renderercreate",(e=>{e.renderer.p()&&e.renderer.l(t)})),this.videoId++}}showTopAlways(t){this.options.showTopAlways=t;const e=this.getRenderer();e&&e.m()}setDoubleSide(t){this.options.doubleSide=t;const e=this.getRenderer();e&&e.m()}getVideoSurfaces(){const t=[];for(const e in this.G)t.push(this.G[e]);return t}removeVideoSurfaces(t){if(Array.isArray(t))t.forEach((t=>{this.removeVideoSurfaces(t)}));else{const e=t.S(),i=this.getRenderer();i&&i.V(e),delete this.G[e]}}remove(){this.clear(),super.remove()}clear(){const t=this.getVideoSurfaces();for(let e=0;e<t.length;e++)t[e].remove()}}b$1.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,markerEvents:!0,forceRenderOnZooming:!0,forceRenderOnMoving:!0,forceRenderOnRotating:!0,showTopAlways:!0,doubleSide:!0}),b$1.registerJSONType("VideoLayer"),b$1.registerRenderer("gl",class extends t__namespace.renderer.CanvasRenderer{constructor(t){super(t),this.t={}}draw(t,e){this.prepareCanvas(),this.i(e)}drawOnInteracting(t,e,i){this.i(i)}needToRedraw(){return!0}hitDetect(){return!1}createContext(){if(this.canvas.gl&&this.canvas.gl.wrap)this.gl=this.canvas.gl.wrap(),this.regl=this.canvas.gl.regl;else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,stencil:!0};this.glOptions=t,this.gl=this.gl||this.s(this.canvas,t),this.regl=a$2({gl:this.gl,extensions:["ANGLE_instanced_arrays","OES_texture_float","OES_texture_half_float","OES_texture_float_linear","OES_texture_half_float_linear","EXT_shader_texture_lod","OES_element_index_uint","OES_standard_derivatives","WEBGL_depth_texture"],optionalExtensions:this.layer.options.glExtensions||[]})}this.o(),this.h();const t=this.layer.getVideoSurfaces();for(let e=0;e<t.length;e++)this.l(t[e])}s(t,e){const i=["webgl","experimental-webgl"];let s=null;for(let r=0;r<i.length;++r){try{s=t.getContext(i[r],e)}catch(t){}if(s)break}return s}h(){const t=this.layer.getMap(),e=new B$6(this.regl);this.renderer=e,this.u={projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,viewMatrix:t.viewMatrix,halton:[.2107,-.0202],uHalton:[.2107,-.0202],uCameraPosition:t.cameraPosition,cameraPosition:t.cameraPosition,globalTexSize:[t.width,t.height]}}p(){return this.regl}o(){this.viewport={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1},this.m()}m(){this.v&&this.v.dispose(),this.layer.options.showTopAlways?(_$1.extraCommandProps.depth.mask=!1,_$1.extraCommandProps.depth.range=[0,0]):(delete _$1.extraCommandProps.depth.mask,delete _$1.extraCommandProps.depth.range),_$1.extraCommandProps.cull.enable=!this.layer.options.doubleSide,this.v=new vn$4(_$1)}l(t){const e=this.regl.texture(),i=new Ce$5({videoTexture:e,opacity:1}),s=t.getCoordinates(),{worldCenter:r,points:o}=this._(s),n=this.g(o),a=new Be$5(n,i);this.O(a,r);const l=new Ke$5(a),d=t.S();this.t[d]=l}T(t){const e=t.S(),i=this.t[e].getMeshes()[0],s=t.getCoordinates();i.geometry.dispose();const{worldCenter:r,points:o}=this._(s),n=this.g(o);i.geometry=n,this.O(i,r)}i(t){const e=this.layer.getVideoSurfaces().filter((t=>t.isVisible()));if(!e.length)return;const i=this.C(e);if(!i)return;let s=null;t&&(s=t.renderTarget&&t.renderTarget.fbo),this.renderer.render(this.v,this.u,i,s)}g(t){return new Q$7({POSITION:t,TEXCOORD:[0,0,1,0,1,1,0,1]},g,0,{primitive:"triangles",positionAttribute:"POSITION",uv0Attribute:"TEXCOORD",normalAttribute:"NORMAL",positionSize:3})}_(e){let i=[];const s=this.getMap(),r=new t__namespace.Polygon(e).getCenter(),o=w(s,r,0);return this.M=o,s&&e.forEach((e=>{const r=new t__namespace.Coordinate(e[0],e[1]),n=s.altitudeToPoint(e[2]||0,s.getGLRes()),a=w(s,r,n);a[0]=a[0]-o[0],a[1]=a[1]-o[1],i=i.concat(a)})),{worldCenter:o,points:i}}C(t){const e=[],i=this.layer.getMap();for(let s=0;s<t.length;s++){const r=t[s],o=this.t[r.S()];if(!o)continue;const n=o.getMeshes();for(let t=0;t<n.length;t++){const s=n[t],o=s.getMaterial(),a=o.get("videoTexture");a&&r.P()&&(a(r.video),o.set("opacity",r.getOpacity())),f(i.projViewMatrix,s.getBoundingBox())&&e.push(s)}}return e.length?new Ke$5(e):null}O(t,e){fromRotationTranslationScale(t.localTransform,fromEuler([],0,0,0),e,[1,1,1])}remove(){this.v&&this.v.dispose(),super.remove()}clearCanvas(){this.canvas&&(this.regl.clear({color:[0,0,0,0],depth:1,stencil:0}),super.clearCanvas())}V(t){const e=this.t[t];e&&e.getMeshes().forEach((t=>{t.geometry.dispose(),t.material&&t.material.dispose(),t.dispose()}))}});
/*!
	 * @maptalks/analysis v0.95.6
	 * LICENSE : UNLICENSED
	 * (c) 2016-2024 maptalks.org
	 */
var _,D="undefined"!=typeof Float32Array?Float32Array:Array;function I(A){return A[0]=1,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=1,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=1,A[11]=0,A[12]=0,A[13]=0,A[14]=0,A[15]=1,A}function M(A,t,n){var i=t[0],r=t[1],e=t[2],s=t[3],u=t[4],o=t[5],h=t[6],f=t[7],c=t[8],a=t[9],v=t[10],l=t[11],w=t[12],P=t[13],g=t[14],C=t[15],D=n[0],I=n[1],M=n[2],b=n[3];return A[0]=D*i+I*u+M*c+b*w,A[1]=D*r+I*o+M*a+b*P,A[2]=D*e+I*h+M*v+b*g,A[3]=D*s+I*f+M*l+b*C,A[4]=(D=n[4])*i+(I=n[5])*u+(M=n[6])*c+(b=n[7])*w,A[5]=D*r+I*o+M*a+b*P,A[6]=D*e+I*h+M*v+b*g,A[7]=D*s+I*f+M*l+b*C,A[8]=(D=n[8])*i+(I=n[9])*u+(M=n[10])*c+(b=n[11])*w,A[9]=D*r+I*o+M*a+b*P,A[10]=D*e+I*h+M*v+b*g,A[11]=D*s+I*f+M*l+b*C,A[12]=(D=n[12])*i+(I=n[13])*u+(M=n[14])*c+(b=n[15])*w,A[13]=D*r+I*o+M*a+b*P,A[14]=D*e+I*h+M*v+b*g,A[15]=D*s+I*f+M*l+b*C,A}function b(A,t,n){var i=n[0],r=n[1],e=n[2];return A[0]=t[0]*i,A[1]=t[1]*i,A[2]=t[2]*i,A[3]=t[3]*i,A[4]=t[4]*r,A[5]=t[5]*r,A[6]=t[6]*r,A[7]=t[7]*r,A[8]=t[8]*e,A[9]=t[9]*e,A[10]=t[10]*e,A[11]=t[11]*e,A[12]=t[12],A[13]=t[13],A[14]=t[14],A[15]=t[15],A}function z(A,t,n){var i=Math.sin(n),r=Math.cos(n),e=t[4],s=t[5],u=t[6],o=t[7],h=t[8],f=t[9],c=t[10],a=t[11];return t!==A&&(A[0]=t[0],A[1]=t[1],A[2]=t[2],A[3]=t[3],A[12]=t[12],A[13]=t[13],A[14]=t[14],A[15]=t[15]),A[4]=e*r+h*i,A[5]=s*r+f*i,A[6]=u*r+c*i,A[7]=o*r+a*i,A[8]=h*r-e*i,A[9]=f*r-s*i,A[10]=c*r-u*i,A[11]=a*r-o*i,A}function d(A,t,n){var i=Math.sin(n),r=Math.cos(n),e=t[0],s=t[1],u=t[2],o=t[3],h=t[8],f=t[9],c=t[10],a=t[11];return t!==A&&(A[4]=t[4],A[5]=t[5],A[6]=t[6],A[7]=t[7],A[12]=t[12],A[13]=t[13],A[14]=t[14],A[15]=t[15]),A[0]=e*r-h*i,A[1]=s*r-f*i,A[2]=u*r-c*i,A[3]=o*r-a*i,A[8]=e*i+h*r,A[9]=s*i+f*r,A[10]=u*i+c*r,A[11]=o*i+a*r,A}function x(A,t,n){var i=Math.sin(n),r=Math.cos(n),e=t[0],s=t[1],u=t[2],o=t[3],h=t[4],f=t[5],c=t[6],a=t[7];return t!==A&&(A[8]=t[8],A[9]=t[9],A[10]=t[10],A[11]=t[11],A[12]=t[12],A[13]=t[13],A[14]=t[14],A[15]=t[15]),A[0]=e*r+h*i,A[1]=s*r+f*i,A[2]=u*r+c*i,A[3]=o*r+a*i,A[4]=h*r-e*i,A[5]=f*r-s*i,A[6]=c*r-u*i,A[7]=a*r-o*i,A}function m(A,t){return A[0]=t[12],A[1]=t[13],A[2]=t[14],A}function y(A,t,n,i){var r=t[0],e=t[1],s=t[2],u=t[3],o=r+r,h=e+e,f=s+s,c=r*o,a=r*h,v=r*f,l=e*h,w=e*f,P=s*f,g=u*o,C=u*h,D=u*f,I=i[0],M=i[1],b=i[2];return A[0]=(1-(l+P))*I,A[1]=(a+D)*I,A[2]=(v-C)*I,A[3]=0,A[4]=(a-D)*M,A[5]=(1-(c+P))*M,A[6]=(w+g)*M,A[7]=0,A[8]=(v+C)*b,A[9]=(w-g)*b,A[10]=(1-(c+l))*b,A[11]=0,A[12]=n[0],A[13]=n[1],A[14]=n[2],A[15]=1,A}function p(A,t,n,i,r){var e=1/Math.tan(t/2),s=void 0;return A[0]=e/n,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=e,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[11]=-1,A[12]=0,A[13]=0,A[15]=0,null!=r&&r!==1/0?(A[10]=(r+i)*(s=1/(i-r)),A[14]=2*r*i*s):(A[10]=-1,A[14]=-2*i),A}function L(A,t,n,i){var r=void 0,e=void 0,s=void 0,u=void 0,o=void 0,h=void 0,f=void 0,c=void 0,a=void 0,v=void 0,l=t[0],w=t[1],P=t[2],g=i[0],C=i[1],D=i[2],M=n[0],b=n[1],z=n[2];return Math.abs(l-M)<1e-6&&Math.abs(w-b)<1e-6&&Math.abs(P-z)<1e-6?I(A):(f=l-M,c=w-b,a=P-z,r=C*(a*=v=1/Math.sqrt(f*f+c*c+a*a))-D*(c*=v),e=D*(f*=v)-g*a,s=g*c-C*f,(v=Math.sqrt(r*r+e*e+s*s))?(r*=v=1/v,e*=v,s*=v):(r=0,e=0,s=0),u=c*s-a*e,o=a*r-f*s,h=f*e-c*r,(v=Math.sqrt(u*u+o*o+h*h))?(u*=v=1/v,o*=v,h*=v):(u=0,o=0,h=0),A[0]=r,A[1]=u,A[2]=f,A[3]=0,A[4]=e,A[5]=o,A[6]=c,A[7]=0,A[8]=s,A[9]=h,A[10]=a,A[11]=0,A[12]=-(r*l+e*w+s*P),A[13]=-(u*l+o*w+h*P),A[14]=-(f*l+c*w+a*P),A[15]=1,A)}function T(){var A=new D(3);return D!=Float32Array&&(A[0]=0,A[1]=0,A[2]=0),A}function F(A,t,n){var i=new D(3);return i[0]=A,i[1]=t,i[2]=n,i}function U(A,t){return A[0]=t[0],A[1]=t[1],A[2]=t[2],A}function E(A,t,n,i){return A[0]=t,A[1]=n,A[2]=i,A}function N(A,t,n){return A[0]=t[0]+n[0],A[1]=t[1]+n[1],A[2]=t[2]+n[2],A}function j(A,t,n){return A[0]=t[0]-n[0],A[1]=t[1]-n[1],A[2]=t[2]-n[2],A}function Q(A,t){var n=t[0],i=t[1],r=t[2],e=n*n+i*i+r*r;return e>0&&(e=1/Math.sqrt(e),A[0]=t[0]*e,A[1]=t[1]*e,A[2]=t[2]*e),A}function k(A,t,n){var i=t[0],r=t[1],e=t[2],s=n[3]*i+n[7]*r+n[11]*e+n[15];return A[0]=(n[0]*i+n[4]*r+n[8]*e+n[12])/(s=s||1),A[1]=(n[1]*i+n[5]*r+n[9]*e+n[13])/s,A[2]=(n[2]*i+n[6]*r+n[10]*e+n[14])/s,A}function B(A,t){var n=F(A[0],A[1],A[2]),i=F(t[0],t[1],t[2]);Q(n,n),Q(i,i);var r=function(A,t){return A[0]*t[0]+A[1]*t[1]+A[2]*t[2]}(n,i);return r>1?0:r<-1?Math.PI:Math.acos(r)}function R(){var A=new D(4);return D!=Float32Array&&(A[0]=0,A[1]=0,A[2]=0),A[3]=1,A}function G(A){return A[0]=0,A[1]=0,A[2]=0,A[3]=1,A}function Y(A,t,n){n*=.5;var i=t[0],r=t[1],e=t[2],s=t[3],u=Math.sin(n),o=Math.cos(n);return A[0]=i*o+s*u,A[1]=r*o+e*u,A[2]=e*o-r*u,A[3]=s*o-i*u,A}function q(A,t,n){n*=.5;var i=t[0],r=t[1],e=t[2],s=t[3],u=Math.sin(n),o=Math.cos(n);return A[0]=i*o-e*u,A[1]=r*o+s*u,A[2]=e*o+i*u,A[3]=s*o-r*u,A}function V(A,t,n){n*=.5;var i=t[0],r=t[1],e=t[2],s=t[3],u=Math.sin(n),o=Math.cos(n);return A[0]=i*o+r*u,A[1]=r*o-i*u,A[2]=e*o+s*u,A[3]=s*o-e*u,A}function W(A,t,n,i){var r=.5*Math.PI/180;t*=r,n*=r,i*=r;var e=Math.sin(t),s=Math.cos(t),u=Math.sin(n),o=Math.cos(n),h=Math.sin(i),f=Math.cos(i);return A[0]=e*o*f-s*u*h,A[1]=s*u*f+e*o*h,A[2]=s*o*h-e*u*f,A[3]=s*o*f+e*u*h,A}function K(A,t,n){return A[0]=t,A[1]=n,A}T(),function(){var A;A=new D(4),D!=Float32Array&&(A[0]=0,A[1]=0,A[2]=0,A[3]=0)}(),T(),F(1,0,0),F(0,1,0),R(),R(),_=new D(9),D!=Float32Array&&(_[1]=0,_[2]=0,_[3]=0,_[5]=0,_[6]=0,_[7]=0),_[0]=1,_[4]=1,_[8]=1,function(){var A=new D(2);D!=Float32Array&&(A[0]=0,A[1]=0)}();class H{constructor(A,t){this.renderer=A,this.regl=A.regl,this.u=t,this.h()}h(){this.l=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:2048,height:2048,wrap:"clamp",mag:"nearest",min:"nearest"}),depth:!0})}g(A,t,n){const i={projViewMatrix:t,minAltitude:0,logDepthBufFC:2/(Math.log(n+1)/Math.LN2)};this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.l}),this.renderer.render(this.C,i,A,this.l)}D(t,n){this.C=new vn$4({vert:"#include <gl2_vert>\n\n#ifdef HAS_ALTITUDE\n\n    attribute vec2 aPosition;\n\n    attribute float aAltitude;\n\n#else\n\n    attribute vec3 aPosition;\n\n#endif\n\n// uniform mat4 projViewMatrix;\n\n// uniform mat4 modelMatrix;\n\nuniform mat4 projViewModelMatrix;\n\nuniform mat4 positionMatrix;\n\nvarying vec2 vHighPrecisionZW;\n\n#include <get_output>\n\nvarying float vFragDepth;\n\n\n\n#ifdef HAS_ALTITUDE\n\n    vec3 unpackVTPosition() {\n\n        return vec3(aPosition, aAltitude);\n\n    }\n\n#endif\n\nvoid main()\n\n{\n\n    #ifdef HAS_ALTITUDE\n\n        vec3 i = unpackVTPosition();\n\n        vec4 j = vec4(i, 1.);\n\n        gl_Position = projViewModelMatrix * j;\n\n    #else\n\n        mat4 localPositionMatrix = getPositionMatrix();\n\n        gl_Position = projViewModelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    #endif\n\n    vFragDepth = 1.0 + gl_Position.w;\n\n    vHighPrecisionZW = gl_Position.zw;\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\n#include <gl2_frag>\n\n\n\nuniform float logDepthBufFC;\n\nvarying float vFragDepth;\n\nvarying vec2 vHighPrecisionZW;\n\n\n\nconst float PackUpscale = 256. / 255.;\n\nconst float UnpackDownscale = 255. / 256.;\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\n\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA(const in float v ) {\n\n    vec4 r = vec4(fract(v * PackFactors), v);\n\n    r.yzw -= r.xyz * ShiftRight8;\n\n    return r * PackUpscale;\n\n}\n\nvoid main() {\n\n    gl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n\n    float fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n    glFragColor = packDepthToRGBA(fragCoordZ);\n\n    #if __VERSION__ == 100\n\n        gl_FragColor = glFragColor;\n\n    #endif\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,t)=>M([],t.projViewMatrix,t.modelMatrix)}],extraCommandProps:{viewport:{x:0,y:0,width:()=>{const A=this.I(t,n);return A?A.width:1},height:()=>{const A=this.I(t,n);return A?A.height:1}}}}),this.C.version=300}I(A,t){return this.m(A,t)?{width:2048,height:2048}:null}m(A,t){return A&&t&&A*t>0}dispose(){this.l&&this.l.destroy(),this.C&&this.C.dispose()}}const J=[0,0,0,1];class Z extends H{h(){this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.O=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 projViewModelMatrix;\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 localPosition = localPositionMatrix * getPosition(aPosition);\n\n    gl_Position = projViewModelMatrix * localPosition;\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\n\n\nvoid main() {\n\n    gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n}\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,n)=>multiply$5([],n.projViewMatrix,n.modelMatrix)}],extraCommandProps:{viewport:this.u}}),this.F=new Ke$5}render(A,t){this.U(),this.renderer.clear({color:J,depth:1,framebuffer:this.T}),this.F.setMeshes(A);return this.renderer.render(this.O,{projViewMatrix:t},this.F,this.T),this.T}U(){const A=t__namespace.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,t=t__namespace.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;!this.T||this.T.width===A&&this.T.height===t||this.T.resize(A,t)}dispose(){this.T&&(this.T.destroy(),delete this.T),this.O&&(this.O.dispose(),delete this.O)}}function X(A,t){return A.altitudeToPoint(t||0,A.getGLRes())}const $=new t__namespace.Coordinate(0,0);function AA(A,t,n,i){if(!A)return null;$.set(t,n);const r=A.coordinateToPointAtRes($,A.getGLRes()),e=X(A,i);return[r.x,r.y,e]}var tA={exports:{}};function nA(A,t,n){n=n||2;var i,r,e,s,u,o,h,f=t&&t.length,c=f?t[0]*n:A.length,a=iA(A,0,c,n,!0),v=[];if(!a||a.next===a.prev)return v;if(f&&(a=function(A,t,n,i){var r,e,o,h=[];for(r=0,e=t.length;r<e;r++)(o=iA(A,t[r]*i,r<e-1?t[r+1]*i:A.length,i,!1))===o.next&&(o.steiner=!0),h.push(lA(o));for(h.sort(fA),r=0;r<h.length;r++)n=cA(h[r],n);return n}(A,t,a,n)),A.length>80*n){i=e=A[0],r=s=A[1];for(var l=n;l<c;l+=n)(u=A[l])<i&&(i=u),(o=A[l+1])<r&&(r=o),u>e&&(e=u),o>s&&(s=o);h=0!==(h=Math.max(e-i,s-r))?32767/h:0}return eA(a,v,n,i,r,h,0),v}function iA(A,t,n,i,r){var e,s;if(r===yA(A,t,n,i)>0)for(e=t;e<n;e+=i)s=dA(e,A[e],A[e+1],s);else for(e=n-i;e>=t;e-=i)s=dA(e,A[e],A[e+1],s);return s&&CA(s,s.next)&&(xA(s),s=s.next),s}function rA(A,t){if(!A)return A;t||(t=A);var n,i=A;do{if(n=!1,i.steiner||!CA(i,i.next)&&0!==gA(i.prev,i,i.next))i=i.next;else{if(xA(i),(i=t=i.prev)===i.next)break;n=!0}}while(n||i!==t);return t}function eA(A,t,n,i,r,e,s){if(A){!s&&e&&function(A,t,n,i){var r=A;do{0===r.z&&(r.z=vA(r.x,r.y,t,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==A);r.prevZ.nextZ=null,r.prevZ=null,function(A){var t,n,i,r,e,s,u,o,h=1;do{for(n=A,A=null,e=null,s=0;n;){for(s++,i=n,u=0,t=0;t<h&&(u++,i=i.nextZ);t++);for(o=h;u>0||o>0&&i;)0!==u&&(0===o||!i||n.z<=i.z)?(r=n,n=n.nextZ,u--):(r=i,i=i.nextZ,o--),e?e.nextZ=r:A=r,r.prevZ=e,e=r;n=i}e.nextZ=null,h*=2}while(s>1)}(r)}(A,i,r,e);for(var u,o,h=A;A.prev!==A.next;)if(u=A.prev,o=A.next,e?uA(A,i,r,e):sA(A))t.push(u.i/n|0),t.push(A.i/n|0),t.push(o.i/n|0),xA(A),A=o.next,h=o.next;else if((A=o)===h){s?1===s?eA(A=oA(rA(A),t,n),t,n,i,r,e,2):2===s&&hA(A,t,n,i,r,e):eA(rA(A),t,n,i,r,e,1);break}}}function sA(A){var t=A.prev,n=A,i=A.next;if(gA(t,n,i)>=0)return!1;for(var r=t.x,e=n.x,s=i.x,u=t.y,o=n.y,h=i.y,f=r<e?r<s?r:s:e<s?e:s,c=u<o?u<h?u:h:o<h?o:h,a=r>e?r>s?r:s:e>s?e:s,v=u>o?u>h?u:h:o>h?o:h,l=i.next;l!==t;){if(l.x>=f&&l.x<=a&&l.y>=c&&l.y<=v&&wA(r,u,e,o,s,h,l.x,l.y)&&gA(l.prev,l,l.next)>=0)return!1;l=l.next}return!0}function uA(A,t,n,i){var r=A.prev,e=A,s=A.next;if(gA(r,e,s)>=0)return!1;for(var u=r.x,o=e.x,h=s.x,f=r.y,c=e.y,a=s.y,v=u<o?u<h?u:h:o<h?o:h,l=f<c?f<a?f:a:c<a?c:a,w=u>o?u>h?u:h:o>h?o:h,P=f>c?f>a?f:a:c>a?c:a,g=vA(v,l,t,n,i),C=vA(w,P,t,n,i),D=A.prevZ,I=A.nextZ;D&&D.z>=g&&I&&I.z<=C;){if(D.x>=v&&D.x<=w&&D.y>=l&&D.y<=P&&D!==r&&D!==s&&wA(u,f,o,c,h,a,D.x,D.y)&&gA(D.prev,D,D.next)>=0)return!1;if(D=D.prevZ,I.x>=v&&I.x<=w&&I.y>=l&&I.y<=P&&I!==r&&I!==s&&wA(u,f,o,c,h,a,I.x,I.y)&&gA(I.prev,I,I.next)>=0)return!1;I=I.nextZ}for(;D&&D.z>=g;){if(D.x>=v&&D.x<=w&&D.y>=l&&D.y<=P&&D!==r&&D!==s&&wA(u,f,o,c,h,a,D.x,D.y)&&gA(D.prev,D,D.next)>=0)return!1;D=D.prevZ}for(;I&&I.z<=C;){if(I.x>=v&&I.x<=w&&I.y>=l&&I.y<=P&&I!==r&&I!==s&&wA(u,f,o,c,h,a,I.x,I.y)&&gA(I.prev,I,I.next)>=0)return!1;I=I.nextZ}return!0}function oA(A,t,n){var i=A;do{var r=i.prev,e=i.next.next;!CA(r,e)&&DA(r,i,i.next,e)&&bA(r,e)&&bA(e,r)&&(t.push(r.i/n|0),t.push(i.i/n|0),t.push(e.i/n|0),xA(i),xA(i.next),i=A=e),i=i.next}while(i!==A);return rA(i)}function hA(A,t,n,i,r,e){var s=A;do{for(var u=s.next.next;u!==s.prev;){if(s.i!==u.i&&PA(s,u)){var o=zA(s,u);return s=rA(s,s.next),o=rA(o,o.next),eA(s,t,n,i,r,e,0),void eA(o,t,n,i,r,e,0)}u=u.next}s=s.next}while(s!==A)}function fA(A,t){return A.x-t.x}function cA(A,t){var n=function(A,t){var n,i=t,r=A.x,e=A.y,s=-1/0;do{if(e<=i.y&&e>=i.next.y&&i.next.y!==i.y){var u=i.x+(e-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(u<=r&&u>s&&(s=u,n=i.x<i.next.x?i:i.next,u===r))return n}i=i.next}while(i!==t);if(!n)return null;var o,h=n,f=n.x,c=n.y,a=1/0;i=n;do{r>=i.x&&i.x>=f&&r!==i.x&&wA(e<c?r:s,e,f,c,e<c?s:r,e,i.x,i.y)&&(o=Math.abs(e-i.y)/(r-i.x),bA(i,A)&&(o<a||o===a&&(i.x>n.x||i.x===n.x&&aA(n,i)))&&(n=i,a=o)),i=i.next}while(i!==h);return n}(A,t);if(!n)return t;var i=zA(n,A);return rA(i,i.next),rA(n,n.next)}function aA(A,t){return gA(A.prev,A,t.prev)<0&&gA(t.next,A,A.next)<0}function vA(A,t,n,i,r){return(A=1431655765&((A=858993459&((A=252645135&((A=16711935&((A=(A-n)*r|0)|A<<8))|A<<4))|A<<2))|A<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-i)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function lA(A){var t=A,n=A;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==A);return n}function wA(A,t,n,i,r,e,s,u){return(r-s)*(t-u)>=(A-s)*(e-u)&&(A-s)*(i-u)>=(n-s)*(t-u)&&(n-s)*(e-u)>=(r-s)*(i-u)}function PA(A,t){return A.next.i!==t.i&&A.prev.i!==t.i&&!function(A,t){var n=A;do{if(n.i!==A.i&&n.next.i!==A.i&&n.i!==t.i&&n.next.i!==t.i&&DA(n,n.next,A,t))return!0;n=n.next}while(n!==A);return!1}(A,t)&&(bA(A,t)&&bA(t,A)&&function(A,t){var n=A,i=!1,r=(A.x+t.x)/2,e=(A.y+t.y)/2;do{n.y>e!=n.next.y>e&&n.next.y!==n.y&&r<(n.next.x-n.x)*(e-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==A);return i}(A,t)&&(gA(A.prev,A,t.prev)||gA(A,t.prev,t))||CA(A,t)&&gA(A.prev,A,A.next)>0&&gA(t.prev,t,t.next)>0)}function gA(A,t,n){return(t.y-A.y)*(n.x-t.x)-(t.x-A.x)*(n.y-t.y)}function CA(A,t){return A.x===t.x&&A.y===t.y}function DA(A,t,n,i){var r=MA(gA(A,t,n)),e=MA(gA(A,t,i)),s=MA(gA(n,i,A)),u=MA(gA(n,i,t));return r!==e&&s!==u||!(0!==r||!IA(A,n,t))||!(0!==e||!IA(A,i,t))||!(0!==s||!IA(n,A,i))||!(0!==u||!IA(n,t,i))}function IA(A,t,n){return t.x<=Math.max(A.x,n.x)&&t.x>=Math.min(A.x,n.x)&&t.y<=Math.max(A.y,n.y)&&t.y>=Math.min(A.y,n.y)}function MA(A){return A>0?1:A<0?-1:0}function bA(A,t){return gA(A.prev,A,A.next)<0?gA(A,t,A.next)>=0&&gA(A,A.prev,t)>=0:gA(A,t,A.prev)<0||gA(A,A.next,t)<0}function zA(A,t){var n=new mA(A.i,A.x,A.y),i=new mA(t.i,t.x,t.y),r=A.next,e=t.prev;return A.next=t,t.prev=A,n.next=r,r.prev=n,i.next=n,n.prev=i,e.next=i,i.prev=e,i}function dA(A,t,n,i){var r=new mA(A,t,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function xA(A){A.next.prev=A.prev,A.prev.next=A.next,A.prevZ&&(A.prevZ.nextZ=A.nextZ),A.nextZ&&(A.nextZ.prevZ=A.prevZ)}function mA(A,t,n){this.i=A,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function yA(A,t,n,i){for(var r=0,e=t,s=n-i;e<n;e+=i)r+=(A[s]-A[e])*(A[e+1]+A[s+1]),s=e;return r}tA.exports=nA,tA.exports.default=nA,nA.deviation=function(A,t,n,i){var r=t&&t.length,s=Math.abs(yA(A,0,r?t[0]*n:A.length,n));if(r)for(var u=0,o=t.length;u<o;u++){s-=Math.abs(yA(A,t[u]*n,u<o-1?t[u+1]*n:A.length,n))}var c=0;for(u=0;u<i.length;u+=3){var a=i[u]*n,v=i[u+1]*n,l=i[u+2]*n;c+=Math.abs((A[a]-A[l])*(A[v+1]-A[a+1])-(A[a]-A[v])*(A[l+1]-A[a+1]))}return 0===s&&0===c?0:Math.abs((c-s)/s)},nA.flatten=function(A){for(var t=A[0][0].length,n={vertices:[],holes:[],dimensions:t},i=0,r=0;r<A.length;r++){for(var e=0;e<A[r].length;e++)for(var s=0;s<t;s++)n.vertices.push(A[r][e][s]);r>0&&n.holes.push(i+=A[r-1].length)}return n};var pA=tA.exports;class LA extends(t$1.Eventable(t$1.Handlerable(t$1.Class))){constructor(A){super(A),this.N=!0}addTo(A){return A.getMap()?(this.layer=A,this.j()):A.once("add",(()=>{this.addTo(A)}),this),this}j(){const A=this.layer.getRenderer();A?(this.regl=A.regl,this.S(A)):this.layer.once("renderercreate",(A=>{this.regl=A.renderer.regl,this.S(A.renderer)}),this)}enable(){this.N=!0;const A=this.layer.getRenderer();A&&A.setToRedraw()}disable(){this.N=!1;const A=this.layer.getRenderer();A&&A.setToRedraw()}isEnable(){return this.N}remove(){if(this.layer){const A=this.layer;delete this.layer,A.removeAnalysis(this),this.k&&(this.k.dispose(),delete this.k),this.B&&(this.B.dispose(),delete this.B),this.R&&(this.R.forEach((A=>{A.geometry.dispose(),A.dispose()})),delete this.R),this.G&&(this.G.dispose(),delete this.G)}}update(A,t){this.options[A]=t;const n=this.layer.getRenderer();n&&n.setToRedraw()}getExcludeLayers(){return this.options.excludeLayers||[]}setExcludeLayers(A){this.options.excludeLayers=A}exportAnalysisMap(A){if(!this.isEnable())return null;let t=this.k.render(A,this.q);t=t.meshesMap?t.meshesMap:t;const n=this.layer.getRenderer();if(t&&n){const A=n.regl,i=t.width,r=t.height,e=new Uint8Array(4*i*r);return A.read({data:e,x:0,y:0,framebuffer:t,width:i,height:r}),e}return null}getAnalysisType(){return this.type}V(A){const t=new t$1.Polygon(A,{symbol:{polygonOpacity:.2}}).getExtent();return this.W(t,A)}W(n,i){const r=this.layer.getMap(),e=r.getCenter(),s=r.getZoom(),u=r.getPitch(),o=r.getBearing(),h=r.getFitZoom(n),f=n.getCenter();r.setZoom(h),r.setCenter(f),r.setPitch(0),r.setBearing(0);const c=r.getExtent();this._=this._||[],copy$5(this._,r.projViewMatrix);const a=AA(r,c.xmin,c.ymin),v=AA(r,c.xmax,c.ymax),l=[a[0],a[1],v[0],v[1]],w=AA(r,n.xmin,n.ymin),P=AA(r,n.xmax,n.ymax),g=[w[0],w[1],P[0],P[1]];if(r.setZoom(s),r.setCenter(e),r.setPitch(u),r.setBearing(o),this.R=this.K(i,f),!this.B){const t=new B$6(this.regl);this.B=new Z(t,this.u)}return{extentMap:this.B.render(this.R,this._),extentInWorld:l,extentPolygon:g}}K(i,r){const e=[],s=this.layer.getMap(),u=AA(s,r.x,r.y,0);for(let A=0;A<i.length;A++){const t=AA(s,...i[A]);e.push(t[0]-u[0]),e.push(t[1]-u[1]),e.push(0)}const o=pA(e,null,3);this.R&&(this.R[0].geometry.dispose(),this.R[0].dispose());const h=new Q$7({POSITION:e},o,0,{positionAttribute:"POSITION"}),f=new Be$5(h),c=fromRotationTranslationScale([],identity$1([]),u,[1,1,1]);return f.localTransform=c,this.R=[f],this.R}}var TA="attribute vec3 aPosition;\n\nattribute vec2 aTexCoord;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 projViewModelMatrix;\n\nuniform mat4 cut_projViewMatrixFromViewpoint;\n\nvarying vec4 cut_positionFromViewpoint;\n\nvarying vec2 v_texCoord;\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 localPosition = localPositionMatrix * getPosition(aPosition);\n\n    gl_PointSize = 1.0;\n\n    gl_Position = projViewModelMatrix * localPosition;\n\n    cut_positionFromViewpoint = cut_projViewMatrixFromViewpoint * modelMatrix * localPosition;\n\n    v_texCoord = aTexCoord;\n\n}\n\n",OA="#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\nuniform sampler2D meshesMap;\n\nvarying vec4 cut_positionFromViewpoint;\n\nvarying vec2 v_texCoord;\n\n\n\nvoid main() {\n\n    vec3 shadowCoord = (cut_positionFromViewpoint.xyz / cut_positionFromViewpoint.w)/2.0 + 0.5;\n\n    if (shadowCoord.x > 0.0 && shadowCoord.x < 1.0 && shadowCoord.y > 0.0 && shadowCoord.y < 1.0 && shadowCoord.z < 1.0) {\n\n        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n    } else {\n\n        #ifdef HAS_HELPERPARTS\n\n          gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n\n        #else\n\n          gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n\n        #endif\n\n        vec2 v = v_texCoord;\n\n    }\n\n}\n\n";const FA={helper:{asset:{generator:"Khronos glTF Blender I/O v1.6.16",version:"2.0"},scene:0,scenes:[{name:"Scene",nodes:[0,1,2,3,4,5,6,7]}],nodes:[{mesh:0,name:"è§’2",scale:[1.365131139755249,1.365131139755249,.21621514856815338],translation:[-8.534053802490234,0,-9.680065155029297]},{mesh:1,name:"è§’3",rotation:[1,0,0,-4.371138828673793e-8],scale:[1.365131139755249,1.365131139755249,.21621514856815338],translation:[-8.534053802490234,.04612281173467636,9.669971466064453]},{mesh:2,name:"è§’1",rotation:[0,0,-1,-4.371138828673793e-8],scale:[1.365131139755249,1.365131139755249,.21621514856815338],translation:[8.530546188354492,.028526417911052704,-9.667880058288574]},{mesh:3,name:"è§’4",rotation:[0,-1,0,1910685676922942e-30],scale:[1.365131139755249,1.365131139755249,.21621514856815338],translation:[8.530546188354492,0,9.639498710632324]},{mesh:4,name:"Xè½´",translation:[.008500291034579277,0,11.816417694091797]},{mesh:5,name:"å¹³é¢",scale:[9.5003657913208,9.5003657913208,9.5003657913208]},{mesh:6,name:"Yè½´",rotation:[.5384660959243774,.45831674337387085,-.45831674337387085,-.5384663343429565],translation:[11.712308883666992,0,.32547950744628906]},{mesh:7,name:"Zè½´",scale:[.49277400970458984,.41999998688697815,.49277400970458984],translation:[.0035659661516547203,1.6771862506866455,-11.201739311218262]}],materials:[{doubleSided:!0,name:"æè´¨.015",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.014",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.016",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.013",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.009",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,.800000011920929],metallicFactor:0,roughnessFactor:.5}},{alphaMode:"BLEND",name:"Color_H04",pbrMetallicRoughness:{metallicFactor:0,roughnessFactor:.6000000238418579}},{doubleSided:!0,name:"æè´¨.017",pbrMetallicRoughness:{baseColorFactor:[0,.2746773362159729,.6795424818992615,.800000011920929],metallicFactor:0,roughnessFactor:.5}},{alphaMode:"BLEND",name:"Color_H04.006",pbrMetallicRoughness:{metallicFactor:0,roughnessFactor:.6000000238418579}},{doubleSided:!0,name:"æè´¨.023",pbrMetallicRoughness:{baseColorFactor:[.010960042476654053,.25818300247192383,.7991030216217041,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.022",pbrMetallicRoughness:{baseColorFactor:[.010960042476654053,.25818300247192383,.7991030216217041,1],metallicFactor:0,roughnessFactor:.5}},{doubleSided:!0,name:"æè´¨.021",pbrMetallicRoughness:{baseColorFactor:[.010960042476654053,.25818300247192383,.7991030216217041,1],metallicFactor:0,roughnessFactor:.5}}],meshes:[{name:"å¹³é¢.009",primitives:[{attributes:{POSITION:0,NORMAL:1,TEXCOORD_0:2},indices:3,material:0}]},{name:"å¹³é¢.010",primitives:[{attributes:{POSITION:4,NORMAL:5,TEXCOORD_0:6},indices:3,material:1}]},{name:"å¹³é¢.011",primitives:[{attributes:{POSITION:7,NORMAL:8,TEXCOORD_0:9},indices:3,material:2}]},{name:"å¹³é¢.012",primitives:[{attributes:{POSITION:10,NORMAL:11,TEXCOORD_0:12},indices:3,material:3}]},{name:"åœ†çŽ¯.004",primitives:[{attributes:{POSITION:13,NORMAL:14,TEXCOORD_0:15},indices:16,material:4},{attributes:{POSITION:17,NORMAL:18,TEXCOORD_0:19},indices:20,material:5}]},{name:"å¹³é¢.015",primitives:[{attributes:{POSITION:21,NORMAL:22,TEXCOORD_0:23},indices:24}]},{name:"åœ†çŽ¯.008",primitives:[{attributes:{POSITION:25,NORMAL:26,TEXCOORD_0:27},indices:16,material:6},{attributes:{POSITION:28,NORMAL:29,TEXCOORD_0:30},indices:20,material:7}]},{name:"ç«‹æ–¹ä½“.011",primitives:[{attributes:{POSITION:31,NORMAL:32,TEXCOORD_0:33},indices:34,material:8},{attributes:{POSITION:35,NORMAL:36,TEXCOORD_0:37},indices:38,material:9},{attributes:{POSITION:39,NORMAL:40,TEXCOORD_0:41},indices:42,material:10}]}],accessors:[{bufferView:0,componentType:5126,count:68,max:[1,.08513133227825165,11.627518653869629],min:[-1,0,-1.0000085830688477],type:"VEC3"},{bufferView:1,componentType:5126,count:68,type:"VEC3"},{bufferView:2,componentType:5126,count:68,type:"VEC2"},{bufferView:3,componentType:5123,count:144,type:"SCALAR"},{bufferView:4,componentType:5126,count:68,max:[1,.08513133227825165,11.627518653869629],min:[-1,0,-1.0000085830688477],type:"VEC3"},{bufferView:5,componentType:5126,count:68,type:"VEC3"},{bufferView:6,componentType:5126,count:68,type:"VEC2"},{bufferView:7,componentType:5126,count:68,max:[1,.08513133227825165,11.627518653869629],min:[-1,0,-1.0000085830688477],type:"VEC3"},{bufferView:8,componentType:5126,count:68,type:"VEC3"},{bufferView:9,componentType:5126,count:68,type:"VEC2"},{bufferView:10,componentType:5126,count:68,max:[1,.08513133227825165,11.627518653869629],min:[-1,0,-1.0000085830688477],type:"VEC3"},{bufferView:11,componentType:5126,count:68,type:"VEC3"},{bufferView:12,componentType:5126,count:68,type:"VEC2"},{bufferView:13,componentType:5126,count:32,max:[1,0,1],min:[-1,0,-1],type:"VEC3"},{bufferView:14,componentType:5126,count:32,type:"VEC3"},{bufferView:15,componentType:5126,count:32,type:"VEC2"},{bufferView:16,componentType:5123,count:90,type:"SCALAR"},{bufferView:17,componentType:5126,count:745,max:[.7661519646644592,.011582847684621811,.664243221282959],min:[-.7468101978302002,-.015204675495624542,-.6202079057693481],type:"VEC3"},{bufferView:18,componentType:5126,count:745,type:"VEC3"},{bufferView:19,componentType:5126,count:745,type:"VEC2"},{bufferView:20,componentType:5123,count:1053,type:"SCALAR"},{bufferView:21,componentType:5126,count:4,max:[1,0,1],min:[-1,0,-1],type:"VEC3"},{bufferView:22,componentType:5126,count:4,type:"VEC3"},{bufferView:23,componentType:5126,count:4,type:"VEC2"},{bufferView:24,componentType:5123,count:6,type:"SCALAR"},{bufferView:25,componentType:5126,count:32,max:[1,0,1],min:[-1,0,-1],type:"VEC3"},{bufferView:26,componentType:5126,count:32,type:"VEC3"},{bufferView:27,componentType:5126,count:32,type:"VEC2"},{bufferView:28,componentType:5126,count:745,max:[.7661519646644592,.011582847684621811,.664243221282959],min:[-.7468101978302002,-.015204675495624542,-.6202079057693481],type:"VEC3"},{bufferView:29,componentType:5126,count:745,type:"VEC3"},{bufferView:30,componentType:5126,count:745,type:"VEC2"},{bufferView:31,componentType:5126,count:16,max:[1,1,1],min:[-1,-1,-1],type:"VEC3"},{bufferView:32,componentType:5126,count:16,type:"VEC3"},{bufferView:33,componentType:5126,count:16,type:"VEC2"},{bufferView:34,componentType:5123,count:18,type:"SCALAR"},{bufferView:35,componentType:5126,count:16,max:[1.0000004768371582,-6.847862720489502,1.0000038146972656],min:[-.999999463558197,-8.847862243652344,-.9999960660934448],type:"VEC3"},{bufferView:36,componentType:5126,count:16,type:"VEC3"},{bufferView:37,componentType:5126,count:16,type:"VEC2"},{bufferView:38,componentType:5123,count:18,type:"SCALAR"},{bufferView:39,componentType:5126,count:24,max:[.23352710902690887,-.6051979064941406,.20581023395061493],min:[-.16755716502666473,-7.437830924987793,-.19527404010295868],type:"VEC3"},{bufferView:40,componentType:5126,count:24,type:"VEC3"},{bufferView:41,componentType:5126,count:24,type:"VEC2"},{bufferView:42,componentType:5123,count:36,type:"SCALAR"}],bufferViews:[{buffer:0,byteLength:816,byteOffset:0},{buffer:0,byteLength:816,byteOffset:816},{buffer:0,byteLength:544,byteOffset:1632},{buffer:0,byteLength:288,byteOffset:2176},{buffer:0,byteLength:816,byteOffset:2464},{buffer:0,byteLength:816,byteOffset:3280},{buffer:0,byteLength:544,byteOffset:4096},{buffer:0,byteLength:816,byteOffset:4640},{buffer:0,byteLength:816,byteOffset:5456},{buffer:0,byteLength:544,byteOffset:6272},{buffer:0,byteLength:816,byteOffset:6816},{buffer:0,byteLength:816,byteOffset:7632},{buffer:0,byteLength:544,byteOffset:8448},{buffer:0,byteLength:384,byteOffset:8992},{buffer:0,byteLength:384,byteOffset:9376},{buffer:0,byteLength:256,byteOffset:9760},{buffer:0,byteLength:180,byteOffset:10016},{buffer:0,byteLength:8940,byteOffset:10196},{buffer:0,byteLength:8940,byteOffset:19136},{buffer:0,byteLength:5960,byteOffset:28076},{buffer:0,byteLength:2106,byteOffset:34036},{buffer:0,byteLength:48,byteOffset:36144},{buffer:0,byteLength:48,byteOffset:36192},{buffer:0,byteLength:32,byteOffset:36240},{buffer:0,byteLength:12,byteOffset:36272},{buffer:0,byteLength:384,byteOffset:36284},{buffer:0,byteLength:384,byteOffset:36668},{buffer:0,byteLength:256,byteOffset:37052},{buffer:0,byteLength:8940,byteOffset:37308},{buffer:0,byteLength:8940,byteOffset:46248},{buffer:0,byteLength:5960,byteOffset:55188},{buffer:0,byteLength:192,byteOffset:61148},{buffer:0,byteLength:192,byteOffset:61340},{buffer:0,byteLength:128,byteOffset:61532},{buffer:0,byteLength:36,byteOffset:61660},{buffer:0,byteLength:192,byteOffset:61696},{buffer:0,byteLength:192,byteOffset:61888},{buffer:0,byteLength:128,byteOffset:62080},{buffer:0,byteLength:36,byteOffset:62208},{buffer:0,byteLength:288,byteOffset:62244},{buffer:0,byteLength:288,byteOffset:62532},{buffer:0,byteLength:192,byteOffset:62820},{buffer:0,byteLength:72,byteOffset:63012}],buffers:[{byteLength:63084,uri:"data:application/octet-stream;base64, "}]}};var UA="#include <gl2_vert>\n\nattribute vec3 aPosition;\n\nuniform mat4 projViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform float pointSize;\n\n//å¼•å…¥fbo pickingçš„vertç›¸å…³å‡½æ•°\n\n#include <fbo_picking_vert>\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    gl_Position = projViewMatrix * modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    //ä¼ å…¥gl_Positionçš„depthå€¼\n\n    fbo_picking_setData(gl_Position.w, true);\n\n}\n\n";const EA=[0,1e5,0],NA=[0,0,0],jA=[-1,-1,0,1,-1,0,-1,1,0,1,1,0],QA=[3,1,0,0,2,3],SA=[.1,.1,.1],kA=[],BA=[],RA=[],GA=[],YA=[],qA=[],VA=[],WA=[],_A=[0,-1,0],KA={lightAmbient:[1,1,1],lightDiffuse:[1,1,1],lightSpecular:[1,1,1],lightDirection:[1,1,1]},HA={4:[4,5],5:[4,5],7:[7,8],8:[7,8],9:[9,10,11],10:[9,10,11],11:[9,10,11]},JA=[6];class ZA{constructor(A,t,n,i,r){this.map=A,this.renderer=t,this.updateTRS(n,i,r),this.createPickHelper(),this.createHelperMeshes(),this.H(),this.registEvents(),this.mouseAction="moving",this.J=null,this.$=!0}registEvents(){const A=this.map;A.on("dom:mousemove",this.AA,this),A.on("dom:mousedown",this.tA,this),A.on("dom:mouseup",this.nA,this),A.on("zooming moving dragrotating",this.iA,this)}unregistEvents(){const A=this.map;A.off("dom:mousemove",this.AA,this),A.off("dom:mousedown",this.tA,this),A.off("dom:mouseup",this.nA,this),A.off("zooming moving dragrotating",this.iA,this)}AA(A){this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y};const t=this.getCntrollerMeshes();if(this.currentPickingObject=this.rA(this.currentMousePosition,t,"meshes"),"transform"===this.mouseAction){if("z-translate"===this.eA){const n=m(RA,t[9].localTransform);this.sA(!0,n,[this.uA[0]*Math.PI/180,this.uA[1]*Math.PI/180,this.uA[2]*Math.PI/180])}else if("y-rotate"===this.eA){const n=m(RA,t[4].localTransform);this.sA(!0,n,[90*Math.PI/180,0,-this.uA[2]])}else if("z-rotate"===this.eA){const n=m(RA,t[7].localTransform);this.sA(!0,n,[0,0,0])}}else this.sA(!1);this.oA(),this.hA(this.currentMousePosition)}oA(){this.fA(),this.currentPickingObject&&null!=this.currentPickingObject.meshId&&(this.lastPickingMeshId=this.currentPickingObject.pickingId,this.cA(this.currentPickingObject.pickingId,.6)),this.aA()}hA(A){if("transform"===this.mouseAction){const A=this.vA,t=this.rA(this.currentMousePosition,[A],"plane"),n=this.rA(this.lastMousePosition,[A],"plane");if(!t||null===t.meshId||!n||null===n.meshId)return;const i=[0,0,0];let r=0;if("z-translate"===this.eA){i[0]=t.point[0]-n.point[0],i[1]=t.point[1]-n.point[1],i[2]=t.point[2]-n.point[2];const A=this.lA(),r=B(i,A),e=function(A){var t=A[0],n=A[1],i=A[2];return Math.sqrt(t*t+n*n+i*i)}(i)*Math.cos(r),s=Math.sign(e)*Math.sqrt(Math.pow(e,2)/(Math.pow(A[0],2)+Math.pow(A[1],2)+Math.pow(A[2],2))),u=E(GA,A[0]*s,A[1]*s,A[2]*s);this.wA(u)}else"y-rotate"!==this.eA&&"z-rotate"!==this.eA||(r=this.PA(t.point,n.point,this.eA),this.gA(r,this.eA))}this.lastMousePosition=A,this.lastPickingObject=this.currentPickingObject,this.lastPickingMeshId=this.currentPickingObject.meshId}PA(A,t,n){const i=this.CA;let r,e;"y-rotate"===n?(r=K(VA,t[0]-i[0],t[2]-i[2]),e=K(WA,A[0]-i[0],A[2]-i[2])):"z-rotate"===n&&(r=K(VA,t[0]-i[0],t[1]-i[1]),e=K(WA,A[0]-i[0],A[1]-i[1]));const s=Math.atan2(r[1],r[0]);return(Math.atan2(e[1],e[0])-s)/Math.PI*180}wA(A){N(this.CA,this.CA,A),this.DA()}gA(A,t){"y-rotate"===t?this.uA[1]-=A:"z-rotate"===t&&(this.uA[2]+=A),this.DA()}DA(){const A=this.updateMatrix();b(A,A,SA);const t=this.getCntrollerMeshes();for(let n=0;n<t.length;n++){const i=t[n];let r=A;7!==n&&8!==n||(r=this.updateMatrixExcept(0),b(r,r,SA)),M(i.localTransform,r,i.nodeMatrix)}}aA(){this.renderer&&this.renderer.parentRenderer.setToRedraw()}tA(A){this.currentMousePosition={x:A.containerPoint.x,y:A.containerPoint.y};const t=this.getCntrollerMeshes();this.firstDownPoint=this.currentPickingObject=this.rA(this.currentMousePosition,t,"meshes"),this.currentPickingObject&&null!=this.currentPickingObject.meshId?(this.mouseAction="transform",this.IA(this.currentPickingObject.pickingId),this.map.config("zoomable",!1),this.map.config("draggable",!1),this.aA()):(this.mouseAction="pan",this.map.config("zoomable",!0),this.map.config("draggable",!0)),this.lastMousePosition=this.currentMousePosition,this.lastPickingObject=this.currentPickingObject,this.lastPickingMesh=t[this.currentPickingObject.meshId]}IA(A){HA[9].indexOf(A)>-1?this.eA="z-translate":HA[4].indexOf(A)>-1?this.eA="y-rotate":HA[7].indexOf(A)>-1&&(this.eA="z-rotate")}sA(A,t,n){const i=this.vA,r=t||i.originTranslation,e=function(A,t){var n=t[0],i=t[1],r=t[2],e=t[4],s=t[5],u=t[6],o=t[8],h=t[9],f=t[10];return A[0]=Math.sqrt(n*n+i*i+r*r),A[1]=Math.sqrt(e*e+s*s+u*u),A[2]=Math.sqrt(o*o+h*h+f*f),A}(BA,i.localTransform),s=W(kA,0,0,0);y(i.localTransform,s,r,e),A&&!this.MA()&&(x(i.localTransform,i.localTransform,n[2]),z(i.localTransform,i.localTransform,n[0]),d(i.localTransform,i.localTransform,n[1]))}MA(){if(this.map.getPitch())return!1;const A=this.map.cameraPosition,t=this.map.coordinateToPointAtRes(this.map.getCenter(),this.map.getGLRes());E(t,t.x,t.y,0);const n=this.bA.getCoordinates(),i=this.map.coordinateToPointAtRes(n,this.map.getGLRes()),r=this.bA.getTranslation(),e=E(RA,i.x,i.y,0),s=N(e,e,r);return B(j(GA,A,s),j(GA,A,t))<1/180*Math.PI}nA(){"transform"===this.mouseAction&&(this.firstDownPoint=null,this.$=!0),this.mouseAction="moving",this.eA=null,this.map.config("zoomable",!0),this.map.config("draggable",!0),this.aA()}iA(){this.$=!0}fA(){(function(A){return null==A})(this.lastPickingMeshId)||this.cA(this.lastPickingMeshId),this.map.resetCursor()}cA(A,t){const n=this.getCntrollerMeshes();if(JA.indexOf(A)<0){const i=HA[A];if(i)for(let A=0;A<i.length;A++){this.zA(n[i[A]],t)}else{this.zA(n[A],t)}}this.map.setCursor("pointer")}zA(A,t){const n=A.material.get("polygonFill");n[3]=t||A.originOpacity,A.material.set("polygonFill",n)}rA(A,t,n){const i=this.map;if(!(i&&this.G&&this.renderer&&this.renderer.canvas))return null;const r=i.getDevicePixelRatio(),e=A.x*r,s=A.y*r,u={projViewMatrix:this.map.projViewMatrix,pointSize:1};return!this.$&&this.dA&&this.dA===n||(this.G.render(t,u,!0),this.dA=n,this.$=!1),this.G.pick(e,s,10,u,{viewMatrix:this.map.viewMatrix,projMatrix:this.map.projMatrix,returnPoint:!0})}updateTRS(A,t,n){this.CA=U([],A),this.xA=U([],n),this.uA=U([],t)}updateMatrix(){const A=this.uA,t=this.CA,n=this.xA,i=G(kA);return V(i,i,A[2]*Math.PI/180),Y(i,i,A[0]*Math.PI/180),q(i,i,A[1]*Math.PI/180),y(YA,i,t,n)}updateMatrixExcept(){const A=U([],this.uA);A[0]=0;const t=this.CA,n=this.xA,i=G(kA);return V(i,i,A[2]*Math.PI/180),Y(i,i,A[0]*Math.PI/180),q(i,i,A[1]*Math.PI/180),y(qA,i,t,n)}lA(){const A=this.uA,t=I([]);return x(t,t,A[2]*Math.PI/180),z(t,t,A[0]*Math.PI/180),d(t,t,A[1]*Math.PI/180),k(GA,_A,t)}createPickHelper(){const t=new Q$7({POSITION:jA},QA,0,{primitive:"triangles",positionAttribute:"POSITION"}),n=t$1.Util.extend({},KA,{polygonFill:[0,0,0,.001]});this.vA=new Be$5(t,new Ie$5(n)),this.vA.setUniform("uPickingId",12);const i=I([]),r=W([],0,0,0);this.vA.originRotation=[0,0,0],y(i,r,this.CA,[3,3,3]),this.vA.originTranslation=this.CA,this.vA.localTransform=i,this.vA.transparent=!0,this.vA.setDefines({HAS_HELPERPARTS:1,HAS_PICKING_ID:2})}createHelperMeshes(){this.mA=this.yA("helper"),this.pA=[],this.pA.push(...this.mA),this.pA.push(this.vA)}getPickHelperMesh(){return this.vA}getCntrollerMeshes(){return this.mA}getAllMeshes(){return this.pA.length<12&&this.pA.push(...this.mA),this.pA}createProjViewMatrix(){const A=this.updateMatrix(),t=k([],NA,A),n=k([],EA,A),i=Math.sqrt(Math.pow(n[0]-t[0],2)+Math.pow(n[1]-t[1],2)+Math.pow(n[2]-t[2],2));return M([],function(A,t,n,i,r,e,s){var u=1/(t-n),o=1/(i-r),h=1/(1-s);return A[0]=-2*u,A[1]=0,A[2]=0,A[3]=0,A[4]=0,A[5]=-2*o,A[6]=0,A[7]=0,A[8]=0,A[9]=0,A[10]=2*h,A[11]=0,A[12]=(t+n)*u,A[13]=(r+i)*o,A[14]=(s+1)*h,A[15]=1,A}([],-this.xA[0],this.xA[1],-this.xA[0],this.xA[1],0,i),L([],n,t,[0,0,1]))}yA(t){const n=[],i=function(t){return Dt$6.loadGLTF("",FA[t]).then((A=>A))}(t),r=this.updateMatrix();return b(r,r,SA),i.then((t=>{Dt$6.exportGLTFPack(t).getMeshesInfo().forEach(((t,i)=>{const e=t.materialInfo||{};e.polygonFill=6===i?[1,1,1,.1]:[1,1,1,1],t$1.Util.extend(e,KA,e);const s=new Ie$5(e),u=new Be$5(t.geometry,s);u.setUniform("uPickingId",i);const o=u.getDefines();if(o.HAS_HELPERPARTS=1,o.HAS_PICKING_ID=2,u.setDefines(o),u.nodeMatrix=t.nodeMatrix,u.originTransform=function(A,t){return A[0]=t[0],A[1]=t[1],A[2]=t[2],A[3]=t[3],A[4]=t[4],A[5]=t[5],A[6]=t[6],A[7]=t[7],A[8]=t[8],A[9]=t[9],A[10]=t[10],A[11]=t[11],A[12]=t[12],A[13]=t[13],A[14]=t[14],A[15]=t[15],A}([],u.localTransform),7===i||8===i){const A=this.updateMatrixExcept(0);b(A,A,SA),M(u.localTransform,A,u.nodeMatrix)}else M(u.localTransform,r,u.nodeMatrix);u.originOpacity=6===i?.1:1,u.transparent=!0,n.push(u)}))})),n}H(){this.pickingFBO=this.renderer.regl.framebuffer(this.renderer.canvas.width,this.renderer.canvas.height),this.G=new Cr$4(this.renderer,{vert:UA,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(A,t){return M([],t.projViewMatrix,t.modelMatrix)}}]},this.pickingFBO,this.map)}LA(){this.unregistEvents(),this.dispose()}dispose(){this.getAllMeshes().forEach((A=>{A.geometry.dispose(),A.dispose()})),this.pickingFBO&&this.pickingFBO.destroy()}resize(A,t){this.pickingFBO.width===A&&this.pickingFBO.height===t||this.pickingFBO.resize(A,t)}}class XA extends vn$4{constructor(A={}){const t=[],n=[],i=A.uniforms,r=[{name:"modelNormalMatrix",type:"function",fn:function(A,n){return function(A,t){return A[0]=t[0],A[1]=t[1],A[2]=t[2],A[3]=t[4],A[4]=t[5],A[5]=t[6],A[6]=t[8],A[7]=t[9],A[8]=t[10],A}(t,n.modelMatrix)}},{name:"modelViewMatrix",type:"function",fn:function(A,t){return M(n,t.viewMatrix,t.modelMatrix)}}];i&&r.push(...i),super({vert:"#include <gl2_vert>\n\nattribute vec3 aPosition;\n\n#include <line_extrusion_vert>\n\n\n\n#ifdef HAS_MAP\n\n    uniform vec2 uvScale;\n\n    uniform vec2 uvOffset;\n\n    attribute vec2 aTexCoord;\n\n    varying vec2 vTexCoord;\n\n#endif\n\n#if defined(HAS_COLOR)\n\n    attribute vec4 aColor;\n\n    varying vec4 vColor;\n\n#elif defined(HAS_COLOR0)\n\n    attribute vec4 aColor0;\n\n    varying vec4 vColor;\n\n#endif\n\n\n\nvarying vec3 vFragPos;\n\nvarying vec3 vNormal;\n\n\n\nuniform mat4 projMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform mat3 modelNormalMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform vec2 halton;\n\nuniform vec2 outSize;\n\n\n\nuniform mat4 projViewMatrix;\n\n\n\n#include <get_output>\n\n#include <heatmap_render_vert>\n\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n\n    #include <vsm_shadow_vert>\n\n#endif\n\n\n\n#ifdef HAS_EXTRUSION_OPACITY\n\n    attribute float aExtrusionOpacity;\n\n    varying float vExtrusionOpacity;\n\n#endif\n\n\n\n#if defined(HAS_TANGENT)\n\n    varying vec4 vTangent;\n\n#endif\n\n\n\nuniform mat4 cut_projViewMatrixFromViewpoint;\n\nvarying vec4 cut_positionFromViewpoint;\n\n\n\n\n\nvoid toTangentFrame(const highp vec4 q, out highp vec3 n) {\n\n    n = vec3( 0.0,  0.0,  1.0) +\n\n        vec3( 2.0, -2.0, -2.0) * q.x * q.zwx +\n\n        vec3( 2.0,  2.0, -2.0) * q.y * q.wzy;\n\n}\n\n\n\n\n\nvoid toTangentFrame(const highp vec4 q, out highp vec3 n, out highp vec3 t) {\n\n    toTangentFrame(q, n);\n\n    t = vec3( 1.0,  0.0,  0.0) +\n\n        vec3(-2.0,  2.0, -2.0) * q.y * q.yxw +\n\n        vec3(-2.0,  2.0,  2.0) * q.z * q.zwx;\n\n}\n\n\n\n\n\nvoid main()\n\n{\n\n    #ifdef IS_LINE_EXTRUSION\n\n        vec4 localPosition = getPosition(getLineExtrudePosition(aPosition));\n\n    #else\n\n        vec4 localPosition = getPosition(aPosition);\n\n    #endif\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n\n\n    vFragPos = vec3(modelMatrix * localPositionMatrix * localPosition);\n\n\n\n    #if defined(HAS_NORMAL) || defined(HAS_TANGENT)\n\n        mat3 localNormalMatrix = modelNormalMatrix * mat3(localPositionMatrix);\n\n        vec3 Normal;\n\n        #if defined(HAS_TANGENT)\n\n            vec3 t;\n\n            toTangentFrame(aTangent, Normal, t);\n\n            vTangent = vec4(localNormalMatrix * t, aTangent.w);\n\n        #else\n\n            #ifdef HAS_DECODE_NORMAL\n\n                Normal = getNormal(aNormal);\n\n            #else\n\n                Normal = aNormal;\n\n            #endif\n\n        #endif\n\n        vec3 localNormal = appendMorphNormal(Normal);\n\n        vNormal = normalize(localNormalMatrix * localNormal);\n\n    #else\n\n        vNormal = vec3(0.0);\n\n    #endif\n\n\n\n    mat4 jitteredProjection = projMatrix;\n\n    jitteredProjection[2].xy += halton.xy / outSize.xy;\n\n    gl_Position = jitteredProjection * modelViewMatrix * localPositionMatrix * localPosition;\n\n    #ifdef HAS_MAP\n\n        vec2 TexCoord = decode_getTexcoord(aTexCoord);\n\n        vTexCoord = TexCoord * uvScale + uvOffset;\n\n    #endif\n\n    #ifdef HAS_EXTRUSION_OPACITY\n\n        vExtrusionOpacity = aExtrusionOpacity;\n\n    #endif\n\n    #if defined(HAS_COLOR)\n\n        vColor = aColor / 255.0;\n\n    #elif defined(HAS_COLOR0)\n\n        vColor = aColor0 / 255.0;\n\n    #endif\n\n    cut_positionFromViewpoint = cut_projViewMatrixFromViewpoint * modelMatrix * localPositionMatrix * localPosition;\n\n}\n\n",frag:"precision mediump float;\n\n#include <gl2_frag>\n\n\n\nuniform vec4 baseColorFactor;\n\nuniform float materialShininess;//åå…‰åº¦ï¼Œå³å½±å“é•œé¢é«˜å…‰çš„æ•£å°„/åŠå¾„\n\nuniform float opacity;\n\nuniform float environmentExposure;\n\nuniform float specularStrength;\n\n\n\nuniform vec3 light0_viewDirection;\n\nuniform vec3 ambientColor;\n\nuniform vec4 light0_diffuse;\n\nuniform vec3 lightSpecular;\n\nuniform vec3 cameraPosition;\n\n\n\n#ifdef HAS_TANGENT\n\n    varying vec4 vTangent;\n\n#endif\n\n\n\n#ifdef HAS_MAP\n\n    varying vec2 vTexCoord;\n\n#endif\n\nvarying vec3 vNormal;\n\nvarying vec3 vFragPos;\n\n\n\n#ifdef HAS_INSTANCE_COLOR\n\n    varying vec4 vInstanceColor;\n\n#endif\n\n\n\n#ifdef HAS_BASECOLOR_MAP\n\n    uniform sampler2D baseColorTexture;\n\n#endif\n\n\n\n#ifdef HAS_EXTRUSION_OPACITY\n\n    uniform vec2 extrusionOpacityRange;\n\n    varying float vExtrusionOpacity;\n\n#endif\n\n\n\n#if defined(HAS_COLOR) || defined(HAS_COLOR0)\n\n    varying vec4 vColor;\n\n#elif defined(IS_LINE_EXTRUSION)\n\n    uniform vec4 lineColor;\n\n#else\n\n    uniform vec4 polygonFill;\n\n#endif\n\n\n\n#ifdef IS_LINE_EXTRUSION\n\n    uniform float lineOpacity;\n\n#else\n\n    uniform float polygonOpacity;\n\n#endif\n\n\n\n#ifdef HAS_OCCLUSION_MAP\n\n    uniform sampler2D occlusionTexture;\n\n#endif\n\n\n\n#ifdef HAS_NORMAL_MAP\n\n    uniform sampler2D normalTexture;\n\n#endif\n\n\n\n#ifdef HAS_EMISSIVE_MAP\n\n    uniform sampler2D emissiveTexture;\n\n#endif\n\n\n\n#ifdef SHADING_MODEL_SPECULAR_GLOSSINESS\n\n    uniform vec4 diffuseFactor;\n\n    uniform vec3 specularFactor;\n\n    #ifdef HAS_DIFFUSE_MAP\n\n        uniform sampler2D diffuseTexture;\n\n    #endif\n\n    #ifdef HAS_SPECULARGLOSSINESS_MAP\n\n        uniform sampler2D specularGlossinessTexture;\n\n    #endif\n\n#endif\n\n#include <heatmap_render_frag>\n\n\n\n#if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n\n  #include <vsm_shadow_frag>\n\n#endif\n\nvarying vec4 cut_positionFromViewpoint;\n\n\n\nvec3 transformNormal() {\n\n    #if defined(HAS_NORMAL_MAP)\n\n        vec3 n = normalize(vNormal);\n\n        vec3 normal = texture2D(normalTexture, vTexCoord).xyz * 2.0 - 1.0;\n\n        #if defined(HAS_TANGENT)\n\n            vec3 t = normalize(vTangent.xyz);\n\n            vec3 b = normalize(cross(n, t) * sign(vTangent.w));\n\n            mat3 tbn = mat3(t, b, n);\n\n            return normalize(tbn * normal);\n\n        #else\n\n            return normalize(normal);\n\n        #endif\n\n    #else\n\n        return normalize(vNormal);\n\n    #endif\n\n}\n\n\n\nvec4 linearTosRGB(const in vec4 color) {\n\n    return vec4( color.r < 0.0031308 ? color.r * 12.92 : 1.055 * pow(color.r, 1.0/2.4) - 0.055, color.g < 0.0031308 ? color.g * 12.92 : 1.055 * pow(color.g, 1.0/2.4) - 0.055, color.b < 0.0031308 ? color.b * 12.92 : 1.055 * pow(color.b, 1.0/2.4) - 0.055, color.a);\n\n}\n\n\n\nvec4 getBaseColor() {\n\n    #if defined(HAS_BASECOLOR_MAP)\n\n        return texture2D(baseColorTexture, vTexCoord);\n\n    #elif defined(HAS_DIFFUSE_MAP)\n\n        return texture2D(diffuseTexture, vTexCoord);\n\n    #elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\n\n        return diffuseFactor;\n\n    #else\n\n        return baseColorFactor;\n\n    #endif\n\n}\n\n\n\nvec3 getSpecularColor() {\n\n    #if defined(HAS_SPECULARGLOSSINESS_MAP)\n\n        return texture2D(specularGlossinessTexture, vTexCoord).rgb;\n\n    #elif defined(SHADING_MODEL_SPECULAR_GLOSSINESS)\n\n        return specularFactor;\n\n    #else\n\n        return vec3(1.0);\n\n    #endif\n\n}\n\n\n\nvoid main() {\n\n    //çŽ¯å¢ƒå…‰\n\n    vec4 baseColor = getBaseColor();\n\n    vec3 ambient = environmentExposure * ambientColor * baseColor.rgb;\n\n\n\n    #ifdef HAS_INSTANCE_COLOR\n\n        ambient *= vInstanceColor.rgb;\n\n    #endif\n\n\n\n    //æ¼«åå°„å…‰\n\n    vec3 norm = transformNormal();\n\n    vec3 lightDir = normalize(-light0_viewDirection);\n\n    float diff = max(dot(norm, lightDir), 0.0);\n\n    vec3 diffuse = light0_diffuse.rgb * diff * baseColor.rgb;\n\n    #if defined(HAS_COLOR) || defined(HAS_COLOR0)\n\n        vec3 color = vColor.rgb;\n\n    #elif defined(IS_LINE_EXTRUSION)\n\n        vec3 color = lineColor.rgb;\n\n    #else\n\n        vec3 color = polygonFill.rgb;\n\n    #endif\n\n    #ifdef HAS_INSTANCE_COLOR\n\n        color *= vInstanceColor.rgb;\n\n    #endif\n\n    ambient *= color.rgb;\n\n    diffuse *= color.rgb;\n\n\n\n    //é•œé¢åè‰²å…‰\n\n    vec3 viewDir = normalize(cameraPosition - vFragPos);\n\n    vec3 halfwayDir = normalize(lightDir + viewDir);\n\n    float spec = pow(max(dot(norm, halfwayDir), 0.0), materialShininess);\n\n    vec3 specular = specularStrength * lightSpecular * spec * getSpecularColor();\n\n    #ifdef HAS_OCCLUSION_MAP\n\n        float ao = texture2D(occlusionTexture, vTexCoord).r;\n\n        ambient *= ao;\n\n    #endif\n\n    #if defined(HAS_SHADOWING) && !defined(HAS_BLOOM)\n\n        float shadowCoeff = shadow_computeShadow();\n\n        diffuse = shadow_blend(diffuse, shadowCoeff).rgb;\n\n        specular = shadow_blend(specular, shadowCoeff).rgb;\n\n    #endif\n\n    vec3 result = ambient + diffuse + specular;\n\n\n\n    #ifdef HAS_EMISSIVE_MAP\n\n        vec3 emit = texture2D(emissiveTexture, vTexCoord).rgb;\n\n        result += emit;\n\n    #endif\n\n    vec3 shadowCoord = (cut_positionFromViewpoint.xyz / cut_positionFromViewpoint.w)/2.0 + 0.5;\n\n    if (shadowCoord.x > 0.0 && shadowCoord.x < 1.0 && shadowCoord.y > 0.0 && shadowCoord.y < 1.0 && shadowCoord.z < 1.0) {\n\n        discard;\n\n    }\n\n    glFragColor = vec4(result, opacity);\n\n    // glFragColor = linearTosRGB(glFragColor);\n\n    #if defined(HAS_COLOR) || defined(HAS_COLOR0)\n\n        float colorAlpha = vColor.a;\n\n    #elif defined(IS_LINE_EXTRUSION)\n\n        float colorAlpha = lineColor.a;\n\n    #else\n\n        float colorAlpha = polygonFill.a;\n\n    #endif\n\n        glFragColor *= colorAlpha;\n\n    #ifdef HAS_EXTRUSION_OPACITY\n\n        float topAlpha = extrusionOpacityRange.x;\n\n        float bottomAlpha = extrusionOpacityRange.y;\n\n        float alpha = topAlpha + vExtrusionOpacity * (bottomAlpha - topAlpha);\n\n        alpha = clamp(alpha, 0.0, 1.0);\n\n        glFragColor *= alpha;\n\n    #endif\n\n\n\n    #if __VERSION__ == 100\n\n        gl_FragColor = glFragColor;\n\n    #endif\n\n}\n\n",uniforms:r,defines:A.defines||{},extraCommandProps:A.extraCommandProps||{}}),this.version=300}}const $A=[0,0,0,1],At={lightAmbient:[1,1,1],lightDiffuse:[1,1,1],lightSpecular:[1,1,1],lightDirection:[1,1,1]};class tt extends H{h(){this.TA=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.OA=new vn$4({vert:TA,frag:OA,uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,t)=>M([],t.projViewMatrix,t.modelMatrix)}],extraCommandProps:{viewport:this.u}}),this.FA=new vn$4({vert:TA,frag:OA,uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,t)=>M([],t.projViewMatrix,t.modelMatrix)}],extraCommandProps:{viewport:this.u,depth:{enable:!0,func:"always",mask:!1,range:[0,0]}}}),this.UA=new XA({extraCommandProps:{viewport:this.u,blend:{enable:(A,t)=>!!t.meshConfig.transparent,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}}),this.EA=new XA({extraCommandProps:{viewport:this.u,blend:{enable:(A,t)=>!!t.meshConfig.transparent,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"always",mask:!1,range:[0,0]}}}),this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.NA=new Ke$5,this.jA=new Ke$5,this.F=new Ke$5}QA(A,t,n,i){this.controller=new ZA(A,this.renderer,t,n,i)}SA(A,t,n){this.controller&&(this.controller.updateTRS(A,t,n),this.controller.DA(),this.controller.aA())}render(A,t){this.U(),this.renderer.clear({color:$A,depth:1,framebuffer:this.T});const n=this.kA(A),i=this.controller.getAllMeshes(),r=this.controller.createProjViewMatrix();return this.BA(n,i,r,t.map),this.RA(n,i,r,t.map),{meshesMap:this.TA,invisibleMap:this.T}}kA(t){const n=[];for(let i=0;i<t.length;i++){const r=t$1.Util.extend({},t[i].material.uniforms,At),e=new Ie$5(r),s=new Be$5(t[i].geometry,e),u=s.getDefines();u.HAS_CUT=1,s.setDefines(u),s.localTransform=t[i].localTransform,n.push(s)}return n}RA(A,t,n,i){this.renderer.clear({color:[0,0,0,0],depth:1,framebuffer:this.T});const r={cut_projViewMatrixFromViewpoint:n,projViewMatrix:i.projViewMatrix};this.F.setMeshes(A),this.renderer.render(this.OA,r,this.F,this.T),this.F.setMeshes(t),this.renderer.render(this.FA,r,this.F,this.T)}BA(t,n,i,r){this.renderer.clear({color:[0,0,0,0],depth:1,framebuffer:this.TA});const e=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,s=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height,u={projMatrix:r.projMatrix,cut_projViewMatrixFromViewpoint:i,projViewMatrix:r.projViewMatrix,viewMatrix:r.viewMatrix,cameraPosition:r.cameraPosition,altitudeScale:1,outSize:[e,s],halton:[.2107,-.0202],polygonFill:[1,1,1,1],polygonOpacity:1};!function(t,n,i,r){const{iblTexes:e,dfgLUT:s}=fi$4.PBRUtils.getIBLResOnCanvas(n);if(i&&i.getLights()){const n=fi$4.PBRUtils.getPBRUniforms(i,e,s,r,r),u=i.getLights();t.ambientColor=u.ambient&&u.ambient.color?u.ambient.color:[1,1,1],n&&t$1.Util.extend(t,n)}else{const n=fi$4.PBRUtils.getPBRUniforms(i,null,s,r,r);t$1.Util.extend(t,n)}}(u,this.renderer.canvas,r),this.NA.setMeshes(t),this.renderer.render(this.UA,u,this.NA,this.TA),this.jA.setMeshes(n),this.renderer.render(this.EA,u,this.jA,this.TA)}dispose(){this.T&&this.T.destroy(),this.C&&this.C.dispose(),this.GA&&this.GA.dispose(),this.controller&&this.controller.LA()}U(){const A=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,t=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;!this.T||this.T.width===A&&this.T.height===t||this.T.resize(A,t),!this.TA||this.TA.width===A&&this.TA.height===t||this.TA.resize(A,t),this.controller&&this.controller.resize(A,t)}}const it=[0,0,0,1,1,-1,1,-1,-1,1,-1,1,1,1,1,1,0,0],rt=[0,1,0,2,0,3,0,4,1,2,2,3,3,4,4,1,0,5],et=[],st=G([]),ut=G([]),ot=[],ht=[1,0,0],ft=[],ct=[],at=[],vt=new t$1.Point(0,0),lt=[0,0,0,1];let wt=.01;class Pt extends H{h(){super.h(),this.qA=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 projViewModelMatrix;\n\nuniform mat4 viewshed_projViewMatrixFromViewpoint;\n\nvarying vec4 viewshed_positionFromViewpoint;\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 localPosition = localPositionMatrix * getPosition(aPosition);\n\n    viewshed_positionFromViewpoint = viewshed_projViewMatrixFromViewpoint * modelMatrix * localPosition;\n\n    gl_PointSize = 1.0;\n\n    gl_Position = projViewModelMatrix * localPosition;\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\nvarying vec4 viewshed_positionFromViewpoint;\n\nuniform sampler2D depthMap;\n\nuniform float near;\n\nuniform float far;\n\n#ifdef HAS_HELPERLINE\n\n  uniform vec3 lineColor;\n\n#endif\n\n\n\nconst float UnpackDownscale = 255. / 256.;\n\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\n\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1.);\n\nfloat unpackRGBAToDepth(const in vec4 v) {\n\n    return dot(v, UnpackFactors);\n\n}\n\n\n\nfloat linear(float value) {\n\n    float z = value * 2.0 - 1.0;\n\n    return (2.0 * near * far) / (far + near - z * (far - near));\n\n}\n\n\n\nvoid main() {\n\n    #ifdef HAS_HELPERLINE\n\n        gl_FragColor = vec4(lineColor, 0.009);\n\n    #else\n\n        vec3 shadowCoord = (viewshed_positionFromViewpoint.xyz / viewshed_positionFromViewpoint.w)/2.0 + 0.5;\n\n        vec4 rgbaDepth = texture2D(depthMap, shadowCoord.xy);\n\n        float depth = unpackRGBAToDepth(rgbaDepth);\n\n        float linearZ = linear(shadowCoord.z);\n\n        float linearDepth = linear(depth);\n\n        if (shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 && linearZ >= near && linearZ <= far - near) {\n\n            if (linearZ / far <= linearDepth / (far - near)) {\n\n                gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);//å¯è§†åŒº\n\n            } else {\n\n                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);//ä¸å¯è§†åŒº\n\n            }\n\n        } else {\n\n            gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);\n\n        }\n\n    #endif\n\n}\n\n\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,t)=>M([],t.projViewMatrix,t.modelMatrix)}],extraCommandProps:{viewport:this.u}}),this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0});const t=new Q$7({POSITION:it},rt,0,{primitive:"lines",positionAttribute:"POSITION"});this.VA=new Be$5(t,new Ce$5({lineColor:[.8,.8,.1]}));const n=this.VA.getDefines();n.HAS_HELPERLINE=1,this.VA.setDefines(n),this.F=new Ke$5}render(A,t){const{eyePos:n,lookPoint:i,horizontalAngle:r,verticalAngle:e}=t;if(!this.m(r,e)||!n||!i)return this.T;this.C||this.D(r,e),this.U(r,e),this.renderer.clear({color:lt,depth:1,framebuffer:this.T}),this.VA.localTransform=this.WA(n,i,r,e),A.push(this.VA),this.F.setMeshes(A);const{projViewMatrixFromViewpoint:s,far:u}=this._A(n,i,e,r);return this.g(this.F,s,u),this.KA(this.F,s,t.projViewMatrix,u),this.T}WA(A,t,n,i){const r=Math.sqrt(Math.pow(A[0]-t[0],2)+Math.pow(A[1]-t[1],2)+Math.pow(A[2]-t[2],2));r<=0&&console.warn("both lookpoint and eyePos are in the same position");const e=I(et),s=E(ot,t[0]-A[0],t[1]-A[1],t[2]-A[2]),u=n*Math.PI/360,o=i*Math.PI/360;let h=B(ht,E(ft,s[0],s[1],0));h=s[1]>=0?h:2*Math.PI-h;const f=V(st,ut,h);let c=B(E(ct,s[0],s[1],0),s);return c=s[0]>=0?-c:2*Math.PI-c,q(f,f,c),y(e,f,A,[r,r*Math.tan(u),r*Math.tan(o)]),e}HA(A){const t=this.VA.localTransform,n=[],i=A.getGLRes();for(let r=1;r<(it.length-3)/3;r++){at[0]=it[3*r],at[1]=it[3*r+1],at[2]=it[3*r+2];const e=k([],at,t);vt.set(e[0],e[1]);const s=A.pointAtResToCoord(vt,i),u=A.pointAtResToAltitude(e[2],i);s.z=u,n.push(s)}return n}KA(A,t,n,i){this.renderer.render(this.qA,{viewshed_projViewMatrixFromViewpoint:t,projViewMatrix:n,near:wt,far:i,depthMap:this.l,minAltitude:0},A,this.T)}_A(A,t,n,i){const r=n/i,e=Math.sqrt(Math.pow(A[0]-t[0],2)+Math.pow(A[1]-t[1],2)+Math.pow(A[2]-t[2],2));return wt=e/100,{projViewMatrixFromViewpoint:M([],p([],i*Math.PI/180,r,wt,e),L([],A,t,[0,1,0])),far:e}}dispose(){super.dispose(),this.T&&this.T.destroy(),this.qA&&this.qA.dispose(),this.VA&&(this.VA.geometry.dispose(),this.VA.dispose())}U(A,t){const n=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,i=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;if(!this.T||this.T.width===n&&this.T.height===i||this.T.resize(n,i),this.l&&this.l.width/this.l.height!=A/t){const n=this.I(A,t);n&&this.l.resize(n.width,n.height)}}}class Ct extends H{render(A,{projViewMatrix:t,lineColor:n,lineWidth:i}){return A&&A.length?(this.JA(),this.U(),this.F.setMeshes(A),this.ZA(this.F,t),this.XA(n,i,this.T),this.T):null}h(){this.fboExtent=this.$A();const t=this.u;this.extentShader=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\n#include <get_output>  \n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    gl_Position = projViewMatrix * modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n}",frag:"precision highp float;\n\nvoid main() {\n\n    gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0);\n\n}",extraCommandProps:{viewport:t,cull:{enable:!1}}}),this.outlineShader=new Mn$4({vert:"#if __VERSION__ == 300\n\n\t#define attribute in\n\n\t#define varying out\n\n#endif\n\n\n\nattribute vec2 aPosition;\n\nattribute vec2 aTexCoord;\n\n\n\nvarying vec2 vTexCoord;\n\n\n\nvoid main()\n\n{\n\n  gl_Position = vec4(aPosition, 0., 1.);\n\n  vTexCoord = aTexCoord;\n\n}\n\n",frag:"precision highp float;\n\nprecision highp int;\n\n\n\nvarying vec2 vTexCoord;\n\nuniform sampler2D maskTexture;\n\nuniform vec2 texSize;\n\nuniform vec3 visibleEdgeColor;\n\nuniform float lineWidth;\n\nvoid main() {\n\n    vec2 invSize = (1.0 / texSize) * lineWidth;\n\n    vec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize.x, invSize.y, invSize.x, invSize.y);\n\n    vec4 c1 = texture2D(maskTexture, vTexCoord + uvOffset.xy);\n\n    vec4 c2 = texture2D(maskTexture, vTexCoord - uvOffset.xy);\n\n    vec4 c3 = texture2D(maskTexture, vTexCoord + uvOffset.yw);\n\n    vec4 c4 = texture2D(maskTexture, vTexCoord - uvOffset.yw);\n\n    float diff1 = (c1.r - c2.r)*0.7;\n\n    float diff2 = (c3.r - c4.r)*0.7;\n\n    float d = length(vec2(diff1, diff2) );\n\n    float a1 = min(c1.g, c2.g);\n\n    float a2 = min(c3.g, c4.g);\n\n    float visibilityFactor = min(a1, a2);\n\n    gl_FragColor = 1.0 - visibilityFactor > 0.001 ? vec4(visibleEdgeColor, 1.0) * vec4(d) : vec4(0.0);\n\n}",extraCommandProps:{viewport:t,depth:{enable:!0,mask:!1,func:"always"},blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"}}}),this.T=this.regl.framebuffer({color:this.regl.texture({width:t.width(),height:t.height(),wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.F=new Ke$5}ZA(A,t){this.renderer.render(this.extentShader,{projViewMatrix:t,minAltitude:0},A,this.fboExtent)}XA(A,t,n){this.renderer.render(this.outlineShader,{texSize:[n.width,n.height],visibleEdgeColor:A||[1,0,0],maskTexture:this.fboExtent,lineWidth:t||1,minAltitude:0},null,n)}$A(){return this.regl.framebuffer({color:this.regl.texture({width:2,height:2,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0})}getRenderMeshes(){return this.F.getMeshes()}JA(){this.regl.clear({color:[1,1,1,1],depth:1,framebuffer:this.fboExtent})}dispose(){this.fboExtent&&(this.fboExtent.destroy(),this.extentShader.dispose(),this.outlineShader.dispose(),delete this.fboExtent),this.T&&(this.T.destroy(),delete this.T)}U(){const A=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,t=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;this.T.width===A&&this.fboExtent.height===t||this.T.resize(A,t),this.fboExtent.width===A&&this.fboExtent.height===t||this.fboExtent.resize(A,t)}}const Dt="undefined"==typeof document?null:document.createElement("canvas");class Mt extends H{h(){this.O=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\n#include <get_output>\n\nvarying float flood_height;\n\nvarying vec4 vWorldPosition;\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 worldPosition = modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    vWorldPosition = worldPosition;\n\n    gl_Position = projViewMatrix * worldPosition;\n\n    flood_height = worldPosition.z;\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\nuniform vec4 extent;\n\nuniform float waterHeight;\n\nuniform sampler2D extentMap;\n\nuniform float hasExtent;\n\nuniform float type;\n\nvarying float flood_height;\n\nvarying vec4 vWorldPosition;\n\nvoid main() {\n\n    float width = extent.z - extent.x;\n\n    float height = extent.y - extent.w;\n\n    vec2 uvInExtent = vec2((vWorldPosition.x - extent.x) / width, 1.0 - (vWorldPosition.y - extent.w) / height);\n\n    vec4 extentColor = texture2D(extentMap, uvInExtent);\n\n    bool compare = type == 1.0 ? flood_height < waterHeight : flood_height >= waterHeight;\n\n    if (compare) {\n\n        if (hasExtent == 1.0) {\n\n            if (extentColor.r > 0.0) {\n\n                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n            } else {\n\n                gl_FragColor = vec4(0.0);\n\n            }\n\n        } else {\n\n            gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n        }\n\n    } else {\n\n        gl_FragColor = vec4(0.0);\n\n    }\n\n}\n\n",extraCommandProps:{viewport:this.u}}),this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0})}render(t,n){this.U(),this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.T});const i=new Ke$5(t);return this.it(i,n),this.T}it(A,t){this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.T}),this.renderer.render(this.O,t,A,this.T)}dispose(){this.T&&this.T.destroy(),this.O&&this.O.dispose()}U(){const A=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,t=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;!this.T||this.T.width===A&&this.T.height===t||this.T.resize(A,t)}}const bt=[.1451,.2588,.4863],zt=[0,0,0,0];class dt extends LA{constructor(A){super(A),this.type="floodAnalysis"}YA(A){const t=this.layer.getMap();if(this.q={},this.q.waterHeight=X(t,this.options.waterHeight),this.q.waterOpacity=this.options.waterOpacity,this.q.waterColor=this.options.waterColor,this.q.extent=zt,this.q.extentMap=A.regl.texture({width:2,height:2}),this.q.hasExtent=0,this.q.type=1,this.options.boundary){const{extentMap:A,extentInWorld:t}=this.V(this.options.boundary);this.q.extent=t,this.q.extentMap=A,this.q.hasExtent=1}this.q.projViewMatrix=t.projViewMatrix,this.q.minAltitude=0}S(t){const n=this.u={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.YA(t);const i=new B$6(t.regl);this.k=this.k||new Mt(i,n),this.layer.addAnalysis(this)}update(A,t){if("boundary"===A){const{extentMap:A,extentInWorld:n,extentPolygon:i}=this.V(t);this.q.extent=n,this.q.extentPolygon=i,this.q.extentMap=A}else if("waterHeight"===A){const A=this.layer.getMap();this.q.waterHeight=A.altitudeToPoint(t||0,A.getGLRes())}else this.q[A]=t;super.update(A,t)}renderAnalysis(A){const t={};return this.options.boundary&&this.B.render(this.R,this._),t.flood_waterColor=this.q.waterColor||bt,t.flood_waterOpacity=this.q.waterOpacity||.6,t.floodMap=this.k.render(A,this.q),t}getDefines(){return{HAS_FLOODANALYSE:1}}}const xt=[0,0,0,1,0,0],mt=[0,1],yt=[],pt=[0,0,0,1];class Lt extends H{h(){super.h(),this.rt=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 projViewModelMatrix;\n\nuniform mat4 insight_projViewMatrixFromViewpoint;\n\nvarying vec4 insight_positionFromViewpoint;\n\n#include <get_output>\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 localPosition = localPositionMatrix * getPosition(aPosition);\n\n    gl_Position = projViewModelMatrix * localPosition;\n\n    insight_positionFromViewpoint = insight_projViewMatrixFromViewpoint * modelMatrix * localPosition;\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\nvarying vec4 insight_positionFromViewpoint;\n\nuniform sampler2D depthMap;\n\n\n\nconst float UnpackDownscale = 255. / 256.;\n\nconst vec3 PackFactors = vec3(256. * 256. * 256., 256. * 256., 256.);\n\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1.);\n\nfloat unpackRGBAToDepth(const in vec4 v) {\n\n    return dot(v, UnpackFactors);\n\n}\n\n\n\nvoid main() {\n\n    vec3 shadowCoord = (insight_positionFromViewpoint.xyz / insight_positionFromViewpoint.w)/2.0 + 0.5;\n\n    vec4 rgbaDepth = texture2D(depthMap, shadowCoord.xy);\n\n    float depth = unpackRGBAToDepth(rgbaDepth); // Retrieve the z-value from R\n\n    if (shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0 && shadowCoord.z <= 1.0) {\n\n        if (depth <0.001) {\n\n            gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);//å¯è§†åŒº,green\n\n        } else {\n\n            if (shadowCoord.z <= depth + 0.002) {\n\n                gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);//å¯è§†åŒº,green\n\n            } else {\n\n                gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);//ä¸å¯è§†åŒº,red\n\n            }\n\n        }\n\n    } else {\n\n        gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0);//éžè§†é‡ŽèŒƒå›´,blue\n\n    }\n\n}\n\n\n\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(A,t)=>M([],t.projViewMatrix,t.modelMatrix)}],extraCommandProps:{viewport:this.u}}),this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0});const t=new Q$7({POSITION:xt},mt,0,{primitive:"lines",positionAttribute:"POSITION"});this.et=t,this.VA=new Be$5(t,new Ce$5({lineColor:[.8,.8,.1]})),this.F=new Ke$5}render(A,t){const{lines:n,horizontalAngle:i,verticalAngle:r}=t;this.C||this.D(i,r),this.U(i,r),this.renderer.clear({color:pt,depth:1,framebuffer:this.T});const e=I(yt);this.VA.localTransform=e;for(let e=0;e<n.length;e++){const{from:s,to:u}=n[e];if(!this.m(i,r)||!s||!u)continue;const{projViewMatrixFromViewpoint:o,far:h}=this._A(s,u,i,r);this.F.setMeshes(A),this.g(this.F,o,h),this.st(s,u),this.F.setMeshes(this.VA),this.ut(this.F,o,t.projViewMatrix)}return this.T}st(t,n){this.et&&(this.et.dispose(),this.VA.dispose(),xt[0]=t[0],xt[1]=t[1],xt[2]=t[2],xt[3]=n[0],xt[4]=n[1],xt[5]=n[2],this.et=new Q$7({POSITION:xt},mt,0,{primitive:"lines",positionAttribute:"POSITION"}),this.VA=new Be$5(this.et,new Ce$5({lineColor:[.8,.8,.1]})))}ut(A,t,n){this.renderer.render(this.rt,{insight_projViewMatrixFromViewpoint:t,projViewMatrix:n,depthMap:this.l},A,this.T)}_A(A,t,n,i){const r=n/i,e=Math.sqrt(Math.pow(A[0]-t[0],2)+Math.pow(A[1]-t[1],2)+Math.pow(A[2]-t[2],2));return{projViewMatrixFromViewpoint:M([],p([],i*Math.PI/180,r,1,e+1e3),L([],A,t,[0,1,0])),far:e}}dispose(){super.dispose(),this.T&&this.T.destroy(),this.rt&&this.rt.dispose(),this.VA&&(this.VA.geometry.dispose(),this.VA.dispose())}U(A,t){const n=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():t$1.Util.isFunction(this.u.width)?this.u.width():this.u.width,i=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():t$1.Util.isFunction(this.u.height)?this.u.height():this.u.height;if(!this.T||this.T.width===n&&this.T.height===i||this.T.resize(n,i),this.l&&this.l.width/this.l.height!=A/t){const n=this.I(A,t);n&&this.l.resize(n.width,n.height)}}}const Tt=[1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,1,-1,-1,1,-1,-1,1,1,-1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,-1,-1,-1,-1,1,-1,1,1,-1],Ot=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],Ft=[],Ut=[],Et=[],Nt=[],jt=[],Qt=[],St=[],kt=[],Bt=new t$1.Point(0,0),Rt=[],Gt=[],Yt=[];class qt{constructor(A,t,n={}){this.setFromPoint(A),this.setToPoint(t),this.ot=n,this.ht={},this.ft=0}setFromPoint(A){this.ct=this.vt(A),this.wt()}setToPoint(A){this.Pt=this.vt(A),this.wt()}setOptions(A){this.ot=A}wt(){this.ht={},this.ft++}test(A,t){const n=[];for(let i=0;i<A.length;i++){const r=A[i],e=r.uuid+"-"+r.version+"-"+r.geometry.version+"-"+this.ft;if(this.ht[e]){n.push(this.ht[e]);continue}if(!this.Ct(r.getBoundingBox(),t))continue;const s=r.localTransform,u=r.geometry,o=u.data[u.desc.positionAttribute].array,h=u.data[u.desc.altitudeAttribute]&&u.data[u.desc.altitudeAttribute].array||Rt,f=u.indices;if(!o||!f){console.warn("there are no POSITION or inidces in mesh");continue}const c=this.Dt(t,o,h,f,u.desc.positionSize,s);if(c){const A={mesh:r,coordinates:c};n.push(A),this.ht[e]=A}}return n}Dt(A,t,n,i,s,u){const o=AA(A,this.ct.x,this.ct.y,this.ct.z),h=AA(A,this.Pt.x,this.Pt.y,this.Pt.z),f=set(Et,o,h),c=[];for(let r=0;r<i.length;r+=3){const o=i[r],h=i[r+1],a=i[r+2],v=this.It(Qt,A,t.slice(o*s,o*s+s),n[o]/100,u),w=this.It(St,A,t.slice(h*s,h*s+s),n[h]/100,u),P=this.It(kt,A,t.slice(a*s,a*s+s),n[a]/100,u),g=set$4(Ut,v,w,P),C=sub$2(Gt,v,w),D=sub$2(Yt,v,P),I=this.Mt(g,f);if(I){if(!I[0]||!I[1])continue;const t=A.pointAtResToAltitude(I[2],A.getGLRes());Bt.x=I[0],Bt.y=I[1];const n=A.pointAtResToCoordinate(Bt,A.getGLRes()),i=new t$1.Coordinate(n.x,n.y,t);c.push({coordinate:i,indices:[o,h,a],normal:cross$1([],C,D)})}}return c.length?c:null}It(A,t,n,i,r){let e;return t$1.Util.isNumber(i)?(e=t.altitudeToPoint(i,t.getGLRes()),set$3(A,n[0],n[1],0,1),transformMat4$1(A,A,r),A[2]=e):(e=n[2],set$3(A,n[0],n[1],e,1),transformMat4$1(A,A,r)),A}Mt(A,t){const n=A[0],i=A[1],r=A[2],s=t[0],u=t[1],o=s[0],h=s[1],f=s[2],c=u[0]-s[0],a=u[1]-s[1],v=u[2]-s[2];let l=0,w=0,P=0;n[0]===i[0]&&n[0]===r[0]?l=1:n[1]===i[1]&&n[1]===r[1]?w=1:n[2]===i[2]&&n[2]===r[2]?P=1:(l=(A[2][1]-A[0][1])*(A[2][2]-A[0][2])-(A[1][2]-A[0][2])*(A[2][1]-A[0][1]),w=(A[2][0]-A[0][0])*(A[1][2]-A[0][2])-(A[1][0]-A[0][0])*(A[2][2]-A[0][2]),P=(A[1][0]-A[0][0])*(A[2][1]-A[0][1])-(A[2][0]-A[0][0])*(A[1][1]-A[0][1]));const C=l*c+w*a+P*v;if(0===C)return null;const D=-(l*o+w*h+P*f+-(l*A[0][0]+w*A[0][1]+P*A[0][2]))/C,I=c*D+o,M=a*D+h,b=v*D+f,z=set$4(Nt,I,M,b);return this.bt(A,z)&&(this.ot.allowPointNotOnLine||this.zt(t,z))?[I,M,b]:null}bt(A,t){const n=this.ot.tolerance||1,i=A[0],r=A[1],e=A[2],s=t,u=this.dt(i,r,e),o=this.dt(s,i,r),h=this.dt(s,i,e),f=this.dt(s,r,e);return!(Math.abs(o+h+f-u)>n/1e3)}zt(A,t){const n=this.ot.tolerance||1,i=A[0],r=A[1],s=t,u=length$4(sub$2(jt,i,r)),o=length$4(sub$2(jt,i,s)),h=length$4(sub$2(jt,r,s));return!(Math.abs(o+h-u)>n/1e5)}dt(A,t,n){const s=cross$1([],[t[0]-A[0],t[1]-A[1],t[2]-A[2]],[n[0]-A[0],n[1]-A[1],n[2]-A[2]]);return.5*Math.sqrt(s[0]*s[0]+s[1]*s[1]+s[2]*s[2])}vt(A){return A instanceof t$1.Coordinate?A:Array.isArray(A)?new t$1.Coordinate(A):null}Ct(A,t){const n=[AA(t,this.ct.x,this.ct.y,this.ct.z),AA(t,this.Pt.x,this.Pt.y,this.Pt.z)],i=A[0],r=A[1];for(let A=0;A<Tt.length;A+=3)for(let t=0;t<3;t++){const n=3*A+t;Ft[n]=Tt[n]>0?r[t]:i[t]}for(let A=0;A<Ot.length;A+=3){const t=Ot[A],i=Ot[A+1],r=Ot[A+2],e=[Ft.slice(3*t,3*t+3),Ft.slice(3*i,3*i+3),Ft.slice(3*r,3*r+3)];if(this.Mt(e,n))return!0}return!1}}const Wt=[0,0,0,1],_t=[],Kt=[];class Ht extends H{h(){this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0}),this.O=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 projViewModelMatrix;\n\nuniform mat4 modelViewMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\n#include <get_output>\n\nvarying vec4 vPosition;\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 worldPosition = modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    vPosition = worldPosition;\n\n    gl_Position = projViewModelMatrix * localPositionMatrix * getPosition(aPosition);\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\n#include <gl2_frag>\n\n\n\nvarying vec4 vPosition;\n\n\n\nconst vec2 range = vec2(-100.0, 1000.0);\n\nvec4 encodeHeight(const in float height) {\n\n    float alpha = 1.0;\n\n    vec4 pack = vec4(0.0);\n\n    pack.a = alpha;\n\n    const vec3 code = vec3(1.0, 255.0, 65025.0);\n\n    pack.rgb = vec3(code * height);\n\n    pack.gb = fract(pack.gb);\n\n    pack.rg -= pack.gb * (1.0 / 256.0);\n\n    pack.b -= mod(pack.b, 4.0 / 255.0);\n\n    return pack;\n\n}\n\n\n\nvoid main() {\n\n    float height = (vPosition.z - range.x) / (range.y - range.x);\n\n    glFragColor = encodeHeight(height);\n\n    #if __VERSION__ == 100\n\n        gl_FragColor = glFragColor;\n\n    #endif\n\n}\n\n",uniforms:[{name:"modelViewMatrix",type:"function",fn:(A,n)=>multiply$5(_t,n.viewMatrix,n.modelMatrix)},{name:"projViewModelMatrix",type:"function",fn:(A,n)=>multiply$5(Kt,n.projViewMatrix,n.modelMatrix)}],extraCommandProps:{viewport:this.u,cull:{enable:!0},frontFace:"ccw"}}),this.F=new Ke$5}render(A,t){this.U(),this.renderer.clear({color:Wt,depth:1,framebuffer:this.T}),this.F.setMeshes(A);return this.renderer.render(this.O,{projViewMatrix:t},this.F,this.T),this.T}U(){const A=t__namespace.Util.isFunction(this.u.width)?this.u.width():this.u.width,t=t__namespace.Util.isFunction(this.u.height)?this.u.height():this.u.height;!this.T||this.T.width===A&&this.T.height===t||this.T.resize(A,t)}dispose(){this.T&&(this.T.destroy(),delete this.T),this.O&&(this.O.dispose(),delete this.O)}}const Jt=$n$2.getRendererClass("gl");class Zt extends $n$2{excavate(A){this.N=!0,this.Ft=Array.isArray(A)?A:[A];const t=this.getRenderer();t&&(t.Ut(),t.setToRedraw())}getExcavatedLayers(){return this.Ft}enable(){this.N=!0,this.Et()}disable(){this.N=!1,this.Et()}isEnable(){return this.N}Et(){const A=this.getRenderer();A&&A.setToRedraw()}}Zt.registerRenderer("gl",class extends Jt{draw(A,t){this.layer.getExcavatedLayers()&&this.layer.isEnable()&&(this.Nt(),super.draw(A,t))}Nt(){this._&&this.jt||this.Qt(),this.St=this.St||this.Ut();const A=this.getMap(),t=this.meshes;if(t&&this.St){for(let n=0;n<t.length;n++){const i=t[n],r=i.getDefines();r.HAS_EXCAVATE_ANALYSIS=1,i.setDefines(r),i.setUniform("heightmap",this.St),i.setUniform("excavateExtent",this.jt),i.setUniform("excavateHeight",X(A,this.options.height))}this.setToRedraw()}}Ut(){const A=this.layer.getExcavatedLayers();this.kt=[];for(let t=0;t<A.length;t++){const n=A[t].getRenderer();if(!n.getAnalysisMeshes)continue;const i=n.getAnalysisMeshes();t$1.Util.pushIn(this.kt,i)}return this.kt.length?(this.k=this.k||this.S(),this.k.render(this.kt,this._)):null}Qt(){const A=this.layer.getMap(),n=this.layer.getExtent(),i=A.getCenter(),r=A.getZoom(),e=A.getPitch(),u=A.getBearing(),o=A.getFitZoom(n),h=n.getCenter();A.setZoom(o),A.setCenter(h),A.setPitch(0),A.setBearing(0);const f=A.getExtent();this._=this._||[],copy$5(this._,A.projViewMatrix);const c=AA(A,f.xmin,f.ymin),a=AA(A,f.xmax,f.ymax);this.jt=set$3(this.jt||[],c[0],c[1],a[0],a[1]),A.setZoom(r),A.setCenter(i),A.setPitch(e),A.setBearing(u)}S(){this.u={x:0,y:0,width:()=>this.canvas?this.canvas.width:1,height:()=>this.canvas?this.canvas.height:1};const t=new B$6(this.regl);return this.k=this.k||new Ht(t,this.u),this.k}Bt(){this.Qt(),this.setToRedraw()}onGeometryAdd(A){super.onGeometryAdd(A),this.Bt()}onGeometryRemove(){super.onGeometryRemove(),this.Bt()}remove(){super.remove(),this.k&&this.k.dispose()}});class Xt extends H{h(){this.O=new vn$4({vert:"attribute vec3 aPosition;\n\nuniform mat4 projMatrix;\n\nuniform mat4 modelMatrix;\n\nuniform mat4 positionMatrix;\n\nuniform mat4 modelViewMatrix;\n\n#include <get_output>\n\nvarying vec4 vWorldPosition;\n\nvoid main()\n\n{\n\n    mat4 localPositionMatrix = getPositionMatrix();\n\n    vec4 worldPosition = modelMatrix * localPositionMatrix * getPosition(aPosition);\n\n    vWorldPosition = worldPosition;\n\n    gl_Position = projMatrix * modelViewMatrix * localPositionMatrix * getPosition(aPosition);\n\n}\n\n",frag:"#ifdef GL_ES\n\nprecision highp float;\n\n#endif\n\nuniform vec4 extent;\n\nuniform sampler2D extentMap;\n\nvarying vec4 vWorldPosition;\n\nvoid main() {\n\n    float width = extent.z - extent.x;\n\n    float height = extent.y - extent.w;\n\n    vec2 uvInExtent = vec2((vWorldPosition.x - extent.x) / width, 1.0 - (vWorldPosition.y - extent.w) / height);\n\n    vec4 extentColor = texture2D(extentMap, uvInExtent);\n\n    if (extentColor.r > 0.0) {\n\n        gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n\n    } else {\n\n        gl_FragColor = vec4(0.0);\n\n    }\n\n}\n\n",uniforms:[{name:"modelViewMatrix",type:"function",fn:function(A,n){return multiply$5([],n.viewMatrix,n.modelMatrix)}}],extraCommandProps:{viewport:this.u}}),this.T=this.renderer.regl.framebuffer({color:this.renderer.regl.texture({width:1,height:1,wrap:"clamp",mag:"linear",min:"linear"}),depth:!0})}render(t,n){this.U(),this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.T});const i=new Ke$5(t);return this.it(i,n),this.T}it(A,t){this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.T}),this.renderer.render(this.O,t,A,this.T)}dispose(){this.T&&this.T.destroy(),this.O&&this.O.dispose()}U(){const A=t$1.Util.isFunction(this.u.width.data)?this.u.width.data():this.u.width,t=t$1.Util.isFunction(this.u.height.data)?this.u.height.data():this.u.height;!this.T||this.T.width===A&&this.T.height===t||this.T.resize(A,t)}}var $t={centimeters:637100880,centimetres:637100880,degrees:6371008.8/111325,feet:20902260.511392,inches:6371008.8*39.37,kilometers:6371.0088,kilometres:6371.0088,meters:6371008.8,metres:6371008.8,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:6371008.8/1852,radians:1,yards:6371008.8*1.0936};function An(A,t,n){void 0===n&&(n={});var i={type:"Feature"};return(0===n.id||n.id)&&(i.id=n.id),n.bbox&&(i.bbox=n.bbox),i.properties=t||{},i.geometry=A,i}function tn(A,t,n){if(void 0===n&&(n={}),!A)throw new Error("coordinates is required");if(!Array.isArray(A))throw new Error("coordinates must be an Array");if(A.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!hn(A[0])||!hn(A[1]))throw new Error("coordinates must contain numbers");return An({type:"Point",coordinates:A},t,n)}function nn(A,t,n){if(void 0===n&&(n={}),A.length<2)throw new Error("coordinates must be an array of two or more positions");return An({type:"LineString",coordinates:A},t,n)}function rn(A,t){void 0===t&&(t={});var n={type:"FeatureCollection"};return t.id&&(n.id=t.id),t.bbox&&(n.bbox=t.bbox),n.features=A,n}function en(A,t){void 0===t&&(t="kilometers");var n=$t[t];if(!n)throw new Error(t+" units is invalid");return A*n}function sn(A,t){void 0===t&&(t="kilometers");var n=$t[t];if(!n)throw new Error(t+" units is invalid");return A/n}function un(A){return A%(2*Math.PI)*180/Math.PI}function on(A){return A%360*Math.PI/180}function hn(A){return!isNaN(A)&&null!==A&&!Array.isArray(A)}function fn(A){if(!A)throw new Error("coord is required");if(!Array.isArray(A)){if("Feature"===A.type&&null!==A.geometry&&"Point"===A.geometry.type)return A.geometry.coordinates;if("Point"===A.type)return A.coordinates}if(Array.isArray(A)&&A.length>=2&&!Array.isArray(A[0])&&!Array.isArray(A[1]))return A;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function cn(A,t,n){if(void 0===n&&(n={}),!0===n.final)return function(A,t){var n=cn(t,A);return(n+180)%360}(A,t);var i=fn(A),r=fn(t),e=on(i[0]),s=on(r[0]),u=on(i[1]),o=on(r[1]),h=Math.sin(s-e)*Math.cos(o),f=Math.cos(u)*Math.sin(o)-Math.sin(u)*Math.cos(o)*Math.cos(s-e);return un(Math.atan2(h,f))}function an(A,t,n,i){void 0===i&&(i={});var r=fn(A),e=on(r[0]),s=on(r[1]),u=on(n),o=sn(t,i.units),h=Math.asin(Math.sin(s)*Math.cos(o)+Math.cos(s)*Math.sin(o)*Math.cos(u));return tn([un(e+Math.atan2(Math.sin(u)*Math.sin(o)*Math.cos(s),Math.cos(o)-Math.sin(s)*Math.sin(h))),un(h)],i.properties)}function vn(A,t,n){void 0===n&&(n={});var i=fn(A),r=fn(t),e=on(r[1]-i[1]),s=on(r[0]-i[0]),u=on(i[1]),o=on(r[1]),h=Math.pow(Math.sin(e/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(u)*Math.cos(o);return en(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),n.units)}function ln(A,t,n){void 0===n&&(n={});for(var i,r=("Feature"===(i=A).type?i.geometry:i).coordinates,e=0,s=0;s<r.length&&!(t>=e&&s===r.length-1);s++){if(e>=t){var u=t-e;if(u){var o=cn(r[s],r[s-1])-180;return an(r[s],u,o,n)}return tn(r[s])}e+=vn(r[s],r[s+1],n)}return tn(r[r.length-1])}function wn(A,t){if("Feature"===A.type)t(A,0);else if("FeatureCollection"===A.type)for(var n=0;n<A.features.length&&!1!==t(A.features[n],n);n++);}function Pn(A,t){var n,i,r,e,s,u,o,h,f,c,a=0,v="FeatureCollection"===A.type,l="Feature"===A.type,w=v?A.features.length:1;for(n=0;n<w;n++){for(h=v?A.features[n].properties:l?A.properties:{},f=v?A.features[n].bbox:l?A.bbox:void 0,c=v?A.features[n].id:l?A.id:void 0,s=(o=!!(u=v?A.features[n].geometry:l?A.geometry:A)&&"GeometryCollection"===u.type)?u.geometries.length:1,r=0;r<s;r++)if(null!==(e=o?u.geometries[r]:u))switch(e.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===t(e,a,h,f,c))return!1;break;case"GeometryCollection":for(i=0;i<e.geometries.length;i++)if(!1===t(e.geometries[i],a,h,f,c))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===t(null,a,h,f,c))return!1;a++}}function gn(A){var t=[1/0,1/0,-1/0,-1/0];return function A(t,n,i){if(null!==t)for(var r,e,s,u,o,h,f,c,a=0,v=0,l=t.type,w="FeatureCollection"===l,P="Feature"===l,g=w?t.features.length:1,C=0;C<g;C++){o=(c=!!(f=w?t.features[C].geometry:P?t.geometry:t)&&"GeometryCollection"===f.type)?f.geometries.length:1;for(var D=0;D<o;D++){var I=0,M=0;if(null!==(u=c?f.geometries[D]:f)){h=u.coordinates;var b=u.type;switch(a=!i||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===n(h,v,C,I,M))return!1;v++,I++;break;case"LineString":case"MultiPoint":for(r=0;r<h.length;r++){if(!1===n(h[r],v,C,I,M))return!1;v++,"MultiPoint"===b&&I++}"LineString"===b&&I++;break;case"Polygon":case"MultiLineString":for(r=0;r<h.length;r++){for(e=0;e<h[r].length-a;e++){if(!1===n(h[r][e],v,C,I,M))return!1;v++}"MultiLineString"===b&&I++,"Polygon"===b&&M++}"Polygon"===b&&I++;break;case"MultiPolygon":for(r=0;r<h.length;r++){for(M=0,e=0;e<h[r].length;e++){for(s=0;s<h[r][e].length-a;s++){if(!1===n(h[r][e][s],v,C,I,M))return!1;v++}M++}I++}break;case"GeometryCollection":for(r=0;r<u.geometries.length;r++)if(!1===A(u.geometries[r],n,i))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}(A,(function(A){t[0]>A[0]&&(t[0]=A[0]),t[1]>A[1]&&(t[1]=A[1]),t[2]<A[0]&&(t[2]=A[0]),t[3]<A[1]&&(t[3]=A[1])})),t}gn.default=gn,"fill"in Array.prototype||Object.defineProperty(Array.prototype,"fill",{configurable:!0,value:function(A){if(null==this)throw new TypeError(this+" is not an object");var t=Object(this),n=Math.max(Math.min(t.length,9007199254740991),0)||0,i=1 in arguments&&parseInt(Number(arguments[1]),10)||0;i=i<0?Math.max(n+i,0):Math.min(i,n);var r=2 in arguments&&void 0!==arguments[2]?parseInt(Number(arguments[2]),10)||0:n;for(r=r<0?Math.max(n+arguments[2],0):Math.min(r,n);i<r;)t[i]=A,++i;return t},writable:!0}),Number.isFinite=Number.isFinite||function(A){return"number"==typeof A&&isFinite(A)},Number.isInteger=Number.isInteger||function(A){return"number"==typeof A&&isFinite(A)&&Math.floor(A)===A},Number.parseFloat=Number.parseFloat||parseFloat,Number.isNaN=Number.isNaN||function(A){return A!=A},Math.trunc=Math.trunc||function(A){return A<0?Math.ceil(A):Math.floor(A)};var Cn=function(){};Cn.prototype.interfaces_=function(){return[]},Cn.prototype.getClass=function(){return Cn},Cn.prototype.equalsWithTolerance=function(A,t,n){return Math.abs(A-t)<=n};var Dn=function(A){function t(t){A.call(this,t),this.name="IllegalArgumentException",this.message=t,this.stack=(new A).stack}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t}(Error),In=function(){},Mn={MAX_VALUE:{configurable:!0}};In.isNaN=function(A){return Number.isNaN(A)},In.doubleToLongBits=function(A){return A},In.longBitsToDouble=function(A){return A},In.isInfinite=function(A){return!Number.isFinite(A)},Mn.MAX_VALUE.get=function(){return Number.MAX_VALUE},Object.defineProperties(In,Mn);var bn=function(){},zn=function(){},dn=function(){};function xn(){}var mn=function A(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)this.x=0,this.y=0,this.z=A.NULL_ORDINATE;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.z=t.z}else 2===arguments.length?(this.x=arguments[0],this.y=arguments[1],this.z=A.NULL_ORDINATE):3===arguments.length&&(this.x=arguments[0],this.y=arguments[1],this.z=arguments[2])},yn={DimensionalComparator:{configurable:!0},serialVersionUID:{configurable:!0},NULL_ORDINATE:{configurable:!0},X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0}};mn.prototype.setOrdinate=function(A,t){switch(A){case mn.X:this.x=t;break;case mn.Y:this.y=t;break;case mn.Z:this.z=t;break;default:throw new Dn("Invalid ordinate index: "+A)}},mn.prototype.equals2D=function(){if(1===arguments.length){var A=arguments[0];return this.x===A.x&&this.y===A.y}if(2===arguments.length){var t=arguments[0],n=arguments[1];return!!Cn.equalsWithTolerance(this.x,t.x,n)&&!!Cn.equalsWithTolerance(this.y,t.y,n)}},mn.prototype.getOrdinate=function(A){switch(A){case mn.X:return this.x;case mn.Y:return this.y;case mn.Z:return this.z}throw new Dn("Invalid ordinate index: "+A)},mn.prototype.equals3D=function(A){return this.x===A.x&&this.y===A.y&&(this.z===A.z||In.isNaN(this.z))&&In.isNaN(A.z)},mn.prototype.equals=function(A){return A instanceof mn&&this.equals2D(A)},mn.prototype.equalInZ=function(A,t){return Cn.equalsWithTolerance(this.z,A.z,t)},mn.prototype.compareTo=function(A){return this.x<A.x?-1:this.x>A.x?1:this.y<A.y?-1:this.y>A.y?1:0},mn.prototype.clone=function(){},mn.prototype.copy=function(){return new mn(this)},mn.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},mn.prototype.distance3D=function(A){var t=this.x-A.x,n=this.y-A.y,i=this.z-A.z;return Math.sqrt(t*t+n*n+i*i)},mn.prototype.distance=function(A){var t=this.x-A.x,n=this.y-A.y;return Math.sqrt(t*t+n*n)},mn.prototype.hashCode=function(){var A=17;return 37*(A=37*A+mn.hashCode(this.x))+mn.hashCode(this.y)},mn.prototype.setCoordinate=function(A){this.x=A.x,this.y=A.y,this.z=A.z},mn.prototype.interfaces_=function(){return[bn,zn,xn]},mn.prototype.getClass=function(){return mn},mn.hashCode=function(){if(1===arguments.length){var A=arguments[0],t=In.doubleToLongBits(A);return Math.trunc((t^t)>>>32)}},yn.DimensionalComparator.get=function(){return pn},yn.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},yn.NULL_ORDINATE.get=function(){return In.NaN},yn.X.get=function(){return 0},yn.Y.get=function(){return 1},yn.Z.get=function(){return 2},Object.defineProperties(mn,yn);var pn=function(A){if(this.Rt=2,0===arguments.length);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new Dn("only 2 or 3 dimensions may be specified");this.Rt=t}};pn.prototype.compare=function(A,t){var n=A,i=t,r=pn.compare(n.x,i.x);if(0!==r)return r;var e=pn.compare(n.y,i.y);return 0!==e?e:this.Rt<=2?0:pn.compare(n.z,i.z)},pn.prototype.interfaces_=function(){return[dn]},pn.prototype.getClass=function(){return pn},pn.compare=function(A,t){return A<t?-1:A>t?1:In.isNaN(A)?In.isNaN(t)?0:-1:In.isNaN(t)?1:0};var Ln=function(){};Ln.prototype.create=function(){},Ln.prototype.interfaces_=function(){return[]},Ln.prototype.getClass=function(){return Ln};var Tn=function(){},On={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};Tn.prototype.interfaces_=function(){return[]},Tn.prototype.getClass=function(){return Tn},Tn.toLocationSymbol=function(A){switch(A){case Tn.EXTERIOR:return"e";case Tn.BOUNDARY:return"b";case Tn.INTERIOR:return"i";case Tn.NONE:return"-"}throw new Dn("Unknown location value: "+A)},On.INTERIOR.get=function(){return 0},On.BOUNDARY.get=function(){return 1},On.EXTERIOR.get=function(){return 2},On.NONE.get=function(){return-1},Object.defineProperties(Tn,On);var Fn=function(A,t){return A.interfaces_&&A.interfaces_().indexOf(t)>-1},Un=function(){},En={LOG_10:{configurable:!0}};Un.prototype.interfaces_=function(){return[]},Un.prototype.getClass=function(){return Un},Un.log10=function(A){var t=Math.log(A);return In.isInfinite(t)||In.isNaN(t)?t:t/Un.LOG_10},Un.min=function(A,t,n,i){var r=A;return t<r&&(r=t),n<r&&(r=n),i<r&&(r=i),r},Un.clamp=function(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var A=arguments[0],t=arguments[1],n=arguments[2];return A<t?t:A>n?n:A}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],e=arguments[2];return i<r?r:i>e?e:i}},Un.wrap=function(A,t){return A<0?t- -A%t:A%t},Un.max=function(){if(3===arguments.length){var A=arguments[0],t=arguments[1],n=arguments[2],i=A;return t>i&&(i=t),n>i&&(i=n),i}if(4===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2],u=arguments[3],o=r;return e>o&&(o=e),s>o&&(o=s),u>o&&(o=u),o}},Un.average=function(A,t){return(A+t)/2},En.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Un,En);var Nn=function(A){this.str=A};Nn.prototype.append=function(A){this.str+=A},Nn.prototype.setCharAt=function(A,t){this.str=this.str.substr(0,A)+t+this.str.substr(A+1)},Nn.prototype.toString=function(A){return this.str};var jn=function(A){this.value=A};jn.prototype.intValue=function(){return this.value},jn.prototype.compareTo=function(A){return this.value<A?-1:this.value>A?1:0},jn.isNaN=function(A){return Number.isNaN(A)};var Qn=function(){};Qn.isWhitespace=function(A){return A<=32&&A>=0||127===A},Qn.toUpperCase=function(A){return A.toUpperCase()};var Sn=function A(){if(this.Gt=0,this.Yt=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var t=arguments[0];this.init(t)}else if(arguments[0]instanceof A){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var i=arguments[0];A.call(this,A.parse(i))}}else if(2===arguments.length){var r=arguments[0],e=arguments[1];this.init(r,e)}},kn={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};Sn.prototype.le=function(A){return(this.Gt<A.Gt||this.Gt===A.Gt)&&this.Yt<=A.Yt},Sn.prototype.extractSignificantDigits=function(A,t){var n=this.abs(),i=Sn.magnitude(n.Gt),r=Sn.TEN.pow(i);(n=n.divide(r)).gt(Sn.TEN)?(n=n.divide(Sn.TEN),i+=1):n.lt(Sn.ONE)&&(n=n.multiply(Sn.TEN),i-=1);for(var e=i+1,s=new Nn,u=Sn.MAX_PRINT_DIGITS-1,o=0;o<=u;o++){A&&o===e&&s.append(".");var h=Math.trunc(n.Gt);if(h<0)break;var f=!1,c=0;h>9?(f=!0,c="9"):c="0"+h,s.append(c),n=n.subtract(Sn.valueOf(h)).multiply(Sn.TEN),f&&n.selfAdd(Sn.TEN);var a=!0,v=Sn.magnitude(n.Gt);if(v<0&&Math.abs(v)>=u-o&&(a=!1),!a)break}return t[0]=i,s.toString()},Sn.prototype.sqr=function(){return this.multiply(this)},Sn.prototype.doubleValue=function(){return this.Gt+this.Yt},Sn.prototype.subtract=function(){if(arguments[0]instanceof Sn){var A=arguments[0];return this.add(A.negate())}if("number"==typeof arguments[0]){var t=arguments[0];return this.add(-t)}},Sn.prototype.equals=function(){if(1===arguments.length){var A=arguments[0];return this.Gt===A.Gt&&this.Yt===A.Yt}},Sn.prototype.isZero=function(){return 0===this.Gt&&0===this.Yt},Sn.prototype.selfSubtract=function(){if(arguments[0]instanceof Sn){var A=arguments[0];return this.isNaN()?this:this.selfAdd(-A.Gt,-A.Yt)}if("number"==typeof arguments[0]){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t,0)}},Sn.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},Sn.prototype.min=function(A){return this.le(A)?this:A},Sn.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof Sn){var A=arguments[0];return this.selfDivide(A.Gt,A.Yt)}if("number"==typeof arguments[0]){var t=arguments[0];return this.selfDivide(t,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,e=null,s=null,u=null,o=null,h=null,f=null,c=null;return c=(r=(h=Sn.SPLIT*(o=this.Gt/n))-(r=h-o))*(s=(c=Sn.SPLIT*n)-(s=c-n))-(f=o*n)+r*(u=n-s)+(e=o-r)*s+e*u,c=o+(h=(this.Gt-f-c+this.Yt-o*i)/n),this.Gt=c,this.Yt=o-c+h,this}},Sn.prototype.dump=function(){return"DD<"+this.Gt+", "+this.Yt+">"},Sn.prototype.divide=function(){if(arguments[0]instanceof Sn){var A=arguments[0],t=null,n=null,i=null,r=null,e=null,s=null,u=null,o=null;n=(e=this.Gt/A.Gt)-(t=(s=Sn.SPLIT*e)-(t=s-e)),o=t*(i=(o=Sn.SPLIT*A.Gt)-(i=o-A.Gt))-(u=e*A.Gt)+t*(r=A.Gt-i)+n*i+n*r;var h=o=e+(s=(this.Gt-u-o+this.Yt-e*A.Yt)/A.Gt),f=e-o+s;return new Sn(h,f)}if("number"==typeof arguments[0]){var c=arguments[0];return In.isNaN(c)?Sn.createNaN():Sn.copy(this).selfDivide(c,0)}},Sn.prototype.ge=function(A){return(this.Gt>A.Gt||this.Gt===A.Gt)&&this.Yt>=A.Yt},Sn.prototype.pow=function(A){if(0===A)return Sn.valueOf(1);var t=new Sn(this),n=Sn.valueOf(1),i=Math.abs(A);if(i>1)for(;i>0;)i%2==1&&n.selfMultiply(t),(i/=2)>0&&(t=t.sqr());else n=t;return A<0?n.reciprocal():n},Sn.prototype.ceil=function(){if(this.isNaN())return Sn.NaN;var A=Math.ceil(this.Gt),t=0;return A===this.Gt&&(t=Math.ceil(this.Yt)),new Sn(A,t)},Sn.prototype.compareTo=function(A){return this.Gt<A.Gt?-1:this.Gt>A.Gt?1:this.Yt<A.Yt?-1:this.Yt>A.Yt?1:0},Sn.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},Sn.prototype.setValue=function(){if(arguments[0]instanceof Sn){var A=arguments[0];return this.init(A),this}if("number"==typeof arguments[0]){var t=arguments[0];return this.init(t),this}},Sn.prototype.max=function(A){return this.ge(A)?this:A},Sn.prototype.sqrt=function(){if(this.isZero())return Sn.valueOf(0);if(this.isNegative())return Sn.NaN;var A=1/Math.sqrt(this.Gt),n=Sn.valueOf(this.Gt*A),i=this.subtract(n.sqr()).Gt*(.5*A);return n.add(i)},Sn.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof Sn){var A=arguments[0];return this.selfAdd(A.Gt,A.Yt)}if("number"==typeof arguments[0]){var t=arguments[0],n=null,i=null,r=null,e=null,s=null,u=null;return e=(r=this.Gt+t)-(s=r-this.Gt),i=(u=(e=t-s+(this.Gt-e))+this.Yt)+(r-(n=r+u)),this.Gt=n+i,this.Yt=i+(n-this.Gt),this}}else if(2===arguments.length){var o=arguments[0],h=arguments[1],f=null,c=null,a=null,v=null,l=null,w=null,P=null;l=(v=this.Gt+o)-(w=v-this.Gt),a=(c=this.Yt+h)-(P=c-this.Yt);var g=(f=v+(w=(l=o-w+(this.Gt-l))+c))+(w=(a=h-P+(this.Yt-a))+(w+(v-f))),C=w+(f-g);return this.Gt=g,this.Yt=C,this}},Sn.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof Sn){var A=arguments[0];return this.selfMultiply(A.Gt,A.Yt)}if("number"==typeof arguments[0]){var t=arguments[0];return this.selfMultiply(t,0)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=null,e=null,s=null,u=null,o=null,h=null;r=(o=Sn.SPLIT*this.Gt)-this.Gt,r=o-r;var f=(o=this.Gt*n)+(h=r*(s=(h=Sn.SPLIT*n)-(s=h-n))-o+r*(u=n-s)+(e=this.Gt-r)*s+e*u+(this.Gt*i+this.Yt*n)),c=h+(r=o-f);return this.Gt=f,this.Yt=c,this}},Sn.prototype.selfSqr=function(){return this.selfMultiply(this)},Sn.prototype.floor=function(){if(this.isNaN())return Sn.NaN;var A=Math.floor(this.Gt),t=0;return A===this.Gt&&(t=Math.floor(this.Yt)),new Sn(A,t)},Sn.prototype.negate=function(){return this.isNaN()?this:new Sn(-this.Gt,-this.Yt)},Sn.prototype.clone=function(){},Sn.prototype.multiply=function(){if(arguments[0]instanceof Sn){var A=arguments[0];return A.isNaN()?Sn.createNaN():Sn.copy(this).selfMultiply(A)}if("number"==typeof arguments[0]){var t=arguments[0];return In.isNaN(t)?Sn.createNaN():Sn.copy(this).selfMultiply(t,0)}},Sn.prototype.isNaN=function(){return In.isNaN(this.Gt)},Sn.prototype.intValue=function(){return Math.trunc(this.Gt)},Sn.prototype.toString=function(){var A=Sn.magnitude(this.Gt);return A>=-3&&A<=20?this.toStandardNotation():this.toSciNotation()},Sn.prototype.toStandardNotation=function(){var A=this.getSpecialNumberString();if(null!==A)return A;var t=new Array(1).fill(null),n=this.extractSignificantDigits(!0,t),i=t[0]+1,r=n;if("."===n.charAt(0))r="0"+n;else if(i<0)r="0."+Sn.stringOfChar("0",-i)+n;else if(-1===n.indexOf(".")){r=n+Sn.stringOfChar("0",i-n.length)+".0"}return this.isNegative()?"-"+r:r},Sn.prototype.reciprocal=function(){var A,t,n,i,r=null,e=null,s=null,u=null;A=(n=1/this.Gt)-(r=(s=Sn.SPLIT*n)-(r=s-n)),e=(u=Sn.SPLIT*this.Gt)-this.Gt;var o=n+(s=(1-(i=n*this.Gt)-(u=r*(e=u-e)-i+r*(t=this.Gt-e)+A*e+A*t)-n*this.Yt)/this.Gt);return new Sn(o,n-o+s)},Sn.prototype.toSciNotation=function(){if(this.isZero())return Sn.SCI_NOT_ZERO;var A=this.getSpecialNumberString();if(null!==A)return A;var t=new Array(1).fill(null),n=this.extractSignificantDigits(!1,t),i=Sn.SCI_NOT_EXPONENT_CHAR+t[0];if("0"===n.charAt(0))throw new Error("Found leading zero: "+n);var r="";n.length>1&&(r=n.substring(1));var e=n.charAt(0)+"."+r;return this.isNegative()?"-"+e+i:e+i},Sn.prototype.abs=function(){return this.isNaN()?Sn.NaN:this.isNegative()?this.negate():new Sn(this)},Sn.prototype.isPositive=function(){return(this.Gt>0||0===this.Gt)&&this.Yt>0},Sn.prototype.lt=function(A){return(this.Gt<A.Gt||this.Gt===A.Gt)&&this.Yt<A.Yt},Sn.prototype.add=function(){if(arguments[0]instanceof Sn){var A=arguments[0];return Sn.copy(this).selfAdd(A)}if("number"==typeof arguments[0]){var t=arguments[0];return Sn.copy(this).selfAdd(t)}},Sn.prototype.init=function(){if(1===arguments.length){if("number"==typeof arguments[0]){var A=arguments[0];this.Gt=A,this.Yt=0}else if(arguments[0]instanceof Sn){var t=arguments[0];this.Gt=t.Gt,this.Yt=t.Yt}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.Gt=n,this.Yt=i}},Sn.prototype.gt=function(A){return(this.Gt>A.Gt||this.Gt===A.Gt)&&this.Yt>A.Yt},Sn.prototype.isNegative=function(){return(this.Gt<0||0===this.Gt)&&this.Yt<0},Sn.prototype.trunc=function(){return this.isNaN()?Sn.NaN:this.isPositive()?this.floor():this.ceil()},Sn.prototype.signum=function(){return this.Gt>0?1:this.Gt<0?-1:this.Yt>0?1:this.Yt<0?-1:0},Sn.prototype.interfaces_=function(){return[xn,bn,zn]},Sn.prototype.getClass=function(){return Sn},Sn.sqr=function(A){return Sn.valueOf(A).selfMultiply(A)},Sn.valueOf=function(){if("string"==typeof arguments[0]){var A=arguments[0];return Sn.parse(A)}if("number"==typeof arguments[0]){var t=arguments[0];return new Sn(t)}},Sn.sqrt=function(A){return Sn.valueOf(A).sqrt()},Sn.parse=function(A){for(var t=0,n=A.length;Qn.isWhitespace(A.charAt(t));)t++;var i=!1;if(t<n){var r=A.charAt(t);"-"!==r&&"+"!==r||(t++,"-"===r&&(i=!0))}for(var e=new Sn,s=0,u=0,o=0;!(t>=n);){var h=A.charAt(t);if(t++,Qn.isDigit(h)){var f=h-"0";e.selfMultiply(Sn.TEN),e.selfAdd(f),s++}else{if("."!==h){if("e"===h||"E"===h){var c=A.substring(t);try{o=jn.parseInt(c)}catch(t){throw t instanceof Error?new Error("Invalid exponent "+c+" in string "+A):t}break}throw new Error("Unexpected character '"+h+"' at position "+t+" in string "+A)}u=s}}var a=e,v=s-u-o;if(0===v)a=e;else if(v>0){var l=Sn.TEN.pow(v);a=e.divide(l)}else if(v<0){var w=Sn.TEN.pow(-v);a=e.multiply(w)}return i?a.negate():a},Sn.createNaN=function(){return new Sn(In.NaN,In.NaN)},Sn.copy=function(A){return new Sn(A)},Sn.magnitude=function(A){var t=Math.abs(A),n=Math.log(t)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=t&&(i+=1),i},Sn.stringOfChar=function(A,t){for(var n=new Nn,i=0;i<t;i++)n.append(A);return n.toString()},kn.PI.get=function(){return new Sn(3.141592653589793,12246467991473532e-32)},kn.TWO_PI.get=function(){return new Sn(6.283185307179586,24492935982947064e-32)},kn.PI_2.get=function(){return new Sn(1.5707963267948966,6123233995736766e-32)},kn.E.get=function(){return new Sn(2.718281828459045,14456468917292502e-32)},kn.NaN.get=function(){return new Sn(In.NaN,In.NaN)},kn.EPS.get=function(){return 123259516440783e-46},kn.SPLIT.get=function(){return 134217729},kn.MAX_PRINT_DIGITS.get=function(){return 32},kn.TEN.get=function(){return Sn.valueOf(10)},kn.ONE.get=function(){return Sn.valueOf(1)},kn.SCI_NOT_EXPONENT_CHAR.get=function(){return"E"},kn.SCI_NOT_ZERO.get=function(){return"0.0E0"},Object.defineProperties(Sn,kn);var Bn=function(){},Rn={DP_SAFE_EPSILON:{configurable:!0}};Bn.prototype.interfaces_=function(){return[]},Bn.prototype.getClass=function(){return Bn},Bn.orientationIndex=function(A,t,n){var i=Bn.orientationIndexFilter(A,t,n);if(i<=1)return i;var r=Sn.valueOf(t.x).selfAdd(-A.x),e=Sn.valueOf(t.y).selfAdd(-A.y),s=Sn.valueOf(n.x).selfAdd(-t.x),u=Sn.valueOf(n.y).selfAdd(-t.y);return r.selfMultiply(u).selfSubtract(e.selfMultiply(s)).signum()},Bn.signOfDet2x2=function(A,t,n,i){return A.multiply(i).selfSubtract(t.multiply(n)).signum()},Bn.intersection=function(A,t,n,i){var r=Sn.valueOf(i.y).selfSubtract(n.y).selfMultiply(Sn.valueOf(t.x).selfSubtract(A.x)),e=Sn.valueOf(i.x).selfSubtract(n.x).selfMultiply(Sn.valueOf(t.y).selfSubtract(A.y)),s=r.subtract(e),u=Sn.valueOf(i.x).selfSubtract(n.x).selfMultiply(Sn.valueOf(A.y).selfSubtract(n.y)),o=Sn.valueOf(i.y).selfSubtract(n.y).selfMultiply(Sn.valueOf(A.x).selfSubtract(n.x)),h=u.subtract(o).selfDivide(s).doubleValue(),f=Sn.valueOf(A.x).selfAdd(Sn.valueOf(t.x).selfSubtract(A.x).selfMultiply(h)).doubleValue(),c=Sn.valueOf(t.x).selfSubtract(A.x).selfMultiply(Sn.valueOf(A.y).selfSubtract(n.y)),a=Sn.valueOf(t.y).selfSubtract(A.y).selfMultiply(Sn.valueOf(A.x).selfSubtract(n.x)),v=c.subtract(a).selfDivide(s).doubleValue(),l=Sn.valueOf(n.y).selfAdd(Sn.valueOf(i.y).selfSubtract(n.y).selfMultiply(v)).doubleValue();return new mn(f,l)},Bn.orientationIndexFilter=function(A,t,n){var i=null,r=(A.x-n.x)*(t.y-n.y),e=(A.y-n.y)*(t.x-n.x),s=r-e;if(r>0){if(e<=0)return Bn.signum(s);i=r+e}else{if(!(r<0))return Bn.signum(s);if(e>=0)return Bn.signum(s);i=-r-e}var u=Bn.DP_SAFE_EPSILON*i;return s>=u||-s>=u?Bn.signum(s):2},Bn.signum=function(A){return A>0?1:A<0?-1:0},Rn.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(Bn,Rn);var Gn=function(){},Yn={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};Yn.X.get=function(){return 0},Yn.Y.get=function(){return 1},Yn.Z.get=function(){return 2},Yn.M.get=function(){return 3},Gn.prototype.setOrdinate=function(A,t,n){},Gn.prototype.size=function(){},Gn.prototype.getOrdinate=function(A,t){},Gn.prototype.getCoordinate=function(){},Gn.prototype.getCoordinateCopy=function(A){},Gn.prototype.getDimension=function(){},Gn.prototype.getX=function(A){},Gn.prototype.clone=function(){},Gn.prototype.expandEnvelope=function(A){},Gn.prototype.copy=function(){},Gn.prototype.getY=function(A){},Gn.prototype.toCoordinateArray=function(){},Gn.prototype.interfaces_=function(){return[zn]},Gn.prototype.getClass=function(){return Gn},Object.defineProperties(Gn,Yn);var qn=function(){},Vn=function(A){function t(){A.call(this,"Projective point not representable on the Cartesian plane.")}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(qn),Wn=function(){};Wn.arraycopy=function(A,t,n,i,r){for(var e=0,s=t;s<t+r;s++)n[i+e]=A[s],e++},Wn.getProperty=function(A){return{"line.separator":"\n"}[A]};var _n=function A(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){var t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this.x=n,this.y=i,this.w=1}else if(arguments[0]instanceof A&&arguments[1]instanceof A){var r=arguments[0],e=arguments[1];this.x=r.y*e.w-e.y*r.w,this.y=e.x*r.w-r.x*e.w,this.w=r.x*e.y-e.x*r.y}else if(arguments[0]instanceof mn&&arguments[1]instanceof mn){var s=arguments[0],u=arguments[1];this.x=s.y-u.y,this.y=u.x-s.x,this.w=s.x*u.y-u.x*s.y}}else if(3===arguments.length){var o=arguments[0],h=arguments[1],f=arguments[2];this.x=o,this.y=h,this.w=f}else if(4===arguments.length){var c=arguments[0],a=arguments[1],v=arguments[2],l=arguments[3],w=c.y-a.y,P=a.x-c.x,g=c.x*a.y-a.x*c.y,C=v.y-l.y,D=l.x-v.x,I=v.x*l.y-l.x*v.y;this.x=P*I-D*g,this.y=C*g-w*I,this.w=w*D-C*P}};_n.prototype.getY=function(){var A=this.y/this.w;if(In.isNaN(A)||In.isInfinite(A))throw new Vn;return A},_n.prototype.getX=function(){var A=this.x/this.w;if(In.isNaN(A)||In.isInfinite(A))throw new Vn;return A},_n.prototype.getCoordinate=function(){var A=new mn;return A.x=this.getX(),A.y=this.getY(),A},_n.prototype.interfaces_=function(){return[]},_n.prototype.getClass=function(){return _n},_n.intersection=function(A,t,n,i){var r=A.y-t.y,e=t.x-A.x,s=A.x*t.y-t.x*A.y,u=n.y-i.y,o=i.x-n.x,h=n.x*i.y-i.x*n.y,f=r*o-u*e,c=(e*h-o*s)/f,a=(u*s-r*h)/f;if(In.isNaN(c)||In.isInfinite(c)||In.isNaN(a)||In.isInfinite(a))throw new Vn;return new mn(c,a)};var Kn=function A(){if(this.qt=null,this.Vt=null,this.Wt=null,this._t=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof mn){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof A){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2],o=arguments[3];this.init(e,s,u,o)}},Hn={serialVersionUID:{configurable:!0}};Kn.prototype.getArea=function(){return this.getWidth()*this.getHeight()},Kn.prototype.equals=function(A){if(!(A instanceof Kn))return!1;var t=A;return this.isNull()?t.isNull():this.Vt===t.getMaxX()&&this._t===t.getMaxY()&&this.qt===t.getMinX()&&this.Wt===t.getMinY()},Kn.prototype.intersection=function(A){return this.isNull()||A.isNull()||!this.intersects(A)?new Kn:new Kn(this.qt>A.qt?this.qt:A.qt,this.Vt<A.Vt?this.Vt:A.Vt,this.Wt>A.Wt?this.Wt:A.Wt,this._t<A._t?this._t:A._t)},Kn.prototype.isNull=function(){return this.Vt<this.qt},Kn.prototype.getMaxX=function(){return this.Vt},Kn.prototype.covers=function(){if(1===arguments.length){if(arguments[0]instanceof mn){var A=arguments[0];return this.covers(A.x,A.y)}if(arguments[0]instanceof Kn){var t=arguments[0];return!this.isNull()&&!t.isNull()&&t.getMinX()>=this.qt&&t.getMaxX()<=this.Vt&&t.getMinY()>=this.Wt&&t.getMaxY()<=this._t}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&n>=this.qt&&n<=this.Vt&&i>=this.Wt&&i<=this._t}},Kn.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof Kn){var A=arguments[0];return!this.isNull()&&!A.isNull()&&!(A.qt>this.Vt||A.Vt<this.qt||A.Wt>this._t||A._t<this.Wt)}if(arguments[0]instanceof mn){var t=arguments[0];return this.intersects(t.x,t.y)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return!this.isNull()&&!(n>this.Vt||n<this.qt||i>this._t||i<this.Wt)}},Kn.prototype.getMinY=function(){return this.Wt},Kn.prototype.getMinX=function(){return this.qt},Kn.prototype.expandToInclude=function(){if(1===arguments.length){if(arguments[0]instanceof mn){var A=arguments[0];this.expandToInclude(A.x,A.y)}else if(arguments[0]instanceof Kn){var t=arguments[0];if(t.isNull())return null;this.isNull()?(this.qt=t.getMinX(),this.Vt=t.getMaxX(),this.Wt=t.getMinY(),this._t=t.getMaxY()):(t.qt<this.qt&&(this.qt=t.qt),t.Vt>this.Vt&&(this.Vt=t.Vt),t.Wt<this.Wt&&(this.Wt=t.Wt),t._t>this._t&&(this._t=t._t))}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.isNull()?(this.qt=n,this.Vt=n,this.Wt=i,this._t=i):(n<this.qt&&(this.qt=n),n>this.Vt&&(this.Vt=n),i<this.Wt&&(this.Wt=i),i>this._t&&(this._t=i))}},Kn.prototype.minExtent=function(){if(this.isNull())return 0;var A=this.getWidth(),t=this.getHeight();return A<t?A:t},Kn.prototype.getWidth=function(){return this.isNull()?0:this.Vt-this.qt},Kn.prototype.compareTo=function(A){var t=A;return this.isNull()?t.isNull()?0:-1:t.isNull()?1:this.qt<t.qt?-1:this.qt>t.qt?1:this.Wt<t.Wt?-1:this.Wt>t.Wt?1:this.Vt<t.Vt?-1:this.Vt>t.Vt?1:this._t<t._t?-1:this._t>t._t?1:0},Kn.prototype.translate=function(A,t){if(this.isNull())return null;this.init(this.getMinX()+A,this.getMaxX()+A,this.getMinY()+t,this.getMaxY()+t)},Kn.prototype.toString=function(){return"Env["+this.qt+" : "+this.Vt+", "+this.Wt+" : "+this._t+"]"},Kn.prototype.setToNull=function(){this.qt=0,this.Vt=-1,this.Wt=0,this._t=-1},Kn.prototype.getHeight=function(){return this.isNull()?0:this._t-this.Wt},Kn.prototype.maxExtent=function(){if(this.isNull())return 0;var A=this.getWidth(),t=this.getHeight();return A>t?A:t},Kn.prototype.expandBy=function(){if(1===arguments.length){var A=arguments[0];this.expandBy(A,A)}else if(2===arguments.length){var t=arguments[0],n=arguments[1];if(this.isNull())return null;this.qt-=t,this.Vt+=t,this.Wt-=n,this._t+=n,(this.qt>this.Vt||this.Wt>this._t)&&this.setToNull()}},Kn.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof Kn){var A=arguments[0];return this.covers(A)}if(arguments[0]instanceof mn){var t=arguments[0];return this.covers(t)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return this.covers(n,i)}},Kn.prototype.centre=function(){return this.isNull()?null:new mn((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},Kn.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof mn){var A=arguments[0];this.init(A.x,A.x,A.y,A.y)}else if(arguments[0]instanceof Kn){var t=arguments[0];this.qt=t.qt,this.Vt=t.Vt,this.Wt=t.Wt,this._t=t._t}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.init(n.x,i.x,n.y,i.y)}else if(4===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2],u=arguments[3];r<e?(this.qt=r,this.Vt=e):(this.qt=e,this.Vt=r),s<u?(this.Wt=s,this._t=u):(this.Wt=u,this._t=s)}},Kn.prototype.getMaxY=function(){return this._t},Kn.prototype.distance=function(A){if(this.intersects(A))return 0;var t=0;this.Vt<A.qt?t=A.qt-this.Vt:this.qt>A.Vt&&(t=this.qt-A.Vt);var n=0;return this._t<A.Wt?n=A.Wt-this._t:this.Wt>A._t&&(n=this.Wt-A._t),0===t?n:0===n?t:Math.sqrt(t*t+n*n)},Kn.prototype.hashCode=function(){var A=17;return 37*(A=37*(A=37*(A=37*A+mn.hashCode(this.qt))+mn.hashCode(this.Vt))+mn.hashCode(this.Wt))+mn.hashCode(this._t)},Kn.prototype.interfaces_=function(){return[bn,xn]},Kn.prototype.getClass=function(){return Kn},Kn.intersects=function(){if(3===arguments.length){var A=arguments[0],t=arguments[1],n=arguments[2];return n.x>=(A.x<t.x?A.x:t.x)&&n.x<=(A.x>t.x?A.x:t.x)&&n.y>=(A.y<t.y?A.y:t.y)&&n.y<=(A.y>t.y?A.y:t.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2],s=arguments[3],u=Math.min(e.x,s.x),o=Math.max(e.x,s.x),h=Math.min(i.x,r.x),f=Math.max(i.x,r.x);return!(h>o||f<u||(u=Math.min(e.y,s.y),o=Math.max(e.y,s.y),h=Math.min(i.y,r.y),f=Math.max(i.y,r.y),h>o||f<u))}},Hn.serialVersionUID.get=function(){return 0x51845cd552189800},Object.defineProperties(Kn,Hn);var Jn={typeStr:/^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,emptyTypeStr:/^\s*(\w+)\s*EMPTY\s*$/,spaces:/\s+/,parenComma:/\)\s*,\s*\(/,doubleParenComma:/\)\s*\)\s*,\s*\(\s*\(/,trimParens:/^\s*\(?(.*?)\)?\s*$/},Zn=function(A){this.geometryFactory=A||new jr};Zn.prototype.read=function(A){var t,n;A=A.replace(/[\n\r]/g," ");var r=Jn.typeStr.exec(A);if(-1!==A.search("EMPTY")&&((r=Jn.emptyTypeStr.exec(A))[2]=void 0),r&&(n=r[1].toLowerCase(),$n[n]&&(t=$n[n].apply(this,[r[2]]))),void 0===t)throw new Error("Could not parse WKT "+A);return t},Zn.prototype.write=function(A){return this.extractGeometry(A)},Zn.prototype.extractGeometry=function(A){var t=A.getGeometryType().toLowerCase();if(!Xn[t])return null;var n=t.toUpperCase();return A.isEmpty()?n+" EMPTY":n+"("+Xn[t].apply(this,[A])+")"};var Xn={coordinate:function(A){return A.x+" "+A.y},point:function(A){return Xn.coordinate.call(this,A.Kt.Kt[0])},multipoint:function(A){for(var t=[],n=0,i=A.Ht.length;n<i;++n)t.push("("+Xn.point.apply(this,[A.Ht[n]])+")");return t.join(",")},linestring:function(A){for(var t=[],n=0,i=A.Jt.Kt.length;n<i;++n)t.push(Xn.coordinate.apply(this,[A.Jt.Kt[n]]));return t.join(",")},linearring:function(A){for(var t=[],n=0,i=A.Jt.Kt.length;n<i;++n)t.push(Xn.coordinate.apply(this,[A.Jt.Kt[n]]));return t.join(",")},multilinestring:function(A){for(var t=[],n=0,i=A.Ht.length;n<i;++n)t.push("("+Xn.linestring.apply(this,[A.Ht[n]])+")");return t.join(",")},polygon:function(A){var t=[];t.push("("+Xn.linestring.apply(this,[A.Zt])+")");for(var n=0,i=A.Xt.length;n<i;++n)t.push("("+Xn.linestring.apply(this,[A.Xt[n]])+")");return t.join(",")},multipolygon:function(A){for(var t=[],n=0,i=A.Ht.length;n<i;++n)t.push("("+Xn.polygon.apply(this,[A.Ht[n]])+")");return t.join(",")},geometrycollection:function(A){for(var t=[],n=0,i=A.Ht.length;n<i;++n)t.push(this.extractGeometry(A.Ht[n]));return t.join(",")}},$n={point:function(A){if(void 0===A)return this.geometryFactory.createPoint();var t=A.trim().split(Jn.spaces);return this.geometryFactory.createPoint(new mn(Number.parseFloat(t[0]),Number.parseFloat(t[1])))},multipoint:function(A){var t;if(void 0===A)return this.geometryFactory.createMultiPoint();for(var n=A.trim().split(","),i=[],r=0,e=n.length;r<e;++r)t=n[r].replace(Jn.trimParens,"$1"),i.push($n.point.apply(this,[t]));return this.geometryFactory.createMultiPoint(i)},linestring:function(A){if(void 0===A)return this.geometryFactory.createLineString();for(var t,n=A.trim().split(","),i=[],r=0,e=n.length;r<e;++r)t=n[r].trim().split(Jn.spaces),i.push(new mn(Number.parseFloat(t[0]),Number.parseFloat(t[1])));return this.geometryFactory.createLineString(i)},linearring:function(A){if(void 0===A)return this.geometryFactory.createLinearRing();for(var t,n=A.trim().split(","),i=[],r=0,e=n.length;r<e;++r)t=n[r].trim().split(Jn.spaces),i.push(new mn(Number.parseFloat(t[0]),Number.parseFloat(t[1])));return this.geometryFactory.createLinearRing(i)},multilinestring:function(A){var t;if(void 0===A)return this.geometryFactory.createMultiLineString();for(var n=A.trim().split(Jn.parenComma),i=[],r=0,e=n.length;r<e;++r)t=n[r].replace(Jn.trimParens,"$1"),i.push($n.linestring.apply(this,[t]));return this.geometryFactory.createMultiLineString(i)},polygon:function(A){var t,n,i;if(void 0===A)return this.geometryFactory.createPolygon();for(var r,e=A.trim().split(Jn.parenComma),s=[],u=0,o=e.length;u<o;++u)t=e[u].replace(Jn.trimParens,"$1"),n=$n.linestring.apply(this,[t]),i=this.geometryFactory.createLinearRing(n.Jt),0===u?r=i:s.push(i);return this.geometryFactory.createPolygon(r,s)},multipolygon:function(A){var t;if(void 0===A)return this.geometryFactory.createMultiPolygon();for(var n=A.trim().split(Jn.doubleParenComma),i=[],r=0,e=n.length;r<e;++r)t=n[r].replace(Jn.trimParens,"$1"),i.push($n.polygon.apply(this,[t]));return this.geometryFactory.createMultiPolygon(i)},geometrycollection:function(A){if(void 0===A)return this.geometryFactory.createGeometryCollection();for(var t=(A=A.replace(/,\s*([A-Za-z])/g,"|$1")).trim().split("|"),n=[],i=0,r=t.length;i<r;++i)n.push(this.read(t[i]));return this.geometryFactory.createGeometryCollection(n)}},Ai=function(A){this.parser=new Zn(A)};Ai.prototype.write=function(A){return this.parser.write(A)},Ai.toLineString=function(A,t){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+A.x+" "+A.y+", "+t.x+" "+t.y+" )"};var ti=function(A){function t(t){A.call(this,t),this.name="RuntimeException",this.message=t,this.stack=(new A).stack}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t}(Error),ni=function(A){function t(){if(A.call(this),0===arguments.length)A.call(this);else if(1===arguments.length){var t=arguments[0];A.call(this,t)}}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(ti),ii=function(){};ii.prototype.interfaces_=function(){return[]},ii.prototype.getClass=function(){return ii},ii.shouldNeverReachHere=function(){if(0===arguments.length)ii.shouldNeverReachHere(null);else if(1===arguments.length){var A=arguments[0];throw new ni("Should never reach here"+(null!==A?": "+A:""))}},ii.isTrue=function(){var A;if(1===arguments.length)ii.isTrue(arguments[0],null);else if(2===arguments.length&&(A=arguments[1],!arguments[0]))throw null===A?new ni:new ni(A)},ii.equals=function(){var A,t,n;if(2===arguments.length)ii.equals(A=arguments[0],t=arguments[1],null);else if(3===arguments.length&&(n=arguments[2],!(t=arguments[1]).equals(A=arguments[0])))throw new ni("Expected "+A+" but encountered "+t+(null!==n?": "+n:""))};var ri=function(){this.$t=null,this.An=Array(2).fill().map((function(){return Array(2)})),this.tn=new Array(2).fill(null),this.nn=null,this.in=null,this.rn=null,this.en=null,this.sn=null,this.tn[0]=new mn,this.tn[1]=new mn,this.rn=this.tn[0],this.en=this.tn[1],this.$t=0},ei={DONT_INTERSECT:{configurable:!0},DO_INTERSECT:{configurable:!0},COLLINEAR:{configurable:!0},NO_INTERSECTION:{configurable:!0},POINT_INTERSECTION:{configurable:!0},COLLINEAR_INTERSECTION:{configurable:!0}};ri.prototype.getIndexAlongSegment=function(A,t){return this.computeIntLineIndex(),this.nn[A][t]},ri.prototype.getTopologySummary=function(){var A=new Nn;return this.isEndPoint()&&A.append(" endpoint"),this.in&&A.append(" proper"),this.isCollinear()&&A.append(" collinear"),A.toString()},ri.prototype.computeIntersection=function(A,t,n,i){this.An[0][0]=A,this.An[0][1]=t,this.An[1][0]=n,this.An[1][1]=i,this.$t=this.computeIntersect(A,t,n,i)},ri.prototype.getIntersectionNum=function(){return this.$t},ri.prototype.computeIntLineIndex=function(){if(0===arguments.length)null===this.nn&&(this.nn=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var A=arguments[0],t=this.getEdgeDistance(A,0),n=this.getEdgeDistance(A,1);t>n?(this.nn[A][0]=0,this.nn[A][1]=1):(this.nn[A][0]=1,this.nn[A][1]=0)}},ri.prototype.isProper=function(){return this.hasIntersection()&&this.in},ri.prototype.setPrecisionModel=function(A){this.sn=A},ri.prototype.isInteriorIntersection=function(){var A=this;if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],n=0;n<this.$t;n++)if(!A.tn[n].equals2D(A.An[t][0])&&!A.tn[n].equals2D(A.An[t][1]))return!0;return!1}},ri.prototype.getIntersection=function(A){return this.tn[A]},ri.prototype.isEndPoint=function(){return this.hasIntersection()&&!this.in},ri.prototype.hasIntersection=function(){return this.$t!==ri.NO_INTERSECTION},ri.prototype.getEdgeDistance=function(A,t){return ri.computeEdgeDistance(this.tn[t],this.An[A][0],this.An[A][1])},ri.prototype.isCollinear=function(){return this.$t===ri.COLLINEAR_INTERSECTION},ri.prototype.toString=function(){return Ai.toLineString(this.An[0][0],this.An[0][1])+" - "+Ai.toLineString(this.An[1][0],this.An[1][1])+this.getTopologySummary()},ri.prototype.getEndpoint=function(A,t){return this.An[A][t]},ri.prototype.isIntersection=function(A){for(var t=0;t<this.$t;t++)if(this.tn[t].equals2D(A))return!0;return!1},ri.prototype.getIntersectionAlongSegment=function(A,t){return this.computeIntLineIndex(),this.tn[this.nn[A][t]]},ri.prototype.interfaces_=function(){return[]},ri.prototype.getClass=function(){return ri},ri.computeEdgeDistance=function(A,t,n){var i=Math.abs(n.x-t.x),r=Math.abs(n.y-t.y),e=-1;if(A.equals(t))e=0;else if(A.equals(n))e=i>r?i:r;else{var s=Math.abs(A.x-t.x),u=Math.abs(A.y-t.y);0!==(e=i>r?s:u)||A.equals(t)||(e=Math.max(s,u))}return ii.isTrue(!(0===e&&!A.equals(t)),"Bad distance calculation"),e},ri.nonRobustComputeEdgeDistance=function(A,t,n){var i=A.x-t.x,r=A.y-t.y,e=Math.sqrt(i*i+r*r);return ii.isTrue(!(0===e&&!A.equals(t)),"Invalid distance calculation"),e},ei.DONT_INTERSECT.get=function(){return 0},ei.DO_INTERSECT.get=function(){return 1},ei.COLLINEAR.get=function(){return 2},ei.NO_INTERSECTION.get=function(){return 0},ei.POINT_INTERSECTION.get=function(){return 1},ei.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(ri,ei);var si=function(A){function t(){A.apply(this,arguments)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.isInSegmentEnvelopes=function(A){var t=new Kn(this.An[0][0],this.An[0][1]),n=new Kn(this.An[1][0],this.An[1][1]);return t.contains(A)&&n.contains(A)},t.prototype.computeIntersection=function(){if(3!==arguments.length)return A.prototype.computeIntersection.apply(this,arguments);var t=arguments[0],n=arguments[1],i=arguments[2];if(this.in=!1,Kn.intersects(n,i,t)&&0===hi.orientationIndex(n,i,t)&&0===hi.orientationIndex(i,n,t))return this.in=!0,(t.equals(n)||t.equals(i))&&(this.in=!1),this.$t=A.POINT_INTERSECTION,null;this.$t=A.NO_INTERSECTION},t.prototype.normalizeToMinimum=function(A,t,n,i,r){r.x=this.smallestInAbsValue(A.x,t.x,n.x,i.x),r.y=this.smallestInAbsValue(A.y,t.y,n.y,i.y),A.x-=r.x,A.y-=r.y,t.x-=r.x,t.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},t.prototype.safeHCoordinateIntersection=function(A,n,i,r){var e=null;try{e=_n.intersection(A,n,i,r)}catch(s){if(!(s instanceof Vn))throw s;e=t.nearestEndpoint(A,n,i,r)}return e},t.prototype.intersection=function(A,n,i,r){var e=this.intersectionWithNormalization(A,n,i,r);return this.isInSegmentEnvelopes(e)||(e=new mn(t.nearestEndpoint(A,n,i,r))),null!==this.sn&&this.sn.makePrecise(e),e},t.prototype.smallestInAbsValue=function(A,t,n,i){var r=A,e=Math.abs(r);return Math.abs(t)<e&&(r=t,e=Math.abs(t)),Math.abs(n)<e&&(r=n,e=Math.abs(n)),Math.abs(i)<e&&(r=i),r},t.prototype.checkDD=function(A,t,n,i,r){var e=Bn.intersection(A,t,n,i),s=this.isInSegmentEnvelopes(e);Wn.out.println("DD in env = "+s+"  --------------------- "+e),r.distance(e)>1e-4&&Wn.out.println("Distance = "+r.distance(e))},t.prototype.intersectionWithNormalization=function(A,t,n,i){var r=new mn(A),e=new mn(t),s=new mn(n),u=new mn(i),o=new mn;this.normalizeToEnvCentre(r,e,s,u,o);var h=this.safeHCoordinateIntersection(r,e,s,u);return h.x+=o.x,h.y+=o.y,h},t.prototype.computeCollinearIntersection=function(t,n,i,r){var e=Kn.intersects(t,n,i),s=Kn.intersects(t,n,r),u=Kn.intersects(i,r,t),o=Kn.intersects(i,r,n);return e&&s?(this.tn[0]=i,this.tn[1]=r,A.COLLINEAR_INTERSECTION):u&&o?(this.tn[0]=t,this.tn[1]=n,A.COLLINEAR_INTERSECTION):e&&u?(this.tn[0]=i,this.tn[1]=t,!i.equals(t)||s||o?A.COLLINEAR_INTERSECTION:A.POINT_INTERSECTION):e&&o?(this.tn[0]=i,this.tn[1]=n,!i.equals(n)||s||u?A.COLLINEAR_INTERSECTION:A.POINT_INTERSECTION):s&&u?(this.tn[0]=r,this.tn[1]=t,!r.equals(t)||e||o?A.COLLINEAR_INTERSECTION:A.POINT_INTERSECTION):s&&o?(this.tn[0]=r,this.tn[1]=n,!r.equals(n)||e||u?A.COLLINEAR_INTERSECTION:A.POINT_INTERSECTION):A.NO_INTERSECTION},t.prototype.normalizeToEnvCentre=function(A,t,n,i,r){var e=A.x<t.x?A.x:t.x,s=A.y<t.y?A.y:t.y,u=A.x>t.x?A.x:t.x,o=A.y>t.y?A.y:t.y,h=n.x<i.x?n.x:i.x,f=n.y<i.y?n.y:i.y,c=n.x>i.x?n.x:i.x,a=n.y>i.y?n.y:i.y,l=((s>f?s:f)+(o<a?o:a))/2;r.x=((e>h?e:h)+(u<c?u:c))/2,r.y=l,A.x-=r.x,A.y-=r.y,t.x-=r.x,t.y-=r.y,n.x-=r.x,n.y-=r.y,i.x-=r.x,i.y-=r.y},t.prototype.computeIntersect=function(t,n,i,r){if(this.in=!1,!Kn.intersects(t,n,i,r))return A.NO_INTERSECTION;var e=hi.orientationIndex(t,n,i),s=hi.orientationIndex(t,n,r);if(e>0&&s>0||e<0&&s<0)return A.NO_INTERSECTION;var u=hi.orientationIndex(i,r,t),o=hi.orientationIndex(i,r,n);return u>0&&o>0||u<0&&o<0?A.NO_INTERSECTION:0===e&&0===s&&0===u&&0===o?this.computeCollinearIntersection(t,n,i,r):(0===e||0===s||0===u||0===o?(this.in=!1,t.equals2D(i)||t.equals2D(r)?this.tn[0]=t:n.equals2D(i)||n.equals2D(r)?this.tn[0]=n:0===e?this.tn[0]=new mn(i):0===s?this.tn[0]=new mn(r):0===u?this.tn[0]=new mn(t):0===o&&(this.tn[0]=new mn(n))):(this.in=!0,this.tn[0]=this.intersection(t,n,i,r)),A.POINT_INTERSECTION)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t.nearestEndpoint=function(A,t,n,i){var r=A,e=hi.distancePointLine(A,n,i),s=hi.distancePointLine(t,n,i);return s<e&&(e=s,r=t),(s=hi.distancePointLine(n,A,t))<e&&(e=s,r=n),(s=hi.distancePointLine(i,A,t))<e&&(e=s,r=i),r},t}(ri),ui=function(){};ui.prototype.interfaces_=function(){return[]},ui.prototype.getClass=function(){return ui},ui.orientationIndex=function(A,t,n){return ui.signOfDet2x2(t.x-A.x,t.y-A.y,n.x-t.x,n.y-t.y)},ui.signOfDet2x2=function(A,t,n,i){var r=null,e=null,s=null;if(r=1,0===A||0===i)return 0===t||0===n?0:t>0?n>0?-r:r:n>0?r:-r;if(0===t||0===n)return i>0?A>0?r:-r:A>0?-r:r;if(t>0?i>0?t<=i||(r=-r,e=A,A=n,n=e,e=t,t=i,i=e):t<=-i?(r=-r,n=-n,i=-i):(e=A,A=-n,n=e,e=t,t=-i,i=e):i>0?-t<=i?(r=-r,A=-A,t=-t):(e=-A,A=n,n=e,e=-t,t=i,i=e):t>=i?(A=-A,t=-t,n=-n,i=-i):(r=-r,e=-A,A=-n,n=e,e=-t,t=-i,i=e),A>0){if(!(n>0))return r;if(!(A<=n))return r}else{if(n>0)return-r;if(!(A>=n))return-r;r=-r,A=-A,n=-n}for(;;){if((i-=(s=Math.floor(n/A))*t)<0)return-r;if(i>t)return r;if(A>(n-=s*A)+n){if(t<i+i)return r}else{if(t>i+i)return-r;n=A-n,i=t-i,r=-r}if(0===i)return 0===n?0:-r;if(0===n)return r;if((t-=(s=Math.floor(A/n))*i)<0)return r;if(t>i)return-r;if(n>(A-=s*n)+A){if(i<t+t)return-r}else{if(i>t+t)return r;A=n-A,t=i-t,r=-r}if(0===t)return 0===A?0:r;if(0===A)return-r}};var oi=function(){this.un=null,this.hn=0,this.cn=!1;var A=arguments[0];this.un=A};oi.prototype.countSegment=function(A,t){if(A.x<this.un.x&&t.x<this.un.x)return null;if(this.un.x===t.x&&this.un.y===t.y)return this.cn=!0,null;if(A.y===this.un.y&&t.y===this.un.y){var n=A.x,i=t.x;return n>i&&(n=t.x,i=A.x),this.un.x>=n&&this.un.x<=i&&(this.cn=!0),null}if(A.y>this.un.y&&t.y<=this.un.y||t.y>this.un.y&&A.y<=this.un.y){var e=A.y-this.un.y,u=t.y-this.un.y,o=ui.signOfDet2x2(A.x-this.un.x,e,t.x-this.un.x,u);if(0===o)return this.cn=!0,null;u<e&&(o=-o),o>0&&this.hn++}},oi.prototype.isPointInPolygon=function(){return this.getLocation()!==Tn.EXTERIOR},oi.prototype.getLocation=function(){return this.cn?Tn.BOUNDARY:this.hn%2==1?Tn.INTERIOR:Tn.EXTERIOR},oi.prototype.isOnSegment=function(){return this.cn},oi.prototype.interfaces_=function(){return[]},oi.prototype.getClass=function(){return oi},oi.locatePointInRing=function(){if(arguments[0]instanceof mn&&Fn(arguments[1],Gn)){for(var A=arguments[0],t=arguments[1],n=new oi(A),i=new mn,r=new mn,e=1;e<t.size();e++)if(t.getCoordinate(e,i),t.getCoordinate(e-1,r),n.countSegment(i,r),n.isOnSegment())return n.getLocation();return n.getLocation()}if(arguments[0]instanceof mn&&arguments[1]instanceof Array){for(var s=arguments[0],u=arguments[1],o=new oi(s),h=1;h<u.length;h++){var f=u[h],c=u[h-1];if(o.countSegment(f,c),o.isOnSegment())return o.getLocation()}return o.getLocation()}};var hi=function(){},fi={CLOCKWISE:{configurable:!0},RIGHT:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},LEFT:{configurable:!0},COLLINEAR:{configurable:!0},STRAIGHT:{configurable:!0}};hi.prototype.interfaces_=function(){return[]},hi.prototype.getClass=function(){return hi},hi.orientationIndex=function(A,t,n){return Bn.orientationIndex(A,t,n)},hi.signedArea=function(){if(arguments[0]instanceof Array){var A=arguments[0];if(A.length<3)return 0;for(var t=0,n=A[0].x,i=1;i<A.length-1;i++){var r=A[i].x-n,e=A[i+1].y,s=A[i-1].y;t+=r*(s-e)}return t/2}if(Fn(arguments[0],Gn)){var u=arguments[0],o=u.size();if(o<3)return 0;var h=new mn,f=new mn,c=new mn;u.getCoordinate(0,f),u.getCoordinate(1,c);var a=f.x;c.x-=a;for(var v=0,l=1;l<o-1;l++)h.y=f.y,f.x=c.x,f.y=c.y,u.getCoordinate(l+1,c),c.x-=a,v+=f.x*(h.y-c.y);return v/2}},hi.distanceLineLine=function(A,t,n,i){if(A.equals(t))return hi.distancePointLine(A,n,i);if(n.equals(i))return hi.distancePointLine(i,A,t);var r=!1;if(Kn.intersects(A,t,n,i)){var e=(t.x-A.x)*(i.y-n.y)-(t.y-A.y)*(i.x-n.x);if(0===e)r=!0;else{var u=((A.y-n.y)*(t.x-A.x)-(A.x-n.x)*(t.y-A.y))/e,o=((A.y-n.y)*(i.x-n.x)-(A.x-n.x)*(i.y-n.y))/e;(o<0||o>1||u<0||u>1)&&(r=!0)}}else r=!0;return r?Un.min(hi.distancePointLine(A,n,i),hi.distancePointLine(t,n,i),hi.distancePointLine(n,A,t),hi.distancePointLine(i,A,t)):0},hi.isPointInRing=function(A,t){return hi.locatePointInRing(A,t)!==Tn.EXTERIOR},hi.computeLength=function(A){var t=A.size();if(t<=1)return 0;var n=0,i=new mn;A.getCoordinate(0,i);for(var r=i.x,e=i.y,s=1;s<t;s++){A.getCoordinate(s,i);var u=i.x,o=i.y,h=u-r,f=o-e;n+=Math.sqrt(h*h+f*f),r=u,e=o}return n},hi.isCCW=function(A){var t=A.length-1;if(t<3)throw new Dn("Ring has fewer than 4 points, so orientation cannot be determined");for(var n=A[0],i=0,r=1;r<=t;r++){var e=A[r];e.y>n.y&&(n=e,i=r)}var s=i;do{(s-=1)<0&&(s=t)}while(A[s].equals2D(n)&&s!==i);var u=i;do{u=(u+1)%t}while(A[u].equals2D(n)&&u!==i);var o=A[s],h=A[u];if(o.equals2D(n)||h.equals2D(n)||o.equals2D(h))return!1;var f=hi.computeOrientation(o,n,h);return 0===f?o.x>h.x:f>0},hi.locatePointInRing=function(A,t){return oi.locatePointInRing(A,t)},hi.distancePointLinePerpendicular=function(A,t,n){var i=(n.x-t.x)*(n.x-t.x)+(n.y-t.y)*(n.y-t.y);return Math.abs(((t.y-A.y)*(n.x-t.x)-(t.x-A.x)*(n.y-t.y))/i)*Math.sqrt(i)},hi.computeOrientation=function(A,t,n){return hi.orientationIndex(A,t,n)},hi.distancePointLine=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1];if(0===t.length)throw new Dn("Line array must contain at least one vertex");for(var n=A.distance(t[0]),i=0;i<t.length-1;i++){var r=hi.distancePointLine(A,t[i],t[i+1]);r<n&&(n=r)}return n}if(3===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2];if(s.x===u.x&&s.y===u.y)return e.distance(s);var o=(u.x-s.x)*(u.x-s.x)+(u.y-s.y)*(u.y-s.y),h=((e.x-s.x)*(u.x-s.x)+(e.y-s.y)*(u.y-s.y))/o;if(h<=0)return e.distance(s);if(h>=1)return e.distance(u);var f=((s.y-e.y)*(u.x-s.x)-(s.x-e.x)*(u.y-s.y))/o;return Math.abs(f)*Math.sqrt(o)}},hi.isOnLine=function(A,t){for(var n=new si,i=1;i<t.length;i++){if(n.computeIntersection(A,t[i-1],t[i]),n.hasIntersection())return!0}return!1},fi.CLOCKWISE.get=function(){return-1},fi.RIGHT.get=function(){return hi.CLOCKWISE},fi.COUNTERCLOCKWISE.get=function(){return 1},fi.LEFT.get=function(){return hi.COUNTERCLOCKWISE},fi.COLLINEAR.get=function(){return 0},fi.STRAIGHT.get=function(){return hi.COLLINEAR},Object.defineProperties(hi,fi);var ci=function(){};ci.prototype.filter=function(A){},ci.prototype.interfaces_=function(){return[]},ci.prototype.getClass=function(){return ci};var ai=function(){var A=arguments[0];this.an=null,this.vn=null,this.ln=null,this.wn=null,this.vn=A,this.ln=A.getSRID()},vi={serialVersionUID:{configurable:!0},SORTINDEX_POINT:{configurable:!0},SORTINDEX_MULTIPOINT:{configurable:!0},SORTINDEX_LINESTRING:{configurable:!0},SORTINDEX_LINEARRING:{configurable:!0},SORTINDEX_MULTILINESTRING:{configurable:!0},SORTINDEX_POLYGON:{configurable:!0},SORTINDEX_MULTIPOLYGON:{configurable:!0},SORTINDEX_GEOMETRYCOLLECTION:{configurable:!0},geometryChangedFilter:{configurable:!0}};ai.prototype.isGeometryCollection=function(){return this.getSortIndex()===ai.SORTINDEX_GEOMETRYCOLLECTION},ai.prototype.getFactory=function(){return this.vn},ai.prototype.getGeometryN=function(A){return this},ai.prototype.getArea=function(){return 0},ai.prototype.isRectangle=function(){return!1},ai.prototype.equals=function(){if(arguments[0]instanceof ai){var A=arguments[0];return null!==A&&this.equalsTopo(A)}if(arguments[0]instanceof Object){var t=arguments[0];if(!(t instanceof ai))return!1;var n=t;return this.equalsExact(n)}},ai.prototype.equalsExact=function(A){return this===A||this.equalsExact(A,0)},ai.prototype.geometryChanged=function(){this.apply(ai.geometryChangedFilter)},ai.prototype.geometryChangedAction=function(){this.an=null},ai.prototype.equalsNorm=function(A){return null!==A&&this.norm().equalsExact(A.norm())},ai.prototype.getLength=function(){return 0},ai.prototype.getNumGeometries=function(){return 1},ai.prototype.compareTo=function(){if(1===arguments.length){var A=arguments[0],t=A;return this.getSortIndex()!==t.getSortIndex()?this.getSortIndex()-t.getSortIndex():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(A)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return this.getSortIndex()!==n.getSortIndex()?this.getSortIndex()-n.getSortIndex():this.isEmpty()&&n.isEmpty()?0:this.isEmpty()?-1:n.isEmpty()?1:this.compareToSameClass(n,i)}},ai.prototype.getUserData=function(){return this.wn},ai.prototype.getSRID=function(){return this.ln},ai.prototype.getEnvelope=function(){return this.getFactory().toGeometry(this.getEnvelopeInternal())},ai.prototype.checkNotGeometryCollection=function(A){if(A.getSortIndex()===ai.SORTINDEX_GEOMETRYCOLLECTION)throw new Dn("This method does not support GeometryCollection arguments")},ai.prototype.equal=function(A,t,n){return 0===n?A.equals(t):A.distance(t)<=n},ai.prototype.norm=function(){var A=this.copy();return A.normalize(),A},ai.prototype.getPrecisionModel=function(){return this.vn.getPrecisionModel()},ai.prototype.getEnvelopeInternal=function(){return null===this.an&&(this.an=this.computeEnvelopeInternal()),new Kn(this.an)},ai.prototype.setSRID=function(A){this.ln=A},ai.prototype.setUserData=function(A){this.wn=A},ai.prototype.compare=function(A,t){for(var n=A.iterator(),i=t.iterator();n.hasNext()&&i.hasNext();){var r=n.next(),e=i.next(),s=r.compareTo(e);if(0!==s)return s}return n.hasNext()?1:i.hasNext()?-1:0},ai.prototype.hashCode=function(){return this.getEnvelopeInternal().hashCode()},ai.prototype.isGeometryCollectionOrDerived=function(){return this.getSortIndex()===ai.SORTINDEX_GEOMETRYCOLLECTION||this.getSortIndex()===ai.SORTINDEX_MULTIPOINT||this.getSortIndex()===ai.SORTINDEX_MULTILINESTRING||this.getSortIndex()===ai.SORTINDEX_MULTIPOLYGON},ai.prototype.interfaces_=function(){return[zn,bn,xn]},ai.prototype.getClass=function(){return ai},ai.hasNonEmptyElements=function(A){for(var t=0;t<A.length;t++)if(!A[t].isEmpty())return!0;return!1},ai.hasNullElements=function(A){for(var t=0;t<A.length;t++)if(null===A[t])return!0;return!1},vi.serialVersionUID.get=function(){return 0x799ea46522854c00},vi.SORTINDEX_POINT.get=function(){return 0},vi.SORTINDEX_MULTIPOINT.get=function(){return 1},vi.SORTINDEX_LINESTRING.get=function(){return 2},vi.SORTINDEX_LINEARRING.get=function(){return 3},vi.SORTINDEX_MULTILINESTRING.get=function(){return 4},vi.SORTINDEX_POLYGON.get=function(){return 5},vi.SORTINDEX_MULTIPOLYGON.get=function(){return 6},vi.SORTINDEX_GEOMETRYCOLLECTION.get=function(){return 7},vi.geometryChangedFilter.get=function(){return li},Object.defineProperties(ai,vi);var li=function(){};li.interfaces_=function(){return[ci]},li.filter=function(A){A.geometryChangedAction()};var wi=function(){};wi.prototype.filter=function(A){},wi.prototype.interfaces_=function(){return[]},wi.prototype.getClass=function(){return wi};var Pi=function(){},gi={Mod2BoundaryNodeRule:{configurable:!0},EndPointBoundaryNodeRule:{configurable:!0},MultiValentEndPointBoundaryNodeRule:{configurable:!0},MonoValentEndPointBoundaryNodeRule:{configurable:!0},MOD2_BOUNDARY_RULE:{configurable:!0},ENDPOINT_BOUNDARY_RULE:{configurable:!0},MULTIVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},MONOVALENT_ENDPOINT_BOUNDARY_RULE:{configurable:!0},OGC_SFS_BOUNDARY_RULE:{configurable:!0}};Pi.prototype.isInBoundary=function(A){},Pi.prototype.interfaces_=function(){return[]},Pi.prototype.getClass=function(){return Pi},gi.Mod2BoundaryNodeRule.get=function(){return Ci},gi.EndPointBoundaryNodeRule.get=function(){return Di},gi.MultiValentEndPointBoundaryNodeRule.get=function(){return Ii},gi.MonoValentEndPointBoundaryNodeRule.get=function(){return Mi},gi.MOD2_BOUNDARY_RULE.get=function(){return new Ci},gi.ENDPOINT_BOUNDARY_RULE.get=function(){return new Di},gi.MULTIVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new Ii},gi.MONOVALENT_ENDPOINT_BOUNDARY_RULE.get=function(){return new Mi},gi.OGC_SFS_BOUNDARY_RULE.get=function(){return Pi.MOD2_BOUNDARY_RULE},Object.defineProperties(Pi,gi);var Ci=function(){};Ci.prototype.isInBoundary=function(A){return A%2==1},Ci.prototype.interfaces_=function(){return[Pi]},Ci.prototype.getClass=function(){return Ci};var Di=function(){};Di.prototype.isInBoundary=function(A){return A>0},Di.prototype.interfaces_=function(){return[Pi]},Di.prototype.getClass=function(){return Di};var Ii=function(){};Ii.prototype.isInBoundary=function(A){return A>1},Ii.prototype.interfaces_=function(){return[Pi]},Ii.prototype.getClass=function(){return Ii};var Mi=function(){};Mi.prototype.isInBoundary=function(A){return 1===A},Mi.prototype.interfaces_=function(){return[Pi]},Mi.prototype.getClass=function(){return Mi};var bi=function(){};function zi(A){this.message=A||""}bi.prototype.add=function(){},bi.prototype.addAll=function(){},bi.prototype.isEmpty=function(){},bi.prototype.iterator=function(){},bi.prototype.size=function(){},bi.prototype.toArray=function(){},bi.prototype.remove=function(){},(zi.prototype=new Error).name="IndexOutOfBoundsException";var di=function(){};di.prototype.hasNext=function(){},di.prototype.next=function(){},di.prototype.remove=function(){};var xi=function(A){function t(){A.apply(this,arguments)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.get=function(){},t.prototype.set=function(){},t.prototype.isEmpty=function(){},t}(bi);function mi(A){this.message=A||""}(mi.prototype=new Error).name="NoSuchElementException";var yi=function(A){function t(){A.call(this),this.array_=[],arguments[0]instanceof bi&&this.addAll(arguments[0])}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.ensureCapacity=function(){},t.prototype.interfaces_=function(){return[A,bi]},t.prototype.add=function(A){return 1===arguments.length?this.array_.push(A):this.array_.splice(arguments[0],arguments[1]),!0},t.prototype.clear=function(){this.array_=[]},t.prototype.addAll=function(A){for(var t=A.iterator();t.hasNext();)this.add(t.next());return!0},t.prototype.set=function(A,t){var n=this.array_[A];return this.array_[A]=t,n},t.prototype.iterator=function(){return new pi(this)},t.prototype.get=function(A){if(A<0||A>=this.size())throw new zi;return this.array_[A]},t.prototype.isEmpty=function(){return 0===this.array_.length},t.prototype.size=function(){return this.array_.length},t.prototype.toArray=function(){for(var A=[],t=0,n=this.array_.length;t<n;t++)A.push(this.array_[t]);return A},t.prototype.remove=function(A){for(var t=!1,n=0,i=this.array_.length;n<i;n++)if(this.array_[n]===A){this.array_.splice(n,1),t=!0;break}return t},t}(xi),pi=function(A){function t(t){A.call(this),this.arrayList_=t,this.position_=0}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.next=function(){if(this.position_===this.arrayList_.size())throw new mi;return this.arrayList_.get(this.position_++)},t.prototype.hasNext=function(){return this.position_<this.arrayList_.size()},t.prototype.set=function(A){return this.arrayList_.set(this.position_-1,A)},t.prototype.remove=function(){this.arrayList_.remove(this.arrayList_.get(this.position_))},t}(di),Li=function(A){function t(){if(A.call(this),0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.ensureCapacity(n.length),this.add(n,i)}}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={coordArrayType:{configurable:!0}};return n.coordArrayType.get=function(){return new Array(0).fill(null)},t.prototype.getCoordinate=function(A){return this.get(A)},t.prototype.addAll=function(){var t=this;if(2===arguments.length){for(var n=arguments[0],i=arguments[1],r=!1,e=n.iterator();e.hasNext();)t.add(e.next(),i),r=!0;return r}return A.prototype.addAll.apply(this,arguments)},t.prototype.clone=function(){for(var t=A.prototype.clone.call(this),n=0;n<this.size();n++)t.add(n,this.get(n).copy());return t},t.prototype.toCoordinateArray=function(){return this.toArray(t.coordArrayType)},t.prototype.add=function(){var t=this;if(1===arguments.length){var n=arguments[0];A.prototype.add.call(this,n)}else if(2===arguments.length){if(arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var i=arguments[0],r=arguments[1];return this.add(i,r,!0),!0}if(arguments[0]instanceof mn&&"boolean"==typeof arguments[1]){var e=arguments[0],s=arguments[1];if(!s&&this.size()>=1){var u=this.get(this.size()-1);if(u.equals2D(e))return null}A.prototype.add.call(this,e)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],h=arguments[1];return this.add(o,h),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var f=arguments[0],c=arguments[1],a=arguments[2];if(a)for(var v=0;v<f.length;v++)t.add(f[v],c);else for(var l=f.length-1;l>=0;l--)t.add(f[l],c);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof mn){var w=arguments[0],P=arguments[1],g=arguments[2];if(!g){var C=this.size();if(C>0){if(w>0){var D=this.get(w-1);if(D.equals2D(P))return null}if(w<C){var I=this.get(w);if(I.equals2D(P))return null}}}A.prototype.add.call(this,w,P)}}else if(4===arguments.length){var M=arguments[0],b=arguments[1],z=arguments[2],d=arguments[3],x=1;z>d&&(x=-1);for(var m=z;m!==d;m+=x)t.add(M[m],b);return!0}},t.prototype.closeRing=function(){this.size()>0&&this.add(new mn(this.get(0)),!1)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},Object.defineProperties(t,n),t}(yi),Ti=function(){},Oi={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Oi.ForwardComparator.get=function(){return Fi},Oi.BidirectionalComparator.get=function(){return Ui},Oi.coordArrayType.get=function(){return new Array(0).fill(null)},Ti.prototype.interfaces_=function(){return[]},Ti.prototype.getClass=function(){return Ti},Ti.isRing=function(A){return!(A.length<4||!A[0].equals2D(A[A.length-1]))},Ti.ptNotInList=function(A,t){for(var n=0;n<A.length;n++){var i=A[n];if(Ti.indexOf(i,t)<0)return i}return null},Ti.scroll=function(A,t){var n=Ti.indexOf(t,A);if(n<0)return null;var i=new Array(A.length).fill(null);Wn.arraycopy(A,n,i,0,A.length-n),Wn.arraycopy(A,0,i,A.length-n,n),Wn.arraycopy(i,0,A,0,A.length)},Ti.equals=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1];if(A===t)return!0;if(null===A||null===t)return!1;if(A.length!==t.length)return!1;for(var n=0;n<A.length;n++)if(!A[n].equals(t[n]))return!1;return!0}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2];if(i===r)return!0;if(null===i||null===r)return!1;if(i.length!==r.length)return!1;for(var s=0;s<i.length;s++)if(0!==e.compare(i[s],r[s]))return!1;return!0}},Ti.intersection=function(A,t){for(var n=new Li,i=0;i<A.length;i++)t.intersects(A[i])&&n.add(A[i],!0);return n.toCoordinateArray()},Ti.hasRepeatedPoints=function(A){for(var t=1;t<A.length;t++)if(A[t-1].equals(A[t]))return!0;return!1},Ti.removeRepeatedPoints=function(A){return Ti.hasRepeatedPoints(A)?new Li(A,!1).toCoordinateArray():A},Ti.reverse=function(A){for(var t=A.length-1,n=Math.trunc(t/2),i=0;i<=n;i++){var r=A[i];A[i]=A[t-i],A[t-i]=r}},Ti.removeNull=function(A){for(var t=0,n=0;n<A.length;n++)null!==A[n]&&t++;var i=new Array(t).fill(null);if(0===t)return i;for(var r=0,e=0;e<A.length;e++)null!==A[e]&&(i[r++]=A[e]);return i},Ti.copyDeep=function(){if(1===arguments.length){for(var A=arguments[0],t=new Array(A.length).fill(null),n=0;n<A.length;n++)t[n]=new mn(A[n]);return t}if(5===arguments.length)for(var i=arguments[0],r=arguments[1],e=arguments[2],s=arguments[3],u=arguments[4],o=0;o<u;o++)e[s+o]=new mn(i[r+o])},Ti.isEqualReversed=function(A,t){for(var n=0;n<A.length;n++){if(0!==A[n].compareTo(t[A.length-n-1]))return!1}return!0},Ti.envelope=function(A){for(var t=new Kn,n=0;n<A.length;n++)t.expandToInclude(A[n]);return t},Ti.toCoordinateArray=function(A){return A.toArray(Ti.coordArrayType)},Ti.atLeastNCoordinatesOrNothing=function(A,t){return t.length>=A?t:[]},Ti.indexOf=function(A,t){for(var n=0;n<t.length;n++)if(A.equals(t[n]))return n;return-1},Ti.increasingDirection=function(A){for(var t=0;t<Math.trunc(A.length/2);t++){var i=A[t].compareTo(A[A.length-1-t]);if(0!==i)return i}return 1},Ti.compare=function(A,t){for(var n=0;n<A.length&&n<t.length;){var i=A[n].compareTo(t[n]);if(0!==i)return i;n++}return n<t.length?-1:n<A.length?1:0},Ti.minCoordinate=function(A){for(var t=null,n=0;n<A.length;n++)(null===t||t.compareTo(A[n])>0)&&(t=A[n]);return t},Ti.extract=function(A,t,n){t=Un.clamp(t,0,A.length);var i=(n=Un.clamp(n,-1,A.length))-t+1;n<0&&(i=0),t>=A.length&&(i=0),n<t&&(i=0);var r=new Array(i).fill(null);if(0===i)return r;for(var e=0,s=t;s<=n;s++)r[e++]=A[s];return r},Object.defineProperties(Ti,Oi);var Fi=function(){};Fi.prototype.compare=function(A,t){return Ti.compare(A,t)},Fi.prototype.interfaces_=function(){return[dn]},Fi.prototype.getClass=function(){return Fi};var Ui=function(){};Ui.prototype.compare=function(A,t){var n=A,i=t;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;var r=Ti.compare(n,i);return Ti.isEqualReversed(n,i)?0:r},Ui.prototype.OLDcompare=function(A,t){var n=A,i=t;if(n.length<i.length)return-1;if(n.length>i.length)return 1;if(0===n.length)return 0;for(var r=Ti.increasingDirection(n),e=Ti.increasingDirection(i),s=r>0?0:n.length-1,u=e>0?0:n.length-1,o=0;o<n.length;o++){var h=n[s].compareTo(i[u]);if(0!==h)return h;s+=r,u+=e}return 0},Ui.prototype.interfaces_=function(){return[dn]},Ui.prototype.getClass=function(){return Ui};var Ei=function(){};Ei.prototype.get=function(){},Ei.prototype.put=function(){},Ei.prototype.size=function(){},Ei.prototype.values=function(){},Ei.prototype.entrySet=function(){};var Ni=function(A){function t(){A.apply(this,arguments)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t}(Ei);function ji(A){this.message=A||""}function Qi(){}(ji.prototype=new Error).name="OperationNotSupported",(Qi.prototype=new bi).contains=function(){};var Si=function(A){function t(){A.call(this),this.array_=[],arguments[0]instanceof bi&&this.addAll(arguments[0])}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.contains=function(A){for(var t=0,n=this.array_.length;t<n;t++)if(this.array_[t]===A)return!0;return!1},t.prototype.add=function(A){return!this.contains(A)&&(this.array_.push(A),!0)},t.prototype.addAll=function(A){for(var t=A.iterator();t.hasNext();)this.add(t.next());return!0},t.prototype.remove=function(A){throw new Error},t.prototype.size=function(){return this.array_.length},t.prototype.isEmpty=function(){return 0===this.array_.length},t.prototype.toArray=function(){for(var A=[],t=0,n=this.array_.length;t<n;t++)A.push(this.array_[t]);return A},t.prototype.iterator=function(){return new ki(this)},t}(Qi),ki=function(A){function t(t){A.call(this),this.hashSet_=t,this.position_=0}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.next=function(){if(this.position_===this.hashSet_.size())throw new mi;return this.hashSet_.array_[this.position_++]},t.prototype.hasNext=function(){return this.position_<this.hashSet_.size()},t.prototype.remove=function(){throw new ji},t}(di);function Bi(A){return null===A?0:A.color}function Ri(A){return null===A?null:A.parent}function Gi(A,t){null!==A&&(A.color=t)}function Yi(A){return null===A?null:A.left}function qi(A){return null===A?null:A.right}function Vi(){this.root_=null,this.size_=0}(Vi.prototype=new Ni).get=function(A){for(var t=this.root_;null!==t;){var n=A.compareTo(t.key);if(n<0)t=t.left;else{if(!(n>0))return t.value;t=t.right}}return null},Vi.prototype.put=function(A,t){if(null===this.root_)return this.root_={key:A,value:t,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=A.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var e=r.value;return r.value=t,e}r=r.right}}while(null!==r);var s={key:A,left:null,right:null,value:t,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null},Vi.prototype.fixAfterInsertion=function(A){for(A.color=1;null!=A&&A!==this.root_&&1===A.parent.color;)if(Ri(A)===Yi(Ri(Ri(A)))){var t=qi(Ri(Ri(A)));1===Bi(t)?(Gi(Ri(A),0),Gi(t,0),Gi(Ri(Ri(A)),1),A=Ri(Ri(A))):(A===qi(Ri(A))&&(A=Ri(A),this.rotateLeft(A)),Gi(Ri(A),0),Gi(Ri(Ri(A)),1),this.rotateRight(Ri(Ri(A))))}else{var n=Yi(Ri(Ri(A)));1===Bi(n)?(Gi(Ri(A),0),Gi(n,0),Gi(Ri(Ri(A)),1),A=Ri(Ri(A))):(A===Yi(Ri(A))&&(A=Ri(A),this.rotateRight(A)),Gi(Ri(A),0),Gi(Ri(Ri(A)),1),this.rotateLeft(Ri(Ri(A))))}this.root_.color=0},Vi.prototype.values=function(){var A=new yi,t=this.getFirstEntry();if(null!==t)for(A.add(t.value);null!==(t=Vi.successor(t));)A.add(t.value);return A},Vi.prototype.entrySet=function(){var A=new Si,t=this.getFirstEntry();if(null!==t)for(A.add(t);null!==(t=Vi.successor(t));)A.add(t);return A},Vi.prototype.rotateLeft=function(A){if(null!=A){var t=A.right;A.right=t.left,null!=t.left&&(t.left.parent=A),t.parent=A.parent,null===A.parent?this.root_=t:A.parent.left===A?A.parent.left=t:A.parent.right=t,t.left=A,A.parent=t}},Vi.prototype.rotateRight=function(A){if(null!=A){var t=A.left;A.left=t.right,null!=t.right&&(t.right.parent=A),t.parent=A.parent,null===A.parent?this.root_=t:A.parent.right===A?A.parent.right=t:A.parent.left=t,t.right=A,A.parent=t}},Vi.prototype.getFirstEntry=function(){var A=this.root_;if(null!=A)for(;null!=A.left;)A=A.left;return A},Vi.successor=function(A){if(null===A)return null;if(null!==A.right){for(var t=A.right;null!==t.left;)t=t.left;return t}for(var n=A.parent,i=A;null!==n&&i===n.right;)i=n,n=n.parent;return n},Vi.prototype.size=function(){return this.size_};var Wi=function(){};function _i(){}function Ki(){this.array_=[],arguments[0]instanceof bi&&this.addAll(arguments[0])}Wi.prototype.interfaces_=function(){return[]},Wi.prototype.getClass=function(){return Wi},_i.prototype=new Qi,(Ki.prototype=new _i).contains=function(A){for(var t=0,n=this.array_.length;t<n;t++)if(0===this.array_[t].compareTo(A))return!0;return!1},Ki.prototype.add=function(A){if(this.contains(A))return!1;for(var t=0,n=this.array_.length;t<n;t++)if(1===this.array_[t].compareTo(A))return this.array_.splice(t,0,A),!0;return this.array_.push(A),!0},Ki.prototype.addAll=function(A){for(var t=A.iterator();t.hasNext();)this.add(t.next());return!0},Ki.prototype.remove=function(A){throw new ji},Ki.prototype.size=function(){return this.array_.length},Ki.prototype.isEmpty=function(){return 0===this.array_.length},Ki.prototype.toArray=function(){for(var A=[],t=0,n=this.array_.length;t<n;t++)A.push(this.array_[t]);return A},Ki.prototype.iterator=function(){return new Hi(this)};var Hi=function(A){this.treeSet_=A,this.position_=0};Hi.prototype.next=function(){if(this.position_===this.treeSet_.size())throw new mi;return this.treeSet_.array_[this.position_++]},Hi.prototype.hasNext=function(){return this.position_<this.treeSet_.size()},Hi.prototype.remove=function(){throw new ji};var Ji=function(){};Ji.sort=function(){var A,t,n,i,r=arguments[0];if(1===arguments.length)i=function(A,t){return A.compareTo(t)},r.sort(i);else if(2===arguments.length)n=arguments[1],i=function(A,t){return n.compare(A,t)},r.sort(i);else if(3===arguments.length){(t=r.slice(arguments[1],arguments[2])).sort();var e=r.slice(0,arguments[1]).concat(t,r.slice(arguments[2],r.length));for(r.splice(0,r.length),A=0;A<e.length;A++)r.push(e[A])}else if(4===arguments.length)for(t=r.slice(arguments[1],arguments[2]),n=arguments[3],i=function(A,t){return n.compare(A,t)},t.sort(i),e=r.slice(0,arguments[1]).concat(t,r.slice(arguments[2],r.length)),r.splice(0,r.length),A=0;A<e.length;A++)r.push(e[A])},Ji.asList=function(A){for(var t=new yi,n=0,i=A.length;n<i;n++)t.add(A[n]);return t};var Zi=function(){},Xi={P:{configurable:!0},L:{configurable:!0},A:{configurable:!0},FALSE:{configurable:!0},TRUE:{configurable:!0},DONTCARE:{configurable:!0},SYM_FALSE:{configurable:!0},SYM_TRUE:{configurable:!0},SYM_DONTCARE:{configurable:!0},SYM_P:{configurable:!0},SYM_L:{configurable:!0},SYM_A:{configurable:!0}};Xi.P.get=function(){return 0},Xi.L.get=function(){return 1},Xi.A.get=function(){return 2},Xi.FALSE.get=function(){return-1},Xi.TRUE.get=function(){return-2},Xi.DONTCARE.get=function(){return-3},Xi.SYM_FALSE.get=function(){return"F"},Xi.SYM_TRUE.get=function(){return"T"},Xi.SYM_DONTCARE.get=function(){return"*"},Xi.SYM_P.get=function(){return"0"},Xi.SYM_L.get=function(){return"1"},Xi.SYM_A.get=function(){return"2"},Zi.prototype.interfaces_=function(){return[]},Zi.prototype.getClass=function(){return Zi},Zi.toDimensionSymbol=function(A){switch(A){case Zi.FALSE:return Zi.SYM_FALSE;case Zi.TRUE:return Zi.SYM_TRUE;case Zi.DONTCARE:return Zi.SYM_DONTCARE;case Zi.P:return Zi.SYM_P;case Zi.L:return Zi.SYM_L;case Zi.A:return Zi.SYM_A}throw new Dn("Unknown dimension value: "+A)},Zi.toDimensionValue=function(A){switch(Qn.toUpperCase(A)){case Zi.SYM_FALSE:return Zi.FALSE;case Zi.SYM_TRUE:return Zi.TRUE;case Zi.SYM_DONTCARE:return Zi.DONTCARE;case Zi.SYM_P:return Zi.P;case Zi.SYM_L:return Zi.L;case Zi.SYM_A:return Zi.A}throw new Dn("Unknown dimension symbol: "+A)},Object.defineProperties(Zi,Xi);var $i=function(){};$i.prototype.filter=function(A){},$i.prototype.interfaces_=function(){return[]},$i.prototype.getClass=function(){return $i};var Ar=function(){};Ar.prototype.filter=function(A,t){},Ar.prototype.isDone=function(){},Ar.prototype.isGeometryChanged=function(){},Ar.prototype.interfaces_=function(){return[]},Ar.prototype.getClass=function(){return Ar};var tr=function(A){function t(t,n){if(A.call(this,n),this.Ht=t||[],A.hasNullElements(this.Ht))throw new Dn("geometries must not contain null elements")}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.computeEnvelopeInternal=function(){for(var A=new Kn,t=0;t<this.Ht.length;t++)A.expandToInclude(this.Ht[t].getEnvelopeInternal());return A},t.prototype.getGeometryN=function(A){return this.Ht[A]},t.prototype.getSortIndex=function(){return A.SORTINDEX_GEOMETRYCOLLECTION},t.prototype.getCoordinates=function(){for(var A=new Array(this.getNumPoints()).fill(null),t=-1,n=0;n<this.Ht.length;n++)for(var i=this.Ht[n].getCoordinates(),r=0;r<i.length;r++)A[++t]=i[r];return A},t.prototype.getArea=function(){for(var A=0,t=0;t<this.Ht.length;t++)A+=this.Ht[t].getArea();return A},t.prototype.equalsExact=function(){var t=this;if(2===arguments.length){var n=arguments[0],i=arguments[1];if(!this.isEquivalentClass(n))return!1;var r=n;if(this.Ht.length!==r.Ht.length)return!1;for(var e=0;e<this.Ht.length;e++)if(!t.Ht[e].equalsExact(r.Ht[e],i))return!1;return!0}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.normalize=function(){for(var A=0;A<this.Ht.length;A++)this.Ht[A].normalize();Ji.sort(this.Ht)},t.prototype.getCoordinate=function(){return this.isEmpty()?null:this.Ht[0].getCoordinate()},t.prototype.getBoundaryDimension=function(){for(var A=Zi.FALSE,t=0;t<this.Ht.length;t++)A=Math.max(A,this.Ht[t].getBoundaryDimension());return A},t.prototype.getDimension=function(){for(var A=Zi.FALSE,t=0;t<this.Ht.length;t++)A=Math.max(A,this.Ht[t].getDimension());return A},t.prototype.getLength=function(){for(var A=0,t=0;t<this.Ht.length;t++)A+=this.Ht[t].getLength();return A},t.prototype.getNumPoints=function(){for(var A=0,t=0;t<this.Ht.length;t++)A+=this.Ht[t].getNumPoints();return A},t.prototype.getNumGeometries=function(){return this.Ht.length},t.prototype.reverse=function(){for(var t=new Array(this.Ht.length).fill(null),n=0;n<this.Ht.length;n++)t[n]=this.Ht[n].reverse();return this.getFactory().createGeometryCollection(t)},t.prototype.compareToSameClass=function(){var A=this;if(1===arguments.length){var t=arguments[0],n=new Ki(Ji.asList(this.Ht)),i=new Ki(Ji.asList(t.Ht));return this.compare(n,i)}if(2===arguments.length){for(var r=arguments[0],e=arguments[1],s=r,u=this.getNumGeometries(),o=s.getNumGeometries(),h=0;h<u&&h<o;){var f=A.getGeometryN(h),c=s.getGeometryN(h),a=f.compareToSameClass(c,e);if(0!==a)return a;h++}return h<u?1:h<o?-1:0}},t.prototype.apply=function(){var A=this;if(Fn(arguments[0],wi))for(var t=arguments[0],n=0;n<this.Ht.length;n++)A.Ht[n].apply(t);else if(Fn(arguments[0],Ar)){var i=arguments[0];if(0===this.Ht.length)return null;for(var r=0;r<this.Ht.length&&(A.Ht[r].apply(i),!i.isDone());r++);i.isGeometryChanged()&&this.geometryChanged()}else if(Fn(arguments[0],$i)){var e=arguments[0];e.filter(this);for(var s=0;s<this.Ht.length;s++)A.Ht[s].apply(e)}else if(Fn(arguments[0],ci)){var u=arguments[0];u.filter(this);for(var o=0;o<this.Ht.length;o++)A.Ht[o].apply(u)}},t.prototype.getBoundary=function(){return this.checkNotGeometryCollection(this),ii.shouldNeverReachHere(),null},t.prototype.clone=function(){var t=A.prototype.clone.call(this);t.Ht=new Array(this.Ht.length).fill(null);for(var n=0;n<this.Ht.length;n++)t.Ht[n]=this.Ht[n].clone();return t},t.prototype.getGeometryType=function(){return"GeometryCollection"},t.prototype.copy=function(){for(var A=new Array(this.Ht.length).fill(null),n=0;n<A.length;n++)A[n]=this.Ht[n].copy();return new t(A,this.vn)},t.prototype.isEmpty=function(){for(var A=0;A<this.Ht.length;A++)if(!this.Ht[A].isEmpty())return!1;return!0},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return-0x4f07bcb1f857d800},Object.defineProperties(t,n),t}(ai),nr=function(A){function t(){A.apply(this,arguments)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.getSortIndex=function(){return ai.SORTINDEX_MULTILINESTRING},t.prototype.equalsExact=function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];return!!this.isEquivalentClass(t)&&A.prototype.equalsExact.call(this,t,n)}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.getBoundaryDimension=function(){return this.isClosed()?Zi.FALSE:0},t.prototype.isClosed=function(){if(this.isEmpty())return!1;for(var A=0;A<this.Ht.length;A++)if(!this.Ht[A].isClosed())return!1;return!0},t.prototype.getDimension=function(){return 1},t.prototype.reverse=function(){for(var A=this.Ht.length,t=new Array(A).fill(null),n=0;n<this.Ht.length;n++)t[A-1-n]=this.Ht[n].reverse();return this.getFactory().createMultiLineString(t)},t.prototype.getBoundary=function(){return new ir(this).getBoundary()},t.prototype.getGeometryType=function(){return"MultiLineString"},t.prototype.copy=function(){for(var A=new Array(this.Ht.length).fill(null),n=0;n<A.length;n++)A[n]=this.Ht[n].copy();return new t(A,this.vn)},t.prototype.interfaces_=function(){return[Wi]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return 0x7155d2ab4afa8000},Object.defineProperties(t,n),t}(tr),ir=function(){if(this.Pn=null,this.gn=null,this.Cn=null,this.Dn=null,1===arguments.length){var A=arguments[0],t=Pi.MOD2_BOUNDARY_RULE;this.Pn=A,this.gn=A.getFactory(),this.Cn=t}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.Pn=n,this.gn=n.getFactory(),this.Cn=i}};ir.prototype.boundaryMultiLineString=function(A){if(this.Pn.isEmpty())return this.getEmptyMultiPoint();var t=this.computeBoundaryCoordinates(A);return 1===t.length?this.gn.createPoint(t[0]):this.gn.createMultiPointFromCoords(t)},ir.prototype.getBoundary=function(){return this.Pn instanceof lr?this.boundaryLineString(this.Pn):this.Pn instanceof nr?this.boundaryMultiLineString(this.Pn):this.Pn.getBoundary()},ir.prototype.boundaryLineString=function(A){return this.Pn.isEmpty()?this.getEmptyMultiPoint():A.isClosed()?this.Cn.isInBoundary(2)?A.getStartPoint():this.gn.createMultiPoint():this.gn.createMultiPoint([A.getStartPoint(),A.getEndPoint()])},ir.prototype.getEmptyMultiPoint=function(){return this.gn.createMultiPoint()},ir.prototype.computeBoundaryCoordinates=function(A){var t=new yi;this.Dn=new Vi;for(var n=0;n<A.getNumGeometries();n++){var i=A.getGeometryN(n);0!==i.getNumPoints()&&(this.addEndpoint(i.getCoordinateN(0)),this.addEndpoint(i.getCoordinateN(i.getNumPoints()-1)))}for(var r=this.Dn.entrySet().iterator();r.hasNext();){var e=r.next(),s=e.getValue().count;this.Cn.isInBoundary(s)&&t.add(e.getKey())}return Ti.toCoordinateArray(t)},ir.prototype.addEndpoint=function(A){var t=this.Dn.get(A);null===t&&(t=new rr,this.Dn.put(A,t)),t.count++},ir.prototype.interfaces_=function(){return[]},ir.prototype.getClass=function(){return ir},ir.getBoundary=function(){if(1===arguments.length){var A=arguments[0],t=new ir(A);return t.getBoundary()}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=new ir(n,i);return r.getBoundary()}};var rr=function(){this.count=null};function er(){}function sr(){}rr.prototype.interfaces_=function(){return[]},rr.prototype.getClass=function(){return rr};var ur=function(){};function or(){}function hr(){}function fr(){}var cr=function(){},ar={NEWLINE:{configurable:!0},SIMPLE_ORDINATE_FORMAT:{configurable:!0}};cr.prototype.interfaces_=function(){return[]},cr.prototype.getClass=function(){return cr},cr.chars=function(A,t){for(var n=new Array(t).fill(null),i=0;i<t;i++)n[i]=A;return String(n)},cr.getStackTrace=function(){if(1===arguments.length){var A=arguments[0],t=new or,n=new er;return A.printStackTrace(n),t.toString()}if(2===arguments.length){var i=arguments[0],r=arguments[1],e="";new sr(cr.getStackTrace(i));for(var s=new fr,u=0;u<r;u++)try{e+=s.readLine()+cr.NEWLINE}catch(A){if(!(A instanceof hr))throw A;ii.shouldNeverReachHere()}return e}},cr.split=function(A,t){for(var n=t.length,i=new yi,r=""+A,e=r.indexOf(t);e>=0;){var s=r.substring(0,e);i.add(s),e=(r=r.substring(e+n)).indexOf(t)}r.length>0&&i.add(r);for(var u=new Array(i.size()).fill(null),o=0;o<u.length;o++)u[o]=i.get(o);return u},cr.toString=function(){if(1===arguments.length){var A=arguments[0];return cr.SIMPLE_ORDINATE_FORMAT.format(A)}},cr.spaces=function(A){return cr.chars(" ",A)},ar.NEWLINE.get=function(){return Wn.getProperty("line.separator")},ar.SIMPLE_ORDINATE_FORMAT.get=function(){return new ur},Object.defineProperties(cr,ar);var vr=function(){};vr.prototype.interfaces_=function(){return[]},vr.prototype.getClass=function(){return vr},vr.copyCoord=function(A,t,n,i){for(var r=Math.min(A.getDimension(),n.getDimension()),e=0;e<r;e++)n.setOrdinate(i,e,A.getOrdinate(t,e))},vr.isRing=function(A){var t=A.size();return 0===t||!(t<=3)&&A.getOrdinate(0,Gn.X)===A.getOrdinate(t-1,Gn.X)&&A.getOrdinate(0,Gn.Y)===A.getOrdinate(t-1,Gn.Y)},vr.isEqual=function(A,t){var n=A.size();if(n!==t.size())return!1;for(var i=Math.min(A.getDimension(),t.getDimension()),r=0;r<n;r++)for(var e=0;e<i;e++){var s=A.getOrdinate(r,e),u=t.getOrdinate(r,e);if(!(A.getOrdinate(r,e)===t.getOrdinate(r,e)||In.isNaN(s)&&In.isNaN(u)))return!1}return!0},vr.extend=function(A,t,n){var i=A.create(n,t.getDimension()),r=t.size();if(vr.copy(t,0,i,0,r),r>0)for(var e=r;e<n;e++)vr.copy(t,r-1,i,e,1);return i},vr.reverse=function(A){for(var t=A.size()-1,n=Math.trunc(t/2),i=0;i<=n;i++)vr.swap(A,i,t-i)},vr.swap=function(A,t,n){if(t===n)return null;for(var i=0;i<A.getDimension();i++){var r=A.getOrdinate(t,i);A.setOrdinate(t,i,A.getOrdinate(n,i)),A.setOrdinate(n,i,r)}},vr.copy=function(A,t,n,i,r){for(var e=0;e<r;e++)vr.copyCoord(A,t+e,n,i+e)},vr.toString=function(){if(1===arguments.length){var A=arguments[0],t=A.size();if(0===t)return"()";var n=A.getDimension(),i=new Nn;i.append("(");for(var r=0;r<t;r++){r>0&&i.append(" ");for(var e=0;e<n;e++)e>0&&i.append(","),i.append(cr.toString(A.getOrdinate(r,e)))}return i.append(")"),i.toString()}},vr.ensureValidRing=function(A,t){var n=t.size();return 0===n?t:n<=3?vr.createClosedRing(A,t,4):t.getOrdinate(0,Gn.X)===t.getOrdinate(n-1,Gn.X)&&t.getOrdinate(0,Gn.Y)===t.getOrdinate(n-1,Gn.Y)?t:vr.createClosedRing(A,t,n+1)},vr.createClosedRing=function(A,t,n){var i=A.create(n,t.getDimension()),r=t.size();vr.copy(t,0,i,0,r);for(var e=r;e<n;e++)vr.copy(t,0,i,e,1);return i};var lr=function(A){function t(t,n){A.call(this,n),this.Jt=null,this.init(t)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.computeEnvelopeInternal=function(){return this.isEmpty()?new Kn:this.Jt.expandEnvelope(new Kn)},t.prototype.isRing=function(){return this.isClosed()&&this.isSimple()},t.prototype.getSortIndex=function(){return A.SORTINDEX_LINESTRING},t.prototype.getCoordinates=function(){return this.Jt.toCoordinateArray()},t.prototype.equalsExact=function(){var t=this;if(2===arguments.length){var n=arguments[0],i=arguments[1];if(!this.isEquivalentClass(n))return!1;var r=n;if(this.Jt.size()!==r.Jt.size())return!1;for(var e=0;e<this.Jt.size();e++)if(!t.equal(t.Jt.getCoordinate(e),r.Jt.getCoordinate(e),i))return!1;return!0}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.normalize=function(){for(var A=0;A<Math.trunc(this.Jt.size()/2);A++){var t=this.Jt.size()-1-A;if(!this.Jt.getCoordinate(A).equals(this.Jt.getCoordinate(t)))return this.Jt.getCoordinate(A).compareTo(this.Jt.getCoordinate(t))>0&&vr.reverse(this.Jt),null}},t.prototype.getCoordinate=function(){return this.isEmpty()?null:this.Jt.getCoordinate(0)},t.prototype.getBoundaryDimension=function(){return this.isClosed()?Zi.FALSE:0},t.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},t.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},t.prototype.getDimension=function(){return 1},t.prototype.getLength=function(){return hi.computeLength(this.Jt)},t.prototype.getNumPoints=function(){return this.Jt.size()},t.prototype.reverse=function(){var A=this.Jt.copy();return vr.reverse(A),this.getFactory().createLineString(A)},t.prototype.compareToSameClass=function(){var A=this;if(1===arguments.length){for(var t=arguments[0],n=t,i=0,r=0;i<this.Jt.size()&&r<n.Jt.size();){var e=A.Jt.getCoordinate(i).compareTo(n.Jt.getCoordinate(r));if(0!==e)return e;i++,r++}return i<this.Jt.size()?1:r<n.Jt.size()?-1:0}if(2===arguments.length){var s=arguments[0],u=arguments[1],o=s;return u.compare(this.Jt,o.Jt)}},t.prototype.apply=function(){var A=this;if(Fn(arguments[0],wi))for(var t=arguments[0],n=0;n<this.Jt.size();n++)t.filter(A.Jt.getCoordinate(n));else if(Fn(arguments[0],Ar)){var i=arguments[0];if(0===this.Jt.size())return null;for(var r=0;r<this.Jt.size()&&(i.filter(A.Jt,r),!i.isDone());r++);i.isGeometryChanged()&&this.geometryChanged()}else if(Fn(arguments[0],$i)){var e=arguments[0];e.filter(this)}else if(Fn(arguments[0],ci)){var s=arguments[0];s.filter(this)}},t.prototype.getBoundary=function(){return new ir(this).getBoundary()},t.prototype.isEquivalentClass=function(A){return A instanceof t},t.prototype.clone=function(){var t=A.prototype.clone.call(this);return t.Jt=this.Jt.clone(),t},t.prototype.getCoordinateN=function(A){return this.Jt.getCoordinate(A)},t.prototype.getGeometryType=function(){return"LineString"},t.prototype.copy=function(){return new t(this.Jt.copy(),this.vn)},t.prototype.getCoordinateSequence=function(){return this.Jt},t.prototype.isEmpty=function(){return 0===this.Jt.size()},t.prototype.init=function(A){if(null===A&&(A=this.getFactory().getCoordinateSequenceFactory().create([])),1===A.size())throw new Dn("Invalid number of points in LineString (found "+A.size()+" - must be 0 or >= 2)");this.Jt=A},t.prototype.isCoordinate=function(A){for(var t=0;t<this.Jt.size();t++)if(this.Jt.getCoordinate(t).equals(A))return!0;return!1},t.prototype.getStartPoint=function(){return this.isEmpty()?null:this.getPointN(0)},t.prototype.getPointN=function(A){return this.getFactory().createPoint(this.Jt.getCoordinate(A))},t.prototype.interfaces_=function(){return[Wi]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return 0x2b2b51ba435c8e00},Object.defineProperties(t,n),t}(ai),wr=function(){};wr.prototype.interfaces_=function(){return[]},wr.prototype.getClass=function(){return wr};var Pr=function(A){function t(t,n){A.call(this,n),this.Kt=t||null,this.init(this.Kt)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.computeEnvelopeInternal=function(){if(this.isEmpty())return new Kn;var A=new Kn;return A.expandToInclude(this.Kt.getX(0),this.Kt.getY(0)),A},t.prototype.getSortIndex=function(){return A.SORTINDEX_POINT},t.prototype.getCoordinates=function(){return this.isEmpty()?[]:[this.getCoordinate()]},t.prototype.equalsExact=function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];return!!this.isEquivalentClass(t)&&(!(!this.isEmpty()||!t.isEmpty())||this.isEmpty()===t.isEmpty()&&this.equal(t.getCoordinate(),this.getCoordinate(),n))}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.normalize=function(){},t.prototype.getCoordinate=function(){return 0!==this.Kt.size()?this.Kt.getCoordinate(0):null},t.prototype.getBoundaryDimension=function(){return Zi.FALSE},t.prototype.getDimension=function(){return 0},t.prototype.getNumPoints=function(){return this.isEmpty()?0:1},t.prototype.reverse=function(){return this.copy()},t.prototype.getX=function(){if(null===this.getCoordinate())throw new Error("getX called on empty Point");return this.getCoordinate().x},t.prototype.compareToSameClass=function(){if(1===arguments.length){var A=arguments[0],t=A;return this.getCoordinate().compareTo(t.getCoordinate())}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=n;return i.compare(this.Kt,r.Kt)}},t.prototype.apply=function(){if(Fn(arguments[0],wi)){var A=arguments[0];if(this.isEmpty())return null;A.filter(this.getCoordinate())}else if(Fn(arguments[0],Ar)){var t=arguments[0];if(this.isEmpty())return null;t.filter(this.Kt,0),t.isGeometryChanged()&&this.geometryChanged()}else if(Fn(arguments[0],$i)){var n=arguments[0];n.filter(this)}else if(Fn(arguments[0],ci)){var i=arguments[0];i.filter(this)}},t.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},t.prototype.clone=function(){var t=A.prototype.clone.call(this);return t.Kt=this.Kt.clone(),t},t.prototype.getGeometryType=function(){return"Point"},t.prototype.copy=function(){return new t(this.Kt.copy(),this.vn)},t.prototype.getCoordinateSequence=function(){return this.Kt},t.prototype.getY=function(){if(null===this.getCoordinate())throw new Error("getY called on empty Point");return this.getCoordinate().y},t.prototype.isEmpty=function(){return 0===this.Kt.size()},t.prototype.init=function(A){null===A&&(A=this.getFactory().getCoordinateSequenceFactory().create([])),ii.isTrue(A.size()<=1),this.Kt=A},t.prototype.isSimple=function(){return!0},t.prototype.interfaces_=function(){return[wr]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return 0x44077bad161cbc00},Object.defineProperties(t,n),t}(ai),gr=function(){};gr.prototype.interfaces_=function(){return[]},gr.prototype.getClass=function(){return gr};var Cr=function(A){function t(t,n,i){if(A.call(this,i),this.Zt=null,this.Xt=null,null===t&&(t=this.getFactory().createLinearRing()),null===n&&(n=[]),A.hasNullElements(n))throw new Dn("holes must not contain null elements");if(t.isEmpty()&&A.hasNonEmptyElements(n))throw new Dn("shell is empty but holes are not");this.Zt=t,this.Xt=n}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.computeEnvelopeInternal=function(){return this.Zt.getEnvelopeInternal()},t.prototype.getSortIndex=function(){return A.SORTINDEX_POLYGON},t.prototype.getCoordinates=function(){if(this.isEmpty())return[];for(var A=new Array(this.getNumPoints()).fill(null),t=-1,n=this.Zt.getCoordinates(),i=0;i<n.length;i++)A[++t]=n[i];for(var r=0;r<this.Xt.length;r++)for(var e=this.Xt[r].getCoordinates(),s=0;s<e.length;s++)A[++t]=e[s];return A},t.prototype.getArea=function(){var A=0;A+=Math.abs(hi.signedArea(this.Zt.getCoordinateSequence()));for(var t=0;t<this.Xt.length;t++)A-=Math.abs(hi.signedArea(this.Xt[t].getCoordinateSequence()));return A},t.prototype.isRectangle=function(){if(0!==this.getNumInteriorRing())return!1;if(null===this.Zt)return!1;if(5!==this.Zt.getNumPoints())return!1;for(var A=this.Zt.getCoordinateSequence(),t=this.getEnvelopeInternal(),n=0;n<5;n++){var i=A.getX(n);if(i!==t.getMinX()&&i!==t.getMaxX())return!1;var r=A.getY(n);if(r!==t.getMinY()&&r!==t.getMaxY())return!1}for(var e=A.getX(0),s=A.getY(0),u=1;u<=4;u++){var o=A.getX(u),h=A.getY(u);if(o!==e==(h!==s))return!1;e=o,s=h}return!0},t.prototype.equalsExact=function(){var t=this;if(2===arguments.length){var n=arguments[0],i=arguments[1];if(!this.isEquivalentClass(n))return!1;var r=n,e=this.Zt,s=r.Zt;if(!e.equalsExact(s,i))return!1;if(this.Xt.length!==r.Xt.length)return!1;for(var u=0;u<this.Xt.length;u++)if(!t.Xt[u].equalsExact(r.Xt[u],i))return!1;return!0}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.normalize=function(){var A=this;if(0===arguments.length){this.normalize(this.Zt,!0);for(var t=0;t<this.Xt.length;t++)A.normalize(A.Xt[t],!1);Ji.sort(this.Xt)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];if(n.isEmpty())return null;var r=new Array(n.getCoordinates().length-1).fill(null);Wn.arraycopy(n.getCoordinates(),0,r,0,r.length);var e=Ti.minCoordinate(n.getCoordinates());Ti.scroll(r,e),Wn.arraycopy(r,0,n.getCoordinates(),0,r.length),n.getCoordinates()[r.length]=r[0],hi.isCCW(n.getCoordinates())===i&&Ti.reverse(n.getCoordinates())}},t.prototype.getCoordinate=function(){return this.Zt.getCoordinate()},t.prototype.getNumInteriorRing=function(){return this.Xt.length},t.prototype.getBoundaryDimension=function(){return 1},t.prototype.getDimension=function(){return 2},t.prototype.getLength=function(){var A=0;A+=this.Zt.getLength();for(var t=0;t<this.Xt.length;t++)A+=this.Xt[t].getLength();return A},t.prototype.getNumPoints=function(){for(var A=this.Zt.getNumPoints(),t=0;t<this.Xt.length;t++)A+=this.Xt[t].getNumPoints();return A},t.prototype.reverse=function(){var A=this.copy();A.Zt=this.Zt.copy().reverse(),A.Xt=new Array(this.Xt.length).fill(null);for(var t=0;t<this.Xt.length;t++)A.Xt[t]=this.Xt[t].copy().reverse();return A},t.prototype.convexHull=function(){return this.getExteriorRing().convexHull()},t.prototype.compareToSameClass=function(){var A=this;if(1===arguments.length){var t=arguments[0],n=this.Zt,i=t.Zt;return n.compareToSameClass(i)}if(2===arguments.length){var r=arguments[0],e=arguments[1],s=r,u=this.Zt,o=s.Zt,h=u.compareToSameClass(o,e);if(0!==h)return h;for(var f=this.getNumInteriorRing(),c=s.getNumInteriorRing(),a=0;a<f&&a<c;){var v=A.getInteriorRingN(a),l=s.getInteriorRingN(a),w=v.compareToSameClass(l,e);if(0!==w)return w;a++}return a<f?1:a<c?-1:0}},t.prototype.apply=function(A){if(Fn(A,wi)){this.Zt.apply(A);for(var t=0;t<this.Xt.length;t++)this.Xt[t].apply(A)}else if(Fn(A,Ar)){if(this.Zt.apply(A),!A.isDone())for(var n=0;n<this.Xt.length&&(this.Xt[n].apply(A),!A.isDone());n++);A.isGeometryChanged()&&this.geometryChanged()}else if(Fn(A,$i))A.filter(this);else if(Fn(A,ci)){A.filter(this),this.Zt.apply(A);for(var i=0;i<this.Xt.length;i++)this.Xt[i].apply(A)}},t.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();var A=new Array(this.Xt.length+1).fill(null);A[0]=this.Zt;for(var t=0;t<this.Xt.length;t++)A[t+1]=this.Xt[t];return A.length<=1?this.getFactory().createLinearRing(A[0].getCoordinateSequence()):this.getFactory().createMultiLineString(A)},t.prototype.clone=function(){var t=A.prototype.clone.call(this);t.Zt=this.Zt.clone(),t.Xt=new Array(this.Xt.length).fill(null);for(var n=0;n<this.Xt.length;n++)t.Xt[n]=this.Xt[n].clone();return t},t.prototype.getGeometryType=function(){return"Polygon"},t.prototype.copy=function(){for(var A=this.Zt.copy(),n=new Array(this.Xt.length).fill(null),i=0;i<n.length;i++)n[i]=this.Xt[i].copy();return new t(A,n,this.vn)},t.prototype.getExteriorRing=function(){return this.Zt},t.prototype.isEmpty=function(){return this.Zt.isEmpty()},t.prototype.getInteriorRingN=function(A){return this.Xt[A]},t.prototype.interfaces_=function(){return[gr]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return-0x307ffefd8dc97200},Object.defineProperties(t,n),t}(ai),Dr=function(A){function t(){A.apply(this,arguments)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.getSortIndex=function(){return ai.SORTINDEX_MULTIPOINT},t.prototype.isValid=function(){return!0},t.prototype.equalsExact=function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];return!!this.isEquivalentClass(t)&&A.prototype.equalsExact.call(this,t,n)}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.getCoordinate=function(){if(1===arguments.length){var t=arguments[0];return this.Ht[t].getCoordinate()}return A.prototype.getCoordinate.apply(this,arguments)},t.prototype.getBoundaryDimension=function(){return Zi.FALSE},t.prototype.getDimension=function(){return 0},t.prototype.getBoundary=function(){return this.getFactory().createGeometryCollection(null)},t.prototype.getGeometryType=function(){return"MultiPoint"},t.prototype.copy=function(){for(var A=new Array(this.Ht.length).fill(null),n=0;n<A.length;n++)A[n]=this.Ht[n].copy();return new t(A,this.vn)},t.prototype.interfaces_=function(){return[wr]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return-0x6fb1ed4162e0fc00},Object.defineProperties(t,n),t}(tr),Ir=function(A){function t(t,n){t instanceof mn&&n instanceof jr&&(t=n.getCoordinateSequenceFactory().create(t)),A.call(this,t,n),this.validateConstruction()}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={MINIMUM_VALID_SIZE:{configurable:!0},serialVersionUID:{configurable:!0}};return t.prototype.getSortIndex=function(){return ai.SORTINDEX_LINEARRING},t.prototype.getBoundaryDimension=function(){return Zi.FALSE},t.prototype.isClosed=function(){return!!this.isEmpty()||A.prototype.isClosed.call(this)},t.prototype.reverse=function(){var A=this.Jt.copy();return vr.reverse(A),this.getFactory().createLinearRing(A)},t.prototype.validateConstruction=function(){if(!this.isEmpty()&&!A.prototype.isClosed.call(this))throw new Dn("Points of LinearRing do not form a closed linestring");if(this.getCoordinateSequence().size()>=1&&this.getCoordinateSequence().size()<t.MINIMUM_VALID_SIZE)throw new Dn("Invalid number of points in LinearRing (found "+this.getCoordinateSequence().size()+" - must be 0 or >= 4)")},t.prototype.getGeometryType=function(){return"LinearRing"},t.prototype.copy=function(){return new t(this.Jt.copy(),this.vn)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},n.MINIMUM_VALID_SIZE.get=function(){return 4},n.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(t,n),t}(lr),Mr=function(A){function t(){A.apply(this,arguments)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={serialVersionUID:{configurable:!0}};return t.prototype.getSortIndex=function(){return ai.SORTINDEX_MULTIPOLYGON},t.prototype.equalsExact=function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];return!!this.isEquivalentClass(t)&&A.prototype.equalsExact.call(this,t,n)}return A.prototype.equalsExact.apply(this,arguments)},t.prototype.getBoundaryDimension=function(){return 1},t.prototype.getDimension=function(){return 2},t.prototype.reverse=function(){for(var t=new Array(this.Ht.length).fill(null),n=0;n<this.Ht.length;n++)t[n]=this.Ht[n].reverse();return this.getFactory().createMultiPolygon(t)},t.prototype.getBoundary=function(){if(this.isEmpty())return this.getFactory().createMultiLineString();for(var A=new yi,t=0;t<this.Ht.length;t++)for(var n=this.Ht[t].getBoundary(),i=0;i<n.getNumGeometries();i++)A.add(n.getGeometryN(i));var r=new Array(A.size()).fill(null);return this.getFactory().createMultiLineString(A.toArray(r))},t.prototype.getGeometryType=function(){return"MultiPolygon"},t.prototype.copy=function(){for(var A=new Array(this.Ht.length).fill(null),n=0;n<A.length;n++)A[n]=this.Ht[n].copy();return new t(A,this.vn)},t.prototype.interfaces_=function(){return[gr]},t.prototype.getClass=function(){return t},n.serialVersionUID.get=function(){return-0x7a5aa1369171980},Object.defineProperties(t,n),t}(tr),br=function(A){this.vn=A||null,this.In=!1},zr={NoOpGeometryOperation:{configurable:!0},CoordinateOperation:{configurable:!0},CoordinateSequenceOperation:{configurable:!0}};br.prototype.setCopyUserData=function(A){this.In=A},br.prototype.edit=function(A,t){if(null===A)return null;var n=this.editInternal(A,t);return this.In&&n.setUserData(A.getUserData()),n},br.prototype.editInternal=function(A,t){return null===this.vn&&(this.vn=A.getFactory()),A instanceof tr?this.editGeometryCollection(A,t):A instanceof Cr?this.editPolygon(A,t):A instanceof Pr||A instanceof lr?t.edit(A,this.vn):(ii.shouldNeverReachHere("Unsupported Geometry class: "+A.getClass().getName()),null)},br.prototype.editGeometryCollection=function(A,t){for(var n=t.edit(A,this.vn),i=new yi,r=0;r<n.getNumGeometries();r++){var e=this.edit(n.getGeometryN(r),t);null===e||e.isEmpty()||i.add(e)}return n.getClass()===Dr?this.vn.createMultiPoint(i.toArray([])):n.getClass()===nr?this.vn.createMultiLineString(i.toArray([])):n.getClass()===Mr?this.vn.createMultiPolygon(i.toArray([])):this.vn.createGeometryCollection(i.toArray([]))},br.prototype.editPolygon=function(A,t){var n=t.edit(A,this.vn);if(null===n&&(n=this.vn.createPolygon(null)),n.isEmpty())return n;var i=this.edit(n.getExteriorRing(),t);if(null===i||i.isEmpty())return this.vn.createPolygon();for(var r=new yi,e=0;e<n.getNumInteriorRing();e++){var s=this.edit(n.getInteriorRingN(e),t);null===s||s.isEmpty()||r.add(s)}return this.vn.createPolygon(i,r.toArray([]))},br.prototype.interfaces_=function(){return[]},br.prototype.getClass=function(){return br},br.GeometryEditorOperation=function(){},zr.NoOpGeometryOperation.get=function(){return dr},zr.CoordinateOperation.get=function(){return xr},zr.CoordinateSequenceOperation.get=function(){return mr},Object.defineProperties(br,zr);var dr=function(){};dr.prototype.edit=function(A,t){return A},dr.prototype.interfaces_=function(){return[br.GeometryEditorOperation]},dr.prototype.getClass=function(){return dr};var xr=function(){};xr.prototype.edit=function(A,t){var n=this.editCoordinates(A.getCoordinates(),A);return null===n?A:A instanceof Ir?t.createLinearRing(n):A instanceof lr?t.createLineString(n):A instanceof Pr?n.length>0?t.createPoint(n[0]):t.createPoint():A},xr.prototype.interfaces_=function(){return[br.GeometryEditorOperation]},xr.prototype.getClass=function(){return xr};var mr=function(){};mr.prototype.edit=function(A,t){return A instanceof Ir?t.createLinearRing(this.edit(A.getCoordinateSequence(),A)):A instanceof lr?t.createLineString(this.edit(A.getCoordinateSequence(),A)):A instanceof Pr?t.createPoint(this.edit(A.getCoordinateSequence(),A)):A},mr.prototype.interfaces_=function(){return[br.GeometryEditorOperation]},mr.prototype.getClass=function(){return mr};var yr=function(){var A=this;if(this.Mn=3,this.Kt=null,1===arguments.length){if(arguments[0]instanceof Array)this.Kt=arguments[0],this.Mn=3;else if(Number.isInteger(arguments[0])){var t=arguments[0];this.Kt=new Array(t).fill(null);for(var n=0;n<t;n++)A.Kt[n]=new mn}else if(Fn(arguments[0],Gn)){var i=arguments[0];if(null===i)return this.Kt=new Array(0).fill(null),null;this.Mn=i.getDimension(),this.Kt=new Array(i.size()).fill(null);for(var r=0;r<this.Kt.length;r++)A.Kt[r]=i.getCoordinateCopy(r)}}else if(2===arguments.length)if(arguments[0]instanceof Array&&Number.isInteger(arguments[1])){var e=arguments[0],s=arguments[1];this.Kt=e,this.Mn=s,null===e&&(this.Kt=new Array(0).fill(null))}else if(Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var u=arguments[0],o=arguments[1];this.Kt=new Array(u).fill(null),this.Mn=o;for(var h=0;h<u;h++)A.Kt[h]=new mn}},pr={serialVersionUID:{configurable:!0}};yr.prototype.setOrdinate=function(A,t,n){switch(t){case Gn.X:this.Kt[A].x=n;break;case Gn.Y:this.Kt[A].y=n;break;case Gn.Z:this.Kt[A].z=n;break;default:throw new Dn("invalid ordinateIndex")}},yr.prototype.size=function(){return this.Kt.length},yr.prototype.getOrdinate=function(A,t){switch(t){case Gn.X:return this.Kt[A].x;case Gn.Y:return this.Kt[A].y;case Gn.Z:return this.Kt[A].z}return In.NaN},yr.prototype.getCoordinate=function(){if(1===arguments.length){var A=arguments[0];return this.Kt[A]}if(2===arguments.length){var t=arguments[0],n=arguments[1];n.x=this.Kt[t].x,n.y=this.Kt[t].y,n.z=this.Kt[t].z}},yr.prototype.getCoordinateCopy=function(A){return new mn(this.Kt[A])},yr.prototype.getDimension=function(){return this.Mn},yr.prototype.getX=function(A){return this.Kt[A].x},yr.prototype.clone=function(){for(var A=new Array(this.size()).fill(null),t=0;t<this.Kt.length;t++)A[t]=this.Kt[t].clone();return new yr(A,this.Mn)},yr.prototype.expandEnvelope=function(A){for(var t=0;t<this.Kt.length;t++)A.expandToInclude(this.Kt[t]);return A},yr.prototype.copy=function(){for(var A=new Array(this.size()).fill(null),t=0;t<this.Kt.length;t++)A[t]=this.Kt[t].copy();return new yr(A,this.Mn)},yr.prototype.toString=function(){if(this.Kt.length>0){var A=new Nn(17*this.Kt.length);A.append("("),A.append(this.Kt[0]);for(var t=1;t<this.Kt.length;t++)A.append(", "),A.append(this.Kt[t]);return A.append(")"),A.toString()}return"()"},yr.prototype.getY=function(A){return this.Kt[A].y},yr.prototype.toCoordinateArray=function(){return this.Kt},yr.prototype.interfaces_=function(){return[Gn,xn]},yr.prototype.getClass=function(){return yr},pr.serialVersionUID.get=function(){return-0xcb44a778db18e00},Object.defineProperties(yr,pr);var Lr=function(){},Tr={serialVersionUID:{configurable:!0},instanceObject:{configurable:!0}};Lr.prototype.readResolve=function(){return Lr.instance()},Lr.prototype.create=function(){if(1===arguments.length){if(arguments[0]instanceof Array){var A=arguments[0];return new yr(A)}if(Fn(arguments[0],Gn)){var t=arguments[0];return new yr(t)}}else if(2===arguments.length){var n=arguments[0],i=arguments[1];return i>3&&(i=3),i<2?new yr(n):new yr(n,i)}},Lr.prototype.interfaces_=function(){return[Ln,xn]},Lr.prototype.getClass=function(){return Lr},Lr.instance=function(){return Lr.instanceObject},Tr.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},Tr.instanceObject.get=function(){return new Lr},Object.defineProperties(Lr,Tr);var Or=function(A){function t(){A.call(this),this.map_=new Map}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.get=function(A){return this.map_.get(A)||null},t.prototype.put=function(A,t){return this.map_.set(A,t),t},t.prototype.values=function(){for(var A=new yi,t=this.map_.values(),n=t.next();!n.done;)A.add(n.value),n=t.next();return A},t.prototype.entrySet=function(){var A=new Si;return this.map_.entries().forEach((function(t){return A.add(t)})),A},t.prototype.size=function(){return this.map_.size()},t}(Ei),Fr=function A(){if(this.bn=null,this.xA=null,0===arguments.length)this.bn=A.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Er){var t=arguments[0];this.bn=t,t===A.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){var n=arguments[0];this.bn=A.FIXED,this.setScale(n)}else if(arguments[0]instanceof A){var i=arguments[0];this.bn=i.bn,this.xA=i.xA}},Ur={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};Fr.prototype.equals=function(A){if(!(A instanceof Fr))return!1;return this.bn===A.bn&&this.xA===A.xA},Fr.prototype.compareTo=function(A){var t=A,n=this.getMaximumSignificantDigits(),i=t.getMaximumSignificantDigits();return new jn(n).compareTo(new jn(i))},Fr.prototype.getScale=function(){return this.xA},Fr.prototype.isFloating=function(){return this.bn===Fr.FLOATING||this.bn===Fr.FLOATING_SINGLE},Fr.prototype.getType=function(){return this.bn},Fr.prototype.toString=function(){var A="UNKNOWN";return this.bn===Fr.FLOATING?A="Floating":this.bn===Fr.FLOATING_SINGLE?A="Floating-Single":this.bn===Fr.FIXED&&(A="Fixed (Scale="+this.getScale()+")"),A},Fr.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var A=arguments[0];return In.isNaN(A)||this.bn===Fr.FLOATING_SINGLE?A:this.bn===Fr.FIXED?Math.round(A*this.xA)/this.xA:A}if(arguments[0]instanceof mn){var t=arguments[0];if(this.bn===Fr.FLOATING)return null;t.x=this.makePrecise(t.x),t.y=this.makePrecise(t.y)}},Fr.prototype.getMaximumSignificantDigits=function(){var A=16;return this.bn===Fr.FLOATING?A=16:this.bn===Fr.FLOATING_SINGLE?A=6:this.bn===Fr.FIXED&&(A=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),A},Fr.prototype.setScale=function(A){this.xA=Math.abs(A)},Fr.prototype.interfaces_=function(){return[xn,bn]},Fr.prototype.getClass=function(){return Fr},Fr.mostPrecise=function(A,t){return A.compareTo(t)>=0?A:t},Ur.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},Ur.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(Fr,Ur);var Er=function A(t){this.zn=t||null,A.nameToTypeMap.put(t,this)},Nr={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};Er.prototype.readResolve=function(){return Er.nameToTypeMap.get(this.zn)},Er.prototype.toString=function(){return this.zn},Er.prototype.interfaces_=function(){return[xn]},Er.prototype.getClass=function(){return Er},Nr.serialVersionUID.get=function(){return-552860263173159e4},Nr.nameToTypeMap.get=function(){return new Or},Object.defineProperties(Er,Nr),Fr.Type=Er,Fr.FIXED=new Er("FIXED"),Fr.FLOATING=new Er("FLOATING"),Fr.FLOATING_SINGLE=new Er("FLOATING SINGLE");var jr=function A(){this.sn=new Fr,this.ln=0,this.dn=A.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?Fn(arguments[0],Ln)?this.dn=arguments[0]:arguments[0]instanceof Fr&&(this.sn=arguments[0]):2===arguments.length?(this.sn=arguments[0],this.ln=arguments[1]):3===arguments.length&&(this.sn=arguments[0],this.ln=arguments[1],this.dn=arguments[2]))},Qr={serialVersionUID:{configurable:!0}};jr.prototype.toGeometry=function(A){return A.isNull()?this.createPoint(null):A.getMinX()===A.getMaxX()&&A.getMinY()===A.getMaxY()?this.createPoint(new mn(A.getMinX(),A.getMinY())):A.getMinX()===A.getMaxX()||A.getMinY()===A.getMaxY()?this.createLineString([new mn(A.getMinX(),A.getMinY()),new mn(A.getMaxX(),A.getMaxY())]):this.createPolygon(this.createLinearRing([new mn(A.getMinX(),A.getMinY()),new mn(A.getMinX(),A.getMaxY()),new mn(A.getMaxX(),A.getMaxY()),new mn(A.getMaxX(),A.getMinY()),new mn(A.getMinX(),A.getMinY())]),null)},jr.prototype.createLineString=function(A){return A?A instanceof Array?new lr(this.getCoordinateSequenceFactory().create(A),this):Fn(A,Gn)?new lr(A,this):void 0:new lr(this.getCoordinateSequenceFactory().create([]),this)},jr.prototype.createMultiLineString=function(){if(0===arguments.length)return new nr(null,this);if(1===arguments.length){var A=arguments[0];return new nr(A,this)}},jr.prototype.buildGeometry=function(A){for(var t=null,n=!1,i=!1,r=A.iterator();r.hasNext();){var e=r.next(),s=e.getClass();null===t&&(t=s),s!==t&&(n=!0),e.isGeometryCollectionOrDerived()&&(i=!0)}if(null===t)return this.createGeometryCollection();if(n||i)return this.createGeometryCollection(jr.toGeometryArray(A));var u=A.iterator().next();if(A.size()>1){if(u instanceof Cr)return this.createMultiPolygon(jr.toPolygonArray(A));if(u instanceof lr)return this.createMultiLineString(jr.toLineStringArray(A));if(u instanceof Pr)return this.createMultiPoint(jr.toPointArray(A));ii.shouldNeverReachHere("Unhandled class: "+u.getClass().getName())}return u},jr.prototype.createMultiPointFromCoords=function(A){return this.createMultiPoint(null!==A?this.getCoordinateSequenceFactory().create(A):null)},jr.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof mn){var A=arguments[0];return this.createPoint(null!==A?this.getCoordinateSequenceFactory().create([A]):null)}if(Fn(arguments[0],Gn)){var t=arguments[0];return new Pr(t,this)}}},jr.prototype.getCoordinateSequenceFactory=function(){return this.dn},jr.prototype.createPolygon=function(){if(0===arguments.length)return new Cr(null,null,this);if(1===arguments.length){if(Fn(arguments[0],Gn)){var A=arguments[0];return this.createPolygon(this.createLinearRing(A))}if(arguments[0]instanceof Array){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Ir){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return new Cr(i,r,this)}},jr.prototype.getSRID=function(){return this.ln},jr.prototype.createGeometryCollection=function(){if(0===arguments.length)return new tr(null,this);if(1===arguments.length){var A=arguments[0];return new tr(A,this)}},jr.prototype.createGeometry=function(A){return new br(this).edit(A,{edit:function(){if(2===arguments.length){var A=arguments[0];return this.dn.create(A)}}})},jr.prototype.getPrecisionModel=function(){return this.sn},jr.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var A=arguments[0];return this.createLinearRing(null!==A?this.getCoordinateSequenceFactory().create(A):null)}if(Fn(arguments[0],Gn)){var t=arguments[0];return new Ir(t,this)}}},jr.prototype.createMultiPolygon=function(){if(0===arguments.length)return new Mr(null,this);if(1===arguments.length){var A=arguments[0];return new Mr(A,this)}},jr.prototype.createMultiPoint=function(){var A=this;if(0===arguments.length)return new Dr(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return new Dr(t,this)}if(arguments[0]instanceof Array){var n=arguments[0];return this.createMultiPoint(null!==n?this.getCoordinateSequenceFactory().create(n):null)}if(Fn(arguments[0],Gn)){var i=arguments[0];if(null===i)return this.createMultiPoint(new Array(0).fill(null));for(var r=new Array(i.size()).fill(null),e=0;e<i.size();e++){var s=A.getCoordinateSequenceFactory().create(1,i.getDimension());vr.copy(i,e,s,0,1),r[e]=A.createPoint(s)}return this.createMultiPoint(r)}}},jr.prototype.interfaces_=function(){return[xn]},jr.prototype.getClass=function(){return jr},jr.toMultiPolygonArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toGeometryArray=function(A){if(null===A)return null;var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.getDefaultCoordinateSequenceFactory=function(){return Lr.instance()},jr.toMultiLineStringArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toLineStringArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toMultiPointArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toLinearRingArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toPointArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.toPolygonArray=function(A){var t=new Array(A.size()).fill(null);return A.toArray(t)},jr.createPointFromInternalCoord=function(A,t){return t.getPrecisionModel().makePrecise(A),t.getFactory().createPoint(A)},Qr.serialVersionUID.get=function(){return-0x5ea75f2051eeb400},Object.defineProperties(jr,Qr);var Sr=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],kr=function(A){this.geometryFactory=A||new jr};kr.prototype.read=function(A){var t,n=(t="string"==typeof A?JSON.parse(A):A).type;if(!Br[n])throw new Error("Unknown GeoJSON type: "+t.type);return-1!==Sr.indexOf(n)?Br[n].apply(this,[t.coordinates]):Br[n].apply(this,"GeometryCollection"===n?[t.geometries]:[t])},kr.prototype.write=function(A){var t=A.getGeometryType();if(!Rr[t])throw new Error("Geometry is not supported");return Rr[t].apply(this,[A])};var Br={Feature:function(A){var t={};for(var n in A)t[n]=A[n];if(A.geometry){if(!Br[A.geometry.type])throw new Error("Unknown GeoJSON type: "+A.type);t.geometry=this.read(A.geometry)}return A.bbox&&(t.bbox=Br.bbox.apply(this,[A.bbox])),t},FeatureCollection:function(A){var t={};if(A.features){t.features=[];for(var n=0;n<A.features.length;++n)t.features.push(this.read(A.features[n]))}return A.bbox&&(t.bbox=this.parse.bbox.apply(this,[A.bbox])),t},coordinates:function(A){for(var t=[],n=0;n<A.length;++n){var i=A[n];t.push(new mn(i[0],i[1]))}return t},bbox:function(A){return this.geometryFactory.createLinearRing([new mn(A[0],A[1]),new mn(A[2],A[1]),new mn(A[2],A[3]),new mn(A[0],A[3]),new mn(A[0],A[1])])},Point:function(A){var t=new mn(A[0],A[1]);return this.geometryFactory.createPoint(t)},MultiPoint:function(A){for(var t=[],n=0;n<A.length;++n)t.push(Br.Point.apply(this,[A[n]]));return this.geometryFactory.createMultiPoint(t)},LineString:function(A){var t=Br.coordinates.apply(this,[A]);return this.geometryFactory.createLineString(t)},MultiLineString:function(A){for(var t=[],n=0;n<A.length;++n)t.push(Br.LineString.apply(this,[A[n]]));return this.geometryFactory.createMultiLineString(t)},Polygon:function(A){for(var t=Br.coordinates.apply(this,[A[0]]),n=this.geometryFactory.createLinearRing(t),i=[],r=1;r<A.length;++r){var s=Br.coordinates.apply(this,[A[r]]),u=this.geometryFactory.createLinearRing(s);i.push(u)}return this.geometryFactory.createPolygon(n,i)},MultiPolygon:function(A){for(var t=[],n=0;n<A.length;++n){t.push(Br.Polygon.apply(this,[A[n]]))}return this.geometryFactory.createMultiPolygon(t)},GeometryCollection:function(A){for(var t=[],n=0;n<A.length;++n){t.push(this.read(A[n]))}return this.geometryFactory.createGeometryCollection(t)}},Rr={coordinate:function(A){return[A.x,A.y]},Point:function(A){return{type:"Point",coordinates:Rr.coordinate.apply(this,[A.getCoordinate()])}},MultiPoint:function(A){for(var t=[],n=0;n<A.Ht.length;++n){var r=Rr.Point.apply(this,[A.Ht[n]]);t.push(r.coordinates)}return{type:"MultiPoint",coordinates:t}},LineString:function(A){for(var t=[],n=A.getCoordinates(),i=0;i<n.length;++i){t.push(Rr.coordinate.apply(this,[n[i]]))}return{type:"LineString",coordinates:t}},MultiLineString:function(A){for(var t=[],n=0;n<A.Ht.length;++n){var r=Rr.LineString.apply(this,[A.Ht[n]]);t.push(r.coordinates)}return{type:"MultiLineString",coordinates:t}},Polygon:function(A){var t=[],n=Rr.LineString.apply(this,[A.Zt]);t.push(n.coordinates);for(var i=0;i<A.Xt.length;++i){var e=Rr.LineString.apply(this,[A.Xt[i]]);t.push(e.coordinates)}return{type:"Polygon",coordinates:t}},MultiPolygon:function(A){for(var t=[],n=0;n<A.Ht.length;++n){var r=Rr.Polygon.apply(this,[A.Ht[n]]);t.push(r.coordinates)}return{type:"MultiPolygon",coordinates:t}},GeometryCollection:function(A){for(var t=[],n=0;n<A.Ht.length;++n){var i=A.Ht[n],r=i.getGeometryType();t.push(Rr[r].apply(this,[i]))}return{type:"GeometryCollection",geometries:t}}},Gr=function(A){this.geometryFactory=A||new jr,this.precisionModel=this.geometryFactory.getPrecisionModel(),this.parser=new kr(this.geometryFactory)};Gr.prototype.read=function(A){var t=this.parser.read(A);return this.precisionModel.getType()===Fr.FIXED&&this.reducePrecision(t),t},Gr.prototype.reducePrecision=function(A){var t,n;if(A.coordinate)this.precisionModel.makePrecise(A.coordinate);else if(A.points)for(t=0,n=A.points.length;t<n;t++)this.precisionModel.makePrecise(A.points[t]);else if(A.geometries)for(t=0,n=A.geometries.length;t<n;t++)this.reducePrecision(A.geometries[t])};var Yr=function(){this.parser=new kr(this.geometryFactory)};Yr.prototype.write=function(A){return this.parser.write(A)};var qr=function(){},Vr={ON:{configurable:!0},LEFT:{configurable:!0},RIGHT:{configurable:!0}};function Wr(A){this.message=A||""}function _r(){this.array_=[]}qr.prototype.interfaces_=function(){return[]},qr.prototype.getClass=function(){return qr},qr.opposite=function(A){return A===qr.LEFT?qr.RIGHT:A===qr.RIGHT?qr.LEFT:A},Vr.ON.get=function(){return 0},Vr.LEFT.get=function(){return 1},Vr.RIGHT.get=function(){return 2},Object.defineProperties(qr,Vr),(Wr.prototype=new Error).name="EmptyStackException",(_r.prototype=new xi).add=function(A){return this.array_.push(A),!0},_r.prototype.get=function(A){if(A<0||A>=this.size())throw new Error;return this.array_[A]},_r.prototype.push=function(A){return this.array_.push(A),A},_r.prototype.pop=function(A){if(0===this.array_.length)throw new Wr;return this.array_.pop()},_r.prototype.peek=function(){if(0===this.array_.length)throw new Wr;return this.array_[this.array_.length-1]},_r.prototype.empty=function(){return 0===this.array_.length},_r.prototype.isEmpty=function(){return this.empty()},_r.prototype.search=function(A){return this.array_.indexOf(A)},_r.prototype.size=function(){return this.array_.length},_r.prototype.toArray=function(){for(var A=[],t=0,n=this.array_.length;t<n;t++)A.push(this.array_[t]);return A};var Kr=function(){this.xn=-1,this.mn=null,this.yn=null,this.pn=null};Kr.prototype.getCoordinate=function(){return this.mn},Kr.prototype.getRightmostSide=function(A,t){var n=this.getRightmostSideOfSegment(A,t);return n<0&&(n=this.getRightmostSideOfSegment(A,t-1)),n<0&&(this.mn=null,this.checkForRightmostCoordinate(A)),n},Kr.prototype.findRightmostEdgeAtVertex=function(){var A=this.yn.getEdge().getCoordinates();ii.isTrue(this.xn>0&&this.xn<A.length,"rightmost point expected to be interior vertex of edge");var t=A[this.xn-1],n=A[this.xn+1],i=hi.computeOrientation(this.mn,n,t),r=!1;(t.y<this.mn.y&&n.y<this.mn.y&&i===hi.COUNTERCLOCKWISE||t.y>this.mn.y&&n.y>this.mn.y&&i===hi.CLOCKWISE)&&(r=!0),r&&(this.xn=this.xn-1)},Kr.prototype.getRightmostSideOfSegment=function(A,t){var n=A.getEdge().getCoordinates();if(t<0||t+1>=n.length)return-1;if(n[t].y===n[t+1].y)return-1;var i=qr.LEFT;return n[t].y<n[t+1].y&&(i=qr.RIGHT),i},Kr.prototype.getEdge=function(){return this.pn},Kr.prototype.checkForRightmostCoordinate=function(A){for(var t=A.getEdge().getCoordinates(),n=0;n<t.length-1;n++)(null===this.mn||t[n].x>this.mn.x)&&(this.yn=A,this.xn=n,this.mn=t[n])},Kr.prototype.findRightmostEdgeAtNode=function(){var A=this.yn.getNode().getEdges();this.yn=A.getRightmostEdge(),this.yn.isForward()||(this.yn=this.yn.getSym(),this.xn=this.yn.getEdge().getCoordinates().length-1)},Kr.prototype.findEdge=function(A){for(var t=A.iterator();t.hasNext();){var n=t.next();n.isForward()&&this.checkForRightmostCoordinate(n)}ii.isTrue(0!==this.xn||this.mn.equals(this.yn.getCoordinate()),"inconsistency in rightmost processing"),0===this.xn?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this.pn=this.yn,this.getRightmostSide(this.yn,this.xn)===qr.LEFT&&(this.pn=this.yn.getSym())},Kr.prototype.interfaces_=function(){return[]},Kr.prototype.getClass=function(){return Kr};var Hr=function(A){function t(n,i){A.call(this,t.msgWithCoord(n,i)),this.pt=i?new mn(i):null,this.name="TopologyException"}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.getCoordinate=function(){return this.pt},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t.msgWithCoord=function(A,t){return t?A:A+" [ "+t+" ]"},t}(ti),Jr=function(){this.array_=[]};Jr.prototype.addLast=function(A){this.array_.push(A)},Jr.prototype.removeFirst=function(){return this.array_.shift()},Jr.prototype.isEmpty=function(){return 0===this.array_.length};var Zr=function(){this.Ln=null,this.Tn=new yi,this.On=new yi,this.Fn=null,this.Un=null,this.Ln=new Kr};Zr.prototype.clearVisitedEdges=function(){for(var A=this.Tn.iterator();A.hasNext();)A.next().setVisited(!1)},Zr.prototype.getRightmostCoordinate=function(){return this.Fn},Zr.prototype.computeNodeDepth=function(A){for(var t=null,n=A.getEdges().iterator();n.hasNext();){var i=n.next();if(i.isVisited()||i.getSym().isVisited()){t=i;break}}if(null===t)throw new Hr("unable to find edge to compute depths at "+A.getCoordinate());A.getEdges().computeDepths(t);for(var r=A.getEdges().iterator();r.hasNext();){var e=r.next();e.setVisited(!0),this.copySymDepths(e)}},Zr.prototype.computeDepth=function(A){this.clearVisitedEdges();var t=this.Ln.getEdge();t.setEdgeDepths(qr.RIGHT,A),this.copySymDepths(t),this.computeDepths(t)},Zr.prototype.create=function(A){this.addReachable(A),this.Ln.findEdge(this.Tn),this.Fn=this.Ln.getCoordinate()},Zr.prototype.findResultEdges=function(){for(var A=this.Tn.iterator();A.hasNext();){var t=A.next();t.getDepth(qr.RIGHT)>=1&&t.getDepth(qr.LEFT)<=0&&!t.isInteriorAreaEdge()&&t.setInResult(!0)}},Zr.prototype.computeDepths=function(A){var t=new Si,n=new Jr,i=A.getNode();for(n.addLast(i),t.add(i),A.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();t.add(r),this.computeNodeDepth(r);for(var e=r.getEdges().iterator();e.hasNext();){var s=e.next().getSym();if(!s.isVisited()){var u=s.getNode();t.contains(u)||(n.addLast(u),t.add(u))}}}},Zr.prototype.compareTo=function(A){return this.Fn.x<A.Fn.x?-1:this.Fn.x>A.Fn.x?1:0},Zr.prototype.getEnvelope=function(){if(null===this.Un){for(var A=new Kn,t=this.Tn.iterator();t.hasNext();)for(var n=t.next().getEdge().getCoordinates(),i=0;i<n.length-1;i++)A.expandToInclude(n[i]);this.Un=A}return this.Un},Zr.prototype.addReachable=function(A){var t=new _r;for(t.add(A);!t.empty();){var n=t.pop();this.add(n,t)}},Zr.prototype.copySymDepths=function(A){var t=A.getSym();t.setDepth(qr.LEFT,A.getDepth(qr.RIGHT)),t.setDepth(qr.RIGHT,A.getDepth(qr.LEFT))},Zr.prototype.add=function(A,t){A.setVisited(!0),this.On.add(A);for(var n=A.getEdges().iterator();n.hasNext();){var i=n.next();this.Tn.add(i);var r=i.getSym().getNode();r.isVisited()||t.push(r)}},Zr.prototype.getNodes=function(){return this.On},Zr.prototype.getDirectedEdges=function(){return this.Tn},Zr.prototype.interfaces_=function(){return[bn]},Zr.prototype.getClass=function(){return Zr};var Xr=function A(){var t=this;if(this.location=null,1===arguments.length){if(arguments[0]instanceof Array){var n=arguments[0];this.init(n.length)}else if(Number.isInteger(arguments[0])){var i=arguments[0];this.init(1),this.location[qr.ON]=i}else if(arguments[0]instanceof A){var r=arguments[0];if(this.init(r.location.length),null!==r)for(var e=0;e<this.location.length;e++)t.location[e]=r.location[e]}}else if(3===arguments.length){var s=arguments[0],u=arguments[1],o=arguments[2];this.init(3),this.location[qr.ON]=s,this.location[qr.LEFT]=u,this.location[qr.RIGHT]=o}};Xr.prototype.setAllLocations=function(A){for(var t=0;t<this.location.length;t++)this.location[t]=A},Xr.prototype.isNull=function(){for(var A=0;A<this.location.length;A++)if(this.location[A]!==Tn.NONE)return!1;return!0},Xr.prototype.setAllLocationsIfNull=function(A){for(var t=0;t<this.location.length;t++)this.location[t]===Tn.NONE&&(this.location[t]=A)},Xr.prototype.isLine=function(){return 1===this.location.length},Xr.prototype.merge=function(A){if(A.location.length>this.location.length){var t=new Array(3).fill(null);t[qr.ON]=this.location[qr.ON],t[qr.LEFT]=Tn.NONE,t[qr.RIGHT]=Tn.NONE,this.location=t}for(var n=0;n<this.location.length;n++)this.location[n]===Tn.NONE&&n<A.location.length&&(this.location[n]=A.location[n])},Xr.prototype.getLocations=function(){return this.location},Xr.prototype.flip=function(){if(this.location.length<=1)return null;var A=this.location[qr.LEFT];this.location[qr.LEFT]=this.location[qr.RIGHT],this.location[qr.RIGHT]=A},Xr.prototype.toString=function(){var A=new Nn;return this.location.length>1&&A.append(Tn.toLocationSymbol(this.location[qr.LEFT])),A.append(Tn.toLocationSymbol(this.location[qr.ON])),this.location.length>1&&A.append(Tn.toLocationSymbol(this.location[qr.RIGHT])),A.toString()},Xr.prototype.setLocations=function(A,t,n){this.location[qr.ON]=A,this.location[qr.LEFT]=t,this.location[qr.RIGHT]=n},Xr.prototype.get=function(A){return A<this.location.length?this.location[A]:Tn.NONE},Xr.prototype.isArea=function(){return this.location.length>1},Xr.prototype.isAnyNull=function(){for(var A=0;A<this.location.length;A++)if(this.location[A]===Tn.NONE)return!0;return!1},Xr.prototype.setLocation=function(){if(1===arguments.length){var A=arguments[0];this.setLocation(qr.ON,A)}else if(2===arguments.length){var t=arguments[0],n=arguments[1];this.location[t]=n}},Xr.prototype.init=function(A){this.location=new Array(A).fill(null),this.setAllLocations(Tn.NONE)},Xr.prototype.isEqualOnSide=function(A,t){return this.location[t]===A.location[t]},Xr.prototype.allPositionsEqual=function(A){for(var t=0;t<this.location.length;t++)if(this.location[t]!==A)return!1;return!0},Xr.prototype.interfaces_=function(){return[]},Xr.prototype.getClass=function(){return Xr};var $r=function A(){if(this.elt=new Array(2).fill(null),1===arguments.length){if(Number.isInteger(arguments[0])){var t=arguments[0];this.elt[0]=new Xr(t),this.elt[1]=new Xr(t)}else if(arguments[0]instanceof A){var n=arguments[0];this.elt[0]=new Xr(n.elt[0]),this.elt[1]=new Xr(n.elt[1])}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.elt[0]=new Xr(Tn.NONE),this.elt[1]=new Xr(Tn.NONE),this.elt[i].setLocation(r)}else if(3===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2];this.elt[0]=new Xr(e,s,u),this.elt[1]=new Xr(e,s,u)}else if(4===arguments.length){var o=arguments[0],h=arguments[1],f=arguments[2],c=arguments[3];this.elt[0]=new Xr(Tn.NONE,Tn.NONE,Tn.NONE),this.elt[1]=new Xr(Tn.NONE,Tn.NONE,Tn.NONE),this.elt[o].setLocations(h,f,c)}};$r.prototype.getGeometryCount=function(){var A=0;return this.elt[0].isNull()||A++,this.elt[1].isNull()||A++,A},$r.prototype.setAllLocations=function(A,t){this.elt[A].setAllLocations(t)},$r.prototype.isNull=function(A){return this.elt[A].isNull()},$r.prototype.setAllLocationsIfNull=function(){if(1===arguments.length){var A=arguments[0];this.setAllLocationsIfNull(0,A),this.setAllLocationsIfNull(1,A)}else if(2===arguments.length){var t=arguments[0],n=arguments[1];this.elt[t].setAllLocationsIfNull(n)}},$r.prototype.isLine=function(A){return this.elt[A].isLine()},$r.prototype.merge=function(A){for(var t=0;t<2;t++)null===this.elt[t]&&null!==A.elt[t]?this.elt[t]=new Xr(A.elt[t]):this.elt[t].merge(A.elt[t])},$r.prototype.flip=function(){this.elt[0].flip(),this.elt[1].flip()},$r.prototype.getLocation=function(){if(1===arguments.length){var A=arguments[0];return this.elt[A].get(qr.ON)}if(2===arguments.length){var t=arguments[0],n=arguments[1];return this.elt[t].get(n)}},$r.prototype.toString=function(){var A=new Nn;return null!==this.elt[0]&&(A.append("A:"),A.append(this.elt[0].toString())),null!==this.elt[1]&&(A.append(" B:"),A.append(this.elt[1].toString())),A.toString()},$r.prototype.isArea=function(){if(0===arguments.length)return this.elt[0].isArea()||this.elt[1].isArea();if(1===arguments.length){var A=arguments[0];return this.elt[A].isArea()}},$r.prototype.isAnyNull=function(A){return this.elt[A].isAnyNull()},$r.prototype.setLocation=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1];this.elt[A].setLocation(qr.ON,t)}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.elt[n].setLocation(i,r)}},$r.prototype.isEqualOnSide=function(A,t){return this.elt[0].isEqualOnSide(A.elt[0],t)&&this.elt[1].isEqualOnSide(A.elt[1],t)},$r.prototype.allPositionsEqual=function(A,t){return this.elt[A].allPositionsEqual(t)},$r.prototype.toLine=function(A){this.elt[A].isArea()&&(this.elt[A]=new Xr(this.elt[A].location[0]))},$r.prototype.interfaces_=function(){return[]},$r.prototype.getClass=function(){return $r},$r.toLineLabel=function(A){for(var t=new $r(Tn.NONE),n=0;n<2;n++)t.setLocation(n,A.getLocation(n));return t};var Ae=function(){this.En=null,this.Nn=-1,this.jn=new yi,this.Qn=new yi,this.Sn=new $r(Tn.NONE),this.kn=null,this.Bn=null,this.Zt=null,this.Xt=new yi,this.Rn=null;var A=arguments[0],t=arguments[1];this.Rn=t,this.computePoints(A),this.computeRing()};Ae.prototype.computeRing=function(){if(null!==this.kn)return null;for(var A=new Array(this.Qn.size()).fill(null),t=0;t<this.Qn.size();t++)A[t]=this.Qn.get(t);this.kn=this.Rn.createLinearRing(A),this.Bn=hi.isCCW(this.kn.getCoordinates())},Ae.prototype.isIsolated=function(){return 1===this.Sn.getGeometryCount()},Ae.prototype.computePoints=function(A){this.En=A;var t=A,n=!0;do{if(null===t)throw new Hr("Found null DirectedEdge");if(t.getEdgeRing()===this)throw new Hr("Directed Edge visited twice during ring-building at "+t.getCoordinate());this.jn.add(t);var i=t.getLabel();ii.isTrue(i.isArea()),this.mergeLabel(i),this.addPoints(t.getEdge(),t.isForward(),n),n=!1,this.setEdgeRing(t,this),t=this.getNext(t)}while(t!==this.En)},Ae.prototype.getLinearRing=function(){return this.kn},Ae.prototype.getCoordinate=function(A){return this.Qn.get(A)},Ae.prototype.computeMaxNodeDegree=function(){this.Nn=0;var A=this.En;do{var t=A.getNode().getEdges().getOutgoingDegree(this);t>this.Nn&&(this.Nn=t),A=this.getNext(A)}while(A!==this.En);this.Nn*=2},Ae.prototype.addPoints=function(A,t,n){var i=A.getCoordinates();if(t){var r=1;n&&(r=0);for(var e=r;e<i.length;e++)this.Qn.add(i[e])}else{var s=i.length-2;n&&(s=i.length-1);for(var u=s;u>=0;u--)this.Qn.add(i[u])}},Ae.prototype.isHole=function(){return this.Bn},Ae.prototype.setInResult=function(){var A=this.En;do{A.getEdge().setInResult(!0),A=A.getNext()}while(A!==this.En)},Ae.prototype.containsPoint=function(A){var t=this.getLinearRing();if(!t.getEnvelopeInternal().contains(A))return!1;if(!hi.isPointInRing(A,t.getCoordinates()))return!1;for(var n=this.Xt.iterator();n.hasNext();)if(n.next().containsPoint(A))return!1;return!0},Ae.prototype.addHole=function(A){this.Xt.add(A)},Ae.prototype.isShell=function(){return null===this.Zt},Ae.prototype.getLabel=function(){return this.Sn},Ae.prototype.getEdges=function(){return this.jn},Ae.prototype.getMaxNodeDegree=function(){return this.Nn<0&&this.computeMaxNodeDegree(),this.Nn},Ae.prototype.getShell=function(){return this.Zt},Ae.prototype.mergeLabel=function(){if(1===arguments.length){var A=arguments[0];this.mergeLabel(A,0),this.mergeLabel(A,1)}else if(2===arguments.length){var t=arguments[0],n=arguments[1],i=t.getLocation(n,qr.RIGHT);if(i===Tn.NONE)return null;if(this.Sn.getLocation(n)===Tn.NONE)return this.Sn.setLocation(n,i),null}},Ae.prototype.setShell=function(A){this.Zt=A,null!==A&&A.addHole(this)},Ae.prototype.toPolygon=function(A){for(var t=new Array(this.Xt.size()).fill(null),n=0;n<this.Xt.size();n++)t[n]=this.Xt.get(n).getLinearRing();return A.createPolygon(this.getLinearRing(),t)},Ae.prototype.interfaces_=function(){return[]},Ae.prototype.getClass=function(){return Ae};var te=function(A){function t(){var t=arguments[0],n=arguments[1];A.call(this,t,n)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.setEdgeRing=function(A,t){A.setMinEdgeRing(t)},t.prototype.getNext=function(A){return A.getNextMin()},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Ae),ne=function(A){function t(){var t=arguments[0],n=arguments[1];A.call(this,t,n)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.buildMinimalRings=function(){var A=new yi,t=this.En;do{if(null===t.getMinEdgeRing()){var n=new te(t,this.Rn);A.add(n)}t=t.getNext()}while(t!==this.En);return A},t.prototype.setEdgeRing=function(A,t){A.setEdgeRing(t)},t.prototype.linkDirectedEdgesForMinimalEdgeRings=function(){var A=this.En;do{A.getNode().getEdges().linkMinimalDirectedEdges(this),A=A.getNext()}while(A!==this.En)},t.prototype.getNext=function(A){return A.getNext()},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Ae),ie=function(){if(this.Sn=null,this.Gn=!1,this.Yn=!1,this.qn=!1,this.Vn=!1,0===arguments.length);else if(1===arguments.length){var A=arguments[0];this.Sn=A}};ie.prototype.setVisited=function(A){this.Vn=A},ie.prototype.setInResult=function(A){this.Gn=A},ie.prototype.isCovered=function(){return this.Yn},ie.prototype.isCoveredSet=function(){return this.qn},ie.prototype.setLabel=function(A){this.Sn=A},ie.prototype.getLabel=function(){return this.Sn},ie.prototype.setCovered=function(A){this.Yn=A,this.qn=!0},ie.prototype.updateIM=function(A){ii.isTrue(this.Sn.getGeometryCount()>=2,"found partial label"),this.computeIM(A)},ie.prototype.isInResult=function(){return this.Gn},ie.prototype.isVisited=function(){return this.Vn},ie.prototype.interfaces_=function(){return[]},ie.prototype.getClass=function(){return ie};var re=function(A){function t(){A.call(this),this.Wn=null,this.jn=null;var t=arguments[0],n=arguments[1];this.Wn=t,this.jn=n,this.Sn=new $r(0,Tn.NONE)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.isIncidentEdgeInResult=function(){for(var A=this.getEdges().getEdges().iterator();A.hasNext();)if(A.next().getEdge().isInResult())return!0;return!1},t.prototype.isIsolated=function(){return 1===this.Sn.getGeometryCount()},t.prototype.getCoordinate=function(){return this.Wn},t.prototype.print=function(A){A.println("node "+this.Wn+" lbl: "+this.Sn)},t.prototype.computeIM=function(A){},t.prototype.computeMergedLocation=function(A,t){var n=Tn.NONE;if(n=this.Sn.getLocation(t),!A.isNull(t)){var i=A.getLocation(t);n!==Tn.BOUNDARY&&(n=i)}return n},t.prototype.setLabel=function(){if(2!==arguments.length)return A.prototype.setLabel.apply(this,arguments);var t=arguments[0],n=arguments[1];null===this.Sn?this.Sn=new $r(t,n):this.Sn.setLocation(t,n)},t.prototype.getEdges=function(){return this.jn},t.prototype.mergeLabel=function(){var A=this;if(arguments[0]instanceof t){var n=arguments[0];this.mergeLabel(n.Sn)}else if(arguments[0]instanceof $r)for(var i=arguments[0],r=0;r<2;r++){var e=A.computeMergedLocation(i,r),s=A.Sn.getLocation(r);s===Tn.NONE&&A.Sn.setLocation(r,e)}},t.prototype.add=function(A){this.jn.insert(A),A.setNode(this)},t.prototype.setLabelBoundary=function(A){if(null===this.Sn)return null;var t=Tn.NONE;null!==this.Sn&&(t=this.Sn.getLocation(A));var n=null;if(t===Tn.BOUNDARY)n=Tn.INTERIOR;else n=Tn.BOUNDARY;this.Sn.setLocation(A,n)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(ie),ee=function(){this.nodeMap=new Vi,this.nodeFact=null;var A=arguments[0];this.nodeFact=A};ee.prototype.find=function(A){return this.nodeMap.get(A)},ee.prototype.addNode=function(){if(arguments[0]instanceof mn){var A=arguments[0],t=this.nodeMap.get(A);return null===t&&(t=this.nodeFact.createNode(A),this.nodeMap.put(A,t)),t}if(arguments[0]instanceof re){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}},ee.prototype.print=function(A){for(var t=this.iterator();t.hasNext();)t.next().print(A)},ee.prototype.iterator=function(){return this.nodeMap.values().iterator()},ee.prototype.values=function(){return this.nodeMap.values()},ee.prototype.getBoundaryNodes=function(A){for(var t=new yi,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(A)===Tn.BOUNDARY&&t.add(i)}return t},ee.prototype.add=function(A){var t=A.getCoordinate();this.addNode(t).add(A)},ee.prototype.interfaces_=function(){return[]},ee.prototype.getClass=function(){return ee};var se=function(){},ue={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};se.prototype.interfaces_=function(){return[]},se.prototype.getClass=function(){return se},se.isNorthern=function(A){return A===se.NE||A===se.NW},se.isOpposite=function(A,t){return A!==t&&2==(A-t+4)%4},se.commonHalfPlane=function(A,t){if(A===t)return A;if(2==(A-t+4)%4)return-1;var n=A<t?A:t;return 0===n&&3===(A>t?A:t)?3:n},se.isInHalfPlane=function(A,t){return t===se.SE?A===se.SE||A===se.SW:A===t||A===t+1},se.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var A=arguments[0],t=arguments[1];if(0===A&&0===t)throw new Dn("Cannot compute the quadrant for point ( "+A+", "+t+" )");return A>=0?t>=0?se.NE:se.SE:t>=0?se.NW:se.SW}if(arguments[0]instanceof mn&&arguments[1]instanceof mn){var n=arguments[0],i=arguments[1];if(i.x===n.x&&i.y===n.y)throw new Dn("Cannot compute the quadrant for two identical points "+n);return i.x>=n.x?i.y>=n.y?se.NE:se.SE:i.y>=n.y?se.NW:se.SW}},ue.NE.get=function(){return 0},ue.NW.get=function(){return 1},ue.SW.get=function(){return 2},ue.SE.get=function(){return 3},Object.defineProperties(se,ue);var oe=function(){if(this._n=null,this.Sn=null,this.Kn=null,this.Hn=null,this.Jn=null,this.Zn=null,this.Xn=null,this.$n=null,1===arguments.length){var A=arguments[0];this._n=A}else if(3===arguments.length){var t=arguments[0],n=arguments[1],i=arguments[2],r=null;this._n=t,this.init(n,i),this.Sn=r}else if(4===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2],o=arguments[3];this._n=e,this.init(s,u),this.Sn=o}};oe.prototype.compareDirection=function(A){return this.Zn===A.Zn&&this.Xn===A.Xn?0:this.$n>A.$n?1:this.$n<A.$n?-1:hi.computeOrientation(A.Hn,A.Jn,this.Jn)},oe.prototype.getDy=function(){return this.Xn},oe.prototype.getCoordinate=function(){return this.Hn},oe.prototype.setNode=function(A){this.Kn=A},oe.prototype.print=function(A){var t=Math.atan2(this.Xn,this.Zn),n=this.getClass().getName(),i=n.lastIndexOf("."),r=n.substring(i+1);A.print("  "+r+": "+this.Hn+" - "+this.Jn+" "+this.$n+":"+t+"   "+this.Sn)},oe.prototype.compareTo=function(A){return this.compareDirection(A)},oe.prototype.getDirectedCoordinate=function(){return this.Jn},oe.prototype.getDx=function(){return this.Zn},oe.prototype.getLabel=function(){return this.Sn},oe.prototype.getEdge=function(){return this._n},oe.prototype.getQuadrant=function(){return this.$n},oe.prototype.getNode=function(){return this.Kn},oe.prototype.toString=function(){var A=Math.atan2(this.Xn,this.Zn),t=this.getClass().getName(),n=t.lastIndexOf(".");return"  "+t.substring(n+1)+": "+this.Hn+" - "+this.Jn+" "+this.$n+":"+A+"   "+this.Sn},oe.prototype.computeLabel=function(A){},oe.prototype.init=function(A,t){this.Hn=A,this.Jn=t,this.Zn=t.x-A.x,this.Xn=t.y-A.y,this.$n=se.quadrant(this.Zn,this.Xn),ii.isTrue(!(0===this.Zn&&0===this.Xn),"EdgeEnd with identical endpoints found")},oe.prototype.interfaces_=function(){return[bn]},oe.prototype.getClass=function(){return oe};var he=function(A){function t(){var t=arguments[0],n=arguments[1];if(A.call(this,t),this.Ai=null,this.Gn=!1,this.Vn=!1,this.ti=null,this.ni=null,this.ii=null,this.ri=null,this.ei=null,this.si=[0,-999,-999],this.Ai=n,n)this.init(t.getCoordinate(0),t.getCoordinate(1));else{var i=t.getNumPoints()-1;this.init(t.getCoordinate(i),t.getCoordinate(i-1))}this.computeDirectedLabel()}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.getNextMin=function(){return this.ii},t.prototype.getDepth=function(A){return this.si[A]},t.prototype.setVisited=function(A){this.Vn=A},t.prototype.computeDirectedLabel=function(){this.Sn=new $r(this._n.getLabel()),this.Ai||this.Sn.flip()},t.prototype.getNext=function(){return this.ni},t.prototype.setDepth=function(A,t){if(-999!==this.si[A]&&this.si[A]!==t)throw new Hr("assigned depths do not match",this.getCoordinate());this.si[A]=t},t.prototype.isInteriorAreaEdge=function(){for(var A=!0,t=0;t<2;t++)this.Sn.isArea(t)&&this.Sn.getLocation(t,qr.LEFT)===Tn.INTERIOR&&this.Sn.getLocation(t,qr.RIGHT)===Tn.INTERIOR||(A=!1);return A},t.prototype.setNextMin=function(A){this.ii=A},t.prototype.print=function(t){A.prototype.print.call(this,t),t.print(" "+this.si[qr.LEFT]+"/"+this.si[qr.RIGHT]),t.print(" ("+this.getDepthDelta()+")"),this.Gn&&t.print(" inResult")},t.prototype.setMinEdgeRing=function(A){this.ei=A},t.prototype.isLineEdge=function(){var A=this.Sn.isLine(0)||this.Sn.isLine(1),t=!this.Sn.isArea(0)||this.Sn.allPositionsEqual(0,Tn.EXTERIOR),n=!this.Sn.isArea(1)||this.Sn.allPositionsEqual(1,Tn.EXTERIOR);return A&&t&&n},t.prototype.setEdgeRing=function(A){this.ri=A},t.prototype.getMinEdgeRing=function(){return this.ei},t.prototype.getDepthDelta=function(){var A=this._n.getDepthDelta();return this.Ai||(A=-A),A},t.prototype.setInResult=function(A){this.Gn=A},t.prototype.getSym=function(){return this.ti},t.prototype.isForward=function(){return this.Ai},t.prototype.getEdge=function(){return this._n},t.prototype.printEdge=function(A){this.print(A),A.print(" "),this.Ai?this._n.print(A):this._n.printReverse(A)},t.prototype.setSym=function(A){this.ti=A},t.prototype.setVisitedEdge=function(A){this.setVisited(A),this.ti.setVisited(A)},t.prototype.setEdgeDepths=function(A,t){var n=this.getEdge().getDepthDelta();this.Ai||(n=-n);var i=1;A===qr.LEFT&&(i=-1);var r=qr.opposite(A),e=t+n*i;this.setDepth(A,t),this.setDepth(r,e)},t.prototype.getEdgeRing=function(){return this.ri},t.prototype.isInResult=function(){return this.Gn},t.prototype.setNext=function(A){this.ni=A},t.prototype.isVisited=function(){return this.Vn},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t.depthFactor=function(A,t){return A===Tn.EXTERIOR&&t===Tn.INTERIOR?1:A===Tn.INTERIOR&&t===Tn.EXTERIOR?-1:0},t}(oe),fe=function(){};fe.prototype.createNode=function(A){return new re(A,null)},fe.prototype.interfaces_=function(){return[]},fe.prototype.getClass=function(){return fe};var ce=function(){if(this.jn=new yi,this.On=null,this.ui=new yi,0===arguments.length)this.On=new ee(new fe);else if(1===arguments.length){var A=arguments[0];this.On=new ee(A)}};ce.prototype.printEdges=function(A){A.println("Edges:");for(var t=0;t<this.jn.size();t++){A.println("edge "+t+":");var n=this.jn.get(t);n.print(A),n.eiList.print(A)}},ce.prototype.find=function(A){return this.On.find(A)},ce.prototype.addNode=function(){if(arguments[0]instanceof re){var A=arguments[0];return this.On.addNode(A)}if(arguments[0]instanceof mn){var t=arguments[0];return this.On.addNode(t)}},ce.prototype.getNodeIterator=function(){return this.On.iterator()},ce.prototype.linkResultDirectedEdges=function(){for(var A=this.On.iterator();A.hasNext();)A.next().getEdges().linkResultDirectedEdges()},ce.prototype.debugPrintln=function(A){Wn.out.println(A)},ce.prototype.isBoundaryNode=function(A,t){var n=this.On.find(t);if(null===n)return!1;var i=n.getLabel();return null!==i&&i.getLocation(A)===Tn.BOUNDARY},ce.prototype.linkAllDirectedEdges=function(){for(var A=this.On.iterator();A.hasNext();)A.next().getEdges().linkAllDirectedEdges()},ce.prototype.matchInSameDirection=function(A,t,n,i){return!!A.equals(n)&&hi.computeOrientation(A,t,i)===hi.COLLINEAR&&se.quadrant(A,t)===se.quadrant(n,i)},ce.prototype.getEdgeEnds=function(){return this.ui},ce.prototype.debugPrint=function(A){Wn.out.print(A)},ce.prototype.getEdgeIterator=function(){return this.jn.iterator()},ce.prototype.findEdgeInSameDirection=function(A,t){for(var n=0;n<this.jn.size();n++){var i=this.jn.get(n),r=i.getCoordinates();if(this.matchInSameDirection(A,t,r[0],r[1]))return i;if(this.matchInSameDirection(A,t,r[r.length-1],r[r.length-2]))return i}return null},ce.prototype.insertEdge=function(A){this.jn.add(A)},ce.prototype.findEdgeEnd=function(A){for(var t=this.getEdgeEnds().iterator();t.hasNext();){var n=t.next();if(n.getEdge()===A)return n}return null},ce.prototype.addEdges=function(A){for(var t=A.iterator();t.hasNext();){var n=t.next();this.jn.add(n);var i=new he(n,!0),r=new he(n,!1);i.setSym(r),r.setSym(i),this.add(i),this.add(r)}},ce.prototype.add=function(A){this.On.add(A),this.ui.add(A)},ce.prototype.getNodes=function(){return this.On.values()},ce.prototype.findEdge=function(A,t){for(var n=0;n<this.jn.size();n++){var i=this.jn.get(n),r=i.getCoordinates();if(A.equals(r[0])&&t.equals(r[1]))return i}return null},ce.prototype.interfaces_=function(){return[]},ce.prototype.getClass=function(){return ce},ce.linkResultDirectedEdges=function(A){for(var t=A.iterator();t.hasNext();)t.next().getEdges().linkResultDirectedEdges()};var ae=function(){this.Rn=null,this.oi=new yi;var A=arguments[0];this.Rn=A};ae.prototype.sortShellsAndHoles=function(A,t,n){for(var i=A.iterator();i.hasNext();){var r=i.next();r.isHole()?n.add(r):t.add(r)}},ae.prototype.computePolygons=function(A){for(var t=new yi,n=A.iterator();n.hasNext();){var i=n.next().toPolygon(this.Rn);t.add(i)}return t},ae.prototype.placeFreeHoles=function(A,t){for(var n=t.iterator();n.hasNext();){var i=n.next();if(null===i.getShell()){var r=this.findEdgeRingContaining(i,A);if(null===r)throw new Hr("unable to assign hole to a shell",i.getCoordinate(0));i.setShell(r)}}},ae.prototype.buildMinimalEdgeRings=function(A,t,n){for(var i=new yi,r=A.iterator();r.hasNext();){var e=r.next();if(e.getMaxNodeDegree()>2){e.linkDirectedEdgesForMinimalEdgeRings();var s=e.buildMinimalRings(),u=this.findShell(s);null!==u?(this.placePolygonHoles(u,s),t.add(u)):n.addAll(s)}else i.add(e)}return i},ae.prototype.containsPoint=function(A){for(var t=this.oi.iterator();t.hasNext();)if(t.next().containsPoint(A))return!0;return!1},ae.prototype.buildMaximalEdgeRings=function(A){for(var t=new yi,n=A.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new ne(i,this.Rn);t.add(r),r.setInResult()}}return t},ae.prototype.placePolygonHoles=function(A,t){for(var n=t.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(A)}},ae.prototype.getPolygons=function(){return this.computePolygons(this.oi)},ae.prototype.findEdgeRingContaining=function(A,t){for(var n=A.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),e=null,s=null,u=t.iterator();u.hasNext();){var o=u.next(),h=o.getLinearRing(),f=h.getEnvelopeInternal();null!==e&&(s=e.getLinearRing().getEnvelopeInternal());var c=!1;f.contains(i)&&hi.isPointInRing(r,h.getCoordinates())&&(c=!0),c&&(null===e||s.contains(f))&&(e=o)}return e},ae.prototype.findShell=function(A){for(var t=0,n=null,i=A.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,t++)}return ii.isTrue(t<=1,"found two shells in MinimalEdgeRing list"),n},ae.prototype.add=function(){if(1===arguments.length){var A=arguments[0];this.add(A.getEdgeEnds(),A.getNodes())}else if(2===arguments.length){var t=arguments[0],n=arguments[1];ce.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(t),r=new yi,e=this.buildMinimalEdgeRings(i,this.oi,r);this.sortShellsAndHoles(e,this.oi,r),this.placeFreeHoles(this.oi,r)}},ae.prototype.interfaces_=function(){return[]},ae.prototype.getClass=function(){return ae};var ve=function(){};ve.prototype.getBounds=function(){},ve.prototype.interfaces_=function(){return[]},ve.prototype.getClass=function(){return ve};var le=function(){this.hi=null,this.fi=null;var A=arguments[0],t=arguments[1];this.hi=A,this.fi=t};le.prototype.getItem=function(){return this.fi},le.prototype.getBounds=function(){return this.hi},le.prototype.interfaces_=function(){return[ve,xn]},le.prototype.getClass=function(){return le};var we=function(){this.ci=null,this.ai=null,this.ci=0,this.ai=new yi,this.ai.add(null)};we.prototype.poll=function(){if(this.isEmpty())return null;var A=this.ai.get(1);return this.ai.set(1,this.ai.get(this.ci)),this.ci-=1,this.reorder(1),A},we.prototype.size=function(){return this.ci},we.prototype.reorder=function(A){for(var t=null,n=this.ai.get(A);2*A<=this.ci&&((t=2*A)!==this.ci&&this.ai.get(t+1).compareTo(this.ai.get(t))<0&&t++,this.ai.get(t).compareTo(n)<0);A=t)this.ai.set(A,this.ai.get(t));this.ai.set(A,n)},we.prototype.clear=function(){this.ci=0,this.ai.clear()},we.prototype.isEmpty=function(){return 0===this.ci},we.prototype.add=function(A){this.ai.add(null),this.ci+=1;var t=this.ci;for(this.ai.set(0,A);A.compareTo(this.ai.get(Math.trunc(t/2)))<0;t/=2)this.ai.set(t,this.ai.get(Math.trunc(t/2)));this.ai.set(t,A)},we.prototype.interfaces_=function(){return[]},we.prototype.getClass=function(){return we};var Pe=function(){};Pe.prototype.visitItem=function(A){},Pe.prototype.interfaces_=function(){return[]},Pe.prototype.getClass=function(){return Pe};var ge=function(){};ge.prototype.insert=function(A,t){},ge.prototype.remove=function(A,t){},ge.prototype.query=function(){},ge.prototype.interfaces_=function(){return[]},ge.prototype.getClass=function(){return ge};var Ce=function(){if(this.vi=new yi,this.hi=null,this.li=null,0===arguments.length);else if(1===arguments.length){var A=arguments[0];this.li=A}},De={serialVersionUID:{configurable:!0}};Ce.prototype.getLevel=function(){return this.li},Ce.prototype.size=function(){return this.vi.size()},Ce.prototype.getChildBoundables=function(){return this.vi},Ce.prototype.addChildBoundable=function(A){ii.isTrue(null===this.hi),this.vi.add(A)},Ce.prototype.isEmpty=function(){return this.vi.isEmpty()},Ce.prototype.getBounds=function(){return null===this.hi&&(this.hi=this.computeBounds()),this.hi},Ce.prototype.interfaces_=function(){return[ve,xn]},Ce.prototype.getClass=function(){return Ce},De.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties(Ce,De);var Ie=function(){};Ie.reverseOrder=function(){return{compare:function(A,t){return t.compareTo(A)}}},Ie.min=function(A){return Ie.sort(A),A.get(0)},Ie.sort=function(A,t){var n=A.toArray();t?Ji.sort(n,t):Ji.sort(n);for(var i=A.iterator(),r=0,e=n.length;r<e;r++)i.next(),i.set(n[r])},Ie.singletonList=function(A){var t=new yi;return t.add(A),t};var Me=function(){this.wi=null,this.Pi=null,this.gi=null,this.Ci=null;var A=arguments[0],t=arguments[1],n=arguments[2];this.wi=A,this.Pi=t,this.Ci=n,this.gi=this.distance()};Me.prototype.expandToQueue=function(A,t){var n=Me.isComposite(this.wi),i=Me.isComposite(this.Pi);if(n&&i)return Me.area(this.wi)>Me.area(this.Pi)?(this.expand(this.wi,this.Pi,A,t),null):(this.expand(this.Pi,this.wi,A,t),null);if(n)return this.expand(this.wi,this.Pi,A,t),null;if(i)return this.expand(this.Pi,this.wi,A,t),null;throw new Dn("neither boundable is composite")},Me.prototype.isLeaves=function(){return!(Me.isComposite(this.wi)||Me.isComposite(this.Pi))},Me.prototype.compareTo=function(A){return this.gi<A.gi?-1:this.gi>A.gi?1:0},Me.prototype.expand=function(A,t,n,i){for(var r=A.getChildBoundables().iterator();r.hasNext();){var e=r.next(),s=new Me(e,t,this.Ci);s.getDistance()<i&&n.add(s)}},Me.prototype.getBoundable=function(A){return 0===A?this.wi:this.Pi},Me.prototype.getDistance=function(){return this.gi},Me.prototype.distance=function(){return this.isLeaves()?this.Ci.distance(this.wi,this.Pi):this.wi.getBounds().distance(this.Pi.getBounds())},Me.prototype.interfaces_=function(){return[bn]},Me.prototype.getClass=function(){return Me},Me.area=function(A){return A.getBounds().getArea()},Me.isComposite=function(A){return A instanceof Ce};var be=function A(){if(this.Di=null,this.Ii=!1,this.Mi=new yi,this.bi=null,0===arguments.length){var t=A.DEFAULT_NODE_CAPACITY;this.bi=t}else if(1===arguments.length){var n=arguments[0];ii.isTrue(n>1,"Node capacity must be greater than 1"),this.bi=n}},ze={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};be.prototype.getNodeCapacity=function(){return this.bi},be.prototype.lastNode=function(A){return A.get(A.size()-1)},be.prototype.size=function(){var A=this;if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this.Di));if(1===arguments.length){for(var t=arguments[0],n=0,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof Ce?n+=A.size(r):r instanceof le&&(n+=1)}return n}},be.prototype.removeItem=function(A,t){for(var n=null,i=A.getChildBoundables().iterator();i.hasNext();){var r=i.next();r instanceof le&&r.getItem()===t&&(n=r)}return null!==n&&(A.getChildBoundables().remove(n),!0)},be.prototype.itemsTree=function(){var A=this;if(0===arguments.length){this.build();var t=this.itemsTree(this.Di);return null===t?new yi:t}if(1===arguments.length){for(var n=arguments[0],i=new yi,r=n.getChildBoundables().iterator();r.hasNext();){var e=r.next();if(e instanceof Ce){var s=A.itemsTree(e);null!==s&&i.add(s)}else e instanceof le?i.add(e.getItem()):ii.shouldNeverReachHere()}return i.size()<=0?null:i}},be.prototype.insert=function(A,t){ii.isTrue(!this.Ii,"Cannot insert items into an STR packed R-tree after it has been built."),this.Mi.add(new le(A,t))},be.prototype.boundablesAtLevel=function(){var A=this;if(1===arguments.length){var t=arguments[0],n=new yi;return this.boundablesAtLevel(t,this.Di,n),n}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2];if(ii.isTrue(i>-2),r.getLevel()===i)return e.add(r),null;for(var s=r.getChildBoundables().iterator();s.hasNext();){var u=s.next();u instanceof Ce?A.boundablesAtLevel(i,u,e):(ii.isTrue(u instanceof le),-1===i&&e.add(u))}return null}},be.prototype.query=function(){var A=this;if(1===arguments.length){var t=arguments[0];this.build();var n=new yi;return this.isEmpty()||this.getIntersectsOp().intersects(this.Di.getBounds(),t)&&this.query(t,this.Di,n),n}if(2===arguments.length){var i=arguments[0],r=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this.Di.getBounds(),i)&&this.query(i,this.Di,r)}else if(3===arguments.length)if(Fn(arguments[2],Pe)&&arguments[0]instanceof Object&&arguments[1]instanceof Ce)for(var e=arguments[0],s=arguments[1],u=arguments[2],o=s.getChildBoundables(),h=0;h<o.size();h++){var f=o.get(h);A.getIntersectsOp().intersects(f.getBounds(),e)&&(f instanceof Ce?A.query(e,f,u):f instanceof le?u.visitItem(f.getItem()):ii.shouldNeverReachHere())}else if(Fn(arguments[2],xi)&&arguments[0]instanceof Object&&arguments[1]instanceof Ce)for(var c=arguments[0],a=arguments[1],v=arguments[2],l=a.getChildBoundables(),w=0;w<l.size();w++){var P=l.get(w);A.getIntersectsOp().intersects(P.getBounds(),c)&&(P instanceof Ce?A.query(c,P,v):P instanceof le?v.add(P.getItem()):ii.shouldNeverReachHere())}},be.prototype.build=function(){if(this.Ii)return null;this.Di=this.Mi.isEmpty()?this.createNode(0):this.createHigherLevels(this.Mi,-1),this.Mi=null,this.Ii=!0},be.prototype.getRoot=function(){return this.build(),this.Di},be.prototype.remove=function(){var A=this;if(2===arguments.length){var t=arguments[0],n=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this.Di.getBounds(),t)&&this.remove(t,this.Di,n)}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2],s=this.removeItem(r,e);if(s)return!0;for(var u=null,o=r.getChildBoundables().iterator();o.hasNext();){var h=o.next();if(A.getIntersectsOp().intersects(h.getBounds(),i)&&h instanceof Ce&&(s=A.remove(i,h,e))){u=h;break}}return null!==u&&u.getChildBoundables().isEmpty()&&r.getChildBoundables().remove(u),s}},be.prototype.createHigherLevels=function(A,t){ii.isTrue(!A.isEmpty());var n=this.createParentBoundables(A,t+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,t+1)},be.prototype.depth=function(){var A=this;if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this.Di));if(1===arguments.length){for(var t=arguments[0],n=0,i=t.getChildBoundables().iterator();i.hasNext();){var r=i.next();if(r instanceof Ce){var e=A.depth(r);e>n&&(n=e)}}return n+1}},be.prototype.createParentBoundables=function(A,t){ii.isTrue(!A.isEmpty());var n=new yi;n.add(this.createNode(t));var i=new yi(A);Ie.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var e=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(t)),this.lastNode(n).addChildBoundable(e)}return n},be.prototype.isEmpty=function(){return this.Ii?this.Di.isEmpty():this.Mi.isEmpty()},be.prototype.interfaces_=function(){return[xn]},be.prototype.getClass=function(){return be},be.compareDoubles=function(A,t){return A>t?1:A<t?-1:0},ze.IntersectsOp.get=function(){return de},ze.serialVersionUID.get=function(){return-0x35ef64c82d4c5400},ze.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(be,ze);var de=function(){},xe=function(){};xe.prototype.distance=function(A,t){},xe.prototype.interfaces_=function(){return[]},xe.prototype.getClass=function(){return xe};var me=function(A){function t(n){A.call(this,n=n||t.DEFAULT_NODE_CAPACITY)}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={STRtreeNode:{configurable:!0},serialVersionUID:{configurable:!0},xComparator:{configurable:!0},yComparator:{configurable:!0},intersectsOp:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};return t.prototype.createParentBoundablesFromVerticalSlices=function(A,t){ii.isTrue(A.length>0);for(var n=new yi,i=0;i<A.length;i++)n.addAll(this.createParentBoundablesFromVerticalSlice(A[i],t));return n},t.prototype.createNode=function(A){return new ye(A)},t.prototype.size=function(){return 0===arguments.length?A.prototype.size.call(this):A.prototype.size.apply(this,arguments)},t.prototype.insert=function(){if(2!==arguments.length)return A.prototype.insert.apply(this,arguments);var t=arguments[0],n=arguments[1];if(t.isNull())return null;A.prototype.insert.call(this,t,n)},t.prototype.getIntersectsOp=function(){return t.intersectsOp},t.prototype.verticalSlices=function(A,t){for(var n=Math.trunc(Math.ceil(A.size()/t)),i=new Array(t).fill(null),r=A.iterator(),e=0;e<t;e++){i[e]=new yi;for(var s=0;r.hasNext()&&s<n;){var u=r.next();i[e].add(u),s++}}return i},t.prototype.query=function(){if(1===arguments.length){var t=arguments[0];return A.prototype.query.call(this,t)}if(2===arguments.length){var n=arguments[0],i=arguments[1];A.prototype.query.call(this,n,i)}else if(3===arguments.length)if(Fn(arguments[2],Pe)&&arguments[0]instanceof Object&&arguments[1]instanceof Ce){var r=arguments[0],e=arguments[1],s=arguments[2];A.prototype.query.call(this,r,e,s)}else if(Fn(arguments[2],xi)&&arguments[0]instanceof Object&&arguments[1]instanceof Ce){var u=arguments[0],o=arguments[1],h=arguments[2];A.prototype.query.call(this,u,o,h)}},t.prototype.getComparator=function(){return t.yComparator},t.prototype.createParentBoundablesFromVerticalSlice=function(t,n){return A.prototype.createParentBoundables.call(this,t,n)},t.prototype.remove=function(){if(2===arguments.length){var t=arguments[0],n=arguments[1];return A.prototype.remove.call(this,t,n)}return A.prototype.remove.apply(this,arguments)},t.prototype.depth=function(){return 0===arguments.length?A.prototype.depth.call(this):A.prototype.depth.apply(this,arguments)},t.prototype.createParentBoundables=function(A,n){ii.isTrue(!A.isEmpty());var i=Math.trunc(Math.ceil(A.size()/this.getNodeCapacity())),r=new yi(A);Ie.sort(r,t.xComparator);var e=this.verticalSlices(r,Math.trunc(Math.ceil(Math.sqrt(i))));return this.createParentBoundablesFromVerticalSlices(e,n)},t.prototype.nearestNeighbour=function(){if(1===arguments.length){if(Fn(arguments[0],xe)){var A=arguments[0],n=new Me(this.getRoot(),this.getRoot(),A);return this.nearestNeighbour(n)}if(arguments[0]instanceof Me){var i=arguments[0];return this.nearestNeighbour(i,In.POSITIVE_INFINITY)}}else if(2===arguments.length){if(arguments[0]instanceof t&&Fn(arguments[1],xe)){var r=arguments[0],e=arguments[1],s=new Me(this.getRoot(),r.getRoot(),e);return this.nearestNeighbour(s)}if(arguments[0]instanceof Me&&"number"==typeof arguments[1]){var u=arguments[0],o=arguments[1],h=o,f=null,c=new we;for(c.add(u);!c.isEmpty()&&h>0;){var a=c.poll(),v=a.getDistance();if(v>=h)break;a.isLeaves()?(h=v,f=a):a.expandToQueue(c,h)}return[f.getBoundable(0).getItem(),f.getBoundable(1).getItem()]}}else if(3===arguments.length){var l=arguments[0],w=arguments[1],P=arguments[2],g=new le(l,w),C=new Me(this.getRoot(),g,P);return this.nearestNeighbour(C)[0]}},t.prototype.interfaces_=function(){return[ge,xn]},t.prototype.getClass=function(){return t},t.centreX=function(A){return t.avg(A.getMinX(),A.getMaxX())},t.avg=function(A,t){return(A+t)/2},t.centreY=function(A){return t.avg(A.getMinY(),A.getMaxY())},n.STRtreeNode.get=function(){return ye},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0},n.xComparator.get=function(){return{interfaces_:function(){return[dn]},compare:function(n,i){return A.compareDoubles(t.centreX(n.getBounds()),t.centreX(i.getBounds()))}}},n.yComparator.get=function(){return{interfaces_:function(){return[dn]},compare:function(n,i){return A.compareDoubles(t.centreY(n.getBounds()),t.centreY(i.getBounds()))}}},n.intersectsOp.get=function(){return{interfaces_:function(){return[A.IntersectsOp]},intersects:function(A,t){return A.intersects(t)}}},n.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(t,n),t}(be),ye=function(A){function t(){var t=arguments[0];A.call(this,t)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.computeBounds=function(){for(var A=null,t=this.getChildBoundables().iterator();t.hasNext();){var n=t.next();null===A?A=new Kn(n.getBounds()):A.expandToInclude(n.getBounds())}return A},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Ce),pe=function(){};pe.prototype.interfaces_=function(){return[]},pe.prototype.getClass=function(){return pe},pe.relativeSign=function(A,t){return A<t?-1:A>t?1:0},pe.compare=function(A,t,n){if(t.equals2D(n))return 0;var i=pe.relativeSign(t.x,n.x),r=pe.relativeSign(t.y,n.y);switch(A){case 0:return pe.compareValue(i,r);case 1:return pe.compareValue(r,i);case 2:return pe.compareValue(r,-i);case 3:return pe.compareValue(-i,r);case 4:return pe.compareValue(-i,-r);case 5:return pe.compareValue(-r,-i);case 6:return pe.compareValue(-r,i);case 7:return pe.compareValue(i,-r)}return ii.shouldNeverReachHere("invalid octant value"),0},pe.compareValue=function(A,t){return A<0?-1:A>0?1:t<0?-1:t>0?1:0};var Le=function(){this.zi=null,this.coord=null,this.segmentIndex=null,this.di=null,this.xi=null;var A=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.zi=A,this.coord=new mn(t),this.segmentIndex=n,this.di=i,this.xi=!t.equals2D(A.getCoordinate(n))};Le.prototype.getCoordinate=function(){return this.coord},Le.prototype.print=function(A){A.print(this.coord),A.print(" seg # = "+this.segmentIndex)},Le.prototype.compareTo=function(A){var t=A;return this.segmentIndex<t.segmentIndex?-1:this.segmentIndex>t.segmentIndex?1:this.coord.equals2D(t.coord)?0:pe.compare(this.di,this.coord,t.coord)},Le.prototype.isEndPoint=function(A){return 0===this.segmentIndex&&!this.xi||this.segmentIndex===A},Le.prototype.isInterior=function(){return this.xi},Le.prototype.interfaces_=function(){return[bn]},Le.prototype.getClass=function(){return Le};var Te=function(){this.mi=new Vi,this._n=null;var A=arguments[0];this._n=A};Te.prototype.getSplitCoordinates=function(){var A=new Li;this.addEndpoints();for(var t=this.iterator(),n=t.next();t.hasNext();){var i=t.next();this.addEdgeCoordinates(n,i,A),n=i}return A.toCoordinateArray()},Te.prototype.addCollapsedNodes=function(){var A=new yi;this.findCollapsesFromInsertedNodes(A),this.findCollapsesFromExistingVertices(A);for(var t=A.iterator();t.hasNext();){var n=t.next().intValue();this.add(this._n.getCoordinate(n),n)}},Te.prototype.print=function(A){A.println("Intersections:");for(var t=this.iterator();t.hasNext();)t.next().print(A)},Te.prototype.findCollapsesFromExistingVertices=function(A){for(var t=0;t<this._n.size()-2;t++){var n=this._n.getCoordinate(t),i=this._n.getCoordinate(t+2);n.equals2D(i)&&A.add(new jn(t+1))}},Te.prototype.addEdgeCoordinates=function(A,t,n){var i=this._n.getCoordinate(t.segmentIndex),r=t.isInterior()||!t.coord.equals2D(i);n.add(new mn(A.coord),!1);for(var e=A.segmentIndex+1;e<=t.segmentIndex;e++)n.add(this._n.getCoordinate(e));r&&n.add(new mn(t.coord))},Te.prototype.iterator=function(){return this.mi.values().iterator()},Te.prototype.addSplitEdges=function(A){this.addEndpoints(),this.addCollapsedNodes();for(var t=this.iterator(),n=t.next();t.hasNext();){var i=t.next(),r=this.createSplitEdge(n,i);A.add(r),n=i}},Te.prototype.findCollapseIndex=function(A,t,n){if(!A.coord.equals2D(t.coord))return!1;var i=t.segmentIndex-A.segmentIndex;return t.isInterior()||i--,1===i&&(n[0]=A.segmentIndex+1,!0)},Te.prototype.findCollapsesFromInsertedNodes=function(A){for(var t=new Array(1).fill(null),n=this.iterator(),i=n.next();n.hasNext();){var r=n.next();this.findCollapseIndex(i,r,t)&&A.add(new jn(t[0])),i=r}},Te.prototype.getEdge=function(){return this._n},Te.prototype.addEndpoints=function(){var A=this._n.size()-1;this.add(this._n.getCoordinate(0),0),this.add(this._n.getCoordinate(A),A)},Te.prototype.createSplitEdge=function(A,t){var n=t.segmentIndex-A.segmentIndex+2,i=this._n.getCoordinate(t.segmentIndex),r=t.isInterior()||!t.coord.equals2D(i);r||n--;var e=new Array(n).fill(null),s=0;e[s++]=new mn(A.coord);for(var u=A.segmentIndex+1;u<=t.segmentIndex;u++)e[s++]=this._n.getCoordinate(u);return r&&(e[s]=new mn(t.coord)),new Ee(e,this._n.getData())},Te.prototype.add=function(A,t){var n=new Le(this._n,A,t,this._n.getSegmentOctant(t)),i=this.mi.get(n);return null!==i?(ii.isTrue(i.coord.equals2D(A),"Found equal nodes with different coordinates"),i):(this.mi.put(n,n),n)},Te.prototype.checkSplitEdgesCorrectness=function(A){var t=this._n.getCoordinates(),n=A.get(0).getCoordinate(0);if(!n.equals2D(t[0]))throw new ti("bad split edge start point at "+n);var i=A.get(A.size()-1).getCoordinates(),r=i[i.length-1];if(!r.equals2D(t[t.length-1]))throw new ti("bad split edge end point at "+r)},Te.prototype.interfaces_=function(){return[]},Te.prototype.getClass=function(){return Te};var Oe=function(){};Oe.prototype.interfaces_=function(){return[]},Oe.prototype.getClass=function(){return Oe},Oe.octant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var A=arguments[0],t=arguments[1];if(0===A&&0===t)throw new Dn("Cannot compute the octant for point ( "+A+", "+t+" )");var n=Math.abs(A),i=Math.abs(t);return A>=0?t>=0?n>=i?0:1:n>=i?7:6:t>=0?n>=i?3:2:n>=i?4:5}if(arguments[0]instanceof mn&&arguments[1]instanceof mn){var r=arguments[0],e=arguments[1],s=e.x-r.x,u=e.y-r.y;if(0===s&&0===u)throw new Dn("Cannot compute the octant for two identical points "+r);return Oe.octant(s,u)}};var Fe=function(){};Fe.prototype.getCoordinates=function(){},Fe.prototype.size=function(){},Fe.prototype.getCoordinate=function(A){},Fe.prototype.isClosed=function(){},Fe.prototype.setData=function(A){},Fe.prototype.getData=function(){},Fe.prototype.interfaces_=function(){return[]},Fe.prototype.getClass=function(){return Fe};var Ue=function(){};Ue.prototype.addIntersection=function(A,t){},Ue.prototype.interfaces_=function(){return[Fe]},Ue.prototype.getClass=function(){return Ue};var Ee=function(){this.yi=new Te(this),this.Qn=null,this.pi=null;var A=arguments[0],t=arguments[1];this.Qn=A,this.pi=t};Ee.prototype.getCoordinates=function(){return this.Qn},Ee.prototype.size=function(){return this.Qn.length},Ee.prototype.getCoordinate=function(A){return this.Qn[A]},Ee.prototype.isClosed=function(){return this.Qn[0].equals(this.Qn[this.Qn.length-1])},Ee.prototype.getSegmentOctant=function(A){return A===this.Qn.length-1?-1:this.safeOctant(this.getCoordinate(A),this.getCoordinate(A+1))},Ee.prototype.setData=function(A){this.pi=A},Ee.prototype.safeOctant=function(A,t){return A.equals2D(t)?0:Oe.octant(A,t)},Ee.prototype.getData=function(){return this.pi},Ee.prototype.addIntersection=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1];this.addIntersectionNode(A,t)}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[3],e=new mn(n.getIntersection(r));this.addIntersection(e,i)}},Ee.prototype.toString=function(){return Ai.toLineString(new yr(this.Qn))},Ee.prototype.getNodeList=function(){return this.yi},Ee.prototype.addIntersectionNode=function(A,t){var n=t,i=n+1;i<this.Qn.length&&(A.equals2D(this.Qn[i])&&(n=i));return this.yi.add(A,n)},Ee.prototype.addIntersections=function(A,t,n){for(var i=0;i<A.getIntersectionNum();i++)this.addIntersection(A,t,n,i)},Ee.prototype.interfaces_=function(){return[Ue]},Ee.prototype.getClass=function(){return Ee},Ee.getNodedSubstrings=function(){if(1===arguments.length){var A=arguments[0],t=new yi;return Ee.getNodedSubstrings(A,t),t}if(2===arguments.length)for(var n=arguments[0],i=arguments[1],r=n.iterator();r.hasNext();){var e=r.next();e.getNodeList().addSplitEdges(i)}};var Ne=function(){if(this.p0=null,this.p1=null,0===arguments.length)this.p0=new mn,this.p1=new mn;else if(1===arguments.length){var A=arguments[0];this.p0=new mn(A.p0),this.p1=new mn(A.p1)}else if(2===arguments.length)this.p0=arguments[0],this.p1=arguments[1];else if(4===arguments.length){var t=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3];this.p0=new mn(t,n),this.p1=new mn(i,r)}},je={serialVersionUID:{configurable:!0}};Ne.prototype.minX=function(){return Math.min(this.p0.x,this.p1.x)},Ne.prototype.orientationIndex=function(){if(arguments[0]instanceof Ne){var A=arguments[0],t=hi.orientationIndex(this.p0,this.p1,A.p0),n=hi.orientationIndex(this.p0,this.p1,A.p1);return t>=0&&n>=0||t<=0&&n<=0?Math.max(t,n):0}if(arguments[0]instanceof mn){var i=arguments[0];return hi.orientationIndex(this.p0,this.p1,i)}},Ne.prototype.toGeometry=function(A){return A.createLineString([this.p0,this.p1])},Ne.prototype.isVertical=function(){return this.p0.x===this.p1.x},Ne.prototype.equals=function(A){if(!(A instanceof Ne))return!1;var t=A;return this.p0.equals(t.p0)&&this.p1.equals(t.p1)},Ne.prototype.intersection=function(A){var t=new si;return t.computeIntersection(this.p0,this.p1,A.p0,A.p1),t.hasIntersection()?t.getIntersection(0):null},Ne.prototype.project=function(){if(arguments[0]instanceof mn){var A=arguments[0];if(A.equals(this.p0)||A.equals(this.p1))return new mn(A);var t=this.projectionFactor(A),n=new mn;return n.x=this.p0.x+t*(this.p1.x-this.p0.x),n.y=this.p0.y+t*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof Ne){var i=arguments[0],r=this.projectionFactor(i.p0),e=this.projectionFactor(i.p1);if(r>=1&&e>=1)return null;if(r<=0&&e<=0)return null;var s=this.project(i.p0);r<0&&(s=this.p0),r>1&&(s=this.p1);var u=this.project(i.p1);return e<0&&(u=this.p0),e>1&&(u=this.p1),new Ne(s,u)}},Ne.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},Ne.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},Ne.prototype.getCoordinate=function(A){return 0===A?this.p0:this.p1},Ne.prototype.distancePerpendicular=function(A){return hi.distancePointLinePerpendicular(A,this.p0,this.p1)},Ne.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},Ne.prototype.midPoint=function(){return Ne.midPoint(this.p0,this.p1)},Ne.prototype.projectionFactor=function(A){if(A.equals(this.p0))return 0;if(A.equals(this.p1))return 1;var t=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=t*t+n*n;return i<=0?In.NaN:((A.x-this.p0.x)*t+(A.y-this.p0.y)*n)/i},Ne.prototype.closestPoints=function(A){var t=this.intersection(A);if(null!==t)return[t,t];var n=new Array(2).fill(null),i=In.MAX_VALUE,r=null,e=this.closestPoint(A.p0);i=e.distance(A.p0),n[0]=e,n[1]=A.p0;var s=this.closestPoint(A.p1);(r=s.distance(A.p1))<i&&(i=r,n[0]=s,n[1]=A.p1);var u=A.closestPoint(this.p0);(r=u.distance(this.p0))<i&&(i=r,n[0]=this.p0,n[1]=u);var o=A.closestPoint(this.p1);return(r=o.distance(this.p1))<i&&(i=r,n[0]=this.p1,n[1]=o),n},Ne.prototype.closestPoint=function(A){var t=this.projectionFactor(A);return t>0&&t<1?this.project(A):this.p0.distance(A)<this.p1.distance(A)?this.p0:this.p1},Ne.prototype.maxX=function(){return Math.max(this.p0.x,this.p1.x)},Ne.prototype.getLength=function(){return this.p0.distance(this.p1)},Ne.prototype.compareTo=function(A){var t=A,n=this.p0.compareTo(t.p0);return 0!==n?n:this.p1.compareTo(t.p1)},Ne.prototype.reverse=function(){var A=this.p0;this.p0=this.p1,this.p1=A},Ne.prototype.equalsTopo=function(A){return this.p0.equals(A.p0)&&(this.p1.equals(A.p1)||this.p0.equals(A.p1))&&this.p1.equals(A.p0)},Ne.prototype.lineIntersection=function(A){try{return _n.intersection(this.p0,this.p1,A.p0,A.p1)}catch(A){if(!(A instanceof Vn))throw A}return null},Ne.prototype.maxY=function(){return Math.max(this.p0.y,this.p1.y)},Ne.prototype.pointAlongOffset=function(A,t){var n=this.p0.x+A*(this.p1.x-this.p0.x),i=this.p0.y+A*(this.p1.y-this.p0.y),r=this.p1.x-this.p0.x,e=this.p1.y-this.p0.y,s=Math.sqrt(r*r+e*e),u=0,o=0;if(0!==t){if(s<=0)throw new Error("Cannot compute offset from zero-length line segment");u=t*r/s,o=t*e/s}return new mn(n-o,i+u)},Ne.prototype.setCoordinates=function(){if(1===arguments.length){var A=arguments[0];this.setCoordinates(A.p0,A.p1)}else if(2===arguments.length){var t=arguments[0],n=arguments[1];this.p0.x=t.x,this.p0.y=t.y,this.p1.x=n.x,this.p1.y=n.y}},Ne.prototype.segmentFraction=function(A){var t=this.projectionFactor(A);return t<0?t=0:(t>1||In.isNaN(t))&&(t=1),t},Ne.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},Ne.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},Ne.prototype.distance=function(){if(arguments[0]instanceof Ne){var A=arguments[0];return hi.distanceLineLine(this.p0,this.p1,A.p0,A.p1)}if(arguments[0]instanceof mn){var t=arguments[0];return hi.distancePointLine(t,this.p0,this.p1)}},Ne.prototype.pointAlong=function(A){var t=new mn;return t.x=this.p0.x+A*(this.p1.x-this.p0.x),t.y=this.p0.y+A*(this.p1.y-this.p0.y),t},Ne.prototype.hashCode=function(){var A=In.doubleToLongBits(this.p0.x);A^=31*In.doubleToLongBits(this.p0.y);var t=Math.trunc(A)^Math.trunc(A>>32),n=In.doubleToLongBits(this.p1.x);return n^=31*In.doubleToLongBits(this.p1.y),t^Math.trunc(n)^Math.trunc(n>>32)},Ne.prototype.interfaces_=function(){return[bn,xn]},Ne.prototype.getClass=function(){return Ne},Ne.midPoint=function(A,t){return new mn((A.x+t.x)/2,(A.y+t.y)/2)},je.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(Ne,je);var Qe=function(){this.tempEnv1=new Kn,this.tempEnv2=new Kn,this.Li=new Ne,this.Ti=new Ne};Qe.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){var A=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];A.getLineSegment(t,this.Li),n.getLineSegment(i,this.Ti),this.overlap(this.Li,this.Ti)}},Qe.prototype.interfaces_=function(){return[]},Qe.prototype.getClass=function(){return Qe};var Se=function(){this.Qn=null,this.Oi=null,this.Fi=null,this.Un=null,this.Ui=null,this.Ei=null;var A=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.Qn=A,this.Oi=t,this.Fi=n,this.Ui=i};Se.prototype.getLineSegment=function(A,t){t.p0=this.Qn[A],t.p1=this.Qn[A+1]},Se.prototype.computeSelect=function(A,t,n,i){if(i.tempEnv1.init(this.Qn[t],this.Qn[n]),n-t==1)return i.select(this,t),null;if(!A.intersects(i.tempEnv1))return null;var s=Math.trunc((t+n)/2);t<s&&this.computeSelect(A,t,s,i),s<n&&this.computeSelect(A,s,n,i)},Se.prototype.getCoordinates=function(){for(var A=new Array(this.Fi-this.Oi+1).fill(null),t=0,n=this.Oi;n<=this.Fi;n++)A[t++]=this.Qn[n];return A},Se.prototype.computeOverlaps=function(A,t){this.computeOverlapsInternal(this.Oi,this.Fi,A,A.Oi,A.Fi,t)},Se.prototype.setId=function(A){this.Ei=A},Se.prototype.select=function(A,t){this.computeSelect(A,this.Oi,this.Fi,t)},Se.prototype.getEnvelope=function(){null===this.Un&&(this.Un=new Kn(this.Qn[this.Oi],this.Qn[this.Fi]));return this.Un},Se.prototype.getEndIndex=function(){return this.Fi},Se.prototype.getStartIndex=function(){return this.Oi},Se.prototype.getContext=function(){return this.Ui},Se.prototype.getId=function(){return this.Ei},Se.prototype.computeOverlapsInternal=function(A,t,n,i,r,e){var s=this.Qn[A],u=this.Qn[t],o=n.Qn[i],h=n.Qn[r];if(t-A==1&&r-i==1)return e.overlap(this,A,n,i),null;if(e.tempEnv1.init(s,u),e.tempEnv2.init(o,h),!e.tempEnv1.intersects(e.tempEnv2))return null;var f=Math.trunc((A+t)/2),c=Math.trunc((i+r)/2);A<f&&(i<c&&this.computeOverlapsInternal(A,f,n,i,c,e),c<r&&this.computeOverlapsInternal(A,f,n,c,r,e)),f<t&&(i<c&&this.computeOverlapsInternal(f,t,n,i,c,e),c<r&&this.computeOverlapsInternal(f,t,n,c,r,e))},Se.prototype.interfaces_=function(){return[]},Se.prototype.getClass=function(){return Se};var ke=function(){};ke.prototype.interfaces_=function(){return[]},ke.prototype.getClass=function(){return ke},ke.getChainStartIndices=function(A){var t=0,n=new yi;n.add(new jn(t));do{var i=ke.findChainEnd(A,t);n.add(new jn(i)),t=i}while(t<A.length-1);return ke.toIntArray(n)},ke.findChainEnd=function(A,t){for(var n=t;n<A.length-1&&A[n].equals2D(A[n+1]);)n++;if(n>=A.length-1)return A.length-1;for(var i=se.quadrant(A[n],A[n+1]),r=t+1;r<A.length&&(A[r-1].equals2D(A[r])||se.quadrant(A[r-1],A[r])===i);)r++;return r-1},ke.getChains=function(){if(1===arguments.length){var A=arguments[0];return ke.getChains(A,null)}if(2===arguments.length){for(var t=arguments[0],n=arguments[1],i=new yi,r=ke.getChainStartIndices(t),e=0;e<r.length-1;e++){var s=new Se(t,r[e],r[e+1],n);i.add(s)}return i}},ke.toIntArray=function(A){for(var t=new Array(A.size()).fill(null),n=0;n<t.length;n++)t[n]=A.get(n).intValue();return t};var Be=function(){};Be.prototype.computeNodes=function(A){},Be.prototype.getNodedSubstrings=function(){},Be.prototype.interfaces_=function(){return[]},Be.prototype.getClass=function(){return Be};var Re=function(){if(this.Ni=null,0===arguments.length);else if(1===arguments.length){var A=arguments[0];this.setSegmentIntersector(A)}};Re.prototype.setSegmentIntersector=function(A){this.Ni=A},Re.prototype.interfaces_=function(){return[Be]},Re.prototype.getClass=function(){return Re};var Ge=function(A){function t(t){t?A.call(this,t):A.call(this),this.ji=new yi,this.Qi=new me,this.Si=0,this.ki=null,this.Bi=0}A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t;var n={SegmentOverlapAction:{configurable:!0}};return t.prototype.getMonotoneChains=function(){return this.ji},t.prototype.getNodedSubstrings=function(){return Ee.getNodedSubstrings(this.ki)},t.prototype.getIndex=function(){return this.Qi},t.prototype.add=function(A){for(var t=ke.getChains(A.getCoordinates(),A).iterator();t.hasNext();){var n=t.next();n.setId(this.Si++),this.Qi.insert(n.getEnvelope(),n),this.ji.add(n)}},t.prototype.computeNodes=function(A){this.ki=A;for(var t=A.iterator();t.hasNext();)this.add(t.next());this.intersectChains()},t.prototype.intersectChains=function(){for(var A=new Ye(this.Ni),t=this.ji.iterator();t.hasNext();)for(var n=t.next(),i=this.Qi.query(n.getEnvelope()).iterator();i.hasNext();){var r=i.next();if(r.getId()>n.getId()&&(n.computeOverlaps(r,A),this.Bi++),this.Ni.isDone())return null}},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},n.SegmentOverlapAction.get=function(){return Ye},Object.defineProperties(t,n),t}(Re),Ye=function(A){function t(){A.call(this),this.Ri=null;var t=arguments[0];this.Ri=t}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.overlap=function(){if(4!==arguments.length)return A.prototype.overlap.apply(this,arguments);var t=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3],e=t.getContext(),s=i.getContext();this.Ri.processIntersections(e,n,s,r)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Qe),qe=function A(){if(this.Gi=A.DEFAULT_QUADRANT_SEGMENTS,this.Yi=A.CAP_ROUND,this.qi=A.JOIN_ROUND,this.Vi=A.DEFAULT_MITRE_LIMIT,this.Wi=!1,this._i=A.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(i)}else if(4===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2],u=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(e),this.setJoinStyle(s),this.setMitreLimit(u)}},Ve={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};qe.prototype.getEndCapStyle=function(){return this.Yi},qe.prototype.isSingleSided=function(){return this.Wi},qe.prototype.setQuadrantSegments=function(A){this.Gi=A,0===this.Gi&&(this.qi=qe.JOIN_BEVEL),this.Gi<0&&(this.qi=qe.JOIN_MITRE,this.Vi=Math.abs(this.Gi)),A<=0&&(this.Gi=1),this.qi!==qe.JOIN_ROUND&&(this.Gi=qe.DEFAULT_QUADRANT_SEGMENTS)},qe.prototype.getJoinStyle=function(){return this.qi},qe.prototype.setJoinStyle=function(A){this.qi=A},qe.prototype.setSimplifyFactor=function(A){this._i=A<0?0:A},qe.prototype.getSimplifyFactor=function(){return this._i},qe.prototype.getQuadrantSegments=function(){return this.Gi},qe.prototype.setEndCapStyle=function(A){this.Yi=A},qe.prototype.getMitreLimit=function(){return this.Vi},qe.prototype.setMitreLimit=function(A){this.Vi=A},qe.prototype.setSingleSided=function(A){this.Wi=A},qe.prototype.interfaces_=function(){return[]},qe.prototype.getClass=function(){return qe},qe.bufferDistanceError=function(A){var t=Math.PI/2/A;return 1-Math.cos(t/2)},Ve.CAP_ROUND.get=function(){return 1},Ve.CAP_FLAT.get=function(){return 2},Ve.CAP_SQUARE.get=function(){return 3},Ve.JOIN_ROUND.get=function(){return 1},Ve.JOIN_MITRE.get=function(){return 2},Ve.JOIN_BEVEL.get=function(){return 3},Ve.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},Ve.DEFAULT_MITRE_LIMIT.get=function(){return 5},Ve.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(qe,Ve);var We=function(A){this.Ki=null,this.Hi=null,this.Ji=hi.COUNTERCLOCKWISE,this.Zi=A||null},_e={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};We.prototype.isDeletable=function(A,t,n,i){var r=this.Zi[A],e=this.Zi[t],s=this.Zi[n];return!!this.isConcave(r,e,s)&&!!this.isShallow(r,e,s,i)&&this.isShallowSampled(r,e,A,n,i)},We.prototype.deleteShallowConcavities=function(){for(var A=1,t=this.findNextNonDeletedIndex(A),n=this.findNextNonDeletedIndex(t),i=!1;n<this.Zi.length;){var r=!1;this.isDeletable(A,t,n,this.Ki)&&(this.Hi[t]=We.DELETE,r=!0,i=!0),t=this.findNextNonDeletedIndex(A=r?n:t),n=this.findNextNonDeletedIndex(t)}return i},We.prototype.isShallowConcavity=function(A,t,n,i){return hi.computeOrientation(A,t,n)===this.Ji&&hi.distancePointLine(t,A,n)<i},We.prototype.isShallowSampled=function(A,t,n,i,r){var e=Math.trunc((i-n)/We.NUM_PTS_TO_CHECK);e<=0&&(e=1);for(var s=n;s<i;s+=e)if(!this.isShallow(A,t,this.Zi[s],r))return!1;return!0},We.prototype.isConcave=function(A,t,n){return hi.computeOrientation(A,t,n)===this.Ji},We.prototype.simplify=function(A){this.Ki=Math.abs(A),A<0&&(this.Ji=hi.CLOCKWISE),this.Hi=new Array(this.Zi.length).fill(null);var t=!1;do{t=this.deleteShallowConcavities()}while(t);return this.collapseLine()},We.prototype.findNextNonDeletedIndex=function(A){for(var t=A+1;t<this.Zi.length&&this.Hi[t]===We.DELETE;)t++;return t},We.prototype.isShallow=function(A,t,n,i){return hi.distancePointLine(t,A,n)<i},We.prototype.collapseLine=function(){for(var A=new Li,t=0;t<this.Zi.length;t++)this.Hi[t]!==We.DELETE&&A.add(this.Zi[t]);return A.toCoordinateArray()},We.prototype.interfaces_=function(){return[]},We.prototype.getClass=function(){return We},We.simplify=function(A,t){return new We(A).simplify(t)},_e.INIT.get=function(){return 0},_e.DELETE.get=function(){return 1},_e.KEEP.get=function(){return 1},_e.NUM_PTS_TO_CHECK.get=function(){return 10},Object.defineProperties(We,_e);var Ke=function(){this.Xi=null,this.sn=null,this.$i=0,this.Xi=new yi},He={COORDINATE_ARRAY_TYPE:{configurable:!0}};Ke.prototype.getCoordinates=function(){return this.Xi.toArray(Ke.COORDINATE_ARRAY_TYPE)},Ke.prototype.setPrecisionModel=function(A){this.sn=A},Ke.prototype.addPt=function(A){var t=new mn(A);if(this.sn.makePrecise(t),this.isRedundant(t))return null;this.Xi.add(t)},Ke.prototype.revere=function(){},Ke.prototype.addPts=function(A,t){if(t)for(var n=0;n<A.length;n++)this.addPt(A[n]);else for(var i=A.length-1;i>=0;i--)this.addPt(A[i])},Ke.prototype.isRedundant=function(A){if(this.Xi.size()<1)return!1;var t=this.Xi.get(this.Xi.size()-1);return A.distance(t)<this.$i},Ke.prototype.toString=function(){return(new jr).createLineString(this.getCoordinates()).toString()},Ke.prototype.closeRing=function(){if(this.Xi.size()<1)return null;var A=new mn(this.Xi.get(0)),t=this.Xi.get(this.Xi.size()-1);if(A.equals(t))return null;this.Xi.add(A)},Ke.prototype.setMinimumVertexDistance=function(A){this.$i=A},Ke.prototype.interfaces_=function(){return[]},Ke.prototype.getClass=function(){return Ke},He.COORDINATE_ARRAY_TYPE.get=function(){return new Array(0).fill(null)},Object.defineProperties(Ke,He);var Je=function(){},Ze={PI_TIMES_2:{configurable:!0},PI_OVER_2:{configurable:!0},PI_OVER_4:{configurable:!0},COUNTERCLOCKWISE:{configurable:!0},CLOCKWISE:{configurable:!0},NONE:{configurable:!0}};Je.prototype.interfaces_=function(){return[]},Je.prototype.getClass=function(){return Je},Je.toDegrees=function(A){return 180*A/Math.PI},Je.normalize=function(A){for(;A>Math.PI;)A-=Je.PI_TIMES_2;for(;A<=-Math.PI;)A+=Je.PI_TIMES_2;return A},Je.angle=function(){if(1===arguments.length){var A=arguments[0];return Math.atan2(A.y,A.x)}if(2===arguments.length){var t=arguments[0],n=arguments[1],i=n.x-t.x,r=n.y-t.y;return Math.atan2(r,i)}},Je.isAcute=function(A,t,n){return(A.x-t.x)*(n.x-t.x)+(A.y-t.y)*(n.y-t.y)>0},Je.isObtuse=function(A,t,n){return(A.x-t.x)*(n.x-t.x)+(A.y-t.y)*(n.y-t.y)<0},Je.interiorAngle=function(A,t,n){var i=Je.angle(t,A),r=Je.angle(t,n);return Math.abs(r-i)},Je.normalizePositive=function(A){if(A<0){for(;A<0;)A+=Je.PI_TIMES_2;A>=Je.PI_TIMES_2&&(A=0)}else{for(;A>=Je.PI_TIMES_2;)A-=Je.PI_TIMES_2;A<0&&(A=0)}return A},Je.angleBetween=function(A,t,n){var i=Je.angle(t,A),r=Je.angle(t,n);return Je.diff(i,r)},Je.diff=function(A,t){var n=null;return(n=A<t?t-A:A-t)>Math.PI&&(n=2*Math.PI-n),n},Je.toRadians=function(A){return A*Math.PI/180},Je.getTurn=function(A,t){var n=Math.sin(t-A);return n>0?Je.COUNTERCLOCKWISE:n<0?Je.CLOCKWISE:Je.NONE},Je.angleBetweenOriented=function(A,t,n){var i=Je.angle(t,A),r=Je.angle(t,n)-i;return r<=-Math.PI?r+Je.PI_TIMES_2:r>Math.PI?r-Je.PI_TIMES_2:r},Ze.PI_TIMES_2.get=function(){return 2*Math.PI},Ze.PI_OVER_2.get=function(){return Math.PI/2},Ze.PI_OVER_4.get=function(){return Math.PI/4},Ze.COUNTERCLOCKWISE.get=function(){return hi.COUNTERCLOCKWISE},Ze.CLOCKWISE.get=function(){return hi.CLOCKWISE},Ze.NONE.get=function(){return hi.COLLINEAR},Object.defineProperties(Je,Ze);var Xe=function A(){this.Ar=0,this.tr=null,this.nr=1,this.ir=null,this.gi=0,this.sn=null,this.rr=null,this.er=null,this.sr=null,this.ur=null,this.or=null,this.hr=new Ne,this.cr=new Ne,this.ar=new Ne,this.vr=new Ne,this.lr=0,this.wr=!1;var t=arguments[0],n=arguments[1],i=arguments[2];this.sn=t,this.rr=n,this.er=new si,this.tr=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===qe.JOIN_ROUND&&(this.nr=A.MAX_CLOSING_SEG_LEN_FACTOR),this.init(i)},$e={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};Xe.prototype.addNextSegment=function(A,t){if(this.sr=this.ur,this.ur=this.or,this.or=A,this.hr.setCoordinates(this.sr,this.ur),this.computeOffsetSegment(this.hr,this.lr,this.gi,this.ar),this.cr.setCoordinates(this.ur,this.or),this.computeOffsetSegment(this.cr,this.lr,this.gi,this.vr),this.ur.equals(this.or))return null;var n=hi.computeOrientation(this.sr,this.ur,this.or),i=n===hi.CLOCKWISE&&this.lr===qr.LEFT||n===hi.COUNTERCLOCKWISE&&this.lr===qr.RIGHT;0===n?this.addCollinear(t):i?this.addOutsideTurn(n,t):this.addInsideTurn(n,t)},Xe.prototype.addLineEndCap=function(A,t){var n=new Ne(A,t),i=new Ne;this.computeOffsetSegment(n,qr.LEFT,this.gi,i);var r=new Ne;this.computeOffsetSegment(n,qr.RIGHT,this.gi,r);var u=Math.atan2(t.y-A.y,t.x-A.x);switch(this.rr.getEndCapStyle()){case qe.CAP_ROUND:this.ir.addPt(i.p1),this.addFilletArc(t,u+Math.PI/2,u-Math.PI/2,hi.CLOCKWISE,this.gi),this.ir.addPt(r.p1);break;case qe.CAP_FLAT:this.ir.addPt(i.p1),this.ir.addPt(r.p1);break;case qe.CAP_SQUARE:var o=new mn;o.x=Math.abs(this.gi)*Math.cos(u),o.y=Math.abs(this.gi)*Math.sin(u);var h=new mn(i.p1.x+o.x,i.p1.y+o.y),f=new mn(r.p1.x+o.x,r.p1.y+o.y);this.ir.addPt(h),this.ir.addPt(f)}},Xe.prototype.getCoordinates=function(){return this.ir.getCoordinates()},Xe.prototype.addMitreJoin=function(A,t,n,i){var r=!0,e=null;try{e=_n.intersection(t.p0,t.p1,n.p0,n.p1),(i<=0?1:e.distance(A)/Math.abs(i))>this.rr.getMitreLimit()&&(r=!1)}catch(A){if(!(A instanceof Vn))throw A;e=new mn(0,0),r=!1}r?this.ir.addPt(e):this.addLimitedMitreJoin(t,n,i,this.rr.getMitreLimit())},Xe.prototype.addFilletCorner=function(A,t,n,i,r){var u=Math.atan2(t.y-A.y,t.x-A.x),f=Math.atan2(n.y-A.y,n.x-A.x);i===hi.CLOCKWISE?u<=f&&(u+=2*Math.PI):u>=f&&(u-=2*Math.PI),this.ir.addPt(t),this.addFilletArc(A,u,f,i,r),this.ir.addPt(n)},Xe.prototype.addOutsideTurn=function(A,t){if(this.ar.p1.distance(this.vr.p0)<this.gi*Xe.OFFSET_SEGMENT_SEPARATION_FACTOR)return this.ir.addPt(this.ar.p1),null;this.rr.getJoinStyle()===qe.JOIN_MITRE?this.addMitreJoin(this.ur,this.ar,this.vr,this.gi):this.rr.getJoinStyle()===qe.JOIN_BEVEL?this.addBevelJoin(this.ar,this.vr):(t&&this.ir.addPt(this.ar.p1),this.addFilletCorner(this.ur,this.ar.p1,this.vr.p0,A,this.gi),this.ir.addPt(this.vr.p0))},Xe.prototype.createSquare=function(A){this.ir.addPt(new mn(A.x+this.gi,A.y+this.gi)),this.ir.addPt(new mn(A.x+this.gi,A.y-this.gi)),this.ir.addPt(new mn(A.x-this.gi,A.y-this.gi)),this.ir.addPt(new mn(A.x-this.gi,A.y+this.gi)),this.ir.closeRing()},Xe.prototype.addSegments=function(A,t){this.ir.addPts(A,t)},Xe.prototype.addFirstSegment=function(){this.ir.addPt(this.vr.p0)},Xe.prototype.addLastSegment=function(){this.ir.addPt(this.vr.p1)},Xe.prototype.initSideSegments=function(A,t,n){this.ur=A,this.or=t,this.lr=n,this.cr.setCoordinates(A,t),this.computeOffsetSegment(this.cr,n,this.gi,this.vr)},Xe.prototype.addLimitedMitreJoin=function(A,t,n,i){var r=this.hr.p1,e=Je.angle(r,this.hr.p0),s=Je.angleBetweenOriented(this.hr.p0,r,this.cr.p1)/2,u=Je.normalize(e+s),o=Je.normalize(u+Math.PI),h=i*n,f=n-h*Math.abs(Math.sin(s)),c=r.x+h*Math.cos(o),a=r.y+h*Math.sin(o),v=new mn(c,a),l=new Ne(r,v),w=l.pointAlongOffset(1,f),P=l.pointAlongOffset(1,-f);this.lr===qr.LEFT?(this.ir.addPt(w),this.ir.addPt(P)):(this.ir.addPt(P),this.ir.addPt(w))},Xe.prototype.computeOffsetSegment=function(A,t,n,i){var r=t===qr.LEFT?1:-1,e=A.p1.x-A.p0.x,s=A.p1.y-A.p0.y,u=Math.sqrt(e*e+s*s),o=r*n*e/u,h=r*n*s/u;i.p0.x=A.p0.x-h,i.p0.y=A.p0.y+o,i.p1.x=A.p1.x-h,i.p1.y=A.p1.y+o},Xe.prototype.addFilletArc=function(A,t,n,i,r){var e=i===hi.CLOCKWISE?-1:1,s=Math.abs(t-n),u=Math.trunc(s/this.tr+.5);if(u<1)return null;for(var o=s/u,h=0,f=new mn;h<s;){var c=t+e*h;f.x=A.x+r*Math.cos(c),f.y=A.y+r*Math.sin(c),this.ir.addPt(f),h+=o}},Xe.prototype.addInsideTurn=function(A,t){if(this.er.computeIntersection(this.ar.p0,this.ar.p1,this.vr.p0,this.vr.p1),this.er.hasIntersection())this.ir.addPt(this.er.getIntersection(0));else if(this.wr=!0,this.ar.p1.distance(this.vr.p0)<this.gi*Xe.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR)this.ir.addPt(this.ar.p1);else{if(this.ir.addPt(this.ar.p1),this.nr>0){var n=new mn((this.nr*this.ar.p1.x+this.ur.x)/(this.nr+1),(this.nr*this.ar.p1.y+this.ur.y)/(this.nr+1));this.ir.addPt(n);var i=new mn((this.nr*this.vr.p0.x+this.ur.x)/(this.nr+1),(this.nr*this.vr.p0.y+this.ur.y)/(this.nr+1));this.ir.addPt(i)}else this.ir.addPt(this.ur);this.ir.addPt(this.vr.p0)}},Xe.prototype.createCircle=function(A){var t=new mn(A.x+this.gi,A.y);this.ir.addPt(t),this.addFilletArc(A,0,2*Math.PI,-1,this.gi),this.ir.closeRing()},Xe.prototype.addBevelJoin=function(A,t){this.ir.addPt(A.p1),this.ir.addPt(t.p0)},Xe.prototype.init=function(A){this.gi=A,this.Ar=A*(1-Math.cos(this.tr/2)),this.ir=new Ke,this.ir.setPrecisionModel(this.sn),this.ir.setMinimumVertexDistance(A*Xe.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},Xe.prototype.addCollinear=function(A){this.er.computeIntersection(this.sr,this.ur,this.ur,this.or),this.er.getIntersectionNum()>=2&&(this.rr.getJoinStyle()===qe.JOIN_BEVEL||this.rr.getJoinStyle()===qe.JOIN_MITRE?(A&&this.ir.addPt(this.ar.p1),this.ir.addPt(this.vr.p0)):this.addFilletCorner(this.ur,this.ar.p1,this.vr.p0,hi.CLOCKWISE,this.gi))},Xe.prototype.closeRing=function(){this.ir.closeRing()},Xe.prototype.hasNarrowConcaveAngle=function(){return this.wr},Xe.prototype.interfaces_=function(){return[]},Xe.prototype.getClass=function(){return Xe},$e.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},$e.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},$e.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},$e.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(Xe,$e);var As=function(){this.gi=0,this.sn=null,this.rr=null;var A=arguments[0],t=arguments[1];this.sn=A,this.rr=t};As.prototype.getOffsetCurve=function(A,t){if(this.gi=t,0===t)return null;var n=t<0,i=Math.abs(t),r=this.getSegGen(i);A.length<=1?this.computePointCurve(A[0],r):this.computeOffsetCurve(A,n,r);var e=r.getCoordinates();return n&&Ti.reverse(e),e},As.prototype.computeSingleSidedBufferCurve=function(A,t,n){var i=this.simplifyTolerance(this.gi);if(t){n.addSegments(A,!0);var r=We.simplify(A,-i),e=r.length-1;n.initSideSegments(r[e],r[e-1],qr.LEFT),n.addFirstSegment();for(var s=e-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{n.addSegments(A,!1);var u=We.simplify(A,i),o=u.length-1;n.initSideSegments(u[0],u[1],qr.LEFT),n.addFirstSegment();for(var h=2;h<=o;h++)n.addNextSegment(u[h],!0)}n.addLastSegment(),n.closeRing()},As.prototype.computeRingBufferCurve=function(A,t,n){var i=this.simplifyTolerance(this.gi);t===qr.RIGHT&&(i=-i);var r=We.simplify(A,i),e=r.length-1;n.initSideSegments(r[e-1],r[0],t);for(var s=1;s<=e;s++){n.addNextSegment(r[s],1!==s)}n.closeRing()},As.prototype.computeLineBufferCurve=function(A,t){var n=this.simplifyTolerance(this.gi),i=We.simplify(A,n),r=i.length-1;t.initSideSegments(i[0],i[1],qr.LEFT);for(var e=2;e<=r;e++)t.addNextSegment(i[e],!0);t.addLastSegment(),t.addLineEndCap(i[r-1],i[r]);var s=We.simplify(A,-n),u=s.length-1;t.initSideSegments(s[u],s[u-1],qr.LEFT);for(var o=u-2;o>=0;o--)t.addNextSegment(s[o],!0);t.addLastSegment(),t.addLineEndCap(s[1],s[0]),t.closeRing()},As.prototype.computePointCurve=function(A,t){switch(this.rr.getEndCapStyle()){case qe.CAP_ROUND:t.createCircle(A);break;case qe.CAP_SQUARE:t.createSquare(A)}},As.prototype.getLineCurve=function(A,t){if(this.gi=t,t<0&&!this.rr.isSingleSided())return null;if(0===t)return null;var n=Math.abs(t),i=this.getSegGen(n);if(A.length<=1)this.computePointCurve(A[0],i);else if(this.rr.isSingleSided()){this.computeSingleSidedBufferCurve(A,t<0,i)}else this.computeLineBufferCurve(A,i);return i.getCoordinates()},As.prototype.getBufferParameters=function(){return this.rr},As.prototype.simplifyTolerance=function(A){return A*this.rr.getSimplifyFactor()},As.prototype.getRingCurve=function(A,t,n){if(this.gi=n,A.length<=2)return this.getLineCurve(A,n);if(0===n)return As.copyCoordinates(A);var i=this.getSegGen(n);return this.computeRingBufferCurve(A,t,i),i.getCoordinates()},As.prototype.computeOffsetCurve=function(A,t,n){var i=this.simplifyTolerance(this.gi);if(t){var r=We.simplify(A,-i),e=r.length-1;n.initSideSegments(r[e],r[e-1],qr.LEFT),n.addFirstSegment();for(var s=e-2;s>=0;s--)n.addNextSegment(r[s],!0)}else{var u=We.simplify(A,i),o=u.length-1;n.initSideSegments(u[0],u[1],qr.LEFT),n.addFirstSegment();for(var h=2;h<=o;h++)n.addNextSegment(u[h],!0)}n.addLastSegment()},As.prototype.getSegGen=function(A){return new Xe(this.sn,this.rr,A)},As.prototype.interfaces_=function(){return[]},As.prototype.getClass=function(){return As},As.copyCoordinates=function(A){for(var t=new Array(A.length).fill(null),n=0;n<t.length;n++)t[n]=new mn(A[n]);return t};var ts=function(){this.Pr=null,this.gr=new Ne,this.Cr=new hi;var A=arguments[0];this.Pr=A},ns={DepthSegment:{configurable:!0}};ts.prototype.findStabbedSegments=function(){var A=this;if(1===arguments.length){for(var t=arguments[0],n=new yi,i=this.Pr.iterator();i.hasNext();){var r=i.next(),e=r.getEnvelope();t.y<e.getMinY()||t.y>e.getMaxY()||A.findStabbedSegments(t,r.getDirectedEdges(),n)}return n}if(3===arguments.length)if(Fn(arguments[2],xi)&&arguments[0]instanceof mn&&arguments[1]instanceof he)for(var s=arguments[0],u=arguments[1],o=arguments[2],h=u.getEdge().getCoordinates(),f=0;f<h.length-1;f++){A.gr.p0=h[f],A.gr.p1=h[f+1],A.gr.p0.y>A.gr.p1.y&&A.gr.reverse();var c=Math.max(A.gr.p0.x,A.gr.p1.x);if(!(c<s.x||A.gr.isHorizontal()||s.y<A.gr.p0.y||s.y>A.gr.p1.y||hi.computeOrientation(A.gr.p0,A.gr.p1,s)===hi.RIGHT)){var a=u.getDepth(qr.LEFT);A.gr.p0.equals(h[f])||(a=u.getDepth(qr.RIGHT));var v=new is(A.gr,a);o.add(v)}}else if(Fn(arguments[2],xi)&&arguments[0]instanceof mn&&Fn(arguments[1],xi))for(var l=arguments[0],w=arguments[1],P=arguments[2],g=w.iterator();g.hasNext();){var C=g.next();C.isForward()&&A.findStabbedSegments(l,C,P)}},ts.prototype.getDepth=function(A){var t=this.findStabbedSegments(A);return 0===t.size()?0:Ie.min(t).Dr},ts.prototype.interfaces_=function(){return[]},ts.prototype.getClass=function(){return ts},ns.DepthSegment.get=function(){return is},Object.defineProperties(ts,ns);var is=function(){this.Ir=null,this.Dr=null;var A=arguments[0],t=arguments[1];this.Ir=new Ne(A),this.Dr=t};is.prototype.compareTo=function(A){var t=A;if(this.Ir.minX()>=t.Ir.maxX())return 1;if(this.Ir.maxX()<=t.Ir.minX())return-1;var n=this.Ir.orientationIndex(t.Ir);return 0!==n||0!=(n=-1*t.Ir.orientationIndex(this.Ir))?n:this.Ir.compareTo(t.Ir)},is.prototype.compareX=function(A,t){var n=A.p0.compareTo(t.p0);return 0!==n?n:A.p1.compareTo(t.p1)},is.prototype.toString=function(){return this.Ir.toString()},is.prototype.interfaces_=function(){return[bn]},is.prototype.getClass=function(){return is};var rs=function(A,t,n){this.p0=A||null,this.p1=t||null,this.p2=n||null};rs.prototype.area=function(){return rs.area(this.p0,this.p1,this.p2)},rs.prototype.signedArea=function(){return rs.signedArea(this.p0,this.p1,this.p2)},rs.prototype.interpolateZ=function(A){if(null===A)throw new Dn("Supplied point is null.");return rs.interpolateZ(A,this.p0,this.p1,this.p2)},rs.prototype.longestSideLength=function(){return rs.longestSideLength(this.p0,this.p1,this.p2)},rs.prototype.isAcute=function(){return rs.isAcute(this.p0,this.p1,this.p2)},rs.prototype.circumcentre=function(){return rs.circumcentre(this.p0,this.p1,this.p2)},rs.prototype.area3D=function(){return rs.area3D(this.p0,this.p1,this.p2)},rs.prototype.centroid=function(){return rs.centroid(this.p0,this.p1,this.p2)},rs.prototype.inCentre=function(){return rs.inCentre(this.p0,this.p1,this.p2)},rs.prototype.interfaces_=function(){return[]},rs.prototype.getClass=function(){return rs},rs.area=function(A,t,n){return Math.abs(((n.x-A.x)*(t.y-A.y)-(t.x-A.x)*(n.y-A.y))/2)},rs.signedArea=function(A,t,n){return((n.x-A.x)*(t.y-A.y)-(t.x-A.x)*(n.y-A.y))/2},rs.det=function(A,t,n,i){return A*i-t*n},rs.interpolateZ=function(A,t,n,i){var r=t.x,e=t.y,s=n.x-r,u=i.x-r,o=n.y-e,h=i.y-e,f=s*h-u*o,c=A.x-r,a=A.y-e;return t.z+(h*c-u*a)/f*(n.z-t.z)+(-o*c+s*a)/f*(i.z-t.z)},rs.longestSideLength=function(A,t,n){var i=A.distance(t),r=t.distance(n),e=n.distance(A),s=i;return r>s&&(s=r),e>s&&(s=e),s},rs.isAcute=function(A,t,n){return!!Je.isAcute(A,t,n)&&!!Je.isAcute(t,n,A)&&!!Je.isAcute(n,A,t)},rs.circumcentre=function(A,t,n){var i=n.x,r=n.y,e=A.x-i,s=A.y-r,u=t.x-i,o=t.y-r,h=2*rs.det(e,s,u,o),f=rs.det(s,e*e+s*s,o,u*u+o*o),c=rs.det(e,e*e+s*s,u,u*u+o*o);return new mn(i-f/h,r+c/h)},rs.perpendicularBisector=function(A,t){var n=t.x-A.x,i=t.y-A.y,r=new _n(A.x+n/2,A.y+i/2,1),e=new _n(A.x-i+n/2,A.y+n+i/2,1);return new _n(r,e)},rs.angleBisector=function(A,t,n){var i=t.distance(A),r=i/(i+t.distance(n));return new mn(A.x+r*(n.x-A.x),A.y+r*(n.y-A.y))},rs.area3D=function(A,t,n){var i=t.x-A.x,r=t.y-A.y,e=t.z-A.z,s=n.x-A.x,u=n.y-A.y,o=n.z-A.z,h=r*o-e*u,f=e*s-i*o,c=i*u-r*s;return Math.sqrt(h*h+f*f+c*c)/2},rs.centroid=function(A,t,n){return new mn((A.x+t.x+n.x)/3,(A.y+t.y+n.y)/3)},rs.inCentre=function(A,t,n){var i=t.distance(n),r=A.distance(n),e=A.distance(t),s=i+r+e;return new mn((i*A.x+r*t.x+e*n.x)/s,(i*A.y+r*t.y+e*n.y)/s)};var es=function(){this.Mr=null,this.gi=null,this.br=null,this.zr=new yi;var A=arguments[0],t=arguments[1],n=arguments[2];this.Mr=A,this.gi=t,this.br=n};es.prototype.addPoint=function(A){if(this.gi<=0)return null;var t=A.getCoordinates(),n=this.br.getLineCurve(t,this.gi);this.addCurve(n,Tn.EXTERIOR,Tn.INTERIOR)},es.prototype.addPolygon=function(A){var t=this.gi,n=qr.LEFT;this.gi<0&&(t=-this.gi,n=qr.RIGHT);var i=A.getExteriorRing(),r=Ti.removeRepeatedPoints(i.getCoordinates());if(this.gi<0&&this.isErodedCompletely(i,this.gi))return null;if(this.gi<=0&&r.length<3)return null;this.addPolygonRing(r,t,n,Tn.EXTERIOR,Tn.INTERIOR);for(var e=0;e<A.getNumInteriorRing();e++){var s=A.getInteriorRingN(e),u=Ti.removeRepeatedPoints(s.getCoordinates());this.gi>0&&this.isErodedCompletely(s,-this.gi)||this.addPolygonRing(u,t,qr.opposite(n),Tn.INTERIOR,Tn.EXTERIOR)}},es.prototype.isTriangleErodedCompletely=function(A,t){var n=new rs(A[0],A[1],A[2]),i=n.inCentre();return hi.distancePointLine(i,n.p0,n.p1)<Math.abs(t)},es.prototype.addLineString=function(A){if(this.gi<=0&&!this.br.getBufferParameters().isSingleSided())return null;var t=Ti.removeRepeatedPoints(A.getCoordinates()),n=this.br.getLineCurve(t,this.gi);this.addCurve(n,Tn.EXTERIOR,Tn.INTERIOR)},es.prototype.addCurve=function(A,t,n){if(null===A||A.length<2)return null;var i=new Ee(A,new $r(0,Tn.BOUNDARY,t,n));this.zr.add(i)},es.prototype.getCurves=function(){return this.add(this.Mr),this.zr},es.prototype.addPolygonRing=function(A,t,n,i,r){if(0===t&&A.length<Ir.MINIMUM_VALID_SIZE)return null;var e=i,s=r;A.length>=Ir.MINIMUM_VALID_SIZE&&hi.isCCW(A)&&(e=r,s=i,n=qr.opposite(n));var u=this.br.getRingCurve(A,n,t);this.addCurve(u,e,s)},es.prototype.add=function(A){if(A.isEmpty())return null;A instanceof Cr?this.addPolygon(A):A instanceof lr?this.addLineString(A):A instanceof Pr?this.addPoint(A):(A instanceof Dr||A instanceof nr||A instanceof Mr||A instanceof tr)&&this.addCollection(A)},es.prototype.isErodedCompletely=function(A,t){var n=A.getCoordinates();if(n.length<4)return t<0;if(4===n.length)return this.isTriangleErodedCompletely(n,t);var i=A.getEnvelopeInternal(),r=Math.min(i.getHeight(),i.getWidth());return t<0&&2*Math.abs(t)>r},es.prototype.addCollection=function(A){for(var t=0;t<A.getNumGeometries();t++){var n=A.getGeometryN(t);this.add(n)}},es.prototype.interfaces_=function(){return[]},es.prototype.getClass=function(){return es};var ss=function(){};ss.prototype.locate=function(A){},ss.prototype.interfaces_=function(){return[]},ss.prototype.getClass=function(){return ss};var us=function(){this.dr=null,this.xr=null,this.mr=null,this.Qi=null,this.yr=null;var A=arguments[0];this.dr=A,this.xr=!0,this.Qi=0,this.mr=A.getNumGeometries()};us.prototype.next=function(){if(this.xr)return this.xr=!1,us.isAtomic(this.dr)&&this.Qi++,this.dr;if(null!==this.yr){if(this.yr.hasNext())return this.yr.next();this.yr=null}if(this.Qi>=this.mr)throw new mi;var A=this.dr.getGeometryN(this.Qi++);return A instanceof tr?(this.yr=new us(A),this.yr.next()):A},us.prototype.remove=function(){throw new Error(this.getClass().getName())},us.prototype.hasNext=function(){if(this.xr)return!0;if(null!==this.yr){if(this.yr.hasNext())return!0;this.yr=null}return!(this.Qi>=this.mr)},us.prototype.interfaces_=function(){return[di]},us.prototype.getClass=function(){return us},us.isAtomic=function(A){return!(A instanceof tr)};var os=function(){this.Pn=null;var A=arguments[0];this.Pn=A};os.prototype.locate=function(A){return os.locate(A,this.Pn)},os.prototype.interfaces_=function(){return[ss]},os.prototype.getClass=function(){return os},os.isPointInRing=function(A,t){return!!t.getEnvelopeInternal().intersects(A)&&hi.isPointInRing(A,t.getCoordinates())},os.containsPointInPolygon=function(A,t){if(t.isEmpty())return!1;var n=t.getExteriorRing();if(!os.isPointInRing(A,n))return!1;for(var i=0;i<t.getNumInteriorRing();i++){var r=t.getInteriorRingN(i);if(os.isPointInRing(A,r))return!1}return!0},os.containsPoint=function(A,t){if(t instanceof Cr)return os.containsPointInPolygon(A,t);if(t instanceof tr)for(var n=new us(t);n.hasNext();){var i=n.next();if(i!==t&&os.containsPoint(A,i))return!0}return!1},os.locate=function(A,t){return t.isEmpty()?Tn.EXTERIOR:os.containsPoint(A,t)?Tn.INTERIOR:Tn.EXTERIOR};var hs=function(){this.pr=new Vi,this.Lr=null,this.Tr=[Tn.NONE,Tn.NONE]};hs.prototype.getNextCW=function(A){this.getEdges();var t=this.Lr.indexOf(A),n=t-1;return 0===t&&(n=this.Lr.size()-1),this.Lr.get(n)},hs.prototype.propagateSideLabels=function(A){for(var t=Tn.NONE,n=this.iterator();n.hasNext();){var i=n.next().getLabel();i.isArea(A)&&i.getLocation(A,qr.LEFT)!==Tn.NONE&&(t=i.getLocation(A,qr.LEFT))}if(t===Tn.NONE)return null;for(var r=t,e=this.iterator();e.hasNext();){var s=e.next(),u=s.getLabel();if(u.getLocation(A,qr.ON)===Tn.NONE&&u.setLocation(A,qr.ON,r),u.isArea(A)){var o=u.getLocation(A,qr.LEFT),h=u.getLocation(A,qr.RIGHT);if(h!==Tn.NONE){if(h!==r)throw new Hr("side location conflict",s.getCoordinate());o===Tn.NONE&&ii.shouldNeverReachHere("found single null side (at "+s.getCoordinate()+")"),r=o}else ii.isTrue(u.getLocation(A,qr.LEFT)===Tn.NONE,"found single null side"),u.setLocation(A,qr.RIGHT,r),u.setLocation(A,qr.LEFT,r)}}},hs.prototype.getCoordinate=function(){var A=this.iterator();return A.hasNext()?A.next().getCoordinate():null},hs.prototype.print=function(A){Wn.out.println("EdgeEndStar:   "+this.getCoordinate());for(var t=this.iterator();t.hasNext();)t.next().print(A)},hs.prototype.isAreaLabelsConsistent=function(A){return this.computeEdgeEndLabels(A.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)},hs.prototype.checkAreaLabelsConsistent=function(A){var t=this.getEdges();if(t.size()<=0)return!0;var n=t.size()-1,i=t.get(n).getLabel().getLocation(A,qr.LEFT);ii.isTrue(i!==Tn.NONE,"Found unlabelled area edge");for(var r=i,e=this.iterator();e.hasNext();){var s=e.next().getLabel();ii.isTrue(s.isArea(A),"Found non-area edge");var u=s.getLocation(A,qr.LEFT),o=s.getLocation(A,qr.RIGHT);if(u===o)return!1;if(o!==r)return!1;r=u}return!0},hs.prototype.findIndex=function(A){this.iterator();for(var t=0;t<this.Lr.size();t++)if(this.Lr.get(t)===A)return t;return-1},hs.prototype.iterator=function(){return this.getEdges().iterator()},hs.prototype.getEdges=function(){return null===this.Lr&&(this.Lr=new yi(this.pr.values())),this.Lr},hs.prototype.getLocation=function(A,t,n){return this.Tr[A]===Tn.NONE&&(this.Tr[A]=os.locate(t,n[A].getGeometry())),this.Tr[A]},hs.prototype.toString=function(){var A=new Nn;A.append("EdgeEndStar:   "+this.getCoordinate()),A.append("\n");for(var t=this.iterator();t.hasNext();){var n=t.next();A.append(n),A.append("\n")}return A.toString()},hs.prototype.computeEdgeEndLabels=function(A){for(var t=this.iterator();t.hasNext();)t.next().computeLabel(A)},hs.prototype.computeLabelling=function(A){this.computeEdgeEndLabels(A[0].getBoundaryNodeRule()),this.propagateSideLabels(0),this.propagateSideLabels(1);for(var t=[!1,!1],n=this.iterator();n.hasNext();)for(var i=n.next().getLabel(),r=0;r<2;r++)i.isLine(r)&&i.getLocation(r)===Tn.BOUNDARY&&(t[r]=!0);for(var e=this.iterator();e.hasNext();)for(var s=e.next(),u=s.getLabel(),o=0;o<2;o++)if(u.isAnyNull(o)){var h=Tn.NONE;if(t[o])h=Tn.EXTERIOR;else{var f=s.getCoordinate();h=this.getLocation(o,f,A)}u.setAllLocationsIfNull(o,h)}},hs.prototype.getDegree=function(){return this.pr.size()},hs.prototype.insertEdgeEnd=function(A,t){this.pr.put(A,t),this.Lr=null},hs.prototype.interfaces_=function(){return[]},hs.prototype.getClass=function(){return hs};var fs=function(A){function t(){A.call(this),this.Or=null,this.Sn=null,this.Fr=1,this.Ur=2}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.linkResultDirectedEdges=function(){this.getResultAreaEdges();for(var A=null,t=null,n=this.Fr,i=0;i<this.Or.size();i++){var r=this.Or.get(i),e=r.getSym();if(r.getLabel().isArea())switch(null===A&&r.isInResult()&&(A=r),n){case this.Fr:if(!e.isInResult())continue;t=e,n=this.Ur;break;case this.Ur:if(!r.isInResult())continue;t.setNext(r),n=this.Fr}}if(n===this.Ur){if(null===A)throw new Hr("no outgoing dirEdge found",this.getCoordinate());ii.isTrue(A.isInResult(),"unable to link last incoming dirEdge"),t.setNext(A)}},t.prototype.insert=function(A){this.insertEdgeEnd(A,A)},t.prototype.getRightmostEdge=function(){var A=this.getEdges(),t=A.size();if(t<1)return null;var n=A.get(0);if(1===t)return n;var i=A.get(t-1),r=n.getQuadrant(),e=i.getQuadrant();return se.isNorthern(r)&&se.isNorthern(e)?n:se.isNorthern(r)||se.isNorthern(e)?0!==n.getDy()?n:0!==i.getDy()?i:(ii.shouldNeverReachHere("found two horizontal edges incident on node"),null):i},t.prototype.print=function(A){Wn.out.println("DirectedEdgeStar: "+this.getCoordinate());for(var t=this.iterator();t.hasNext();){var n=t.next();A.print("out "),n.print(A),A.println(),A.print("in "),n.getSym().print(A),A.println()}},t.prototype.getResultAreaEdges=function(){if(null!==this.Or)return this.Or;this.Or=new yi;for(var A=this.iterator();A.hasNext();){var t=A.next();(t.isInResult()||t.getSym().isInResult())&&this.Or.add(t)}return this.Or},t.prototype.updateLabelling=function(A){for(var t=this.iterator();t.hasNext();){var n=t.next().getLabel();n.setAllLocationsIfNull(0,A.getLocation(0)),n.setAllLocationsIfNull(1,A.getLocation(1))}},t.prototype.linkAllDirectedEdges=function(){this.getEdges();for(var A=null,t=null,n=this.Lr.size()-1;n>=0;n--){var i=this.Lr.get(n),r=i.getSym();null===t&&(t=r),null!==A&&r.setNext(A),A=i}t.setNext(A)},t.prototype.computeDepths=function(){var A=this;if(1===arguments.length){var t=arguments[0],n=this.findIndex(t),i=t.getDepth(qr.LEFT),r=t.getDepth(qr.RIGHT),e=this.computeDepths(n+1,this.Lr.size(),i),s=this.computeDepths(0,n,e);if(s!==r)throw new Hr("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var u=arguments[0],o=arguments[1],h=arguments[2],f=h,c=u;c<o;c++){var a=A.Lr.get(c);a.setEdgeDepths(qr.RIGHT,f),f=a.getDepth(qr.LEFT)}return f}},t.prototype.mergeSymLabels=function(){for(var A=this.iterator();A.hasNext();){var t=A.next();t.getLabel().merge(t.getSym().getLabel())}},t.prototype.linkMinimalDirectedEdges=function(A){for(var t=null,n=null,i=this.Fr,r=this.Or.size()-1;r>=0;r--){var e=this.Or.get(r),s=e.getSym();switch(null===t&&e.getEdgeRing()===A&&(t=e),i){case this.Fr:if(s.getEdgeRing()!==A)continue;n=s,i=this.Ur;break;case this.Ur:if(e.getEdgeRing()!==A)continue;n.setNextMin(e),i=this.Fr}}i===this.Ur&&(ii.isTrue(null!==t,"found null for first outgoing dirEdge"),ii.isTrue(t.getEdgeRing()===A,"unable to link last incoming dirEdge"),n.setNextMin(t))},t.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var A=0,t=this.iterator();t.hasNext();){var n=t.next();n.isInResult()&&A++}return A}if(1===arguments.length){for(var i=arguments[0],r=0,e=this.iterator();e.hasNext();){var s=e.next();s.getEdgeRing()===i&&r++}return r}},t.prototype.getLabel=function(){return this.Sn},t.prototype.findCoveredLineEdges=function(){for(var A=Tn.NONE,t=this.iterator();t.hasNext();){var n=t.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){A=Tn.INTERIOR;break}if(i.isInResult()){A=Tn.EXTERIOR;break}}}if(A===Tn.NONE)return null;for(var r=A,e=this.iterator();e.hasNext();){var s=e.next(),u=s.getSym();s.isLineEdge()?s.getEdge().setCovered(r===Tn.INTERIOR):(s.isInResult()&&(r=Tn.EXTERIOR),u.isInResult()&&(r=Tn.INTERIOR))}},t.prototype.computeLabelling=function(t){A.prototype.computeLabelling.call(this,t),this.Sn=new $r(Tn.NONE);for(var n=this.iterator();n.hasNext();)for(var i=n.next().getEdge().getLabel(),r=0;r<2;r++){var e=i.getLocation(r);e!==Tn.INTERIOR&&e!==Tn.BOUNDARY||this.Sn.setLocation(r,Tn.INTERIOR)}},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(hs),cs=function(A){function t(){A.apply(this,arguments)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.createNode=function(A){return new re(A,new fs)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(fe),as=function A(){this.Qn=null,this.Er=null;var t=arguments[0];this.Qn=t,this.Er=A.orientation(t)};as.prototype.compareTo=function(A){return as.compareOriented(this.Qn,this.Er,A.Qn,A.Er)},as.prototype.interfaces_=function(){return[bn]},as.prototype.getClass=function(){return as},as.orientation=function(A){return 1===Ti.increasingDirection(A)},as.compareOriented=function(A,t,n,i){for(var r=t?1:-1,e=i?1:-1,s=t?A.length:-1,u=i?n.length:-1,o=t?0:A.length-1,h=i?0:n.length-1;;){var f=A[o].compareTo(n[h]);if(0!==f)return f;var c=(o+=r)===s,a=(h+=e)===u;if(c&&!a)return-1;if(!c&&a)return 1;if(c&&a)return 0}};var vs=function(){this.jn=new yi,this.Nr=new Vi};vs.prototype.print=function(A){A.print("MULTILINESTRING ( ");for(var t=0;t<this.jn.size();t++){var n=this.jn.get(t);t>0&&A.print(","),A.print("(");for(var i=n.getCoordinates(),r=0;r<i.length;r++)r>0&&A.print(","),A.print(i[r].x+" "+i[r].y);A.println(")")}A.print(")  ")},vs.prototype.addAll=function(A){for(var t=A.iterator();t.hasNext();)this.add(t.next())},vs.prototype.findEdgeIndex=function(A){for(var t=0;t<this.jn.size();t++)if(this.jn.get(t).equals(A))return t;return-1},vs.prototype.iterator=function(){return this.jn.iterator()},vs.prototype.getEdges=function(){return this.jn},vs.prototype.get=function(A){return this.jn.get(A)},vs.prototype.findEqualEdge=function(A){var t=new as(A.getCoordinates());return this.Nr.get(t)},vs.prototype.add=function(A){this.jn.add(A);var t=new as(A.getCoordinates());this.Nr.put(t,A)},vs.prototype.interfaces_=function(){return[]},vs.prototype.getClass=function(){return vs};var ls=function(){};ls.prototype.processIntersections=function(A,t,n,i){},ls.prototype.isDone=function(){},ls.prototype.interfaces_=function(){return[]},ls.prototype.getClass=function(){return ls};var ws=function(){this.jr=!1,this.Qr=!1,this.Sr=!1,this.kr=!1,this.Br=null,this.er=null,this.Rr=null,this.numIntersections=0,this.numInteriorIntersections=0,this.numProperIntersections=0,this.numTests=0;var A=arguments[0];this.er=A};ws.prototype.isTrivialIntersection=function(A,t,n,i){if(A===n&&1===this.er.getIntersectionNum()){if(ws.isAdjacentSegments(t,i))return!0;if(A.isClosed()){var r=A.size()-1;if(0===t&&i===r||0===i&&t===r)return!0}}return!1},ws.prototype.getProperIntersectionPoint=function(){return this.Br},ws.prototype.hasProperInteriorIntersection=function(){return this.Sr},ws.prototype.getLineIntersector=function(){return this.er},ws.prototype.hasProperIntersection=function(){return this.Qr},ws.prototype.processIntersections=function(A,t,n,i){if(A===n&&t===i)return null;this.numTests++;var r=A.getCoordinates()[t],e=A.getCoordinates()[t+1],s=n.getCoordinates()[i],u=n.getCoordinates()[i+1];this.er.computeIntersection(r,e,s,u),this.er.hasIntersection()&&(this.numIntersections++,this.er.isInteriorIntersection()&&(this.numInteriorIntersections++,this.kr=!0),this.isTrivialIntersection(A,t,n,i)||(this.jr=!0,A.addIntersections(this.er,t,0),n.addIntersections(this.er,i,1),this.er.isProper()&&(this.numProperIntersections++,this.Qr=!0,this.Sr=!0)))},ws.prototype.hasIntersection=function(){return this.jr},ws.prototype.isDone=function(){return!1},ws.prototype.hasInteriorIntersection=function(){return this.kr},ws.prototype.interfaces_=function(){return[ls]},ws.prototype.getClass=function(){return ws},ws.isAdjacentSegments=function(A,t){return 1===Math.abs(A-t)};var Ps=function(){this.coord=null,this.segmentIndex=null,this.dist=null;var A=arguments[0],t=arguments[1],n=arguments[2];this.coord=new mn(A),this.segmentIndex=t,this.dist=n};Ps.prototype.getSegmentIndex=function(){return this.segmentIndex},Ps.prototype.getCoordinate=function(){return this.coord},Ps.prototype.print=function(A){A.print(this.coord),A.print(" seg # = "+this.segmentIndex),A.println(" dist = "+this.dist)},Ps.prototype.compareTo=function(A){return this.compare(A.segmentIndex,A.dist)},Ps.prototype.isEndPoint=function(A){return 0===this.segmentIndex&&0===this.dist||this.segmentIndex===A},Ps.prototype.toString=function(){return this.coord+" seg # = "+this.segmentIndex+" dist = "+this.dist},Ps.prototype.getDistance=function(){return this.dist},Ps.prototype.compare=function(A,t){return this.segmentIndex<A?-1:this.segmentIndex>A?1:this.dist<t?-1:this.dist>t?1:0},Ps.prototype.interfaces_=function(){return[bn]},Ps.prototype.getClass=function(){return Ps};var gs=function(){this.mi=new Vi,this.edge=null;var A=arguments[0];this.edge=A};gs.prototype.print=function(A){A.println("Intersections:");for(var t=this.iterator();t.hasNext();)t.next().print(A)},gs.prototype.iterator=function(){return this.mi.values().iterator()},gs.prototype.addSplitEdges=function(A){this.addEndpoints();for(var t=this.iterator(),n=t.next();t.hasNext();){var i=t.next(),r=this.createSplitEdge(n,i);A.add(r),n=i}},gs.prototype.addEndpoints=function(){var A=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[A],A,0)},gs.prototype.createSplitEdge=function(A,t){var n=t.segmentIndex-A.segmentIndex+2,r=t.dist>0||!t.coord.equals2D(this.edge.pts[t.segmentIndex]);r||n--;var e=new Array(n).fill(null),s=0;e[s++]=new mn(A.coord);for(var u=A.segmentIndex+1;u<=t.segmentIndex;u++)e[s++]=this.edge.pts[u];return r&&(e[s]=t.coord),new bs(e,new $r(this.edge.Sn))},gs.prototype.add=function(A,t,n){var i=new Ps(A,t,n),r=this.mi.get(i);return null!==r?r:(this.mi.put(i,i),i)},gs.prototype.isIntersection=function(A){for(var t=this.iterator();t.hasNext();)if(t.next().coord.equals(A))return!0;return!1},gs.prototype.interfaces_=function(){return[]},gs.prototype.getClass=function(){return gs};var Cs=function(){};Cs.prototype.getChainStartIndices=function(A){var t=0,n=new yi;n.add(new jn(t));do{var i=this.findChainEnd(A,t);n.add(new jn(i)),t=i}while(t<A.length-1);return Cs.toIntArray(n)},Cs.prototype.findChainEnd=function(A,t){for(var n=se.quadrant(A[t],A[t+1]),i=t+1;i<A.length&&se.quadrant(A[i-1],A[i])===n;)i++;return i-1},Cs.prototype.interfaces_=function(){return[]},Cs.prototype.getClass=function(){return Cs},Cs.toIntArray=function(A){for(var t=new Array(A.size()).fill(null),n=0;n<t.length;n++)t[n]=A.get(n).intValue();return t};var Ds=function(){this.e=null,this.pts=null,this.startIndex=null,this.env1=new Kn,this.env2=new Kn;var A=arguments[0];this.e=A,this.pts=A.getCoordinates();var t=new Cs;this.startIndex=t.getChainStartIndices(this.pts)};Ds.prototype.getCoordinates=function(){return this.pts},Ds.prototype.getMaxX=function(A){var t=this.pts[this.startIndex[A]].x,n=this.pts[this.startIndex[A+1]].x;return t>n?t:n},Ds.prototype.getMinX=function(A){var t=this.pts[this.startIndex[A]].x,n=this.pts[this.startIndex[A+1]].x;return t<n?t:n},Ds.prototype.computeIntersectsForChain=function(){if(4===arguments.length){var A=arguments[0],t=arguments[1],n=arguments[2],i=arguments[3];this.computeIntersectsForChain(this.startIndex[A],this.startIndex[A+1],t,t.startIndex[n],t.startIndex[n+1],i)}else if(6===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2],u=arguments[3],o=arguments[4],h=arguments[5],f=this.pts[r],c=this.pts[e],a=s.pts[u],v=s.pts[o];if(e-r==1&&o-u==1)return h.addIntersections(this.e,r,s.e,u),null;if(this.env1.init(f,c),this.env2.init(a,v),!this.env1.intersects(this.env2))return null;var l=Math.trunc((r+e)/2),w=Math.trunc((u+o)/2);r<l&&(u<w&&this.computeIntersectsForChain(r,l,s,u,w,h),w<o&&this.computeIntersectsForChain(r,l,s,w,o,h)),l<e&&(u<w&&this.computeIntersectsForChain(l,e,s,u,w,h),w<o&&this.computeIntersectsForChain(l,e,s,w,o,h))}},Ds.prototype.getStartIndexes=function(){return this.startIndex},Ds.prototype.computeIntersects=function(A,t){for(var n=0;n<this.startIndex.length-1;n++)for(var i=0;i<A.startIndex.length-1;i++)this.computeIntersectsForChain(n,A,i,t)},Ds.prototype.interfaces_=function(){return[]},Ds.prototype.getClass=function(){return Ds};var Is=function A(){this.si=Array(2).fill().map((function(){return Array(3)}));for(var t=0;t<2;t++)for(var n=0;n<3;n++)this.si[t][n]=A.NULL_VALUE},Ms={NULL_VALUE:{configurable:!0}};Is.prototype.getDepth=function(A,t){return this.si[A][t]},Is.prototype.setDepth=function(A,t,n){this.si[A][t]=n},Is.prototype.isNull=function(){var A=this;if(0===arguments.length){for(var t=0;t<2;t++)for(var n=0;n<3;n++)if(A.si[t][n]!==Is.NULL_VALUE)return!1;return!0}if(1===arguments.length){var i=arguments[0];return this.si[i][1]===Is.NULL_VALUE}if(2===arguments.length){var r=arguments[0],e=arguments[1];return this.si[r][e]===Is.NULL_VALUE}},Is.prototype.normalize=function(){for(var A=0;A<2;A++)if(!this.isNull(A)){var t=this.si[A][1];this.si[A][2]<t&&(t=this.si[A][2]),t<0&&(t=0);for(var n=1;n<3;n++){var i=0;this.si[A][n]>t&&(i=1),this.si[A][n]=i}}},Is.prototype.getDelta=function(A){return this.si[A][qr.RIGHT]-this.si[A][qr.LEFT]},Is.prototype.getLocation=function(A,t){return this.si[A][t]<=0?Tn.EXTERIOR:Tn.INTERIOR},Is.prototype.toString=function(){return"A: "+this.si[0][1]+","+this.si[0][2]+" B: "+this.si[1][1]+","+this.si[1][2]},Is.prototype.add=function(){var A=this;if(1===arguments.length)for(var t=arguments[0],n=0;n<2;n++)for(var i=1;i<3;i++){var r=t.getLocation(n,i);r!==Tn.EXTERIOR&&r!==Tn.INTERIOR||(A.isNull(n,i)?A.si[n][i]=Is.depthAtLocation(r):A.si[n][i]+=Is.depthAtLocation(r))}else if(3===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2];u===Tn.INTERIOR&&this.si[e][s]++}},Is.prototype.interfaces_=function(){return[]},Is.prototype.getClass=function(){return Is},Is.depthAtLocation=function(A){return A===Tn.EXTERIOR?0:A===Tn.INTERIOR?1:Is.NULL_VALUE},Ms.NULL_VALUE.get=function(){return-1},Object.defineProperties(Is,Ms);var bs=function(A){function t(){if(A.call(this),this.pts=null,this.Un=null,this.eiList=new gs(this),this.zn=null,this.Gr=null,this.Yr=!0,this.si=new Is,this.qr=0,1===arguments.length){var n=arguments[0];t.call(this,n,null)}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.pts=i,this.Sn=r}}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.getDepth=function(){return this.si},t.prototype.getCollapsedEdge=function(){var A=new Array(2).fill(null);return A[0]=this.pts[0],A[1]=this.pts[1],new t(A,$r.toLineLabel(this.Sn))},t.prototype.isIsolated=function(){return this.Yr},t.prototype.getCoordinates=function(){return this.pts},t.prototype.setIsolated=function(A){this.Yr=A},t.prototype.setName=function(A){this.zn=A},t.prototype.equals=function(A){if(!(A instanceof t))return!1;var n=A;if(this.pts.length!==n.pts.length)return!1;for(var i=!0,r=!0,e=this.pts.length,s=0;s<this.pts.length;s++)if(this.pts[s].equals2D(n.pts[s])||(i=!1),this.pts[s].equals2D(n.pts[--e])||(r=!1),!i&&!r)return!1;return!0},t.prototype.getCoordinate=function(){if(0===arguments.length)return this.pts.length>0?this.pts[0]:null;if(1===arguments.length){var A=arguments[0];return this.pts[A]}},t.prototype.print=function(A){A.print("edge "+this.zn+": "),A.print("LINESTRING (");for(var t=0;t<this.pts.length;t++)t>0&&A.print(","),A.print(this.pts[t].x+" "+this.pts[t].y);A.print(")  "+this.Sn+" "+this.qr)},t.prototype.computeIM=function(A){t.updateIM(this.Sn,A)},t.prototype.isCollapsed=function(){return!!this.Sn.isArea()&&3===this.pts.length&&!!this.pts[0].equals(this.pts[2])},t.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])},t.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1},t.prototype.getDepthDelta=function(){return this.qr},t.prototype.getNumPoints=function(){return this.pts.length},t.prototype.printReverse=function(A){A.print("edge "+this.zn+": ");for(var t=this.pts.length-1;t>=0;t--)A.print(this.pts[t]+" ");A.println("")},t.prototype.getMonotoneChainEdge=function(){return null===this.Gr&&(this.Gr=new Ds(this)),this.Gr},t.prototype.getEnvelope=function(){if(null===this.Un){this.Un=new Kn;for(var A=0;A<this.pts.length;A++)this.Un.expandToInclude(this.pts[A])}return this.Un},t.prototype.addIntersection=function(A,t,n,i){var r=new mn(A.getIntersection(i)),e=t,s=A.getEdgeDistance(n,i),u=e+1;u<this.pts.length&&(r.equals2D(this.pts[u])&&(e=u,s=0));this.eiList.add(r,e,s)},t.prototype.toString=function(){var A=new Nn;A.append("edge "+this.zn+": "),A.append("LINESTRING (");for(var t=0;t<this.pts.length;t++)t>0&&A.append(","),A.append(this.pts[t].x+" "+this.pts[t].y);return A.append(")  "+this.Sn+" "+this.qr),A.toString()},t.prototype.isPointwiseEqual=function(A){if(this.pts.length!==A.pts.length)return!1;for(var t=0;t<this.pts.length;t++)if(!this.pts[t].equals2D(A.pts[t]))return!1;return!0},t.prototype.setDepthDelta=function(A){this.qr=A},t.prototype.getEdgeIntersectionList=function(){return this.eiList},t.prototype.addIntersections=function(A,t,n){for(var i=0;i<A.getIntersectionNum();i++)this.addIntersection(A,t,n,i)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t.updateIM=function(){if(2!==arguments.length)return A.prototype.updateIM.apply(this,arguments);var t=arguments[0],n=arguments[1];n.setAtLeastIfValid(t.getLocation(0,qr.ON),t.getLocation(1,qr.ON),1),t.isArea()&&(n.setAtLeastIfValid(t.getLocation(0,qr.LEFT),t.getLocation(1,qr.LEFT),2),n.setAtLeastIfValid(t.getLocation(0,qr.RIGHT),t.getLocation(1,qr.RIGHT),2))},t}(ie),zs=function(A){this.Vr=null,this.Wr=null,this.gn=null,this._r=null,this.Lr=new vs,this.rr=A||null};zs.prototype.setWorkingPrecisionModel=function(A){this.Vr=A},zs.prototype.insertUniqueEdge=function(A){var t=this.Lr.findEqualEdge(A);if(null!==t){var n=t.getLabel(),i=A.getLabel();t.isPointwiseEqual(A)||(i=new $r(A.getLabel())).flip(),n.merge(i);var r=zs.depthDelta(i),e=t.getDepthDelta()+r;t.setDepthDelta(e)}else this.Lr.add(A),A.setDepthDelta(zs.depthDelta(A.getLabel()))},zs.prototype.buildSubgraphs=function(A,t){for(var n=new yi,i=A.iterator();i.hasNext();){var r=i.next(),e=r.getRightmostCoordinate(),s=new ts(n).getDepth(e);r.computeDepth(s),r.findResultEdges(),n.add(r),t.add(r.getDirectedEdges(),r.getNodes())}},zs.prototype.createSubgraphs=function(A){for(var t=new yi,n=A.getNodes().iterator();n.hasNext();){var i=n.next();if(!i.isVisited()){var r=new Zr;r.create(i),t.add(r)}}return Ie.sort(t,Ie.reverseOrder()),t},zs.prototype.createEmptyResultGeometry=function(){return this.gn.createPolygon()},zs.prototype.getNoder=function(A){if(null!==this.Wr)return this.Wr;var t=new Ge,n=new si;return n.setPrecisionModel(A),t.setSegmentIntersector(new ws(n)),t},zs.prototype.buffer=function(A,t){var n=this.Vr;null===n&&(n=A.getPrecisionModel()),this.gn=A.getFactory();var i=new As(n,this.rr),r=new es(A,t,i).getCurves();if(r.size()<=0)return this.createEmptyResultGeometry();this.computeNodedEdges(r,n),this._r=new ce(new cs),this._r.addEdges(this.Lr.getEdges());var e=this.createSubgraphs(this._r),s=new ae(this.gn);this.buildSubgraphs(e,s);var u=s.getPolygons();return u.size()<=0?this.createEmptyResultGeometry():this.gn.buildGeometry(u)},zs.prototype.computeNodedEdges=function(A,t){var n=this.getNoder(t);n.computeNodes(A);for(var i=n.getNodedSubstrings().iterator();i.hasNext();){var r=i.next(),e=r.getCoordinates();if(2!==e.length||!e[0].equals2D(e[1])){var s=r.getData(),u=new bs(r.getCoordinates(),new $r(s));this.insertUniqueEdge(u)}}},zs.prototype.setNoder=function(A){this.Wr=A},zs.prototype.interfaces_=function(){return[]},zs.prototype.getClass=function(){return zs},zs.depthDelta=function(A){var t=A.getLocation(0,qr.LEFT),n=A.getLocation(0,qr.RIGHT);return t===Tn.INTERIOR&&n===Tn.EXTERIOR?1:t===Tn.EXTERIOR&&n===Tn.INTERIOR?-1:0},zs.convertSegStrings=function(A){for(var t=new jr,n=new yi;A.hasNext();){var i=A.next(),r=t.createLineString(i.getCoordinates());n.add(r)}return t.buildGeometry(n)};var ds=function(){if(this.Kr=null,this.Hr=null,this.Jr=null,this.Zr=null,this.Xr=!1,2===arguments.length){var A=arguments[0],t=arguments[1];this.Kr=A,this.Hr=t,this.Jr=0,this.Zr=0,this.Xr=!this.isIntegerPrecision()}else if(4===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],e=arguments[3];this.Kr=n,this.Hr=i,this.Jr=r,this.Zr=e,this.Xr=!this.isIntegerPrecision()}};ds.prototype.rescale=function(){var A=this;if(Fn(arguments[0],bi))for(var t=arguments[0],n=t.iterator();n.hasNext();){var i=n.next();A.rescale(i.getCoordinates())}else if(arguments[0]instanceof Array){for(var r=arguments[0],e=0;e<r.length;e++)r[e].x=r[e].x/A.Hr+A.Jr,r[e].y=r[e].y/A.Hr+A.Zr;2===r.length&&r[0].equals2D(r[1])&&Wn.out.println(r)}},ds.prototype.scale=function(){var A=this;if(Fn(arguments[0],bi)){for(var t=arguments[0],n=new yi,i=t.iterator();i.hasNext();){var r=i.next();n.add(new Ee(A.scale(r.getCoordinates()),r.getData()))}return n}if(arguments[0]instanceof Array){for(var e=arguments[0],s=new Array(e.length).fill(null),u=0;u<e.length;u++)s[u]=new mn(Math.round((e[u].x-A.Jr)*A.Hr),Math.round((e[u].y-A.Zr)*A.Hr),e[u].z);var o=Ti.removeRepeatedPoints(s);return o}},ds.prototype.isIntegerPrecision=function(){return 1===this.Hr},ds.prototype.getNodedSubstrings=function(){var A=this.Kr.getNodedSubstrings();return this.Xr&&this.rescale(A),A},ds.prototype.computeNodes=function(A){var t=A;this.Xr&&(t=this.scale(A)),this.Kr.computeNodes(t)},ds.prototype.interfaces_=function(){return[Be]},ds.prototype.getClass=function(){return ds};var xs=function(){this.er=new si,this.$r=null;var A=arguments[0];this.$r=A},ms={fact:{configurable:!0}};xs.prototype.checkEndPtVertexIntersections=function(){var A=this;if(0===arguments.length)for(var t=this.$r.iterator();t.hasNext();){var n=t.next(),i=n.getCoordinates();A.checkEndPtVertexIntersections(i[0],A.$r),A.checkEndPtVertexIntersections(i[i.length-1],A.$r)}else if(2===arguments.length)for(var r=arguments[0],e=arguments[1],s=e.iterator();s.hasNext();)for(var u=s.next(),o=u.getCoordinates(),h=1;h<o.length-1;h++)if(o[h].equals(r))throw new ti("found endpt/interior pt intersection at index "+h+" :pt "+r)},xs.prototype.checkInteriorIntersections=function(){var A=this;if(0===arguments.length)for(var t=this.$r.iterator();t.hasNext();)for(var n=t.next(),i=this.$r.iterator();i.hasNext();){var r=i.next();A.checkInteriorIntersections(n,r)}else if(2===arguments.length)for(var e=arguments[0],s=arguments[1],u=e.getCoordinates(),o=s.getCoordinates(),h=0;h<u.length-1;h++)for(var f=0;f<o.length-1;f++)A.checkInteriorIntersections(e,h,s,f);else if(4===arguments.length){var c=arguments[0],a=arguments[1],v=arguments[2],l=arguments[3];if(c===v&&a===l)return null;var w=c.getCoordinates()[a],P=c.getCoordinates()[a+1],g=v.getCoordinates()[l],C=v.getCoordinates()[l+1];if(this.er.computeIntersection(w,P,g,C),this.er.hasIntersection()&&(this.er.isProper()||this.hasInteriorIntersection(this.er,w,P)||this.hasInteriorIntersection(this.er,g,C)))throw new ti("found non-noded intersection at "+w+"-"+P+" and "+g+"-"+C)}},xs.prototype.checkValid=function(){this.checkEndPtVertexIntersections(),this.checkInteriorIntersections(),this.checkCollapses()},xs.prototype.checkCollapses=function(){var A=this;if(0===arguments.length)for(var t=this.$r.iterator();t.hasNext();){var n=t.next();A.checkCollapses(n)}else if(1===arguments.length)for(var i=arguments[0],r=i.getCoordinates(),e=0;e<r.length-2;e++)A.checkCollapse(r[e],r[e+1],r[e+2])},xs.prototype.hasInteriorIntersection=function(A,t,n){for(var i=0;i<A.getIntersectionNum();i++){var r=A.getIntersection(i);if(!r.equals(t)&&!r.equals(n))return!0}return!1},xs.prototype.checkCollapse=function(A,t,n){if(A.equals(n))throw new ti("found non-noded collapse at "+xs.fact.createLineString([A,t,n]))},xs.prototype.interfaces_=function(){return[]},xs.prototype.getClass=function(){return xs},ms.fact.get=function(){return new jr},Object.defineProperties(xs,ms);var ys=function(){this.er=null,this.Ae=null,this.te=null,this.ne=null,this.ie=null,this.re=null,this.Hr=null,this.qt=null,this.Vt=null,this.Wt=null,this._t=null,this.ee=new Array(4).fill(null),this.se=null;var A=arguments[0],t=arguments[1],n=arguments[2];if(this.te=A,this.Ae=A,this.Hr=t,this.er=n,t<=0)throw new Dn("Scale factor must be non-zero");1!==t&&(this.Ae=new mn(this.scale(A.x),this.scale(A.y)),this.ie=new mn,this.re=new mn),this.initCorners(this.Ae)},ps={SAFE_ENV_EXPANSION_FACTOR:{configurable:!0}};ys.prototype.intersectsScaled=function(A,t){var n=Math.min(A.x,t.x),i=Math.max(A.x,t.x),r=Math.min(A.y,t.y),e=Math.max(A.y,t.y),s=this.Vt<n||this.qt>i||this._t<r||this.Wt>e;if(s)return!1;var u=this.intersectsToleranceSquare(A,t);return ii.isTrue(!(s&&u),"Found bad envelope test"),u},ys.prototype.initCorners=function(A){this.qt=A.x-.5,this.Vt=A.x+.5,this.Wt=A.y-.5,this._t=A.y+.5,this.ee[0]=new mn(this.Vt,this._t),this.ee[1]=new mn(this.qt,this._t),this.ee[2]=new mn(this.qt,this.Wt),this.ee[3]=new mn(this.Vt,this.Wt)},ys.prototype.intersects=function(A,t){return 1===this.Hr?this.intersectsScaled(A,t):(this.copyScaled(A,this.ie),this.copyScaled(t,this.re),this.intersectsScaled(this.ie,this.re))},ys.prototype.scale=function(A){return Math.round(A*this.Hr)},ys.prototype.getCoordinate=function(){return this.te},ys.prototype.copyScaled=function(A,t){t.x=this.scale(A.x),t.y=this.scale(A.y)},ys.prototype.getSafeEnvelope=function(){if(null===this.se){var A=ys.SAFE_ENV_EXPANSION_FACTOR/this.Hr;this.se=new Kn(this.te.x-A,this.te.x+A,this.te.y-A,this.te.y+A)}return this.se},ys.prototype.intersectsPixelClosure=function(A,t){return this.er.computeIntersection(A,t,this.ee[0],this.ee[1]),!!(this.er.hasIntersection()||(this.er.computeIntersection(A,t,this.ee[1],this.ee[2]),this.er.hasIntersection()||(this.er.computeIntersection(A,t,this.ee[2],this.ee[3]),this.er.hasIntersection()||(this.er.computeIntersection(A,t,this.ee[3],this.ee[0]),this.er.hasIntersection()))))},ys.prototype.intersectsToleranceSquare=function(A,t){var n=!1,i=!1;return this.er.computeIntersection(A,t,this.ee[0],this.ee[1]),!!(this.er.isProper()||(this.er.computeIntersection(A,t,this.ee[1],this.ee[2]),this.er.isProper()||(this.er.hasIntersection()&&(n=!0),this.er.computeIntersection(A,t,this.ee[2],this.ee[3]),this.er.isProper()||(this.er.hasIntersection()&&(i=!0),this.er.computeIntersection(A,t,this.ee[3],this.ee[0]),this.er.isProper()||n&&i||A.equals(this.Ae)||t.equals(this.Ae)))))},ys.prototype.addSnappedNode=function(A,t){var n=A.getCoordinate(t),i=A.getCoordinate(t+1);return!!this.intersects(n,i)&&(A.addIntersection(this.getCoordinate(),t),!0)},ys.prototype.interfaces_=function(){return[]},ys.prototype.getClass=function(){return ys},ps.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(ys,ps);var Ls=function(){this.tempEnv1=new Kn,this.selectedSegment=new Ne};Ls.prototype.select=function(){if(1===arguments.length);else if(2===arguments.length){var A=arguments[0],t=arguments[1];A.getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}},Ls.prototype.interfaces_=function(){return[]},Ls.prototype.getClass=function(){return Ls};var Ts=function(){this.Qi=null;var A=arguments[0];this.Qi=A},Os={HotPixelSnapAction:{configurable:!0}};Ts.prototype.snap=function(){if(1===arguments.length){var A=arguments[0];return this.snap(A,null,-1)}if(3===arguments.length){var t=arguments[0],n=arguments[1],i=arguments[2],r=t.getSafeEnvelope(),e=new Fs(t,n,i);return this.Qi.query(r,{interfaces_:function(){return[Pe]},visitItem:function(A){A.select(r,e)}}),e.isNodeAdded()}},Ts.prototype.interfaces_=function(){return[]},Ts.prototype.getClass=function(){return Ts},Os.HotPixelSnapAction.get=function(){return Fs},Object.defineProperties(Ts,Os);var Fs=function(A){function t(){A.call(this),this.ue=null,this.oe=null,this.he=null,this.fe=!1;var t=arguments[0],n=arguments[1],i=arguments[2];this.ue=t,this.oe=n,this.he=i}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.isNodeAdded=function(){return this.fe},t.prototype.select=function(){if(2!==arguments.length)return A.prototype.select.apply(this,arguments);var t=arguments[0],n=arguments[1],i=t.getContext();if(null!==this.oe&&i===this.oe&&n===this.he)return null;this.fe=this.ue.addSnappedNode(i,n)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Ls),Us=function(){this.er=null,this.ce=null;var A=arguments[0];this.er=A,this.ce=new yi};Us.prototype.processIntersections=function(A,t,n,i){if(A===n&&t===i)return null;var r=A.getCoordinates()[t],e=A.getCoordinates()[t+1],s=n.getCoordinates()[i],u=n.getCoordinates()[i+1];if(this.er.computeIntersection(r,e,s,u),this.er.hasIntersection()&&this.er.isInteriorIntersection()){for(var o=0;o<this.er.getIntersectionNum();o++)this.ce.add(this.er.getIntersection(o));A.addIntersections(this.er,t,0),n.addIntersections(this.er,i,1)}},Us.prototype.isDone=function(){return!1},Us.prototype.getInteriorIntersections=function(){return this.ce},Us.prototype.interfaces_=function(){return[ls]},Us.prototype.getClass=function(){return Us};var Es=function(){this.ae=null,this.er=null,this.Hr=null,this.Kr=null,this.ve=null,this.ki=null;var A=arguments[0];this.ae=A,this.er=new si,this.er.setPrecisionModel(A),this.Hr=A.getScale()};Es.prototype.checkCorrectness=function(A){var t=Ee.getNodedSubstrings(A),n=new xs(t);try{n.checkValid()}catch(A){if(!(A instanceof qn))throw A;A.printStackTrace()}},Es.prototype.getNodedSubstrings=function(){return Ee.getNodedSubstrings(this.ki)},Es.prototype.snapRound=function(A,t){var n=this.findInteriorIntersections(A,t);this.computeIntersectionSnaps(n),this.computeVertexSnaps(A)},Es.prototype.findInteriorIntersections=function(A,t){var n=new Us(t);return this.Kr.setSegmentIntersector(n),this.Kr.computeNodes(A),n.getInteriorIntersections()},Es.prototype.computeVertexSnaps=function(){var A=this;if(Fn(arguments[0],bi))for(var t=arguments[0],n=t.iterator();n.hasNext();){var i=n.next();A.computeVertexSnaps(i)}else if(arguments[0]instanceof Ee)for(var r=arguments[0],e=r.getCoordinates(),s=0;s<e.length;s++){var u=new ys(e[s],A.Hr,A.er),o=A.ve.snap(u,r,s);o&&r.addIntersection(e[s],s)}},Es.prototype.computeNodes=function(A){this.ki=A,this.Kr=new Ge,this.ve=new Ts(this.Kr.getIndex()),this.snapRound(A,this.er)},Es.prototype.computeIntersectionSnaps=function(A){for(var t=A.iterator();t.hasNext();){var n=t.next(),i=new ys(n,this.Hr,this.er);this.ve.snap(i)}},Es.prototype.interfaces_=function(){return[Be]},Es.prototype.getClass=function(){return Es};var Ns=function(){if(this.we=null,this.gi=null,this.rr=new qe,this.Pe=null,this.Ce=null,1===arguments.length){var A=arguments[0];this.we=A}else if(2===arguments.length){var t=arguments[0],n=arguments[1];this.we=t,this.rr=n}},js={CAP_ROUND:{configurable:!0},CAP_BUTT:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},MAX_PRECISION_DIGITS:{configurable:!0}};Ns.prototype.bufferFixedPrecision=function(A){var t=new ds(new Es(new Fr(1)),A.getScale()),n=new zs(this.rr);n.setWorkingPrecisionModel(A),n.setNoder(t),this.Pe=n.buffer(this.we,this.gi)},Ns.prototype.bufferReducedPrecision=function(){var A=this;if(0===arguments.length){for(var t=Ns.MAX_PRECISION_DIGITS;t>=0;t--){try{A.bufferReducedPrecision(t)}catch(t){if(!(t instanceof Hr))throw t;A.Ce=t}if(null!==A.Pe)return null}throw this.Ce}if(1===arguments.length){var n=arguments[0],i=Ns.precisionScaleFactor(this.we,this.gi,n),r=new Fr(i);this.bufferFixedPrecision(r)}},Ns.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this.Pe)return null;var A=this.we.getFactory().getPrecisionModel();A.getType()===Fr.FIXED?this.bufferFixedPrecision(A):this.bufferReducedPrecision()},Ns.prototype.setQuadrantSegments=function(A){this.rr.setQuadrantSegments(A)},Ns.prototype.bufferOriginalPrecision=function(){try{var A=new zs(this.rr);this.Pe=A.buffer(this.we,this.gi)}catch(A){if(!(A instanceof ti))throw A;this.Ce=A}},Ns.prototype.getResultGeometry=function(A){return this.gi=A,this.computeGeometry(),this.Pe},Ns.prototype.setEndCapStyle=function(A){this.rr.setEndCapStyle(A)},Ns.prototype.interfaces_=function(){return[]},Ns.prototype.getClass=function(){return Ns},Ns.bufferOp=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1],n=new Ns(A),i=n.getResultGeometry(t);return i}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof ai&&"number"==typeof arguments[1]){var r=arguments[0],e=arguments[1],s=arguments[2],u=new Ns(r);u.setQuadrantSegments(s);var o=u.getResultGeometry(e);return o}if(arguments[2]instanceof qe&&arguments[0]instanceof ai&&"number"==typeof arguments[1]){var h=arguments[0],f=arguments[1],c=arguments[2],a=new Ns(h,c),v=a.getResultGeometry(f);return v}}else if(4===arguments.length){var l=arguments[0],w=arguments[1],P=arguments[2],g=arguments[3],C=new Ns(l);C.setQuadrantSegments(P),C.setEndCapStyle(g);var D=C.getResultGeometry(w);return D}},Ns.precisionScaleFactor=function(A,t,n){var i=A.getEnvelopeInternal(),r=Un.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(t>0?t:0),e=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,e)},js.CAP_ROUND.get=function(){return qe.CAP_ROUND},js.CAP_BUTT.get=function(){return qe.CAP_FLAT},js.CAP_FLAT.get=function(){return qe.CAP_FLAT},js.CAP_SQUARE.get=function(){return qe.CAP_SQUARE},js.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(Ns,js);var Qs=function(){this.Ae=[new mn,new mn],this.gi=In.NaN,this.De=!0};Qs.prototype.getCoordinates=function(){return this.Ae},Qs.prototype.getCoordinate=function(A){return this.Ae[A]},Qs.prototype.setMinimum=function(){if(1===arguments.length){var A=arguments[0];this.setMinimum(A.Ae[0],A.Ae[1])}else if(2===arguments.length){var t=arguments[0],n=arguments[1];if(this.De)return this.initialize(t,n),null;var i=t.distance(n);i<this.gi&&this.initialize(t,n,i)}},Qs.prototype.initialize=function(){if(0===arguments.length)this.De=!0;else if(2===arguments.length){var A=arguments[0],t=arguments[1];this.Ae[0].setCoordinate(A),this.Ae[1].setCoordinate(t),this.gi=A.distance(t),this.De=!1}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.Ae[0].setCoordinate(n),this.Ae[1].setCoordinate(i),this.gi=r,this.De=!1}},Qs.prototype.getDistance=function(){return this.gi},Qs.prototype.setMaximum=function(){if(1===arguments.length){var A=arguments[0];this.setMaximum(A.Ae[0],A.Ae[1])}else if(2===arguments.length){var t=arguments[0],n=arguments[1];if(this.De)return this.initialize(t,n),null;var i=t.distance(n);i>this.gi&&this.initialize(t,n,i)}},Qs.prototype.interfaces_=function(){return[]},Qs.prototype.getClass=function(){return Qs};var Ss=function(){};Ss.prototype.interfaces_=function(){return[]},Ss.prototype.getClass=function(){return Ss},Ss.computeDistance=function(){if(arguments[2]instanceof Qs&&arguments[0]instanceof lr&&arguments[1]instanceof mn)for(var A=arguments[0],t=arguments[1],n=arguments[2],i=A.getCoordinates(),r=new Ne,e=0;e<i.length-1;e++){r.setCoordinates(i[e],i[e+1]);var s=r.closestPoint(t);n.setMinimum(s,t)}else if(arguments[2]instanceof Qs&&arguments[0]instanceof Cr&&arguments[1]instanceof mn){var u=arguments[0],o=arguments[1],h=arguments[2];Ss.computeDistance(u.getExteriorRing(),o,h);for(var f=0;f<u.getNumInteriorRing();f++)Ss.computeDistance(u.getInteriorRingN(f),o,h)}else if(arguments[2]instanceof Qs&&arguments[0]instanceof ai&&arguments[1]instanceof mn){var c=arguments[0],a=arguments[1],v=arguments[2];if(c instanceof lr)Ss.computeDistance(c,a,v);else if(c instanceof Cr)Ss.computeDistance(c,a,v);else if(c instanceof tr)for(var l=c,w=0;w<l.getNumGeometries();w++){var P=l.getGeometryN(w);Ss.computeDistance(P,a,v)}else v.setMinimum(c.getCoordinate(),a)}else if(arguments[2]instanceof Qs&&arguments[0]instanceof Ne&&arguments[1]instanceof mn){var g=arguments[0],C=arguments[1],D=arguments[2],I=g.closestPoint(C);D.setMinimum(I,C)}};var ks=function(A){this.Ie=new Qs,this.Mr=A||null},Bs={MaxPointDistanceFilter:{configurable:!0},MaxMidpointDistanceFilter:{configurable:!0}};ks.prototype.computeMaxMidpointDistance=function(A){var t=new Gs(this.Mr);A.apply(t),this.Ie.setMaximum(t.getMaxPointDistance())},ks.prototype.computeMaxVertexDistance=function(A){var t=new Rs(this.Mr);A.apply(t),this.Ie.setMaximum(t.getMaxPointDistance())},ks.prototype.findDistance=function(A){return this.computeMaxVertexDistance(A),this.computeMaxMidpointDistance(A),this.Ie.getDistance()},ks.prototype.getDistancePoints=function(){return this.Ie},ks.prototype.interfaces_=function(){return[]},ks.prototype.getClass=function(){return ks},Bs.MaxPointDistanceFilter.get=function(){return Rs},Bs.MaxMidpointDistanceFilter.get=function(){return Gs},Object.defineProperties(ks,Bs);var Rs=function(A){this.Ie=new Qs,this.Me=new Qs,this.Pn=A||null};Rs.prototype.filter=function(A){this.Me.initialize(),Ss.computeDistance(this.Pn,A,this.Me),this.Ie.setMaximum(this.Me)},Rs.prototype.getMaxPointDistance=function(){return this.Ie},Rs.prototype.interfaces_=function(){return[wi]},Rs.prototype.getClass=function(){return Rs};var Gs=function(A){this.Ie=new Qs,this.Me=new Qs,this.Pn=A||null};Gs.prototype.filter=function(A,t){if(0===t)return null;var n=A.getCoordinate(t-1),i=A.getCoordinate(t),r=new mn((n.x+i.x)/2,(n.y+i.y)/2);this.Me.initialize(),Ss.computeDistance(this.Pn,r,this.Me),this.Ie.setMaximum(this.Me)},Gs.prototype.isDone=function(){return!1},Gs.prototype.isGeometryChanged=function(){return!1},Gs.prototype.getMaxPointDistance=function(){return this.Ie},Gs.prototype.interfaces_=function(){return[Ar]},Gs.prototype.getClass=function(){return Gs};var Ys=function(A){this.be=A||null};Ys.prototype.filter=function(A){A instanceof Cr&&this.be.add(A)},Ys.prototype.interfaces_=function(){return[$i]},Ys.prototype.getClass=function(){return Ys},Ys.getPolygons=function(){if(1===arguments.length){var A=arguments[0];return Ys.getPolygons(A,new yi)}if(2===arguments.length){var t=arguments[0],n=arguments[1];return t instanceof Cr?n.add(t):t instanceof tr&&t.apply(new Ys(n)),n}};var qs=function(){if(this.xt=null,this.ze=!1,1===arguments.length){var A=arguments[0];this.xt=A}else if(2===arguments.length){var t=arguments[0],n=arguments[1];this.xt=t,this.ze=n}};qs.prototype.filter=function(A){if(this.ze&&A instanceof Ir){var t=A.getFactory().createLineString(A.getCoordinateSequence());return this.xt.add(t),null}A instanceof lr&&this.xt.add(A)},qs.prototype.setForceToLineString=function(A){this.ze=A},qs.prototype.interfaces_=function(){return[ci]},qs.prototype.getClass=function(){return qs},qs.getGeometry=function(){if(1===arguments.length){var A=arguments[0];return A.getFactory().buildGeometry(qs.getLines(A))}if(2===arguments.length){var t=arguments[0],n=arguments[1];return t.getFactory().buildGeometry(qs.getLines(t,n))}},qs.getLines=function(){if(1===arguments.length){var A=arguments[0];return qs.getLines(A,!1)}if(2===arguments.length){if(Fn(arguments[0],bi)&&Fn(arguments[1],bi)){for(var t=arguments[0],n=arguments[1],i=t.iterator();i.hasNext();){var r=i.next();qs.getLines(r,n)}return n}if(arguments[0]instanceof ai&&"boolean"==typeof arguments[1]){var e=arguments[0],s=arguments[1],u=new yi;return e.apply(new qs(u,s)),u}if(arguments[0]instanceof ai&&Fn(arguments[1],bi)){var o=arguments[0],h=arguments[1];return o instanceof lr?h.add(o):o.apply(new qs(h)),h}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&Fn(arguments[0],bi)&&Fn(arguments[1],bi)){for(var f=arguments[0],c=arguments[1],a=arguments[2],v=f.iterator();v.hasNext();){var l=v.next();qs.getLines(l,c,a)}return c}if("boolean"==typeof arguments[2]&&arguments[0]instanceof ai&&Fn(arguments[1],bi)){var w=arguments[0],P=arguments[1],g=arguments[2];return w.apply(new qs(P,g)),P}}};var Vs=function(){if(this.de=Pi.OGC_SFS_BOUNDARY_RULE,this.xe=null,this.me=null,0===arguments.length);else if(1===arguments.length){var A=arguments[0];if(null===A)throw new Dn("Rule must be non-null");this.de=A}};Vs.prototype.locateInternal=function(){var A=this;if(arguments[0]instanceof mn&&arguments[1]instanceof Cr){var t=arguments[0],n=arguments[1];if(n.isEmpty())return Tn.EXTERIOR;var i=n.getExteriorRing(),r=this.locateInPolygonRing(t,i);if(r===Tn.EXTERIOR)return Tn.EXTERIOR;if(r===Tn.BOUNDARY)return Tn.BOUNDARY;for(var e=0;e<n.getNumInteriorRing();e++){var s=n.getInteriorRingN(e),u=A.locateInPolygonRing(t,s);if(u===Tn.INTERIOR)return Tn.EXTERIOR;if(u===Tn.BOUNDARY)return Tn.BOUNDARY}return Tn.INTERIOR}if(arguments[0]instanceof mn&&arguments[1]instanceof lr){var o=arguments[0],h=arguments[1];if(!h.getEnvelopeInternal().intersects(o))return Tn.EXTERIOR;var f=h.getCoordinates();return h.isClosed()||!o.equals(f[0])&&!o.equals(f[f.length-1])?hi.isOnLine(o,f)?Tn.INTERIOR:Tn.EXTERIOR:Tn.BOUNDARY}if(arguments[0]instanceof mn&&arguments[1]instanceof Pr){var c=arguments[0],a=arguments[1],v=a.getCoordinate();return v.equals2D(c)?Tn.INTERIOR:Tn.EXTERIOR}},Vs.prototype.locateInPolygonRing=function(A,t){return t.getEnvelopeInternal().intersects(A)?hi.locatePointInRing(A,t.getCoordinates()):Tn.EXTERIOR},Vs.prototype.intersects=function(A,t){return this.locate(A,t)!==Tn.EXTERIOR},Vs.prototype.updateLocationInfo=function(A){A===Tn.INTERIOR&&(this.xe=!0),A===Tn.BOUNDARY&&this.me++},Vs.prototype.computeLocation=function(A,t){if(t instanceof Pr&&this.updateLocationInfo(this.locateInternal(A,t)),t instanceof lr)this.updateLocationInfo(this.locateInternal(A,t));else if(t instanceof Cr)this.updateLocationInfo(this.locateInternal(A,t));else if(t instanceof nr)for(var n=t,i=0;i<n.getNumGeometries();i++){var r=n.getGeometryN(i);this.updateLocationInfo(this.locateInternal(A,r))}else if(t instanceof Mr)for(var e=t,s=0;s<e.getNumGeometries();s++){var u=e.getGeometryN(s);this.updateLocationInfo(this.locateInternal(A,u))}else if(t instanceof tr)for(var o=new us(t);o.hasNext();){var h=o.next();h!==t&&this.computeLocation(A,h)}},Vs.prototype.locate=function(A,t){return t.isEmpty()?Tn.EXTERIOR:t instanceof lr||t instanceof Cr?this.locateInternal(A,t):(this.xe=!1,this.me=0,this.computeLocation(A,t),this.de.isInBoundary(this.me)?Tn.BOUNDARY:this.me>0||this.xe?Tn.INTERIOR:Tn.EXTERIOR)},Vs.prototype.interfaces_=function(){return[]},Vs.prototype.getClass=function(){return Vs};var Ws=function A(){if(this.ye=null,this.pe=null,this.Ae=null,2===arguments.length){var t=arguments[0],n=arguments[1];A.call(this,t,A.INSIDE_AREA,n)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2];this.ye=i,this.pe=r,this.Ae=e}},_s={INSIDE_AREA:{configurable:!0}};Ws.prototype.isInsideArea=function(){return this.pe===Ws.INSIDE_AREA},Ws.prototype.getCoordinate=function(){return this.Ae},Ws.prototype.getGeometryComponent=function(){return this.ye},Ws.prototype.getSegmentIndex=function(){return this.pe},Ws.prototype.interfaces_=function(){return[]},Ws.prototype.getClass=function(){return Ws},_s.INSIDE_AREA.get=function(){return-1},Object.defineProperties(Ws,_s);var Ks=function(A){this.Qn=A||null};Ks.prototype.filter=function(A){A instanceof Pr&&this.Qn.add(A)},Ks.prototype.interfaces_=function(){return[$i]},Ks.prototype.getClass=function(){return Ks},Ks.getPoints=function(){if(1===arguments.length){var A=arguments[0];return A instanceof Pr?Ie.singletonList(A):Ks.getPoints(A,new yi)}if(2===arguments.length){var t=arguments[0],n=arguments[1];return t instanceof Pr?n.add(t):t instanceof tr&&t.apply(new Ks(n)),n}};var Hs=function(){this.Le=null;var A=arguments[0];this.Le=A};Hs.prototype.filter=function(A){(A instanceof Pr||A instanceof lr||A instanceof Cr)&&this.Le.add(new Ws(A,0,A.getCoordinate()))},Hs.prototype.interfaces_=function(){return[$i]},Hs.prototype.getClass=function(){return Hs},Hs.getLocations=function(A){var t=new yi;return A.apply(new Hs(t)),t};var Js=function(){if(this.Pn=null,this.Te=0,this.Oe=new Vs,this.Fe=null,this.Ue=In.MAX_VALUE,2===arguments.length){var A=arguments[0],t=arguments[1];this.Pn=[A,t],this.Te=0}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.Pn=new Array(2).fill(null),this.Pn[0]=n,this.Pn[1]=i,this.Te=r}};Js.prototype.computeContainmentDistance=function(){var A=this;if(0===arguments.length){var t=new Array(2).fill(null);if(this.computeContainmentDistance(0,t),this.Ue<=this.Te)return null;this.computeContainmentDistance(1,t)}else if(2===arguments.length){var n=arguments[0],i=arguments[1],r=1-n,e=Ys.getPolygons(this.Pn[n]);if(e.size()>0){var s=Hs.getLocations(this.Pn[r]);if(this.computeContainmentDistance(s,e,i),this.Ue<=this.Te)return this.Fe[r]=i[0],this.Fe[n]=i[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&Fn(arguments[0],xi)&&Fn(arguments[1],xi)){for(var u=arguments[0],o=arguments[1],h=arguments[2],f=0;f<u.size();f++)for(var c=u.get(f),a=0;a<o.size();a++)if(A.computeContainmentDistance(c,o.get(a),h),A.Ue<=A.Te)return null}else if(arguments[2]instanceof Array&&arguments[0]instanceof Ws&&arguments[1]instanceof Cr){var v=arguments[0],l=arguments[1],w=arguments[2],P=v.getCoordinate();if(Tn.EXTERIOR!==this.Oe.locate(P,l))return this.Ue=0,w[0]=v,w[1]=new Ws(l,P),null}},Js.prototype.computeMinDistanceLinesPoints=function(A,t,n){for(var i=0;i<A.size();i++)for(var r=A.get(i),e=0;e<t.size();e++){var s=t.get(e);if(this.computeMinDistance(r,s,n),this.Ue<=this.Te)return null}},Js.prototype.computeFacetDistance=function(){var A=new Array(2).fill(null),t=qs.getLines(this.Pn[0]),n=qs.getLines(this.Pn[1]),i=Ks.getPoints(this.Pn[0]),r=Ks.getPoints(this.Pn[1]);return this.computeMinDistanceLines(t,n,A),this.updateMinDistance(A,!1),this.Ue<=this.Te?null:(A[0]=null,A[1]=null,this.computeMinDistanceLinesPoints(t,r,A),this.updateMinDistance(A,!1),this.Ue<=this.Te?null:(A[0]=null,A[1]=null,this.computeMinDistanceLinesPoints(n,i,A),this.updateMinDistance(A,!0),this.Ue<=this.Te?null:(A[0]=null,A[1]=null,this.computeMinDistancePoints(i,r,A),void this.updateMinDistance(A,!1))))},Js.prototype.nearestLocations=function(){return this.computeMinDistance(),this.Fe},Js.prototype.updateMinDistance=function(A,t){if(null===A[0])return null;t?(this.Fe[0]=A[1],this.Fe[1]=A[0]):(this.Fe[0]=A[0],this.Fe[1]=A[1])},Js.prototype.nearestPoints=function(){return this.computeMinDistance(),[this.Fe[0].getCoordinate(),this.Fe[1].getCoordinate()]},Js.prototype.computeMinDistance=function(){var A=this;if(0===arguments.length){if(null!==this.Fe)return null;if(this.Fe=new Array(2).fill(null),this.computeContainmentDistance(),this.Ue<=this.Te)return null;this.computeFacetDistance()}else if(3===arguments.length)if(arguments[2]instanceof Array&&arguments[0]instanceof lr&&arguments[1]instanceof Pr){var t=arguments[0],n=arguments[1],i=arguments[2];if(t.getEnvelopeInternal().distance(n.getEnvelopeInternal())>this.Ue)return null;for(var r=t.getCoordinates(),e=n.getCoordinate(),s=0;s<r.length-1;s++){var u=hi.distancePointLine(e,r[s],r[s+1]);if(u<A.Ue){A.Ue=u;var o=new Ne(r[s],r[s+1]),h=o.closestPoint(e);i[0]=new Ws(t,s,h),i[1]=new Ws(n,0,e)}if(A.Ue<=A.Te)return null}}else if(arguments[2]instanceof Array&&arguments[0]instanceof lr&&arguments[1]instanceof lr){var f=arguments[0],c=arguments[1],a=arguments[2];if(f.getEnvelopeInternal().distance(c.getEnvelopeInternal())>this.Ue)return null;for(var v=f.getCoordinates(),l=c.getCoordinates(),w=0;w<v.length-1;w++)for(var P=0;P<l.length-1;P++){var g=hi.distanceLineLine(v[w],v[w+1],l[P],l[P+1]);if(g<A.Ue){A.Ue=g;var C=new Ne(v[w],v[w+1]),D=new Ne(l[P],l[P+1]),I=C.closestPoints(D);a[0]=new Ws(f,w,I[0]),a[1]=new Ws(c,P,I[1])}if(A.Ue<=A.Te)return null}}},Js.prototype.computeMinDistancePoints=function(A,t,n){for(var i=0;i<A.size();i++)for(var r=A.get(i),e=0;e<t.size();e++){var s=t.get(e),u=r.getCoordinate().distance(s.getCoordinate());if(u<this.Ue&&(this.Ue=u,n[0]=new Ws(r,0,r.getCoordinate()),n[1]=new Ws(s,0,s.getCoordinate())),this.Ue<=this.Te)return null}},Js.prototype.distance=function(){if(null===this.Pn[0]||null===this.Pn[1])throw new Dn("null geometries are not supported");return this.Pn[0].isEmpty()||this.Pn[1].isEmpty()?0:(this.computeMinDistance(),this.Ue)},Js.prototype.computeMinDistanceLines=function(A,t,n){for(var i=0;i<A.size();i++)for(var r=A.get(i),e=0;e<t.size();e++){var s=t.get(e);if(this.computeMinDistance(r,s,n),this.Ue<=this.Te)return null}},Js.prototype.interfaces_=function(){return[]},Js.prototype.getClass=function(){return Js},Js.distance=function(A,t){return new Js(A,t).distance()},Js.isWithinDistance=function(A,t,n){return new Js(A,t,n).distance()<=n},Js.nearestPoints=function(A,t){return new Js(A,t).nearestPoints()};var Zs=function(){this.Ae=[new mn,new mn],this.gi=In.NaN,this.De=!0};Zs.prototype.getCoordinates=function(){return this.Ae},Zs.prototype.getCoordinate=function(A){return this.Ae[A]},Zs.prototype.setMinimum=function(){if(1===arguments.length){var A=arguments[0];this.setMinimum(A.Ae[0],A.Ae[1])}else if(2===arguments.length){var t=arguments[0],n=arguments[1];if(this.De)return this.initialize(t,n),null;var i=t.distance(n);i<this.gi&&this.initialize(t,n,i)}},Zs.prototype.initialize=function(){if(0===arguments.length)this.De=!0;else if(2===arguments.length){var A=arguments[0],t=arguments[1];this.Ae[0].setCoordinate(A),this.Ae[1].setCoordinate(t),this.gi=A.distance(t),this.De=!1}else if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2];this.Ae[0].setCoordinate(n),this.Ae[1].setCoordinate(i),this.gi=r,this.De=!1}},Zs.prototype.toString=function(){return Ai.toLineString(this.Ae[0],this.Ae[1])},Zs.prototype.getDistance=function(){return this.gi},Zs.prototype.setMaximum=function(){if(1===arguments.length){var A=arguments[0];this.setMaximum(A.Ae[0],A.Ae[1])}else if(2===arguments.length){var t=arguments[0],n=arguments[1];if(this.De)return this.initialize(t,n),null;var i=t.distance(n);i>this.gi&&this.initialize(t,n,i)}},Zs.prototype.interfaces_=function(){return[]},Zs.prototype.getClass=function(){return Zs};var Xs=function(){};Xs.prototype.interfaces_=function(){return[]},Xs.prototype.getClass=function(){return Xs},Xs.computeDistance=function(){if(arguments[2]instanceof Zs&&arguments[0]instanceof lr&&arguments[1]instanceof mn)for(var A=arguments[0],t=arguments[1],n=arguments[2],i=new Ne,r=A.getCoordinates(),e=0;e<r.length-1;e++){i.setCoordinates(r[e],r[e+1]);var s=i.closestPoint(t);n.setMinimum(s,t)}else if(arguments[2]instanceof Zs&&arguments[0]instanceof Cr&&arguments[1]instanceof mn){var u=arguments[0],o=arguments[1],h=arguments[2];Xs.computeDistance(u.getExteriorRing(),o,h);for(var f=0;f<u.getNumInteriorRing();f++)Xs.computeDistance(u.getInteriorRingN(f),o,h)}else if(arguments[2]instanceof Zs&&arguments[0]instanceof ai&&arguments[1]instanceof mn){var c=arguments[0],a=arguments[1],v=arguments[2];if(c instanceof lr)Xs.computeDistance(c,a,v);else if(c instanceof Cr)Xs.computeDistance(c,a,v);else if(c instanceof tr)for(var l=c,w=0;w<l.getNumGeometries();w++){var P=l.getGeometryN(w);Xs.computeDistance(P,a,v)}else v.setMinimum(c.getCoordinate(),a)}else if(arguments[2]instanceof Zs&&arguments[0]instanceof Ne&&arguments[1]instanceof mn){var g=arguments[0],C=arguments[1],D=arguments[2],I=g.closestPoint(C);D.setMinimum(I,C)}};var $s=function(){this.Ee=null,this.Ne=null,this.je=new Zs,this.Qe=0;var A=arguments[0],t=arguments[1];this.Ee=A,this.Ne=t},Au={MaxPointDistanceFilter:{configurable:!0},MaxDensifiedByFractionDistanceFilter:{configurable:!0}};$s.prototype.getCoordinates=function(){return this.je.getCoordinates()},$s.prototype.setDensifyFraction=function(A){if(A>1||A<=0)throw new Dn("Fraction is not in range (0.0 - 1.0]");this.Qe=A},$s.prototype.compute=function(A,t){this.computeOrientedDistance(A,t,this.je),this.computeOrientedDistance(t,A,this.je)},$s.prototype.distance=function(){return this.compute(this.Ee,this.Ne),this.je.getDistance()},$s.prototype.computeOrientedDistance=function(A,t,n){var i=new tu(t);if(A.apply(i),n.setMaximum(i.getMaxPointDistance()),this.Qe>0){var r=new nu(t,this.Qe);A.apply(r),n.setMaximum(r.getMaxPointDistance())}},$s.prototype.orientedDistance=function(){return this.computeOrientedDistance(this.Ee,this.Ne,this.je),this.je.getDistance()},$s.prototype.interfaces_=function(){return[]},$s.prototype.getClass=function(){return $s},$s.distance=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1],n=new $s(A,t);return n.distance()}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2],s=new $s(i,r);return s.setDensifyFraction(e),s.distance()}},Au.MaxPointDistanceFilter.get=function(){return tu},Au.MaxDensifiedByFractionDistanceFilter.get=function(){return nu},Object.defineProperties($s,Au);var tu=function(){this.Ie=new Zs,this.Me=new Zs,this.Se=new Xs,this.Pn=null;var A=arguments[0];this.Pn=A};tu.prototype.filter=function(A){this.Me.initialize(),Xs.computeDistance(this.Pn,A,this.Me),this.Ie.setMaximum(this.Me)},tu.prototype.getMaxPointDistance=function(){return this.Ie},tu.prototype.interfaces_=function(){return[wi]},tu.prototype.getClass=function(){return tu};var nu=function(){this.Ie=new Zs,this.Me=new Zs,this.Pn=null,this.ke=0;var A=arguments[0],t=arguments[1];this.Pn=A,this.ke=Math.trunc(Math.round(1/t))};nu.prototype.filter=function(A,t){if(0===t)return null;for(var n=A.getCoordinate(t-1),i=A.getCoordinate(t),r=(i.x-n.x)/this.ke,e=(i.y-n.y)/this.ke,s=0;s<this.ke;s++){var h=new mn(n.x+s*r,n.y+s*e);this.Me.initialize(),Xs.computeDistance(this.Pn,h,this.Me),this.Ie.setMaximum(this.Me)}},nu.prototype.isDone=function(){return!1},nu.prototype.isGeometryChanged=function(){return!1},nu.prototype.getMaxPointDistance=function(){return this.Ie},nu.prototype.interfaces_=function(){return[Ar]},nu.prototype.getClass=function(){return nu};var iu=function(A,t,n){this.Be=null,this.Re=null,this.Ge=null,this.Ye=null,this.qe=!0,this.Ve=null,this.We=null,this._e=null,this.Ke=A||null,this.He=t||null,this.$t=n||null},ru={VERBOSE:{configurable:!0},MAX_DISTANCE_DIFF_FRAC:{configurable:!0}};iu.prototype.checkMaximumDistance=function(A,t,n){var i=new $s(t,A);if(i.setDensifyFraction(.25),this.Ye=i.orientedDistance(),this.Ye>n){this.qe=!1;var r=i.getCoordinates();this.We=r[1],this._e=A.getFactory().createLineString(r),this.Ve="Distance between buffer curve and input is too large ("+this.Ye+" at "+Ai.toLineString(r[0],r[1])+")"}},iu.prototype.isValid=function(){var A=Math.abs(this.He),t=iu.MAX_DISTANCE_DIFF_FRAC*A;return this.Be=A-t,this.Re=A+t,!(!this.Ke.isEmpty()&&!this.$t.isEmpty())||(this.He>0?this.checkPositiveValid():this.checkNegativeValid(),iu.VERBOSE&&Wn.out.println("Min Dist= "+this.Ge+"  err= "+(1-this.Ge/this.He)+"  Max Dist= "+this.Ye+"  err= "+(this.Ye/this.He-1)),this.qe)},iu.prototype.checkNegativeValid=function(){if(!(this.Ke instanceof Cr||this.Ke instanceof Mr||this.Ke instanceof tr))return null;var A=this.getPolygonLines(this.Ke);if(this.checkMinimumDistance(A,this.$t,this.Be),!this.qe)return null;this.checkMaximumDistance(A,this.$t,this.Re)},iu.prototype.getErrorIndicator=function(){return this._e},iu.prototype.checkMinimumDistance=function(A,t,n){var i=new Js(A,t,n);if(this.Ge=i.distance(),this.Ge<n){this.qe=!1;var r=i.nearestPoints();this.We=i.nearestPoints()[1],this._e=A.getFactory().createLineString(r),this.Ve="Distance between buffer curve and input is too small ("+this.Ge+" at "+Ai.toLineString(r[0],r[1])+" )"}},iu.prototype.checkPositiveValid=function(){var A=this.$t.getBoundary();if(this.checkMinimumDistance(this.Ke,A,this.Be),!this.qe)return null;this.checkMaximumDistance(this.Ke,A,this.Re)},iu.prototype.getErrorLocation=function(){return this.We},iu.prototype.getPolygonLines=function(A){for(var t=new yi,n=new qs(t),i=Ys.getPolygons(A).iterator();i.hasNext();)i.next().apply(n);return A.getFactory().buildGeometry(t)},iu.prototype.getErrorMessage=function(){return this.Ve},iu.prototype.interfaces_=function(){return[]},iu.prototype.getClass=function(){return iu},ru.VERBOSE.get=function(){return!1},ru.MAX_DISTANCE_DIFF_FRAC.get=function(){return.012},Object.defineProperties(iu,ru);var eu=function(A,t,n){this.qe=!0,this.Je=null,this.We=null,this._e=null,this.Ke=A||null,this.gi=t||null,this.$t=n||null},su={VERBOSE:{configurable:!0},MAX_ENV_DIFF_FRAC:{configurable:!0}};eu.prototype.isValid=function(){return this.checkPolygonal(),this.qe?(this.checkExpectedEmpty(),this.qe?(this.checkEnvelope(),this.qe?(this.checkArea(),this.qe?(this.checkDistance(),this.qe):this.qe):this.qe):this.qe):this.qe},eu.prototype.checkEnvelope=function(){if(this.gi<0)return null;var A=this.gi*eu.MAX_ENV_DIFF_FRAC;0===A&&(A=.001);var t=new Kn(this.Ke.getEnvelopeInternal());t.expandBy(this.gi);var n=new Kn(this.$t.getEnvelopeInternal());n.expandBy(A),n.contains(t)||(this.qe=!1,this.Je="Buffer envelope is incorrect",this._e=this.Ke.getFactory().toGeometry(n)),this.report("Envelope")},eu.prototype.checkDistance=function(){var A=new iu(this.Ke,this.gi,this.$t);A.isValid()||(this.qe=!1,this.Je=A.getErrorMessage(),this.We=A.getErrorLocation(),this._e=A.getErrorIndicator()),this.report("Distance")},eu.prototype.checkArea=function(){var A=this.Ke.getArea(),t=this.$t.getArea();this.gi>0&&A>t&&(this.qe=!1,this.Je="Area of positive buffer is smaller than input",this._e=this.$t),this.gi<0&&A<t&&(this.qe=!1,this.Je="Area of negative buffer is larger than input",this._e=this.$t),this.report("Area")},eu.prototype.checkPolygonal=function(){this.$t instanceof Cr||this.$t instanceof Mr||(this.qe=!1),this.Je="Result is not polygonal",this._e=this.$t,this.report("Polygonal")},eu.prototype.getErrorIndicator=function(){return this._e},eu.prototype.getErrorLocation=function(){return this.We},eu.prototype.checkExpectedEmpty=function(){return this.Ke.getDimension()>=2||this.gi>0?null:(this.$t.isEmpty()||(this.qe=!1,this.Je="Result is non-empty",this._e=this.$t),void this.report("ExpectedEmpty"))},eu.prototype.report=function(A){if(!eu.VERBOSE)return null;Wn.out.println("Check "+A+": "+(this.qe?"passed":"FAILED"))},eu.prototype.getErrorMessage=function(){return this.Je},eu.prototype.interfaces_=function(){return[]},eu.prototype.getClass=function(){return eu},eu.isValidMsg=function(A,t,n){var i=new eu(A,t,n);return i.isValid()?null:i.getErrorMessage()},eu.isValid=function(A,t,n){return!!new eu(A,t,n).isValid()},su.VERBOSE.get=function(){return!1},su.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(eu,su);var uu=function(){this.Qn=null,this.pi=null;var A=arguments[0],t=arguments[1];this.Qn=A,this.pi=t};uu.prototype.getCoordinates=function(){return this.Qn},uu.prototype.size=function(){return this.Qn.length},uu.prototype.getCoordinate=function(A){return this.Qn[A]},uu.prototype.isClosed=function(){return this.Qn[0].equals(this.Qn[this.Qn.length-1])},uu.prototype.getSegmentOctant=function(A){return A===this.Qn.length-1?-1:Oe.octant(this.getCoordinate(A),this.getCoordinate(A+1))},uu.prototype.setData=function(A){this.pi=A},uu.prototype.getData=function(){return this.pi},uu.prototype.toString=function(){return Ai.toLineString(new yr(this.Qn))},uu.prototype.interfaces_=function(){return[Fe]},uu.prototype.getClass=function(){return uu};var ou=function(){this.Ze=!1,this.Xe=!1,this.er=null,this.$e=null,this.As=null,this.ts=new yi,this.ns=0,this.rs=!0;var A=arguments[0];this.er=A,this.$e=null};ou.prototype.getInteriorIntersection=function(){return this.$e},ou.prototype.setCheckEndSegmentsOnly=function(A){this.Xe=A},ou.prototype.getIntersectionSegments=function(){return this.As},ou.prototype.count=function(){return this.ns},ou.prototype.getIntersections=function(){return this.ts},ou.prototype.setFindAllIntersections=function(A){this.Ze=A},ou.prototype.setKeepIntersections=function(A){this.rs=A},ou.prototype.processIntersections=function(A,t,n,i){if(!this.Ze&&this.hasIntersection())return null;if(A===n&&t===i)return null;if(this.Xe&&!this.isEndSegment(A,t)&&!this.isEndSegment(n,i))return null;var r=A.getCoordinates()[t],e=A.getCoordinates()[t+1],s=n.getCoordinates()[i],u=n.getCoordinates()[i+1];this.er.computeIntersection(r,e,s,u),this.er.hasIntersection()&&this.er.isInteriorIntersection()&&(this.As=new Array(4).fill(null),this.As[0]=r,this.As[1]=e,this.As[2]=s,this.As[3]=u,this.$e=this.er.getIntersection(0),this.rs&&this.ts.add(this.$e),this.ns++)},ou.prototype.isEndSegment=function(A,t){return 0===t||t>=A.size()-2},ou.prototype.hasIntersection=function(){return null!==this.$e},ou.prototype.isDone=function(){return!this.Ze&&null!==this.$e},ou.prototype.interfaces_=function(){return[ls]},ou.prototype.getClass=function(){return ou},ou.createAllIntersectionsFinder=function(A){var t=new ou(A);return t.setFindAllIntersections(!0),t},ou.createAnyIntersectionFinder=function(A){return new ou(A)},ou.createIntersectionCounter=function(A){var t=new ou(A);return t.setFindAllIntersections(!0),t.setKeepIntersections(!1),t};var hu=function(){this.er=new si,this.$r=null,this.Ze=!1,this.Ni=null,this.qe=!0;var A=arguments[0];this.$r=A};hu.prototype.execute=function(){if(null!==this.Ni)return null;this.checkInteriorIntersections()},hu.prototype.getIntersections=function(){return this.Ni.getIntersections()},hu.prototype.isValid=function(){return this.execute(),this.qe},hu.prototype.setFindAllIntersections=function(A){this.Ze=A},hu.prototype.checkInteriorIntersections=function(){this.qe=!0,this.Ni=new ou(this.er),this.Ni.setFindAllIntersections(this.Ze);var A=new Ge;if(A.setSegmentIntersector(this.Ni),A.computeNodes(this.$r),this.Ni.hasIntersection())return this.qe=!1,null},hu.prototype.checkValid=function(){if(this.execute(),!this.qe)throw new Hr(this.getErrorMessage(),this.Ni.getInteriorIntersection())},hu.prototype.getErrorMessage=function(){if(this.qe)return"no intersections found";var A=this.Ni.getIntersectionSegments();return"found non-noded intersection between "+Ai.toLineString(A[0],A[1])+" and "+Ai.toLineString(A[2],A[3])},hu.prototype.interfaces_=function(){return[]},hu.prototype.getClass=function(){return hu},hu.computeIntersections=function(A){var t=new hu(A);return t.setFindAllIntersections(!0),t.isValid(),t.getIntersections()};var fu=function A(){this.es=null;var t=arguments[0];this.es=new hu(A.toSegmentStrings(t))};fu.prototype.checkValid=function(){this.es.checkValid()},fu.prototype.interfaces_=function(){return[]},fu.prototype.getClass=function(){return fu},fu.toSegmentStrings=function(A){for(var t=new yi,n=A.iterator();n.hasNext();){var i=n.next();t.add(new uu(i.getCoordinates(),i))}return t},fu.checkValid=function(A){new fu(A).checkValid()};var cu=function(A){this.ss=A};cu.prototype.map=function(A){for(var t=new yi,n=0;n<A.getNumGeometries();n++){var i=this.ss.map(A.getGeometryN(n));i.isEmpty()||t.add(i)}return A.getFactory().createGeometryCollection(jr.toGeometryArray(t))},cu.prototype.interfaces_=function(){return[]},cu.prototype.getClass=function(){return cu},cu.map=function(A,t){return new cu(t).map(A)};var au=function(){this.us=null,this.Rn=null,this.Oe=null,this.os=new yi,this.hs=new yi;var A=arguments[0],t=arguments[1],n=arguments[2];this.us=A,this.Rn=t,this.Oe=n};au.prototype.collectLines=function(A){for(var t=this.us.getGraph().getEdgeEnds().iterator();t.hasNext();){var n=t.next();this.collectLineEdge(n,A,this.os),this.collectBoundaryTouchEdge(n,A,this.os)}},au.prototype.labelIsolatedLine=function(A,t){var n=this.Oe.locate(A.getCoordinate(),this.us.getArgGeometry(t));A.getLabel().setLocation(t,n)},au.prototype.build=function(A){return this.findCoveredLineEdges(),this.collectLines(A),this.buildLines(A),this.hs},au.prototype.collectLineEdge=function(A,t,n){var i=A.getLabel(),r=A.getEdge();A.isLineEdge()&&(A.isVisited()||!Wu.isResultOfOp(i,t)||r.isCovered()||(n.add(r),A.setVisitedEdge(!0)))},au.prototype.findCoveredLineEdges=function(){for(var A=this.us.getGraph().getNodes().iterator();A.hasNext();)A.next().getEdges().findCoveredLineEdges();for(var t=this.us.getGraph().getEdgeEnds().iterator();t.hasNext();){var n=t.next(),i=n.getEdge();if(n.isLineEdge()&&!i.isCoveredSet()){var r=this.us.isCoveredByA(n.getCoordinate());i.setCovered(r)}}},au.prototype.labelIsolatedLines=function(A){for(var t=A.iterator();t.hasNext();){var n=t.next(),i=n.getLabel();n.isIsolated()&&(i.isNull(0)?this.labelIsolatedLine(n,0):this.labelIsolatedLine(n,1))}},au.prototype.buildLines=function(A){for(var t=this.os.iterator();t.hasNext();){var n=t.next(),i=this.Rn.createLineString(n.getCoordinates());this.hs.add(i),n.setInResult(!0)}},au.prototype.collectBoundaryTouchEdge=function(A,t,n){var i=A.getLabel();return A.isLineEdge()||A.isVisited()||A.isInteriorAreaEdge()||A.getEdge().isInResult()?null:(ii.isTrue(!(A.isInResult()||A.getSym().isInResult())||!A.getEdge().isInResult()),void(Wu.isResultOfOp(i,t)&&t===Wu.INTERSECTION&&(n.add(A.getEdge()),A.setVisitedEdge(!0))))},au.prototype.interfaces_=function(){return[]},au.prototype.getClass=function(){return au};var vu=function(){this.us=null,this.Rn=null,this.fs=new yi;var A=arguments[0],t=arguments[1];this.us=A,this.Rn=t};vu.prototype.filterCoveredNodeToPoint=function(A){var t=A.getCoordinate();if(!this.us.isCoveredByLA(t)){var n=this.Rn.createPoint(t);this.fs.add(n)}},vu.prototype.extractNonCoveredResultNodes=function(A){for(var t=this.us.getGraph().getNodes().iterator();t.hasNext();){var n=t.next();if(!(n.isInResult()||n.isIncidentEdgeInResult()||0!==n.getEdges().getDegree()&&A!==Wu.INTERSECTION)){var i=n.getLabel();Wu.isResultOfOp(i,A)&&this.filterCoveredNodeToPoint(n)}}},vu.prototype.build=function(A){return this.extractNonCoveredResultNodes(A),this.fs},vu.prototype.interfaces_=function(){return[]},vu.prototype.getClass=function(){return vu};var lu=function(){this.Mr=null,this.vn=null,this.cs=!0,this.as=!0,this.vs=!1,this.ls=!1};lu.prototype.transformPoint=function(A,t){return this.vn.createPoint(this.transformCoordinates(A.getCoordinateSequence(),A))},lu.prototype.transformPolygon=function(A,t){var n=!0,i=this.transformLinearRing(A.getExteriorRing(),A);null!==i&&i instanceof Ir&&!i.isEmpty()||(n=!1);for(var r=new yi,e=0;e<A.getNumInteriorRing();e++){var s=this.transformLinearRing(A.getInteriorRingN(e),A);null===s||s.isEmpty()||(s instanceof Ir||(n=!1),r.add(s))}if(n)return this.vn.createPolygon(i,r.toArray([]));var u=new yi;return null!==i&&u.add(i),u.addAll(r),this.vn.buildGeometry(u)},lu.prototype.createCoordinateSequence=function(A){return this.vn.getCoordinateSequenceFactory().create(A)},lu.prototype.getInputGeometry=function(){return this.Mr},lu.prototype.transformMultiLineString=function(A,t){for(var n=new yi,i=0;i<A.getNumGeometries();i++){var r=this.transformLineString(A.getGeometryN(i),A);null!==r&&(r.isEmpty()||n.add(r))}return this.vn.buildGeometry(n)},lu.prototype.transformCoordinates=function(A,t){return this.copy(A)},lu.prototype.transformLineString=function(A,t){return this.vn.createLineString(this.transformCoordinates(A.getCoordinateSequence(),A))},lu.prototype.transformMultiPoint=function(A,t){for(var n=new yi,i=0;i<A.getNumGeometries();i++){var r=this.transformPoint(A.getGeometryN(i),A);null!==r&&(r.isEmpty()||n.add(r))}return this.vn.buildGeometry(n)},lu.prototype.transformMultiPolygon=function(A,t){for(var n=new yi,i=0;i<A.getNumGeometries();i++){var r=this.transformPolygon(A.getGeometryN(i),A);null!==r&&(r.isEmpty()||n.add(r))}return this.vn.buildGeometry(n)},lu.prototype.copy=function(A){return A.copy()},lu.prototype.transformGeometryCollection=function(A,t){for(var n=new yi,i=0;i<A.getNumGeometries();i++){var r=this.transform(A.getGeometryN(i));null!==r&&(this.cs&&r.isEmpty()||n.add(r))}return this.as?this.vn.createGeometryCollection(jr.toGeometryArray(n)):this.vn.buildGeometry(n)},lu.prototype.transform=function(A){if(this.Mr=A,this.vn=A.getFactory(),A instanceof Pr)return this.transformPoint(A,null);if(A instanceof Dr)return this.transformMultiPoint(A,null);if(A instanceof Ir)return this.transformLinearRing(A,null);if(A instanceof lr)return this.transformLineString(A,null);if(A instanceof nr)return this.transformMultiLineString(A,null);if(A instanceof Cr)return this.transformPolygon(A,null);if(A instanceof Mr)return this.transformMultiPolygon(A,null);if(A instanceof tr)return this.transformGeometryCollection(A,null);throw new Dn("Unknown Geometry subtype: "+A.getClass().getName())},lu.prototype.transformLinearRing=function(A,t){var n=this.transformCoordinates(A.getCoordinateSequence(),A);if(null===n)return this.vn.createLinearRing(null);var i=n.size();return i>0&&i<4&&!this.ls?this.vn.createLineString(n):this.vn.createLinearRing(n)},lu.prototype.interfaces_=function(){return[]},lu.prototype.getClass=function(){return lu};var wu=function A(){if(this.ws=0,this.Ps=null,this.gr=new Ne,this.gs=!1,this.Cs=!1,arguments[0]instanceof lr&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1];A.call(this,t.getCoordinates(),n)}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var i=arguments[0],r=arguments[1];this.Ps=i,this.Cs=A.isClosed(i),this.ws=r}};wu.prototype.snapVertices=function(A,t){for(var n=this.Cs?A.size()-1:A.size(),i=0;i<n;i++){var r=A.get(i),e=this.findSnapForVertex(r,t);null!==e&&(A.set(i,new mn(e)),0===i&&this.Cs&&A.set(A.size()-1,new mn(e)))}},wu.prototype.findSnapForVertex=function(A,t){for(var n=0;n<t.length;n++){if(A.equals2D(t[n]))return null;if(A.distance(t[n])<this.ws)return t[n]}return null},wu.prototype.snapTo=function(A){var t=new Li(this.Ps);return this.snapVertices(t,A),this.snapSegments(t,A),t.toCoordinateArray()},wu.prototype.snapSegments=function(A,t){if(0===t.length)return null;var n=t.length;t[0].equals2D(t[t.length-1])&&(n=t.length-1);for(var i=0;i<n;i++){var r=t[i],e=this.findSegmentIndexToSnap(r,A);e>=0&&A.add(e+1,new mn(r),!1)}},wu.prototype.findSegmentIndexToSnap=function(A,t){for(var n=In.MAX_VALUE,i=-1,r=0;r<t.size()-1;r++){if(this.gr.p0=t.get(r),this.gr.p1=t.get(r+1),this.gr.p0.equals2D(A)||this.gr.p1.equals2D(A)){if(this.gs)continue;return-1}var e=this.gr.distance(A);e<this.ws&&e<n&&(n=e,i=r)}return i},wu.prototype.setAllowSnappingToSourceVertices=function(A){this.gs=A},wu.prototype.interfaces_=function(){return[]},wu.prototype.getClass=function(){return wu},wu.isClosed=function(A){return!(A.length<=1)&&A[0].equals2D(A[A.length-1])};var Pu=function(A){this.Ds=A||null},gu={SNAP_PRECISION_FACTOR:{configurable:!0}};Pu.prototype.snapTo=function(A,t){var n=this.extractTargetCoordinates(A);return new Cu(t,n).transform(this.Ds)},Pu.prototype.snapToSelf=function(A,t){var n=this.extractTargetCoordinates(this.Ds),i=new Cu(A,n,!0).transform(this.Ds),r=i;return t&&Fn(r,gr)&&(r=i.buffer(0)),r},Pu.prototype.computeSnapTolerance=function(A){return this.computeMinimumSegmentLength(A)/10},Pu.prototype.extractTargetCoordinates=function(A){for(var t=new Ki,n=A.getCoordinates(),i=0;i<n.length;i++)t.add(n[i]);return t.toArray(new Array(0).fill(null))},Pu.prototype.computeMinimumSegmentLength=function(A){for(var t=In.MAX_VALUE,n=0;n<A.length-1;n++){var i=A[n].distance(A[n+1]);i<t&&(t=i)}return t},Pu.prototype.interfaces_=function(){return[]},Pu.prototype.getClass=function(){return Pu},Pu.snap=function(A,t,n){var i=new Array(2).fill(null),r=new Pu(A);i[0]=r.snapTo(t,n);var e=new Pu(t);return i[1]=e.snapTo(i[0],n),i},Pu.computeOverlaySnapTolerance=function(){if(1===arguments.length){var A=arguments[0],t=Pu.computeSizeBasedSnapTolerance(A),n=A.getPrecisionModel();if(n.getType()===Fr.FIXED){var i=1/n.getScale()*2/1.415;i>t&&(t=i)}return t}if(2===arguments.length){var r=arguments[0],e=arguments[1];return Math.min(Pu.computeOverlaySnapTolerance(r),Pu.computeOverlaySnapTolerance(e))}},Pu.computeSizeBasedSnapTolerance=function(A){var t=A.getEnvelopeInternal();return Math.min(t.getHeight(),t.getWidth())*Pu.SNAP_PRECISION_FACTOR},Pu.snapToSelf=function(A,t,n){return new Pu(A).snapToSelf(t,n)},gu.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Pu,gu);var Cu=function(A){function t(t,n,i){A.call(this),this.ws=t||null,this.Is=n||null,this.Ms=void 0!==i&&i}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.snapLine=function(A,t){var n=new wu(A,this.ws);return n.setAllowSnappingToSourceVertices(this.Ms),n.snapTo(t)},t.prototype.transformCoordinates=function(A,t){var n=A.toCoordinateArray(),i=this.snapLine(n,this.Is);return this.vn.getCoordinateSequenceFactory().create(i)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(lu),Du=function(){this.bs=!0,this.zs=53,this.ds=0,this.xs=null};Du.prototype.getCommon=function(){return In.longBitsToDouble(this.ds)},Du.prototype.add=function(A){var t=In.doubleToLongBits(A);return this.bs?(this.ds=t,this.xs=Du.signExpBits(this.ds),this.bs=!1,null):Du.signExpBits(t)!==this.xs?(this.ds=0,null):(this.zs=Du.numCommonMostSigMantissaBits(this.ds,t),void(this.ds=Du.zeroLowerBits(this.ds,64-(12+this.zs))))},Du.prototype.toString=function(){if(1===arguments.length){var A=arguments[0],t=In.longBitsToDouble(A),n=In.toBinaryString(A),i="0000000000000000000000000000000000000000000000000000000000000000"+n,r=i.substring(i.length-64),e=r.substring(0,1)+"  "+r.substring(1,12)+"(exp) "+r.substring(12)+" [ "+t+" ]";return e}},Du.prototype.interfaces_=function(){return[]},Du.prototype.getClass=function(){return Du},Du.getBit=function(A,t){return 0!=(A&1<<t)?1:0},Du.signExpBits=function(A){return A>>52},Du.zeroLowerBits=function(A,t){return A&~((1<<t)-1)},Du.numCommonMostSigMantissaBits=function(A,t){for(var n=0,i=52;i>=0;i--){if(Du.getBit(A,i)!==Du.getBit(t,i))return n;n++}return 52};var Iu=function(){this.ms=null,this.ys=new bu},Mu={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};Iu.prototype.addCommonBits=function(A){var t=new zu(this.ms);A.apply(t),A.geometryChanged()},Iu.prototype.removeCommonBits=function(A){if(0===this.ms.x&&0===this.ms.y)return A;var t=new mn(this.ms);t.x=-t.x,t.y=-t.y;var n=new zu(t);return A.apply(n),A.geometryChanged(),A},Iu.prototype.getCommonCoordinate=function(){return this.ms},Iu.prototype.add=function(A){A.apply(this.ys),this.ms=this.ys.getCommonCoordinate()},Iu.prototype.interfaces_=function(){return[]},Iu.prototype.getClass=function(){return Iu},Mu.CommonCoordinateFilter.get=function(){return bu},Mu.Translater.get=function(){return zu},Object.defineProperties(Iu,Mu);var bu=function(){this.ps=new Du,this.Ls=new Du};bu.prototype.filter=function(A){this.ps.add(A.x),this.Ls.add(A.y)},bu.prototype.getCommonCoordinate=function(){return new mn(this.ps.getCommon(),this.Ls.getCommon())},bu.prototype.interfaces_=function(){return[wi]},bu.prototype.getClass=function(){return bu};var zu=function(){this.trans=null;var A=arguments[0];this.trans=A};zu.prototype.filter=function(A,t){var n=A.getOrdinate(t,0)+this.trans.x,i=A.getOrdinate(t,1)+this.trans.y;A.setOrdinate(t,0,n),A.setOrdinate(t,1,i)},zu.prototype.isDone=function(){return!1},zu.prototype.isGeometryChanged=function(){return!0},zu.prototype.interfaces_=function(){return[Ar]},zu.prototype.getClass=function(){return zu};var du=function(A,t){this.Pn=new Array(2).fill(null),this.ws=null,this.Ts=null,this.Pn[0]=A,this.Pn[1]=t,this.computeSnapTolerance()};du.prototype.selfSnap=function(A){return new Pu(A).snapTo(A,this.ws)},du.prototype.removeCommonBits=function(A){this.Ts=new Iu,this.Ts.add(A[0]),this.Ts.add(A[1]);var t=new Array(2).fill(null);return t[0]=this.Ts.removeCommonBits(A[0].copy()),t[1]=this.Ts.removeCommonBits(A[1].copy()),t},du.prototype.prepareResult=function(A){return this.Ts.addCommonBits(A),A},du.prototype.getResultGeometry=function(A){var t=this.snap(this.Pn),n=Wu.overlayOp(t[0],t[1],A);return this.prepareResult(n)},du.prototype.checkValid=function(A){A.isValid()||Wn.out.println("Snapped geometry is invalid")},du.prototype.computeSnapTolerance=function(){this.ws=Pu.computeOverlaySnapTolerance(this.Pn[0],this.Pn[1])},du.prototype.snap=function(A){var t=this.removeCommonBits(A);return Pu.snap(t[0],t[1],this.ws)},du.prototype.interfaces_=function(){return[]},du.prototype.getClass=function(){return du},du.overlayOp=function(A,t,n){return new du(A,t).getResultGeometry(n)},du.union=function(A,t){return du.overlayOp(A,t,Wu.UNION)},du.intersection=function(A,t){return du.overlayOp(A,t,Wu.INTERSECTION)},du.symDifference=function(A,t){return du.overlayOp(A,t,Wu.SYMDIFFERENCE)},du.difference=function(A,t){return du.overlayOp(A,t,Wu.DIFFERENCE)};var xu=function(A,t){this.Pn=new Array(2).fill(null),this.Pn[0]=A,this.Pn[1]=t};xu.prototype.getResultGeometry=function(A){var t=null,n=!1,i=null;try{t=Wu.overlayOp(this.Pn[0],this.Pn[1],A),n=!0}catch(A){if(!(A instanceof ti))throw A;i=A}if(!n)try{t=du.overlayOp(this.Pn[0],this.Pn[1],A)}catch(A){throw A instanceof ti?i:A}return t},xu.prototype.interfaces_=function(){return[]},xu.prototype.getClass=function(){return xu},xu.overlayOp=function(A,t,n){return new xu(A,t).getResultGeometry(n)},xu.union=function(A,t){return xu.overlayOp(A,t,Wu.UNION)},xu.intersection=function(A,t){return xu.overlayOp(A,t,Wu.INTERSECTION)},xu.symDifference=function(A,t){return xu.overlayOp(A,t,Wu.SYMDIFFERENCE)},xu.difference=function(A,t){return xu.overlayOp(A,t,Wu.DIFFERENCE)};var mu=function(){this.mce=null,this.chainIndex=null;var A=arguments[0],t=arguments[1];this.mce=A,this.chainIndex=t};mu.prototype.computeIntersections=function(A,t){this.mce.computeIntersectsForChain(this.chainIndex,A.mce,A.chainIndex,t)},mu.prototype.interfaces_=function(){return[]},mu.prototype.getClass=function(){return mu};var yu=function A(){if(this.Sn=null,this.Os=null,this.Fs=null,this.Us=null,this.Es=null,this.Ns=null,2===arguments.length){var t=arguments[0],n=arguments[1];this.Fs=A.DELETE,this.Os=t,this.Us=n}else if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2];this.Fs=A.INSERT,this.Sn=i,this.Os=r,this.Ns=e}},pu={INSERT:{configurable:!0},DELETE:{configurable:!0}};yu.prototype.isDelete=function(){return this.Fs===yu.DELETE},yu.prototype.setDeleteEventIndex=function(A){this.Es=A},yu.prototype.getObject=function(){return this.Ns},yu.prototype.compareTo=function(A){return this.Os<A.Os?-1:this.Os>A.Os?1:this.Fs<A.Fs?-1:this.Fs>A.Fs?1:0},yu.prototype.getInsertEvent=function(){return this.Us},yu.prototype.isInsert=function(){return this.Fs===yu.INSERT},yu.prototype.isSameLabel=function(A){return null!==this.Sn&&this.Sn===A.Sn},yu.prototype.getDeleteEventIndex=function(){return this.Es},yu.prototype.interfaces_=function(){return[bn]},yu.prototype.getClass=function(){return yu},pu.INSERT.get=function(){return 1},pu.DELETE.get=function(){return 2},Object.defineProperties(yu,pu);var Lu=function(){};Lu.prototype.interfaces_=function(){return[]},Lu.prototype.getClass=function(){return Lu};var Tu=function(){this.jr=!1,this.Qr=!1,this.Sr=!1,this.Br=null,this.er=null,this.js=null,this.Qs=null,this.Rr=null,this.Ss=0,this.numTests=0,this.ks=null,this.Bs=!1,this.Rs=!1;var A=arguments[0],t=arguments[1],n=arguments[2];this.er=A,this.js=t,this.Qs=n};Tu.prototype.isTrivialIntersection=function(A,t,n,i){if(A===n&&1===this.er.getIntersectionNum()){if(Tu.isAdjacentSegments(t,i))return!0;if(A.isClosed()){var r=A.getNumPoints()-1;if(0===t&&i===r||0===i&&t===r)return!0}}return!1},Tu.prototype.getProperIntersectionPoint=function(){return this.Br},Tu.prototype.setIsDoneIfProperInt=function(A){this.Rs=A},Tu.prototype.hasProperInteriorIntersection=function(){return this.Sr},Tu.prototype.isBoundaryPointInternal=function(A,t){for(var n=t.iterator();n.hasNext();){var i=n.next().getCoordinate();if(A.isIntersection(i))return!0}return!1},Tu.prototype.hasProperIntersection=function(){return this.Qr},Tu.prototype.hasIntersection=function(){return this.jr},Tu.prototype.isDone=function(){return this.Bs},Tu.prototype.isBoundaryPoint=function(A,t){return!(null===t||!this.isBoundaryPointInternal(A,t[0])&&!this.isBoundaryPointInternal(A,t[1]))},Tu.prototype.setBoundaryNodes=function(A,t){this.ks=new Array(2).fill(null),this.ks[0]=A,this.ks[1]=t},Tu.prototype.addIntersections=function(A,t,n,i){if(A===n&&t===i)return null;this.numTests++;var r=A.getCoordinates()[t],e=A.getCoordinates()[t+1],s=n.getCoordinates()[i],u=n.getCoordinates()[i+1];this.er.computeIntersection(r,e,s,u),this.er.hasIntersection()&&(this.Qs&&(A.setIsolated(!1),n.setIsolated(!1)),this.Ss++,this.isTrivialIntersection(A,t,n,i)||(this.jr=!0,!this.js&&this.er.isProper()||(A.addIntersections(this.er,t,0),n.addIntersections(this.er,i,1)),this.er.isProper()&&(this.Br=this.er.getIntersection(0).copy(),this.Qr=!0,this.Rs&&(this.Bs=!0),this.isBoundaryPoint(this.er,this.ks)||(this.Sr=!0))))},Tu.prototype.interfaces_=function(){return[]},Tu.prototype.getClass=function(){return Tu},Tu.isAdjacentSegments=function(A,t){return 1===Math.abs(A-t)};var Ou=function(A){function t(){A.call(this),this.events=new yi,this.nOverlaps=null}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.prepareEvents=function(){Ie.sort(this.events);for(var A=0;A<this.events.size();A++){var t=this.events.get(A);t.isDelete()&&t.getInsertEvent().setDeleteEventIndex(A)}},t.prototype.computeIntersections=function(){var A=this;if(1===arguments.length){var t=arguments[0];this.nOverlaps=0,this.prepareEvents();for(var n=0;n<this.events.size();n++){var i=A.events.get(n);if(i.isInsert()&&A.processOverlaps(n,i.getDeleteEventIndex(),i,t),t.isDone())break}}else if(3===arguments.length)if(arguments[2]instanceof Tu&&Fn(arguments[0],xi)&&Fn(arguments[1],xi)){var r=arguments[0],e=arguments[1],s=arguments[2];this.addEdges(r,r),this.addEdges(e,e),this.computeIntersections(s)}else if("boolean"==typeof arguments[2]&&Fn(arguments[0],xi)&&arguments[1]instanceof Tu){var u=arguments[0],o=arguments[1],h=arguments[2];h?this.addEdges(u,null):this.addEdges(u),this.computeIntersections(o)}},t.prototype.addEdge=function(A,t){for(var n=A.getMonotoneChainEdge(),i=n.getStartIndexes(),r=0;r<i.length-1;r++){var e=new mu(n,r),s=new yu(t,n.getMinX(r),e);this.events.add(s),this.events.add(new yu(n.getMaxX(r),s))}},t.prototype.processOverlaps=function(A,t,n,i){for(var r=n.getObject(),e=A;e<t;e++){var s=this.events.get(e);if(s.isInsert()){var u=s.getObject();n.isSameLabel(s)||(r.computeIntersections(u,i),this.nOverlaps++)}}},t.prototype.addEdges=function(){var A=this;if(1===arguments.length)for(var t=arguments[0],n=t.iterator();n.hasNext();){var i=n.next();A.addEdge(i,i)}else if(2===arguments.length)for(var r=arguments[0],e=arguments[1],s=r.iterator();s.hasNext();){var u=s.next();A.addEdge(u,e)}},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Lu),Fu=function(){this.Gs=In.POSITIVE_INFINITY,this.mr=In.NEGATIVE_INFINITY},Uu={NodeComparator:{configurable:!0}};Fu.prototype.getMin=function(){return this.Gs},Fu.prototype.intersects=function(A,t){return!(this.Gs>t||this.mr<A)},Fu.prototype.getMax=function(){return this.mr},Fu.prototype.toString=function(){return Ai.toLineString(new mn(this.Gs,0),new mn(this.mr,0))},Fu.prototype.interfaces_=function(){return[]},Fu.prototype.getClass=function(){return Fu},Uu.NodeComparator.get=function(){return Eu},Object.defineProperties(Fu,Uu);var Eu=function(){};Eu.prototype.compare=function(A,t){var r=(A.Gs+A.mr)/2,e=(t.Gs+t.mr)/2;return r<e?-1:r>e?1:0},Eu.prototype.interfaces_=function(){return[dn]},Eu.prototype.getClass=function(){return Eu};var Nu=function(A){function t(){A.call(this),this.fi=null;var t=arguments[0],n=arguments[1],i=arguments[2];this.Gs=t,this.mr=n,this.fi=i}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.query=function(A,t,n){if(!this.intersects(A,t))return null;n.visitItem(this.fi)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Fu),ju=function(A){function t(){A.call(this),this.Ys=null,this.qs=null;var t=arguments[0],n=arguments[1];this.Ys=t,this.qs=n,this.buildExtent(this.Ys,this.qs)}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.buildExtent=function(A,t){this.Gs=Math.min(A.Gs,t.Gs),this.mr=Math.max(A.mr,t.mr)},t.prototype.query=function(A,t,n){if(!this.intersects(A,t))return null;null!==this.Ys&&this.Ys.query(A,t,n),null!==this.qs&&this.qs.query(A,t,n)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(Fu),Qu=function(){this.Vs=new yi,this.Di=null,this.li=0};Qu.prototype.buildTree=function(){Ie.sort(this.Vs,new Fu.NodeComparator);for(var A=this.Vs,t=null,n=new yi;;){if(this.buildLevel(A,n),1===n.size())return n.get(0);t=A,A=n,n=t}},Qu.prototype.insert=function(A,t,n){if(null!==this.Di)throw new Error("Index cannot be added to once it has been queried");this.Vs.add(new Nu(A,t,n))},Qu.prototype.query=function(A,t,n){this.init(),this.Di.query(A,t,n)},Qu.prototype.buildRoot=function(){if(null!==this.Di)return null;this.Di=this.buildTree()},Qu.prototype.printNode=function(A){Wn.out.println(Ai.toLineString(new mn(A.Gs,this.li),new mn(A.mr,this.li)))},Qu.prototype.init=function(){if(null!==this.Di)return null;this.buildRoot()},Qu.prototype.buildLevel=function(A,t){this.li++,t.clear();for(var n=0;n<A.size();n+=2){var i=A.get(n);if(null===(n+1<A.size()?A.get(n):null))t.add(i);else{var r=new ju(A.get(n),A.get(n+1));t.add(r)}}},Qu.prototype.interfaces_=function(){return[]},Qu.prototype.getClass=function(){return Qu};var Su=function(){this.ai=new yi};Su.prototype.visitItem=function(A){this.ai.add(A)},Su.prototype.getItems=function(){return this.ai},Su.prototype.interfaces_=function(){return[Pe]},Su.prototype.getClass=function(){return Su};var ku=function(){this.Qi=null;var A=arguments[0];if(!Fn(A,gr))throw new Dn("Argument must be Polygonal");this.Qi=new Gu(A)},Bu={SegmentVisitor:{configurable:!0},IntervalIndexedGeometry:{configurable:!0}};ku.prototype.locate=function(A){var t=new oi(A),n=new Ru(t);return this.Qi.query(A.y,A.y,n),t.getLocation()},ku.prototype.interfaces_=function(){return[ss]},ku.prototype.getClass=function(){return ku},Bu.SegmentVisitor.get=function(){return Ru},Bu.IntervalIndexedGeometry.get=function(){return Gu},Object.defineProperties(ku,Bu);var Ru=function(){this.Ws=null;var A=arguments[0];this.Ws=A};Ru.prototype.visitItem=function(A){var t=A;this.Ws.countSegment(t.getCoordinate(0),t.getCoordinate(1))},Ru.prototype.interfaces_=function(){return[Pe]},Ru.prototype.getClass=function(){return Ru};var Gu=function(){this.Qi=new Qu;var A=arguments[0];this.init(A)};Gu.prototype.init=function(A){for(var t=qs.getLines(A).iterator();t.hasNext();){var n=t.next().getCoordinates();this.addLine(n)}},Gu.prototype.addLine=function(A){for(var t=1;t<A.length;t++){var n=new Ne(A[t-1],A[t]),i=Math.min(n.p0.y,n.p1.y),r=Math.max(n.p0.y,n.p1.y);this.Qi.insert(i,r,n)}},Gu.prototype.query=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1],n=new Su;return this.Qi.query(A,t,n),n.getItems()}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2];this.Qi.query(i,r,e)}},Gu.prototype.interfaces_=function(){return[]},Gu.prototype.getClass=function(){return Gu};var Yu=function(A){function t(){if(A.call(this),this._s=null,this.Ks=new Or,this.Hs=null,this.Js=!0,this.Zs=null,this.Xs=null,this.$s=!1,this.Au=null,this.tu=null,this.Oe=new Vs,2===arguments.length){var t=arguments[0],n=arguments[1],i=Pi.OGC_SFS_BOUNDARY_RULE;this.Zs=t,this._s=n,this.Hs=i,null!==n&&this.add(n)}else if(3===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2];this.Zs=r,this._s=e,this.Hs=s,null!==e&&this.add(e)}}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.insertBoundaryPoint=function(A,n){var i=this.On.addNode(n).getLabel(),r=1;i.getLocation(A,qr.ON)===Tn.BOUNDARY&&r++;var e=t.determineBoundary(this.Hs,r);i.setLocation(A,e)},t.prototype.computeSelfNodes=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1];return this.computeSelfNodes(A,t,!1)}if(3===arguments.length){var n=arguments[0],i=arguments[1],r=arguments[2],e=new Tu(n,!0,!1);e.setIsDoneIfProperInt(r);var s=this.createEdgeSetIntersector(),u=this._s instanceof Ir||this._s instanceof Cr||this._s instanceof Mr,o=i||!u;return s.computeIntersections(this.jn,e,o),this.addSelfIntersectionNodes(this.Zs),e}},t.prototype.computeSplitEdges=function(A){for(var t=this.jn.iterator();t.hasNext();)t.next().eiList.addSplitEdges(A)},t.prototype.computeEdgeIntersections=function(A,t,n){var i=new Tu(t,n,!0);return i.setBoundaryNodes(this.getBoundaryNodes(),A.getBoundaryNodes()),this.createEdgeSetIntersector().computeIntersections(this.jn,A.jn,i),i},t.prototype.getGeometry=function(){return this._s},t.prototype.getBoundaryNodeRule=function(){return this.Hs},t.prototype.hasTooFewPoints=function(){return this.$s},t.prototype.addPoint=function(){if(arguments[0]instanceof Pr){var A=arguments[0],t=A.getCoordinate();this.insertPoint(this.Zs,t,Tn.INTERIOR)}else if(arguments[0]instanceof mn){var n=arguments[0];this.insertPoint(this.Zs,n,Tn.INTERIOR)}},t.prototype.addPolygon=function(A){this.addPolygonRing(A.getExteriorRing(),Tn.EXTERIOR,Tn.INTERIOR);for(var t=0;t<A.getNumInteriorRing();t++){var n=A.getInteriorRingN(t);this.addPolygonRing(n,Tn.INTERIOR,Tn.EXTERIOR)}},t.prototype.addEdge=function(A){this.insertEdge(A);var t=A.getCoordinates();this.insertPoint(this.Zs,t[0],Tn.BOUNDARY),this.insertPoint(this.Zs,t[t.length-1],Tn.BOUNDARY)},t.prototype.addLineString=function(A){var t=Ti.removeRepeatedPoints(A.getCoordinates());if(t.length<2)return this.$s=!0,this.Au=t[0],null;var n=new bs(t,new $r(this.Zs,Tn.INTERIOR));this.Ks.put(A,n),this.insertEdge(n),ii.isTrue(t.length>=2,"found LineString with single point"),this.insertBoundaryPoint(this.Zs,t[0]),this.insertBoundaryPoint(this.Zs,t[t.length-1])},t.prototype.getInvalidPoint=function(){return this.Au},t.prototype.getBoundaryPoints=function(){for(var A=this.getBoundaryNodes(),t=new Array(A.size()).fill(null),n=0,i=A.iterator();i.hasNext();){var r=i.next();t[n++]=r.getCoordinate().copy()}return t},t.prototype.getBoundaryNodes=function(){return null===this.Xs&&(this.Xs=this.On.getBoundaryNodes(this.Zs)),this.Xs},t.prototype.addSelfIntersectionNode=function(A,t,n){if(this.isBoundaryNode(A,t))return null;n===Tn.BOUNDARY&&this.Js?this.insertBoundaryPoint(A,t):this.insertPoint(A,t,n)},t.prototype.addPolygonRing=function(A,t,n){if(A.isEmpty())return null;var i=Ti.removeRepeatedPoints(A.getCoordinates());if(i.length<4)return this.$s=!0,this.Au=i[0],null;var r=t,e=n;hi.isCCW(i)&&(r=n,e=t);var s=new bs(i,new $r(this.Zs,Tn.BOUNDARY,r,e));this.Ks.put(A,s),this.insertEdge(s),this.insertPoint(this.Zs,i[0],Tn.BOUNDARY)},t.prototype.insertPoint=function(A,t,n){var i=this.On.addNode(t),r=i.getLabel();null===r?i.Sn=new $r(A,n):r.setLocation(A,n)},t.prototype.createEdgeSetIntersector=function(){return new Ou},t.prototype.addSelfIntersectionNodes=function(A){for(var t=this.jn.iterator();t.hasNext();)for(var n=t.next(),i=n.getLabel().getLocation(A),r=n.eiList.iterator();r.hasNext();){var e=r.next();this.addSelfIntersectionNode(A,e.coord,i)}},t.prototype.add=function(){if(1!==arguments.length)return A.prototype.add.apply(this,arguments);var t=arguments[0];if(t.isEmpty())return null;if(t instanceof Mr&&(this.Js=!1),t instanceof Cr)this.addPolygon(t);else if(t instanceof lr)this.addLineString(t);else if(t instanceof Pr)this.addPoint(t);else if(t instanceof Dr)this.addCollection(t);else if(t instanceof nr)this.addCollection(t);else if(t instanceof Mr)this.addCollection(t);else{if(!(t instanceof tr))throw new Error(t.getClass().getName());this.addCollection(t)}},t.prototype.addCollection=function(A){for(var t=0;t<A.getNumGeometries();t++){var n=A.getGeometryN(t);this.add(n)}},t.prototype.locate=function(A){return Fn(this._s,gr)&&this._s.getNumGeometries()>50?(null===this.tu&&(this.tu=new ku(this._s)),this.tu.locate(A)):this.Oe.locate(A,this._s)},t.prototype.findEdge=function(){if(1===arguments.length){var t=arguments[0];return this.Ks.get(t)}return A.prototype.findEdge.apply(this,arguments)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t.determineBoundary=function(A,t){return A.isInBoundary(t)?Tn.BOUNDARY:Tn.INTERIOR},t}(ce),qu=function(){if(this.er=new si,this.nu=null,this.iu=null,1===arguments.length){var A=arguments[0];this.setComputationPrecision(A.getPrecisionModel()),this.iu=new Array(1).fill(null),this.iu[0]=new Yu(0,A)}else if(2===arguments.length){var t=arguments[0],n=arguments[1],i=Pi.OGC_SFS_BOUNDARY_RULE;t.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(t.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this.iu=new Array(2).fill(null),this.iu[0]=new Yu(0,t,i),this.iu[1]=new Yu(1,n,i)}else if(3===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2];r.getPrecisionModel().compareTo(e.getPrecisionModel())>=0?this.setComputationPrecision(r.getPrecisionModel()):this.setComputationPrecision(e.getPrecisionModel()),this.iu=new Array(2).fill(null),this.iu[0]=new Yu(0,r,s),this.iu[1]=new Yu(1,e,s)}};qu.prototype.getArgGeometry=function(A){return this.iu[A].getGeometry()},qu.prototype.setComputationPrecision=function(A){this.nu=A,this.er.setPrecisionModel(this.nu)},qu.prototype.interfaces_=function(){return[]},qu.prototype.getClass=function(){return qu};var Vu=function(){};Vu.prototype.interfaces_=function(){return[]},Vu.prototype.getClass=function(){return Vu},Vu.map=function(){if(arguments[0]instanceof ai&&Fn(arguments[1],Vu.MapOp)){for(var A=arguments[0],t=arguments[1],n=new yi,i=0;i<A.getNumGeometries();i++){var r=t.map(A.getGeometryN(i));null!==r&&n.add(r)}return A.getFactory().buildGeometry(n)}if(Fn(arguments[0],bi)&&Fn(arguments[1],Vu.MapOp)){for(var e=arguments[0],s=arguments[1],u=new yi,o=e.iterator();o.hasNext();){var h=o.next(),f=s.map(h);null!==f&&u.add(f)}return u}},Vu.MapOp=function(){};var Wu=function(A){function t(){var t=arguments[0],n=arguments[1];A.call(this,t,n),this.Oe=new Vs,this.gn=null,this.ru=null,this._r=null,this.Lr=new vs,this.eu=new yi,this.hs=new yi,this.fs=new yi,this._r=new ce(new cs),this.gn=t.getFactory()}return A&&(t.__proto__=A),(t.prototype=Object.create(A&&A.prototype)).constructor=t,t.prototype.insertUniqueEdge=function(A){var t=this.Lr.findEqualEdge(A);if(null!==t){var n=t.getLabel(),i=A.getLabel();t.isPointwiseEqual(A)||(i=new $r(A.getLabel())).flip();var r=t.getDepth();r.isNull()&&r.add(n),r.add(i),n.merge(i)}else this.Lr.add(A)},t.prototype.getGraph=function(){return this._r},t.prototype.cancelDuplicateResultEdges=function(){for(var A=this._r.getEdgeEnds().iterator();A.hasNext();){var t=A.next(),n=t.getSym();t.isInResult()&&n.isInResult()&&(t.setInResult(!1),n.setInResult(!1))}},t.prototype.isCoveredByLA=function(A){return!!this.isCovered(A,this.hs)||!!this.isCovered(A,this.eu)},t.prototype.computeGeometry=function(A,n,i,r){var e=new yi;return e.addAll(A),e.addAll(n),e.addAll(i),e.isEmpty()?t.createEmptyResult(r,this.iu[0].getGeometry(),this.iu[1].getGeometry(),this.gn):this.gn.buildGeometry(e)},t.prototype.mergeSymLabels=function(){for(var A=this._r.getNodes().iterator();A.hasNext();)A.next().getEdges().mergeSymLabels()},t.prototype.isCovered=function(A,t){for(var n=t.iterator();n.hasNext();){var i=n.next();if(this.Oe.locate(A,i)!==Tn.EXTERIOR)return!0}return!1},t.prototype.replaceCollapsedEdges=function(){for(var A=new yi,t=this.Lr.iterator();t.hasNext();){var n=t.next();n.isCollapsed()&&(t.remove(),A.add(n.getCollapsedEdge()))}this.Lr.addAll(A)},t.prototype.updateNodeLabelling=function(){for(var A=this._r.getNodes().iterator();A.hasNext();){var t=A.next(),n=t.getEdges().getLabel();t.getLabel().merge(n)}},t.prototype.getResultGeometry=function(A){return this.computeOverlay(A),this.ru},t.prototype.insertUniqueEdges=function(A){for(var t=A.iterator();t.hasNext();){var n=t.next();this.insertUniqueEdge(n)}},t.prototype.computeOverlay=function(A){this.copyPoints(0),this.copyPoints(1),this.iu[0].computeSelfNodes(this.er,!1),this.iu[1].computeSelfNodes(this.er,!1),this.iu[0].computeEdgeIntersections(this.iu[1],this.er,!0);var t=new yi;this.iu[0].computeSplitEdges(t),this.iu[1].computeSplitEdges(t),this.insertUniqueEdges(t),this.computeLabelsFromDepths(),this.replaceCollapsedEdges(),fu.checkValid(this.Lr.getEdges()),this._r.addEdges(this.Lr.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(A),this.cancelDuplicateResultEdges();var n=new ae(this.gn);n.add(this._r),this.eu=n.getPolygons();var i=new au(this,this.gn,this.Oe);this.hs=i.build(A);var r=new vu(this,this.gn,this.Oe);this.fs=r.build(A),this.ru=this.computeGeometry(this.fs,this.hs,this.eu,A)},t.prototype.labelIncompleteNode=function(A,t){var n=this.Oe.locate(A.getCoordinate(),this.iu[t].getGeometry());A.getLabel().setLocation(t,n)},t.prototype.copyPoints=function(A){for(var t=this.iu[A].getNodeIterator();t.hasNext();){var n=t.next();this._r.addNode(n.getCoordinate()).setLabel(A,n.getLabel().getLocation(A))}},t.prototype.findResultAreaEdges=function(A){for(var n=this._r.getEdgeEnds().iterator();n.hasNext();){var i=n.next(),r=i.getLabel();r.isArea()&&!i.isInteriorAreaEdge()&&t.isResultOfOp(r.getLocation(0,qr.RIGHT),r.getLocation(1,qr.RIGHT),A)&&i.setInResult(!0)}},t.prototype.computeLabelsFromDepths=function(){for(var A=this.Lr.iterator();A.hasNext();){var t=A.next(),n=t.getLabel(),i=t.getDepth();if(!i.isNull()){i.normalize();for(var r=0;r<2;r++)n.isNull(r)||!n.isArea()||i.isNull(r)||(0===i.getDelta(r)?n.toLine(r):(ii.isTrue(!i.isNull(r,qr.LEFT),"depth of LEFT side has not been initialized"),n.setLocation(r,qr.LEFT,i.getLocation(r,qr.LEFT)),ii.isTrue(!i.isNull(r,qr.RIGHT),"depth of RIGHT side has not been initialized"),n.setLocation(r,qr.RIGHT,i.getLocation(r,qr.RIGHT))))}}},t.prototype.computeLabelling=function(){for(var A=this._r.getNodes().iterator();A.hasNext();)A.next().getEdges().computeLabelling(this.iu);this.mergeSymLabels(),this.updateNodeLabelling()},t.prototype.labelIncompleteNodes=function(){for(var A=this._r.getNodes().iterator();A.hasNext();){var t=A.next(),n=t.getLabel();t.isIsolated()&&(n.isNull(0)?this.labelIncompleteNode(t,0):this.labelIncompleteNode(t,1)),t.getEdges().updateLabelling(n)}},t.prototype.isCoveredByA=function(A){return!!this.isCovered(A,this.eu)},t.prototype.interfaces_=function(){return[]},t.prototype.getClass=function(){return t},t}(qu);Wu.overlayOp=function(A,t,n){return new Wu(A,t).getResultGeometry(n)},Wu.intersection=function(A,t){if(A.isEmpty()||t.isEmpty())return Wu.createEmptyResult(Wu.INTERSECTION,A,t,A.getFactory());if(A.isGeometryCollection()){var n=t;return cu.map(A,{interfaces_:function(){return[Vu.MapOp]},map:function(A){return A.intersection(n)}})}return A.checkNotGeometryCollection(A),A.checkNotGeometryCollection(t),xu.overlayOp(A,t,Wu.INTERSECTION)},Wu.symDifference=function(A,t){if(A.isEmpty()||t.isEmpty()){if(A.isEmpty()&&t.isEmpty())return Wu.createEmptyResult(Wu.SYMDIFFERENCE,A,t,A.getFactory());if(A.isEmpty())return t.copy();if(t.isEmpty())return A.copy()}return A.checkNotGeometryCollection(A),A.checkNotGeometryCollection(t),xu.overlayOp(A,t,Wu.SYMDIFFERENCE)},Wu.resultDimension=function(A,t,n){var i=t.getDimension(),r=n.getDimension(),e=-1;switch(A){case Wu.INTERSECTION:e=Math.min(i,r);break;case Wu.UNION:e=Math.max(i,r);break;case Wu.DIFFERENCE:e=i;break;case Wu.SYMDIFFERENCE:e=Math.max(i,r)}return e},Wu.createEmptyResult=function(A,t,n,i){var r=null;switch(Wu.resultDimension(A,t,n)){case-1:r=i.createGeometryCollection(new Array(0).fill(null));break;case 0:r=i.createPoint();break;case 1:r=i.createLineString();break;case 2:r=i.createPolygon()}return r},Wu.difference=function(A,t){return A.isEmpty()?Wu.createEmptyResult(Wu.DIFFERENCE,A,t,A.getFactory()):t.isEmpty()?A.copy():(A.checkNotGeometryCollection(A),A.checkNotGeometryCollection(t),xu.overlayOp(A,t,Wu.DIFFERENCE))},Wu.isResultOfOp=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1],n=A.getLocation(0),i=A.getLocation(1);return Wu.isResultOfOp(n,i,t)}if(3===arguments.length){var r=arguments[0],e=arguments[1],s=arguments[2];switch(r===Tn.BOUNDARY&&(r=Tn.INTERIOR),e===Tn.BOUNDARY&&(e=Tn.INTERIOR),s){case Wu.INTERSECTION:return r===Tn.INTERIOR&&e===Tn.INTERIOR;case Wu.UNION:return r===Tn.INTERIOR||e===Tn.INTERIOR;case Wu.DIFFERENCE:return r===Tn.INTERIOR&&e!==Tn.INTERIOR;case Wu.SYMDIFFERENCE:return r===Tn.INTERIOR&&e!==Tn.INTERIOR||r!==Tn.INTERIOR&&e===Tn.INTERIOR}return!1}},Wu.INTERSECTION=1,Wu.UNION=2,Wu.DIFFERENCE=3,Wu.SYMDIFFERENCE=4;var _u=function(){this.su=null,this.uu=null,this.ou=null,this.Oe=new Vs,this.gr=new Ne;var A=arguments[0],t=arguments[1];this.su=A,this.uu=t,this.ou=this.extractLinework(A)};_u.prototype.isWithinToleranceOfBoundary=function(A){for(var t=0;t<this.ou.getNumGeometries();t++)for(var n=this.ou.getGeometryN(t).getCoordinateSequence(),i=0;i<n.size()-1;i++)if(n.getCoordinate(i,this.gr.p0),n.getCoordinate(i+1,this.gr.p1),this.gr.distance(A)<=this.uu)return!0;return!1},_u.prototype.getLocation=function(A){return this.isWithinToleranceOfBoundary(A)?Tn.BOUNDARY:this.Oe.locate(A,this.su)},_u.prototype.extractLinework=function(A){var t=new Ku;A.apply(t);var n=t.getLinework(),i=jr.toLineStringArray(n);return A.getFactory().createMultiLineString(i)},_u.prototype.interfaces_=function(){return[]},_u.prototype.getClass=function(){return _u};var Ku=function(){this.ou=null,this.ou=new yi};Ku.prototype.getLinework=function(){return this.ou},Ku.prototype.filter=function(A){if(A instanceof Cr){var t=A;this.ou.add(t.getExteriorRing());for(var n=0;n<t.getNumInteriorRing();n++)this.ou.add(t.getInteriorRingN(n))}},Ku.prototype.interfaces_=function(){return[$i]},Ku.prototype.getClass=function(){return Ku};var Hu=function(){this.su=null,this.hu=!0,this.fu=!0;var A=arguments[0];this.su=A};Hu.prototype.extractPoints=function(A,t,n){for(var i=A.getCoordinates(),r=0;r<i.length-1;r++)this.computeOffsetPoints(i[r],i[r+1],t,n)},Hu.prototype.setSidesToGenerate=function(A,t){this.hu=A,this.fu=t},Hu.prototype.getPoints=function(A){for(var t=new yi,n=qs.getLines(this.su).iterator();n.hasNext();){var i=n.next();this.extractPoints(i,A,t)}return t},Hu.prototype.computeOffsetPoints=function(A,t,n,i){var r=t.x-A.x,e=t.y-A.y,s=Math.sqrt(r*r+e*e),u=n*r/s,o=n*e/s,h=(t.x+A.x)/2,f=(t.y+A.y)/2;if(this.hu){var c=new mn(h-o,f+u);i.add(c)}if(this.fu){var a=new mn(h+o,f-u);i.add(a)}},Hu.prototype.interfaces_=function(){return[]},Hu.prototype.getClass=function(){return Hu};var Ju=function A(){this.Pn=null,this.cu=null,this.au=new Array(3).fill(null),this.vu=null,this.uu=A.TOLERANCE,this.lu=new yi;var t=arguments[0],n=arguments[1],i=arguments[2];this.uu=A.computeBoundaryDistanceTolerance(t,n),this.Pn=[t,n,i],this.cu=[new _u(this.Pn[0],this.uu),new _u(this.Pn[1],this.uu),new _u(this.Pn[2],this.uu)]},Zu={TOLERANCE:{configurable:!0}};Ju.prototype.reportResult=function(A,t,n){Wn.out.println("Overlay result invalid - A:"+Tn.toLocationSymbol(t[0])+" B:"+Tn.toLocationSymbol(t[1])+" expected:"+(n?"i":"e")+" actual:"+Tn.toLocationSymbol(t[2]))},Ju.prototype.isValid=function(A){return this.addTestPts(this.Pn[0]),this.addTestPts(this.Pn[1]),this.checkValid(A)},Ju.prototype.checkValid=function(){var A=this;if(1===arguments.length){for(var t=arguments[0],n=0;n<this.lu.size();n++){var i=A.lu.get(n);if(!A.checkValid(t,i))return A.vu=i,!1}return!0}if(2===arguments.length){var r=arguments[0],e=arguments[1];return this.au[0]=this.cu[0].getLocation(e),this.au[1]=this.cu[1].getLocation(e),this.au[2]=this.cu[2].getLocation(e),!!Ju.hasLocation(this.au,Tn.BOUNDARY)||this.isValidResult(r,this.au)}},Ju.prototype.addTestPts=function(A){var t=new Hu(A);this.lu.addAll(t.getPoints(5*this.uu))},Ju.prototype.isValidResult=function(A,t){var n=Wu.isResultOfOp(t[0],t[1],A),i=!(n^t[2]===Tn.INTERIOR);return i||this.reportResult(A,t,n),i},Ju.prototype.getInvalidLocation=function(){return this.vu},Ju.prototype.interfaces_=function(){return[]},Ju.prototype.getClass=function(){return Ju},Ju.hasLocation=function(A,t){for(var n=0;n<3;n++)if(A[n]===t)return!0;return!1},Ju.computeBoundaryDistanceTolerance=function(A,t){return Math.min(Pu.computeSizeBasedSnapTolerance(A),Pu.computeSizeBasedSnapTolerance(t))},Ju.isValid=function(A,t,n,i){return new Ju(A,t,i).isValid(n)},Zu.TOLERANCE.get=function(){return 1e-6},Object.defineProperties(Ju,Zu);var Xu=function A(t){this.wu=null,this.Pu=!1,this.gu=null,this.wu=A.extractFactory(t),this.gu=t};Xu.prototype.extractElements=function(A,t){if(null===A)return null;for(var n=0;n<A.getNumGeometries();n++){var i=A.getGeometryN(n);this.Pu&&i.isEmpty()||t.add(i)}},Xu.prototype.combine=function(){for(var A=new yi,t=this.gu.iterator();t.hasNext();){var n=t.next();this.extractElements(n,A)}return 0===A.size()?null!==this.wu?this.wu.createGeometryCollection(null):null:this.wu.buildGeometry(A)},Xu.prototype.interfaces_=function(){return[]},Xu.prototype.getClass=function(){return Xu},Xu.combine=function(){if(1===arguments.length){var A=arguments[0],t=new Xu(A);return t.combine()}if(2===arguments.length){var n=arguments[0],i=arguments[1],r=new Xu(Xu.createList(n,i));return r.combine()}if(3===arguments.length){var e=arguments[0],s=arguments[1],u=arguments[2],o=new Xu(Xu.createList(e,s,u));return o.combine()}},Xu.extractFactory=function(A){return A.isEmpty()?null:A.iterator().next().getFactory()},Xu.createList=function(){if(2===arguments.length){var A=arguments[0],t=arguments[1],n=new yi;return n.add(A),n.add(t),n}if(3===arguments.length){var i=arguments[0],r=arguments[1],e=arguments[2],s=new yi;return s.add(i),s.add(r),s.add(e),s}};var $u=function(){this.Cu=null,this.wu=null;var A=arguments[0];this.Cu=A,null===this.Cu&&(this.Cu=new yi)},Ao={STRTREE_NODE_CAPACITY:{configurable:!0}};$u.prototype.reduceToGeometries=function(A){for(var t=new yi,n=A.iterator();n.hasNext();){var i=n.next(),r=null;Fn(i,xi)?r=this.unionTree(i):i instanceof ai&&(r=i),t.add(r)}return t},$u.prototype.extractByEnvelope=function(A,t,n){for(var i=new yi,r=0;r<t.getNumGeometries();r++){var e=t.getGeometryN(r);e.getEnvelopeInternal().intersects(A)?i.add(e):n.add(e)}return this.wu.buildGeometry(i)},$u.prototype.unionOptimized=function(A,t){var n=A.getEnvelopeInternal(),i=t.getEnvelopeInternal();if(!n.intersects(i))return Xu.combine(A,t);if(A.getNumGeometries()<=1&&t.getNumGeometries()<=1)return this.unionActual(A,t);var r=n.intersection(i);return this.unionUsingEnvelopeIntersection(A,t,r)},$u.prototype.union=function(){if(null===this.Cu)throw new Error("union() method cannot be called twice");if(this.Cu.isEmpty())return null;this.wu=this.Cu.iterator().next().getFactory();for(var A=new me($u.STRTREE_NODE_CAPACITY),t=this.Cu.iterator();t.hasNext();){var n=t.next();A.insert(n.getEnvelopeInternal(),n)}this.Cu=null;var i=A.itemsTree();return this.unionTree(i)},$u.prototype.binaryUnion=function(){if(1===arguments.length){var A=arguments[0];return this.binaryUnion(A,0,A.size())}if(3===arguments.length){var t=arguments[0],n=arguments[1],i=arguments[2];if(i-n<=1){var r=$u.getGeometry(t,n);return this.unionSafe(r,null)}if(i-n==2)return this.unionSafe($u.getGeometry(t,n),$u.getGeometry(t,n+1));var e=Math.trunc((i+n)/2),s=this.binaryUnion(t,n,e),u=this.binaryUnion(t,e,i);return this.unionSafe(s,u)}},$u.prototype.repeatedUnion=function(A){for(var t=null,n=A.iterator();n.hasNext();){var i=n.next();t=null===t?i.copy():t.union(i)}return t},$u.prototype.unionSafe=function(A,t){return null===A&&null===t?null:null===A?t.copy():null===t?A.copy():this.unionOptimized(A,t)},$u.prototype.unionActual=function(A,t){return $u.restrictToPolygons(A.union(t))},$u.prototype.unionTree=function(A){var t=this.reduceToGeometries(A);return this.binaryUnion(t)},$u.prototype.unionUsingEnvelopeIntersection=function(A,t,n){var i=new yi,r=this.extractByEnvelope(n,A,i),e=this.extractByEnvelope(n,t,i),s=this.unionActual(r,e);return i.add(s),Xu.combine(i)},$u.prototype.bufferUnion=function(){if(1===arguments.length){var A=arguments[0],t=A.get(0).getFactory(),n=t.buildGeometry(A),i=n.buffer(0);return i}if(2===arguments.length){var r=arguments[0],e=arguments[1],s=r.getFactory(),u=s.createGeometryCollection([r,e]),o=u.buffer(0);return o}},$u.prototype.interfaces_=function(){return[]},$u.prototype.getClass=function(){return $u},$u.restrictToPolygons=function(A){if(Fn(A,gr))return A;var t=Ys.getPolygons(A);return 1===t.size()?t.get(0):A.getFactory().createMultiPolygon(jr.toPolygonArray(t))},$u.getGeometry=function(A,t){return t>=A.size()?null:A.get(t)},$u.union=function(A){return new $u(A).union()},Ao.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties($u,Ao);var to=function(){};function no(){return new io}function io(){this.reset()}to.prototype.interfaces_=function(){return[]},to.prototype.getClass=function(){return to},to.union=function(A,t){if(A.isEmpty()||t.isEmpty()){if(A.isEmpty()&&t.isEmpty())return Wu.createEmptyResult(Wu.UNION,A,t,A.getFactory());if(A.isEmpty())return t.copy();if(t.isEmpty())return A.copy()}return A.checkNotGeometryCollection(A),A.checkNotGeometryCollection(t),xu.overlayOp(A,t,Wu.UNION)},io.prototype={constructor:io,reset:function(){this.s=this.t=0},add:function(A){eo(ro,A,this.t),eo(this,ro.s,this.s),this.s?this.t+=ro.t:this.s=ro.t},valueOf:function(){return this.s}};var ro=new io;function eo(A,t,n){var i=A.s=t+n,r=i-t;A.t=t-(i-r)+(n-r)}var so=1e-6,uo=Math.PI,oo=uo/2,ho=uo/4,fo=2*uo,co=180/uo,ao=uo/180,vo=Math.abs,lo=Math.atan,wo=Math.atan2,Po=Math.cos,go=Math.sin,Co=Math.sqrt;function Do(A){return A>1?0:A<-1?uo:Math.acos(A)}function Io(A){return A>1?oo:A<-1?-oo:Math.asin(A)}function Mo(){}function bo(A,t){A&&yo.hasOwnProperty(A.type)&&yo[A.type](A,t)}var zo,xo,mo={Feature:function(A,t){bo(A.geometry,t)},FeatureCollection:function(A,t){for(var n=A.features,i=-1,r=n.length;++i<r;)bo(n[i].geometry,t)}},yo={Sphere:function(A,t){t.sphere()},Point:function(A,t){t.point((A=A.coordinates)[0],A[1],A[2])},MultiPoint:function(A,t){for(var n=A.coordinates,i=-1,r=n.length;++i<r;)t.point((A=n[i])[0],A[1],A[2])},LineString:function(A,t){po(A.coordinates,t,0)},MultiLineString:function(A,t){for(var n=A.coordinates,i=-1,r=n.length;++i<r;)po(n[i],t,0)},Polygon:function(A,t){Lo(A.coordinates,t)},MultiPolygon:function(A,t){for(var n=A.coordinates,i=-1,r=n.length;++i<r;)Lo(n[i],t)},GeometryCollection:function(A,t){for(var n=A.geometries,i=-1,r=n.length;++i<r;)bo(n[i],t)}};function po(A,t,n){var i,r=-1,e=A.length-n;for(t.lineStart();++r<e;)t.point((i=A[r])[0],i[1],i[2]);t.lineEnd()}function Lo(A,t){var n=-1,i=A.length;for(t.polygonStart();++n<i;)po(A[n],t,1);t.polygonEnd()}function To(A){return[wo(A[1],A[0]),Io(A[2])]}function Oo(A){var t=A[0],n=A[1],i=Po(n);return[i*Po(t),i*go(t),go(n)]}function Fo(A,t){return A[0]*t[0]+A[1]*t[1]+A[2]*t[2]}function Uo(A,t){return[A[1]*t[2]-A[2]*t[1],A[2]*t[0]-A[0]*t[2],A[0]*t[1]-A[1]*t[0]]}function Eo(A,t){A[0]+=t[0],A[1]+=t[1],A[2]+=t[2]}function No(A,t){return[A[0]*t,A[1]*t,A[2]*t]}function jo(A){var t=Co(A[0]*A[0]+A[1]*A[1]+A[2]*A[2]);A[0]/=t,A[1]/=t,A[2]/=t}function Qo(A,t){function n(n,i){return n=A(n,i),t(n[0],n[1])}return A.invert&&t.invert&&(n.invert=function(n,i){return(n=t.invert(n,i))&&A.invert(n[0],n[1])}),n}function So(A,t){return[A>uo?A-fo:A<-uo?A+fo:A,t]}function ko(A){return function(t,n){return[(t+=A)>uo?t-fo:t<-uo?t+fo:t,n]}}function Bo(A){var t=ko(A);return t.invert=ko(-A),t}function Ro(A,t){var n=Po(A),i=go(A),r=Po(t),e=go(t);function s(A,t){var s=Po(t),u=Po(A)*s,o=go(A)*s,h=go(t),f=h*n+u*i;return[wo(o*r-f*e,u*n-h*i),Io(f*r+o*e)]}return s.invert=function(A,t){var s=Po(t),u=Po(A)*s,o=go(A)*s,h=go(t),f=h*r-o*e;return[wo(o*r+h*e,u*n+f*i),Io(f*n-u*i)]},s}function Go(A,t){(t=Oo(t))[0]-=A,jo(t);var n=Do(-t[1]);return((-t[2]<0?-n:n)+fo-so)%fo}function Yo(){var A,t=[];return{point:function(t,n){A.push([t,n])},lineStart:function(){t.push(A=[])},lineEnd:Mo,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var n=t;return t=[],A=null,n}}}function qo(A,t){return vo(A[0]-t[0])<so&&vo(A[1]-t[1])<so}function Vo(A,t,n,i){this.x=A,this.z=t,this.o=n,this.e=i,this.v=!1,this.n=this.p=null}function Wo(A,t,n,i,r){var e,s,u=[],o=[];if(A.forEach((function(A){if(!((t=A.length-1)<=0)){var t,n,i=A[0],s=A[t];if(qo(i,s)){for(r.lineStart(),e=0;e<t;++e)r.point((i=A[e])[0],i[1]);r.lineEnd()}else u.push(n=new Vo(i,A,null,!0)),o.push(n.o=new Vo(i,null,n,!1)),u.push(n=new Vo(s,A,null,!1)),o.push(n.o=new Vo(s,null,n,!0))}})),u.length){for(o.sort(t),_o(u),_o(o),e=0,s=o.length;e<s;++e)o[e].e=n=!n;for(var h,f,c=u[0];;){for(var a=c,v=!0;a.v;)if((a=a.n)===c)return;h=a.z,r.lineStart();do{if(a.v=a.o.v=!0,a.e){if(v)for(e=0,s=h.length;e<s;++e)r.point((f=h[e])[0],f[1]);else i(a.x,a.n.x,1,r);a=a.n}else{if(v)for(e=(h=a.p.z).length-1;e>=0;--e)r.point((f=h[e])[0],f[1]);else i(a.x,a.p.x,-1,r);a=a.p}h=(a=a.o).z,v=!v}while(!a.v);r.lineEnd()}}}function _o(A){if(t=A.length){for(var t,n,i=0,r=A[0];++i<t;)r.n=n=A[i],n.p=r,r=n;r.n=n=A[0],n.p=r}}function Ko(A,t){return A<t?-1:A>t?1:A>=t?0:NaN}function Ho(A){for(var t,n,i,r=A.length,e=-1,s=0;++e<r;)s+=A[e].length;for(n=new Array(s);--r>=0;)for(t=(i=A[r]).length;--t>=0;)n[--s]=i[t];return n}function Jo(A,t,n,i){function r(r,e){return A<=r&&r<=n&&t<=e&&e<=i}function e(r,e,u,h){var f=0,c=0;if(null==r||(f=s(r,u))!==(c=s(e,u))||o(r,e)<0^u>0)do{h.point(0===f||3===f?A:n,f>1?i:t)}while((f=(f+u+4)%4)!==c);else h.point(e[0],e[1])}function s(i,r){return vo(i[0]-A)<so?r>0?0:3:vo(i[0]-n)<so?r>0?2:1:vo(i[1]-t)<so?r>0?1:0:r>0?3:2}function u(A,t){return o(A.x,t.x)}function o(A,t){var n=s(A,1),i=s(t,1);return n!==i?n-i:0===n?t[1]-A[1]:1===n?A[0]-t[0]:2===n?A[1]-t[1]:t[0]-A[0]}return function(s){var o,h,f,c,a,v,l,w,P,g,C,D=s,I=Yo(),M={point:b,lineStart:function(){M.point=z,h&&h.push(f=[]),g=!0,P=!1,l=w=NaN},lineEnd:function(){o&&(z(c,a),v&&P&&I.rejoin(),o.push(I.result())),M.point=b,P&&D.lineEnd()},polygonStart:function(){D=I,o=[],h=[],C=!0},polygonEnd:function(){var t=function(){for(var t=0,n=0,r=h.length;n<r;++n)for(var e,s,u=h[n],o=1,f=u.length,c=u[0],a=c[0],v=c[1];o<f;++o)e=a,s=v,a=(c=u[o])[0],v=c[1],s<=i?v>i&&(a-e)*(i-s)>(v-s)*(A-e)&&++t:v<=i&&(a-e)*(i-s)<(v-s)*(A-e)&&--t;return t}(),n=C&&t,r=(o=Ho(o)).length;(n||r)&&(s.polygonStart(),n&&(s.lineStart(),e(null,null,1,s),s.lineEnd()),r&&Wo(o,u,t,e,s),s.polygonEnd()),D=s,o=h=f=null}};function b(A,t){r(A,t)&&D.point(A,t)}function z(e,s){var u=r(e,s);if(h&&f.push([e,s]),g)c=e,a=s,v=u,g=!1,u&&(D.lineStart(),D.point(e,s));else if(u&&P)D.point(e,s);else{var o=[l=Math.max(-1e9,Math.min(1e9,l)),w=Math.max(-1e9,Math.min(1e9,w))],I=[e=Math.max(-1e9,Math.min(1e9,e)),s=Math.max(-1e9,Math.min(1e9,s))];!function(A,t,n,i,r,e){var s,u=A[0],o=A[1],h=0,f=1,c=t[0]-u,a=t[1]-o;if(s=n-u,c||!(s>0)){if(s/=c,c<0){if(s<h)return;s<f&&(f=s)}else if(c>0){if(s>f)return;s>h&&(h=s)}if(s=r-u,c||!(s<0)){if(s/=c,c<0){if(s>f)return;s>h&&(h=s)}else if(c>0){if(s<h)return;s<f&&(f=s)}if(s=i-o,a||!(s>0)){if(s/=a,a<0){if(s<h)return;s<f&&(f=s)}else if(a>0){if(s>f)return;s>h&&(h=s)}if(s=e-o,a||!(s<0)){if(s/=a,a<0){if(s>f)return;s>h&&(h=s)}else if(a>0){if(s<h)return;s<f&&(f=s)}return h>0&&(A[0]=u+h*c,A[1]=o+h*a),f<1&&(t[0]=u+f*c,t[1]=o+f*a),!0}}}}}(o,I,A,t,n,i)?u&&(D.lineStart(),D.point(e,s),C=!1):(P||(D.lineStart(),D.point(o[0],o[1])),D.point(I[0],I[1]),u||D.lineEnd(),C=!1)}l=e,w=s,P=u}return M}}no(),no(),no(),So.invert=So,1===(zo=Ko).length&&(xo=zo,zo=function(A,t){return Ko(xo(A),t)});var Zo=no();function Xo(A){return A}no(),no(),no();var $o=1/0,Ah=$o,th=-$o,nh=th,ih={point:function(A,t){A<$o&&($o=A),A>th&&(th=A),t<Ah&&(Ah=t),t>nh&&(nh=t)},lineStart:Mo,lineEnd:Mo,polygonStart:Mo,polygonEnd:Mo,result:function(){var A=[[$o,Ah],[th,nh]];return th=nh=-(Ah=$o=1/0),A}};function rh(A,t,n,i){return function(r,e){var s,u,o,h=t(e),f=r.invert(i[0],i[1]),c=Yo(),a=t(c),v=!1,l={point:w,lineStart:g,lineEnd:C,polygonStart:function(){l.point=D,l.lineStart=I,l.lineEnd=M,u=[],s=[]},polygonEnd:function(){l.point=w,l.lineStart=g,l.lineEnd=C,u=Ho(u);var A=function(A,t){var n=t[0],i=t[1],r=[go(n),-Po(n),0],e=0,s=0;Zo.reset();for(var u=0,o=A.length;u<o;++u)if(f=(h=A[u]).length)for(var h,f,c=h[f-1],a=c[0],v=c[1]/2+ho,l=go(v),w=Po(v),P=0;P<f;++P,a=C,l=I,w=M,c=g){var g=h[P],C=g[0],D=g[1]/2+ho,I=go(D),M=Po(D),b=C-a,z=b>=0?1:-1,d=z*b,x=d>uo,m=l*I;if(Zo.add(wo(m*z*go(d),w*M+m*Po(d))),e+=x?b+z*fo:b,x^a>=n^C>=n){var y=Uo(Oo(c),Oo(g));jo(y);var p=Uo(r,y);jo(p);var L=(x^b>=0?-1:1)*Io(p[2]);(i>L||i===L&&(y[0]||y[1]))&&(s+=x^b>=0?1:-1)}}return(e<-so||e<so&&Zo<-so)^1&s}(s,f);u.length?(v||(e.polygonStart(),v=!0),Wo(u,sh,A,n,e)):A&&(v||(e.polygonStart(),v=!0),e.lineStart(),n(null,null,1,e),e.lineEnd()),v&&(e.polygonEnd(),v=!1),u=s=null},sphere:function(){e.polygonStart(),e.lineStart(),n(null,null,1,e),e.lineEnd(),e.polygonEnd()}};function w(t,n){var i=r(t,n);A(t=i[0],n=i[1])&&e.point(t,n)}function P(A,t){var n=r(A,t);h.point(n[0],n[1])}function g(){l.point=P,h.lineStart()}function C(){l.point=w,h.lineEnd()}function D(A,t){o.push([A,t]);var n=r(A,t);a.point(n[0],n[1])}function I(){a.lineStart(),o=[]}function M(){D(o[0][0],o[0][1]),a.lineEnd();var A,t,n,i,r=a.clean(),h=c.result(),f=h.length;if(o.pop(),s.push(o),o=null,f)if(1&r){if((t=(n=h[0]).length-1)>0){for(v||(e.polygonStart(),v=!0),e.lineStart(),A=0;A<t;++A)e.point((i=n[A])[0],i[1]);e.lineEnd()}}else f>1&&2&r&&h.push(h.pop().concat(h.shift())),u.push(h.filter(eh))}return l}}function eh(A){return A.length>1}function sh(A,t){return((A=A.x)[0]<0?A[1]-oo-so:oo-A[1])-((t=t.x)[0]<0?t[1]-oo-so:oo-t[1])}no();var uh=rh((function(){return!0}),(function(A){var t,n=NaN,i=NaN,r=NaN;return{lineStart:function(){A.lineStart(),t=1},point:function(e,s){var u=e>0?uo:-uo,o=vo(e-n);vo(o-uo)<so?(A.point(n,i=(i+s)/2>0?oo:-oo),A.point(r,i),A.lineEnd(),A.lineStart(),A.point(u,i),A.point(e,i),t=0):r!==u&&o>=uo&&(vo(n-r)<so&&(n-=r*so),vo(e-u)<so&&(e-=u*so),i=function(A,t,n,i){var r,e,s=go(A-n);return vo(s)>so?lo((go(t)*(e=Po(i))*go(n)-go(i)*(r=Po(t))*go(A))/(r*e*s)):(t+i)/2}(n,i,e,s),A.point(r,i),A.lineEnd(),A.lineStart(),A.point(u,i),t=0),A.point(n=e,i=s),r=u},lineEnd:function(){A.lineEnd(),n=i=NaN},clean:function(){return 2-t}}}),(function(A,t,n,i){var r;if(null==A)i.point(-uo,r=n*oo),i.point(0,r),i.point(uo,r),i.point(uo,0),i.point(uo,-r),i.point(0,-r),i.point(-uo,-r),i.point(-uo,0),i.point(-uo,r);else if(vo(A[0]-t[0])>so){var e=A[0]<t[0]?uo:-uo;i.point(-e,r=n*e/2),i.point(0,r),i.point(e,r)}else i.point(t[0],t[1])}),[-uo,-oo]);function oh(A,t){var n=Po(A),i=n>0,r=vo(n)>so;function e(A,t){return Po(A)*Po(t)>n}function s(A,t,i){var r=[1,0,0],e=Uo(Oo(A),Oo(t)),s=Fo(e,e),u=e[0],o=s-u*u;if(!o)return!i&&A;var h=n*s/o,f=-n*u/o,c=Uo(r,e),a=No(r,h);Eo(a,No(e,f));var v=c,l=Fo(a,v),w=Fo(v,v),P=l*l-w*(Fo(a,a)-1);if(!(P<0)){var g=Co(P),C=No(v,(-l-g)/w);if(Eo(C,a),C=To(C),!i)return C;var D,I=A[0],M=t[0],b=A[1],z=t[1];M<I&&(D=I,I=M,M=D);var d=M-I,x=vo(d-uo)<so;if(!x&&z<b&&(D=b,b=z,z=D),x||d<so?x?b+z>0^C[1]<(vo(C[0]-I)<so?b:z):b<=C[1]&&C[1]<=z:d>uo^(I<=C[0]&&C[0]<=M)){var m=No(v,(-l+g)/w);return Eo(m,a),[C,To(m)]}}}function u(t,n){var r=i?A:uo-A,e=0;return t<-r?e|=1:t>r&&(e|=2),n<-r?e|=4:n>r&&(e|=8),e}return rh(e,(function(A){var t,n,o,h,f;return{lineStart:function(){h=o=!1,f=1},point:function(c,a){var v,l=[c,a],w=e(c,a),P=i?w?0:u(c,a):w?u(c+(c<0?uo:-uo),a):0;if(!t&&(h=o=w)&&A.lineStart(),w!==o&&(!(v=s(t,l))||qo(t,v)||qo(l,v))&&(l[0]+=so,l[1]+=so,w=e(l[0],l[1])),w!==o)f=0,w?(A.lineStart(),v=s(l,t),A.point(v[0],v[1])):(v=s(t,l),A.point(v[0],v[1]),A.lineEnd()),t=v;else if(r&&t&&i^w){var g;P&n||!(g=s(l,t,!0))||(f=0,i?(A.lineStart(),A.point(g[0][0],g[0][1]),A.point(g[1][0],g[1][1]),A.lineEnd()):(A.point(g[1][0],g[1][1]),A.lineEnd(),A.lineStart(),A.point(g[0][0],g[0][1])))}!w||t&&qo(t,l)||A.point(l[0],l[1]),t=l,o=w,n=P},lineEnd:function(){o&&A.lineEnd(),t=null},clean:function(){return f|(h&&o)<<1}}}),(function(n,i,r,e){!function(A,t,n,i,r,e){if(n){var s=Po(t),u=go(t),o=i*n;null==r?(r=t+i*fo,e=t-o/2):(r=Go(s,r),e=Go(s,e),(i>0?r<e:r>e)&&(r+=i*fo));for(var h,f=r;i>0?f>e:f<e;f-=o)h=To([s,-u*Po(f),-u*go(f)]),A.point(h[0],h[1])}}(e,A,t,r,n,i)}),i?[0,-A]:[-uo,A-uo])}function hh(A){return function(t){var n=new fh;for(var i in A)n[i]=A[i];return n.stream=t,n}}function fh(){}function ch(A,t,n){var i=t[1][0]-t[0][0],r=t[1][1]-t[0][1],e=A.clipExtent&&A.clipExtent();A.scale(150).translate([0,0]),null!=e&&A.clipExtent(null),function(A,t){A&&mo.hasOwnProperty(A.type)?mo[A.type](A,t):bo(A,t)}(n,A.stream(ih));var s=ih.result(),u=Math.min(i/(s[1][0]-s[0][0]),r/(s[1][1]-s[0][1])),o=+t[0][0]+(i-u*(s[1][0]+s[0][0]))/2,h=+t[0][1]+(r-u*(s[1][1]+s[0][1]))/2;return null!=e&&A.clipExtent(e),A.scale(150*u).translate([o,h])}fh.prototype={constructor:fh,point:function(A,t){this.stream.point(A,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var ah=Po(30*ao);function vh(A,t){return+t?function(A,t){function n(i,r,e,s,u,o,h,f,c,a,v,l,w,P){var g=h-i,C=f-r,D=g*g+C*C;if(D>4*t&&w--){var I=s+a,M=u+v,b=o+l,z=Co(I*I+M*M+b*b),d=Io(b/=z),x=vo(vo(b)-1)<so||vo(e-c)<so?(e+c)/2:wo(M,I),m=A(x,d),y=m[0],p=m[1],L=y-i,T=p-r,O=C*L-g*T;(O*O/D>t||vo((g*L+C*T)/D-.5)>.3||s*a+u*v+o*l<ah)&&(n(i,r,e,s,u,o,y,p,x,I/=z,M/=z,b,w,P),P.point(y,p),n(y,p,x,I,M,b,h,f,c,a,v,l,w,P))}}return function(t){var i,r,e,s,u,o,h,f,c,a,v,l,w={point:P,lineStart:g,lineEnd:D,polygonStart:function(){t.polygonStart(),w.lineStart=I},polygonEnd:function(){t.polygonEnd(),w.lineStart=g}};function P(n,i){n=A(n,i),t.point(n[0],n[1])}function g(){f=NaN,w.point=C,t.lineStart()}function C(i,r){var e=Oo([i,r]),s=A(i,r);n(f,c,h,a,v,l,f=s[0],c=s[1],h=i,a=e[0],v=e[1],l=e[2],16,t),t.point(f,c)}function D(){w.point=P,t.lineEnd()}function I(){g(),w.point=M,w.lineEnd=b}function M(A,t){C(i=A,t),r=f,e=c,s=a,u=v,o=l,w.point=C}function b(){n(f,c,h,a,v,l,r,e,i,s,u,o,16,t),w.lineEnd=D,D()}return w}}(A,t):function(A){return hh({point:function(t,n){t=A(t,n),this.stream.point(t[0],t[1])}})}(A)}var lh=hh({point:function(A,t){this.stream.point(A*ao,t*ao)}});function Ph(A){return function(t,n){var i=Po(t),r=Po(n),e=A(i*r);return[e*r*go(t),e*go(n)]}}function gh(A){return function(t,n){var i=Co(t*t+n*n),r=A(i),e=go(r),s=Po(r);return[wo(t*e,i*s),Io(i&&n*e/i)]}}Ph((function(A){return Co(2/(1+A))})).invert=gh((function(A){return 2*Io(A/2)}));var Ch=Ph((function(A){return(A=Do(A))&&A/go(A)}));function Dh(){return function(A){return function(A){var t,n,i,r,e,s,u,o,h,f,c=150,a=480,v=250,l=0,w=0,P=0,g=0,C=0,D=null,I=uh,M=null,b=Xo,z=.5,d=vh(y,z);function x(A){return[(A=e(A[0]*ao,A[1]*ao))[0]*c+n,i-A[1]*c]}function m(A){return(A=e.invert((A[0]-n)/c,(i-A[1])/c))&&[A[0]*co,A[1]*co]}function y(A,r){return[(A=t(A,r))[0]*c+n,i-A[1]*c]}function p(){e=Qo(r=function(A,t,n){return(A%=fo)?t||n?Qo(Bo(A),Ro(t,n)):Bo(A):t||n?Ro(t,n):So}(P,g,C),t);var A=t(l,w);return n=a-A[0]*c,i=v+A[1]*c,L()}function L(){return h=f=null,x}return x.stream=function(A){return h&&f===A?h:h=lh(I(r,d(b(f=A))))},x.clipAngle=function(A){return arguments.length?(I=+A?oh(D=A*ao,6*ao):(D=null,uh),L()):D*co},x.clipExtent=function(A){return arguments.length?(b=null==A?(M=s=u=o=null,Xo):Jo(M=+A[0][0],s=+A[0][1],u=+A[1][0],o=+A[1][1]),L()):null==M?null:[[M,s],[u,o]]},x.scale=function(A){return arguments.length?(c=+A,p()):c},x.translate=function(A){return arguments.length?(a=+A[0],v=+A[1],p()):[a,v]},x.center=function(A){return arguments.length?(l=A[0]%360*ao,w=A[1]%360*ao,p()):[l*co,w*co]},x.rotate=function(A){return arguments.length?(P=A[0]%360*ao,g=A[1]%360*ao,C=A.length>2?A[2]%360*ao:0,p()):[P*co,g*co,C*co]},x.precision=function(A){return arguments.length?(d=vh(y,z=A*A),L()):Co(z)},x.fitExtent=function(A,t){return ch(x,A,t)},x.fitSize=function(A,t){return function(A,t,n){return ch(A,[[0,0],t],n)}(x,A,t)},function(){return t=A.apply(this,arguments),x.invert=t.invert&&m,p()}}((function(){return A}))()}(Ch).scale(79.4188).clipAngle(179.999)}function Ih(A,t){return[A,t]}function Mh(A,t,n,i){var r=A.properties||{},e="Feature"===A.type?A.geometry:A;if("GeometryCollection"===e.type){var s=[];return Pn(A,(function(A){var r=Mh(A,t,n,i);r&&s.push(r)})),rn(s)}var u=function(A){var t=function(A,t){void 0===t&&(t={});var n=gn(A);return tn([(n[0]+n[2])/2,(n[1]+n[3])/2],t.properties,t)}(A).geometry.coordinates,n=[-t[0],-t[1]];return Dh().rotate(n).scale(6371008.8)}(e),o={type:e.type,coordinates:bh(e.coordinates,u)},h=(new Gr).read(o),f=en(sn(t,n),"meters"),c=Ns.bufferOp(h,f,i);if(!function A(t){return Array.isArray(t[0])?A(t[0]):isNaN(t[0])}((c=(new Yr).write(c)).coordinates))return An({type:c.type,coordinates:zh(c.coordinates,u)},r)}function bh(A,t){return"object"!=typeof A[0]?t(A):A.map((function(A){return bh(A,t)}))}function zh(A,t){return"object"!=typeof A[0]?t.invert(A):A.map((function(A){return zh(A,t)}))}Ch.invert=gh((function(A){return A})),Ih.invert=Ih;const dh=[.8451,.2588,.4863],xh=[],mh=[],yh=[];const Lh=[.8,.1,.1];class Oh extends t__namespace.DrawTool{constructor(A){super(A),this.on("enable",this.pu,this),this.on("disable",this.Lu,this),this.Tu=[]}addTo(A){const t=A.getMap();return t?(super.addTo(t),this.Ou=A,this.Fu=t,this.Uu()):A.once("add",(()=>{this.addTo(A)}),this),this}Uu(){this.Fu.getLayer(t__namespace.INTERNAL_LAYER_PREFIX+"drawtool").hide()}pu(){this.on("drawstart",this.Eu,this).on("drawvertex",this.Nu,this).on("mousemove",this.ju,this).on("drawend",this.Qu,this)}Lu(){this.off("drawstart",this.Eu,this).off("drawvertex",this.Nu,this).off("mousemove",this.ju,this).off("drawend",this.Qu,this)}Su(A){const t=this.Ou.identify(A,{includeInternals:!0})[0];return t&&t.coordinate?new t__namespace.Coordinate(t.coordinate):(A.z=A.z||0,A)}Eu(A){const t=this.Su(A.coordinate);t&&(this.ku=!0,this.Tu.push(t),this.Bu(t))}Nu(A){const t=this.Su(A.coordinate);t&&(this.ku=!0,this.Tu[this.Tu.length-1]=t,this.Ru())}ju(A){const t=this.Su(A.coordinate);t&&(this.ku?this.Tu.push(t):this.Tu[this.Tu.length-1]=t,this.Ru(),this.ku=!1)}Qu(A){const t=this.Su(A.coordinate);t&&(this.Tu.push(t),this.Gu())}Gu(){this.Ru(),this.Tu=[],this.et=null,this.Sn=null}remove(){this.Yu&&this.Yu.remove(),this.qu&&this.qu.remove()}clear(){this.Yu&&this.Yu.clear(),this.qu&&this.qu.clear()}}Oh.mergeOptions({mode:"LineString",language:"zh-CN",metric:!0,imperial:!1,once:!0,symbol:{lineColor:"#f00",lineWidth:2,polygonFill:"#ddd",polygonOpacity:.4},vertexSymbol:{markerType:"ellipse",markerFill:"#fff",markerLineColor:"#669955",markerLineWidth:3,markerWidth:12,markerHeight:12,markerDy:6},labelSymbol:{markerType:"square",markerFill:"rgb(135,196,240)",markerFillOpacity:"0.6",markerDx:-15,markerVerticalAlignment:"middle",markerHorizontalAlignment:"left",markerTextFit:"both",markerTextFitPadding:[5,5,5,10],textHorizontalAlignment:"left",textSize:16,textFill:"#fff",textDx:-25}});const Fh=[["ç›´çº¿è·ç¦»","åž‚ç›´é«˜åº¦","æ°´å¹³è·ç¦»"],["spatial distance","vertical height","horizontal distance"]];"undefined"!=typeof window&&(window.maptalksgl=window.maptalksgl||{},window.maptalksgl.transcoders=window.maptalksgl.transcoders||transcoders),exports.AEMarker=class extends st$1{constructor(t,n){super(t,n);const s=t$1.Util.extend({},Bt$1,this.options.symbol);this.setSymbol(s);const i=t$1.Util.extend({},Ft$1,this.options.symbol.uniforms);this.setUniforms(i)}},exports.Area3DTool=class extends Oh{Uu(){super.Uu(),this.Yu=new Je$2(t__namespace.INTERNAL_LAYER_PREFIX+"_area3dtool",{geometryEvents:!1}).addTo(this.Ou),this.qu=new Ye$2(t__namespace.INTERNAL_LAYER_PREFIX+"_area3dtool_marker",{geometryEvents:!1}).addTo(this.Ou)}Ru(){this.et.setCoordinates(this.Tu);const A=this.qu.getGeometries(),t=this.Yu.getGeometries().length;for(let n=0;n<A.length;n++){const i=A[n].getId();i!=="label"+t&&i.indexOf(t+"_")>-1&&A[n].remove()}for(let A=0;A<this.Tu.length-1;A++)new t__namespace.Marker(this.Tu[A],{id:t+"_"+A,symbol:this.options.vertexSymbol}).addTo(this.qu);this.Vu()}Vu(){const A=this.getMeasureResult(),t=("zh-CN"!==this.options.language?"area: ":"é¢ç§¯: ")+this.Wu(A),n=t__namespace.Util.extend({textName:t},this.options.labelSymbol),i=this.Tu[this.Tu.length-1],r=this.Yu.getGeometries().length;this.Sn?(this.Sn.setSymbol([this.options.vertexSymbol,n]),this.Sn.setCoordinates(i)):this.Sn=new t__namespace.Marker(i,{id:"label"+r,symbol:[this.options.vertexSymbol,n]}).addTo(this.qu)}Wu(A){let t;t="zh-CN"===this.options.language?[" å¹³æ–¹ç±³"," å¹³æ–¹å…¬é‡Œ"," å¹³æ–¹è‹±å°º"," å¹³æ–¹è‹±é‡Œ"]:[" sq.m"," sq.km"," sq.ft"," sq.mi"];let n="";if(this.options.metric&&(this._u=A<1e6?A.toFixed(2):(A/1e6).toFixed(2),this.Ku=A<1e6?t[0]:t[1]),this.options.imperial){n.length>0&&(n+="\n");const i=27878400;this._u=(A*=3.2808399)<i?A.toFixed(2):(A/i).toFixed(2),this.Ku=A<i?t[2]:t[3]}return n+=this._u+this.Ku,n}Bu(A){this.et||(this.et=new t__namespace.Polygon([A],{symbol:this.options.symbol}).addTo(this.Yu)),this.Ru(),this.ku=!0}getMeasureResult(){return this.et.getArea()}},exports.B3DMLoader=ds$1,exports.BoxInsideClipMask=ln$4,exports.BoxOutsideClipMask=cn$4,exports.CMPTLoader=vs$1,exports.ClipInsideMask=Xs$3,exports.ClipOutsideMask=Js$3,exports.ColorMask=tn$4,exports.CrossCutAnalysis=class extends LA{constructor(A){super(A),this.type="crosscutAnalysis",this.$=!0}YA(){const A=this.layer.getMap();this.q={};const{extentMap:t,extentInWorld:n}=this.Du(this.options.cutLine);this.q.extent=n,this.q.extentMap=t,this.q.projMatrix=A.projMatrix,this.q.viewMatrix=A.viewMatrix,this.q.minAltitude=0;const i=new t__namespace.LineString(this.options.cutLine);this.Iu=i.getExtent()}getAltitudes(A){const t=nn(this.options.cutLine);let n=0;for(let A=0;A<this.options.cutLine.length-1;A++)n+=vn(this.options.cutLine[A],this.options.cutLine[A+1]);const i=n/A,r=[],e=[];for(let n=0;n<A;n++){const A=ln(t,i*(n+1));e.push(A.geometry.coordinates)}const s=this.layer.getMap(),o=s.getDevicePixelRatio(),{projViewMatrix:h,projMatrix:f,viewMatrix:c}=this.Mu(e);for(let A=0;A<e.length;A++){const t=this.bu(e[A],e),v=this.zu(t.x*o,t.y*o,h,f,c);if(!v)continue;const l=s.pointAtResToAltitude(v[2],s.getGLRes()),w=s.pointAtResToCoordinate(new t__namespace.Point(v[0],v[1]),s.getGLRes());r.push({coordinate:new t__namespace.Coordinate(w.x,w.y,l),distance:i*A})}return r}Du(A){const t=function(A,t,n){var i=(n=n||{}).units||"kilometers",r=n.steps||8;if(!A)throw new Error("geojson is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be an number");if(r<=0)throw new Error("steps must be greater than 0");var e=[];switch(A.type){case"GeometryCollection":return Pn(A,(function(A){var n=Mh(A,t,i,r);n&&e.push(n)})),rn(e);case"FeatureCollection":return wn(A,(function(A){var n=Mh(A,t,i,r);n&&wn(n,(function(A){A&&e.push(A)}))})),rn(e)}return Mh(A,t,i,r)}(nn(A),.001);return this.V(t.geometry.coordinates[0])}S(t){const n=this.u={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.YA(t),this.du(t);const i=new B$6(t.regl);this.k=this.k||new Xt(i,n),this.layer.addAnalysis(this)}du(n){const i=this.layer.getMap();this.pickingFBO=n.canvas.pickingFBO||n.regl.framebuffer(n.canvas.width,n.canvas.height);const r=new B$6(n.regl);this.G=new Cr$4(r,{vert:UA,uniforms:[{name:"projViewModelMatrix",type:"function",fn:function(A,n){return multiply$5([],n.projViewMatrix,n.modelMatrix)}}]},this.pickingFBO,i)}Mu(){if(this.xu)return this.xu;const A=this.layer.getMap(),{precenter:n,prezoom:i,prepitch:r,prebearing:e}=this.mu();return copy$5(xh,A.projViewMatrix),copy$5(mh,A.projMatrix),copy$5(yh,A.viewMatrix),A.setZoom(i),A.setCenter(n),A.setPitch(r),A.setBearing(e),this.xu={projViewMatrix:xh,projMatrix:mh,viewMatrix:yh},this.xu}mu(){const A=this.Iu,t=this.layer.getMap(),n=t.getCenter(),i=t.getZoom(),r=t.getPitch(),e=t.getBearing(),s=t.getFitZoom(A);return t.setZoom(s),t.setCenter(A.getCenter()),t.setPitch(0),{precenter:n,prezoom:i,prepitch:r,prebearing:e}}bu(A){const{precenter:t,prezoom:n,prepitch:i,prebearing:r}=this.mu(),e=this.layer.getMap(),s=e.coordinateToContainerPoint(new t__namespace.Coordinate(A));return e.setZoom(n),e.setCenter(t),e.setPitch(i),e.setBearing(r),s}zu(A,t,n,i,r,e={}){if(this.$){if(!this.yu||0===this.yu.length)return null;const A=this.yu;A.forEach((A=>{const t=A.getDefines();t.HAS_PICKING_ID=2,A.setDefines(t),A.setUniform("uPickingId",1)})),this.G.render(A,{projViewMatrix:n,minAltitude:this.q.minAltitude},!0),this.$=!1}const{point:s}=this.G.pick(A,t,e.tolerance||3,{projViewMatrix:n,minAltitude:this.q.minAltitude},{viewMatrix:r,projMatrix:i,returnPoint:!0});return s}update(A,t){if(super.update(A,t),"cutLine"===A){const{extentMap:A,extentInWorld:n}=this.Du(t);this.q.extent=n,this.q.extentMap=A;const i=new t__namespace.LineString(this.options.cutLine);this.Iu=i.getExtent(),this.$=!0,delete this.xu}else this.q[A]=t}renderAnalysis(A){const t={};return this.B.render(this.R,this._),t.cutLineColor=this.options.cutLineColor||dh,t.crosscutMap=this.k.render(A,this.q),this.yu=A,t}getDefines(){return{HAS_CROSSCUT:1}}},exports.CutAnalysis=class extends LA{constructor(A){super(A),this.type="cut"}update(A,t){if("eyePos"===A||"lookPoint"===A){const n=this.layer.getMap();this.q[A]=AA(n,...t)}else this.q[A]=t;super.update(A,t)}reset(){if(this.k){this.k.SA(this.q.position,this.q.rotation,this.q.scale)}}YA(){const A=this.layer.getMap();this.q={},this.q.position=AA(A,...this.options.position),this.q.rotation=this.options.rotation||[0,0,0],this.q.scale=this.options.scale||[1,1,1],this.q.projViewMatrix=A.projViewMatrix,this.q.minAltitude=0}S(t){const n={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1},i=new B$6(t.regl);i.canvas=t.canvas,i.parentRenderer=t,this.YA(),this.k=new tt(i,n)||this.k;const r=this.layer.getMap();this.k.QA(r,this.q.position,this.q.rotation,this.q.scale),this.layer.addAnalysis(this),t.setToRedraw()}renderAnalysis(A){const t={};this.q.map=this.layer.getMap();const{meshesMap:n,invisibleMap:i}=this.k.render(A,this.q);return t.meshesMap=n,t.invisibleMap=i,t}getDefines(){return{HAS_CUT:1}}},exports.Distance3DTool=class extends Oh{Uu(){super.Uu(),this.Yu=new $e$2(t__namespace.INTERNAL_LAYER_PREFIX+"_distance3dtool",{geometryEvents:!1}).addTo(this.Ou),this.qu=new Ye$2(t__namespace.INTERNAL_LAYER_PREFIX+"_distance3dtool_marker",{geometryEvents:!1}).addTo(this.Ou)}Ru(){this.et.setCoordinates(this.Tu);const A=this.qu.getGeometries(),t=this.Yu.getGeometries().length;for(let n=0;n<A.length;n++){const i=A[n].getId();i!=="label"+t&&i.indexOf(t+"_")>-1&&A[n].remove()}for(let A=0;A<this.Tu.length-1;A++)new t__namespace.Marker(this.Tu[A],{id:t+"_"+A,symbol:this.options.vertexSymbol}).addTo(this.qu);this.Vu()}Vu(){const A=this.getMeasureResult(),t=("zh-CN"!==this.options.language?"distance: ":"è·ç¦»: ")+this.Wu(A),n=t__namespace.Util.extend({textName:t},this.options.labelSymbol),i=this.Tu[this.Tu.length-1],r=this.Yu.getGeometries().length;this.Sn?(this.Sn.setSymbol([this.options.vertexSymbol,n]),this.Sn.setCoordinates(i)):this.Sn=new t__namespace.Marker(i,{id:"label"+r,symbol:[this.options.vertexSymbol,n]}).addTo(this.qu)}Wu(A){let t;t="zh-CN"===this.options.language?[" ç±³"," å…¬é‡Œ"," è‹±å°º"," è‹±é‡Œ"]:[" m"," km"," feet"," mile"];let n="";return this.options.metric&&(this._u=A<1e3?A.toFixed(1):(A/1e3).toFixed(2),this.Ku=A<1e3?t[0]:t[1]),this.options.imperial&&(n.length>0&&(n+="\n"),this._u=(A*=3.2808399)<5280?A.toFixed(1):(A/5280).toFixed(2),this.Ku=A<5280?t[2]:t[3]),n+=this._u+this.Ku,n}Bu(A){this.et||(this.et=new t__namespace.LineString([A],{symbol:this.options.symbol}).addTo(this.Yu)),this.Ru(),this.ku=!0}getMeasureResult(){return this.et.getLength()}},exports.EffectLayer=St$1,exports.EffectLine=class extends st$1{constructor(t,n){super(t,n);const s=t$1.Util.extend({},Pt$1,this.options.symbol);this.setSymbol(s);const i=t$1.Util.extend({},It$1,this.options.symbol.uniforms);this.setUniforms(i),this.setShader("effectline"),this.ht="effectmarker"}getEffectType(){return"sequence"}setTexture(t){return this.setUniform("texture",t),this}setHeight(t){return this.setUniform("modelHeight",t),this}setStartOpacity(t){return this.setUniform("startOpacity",t),this}setEndOpacity(t){return this.setUniform("endOpacity",t),this}},exports.EffectLineLayer=kt$1,exports.EffectMarker=st$1,exports.EffectRing=class extends et$1{constructor(t,n){super(t,n);const s=t$1.Util.extend({},Nt$1,this.options.symbol.uniforms);this.setUniforms(s),this.setShader("effectring"),this.ht="effectring"}},exports.EffectRingLayer=Lt$1,exports.ElevateMask=sn$4,exports.ExcavateAnalysis=Zt,exports.ExtrudePolygonLayer=$n$2,exports.FillPainter=nr$2,exports.FillPlugin=ga,exports.FilterUtil=Mr$3,exports.FlatInsideMask=Ks$3,exports.FlatOutsideMask=Qs$3,exports.FloodAnalysis=dt,exports.GLContext=a,exports.GLTFGeometry=class extends et$1{Dt(t){const e=this.getMap(),n=e.getGLRes(),s=e.distanceToPointAtRes(100,100,n,this.getCenter()),i=e.altitudeToPoint(100,n);return t[0]*=s.x/100,t[1]*=s.y/100,t[2]*=i/100,t}},exports.GLTFLayer=ht$1,exports.GLTFLineString=vt$1,exports.GLTFMarker=et$1,exports.GLTFMercatorGeometry=class extends et$1{Dt(t){const e=this.getMap(),n=e.getGLRes(),s=this.getCoordinates(),i=e.coordToPointAtRes(s,n,ft$1),r=t$1.projection.EPSG3857.project(s,ut$1)._add(1,1),o=t$1.projection.EPSG3857.unproject(r,lt$1),a=e.coordToPointAtRes(o,n,dt$1),c=a.x-i.x,u=a.y-i.y,l=e.altitudeToPoint(100,n);return t[0]*=c,t[1]*=u,t[2]*=l/100,t}},exports.GLTFPhongPlugin=Ta,exports.GLTFStandardPlugin=ka,exports.Geo3DTilesLayer=os$1,exports.Geo3DTilesUtil=Nt$2,exports.Geo3DTransform=ue$1,exports.GeoJSONVectorTileLayer=ve$2,exports.GlowMarker=At$1,exports.GlowMarkerLayer=Et$1,exports.GroundPainter=jt$4,exports.GroupGLLayer=Cs$3,exports.HeatmapPlugin=Oa,exports.HeatmapProcess=$s$2,exports.Height3DTool=class extends Oh{Uu(){super.Uu(),this.qu=new Ye$2(t__namespace.INTERNAL_LAYER_PREFIX+"_height3dtool_marker").addTo(this.Fu).bringToFront(),this.Yu=new t__namespace.VectorLayer(t__namespace.INTERNAL_LAYER_PREFIX+"_height3dtool",{enableAltitude:!0}).addTo(this.Fu).bringToFront()}Nu(A){super.Nu(A),this.Tu.length>1&&(this.Gu(),this.disable())}Ru(){const A=this.qu.getGeometries(),t=this.Yu.getGeometries().length;for(let n=0;n<A.length;n++){const i=A[n].getId();i!=="label"+t+"_"+n&&0===i.indexOf(t+"_")&&A[n].remove()}for(let A=0;A<this.Tu.length;A++)new t__namespace.Marker(this.Tu[A],{id:t+"_"+A,symbol:this.options.vertexSymbol}).addTo(this.qu);const n=this.Tu.length;if(n>1){const e=new t__namespace.Coordinate([this.Tu[n-1].x,this.Tu[n-1].y,this.Tu[n-2].z]);new t__namespace.Marker(e,{id:t+"_2",symbol:this.options.vertexSymbol}).addTo(this.qu);const s=[].concat(this.Tu);s.push(e),s.push(this.Tu[0]);const o=s.map((A=>A.z));this.et.setCoordinates(s),this.et.setProperties({altitude:o});const h=this.Fu.getProjection().measureLenBetween(s[0],s[2]),f=s[1].z-s[2].z,c=Math.sqrt(Math.pow(h,2)+Math.pow(f,2));this.Vu(s,[c,f,h])}}Vu(A,t){for(let n=0;n<A.length-1;n++){const i=A[n],r=A[n+1],s="zh-CN"===this.options.language?0:1,o=this.Wu(t[n]),f=t__namespace.Util.extend({textName:Fh[s][n]+":"+o},this.options.labelSymbol);n<2&&(f.markerDx=20,f.textDx=25,f.markerHorizontalAlignment="right",f.textHorizontalAlignment="right");const c=1===n?i:new t__namespace.Coordinate((i.x+r.x)/2,(i.y+r.y)/2,(i.z+r.z)/2),a="label"+this.Yu.getGeometries().length+"_"+n,v=this.qu.getGeometryById(a);v?(v.setSymbol([this.options.vertexSymbol,f]),v.setCoordinates(c)):new t__namespace.Marker(c,{id:a,symbol:[this.options.vertexSymbol,f]}).addTo(this.qu)}}Wu(A){let t;t="zh-CN"===this.options.language?[" ç±³"," å…¬é‡Œ"," è‹±å°º"," è‹±é‡Œ"]:[" m"," km"," feet"," mile"];let n="";return this.options.metric&&(this._u=A<1e3?A.toFixed(1):(A/1e3).toFixed(2),this.Ku=A<1e3?t[0]:t[1]),this.options.imperial&&(n.length>0&&(n+="\n"),this._u=(A*=3.2808399)<5280?A.toFixed(1):(A/5280).toFixed(2),this.Ku=A<5280?t[2]:t[3]),n+=this._u+this.Ku,n}Bu(A){this.et||(this.et=new t__namespace.LineString([A],{symbol:this.options.symbol}).addTo(this.Yu)),this.Ru(),this.ku=!0}getMeasureResult(){return this.et.getLength()}},exports.HeightLimitAnalysis=class extends dt{constructor(A){super(A),this.type="heightLimitAnalysis"}YA(A){super.YA(A);const t=this.layer.getMap();this.q.waterHeight=X(t,this.options.limitHeight),this.q.type=2}update(A,t){if(super.update(A,t),"limitHeight"===A){const A=this.layer.getMap();this.q.waterHeight=A.altitudeToPoint(t||0,A.getGLRes())}}renderAnalysis(A){const t=super.renderAnalysis(A);return t.heightLimitMap=t.floodMap,t.limitColor=this.options.limitColor||Lh,t}getDefines(){return{HAS_HEIGHTLIMIT:1}}},exports.HighlightUtil=Ws$3,exports.IconPainter=Es$1,exports.IconPlugin=ba,exports.InSightAnalysis=class extends LA{constructor(A){super(A),this.xt=A.lines||[],this.yt=new qt,this.type="insight"}update(A,t){"lines"===A?this.setLines(t):this.q[A]=t,super.update(A,t)}addLine(A){const{from:t,to:n}=A;t&&n&&this.xt.push(A),this.Lt()}removeLine(A){const t=this.xt.indexOf(A);t>-1&&this.xt.splice(t,1),this.Lt()}getLines(){return this.xt}setLines(A){this.xt=A,this.Lt()}clearLines(){this.xt=[],this.Lt()}getIntersetction(){const A=[];if(!this.Tt)return A;const t=this.layer.getMap();for(let n=0;n<this.xt.length;n++){const{from:i,to:r}=this.xt[n];this.yt.setFromPoint(i),this.yt.setToPoint(r);const e=this.yt.test(this.Tt,t);if(e&&e.length){const t={inSightLine:this.xt[n],intersects:[]};e.forEach((A=>{const n=this.Ot(A);n&&t.intersects.push(n)})),A.push(t)}}return A}Ot(A){const t=[],n=this.layer;if(!n)return t;const{mesh:i,coordinates:r}=A,e=this.getExcludeLayers();return n.getLayers().forEach((A=>{const n=A.getId(),s=A.getRenderer();if(e.indexOf(n)<0&&s&&s.getRayCastData&&r.length){const n=s.getRayCastData(i,r[0].indices[0]);n&&t.push({data:n,coordinates:r})}})),t}Lt(){this.YA();const A=this.layer.getRenderer();A&&A.setToRedraw()}YA(){const A=this.layer.getMap();this.q={},this.q.lines=this.xt.map((t=>{const{from:n,to:i}=t;return{from:AA(A,...n),to:AA(A,...i)}})),this.q.visibleColor=this.options.visibleColor,this.q.invisibleColor=this.options.invisibleColor,this.q.projViewMatrix=A.projViewMatrix,this.q.horizontalAngle=45,this.q.verticalAngle=45,this.q.minAltitude=0}S(t){const n={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.YA();const i=new B$6(t.regl);this.k=this.k||new Lt(i,n),this.layer.addAnalysis(this),t.setToRedraw()}renderAnalysis(A){const t={};this.Tt=A;const n=this.k.render(A,this.q);return t.insightMap=n,t.insight_visibleColor=this.q.visibleColor||[0,1,0,1],t.insight_invisibleColor=this.q.invisibleColor||[1,0,0,1],t}getDefines(){return{HAS_INSIGHT:1}}},exports.LineGradientPlugin=xa,exports.LinePainter=or$2,exports.LinePlugin=va,exports.LineStringLayer=$e$2,exports.LitPlugin=Ma,exports.MSDJSONLoader=class{constructor(t){this.i=t||{}}load(){const t=this.i.data;let r=this.i.basePath;if("string"==typeof(e=t)||null!==e.constructor&&e.constructor===String){const e=this.i.fetchFunction||fetch,i=this.i.fetchOptions;if(!r){const e=t.lastIndexOf("/");r=e<0?"./":t.substring(0,e)}return e(t,i).then((t=>t.json())).then((t=>(this.s(t,r),this)))}return this.s(t,r||"./"),Promise.resolve(this);var e}getMSDJSON(){return e(this.h)}getMapJSON(){return e(this.t)}getView(){if(!this.t)return null;const{center:t,zoom:r,pitch:e,bearing:i}=this.t;return{center:t,zoom:r,pitch:e,bearing:i}}getLights(){return this.t&&this.t.options.lights}getSceneConfig(){return this.t&&this.t.layers[0].options.sceneConfig}s(r,i){if("./"!==i&&"."!==i){"/"!==i[i.length-1]&&(i+="/"),this.h=r;let t=JSON.stringify(r);t=t.replace(/".\/res/g,'"'+i+"res"),r=JSON.parse(t)}else this.h=e(r);this.t=r||{},this.u=function(r){return r.layers?r.layers.map((r=>r?new t(r):null)):[]}(r.layers[0])}getLayer(t){const r=this.u;if(!r)return null;for(let e=0;e<r.length;e++){const i=r[e];if(i&&t===i.getId())return i}return null}getLayers(){return this.u||[]}},exports.MapboxVectorTileLayer=ye$2,exports.MaskLayerMixin=ds$4,exports.MaskRendererMixin=oe$4,exports.MultiGLTFMarker=_t$1,exports.NativeLinePainter=To$1,exports.NativeLinePlugin=wa,exports.NativePointPainter=So$1,exports.PackUtil=Fa,exports.PhongPainter=Uo$1,exports.PhongPlugin=_a,exports.PointLayer=Ye$2,exports.PolygonLayer=Je$2,exports.RayCaster=qt,exports.SYMBOLS_NEED_REBUILD_IN_VECTOR=Ia$1,exports.SYMBOLS_NEED_REBUILD_IN_VT=Da,exports.SkylineAnalysis=class extends LA{constructor(A){super(A),this.type="skyline"}YA(){const A=this.layer.getMap();this.q={},this.q.lineColor=this.options.lineColor,this.q.lineWidth=this.options.lineWidth,this.q.projViewMatrix=A.projViewMatrix,this.q.minAltitude=0}S(t){const n={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.YA(),this.renderer=new B$6(t.regl),this.k=new Ct(this.renderer,n)||this.k,this.layer.addAnalysis(this),this.At=this.tt(t.regl)}renderAnalysis(A){this.At=this.At||this.tt(this.renderer.regl);const t=this.layer.getMap();this.nt(t);const n={},i=A.concat([this.At]);return this.renderer.clear({color:[0,0,0,1],depth:1,framebuffer:this.T}),this.T=this.k.render(i,this.q),n.skylineMap=this.T,n}exportSkylineMap(A){if(!Dt||!this.isEnable())return null;A||(A={});const t=this.k.getRenderMeshes(),n=this.exportAnalysisMap(t),i=this.T.width,r=this.T.height,e=new Uint8ClampedArray(n.length);for(let A=0;A<i;A++)for(let t=0;t<r;t++)e[4*(t*i+A)]=n[4*((r-t)*i+A)],e[4*(t*i+A)+1]=n[4*((r-t)*i+A)+1],e[4*(t*i+A)+2]=n[4*((r-t)*i+A)+2],e[4*(t*i+A)+3]=n[4*((r-t)*i+A)+3],0===e[4*(t*i+A)]&&0===e[4*(t*i+A)+1]&&0===e[4*(t*i+A)+2]&&(e[4*(t*i+A)+3]=0);Dt.width=i,Dt.height=r;const s=new ImageData(e,i,r);Dt.getContext("2d").putImageData(s,0,0);const u=Dt.toDataURL();if(A.save){const t=document.createElement("a");t.download=A.filename||"export",t.href=u,document.body.appendChild(t),t.click(),document.body.removeChild(t)}return u}update(A,t){this.q[A]=t,super.update(A,t)}tt(t){const n=new tn$5;return n.generateBuffers(t),n.data.aTexCoord=new Float32Array(8),new Be$5(n)}nt(A){const t=jt$4.getGroundTransform(this.At.localTransform,A);this.At.setLocalTransform(t)}remove(){super.remove(),this.At&&(this.At.geometry.dispose(),this.At.dispose(),delete this.At)}getDefines(){return{HAS_SKYLINE:1}}},exports.TextPainter=xo$1,exports.TextPlugin=Aa,exports.TransformControl=tA$1,exports.TubePlugin=Pa,exports.Vector3DLayer=we$2,exports.VectorTileLayer=he$2,exports.VectorTileLayerRenderer=Jt$2,exports.VideoLayer=b$1,exports.VideoMask=en$4,exports.VideoSurface=y$1,exports.ViewshedAnalysis=class extends LA{constructor(A){super(A),this.type="viewshed"}update(A,t){if("eyePos"===A||"lookPoint"===A){const n=this.layer.getMap();this.q[A]=AA(n,...t)}else this.q[A]=t;super.update(A,t)}YA(){const A=this.layer.getMap();this.q={},this.q.eyePos=AA(A,...this.options.eyePos),this.q.lookPoint=AA(A,...this.options.lookPoint),this.q.verticalAngle=this.options.verticalAngle,this.q.horizontalAngle=this.options.horizontalAngle,this.q.visibleColor=this.options.visibleColor,this.q.invisibleColor=this.options.invisibleColor,this.q.projViewMatrix=A.projViewMatrix,this.q.minAltitude=0}S(t){const n={x:0,y:0,width:()=>t.canvas?t.canvas.width:1,height:()=>t.canvas?t.canvas.height:1};this.YA();const i=new B$6(t.regl);this.k=new Pt(i,n)||this.k,this.layer.addAnalysis(this),t.setToRedraw()}renderAnalysis(A){const t={},n=this.k.render(A,this.q);return t.viewshedMap=n,t.viewshed_visibleColor=this.q.visibleColor||[0,1,0,.3],t.viewshed_invisibleColor=this.q.invisibleColor||[1,0,0,.3],t}getVertexCoordinates(){const A=this.layer.getMap();return A?this.k.HA(A):[]}getDefines(){return{HAS_VIEWSHED:1}}},exports.WaterPlugin=Ia,exports.WireframePainter=Bo$1,exports.WireframePlugin=Sa,exports.createREGL=a$2,exports.glMatrix=common,exports.mat2=mat2,exports.mat2d=mat2d,exports.mat3=mat3,exports.mat4=mat4,exports.quat=quat,exports.quat2=quat2,exports.reshader=l$1,exports.transcoders=transcoders,exports.vec2=vec2,exports.vec3=vec3,exports.vec4=vec4,Object.defineProperty(exports,"__esModule",{value:!0})}));/*!
 * @maptalks/transcoders.draco v0.86.0
 * LICENSE : ISC
 * (c) 2022-2023 maptalks.com
 */
!function(){!function(A,I){"object"==typeof exports&&"undefined"!=typeof module?module.exports=I():"function"==typeof define&&define.amd?define(I):((A="undefined"!=typeof globalThis?globalThis:A||self).maptalksgl=A.maptalksgl||{},A.maptalksgl.transcoders=A.maptalksgl.transcoders||{},A.maptalksgl.transcoders.draco=I())}(this,(function(){"use strict";const A=function(){const A=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();return A.draco______decoder||(A.draco______decoder=function(){function A(A){if(A.__esModule)return A;var I=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(A).forEach((function(g){var C=Object.getOwnPropertyDescriptor(A,g);Object.defineProperty(I,g,C.get?C:{enumerable:!0,get:function(){return A[g]}})})),I}var I={exports:{}};function g(A,I){for(var g=0,C=A.length-1;C>=0;C--){var Q=A[C];"."===Q?A.splice(C,1):".."===Q?(A.splice(C,1),g++):g&&(A.splice(C,1),g--)}if(I)for(;g--;g)A.unshift("..");return A}var C=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,Q=function(A){return C.exec(A).slice(1)};function B(){for(var A="",I=!1,C=arguments.length-1;C>=-1&&!I;C--){var Q=C>=0?arguments[C]:"/";if("string"!=typeof Q)throw new TypeError("Arguments to path.resolve must be strings");Q&&(A=Q+"/"+A,I="/"===Q.charAt(0))}return(I?"/":"")+(A=g(k(A.split("/"),(function(A){return!!A})),!I).join("/"))||"."}function E(A){var I=i(A),C="/"===t(A,-1);return(A=g(k(A.split("/"),(function(A){return!!A})),!I).join("/"))||I||(A="."),A&&C&&(A+="/"),(I?"/":"")+A}function i(A){return"/"===A.charAt(0)}function o(){var A=Array.prototype.slice.call(arguments,0);return E(k(A,(function(A,I){if("string"!=typeof A)throw new TypeError("Arguments to path.join must be strings");return A})).join("/"))}function a(A,I){function g(A){for(var I=0;I<A.length&&""===A[I];I++);for(var g=A.length-1;g>=0&&""===A[g];g--);return I>g?[]:A.slice(I,g-I+1)}A=B(A).substr(1),I=B(I).substr(1);for(var C=g(A.split("/")),Q=g(I.split("/")),E=Math.min(C.length,Q.length),i=E,o=0;o<E;o++)if(C[o]!==Q[o]){i=o;break}var a=[];for(o=i;o<C.length;o++)a.push("..");return(a=a.concat(Q.slice(i))).join("/")}function r(A){var I=Q(A),g=I[0],C=I[1];return g||C?(C&&(C=C.substr(0,C.length-1)),g+C):"."}function D(A,I){var g=Q(A)[2];return I&&g.substr(-1*I.length)===I&&(g=g.substr(0,g.length-I.length)),g}function e(A){return Q(A)[3]}var f={extname:e,basename:D,dirname:r,sep:"/",delimiter:":",relative:a,join:o,isAbsolute:i,normalize:E,resolve:B};function k(A,I){if(A.filter)return A.filter(I);for(var g=[],C=0;C<A.length;C++)I(A[C],C,A)&&g.push(A[C]);return g}var t="b"==="ab".substr(-1)?function(A,I,g){return A.substr(I,g)}:function(A,I,g){return I<0&&(I=A.length+I),A.substr(I,g)},N=A(Object.freeze({__proto__:null,resolve:B,normalize:E,isAbsolute:i,join:o,relative:a,sep:"/",delimiter:":",dirname:r,basename:D,extname:e,default:f})),s=A(Object.freeze({__proto__:null,default:{}}));!function(A,I){var g,C=(g="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(A){var I,C,Q=void 0!==(A=A||{})?A:{};Q.ready=new Promise((function(A,g){I=A,C=g}));var B=!1,E=!1;Q.onRuntimeInitialized=function(){B=!0,E&&"function"==typeof Q.onModuleLoaded&&Q.onModuleLoaded(Q)},Q.onModuleParsed=function(){E=!0,B&&"function"==typeof Q.onModuleLoaded&&Q.onModuleLoaded(Q)},Q.isVersionSupported=function(A){if("string"!=typeof A)return!1;const I=A.split(".");return!(I.length<2||I.length>3)&&(1==I[0]&&I[1]>=0&&I[1]<=5||!(0!=I[0]||I[1]>10))};var i,o={};for(i in Q)Q.hasOwnProperty(i)&&(o[i]=Q[i]);var a,r,D,e,f,k="object"==typeof window,t="function"==typeof importScripts,F="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,n="";F?(n=t?N.dirname(n)+"/":__dirname+"/",a=function(A,I){var g=CA(A);return g?I?g:g.toString():(e||(e=s),f||(f=N),A=f.normalize(A),e.readFileSync(A,I?null:"utf8"))},D=function(A){var I=a(A,!0);return I.buffer||(I=new Uint8Array(I)),U(I.buffer),I},r=function(A,I,g){var C=CA(A);C&&I(C),e||(e=s),f||(f=N),A=f.normalize(A),e.readFile(A,(function(A,C){A?g(A):I(C.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),Q.inspect=function(){return"[Emscripten Module object]"}):(k||t)&&(t?n=self.location.href:"undefined"!=typeof document&&document.currentScript&&(n=document.currentScript.src),g&&(n=g),n=0!==n.indexOf("blob:")?n.substr(0,n.replace(/[?#].*/,"").lastIndexOf("/")+1):"",a=function(A){try{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.send(null),I.responseText}catch(I){var g=CA(A);if(g)return function(A){for(var I=[],g=0;g<A.length;g++){var C=A[g];C>255&&(C&=255),I.push(String.fromCharCode(C))}return I.join("")}(g);throw I}},t&&(D=function(A){try{var I=new XMLHttpRequest;return I.open("GET",A,!1),I.responseType="arraybuffer",I.send(null),new Uint8Array(I.response)}catch(I){var g=CA(A);if(g)return g;throw I}}),r=function(A,I,g){var C=new XMLHttpRequest;C.open("GET",A,!0),C.responseType="arraybuffer",C.onload=function(){if(200==C.status||0==C.status&&C.response)I(C.response);else{var Q=CA(A);Q?I(Q.buffer):g()}},C.onerror=g,C.send(null)});var R,y=Q.print||console.log.bind(console),G=Q.printErr||console.warn.bind(console);for(i in o)o.hasOwnProperty(i)&&(Q[i]=o[i]);o=null,Q.wasmBinary&&(R=Q.wasmBinary);var c,w={Memory:function(A){this.buffer=new ArrayBuffer(65536*A.initial)},Module:function(A){},Instance:function(A,I){this.exports=function(A){for(var I,g=new Uint8Array(123),C=25;C>=0;--C)g[48+C]=52+C,g[65+C]=C,g[97+C]=26+C;function Q(A,I,C){for(var Q,B,E=0,i=I,o=C.length,a=I+(3*o>>2)-("="==C[o-2])-("="==C[o-1]);E<o;E+=4)Q=g[C.charCodeAt(E+1)],B=g[C.charCodeAt(E+2)],A[i++]=g[C.charCodeAt(E)]<<2|Q>>4,i<a&&(A[i++]=Q<<4|B>>2),i<a&&(A[i++]=B<<6|g[C.charCodeAt(E+3)])}g[43]=62,g[47]=63;var B=new ArrayBuffer(16),E=new Int32Array(B),i=new Float32Array(B);function o(A){i[2]=A}function a(A){return E[A]}return function(A){var g=A.a,C=g.buffer;g.grow=function(A){A|=0;var Q=0|yQ(),E=Q+A|0;if(Q<E&&E<65536){var i=new ArrayBuffer(s(E,65536));new Int8Array(i).set(B),B=new Int8Array(i),r=new Int16Array(i),D=new Int32Array(i),e=new Uint8Array(i),f=new Uint16Array(i),k=new Uint32Array(i),t=new Float32Array(i),N=new Float64Array(i),g.buffer=C=i,I=e}return Q};var B=new Int8Array(C),r=new Int16Array(C),D=new Int32Array(C),e=new Uint8Array(C),f=new Uint16Array(C),k=new Uint32Array(C),t=new Float32Array(C),N=new Float64Array(C),s=Math.imul,F=Math.fround,n=Math.abs,R=Math.clz32,y=Math.min,G=Math.max,c=Math.floor,w=Math.ceil,b=Math.sqrt,U=A.abort,h=A.b,J=A.c,S=A.d,Y=A.e,K=A.f,M=A.g,l=A.h,L=A.i,d=5260336,u=0;function p(A,I,g){var C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0;d=C=d-672|0,Q=D[I+20>>2];A:{I:{g:if(!((r=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=r>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E)||(D[A>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,k[A>>2]>31||(Q=E,(E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B)||(D[A+4>>2]=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,Q=E,(E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B)||(D[A+12>>2]=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,G=B,D[I+16>>2]=B,D[I+20>>2]=Q,(0|(o=D[A+12>>2]))!=(0|(Q=D[A+20>>2]))&&Q||(Q=E,(E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))))))))if(D[A+16>>2]=E=e[0|(Q=G+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E>>>0>=7)D[C>>2]=E,HI(1857,C);else{D[C+664>>2]=g;C:if(o){Q:if(!(o>>>0<=(D[g+8>>2]-(r=D[g>>2])|0)/12>>>0)){if(!(o>>>0<357913942))break I;if(B=D[g+4>>2],o=(Q=DC(E=s(o,12)))+E|0,Q=E=Q+s((B-r|0)/12|0,12)|0,(0|B)!=(0|r))for(Q=E;D[(Q=Q-12|0)>>2]=D[(B=B-12|0)>>2],D[Q+4>>2]=D[B+4>>2],D[Q+8>>2]=D[B+8>>2],(0|B)!=(0|r););if(D[g+8>>2]=o,D[g+4>>2]=E,D[g>>2]=Q,!r)break Q;sA(r)}Q:switch(D[A+16>>2]){case 0:if(a=zA(C+8|0,3),G=C+664|0,Q=D[I+20>>2],!((r=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=r>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[a>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,!(k[a>>2]>32)&&(Q=E,!((E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[a+4>>2]=E=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[a+8>>2]=0,wI(a+16|0,I)&&wI(a+36|0,I)&&wI(a+56|0,I)&&wI(a+76|0,I)))))){if(J=D[a+4>>2],E=0,r=0,d=o=d-32|0,B=D[a+12>>2],D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,B){if(B>>>0>=1073741824)break A;E=DC(I=B<<2),D[o+8>>2]=E,D[o+16>>2]=r=I+E|0,bI(E,0,I),D[o+12>>2]=r}if((Q=D[(I=D[a+120>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,r=D[o+12>>2],B=D[a+12>>2],E=D[o+8>>2]),D[I+4>>2]=r,D[I>>2]=E,D[I+8>>2]=D[o+16>>2],E=0,D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,B){if(B>>>0>=1073741824)break A;i=DC(I=B<<2),D[o+8>>2]=i,D[o+16>>2]=E=I+i|0,bI(i,0,I),D[o+12>>2]=E}(Q=D[(I=D[a+132>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,i=D[o+8>>2],E=D[o+12>>2]),D[I+4>>2]=E,D[I>>2]=i,D[I+8>>2]=D[o+16>>2],D[o+24>>2]=0,D[o+28>>2]=0,D[o+16>>2]=0,D[o+20>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,AI(o+8|0),I=D[D[o+12>>2]+((Q=((I=D[o+24>>2]+D[o+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=J,D[o+28>>2]=B=(I=D[o+28>>2])+1|0;B:if(!(I>>>0>B>>>0))for(b=a+96|0;;){if(I=D[(y=D[o+12>>2])+((Q=((I=(E=D[o+24>>2])+(r=B-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,t=D[I+8>>2],i=D[I+4>>2],Q=D[I>>2],D[o+28>>2]=r,1+(((r=(I=D[o+16>>2])-y|0)?s(r>>2,341)-1|0:0)-(B+E|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[o+16>>2]=D[o+16>>2]-4),E=0,Q>>>0>J>>>0)break B;if((i=(0|i)==((I=D[a+12>>2])-1|0)?0:i+1|0)>>>0>=I>>>0)break B;r=(B=s(t,12))+D[a+120>>2]|0;E:{i:if(F=D[a>>2]-D[(N=i<<2)+D[(y=B+D[a+132>>2]|0)>>2]>>2]|0){o:{a:{r:{D:{if(Q>>>0<=2){if(D[(I=D[a+108>>2])>>2]=i,E=1,(B=D[a+12>>2])>>>0>1)break D;break o}if(k[a+8>>2]>k[a+4>>2])break B;(0|(E=(I=D[a+120>>2])+(y=s(f=t+1|0,12))|0))!=(0|r)&&(qI(E,D[r>>2],D[r+4>>2]),I=D[a+120>>2]),D[(I=N+D[I+y>>2]|0)>>2]=D[I>>2]+(1<<F-1);e:if((0|(I=31^R(Q)))<=(0|(F=32-(E=D[a+32>>2])|0))){if((0|(r=D[a+28>>2]))==D[a+20>>2]){E=0;break e}if(F=D[r>>2],D[a+32>>2]=n=I+E|0,E=F<<E>>>32-I|0,32!=(0|n))break e;D[a+32>>2]=0,D[a+28>>2]=r+4}else(0|(n=(r=D[a+28>>2])+4|0))!=D[a+20>>2]?(c=D[r>>2],D[a+28>>2]=n,D[a+32>>2]=F=I-F|0,E=D[r+4>>2]>>>32-F|c<<E>>>32-I):E=0;if((0|(E=Q-(I=(Q>>>1|0)-E|0)|0))!=(0|I)){if((0|(Q=D[a+88>>2]))==D[a+80>>2])break r;r=D[Q>>2],D[a+92>>2]=n=(F=D[a+92>>2])+1|0,r&=-2147483648>>>F;e:{if(32==(0|n)){if(D[a+92>>2]=0,D[a+88>>2]=Q+4,r)break e;break r}if(!r)break r}Q=E}else Q=I;E=I;break a}for(;D[I+(E<<2)>>2]=i=(B-1|0)==(0|i)?0:i+1|0,(E=E+1|0)>>>0<(B=D[a+12>>2])>>>0;);break o}Q=I}if(D[(N=(r=D[(B=(I=D[a+132>>2])+B|0)>>2])+N|0)>>2]=D[N>>2]+1,qI(I+y|0,r,D[B+4>>2]),E&&((0|(B=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(r=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),r=D[o+12>>2],B=D[o+24>>2]+D[o+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=i,D[I>>2]=E,D[o+28>>2]=D[o+28>>2]+1),!Q)break i;(0|(B=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(E=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),B=D[o+24>>2]+D[o+28>>2]|0,E=D[o+12>>2]),I=D[E+((I=(B>>>0)/341|0)<<2)>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=f,D[I+4>>2]=i,D[I>>2]=Q,D[o+28>>2]=B=D[o+28>>2]+1|0;break E}if(t=0,Q)for(;;){if(B)for(N=D[a+40>>2],i=D[a+96>>2],c=D[a+108>>2],S=D[r>>2],K=D[y>>2],B=0;;){D[i+(D[(F=c+(B<<2)|0)>>2]<<2)>>2]=0;o:if(I=D[a>>2]-D[(E=D[F>>2]<<2)+K>>2]|0)if(E=i+E|0,(0|(w=32-(f=D[a+52>>2])|0))>=(0|I)){if((0|(n=D[a+48>>2]))==(0|N)){D[E>>2]=0;break o}if(D[E>>2]=D[n>>2]<<f>>>32-I,D[a+52>>2]=I=I+D[a+52>>2]|0,32!=(0|I))break o;D[a+52>>2]=0,D[a+48>>2]=n+4}else(0|(h=(n=D[a+48>>2])+4|0))!=(0|N)?(Y=D[n>>2],D[a+48>>2]=h,D[a+52>>2]=w=I-w|0,D[E>>2]=D[n+4>>2]>>>32-w|Y<<f>>>32-I):D[E>>2]=0;if(D[(E=(I=D[F>>2]<<2)+i|0)>>2]=D[E>>2]|D[I+S>>2],!((B=B+1|0)>>>0<k[a+12>>2]))break}if(JI(G,b),D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(t=t+1|0)))break i;B=D[a+12>>2]}}else{if(!Q)break i;for(;;){if(y=D[(I=D[r>>2])+8>>2],N=D[I+4>>2],F=D[I>>2],(B=D[(I=D[G>>2])+4>>2])>>>0<(f=D[I+8>>2])>>>0)D[B+8>>2]=y,D[B+4>>2]=N,D[B>>2]=F,D[I+4>>2]=B+12;else{if((i=1+(n=(B-(t=D[I>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(c=(f=(f-t|0)/12|0)<<1,(i=f>>>0<178956970?i>>>0>c>>>0?i:c:357913941)>>>0>=357913942)break I;if(c=s(n,12),n=DC(f=s(i,12)),D[8+(i=c+n|0)>>2]=y,D[i+4>>2]=N,D[i>>2]=F,y=i+12|0,(0|B)!=(0|t))for(;D[(i=i-12|0)>>2]=D[(B=B-12|0)>>2],D[i+4>>2]=D[B+4>>2],D[i+8>>2]=D[B+8>>2],(0|B)!=(0|t););D[I+8>>2]=f+n,D[I+4>>2]=y,D[I>>2]=i,t&&sA(t)}if(D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(E=E+1|0)))break}}B=D[o+28>>2]}if(!B)break}if(D[o+28>>2]=0,(i=(B=D[o+16>>2])-(I=D[o+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[o+12>>2]=I=D[o+12>>2]+4|0,(i=(B=D[o+16>>2])-I>>2)>>>0>2;);E=170;B:switch(i-1|0){case 1:E=341;case 0:D[o+24>>2]=E}if((0|I)!=(0|B)){for(;sA(D[I>>2]),(0|B)!=(0|(I=I+4|0)););(0|(I=D[o+16>>2]))!=(0|(Q=D[o+12>>2]))&&(D[o+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[o+8>>2])&&sA(I),d=o+32|0}mI(a);break C;case 1:if(o=zA(C+8|0,3),J=C+664|0,Q=D[I+20>>2],!((i=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=i>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[o>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(i=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,r=B,D[I+16>>2]=B,D[I+20>>2]=Q,!(k[o>>2]>32)&&(Q=E,!((E=i+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[o+4>>2]=E=e[0|(Q=r+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[o+8>>2]=0,wI(o+16|0,I)&&wI(o+36|0,I)&&wI(o+56|0,I)&&wI(o+76|0,I)))))){if(y=D[o+4>>2],E=0,r=0,d=i=d-32|0,B=D[o+12>>2],D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;r=DC(I=B<<2),D[i+8>>2]=r,D[i+16>>2]=E=I+r|0,bI(r,0,I),D[i+12>>2]=E}if((Q=D[(I=D[o+120>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,r=D[i+8>>2],B=D[o+12>>2],E=D[i+12>>2]),D[I+4>>2]=E,D[I>>2]=r,D[I+8>>2]=D[i+16>>2],r=0,D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;t=DC(I=B<<2),D[i+8>>2]=t,D[i+16>>2]=r=I+t|0,bI(t,0,I),D[i+12>>2]=r}(Q=D[(I=D[o+132>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,t=D[i+8>>2],r=D[i+12>>2]),D[I+4>>2]=r,D[I>>2]=t,D[I+8>>2]=D[i+16>>2],D[i+24>>2]=0,D[i+28>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,AI(i+8|0),I=D[D[i+12>>2]+((Q=((I=D[i+24>>2]+D[i+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=y,D[i+28>>2]=B=(I=D[i+28>>2])+1|0;B:if(!(I>>>0>B>>>0))for(n=o+96|0;;){if(I=D[(t=D[i+12>>2])+((Q=((I=(E=D[i+24>>2])+(r=B-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,a=D[I+8>>2],Q=D[I+4>>2],I=D[I>>2],D[i+28>>2]=r,1+(((t=(r=D[i+16>>2])-t|0)?s(t>>2,341)-1|0:0)-(B+E|0)|0)>>>0>=682&&(sA(D[r-4>>2]),D[i+16>>2]=D[i+16>>2]-4),I>>>0>y>>>0)break B;if(E=0,(t=(0|Q)==((B=D[o+12>>2])-1|0)?0:Q+1|0)>>>0>=B>>>0)break B;G=(Q=D[o+120>>2])+(B=s(a,12))|0;E:{i:if(N=D[o>>2]-D[(r=t<<2)+D[(b=B+D[o+132>>2]|0)>>2]>>2]|0){o:{a:{r:{D:{if(I>>>0<=2){if(D[(Q=D[o+108>>2])>>2]=t,r=1,(B=D[o+12>>2])>>>0>1)break D;break o}if(k[o+8>>2]>k[o+4>>2])break B;qI((E=Q)+(Q=B+12|0)|0,D[G>>2],D[G+4>>2]),D[(Q=r+D[Q+D[o+120>>2]>>2]|0)>>2]=D[Q>>2]+(1<<N-1);e:if((0|(Q=31^R(I)))<=(0|(N=32-(E=D[o+32>>2])|0))){if((0|(G=D[o+28>>2]))==D[o+20>>2]){E=0;break e}if(N=D[G>>2],D[o+32>>2]=F=Q+E|0,E=N<<E>>>32-Q|0,32!=(0|F))break e;D[o+32>>2]=0,D[o+28>>2]=G+4}else(0|(F=(G=D[o+28>>2])+4|0))!=D[o+20>>2]?(f=D[G>>2],D[o+28>>2]=F,D[o+32>>2]=N=Q-N|0,E=D[G+4>>2]>>>32-N|f<<E>>>32-Q):E=0;if(G=a+1|0,(0|(E=(Q=I)-(I=(I>>>1|0)-E|0)|0))!=(0|I)){if((0|(Q=D[o+88>>2]))==D[o+80>>2])break r;N=D[Q>>2],D[o+92>>2]=f=(F=D[o+92>>2])+1|0,N&=-2147483648>>>F;e:{if(32==(0|f)){if(D[o+92>>2]=0,D[o+88>>2]=Q+4,N)break e;break r}if(!N)break r}Q=E}else Q=I;E=I;break a}for(;D[Q+(r<<2)>>2]=t=(B-1|0)==(0|t)?0:t+1|0,(r=r+1|0)>>>0<(B=D[o+12>>2])>>>0;);break o}Q=I}if(D[(N=(f=r)+(r=D[(B=(I=D[o+132>>2])+B|0)>>2])|0)>>2]=D[N>>2]+1,qI(I+s(G,12)|0,r,D[B+4>>2]),E&&((0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(r=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),r=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=a,D[I+4>>2]=t,D[I>>2]=E,D[i+28>>2]=D[i+28>>2]+1),!Q)break i;(0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(r=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),r=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=G,D[I+4>>2]=t,D[I>>2]=Q,D[i+28>>2]=B=D[i+28>>2]+1|0;break E}if(a=0,I)for(;;){if(B)for(t=D[o+40>>2],r=D[o+96>>2],c=D[o+108>>2],S=D[G>>2],K=D[b>>2],B=0;;){D[r+(D[(N=c+(B<<2)|0)>>2]<<2)>>2]=0;o:if(Q=D[o>>2]-D[(E=D[N>>2]<<2)+K>>2]|0)if(E=E+r|0,(0|(w=32-(F=D[o+52>>2])|0))>=(0|Q)){if((0|(f=D[o+48>>2]))==(0|t)){D[E>>2]=0;break o}if(D[E>>2]=D[f>>2]<<F>>>32-Q,D[o+52>>2]=Q=Q+D[o+52>>2]|0,32!=(0|Q))break o;D[o+52>>2]=0,D[o+48>>2]=f+4}else(0|(h=(f=D[o+48>>2])+4|0))!=(0|t)?(Y=D[f>>2],D[o+48>>2]=h,D[o+52>>2]=w=Q-w|0,D[E>>2]=D[f+4>>2]>>>32-w|Y<<F>>>32-Q):D[E>>2]=0;if(D[(E=(Q=D[N>>2]<<2)+r|0)>>2]=D[E>>2]|D[Q+S>>2],!((B=B+1|0)>>>0<k[o+12>>2]))break}if(JI(J,n),D[o+8>>2]=D[o+8>>2]+1,(0|I)==(0|(a=a+1|0)))break i;B=D[o+12>>2]}}else{if(!I)break i;for(;;){if(a=D[(Q=D[G>>2])+8>>2],N=D[Q+4>>2],F=D[Q>>2],(B=D[(Q=D[J>>2])+4>>2])>>>0<(f=D[Q+8>>2])>>>0)D[B+8>>2]=a,D[B+4>>2]=N,D[B>>2]=F,D[Q+4>>2]=B+12;else{if((t=1+(b=(B-(r=D[Q>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(c=(f=(f-r|0)/12|0)<<1,(t=f>>>0<178956970?t>>>0>c>>>0?t:c:357913941)>>>0>=357913942)break I;if(c=s(b,12),b=DC(f=s(t,12)),D[8+(t=c+b|0)>>2]=a,D[t+4>>2]=N,D[t>>2]=F,a=t+12|0,(0|B)!=(0|r))for(;D[(t=t-12|0)>>2]=D[(B=B-12|0)>>2],D[t+4>>2]=D[B+4>>2],D[t+8>>2]=D[B+8>>2],(0|B)!=(0|r););D[Q+8>>2]=f+b,D[Q+4>>2]=a,D[Q>>2]=t,r&&sA(r)}if(D[o+8>>2]=D[o+8>>2]+1,(0|I)==(0|(E=E+1|0)))break}}B=D[i+28>>2]}if(!B)break}if(D[i+28>>2]=0,(t=(B=D[i+16>>2])-(I=D[i+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[i+12>>2]=I=D[i+12>>2]+4|0,(t=(B=D[i+16>>2])-I>>2)>>>0>2;);r=170;B:switch(t-1|0){case 1:r=341;case 0:D[i+24>>2]=r}if((0|I)!=(0|B)){for(;sA(D[I>>2]),(0|B)!=(0|(I=I+4|0)););(0|(I=D[i+16>>2]))!=(0|(Q=D[i+12>>2]))&&(D[i+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[i+8>>2])&&sA(I),d=i+32|0}mI(o);break C;case 2:if(o=jA(C+8|0,3),G=C+664|0,Q=D[I+20>>2],!((i=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=i>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[o>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(i=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,r=B,D[I+16>>2]=B,D[I+20>>2]=Q,!(k[o>>2]>32)&&(Q=E,!((E=i+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[o+4>>2]=E=e[0|(Q=r+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[o+8>>2]=0,TA(o+16|0,I)&&wI(o+32|0,I)&&wI(o+52|0,I)&&wI(o+72|0,I)))))){if(J=D[o+4>>2],E=0,r=0,d=i=d-32|0,B=D[o+12>>2],D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;E=DC(I=B<<2),D[i+8>>2]=E,D[i+16>>2]=r=I+E|0,bI(E,0,I),D[i+12>>2]=r}if((Q=D[(I=D[o+116>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,r=D[i+12>>2],B=D[o+12>>2],E=D[i+8>>2]),D[I+4>>2]=r,D[I>>2]=E,D[I+8>>2]=D[i+16>>2],E=0,D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;a=DC(I=B<<2),D[i+8>>2]=a,D[i+16>>2]=E=I+a|0,bI(a,0,I),D[i+12>>2]=E}(Q=D[(I=D[o+128>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,a=D[i+8>>2],E=D[i+12>>2]),D[I+4>>2]=E,D[I>>2]=a,D[I+8>>2]=D[i+16>>2],D[i+24>>2]=0,D[i+28>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,AI(i+8|0),I=D[D[i+12>>2]+((Q=((I=D[i+24>>2]+D[i+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=J,D[i+28>>2]=B=(I=D[i+28>>2])+1|0;B:if(!(I>>>0>B>>>0))for(b=o+92|0,c=o+16|0;;){if(I=D[(y=D[i+12>>2])+((Q=((I=(E=D[i+24>>2])+(a=B-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,t=D[I+8>>2],r=D[I+4>>2],Q=D[I>>2],D[i+28>>2]=a,1+(((a=(I=D[i+16>>2])-y|0)?s(a>>2,341)-1|0:0)-(B+E|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[i+16>>2]=D[i+16>>2]-4),E=0,Q>>>0>J>>>0)break B;if((a=(0|r)==((I=D[o+12>>2])-1|0)?0:r+1|0)>>>0>=I>>>0)break B;r=(B=s(t,12))+D[o+116>>2]|0;E:if(F=D[o>>2]-D[(N=a<<2)+D[(y=B+D[o+128>>2]|0)>>2]>>2]|0){i:{o:{a:{r:{if(Q>>>0<=2){if(D[(I=D[o+104>>2])>>2]=a,E=1,(B=D[o+12>>2])>>>0>1)break r;break i}if(k[o+8>>2]>k[o+4>>2])break B;if((0|(E=(I=D[o+116>>2])+(y=s(f=t+1|0,12))|0))!=(0|r)&&(qI(E,D[r>>2],D[r+4>>2]),I=D[o+116>>2]),D[(I=N+D[I+y>>2]|0)>>2]=D[I>>2]+(1<<F-1),D[i+4>>2]=0,eg(c,31^R(Q),i+4|0),(0|(E=Q-(I=(Q>>>1|0)-D[i+4>>2]|0)|0))!=(0|I)){if((0|(Q=D[o+84>>2]))==D[o+76>>2])break a;r=D[Q>>2],D[o+88>>2]=n=(F=D[o+88>>2])+1|0,r&=-2147483648>>>F;D:{if(32==(0|n)){if(D[o+88>>2]=0,D[o+84>>2]=Q+4,r)break D;break a}if(!r)break a}Q=E}else Q=I;E=I;break o}for(;D[I+(E<<2)>>2]=a=(B-1|0)==(0|a)?0:a+1|0,(B=D[o+12>>2])>>>0>(E=E+1|0)>>>0;);break i}Q=I}if(D[(N=(r=D[(B=(I=D[o+128>>2])+B|0)>>2])+N|0)>>2]=D[N>>2]+1,qI(I+y|0,r,D[B+4>>2]),E&&((0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(r=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),r=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=a,D[I>>2]=E,D[i+28>>2]=D[i+28>>2]+1),!Q)break E;(0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(E=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),B=D[i+24>>2]+D[i+28>>2]|0,E=D[i+12>>2]),I=D[E+((I=(B>>>0)/341|0)<<2)>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=f,D[I+4>>2]=a,D[I>>2]=Q,D[i+28>>2]=D[i+28>>2]+1;break E}if(a=0,Q)for(;;){if(B)for(N=D[o+36>>2],t=D[o+92>>2],S=D[o+104>>2],K=D[r>>2],w=D[y>>2],B=0;;){D[t+(D[(F=S+(B<<2)|0)>>2]<<2)>>2]=0;i:if(I=D[o>>2]-D[(E=D[F>>2]<<2)+w>>2]|0)if(E=E+t|0,(0|(h=32-(f=D[o+48>>2])|0))>=(0|I)){if((0|(n=D[o+44>>2]))==(0|N)){D[E>>2]=0;break i}if(D[E>>2]=D[n>>2]<<f>>>32-I,D[o+48>>2]=I=I+D[o+48>>2]|0,32!=(0|I))break i;D[o+48>>2]=0,D[o+44>>2]=n+4}else(0|(Y=(n=D[o+44>>2])+4|0))!=(0|N)?(M=D[n>>2],D[o+44>>2]=Y,D[o+48>>2]=h=I-h|0,D[E>>2]=D[n+4>>2]>>>32-h|M<<f>>>32-I):D[E>>2]=0;if(D[(E=(I=D[F>>2]<<2)+t|0)>>2]=D[E>>2]|D[I+K>>2],!((B=B+1|0)>>>0<k[o+12>>2]))break}if(JI(G,b),D[o+8>>2]=D[o+8>>2]+1,(0|Q)==(0|(a=a+1|0)))break E;B=D[o+12>>2]}}else{if(!Q)break E;for(;;){if(y=D[(I=D[r>>2])+8>>2],N=D[I+4>>2],F=D[I>>2],(B=D[(I=D[G>>2])+4>>2])>>>0<(f=D[I+8>>2])>>>0)D[B+8>>2]=y,D[B+4>>2]=N,D[B>>2]=F,D[I+4>>2]=B+12;else{if((a=1+(n=(B-(t=D[I>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(S=(f=(f-t|0)/12|0)<<1,(a=f>>>0<178956970?a>>>0>S>>>0?a:S:357913941)>>>0>=357913942)break I;if(w=s(n,12),n=DC(f=s(a,12)),D[8+(a=w+n|0)>>2]=y,D[a+4>>2]=N,D[a>>2]=F,y=a+12|0,(0|B)!=(0|t))for(;D[(a=a-12|0)>>2]=D[(B=B-12|0)>>2],D[a+4>>2]=D[B+4>>2],D[a+8>>2]=D[B+8>>2],(0|B)!=(0|t););D[I+8>>2]=f+n,D[I+4>>2]=y,D[I>>2]=a,t&&sA(t)}if(D[o+8>>2]=D[o+8>>2]+1,(0|Q)==(0|(E=E+1|0)))break}}if(!(B=D[i+28>>2]))break}if(D[i+28>>2]=0,(a=(B=D[i+16>>2])-(I=D[i+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[i+12>>2]=I=D[i+12>>2]+4|0,(a=(B=D[i+16>>2])-I>>2)>>>0>2;);E=170;B:switch(a-1|0){case 1:E=341;case 0:D[i+24>>2]=E}if((0|I)!=(0|B)){for(;sA(D[I>>2]),(0|B)!=(0|(I=I+4|0)););(0|(I=D[i+16>>2]))!=(0|(Q=D[i+12>>2]))&&(D[i+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[i+8>>2])&&sA(I),d=i+32|0}jI(o);break C;case 3:if(o=jA(C+8|0,3),J=C+664|0,Q=D[I+20>>2],!((i=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=i>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[o>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(i=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,r=B,D[I+16>>2]=B,D[I+20>>2]=Q,!(k[o>>2]>32)&&(Q=E,!((E=i+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[o+4>>2]=E=e[0|(Q=r+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[o+8>>2]=0,TA(o+16|0,I)&&wI(o+32|0,I)&&wI(o+52|0,I)&&wI(o+72|0,I)))))){if(y=D[o+4>>2],r=0,E=0,d=i=d-32|0,B=D[o+12>>2],D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;r=DC(I=B<<2),D[i+8>>2]=r,D[i+16>>2]=E=I+r|0,bI(r,0,I),D[i+12>>2]=E}if((Q=D[(I=D[o+116>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,r=D[i+8>>2],B=D[o+12>>2],E=D[i+12>>2]),D[I+4>>2]=E,D[I>>2]=r,D[I+8>>2]=D[i+16>>2],r=0,D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,B){if(B>>>0>=1073741824)break A;a=DC(I=B<<2),D[i+8>>2]=a,D[i+16>>2]=r=I+a|0,bI(a,0,I),D[i+12>>2]=r}(Q=D[(I=D[o+128>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,a=D[i+8>>2],r=D[i+12>>2]),D[I+4>>2]=r,D[I>>2]=a,D[I+8>>2]=D[i+16>>2],D[i+24>>2]=0,D[i+28>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,AI(i+8|0),I=D[D[i+12>>2]+((Q=((I=D[i+24>>2]+D[i+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=y,D[i+28>>2]=B=(I=D[i+28>>2])+1|0;B:if(!(I>>>0>B>>>0))for(n=o+92|0,b=o+16|0;;){if(I=D[(a=D[i+12>>2])+((Q=((I=(E=D[i+24>>2])+(r=B-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,G=D[I+8>>2],Q=D[I+4>>2],I=D[I>>2],D[i+28>>2]=r,1+(((a=(r=D[i+16>>2])-a|0)?s(a>>2,341)-1|0:0)-(B+E|0)|0)>>>0>=682&&(sA(D[r-4>>2]),D[i+16>>2]=D[i+16>>2]-4),I>>>0>y>>>0)break B;if(E=0,(a=(0|Q)==((B=D[o+12>>2])-1|0)?0:Q+1|0)>>>0>=B>>>0)break B;t=(Q=D[o+116>>2])+(B=s(G,12))|0;E:if(N=D[o>>2]-D[(r=a<<2)+D[(c=B+D[o+128>>2]|0)>>2]>>2]|0){i:{o:{a:{r:{if(I>>>0<=2){if(D[(Q=D[o+104>>2])>>2]=a,r=1,(B=D[o+12>>2])>>>0>1)break r;break i}if(k[o+8>>2]>k[o+4>>2])break B;if(qI((E=Q)+(Q=B+12|0)|0,D[t>>2],D[t+4>>2]),D[(Q=r+D[Q+D[o+116>>2]>>2]|0)>>2]=D[Q>>2]+(1<<N-1),D[i+4>>2]=0,eg(b,31^R(I),i+4|0),t=G+1|0,(0|(E=(Q=I)-(I=(I>>>1|0)-D[i+4>>2]|0)|0))!=(0|I)){if((0|(Q=D[o+84>>2]))==D[o+76>>2])break a;N=D[Q>>2],D[o+88>>2]=f=(F=D[o+88>>2])+1|0,N&=-2147483648>>>F;D:{if(32==(0|f)){if(D[o+88>>2]=0,D[o+84>>2]=Q+4,N)break D;break a}if(!N)break a}Q=E}else Q=I;E=I;break o}for(;D[Q+(r<<2)>>2]=a=(B-1|0)==(0|a)?0:a+1|0,(B=D[o+12>>2])>>>0>(r=r+1|0)>>>0;);break i}Q=I}if(D[(N=(f=r)+(r=D[(B=(I=D[o+128>>2])+B|0)>>2])|0)>>2]=D[N>>2]+1,qI(I+s(t,12)|0,r,D[B+4>>2]),E&&((0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(r=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),r=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=G,D[I+4>>2]=a,D[I>>2]=E,D[i+28>>2]=D[i+28>>2]+1),!Q)break E;(0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(r=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),r=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=a,D[I>>2]=Q,D[i+28>>2]=D[i+28>>2]+1;break E}if(a=0,I)for(;;){if(B)for(G=D[o+36>>2],r=D[o+92>>2],S=D[o+104>>2],K=D[t>>2],w=D[c>>2],B=0;;){D[r+(D[(N=S+(B<<2)|0)>>2]<<2)>>2]=0;i:if(Q=D[o>>2]-D[(E=D[N>>2]<<2)+w>>2]|0)if(E=E+r|0,(0|(h=32-(F=D[o+48>>2])|0))>=(0|Q)){if((0|(f=D[o+44>>2]))==(0|G)){D[E>>2]=0;break i}if(D[E>>2]=D[f>>2]<<F>>>32-Q,D[o+48>>2]=Q=Q+D[o+48>>2]|0,32!=(0|Q))break i;D[o+48>>2]=0,D[o+44>>2]=f+4}else(0|(Y=(f=D[o+44>>2])+4|0))!=(0|G)?(M=D[f>>2],D[o+44>>2]=Y,D[o+48>>2]=h=Q-h|0,D[E>>2]=D[f+4>>2]>>>32-h|M<<F>>>32-Q):D[E>>2]=0;if(D[(E=(Q=D[N>>2]<<2)+r|0)>>2]=D[E>>2]|D[Q+K>>2],!((B=B+1|0)>>>0<k[o+12>>2]))break}if(JI(J,n),D[o+8>>2]=D[o+8>>2]+1,(0|I)==(0|(a=a+1|0)))break E;B=D[o+12>>2]}}else{if(!I)break E;for(;;){if(G=D[(Q=D[t>>2])+8>>2],N=D[Q+4>>2],F=D[Q>>2],(B=D[(Q=D[J>>2])+4>>2])>>>0<(f=D[Q+8>>2])>>>0)D[B+8>>2]=G,D[B+4>>2]=N,D[B>>2]=F,D[Q+4>>2]=B+12;else{if((a=1+(c=(B-(r=D[Q>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(S=(f=(f-r|0)/12|0)<<1,(a=f>>>0<178956970?a>>>0>S>>>0?a:S:357913941)>>>0>=357913942)break I;if(w=s(c,12),c=DC(f=s(a,12)),D[8+(a=w+c|0)>>2]=G,D[a+4>>2]=N,D[a>>2]=F,G=a+12|0,(0|B)!=(0|r))for(;D[(a=a-12|0)>>2]=D[(B=B-12|0)>>2],D[a+4>>2]=D[B+4>>2],D[a+8>>2]=D[B+8>>2],(0|B)!=(0|r););D[Q+8>>2]=f+c,D[Q+4>>2]=G,D[Q>>2]=a,r&&sA(r)}if(D[o+8>>2]=D[o+8>>2]+1,(0|I)==(0|(E=E+1|0)))break}}if(!(B=D[i+28>>2]))break}if(D[i+28>>2]=0,(a=(B=D[i+16>>2])-(I=D[i+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[i+12>>2]=I=D[i+12>>2]+4|0,(a=(B=D[i+16>>2])-I>>2)>>>0>2;);r=170;B:switch(a-1|0){case 1:r=341;case 0:D[i+24>>2]=r}if((0|I)!=(0|B)){for(;sA(D[I>>2]),(0|B)!=(0|(I=I+4|0)););(0|(I=D[i+16>>2]))!=(0|(Q=D[i+12>>2]))&&(D[i+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[i+8>>2])&&sA(I),d=i+32|0}jI(o);break C;case 4:if(a=z(C+8|0,3),G=C+664|0,Q=D[I+20>>2],!((r=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=r>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[a>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,!(k[a>>2]>32)&&(Q=E,!((E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[a+4>>2]=E=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[a+8>>2]=0,iI(a+16|0,I)&&wI(a+544|0,I)&&wI(a+564|0,I)&&wI(a+584|0,I)))))){if(J=D[a+4>>2],B=0,Q=0,d=o=d-32|0,E=D[a+12>>2],D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,E){if(E>>>0>=1073741824)break A;B=DC(I=E<<2),D[o+8>>2]=B,D[o+16>>2]=Q=I+B|0,bI(B,0,I),D[o+12>>2]=Q}if((r=D[(I=D[a+628>>2])>>2])&&(D[I+4>>2]=r,sA(r),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,E=D[a+12>>2],B=D[o+8>>2],Q=D[o+12>>2]),D[I+4>>2]=Q,D[I>>2]=B,D[I+8>>2]=D[o+16>>2],B=0,D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,E){if(E>>>0>=1073741824)break A;i=DC(I=E<<2),D[o+8>>2]=i,D[o+16>>2]=B=I+i|0,bI(i,0,I),D[o+12>>2]=B}(Q=D[(I=D[a+640>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,i=D[o+8>>2],B=D[o+12>>2]),D[I+4>>2]=B,D[I>>2]=i,D[I+8>>2]=D[o+16>>2],D[o+24>>2]=0,D[o+28>>2]=0,D[o+16>>2]=0,D[o+20>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,AI(o+8|0),I=D[D[o+12>>2]+((Q=((I=D[o+24>>2]+D[o+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=J,D[o+28>>2]=E=(I=D[o+28>>2])+1|0;B:if(!(I>>>0>E>>>0))for(b=a+604|0;;){if(I=D[(y=D[o+12>>2])+((Q=((I=(i=D[o+24>>2])+(r=E-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,t=D[I+8>>2],B=D[I+4>>2],Q=D[I>>2],D[o+28>>2]=r,1+(((r=(I=D[o+16>>2])-y|0)?s(r>>2,341)-1|0:0)-(i+E|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[o+16>>2]=D[o+16>>2]-4),Q>>>0>J>>>0)break B;if((i=(0|B)==((I=D[a+12>>2])-1|0)?0:B+1|0)>>>0>=I>>>0)break B;r=(y=s(t,12))+D[a+628>>2]|0;E:{i:if(E=D[a>>2]-D[(F=i<<2)+D[(N=y+D[a+640>>2]|0)>>2]>>2]|0){o:{a:{r:{D:{if(Q>>>0<=2){if(D[(I=D[a+616>>2])>>2]=i,B=1,(E=D[a+12>>2])>>>0>1)break D;break o}if(k[a+8>>2]>k[a+4>>2])break B;if((0|(B=(I=D[a+628>>2])+(N=s(f=t+1|0,12))|0))!=(0|r)&&(qI(B,D[r>>2],D[r+4>>2]),I=D[a+628>>2]),D[(I=F+D[I+N>>2]|0)>>2]=D[I>>2]+(1<<E-1),B=0,E=0,I=31^R(Q))for(;B=ug(16+(a+(E<<4)|0)|0)|B<<1,(0|I)!=(0|(E=E+1|0)););if((0|(E=Q-(I=(Q>>>1|0)-B|0)|0))!=(0|I)){if((0|(Q=D[a+596>>2]))==D[a+588>>2])break r;B=D[Q>>2],D[a+600>>2]=n=(r=D[a+600>>2])+1|0,B&=-2147483648>>>r;e:{if(32==(0|n)){if(D[a+600>>2]=0,D[a+596>>2]=Q+4,B)break e;break r}if(!B)break r}Q=E}else Q=I;E=I;break a}for(;D[I+(B<<2)>>2]=i=(E-1|0)==(0|i)?0:i+1|0,(E=D[a+12>>2])>>>0>(B=B+1|0)>>>0;);break o}Q=I}if(D[(y=(r=D[(B=(I=D[a+640>>2])+y|0)>>2])+F|0)>>2]=D[y>>2]+1,qI(I+N|0,r,D[B+4>>2]),E&&((0|(B=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(r=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),r=D[o+12>>2],B=D[o+24>>2]+D[o+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=i,D[I>>2]=E,D[o+28>>2]=D[o+28>>2]+1),!Q)break i;(0|(E=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(B=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),B=D[o+12>>2],E=D[o+24>>2]+D[o+28>>2]|0),I=D[((I=(E>>>0)/341|0)<<2)+B>>2]+s(E-s(I,341)|0,12)|0,D[I+8>>2]=f,D[I+4>>2]=i,D[I>>2]=Q,D[o+28>>2]=E=D[o+28>>2]+1|0;break E}if(I=0,Q)for(;;){if(E)for(y=D[a+548>>2],t=D[a+604>>2],c=D[a+616>>2],S=D[r>>2],K=D[N>>2],E=0;;){D[t+(D[(F=c+(E<<2)|0)>>2]<<2)>>2]=0;o:if(B=D[a>>2]-D[(i=D[F>>2]<<2)+K>>2]|0)if(i=i+t|0,(0|(w=32-(f=D[a+560>>2])|0))>=(0|B)){if((0|(n=D[a+556>>2]))==(0|y)){D[i>>2]=0;break o}if(D[i>>2]=D[n>>2]<<f>>>32-B,D[a+560>>2]=B=B+D[a+560>>2]|0,32!=(0|B))break o;D[a+560>>2]=0,D[a+556>>2]=n+4}else(0|(h=(n=D[a+556>>2])+4|0))!=(0|y)?(Y=D[n>>2],D[a+556>>2]=h,D[a+560>>2]=w=B-w|0,D[i>>2]=D[n+4>>2]>>>32-w|Y<<f>>>32-B):D[i>>2]=0;if(D[(i=(B=D[F>>2]<<2)+t|0)>>2]=D[i>>2]|D[B+S>>2],!((E=E+1|0)>>>0<k[a+12>>2]))break}if(JI(G,b),D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(I=I+1|0)))break i;E=D[a+12>>2]}}else{if(I=0,!Q)break i;for(;;){if(y=D[(E=D[r>>2])+8>>2],N=D[E+4>>2],F=D[E>>2],(E=D[(B=D[G>>2])+4>>2])>>>0<(f=D[B+8>>2])>>>0)D[E+8>>2]=y,D[E+4>>2]=N,D[E>>2]=F,D[B+4>>2]=E+12;else{if((i=1+(n=(E-(t=D[B>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(c=(f=(f-t|0)/12|0)<<1,(i=f>>>0<178956970?i>>>0>c>>>0?i:c:357913941)>>>0>=357913942)break I;if(c=s(n,12),n=DC(f=s(i,12)),D[8+(i=c+n|0)>>2]=y,D[i+4>>2]=N,D[i>>2]=F,y=i+12|0,(0|E)!=(0|t))for(;D[(i=i-12|0)>>2]=D[(E=E-12|0)>>2],D[i+4>>2]=D[E+4>>2],D[i+8>>2]=D[E+8>>2],(0|E)!=(0|t););D[B+8>>2]=f+n,D[B+4>>2]=y,D[B>>2]=i,t&&sA(t)}if(D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(I=I+1|0)))break}}E=D[o+28>>2]}if(!E)break}if(D[o+28>>2]=0,(i=(E=D[o+16>>2])-(I=D[o+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[o+12>>2]=I=D[o+12>>2]+4|0,(i=(E=D[o+16>>2])-I>>2)>>>0>2;);Q=170;B:switch(i-1|0){case 1:Q=341;case 0:D[o+24>>2]=Q}if((0|I)!=(0|E)){for(;sA(D[I>>2]),(0|E)!=(0|(I=I+4|0)););(0|(I=D[o+16>>2]))!=(0|(Q=D[o+12>>2]))&&(D[o+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[o+8>>2])&&sA(I),d=o+32|0}XI(a);break C;case 5:if(r=z(C+8|0,3),J=C+664|0,Q=D[I+20>>2],!((i=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=i>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[r>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(i=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,!(k[r>>2]>32)&&(Q=E,!((E=i+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[r+4>>2]=E=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[r+8>>2]=0,iI(r+16|0,I)&&wI(r+544|0,I)&&wI(r+564|0,I)&&wI(r+584|0,I)))))){if(y=D[r+4>>2],B=0,Q=0,d=i=d-32|0,E=D[r+12>>2],D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,E){if(E>>>0>=1073741824)break A;B=DC(I=E<<2),D[i+8>>2]=B,D[i+16>>2]=Q=I+B|0,bI(B,0,I),D[i+12>>2]=Q}if((o=D[(I=D[r+628>>2])>>2])&&(D[I+4>>2]=o,sA(o),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,E=D[r+12>>2],B=D[i+8>>2],Q=D[i+12>>2]),D[I+4>>2]=Q,D[I>>2]=B,D[I+8>>2]=D[i+16>>2],B=0,D[i+16>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,E){if(E>>>0>=1073741824)break A;a=DC(I=E<<2),D[i+8>>2]=a,D[i+16>>2]=B=I+a|0,bI(a,0,I),D[i+12>>2]=B}(Q=D[(I=D[r+640>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,a=D[i+8>>2],B=D[i+12>>2]),D[I+4>>2]=B,D[I>>2]=a,D[I+8>>2]=D[i+16>>2],D[i+24>>2]=0,D[i+28>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,AI(i+8|0),I=D[D[i+12>>2]+((Q=((I=D[i+24>>2]+D[i+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=y,D[i+28>>2]=E=(I=D[i+28>>2])+1|0;B:if(!(I>>>0>E>>>0))for(n=r+604|0;;){if(I=D[(a=D[i+12>>2])+((Q=((I=(B=D[i+24>>2])+(o=E-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,G=D[I+8>>2],Q=D[I+4>>2],I=D[I>>2],D[i+28>>2]=o,1+(((a=(o=D[i+16>>2])-a|0)?s(a>>2,341)-1|0:0)-(B+E|0)|0)>>>0>=682&&(sA(D[o-4>>2]),D[i+16>>2]=D[i+16>>2]-4),I>>>0>y>>>0)break B;if((a=(0|Q)==((E=D[r+12>>2])-1|0)?0:Q+1|0)>>>0>=E>>>0)break B;t=(Q=D[r+628>>2])+(o=s(G,12))|0;E:{i:if(E=D[r>>2]-D[(N=a<<2)+D[(b=o+D[r+640>>2]|0)>>2]>>2]|0){o:{a:{r:{D:{if(I>>>0<=2){if(D[(Q=D[r+616>>2])>>2]=a,B=1,(E=D[r+12>>2])>>>0>1)break D;break o}if(k[r+8>>2]>k[r+4>>2])break B;if(qI((B=Q)+(Q=o+12|0)|0,D[t>>2],D[t+4>>2]),D[(Q=N+D[Q+D[r+628>>2]>>2]|0)>>2]=D[Q>>2]+(1<<E-1),B=0,E=0,Q=31^R(I))for(;B=ug(16+(r+(E<<4)|0)|0)|B<<1,(0|Q)!=(0|(E=E+1|0)););if(t=G+1|0,(0|(E=(Q=I)-(I=(I>>>1|0)-B|0)|0))!=(0|I)){if((0|(Q=D[r+596>>2]))==D[r+588>>2])break r;B=D[Q>>2],D[r+600>>2]=f=(F=D[r+600>>2])+1|0,B&=-2147483648>>>F;e:{if(32==(0|f)){if(D[r+600>>2]=0,D[r+596>>2]=Q+4,B)break e;break r}if(!B)break r}Q=E}else Q=I;E=I;break a}for(;D[Q+(B<<2)>>2]=a=(E-1|0)==(0|a)?0:a+1|0,(E=D[r+12>>2])>>>0>(B=B+1|0)>>>0;);break o}Q=I}if(D[(N=(o=D[(B=(I=D[r+640>>2])+o|0)>>2])+N|0)>>2]=D[N>>2]+1,qI(I+s(t,12)|0,o,D[B+4>>2]),E&&((0|(B=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(o=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),o=D[i+12>>2],B=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+o>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=G,D[I+4>>2]=a,D[I>>2]=E,D[i+28>>2]=D[i+28>>2]+1),!Q)break i;(0|(E=D[i+28>>2]+D[i+24>>2]|0))==(0|((I=D[i+16>>2]-(B=D[i+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(i+8|0),B=D[i+12>>2],E=D[i+24>>2]+D[i+28>>2]|0),I=D[((I=(E>>>0)/341|0)<<2)+B>>2]+s(E-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=a,D[I>>2]=Q,D[i+28>>2]=E=D[i+28>>2]+1|0;break E}if(o=0,I)for(;;){if(E)for(G=D[r+548>>2],a=D[r+604>>2],c=D[r+616>>2],S=D[t>>2],K=D[b>>2],E=0;;){D[a+(D[(N=c+(E<<2)|0)>>2]<<2)>>2]=0;o:if(Q=D[r>>2]-D[(B=D[N>>2]<<2)+K>>2]|0)if(B=B+a|0,(0|(w=32-(F=D[r+560>>2])|0))>=(0|Q)){if((0|(f=D[r+556>>2]))==(0|G)){D[B>>2]=0;break o}if(D[B>>2]=D[f>>2]<<F>>>32-Q,D[r+560>>2]=Q=Q+D[r+560>>2]|0,32!=(0|Q))break o;D[r+560>>2]=0,D[r+556>>2]=f+4}else(0|(h=(f=D[r+556>>2])+4|0))!=(0|G)?(Y=D[f>>2],D[r+556>>2]=h,D[r+560>>2]=w=Q-w|0,D[B>>2]=D[f+4>>2]>>>32-w|Y<<F>>>32-Q):D[B>>2]=0;if(D[(B=(Q=D[N>>2]<<2)+a|0)>>2]=D[B>>2]|D[Q+S>>2],!((E=E+1|0)>>>0<k[r+12>>2]))break}if(JI(J,n),D[r+8>>2]=D[r+8>>2]+1,(0|I)==(0|(o=o+1|0)))break i;E=D[r+12>>2]}}else{if(o=0,!I)break i;for(;;){if(G=D[(Q=D[t>>2])+8>>2],N=D[Q+4>>2],F=D[Q>>2],(E=D[(Q=D[J>>2])+4>>2])>>>0<(f=D[Q+8>>2])>>>0)D[E+8>>2]=G,D[E+4>>2]=N,D[E>>2]=F,D[Q+4>>2]=E+12;else{if((a=1+(b=(E-(B=D[Q>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(c=(f=(f-B|0)/12|0)<<1,(a=f>>>0<178956970?a>>>0>c>>>0?a:c:357913941)>>>0>=357913942)break I;if(c=s(b,12),b=DC(f=s(a,12)),D[8+(a=c+b|0)>>2]=G,D[a+4>>2]=N,D[a>>2]=F,G=a+12|0,(0|B)!=(0|E))for(;D[(a=a-12|0)>>2]=D[(E=E-12|0)>>2],D[a+4>>2]=D[E+4>>2],D[a+8>>2]=D[E+8>>2],(0|B)!=(0|E););D[Q+8>>2]=f+b,D[Q+4>>2]=G,D[Q>>2]=a,B&&sA(B)}if(D[r+8>>2]=D[r+8>>2]+1,(0|I)==(0|(o=o+1|0)))break}}E=D[i+28>>2]}if(!E)break}if(D[i+28>>2]=0,(a=(E=D[i+16>>2])-(I=D[i+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[i+12>>2]=I=D[i+12>>2]+4|0,(a=(E=D[i+16>>2])-I>>2)>>>0>2;);B=170;B:switch(a-1|0){case 1:B=341;case 0:D[i+24>>2]=B}if((0|I)!=(0|E)){for(;sA(D[I>>2]),(0|E)!=(0|(I=I+4|0)););(0|(I=D[i+16>>2]))!=(0|(Q=D[i+12>>2]))&&(D[i+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[i+8>>2])&&sA(I),d=i+32|0}XI(r);break C;case 6:break Q;default:break g}if(a=z(C+8|0,3),G=C+664|0,Q=D[I+20>>2],!((r=(B=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=r>>>0<4?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E))&&(D[a>>2]=e[0|(Q=B+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,E=Q=D[I+20>>2],Q=(B=(r=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=o=B,D[I+20>>2]=Q,!(k[a>>2]>32)&&(Q=E,!((E=r+8|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<8?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B))&&(D[a+4>>2]=E=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,E&&(D[a+8>>2]=0,iI(a+16|0,I)&&wI(a+544|0,I)&&wI(a+564|0,I)&&wI(a+584|0,I)))))){if(J=D[a+4>>2],B=0,Q=0,d=o=d-32|0,E=D[a+12>>2],D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,E){if(E>>>0>=1073741824)break A;B=DC(I=E<<2),D[o+8>>2]=B,D[o+16>>2]=Q=I+B|0,bI(B,0,I),D[o+12>>2]=Q}if((r=D[(I=D[a+628>>2])>>2])&&(D[I+4>>2]=r,sA(r),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,E=D[a+12>>2],B=D[o+8>>2],Q=D[o+12>>2]),D[I+4>>2]=Q,D[I>>2]=B,D[I+8>>2]=D[o+16>>2],B=0,D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,E){if(E>>>0>=1073741824)break A;i=DC(I=E<<2),D[o+8>>2]=i,D[o+16>>2]=B=I+i|0,bI(i,0,I),D[o+12>>2]=B}(Q=D[(I=D[a+640>>2])>>2])&&(D[I+4>>2]=Q,sA(Q),D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,i=D[o+8>>2],B=D[o+12>>2]),D[I+4>>2]=B,D[I>>2]=i,D[I+8>>2]=D[o+16>>2],D[o+24>>2]=0,D[o+28>>2]=0,D[o+16>>2]=0,D[o+20>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,AI(o+8|0),I=D[D[o+12>>2]+((Q=((I=D[o+24>>2]+D[o+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(I-s(Q,341)|0,12)|0,D[I+4>>2]=0,D[I+8>>2]=0,D[I>>2]=J,D[o+28>>2]=E=(I=D[o+28>>2])+1|0;Q:if(!(I>>>0>E>>>0))for(b=a+604|0;;){if(Q=D[(r=D[o+12>>2])+((i=((Q=(I=D[o+24>>2])+(B=E-1|0)|0)>>>0)/341|0)<<2)>>2]+s(Q-s(i,341)|0,12)|0,t=D[Q+8>>2],Q=D[Q>>2],D[o+28>>2]=B,1+(((i=(B=D[o+16>>2])-r|0)?s(i>>2,341)-1|0:0)-(I+E|0)|0)>>>0>=682&&(sA(D[B-4>>2]),D[o+16>>2]=D[o+16>>2]-4),Q>>>0>J>>>0)break Q;if(I=D[a+628>>2],(i=kI(a,Q,N=(y=s(t,12))+D[a+640>>2]|0))>>>0>=k[a+12>>2])break Q;r=I+y|0;B:{E:if(E=D[a>>2]-D[(F=i<<2)+D[N>>2]>>2]|0){i:{o:{a:{r:{if(Q>>>0<=2){if(D[(I=D[a+616>>2])>>2]=i,B=1,(E=D[a+12>>2])>>>0>1)break r;break i}if(k[a+8>>2]>k[a+4>>2])break Q;if((0|(B=(I=D[a+628>>2])+(N=s(f=t+1|0,12))|0))!=(0|r)&&(qI(B,D[r>>2],D[r+4>>2]),I=D[a+628>>2]),D[(I=F+D[I+N>>2]|0)>>2]=D[I>>2]+(1<<E-1),B=0,E=0,I=31^R(Q))for(;B=ug(16+(a+(E<<4)|0)|0)|B<<1,(0|I)!=(0|(E=E+1|0)););if((0|(E=Q-(I=(Q>>>1|0)-B|0)|0))!=(0|I)){if((0|(Q=D[a+596>>2]))==D[a+588>>2])break a;B=D[Q>>2],D[a+600>>2]=n=(r=D[a+600>>2])+1|0,B&=-2147483648>>>r;D:{if(32==(0|n)){if(D[a+600>>2]=0,D[a+596>>2]=Q+4,B)break D;break a}if(!B)break a}Q=E}else Q=I;E=I;break o}for(;D[I+(B<<2)>>2]=i=(E-1|0)==(0|i)?0:i+1|0,(E=D[a+12>>2])>>>0>(B=B+1|0)>>>0;);break i}Q=I}if(D[(y=(r=D[(B=(I=D[a+640>>2])+y|0)>>2])+F|0)>>2]=D[y>>2]+1,qI(I+N|0,r,D[B+4>>2]),E&&((0|(B=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(r=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),r=D[o+12>>2],B=D[o+24>>2]+D[o+28>>2]|0),I=D[((I=(B>>>0)/341|0)<<2)+r>>2]+s(B-s(I,341)|0,12)|0,D[I+8>>2]=t,D[I+4>>2]=i,D[I>>2]=E,D[o+28>>2]=D[o+28>>2]+1),!Q)break E;(0|(E=D[o+28>>2]+D[o+24>>2]|0))==(0|((I=D[o+16>>2]-(B=D[o+12>>2])|0)?s(I>>2,341)-1|0:0))&&(AI(o+8|0),B=D[o+12>>2],E=D[o+24>>2]+D[o+28>>2]|0),I=D[((I=(E>>>0)/341|0)<<2)+B>>2]+s(E-s(I,341)|0,12)|0,D[I+8>>2]=f,D[I+4>>2]=i,D[I>>2]=Q,D[o+28>>2]=E=D[o+28>>2]+1|0;break B}if(I=0,Q)for(;;){if(E)for(y=D[a+548>>2],t=D[a+604>>2],c=D[a+616>>2],S=D[r>>2],K=D[N>>2],E=0;;){D[t+(D[(F=c+(E<<2)|0)>>2]<<2)>>2]=0;i:if(B=D[a>>2]-D[(i=D[F>>2]<<2)+K>>2]|0)if(i=i+t|0,(0|(w=32-(f=D[a+560>>2])|0))>=(0|B)){if((0|(n=D[a+556>>2]))==(0|y)){D[i>>2]=0;break i}if(D[i>>2]=D[n>>2]<<f>>>32-B,D[a+560>>2]=B=B+D[a+560>>2]|0,32!=(0|B))break i;D[a+560>>2]=0,D[a+556>>2]=n+4}else(0|(h=(n=D[a+556>>2])+4|0))!=(0|y)?(Y=D[n>>2],D[a+556>>2]=h,D[a+560>>2]=w=B-w|0,D[i>>2]=D[n+4>>2]>>>32-w|Y<<f>>>32-B):D[i>>2]=0;if(D[(i=(B=D[F>>2]<<2)+t|0)>>2]=D[i>>2]|D[B+S>>2],!((E=E+1|0)>>>0<k[a+12>>2]))break}if(JI(G,b),D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(I=I+1|0)))break E;E=D[a+12>>2]}}else{if(I=0,!Q)break E;for(;;){if(y=D[(E=D[r>>2])+8>>2],N=D[E+4>>2],F=D[E>>2],(E=D[(B=D[G>>2])+4>>2])>>>0<(f=D[B+8>>2])>>>0)D[E+8>>2]=y,D[E+4>>2]=N,D[E>>2]=F,D[B+4>>2]=E+12;else{if((i=1+(n=(E-(t=D[B>>2])|0)/12|0)|0)>>>0>=357913942)break A;if(c=(f=(f-t|0)/12|0)<<1,(i=f>>>0<178956970?i>>>0>c>>>0?i:c:357913941)>>>0>=357913942)break I;if(c=s(n,12),n=DC(f=s(i,12)),D[8+(i=c+n|0)>>2]=y,D[i+4>>2]=N,D[i>>2]=F,y=i+12|0,(0|E)!=(0|t))for(;D[(i=i-12|0)>>2]=D[(E=E-12|0)>>2],D[i+4>>2]=D[E+4>>2],D[i+8>>2]=D[E+8>>2],(0|E)!=(0|t););D[B+8>>2]=f+n,D[B+4>>2]=y,D[B>>2]=i,t&&sA(t)}if(D[a+8>>2]=D[a+8>>2]+1,(0|Q)==(0|(I=I+1|0)))break}}E=D[o+28>>2]}if(!E)break}if(D[o+28>>2]=0,(i=(E=D[o+16>>2])-(I=D[o+12>>2])>>2)>>>0>=3)for(;sA(D[I>>2]),D[o+12>>2]=I=D[o+12>>2]+4|0,(i=(E=D[o+16>>2])-I>>2)>>>0>2;);Q=170;Q:switch(i-1|0){case 1:Q=341;case 0:D[o+24>>2]=Q}if((0|I)!=(0|E)){for(;sA(D[I>>2]),(0|E)!=(0|(I=I+4|0)););(0|(I=D[o+16>>2]))!=(0|(Q=D[o+12>>2]))&&(D[o+16>>2]=I+(((I-Q|0)-4>>>2^-1)<<2))}(I=D[o+8>>2])&&sA(I),d=o+32|0}XI(a)}i=D[A+12>>2]==((D[g+4>>2]-D[g>>2]|0)/12|0)}return d=C+672|0,i}xg(1336),U()}iQ(),U()}function H(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,U=0,h=0,J=0,S=0;if(!A)return 1;A:if(!((0|(Q=D[g+20>>2]))>=(0|(t=D[g+12>>2]))&(o=D[g+16>>2])>>>0>=k[g+8>>2]|(0|Q)>(0|t))){t=e[o+D[g>>2]|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q;I:switch(0|t){case 0:o=A,Q=I,N=C,A=0,C=0,d=t=d+-64|0,D[t+56>>2]=0,D[t+48>>2]=0,D[t+52>>2]=0,D[t+40>>2]=0,D[t+44>>2]=0,D[t+32>>2]=0,D[t+36>>2]=0,D[t+24>>2]=0,D[t+28>>2]=0,D[t+16>>2]=0,D[t+20>>2]=0,D[t+8>>2]=0,D[t+12>>2]=0;g:if(hA(t+8|0,g)&&!(!mA(t+8|0,g)|(D[t+20>>2]?0:o))){if(dI(g,0,0),o)for(y=Q<<2,c=D[t+36>>2],w=D[t+48>>2],h=D[t+24>>2];;){C:if(!((G=D[t+56>>2])>>>0>16383))for(A=D[t+52>>2];;){if((0|A)<=0)break C;if(D[t+52>>2]=A=A-1|0,D[t+56>>2]=G=e[A+w|0]|G<<8,!(G>>>0<16384))break}if(D[t+56>>2]=(s(D[(I=((i=D[((A=4095&G)<<2)+h>>2])<<3)+c|0)>>2],G>>>12|0)+A|0)-D[I+4>>2],!((0|Q)<=0)){if(A=0,!e[g+36|0]|i>>>0>32)break g;if(i){for(J=-2&i,S=1&i,E=C+Q|0,I=D[g+32>>2];;){if(a=D[g+28>>2],n=D[g+24>>2],G=0,A=I,r=0,F=0,1!=(0|i))for(;(R=n+(A>>>3|0)|0)>>>0>=a>>>0?R=0:(R=e[0|R],D[g+32>>2]=I=A+1|0,R=R>>>(7&A)&1,A=I),R=R<<G|r,r=0,(b=n+(A>>>3|0)|0)>>>0<a>>>0&&(r=e[0|b],D[g+32>>2]=I=A+1|0,r=r>>>(7&A)&1,A=I),b=1|G,G=G+2|0,r=R|r<<b,(0|J)!=(0|(F=F+2|0)););if(F=N+(C<<2)|0,S&&((R=a)>>>0>(a=n+(A>>>3|0)|0)>>>0?(a=e[0|a],D[g+32>>2]=I=A+1|0,A=a>>>(7&A)&1):A=0,r|=A<<G),D[F>>2]=r,(0|E)==(0|(C=C+1|0)))break}C=E}else bI(N+(C<<2)|0,0,y),C=C+Q|0}if(!(o>>>0>(U=Q+U|0)>>>0))break}B[g+36|0]=0,Q=0,r=(7&(Q=(A=D[g+32>>2]+7|0)>>>0<7?1:Q))<<29|A>>>3,Q=(Q>>>3|0)+(I=D[g+20>>2])|0,D[g+16>>2]=A=r+D[g+16>>2]|0,D[g+20>>2]=A>>>0<r>>>0?Q+1|0:Q,A=1}return(I=D[t+36>>2])&&(D[t+40>>2]=I,sA(I)),(I=D[t+24>>2])&&(D[t+28>>2]=I,sA(I)),(I=D[t+8>>2])&&(D[t+12>>2]=I,sA(I)),d=t- -64|0,A;case 1:break I;default:break A}I=0;I:if(!((0|(Q=D[g+20>>2]))>=(0|(t=D[g+12>>2]))&(o=D[g+16>>2])>>>0>=k[g+8>>2]|(0|Q)>(0|t))){t=e[o+D[g>>2]|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q;g:switch(t-1|0){case 4:if(d=Q=d+-64|0,D[Q+56>>2]=0,D[Q+48>>2]=0,D[Q+52>>2]=0,D[Q+40>>2]=0,D[Q+44>>2]=0,D[Q+32>>2]=0,D[Q+36>>2]=0,D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,!(!hA(Q+8|0,g)|(D[Q+20>>2]?0:A))&&mA(Q+8|0,g))if(A)for(o=D[Q+36>>2],N=D[Q+48>>2],E=D[Q+24>>2],g=D[Q+56>>2];;){C:if(!(g>>>0>16383))for(I=D[Q+52>>2];;){if((0|I)<=0)break C;if(D[Q+52>>2]=I=I-1|0,D[Q+56>>2]=g=e[I+N|0]|g<<8,!(g>>>0<16384))break}if(g=(s(D[(G=o+((t=D[E+((I=4095&g)<<2)>>2])<<3)|0)>>2],g>>>12|0)+I|0)-D[G+4>>2]|0,D[Q+56>>2]=g,D[(r<<2)+C>>2]=t,I=1,(0|(r=r+1|0))==(0|A))break}else I=1;(A=D[Q+36>>2])&&(D[Q+40>>2]=A,sA(A)),(A=D[Q+24>>2])&&(D[Q+28>>2]=A,sA(A)),(A=D[Q+8>>2])&&(D[Q+12>>2]=A,sA(A)),d=Q- -64|0;break I;case 8:t=A,G=C,d=E=d+-64|0,D[E+48>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E>>2]=0,D[E+4>>2]=0;C:{Q:if(A=f[g+38>>1]){if(A>>>0<=511){if(Q=D[g+20>>2],(0|(A=D[g+12>>2]))<=(0|(Q=(C=(I=D[g+16>>2])+4|0)>>>0<4?Q+1|0:Q))&C>>>0>k[g+8>>2]|(0|A)<(0|Q))break Q;D[E+12>>2]=a=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,Q=D[g+20>>2],Q=(A=D[g+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q}else{if(!Fg(1,E+12|0,g))break Q;a=D[E+12>>2]}if((A=D[E+4>>2]-(I=D[E>>2])>>2)>>>0<a>>>0?($I(E,a-A|0),a=D[E+12>>2]):A>>>0<=a>>>0||(D[E+4>>2]=I+(a<<2)),C=1,!a)break C;for(R=D[g+8>>2],F=D[g+12>>2],y=D[E>>2],I=0;;){if(C=0,(0|F)<=(0|(Q=D[g+20>>2]))&R>>>0<=(A=D[g+16>>2])>>>0|(0|Q)>(0|F))break C;n=e[(C=D[g>>2])+A|0],Q=(A=A+1|0)?Q:Q+1|0,o=A,D[g+16>>2]=A,D[g+20>>2]=Q,A=n>>>2|0,i=0;B:{E:{i:{o:switch(0|(c=3&n)){case 0:break E;case 3:break o;default:break i}if(C=0,(A=A+I|0)>>>0>=a>>>0)break C;bI(y+(I<<2)|0,0,4+(252&n)|0),I=A;break B}for(;;){if((0|Q)>=(0|F)&o>>>0>=R>>>0|(0|Q)>(0|F))break Q;if(a=e[C+o|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q,A|=a<<(i<<3|6),(0|c)==(0|(i=i+1|0)))break}}D[y+(I<<2)>>2]=A}if(!((I=I+1|0)>>>0<(a=D[E+12>>2])>>>0))break}if(o=E+16|0,R=D[E>>2],(C=(I=D[E+20>>2]-(A=D[E+16>>2])|0)>>2)>>>0<=8191?$I(o,8192-C|0):32768!=(0|I)&&(D[E+20>>2]=A+32768),(C=D[E+32>>2]-(I=D[(A=E+28|0)>>2])>>3)>>>0<a>>>0)Ag(A,a-C|0),I=D[A>>2];else if(C>>>0>a>>>0&&(D[E+32>>2]=(a<<3)+I),!a)break Q;for(i=0,C=0;;){if(F=D[(Q=R+(i<<2)|0)>>2],D[4+(n=(i<<3)+I|0)>>2]=A=C,D[n>>2]=F,(C=(Q=D[Q>>2])+A|0)>>>0>8192)break Q;if(!(A>>>0>=C>>>0)){if(n=D[o>>2],F=0,y=7&Q)for(;D[n+(A<<2)>>2]=i,A=A+1|0,(0|y)!=(0|(F=F+1|0)););if(!(Q-1>>>0<=6))for(;D[(Q=n+(A<<2)|0)>>2]=i,D[Q+28>>2]=i,D[Q+24>>2]=i,D[Q+20>>2]=i,D[Q+16>>2]=i,D[Q+12>>2]=i,D[Q+8>>2]=i,D[Q+4>>2]=i,(0|C)!=(0|(A=A+8|0)););}if((0|(i=i+1|0))==(0|a))break}N=8192==(0|C)}C=N}C:if(!(!C|(D[E+12>>2]?0:t))){if(f[g+38>>1]<=511){if(a=A=D[g+12>>2],Q=D[g+20>>2],o=C=(I=D[g+16>>2])+8|0,(N=D[g+8>>2])>>>0<C>>>0&(0|A)<=(0|(Q=C>>>0<8?Q+1|0:Q))|(0|A)<(0|Q))break C;I=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,i=e[A+4|0]|e[A+5|0]<<8|e[A+6|0]<<16|e[A+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,E+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[E+56>>2],i=D[E+60>>2]}if(!((0|(C=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&N-o>>>0<I>>>0|C>>>0<i>>>0||(Q=Q+i|0,Q=(A=I+o|0)>>>0<I>>>0?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q,(0|I)<=0))){D[E+40>>2]=C=o+D[g>>2]|0;Q:if((Q=e[0|(g=C+(A=I-1|0)|0)])>>>0<=63)D[E+44>>2]=A,I=63&e[0|g];else{B:switch((Q>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[E+44>>2]=A=I-2|0,I=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[E+44>>2]=A=I-3|0,I=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[E+44>>2]=A=I-4|0,I=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[E+48>>2]=g=I+32768|0,!(g>>>0>8388607))if(t)for(Q=D[E+28>>2],I=0,o=D[E+16>>2];;){Q:if(!(g>>>0>32767))for(;;){if((0|A)<=0)break Q;if(D[E+44>>2]=A=A-1|0,D[E+48>>2]=g=e[A+C|0]|g<<8,!(g>>>0<32768))break}if(g=(s(D[(i=Q+((N=D[o+((r=8191&g)<<2)>>2])<<3)|0)>>2],g>>>13|0)+r|0)-D[i+4>>2]|0,D[E+48>>2]=g,D[G+(I<<2)>>2]=N,r=1,(0|t)==(0|(I=I+1|0)))break}else r=1}}(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),(A=D[E>>2])&&(D[E+4>>2]=A,sA(A)),d=E- -64|0,I=r;break I;case 9:t=A,G=C,d=E=d+-64|0,D[E+48>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E>>2]=0,D[E+4>>2]=0;C:{Q:if(A=f[g+38>>1]){if(A>>>0<=511){if(Q=D[g+20>>2],(0|(A=D[g+12>>2]))<=(0|(Q=(C=(I=D[g+16>>2])+4|0)>>>0<4?Q+1|0:Q))&C>>>0>k[g+8>>2]|(0|A)<(0|Q))break Q;D[E+12>>2]=a=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,Q=D[g+20>>2],Q=(A=D[g+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q}else{if(!Fg(1,E+12|0,g))break Q;a=D[E+12>>2]}if((A=D[E+4>>2]-(I=D[E>>2])>>2)>>>0<a>>>0?($I(E,a-A|0),a=D[E+12>>2]):A>>>0<=a>>>0||(D[E+4>>2]=I+(a<<2)),C=1,!a)break C;for(R=D[g+8>>2],F=D[g+12>>2],y=D[E>>2],I=0;;){if(C=0,(0|F)<=(0|(Q=D[g+20>>2]))&R>>>0<=(A=D[g+16>>2])>>>0|(0|Q)>(0|F))break C;n=e[(C=D[g>>2])+A|0],Q=(A=A+1|0)?Q:Q+1|0,o=A,D[g+16>>2]=A,D[g+20>>2]=Q,A=n>>>2|0,i=0;B:{E:{i:{o:switch(0|(c=3&n)){case 0:break E;case 3:break o;default:break i}if(C=0,(A=A+I|0)>>>0>=a>>>0)break C;bI(y+(I<<2)|0,0,4+(252&n)|0),I=A;break B}for(;;){if((0|Q)>=(0|F)&o>>>0>=R>>>0|(0|Q)>(0|F))break Q;if(a=e[C+o|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q,A|=a<<(i<<3|6),(0|c)==(0|(i=i+1|0)))break}}D[y+(I<<2)>>2]=A}if(!((I=I+1|0)>>>0<(a=D[E+12>>2])>>>0))break}if(o=E+16|0,R=D[E>>2],(C=(I=D[E+20>>2]-(A=D[E+16>>2])|0)>>2)>>>0<=32767?$I(o,32768-C|0):131072!=(0|I)&&(D[E+20>>2]=A+131072),(C=D[E+32>>2]-(I=D[(A=E+28|0)>>2])>>3)>>>0<a>>>0)Ag(A,a-C|0),I=D[A>>2];else if(C>>>0>a>>>0&&(D[E+32>>2]=(a<<3)+I),!a)break Q;for(i=0,C=0;;){if(F=D[(Q=R+(i<<2)|0)>>2],D[4+(n=(i<<3)+I|0)>>2]=A=C,D[n>>2]=F,(C=(Q=D[Q>>2])+A|0)>>>0>32768)break Q;if(!(A>>>0>=C>>>0)){if(n=D[o>>2],F=0,y=7&Q)for(;D[n+(A<<2)>>2]=i,A=A+1|0,(0|y)!=(0|(F=F+1|0)););if(!(Q-1>>>0<=6))for(;D[(Q=n+(A<<2)|0)>>2]=i,D[Q+28>>2]=i,D[Q+24>>2]=i,D[Q+20>>2]=i,D[Q+16>>2]=i,D[Q+12>>2]=i,D[Q+8>>2]=i,D[Q+4>>2]=i,(0|C)!=(0|(A=A+8|0)););}if((0|(i=i+1|0))==(0|a))break}N=32768==(0|C)}C=N}C:if(!(!C|(D[E+12>>2]?0:t))){if(f[g+38>>1]<=511){if(a=A=D[g+12>>2],Q=D[g+20>>2],o=C=(I=D[g+16>>2])+8|0,(N=D[g+8>>2])>>>0<C>>>0&(0|A)<=(0|(Q=C>>>0<8?Q+1|0:Q))|(0|A)<(0|Q))break C;I=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,i=e[A+4|0]|e[A+5|0]<<8|e[A+6|0]<<16|e[A+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,E+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[E+56>>2],i=D[E+60>>2]}if(!((0|(C=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&N-o>>>0<I>>>0|C>>>0<i>>>0||(C=Q+i|0,C=(A=I+o|0)>>>0<I>>>0?C+1|0:C,D[g+16>>2]=A,D[g+20>>2]=C,(0|I)<=0))){D[E+40>>2]=C=o+D[g>>2]|0;Q:if((Q=e[0|(g=C+(A=I-1|0)|0)])>>>0<=63)D[E+44>>2]=A,I=63&e[0|g];else{B:switch((Q>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[E+44>>2]=A=I-2|0,I=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[E+44>>2]=A=I-3|0,I=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[E+44>>2]=A=I-4|0,I=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[E+48>>2]=g=I+131072|0,!(g>>>0>33554431))if(t)for(Q=D[E+28>>2],I=0,o=D[E+16>>2];;){Q:if(!(g>>>0>131071))for(;;){if((0|A)<=0)break Q;if(D[E+44>>2]=A=A-1|0,D[E+48>>2]=g=e[A+C|0]|g<<8,!(g>>>0<131072))break}if(g=(s(D[(i=Q+((N=D[o+((r=32767&g)<<2)>>2])<<3)|0)>>2],g>>>15|0)+r|0)-D[i+4>>2]|0,D[E+48>>2]=g,D[G+(I<<2)>>2]=N,r=1,(0|t)==(0|(I=I+1|0)))break}else r=1}}(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),(A=D[E>>2])&&(D[E+4>>2]=A,sA(A)),d=E- -64|0,I=r;break I;case 10:t=A,G=C,d=E=d+-64|0,D[E+48>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E>>2]=0,D[E+4>>2]=0;C:{Q:if(A=f[g+38>>1]){if(A>>>0<=511){if(Q=D[g+20>>2],(0|(A=D[g+12>>2]))<=(0|(Q=(C=(I=D[g+16>>2])+4|0)>>>0<4?Q+1|0:Q))&C>>>0>k[g+8>>2]|(0|A)<(0|Q))break Q;D[E+12>>2]=a=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,Q=D[g+20>>2],Q=(A=D[g+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q}else{if(!Fg(1,E+12|0,g))break Q;a=D[E+12>>2]}if((A=D[E+4>>2]-(I=D[E>>2])>>2)>>>0<a>>>0?($I(E,a-A|0),a=D[E+12>>2]):A>>>0<=a>>>0||(D[E+4>>2]=I+(a<<2)),C=1,!a)break C;for(R=D[g+8>>2],F=D[g+12>>2],y=D[E>>2],I=0;;){if(C=0,(0|F)<=(0|(Q=D[g+20>>2]))&R>>>0<=(A=D[g+16>>2])>>>0|(0|Q)>(0|F))break C;n=e[(c=D[g>>2])+A|0],Q=(A=A+1|0)?Q:Q+1|0,o=A,D[g+16>>2]=A,D[g+20>>2]=Q,A=n>>>2|0,i=0;B:{E:{i:{o:switch(0|(w=3&n)){case 0:break E;case 3:break o;default:break i}if(C=0,(A=A+I|0)>>>0>=a>>>0)break C;bI(y+(I<<2)|0,0,4+(252&n)|0),I=A;break B}for(;;){if((0|Q)>=(0|F)&o>>>0>=R>>>0|(0|Q)>(0|F))break Q;if(a=e[o+c|0],C=Q,C=(Q=o+1|0)?C:C+1|0,o=Q,D[g+16>>2]=Q,D[g+20>>2]=Q=C,A|=a<<(i<<3|6),(0|w)==(0|(i=i+1|0)))break}}D[y+(I<<2)>>2]=A}if(!((I=I+1|0)>>>0<(a=D[E+12>>2])>>>0))break}if(o=E+16|0,R=D[E>>2],(C=(I=D[E+20>>2]-(A=D[E+16>>2])|0)>>2)>>>0<=65535?$I(o,65536-C|0):262144!=(0|I)&&(D[E+20>>2]=A+262144),(C=D[E+32>>2]-(I=D[(A=E+28|0)>>2])>>3)>>>0<a>>>0)Ag(A,a-C|0),I=D[A>>2];else if(C>>>0>a>>>0&&(D[E+32>>2]=(a<<3)+I),!a)break Q;for(i=0,C=0;;){if(F=D[(Q=R+(i<<2)|0)>>2],D[4+(n=(i<<3)+I|0)>>2]=A=C,D[n>>2]=F,(C=(Q=D[Q>>2])+A|0)>>>0>65536)break Q;if(!(A>>>0>=C>>>0)){if(n=D[o>>2],F=0,y=7&Q)for(;D[n+(A<<2)>>2]=i,A=A+1|0,(0|y)!=(0|(F=F+1|0)););if(!(Q-1>>>0<=6))for(;D[(Q=n+(A<<2)|0)>>2]=i,D[Q+28>>2]=i,D[Q+24>>2]=i,D[Q+20>>2]=i,D[Q+16>>2]=i,D[Q+12>>2]=i,D[Q+8>>2]=i,D[Q+4>>2]=i,(0|C)!=(0|(A=A+8|0)););}if((0|(i=i+1|0))==(0|a))break}N=65536==(0|C)}C=N}C:if(!(!C|(D[E+12>>2]?0:t))){if(f[g+38>>1]<=511){if(a=A=D[g+12>>2],Q=D[g+20>>2],o=C=(I=D[g+16>>2])+8|0,(N=D[g+8>>2])>>>0<C>>>0&(0|A)<=(0|(Q=C>>>0<8?Q+1|0:Q))|(0|A)<(0|Q))break C;I=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,i=e[A+4|0]|e[A+5|0]<<8|e[A+6|0]<<16|e[A+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,E+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[E+56>>2],i=D[E+60>>2]}if(!((0|(C=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&N-o>>>0<I>>>0|C>>>0<i>>>0||(Q=Q+i|0,Q=(A=I+o|0)>>>0<I>>>0?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q,(0|I)<=0))){D[E+40>>2]=C=o+D[g>>2]|0;Q:if((Q=e[0|(g=C+(A=I-1|0)|0)])>>>0<=63)D[E+44>>2]=A,I=63&e[0|g];else{B:switch((Q>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[E+44>>2]=A=I-2|0,I=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[E+44>>2]=A=I-3|0,I=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[E+44>>2]=A=I-4|0,I=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[E+48>>2]=g=I+262144|0,!(g>>>0>67108863))if(t)for(Q=D[E+28>>2],I=0,o=D[E+16>>2];;){Q:if(!(g>>>0>262143))for(;;){if((0|A)<=0)break Q;if(D[E+44>>2]=A=A-1|0,D[E+48>>2]=g=e[A+C|0]|g<<8,!(g>>>0<262144))break}if(g=(s(D[(i=Q+((N=D[o+((r=65535&g)<<2)>>2])<<3)|0)>>2],g>>>16|0)+r|0)-D[i+4>>2]|0,D[E+48>>2]=g,D[G+(I<<2)>>2]=N,r=1,(0|t)==(0|(I=I+1|0)))break}else r=1}}(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),(A=D[E>>2])&&(D[E+4>>2]=A,sA(A)),d=E- -64|0,I=r;break I;case 11:t=A,G=C,d=E=d+-64|0,D[E+48>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E>>2]=0,D[E+4>>2]=0;C:{Q:if(A=f[g+38>>1]){if(A>>>0<=511){if(Q=D[g+20>>2],(0|(A=D[g+12>>2]))<=(0|(Q=(C=(I=D[g+16>>2])+4|0)>>>0<4?Q+1|0:Q))&C>>>0>k[g+8>>2]|(0|A)<(0|Q))break Q;D[E+12>>2]=a=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,Q=D[g+20>>2],Q=(A=D[g+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q}else{if(!Fg(1,E+12|0,g))break Q;a=D[E+12>>2]}if((A=D[E+4>>2]-(I=D[E>>2])>>2)>>>0<a>>>0?($I(E,a-A|0),a=D[E+12>>2]):A>>>0<=a>>>0||(D[E+4>>2]=I+(a<<2)),C=1,!a)break C;for(R=D[g+8>>2],F=D[g+12>>2],y=D[E>>2],I=0;;){if(C=0,(0|F)<=(0|(Q=D[g+20>>2]))&R>>>0<=(A=D[g+16>>2])>>>0|(0|Q)>(0|F))break C;n=e[(C=D[g>>2])+A|0],Q=(A=A+1|0)?Q:Q+1|0,o=A,D[g+16>>2]=A,D[g+20>>2]=Q,A=n>>>2|0,i=0;B:{E:{i:{o:switch(0|(c=3&n)){case 0:break E;case 3:break o;default:break i}if(C=0,(A=A+I|0)>>>0>=a>>>0)break C;bI(y+(I<<2)|0,0,4+(252&n)|0),I=A;break B}for(;;){if((0|Q)>=(0|F)&o>>>0>=R>>>0|(0|Q)>(0|F))break Q;if(a=e[C+o|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q,A|=a<<(i<<3|6),(0|c)==(0|(i=i+1|0)))break}}D[y+(I<<2)>>2]=A}if(!((I=I+1|0)>>>0<(a=D[E+12>>2])>>>0))break}if(o=E+16|0,R=D[E>>2],(C=(I=D[E+20>>2]-(A=D[E+16>>2])|0)>>2)>>>0<=262143?$I(o,262144-C|0):1048576!=(0|I)&&(D[E+20>>2]=A- -1048576),(C=D[E+32>>2]-(I=D[(A=E+28|0)>>2])>>3)>>>0<a>>>0)Ag(A,a-C|0),I=D[A>>2];else if(C>>>0>a>>>0&&(D[E+32>>2]=(a<<3)+I),!a)break Q;for(i=0,C=0;;){if(F=D[(Q=R+(i<<2)|0)>>2],D[4+(n=(i<<3)+I|0)>>2]=A=C,D[n>>2]=F,(C=(Q=D[Q>>2])+A|0)>>>0>262144)break Q;if(!(A>>>0>=C>>>0)){if(n=D[o>>2],F=0,y=7&Q)for(;D[n+(A<<2)>>2]=i,A=A+1|0,(0|y)!=(0|(F=F+1|0)););if(!(Q-1>>>0<=6))for(;D[(Q=n+(A<<2)|0)>>2]=i,D[Q+28>>2]=i,D[Q+24>>2]=i,D[Q+20>>2]=i,D[Q+16>>2]=i,D[Q+12>>2]=i,D[Q+8>>2]=i,D[Q+4>>2]=i,(0|C)!=(0|(A=A+8|0)););}if((0|(i=i+1|0))==(0|a))break}N=262144==(0|C)}C=N}C:if(!(!C|(D[E+12>>2]?0:t))){if(f[g+38>>1]<=511){if(a=A=D[g+12>>2],Q=D[g+20>>2],o=C=(I=D[g+16>>2])+8|0,(N=D[g+8>>2])>>>0<C>>>0&(0|A)<=(0|(Q=C>>>0<8?Q+1|0:Q))|(0|A)<(0|Q))break C;I=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,i=e[A+4|0]|e[A+5|0]<<8|e[A+6|0]<<16|e[A+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,E+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[E+56>>2],i=D[E+60>>2]}if(!((0|(C=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&N-o>>>0<I>>>0|C>>>0<i>>>0||(Q=Q+i|0,Q=(A=I+o|0)>>>0<I>>>0?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q,(0|I)<=0))){D[E+40>>2]=C=o+D[g>>2]|0;Q:if((Q=e[0|(g=C+(A=I-1|0)|0)])>>>0<=63)D[E+44>>2]=A,I=63&e[0|g];else{B:switch((Q>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[E+44>>2]=A=I-2|0,I=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[E+44>>2]=A=I-3|0,I=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[E+44>>2]=A=I-4|0,I=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[E+48>>2]=g=I- -1048576|0,!(g>>>0>268435455))if(t)for(Q=D[E+28>>2],I=0,o=D[E+16>>2];;){Q:if(!(g>>>0>1048575))for(;;){if((0|A)<=0)break Q;if(D[E+44>>2]=A=A-1|0,D[E+48>>2]=g=e[A+C|0]|g<<8,!(g>>>0<1048576))break}if(g=(s(D[(i=Q+((N=D[o+((r=262143&g)<<2)>>2])<<3)|0)>>2],g>>>18|0)+r|0)-D[i+4>>2]|0,D[E+48>>2]=g,D[G+(I<<2)>>2]=N,r=1,(0|t)==(0|(I=I+1|0)))break}else r=1}}(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),(A=D[E>>2])&&(D[E+4>>2]=A,sA(A)),d=E- -64|0,I=r;break I;case 12:t=A,G=C,d=E=d+-64|0,D[E+48>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E>>2]=0,D[E+4>>2]=0;C:{Q:if(A=f[g+38>>1]){if(A>>>0<=511){if(Q=D[g+20>>2],(0|(A=D[g+12>>2]))<=(0|(Q=(C=(I=D[g+16>>2])+4|0)>>>0<4?Q+1|0:Q))&C>>>0>k[g+8>>2]|(0|A)<(0|Q))break Q;D[E+12>>2]=a=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,Q=D[g+20>>2],Q=(A=D[g+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[g+16>>2]=A,D[g+20>>2]=Q}else{if(!Fg(1,E+12|0,g))break Q;a=D[E+12>>2]}if((A=D[E+4>>2]-(I=D[E>>2])>>2)>>>0<a>>>0?($I(E,a-A|0),a=D[E+12>>2]):A>>>0<=a>>>0||(D[E+4>>2]=I+(a<<2)),C=1,!a)break C;for(R=D[g+8>>2],F=D[g+12>>2],y=D[E>>2],I=0;;){if(C=0,(0|F)<=(0|(Q=D[g+20>>2]))&R>>>0<=(A=D[g+16>>2])>>>0|(0|Q)>(0|F))break C;n=e[(C=D[g>>2])+A|0],Q=(A=A+1|0)?Q:Q+1|0,o=A,D[g+16>>2]=A,D[g+20>>2]=Q,A=n>>>2|0,i=0;B:{E:{i:{o:switch(0|(c=3&n)){case 0:break E;case 3:break o;default:break i}if(C=0,(A=A+I|0)>>>0>=a>>>0)break C;bI(y+(I<<2)|0,0,4+(252&n)|0),I=A;break B}for(;;){if((0|Q)>=(0|F)&o>>>0>=R>>>0|(0|Q)>(0|F))break Q;if(a=e[C+o|0],Q=(o=o+1|0)?Q:Q+1|0,D[g+16>>2]=o,D[g+20>>2]=Q,A|=a<<(i<<3|6),(0|c)==(0|(i=i+1|0)))break}}D[y+(I<<2)>>2]=A}if(!((I=I+1|0)>>>0<(a=D[E+12>>2])>>>0))break}if(o=E+16|0,R=D[E>>2],(C=(I=D[E+20>>2]-(A=D[E+16>>2])|0)>>2)>>>0<=524287?$I(o,524288-C|0):2097152!=(0|I)&&(D[E+20>>2]=A+2097152),(C=D[E+32>>2]-(I=D[(A=E+28|0)>>2])>>3)>>>0<a>>>0)Ag(A,a-C|0),I=D[A>>2];else if(C>>>0>a>>>0&&(D[E+32>>2]=(a<<3)+I),!a)break Q;for(i=0,C=0;;){if(F=D[(Q=R+(i<<2)|0)>>2],D[4+(n=(i<<3)+I|0)>>2]=A=C,D[n>>2]=F,(C=(Q=D[Q>>2])+A|0)>>>0>524288)break Q;if(!(A>>>0>=C>>>0)){if(n=D[o>>2],F=0,y=7&Q)for(;D[n+(A<<2)>>2]=i,A=A+1|0,(0|y)!=(0|(F=F+1|0)););if(!(Q-1>>>0<=6))for(;D[(Q=n+(A<<2)|0)>>2]=i,D[Q+28>>2]=i,D[Q+24>>2]=i,D[Q+20>>2]=i,D[Q+16>>2]=i,D[Q+12>>2]=i,D[Q+8>>2]=i,D[Q+4>>2]=i,(0|C)!=(0|(A=A+8|0)););}if((0|(i=i+1|0))==(0|a))break}N=524288==(0|C)}C=N}C:if(!(!C|(D[E+12>>2]?0:t))){if(f[g+38>>1]<=511){if(a=A=D[g+12>>2],Q=D[g+20>>2],o=C=(I=D[g+16>>2])+8|0,(N=D[g+8>>2])>>>0<C>>>0&(0|A)<=(0|(Q=C>>>0<8?Q+1|0:Q))|(0|A)<(0|Q))break C;I=e[0|(A=I+D[g>>2]|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,i=e[A+4|0]|e[A+5|0]<<8|e[A+6|0]<<16|e[A+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,E+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[E+56>>2],i=D[E+60>>2]}if(!((0|(C=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&N-o>>>0<I>>>0|C>>>0<i>>>0||(C=Q+i|0,C=(A=I+o|0)>>>0<I>>>0?C+1|0:C,D[g+16>>2]=A,D[g+20>>2]=C,(0|I)<=0))){D[E+40>>2]=C=o+D[g>>2]|0;Q:if((Q=e[0|(g=C+(A=I-1|0)|0)])>>>0<=63)D[E+44>>2]=A,I=63&e[0|g];else{B:switch((Q>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[E+44>>2]=A=I-2|0,I=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[E+44>>2]=A=I-3|0,I=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[E+44>>2]=A=I-4|0,I=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[E+48>>2]=g=I+2097152|0,!(g>>>0>536870911))if(t)for(Q=D[E+28>>2],I=0,o=D[E+16>>2];;){Q:if(!(g>>>0>2097151))for(;;){if((0|A)<=0)break Q;if(D[E+44>>2]=A=A-1|0,D[E+48>>2]=g=e[A+C|0]|g<<8,!(g>>>0<2097152))break}if(g=(s(D[(i=Q+((N=D[o+((r=524287&g)<<2)>>2])<<3)|0)>>2],g>>>19|0)+r|0)-D[i+4>>2]|0,D[E+48>>2]=g,D[G+(I<<2)>>2]=N,r=1,(0|t)==(0|(I=I+1|0)))break}else r=1}}(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),(A=D[E>>2])&&(D[E+4>>2]=A,sA(A)),d=E- -64|0,I=r;break I;case 17:I=rA(A,g,C);break I;case 0:case 1:case 2:case 3:case 5:case 6:case 7:d=r=d+-64|0,D[r+48>>2]=0,D[r+40>>2]=0,D[r+44>>2]=0,D[r+32>>2]=0,D[r+36>>2]=0,D[r+24>>2]=0,D[r+28>>2]=0,D[r+16>>2]=0,D[r+20>>2]=0,D[r+8>>2]=0,D[r+12>>2]=0,D[r>>2]=0,D[r+4>>2]=0;C:if(!(!hA(r,g)|(D[r+12>>2]?0:A))){if(f[g+38>>1]<=511){if(a=I=D[g+12>>2],Q=D[g+20>>2],(N=D[g+8>>2])>>>0<(o=(t=D[g+16>>2])+8|0)>>>0&(0|I)<=(0|(Q=o>>>0<8?Q+1|0:Q))|(0|I)<(0|Q))break C;I=e[0|(t=t+D[g>>2]|0)]|e[t+1|0]<<8|e[t+2|0]<<16|e[t+3|0]<<24,i=e[t+4|0]|e[t+5|0]<<8|e[t+6|0]<<16|e[t+7|0]<<24,D[g+16>>2]=o,D[g+20>>2]=Q}else{if(!ag(1,r+56|0,g))break C;o=D[g+16>>2],Q=D[g+20>>2],N=D[g+8>>2],a=D[g+12>>2],I=D[r+56>>2],i=D[r+60>>2]}if(t=N-o|0,!((0|(N=a-((o>>>0>N>>>0)+Q|0)|0))==(0|i)&I>>>0>t>>>0|i>>>0>N>>>0||(Q=Q+i|0,Q=(N=I+o|0)>>>0<I>>>0?Q+1|0:Q,D[g+16>>2]=N,D[g+20>>2]=Q,(0|I)<=0))){D[r+40>>2]=Q=o+D[g>>2]|0;Q:if((N=e[0|(o=Q+(g=I-1|0)|0)])>>>0<=63)D[r+44>>2]=g,I=63&e[0|o];else{B:switch((N>>>6|0)-1|0){case 0:if(I>>>0<2)break C;D[r+44>>2]=g=I-2|0,I=e[1+(I=(I+Q|0)-2|0)|0]<<8&16128|e[0|I];break Q;case 1:if(I>>>0<3)break C;D[r+44>>2]=g=I-3|0,I=e[2+(I=(I+Q|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break Q}D[r+44>>2]=g=I-4|0,I=e[2+(I=(I+Q|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}if(D[r+48>>2]=I=I+16384|0,!(I>>>0>4194303))if(A)for(o=D[r+28>>2],i=0,N=D[r+16>>2];;){Q:if(!(I>>>0>16383))for(;;){if((0|g)<=0)break Q;if(D[r+44>>2]=g=g-1|0,D[r+48>>2]=I=e[g+Q|0]|I<<8,!(I>>>0<16384))break}if(I=(s(D[(G=o+((t=D[N+((E=4095&I)<<2)>>2])<<3)|0)>>2],I>>>12|0)+E|0)-D[G+4>>2]|0,D[r+48>>2]=I,D[(i<<2)+C>>2]=t,E=1,(0|(i=i+1|0))==(0|A))break}else E=1}}(A=D[r+28>>2])&&(D[r+32>>2]=A,sA(A)),(A=D[r+16>>2])&&(D[r+20>>2]=A,sA(A)),(A=D[r>>2])&&(D[r+4>>2]=A,sA(A)),d=r- -64|0,I=E;break I;case 13:case 14:case 15:case 16:break g;default:break I}I=rA(A,g,C)}r=I}return r}function q(A){var I,g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0;d=I=d-16|0;A:{I:{g:{C:{Q:{B:{E:{i:{o:{a:{r:{if((A|=0)>>>0<=244){if(3&(g=(B=D[3978])>>>(C=(o=A>>>0<11?16:A+11&-8)>>>3|0)|0)){A=(E=D[15960+(g=(Q=C+(1&(-1^g))|0)<<3)>>2])+8|0,(0|(C=D[E+8>>2]))!=(0|(g=g+15952|0))?(D[C+12>>2]=g,D[g+8>>2]=C):(t=15912,N=JC(Q)&B,D[t>>2]=N),D[E+4>>2]=3|(g=Q<<3),D[4+(g=g+E|0)>>2]=1|D[g+4>>2];break A}if((f=D[3980])>>>0>=o>>>0)break r;if(g){C=A=(g=(0-(A=(0-(A=2<<C)|A)&g<<C)&A)-1|0)>>>12&16,C|=A=(g=g>>>A|0)>>>5&8,C|=A=(g=g>>>A|0)>>>2&4,(0|(g=D[(i=D[15960+(A=(C=((C|=A=(g=g>>>A|0)>>>1&2)|(A=(g=g>>>A|0)>>>1&1))+(g>>>A|0)|0)<<3)>>2])+8>>2]))!=(0|(A=A+15952|0))?(D[g+12>>2]=A,D[A+8>>2]=g):(B=JC(C)&B,D[3978]=B),A=i+8|0,D[i+4>>2]=3|o,D[4+(Q=i+o|0)>>2]=1|(E=(g=C<<3)-o|0),D[g+i>>2]=E,f&&(C=15952+((g=f>>>3|0)<<3)|0,i=D[3983],(g=1<<g)&B?g=D[C+8>>2]:(D[3978]=g|B,g=C),D[C+8>>2]=i,D[g+12>>2]=i,D[i+12>>2]=C,D[i+8>>2]=g),D[3983]=Q,D[3980]=E;break A}if(!(r=D[3979]))break r;for(C=A=(g=(r&0-r)-1|0)>>>12&16,C|=A=(g=g>>>A|0)>>>5&8,C|=A=(g=g>>>A|0)>>>2&4,Q=(-8&D[(g=D[16216+(((C|=A=(g=g>>>A|0)>>>1&2)|(A=(g=g>>>A|0)>>>1&1))+(g>>>A|0)<<2)>>2])+4>>2])-o|0,C=g;(A=D[C+16>>2])||(A=D[C+20>>2]);)Q=(E=(C=(-8&D[A+4>>2])-o|0)>>>0<Q>>>0)?C:Q,g=E?A:g,C=A;if(a=D[g+24>>2],(0|(E=D[g+12>>2]))!=(0|g)){D[(A=D[g+8>>2])+12>>2]=E,D[E+8>>2]=A;break I}if(!(A=D[(C=g+20|0)>>2])){if(!(A=D[g+16>>2]))break a;C=g+16|0}for(;i=C,E=A,(A=D[(C=A+20|0)>>2])||(C=E+16|0,A=D[E+16>>2]););D[i>>2]=0;break I}if(o=-1,!(A>>>0>4294967231)&&(o=-8&(A=A+11|0),r=D[3979])){Q=0-o|0,B=0,o>>>0<256||(B=31,o>>>0>16777215||(A=A>>>8|0,A<<=i=A+1048320>>>16&8,B=28+((A=((A<<=C=A+520192>>>16&4)<<(g=A+245760>>>16&2)>>>15|0)-(g|C|i)|0)<<1|o>>>A+21&1)|0));D:{e:{if(C=D[16216+(B<<2)>>2])for(A=0,g=o<<(31==(0|B)?0:25-(B>>>1|0)|0);;){if(!((i=(-8&D[C+4>>2])-o|0)>>>0>=Q>>>0||(E=C,Q=i))){Q=0,A=C;break e}if(i=D[C+20>>2],C=D[16+((g>>>29&4)+C|0)>>2],A=i?(0|i)==(0|C)?A:i:A,g<<=1,!C)break}else A=0;if(!(A|E)){if(E=0,!(A=(0-(A=2<<B)|A)&r))break r;C=A=(g=(A&0-A)-1|0)>>>12&16,C|=A=(g=g>>>A|0)>>>5&8,C|=A=(g=g>>>A|0)>>>2&4,A=D[16216+(((C|=A=(g=g>>>A|0)>>>1&2)|(A=(g=g>>>A|0)>>>1&1))+(g>>>A|0)<<2)>>2]}if(!A)break D}for(;Q=(C=(g=(-8&D[A+4>>2])-o|0)>>>0<Q>>>0)?g:Q,E=C?A:E,A=(g=D[A+16>>2])||D[A+20>>2];);}if(!(!E|D[3980]-o>>>0<=Q>>>0)){if(B=D[E+24>>2],(0|E)!=(0|(g=D[E+12>>2]))){D[(A=D[E+8>>2])+12>>2]=g,D[g+8>>2]=A;break g}if(!(A=D[(C=E+20|0)>>2])){if(!(A=D[E+16>>2]))break o;C=E+16|0}for(;i=C,g=A,(A=D[(C=A+20|0)>>2])||(C=g+16|0,A=D[g+16>>2]););D[i>>2]=0;break g}}}if((C=D[3980])>>>0>=o>>>0){Q=D[3983],(g=C-o|0)>>>0>=16?(D[3980]=g,D[3983]=A=Q+o|0,D[A+4>>2]=1|g,D[C+Q>>2]=g,D[Q+4>>2]=3|o):(D[3983]=0,D[3980]=0,D[Q+4>>2]=3|C,D[4+(A=C+Q|0)>>2]=1|D[A+4>>2]),A=Q+8|0;break A}if((a=D[3981])>>>0>o>>>0){D[3981]=g=a-o|0,D[3984]=A=(C=D[3984])+o|0,D[A+4>>2]=1|g,D[C+4>>2]=3|o,A=C+8|0;break A}if(A=0,r=o+47|0,D[4096]?C=D[4098]:(D[4099]=-1,D[4100]=-1,D[4097]=4096,D[4098]=4096,D[4096]=I+12&-16^1431655768,D[4101]=0,D[4089]=0,C=4096),(C=(i=r+C|0)&(E=0-C|0))>>>0<=o>>>0)break A;if((Q=D[4088])&&Q>>>0<(B=(g=D[4086])+C|0)>>>0|g>>>0>=B>>>0)break A;if(4&e[16356])break B;r:{D:{if(Q=D[3984])for(A=16360;;){if((g=D[A>>2])>>>0<=Q>>>0&Q>>>0<g+D[A+4>>2]>>>0)break D;if(!(A=D[A+8>>2]))break}if(-1==(0|(g=Pg(0))))break E;if(B=C,(A=(Q=D[4097])-1|0)&g&&(B=(C-g|0)+(A+g&0-Q)|0),B>>>0<=o>>>0|B>>>0>2147483646)break E;if((Q=D[4088])&&Q>>>0<(E=(A=D[4086])+B|0)>>>0|A>>>0>=E>>>0)break E;if((0|g)!=(0|(A=Pg(B))))break r;break Q}if((B=E&i-a)>>>0>2147483646)break E;if((0|(g=Pg(B)))==(D[A>>2]+D[A+4>>2]|0))break i;A=g}if(!(-1==(0|A)|o+48>>>0<=B>>>0)){if((g=(g=D[4098])+(r-B|0)&0-g)>>>0>2147483646){g=A;break Q}if(-1!=(0|Pg(g))){B=g+B|0,g=A;break Q}Pg(0-B|0);break E}if(g=A,-1!=(0|A))break Q;break E}E=0;break I}g=0;break g}if(-1!=(0|g))break Q}D[4089]=4|D[4089]}if(C>>>0>2147483646)break C;if(-1==(0|(g=Pg(C)))|-1==(0|(A=Pg(0)))|A>>>0<=g>>>0)break C;if((B=A-g|0)>>>0<=o+40>>>0)break C}D[4086]=A=D[4086]+B|0,A>>>0>k[4087]&&(D[4087]=A);Q:{B:{E:{if(i=D[3984]){for(A=16360;;){if(((Q=D[A>>2])+(C=D[A+4>>2])|0)==(0|g))break E;if(!(A=D[A+8>>2]))break}break B}for((A=D[3982])>>>0<=g>>>0&&A||(D[3982]=g),A=0,D[4091]=B,D[4090]=g,D[3986]=-1,D[3987]=D[4096],D[4093]=0;D[15960+(Q=A<<3)>>2]=C=Q+15952|0,D[Q+15964>>2]=C,32!=(0|(A=A+1|0)););D[3981]=C=(Q=B-40|0)-(A=g+8&7?-8-g&7:0)|0,D[3984]=A=A+g|0,D[A+4>>2]=1|C,D[4+(g+Q|0)>>2]=40,D[3985]=D[4100];break Q}if(!(8&e[A+12|0]|Q>>>0>i>>>0|g>>>0<=i>>>0)){D[A+4>>2]=C+B,D[3984]=C=(A=i+8&7?-8-i&7:0)+i|0,D[3981]=A=(g=D[3981]+B|0)-A|0,D[C+4>>2]=1|A,D[4+(g+i|0)>>2]=40,D[3985]=D[4100];break Q}}k[3982]>g>>>0&&(D[3982]=g),C=g+B|0,A=16360;B:{E:{i:{o:{a:{r:{for(;;){if((0|C)!=D[A>>2]){if(A=D[A+8>>2])continue;break r}break}if(!(8&e[A+12|0]))break a}for(A=16360;;){if((C=D[A>>2])>>>0<=i>>>0&&(E=C+D[A+4>>2]|0)>>>0>i>>>0)break o;A=D[A+8>>2]}}if(D[A>>2]=g,D[A+4>>2]=D[A+4>>2]+B,D[4+(r=(g+8&7?-8-g&7:0)+g|0)>>2]=3|o,C=(B=C+(C+8&7?-8-C&7:0)|0)-(a=o+r|0)|0,(0|B)==(0|i)){D[3984]=a,D[3981]=A=D[3981]+C|0,D[a+4>>2]=1|A;break E}if(D[3983]==(0|B)){D[3983]=a,D[3980]=A=D[3980]+C|0,D[a+4>>2]=1|A,D[A+a>>2]=A;break E}if(1==(3&(A=D[B+4>>2]))){i=-8&A;a:if(A>>>0<=255){if(A=A>>>3|0,(0|(g=D[B+12>>2]))==(0|(Q=D[B+8>>2]))){t=15912,N=D[3978]&JC(A),D[t>>2]=N;break a}D[Q+12>>2]=g,D[g+8>>2]=Q}else{if(o=D[B+24>>2],(0|B)==(0|(g=D[B+12>>2])))if((Q=D[(A=B+20|0)>>2])||(Q=D[(A=B+16|0)>>2])){for(;E=A,(Q=D[(A=(g=Q)+20|0)>>2])||(A=g+16|0,Q=D[g+16>>2]););D[E>>2]=0}else g=0;else D[(A=D[B+8>>2])+12>>2]=g,D[g+8>>2]=A;if(o){r:{if(D[(A=16216+((Q=D[B+28>>2])<<2)|0)>>2]==(0|B)){if(D[A>>2]=g,g)break r;t=15916,N=D[3979]&JC(Q),D[t>>2]=N;break a}if(D[o+(D[o+16>>2]==(0|B)?16:20)>>2]=g,!g)break a}D[g+24>>2]=o,(A=D[B+16>>2])&&(D[g+16>>2]=A,D[A+24>>2]=g),(A=D[B+20>>2])&&(D[g+20>>2]=A,D[A+24>>2]=g)}}B=B+i|0,C=C+i|0}if(D[B+4>>2]=-2&D[B+4>>2],D[a+4>>2]=1|C,D[C+a>>2]=C,C>>>0<=255){g=15952+((A=C>>>3|0)<<3)|0,(C=D[3978])&(A=1<<A)?A=D[g+8>>2]:(D[3978]=A|C,A=g),D[g+8>>2]=a,D[A+12>>2]=a,D[a+12>>2]=g,D[a+8>>2]=A;break E}if(A=31,C>>>0<=16777215&&(A=C>>>8|0,A<<=E=A+1048320>>>16&8,A=28+((A=((A<<=Q=A+520192>>>16&4)<<(g=A+245760>>>16&2)>>>15|0)-(g|Q|E)|0)<<1|C>>>A+21&1)|0),D[a+28>>2]=A,D[a+16>>2]=0,D[a+20>>2]=0,E=16216+(A<<2)|0,(Q=D[3979])&(g=1<<A)){for(A=C<<(31==(0|A)?0:25-(A>>>1|0)|0),g=D[E>>2];;){if(Q=g,(-8&D[g+4>>2])==(0|C))break i;if(g=A>>>29|0,A<<=1,!(g=D[16+(E=Q+(4&g)|0)>>2]))break}D[E+16>>2]=a,D[a+24>>2]=Q}else D[3979]=g|Q,D[E>>2]=a,D[a+24>>2]=E;D[a+12>>2]=a,D[a+8>>2]=a;break E}for(D[3981]=C=(Q=B-40|0)-(A=g+8&7?-8-g&7:0)|0,D[3984]=A=A+g|0,D[A+4>>2]=1|C,D[4+(g+Q|0)>>2]=40,D[3985]=D[4100],D[(C=(A=(E+(E-39&7?39-E&7:0)|0)-47|0)>>>0<i+16>>>0?i:A)+4>>2]=27,A=D[4093],D[C+16>>2]=D[4092],D[C+20>>2]=A,A=D[4091],D[C+8>>2]=D[4090],D[C+12>>2]=A,D[4092]=C+8,D[4091]=B,D[4090]=g,D[4093]=0,A=C+24|0;D[A+4>>2]=7,g=A+8|0,A=A+4|0,g>>>0<E>>>0;);if((0|C)==(0|i))break Q;if(D[C+4>>2]=-2&D[C+4>>2],D[i+4>>2]=1|(E=C-i|0),D[C>>2]=E,E>>>0<=255){g=15952+((A=E>>>3|0)<<3)|0,(C=D[3978])&(A=1<<A)?A=D[g+8>>2]:(D[3978]=A|C,A=g),D[g+8>>2]=i,D[A+12>>2]=i,D[i+12>>2]=g,D[i+8>>2]=A;break Q}if(A=31,D[i+16>>2]=0,D[i+20>>2]=0,E>>>0<=16777215&&(A=E>>>8|0,A<<=Q=A+1048320>>>16&8,A=28+((A=((A<<=C=A+520192>>>16&4)<<(g=A+245760>>>16&2)>>>15|0)-(g|C|Q)|0)<<1|E>>>A+21&1)|0),D[i+28>>2]=A,Q=16216+(A<<2)|0,(C=D[3979])&(g=1<<A)){for(A=E<<(31==(0|A)?0:25-(A>>>1|0)|0),g=D[Q>>2];;){if(C=g,(0|E)==(-8&D[g+4>>2]))break B;if(g=A>>>29|0,A<<=1,!(g=D[16+(Q=C+(4&g)|0)>>2]))break}D[Q+16>>2]=i,D[i+24>>2]=C}else D[3979]=g|C,D[Q>>2]=i,D[i+24>>2]=Q;D[i+12>>2]=i,D[i+8>>2]=i;break Q}D[(A=D[Q+8>>2])+12>>2]=a,D[Q+8>>2]=a,D[a+24>>2]=0,D[a+12>>2]=Q,D[a+8>>2]=A}A=r+8|0;break A}D[(A=D[C+8>>2])+12>>2]=i,D[C+8>>2]=i,D[i+24>>2]=0,D[i+12>>2]=C,D[i+8>>2]=A}if(!((A=D[3981])>>>0<=o>>>0)){D[3981]=g=A-o|0,D[3984]=A=(C=D[3984])+o|0,D[A+4>>2]=1|g,D[C+4>>2]=3|o,A=C+8|0;break A}}D[3934]=48,A=0;break A}g:if(B){C:{if(D[(A=16216+((C=D[E+28>>2])<<2)|0)>>2]==(0|E)){if(D[A>>2]=g,g)break C;r=JC(C)&r,D[3979]=r;break g}if(D[B+(D[B+16>>2]==(0|E)?16:20)>>2]=g,!g)break g}D[g+24>>2]=B,(A=D[E+16>>2])&&(D[g+16>>2]=A,D[A+24>>2]=g),(A=D[E+20>>2])&&(D[g+20>>2]=A,D[A+24>>2]=g)}g:if(Q>>>0<=15)D[E+4>>2]=3|(A=Q+o|0),D[4+(A=A+E|0)>>2]=1|D[A+4>>2];else if(D[E+4>>2]=3|o,D[4+(B=E+o|0)>>2]=1|Q,D[Q+B>>2]=Q,Q>>>0<=255)g=15952+((A=Q>>>3|0)<<3)|0,(C=D[3978])&(A=1<<A)?A=D[g+8>>2]:(D[3978]=A|C,A=g),D[g+8>>2]=B,D[A+12>>2]=B,D[B+12>>2]=g,D[B+8>>2]=A;else{A=31,Q>>>0<=16777215&&(A=Q>>>8|0,A<<=i=A+1048320>>>16&8,A=28+((A=((A<<=C=A+520192>>>16&4)<<(g=A+245760>>>16&2)>>>15|0)-(g|C|i)|0)<<1|Q>>>A+21&1)|0),D[B+28>>2]=A,D[B+16>>2]=0,D[B+20>>2]=0,g=16216+(A<<2)|0;C:{if((C=1<<A)&r){for(A=Q<<(31==(0|A)?0:25-(A>>>1|0)|0),o=D[g>>2];;){if((-8&D[(g=o)+4>>2])==(0|Q))break C;if(C=A>>>29|0,A<<=1,!(o=D[16+(C=(4&C)+g|0)>>2]))break}D[C+16>>2]=B}else D[3979]=C|r,D[g>>2]=B;D[B+24>>2]=g,D[B+12>>2]=B,D[B+8>>2]=B;break g}D[(A=D[g+8>>2])+12>>2]=B,D[g+8>>2]=B,D[B+24>>2]=0,D[B+12>>2]=g,D[B+8>>2]=A}A=E+8|0;break A}I:if(a){g:{if(D[(A=16216+((C=D[g+28>>2])<<2)|0)>>2]==(0|g)){if(D[A>>2]=E,E)break g;t=15916,N=JC(C)&r,D[t>>2]=N;break I}if(D[a+(D[a+16>>2]==(0|g)?16:20)>>2]=E,!E)break I}D[E+24>>2]=a,(A=D[g+16>>2])&&(D[E+16>>2]=A,D[A+24>>2]=E),(A=D[g+20>>2])&&(D[E+20>>2]=A,D[A+24>>2]=E)}Q>>>0<=15?(D[g+4>>2]=3|(A=Q+o|0),D[4+(A=A+g|0)>>2]=1|D[A+4>>2]):(D[g+4>>2]=3|o,D[4+(E=g+o|0)>>2]=1|Q,D[Q+E>>2]=Q,f&&(C=15952+((A=f>>>3|0)<<3)|0,i=D[3983],(A=1<<A)&B?A=D[C+8>>2]:(D[3978]=A|B,A=C),D[C+8>>2]=i,D[A+12>>2]=i,D[i+12>>2]=C,D[i+8>>2]=A),D[3983]=E,D[3980]=Q),A=g+8|0}return d=I+16|0,0|A}function W(A,I){var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0;d=g=d-48|0,C=DC(8),D[C+4>>2]=I,D[C>>2]=0,D[g+40>>2]=I=C+8|0,D[g+36>>2]=I,D[g+32>>2]=C;A:{I:{g:{C:{for(;;){if(f=D[4+(I=I-8|0)>>2],o=D[I>>2],D[g+36>>2]=I,o){D[g+24>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,C=1;Q:if(!((0|(a=D[(I=D[A>>2])+12>>2]))<=(0|(Q=D[I+20>>2]))&(i=D[I+16>>2])>>>0>=(E=D[I+8>>2])>>>0|(0|Q)>(0|a))){if(E=e[i+D[I>>2]|0],Q=(i=i+1|0)?Q:Q+1|0,D[I+16>>2]=i,D[I+20>>2]=Q,CI(g+16|0,E),E){if(Q=D[A>>2],N=rC(g+16|0),i=D[Q+20>>2],I=E,(s=(r=D[Q+16>>2])+E|0)>>>0>k[Q+8>>2]&(0|(a=D[Q+12>>2]))<=(0|(i=E>>>0>s>>>0?i+1|0:i))|(0|i)>(0|a))break Q;xA(N,r+D[Q>>2]|0,E),C=D[Q+20>>2],C=(E=I+D[Q+16>>2]|0)>>>0<I>>>0?C+1|0:C,D[Q+16>>2]=E,D[Q+20>>2]=C}f=DC(24),D[(I=f)+4>>2]=0,D[I+8>>2]=0,D[(I=I+16|0)>>2]=0,D[I+4>>2]=0,D[f>>2]=f+4,D[f+12>>2]=I,d=E=d-32|0;B:if((0|(t=LI(i=o+12|0,C=g+16|0)))!=(0|(n=o+16|0)))f&&(AC(f+12|0,D[f+16>>2]),aC(f,D[f+4>>2]),sA(f));else{D[E+16>>2]=C;E:{i:{if(I=D[i+4>>2])for(a=(o=(Q=e[C+11|0])<<24>>24<0)?D[C>>2]:C,o=o?D[C+4>>2]:Q,C=i+4|0;;){o:{a:{r:{D:{e:{f:if(r=(N=(Q=(s=(Q=e[I+27|0])<<24>>24<0)?D[I+20>>2]:Q)>>>0<o>>>0)?Q:o){if(F=I+16|0,!(F=cg(a,s=s?D[F>>2]:F,r))){if(Q>>>0>o>>>0)break f;break e}if((0|F)>=0)break e}else if(Q>>>0<=o>>>0)break D;if(Q=D[I>>2])break o;break i}if(Q=cg(s,a,r))break r}if(N)break a;break E}if((0|Q)>=0)break E}if(C=I+4|0,!(Q=D[I+4>>2]))break E;I=C}C=I,I=Q}I=i+4|0}C=I}if((Q=D[C>>2])?I=0:(a=(Q=DC(32))+16|0,B[(o=D[E+16>>2])+11|0]>=0?(s=D[o+4>>2],D[a>>2]=D[o>>2],D[a+4>>2]=s,D[a+8>>2]=D[o+8>>2]):Lg(a,D[o>>2],D[o+4>>2]),D[Q+8>>2]=I,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+28>>2]=0,D[C>>2]=Q,(I=D[D[i>>2]>>2])?(D[i>>2]=I,I=D[C>>2]):I=Q,PA(D[i+4>>2],I),D[i+8>>2]=D[i+8>>2]+1,I=1),B[E+28|0]=I,D[E+24>>2]=Q,I=D[(C=D[E+24>>2])+28>>2],D[C+28>>2]=f,!I)break B;AC(I+12|0,D[I+16>>2]),aC(I,D[I+4>>2]),sA(I)}d=E+32|0,C=(0|t)!=(0|n)}if(B[g+27|0]<0&&sA(D[g+16>>2]),C)break I}if(!f)break I;if(D[g+16>>2]=0,!Gg(1,g+16|0,D[A>>2]))break I;if(I=0,y=D[g+16>>2])for(;;){s=0,d=r=d-32|0,D[r+24>>2]=0,D[r+16>>2]=0,D[r+20>>2]=0;Q:{B:{E:if(!((0|(i=D[(C=D[A>>2])+12>>2]))<=(0|(Q=D[C+20>>2]))&(o=D[C+16>>2])>>>0>=(E=D[C+8>>2])>>>0|(0|Q)>(0|i))){if(i=e[o+D[C>>2]|0],E=C,C=Q,C=(Q=o+1|0)?C:C+1|0,D[E+16>>2]=Q,D[E+20>>2]=C,CI(r+16|0,i),i){if(E=D[A>>2],N=rC(r+16|0),Q=D[E+20>>2],(a=(t=D[E+16>>2])+(C=i)|0)>>>0>k[E+8>>2]&(0|(o=D[E+12>>2]))<=(0|(Q=C>>>0>a>>>0?Q+1|0:Q))|(0|Q)>(0|o))break E;xA(N,t+D[E>>2]|0,i),Q=D[E+20>>2],Q=(i=C+D[E+16>>2]|0)>>>0<C>>>0?Q+1|0:Q,D[E+16>>2]=i,D[E+20>>2]=Q}if(D[r+12>>2]=0,Gg(1,r+12|0,D[A>>2])&&(C=D[r+12>>2])){if(D[r+8>>2]=0,D[r>>2]=0,D[r+4>>2]=0,(0|C)<0)break B;if(Q=DC(C),D[r>>2]=Q,D[r+8>>2]=E=C+Q|0,N=bI(Q,0,C),D[r+4>>2]=E,i=D[(E=D[A>>2])+20>>2],s=(0|(i=(a=C+(t=D[E+16>>2])|0)>>>0<C>>>0?i+1|0:i))<=(0|(o=D[E+12>>2]))&a>>>0<=(s=D[E+8>>2])>>>0|(0|i)<(0|o)){if(xA(N,t+D[E>>2]|0,C),Q=C,i=C+D[E+16>>2]|0,C=D[E+20>>2],D[E+16>>2]=i,D[E+20>>2]=Q>>>0>i>>>0?C+1|0:C,d=o=d-48|0,(0|(Q=LI(f,r+16|0)))!=(f+4|0)){i:if(E=D[Q+4>>2])for(;i=E,E=D[E>>2];);else{if(D[(i=D[Q+8>>2])>>2]==(0|Q))break i;for(C=Q+8|0;C=(E=D[C>>2])+8|0,(0|E)!=D[(i=D[E+8>>2])>>2];);}D[f>>2]==(0|Q)&&(D[f>>2]=i),D[f+8>>2]=D[f+8>>2]-1,i=D[f+4>>2],a=Q;i:{o:{if(E=D[Q>>2]){if(!(C=D[a+4>>2]))break o;for(;Q=C,C=D[C>>2];);}if(!(E=D[Q+4>>2])){E=0,N=1;break i}}D[E+8>>2]=D[Q+8>>2],N=0}i:if((0|Q)!=(0|(C=D[(t=D[Q+8>>2])>>2])))D[t+4>>2]=E;else{if(D[t>>2]=E,(0|Q)==(0|i)){C=0,i=E;break i}C=D[t+4>>2]}F=!e[Q+12|0],(0|Q)!=(0|a)&&(D[Q+8>>2]=t=D[a+8>>2],D[t+(((0|a)!=D[D[a+8>>2]>>2])<<2)>>2]=Q,D[Q>>2]=t=D[a>>2],D[t+8>>2]=Q,D[Q+4>>2]=t=D[a+4>>2],t&&(D[t+8>>2]=Q),B[Q+12|0]=e[a+12|0],i=(0|i)==(0|a)?Q:i);i:if(!(F|!i)){if(N)for(;;){E=e[C+12|0];o:{if(D[(Q=D[C+8>>2])>>2]!=(0|C)){E||(B[C+12|0]=1,B[Q+12|0]=0,D[Q+4>>2]=N=D[(E=D[Q+4>>2])>>2],N&&(D[N+8>>2]=Q),D[E+8>>2]=D[Q+8>>2],D[(((0|Q)!=D[(N=D[Q+8>>2])>>2])<<2)+N>>2]=E,D[E>>2]=Q,D[Q+8>>2]=E,Q=C,i=(0|(C=D[C>>2]))==(0|i)?Q:i,C=D[C+4>>2]);a:{r:{D:{if(e[(Q=D[C>>2])+12|0]||!Q){if(!e[(E=D[C+4>>2])+12|0]&&E)break D;if(B[C+12|0]=0,(0|i)!=(0|(C=D[C+8>>2]))){if(e[C+12|0])break o}else C=i;B[C+12|0]=1;break i}if(!(E=D[C+4>>2]))break r}if(!e[E+12|0]){Q=C;break a}}B[Q+12|0]=1,B[C+12|0]=0,D[C>>2]=E=D[Q+4>>2],E&&(D[E+8>>2]=C),D[Q+8>>2]=D[C+8>>2],D[((D[(E=D[C+8>>2])>>2]!=(0|C))<<2)+E>>2]=Q,D[Q+4>>2]=C,D[C+8>>2]=Q,E=C}B[Q+12|0]=e[(C=D[Q+8>>2])+12|0],B[C+12|0]=1,B[E+12|0]=1,D[C+4>>2]=E=D[(Q=D[C+4>>2])>>2],E&&(D[E+8>>2]=C),D[Q+8>>2]=D[C+8>>2],D[(((0|C)!=D[(E=D[C+8>>2])>>2])<<2)+E>>2]=Q,D[Q>>2]=C,D[C+8>>2]=Q;break i}E||(B[C+12|0]=1,B[Q+12|0]=0,D[Q>>2]=E=D[C+4>>2],E&&(D[E+8>>2]=Q),D[C+8>>2]=D[Q+8>>2],D[(((0|Q)!=D[(E=D[Q+8>>2])>>2])<<2)+E>>2]=C,D[C+4>>2]=Q,D[Q+8>>2]=C,i=(0|Q)==(0|i)?C:i,C=D[Q>>2]);a:if(!(E=D[C>>2])|e[E+12|0]){if(e[(Q=D[C+4>>2])+12|0]||!Q){if(B[C+12|0]=0,(0|(C=D[C+8>>2]))!=(0|i)&&e[C+12|0])break o;B[C+12|0]=1;break i}if(E){if(!e[E+12|0]){Q=C;break a}Q=D[C+4>>2]}B[Q+12|0]=1,B[C+12|0]=0,D[C+4>>2]=E=D[Q>>2],E&&(D[E+8>>2]=C),D[Q+8>>2]=D[C+8>>2],D[((D[(E=D[C+8>>2])>>2]!=(0|C))<<2)+E>>2]=Q,D[Q>>2]=C,D[C+8>>2]=Q,E=C}else Q=C;B[Q+12|0]=e[(C=D[Q+8>>2])+12|0],B[C+12|0]=1,B[E+12|0]=1,D[C>>2]=E=D[(Q=D[C>>2])+4>>2],E&&(D[E+8>>2]=C),D[Q+8>>2]=D[C+8>>2],D[(((0|C)!=D[(E=D[C+8>>2])>>2])<<2)+E>>2]=Q,D[Q+4>>2]=C,D[C+8>>2]=Q;break i}C=D[(((0|(Q=C))==D[(C=D[C+8>>2])>>2])<<2)+C>>2]}B[E+12|0]=1}(C=D[a+28>>2])&&(D[a+32>>2]=C,sA(C)),B[a+27|0]<0&&sA(D[a+16>>2]),sA(a)}D[o>>2]=0,D[o+4>>2]=0,D[o+8>>2]=0,Cg(o,C=D[r+4>>2]-D[r>>2]|0),xA(D[o>>2],D[r>>2],C),B[r+27|0]>=0?(D[o+24>>2]=D[r+24>>2],C=D[r+20>>2],D[o+16>>2]=D[r+16>>2],D[o+20>>2]=C):Lg(o+16|0,D[r+16>>2],D[r+20>>2]),D[o+36>>2]=0,D[o+28>>2]=0,D[o+32>>2]=0,Cg(o+28|0,D[o+4>>2]-D[o>>2]|0),xA(D[o+28>>2],C=D[o>>2],D[o+4>>2]-C|0),Q=i=o+16|0;i:{o:{if(C=D[f+4>>2])for(N=(a=(E=e[Q+11|0])<<24>>24<0)?D[Q>>2]:Q,a=a?D[Q+4>>2]:E,Q=f+4|0;;){a:{r:{D:{e:{f:{k:if(F=(n=(E=(t=(E=e[C+27|0])<<24>>24<0)?D[C+20>>2]:E)>>>0<a>>>0)?E:a){if(R=C+16|0,!(R=cg(N,t=t?D[R>>2]:R,F))){if(E>>>0>a>>>0)break k;break f}if((0|R)>=0)break f}else if(E>>>0<=a>>>0)break e;if(E=D[C>>2])break a;break o}if(E=cg(t,N,F))break D}if(n)break r;break i}if((0|E)>=0)break i}if(Q=C+4|0,!(E=D[C+4>>2]))break i;C=Q}Q=C,C=E}C=f+4|0}Q=C}if((E=D[Q>>2])?C=0:(E=DC(40),D[E+24>>2]=D[i+8>>2],a=D[i+4>>2],D[E+16>>2]=D[i>>2],D[E+20>>2]=a,D[i>>2]=0,D[i+4>>2]=0,D[i+8>>2]=0,D[E+36>>2]=0,D[(a=E+28|0)>>2]=0,D[a+4>>2]=0,Cg(a,D[i+16>>2]-D[i+12>>2]|0),xA(N=D[a>>2],a=D[i+12>>2],D[i+16>>2]-a|0),D[E+8>>2]=C,D[E>>2]=0,D[E+4>>2]=0,D[Q>>2]=E,(C=D[D[f>>2]>>2])?(D[f>>2]=C,C=D[Q>>2]):C=E,PA(D[f+4>>2],C),D[f+8>>2]=D[f+8>>2]+1,C=1),B[o+44|0]=C,D[o+40>>2]=E,(C=D[o+28>>2])&&(D[o+32>>2]=C,sA(C)),B[o+27|0]<0&&sA(D[o+16>>2]),(C=D[o>>2])&&(D[o+4>>2]=C,sA(C)),d=o+48|0,!(Q=D[r>>2]))break E}D[r+4>>2]=Q,sA(Q)}}B[r+27|0]<0&&sA(D[r+16>>2]),d=r+32|0;break Q}iQ(),U()}if(!s)break I;if((0|y)==(0|(I=I+1|0)))break}if(D[g+12>>2]=0,!Gg(1,g+12|0,D[A>>2]))break I;if((E=(C=D[(I=D[A>>2])+8>>2])-(Q=D[I+16>>2])|0)>>>0<(i=D[g+12>>2])>>>0&(0|(I=D[I+12>>2]-(D[I+20>>2]+(C>>>0<Q>>>0)|0)|0))<=0|(0|I)<0)break I;if(C=0,I=D[g+36>>2],i)for(;;){if((E=D[g+40>>2])>>>0>I>>>0)D[I+4>>2]=0,D[I>>2]=f,D[g+36>>2]=I=I+8|0;else{if((I=1+(a=(o=I-(Q=D[g+32>>2])|0)>>3)|0)>>>0>=536870912)break C;if(s=(E=E-Q|0)>>2,(I=E>>3>>>0<268435455?I>>>0>s>>>0?I:s:536870911)>>>0>=536870912)break g;N=a<<3,E=DC(a=I<<3),D[4+(I=N+E|0)>>2]=0,D[I>>2]=f,I=I+8|0,(0|o)>0&&xA(E,Q,o),D[g+40>>2]=E+a,D[g+36>>2]=I,D[g+32>>2]=E,Q&&sA(Q)}if((0|i)==(0|(C=C+1|0)))break}if(D[g+32>>2]==(0|I))break}A=1;break A}iQ(),U()}xg(1336),U()}I=D[g+32>>2],A=0}return I&&sA(I),d=g+48|0,A}function V(A,I,g,C,Q){var E,i=0,o=0,a=0,f=0,t=0,N=0,s=0,F=0,n=0,R=0;d=E=d-32|0,D[I+32>>2]=C,D[I+40>>2]=g,D[I+4>>2]=Q,aA(A,C,E+16|0);A:if(!D[A>>2])if(a=A+4|0,B[A+15|0]<0&&sA(D[a>>2]),C=e[E+23|0],(0|RQ[D[D[I>>2]+8>>2]](I))==(0|C))if(B[I+36|0]=g=e[E+21|0],B[I+37|0]=Q=e[E+22|0],(g-3&255)>>>0<=253)I=DC(32),g=e[1571]|e[1572]<<8|e[1573]<<16|e[1574]<<24,B[I+14|0]=C=e[1567]|e[1568]<<8|e[1569]<<16|e[1570]<<24,B[I+15|0]=C>>>8,B[I+16|0]=C>>>16,B[I+17|0]=C>>>24,B[I+18|0]=g,B[I+19|0]=g>>>8,B[I+20|0]=g>>>16,B[I+21|0]=g>>>24,g=e[1565]|e[1566]<<8|e[1567]<<16|e[1568]<<24,B[I+8|0]=C=e[1561]|e[1562]<<8|e[1563]<<16|e[1564]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1557]|e[1558]<<8|e[1559]<<16|e[1560]<<24,B[0|I]=C=e[1553]|e[1554]<<8|e[1555]<<16|e[1556]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+22|0]=0,D[A>>2]=-5,Lg(a,I,22),sA(I);else if(2!=(0|g)|Q>>>0<=(C?2:3)>>>0){if(r[D[I+32>>2]+38>>1]=g=Q|g<<8,!((65535&g)>>>0<259|r[E+26>>1]>=0)){d=f=d-16|0,Q=DC(36),D[(g=Q)+4>>2]=0,D[g+8>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,D[(g=g+16|0)>>2]=0,D[g+4>>2]=0,D[Q>>2]=Q+4,D[Q+32>>2]=0,D[Q+12>>2]=g,D[f>>2]=0,C=D[I+32>>2],d=t=d-16|0,g=0;I:if(Q&&(D[f>>2]=C,D[t+12>>2]=0,g=0,Gg(1,t+12|0,C))){if(F=D[t+12>>2])for(;;){g:{if(Gg(1,t+8|0,D[f>>2])){if(g=DC(28),D[g+4>>2]=0,D[g+8>>2]=0,D[(C=g+16|0)>>2]=0,D[C+4>>2]=0,D[g>>2]=g+4,D[g+12>>2]=C,D[g+24>>2]=D[t+8>>2],W(f,g))break g;AC(g+12|0,D[g+16>>2]),aC(g,D[g+4>>2]),sA(g)}g=0;break I}if(d=i=d-16|0,D[i+8>>2]=g,g){if((C=D[Q+28>>2])>>>0<k[Q+32>>2])D[i+8>>2]=0,D[C>>2]=g,D[Q+28>>2]=C+4;else{C=0;g:{C:{Q:{if((g=1+(s=D[Q+28>>2]-(o=D[Q+24>>2])>>2)|0)>>>0<1073741824){if(N=(o=D[Q+32>>2]-o|0)>>1,g=o>>2>>>0<536870911?g>>>0>N>>>0?g:N:1073741823){if(g>>>0>=1073741824)break Q;C=DC(g<<2)}if(N=D[i+8>>2],D[i+8>>2]=0,D[(o=(s<<2)+C|0)>>2]=N,s=(g<<2)+C|0,N=o+4|0,(0|(C=D[Q+28>>2]))==(0|(g=D[Q+24>>2])))break C;for(;R=D[(C=C-4|0)>>2],D[C>>2]=0,D[(o=o-4|0)>>2]=R,(0|g)!=(0|C););if(D[Q+32>>2]=s,C=D[Q+28>>2],D[Q+28>>2]=N,g=D[Q+24>>2],D[Q+24>>2]=o,(0|g)==(0|C))break g;for(;o=D[(C=C-4|0)>>2],D[C>>2]=0,o&&(AC(o+12|0,D[o+16>>2]),aC(o,D[o+4>>2]),sA(o)),(0|g)!=(0|C););break g}iQ(),U()}xg(1336),U()}D[Q+32>>2]=s,D[Q+28>>2]=N,D[Q+24>>2]=o}g&&sA(g)}g=D[i+8>>2],D[i+8>>2]=0,g&&(AC(g+12|0,D[g+16>>2]),aC(g,D[g+4>>2]),sA(g))}else D[i+8>>2]=0;if(d=i+16|0,(0|F)==(0|(n=n+1|0)))break}g=W(f,Q)}if(d=t+16|0,g?(g=D[(C=D[I+4>>2])+4>>2],D[C+4>>2]=Q,g&&wg(g),D[A>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0):(g=DC(32),B[g+24|0]=C=e[1723]|e[1724]<<8,B[g+25|0]=C>>>8,C=e[1719]|e[1720]<<8|e[1721]<<16|e[1722]<<24,B[g+16|0]=i=e[1715]|e[1716]<<8|e[1717]<<16|e[1718]<<24,B[g+17|0]=i>>>8,B[g+18|0]=i>>>16,B[g+19|0]=i>>>24,B[g+20|0]=C,B[g+21|0]=C>>>8,B[g+22|0]=C>>>16,B[g+23|0]=C>>>24,C=e[1711]|e[1712]<<8|e[1713]<<16|e[1714]<<24,B[g+8|0]=i=e[1707]|e[1708]<<8|e[1709]<<16|e[1710]<<24,B[g+9|0]=i>>>8,B[g+10|0]=i>>>16,B[g+11|0]=i>>>24,B[g+12|0]=C,B[g+13|0]=C>>>8,B[g+14|0]=C>>>16,B[g+15|0]=C>>>24,C=e[1703]|e[1704]<<8|e[1705]<<16|e[1706]<<24,B[0|g]=i=e[1699]|e[1700]<<8|e[1701]<<16|e[1702]<<24,B[g+1|0]=i>>>8,B[g+2|0]=i>>>16,B[g+3|0]=i>>>24,B[g+4|0]=C,B[g+5|0]=C>>>8,B[g+6|0]=C>>>16,B[g+7|0]=C>>>24,B[g+26|0]=0,D[A>>2]=-1,Lg(A+4|0,g,26),sA(g),D[f+8>>2]=0,wg(Q)),d=f+16|0,D[A>>2])break A;B[a+11|0]>=0||sA(D[a>>2])}if(0|RQ[D[D[I>>2]+12>>2]](I))if(0|RQ[D[D[I>>2]+20>>2]](I))if(0|RQ[D[D[I>>2]+24>>2]](I))D[A>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0;else{if(I=Vg(E,1461),D[A>>2]=-1,B[I+11|0]>=0){A=D[E+4>>2],D[a>>2]=D[E>>2],D[a+4>>2]=A,D[a+8>>2]=D[E+8>>2];break A}if(Lg(a,D[I>>2],D[I+4>>2]),B[I+11|0]>=0)break A;sA(D[I>>2])}else{if(I=Vg(E,1726),D[A>>2]=-1,B[I+11|0]>=0){A=D[E+4>>2],D[a>>2]=D[E>>2],D[a+4>>2]=A,D[a+8>>2]=D[E+8>>2];break A}if(Lg(a,D[I>>2],D[I+4>>2]),B[I+11|0]>=0)break A;sA(D[I>>2])}else I=DC(48),B[I+32|0]=e[1528],g=e[1524]|e[1525]<<8|e[1526]<<16|e[1527]<<24,B[I+24|0]=C=e[1520]|e[1521]<<8|e[1522]<<16|e[1523]<<24,B[I+25|0]=C>>>8,B[I+26|0]=C>>>16,B[I+27|0]=C>>>24,B[I+28|0]=g,B[I+29|0]=g>>>8,B[I+30|0]=g>>>16,B[I+31|0]=g>>>24,g=e[1516]|e[1517]<<8|e[1518]<<16|e[1519]<<24,B[I+16|0]=C=e[1512]|e[1513]<<8|e[1514]<<16|e[1515]<<24,B[I+17|0]=C>>>8,B[I+18|0]=C>>>16,B[I+19|0]=C>>>24,B[I+20|0]=g,B[I+21|0]=g>>>8,B[I+22|0]=g>>>16,B[I+23|0]=g>>>24,g=e[1508]|e[1509]<<8|e[1510]<<16|e[1511]<<24,B[I+8|0]=C=e[1504]|e[1505]<<8|e[1506]<<16|e[1507]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1500]|e[1501]<<8|e[1502]<<16|e[1503]<<24,B[0|I]=C=e[1496]|e[1497]<<8|e[1498]<<16|e[1499]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+33|0]=0,D[A>>2]=-1,Lg(a,I,33),sA(I)}else I=DC(32),g=e[1548]|e[1549]<<8|e[1550]<<16|e[1551]<<24,B[I+14|0]=C=e[1544]|e[1545]<<8|e[1546]<<16|e[1547]<<24,B[I+15|0]=C>>>8,B[I+16|0]=C>>>16,B[I+17|0]=C>>>24,B[I+18|0]=g,B[I+19|0]=g>>>8,B[I+20|0]=g>>>16,B[I+21|0]=g>>>24,g=e[1542]|e[1543]<<8|e[1544]<<16|e[1545]<<24,B[I+8|0]=C=e[1538]|e[1539]<<8|e[1540]<<16|e[1541]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1534]|e[1535]<<8|e[1536]<<16|e[1537]<<24,B[0|I]=C=e[1530]|e[1531]<<8|e[1532]<<16|e[1533]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+22|0]=0,D[A>>2]=-5,Lg(a,I,22),sA(I);else I=DC(64),B[I+48|0]=g=e[1458]|e[1459]<<8,B[I+49|0]=g>>>8,g=e[1454]|e[1455]<<8|e[1456]<<16|e[1457]<<24,B[I+40|0]=C=e[1450]|e[1451]<<8|e[1452]<<16|e[1453]<<24,B[I+41|0]=C>>>8,B[I+42|0]=C>>>16,B[I+43|0]=C>>>24,B[I+44|0]=g,B[I+45|0]=g>>>8,B[I+46|0]=g>>>16,B[I+47|0]=g>>>24,g=e[1446]|e[1447]<<8|e[1448]<<16|e[1449]<<24,B[I+32|0]=C=e[1442]|e[1443]<<8|e[1444]<<16|e[1445]<<24,B[I+33|0]=C>>>8,B[I+34|0]=C>>>16,B[I+35|0]=C>>>24,B[I+36|0]=g,B[I+37|0]=g>>>8,B[I+38|0]=g>>>16,B[I+39|0]=g>>>24,g=e[1438]|e[1439]<<8|e[1440]<<16|e[1441]<<24,B[I+24|0]=C=e[1434]|e[1435]<<8|e[1436]<<16|e[1437]<<24,B[I+25|0]=C>>>8,B[I+26|0]=C>>>16,B[I+27|0]=C>>>24,B[I+28|0]=g,B[I+29|0]=g>>>8,B[I+30|0]=g>>>16,B[I+31|0]=g>>>24,g=e[1430]|e[1431]<<8|e[1432]<<16|e[1433]<<24,B[I+16|0]=C=e[1426]|e[1427]<<8|e[1428]<<16|e[1429]<<24,B[I+17|0]=C>>>8,B[I+18|0]=C>>>16,B[I+19|0]=C>>>24,B[I+20|0]=g,B[I+21|0]=g>>>8,B[I+22|0]=g>>>16,B[I+23|0]=g>>>24,g=e[1422]|e[1423]<<8|e[1424]<<16|e[1425]<<24,B[I+8|0]=C=e[1418]|e[1419]<<8|e[1420]<<16|e[1421]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1414]|e[1415]<<8|e[1416]<<16|e[1417]<<24,B[0|I]=C=e[1410]|e[1411]<<8|e[1412]<<16|e[1413]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+50|0]=0,D[A>>2]=-1,Lg(a,I,50),sA(I);d=E+32|0}function _(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0;if(C=D[I+20>>2],!((Q=(o=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(C=Q>>>0<4?C+1|0:C))>=(0|(B=D[I+12>>2]))|(0|C)>(0|B)||(D[A>>2]=e[0|(C=o+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,B=C=D[I+20>>2],C=(o=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C,a=o,D[I+16>>2]=o,D[I+20>>2]=C,k[A>>2]>32||(C=B,(B=Q+8|0)>>>0>k[I+8>>2]&(0|(C=B>>>0<8?C+1|0:C))>=(0|(o=D[I+12>>2]))|(0|C)>(0|o))))){if(D[A+4>>2]=i=e[0|(C=a+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(B=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=B,D[I+20>>2]=C,!i)return 1;if(i=0,D[A+8>>2]=0,wI(A+16|0,I)&&wI(A+36|0,I)&&wI(A+56|0,I)&&wI(A+76|0,I)){G=D[A+4>>2],o=g,I=0,g=0,d=Q=d-32|0,B=A,A=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(A){if(A>>>0>=1073741824)break I;I=DC(C=A<<2),D[Q+8>>2]=I,D[Q+16>>2]=g=I+C|0,bI(I,0,C),D[Q+12>>2]=g}(i=D[(C=D[B+120>>2])>>2])&&(D[C+4>>2]=i,sA(i),D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,g=D[Q+12>>2],I=D[Q+8>>2],A=D[B+12>>2]),D[C+4>>2]=g,D[C>>2]=I,D[C+8>>2]=D[Q+16>>2],I=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;g:{if(A){if(A>>>0>=1073741824)break g;E=DC(A<<=2),D[Q+8>>2]=E,D[Q+16>>2]=I=A+E|0,bI(E,0,A),D[Q+12>>2]=I}(g=D[(A=D[B+132>>2])>>2])&&(D[A+4>>2]=g,sA(g),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,E=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=E,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=G,C=1,D[Q+28>>2]=A=(I=D[Q+28>>2])+1|0;C:if(!(A>>>0<I>>>0)){for(;;){if(g=D[(r=D[Q+12>>2])+((g=((I=(C=D[Q+24>>2])+(E=A-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(g,341)|0,12)|0,I=D[g+8>>2],i=D[g+4>>2],a=D[g>>2],D[Q+28>>2]=E,1+(((E=(g=D[Q+16>>2])-r|0)?s(E>>2,341)-1|0:0)-(A+C|0)|0)>>>0>=682&&(sA(D[g-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),C=0,a>>>0>G>>>0)break C;if((E=(0|i)==((A=D[B+12>>2])-1|0)?0:i+1|0)>>>0>=A>>>0)break C;r=(f=s(I,12))+D[B+120>>2]|0;Q:{B:{if(!(g=D[B>>2]-D[(F=E<<2)+D[(t=f+D[B+132>>2]|0)>>2]>>2]|0)){if(!a)break B;if(t=0,(0|(A=D[o+16>>2]))==(0|(E=D[o+20>>2]))){A=D[B+8>>2],D[o+28>>2]=a+D[o+28>>2],D[B+8>>2]=A+a;break B}for(;;){i=0;E:if((0|A)!=(0|E))for(;;){if(C=s(i,20)+A|0,g=D[r>>2]+(D[C+4>>2]<<2)|0,f=D[C>>2],!((E=D[C+12>>2])>>>0>3))if(I=D[o+12>>2],D[C+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[C+12>>2])|0,(A=A+1|0)>>>0<k[C+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break E;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|a)==(0|(t=t+1|0)))break B;A=D[o+16>>2],E=D[o+20>>2]}}E:{i:{o:{a:{if(a>>>0<=2){if(D[(g=D[B+108>>2])>>2]=E,I=1,(A=D[B+12>>2])>>>0>1)break a;break E}if(k[B+8>>2]>k[B+4>>2])break C;(0|(C=(A=D[B+120>>2])+(t=s(N=I+1|0,12))|0))!=(0|r)&&(qI(C,D[r>>2],D[r+4>>2]),A=D[B+120>>2]),D[(A=F+D[A+t>>2]|0)>>2]=D[A>>2]+(1<<g-1);r:if((0|(A=31^R(a)))<=(0|(i=32-(g=D[B+32>>2])|0))){if((0|(i=D[B+28>>2]))==D[B+20>>2]){C=0;break r}if(C=D[i>>2],D[B+32>>2]=r=A+g|0,C=C<<g>>>32-A|0,32!=(0|r))break r;D[B+32>>2]=0,D[B+28>>2]=i+4}else(0|(r=(C=D[B+28>>2])+4|0))!=D[B+20>>2]?(y=D[C>>2],D[B+28>>2]=r,D[B+32>>2]=i=A-i|0,C=D[C+4>>2]>>>32-i|y<<g>>>32-A):C=0;if((0|(C=a-(A=(a>>>1|0)-C|0)|0))!=(0|A)){if((0|(g=D[B+88>>2]))==D[B+80>>2])break o;i=D[g>>2],D[B+92>>2]=r=(a=D[B+92>>2])+1|0,i&=-2147483648>>>a;r:{if(32==(0|r)){if(D[B+92>>2]=0,D[B+88>>2]=g+4,i)break r;break o}if(!i)break o}}else C=A;i=C,C=A;break i}for(;D[g+(I<<2)>>2]=E=(A-1|0)==(0|E)?0:E+1|0,(A=D[B+12>>2])>>>0>(I=I+1|0)>>>0;);break E}i=A}if(D[(r=(a=D[(g=(A=D[B+132>>2])+f|0)>>2])+F|0)>>2]=D[r>>2]+1,qI(A+t|0,a,D[g+4>>2]),C&&((0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((a=D[Q+16>>2]-(g=D[Q+12>>2])|0)?s(a>>2,341)-1|0:0))&&(AI(Q+8|0),g=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(a=g)+((g=(A>>>0)/341|0)<<2)>>2]+s(A-s(g,341)|0,12)|0,D[A+8>>2]=I,D[A+4>>2]=E,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!i)break B;(0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((g=D[Q+16>>2]-(I=D[Q+12>>2])|0)?s(g>>2,341)-1|0:0))&&(AI(Q+8|0),I=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(g=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=N,D[A+4>>2]=E,D[A>>2]=i,D[Q+28>>2]=A=D[Q+28>>2]+1|0;break Q}if(F=0,a)for(;;){if(A)for(i=D[B+40>>2],C=D[B+96>>2],y=D[B+108>>2],w=D[r>>2],b=D[t>>2],A=0;;){D[C+(D[(E=y+(A<<2)|0)>>2]<<2)>>2]=0;E:if(I=D[B>>2]-D[(g=D[E>>2]<<2)+b>>2]|0)if(g=g+C|0,(0|(n=32-(f=D[B+52>>2])|0))>=(0|I)){if((0|(N=D[B+48>>2]))==(0|i)){D[g>>2]=0;break E}if(D[g>>2]=D[N>>2]<<f>>>32-I,D[B+52>>2]=I=I+D[B+52>>2]|0,32!=(0|I))break E;D[B+52>>2]=0,D[B+48>>2]=N+4}else(0|i)!=(0|(c=(N=D[B+48>>2])+4|0))?(h=D[N>>2],D[B+48>>2]=c,D[B+52>>2]=n=I-n|0,D[g>>2]=D[N+4>>2]>>>32-n|h<<f>>>32-I):D[g>>2]=0;if(D[(g=(I=D[E>>2]<<2)+C|0)>>2]=D[g>>2]|D[I+w>>2],!((A=A+1|0)>>>0<k[B+12>>2]))break}i=0;E:if((0|(A=D[o+16>>2]))!=D[o+20>>2])for(;;){if(C=s(i,20)+A|0,g=D[B+96>>2]+(D[C+4>>2]<<2)|0,f=D[C>>2],!((E=D[C+12>>2])>>>0>3))if(I=D[o+12>>2],D[C+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[C+12>>2])|0,(A=A+1|0)>>>0<k[C+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break E;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|a)==(0|(F=F+1|0)))break B;A=D[B+12>>2]}}A=D[Q+28>>2]}if(!A)break}C=1}if(D[Q+28>>2]=0,(I=(E=D[Q+16>>2])-(A=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[A>>2]),D[Q+12>>2]=A=D[Q+12>>2]+4|0,(I=(E=D[Q+16>>2])-A>>2)>>>0>2;);g=170;C:switch(I-1|0){case 1:g=341;case 0:D[Q+24>>2]=g}if((0|A)!=(0|E)){for(;sA(D[A>>2]),(0|E)!=(0|(A=A+4|0)););(0|(A=D[Q+16>>2]))!=(0|(I=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-I|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}i=C}}return i}function T(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0;if(C=D[I+20>>2],!((Q=(o=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(C=Q>>>0<4?C+1|0:C))>=(0|(B=D[I+12>>2]))|(0|C)>(0|B)||(D[A>>2]=e[0|(C=o+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,B=C=D[I+20>>2],C=(o=(Q=D[I+16>>2])+4|0)>>>0<4?B+1|0:B,r=o,D[I+16>>2]=o,D[I+20>>2]=C,k[A>>2]>32||(C=B,(B=Q+8|0)>>>0>k[I+8>>2]&(0|(C=B>>>0<8?C+1|0:C))>=(0|(o=D[I+12>>2]))|(0|C)>(0|o))))){if(D[A+4>>2]=E=e[0|(C=r+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(B=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=B,D[I+20>>2]=C,!E)return 1;if(E=0,D[A+8>>2]=0,wI(A+16|0,I)&&wI(A+36|0,I)&&wI(A+56|0,I)&&wI(A+76|0,I)){n=D[A+4>>2],o=g,I=0,g=0,d=Q=d-32|0,B=A,A=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(A){if(A>>>0>=1073741824)break I;I=DC(C=A<<2),D[Q+8>>2]=I,D[Q+16>>2]=g=I+C|0,bI(I,0,C),D[Q+12>>2]=g}(E=D[(C=D[B+120>>2])>>2])&&(D[C+4>>2]=E,sA(E),D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,g=D[Q+12>>2],I=D[Q+8>>2],A=D[B+12>>2]),D[C+4>>2]=g,D[C>>2]=I,D[C+8>>2]=D[Q+16>>2],I=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;g:{if(A){if(A>>>0>=1073741824)break g;i=DC(A<<=2),D[Q+8>>2]=i,D[Q+16>>2]=I=A+i|0,bI(i,0,A),D[Q+12>>2]=I}(g=D[(A=D[B+132>>2])>>2])&&(D[A+4>>2]=g,sA(g),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,i=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=i,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=n,C=1,D[Q+28>>2]=A=(I=D[Q+28>>2])+1|0;C:if(!(A>>>0<I>>>0)){for(;;){if(I=D[(a=D[Q+12>>2])+((g=((I=(C=D[Q+24>>2])+(i=A-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(g,341)|0,12)|0,g=D[I+8>>2],E=D[I+4>>2],r=D[I>>2],D[Q+28>>2]=i,1+(((i=(I=D[Q+16>>2])-a|0)?s(i>>2,341)-1|0:0)-(A+C|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),r>>>0>n>>>0){C=0;break C}if(C=0,(i=(0|E)==((A=D[B+12>>2])-1|0)?0:E+1|0)>>>0>=A>>>0)break C;t=(A=D[B+120>>2])+(I=s(g,12))|0;Q:{B:{if(!(E=D[B>>2]-D[(a=i<<2)+D[(y=I+D[B+132>>2]|0)>>2]>>2]|0)){if(!r)break B;if((0|(A=D[o+16>>2]))==(0|(i=D[o+20>>2]))){A=D[B+8>>2],D[o+28>>2]=r+D[o+28>>2],D[B+8>>2]=A+r;break B}for(;;){E=0;E:if((0|A)!=(0|i))for(;;){if(a=s(E,20)+A|0,g=D[t>>2]+(D[a+4>>2]<<2)|0,f=D[a>>2],!((i=D[a+12>>2])>>>0>3))if(I=D[o+12>>2],D[a+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,i))+(i=D[a+12>>2])|0,(A=A+1|0)>>>0<k[a+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break E;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((E=E+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|r)==(0|(C=C+1|0)))break B;A=D[o+16>>2],i=D[o+20>>2]}}E:{i:{o:{a:{if(r>>>0<=2){if(D[(g=D[B+108>>2])>>2]=i,I=1,(A=D[B+12>>2])>>>0>1)break a;break E}if(k[B+8>>2]>k[B+4>>2])break C;qI((C=A)+(A=I+12|0)|0,D[t>>2],D[t+4>>2]),D[(A=a+D[A+D[B+120>>2]>>2]|0)>>2]=D[A>>2]+(1<<E-1);r:if((0|(A=31^R(r)))<=(0|(f=32-(C=D[B+32>>2])|0))){if((0|(E=D[B+28>>2]))==D[B+20>>2]){C=0;break r}if(f=D[E>>2],D[B+32>>2]=t=A+C|0,C=f<<C>>>32-A|0,32!=(0|t))break r;D[B+32>>2]=0,D[B+28>>2]=E+4}else(0|(t=(E=D[B+28>>2])+4|0))!=D[B+20>>2]?(N=D[E>>2],D[B+28>>2]=t,D[B+32>>2]=f=A-f|0,C=D[E+4>>2]>>>32-f|N<<C>>>32-A):C=0;if(f=g+1|0,(0|(C=r-(A=(r>>>1|0)-C|0)|0))!=(0|A)){if((0|(E=D[B+88>>2]))==D[B+80>>2])break o;r=D[E>>2],D[B+92>>2]=N=(t=D[B+92>>2])+1|0,r&=-2147483648>>>t;r:{if(32==(0|N)){if(D[B+92>>2]=0,D[B+88>>2]=E+4,r)break r;break o}if(!r)break o}}else C=A;E=C,C=A;break i}for(;D[g+(I<<2)>>2]=i=(A-1|0)==(0|i)?0:i+1|0,(A=D[B+12>>2])>>>0>(I=I+1|0)>>>0;);break E}E=A}if(D[(a=(r=D[(I=(A=D[B+132>>2])+I|0)>>2])+a|0)>>2]=D[a>>2]+1,qI(A+s(f,12)|0,r,D[I+4>>2]),C&&((0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((r=D[Q+16>>2]-(I=D[Q+12>>2])|0)?s(r>>2,341)-1|0:0))&&(AI(Q+8|0),I=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(r=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=g,D[A+4>>2]=i,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!E)break B;(0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((g=D[Q+16>>2]-(I=D[Q+12>>2])|0)?s(g>>2,341)-1|0:0))&&(AI(Q+8|0),I=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(g=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=f,D[A+4>>2]=i,D[A>>2]=E,D[Q+28>>2]=A=D[Q+28>>2]+1|0;break Q}if(r)for(;;){if(A)for(i=D[B+40>>2],E=D[B+96>>2],c=D[B+108>>2],w=D[t>>2],b=D[y>>2],A=0;;){D[E+(D[(a=(A<<2)+c|0)>>2]<<2)>>2]=0;E:if(I=D[B>>2]-D[(g=D[a>>2]<<2)+b>>2]|0)if(g=g+E|0,(0|(F=32-(f=D[B+52>>2])|0))>=(0|I)){if((0|(N=D[B+48>>2]))==(0|i)){D[g>>2]=0;break E}if(D[g>>2]=D[N>>2]<<f>>>32-I,D[B+52>>2]=I=I+D[B+52>>2]|0,32!=(0|I))break E;D[B+52>>2]=0,D[B+48>>2]=N+4}else(0|i)!=(0|(G=(N=D[B+48>>2])+4|0))?(h=D[N>>2],D[B+48>>2]=G,D[B+52>>2]=F=I-F|0,D[g>>2]=D[N+4>>2]>>>32-F|h<<f>>>32-I):D[g>>2]=0;if(D[(g=(I=D[a>>2]<<2)+E|0)>>2]=D[g>>2]|D[I+w>>2],!((A=A+1|0)>>>0<k[B+12>>2]))break}E=0;E:if((0|(A=D[o+16>>2]))!=D[o+20>>2])for(;;){if(a=s(E,20)+A|0,g=D[B+96>>2]+(D[a+4>>2]<<2)|0,f=D[a>>2],!((i=D[a+12>>2])>>>0>3))if(I=D[o+12>>2],D[a+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,i))+(i=D[a+12>>2])|0,(A=A+1|0)>>>0<k[a+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break E;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((E=E+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|r)==(0|(C=C+1|0)))break B;A=D[B+12>>2]}}A=D[Q+28>>2]}if(!A)break}C=1}if(D[Q+28>>2]=0,(I=(i=D[Q+16>>2])-(A=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[A>>2]),D[Q+12>>2]=A=D[Q+12>>2]+4|0,(I=(i=D[Q+16>>2])-A>>2)>>>0>2;);g=170;C:switch(I-1|0){case 1:g=341;case 0:D[Q+24>>2]=g}if((0|A)!=(0|i)){for(;sA(D[A>>2]),(0|i)!=(0|(A=A+4|0)););(0|(A=D[Q+16>>2]))!=(0|(I=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-I|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}E=C}}return E}function m(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0;if(C=D[I+20>>2],!((Q=(o=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(C=Q>>>0<4?C+1|0:C))>=(0|(B=D[I+12>>2]))|(0|C)>(0|B)||(D[A>>2]=e[0|(C=o+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,B=C=D[I+20>>2],C=(o=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C,a=o,D[I+16>>2]=o,D[I+20>>2]=C,k[A>>2]>32||(C=B,(B=Q+8|0)>>>0>k[I+8>>2]&(0|(C=B>>>0<8?C+1|0:C))>=(0|(o=D[I+12>>2]))|(0|C)>(0|o))))){if(D[A+4>>2]=i=e[0|(C=a+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(B=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=B,D[I+20>>2]=C,!i)return 1;if(i=0,D[A+8>>2]=0,TA(A+16|0,I)&&wI(A+32|0,I)&&wI(A+52|0,I)&&wI(A+72|0,I)){y=D[A+4>>2],o=g,I=0,g=0,d=Q=d-32|0,B=A,A=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(A){if(A>>>0>=1073741824)break I;I=DC(C=A<<2),D[Q+8>>2]=I,D[Q+16>>2]=g=I+C|0,bI(I,0,C),D[Q+12>>2]=g}(i=D[(C=D[B+116>>2])>>2])&&(D[C+4>>2]=i,sA(i),D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,g=D[Q+12>>2],I=D[Q+8>>2],A=D[B+12>>2]),D[C+4>>2]=g,D[C>>2]=I,D[C+8>>2]=D[Q+16>>2],I=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;g:{if(A){if(A>>>0>=1073741824)break g;E=DC(A<<=2),D[Q+8>>2]=E,D[Q+16>>2]=I=A+E|0,bI(E,0,A),D[Q+12>>2]=I}(g=D[(A=D[B+128>>2])>>2])&&(D[A+4>>2]=g,sA(g),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,E=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=E,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=y,C=1,D[Q+28>>2]=A=(I=D[Q+28>>2])+1|0;C:if(!(A>>>0<I>>>0)){for(c=B+16|0;;){if(g=D[(f=D[Q+12>>2])+((g=((I=(C=D[Q+24>>2])+(E=A-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(g,341)|0,12)|0,I=D[g+8>>2],i=D[g+4>>2],a=D[g>>2],D[Q+28>>2]=E,1+(((E=(g=D[Q+16>>2])-f|0)?s(E>>2,341)-1|0:0)-(A+C|0)|0)>>>0>=682&&(sA(D[g-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),C=0,a>>>0>y>>>0)break C;if((E=((A=D[B+12>>2])-1|0)==(0|i)?0:i+1|0)>>>0>=A>>>0)break C;f=(g=s(I,12))+D[B+116>>2]|0;Q:{if(!(i=D[B>>2]-D[(r=E<<2)+D[(t=g+D[B+128>>2]|0)>>2]>>2]|0)){if(!a)break Q;if(t=0,(0|(A=D[o+16>>2]))==(0|(E=D[o+20>>2]))){A=D[B+8>>2],D[o+28>>2]=a+D[o+28>>2],D[B+8>>2]=A+a;break Q}for(;;){i=0;B:if((0|A)!=(0|E))for(;;){if(C=s(i,20)+A|0,g=D[f>>2]+(D[C+4>>2]<<2)|0,r=D[C>>2],!((E=D[C+12>>2])>>>0>3))if(I=D[o+12>>2],D[C+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[C+12>>2])|0,(A=A+1|0)>>>0<k[C+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[r+84|0]?A:D[D[r+68>>2]+(A<<2)>>2])>>>0>=k[r+80>>2])break B;if(xA(D[D[r>>2]>>2]+s(I=A,A=D[r+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|a)==(0|(t=t+1|0)))break Q;A=D[o+16>>2],E=D[o+20>>2]}}B:{E:{i:{o:{if(a>>>0<=2){if(D[(g=D[B+104>>2])>>2]=E,I=1,(A=D[B+12>>2])>>>0>1)break o;break B}if(k[B+8>>2]>k[B+4>>2])break C;if((0|(C=(A=D[B+116>>2])+(t=s(F=I+1|0,12))|0))!=(0|f)&&(qI(C,D[f>>2],D[f+4>>2]),A=D[B+116>>2]),D[(A=r+D[A+t>>2]|0)>>2]=D[A>>2]+(1<<i-1),D[Q+4>>2]=0,eg(c,31^R(a),Q+4|0),(0|(C=a-(A=(a>>>1|0)-D[Q+4>>2]|0)|0))!=(0|A)){if((0|(i=D[B+84>>2]))==D[B+76>>2])break i;a=D[i>>2],D[B+88>>2]=N=(f=D[B+88>>2])+1|0,a&=-2147483648>>>f;a:{if(32==(0|N)){if(D[B+88>>2]=0,D[B+84>>2]=i+4,a)break a;break i}if(!a)break i}}else C=A;i=C,C=A;break E}for(;D[g+(I<<2)>>2]=E=(A-1|0)==(0|E)?0:E+1|0,(A=D[B+12>>2])>>>0>(I=I+1|0)>>>0;);break B}i=A}if(D[(f=(a=D[(g=(A=D[B+128>>2])+g|0)>>2])+r|0)>>2]=D[f>>2]+1,qI(A+t|0,a,D[g+4>>2]),C&&((0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((a=D[Q+16>>2]-(g=D[Q+12>>2])|0)?s(a>>2,341)-1|0:0))&&(AI(Q+8|0),g=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(a=g)+((g=(A>>>0)/341|0)<<2)>>2]+s(A-s(g,341)|0,12)|0,D[A+8>>2]=I,D[A+4>>2]=E,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!i)break Q;(0|(A=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((g=D[Q+16>>2]-(I=D[Q+12>>2])|0)?s(g>>2,341)-1|0:0))&&(AI(Q+8|0),I=D[Q+12>>2],A=D[Q+24>>2]+D[Q+28>>2]|0),A=D[(g=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=F,D[A+4>>2]=E,D[A>>2]=i,D[Q+28>>2]=D[Q+28>>2]+1;break Q}if(F=0,a)for(;;){if(A)for(i=D[B+36>>2],C=D[B+92>>2],w=D[B+104>>2],b=D[f>>2],h=D[t>>2],A=0;;){D[C+(D[(E=(A<<2)+w|0)>>2]<<2)>>2]=0;B:if(I=D[B>>2]-D[(g=D[E>>2]<<2)+h>>2]|0)if(g=g+C|0,(0|(n=32-(r=D[B+48>>2])|0))>=(0|I)){if((0|(N=D[B+44>>2]))==(0|i)){D[g>>2]=0;break B}if(D[g>>2]=D[N>>2]<<r>>>32-I,D[B+48>>2]=I=I+D[B+48>>2]|0,32!=(0|I))break B;D[B+48>>2]=0,D[B+44>>2]=N+4}else(0|i)!=(0|(G=(N=D[B+44>>2])+4|0))?(J=D[N>>2],D[B+44>>2]=G,D[B+48>>2]=n=I-n|0,D[g>>2]=D[N+4>>2]>>>32-n|J<<r>>>32-I):D[g>>2]=0;if(D[(g=(I=D[E>>2]<<2)+C|0)>>2]=D[g>>2]|D[I+b>>2],!((A=A+1|0)>>>0<k[B+12>>2]))break}i=0;B:if((0|(A=D[o+16>>2]))!=D[o+20>>2])for(;;){if(C=s(i,20)+A|0,g=D[B+92>>2]+(D[C+4>>2]<<2)|0,r=D[C>>2],!((E=D[C+12>>2])>>>0>3))if(I=D[o+12>>2],D[C+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[C+12>>2])|0,(A=A+1|0)>>>0<k[C+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[r+84|0]?A:D[D[r+68>>2]+(A<<2)>>2])>>>0>=k[r+80>>2])break B;if(xA(D[D[r>>2]>>2]+s(I=A,A=D[r+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|a)==(0|(F=F+1|0)))break Q;A=D[B+12>>2]}}if(!(A=D[Q+28>>2]))break}C=1}if(D[Q+28>>2]=0,(I=(E=D[Q+16>>2])-(A=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[A>>2]),D[Q+12>>2]=A=D[Q+12>>2]+4|0,(I=(E=D[Q+16>>2])-A>>2)>>>0>2;);g=170;C:switch(I-1|0){case 1:g=341;case 0:D[Q+24>>2]=g}if((0|A)!=(0|E)){for(;sA(D[A>>2]),(0|E)!=(0|(A=A+4|0)););(0|(A=D[Q+16>>2]))!=(0|(I=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-I|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}i=C}}return i}function Z(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0;if(B=D[I+20>>2],!((E=(Q=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(B=E>>>0<4?B+1|0:B))>=(0|(i=D[I+12>>2]))|(0|B)>(0|i)||(D[A>>2]=e[0|(B=Q+D[I>>2]|0)]|e[B+1|0]<<8|e[B+2|0]<<16|e[B+3|0]<<24,i=B=D[I+20>>2],B=(Q=(E=D[I+16>>2])+4|0)>>>0<4?B+1|0:B,o=Q,D[I+16>>2]=Q,D[I+20>>2]=B,k[A>>2]>32||(B=i,(0|(Q=D[I+12>>2]))<=(0|(B=(i=E+8|0)>>>0<8?B+1|0:B))&i>>>0>k[I+8>>2]|(0|Q)<(0|B))))){if(D[A+4>>2]=B=e[0|(C=o+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(i=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=i,D[I+20>>2]=C,!B)return 1;if(C=0,D[A+8>>2]=0,iI(A+16|0,I)&&wI(A+544|0,I)&&wI(A+564|0,I)&&wI(A+584|0,I)){y=D[A+4>>2],i=g,g=0,I=0,d=Q=d-32|0,B=A,C=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(C){if(C>>>0>=1073741824)break I;g=DC(A=C<<2),D[Q+8>>2]=g,D[Q+16>>2]=I=A+g|0,bI(g,0,A),D[Q+12>>2]=I}(E=D[(A=D[B+628>>2])>>2])&&(D[A+4>>2]=E,sA(E),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,C=D[B+12>>2],g=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=g,D[A+8>>2]=D[Q+16>>2],g=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,E=0;g:{if(C){if(C>>>0>=1073741824)break g;E=DC(A=C<<2),D[Q+8>>2]=E,D[Q+16>>2]=g=A+E|0,bI(E,0,A),D[Q+12>>2]=g}(I=D[(A=D[B+640>>2])>>2])&&(D[A+4>>2]=I,sA(I),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,E=D[Q+8>>2],g=D[Q+12>>2]),D[A+4>>2]=g,D[A>>2]=E,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=y,I=1,D[Q+28>>2]=C=(A=D[Q+28>>2])+1|0;C:if(!(A>>>0>C>>>0)){for(;;){if(A=D[(f=D[Q+12>>2])+((g=((A=(I=D[Q+24>>2])+(E=C-1|0)|0)>>>0)/341|0)<<2)>>2]+s(A-s(g,341)|0,12)|0,a=D[A+8>>2],g=D[A+4>>2],o=D[A>>2],D[Q+28>>2]=E,1+(((E=(A=D[Q+16>>2])-f|0)?s(E>>2,341)-1|0:0)-(I+C|0)|0)>>>0>=682&&(sA(D[A-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),I=0,o>>>0>y>>>0)break C;if((E=((A=D[B+12>>2])-1|0)==(0|g)?0:g+1|0)>>>0>=A>>>0)break C;f=(r=s(a,12))+D[B+628>>2]|0;Q:{B:if(g=D[B>>2]-D[(F=E<<2)+D[(t=r+D[B+640>>2]|0)>>2]>>2]|0){E:{i:{o:{a:{if(o>>>0<=2){if(D[(A=D[B+616>>2])>>2]=E,g=1,(C=D[B+12>>2])>>>0>1)break a;break E}if(k[B+8>>2]>k[B+4>>2])break C;if((0|(I=(A=D[B+628>>2])+(t=s(N=a+1|0,12))|0))!=(0|f)&&(qI(I,D[f>>2],D[f+4>>2]),A=D[B+628>>2]),D[(A=F+D[A+t>>2]|0)>>2]=D[A>>2]+(1<<g-1),g=0,C=0,A=31^R(o))for(;g=ug(16+((C<<4)+B|0)|0)|g<<1,(0|A)!=(0|(C=C+1|0)););if((0|(C=o-(A=(o>>>1|0)-g|0)|0))!=(0|A)){if((0|(I=D[B+596>>2]))==D[B+588>>2])break o;g=D[I>>2],D[B+600>>2]=f=(o=D[B+600>>2])+1|0,g&=-2147483648>>>o;r:{if(32==(0|f)){if(D[B+600>>2]=0,D[B+596>>2]=I+4,g)break r;break o}if(!g)break o}I=C}else I=A;C=A;break i}for(;D[A+(g<<2)>>2]=E=(C-1|0)==(0|E)?0:E+1|0,(g=g+1|0)>>>0<(C=D[B+12>>2])>>>0;);break E}I=A}if(D[(f=(o=D[(g=(A=D[B+640>>2])+r|0)>>2])+F|0)>>2]=D[f>>2]+1,qI(A+t|0,o,D[g+4>>2]),C&&((0|(g=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((o=D[Q+16>>2]-(A=D[Q+12>>2])|0)?s(o>>2,341)-1|0:0))?(AI(Q+8|0),g=D[Q+24>>2]+D[Q+28>>2]|0,o=D[Q+12>>2]):o=A,A=D[o+((A=(g>>>0)/341|0)<<2)>>2]+s(g-s(A,341)|0,12)|0,D[A+8>>2]=a,D[A+4>>2]=E,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!I)break B;(0|(C=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((A=D[Q+16>>2]-(g=D[Q+12>>2])|0)?s(A>>2,341)-1|0:0))&&(AI(Q+8|0),C=D[Q+24>>2]+D[Q+28>>2]|0,g=D[Q+12>>2]),A=D[g+((A=(C>>>0)/341|0)<<2)>>2]+s(C-s(A,341)|0,12)|0,D[A+8>>2]=N,D[A+4>>2]=E,D[A>>2]=I,D[Q+28>>2]=C=D[Q+28>>2]+1|0;break Q}if(F=0,o)for(;;){if(C)for(E=D[B+548>>2],g=D[B+604>>2],c=D[B+616>>2],w=D[f>>2],b=D[t>>2],C=0;;){D[g+(D[(a=(C<<2)+c|0)>>2]<<2)>>2]=0;E:if(A=D[B>>2]-D[(I=D[a>>2]<<2)+b>>2]|0)if(I=I+g|0,(0|(n=32-(r=D[B+560>>2])|0))>=(0|A)){if((0|(N=D[B+556>>2]))==(0|E)){D[I>>2]=0;break E}if(D[I>>2]=D[N>>2]<<r>>>32-A,D[B+560>>2]=A=A+D[B+560>>2]|0,32!=(0|A))break E;D[B+560>>2]=0,D[B+556>>2]=N+4}else(0|E)!=(0|(G=(N=D[B+556>>2])+4|0))?(h=D[N>>2],D[B+556>>2]=G,D[B+560>>2]=n=A-n|0,D[I>>2]=D[N+4>>2]>>>32-n|h<<r>>>32-A):D[I>>2]=0;if(D[(I=(A=D[a>>2]<<2)+g|0)>>2]=D[I>>2]|D[A+w>>2],!((C=C+1|0)>>>0<k[B+12>>2]))break}A=0;E:if((0|(C=D[i+16>>2]))!=D[i+20>>2])for(;;){if(a=s(A,20)+C|0,I=D[B+604>>2]+(D[a+4>>2]<<2)|0,r=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(g=D[i+12>>2],D[a+16>>2]){for(C=0;g=(g=xA(g,(C<<2)+I|0,E))+(E=D[a+12>>2])|0,(C=C+1|0)>>>0<k[a+16>>2];);I=D[i+12>>2]}else I=g;if(C=D[i+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(g=D[r+40>>2],C)|0,I,g),!((A=A+1|0)>>>0<(D[i+20>>2]-(C=D[i+16>>2])|0)/20>>>0))break}if(D[i+28>>2]=D[i+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|o)==(0|(F=F+1|0)))break B;C=D[B+12>>2]}}else{if(t=0,!o)break B;for(;;){A=0;E:if((0|(C=D[i+16>>2]))!=D[i+20>>2])for(;;){if(a=s(A,20)+C|0,I=D[f>>2]+(D[a+4>>2]<<2)|0,r=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(g=D[i+12>>2],D[a+16>>2]){for(C=0;g=(g=xA(g,(C<<2)+I|0,E))+(E=D[a+12>>2])|0,(C=C+1|0)>>>0<k[a+16>>2];);I=D[i+12>>2]}else I=g;if(C=D[i+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(g=D[r+40>>2],C)|0,I,g),!((A=A+1|0)>>>0<(D[i+20>>2]-(C=D[i+16>>2])|0)/20>>>0))break}if(D[i+28>>2]=D[i+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|o)==(0|(t=t+1|0)))break}}C=D[Q+28>>2]}if(!C)break}I=1}if(D[Q+28>>2]=0,(g=(E=D[Q+16>>2])-(C=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[C>>2]),D[Q+12>>2]=C=D[Q+12>>2]+4|0,(g=(E=D[Q+16>>2])-C>>2)>>>0>2;);A=170;C:switch(g-1|0){case 1:A=341;case 0:D[Q+24>>2]=A}if((0|C)!=(0|E)){for(;sA(D[C>>2]),(0|E)!=(0|(C=C+4|0)););(0|(A=D[Q+16>>2]))!=(0|(g=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-g|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}C=I}}return C}function x(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0;if(Q=D[I+20>>2],!((C=(o=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(Q=C>>>0<4?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B)||(D[A>>2]=e[0|(Q=o+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,B=Q=D[I+20>>2],Q=(o=(C=D[I+16>>2])+4|0)>>>0<4?B+1|0:B,r=o,D[I+16>>2]=o,D[I+20>>2]=Q,k[A>>2]>32||(Q=B,(B=C+8|0)>>>0>k[I+8>>2]&(0|(Q=B>>>0<8?Q+1|0:Q))>=(0|(o=D[I+12>>2]))|(0|Q)>(0|o))))){if(D[A+4>>2]=i=e[0|(Q=r+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=D[I+20>>2],Q=(B=D[I+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[I+16>>2]=B,D[I+20>>2]=Q,!i)return 1;if(i=0,D[A+8>>2]=0,TA(A+16|0,I)&&wI(A+32|0,I)&&wI(A+52|0,I)&&wI(A+72|0,I)){n=D[A+4>>2],o=g,I=0,g=0,d=C=d-32|0,B=A,A=D[A+12>>2],D[C+16>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0;A:{I:{if(A){if(A>>>0>=1073741824)break I;I=DC(Q=A<<2),D[C+8>>2]=I,D[C+16>>2]=g=I+Q|0,bI(I,0,Q),D[C+12>>2]=g}(i=D[(Q=D[B+116>>2])>>2])&&(D[Q+4>>2]=i,sA(i),D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,g=D[C+12>>2],I=D[C+8>>2],A=D[B+12>>2]),D[Q+4>>2]=g,D[Q>>2]=I,D[Q+8>>2]=D[C+16>>2],I=0,D[C+16>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0;g:{if(A){if(A>>>0>=1073741824)break g;E=DC(A<<=2),D[C+8>>2]=E,D[C+16>>2]=I=A+E|0,bI(E,0,A),D[C+12>>2]=I}(g=D[(A=D[B+128>>2])>>2])&&(D[A+4>>2]=g,sA(g),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,E=D[C+8>>2],I=D[C+12>>2]),D[A+4>>2]=I,D[A>>2]=E,D[A+8>>2]=D[C+16>>2],D[C+24>>2]=0,D[C+28>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,AI(C+8|0),A=D[D[C+12>>2]+((I=((A=D[C+24>>2]+D[C+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=n,Q=1,D[C+28>>2]=A=(I=D[C+28>>2])+1|0;C:if(!(A>>>0<I>>>0)){for(c=B+16|0;;){if(I=D[(a=D[C+12>>2])+((g=((I=(Q=D[C+24>>2])+(E=A-1|0)|0)>>>0)/341|0)<<2)>>2]+s(I-s(g,341)|0,12)|0,g=D[I+8>>2],i=D[I+4>>2],r=D[I>>2],D[C+28>>2]=E,1+(((E=(I=D[C+16>>2])-a|0)?s(E>>2,341)-1|0:0)-(A+Q|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[C+16>>2]=D[C+16>>2]-4),r>>>0>n>>>0){Q=0;break C}if(Q=0,(E=(0|i)==((A=D[B+12>>2])-1|0)?0:i+1|0)>>>0>=A>>>0)break C;N=(A=D[B+116>>2])+(I=s(g,12))|0;Q:{if(!(i=D[B>>2]-D[(a=E<<2)+D[(y=I+D[B+128>>2]|0)>>2]>>2]|0)){if(!r)break Q;if((0|(A=D[o+16>>2]))==(0|(E=D[o+20>>2]))){A=D[B+8>>2],D[o+28>>2]=r+D[o+28>>2],D[B+8>>2]=A+r;break Q}for(;;){i=0;B:if((0|A)!=(0|E))for(;;){if(a=s(i,20)+A|0,g=D[N>>2]+(D[a+4>>2]<<2)|0,f=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(I=D[o+12>>2],D[a+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[a+12>>2])|0,(A=A+1|0)>>>0<k[a+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break B;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|r)==(0|(Q=Q+1|0)))break Q;A=D[o+16>>2],E=D[o+20>>2]}}B:{E:{i:{o:{if(r>>>0<=2){if(D[(g=D[B+104>>2])>>2]=E,I=1,(A=D[B+12>>2])>>>0>1)break o;break B}if(k[B+8>>2]>k[B+4>>2])break C;if(qI((Q=A)+(A=I+12|0)|0,D[N>>2],D[N+4>>2]),D[(A=a+D[A+D[B+116>>2]>>2]|0)>>2]=D[A>>2]+(1<<i-1),D[C+4>>2]=0,eg(c,31^R(r),C+4|0),f=g+1|0,(0|(Q=r-(A=(r>>>1|0)-D[C+4>>2]|0)|0))!=(0|A)){if((0|(i=D[B+84>>2]))==D[B+76>>2])break i;r=D[i>>2],D[B+88>>2]=t=(N=D[B+88>>2])+1|0,r&=-2147483648>>>N;a:{if(32==(0|t)){if(D[B+88>>2]=0,D[B+84>>2]=i+4,r)break a;break i}if(!r)break i}}else Q=A;i=Q,Q=A;break E}for(;D[g+(I<<2)>>2]=E=(A-1|0)==(0|E)?0:E+1|0,(A=D[B+12>>2])>>>0>(I=I+1|0)>>>0;);break B}i=A}if(D[(a=(r=D[(I=(A=D[B+128>>2])+I|0)>>2])+a|0)>>2]=D[a>>2]+1,qI(A+s(f,12)|0,r,D[I+4>>2]),Q&&((0|(A=D[C+28>>2]+D[C+24>>2]|0))==(0|((r=D[C+16>>2]-(I=D[C+12>>2])|0)?s(r>>2,341)-1|0:0))&&(AI(C+8|0),I=D[C+12>>2],A=D[C+24>>2]+D[C+28>>2]|0),A=D[(r=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=g,D[A+4>>2]=E,D[A>>2]=Q,D[C+28>>2]=D[C+28>>2]+1),!i)break Q;(0|(A=D[C+28>>2]+D[C+24>>2]|0))==(0|((g=D[C+16>>2]-(I=D[C+12>>2])|0)?s(g>>2,341)-1|0:0))&&(AI(C+8|0),I=D[C+12>>2],A=D[C+24>>2]+D[C+28>>2]|0),A=D[(g=I)+((I=(A>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+8>>2]=f,D[A+4>>2]=E,D[A>>2]=i,D[C+28>>2]=D[C+28>>2]+1;break Q}if(r)for(;;){if(A)for(E=D[B+36>>2],i=D[B+92>>2],w=D[B+104>>2],b=D[N>>2],h=D[y>>2],A=0;;){D[i+(D[(a=(A<<2)+w|0)>>2]<<2)>>2]=0;B:if(I=D[B>>2]-D[(g=D[a>>2]<<2)+h>>2]|0)if(g=g+i|0,(0|(F=32-(f=D[B+48>>2])|0))>=(0|I)){if((0|(t=D[B+44>>2]))==(0|E)){D[g>>2]=0;break B}if(D[g>>2]=D[t>>2]<<f>>>32-I,D[B+48>>2]=I=I+D[B+48>>2]|0,32!=(0|I))break B;D[B+48>>2]=0,D[B+44>>2]=t+4}else(0|E)!=(0|(G=(t=D[B+44>>2])+4|0))?(J=D[t>>2],D[B+44>>2]=G,D[B+48>>2]=F=I-F|0,D[g>>2]=D[t+4>>2]>>>32-F|J<<f>>>32-I):D[g>>2]=0;if(D[(g=(I=D[a>>2]<<2)+i|0)>>2]=D[g>>2]|D[I+b>>2],!((A=A+1|0)>>>0<k[B+12>>2]))break}i=0;B:if((0|(A=D[o+16>>2]))!=D[o+20>>2])for(;;){if(a=s(i,20)+A|0,g=D[B+92>>2]+(D[a+4>>2]<<2)|0,f=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(I=D[o+12>>2],D[a+16>>2]){for(A=0;I=(I=xA(I,(A<<2)+g|0,E))+(E=D[a+12>>2])|0,(A=A+1|0)>>>0<k[a+16>>2];);g=D[o+12>>2]}else g=I;if(A=D[o+28>>2],(A=e[f+84|0]?A:D[D[f+68>>2]+(A<<2)>>2])>>>0>=k[f+80>>2])break B;if(xA(D[D[f>>2]>>2]+s(I=A,A=D[f+40>>2])|0,g,A),!((i=i+1|0)>>>0<(D[o+20>>2]-(A=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|r)==(0|(Q=Q+1|0)))break Q;A=D[B+12>>2]}}if(!(A=D[C+28>>2]))break}Q=1}if(D[C+28>>2]=0,(I=(E=D[C+16>>2])-(A=D[C+12>>2])>>2)>>>0>=3)for(;sA(D[A>>2]),D[C+12>>2]=A=D[C+12>>2]+4|0,(I=(E=D[C+16>>2])-A>>2)>>>0>2;);g=170;C:switch(I-1|0){case 1:g=341;case 0:D[C+24>>2]=g}if((0|A)!=(0|E)){for(;sA(D[A>>2]),(0|E)!=(0|(A=A+4|0)););(0|(A=D[C+16>>2]))!=(0|(I=D[C+12>>2]))&&(D[C+16>>2]=A+(((A-I|0)-4>>>2^-1)<<2))}(A=D[C+8>>2])&&sA(A),d=C+32|0;break A}iQ(),U()}iQ(),U()}i=Q}}return i}function X(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0;if(B=D[I+20>>2],!((0|(E=D[I+12>>2]))<=(0|(B=(Q=(o=D[I+16>>2])+4|0)>>>0<4?B+1|0:B))&Q>>>0>k[I+8>>2]|(0|E)<(0|B)||(D[A>>2]=e[0|(B=o+D[I>>2]|0)]|e[B+1|0]<<8|e[B+2|0]<<16|e[B+3|0]<<24,E=B=D[I+20>>2],B=(o=(Q=D[I+16>>2])+4|0)>>>0<4?E+1|0:E,a=o,D[I+16>>2]=o,D[I+20>>2]=B,k[A>>2]>32||(B=E,(E=Q+8|0)>>>0>k[I+8>>2]&(0|(B=E>>>0<8?B+1|0:B))>=(0|(o=D[I+12>>2]))|(0|B)>(0|o))))){if(D[A+4>>2]=B=e[0|(C=a+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(E=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=E,D[I+20>>2]=C,!B)return 1;if(C=0,D[A+8>>2]=0,iI(A+16|0,I)&&wI(A+544|0,I)&&wI(A+564|0,I)&&wI(A+584|0,I)){n=D[A+4>>2],o=g,I=0,g=0,d=Q=d-32|0,E=A,C=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(C){if(C>>>0>=1073741824)break I;I=DC(A=C<<2),D[Q+8>>2]=I,D[Q+16>>2]=g=A+I|0,bI(I,0,A),D[Q+12>>2]=g}(B=D[(A=D[E+628>>2])>>2])&&(D[A+4>>2]=B,sA(B),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,C=D[E+12>>2],g=D[Q+12>>2],I=D[Q+8>>2]),D[A+4>>2]=g,D[A>>2]=I,D[A+8>>2]=D[Q+16>>2],I=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;g:{if(C){if(C>>>0>=1073741824)break g;i=DC(A=C<<2),D[Q+8>>2]=i,D[Q+16>>2]=I=A+i|0,bI(i,0,A),D[Q+12>>2]=I}(g=D[(A=D[E+640>>2])>>2])&&(D[A+4>>2]=g,sA(g),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,i=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=i,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=n,g=1,D[Q+28>>2]=C=(A=D[Q+28>>2])+1|0;C:if(!(A>>>0>C>>>0)){for(;;){if(A=D[(i=D[Q+12>>2])+((I=((A=(g=D[Q+24>>2])+(B=C-1|0)|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,f=D[A+8>>2],I=D[A+4>>2],a=D[A>>2],D[Q+28>>2]=B,1+(((B=(A=D[Q+16>>2])-i|0)?s(B>>2,341)-1|0:0)-(g+C|0)|0)>>>0>=682&&(sA(D[A-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),a>>>0>n>>>0){g=0;break C}if(g=0,(i=(0|I)==((A=D[E+12>>2])-1|0)?0:I+1|0)>>>0>=A>>>0)break C;N=(A=D[E+628>>2])+(r=s(f,12))|0;Q:{B:if(I=D[E>>2]-D[(t=i<<2)+D[(y=r+D[E+640>>2]|0)>>2]>>2]|0){E:{i:{o:{a:{if(a>>>0<=2){if(D[(A=D[E+616>>2])>>2]=i,I=1,(C=D[E+12>>2])>>>0>1)break a;break E}if(k[E+8>>2]>k[E+4>>2])break C;if(qI((g=A)+(A=r+12|0)|0,D[N>>2],D[N+4>>2]),D[(A=t+D[A+D[E+628>>2]>>2]|0)>>2]=D[A>>2]+(1<<I-1),I=0,C=0,A=31^R(a))for(;I=ug(16+((C<<4)+E|0)|0)|I<<1,(0|A)!=(0|(C=C+1|0)););if(g=f+1|0,(0|(C=a-(A=(a>>>1|0)-I|0)|0))!=(0|A)){if((0|(I=D[E+596>>2]))==D[E+588>>2])break o;B=D[I>>2],D[E+600>>2]=N=(a=D[E+600>>2])+1|0,B&=-2147483648>>>a;r:{if(32==(0|N)){if(D[E+600>>2]=0,D[E+596>>2]=I+4,B)break r;break o}if(!B)break o}}else C=A;B=C,C=A;break i}for(;D[A+(I<<2)>>2]=i=(C-1|0)==(0|i)?0:i+1|0,(I=I+1|0)>>>0<(C=D[E+12>>2])>>>0;);break E}B=A}if(D[(r=(a=D[(I=(A=D[E+640>>2])+r|0)>>2])+t|0)>>2]=D[r>>2]+1,qI(A+s(g,12)|0,a,D[I+4>>2]),C&&((0|(I=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((a=D[Q+16>>2]-(A=D[Q+12>>2])|0)?s(a>>2,341)-1|0:0))?(AI(Q+8|0),I=D[Q+24>>2]+D[Q+28>>2]|0,a=D[Q+12>>2]):a=A,A=D[a+((A=(I>>>0)/341|0)<<2)>>2]+s(I-s(A,341)|0,12)|0,D[A+8>>2]=f,D[A+4>>2]=i,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!B)break B;(0|(C=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((A=D[Q+16>>2]-(I=D[Q+12>>2])|0)?s(A>>2,341)-1|0:0))&&(AI(Q+8|0),C=D[Q+24>>2]+D[Q+28>>2]|0,I=D[Q+12>>2]),A=D[I+((A=(C>>>0)/341|0)<<2)>>2]+s(C-s(A,341)|0,12)|0,D[A+8>>2]=g,D[A+4>>2]=i,D[A>>2]=B,D[Q+28>>2]=C=D[Q+28>>2]+1|0;break Q}if(A=0,a)for(;;){if(C)for(i=D[E+548>>2],B=D[E+604>>2],c=D[E+616>>2],w=D[N>>2],b=D[y>>2],C=0;;){D[B+(D[(f=(C<<2)+c|0)>>2]<<2)>>2]=0;E:if(I=D[E>>2]-D[(g=D[f>>2]<<2)+b>>2]|0)if(g=g+B|0,(0|(F=32-(r=D[E+560>>2])|0))>=(0|I)){if((0|(t=D[E+556>>2]))==(0|i)){D[g>>2]=0;break E}if(D[g>>2]=D[t>>2]<<r>>>32-I,D[E+560>>2]=I=I+D[E+560>>2]|0,32!=(0|I))break E;D[E+560>>2]=0,D[E+556>>2]=t+4}else(0|i)!=(0|(G=(t=D[E+556>>2])+4|0))?(h=D[t>>2],D[E+556>>2]=G,D[E+560>>2]=F=I-F|0,D[g>>2]=D[t+4>>2]>>>32-F|h<<r>>>32-I):D[g>>2]=0;if(D[(g=(I=D[f>>2]<<2)+B|0)>>2]=D[g>>2]|D[I+w>>2],!((C=C+1|0)>>>0<k[E+12>>2]))break}B=0;E:if((0|(C=D[o+16>>2]))!=D[o+20>>2])for(;;){if(f=s(B,20)+C|0,g=D[E+604>>2]+(D[f+4>>2]<<2)|0,r=D[f>>2],!((i=D[f+12>>2])>>>0>3))if(I=D[o+12>>2],D[f+16>>2]){for(C=0;I=(I=xA(I,(C<<2)+g|0,i))+(i=D[f+12>>2])|0,(C=C+1|0)>>>0<k[f+16>>2];);g=D[o+12>>2]}else g=I;if(C=D[o+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(I=D[r+40>>2],C)|0,g,I),!((B=B+1|0)>>>0<(D[o+20>>2]-(C=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[E+8>>2]=D[E+8>>2]+1,(0|a)==(0|(A=A+1|0)))break B;C=D[E+12>>2]}}else{if(A=0,!a)break B;for(;;){B=0;E:if((0|(C=D[o+16>>2]))!=D[o+20>>2])for(;;){if(f=s(B,20)+C|0,g=D[N>>2]+(D[f+4>>2]<<2)|0,r=D[f>>2],!((i=D[f+12>>2])>>>0>3))if(I=D[o+12>>2],D[f+16>>2]){for(C=0;I=(I=xA(I,(C<<2)+g|0,i))+(i=D[f+12>>2])|0,(C=C+1|0)>>>0<k[f+16>>2];);g=D[o+12>>2]}else g=I;if(C=D[o+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(I=D[r+40>>2],C)|0,g,I),!((B=B+1|0)>>>0<(D[o+20>>2]-(C=D[o+16>>2])|0)/20>>>0))break}if(D[o+28>>2]=D[o+28>>2]+1,D[E+8>>2]=D[E+8>>2]+1,(0|a)==(0|(A=A+1|0)))break}}C=D[Q+28>>2]}if(!C)break}g=1}if(D[Q+28>>2]=0,(I=(i=D[Q+16>>2])-(C=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[C>>2]),D[Q+12>>2]=C=D[Q+12>>2]+4|0,(I=(i=D[Q+16>>2])-C>>2)>>>0>2;);A=170;C:switch(I-1|0){case 1:A=341;case 0:D[Q+24>>2]=A}if((0|C)!=(0|i)){for(;sA(D[C>>2]),(0|i)!=(0|(C=C+4|0)););(0|(A=D[Q+16>>2]))!=(0|(I=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-I|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}C=g}}return C}function j(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,F=0,n=0,y=0,G=0,c=0,w=0,b=0,h=0;if(B=D[I+20>>2],!((E=(Q=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(B=E>>>0<4?B+1|0:B))>=(0|(i=D[I+12>>2]))|(0|B)>(0|i)||(D[A>>2]=e[0|(B=Q+D[I>>2]|0)]|e[B+1|0]<<8|e[B+2|0]<<16|e[B+3|0]<<24,i=B=D[I+20>>2],B=(Q=(E=D[I+16>>2])+4|0)>>>0<4?B+1|0:B,o=Q,D[I+16>>2]=Q,D[I+20>>2]=B,k[A>>2]>32||(B=i,(0|(Q=D[I+12>>2]))<=(0|(B=(i=E+8|0)>>>0<8?B+1|0:B))&i>>>0>k[I+8>>2]|(0|Q)<(0|B))))){if(D[A+4>>2]=B=e[0|(C=o+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[I+20>>2],C=(i=D[I+16>>2]+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=i,D[I+20>>2]=C,!B)return 1;if(C=0,D[A+8>>2]=0,iI(A+16|0,I)&&wI(A+544|0,I)&&wI(A+564|0,I)&&wI(A+584|0,I)){y=D[A+4>>2],i=g,g=0,I=0,d=Q=d-32|0,B=A,C=D[A+12>>2],D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0;A:{I:{if(C){if(C>>>0>=1073741824)break I;g=DC(A=C<<2),D[Q+8>>2]=g,D[Q+16>>2]=I=A+g|0,bI(g,0,A),D[Q+12>>2]=I}(E=D[(A=D[B+628>>2])>>2])&&(D[A+4>>2]=E,sA(E),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,C=D[B+12>>2],g=D[Q+8>>2],I=D[Q+12>>2]),D[A+4>>2]=I,D[A>>2]=g,D[A+8>>2]=D[Q+16>>2],g=0,D[Q+16>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,E=0;g:{if(C){if(C>>>0>=1073741824)break g;E=DC(A=C<<2),D[Q+8>>2]=E,D[Q+16>>2]=g=A+E|0,bI(E,0,A),D[Q+12>>2]=g}(I=D[(A=D[B+640>>2])>>2])&&(D[A+4>>2]=I,sA(I),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,E=D[Q+8>>2],g=D[Q+12>>2]),D[A+4>>2]=g,D[A>>2]=E,D[A+8>>2]=D[Q+16>>2],D[Q+24>>2]=0,D[Q+28>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=0,D[Q+12>>2]=0,AI(Q+8|0),A=D[D[Q+12>>2]+((I=((A=D[Q+24>>2]+D[Q+28>>2]|0)>>>0)/341|0)<<2)>>2]+s(A-s(I,341)|0,12)|0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=y,I=1,D[Q+28>>2]=C=(A=D[Q+28>>2])+1|0;C:if(!(A>>>0>C>>>0)){for(;;){if(g=D[(f=D[Q+12>>2])+((E=((g=(A=D[Q+24>>2])+(I=C-1|0)|0)>>>0)/341|0)<<2)>>2]+s(g-s(E,341)|0,12)|0,a=D[g+8>>2],o=D[g>>2],D[Q+28>>2]=I,1+(((g=(I=D[Q+16>>2])-f|0)?s(g>>2,341)-1|0:0)-(A+C|0)|0)>>>0>=682&&(sA(D[I-4>>2]),D[Q+16>>2]=D[Q+16>>2]-4),I=0,o>>>0>y>>>0)break C;if(A=D[B+628>>2],(E=kI(B,o,t=(r=s(a,12))+D[B+640>>2]|0))>>>0>=k[B+12>>2])break C;f=A+r|0;Q:{B:if(g=D[B>>2]-D[(F=E<<2)+D[t>>2]>>2]|0){E:{i:{o:{a:{if(o>>>0<=2){if(D[(A=D[B+616>>2])>>2]=E,g=1,(C=D[B+12>>2])>>>0>1)break a;break E}if(k[B+8>>2]>k[B+4>>2])break C;if((0|(I=(A=D[B+628>>2])+(t=s(N=a+1|0,12))|0))!=(0|f)&&(qI(I,D[f>>2],D[f+4>>2]),A=D[B+628>>2]),D[(A=F+D[A+t>>2]|0)>>2]=D[A>>2]+(1<<g-1),g=0,C=0,A=31^R(o))for(;g=ug(16+((C<<4)+B|0)|0)|g<<1,(0|A)!=(0|(C=C+1|0)););if((0|(C=o-(A=(o>>>1|0)-g|0)|0))!=(0|A)){if((0|(I=D[B+596>>2]))==D[B+588>>2])break o;g=D[I>>2],D[B+600>>2]=f=(o=D[B+600>>2])+1|0,g&=-2147483648>>>o;r:{if(32==(0|f)){if(D[B+600>>2]=0,D[B+596>>2]=I+4,g)break r;break o}if(!g)break o}I=C}else I=A;C=A;break i}for(;D[A+(g<<2)>>2]=E=(C-1|0)==(0|E)?0:E+1|0,(g=g+1|0)>>>0<(C=D[B+12>>2])>>>0;);break E}I=A}if(D[(f=(o=D[(g=(A=D[B+640>>2])+r|0)>>2])+F|0)>>2]=D[f>>2]+1,qI(A+t|0,o,D[g+4>>2]),C&&((0|(g=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((o=D[Q+16>>2]-(A=D[Q+12>>2])|0)?s(o>>2,341)-1|0:0))?(AI(Q+8|0),g=D[Q+24>>2]+D[Q+28>>2]|0,o=D[Q+12>>2]):o=A,A=D[o+((A=(g>>>0)/341|0)<<2)>>2]+s(g-s(A,341)|0,12)|0,D[A+8>>2]=a,D[A+4>>2]=E,D[A>>2]=C,D[Q+28>>2]=D[Q+28>>2]+1),!I)break B;(0|(C=D[Q+28>>2]+D[Q+24>>2]|0))==(0|((A=D[Q+16>>2]-(g=D[Q+12>>2])|0)?s(A>>2,341)-1|0:0))&&(AI(Q+8|0),C=D[Q+24>>2]+D[Q+28>>2]|0,g=D[Q+12>>2]),A=D[g+((A=(C>>>0)/341|0)<<2)>>2]+s(C-s(A,341)|0,12)|0,D[A+8>>2]=N,D[A+4>>2]=E,D[A>>2]=I,D[Q+28>>2]=C=D[Q+28>>2]+1|0;break Q}if(F=0,o)for(;;){if(C)for(E=D[B+548>>2],g=D[B+604>>2],c=D[B+616>>2],w=D[f>>2],b=D[t>>2],C=0;;){D[g+(D[(a=(C<<2)+c|0)>>2]<<2)>>2]=0;E:if(A=D[B>>2]-D[(I=D[a>>2]<<2)+b>>2]|0)if(I=I+g|0,(0|(n=32-(r=D[B+560>>2])|0))>=(0|A)){if((0|(N=D[B+556>>2]))==(0|E)){D[I>>2]=0;break E}if(D[I>>2]=D[N>>2]<<r>>>32-A,D[B+560>>2]=A=A+D[B+560>>2]|0,32!=(0|A))break E;D[B+560>>2]=0,D[B+556>>2]=N+4}else(0|E)!=(0|(G=(N=D[B+556>>2])+4|0))?(h=D[N>>2],D[B+556>>2]=G,D[B+560>>2]=n=A-n|0,D[I>>2]=D[N+4>>2]>>>32-n|h<<r>>>32-A):D[I>>2]=0;if(D[(I=(A=D[a>>2]<<2)+g|0)>>2]=D[I>>2]|D[A+w>>2],!((C=C+1|0)>>>0<k[B+12>>2]))break}A=0;E:if((0|(C=D[i+16>>2]))!=D[i+20>>2])for(;;){if(a=s(A,20)+C|0,I=D[B+604>>2]+(D[a+4>>2]<<2)|0,r=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(g=D[i+12>>2],D[a+16>>2]){for(C=0;g=(g=xA(g,(C<<2)+I|0,E))+(E=D[a+12>>2])|0,(C=C+1|0)>>>0<k[a+16>>2];);I=D[i+12>>2]}else I=g;if(C=D[i+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(g=D[r+40>>2],C)|0,I,g),!((A=A+1|0)>>>0<(D[i+20>>2]-(C=D[i+16>>2])|0)/20>>>0))break}if(D[i+28>>2]=D[i+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|o)==(0|(F=F+1|0)))break B;C=D[B+12>>2]}}else{if(t=0,!o)break B;for(;;){A=0;E:if((0|(C=D[i+16>>2]))!=D[i+20>>2])for(;;){if(a=s(A,20)+C|0,I=D[f>>2]+(D[a+4>>2]<<2)|0,r=D[a>>2],!((E=D[a+12>>2])>>>0>3))if(g=D[i+12>>2],D[a+16>>2]){for(C=0;g=(g=xA(g,(C<<2)+I|0,E))+(E=D[a+12>>2])|0,(C=C+1|0)>>>0<k[a+16>>2];);I=D[i+12>>2]}else I=g;if(C=D[i+28>>2],(C=e[r+84|0]?C:D[D[r+68>>2]+(C<<2)>>2])>>>0>=k[r+80>>2])break E;if(xA(D[D[r>>2]>>2]+s(g=D[r+40>>2],C)|0,I,g),!((A=A+1|0)>>>0<(D[i+20>>2]-(C=D[i+16>>2])|0)/20>>>0))break}if(D[i+28>>2]=D[i+28>>2]+1,D[B+8>>2]=D[B+8>>2]+1,(0|o)==(0|(t=t+1|0)))break}}C=D[Q+28>>2]}if(!C)break}I=1}if(D[Q+28>>2]=0,(g=(E=D[Q+16>>2])-(C=D[Q+12>>2])>>2)>>>0>=3)for(;sA(D[C>>2]),D[Q+12>>2]=C=D[Q+12>>2]+4|0,(g=(E=D[Q+16>>2])-C>>2)>>>0>2;);A=170;C:switch(g-1|0){case 1:A=341;case 0:D[Q+24>>2]=A}if((0|C)!=(0|E)){for(;sA(D[C>>2]),(0|E)!=(0|(C=C+4|0)););(0|(A=D[Q+16>>2]))!=(0|(g=D[Q+12>>2]))&&(D[Q+16>>2]=A+(((A-g|0)-4>>>2^-1)<<2))}(A=D[Q+8>>2])&&sA(A),d=Q+32|0;break A}iQ(),U()}iQ(),U()}C=I}}return C}function O(A,I,g,C,Q){var E,i,o,a=0,f=0,k=0,t=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,U=0,h=0,J=0,S=0,Y=0,K=0;d=E=d-80|0,D[E+76>>2]=I,o=E+55|0,i=E+56|0,I=0;A:{I:{g:{C:{Q:for(;;){if((2147483647-y|0)<(0|I))break C;y=I+y|0;B:{E:{i:{if(F=e[0|(I=n=D[E+76>>2])])for(;;){o:{a:if(a=255&F){if(37!=(0|a))break o;for(F=I;;){if(37!=e[I+1|0])break a;if(D[E+76>>2]=a=I+2|0,F=F+1|0,f=e[I+2|0],I=a,37!=(0|f))break}}else F=I;if((0|(I=F-n|0))>(0|(J=2147483647-y|0)))break C;if(A&&VC(A,n,I),I)continue Q;w=-1,a=1,B[(I=D[E+76>>2])+1|0]-48>>>0>=10|36!=e[I+2|0]||(w=B[I+1|0]-48|0,b=1,a=3),D[E+76>>2]=I=a+I|0,G=0;a:if((f=(t=B[0|I])-32|0)>>>0>31)a=I;else if(a=I,75913&(k=1<<f))for(;;){if(D[E+76>>2]=a=I+1|0,G|=k,(f=(t=B[I+1|0])-32|0)>>>0>=32)break a;if(I=a,!(75913&(k=1<<f)))break}a:if(42!=(0|t)){if((0|(c=qg(E+76|0)))<0)break C;I=D[E+76>>2]}else{if(B[a+1|0]-48>>>0>=10||36!=e[(I=D[E+76>>2])+2|0]){if(b)break i;b=0,c=0,A&&(D[g>>2]=(I=D[g>>2])+4,c=D[I>>2]),I=D[E+76>>2]+1|0}else D[((B[I+1|0]<<2)+Q|0)-192>>2]=10,c=D[((B[I+1|0]<<3)+C|0)-384>>2],b=1,I=I+3|0;if(D[E+76>>2]=I,(0|c)>=0)break a;c=0-c|0,G|=8192}if(a=0,k=-1,f=0,46==e[0|I])if(42!=e[I+1|0])D[E+76>>2]=I+1,k=qg(E+76|0),I=D[E+76>>2],f=1;else{if(B[I+2|0]-48>>>0>=10||36!=e[(I=D[E+76>>2])+3|0]){if(b)break i;A?(D[g>>2]=(I=D[g>>2])+4,k=D[I>>2]):k=0,I=D[E+76>>2]+2|0}else D[((B[I+2|0]<<2)+Q|0)-192>>2]=10,k=D[((B[I+2|0]<<3)+C|0)-384>>2],I=I+4|0;D[E+76>>2]=I,f=(-1^k)>>>31|0}for(U=f;;){if(R=a,F=28,B[0|I]-123>>>0<4294967238)break g;if(D[E+76>>2]=t=I+1|0,a=B[0|I],I=t,!((a=e[13743+(a+s(R,58)|0)|0])-1>>>0<8))break}a:{r:{if(27!=(0|a)){if(!a)break g;if((0|w)>=0){D[(w<<2)+Q>>2]=a,a=D[4+(I=(w<<3)+C|0)>>2],D[E+64>>2]=D[I>>2],D[E+68>>2]=a;break r}if(!A)break B;cI(E- -64|0,a,g),t=D[E+76>>2];break a}if((0|w)>=0)break g}if(I=0,!A)continue Q}f=-65537&G,a=8192&G?f:G,G=0,w=1244,F=i;a:{r:{D:{e:{f:{k:{t:{N:{s:{F:{n:{R:{y:{G:{c:{w:switch(I=B[t-1|0],(I=R&&3==(15&I)?-33&I:I)-88|0){case 11:break a;case 9:case 13:case 14:case 15:break r;case 27:break t;case 12:case 17:break F;case 23:break n;case 0:case 32:break R;case 24:break y;case 22:break G;case 29:break c;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 10:case 16:case 18:case 19:case 20:case 21:case 25:case 26:case 28:case 30:case 31:break E}w:switch(I-65|0){case 0:case 4:case 5:case 6:break r;case 2:break f;case 1:case 3:break E}if(83==(0|I))break k;break E}t=D[E+64>>2],f=D[E+68>>2],w=1244;break s}I=0;G:switch(255&R){case 0:case 1:D[D[E+64>>2]>>2]=y;continue Q;case 2:D[(a=D[E+64>>2])>>2]=y,D[a+4>>2]=y>>31;continue Q;case 3:r[D[E+64>>2]>>1]=y;continue Q;case 4:B[D[E+64>>2]]=y;continue Q;case 6:D[D[E+64>>2]>>2]=y;continue Q;case 7:break G;default:continue Q}D[(a=D[E+64>>2])>>2]=y,D[a+4>>2]=y>>31;continue Q}k=k>>>0>8?k:8,a|=8,I=120}if(R=i,h=32&I,(t=D[E+64>>2])|(f=D[E+68>>2]))for(;B[0|(R=R-1|0)]=h|e[14272+(15&t)|0],S=!f&t>>>0>15|0!=(0|f),n=f,f=f>>>4|0,t=(15&n)<<28|t>>>4,S;);if(n=R,!(D[E+64>>2]|D[E+68>>2])|!(8&a))break N;w=1244+(I>>>4|0)|0,G=2;break N}if(I=i,(t=D[E+64>>2])|(f=D[E+68>>2]))for(;B[0|(I=I-1|0)]=7&t|48,R=!f&t>>>0>7|0!=(0|f),n=f,f=f>>>3|0,t=(7&n)<<29|t>>>3,R;);if(n=I,!(8&a))break N;k=(0|(I=i-n|0))<(0|k)?k:I+1|0;break N}f=I=D[E+68>>2],t=D[E+64>>2],(0|I)<0?(f=0-((0!=(0|t))+f|0)|0,D[E+64>>2]=t=0-t|0,D[E+68>>2]=f,G=1,w=1244):2048&a?(G=1,w=1245):w=(G=1&a)?1246:1244}if(n=i,f)for(;Y=n=n-1|0,K=t-mg(R=vA(t,f,10,0),I=u,10,0)|48,B[0|Y]=K,h=f>>>0>9,t=R,f=I,h;);else R=t;if(R)for(;B[0|(n=n-1|0)]=R-s(I=(R>>>0)/10|0,10)|48,f=R>>>0>9,R=I,f;);}if((0|k)<0&&U)break C;if(a=U?-65537&a:a,!(k|0!=((f=D[E+64>>2])|(I=D[E+68>>2])))){F=n=i,k=0;break E}k=(0|(I=!(I|f)+(i-n|0)|0))<(0|k)?k:I;break E}F=0!=(0|(a=t=(0|k)<0?2147483647:k));t:{N:{s:{F:if(!(!(3&(I=n=(I=D[E+64>>2])||1758))|!a))for(;;){if(!e[0|I])break s;if(F=0!=(0|(a=a-1|0)),!(3&(I=I+1|0)))break F;if(!a)break}if(!F)break N}s:if(!(!e[0|I]|a>>>0<4))for(;;){if((-1^(F=D[I>>2]))&F-16843009&-2139062144)break s;if(I=I+4|0,!((a=a-4|0)>>>0>3))break}if(a)for(;;){if(!e[0|I])break t;if(I=I+1|0,!(a=a-1|0))break}}I=0}if(F=(I=I?I-n|0:t)+n|0,(0|k)>=0){a=f,k=I;break E}if(a=f,k=I,e[0|F])break C;break E}if(k){F=D[E+64>>2];break e}I=0,Xg(A,32,c,0,a);break D}D[E+12>>2]=0,D[E+8>>2]=D[E+64>>2],D[E+64>>2]=F=E+8|0,k=-1}I=0;e:{for(;;){if(!(f=D[F>>2]))break e;if(!((n=(0|(f=zI(E+4|0,f)))<0)|f>>>0>k-I>>>0)){if(F=F+4|0,k>>>0>(I=I+f|0)>>>0)continue;break e}break}if(n)break I}if(F=61,(0|I)<0)break g;if(Xg(A,32,c,I,a),I)for(k=0,F=D[E+64>>2];;){if(!(f=D[F>>2]))break D;if((k=(f=zI(E+4|0,f))+k|0)>>>0>I>>>0)break D;if(VC(A,E+4|0,f),F=F+4|0,!(I>>>0>k>>>0))break}else I=0}Xg(A,32,c,I,8192^a),I=(0|I)<(0|c)?c:I;continue Q}if((0|k)<0&&U)break C;if(F=61,(0|(I=0|RQ[0](A,N[E+64>>3],c,k,a,I)))>=0)continue Q;break g}B[E+55|0]=D[E+64>>2],k=1,n=o,a=f;break E}D[E+76>>2]=a=I+1|0,F=e[I+1|0],I=a}if(A)break A;if(!b)break B;for(I=1;;){if(A=D[(I<<2)+Q>>2]){if(cI((I<<3)+C|0,A,g),y=1,10!=(0|(I=I+1|0)))continue;break A}break}if(y=1,I>>>0>=10)break A;for(;;){if(D[(I<<2)+Q>>2])break i;if(10==(0|(I=I+1|0)))break}break A}F=28;break g}if((0|(R=(0|k)<(0|(t=F-n|0))?t:k))>(2147483647-G|0))break C;if(F=61,(0|J)<(0|(I=(0|(f=R+G|0))>(0|c)?f:c)))break g;Xg(A,32,I,f,a),VC(A,w,G),Xg(A,48,I,f,65536^a),Xg(A,48,R,t,0),VC(A,n,t),Xg(A,32,I,f,8192^a);continue}break}y=0;break A}F=61}D[3934]=F}y=-1}return d=E+80|0,y}function v(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0;A:{I:if(C){g:{C:switch(D[A+28>>2]-1|0){case 0:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=B[0|I],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+1|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(B[0|I])/F(127),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+1|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 1:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=e[0|I],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+1|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(e[0|I])/F(255),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+1|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 2:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=r[I>>1],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+2|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(r[I>>1])/F(32767),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+2|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 3:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=f[I>>1],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+2|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(f[I>>1])/F(65535),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+2|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 4:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=D[I>>2],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+4|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(D[I>>2])*F(4.656612873077393e-10),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+4|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 5:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=k[I>>2],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+4|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(k[I>>2])*F(2.3283064365386963e-10),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+4|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 6:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=+k[I>>2]+4294967296*+D[I+4>>2],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+8|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(+k[I>>2]+4294967296*+D[I+4>>2])*F(10842021724855044e-35),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+8|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 7:a=1;Q:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if(o=D[(Q=D[A>>2])>>2],E=I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0,I=o+I|0,Q=(i=D[Q+4>>2])-o|0,!e[A+32|0]){if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=+k[I>>2]+4294967296*+k[I+4>>2],(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+8|0)>>>0))break}break A}if((0|Q)<=(0|E))break A;for(E=0;;){if(t[(E<<2)+C>>2]=F(+k[I>>2]+4294967296*+k[I+4>>2])*F(5.421010862427522e-20),(0|(E=E+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break Q;if(!(i>>>0>(I=I+8|0)>>>0))break}break A}if((0|g)>(0|Q))break g;break I;case 8:if(a=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,i=D[Q+4>>2];;){if(I>>>0>=i>>>0)break A;if(t[(E<<2)+C>>2]=t[I>>2],I=I+4|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 9:if(a=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,i=D[Q+4>>2];;){if(I>>>0>=i>>>0)break A;if(t[(E<<2)+C>>2]=N[I>>3],I=I+8|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 10:break C;default:break I}if(a=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(Q=D[(i=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0;;){if(k[i+4>>2]<=I>>>0)break A;if(t[(E<<2)+C>>2]=F(e[0|I]?1:0),I=I+1|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break I}bI((Q<<2)+C|0,0,g-Q<<2)}return a}return 0}function z(A,I){var g,C,Q=0,E=0,i=0;d=g=d-16|0,D[A+12>>2]=I,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,D[(E=A+16|0)>>2]=0,D[E+4>>2]=0,B[E+5|0]=0,B[E+6|0]=0,B[E+7|0]=0,B[E+8|0]=0,B[E+9|0]=0,B[E+10|0]=0,B[E+11|0]=0,B[E+12|0]=0,D[(Q=E+16|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+32|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+48|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E- -64|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+80|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+96|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+112|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+128|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+144|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+160|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+176|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+192|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+208|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+224|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+240|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+256|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+272|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+288|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+304|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+320|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+336|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+352|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+368|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+384|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+400|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+416|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+432|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+448|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+464|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(Q=E+480|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[(E=E+496|0)>>2]=0,D[E+4>>2]=0,B[E+5|0]=0,B[E+6|0]=0,B[E+7|0]=0,B[E+8|0]=0,B[E+9|0]=0,B[E+10|0]=0,B[E+11|0]=0,B[E+12|0]=0,D[A+528>>2]=0,D[A+532>>2]=0,B[A+533|0]=0,B[A+534|0]=0,B[A+535|0]=0,B[A+536|0]=0,B[A+537|0]=0,B[A+538|0]=0,B[A+539|0]=0,B[A+540|0]=0,D[A+544>>2]=0,D[A+548>>2]=0,D[A+560>>2]=0,D[A+552>>2]=0,D[A+556>>2]=0,D[A+564>>2]=0,D[A+568>>2]=0,D[A+580>>2]=0,D[A+572>>2]=0,D[A+576>>2]=0,D[A+584>>2]=0,D[A+588>>2]=0,D[A+600>>2]=0,D[A+592>>2]=0,D[A+596>>2]=0,D[A+612>>2]=0,D[A+604>>2]=0,D[A+608>>2]=0,C=A+628|0;A:{I:{if(I){if(I>>>0<1073741824)break I;iQ(),U()}D[A+616>>2]=0,D[A+620>>2]=0,D[A+624>>2]=0,D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,E=1;break A}Q=DC(E=I<<2),D[A+604>>2]=Q,D[A+612>>2]=i=Q+E|0,bI(Q,0,E),D[A+624>>2]=0,D[A+616>>2]=0,D[A+620>>2]=0,D[A+608>>2]=i,Q=DC(E),D[A+616>>2]=Q,D[A+624>>2]=i=Q+E|0,bI(Q,0,E),D[A+620>>2]=i,Q=DC(E),D[g>>2]=Q,D[g+8>>2]=i=Q+E|0,bI(Q,0,E),D[g+4>>2]=i,E=I<<5|1}return uI(C,E,g),(Q=D[g>>2])&&(D[g+4>>2]=Q,sA(Q)),D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,I&&(Q=DC(I<<=2),D[g>>2]=Q,D[g+8>>2]=i=I+Q|0,bI(Q,0,I),D[g+4>>2]=i),uI(A+640|0,E,g),(I=D[g>>2])&&(D[g+4>>2]=I,sA(I)),d=g+16|0,A}function P(A,I){I|=0;var g,C,Q,E=0,i=0,o=0,a=0,r=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0;d=g=d-96|0;A:if(!((0|(i=R=D[(o=D[(Q=D[4+(A|=0)>>2])+32>>2])+12>>2]))<=(0|(E=D[o+20>>2]))&(C=D[o+16>>2])>>>0>=(r=F=D[o+8>>2])>>>0|(0|E)>(0|i)||(y=e[(a=D[o>>2])+C|0],i=(r=C+1|0)?E:E+1|0,D[o+16>>2]=r,D[o+20>>2]=i,(0|i)>=(0|R)&r>>>0>=F>>>0|(0|i)>(0|R)))){n=e[a+r|0],i=(r=C+2|0)>>>0<2?E+1|0:E,N=r,D[o+16>>2]=r,D[o+20>>2]=i;I:{if((0|(t=y<<24>>24))>=0){if(y>>>0>=(D[A+220>>2]-(r=D[A+216>>2])|0)/144>>>0)break A;if(r=r+s(y,144)|0,D[r>>2]<0)break I;break A}if(D[A+212>>2]>=0)break A;r=A+212|0}D[r>>2]=I;I:{g:{C:{if((65535&((r=f[Q+36>>1])<<8|r>>>8))>>>0>=258){if((0|i)>=(0|R)&N>>>0>=F>>>0|(0|i)>(0|R))break A;if(r=e[a+N|0],E=(i=C+3|0)>>>0<3?E+1|0:E,D[o+16>>2]=i,D[o+20>>2]=E,E=r>>>0>1)break A;if(E=E?0:r,!n)break C;if(E)break A;break g}if(n)break g;E=0}if((0|t)<0?o=A+184|0:(o=D[A+216>>2]+s(y,144)|0,B[o+100|0]=0,o=o+104|0),1!=(0|E)?(d=i=d+-64|0,a=D[D[A+4>>2]+44>>2],E=DC(80),D[E>>2]=12672,D[E+4>>2]=0,D[E+76>>2]=0,D[E+72>>2]=o,D[E+68>>2]=a,D[E+8>>2]=12836,D[E+12>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E- -64>>2]=0,D[(r=n=E+56|0)>>2]=0,D[r+4>>2]=0,F=D[A+8>>2],D[i+40>>2]=0,D[i+44>>2]=0,D[i+32>>2]=0,D[i+36>>2]=0,D[(r=N=i+24|0)>>2]=0,D[r+4>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,D[i+8>>2]=0,D[i+12>>2]=0,D[i+56>>2]=0,D[i+48>>2]=0,D[i+52>>2]=0,D[i>>2]=12836,D[i+4>>2]=F,t=D[F>>2],r=D[F+4>>2],B[i+63|0]=0,hI(R=N,(r-t>>2>>>0)/3|0,N=i+63|0),t=D[(r=D[i+4>>2])+28>>2],r=D[r+24>>2],B[i+63|0]=0,hI(i+36|0,t-r>>2,N),D[i+20>>2]=E,D[i+16>>2]=a,D[i+12>>2]=o,D[i+8>>2]=F,tI(E+8|0,i),SI(n,D[i+48>>2],D[i+52>>2]),D[i>>2]=12836,(o=D[i+48>>2])&&(D[i+52>>2]=o,sA(o)),D[i>>2]=12652,(o=D[i+36>>2])&&sA(o),(o=D[i+24>>2])&&sA(o),d=i- -64|0):(d=a=d-112|0,N=D[D[A+4>>2]+44>>2],E=DC(120),D[E>>2]=12204,D[E+4>>2]=0,D[E+116>>2]=0,D[E+112>>2]=o,D[E+108>>2]=N,D[E+12>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E+56>>2]=0,D[E+60>>2]=0,D[E+8>>2]=12416,D[(i=E- -64|0)>>2]=0,D[i+4>>2]=0,D[E+72>>2]=0,D[E+76>>2]=0,D[E+80>>2]=0,D[E+84>>2]=0,D[E+88>>2]=0,D[E+104>>2]=0,D[E+96>>2]=0,D[E+100>>2]=0,n=D[A+8>>2],D[a+48>>2]=0,D[a+52>>2]=0,D[a+40>>2]=0,D[a+44>>2]=0,D[(i=t=a+32|0)>>2]=0,D[i+4>>2]=0,D[a+24>>2]=0,D[a+28>>2]=0,D[a+16>>2]=0,D[a+20>>2]=0,D[(i=a- -64|0)>>2]=0,D[i+4>>2]=0,D[a+72>>2]=0,D[a+76>>2]=0,D[a+80>>2]=0,D[a+84>>2]=0,D[a+88>>2]=0,D[a+104>>2]=0,D[a+56>>2]=0,D[a+60>>2]=0,D[a+8>>2]=12416,D[a+96>>2]=0,D[a+100>>2]=0,D[a+12>>2]=n,r=D[n>>2],i=D[n+4>>2],B[a+111|0]=0,hI(F=t,(i-r>>2>>>0)/3|0,t=a+111|0),r=D[(i=D[a+12>>2])+28>>2],i=D[i+24>>2],B[a+111|0]=0,hI(a+44|0,r-i>>2,t),D[a+28>>2]=E,D[a+24>>2]=N,D[a+20>>2]=o,D[a+16>>2]=n,tI(o=E+8|0,i=a+8|0),(0|i)!=(0|o)?(SI(E+56|0,D[i+48>>2],D[i+52>>2]),SI(E+68|0,D[i+60>>2],D[i- -64>>2]),SI(E+80|0,D[i+72>>2],D[i+76>>2]),D[E+92>>2]=D[i+84>>2],qI(E+96|0,D[i+88>>2],D[i+92>>2])):D[E+92>>2]=D[i+84>>2],D[a+8>>2]=12416,(o=D[a+96>>2])&&(D[a+100>>2]=o,sA(o)),(o=D[a+80>>2])&&(D[a+84>>2]=o,sA(o)),(o=D[a+68>>2])&&(D[a+72>>2]=o,sA(o)),(o=D[a+56>>2])&&(D[a+60>>2]=o,sA(o)),D[a+8>>2]=12652,(o=D[a+44>>2])&&sA(o),(o=D[a+32>>2])&&sA(o),d=a+112|0),!E)break A;break I}if((0|t)<0)break A;r=D[Q+44>>2],o=D[A+216>>2],E=DC(80),D[E+76>>2]=0,D[E+68>>2]=r,D[E+8>>2]=11900,D[E>>2]=12964,D[E+4>>2]=0,i=o+s(y,144)|0,D[E+72>>2]=k=i+104|0,D[E- -64>>2]=0,D[E+56>>2]=0,D[E+60>>2]=0,D[E+52>>2]=0,D[E+44>>2]=0,D[E+48>>2]=0,D[E+36>>2]=0,D[E+40>>2]=0,D[E+28>>2]=0,D[E+32>>2]=0,D[E+20>>2]=0,D[E+24>>2]=0,D[E+12>>2]=0,D[E+16>>2]=0,D[g+24>>2]=r,D[g+68>>2]=0,D[g+72>>2]=0,D[g+60>>2]=0,D[g+64>>2]=0,D[g+52>>2]=0,D[g+56>>2]=0,D[g+44>>2]=0,D[g+48>>2]=0,D[g+84>>2]=0,D[g+88>>2]=0,D[g+76>>2]=0,D[g+80>>2]=0,D[g+28>>2]=E,o=D[g+28>>2],D[g+8>>2]=D[g+24>>2],D[g+12>>2]=o,D[g+16>>2]=i=i+4|0,D[g+20>>2]=k,D[g+36>>2]=0,D[g+40>>2]=0,D[g+32>>2]=11900,o=D[g+20>>2],D[g>>2]=D[g+16>>2],D[g+4>>2]=o,Dg(k=g+32|0,i,g),tI(o=E+8|0,k),(0|o)!=(0|k)&&SI(E+56|0,D[k+48>>2],D[k+52>>2]),BC(k)}E=pg(DC(64),E),t=D[A+4>>2],A=E;I:{g:{if((0|(E=I))>=0){if(i=t+8|0,!((0|(r=(I=D[t+12>>2])-(o=D[t+8>>2])>>2))>(0|E)))if(k=E+1|0,E>>>0>=r>>>0)GI(i,k-r|0);else if(!(r>>>0<=k>>>0)){if((0|(o=o+(k<<2)|0))!=(0|I))for(;k=D[(I=I-4|0)>>2],D[I>>2]=0,k&&RQ[D[D[k>>2]+4>>2]](k),(0|I)!=(0|o););D[t+12>>2]=o}if(I=D[(o=D[i>>2]+(E<<2)|0)>>2],D[o>>2]=A,I)break g;break I}if(I=A,!A)break I}RQ[D[D[I>>2]+4>>2]](I)}k=(-1^E)>>>31|0}return d=g+96|0,0|k}function $(A){var I,g=0,C=0,Q=0,B=0,E=0;if(d=I=d-16|0,D[I+12>>2]=A,A>>>0<=211)Q=D[Kg(14288,14480,I+12|0)>>2];else{for(A>>>0>=4294967292&&(FQ(),U()),Q=s(B=(A>>>0)/210|0,210),D[I+8>>2]=A-Q,E=Kg(14480,14672,I+8|0)-14480>>2;;){Q=D[14480+(E<<2)>>2]+Q|0,A=5;A:{for(;;){I:if(47!=(0|A)){if((g=D[14288+(A<<2)>>2])>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if(A=A+1|0,(0|s(g,C))!=(0|Q))continue}else for(A=211;;){if((g=(Q>>>0)/(A>>>0)|0)>>>0<A>>>0)break A;if((0|s(A,g))==(0|Q))break I;if((g=A+10|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+12|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+16|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+18|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+22|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+28|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+30|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+36|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+40|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+42|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+46|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+52|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+58|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+60|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+66|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+70|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+72|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+78|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+82|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+88|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+96|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+100|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+102|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+106|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+108|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+112|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+120|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+126|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+130|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+136|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+138|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+142|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+148|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+150|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+156|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+162|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+166|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+168|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+172|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+178|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+180|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+186|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+190|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+192|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+196|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+198|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if((0|s(g,C))==(0|Q))break I;if((g=A+208|0)>>>0>(C=(Q>>>0)/(g>>>0)|0)>>>0)break A;if(A=A+210|0,(0|s(g,C))==(0|Q))break}break}E=(A=48==(0|(Q=E+1|0)))?0:Q,Q=s(B=A+B|0,210);continue}break}D[I+12>>2]=Q}return d=I+16|0,Q}function AA(A,I){var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0,R=0,y=0;d=g=d-16|0;A:{I:{g:{if(e[D[A+4>>2]+36|0]<=1){if(t=-1,C=D[I+20>>2],C=(i=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C,(E=i)>>>0>k[I+8>>2]&(0|(i=D[I+12>>2]))<=(0|C)|(0|C)>(0|i))break g;D[g+12>>2]=i=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=E,D[I+20>>2]=C}else{if(t=-1,!yg(1,g+12|0,I))break g;i=D[g+12>>2]}C:{Q:{B:{E:{i:{o:if(i){if((D[(C=D[A+8>>2])+4>>2]-D[C>>2]>>2>>>0)/3>>>0<i>>>0)break g;if((65535&((C=f[D[A+4>>2]+36>>1])<<8|C>>>8))>>>0>=258){Q=0;a:{r:{for(;;){if(!yg(1,g+8|0,I))break g;if(C=D[g+8>>2],!yg(1,g+8|0,I))break g;if((Q=C+Q|0)>>>0<(C=D[g+8>>2])>>>0)break g;if(a=Q-C|0,(0|(o=D[A+40>>2]))==D[A+44>>2]){if((r=1+(o=(0|(E=o-(C=D[A+36>>2])|0))/12|0)|0)>>>0>=357913942)break r;if(F=o<<1,(r=o>>>0<178956970?r>>>0>F>>>0?r:F:357913941)>>>0>=357913942)break a;o=(F=DC(r=s(r,12)))+s(o,12)|0,D[o+4>>2]=Q,D[o>>2]=a,a=o+s((0|E)/-12|0,12)|0,o=o+12|0,(0|E)>0&&xA(a,C,E),D[A+44>>2]=r+F,D[A+40>>2]=o,D[A+36>>2]=a,C&&sA(C)}else D[o+4>>2]=Q,D[o>>2]=a,D[A+40>>2]=o+12;if((0|(N=N+1|0))==(0|i))break}for(t=0,dI(I,0,0),Q=i>>>0>1?i:1;;){C=e[I+36|0];D:{e:{if((65535&((i=f[D[A+4>>2]+36>>1])<<8|i>>>8))>>>0<=513){if(!C)break D;if(o=0,(i=(N=(C=D[I+32>>2])>>>3|0)+(E=D[I+24>>2])|0)>>>0>=(a=D[I+28>>2])>>>0?i=C:(o=e[0|i],D[I+32>>2]=i=C+1|0,N=i>>>3|0,o=o>>>(7&C)&1),a>>>0>E+N>>>0)break e;break D}if(!C)break D;if(o=0,(C=D[I+24>>2]+((i=D[I+32>>2])>>>3|0)|0)>>>0>=k[I+28>>2])break D;o=e[0|C]>>>(7&i)&1}D[I+32>>2]=i+1}if(C=D[A+36>>2]+s(t,12)|0,B[C+8|0]=254&e[C+8|0]|1&o,(0|Q)==(0|(t=t+1|0)))break}B[I+36|0]=0,Q=0,C=(C=D[I+20>>2])+(E=(Q=(i=D[I+32>>2]+7|0)>>>0<7?1:Q)>>>3|0)|0,D[I+16>>2]=Q=(i=(7&Q)<<29|i>>>3)+D[I+16>>2]|0,D[I+20>>2]=Q>>>0<i>>>0?C+1|0:C;break o}iQ(),U()}break A}for(;;){if(Q=C=D[I+20>>2],F=r=(a=D[I+16>>2])+4|0,(n=D[I+8>>2])>>>0<r>>>0&(0|(C=r>>>0<4?C+1|0:C))>=(0|(E=D[I+12>>2]))|(0|C)>(0|E))break g;if(y=e[0|(r=(R=D[I>>2])+a|0)]|e[r+1|0]<<8|e[r+2|0]<<16|e[r+3|0]<<24,D[I+16>>2]=F,D[I+20>>2]=C,C=Q,(r=a+8|0)>>>0>n>>>0&(0|(C=r>>>0<8?C+1|0:C))>=(0|E)|(0|C)>(0|E))break g;if(F=e[0|(F=F+R|0)]|e[F+1|0]<<8|e[F+2|0]<<16|e[F+3|0]<<24,D[I+16>>2]=r,D[I+20>>2]=C,(0|C)>=(0|E)&r>>>0>=n>>>0|(0|C)>(0|E))break g;if(C=e[r+R|0],Q=(E=a+9|0)>>>0<9?Q+1|0:Q,D[I+16>>2]=E,D[I+20>>2]=Q,o=1&C|-2&o,(0|(C=D[A+40>>2]))==D[A+44>>2]){if((a=1+(C=(0|(E=C-(Q=D[A+36>>2])|0))/12|0)|0)>>>0>=357913942)break i;if(r=C<<1,(a=C>>>0<178956970?a>>>0>r>>>0?a:r:357913941)>>>0>=357913942)break A;C=(n=DC(r=s(a,12)))+s(C,12)|0,B[C+8|0]=o,D[C+4>>2]=F,D[C>>2]=y,a=C+s((0|E)/-12|0,12)|0,(0|E)>0&&xA(a,Q,E),D[A+44>>2]=r+n,D[A+40>>2]=C+12,D[A+36>>2]=a,Q&&sA(Q)}else B[C+8|0]=o,D[C+4>>2]=F,D[C>>2]=y,D[A+40>>2]=C+12;if((0|(N=N+1|0))==(0|i))break}}if(D[g+8>>2]=0,(C=65535&((C=f[D[A+4>>2]+36>>1])<<8|C>>>8))>>>0<=511){if(t=-1,C=D[I+20>>2],(0|(E=D[I+12>>2]))<=(0|(C=(i=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C))&i>>>0>k[I+8>>2]|(0|C)>(0|E))break g;Q=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=C}else{if(512!=(0|C))break C;if(t=-1,!yg(1,g+8|0,I))break g;Q=D[g+8>>2]}if(!Q)break C;if((65535&((C=f[D[A+4>>2]+36>>1])<<8|C>>>8))>>>0<258)break Q;for(o=0,t=0;;){if(!yg(1,g+4|0,I))break B;if(t=D[g+4>>2]+t|0,(0|(C=D[A+52>>2]))==D[A+56>>2]){if((C=1+(a=(E=C-(i=D[A+48>>2])|0)>>2)|0)>>>0>=1073741824)break E;if(N=E>>1,N=a>>>0<536870911?C>>>0>N>>>0?C:N:1073741823){if(N>>>0>=1073741824)break A;C=DC(N<<2)}else C=0;D[(a=C+(a<<2)|0)>>2]=t,(0|E)>0&&xA(C,i,E),D[A+56>>2]=C+(N<<2),D[A+52>>2]=a+4,D[A+48>>2]=C,i&&sA(i)}else D[C>>2]=t,D[A+52>>2]=C+4;if((0|(o=o+1|0))==(0|Q))break}break C}iQ(),U()}iQ(),U()}t=-1;break g}for(i=0;;){if(C=D[I+20>>2],(0|(t=D[I+12>>2]))<=(0|(C=(o=(E=D[I+16>>2])+4|0)>>>0<4?C+1|0:C))&o>>>0>k[I+8>>2]|(0|C)>(0|t)){t=-1;break g}if(N=e[0|(E=E+D[I>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=o,D[I+20>>2]=C,(0|(C=D[A+52>>2]))==D[A+56>>2]){if((C=1+(a=(o=C-(E=D[A+48>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(t=o>>1,t=a>>>0<536870911?C>>>0>t>>>0?C:t:1073741823){if(t>>>0>=1073741824)break A;C=DC(t<<2)}else C=0;D[(a=C+(a<<2)|0)>>2]=N,(0|o)>0&&xA(C,E,o),D[A+56>>2]=C+(t<<2),D[A+52>>2]=a+4,D[A+48>>2]=C,E&&sA(E)}else D[C>>2]=N,D[A+52>>2]=C+4;if((0|(i=i+1|0))==(0|Q))break}}t=D[I+16>>2]}return d=g+16|0,t}iQ(),U()}xg(1336),U()}function IA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=F(0),r=0;A:if(C){I:{g:switch(D[A+28>>2]-1|0){case 0:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(B[I+C|0]=e[0|E],(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 1:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((0|(Q=B[0|E]))<0)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 2:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(((Q=f[E>>1])-128&65535)>>>0<65280)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+2|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 3:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=f[E>>1])>>>0>127)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+2|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 4:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=D[E>>2])-128>>>0<4294967040)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 5:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=D[E>>2])>>>0>127)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 6:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(-1==(0|(Q=D[E+4>>2]-((o=D[E>>2])>>>0<128)|0))&o-128>>>0<4294967040|-1!=(0|Q))break A;if(B[I+C|0]=o,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 7:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(!(Q=D[E+4>>2])&(o=D[E>>2])>>>0>127|Q)break A;if(B[I+C|0]=o,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 8:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(o=I+C|0,Q=F(n(a=t[E>>2]))<F(2147483648)?~~a:-2147483648,B[0|o]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 9:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(o=I+C|0,Q=n(r=N[E>>3])<2147483648?~~r:-2147483648,B[0|o]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 10:break g;default:break A}g:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(B[I+C|0]=e[0|E],(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break g;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)<=(0|Q))break A}bI(C+Q|0,0,g-Q|0)}return i}function gA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=F(0),r=0;A:if(C){I:{g:switch(D[A+28>>2]-1|0){case 0:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((0|(Q=B[0|E]))<0)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 1:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(B[I+C|0]=e[0|E],(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 2:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=f[E>>1])>>>0>255)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+2|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 3:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=f[E>>1])>>>0>255)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+2|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 4:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=D[E>>2])>>>0>255)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 5:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if((Q=D[E>>2])>>>0>255)break A;if(B[I+C|0]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 6:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(!(Q=D[E+4>>2])&(o=D[E>>2])>>>0>255|Q)break A;if(B[I+C|0]=o,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 7:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(!(Q=D[E+4>>2])&(o=D[E>>2])>>>0>255|Q)break A;if(B[I+C|0]=o,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 8:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(o=I+C|0,Q=(a=t[E>>2])<F(4294967296)&a>=F(0)?~~a>>>0:0,B[0|o]=Q,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+4|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 9:C:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(B[0|(o=I+C|0)]=Q=(r=N[E>>3])<4294967296&r>=0?~~r>>>0:0,(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break C;if(!((E=E+8|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)>(0|Q))break I;break A;case 10:break g;default:break A}g:if(!((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))<=0)){if((0|(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0))>=(D[(E=D[A>>2])+4>>2]-(Q=D[E>>2])|0))break A;for(E=I+Q|0,I=0;;){if(B[I+C|0]=e[0|E],(0|(I=I+1|0))>=(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q)))break g;if(!((E=E+1|0)>>>0<k[D[A>>2]+4>>2]))break}break A}if(i=1,(0|g)<=(0|Q))break A}bI(C+Q|0,0,g-Q|0)}return i}function CA(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;A:{I:{g:{C:{Q:if(D[A+92>>2]!=D[A+88>>2]){if((0|(g=D[A+52>>2]))==D[A+56>>2]){if((Q=1+(C=(i=g-(E=D[A+48>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(g=i>>1,B=C>>>0<536870911?g>>>0<Q>>>0?Q:g:1073741823){if(B>>>0>=1073741824)break A;g=DC(B<<2)}else g=0;D[(Q=g+(C<<2)|0)>>2]=I,(0|i)>0&&xA(g,E,i),D[A+56>>2]=g+(B<<2),D[A+52>>2]=Q+4,D[A+48>>2]=g,E&&sA(E)}else D[g>>2]=I,D[A+52>>2]=g+4;D[A+84>>2]=0,Q=-1,g=-1;B:if(-1!=(0|I)){if(B=D[A+4>>2],-1!=(0|(g=((g=I+1|0)>>>0)%3|0?g:I-2|0))&&(Q=D[D[B>>2]+(g<<2)>>2]),(I>>>0)%3|0)C=I-1|0;else if(g=-1,-1==(0|(C=I+2|0)))break B;g=D[D[B>>2]+(C<<2)>>2]}if(a=g>>>3&536870908,(i=D[(E=(C=D[A+36>>2])+(Q>>>3&536870908)|0)>>2])&(B=1<<Q)||(D[E>>2]=B|i,gI(B=A+8|0,Q,C=-1!=(0|I)?((C=I+1|0)>>>0)%3|0?C:I-2|0:-1),C=D[A+36>>2]),(C=D[(B=C+a|0)>>2])&(Q=1<<g)||(D[B>>2]=C|Q,Q=-1,-1!=(0|I)&&(Q=I-1|0,(I>>>0)%3|0||(Q=I+2|0)),gI(C=A+8|0,g,Q)),Q=-1,(C=D[(B=D[A+36>>2]+((Q=-1!=(0|I)?D[D[D[A+4>>2]>>2]+(I<<2)>>2]:Q)>>>3&536870908)|0)>>2])&(g=1<<Q)||(D[B>>2]=g|C,gI(A+8|0,Q,I)),!((0|(C=D[A+84>>2]))>2))for(;;){if(Q=s(C,12)+A|0,(0|(I=D[Q+52>>2]))==D[Q+48>>2]){if(3!=(0|(C=C+1|0)))continue;break Q}if(I=D[(g=I-4|0)>>2],D[Q+52>>2]=g,D[A+84>>2]=C,-1==(0|I))break Q;B:if(!(D[(Q=D[A+24>>2])+((g=(I>>>0)/3|0)>>>3&268435452)>>2]>>>g&1)){E:{for(;;){D[(g=((e=(I>>>0)/3|0)>>>3&268435452)+Q|0)>>2]=D[g>>2]|1<<e,Q=-1;i:{o:{a:{r:{D:{e:{f:{k:{if(!((C=D[(B=D[A+36>>2]+((Q=-1!=(0|I)?D[D[D[A+4>>2]>>2]+(I<<2)>>2]:Q)>>>3&536870908)|0)>>2])&(g=1<<Q))){if(D[B>>2]=g|C,i=D[(D[D[A+16>>2]+96>>2]+s(e,12)|0)+((I>>>0)%3<<2)>>2],(0|(g=D[(r=D[D[A+20>>2]+4>>2])+4>>2]))==D[r+8>>2]){if((C=1+(B=(a=g-(o=D[r>>2])|0)>>2)|0)>>>0>=1073741824)break k;if(g=a>>1,E=B>>>0<536870911?g>>>0<C>>>0?C:g:1073741823){if(E>>>0>=1073741824)break A;g=DC(E<<2)}else g=0;D[(C=g+(B<<2)|0)>>2]=i,(0|a)>0&&xA(g,o,a),D[r+8>>2]=g+(E<<2),D[r+4>>2]=C+4,D[r>>2]=g,o&&sA(o)}else D[g>>2]=i,D[r+4>>2]=g+4;if((0|(g=D[(o=D[A+12>>2])+4>>2]))==D[o+8>>2]){if((C=1+(B=(E=g-(a=D[o>>2])|0)>>2)|0)>>>0>=1073741824)break f;if(g=E>>1,i=B>>>0<536870911?g>>>0<C>>>0?C:g:1073741823){if(i>>>0>=1073741824)break A;g=DC(i<<2)}else g=0;D[(C=g+(B<<2)|0)>>2]=I,(0|E)>0&&xA(g,a,E),D[o+8>>2]=g+(i<<2),D[o+4>>2]=C+4,D[o>>2]=g,a&&sA(a)}else D[g>>2]=I,D[o+4>>2]=g+4;D[D[(g=D[A+12>>2])+12>>2]+(Q<<2)>>2]=D[g+24>>2],D[g+24>>2]=D[g+24>>2]+1}if(-1==(0|I))break E;E=D[A+4>>2],Q=-1,-1!=(0|(g=((g=I+1|0)>>>0)%3|0?g:I-2|0))&&(Q=D[D[E+12>>2]+(g<<2)>>2]);t:{if((0|s(e,3))==(0|I)){if(B=I+2|0,I=-1,-1==(0|B))break t}else B=I-1|0;I=D[D[E+12>>2]+(B<<2)>>2]}if(i=-1==(0|I),B=(I>>>0)/3|0,C=(Q>>>0)/3|0,!(g=-1==(0|Q))){if(g=D[D[A+24>>2]+((g=g?-1:C)>>>3&536870908)>>2]&1<<g,i)break e;e=0!=(0|g);break D}if(e=1,!i)break D;break E}iQ(),U()}iQ(),U()}if(!g)break r;break E}if(!(D[D[A+24>>2]+((g=i?-1:B)>>>3&536870908)>>2]>>>g&1)){if(B=0,D[D[A+36>>2]+((g=D[D[E>>2]+(I<<2)>>2])>>>3&536870908)>>2]>>>g&1||(D[(g=D[A+88>>2]+(g<<2)|0)>>2]=(C=D[g>>2])+1,B=(0|C)<=0?2:1),D[A+84>>2]>=(0|B)&&e)break o;if(r=s(B,12)+A|0,(0|(g=D[r+52>>2]))==D[r+56>>2]){if((C=1+(i=(a=g-(o=D[r+48>>2])|0)>>2)|0)>>>0>=1073741824)break C;if(g=a>>1,E=i>>>0<536870911?g>>>0<C>>>0?C:g:1073741823){if(E>>>0>=1073741824)break A;g=DC(E<<2)}else g=0;D[(C=g+(i<<2)|0)>>2]=I,(0|a)>0&&xA(g,o,a),D[r+48>>2]=g,D[r+52>>2]=C+4,D[r+56>>2]=g+(E<<2),o&&sA(o)}else D[g>>2]=I,D[r+52>>2]=g+4;D[A+84>>2]<=(0|B)||(D[A+84>>2]=B)}if(e)break E;if(I=-1,-1==(0|Q))break a}I=D[D[D[A+4>>2]>>2]+(Q<<2)>>2]}if(B=0,D[D[A+36>>2]+(I>>>3&536870908)>>2]>>>I&1||(D[(I=D[A+88>>2]+(I<<2)|0)>>2]=(g=D[I>>2])+1,B=(0|g)<=0?2:1),D[A+84>>2]<(0|B))break i;I=Q}Q=D[A+24>>2];continue}break}if(o=s(B,12)+A|0,(0|(I=D[o+52>>2]))==D[o+56>>2]){if((g=1+(C=(E=I-(a=D[o+48>>2])|0)>>2)|0)>>>0>=1073741824)break g;if(I=E>>1,i=C>>>0<536870911?I>>>0<g>>>0?g:I:1073741823){if(i>>>0>=1073741824)break A;I=DC(i<<2)}else I=0;D[(g=I+(C<<2)|0)>>2]=Q,(0|E)>0&&xA(I,a,E),D[o+48>>2]=I,D[o+52>>2]=g+4,D[o+56>>2]=I+(i<<2),a&&sA(a)}else D[I>>2]=Q,D[o+52>>2]=I+4;if((0|(C=D[A+84>>2]))<=(0|B))break B;D[A+84>>2]=B,C=B;break B}C=D[A+84>>2]}if(!((0|C)<3))break}}return 1}iQ(),U()}iQ(),U()}iQ(),U()}xg(1336),U()}function QA(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0;if(d=g=d-48|0,C=D[D[A+4>>2]+44>>2],E=D[(Q=D[A+8>>2])>>2],Q=D[Q+4>>2],D[g+40>>2]=0,D[g+32>>2]=0,D[g+36>>2]=0,(Q=(Q-E>>2>>>0)/3|0)>>>0>(E=(D[C+100>>2]-(a=D[C+96>>2])|0)/12|0)>>>0?MA(C+96|0,Q-E|0,g+32|0):Q>>>0>=E>>>0||(D[C+100>>2]=a+s(Q,12)),D[A+216>>2]!=D[A+220>>2]){D[g+24>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,I=D[(r=D[A+8>>2])>>2],C=D[r+4>>2],D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0;A:{I:{g:{C:{Q:{B:{E:{if(I=C-I|0){if((0|I)<0)break E;k=DC(I),D[g>>2]=k,D[g+8>>2]=(I>>2<<2)+k,G=g,c=bI(k,0,I)+I|0,D[G+4>>2]=c}if((D[r+28>>2]-(C=D[r+24>>2])|0)<=0){Q=0,I=0;break I}for(Q=0,E=0,I=0;;){i:if(-1!=(0|(a=D[(t<<2)+C>>2]))){o:if(!(D[D[A+120>>2]+(t>>>3&536870908)>>2]>>>t&1)&&(C=D[A+220>>2]-(F=D[A+216>>2])|0))for(n=(C=(0|C)/144|0)>>>0>1?C:1,e=0,R=0!=(0|(C=(a>>>0)%3|0))|-1!=(0|(i=a+2|0)),y=C?a-1|0:i;;){if(o=a<<2,B=F+s(e,144)|0,D[D[B+16>>2]+((C=D[o+D[D[B+68>>2]>>2]>>2])>>>3&536870908)>>2]>>>C&1&&(C=-1,R&&(C=-1,-1!=(0|(i=D[D[r+12>>2]+(y<<2)>>2]))&&(C=i-1|0,(i>>>0)%3|0||(C=i+2|0))),(0|a)!=(0|C)))for(i=D[(B=D[B+32>>2])+o>>2];;){if(f=0,-1==(0|C))break A;if(D[B+(C<<2)>>2]!=(0|i)){a=C;break o}a:{if((C>>>0)%3|0)o=C-1|0;else if(f=-1,-1==(0|(o=C+2|0)))break a;f=-1,-1!=(0|(C=D[D[r+12>>2]+(o<<2)>>2]))&&(f=C-1|0,(C>>>0)%3|0||(f=C+2|0))}if((0|a)==(0|(C=f)))break}if((0|n)==(0|(e=e+1|0)))break}if(D[(a<<2)+k>>2]=i=(C=I-E|0)>>2,I>>>0<N>>>0)D[I>>2]=a,D[g+20>>2]=I=I+4|0;else{if((I=i+1|0)>>>0>=1073741824)break B;if(B=(Q=N-E|0)>>1,I=Q>>2>>>0<536870911?I>>>0>B>>>0?I:B:1073741823){if(I>>>0>=1073741824)break Q;Q=DC(I<<2)}else Q=0;D[(i=Q+(i<<2)|0)>>2]=a,N=(I<<2)+Q|0,I=i+4|0,(0|C)>0&&xA(Q,E,C),D[g+24>>2]=N,D[g+20>>2]=I,D[g+16>>2]=Q,E&&(sA(E),r=D[A+8>>2]),E=Q}if(-1!=(0|a)){if((a>>>0)%3|0)C=a-1|0;else if(-1==(0|(C=a+2|0)))break i;if(-1!=(0|(C=D[D[r+12>>2]+(C<<2)>>2]))&&-1!=(0|(C=C+((C>>>0)%3|0?-1:2)|0))&&(0|C)!=(0|(B=a)))for(;;){i=C;o:{a:if(C=D[A+220>>2]-(o=D[A+216>>2])|0){for(e=(C=(0|C)/144|0)>>>0>1?C:1,C=0;;){if(F=D[32+(o+s(C,144)|0)>>2],D[F+(n=i<<2)>>2]==D[F+(B<<2)>>2]){if((0|e)!=(0|(C=C+1|0)))continue;break a}break}if(D[k+n>>2]=B=(C=I-Q|0)>>2,I>>>0<N>>>0){D[I>>2]=i,D[g+20>>2]=I=I+4|0,E=Q;break o}if((I=B+1|0)>>>0>=1073741824)break C;if(o=(E=N-Q|0)>>1,I=E>>2>>>0<536870911?I>>>0>o>>>0?I:o:1073741823){if(I>>>0>=1073741824)break g;E=DC(I<<2)}else E=0;if(D[(B=E+(B<<2)|0)>>2]=i,N=(I<<2)+E|0,I=B+4|0,(0|C)>0&&xA(E,Q,C),D[g+24>>2]=N,D[g+20>>2]=I,D[g+16>>2]=E,!Q){Q=E;break o}sA(Q),r=D[A+8>>2],Q=E;break o}D[(i<<2)+k>>2]=D[(B<<2)+k>>2]}if(-1==(0|i))break i;if((i>>>0)%3|0)C=i-1|0;else if(-1==(0|(C=i+2|0)))break i;if(-1==(0|(C=D[D[r+12>>2]+(C<<2)>>2])))break i;if(-1==(0|(C=C+((C>>>0)%3|0?-1:2)|0)))break i;if(B=i,(0|C)==(0|a))break}}}if(!((0|(t=t+1|0))<D[r+28>>2]-(C=D[r+24>>2])>>2))break}break I}iQ(),U()}iQ(),U()}xg(1336),U()}iQ(),U()}xg(1336),U()}if((0|(e=D[(o=D[(t=D[A+4>>2])+44>>2])+100>>2]))!=D[o+96>>2])for(C=0;E=C+1|0,i=s(C,12),B=D[8+(a=i+k|0)>>2],r=D[a+4>>2],a=D[a>>2],(f=C)>>>0>=(e=(e-(C=D[o+96>>2])|0)/12|0)>>>0&&(D[g+40>>2]=0,D[g+32>>2]=0,D[g+36>>2]=0,MA(o+96|0,E-e|0,g+32|0),t=D[A+4>>2],C=D[o+96>>2]),D[8+(C=C+i|0)>>2]=B,D[C+4>>2]=r,D[C>>2]=a,(C=E)>>>0<((e=D[(o=D[t+44>>2])+100>>2])-D[o+96>>2]|0)/12>>>0;);D[D[t+4>>2]+80>>2]=I-Q>>2,f=1}C=f,k&&sA(k),Q&&(D[g+20>>2]=Q,sA(Q))}else{if((0|(Q=D[(o=D[(r=D[A+4>>2])+44>>2])+100>>2]))!=D[o+96>>2])for(C=0;;){i=D[A+8>>2];A:{if(-1!=(0|(B=s(C,3))))if(e=-1,a=D[D[i>>2]+(B<<2)>>2],-1!=(0|(E=B+1|0))){if(e=D[D[i>>2]+(E<<2)>>2],E=-1,-1==(0|(B=B+2|0)))break A}else B=0;else e=D[4+(D[i>>2]+(B<<2)|0)>>2],a=-1,B=1;E=D[D[i>>2]+(B<<2)>>2]}if(i=E,E=C+1|0,(B=((B=Q)-(Q=D[o+96>>2])|0)/12|0)>>>0<=C>>>0&&(D[g+40>>2]=0,D[g+32>>2]=0,D[g+36>>2]=0,MA(o+96|0,E-B|0,g+32|0),r=D[A+4>>2],Q=D[o+96>>2]),C=s(C,12)+Q|0,D[C+8>>2]=i,D[C+4>>2]=e,D[C>>2]=a,!((C=E)>>>0<((Q=D[(o=D[r+44>>2])+100>>2])-D[o+96>>2]|0)/12>>>0))break}D[D[r+4>>2]+80>>2]=I,C=1}return d=g+48|0,C}function BA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=F(0),k=0,s=0;A:if(C){I:{g:switch(D[A+28>>2]-1|0){case 0:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=i=B[0|I],D[Q+4>>2]=i>>31,I=I+1|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 1:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=e[0|I],D[Q+4>>2]=0,I=I+1|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 2:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=i=r[I>>1],D[Q+4>>2]=i>>31,I=I+2|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 3:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=f[I>>1],D[Q+4>>2]=0,I=I+2|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 4:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=i=D[I>>2],D[Q+4>>2]=i>>31,I=I+4|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 5:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=D[I>>2],D[Q+4>>2]=0,I=I+4|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 6:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(i=D[I+4>>2],D[(Q=(E<<3)+C|0)>>2]=D[I>>2],D[Q+4>>2]=i,I=I+8|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 7:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(Q=D[I>>2],(0|(i=D[I+4>>2]))<0)break A;if(D[(s=(E<<3)+C|0)>>2]=Q,D[s+4>>2]=i,I=I+8|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 8:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,s=D[Q+4>>2];;){if(I>>>0>=s>>>0)break A;if(Q=(E<<3)+C|0,F(n(a=t[I>>2]))<F(0x8000000000000000)?(i=F(n(a))>=F(1)?~~(a>F(0)?F(y(F(c(F(a*F(2.3283064365386963e-10)))),F(4294967296))):F(w(F(F(a-F(~~a>>>0>>>0))*F(2.3283064365386963e-10)))))>>>0:0,o=~~a>>>0):(i=-2147483648,o=0),D[Q>>2]=o,D[Q+4>>2]=i,I=I+4|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 9:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,s=D[Q+4>>2];;){if(I>>>0>=s>>>0)break A;if(Q=(E<<3)+C|0,n(k=N[I>>3])<0x8000000000000000?(i=n(k)>=1?~~(k>0?y(c(2.3283064365386963e-10*k),4294967295):w(2.3283064365386963e-10*(k-+(~~k>>>0>>>0))))>>>0:0,o=~~k>>>0):(i=-2147483648,o=0),D[Q>>2]=o,D[Q+4>>2]=i,I=I+8|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break I;break A;case 10:break g;default:break A}if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(i=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,o=D[Q+4>>2];;){if(I>>>0>=o>>>0)break A;if(D[(Q=(E<<3)+C|0)>>2]=e[0|I],D[Q+4>>2]=0,I=I+1|0,!((0|(E=E+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break A}bI((Q<<3)+C|0,0,g-Q<<3)}}function EA(A,I,g){I|=0,g|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0;d=C=d-96|0,E=D[16+(A|=0)>>2],B[C+92|0]=1,D[C+88>>2]=I,D[C+84>>2]=I,D[C+80>>2]=E;A:{I:{if((E=D[D[E+28>>2]+(I<<2)>>2])>>>0<D[(t=D[A+20>>2])+4>>2]-(Q=D[t>>2])>>2>>>0){if(Q=D[D[A+8>>2]+(D[Q+(E<<2)>>2]<<2)>>2],e[(E=D[A+4>>2])+84|0]||(Q=D[D[E+68>>2]+(Q<<2)>>2]),D[C+72>>2]=0,D[C+76>>2]=0,D[(t=C- -64|0)>>2]=0,D[t+4>>2]=0,D[C+56>>2]=0,D[C+60>>2]=0,BA(E,Q,B[E+24|0],C+56|0),Q=((E=I+1|0)>>>0)%3|0,I>>>0<=E>>>0)for(t=Q?E:I-2|0,o=((I>>>0)%3|0?-1:2)+I|0;;){if(Q=t,E=o,D[A+28>>2]&&(Q=((E=I+1|0)>>>0)%3|0?E:I-2|0,E=I-1|0,(I>>>0)%3|0||(E=I+2|0)),(Q=D[D[D[A+16>>2]+28>>2]+(Q<<2)>>2])>>>0>=D[(f=D[A+20>>2])+4>>2]-(I=D[f>>2])>>2>>>0)break I;if(Q=D[D[A+8>>2]+(D[I+(Q<<2)>>2]<<2)>>2],e[(I=D[A+4>>2])+84|0]||(Q=D[D[I+68>>2]+(Q<<2)>>2]),D[C+48>>2]=0,D[C+52>>2]=0,D[C+40>>2]=0,D[C+44>>2]=0,D[C+32>>2]=0,D[C+36>>2]=0,BA(I,Q,B[I+24|0],C+32|0),(E=D[D[D[A+16>>2]+28>>2]+(E<<2)>>2])>>>0>=D[(Q=D[A+20>>2])+4>>2]-(I=D[Q>>2])>>2>>>0)break A;Q=D[D[A+8>>2]+(D[I+(E<<2)>>2]<<2)>>2],e[(I=D[A+4>>2])+84|0]||(Q=D[D[I+68>>2]+(Q<<2)>>2]),D[C+24>>2]=0,D[C+28>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,BA(I,Q,B[I+24|0],C+8|0),c=mg(Q=(E=D[C+8>>2])-(I=D[C+56>>2])|0,N=D[C+12>>2]-((f=D[C+60>>2])+(I>>>0>E>>>0)|0)|0,y=(a=D[C+40>>2])-(E=D[C+64>>2])|0,a=D[C+44>>2]-((G=D[C+68>>2])+(E>>>0>a>>>0)|0)|0),i=i-(u+(r>>>0<c>>>0)|0)|0,b=w=r-c|0,E=mg(c=(r=D[C+16>>2])-E|0,G=D[C+20>>2]-((E>>>0>r>>>0)+G|0)|0,w=(r=D[C+32>>2])-I|0,f=D[C+36>>2]-((I>>>0>r>>>0)+f|0)|0),I=u+i|0,i=I=E>>>0>(r=b+E|0)>>>0?I+1|0:I,b=s,F=mg(Q,F=N,N=(I=D[C+48>>2])-(E=D[C+72>>2])|0,h=D[C+52>>2]-((s=D[C+76>>2])+(I>>>0<E>>>0)|0)|0),I=u+k|0,I=(Q=b+F|0)>>>0<F>>>0?I+1|0:I,s=Q-(k=mg(F=(k=D[C+24>>2])-E|0,E=D[C+28>>2]-((E>>>0>k>>>0)+s|0)|0,w,f))|0,k=I-(u+(Q>>>0<k>>>0)|0)|0,Q=n-(I=mg(c,G,N,h))|0,I=R-(u+(I>>>0>n>>>0)|0)|0,R=mg(F,E,y,a),I=u+I|0,R=I=(n=R+Q|0)>>>0<R>>>0?I+1|0:I,I=D[C+88>>2],E=D[C+80>>2];g:if(e[C+92|0]){C:{if(-1==(0|I)||-1==(0|(I=((Q=I+1|0)>>>0)%3|0?Q:I-2|0))|D[D[E>>2]+(I>>>3&536870908)>>2]>>>I&1||-1==(0|(I=D[D[D[E+64>>2]+12>>2]+(I<<2)>>2])))D[C+88>>2]=-1;else if(D[C+88>>2]=I=((Q=I+1|0)>>>0)%3|0?Q:I-2|0,-1!=(0|I))break C;Q=-1;Q:if(-1!=(0|(I=D[C+84>>2]))){if((I>>>0)%3|0)I=I-1|0;else if(Q=-1,-1==(0|(I=I+2|0)))break Q;Q=-1,D[D[E>>2]+(I>>>3&536870908)>>2]>>>I&1||(Q=-1,-1!=(0|(I=D[D[D[E+64>>2]+12>>2]+(I<<2)>>2]))&&(Q=I-1|0,(I>>>0)%3|0||(Q=I+2|0)))}B[C+92|0]=0,D[C+88>>2]=Q;break g}if((0|I)!=D[C+84>>2])break g;D[C+88>>2]=-1}else{Q=-1;C:if(-1!=(0|I)){if((I>>>0)%3|0)I=I-1|0;else if(Q=-1,-1==(0|(I=I+2|0)))break C;Q=-1,D[D[E>>2]+(I>>>3&536870908)>>2]>>>I&1||(Q=-1,-1!=(0|(I=D[D[D[E+64>>2]+12>>2]+(I<<2)>>2]))&&(Q=I-1|0,(I>>>0)%3|0||(Q=I+2|0)))}D[C+88>>2]=Q}if(-1==(0|(I=D[C+88>>2])))break}Q=(I=R>>31)+n|0,E=I,I=I+R|0,f=Q^E,o=E^(Q>>>0<E>>>0?I+1|0:I),N=-1,Q=2147483647,a=I=k>>31,E=I+s|0,I=I+k|0,I=E>>>0<a>>>0?I+1|0:I,E^=a,a=I^=a,y=-1^E,I^=2147483647,t=i;g:{if(D[A+28>>2]){if(!((0|I)==(0|o)&f>>>0>y>>>0|I>>>0<o>>>0)&&(I=o+a|0,E=I=(A=E+f|0)>>>0<E>>>0?I+1|0:I,o=i,i=(I=i>>31)+r|0,a=o,o=I,I=a+I|0,I=i>>>0<o>>>0?I+1|0:I,i^=o,!((0|(o=2147483647^(I^=o)))==(0|E)&(-1^i)>>>0<A>>>0|E>>>0>o>>>0)&&(I=I+E|0,N=A=A+i|0,Q=I=A>>>0<i>>>0?I+1|0:I,!I&A>>>0<536870913)))break g;I=Q>>>29|0,A=(536870911&Q)<<3|N>>>29}else{if((0|I)==(0|o)&f>>>0>y>>>0|I>>>0<o>>>0)break g;if(I=o+a|0,I=(A=E+f|0)>>>0<E>>>0?I+1|0:I,E=A,A=I,Q=(I=i>>31)+r|0,o=i,i=I,I=o+I|0,o=Q^i,i^=I=Q>>>0<i>>>0?I+1|0:I,I=Q=o+E|0,(i=!(0&(A=(0|(i^=2147483647))==(0|A)&(-1^o)>>>0<E>>>0|A>>>0>i>>>0)))&(0|(A=A?-1:I))<=536870912|(0|A)<536870912)break g;I=0,A=A>>>29|0}r=_g(r,t,A,I),s=_g(s,k,A,I),n=_g(n,R,A,I)}return D[g+8>>2]=r,D[g+4>>2]=s,D[g>>2]=n,void(d=C+96|0)}sQ(),U()}sQ(),U()}sQ(),U()}function iA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,k=F(0),s=0;A:{I:if(C){g:{C:switch(D[A+28>>2]-1|0){case 0:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=B[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 1:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 2:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=f[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 3:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((0|(Q=r[I>>1]))<0)break I;if(r[(i<<1)+C>>1]=Q,I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if(o=1,(0|g)>(0|Q))break g;break I;case 4:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((Q=D[I>>2])-32768>>>0<4294901760)break A;if(r[(i<<1)+C>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 5:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((Q=D[I>>2])>>>0>32767)break A;if(r[(i<<1)+C>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 6:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(-1==(0|(Q=D[I+4>>2]-((a=D[I>>2])>>>0<32768)|0))&a-32768>>>0<4294901760|-1!=(0|Q))break A;if(r[(i<<1)+C>>1]=a,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 7:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(!(Q=D[I+4>>2])&(a=D[I>>2])>>>0>32767|Q)break A;if(r[(i<<1)+C>>1]=a,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 8:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<1)+C|0,Q=F(n(k=t[I>>2]))<F(2147483648)?~~k:-2147483648,r[a>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 9:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<1)+C|0,Q=n(s=N[I>>3])<2147483648?~~s:-2147483648,r[a>>1]=Q,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 10:break C;default:break I}if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break I}bI((Q<<1)+C|0,0,g-Q<<1)}return o}return 0}function oA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,k=F(0),s=0;A:{I:if(C){g:{C:switch(D[A+28>>2]-1|0){case 0:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((0|(Q=B[0|I]))<0)break I;if(r[(i<<1)+C>>1]=255&Q,I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if(o=1,(0|g)>(0|Q))break g;break I;case 1:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 2:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((0|(Q=r[I>>1]))<0)break I;if(r[(i<<1)+C>>1]=Q,I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if(o=1,(0|g)>(0|Q))break g;break I;case 3:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=f[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 4:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((Q=D[I>>2])>>>0>65535)break A;if(r[(i<<1)+C>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 5:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((Q=D[I>>2])>>>0>65535)break A;if(r[(i<<1)+C>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 6:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(!(Q=D[I+4>>2])&(a=D[I>>2])>>>0>65535|Q)break A;if(r[(i<<1)+C>>1]=a,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 7:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(!(Q=D[I+4>>2])&(a=D[I>>2])>>>0>65535|Q)break A;if(r[(i<<1)+C>>1]=a,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 8:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<1)+C|0,Q=(k=t[I>>2])<F(4294967296)&k>=F(0)?~~k>>>0:0,r[a>>1]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 9:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(a=(i<<1)+C|0)>>1]=Q=(s=N[I>>3])<4294967296&s>=0?~~s>>>0:0,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 10:break C;default:break I}if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(r[(i<<1)+C>>1]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break I}bI((Q<<1)+C|0,0,g-Q<<1)}return o}return 0}function aA(A,I,g){var C,Q=0,E=0,i=0,o=0,a=0;d=C=d-48|0,Q=f[6693]|f[6694]<<16,r[C+38>>1]=E=f[6691]|f[6692]<<16,r[C+40>>1]=E>>>16,r[C+42>>1]=Q,r[C+44>>1]=Q>>>16,Q=D[3345],D[C+32>>2]=D[3344],D[C+36>>2]=Q,Q=D[3343],D[C+24>>2]=D[3342],D[C+28>>2]=Q,Q=D[3341],D[C+16>>2]=D[3340],D[C+20>>2]=Q,Q=D[I+20>>2];A:{I:if((o=(i=D[I+16>>2])+5|0)>>>0>k[I+8>>2]&(0|(Q=o>>>0<5?Q+1|0:Q))>=(0|(E=D[I+12>>2]))|(0|Q)>(0|E)){if((I=bg(C+16|0))>>>0>=4294967280)break A;g:{if(I>>>0>=11)g=DC(Q=I+16&-16),D[C+8>>2]=-2147483648|Q,D[C>>2]=g,D[C+4>>2]=I;else if(B[C+11|0]=I,g=C,!I)break g;xA(g,C+16|0,I)}if(B[I+g|0]=0,D[A>>2]=-2,A=A+4|0,B[C+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}Lg(I=A,A=D[C>>2],D[C+4>>2]),sA(A)}else if(B[0|g]=E=e[0|(Q=i+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,B[g+1|0]=E>>>8,B[g+2|0]=E>>>16,B[g+3|0]=E>>>24,B[g+4|0]=e[Q+4|0],Q=D[I+20>>2],Q=(E=D[I+16>>2]+5|0)>>>0<5?Q+1|0:Q,D[I+16>>2]=E,D[I+20>>2]=Q,cg(g,1404,5))I=DC(32),B[I+16|0]=e[1640],g=e[1636]|e[1637]<<8|e[1638]<<16|e[1639]<<24,B[I+8|0]=Q=e[1632]|e[1633]<<8|e[1634]<<16|e[1635]<<24,B[I+9|0]=Q>>>8,B[I+10|0]=Q>>>16,B[I+11|0]=Q>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1628]|e[1629]<<8|e[1630]<<16|e[1631]<<24,B[0|I]=Q=e[1624]|e[1625]<<8|e[1626]<<16|e[1627]<<24,B[I+1|0]=Q>>>8,B[I+2|0]=Q>>>16,B[I+3|0]=Q>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+17|0]=0,D[A>>2]=-1,Lg(A+4|0,I,17),sA(I);else if((0|(i=D[I+12>>2]))<=(0|Q)&k[I+8>>2]<=E>>>0|(0|Q)>(0|i)){if((I=bg(C+16|0))>>>0>=4294967280)break A;g:{if(I>>>0>=11)g=DC(Q=I+16&-16),D[C+8>>2]=-2147483648|Q,D[C>>2]=g,D[C+4>>2]=I;else if(B[C+11|0]=I,g=C,!I)break g;xA(g,C+16|0,I)}if(B[I+g|0]=0,D[A>>2]=-2,A=A+4|0,B[C+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}Lg(I=A,A=D[C>>2],D[C+4>>2]),sA(A)}else if(B[g+5|0]=e[E+D[I>>2]|0],Q=D[I+20>>2],Q=(E=D[I+16>>2]+1|0)?Q:Q+1|0,D[I+16>>2]=E,D[I+20>>2]=Q,(0|(i=D[I+12>>2]))<=(0|Q)&k[I+8>>2]<=E>>>0|(0|Q)>(0|i)){if((I=bg(C+16|0))>>>0>=4294967280)break A;g:{if(I>>>0>=11)g=DC(Q=I+16&-16),D[C+8>>2]=-2147483648|Q,D[C>>2]=g,D[C+4>>2]=I;else if(B[C+11|0]=I,g=C,!I)break g;xA(g,C+16|0,I)}if(B[I+g|0]=0,D[A>>2]=-2,A=A+4|0,B[C+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}Lg(I=A,A=D[C>>2],D[C+4>>2]),sA(A)}else if(B[g+6|0]=e[E+D[I>>2]|0],Q=D[I+20>>2],Q=(E=D[I+16>>2]+1|0)?Q:Q+1|0,D[I+16>>2]=E,D[I+20>>2]=Q,(0|(i=D[I+12>>2]))<=(0|Q)&k[I+8>>2]<=E>>>0|(0|Q)>(0|i)){if((I=bg(C+16|0))>>>0>=4294967280)break A;g:{if(I>>>0>=11)g=DC(Q=I+16&-16),D[C+8>>2]=-2147483648|Q,D[C>>2]=g,D[C+4>>2]=I;else if(B[C+11|0]=I,g=C,!I)break g;xA(g,C+16|0,I)}if(B[I+g|0]=0,D[A>>2]=-2,A=A+4|0,B[C+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}Lg(I=A,A=D[C>>2],D[C+4>>2]),sA(A)}else if(B[g+7|0]=e[E+D[I>>2]|0],Q=D[I+20>>2],Q=(E=D[I+16>>2]+1|0)?Q:Q+1|0,D[I+16>>2]=E,D[I+20>>2]=Q,(0|(i=D[I+12>>2]))<=(0|Q)&k[I+8>>2]<=E>>>0|(0|Q)>(0|i)){if(I=Vg(C,C+16|0),D[A>>2]=-2,A=A+4|0,B[I+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}if(Lg(A,D[I>>2],D[I+4>>2]),B[I+11|0]>=0)break I;sA(D[I>>2])}else if(B[g+8|0]=e[E+D[I>>2]|0],E=Q=D[I+20>>2],Q=(i=(a=D[I+16>>2])+1|0)?Q:Q+1|0,D[I+16>>2]=i,D[I+20>>2]=Q,Q=E,(E=a+3|0)>>>0>k[I+8>>2]&(0|(Q=E>>>0<3?Q+1|0:Q))>=(0|(o=D[I+12>>2]))|(0|Q)>(0|o)){if(I=Vg(C,C+16|0),D[A>>2]=-2,A=A+4|0,B[I+11|0]>=0){I=D[C+4>>2],D[A>>2]=D[C>>2],D[A+4>>2]=I,D[A+8>>2]=D[C+8>>2];break I}if(Lg(A,D[I>>2],D[I+4>>2]),B[I+11|0]>=0)break I;sA(D[I>>2])}else r[(E=g)+10>>1]=e[0|(g=i+D[I>>2]|0)]|e[g+1|0]<<8,Q=D[I+20>>2],Q=(g=D[I+16>>2]+2|0)>>>0<2?Q+1|0:Q,D[I+16>>2]=g,D[I+20>>2]=Q,D[A+8>>2]=0,D[A+12>>2]=0,D[A>>2]=0,D[A+4>>2]=0;return void(d=C+48|0)}aQ(),U()}function rA(A,I,g){var C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;d=C=d+-64|0,D[C+48>>2]=0,D[C+40>>2]=0,D[C+44>>2]=0,D[C+32>>2]=0,D[C+36>>2]=0,D[C+24>>2]=0,D[C+28>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,D[C>>2]=0,D[C+4>>2]=0;A:{I:if(I=f[(B=I)+38>>1]){if(I>>>0<=511){if(I=D[B+20>>2],(E=(i=D[B+16>>2])+4|0)>>>0>k[B+8>>2]&(0|(I=E>>>0<4?I+1|0:I))>=(0|(Q=D[B+12>>2]))|(0|I)>(0|Q))break I;D[C+12>>2]=a=e[0|(I=i+D[B>>2]|0)]|e[I+1|0]<<8|e[I+2|0]<<16|e[I+3|0]<<24,Q=D[B+20>>2],Q=(I=D[B+16>>2]+4|0)>>>0<4?Q+1|0:Q,D[B+16>>2]=I,D[B+20>>2]=Q}else{if(!Fg(1,C+12|0,B))break I;a=D[C+12>>2]}if((I=D[C+4>>2]-(Q=D[C>>2])>>2)>>>0<a>>>0?($I(C,a-I|0),a=D[C+12>>2]):I>>>0<=a>>>0||(D[C+4>>2]=Q+(a<<2)),Q=1,!a)break A;for(N=D[B+8>>2],t=D[B+12>>2],R=D[C>>2],i=0;;){if(Q=0,(0|t)<=(0|(I=D[B+20>>2]))&N>>>0<=(E=D[B+16>>2])>>>0|(0|I)>(0|t))break A;F=e[(n=D[B>>2])+E|0],Q=I,Q=(I=E+1|0)?Q:Q+1|0,E=I,D[B+16>>2]=I,D[B+20>>2]=Q,I=F>>>2|0,o=0;g:{C:{Q:{B:switch(0|(y=3&F)){case 0:break C;case 3:break B;default:break Q}if(Q=0,(I=I+i|0)>>>0>=a>>>0)break A;bI(R+(i<<2)|0,0,4+(252&F)|0),i=I;break g}for(;;){if((0|Q)>=(0|t)&E>>>0>=N>>>0|(0|Q)>(0|t))break I;if(a=e[E+n|0],Q=(E=E+1|0)?Q:Q+1|0,D[B+16>>2]=E,D[B+20>>2]=Q,I|=a<<(o<<3|6),(0|y)==(0|(o=o+1|0)))break}}D[R+(i<<2)>>2]=I}if(!((i=i+1|0)>>>0<(a=D[C+12>>2])>>>0))break}if(t=C+16|0,R=D[C>>2],(i=(Q=D[C+20>>2]-(I=D[C+16>>2])|0)>>2)>>>0<=1048575?$I(t,1048576-i|0):4194304!=(0|Q)&&(D[C+20>>2]=I+4194304),(Q=D[C+32>>2]-(i=D[(I=C+28|0)>>2])>>3)>>>0<a>>>0)Ag(I,a-Q|0),i=D[I>>2];else if(Q>>>0>a>>>0&&(D[C+32>>2]=(a<<3)+i),!a)break I;for(o=0,Q=0;;){if(F=D[(E=(o<<2)+R|0)>>2],D[4+(N=(o<<3)+i|0)>>2]=I=Q,D[N>>2]=F,(Q=(E=D[E>>2])+I|0)>>>0>1048576)break I;if(!(I>>>0>=Q>>>0)){if(F=D[t>>2],N=0,n=7&E)for(;D[F+(I<<2)>>2]=o,I=I+1|0,(0|n)!=(0|(N=N+1|0)););if(!(E-1>>>0<=6))for(;D[(E=F+(I<<2)|0)>>2]=o,D[E+28>>2]=o,D[E+24>>2]=o,D[E+20>>2]=o,D[E+16>>2]=o,D[E+12>>2]=o,D[E+8>>2]=o,D[E+4>>2]=o,(0|Q)!=(0|(I=I+8|0)););}if((0|a)==(0|(o=o+1|0)))break}r=1048576==(0|Q)}Q=r}A:if(!(!Q|(D[C+12>>2]?0:A))){if(f[B+38>>1]<=511){if(o=I=D[B+12>>2],Q=D[B+20>>2],(i=D[B+8>>2])>>>0<(E=(r=D[B+16>>2])+8|0)>>>0&(0|I)<=(0|(Q=E>>>0<8?Q+1|0:Q))|(0|I)<(0|Q))break A;I=e[0|(r=r+D[B>>2]|0)]|e[r+1|0]<<8|e[r+2|0]<<16|e[r+3|0]<<24,r=e[r+4|0]|e[r+5|0]<<8|e[r+6|0]<<16|e[r+7|0]<<24,D[B+16>>2]=E,D[B+20>>2]=Q}else{if(!ag(1,C+56|0,B))break A;E=D[B+16>>2],Q=D[B+20>>2],i=D[B+8>>2],o=D[B+12>>2],I=D[C+56>>2],r=D[C+60>>2]}if(a=i-E|0,!((0|(i=o-(Q+(E>>>0>i>>>0)|0)|0))==(0|r)&I>>>0>a>>>0|i>>>0<r>>>0||(Q=Q+r|0,Q=(i=I+E|0)>>>0<I>>>0?Q+1|0:Q,D[B+16>>2]=i,D[B+20>>2]=Q,Q=I,(0|I)<=0))){D[C+40>>2]=E=E+D[B>>2]|0;I:if((i=e[0|(B=E+(I=Q-1|0)|0)])>>>0<=63)D[C+44>>2]=I,Q=63&e[0|B];else{g:switch((i>>>6|0)-1|0){case 0:if(Q>>>0<2)break A;D[C+44>>2]=I=Q-2|0,Q=e[1+(B=(Q+E|0)-2|0)|0]<<8&16128|e[0|B];break I;case 1:if(Q>>>0<3)break A;D[C+44>>2]=I=Q-3|0,Q=e[2+(B=(Q+E|0)-3|0)|0]<<16&4128768|e[B+1|0]<<8|e[0|B];break I}D[C+44>>2]=I=Q-4|0,Q=e[2+(B=(Q+E|0)-4|0)|0]<<16|e[B+3|0]<<24&1056964608|e[B+1|0]<<8|e[0|B]}if(D[C+48>>2]=B=Q+4194304|0,!(B>>>0>1073741823))if(A)for(Q=D[C+28>>2],i=0,r=D[C+16>>2];;){I:if(!(B>>>0>4194303))for(;;){if((0|I)<=0)break I;if(D[C+44>>2]=I=I-1|0,D[C+48>>2]=B=e[I+E|0]|B<<8,!(B>>>0<4194304))break}if(B=(s(D[(t=Q+((a=D[r+((o=1048575&B)<<2)>>2])<<3)|0)>>2],B>>>20|0)+o|0)-D[t+4>>2]|0,D[C+48>>2]=B,D[(i<<2)+g>>2]=a,G=1,(0|(i=i+1|0))==(0|A))break}else G=1}}return(A=D[C+28>>2])&&(D[C+32>>2]=A,sA(A)),(A=D[C+16>>2])&&(D[C+20>>2]=A,sA(A)),(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),d=C- -64|0,G}function DA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,k=F(0),s=0;A:{I:if(C){g:{C:switch(D[A+28>>2]-1|0){case 0:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=B[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 1:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 2:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=r[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 3:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=f[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 4:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=D[I>>2],I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 5:if((0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if((0|(Q=D[I>>2]))<0)break I;if(D[(i<<2)+C>>2]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if(o=1,(0|g)>(0|Q))break g;break I;case 6:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(-1!=(D[I+4>>2]-((Q=D[I>>2])>>>0<2147483648)|0))break A;if(D[(i<<2)+C>>2]=Q,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 7:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(!(Q=D[I+4>>2])&(a=D[I>>2])>>>0>2147483647|Q)break A;if(D[(i<<2)+C>>2]=a,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 8:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<2)+C|0,Q=F(n(k=t[I>>2]))<F(2147483648)?~~k:-2147483648,D[a>>2]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 9:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<2)+C|0,Q=n(s=N[I>>3])<2147483648?~~s:-2147483648,D[a>>2]=Q,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 10:break C;default:break I}if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break I}bI((Q<<2)+C|0,0,g-Q<<2)}return o}return 0}function eA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,k=F(0),s=0;A:{I:if(C){g:{C:switch(D[A+28>>2]-1|0){case 0:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=B[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 1:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 2:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=r[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 3:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=f[I>>1],I=I+2|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 4:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=D[I>>2],I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 5:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=D[I>>2],I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 6:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(Q=D[I>>2],D[I+4>>2])break A;if(D[(i<<2)+C>>2]=Q,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 7:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(Q=D[I>>2],D[I+4>>2])break A;if(D[(i<<2)+C>>2]=Q,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 8:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(a=(i<<2)+C|0,Q=(k=t[I>>2])<F(4294967296)&k>=F(0)?~~k>>>0:0,D[a>>2]=Q,I=I+4|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 9:if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(a=(i<<2)+C|0)>>2]=Q=(s=N[I>>3])<4294967296&s>=0?~~s>>>0:0,I=I+8|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)>(0|Q))break g;break I;case 10:break C;default:break I}if(o=1,(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))>0)for(I=(E=D[(Q=D[A>>2])>>2])+(I=D[A+48>>2]+mg(D[A+40>>2],D[A+44>>2],I,0)|0)|0,E=D[Q+4>>2];;){if(I>>>0>=E>>>0)break A;if(D[(i<<2)+C>>2]=e[0|I],I=I+1|0,!((0|(i=i+1|0))<(0|((0|g)<(0|(Q=B[A+24|0]))?g:Q))))break}if((0|g)<=(0|Q))break I}bI((Q<<2)+C|0,0,g-Q<<2)}return o}return 0}function fA(A,I,g,C){var Q,E=0,i=0,o=0,a=0,r=0,f=0;if(d=Q=d-80|0,E=D[g+36>>2],D[Q+72>>2]=D[g+32>>2],D[Q+76>>2]=E,i=D[g+28>>2],D[(E=Q- -64|0)>>2]=D[g+24>>2],D[E+4>>2]=i,E=D[g+20>>2],D[Q+56>>2]=D[g+16>>2],D[Q+60>>2]=E,E=D[g+12>>2],D[Q+48>>2]=D[g+8>>2],D[Q+52>>2]=E,E=D[g+4>>2],D[Q+40>>2]=D[g>>2],D[Q+44>>2]=E,aA(A,Q+40|0,Q+24|0),!D[A>>2])if(r=A+4|0,B[A+15|0]<0&&sA(D[r>>2]),e[Q+31|0])I=DC(32),B[I+23|0]=g=e[1665]|e[1666]<<8|e[1667]<<16|e[1668]<<24,B[I+24|0]=g>>>8,B[I+25|0]=g>>>16,B[I+26|0]=g>>>24,g=e[1662]|e[1663]<<8|e[1664]<<16|e[1665]<<24,B[I+16|0]=C=e[1658]|e[1659]<<8|e[1660]<<16|e[1661]<<24,B[I+17|0]=C>>>8,B[I+18|0]=C>>>16,B[I+19|0]=C>>>24,B[I+20|0]=g,B[I+21|0]=g>>>8,B[I+22|0]=g>>>16,B[I+23|0]=g>>>24,g=e[1654]|e[1655]<<8|e[1656]<<16|e[1657]<<24,B[I+8|0]=C=e[1650]|e[1651]<<8|e[1652]<<16|e[1653]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1646]|e[1647]<<8|e[1648]<<16|e[1649]<<24,B[0|I]=C=e[1642]|e[1643]<<8|e[1644]<<16|e[1645]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+27|0]=0,D[A>>2]=-1,Lg(r,I,27),sA(I);else{d=a=d-16|0;A:{I:switch(B[Q+32|0]){case 0:E=DC(44),D[E>>2]=0,D[E+4>>2]=0,D[E+40>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,i=IC(E),D[E>>2]=13528,D[Q+8>>2]=0,D[Q+12>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+16>>2]=i;break A;case 1:E=DC(44),D[E>>2]=0,D[E+4>>2]=0,D[E+40>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,i=IC(E),D[E>>2]=13436,D[Q+8>>2]=0,D[Q+12>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+16>>2]=i;break A}i=DC(32),B[i+24|0]=E=e[1694]|e[1695]<<8|e[1696]<<16|e[1697]<<24,B[i+25|0]=E>>>8,B[i+26|0]=E>>>16,B[i+27|0]=E>>>24,E=e[1690]|e[1691]<<8|e[1692]<<16|e[1693]<<24,B[i+16|0]=o=e[1686]|e[1687]<<8|e[1688]<<16|e[1689]<<24,B[i+17|0]=o>>>8,B[i+18|0]=o>>>16,B[i+19|0]=o>>>24,B[i+20|0]=E,B[i+21|0]=E>>>8,B[i+22|0]=E>>>16,B[i+23|0]=E>>>24,E=e[1682]|e[1683]<<8|e[1684]<<16|e[1685]<<24,B[i+8|0]=o=e[1678]|e[1679]<<8|e[1680]<<16|e[1681]<<24,B[i+9|0]=o>>>8,B[i+10|0]=o>>>16,B[i+11|0]=o>>>24,B[i+12|0]=E,B[i+13|0]=E>>>8,B[i+14|0]=E>>>16,B[i+15|0]=E>>>24,E=e[1674]|e[1675]<<8|e[1676]<<16|e[1677]<<24,B[0|i]=o=e[1670]|e[1671]<<8|e[1672]<<16|e[1673]<<24,B[i+1|0]=o>>>8,B[i+2|0]=o>>>16,B[i+3|0]=o>>>24,B[i+4|0]=E,B[i+5|0]=E>>>8,B[i+6|0]=E>>>16,B[i+7|0]=E>>>24,B[i+28|0]=0,D[a>>2]=-1,Lg(E=4|a,i,28),f=B[a+15|0],D[Q>>2]=D[a>>2],o=Q+4|0,(0|f)>=0?(f=D[E+4>>2],D[o>>2]=D[E>>2],D[o+4>>2]=f,D[o+8>>2]=D[E+8>>2]):Lg(o,D[a+4>>2],D[a+8>>2]),D[Q+16>>2]=0,B[a+15|0]<0&&sA(D[a+4>>2]),sA(i)}d=a+16|0;A:if(E=D[Q>>2]){if(D[A>>2]=E,B[Q+15|0]>=0){I=D[4+(A=4|Q)>>2],D[r>>2]=D[A>>2],D[r+4>>2]=I,D[r+8>>2]=D[A+8>>2];break A}Lg(r,D[Q+4>>2],D[Q+8>>2])}else E=D[Q+16>>2],D[Q+16>>2]=0,V(A,E,I,g,C),D[A>>2]||(B[r+11|0]<0&&sA(D[r>>2]),D[A>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0),RQ[D[D[E>>2]+4>>2]](E);A=D[Q+16>>2],D[Q+16>>2]=0,A&&RQ[D[D[A>>2]+4>>2]](A),B[Q+15|0]>=0||sA(D[Q+4>>2])}d=Q+80|0}function kA(A,I){var g=0,C=0,Q=0,E=0,i=0,o=0;if((E=((g=D[A+4>>2])-(C=D[A>>2])|0)/144|0)>>>0<I>>>0)if(C=A,(i=I-E|0)>>>0<=((g=D[A+8>>2])-(A=D[A+4>>2])|0)/144>>>0){if(i){for(I=s(i,144)+A|0;D[A>>2]=-1,fg(A+4|0),D[A+104>>2]=0,D[A+108>>2]=0,B[A+100|0]=1,D[A+112>>2]=0,D[A+116>>2]=0,D[A+120>>2]=0,D[A+124>>2]=0,D[A+128>>2]=0,D[A+132>>2]=0,D[A+136>>2]=0,D[A+140>>2]=0,(0|I)!=(0|(A=A+144|0)););A=I}D[C+4>>2]=A}else{A:{I:{g:{if((o=(E=((I=A)-(A=D[C>>2])|0)/144|0)+i|0)>>>0<29826162){if(A=(I=(g-A|0)/144|0)<<1,Q=I>>>0<14913080?A>>>0<o>>>0?o:A:29826161){if(Q>>>0>=29826162)break g;g=DC(s(Q,144))}else g=0;for(o=(I=g+s(E,144)|0)+s(i,144)|0,A=I;D[A>>2]=-1,fg(A+4|0),D[A+104>>2]=0,D[A+108>>2]=0,B[A+100|0]=1,D[A+112>>2]=0,D[A+116>>2]=0,D[A+120>>2]=0,D[A+124>>2]=0,D[A+128>>2]=0,D[A+132>>2]=0,D[A+136>>2]=0,D[A+140>>2]=0,(0|o)!=(0|(A=A+144|0)););if(E=g+s(Q,144)|0,(0|(A=D[C+4>>2]))==(0|(Q=D[C>>2])))break I;for(;D[(I=I-144|0)>>2]=D[(A=A-144|0)>>2],D[I+4>>2]=D[A+4>>2],D[I+8>>2]=D[A+8>>2],D[I+12>>2]=D[A+12>>2],D[A+12>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[I+16>>2]=D[A+16>>2],D[I+20>>2]=D[A+20>>2],D[I+24>>2]=D[A+24>>2],D[A+24>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,g=e[A+28|0],D[I+40>>2]=0,D[I+32>>2]=0,D[I+36>>2]=0,B[I+28|0]=g,D[I+32>>2]=D[A+32>>2],D[I+36>>2]=D[A+36>>2],D[I+40>>2]=D[A+40>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[I+52>>2]=0,D[I+44>>2]=0,D[I+48>>2]=0,D[I+44>>2]=D[A+44>>2],D[I+48>>2]=D[A+48>>2],D[I+52>>2]=D[A+52>>2],D[A+52>>2]=0,D[A+44>>2]=0,D[A+48>>2]=0,D[(g=I- -64|0)>>2]=0,D[I+56>>2]=0,D[I+60>>2]=0,D[I+56>>2]=D[A+56>>2],D[I+60>>2]=D[A+60>>2],D[(i=g)>>2]=D[(g=A- -64|0)>>2],D[g>>2]=0,D[A+56>>2]=0,D[A+60>>2]=0,D[I+68>>2]=D[A+68>>2],g=D[A+72>>2],D[I+84>>2]=0,D[I+76>>2]=0,D[I+80>>2]=0,D[I+72>>2]=g,D[I+76>>2]=D[A+76>>2],D[I+80>>2]=D[A+80>>2],D[I+84>>2]=D[A+84>>2],D[A+84>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[I+96>>2]=0,D[I+88>>2]=0,D[I+92>>2]=0,D[I+88>>2]=D[A+88>>2],D[I+92>>2]=D[A+92>>2],D[I+96>>2]=D[A+96>>2],D[A+96>>2]=0,D[A+88>>2]=0,D[A+92>>2]=0,g=e[A+100|0],D[I+112>>2]=0,D[I+104>>2]=0,D[I+108>>2]=0,B[I+100|0]=g,D[I+104>>2]=D[A+104>>2],D[I+108>>2]=D[A+108>>2],D[I+112>>2]=D[A+112>>2],D[A+112>>2]=0,D[A+104>>2]=0,D[A+108>>2]=0,D[I+124>>2]=0,D[I+116>>2]=0,D[I+120>>2]=0,D[I+116>>2]=D[A+116>>2],D[I+120>>2]=D[A+120>>2],D[I+124>>2]=D[A+124>>2],D[A+124>>2]=0,D[A+116>>2]=0,D[A+120>>2]=0,g=D[A+128>>2],D[I+140>>2]=0,D[I+132>>2]=0,D[I+136>>2]=0,D[I+128>>2]=g,D[I+132>>2]=D[A+132>>2],D[I+136>>2]=D[A+136>>2],D[I+140>>2]=D[A+140>>2],D[A+140>>2]=0,D[A+132>>2]=0,D[A+136>>2]=0,(0|A)!=(0|Q););if(D[C+8>>2]=E,A=D[C+4>>2],D[C+4>>2]=o,Q=D[C>>2],D[C>>2]=I,(0|A)==(0|Q))break A;for(;(I=D[A-12>>2])&&(D[A-8>>2]=I,sA(I)),(I=D[A-28>>2])&&(D[A-24>>2]=I,sA(I)),(I=D[A-40>>2])&&(D[A-36>>2]=I,sA(I)),Mg(A-140|0),(0|Q)!=(0|(A=A-144|0)););break A}iQ(),U()}xg(1336),U()}D[C+8>>2]=E,D[C+4>>2]=o,D[C>>2]=I}Q&&sA(Q)}else if(I>>>0<E>>>0){if((0|(C=C+s(I,144)|0))!=(0|g))for(;(I=D[g-12>>2])&&(D[g-8>>2]=I,sA(I)),(I=D[g-28>>2])&&(D[g-24>>2]=I,sA(I)),(I=D[g-40>>2])&&(D[g-36>>2]=I,sA(I)),Mg(g-140|0),(0|C)!=(0|(g=g-144|0)););D[A+4>>2]=C}}function tA(A,I,g){I|=0,g|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0;if(d=C=d-96|0,Q=D[16+(A|=0)>>2],B[C+92|0]=1,D[C+88>>2]=I,D[C+84>>2]=I,D[C+80>>2]=Q,-1!=(0|I)&&!((Q=D[D[Q>>2]+(I<<2)>>2])>>>0>=D[(t=D[A+20>>2])+4>>2]-(E=D[t>>2])>>2>>>0)){Q=D[D[A+8>>2]+(D[E+(Q<<2)>>2]<<2)>>2],e[(E=D[A+4>>2])+84|0]||(Q=D[D[E+68>>2]+(Q<<2)>>2]),D[C+72>>2]=0,D[C+76>>2]=0,D[(t=C- -64|0)>>2]=0,D[t+4>>2]=0,D[C+56>>2]=0,D[C+60>>2]=0,BA(E,Q,B[E+24|0],C+56|0),t=((Q=I+1|0)>>>0)%3|0?Q:I-2|0,o=((I>>>0)%3|0?-1:2)+I|0;A:{I:{for(;;){if(E=t,Q=o,D[A+28>>2]&&(E=((Q=I+1|0)>>>0)%3|0?Q:I-2|0,Q=I-1|0,(I>>>0)%3|0||(Q=I+2|0)),-1==(0|E))break A;if((E=D[D[D[A+16>>2]>>2]+(E<<2)>>2])>>>0>=D[(f=D[A+20>>2])+4>>2]-(I=D[f>>2])>>2>>>0)break A;if(E=D[D[A+8>>2]+(D[(E<<2)+I>>2]<<2)>>2],e[(I=D[A+4>>2])+84|0]||(E=D[D[I+68>>2]+(E<<2)>>2]),D[C+48>>2]=0,D[C+52>>2]=0,D[C+40>>2]=0,D[C+44>>2]=0,D[C+32>>2]=0,D[C+36>>2]=0,BA(I,E,B[I+24|0],C+32|0),-1==(0|Q))break I;if((Q=D[D[D[A+16>>2]>>2]+(Q<<2)>>2])>>>0>=D[(E=D[A+20>>2])+4>>2]-(I=D[E>>2])>>2>>>0)break I;if(E=D[D[A+8>>2]+(D[I+(Q<<2)>>2]<<2)>>2],e[(I=D[A+4>>2])+84|0]||(E=D[D[I+68>>2]+(E<<2)>>2]),D[C+24>>2]=0,D[C+28>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,BA(I,E,B[I+24|0],C+8|0),c=mg(E=(Q=D[C+8>>2])-(I=D[C+56>>2])|0,N=D[C+12>>2]-((f=D[C+60>>2])+(I>>>0>Q>>>0)|0)|0,y=(a=D[C+40>>2])-(Q=D[C+64>>2])|0,a=D[C+44>>2]-((G=D[C+68>>2])+(Q>>>0>a>>>0)|0)|0),i=i-(u+(r>>>0<c>>>0)|0)|0,b=w=r-c|0,Q=mg(c=(r=D[C+16>>2])-Q|0,G=D[C+20>>2]-((Q>>>0>r>>>0)+G|0)|0,w=(r=D[C+32>>2])-I|0,f=D[C+36>>2]-((I>>>0>r>>>0)+f|0)|0),I=u+i|0,i=I=Q>>>0>(r=b+Q|0)>>>0?I+1|0:I,b=s,F=mg(E,F=N,N=(I=D[C+48>>2])-(Q=D[C+72>>2])|0,h=D[C+52>>2]-((s=D[C+76>>2])+(I>>>0<Q>>>0)|0)|0),I=u+k|0,I=(E=b+F|0)>>>0<F>>>0?I+1|0:I,s=E-(k=mg(F=(k=D[C+24>>2])-Q|0,Q=D[C+28>>2]-((Q>>>0>k>>>0)+s|0)|0,w,f))|0,k=I-(u+(E>>>0<k>>>0)|0)|0,E=n-(I=mg(c,G,N,h))|0,I=R-(u+(I>>>0>n>>>0)|0)|0,R=mg(F,Q,y,a),I=u+I|0,R=I=(n=R+E|0)>>>0<R>>>0?I+1|0:I,FI(C+80|0),-1==(0|(I=D[C+88>>2])))break}E=(I=R>>31)+n|0,Q=I,I=I+R|0,f=E^Q,o=Q^(E>>>0<Q>>>0?I+1|0:I),N=-1,E=2147483647,a=I=k>>31,Q=I+s|0,I=I+k|0,I=Q>>>0<a>>>0?I+1|0:I,Q^=a,a=I^=a,y=-1^Q,I^=2147483647,t=i;g:{if(D[A+28>>2]){if(!((0|I)==(0|o)&f>>>0>y>>>0|I>>>0<o>>>0)&&(I=o+a|0,Q=I=(A=Q+f|0)>>>0<Q>>>0?I+1|0:I,o=i,i=(I=i>>31)+r|0,a=o,o=I,I=a+I|0,I=i>>>0<o>>>0?I+1|0:I,i^=o,!((0|(o=2147483647^(I^=o)))==(0|Q)&(-1^i)>>>0<A>>>0|Q>>>0>o>>>0)&&(I=I+Q|0,N=A=A+i|0,E=I=A>>>0<i>>>0?I+1|0:I,!I&A>>>0<536870913)))break g;I=E>>>29|0,A=(536870911&E)<<3|N>>>29}else{if((0|I)==(0|o)&f>>>0>y>>>0|I>>>0<o>>>0)break g;if(I=o+a|0,I=(A=Q+f|0)>>>0<Q>>>0?I+1|0:I,Q=A,A=I,E=(I=i>>31)+r|0,o=i,i=I,I=o+I|0,o=E^i,i^=I=E>>>0<i>>>0?I+1|0:I,I=E=o+Q|0,(i=!(0&(A=(0|(i^=2147483647))==(0|A)&(-1^o)>>>0<Q>>>0|A>>>0>i>>>0)))&(0|(A=A?-1:I))<=536870912|(0|A)<536870912)break g;I=0,A=A>>>29|0}r=_g(r,t,A,I),s=_g(s,k,A,I),n=_g(n,R,A,I)}return D[g+8>>2]=r,D[g+4>>2]=s,D[g>>2]=n,void(d=C+96|0)}sQ(),U()}sQ(),U()}sQ(),U()}function NA(A,I){A|=0;var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0;if(!((0|(I|=0))<0||(C=D[A+12>>2])-(g=D[A+8>>2])>>2>>>0<=I>>>0)){o=D[(B=D[(Q=g+(I<<2)|0)>>2])+60>>2],E=D[B+56>>2];A:{if((0|(g=Q+4|0))!=(0|C)){for(;i=D[g>>2],D[g>>2]=0,D[Q>>2]=i,B&&Wg(B),Q=Q+4|0,(0|(g=g+4|0))!=(0|C);)B=D[Q>>2];if((0|Q)==(0|(C=D[A+12>>2])))break A}for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&Wg(g),(0|C)!=(0|Q););}D[A+12>>2]=Q;A:if(!(!(B=D[A+4>>2])|(0|o)<0)&&(0|(C=D[B+24>>2]))!=(0|(g=D[B+28>>2])))for(;;){if((0|o)==D[D[C>>2]+24>>2]){I:{if((0|(Q=C+4|0))!=(0|(o=D[B+28>>2]))){for(;i=D[Q>>2],D[Q>>2]=0,g=D[C>>2],D[C>>2]=i,g&&(AC(g+12|0,D[g+16>>2]),aC(g,D[g+4>>2]),sA(g)),C=C+4|0,(0|o)!=(0|(Q=Q+4|0)););if((0|(Q=D[B+28>>2]))==(0|C))break I}for(;g=D[(Q=Q-4|0)>>2],D[Q>>2]=0,g&&(AC(g+12|0,D[g+16>>2]),aC(g,D[g+4>>2]),sA(g)),(0|C)!=(0|Q););}D[B+28>>2]=C;break A}if((0|g)==(0|(C=C+4|0)))break}A:if(!((0|E)>4)){I:if(Q=s(E,12)+A|0,(0|(C=D[Q+20>>2]))!=(0|(g=D[Q+24>>2]))){for(;;){if(D[C>>2]==(0|I))break I;if((0|g)==(0|(C=C+4|0)))break}break A}(0|C)!=(0|g)&&((g=g-(B=C+4|0)|0)&&RI(C,B,g),D[Q+24>>2]=C+g)}if(C=D[A+24>>2]-(Q=D[A+20>>2])|0){if(o=1&(B=(g=C>>2)>>>0>1?g:1),C=0,g>>>0>=2)for(B&=-2,g=0;(0|(a=D[(i=(E=C<<2)+Q|0)>>2]))>(0|I)&&(D[i>>2]=a-1),(0|(i=D[(E=Q+(4|E)|0)>>2]))>(0|I)&&(D[E>>2]=i-1),C=C+2|0,(0|B)!=(0|(g=g+2|0)););o&&((0|(g=D[(C=Q+(C<<2)|0)>>2]))<=(0|I)||(D[C>>2]=g-1))}if(C=D[A+36>>2]-(Q=D[A+32>>2])|0){if(o=1&(B=(g=C>>2)>>>0>1?g:1),C=0,g>>>0>=2)for(B&=-2,g=0;(0|(a=D[(i=(E=C<<2)+Q|0)>>2]))>(0|I)&&(D[i>>2]=a-1),(0|(i=D[(E=Q+(4|E)|0)>>2]))>(0|I)&&(D[E>>2]=i-1),C=C+2|0,(0|B)!=(0|(g=g+2|0)););o&&((0|(g=D[(C=Q+(C<<2)|0)>>2]))<=(0|I)||(D[C>>2]=g-1))}if(C=D[A+48>>2]-(Q=D[A+44>>2])|0){if(o=1&(B=(g=C>>2)>>>0>1?g:1),C=0,g>>>0>=2)for(B&=-2,g=0;(0|(a=D[(i=(E=C<<2)+Q|0)>>2]))>(0|I)&&(D[i>>2]=a-1),(0|(i=D[(E=Q+(4|E)|0)>>2]))>(0|I)&&(D[E>>2]=i-1),C=C+2|0,(0|B)!=(0|(g=g+2|0)););o&&((0|(g=D[(C=Q+(C<<2)|0)>>2]))<=(0|I)||(D[C>>2]=g-1))}if(C=D[A+60>>2]-(Q=D[A+56>>2])|0){if(o=1&(B=(g=C>>2)>>>0>1?g:1),C=0,g>>>0>=2)for(B&=-2,g=0;(0|(a=D[(i=(E=C<<2)+Q|0)>>2]))>(0|I)&&(D[i>>2]=a-1),(0|(i=D[(E=Q+(4|E)|0)>>2]))>(0|I)&&(D[E>>2]=i-1),C=C+2|0,(0|B)!=(0|(g=g+2|0)););o&&((0|(g=D[(C=Q+(C<<2)|0)>>2]))<=(0|I)||(D[C>>2]=g-1))}if(C=(g=D[A+72>>2])-(A=D[A+68>>2])|0){if(B=1&(Q=(g=C>>2)>>>0>1?g:1),C=0,g>>>0>=2)for(Q&=-2,g=0;(0|(i=D[(E=(o=C<<2)+A|0)>>2]))>(0|I)&&(D[E>>2]=i-1),(0|(E=D[(o=A+(4|o)|0)>>2]))>(0|I)&&(D[o>>2]=E-1),C=C+2|0,(0|Q)!=(0|(g=g+2|0)););B&&((0|(g=I))>=(0|(I=D[(A=A+(C<<2)|0)>>2]))||(D[A>>2]=I-1))}}}function sA(A){var I=0,g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0;A:if(A|=0){B=(C=A-8|0)+(A=-8&(I=D[A-4>>2]))|0;I:if(!(1&I)){if(!(3&I))break A;if((C=C-(I=D[C>>2])|0)>>>0<k[3982])break A;if(A=A+I|0,D[3983]==(0|C)){if(3==(3&(I=D[B+4>>2])))return D[3980]=A,D[B+4>>2]=-2&I,D[C+4>>2]=1|A,void(D[A+C>>2]=A)}else{if(I>>>0<=255){if(I=I>>>3|0,(0|(g=D[C+12>>2]))==(0|(Q=D[C+8>>2]))){o=15912,a=D[3978]&JC(I),D[o>>2]=a;break I}D[Q+12>>2]=g,D[g+8>>2]=Q;break I}if(i=D[C+24>>2],(0|C)==(0|(I=D[C+12>>2])))if((g=D[(Q=C+20|0)>>2])||(g=D[(Q=C+16|0)>>2])){for(;E=Q,(g=D[(Q=(I=g)+20|0)>>2])||(Q=I+16|0,g=D[I+16>>2]););D[E>>2]=0}else I=0;else D[(g=D[C+8>>2])+12>>2]=I,D[I+8>>2]=g;if(!i)break I;g:{if(D[(g=16216+((Q=D[C+28>>2])<<2)|0)>>2]==(0|C)){if(D[g>>2]=I,I)break g;o=15916,a=D[3979]&JC(Q),D[o>>2]=a;break I}if(D[i+(D[i+16>>2]==(0|C)?16:20)>>2]=I,!I)break I}if(D[I+24>>2]=i,(g=D[C+16>>2])&&(D[I+16>>2]=g,D[g+24>>2]=I),!(g=D[C+20>>2]))break I;D[I+20>>2]=g,D[g+24>>2]=I}}if(!(C>>>0>=B>>>0)&&1&(I=D[B+4>>2])){I:{if(!(2&I)){if(D[3984]==(0|B)){if(D[3984]=C,D[3981]=A=D[3981]+A|0,D[C+4>>2]=1|A,D[3983]!=(0|C))break A;return D[3980]=0,void(D[3983]=0)}if(D[3983]==(0|B))return D[3983]=C,D[3980]=A=D[3980]+A|0,D[C+4>>2]=1|A,void(D[A+C>>2]=A);A=(-8&I)+A|0;g:if(I>>>0<=255){if(I=I>>>3|0,(0|(g=D[B+12>>2]))==(0|(Q=D[B+8>>2]))){o=15912,a=D[3978]&JC(I),D[o>>2]=a;break g}D[Q+12>>2]=g,D[g+8>>2]=Q}else{if(i=D[B+24>>2],(0|B)==(0|(I=D[B+12>>2])))if((g=D[(Q=B+20|0)>>2])||(g=D[(Q=B+16|0)>>2])){for(;E=Q,(g=D[(Q=(I=g)+20|0)>>2])||(Q=I+16|0,g=D[I+16>>2]););D[E>>2]=0}else I=0;else D[(g=D[B+8>>2])+12>>2]=I,D[I+8>>2]=g;if(i){C:{if(D[(g=16216+((Q=D[B+28>>2])<<2)|0)>>2]==(0|B)){if(D[g>>2]=I,I)break C;o=15916,a=D[3979]&JC(Q),D[o>>2]=a;break g}if(D[i+(D[i+16>>2]==(0|B)?16:20)>>2]=I,!I)break g}D[I+24>>2]=i,(g=D[B+16>>2])&&(D[I+16>>2]=g,D[g+24>>2]=I),(g=D[B+20>>2])&&(D[I+20>>2]=g,D[g+24>>2]=I)}}if(D[C+4>>2]=1|A,D[A+C>>2]=A,D[3983]!=(0|C))break I;return void(D[3980]=A)}D[B+4>>2]=-2&I,D[C+4>>2]=1|A,D[A+C>>2]=A}if(A>>>0<=255)return I=15952+((A=A>>>3|0)<<3)|0,(g=D[3978])&(A=1<<A)?A=D[I+8>>2]:(D[3978]=A|g,A=I),D[I+8>>2]=C,D[A+12>>2]=C,D[C+12>>2]=I,void(D[C+8>>2]=A);Q=31,D[C+16>>2]=0,D[C+20>>2]=0,A>>>0<=16777215&&(I=A>>>8|0,I<<=E=I+1048320>>>16&8,Q=28+((I=((I<<=Q=I+520192>>>16&4)<<(g=I+245760>>>16&2)>>>15|0)-(g|Q|E)|0)<<1|A>>>I+21&1)|0),D[C+28>>2]=Q,E=16216+(Q<<2)|0;I:{g:{if((g=D[3979])&(I=1<<Q)){for(Q=A<<(31==(0|Q)?0:25-(Q>>>1|0)|0),I=D[E>>2];;){if(g=I,(-8&D[I+4>>2])==(0|A))break g;if(I=Q>>>29|0,Q<<=1,!(I=D[16+(E=g+(4&I)|0)>>2]))break}D[E+16>>2]=C,D[C+24>>2]=g}else D[3979]=I|g,D[E>>2]=C,D[C+24>>2]=E;D[C+12>>2]=C,D[C+8>>2]=C;break I}D[(A=D[g+8>>2])+12>>2]=C,D[g+8>>2]=C,D[C+24>>2]=0,D[C+12>>2]=g,D[C+8>>2]=A}D[3986]=(A=D[3986]-1|0)||-1}}}function FA(A,I,g,C){var Q,E=0,i=0,o=0,a=0,r=0,e=F(0),f=0,N=0,s=F(0);Q=D[g>>2];A:{I:if(i=D[I+4>>2]){g:{if((o=bC(i))>>>0>=2){if((E=Q)>>>0>=i>>>0&&(E=(Q>>>0)%(i>>>0)|0),!(g=D[D[I>>2]+(E<<2)>>2]))break I;if(o>>>0<=1)break g;for(;;){if(!(g=D[g>>2]))break I;if((0|(o=D[g+4>>2]))!=(0|Q)&&(i>>>0<=o>>>0&&(o=(o>>>0)%(i>>>0)|0),(0|E)!=(0|o)))break I;if(D[g+8>>2]==(0|Q))break}I=0;break A}if(!(g=D[D[I>>2]+((E=i-1&Q)<<2)>>2]))break I}for(o=i-1|0;;){if(!(g=D[g>>2]))break I;if((0|(a=D[g+4>>2]))!=(0|Q)&(o&a)!=(0|E))break I;if(D[g+8>>2]==(0|Q))break}I=0;break A}if(g=DC(16),C=D[D[C>>2]>>2],D[g+12>>2]=0,D[g+8>>2]=C,D[g+4>>2]=Q,D[g>>2]=0,s=F(D[I+12>>2]+1>>>0),e=t[I+16>>2],!i||s>F(e*F(i>>>0))){o=0!=(i-1&i)|i>>>0<3|i<<1,E=2,1!=(0|(C=(C=(e=F(w(F(s/e))))<F(4294967296)&e>=F(0)?~~e>>>0:0)>>>0>o>>>0?C:o))&&(C&C-1?(E=$(C),i=D[I+4>>2]):E=C);I:{if(E>>>0<=i>>>0){if(E>>>0>=i>>>0)break I;if(o=i>>>0<3,C=(e=F(w(F(F(k[I+12>>2])/t[I+16>>2]))))<F(4294967296)&e>=F(0)?~~e>>>0:0,(E=(C=o||bC(i)>>>0>1?$(C):C>>>0<2?C:1<<32-R(C-1|0))>>>0>E>>>0?C:E)>>>0>=i>>>0)break I}i=0,a=E;g:{C:{Q:{B:{if(E){if(a>>>0>=1073741824)break B;if(E=DC(a<<2),C=D[I>>2],D[I>>2]=E,C&&sA(C),D[I+4>>2]=a,E=0,a-1>>>0>=3)for(o=-4&a;D[(C=E<<2)+D[I>>2]>>2]=0,D[D[I>>2]+(4|C)>>2]=0,D[D[I>>2]+(8|C)>>2]=0,D[D[I>>2]+(12|C)>>2]=0,E=E+4|0,(0|o)!=(0|(i=i+4|0)););if(C=3&a)for(;D[D[I>>2]+(E<<2)>>2]=0,E=E+1|0,(0|C)!=(0|(r=r+1|0)););if(!(i=D[I+8>>2]))break g;if(C=I+8|0,o=D[i+4>>2],(E=bC(a))>>>0<2)break Q;if(D[D[I>>2]+((o=o>>>0>=a>>>0?(o>>>0)%(a>>>0)|0:o)<<2)>>2]=C,!(C=D[i>>2]))break g;if(E>>>0<=1)break C;for(;;){if(a>>>0<=(r=D[C+4>>2])>>>0&&(r=(r>>>0)%(a>>>0)|0),(0|o)!=(0|r))if(E=C,D[(N=(f=r<<2)+D[I>>2]|0)>>2]){for(;r=E,D[C+8>>2]==D[(E=D[E>>2])+8>>2]&&E;);D[i>>2]=E,D[r>>2]=D[D[f+D[I>>2]>>2]>>2],D[D[f+D[I>>2]>>2]>>2]=C}else D[N>>2]=i,i=C,o=r;else i=C;if(!(C=D[i>>2]))break}break g}C=D[I>>2],D[I>>2]=0,C&&sA(C),D[I+4>>2]=0;break g}xg(1336),U()}if(D[D[I>>2]+((o&=a-1)<<2)>>2]=C,!(C=D[i>>2]))break g}for(f=a-1|0;;){if((0|(a=f&D[C+4>>2]))!=(0|o))if(E=C,D[(N=(r=a<<2)+D[I>>2]|0)>>2]){for(;a=E,D[C+8>>2]==D[(E=D[E>>2])+8>>2]&&E;);D[i>>2]=E,D[a>>2]=D[D[r+D[I>>2]>>2]>>2],D[D[r+D[I>>2]>>2]>>2]=C}else D[N>>2]=i,i=C,o=a;else i=C;if(!(C=D[i>>2]))break}}}E=(C=(i=D[I+4>>2])-1|0)&i?i>>>0>Q>>>0?Q:(Q>>>0)%(i>>>0)|0:C&Q}I:if(C=D[(E=D[I>>2]+(E<<2)|0)>>2])D[g>>2]=D[C>>2],D[C>>2]=g;else{if(D[g>>2]=D[I+8>>2],D[I+8>>2]=g,D[E>>2]=I+8,!(C=D[g>>2]))break I;C=D[C+4>>2],(E=i-1|0)&i?C>>>0<i>>>0||(C=(C>>>0)%(i>>>0)|0):C&=E,D[D[I>>2]+(C<<2)>>2]=g}D[I+12>>2]=D[I+12>>2]+1,I=1}B[A+4|0]=I,D[A>>2]=g}function nA(A){var I=0,g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;D[A+56>>2]=D[A+52>>2],D[A+44>>2]=D[A+40>>2];A:{I:{g:{if((0|(g=D[(Q=D[A+64>>2])+24>>2]))!=D[Q+28>>2])for(;;){C=I;C:if(-1!=(0|(o=D[(r<<2)+g>>2]))){if((0|(I=D[A+56>>2]))==D[A+60>>2]){if((I=1+(E=(Q=I-(g=D[A+52>>2])|0)>>2)|0)>>>0>=1073741824)break g;if(B=Q>>1,B=E>>>0<536870911?I>>>0>B>>>0?I:B:1073741823){if(B>>>0>=1073741824)break A;I=DC(B<<2)}else I=0;D[(E=I+(E<<2)|0)>>2]=C,(0|Q)>0&&xA(I,g,Q),D[A+60>>2]=I+(B<<2),D[A+56>>2]=E+4,D[A+52>>2]=I,g&&sA(g)}else D[I>>2]=C,D[A+56>>2]=I+4;Q:if(D[D[A+12>>2]+(r>>>3&536870908)>>2]>>>r&1&&-1!=(0|(I=((I=o+1|0)>>>0)%3|0?I:o-2|0))&&!(D[(Q=D[A>>2])+(I>>>3&536870908)>>2]>>>I&1)&&-1!=(0|(I=D[D[D[A+64>>2]+12>>2]+(I<<2)>>2]))&&-1!=(0|(g=((g=I+1|0)>>>0)%3|0?g:I-2|0)))for(B=D[A+64>>2];;){if(o=g,-1==(0|(I=((I=g+1|0)>>>0)%3|0?I:g-2|0))|D[Q+(I>>>3&536870908)>>2]>>>I&1)break Q;if(-1==(0|(I=D[D[B+12>>2]+(I<<2)>>2])))break Q;if(-1==(0|(g=((g=I+1|0)>>>0)%3|0?g:I-2|0)))break}if(D[D[A+28>>2]+(o<<2)>>2]=C,(0|(I=D[A+44>>2]))==D[A+48>>2]){if((I=1+(E=(Q=I-(g=D[A+40>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(B=Q>>1,B=E>>>0<536870911?I>>>0>B>>>0?I:B:1073741823){if(B>>>0>=1073741824)break A;I=DC(B<<2)}else I=0;D[(E=I+(E<<2)|0)>>2]=o,(0|Q)>0&&xA(I,g,Q),D[A+48>>2]=I+(B<<2),D[A+44>>2]=E+4,D[A+40>>2]=I,g&&sA(g)}else D[I>>2]=o,D[A+44>>2]=I+4;if(I=C+1|0,Q=D[A+64>>2],(o>>>0)%3|0)g=o-1|0;else if(-1==(0|(g=o+2|0)))break C;if(-1!=(0|(g=D[D[Q+12>>2]+(g<<2)>>2]))&&!(-1==(0|(g=g+((g>>>0)%3|0?-1:2)|0))|(0|g)==(0|o)))for(;;){if(D[D[A>>2]+((Q=((Q=g+1|0)>>>0)%3|0?Q:g-2|0)>>>3&536870908)>>2]>>>Q&1){if((0|(C=D[A+56>>2]))==D[A+60>>2]){if((C=1+(i=(B=C-(Q=D[A+52>>2])|0)>>2)|0)>>>0>=1073741824)break g;if(E=B>>1,E=i>>>0<536870911?C>>>0>E>>>0?C:E:1073741823){if(E>>>0>=1073741824)break A;C=DC(E<<2)}else C=0;D[(i=C+(i<<2)|0)>>2]=I,(0|B)>0&&xA(C,Q,B),D[A+60>>2]=C+(E<<2),D[A+56>>2]=i+4,D[A+52>>2]=C,Q&&sA(Q)}else D[C>>2]=I,D[A+56>>2]=C+4;if(Q=I+1|0,(0|(C=D[A+44>>2]))==D[A+48>>2]){if((C=1+(a=(E=C-(B=D[A+40>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(i=E>>1,i=a>>>0<536870911?C>>>0>i>>>0?C:i:1073741823){if(i>>>0>=1073741824)break A;C=DC(i<<2)}else C=0;D[(a=C+(a<<2)|0)>>2]=g,(0|E)>0&&xA(C,B,E),D[A+48>>2]=C+(i<<2),D[A+44>>2]=a+4,D[A+40>>2]=C,B&&sA(B)}else D[C>>2]=g,D[A+44>>2]=C+4;C=I,I=Q}if(D[D[A+28>>2]+(g<<2)>>2]=C,Q=D[A+64>>2],(g>>>0)%3|0)g=g-1|0;else if(-1==(0|(g=g+2|0)))break C;if(-1==(0|(g=D[D[Q+12>>2]+(g<<2)>>2])))break C;if(-1==(0|(g=g+((g>>>0)%3|0?-1:2)|0)))break C;if((0|g)==(0|o))break}}if(!((r=r+1|0)>>>0<D[Q+28>>2]-(g=D[Q+24>>2])>>2>>>0))break}return}iQ(),U()}iQ(),U()}xg(1336),U()}function RA(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;if(-1==(0|I))return 1;if(!(D[D[A+24>>2]+((g=(I>>>0)/3|0)>>>3&268435452)>>2]>>>g&1)){if(D[A+52>>2]=C=D[A+48>>2],(0|C)==D[A+56>>2]?(Q=DC(4),D[Q>>2]=I,D[A+56>>2]=B=Q+4|0,D[A+52>>2]=B,D[A+48>>2]=Q,C&&sA(C)):(D[C>>2]=I,D[A+52>>2]=C+4),-1==(0|(C=D[(B=D[D[A+4>>2]+28>>2])+((Q=((C=I+1|0)>>>0)%3|0?C:I-2|0)<<2)>>2])))return 0;if(E=(I-s(g,3)|0?-1:2)+I|0,-1==(0|(g=D[B+(E<<2)>>2])))return 0;if((i=D[(B=(I=D[A+36>>2])+(C>>>3&536870908)|0)>>2])&(o=1<<C)||(D[B>>2]=i|o,gI(A+8|0,C,Q),I=D[A+36>>2]),(C=D[(I=(g>>>3&536870908)+I|0)>>2])&(Q=1<<g)||(D[I>>2]=C|Q,gI(A+8|0,g,E)),(0|(g=D[A+52>>2]))==D[A+48>>2])return 1;for(r=A+8|0;;){C=((I=D[(g=g-4|0)>>2])>>>0)/3|0;A:{I:if(-1!=(0|I)&&!((B=D[(Q=D[A+24>>2]+(C>>>3&268435452)|0)>>2])&(C=1<<C))){if(D[Q>>2]=C|B,-1==(0|(C=D[D[(Q=D[A+4>>2])+28>>2]+(I<<2)>>2])))return 0;for(;;){g=I;g:{if(!((E=D[(B=D[A+36>>2]+(C>>>3&536870908)|0)>>2])&(i=1<<C)))if(-1==(0|(I=D[D[Q+40>>2]+(C<<2)>>2]))||-1==(0|(I=((o=I+1|0)>>>0)%3|0?o:I-2|0))|D[D[Q>>2]+(I>>>3&536870908)>>2]>>>I&1||-1==(0|(I=D[D[D[Q+64>>2]+12>>2]+(I<<2)>>2])))D[B>>2]=E|i,gI(r,C,g);else if(D[B>>2]=E|i,gI(r,C,g),-1!=(0|(((C=I+1|0)>>>0)%3|0?C:I-2|0))){I=-1,Q=D[A+4>>2],-1!=(0|g)&&(-1==(0|(C=((C=g+1|0)>>>0)%3|0?C:g-2|0))|D[D[Q>>2]+(C>>>3&536870908)>>2]>>>C&1||(I=D[D[D[Q+64>>2]+12>>2]+(C<<2)>>2])),i=1<<(C=(I>>>0)/3|0),B=D[(g=D[A+24>>2])+((o=C>>>5|0)<<2)>>2];break g}C:{if(-1!=(0|g)){C=-1,-1==(0|(I=((I=g+1|0)>>>0)%3|0?I:g-2|0))|D[D[(Q=D[A+4>>2])>>2]+(I>>>3&536870908)>>2]>>>I&1||(C=D[D[D[Q+64>>2]+12>>2]+(I<<2)>>2]);Q:{if((g>>>0)%3|0)g=g-1|0;else if(I=-1,-1==(0|(g=g+2|0)))break Q;I=-1,D[D[Q>>2]+(g>>>3&536870908)>>2]>>>g&1||(I=D[D[D[Q+64>>2]+12>>2]+(g<<2)>>2])}if(E=(a=-1==(0|I))?-1:(I>>>0)/3|0,B=(C>>>0)/3|0,!((i=-1==(0|C))||(B=D[(g=D[A+24>>2])+((o=(i=i?-1:B)>>>5|0)<<2)>>2])&(i=1<<i)))break C;if(!(a||(i=1<<E)&(B=D[(g=D[A+24>>2])+((o=E>>>5|0)<<2)>>2])))break g}D[A+52>>2]=g=D[A+52>>2]-4|0;break A}if(a)I=C;else if(D[(E>>>3&536870908)+g>>2]>>>E&1)I=C;else{if(D[(g=D[A+52>>2])-4>>2]=I,(0|g)!=D[A+56>>2]){D[g>>2]=C,g=g+4|0;break I}C:{if((I=1+(g=(B=g-(Q=D[A+48>>2])|0)>>2)|0)>>>0<1073741824){if(E=B>>1,E=g>>>0<536870911?I>>>0>E>>>0?I:E:1073741823){if(E>>>0>=1073741824)break C;I=DC(E<<2)}else I=0;if(D[(g=I+(g<<2)|0)>>2]=C,g=g+4|0,(0|B)>0&&xA(I,Q,B),D[A+56>>2]=I+(E<<2),D[A+52>>2]=g,D[A+48>>2]=I,!Q)break A;sA(Q),g=D[A+52>>2];break A}iQ(),U()}xg(1336),U()}}if(D[(o<<2)+g>>2]=B|i,-1==(0|(C=D[D[Q+28>>2]+(I<<2)>>2])))break}return 0}D[A+52>>2]=g}if(D[A+48>>2]==(0|g))break}}return 1}function yA(A,I,g,C){var Q,E=0,i=0,o=0,a=0,r=0,f=0;if(d=Q=d-80|0,E=D[g+36>>2],D[Q+72>>2]=D[g+32>>2],D[Q+76>>2]=E,i=D[g+28>>2],D[(E=Q- -64|0)>>2]=D[g+24>>2],D[E+4>>2]=i,E=D[g+20>>2],D[Q+56>>2]=D[g+16>>2],D[Q+60>>2]=E,E=D[g+12>>2],D[Q+48>>2]=D[g+8>>2],D[Q+52>>2]=E,E=D[g+4>>2],D[Q+40>>2]=D[g>>2],D[Q+44>>2]=E,aA(A,Q+40|0,Q+24|0),!D[A>>2])if(r=A+4|0,B[A+15|0]<0&&sA(D[r>>2]),1==e[Q+31|0]){d=a=d-16|0;A:{I:switch(e[Q+32|0]){case 0:WC(E=DC(48)),D[E>>2]=13144,D[Q+8>>2]=0,D[Q+12>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+16>>2]=E;break A;case 1:WC(E=DC(52)),D[E+48>>2]=0,D[E>>2]=11304,D[Q+8>>2]=0,D[Q+12>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+16>>2]=E;break A}i=DC(32),B[i+24|0]=E=e[1694]|e[1695]<<8|e[1696]<<16|e[1697]<<24,B[i+25|0]=E>>>8,B[i+26|0]=E>>>16,B[i+27|0]=E>>>24,E=e[1690]|e[1691]<<8|e[1692]<<16|e[1693]<<24,B[i+16|0]=o=e[1686]|e[1687]<<8|e[1688]<<16|e[1689]<<24,B[i+17|0]=o>>>8,B[i+18|0]=o>>>16,B[i+19|0]=o>>>24,B[i+20|0]=E,B[i+21|0]=E>>>8,B[i+22|0]=E>>>16,B[i+23|0]=E>>>24,E=e[1682]|e[1683]<<8|e[1684]<<16|e[1685]<<24,B[i+8|0]=o=e[1678]|e[1679]<<8|e[1680]<<16|e[1681]<<24,B[i+9|0]=o>>>8,B[i+10|0]=o>>>16,B[i+11|0]=o>>>24,B[i+12|0]=E,B[i+13|0]=E>>>8,B[i+14|0]=E>>>16,B[i+15|0]=E>>>24,E=e[1674]|e[1675]<<8|e[1676]<<16|e[1677]<<24,B[0|i]=o=e[1670]|e[1671]<<8|e[1672]<<16|e[1673]<<24,B[i+1|0]=o>>>8,B[i+2|0]=o>>>16,B[i+3|0]=o>>>24,B[i+4|0]=E,B[i+5|0]=E>>>8,B[i+6|0]=E>>>16,B[i+7|0]=E>>>24,B[i+28|0]=0,D[a>>2]=-1,Lg(E=4|a,i,28),f=B[a+15|0],D[Q>>2]=D[a>>2],o=Q+4|0,(0|f)>=0?(f=D[E+4>>2],D[o>>2]=D[E>>2],D[o+4>>2]=f,D[o+8>>2]=D[E+8>>2]):Lg(o,D[a+4>>2],D[a+8>>2]),D[Q+16>>2]=0,B[a+15|0]<0&&sA(D[a+4>>2]),sA(i)}d=a+16|0;A:if(E=D[Q>>2]){if(D[A>>2]=E,B[Q+15|0]>=0){I=D[4+(A=4|Q)>>2],D[r>>2]=D[A>>2],D[r+4>>2]=I,D[r+8>>2]=D[A+8>>2];break A}Lg(r,D[Q+4>>2],D[Q+8>>2])}else E=D[Q+16>>2],D[Q+16>>2]=0,D[E+44>>2]=C,V(A,E,I,g,C),D[A>>2]||(B[r+11|0]<0&&sA(D[r>>2]),D[A>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0),RQ[D[D[E>>2]+4>>2]](E);A=D[Q+16>>2],D[Q+16>>2]=0,A&&RQ[D[D[A>>2]+4>>2]](A),B[Q+15|0]>=0||sA(D[Q+4>>2])}else I=DC(32),B[I+16|0]=g=e[1592]|e[1593]<<8|e[1594]<<16|e[1595]<<24,B[I+17|0]=g>>>8,B[I+18|0]=g>>>16,B[I+19|0]=g>>>24,g=e[1588]|e[1589]<<8|e[1590]<<16|e[1591]<<24,B[I+8|0]=C=e[1584]|e[1585]<<8|e[1586]<<16|e[1587]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=g,B[I+13|0]=g>>>8,B[I+14|0]=g>>>16,B[I+15|0]=g>>>24,g=e[1580]|e[1581]<<8|e[1582]<<16|e[1583]<<24,B[0|I]=C=e[1576]|e[1577]<<8|e[1578]<<16|e[1579]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=g,B[I+5|0]=g>>>8,B[I+6|0]=g>>>16,B[I+7|0]=g>>>24,B[I+20|0]=0,D[A>>2]=-1,Lg(r,I,20),sA(I);d=Q+80|0}function GA(A,I,g){var C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0;C=s(I,12)+A|0,D[C+12>>2]=D[C+8>>2],e=-1==(0|g)?-1:(g>>>0)/3|0,k=1,a=g;A:{I:{g:{for(;;){C:{if(t=1&B){if(-1==(0|a))break C;if(-1==(0|UI(A,((a>>>0)%3|0?-1:2)+a|0)))break A;if(-1==(0|(Q=((g=a+1|0)>>>0)%3|0?g:a-2|0)))break A;if(-1==(0|(g=((g=Q+1|0)>>>0)%3|0?g:Q-2|0)))break A;if(-1==(0|(Q=D[D[D[A+4>>2]+12>>2]+(g<<2)>>2])))break A;if(-1==(0|(g=((g=Q+1|0)>>>0)%3|0?g:Q-2|0)))break A;e=(g>>>0)/3|0}if(!((r=1<<e)&(f=D[(i=D[A+56>>2]+(e>>>3&536870908)|0)>>2]))){for(B=0;;){if(D[i>>2]=f|r,(0|(Q=D[C+12>>2]))==D[C+16>>2]){if((o=1+(E=(r=Q-(i=D[C+8>>2])|0)>>2)|0)>>>0>=1073741824)break g;if(Q=r>>1,f=E>>>0<536870911?Q>>>0<o>>>0?o:Q:1073741823){if(f>>>0>=1073741824)break I;Q=DC(f<<2)}else Q=0;D[(o=Q+(E<<2)|0)>>2]=e,(0|r)>0&&xA(Q,i,r),D[C+8>>2]=Q,D[C+12>>2]=o+4,D[C+16>>2]=Q+(f<<2),i&&sA(i)}else D[Q>>2]=e,D[C+12>>2]=Q+4;o=B+1|0;Q:{B:{if(B)if(1&o){if(-1==(0|g)){g=-1;break Q}g=((Q=g+1|0)>>>0)%3|0?Q:g-2|0}else{if(a=t?g:a,-1==(0|g)){g=-1;break Q}if((g>>>0)%3|0){B=g-1|0;break B}g=g+2|0}if(Q=g,g=-1,B=Q,-1==(0|Q))break Q}if(g=D[D[D[A+4>>2]+12>>2]+(B<<2)>>2],i=-1,f=-1,(0|(E=((Q=B+1|0)>>>0)%3|0?Q:B-2|0))>=0&&(f=D[(D[D[A>>2]+96>>2]+s(Q=(E>>>0)/3|0,12)|0)+(E-s(Q,3)<<2)>>2]),-1!=(0|g)?(r=0,(0|(E=((g>>>0)%3|0?-1:2)+g|0))<0||(i=D[(D[D[A>>2]+96>>2]+s(Q=(E>>>0)/3|0,12)|0)+(E-s(Q,3)<<2)>>2])):r=1,(0|i)==(0|f)){B:{E:{i:{o:{if((0|(B=((B>>>0)%3|0?-1:2)+B|0))>=0){if(i=D[(D[D[A>>2]+96>>2]+s(Q=(B>>>0)/3|0,12)|0)+(B-s(Q,3)<<2)>>2],B=-1,!r)break o;break i}if(i=-1,r)break E}B=(0|(B=((Q=g+1|0)>>>0)%3|0?Q:g-2|0))<0?-1:D[(D[D[A>>2]+96>>2]+s(Q=(B>>>0)/3|0,12)|0)+(B-s(Q,3)<<2)>>2]}if((0|B)!=(0|i)){g=-1;break Q}if(-1!=(0|g))break B;g=-1;break Q}if(-1==(0|g)){g=-1;break Q}}if(B=o,!((f=D[(i=D[A+56>>2]+((e=(g>>>0)/3|0)>>>3&268435452)|0)>>2])&(r=1<<e)))continue}else g=-1}break}!t|!(1&o)||(Q=D[(B=D[A+56>>2]+((o=D[(E=D[C+12>>2]-4|0)>>2])>>>3&536870908)|0)>>2],N=B,F=JC(o)&Q,D[N>>2]=F,D[C+12>>2]=E)}if(B=1,Q=k,k=0,Q)continue;break A}break}a=-1,UI(A,-1);break A}iQ(),U()}xg(1336),U()}if(D[44+((I<<2)+A|0)>>2]=a,I=D[C+12>>2]-(E=D[C+8>>2])|0){if(a=D[A+56>>2],o=1&(A=(I>>=2)>>>0>1?I:1),g=0,I>>>0>=2)for(k=-2&A,e=0;A=D[(I=a+((Q=D[(B=g<<2)+E>>2])>>>3&536870908)|0)>>2],N=I,F=JC(Q)&A,D[N>>2]=F,A=D[(I=a+((Q=D[E+(4|B)>>2])>>>3&536870908)|0)>>2],N=I,F=JC(Q)&A,D[N>>2]=F,g=g+2|0,(0|k)!=(0|(e=e+2|0)););o&&(A=D[(I=a+((g=D[E+(g<<2)>>2])>>>3&536870908)|0)>>2],N=I,F=JC(g)&A,D[N>>2]=F)}}function cA(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0;if(-1==(0|I))return 1;if(!(D[D[A+24>>2]+((C=(I>>>0)/3|0)>>>3&268435452)>>2]>>>C&1)){if(D[A+52>>2]=g=D[A+48>>2],(0|g)==D[A+56>>2]?(Q=DC(4),D[Q>>2]=I,D[A+56>>2]=B=Q+4|0,D[A+52>>2]=B,D[A+48>>2]=Q,g&&sA(g)):(D[g>>2]=I,D[A+52>>2]=g+4),Q=-1,B=D[A+4>>2],-1!=(0|(E=((g=I+1|0)>>>0)%3|0?g:I-2|0))&&(Q=D[D[B>>2]+(E<<2)>>2]),i=I-s(C,3)|0)g=I-1|0;else if(-1==(0|(g=I+2|0)))return 0;if(-1==(0|Q))return 0;if(-1==(0|(C=D[D[B>>2]+(g<<2)>>2])))return 0;if((o=D[(B=(g=D[A+36>>2])+(Q>>>3&536870908)|0)>>2])&(a=1<<Q)||(D[B>>2]=o|a,gI(A+8|0,Q,E),g=D[A+36>>2]),(Q=D[(g=(C>>>3&536870908)+g|0)>>2])&(B=1<<C)||(D[g>>2]=Q|B,gI(A+8|0,C,(i?-1:2)+I|0)),(0|(g=D[A+52>>2]))==D[A+48>>2])return 1;for(a=A+8|0;;){C=((I=D[(g=g-4|0)>>2])>>>0)/3|0;A:{I:if(-1!=(0|I)&&!((B=D[(Q=D[A+24>>2]+(C>>>3&268435452)|0)>>2])&(C=1<<C))){for(D[Q>>2]=C|B;;){if(-1==(0|(g=D[D[(C=D[A+4>>2])>>2]+(I<<2)>>2])))return 0;g:{if(!((B=D[(Q=D[A+36>>2]+(g>>>3&536870908)|0)>>2])&(E=1<<g)))if(-1!=(0|(i=D[D[C+24>>2]+(g<<2)>>2]))&&-1!=(0|(i=((o=i+1|0)>>>0)%3|0?o:i-2|0))&&-1!=(0|(C=D[D[C+12>>2]+(i<<2)>>2]))){if(D[Q>>2]=B|E,gI(a,g,I),-1!=(0|(((g=C+1|0)>>>0)%3|0?g:C-2|0))){C=I-2|0,g=I+1|0,I=-1,-1!=(0|(g=(g>>>0)%3|0?g:C))&&(I=D[D[D[A+4>>2]+12>>2]+(g<<2)>>2]),E=1<<(g=(I>>>0)/3|0),C=D[(Q=D[A+24>>2])+((i=g>>>5|0)<<2)>>2];break g}}else D[Q>>2]=B|E,gI(a,g,I);g=-1,B=D[A+4>>2],-1!=(0|(C=((C=I+1|0)>>>0)%3|0?C:I-2|0))&&(g=D[D[B+12>>2]+(C<<2)>>2]);C:{if((I>>>0)%3|0)Q=I-1|0;else if(Q=I+2|0,I=-1,-1==(0|Q))break C;I=D[D[B+12>>2]+(Q<<2)>>2]}if(B=(o=-1==(0|I))?-1:(I>>>0)/3|0,C=(g>>>0)/3|0,(E=-1==(0|g))||(C=D[(Q=D[A+24>>2])+((i=(E=E?-1:C)>>>5|0)<<2)>>2])&(E=1<<E)){if(!(o||(E=1<<B)&(C=D[(Q=D[A+24>>2])+((i=B>>>5|0)<<2)>>2])))break g;D[A+52>>2]=g=D[A+52>>2]-4|0;break A}if(o)I=g;else if(D[(B>>>3&536870908)+Q>>2]>>>B&1)I=g;else{if(D[(C=D[A+52>>2])-4>>2]=I,(0|C)!=D[A+56>>2]){D[C>>2]=g,g=C+4|0;break I}C:{if((I=1+(E=(Q=(I=C)-(C=D[A+48>>2])|0)>>2)|0)>>>0<1073741824){if(B=Q>>1,B=E>>>0<536870911?I>>>0>B>>>0?I:B:1073741823){if(B>>>0>=1073741824)break C;I=DC(B<<2)}else I=0;if(D[(E=I+(E<<2)|0)>>2]=g,g=E+4|0,(0|Q)>0&&xA(I,C,Q),D[A+56>>2]=I+(B<<2),D[A+52>>2]=g,D[A+48>>2]=I,!C)break A;sA(C),g=D[A+52>>2];break A}iQ(),U()}xg(1336),U()}}if(D[(i<<2)+Q>>2]=C|E,-1==(0|I))break}return 0}D[A+52>>2]=g}if(D[A+48>>2]==(0|g))break}}return 1}function wA(A,I){A|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0;d=g=d-32|0;A:{if(f[38+(I|=0)>>1]<=513){if((0|(C=D[I+20>>2]))>=(0|(a=D[I+12>>2]))&(Q=D[I+16>>2])>>>0>=k[I+8>>2]|(0|C)>(0|a))break A;if(a=e[Q+D[I>>2]|0],C=(Q=Q+1|0)?C:C+1|0,D[I+16>>2]=Q,D[I+20>>2]=C,a)break A}I:if(ng(1,g+28|0,I))g:{if(Q=D[g+28>>2]){if(BI(A+60|0,Q),D[(C=g+8|0)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,!TA(C,I))break g;for(;a=1<<E,i=ug(C),D[(o=D[A+60>>2]+(E>>>3&536870908)|0)>>2]=i=i?a|D[o>>2]:D[o>>2]&(-1^a),(0|Q)!=(0|(E=E+1|0)););}if(!ng(1,g+28|0,I))break I;if(Q=D[g+28>>2]){if(E=0,BI(A+72|0,Q),D[(C=g+8|0)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,!TA(C,I))break g;for(;a=1<<E,i=ug(C),D[(o=D[A+72>>2]+(E>>>3&536870908)|0)>>2]=i=i?a|D[o>>2]:D[o>>2]&(-1^a),(0|Q)!=(0|(E=E+1|0)););}if(!ng(1,g+28|0,I))break I;if(Q=D[g+28>>2]){if(E=0,BI(A+84|0,Q),D[(C=g+8|0)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,!TA(C,I))break g;for(;a=1<<E,i=ug(C),D[(o=D[A+84>>2]+(E>>>3&536870908)|0)>>2]=i=i?a|D[o>>2]:D[o>>2]&(-1^a),(0|Q)!=(0|(E=E+1|0)););}if(!ng(1,g+28|0,I))break I;if(Q=D[g+28>>2]){if(E=0,BI(A+96|0,Q),D[(C=g+8|0)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,!TA(C,I))break g;for(;a=1<<E,i=ug(C),D[(o=D[A+96>>2]+(E>>>3&536870908)|0)>>2]=i=i?a|D[o>>2]:D[o>>2]&(-1^a),(0|Q)!=(0|(E=E+1|0)););}if(E=0,a=Q=D[I+12>>2],o=C=D[I+20>>2],(t=D[I+8>>2])>>>0<(r=(i=D[I+16>>2])+4|0)>>>0&(0|(C=r>>>0<4?C+1|0:C))>=(0|Q)|(0|C)>(0|Q))break A;if(Q=e[0|(Q=(N=D[I>>2])+i|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=r,D[I+20>>2]=C,C=o,i=o=i+8|0,o=C=o>>>0<8?C+1|0:C,i>>>0>t>>>0&(0|C)>=(0|a)|(0|C)>(0|a))break A;if(C=e[0|(C=r+N|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=o,(0|C)<(0|Q))break A;if(D[A+16>>2]=C,D[A+12>>2]=Q,!(I=(C>>31)-((Q>>31)+(C>>>0<Q>>>0)|0)|0)&(C=C-Q|0)>>>0>2147483646|I)break A;if(E=1,D[A+20>>2]=I=C+1|0,D[A+24>>2]=C=I>>>1|0,D[A+28>>2]=0-C,1&I)break A;D[A+24>>2]=C-1;break A}E=0}return d=g+32|0,0|E}function bA(A,I,g){I|=0,g|=0;var C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,F=0;A:if(!((0|(N=0|RQ[D[D[(A|=0)>>2]+44>>2]](A)))<=0)&&(Q=D[I+4>>2]-D[I>>2]>>2,d=i=d+-64|0,C=zg(i),E=s(D[3408],N),oC(C,D[D[A+8>>2]+56>>2],N<<24>>24,5,0,E,E>>31),C=lI(E=DC(96),C),B[C+84|0]=1,D[C+72>>2]=D[C+68>>2],KI(C,Q),D[C+60>>2]=D[D[A+8>>2]+60>>2],C=D[A+16>>2],D[A+16>>2]=E,C&&Wg(C),d=i- -64|0,D[(i=D[A+16>>2])+80>>2]&&(a=D[D[i>>2]>>2])&&!((0|(o=D[g+12>>2]))<=(0|(C=D[g+20>>2]))&(r=D[g+8>>2])>>>0<=(E=D[g+16>>2])>>>0|(0|C)>(0|o)))){f=s(Q,N),a=a+D[i+48>>2]|0,t=e[(k=D[g>>2])+E|0],Q=(i=E+1|0)?C:C+1|0,D[g+16>>2]=i,D[g+20>>2]=Q;I:{g:{C:{if(t){if(H(f,N,g,a))break C;break A}if((0|Q)>=(0|o)&i>>>0>=r>>>0|(0|Q)>(0|o))break A;i=e[i+k|0],C=(Q=E+2|0)>>>0<2?C+1|0:C,D[g+16>>2]=Q,D[g+20>>2]=C,C=D[(C=D[D[A+16>>2]+64>>2])+4>>2]-D[C>>2]|0;Q:{if((0|i)==D[3408]){if((Q=C)>>>0<(C=f<<2)>>>0)break A;if(Q=D[g+20>>2],(0|(Q=(E=C+(r=D[g+16>>2])|0)>>>0<C>>>0?Q+1|0:Q))<=(0|(i=D[g+12>>2]))&E>>>0<=(o=D[g+8>>2])>>>0|(0|Q)<(0|i))break Q;break A}if(C>>>0<s(i,f)>>>0)break A;if(o=D[g+12>>2],Q=D[g+20>>2],(E=k=D[g+8>>2])-(r=D[g+16>>2])>>>0<mg(C=i,0,f,0)>>>0&(0|(E=o-(Q+(E>>>0<r>>>0)|0)|0))<=(0|(t=u))|(0|E)<(0|t))break A;if(E=1,!f)break g;if(E=0,(t=k)>>>0<(k=C+r|0)>>>0&(0|(Q=k>>>0<C>>>0?Q+1|0:Q))>=(0|o)|(0|Q)>(0|o))break I;for(;;){if(xA(a+(F<<2)|0,r+D[g>>2]|0,i),Q=D[g+20>>2],Q=(o=C+D[g+16>>2]|0)>>>0<C>>>0?Q+1|0:Q,r=o,D[g+16>>2]=o,D[g+20>>2]=Q,(0|f)==(0|(F=F+1|0)))break C;if(!((0|(Q=(k=C+r|0)>>>0<C>>>0?Q+1|0:Q))<=(0|(o=D[g+12>>2]))&k>>>0<=(t=D[g+8>>2])>>>0|(0|Q)<(0|o)))break}break I}xA(a,r+D[g>>2]|0,C),Q=C,i=C+D[g+16>>2]|0,C=D[g+20>>2],D[g+16>>2]=i,D[g+20>>2]=Q>>>0>i>>>0?C+1|0:C}if(E=1,f&&!((C=D[A+20>>2])&&(E=0,0|RQ[D[D[C>>2]+32>>2]](C)))){if(C=0,E=0,!((0|f)<=0)){if(1!=(0|f))for(o=-2&f;D[(Q=C<<2)+a>>2]=0-(1&(i=D[Q+a>>2]))^i>>>1,D[(i=4|Q)+a>>2]=0-(1&(Q=D[i+a>>2]))^Q>>>1,C=C+2|0,(0|o)!=(0|(E=E+2|0)););1&f&&(D[(Q=C<<2)+a>>2]=0-(1&(C=D[Q+a>>2]))^C>>>1)}E=0}}if(C=D[A+20>>2]){if(!(0|RQ[D[D[C>>2]+40>>2]](C,g)))break A;if(!(E||(E=0,0|RQ[D[D[(A=D[A+20>>2])>>2]+44>>2]](A,a,a,f,N,D[I>>2]))))break I}E=1}return 0|E}return 0}function UA(A,I){I|=0;var g,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;d=g=d-80|0;A:{if(e[D[28+(A|=0)>>2]+36|0]<=1){if(Q=D[I+20>>2],(0|(r=D[I+12>>2]))<=(0|(Q=(B=(C=D[I+16>>2])+4|0)>>>0<4?Q+1|0:Q))&B>>>0>k[I+8>>2]|(0|Q)>(0|r))break A;o=e[0|(C=C+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=B,D[I+20>>2]=Q}else{if(!Rg(1,g+76|0,I))break A;o=D[g+76>>2]}if(o&&!((Q=mg((Q=D[I+8>>2])-(C=D[I+16>>2])|0,D[I+12>>2]-(D[I+20>>2]+(C>>>0>Q>>>0)|0)|0,5,0))>>>0<o>>>0&(0|(C=u))<=0|(0|C)<0)){for((Q=D[A+8>>2]-(C=D[A+4>>2])>>2)>>>0<o>>>0?$I(A+4|0,o-Q|0):Q>>>0<=o>>>0||(D[A+8>>2]=C+(o<<2)),G=A+16|0,N=D[A+32>>2],E=1;;){I:if(!((0|(C=i=D[I+12>>2]))<=(0|(Q=D[I+20>>2]))&(n=D[I+8>>2])>>>0<=(a=D[I+16>>2])>>>0|(0|C)<(0|Q)||(r=e[(R=D[I>>2])+a|0],C=Q,C=(B=a+1|0)?C:C+1|0,D[I+16>>2]=B,D[I+20>>2]=C,(0|C)>=(0|i)&B>>>0>=n>>>0|(0|C)>(0|i)||(B=e[B+R|0],C=Q,C=(t=a+2|0)>>>0<2?C+1|0:C,D[I+16>>2]=t,D[I+20>>2]=C,(0|C)>=(0|i)&t>>>0>=n>>>0|(0|C)>(0|i)||(t=e[t+R|0],C=Q,C=(y=a+3|0)>>>0<3?C+1|0:C,D[I+16>>2]=y,D[I+20>>2]=C,(0|C)>=(0|i)&y>>>0>=n>>>0|(0|C)>(0|i)||(i=e[y+R|0],C=Q,C=(Q=a+4|0)>>>0<4?C+1|0:C,D[I+16>>2]=Q,D[I+20>>2]=C,!t|(B-12&255)>>>0<245|r>>>0>4)))))){if(oC(a=zg(g+8|0),r,n=t<<24>>24,B,i=0!=(0|i),Q=s(C=(Q=B-1|0)>>>0<=10?D[13616+(Q<<2)>>2]:-1,t),Q>>31),(65535&((Q=f[D[A+28>>2]+36>>1])<<8|Q>>>8))>>>0<=258){if(C=D[I+20>>2],(0|(r=D[I+12>>2]))<=(0|(C=(B=(Q=D[I+16>>2])+2|0)>>>0<2?C+1|0:C))&B>>>0>k[I+8>>2]|(0|C)>(0|r))break I;E=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8,D[I+16>>2]=B,D[I+20>>2]=C}else{if(!Rg(1,g+4|0,I))break I;E=D[g+4>>2]}if(D[g+68>>2]=E,Q=lI(DC(96),a),RQ[D[D[N>>2]+8>>2]](N,D[N+12>>2]-D[N+8>>2]>>2,Q),D[D[(B=(Q=(D[N+12>>2]-D[N+8>>2]>>2)-1|0)<<2)+D[N+8>>2]>>2]+60>>2]=E,D[D[A+4>>2]+(F<<2)>>2]=Q,(0|(C=D[A+20>>2]-(E=D[A+16>>2])>>2))>(0|Q)||(D[g>>2]=-1,(Q=Q+1|0)>>>0>C>>>0?(ZA(G,Q-C|0,g),E=D[G>>2]):C>>>0<=Q>>>0||(D[A+20>>2]=(Q<<2)+E)),D[B+E>>2]=F,E=(F=F+1|0)>>>0<o>>>0,(0|o)!=(0|F))continue}break}F=!E}}return d=g+80|0,1&F}function hA(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,s=0,F=0;A:if(g=f[I+38>>1]){if(g>>>0<=511){if(g=D[I+20>>2],(Q=(E=D[I+16>>2])+4|0)>>>0>k[I+8>>2]&(0|(g=Q>>>0<4?g+1|0:g))>=(0|(C=D[I+12>>2]))|(0|g)>(0|C))break A;D[A+12>>2]=B=e[0|(g=E+D[I>>2]|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,g=D[I+20>>2],g=(C=D[I+16>>2]+4|0)>>>0<4?g+1|0:g,D[I+16>>2]=C,D[I+20>>2]=g}else{if(!Fg(1,A+12|0,I))break A;B=D[A+12>>2]}if((g=D[A+4>>2]-(C=D[A>>2])>>2)>>>0<B>>>0?($I(A,B-g|0),B=D[A+12>>2]):g>>>0<=B>>>0||(D[A+4>>2]=C+(B<<2)),!B)return 1;for(a=D[I+8>>2],o=D[I+12>>2],t=D[A>>2],E=0;;){if((0|o)<=(0|(g=D[I+20>>2]))&a>>>0<=(C=D[I+16>>2])>>>0|(0|g)>(0|o))return 0;r=e[(N=D[I>>2])+C|0],g=(C=C+1|0)?g:g+1|0,i=C,D[I+16>>2]=C,D[I+20>>2]=g,C=r>>>2|0,Q=0;I:{g:{C:{Q:switch(0|(s=3&r)){case 0:break g;case 3:break Q;default:break C}if((g=C+E|0)>>>0>=B>>>0)return 0;bI(t+(E<<2)|0,0,4+(252&r)|0),E=g;break I}for(;;){if((0|g)>=(0|o)&i>>>0>=a>>>0|(0|g)>(0|o))break A;if(B=e[i+N|0],g=(i=i+1|0)?g:g+1|0,D[I+16>>2]=i,D[I+20>>2]=g,C|=B<<(Q<<3|6),(0|s)==(0|(Q=Q+1|0)))break}}D[t+(E<<2)>>2]=C}if(!((B=D[A+12>>2])>>>0>(E=E+1|0)>>>0))break}if(g=A+16|0,r=D[A>>2],(E=(C=D[A+20>>2]-(I=D[A+16>>2])|0)>>2)>>>0<=4095?$I(g,4096-E|0):16384!=(0|C)&&(D[A+20>>2]=I+16384),(C=D[A+32>>2]-(E=D[(I=A+28|0)>>2])>>3)>>>0<B>>>0)Ag(I,B-C|0),E=D[I>>2];else if(C>>>0>B>>>0&&(D[A+32>>2]=(B<<3)+E),!B)break A;for(Q=0,A=0;;){if(o=D[(I=r+(Q<<2)|0)>>2],D[4+(i=(Q<<3)+E|0)>>2]=C=A,D[i>>2]=o,(A=(o=D[I>>2])+C|0)>>>0>4096)break A;if(!(A>>>0<=C>>>0)){if(i=D[g>>2],I=0,a=7&o)for(;D[i+(C<<2)>>2]=Q,C=C+1|0,(0|a)!=(0|(I=I+1|0)););if(!(o-1>>>0<=6))for(;D[(I=i+(C<<2)|0)>>2]=Q,D[I+28>>2]=Q,D[I+24>>2]=Q,D[I+20>>2]=Q,D[I+16>>2]=Q,D[I+12>>2]=Q,D[I+8>>2]=Q,D[I+4>>2]=Q,(0|(C=C+8|0))!=(0|A););}if((0|(Q=Q+1|0))==(0|B))break}F=4096==(0|A)}return F}function JA(A,I){var g,C=0,Q=0,B=0,E=0,i=0;d=g=d-16|0,C=D[A+4>>2],D[A+40>>2]=D[A>>2],D[A+44>>2]=C,C=D[A+36>>2],D[A+72>>2]=D[A+32>>2],D[A+76>>2]=C,Q=D[A+28>>2],D[(C=A- -64|0)>>2]=D[A+24>>2],D[C+4>>2]=Q,C=D[A+20>>2],D[A+56>>2]=D[A+16>>2],D[A+60>>2]=C,C=D[A+12>>2],D[A+48>>2]=D[A+8>>2],D[A+52>>2]=C;A:if(dI(A+40|0,1,g+8|0)&&(C=D[A+44>>2],D[A>>2]=D[A+40>>2],D[A+4>>2]=C,C=D[A+76>>2],D[A+32>>2]=D[A+72>>2],D[A+36>>2]=C,C=D[A+68>>2],D[A+24>>2]=D[A+64>>2],D[A+28>>2]=C,i=Q=D[A+60>>2],D[A+16>>2]=C=D[A+56>>2],D[A+20>>2]=Q,B=D[A+52>>2],D[A+8>>2]=Q=D[A+48>>2],D[A+12>>2]=B,(0|(E=D[g+12>>2]))==(0|(B=B-((C>>>0>Q>>>0)+i|0)|0))&(Q-C|0)>>>0>=(Q=D[g+8>>2])>>>0|B>>>0>E>>>0)){if(B=C+Q|0,C=i+E|0,D[A+16>>2]=B,D[A+20>>2]=Q>>>0>B>>>0?C+1|0:C,f[A+38>>1]<=513){if(C=D[A+4>>2],D[A+96>>2]=D[A>>2],D[A+100>>2]=C,C=D[A+36>>2],D[A+128>>2]=D[A+32>>2],D[A+132>>2]=C,C=D[A+28>>2],D[A+120>>2]=D[A+24>>2],D[A+124>>2]=C,C=D[A+20>>2],D[A+112>>2]=D[A+16>>2],D[A+116>>2]=C,C=D[A+12>>2],D[A+104>>2]=D[A+8>>2],D[A+108>>2]=C,!(dI(A+96|0,1,g+8|0)&&(C=D[A+100>>2],D[A>>2]=D[A+96>>2],D[A+4>>2]=C,C=D[A+132>>2],D[A+32>>2]=D[A+128>>2],D[A+36>>2]=C,C=D[A+124>>2],D[A+24>>2]=D[A+120>>2],D[A+28>>2]=C,i=Q=D[A+116>>2],D[A+16>>2]=C=D[A+112>>2],D[A+20>>2]=Q,B=D[A+108>>2],D[A+8>>2]=Q=D[A+104>>2],D[A+12>>2]=B,(0|(E=D[g+12>>2]))==(0|(B=B-((C>>>0>Q>>>0)+i|0)|0))&(Q-C|0)>>>0>=(Q=D[g+8>>2])>>>0|B>>>0>E>>>0))){C=0;break A}B=C+Q|0,C=i+E|0,D[A+16>>2]=B,D[A+20>>2]=Q>>>0>B>>>0?C+1|0:C}else if(C=0,!TA(A+80|0,A))break A;C=0,YI(A)&&(C=D[A+4>>2],D[I>>2]=D[A>>2],D[I+4>>2]=C,C=D[A+36>>2],D[I+32>>2]=D[A+32>>2],D[I+36>>2]=C,C=D[A+28>>2],D[I+24>>2]=D[A+24>>2],D[I+28>>2]=C,C=D[A+20>>2],D[I+16>>2]=D[A+16>>2],D[I+20>>2]=C,C=D[A+12>>2],D[I+8>>2]=D[A+8>>2],D[I+12>>2]=C,C=1)}else C=0;return d=g+16|0,C}function SA(A,I,g){A|=0,I|=0;var C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;d=C=d-16|0,D[C+8>>2]=g|=0;A:if(!((0|(E=(B=D[A+12>>2])-(Q=D[A+8>>2])>>2))>(0|I)))if((o=I+1|0)>>>0>E>>>0){if((E=o-E|0)>>>0<=(i=D[A+16>>2])-(Q=D[A+12>>2])>>2>>>0){E&&(Q=bI(B=Q,0,Q=E<<2)+Q|0),D[A+12>>2]=Q;break A}I:{g:{C:{if((B=(r=Q-(o=D[A+8>>2])>>2)+E|0)>>>0<1073741824){if(e=(i=i-o|0)>>1,i=i>>2>>>0<536870911?B>>>0>e>>>0?B:e:1073741823){if(i>>>0>=1073741824)break C;a=DC(i<<2)}if(r=(E=bI(B=(r<<2)+a|0,0,r=E<<2))+r|0,i=(i<<2)+a|0,(0|Q)==(0|o))break g;for(;E=D[(Q=Q-4|0)>>2],D[Q>>2]=0,D[(B=B-4|0)>>2]=E,(0|Q)!=(0|o););if(D[A+16>>2]=i,E=D[A+12>>2],D[A+12>>2]=r,Q=D[A+8>>2],D[A+8>>2]=B,(0|Q)==(0|E))break I;for(;B=D[(E=E-4|0)>>2],D[E>>2]=0,B&&Wg(B),(0|Q)!=(0|E););break I}iQ(),U()}xg(1336),U()}D[A+16>>2]=i,D[A+12>>2]=r,D[A+8>>2]=E}Q&&sA(Q)}else if(!(E>>>0<=o>>>0)){if((0|(Q=Q+(o<<2)|0))!=(0|B)){for(;g=D[(B=B-4|0)>>2],D[B>>2]=0,g&&Wg(g),(0|Q)!=(0|B););g=D[C+8>>2]}D[A+12>>2]=Q}A:{I:{if(!((0|(Q=D[g+56>>2]))>4))if(B=s(Q,12)+A|0,(0|(Q=D[B+24>>2]))==D[B+28>>2]){if((Q=1+(a=(o=Q-(E=D[B+20>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(i=o>>1,i=a>>>0<536870911?Q>>>0>i>>>0?Q:i:1073741823){if(i>>>0>=1073741824)break A;Q=DC(i<<2)}else Q=0;D[(a=Q+(a<<2)|0)>>2]=I,(0|o)>0&&xA(Q,E,o),D[B+20>>2]=Q,D[B+24>>2]=a+4,D[B+28>>2]=Q+(i<<2),E&&sA(E)}else D[Q>>2]=I,D[B+24>>2]=Q+4;return D[g+60>>2]=I,A=D[A+8>>2],D[C+8>>2]=0,A=D[(I=A+(I<<2)|0)>>2],D[I>>2]=g,A&&Wg(A),A=D[C+8>>2],D[C+8>>2]=0,A&&Wg(A),void(d=C+16|0)}iQ(),U()}xg(1336),U()}function YA(A,I){var g,C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0,f=0;d=g=d-16|0,D[g>>2]=I,o=-1,-1!=(0|I)?(D[g+4>>2]=((Q=I+1|0)>>>0)%3|0?Q:I-2|0,o=(I>>>0)%3|0?I-1|0:I+2|0):D[g+4>>2]=-1,D[g+8>>2]=o,C=-1==(0|I)?-1:(I>>>0)/3|0;A:{I:{g:{C:{for(;;){Q:if(-1!=(0|I)&&-1!=(0|(Q=D[D[D[A+8>>2]+12>>2]+(I<<2)>>2]))){if(!((Q>>>0)/3>>>0<C>>>0)&&(o=0,D[A+220>>2]!=D[A+216>>2]))for(;;){if(ug(D[A+368>>2]+(o<<4)|0))if(i=D[A+216>>2]+s(o,144)|0,(Q=D[i+136>>2])>>>0<(B=D[i+140>>2])>>>0)D[Q>>2]=I,D[i+136>>2]=Q+4;else{if((Q=1+(E=(r=Q-(a=D[i+132>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(e=E<<2,E=(B=B-a|0)>>1,B=B>>2>>>0<536870911?Q>>>0>E>>>0?Q:E:1073741823){if(B>>>0>=1073741824)break A;Q=DC(B<<2)}else Q=0;D[(E=e+Q|0)>>2]=I,(0|r)>0&&xA(Q,a,r),D[i+132>>2]=Q,D[i+136>>2]=E+4,D[i+140>>2]=Q+(B<<2),a&&sA(a)}if(!((o=o+1|0)>>>0<(D[A+220>>2]-D[A+216>>2]|0)/144>>>0))break}}else{if(o=0,(0|(Q=D[A+216>>2]))==D[A+220>>2])break Q;for(;;){if(i=s(o,144)+Q|0,(Q=D[i+136>>2])>>>0<(B=D[i+140>>2])>>>0)D[Q>>2]=I,D[i+136>>2]=Q+4;else{if((Q=1+(E=(r=Q-(a=D[i+132>>2])|0)>>2)|0)>>>0>=1073741824)break C;if(e=E<<2,E=(B=B-a|0)>>1,B=B>>2>>>0<536870911?Q>>>0>E>>>0?Q:E:1073741823){if(B>>>0>=1073741824)break g;Q=DC(B<<2)}else Q=0;D[(E=e+Q|0)>>2]=I,(0|r)>0&&xA(Q,a,r),D[i+132>>2]=Q,D[i+136>>2]=E+4,D[i+140>>2]=Q+(B<<2),a&&sA(a)}if(!((o=o+1|0)>>>0<(D[A+220>>2]-(Q=D[A+216>>2])|0)/144>>>0))break}}if(3==(0|(f=f+1|0)))break;I=D[(f<<2)+g>>2]}return d=g+16|0,1}iQ(),U()}xg(1336),U()}iQ(),U()}xg(1336),U()}function KA(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;d=g=d-16|0,D[g>>2]=I,i=-1,-1!=(0|I)?(D[g+4>>2]=((C=I+1|0)>>>0)%3|0?C:I-2|0,i=(I>>>0)%3|0?I-1|0:I+2|0):D[g+4>>2]=-1,D[g+8>>2]=i;A:{I:{for(;;){g:{if(!(-1==(0|I)|-1==D[D[D[A+8>>2]+12>>2]+(I<<2)>>2])){if(i=0,D[A+220>>2]==D[A+216>>2])break g;C:{for(;;){Q:{if(ug(D[A+368>>2]+(i<<4)|0))if(E=D[A+216>>2]+s(i,144)|0,(C=D[E+136>>2])>>>0<(Q=D[E+140>>2])>>>0)D[C>>2]=I,D[E+136>>2]=C+4;else{if((C=1+(B=(a=C-(o=D[E+132>>2])|0)>>2)|0)>>>0>=1073741824)break Q;if(r=B<<2,B=(Q=Q-o|0)>>1,Q=Q>>2>>>0<536870911?C>>>0>B>>>0?C:B:1073741823){if(Q>>>0>=1073741824)break C;C=DC(Q<<2)}else C=0;D[(B=r+C|0)>>2]=I,(0|a)>0&&xA(C,o,a),D[E+132>>2]=C,D[E+136>>2]=B+4,D[E+140>>2]=C+(Q<<2),o&&sA(o)}if((i=i+1|0)>>>0<(D[A+220>>2]-D[A+216>>2]|0)/144>>>0)continue;break g}break}iQ(),U()}xg(1336),U()}if(i=0,(0|(C=D[A+216>>2]))!=D[A+220>>2])for(;;){if(E=s(i,144)+C|0,(C=D[E+136>>2])>>>0<(Q=D[E+140>>2])>>>0)D[C>>2]=I,D[E+136>>2]=C+4;else{if((C=1+(B=(a=C-(o=D[E+132>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(r=B<<2,B=(Q=Q-o|0)>>1,Q=Q>>2>>>0<536870911?C>>>0>B>>>0?C:B:1073741823){if(Q>>>0>=1073741824)break A;C=DC(Q<<2)}else C=0;D[(B=r+C|0)>>2]=I,(0|a)>0&&xA(C,o,a),D[E+132>>2]=C,D[E+136>>2]=B+4,D[E+140>>2]=C+(Q<<2),o&&sA(o)}if(!((i=i+1|0)>>>0<(D[A+220>>2]-(C=D[A+216>>2])|0)/144>>>0))break}}if(3==(0|(e=e+1|0)))break;I=D[(e<<2)+g>>2]}return d=g+16|0,1}iQ(),U()}xg(1336),U()}function MA(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;if(((Q=D[A+8>>2])-(E=D[A+4>>2])|0)/12>>>0>=I>>>0){if(I){if(C=E,B=1+(((Q=s(I,12)-12|0)>>>0)/12|0)&3)for(;a=D[g+4>>2],D[C>>2]=D[g>>2],D[C+4>>2]=a,D[C+8>>2]=D[g+8>>2],C=C+12|0,(0|B)!=(0|(i=i+1|0)););if(E=s(I,12)+E|0,!(Q>>>0<36))for(;I=D[g+4>>2],D[C>>2]=D[g>>2],D[C+4>>2]=I,D[C+8>>2]=D[g+8>>2],D[C+20>>2]=D[g+8>>2],I=D[g+4>>2],D[C+12>>2]=D[g>>2],D[C+16>>2]=I,D[C+32>>2]=D[g+8>>2],I=D[g+4>>2],D[C+24>>2]=D[g>>2],D[C+28>>2]=I,I=D[g+4>>2],D[C+36>>2]=D[g>>2],D[C+40>>2]=I,D[C+44>>2]=D[g+8>>2],(0|E)!=(0|(C=C+48|0)););}D[A+4>>2]=E}else{A:{if((C=(o=(E-(B=D[A>>2])|0)/12|0)+I|0)>>>0<357913942){if(B=(Q=(Q-B|0)/12|0)<<1,B=Q>>>0<178956970?C>>>0>B>>>0?C:B:357913941){if(B>>>0>=357913942)break A;a=DC(s(B,12))}if(C=Q=s(o,12)+a|0,r=1+(((o=(I=s(I,12))-12|0)>>>0)/12|0)&3)for(C=Q;e=D[g+4>>2],D[C>>2]=D[g>>2],D[C+4>>2]=e,D[C+8>>2]=D[g+8>>2],C=C+12|0,(0|r)!=(0|(i=i+1|0)););if(i=I+Q|0,o>>>0>=36)for(;I=D[g+4>>2],D[C>>2]=D[g>>2],D[C+4>>2]=I,D[C+8>>2]=D[g+8>>2],D[C+20>>2]=D[g+8>>2],I=D[g+4>>2],D[C+12>>2]=D[g>>2],D[C+16>>2]=I,D[C+32>>2]=D[g+8>>2],I=D[g+4>>2],D[C+24>>2]=D[g>>2],D[C+28>>2]=I,I=D[g+4>>2],D[C+36>>2]=D[g>>2],D[C+40>>2]=I,D[C+44>>2]=D[g+8>>2],(0|i)!=(0|(C=C+48|0)););return C=Q+s((0|(g=E-(I=D[A>>2])|0))/-12|0,12)|0,(0|g)>0&&xA(C,I,g),D[A+8>>2]=s(B,12)+a,D[A+4>>2]=i,D[A>>2]=C,void(I&&sA(I))}iQ(),U()}xg(1336),U()}}function lA(A,I,g,C){var Q,B,E=0,i=0,o=0,a=0,r=0,e=0;if(E=o=D[g+4>>2]-(Q=D[I+16>>2])|0,D[g>>2]=i=D[g>>2]-Q|0,D[g+4>>2]=E,B=(0|(e=D[I+16>>2]))>=((a=(E>>=31)+o^E)+((E=i>>31)+i^E)|0))E=o;else{A:{I:{if((0|i)>=0){if(r=1,a=1,(0|o)>=0)break A;if(E=1,r=-1,a=-1,i)break I;break A}if(E=-1,r=-1,a=-1,(0|o)<=0)break A}r=(0|o)<=0?-1:1,a=E}E=(E=i<<1)-(i=s(a,e))|0,a=(0|s(r,a))>=0,r=s(r,e),D[g+4>>2]=E=((a?0-E|0:E)+r|0)/2|0,e=i,i=(o<<1)-r|0,D[g>>2]=i=(e+(a?0-i|0:i)|0)/2|0}A:{I:{g:{C:{Q:{B:{E:{if(i){if((0|i)<0)break E;if((0|E)>=0)break B;break g}if(E)break Q;r=1,o=0,E=0,a=0;break A}if(r=1,(0|E)>0)break C;a=(0|E)>0?253:0,o=E,E=i;break A}o=0-E|0,E=0-i|0,a=254;break I}if((0|E)<=0)break g}E=0-E|0,o=i,a=253;break I}o=0-i|0,a=255}D[g>>2]=E,D[g+4>>2]=o,r=0}g=D[C+4>>2]+o|0,(0|(i=D[C>>2]+E|0))>(0|(o=D[I+16>>2]))?i=i-D[I+4>>2]|0:(0-o|0)<=(0|i)||(i=D[I+4>>2]+i|0),(0|g)>(0|o)?g=g-D[I+4>>2]|0:(0-o|0)<=(0|g)||(g=D[I+4>>2]+g|0);A:if(r)I=g;else{I=g;I:switch((3&a)-1|0){case 0:I=0-i|0,i=g;break A;case 1:I=0-g|0,i=0-i|0;break A;case 2:break I;default:break A}I=i,i=0-g|0}if(B)g=I;else{A:{I:{if((0|i)>=0){if(g=1,E=1,(0|I)>=0)break A;if(C=1,g=-1,E=-1,i)break I;break A}if(C=-1,g=-1,E=-1,(0|I)<=0)break A}g=(0|I)<=0?-1:1,E=C}C=i<<1,i=s(E,o),D[A>>2]=C=C-i|0,e=0-C|0,a=C,g=(((C=(0|s(g,E))>=0)?e:a)+(E=s(g,o))|0)/2|0,I=(I<<1)-E|0,i=(i+(C?0-I|0:I)|0)/2|0}D[A>>2]=i+Q,D[A+4>>2]=g+Q}function LA(A,I){var g=0,C=0,Q=0,E=0;D[A+64>>2]||(g=DC(32),D[g+16>>2]=0,D[g+20>>2]=0,D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,C=D[A+64>>2],D[A+64>>2]=g,C&&((g=D[C>>2])&&(D[C+4>>2]=g,sA(g)),sA(C),g=D[A+64>>2]),D[A>>2]=g,C=D[g+20>>2],D[A+8>>2]=D[g+16>>2],D[A+12>>2]=C,C=D[g+24>>2],g=D[g+28>>2],D[A+48>>2]=0,D[A+52>>2]=0,D[A+40>>2]=0,D[A+44>>2]=0,D[A+16>>2]=C,D[A+20>>2]=g);A:{B[A+24|0]=e[I+24|0],D[A+28>>2]=D[I+28>>2],B[A+32|0]=e[I+32|0],g=D[I+44>>2],D[A+40>>2]=D[I+40>>2],D[A+44>>2]=g,g=D[I+52>>2],D[A+48>>2]=D[I+48>>2],D[A+52>>2]=g,D[A+56>>2]=D[I+56>>2],g=D[I+12>>2],D[A+8>>2]=D[I+8>>2],D[A+12>>2]=g,g=D[I+20>>2],D[A+16>>2]=D[I+16>>2],D[A+20>>2]=g,D[A+60>>2]=D[I+60>>2],(C=D[I>>2])?(g=0,(Q=D[A>>2])&&(Hg(Q,g=D[C>>2],D[C+4>>2]-g|0,0),g=1)):(D[A>>2]=0,g=1);I:if(g){B[A+84|0]=e[I+84|0],D[A+80>>2]=D[I+80>>2],(0|A)!=(0|I)&&SI(A+68|0,D[I+68>>2],D[I+72>>2]);g:{if(C=D[I+88>>2]){if(I=DC(40),g=D[C>>2],D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I>>2]=g,Q=D[C+12>>2]-D[C+8>>2]|0){if((0|Q)<0)break A;g=DC(Q),D[I+8>>2]=g,D[I+12>>2]=g,D[I+16>>2]=g+Q,(0|(Q=D[C+12>>2]-(E=D[C+8>>2])|0))>0&&(g=xA(g,E,Q)+Q|0),D[I+12>>2]=g}if(g=D[C+36>>2],D[I+32>>2]=D[C+32>>2],D[I+36>>2]=g,g=D[C+28>>2],D[I+24>>2]=D[C+24>>2],D[I+28>>2]=g,g=D[A+88>>2],D[A+88>>2]=I,g)break g;break I}if(g=D[A+88>>2],D[A+88>>2]=0,!g)break I}(A=D[g+8>>2])&&(D[g+12>>2]=A,sA(A)),sA(g)}return}iQ(),U()}function dA(A,I,g,C){var Q=0,E=0,i=0,o=0,a=0,r=0;if(!((0|(o=C-g|0))<=0)){A:{if((0|o)<=((E=D[A+8>>2])-(a=D[A+4>>2])|0)){if((0|(r=a-I|0))>=(0|o)){i=a,E=C;break A}if(i=a,(0|(E=g+r|0))!=(0|C))for(Q=E;B[0|i]=e[0|Q],i=i+1|0,(0|(Q=Q+1|0))!=(0|C););if(D[A+4>>2]=i,(0|r)>0)break A;return}if((0|(C=o+(a-(Q=D[A>>2])|0)|0))>=0){if(r=(E=E-Q|0)<<1,g=xA((i=I-Q|0)+(C=(E=E>>>0<1073741823?C>>>0>r>>>0?C:r:2147483647)?DC(E):0)|0,g,o),(0|i)>0&&xA(C,Q,i),g=g+o|0,(0|I)!=(0|a)){if(i=(-1^I)+a|0,o=a-I&7)for(Q=0;B[0|g]=e[0|I],g=g+1|0,I=I+1|0,(0|o)!=(0|(Q=Q+1|0)););if(i>>>0>=7)for(;B[0|g]=e[0|I],B[g+1|0]=e[I+1|0],B[g+2|0]=e[I+2|0],B[g+3|0]=e[I+3|0],B[g+4|0]=e[I+4|0],B[g+5|0]=e[I+5|0],B[g+6|0]=e[I+6|0],B[g+7|0]=e[I+7|0],g=g+8|0,(0|a)!=(0|(I=I+8|0)););Q=D[A>>2]}return D[A+8>>2]=C+E,D[A+4>>2]=g,D[A>>2]=C,void(Q&&sA(Q))}iQ(),U()}if(a>>>0>(C=(Q=i)-o|0)>>>0)for(;B[0|Q]=e[0|C],Q=Q+1|0,a>>>0>(C=C+1|0)>>>0;);if(D[A+4>>2]=Q,(A=i-(I+o|0)|0)&&RI(i-A|0,I,A),(0|g)!=(0|E)){if(A=(-1^g)+E|0,i=E-g&7)for(C=0,Q=I;B[0|Q]=e[0|g],Q=Q+1|0,g=g+1|0,(0|i)!=(0|(C=C+1|0)););else Q=I;if(!(A>>>0<7))for(;B[0|Q]=e[0|g],B[Q+1|0]=e[g+1|0],B[Q+2|0]=e[g+2|0],B[Q+3|0]=e[g+3|0],B[Q+4|0]=e[g+4|0],B[Q+5|0]=e[g+5|0],B[Q+6|0]=e[g+6|0],B[Q+7|0]=e[g+7|0],Q=Q+8|0,(0|E)!=(0|(g=g+8|0)););}}}function uA(A,I,g,C){A|=0,C|=0;var Q,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0;d=Q=d-16|0,E=s(a=D[80+(I|=0)>>2],A=B[24+(g|=0)|0]);A:{I:{if(!(5==(0|(I=D[g+28>>2]))|6==(0|I))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,A){if((0|A)<0)break I;o=DC(I=A<<2),D[Q>>2]=o,D[Q+8>>2]=i=I+o|0,bI(o,0,I),D[Q+4>>2]=i}(I=D[C+4>>2]-(i=D[C>>2])>>2)>>>0<E>>>0?$I(C,E-I|0):I>>>0<=E>>>0||(D[C+4>>2]=i+(E<<2));g:if(a)if(A){for(n=-4&A,N=3&A,R=A-1>>>0<3,I=1,E=0;;){if(DA(g,e[g+84|0]?E:D[D[g+68>>2]+(E<<2)>>2],B[g+24|0],o)){if(F=D[C>>2],t=0,i=D[Q>>2],A=0,I=0,!R)for(;D[(f=(r<<2)+F|0)>>2]=D[i+(k=A<<2)>>2],D[f+4>>2]=D[i+(4|k)>>2],D[f+8>>2]=D[i+(8|k)>>2],D[f+12>>2]=D[i+(12|k)>>2],A=A+4|0,r=r+4|0,(0|n)!=(0|(I=I+4|0)););if(N)for(;D[(r<<2)+F>>2]=D[i+(A<<2)>>2],A=A+1|0,r=r+1|0,(0|(t=t+1|0))!=(0|N););if(I=a>>>0>(E=E+1|0)>>>0,(0|E)!=(0|a))continue}break}o=D[Q>>2]}else for(A=0,I=1;;){if(!DA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],o))break g;if(I=a>>>0>(A=A+1|0)>>>0,(0|A)==(0|a))break}else I=0;o&&sA(o),A=1^I}else{if(o=D[g+48>>2],a=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,g=0,A=E<<2){if((0|A)<0)break I;r=(I=xA(g=DC(A),o+a|0,A))+A|0,I=I+(A>>2<<2)|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=r,D[C>>2]=g,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}return 0|A}function pA(A,I){A|=0,I|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0;d=g=d-32|0,D[g+28>>2]=0;A:{if(f[I+38>>1]<=513){if(C=D[I+20>>2],(0|(E=D[I+12>>2]))<=(0|(C=(o=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C))&o>>>0>k[I+8>>2]|(0|C)>(0|E))break A;Q=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=o,D[I+20>>2]=C}else{if(!ng(1,g+28|0,I))break A;Q=D[g+28>>2]}if(Q&&(BI(A+76|0,Q),D[(C=g+8|0)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,TA(C,I))){for(E=1;i=1<<a,r=ug(C),o=D[A+76>>2]+(a>>>3&536870908)|0,1&(E^=r)?i=D[o>>2]&(-1^i):i|=D[o>>2],E^=1,D[o>>2]=i,(0|(a=a+1|0))!=(0|Q););a=0,o=Q=D[I+12>>2],E=C=D[I+20>>2],(t=D[I+8>>2])>>>0<(r=(i=D[I+16>>2])+4|0)>>>0&(0|(C=r>>>0<4?C+1|0:C))>=(0|Q)|(0|C)>(0|Q)||(Q=e[0|(Q=(N=D[I>>2])+i|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=r,D[I+20>>2]=C,C=E,i=E=i+8|0,E=C=E>>>0<8?C+1|0:C,i>>>0>t>>>0&(0|C)>=(0|o)|(0|C)>(0|o)||(C=e[0|(C=r+N|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=E,(0|C)<(0|Q)||(D[A+16>>2]=C,D[A+12>>2]=Q,!(I=(C>>31)-((Q>>31)+(C>>>0<Q>>>0)|0)|0)&(C=C-Q|0)>>>0>2147483646|I||(a=1,D[A+20>>2]=I=C+1|0,D[A+24>>2]=C=I>>>1|0,D[A+28>>2]=0-C,1&I||(D[A+24>>2]=C-1)))))}}return d=g+32|0,0|a}function HA(A,I){var g=0,C=0,Q=0,B=0,E=0;C=-1,B=-1,-1!=(0|I)&&(C=((g=I+1|0)>>>0)%3|0?g:I-2|0,B=I-1|0,(I>>>0)%3|0||(B=I+2|0));A:{I:{g:{C:{Q:{B:switch(0|(Q=D[A+184>>2])){case 7:break g;case 3:break C;case 5:break Q;case 0:case 1:break B;default:break A}E=D[A+148>>2],g=-1,Q=1,D[(C=(C=(-1!=(0|C)?D[D[E>>2]+(C<<2)>>2]:g)<<2)+(g=D[A+156>>2])|0)>>2]=D[C>>2]+1,g=((-1!=(0|B)?D[D[E>>2]+(B<<2)>>2]:-1)<<2)+g|0;break I}E=D[A+148>>2],D[(Q=(g=D[A+156>>2])+((-1!=(0|I)?D[D[E>>2]+(I<<2)>>2]:-1)<<2)|0)>>2]=D[Q>>2]+1,D[(C=((-1!=(0|C)?D[D[E>>2]+(C<<2)>>2]:-1)<<2)+g|0)>>2]=D[C>>2]+1,Q=2,g=((-1!=(0|B)?D[D[E>>2]+(B<<2)>>2]:-1)<<2)+g|0;break I}E=D[A+148>>2],D[(Q=(g=D[A+156>>2])+((-1!=(0|I)?D[D[E>>2]+(I<<2)>>2]:-1)<<2)|0)>>2]=D[Q>>2]+1,D[(C=((-1!=(0|C)?D[D[E>>2]+(C<<2)>>2]:-1)<<2)+g|0)>>2]=D[C>>2]+2,Q=1,g=((-1!=(0|B)?D[D[E>>2]+(B<<2)>>2]:-1)<<2)+g|0;break I}E=D[A+148>>2],D[(Q=(g=D[A+156>>2])+((-1!=(0|I)?D[D[E>>2]+(I<<2)>>2]:-1)<<2)|0)>>2]=D[Q>>2]+2,D[(C=((-1!=(0|C)?D[D[E>>2]+(C<<2)>>2]:-1)<<2)+g|0)>>2]=D[C>>2]+2,Q=2,g=((-1!=(0|B)?D[D[E>>2]+(B<<2)>>2]:-1)<<2)+g|0}D[g>>2]=D[g>>2]+Q,Q=D[A+184>>2]}A:switch(0|Q){case 0:case 5:return g=-1,-1!=(0|I)&&(g=-1,-1!=(0|(I=((C=I+1|0)>>>0)%3|0?C:I-2|0))&&(g=D[D[D[A+148>>2]>>2]+(I<<2)>>2])),D[(B=D[A+156>>2])+(g<<2)>>2]<=5?void(D[A+188>>2]=5):void(D[A+188>>2]=0)}D[A+188>>2]=-1}function qA(A){var I,g=0,C=0,Q=0,B=0;if(D[(A|=0)>>2]=11512,(g=D[196+(I=A+232|0)>>2])&&(D[I+200>>2]=g,sA(g)),C=D[I+184>>2]){if((0|C)==(0|(g=D[I+188>>2])))g=C;else{for(;(B=D[(Q=g-12|0)>>2])&&(D[g-8>>2]=B,sA(B)),(0|C)!=(0|(g=Q)););g=D[I+184>>2]}D[I+188>>2]=C,sA(g)}if((g=D[I+156>>2])&&(D[I+160>>2]=g,sA(g)),C=D[I+136>>2],D[I+136>>2]=0,C){if(g=D[(Q=C-4|0)>>2])for(g=C+(g<<4)|0;(0|C)!=(0|(g=g-16|0)););sA(Q)}if(C=D[A+216>>2]){if((0|C)==(0|(g=D[A+220>>2])))g=C;else{for(;(Q=D[g-12>>2])&&(D[g-8>>2]=Q,sA(Q)),(Q=D[g-28>>2])&&(D[g-24>>2]=Q,sA(Q)),(Q=D[g-40>>2])&&(D[g-36>>2]=Q,sA(Q)),Mg(g-140|0),(0|C)!=(0|(g=g-144|0)););g=D[A+216>>2]}D[A+220>>2]=C,sA(g)}if((g=D[A+196>>2])&&(D[A+200>>2]=g,sA(g)),(g=D[A+184>>2])&&(D[A+188>>2]=g,sA(g)),(g=D[A+172>>2])&&(D[A+176>>2]=g,sA(g)),(g=D[A+160>>2])&&(D[A+164>>2]=g,sA(g)),g=D[A+144>>2])for(;C=D[g>>2],sA(g),g=C;);return g=D[A+136>>2],D[A+136>>2]=0,g&&sA(g),(g=D[A+120>>2])&&sA(g),(g=D[A+108>>2])&&sA(g),(g=D[A+96>>2])&&sA(g),(g=D[A+72>>2])&&(D[A+76>>2]=g,sA(g)),(g=D[A+60>>2])&&sA(g),(g=D[A+48>>2])&&(D[A+52>>2]=g,sA(g)),(g=D[A+36>>2])&&(D[A+40>>2]=g,sA(g)),(g=D[A+24>>2])&&(D[A+28>>2]=g,sA(g)),(g=D[A+12>>2])&&(D[A+16>>2]=g,sA(g)),g=D[A+8>>2],D[A+8>>2]=0,g&&Yg(g),0|A}function WA(A,I){A|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0;if(d=g=d-16|0,C=D[20+(I|=0)>>2],!((0|(E=D[I+12>>2]))<=(0|(C=(o=(Q=D[I+16>>2])+4|0)>>>0<4?C+1|0:C))&o>>>0>k[I+8>>2]|(0|C)>(0|E))&&(Q=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=o,D[I+20>>2]=C,!((0|Q)<0)&&(BI(A+76|0,Q),D[(C=g)>>2]=0,D[C+4>>2]=0,B[C+5|0]=0,B[C+6|0]=0,B[C+7|0]=0,B[C+8|0]=0,B[C+9|0]=0,B[C+10|0]=0,B[C+11|0]=0,B[C+12|0]=0,TA(C,I)))){if(Q)for(E=1;i=1<<a,r=ug(C),o=D[A+76>>2]+(a>>>3&536870908)|0,1&(E^=r)?i=D[o>>2]&(-1^i):i|=D[o>>2],E^=1,D[o>>2]=i,(0|Q)!=(0|(a=a+1|0)););a=0,o=Q=D[I+12>>2],E=C=D[I+20>>2],(f=D[I+8>>2])>>>0<(r=(i=D[I+16>>2])+4|0)>>>0&(0|(C=r>>>0<4?C+1|0:C))>=(0|Q)|(0|C)>(0|Q)||(Q=e[0|(Q=(t=D[I>>2])+i|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=r,D[I+20>>2]=C,C=E,i=E=i+8|0,E=C=E>>>0<8?C+1|0:C,i>>>0>f>>>0&(0|C)>=(0|o)|(0|C)>(0|o)||(C=e[0|(C=r+t|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=E,(0|C)<(0|Q)||(D[A+16>>2]=C,D[A+12>>2]=Q,!(I=(C>>31)-((Q>>31)+(C>>>0<Q>>>0)|0)|0)&(C=C-Q|0)>>>0>2147483646|I||(a=1,D[A+20>>2]=I=C+1|0,D[A+24>>2]=C=I>>>1|0,D[A+28>>2]=0-C,1&I||(D[A+24>>2]=C-1)))))}return d=g+16|0,0|a}function VA(A,I){var g=0,C=0,Q=0,B=0,E=0;B=-1,C=-1,-1!=(0|I)&&(B=((C=I+1|0)>>>0)%3|0?C:I-2|0,C=I-1|0,(I>>>0)%3|0||(C=I+2|0));A:{I:{g:switch(D[A+168>>2]){case 0:case 1:Q=D[A+148>>2],g=1,D[(E=(I=D[A+156>>2])+((-1!=(0|B)?D[D[Q>>2]+(B<<2)>>2]:-1)<<2)|0)>>2]=D[E>>2]+1,I=((-1!=(0|C)?D[D[Q>>2]+(C<<2)>>2]:-1)<<2)+I|0;break I;case 5:Q=D[A+148>>2],g=-1,D[(g=(g=(-1!=(0|I)?D[D[Q>>2]+(I<<2)>>2]:g)<<2)+(I=D[A+156>>2])|0)>>2]=D[g>>2]+1,D[(g=((-1!=(0|B)?D[D[Q>>2]+(B<<2)>>2]:-1)<<2)+I|0)>>2]=D[g>>2]+1,g=2,I=((-1!=(0|C)?D[D[Q>>2]+(C<<2)>>2]:-1)<<2)+I|0;break I;case 3:Q=D[A+148>>2],g=-1,D[(g=(g=(-1!=(0|I)?D[D[Q>>2]+(I<<2)>>2]:g)<<2)+(I=D[A+156>>2])|0)>>2]=D[g>>2]+1,D[(g=((-1!=(0|B)?D[D[Q>>2]+(B<<2)>>2]:-1)<<2)+I|0)>>2]=D[g>>2]+2,g=1,I=((-1!=(0|C)?D[D[Q>>2]+(C<<2)>>2]:-1)<<2)+I|0;break I;case 7:break g;default:break A}Q=D[A+148>>2],g=-1,D[(g=(g=(-1!=(0|I)?D[D[Q>>2]+(I<<2)>>2]:g)<<2)+(I=D[A+156>>2])|0)>>2]=D[g>>2]+2,D[(g=((-1!=(0|B)?D[D[Q>>2]+(B<<2)>>2]:-1)<<2)+I|0)>>2]=D[g>>2]+2,g=2,I=((-1!=(0|C)?D[D[Q>>2]+(C<<2)>>2]:-1)<<2)+I|0}D[I>>2]=D[I>>2]+g}C=D[A+180>>2],I=D[D[A+156>>2]+((-1!=(0|B)?D[D[D[A+148>>2]>>2]+(B<<2)>>2]:-1)<<2)>>2],D[(g=A)+172>>2]=(0|(A=D[A+176>>2]))>(0|I)?0:((0|I)>(0|C)?C:I)-A|0}function _A(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;if((C=D[A+8>>2])-(Q=D[A>>2])>>2>>>0>=I>>>0){if(B=I>>>0>(i=(E=D[A+4>>2])-Q>>2)>>>0?i:I){if(r=B-1|0,o=7&B)for(C=Q;D[C>>2]=D[g>>2],B=B-1|0,C=C+4|0,(0|(a=a+1|0))!=(0|o););else C=Q;if(!(r>>>0<7))for(;D[C>>2]=D[g>>2],D[C+4>>2]=D[g>>2],D[C+8>>2]=D[g>>2],D[C+12>>2]=D[g>>2],D[C+16>>2]=D[g>>2],D[C+20>>2]=D[g>>2],D[C+24>>2]=D[g>>2],D[C+28>>2]=D[g>>2],C=C+32|0,B=B-8|0;);}if(I>>>0>i>>>0){if(C=A,A=I-i|0)for(A=(A<<2)+E|0;D[E>>2]=D[g>>2],(0|A)!=(0|(E=E+4|0)););else A=E;return void(D[C+4>>2]=A)}D[A+4>>2]=Q+(I<<2)}else if(Q&&(D[A+4>>2]=Q,sA(Q),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,C=0),I>>>0>=1073741824||(Q=C>>1,(C=C>>2>>>0<536870911?I>>>0>Q>>>0?I:Q:1073741823)>>>0>=1073741824))iQ(),U();else{if(Q=DC(C<<=2),D[A>>2]=Q,D[A+8>>2]=C+Q,g=D[g>>2],C=Q,i=1+((E=(I<<=2)-4|0)>>>2|0)&7)for(;D[C>>2]=g,C=C+4|0,(0|i)!=(0|(B=B+1|0)););if(I=I+Q|0,E>>>0>=28)for(;D[C+28>>2]=g,D[C+24>>2]=g,D[C+20>>2]=g,D[C+16>>2]=g,D[C+12>>2]=g,D[C+8>>2]=g,D[C+4>>2]=g,D[C>>2]=g,(0|I)!=(0|(C=C+32|0)););D[A+4>>2]=I}}function TA(A,I){var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0;d=g=d-16|0;A:if(!((0|(E=D[I+20>>2]))>=(0|(C=D[I+12>>2]))&(i=D[I+16>>2])>>>0>=k[I+8>>2]|(0|C)<(0|E))){if(B[A+12|0]=e[i+D[I>>2]|0],C=E=D[I+20>>2],E=(Q=(i=D[I+16>>2])+1|0)?C:C+1|0,a=Q,D[I+16>>2]=Q,D[I+20>>2]=E,f[I+38>>1]<=513){if(E=C,i=C=i+5|0,(Q=D[I+8>>2])>>>0<C>>>0&(0|(E=C>>>0<5?E+1|0:E))>=(0|(o=D[I+12>>2]))|(0|E)>(0|o))break A;C=e[0|(C=a+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=E}else{if(!function A(I,g,C){var Q=0,B=0,E=0,i=0,o=0;I:if(!(I>>>0>5||(0|(Q=E=D[C+20>>2]))>=(0|(i=D[C+12>>2]))&(B=D[C+16>>2])>>>0>=k[C+8>>2]|(0|Q)>(0|i))){if(Q=e[B+D[C>>2]|0],E=(B=B+1|0)?E:E+1|0,D[C+16>>2]=B,D[C+20>>2]=E,128&Q){if(!A(I+1|0,g,C))break I;Q=127&Q|D[g>>2]<<7}D[g>>2]=Q,o=1}return o}(1,g+12|0,I))break A;i=D[I+16>>2],E=D[I+20>>2],Q=D[I+8>>2],o=D[I+12>>2],C=D[g+12>>2]}if(a=Q-i|0,!((0|(Q=o-(E+(Q>>>0<i>>>0)|0)|0))<=0&C>>>0>a>>>0|(0|Q)<0|(0|C)<=0)){D[A>>2]=Q=i+D[I>>2]|0,t=A;I:if((r=e[0|(a=(o=C-1|0)+Q|0)])>>>0<=63)D[A+4>>2]=o,A=63&e[0|a];else{g:switch((r>>>6|0)-1|0){case 0:if(C>>>0<2)break A;D[A+4>>2]=C-2,A=e[1+(Q=(C+Q|0)-2|0)|0]<<8&16128|e[0|Q];break I;case 1:break g;default:break A}if(C>>>0<3)break A;D[A+4>>2]=C-3,A=e[2+(Q=(C+Q|0)-3|0)|0]<<16&4128768|e[Q+1|0]<<8|e[0|Q]}D[t+8>>2]=A=A+4096|0,A>>>0>1048575||(E=(A=C+i|0)>>>0<C>>>0?E+1|0:E,D[I+16>>2]=A,D[I+20>>2]=E,N=1)}}return d=g+16|0,N}function mA(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;d=g=d-16|0;A:{if(f[I+38>>1]<=511){if(o=i=D[I+12>>2],C=D[I+20>>2],(B=D[I+8>>2])>>>0<(E=(Q=D[I+16>>2])+8|0)>>>0&(0|(C=E>>>0<8?C+1|0:C))>=(0|i)|(0|C)>(0|i))break A;i=e[0|(Q=Q+D[I>>2]|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,Q=e[Q+4|0]|e[Q+5|0]<<8|e[Q+6|0]<<16|e[Q+7|0]<<24,D[I+16>>2]=E,D[I+20>>2]=C}else{if(!ag(1,g+8|0,I))break A;E=D[I+16>>2],C=D[I+20>>2],B=D[I+8>>2],o=D[I+12>>2],i=D[g+8>>2],Q=D[g+12>>2]}if(a=B-E|0,!((0|(B=o-(C+(E>>>0>B>>>0)|0)|0))==(0|Q)&i>>>0>a>>>0|Q>>>0>B>>>0||(C=C+Q|0,C=(B=E+i|0)>>>0<E>>>0?C+1|0:C,D[I+16>>2]=B,D[I+20>>2]=C,(0|(C=i))<=0))){D[A+40>>2]=I=E+D[I>>2]|0,o=A;I:if((B=e[0|(i=I+(E=C-1|0)|0)])>>>0<=63)D[A+44>>2]=E,A=63&e[0|i];else{g:switch((B>>>6|0)-1|0){case 0:if(C>>>0<2)break A;D[A+44>>2]=C-2,A=e[1+(I=(I+C|0)-2|0)|0]<<8&16128|e[0|I];break I;case 1:if(C>>>0<3)break A;D[A+44>>2]=C-3,A=e[2+(I=(I+C|0)-3|0)|0]<<16&4128768|e[I+1|0]<<8|e[0|I];break I}D[A+44>>2]=C-4,A=e[2+(I=(I+C|0)-4|0)|0]<<16|e[I+3|0]<<24&1056964608|e[I+1|0]<<8|e[0|I]}D[o+48>>2]=A=A+16384|0,r=A>>>0<4194304}}return d=g+16|0,r}function ZA(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;if((B=D[A+8>>2])-(Q=D[A+4>>2])>>2>>>0>=I>>>0){if(I){if(C=Q,i=1+((E=(I<<2)-4|0)>>>2|0)&7)for(;D[C>>2]=D[g>>2],C=C+4|0,(0|i)!=(0|(o=o+1|0)););if(Q=(I<<2)+Q|0,!(E>>>0<28))for(;D[C>>2]=D[g>>2],D[C+4>>2]=D[g>>2],D[C+8>>2]=D[g>>2],D[C+12>>2]=D[g>>2],D[C+16>>2]=D[g>>2],D[C+20>>2]=D[g>>2],D[C+24>>2]=D[g>>2],D[C+28>>2]=D[g>>2],(0|Q)!=(0|(C=C+32|0)););}D[A+4>>2]=Q}else{A:{if((C=(Q=(r=Q-(E=D[A>>2])|0)>>2)+I|0)>>>0<1073741824){if(a=(B=B-E|0)>>1,B=B>>2>>>0<536870911?C>>>0>a>>>0?C:a:1073741823){if(B>>>0>=1073741824)break A;i=DC(B<<2)}if(C=Q=(Q<<2)+i|0,e=1+((a=(I<<=2)-4|0)>>>2|0)&7)for(C=Q;D[C>>2]=D[g>>2],C=C+4|0,(0|e)!=(0|(o=o+1|0)););if(I=I+Q|0,a>>>0>=28)for(;D[C>>2]=D[g>>2],D[C+4>>2]=D[g>>2],D[C+8>>2]=D[g>>2],D[C+12>>2]=D[g>>2],D[C+16>>2]=D[g>>2],D[C+20>>2]=D[g>>2],D[C+24>>2]=D[g>>2],D[C+28>>2]=D[g>>2],(0|I)!=(0|(C=C+32|0)););return(0|r)>0&&xA(i,E,r),D[A+8>>2]=(B<<2)+i,D[A+4>>2]=I,D[A>>2]=i,void(E&&sA(E))}iQ(),U()}xg(1336),U()}}function xA(A,I,g){var C,Q=0,E=0;if(g>>>0>=512)return Y(0|A,0|I,0|g),A;C=A+g|0;A:if(3&(A^I))if(C>>>0<4)g=A;else if((Q=C-4|0)>>>0<A>>>0)g=A;else for(g=A;B[0|g]=e[0|I],B[g+1|0]=e[I+1|0],B[g+2|0]=e[I+2|0],B[g+3|0]=e[I+3|0],I=I+4|0,Q>>>0>=(g=g+4|0)>>>0;);else{I:if(3&A)if(g)for(g=A;;){if(B[0|g]=e[0|I],I=I+1|0,!(3&(g=g+1|0)))break I;if(!(g>>>0<C>>>0))break}else g=A;else g=A;if(!((Q=-4&C)>>>0<64||(E=Q+-64|0)>>>0<g>>>0))for(;D[g>>2]=D[I>>2],D[g+4>>2]=D[I+4>>2],D[g+8>>2]=D[I+8>>2],D[g+12>>2]=D[I+12>>2],D[g+16>>2]=D[I+16>>2],D[g+20>>2]=D[I+20>>2],D[g+24>>2]=D[I+24>>2],D[g+28>>2]=D[I+28>>2],D[g+32>>2]=D[I+32>>2],D[g+36>>2]=D[I+36>>2],D[g+40>>2]=D[I+40>>2],D[g+44>>2]=D[I+44>>2],D[g+48>>2]=D[I+48>>2],D[g+52>>2]=D[I+52>>2],D[g+56>>2]=D[I+56>>2],D[g+60>>2]=D[I+60>>2],I=I- -64|0,E>>>0>=(g=g- -64|0)>>>0;);if(g>>>0>=Q>>>0)break A;for(;D[g>>2]=D[I>>2],I=I+4|0,Q>>>0>(g=g+4|0)>>>0;);}if(g>>>0<C>>>0)for(;B[0|g]=e[0|I],I=I+1|0,(0|C)!=(0|(g=g+1|0)););return A}function XA(A){var I,g=0,C=0,Q=0;if(D[(A|=0)>>2]=11464,(g=D[A+388>>2])&&(D[A+392>>2]=g,sA(g)),I=D[A+368>>2],D[A+368>>2]=0,I){if(g=D[(Q=I-4|0)>>2])for(C=(g<<4)+I|0;(0|I)!=(0|(C=C-16|0)););sA(Q)}if(Q=D[A+216>>2]){if((0|Q)==(0|(C=D[A+220>>2])))g=Q;else{for(;(g=D[C-12>>2])&&(D[C-8>>2]=g,sA(g)),(g=D[C-28>>2])&&(D[C-24>>2]=g,sA(g)),(g=D[C-40>>2])&&(D[C-36>>2]=g,sA(g)),Mg(C-140|0),(0|Q)!=(0|(C=C-144|0)););g=D[A+216>>2]}D[A+220>>2]=Q,sA(g)}if((g=D[A+196>>2])&&(D[A+200>>2]=g,sA(g)),(g=D[A+184>>2])&&(D[A+188>>2]=g,sA(g)),(g=D[A+172>>2])&&(D[A+176>>2]=g,sA(g)),(g=D[A+160>>2])&&(D[A+164>>2]=g,sA(g)),C=D[A+144>>2])for(;g=D[C>>2],sA(C),C=g,g;);return g=D[A+136>>2],D[A+136>>2]=0,g&&sA(g),(g=D[A+120>>2])&&sA(g),(g=D[A+108>>2])&&sA(g),(g=D[A+96>>2])&&sA(g),(g=D[A+72>>2])&&(D[A+76>>2]=g,sA(g)),(g=D[A+60>>2])&&sA(g),(g=D[A+48>>2])&&(D[A+52>>2]=g,sA(g)),(g=D[A+36>>2])&&(D[A+40>>2]=g,sA(g)),(g=D[A+24>>2])&&(D[A+28>>2]=g,sA(g)),(g=D[A+12>>2])&&(D[A+16>>2]=g,sA(g)),g=D[A+8>>2],D[A+8>>2]=0,g&&Yg(g),0|A}function jA(A,I){var g,C,Q=0,E=0,i=0;d=g=d-16|0,D[A+12>>2]=I,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,D[(Q=A+16|0)>>2]=0,D[Q+4>>2]=0,B[Q+5|0]=0,B[Q+6|0]=0,B[Q+7|0]=0,B[Q+8|0]=0,B[Q+9|0]=0,B[Q+10|0]=0,B[Q+11|0]=0,B[Q+12|0]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+48>>2]=0,D[A+40>>2]=0,D[A+44>>2]=0,D[A+52>>2]=0,D[A+56>>2]=0,D[A+68>>2]=0,D[A+60>>2]=0,D[A+64>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+88>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+100>>2]=0,D[A+92>>2]=0,D[A+96>>2]=0,C=A+116|0;A:{I:{if(I){if(I>>>0<1073741824)break I;iQ(),U()}D[A+104>>2]=0,D[A+108>>2]=0,D[A+112>>2]=0,D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,Q=1;break A}E=DC(Q=I<<2),D[A+92>>2]=E,D[A+100>>2]=i=Q+E|0,bI(E,0,Q),D[A+112>>2]=0,D[A+104>>2]=0,D[A+108>>2]=0,D[A+96>>2]=i,E=DC(Q),D[A+104>>2]=E,D[A+112>>2]=i=Q+E|0,bI(E,0,Q),D[A+108>>2]=i,E=DC(Q),D[g>>2]=E,D[g+8>>2]=i=Q+E|0,bI(E,0,Q),D[g+4>>2]=i,Q=I<<5|1}return uI(C,Q,g),(E=D[g>>2])&&(D[g+4>>2]=E,sA(E)),D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,I&&(E=DC(I<<=2),D[g>>2]=E,D[g+8>>2]=i=I+E|0,bI(E,0,I),D[g+4>>2]=i),uI(A+128|0,Q,g),(I=D[g>>2])&&(D[g+4>>2]=I,sA(I)),d=g+16|0,A}function OA(A){var I,g=0,C=0,Q=0;if(D[(A|=0)>>2]=11412,I=D[A+368>>2],D[A+368>>2]=0,I){if(g=D[(Q=I-4|0)>>2])for(C=(g<<4)+I|0;(0|I)!=(0|(C=C-16|0)););sA(Q)}if(Q=D[A+216>>2]){if((0|Q)==(0|(C=D[A+220>>2])))g=Q;else{for(;(g=D[C-12>>2])&&(D[C-8>>2]=g,sA(g)),(g=D[C-28>>2])&&(D[C-24>>2]=g,sA(g)),(g=D[C-40>>2])&&(D[C-36>>2]=g,sA(g)),Mg(C-140|0),(0|Q)!=(0|(C=C-144|0)););g=D[A+216>>2]}D[A+220>>2]=Q,sA(g)}if((g=D[A+196>>2])&&(D[A+200>>2]=g,sA(g)),(g=D[A+184>>2])&&(D[A+188>>2]=g,sA(g)),(g=D[A+172>>2])&&(D[A+176>>2]=g,sA(g)),(g=D[A+160>>2])&&(D[A+164>>2]=g,sA(g)),C=D[A+144>>2])for(;g=D[C>>2],sA(C),C=g,g;);return g=D[A+136>>2],D[A+136>>2]=0,g&&sA(g),(g=D[A+120>>2])&&sA(g),(g=D[A+108>>2])&&sA(g),(g=D[A+96>>2])&&sA(g),(g=D[A+72>>2])&&(D[A+76>>2]=g,sA(g)),(g=D[A+60>>2])&&sA(g),(g=D[A+48>>2])&&(D[A+52>>2]=g,sA(g)),(g=D[A+36>>2])&&(D[A+40>>2]=g,sA(g)),(g=D[A+24>>2])&&(D[A+28>>2]=g,sA(g)),(g=D[A+12>>2])&&(D[A+16>>2]=g,sA(g)),g=D[A+8>>2],D[A+8>>2]=0,g&&Yg(g),0|A}function vA(A,I,g,C){var Q,B=0,E=0,i=0,o=0,a=0,r=0,D=0,e=0;Q=g;A:{I:{g:{C:{Q:{B:{E:{i:{o:{a:{r:{if(I){if(!Q)break r;if(!C)break a;if((g=R(C)-R(I)|0)>>>0<=31)break o;break g}if(1==(0|C)|C>>>0>1)break g;A=(A>>>0)/(Q>>>0)|0,u=0;break A}if(!A)break i;if(!C)break E;if(C-1&C)break E;A=I>>>lC(C)|0,u=0;break A}if(!(Q-1&Q))break B;B=0-(i=(R(Q)+33|0)-R(I)|0)|0;break C}i=g+1|0,B=63-g|0;break C}A=(I>>>0)/(C>>>0)|0,u=0;break A}if((g=R(C)-R(I)|0)>>>0<31)break Q;break g}if(1==(0|Q))break I;C=31&(g=lC(Q)),(63&g)>>>0>=32?(g=0,A=I>>>C|0):(g=I>>>C|0,A=((1<<C)-1&I)<<32-C|A>>>C),u=g;break A}i=g+1|0,B=63-g|0}if(E=31&(g=63&i),g>>>0>=32?(g=0,a=I>>>E|0):(g=I>>>E|0,a=((1<<E)-1&I)<<32-E|A>>>E),E=g,B=31&(g=63&B),g>>>0>=32?(g=A<<B,A=0):(g=(1<<B)-1&A>>>32-B|I<<B,A<<=B),I=g,i)for(g=C-1|0,D=-1!=(0|(B=Q-1|0))?g+1|0:g;a=(g=a<<1|I>>>31)-(r=Q&(o=D-((E=E<<1|a>>>31)+(g>>>0>B>>>0)|0)>>31))|0,E=E-((C&o)+(g>>>0<r>>>0)|0)|0,I=I<<1|A>>>31,A=e|A<<1,e=o&=1,i=i-1|0;);u=I<<1|A>>>31,A=o|A<<1;break A}A=0,I=0}u=I}return A}function zA(A,I){var g,C,Q=0,B=0,E=0;d=g=d-16|0,D[A+12>>2]=I,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+32>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,D[A+36>>2]=0,D[A+40>>2]=0,D[A+52>>2]=0,D[A+44>>2]=0,D[A+48>>2]=0,D[A+56>>2]=0,D[A+60>>2]=0,D[A+72>>2]=0,D[A+64>>2]=0,D[A+68>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+92>>2]=0,D[A+84>>2]=0,D[A+88>>2]=0,D[A+104>>2]=0,D[A+96>>2]=0,D[A+100>>2]=0,C=A+120|0;A:{I:{if(I){if(I>>>0<1073741824)break I;iQ(),U()}D[A+108>>2]=0,D[A+112>>2]=0,D[A+116>>2]=0,D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,B=1;break A}Q=DC(B=I<<2),D[A+96>>2]=Q,D[A+104>>2]=E=Q+B|0,bI(Q,0,B),D[A+116>>2]=0,D[A+108>>2]=0,D[A+112>>2]=0,D[A+100>>2]=E,Q=DC(B),D[A+108>>2]=Q,D[A+116>>2]=E=Q+B|0,bI(Q,0,B),D[A+112>>2]=E,Q=DC(B),D[g>>2]=Q,D[g+8>>2]=E=Q+B|0,bI(Q,0,B),D[g+4>>2]=E,B=I<<5|1}return uI(C,B,g),(Q=D[g>>2])&&(D[g+4>>2]=Q,sA(Q)),D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,I&&(Q=DC(I<<=2),D[g>>2]=Q,D[g+8>>2]=E=I+Q|0,bI(Q,0,I),D[g+4>>2]=E),uI(A+132|0,B,g),(I=D[g>>2])&&(D[g+4>>2]=I,sA(I)),d=g+16|0,A}function PA(A,I){var g=0,C=0,Q=0;B[I+12|0]=g=(0|A)==(0|I);A:if(!g)for(;;){if(e[(C=D[I+8>>2])+12|0])break A;I:{if((0|C)!=(0|(Q=D[(g=D[C+8>>2])>>2]))){if(!(e[Q+12|0]|!Q))break I;D[C>>2]==(0|I)?(D[C>>2]=A=D[I+4>>2],A&&(D[A+8>>2]=C,g=D[C+8>>2]),D[I+8>>2]=g,D[(((0|C)!=D[(A=D[C+8>>2])>>2])<<2)+A>>2]=I,D[I+4>>2]=C,D[C+8>>2]=I,g=D[I+8>>2]):I=C,B[I+12|0]=1,B[g+12|0]=0,D[g+4>>2]=I=D[(A=D[g+4>>2])>>2],I&&(D[I+8>>2]=g),D[A+8>>2]=D[g+8>>2],D[((D[(I=D[g+8>>2])>>2]!=(0|g))<<2)+I>>2]=A,D[A>>2]=g,I=g+8|0}else{if(!(!(Q=D[g+4>>2])|e[Q+12|0]))break I;D[C>>2]!=(0|I)?(D[C+4>>2]=A=D[(I=D[C+4>>2])>>2],A&&(D[A+8>>2]=C,g=D[C+8>>2]),D[I+8>>2]=g,D[(((0|C)!=D[(A=D[C+8>>2])>>2])<<2)+A>>2]=I,D[I>>2]=C,D[C+8>>2]=I,g=D[I+8>>2]):I=C,B[I+12|0]=1,B[g+12|0]=0,D[g>>2]=I=D[(A=D[g>>2])+4>>2],I&&(D[I+8>>2]=g),D[A+8>>2]=D[g+8>>2],D[((D[(I=D[g+8>>2])>>2]!=(0|g))<<2)+I>>2]=A,D[A+4>>2]=g,I=g+8|0}D[I>>2]=A;break A}if(B[C+12|0]=1,B[g+12|0]=C=(0|A)==(0|g),B[Q+12|0]=1,I=g,C)break}}function $A(A,I,g,C){var Q,B,E=0,i=0,o=0,a=0,r=0,e=0,f=0;if(E=r=D[g+4>>2]-(Q=D[I+16>>2])|0,D[g>>2]=i=D[g>>2]-Q|0,D[g+4>>2]=E,B=(0|(o=D[I+16>>2]))>=((a=(E>>=31)+r^E)+((E=i>>31)+i^E)|0))E=r;else{A:{I:{if((0|i)>=0){if(E=1,a=1,(0|r)>=0)break A;if(e=1,E=-1,a=-1,i)break I;break A}if(e=-1,E=-1,a=-1,(0|r)<=0)break A}E=(0|r)<=0?-1:1,a=e}i=(i<<1)-(e=s(o,a))|0,a=(0|s(E,a))>=0,o=s(E,o),D[g+4>>2]=E=((a?0-i|0:i)+o|0)/2|0,f=g,g=(r<<1)-o|0,D[f>>2]=i=(e+(a?0-g|0:g)|0)/2|0,o=D[I+16>>2]}if((0|o)<(0|(i=D[C>>2]+i|0))?i=i-D[I+4>>2]|0:(0-o|0)<=(0|i)||(i=D[I+4>>2]+i|0),(0|(g=D[C+4>>2]+E|0))>(0|o)?g=g-D[I+4>>2]|0:(0-o|0)<=(0|g)||(g=D[I+4>>2]+g|0),B)o=g;else{A:{I:{if((0|i)>=0){if(I=1,E=1,(0|g)>=0)break A;if(C=1,I=-1,E=-1,i)break I;break A}if(C=-1,I=-1,E=-1,(0|g)<=0)break A}I=(0|g)<=0?-1:1,E=C}r=s(E,o),D[A>>2]=C=(i<<1)-r|0,e=0-C|0,a=C,o=(((C=(0|s(I,E))>=0)?e:a)+(I=s(I,o))|0)/2|0,I=(g<<1)-I|0,i=(r+(C?0-I|0:I)|0)/2|0}D[A>>2]=i+Q,D[A+4>>2]=o+Q}function AI(A){var I,g=0,C=0,Q=0,B=0,E=0,i=0;d=I=d-32|0;A:if((g=D[A+16>>2])>>>0>=341)D[A+16>>2]=g-341,D[I+8>>2]=D[(g=D[A+4>>2])>>2],D[A+4>>2]=g+4,aI(A,I+8|0);else{I:{g:{C:{Q:{if((B=(Q=D[A+8>>2])-D[A+4>>2]>>2)>>>0<(g=(C=D[A+12>>2])-D[A>>2]|0)>>2>>>0){if((0|C)==(0|Q))break Q;E=I,i=DC(4092),D[E+8>>2]=i,aI(A,I+8|0);break A}if(D[I+24>>2]=A+12,(g=g?g>>1:1)>>>0>=1073741824)break C;if(g=DC(C=g<<2),D[I+8>>2]=g,D[I+16>>2]=Q=g+(B<<2)|0,D[I+20>>2]=g+C,D[I+12>>2]=Q,E=I,i=DC(4092),D[E+4>>2]=i,aI(I+8|0,I+4|0),(0|(C=D[A+8>>2]))==D[A+4>>2]){g=C;break I}for(;rI(I+8|0,C=C-4|0),D[A+4>>2]!=(0|C););break g}E=I,i=DC(4092),D[E+8>>2]=i,rI(A,g=I+8|0),D[I+8>>2]=D[(C=D[A+4>>2])>>2],D[A+4>>2]=C+4,aI(A,g);break A}xg(1336),U()}g=D[A+8>>2]}Q=D[A>>2],D[A>>2]=D[I+8>>2],D[I+8>>2]=Q,D[A+4>>2]=D[I+12>>2],D[I+12>>2]=C,D[A+8>>2]=D[I+16>>2],D[I+16>>2]=g,B=D[A+12>>2],D[A+12>>2]=D[I+20>>2],D[I+20>>2]=B,(0|g)!=(0|C)&&(D[I+16>>2]=g+(((g-C|0)-4>>>2^-1)<<2)),Q&&sA(Q)}d=I+32|0}function II(A,I,g){A|=0,I|=0,g|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=F(0),e=0,f=0,k=0,N=0,s=0,n=0,R=0,y=0,G=0,c=0,w=0;if(d=C=d-16|0,9==D[g+28>>2]){Q=D[A+4>>2],E=(o=B[g+24|0])<<2,i=DC((1073741823&o)!=(0|o)?-1:E),D[(f=C+8|0)>>2]=1065353216,r=t[A+20>>2],(0|(Q=-1<<Q^-1))>0&&(t[f>>2]=r/F(0|Q));A:if((s=(0|Q)>0)&&(e=D[g+80>>2]))if(Q=0,(0|o)<=0){if(1!=(0|e))for(A=-2&e,I=0;xA(D[D[g+64>>2]>>2]+Q|0,i,E),xA((Q=Q+E|0)+D[D[g+64>>2]>>2]|0,i,E),Q=Q+E|0,(0|A)!=(0|(I=I+2|0)););if(!(1&e))break A;xA(D[D[g+64>>2]>>2]+Q|0,i,E)}else for(n=D[D[I>>2]>>2]+D[I+48>>2]|0,c=-2&o,w=1&o;;){if(k=D[A+8>>2],r=t[f>>2],I=0,N=0,1!=(0|o))for(;t[(a=I<<2)+i>>2]=F(r*F(D[(R=(Q<<2)+n|0)>>2]))+t[a+k>>2],t[(a|=4)+i>>2]=F(r*F(D[R+4>>2]))+t[a+k>>2],I=I+2|0,Q=Q+2|0,(0|c)!=(0|(N=N+2|0)););if(w&&(t[(I<<=2)+i>>2]=F(r*F(D[(Q<<2)+n>>2]))+t[I+k>>2],Q=Q+1|0),xA(D[D[g+64>>2]>>2]+y|0,i,E),y=E+y|0,(0|(G=G+1|0))==(0|e))break}sA(i)}return d=C+16|0,0|s}function gI(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0;E=D[(D[D[A+8>>2]+96>>2]+s(C=(g>>>0)/3|0,12)|0)+(g-s(C,3)<<2)>>2];A:if((0|(C=D[(Q=D[D[A+12>>2]+4>>2])+4>>2]))==D[Q+8>>2]){I:{if((C=1+(a=(o=C-(i=D[Q>>2])|0)>>2)|0)>>>0<1073741824){if(B=o>>1,B=a>>>0<536870911?C>>>0>B>>>0?C:B:1073741823){if(B>>>0>=1073741824)break I;C=DC(B<<2)}else C=0;D[(a=C+(a<<2)|0)>>2]=E,(0|o)>0&&xA(C,i,o),D[Q+8>>2]=C+(B<<2),D[Q+4>>2]=a+4,D[Q>>2]=C,i&&sA(i);break A}iQ(),U()}xg(1336),U()}else D[C>>2]=E,D[Q+4>>2]=C+4;A:{I:{if((0|(C=D[(Q=D[A+4>>2])+4>>2]))==D[Q+8>>2]){if((C=1+(E=(o=C-(i=D[Q>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(B=o>>1,B=E>>>0<536870911?C>>>0>B>>>0?C:B:1073741823){if(B>>>0>=1073741824)break A;C=DC(B<<2)}else C=0;D[(E=C+(E<<2)|0)>>2]=g,(0|o)>0&&xA(C,i,o),D[Q+8>>2]=C+(B<<2),D[Q+4>>2]=E+4,D[Q>>2]=C,i&&sA(i)}else D[C>>2]=g,D[Q+4>>2]=C+4;return D[D[(A=D[A+4>>2])+12>>2]+(I<<2)>>2]=D[A+24>>2],void(D[A+24>>2]=D[A+24>>2]+1)}iQ(),U()}xg(1336),U()}function CI(A,I){var g=0,C=0,Q=0,E=0,i=0,o=0,a=0,r=0;if((C=e[A+11|0]>>>7|0?D[A+4>>2]:e[A+11|0])>>>0<I>>>0)return d=o=d-16|0,(E=I-C|0)&&(a=(i=(I=e[A+11|0]>>>7|0)?D[A+4>>2]:e[A+11|0])+E|0,(I=I?(2147483647&D[A+8>>2])-1|0:10)-i>>>0<E>>>0&&(d=C=d-16|0,(g=a-I|0)>>>0<=-17-I>>>0?(r=e[A+11|0]>>>7|0?D[A>>2]:A,I>>>0<2147483623?(D[C+8>>2]=I<<1,D[C+12>>2]=I+g,d=g=d-16|0,d=g+16|0,g=(g=D[(k[(Q=C+12|0)>>2]<k[(g=C+8|0)>>2]?g:Q)>>2])>>>0>=11?11==(0|(g=(Q=g+16&-16)-1|0))?Q:g:10):g=-18,g=DC(Q=g+1|0),i&&zC(g,r,i),10!=(0|I)&&sA(r),D[A>>2]=g,D[A+8>>2]=-2147483648|Q,d=C+16|0):(aQ(),U())),C=i+(I=e[A+11|0]>>>7|0?D[A>>2]:A)|0,E&&bI(C,0,E),e[A+11|0]>>>7|0?D[A+4>>2]=a:B[A+11|0]=a,B[o+15|0]=0,B[I+a|0]=e[o+15|0]),void(d=o+16|0);d=C=d-16|0,e[A+11|0]>>>7|0?(E=D[A>>2],B[C+15|0]=0,B[I+E|0]=e[C+15|0],D[A+4>>2]=I):(B[C+14|0]=0,B[A+I|0]=e[C+14|0],B[A+11|0]=I),d=C+16|0}function QI(A,I){A|=0;var g,C,Q,B=0,E=0,i=0,o=0,a=0,r=0,k=0,t=0;o=E=D[20+(I|=0)>>2];A:if(!((Q=D[I+8>>2])>>>0<(i=(C=D[I+16>>2])+4|0)>>>0&(0|(B=g=D[I+12>>2]))<=(0|(E=i>>>0<4?E+1|0:E))|(0|B)<(0|E)||(B=e[0|(B=C+(r=D[I>>2])|0)]|e[B+1|0]<<8|e[B+2|0]<<16|e[B+3|0]<<24,D[I+16>>2]=i,D[I+20>>2]=E,E=o,(a=C+8|0)>>>0>Q>>>0&(0|(E=a>>>0<8?E+1|0:E))>=(0|g)|(0|E)>(0|g)||(i=e[0|(i=i+r|0)]|e[i+1|0]<<8|e[i+2|0]<<16|e[i+3|0]<<24,D[I+16>>2]=a,D[I+20>>2]=E,(0|B)>(0|i)||(D[A+16>>2]=i,D[A+12>>2]=B,!(t=(i>>31)-((B>>31)+(B>>>0>i>>>0)|0)|0)&(B=i-B|0)>>>0>2147483646|t))))){if(D[A+20>>2]=B=B+1|0,D[A+24>>2]=i=B>>>1|0,D[A+28>>2]=0-i,1&B||(D[A+24>>2]=i-1),f[I+38>>1]<=513){if((0|E)>=(0|g)&a>>>0>=Q>>>0|(0|E)>(0|g))break A;B=e[a+r|0],E=o,E=(o=C+9|0)>>>0<9?E+1|0:E,D[I+16>>2]=o,D[I+20>>2]=E;I:switch(0|B){case 1:k=1;break;case 0:break I;default:break A}D[A+88>>2]=k}k=TA(A+112|0,I)}return 0|k}function BI(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0;d=g=d-16|0;A:{I:if((Q=D[A+4>>2])>>>0<I>>>0){if((B=I-Q|0)>>>0>(C=(i=D[A+8>>2])<<5)>>>0|Q>>>0>C-B>>>0){if(D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,(0|I)<0)break A;C>>>0<=1073741822?(C=I+31&-32,I=(I=i<<6)>>>0<C>>>0?C:I):I=2147483647,vI(g,I),D[g+4>>2]=(Q=D[A+4>>2])+B,o=D[A>>2],I=D[g>>2],(0|Q)<=0||(I=RI(I,o,i=(C=Q>>>5|0)<<2)+i|0,(0|(E=Q-(C<<5)|0))<=0?E=0:D[I>>2]=D[I>>2]&(-1^(C=-1>>>32-E|0))|C&D[o+i>>2],o=D[A>>2]),D[A>>2]=D[g>>2],D[g>>2]=o,C=D[A+4>>2],D[A+4>>2]=D[g+4>>2],D[g+4>>2]=C,C=D[A+8>>2],D[A+8>>2]=D[g+8>>2],D[g+8>>2]=C,o&&sA(o)}else D[A+4>>2]=I,E=31&Q,I=D[A>>2]+(Q>>>3&536870908)|0;if(!B)break I;if(E&&(D[I>>2]=D[I>>2]&(-1<<E&-1>>>(C=32-E|0)-(A=C>>>0>B>>>0?B:C)^-1),B=B-A|0,I=I+4|0),A=bI(I,0,C=B>>>5<<2),!(I=31&B))break I;D[(A=A+C|0)>>2]=D[A>>2]&(-1>>>32-I^-1)}else D[A+4>>2]=I;return void(d=g+16|0)}iQ(),U()}function EI(A,I,g){g|=0;var C=0,Q=0,E=0,i=0,o=0,a=0,r=0;return(C=(E=D[12+(A|=0)>>2])-(o=D[A+8>>2])>>2)>>>0<(I=B[24+(I|=0)|0])>>>0?($I(A+8|0,I-C|0),o=D[A+8>>2],E=D[A+12>>2]):I>>>0>=C>>>0||(D[A+12>>2]=E=(I<<2)+o|0),I=0,a=D[g+20>>2],E=C=E-o|0,(i=(Q=D[g+16>>2])+C|0)>>>0>k[g+8>>2]&(0|(r=D[g+12>>2]))<=(0|(a=C>>>0>i>>>0?a+1|0:a))|(0|a)>(0|r)||(xA(o,Q+D[g>>2]|0,C),C=D[g+20>>2],C=(Q=E+D[g+16>>2]|0)>>>0<E>>>0?C+1|0:C,i=Q,D[g+16>>2]=Q,D[g+20>>2]=C,(E=i+4|0)>>>0>k[g+8>>2]&(0|(C=E>>>0<4?C+1|0:C))>=(0|(Q=D[g+12>>2]))|(0|C)>(0|Q)||(D[A+20>>2]=e[0|(C=i+D[g>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,C=D[g+20>>2],E=(Q=(i=D[g+16>>2])+4|0)>>>0<4?C+1|0:C,r=Q,D[g+16>>2]=Q,D[g+20>>2]=E,(0|E)>=(0|(Q=D[g+12>>2]))&r>>>0>=k[g+8>>2]|(0|E)>(0|Q)||(Q=e[r+D[g>>2]|0],C=(E=i+5|0)>>>0<5?C+1|0:C,D[g+16>>2]=E,D[g+20>>2]=C,Q-1>>>0>29||(D[A+4>>2]=Q,I=1)))),0|I}function iI(A,I){var g=0;return TA(A,I)&&TA(A+16|0,I)&&TA(A+32|0,I)&&TA(A+48|0,I)&&TA(A- -64|0,I)&&TA(A+80|0,I)&&TA(A+96|0,I)&&TA(A+112|0,I)&&TA(A+128|0,I)&&TA(A+144|0,I)&&TA(A+160|0,I)&&TA(A+176|0,I)&&TA(A+192|0,I)&&TA(A+208|0,I)&&TA(A+224|0,I)&&TA(A+240|0,I)&&TA(A+256|0,I)&&TA(A+272|0,I)&&TA(A+288|0,I)&&TA(A+304|0,I)&&TA(A+320|0,I)&&TA(A+336|0,I)&&TA(A+352|0,I)&&TA(A+368|0,I)&&TA(A+384|0,I)&&TA(A+400|0,I)&&TA(A+416|0,I)&&TA(A+432|0,I)&&TA(A+448|0,I)&&TA(A+464|0,I)&&TA(A+480|0,I)&&TA(A+496|0,I)&&(g=TA(A+512|0,I)),g}function oI(A,I){var g,C=0,Q=0,E=0,i=0,o=0;d=g=d-16|0;A:{I:{if(I){if(D[A+88>>2]=0,D[A+92>>2]=0,C=D[A+84>>2],D[A+84>>2]=0,C&&sA(C),D[A+76>>2]=0,D[A+80>>2]=0,C=D[A+72>>2],D[A+72>>2]=0,C&&sA(C),C=D[I>>2],Q=D[I+4>>2],B[g+15|0]=0,hI(A,Q-C>>2,g+15|0),C=D[I+28>>2],Q=D[I+24>>2],B[g+14|0]=0,hI(A+12|0,C-Q>>2,g+14|0),_A(A+28|0,D[I+4>>2]-D[I>>2]>>2,13740),!((E=(Q=D[I+28>>2]-D[I+24>>2]|0)>>2)>>>0<=D[A+60>>2]-(C=D[A+52>>2])>>2>>>0)){if((0|Q)<0)break I;i=D[A+56>>2],o=(Q=DC(Q))+(E<<2)|0,i=(E=i-C|0)+Q|0,(0|E)>0&&xA(Q,C,E),D[A+60>>2]=o,D[A+56>>2]=i,D[A+52>>2]=Q,C&&sA(C)}if(!((E=(Q=D[I+28>>2]-D[I+24>>2]|0)>>2)>>>0<=D[A+48>>2]-(C=D[A+40>>2])>>2>>>0)){if((0|Q)<0)break A;i=D[A+44>>2],o=(Q=DC(Q))+(E<<2)|0,i=(E=i-C|0)+Q|0,(0|E)>0&&xA(Q,C,E),D[A+48>>2]=o,D[A+44>>2]=i,D[A+40>>2]=Q,C&&sA(C)}B[A+24|0]=1,D[A+64>>2]=I}return void(d=g+16|0)}xg(1336),U()}xg(1336),U()}function aI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;A:{if((0|(Q=D[A+8>>2]))==D[A+12>>2])if((C=D[A+4>>2])>>>0>(E=D[A>>2])>>>0)g=(E=(1+(C-E>>2)|0)/-2<<2)+C|0,(B=Q-C|0)&&(RI(g,C,B),C=D[A+4>>2]),D[A+8>>2]=Q=g+B|0,D[A+4>>2]=C+E;else{if((g=(g=Q-E|0)?g>>1:1)>>>0>=1073741824)break A;if(e=(i=DC(B=g<<2))+B|0,o=Q-C|0,Q=B=(-4&g)+i|0,o){if(r=1+((a=o-4|0)>>>2|0)&7)for(Q=0,g=B;D[g>>2]=D[C>>2],C=C+4|0,g=g+4|0,(0|r)!=(0|(Q=Q+1|0)););else g=B;if(Q=B+o|0,!(a>>>0<28))for(;D[g>>2]=D[C>>2],D[g+4>>2]=D[C+4>>2],D[g+8>>2]=D[C+8>>2],D[g+12>>2]=D[C+12>>2],D[g+16>>2]=D[C+16>>2],D[g+20>>2]=D[C+20>>2],D[g+24>>2]=D[C+24>>2],D[g+28>>2]=D[C+28>>2],C=C+32|0,(0|Q)!=(0|(g=g+32|0)););}D[A+12>>2]=e,D[A+8>>2]=Q,D[A+4>>2]=B,D[A>>2]=i,E&&(sA(E),Q=D[A+8>>2])}return D[Q>>2]=D[I>>2],void(D[A+8>>2]=D[A+8>>2]+4)}xg(1336),U()}function rI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,e=0;A:{if((0|(E=D[A+4>>2]))==D[A>>2])if((C=D[A+8>>2])>>>0<(g=D[A+12>>2])>>>0)g=(B=(1+(g-C>>2)|0)/2<<2)+C|0,(Q=C-E|0)&&(RI(g=g-Q|0,E,Q),C=D[A+8>>2]),D[A+4>>2]=g,D[A+8>>2]=C+B;else{if((g=(g=g-E|0)?g>>1:1)>>>0>=1073741824)break A;if(e=(i=DC(Q=g<<2))+Q|0,B=g=(g+3&-4)+i|0,o=C-E|0){if(C=g,Q=E,r=1+((a=o-4|0)>>>2|0)&7)for(B=0;D[C>>2]=D[Q>>2],Q=Q+4|0,C=C+4|0,(0|r)!=(0|(B=B+1|0)););if(B=g+o|0,!(a>>>0<28))for(;D[C>>2]=D[Q>>2],D[C+4>>2]=D[Q+4>>2],D[C+8>>2]=D[Q+8>>2],D[C+12>>2]=D[Q+12>>2],D[C+16>>2]=D[Q+16>>2],D[C+20>>2]=D[Q+20>>2],D[C+24>>2]=D[Q+24>>2],D[C+28>>2]=D[Q+28>>2],Q=Q+32|0,(0|B)!=(0|(C=C+32|0)););}D[A+12>>2]=e,D[A+8>>2]=B,D[A+4>>2]=g,D[A>>2]=i,E&&(sA(E),g=D[A+4>>2])}else g=E;return D[g-4>>2]=D[I>>2],void(D[A+4>>2]=D[A+4>>2]-4)}xg(1336),U()}function DI(A,I,g){A|=0,I|=0,g|=0;var C=0,Q=F(0),E=F(0),i=F(0),r=F(0),f=F(0),k=0,t=F(0),N=F(0),s=F(0),R=F(0),y=0;if(!(9!=D[g+28>>2]|3!=e[g+24|0])&&!((A=D[A+4>>2])-31>>>0<4294967267)&&(y=1,k=D[g+80>>2]))for(t=F(F(2)/F((1<<A)-2|0)),g=D[D[g>>2]>>2]+D[g+48>>2]|0,A=D[D[I>>2]>>2]+D[I+48>>2]|0,I=0;i=F(0),N=F(0),s=F(0),Q=F(F(F(D[A>>2])*t)+F(-1)),E=F(F(F(D[A+4>>2])*t)+F(-1)),f=F(F(F(1)-F(n(Q)))-F(n(E))),r=F(G(F(-f),F(0))),R=F(-r),E=F(E+(E<F(0)?r:R)),Q=F(Q+(Q<F(0)?r:R)),+(r=F(F(E*E)+F(F(f*f)+F(Q*Q))))<1e-6||(i=F(F(1)/F(b(r))),s=F(E*i),N=F(Q*i),i=F(f*i)),A=A+8|0,o(s),C=a(2),B[g+8|0]=C,B[g+9|0]=C>>>8,B[g+10|0]=C>>>16,B[g+11|0]=C>>>24,o(N),C=a(2),B[g+4|0]=C,B[g+5|0]=C>>>8,B[g+6|0]=C>>>16,B[g+7|0]=C>>>24,o(i),C=a(2),B[0|g]=C,B[g+1|0]=C>>>8,B[g+2|0]=C>>>16,B[g+3|0]=C>>>24,g=g+12|0,(0|k)!=(0|(I=I+1|0)););return 0|y}function eI(A,I,g,C){var Q,B=0,E=0,i=0,o=0,a=0,r=0,e=0,f=0;r=+t[I+4>>2],e=+t[I+8>>2],(i=n(a=+t[I>>2])+n(r)+n(e))>1e-6?(r*=i=1/i,a*=i,B=i*e<0):(a=1,r=0,B=0),i=c(a*(e=+(0|(Q=D[A+16>>2])))+.5),o=(E=(f=n(i)<2147483648?~~i:-2147483648)>>31)+f^E,i=c(r*e+.5),o=(0|(I=Q-(o+((E=n(i)<2147483648?~~i:-2147483648)+(I=E>>31)^I)|0)|0))<0?0:I,B=B?0-o|0:o,E=E+(I>>31&((0|E)>0?I:0-I|0))|0,(0|f)>=0?(I=B+Q|0,A=D[A+8>>2],B=E+Q|0):(I=E>>31,I^=I+E,A=D[A+8>>2],I=(0|B)<0?I:A-I|0,B=(0|E)<0?o:A-o|0),I|B&&(0|A)!=(0|I)|B&&I|(E=(0|A)!=(0|B))?(0|I)<=(0|Q)|B?(0|I)>=(0|Q)|E?(0|A)!=(0|I)|(0|B)>=(0|Q)?I?A=B:(I=0,A=(0|B)<=(0|Q)?B:(Q<<1)-B|0):(I=A,A=(Q<<1)-B|0):I=(Q<<1)-I|0:(I=(Q<<1)-I|0,A=0):I=A,D[g>>2]=A,D[C>>2]=I}function fI(A,I){var g,C,Q,E=0,i=0,o=0;D[(E=(C=D[A>>2])+(I>>>3&536870908)|0)>>2]=D[E>>2]|1<<I,g=D[A+64>>2],i=-1,(o=-1==(0|I))||(i=-1,-1!=(0|(E=((E=I+1|0)>>>0)%3|0?E:I-2|0))&&(i=D[D[g>>2]+(E<<2)>>2])),D[(Q=(i>>>3&536870908)+(E=D[A+12>>2])|0)>>2]=D[Q>>2]|1<<i;A:{if(o)A=E+536870908|0,I=D[E+536870908>>2],E=-2147483648;else{I:{if((I>>>0)%3|0)o=I-1|0;else if(i=-1,-1==(0|(o=I+2|0)))break I;i=D[D[g>>2]+(o<<2)>>2]}if(D[(o=(i>>>3&536870908)+E|0)>>2]=D[o>>2]|1<<i,i=-1,-1==(0|(I=D[D[g+12>>2]+(I<<2)>>2])))break A;B[A+24|0]=0,D[(A=(I>>>3&536870908)+C|0)>>2]=D[A>>2]|1<<I,-1!=(0|(A=((A=I+1|0)>>>0)%3|0?A:I-2|0))&&(i=D[D[g>>2]+(A<<2)>>2]),D[(A=E+(i>>>3&536870908)|0)>>2]=D[A>>2]|1<<i;I:{if((I>>>0)%3|0)I=I-1|0;else if(A=-1,-1==(0|(I=I+2|0)))break I;A=D[D[g>>2]+(I<<2)>>2]}I=1<<A,E=D[(A=E+(A>>>3&536870908)|0)>>2]}D[A>>2]=I|E}}function kI(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0;A:if(I>>>0<=63){if(I=0,(A=D[A+12>>2])>>>0<2)break A;if(C=D[g>>2],Q=3&(I=A-1|0),g=0,A-2>>>0<3)A=1,I=0;else for(B=-4&I,I=0,A=1;I=k[C+((I=k[C+((I=k[C+((I=k[C+(I<<2)>>2]>k[C+(A<<2)>>2]?A:I)<<2)>>2]>k[C+((o=A+1|0)<<2)>>2]?o:I)<<2)>>2]>k[C+((i=A+2|0)<<2)>>2]?i:I)<<2)>>2]>k[C+((E=A+3|0)<<2)>>2]?E:I,A=A+4|0,(0|B)!=(0|(a=a+4|0)););if(!Q)break A;for(;I=k[C+(I<<2)>>2]>k[C+(A<<2)>>2]?A:I,A=A+1|0,(0|Q)!=(0|(g=g+1|0)););}else{if((0|(C=32-(I=D[A+580>>2])|0))>=4){if((0|(g=D[A+576>>2]))==D[A+568>>2])return 0;if(C=D[g>>2],D[A+580>>2]=Q=I+4|0,I=C<<I>>>28|0,32!=(0|Q))break A;return D[A+580>>2]=0,D[A+576>>2]=g+4,I}if((0|(Q=(g=D[A+576>>2])+4|0))==D[A+568>>2])return 0;B=D[g>>2],D[A+576>>2]=Q,D[A+580>>2]=I-28,I=D[g+4>>2]>>>(A=60-I|0)|B<<I>>>A-C}return I}function tI(A,I){var g=0,C=0;g=D[I+8>>2],D[A+4>>2]=D[I+4>>2],D[A+8>>2]=g,D[A+20>>2]=D[I+20>>2],g=D[I+16>>2],D[A+12>>2]=D[I+12>>2],D[A+16>>2]=g;A:{I:{if((0|A)!=(0|I)){if(g=D[I+28>>2]){if(D[A+32>>2]<<5>>>0>=g>>>0)C=D[A+24>>2];else{if((C=D[A+24>>2])&&(sA(C),D[A+32>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,g=D[I+28>>2]),(0|g)<0)break I;C=DC((g=1+(g-1>>>5|0)|0)<<2),D[A+32>>2]=g,D[A+28>>2]=0,D[A+24>>2]=C,g=D[I+28>>2]}RI(C,D[I+24>>2],4+(g-1>>>3&536870908)|0),g=D[I+28>>2]}else g=0;if(D[A+28>>2]=g,g=D[I+40>>2]){if(D[A+44>>2]<<5>>>0>=g>>>0)C=D[A+36>>2];else{if((C=D[A+36>>2])&&(sA(C),D[A+44>>2]=0,D[A+36>>2]=0,D[A+40>>2]=0,g=D[I+40>>2]),(0|g)<0)break A;C=DC((g=1+(g-1>>>5|0)|0)<<2),D[A+44>>2]=g,D[A+40>>2]=0,D[A+36>>2]=C,g=D[I+40>>2]}RI(C,D[I+36>>2],4+(g-1>>>3&536870908)|0),I=D[I+40>>2]}else I=0;D[A+40>>2]=I}return}iQ(),U()}iQ(),U()}function NI(A,I){A|=0;var g,C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,k=0;B=Q=D[20+(I|=0)>>2],o=E=(g=D[I+16>>2])+4|0;A:if(!((C=D[I+8>>2])>>>0<E>>>0&(0|(Q=E>>>0<4?Q+1|0:Q))>=(0|(i=D[I+12>>2]))|(0|Q)>(0|i))){if(a=e[0|(E=g+(k=D[I>>2])|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=o,D[I+20>>2]=Q,(E=f[I+38>>1])>>>0<=513){if(Q=B,o=B=g+8|0,B>>>0>C>>>0&(0|(Q=B>>>0<8?Q+1|0:Q))>=(0|i)|(0|Q)>(0|i))break A;D[I+16>>2]=o,D[I+20>>2]=Q}if(1&a&&!((B=31^R(a))-30>>>0<4294967267)){if(D[A+8>>2]=B+1,D[A+16>>2]=a=-2-(B=-2<<B)|0,D[A+12>>2]=-1^B,D[A+24>>2]=(0|a)/2,t[A+20>>2]=F(2)/F(0|a),E>>>0<=513){if((0|Q)>=(0|i)&o>>>0>=C>>>0|(0|Q)>(0|i))break A;i=e[o+k|0],Q=(B=o+1|0)?Q:Q+1|0,D[I+16>>2]=B,D[I+20>>2]=Q;I:switch(0|i){case 1:r=1;break;case 0:break I;default:break A}D[A+72>>2]=r}r=TA(A+96|0,I)}}return 0|r}function sI(A,I){A|=0;var g,C,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,k=0;o=Q=D[20+(I|=0)>>2];A:if(!((C=D[I+8>>2])>>>0<(B=(g=D[I+16>>2])+4|0)>>>0&(0|(Q=B>>>0<4?Q+1|0:Q))>=(0|(i=D[I+12>>2]))|(0|Q)>(0|i))&&(E=e[0|(E=g+(k=D[I>>2])|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=B,D[I+20>>2]=Q,Q=o,a=B=g+8|0,!(B>>>0>C>>>0&(0|(Q=B>>>0<8?Q+1|0:Q))>=(0|i)|(0|Q)>(0|i))&&(D[I+16>>2]=a,D[I+20>>2]=Q,1&E&&!((B=31^R(E))-30>>>0<4294967267)))){if(D[A+8>>2]=B+1,D[A+16>>2]=E=-2-(B=-2<<B)|0,D[A+12>>2]=-1^B,D[A+24>>2]=(0|E)/2,t[A+20>>2]=F(2)/F(0|E),f[I+38>>1]<=513){if((0|Q)>=(0|i)&a>>>0>=C>>>0|(0|Q)>(0|i))break A;i=e[a+k|0],o=(Q=g+9|0)>>>0<9?o+1|0:o,D[I+16>>2]=Q,D[I+20>>2]=o;I:switch(0|i){case 1:r=1;break;case 0:break I;default:break A}D[A+72>>2]=r}r=TA(A+96|0,I)}return 0|r}function FI(A){var I,g=0,C=0;g=D[A+8>>2],I=D[A>>2];A:{if(e[A+12|0]){I:{if(-1!=(0|g)&&-1!=(0|(g=((C=g+1|0)>>>0)%3|0?C:g-2|0))&&-1!=(0|(g=D[D[I+12>>2]+(g<<2)>>2]))){if(D[A+8>>2]=g=((C=g+1|0)>>>0)%3|0?C:g-2|0,-1!=(0|g))break I}else D[A+8>>2]=-1;g=-1;g:if(-1!=(0|(C=D[A+4>>2]))){if((C>>>0)%3|0)C=C-1|0;else if(g=-1,-1==(0|(C=C+2|0)))break g;g=-1,-1!=(0|(C=D[D[I+12>>2]+(C<<2)>>2]))&&(g=C-1|0,(C>>>0)%3|0||(g=C+2|0))}return B[A+12|0]=0,void(D[A+8>>2]=g)}if((0|g)!=D[A+4>>2])break A;return void(D[A+8>>2]=-1)}C=-1;I:if(-1!=(0|g)){if((g>>>0)%3|0)g=g-1|0;else if(C=-1,-1==(0|(g=g+2|0)))break I;C=-1,-1!=(0|(g=D[D[I+12>>2]+(g<<2)>>2]))&&(C=g-1|0,(g>>>0)%3|0||(C=g+2|0))}D[A+8>>2]=C}}function nI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0;D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,D[A+24>>2]=0,o=(0|(B=D[I+4>>2]-D[I>>2]|0))/20|0;A:{I:{g:{if(B){if(o>>>0>=214748365)break g;C=DC(B),D[A+16>>2]=C,D[A+20>>2]=C,D[A+24>>2]=s(o,20)+C,I=(0|(I=D[I+4>>2]-(g=D[I>>2])|0))<=0?C:xA(C,g,I)+s((I>>>0)/20|0,20)|0,D[A+20>>2]=g=I}if(D[A+28>>2]=0,!(I=g-C|0))break A;if(B=1&(g=(I=(0|I)/20|0)>>>0>1?I:1),I>>>0<2){I=0;break I}for(o=-2&g,I=0,g=0;E=s(1|I,20)+C|0,E=s(D[E+16>>2],D[E+12>>2]),i=s(I,20)+C|0,Q=(Q=Q>>>0<(i=s(D[i+16>>2],D[i+12>>2]))>>>0?i:Q)>>>0<E>>>0?E:Q,I=I+2|0,(0|o)!=(0|(g=g+2|0)););break I}iQ(),U()}B&&(I=s(I,20)+C|0,Q=(I=s(D[I+16>>2],D[I+12>>2]))>>>0>Q>>>0?I:Q)}return Cg(A,Q),D[A+12>>2]=D[A>>2],A}function RI(A,I,g){var C=0,Q=0;A:if((0|A)!=(0|I)){if(I-(Q=A+g|0)>>>0<=0-(g<<1)>>>0)return xA(A,I,g);if(C=3&(A^I),A>>>0<I>>>0){if(C)C=A;else{if(3&A)for(C=A;;){if(!g)break A;if(B[0|C]=e[0|I],I=I+1|0,g=g-1|0,!(3&(C=C+1|0)))break}else C=A;if(!(g>>>0<=3))for(;D[C>>2]=D[I>>2],I=I+4|0,C=C+4|0,(g=g-4|0)>>>0>3;);}if(g)for(;B[0|C]=e[0|I],C=C+1|0,I=I+1|0,g=g-1|0;);}else{if(!C){if(3&Q)for(;;){if(!g)break A;if(B[0|(C=(g=g-1|0)+A|0)]=e[I+g|0],!(3&C))break}if(!(g>>>0<=3))for(;D[(g=g-4|0)+A>>2]=D[I+g>>2],g>>>0>3;);}if(!g)break A;for(;B[(g=g-1|0)+A|0]=e[I+g|0],g;);}}return A}function yI(A,I,g){var C,Q,B=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0;d=C=d-16|0;A:{if((0|(i=D[A+24>>2]))!=(0|(Q=D[A+28>>2])))for(;;){D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,B=jg(D[i>>2],I,C),a=(A=e[C+11|0])<<24>>24,r=3;I:{g:{C:{Q:if(B&&(r=0,(0|(f=(0|a)<0?D[C+4>>2]:A))==(0|((0|(E=(B=e[g+11|0])<<24>>24))<0?D[g+4>>2]:B)))){o=(0|E)<0?D[g>>2]:g,E=D[C>>2];B:{if(!(B=(0|a)<0)){if(!a)break B;if(B=C,e[0|o]!=(255&E))break I;for(;;){if(!(A=A-1|0))break B;if(E=e[o+1|0],o=o+1|0,(0|E)!=e[0|(B=B+1|0)])break}break Q}if(f&&cg(B?E:C,o,f))break C}k=D[i>>2],r=1}if((0|a)>=0)break g}sA(D[C>>2])}switch(0|r){case 0:case 3:break I;default:break A}}if((0|Q)==(0|(i=i+4|0)))break}k=0}return d=C+16|0,k}function GI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0;if((C=D[A+8>>2])-(g=D[A+4>>2])>>2>>>0>=I>>>0)return I&&(g=bI(g,0,I<<=2)+I|0),void(D[A+4>>2]=g);A:{I:{g:{if((Q=(B=g-(E=D[A>>2])>>2)+I|0)>>>0<1073741824){if(i=(C=C-E|0)>>1,Q=C>>2>>>0<536870911?Q>>>0>i>>>0?Q:i:1073741823){if(Q>>>0>=1073741824)break g;o=DC(Q<<2)}if(B=(I=bI(C=(B<<2)+o|0,0,B=I<<2))+B|0,Q=(Q<<2)+o|0,(0|g)==(0|E))break I;for(;I=D[(g=g-4|0)>>2],D[g>>2]=0,D[(C=C-4|0)>>2]=I,(0|g)!=(0|E););if(D[A+8>>2]=Q,I=D[A+4>>2],D[A+4>>2]=B,g=D[A>>2],D[A>>2]=C,(0|I)==(0|g))break A;for(;A=D[(I=I-4|0)>>2],D[I>>2]=0,A&&RQ[D[D[A>>2]+4>>2]](A),(0|I)!=(0|g););break A}iQ(),U()}xg(1336),U()}D[A+8>>2]=Q,D[A+4>>2]=B,D[A>>2]=I}g&&sA(g)}function cI(A,I,g){A:switch(I-9|0){case 0:return D[g>>2]=(I=D[g>>2])+4,void(D[A>>2]=D[I>>2]);case 6:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=I=r[I>>1],void(D[A+4>>2]=I>>31);case 7:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=f[I>>1],void(D[A+4>>2]=0);case 8:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=I=B[0|I],void(D[A+4>>2]=I>>31);case 9:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=e[0|I],void(D[A+4>>2]=0);case 16:return D[g>>2]=8+(I=D[g>>2]+7&-8),void(N[A>>3]=N[I>>3]);case 17:RQ[0](A,g);default:return;case 1:case 4:case 14:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=I=D[I>>2],void(D[A+4>>2]=I>>31);case 2:case 5:case 11:case 15:return D[g>>2]=(I=D[g>>2])+4,D[A>>2]=D[I>>2],void(D[A+4>>2]=0);case 3:case 10:case 12:case 13:}D[g>>2]=8+(I=D[g>>2]+7&-8),g=D[I+4>>2],D[A>>2]=D[I>>2],D[A+4>>2]=g}function wI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0;return D[A+16>>2]=0,D[A+4>>2]=g=D[A>>2],D[A+12>>2]=g,C=D[I+20>>2],(i=D[I+8>>2])>>>0<(Q=(B=D[I+16>>2])+4|0)>>>0&(0|(g=E=D[I+12>>2]))<=(0|(C=Q>>>0<4?C+1|0:C))|(0|g)<(0|C)||(g=e[0|(g=B+D[I>>2]|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[I+16>>2]=Q,D[I+20>>2]=C,!g|3&g||i-Q>>>0<g>>>0&(0|(B=E-(C+(Q>>>0>i>>>0)|0)|0))<=0|(0|B)<0||(g>>>0>=4&&($I(A,g>>>2|0),i=D[I+8>>2],E=D[I+12>>2],Q=D[I+16>>2],C=D[I+20>>2]),(B=g+Q|0)>>>0>i>>>0&(0|(C=g>>>0>B>>>0?C+1|0:C))>=(0|E)|(0|C)>(0|E)||(xA(D[A>>2],Q+D[I>>2]|0,g),C=D[I+20>>2],C=(Q=g+D[I+16>>2]|0)>>>0<g>>>0?C+1|0:C,D[I+16>>2]=Q,D[I+20>>2]=C,D[A+16>>2]=0,D[A+12>>2]=D[A>>2],o=1))),o}function bI(A,I,g){var C=0,Q=0,E=0;if(g&&(B[0|A]=I,B[(Q=A+g|0)-1|0]=I,!(g>>>0<3||(B[A+2|0]=I,B[A+1|0]=I,B[Q-3|0]=I,B[Q-2|0]=I,g>>>0<7||(B[A+3|0]=I,B[Q-4|0]=I,g>>>0<9||(E=(Q=0-A&3)+A|0,C=s(255&I,16843009),D[E>>2]=C,D[(g=(I=g-Q&-4)+E|0)-4>>2]=C,I>>>0<9||(D[E+8>>2]=C,D[E+4>>2]=C,D[g-8>>2]=C,D[g-12>>2]=C,I>>>0<25||(D[E+24>>2]=C,D[E+20>>2]=C,D[E+16>>2]=C,D[E+12>>2]=C,D[g-16>>2]=C,D[g-20>>2]=C,D[g-24>>2]=C,D[g-28>>2]=C,(g=(g=I)-(I=4&E|24)|0)>>>0<32))))))))for(C=mg(C,0,1,1),Q=u,I=I+E|0;D[I+24>>2]=C,D[I+28>>2]=Q,D[I+16>>2]=C,D[I+20>>2]=Q,D[I+8>>2]=C,D[I+12>>2]=Q,D[I>>2]=C,D[I+4>>2]=Q,I=I+32|0,(g=g-32|0)>>>0>31;);return A}function UI(A,I){var g=0,C=0,Q=0,B=0,E=0;C=-1,B=-1,Q=-1;A:{I:if(-1!=(0|I)){if(E=1,B=D[D[D[A+4>>2]+12>>2]+(I<<2)>>2],(0|(g=((g=I+1|0)>>>0)%3|0?g:I-2|0))>=0&&(Q=D[(D[D[A>>2]+96>>2]+s(Q=(g>>>0)/3|0,12)|0)+(g-s(Q,3)<<2)>>2]),-1!=(0|B)&&(E=0,(0|(g=((B>>>0)%3|0?-1:2)+B|0))<0||(C=D[(D[D[A>>2]+96>>2]+s(C=(g>>>0)/3|0,12)|0)+(g-s(C,3)<<2)>>2])),g=-1,(0|C)!=(0|Q))break A;if(Q=-1,(0|(I=((I>>>0)%3|0?-1:2)+I|0))>=0){if(C=D[(D[D[A>>2]+96>>2]+s(C=(I>>>0)/3|0,12)|0)+(I-s(C,3)<<2)>>2],E)break I}else if(C=-1,E)break I;(0|(I=((I=B+1|0)>>>0)%3|0?I:B-2|0))<0||(Q=D[((g=D[D[A>>2]+96>>2])+s(A=(I>>>0)/3|0,12)|0)+(I-s(A,3)<<2)>>2])}g=(0|C)==(0|Q)?B:-1}return g}function hI(A,I,g){var C,Q=0,B=0,E=0;d=C=d-16|0,D[A+4>>2]=0;A:{I:if(I){if((Q=(E=D[A+8>>2])<<5)>>>0>=I>>>0)D[A+4>>2]=I;else{if(D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,(0|I)<0)break A;vI(C,Q=Q>>>0<=1073741822?(Q=E<<6)>>>0<(B=I+31&-32)>>>0?B:Q:2147483647),B=D[A>>2],D[A>>2]=D[C>>2],D[C>>2]=B,Q=D[A+4>>2],D[A+4>>2]=I,D[C+4>>2]=Q,Q=D[A+8>>2],D[A+8>>2]=D[C+8>>2],D[C+8>>2]=Q,B&&sA(B)}if(Q=(B=I>>>5|0)<<2,A=D[A>>2],e[0|g]){if(A=bI(A,255,Q),!(I&=31))break I;D[(A=A+(B<<2)|0)>>2]=D[A>>2]|-1>>>32-I}else A=bI(A,0,Q),(I&=31)&&(D[(A=A+(B<<2)|0)>>2]=D[A>>2]&(-1>>>32-I^-1))}return void(d=C+16|0)}iQ(),U()}function JI(A,I){var g,C,Q,B=0,E=0,i=0,o=0,a=0;if(o=D[(I=D[I>>2])+8>>2],C=D[I+4>>2],Q=D[I>>2],(I=D[(g=D[A>>2])+4>>2])>>>0<(B=D[g+8>>2])>>>0)return D[I+8>>2]=o,D[I+4>>2]=C,D[I>>2]=Q,void(D[g+4>>2]=I+12);A:{if((A=1+(i=(I-(E=D[g>>2])|0)/12|0)|0)>>>0<357913942){if(a=(B=(B-E|0)/12|0)<<1,(A=B>>>0<178956970?A>>>0>a>>>0?A:a:357913941)>>>0>=357913942)break A;if(a=s(i,12),i=DC(B=s(A,12)),D[8+(A=a+i|0)>>2]=o,D[A+4>>2]=C,D[A>>2]=Q,o=A+12|0,(0|I)!=(0|E))for(;D[(A=A-12|0)>>2]=D[(I=I-12|0)>>2],D[A+4>>2]=D[I+4>>2],D[A+8>>2]=D[I+8>>2],(0|I)!=(0|E););return D[g+8>>2]=B+i,D[g+4>>2]=o,D[g>>2]=A,void(E&&sA(E))}iQ(),U()}xg(1336),U()}function SI(A,I,g){var C,Q=0,B=0,E=0,i=0;if((C=(E=g-I|0)>>2)>>>0<=(Q=D[A+8>>2])-(B=D[A>>2])>>2>>>0){if((0|(Q=C>>>0>(i=(Q=(E=D[A+4>>2])-B|0)>>2)>>>0?I+Q|0:g))!=(0|I))for(;D[B>>2]=D[I>>2],B=B+4|0,(0|Q)!=(0|(I=I+4|0)););return C>>>0>i>>>0?((0|(I=g-Q|0))>0&&(E=xA(E,Q,I)+I|0),void(D[A+4>>2]=E)):void(D[A+4>>2]=B)}if(B&&(D[A+4>>2]=B,sA(B),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,Q=0),!((0|E)<0||(g=Q>>1,(g=Q>>2>>>0<536870911?g>>>0<C>>>0?C:g:1073741823)>>>0>=1073741824)))return g=DC(B=g<<2),D[A>>2]=g,D[A+4>>2]=g,D[A+8>>2]=g+B,E&&(g=xA(g,I,E)+E|0),void(D[A+4>>2]=g);iQ(),U()}function YI(A){var I=0,g=0,C=0,Q=0;g=1;A:if(!((0|(C=D[A+140>>2]))<=0)){for(I=C<<4,g=DC((0|C)!=(268435455&C)?-1:4|I),D[g>>2]=C,C=(g=g+4|0)+I|0,I=g;D[I>>2]=0,D[I+4>>2]=0,B[I+5|0]=0,B[I+6|0]=0,B[I+7|0]=0,B[I+8|0]=0,B[I+9|0]=0,B[I+10|0]=0,B[I+11|0]=0,B[I+12|0]=0,(0|C)!=(0|(I=I+16|0)););if(Q=D[A+136>>2],D[A+136>>2]=g,Q){if(g=D[(C=Q-4|0)>>2])for(I=(g<<4)+Q|0;(0|Q)!=(0|(I=I-16|0)););sA(C)}if(g=1,!(D[A+140>>2]<=0))for(I=0;;){if(!(g=TA(D[A+136>>2]+(I<<4)|0,A)))break A;if(!((0|(I=I+1|0))<D[A+140>>2]))break}}return g}function KI(A,I){var g,C=0,Q=0,E=0,i=0;return D[A+64>>2]||(C=DC(32),D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C>>2]=0,D[C+4>>2]=0,D[C+24>>2]=0,D[C+28>>2]=0,Q=D[A+64>>2],D[A+64>>2]=C,Q&&((C=D[Q>>2])&&(D[Q+4>>2]=C,sA(C)),sA(Q))),E=D[A+64>>2],Q=C=s(Q=(C=D[A+28>>2]-1|0)>>>0<=10?D[13616+(C<<2)>>2]:-1,B[A+24|0]),(E=Hg(E,0,mg(C,g=C>>31,I,0),u))&&(D[A>>2]=C=D[A+64>>2],i=D[C+20>>2],D[A+8>>2]=D[C+16>>2],D[A+12>>2]=i,i=D[C+24>>2],C=D[C+28>>2],D[A+48>>2]=0,D[A+52>>2]=0,D[A+40>>2]=Q,D[A+44>>2]=g,D[A+16>>2]=i,D[A+20>>2]=C,D[A+80>>2]=I),E}function MI(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0;B=A+4|0;A:{if(A=D[A+4>>2])for(o=(C=(Q=e[g+11|0])<<24>>24<0)?D[g>>2]:g,Q=C?D[g+4>>2]:Q;;){I:{g:{C:{Q:{B:{E:if(i=(a=(g=(C=(g=e[A+27|0])<<24>>24<0)?D[A+20>>2]:g)>>>0<Q>>>0)?g:Q){if(E=A+16|0,!(E=cg(o,C=C?D[E>>2]:E,i))){if(g>>>0>Q>>>0)break E;break B}if((0|E)>=0)break B}else if(g>>>0<=Q>>>0)break Q;if(g=D[A>>2])break I;return D[I>>2]=A,A}if(g=cg(C,o,i))break C}if(a)break g;break A}if((0|g)>=0)break A}if(B=A+4|0,!(g=D[A+4>>2]))break A;A=B}B=A,A=g}return D[I>>2]=B,B}return D[I>>2]=A,B}function lI(A,I){var g=0;return g=D[I+4>>2],D[A>>2]=D[I>>2],D[A+4>>2]=g,g=D[I+60>>2],D[A+56>>2]=D[I+56>>2],D[A+60>>2]=g,g=D[I+52>>2],D[A+48>>2]=D[I+48>>2],D[A+52>>2]=g,g=D[I+44>>2],D[A+40>>2]=D[I+40>>2],D[A+44>>2]=g,g=D[I+36>>2],D[A+32>>2]=D[I+32>>2],D[A+36>>2]=g,g=D[I+28>>2],D[A+24>>2]=D[I+24>>2],D[A+28>>2]=g,g=D[I+20>>2],D[A+16>>2]=D[I+16>>2],D[A+20>>2]=g,g=D[I+12>>2],D[A+8>>2]=D[I+8>>2],D[A+12>>2]=g,D[A+88>>2]=0,D[A+64>>2]=0,D[A+68>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,B[A+77|0]=0,B[A+78|0]=0,B[A+79|0]=0,B[A+80|0]=0,B[A+81|0]=0,B[A+82|0]=0,B[A+83|0]=0,B[A+84|0]=0,A}function LI(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0,a=0;g=A+4|0;A:{I:if(A=D[A+4>>2]){for(o=(C=(Q=e[I+11|0])<<24>>24<0)?D[I>>2]:I,B=C?D[I+4>>2]:Q,C=g;(Q=(E=(i=(a=(I=e[A+27|0])<<24>>24<0)?D[A+20>>2]:I)>>>0>B>>>0)?B:i)&&(I=A+16|0,I=cg(a?D[I>>2]:I,o,Q))||(I=B>>>0>i>>>0?-1:E),C=(0|I)<0?C:A,A=D[(I>>>29&4)+A>>2];);if((0|C)!=(0|g)){if(!((I=(Q=(E=(A=e[C+27|0])<<24>>24<0)?D[C+20>>2]:A)>>>0<B>>>0?Q:B)&&(A=C+16|0,A=cg(o,E?D[A>>2]:A,I)))){if(Q>>>0>B>>>0)break I;break A}if((0|A)>=0)break A}}C=g}return C}function dI(A,I,g){var C=0,Q=0,E=0,i=0;A:{if(I)if(f[A+38>>1]<=513){if(I=D[A+20>>2],(i=(E=D[A+16>>2])+8|0)>>>0>k[A+8>>2]&(0|(I=i>>>0<8?I+1|0:I))>=(0|(Q=D[A+12>>2]))|(0|I)>(0|Q))break A;C=e[4+(I=E+D[A>>2]|0)|0]|e[I+5|0]<<8|e[I+6|0]<<16|e[I+7|0]<<24,D[g>>2]=e[0|I]|e[I+1|0]<<8|e[I+2|0]<<16|e[I+3|0]<<24,D[g+4>>2]=C,I=D[A+20>>2],I=(g=D[A+16>>2]+8|0)>>>0<8?I+1|0:I,D[A+16>>2]=g,D[A+20>>2]=I}else if(!function A(I,g,C){var Q=0,E=0,i=0,o=0;I:if(!(I>>>0>10||(0|(Q=D[C+20>>2]))>=(0|(E=D[C+12>>2]))&(i=D[C+16>>2])>>>0>=k[C+8>>2]|(0|Q)>(0|E))){if(E=B[i+D[C>>2]|0],Q=(i=i+1|0)?Q:Q+1|0,D[C+16>>2]=i,D[C+20>>2]=Q,(0|E)<0){if(!A(I+1|0,g,C))break I;I=D[g+4>>2]<<7|(C=D[g>>2])>>>25,C=127&E|C<<7}else I=0,C=255&E;D[g>>2]=C,D[g+4>>2]=I,o=1}return o}(1,g,A))break A;B[A+36|0]=1,D[A+32>>2]=0,D[A+24>>2]=g=(I=D[A+16>>2])+D[A>>2]|0,D[(C=A)+28>>2]=g+((A=D[A+8>>2])-I|0),C=1}return C}function uI(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0;D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0;A:{I:{if(I){if(I>>>0>=357913942)break I;if(I=DC(C=s(I,12)),D[A>>2]=I,D[A+4>>2]=I,D[A+8>>2]=Q=I+C|0,g=D[g+4>>2]-(B=D[g>>2])|0){if((0|g)<0)break A;for(E=g>>2<<2,i=g>>>2<<2;D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,C=DC(g),D[I>>2]=C,D[I+4>>2]=C,D[I+8>>2]=C+E,o=I,a=xA(C,B,g)+i|0,D[o+4>>2]=a,(0|Q)!=(0|(I=I+12|0)););}else bI(g=I,0,12+((I=C-12|0)-((I>>>0)%12|0)|0)|0);D[A+4>>2]=Q}return}iQ(),U()}D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,iQ(),U()}function pI(A,I){A|=0,I|=0;var g=0,C=0,Q=0,B=0,E=0,i=0;B=DC(64),g=DC(12),D[g+8>>2]=D[D[A+4>>2]+80>>2],D[g>>2]=13248,D[g+4>>2]=0,B=pg(B,g);A:{if((0|I)<0)g=B;else{if(i=A+8|0,!((0|(E=(g=D[A+12>>2])-(Q=D[A+8>>2])>>2))>(0|I)))if(C=I+1|0,I>>>0>=E>>>0)GI(i,C-E|0);else if(!(C>>>0>=E>>>0)){if((0|(Q=Q+(C<<2)|0))!=(0|g))for(;C=D[(g=g-4|0)>>2],D[g>>2]=0,C&&RQ[D[D[C>>2]+4>>2]](C),(0|g)!=(0|Q););D[A+12>>2]=Q}if(g=D[(A=D[i>>2]+(I<<2)|0)>>2],D[A>>2]=B,!g)break A}RQ[D[D[g>>2]+4>>2]](g)}return(-1^I)>>>31|0}function HI(A,I){var g,C,Q=0;if(d=C=d-16|0,D[C+12>>2]=I,d=g=d-208|0,D[g+204>>2]=I,bI(I=g+160|0,0,40),D[g+200>>2]=D[g+204>>2],!((0|O(0,A,g+200|0,g+80|0,I))<0)){I=D[3868],D[3886]<=0&&(D[3868]=-33&I);A:{I:{if(D[3880]){if(D[3872])break I}else D[3880]=80,D[3875]=0,D[3872]=0,D[3873]=0,Q=D[3879],D[3879]=g;if(vg(15472))break A}O(15472,A,g+200|0,g+80|0,g+160|0)}Q&&(RQ[D[3877]](15472,0,0),D[3880]=0,D[3879]=Q,D[3875]=0,D[3872]=0,D[3873]=0),D[3868]=D[3868]|32&I}d=g+208|0,d=C+16|0}function qI(A,I,g){var C,Q=0,B=0,E=0,i=0;return(C=(E=g-I|0)>>2)>>>0<=(Q=D[A+8>>2])-(B=D[A>>2])>>2>>>0?((i=(Q=(E=(Q=D[A+4>>2]-B|0)>>2)>>>0<C>>>0?I+Q|0:g)-I|0)&&RI(B,I,i),E>>>0<C>>>0?(I=D[A+4>>2],(0|(g=g-Q|0))>0&&(I=xA(I,Q,g)+g|0),void(D[A+4>>2]=I)):void(D[A+4>>2]=B+i)):(B&&(D[A+4>>2]=B,sA(B),D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,Q=0),(0|E)<0||(g=Q>>1,(g=Q>>2>>>0<536870911?g>>>0<C>>>0?C:g:1073741823)>>>0>=1073741824)?(iQ(),void U()):(g=DC(B=g<<2),D[A>>2]=g,D[A+4>>2]=g,D[A+8>>2]=g+B,E&&(g=xA(g,I,E)+E|0),void(D[A+4>>2]=g)))}function WI(A,I,g){var C=0,Q=0,B=0,E=0;A:{if(!((0|I)<0|(0|g)<0)){if(!(I>>>0>1431655765)){if(_A(A,C=s(I,3),13680),_A(A+12|0,C,13684),!(D[A+32>>2]-(C=D[A+24>>2])>>2>>>0>=g>>>0)){if(g>>>0>=1073741824)break A;Q=D[A+28>>2],B=(g=DC(B=g<<2))+B|0,E=(Q=Q-C|0)+g|0,(0|Q)>0&&xA(g,C,Q),D[A+32>>2]=B,D[A+28>>2]=E,D[A+24>>2]=g,C&&sA(C)}D[A+80>>2]=0,D[A+84>>2]=0,g=D[A+76>>2],D[A+76>>2]=0,g&&sA(g),D[A+68>>2]=0,D[A+72>>2]=0,A=D[(g=A- -64|0)>>2],D[g>>2]=0,A&&sA(A)}C=I>>>0<1431655766}return C}xg(1336),U()}function VI(A){var I=0,g=0,C=0,Q=0,E=0;if(!e[(C=D[A+8>>2])+84|0]&&!(!(I=D[A+16>>2])|!e[I+84|0]||(g=D[C+72>>2],Q=D[C+68>>2],B[I+84|0]=0,(g=g-Q>>2)>>>0>(Q=D[I+72>>2]-(E=D[I+68>>2])>>2)>>>0?(ZA(I+68|0,g-Q|0,2344),C=D[A+8>>2]):g>>>0>=Q>>>0||(D[I+72>>2]=E+(g<<2)),(I=e[C+84|0])||(0|(g=D[C+68>>2]))==D[C+72>>2])))if(Q=D[D[A+16>>2]+68>>2],I)D[Q>>2]=0;else for(I=0;D[(E=I<<2)+Q>>2]=D[g+E>>2],(I=I+1|0)>>>0<D[C+72>>2]-(g=D[C+68>>2])>>2>>>0;);return D[A+16>>2]}function _I(A,I){I|=0;var g=0,C=0,Q=0,B=0;A:if((0|(g=D[216+(A|=0)>>2]))!=D[A+220>>2]){for(;;){I:if(!((0|(g=D[s(Q,144)+g>>2]))<0||(0|g)>=D[(C=D[A+4>>2])+12>>2]-(B=D[C+8>>2])>>2||(C=0,(0|RQ[D[D[(g=D[(g<<2)+B>>2])>>2]+24>>2]](g))<=0))){for(;;){if((0|RQ[D[D[g>>2]+20>>2]](g,C))!=(0|I)){if(C=C+1|0,(0|RQ[D[D[g>>2]+24>>2]](g))>(0|C))continue;break I}break}A=D[A+216>>2]+s(Q,144)|0,Q=e[A+100|0]?A+4|0:0;break A}if(!((Q=Q+1|0)>>>0<(D[A+220>>2]-(g=D[A+216>>2])|0)/144>>>0))break}return 0}return 0|Q}function TI(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0;if((0|(g=D[A+4>>2]))!=D[A+8>>2])return C=D[I+4>>2],D[g>>2]=D[I>>2],D[g+4>>2]=C,D[g+8>>2]=D[I+8>>2],void(D[A+4>>2]=g+12);A:{if((g=1+(C=(0|(E=g-(B=D[A>>2])|0))/12|0)|0)>>>0<357913942){if(Q=C<<1,Q=C>>>0<178956970?g>>>0>Q>>>0?g:Q:357913941){if(Q>>>0>=357913942)break A;g=DC(s(Q,12))}else g=0;return C=g+s(C,12)|0,i=D[I+4>>2],D[C>>2]=D[I>>2],D[C+4>>2]=i,D[C+8>>2]=D[I+8>>2],I=C+s((0|E)/-12|0,12)|0,(0|E)>0&&xA(I,B,E),D[A+8>>2]=g+s(Q,12),D[A+4>>2]=C+12,D[A>>2]=I,void(B&&sA(B))}iQ(),U()}xg(1336),U()}function mI(A){var I=0,g=0,C=0,Q=0;if(g=D[A+132>>2]){if((0|g)==(0|(I=D[A+136>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+132>>2]}D[A+136>>2]=g,sA(I)}if(g=D[A+120>>2]){if((0|g)==(0|(I=D[A+124>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+120>>2]}D[A+124>>2]=g,sA(I)}(I=D[A+108>>2])&&(D[A+112>>2]=I,sA(I)),(I=D[A+96>>2])&&(D[A+100>>2]=I,sA(I)),cC(A+76|0),cC(A+56|0),cC(A+36|0),cC(A+16|0)}function ZI(A){var I=0,g=0,C=0;if(D[(A|=0)>>2]=2156,I=D[A+60>>2]){if((0|I)==(0|(g=D[A- -64>>2])))g=I;else{for(;C=D[(g=g-4|0)>>2],D[g>>2]=0,C&&Wg(C),(0|I)!=(0|g););g=D[A+60>>2]}D[A+64>>2]=I,sA(g)}if((I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),I=D[A+36>>2]){if((0|I)==(0|(g=D[A+40>>2])))g=I;else{for(;RQ[D[D[(g=g-24|0)>>2]>>2]](g),(0|I)!=(0|g););g=D[A+36>>2]}D[A+40>>2]=I,sA(g)}return D[A>>2]=2012,(I=D[A+16>>2])&&(D[A+20>>2]=I,sA(I)),(I=D[A+4>>2])&&(D[A+8>>2]=I,sA(I)),0|A}function xI(A,I,g,C,Q,E,i){var o,a=0,r=0;if(d=o=d-16|0,(-1^I)-17>>>0>=g>>>0)return r=e[A+11|0]>>>7|0?D[A>>2]:A,I>>>0<2147483623?(D[o+8>>2]=I<<1,D[o+12>>2]=I+g,d=g=d-16|0,d=g+16|0,g=(g=D[(k[(a=o+12|0)>>2]<k[(g=o+8|0)>>2]?g:a)>>2])>>>0>=11?11==(0|(g=(a=g+16&-16)-1|0))?a:g:10):g=-18,g=DC(a=g+1|0),E&&zC(g,i,E),(C=C-Q|0)&&zC(g+E|0,Q+r|0,C),10!=(0|I)&&sA(r),D[A>>2]=g,D[A+8>>2]=-2147483648|a,D[(I=A)+4>>2]=A=C+E|0,B[o+7|0]=0,B[A+g|0]=e[o+7|0],void(d=o+16|0);aQ(),U()}function XI(A){var I=0,g=0,C=0,Q=0;if(g=D[A+640>>2]){if((0|g)==(0|(I=D[A+644>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+640>>2]}D[A+644>>2]=g,sA(I)}if(g=D[A+628>>2]){if((0|g)==(0|(I=D[A+632>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+628>>2]}D[A+632>>2]=g,sA(I)}(I=D[A+616>>2])&&(D[A+620>>2]=I,sA(I)),(I=D[A+604>>2])&&(D[A+608>>2]=I,sA(I)),cC(A+584|0),cC(A+564|0),cC(A+544|0)}function jI(A){var I=0,g=0,C=0,Q=0;if(g=D[A+128>>2]){if((0|g)==(0|(I=D[A+132>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+128>>2]}D[A+132>>2]=g,sA(I)}if(g=D[A+116>>2]){if((0|g)==(0|(I=D[A+120>>2])))I=g;else{for(;(C=D[(Q=I-12|0)>>2])&&(D[I-8>>2]=C,sA(C)),(0|g)!=(0|(I=Q)););I=D[A+116>>2]}D[A+120>>2]=g,sA(I)}(I=D[A+104>>2])&&(D[A+108>>2]=I,sA(I)),(I=D[A+92>>2])&&(D[A+96>>2]=I,sA(I)),cC(A+72|0),cC(A+52|0),cC(A+32|0)}function OI(A,I){I|=0;var g=0,C=0,Q=0,B=0;if((0|(g=D[216+(A|=0)>>2]))!=D[A+220>>2])for(;;){A:if(!((0|(g=D[s(Q,144)+g>>2]))<0||(0|g)>=D[(C=D[A+4>>2])+12>>2]-(B=D[C+8>>2])>>2||(C=0,(0|RQ[D[D[(g=D[(g<<2)+B>>2])>>2]+24>>2]](g))<=0))){for(;;){if((0|RQ[D[D[g>>2]+20>>2]](g,C))!=(0|I)){if(C=C+1|0,(0|RQ[D[D[g>>2]+24>>2]](g))>(0|C))continue;break A}break}return 104+(D[A+216>>2]+s(Q,144)|0)|0}if(!((Q=Q+1|0)>>>0<(D[A+220>>2]-(g=D[A+216>>2])|0)/144>>>0))break}return A+184|0}function vI(A,I){var g,C=0,Q=0,B=0,E=0,i=0,o=0;d=g=d-16|0;A:{if(!(D[A+8>>2]<<5>>>0>=I>>>0)){if(D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,(0|I)<0)break A;Q=DC((E=1+(I-1>>>5|0)|0)<<2),D[g+8>>2]=E,D[g>>2]=Q,B=D[A>>2],D[g+4>>2]=I=D[A+4>>2],D[((I>>>0<33?0:I-1>>>5|0)<<2)+Q>>2]=0,(0|I)<=0||(o=RI(Q,B,C=(i=I>>>5|0)<<2),(0|(I=I-(i<<5)|0))<=0||(D[(C=C+o|0)>>2]=D[C>>2]&(-1^(I=-1>>>32-I|0))|I&D[(i<<2)+B>>2])),D[A+8>>2]=E,D[A>>2]=Q,B&&sA(B)}return void(d=g+16|0)}iQ(),U()}function zI(A,I){if(!A)return 0;A:{I:{if(A){if(I>>>0<=127)break I;if(D[D[3971]>>2]){if(I>>>0<=2047){B[A+1|0]=63&I|128,B[0|A]=I>>>6|192,A=2;break A}if(!(57344!=(-8192&I)&I>>>0>=55296)){B[A+2|0]=63&I|128,B[0|A]=I>>>12|224,B[A+1|0]=I>>>6&63|128,A=3;break A}if(I-65536>>>0<=1048575){B[A+3|0]=63&I|128,B[0|A]=I>>>18|240,B[A+2|0]=I>>>6&63|128,B[A+1|0]=I>>>12&63|128,A=4;break A}}else if(57216==(-128&I))break I;D[3934]=25,A=-1}else A=1;break A}B[0|A]=I,A=1}return A}function PI(A){var I,g=0,C=0;if(D[(A|=0)>>2]=13756,(g=D[A+68>>2])&&(D[A+72>>2]=g,sA(g)),(g=D[A+56>>2])&&(D[A+60>>2]=g,sA(g)),(g=D[A+44>>2])&&(D[A+48>>2]=g,sA(g)),(g=D[A+32>>2])&&(D[A+36>>2]=g,sA(g)),(g=D[A+20>>2])&&(D[A+24>>2]=g,sA(g)),I=D[A+8>>2]){if((0|(C=D[A+12>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&Wg(g),(0|I)!=(0|C););g=D[A+8>>2]}D[A+12>>2]=I,sA(g)}return g=D[A+4>>2],D[A+4>>2]=0,g&&wg(g),0|A}function $I(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0;if((Q=D[A+8>>2])-(g=D[A+4>>2])>>2>>>0>=I>>>0)return I&&(g=bI(g,0,I<<=2)+I|0),void(D[A+4>>2]=g);A:{if((C=(i=(E=g-(B=D[A>>2])|0)>>2)+I|0)>>>0<1073741824){if(g=0,o=(Q=Q-B|0)>>1,C=Q>>2>>>0<536870911?C>>>0>o>>>0?C:o:1073741823){if(C>>>0>=1073741824)break A;g=DC(C<<2)}return I=bI((i<<2)+g|0,0,I<<=2)+I|0,(0|E)>0&&xA(g,B,E),D[A+8>>2]=(C<<2)+g,D[A+4>>2]=I,D[A>>2]=g,void(B&&sA(B))}iQ(),U()}xg(1336),U()}function Ag(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0;if((Q=D[A+8>>2])-(g=D[A+4>>2])>>3>>>0>=I>>>0)return I&&(g=bI(g,0,I<<=3)+I|0),void(D[A+4>>2]=g);A:{if((C=(i=(E=g-(B=D[A>>2])|0)>>3)+I|0)>>>0<536870912){if(g=0,o=(Q=Q-B|0)>>2,C=Q>>3>>>0<268435455?C>>>0>o>>>0?C:o:536870911){if(C>>>0>=536870912)break A;g=DC(C<<3)}return I=bI((i<<3)+g|0,0,I<<=3)+I|0,(0|E)>0&&xA(g,B,E),D[A+8>>2]=(C<<3)+g,D[A+4>>2]=I,D[A>>2]=g,void(B&&sA(B))}iQ(),U()}xg(1336),U()}function Ig(A,I){var g,C=0,Q=0,B=0,E=0,i=0;if((A=D[(g=D[A>>2])+4>>2])>>>0<(C=D[g+8>>2])>>>0)return D[A>>2]=D[I>>2],void(D[g+4>>2]=A+4);A:{if((A=1+(Q=(E=A-(B=D[g>>2])|0)>>2)|0)>>>0<1073741824){if(i=Q<<2,Q=(C=C-B|0)>>1,C=C>>2>>>0<536870911?A>>>0>Q>>>0?A:Q:1073741823){if(C>>>0>=1073741824)break A;A=DC(C<<2)}else A=0;return D[(Q=i+A|0)>>2]=D[I>>2],(0|E)>0&&xA(A,B,E),D[g+8>>2]=A+(C<<2),D[g+4>>2]=Q+4,D[g>>2]=A,void(B&&sA(B))}iQ(),U()}xg(1336),U()}function gg(A,I){var g=0,C=0,Q=0,E=0;if((0|(g=A+4|0))!=(0|(A=LI(A,I)))){for(I=B[A+39|0]<0?D[A+28>>2]:A+28|0;I=(A=I)+1|0,32==(0|(g=B[0|A]))|g-9>>>0<5;);A:{I:{g:switch((g=B[0|A])-43|0){case 0:break I;case 2:break g;default:break A}Q=1}g=B[0|I],A=I}if(g-48>>>0<10)for(;C=48+(s(C,10)-B[0|A]|0)|0,I=B[A+1|0],A=A+1|0,I-48>>>0<10;);-1!=(0|(A=Q?C:0-C|0))&&(E=0!=(0|A))}return E}function Cg(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0;A:{I:{if((B=(g=D[A+4>>2])-(Q=D[A>>2])|0)>>>0<I>>>0){if((E=I-B|0)>>>0<=(C=D[A+8>>2])-g>>>0)return E&&(g=bI(g,0,E)+E|0),void(D[A+4>>2]=g);if((0|I)<0)break A;if(g=0,i=(C=C-Q|0)<<1,(C=C>>>0<1073741823?I>>>0>i>>>0?I:i:2147483647)&&(g=DC(C)),bI(g+B|0,0,E),(0|B)>0&&xA(g,Q,B),D[A+8>>2]=g+C,D[A+4>>2]=I+g,D[A>>2]=g,!Q)break I;return void sA(Q)}I>>>0>=B>>>0||(D[A+4>>2]=I+Q)}return}iQ(),U()}function Qg(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0;if((Q=D[A+8>>2])-(g=D[A+4>>2])>>1>>>0>=I>>>0)return I&&(g=bI(g,0,I<<=1)+I|0),void(D[A+4>>2]=g);A:{if((0|(C=(i=(E=g-(B=D[A>>2])|0)>>1)+I|0))>=0){if(g=0,C=(Q=Q-B|0)>>1>>>0<1073741823?C>>>0>Q>>>0?C:Q:2147483647){if((0|C)<0)break A;g=DC(C<<1)}return I=bI((i<<1)+g|0,0,I<<=1)+I|0,(0|E)>0&&xA(g,B,E),D[A+8>>2]=(C<<1)+g,D[A+4>>2]=I,D[A>>2]=g,void(B&&sA(B))}iQ(),U()}xg(1336),U()}function Bg(A){var I=0,g=0,C=0,Q=0,B=0;if((0|(I=D[A+4>>2]))!=D[A+8>>2])return D[I>>2]=D[2863],void(D[A+4>>2]=I+4);A:{if((I=1+(C=(B=I-(Q=D[A>>2])|0)>>2)|0)>>>0<1073741824){if(g=B>>1,g=C>>>0<536870911?I>>>0>g>>>0?I:g:1073741823){if(g>>>0>=1073741824)break A;I=DC(g<<2)}else I=0;return D[(C=I+(C<<2)|0)>>2]=D[2863],(0|B)>0&&xA(I,Q,B),D[A+8>>2]=I+(g<<2),D[A+4>>2]=C+4,D[A>>2]=I,void(Q&&sA(Q))}iQ(),U()}xg(1336),U()}function Eg(A,I,g){var C=0,Q=0,B=0;A:{if(!(C=D[g+16>>2])){if(vg(g))break A;C=D[g+16>>2]}if(C-(B=D[g+20>>2])>>>0<I>>>0)return 0|RQ[D[g+36>>2]](g,A,I);I:if(D[g+80>>2]<0)C=0;else{for(Q=I;;){if(!(C=Q)){C=0;break I}if(10==e[(Q=C-1|0)+A|0])break}if((Q=0|RQ[D[g+36>>2]](g,A,C))>>>0<C>>>0)break A;A=A+C|0,I=I-C|0,B=D[g+20>>2]}xA(B,A,I),D[g+20>>2]=D[g+20>>2]+I,Q=I+C|0}return Q}function ig(A,I){var g=0,C=0,Q=0,B=0;(g=D[A+16>>2]-(C=D[A+12>>2])>>2)>>>0<I>>>0?$I(A+12|0,I-g|0):I>>>0>=g>>>0||(D[A+16>>2]=C+(I<<2));A:{if(!(D[A+8>>2]-(g=D[A>>2])>>2>>>0>=I>>>0)){if(I>>>0>=1073741824)break A;C=D[A+4>>2],Q=(I=DC(Q=I<<2))+Q|0,B=(C=C-g|0)+I|0,(0|C)>0&&xA(I,g,C),D[A+8>>2]=Q,D[A+4>>2]=B,D[A>>2]=I,g&&sA(g)}return}xg(1336),U()}function og(A){var I=0,g=0,C=0;e[A+76|0]&&(B[A+76|0]=0,C=(C=D[A+60>>2])+((I=(g=D[A+72>>2]+7|0)>>>0<7?1:I)>>>3|0)|0,D[A+56>>2]=I=(g=I<<29|g>>>3)+D[A+56>>2]|0,D[A+60>>2]=I>>>0<g>>>0?C+1|0:C),f[A+38>>1]<=513&&(B[A+132|0]=0,I=0,C=(C=D[A+116>>2])+((I=(g=D[A+128>>2]+7|0)>>>0<7?1:I)>>>3|0)|0,D[A+112>>2]=I=(g=I<<29|g>>>3)+D[A+112>>2]|0,D[A+116>>2]=I>>>0<g>>>0?C+1|0:C)}function ag(A,I,g){var C=0,Q=0,E=0,i=0;A:if(!(A>>>0>10||(0|(C=D[g+20>>2]))>=(0|(Q=D[g+12>>2]))&(E=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|Q))){if(Q=B[E+D[g>>2]|0],C=(E=E+1|0)?C:C+1|0,D[g+16>>2]=E,D[g+20>>2]=C,(0|Q)<0){if(!ag(A+1|0,I,g))break A;A=D[I+4>>2]<<7|(g=D[I>>2])>>>25,g=127&Q|g<<7}else A=0,g=255&Q;D[I>>2]=g,D[I+4>>2]=A,i=1}return i}function rg(A,I,g,C){B[A+53|0]=1;A:if(D[A+4>>2]==(0|g)){B[A+52|0]=1;I:{if(!(g=D[A+16>>2])){if(D[A+36>>2]=1,D[A+24>>2]=C,D[A+16>>2]=I,1!=D[A+48>>2])break A;if(1==(0|C))break I;break A}if((0|I)==(0|g)){if(2==(0|(g=D[A+24>>2]))&&(D[A+24>>2]=C,g=C),1!=D[A+48>>2])break A;if(1==(0|g))break I;break A}D[A+36>>2]=D[A+36>>2]+1}B[A+54|0]=1}}function Dg(A,I,g){g|=0;var C,Q=0;d=C=d-16|0,D[4+(A|=0)>>2]=I|=0,Q=D[(I=D[I+64>>2])>>2],I=D[I+4>>2],B[C+15|0]=0,hI(A+24|0,(I-Q>>2>>>0)/3|0,C+15|0),Q=D[(I=D[A+4>>2])+56>>2],I=D[I+52>>2],B[C+14|0]=0,hI(A+36|0,Q-I>>2,C+14|0),I=D[g+12>>2],D[A+16>>2]=D[g+8>>2],D[A+20>>2]=I,I=D[g+4>>2],D[A+8>>2]=D[g>>2],D[A+12>>2]=I,d=C+16|0}function eg(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0;if(I)for(E=0-e[A+12|0]&255,i=D[A>>2],Q=D[A+8>>2];o=C<<1,Q>>>0>4095||(0|(C=D[A+4>>2]))<=0||(D[A+4>>2]=C=C-1|0,Q=e[C+i|0]|Q<<8),C=(B=255&Q)>>>0<E>>>0,a=B,B=s(Q>>>8|0,E),D[A+8>>2]=Q=C?a+B|0:Q-(E+B|0)|0,C|=o,I=I-1|0;);D[g>>2]=C}function fg(A){D[A>>2]=0,D[A+4>>2]=0,D[A+28>>2]=0,D[A+32>>2]=0,B[A+24|0]=1,D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0,D[A+36>>2]=0,D[A+40>>2]=0,D[A+44>>2]=0,D[A+48>>2]=0,D[A+52>>2]=0,D[A+56>>2]=0,D[A+60>>2]=0,D[A+64>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+88>>2]=0,D[A+92>>2]=0,D[A+68>>2]=A}function kg(A,I){var g,C,Q,B=0,E=0;D[A+144>>2]=I,B=D[32+(0|RQ[D[D[I>>2]+32>>2]](I))>>2],g=D[B>>2]+D[B+16>>2]|0,E=D[32+(0|RQ[D[D[I>>2]+32>>2]](I))>>2],B=(B=D[E+8>>2])-(E=D[E+16>>2])|0,C=A,Q=f[D[32+(0|RQ[D[D[I>>2]+32>>2]](I))>>2]+38>>1],r[C+38>>1]=Q,D[A>>2]=g,D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=B,D[A+12>>2]=0}function tg(A){var I;D[A>>2]=0,D[A+4>>2]=0,D[A+56>>2]=0,D[A+48>>2]=0,D[A+52>>2]=0,D[A+40>>2]=0,D[A+44>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0,D[(I=A- -64|0)>>2]=0,D[I+4>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+60>>2]=A}function Ng(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!Ng(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function sg(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!sg(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function Fg(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!Fg(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function ng(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!ng(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function Rg(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!Rg(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function yg(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!yg(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function Gg(A,I,g){var C=0,Q=0,B=0,E=0,i=0;A:if(!(A>>>0>5||(0|(C=B=D[g+20>>2]))>=(0|(E=D[g+12>>2]))&(Q=D[g+16>>2])>>>0>=k[g+8>>2]|(0|C)>(0|E))){if(C=e[Q+D[g>>2]|0],B=(Q=Q+1|0)?B:B+1|0,D[g+16>>2]=Q,D[g+20>>2]=B,128&C){if(!Gg(A+1|0,I,g))break A;C=127&C|D[I>>2]<<7}D[I>>2]=C,i=1}return i}function cg(A,I,g){var C=0,Q=0;A:{I:{if(g>>>0>=4){if(3&(A|I))break I;for(;;){if(D[A>>2]!=D[I>>2])break I;if(I=I+4|0,A=A+4|0,!((g=g-4|0)>>>0>3))break}}if(!g)break A}for(;;){if((0|(C=e[0|A]))==(0|(Q=e[0|I]))){if(I=I+1|0,A=A+1|0,g=g-1|0)continue;break A}break}return C-Q|0}return 0}function wg(A){var I=0,g=0,C=0;if(A){if(C=D[A+24>>2]){if((0|(g=D[A+28>>2]))==(0|C))I=C;else{for(;I=D[(g=g-4|0)>>2],D[g>>2]=0,I&&(AC(I+12|0,D[I+16>>2]),aC(I,D[I+4>>2]),sA(I)),(0|C)!=(0|g););I=D[A+24>>2]}D[A+28>>2]=C,sA(I)}AC(A+12|0,D[A+16>>2]),aC(A,D[A+4>>2]),sA(A)}}function bg(A){var I=0,g=0,C=0;A:{if(3&(I=A))for(;;){if(!e[0|I])break A;if(!(3&(I=I+1|0)))break}for(;g=I,I=I+4|0,!((-1^(C=D[g>>2]))&C-16843009&-2139062144););if(!(255&C))return g-A|0;for(;C=e[g+1|0],g=I=g+1|0,C;);}return I-A|0}function Ug(A){var I,g=0,C=0;if(D[(A|=0)>>2]=13312,(g=D[A+20>>2])&&(D[A+24>>2]=g,sA(g)),I=D[A+8>>2]){if((0|(C=D[A+12>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+8>>2]}D[A+12>>2]=I,sA(g)}sA(A)}function hg(A,I,g){A|=0,I|=0;var C,Q,B,E,i=0,o=0;return(E=D[8+(g|=0)>>2])>>>0>(Q=D[g+16>>2])>>>0&(0|(i=B=D[g+12>>2]))>=(0|(C=D[g+20>>2]))|(0|C)<(0|i)&&(I=e[Q+D[g>>2]|0],i=(o=Q+1|0)?C:C+1|0,D[g+16>>2]=o,D[g+20>>2]=i,D[A+4>>2]=I),Q>>>0<E>>>0&(0|C)<=(0|B)|(0|C)<(0|B)}function Jg(A,I,g){var C=0;if(!g)return D[A+4>>2]==D[I+4>>2];if((0|A)==(0|I))return 1;A:if(!(!(A=e[0|(C=D[A+4>>2])])|(0|(I=e[0|(g=D[I+4>>2])]))!=(0|A)))for(;;){if(I=e[g+1|0],!(A=e[C+1|0]))break A;if(g=g+1|0,C=C+1|0,(0|A)!=(0|I))break}return(0|A)==(0|I)}function Sg(A,I){var g=0,C=0,Q=0,B=0;A:{if(!(D[A+8>>2]-(g=D[A>>2])>>2>>>0>=I>>>0)){if(I>>>0>=1073741824)break A;C=D[A+4>>2],Q=(I=DC(Q=I<<2))+Q|0,B=(C=C-g|0)+I|0,(0|C)>0&&xA(I,g,C),D[A+8>>2]=Q,D[A+4>>2]=B,D[A>>2]=I,g&&sA(g)}return}xg(1336),U()}function Yg(A){var I=0;A&&((I=D[A+76>>2])&&(D[A+80>>2]=I,sA(I)),(I=D[A- -64>>2])&&(D[A+68>>2]=I,sA(I)),(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),(I=D[A+24>>2])&&(D[A+28>>2]=I,sA(I)),(I=D[A+12>>2])&&(D[A+16>>2]=I,sA(I)),(I=D[A>>2])&&(D[A+4>>2]=I,sA(I)),sA(A))}function Kg(A,I,g){var C,Q,B=0,E=0,i=0;for(d=C=(d=Q=d-16|0)-16|0,I=I-A>>2;I;)D[C+12>>2]=A,D[C+12>>2]=D[C+12>>2]+((B=I>>>1|0)<<2),i=(-1^B)+I|0,I=B,I=(E=k[(B=D[C+12>>2])>>2]<k[g>>2])?i:I,A=E?B+4|0:A;return d=C+16|0,d=Q+16|0,A}function Mg(A){var I=0;(I=D[A+84>>2])&&(D[A+88>>2]=I,sA(I)),(I=D[A+72>>2])&&(D[A+76>>2]=I,sA(I)),(I=D[A+52>>2])&&(D[A+56>>2]=I,sA(I)),(I=D[A+40>>2])&&(D[A+44>>2]=I,sA(I)),(I=D[A+28>>2])&&(D[A+32>>2]=I,sA(I)),(I=D[A+12>>2])&&sA(I),(A=D[A>>2])&&sA(A)}function lg(A){var I,g=0,C=0;if((0|(g=D[A+4>>2]))!=(0|(I=D[A>>2])))for(;(C=D[g-12>>2])&&(D[g-8>>2]=C,sA(C)),(C=D[g-28>>2])&&(D[g-24>>2]=C,sA(C)),(C=D[g-40>>2])&&(D[g-36>>2]=C,sA(C)),Mg(g-140|0),(0|I)!=(0|(g=g-144|0)););D[A+4>>2]=I}function Lg(A,I,g){var C=0,Q=0;A:{if(g>>>0<=10)B[(C=A)+11|0]=g;else{if(g>>>0>4294967279)break A;C=g>>>0>=11?11==(0|(C=(Q=g+16&-16)-1|0))?Q:C:10,C=DC(Q=C+1|0),D[A>>2]=C,D[A+8>>2]=-2147483648|Q,D[A+4>>2]=g}return void zC(C,I,g+1|0)}aQ(),U()}function dg(A,I){var g,C;return C=DC(40),D[C>>2]=-1,D[16+(g=C+8|0)>>2]=0,D[g+20>>2]=0,D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,RQ[D[D[A>>2]+16>>2]](A,C),A=D[I+88>>2],D[I+88>>2]=C,A&&((I=D[A+8>>2])&&(D[A+12>>2]=I,sA(I)),sA(A)),1}function ug(A){var I,g,C=0,Q=0,B=0;return B=e[A+12|0],(Q=D[A+8>>2])>>>0>4095||(0|(C=D[A+4>>2]))<=0||(D[A+4>>2]=C=C-1|0,Q=e[C+D[A>>2]|0]|Q<<8),C=s(B=0-B&255,Q>>>8|0),D[A+8>>2]=(g=(I=255&Q)>>>0<B>>>0)?C+I|0:Q-(C+B|0)|0,g}function pg(A,I){return D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=2012,D[A+12>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+40>>2]=0,D[A>>2]=2356,D[A+44>>2]=0,D[A+48>>2]=0,D[A+52>>2]=0,D[A+56>>2]=0,D[A+60>>2]=I,A}function Hg(A,I,g,C){if(I){if((0|C)<0)return 0;!C&D[A+4>>2]-D[A>>2]>>>0>=g>>>0||Cg(A,g),g&&RI(D[A>>2],I,g)}else{if((0|C)<0)return 0;Cg(A,g)}return I=D[A+28>>2],I=(g=D[A+24>>2]+1|0)?I:I+1|0,D[A+24>>2]=g,D[A+28>>2]=I,1}function qg(A){var I=0,g=0,C=0;if(B[D[A>>2]]-48>>>0>=10)return 0;for(;C=D[A>>2],g=-1,I>>>0<=214748364&&(g=(0|(g=B[0|C]-48|0))>(2147483647-(I=s(I,10))|0)?-1:g+I|0),D[A>>2]=C+1,I=g,B[C+1|0]-48>>>0<10;);return I}function Wg(A){var I=0,g=0;(A|=0)&&(I=D[A+88>>2],D[A+88>>2]=0,I&&((g=D[I+8>>2])&&(D[I+12>>2]=g,sA(g)),sA(I)),(I=D[A+68>>2])&&(D[A+72>>2]=I,sA(I)),I=D[A+64>>2],D[A+64>>2]=0,I&&((g=D[I>>2])&&(D[I+4>>2]=g,sA(g)),sA(I)),sA(A))}function Vg(A,I){var g,C=0,Q=0;if((g=bg(I))>>>0<4294967280){A:{if(g>>>0>=11)C=DC(Q=g+16&-16),D[A+8>>2]=-2147483648|Q,D[A>>2]=C,D[A+4>>2]=g;else if(B[A+11|0]=g,C=A,!g)break A;xA(C,I,g)}return B[g+C|0]=0,A}aQ(),U()}function _g(A,I,g,C){var Q,B=0,E=0;return Q=(E=I^C)>>31,E>>=31,A=vA((A^=B=I>>31)-B|0,B=(I^B)-((A>>>0<B>>>0)+B|0)|0,(I=g^(A=C>>31))-A|0,(A^C)-((A>>>0>I>>>0)+A|0)|0)^E,u=(Q^u)-((A>>>0<E>>>0)+Q|0)|0,I=A-E|0}function Tg(A,I,g){var C,Q=0;d=C=d-16|0,(Q=2147483647&D[A+8>>2])>>>0>g>>>0?(Q=D[A>>2],D[A+4>>2]=g,zC(Q,I,g),B[C+15|0]=0,B[g+Q|0]=e[C+15|0]):xI(A,Q-1|0,1+(g-Q|0)|0,A=D[A+4>>2],A,g,I),d=C+16|0}function mg(A,I,g,C){var Q,B,E,i,o=0,a=0;return i=s(o=g>>>16|0,a=A>>>16|0),o=(65535&(a=((E=s(Q=65535&g,B=65535&A))>>>16|0)+s(a,Q)|0))+s(o,B)|0,u=(s(I,g)+i|0)+s(A,C)+(a>>>16)+(o>>>16)|0,65535&E|o<<16}function Zg(A,I,g){var C;if(!(C=D[A+16>>2]))return D[A+36>>2]=1,D[A+24>>2]=g,void(D[A+16>>2]=I);A:{if((0|I)==(0|C)){if(2!=D[A+24>>2])break A;return void(D[A+24>>2]=g)}B[A+54|0]=1,D[A+24>>2]=2,D[A+36>>2]=D[A+36>>2]+1}}function xg(A){var I,g,C,Q,B;I=0|L(8),D[I>>2]=14928,D[I>>2]=14972,C=DC((g=bg(A))+13|0),D[C+8>>2]=0,D[C+4>>2]=g,D[C>>2]=g,Q=I,B=xA(C+12|0,A,g+1|0),D[Q+4>>2]=B,D[I>>2]=15020,l(0|I,15052,13),U()}function Xg(A,I,g,C,Q){var B;if(d=B=d-256|0,!(73728&Q|(0|g)<=(0|C))){if(bI(B,255&I,(C=(g=g-C|0)>>>0<256)?g:256),!C)for(;VC(A,B,256),(g=g-256|0)>>>0>255;);VC(A,B,g)}d=B+256|0}function jg(A,I,g){var C=0;return(0|(C=A+4|0))==(0|(A=LI(A,I)))?0:((0|(I=D[A+32>>2]))!=(0|(C=D[A+28>>2]))&&(CI(g,I-C|0),xA(rC(g),g=D[A+28>>2],D[A+32>>2]-g|0)),(0|I)!=(0|C))}function Og(A,I){var g,C=0;if(A=D[A+12>>2]-(g=D[A+8>>2])|0)for(C=(A>>=2)>>>0>1?A:1,A=0;;){if(D[D[(A<<2)+g>>2]+60>>2]==(0|I))return A;if((0|C)==(0|(A=A+1|0)))break}return-1}function vg(A){var I=0;return D[A+72>>2]=(I=D[A+72>>2])-1|I,8&(I=D[A>>2])?(D[A>>2]=32|I,-1):(D[A+4>>2]=0,D[A+8>>2]=0,D[A+28>>2]=I=D[A+44>>2],D[A+20>>2]=I,D[A+16>>2]=I+D[A+48>>2],0)}function zg(A){return D[A+8>>2]=0,D[A+12>>2]=0,D[A>>2]=0,D[A+40>>2]=0,D[A+44>>2]=0,D[A+28>>2]=9,B[A+24|0]=1,D[A+56>>2]=-1,D[A+60>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+48>>2]=0,D[A+52>>2]=0,A}function Pg(A){var I,g;return(A=(I=D[3866])+(g=A+3&-4)|0)>>>0<=I>>>0&&g||A>>>0>yQ()<<16>>>0&&!(0|K(0|A))?(D[3934]=48,-1):(D[3866]=A,I)}function $g(A,I,g){var C;d=C=d-16|0,g>>>0<=10?(B[A+11|0]=g,zC(A,I,g),B[C+15|0]=0,B[A+g|0]=e[C+15|0]):xI(A,10,g-10|0,A=e[A+11|0],A,g,I),d=C+16|0}function AC(A,I){I&&(AC(A,D[I>>2]),AC(A,D[I+4>>2]),A=D[I+28>>2],D[I+28>>2]=0,A&&(AC(A+12|0,D[A+16>>2]),aC(A,D[A+4>>2]),sA(A)),B[I+27|0]<0&&sA(D[I+16>>2]),sA(I))}function IC(A){return D[A+40>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=13312,D[A+12>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,D[A+32>>2]=0,r[A+36>>1]=0,A}function gC(A){var I=0;return!D[(A|=0)- -64>>2]|!D[A+68>>2]|!D[A+44>>2]|!D[A+48>>2]||!D[A+52>>2]|!D[A+56>>2]||(I=-1!=D[A+92>>2]),0|I}function CC(A){var I=0;return D[(A|=0)>>2]=2476,I=D[A+20>>2],D[A+20>>2]=0,I&&RQ[D[D[I>>2]+4>>2]](I),D[A>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),0|A}function QC(A){var I=0;return!D[48+(A|=0)>>2]|!D[A+52>>2]|!D[A+28>>2]|!D[A+32>>2]||!D[A+36>>2]|!D[A+40>>2]||(I=-1!=D[A+76>>2]),0|I}function BC(A){var I=0;return D[(A|=0)>>2]=11900,(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12152,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),0|A}function EC(A){var I=0;D[(A|=0)>>2]=2476,I=D[A+20>>2],D[A+20>>2]=0,I&&RQ[D[D[I>>2]+4>>2]](I),D[A>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),sA(A)}function iC(A,I){var g=0;return g=-1,-1==(0|I)|(0|I)>4||(I=s(I,12)+A|0,(D[I+24>>2]-(A=D[I+20>>2])|0)<=0||(g=D[A>>2])),g}function oC(A,I,g,C,Q,E,i){D[A>>2]=0,D[A+56>>2]=I,D[A+48>>2]=0,D[A+52>>2]=0,D[A+40>>2]=E,D[A+44>>2]=i,B[A+32|0]=Q,D[A+28>>2]=C,B[A+24|0]=g}function aC(A,I){I&&(aC(A,D[I>>2]),aC(A,D[I+4>>2]),(A=D[I+28>>2])&&(D[I+32>>2]=A,sA(A)),B[I+27|0]<0&&sA(D[I+16>>2]),sA(I))}function rC(A){return(e[A+11|0]>>>7|0?D[A+4>>2]:e[A+11|0])||(FQ(),U()),e[A+11|0]>>>7|0&&(A=D[A>>2]),A}function DC(A){var I=0;A=A||1;A:{for(;;){if(I=q(A))break A;if(!(I=D[3977]))break;RQ[0|I]()}h(),U()}return I}function eC(A,I){I&&(eC(A,D[I>>2]),eC(A,D[I+4>>2]),B[I+39|0]<0&&sA(D[I+28>>2]),B[I+27|0]<0&&sA(D[I+16>>2]),sA(I))}function fC(A,I){A|=0;var g=0;A:switch(0|(I|=0)){case 1:I=1;case 0:D[A+28>>2]=I,g=1}return 0|g}function kC(A){var I,g;return D[(A|=0)>>2]=14972,D[8+(I=D[A+4>>2]-12|0)>>2]=g=D[I+8>>2]-1|0,(0|g)<0&&sA(I),0|A}function tC(A,I,g){return g|=0,D[4+(A|=0)>>2]=I|=0,I=D[D[D[I+4>>2]+8>>2]+(g<<2)>>2],D[A+12>>2]=g,D[A+8>>2]=I,1}function NC(A){var I=0;return!D[60+(A|=0)>>2]|!D[A+44>>2]|!D[A+48>>2]|!D[A+52>>2]||(I=0!=D[A+56>>2]),0|I}function sC(A,I){var g,C;Cg(A,I),g=I=D[A+28>>2],C=I+1|0,D[A+24>>2]=I=D[A+24>>2]+1|0,D[A+28>>2]=I?g:C}function FC(A){var I=0;return!D[52+(A|=0)>>2]|!D[A+44>>2]|!D[A+48>>2]||(I=0!=D[A+56>>2]),0|I}function nC(A,I){A|=0;var g=0;return D[56+(I|=0)>>2]|!I|3!=e[I+24|0]||(D[A+60>>2]=I,g=1),0|g}function RC(A,I){A|=0;var g=0;return D[56+(I|=0)>>2]|3!=e[I+24|0]||(D[A- -64>>2]=I,g=1),0|g}function yC(A){var I=0;(I=D[A+16>>2])&&(D[A+20>>2]=I,sA(I)),(I=D[A>>2])&&(D[A+4>>2]=I,sA(I))}function GC(A,I){A|=0;var g=0;return D[56+(I|=0)>>2]|3!=e[I+24|0]||(D[A+48>>2]=I,g=1),0|g}function cC(A){var I;D[A+16>>2]=0,D[A+4>>2]=I=D[A>>2],D[A+12>>2]=I,I&&(D[A+4>>2]=I,sA(I))}function wC(A){var I;D[(A|=0)>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)}function bC(A){for(var I=0;A;)A&=A-1,I=I+1|0;return I}function UC(){var A;return A=DC(12),D[A>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,0|A}function hC(A){var I=0;(A|=0)&&((I=D[A>>2])&&(D[A+4>>2]=I,sA(I)),sA(A))}function JC(A){var I;return(-1>>>(I=31&A)&-2)<<I|(-1<<(A=0-A&31)&-2)>>>A}function SC(A,I,g){A=Eg(A,I,g)}function YC(A,I){return 0|RQ[D[D[(A|=0)>>2]+12>>2]](A,I|=0)}function KC(A,I){return D[D[(A|=0)>>2]+((I|=0)<<2)>>2]}function MC(A){return D[A>>2]=13756,bI(A+4|0,0,80),A}function lC(A){return A?31-R(A-1^A)|0:32}function LC(A){return D[12+(A|=0)>>2]-D[A+8>>2]>>2}function dC(A){(A|=0)&&RQ[D[D[A>>2]+4>>2]](A)}function uC(A,I){return D[4+(A|=0)>>2]=I|=0,1}function pC(A){return D[4+(A|=0)>>2]-D[A>>2]>>1}function HC(A){return D[4+(A|=0)>>2]-D[A>>2]>>2}function qC(A){return D[4+(A|=0)>>2]-D[A>>2]|0}function WC(A){IC(A),D[A+44>>2]=0,D[A>>2]=11208}function VC(A,I,g){32&e[0|A]||Eg(I,g,A)}function _C(A){return D[28+(A|=0)>>2]}function TC(A){return D[80+(A|=0)>>2]}function mC(A,I){return-1}function ZC(A){return D[4+(A|=0)>>2]}function xC(A){return D[8+(A|=0)>>2]}function XC(A,I){return 6}function jC(A,I){return 1}function OC(A,I){return 0}function vC(A){return D[(A|=0)>>2]}function zC(A,I,g){g&&xA(A,I,g)}function PC(A){(A|=0)&&sA(A)}function $C(A){return 0|(A|=0)}function AQ(A){return 3}function IQ(A){return 0}function gQ(A){return 4}function CQ(A){return 2}function QQ(A){return 5}function BQ(A){return 6}function EQ(A){return 1}function iQ(){xg(1276),U()}function oQ(A){sA(A|=0)}function aQ(){xg(1323),U()}function rQ(A){U()}function DQ(){return 3}function eQ(){return 4}function fQ(){return-1}function kQ(){return 1}function tQ(){return 0}function NQ(){return 2}function sQ(){FQ(),U()}function FQ(){h(),U()}function nQ(A){}Q(I=e,1028," "),Q(I,12180,"AQAAAAMAAAAFAAAABwAAAAAAAABoMAAASAEAAEkBAABKAQAASwEAAE41ZHJhY28yMk1lc2hUcmF2ZXJzYWxTZXF1ZW5jZXJJTlNfMjhNYXhQcmVkaWN0aW9uRGVncmVlVHJhdmVyc2VySU5TXzExQ29ybmVyVGFibGVFTlNfMzZNZXNoQXR0cmlidXRlSW5kaWNlc0VuY29kaW5nT2JzZXJ2ZXJJUzJfRUVFRUVFAE41ZHJhY28xNVBvaW50c1NlcXVlbmNlckUAAAAAWDsAAEMwAACAOwAAvC8AAGAwAAD/////AAAAAFgxAABMAQAATQEAAE4BAABONWRyYWNvMjhNYXhQcmVkaWN0aW9uRGVncmVlVHJhdmVyc2VySU5TXzExQ29ybmVyVGFibGVFTlNfMzZNZXNoQXR0cmlidXRlSW5kaWNlc0VuY29kaW5nT2JzZXJ2ZXJJUzFfRUVFRQBONWRyYWNvMTNUcmF2ZXJzZXJCYXNlSU5TXzExQ29ybmVyVGFibGVFTlNfMzZNZXNoQXR0cmlidXRlSW5kaWNlc0VuY29kaW5nT2JzZXJ2ZXJJUzFfRUVFRQAAWDsAAPUwAACAOwAAjDAAAFAxAAAAAAAAUDEAAE8BAABQAQAATgEAAAAAAAAQMgAAUQEAAFIBAABTAQAAVAEAAE41ZHJhY28yMk1lc2hUcmF2ZXJzYWxTZXF1ZW5jZXJJTlNfMTlEZXB0aEZpcnN0VHJhdmVyc2VySU5TXzExQ29ybmVyVGFibGVFTlNfMzZNZXNoQXR0cmlidXRlSW5kaWNlc0VuY29kaW5nT2JzZXJ2ZXJJUzJfRUVFRUVFAAAAgDsAAJAxAABgMAAAAAAAAJAyAABVAQAAVgEAAE4BAABONWRyYWNvMTlEZXB0aEZpcnN0VHJhdmVyc2VySU5TXzExQ29ybmVyVGFibGVFTlNfMzZNZXNoQXR0cmlidXRlSW5kaWNlc0VuY29kaW5nT2JzZXJ2ZXJJUzFfRUVFRQCAOwAAMDIAAFAxAAAAAAAAQDMAAFcBAABYAQAAWQEAAFoBAABONWRyYWNvMjJNZXNoVHJhdmVyc2FsU2VxdWVuY2VySU5TXzE5RGVwdGhGaXJzdFRyYXZlcnNlcklOU18yNE1lc2hBdHRyaWJ1dGVDb3JuZXJUYWJsZUVOU18zNk1lc2hBdHRyaWJ1dGVJbmRpY2VzRW5jb2RpbmdPYnNlcnZlcklTMl9FRUVFRUUAAIA7AAC0MgAAYDA="),Q(I,13140,"rDMAABEBAABbAQAAEwEAABQBAABcAQAAFQEAABYBAAAXAQAAGAEAABkBAAAaAQAAGwEAAF0BAABONWRyYWNvMjFNZXNoU2VxdWVudGlhbERlY29kZXJFAIA7AACMMwAAFCwAAAAAAADsMwAAXgEAAF8BAABgAQAAYQEAAE41ZHJhY28xNUxpbmVhclNlcXVlbmNlckUAAACAOwAA0DMAAGAwAAAAAAAAbDQAABEBAABiAQAAYwEAABQBAAAiAAAAZAEAABYBAAAXAQAAGAE="),Q(I,13360,"RmFpbGVkIHRvIHBhcnNlIERyYWNvIGhlYWRlci4ATjVkcmFjbzE3UG9pbnRDbG91ZERlY29kZXJFAAAAWDsAAE40AAAAAAAAxDQAABEBAABlAQAAYwEAABQBAABmAQAAZwEAABYBAAAXAQAAGAEAAE41ZHJhY28yM1BvaW50Q2xvdWRLZFRyZWVEZWNvZGVyRQAAAIA7AACgNAAAbDQAAAAAAAAkNQAAEQEAAGgBAABjAQAAFAEAAGkBAABqAQAAFgEAABcBAAAYAQAATjVkcmFjbzI3UG9pbnRDbG91ZFNlcXVlbnRpYWxEZWNvZGVyRQAAAIA7AAD8NAAAbDQAAAEAAAABAAAAAgAAAAIAAAAEAAAABAAAAAgAAAAIAAAABAAAAAgAAAAB"),Q(I,13667,"wAAAAMAAAADAAAAAwP//////////AAAAAKA1AABrAQAAbAEAAG0BAABuAQAATjVkcmFjbzRNZXNoRQAAAIA7AACQNQAA5DUAAP////8AAAAAAAAAAOQ1AABvAQAAcAEAAHEBAAByAQAATjVkcmFjbzEwUG9pbnRDbG91ZEUAAAAAWDsAAMw1AADYOwAAGQAKABkZGQAAAAAFAAAAAAAACQAAAAALAAAAAAAAAAAZABEKGRkZAwoHAAEACQsYAAAJBgsAAAsABhkAAAAZGRk="),Q(I,13889,"DgAAAAAAAAAAGQAKDRkZGQANAAACAAkOAAAACQAOAAAO"),Q(I,13947,"DA=="),Q(I,13959,"EwAAAAATAAAAAAkMAAAAAAAMAAAM"),Q(I,14005,"EA=="),Q(I,14017,"DwAAAAQPAAAAAAkQAAAAAAAQAAAQ"),Q(I,14063,"Eg=="),Q(I,14075,"EQAAAAARAAAAAAkSAAAAAAASAAASAAAaAAAAGhoa"),Q(I,14130,"GgAAABoaGgAAAAAAAAk="),Q(I,14179,"FA=="),Q(I,14191,"FwAAAAAXAAAAAAkUAAAAAAAUAAAU"),Q(I,14237,"Fg=="),Q(I,14249,"FQAAAAAVAAAAAAkWAAAAAAAWAAAWAAAwMTIzNDU2Nzg5QUJDREVGAAAAAAIAAAADAAAABQAAAAcAAAALAAAADQAAABEAAAATAAAAFwAAAB0AAAAfAAAAJQAAACkAAAArAAAALwAAADUAAAA7AAAAPQAAAEMAAABHAAAASQAAAE8AAABTAAAAWQAAAGEAAABlAAAAZwAAAGsAAABtAAAAcQAAAH8AAACDAAAAiQAAAIsAAACVAAAAlwAAAJ0AAACjAAAApwAAAK0AAACzAAAAtQAAAL8AAADBAAAAxQAAAMcAAADTAAAAAQAAAAsAAAANAAAAEQAAABMAAAAXAAAAHQAAAB8AAAAlAAAAKQAAACsAAAAvAAAANQAAADsAAAA9AAAAQwAAAEcAAABJAAAATwAAAFMAAABZAAAAYQAAAGUAAABnAAAAawAAAG0AAABxAAAAeQAAAH8AAACDAAAAiQAAAIsAAACPAAAAlQAAAJcAAACdAAAAowAAAKcAAACpAAAArQAAALMAAAC1AAAAuwAAAL8AAADBAAAAxQAAAMcAAADRAAAAMDAwMTAyMDMwNDA1MDYwNzA4MDkxMDExMTIxMzE0MTUxNjE3MTgxOTIwMjEyMjIzMjQyNTI2MjcyODI5MzAzMTMyMzMzNDM1MzYzNzM4Mzk0MDQxNDI0MzQ0NDU0NjQ3NDg0OTUwNTE1MjUzNTQ1NTU2NTc1ODU5NjA2MTYyNjM2NDY1NjY2NzY4Njk3MDcxNzI3Mzc0NzU3Njc3Nzg3OTgwODE4MjgzODQ4NTg2ODc4ODg5OTA5MTkyOTM5NDk1OTY5Nzk4OTk="),Q(I,14884,"CgAAAGQAAADoAwAAECcAAKCGAQBAQg8AgJaYAADh9QUAypo7AAAAAGw6AAB2AQAAdwEAAHgBAABTdDlleGNlcHRpb24AAAAAWDsAAFw6AAAAAAAAmDoAAA0AAAB5AQAAegEAAFN0MTFsb2dpY19lcnJvcgCAOwAAiDoAAGw6AAAAAAAAzDoAAA0AAAB7AQAAegEAAFN0MTJsZW5ndGhfZXJyb3IAAAAAgDsAALg6AACYOgAAU3Q5dHlwZV9pbmZvAAAAAFg7AADYOgAATjEwX19jeHhhYml2MTE2X19zaGltX3R5cGVfaW5mb0UAAAAAgDsAAPA6AADoOgAATjEwX19jeHhhYml2MTE3X19jbGFzc190eXBlX2luZm9FAAAAgDsAACA7AAAUOwAAAAAAAEQ7AAB8AQAAfQEAAH4BAAB/AQAAgAEAAIEBAACCAQAAgwEAAAAAAADIOwAAfAEAAIQBAAB+AQAAfwEAAIABAACFAQAAhgEAAIcBAABOMTBfX2N4eGFiaXYxMjBfX3NpX2NsYXNzX3R5cGVfaW5mb0UAAAAAgDsAAKA7AABEOw=="),Q(I,15320,"BQ=="),Q(I,15332,"cwE="),Q(I,15356,"dAEAAHUBAAB4PQ=="),Q(I,15380,"Ag=="),Q(I,15396,"//////////8="),Q(I,15464,"MERQAAAAAAAF"),Q(I,15484,"iAE="),Q(I,15508,"dAEAAIkBAAAoQAAAAAQ="),Q(I,15532,"AQ=="),Q(I,15548,"/////wo=");var RQ=function(A){return A.set=function(A,I){this[A]=I},A.get=function(A){return this[A]},A}([null,$C,oQ,CQ,function(A,I){A|=0;var g=0;return!(I=D[88+(I|=0)>>2])|2!=D[I>>2]||(D[(g=A)+4>>2]=e[0|(A=D[I+8>>2])]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,g=1),0|g},function(A,I){A|=0;var g,C=0;D[(I|=0)>>2]=2,(g=D[I+12>>2]-(C=D[I+8>>2])|0)>>>0<=4294967291&&(sC(I+8|0,g+4|0),C=D[I+8>>2]),B[0|(I=C+g|0)]=A=D[A+4>>2],B[I+1|0]=A>>>8,B[I+2|0]=A>>>16,B[I+3|0]=A>>>24},function(A,I,g,C){I|=0,g|=0;var Q,B=0,E=0,i=0,o=0,a=0,r=0,f=0;if(i=D[80+(C|=0)>>2],d=Q=d-48|0,!((A=D[4+(A|=0)>>2])-31>>>0<4294967267))if(o=D[D[C>>2]>>2]+D[C+48>>2]|0,D[Q+16>>2]=A,D[Q+20>>2]=-1^(A=-1<<A),D[Q+24>>2]=A=-2-A|0,D[Q+32>>2]=(0|A)/2,t[Q+28>>2]=F(2)/F(0|A),(0|(E=D[g>>2]))==D[g+4>>2])if(i)for(C=0,A=0;xA(a=Q+36|0,(g=D[D[I>>2]>>2])+(E=D[I+48>>2]+mg(B=D[I+40>>2],D[I+44>>2],e[I+84|0]?A:D[D[I+68>>2]+(A<<2)>>2],0)|0)|0,B),eI(Q+16|0,a,Q+12|0,Q+8|0),D[(g=C<<2)+o>>2]=D[Q+12>>2],D[(4|g)+o>>2]=D[Q+8>>2],C=C+2|0,B=1,(0|i)!=(0|(A=A+1|0)););else B=1;else for(A=0,C=0;B=D[(C<<2)+E>>2],a=D[D[I>>2]>>2],f=D[I+48>>2],e[I+84|0]||(B=D[D[I+68>>2]+(B<<2)>>2]),xA(i=Q+36|0,(B=mg(r=D[I+40>>2],E=D[I+44>>2],B,0)+f|0)+a|0,r),eI(Q+16|0,i,Q+12|0,Q+8|0),D[(E=A<<2)+o>>2]=D[Q+12>>2],D[(4|E)+o>>2]=D[Q+8>>2],B=1,A=A+2|0,(C=C+1|0)>>>0<D[g+4>>2]-(E=D[g>>2])>>2>>>0;);return d=Q+48|0,0|B},DI,function(A,I){I|=0;var g,C=0;return d=g=d-16|0,-1!=(0|(A=D[4+(A|=0)>>2]))&&(B[g+15|0]=A,!!D[I+16>>2]&(0|(C=D[I+20>>2]))>=0|(0|C)>0||dA(I,D[I+4>>2],g+15|0,g+16|0)),d=g+16|0,-1!=(0|A)|0},hg,function(A,I,g){var C,Q,E;return g|=0,d=C=d+-64|0,Q=0|RQ[D[D[(A|=0)>>2]+44>>2]](A,I|=0),A=0|RQ[D[D[A>>2]+40>>2]](A,I),oC(E=zg(C),D[I+56>>2],Q<<24>>24,A,0,A=s(A=(A=A-1|0)>>>0<=10?D[13616+(A<<2)>>2]:-1,Q),A>>31),KI(A=lI(DC(96),E),g),B[A+84|0]=1,D[A+72>>2]=D[A+68>>2],D[A+60>>2]=D[I+60>>2],d=C- -64|0,0|A},XC,function(A,I){return 2},kC,function(A){var I;return D[(A|=0)>>2]=1140,(I=D[A+8>>2])&&(D[A+12>>2]=I,sA(I)),0|A},function(A){var I;D[(A|=0)>>2]=1140,(I=D[A+8>>2])&&(D[A+12>>2]=I,sA(I)),sA(A)},EQ,function(A,I){A|=0;var g=0,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0;if(!(!(g=D[88+(I|=0)>>2])|1!=D[g>>2])){if(D[A+4>>2]=e[0|(C=D[g+8>>2])]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,(C=B[I+24|0])>>>0>(E=D[A+12>>2]-(Q=D[A+8>>2])>>2)>>>0?($I(A+8|0,C-E|0),C=B[I+24|0],Q=D[A+8>>2]):C>>>0>=E>>>0||(D[A+12>>2]=(C<<2)+Q),f=1,E=D[g+8>>2],(0|C)<=0)I=4;else{if(o=3&C,C-1>>>0<3)I=4,C=0;else for(k=-4&C,C=0,I=4;D[(i=C<<2)+Q>>2]=e[0|(g=I+E|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[(4|i)+Q>>2]=e[g+4|0]|e[g+5|0]<<8|e[g+6|0]<<16|e[g+7|0]<<24,D[(8|i)+Q>>2]=e[g+8|0]|e[g+9|0]<<8|e[g+10|0]<<16|e[g+11|0]<<24,D[(12|i)+Q>>2]=e[g+12|0]|e[g+13|0]<<8|e[g+14|0]<<16|e[g+15|0]<<24,C=C+4|0,I=I+16|0,(0|k)!=(0|(a=a+4|0)););if(o)for(;D[(C<<2)+Q>>2]=e[0|(g=I+E|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,C=C+1|0,I=I+4|0,(0|(r=r+1|0))!=(0|o););}D[(g=A)+20>>2]=e[0|(A=I+E|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24}return 0|f},function(A,I){A|=0;var g,C=0,Q=0,E=0,i=0;if(D[(I|=0)>>2]=1,g=I+8|0,(Q=D[I+12>>2]-(C=D[I+8>>2])|0)>>>0<=4294967291&&(sC(g,Q+4|0),C=D[g>>2]),B[0|(C=C+Q|0)]=Q=D[A+4>>2],B[C+1|0]=Q>>>8,B[C+2|0]=Q>>>16,B[C+3|0]=Q>>>24,(0|(C=D[A+8>>2]))!=D[A+12>>2])for(Q=0;i=(Q<<2)+C|0,(E=D[I+12>>2]-(C=D[I+8>>2])|0)>>>0<=4294967291&&(sC(g,E+4|0),C=D[g>>2]),B[0|(C=C+E|0)]=E=D[i>>2],B[C+1|0]=E>>>8,B[C+2|0]=E>>>16,B[C+3|0]=E>>>24,(Q=Q+1|0)>>>0<D[A+12>>2]-(C=D[A+8>>2])>>2>>>0;);(C=(C=D[I+12>>2])-(I=D[I+8>>2])|0)>>>0<=4294967291&&(sC(g,C+4|0),I=D[g>>2]),B[0|(I=I+C|0)]=A=D[A+20>>2],B[I+1|0]=A>>>8,B[I+2|0]=A>>>16,B[I+3|0]=A>>>24},function(A,I,g,C){A|=0,I|=0,g|=0,C|=0;var Q,E=F(0),i=0,o=0,a=0,r=0,f=0,k=F(0),N=0,s=0,R=0,y=0,G=0,w=0,b=0,U=0,h=0,J=0,S=0,Y=0,K=0,M=0;if(D[g>>2]==D[g+4>>2]){if(o=D[C+80>>2],d=J=d-16|0,f=D[A+4>>2],a=D[C+48>>2],C=D[D[C>>2]>>2],r=B[I+24|0],D[(g=J+8|0)>>2]=1065353216,h=g,t[g>>2]=F(-1<<f^-1)/t[A+20>>2],S=DC((0|r)!=(1073741823&r)?-1:r<<2),!(!o|(0|r)<=0))if(b=C+a|0,K=D[I>>2],g=D[I+48>>2],M=D[I+44>>2],Y=D[I+40>>2],e[I+84|0])for(R=-2&r,U=1&r,I=0;;){if(G=xA(S,(a=D[K>>2])+(C=mg(Y,M,y,i)+g|0)|0,Y),k=t[h>>2],N=D[A+8>>2],C=0,s=0,1!=(0|r))for(;a=b+(I<<2)|0,E=F(c(F(F(k*F(t[(w=C<<2)+G>>2]-t[N+w>>2]))+F(.5)))),f=F(n(E))<F(2147483648)?~~E:-2147483648,D[a>>2]=f,E=F(c(F(F(k*F(t[(f=4|w)+G>>2]-t[N+f>>2]))+F(.5)))),f=F(n(E))<F(2147483648)?~~E:-2147483648,D[a+4>>2]=f,C=C+2|0,I=I+2|0,(0|R)!=(0|(s=s+2|0)););if(U&&(a=b+(I<<2)|0,E=F(c(F(F(k*F(t[(C<<=2)+G>>2]-t[C+N>>2]))+F(.5)))),C=F(n(E))<F(2147483648)?~~E:-2147483648,D[a>>2]=C,I=I+1|0),y=C=y+1|0,!((0|o)!=(0|C)|(i=C?i:i+1|0)))break}else for(R=D[I+68>>2],U=-2&r,f=1&r,I=0;;){if(G=xA(S,(i=D[K>>2])+(C=mg(Y,M,D[R+(y<<2)>>2],0)+g|0)|0,Y),k=t[h>>2],N=D[A+8>>2],C=0,s=0,1!=(0|r))for(;i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(w=C<<2)+G>>2]-t[N+w>>2]))+F(.5)))),a=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=a,E=F(c(F(F(k*F(t[(a=4|w)+G>>2]-t[N+a>>2]))+F(.5)))),a=F(n(E))<F(2147483648)?~~E:-2147483648,D[i+4>>2]=a,C=C+2|0,I=I+2|0,(0|U)!=(0|(s=s+2|0)););if(f&&(i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(C<<=2)+G>>2]-t[C+N>>2]))+F(.5)))),C=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=C,I=I+1|0),(0|o)==(0|(y=y+1|0)))break}return sA(S),d=J+16|0,1}if(d=J=d-16|0,h=D[A+4>>2],o=D[C+48>>2],i=D[D[C>>2]>>2],Q=B[I+24|0],D[(C=J+8|0)>>2]=1065353216,a=C,t[C>>2]=F(-1<<h^-1)/t[A+20>>2],S=DC((0|Q)!=(1073741823&Q)?-1:Q<<2),!(!(g=D[g+4>>2]-(K=D[g>>2])|0)|(0|Q)<=0))if(b=i+o|0,M=D[I>>2],C=D[I+48>>2],Y=D[I+44>>2],y=D[I+40>>2],w=(g>>=2)>>>0>1?g:1,e[I+84|0])for(f=-2&Q,h=1&Q,I=0;;){if(N=xA(S,(i=D[M>>2])+(g=mg(y,Y,D[K+(s<<2)>>2],0)+C|0)|0,y),k=t[a>>2],R=D[A+8>>2],g=0,r=0,1!=(0|Q))for(;i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(U=g<<2)+N>>2]-t[R+U>>2]))+F(.5)))),o=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=o,E=F(c(F(F(k*F(t[(o=4|U)+N>>2]-t[R+o>>2]))+F(.5)))),o=F(n(E))<F(2147483648)?~~E:-2147483648,D[i+4>>2]=o,g=g+2|0,I=I+2|0,(0|f)!=(0|(r=r+2|0)););if(h&&(i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(g<<=2)+N>>2]-t[g+R>>2]))+F(.5)))),g=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=g,I=I+1|0),(0|w)==(0|(s=s+1|0)))break}else for(U=D[I+68>>2],f=-2&Q,h=1&Q,I=0;;){if(G=xA(S,(i=D[M>>2])+(g=mg(y,Y,D[U+(D[K+(s<<2)>>2]<<2)>>2],0)+C|0)|0,y),k=t[a>>2],N=D[A+8>>2],g=0,r=0,1!=(0|Q))for(;i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(R=g<<2)+G>>2]-t[N+R>>2]))+F(.5)))),o=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=o,E=F(c(F(F(k*F(t[(o=4|R)+G>>2]-t[N+o>>2]))+F(.5)))),o=F(n(E))<F(2147483648)?~~E:-2147483648,D[i+4>>2]=o,g=g+2|0,I=I+2|0,(0|f)!=(0|(r=r+2|0)););if(h&&(i=b+(I<<2)|0,E=F(c(F(F(k*F(t[(g<<=2)+G>>2]-t[g+N>>2]))+F(.5)))),g=F(n(E))<F(2147483648)?~~E:-2147483648,D[i>>2]=g,I=I+1|0),(0|w)==(0|(s=s+1|0)))break}return sA(S),d=J+16|0,1},II,function(A,I){I|=0;var g,C,Q=0,E=0;return d=g=d-16|0,-1!=(0|(C=D[4+(A|=0)>>2]))&&(!!D[I+16>>2]&(0|(Q=D[I+20>>2]))>=0|(0|Q)>0||(dA(I,D[I+4>>2],D[A+8>>2],D[A+12>>2]),!!D[I+16>>2]&(0|(Q=D[I+20>>2]))>=0|(0|Q)>0||(dA(I,D[I+4>>2],Q=A+20|0,Q+4|0),Q=D[I+20>>2],E=D[I+16>>2],B[g+15|0]=D[A+4>>2],!!E&(0|Q)>=0|(0|Q)>0||dA(I,D[I+4>>2],g+15|0,g+16|0)))),d=g+16|0,-1!=(0|C)|0},EI,XC,function(A,I){return B[24+(I|=0)|0]},function(A){var I=0;return D[(A|=0)>>2]=2012,(I=D[A+16>>2])&&(D[A+20>>2]=I,sA(I)),(I=D[A+4>>2])&&(D[A+8>>2]=I,sA(I)),0|A},rQ,function(A,I,g){return I|=0,D[32+(A|=0)>>2]=g|=0,D[A+28>>2]=I,1},UA,function(A,I){var g=0;return 0|RQ[D[D[(A|=0)>>2]+36>>2]](A,I|=0)&&0|RQ[D[D[A>>2]+40>>2]](A,I)&&(g=0|RQ[D[D[A>>2]+44>>2]](A)),0|g},function(A,I){return D[D[4+(A|=0)>>2]+((I|=0)<<2)>>2]},function(A){return D[8+(A|=0)>>2]-D[A+4>>2]>>2},_C,OC,function(){U()},jC,EQ,ZI,function(A){sA(ZI(A|=0))},function(A,I){A|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0;d=g=d-704|0,n=1;A:{I:{g:{if(!(f[38+(I|=0)>>1]<515||(n=0,(0|(C=D[I+20>>2]))>=(0|(E=D[I+12>>2]))&(Q=D[I+16>>2])>>>0>=k[I+8>>2]|(0|C)>(0|E)))){if(y=e[Q+D[I>>2]|0],C=(Q=Q+1|0)?C:C+1|0,D[I+16>>2]=Q,D[I+20>>2]=C,R=D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+80>>2],C=0|RQ[D[D[A>>2]+24>>2]](A),D[g+696>>2]=0,D[g+688>>2]=0,D[g+692>>2]=0,C){if(C>>>0>=214748365)break g;r=DC(C=s(C,20)),D[g+688>>2]=r,D[g+696>>2]=C+r,c=g,w=bI(r,0,C=s((C-20>>>0)/20|0,20)+20|0)+C|0,D[c+692>>2]=w}C:{if((0|RQ[D[D[A>>2]+24>>2]](A))>0)for(;;){if(C=0|RQ[D[D[A>>2]+20>>2]](A,F),KI(E=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(C<<2)>>2],R),B[E+84|0]=1,D[E+72>>2]=D[E+68>>2],(C=D[E+28>>2])>>>0>9)break C;Q:{B:{E:{if(!(42&(Q=1<<C))){if(84&Q)break Q;if(9!=(0|C))break C;if(C=B[E+24|0],Q=zg(g),i=C,C=s(C,D[3409]),oC(Q,D[E+56>>2],i,6,0,C,C>>31),C=lI(E=DC(96),Q),D[g+656>>2]=E,B[C+84|0]=1,D[C+72>>2]=D[C+68>>2],KI(C,R),(C=D[A+64>>2])>>>0>=k[A+68>>2])break E;Q=D[g+656>>2],D[g+656>>2]=0,D[C>>2]=Q,D[A+64>>2]=Q=C+4|0;break B}if(Q=0,B[E+24|0]<=0)break Q;for(;;){if((C=D[A+52>>2])>>>0<(i=D[A+56>>2])>>>0)D[C>>2]=0,D[A+52>>2]=C+4;else{if((C=1+(t=(N=C-(o=D[A+48>>2])|0)>>2)|0)>>>0>=1073741824)break I;if(G=t<<2,t=(i=i-o|0)>>1,i=i>>2>>>0<536870911?C>>>0>t>>>0?C:t:1073741823){if(i>>>0>=1073741824)break A;C=DC(i<<2)}else C=0;D[(t=G+C|0)>>2]=0,(0|N)>0&&xA(C,o,N),D[A+56>>2]=C+(i<<2),D[A+52>>2]=t+4,D[A+48>>2]=C,o&&sA(o)}if(!((0|(Q=Q+1|0))<B[E+24|0]))break}break Q}Q=0;E:{i:{o:{if((C=1+(o=D[A+64>>2]-(E=D[A+60>>2])>>2)|0)>>>0<1073741824){if(i=(E=D[A+68>>2]-E|0)>>1,E=E>>2>>>0<536870911?C>>>0>i>>>0?C:i:1073741823){if(E>>>0>=1073741824)break o;Q=DC(E<<2)}if(i=D[g+656>>2],D[g+656>>2]=0,D[(C=(o<<2)+Q|0)>>2]=i,o=(E<<2)+Q|0,i=C+4|0,(0|(Q=D[A+64>>2]))==(0|(E=D[A+60>>2])))break i;for(;N=D[(Q=Q-4|0)>>2],D[Q>>2]=0,D[(C=C-4|0)>>2]=N,(0|Q)!=(0|E););if(D[A+68>>2]=o,Q=D[A+64>>2],D[A+64>>2]=i,E=D[A+60>>2],D[A+60>>2]=C,(0|Q)==(0|E))break E;for(;C=D[(Q=Q-4|0)>>2],D[Q>>2]=0,C&&Wg(C),(0|Q)!=(0|E););break E}iQ(),U()}xg(1336),U()}D[A+68>>2]=o,D[A+64>>2]=i,D[A+60>>2]=C}E&&sA(E),Q=D[A+64>>2]}E=D[Q-4>>2],C=D[g+656>>2],D[g+656>>2]=0,C&&Wg(C)}if(Q=(C=(o=D[E+28>>2])-1|0)>>>0<=10?D[13616+(C<<2)>>2]:-1,C=s(F,20)+r|0,D[C+16>>2]=i=B[E+24|0],D[C+8>>2]=o,D[C+4>>2]=a,D[C>>2]=E,D[C+12>>2]=(0|Q)>0?Q:0,a=i+a|0,F=F+1|0,!((0|RQ[D[D[A>>2]+24>>2]](A))>(0|F)))break}A=nI(g+656|0,g+688|0);Q:{B:{E:switch(0|y){case 0:if(I=_(C=zA(g,a),I,A),mI(C),I)break B;break Q;case 1:if(I=T(C=zA(g,a),I,A),mI(C),I)break B;break Q;case 2:if(I=m(C=jA(g,a),I,A),jI(C),I)break B;break Q;case 3:if(I=x(C=jA(g,a),I,A),jI(C),I)break B;break Q;case 4:if(I=Z(C=z(g,a),I,A),XI(C),I)break B;break Q;case 5:if(I=X(C=z(g,a),I,A),XI(C),I)break B;break Q;case 6:break E;default:break Q}if(I=j(C=z(g,a),I,A),XI(C),!I)break Q}n=1}(I=D[A+16>>2])&&(D[A+20>>2]=I,sA(I)),(I=D[A>>2])&&(D[A+4>>2]=I,sA(I)),r=D[g+688>>2]}r&&(D[g+692>>2]=r,sA(r))}return d=g+704|0,0|n}iQ(),U()}iQ(),U()}xg(1336),U()},function(A,I){A|=0,I|=0;var g,C=0,Q=0,o=0,a=0,r=0,N=0,n=0,R=0,y=0,G=0,c=0,w=F(0),b=0,h=0,J=0;d=g=d-720|0;A:{I:{g:{C:{Q:{B:{E:{i:{if(f[I+38>>1]>=515){if(D[g+680>>2]=0,D[g+672>>2]=0,D[g+676>>2]=0,(0|RQ[D[D[A>>2]+24>>2]](A))<=0)break C;for(;;){if(C=0|RQ[D[D[A>>2]+20>>2]](A,R),Q=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(C<<2)>>2],9==D[Q+28>>2]){if((C=D[g+676>>2]-(o=D[g+672>>2])>>2)>>>0<(a=B[Q+24|0])>>>0?$I(g+672|0,a-C|0):C>>>0<=a>>>0||(D[g+676>>2]=o+(a<<2)),r=0,C=D[I+20>>2],(N=(n=D[I+16>>2])+(Q=a<<2)|0)>>>0>k[I+8>>2]&(0|(o=D[I+12>>2]))<=(0|(C=Q>>>0>N>>>0?C+1|0:C))|(0|C)>(0|o))break I;if(xA(D[g+672>>2],n+D[I>>2]|0,Q),C=D[I+20>>2],C=(o=Q+D[I+16>>2]|0)>>>0<Q>>>0?C+1|0:C,D[I+16>>2]=o,D[I+20>>2]=C,(G=D[I+8>>2])>>>0<(N=o+4|0)>>>0&(0|(Q=N>>>0<4?C+1|0:C))>=(0|(n=y=D[I+12>>2]))|(0|Q)>(0|n))break I;if(n=e[0|(n=(c=D[I>>2])+o|0)]|e[n+1|0]<<8|e[n+2|0]<<16|e[n+3|0]<<24,D[I+16>>2]=N,D[I+20>>2]=Q,(0|Q)>=(0|y)&N>>>0>=G>>>0|(0|Q)>(0|y))break I;if(Q=e[N+c|0],C=(o=o+5|0)>>>0<5?C+1|0:C,D[I+16>>2]=o,D[I+20>>2]=C,Q>>>0>31)break I;if(E[2]=n,w=i[2],D[g+20>>2]=-1,D[g+16>>2]=1140,D[g+32>>2]=0,D[g+36>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,C=g+16|0,o=D[g+672>>2],(N=Q-1|0)>>>0<=29&&(D[C+4>>2]=Q,qI(C+8|0,o,o+(a<<2)|0),t[C+20>>2]=w),!(N>>>0>=30)){if(dg(g+16|0,D[D[A+60>>2]+((D[A+40>>2]-D[A+36>>2]|0)/24<<2)>>2]),(0|(C=D[A+40>>2]))==D[A+44>>2]){C=0;o:{a:{r:{D:{if((Q=1+(o=((a=D[A+40>>2])-(r=D[A+36>>2])|0)/24|0)|0)>>>0<178956971){if(n=(N=(D[A+44>>2]-r|0)/24|0)<<1,N=N>>>0<89478485?Q>>>0>n>>>0?Q:n:178956970){if(N>>>0>=178956971)break D;C=DC(s(N,24))}if(o=s(o,24)+C|0,D[o>>2]=1140,Q=D[g+20>>2],D[o+16>>2]=0,D[o+8>>2]=0,D[o+12>>2]=0,D[o+4>>2]=Q,Q=D[g+28>>2]-(y=D[g+24>>2])|0){if((0|Q)<0)break r;n=DC(Q),D[o+8>>2]=n,D[o+16>>2]=n+(Q>>2<<2),h=o,J=xA(n,y,Q)+Q|0,D[h+12>>2]=J}if(C=s(N,24)+C|0,t[o+20>>2]=t[g+36>>2],Q=o+24|0,(0|a)==(0|r))break a;for(;D[(o=o-24|0)>>2]=1140,D[o+4>>2]=D[a-20>>2],D[o+8>>2]=D[(N=a-16|0)>>2],D[o+12>>2]=D[a-12>>2],D[o+16>>2]=D[(n=a-8|0)>>2],D[n>>2]=0,D[N>>2]=0,D[N+4>>2]=0,t[o+20>>2]=t[a-4>>2],(0|r)!=(0|(a=a-24|0)););if(D[A+44>>2]=C,r=D[A+40>>2],D[A+40>>2]=Q,a=D[A+36>>2],D[A+36>>2]=o,(0|a)==(0|r))break o;for(;RQ[D[D[(r=r-24|0)>>2]>>2]](r),(0|a)!=(0|r););break o}iQ(),U()}xg(1336),U()}iQ(),U()}D[A+44>>2]=C,D[A+40>>2]=Q,D[A+36>>2]=o}a&&sA(a)}else{if(D[C>>2]=1140,Q=D[g+20>>2],D[C+16>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,D[C+4>>2]=Q,a=D[g+28>>2]-D[g+24>>2]|0){if((0|a)<0)break i;Q=DC(a),D[C+8>>2]=Q,D[C+12>>2]=Q,D[C+16>>2]=Q+(a>>2<<2),(0|(a=D[g+28>>2]-(o=D[g+24>>2])|0))>0&&(Q=xA(Q,o,a)+a|0),D[C+12>>2]=Q}t[C+20>>2]=t[g+36>>2],D[A+40>>2]=C+24}r=1}if(D[g+16>>2]=1140,(C=D[g+24>>2])&&(D[g+28>>2]=C,sA(C)),!r)break g}if(R=R+1|0,!((0|RQ[D[D[A>>2]+24>>2]](A))>(0|R)))break}break C}if(N=0|RQ[D[D[A>>2]+24>>2]](A),D[g+712>>2]=0,D[g+704>>2]=0,D[g+708>>2]=0,N){if(N>>>0>=214748365)break E;for(Q=DC(C=s(N,20)),D[g+704>>2]=Q,D[g+712>>2]=C+Q,Q=bI(Q,0,C=s((C-20>>>0)/20|0,20)+20|0),D[g+708>>2]=C+Q;;){if(C=0|RQ[D[D[A>>2]+20>>2]](A,R),a=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(C<<2)>>2],(y=(0|(C=(C=(n=D[a+28>>2])-1|0)>>>0<=10?D[13616+(C<<2)>>2]:-1))>0?C:0)>>>0>4)break Q;if(C=Q+s(R,20)|0,D[C+16>>2]=G=B[a+24|0],D[C+12>>2]=y,D[C+8>>2]=n,D[C+4>>2]=o,D[C>>2]=a,o=o+G|0,(0|N)==(0|(R=R+1|0)))break}}if(C=0|RQ[D[D[A>>2]+20>>2]](A,0),G=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(C<<2)>>2],B[G+84|0]=1,D[G+72>>2]=D[G+68>>2],(0|(C=a=D[I+12>>2]))<=(0|(Q=D[I+20>>2]))&(n=D[I+8>>2])>>>0<=(R=D[I+16>>2])>>>0|(0|C)<(0|Q))break Q;b=e[(c=D[I>>2])+R|0],C=Q,C=(y=R+1|0)?C:C+1|0,D[I+16>>2]=y,D[I+20>>2]=C;o:switch(0|b){case 0:if(!(n>>>0<=y>>>0&(0|C)>=(0|a)|(0|C)>(0|a)||(C=Q,C=(A=R+2|0)>>>0<2?C+1|0:C,D[I+16>>2]=A,D[I+20>>2]=C,C=Q,(Q=R+6|0)>>>0>n>>>0&(0|(C=Q>>>0<6?C+1|0:C))>=(0|a)|(0|C)>(0|a)))){A=e[0|(A=A+c|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,D[I+16>>2]=Q,D[I+20>>2]=C,KI(G,A),D[20+(r=g+672|0)>>2]=0,D[r+12>>2]=0,D[r+16>>2]=0,D[r>>2]=0,D[r+4>>2]=0,D[r+20>>2]=A,R=nI(g+16|0,g+704|0),a=0,d=o=d-32|0,D[o+24>>2]=0,D[o+16>>2]=0,D[o+20>>2]=0,n=A=D[I+12>>2],Q=C=D[I+20>>2];a:if(!((G=D[I+8>>2])>>>0<(N=(y=D[I+16>>2])+4|0)>>>0&(0|A)<=(0|(C=N>>>0<4?C+1|0:C))|(0|A)<(0|C))){A=e[0|(A=(c=D[I>>2])+y|0)]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24,D[I+16>>2]=N,D[I+20>>2]=C;r:{D:switch(A-2|0){case 1:if((0|C)>=(0|n)&N>>>0>=G>>>0|(0|C)>(0|n))break a;if(A=B[N+c|0],C=Q,C=(Q=y+5|0)>>>0<5?C+1|0:C,D[I+16>>2]=Q,D[I+20>>2]=C,D[r+8>>2]=A,1==(0|A)){if(p(r,I,o+16|0))break r;break a}SC(1943,23,D[3451]);break a;default:SC(1918,24,D[3451]);break a;case 0:}if(!p(r,I,o+16|0))break a}if(D[o+8>>2]=D[o+16>>2],D[o>>2]=D[o+20>>2],d=A=d-32|0,I=D[r>>2],w=t[r+4>>2],D[(a=A+24|0)>>2]=1065353216,(0|(I=-1<<I^-1))>0&&(t[a>>2]=w/F(0|I)),(0|(r=D[o+8>>2]))!=D[o>>2])for(C=D[R+28>>2];Q=D[r>>2],N=D[r+4>>2],t[A+16>>2]=(w=t[a>>2])*F(D[r+8>>2]-I|0),t[A+12>>2]=w*F(N-I|0),t[A+8>>2]=w*F(Q-I|0),e[(Q=D[(N=D[R+16>>2])>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),xA(D[D[Q>>2]>>2]+s(n=C,C=D[Q+40>>2])|0,(A+8|0)+(D[N+4>>2]<<2)|0,C),D[R+28>>2]=C=D[R+28>>2]+1|0,(0|(r=r+12|0))!=D[o>>2];);d=A+32|0,a=1}if((A=D[o+16>>2])&&(D[o+20>>2]=A,sA(A)),d=o+32|0,yC(R),r=1,a)break Q}r=0;break Q;case 1:break o;default:break Q}if(n>>>0<=y>>>0&(0|C)>=(0|a)|(0|C)>(0|a))break Q;if(y=e[y+c|0],C=Q,C=(G=R+2|0)>>>0<2?C+1|0:C,D[I+16>>2]=G,D[I+20>>2]=C,y>>>0>=7){D[g>>2]=y,HI(1795,g);break Q}if(C=Q,R=Q=R+6|0,Q>>>0>n>>>0&(0|(C=Q>>>0<6?C+1|0:C))>=(0|a)|(0|C)>(0|a))break Q;if(Q=e[0|(Q=G+c|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[I+16>>2]=R,D[I+20>>2]=C,N)for(R=0;C=0|RQ[D[D[A>>2]+20>>2]](A,R),KI(C=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(C<<2)>>2],Q),B[C+84|0]=1,D[C+72>>2]=D[C+68>>2],(0|N)!=(0|(R=R+1|0)););A=nI(g+672|0,g+704|0);o:{a:switch(0|y){case 1:if(I=T(C=zA(g+16|0,o),I,A),mI(C),!I)break B;break o;case 2:if(I=m(C=jA(g+16|0,o),I,A),jI(C),!I)break B;break o;case 3:if(I=x(C=jA(g+16|0,o),I,A),jI(C),!I)break B;break o;case 4:if(I=Z(C=z(g+16|0,o),I,A),XI(C),!I)break B;break o;case 5:if(I=X(C=z(g+16|0,o),I,A),XI(C),!I)break B;break o;case 6:if(I=j(C=z(g+16|0,o),I,A),XI(C),I)break o;break B;case 0:break a;default:break B}if(I=_(C=zA(g+16|0,o),I,A),mI(C),!I)break B}yC(A),r=1;break Q}iQ(),U()}iQ(),U()}yC(A)}if(!(A=D[g+704>>2]))break A;D[g+708>>2]=A,sA(A);break A}if(D[A+52>>2]==D[A+48>>2]){r=1;break I}for(R=0;;){if(!Ng(1,g+16|0,I))break g;if(r=1,D[(C=D[A+48>>2])+(R<<2)>>2]=(Q=D[g+16>>2])>>>1^0-(1&Q),!((R=R+1|0)>>>0<D[A+52>>2]-C>>2>>>0))break}break I}r=0}(A=D[g+672>>2])&&(D[g+676>>2]=A,sA(A))}return d=g+720|0,0|r},function(A){A|=0;var I,g=0,C=0,Q=0,E=0,i=0,o=0,a=0,N=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=F(0),l=0;d=I=d-32|0;A:if(D[A+60>>2]!=D[A- -64>>2]|D[A+48>>2]!=D[A+52>>2]){if(i=1,!((0|RQ[D[D[A>>2]+24>>2]](A))<=0)){I:{g:{for(;;){C:{Q=0|RQ[D[D[A>>2]+20>>2]](A,l);Q:{B:{E:switch(o=D[D[D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]+8>>2]+(Q<<2)>>2],D[o+28>>2]-1|0){case 8:break B;case 0:case 2:case 4:break E;default:break Q}if(Q=B[o+24|0],D[I+24>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,Q){if((0|Q)<0)break I;if(i=DC(C=Q<<2),D[I+16>>2]=i,D[I+24>>2]=Q=C+i|0,R=0,bI(i,0,C),D[I+20>>2]=Q,Q=B[o+24|0],D[I+8>>2]=0,D[I>>2]=0,D[I+4>>2]=0,Q){if((0|Q)<0)break g;R=DC(Q<<=2),D[I>>2]=R,bI(R,0,Q)}}else i=0,D[I>>2]=0,R=0;E:{i:switch(D[o+28>>2]-1|0){case 4:a=0,C=0,y=0,Q=0,d=c=d-16|0,N=B[o+24|0],D[c+8>>2]=0,D[c>>2]=0,D[c+4>>2]=0;o:{a:{if(N){if((0|N)<0)break a;C=DC(g=N<<2),D[c>>2]=C,D[c+8>>2]=g+C,bI(C,0,g),bI(a=DC(g),0,g)}if(!D[o+80>>2])break o;for(;;){if(S=xA(C,(g=D[(w=D[o>>2])>>2])+(b=D[o+48>>2]+mg(E=D[o+40>>2],D[o+44>>2],y,Q)|0)|0,E),!((0|(h=N<<24>>24))<=0)){if(J=D[A+48>>2],n=0,1!=(255&N))for(b=-2&h,N=0;D[(g=n<<2)+a>>2]=D[J+(n+Y<<2)>>2]+D[g+S>>2],D[(g=(G=1|n)<<2)+a>>2]=D[J+(G+Y<<2)>>2]+D[g+S>>2],n=n+2|0,(0|b)!=(0|(N=N+2|0)););1&h&&(D[(g=n<<2)+a>>2]=D[J+(n+Y<<2)>>2]+D[g+S>>2])}if(xA(D[w>>2]+s(E,y)|0,a,E),y=g=y+1|0,!(Q=g?Q:Q+1|0)&k[o+80>>2]<=g>>>0|Q)break o;N=e[o+24|0]}}iQ(),U()}a&&sA(a),C&&sA(C),d=c+16|0;break E;case 2:a=0,C=0,y=0,Q=0,d=c=d-16|0,N=B[o+24|0],D[c+8>>2]=0,D[c>>2]=0,D[c+4>>2]=0;o:{a:{if(N){if((0|N)<0)break a;C=DC(g=N<<1),D[c>>2]=C,D[c+8>>2]=g+C,bI(C,0,g),bI(a=DC(g),0,g)}if(!D[o+80>>2])break o;for(;;){if(S=xA(C,(g=D[(w=D[o>>2])>>2])+(b=D[o+48>>2]+mg(E=D[o+40>>2],D[o+44>>2],y,Q)|0)|0,E),!((0|(h=N<<24>>24))<=0)){if(J=D[A+48>>2],n=0,1!=(255&N))for(b=-2&h,N=0;r[(g=n<<1)+a>>1]=f[g+S>>1]+f[J+(n+Y<<2)>>1],r[(g=(G=1|n)<<1)+a>>1]=f[g+S>>1]+f[J+(G+Y<<2)>>1],n=n+2|0,(0|b)!=(0|(N=N+2|0)););1&h&&(r[(g=n<<1)+a>>1]=f[g+S>>1]+f[J+(n+Y<<2)>>1])}if(xA(D[w>>2]+s(E,y)|0,a,E),y=g=y+1|0,!(Q=g?Q:Q+1|0)&k[o+80>>2]<=g>>>0|Q)break o;N=e[o+24|0]}}iQ(),U()}a&&sA(a),C&&sA(C),d=c+16|0;break E;case 0:break i;default:break E}a=0,n=0,y=0,Q=0,d=w=d-16|0,C=B[o+24|0],D[w+8>>2]=0,D[w>>2]=0,D[w+4>>2]=0;i:{o:{if(C){if((0|C)<0)break o;n=DC(C),D[w>>2]=n,D[w+8>>2]=C+n,bI(n,0,C),bI(a=DC(C),0,C)}if(D[o+80>>2])for(;;){if(h=xA(n,(C=D[D[o>>2]>>2])+(G=D[o+48>>2]+mg(g=D[o+40>>2],D[o+44>>2],y,Q)|0)|0,g),!((0|(b=B[o+24|0]))<=0)){if(G=D[A+48>>2],N=0,1!=(0|b))for(C=-2&b,E=0;B[a+N|0]=e[N+h|0]+e[G+(N+Y<<2)|0],B[(g=1|N)+a|0]=e[g+h|0]+e[G+(g+Y<<2)|0],N=N+2|0,(0|C)!=(0|(E=E+2|0)););1&b&&(B[a+N|0]=e[N+h|0]+e[G+(N+Y<<2)|0])}if(xA(D[D[o>>2]>>2]+s(C=D[o+40>>2],y)|0,a,C),y=C=y+1|0,!(!(Q=C?Q:Q+1|0)&k[o+80>>2]>C>>>0))break}a&&sA(a),n&&sA(n),d=w+16|0;break i}iQ(),U()}}if(Y=B[o+24|0]+Y|0,Q=1,R&&sA(R),i&&sA(i),Q)break Q;i=0;break A}n=D[D[A+60>>2]+(K<<2)>>2],b=D[A+36>>2],C=D[40+(0|RQ[D[D[A>>2]+28>>2]](A))>>2],G=D[o+56>>2],g=DC(32),D[I+16>>2]=g,D[I+20>>2]=24,D[I+24>>2]=-2147483616,B[g+24|0]=0,E=e[1318]|e[1319]<<8|e[1320]<<16|e[1321]<<24,B[g+16|0]=Q=e[1314]|e[1315]<<8|e[1316]<<16|e[1317]<<24,B[g+17|0]=Q>>>8,B[g+18|0]=Q>>>16,B[g+19|0]=Q>>>24,B[g+20|0]=E,B[g+21|0]=E>>>8,B[g+22|0]=E>>>16,B[g+23|0]=E>>>24,E=e[1310]|e[1311]<<8|e[1312]<<16|e[1313]<<24,B[g+8|0]=Q=e[1306]|e[1307]<<8|e[1308]<<16|e[1309]<<24,B[g+9|0]=Q>>>8,B[g+10|0]=Q>>>16,B[g+11|0]=Q>>>24,B[g+12|0]=E,B[g+13|0]=E>>>8,B[g+14|0]=E>>>16,B[g+15|0]=E>>>24,E=e[1302]|e[1303]<<8|e[1304]<<16|e[1305]<<24,B[0|g]=Q=e[1298]|e[1299]<<8|e[1300]<<16|e[1301]<<24,B[g+1|0]=Q>>>8,B[g+2|0]=Q>>>16,B[g+3|0]=Q>>>24,B[g+4|0]=E,B[g+5|0]=E>>>8,B[g+6|0]=E>>>16,B[g+7|0]=E>>>24,R=E=C+16|0;B:if(i=D[E>>2]){for(;R=(Q=(0|G)>D[i+16>>2])?R:i,i=D[(Q<<2)+i>>2];);if(!((0|E)==(0|R)|(0|G)<D[R+16>>2])&&(i=D[R+24>>2]))for(Q=R+20|0;;){E:{i:{o:{if(h=(w=(J=(G=(E=e[i+27|0])<<24>>24<0)?D[i+20>>2]:E)>>>0<24)?J:24){E=i+16|0;a:{if(!(E=cg(g,G=G?D[E>>2]:E,h))){if(J>>>0<=24)break a;break E}if((0|E)<0)break E}if(!(E=cg(G,g,h)))break o;if((0|E)<0)break i;C=Q;break B}if(J>>>0>24)break E}if(!w){C=Q;break B}}i=i+4|0}if(!(i=D[i>>2]))break}}if(C=gg(C,I+16|0),B[I+27|0]<0&&sA(D[I+16>>2]),Q=K+1|0,C)LA(o,n);else{if(w=b+s(K,24)|0,C=D[w+4>>2],c=(y=B[o+24|0])<<2,a=DC((0|y)!=(1073741823&y)?-1:c),D[I+16>>2]=1065353216,M=t[w+20>>2],(0|(C=-1<<C^-1))>0&&(t[I+16>>2]=M/F(0|C)),(0|C)<=0)break C;if(D[n+80>>2])if((0|y)<=0)for(R=0,i=0;xA(D[D[o+64>>2]>>2]+i|0,a,c),i=i+c|0,(R=R+1|0)>>>0<k[n+80>>2];);else for(h=D[D[n>>2]>>2]+D[n+48>>2]|0,G=-2&y,E=1&y,b=0,S=0,i=0;;){if(J=D[w+8>>2],M=t[I+16>>2],R=0,K=0,1!=(0|y))for(;t[(C=R<<2)+a>>2]=F(M*F(D[(g=h+(i<<2)|0)>>2]))+t[C+J>>2],t[(C|=4)+a>>2]=F(M*F(D[g+4>>2]))+t[C+J>>2],R=R+2|0,i=i+2|0,(0|G)!=(0|(K=K+2|0)););if(E&&(t[(C=R<<2)+a>>2]=F(M*F(D[h+(i<<2)>>2]))+t[C+J>>2],i=i+1|0),xA(D[D[o+64>>2]>>2]+S|0,a,c),S=c+S|0,!((b=b+1|0)>>>0<k[n+80>>2]))break}sA(a)}K=Q}if(i=1,l=l+1|0,(0|RQ[D[D[A>>2]+24>>2]](A))>(0|l))continue;break A}break}sA(a),i=0;break A}iQ(),U()}iQ(),U()}}else i=1;return d=I+32|0,0|i},function(A){var I;return D[(A|=0)>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),0|A},function(A){var I;D[(A|=0)>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),sA(A)},tC,function(A,I){return I|=0,D[12+(A|=0)>>2]=-1,D[A+8>>2]=I,1},function(A,I,g){I|=0,g|=0;var C,Q=0;return B[(C=D[8+(A|=0)>>2])+24|0]<=0||KI(C,D[I+4>>2]-D[I>>2]>>2)&&(Q=0|RQ[D[D[A>>2]+32>>2]](A,I,g)),0|Q},function(A,I,g){return 1},jC,function(A,I){A|=0;var g=0,C=0,Q=0,B=0,E=0,i=0;B=1;A:if(!((0|RQ[D[D[(I|=0)>>2]+20>>2]](I))<=0))for(;;){if(B=0,-1==(0|(g=iC(D[D[A+4>>2]+4>>2],0|RQ[D[D[I>>2]+24>>2]](I,E)))))break A;I:{if(e[(Q=D[A+4>>2])+36|0]<=1){if(0|RQ[D[D[I>>2]+28>>2]](I,D[D[D[Q+4>>2]+8>>2]+(g<<2)>>2]))break I;break A}if(C=0,(0|g)<0||D[(i=D[Q+4>>2])+12>>2]-D[i+8>>2]>>2<=(0|g)||(C=0|RQ[D[D[(C=D[D[Q+8>>2]+(D[D[Q+20>>2]+(g<<2)>>2]<<2)>>2])>>2]+32>>2]](C,g)),!C)break A;if(!(0|RQ[D[D[I>>2]+28>>2]](I,C)))break A}if(B=1,E=E+1|0,!((0|RQ[D[D[I>>2]+20>>2]](I))>(0|E)))break}return 0|B},function(A,I,g){g|=0;var C,Q,B=0,E=0,i=0,o=0,a=0,r=0,e=0,f=0;if(B=D[(I|=0)>>2],I=D[I+4>>2],Q=DC((0|(C=D[D[8+(A|=0)>>2]+40>>2]))>=0?C:-1),i=1,!((0|(o=I-B|0))<=0||(I=0,i=0,B=0+D[g+20>>2]|0,B=(E=C+(a=D[g+16>>2])|0)>>>0<C>>>0?B+1|0:B,(r=E)>>>0>k[g+8>>2]&(0|(E=D[g+12>>2]))<=(0|B)|(0|B)>(0|E)))){for(i=(0|(e=o>>2))>1?e:1;E=xA(Q,a+D[g>>2]|0,C),D[g+16>>2]=r,D[g+20>>2]=B,xA(D[D[D[A+8>>2]+64>>2]>>2]+I|0,E,C),(0|i)!=(0|(f=f+1|0))&&(I=I+C|0,B=0+D[g+20>>2]|0,B=(E=C+(a=D[g+16>>2])|0)>>>0<C>>>0?B+1|0:B,r=E,o=E,(0|(E=D[g+12>>2]))>=(0|B)&k[g+8>>2]>=o>>>0|(0|B)<(0|E)););i=(0|f)>=(0|e)}return sA(Q),0|i},function(A){var I,g=0,C=0;if(D[(A|=0)>>2]=2356,g=D[A+60>>2],D[A+60>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(g=D[A+48>>2])&&(D[A+52>>2]=g,sA(g)),I=D[A+36>>2]){if((0|(C=D[A+40>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+36>>2]}D[A+40>>2]=I,sA(g)}return D[A>>2]=2012,(g=D[A+16>>2])&&(D[A+20>>2]=g,sA(g)),(g=D[A+4>>2])&&(D[A+8>>2]=g,sA(g)),0|A},function(A){var I,g=0,C=0;if(D[(A|=0)>>2]=2356,g=D[A+60>>2],D[A+60>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(g=D[A+48>>2])&&(D[A+52>>2]=g,sA(g)),I=D[A+36>>2]){if((0|(C=D[A+40>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+36>>2]}D[A+40>>2]=I,sA(g)}D[A>>2]=2012,(g=D[A+16>>2])&&(D[A+20>>2]=g,sA(g)),(g=D[A+4>>2])&&(D[A+8>>2]=g,sA(g)),sA(A)},function(A,I){var g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0;if(UA(A|=0,I|=0)){if(o=A+36|0,(E=0|RQ[D[D[A>>2]+24>>2]](A))>>>0>(g=(C=D[A+40>>2])-(Q=D[A+36>>2])>>2)>>>0)GI(o,E-g|0);else if(!(g>>>0<=E>>>0)){if((0|(Q=Q+(E<<2)|0))!=(0|C))for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|C)!=(0|Q););D[A+40>>2]=Q}A:if((0|E)<=0)Q=0;else if(Q=1,!((0|(g=D[I+20>>2]))>=(0|(C=D[I+12>>2]))&(B=D[I+16>>2])>>>0>=k[I+8>>2]|(0|g)>(0|C)))for(C=0;;){if(i=e[B+D[I>>2]|0],g=(B=B+1|0)?g:g+1|0,D[I+16>>2]=B,D[I+20>>2]=g,B=0|RQ[D[D[A>>2]+48>>2]](A,i),g=D[(a=(i=C<<2)+D[A+36>>2]|0)>>2],D[a>>2]=B,g&&RQ[D[D[g>>2]+4>>2]](g),!(g=D[D[o>>2]+i>>2]))break A;if(r=g,f=0|RQ[D[D[A>>2]+28>>2]](A),t=0|RQ[D[D[A>>2]+20>>2]](A,C),!(0|RQ[D[D[g>>2]+8>>2]](0|r,0|f,0|t)))break A;if(Q=(0|E)>(0|(C=C+1|0)),(0|C)==(0|E))break A;if(!((B=D[I+16>>2])>>>0<k[I+8>>2]&(0|(g=D[I+20>>2]))<=(0|(i=D[I+12>>2]))|(0|g)<(0|i)))break}A=!Q}else A=0;return 0|A},function(A,I){I|=0;var g=0,C=0,Q=0,B=0,E=0;if((g=D[60+(A|=0)>>2])&&(D[g+4>>2]=A+48,0|RQ[D[D[g>>2]+12>>2]](g))){A:if(!((0|(g=0|RQ[D[D[A>>2]+24>>2]](A)))<=0)){for(;;){if(B=D[4+(0|RQ[D[D[A>>2]+28>>2]](A))>>2],E=0|RQ[D[D[A>>2]+20>>2]](A,C),0|RQ[D[D[(Q=D[A+60>>2])>>2]+8>>2]](Q,D[D[B+8>>2]+(E<<2)>>2])){if((0|g)!=(0|(C=C+1|0)))continue;break A}break}return 0}C=0,0|RQ[D[D[A>>2]+36>>2]](A,I)&&0|RQ[D[D[A>>2]+40>>2]](A,I)&&(C=0|RQ[D[D[A>>2]+44>>2]](A))}return 0|C},function(A,I){var g,C=0;return C=0,D[20+(A|=0)>>2]-(g=D[A+16>>2])>>2<=(0|(I|=0))||(C=0,(0|(I=D[(I<<2)+g>>2]))<0||(C=VI(D[D[A+36>>2]+(I<<2)>>2]))),0|C},function(A,I){I|=0;var g,C=0,Q=0,B=0,E=0;if(C=1,!((0|(g=0|RQ[D[D[(A|=0)>>2]+24>>2]](A)))<=0)&&(C=0,0|RQ[D[D[(Q=D[D[A+36>>2]>>2])>>2]+16>>2]](Q,B=A+48|0,I))){for(Q=1;(0|g)!=(0|(C=Q))&&(Q=C+1|0,0|RQ[D[D[(E=D[D[A+36>>2]+(C<<2)>>2])>>2]+16>>2]](E,B,I)););C=(0|C)>=(0|g)}return 0|C},function(A,I){I|=0;var g,C=0,Q=0,B=0,E=0;if(C=1,!((0|(g=0|RQ[D[D[(A|=0)>>2]+24>>2]](A)))<=0)&&(C=0,0|RQ[D[D[(Q=D[D[A+36>>2]>>2])>>2]+20>>2]](Q,B=A+48|0,I))){for(Q=1;(0|g)!=(0|(C=Q))&&(Q=C+1|0,0|RQ[D[D[(E=D[D[A+36>>2]+(C<<2)>>2])>>2]+20>>2]](E,B,I)););C=(0|C)>=(0|g)}return 0|C},function(A){var I,g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,s=0,F=0,n=0;d=I=d-16|0,t=1;A:if((0|(g=0|RQ[D[D[(A|=0)>>2]+24>>2]](A)))<=0)t=0;else for(n=A+48|0;;){I:{if(D[40+(0|RQ[D[D[A>>2]+28>>2]](A))>>2]&&(E=D[(r=D[(N=f<<2)+D[A+36>>2]>>2])+8>>2],s=VI(r))){r=D[40+(0|RQ[D[D[A>>2]+28>>2]](A))>>2],a=D[E+56>>2],Q=DC(32),D[I>>2]=Q,D[I+4>>2]=24,D[I+8>>2]=-2147483616,B[Q+24|0]=0,C=e[1318]|e[1319]<<8|e[1320]<<16|e[1321]<<24,B[Q+16|0]=E=e[1314]|e[1315]<<8|e[1316]<<16|e[1317]<<24,B[Q+17|0]=E>>>8,B[Q+18|0]=E>>>16,B[Q+19|0]=E>>>24,B[Q+20|0]=C,B[Q+21|0]=C>>>8,B[Q+22|0]=C>>>16,B[Q+23|0]=C>>>24,C=e[1310]|e[1311]<<8|e[1312]<<16|e[1313]<<24,B[Q+8|0]=E=e[1306]|e[1307]<<8|e[1308]<<16|e[1309]<<24,B[Q+9|0]=E>>>8,B[Q+10|0]=E>>>16,B[Q+11|0]=E>>>24,B[Q+12|0]=C,B[Q+13|0]=C>>>8,B[Q+14|0]=C>>>16,B[Q+15|0]=C>>>24,C=e[1302]|e[1303]<<8|e[1304]<<16|e[1305]<<24,B[0|Q]=E=e[1298]|e[1299]<<8|e[1300]<<16|e[1301]<<24,B[Q+1|0]=E>>>8,B[Q+2|0]=E>>>16,B[Q+3|0]=E>>>24,B[Q+4|0]=C,B[Q+5|0]=C>>>8,B[Q+6|0]=C>>>16,B[Q+7|0]=C>>>24,o=C=r+16|0;g:if(i=D[C>>2]){for(;o=(E=(0|a)>D[i+16>>2])?o:i,i=D[(E<<2)+i>>2];);if(!((0|C)==(0|o)|(0|a)<D[o+16>>2])&&(i=D[o+24>>2]))for(E=o+20|0;;){C:{Q:{B:{if(o=(F=(k=(a=(C=e[i+27|0])<<24>>24<0)?D[i+20>>2]:C)>>>0<24)?k:24){C=i+16|0;E:{if(!(C=cg(Q,a=a?D[C>>2]:C,o))){if(k>>>0<=24)break E;break C}if((0|C)<0)break C}if(!(C=cg(a,Q,o)))break B;if((0|C)<0)break Q;r=E;break g}if(k>>>0>24)break C}if(!F){r=E;break g}}i=i+4|0}if(!(i=D[i>>2]))break}}if(E=gg(r,I),B[I+11|0]<0&&sA(D[I>>2]),E){LA(D[D[D[A+36>>2]+N>>2]+8>>2],s);break I}}if(!(0|RQ[D[D[(E=D[D[A+36>>2]+(f<<2)>>2])>>2]+24>>2]](E,n)))break A}if(t=(0|g)>(0|(f=f+1|0)),(0|f)==(0|g))break}return d=I+16|0,1&(-1^t)},function(A,I){A|=0,A=0;A:switch(0|(I|=0)){case 0:return A=DC(20),D[A+12>>2]=-1,D[A+16>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=2260,0|A;case 1:return A=DC(24),D[A+12>>2]=-1,D[A+16>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=2260,D[A+20>>2]=0,D[A>>2]=2476,0|A;case 2:return A=DC(48),D[A+12>>2]=-1,D[A+16>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=2260,D[A+20>>2]=0,D[A>>2]=2476,D[A+32>>2]=0,D[A+36>>2]=0,D[A+28>>2]=-1,D[A+24>>2]=1140,D[A>>2]=11076,D[A+40>>2]=0,D[A+44>>2]=0,0|A;case 3:A=DC(32),D[A+12>>2]=-1,D[A+16>>2]=0,D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=2260,D[A+20>>2]=0,D[A>>2]=2476,D[A+28>>2]=-1,D[A+24>>2]=1032,D[A>>2]=7056}return 0|A},CC,EC,tC,function(A,I){I|=0;var g,C=0;return(g=D[4+(A|=0)>>2])&&(C=1,e[g+36|0]<2)||(C=0|RQ[D[D[A>>2]+48>>2]](A,D[I+4>>2]-D[I>>2]>>2)),0|C},function(A,I,g){A|=0,I|=0;var C,Q,E=0,i=0,o=0,a=0,r=0,f=0,k=0;A:if(!((0|(E=C=D[12+(g|=0)>>2]))<=(0|(i=D[g+20>>2]))&(Q=D[g+8>>2])>>>0<=(o=D[g+16>>2])>>>0|(0|E)<(0|i))){if(f=B[(r=D[g>>2])+o|0],E=i,E=(a=o+1|0)?E:E+1|0,D[g+16>>2]=a,D[g+20>>2]=E,-2!=(0|f)){if((0|E)>=(0|C)&a>>>0>=Q>>>0|(0|E)>(0|C))break A;if(E=B[a+r|0],i=(o=o+2|0)>>>0<2?i+1|0:i,D[g+16>>2]=o,D[g+20>>2]=i,(E-4&255)>>>0<251)break A;i=0|RQ[D[D[A>>2]+40>>2]](A,f,E),E=D[A+20>>2],D[A+20>>2]=i,E&&RQ[D[D[E>>2]+4>>2]](E)}(!(E=D[A+20>>2])||0|RQ[D[D[A>>2]+28>>2]](A,E))&&0|RQ[D[D[A>>2]+36>>2]](A,I,g)&&(!(g=D[A+4>>2])|e[g+36|0]>1||0|RQ[D[D[A>>2]+48>>2]](A,D[I+4>>2]-D[I>>2]>>2))&&(k=1)}return 0|k},bA,function(A,I,g){A|=0,I|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=0,e=0,k=0,t=0,N=0,s=0;if(d=C=d-48|0,1==(0|(g|=0))){o=D[A+4>>2],g=D[A+12>>2],D[C+40>>2]=0,D[C+32>>2]=0,D[C+36>>2]=0,D[C+24>>2]=0,D[C+28>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,E=C+8|0;A:if(-2!=(0|I)){if(t=D[D[D[o+4>>2]+8>>2]+(g<<2)>>2],1==(0|RQ[D[D[o>>2]+8>>2]](o))){if(k=65535&((A=f[o+36>>1])<<8|A>>>8),A=0,d=e=d-32|0,a=D[D[D[o+4>>2]+8>>2]+(g<<2)>>2],!(1!=(0|RQ[D[D[o>>2]+8>>2]](o))|I-1>>>0>5||!(Q=0|RQ[D[D[o>>2]+36>>2]](o))|!(r=0|RQ[D[D[o>>2]+44>>2]](o,g))))if(g=0|RQ[D[D[o>>2]+40>>2]](o,g)){A=D[o+44>>2],D[e+12>>2]=g,D[e+8>>2]=A,D[e+20>>2]=r,D[e+16>>2]=r+12,i=e+8|0,A=0;I:{g:{C:switch(I-1|0){case 0:if(A=DC(60),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A>>2]=2592;break I;case 1:if(A=DC(60),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A>>2]=3356;break I;case 3:if(A=DC(112),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=3592,D[A+68>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+88>>2]=0,D[A+92>>2]=0,D[A+96>>2]=0,D[A+100>>2]=0,D[A+104>>2]=0,D[A+108>>2]=0;break I;case 2:if(A=DC(92),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=3840,D[A+68>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+88>>2]=k;break I;case 4:if(A=DC(104),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,g=D[i+8>>2],I=D[i+12>>2],D[A+84>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=4068,D[A+52>>2]=g,D[A+56>>2]=I,I=D[i+4>>2],D[A+88>>2]=D[i>>2],D[A+92>>2]=I,I=D[i+12>>2],D[A+96>>2]=D[i+8>>2],D[A+100>>2]=I;break I;case 5:break C;default:break I}A=DC(128),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I;C:{Q:{if(g=D[E+28>>2]-D[E+24>>2]|0){if((0|g)<0)break Q;I=DC(g),D[A+32>>2]=I,D[A+36>>2]=I,D[A+40>>2]=I+(g>>2<<2),(0|(Q=D[E+28>>2]-(g=D[E+24>>2])|0))>0&&(I=xA(I,g,Q)+Q|0),D[A+36>>2]=I}D[A>>2]=3244,I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[(I=A- -64|0)>>2]=0,D[I+4>>2]=0,D[A+60>>2]=4932,D[A>>2]=4304,I=D[i+4>>2],D[A+72>>2]=D[i>>2],D[A+76>>2]=I,I=D[i+12>>2],D[A+80>>2]=D[i+8>>2],D[A+84>>2]=I,D[A+104>>2]=1065353216,D[A+108>>2]=-1,D[A+96>>2]=-1,D[A+100>>2]=-1,D[A+88>>2]=1,D[A+92>>2]=-1,D[A+60>>2]=4540,D[A+112>>2]=0,D[A+116>>2]=0,B[A+117|0]=0,B[A+118|0]=0,B[A+119|0]=0,B[A+120|0]=0,B[A+121|0]=0,B[A+122|0]=0,B[A+123|0]=0,B[A+124|0]=0;break C}iQ(),U()}break I}iQ(),U()}}else{A=D[o+44>>2],D[e+12>>2]=Q,D[e+8>>2]=A,D[e+20>>2]=r,D[e+16>>2]=r+12,i=e+8|0,A=0;I:{g:{C:switch(I-1|0){case 0:if(A=DC(60),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A>>2]=4960;break I;case 1:if(A=DC(60),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A>>2]=5384;break I;case 3:if(A=DC(112),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=5608,D[A+68>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+88>>2]=0,D[A+92>>2]=0,D[A+96>>2]=0,D[A+100>>2]=0,D[A+104>>2]=0,D[A+108>>2]=0;break I;case 2:if(A=DC(92),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=5844,D[A+68>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+84>>2]=0,D[A+88>>2]=k;break I;case 4:if(A=DC(104),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I,Q=D[E+28>>2]-(I=D[E+24>>2])|0){if((0|Q)<0)break g;g=DC(Q),D[A+32>>2]=g,D[A+40>>2]=g+(Q>>2<<2),N=A,s=xA(g,I,Q)+Q|0,D[N+36>>2]=s}I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,g=D[i+8>>2],I=D[i+12>>2],D[A+84>>2]=0,D[A+76>>2]=0,D[A+80>>2]=0,D[A+60>>2]=0,D[A+64>>2]=0,D[A>>2]=6060,D[A+52>>2]=g,D[A+56>>2]=I,I=D[i+4>>2],D[A+88>>2]=D[i>>2],D[A+92>>2]=I,I=D[i+12>>2],D[A+96>>2]=D[i+8>>2],D[A+100>>2]=I;break I;case 5:break C;default:break I}A=DC(128),D[A+4>>2]=a,D[A>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],Q=D[E+20>>2],g=D[E>>2],I=D[E+4>>2],D[A+40>>2]=0,D[A+32>>2]=0,D[A+36>>2]=0,D[A+24>>2]=r,D[A+28>>2]=Q,D[A+16>>2]=o,D[A+20>>2]=a,D[A+8>>2]=g,D[A+12>>2]=I;C:{Q:{if(g=D[E+28>>2]-D[E+24>>2]|0){if((0|g)<0)break Q;I=DC(g),D[A+32>>2]=I,D[A+36>>2]=I,D[A+40>>2]=I+(g>>2<<2),(0|(Q=D[E+28>>2]-(g=D[E+24>>2])|0))>0&&(I=xA(I,g,Q)+Q|0),D[A+36>>2]=I}D[A>>2]=5328,I=D[i+4>>2],D[A+44>>2]=D[i>>2],D[A+48>>2]=I,I=D[i+12>>2],D[A+52>>2]=D[i+8>>2],D[A+56>>2]=I,D[(I=A- -64|0)>>2]=0,D[I+4>>2]=0,D[A+60>>2]=6868,D[A>>2]=6284,I=D[i+4>>2],D[A+72>>2]=D[i>>2],D[A+76>>2]=I,I=D[i+12>>2],D[A+80>>2]=D[i+8>>2],D[A+84>>2]=I,D[A+104>>2]=1065353216,D[A+108>>2]=-1,D[A+96>>2]=-1,D[A+100>>2]=-1,D[A+88>>2]=1,D[A+92>>2]=-1,D[A+60>>2]=6504,D[A+112>>2]=0,D[A+116>>2]=0,B[A+117|0]=0,B[A+118|0]=0,B[A+119|0]=0,B[A+120|0]=0,B[A+121|0]=0,B[A+122|0]=0,B[A+123|0]=0,B[A+124|0]=0;break C}iQ(),U()}break I}iQ(),U()}}if(d=e+32|0,Q=A,A)break A}Q=DC(44),D[Q+4>>2]=t,D[Q>>2]=3300,o=D[E+8>>2],a=D[E+12>>2],r=D[E+16>>2],g=D[E+20>>2],I=D[E>>2],A=D[E+4>>2],D[Q+40>>2]=0,D[Q+32>>2]=0,D[Q+36>>2]=0,D[Q+24>>2]=r,D[Q+28>>2]=g,D[Q+16>>2]=o,D[Q+20>>2]=a,D[Q+8>>2]=I,D[Q+12>>2]=A;I:{if(g=D[E+28>>2]-(A=D[E+24>>2])|0){if((0|g)<0)break I;I=DC(g),D[Q+32>>2]=I,D[Q+40>>2]=I+(g>>2<<2),N=Q,s=xA(I,A,g)+g|0,D[N+36>>2]=s}D[Q>>2]=6896;break A}iQ(),U()}(A=D[C+32>>2])&&(D[C+36>>2]=A,sA(A))}return d=C+48|0,0|Q},function(A){return B[D[8+(A|=0)>>2]+24|0]},function(A,I){I|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,e=0,f=0,k=0,t=0,N=0,s=0;g=A|=0;A:{I:{g:{C:{Q:{B:{E:{i:switch(D[(f=D[A+8>>2])+28>>2]-1|0){case 4:break g;case 5:break C;case 2:break Q;case 3:break B;case 0:break E;case 1:break i;default:break A}if(Q=DC((0|(C=B[f+24|0]))>=0?C:-1),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,!I)break I;if((0|C)>0){for(f=-4&C,t=3&C,E=C-1>>>0<3;;){if(A=0,o=0,!E)for(;B[A+Q|0]=D[(e=a+(i<<2)|0)>>2],B[(1|A)+Q|0]=D[e+4>>2],B[(2|A)+Q|0]=D[e+8>>2],B[(3|A)+Q|0]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;B[A+Q|0]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+N|0,Q,C),N=C+N|0,(0|(k=k+1|0))==(0|I))break}break I}if(xA(D[D[f+64>>2]>>2],Q,C),1==(0|I))break I;if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););if(!a)break I;xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C);break I}if(Q=DC((0|(C=B[f+24|0]))>=0?C:-1),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,!I)break I;if((0|C)>0){for(f=-4&C,t=3&C,E=C-1>>>0<3;;){if(A=0,o=0,!E)for(;B[A+Q|0]=D[(e=a+(i<<2)|0)>>2],B[(1|A)+Q|0]=D[e+4>>2],B[(2|A)+Q|0]=D[e+8>>2],B[(3|A)+Q|0]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;B[A+Q|0]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+N|0,Q,C),N=C+N|0,(0|(k=k+1|0))==(0|I))break}break I}if(xA(D[D[f+64>>2]>>2],Q,C),1==(0|I))break I;if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););if(!a)break I;xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C);break I}if(Q=DC((A=(E=B[f+24|0])+E|0)>>>0<E>>>0?-1:A),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,!I)break I;if(C=E<<1,(0|E)>0){for(f=-4&E,t=3&E,E=E-1>>>0<3;;){if(A=0,o=0,!E)for(;r[(k=A<<1)+Q>>1]=D[(e=a+(i<<2)|0)>>2],r[(2|k)+Q>>1]=D[e+4>>2],r[(4|k)+Q>>1]=D[e+8>>2],r[(6|k)+Q>>1]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;r[(A<<1)+Q>>1]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+s|0,Q,C),s=C+s|0,(0|(N=N+1|0))==(0|I))break}break I}if(xA(D[D[f+64>>2]>>2],Q,C),1==(0|I))break I;if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););if(!a)break I;xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C);break I}if(Q=DC((A=(E=B[f+24|0])+E|0)>>>0<E>>>0?-1:A),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,!I)break I;if(C=E<<1,(0|E)>0){for(f=-4&E,t=3&E,E=E-1>>>0<3;;){if(A=0,o=0,!E)for(;r[(k=A<<1)+Q>>1]=D[(e=a+(i<<2)|0)>>2],r[(2|k)+Q>>1]=D[e+4>>2],r[(4|k)+Q>>1]=D[e+8>>2],r[(6|k)+Q>>1]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;r[(A<<1)+Q>>1]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+s|0,Q,C),s=C+s|0,(0|(N=N+1|0))==(0|I))break}break I}if(xA(D[D[f+64>>2]>>2],Q,C),1==(0|I))break I;if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););if(!a)break I;xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C);break I}if(C=(E=B[f+24|0])<<2,Q=DC((0|E)!=(1073741823&E)?-1:C),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,!I)break I;if((0|E)>0){for(f=-4&E,t=3&E,E=E-1>>>0<3;;){if(A=0,o=0,!E)for(;D[(k=A<<2)+Q>>2]=D[(e=a+(i<<2)|0)>>2],D[(4|k)+Q>>2]=D[e+4>>2],D[(8|k)+Q>>2]=D[e+8>>2],D[(12|k)+Q>>2]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;D[(A<<2)+Q>>2]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+s|0,Q,C),s=C+s|0,(0|(N=N+1|0))==(0|I))break}break I}if(xA(D[D[f+64>>2]>>2],Q,C),1==(0|I))break I;if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););if(!a)break I;xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C);break I}if(C=(E=B[f+24|0])<<2,Q=DC((0|E)!=(1073741823&E)?-1:C),a=D[(A=D[g+16>>2])+80>>2]?D[D[A>>2]>>2]+D[A+48>>2]|0:0,I)if((0|E)>0)for(f=-4&E,t=3&E,E=E-1>>>0<3;;){if(A=0,o=0,!E)for(;D[(k=A<<2)+Q>>2]=D[(e=a+(i<<2)|0)>>2],D[(4|k)+Q>>2]=D[e+4>>2],D[(8|k)+Q>>2]=D[e+8>>2],D[(12|k)+Q>>2]=D[e+12>>2],A=A+4|0,i=i+4|0,(0|f)!=(0|(o=o+4|0)););if(o=0,t)for(;D[(A<<2)+Q>>2]=D[a+(i<<2)>>2],A=A+1|0,i=i+1|0,(0|t)!=(0|(o=o+1|0)););if(xA(D[D[D[g+8>>2]+64>>2]>>2]+s|0,Q,C),s=C+s|0,(0|(N=N+1|0))==(0|I))break}else if(xA(D[D[f+64>>2]>>2],Q,C),1!=(0|I)){if(a=1&(E=I-1|0),A=0,2!=(0|I))for(I=-2&E;xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),xA((A=A+C|0)+D[D[D[g+8>>2]+64>>2]>>2]|0,Q,C),(0|I)!=(0|(i=i+2|0)););a&&xA(D[D[D[g+8>>2]+64>>2]>>2]+(A+C|0)|0,Q,C)}}sA(Q),Q=1}return 0|Q},function(A){var I;return D[(A|=0)>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},wC,EQ,ZC,FC,IQ,mC,OC,IQ,EQ,function(A,I){A|=0;var g,C,Q,B=0,E=0,i=0,o=0,a=0,r=0;return C=E=D[12+(I|=0)>>2],i=B=D[I+20>>2],(Q=D[I+8>>2])>>>0<(g=(o=D[I+16>>2])+4|0)>>>0&(0|(B=g>>>0<4?B+1|0:B))>=(0|E)|(0|B)>(0|E)||(E=e[0|(E=(a=D[I>>2])+o|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=g,D[I+20>>2]=B,B=i,o=i=o+8|0,i=B=i>>>0<8?B+1|0:B,o>>>0>Q>>>0&(0|B)>=(0|C)|(0|B)>(0|C)||(B=e[0|(B=g+a|0)]|e[B+1|0]<<8|e[B+2|0]<<16|e[B+3|0]<<24,D[I+16>>2]=o,D[I+20>>2]=i,(0|B)<(0|E)||(D[A+16>>2]=B,D[A+12>>2]=E,!(I=(B>>31)-((E>>31)+(B>>>0<E>>>0)|0)|0)&(B=B-E|0)>>>0>2147483646|I||(r=1,D[A+20>>2]=I=B+1|0,D[A+24>>2]=B=I>>>1|0,D[A+28>>2]=0-B,1&I||(D[A+24>>2]=B-1))))),0|r},function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;if(D[8+(A|=0)>>2]=Q|=0,(B=D[A+36>>2]-(k=D[(C=A+32|0)>>2])>>2)>>>0<Q>>>0?($I(C,Q-B|0),k=D[C>>2],C=D[A+8>>2]):(Q>>>0<B>>>0&&(D[A+36>>2]=(Q<<2)+k),C=Q),o=D[A+52>>2],E=D[A+48>>2],B=0,t=bI(DC(t=(1073741823&Q)!=(0|Q)?-1:Q<<2),0,t),!((0|C)<=0)){for(;(0|(a=D[(C=B<<2)+t>>2]))>(0|(r=D[A+16>>2]))?D[C+k>>2]=r:D[(C=C+k|0)>>2]=(0|(r=D[A+12>>2]))>(0|a)?r:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(!((0|C)<=0))for(B=0;;){D[(C=(a=B<<2)+g|0)>>2]=a=D[I+a>>2]+D[a+k>>2]|0;A:{if((0|a)>D[A+16>>2])a=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break A;a=a+D[A+20>>2]|0}D[C>>2]=a}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}if((0|(B=D[(B=D[A+56>>2])+4>>2]-(i=D[B>>2])|0))>=5)for(n=(0|(B>>=2))>2?B:2,R=B>>>0>1?B:1,y=-2&Q,G=1&Q,k=1;;){A:{I:{if((0|k)!=(0|R)){if(F=s(Q,k),-1==(0|(B=D[(k<<2)+i>>2]))|D[D[E>>2]+(B>>>3&536870908)>>2]>>>B&1)break I;if(-1==(0|(B=D[D[D[E+64>>2]+12>>2]+(B<<2)>>2])))break I;if((0|(f=D[(r=D[o>>2])+(D[(a=D[E+28>>2])+(B<<2)>>2]<<2)>>2]))>=(0|k))break I;if((0|(e=D[r+(D[a+((((e=B+1|0)>>>0)%3|0?e:B-2|0)<<2)>>2]<<2)>>2]))>=(0|k))break I;if((0|(B=D[r+(D[a+(B+((B>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2]))>=(0|k))break I;if(!((0|Q)<=0)){if(a=s(Q,B),r=s(Q,e),f=s(Q,f),B=0,N=0,1!=(0|Q))for(;D[t+(B<<2)>>2]=(D[(B+a<<2)+g>>2]+D[(B+r<<2)+g>>2]|0)-D[(B+f<<2)+g>>2],D[t+((e=1|B)<<2)>>2]=(D[(a+e<<2)+g>>2]+D[(r+e<<2)+g>>2]|0)-D[(f+e<<2)+g>>2],B=B+2|0,(0|y)!=(0|(N=N+2|0)););G&&(D[t+(B<<2)>>2]=(D[(B+a<<2)+g>>2]+D[(B+r<<2)+g>>2]|0)-D[(B+f<<2)+g>>2])}if((0|C)<=0)break A;for(r=D[A+32>>2],B=0;(0|(a=D[(C=B<<2)+t>>2]))>(0|(f=D[A+16>>2]))?D[C+r>>2]=f:D[(C=C+r|0)>>2]=(0|(f=D[A+12>>2]))>(0|a)?f:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(B=0,(0|C)<=0)break A;for(f=(C=F<<2)+g|0,e=I+C|0;;){D[(C=(a=B<<2)+f|0)>>2]=a=D[a+e>>2]+D[a+r>>2]|0;g:{if((0|a)>D[A+16>>2])a=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break g;a=a+D[A+20>>2]|0}D[C>>2]=a}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}break A}sQ(),U()}if(!((0|C)<=0)){for(f=(s(k-1|0,Q)<<2)+g|0,r=D[A+32>>2],B=0;(0|(a=D[(C=B<<2)+f>>2]))>(0|(e=D[A+16>>2]))?D[C+r>>2]=e:D[(C=C+r|0)>>2]=(0|(e=D[A+12>>2]))>(0|a)?e:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(B=0,!((0|C)<=0))for(f=(C=F<<2)+g|0,e=I+C|0;;){D[(C=(a=B<<2)+f|0)>>2]=a=D[a+e>>2]+D[a+r>>2]|0;I:{if((0|a)>D[A+16>>2])a=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break I;a=a+D[A+20>>2]|0}D[C>>2]=a}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}}if((0|n)==(0|(k=k+1|0)))break}return sA(t),1},rQ,rQ,wC,CQ,FC,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0;if(D[8+(A|=0)>>2]=Q|=0,(B=D[A+36>>2]-(e=D[(C=A+32|0)>>2])>>2)>>>0<Q>>>0?($I(C,Q-B|0),e=D[C>>2],C=D[A+8>>2]):(Q>>>0<B>>>0&&(D[A+36>>2]=(Q<<2)+e),C=Q),E=bI(DC(B=(1073741823&Q)!=(0|Q)?-1:Q<<2),0,B),i=bI(DC(B),0,B),!((0|C)<=0)){for(;(0|(B=D[(C=a<<2)+E>>2]))>(0|(r=D[A+16>>2]))?D[C+e>>2]=r:D[(C=C+e|0)>>2]=(0|(r=D[A+12>>2]))>(0|B)?r:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(!((0|C)<=0))for(B=0;;){D[(C=(r=B<<2)+g|0)>>2]=r=D[I+r>>2]+D[r+e>>2]|0;A:{if((0|r)>D[A+16>>2])a=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break A;a=r+D[A+20>>2]|0}D[C>>2]=a}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}if((0|(B=D[(B=D[A+56>>2])+4>>2]-(o=D[B>>2])|0))>=5)for(h=D[A+52>>2],R=D[A+48>>2],J=(0|(B>>=2))>2?B:2,S=B>>>0>1?B:1,c=-2&Q,w=1&Q,Y=-4&Q,b=3&Q,G=Q-1|0,K=Q<<2,F=1;;){A:{I:{g:{C:if((0|F)==(0|S))sQ(),U();else{if(r=D[(F<<2)+o>>2],(y=(0|Q)<=0)||bI(E,0,K),-1==(0|r)){f=s(Q,F);break I}for(M=D[R>>2],N=0,B=r;;){if(!(D[(B>>>3&536870908)+M>>2]>>>B&1||-1==(0|(a=D[D[D[R+64>>2]+12>>2]+(B<<2)>>2]))||(0|(t=D[(f=D[h>>2])+(D[(e=D[R+28>>2])+(a<<2)>>2]<<2)>>2]))>=(0|F)||(0|(k=D[f+(D[e+((((k=a+1|0)>>>0)%3|0?k:a-2|0)<<2)>>2]<<2)>>2]))>=(0|F)||(0|(a=D[f+(D[e+(a+((a>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2]))>=(0|F))){if(!y){if(e=s(Q,a),f=s(Q,k),t=s(Q,t),a=0,n=0,G)for(;D[(a<<2)+i>>2]=(D[(a+e<<2)+g>>2]+D[(a+f<<2)+g>>2]|0)-D[(a+t<<2)+g>>2],D[((k=1|a)<<2)+i>>2]=(D[(e+k<<2)+g>>2]+D[(f+k<<2)+g>>2]|0)-D[(k+t<<2)+g>>2],a=a+2|0,(0|c)!=(0|(n=n+2|0)););if(w&&(D[(a<<2)+i>>2]=(D[(a+e<<2)+g>>2]+D[(a+f<<2)+g>>2]|0)-D[(a+t<<2)+g>>2]),!y){if(e=0,a=0,f=0,G>>>0>2)for(;D[(k=(t=a<<2)+E|0)>>2]=D[k>>2]+D[t+i>>2],D[(n=(k=4|t)+E|0)>>2]=D[n>>2]+D[k+i>>2],D[(n=(k=8|t)+E|0)>>2]=D[n>>2]+D[k+i>>2],D[(k=(t|=12)+E|0)>>2]=D[k>>2]+D[t+i>>2],a=a+4|0,(0|Y)!=(0|(f=f+4|0)););if(b)for(;D[(t=(f=a<<2)+E|0)>>2]=D[t>>2]+D[f+i>>2],a=a+1|0,(0|b)!=(0|(e=e+1|0)););}}N=N+1|0}Q:{if((B>>>0)%3|0)B=B-1|0;else if(a=-1,-1==(0|(B=B+2|0)))break Q;a=-1,D[D[R>>2]+(B>>>3&536870908)>>2]>>>B&1||(a=-1,-1!=(0|(B=D[D[D[R+64>>2]+12>>2]+(B<<2)>>2]))&&(a=B-1|0,(B>>>0)%3|0||(a=B+2|0)))}if(-1==(0|(B=(0|a)==(0|r)?-1:a)))break}if(f=s(Q,F),!N)break I;if(y)break g;if(a=0,B=0,!G)break C;for(;D[(e=(r=a<<2)+E|0)>>2]=D[e>>2]/(0|N),D[(r=(4|r)+E|0)>>2]=D[r>>2]/(0|N),a=a+2|0,(0|c)!=(0|(B=B+2|0)););}w&&(D[(B=(a<<2)+E|0)>>2]=D[B>>2]/(0|N))}if((0|C)<=0)break A;for(e=D[A+32>>2],a=0;(0|(B=D[(C=a<<2)+E>>2]))>(0|(r=D[A+16>>2]))?D[C+e>>2]=r:D[(C=C+e|0)>>2]=(0|(r=D[A+12>>2]))>(0|B)?r:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(B=0,(0|C)<=0)break A;for(a=(C=f<<2)+g|0,f=I+C|0;;){D[(C=(r=B<<2)+a|0)>>2]=r=D[r+f>>2]+D[r+e>>2]|0;g:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break g;r=r+D[A+20>>2]|0}D[C>>2]=r}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}break A}if(!((0|C)<=0)){for(r=(s(F-1|0,Q)<<2)+g|0,e=D[A+32>>2],a=0;(0|(B=D[(C=a<<2)+r>>2]))>(0|(N=D[A+16>>2]))?D[C+e>>2]=N:D[(C=C+e|0)>>2]=(0|(N=D[A+12>>2]))>(0|B)?N:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(B=0,!((0|C)<=0))for(a=(C=f<<2)+g|0,f=I+C|0;;){D[(C=(r=B<<2)+a|0)>>2]=r=D[r+f>>2]+D[r+e>>2]|0;I:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break I;r=r+D[A+20>>2]|0}D[C>>2]=r}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}}if((0|J)==(0|(F=F+1|0)))break}return sA(i),sA(E),1},function(A){var I=0;return D[(A|=0)>>2]=3592,(I=D[A+96>>2])&&sA(I),(I=D[A+84>>2])&&sA(I),(I=D[A+72>>2])&&sA(I),(I=D[A+60>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=3592,(I=D[A+96>>2])&&sA(I),(I=D[A+84>>2])&&sA(I),(I=D[A+72>>2])&&sA(I),(I=D[A+60>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},gQ,FC,wA,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0,H=0;d=E=d+-64|0,D[8+(A|=0)>>2]=Q|=0;A:{if((C=D[A+36>>2]-(r=D[(B=A+32|0)>>2])>>2)>>>0<Q>>>0)$I(B,Q-C|0),D[E+56>>2]=0,D[E+60>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=0;else if(C>>>0>Q>>>0&&(D[A+36>>2]=r+(Q<<2)),D[E+56>>2]=0,D[E+60>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=0,C=0,!Q)break A;ZA(E+16|0,Q,E),e=D[E+28>>2],C=D[E+32>>2]}D[E>>2]=0;A:if((C=C-e>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+32>>2]=(Q<<2)+e}else ZA(E+16|12,Q-C|0,E);D[E>>2]=0;A:if((C=D[E+44>>2]-(B=D[E+40>>2])>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+44>>2]=B+(Q<<2)}else ZA(E+40|0,Q-C|0,E);D[E>>2]=0;A:if((C=D[E+56>>2]-(B=D[E+52>>2])>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+56>>2]=B+(Q<<2)}else ZA(E+52|0,Q-C|0,E);if(e=0,!(D[A+8>>2]<=0)){for(f=D[A+32>>2],r=D[E+16>>2];(0|(B=D[(C=e<<2)+r>>2]))>(0|(N=D[A+16>>2]))?D[C+f>>2]=N:D[(C=C+f|0)>>2]=(0|(N=D[A+12>>2]))>(0|B)?N:B,(0|(e=e+1|0))<(0|(C=D[A+8>>2])););if(!((0|C)<=0))for(C=0;;){D[(B=(r=C<<2)+g|0)>>2]=r=D[I+r>>2]+D[r+f>>2]|0;A:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break A;r=r+D[A+20>>2]|0}D[B>>2]=r}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}a=D[A+52>>2],i=D[A+48>>2],o=DC(16),D[(C=o)>>2]=0,D[C+4>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,D[E+8>>2]=0,D[E>>2]=0,D[E+4>>2]=0;A:{if(Q){if(Q>>>0>=1073741824)break A;b=DC(C=Q<<2),D[E>>2]=b,D[E+8>>2]=C+b,bI(b,0,C)}R=1;I:if(!((0|(C=D[(C=D[A+56>>2])+4>>2]-(S=D[C>>2])|0))<5))for(l=(0|(C>>=2))>2?C:2,L=C>>>0>1?C:1,Y=-2&Q,K=1&Q,u=-4&Q,M=3&Q,h=Q-1|0,p=Q<<2,N=1;;){g:{C:{Q:{B:{if((0|N)!=(0|L)){C=((B=D[(N<<2)+S>>2])>>>0)%3|0;E:{i:if(-1!=(0|B)){f=0,J=0!=(0|C)|-1!=(0|(r=B+2|0)),F=1,n=1<<(y=C?B-1|0:r),G=y>>>5|0,H=D[i>>2],C=B;o:{for(;;){if(!(D[(C>>>3&536870908)+H>>2]>>>C&1||-1==(0|(r=D[D[D[i+64>>2]+12>>2]+(C<<2)>>2]))||(0|(R=D[(k=D[a>>2])+(D[(e=D[i+28>>2])+(r<<2)>>2]<<2)>>2]))>=(0|N)||(0|(t=D[k+(D[e+((((t=r+1|0)>>>0)%3|0?t:r-2|0)<<2)>>2]<<2)>>2]))>=(0|N)||(0|(e=D[k+(D[e+(r+((r>>>0)%3|0?-1:2)<<2)>>2]<<2)>>2]))>=(0|N))){if(Q){if(r=D[(E+16|0)+s(f,12)>>2],k=s(Q,e),t=s(Q,t),R=s(Q,R),e=0,w=0,h)for(;D[r+(e<<2)>>2]=(D[(e+k<<2)+g>>2]+D[(e+t<<2)+g>>2]|0)-D[(e+R<<2)+g>>2],D[r+((c=1|e)<<2)>>2]=(D[(k+c<<2)+g>>2]+D[(t+c<<2)+g>>2]|0)-D[(R+c<<2)+g>>2],e=e+2|0,(0|Y)!=(0|(w=w+2|0)););K&&(D[r+(e<<2)>>2]=(D[(e+k<<2)+g>>2]+D[(e+t<<2)+g>>2]|0)-D[(e+R<<2)+g>>2])}if(r=4,4==(0|(f=f+1|0)))break o}a:if(1&F){if(e=C-2|0,r=C+1|0,C=-1,-1==(0|(r=(r>>>0)%3|0?r:e))|D[D[i>>2]+(r>>>3&536870908)>>2]>>>r&1)break a;if(-1==(0|(r=D[D[D[i+64>>2]+12>>2]+(r<<2)>>2])))break a;C=((C=r+1|0)>>>0)%3|0?C:r-2|0}else{if((C>>>0)%3|0)e=C-1|0;else if(e=C+2|0,C=-1,-1==(0|e))break a;C=-1,D[D[i>>2]+(e>>>3&536870908)>>2]>>>e&1||-1!=(0|(r=D[D[D[i+64>>2]+12>>2]+(e<<2)>>2]))&&(C=(r>>>0)%3|0?r-1|0:r+2|0)}a:if((0|C)!=(0|B)){if(!(1&(1^F)|-1!=(0|C))){if(!J|n&D[D[i>>2]+(G<<2)>>2])break a;if(-1==(0|(C=D[D[D[i+64>>2]+12>>2]+(y<<2)>>2])))break a;F=0,C=(C>>>0)%3|0?C-1|0:C+2|0}if(-1!=(0|C))continue}break}if((0|(r=f))<=0)break i}for(Q&&bI(D[E>>2],0,p),c=((C=r-1|0)<<2)+o|0,w=C=s(C,12)+A|0,J=D[C- -64>>2],R=0,F=0,C=0;;){if(D[c>>2]=(B=D[c>>2])+1,B>>>0>=J>>>0)break I;if(!(D[D[w+60>>2]+(B>>>3&536870908)>>2]>>>B&1)&&(C=C+1|0,Q)){if(f=D[E>>2],k=D[(E+16|0)+s(F,12)>>2],y=0,e=0,B=0,h>>>0>=3)for(;D[(n=(t=e<<2)+f|0)>>2]=D[n>>2]+D[k+t>>2],D[(G=(n=4|t)+f|0)>>2]=D[G>>2]+D[k+n>>2],D[(G=(n=8|t)+f|0)>>2]=D[G>>2]+D[k+n>>2],D[(n=(t|=12)+f|0)>>2]=D[n>>2]+D[k+t>>2],e=e+4|0,(0|u)!=(0|(B=B+4|0)););if(M)for(;D[(t=(B=e<<2)+f|0)>>2]=D[t>>2]+D[B+k>>2],e=e+1|0,(0|M)!=(0|(y=y+1|0)););}if((0|(F=F+1|0))==(0|r))break}if(B=F=s(Q,N),!C)break E;if(!Q)break C;if(B=D[E>>2],e=0,r=0,h)break B;break Q}B=s(Q,N)}if(D[A+8>>2]<=0)break g;for(F=(s(N-1|0,Q)<<2)+g|0,f=D[A+32>>2],e=0;(0|(r=D[(C=e<<2)+F>>2]))>(0|(k=D[A+16>>2]))?D[C+f>>2]=k:D[(C=C+f|0)>>2]=(0|(k=D[A+12>>2]))>(0|r)?k:r,(0|(e=e+1|0))<(0|(r=D[A+8>>2])););if(C=0,(0|r)<=0)break g;for(e=(B<<=2)+g|0,F=I+B|0;;){D[(B=(r=C<<2)+e|0)>>2]=r=D[r+F>>2]+D[r+f>>2]|0;E:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break E;r=r+D[A+20>>2]|0}D[B>>2]=r}if(!((0|(C=C+1|0))<D[A+8>>2]))break}break g}sQ(),U()}for(;D[(k=(f=e<<2)+B|0)>>2]=D[k>>2]/(0|C),D[(f=B+(4|f)|0)>>2]=D[f>>2]/(0|C),e=e+2|0,(0|Y)!=(0|(r=r+2|0)););}K&&(D[(B=B+(e<<2)|0)>>2]=D[B>>2]/(0|C))}if(!(D[A+8>>2]<=0)){for(f=D[A+32>>2],e=0;(0|(B=D[(C=e<<2)+b>>2]))>(0|(r=D[A+16>>2]))?D[C+f>>2]=r:D[(C=C+f|0)>>2]=(0|(r=D[A+12>>2]))>(0|B)?r:B,(0|(e=e+1|0))<(0|(B=D[A+8>>2])););if(C=0,!((0|B)<=0))for(e=(B=F<<2)+g|0,F=I+B|0;;){D[(B=(r=C<<2)+e|0)>>2]=r=D[r+F>>2]+D[r+f>>2]|0;C:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break C;r=r+D[A+20>>2]|0}D[B>>2]=r}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}}if(R=1,(0|l)==(0|(N=N+1|0)))break}return(A=D[E>>2])&&sA(A),sA(o),(A=D[E+52>>2])&&(D[E+56>>2]=A,sA(A)),(A=D[E+40>>2])&&(D[E+44>>2]=A,sA(A)),(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),d=E- -64|0,0|R}iQ(),U()},function(A){var I=0;return D[(A|=0)>>2]=3840,(I=D[A+76>>2])&&sA(I),I=D[A+68>>2],D[A+68>>2]=0,I&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=3840,(I=D[A+76>>2])&&sA(I),I=D[A+68>>2],D[A+68>>2]=0,I&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},AQ,NC,EQ,OC,nC,pA,function(A,I,g,C,Q,E){A|=0,I|=0,g|=0,C|=0,Q|=0,E|=0;var i=0,o=0,a=F(0),r=F(0),f=0,k=0,N=0,R=F(0),y=F(0),G=F(0),w=F(0),h=F(0),J=F(0),S=0,Y=F(0),K=F(0),M=F(0),l=F(0),L=F(0),u=F(0),p=0,H=F(0),q=F(0);D[A+64>>2]=E,D[A+72>>2]=Q,E=DC((1073741823&Q)!=(0|Q)?-1:Q<<2),C=D[A+68>>2],D[A+68>>2]=E,C&&sA(C),D[A+8>>2]=Q,(C=D[A+36>>2]-(i=D[(E=A+32|0)>>2])>>2)>>>0<Q>>>0?$I(E,Q-C|0):C>>>0<=Q>>>0||(D[A+36>>2]=i+(Q<<2));A:if(!((0|(C=(i=D[(C=D[A+56>>2])+4>>2])-(E=D[C>>2])|0))<=0)){if((0|E)!=(0|i))for(p=(C=C>>>2|0)>>>0>1?C:1;;){if(o=D[(N<<2)+E>>2],r=F(0),d=i=d-48|0,E=-1,C=-1,-1!=(0|o)&&(E=((C=o+1|0)>>>0)%3|0?C:o-2|0,C=o-1|0,(o>>>0)%3|0||(C=o+2|0)),(f=D[(f=D[A+52>>2])+4>>2]-(o=D[f>>2])>>2)>>>0<=(k=D[(k=E<<2)+(E=D[D[A+48>>2]+28>>2])>>2])>>>0||(E=D[E+(C<<2)>>2])>>>0>=f>>>0)sQ(),U();else{I:if((0|(f=D[o+(E<<2)>>2]))>=(0|N)|(0|(C=D[o+(k<<2)>>2]))>=(0|N)){if((0|C)<(0|N))C=s(C,E=D[A+72>>2]);else{if(E=0,(0|N)<=0){if(D[A+72>>2]<=0)break I;for(C=D[A+68>>2];D[C+(E<<2)>>2]=0,(0|(E=E+1|0))<D[A+72>>2];);break I}C=s(E=D[A+72>>2],N-1|0)}if(!((0|E)<=0))for(o=D[A+68>>2],E=0;D[o+(E<<2)>>2]=D[(C+E<<2)+g>>2],(0|(E=E+1|0))<D[A+72>>2];);}else{if(o=(s(E=D[A+72>>2],f)<<2)+g|0,R=F(D[o+4>>2]),E=(s(C,E)<<2)+g|0,w=F(D[E+4>>2]),!((Y=F(D[o>>2]))!=(l=F(D[E>>2]))|R!=w)){if(C=D[A+68>>2],E=F(n(R))<F(2147483648)?~~R:-2147483648,D[C+4>>2]=E,F(n(Y))<F(2147483648)){D[C>>2]=~~Y;break I}D[C>>2]=-2147483648;break I}E=D[D[A+64>>2]+(N<<2)>>2],D[i+40>>2]=0,D[i+32>>2]=0,D[i+36>>2]=0,e[(o=D[A+60>>2])+84|0]||(E=D[D[o+68>>2]+(E<<2)>>2]),v(o,E,B[o+24|0],i+32|0),E=D[D[A+64>>2]+(C<<2)>>2],D[i+24>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,e[(C=D[A+60>>2])+84|0]||(E=D[D[C+68>>2]+(E<<2)>>2]),v(C,E,B[C+24|0],i+16|0),E=D[D[A+64>>2]+(f<<2)>>2],D[i+8>>2]=0,D[i>>2]=0,D[i+4>>2]=0,e[(C=D[A+60>>2])+84|0]||(E=D[D[C+68>>2]+(E<<2)>>2]),v(C,E,B[C+24|0],i),a=F(t[i+8>>2]-(h=t[i+24>>2])),K=F(t[i+4>>2]-(J=t[i+20>>2])),M=F(t[i>>2]-(u=t[i+16>>2])),L=F(F(a*a)+F(F(K*K)+F(F(M*M)+F(0)))),y=t[i+40>>2],H=t[i+36>>2],q=t[i+32>>2],D[A+88>>2]>=258&&(G=F(0),!(L>F(0)))||(y=F(y-h),h=F(H-J),J=F(q-u),r=F(F(F(a*y)+F(F(K*h)+F(F(M*J)+F(0))))/L),a=F(y-F(a*r)),y=F(a*a),a=F(h-F(K*r)),G=F(a*a),a=F(J-F(M*r)),G=F(b(F(F(y+F(G+F(F(a*a)+F(0))))/L)))),y=G,E=D[D[A+76>>2]+((C=D[A+80>>2]-1|0)>>>3&536870908)>>2],D[A+80>>2]=C,a=F(R-w),G=F(F(a*r)+w),w=F(Y-l),R=F(w*y),R=F(G+((C=E>>>C&1)?R:F(-R))),G=F(F(w*r)+l),r=F(a*y),(r=F(G+(C?F(-r):r)))==r?(E=D[A+68>>2],S=c(+r+.5),C=n(S)<2147483648?~~S:-2147483648,D[E>>2]=C):D[(E=D[A+68>>2])>>2]=-2147483648,S=c(+R+.5),C=n(S)<2147483648?~~S:-2147483648,D[E+4>>2]=R!=R?-2147483648:C}d=i+48|0}if(!(D[A+8>>2]<=0)){for(o=D[A+32>>2],f=D[A+68>>2],E=0;(0|(i=D[(C=E<<2)+f>>2]))>(0|(k=D[A+16>>2]))?D[C+o>>2]=k:D[(C=C+o|0)>>2]=(0|(k=D[A+12>>2]))>(0|i)?k:i,(0|(E=E+1|0))<(0|(i=D[A+8>>2])););if(C=0,!((0|i)<=0))for(f=(E=s(Q,N)<<2)+g|0,k=I+E|0;;){D[(E=(i=C<<2)+f|0)>>2]=i=D[i+k>>2]+D[i+o>>2]|0;I:{if((0|i)>D[A+16>>2])i=i-D[A+20>>2]|0;else{if((0|i)>=D[A+12>>2])break I;i=i+D[A+20>>2]|0}D[E>>2]=i}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}if((0|p)==(0|(N=N+1|0)))break A;if(!(D[(C=D[A+56>>2])+4>>2]-(E=D[C>>2])>>2>>>0>N>>>0))break}sQ(),U()}return 1},function(A){var I=0;return D[(A|=0)>>2]=4068,(I=D[A+76>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=4068,(I=D[A+76>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},QQ,NC,EQ,OC,nC,WA,function(A,I,g,C,Q,E){A|=0,I|=0,g|=0,C|=0,E|=0;var i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,p=0,H=0,q=0,W=0,V=0,_=0,T=0,m=0,Z=0,x=0,X=0,j=0,O=0,v=0,z=0;if(2==(0|(Q|=0))){D[A+8>>2]=2,D[A- -64>>2]=E,(i=(E=D[A+36>>2]-(Q=D[(C=A+32|0)>>2])|0)>>2)>>>0<=1?$I(C,2-i|0):8!=(0|E)&&(D[A+36>>2]=Q+8);A:if((0|(E=(Q=D[(C=D[A+56>>2])+4>>2])-(C=D[C>>2])|0))<=0)E=0;else{if((0|C)!=(0|Q))for(t=A+60|0,j=(0|(H=E>>2))>1?H:1,E=1;;){d=r=d-80|0,Q=-1,i=-1,-1!=(0|(C=D[(n<<2)+C>>2]))&&(Q=((Q=C+1|0)>>>0)%3|0?Q:C-2|0,i=C-1|0,(C>>>0)%3|0||(i=C+2|0));I:{g:{C:{Q:{if(!((a=D[(a=D[t+36>>2])+4>>2]-(C=D[a>>2])>>2)>>>0<=(f=D[(o=Q<<2)+(Q=D[D[t+32>>2]+28>>2])>>2])>>>0||(Q=D[Q+(i<<2)>>2])>>>0>=a>>>0)){B:{if(!((0|(i=D[C+(Q<<2)>>2]))>=(0|n)|(0|(a=D[C+(f<<2)>>2]))>=(0|n))){if(!((0|(h=D[(C=(i<<3)+g|0)>>2]))!=(0|(M=D[(Q=(a<<3)+g|0)>>2]))|(0|(y=D[Q+4>>2]))!=(0|(w=D[C+4>>2])))){D[t+8>>2]=M,D[t+12>>2]=y;break B}if(C=D[D[t+4>>2]+(n<<2)>>2],D[r+72>>2]=0,D[r+76>>2]=0,D[(Q=r- -64|0)>>2]=0,D[Q+4>>2]=0,D[r+56>>2]=0,D[r+60>>2]=0,e[(Q=D[t>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),BA(Q,C,B[Q+24|0],r+56|0),C=D[D[t+4>>2]+(a<<2)>>2],D[r+48>>2]=0,D[r+52>>2]=0,D[r+40>>2]=0,D[r+44>>2]=0,D[r+32>>2]=0,D[r+36>>2]=0,e[(Q=D[t>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),BA(Q,C,B[Q+24|0],r+32|0),C=D[D[t+4>>2]+(i<<2)>>2],D[r+24>>2]=0,D[r+28>>2]=0,D[r+16>>2]=0,D[r+20>>2]=0,D[r+8>>2]=0,D[r+12>>2]=0,e[(Q=D[t>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),BA(Q,C,B[Q+24|0],r+8|0),C=mg(s=(C=D[r+16>>2])-(Q=l=D[r+40>>2])|0,f=D[r+20>>2]-((q=D[r+44>>2])+(C>>>0<Q>>>0)|0)|0,s,f),Q=u,N=C,i=mg(G=(C=D[r+8>>2])-(i=L=D[r+32>>2])|0,o=D[r+12>>2]-((W=D[r+36>>2])+(C>>>0<i>>>0)|0)|0,G,o),Q=u+Q|0,Q=(C=N+i|0)>>>0<i>>>0?Q+1|0:Q,N=C,R=mg(F=(C=D[r+24>>2])-(i=p=D[r+48>>2])|0,k=D[r+28>>2]-((V=D[r+52>>2])+(C>>>0<i>>>0)|0)|0,F,k),i=u+Q|0,c=C=N+R|0,C|(R=C>>>0<R>>>0?i+1|0:i)){if(C=mg((C=N=D[r+64>>2])-l|0,(T=D[r+68>>2])-((C>>>0<l>>>0)+q|0)|0,s,f),Q=u,C=(i=C)+(a=mg((C=m=D[r+56>>2])-L|0,(Z=D[r+60>>2])-((C>>>0<L>>>0)+W|0)|0,G,o))|0,i=u+Q|0,i=C>>>0<a>>>0?i+1|0:i,C=(Q=C)+(a=mg((C=x=D[r+72>>2])-p|0,(X=D[r+76>>2])-((C>>>0<p>>>0)+V|0)|0,F,k))|0,Q=u+i|0,J=C,b=C>>>0<a>>>0?Q+1|0:Q,i=(C=k>>31)+k|0,i=(Q=C+F|0)>>>0<C>>>0?i+1|0:i,Q^=C,a=C^=i,i=(C=f>>31)+f|0,Y=C^(S=C+s|0),S=C^=C>>>0>S>>>0?i+1|0:i,_=0,i=(C=o>>31)+o|0,i=(K=C+G|0)>>>0<C>>>0?i+1|0:i,O=Q,K^=C,(Q=vA(-1,2147483647,(Q=(0|a)==(0|(C=(i=(0|S)==(0|(C^=i))&Y>>>0>K>>>0|C>>>0<S>>>0)?S:C))&Q>>>0>(Y=i?Y:K)>>>0|C>>>0<a>>>0)?O:Y,Q?a:C)>>>0<J>>>0)&(0|(C=u))<=(0|b)|(0|C)<(0|b))break I;if(a=1,C=0,Q=N,s=_g(mg(s,f,J,b),u,c,R),i=u+q|0,i=T-((Q>>>0<(f=s+l|0)>>>0)+(i=f>>>0<s>>>0?i+1|0:i)|0)|0,i=mg(Q=Q-f|0,i,Q,i),s=u,Q=m,N=i,o=_g(mg(G,o,J,b),u,c,R),i=u+W|0,i=Z-((Q>>>0<(f=o+L|0)>>>0)+(i=o>>>0>f>>>0?i+1|0:i)|0)|0,f=mg(Q=Q-f|0,i,Q,i),Q=u+s|0,f=Q=(i=N+f|0)>>>0<f>>>0?Q+1|0:Q,Q=x,N=i,k=_g(mg(F,k,J,b),u,c,R),i=u+V|0,i=X-((Q>>>0<(o=k+p|0)>>>0)+(i=o>>>0<k>>>0?i+1|0:i)|0)|0,o=mg(Q=Q-o|0,i,Q,i),i=u+f|0,f=mg(Q=N+o|0,Q>>>0<o>>>0?i+1|0:i,c,R),o=Q=u,!Q&f>>>0<=1)break Q;for(k=f,Q=o;i=C<<1|a>>>31,a<<=1,C=i,s=!Q&k>>>0>7|0!=(0|Q),k=(3&Q)<<30|k>>>2,Q=Q>>>2|0,s;);break C}}if((0|a)<(0|n))C=a<<1;else{if((0|n)<=0){D[t+8>>2]=0,D[t+12>>2]=0;break B}C=(n<<1)-2|0}D[t+8>>2]=D[(C=(C<<2)+g|0)>>2],D[t+12>>2]=D[C+4>>2]}_=1;break I}sQ(),U()}if(C=o,(a=f)-1|0)break g}for(;Q=vA(f,o,a,C)+a|0,i=C+u|0,Q=mg(a=(1&(i=Q>>>0<a>>>0?i+1|0:i))<<31|Q>>>1,C=i>>>1|0,a,C),(0|o)==(0|(i=u))&Q>>>0>f>>>0|i>>>0>o>>>0;);}(f=D[t+20>>2])&&(k=D[D[t+16>>2]+((Q=f-1|0)>>>3&536870908)>>2],D[t+20>>2]=Q,i=mg(J,b,s=w-(i=y)|0,G=(w>>31)-((o=i>>31)+(i>>>0>w>>>0)|0)|0),F=u,o=(y=mg(y,o,c,R))+i|0,i=u+F|0,i=o>>>0<y>>>0?i+1|0:i,N=o,h=o=mg(a,C,F=h-(o=M)|0,w=(h>>31)-((y=o>>31)+(o>>>0>h>>>0)|0)|0),o=N+(k=(Q=k>>>Q&1)?0-o|0:o)|0,N=i,i=u,i=N+(Q?0-(i+(0!=(0|h))|0)|0:i)|0,v=t,z=_g(o,o>>>0<k>>>0?i+1|0:i,c,R),D[v+12>>2]=z,i=mg(F,w,J,b),k=u,o=(F=mg(c,R,M,y))+i|0,i=u+k|0,i=o>>>0<F>>>0?i+1|0:i,N=o,C=mg(a,C,s,G),a=N+(o=Q?C:0-C|0)|0,N=i,i=u,Q=N+(Q?i:0-((0!=(0|C))+i|0)|0)|0,v=t,z=_g(a,a>>>0<o>>>0?Q+1|0:Q,c,R),D[v+8>>2]=z),_=0!=(0|f)}if(d=r+80|0,!_)break A;if(!(D[A+8>>2]<=0)){for(i=D[A+32>>2],C=0;(0|(E=D[68+((Q=C<<2)+A|0)>>2]))>(0|(a=D[A+16>>2]))?D[Q+i>>2]=a:D[(Q=Q+i|0)>>2]=(0|(a=D[A+12>>2]))>(0|E)?a:E,(0|(C=C+1|0))<(0|(E=D[A+8>>2])););if(Q=0,!((0|E)<=0))for(a=(C=n<<3)+g|0,f=I+C|0;;){D[(C=(E=Q<<2)+a|0)>>2]=E=D[E+f>>2]+D[E+i>>2]|0;I:{if((0|E)>D[A+16>>2])E=E-D[A+20>>2]|0;else{if((0|E)>=D[A+12>>2])break I;E=E+D[A+20>>2]|0}D[C>>2]=E}if(!((0|(Q=Q+1|0))<D[A+8>>2]))break}}if(E=(0|H)>(0|(n=n+1|0)),(0|n)==(0|j))break A;if(!(D[(Q=D[A+56>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>n>>>0))break}sQ(),U()}A=1^E}else A=0;return 1&A},function(A){var I;return D[(A|=0)>>2]=4304,D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I;D[(A|=0)>>2]=4304,D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},BQ,gC,EQ,OC,RC,QI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,t=0;d=E=d-32|0,D[68+(A|=0)>>2]=B|=0,C=D[(Q=D[A+56>>2])>>2],B=D[Q+4>>2],D[E+24>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0;A:if(!((0|(B=B-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+112|0,k=A+60|0,t=(Q=B>>>2|0)>>>0>1?Q:1;;){if(EA(k,D[(r<<2)+C>>2],E+16|0),o=(a=D[E+24>>2])>>31,i=(o^=o+a)+(((C=(Q=D[E+20>>2])>>31)^C+Q)+((i=(B=D[E+16>>2])>>31)^B+i)|0)|0,C=0,(C=i>>>0<o>>>0?1:C)|i?(B=_g(mg(o=D[A+108>>2],e=o>>31,B,B>>31),u,i,C),D[E+16>>2]=B,C=_g(mg(o,e,Q,Q>>31),u,i,C),D[E+20>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=B>>31)+B^C)|0,D[E+24>>2]=(0|a)>=0?o-C:C-o):D[E+16>>2]=D[A+108>>2],C=ug(f),B=D[E+16>>2],C?(D[E+24>>2]=0-D[E+24>>2],D[E+20>>2]=Q=0-D[E+20>>2]|0,D[E+16>>2]=B=0-B|0):Q=D[E+20>>2],(0|B)>=0?(B=(C=D[A+108>>2])+D[E+24>>2]|0,C=C+Q|0):((0|Q)<0?(C=(B=D[E+24>>2])>>31,C^=C+B):C=D[A+100>>2]-((C=(B=D[E+24>>2])>>31)^C+B)|0,B=(0|B)<0?(B=Q)+(Q>>=31)^Q:D[A+100>>2]-((B=Q)+(Q>>=31)^Q)|0),Q=D[A+100>>2],C|B?(0|Q)!=(0|B)|C?B|(i=(0|C)!=(0|Q))?C||(0|(a=D[A+108>>2]))>=(0|B)?i||(0|(i=D[A+108>>2]))<=(0|B)?(0|Q)!=(0|B)||(0|(Q=D[A+108>>2]))<=(0|C)?B||(B=0,(0|(Q=D[A+108>>2]))>=(0|C)||(C=(Q<<1)-C|0)):C=(Q<<1)-C|0:B=(i<<1)-B|0:(B=(a<<1)-B|0,C=0):B=C:C=B:C=B=Q,D[E+12>>2]=B,D[E+8>>2]=C,!(D[A+8>>2]<=0)){for(i=D[A+32>>2],B=0;(0|(Q=D[A+16>>2]))<(0|C)?D[i+(B<<2)>>2]=Q:D[(Q=i+(B<<2)|0)>>2]=(0|(a=D[A+12>>2]))>(0|C)?a:C,(0|(B=B+1|0))<(0|(Q=D[A+8>>2]));)C=D[(E+8|0)+(B<<2)>>2];if(C=0,!((0|Q)<=0))for(a=(Q=r<<3)+g|0,o=I+Q|0;;){D[(Q=(B=C<<2)+a|0)>>2]=B=D[B+o>>2]+D[B+i>>2]|0;I:{if((0|B)>D[A+16>>2])B=B-D[A+20>>2]|0;else{if((0|B)>=D[A+12>>2])break I;B=B+D[A+20>>2]|0}D[Q>>2]=B}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}if((0|t)==(0|(r=r+1|0)))break A;if(!(D[(Q=D[A+56>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>r>>>0))break}sQ(),U()}return d=E+32|0,1},$C,oQ,fC,_C,EA,rQ,wC,EQ,FC,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;if(D[8+(A|=0)>>2]=Q|=0,(B=D[A+36>>2]-(k=D[(C=A+32|0)>>2])>>2)>>>0<Q>>>0?($I(C,Q-B|0),k=D[C>>2],C=D[A+8>>2]):(Q>>>0<B>>>0&&(D[A+36>>2]=(Q<<2)+k),C=Q),o=D[A+52>>2],E=D[A+48>>2],B=0,N=bI(DC(N=(1073741823&Q)!=(0|Q)?-1:Q<<2),0,N),!((0|C)<=0)){for(;(0|(a=D[(C=B<<2)+N>>2]))>(0|(e=D[A+16>>2]))?D[C+k>>2]=e:D[(C=C+k|0)>>2]=(0|(e=D[A+12>>2]))>(0|a)?e:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(!((0|C)<=0))for(B=0;;){D[(C=(a=B<<2)+g|0)>>2]=a=D[I+a>>2]+D[a+k>>2]|0;A:{if((0|a)>D[A+16>>2])r=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break A;r=a+D[A+20>>2]|0}D[C>>2]=r}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}if((0|(B=D[(B=D[A+56>>2])+4>>2]-(i=D[B>>2])|0))>=5)for(n=(0|(B>>=2))>2?B:2,R=B>>>0>1?B:1,y=-2&Q,G=1&Q,k=1;;){A:{I:{if((0|k)!=(0|R)){if(F=s(Q,k),-1==(0|(B=D[(k<<2)+i>>2])))break I;if(-1==(0|(B=D[D[E+12>>2]+(B<<2)>>2])))break I;f=D[(e=D[o>>2])+(D[(a=D[E>>2])+(B<<2)>>2]<<2)>>2],r=-1!=(0|(r=((r=B+1|0)>>>0)%3|0?r:B-2|0))?D[a+(r<<2)>>2]:-1;g:{if((B>>>0)%3|0)B=B-1|0;else if(t=-1,-1==(0|(B=B+2|0)))break g;t=D[a+(B<<2)>>2]}if((0|f)>=(0|k))break I;if((0|(B=D[(r<<2)+e>>2]))>=(0|k))break I;if((0|(a=D[e+(t<<2)>>2]))>=(0|k))break I;if(!((0|Q)<=0)){if(a=s(Q,a),e=s(Q,B),f=s(Q,f),B=0,t=0,1!=(0|Q))for(;D[N+(B<<2)>>2]=(D[(B+a<<2)+g>>2]+D[(B+e<<2)+g>>2]|0)-D[(B+f<<2)+g>>2],D[N+((r=1|B)<<2)>>2]=(D[(a+r<<2)+g>>2]+D[(e+r<<2)+g>>2]|0)-D[(r+f<<2)+g>>2],B=B+2|0,(0|y)!=(0|(t=t+2|0)););G&&(D[N+(B<<2)>>2]=(D[(B+a<<2)+g>>2]+D[(B+e<<2)+g>>2]|0)-D[(B+f<<2)+g>>2])}if((0|C)<=0)break A;for(e=D[A+32>>2],B=0;(0|(a=D[(C=B<<2)+N>>2]))>(0|(f=D[A+16>>2]))?D[C+e>>2]=f:D[(C=C+e|0)>>2]=(0|(f=D[A+12>>2]))>(0|a)?f:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(B=0,(0|C)<=0)break A;for(f=(C=F<<2)+g|0,r=I+C|0;;){D[(C=(a=B<<2)+f|0)>>2]=a=D[a+r>>2]+D[a+e>>2]|0;g:{if((0|a)>D[A+16>>2])t=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break g;t=a+D[A+20>>2]|0}D[C>>2]=t}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}break A}sQ(),U()}if(!((0|C)<=0)){for(f=(s(k-1|0,Q)<<2)+g|0,e=D[A+32>>2],B=0;(0|(a=D[(C=B<<2)+f>>2]))>(0|(r=D[A+16>>2]))?D[C+e>>2]=r:D[(C=C+e|0)>>2]=(0|(r=D[A+12>>2]))>(0|a)?r:a,(0|(C=D[A+8>>2]))>(0|(B=B+1|0)););if(B=0,!((0|C)<=0))for(f=(C=F<<2)+g|0,r=I+C|0;;){D[(C=(a=B<<2)+f|0)>>2]=a=D[a+r>>2]+D[a+e>>2]|0;I:{if((0|a)>D[A+16>>2])t=a-D[A+20>>2]|0;else{if((0|a)>=D[A+12>>2])break I;t=a+D[A+20>>2]|0}D[C>>2]=t}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}}if((0|n)==(0|(k=k+1|0)))break}return sA(N),1},rQ,wC,CQ,FC,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a=0,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0;if(D[8+(A|=0)>>2]=Q|=0,(B=D[A+36>>2]-(e=D[(C=A+32|0)>>2])>>2)>>>0<Q>>>0?($I(C,Q-B|0),e=D[C>>2],C=D[A+8>>2]):(Q>>>0<B>>>0&&(D[A+36>>2]=(Q<<2)+e),C=Q),E=bI(DC(B=(1073741823&Q)!=(0|Q)?-1:Q<<2),0,B),i=bI(DC(B),0,B),!((0|C)<=0)){for(;(0|(B=D[(C=a<<2)+E>>2]))>(0|(r=D[A+16>>2]))?D[C+e>>2]=r:D[(C=C+e|0)>>2]=(0|(r=D[A+12>>2]))>(0|B)?r:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(!((0|C)<=0))for(B=0;;){D[(C=(r=B<<2)+g|0)>>2]=r=D[I+r>>2]+D[r+e>>2]|0;A:{if((0|r)>D[A+16>>2])a=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break A;a=r+D[A+20>>2]|0}D[C>>2]=a}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}if((0|(B=D[(B=D[A+56>>2])+4>>2]-(o=D[B>>2])|0))>=5)for(J=D[A+52>>2],G=D[A+48>>2],S=(0|(B>>=2))>2?B:2,Y=B>>>0>1?B:1,c=-2&Q,w=1&Q,K=-4&Q,b=3&Q,y=Q-1|0,M=Q<<2,F=1;;){A:{I:{g:{C:if((0|F)==(0|Y))sQ(),U();else{if(r=D[(F<<2)+o>>2],(R=(0|Q)<=0)||bI(E,0,M),-1==(0|r)){r=s(Q,F);break I}for(h=D[G+12>>2],t=0,B=r;;){if(-1!=(0|(a=D[(B<<2)+h>>2]))){n=D[(f=D[J>>2])+(D[(e=D[G>>2])+(a<<2)>>2]<<2)>>2],k=-1!=(0|(k=((k=a+1|0)>>>0)%3|0?k:a-2|0))?D[e+(k<<2)>>2]:-1;Q:{if((a>>>0)%3|0)a=a-1|0;else if(N=-1,-1==(0|(a=a+2|0)))break Q;N=D[e+(a<<2)>>2]}if(!((0|F)<=(0|n)||(0|(a=D[(k<<2)+f>>2]))>=(0|F)||(0|(e=D[f+(N<<2)>>2]))>=(0|F))){if(!R){if(e=s(Q,e),f=s(Q,a),n=s(Q,n),a=0,N=0,y)for(;D[(a<<2)+i>>2]=(D[(a+e<<2)+g>>2]+D[(a+f<<2)+g>>2]|0)-D[(a+n<<2)+g>>2],D[((k=1|a)<<2)+i>>2]=(D[(e+k<<2)+g>>2]+D[(f+k<<2)+g>>2]|0)-D[(k+n<<2)+g>>2],a=a+2|0,(0|c)!=(0|(N=N+2|0)););if(w&&(D[(a<<2)+i>>2]=(D[(a+e<<2)+g>>2]+D[(a+f<<2)+g>>2]|0)-D[(a+n<<2)+g>>2]),!R){if(n=0,a=0,e=0,y>>>0>2)for(;D[(k=(f=a<<2)+E|0)>>2]=D[k>>2]+D[f+i>>2],D[(N=(k=4|f)+E|0)>>2]=D[N>>2]+D[k+i>>2],D[(N=(k=8|f)+E|0)>>2]=D[N>>2]+D[k+i>>2],D[(k=(f|=12)+E|0)>>2]=D[k>>2]+D[f+i>>2],a=a+4|0,(0|K)!=(0|(e=e+4|0)););if(b)for(;D[(f=(e=a<<2)+E|0)>>2]=D[f>>2]+D[e+i>>2],a=a+1|0,(0|b)!=(0|(n=n+1|0)););}}t=t+1|0}}Q:{if((B>>>0)%3|0)B=B-1|0;else if(a=-1,-1==(0|(B=B+2|0)))break Q;a=-1,-1!=(0|(B=D[(B<<2)+h>>2]))&&(a=B-1|0,(B>>>0)%3|0||(a=B+2|0))}if(-1==(0|(B=(0|a)==(0|r)?-1:a)))break}if(r=s(Q,F),!t)break I;if(R)break g;if(a=0,B=0,!y)break C;for(;D[(f=(e=a<<2)+E|0)>>2]=D[f>>2]/(0|t),D[(e=(4|e)+E|0)>>2]=D[e>>2]/(0|t),a=a+2|0,(0|c)!=(0|(B=B+2|0)););}w&&(D[(B=(a<<2)+E|0)>>2]=D[B>>2]/(0|t))}if((0|C)<=0)break A;for(e=D[A+32>>2],a=0;(0|(B=D[(C=a<<2)+E>>2]))>(0|(t=D[A+16>>2]))?D[C+e>>2]=t:D[(C=C+e|0)>>2]=(0|(t=D[A+12>>2]))>(0|B)?t:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(B=0,(0|C)<=0)break A;for(a=(C=r<<2)+g|0,t=I+C|0;;){D[(C=(r=B<<2)+a|0)>>2]=r=D[r+t>>2]+D[r+e>>2]|0;g:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break g;r=r+D[A+20>>2]|0}D[C>>2]=r}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}break A}if(!((0|C)<=0)){for(t=(s(F-1|0,Q)<<2)+g|0,e=D[A+32>>2],a=0;(0|(B=D[(C=a<<2)+t>>2]))>(0|(f=D[A+16>>2]))?D[C+e>>2]=f:D[(C=C+e|0)>>2]=(0|(f=D[A+12>>2]))>(0|B)?f:B,(0|(C=D[A+8>>2]))>(0|(a=a+1|0)););if(B=0,!((0|C)<=0))for(a=(C=r<<2)+g|0,t=I+C|0;;){D[(C=(r=B<<2)+a|0)>>2]=r=D[r+t>>2]+D[r+e>>2]|0;I:{if((0|r)>D[A+16>>2])r=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break I;r=r+D[A+20>>2]|0}D[C>>2]=r}if(!((0|(C=D[A+8>>2]))>(0|(B=B+1|0))))break}}}if((0|S)==(0|(F=F+1|0)))break}return sA(i),sA(E),1},function(A){var I=0;return D[(A|=0)>>2]=5608,(I=D[A+96>>2])&&sA(I),(I=D[A+84>>2])&&sA(I),(I=D[A+72>>2])&&sA(I),(I=D[A+60>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=5608,(I=D[A+96>>2])&&sA(I),(I=D[A+84>>2])&&sA(I),(I=D[A+72>>2])&&sA(I),(I=D[A+60>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},gQ,FC,wA,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i,o,a,r=0,e=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0;d=E=d+-64|0,D[8+(A|=0)>>2]=Q|=0;A:{if((C=D[A+36>>2]-(r=D[(B=A+32|0)>>2])>>2)>>>0<Q>>>0)$I(B,Q-C|0),D[E+56>>2]=0,D[E+60>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=0;else if(C>>>0>Q>>>0&&(D[A+36>>2]=r+(Q<<2)),D[E+56>>2]=0,D[E+60>>2]=0,D[E+48>>2]=0,D[E+52>>2]=0,D[E+40>>2]=0,D[E+44>>2]=0,D[E+32>>2]=0,D[E+36>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=0,C=0,!Q)break A;ZA(E+16|0,Q,E),e=D[E+28>>2],C=D[E+32>>2]}D[E>>2]=0;A:if((C=C-e>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+32>>2]=(Q<<2)+e}else ZA(E+16|12,Q-C|0,E);D[E>>2]=0;A:if((C=D[E+44>>2]-(B=D[E+40>>2])>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+44>>2]=B+(Q<<2)}else ZA(E+40|0,Q-C|0,E);D[E>>2]=0;A:if((C=D[E+56>>2]-(B=D[E+52>>2])>>2)>>>0>=Q>>>0){if(C>>>0<=Q>>>0)break A;D[E+56>>2]=B+(Q<<2)}else ZA(E+52|0,Q-C|0,E);if(e=0,!(D[A+8>>2]<=0)){for(k=D[A+32>>2],r=D[E+16>>2];(0|(B=D[(C=e<<2)+r>>2]))>(0|(F=D[A+16>>2]))?D[C+k>>2]=F:D[(C=C+k|0)>>2]=(0|(F=D[A+12>>2]))>(0|B)?F:B,(0|(e=e+1|0))<(0|(C=D[A+8>>2])););if(!((0|C)<=0))for(C=0;;){D[(B=(r=C<<2)+g|0)>>2]=r=D[I+r>>2]+D[r+k>>2]|0;A:{if((0|r)>D[A+16>>2])f=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break A;f=r+D[A+20>>2]|0}D[B>>2]=f}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}a=D[A+52>>2],o=D[A+48>>2],i=DC(16),D[(C=i)>>2]=0,D[C+4>>2]=0,D[C+8>>2]=0,D[C+12>>2]=0,D[E+8>>2]=0,D[E>>2]=0,D[E+4>>2]=0;A:{if(Q){if(Q>>>0>=1073741824)break A;b=DC(C=Q<<2),D[E>>2]=b,D[E+8>>2]=C+b,bI(b,0,C)}G=1;I:if(!((0|(C=D[(C=D[A+56>>2])+4>>2]-(S=D[C>>2])|0))<5))for(l=(0|(C>>=2))>2?C:2,L=C>>>0>1?C:1,Y=-2&Q,K=1&Q,u=-4&Q,M=3&Q,h=Q-1|0,p=Q<<2,F=1;;){g:{C:{Q:{B:{if((0|F)!=(0|L)){C=((B=D[(F<<2)+S>>2])>>>0)%3|0;E:{i:if(-1!=(0|B)){k=0,J=0!=(0|C)|-1!=(0|(r=B+2|0)),y=(c=D[o+12>>2])+((C?B-1|0:r)<<2)|0,n=1,C=B;o:{for(;;){if(-1!=(0|(r=D[c+(C<<2)>>2]))){t=-1,N=D[o>>2],-1!=(0|(R=((R=r+1|0)>>>0)%3|0?R:r-2|0))&&(t=D[N+(R<<2)>>2]),R=D[(e=(G=D[a>>2])+(D[N+(r<<2)>>2]<<2)|0)>>2];a:{if((r>>>0)%3|0)e=r-1|0;else if(f=-1,-1==(0|(e=r+2|0)))break a;f=D[N+(e<<2)>>2]}if(!((0|F)<=(0|R)||(0|(e=D[G+(t<<2)>>2]))>=(0|F)||(0|(t=D[G+(f<<2)>>2]))>=(0|F))){if(r=D[(E+16|0)+s(k,12)>>2],Q){if(t=s(Q,t),N=s(Q,e),G=s(Q,R),e=0,f=0,h)for(;D[r+(e<<2)>>2]=(D[(e+t<<2)+g>>2]+D[(e+N<<2)+g>>2]|0)-D[(e+G<<2)+g>>2],D[r+((R=1|e)<<2)>>2]=(D[(t+R<<2)+g>>2]+D[(N+R<<2)+g>>2]|0)-D[(R+G<<2)+g>>2],e=e+2|0,(0|Y)!=(0|(f=f+2|0)););K&&(D[r+(e<<2)>>2]=(D[(e+t<<2)+g>>2]+D[(e+N<<2)+g>>2]|0)-D[(e+G<<2)+g>>2])}if(r=4,4==(0|(k=k+1|0)))break o}}a:if(1&n){if(f=-1,-1==(0|(C=((e=C+1|0)>>>0)%3|0?e:C-2|0)))break a;if(f=-1,-1==(0|(C=D[c+(C<<2)>>2])))break a;f=((r=C+1|0)>>>0)%3|0?r:C-2|0}else{if((C>>>0)%3|0)e=C-1|0;else if(f=-1,-1==(0|(e=C+2|0)))break a;f=-1,-1!=(0|(C=D[c+(e<<2)>>2]))&&(f=C-1|0,(C>>>0)%3|0||(f=C+2|0))}a:if((0|B)!=(0|(C=f))){if(!(1&(1^n)|-1!=(0|C))){if(!J)break a;if(-1==(0|(C=D[y>>2])))break a;n=0,C=(C>>>0)%3|0?C-1|0:C+2|0}if(-1!=(0|C))continue}break}if((0|(r=k))<=0)break i}for(Q&&bI(D[E>>2],0,p),R=((C=r-1|0)<<2)+i|0,f=C=s(C,12)+A|0,J=D[C- -64>>2],G=0,n=0,C=0;;){if(D[R>>2]=(B=D[R>>2])+1,B>>>0>=J>>>0)break I;if(!(D[D[f+60>>2]+(B>>>3&536870908)>>2]>>>B&1)&&(C=C+1|0,Q)){if(k=D[E>>2],c=D[(E+16|0)+s(n,12)>>2],t=0,e=0,B=0,h>>>0>=3)for(;D[(y=(N=e<<2)+k|0)>>2]=D[y>>2]+D[N+c>>2],D[(w=(y=4|N)+k|0)>>2]=D[w>>2]+D[c+y>>2],D[(w=(y=8|N)+k|0)>>2]=D[w>>2]+D[c+y>>2],D[(y=(N|=12)+k|0)>>2]=D[y>>2]+D[N+c>>2],e=e+4|0,(0|u)!=(0|(B=B+4|0)););if(M)for(;D[(N=(B=e<<2)+k|0)>>2]=D[N>>2]+D[B+c>>2],e=e+1|0,(0|M)!=(0|(t=t+1|0)););}if((0|(n=n+1|0))==(0|r))break}if(B=n=s(Q,F),!C)break E;if(!Q)break C;if(B=D[E>>2],e=0,r=0,h)break B;break Q}B=s(Q,F)}if(D[A+8>>2]<=0)break g;for(n=(s(F-1|0,Q)<<2)+g|0,k=D[A+32>>2],e=0;(0|(r=D[(C=e<<2)+n>>2]))>(0|(t=D[A+16>>2]))?D[C+k>>2]=t:D[(C=C+k|0)>>2]=(0|(t=D[A+12>>2]))>(0|r)?t:r,(0|(e=e+1|0))<(0|(r=D[A+8>>2])););if(C=0,(0|r)<=0)break g;for(e=(B<<=2)+g|0,n=I+B|0;;){D[(B=(r=C<<2)+e|0)>>2]=r=D[r+n>>2]+D[r+k>>2]|0;E:{if((0|r)>D[A+16>>2])f=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break E;f=r+D[A+20>>2]|0}D[B>>2]=f}if(!((0|(C=C+1|0))<D[A+8>>2]))break}break g}sQ(),U()}for(;D[(t=(k=e<<2)+B|0)>>2]=D[t>>2]/(0|C),D[(k=B+(4|k)|0)>>2]=D[k>>2]/(0|C),e=e+2|0,(0|Y)!=(0|(r=r+2|0)););}K&&(D[(B=B+(e<<2)|0)>>2]=D[B>>2]/(0|C))}if(!(D[A+8>>2]<=0)){for(k=D[A+32>>2],e=0;(0|(B=D[(C=e<<2)+b>>2]))>(0|(r=D[A+16>>2]))?D[C+k>>2]=r:D[(C=C+k|0)>>2]=(0|(r=D[A+12>>2]))>(0|B)?r:B,(0|(e=e+1|0))<(0|(B=D[A+8>>2])););if(C=0,!((0|B)<=0))for(e=(B=n<<2)+g|0,n=I+B|0;;){D[(B=(r=C<<2)+e|0)>>2]=r=D[r+n>>2]+D[r+k>>2]|0;C:{if((0|r)>D[A+16>>2])f=r-D[A+20>>2]|0;else{if((0|r)>=D[A+12>>2])break C;f=r+D[A+20>>2]|0}D[B>>2]=f}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}}if(G=1,(0|l)==(0|(F=F+1|0)))break}return(A=D[E>>2])&&sA(A),sA(i),(A=D[E+52>>2])&&(D[E+56>>2]=A,sA(A)),(A=D[E+40>>2])&&(D[E+44>>2]=A,sA(A)),(A=D[E+28>>2])&&(D[E+32>>2]=A,sA(A)),(A=D[E+16>>2])&&(D[E+20>>2]=A,sA(A)),d=E- -64|0,0|G}iQ(),U()},function(A){var I=0;return D[(A|=0)>>2]=5844,(I=D[A+76>>2])&&sA(I),I=D[A+68>>2],D[A+68>>2]=0,I&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=5844,(I=D[A+76>>2])&&sA(I),I=D[A+68>>2],D[A+68>>2]=0,I&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},AQ,NC,EQ,OC,nC,pA,function(A,I,g,C,Q,E){A|=0,I|=0,g|=0,C|=0,Q|=0,E|=0;var i=0,o=0,a=F(0),r=0,f=F(0),k=0,N=F(0),R=F(0),y=F(0),G=0,w=F(0),h=F(0),J=F(0),S=0,Y=F(0),K=F(0),M=F(0),l=F(0),L=F(0),u=F(0),p=0,H=F(0),q=F(0);D[A+64>>2]=E,D[A+72>>2]=Q,E=DC((1073741823&Q)!=(0|Q)?-1:Q<<2),C=D[A+68>>2],D[A+68>>2]=E,C&&sA(C),D[A+8>>2]=Q,(C=D[A+36>>2]-(i=D[(E=A+32|0)>>2])>>2)>>>0<Q>>>0?$I(E,Q-C|0):C>>>0<=Q>>>0||(D[A+36>>2]=i+(Q<<2));A:if(!((0|(C=(i=D[(C=D[A+56>>2])+4>>2])-(E=D[C>>2])|0))<=0)){if((0|E)!=(0|i))for(p=(C=C>>>2|0)>>>0>1?C:1;;){if(f=F(0),d=i=d-48|0,o=-1,-1==(0|(C=D[(k<<2)+E>>2]))||(r=D[A+48>>2],-1!=(0|(E=((E=C+1|0)>>>0)%3|0?E:C-2|0))&&(o=D[D[r>>2]+(E<<2)>>2]),E=-1,-1!=(0|(C=C+((C>>>0)%3|0?-1:2)|0))&&(E=D[D[r>>2]+(C<<2)>>2]),(C=D[(C=D[A+52>>2])+4>>2]-(r=D[C>>2])>>2)>>>0<=o>>>0|C>>>0<=E>>>0))sQ(),U();else{C=D[r+(o<<2)>>2];I:if((0|(r=D[r+(E<<2)>>2]))>=(0|k)|(0|C)>=(0|k)){if((0|C)<(0|k))C=s(C,E=D[A+72>>2]);else{if(E=0,(0|k)<=0){if(D[A+72>>2]<=0)break I;for(C=D[A+68>>2];D[C+(E<<2)>>2]=0,(0|(E=E+1|0))<D[A+72>>2];);break I}C=s(E=D[A+72>>2],k-1|0)}if(!((0|E)<=0))for(o=D[A+68>>2],E=0;D[o+(E<<2)>>2]=D[(C+E<<2)+g>>2],(0|(E=E+1|0))<D[A+72>>2];);}else{if(o=(s(E=D[A+72>>2],r)<<2)+g|0,N=F(D[o+4>>2]),E=(s(C,E)<<2)+g|0,w=F(D[E+4>>2]),!((Y=F(D[o>>2]))!=(l=F(D[E>>2]))|N!=w)){if(C=D[A+68>>2],E=F(n(N))<F(2147483648)?~~N:-2147483648,D[C+4>>2]=E,F(n(Y))<F(2147483648)){D[C>>2]=~~Y;break I}D[C>>2]=-2147483648;break I}E=D[D[A+64>>2]+(k<<2)>>2],D[i+40>>2]=0,D[i+32>>2]=0,D[i+36>>2]=0,e[(o=D[A+60>>2])+84|0]||(E=D[D[o+68>>2]+(E<<2)>>2]),v(o,E,B[o+24|0],i+32|0),E=D[D[A+64>>2]+(C<<2)>>2],D[i+24>>2]=0,D[i+16>>2]=0,D[i+20>>2]=0,e[(C=D[A+60>>2])+84|0]||(E=D[D[C+68>>2]+(E<<2)>>2]),v(C,E,B[C+24|0],i+16|0),E=D[D[A+64>>2]+(r<<2)>>2],D[i+8>>2]=0,D[i>>2]=0,D[i+4>>2]=0,e[(C=D[A+60>>2])+84|0]||(E=D[D[C+68>>2]+(E<<2)>>2]),v(C,E,B[C+24|0],i),a=F(t[i+8>>2]-(h=t[i+24>>2])),K=F(t[i+4>>2]-(J=t[i+20>>2])),M=F(t[i>>2]-(u=t[i+16>>2])),L=F(F(a*a)+F(F(K*K)+F(F(M*M)+F(0)))),R=t[i+40>>2],H=t[i+36>>2],q=t[i+32>>2],D[A+88>>2]>=258&&(y=F(0),!(L>F(0)))||(R=F(R-h),h=F(H-J),J=F(q-u),f=F(F(F(a*R)+F(F(K*h)+F(F(M*J)+F(0))))/L),a=F(R-F(a*f)),R=F(a*a),a=F(h-F(K*f)),y=F(a*a),a=F(J-F(M*f)),y=F(b(F(F(R+F(y+F(F(a*a)+F(0))))/L)))),R=y,E=D[D[A+76>>2]+((C=D[A+80>>2]-1|0)>>>3&536870908)>>2],D[A+80>>2]=C,a=F(N-w),y=F(F(a*f)+w),w=F(Y-l),N=F(w*R),N=F(y+((C=E>>>C&1)?N:F(-N))),y=F(F(w*f)+l),f=F(a*R),(f=F(y+(C?F(-f):f)))==f?(E=D[A+68>>2],S=c(+f+.5),C=n(S)<2147483648?~~S:-2147483648,D[E>>2]=C):D[(E=D[A+68>>2])>>2]=-2147483648,S=c(+N+.5),C=n(S)<2147483648?~~S:-2147483648,D[E+4>>2]=N!=N?-2147483648:C}d=i+48|0}if(!(D[A+8>>2]<=0)){for(o=D[A+32>>2],r=D[A+68>>2],E=0;(0|(i=D[(C=E<<2)+r>>2]))>(0|(G=D[A+16>>2]))?D[C+o>>2]=G:D[(C=C+o|0)>>2]=(0|(G=D[A+12>>2]))>(0|i)?G:i,(0|(E=E+1|0))<(0|(i=D[A+8>>2])););if(C=0,!((0|i)<=0))for(r=(E=s(Q,k)<<2)+g|0,G=I+E|0;;){D[(E=(i=C<<2)+r|0)>>2]=i=D[i+G>>2]+D[i+o>>2]|0;I:{if((0|i)>D[A+16>>2])i=i-D[A+20>>2]|0;else{if((0|i)>=D[A+12>>2])break I;i=i+D[A+20>>2]|0}D[E>>2]=i}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}if((0|p)==(0|(k=k+1|0)))break A;if(!(D[(C=D[A+56>>2])+4>>2]-(E=D[C>>2])>>2>>>0>k>>>0))break}sQ(),U()}return 1},function(A){var I=0;return D[(A|=0)>>2]=6060,(I=D[A+76>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I=0;D[(A|=0)>>2]=6060,(I=D[A+76>>2])&&sA(I),D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},QQ,NC,EQ,OC,nC,WA,function(A,I,g,C,Q,E){A|=0,I|=0,g|=0,C|=0,E|=0;var i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,p=0,H=0,q=0,W=0,V=0,_=0,T=0,m=0,Z=0,x=0,X=0,j=0,O=0,v=0;if(2==(0|(Q|=0))){D[A+8>>2]=2,D[A- -64>>2]=E,(i=(E=D[A+36>>2]-(Q=D[(C=A+32|0)>>2])|0)>>2)>>>0<=1?$I(C,2-i|0):8!=(0|E)&&(D[A+36>>2]=Q+8);A:if((0|(E=(Q=D[(C=D[A+56>>2])+4>>2])-(C=D[C>>2])|0))<=0)E=0;else{if((0|C)!=(0|Q))for(t=A+60|0,j=(0|(p=E>>2))>1?p:1,E=1;;){if(d=a=d-80|0,Q=-1,-1==(0|(i=D[(F<<2)+C>>2]))||(o=D[t+32>>2],-1!=(0|(C=((C=i+1|0)>>>0)%3|0?C:i-2|0))&&(Q=D[D[o>>2]+(C<<2)>>2]),C=-1,-1!=(0|(i=i+((i>>>0)%3|0?-1:2)|0))&&(C=D[D[o>>2]+(i<<2)>>2]),(o=D[(o=D[t+36>>2])+4>>2]-(i=D[o>>2])>>2)>>>0<=Q>>>0|C>>>0>=o>>>0))sQ(),U();else{o=D[i+(Q<<2)>>2];I:{g:{C:{Q:{B:{if(!((0|(i=D[i+(C<<2)>>2]))>=(0|F)|(0|o)>=(0|F))){if(!((0|(G=D[(C=(i<<3)+g|0)>>2]))!=(0|(M=D[(Q=(o<<3)+g|0)>>2]))|(0|(R=D[Q+4>>2]))!=(0|(b=D[C+4>>2])))){D[t+8>>2]=M,D[t+12>>2]=R;break B}if(C=D[D[t+4>>2]+(F<<2)>>2],D[a+72>>2]=0,D[a+76>>2]=0,D[(Q=a- -64|0)>>2]=0,D[Q+4>>2]=0,D[a+56>>2]=0,D[a+60>>2]=0,e[(Q=D[t>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),BA(Q,C,B[Q+24|0],a+56|0),C=D[D[t+4>>2]+(o<<2)>>2],D[a+48>>2]=0,D[a+52>>2]=0,D[a+40>>2]=0,D[a+44>>2]=0,D[a+32>>2]=0,D[a+36>>2]=0,e[(Q=D[t>>2])+84|0]||(C=D[D[Q+68>>2]+(C<<2)>>2]),BA(Q,C,B[Q+24|0],a+32|0),Q=D[D[t+4>>2]+(i<<2)>>2],D[a+24>>2]=0,D[a+28>>2]=0,D[a+16>>2]=0,D[a+20>>2]=0,D[a+8>>2]=0,D[a+12>>2]=0,e[(C=D[t>>2])+84|0]||(Q=D[D[C+68>>2]+(Q<<2)>>2]),BA(C,Q,B[C+24|0],a+8|0),C=mg(N=(C=D[a+16>>2])-(Q=h=D[a+40>>2])|0,f=D[a+20>>2]-((H=D[a+44>>2])+(C>>>0<Q>>>0)|0)|0,N,f),Q=u,s=C,i=mg(c=(C=D[a+8>>2])-(i=l=D[a+32>>2])|0,r=D[a+12>>2]-((q=D[a+36>>2])+(C>>>0<i>>>0)|0)|0,c,r),Q=u+Q|0,Q=(C=s+i|0)>>>0<i>>>0?Q+1|0:Q,s=C,n=mg(y=(C=D[a+24>>2])-(i=L=D[a+48>>2])|0,k=D[a+28>>2]-((W=D[a+52>>2])+(C>>>0<i>>>0)|0)|0,y,k),i=u+Q|0,w=C=s+n|0,C|(n=C>>>0<n>>>0?i+1|0:i)){if(C=mg((C=_=D[a+64>>2])-h|0,(T=D[a+68>>2])-((C>>>0<h>>>0)+H|0)|0,N,f),Q=u,C=(i=C)+(o=mg((C=m=D[a+56>>2])-l|0,(Z=D[a+60>>2])-((C>>>0<l>>>0)+q|0)|0,c,r))|0,i=u+Q|0,i=C>>>0<o>>>0?i+1|0:i,C=(Q=C)+(o=mg((C=x=D[a+72>>2])-L|0,(X=D[a+76>>2])-((C>>>0<L>>>0)+W|0)|0,y,k))|0,Q=u+i|0,S=C,J=C>>>0<o>>>0?Q+1|0:Q,i=(C=k>>31)+k|0,o=(Q=C+y|0)^C,V=C^=i=Q>>>0<C>>>0?i+1|0:i,Q=(C=f>>31)+f|0,Y=(i=C+N|0)^C,s=C^=i>>>0<C>>>0?Q+1|0:Q,Q=0,i=(C=r>>31)+r|0,i=(K=C+c|0)>>>0<C>>>0?i+1|0:i,K^=C,(i=vA(-1,2147483647,(i=(0|V)==(0|(C=(i=(0|s)==(0|(C^=i))&Y>>>0>K>>>0|C>>>0<s>>>0)?s:C))&o>>>0>(Y=i?Y:K)>>>0|C>>>0<V>>>0)?o:Y,i?V:C)>>>0<S>>>0)&(0|(C=u))<=(0|J)|(0|C)<(0|J))break I;if(o=1,C=0,Q=_,N=_g(mg(N,f,S,J),u,w,n),i=u+H|0,i=T-((Q>>>0<(f=N+h|0)>>>0)+(i=f>>>0<N>>>0?i+1|0:i)|0)|0,i=mg(Q=Q-f|0,i,Q,i),N=u,Q=m,s=i,r=_g(mg(c,r,S,J),u,w,n),i=u+q|0,i=Z-((Q>>>0<(f=r+l|0)>>>0)+(i=r>>>0>f>>>0?i+1|0:i)|0)|0,f=mg(Q=Q-f|0,i,Q,i),Q=u+N|0,f=Q=(i=s+f|0)>>>0<f>>>0?Q+1|0:Q,Q=x,s=i,k=_g(mg(y,k,S,J),u,w,n),i=u+W|0,i=X-((Q>>>0<(r=k+L|0)>>>0)+(i=r>>>0<k>>>0?i+1|0:i)|0)|0,r=mg(Q=Q-r|0,i,Q,i),i=u+f|0,f=mg(Q=s+r|0,Q>>>0<r>>>0?i+1|0:i,w,n),r=Q=u,!Q&f>>>0<=1)break Q;for(k=f,Q=r;i=C<<1|o>>>31,o<<=1,C=i,N=!Q&k>>>0>7|0!=(0|Q),k=(3&Q)<<30|k>>>2,Q=Q>>>2|0,N;);break C}}if((0|o)<(0|F))C=o<<1;else{if((0|F)<=0){D[t+8>>2]=0,D[t+12>>2]=0;break B}C=(F<<1)-2|0}D[t+8>>2]=D[(C=(C<<2)+g|0)>>2],D[t+12>>2]=D[C+4>>2]}Q=1;break I}if(C=r,(o=f)-1|0)break g}for(;i=vA(f,r,o,C)+o|0,Q=C+u|0,Q=mg(o=(1&(Q=i>>>0<o>>>0?Q+1|0:Q))<<31|i>>>1,C=Q>>>1|0,o,C),(0|r)==(0|(i=u))&Q>>>0>f>>>0|i>>>0>r>>>0;);}(f=D[t+20>>2])&&(k=D[D[t+16>>2]+((Q=f-1|0)>>>3&536870908)>>2],D[t+20>>2]=Q,i=mg(S,J,N=b-(i=R)|0,c=(b>>31)-((r=i>>31)+(i>>>0>b>>>0)|0)|0),y=u,r=(R=mg(R,r,w,n))+i|0,i=u+y|0,i=r>>>0<R>>>0?i+1|0:i,s=r,G=r=mg(o,C,y=G-(r=M)|0,b=(G>>31)-((R=r>>31)+(r>>>0>G>>>0)|0)|0),k=s+(h=(Q=r=k>>>Q&1)?0-G|0:G)|0,s=i,i=u,Q=s+(Q?0-(i+(0!=(0|G))|0)|0:i)|0,O=t,v=_g(k,k>>>0<h>>>0?Q+1|0:Q,w,n),D[O+12>>2]=v,Q=mg(y,b,S,J),i=u,k=mg(w,n,M,R),i=u+i|0,i=(Q=k+Q|0)>>>0<k>>>0?i+1|0:i,C=mg(o,C,N,c),o=(k=r?C:0-C|0)+Q|0,Q=u,Q=(r?Q:0-((0!=(0|C))+Q|0)|0)+i|0,O=t,v=_g(o,o>>>0<k>>>0?Q+1|0:Q,w,n),D[O+8>>2]=v),Q=0!=(0|f)}d=a+80|0}if(!Q)break A;if(!(D[A+8>>2]<=0)){for(i=D[A+32>>2],C=0;(0|(E=D[68+((Q=C<<2)+A|0)>>2]))>(0|(o=D[A+16>>2]))?D[Q+i>>2]=o:D[(Q=Q+i|0)>>2]=(0|(o=D[A+12>>2]))>(0|E)?o:E,(0|(C=C+1|0))<(0|(E=D[A+8>>2])););if(Q=0,!((0|E)<=0))for(o=(C=F<<3)+g|0,f=I+C|0;;){D[(C=(E=Q<<2)+o|0)>>2]=E=D[E+f>>2]+D[E+i>>2]|0;I:{if((0|E)>D[A+16>>2])E=E-D[A+20>>2]|0;else{if((0|E)>=D[A+12>>2])break I;E=E+D[A+20>>2]|0}D[C>>2]=E}if(!((0|(Q=Q+1|0))<D[A+8>>2]))break}}if(E=(0|p)>(0|(F=F+1|0)),(0|F)==(0|j))break A;if(!(D[(Q=D[A+56>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>F>>>0))break}sQ(),U()}A=1^E}else A=0;return 1&A},function(A){var I;return D[(A|=0)>>2]=6284,D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),0|A},function(A){var I;D[(A|=0)>>2]=6284,D[A>>2]=3300,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),sA(A)},BQ,gC,EQ,OC,RC,QI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,t=0;d=E=d-32|0,D[68+(A|=0)>>2]=B|=0,C=D[(Q=D[A+56>>2])>>2],B=D[Q+4>>2],D[E+24>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0;A:if(!((0|(B=B-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+112|0,k=A+60|0,t=(Q=B>>>2|0)>>>0>1?Q:1;;){if(tA(k,D[(r<<2)+C>>2],E+16|0),o=(a=D[E+24>>2])>>31,i=(o^=o+a)+(((C=(Q=D[E+20>>2])>>31)^C+Q)+((i=(B=D[E+16>>2])>>31)^B+i)|0)|0,C=0,(C=i>>>0<o>>>0?1:C)|i?(B=_g(mg(o=D[A+108>>2],e=o>>31,B,B>>31),u,i,C),D[E+16>>2]=B,C=_g(mg(o,e,Q,Q>>31),u,i,C),D[E+20>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=B>>31)+B^C)|0,D[E+24>>2]=(0|a)>=0?o-C:C-o):D[E+16>>2]=D[A+108>>2],C=ug(f),B=D[E+16>>2],C?(D[E+24>>2]=0-D[E+24>>2],D[E+20>>2]=Q=0-D[E+20>>2]|0,D[E+16>>2]=B=0-B|0):Q=D[E+20>>2],(0|B)>=0?(B=(C=D[A+108>>2])+D[E+24>>2]|0,C=C+Q|0):((0|Q)<0?(C=(B=D[E+24>>2])>>31,C^=C+B):C=D[A+100>>2]-((C=(B=D[E+24>>2])>>31)^C+B)|0,B=(0|B)<0?(B=Q)+(Q>>=31)^Q:D[A+100>>2]-((B=Q)+(Q>>=31)^Q)|0),Q=D[A+100>>2],C|B?(0|Q)!=(0|B)|C?B|(i=(0|C)!=(0|Q))?C||(0|(a=D[A+108>>2]))>=(0|B)?i||(0|(i=D[A+108>>2]))<=(0|B)?(0|Q)!=(0|B)||(0|(Q=D[A+108>>2]))<=(0|C)?B||(B=0,(0|(Q=D[A+108>>2]))>=(0|C)||(C=(Q<<1)-C|0)):C=(Q<<1)-C|0:B=(i<<1)-B|0:(B=(a<<1)-B|0,C=0):B=C:C=B:C=B=Q,D[E+12>>2]=B,D[E+8>>2]=C,!(D[A+8>>2]<=0)){for(i=D[A+32>>2],B=0;(0|(Q=D[A+16>>2]))<(0|C)?D[i+(B<<2)>>2]=Q:D[(Q=i+(B<<2)|0)>>2]=(0|(a=D[A+12>>2]))>(0|C)?a:C,(0|(B=B+1|0))<(0|(Q=D[A+8>>2]));)C=D[(E+8|0)+(B<<2)>>2];if(C=0,!((0|Q)<=0))for(a=(Q=r<<3)+g|0,o=I+Q|0;;){D[(Q=(B=C<<2)+a|0)>>2]=B=D[B+o>>2]+D[B+i>>2]|0;I:{if((0|B)>D[A+16>>2])B=B-D[A+20>>2]|0;else{if((0|B)>=D[A+12>>2])break I;B=B+D[A+20>>2]|0}D[Q>>2]=B}if(!((0|(C=C+1|0))<D[A+8>>2]))break}}if((0|t)==(0|(r=r+1|0)))break A;if(!(D[(Q=D[A+56>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>r>>>0))break}sQ(),U()}return d=E+32|0,1},$C,oQ,fC,_C,tA,rQ,wC,IQ,EQ,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,t=0,N=0;if(D[8+(A|=0)>>2]=Q|=0,(o=D[A+36>>2]-(a=D[(B=A+32|0)>>2])>>2)>>>0<Q>>>0?($I(B,Q-o|0),a=D[B>>2],B=D[A+8>>2]):(Q>>>0<o>>>0&&(D[A+36>>2]=(Q<<2)+a),B=Q),o=0,E=bI(DC(i=(1073741823&Q)!=(0|Q)?-1:Q<<2),0,i),!((0|B)<=0)){for(;(0|(i=D[(B=o<<2)+E>>2]))>(0|(r=D[A+16>>2]))?D[B+a>>2]=r:D[(B=B+a|0)>>2]=(0|(r=D[A+12>>2]))>(0|i)?r:i,(0|(B=D[A+8>>2]))>(0|(o=o+1|0)););if(!((0|B)<=0))for(o=0;;){D[(B=(i=o<<2)+g|0)>>2]=i=D[I+i>>2]+D[i+a>>2]|0;A:{if((0|i)>D[A+16>>2])i=i-D[A+20>>2]|0;else{if((0|i)>=D[A+12>>2])break A;i=i+D[A+20>>2]|0}D[B>>2]=i}if(!((0|(B=D[A+8>>2]))>(0|(o=o+1|0))))break}}if(!((0|C)<=(0|Q)|(0|B)<=0))for(t=0-Q<<2,a=Q;;){if(!((0|B)<=0)){for(N=(k=(f=a<<2)+g|0)+t|0,r=D[A+32>>2],o=0;(0|(i=D[(B=o<<2)+N>>2]))>(0|(e=D[A+16>>2]))?D[B+r>>2]=e:D[(B=B+r|0)>>2]=(0|(e=D[A+12>>2]))>(0|i)?e:i,(0|(B=D[A+8>>2]))>(0|(o=o+1|0)););if(o=0,!((0|B)<=0))for(f=I+f|0;;){D[(B=(i=o<<2)+k|0)>>2]=i=D[i+f>>2]+D[i+r>>2]|0;A:{if((0|i)>D[A+16>>2])i=i-D[A+20>>2]|0;else{if((0|i)>=D[A+12>>2])break A;i=i+D[A+20>>2]|0}D[B>>2]=i}if(!((0|(B=D[A+8>>2]))>(0|(o=o+1|0))))break}}if(!((0|(a=Q+a|0))<(0|C)))break}return sA(E),1},CC,EC,function(A,I,g){g|=0;var C=0;return D[4+(A|=0)>>2]=I|=0,I=D[D[D[I+4>>2]+8>>2]+(g<<2)>>2],D[A+12>>2]=g,D[A+8>>2]=I,3==e[(A=D[A+8>>2])+24|0]&&(C=9==D[A+28>>2]),0|C},function(A,I,g){return I|=0,g|=0,e[D[4+(A|=0)>>2]+36|0]>=2&&(I=0,!hg(A+24|0,VI(A),g))||(I=dg(A+24|0,D[A+16>>2])),0|I},function(A,I,g){I|=0,g|=0;var C=0;return e[D[4+(A|=0)>>2]+36|0]<=1&&(C=0,!hg(A+24|0,D[A+8>>2],g))||(C=bA(A,I,g)),0|C},function(A,I,g){A|=0,I|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=0;d=C=d-32|0;A:{I:switch((g|=0)-2|0){case 0:if(g=D[A+4>>2],E=D[A+12>>2],D[C+24>>2]=-1,D[C+16>>2]=-1,D[C+20>>2]=1065353216,D[C+8>>2]=-1,D[C+12>>2]=-1,-2==(0|I))break A;if(r=D[D[D[g+4>>2]+8>>2]+(E<<2)>>2],1==(0|RQ[D[D[g>>2]+8>>2]](g))){a=D[D[D[g+4>>2]+8>>2]+(E<<2)>>2];g:if(!(1!=(0|RQ[D[D[g>>2]+8>>2]](g))|I-1>>>0>5||!(o=0|RQ[D[D[g>>2]+36>>2]](g))|!(A=0|RQ[D[D[g>>2]+44>>2]](g,E))))if(i=A+12|0,E=0|RQ[D[D[g>>2]+40>>2]](g,E),g=D[g+44>>2],E){if(6!=(0|I))break g;Q=DC(112),D[Q+4>>2]=a,I=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=I,I=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=I,D[Q+24>>2]=D[C+24>>2],D[Q+40>>2]=A,D[Q+36>>2]=i,D[Q+32>>2]=E,D[Q+28>>2]=g,D[Q+68>>2]=A,D[Q- -64>>2]=i,D[Q+60>>2]=E,D[Q+56>>2]=g,D[Q+48>>2]=0,D[Q+52>>2]=0,D[Q>>2]=7172,D[Q+88>>2]=1065353216,D[Q+92>>2]=-1,D[Q+80>>2]=-1,D[Q+84>>2]=-1,D[Q+72>>2]=1,D[Q+76>>2]=-1,D[Q+44>>2]=7696,D[(A=Q+96|0)>>2]=0,D[A+4>>2]=0,B[A+5|0]=0,B[A+6|0]=0,B[A+7|0]=0,B[A+8|0]=0,B[A+9|0]=0,B[A+10|0]=0,B[A+11|0]=0,B[A+12|0]=0}else 6==(0|I)&&(Q=DC(112),D[Q+4>>2]=a,I=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=I,I=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=I,D[Q+24>>2]=D[C+24>>2],D[Q+40>>2]=A,D[Q+36>>2]=i,D[Q+32>>2]=o,D[Q+28>>2]=g,D[Q+68>>2]=A,D[Q- -64>>2]=i,D[Q+60>>2]=o,D[Q+56>>2]=g,D[Q+48>>2]=0,D[Q+52>>2]=0,D[Q>>2]=8108,D[Q+88>>2]=1065353216,D[Q+92>>2]=-1,D[Q+80>>2]=-1,D[Q+84>>2]=-1,D[Q+72>>2]=1,D[Q+76>>2]=-1,D[Q+44>>2]=8500,D[(A=Q+96|0)>>2]=0,D[A+4>>2]=0,B[A+5|0]=0,B[A+6|0]=0,B[A+7|0]=0,B[A+8|0]=0,B[A+9|0]=0,B[A+10|0]=0,B[A+11|0]=0,B[A+12|0]=0);if(Q)break A}Q=DC(28),D[Q+4>>2]=r,A=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=A,A=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=A,D[Q+24>>2]=D[C+24>>2],D[Q>>2]=8888;break A;case 1:break I;default:break A}if(g=D[A+4>>2],E=D[A+12>>2],D[C+24>>2]=-1,D[C+16>>2]=-1,D[C+20>>2]=1065353216,D[C+8>>2]=-1,D[C+12>>2]=-1,-2!=(0|I)){if(r=D[D[D[g+4>>2]+8>>2]+(E<<2)>>2],1==(0|RQ[D[D[g>>2]+8>>2]](g))){a=D[D[D[g+4>>2]+8>>2]+(E<<2)>>2];I:if(!(1!=(0|RQ[D[D[g>>2]+8>>2]](g))|I-1>>>0>5||!(o=0|RQ[D[D[g>>2]+36>>2]](g))|!(A=0|RQ[D[D[g>>2]+44>>2]](g,E))))if(i=A+12|0,E=0|RQ[D[D[g>>2]+40>>2]](g,E),g=D[g+44>>2],E){if(6!=(0|I))break I;Q=DC(112),D[Q+4>>2]=a,I=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=I,I=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=I,D[Q+24>>2]=D[C+24>>2],D[Q+40>>2]=A,D[Q+36>>2]=i,D[Q+32>>2]=E,D[Q+28>>2]=g,D[Q+68>>2]=A,D[Q- -64>>2]=i,D[Q+60>>2]=E,D[Q+56>>2]=g,D[Q+48>>2]=0,D[Q+52>>2]=0,D[Q>>2]=9056,D[Q+88>>2]=1065353216,D[Q+92>>2]=-1,D[Q+80>>2]=-1,D[Q+84>>2]=-1,D[Q+72>>2]=1,D[Q+76>>2]=-1,D[Q+44>>2]=9620,D[(A=Q+96|0)>>2]=0,D[A+4>>2]=0,B[A+5|0]=0,B[A+6|0]=0,B[A+7|0]=0,B[A+8|0]=0,B[A+9|0]=0,B[A+10|0]=0,B[A+11|0]=0,B[A+12|0]=0}else 6==(0|I)&&(Q=DC(112),D[Q+4>>2]=a,I=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=I,I=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=I,D[Q+24>>2]=D[C+24>>2],D[Q+40>>2]=A,D[Q+36>>2]=i,D[Q+32>>2]=o,D[Q+28>>2]=g,D[Q+68>>2]=A,D[Q- -64>>2]=i,D[Q+60>>2]=o,D[Q+56>>2]=g,D[Q+48>>2]=0,D[Q+52>>2]=0,D[Q>>2]=10060,D[Q+88>>2]=1065353216,D[Q+92>>2]=-1,D[Q+80>>2]=-1,D[Q+84>>2]=-1,D[Q+72>>2]=1,D[Q+76>>2]=-1,D[Q+44>>2]=10480,D[(A=Q+96|0)>>2]=0,D[A+4>>2]=0,B[A+5|0]=0,B[A+6|0]=0,B[A+7|0]=0,B[A+8|0]=0,B[A+9|0]=0,B[A+10|0]=0,B[A+11|0]=0,B[A+12|0]=0);if(Q)break A}Q=DC(28),D[Q+4>>2]=r,A=D[C+12>>2],D[Q+8>>2]=D[C+8>>2],D[Q+12>>2]=A,A=D[C+20>>2],D[Q+16>>2]=D[C+16>>2],D[Q+20>>2]=A,D[Q+24>>2]=D[C+24>>2],D[Q>>2]=10892}}return d=C+32|0,0|Q},CQ,function(A,I){return 0|DI(24+(A|=0)|0,VI(A),D[A+8>>2])},function(A){return D[(A|=0)>>2]=7172,0|A},function(A){D[(A|=0)>>2]=7172,sA(A)},BQ,ZC,QC,EQ,OC,GC,EQ,CQ,NI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,N=0,s=0;d=E=d-48|0,(C=D[8+(A|=0)>>2])-31>>>0>=4294967267&&(D[A+76>>2]=C,D[A+84>>2]=C=-2-(Q=-1<<C)|0,D[A+80>>2]=-1^Q,D[A+92>>2]=(0|C)/2,t[A+88>>2]=F(2)/F(0|C)),D[A+52>>2]=B,C=D[(Q=D[A+40>>2])>>2],i=D[Q+4>>2],B=0,D[E+16>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0;A:if(!((0|(i=i-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+8|0,k=A+96|0,N=A+44|0,s=(Q=i>>>2|0)>>>0>1?Q:1;;){if(EA(N,D[(B<<2)+C>>2],E+8|0),a=(r=D[E+16>>2])>>31,o=(a^=a+r)+(((C=(Q=D[E+12>>2])>>31)^C+Q)+((o=(i=D[E+8>>2])>>31)^i+o)|0)|0,C=0,(C=o>>>0<a>>>0?1:C)|o?(i=_g(mg(a=D[A+92>>2],e=a>>31,i,i>>31),u,o,C),D[E+8>>2]=i,C=_g(mg(a,e,Q,Q>>31),u,o,C),D[E+12>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=i>>31)+i^C)|0,D[E+16>>2]=(0|r)>=0?a-C:C-a):D[E+8>>2]=D[A+92>>2],C=ug(k),Q=D[E+8>>2],C?(D[E+16>>2]=0-D[E+16>>2],D[E+12>>2]=i=0-D[E+12>>2]|0,D[E+8>>2]=Q=0-Q|0):i=D[E+12>>2],(0|Q)>=0?(C=(Q=D[A+92>>2])+D[E+16>>2]|0,Q=Q+i|0):((0|i)<0?(Q=(C=D[E+16>>2])>>31,Q^=C+Q):Q=D[A+84>>2]-((Q=(C=D[E+16>>2])>>31)^C+Q)|0,(0|C)<0?(C=i>>31,C^=C+i):C=D[A+84>>2]-((C=i>>31)+i^C)|0),i=D[A+84>>2],C|Q?(0|C)!=(0|i)|Q?C|(o=(0|Q)!=(0|i))?Q||(0|(r=D[A+92>>2]))>=(0|C)?o||(0|(o=D[A+92>>2]))<=(0|C)?(0|C)!=(0|i)||(0|(i=D[A+92>>2]))<=(0|Q)?C||(C=0,(0|(i=D[A+92>>2]))>=(0|Q)||(Q=(i<<1)-Q|0)):Q=(i<<1)-Q|0:C=(o<<1)-C|0:(C=(r<<1)-C|0,Q=0):C=Q:Q=C:Q=C=i,r=D[4+(o=(i=B<<3)+I|0)>>2],D[E+40>>2]=D[o>>2],D[E+44>>2]=r,D[E+28>>2]=C,D[E+24>>2]=Q,$A(E+32|0,f,E+24|0,E+40|0),D[(C=g+i|0)>>2]=D[E+32>>2],D[C+4>>2]=D[E+36>>2],(0|s)==(0|(B=B+1|0)))break A;if(!(D[(Q=D[A+40>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>B>>>0))break}sQ(),U()}return d=E+48|0,1},$C,oQ,fC,_C,EA,function(A){return D[(A|=0)>>2]=8108,0|A},function(A){D[(A|=0)>>2]=8108,sA(A)},BQ,QC,EQ,OC,GC,NI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,N=0,s=0;d=E=d-48|0,(C=D[8+(A|=0)>>2])-31>>>0>=4294967267&&(D[A+76>>2]=C,D[A+84>>2]=C=-2-(Q=-1<<C)|0,D[A+80>>2]=-1^Q,D[A+92>>2]=(0|C)/2,t[A+88>>2]=F(2)/F(0|C)),D[A+52>>2]=B,C=D[(Q=D[A+40>>2])>>2],i=D[Q+4>>2],B=0,D[E+16>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0;A:if(!((0|(i=i-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+8|0,k=A+96|0,N=A+44|0,s=(Q=i>>>2|0)>>>0>1?Q:1;;){if(tA(N,D[(B<<2)+C>>2],E+8|0),a=(r=D[E+16>>2])>>31,o=(a^=a+r)+(((C=(Q=D[E+12>>2])>>31)^C+Q)+((o=(i=D[E+8>>2])>>31)^i+o)|0)|0,C=0,(C=o>>>0<a>>>0?1:C)|o?(i=_g(mg(a=D[A+92>>2],e=a>>31,i,i>>31),u,o,C),D[E+8>>2]=i,C=_g(mg(a,e,Q,Q>>31),u,o,C),D[E+12>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=i>>31)+i^C)|0,D[E+16>>2]=(0|r)>=0?a-C:C-a):D[E+8>>2]=D[A+92>>2],C=ug(k),Q=D[E+8>>2],C?(D[E+16>>2]=0-D[E+16>>2],D[E+12>>2]=i=0-D[E+12>>2]|0,D[E+8>>2]=Q=0-Q|0):i=D[E+12>>2],(0|Q)>=0?(C=(Q=D[A+92>>2])+D[E+16>>2]|0,Q=Q+i|0):((0|i)<0?(Q=(C=D[E+16>>2])>>31,Q^=C+Q):Q=D[A+84>>2]-((Q=(C=D[E+16>>2])>>31)^C+Q)|0,(0|C)<0?(C=i>>31,C^=C+i):C=D[A+84>>2]-((C=i>>31)+i^C)|0),i=D[A+84>>2],C|Q?(0|C)!=(0|i)|Q?C|(o=(0|Q)!=(0|i))?Q||(0|(r=D[A+92>>2]))>=(0|C)?o||(0|(o=D[A+92>>2]))<=(0|C)?(0|C)!=(0|i)||(0|(i=D[A+92>>2]))<=(0|Q)?C||(C=0,(0|(i=D[A+92>>2]))>=(0|Q)||(Q=(i<<1)-Q|0)):Q=(i<<1)-Q|0:C=(o<<1)-C|0:(C=(r<<1)-C|0,Q=0):C=Q:Q=C:Q=C=i,r=D[4+(o=(i=B<<3)+I|0)>>2],D[E+40>>2]=D[o>>2],D[E+44>>2]=r,D[E+28>>2]=C,D[E+24>>2]=Q,$A(E+32|0,f,E+24|0,E+40|0),D[(C=g+i|0)>>2]=D[E+32>>2],D[C+4>>2]=D[E+36>>2],(0|s)==(0|(B=B+1|0)))break A;if(!(D[(Q=D[A+40>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>B>>>0))break}sQ(),U()}return d=E+48|0,1},$C,oQ,fC,_C,tA,$C,oQ,IQ,EQ,IQ,mC,OC,function(A,I){A|=0;var g,C,Q,B=0,E=0,i=0,o=0,a=0;o=B=D[20+(I|=0)>>2],Q=E=(g=D[I+16>>2])+4|0;A:if(!((C=D[I+8>>2])>>>0<E>>>0&(0|(B=E>>>0<4?B+1|0:B))>=(0|(i=D[I+12>>2]))|(0|B)>(0|i))){if(E=e[0|(E=g+D[I>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=Q,D[I+20>>2]=B,f[I+38>>1]<=513){if(B=o,(o=g+8|0)>>>0>C>>>0&(0|(B=o>>>0<8?B+1|0:B))>=(0|i)|(0|B)>(0|i))break A;D[I+16>>2]=o,D[I+20>>2]=B}1&E&&((B=(I=31^R(E))-30|0)>>>0>=4294967267&&(D[A+8>>2]=I+1,D[A+16>>2]=I=-2-(i=-2<<I)|0,D[A+12>>2]=-1^i,D[A+24>>2]=(0|I)/2,t[A+20>>2]=F(2)/F(0|I)),a=B>>>0>4294967266)}return 0|a},function(A,I,g,C,Q,B){A|=0,I|=0,g|=0,C|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0;if(d=B=d-32|0,E=bI(DC(i=(1073741823&(Q|=0))!=(0|Q)?-1:Q<<2),0,i),a=D[(i=E)>>2],i=D[i+4>>2],e=D[I+4>>2],D[B+24>>2]=D[I>>2],D[B+28>>2]=e,D[B+8>>2]=a,D[B+12>>2]=i,$A(B+16|0,a=A+8|0,B+8|0,B+24|0),D[g>>2]=D[B+16>>2],D[g+4>>2]=D[B+20>>2],(0|C)>(0|Q))for(e=0-Q<<2,A=Q;f=D[(r=(i=(o=A<<2)+g|0)+e|0)>>2],r=D[r+4>>2],k=D[4+(o=I+o|0)>>2],D[B+24>>2]=D[o>>2],D[B+28>>2]=k,D[B+8>>2]=f,D[B+12>>2]=r,$A(B+16|0,a,B+8|0,B+24|0),D[i>>2]=D[B+16>>2],D[i+4>>2]=D[B+20>>2],(0|C)>(0|(A=A+Q|0)););return sA(E),d=B+32|0,1},function(A){return D[(A|=0)>>2]=9056,0|A},function(A){D[(A|=0)>>2]=9056,sA(A)},BQ,ZC,QC,EQ,OC,GC,EQ,AQ,sI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,N=0,s=0;d=E=d-48|0,(C=D[8+(A|=0)>>2])-31>>>0>=4294967267&&(D[A+76>>2]=C,D[A+84>>2]=C=-2-(Q=-1<<C)|0,D[A+80>>2]=-1^Q,D[A+92>>2]=(0|C)/2,t[A+88>>2]=F(2)/F(0|C)),D[A+52>>2]=B,C=D[(Q=D[A+40>>2])>>2],i=D[Q+4>>2],B=0,D[E+16>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0;A:if(!((0|(i=i-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+8|0,k=A+96|0,N=A+44|0,s=(Q=i>>>2|0)>>>0>1?Q:1;;){if(EA(N,D[(B<<2)+C>>2],E+8|0),a=(r=D[E+16>>2])>>31,o=(a^=a+r)+(((C=(Q=D[E+12>>2])>>31)^C+Q)+((o=(i=D[E+8>>2])>>31)^i+o)|0)|0,C=0,(C=o>>>0<a>>>0?1:C)|o?(i=_g(mg(a=D[A+92>>2],e=a>>31,i,i>>31),u,o,C),D[E+8>>2]=i,C=_g(mg(a,e,Q,Q>>31),u,o,C),D[E+12>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=i>>31)+i^C)|0,D[E+16>>2]=(0|r)>=0?a-C:C-a):D[E+8>>2]=D[A+92>>2],C=ug(k),Q=D[E+8>>2],C?(D[E+16>>2]=0-D[E+16>>2],D[E+12>>2]=i=0-D[E+12>>2]|0,D[E+8>>2]=Q=0-Q|0):i=D[E+12>>2],(0|Q)>=0?(C=(Q=D[A+92>>2])+D[E+16>>2]|0,Q=Q+i|0):((0|i)<0?(Q=(C=D[E+16>>2])>>31,Q^=C+Q):Q=D[A+84>>2]-((Q=(C=D[E+16>>2])>>31)^C+Q)|0,(0|C)<0?(C=i>>31,C^=C+i):C=D[A+84>>2]-((C=i>>31)+i^C)|0),i=D[A+84>>2],C|Q?(0|C)!=(0|i)|Q?C|(o=(0|Q)!=(0|i))?Q||(0|(r=D[A+92>>2]))>=(0|C)?o||(0|(o=D[A+92>>2]))<=(0|C)?(0|C)!=(0|i)||(0|(i=D[A+92>>2]))<=(0|Q)?C||(C=0,(0|(i=D[A+92>>2]))>=(0|Q)||(Q=(i<<1)-Q|0)):Q=(i<<1)-Q|0:C=(o<<1)-C|0:(C=(r<<1)-C|0,Q=0):C=Q:Q=C:Q=C=i,r=D[4+(o=(i=B<<3)+I|0)>>2],o=D[o>>2],D[E+36>>2]=C,D[E+32>>2]=Q,D[E+24>>2]=o,D[E+28>>2]=r,lA(E+40|0,f,E+32|0,E+24|0),D[(C=g+i|0)>>2]=D[E+40>>2],D[C+4>>2]=D[E+44>>2],(0|s)==(0|(B=B+1|0)))break A;if(!(D[(Q=D[A+40>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>B>>>0))break}sQ(),U()}return d=E+48|0,1},$C,oQ,fC,_C,EA,function(A){return D[(A|=0)>>2]=10060,0|A},function(A){D[(A|=0)>>2]=10060,sA(A)},BQ,QC,EQ,OC,GC,sI,function(A,I,g,C,Q,B){I|=0,g|=0,C|=0,Q|=0,B|=0;var E,i=0,o=0,a=0,r=0,e=0,f=0,k=0,N=0,s=0;d=E=d-48|0,(C=D[8+(A|=0)>>2])-31>>>0>=4294967267&&(D[A+76>>2]=C,D[A+84>>2]=C=-2-(Q=-1<<C)|0,D[A+80>>2]=-1^Q,D[A+92>>2]=(0|C)/2,t[A+88>>2]=F(2)/F(0|C)),D[A+52>>2]=B,C=D[(Q=D[A+40>>2])>>2],i=D[Q+4>>2],B=0,D[E+16>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0;A:if(!((0|(i=i-C|0))<=0)){if((0|(C=D[Q>>2]))!=D[Q+4>>2])for(f=A+8|0,k=A+96|0,N=A+44|0,s=(Q=i>>>2|0)>>>0>1?Q:1;;){if(tA(N,D[(B<<2)+C>>2],E+8|0),a=(r=D[E+16>>2])>>31,o=(a^=a+r)+(((C=(Q=D[E+12>>2])>>31)^C+Q)+((o=(i=D[E+8>>2])>>31)^i+o)|0)|0,C=0,(C=o>>>0<a>>>0?1:C)|o?(i=_g(mg(a=D[A+92>>2],e=a>>31,i,i>>31),u,o,C),D[E+8>>2]=i,C=_g(mg(a,e,Q,Q>>31),u,o,C),D[E+12>>2]=C,C=(Q=(Q=C)+(C>>=31)^C)+((C=i>>31)+i^C)|0,D[E+16>>2]=(0|r)>=0?a-C:C-a):D[E+8>>2]=D[A+92>>2],C=ug(k),Q=D[E+8>>2],C?(D[E+16>>2]=0-D[E+16>>2],D[E+12>>2]=i=0-D[E+12>>2]|0,D[E+8>>2]=Q=0-Q|0):i=D[E+12>>2],(0|Q)>=0?(C=(Q=D[A+92>>2])+D[E+16>>2]|0,Q=Q+i|0):((0|i)<0?(Q=(C=D[E+16>>2])>>31,Q^=C+Q):Q=D[A+84>>2]-((Q=(C=D[E+16>>2])>>31)^C+Q)|0,(0|C)<0?(C=i>>31,C^=C+i):C=D[A+84>>2]-((C=i>>31)+i^C)|0),i=D[A+84>>2],C|Q?(0|C)!=(0|i)|Q?C|(o=(0|Q)!=(0|i))?Q||(0|(r=D[A+92>>2]))>=(0|C)?o||(0|(o=D[A+92>>2]))<=(0|C)?(0|C)!=(0|i)||(0|(i=D[A+92>>2]))<=(0|Q)?C||(C=0,(0|(i=D[A+92>>2]))>=(0|Q)||(Q=(i<<1)-Q|0)):Q=(i<<1)-Q|0:C=(o<<1)-C|0:(C=(r<<1)-C|0,Q=0):C=Q:Q=C:Q=C=i,r=D[4+(o=(i=B<<3)+I|0)>>2],o=D[o>>2],D[E+36>>2]=C,D[E+32>>2]=Q,D[E+24>>2]=o,D[E+28>>2]=r,lA(E+40|0,f,E+32|0,E+24|0),D[(C=g+i|0)>>2]=D[E+40>>2],D[C+4>>2]=D[E+44>>2],(0|s)==(0|(B=B+1|0)))break A;if(!(D[(Q=D[A+40>>2])+4>>2]-(C=D[Q>>2])>>2>>>0>B>>>0))break}sQ(),U()}return d=E+48|0,1},$C,oQ,fC,_C,tA,oQ,IQ,EQ,IQ,mC,OC,function(A,I){A|=0;var g,C,Q,B,E=0,i=0,o=0,a=0;return o=E=D[20+(I|=0)>>2],B=i=(C=D[I+16>>2])+4|0,(Q=D[I+8>>2])>>>0<i>>>0&(0|(E=i>>>0<4?E+1|0:E))>=(0|(g=D[I+12>>2]))|(0|E)>(0|g)||(i=e[0|(i=C+D[I>>2]|0)]|e[i+1|0]<<8|e[i+2|0]<<16|e[i+3|0]<<24,D[I+16>>2]=B,D[I+20>>2]=E,E=o,(o=C+8|0)>>>0>Q>>>0&(0|(E=o>>>0<8?E+1|0:E))>=(0|g)|(0|E)>(0|g)||(D[I+16>>2]=o,D[I+20>>2]=E,1&i&&((I=31^R(i))-30>>>0<4294967267||(a=1,D[A+8>>2]=I+1,D[A+16>>2]=I=-2-(E=-2<<I)|0,D[A+12>>2]=-1^E,D[A+24>>2]=(0|I)/2,t[A+20>>2]=F(2)/F(0|I))))),0|a},function(A,I,g,C,Q,B){A|=0,I|=0,g|=0,C|=0,B|=0;var E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0;if(d=B=d-32|0,i=bI(DC(i=(1073741823&(Q|=0))!=(0|Q)?-1:Q<<2),0,i),E=D[I>>2],o=D[I+4>>2],r=D[i+4>>2],D[B+16>>2]=D[i>>2],D[B+20>>2]=r,D[B+8>>2]=E,D[B+12>>2]=o,lA(B+24|0,o=A+8|0,B+16|0,B+8|0),D[g>>2]=D[B+24>>2],D[g+4>>2]=D[B+28>>2],(0|C)>(0|Q))for(r=0-Q<<2,A=Q;f=D[(a=(E=A<<2)+I|0)>>2],a=D[a+4>>2],k=D[4+(e=(E=g+E|0)+r|0)>>2],D[B+16>>2]=D[e>>2],D[B+20>>2]=k,D[B+8>>2]=f,D[B+12>>2]=a,lA(B+24|0,o,B+16|0,B+8|0),D[E>>2]=D[B+24>>2],D[E+4>>2]=D[B+28>>2],(0|C)>(0|(A=A+Q|0)););return sA(i),d=B+32|0,1},function(A){var I=0;return D[24+(A|=0)>>2]=1140,D[A>>2]=11076,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),D[A>>2]=2476,I=D[A+20>>2],D[A+20>>2]=0,I&&RQ[D[D[I>>2]+4>>2]](I),D[A>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),0|A},function(A){var I=0;D[24+(A|=0)>>2]=1140,D[A>>2]=11076,(I=D[A+32>>2])&&(D[A+36>>2]=I,sA(I)),D[A>>2]=2476,I=D[A+20>>2],D[A+20>>2]=0,I&&RQ[D[D[I>>2]+4>>2]](I),D[A>>2]=2260,I=D[A+16>>2],D[A+16>>2]=0,I&&Wg(I),sA(A)},function(A,I,g){var C;return g|=0,D[4+(A|=0)>>2]=I|=0,C=D[D[D[I+4>>2]+8>>2]+(g<<2)>>2],D[A+12>>2]=g,D[A+8>>2]=C,9==D[D[D[D[I+4>>2]+8>>2]+(g<<2)>>2]+28>>2]|0},function(A,I,g){return I|=0,e[D[4+(A|=0)>>2]+36|0]>=2&&(I=0,!(0|RQ[D[D[A>>2]+52>>2]](A)))||(I=dg(A+24|0,D[A+16>>2])),0|I},function(A,I,g){I|=0,g|=0;var C=0;return e[D[4+(A|=0)>>2]+36|0]<=1&&(C=0,!(0|RQ[D[D[A>>2]+52>>2]](A)))||(C=bA(A,I,g)),0|C},function(A,I){return 0|RQ[D[D[(A|=0)>>2]+56>>2]](A,I|=0)},function(A){return 0|EI(24+(A|=0)|0,VI(A)||D[A+8>>2],D[D[A+4>>2]+32>>2])},function(A,I){return 0|II(24+(A|=0)|0,VI(A),D[A+8>>2])},function(A){var I,g=0,C=0;if(D[(A|=0)>>2]=13312,(g=D[A+20>>2])&&(D[A+24>>2]=g,sA(g)),I=D[A+8>>2]){if((0|(C=D[A+12>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+8>>2]}D[A+12>>2]=I,sA(g)}return 0|A},rQ,EQ,EQ,function(A){return D[44+(A|=0)>>2]?0|RQ[D[D[A>>2]+48>>2]](A):0},function(A){var I=0,g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;A:{if(Q=0,!((0|(E=D[(I=D[32+(A|=0)>>2])+12>>2]))<=(0|(C=D[I+20>>2]))&(i=B=D[I+8>>2])>>>0<=(B=D[I+16>>2])>>>0|(0|C)>(0|E))){i=e[B+D[I>>2]|0],C=(E=B+1|0)?C:C+1|0,D[I+16>>2]=E,D[I+20>>2]=C;I:if(i){for(;;){if(0|RQ[D[D[A>>2]+16>>2]](A,g)){if((0|i)!=(0|(g=g+1|0)))continue;break I}break}return 0}if((0|(g=D[A+8>>2]))!=(0|(C=D[A+12>>2])))for(;;){if(!(0|RQ[D[D[(I=D[g>>2])>>2]+8>>2]](I,A,D[A+4>>2])))break A;if((0|C)==(0|(g=g+4|0)))break}if(i){for(g=0;;){if(!(0|RQ[D[D[(I=D[D[A+8>>2]+(g<<2)>>2])>>2]+12>>2]](I,D[A+32>>2])))break A;if((0|i)==(0|(g=g+1|0)))break}if(i)for(B=A+20|0;;){if(g=0,(0|(C=0|RQ[D[D[(I=D[(E=o<<2)+D[A+8>>2]>>2])>>2]+24>>2]](I)))>0)for(;(r=0|RQ[D[D[(I=D[D[A+8>>2]+E>>2])>>2]+20>>2]](I,g))>>>0<(a=D[A+24>>2]-(Q=D[A+20>>2])>>2)>>>0||((I=r+1|0)>>>0>a>>>0?($I(B,I-a|0),Q=D[B>>2]):I>>>0>=a>>>0||(D[A+24>>2]=(I<<2)+Q)),D[(r<<2)+Q>>2]=o,(0|C)!=(0|(g=g+1|0)););if((0|i)==(0|(o=o+1|0)))break}}Q=0,0|RQ[D[D[A>>2]+28>>2]](A)&&(Q=0|RQ[D[D[A>>2]+32>>2]](A))}return 0|Q}return 0},function(A){var I,g=0,C=0;if((0|(g=D[8+(A|=0)>>2]))==(0|(I=D[A+12>>2])))return 1;for(;(C=0|RQ[D[D[(C=D[g>>2])>>2]+16>>2]](C,D[A+32>>2]))&&(0|I)!=(0|(g=g+4|0)););return 0|C},EQ,IQ,OC,OC,function(A){var I,g=0,C=0;if(D[(A|=0)>>2]=11304,g=D[A+48>>2],D[A+48>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),D[A>>2]=13312,(g=D[A+20>>2])&&(D[A+24>>2]=g,sA(g)),I=D[A+8>>2]){if((0|(C=D[A+12>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+8>>2]}D[A+12>>2]=I,sA(g)}return 0|A},function(A){var I,g=0,C=0;if(D[(A|=0)>>2]=11304,g=D[A+48>>2],D[A+48>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),D[A>>2]=13312,(g=D[A+20>>2])&&(D[A+24>>2]=g,sA(g)),I=D[A+8>>2]){if((0|(C=D[A+12>>2]))==(0|I))g=I;else{for(;g=D[(C=C-4|0)>>2],D[C>>2]=0,g&&RQ[D[D[g>>2]+4>>2]](g),(0|I)!=(0|C););g=D[A+8>>2]}D[A+12>>2]=I,sA(g)}sA(A)},function(A){var I,g=0,C=0,Q=0,E=0;if(k[(C=D[32+(A|=0)>>2])+8>>2]>(I=D[C+16>>2])>>>0&(0|(Q=D[C+12>>2]))>=(0|(g=D[C+20>>2]))|(0|g)<(0|Q)){E=e[I+D[C>>2]|0],g=(Q=I+1|0)?g:g+1|0,D[C+16>>2]=Q,D[C+20>>2]=g,C=D[A+48>>2],D[A+48>>2]=0,C&&RQ[D[D[C>>2]+4>>2]](C);A:{I:{g:{C:switch(0|E){case 0:C=DC(384),D[C>>2]=11412,bI(C+4|0,0,80),D[C+96>>2]=0,D[C+100>>2]=0,D[C+92>>2]=-1,D[C+84>>2]=-1,D[C+88>>2]=-1,D[C+104>>2]=0,D[C+108>>2]=0,D[C+112>>2]=0,D[C+116>>2]=0,D[C+120>>2]=0,D[C+124>>2]=0,D[C+128>>2]=0,D[C+132>>2]=0,D[C+136>>2]=0,D[C+140>>2]=0,D[C+144>>2]=0,D[C+148>>2]=0,D[C+156>>2]=0,D[C+160>>2]=0,D[C+152>>2]=1065353216,D[C+164>>2]=0,D[C+168>>2]=0,D[C+172>>2]=0,D[C+176>>2]=0,D[C+180>>2]=0,D[C+184>>2]=0,D[C+188>>2]=0,D[C+192>>2]=0,D[C+196>>2]=0,D[C+200>>2]=0,D[C+204>>2]=0,D[C+208>>2]=0,D[C+212>>2]=-1,D[C+216>>2]=0,D[C+220>>2]=0,D[C+224>>2]=0,r[38+(g=C+232|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,r[38+(g=C+272|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[(g=C+312|0)>>2]=0,D[g+4>>2]=0,B[g+5|0]=0,B[g+6|0]=0,B[g+7|0]=0,B[g+8|0]=0,B[g+9|0]=0,B[g+10|0]=0,B[g+11|0]=0,B[g+12|0]=0,r[38+(g=C+328|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[C+376>>2]=0,D[C+368>>2]=0,D[C+372>>2]=0;break g;case 1:C=DC(424),D[C>>2]=11464,bI(C+4|0,0,80),D[C+96>>2]=0,D[C+100>>2]=0,D[C+92>>2]=-1,D[C+84>>2]=-1,D[C+88>>2]=-1,D[C+104>>2]=0,D[C+108>>2]=0,D[C+112>>2]=0,D[C+116>>2]=0,D[C+120>>2]=0,D[C+124>>2]=0,D[C+128>>2]=0,D[C+132>>2]=0,D[C+136>>2]=0,D[C+140>>2]=0,D[C+144>>2]=0,D[C+148>>2]=0,D[C+156>>2]=0,D[C+160>>2]=0,D[C+152>>2]=1065353216,D[C+164>>2]=0,D[C+168>>2]=0,D[C+172>>2]=0,D[C+176>>2]=0,D[C+180>>2]=0,D[C+184>>2]=0,D[C+188>>2]=0,D[C+192>>2]=0,D[C+196>>2]=0,D[C+200>>2]=0,D[C+204>>2]=0,D[C+208>>2]=0,D[C+212>>2]=-1,D[C+216>>2]=0,D[C+220>>2]=0,D[C+224>>2]=0,r[38+(g=C+232|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,r[38+(g=C+272|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[(g=C+312|0)>>2]=0,D[g+4>>2]=0,B[g+5|0]=0,B[g+6|0]=0,B[g+7|0]=0,B[g+8|0]=0,B[g+9|0]=0,B[g+10|0]=0,B[g+11|0]=0,B[g+12|0]=0,r[38+(g=C+328|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[C+392>>2]=0,D[C+396>>2]=0,D[C+384>>2]=0,D[C+388>>2]=0,D[C+376>>2]=0,D[C+380>>2]=0,D[C+368>>2]=0,D[C+372>>2]=0,D[(g=C+400|0)>>2]=0,D[g+4>>2]=0,B[g+5|0]=0,B[g+6|0]=0,B[g+7|0]=0,B[g+8|0]=0,B[g+9|0]=0,B[g+10|0]=0,B[g+11|0]=0,B[g+12|0]=0,D[C+416>>2]=-1,D[C+420>>2]=-1;break g;case 2:break C;default:break I}C=DC(440),D[C>>2]=11512,bI(C+4|0,0,80),D[C+96>>2]=0,D[C+100>>2]=0,D[C+92>>2]=-1,D[C+84>>2]=-1,D[C+88>>2]=-1,D[C+104>>2]=0,D[C+108>>2]=0,D[C+112>>2]=0,D[C+116>>2]=0,D[C+120>>2]=0,D[C+124>>2]=0,D[C+128>>2]=0,D[C+132>>2]=0,D[C+136>>2]=0,D[C+140>>2]=0,D[C+144>>2]=0,D[C+148>>2]=0,D[C+156>>2]=0,D[C+160>>2]=0,D[C+152>>2]=1065353216,D[C+164>>2]=0,D[C+168>>2]=0,D[C+172>>2]=0,D[C+176>>2]=0,D[C+180>>2]=0,D[C+184>>2]=0,D[C+188>>2]=0,D[C+192>>2]=0,D[C+196>>2]=0,D[C+200>>2]=0,D[C+204>>2]=0,D[C+208>>2]=0,D[C+212>>2]=-1,D[C+216>>2]=0,D[C+220>>2]=0,D[C+224>>2]=0,r[38+(g=C+232|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,r[38+(g=C+272|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[(g=C+312|0)>>2]=0,D[g+4>>2]=0,B[g+5|0]=0,B[g+6|0]=0,B[g+7|0]=0,B[g+8|0]=0,B[g+9|0]=0,B[g+10|0]=0,B[g+11|0]=0,B[g+12|0]=0,r[38+(g=C+328|0)>>1]=0,D[g>>2]=0,D[g+8>>2]=0,D[g+12>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0,D[g+24>>2]=0,D[g+28>>2]=0,B[g+29|0]=0,B[g+30|0]=0,B[g+31|0]=0,B[g+32|0]=0,B[g+33|0]=0,B[g+34|0]=0,B[g+35|0]=0,B[g+36|0]=0,D[C+392>>2]=0,D[C+396>>2]=0,D[C+384>>2]=0,D[C+388>>2]=0,D[C+376>>2]=0,D[C+380>>2]=0,D[C+368>>2]=0,D[C+372>>2]=0,D[C+416>>2]=0,D[C+420>>2]=0,D[C+408>>2]=2,D[C+412>>2]=7,D[C+400>>2]=-1,D[C+404>>2]=-1,D[C+424>>2]=0,D[C+428>>2]=0,D[C+432>>2]=0,D[C+436>>2]=0}if(g=D[A+48>>2],D[A+48>>2]=C,!g)break A;RQ[D[D[g>>2]+4>>2]](g)}if(!(C=D[A+48>>2]))return 0}A=0|RQ[D[D[C>>2]+8>>2]](C,A)}else A=0;return 0|A},function(A,I){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+20>>2]](A,I|=0)},function(A){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+28>>2]](A)},function(A){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+36>>2]](A)},function(A,I){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+12>>2]](A,I|=0)},function(A,I){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+16>>2]](A,I|=0)},function(A){return 0|RQ[D[D[(A=D[48+(A|=0)>>2])>>2]+24>>2]](A)},OA,function(A){sA(OA(A|=0))},uC,_I,OI,P,function(A){var I,g=0,C=0,Q=0,E=0,i=0,o=0,a=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0,H=0,q=0,W=0,V=0,_=0,T=0;if(d=I=d+-64|0,D[132+(A|=0)>>2]=0,D[A+148>>2]){if(C=D[A+144>>2])for(;g=D[C>>2],sA(C),C=g,g;);if(C=0,D[A+144>>2]=0,Q=D[A+140>>2]){if(Q-1>>>0>=3)for(g=-4&Q;D[(N=C<<2)+D[A+136>>2]>>2]=0,D[D[A+136>>2]+(4|N)>>2]=0,D[D[A+136>>2]+(8|N)>>2]=0,D[D[A+136>>2]+(12|N)>>2]=0,C=C+4|0,(0|g)!=(0|(E=E+4|0)););if(g=3&Q)for(;D[D[A+136>>2]+(C<<2)>>2]=0,C=C+1|0,(0|g)!=(0|(Y=Y+1|0)););}D[A+148>>2]=0}A:{I:{if(!((g=(Y=e[(C=D[A+4>>2])+36|0])<<8|e[C+37|0])>>>0>513))if(G=D[C+32>>2],g>>>0<=511){if(g=D[G+20>>2],g=(E=(Q=D[G+16>>2])+4|0)>>>0<4?g+1|0:g,(N=E)>>>0>k[G+8>>2]&(0|(E=D[G+12>>2]))<=(0|g)|(0|g)>(0|E))break I;E=e[0|(E=Q+D[G>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[G+16>>2]=N,D[G+20>>2]=g,D[A+132>>2]=E}else{if(!yg(1,I,G))break I;Y=e[(C=D[A+4>>2])+36|0],D[A+132>>2]=D[I>>2]}G=D[C+32>>2];g:{C:{if((255&Y)>>>0<=1){if(Y=0,g=D[G+20>>2],g=(E=(Q=D[G+16>>2])+4|0)>>>0<4?g+1|0:g,(N=E)>>>0>k[G+8>>2]&(0|(E=D[G+12>>2]))<=(0|g)|(0|g)>(0|E))break A;D[I+60>>2]=E=e[0|(E=Q+D[G>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[G+16>>2]=N,D[G+20>>2]=g,D[A+156>>2]=E,F=A+156|0}else{if(Y=0,!yg(1,I+60|0,G))break A;if(g=e[(C=D[A+4>>2])+36|0],D[A+156>>2]=D[I+60>>2],F=A+156|0,g>>>0>1)break C}if(a=C=D[(Q=D[C+32>>2])+8>>2],C=D[Q+20>>2],a>>>0<(g=(E=D[Q+16>>2])+4|0)>>>0&(0|(C=g>>>0<4?C+1|0:C))>=(0|(N=D[Q+12>>2]))|(0|C)>(0|N))break A;D[I+56>>2]=E=e[0|(E=E+D[Q>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[Q+16>>2]=g,D[Q+20>>2]=C;break g}if(!yg(1,I+56|0,D[C+32>>2]))break A;E=D[I+56>>2]}if(E>>>0>1431655765|k[F>>2]>s(E,3)>>>0)break A;if((0|(N=D[(g=D[(F=D[A+4>>2])+32>>2])+12>>2]))<=(0|(C=D[g+20>>2]))&(t=D[g+16>>2])>>>0>=(Q=i=D[g+8>>2])>>>0|(0|C)>(0|N))break A;if(o=e[(S=D[g>>2])+t|0],a=(Q=t+1|0)?C:C+1|0,G=Q,D[g+16>>2]=Q,D[g+20>>2]=a,e[F+36|0]<=1){if((Q=t+5|0)>>>0>i>>>0&(0|(C=Q>>>0<5?C+1|0:C))>=(0|N)|(0|C)>(0|N))break A;D[I+52>>2]=F=e[0|(N=G+S|0)]|e[N+1|0]<<8|e[N+2|0]<<16|e[N+3|0]<<24,D[g+16>>2]=Q,D[g+20>>2]=C}else{if(!yg(1,I+52|0,g))break A;F=D[I+52>>2]}if(E>>>0<F>>>0|((F>>>0)/3|0)+F>>>0<E>>>0)break A;if(G=D[(C=D[A+4>>2])+32>>2],e[C+36|0]<=1){if(C=D[G+20>>2],C=(g=(Q=D[G+16>>2])+4|0)>>>0<4?C+1|0:C,(N=g)>>>0>k[G+8>>2]&(0|(g=D[G+12>>2]))<=(0|C)|(0|g)<(0|C))break A;D[I+48>>2]=g=e[0|(g=Q+D[G>>2]|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[G+16>>2]=N,D[G+20>>2]=C}else{if(!yg(1,I+48|0,G))break A;g=D[I+48>>2]}if(g>>>0>F>>>0)break A;if(D[A+28>>2]=D[A+24>>2],tg(C=DC(88)),N=D[A+8>>2],D[A+8>>2]=C,N&&(Yg(N),!D[A+8>>2]))break A;if(D[A+164>>2]=D[A+160>>2],Sg(A+160|0,E),D[A+176>>2]=D[A+172>>2],Sg(A+172|0,E),D[A- -64>>2]=0,D[A+92>>2]=-1,D[A+84>>2]=-1,D[A+88>>2]=-1,D[A+40>>2]=D[A+36>>2],D[A+52>>2]=D[A+48>>2],D[A+76>>2]=D[A+72>>2],lg(H=A+216|0),kA(H,o),!WI(D[A+8>>2],E,D[A+156>>2]+g|0))break A;if(C=D[A+156>>2],B[0|I]=1,hI(A+120|0,g+C|0,I),(C=65535&((C=f[(g=D[A+4>>2])+36>>1])<<8|C>>>8))>>>0<=513){if(Q=D[g+32>>2],C>>>0<=511){if(g=D[Q+20>>2],g=(C=(E=D[Q+16>>2])+4|0)>>>0<4?g+1|0:g,(N=C)>>>0>k[Q+8>>2]&(0|(C=D[Q+12>>2]))<=(0|g)|(0|g)>(0|C))break A;E=e[0|(C=E+D[Q>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[Q+16>>2]=N,D[Q+20>>2]=g}else{if(!yg(1,I+44|0,Q))break A;E=D[I+44>>2]}if(!E)break A;if((g=(N=D[(Q=D[D[A+4>>2]+32>>2])+8>>2])-(C=D[Q+16>>2])|0)>>>0<E>>>0&(0|(C=D[Q+12>>2]-(D[Q+20>>2]+(C>>>0>N>>>0)|0)|0))<=0|(0|C)<0)break A;if(r[I+38>>1]=0,D[I>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,D[I+24>>2]=0,D[I+28>>2]=0,B[I+29|0]=0,B[I+30|0]=0,B[I+31|0]=0,B[I+32|0]=0,B[I+33|0]=0,B[I+34|0]=0,B[I+35|0]=0,B[I+36|0]=0,N=((C=D[(Q=D[D[A+4>>2]+32>>2])+16>>2])+D[Q>>2]|0)+E|0,C=((g=D[Q+8>>2])-C|0)-E|0,r[I+38>>1]=f[Q+38>>1],D[I>>2]=N,D[I+16>>2]=0,D[I+20>>2]=0,D[I+8>>2]=C,D[I+12>>2]=0,-1==(0|(G=AA(A,I))))break A;V=G>>31}else if(G=-1,V=-1,-1==(0|AA(A,D[g+32>>2])))break A;kg(q=A+232|0,A),D[A+372>>2]=o,r[I+38>>1]=0,D[I>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,D[I+24>>2]=0,D[I+28>>2]=0,B[I+29|0]=0,B[I+30|0]=0,B[I+31|0]=0,B[I+32|0]=0,B[I+33|0]=0,B[I+34|0]=0,B[I+35|0]=0,B[I+36|0]=0;g:if(JA(q,I)){g=0,C=0,E=0,S=0,N=0,d=n=d-96|0,D[n+72>>2]=0,D[n+64>>2]=0,D[n+68>>2]=0,D[n+48>>2]=0,D[n+52>>2]=0,D[n+40>>2]=0,D[n+44>>2]=0,D[n+56>>2]=1065353216,D[n+32>>2]=0,D[n+24>>2]=0,D[n+28>>2]=0,R=1,o=A,W=D[A+124>>2];C:{Q:{B:{E:{i:{o:{a:{r:if(!((0|F)<=0)){for(l=D[o+216>>2]!=D[o+220>>2];;){S=(a=S)+1|0;D:{e:{f:{k:{t:{N:{s:{F:{n:{R:{y:if(e[o+308|0]){G:{if(!((A=(h=D[o+296>>2])+((y=D[o+304>>2])>>>3|0)|0)>>>0>=(t=D[o+300>>2])>>>0)&&(Q=e[0|A],D[o+304>>2]=A=y+1|0,Q>>>(7&y)&1))switch((Q=h+(w=A>>>3|0)|0)>>>0>=t>>>0?(Q=A,A=0):(i=e[0|Q],D[o+304>>2]=Q=y+2|0,w=Q>>>3|0,A=i>>>(7&A)&1),(i=w+h|0)>>>0<t>>>0?(i=e[0|i],D[o+304>>2]=Q+1,Q=i>>>(7&Q)<<1&2):Q=0,(A=(A|Q)<<1)-1|0){case 0:case 2:case 4:break B;case 5:break R;case 1:case 3:break G;default:break y}if((0|C)==(0|E)){Q=-1;break a}w=-1,b=D[o+8>>2],A=-1,-1!=(0|(M=D[(t=C-4|0)>>2]))&&(A=-1,-1!=(0|(g=((g=M+1|0)>>>0)%3|0?g:M-2|0))&&(A=D[D[b>>2]+(g<<2)>>2])),-1!=(0|(Q=D[(h=D[b+24>>2])+((g=A)<<2)>>2]))&&(w=((A=Q+1|0)>>>0)%3|0?A:Q-2|0),Q=D[b+12>>2],c=s(a,3),D[Q+(M<<2)>>2]=A=c+1|0,D[(i=A<<2)+Q>>2]=M,D[Q+(w<<2)>>2]=y=c+2|0,D[(a=y<<2)+Q>>2]=w,J=-1,A=-1;c:if(-1!=(0|M)){if((M>>>0)%3|0)Q=M-1|0;else if(A=-1,-1==(0|(Q=M+2|0)))break c;A=D[D[b>>2]+(Q<<2)>>2]}if(-1!=(0|w)&&-1!=(0|(Q=((Q=w+1|0)>>>0)%3|0?Q:w-2|0))&&(J=D[D[b>>2]+(Q<<2)>>2]),Q=-1,(0|A)==(0|g)|(0|g)==(0|J))break a;D[(Q=D[b>>2])+(c<<2)>>2]=g,D[Q+i>>2]=J,D[Q+a>>2]=A,-1!=(0|A)&&(D[h+(A<<2)>>2]=y),A=D[(Q=D[o+120>>2]+(g>>>3&536870908)|0)>>2],_=Q,T=JC(g)&A,D[_>>2]=T,D[t>>2]=c,g=E;break D}if((0|C)==(0|E)){Q=-1;break a}if(g=D[(J=D[o+8>>2])+12>>2],c=s(a,3),D[g+(A=(t=c+((h=5==(1|A))?2:1)|0)<<2)>>2]=M=D[(i=C-4|0)>>2],D[g+(M<<2)>>2]=t,Bg(J+24|0),Q=-1,(0|W)<D[(g=D[o+8>>2])+28>>2]-(y=D[g+24>>2])>>2)break a;if(D[(Q=(b=D[g>>2])+A|0)>>2]=A=((g=D[J+28>>2]-D[J+24>>2]|0)>>2)-1|0,g&&(D[y+(A<<2)>>2]=t),t=h?c:c+2|0,Q=b+(c+h<<2)|0,-1!=(0|M)){G:{c:{if((M>>>0)%3|0)g=M-1|0;else if(-1==(0|(g=M+2|0)))break c;if(D[b+(t<<2)>>2]=A=D[b+(g<<2)>>2],-1==(0|A))break G;D[y+(A<<2)>>2]=t;break G}D[b+(t<<2)>>2]=-1}g=-1,-1!=(0|(A=((A=M+1|0)>>>0)%3|0?A:M-2|0))&&(g=D[b+(A<<2)>>2])}else D[b+(t<<2)>>2]=-1,g=-1;D[Q>>2]=g,D[i>>2]=c,g=E;break n}if((0|C)==(0|E)){Q=-1;break a}b=D[(A=C-4|0)>>2],D[n+68>>2]=A;y:if(t=D[n+44>>2])if((i=bC(t)>>>0>1)?t>>>0>(g=a)>>>0||(g=(a>>>0)%(t>>>0)|0):g=a&t+2147483647,Q=D[D[n+40>>2]+(g<<2)>>2])if(Q=D[Q>>2]){G:{if(!i){for(t=t-1|0;;){c:{if((0|(i=D[Q+4>>2]))!=(0|a)){if((i&t)==(0|g))break c;C=A;break y}if((0|a)==D[Q+8>>2])break G}if(!(Q=D[Q>>2]))break}C=A;break y}for(;;){c:{if((0|(i=D[Q+4>>2]))!=(0|a)){if(i>>>0>=t>>>0&&(i=(i>>>0)%(t>>>0)|0),(0|g)==(0|i))break c;C=A;break y}if((0|a)==D[Q+8>>2])break G}if(!(Q=D[Q>>2]))break}C=A;break y}if((0|A)==(0|p)){if((C=1+(g=(i=p-E|0)>>2)|0)>>>0>=1073741824)break s;if(A=i>>1,C=g>>>0<536870911?A>>>0<C>>>0?C:A:1073741823){if(C>>>0>=1073741824)break Q;K=DC(C<<2)}else K=0;D[(A=K+(g<<2)|0)>>2]=D[Q+12>>2],p=(C<<2)+K|0,C=A+4|0,(0|i)>0&&xA(K,E,i),D[n+72>>2]=p,D[n+68>>2]=C,D[n+64>>2]=K,E&&sA(E)}else D[A>>2]=D[Q+12>>2],D[n+68>>2]=C}else C=A;else C=A;else C=A;if((0|C)==(0|K))break F;if(!(g=-1==(0|(c=D[(i=C-4|0)>>2])))&-1!=D[D[(J=D[o+8>>2])+12>>2]+(c<<2)>>2])break F;if(-1!=(0|b)&-1!=D[(y=D[J+12>>2])+(b<<2)>>2])break F;if(h=s(a,3),D[y+(c<<2)>>2]=a=h+2|0,D[(t=a<<2)+y>>2]=c,D[y+(b<<2)>>2]=A=h+1|0,D[(E=A<<2)+y>>2]=b,g)break N;if((c>>>0)%3|0){R=c-1|0;break k}if(-1!=(0|(R=c+2|0)))break k;w=D[J>>2],g=-1;break f}if(Bg((A=D[o+8>>2])+24|0),Q=-1,i=D[o+8>>2],b=s(a,3),D[D[i>>2]+(b<<2)>>2]=t=(J=(y=D[A+28>>2]-D[A+24>>2]|0)>>2)-1|0,Bg(i+24|0),D[D[i>>2]+((h=b+1|0)<<2)>>2]=(D[i+28>>2]-D[i+24>>2]>>2)-1,Bg((A=D[o+8>>2])+24|0),D[D[A>>2]+((i=b+2|0)<<2)>>2]=(D[A+28>>2]-D[A+24>>2]>>2)-1,(0|W)<D[(A=D[o+8>>2])+28>>2]-(c=D[A+24>>2])>>2)break a;R:{if(y){if(D[c+(t<<2)>>2]=b,Q=0,-4!=(0|y)&&(D[c+(J<<2)>>2]=h,-1==(0|(Q=J+1|0))))break R}else D[c+(J<<2)>>2]=h,Q=1;D[c+(Q<<2)>>2]=i}if((0|C)==(0|p)){if((C=1+(E=(Q=C-g|0)>>2)|0)>>>0>=1073741824)break t;if(A=Q>>1,C=E>>>0<536870911?A>>>0<C>>>0?C:A:1073741823){if(C>>>0>=1073741824)break Q;K=DC(C<<2)}else K=0;D[(A=K+(E<<2)|0)>>2]=b,p=(C<<2)+K|0,C=A+4|0,(0|Q)>0&&xA(K,g,Q),D[n+72>>2]=p,D[n+68>>2]=C,D[n+64>>2]=K,g&&sA(g),g=E=K}else D[C>>2]=b,D[n+68>>2]=C=C+4|0}if((0|(Q=D[o+40>>2]))==D[o+36>>2])break D;for(t=(-1^a)+F|0,i=C-4|0;;){if((A=D[Q-8>>2])>>>0>t>>>0)break F;if((0|A)!=(0|t))break D;if(a=e[Q-4|0],Q=D[(A=Q-12|0)>>2],D[o+40>>2]=A,(0|Q)<0)break F;h=D[i>>2],D[n+20>>2]=(-1^Q)+F,D[n+88>>2]=A=n+20|0,FA(n,n+40|0,A,n+88|0),Q=D[n>>2];n:if(1&a){if(A=-1,-1==(0|h))break n;A=((A=h+1|0)>>>0)%3|0?A:h-2|0}else A=-1,-1!=(0|h)&&(A=h-1|0,(h>>>0)%3|0||(A=h+2|0));if(D[Q+12>>2]=A,(0|(Q=D[o+40>>2]))==D[o+36>>2])break}break D}if(Q=-1,1&R)break a;break r}iQ(),U()}g=-1,D[(w=D[J>>2])+(h<<2)>>2]=-1,Q=-1;break e}iQ(),U()}g=D[(w=D[J>>2])+(R<<2)>>2]}D[(h<<2)+w>>2]=g,Q=-1,-1!=(0|(A=((A=c+1|0)>>>0)%3|0?A:c-2|0))&&(Q=D[(A<<2)+w>>2])}if(D[E+w>>2]=Q,-1!=(0|b)){e:{f:{if((b>>>0)%3|0)Q=b-1|0;else if(-1==(0|(Q=b+2|0)))break f;if(D[t+w>>2]=A=D[(Q<<2)+w>>2],-1==(0|A))break e;D[D[J+24>>2]+(A<<2)>>2]=a;break e}D[t+w>>2]=-1}R=-1,Q=-1,-1!=(0|(A=((A=b+1|0)>>>0)%3|0?A:b-2|0))&&(R=D[(A<<2)+w>>2],Q=A)}else D[t+w>>2]=-1,R=-1,Q=-1;a=(A=D[J+24>>2])+(R<<2)|0,-1!=(0|g)&&(D[A+(g<<2)>>2]=D[a>>2]);e:if(-1!=(0|Q))for(;;){if(D[(Q<<2)+w>>2]=g,-1==(0|(A=((A=Q+1|0)>>>0)%3|0?A:Q-2|0)))break e;if(-1==(0|(E=D[y+(A<<2)>>2])))break e;if(-1==(0|(Q=((A=E+1|0)>>>0)%3|0?A:E-2|0)))break}D[a>>2]=-1;e:if(!l){if((0|L)==(0|u)){f:{if((g=1+(E=(a=L-N|0)>>2)|0)>>>0<1073741824){if(A=a>>1,Q=E>>>0<536870911?A>>>0<g>>>0?g:A:1073741823){if(Q>>>0>=1073741824)break f;A=DC(Q<<2)}else A=0;D[(g=A+(E<<2)|0)>>2]=R,L=A+(Q<<2)|0,u=g+4|0,(0|a)>0&&xA(A,N,a),D[n+32>>2]=L,D[n+28>>2]=u,D[n+24>>2]=A,N&&sA(N),N=A;break e}iQ(),U()}break Q}D[u>>2]=R,D[n+28>>2]=u=u+4|0}D[i>>2]=h,g=E=K}if(R=(0|F)>(0|S),(0|F)==(0|S))break}S=F}if(Q=-1,!((0|W)<D[(R=D[o+8>>2])+28>>2]-D[R+24>>2]>>2)){if((0|C)!=(0|K)){for(E=o+60|0,h=o+312|0;;){y=D[(C=C-4|0)>>2],D[n+68>>2]=C;r:{D:{e:{if(f[o+270>>1]<=513){if(!e[o+364|0])break e;if((A=D[o+352>>2]+((g=D[o+360>>2])>>>3|0)|0)>>>0>=k[o+356>>2])break D;A=e[0|A],D[o+360>>2]=g+1,A=A>>>(7&g)&1}else A=ug(h);if(!A)break D}if(((D[(l=D[o+8>>2])+4>>2]-(c=D[l>>2])>>2>>>0)/3|0)<=(0|S))break a;if(A=-1,g=-1,a=-1,-1!=(0|y)&&(a=-1,-1!=(0|(i=((i=y+1|0)>>>0)%3|0?i:y-2|0))&&(a=D[c+(i<<2)>>2])),-1!=(0|(F=D[(t=D[l+24>>2])+(a<<2)>>2]))&&-1!=(0|(i=((i=F+1|0)>>>0)%3|0?i:F-2|0))&&(-1!=(0|(A=((A=i+1|0)>>>0)%3|0?A:i-2|0))&&(g=D[c+(A<<2)>>2]),A=i),R=-1,w=-1,F=-1,-1!=(0|(t=D[t+(g<<2)>>2]))&&(F=-1,-1!=(0|(i=((i=t+1|0)>>>0)%3|0?i:t-2|0))&&(-1!=(0|(F=((F=i+1|0)>>>0)%3|0?F:i-2|0))&&(w=D[c+(F<<2)>>2]),F=i)),L=D[l+12>>2],J=s(S,3),D[L+(t=J<<2)>>2]=y,D[L+(y<<2)>>2]=J,D[(i=(y=J+1|0)<<2)+L>>2]=A,D[L+(A<<2)>>2]=y,D[(A=(l=J+2|0)<<2)+L>>2]=F,D[L+(F<<2)>>2]=l,D[t+c>>2]=g,D[(F=i+c|0)>>2]=w,D[(i=A+c|0)>>2]=a,A=D[(g=(t=D[o+120>>2])+((a=y>>>0<J>>>0?-1:g)>>>3&536870908)|0)>>2],_=g,T=JC(a)&A,D[_>>2]=T,A=D[(g=t+((R=-1!=(0|y)?D[F>>2]:R)>>>3&536870908)|0)>>2],_=g,T=JC(R)&A,D[_>>2]=T,R=-1,A=D[(g=t+((R=-1!=(0|l)?D[i>>2]:R)>>>3&536870908)|0)>>2],_=g,T=JC(R)&A,D[_>>2]=T,(0|(R=D[o+64>>2]))==(A=D[o+68>>2])<<5){if((R+1|0)<0)break o;vI(E,A=R>>>0<=1073741822?(A<<=6)>>>0<(g=R+32&-32)>>>0?g:A:2147483647),R=D[o+64>>2]}if(S=S+1|0,D[o+64>>2]=R+1,D[(A=D[o+60>>2]+(R>>>3&536870908)|0)>>2]=D[A>>2]|1<<R,(0|(A=D[o+76>>2]))!=D[o+80>>2]){D[A>>2]=J,D[o+76>>2]=A+4;break r}if((g=1+(a=(F=A-(t=D[o+72>>2])|0)>>2)|0)>>>0>=1073741824)break i;if(A=F>>1,i=a>>>0<536870911?A>>>0<g>>>0?g:A:1073741823){if(i>>>0>=1073741824)break Q;A=DC(i<<2)}else A=0;if(D[(g=A+(a<<2)|0)>>2]=J,(0|F)>0&&xA(A,t,F),D[o+80>>2]=A+(i<<2),D[o+76>>2]=g+4,D[o+72>>2]=A,!t)break r;sA(t);break r}if((0|(A=D[o+64>>2]))==(a=D[o+68>>2])<<5){if((A+1|0)<0)break o;A>>>0<=1073741822?(g=A+32&-32,A=(A=a<<6)>>>0<g>>>0?g:A):A=2147483647,vI(E,A),A=D[o+64>>2]}if(D[o+64>>2]=A+1,g=D[(a=D[o+60>>2]+(A>>>3&536870908)|0)>>2],_=a,T=JC(A)&g,D[_>>2]=T,(0|(A=D[o+76>>2]))==D[o+80>>2]){if((g=1+(a=(F=A-(t=D[o+72>>2])|0)>>2)|0)>>>0>=1073741824)break i;if(A=F>>1,i=a>>>0<536870911?A>>>0<g>>>0?g:A:1073741823){if(i>>>0>=1073741824)break E;A=DC(i<<2)}else A=0;D[(g=A+(a<<2)|0)>>2]=y,(0|F)>0&&xA(A,t,F),D[o+80>>2]=A+(i<<2),D[o+76>>2]=g+4,D[o+72>>2]=A,t&&sA(t)}else D[A>>2]=y,D[o+76>>2]=A+4}if((0|C)==(0|K))break}R=D[o+8>>2]}if(((D[R+4>>2]-D[R>>2]>>2>>>0)/3|0)==(0|S))if(Q=D[R+28>>2]-(S=D[R+24>>2])>>2,(0|N)!=(0|u))for(g=N;;){if(E=D[g>>2],-1==D[(w=((C=Q-1|0)<<2)+S|0)>>2])for(;C=Q-2|0,Q=Q-1|0,-1==D[(w=(C<<2)+S|0)>>2];);if(C>>>0>=E>>>0){if(D[n>>2]=R,S=D[w>>2],B[n+12|0]=1,D[n+8>>2]=S,D[n+4>>2]=S,-1!=(0|S))for(;D[D[R>>2]+(S<<2)>>2]=E,FI(n),R=D[o+8>>2],-1!=(0|(S=D[n+8>>2])););A=(S=D[R+24>>2])+(C<<2)|0,-1!=(0|E)&&(D[(E<<2)+S>>2]=D[A>>2]),D[A>>2]=-1,i=1<<E,D[(E=(A=D[o+120>>2])+(E>>>3&536870908)|0)>>2]=C=D[(a=A+(C>>>3&536870908)|0)>>2]&(A=1<<C)?i|D[E>>2]:D[E>>2]&(-1^i),D[a>>2]=D[a>>2]&(-1^A),Q=Q-1|0}if((0|u)==(0|(g=g+4|0)))break}else N=u}}if(N&&sA(N),A=D[n+48>>2])for(;C=D[A>>2],sA(A),A=C;);A=D[n+40>>2],D[n+40>>2]=0,A&&sA(A),K&&(D[n+68>>2]=K,sA(K)),d=n+96|0;break C}iQ(),U()}iQ(),U()}xg(1336)}U()}xg(1336),U()}if(-1!=(0|Q)){g=(A=D[I+16>>2])+D[I>>2]|0,A=(C=D[I+8>>2])-A|0,r[(C=D[D[o+4>>2]+32>>2])+38>>1]=f[C+38>>1],D[C>>2]=g,D[C+16>>2]=0,D[C+20>>2]=0,D[C+8>>2]=A,D[C+12>>2]=0,(65535&(C=(A=f[(g=D[o+4>>2])+36>>1])<<8|A>>>8))>>>0<=513&&(a=V+D[(A=D[g+32>>2])+20>>2]|0,a=(g=G+D[A+16>>2]|0)>>>0<G>>>0?a+1|0:a,D[A+16>>2]=g,D[A+20>>2]=a);C:if(D[o+216>>2]!=D[o+220>>2]){if(g=D[(A=D[o+8>>2])>>2],A=D[A+4>>2],!((65535&C)>>>0>=513)){if((0|A)==(0|g))break C;for(C=0;;){if(KA(o,C)){if((C=C+3|0)>>>0<D[(A=D[o+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break C}break}break g}if((0|A)!=(0|g)){for(C=0;;){if(YA(o,C)){if((C=C+3|0)>>>0<D[(A=D[o+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break C}break}break g}}if(og(q),(0|(C=D[o+216>>2]))!=D[o+220>>2])for(E=0;;){if(oI(4+((g=s(E,144))+C|0)|0,D[o+8>>2]),(0|(C=D[132+(A=g+(Y=D[H>>2])|0)>>2]))!=(0|(A=D[A+136>>2])))for(;fI(4+(g+Y|0)|0,D[C>>2]),Y=D[H>>2],(0|A)!=(0|(C=C+4|0)););if(nA(4+(g+Y|0)|0),!((E=E+1|0)>>>0<(D[o+220>>2]-(C=D[o+216>>2])|0)/144>>>0))break}if(ig(o+184|0,D[(A=D[o+8>>2])+28>>2]-D[A+24>>2]>>2),(0|(Y=D[o+216>>2]))!=D[o+220>>2])for(C=0;A=s(C,144)+Y|0,g=D[A+60>>2]-D[A+56>>2]>>2,ig(E=A+104|0,(0|(A=D[(A=D[o+8>>2])+28>>2]-D[A+24>>2]>>2))>(0|g)?A:g),(C=C+1|0)>>>0<(D[o+220>>2]-(Y=D[o+216>>2])|0)/144>>>0;);Y=QA(o,Q)}}break A}Y=0}return d=I- -64|0,0|Y},EQ,ZC,xC,XA,function(A){sA(XA(A|=0))},uC,_I,OI,P,function(A){var I,g=0,C=0,Q=0,E=0,i=0,o=0,a=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0,H=0,q=0,W=0,V=0,_=0,T=0,m=0,Z=0,x=0;if(d=I=d+-64|0,D[132+(A|=0)>>2]=0,D[A+148>>2]){if(E=D[A+144>>2])for(;Q=D[E>>2],sA(E),E=Q,Q;);if(E=0,D[A+144>>2]=0,i=D[A+140>>2]){if(i-1>>>0>=3)for(Q=-4&i;D[(g=E<<2)+D[A+136>>2]>>2]=0,D[D[A+136>>2]+(4|g)>>2]=0,D[D[A+136>>2]+(8|g)>>2]=0,D[D[A+136>>2]+(12|g)>>2]=0,E=E+4|0,(0|Q)!=(0|(o=o+4|0)););if(Q=3&i)for(;D[D[A+136>>2]+(E<<2)>>2]=0,E=E+1|0,(0|Q)!=(0|(S=S+1|0)););}D[A+148>>2]=0}A:{I:{if(!((Q=(S=e[(E=D[A+4>>2])+36|0])<<8|e[E+37|0])>>>0>513))if(C=D[E+32>>2],Q>>>0<=511){if(Q=D[C+20>>2],Q=(o=(i=D[C+16>>2])+4|0)>>>0<4?Q+1|0:Q,(g=o)>>>0>k[C+8>>2]&(0|(o=D[C+12>>2]))<=(0|Q)|(0|Q)>(0|o))break I;o=e[0|(o=i+D[C>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[C+16>>2]=g,D[C+20>>2]=Q,D[A+132>>2]=o}else{if(!yg(1,I,C))break I;S=e[(E=D[A+4>>2])+36|0],D[A+132>>2]=D[I>>2]}C=D[E+32>>2];g:{C:{if((255&S)>>>0<=1){if(S=0,Q=D[C+20>>2],Q=(o=(i=D[C+16>>2])+4|0)>>>0<4?Q+1|0:Q,(g=o)>>>0>k[C+8>>2]&(0|(o=D[C+12>>2]))<=(0|Q)|(0|Q)>(0|o))break A;D[I+60>>2]=o=e[0|(o=i+D[C>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[C+16>>2]=g,D[C+20>>2]=Q,D[A+156>>2]=o,C=A+156|0}else{if(S=0,!yg(1,I+60|0,C))break A;if(Q=e[(E=D[A+4>>2])+36|0],D[A+156>>2]=D[I+60>>2],C=A+156|0,Q>>>0>1)break C}if(n=Q=D[(y=D[E+32>>2])+8>>2],Q=D[y+20>>2],n>>>0<(E=o=(g=D[y+16>>2])+4|0)>>>0&(0|(Q=o>>>0<4?Q+1|0:Q))>=(0|(i=D[y+12>>2]))|(0|Q)>(0|i))break A;D[I+56>>2]=o=e[0|(o=g+D[y>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[y+16>>2]=E,D[y+20>>2]=Q;break g}if(!yg(1,I+56|0,D[E+32>>2]))break A;o=D[I+56>>2]}if(o>>>0>1431655765|k[C>>2]>s(o,3)>>>0)break A;if((0|(g=D[(E=D[(K=D[A+4>>2])+32>>2])+12>>2]))<=(0|(Q=D[E+20>>2]))&(F=D[E+16>>2])>>>0>=(i=n=D[E+8>>2])>>>0|(0|Q)>(0|g))break A;if(t=e[(y=D[E>>2])+F|0],i=(C=F+1|0)?Q:Q+1|0,D[E+16>>2]=C,D[E+20>>2]=i,e[K+36|0]<=1){if((i=F+5|0)>>>0>n>>>0&(0|(Q=i>>>0<5?Q+1|0:Q))>=(0|g)|(0|Q)>(0|g))break A;D[I+52>>2]=C=e[0|(g=C+y|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[E+16>>2]=i,D[E+20>>2]=Q}else{if(!yg(1,I+52|0,E))break A;C=D[I+52>>2]}if(((C>>>0)/3|0)+C>>>0<o>>>0|C>>>0>o>>>0)break A;if(y=D[(Q=D[A+4>>2])+32>>2],e[Q+36|0]<=1){if(Q=D[y+20>>2],Q=(E=(g=D[y+16>>2])+4|0)>>>0<4?Q+1|0:Q,(i=E)>>>0>k[y+8>>2]&(0|(E=D[y+12>>2]))<=(0|Q)|(0|Q)>(0|E))break A;D[I+48>>2]=g=e[0|(E=g+D[y>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[y+16>>2]=i,D[y+20>>2]=Q}else{if(!yg(1,I+48|0,y))break A;g=D[I+48>>2]}if(C>>>0<g>>>0)break A;if(D[A+28>>2]=D[A+24>>2],tg(Q=DC(88)),E=D[A+8>>2],D[A+8>>2]=Q,E&&(Yg(E),!D[A+8>>2]))break A;if(D[A+164>>2]=D[A+160>>2],Sg(A+160|0,o),D[A+176>>2]=D[A+172>>2],Sg(A+172|0,o),D[A- -64>>2]=0,D[A+92>>2]=-1,D[A+84>>2]=-1,D[A+88>>2]=-1,D[A+40>>2]=D[A+36>>2],D[A+52>>2]=D[A+48>>2],D[A+76>>2]=D[A+72>>2],lg(V=A+216|0),kA(V,t),!WI(D[A+8>>2],o,D[A+156>>2]+g|0))break A;if(Q=D[A+156>>2],B[0|I]=1,hI(A+120|0,Q+g|0,I),(Q=65535&((Q=f[(o=D[A+4>>2])+36>>1])<<8|Q>>>8))>>>0<=513){if(y=D[o+32>>2],Q>>>0<=511){if(Q=D[y+20>>2],Q=(o=(i=D[y+16>>2])+4|0)>>>0<4?Q+1|0:Q,(E=o)>>>0>k[y+8>>2]&(0|(o=D[y+12>>2]))<=(0|Q)|(0|Q)>(0|o))break A;o=e[0|(o=i+D[y>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[y+16>>2]=E,D[y+20>>2]=Q}else{if(!yg(1,I+44|0,y))break A;o=D[I+44>>2]}if(!o)break A;if((E=(i=D[(y=D[D[A+4>>2]+32>>2])+8>>2])-(Q=D[y+16>>2])|0)>>>0<o>>>0&(0|(Q=D[y+12>>2]-(D[y+20>>2]+(Q>>>0>i>>>0)|0)|0))<=0|(0|Q)<0)break A;if(r[I+38>>1]=0,D[I>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,D[I+24>>2]=0,D[I+28>>2]=0,B[I+29|0]=0,B[I+30|0]=0,B[I+31|0]=0,B[I+32|0]=0,B[I+33|0]=0,B[I+34|0]=0,B[I+35|0]=0,B[I+36|0]=0,i=((Q=D[(E=y=D[D[A+4>>2]+32>>2])+16>>2])+D[E>>2]|0)+o|0,Q=((E=D[E+8>>2])-Q|0)-o|0,r[I+38>>1]=f[y+38>>1],D[I>>2]=i,D[I+16>>2]=0,D[I+20>>2]=0,D[I+8>>2]=Q,D[I+12>>2]=0,-1==(0|(y=AA(A,I))))break A;m=y>>31}else if(y=-1,m=-1,-1==(0|AA(A,D[o+32>>2])))break A;kg(p=A+232|0,A),Z=A,x=0|RQ[D[D[A>>2]+36>>2]](A),D[Z+380>>2]=x,D[A+372>>2]=t,D[A+384>>2]=D[A+156>>2]+g,r[I+38>>1]=0,D[I>>2]=0,D[(Q=I)+8>>2]=0,D[Q+12>>2]=0,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+24>>2]=0,D[Q+28>>2]=0,B[Q+29|0]=0,B[Q+30|0]=0,B[Q+31|0]=0,B[Q+32|0]=0,B[Q+33|0]=0,B[Q+34|0]=0,B[Q+35|0]=0,B[Q+36|0]=0,F=0,d=n=d-16|0,JA(p,Q)&&(o=Q,Q=D[Q+20>>2],Q=(E=(i=D[o+16>>2])+4|0)>>>0<4?Q+1|0:Q,(g=E)>>>0>k[o+8>>2]&(0|(E=D[o+12>>2]))<=(0|Q)|(0|Q)>(0|E)||(E=e[0|(E=i+D[o>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[o+16>>2]=g,D[o+20>>2]=Q,(0|E)<0||(0|(g=D[p+152>>2]))<=(0|E)||(D[n+12>>2]=0,(E=D[p+160>>2]-(Q=D[p+156>>2])>>2)>>>0<g>>>0?ZA(p+156|0,g-E|0,n+12|0):g>>>0>=E>>>0||(D[p+160>>2]=Q+(g<<2)),F=TA(p+168|0,o)))),d=n+16|0;g:if(F){g=0,F=0,E=0,Q=0,o=0,K=0,d=R=d-96|0,D[R+72>>2]=0,D[R+64>>2]=0,D[R+68>>2]=0,D[R+48>>2]=0,D[R+52>>2]=0,D[R+40>>2]=0,D[R+44>>2]=0,D[R+56>>2]=1065353216,D[R+32>>2]=0,D[R+24>>2]=0,D[R+28>>2]=0,G=1,a=A,_=D[A+124>>2];C:{Q:{B:{E:{n=C;i:{o:if(!((0|C)<=0)){for(q=a+400|0,T=a+232|0,l=D[a+216>>2]!=D[a+220>>2];;){K=(t=K)+1|0;a:{r:{D:{e:{if(-1==D[a+420>>2]||!ug(q)){if(e[a+308|0]){if((A=(c=D[a+296>>2])+((w=D[a+304>>2])>>>3|0)|0)>>>0>=(b=D[a+300>>2])>>>0)break e;if(i=e[0|A],D[a+304>>2]=A=w+1|0,!(i>>>(7&w)&1))break e;(i=c+(N=A>>>3|0)|0)>>>0>=b>>>0?(i=A,A=0):(C=e[0|i],D[a+304>>2]=i=w+2|0,N=i>>>3|0,A=C>>>(7&A)&1),(C=N+c|0)>>>0<b>>>0?(C=e[0|C],D[a+304>>2]=i+1,i=C>>>(7&i)<<1&2):i=0,C=(A|i)<<1|1}else C=1;D[a+416>>2]=C;break r}if(D[a+416>>2]=C=D[a+420>>2],C)break r;break D}D[a+416>>2]=0}if((0|g)==(0|F)){i=-1;break i}b=-1,M=D[a+8>>2],C=-1,-1!=(0|(L=D[(c=g-4|0)>>2]))&&(C=-1,-1!=(0|(i=((i=L+1|0)>>>0)%3|0?i:L-2|0))&&(C=D[D[M>>2]+(i<<2)>>2])),-1!=(0|(i=D[(A=w=D[M+24>>2])+(C<<2)>>2]))&&(b=((A=i+1|0)>>>0)%3|0?A:i-2|0),i=D[M+12>>2],J=s(t,3),D[i+(L<<2)>>2]=A=J+1|0,D[(N=A<<2)+i>>2]=L,D[i+(b<<2)>>2]=h=J+2|0,D[(t=h<<2)+i>>2]=b,G=-1,A=-1;D:if(-1!=(0|L)){if((L>>>0)%3|0)i=L-1|0;else if(A=-1,-1==(0|(i=L+2|0)))break D;A=D[D[M>>2]+(i<<2)>>2]}if(-1!=(0|b)&&-1!=(0|(i=((i=b+1|0)>>>0)%3|0?i:b-2|0))&&(G=D[D[M>>2]+(i<<2)>>2]),i=-1,(0|A)==(0|C)|(0|C)==(0|G))break i;D[(i=D[M>>2])+(J<<2)>>2]=C,D[i+N>>2]=G,D[i+t>>2]=A,-1!=(0|A)&&(D[w+(A<<2)>>2]=h),A=D[(i=D[a+120>>2]+(C>>>3&536870908)|0)>>2],Z=i,x=JC(C)&A,D[Z>>2]=x,D[c>>2]=J,HA(T,J);break a}i=-1;r:{D:{e:{f:{k:{t:{N:{s:{F:{n:switch(C-1|0){case 2:case 4:if((0|Q)==(0|g))break i;if(N=D[(c=D[a+8>>2])+12>>2],w=s(t,3),D[N+(A=(C=w+((b=5==(0|C))?2:1)|0)<<2)>>2]=J=D[(F=g-4|0)>>2],D[N+(J<<2)>>2]=C,Bg(c+24|0),D[(g=D[a+8>>2])+28>>2]-(N=D[g+24>>2])>>2>(0|_))break i;if(D[(L=(h=D[g>>2])+A|0)>>2]=A=((g=D[c+28>>2]-D[c+24>>2]|0)>>2)-1|0,g&&(D[N+(A<<2)>>2]=C),c=b?w:w+2|0,g=h+(b+w<<2)|0,-1!=(0|J)){R:{y:{if((J>>>0)%3|0)C=J-1|0;else if(-1==(0|(C=J+2|0)))break y;if(D[h+(c<<2)>>2]=A=D[h+(C<<2)>>2],-1==(0|A))break R;D[N+(A<<2)>>2]=c;break R}D[h+(c<<2)>>2]=-1}C=-1,-1!=(0|(A=((A=J+1|0)>>>0)%3|0?A:J-2|0))&&(C=D[h+(A<<2)>>2])}else D[h+(c<<2)>>2]=-1,C=-1;D[g>>2]=C,D[F>>2]=w;break F;case 0:if((0|g)==(0|F))break i;M=D[(E=g-4|0)>>2],D[R+68>>2]=E;R:if((c=D[R+44>>2])&&(C=D[R+40>>2],A=t&c+2147483647,(b=bC(c)>>>0>1)&&((A=t)>>>0<c>>>0||(A=(t>>>0)%(c>>>0)|0)),(A=D[C+((N=A)<<2)>>2])&&(C=D[A>>2]))){y:{if(!b){for(b=c-1|0;;){G:{if((0|(A=D[C+4>>2]))!=(0|t)){if((0|N)==(A&b))break G;break R}if((0|t)==D[C+8>>2])break y}if(!(C=D[C>>2]))break}break R}for(;;){G:{if((0|(A=D[C+4>>2]))!=(0|t)){if(A>>>0>=c>>>0&&(A=(A>>>0)%(c>>>0)|0),(0|A)==(0|N))break G;break R}if((0|t)==D[C+8>>2])break y}if(!(C=D[C>>2]))break}break R}if((0|E)==(0|W)){if((Q=1+(E=(N=W-F|0)>>2)|0)>>>0>=1073741824)break t;if(A=N>>1,g=E>>>0<536870911?A>>>0<Q>>>0?Q:A:1073741823){if(g>>>0>=1073741824)break Q;Q=DC(g<<2)}else Q=0;D[(A=Q+(E<<2)|0)>>2]=D[C+12>>2],W=(g<<2)+Q|0,E=A+4|0,(0|N)>0&&xA(Q,F,N),D[R+72>>2]=W,D[R+68>>2]=E,D[R+64>>2]=Q,F&&sA(F)}else D[E>>2]=D[C+12>>2],D[R+68>>2]=g,E=g}if((0|Q)==(0|E))break N;if(!(C=-1==(0|(J=D[(N=E-4|0)>>2])))&-1!=D[D[(h=D[a+8>>2])+12>>2]+(J<<2)>>2])break N;if(-1!=(0|M)&-1!=D[(w=D[h+12>>2])+(M<<2)>>2])break N;if(c=s(t,3),D[w+(J<<2)>>2]=t=c+2|0,D[(F=t<<2)+w>>2]=J,D[w+(M<<2)>>2]=A=c+1|0,D[(g=A<<2)+w>>2]=M,C)break k;if((J>>>0)%3|0){i=J-1|0;break e}if(-1!=(0|(i=J+2|0)))break e;G=D[h>>2],A=-1;break D;case 6:break n;default:break i}if(Bg((A=D[a+8>>2])+24|0),E=D[a+8>>2],h=s(t,3),D[D[E>>2]+(h<<2)>>2]=C=(c=(b=D[A+28>>2]-D[A+24>>2]|0)>>2)-1|0,Bg(E+24|0),D[D[E>>2]+((N=h+1|0)<<2)>>2]=(D[E+28>>2]-D[E+24>>2]>>2)-1,Bg((A=D[a+8>>2])+24|0),D[D[A>>2]+((E=h+2|0)<<2)>>2]=(D[A+28>>2]-D[A+24>>2]>>2)-1,D[(A=D[a+8>>2])+28>>2]-(w=D[A+24>>2])>>2>(0|_))break i;n:{if(b){if(D[w+(C<<2)>>2]=h,C=0,-4!=(0|b)&&(D[w+(c<<2)>>2]=N,-1==(0|(C=c+1|0))))break n}else D[w+(c<<2)>>2]=N,C=1;D[w+(C<<2)>>2]=E}if((0|g)!=(0|W)){D[g>>2]=h,D[R+68>>2]=E=g+4|0;break s}if((Q=1+(E=(C=W-F|0)>>2)|0)>>>0>=1073741824)break f;if(A=C>>1,g=E>>>0<536870911?A>>>0<Q>>>0?Q:A:1073741823){if(g>>>0>=1073741824)break Q;Q=DC(g<<2)}else Q=0;D[(A=Q+(E<<2)|0)>>2]=h,W=(g<<2)+Q|0,E=A+4|0,(0|C)>0&&xA(Q,F,C),D[R+72>>2]=W,D[R+68>>2]=E,D[R+64>>2]=Q,F&&sA(F)}F=Q}HA(T,D[E-4>>2]);s:if((0|(C=D[a+40>>2]))!=D[a+36>>2])for(b=n+(-1^t)|0,N=E-4|0;;){if((A=D[C-8>>2])>>>0>b>>>0)break N;if((0|A)!=(0|b))break s;if(t=e[C-4|0],g=D[(A=C-12|0)>>2],D[a+40>>2]=A,(0|g)<0)break N;C=D[N>>2],D[R+20>>2]=n+(-1^g),D[R+88>>2]=A=R+20|0,FA(R,R+40|0,A,R+88|0),g=D[R>>2];F:if(1&t){if(A=-1,-1==(0|C))break F;A=((A=C+1|0)>>>0)%3|0?A:C-2|0}else A=-1,-1!=(0|C)&&(A=C-1|0,(C>>>0)%3|0||(A=C+2|0));if(D[g+12>>2]=A,(0|(C=D[a+40>>2]))==D[a+36>>2])break}g=E;break a}if(G)break i;break o}iQ(),U()}b=-1,D[(G=D[h>>2])+(c<<2)>>2]=-1,i=-1;break r}iQ(),U()}A=D[(G=D[h>>2])+(i<<2)>>2]}b=A,D[(c<<2)+G>>2]=A,i=-1,-1!=(0|(A=((A=J+1|0)>>>0)%3|0?A:J-2|0))&&(i=D[(A<<2)+G>>2])}if(D[g+G>>2]=i,-1!=(0|M)){r:{D:{if((M>>>0)%3|0)i=M-1|0;else if(-1==(0|(i=M+2|0)))break D;if(D[F+G>>2]=A=D[(i<<2)+G>>2],-1==(0|A))break r;D[D[h+24>>2]+(A<<2)>>2]=t;break r}D[F+G>>2]=-1}F=-1,i=-1,-1!=(0|(A=((A=M+1|0)>>>0)%3|0?A:M-2|0))&&(F=D[(A<<2)+G>>2],i=A)}else D[F+G>>2]=-1,F=-1,i=-1;D[(t=A=(C=D[a+388>>2])+(g=b<<2)|0)>>2]=(L=D[A>>2])+D[(A=F<<2)+C>>2],C=(t=A)+(A=D[h+24>>2])|0,-1!=(0|b)&&(D[A+g>>2]=D[C>>2]);r:if(-1!=(0|i))for(;;){if(D[(i<<2)+G>>2]=b,-1==(0|(A=((A=i+1|0)>>>0)%3|0?A:i-2|0)))break r;if(-1==(0|(g=D[w+(A<<2)>>2])))break r;if(-1==(0|(i=((A=g+1|0)>>>0)%3|0?A:g-2|0)))break}D[C>>2]=-1;r:if(!l){if((0|u)==(0|H)){D:{if((o=1+(g=(C=u-Y|0)>>2)|0)>>>0<1073741824){if(A=C>>1,i=g>>>0<536870911?A>>>0<o>>>0?o:A:1073741823){if(i>>>0>=1073741824)break D;o=DC(i<<2)}else o=0;D[(A=o+(g<<2)|0)>>2]=F,u=(i<<2)+o|0,H=A+4|0,(0|C)>0&&xA(o,Y,C),D[R+32>>2]=u,D[R+28>>2]=H,D[R+24>>2]=o,Y&&sA(Y),Y=o;break r}iQ(),U()}break Q}D[H>>2]=F,D[R+28>>2]=H=H+4|0}D[N>>2]=c,g=E,F=Q,HA(T,c)}if(G=(0|n)>(0|K),(0|n)==(0|K))break}K=n}if(i=-1,!(D[(G=D[a+8>>2])+28>>2]-D[G+24>>2]>>2>(0|_))){if((0|Q)!=(0|E)){for(A=a+60|0,c=a+312|0;;){l=D[(E=E-4|0)>>2],D[R+68>>2]=E;o:{a:{r:{if(f[a+270>>1]<=513){if(!e[a+364|0])break r;if((g=D[a+352>>2]+((C=D[a+360>>2])>>>3|0)|0)>>>0>=k[a+356>>2])break a;g=e[0|g],D[a+360>>2]=C+1,g=g>>>(7&C)&1}else g=ug(c);if(!g)break a}if(((D[(w=D[a+8>>2])+4>>2]-(u=D[w>>2])>>2>>>0)/3|0)<=(0|K))break i;if(C=-1,F=-1,b=-1,n=-1,-1!=(0|l)&&(n=-1,-1!=(0|(g=((g=l+1|0)>>>0)%3|0?g:l-2|0))&&(n=D[u+(g<<2)>>2])),g=-1,-1!=(0|(N=D[(n<<2)+(t=Y=D[w+24>>2])>>2]))&&(g=-1,-1!=(0|(t=((t=N+1|0)>>>0)%3|0?t:N-2|0))&&(C=t,g=-1!=(0|(g=((g=t+1|0)>>>0)%3|0?g:C-2|0))?D[u+(g<<2)>>2]:-1)),N=-1,-1!=(0|(Y=D[Y+(g<<2)>>2]))&&(N=-1,-1!=(0|(t=((t=Y+1|0)>>>0)%3|0?t:Y-2|0))&&(-1!=(0|(N=((N=t+1|0)>>>0)%3|0?N:t-2|0))&&(b=D[u+(N<<2)>>2]),N=t)),q=D[w+12>>2],h=s(K,3),D[q+(Y=h<<2)>>2]=l,D[q+(l<<2)>>2]=h,D[(t=(l=h+1|0)<<2)+q>>2]=C,D[q+(C<<2)>>2]=l,D[(C=(w=h+2|0)<<2)+q>>2]=N,D[q+(N<<2)>>2]=w,D[Y+u>>2]=g,D[(N=t+u|0)>>2]=b,D[(t=C+u|0)>>2]=n,g=D[(C=(Y=D[a+120>>2])+((n=h>>>0>l>>>0?-1:g)>>>3&536870908)|0)>>2],Z=C,x=JC(n)&g,D[Z>>2]=x,g=D[(C=Y+((F=-1!=(0|l)?D[N>>2]:F)>>>3&536870908)|0)>>2],Z=C,x=JC(F)&g,D[Z>>2]=x,C=-1,g=D[(n=Y+((C=-1!=(0|w)?D[t>>2]:C)>>>3&536870908)|0)>>2],Z=n,x=JC(C)&g,D[Z>>2]=x,(0|(C=D[a+64>>2]))==(g=D[a+68>>2])<<5){if((C+1|0)<0)break E;vI(A,g=C>>>0<=1073741822?(C=C+32&-32)>>>0>(g<<=6)>>>0?C:g:2147483647),C=D[a+64>>2]}if(K=K+1|0,D[a+64>>2]=C+1,D[(g=D[a+60>>2]+(C>>>3&536870908)|0)>>2]=D[g>>2]|1<<C,(0|(g=D[a+76>>2]))!=D[a+80>>2]){D[g>>2]=h,D[a+76>>2]=g+4;break o}if((C=1+(n=(F=g-(N=D[a+72>>2])|0)>>2)|0)>>>0>=1073741824)break B;if(g=F>>1,t=n>>>0<536870911?C>>>0>g>>>0?C:g:1073741823){if(t>>>0>=1073741824)break Q;g=DC(t<<2)}else g=0;if(D[(C=g+(n<<2)|0)>>2]=h,(0|F)>0&&xA(g,N,F),D[a+80>>2]=g+(t<<2),D[a+76>>2]=C+4,D[a+72>>2]=g,!N)break o;sA(N);break o}if((0|(G=D[a+64>>2]))==(g=D[a+68>>2])<<5){if((G+1|0)<0)break E;vI(A,g=G>>>0<=1073741822?(C=G+32&-32)>>>0>(g<<=6)>>>0?C:g:2147483647),G=D[a+64>>2]}if(D[a+64>>2]=G+1,g=D[(C=D[a+60>>2]+(G>>>3&536870908)|0)>>2],Z=C,x=JC(G)&g,D[Z>>2]=x,(0|(g=D[a+76>>2]))==D[a+80>>2]){if((C=1+(n=(F=g-(N=D[a+72>>2])|0)>>2)|0)>>>0>=1073741824)break B;if(g=F>>1,t=n>>>0<536870911?C>>>0>g>>>0?C:g:1073741823){if(t>>>0>=1073741824)break Q;g=DC(t<<2)}else g=0;D[(C=g+(n<<2)|0)>>2]=l,(0|F)>0&&xA(g,N,F),D[a+80>>2]=g+(t<<2),D[a+76>>2]=C+4,D[a+72>>2]=g,N&&sA(N)}else D[g>>2]=l,D[a+76>>2]=g+4}if((0|Q)==(0|E))break}G=D[a+8>>2]}if(((D[G+4>>2]-D[G>>2]>>2>>>0)/3|0)==(0|K))if(i=D[G+28>>2]-(E=D[G+24>>2])>>2,(0|o)!=(0|H))for(A=o;;){if(n=D[A>>2],-1==D[(g=((C=i-1|0)<<2)+E|0)>>2])for(;C=i-2|0,i=i-1|0,-1==D[(g=(C<<2)+E|0)>>2];);if(C>>>0>=n>>>0){if(D[R>>2]=G,E=D[g>>2],B[R+12|0]=1,D[R+8>>2]=E,D[R+4>>2]=E,-1!=(0|E))for(;D[D[G>>2]+(E<<2)>>2]=n,FI(R),G=D[a+8>>2],-1!=(0|(E=D[R+8>>2])););g=(E=D[G+24>>2])+(C<<2)|0,-1!=(0|n)&&(D[(n<<2)+E>>2]=D[g>>2]),D[g>>2]=-1,t=1<<n,n=(g=D[a+120>>2])+(n>>>3&536870908)|0,D[(K=g+(C>>>3&536870908)|0)>>2]&(g=1<<C)?t|=D[n>>2]:t=D[n>>2]&(-1^t),D[n>>2]=t,D[K>>2]=D[K>>2]&(-1^g),i=i-1|0}if((0|H)==(0|(A=A+4|0)))break}else o=H}}if(o&&sA(o),A=D[R+48>>2])for(;o=D[A>>2],sA(A),A=o;);A=D[R+40>>2],D[R+40>>2]=0,A&&sA(A),Q&&(D[R+68>>2]=Q,sA(Q)),d=R+96|0;break C}iQ(),U()}iQ(),U()}xg(1336),U()}if(-1!=(0|i)){o=(A=D[I+16>>2])+D[I>>2]|0,A=(Q=D[I+8>>2])-A|0,r[(Q=D[D[a+4>>2]+32>>2])+38>>1]=f[Q+38>>1],D[Q>>2]=o,D[Q+16>>2]=0,D[Q+20>>2]=0,D[Q+8>>2]=A,D[Q+12>>2]=0,(65535&(o=(A=f[(Q=D[a+4>>2])+36>>1])<<8|A>>>8))>>>0<=513&&(Q=m+D[(A=D[Q+32>>2])+20>>2]|0,Q=(E=y+D[A+16>>2]|0)>>>0<y>>>0?Q+1|0:Q,D[A+16>>2]=E,D[A+20>>2]=Q);C:if(D[a+216>>2]!=D[a+220>>2]){if(Q=D[(A=D[a+8>>2])>>2],A=D[A+4>>2],!((65535&o)>>>0>=513)){if((0|A)==(0|Q))break C;for(E=0;;){if(KA(a,E)){if((E=E+3|0)>>>0<D[(A=D[a+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break C}break}break g}if((0|A)!=(0|Q)){for(E=0;;){if(YA(a,E)){if((E=E+3|0)>>>0<D[(A=D[a+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break C}break}break g}}if(og(p),(0|(E=D[a+216>>2]))!=D[a+220>>2])for(o=0;;){if(oI(4+((Q=s(o,144))+E|0)|0,D[a+8>>2]),(0|(E=D[132+(A=Q+(S=D[V>>2])|0)>>2]))!=(0|(A=D[A+136>>2])))for(;fI(4+(Q+S|0)|0,D[E>>2]),S=D[V>>2],(0|A)!=(0|(E=E+4|0)););if(nA(4+(Q+S|0)|0),!((o=o+1|0)>>>0<(D[a+220>>2]-(E=D[a+216>>2])|0)/144>>>0))break}if(ig(a+184|0,D[(A=D[a+8>>2])+28>>2]-D[A+24>>2]>>2),(0|(S=D[a+216>>2]))!=D[a+220>>2])for(E=0;A=s(E,144)+S|0,Q=D[A+60>>2]-D[A+56>>2]>>2,ig(o=A+104|0,(0|(A=D[(A=D[a+8>>2])+28>>2]-D[A+24>>2]>>2))>(0|Q)?A:Q),(E=E+1|0)>>>0<(D[a+220>>2]-(S=D[a+216>>2])|0)/144>>>0;);S=QA(a,i)}}break A}S=0}return d=I- -64|0,0|S},EQ,ZC,xC,qA,function(A){sA(qA(A|=0))},uC,_I,OI,P,function(A){var I,g=0,C=0,Q=0,E=0,i=0,o=0,a=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0,q=0,W=0,V=0,_=0,T=0,m=0,Z=0;if(d=I=d+-64|0,D[132+(A|=0)>>2]=0,D[A+148>>2]){if(g=D[A+144>>2])for(;C=D[g>>2],sA(g),g=C;);if(g=0,D[A+144>>2]=0,C=D[A+140>>2]){if(C-1>>>0>=3)for(F=-4&C;D[(i=g<<2)+D[A+136>>2]>>2]=0,D[D[A+136>>2]+(4|i)>>2]=0,D[D[A+136>>2]+(8|i)>>2]=0,D[D[A+136>>2]+(12|i)>>2]=0,g=g+4|0,(0|F)!=(0|(o=o+4|0)););if(C&=3)for(;D[D[A+136>>2]+(g<<2)>>2]=0,g=g+1|0,(0|C)!=(0|(b=b+1|0)););}D[A+148>>2]=0}A:{I:{g:{if(!((o=(b=e[(g=D[A+4>>2])+36|0])<<8|e[g+37|0])>>>0>513))if(C=D[g+32>>2],o>>>0<=511){if(o=D[C+20>>2],(0|(E=D[C+12>>2]))<=(0|(o=(F=(i=D[C+16>>2])+4|0)>>>0<4?o+1|0:o))&F>>>0>k[C+8>>2]|(0|E)<(0|o))break g;i=e[0|(i=i+D[C>>2]|0)]|e[i+1|0]<<8|e[i+2|0]<<16|e[i+3|0]<<24,D[C+16>>2]=F,D[C+20>>2]=o,D[A+132>>2]=i}else{if(!yg(1,I,C))break g;b=e[(g=D[A+4>>2])+36|0],D[A+132>>2]=D[I>>2]}o=D[g+32>>2];C:{Q:{if((255&b)>>>0<=1){if(b=0,C=D[o+20>>2],(0|(E=D[o+12>>2]))<=(0|(C=(F=(i=D[o+16>>2])+4|0)>>>0<4?C+1|0:C))&F>>>0>k[o+8>>2]|(0|C)>(0|E))break I;D[I+60>>2]=i=e[0|(i=i+D[o>>2]|0)]|e[i+1|0]<<8|e[i+2|0]<<16|e[i+3|0]<<24,D[o+16>>2]=F,D[o+20>>2]=C,D[A+156>>2]=i,i=A+156|0}else{if(b=0,!yg(1,I+60|0,o))break I;if(C=e[(g=D[A+4>>2])+36|0],D[A+156>>2]=D[I+60>>2],i=A+156|0,C>>>0>1)break Q}if(N=g=D[(C=D[g+32>>2])+8>>2],g=D[C+20>>2],N>>>0<(E=(F=D[C+16>>2])+4|0)>>>0&(0|(g=E>>>0<4?g+1|0:g))>=(0|(o=D[C+12>>2]))|(0|g)>(0|o))break I;D[I+56>>2]=o=e[0|(o=F+D[C>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[C+16>>2]=E,D[C+20>>2]=g;break C}if(!yg(1,I+56|0,D[g+32>>2]))break I;o=D[I+56>>2]}if(o>>>0>1431655765|k[i>>2]>s(o,3)>>>0)break I;if((0|(i=D[(g=F=D[(n=D[A+4>>2])+32>>2])+12>>2]))<=(0|(C=D[g+20>>2]))&(R=D[g+8>>2])>>>0<=(E=D[g+16>>2])>>>0|(0|C)>(0|i))break I;if(N=e[(L=D[F>>2])+E|0],g=C,g=(t=E+1|0)?g:g+1|0,D[F+16>>2]=t,D[F+20>>2]=g,e[n+36|0]<=1){if((0|(g=i))<=(0|(C=(i=E+5|0)>>>0<5?C+1|0:C))&(E=i)>>>0>R>>>0|(0|g)<(0|C))break I;D[I+52>>2]=i=e[0|(g=t+L|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[F+16>>2]=E,D[F+20>>2]=C}else{if(!yg(1,I+52|0,F))break I;i=D[I+52>>2]}if(((i>>>0)/3|0)+i>>>0<o>>>0|i>>>0>o>>>0)break I;if(F=D[(g=D[A+4>>2])+32>>2],e[g+36|0]<=1){if(g=D[F+20>>2],(0|(n=D[F+12>>2]))<=(0|(g=(E=(C=D[F+16>>2])+4|0)>>>0<4?g+1|0:g))&E>>>0>k[F+8>>2]|(0|g)>(0|n))break I;D[I+48>>2]=C=e[0|(C=C+D[F>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[F+16>>2]=E,D[F+20>>2]=g}else{if(!yg(1,I+48|0,F))break I;C=D[I+48>>2]}if(C>>>0>i>>>0)break I;if(D[A+28>>2]=D[A+24>>2],tg(F=DC(88)),g=D[A+8>>2],D[A+8>>2]=F,g&&(Yg(g),!D[A+8>>2]))break I;if(D[A+164>>2]=D[A+160>>2],Sg(A+160|0,o),D[A+176>>2]=D[A+172>>2],Sg(A+172|0,o),D[A- -64>>2]=0,D[A+92>>2]=-1,D[A+84>>2]=-1,D[A+88>>2]=-1,D[A+40>>2]=D[A+36>>2],D[A+52>>2]=D[A+48>>2],D[A+76>>2]=D[A+72>>2],lg(W=A+216|0),kA(W,N),!WI(D[A+8>>2],o,D[A+156>>2]+C|0))break I;if(g=D[A+156>>2],B[0|I]=1,hI(A+120|0,g+C|0,I),(o=65535&((o=f[(g=D[A+4>>2])+36>>1])<<8|o>>>8))>>>0<=513){if(F=D[g+32>>2],o>>>0<=511){if(o=D[F+20>>2],(n=g=(E=D[F+16>>2])+4|0)>>>0>k[F+8>>2]&(0|(g=o=g>>>0<4?o+1|0:o))>=(0|(R=D[F+12>>2]))|(0|g)>(0|R))break I;o=e[0|(o=E+D[F>>2]|0)]|e[o+1|0]<<8|e[o+2|0]<<16|e[o+3|0]<<24,D[F+16>>2]=n,D[F+20>>2]=g}else{if(!yg(1,I+44|0,F))break I;o=D[I+44>>2]}if(!o)break I;if((0|(g=D[(g=D[D[A+4>>2]+32>>2])+12>>2]-(D[g+20>>2]+((E=D[g+16>>2])>>>0>(F=D[g+8>>2])>>>0)|0)|0))<=0&o>>>0>(n=F-E|0)>>>0|(0|g)<0)break I;if(r[I+38>>1]=0,D[I>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,D[I+24>>2]=0,D[I+28>>2]=0,B[I+29|0]=0,B[I+30|0]=0,B[I+31|0]=0,B[I+32|0]=0,B[I+33|0]=0,B[I+34|0]=0,B[I+35|0]=0,B[I+36|0]=0,E=((g=D[(F=D[D[A+4>>2]+32>>2])+16>>2])+D[F>>2]|0)+o|0,g=((n=D[F+8>>2])-g|0)-o|0,r[I+38>>1]=f[F+38>>1],D[I>>2]=E,D[I+16>>2]=0,D[I+20>>2]=0,D[I+8>>2]=g,D[I+12>>2]=0,-1==(0|(L=AA(A,I))))break I;V=L>>31}else if(L=-1,V=-1,-1==(0|AA(A,D[g+32>>2])))break I;kg(E=A+232|0,A),m=A,Z=0|RQ[D[D[A>>2]+36>>2]](A),D[m+380>>2]=Z,D[A+372>>2]=N,D[A+384>>2]=D[A+156>>2]+C,r[I+38>>1]=0,D[I>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,D[I+16>>2]=0,D[I+20>>2]=0,D[I+24>>2]=0,D[I+28>>2]=0,B[I+29|0]=0,B[I+30|0]=0,B[I+31|0]=0,B[I+32|0]=0,B[I+33|0]=0,B[I+34|0]=0,B[I+35|0]=0,B[I+36|0]=0,o=0,d=N=d-16|0;C:{Q:{if((65535&((g=f[36+(0|RQ[D[D[(g=D[E+144>>2])>>2]+32>>2]](g))>>1])<<8|g>>>8))>>>0<=513){if(g=D[E+4>>2],D[E+40>>2]=D[E>>2],D[E+44>>2]=g,g=D[E+36>>2],D[E+72>>2]=D[E+32>>2],D[E+76>>2]=g,C=D[E+28>>2],D[(g=E- -64|0)>>2]=D[E+24>>2],D[g+4>>2]=C,g=D[E+20>>2],D[E+56>>2]=D[E+16>>2],D[E+60>>2]=g,g=D[E+12>>2],D[E+48>>2]=D[E+8>>2],D[E+52>>2]=g,!dI(E+40|0,1,N+8|0))break Q;if(g=D[E+44>>2],D[E>>2]=D[E+40>>2],D[E+4>>2]=g,g=D[E+76>>2],D[E+32>>2]=D[E+72>>2],D[E+36>>2]=g,g=D[E+68>>2],D[E+24>>2]=D[E+64>>2],D[E+28>>2]=g,F=C=D[E+60>>2],D[E+16>>2]=g=D[E+56>>2],D[E+20>>2]=C,n=D[E+52>>2],D[E+8>>2]=C=D[E+48>>2],D[E+12>>2]=n,R=C-g|0,(0|(t=D[N+12>>2]))==(0|(C=n-((g>>>0>C>>>0)+F|0)|0))&R>>>0<(n=D[N+8>>2])>>>0|C>>>0<t>>>0)break Q;C=g,n=g+n|0,g=t+F|0,D[E+16>>2]=n,D[E+20>>2]=C>>>0>n>>>0?g+1|0:g}if(f[E+38>>1]<=513){if(g=D[E+4>>2],D[E+96>>2]=D[E>>2],D[E+100>>2]=g,g=D[E+36>>2],D[E+128>>2]=D[E+32>>2],D[E+132>>2]=g,g=D[E+28>>2],D[E+120>>2]=D[E+24>>2],D[E+124>>2]=g,g=D[E+20>>2],D[E+112>>2]=D[E+16>>2],D[E+116>>2]=g,g=D[E+12>>2],D[E+104>>2]=D[E+8>>2],D[E+108>>2]=g,!dI(E+96|0,1,N+8|0))break Q;if(g=D[E+100>>2],D[E>>2]=D[E+96>>2],D[E+4>>2]=g,g=D[E+132>>2],D[E+32>>2]=D[E+128>>2],D[E+36>>2]=g,g=D[E+124>>2],D[E+24>>2]=D[E+120>>2],D[E+28>>2]=g,F=C=D[E+116>>2],D[E+16>>2]=g=D[E+112>>2],D[E+20>>2]=C,n=D[E+108>>2],D[E+8>>2]=C=D[E+104>>2],D[E+12>>2]=n,R=C-g|0,(0|(t=D[N+12>>2]))==(0|(C=n-((g>>>0>C>>>0)+F|0)|0))&R>>>0<(n=D[N+8>>2])>>>0|C>>>0<t>>>0)break Q;C=t+F|0,C=(n=g+n|0)>>>0<g>>>0?C+1|0:C,D[E+16>>2]=n,D[E+20>>2]=C}else if(!TA(E+80|0,E))break C;if(!YI(E))break C;if(g=D[E+4>>2],D[I>>2]=D[E>>2],D[I+4>>2]=g,g=D[E+36>>2],D[I+32>>2]=D[E+32>>2],D[I+36>>2]=g,g=D[E+28>>2],D[I+24>>2]=D[E+24>>2],D[I+28>>2]=g,g=D[E+20>>2],D[I+16>>2]=D[E+16>>2],D[I+20>>2]=g,g=D[E+12>>2],D[I+8>>2]=D[E+8>>2],D[I+12>>2]=g,(65535&((g=f[36+(0|RQ[D[D[(g=D[E+144>>2])>>2]+32>>2]](g))>>1])<<8|g>>>8))>>>0<=513){if(e[36+(0|RQ[D[D[(g=D[E+144>>2])>>2]+32>>2]](g))|0]<=1){if(g=D[I+20>>2],(0|(n=D[I+12>>2]))<=(0|(g=(F=(C=D[I+16>>2])+4|0)>>>0<4?g+1|0:g))&F>>>0>k[I+8>>2]|(0|g)>(0|n))break C;C=e[0|(C=C+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=F,D[I+20>>2]=g}else{if(!yg(1,N+8|0,I))break C;C=D[N+8>>2]}if(C>>>0>=(g=D[E+152>>2])>>>0)break C;if((0|(C=D[I+20>>2]))>=(0|(n=D[I+12>>2]))&(F=D[I+16>>2])>>>0>=k[I+8>>2]|(0|C)>(0|n))break C;if(n=e[F+D[I>>2]|0],C=(F=F+1|0)?C:C+1|0,D[I+16>>2]=F,D[I+20>>2]=C,n)break C;D[E+176>>2]=2,D[E+180>>2]=7}else D[E+176>>2]=2,D[E+180>>2]=7,g=D[E+152>>2];if((0|g)<0)break C;if(D[N+8>>2]=0,o=2,(F=D[E+160>>2]-(n=D[E+156>>2])>>2)>>>0<g>>>0?(ZA(E+156|0,g-F|0,N+8|0),o=D[E+176>>2],C=D[E+180>>2]):(C=7,g>>>0>=F>>>0||(D[E+160>>2]=n+(g<<2))),F=E+184|0,(C=1+(C-o|0)|0)>>>0>(o=((g=D[E+188>>2])-(n=D[E+184>>2])|0)/12|0)>>>0){if((C=C-o|0)>>>0<=((R=D[F+8>>2])-(g=D[F+4>>2])|0)/12>>>0)C&&(g=bI(o=g,0,g=s((s(C,12)-12>>>0)/12|0,12)+12|0)+g|0),D[F+4>>2]=g;else{B:{E:{i:{if((o=(t=(g-(n=D[F>>2])|0)/12|0)+C|0)>>>0<357913942){if(a=(R=(R-n|0)/12|0)<<1,R=R>>>0<178956970?o>>>0>a>>>0?o:a:357913941){if(R>>>0>=357913942)break i;Q=DC(s(R,12))}if(t=(C=bI(o=s(t,12)+Q|0,0,t=s((s(C,12)-12>>>0)/12|0,12)+12|0))+t|0,Q=s(R,12)+Q|0,(0|g)==(0|n))break E;for(;D[(o=o-12|0)>>2]=D[(g=g-12|0)>>2],D[o+4>>2]=D[g+4>>2],D[o+8>>2]=D[g+8>>2],D[g+8>>2]=0,D[g>>2]=0,D[g+4>>2]=0,(0|g)!=(0|n););if(D[F+8>>2]=Q,C=D[F+4>>2],D[F+4>>2]=t,g=D[F>>2],D[F>>2]=o,(0|g)==(0|C))break B;for(;(Q=D[(o=C-12|0)>>2])&&(D[C-8>>2]=Q,sA(Q)),(0|(C=o))!=(0|g););break B}break A}xg(1336),U()}D[F+8>>2]=Q,D[F+4>>2]=t,D[F>>2]=C}g&&sA(g)}C=D[E+188>>2]}else if(C>>>0>=o>>>0)C=g;else{if((0|(C=n+s(C,12)|0))!=(0|g))for(;(Q=D[(o=g-12|0)>>2])&&(D[g-8>>2]=Q,sA(Q)),(0|C)!=(0|(g=o)););D[E+188>>2]=C}if(n=E+196|0,(g=(C-(o=D[E+184>>2])|0)/12|0)>>>0>(Q=D[E+200>>2]-(R=D[E+196>>2])>>2)>>>0?($I(n,g-Q|0),o=D[E+184>>2],C=D[E+188>>2]):g>>>0>=Q>>>0||(D[E+200>>2]=R+(g<<2)),(0|C)==(0|o)){o=1;break C}for(g=0;;){if(!yg(1,N+8|0,I))break Q;if((o=D[N+8>>2])>>>0>(D[(C=D[E+148>>2])+4>>2]-D[C>>2]>>2>>>0)/3>>>0)break Q;if(o&&(C=D[F>>2],a=s(g,12),(t=D[4+(Q=C+a|0)>>2]-(R=D[Q>>2])>>2)>>>0<o>>>0?($I(Q,o-t|0),C=D[F>>2]):t>>>0<=o>>>0||(D[Q+4>>2]=R+(o<<2)),H(o,1,I,D[C+a>>2]),D[D[n>>2]+(g<<2)>>2]=o),o=1,!((g=g+1|0)>>>0<(D[E+188>>2]-D[E+184>>2]|0)/12>>>0))break}break C}o=0}d=N+16|0;C:if(o){g=0,N=0,C=0,F=0,o=0,n=0,d=w=d-96|0,D[w+72>>2]=0,D[w+64>>2]=0,D[w+68>>2]=0,D[w+48>>2]=0,D[w+52>>2]=0,D[w+40>>2]=0,D[w+44>>2]=0,D[w+56>>2]=1065353216,D[w+32>>2]=0,D[w+24>>2]=0,D[w+28>>2]=0,Y=1,t=A,M=D[A+124>>2];Q:{B:{R=i;E:{i:if(!((0|i)<=0)){for(p=t+232|0,T=D[t+216>>2]!=D[t+220>>2];;){n=(A=n)+1|0;o:{a:{r:{if(-1!=(0|(Q=D[t+404>>2]))){if(i=-1,D[(a=D[t+428>>2]+(Q<<2)|0)>>2]=Q=(y=D[a>>2])-1|0,(0|y)<=0)break E;if(i=D[D[D[t+416>>2]+s(D[t+404>>2],12)>>2]+(Q<<2)>>2],D[t+400>>2]=a=D[12176+(i<<2)>>2],!i)break r;break a}a=7;D:{if((65535&((i=f[36+(0|RQ[D[D[(i=D[t+376>>2])>>2]+32>>2]](i))>>1])<<8|i>>>8))>>>0<=513){if(!e[t+308|0]){a=1,D[t+400>>2]=1;break a}if((Q=(a=D[t+296>>2])+((i=D[t+304>>2])>>>3|0)|0)>>>0>=(y=D[t+300>>2])>>>0)break D;if(c=e[0|Q],D[t+304>>2]=Q=i+1|0,!(c>>>(7&i)&1))break D;(G=a+(c=Q>>>3|0)|0)>>>0>=y>>>0?(i=Q,Q=0):(G=e[0|G],D[t+304>>2]=i=i+2|0,c=i>>>3|0,Q=G>>>(7&Q)&1),(a=a+c|0)>>>0<y>>>0?(a=e[0|a],D[t+304>>2]=i+1,i=a>>>(7&i)<<1&2):i=0,a=(Q|i)<<1|1}D[t+400>>2]=a;break a}D[t+400>>2]=0}if((0|g)==(0|N)){i=-1;break E}Q=-1,c=D[t+8>>2],a=-1,-1!=(0|(i=D[(K=g-4|0)>>2]))&&(a=-1,-1!=(0|(G=((G=i+1|0)>>>0)%3|0?G:i-2|0))&&(a=D[D[c>>2]+(G<<2)>>2])),-1!=(0|(y=D[(h=D[c+24>>2])+(a<<2)>>2]))&&(Q=((Q=y+1|0)>>>0)%3|0?Q:y-2|0),y=D[c+12>>2],G=s(A,3),D[y+(i<<2)>>2]=A=G+1|0,D[(u=A<<2)+y>>2]=i,D[y+(Q<<2)>>2]=Y=G+2|0,D[(_=Y<<2)+y>>2]=Q,y=-1,A=-1;r:if(-1!=(0|i)){if((i>>>0)%3|0)i=i-1|0;else if(A=-1,-1==(0|(i=i+2|0)))break r;A=D[D[c>>2]+(i<<2)>>2]}if(-1!=(0|Q)&&-1!=(0|(i=((i=Q+1|0)>>>0)%3|0?i:Q-2|0))&&(y=D[D[c>>2]+(i<<2)>>2]),i=-1,(0|A)==(0|a)|(0|a)==(0|y))break E;D[(i=D[c>>2])+(G<<2)>>2]=a,D[i+u>>2]=y,D[i+_>>2]=A,-1!=(0|A)&&(D[h+(A<<2)>>2]=Y),i=D[(A=D[t+120>>2]+(a>>>3&536870908)|0)>>2],m=A,Z=JC(a)&i,D[m>>2]=Z,D[K>>2]=G,VA(p,G);break o}i=-1;a:{r:{D:{e:{f:{k:{t:{N:switch(a-1|0){case 2:case 4:if((0|g)==(0|F))break E;if(N=D[(Q=D[t+8>>2])+12>>2],G=5==(0|a),a=s(A,3),D[N+(h=(y=(G?2:1)+a|0)<<2)>>2]=g=D[(K=g-4|0)>>2],D[N+(g<<2)>>2]=y,Bg(Q+24|0),D[(N=D[t+8>>2])+28>>2]-(c=D[N+24>>2])>>2>(0|M))break E;if(D[(u=(N=D[N>>2])+h|0)>>2]=h=((Q=D[Q+28>>2]-D[Q+24>>2]|0)>>2)-1|0,Q&&(D[c+(h<<2)>>2]=y),y=G?a:a+2|0,h=N+(a+G<<2)|0,-1!=(0|g)){s:{F:{if((g>>>0)%3|0)Q=g-1|0;else if(-1==(0|(Q=g+2|0)))break F;if(D[N+(y<<2)>>2]=Q=D[N+(Q<<2)>>2],-1==(0|Q))break s;D[c+(Q<<2)>>2]=y;break s}D[N+(y<<2)>>2]=-1}Q=-1,-1!=(0|(g=((y=g+1|0)>>>0)%3|0?y:g-2|0))&&(Q=D[N+(g<<2)>>2])}else D[N+(y<<2)>>2]=-1,Q=-1;D[h>>2]=Q,D[K>>2]=a;break t;case 0:if((0|g)==(0|N))break E;c=D[(C=g-4|0)>>2],D[w+68>>2]=C;s:if((G=D[w+44>>2])&&(a=D[w+40>>2],Q=A&G+2147483647,(h=bC(G)>>>0>1)&&(Q=A,A>>>0<G>>>0||(Q=(A>>>0)%(G>>>0)|0)),(Q=D[a+((y=Q)<<2)>>2])&&(a=D[Q>>2]))){F:{if(!h){for(Q=G-1|0;;){n:{if((0|(G=D[a+4>>2]))!=(0|A)){if((0|y)==(Q&G))break n;break s}if((0|A)==D[a+8>>2])break F}if(!(a=D[a>>2]))break}break s}for(;;){n:{if((0|(Q=D[a+4>>2]))!=(0|A)){if(Q>>>0>=G>>>0&&(Q=(Q>>>0)%(G>>>0)|0),(0|Q)==(0|y))break n;break s}if((0|A)==D[a+8>>2])break F}if(!(a=D[a>>2]))break}break s}if((0|C)==(0|J)){if((C=1+(Q=(g=J-N|0)>>2)|0)>>>0>=1073741824)break A;if(F=g>>1,C=Q>>>0<536870911?C>>>0>F>>>0?C:F:1073741823){if(C>>>0>=1073741824)break B;F=DC(C<<2)}else F=0;D[(Q=F+(Q<<2)|0)>>2]=D[a+12>>2],J=(C<<2)+F|0,C=Q+4|0,(0|g)>0&&xA(F,N,g),D[w+72>>2]=J,D[w+68>>2]=C,D[w+64>>2]=F,N&&sA(N)}else D[C>>2]=D[a+12>>2],D[w+68>>2]=g,C=g}if((0|C)==(0|F))break f;if(!(N=-1==(0|(g=D[(h=C-4|0)>>2])))&-1!=D[D[(a=D[t+8>>2])+12>>2]+(g<<2)>>2])break f;if(-1!=(0|c)&-1!=D[(G=D[a+12>>2])+(c<<2)>>2])break f;if(Y=s(A,3),D[G+(g<<2)>>2]=y=Y+2|0,D[(A=y<<2)+G>>2]=g,D[G+(c<<2)>>2]=i=Y+1|0,D[(K=i<<2)+G>>2]=c,N)break e;if((g>>>0)%3|0){i=g-1|0;break D}if(-1!=(0|(i=g+2|0)))break D;N=D[a>>2],Q=-1;break r;case 6:break N;default:break E}if(Bg((a=D[t+8>>2])+24|0),Q=D[t+8>>2],C=s(A,3),D[D[Q>>2]+(C<<2)>>2]=a=(y=(c=D[a+28>>2]-D[a+24>>2]|0)>>2)-1|0,Bg(Q+24|0),D[D[Q>>2]+((G=C+1|0)<<2)>>2]=(D[Q+28>>2]-D[Q+24>>2]>>2)-1,Bg((Q=D[t+8>>2])+24|0),D[D[Q>>2]+((h=C+2|0)<<2)>>2]=(D[Q+28>>2]-D[Q+24>>2]>>2)-1,D[(K=D[t+8>>2])+28>>2]-(Q=D[K+24>>2])>>2>(0|M))break E;N:{if(c){if(D[Q+(a<<2)>>2]=C,a=0,-4!=(0|c)&&(D[Q+(y<<2)>>2]=G,-1==(0|(a=y+1|0))))break N}else D[Q+(y<<2)>>2]=G,a=1;D[Q+(a<<2)>>2]=h}if((0|g)!=(0|J)){D[g>>2]=C,D[w+68>>2]=C=g+4|0;break k}if((F=1+(a=(g=J-N|0)>>2)|0)>>>0>=1073741824)break A;if(Q=g>>1,Q=a>>>0<536870911?Q>>>0<F>>>0?F:Q:1073741823){if(Q>>>0>=1073741824)break B;F=DC(Q<<2)}else F=0;D[(a=F+(a<<2)|0)>>2]=C,J=(Q<<2)+F|0,C=a+4|0,(0|g)>0&&xA(F,N,g),D[w+72>>2]=J,D[w+68>>2]=C,D[w+64>>2]=F,N&&sA(N)}N=F}VA(p,D[C-4>>2]);k:if((0|(g=D[t+40>>2]))!=D[t+36>>2])for(Q=R+(-1^A)|0,a=C-4|0;;){if((A=D[g-8>>2])>>>0>Q>>>0)break f;if((0|A)!=(0|Q))break k;if(y=e[g-4|0],g=D[(A=g-12|0)>>2],D[t+40>>2]=A,(0|g)<0)break f;A=D[a>>2],D[w+20>>2]=R+(-1^g),D[w+88>>2]=g=w+20|0,FA(w,w+40|0,g,w+88|0),h=D[w>>2];t:if(1&y){if(g=-1,-1==(0|A))break t;g=((g=A+1|0)>>>0)%3|0?g:A-2|0}else g=-1,-1!=(0|A)&&(g=A-1|0,(A>>>0)%3|0||(g=A+2|0));if(D[h+12>>2]=g,(0|(g=D[t+40>>2]))==D[t+36>>2])break}g=C;break o}if(Y)break E;break i}Q=-1,D[(N=D[a>>2])+(Y<<2)>>2]=-1,i=-1;break a}Q=D[(N=D[a>>2])+(i<<2)>>2]}D[(Y<<2)+N>>2]=Q,i=-1,-1!=(0|(g=((u=g+1|0)>>>0)%3|0?u:g-2|0))&&(i=D[(g<<2)+N>>2])}if(D[N+K>>2]=i,-1!=(0|c)){a:{r:{if((c>>>0)%3|0)i=c-1|0;else if(-1==(0|(i=c+2|0)))break r;if(D[(g=A+N|0)>>2]=A=D[(i<<2)+N>>2],-1==(0|A))break a;D[D[a+24>>2]+(A<<2)>>2]=y;break a}D[A+N>>2]=-1}y=-1,i=-1,-1!=(0|(A=((A=c+1|0)>>>0)%3|0?A:c-2|0))&&(y=D[(A<<2)+N>>2],i=A)}else D[A+N>>2]=-1,y=-1,i=-1;D[(c=(A=D[t+388>>2])+(g=Q<<2)|0)>>2]=D[c>>2]+D[(K=A)+(A=y<<2)>>2],A=(a=D[a+24>>2])+A|0,-1!=(0|Q)&&(D[g+a>>2]=D[A>>2]);a:if(-1!=(0|i))for(;;){if(D[(i<<2)+N>>2]=Q,-1==(0|(g=((g=i+1|0)>>>0)%3|0?g:i-2|0)))break a;if(-1==(0|(g=D[G+(g<<2)>>2])))break a;if(-1==(0|(i=((i=g+1|0)>>>0)%3|0?i:g-2|0)))break}D[A>>2]=-1;a:if(!T){if((0|l)==(0|q)){r:{if((g=1+(i=(A=q-S|0)>>2)|0)>>>0<1073741824){if(o=A>>1,g=i>>>0<536870911?g>>>0>o>>>0?g:o:1073741823){if(g>>>0>=1073741824)break r;o=DC(g<<2)}else o=0;D[(i=o+(i<<2)|0)>>2]=y,q=(g<<2)+o|0,l=i+4|0,(0|A)>0&&xA(o,S,A),D[w+32>>2]=q,D[w+28>>2]=l,D[w+24>>2]=o,S&&sA(S),S=o;break a}break A}break B}D[l>>2]=y,D[w+28>>2]=l=l+4|0}D[h>>2]=Y,g=C,N=F,VA(p,Y)}if(Y=(0|n)<(0|R),(0|n)==(0|R))break}n=R}if(i=-1,!(D[(N=D[t+8>>2])+28>>2]-D[N+24>>2]>>2>(0|M))){if((0|C)!=(0|F)){for(A=t+60|0,Y=t+312|0;;){c=D[(C=C-4|0)>>2],D[w+68>>2]=C;i:{o:{a:{if(f[t+270>>1]<=513){if(!e[t+364|0])break a;if((N=D[t+352>>2]+((g=D[t+360>>2])>>>3|0)|0)>>>0>=k[t+356>>2])break o;N=e[0|N],D[t+360>>2]=g+1,g=N>>>(7&g)&1}else g=ug(Y);if(!g)break o}if(((D[(J=D[t+8>>2])+4>>2]-(G=D[J>>2])>>2>>>0)/3|0)<=(0|n))break E;if(a=-1,Q=-1,g=-1,-1!=(0|c)&&(g=-1,-1!=(0|(R=((R=c+1|0)>>>0)%3|0?R:c-2|0))&&(g=D[G+(R<<2)>>2])),-1!=(0|(g=D[(N=D[J+24>>2])+((R=g)<<2)>>2]))&&-1!=(0|(g=((S=g+1|0)>>>0)%3|0?S:g-2|0))&&(-1!=(0|(a=((a=g+1|0)>>>0)%3|0?a:g-2|0))&&(Q=D[G+(a<<2)>>2]),a=g),y=-1,S=-1,g=-1,-1!=(0|(N=D[N+(Q<<2)>>2]))&&(g=-1,-1!=(0|(N=((M=N+1|0)>>>0)%3|0?M:N-2|0))&&(-1!=(0|(g=((g=N+1|0)>>>0)%3|0?g:N-2|0))&&(S=D[G+(g<<2)>>2]),g=N)),J=D[J+12>>2],N=s(n,3),D[J+(M=N<<2)>>2]=c,D[J+(c<<2)>>2]=N,D[(p=(c=N+1|0)<<2)+J>>2]=a,D[J+(a<<2)>>2]=c,D[(q=(a=N+2|0)<<2)+J>>2]=g,D[J+(g<<2)>>2]=a,D[G+M>>2]=Q,D[(g=G+p|0)>>2]=S,D[(S=G+q|0)>>2]=R,J=D[(G=((R=N>>>0>c>>>0?-1:Q)>>>3&536870908)+(Q=D[t+120>>2])|0)>>2],m=G,Z=JC(R)&J,D[m>>2]=Z,R=D[(g=Q+((y=-1!=(0|c)?D[g>>2]:y)>>>3&536870908)|0)>>2],m=g,Z=JC(y)&R,D[m>>2]=Z,g=-1,R=D[(Q=Q+((g=-1!=(0|a)?D[S>>2]:g)>>>3&536870908)|0)>>2],m=Q,Z=JC(g)&R,D[m>>2]=Z,(0|(g=D[t+64>>2]))==(Q=D[t+68>>2])<<5){if((g+1|0)<0)break A;vI(A,g=g>>>0<=1073741822?(g=g+32&-32)>>>0>(Q<<=6)>>>0?g:Q:2147483647),g=D[t+64>>2]}if(n=n+1|0,D[t+64>>2]=g+1,D[(Q=D[t+60>>2]+(g>>>3&536870908)|0)>>2]=D[Q>>2]|1<<g,(0|(g=D[t+76>>2]))!=D[t+80>>2]){D[g>>2]=N,D[t+76>>2]=g+4;break i}if((g=1+(S=(R=g-(Q=D[t+72>>2])|0)>>2)|0)>>>0>=1073741824)break A;if(a=R>>1,a=S>>>0<536870911?g>>>0>a>>>0?g:a:1073741823){if(a>>>0>=1073741824)break B;g=DC(a<<2)}else g=0;if(D[(S=g+(S<<2)|0)>>2]=N,(0|R)>0&&xA(g,Q,R),D[t+80>>2]=g+(a<<2),D[t+76>>2]=S+4,D[t+72>>2]=g,!Q)break i;sA(Q);break i}if((0|(N=D[t+64>>2]))==(g=D[t+68>>2])<<5){if((N+1|0)<0)break A;vI(A,g=N>>>0<=1073741822?(g<<=6)>>>0<(N=N+32&-32)>>>0?N:g:2147483647),N=D[t+64>>2]}if(D[t+64>>2]=N+1,Q=D[(g=D[t+60>>2]+(N>>>3&536870908)|0)>>2],m=g,Z=JC(N)&Q,D[m>>2]=Z,(0|(g=D[t+76>>2]))==D[t+80>>2]){if((g=1+(a=(Q=g-(N=D[t+72>>2])|0)>>2)|0)>>>0>=1073741824)break A;if(R=Q>>1,R=a>>>0<536870911?g>>>0>R>>>0?g:R:1073741823){if(R>>>0>=1073741824)break B;g=DC(R<<2)}else g=0;D[(a=g+(a<<2)|0)>>2]=c,(0|Q)>0&&xA(g,N,Q),D[t+80>>2]=g+(R<<2),D[t+76>>2]=a+4,D[t+72>>2]=g,N&&sA(N)}else D[g>>2]=c,D[t+76>>2]=g+4}if((0|C)==(0|F))break}N=D[t+8>>2]}if(((D[N+4>>2]-D[N>>2]>>2>>>0)/3|0)==(0|n))if(i=D[N+28>>2]-(C=D[N+24>>2])>>2,(0|o)!=(0|l))for(Q=o;;){if(A=D[Q>>2],-1==D[(a=((g=i-1|0)<<2)+C|0)>>2])for(;g=i-2|0,i=i-1|0,-1==D[(a=(g<<2)+C|0)>>2];);if(A>>>0<=g>>>0){if(D[w>>2]=N,C=D[a>>2],B[w+12|0]=1,D[w+8>>2]=C,D[w+4>>2]=C,-1!=(0|C))for(;D[D[N>>2]+(C<<2)>>2]=A,FI(w),N=D[t+8>>2],-1!=(0|(C=D[w+8>>2])););n=(C=D[N+24>>2])+(g<<2)|0,-1!=(0|A)&&(D[(A<<2)+C>>2]=D[n>>2]),D[n>>2]=-1,n=1<<A,A=(R=D[t+120>>2])+(A>>>3&536870908)|0,D[(R=R+(g>>>3&536870908)|0)>>2]&(g=1<<g)?n|=D[A>>2]:n=D[A>>2]&(-1^n),D[A>>2]=n,D[R>>2]=D[R>>2]&(-1^g),i=i-1|0}if((0|l)==(0|(Q=Q+4|0)))break}else o=l}}if(o&&sA(o),A=D[w+48>>2])for(;g=D[A>>2],sA(A),A=g,g;);A=D[w+40>>2],D[w+40>>2]=0,A&&sA(A),F&&(D[w+68>>2]=F,sA(F)),d=w+96|0;break Q}xg(1336),U()}if(-1!=(0|i)){g=(A=D[I+16>>2])+D[I>>2]|0,C=(C=D[I+8>>2])-A|0,r[(A=D[D[t+4>>2]+32>>2])+38>>1]=f[A+38>>1],D[A>>2]=g,D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=C,D[A+12>>2]=0,(65535&(o=(g=f[(A=D[t+4>>2])+36>>1])<<8|g>>>8))>>>0<=513&&(C=V+D[(A=D[A+32>>2])+20>>2]|0,C=(g=L+D[A+16>>2]|0)>>>0<L>>>0?C+1|0:C,D[A+16>>2]=g,D[A+20>>2]=C);Q:if(D[t+216>>2]!=D[t+220>>2]){if(A=D[(g=D[t+8>>2])>>2],g=D[g+4>>2],!((65535&o)>>>0>=513)){if((0|A)==(0|g))break Q;for(g=0;;){if(KA(t,g)){if((g=g+3|0)>>>0<D[(A=D[t+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break Q}break}break C}if((0|A)!=(0|g)){for(g=0;;){if(YA(t,g)){if((g=g+3|0)>>>0<D[(A=D[t+8>>2])+4>>2]-D[A>>2]>>2>>>0)continue;break Q}break}break C}}if(og(E),(0|(g=D[t+216>>2]))!=D[t+220>>2])for(o=0;;){if(oI(4+((A=s(o,144))+g|0)|0,D[t+8>>2]),(0|(g=D[132+(C=A+(b=D[W>>2])|0)>>2]))!=(0|(C=D[C+136>>2])))for(;fI(4+(A+b|0)|0,D[g>>2]),b=D[W>>2],(0|C)!=(0|(g=g+4|0)););if(nA(4+(A+b|0)|0),!((o=o+1|0)>>>0<(D[t+220>>2]-(g=D[t+216>>2])|0)/144>>>0))break}if(ig(t+184|0,D[(A=D[t+8>>2])+28>>2]-D[A+24>>2]>>2),(0|(b=D[t+216>>2]))!=D[t+220>>2])for(g=0;A=s(g,144)+b|0,C=D[A+60>>2]-D[A+56>>2]>>2,ig(o=A+104|0,(0|(A=D[(A=D[t+8>>2])+28>>2]-D[A+24>>2]>>2))>(0|C)?A:C),(g=g+1|0)>>>0<(D[t+220>>2]-(b=D[t+216>>2])|0)/144>>>0;);b=QA(t,i)}}break I}b=0}return d=I- -64|0,0|b}iQ(),U()},EQ,ZC,xC,BC,function(A){var I=0;D[(A|=0)>>2]=11900,(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12152,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),sA(A)},Dg,function(A){var I=0;return D[(A|=0)>>2]=12152,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),0|A},function(A){var I=0;D[(A|=0)>>2]=12152,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),sA(A)},function(A){var I=0;return D[8+(A|=0)>>2]=12416,D[A>>2]=12204,(I=D[A+96>>2])&&(D[A+100>>2]=I,sA(I)),(I=D[A+80>>2])&&(D[A+84>>2]=I,sA(I)),(I=D[A+68>>2])&&(D[A+72>>2]=I,sA(I)),(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12652,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),0|A},function(A){var I=0;D[8+(A|=0)>>2]=12416,D[A>>2]=12204,(I=D[A+96>>2])&&(D[A+100>>2]=I,sA(I)),(I=D[A+80>>2])&&(D[A+84>>2]=I,sA(I)),(I=D[A+68>>2])&&(D[A+72>>2]=I,sA(I)),(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12652,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),sA(A)},function(A,I){var g,C,Q,E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0;if(C=D[12+(A|=0)>>2],o=D[(E=D[A+108>>2])+80>>2],B[84+(I|=0)|0]=0,(i=D[I+72>>2]-(a=D[I+68>>2])>>2)>>>0<o>>>0?(ZA(I+68|0,o-i|0,12404),o=D[(E=D[A+108>>2])+80>>2]):o>>>0>=i>>>0||(D[I+72>>2]=a+(o<<2)),!(E=D[E+100>>2]-(g=D[E+96>>2])|0))return 1;Q=(E=(0|E)/12|0)>>>0>1?E:1,E=0;A:{for(;;){if(1431655765==(0|E))break A;if(i=D[C>>2]+(s(E,3)<<2)|0,-1==(0|(e=D[i>>2])))break A;if(a=s(E,12)+g|0,(r=D[a>>2])>>>0>=o>>>0)break A;if((f=D[(k=D[D[A+112>>2]+12>>2])+(e<<2)>>2])>>>0>=o>>>0)break A;if(D[(e=D[I+68>>2])+(r<<2)>>2]=f,-1==(0|(r=D[i+4>>2])))break A;if((f=D[a+4>>2])>>>0>=o>>>0)break A;if((r=D[(r<<2)+k>>2])>>>0>=o>>>0)break A;if(D[e+(f<<2)>>2]=r,-1==(0|(i=D[i+8>>2])))break A;if((a=D[a+8>>2])>>>0>=o>>>0)break A;if((i=D[(i<<2)+k>>2])>>>0>=o>>>0)break A;if(D[e+(a<<2)>>2]=i,(0|Q)==(0|(E=E+1|0)))break}return 1}return 0},function(A){var I,g=0,C=0,Q=0,B=0,E=0,i=0;d=I=d-16|0;A:{if(!((B=(C=D[(C=D[12+(A|=0)>>2])+28>>2]-D[C+24>>2]|0)>>2)>>>0<=D[(g=D[A+4>>2])+8>>2]-(Q=D[g>>2])>>2>>>0)){if((0|C)<0)break A;E=D[g+4>>2],i=(C=DC(C))+(B<<2)|0,E=(B=E-Q|0)+C|0,(0|B)>0&&xA(C,Q,B),D[g+8>>2]=i,D[g+4>>2]=E,D[g>>2]=C,Q&&sA(Q)}Q=D[(g=D[A+12>>2])+28>>2],g=D[g+24>>2],D[I+12>>2]=0,(g=Q-g>>2)>>>0>(Q=D[A+100>>2]-(B=D[(C=A+96|0)>>2])>>2)>>>0?ZA(C,g-Q|0,I+12|0):g>>>0>=Q>>>0||(D[A+100>>2]=B+(g<<2)),B=A+8|0;I:if(g=D[A+116>>2]){if((0|(C=D[g>>2]))==D[g+4>>2]){Q=1;break I}for(g=0;;){if(!(Q=CA(B,D[(g<<2)+C>>2])))break I;if(!((g=g+1|0)>>>0<D[(E=D[A+116>>2])+4>>2]-(C=D[E>>2])>>2>>>0))break}}else if(Q=1,!((A=D[(A=D[A+12>>2])+4>>2]-D[A>>2]>>2)>>>0<3))for(A=(A>>>0)/3|0,g=0;;){if(!(Q=CA(B,s(g,3))))break I;if((0|A)==(0|(g=g+1|0)))break}return d=I+16|0,0|Q}xg(1336),U()},function(A){var I=0;return D[(A|=0)>>2]=12416,(I=D[A+88>>2])&&(D[A+92>>2]=I,sA(I)),(I=D[A+72>>2])&&(D[A+76>>2]=I,sA(I)),(I=D[A+60>>2])&&(D[A- -64>>2]=I,sA(I)),(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),0|A},function(A){var I=0;D[(A|=0)>>2]=12416,(I=D[A+88>>2])&&(D[A+92>>2]=I,sA(I)),(I=D[A+72>>2])&&(D[A+76>>2]=I,sA(I)),(I=D[A+60>>2])&&(D[A- -64>>2]=I,sA(I)),(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),sA(A)},function(A,I,g){g|=0;var C,Q=0;d=C=d-16|0,D[4+(A|=0)>>2]=I|=0,Q=D[I>>2],I=D[I+4>>2],B[C+15|0]=0,hI(A+24|0,(I-Q>>2>>>0)/3|0,C+15|0),Q=D[(I=D[A+4>>2])+28>>2],I=D[I+24>>2],B[C+14|0]=0,hI(A+36|0,Q-I>>2,C+14|0),I=D[g+12>>2],D[A+16>>2]=D[g+8>>2],D[A+20>>2]=I,I=D[g+4>>2],D[A+8>>2]=D[g>>2],D[A+12>>2]=I,d=C+16|0},function(A){var I=0;return D[(A|=0)>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),0|A},function(A){var I=0;D[(A|=0)>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),sA(A)},function(A){var I=0;return D[8+(A|=0)>>2]=12836,D[A>>2]=12672,(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12652,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),0|A},function(A){var I=0;D[8+(A|=0)>>2]=12836,D[A>>2]=12672,(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12652,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),sA(A)},function(A,I){var g,C,Q,E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0;if(C=D[12+(A|=0)>>2],o=D[(E=D[A+68>>2])+80>>2],B[84+(I|=0)|0]=0,(i=D[I+72>>2]-(a=D[I+68>>2])>>2)>>>0<o>>>0?(ZA(I+68|0,o-i|0,12404),o=D[(E=D[A+68>>2])+80>>2]):o>>>0>=i>>>0||(D[I+72>>2]=a+(o<<2)),!(E=D[E+100>>2]-(g=D[E+96>>2])|0))return 1;Q=(E=(0|E)/12|0)>>>0>1?E:1,E=0;A:{for(;;){if(1431655765==(0|E))break A;if(i=D[C>>2]+(s(E,3)<<2)|0,-1==(0|(e=D[i>>2])))break A;if(a=s(E,12)+g|0,(r=D[a>>2])>>>0>=o>>>0)break A;if((f=D[(k=D[D[A+72>>2]+12>>2])+(e<<2)>>2])>>>0>=o>>>0)break A;if(D[(e=D[I+68>>2])+(r<<2)>>2]=f,-1==(0|(r=D[i+4>>2])))break A;if((f=D[a+4>>2])>>>0>=o>>>0)break A;if((r=D[(r<<2)+k>>2])>>>0>=o>>>0)break A;if(D[e+(f<<2)>>2]=r,-1==(0|(i=D[i+8>>2])))break A;if((a=D[a+8>>2])>>>0>=o>>>0)break A;if((i=D[(i<<2)+k>>2])>>>0>=o>>>0)break A;if(D[e+(a<<2)>>2]=i,(0|Q)==(0|(E=E+1|0)))break}return 1}return 0},function(A){var I=0,g=0,C=0,Q=0,B=0,E=0;I=D[4+(A|=0)>>2];A:{if(!((Q=(g=D[(g=D[A+12>>2])+28>>2]-D[g+24>>2]|0)>>2)>>>0<=D[I+8>>2]-(C=D[I>>2])>>2>>>0)){if((0|g)<0)break A;B=D[I+4>>2],E=(g=DC(g))+(Q<<2)|0,B=(Q=B-C|0)+g|0,(0|Q)>0&&xA(g,C,Q),D[I+8>>2]=E,D[I+4>>2]=B,D[I>>2]=g,C&&sA(C)}Q=A+8|0;I:if(I=D[A+76>>2]){if((0|(C=D[I>>2]))==D[I+4>>2])return 1;for(I=0;;){if(!(g=cA(Q,D[(I<<2)+C>>2])))break I;if(!((I=I+1|0)>>>0<D[(B=D[A+76>>2])+4>>2]-(C=D[B>>2])>>2>>>0))break}}else if(g=1,!((A=D[(A=D[A+12>>2])+4>>2]-D[A>>2]>>2)>>>0<3))for(A=(A>>>0)/3|0,I=0;;){if(!(g=cA(Q,s(I,3))))break I;if((0|A)==(0|(I=I+1|0)))break}return 0|g}xg(1336),U()},function(A){var I=0;return D[(A|=0)>>2]=12836,(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),0|A},function(A){var I=0;D[(A|=0)>>2]=12836,(I=D[A+48>>2])&&(D[A+52>>2]=I,sA(I)),D[A>>2]=12652,(I=D[A+36>>2])&&sA(I),(I=D[A+24>>2])&&sA(I),sA(A)},function(A){var I=0;return D[8+(A|=0)>>2]=11900,D[A>>2]=12964,(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12152,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),0|A},function(A){var I=0;D[8+(A|=0)>>2]=11900,D[A>>2]=12964,(I=D[A+56>>2])&&(D[A+60>>2]=I,sA(I)),D[A+8>>2]=12152,(I=D[A+44>>2])&&sA(I),(I=D[A+32>>2])&&sA(I),sA(A)},function(A,I){var g,C,Q,E=0,i=0,o=0,a=0,r=0,e=0,f=0,k=0;if(e=D[12+(A|=0)>>2],o=D[(E=D[A+68>>2])+80>>2],B[84+(I|=0)|0]=0,(i=D[I+72>>2]-(r=D[I+68>>2])>>2)>>>0<o>>>0?(ZA(I+68|0,o-i|0,12404),o=D[(E=D[A+68>>2])+80>>2]):o>>>0>=i>>>0||(D[I+72>>2]=r+(o<<2)),!(E=D[E+100>>2]-(g=D[E+96>>2])|0))return 1;C=(E=(0|E)/12|0)>>>0>1?E:1,Q=D[e+28>>2],E=0;A:{for(;;){if(i=(s(E,3)<<2)+Q|0,-1==(0|(r=D[i>>2])))break A;if(e=s(E,12)+g|0,(f=D[e>>2])>>>0>=o>>>0)break A;if((a=D[(a=r<<2)+(r=D[D[A+72>>2]+12>>2])>>2])>>>0>=o>>>0)break A;if(D[(k=f<<2)+(f=D[I+68>>2])>>2]=a,-1==(0|(a=D[i+4>>2])))break A;if((k=D[e+4>>2])>>>0>=o>>>0)break A;if((a=D[r+(a<<2)>>2])>>>0>=o>>>0)break A;if(D[f+(k<<2)>>2]=a,-1==(0|(i=D[i+8>>2])))break A;if((e=D[e+8>>2])>>>0>=o>>>0)break A;if((i=D[r+(i<<2)>>2])>>>0>=o>>>0)break A;if(D[f+(e<<2)>>2]=i,(0|C)==(0|(E=E+1|0)))break}return 1}return 0},function(A){var I=0,g=0,C=0,Q=0,B=0,E=0;I=D[4+(A|=0)>>2];A:{if(!((Q=(g=D[(g=D[A+12>>2])+56>>2]-D[g+52>>2]|0)>>2)>>>0<=D[I+8>>2]-(C=D[I>>2])>>2>>>0)){if((0|g)<0)break A;B=D[I+4>>2],E=(g=DC(g))+(Q<<2)|0,B=(Q=B-C|0)+g|0,(0|Q)>0&&xA(g,C,Q),D[I+8>>2]=E,D[I+4>>2]=B,D[I>>2]=g,C&&sA(C)}Q=A+8|0;I:if(I=D[A+76>>2]){if((0|(C=D[I>>2]))==D[I+4>>2])return 1;for(I=0;;){if(!(g=RA(Q,D[(I<<2)+C>>2])))break I;if(!((I=I+1|0)>>>0<D[(B=D[A+76>>2])+4>>2]-(C=D[B>>2])>>2>>>0))break}}else if(g=1,!((A=D[(A=D[D[A+12>>2]+64>>2])+4>>2]-D[A>>2]>>2)>>>0<3))for(A=(A>>>0)/3|0,I=0;;){if(!(g=RA(Q,s(I,3))))break I;if((0|A)==(0|(I=I+1|0)))break}return 0|g}xg(1336),U()},Ug,pI,function(A){var I,g=0,C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0,t=0,N=0,F=0,n=0;d=I=d-32|0,C=D[32+(A|=0)>>2];A:{if((65535&((Q=f[A+36>>1])<<8|Q>>>8))>>>0<=513){if(B=Q=D[C+20>>2],i=E=(o=D[C+16>>2])+4|0,(a=D[C+8>>2])>>>0<E>>>0&(0|(g=D[C+12>>2]))<=(0|(Q=E>>>0<4?Q+1|0:Q))|(0|g)<(0|Q))break A;if(t=e[0|(E=(F=D[C>>2])+o|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[C+16>>2]=i,D[C+20>>2]=Q,Q=g,g=B,(B=o+8|0)>>>0>a>>>0&(0|(g=B>>>0<8?g+1|0:g))>=(0|Q)|(0|g)>(0|Q))break A;D[I+24>>2]=F=e[0|(Q=i+F|0)]|e[Q+1|0]<<8|e[Q+2|0]<<16|e[Q+3|0]<<24,D[C+16>>2]=B,D[C+20>>2]=g}else{if(!sg(1,I+28|0,C))break A;if(!sg(1,I+24|0,D[A+32>>2]))break A;t=D[I+28>>2],F=D[I+24>>2]}if(!(t>>>0>1431655765||(Q=_g(i=(g=o=D[(Q=B=D[A+32>>2])+8>>2])-(C=D[Q+16>>2])|0,(E=D[Q+12>>2])-((n=g>>>0<C>>>0)+(g=D[Q+20>>2])|0)|0,3,0),!u&Q>>>0<t>>>0||(Q=mg(t,0,3,0),!u&Q>>>0<F>>>0|(0|g)>=(0|E)&C>>>0>=o>>>0|(0|g)>(0|E))))){E=e[C+D[B>>2]|0],Q=(o=C+1|0)?g:g+1|0,D[B+16>>2]=o,D[B+20>>2]=Q;I:{if(E){g:if(F>>>0<=255){if(!t)break I;if(D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,(0|Q)>=(0|(g=C=D[B+12>>2]))&o>>>0>=(i=D[B+8>>2])>>>0|(0|g)<(0|Q))break g;for(;;){if(r=e[(E=D[B>>2])+o|0],g=Q,g=(a=o+1|0)?g:g+1|0,D[B+16>>2]=a,D[B+20>>2]=g,D[I+8>>2]=r,(0|g)>=(0|C)&a>>>0>=i>>>0|(0|g)>(0|C))break g;if(r=e[E+a|0],g=Q,g=(a=o+2|0)>>>0<2?g+1|0:g,D[B+16>>2]=a,D[B+20>>2]=g,D[I+12>>2]=r,(0|g)>=(0|C)&a>>>0>=i>>>0|(0|g)>(0|C))break g;if(g=e[E+a|0],Q=(C=o+3|0)>>>0<3?Q+1|0:Q,D[B+16>>2]=C,D[B+20>>2]=Q,D[I+16>>2]=g,TI(D[A+44>>2]+96|0,I+8|0),(0|(N=N+1|0))==(0|t))break I;if(o=D[(g=B=D[A+32>>2])+16>>2],Q=D[g+20>>2],D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,!(o>>>0<(i=D[g+8>>2])>>>0&(0|Q)<=(0|(g=C=D[g+12>>2]))|(0|g)>(0|Q)))break}}else if(F>>>0<=65535){if(!t)break I;if(D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,i=C=C+3|0,C=g=C>>>0<3?g+1|0:g,(a=D[B+8>>2])>>>0<i>>>0&(0|g)>=(0|(E=D[B+12>>2]))|(0|g)>(0|E))break g;for(;;){if(g=e[0|(g=(r=D[B>>2])+o|0)]|e[g+1|0]<<8,D[B+16>>2]=i,D[B+20>>2]=C,D[I+8>>2]=g,g=Q,(C=o+4|0)>>>0>a>>>0&(0|(g=C>>>0<4?g+1|0:g))>=(0|E)|(0|g)>(0|E))break g;if(i=e[0|(i=i+r|0)]|e[i+1|0]<<8,D[B+16>>2]=C,D[B+20>>2]=g,D[I+12>>2]=i,g=Q,(Q=o+6|0)>>>0>a>>>0&(0|(g=Q>>>0<6?g+1|0:g))>=(0|E)|(0|g)>(0|E))break g;if(C=e[0|(C=C+r|0)]|e[C+1|0]<<8,D[B+16>>2]=Q,D[B+20>>2]=g,D[I+16>>2]=C,TI(D[A+44>>2]+96|0,I+8|0),(0|(N=N+1|0))==(0|t))break I;if(o=D[(g=B=D[A+32>>2])+16>>2],Q=D[g+20>>2],D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,E=D[g+12>>2],a=D[g+8>>2],g=Q,i=C=o+2|0,C=g=C>>>0<2?g+1|0:g,!((0|g)<=(0|E)&a>>>0>=i>>>0|(0|g)<(0|E)))break}}else if(k[D[A+44>>2]+80>>2]>2097151||(65535&((E=f[A+36>>1])<<8|E>>>8))>>>0<514){if(!t)break I;if(D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,i=C=C+5|0,C=g=C>>>0<5?g+1|0:g,!((a=D[B+8>>2])>>>0<i>>>0&(0|g)>=(0|(E=D[B+12>>2]))|(0|g)>(0|E)))for(;;){if(g=e[0|(g=(r=D[B>>2])+o|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[B+16>>2]=i,D[B+20>>2]=C,D[I+8>>2]=g,g=Q,n=C=o+8|0,C>>>0>a>>>0&(0|(g=C>>>0<8?g+1|0:g))>=(0|E)|(0|g)>(0|E))break g;if(C=e[0|(C=i+r|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[B+16>>2]=n,D[B+20>>2]=g,D[I+12>>2]=C,C=g=o+12|0,g>>>0>a>>>0&(0|(Q=g>>>0<12?Q+1|0:Q))>=(0|E)|(0|Q)>(0|E))break g;if(g=e[0|(g=r+n|0)]|e[g+1|0]<<8|e[g+2|0]<<16|e[g+3|0]<<24,D[B+16>>2]=C,D[B+20>>2]=Q,D[I+16>>2]=g,TI(D[A+44>>2]+96|0,I+8|0),(0|(N=N+1|0))==(0|t))break I;if(o=D[(g=B=D[A+32>>2])+16>>2],Q=D[g+20>>2],D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,E=D[g+12>>2],a=D[g+8>>2],g=Q,i=C=o+4|0,C=g=C>>>0<4?g+1|0:g,!((0|g)<=(0|E)&a>>>0>=i>>>0|(0|g)<(0|E)))break}}else{if(!t)break I;if(D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,!sg(1,I+4|0,B))break g;for(;;){if(D[I+8>>2]=D[I+4>>2],!sg(1,I+4|0,D[A+32>>2]))break g;if(D[I+12>>2]=D[I+4>>2],!sg(1,I+4|0,D[A+32>>2]))break g;if(D[I+16>>2]=D[I+4>>2],TI(D[A+44>>2]+96|0,I+8|0),(0|(N=N+1|0))==(0|t))break I;if(Q=D[A+32>>2],D[I+16>>2]=0,D[I+8>>2]=0,D[I+12>>2]=0,!sg(1,I+4|0,Q))break}}N=0;break A}B=0,d=g=d-32|0,D[g+24>>2]=0,D[g+16>>2]=0,D[g+20>>2]=0;g:{C:{if(Q=s(t,3)){if(Q>>>0>=1073741824)break C;B=DC(C=s(t,12)),D[g+16>>2]=B,bI(B,0,C)}Q:{if(!(Q=H(Q,1,D[A+32>>2],B))|!t){if(!B)break Q}else for(E=0,C=0;a=(i=D[(o=(C<<2)+B|0)>>2])>>>1|0,D[g>>2]=i=(1&i?0-a|0:a)+r|0,r=(a=D[o+4>>2])>>>1|0,D[g+4>>2]=i=i+(1&a?0-r|0:r)|0,a=(o=D[o+8>>2])>>>1|0,D[g+8>>2]=r=i+(1&o?0-a|0:a)|0,TI(D[A+44>>2]+96|0,g),C=C+3|0,(0|(E=E+1|0))!=(0|t););sA(B)}d=g+32|0;break g}iQ(),U()}if(!Q)break A}D[D[A+4>>2]+80>>2]=F,N=1}}return d=I+32|0,0|N},$C,oQ,function(A,I){return B[84+(I|=0)|0]=1,D[I+72>>2]=D[I+68>>2],1},function(A){var I=0,g=0,C=0,Q=0,B=0;A:{if(!((0|(I=D[8+(A|=0)>>2]))<0||((C=D[(g=D[A+4>>2])+4>>2]-(Q=D[g>>2])>>2)>>>0<I>>>0?($I(g,I-C|0),B=D[A+8>>2]):(B=I,I>>>0>=C>>>0||(D[g+4>>2]=Q+(I<<2),B=I)),(0|(C=B))<=0)))for(Q=D[(A=D[A+4>>2])+4>>2]-(g=D[A>>2])>>2,A=0;;){if((0|A)==(0|Q))break A;if(D[g+(A<<2)>>2]=A,(0|C)==(0|(A=A+1|0)))break}return(-1^I)>>>31|0}sQ(),U()},rQ,IQ,EQ,Ug,function(A,I){A|=0,I|=0;var g,C=0,Q=0,B=0,E=0,i=0;C=DC(72),D[C+4>>2]=0,D[C+8>>2]=0,D[C>>2]=2012,D[C+12>>2]=0,D[C+16>>2]=0,D[C+20>>2]=0,D[C+24>>2]=0,D[C+28>>2]=0,D[C+32>>2]=0,D[C+36>>2]=0,D[C+40>>2]=0,D[C>>2]=2156,D[C+44>>2]=0,D[C+48>>2]=0,D[C+52>>2]=0,D[C+56>>2]=0,D[C+60>>2]=0,D[C+64>>2]=0,D[C+68>>2]=0,g=C;A:{if((0|I)>=0){if(i=A+8|0,!((0|(E=(C=D[A+12>>2])-(B=D[A+8>>2])>>2))>(0|I)))if(Q=I+1|0,I>>>0>=E>>>0)GI(i,Q-E|0);else if(!(Q>>>0>=E>>>0)){if((0|(B=(Q<<2)+B|0))!=(0|C))for(;Q=D[(C=C-4|0)>>2],D[C>>2]=0,Q&&RQ[D[D[Q>>2]+4>>2]](Q),(0|C)!=(0|B););D[A+12>>2]=B}if(C=D[(A=D[i>>2]+(I<<2)|0)>>2],D[A>>2]=g,!C)break A}RQ[D[D[C>>2]+4>>2]](C)}return(-1^I)>>>31|0},function(A){var I,g,C=0,Q=0,B=0,E=0;return Q=D[(I=D[32+(A|=0)>>2])+20>>2],(E=D[I+8>>2])>>>0<(g=(E=D[I+16>>2])+4|0)>>>0&(0|(Q=g>>>0<4?Q+1|0:Q))>=(0|(B=D[I+12>>2]))|(0|Q)>(0|B)||(B=e[0|(C=E+D[I>>2]|0)]|e[C+1|0]<<8|e[C+2|0]<<16|e[C+3|0]<<24,D[I+16>>2]=g,D[I+20>>2]=Q,C=0,(0|B)<0||(D[D[A+4>>2]+80>>2]=B,C=1)),0|C},Ug,pI,function(A){var I,g,C,Q,B,E=0,i=0;return i=D[(I=D[32+(A|=0)>>2])+20>>2],(0|(i=(C=(B=D[I+16>>2])+4|0)>>>0<4?i+1|0:i))<=(0|(g=D[I+12>>2]))&(E=Q=D[I+8>>2])>>>0>=C>>>0|(0|i)<(0|g)&&(E=e[0|(E=B+D[I>>2]|0)]|e[E+1|0]<<8|e[E+2|0]<<16|e[E+3|0]<<24,D[I+16>>2]=C,D[I+20>>2]=i,D[D[A+4>>2]+80>>2]=E),(0|i)<=(0|g)&C>>>0<=Q>>>0|(0|i)<(0|g)},function(A){var I=0;return D[(A|=0)>>2]=13696,(I=D[A+96>>2])&&(D[A+100>>2]=I,sA(I)),(I=D[A+84>>2])&&(D[A+88>>2]=I,sA(I)),PI(A),0|A},function(A){var I=0;D[(A|=0)>>2]=13696,(I=D[A+96>>2])&&(D[A+100>>2]=I,sA(I)),(I=D[A+84>>2])&&(D[A+88>>2]=I,sA(I)),PI(A),sA(A)},function(A,I,g){var C=0,Q=0,B=0,E=0,i=0,o=0,a=0,r=0;if(SA(A|=0,I|=0,g|=0),!((0|(C=D[A+88>>2]-(g=D[A+84>>2])>>2))>(0|I))){if((I=I+1|0)>>>0>C>>>0){A:if((C=I-C|0)>>>0<=(Q=D[A+92>>2])-(g=D[A+88>>2])>>2>>>0){if(C){if(I=g,E=1+((B=(C<<2)-4|0)>>>2|0)&7)for(;D[I>>2]=1,I=I+4|0,(0|E)!=(0|(i=i+1|0)););if(g=(C<<2)+g|0,!(B>>>0<28))for(;D[I+24>>2]=1,D[I+28>>2]=1,D[I+16>>2]=1,D[I+20>>2]=1,D[I+8>>2]=1,D[I+12>>2]=1,D[I>>2]=1,D[I+4>>2]=1,(0|g)!=(0|(I=I+32|0)););}D[A+88>>2]=g}else{I:{if((I=(g=(a=g-(B=D[A+84>>2])|0)>>2)+C|0)>>>0<1073741824){if(o=(Q=Q-B|0)>>1,Q=Q>>2>>>0<536870911?I>>>0>o>>>0?I:o:1073741823){if(Q>>>0>=1073741824)break I;E=DC(Q<<2)}if(I=g=(g<<2)+E|0,r=1+((o=(C<<=2)-4|0)>>>2|0)&7)for(I=g;D[I>>2]=1,I=I+4|0,(0|r)!=(0|(i=i+1|0)););if(g=g+C|0,o>>>0>=28)for(;D[I+24>>2]=1,D[I+28>>2]=1,D[I+16>>2]=1,D[I+20>>2]=1,D[I+8>>2]=1,D[I+12>>2]=1,D[I>>2]=1,D[I+4>>2]=1,(0|g)!=(0|(I=I+32|0)););(0|a)>0&&xA(E,B,a),D[A+92>>2]=(Q<<2)+E,D[A+88>>2]=g,D[A+84>>2]=E,B&&sA(B);break A}iQ(),U()}xg(1336),U()}return}I>>>0>=C>>>0||(D[A+88>>2]=g+(I<<2))}},function(A,I){var g=0,C=0;NA(A|=0,I|=0),(0|I)<0||(g=D[A+88>>2])-(C=D[A+84>>2])>>2<=(0|I)||((g=g-(C=4+(I=C+(I<<2)|0)|0)|0)&&RI(I,C,g),D[A+88>>2]=I+g)},PI,function(A){sA(PI(A|=0))},SA,NA,function(A){return 0|M(D[60+(A|=0)>>2])},function(A,I,g){I|=0,g|=0;var C,Q=0,B=0,E=0,i=0,o=0,a=0;d=C=d-32|0,D[C+16>>2]=B=D[28+(A|=0)>>2],Q=D[A+20>>2],D[C+28>>2]=g,D[C+24>>2]=I,D[C+20>>2]=I=Q-B|0,B=I+g|0,a=2;A:{I:{(Q=0|J(D[A+60>>2],0|(I=C+16|0),2,C+12|0))?(D[3934]=Q,Q=-1):Q=0;g:{if(!Q)for(;;){if((0|(Q=D[C+12>>2]))==(0|B))break g;if((0|Q)<0)break I;if(D[(o=((i=(E=D[I+4>>2])>>>0<Q>>>0)<<3)+I|0)>>2]=(E=Q-(i?E:0)|0)+D[o>>2],D[(o=(i?12:4)+I|0)>>2]=D[o>>2]-E,B=B-Q|0,(Q=0|J(D[A+60>>2],0|(I=i?I+8|0:I),0|(a=a-i|0),C+12|0))?(D[3934]=Q,Q=-1):Q=0,Q)break}if(-1!=(0|B))break I}D[A+28>>2]=I=D[A+44>>2],D[A+20>>2]=I,D[A+16>>2]=I+D[A+48>>2],A=g;break A}D[A+28>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A>>2]=32|D[A>>2],A=0,2!=(0|a)&&(A=g-D[I+4>>2]|0)}return d=C+32|0,0|A},function(A,I,g,C){var Q;return d=Q=d-16|0,(A=0|S(D[60+(A|=0)>>2],0|(I|=0),0|(g|=0),255&(C|=0),Q+8|0))?(D[3934]=A,A=-1):A=0,d=Q+16|0,u=A?-1:D[Q+12>>2],0|(A?-1:D[Q+8>>2])},$C,oQ,function(A){return 1283},function(A){sA(kC(A|=0))},ZC,function(A){kC(A|=0),sA(A)},$C,oQ,nQ,nQ,function(A,I,g){g|=0;var C,Q=0,B=0,E=0,i=0;if(d=C=d+-64|0,Q=1,!Jg(A|=0,I|=0,0)&&(Q=0,I)){d=Q=d+-64|0,E=D[(B=D[I>>2])-4>>2],i=D[B-8>>2],D[Q+20>>2]=0,D[Q+16>>2]=15124,D[Q+12>>2]=I,D[Q+8>>2]=15172,B=0,bI(Q+24|0,0,39),I=I+i|0;A:if(Jg(E,15172,0))D[Q+56>>2]=1,RQ[D[D[E>>2]+20>>2]](E,Q+8|0,I,I,1,0),B=1==D[Q+32>>2]?I:0;else{RQ[D[D[E>>2]+24>>2]](E,Q+8|0,I,1,0);I:switch(D[Q+44>>2]){case 0:B=1==D[Q+48>>2]&&1==D[Q+36>>2]&&1==D[Q+40>>2]?D[Q+28>>2]:0;break A;case 1:break I;default:break A}1!=D[Q+32>>2]&&D[Q+48>>2]|1!=D[Q+36>>2]|1!=D[Q+40>>2]||(B=D[Q+24>>2])}d=Q- -64|0,Q=0,B&&(bI(4|(I=C+8|0),0,52),D[C+56>>2]=1,D[C+20>>2]=-1,D[C+16>>2]=A,D[C+8>>2]=B,RQ[D[D[B>>2]+28>>2]](B,I,D[g>>2],1),1==(0|(A=D[C+32>>2]))&&(D[g>>2]=D[C+24>>2]),Q=1==(0|A))}return d=C- -64|0,0|Q},function(A,I,g,C,Q,B){g|=0,C|=0,Q|=0,Jg(A|=0,D[8+(I|=0)>>2],B|=0)&&rg(I,g,C,Q)},function(A,I,g,C,Q){if(g|=0,C|=0,Jg(A|=0,D[8+(I|=0)>>2],Q|=0))1==D[I+28>>2]|D[I+4>>2]!=(0|g)||(D[I+28>>2]=C);else A:if(Jg(A,D[I>>2],Q)){if(!(D[I+16>>2]!=(0|g)&D[I+20>>2]!=(0|g))){if(1!=(0|C))break A;return void(D[I+32>>2]=1)}D[I+20>>2]=g,D[I+32>>2]=C,D[I+40>>2]=D[I+40>>2]+1,1!=D[I+36>>2]|2!=D[I+24>>2]||(B[I+54|0]=1),D[I+44>>2]=4}},function(A,I,g,C){g|=0,C|=0,Jg(A|=0,D[8+(I|=0)>>2],0)&&Zg(I,g,C)},oQ,function(A,I,g,C,Q,B){g|=0,C|=0,Q|=0,Jg(A|=0,D[8+(I|=0)>>2],B|=0)?rg(I,g,C,Q):RQ[D[D[(A=D[A+8>>2])>>2]+20>>2]](A,I,g,C,Q,B)},function(A,I,g,C,Q){if(g|=0,C|=0,Jg(A|=0,D[8+(I|=0)>>2],Q|=0))1==D[I+28>>2]|D[I+4>>2]!=(0|g)||(D[I+28>>2]=C);else A:{if(Jg(A,D[I>>2],Q)){if(!(D[I+16>>2]!=(0|g)&D[I+20>>2]!=(0|g))){if(1!=(0|C))break A;return void(D[I+32>>2]=1)}D[I+32>>2]=C;I:if(4!=D[I+44>>2]){if(r[I+52>>1]=0,RQ[D[D[(A=D[A+8>>2])>>2]+20>>2]](A,I,g,g,1,Q),e[I+53|0]){if(D[I+44>>2]=3,!e[I+52|0])break I;break A}D[I+44>>2]=4}if(D[I+20>>2]=g,D[I+40>>2]=D[I+40>>2]+1,1!=D[I+36>>2]|2!=D[I+24>>2])break A;return void(B[I+54|0]=1)}RQ[D[D[(A=D[A+8>>2])>>2]+24>>2]](A,I,g,C,Q)}},function(A,I,g,C){g|=0,C|=0,Jg(A|=0,D[8+(I|=0)>>2],0)?Zg(I,g,C):RQ[D[D[(A=D[A+8>>2])>>2]+28>>2]](A,I,g,C)},IQ,function(A,I,g,C){return u=0,0}]);function yQ(){return C.byteLength/65536|0}return{j:function(){D[3971]=15772,D[3953]=42},k:RQ,l:PC,m:function(){var A;return A=DC(40),r[A+38>>1]=0,D[A>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,B[A+29|0]=0,B[A+30|0]=0,B[A+31|0]=0,B[A+32|0]=0,B[A+33|0]=0,B[A+34|0]=0,B[A+35|0]=0,B[A+36|0]=0,0|A},n:function(A,I,g){I|=0,g|=0,D[16+(A|=0)>>2]=0,D[A+20>>2]=0,D[A>>2]=I,D[A+8>>2]=g,D[A+12>>2]=0},o:PC,p:function(){var A,I;return I=DC(40),D[I>>2]=-1,D[16+(A=I+8|0)>>2]=0,D[A+20>>2]=0,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,0|I},q:vC,r:function(A){var I=0;(A|=0)&&((I=D[A+8>>2])&&(D[A+12>>2]=I,sA(I)),sA(A))},s:function(){return 0|zg(DC(64))},t:PC,u:function(){var A;return zg(A=DC(96)),D[A+64>>2]=0,D[A+68>>2]=0,D[A+88>>2]=0,D[A+72>>2]=0,D[A+76>>2]=0,B[A+77|0]=0,B[A+78|0]=0,B[A+79|0]=0,B[A+80|0]=0,B[A+81|0]=0,B[A+82|0]=0,B[A+83|0]=0,B[A+84|0]=0,0|A},v:TC,w:function(A){return D[88+(A|=0)>>2]},x:function(A){return D[56+(A|=0)>>2]},y:_C,z:function(A){return B[24+(A|=0)|0]},A:function(A){return e[32+(A|=0)|0]},B:function(A){return D[40+(A|=0)>>2]},C:function(A){return D[48+(A|=0)>>2]},D:function(A){return D[60+(A|=0)>>2]},E:Wg,F:function(){var A;return A=DC(24),D[A+8>>2]=0,D[A+12>>2]=0,D[A+4>>2]=-1,D[A>>2]=1140,D[A+16>>2]=0,D[A+20>>2]=0,0|A},G:YC,H:ZC,I:function(A,I){return F(t[D[8+(A|=0)>>2]+((I|=0)<<2)>>2])},J:function(A){return F(t[20+(A|=0)>>2])},K:dC,L:function(){var A;return A=DC(8),D[A+4>>2]=-1,D[A>>2]=1032,0|A},M:YC,N:ZC,O:dC,P:function(){return 0|MC(DC(84))},Q:LC,R:TC,S:dC,T:function(){var A;return MC(A=DC(108)),D[A+84>>2]=0,D[A+88>>2]=0,D[A>>2]=13696,D[A+92>>2]=0,D[A+96>>2]=0,D[A+100>>2]=0,D[A+104>>2]=0,0|A},U:function(A){return(D[100+(A|=0)>>2]-D[A+96>>2]|0)/12|0},V:LC,W:TC,X:dC,Y:function(){var A,I;return A=DC(24),D[A+4>>2]=0,D[A+8>>2]=0,D[(I=A+16|0)>>2]=0,D[I+4>>2]=0,D[A>>2]=A+4,D[A+12>>2]=I,0|A},Z:function(A){(A|=0)&&(AC(A+12|0,D[A+16>>2]),aC(A,D[A+4>>2]),sA(A))},_:vC,$:function(A){return 0|!D[(A|=0)>>2]},aa:function(A){return 0|(B[15+(A|=0)|0]<0?D[A+4>>2]:A+4|0)},ba:function(A){(A|=0)&&(B[A+15|0]<0&&sA(D[A+4>>2]),sA(A))},ca:UC,da:function(A,I){return F(t[D[(A|=0)>>2]+((I|=0)<<2)>>2])},ea:HC,fa:hC,ga:UC,ha:function(A,I){return B[D[(A|=0)>>2]+(I|=0)|0]},ia:qC,ja:hC,ka:UC,la:function(A,I){return e[D[(A|=0)>>2]+(I|=0)|0]},ma:qC,na:hC,oa:UC,pa:function(A,I){return r[D[(A|=0)>>2]+((I|=0)<<1)>>1]},qa:pC,ra:hC,sa:UC,ta:function(A,I){return f[D[(A|=0)>>2]+((I|=0)<<1)>>1]},ua:pC,va:hC,wa:UC,xa:KC,ya:HC,za:hC,Aa:UC,Ba:KC,Ca:HC,Da:hC,Ea:function(){var A;return A=DC(28),D[A>>2]=0,D[A+4>>2]=0,D[A+24>>2]=0,D[A+16>>2]=0,D[A+20>>2]=0,D[A+8>>2]=0,D[A+12>>2]=0,0|A},Fa:function(A,I,g){A|=0,I|=0;var C,Q=0,E=0,i=0,o=0,a=0,r=0,f=0;if(d=C=d-16|0,(Q=bg(g|=0))>>>0<4294967280){A:{if(Q>>>0>=11)A=DC(E=Q+16&-16),D[C+8>>2]=-2147483648|E,D[C>>2]=A,D[C+4>>2]=Q;else if(B[C+11|0]=Q,A=C,!Q)break A;xA(A,g,Q)}B[A+Q|0]=0,Q=(g=e[C+11|0])<<24>>24,E=D[C>>2],A=0;A:if(I=D[I+4>>2]){for(A=g,A=(g=(0|Q)<0)?D[C+4>>2]:A,r=g?E:C;;){I:{g:{C:{if(a=(f=(g=(i=(g=e[I+27|0])<<24>>24<0)?D[I+20>>2]:g)>>>0<A>>>0)?g:A){o=I+16|0;Q:{if(!(o=cg(r,i=i?D[o>>2]:o,a))){if(A>>>0>=g>>>0)break Q;break I}if((0|o)<0)break I}if(!(g=cg(i,r,a)))break C;if((0|g)<0)break g;A=1;break A}if(A>>>0<g>>>0)break I}if(!f){A=1;break A}}I=I+4|0}if(!(I=D[I>>2]))break}A=0}(0|Q)<0&&sA(E),d=C+16|0}else aQ(),U();return 0|A},Ga:function(A,I,g){A|=0,I|=0,g|=0;var C,Q=0,E=0;if(d=C=d-16|0,D[C+12>>2]=0,(Q=bg(g))>>>0<4294967280){A:{if(Q>>>0>=11)A=DC(E=Q+16&-16),D[C+8>>2]=-2147483648|E,D[C>>2]=A,D[C+4>>2]=Q;else if(B[C+11|0]=Q,A=C,!Q)break A;xA(A,g,Q)}B[A+Q|0]=0,(0|(A=LI(I,C)))!=(I+4|0)&&4==((I=D[A+32>>2])-(A=D[A+28>>2])|0)&&(D[C+12>>2]=e[0|A]|e[A+1|0]<<8|e[A+2|0]<<16|e[A+3|0]<<24),A=D[C+12>>2],B[C+11|0]<0&&sA(D[C>>2]),d=C+16|0}else aQ(),U();return 0|A},Ha:function(A,I,g,C){A|=0,I|=0,C|=0;var Q=0,E=0,i=0;if(d=A=d-32|0,(Q=bg(g|=0))>>>0<4294967280){A:{if(Q>>>0>=11)E=DC(i=Q+16&-16),D[A+24>>2]=-2147483648|i,D[A+16>>2]=E,D[A+20>>2]=Q;else if(B[A+27|0]=Q,E=A+16|0,!Q)break A;xA(E,g,Q)}B[Q+E|0]=0,D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,(0|(g=LI(I,A+16|0)))!=(I+4|0)&&(0|(I=D[g+28>>2]))!=(0|(E=D[g+32>>2]))&&(3&(I=E-I|0)||((Q=I>>>2|0)>>>0>(i=(E=D[A+4>>2])-(I=D[A>>2])>>2)>>>0?($I(A,Q-i|0),I=D[A>>2],E=D[A+4>>2]):Q>>>0>=i>>>0||(D[A+4>>2]=E=(Q<<2)+I|0),(0|I)==(0|E)?(sQ(),U()):xA(Q=I,I=D[g+28>>2],D[g+32>>2]-I|0))),(I=D[C>>2])&&(D[C+4>>2]=I,sA(I)),D[C>>2]=D[A>>2],D[C+4>>2]=D[A+4>>2],D[C+8>>2]=D[A+8>>2],B[A+27|0]<0&&sA(D[A+16>>2]),d=A+32|0}else aQ(),U()},Ia:function(A,I,g){A|=0,I|=0,g|=0;var C=0,Q=0,E=0,i=0;if(d=A=d-32|0,D[A+24>>2]=0,D[A+28>>2]=0,(C=bg(g))>>>0<4294967280){A:{if(C>>>0>=11)Q=DC(E=C+16&-16),D[A+16>>2]=-2147483648|E,D[A+8>>2]=Q,D[A+12>>2]=C;else if(B[A+19|0]=C,Q=A+8|0,!C)break A;xA(Q,g,C)}B[C+Q|0]=0,(0|(g=I+4|0))!=(0|(I=LI(I,A+8|0)))&&8==((g=D[I+32>>2])-(I=D[I+28>>2])|0)&&(g=e[I+4|0]|e[I+5|0]<<8|e[I+6|0]<<16|e[I+7|0]<<24,D[A+24>>2]=e[0|I]|e[I+1|0]<<8|e[I+2|0]<<16|e[I+3|0]<<24,D[A+28>>2]=g),i=N[A+24>>3],B[A+19|0]<0&&sA(D[A+8>>2]),d=A+32|0}else aQ(),U();return+i},Ja:function(A,I,g){A|=0,I|=0;var C,Q=0,E=0,i=0;if(d=C=d-16|0,(Q=bg(g|=0))>>>0<4294967280){A:{if(Q>>>0>=11)E=DC(i=Q+16&-16),D[C+8>>2]=-2147483648|i,D[C>>2]=E,D[C+4>>2]=Q;else if(B[C+11|0]=Q,E=C,!Q)break A;xA(E,g,Q)}B[Q+E|0]=0,g=jg(I,C,E=A+16|0),I=B[A+27|0],A=D[A+16>>2],B[C+11|0]<0&&sA(D[C>>2]),d=C+16|0,A=g?(0|I)<0?A:E:0}else aQ(),U();return 0|A},Ka:function(A,I){return D[8+(I|=0)>>2]},La:function(A,I,g){var C,Q=0,E=0,i=0,o=0,a=0,r=0,e=0;C=g|=0;A:if(D[12+(Q=A|=0)>>2]!=(0|(I|=0))){if(A=I,(0|(I=D[Q+4>>2]))!=(0|(g=D[Q>>2])))for(;E=I-12|0,B[I-1|0]<0&&sA(D[E>>2]),(0|g)!=(0|(I=E)););if(D[Q+12>>2]=A,D[Q+4>>2]=g,(0|(I=D[A>>2]))!=(0|(r=A+4|0)))for(;;){if(D[Q+8>>2]==(0|g)){o=0;I:{g:{C:{if((g=1+(i=((E=D[Q+4>>2])-(A=D[Q>>2])|0)/12|0)|0)>>>0<357913942){if(e=(a=(D[Q+8>>2]-A|0)/12|0)<<1,g=a>>>0<178956970?g>>>0>e>>>0?g:e:357913941){if(g>>>0>=357913942)break C;o=DC(s(g,12))}if(a=s(g,12),g=s(i,12)+o|0,B[I+27|0]>=0?(i=D[I+20>>2],D[g>>2]=D[I+16>>2],D[g+4>>2]=i,D[g+8>>2]=D[I+24>>2]):(Lg(g,D[I+16>>2],D[I+20>>2]),E=D[Q+4>>2],A=D[Q>>2]),o=o+a|0,i=g+12|0,(0|A)==(0|E))break g;for(;a=D[4+(E=E-12|0)>>2],D[(g=g-12|0)>>2]=D[E>>2],D[g+4>>2]=a,D[g+8>>2]=D[E+8>>2],D[E>>2]=0,D[E+4>>2]=0,D[E+8>>2]=0,(0|A)!=(0|E););if(D[Q+8>>2]=o,A=D[Q+4>>2],D[Q+4>>2]=i,E=D[Q>>2],D[Q>>2]=g,(0|A)==(0|E))break I;for(;g=A-12|0,B[A-1|0]<0&&sA(D[g>>2]),A=g,(0|g)!=(0|E););break I}iQ(),U()}xg(1336),U()}D[Q+8>>2]=o,D[Q+4>>2]=i,D[Q>>2]=g}E&&sA(E)}else B[I+27|0]>=0?(A=D[I+20>>2],D[g>>2]=D[I+16>>2],D[g+4>>2]=A,D[g+8>>2]=D[I+24>>2]):Lg(g,D[I+16>>2],D[I+20>>2]),D[Q+4>>2]=g+12;I:if(g=D[I+4>>2])for(;A=g,g=D[g>>2];);else{if(D[(A=D[I+8>>2])>>2]==(0|I))break I;for(I=I+8|0;I=(g=D[I>>2])+8|0,(0|g)!=D[(A=D[g+8>>2])>>2];);}if((0|A)==(0|r))break A;g=D[Q+4>>2],I=A}}return g=0,(0|C)<0||(D[Q+4>>2]-(A=D[Q>>2])|0)/12>>>0<=C>>>0||(A=A+s(C,12)|0,g=B[A+11|0]<0?D[A>>2]:A),0|g},Ma:function(A){var I=0,g=0,C=0;if(A|=0){if(B[A+27|0]<0&&sA(D[A+16>>2]),I=D[A>>2]){if((0|(g=D[A+4>>2]))==(0|I))C=I;else{for(;C=g-12|0,B[g-1|0]<0&&sA(D[C>>2]),(0|(g=C))!=(0|I););C=D[A>>2]}D[A+4>>2]=I,sA(C)}sA(A)}},Na:function(){var A,I;return A=DC(40),D[A+4>>2]=0,D[A+8>>2]=0,D[A>>2]=A+4,D[(I=A+16|0)>>2]=0,D[I+4>>2]=0,D[A+24>>2]=0,D[A+28>>2]=0,D[A+12>>2]=I,D[A+32>>2]=0,D[A+36>>2]=0,0|A},Oa:function(A,I,g,C){A|=0,I|=0,g|=0,C|=0;var Q,E=0,i=0;d=Q=d+-64|0,r[38+(E=Q+8|0)>>1]=0,D[E>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,B[E+29|0]=0,B[E+30|0]=0,B[E+31|0]=0,B[E+32|0]=0,B[E+33|0]=0,B[E+34|0]=0,B[E+35|0]=0,B[E+36|0]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=I,D[E+8>>2]=g,D[E+12>>2]=0,fA(I=Q+48|0,A,E,C),D[A+24>>2]=D[Q+48>>2];A:if((0|(g=A+24|0))!=(0|I))if(E=Q+48|4,C=(I=e[Q+63|0])<<24>>24,B[11+(i=A+28|0)|0]>=0){if((0|C)>=0){A=D[E+4>>2],D[i>>2]=D[E>>2],D[i+4>>2]=A,D[i+8>>2]=D[E+8>>2];break A}$g(i,D[Q+52>>2],D[Q+56>>2])}else Tg(i,(A=(0|C)<0)?D[Q+52>>2]:E,A?D[Q+56>>2]:I);return B[Q+63|0]<0&&sA(D[Q+52>>2]),d=Q- -64|0,0|g},Pa:function(A,I,g,C){A|=0,I|=0,g|=0,C|=0;var Q,E=0,i=0;d=Q=d+-64|0,r[38+(E=Q+8|0)>>1]=0,D[E>>2]=0,D[E+8>>2]=0,D[E+12>>2]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E+24>>2]=0,D[E+28>>2]=0,B[E+29|0]=0,B[E+30|0]=0,B[E+31|0]=0,B[E+32|0]=0,B[E+33|0]=0,B[E+34|0]=0,B[E+35|0]=0,B[E+36|0]=0,D[E+16>>2]=0,D[E+20>>2]=0,D[E>>2]=I,D[E+8>>2]=g,D[E+12>>2]=0,yA(I=Q+48|0,A,E,C),D[A+24>>2]=D[Q+48>>2];A:if((0|(g=A+24|0))!=(0|I))if(E=Q+48|4,C=(I=e[Q+63|0])<<24>>24,B[11+(i=A+28|0)|0]>=0){if((0|C)>=0){A=D[E+4>>2],D[i>>2]=D[E>>2],D[i+4>>2]=A,D[i+8>>2]=D[E+8>>2];break A}$g(i,D[Q+52>>2],D[Q+56>>2])}else Tg(i,(A=(0|C)<0)?D[Q+52>>2]:E,A?D[Q+56>>2]:I);return B[Q+63|0]<0&&sA(D[Q+52>>2]),d=Q- -64|0,0|g},Qa:function(A,I,g){return 0|iC(I|=0,g|=0)},Ra:function(A,I,g){A|=0,I|=0;var C=0,Q=0,E=0;if(d=A=d-32|0,(C=bg(g|=0))>>>0<4294967280){A:{if(C>>>0>=11)Q=DC(E=C+16&-16),D[A+24>>2]=-2147483648|E,D[A+16>>2]=Q,D[A+20>>2]=C;else if(B[A+27|0]=C,Q=A+16|0,!C)break A;xA(Q,g,C)}B[C+Q|0]=0,B[A+4|0]=0,D[A>>2]=1701667182,B[A+11|0]=4,g=-1,(C=D[I+4>>2])&&(g=-1,(C=yI(C,A,A+16|0))&&(g=Og(I,D[C+24>>2]))),I=g,B[A+11|0]<0&&sA(D[A>>2]),B[A+27|0]<0&&sA(D[A+16>>2]),d=A+32|0}else aQ(),U();return 0|I},Sa:function(A,I,g,C){A|=0,I|=0,C|=0;var Q,E=0,i=0;d=Q=d-32|0;A:{I:{if((E=bg(g|=0))>>>0<4294967280){g:{if(E>>>0>=11)A=DC(i=E+16&-16),D[Q+24>>2]=-2147483648|i,D[Q+16>>2]=A,D[Q+20>>2]=E;else if(B[Q+27|0]=E,A=Q+16|0,!E)break g;xA(A,g,E)}if(B[A+E|0]=0,(g=bg(C))>>>0>=4294967280)break I;g:{if(g>>>0>=11)A=DC(E=g+16&-16),D[Q+8>>2]=-2147483648|E,D[Q>>2]=A,D[Q+4>>2]=g;else if(B[Q+11|0]=g,A=Q,!g)break g;xA(A,C,g)}B[A+g|0]=0,A=-1,(g=D[I+4>>2])&&(A=-1,(g=yI(g,Q+16|0,Q))&&(A=Og(I,D[g+24>>2]))),B[Q+11|0]<0&&sA(D[Q>>2]),B[Q+27|0]<0&&sA(D[Q+16>>2]),d=Q+32|0;break A}aQ(),U()}aQ(),U()}return 0|A},Ta:function(A,I,g){return D[D[8+(I|=0)>>2]+((g|=0)<<2)>>2]},Ua:function(A,I,g){A|=0,g|=0;var C=0,Q=0;C=(A=D[12+(I|=0)>>2])-(I=D[I+8>>2])|0,A=0;A:if(C){C=(A=C>>2)>>>0>1?A:1,A=0;I:{for(;;){if(D[(Q=D[I+(A<<2)>>2])+60>>2]==(0|g))break I;if((0|C)==(0|(A=A+1|0)))break}A=0;break A}A=-1==(0|A)?0:Q}return 0|A},Va:function(A,I){return D[4+(I|=0)>>2]},Wa:function(A,I,g){A|=0,g|=0;var C,Q=0;if((C=D[4+(I|=0)>>2])&&!((0|(I=D[D[D[I+8>>2]+(g<<2)>>2]+60>>2]))<0)&&(0|(A=D[C+24>>2]))!=(0|(g=D[C+28>>2])))A:{for(;;){if((0|I)==D[(Q=D[A>>2])+24>>2])break A;if((0|g)==(0|(A=A+4|0)))break}Q=0}return 0|Q},Xa:function(A,I,g,C){var Q,B;return A|=0,g|=0,C|=0,d=A=d-16|0,I=D[96+(I|=0)>>2],D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,B=(g=xA(Q=DC(12),I+s(g,12)|0,12))+12|0,(I=D[C>>2])&&(D[C+4>>2]=I,sA(I)),D[C+8>>2]=g+12,D[C+4>>2]=B,D[C>>2]=Q,d=A+16|0,1},Ya:function(A,I,g){A|=0,I|=0;var C,Q,E,i,o,a,r=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0,K=0,M=0,l=0,L=0,u=0,p=0,H=0,q=0,W=0,V=0;a=g|=0,g=0,d=Q=d-96|0,bI(C=Q+16|0,0,76),D[Q+92>>2]=-1,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,d=E=d-16|0,D[C+68>>2]=0,D[C+72>>2]=0,D[C>>2]=I,d=i=d-16|0,o=I,(D[I+24>>2]-(A=D[I+20>>2])|0)<=0||-1!=(0|(A=D[A>>2]))&&(g=D[D[I+8>>2]+(A<<2)>>2]);A:{I:{if(g){A=D[o+100>>2],k=D[o+96>>2],D[i+8>>2]=0,D[i>>2]=0,D[i+4>>2]=0,I=(0|(N=A-k|0))/12|0;g:if(N){if(I>>>0>=357913942)break I;if(r=DC(N),D[i>>2]=r,D[i+8>>2]=r+s(I,12),A=0,N=bI(F=r,0,r=s((N-12>>>0)/12|0,12)+12|0),D[i+4>>2]=r+N,e[g+84|0]){if(r=1&(g=I>>>0>1?I:1),I>>>0>=2)for(F=-2&g;g=s(A,12),R=D[4+(I=g+k|0)>>2],y=D[I>>2],D[8+(g=g+N|0)>>2]=D[I+8>>2],D[g>>2]=y,D[g+4>>2]=R,g=s(1|A,12),R=D[8+(I=g+k|0)>>2],y=D[I+4>>2],D[(g=g+N|0)>>2]=D[I>>2],D[g+4>>2]=y,D[g+8>>2]=R,A=A+2|0,(0|F)!=(0|(f=f+2|0)););if(!r)break g;I=s(A,12),g=D[4+(A=I+k|0)>>2],f=D[A>>2],D[8+(I=I+N|0)>>2]=D[A+8>>2],D[I>>2]=f,D[I+4>>2]=g}else for(r=I>>>0>1?I:1,A=D[g+68>>2];g=s(f,12),F=D[A+(D[(I=g+k|0)>>2]<<2)>>2],R=D[A+(D[I+4>>2]<<2)>>2],D[8+(g=g+N|0)>>2]=D[A+(D[I+8>>2]<<2)>>2],D[g+4>>2]=R,D[g>>2]=F,(0|r)!=(0|(f=f+1|0)););}if(d=l=d-16|0,r=DC(88),D[r>>2]=0,D[r+4>>2]=0,D[r+56>>2]=0,D[r+48>>2]=0,D[r+52>>2]=0,D[r+40>>2]=0,D[r+44>>2]=0,D[r+32>>2]=0,D[r+36>>2]=0,D[r+24>>2]=0,D[r+28>>2]=0,D[r+16>>2]=0,D[r+20>>2]=0,D[r+8>>2]=0,D[r+12>>2]=0,D[(A=r- -64|0)>>2]=0,D[A+4>>2]=0,D[r+72>>2]=0,D[r+76>>2]=0,D[r+80>>2]=0,D[r+84>>2]=0,D[r+60>>2]=r,d=K=d-16|0,D[r+80>>2]=0,D[r+84>>2]=0,A=D[r+76>>2],D[r+76>>2]=0,A&&sA(A),D[r+68>>2]=0,D[r+72>>2]=0,A=D[(I=r- -64|0)>>2],D[I>>2]=0,A&&sA(A),(A=s(R=(0|(I=D[i+4>>2]-(f=D[i>>2])|0))/12|0,3))>>>0>(k=D[r+4>>2]-(g=D[r>>2])>>2)>>>0?($I(r,A-k|0),R=(0|(I=D[i+4>>2]-(f=D[i>>2])|0))/12|0,g=D[r>>2]):A>>>0>=k>>>0||(D[r+4>>2]=(A<<2)+g),I)for(N=R>>>0>1?R:1,A=0;k=s(A,12),D[(I=k+g|0)>>2]=D[(k=k+f|0)>>2],D[I+4>>2]=D[k+4>>2],D[I+8>>2]=D[k+8>>2],(0|N)!=(0|(A=A+1|0)););D[K+12>>2]=-1,d=k=d-48|0;g:{C:{Q:{if(S=K+12|0){if((c=(I=(F=D[r+4>>2])-(y=D[r>>2])|0)>>2)>>>0>(A=D[r+16>>2]-(g=D[r+12>>2])>>2)>>>0?(ZA(r+12|0,c-A|0,13684),c=(I=(F=D[r+4>>2])-(y=D[r>>2])|0)>>2):A>>>0<=c>>>0||(D[r+16>>2]=g+(c<<2)),g=0,D[k+40>>2]=0,D[k+32>>2]=0,D[k+36>>2]=0,I){B:{if((0|I)>=0)for(g=DC(I),D[k+36>>2]=g,D[k+32>>2]=g,D[k+40>>2]=(c<<2)+g,A=g,I=0;;){if((N=D[(I<<2)+y>>2])>>>0<(A=A-g>>2)>>>0||(D[k+16>>2]=0,(f=N+1|0)>>>0>A>>>0?(ZA(k+32|0,f-A|0,k+16|0),y=D[r>>2],F=D[r+4>>2],g=D[k+32>>2]):A>>>0<=f>>>0||(D[k+36>>2]=(f<<2)+g)),D[(A=(N<<2)+g|0)>>2]=D[A>>2]+1,(I=I+1|0)>>>0>=(c=(A=F-y|0)>>2)>>>0)break B;A=D[k+36>>2]}break Q}if(D[k+24>>2]=0,D[k+16>>2]=0,D[k+20>>2]=0,A){if(c>>>0>=536870912)break C;A=DC(I=A<<1),D[k+16>>2]=A,D[k+24>>2]=f=A+(c<<3)|0,bI(A,255,I),D[k+20>>2]=f}}else D[k+24>>2]=0,D[k+16>>2]=0,D[k+20>>2]=0;if(F=0,D[k+8>>2]=0,D[k>>2]=0,D[k+4>>2]=0,N=(A=D[k+36>>2]-g|0)>>2,A){if((0|A)<0)break C;if(b=DC(A),D[k>>2]=b,D[k+8>>2]=(N<<2)+b,I=A,A=bI(b,0,A),D[k+4>>2]=I+A,R=3&(f=N>>>0>1?N:1),I=0,f-1>>>0>=3)for(w=-4&f;D[(f=t<<2)+A>>2]=I,D[(Y=4|f)+A>>2]=I=D[g+f>>2]+I|0,D[(J=8|f)+A>>2]=I=I+D[g+Y>>2]|0,D[(f|=12)+A>>2]=I=I+D[g+J>>2]|0,I=I+D[g+f>>2]|0,t=t+4|0,(0|w)!=(0|(n=n+4|0)););if(R)for(;D[(f=t<<2)+A>>2]=I,t=t+1|0,I=D[g+f>>2]+I|0,(0|R)!=(0|(G=G+1|0)););}if(c)for(Y=D[r+12>>2];;){n=-1,-1!=(0|(A=((f=F+1|0)>>>0)%3|0?f:F-2|0))&&(n=D[(A<<2)+y>>2]),A=D[(I=(L=F<<2)+y|0)>>2];B:{E:{if(!((F>>>0)%3|0)){if(G=-1,-1!=(0|(I=F+2|0))&&(G=D[(I<<2)+y>>2]),!((0|A)==(0|n)|(0|A)==(0|G))&(0|n)!=(0|G))break E;D[r+40>>2]=D[r+40>>2]+1,f=F+3|0;break B}G=D[I-4>>2]}E:{i:if(!((0|(J=D[(I=G<<2)+g>>2]))<=0))for(R=D[k+16>>2],I=D[I+b>>2],t=0;;){if(-1==(0|(h=D[(w=R+(I<<3)|0)>>2])))break i;if((0|n)==(0|h)&&(0|(h=-1!=(0|(w=D[w+4>>2]))?D[(w<<2)+y>>2]:-1))!=(0|A)){for(;A=I,!((0|J)<=(0|(t=t+1|0))||(D[(h=R+(A<<3)|0)>>2]=p=D[(u=R+((I=A+1|0)<<3)|0)>>2],D[h+4>>2]=D[u+4>>2],-1==(0|p))););if(D[R+(A<<3)>>2]=-1,-1==(0|w))break i;D[Y+L>>2]=w,D[Y+(w<<2)>>2]=F;break E}if(I=I+1|0,(0|J)==(0|(t=t+1|0)))break}if(!((0|(R=D[(A=n<<2)+g>>2]))<=0))for(n=D[k+16>>2],I=D[A+b>>2],t=0;;){if(-1==D[(A=n+(I<<3)|0)>>2]){D[A>>2]=G,D[A+4>>2]=F;break E}if(I=I+1|0,(0|R)==(0|(t=t+1|0)))break}}}if(!(c>>>0>(F=f)>>>0))break}D[S>>2]=N,b&&sA(b),(A=D[k+16>>2])&&(D[k+20>>2]=A,sA(A)),(A=D[k+32>>2])&&(D[k+36>>2]=A,sA(A))}if(d=k+48|0,Y=0!=(0|S)){if(d=n=d-32|0,G=D[r>>2],A=D[r+4>>2],D[n+24>>2]=0,D[n+16>>2]=0,D[n+20>>2]=0,I=A-G|0){if((0|I)<0)break C;g=DC((f=1+(t=(I>>=2)-1>>>5|0)|0)<<2),D[n+24>>2]=f,D[n+16>>2]=g,D[n+20>>2]=I,D[g+((I>>>0<33?0:t)<<2)>>2]=0,t=bI(t=g,0,g=I>>>5<<2),(I&=31)&&(D[(g=g+t|0)>>2]=D[g>>2]&(-1>>>32-I^-1))}for(D[n+8>>2]=0,D[n>>2]=0;;){if(c=0,f=0,(0|A)!=(0|G)){for(;;){B:if(!(D[(g=D[n+16>>2])+(f>>>3&536870908)>>2]>>>f&1)){for(D[n+4>>2]=t=D[n>>2],I=D[r+12>>2],A=f;N=A,!(-1==(0|(A=((k=A+1|0)>>>0)%3|0?k:A-2|0))||-1==(0|(A=D[I+(A<<2)>>2]))||(0|f)==(0|(A=((k=A+1|0)>>>0)%3|0?k:A-2|0))|-1==(0|A)||D[(A>>>3&536870908)+g>>2]>>>A&1););I=t,R=N;E:{i:{for(;;){if(D[(A=(R>>>3&536870908)+g|0)>>2]=D[A>>2]|1<<R,k=((A=R+1|0)>>>0)%3|0?A:R-2|0,w=(y=((J=(R>>>0)%3|0)?-1:2)+R|0)<<2,(0|I)!=(0|t))if(S=D[(k<<2)+G>>2],b=D[r+12>>2],A=I,-1==(0|y))for(;;){if((0|S)==D[A>>2]&&(F=-1,y=-1,-1!=(0|(g=D[A+4>>2]))))break i;if((0|t)==(0|(A=A+8|0)))break}else for(h=b+w|0;;){if((0|S)==D[A>>2]&&(0|(g=D[A+4>>2]))!=(0|(F=D[h>>2]))){if(t=-1,A=-1,-1==(0|g))break E;break i}if((0|t)==(0|(A=A+8|0)))break}if(y=D[G+w>>2],D[n+8>>2]==(0|t)){if((A=1+(t=(g=t-I|0)>>3)|0)>>>0>=536870912)break C;if(F=g>>2,F=t>>>0<268435455?A>>>0>F>>>0?A:F:536870911){if(F>>>0>=536870912)break Q;A=DC(F<<3)}else A=0;D[(t=A+(t<<3)|0)>>2]=y,D[t+4>>2]=k,t=t+8|0,(0|g)>0&&xA(A,I,g),D[n+8>>2]=A+(F<<3),D[n+4>>2]=t,D[n>>2]=A,I&&sA(I)}else D[t>>2]=y,D[t+4>>2]=k,D[n+4>>2]=t=t+8|0;o:{if(J)A=R-1|0;else if(-1==(0|(A=R+2|0)))break o;if(-1!=(0|(A=D[D[r+12>>2]+(A<<2)>>2]))&&!((0|N)==(0|(R=A+((A>>>0)%3|0?-1:2)|0))|-1==(0|R))){G=D[r>>2],I=D[n>>2],g=D[n+16>>2];continue}}break}G=D[r>>2];break B}t=g,A=D[b+(g<<2)>>2]}-1!=(0|F)&&(D[b+(F<<2)>>2]=-1),-1!=(0|A)&&(D[D[r+12>>2]+(A<<2)>>2]=-1),D[(A=D[r+12>>2])+(y<<2)>>2]=-1,D[A+(t<<2)>>2]=-1,c=1}if(!((f=f+1|0)>>>0<(A=D[r+4>>2])-G>>2>>>0))break}if(c)continue}break}(A=D[n>>2])&&sA(A),(A=D[n+16>>2])&&sA(A),f=0,y=0,c=0,d=N=(d=n+32|0)-32|0,D[r+36>>2]=A=D[K+12>>2],G=r+24|0;B:{if((I=D[r+28>>2]-(g=D[r+24>>2])>>2)>>>0<A>>>0)ZA(G,A-I|0,13684),D[N+24>>2]=0,D[N+16>>2]=0,D[N+20>>2]=0;else if(A>>>0<I>>>0&&(D[r+28>>2]=g+(A<<2)),D[N+24>>2]=0,D[N+16>>2]=0,D[N+20>>2]=0,!A)break B;if((0|A)<0)break C;f=DC((g=1+(I=A-1>>>5|0)|0)<<2),D[N+24>>2]=g,D[N+16>>2]=f,D[N+20>>2]=A,D[((A>>>0<33?0:I)<<2)+f>>2]=0,g=bI(f,0,I=A>>>5<<2),(t=31&A)&&(D[(I=I+g|0)>>2]=D[I>>2]&(-1>>>32-t^-1))}if(F=D[r>>2],R=D[r+4>>2],D[N+8>>2]=0,D[N>>2]=0,D[N+4>>2]=0,I=R-F|0){if((0|I)<0)break C;if(n=DC((t=1+(g=(I>>=2)-1>>>5|0)|0)<<2),D[N+8>>2]=t,D[N>>2]=n,D[N+4>>2]=I,D[((I>>>0<33?0:g)<<2)+n>>2]=0,t=bI(n,0,g=I>>>5<<2),(k=31&I)&&(D[(g=g+t|0)>>2]=D[g>>2]&(-1>>>32-k^-1)),!(I>>>0<3)){for(;;){if(g=-1,-1!=(0|(k=(w=s(y,3))+1|0))&&(g=D[(k<<2)+F>>2]),(0|(I=D[(t=(w<<2)+F|0)>>2]))!=(0|g)&&(0|(k=I))!=(0|(I=D[t+8>>2]))&&(b=0,(0|I)!=(0|g))){for(;;){if(!(D[((t=b+w|0)>>>3&536870908)+n>>2]>>>t&1)){if(R=(g=1<<(I=D[(t<<2)+F>>2]))&D[((n=I>>>5|0)<<2)+f>>2]){if((0|(g=D[r+28>>2]))==D[r+32>>2]){if((g=1+(n=(k=g-(f=D[G>>2])|0)>>2)|0)>>>0>=1073741824)break C;if(F=k>>1,F=n>>>0<536870911?g>>>0>F>>>0?g:F:1073741823){if(F>>>0>=1073741824)break Q;g=DC(F<<2)}else g=0;D[(n=g+(n<<2)|0)>>2]=-1,(0|k)>0&&xA(g,f,k),D[r+32>>2]=g+(F<<2),D[r+28>>2]=n+4,D[r+24>>2]=g,f&&sA(f)}else D[g>>2]=-1,D[r+28>>2]=g+4;if((0|(g=D[r+52>>2]))==D[r+56>>2]){if((g=1+(n=(k=g-(f=D[r+48>>2])|0)>>2)|0)>>>0>=1073741824)break C;if(F=k>>1,F=n>>>0<536870911?g>>>0>F>>>0?g:F:1073741823){if(F>>>0>=1073741824)break Q;g=DC(F<<2)}else g=0;D[(n=g+(n<<2)|0)>>2]=I,(0|k)>0&&xA(g,f,k),D[r+56>>2]=g+(F<<2),D[r+52>>2]=n+4,D[r+48>>2]=g,f&&sA(f)}else D[g>>2]=I,D[r+52>>2]=g+4;if((0|(g=D[N+20>>2]))==(I=D[N+24>>2])<<5){if((g+1|0)<0)break C;vI(f=N+16|0,I=g>>>0<=1073741822?(I<<=6)>>>0<(g=g+32&-32)>>>0?g:I:2147483647),g=D[N+20>>2]}D[N+20>>2]=g+1,f=D[(I=D[N+16>>2]+(g>>>3&536870908)|0)>>2],W=I,V=JC(g)&f,D[W>>2]=V,g=1<<A,n=A>>>5|0,I=A,A=A+1|0}k=A,D[(A=(f=D[N+16>>2])+(n<<2)|0)>>2]=D[A>>2]|g,J=D[r+24>>2]+(I<<2)|0,S=D[r+12>>2],F=D[r>>2],n=D[N>>2],A=t;B:{E:{i:{o:{a:{r:{for(;;){if(-1==(0|A))break r;if(D[(g=(A>>>3&536870908)+n|0)>>2]=D[g>>2]|1<<A,D[J>>2]=A,R&&(D[(A<<2)+F>>2]=I),g=-1,-1!=(0|(A=((h=A+1|0)>>>0)%3|0?h:A-2|0))&&(g=-1,-1!=(0|(A=D[S+(A<<2)>>2]))&&(g=((g=A+1|0)>>>0)%3|0?g:A-2|0)),(0|t)==(0|(A=g)))break}if(-1!=(0|t))break B;A=1;break a}if((t>>>0)%3|0)A=t-1|0;else if(-1==(0|(A=t+2|0)))break o}if(-1!=(0|(A=D[S+(A<<2)>>2]))){if(!((A>>>0)%3|0))break i;A=A-1|0,F=D[r>>2],n=D[N>>2];break E}}F=D[r>>2],n=D[N>>2];break B}if(F=D[r>>2],n=D[N>>2],-1==(0|(A=A+2|0)))break B}for(g=D[r+12>>2];;){if(D[(t=(A>>>3&536870908)+n|0)>>2]=D[t>>2]|1<<A,R&&(D[(A<<2)+F>>2]=I),(A>>>0)%3|0)A=A-1|0;else if(-1==(0|(A=A+2|0)))break B;if(-1==(0|(A=D[g+(A<<2)>>2])))break B;if(-1==(0|(A=A+((A>>>0)%3|0?-1:2)|0)))break}}A=k}if(3==(0|(b=b+1|0)))break}F=D[r>>2],R=D[r+4>>2]}if(!((y=y+1|0)>>>0<(R-F>>2>>>0)/3>>>0))break}f=D[N+16>>2]}}if(D[r+44>>2]=0,A=D[N+20>>2])for(I=31&A,t=(A>>>3&536870908)+f|0,A=0,g=f;D[g>>2]>>>A&1||(D[r+44>>2]=c=c+1|0),(0|t)!=(0|(g=((k=31==(0|A))<<2)+g|0))|(0|(A=k?0:A+1|0))!=(0|I););(A=D[N>>2])&&(sA(A),f=D[N+16>>2]),f&&sA(f),d=N+32|0}d=K+16|0,Y||(D[l+8>>2]=0,Yg(r),r=0),d=l+16|0,A=r;break g}xg(1336),U()}iQ(),U()}(I=D[i>>2])&&(D[i+4>>2]=I,sA(I))}else A=0;d=i+16|0;break A}iQ(),U()}if(I=D[C+4>>2],D[C+4>>2]=A,I&&(Yg(I),A=D[C+4>>2]),A)if(A=D[o+100>>2],I=D[o+96>>2],B[E+12|0]=0,hI(C+56|0,(A-I|0)/12|0,E+12|0),(0|(A=D[o+100>>2]))!=(0|(I=D[o+96>>2])))for(;;){if(!(D[D[C+56>>2]+(M>>>3&536870908)>>2]>>>M&1)){if(GA(C,0,A=s(M,3)),I=D[C+8>>2],g=D[C+12>>2],GA(C,1,A+1|0),t=D[C+20>>2],f=D[C+24>>2],GA(C,2,A+2|0),g=D[C+36>>2]-D[C+32>>2]>>2>>>0>((A=(t=f-t>>2)>>>0>(g=(I=g-I|0)>>2)>>>0)?t:g)>>>0?2:A?1:I?0:-1,D[C+68>>2]<=0||(D[E+12>>2]=D[C+76>>2],D[E+8>>2]=Q,Ig(E+8|0,E+12|0),A=(0|(A=D[44+((g<<2)+C|0)>>2]))<0?-1:D[(D[D[C>>2]+96>>2]+s(I=(A>>>0)/3|0,12)|0)+(A-s(I,3)<<2)>>2],D[E+12>>2]=A,D[E+8>>2]=Q,Ig(E+8|0,E+12|0),D[C+72>>2]=(I=D[C+72>>2])+2,1&I&&(D[E+12>>2]=A,D[E+8>>2]=Q,Ig(E+8|0,E+12|0),D[C+72>>2]=D[C+72>>2]+1)),d=I=d-16|0,D[C+68>>2]=D[C+68>>2]+1,A=s(g,12)+C|0,!((0|(t=D[A+12>>2]-D[A+8>>2]|0))<=0)){A=-1,f=((g=D[44+((g<<2)+C|0)>>2])>>>0)/3|0,D[(r=D[C+56>>2]+((k=(N=-1==(0|g))?-1:f)>>>3&536870908)|0)>>2]=D[r>>2]|1<<k,D[C+72>>2]=D[C+72>>2]+1,D[I+12>>2]=(0|g)>=0?D[(D[D[C>>2]+96>>2]+s(f,12)|0)+((g>>>0)%3<<2)>>2]:-1,D[I+8>>2]=Q,Ig(I+8|0,I+12|0);A:if(N)D[I+12>>2]=-1,D[I+8>>2]=Q,Ig(I+8|0,I+12|0);else{if(r=(0|(k=((k=g+1|0)>>>0)%3|0?k:g-2|0))>=0?D[(D[D[C>>2]+96>>2]+s(N=(k>>>0)/3|0,12)|0)+(k-s(N,3)<<2)>>2]:-1,D[I+12>>2]=r,D[I+8>>2]=Q,Ig(I+8|0,I+12|0),(0|(f=g+(g-s(f,3)|0?-1:2)|0))<0)break A;A=D[(D[D[C>>2]+96>>2]+s(A=(f>>>0)/3|0,12)|0)+(f-s(A,3)<<2)>>2]}if(D[C+76>>2]=A,D[I+12>>2]=A,D[I+8>>2]=Q,A=-1,Ig(I+8|0,I+12|0),A=-1!=(0|g)?D[D[D[C+4>>2]+12>>2]+(g<<2)>>2]:A,!(t>>>0<=7))for(N=(g=t>>>2|0)>>>0>1?g:1,g=1;;){t=A,k=(A>>>0)/3|0,D[(f=D[C+56>>2]+((A=-1==(0|A)?-1:k)>>>3&536870908)|0)>>2]=D[f>>2]|1<<A,D[C+72>>2]=D[C+72>>2]+1,A=-1,A=(0|t)>=0?D[(D[D[C>>2]+96>>2]+s(k,12)|0)+((t>>>0)%3<<2)>>2]:A,D[C+76>>2]=A,D[I+12>>2]=A,D[I+8>>2]=Q,Ig(I+8|0,I+12|0);A:{I:{if(1&g){if(f=-1,-1==(0|t))break A;if((0|t)!=(0|s(k,3))){A=t-1|0;break I}A=t+2|0}else{if(f=-1,-1==(0|t))break A;A=((A=t+1|0)>>>0)%3|0?A:t-2|0}if(f=-1,-1==(0|A))break A}f=D[D[D[C+4>>2]+12>>2]+(A<<2)>>2]}if(A=f,(0|N)==(0|(g=g+1|0)))break}}d=I+16|0,I=D[o+96>>2],A=D[o+100>>2]}if(H=1,!((M=M+1|0)>>>0<(A-I|0)/12>>>0))break}else H=1;return d=E+16|0,H?((A=D[a>>2])&&(D[a+4>>2]=A,sA(A)),D[a>>2]=D[Q>>2],D[a+4>>2]=D[Q+4>>2],D[a+8>>2]=D[Q+8>>2],q=D[Q+84>>2]):(A=D[Q>>2])&&(D[Q+4>>2]=A,sA(A)),(A=D[Q+72>>2])&&sA(A),(A=D[Q+48>>2])&&(D[Q+52>>2]=A,sA(A)),(A=D[Q+36>>2])&&(D[Q+40>>2]=A,sA(A)),(A=D[Q+24>>2])&&(D[Q+28>>2]=A,sA(A)),A=D[Q+20>>2],D[Q+20>>2]=0,A&&Yg(A),d=Q+96|0,0|q},Za:function(A,I,g,C){A|=0,g|=0,C|=0;var Q=0,B=0,E=0;if(!(k[80+(I|=0)>>2]>65535||(E=(0|(Q=s(A=(0|(I=D[I+100>>2]-(B=D[I+96>>2])|0))/12|0,6)))==(0|g),!I|(0|g)!=(0|Q))))for(E=1,Q=A>>>0>1?A:1,A=0;I=s(A,6)+C|0,g=s(A,12)+B|0,r[I>>1]=D[g>>2],r[I+2>>1]=D[g+4>>2],r[I+4>>1]=D[g+8>>2],(0|Q)!=(0|(A=A+1|0)););return 0|E},_a:function(A,I,g,C){A|=0,C|=0;var Q,B=0,E=0,i=0;if(!((0|(I=D[100+(I|=0)>>2]-(Q=D[I+96>>2])|0))!=(0|(g|=0))|!I))for(i=(A=(0|g)/12|0)>>>0>1?A:1,A=0;B=s(A,12),D[(E=B+C|0)>>2]=D[(B=B+Q|0)>>2],D[E+4>>2]=D[B+4>>2],D[E+8>>2]=D[B+8>>2],(0|i)!=(0|(A=A+1|0)););return(0|I)==(0|g)|0},$a:function(A,I,g,C){A|=0,g|=0,C|=0;var Q=0,E=0,i=0;d=A=d-32|0,Q=B[24+(I|=0)|0],E=D[3419],D[A+24>>2]=D[3418],D[A+28>>2]=E,E=D[3417],D[A+16>>2]=D[3416],D[A+20>>2]=E;A:{I:{if(g=v(I,g,Q,A+16|0)){if(D[A+8>>2]=0,D[A>>2]=0,D[A+4>>2]=0,I=0,Q){if((0|Q)<0)break I;i=xA(I=DC(Q<<=2),A+16|0,Q)+Q|0}(Q=D[C>>2])&&(D[C+4>>2]=Q,sA(Q)),D[C+8>>2]=i,D[C+4>>2]=i,D[C>>2]=I}d=A+32|0;break A}iQ(),U()}return 0|g},ab:function(A,I,g,C){A|=0,C|=0;var Q,E,i=0,o=0,a=0,r=0,f=0,k=0,N=0,F=0,n=0,R=0,y=0;A=0,d=Q=d-16|0,E=D[80+(I|=0)>>2],i=B[24+(g|=0)|0],D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0;A:{I:{if(i){if((0|i)<0)break I;if(A=DC(I=i<<2),D[Q>>2]=A,D[Q+8>>2]=a=A+I|0,k=1+((r=I-4|0)>>>2|0)&7)for(I=A;D[I>>2]=-1073741824,I=I+4|0,(0|k)!=(0|(o=o+1|0)););else I=A;if(r>>>0>=28)for(;D[I+24>>2]=-1073741824,D[I+28>>2]=-1073741824,D[I+16>>2]=-1073741824,D[I+20>>2]=-1073741824,D[I+8>>2]=-1073741824,D[I+12>>2]=-1073741824,D[I>>2]=-1073741824,D[I+4>>2]=-1073741824,(0|a)!=(0|(I=I+32|0)););D[Q+4>>2]=a}(I=s(i,E))>>>0>(o=D[C+4>>2]-(a=D[C>>2])>>2)>>>0?$I(C,I-o|0):I>>>0>=o>>>0||(D[C+4>>2]=a+(I<<2));g:if(E)if(f=1,(0|i)<=0)for(I=0;;){if(!v(g,e[g+84|0]?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],A))break g;if(f=E>>>0>(I=I+1|0)>>>0,(0|I)==(0|E))break}else{for(R=-4&i,k=3&i,o=0,y=i-1>>>0<3;;){if(v(g,e[g+84|0]?N:D[D[g+68>>2]+(N<<2)>>2],B[g+24|0],A)){if(n=D[C>>2],F=0,i=D[Q>>2],I=0,f=0,!y)for(;t[(a=n+(o<<2)|0)>>2]=t[(r=I<<2)+i>>2],t[a+4>>2]=t[(4|r)+i>>2],t[a+8>>2]=t[(8|r)+i>>2],t[a+12>>2]=t[(12|r)+i>>2],I=I+4|0,o=o+4|0,(0|R)!=(0|(f=f+4|0)););if(k)for(;t[n+(o<<2)>>2]=t[(I<<2)+i>>2],I=I+1|0,o=o+1|0,(0|k)!=(0|(F=F+1|0)););if(f=(N=N+1|0)>>>0<E>>>0,(0|E)!=(0|N))continue}break}A=D[Q>>2]}A&&sA(A),d=Q+16|0,A=1&(-1^f);break A}iQ(),U()}return 0|A},bb:uA,cb:function(A,I,g,C){A|=0,C|=0;var Q,E,i,o=0,a=0,r=0,f=0,k=0,t=0,N=0;d=Q=d-16|0,o=s(E=D[80+(I|=0)>>2],I=(i=e[24+(g|=0)|0])<<24>>24);A:{I:{g:{if(!(1==(0|(A=D[g+28>>2]))|2==(0|A))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,I){if((0|I)<0)break g;a=DC(I),D[Q>>2]=a,D[Q+8>>2]=A=I+a|0,bI(a,0,I),D[Q+4>>2]=A}C:if((k=(A=D[C+4>>2])-(f=D[C>>2])|0)>>>0<o>>>0){if((t=o-k|0)>>>0<=(N=D[C+8>>2])-A>>>0){t&&(A=bI(A,0,t)+t|0),D[C+4>>2]=A;break C}if((0|o)<0)break I;if(N=(A=N-f|0)<<1,(A=A>>>0<1073741823?o>>>0>N>>>0?o:N:2147483647)&&(r=DC(A)),bI(r+k|0,0,t),(0|k)>0&&xA(r,f,k),D[C+8>>2]=A+r,D[C+4>>2]=o+r,D[C>>2]=r,!f)break C;sA(f)}else o>>>0>=k>>>0||(D[C+4>>2]=o+f);C:if(E)if(I){for(f=-2&(A=I-1|0),k=1&A,A=0,I=1,r=0;;){if(IA(g,e[g+84|0]?r:D[D[g+68>>2]+(r<<2)>>2],B[g+24|0],o=D[Q>>2])){B[D[C>>2]+A|0]=e[0|o],I=1,A=A+1|0,a=0;Q:{B:switch(i-1|0){default:for(;B[D[C>>2]+A|0]=e[D[Q>>2]+I|0],B[1+(D[C>>2]+A|0)|0]=e[1+(D[Q>>2]+I|0)|0],I=I+2|0,A=A+2|0,(0|f)!=(0|(a=a+2|0)););break;case 0:break Q;case 1:}k&&(B[D[C>>2]+A|0]=e[D[Q>>2]+I|0],A=A+1|0)}if(I=E>>>0>(r=r+1|0)>>>0,(0|r)!=(0|E))continue}break}a=D[Q>>2]}else for(A=0,I=1;;){if(!IA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],a))break C;if(I=E>>>0>(A=A+1|0)>>>0,(0|A)==(0|E))break}else I=0;a&&sA(a),A=!I}else{if(A=D[g+48>>2],g=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,o){if((0|o)<0)break g;I=xA(a=DC(o),A+g|0,o)+o|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=I,D[C>>2]=a,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}iQ(),U()}return 0|A},db:function(A,I,g,C){A|=0,C|=0;var Q,E,i,o=0,a=0,r=0,f=0,k=0,t=0,N=0;d=Q=d-16|0,o=s(E=D[80+(I|=0)>>2],I=(i=e[24+(g|=0)|0])<<24>>24);A:{I:{g:{if(!(1==(0|(A=D[g+28>>2]))|2==(0|A))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,I){if((0|I)<0)break g;a=DC(I),D[Q>>2]=a,D[Q+8>>2]=A=I+a|0,bI(a,0,I),D[Q+4>>2]=A}C:if((k=(A=D[C+4>>2])-(f=D[C>>2])|0)>>>0<o>>>0){if((t=o-k|0)>>>0<=(N=D[C+8>>2])-A>>>0){t&&(A=bI(A,0,t)+t|0),D[C+4>>2]=A;break C}if((0|o)<0)break I;if(N=(A=N-f|0)<<1,(A=A>>>0<1073741823?o>>>0>N>>>0?o:N:2147483647)&&(r=DC(A)),bI(r+k|0,0,t),(0|k)>0&&xA(r,f,k),D[C+8>>2]=A+r,D[C+4>>2]=o+r,D[C>>2]=r,!f)break C;sA(f)}else o>>>0>=k>>>0||(D[C+4>>2]=o+f);C:if(E)if(I){for(f=-2&(A=I-1|0),k=1&A,A=0,I=1,r=0;;){if(gA(g,e[g+84|0]?r:D[D[g+68>>2]+(r<<2)>>2],B[g+24|0],o=D[Q>>2])){B[D[C>>2]+A|0]=e[0|o],I=1,A=A+1|0,a=0;Q:{B:switch(i-1|0){default:for(;B[D[C>>2]+A|0]=e[D[Q>>2]+I|0],B[1+(D[C>>2]+A|0)|0]=e[1+(D[Q>>2]+I|0)|0],I=I+2|0,A=A+2|0,(0|f)!=(0|(a=a+2|0)););break;case 0:break Q;case 1:}k&&(B[D[C>>2]+A|0]=e[D[Q>>2]+I|0],A=A+1|0)}if(I=E>>>0>(r=r+1|0)>>>0,(0|r)!=(0|E))continue}break}a=D[Q>>2]}else for(A=0,I=1;;){if(!gA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],a))break C;if(I=E>>>0>(A=A+1|0)>>>0,(0|A)==(0|E))break}else I=0;a&&sA(a),A=!I}else{if(A=D[g+48>>2],g=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,o){if((0|o)<0)break g;I=xA(a=DC(o),A+g|0,o)+o|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=I,D[C>>2]=a,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}iQ(),U()}return 0|A},eb:function(A,I,g,C){A|=0,C|=0;var Q,E=0,i=0,o=0,a=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;d=Q=d-16|0,E=s(a=D[80+(I|=0)>>2],A=B[24+(g|=0)|0]);A:{I:{if(!(3==(0|(I=D[g+28>>2]))|4==(0|I))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,A){if((0|A)<0)break I;o=DC(I=A<<1),D[Q>>2]=o,D[Q+8>>2]=i=I+o|0,bI(o,0,I),D[Q+4>>2]=i}(I=D[C+4>>2]-(i=D[C>>2])>>1)>>>0<E>>>0?Qg(C,E-I|0):I>>>0<=E>>>0||(D[C+4>>2]=i+(E<<1));g:if(a)if(A){for(y=-4&A,n=3&A,G=A-1>>>0<3,I=1,E=0;;){if(iA(g,e[g+84|0]?E:D[D[g+68>>2]+(E<<2)>>2],B[g+24|0],o)){if(R=D[C>>2],F=0,i=D[Q>>2],A=0,I=0,!G)for(;r[(t=(k<<1)+R|0)>>1]=f[i+(N=A<<1)>>1],r[t+2>>1]=f[i+(2|N)>>1],r[t+4>>1]=f[i+(4|N)>>1],r[t+6>>1]=f[i+(6|N)>>1],A=A+4|0,k=k+4|0,(0|y)!=(0|(I=I+4|0)););if(n)for(;r[(k<<1)+R>>1]=f[i+(A<<1)>>1],A=A+1|0,k=k+1|0,(0|(F=F+1|0))!=(0|n););if(I=a>>>0>(E=E+1|0)>>>0,(0|E)!=(0|a))continue}break}o=D[Q>>2]}else for(A=0,I=1;;){if(!iA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],o))break g;if(I=a>>>0>(A=A+1|0)>>>0,(0|A)==(0|a))break}else I=0;o&&sA(o),A=1^I}else{if(o=D[g+48>>2],a=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,g=0,A=E<<1){if((0|A)<0)break I;k=(I=xA(g=DC(A),o+a|0,A))+A|0,I=I+(A>>1<<1)|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=k,D[C>>2]=g,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}return 0|A},fb:function(A,I,g,C){A|=0,C|=0;var Q,E=0,i=0,o=0,a=0,k=0,t=0,N=0,F=0,n=0,R=0,y=0,G=0;d=Q=d-16|0,E=s(a=D[80+(I|=0)>>2],A=B[24+(g|=0)|0]);A:{I:{if(!(3==(0|(I=D[g+28>>2]))|4==(0|I))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,A){if((0|A)<0)break I;o=DC(I=A<<1),D[Q>>2]=o,D[Q+8>>2]=i=I+o|0,bI(o,0,I),D[Q+4>>2]=i}(I=D[C+4>>2]-(i=D[C>>2])>>1)>>>0<E>>>0?Qg(C,E-I|0):I>>>0<=E>>>0||(D[C+4>>2]=i+(E<<1));g:if(a)if(A){for(y=-4&A,n=3&A,G=A-1>>>0<3,I=1,E=0;;){if(oA(g,e[g+84|0]?E:D[D[g+68>>2]+(E<<2)>>2],B[g+24|0],o)){if(R=D[C>>2],F=0,i=D[Q>>2],A=0,I=0,!G)for(;r[(t=(k<<1)+R|0)>>1]=f[i+(N=A<<1)>>1],r[t+2>>1]=f[i+(2|N)>>1],r[t+4>>1]=f[i+(4|N)>>1],r[t+6>>1]=f[i+(6|N)>>1],A=A+4|0,k=k+4|0,(0|y)!=(0|(I=I+4|0)););if(n)for(;r[(k<<1)+R>>1]=f[i+(A<<1)>>1],A=A+1|0,k=k+1|0,(0|(F=F+1|0))!=(0|n););if(I=a>>>0>(E=E+1|0)>>>0,(0|E)!=(0|a))continue}break}o=D[Q>>2]}else for(A=0,I=1;;){if(!oA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],o))break g;if(I=a>>>0>(A=A+1|0)>>>0,(0|A)==(0|a))break}else I=0;o&&sA(o),A=1^I}else{if(o=D[g+48>>2],a=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,g=0,A=E<<1){if((0|A)<0)break I;k=(I=xA(g=DC(A),o+a|0,A))+A|0,I=I+(A>>1<<1)|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=k,D[C>>2]=g,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}return 0|A},gb:uA,hb:function(A,I,g,C){A|=0,C|=0;var Q,E=0,i=0,o=0,a=0,r=0,f=0,k=0,t=0,N=0,F=0,n=0,R=0;d=Q=d-16|0,E=s(a=D[80+(I|=0)>>2],A=B[24+(g|=0)|0]);A:{I:{if(!(5==(0|(I=D[g+28>>2]))|6==(0|I))|!e[g+84|0]){if(D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,A){if((0|A)<0)break I;o=DC(I=A<<2),D[Q>>2]=o,D[Q+8>>2]=i=I+o|0,bI(o,0,I),D[Q+4>>2]=i}(I=D[C+4>>2]-(i=D[C>>2])>>2)>>>0<E>>>0?$I(C,E-I|0):I>>>0<=E>>>0||(D[C+4>>2]=i+(E<<2));g:if(a)if(A){for(n=-4&A,N=3&A,R=A-1>>>0<3,I=1,E=0;;){if(eA(g,e[g+84|0]?E:D[D[g+68>>2]+(E<<2)>>2],B[g+24|0],o)){if(F=D[C>>2],t=0,i=D[Q>>2],A=0,I=0,!R)for(;D[(f=(r<<2)+F|0)>>2]=D[i+(k=A<<2)>>2],D[f+4>>2]=D[i+(4|k)>>2],D[f+8>>2]=D[i+(8|k)>>2],D[f+12>>2]=D[i+(12|k)>>2],A=A+4|0,r=r+4|0,(0|n)!=(0|(I=I+4|0)););if(N)for(;D[(r<<2)+F>>2]=D[i+(A<<2)>>2],A=A+1|0,r=r+1|0,(0|(t=t+1|0))!=(0|N););if(I=a>>>0>(E=E+1|0)>>>0,(0|E)!=(0|a))continue}break}o=D[Q>>2]}else for(A=0,I=1;;){if(!eA(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],o))break g;if(I=a>>>0>(A=A+1|0)>>>0,(0|A)==(0|a))break}else I=0;o&&sA(o),A=1^I}else{if(o=D[g+48>>2],a=D[D[g>>2]>>2],I=0,D[Q+8>>2]=0,D[Q>>2]=0,D[Q+4>>2]=0,g=0,A=E<<2){if((0|A)<0)break I;r=(I=xA(g=DC(A),o+a|0,A))+A|0,I=I+(A>>2<<2)|0}(A=D[C>>2])&&(D[C+4>>2]=A,sA(A)),D[C+8>>2]=I,D[C+4>>2]=r,D[C>>2]=g,A=1}d=Q+16|0,A&=1;break A}iQ(),U()}return 0|A},ib:function(A,I,g,C,Q,E){A|=0,I|=0,g|=0,Q|=0,E|=0;var i=0,o=0,a=0,k=0,N=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0,h=0,J=0,S=0,Y=0;A:{I:{g:{C:{Q:switch((C|=0)-1|0){case 0:A=0,d=F=d-16|0;B:if((0|s(k=D[I+80>>2],i=B[g+24|0]))==(0|Q))if((I=1!=D[g+28>>2])|!(A=e[g+84|0])){if(C=0,D[F+8>>2]=0,D[F>>2]=0,D[F+4>>2]=0,i){if((0|i)<0)break C;o=DC(i),D[F>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!i)for(I=0,C=1;;){if(!IA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(C=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(a=-4&i,N=3&i,I=0,y=i-1>>>0<3,C=1,Q=0;;){if(!IA(g,255&A?Q:D[D[g+68>>2]+(Q<<2)>>2],B[g+24|0],o))break i;if(C=0,A=0,n=0,!y)for(;B[0|(i=I+E|0)]=e[A+o|0],B[i+1|0]=e[(1|A)+o|0],B[i+2|0]=e[(2|A)+o|0],B[i+3|0]=e[(3|A)+o|0],A=A+4|0,I=I+4|0,(0|a)!=(0|(n=n+4|0)););if(N)for(;B[I+E|0]=e[A+o|0],A=A+1|0,I=I+1|0,(0|N)!=(0|(C=C+1|0)););if((0|k)==(0|(Q=Q+1|0)))break;C=Q>>>0<k>>>0,A=e[g+84|0]}A=Q>>>0>=k>>>0;break E}if(i)for(y=-4&i,N=3&i,I=0,b=i-1>>>0<3;;){if(Q=xA(o,(Q=D[D[g>>2]>>2])+(A=D[g+48>>2]+mg(c=D[g+40>>2],D[g+44>>2],255&A?C:D[D[g+68>>2]+(C<<2)>>2],0)|0)|0,c),n=0,A=0,a=0,!b)for(;B[0|(i=I+E|0)]=e[A+Q|0],B[i+1|0]=e[Q+(1|A)|0],B[i+2|0]=e[Q+(2|A)|0],B[i+3|0]=e[Q+(3|A)|0],A=A+4|0,I=I+4|0,(0|y)!=(0|(a=a+4|0)););if(N)for(;B[I+E|0]=e[A+Q|0],A=A+1|0,I=I+1|0,(0|N)!=(0|(n=n+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break E;A=e[g+84|0]}if(n=D[g>>2],Q=D[g+48>>2],b=D[g+68>>2],E=D[g+44>>2],c=g=D[g+40>>2],I=0,1!=(0|k))for(G=-2&k,w=255&A;i=1|I,N=xA(o,(R=D[n>>2])+(N=mg(g,E,w?I:D[b+(I<<2)>>2],0)+Q|0)|0,c),R=D[n>>2],w||(i=D[b+(i<<2)>>2]),xA(N,(i=mg(g,E,i,0)+Q|0)+R|0,c),I=I+2|0,(0|G)!=(0|(a=a+2|0)););if(!(1&k))break i;i=D[n>>2],255&A||(I=D[b+(I<<2)>>2]),xA(o,(A=mg(g,E,I,0)+Q|0)+i|0,c)}if(A=1^C,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break g;case 2:A=0,d=n=d-16|0;B:if((0|s(i=(C=B[g+24|0])<<1,k=D[I+80>>2]))==(0|Q))if((I=3!=D[g+28>>2])|!(A=e[g+84|0])){if(D[n+8>>2]=0,D[n>>2]=0,D[n+4>>2]=0,C){if((0|C)<0)break C;o=DC(i),D[n>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!C)for(I=0,a=1;;){if(!iA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(a=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(y=-4&C,F=3&C,I=0,b=C-1>>>0<3,a=1,C=0;;){if(!iA(g,255&A?C:D[D[g+68>>2]+(C<<2)>>2],B[g+24|0],o))break i;if(a=0,A=0,Q=0,!b)for(;r[(i=(I<<1)+E|0)>>1]=f[(N=A<<1)+o>>1],r[i+2>>1]=f[(2|N)+o>>1],r[i+4>>1]=f[(4|N)+o>>1],r[i+6>>1]=f[(6|N)+o>>1],A=A+4|0,I=I+4|0,(0|y)!=(0|(Q=Q+4|0)););if(F)for(;r[(I<<1)+E>>1]=f[(A<<1)+o>>1],A=A+1|0,I=I+1|0,(0|F)!=(0|(a=a+1|0)););if((0|k)==(0|(C=C+1|0)))break;a=C>>>0<k>>>0,A=e[g+84|0]}A=C>>>0>=k>>>0;break E}if(y=D[g>>2],i=D[g+48>>2],c=D[g+68>>2],N=D[g+44>>2],w=F=D[g+40>>2],C){for(J=-4&C,h=3&C,I=0,S=255&A,Y=C-1>>>0<3,C=0;;){if(a=xA(o,(g=D[y>>2])+(A=mg(F,N,S?C:D[c+(C<<2)>>2],0)+i|0)|0,w),Q=0,A=0,g=0,!Y)for(;r[(G=(I<<1)+E|0)>>1]=f[(R=A<<1)+a>>1],r[G+2>>1]=f[a+(2|R)>>1],r[G+4>>1]=f[a+(4|R)>>1],r[G+6>>1]=f[a+(6|R)>>1],A=A+4|0,I=I+4|0,(0|J)!=(0|(g=g+4|0)););if(h)for(;r[(I<<1)+E>>1]=f[a+(A<<1)>>1],A=A+1|0,I=I+1|0,(0|h)!=(0|(Q=Q+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break}break E}if(I=0,1!=(0|k))for(G=-2&k,E=255&A,C=0;g=1|I,Q=xA(o,(R=D[y>>2])+(Q=mg(F,N,E?I:D[c+(I<<2)>>2],0)+i|0)|0,w),R=D[y>>2],E||(g=D[c+(g<<2)>>2]),xA(Q,(g=mg(F,N,g,0)+i|0)+R|0,w),I=I+2|0,(0|G)!=(0|(C=C+2|0)););if(!(1&k))break i;g=D[y>>2],255&A||(I=D[c+(I<<2)>>2]),xA(o,(A=mg(F,N,I,0)+i|0)+g|0,w)}if(A=1^a,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break I;case 4:A=0,d=n=d-16|0;B:if((0|s(i=(C=B[g+24|0])<<2,k=D[I+80>>2]))==(0|Q))if((I=5!=D[g+28>>2])|!(A=e[g+84|0])){if(D[n+8>>2]=0,D[n>>2]=0,D[n+4>>2]=0,C){if((0|C)<0)break C;o=DC(i),D[n>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!C)for(I=0,a=1;;){if(!DA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(a=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(y=-4&C,F=3&C,I=0,b=C-1>>>0<3,a=1,C=0;;){if(!DA(g,255&A?C:D[D[g+68>>2]+(C<<2)>>2],B[g+24|0],o))break i;if(a=0,A=0,Q=0,!b)for(;D[(i=(I<<2)+E|0)>>2]=D[(N=A<<2)+o>>2],D[i+4>>2]=D[(4|N)+o>>2],D[i+8>>2]=D[(8|N)+o>>2],D[i+12>>2]=D[(12|N)+o>>2],A=A+4|0,I=I+4|0,(0|y)!=(0|(Q=Q+4|0)););if(F)for(;D[(I<<2)+E>>2]=D[(A<<2)+o>>2],A=A+1|0,I=I+1|0,(0|F)!=(0|(a=a+1|0)););if((0|k)==(0|(C=C+1|0)))break;a=C>>>0<k>>>0,A=e[g+84|0]}A=C>>>0>=k>>>0;break E}if(y=D[g>>2],i=D[g+48>>2],c=D[g+68>>2],N=D[g+44>>2],w=F=D[g+40>>2],C){for(J=-4&C,h=3&C,I=0,S=255&A,Y=C-1>>>0<3,C=0;;){if(a=xA(o,(g=D[y>>2])+(A=mg(F,N,S?C:D[c+(C<<2)>>2],0)+i|0)|0,w),Q=0,A=0,g=0,!Y)for(;D[(G=(I<<2)+E|0)>>2]=D[(R=A<<2)+a>>2],D[G+4>>2]=D[a+(4|R)>>2],D[G+8>>2]=D[a+(8|R)>>2],D[G+12>>2]=D[a+(12|R)>>2],A=A+4|0,I=I+4|0,(0|J)!=(0|(g=g+4|0)););if(h)for(;D[(I<<2)+E>>2]=D[a+(A<<2)>>2],A=A+1|0,I=I+1|0,(0|h)!=(0|(Q=Q+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break}break E}if(I=0,1!=(0|k))for(G=-2&k,E=255&A,C=0;g=1|I,Q=xA(o,(R=D[y>>2])+(Q=mg(F,N,E?I:D[c+(I<<2)>>2],0)+i|0)|0,w),R=D[y>>2],E||(g=D[c+(g<<2)>>2]),xA(Q,(g=mg(F,N,g,0)+i|0)+R|0,w),I=I+2|0,(0|G)!=(0|(C=C+2|0)););if(!(1&k))break i;g=D[y>>2],255&A||(I=D[c+(I<<2)>>2]),xA(o,(A=mg(F,N,I,0)+i|0)+g|0,w)}if(A=1^a,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break I;case 1:A=0,d=F=d-16|0;B:if((0|s(k=D[I+80>>2],i=B[g+24|0]))==(0|Q))if((I=2!=D[g+28>>2])|!(A=e[g+84|0])){if(C=0,D[F+8>>2]=0,D[F>>2]=0,D[F+4>>2]=0,i){if((0|i)<0)break C;o=DC(i),D[F>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!i)for(I=0,C=1;;){if(!gA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(C=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(a=-4&i,N=3&i,I=0,y=i-1>>>0<3,C=1,Q=0;;){if(!gA(g,255&A?Q:D[D[g+68>>2]+(Q<<2)>>2],B[g+24|0],o))break i;if(C=0,A=0,n=0,!y)for(;B[0|(i=I+E|0)]=e[A+o|0],B[i+1|0]=e[(1|A)+o|0],B[i+2|0]=e[(2|A)+o|0],B[i+3|0]=e[(3|A)+o|0],A=A+4|0,I=I+4|0,(0|a)!=(0|(n=n+4|0)););if(N)for(;B[I+E|0]=e[A+o|0],A=A+1|0,I=I+1|0,(0|N)!=(0|(C=C+1|0)););if((0|k)==(0|(Q=Q+1|0)))break;C=Q>>>0<k>>>0,A=e[g+84|0]}A=Q>>>0>=k>>>0;break E}if(i)for(y=-4&i,N=3&i,I=0,b=i-1>>>0<3;;){if(Q=xA(o,(Q=D[D[g>>2]>>2])+(A=D[g+48>>2]+mg(c=D[g+40>>2],D[g+44>>2],255&A?C:D[D[g+68>>2]+(C<<2)>>2],0)|0)|0,c),n=0,A=0,a=0,!b)for(;B[0|(i=I+E|0)]=e[A+Q|0],B[i+1|0]=e[Q+(1|A)|0],B[i+2|0]=e[Q+(2|A)|0],B[i+3|0]=e[Q+(3|A)|0],A=A+4|0,I=I+4|0,(0|y)!=(0|(a=a+4|0)););if(N)for(;B[I+E|0]=e[A+Q|0],A=A+1|0,I=I+1|0,(0|N)!=(0|(n=n+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break E;A=e[g+84|0]}if(n=D[g>>2],Q=D[g+48>>2],b=D[g+68>>2],E=D[g+44>>2],c=g=D[g+40>>2],I=0,1!=(0|k))for(G=-2&k,w=255&A;i=1|I,N=xA(o,(R=D[n>>2])+(N=mg(g,E,w?I:D[b+(I<<2)>>2],0)+Q|0)|0,c),R=D[n>>2],w||(i=D[b+(i<<2)>>2]),xA(N,(i=mg(g,E,i,0)+Q|0)+R|0,c),I=I+2|0,(0|G)!=(0|(a=a+2|0)););if(!(1&k))break i;i=D[n>>2],255&A||(I=D[b+(I<<2)>>2]),xA(o,(A=mg(g,E,I,0)+Q|0)+i|0,c)}if(A=1^C,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break g;case 3:A=0,d=n=d-16|0;B:if((0|s(i=(C=B[g+24|0])<<1,k=D[I+80>>2]))==(0|Q))if((I=4!=D[g+28>>2])|!(A=e[g+84|0])){if(D[n+8>>2]=0,D[n>>2]=0,D[n+4>>2]=0,C){if((0|C)<0)break C;o=DC(i),D[n>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!C)for(I=0,a=1;;){if(!oA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(a=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(y=-4&C,F=3&C,I=0,b=C-1>>>0<3,a=1,C=0;;){if(!oA(g,255&A?C:D[D[g+68>>2]+(C<<2)>>2],B[g+24|0],o))break i;if(a=0,A=0,Q=0,!b)for(;r[(i=(I<<1)+E|0)>>1]=f[(N=A<<1)+o>>1],r[i+2>>1]=f[(2|N)+o>>1],r[i+4>>1]=f[(4|N)+o>>1],r[i+6>>1]=f[(6|N)+o>>1],A=A+4|0,I=I+4|0,(0|y)!=(0|(Q=Q+4|0)););if(F)for(;r[(I<<1)+E>>1]=f[(A<<1)+o>>1],A=A+1|0,I=I+1|0,(0|F)!=(0|(a=a+1|0)););if((0|k)==(0|(C=C+1|0)))break;a=C>>>0<k>>>0,A=e[g+84|0]}A=C>>>0>=k>>>0;break E}if(y=D[g>>2],i=D[g+48>>2],c=D[g+68>>2],N=D[g+44>>2],w=F=D[g+40>>2],C){for(J=-4&C,h=3&C,I=0,S=255&A,Y=C-1>>>0<3,C=0;;){if(a=xA(o,(g=D[y>>2])+(A=mg(F,N,S?C:D[c+(C<<2)>>2],0)+i|0)|0,w),Q=0,A=0,g=0,!Y)for(;r[(G=(I<<1)+E|0)>>1]=f[(R=A<<1)+a>>1],r[G+2>>1]=f[a+(2|R)>>1],r[G+4>>1]=f[a+(4|R)>>1],r[G+6>>1]=f[a+(6|R)>>1],A=A+4|0,I=I+4|0,(0|J)!=(0|(g=g+4|0)););if(h)for(;r[(I<<1)+E>>1]=f[a+(A<<1)>>1],A=A+1|0,I=I+1|0,(0|h)!=(0|(Q=Q+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break}break E}if(I=0,1!=(0|k))for(G=-2&k,E=255&A,C=0;g=1|I,Q=xA(o,(R=D[y>>2])+(Q=mg(F,N,E?I:D[c+(I<<2)>>2],0)+i|0)|0,w),R=D[y>>2],E||(g=D[c+(g<<2)>>2]),xA(Q,(g=mg(F,N,g,0)+i|0)+R|0,w),I=I+2|0,(0|G)!=(0|(C=C+2|0)););if(!(1&k))break i;g=D[y>>2],255&A||(I=D[c+(I<<2)>>2]),xA(o,(A=mg(F,N,I,0)+i|0)+g|0,w)}if(A=1^a,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break I;case 5:A=0,d=n=d-16|0;B:if((0|s(i=(C=B[g+24|0])<<2,k=D[I+80>>2]))==(0|Q))if((I=6!=D[g+28>>2])|!(A=e[g+84|0])){if(D[n+8>>2]=0,D[n>>2]=0,D[n+4>>2]=0,C){if((0|C)<0)break C;o=DC(i),D[n>>2]=o,bI(o,0,i)}E:{i:if(k){if(I){if(!C)for(I=0,a=1;;){if(!eA(g,255&A?I:D[D[g+68>>2]+(I<<2)>>2],B[g+24|0],o))break i;if(a=k>>>0>(I=I+1|0)>>>0,(0|I)==(0|k))break i;A=e[g+84|0]}for(y=-4&C,F=3&C,I=0,b=C-1>>>0<3,a=1,C=0;;){if(!eA(g,255&A?C:D[D[g+68>>2]+(C<<2)>>2],B[g+24|0],o))break i;if(a=0,A=0,Q=0,!b)for(;D[(i=(I<<2)+E|0)>>2]=D[(N=A<<2)+o>>2],D[i+4>>2]=D[(4|N)+o>>2],D[i+8>>2]=D[(8|N)+o>>2],D[i+12>>2]=D[(12|N)+o>>2],A=A+4|0,I=I+4|0,(0|y)!=(0|(Q=Q+4|0)););if(F)for(;D[(I<<2)+E>>2]=D[(A<<2)+o>>2],A=A+1|0,I=I+1|0,(0|F)!=(0|(a=a+1|0)););if((0|k)==(0|(C=C+1|0)))break;a=C>>>0<k>>>0,A=e[g+84|0]}A=C>>>0>=k>>>0;break E}if(y=D[g>>2],i=D[g+48>>2],c=D[g+68>>2],N=D[g+44>>2],w=F=D[g+40>>2],C){for(J=-4&C,h=3&C,I=0,S=255&A,Y=C-1>>>0<3,C=0;;){if(a=xA(o,(g=D[y>>2])+(A=mg(F,N,S?C:D[c+(C<<2)>>2],0)+i|0)|0,w),Q=0,A=0,g=0,!Y)for(;D[(G=(I<<2)+E|0)>>2]=D[(R=A<<2)+a>>2],D[G+4>>2]=D[a+(4|R)>>2],D[G+8>>2]=D[a+(8|R)>>2],D[G+12>>2]=D[a+(12|R)>>2],A=A+4|0,I=I+4|0,(0|J)!=(0|(g=g+4|0)););if(h)for(;D[(I<<2)+E>>2]=D[a+(A<<2)>>2],A=A+1|0,I=I+1|0,(0|h)!=(0|(Q=Q+1|0)););if(A=1,(0|k)==(0|(C=C+1|0)))break}break E}if(I=0,1!=(0|k))for(G=-2&k,E=255&A,C=0;g=1|I,Q=xA(o,(R=D[y>>2])+(Q=mg(F,N,E?I:D[c+(I<<2)>>2],0)+i|0)|0,w),R=D[y>>2],E||(g=D[c+(g<<2)>>2]),xA(Q,(g=mg(F,N,g,0)+i|0)+R|0,w),I=I+2|0,(0|G)!=(0|(C=C+2|0)););if(!(1&k))break i;g=D[y>>2],255&A||(I=D[c+(I<<2)>>2]),xA(o,(A=mg(F,N,I,0)+i|0)+g|0,w)}if(A=1^a,!o)break B}sA(o)}else xA(E,D[D[g>>2]>>2]+D[g+48>>2]|0,Q),A=1;break I;case 8:break Q;default:break A}A=0,d=y=d-16|0;Q:if((0|s(C=(N=B[g+24|0])<<2,k=D[I+80>>2]))==(0|Q)){Q=D[g+28>>2],D[y+8>>2]=0,D[y>>2]=0,D[y+4>>2]=0,I=0;B:{E:{i:{if(N){if((0|N)<0)break i;if(I=DC(C),D[y>>2]=I,D[y+8>>2]=i=(N<<2)+I|0,F=1+((C=C-4|0)>>>2|0)&7)for(A=I;D[A>>2]=-1073741824,A=A+4|0,(0|F)!=(0|(o=o+1|0)););else A=I;if(!(C>>>0<28))for(;D[A+24>>2]=-1073741824,D[A+28>>2]=-1073741824,D[A+16>>2]=-1073741824,D[A+20>>2]=-1073741824,D[A+8>>2]=-1073741824,D[A+12>>2]=-1073741824,D[A>>2]=-1073741824,D[A+4>>2]=-1073741824,(0|i)!=(0|(A=A+32|0)););}if(!k)break E;if(9==(0|Q)){if(A=0,b=D[g>>2],C=D[g+48>>2],w=D[g+68>>2],G=e[g+84|0],Q=D[g+44>>2],R=i=D[g+40>>2],(0|N)<=0){if(1!=(0|k))for(N=-2&k,g=0;E=1|A,o=xA(I,(F=D[b>>2])+(o=mg(i,Q,G?A:D[w+(A<<2)>>2],0)+C|0)|0,R),F=D[b>>2],G||(E=D[w+(E<<2)>>2]),xA(o,(E=mg(i,Q,E,0)+C|0)+F|0,R),A=A+2|0,(0|N)!=(0|(g=g+2|0)););if(!(1&k))break E;g=D[b>>2],G||(A=D[w+(A<<2)>>2]),xA(I,(A=mg(i,Q,A,0)+C|0)+g|0,R);break E}for(S=-4&N,h=3&N,o=0,Y=N-1>>>0<3;;){if(g=xA(I,(g=D[b>>2])+(A=mg(i,Q,G?a:D[w+(a<<2)>>2],0)+C|0)|0,R),F=0,A=0,J=0,!Y)for(;t[(N=(o<<2)+E|0)>>2]=t[(n=A<<2)+g>>2],t[N+4>>2]=t[g+(4|n)>>2],t[N+8>>2]=t[g+(8|n)>>2],t[N+12>>2]=t[g+(12|n)>>2],A=A+4|0,o=o+4|0,(0|S)!=(0|(J=J+4|0)););if(h)for(;t[(o<<2)+E>>2]=t[g+(A<<2)>>2],A=A+1|0,o=o+1|0,(0|h)!=(0|(F=F+1|0)););if(A=1,(0|k)==(0|(a=a+1|0)))break}break B}if(n=1,(0|N)<=0){for(A=0;;){if(!v(g,e[g+84|0]?A:D[D[g+68>>2]+(A<<2)>>2],B[g+24|0],I))break E;if(n=k>>>0>(A=A+1|0)>>>0,(0|A)==(0|k))break}break E}for(b=-4&N,i=3&N,o=0,N=N-1>>>0<3;;){if(!v(g,e[g+84|0]?a:D[D[g+68>>2]+(a<<2)>>2],B[g+24|0],I))break E;if(n=0,A=0,F=0,!N)for(;t[(C=(o<<2)+E|0)>>2]=t[(Q=A<<2)+I>>2],t[C+4>>2]=t[(4|Q)+I>>2],t[C+8>>2]=t[(8|Q)+I>>2],t[C+12>>2]=t[(12|Q)+I>>2],A=A+4|0,o=o+4|0,(0|b)!=(0|(F=F+4|0)););if(i)for(;t[(o<<2)+E>>2]=t[(A<<2)+I>>2],A=A+1|0,o=o+1|0,(0|i)!=(0|(n=n+1|0)););if(n=k>>>0>(a=a+1|0)>>>0,(0|a)==(0|k))break}A=a>>>0>=k>>>0;break B}iQ(),U()}if(A=1^n,!I)break Q}sA(I)}d=y+16|0,o=1&A;break A}iQ(),U()}d=F+16|0,o=1&A;break A}d=n+16|0,o=1&A}return 0|o},jb:function(A,I){A|=0;var g,C=0,Q=0,E=0,i=0,o=0,a=0,r=0,f=0,t=0,N=0,s=0,F=0,n=0,R=0,y=0,G=0,c=0,w=0,b=0;d=g=d-16|0,D[g+12>>2]=I|=0,I=DC(32),D[g>>2]=I,D[g+4>>2]=24,D[g+8>>2]=-2147483616,B[I+24|0]=0,Q=e[1318]|e[1319]<<8|e[1320]<<16|e[1321]<<24,B[I+16|0]=C=e[1314]|e[1315]<<8|e[1316]<<16|e[1317]<<24,B[I+17|0]=C>>>8,B[I+18|0]=C>>>16,B[I+19|0]=C>>>24,B[I+20|0]=Q,B[I+21|0]=Q>>>8,B[I+22|0]=Q>>>16,B[I+23|0]=Q>>>24,Q=e[1310]|e[1311]<<8|e[1312]<<16|e[1313]<<24,B[I+8|0]=C=e[1306]|e[1307]<<8|e[1308]<<16|e[1309]<<24,B[I+9|0]=C>>>8,B[I+10|0]=C>>>16,B[I+11|0]=C>>>24,B[I+12|0]=Q,B[I+13|0]=Q>>>8,B[I+14|0]=Q>>>16,B[I+15|0]=Q>>>24,Q=e[1302]|e[1303]<<8|e[1304]<<16|e[1305]<<24,B[0|I]=C=e[1298]|e[1299]<<8|e[1300]<<16|e[1301]<<24,B[I+1|0]=C>>>8,B[I+2|0]=C>>>16,B[I+3|0]=C>>>24,B[I+4|0]=Q,B[I+5|0]=Q>>>8,B[I+6|0]=Q>>>16,B[I+7|0]=Q>>>24,d=a=d-48|0,t=A;A:{if(A=D[(Q=A+16|0)>>2]){for(C=D[g+12>>2],I=Q;I=(i=(0|C)>D[A+16>>2])?I:A,A=D[(i<<2)+A>>2];);if((0|I)!=(0|Q)&&(0|C)>=D[I+16>>2])break A}if(D[4+(A=c=a+24|0)>>2]=0,D[A+8>>2]=0,D[A>>2]=w=A+4|0,A=D[g+12>>2],D[(C=a+16|0)>>2]=0,D[C+4>>2]=0,D[a+8>>2]=A,D[a+12>>2]=C,(0|w)!=(0|(I=D[c>>2])))for(N=a+8|4;;){i=I,o=I+16|0,d=R=d-16|0,r=R+12|0,A=R+8|0;I:{g:{C:{Q:{B:{E:{i:if((0|(y=N+4|0))!=(0|C))if(n=(F=(I=(E=(I=e[C+27|0])<<24>>24<0)?D[C+20>>2]:I)>>>0<(s=(f=(0|(b=(s=e[o+11|0])<<24>>24))<0)?D[o+4>>2]:s)>>>0)?I:s){if(G=C+16|0,!(G=cg(f=f?D[o>>2]:o,E=E?D[G>>2]:G,n))){if(I>>>0>s>>>0)break i;break E}if((0|G)>=0)break E}else if(I>>>0<=s>>>0)break B;E=D[C>>2];i:{o:if((0|(A=C))!=D[N>>2]){if(E)for(I=E;A=I,I=D[I+4>>2];);else{if(A=C+8|0,(0|C)==D[D[C+8>>2]>>2])for(;A=(I=D[A>>2])+8|0,(0|I)==D[D[I+8>>2]>>2];);A=D[A>>2]}if(!((n=(f=(I=(f=e[o+11|0])<<24>>24<0)?D[o+4>>2]:f)>>>0<(F=(s=(F=e[A+27|0])<<24>>24<0)?D[A+20>>2]:F)>>>0?f:F)&&(y=A+16|0,I=cg(s?D[y>>2]:y,I?D[o>>2]:o,n)))){if(f>>>0>F>>>0)break o;break i}if((0|I)>=0)break i}if(!E){D[r>>2]=C,A=C;break I}D[r>>2]=A,A=A+4|0;break I}A=MI(N,r,o);break I}if(I=cg(E,f,n))break Q}if(F)break C;break g}if((0|I)>=0)break g}if(E=D[C+4>>2])for(I=E;A=I,I=D[I>>2];);else if((0|C)!=D[(A=D[C+8>>2])>>2])for(I=C+8|0;I=(f=D[I>>2])+8|0,(0|f)!=D[(A=D[f+8>>2])>>2];);C:{Q:if((0|A)!=(0|y)){if(!((F=(f=(I=(f=e[A+27|0])<<24>>24<0)?D[A+20>>2]:f)>>>0<s>>>0?f:s)&&(n=A+16|0,I=cg((0|b)<0?D[o>>2]:o,I?D[n>>2]:n,F)))){if(f>>>0>s>>>0)break Q;break C}if((0|I)>=0)break C}if(!E){D[r>>2]=C,A=C+4|0;break I}D[r>>2]=A;break I}A=MI(N,r,o);break I}D[r>>2]=C,D[A>>2]=C}(A=D[(I=A)>>2])?I=0:(E=(A=DC(40))+16|0,B[o+11|0]>=0?(r=D[o+4>>2],D[E>>2]=D[o>>2],D[E+4>>2]=r,D[E+8>>2]=D[o+8>>2]):Lg(E,D[o>>2],D[o+4>>2]),E=A+28|0,B[o+23|0]>=0?(r=D[o+16>>2],D[E>>2]=D[o+12>>2],D[E+4>>2]=r,D[E+8>>2]=D[o+20>>2]):Lg(E,D[o+12>>2],D[o+16>>2]),D[A+8>>2]=D[R+12>>2],D[A>>2]=0,D[A+4>>2]=0,D[I>>2]=A,(E=D[D[N>>2]>>2])?(D[N>>2]=E,I=D[I>>2]):I=A,PA(D[N+4>>2],I),D[N+8>>2]=D[N+8>>2]+1,I=1),B[a+44|0]=I,D[a+40>>2]=A,d=R+16|0;I:if(A=D[i+4>>2])for(;A=D[(I=A)>>2];);else{if((0|i)==D[(I=D[i+8>>2])>>2])break I;for(A=i+8|0;A=(i=D[A>>2])+8|0,(0|i)!=D[(I=D[i+8>>2])>>2];);}if((0|I)==(0|w))break}I:{if(A=D[Q>>2])for(Q=t+16|0,i=D[a+8>>2];;){g:{if((0|(I=D[A+16>>2]))>(0|i)){if(I=D[A>>2])break g;Q=A;break I}if((0|I)>=(0|i))break I;if(Q=A+4|0,!(I=D[A+4>>2]))break I;A=Q}Q=A,A=I}A=Q}(I=D[Q>>2])||(I=DC(32),D[I+16>>2]=D[a+8>>2],D[I+20>>2]=D[a+12>>2],D[(i=I+24|0)>>2]=E=D[a+16>>2],D[I+28>>2]=o=D[a+20>>2],o?(D[E+8>>2]=i,D[a+16>>2]=0,D[a+20>>2]=0,D[a+12>>2]=C):D[I+20>>2]=i,D[I+8>>2]=A,D[I>>2]=0,D[I+4>>2]=0,D[Q>>2]=I,(A=D[D[t+12>>2]>>2])?(D[t+12>>2]=A,A=D[Q>>2]):A=I,PA(D[t+16>>2],A),D[t+20>>2]=D[t+20>>2]+1),eC(a+8|4,D[a+16>>2]),eC(c,D[c+4>>2])}if(d=C=(d=t=(d=a+48|0)-48|0)-32|0,(0|(i=(o=C+32|0)-(A=Q=C+21|0)|0))<=9&(0|i)<(1-(k[3720]>1)|0)?(D[C+8>>2]=o,A=61):(B[0|A]=49,D[C+8>>2]=A+1,A=0),D[C+12>>2]=A,A=t+8|0,d=E=(d=a=d-16|0)-16|0,(i=(N=D[C+8>>2])-Q|0)>>>0<=4294967279){for(i>>>0<=10?(B[A+11|0]=i,C=A):(C=i>>>0>=11?11==(0|(C=(r=i+16&-16)-1|0))?r:C:10,C=DC(r=C+1|0),D[A>>2]=C,D[A+8>>2]=-2147483648|r,D[A+4>>2]=i);(0|Q)!=(0|N);)B[0|C]=e[0|Q],C=C+1|0,Q=Q+1|0;B[E+15|0]=0,B[0|C]=e[E+15|0],d=E+16|0}else aQ(),U();d=a+16|0,d=o,D[t+32>>2]=g;A:{I:{if(A=D[4+(C=I+20|0)>>2])for(E=(Q=(I=e[g+11|0])<<24>>24<0)?D[g>>2]:g,i=Q?D[g+4>>2]:I,I=C+4|0;;){g:{C:{Q:{B:{E:{i:if(N=(a=(Q=(o=(Q=e[A+27|0])<<24>>24<0)?D[A+20>>2]:Q)>>>0<i>>>0)?Q:i){if(r=A+16|0,!(r=cg(E,o=o?D[r>>2]:r,N))){if(Q>>>0>i>>>0)break i;break E}if((0|r)>=0)break E}else if(Q>>>0<=i>>>0)break B;if(Q=D[A>>2])break g;break I}if(Q=cg(o,E,N))break Q}if(a)break C;break A}if((0|Q)>=0)break A}if(I=A+4|0,!(Q=D[A+4>>2]))break A;A=I}I=A,A=Q}A=C+4|0}I=A}(Q=D[I>>2])?A=0:(E=(Q=DC(40))+16|0,B[(i=D[t+32>>2])+11|0]>=0?(o=D[i+4>>2],D[E>>2]=D[i>>2],D[E+4>>2]=o,D[E+8>>2]=D[i+8>>2]):Lg(E,D[i>>2],D[i+4>>2]),D[Q+8>>2]=A,D[Q>>2]=0,D[Q+4>>2]=0,D[Q+36>>2]=0,D[Q+28>>2]=0,D[Q+32>>2]=0,D[I>>2]=Q,(A=D[D[C>>2]>>2])?(D[C>>2]=A,A=D[I>>2]):A=Q,PA(D[C+4>>2],A),D[C+8>>2]=D[C+8>>2]+1,A=1),B[t+44|0]=A,D[t+40>>2]=Q,B[(A=D[t+40>>2])+39|0]<0&&sA(D[A+28>>2]),I=D[t+12>>2],D[A+28>>2]=D[t+8>>2],D[A+32>>2]=I,D[A+36>>2]=D[t+16>>2],d=t+48|0,B[g+11|0]<0&&sA(D[g>>2]),d=g+16|0},kb:function(A,I){A|=0;var g,C,Q=0,E=0;E=8+(C=d-32|0)|0,d=g=(d=C)-80|0,A=D[36+(I|=0)>>2],D[g+72>>2]=D[I+32>>2],D[g+76>>2]=A,Q=D[I+28>>2],D[(A=g- -64|0)>>2]=D[I+24>>2],D[A+4>>2]=Q,A=D[I+20>>2],D[g+56>>2]=D[I+16>>2],D[g+60>>2]=A,A=D[I+12>>2],D[g+48>>2]=D[I+8>>2],D[g+52>>2]=A,A=D[I+4>>2],D[g+40>>2]=D[I>>2],D[g+44>>2]=A,aA(g+8|0,g+40|0,g+24|0);A:if(A=D[g+8>>2]){if(D[E>>2]=A,A=E+4|0,B[g+23|0]>=0){E=D[4+(I=g+8|4)>>2],D[A>>2]=D[I>>2],D[A+4>>2]=E,D[A+8>>2]=D[I+8>>2];break A}if(Lg(A,D[g+12>>2],D[g+16>>2]),B[g+23|0]>=0)break A;sA(D[g+12>>2])}else B[g+23|0]<0&&sA(D[g+12>>2]),(A=e[g+31|0])>>>0>=2?(A=DC(32),B[A+24|0]=I=e[1621]|e[1622]<<8,B[A+25|0]=I>>>8,I=e[1617]|e[1618]<<8|e[1619]<<16|e[1620]<<24,B[A+16|0]=Q=e[1613]|e[1614]<<8|e[1615]<<16|e[1616]<<24,B[A+17|0]=Q>>>8,B[A+18|0]=Q>>>16,B[A+19|0]=Q>>>24,B[A+20|0]=I,B[A+21|0]=I>>>8,B[A+22|0]=I>>>16,B[A+23|0]=I>>>24,I=e[1609]|e[1610]<<8|e[1611]<<16|e[1612]<<24,B[A+8|0]=Q=e[1605]|e[1606]<<8|e[1607]<<16|e[1608]<<24,B[A+9|0]=Q>>>8,B[A+10|0]=Q>>>16,B[A+11|0]=Q>>>24,B[A+12|0]=I,B[A+13|0]=I>>>8,B[A+14|0]=I>>>16,B[A+15|0]=I>>>24,I=e[1601]|e[1602]<<8|e[1603]<<16|e[1604]<<24,B[0|A]=Q=e[1597]|e[1598]<<8|e[1599]<<16|e[1600]<<24,B[A+1|0]=Q>>>8,B[A+2|0]=Q>>>16,B[A+3|0]=Q>>>24,B[A+4|0]=I,B[A+5|0]=I>>>8,B[A+6|0]=I>>>16,B[A+7|0]=I>>>24,B[A+26|0]=0,D[g+8>>2]=-1,Lg(I=g+8|4,A,26),Q=B[g+23|0],D[E>>2]=D[g+8>>2],E=E+4|0,(0|Q)>=0?(Q=D[I+4>>2],D[E>>2]=D[I>>2],D[E+4>>2]=Q,D[E+8>>2]=D[I+8>>2]):Lg(E,D[g+12>>2],D[g+16>>2]),B[g+23|0]<0&&sA(D[g+12>>2]),sA(A)):(D[E>>2]=0,D[E+4>>2]=0,D[E+16>>2]=A,D[E+8>>2]=0,D[E+12>>2]=0);return d=g+80|0,A=D[C+24>>2],B[C+23|0]<0&&sA(D[C+12>>2]),d=C+32|0,0|A},lb:function(A,I,g){var C,Q,E=0;d=C=d-16|0,fA(C,A|=0,I|=0,g|=0),D[A+24>>2]=D[C>>2];A:if((0|(Q=A+24|0))!=(0|C))if(I=4|C,g=(E=e[C+15|0])<<24>>24,B[11+(A=A+28|0)|0]>=0){if((0|g)>=0){g=D[I+4>>2],D[A>>2]=D[I>>2],D[A+4>>2]=g,D[A+8>>2]=D[I+8>>2];break A}$g(A,D[C+4>>2],D[C+8>>2])}else Tg(A,(A=(0|g)<0)?D[C+4>>2]:I,A?D[C+8>>2]:E);return B[C+15|0]<0&&sA(D[C+4>>2]),d=C+16|0,0|Q},mb:function(A,I,g){var C,Q,E=0;d=C=d-16|0,yA(C,A|=0,I|=0,g|=0),D[A+24>>2]=D[C>>2];A:if((0|(Q=A+24|0))!=(0|C))if(I=4|C,g=(E=e[C+15|0])<<24>>24,B[11+(A=A+28|0)|0]>=0){if((0|g)>=0){g=D[I+4>>2],D[A>>2]=D[I>>2],D[A+4>>2]=g,D[A+8>>2]=D[I+8>>2];break A}$g(A,D[C+4>>2],D[C+8>>2])}else Tg(A,(A=(0|g)<0)?D[C+4>>2]:I,A?D[C+8>>2]:E);return B[C+15|0]<0&&sA(D[C+4>>2]),d=C+16|0,0|Q},nb:function(A){(A|=0)&&(B[A+39|0]<0&&sA(D[A+28>>2]),function A(I,g){g&&(A(I,D[g>>2]),A(I,D[g+4>>2]),eC(g+20|0,D[g+24>>2]),sA(g))}(A+12|0,D[A+16>>2]),eC(A,D[A+4>>2]),sA(A))},ob:fQ,pb:tQ,qb:kQ,rb:NQ,sb:fQ,tb:tQ,ub:kQ,vb:NQ,wb:DQ,xb:eQ,yb:fQ,zb:tQ,Ab:kQ,Bb:tQ,Cb:kQ,Db:NQ,Eb:DQ,Fb:eQ,Gb:function(){return 5},Hb:function(){return 6},Ib:function(){return 7},Jb:function(){return 8},Kb:function(){return 9},Lb:function(){return 10},Mb:function(){return 11},Nb:function(){return 12},Ob:tQ,Pb:fQ,Qb:function(){return-2},Rb:function(){return-3},Sb:function(){return-4},Tb:function(){return-5},Ub:q,Vb:sA}}(A)}(QA)},instantiate:function(A,I){return{then:function(I){var g=new w.Module(A);I({instance:new w.Instance(g)})}}},RuntimeError:Error};R=[],"object"!=typeof w&&x("no native wasm support detected");var b=!1;function U(A,I){A||x("Assertion failed: "+I)}var h,J,S,Y,K="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function M(A,I,g){for(var C=I+g,Q=I;A[Q]&&!(Q>=C);)++Q;if(Q-I>16&&A.subarray&&K)return K.decode(A.subarray(I,Q));for(var B="";I<Q;){var E=A[I++];if(128&E){var i=63&A[I++];if(192!=(224&E)){var o=63&A[I++];if((E=224==(240&E)?(15&E)<<12|i<<6|o:(7&E)<<18|i<<12|o<<6|63&A[I++])<65536)B+=String.fromCharCode(E);else{var a=E-65536;B+=String.fromCharCode(55296|a>>10,56320|1023&a)}}else B+=String.fromCharCode((31&E)<<6|i)}else B+=String.fromCharCode(E)}return B}function l(A,I){return A?M(S,A,I):""}function L(A){h=A,Q.HEAP8=J=new Int8Array(A),Q.HEAP16=new Int16Array(A),Q.HEAP32=Y=new Int32Array(A),Q.HEAPU8=S=new Uint8Array(A),Q.HEAPU16=new Uint16Array(A),Q.HEAPU32=new Uint32Array(A),Q.HEAPF32=new Float32Array(A),Q.HEAPF64=new Float64Array(A)}var d,u=Q.INITIAL_MEMORY||16777216;(c=Q.wasmMemory?Q.wasmMemory:new w.Memory({initial:u/65536,maximum:32768}))&&(h=c.buffer),u=h.byteLength,L(h);var p=[],H=[],q=[],W=!1;function V(A){H.unshift(A)}var _,T,m=0,Z=null;function x(A){Q.onAbort&&Q.onAbort(A),G(A="Aborted("+A+")"),b=!0;var I=new w.RuntimeError(A+=". Build with -s ASSERTIONS=1 for more info.");throw C(I),I}function X(A){return A.startsWith("data:application/octet-stream;base64,")}function j(A){return A.startsWith("file://")}function O(A){try{if(A==_&&R)return new Uint8Array(R);var I=CA(A);if(I)return I;if(D)return D(A);throw"both async and sync fetching of the wasm failed"}catch(A){x(A)}}function v(A){for(;A.length>0;){var I=A.shift();if("function"!=typeof I){var g=I.func;"number"==typeof g?void 0===I.arg?P(g)():P(g)(I.arg):g(void 0===I.arg?null:I.arg)}else I(Q)}}Q.preloadedImages={},Q.preloadedAudios={},X(_="draco_decoder.wasm")||(T=_,_=Q.locateFile?Q.locateFile(T,n):n+T);var z=[];function P(A){var I=z[A];return I||(A>=z.length&&(z.length=A+1),z[A]=I=d.get(A)),I}function $(A){this.excPtr=A,this.ptr=A-16,this.set_type=function(A){Y[this.ptr+4>>2]=A},this.get_type=function(){return Y[this.ptr+4>>2]},this.set_destructor=function(A){Y[this.ptr+8>>2]=A},this.get_destructor=function(){return Y[this.ptr+8>>2]},this.set_refcount=function(A){Y[this.ptr>>2]=A},this.set_caught=function(A){J[this.ptr+12>>0]=A=A?1:0},this.get_caught=function(){return 0!=J[this.ptr+12>>0]},this.set_rethrown=function(A){J[this.ptr+13>>0]=A=A?1:0},this.get_rethrown=function(){return 0!=J[this.ptr+13>>0]},this.init=function(A,I){this.set_type(A),this.set_destructor(I),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){Y[this.ptr>>2]=Y[this.ptr>>2]+1},this.release_ref=function(){var A=Y[this.ptr>>2];return Y[this.ptr>>2]=A-1,1===A}}function AA(A){try{return c.grow(A-h.byteLength+65535>>>16),L(c.buffer),1}catch(A){}}var IA={mappings:{},buffers:[null,[],[]],printChar:function(A,I){var g=IA.buffers[A];0===I||10===I?((1===A?y:G)(M(g,0)),g.length=0):g.push(I)},varargs:void 0,get:function(){return IA.varargs+=4,Y[IA.varargs-4>>2]},getStr:function(A){return l(A)},get64:function(A,I){return A}},gA="function"==typeof atob?atob:function(A){var I,g,C,Q,B,E,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="",a=0;A=A.replace(/[^A-Za-z0-9\+\/\=]/g,"");do{C=i.indexOf(A.charAt(a++)),I=(15&(Q=i.indexOf(A.charAt(a++))))<<4|(B=i.indexOf(A.charAt(a++)))>>2,g=(3&B)<<6|(E=i.indexOf(A.charAt(a++))),o+=String.fromCharCode(C<<2|Q>>4),64!==B&&(o+=String.fromCharCode(I)),64!==E&&(o+=String.fromCharCode(g))}while(a<A.length);return o};function CA(A){if(X(A))return function(A){if("boolean"==typeof F&&F){var I=Buffer.from(A,"base64");return new Uint8Array(I.buffer,I.byteOffset,I.byteLength)}try{for(var g=gA(A),C=new Uint8Array(g.length),Q=0;Q<g.length;++Q)C[Q]=g.charCodeAt(Q);return C}catch(A){throw new Error("Converting base64 string to bytes failed.")}}(A.slice("data:application/octet-stream;base64,".length))}var QA={i:function(A){return Vg(A+16)+16},h:function(A,I,g){throw new $(A).init(I,g),A},b:function(){x("")},e:function(A,I,g){S.copyWithin(A,I,I+g)},f:function(A){var I,g,C=S.length;if((A>>>=0)>2147483648)return!1;for(var Q=1;Q<=4;Q*=2){var B=C*(1+.2/Q);if(B=Math.min(B,A+100663296),AA(Math.min(2147483648,((I=Math.max(A,B))%(g=65536)>0&&(I+=g-I%g),I))))return!0}return!1},g:function(A){return 0},d:function(A,I,g,C,Q){},c:function(A,I,g,C){for(var Q=0,B=0;B<g;B++){var E=Y[I>>2],i=Y[I+4>>2];I+=8;for(var o=0;o<i;o++)IA.printChar(A,S[E+o]);Q+=i}return Y[C>>2]=Q,0},a:c};!function(){var A={a:QA};function I(A,I){Q.asm=A.exports,d=Q.asm.k,V(Q.asm.j),function(A){if(m--,Q.monitorRunDependencies&&Q.monitorRunDependencies(m),0==m&&Z){var I=Z;Z=null,I()}}()}function g(A){I(A.instance)}function B(I){return function(){if(!R&&(k||t)){if("function"==typeof fetch&&!j(_))return fetch(_,{credentials:"same-origin"}).then((function(A){if(!A.ok)throw"failed to load wasm binary file at '"+_+"'";return A.arrayBuffer()})).catch((function(){return O(_)}));if(r)return new Promise((function(A,I){r(_,(function(I){A(new Uint8Array(I))}),I)}))}return Promise.resolve().then((function(){return O(_)}))}().then((function(I){return w.instantiate(I,A)})).then((function(A){return A})).then(I,(function(A){G("failed to asynchronously prepare wasm: "+A),x(A)}))}if(m++,Q.monitorRunDependencies&&Q.monitorRunDependencies(m),Q.instantiateWasm)try{return Q.instantiateWasm(A,I)}catch(A){return G("Module.instantiateWasm callback failed with error: "+A),!1}(R||"function"!=typeof w.instantiateStreaming||X(_)||j(_)||"function"!=typeof fetch?B(g):fetch(_,{credentials:"same-origin"}).then((function(I){return w.instantiateStreaming(I,A).then(g,(function(A){return G("wasm streaming compile failed: "+A),G("falling back to ArrayBuffer instantiation"),B(g)}))}))).catch(C)}(),Q.___wasm_call_ctors=function(){return(Q.___wasm_call_ctors=Q.asm.j).apply(null,arguments)};var BA,EA=Q._emscripten_bind_VoidPtr___destroy___0=function(){return(EA=Q._emscripten_bind_VoidPtr___destroy___0=Q.asm.l).apply(null,arguments)},iA=Q._emscripten_bind_DecoderBuffer_DecoderBuffer_0=function(){return(iA=Q._emscripten_bind_DecoderBuffer_DecoderBuffer_0=Q.asm.m).apply(null,arguments)},oA=Q._emscripten_bind_DecoderBuffer_Init_2=function(){return(oA=Q._emscripten_bind_DecoderBuffer_Init_2=Q.asm.n).apply(null,arguments)},aA=Q._emscripten_bind_DecoderBuffer___destroy___0=function(){return(aA=Q._emscripten_bind_DecoderBuffer___destroy___0=Q.asm.o).apply(null,arguments)},rA=Q._emscripten_bind_AttributeTransformData_AttributeTransformData_0=function(){return(rA=Q._emscripten_bind_AttributeTransformData_AttributeTransformData_0=Q.asm.p).apply(null,arguments)},DA=Q._emscripten_bind_AttributeTransformData_transform_type_0=function(){return(DA=Q._emscripten_bind_AttributeTransformData_transform_type_0=Q.asm.q).apply(null,arguments)},eA=Q._emscripten_bind_AttributeTransformData___destroy___0=function(){return(eA=Q._emscripten_bind_AttributeTransformData___destroy___0=Q.asm.r).apply(null,arguments)},fA=Q._emscripten_bind_GeometryAttribute_GeometryAttribute_0=function(){return(fA=Q._emscripten_bind_GeometryAttribute_GeometryAttribute_0=Q.asm.s).apply(null,arguments)},kA=Q._emscripten_bind_GeometryAttribute___destroy___0=function(){return(kA=Q._emscripten_bind_GeometryAttribute___destroy___0=Q.asm.t).apply(null,arguments)},tA=Q._emscripten_bind_PointAttribute_PointAttribute_0=function(){return(tA=Q._emscripten_bind_PointAttribute_PointAttribute_0=Q.asm.u).apply(null,arguments)},NA=Q._emscripten_bind_PointAttribute_size_0=function(){return(NA=Q._emscripten_bind_PointAttribute_size_0=Q.asm.v).apply(null,arguments)},sA=Q._emscripten_bind_PointAttribute_GetAttributeTransformData_0=function(){return(sA=Q._emscripten_bind_PointAttribute_GetAttributeTransformData_0=Q.asm.w).apply(null,arguments)},FA=Q._emscripten_bind_PointAttribute_attribute_type_0=function(){return(FA=Q._emscripten_bind_PointAttribute_attribute_type_0=Q.asm.x).apply(null,arguments)},nA=Q._emscripten_bind_PointAttribute_data_type_0=function(){return(nA=Q._emscripten_bind_PointAttribute_data_type_0=Q.asm.y).apply(null,arguments)},RA=Q._emscripten_bind_PointAttribute_num_components_0=function(){return(RA=Q._emscripten_bind_PointAttribute_num_components_0=Q.asm.z).apply(null,arguments)},yA=Q._emscripten_bind_PointAttribute_normalized_0=function(){return(yA=Q._emscripten_bind_PointAttribute_normalized_0=Q.asm.A).apply(null,arguments)},GA=Q._emscripten_bind_PointAttribute_byte_stride_0=function(){return(GA=Q._emscripten_bind_PointAttribute_byte_stride_0=Q.asm.B).apply(null,arguments)},cA=Q._emscripten_bind_PointAttribute_byte_offset_0=function(){return(cA=Q._emscripten_bind_PointAttribute_byte_offset_0=Q.asm.C).apply(null,arguments)},wA=Q._emscripten_bind_PointAttribute_unique_id_0=function(){return(wA=Q._emscripten_bind_PointAttribute_unique_id_0=Q.asm.D).apply(null,arguments)},bA=Q._emscripten_bind_PointAttribute___destroy___0=function(){return(bA=Q._emscripten_bind_PointAttribute___destroy___0=Q.asm.E).apply(null,arguments)},UA=Q._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=function(){return(UA=Q._emscripten_bind_AttributeQuantizationTransform_AttributeQuantizationTransform_0=Q.asm.F).apply(null,arguments)},hA=Q._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=function(){return(hA=Q._emscripten_bind_AttributeQuantizationTransform_InitFromAttribute_1=Q.asm.G).apply(null,arguments)},JA=Q._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=function(){return(JA=Q._emscripten_bind_AttributeQuantizationTransform_quantization_bits_0=Q.asm.H).apply(null,arguments)},SA=Q._emscripten_bind_AttributeQuantizationTransform_min_value_1=function(){return(SA=Q._emscripten_bind_AttributeQuantizationTransform_min_value_1=Q.asm.I).apply(null,arguments)},YA=Q._emscripten_bind_AttributeQuantizationTransform_range_0=function(){return(YA=Q._emscripten_bind_AttributeQuantizationTransform_range_0=Q.asm.J).apply(null,arguments)},KA=Q._emscripten_bind_AttributeQuantizationTransform___destroy___0=function(){return(KA=Q._emscripten_bind_AttributeQuantizationTransform___destroy___0=Q.asm.K).apply(null,arguments)},MA=Q._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=function(){return(MA=Q._emscripten_bind_AttributeOctahedronTransform_AttributeOctahedronTransform_0=Q.asm.L).apply(null,arguments)},lA=Q._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=function(){return(lA=Q._emscripten_bind_AttributeOctahedronTransform_InitFromAttribute_1=Q.asm.M).apply(null,arguments)},LA=Q._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=function(){return(LA=Q._emscripten_bind_AttributeOctahedronTransform_quantization_bits_0=Q.asm.N).apply(null,arguments)},dA=Q._emscripten_bind_AttributeOctahedronTransform___destroy___0=function(){return(dA=Q._emscripten_bind_AttributeOctahedronTransform___destroy___0=Q.asm.O).apply(null,arguments)},uA=Q._emscripten_bind_PointCloud_PointCloud_0=function(){return(uA=Q._emscripten_bind_PointCloud_PointCloud_0=Q.asm.P).apply(null,arguments)},pA=Q._emscripten_bind_PointCloud_num_attributes_0=function(){return(pA=Q._emscripten_bind_PointCloud_num_attributes_0=Q.asm.Q).apply(null,arguments)},HA=Q._emscripten_bind_PointCloud_num_points_0=function(){return(HA=Q._emscripten_bind_PointCloud_num_points_0=Q.asm.R).apply(null,arguments)},qA=Q._emscripten_bind_PointCloud___destroy___0=function(){return(qA=Q._emscripten_bind_PointCloud___destroy___0=Q.asm.S).apply(null,arguments)},WA=Q._emscripten_bind_Mesh_Mesh_0=function(){return(WA=Q._emscripten_bind_Mesh_Mesh_0=Q.asm.T).apply(null,arguments)},VA=Q._emscripten_bind_Mesh_num_faces_0=function(){return(VA=Q._emscripten_bind_Mesh_num_faces_0=Q.asm.U).apply(null,arguments)},_A=Q._emscripten_bind_Mesh_num_attributes_0=function(){return(_A=Q._emscripten_bind_Mesh_num_attributes_0=Q.asm.V).apply(null,arguments)},TA=Q._emscripten_bind_Mesh_num_points_0=function(){return(TA=Q._emscripten_bind_Mesh_num_points_0=Q.asm.W).apply(null,arguments)},mA=Q._emscripten_bind_Mesh___destroy___0=function(){return(mA=Q._emscripten_bind_Mesh___destroy___0=Q.asm.X).apply(null,arguments)},ZA=Q._emscripten_bind_Metadata_Metadata_0=function(){return(ZA=Q._emscripten_bind_Metadata_Metadata_0=Q.asm.Y).apply(null,arguments)},xA=Q._emscripten_bind_Metadata___destroy___0=function(){return(xA=Q._emscripten_bind_Metadata___destroy___0=Q.asm.Z).apply(null,arguments)},XA=Q._emscripten_bind_Status_code_0=function(){return(XA=Q._emscripten_bind_Status_code_0=Q.asm._).apply(null,arguments)},jA=Q._emscripten_bind_Status_ok_0=function(){return(jA=Q._emscripten_bind_Status_ok_0=Q.asm.$).apply(null,arguments)},OA=Q._emscripten_bind_Status_error_msg_0=function(){return(OA=Q._emscripten_bind_Status_error_msg_0=Q.asm.aa).apply(null,arguments)},vA=Q._emscripten_bind_Status___destroy___0=function(){return(vA=Q._emscripten_bind_Status___destroy___0=Q.asm.ba).apply(null,arguments)},zA=Q._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=function(){return(zA=Q._emscripten_bind_DracoFloat32Array_DracoFloat32Array_0=Q.asm.ca).apply(null,arguments)},PA=Q._emscripten_bind_DracoFloat32Array_GetValue_1=function(){return(PA=Q._emscripten_bind_DracoFloat32Array_GetValue_1=Q.asm.da).apply(null,arguments)},$A=Q._emscripten_bind_DracoFloat32Array_size_0=function(){return($A=Q._emscripten_bind_DracoFloat32Array_size_0=Q.asm.ea).apply(null,arguments)},AI=Q._emscripten_bind_DracoFloat32Array___destroy___0=function(){return(AI=Q._emscripten_bind_DracoFloat32Array___destroy___0=Q.asm.fa).apply(null,arguments)},II=Q._emscripten_bind_DracoInt8Array_DracoInt8Array_0=function(){return(II=Q._emscripten_bind_DracoInt8Array_DracoInt8Array_0=Q.asm.ga).apply(null,arguments)},gI=Q._emscripten_bind_DracoInt8Array_GetValue_1=function(){return(gI=Q._emscripten_bind_DracoInt8Array_GetValue_1=Q.asm.ha).apply(null,arguments)},CI=Q._emscripten_bind_DracoInt8Array_size_0=function(){return(CI=Q._emscripten_bind_DracoInt8Array_size_0=Q.asm.ia).apply(null,arguments)},QI=Q._emscripten_bind_DracoInt8Array___destroy___0=function(){return(QI=Q._emscripten_bind_DracoInt8Array___destroy___0=Q.asm.ja).apply(null,arguments)},BI=Q._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=function(){return(BI=Q._emscripten_bind_DracoUInt8Array_DracoUInt8Array_0=Q.asm.ka).apply(null,arguments)},EI=Q._emscripten_bind_DracoUInt8Array_GetValue_1=function(){return(EI=Q._emscripten_bind_DracoUInt8Array_GetValue_1=Q.asm.la).apply(null,arguments)},iI=Q._emscripten_bind_DracoUInt8Array_size_0=function(){return(iI=Q._emscripten_bind_DracoUInt8Array_size_0=Q.asm.ma).apply(null,arguments)},oI=Q._emscripten_bind_DracoUInt8Array___destroy___0=function(){return(oI=Q._emscripten_bind_DracoUInt8Array___destroy___0=Q.asm.na).apply(null,arguments)},aI=Q._emscripten_bind_DracoInt16Array_DracoInt16Array_0=function(){return(aI=Q._emscripten_bind_DracoInt16Array_DracoInt16Array_0=Q.asm.oa).apply(null,arguments)},rI=Q._emscripten_bind_DracoInt16Array_GetValue_1=function(){return(rI=Q._emscripten_bind_DracoInt16Array_GetValue_1=Q.asm.pa).apply(null,arguments)},DI=Q._emscripten_bind_DracoInt16Array_size_0=function(){return(DI=Q._emscripten_bind_DracoInt16Array_size_0=Q.asm.qa).apply(null,arguments)},eI=Q._emscripten_bind_DracoInt16Array___destroy___0=function(){return(eI=Q._emscripten_bind_DracoInt16Array___destroy___0=Q.asm.ra).apply(null,arguments)},fI=Q._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=function(){return(fI=Q._emscripten_bind_DracoUInt16Array_DracoUInt16Array_0=Q.asm.sa).apply(null,arguments)},kI=Q._emscripten_bind_DracoUInt16Array_GetValue_1=function(){return(kI=Q._emscripten_bind_DracoUInt16Array_GetValue_1=Q.asm.ta).apply(null,arguments)},tI=Q._emscripten_bind_DracoUInt16Array_size_0=function(){return(tI=Q._emscripten_bind_DracoUInt16Array_size_0=Q.asm.ua).apply(null,arguments)},NI=Q._emscripten_bind_DracoUInt16Array___destroy___0=function(){return(NI=Q._emscripten_bind_DracoUInt16Array___destroy___0=Q.asm.va).apply(null,arguments)},sI=Q._emscripten_bind_DracoInt32Array_DracoInt32Array_0=function(){return(sI=Q._emscripten_bind_DracoInt32Array_DracoInt32Array_0=Q.asm.wa).apply(null,arguments)},FI=Q._emscripten_bind_DracoInt32Array_GetValue_1=function(){return(FI=Q._emscripten_bind_DracoInt32Array_GetValue_1=Q.asm.xa).apply(null,arguments)},nI=Q._emscripten_bind_DracoInt32Array_size_0=function(){return(nI=Q._emscripten_bind_DracoInt32Array_size_0=Q.asm.ya).apply(null,arguments)},RI=Q._emscripten_bind_DracoInt32Array___destroy___0=function(){return(RI=Q._emscripten_bind_DracoInt32Array___destroy___0=Q.asm.za).apply(null,arguments)},yI=Q._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=function(){return(yI=Q._emscripten_bind_DracoUInt32Array_DracoUInt32Array_0=Q.asm.Aa).apply(null,arguments)},GI=Q._emscripten_bind_DracoUInt32Array_GetValue_1=function(){return(GI=Q._emscripten_bind_DracoUInt32Array_GetValue_1=Q.asm.Ba).apply(null,arguments)},cI=Q._emscripten_bind_DracoUInt32Array_size_0=function(){return(cI=Q._emscripten_bind_DracoUInt32Array_size_0=Q.asm.Ca).apply(null,arguments)},wI=Q._emscripten_bind_DracoUInt32Array___destroy___0=function(){return(wI=Q._emscripten_bind_DracoUInt32Array___destroy___0=Q.asm.Da).apply(null,arguments)},bI=Q._emscripten_bind_MetadataQuerier_MetadataQuerier_0=function(){return(bI=Q._emscripten_bind_MetadataQuerier_MetadataQuerier_0=Q.asm.Ea).apply(null,arguments)},UI=Q._emscripten_bind_MetadataQuerier_HasEntry_2=function(){return(UI=Q._emscripten_bind_MetadataQuerier_HasEntry_2=Q.asm.Fa).apply(null,arguments)},hI=Q._emscripten_bind_MetadataQuerier_GetIntEntry_2=function(){return(hI=Q._emscripten_bind_MetadataQuerier_GetIntEntry_2=Q.asm.Ga).apply(null,arguments)},JI=Q._emscripten_bind_MetadataQuerier_GetIntEntryArray_3=function(){return(JI=Q._emscripten_bind_MetadataQuerier_GetIntEntryArray_3=Q.asm.Ha).apply(null,arguments)},SI=Q._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=function(){return(SI=Q._emscripten_bind_MetadataQuerier_GetDoubleEntry_2=Q.asm.Ia).apply(null,arguments)},YI=Q._emscripten_bind_MetadataQuerier_GetStringEntry_2=function(){return(YI=Q._emscripten_bind_MetadataQuerier_GetStringEntry_2=Q.asm.Ja).apply(null,arguments)},KI=Q._emscripten_bind_MetadataQuerier_NumEntries_1=function(){return(KI=Q._emscripten_bind_MetadataQuerier_NumEntries_1=Q.asm.Ka).apply(null,arguments)},MI=Q._emscripten_bind_MetadataQuerier_GetEntryName_2=function(){return(MI=Q._emscripten_bind_MetadataQuerier_GetEntryName_2=Q.asm.La).apply(null,arguments)},lI=Q._emscripten_bind_MetadataQuerier___destroy___0=function(){return(lI=Q._emscripten_bind_MetadataQuerier___destroy___0=Q.asm.Ma).apply(null,arguments)},LI=Q._emscripten_bind_Decoder_Decoder_0=function(){return(LI=Q._emscripten_bind_Decoder_Decoder_0=Q.asm.Na).apply(null,arguments)},dI=Q._emscripten_bind_Decoder_DecodeArrayToPointCloud_3=function(){return(dI=Q._emscripten_bind_Decoder_DecodeArrayToPointCloud_3=Q.asm.Oa).apply(null,arguments)},uI=Q._emscripten_bind_Decoder_DecodeArrayToMesh_3=function(){return(uI=Q._emscripten_bind_Decoder_DecodeArrayToMesh_3=Q.asm.Pa).apply(null,arguments)},pI=Q._emscripten_bind_Decoder_GetAttributeId_2=function(){return(pI=Q._emscripten_bind_Decoder_GetAttributeId_2=Q.asm.Qa).apply(null,arguments)},HI=Q._emscripten_bind_Decoder_GetAttributeIdByName_2=function(){return(HI=Q._emscripten_bind_Decoder_GetAttributeIdByName_2=Q.asm.Ra).apply(null,arguments)},qI=Q._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=function(){return(qI=Q._emscripten_bind_Decoder_GetAttributeIdByMetadataEntry_3=Q.asm.Sa).apply(null,arguments)},WI=Q._emscripten_bind_Decoder_GetAttribute_2=function(){return(WI=Q._emscripten_bind_Decoder_GetAttribute_2=Q.asm.Ta).apply(null,arguments)},VI=Q._emscripten_bind_Decoder_GetAttributeByUniqueId_2=function(){return(VI=Q._emscripten_bind_Decoder_GetAttributeByUniqueId_2=Q.asm.Ua).apply(null,arguments)},_I=Q._emscripten_bind_Decoder_GetMetadata_1=function(){return(_I=Q._emscripten_bind_Decoder_GetMetadata_1=Q.asm.Va).apply(null,arguments)},TI=Q._emscripten_bind_Decoder_GetAttributeMetadata_2=function(){return(TI=Q._emscripten_bind_Decoder_GetAttributeMetadata_2=Q.asm.Wa).apply(null,arguments)},mI=Q._emscripten_bind_Decoder_GetFaceFromMesh_3=function(){return(mI=Q._emscripten_bind_Decoder_GetFaceFromMesh_3=Q.asm.Xa).apply(null,arguments)},ZI=Q._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=function(){return(ZI=Q._emscripten_bind_Decoder_GetTriangleStripsFromMesh_2=Q.asm.Ya).apply(null,arguments)},xI=Q._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=function(){return(xI=Q._emscripten_bind_Decoder_GetTrianglesUInt16Array_3=Q.asm.Za).apply(null,arguments)},XI=Q._emscripten_bind_Decoder_GetTrianglesUInt32Array_3=function(){return(XI=Q._emscripten_bind_Decoder_GetTrianglesUInt32Array_3=Q.asm._a).apply(null,arguments)},jI=Q._emscripten_bind_Decoder_GetAttributeFloat_3=function(){return(jI=Q._emscripten_bind_Decoder_GetAttributeFloat_3=Q.asm.$a).apply(null,arguments)},OI=Q._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=function(){return(OI=Q._emscripten_bind_Decoder_GetAttributeFloatForAllPoints_3=Q.asm.ab).apply(null,arguments)},vI=Q._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=function(){return(vI=Q._emscripten_bind_Decoder_GetAttributeIntForAllPoints_3=Q.asm.bb).apply(null,arguments)},zI=Q._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=function(){return(zI=Q._emscripten_bind_Decoder_GetAttributeInt8ForAllPoints_3=Q.asm.cb).apply(null,arguments)},PI=Q._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=function(){return(PI=Q._emscripten_bind_Decoder_GetAttributeUInt8ForAllPoints_3=Q.asm.db).apply(null,arguments)},$I=Q._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=function(){return($I=Q._emscripten_bind_Decoder_GetAttributeInt16ForAllPoints_3=Q.asm.eb).apply(null,arguments)},Ag=Q._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=function(){return(Ag=Q._emscripten_bind_Decoder_GetAttributeUInt16ForAllPoints_3=Q.asm.fb).apply(null,arguments)},Ig=Q._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=function(){return(Ig=Q._emscripten_bind_Decoder_GetAttributeInt32ForAllPoints_3=Q.asm.gb).apply(null,arguments)},gg=Q._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=function(){return(gg=Q._emscripten_bind_Decoder_GetAttributeUInt32ForAllPoints_3=Q.asm.hb).apply(null,arguments)},Cg=Q._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=function(){return(Cg=Q._emscripten_bind_Decoder_GetAttributeDataArrayForAllPoints_5=Q.asm.ib).apply(null,arguments)},Qg=Q._emscripten_bind_Decoder_SkipAttributeTransform_1=function(){return(Qg=Q._emscripten_bind_Decoder_SkipAttributeTransform_1=Q.asm.jb).apply(null,arguments)},Bg=Q._emscripten_bind_Decoder_GetEncodedGeometryType_Deprecated_1=function(){return(Bg=Q._emscripten_bind_Decoder_GetEncodedGeometryType_Deprecated_1=Q.asm.kb).apply(null,arguments)},Eg=Q._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=function(){return(Eg=Q._emscripten_bind_Decoder_DecodeBufferToPointCloud_2=Q.asm.lb).apply(null,arguments)},ig=Q._emscripten_bind_Decoder_DecodeBufferToMesh_2=function(){return(ig=Q._emscripten_bind_Decoder_DecodeBufferToMesh_2=Q.asm.mb).apply(null,arguments)},og=Q._emscripten_bind_Decoder___destroy___0=function(){return(og=Q._emscripten_bind_Decoder___destroy___0=Q.asm.nb).apply(null,arguments)},ag=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=function(){return(ag=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_INVALID_TRANSFORM=Q.asm.ob).apply(null,arguments)},rg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=function(){return(rg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_NO_TRANSFORM=Q.asm.pb).apply(null,arguments)},Dg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=function(){return(Dg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_QUANTIZATION_TRANSFORM=Q.asm.qb).apply(null,arguments)},eg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=function(){return(eg=Q._emscripten_enum_draco_AttributeTransformType_ATTRIBUTE_OCTAHEDRON_TRANSFORM=Q.asm.rb).apply(null,arguments)},fg=Q._emscripten_enum_draco_GeometryAttribute_Type_INVALID=function(){return(fg=Q._emscripten_enum_draco_GeometryAttribute_Type_INVALID=Q.asm.sb).apply(null,arguments)},kg=Q._emscripten_enum_draco_GeometryAttribute_Type_POSITION=function(){return(kg=Q._emscripten_enum_draco_GeometryAttribute_Type_POSITION=Q.asm.tb).apply(null,arguments)},tg=Q._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=function(){return(tg=Q._emscripten_enum_draco_GeometryAttribute_Type_NORMAL=Q.asm.ub).apply(null,arguments)},Ng=Q._emscripten_enum_draco_GeometryAttribute_Type_COLOR=function(){return(Ng=Q._emscripten_enum_draco_GeometryAttribute_Type_COLOR=Q.asm.vb).apply(null,arguments)},sg=Q._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=function(){return(sg=Q._emscripten_enum_draco_GeometryAttribute_Type_TEX_COORD=Q.asm.wb).apply(null,arguments)},Fg=Q._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=function(){return(Fg=Q._emscripten_enum_draco_GeometryAttribute_Type_GENERIC=Q.asm.xb).apply(null,arguments)},ng=Q._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=function(){return(ng=Q._emscripten_enum_draco_EncodedGeometryType_INVALID_GEOMETRY_TYPE=Q.asm.yb).apply(null,arguments)},Rg=Q._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=function(){return(Rg=Q._emscripten_enum_draco_EncodedGeometryType_POINT_CLOUD=Q.asm.zb).apply(null,arguments)},yg=Q._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=function(){return(yg=Q._emscripten_enum_draco_EncodedGeometryType_TRIANGULAR_MESH=Q.asm.Ab).apply(null,arguments)},Gg=Q._emscripten_enum_draco_DataType_DT_INVALID=function(){return(Gg=Q._emscripten_enum_draco_DataType_DT_INVALID=Q.asm.Bb).apply(null,arguments)},cg=Q._emscripten_enum_draco_DataType_DT_INT8=function(){return(cg=Q._emscripten_enum_draco_DataType_DT_INT8=Q.asm.Cb).apply(null,arguments)},wg=Q._emscripten_enum_draco_DataType_DT_UINT8=function(){return(wg=Q._emscripten_enum_draco_DataType_DT_UINT8=Q.asm.Db).apply(null,arguments)},bg=Q._emscripten_enum_draco_DataType_DT_INT16=function(){return(bg=Q._emscripten_enum_draco_DataType_DT_INT16=Q.asm.Eb).apply(null,arguments)},Ug=Q._emscripten_enum_draco_DataType_DT_UINT16=function(){return(Ug=Q._emscripten_enum_draco_DataType_DT_UINT16=Q.asm.Fb).apply(null,arguments)},hg=Q._emscripten_enum_draco_DataType_DT_INT32=function(){return(hg=Q._emscripten_enum_draco_DataType_DT_INT32=Q.asm.Gb).apply(null,arguments)},Jg=Q._emscripten_enum_draco_DataType_DT_UINT32=function(){return(Jg=Q._emscripten_enum_draco_DataType_DT_UINT32=Q.asm.Hb).apply(null,arguments)},Sg=Q._emscripten_enum_draco_DataType_DT_INT64=function(){return(Sg=Q._emscripten_enum_draco_DataType_DT_INT64=Q.asm.Ib).apply(null,arguments)},Yg=Q._emscripten_enum_draco_DataType_DT_UINT64=function(){return(Yg=Q._emscripten_enum_draco_DataType_DT_UINT64=Q.asm.Jb).apply(null,arguments)},Kg=Q._emscripten_enum_draco_DataType_DT_FLOAT32=function(){return(Kg=Q._emscripten_enum_draco_DataType_DT_FLOAT32=Q.asm.Kb).apply(null,arguments)},Mg=Q._emscripten_enum_draco_DataType_DT_FLOAT64=function(){return(Mg=Q._emscripten_enum_draco_DataType_DT_FLOAT64=Q.asm.Lb).apply(null,arguments)},lg=Q._emscripten_enum_draco_DataType_DT_BOOL=function(){return(lg=Q._emscripten_enum_draco_DataType_DT_BOOL=Q.asm.Mb).apply(null,arguments)},Lg=Q._emscripten_enum_draco_DataType_DT_TYPES_COUNT=function(){return(Lg=Q._emscripten_enum_draco_DataType_DT_TYPES_COUNT=Q.asm.Nb).apply(null,arguments)},dg=Q._emscripten_enum_draco_StatusCode_OK=function(){return(dg=Q._emscripten_enum_draco_StatusCode_OK=Q.asm.Ob).apply(null,arguments)},ug=Q._emscripten_enum_draco_StatusCode_DRACO_ERROR=function(){return(ug=Q._emscripten_enum_draco_StatusCode_DRACO_ERROR=Q.asm.Pb).apply(null,arguments)},pg=Q._emscripten_enum_draco_StatusCode_IO_ERROR=function(){return(pg=Q._emscripten_enum_draco_StatusCode_IO_ERROR=Q.asm.Qb).apply(null,arguments)},Hg=Q._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=function(){return(Hg=Q._emscripten_enum_draco_StatusCode_INVALID_PARAMETER=Q.asm.Rb).apply(null,arguments)},qg=Q._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=function(){return(qg=Q._emscripten_enum_draco_StatusCode_UNSUPPORTED_VERSION=Q.asm.Sb).apply(null,arguments)},Wg=Q._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=function(){return(Wg=Q._emscripten_enum_draco_StatusCode_UNKNOWN_VERSION=Q.asm.Tb).apply(null,arguments)},Vg=Q._malloc=function(){return(Vg=Q._malloc=Q.asm.Ub).apply(null,arguments)};function _g(A){function g(){BA||(BA=!0,Q.calledRun=!0,b||(W=!0,v(H),I(Q),Q.onRuntimeInitialized&&Q.onRuntimeInitialized(),function(){if(Q.postRun)for("function"==typeof Q.postRun&&(Q.postRun=[Q.postRun]);Q.postRun.length;)A=Q.postRun.shift(),q.unshift(A);var A;v(q)}()))}m>0||(function(){if(Q.preRun)for("function"==typeof Q.preRun&&(Q.preRun=[Q.preRun]);Q.preRun.length;)A=Q.preRun.shift(),p.unshift(A);var A;v(p)}(),m>0||(Q.setStatus?(Q.setStatus("Running..."),setTimeout((function(){setTimeout((function(){Q.setStatus("")}),1),g()}),1)):g()))}if(Q._free=function(){return(Q._free=Q.asm.Vb).apply(null,arguments)},Z=function A(){BA||_g(),BA||(Z=A)},Q.run=_g,Q.preInit)for("function"==typeof Q.preInit&&(Q.preInit=[Q.preInit]);Q.preInit.length>0;)Q.preInit.pop()();function Tg(){}function mg(A){return(A||Tg).__cache__}function Zg(A,I){var g=mg(I),C=g[A];return C||((C=Object.create((I||Tg).prototype)).ptr=A,g[A]=C)}_g(),(Tg.prototype=Object.create(Tg.prototype)).constructor=Tg,Tg.prototype.__class__=Tg,Tg.__cache__={},Q.WrapperObject=Tg,Q.getCache=mg,Q.wrapPointer=Zg,Q.castObject=function(A,I){return Zg(A.ptr,I)},Q.NULL=Zg(0),Q.destroy=function(A){if(!A.__destroy__)throw"Error: Cannot destroy object. (Did you create it yourself?)";A.__destroy__(),delete mg(A.__class__)[A.ptr]},Q.compare=function(A,I){return A.ptr===I.ptr},Q.getPointer=function(A){return A.ptr},Q.getClass=function(A){return A.__class__};var xg={buffer:0,size:0,pos:0,temps:[],needed:0,prepare:function(){if(xg.needed){for(var A=0;A<xg.temps.length;A++)Q._free(xg.temps[A]);xg.temps.length=0,Q._free(xg.buffer),xg.buffer=0,xg.size+=xg.needed,xg.needed=0}xg.buffer||(xg.size+=128,xg.buffer=Q._malloc(xg.size),U(xg.buffer)),xg.pos=0},alloc:function(A,I){U(xg.buffer);var g,C=A.length*I.BYTES_PER_ELEMENT;return xg.pos+(C=C+7&-8)>=xg.size?(U(C>0),xg.needed+=C,g=Q._malloc(C),xg.temps.push(g)):(g=xg.buffer+xg.pos,xg.pos+=C),g},copy:function(A,I,g){switch(g>>>=0,I.BYTES_PER_ELEMENT){case 2:g>>>=1;break;case 4:g>>>=2;break;case 8:g>>>=3}for(var C=0;C<A.length;C++)I[g+C]=A[C]}};function Xg(A){if("string"==typeof A){var I=(C=A,E=B>0?B:function(A){for(var I=0,g=0;g<A.length;++g){var C=A.charCodeAt(g);C>=55296&&C<=57343&&(C=65536+((1023&C)<<10)|1023&A.charCodeAt(++g)),C<=127?++I:I+=C<=2047?2:C<=65535?3:4}return I}(C)+1,i=new Array(E),o=function(A,I,g,C){if(!(C>0))return 0;for(var Q=g,B=g+C-1,E=0;E<A.length;++E){var i=A.charCodeAt(E);if(i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&A.charCodeAt(++E)),i<=127){if(g>=B)break;I[g++]=i}else if(i<=2047){if(g+1>=B)break;I[g++]=192|i>>6,I[g++]=128|63&i}else if(i<=65535){if(g+2>=B)break;I[g++]=224|i>>12,I[g++]=128|i>>6&63,I[g++]=128|63&i}else{if(g+3>=B)break;I[g++]=240|i>>18,I[g++]=128|i>>12&63,I[g++]=128|i>>6&63,I[g++]=128|63&i}}return I[g]=0,g-Q}(C,i,0,i.length),Q&&(i.length=o),i),g=xg.alloc(I,J);return xg.copy(I,J,g),g}var C,Q,B,E,i,o;return A}function jg(A){if("object"==typeof A){var I=xg.alloc(A,J);return xg.copy(A,J,I),I}return A}function Og(){throw"cannot construct a VoidPtr, no constructor in IDL"}function vg(){this.ptr=iA(),mg(vg)[this.ptr]=this}function zg(){this.ptr=rA(),mg(zg)[this.ptr]=this}function Pg(){this.ptr=fA(),mg(Pg)[this.ptr]=this}function $g(){this.ptr=tA(),mg($g)[this.ptr]=this}function AC(){this.ptr=UA(),mg(AC)[this.ptr]=this}function IC(){this.ptr=MA(),mg(IC)[this.ptr]=this}function gC(){this.ptr=uA(),mg(gC)[this.ptr]=this}function CC(){this.ptr=WA(),mg(CC)[this.ptr]=this}function QC(){this.ptr=ZA(),mg(QC)[this.ptr]=this}function BC(){throw"cannot construct a Status, no constructor in IDL"}function EC(){this.ptr=zA(),mg(EC)[this.ptr]=this}function iC(){this.ptr=II(),mg(iC)[this.ptr]=this}function oC(){this.ptr=BI(),mg(oC)[this.ptr]=this}function aC(){this.ptr=aI(),mg(aC)[this.ptr]=this}function rC(){this.ptr=fI(),mg(rC)[this.ptr]=this}function DC(){this.ptr=sI(),mg(DC)[this.ptr]=this}function eC(){this.ptr=yI(),mg(eC)[this.ptr]=this}function fC(){this.ptr=bI(),mg(fC)[this.ptr]=this}function kC(){this.ptr=LI(),mg(kC)[this.ptr]=this}return(Og.prototype=Object.create(Tg.prototype)).constructor=Og,Og.prototype.__class__=Og,Og.__cache__={},Q.VoidPtr=Og,Og.prototype.__destroy__=Og.prototype.__destroy__=function(){EA(this.ptr)},(vg.prototype=Object.create(Tg.prototype)).constructor=vg,vg.prototype.__class__=vg,vg.__cache__={},Q.DecoderBuffer=vg,vg.prototype.Init=vg.prototype.Init=function(A,I){var g=this.ptr;xg.prepare(),"object"==typeof A&&(A=jg(A)),I&&"object"==typeof I&&(I=I.ptr),oA(g,A,I)},vg.prototype.__destroy__=vg.prototype.__destroy__=function(){aA(this.ptr)},(zg.prototype=Object.create(Tg.prototype)).constructor=zg,zg.prototype.__class__=zg,zg.__cache__={},Q.AttributeTransformData=zg,zg.prototype.transform_type=zg.prototype.transform_type=function(){return DA(this.ptr)},zg.prototype.__destroy__=zg.prototype.__destroy__=function(){eA(this.ptr)},(Pg.prototype=Object.create(Tg.prototype)).constructor=Pg,Pg.prototype.__class__=Pg,Pg.__cache__={},Q.GeometryAttribute=Pg,Pg.prototype.__destroy__=Pg.prototype.__destroy__=function(){kA(this.ptr)},($g.prototype=Object.create(Tg.prototype)).constructor=$g,$g.prototype.__class__=$g,$g.__cache__={},Q.PointAttribute=$g,$g.prototype.size=$g.prototype.size=function(){return NA(this.ptr)},$g.prototype.GetAttributeTransformData=$g.prototype.GetAttributeTransformData=function(){return Zg(sA(this.ptr),zg)},$g.prototype.attribute_type=$g.prototype.attribute_type=function(){return FA(this.ptr)},$g.prototype.data_type=$g.prototype.data_type=function(){return nA(this.ptr)},$g.prototype.num_components=$g.prototype.num_components=function(){return RA(this.ptr)},$g.prototype.normalized=$g.prototype.normalized=function(){return!!yA(this.ptr)},$g.prototype.byte_stride=$g.prototype.byte_stride=function(){return GA(this.ptr)},$g.prototype.byte_offset=$g.prototype.byte_offset=function(){return cA(this.ptr)},$g.prototype.unique_id=$g.prototype.unique_id=function(){return wA(this.ptr)},$g.prototype.__destroy__=$g.prototype.__destroy__=function(){bA(this.ptr)},(AC.prototype=Object.create(Tg.prototype)).constructor=AC,AC.prototype.__class__=AC,AC.__cache__={},Q.AttributeQuantizationTransform=AC,AC.prototype.InitFromAttribute=AC.prototype.InitFromAttribute=function(A){return A&&"object"==typeof A&&(A=A.ptr),!!hA(this.ptr,A)},AC.prototype.quantization_bits=AC.prototype.quantization_bits=function(){return JA(this.ptr)},AC.prototype.min_value=AC.prototype.min_value=function(A){return A&&"object"==typeof A&&(A=A.ptr),SA(this.ptr,A)},AC.prototype.range=AC.prototype.range=function(){return YA(this.ptr)},AC.prototype.__destroy__=AC.prototype.__destroy__=function(){KA(this.ptr)},(IC.prototype=Object.create(Tg.prototype)).constructor=IC,IC.prototype.__class__=IC,IC.__cache__={},Q.AttributeOctahedronTransform=IC,IC.prototype.InitFromAttribute=IC.prototype.InitFromAttribute=function(A){return A&&"object"==typeof A&&(A=A.ptr),!!lA(this.ptr,A)},IC.prototype.quantization_bits=IC.prototype.quantization_bits=function(){return LA(this.ptr)},IC.prototype.__destroy__=IC.prototype.__destroy__=function(){dA(this.ptr)},(gC.prototype=Object.create(Tg.prototype)).constructor=gC,gC.prototype.__class__=gC,gC.__cache__={},Q.PointCloud=gC,gC.prototype.num_attributes=gC.prototype.num_attributes=function(){return pA(this.ptr)},gC.prototype.num_points=gC.prototype.num_points=function(){return HA(this.ptr)},gC.prototype.__destroy__=gC.prototype.__destroy__=function(){qA(this.ptr)},(CC.prototype=Object.create(Tg.prototype)).constructor=CC,CC.prototype.__class__=CC,CC.__cache__={},Q.Mesh=CC,CC.prototype.num_faces=CC.prototype.num_faces=function(){return VA(this.ptr)},CC.prototype.num_attributes=CC.prototype.num_attributes=function(){return _A(this.ptr)},CC.prototype.num_points=CC.prototype.num_points=function(){return TA(this.ptr)},CC.prototype.__destroy__=CC.prototype.__destroy__=function(){mA(this.ptr)},(QC.prototype=Object.create(Tg.prototype)).constructor=QC,QC.prototype.__class__=QC,QC.__cache__={},Q.Metadata=QC,QC.prototype.__destroy__=QC.prototype.__destroy__=function(){xA(this.ptr)},(BC.prototype=Object.create(Tg.prototype)).constructor=BC,BC.prototype.__class__=BC,BC.__cache__={},Q.Status=BC,BC.prototype.code=BC.prototype.code=function(){return XA(this.ptr)},BC.prototype.ok=BC.prototype.ok=function(){return!!jA(this.ptr)},BC.prototype.error_msg=BC.prototype.error_msg=function(){return l(OA(this.ptr))},BC.prototype.__destroy__=BC.prototype.__destroy__=function(){vA(this.ptr)},(EC.prototype=Object.create(Tg.prototype)).constructor=EC,EC.prototype.__class__=EC,EC.__cache__={},Q.DracoFloat32Array=EC,EC.prototype.GetValue=EC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),PA(this.ptr,A)},EC.prototype.size=EC.prototype.size=function(){return $A(this.ptr)},EC.prototype.__destroy__=EC.prototype.__destroy__=function(){AI(this.ptr)},(iC.prototype=Object.create(Tg.prototype)).constructor=iC,iC.prototype.__class__=iC,iC.__cache__={},Q.DracoInt8Array=iC,iC.prototype.GetValue=iC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),gI(this.ptr,A)},iC.prototype.size=iC.prototype.size=function(){return CI(this.ptr)},iC.prototype.__destroy__=iC.prototype.__destroy__=function(){QI(this.ptr)},(oC.prototype=Object.create(Tg.prototype)).constructor=oC,oC.prototype.__class__=oC,oC.__cache__={},Q.DracoUInt8Array=oC,oC.prototype.GetValue=oC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),EI(this.ptr,A)},oC.prototype.size=oC.prototype.size=function(){return iI(this.ptr)},oC.prototype.__destroy__=oC.prototype.__destroy__=function(){oI(this.ptr)},(aC.prototype=Object.create(Tg.prototype)).constructor=aC,aC.prototype.__class__=aC,aC.__cache__={},Q.DracoInt16Array=aC,aC.prototype.GetValue=aC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),rI(this.ptr,A)},aC.prototype.size=aC.prototype.size=function(){return DI(this.ptr)},aC.prototype.__destroy__=aC.prototype.__destroy__=function(){eI(this.ptr)},(rC.prototype=Object.create(Tg.prototype)).constructor=rC,rC.prototype.__class__=rC,rC.__cache__={},Q.DracoUInt16Array=rC,rC.prototype.GetValue=rC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),kI(this.ptr,A)},rC.prototype.size=rC.prototype.size=function(){return tI(this.ptr)},rC.prototype.__destroy__=rC.prototype.__destroy__=function(){NI(this.ptr)},(DC.prototype=Object.create(Tg.prototype)).constructor=DC,DC.prototype.__class__=DC,DC.__cache__={},Q.DracoInt32Array=DC,DC.prototype.GetValue=DC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),FI(this.ptr,A)},DC.prototype.size=DC.prototype.size=function(){return nI(this.ptr)},DC.prototype.__destroy__=DC.prototype.__destroy__=function(){RI(this.ptr)},(eC.prototype=Object.create(Tg.prototype)).constructor=eC,eC.prototype.__class__=eC,eC.__cache__={},Q.DracoUInt32Array=eC,eC.prototype.GetValue=eC.prototype.GetValue=function(A){return A&&"object"==typeof A&&(A=A.ptr),GI(this.ptr,A)},eC.prototype.size=eC.prototype.size=function(){return cI(this.ptr)},eC.prototype.__destroy__=eC.prototype.__destroy__=function(){wI(this.ptr)},(fC.prototype=Object.create(Tg.prototype)).constructor=fC,fC.prototype.__class__=fC,fC.__cache__={},Q.MetadataQuerier=fC,fC.prototype.HasEntry=fC.prototype.HasEntry=function(A,I){var g=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),!!UI(g,A,I)},fC.prototype.GetIntEntry=fC.prototype.GetIntEntry=function(A,I){var g=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),hI(g,A,I)},fC.prototype.GetIntEntryArray=fC.prototype.GetIntEntryArray=function(A,I,g){var C=this.ptr;xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),g&&"object"==typeof g&&(g=g.ptr),JI(C,A,I,g)},fC.prototype.GetDoubleEntry=fC.prototype.GetDoubleEntry=function(A,I){var g=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),SI(g,A,I)},fC.prototype.GetStringEntry=fC.prototype.GetStringEntry=function(A,I){var g=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),l(YI(g,A,I))},fC.prototype.NumEntries=fC.prototype.NumEntries=function(A){return A&&"object"==typeof A&&(A=A.ptr),KI(this.ptr,A)},fC.prototype.GetEntryName=fC.prototype.GetEntryName=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),l(MI(this.ptr,A,I))},fC.prototype.__destroy__=fC.prototype.__destroy__=function(){lI(this.ptr)},(kC.prototype=Object.create(Tg.prototype)).constructor=kC,kC.prototype.__class__=kC,kC.__cache__={},Q.Decoder=kC,kC.prototype.DecodeArrayToPointCloud=kC.prototype.DecodeArrayToPointCloud=function(A,I,g){var C=this.ptr;return xg.prepare(),"object"==typeof A&&(A=jg(A)),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),Zg(dI(C,A,I,g),BC)},kC.prototype.DecodeArrayToMesh=kC.prototype.DecodeArrayToMesh=function(A,I,g){var C=this.ptr;return xg.prepare(),"object"==typeof A&&(A=jg(A)),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),Zg(uI(C,A,I,g),BC)},kC.prototype.GetAttributeId=kC.prototype.GetAttributeId=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),pI(this.ptr,A,I)},kC.prototype.GetAttributeIdByName=kC.prototype.GetAttributeIdByName=function(A,I){var g=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),HI(g,A,I)},kC.prototype.GetAttributeIdByMetadataEntry=kC.prototype.GetAttributeIdByMetadataEntry=function(A,I,g){var C=this.ptr;return xg.prepare(),A&&"object"==typeof A&&(A=A.ptr),I=I&&"object"==typeof I?I.ptr:Xg(I),g=g&&"object"==typeof g?g.ptr:Xg(g),qI(C,A,I,g)},kC.prototype.GetAttribute=kC.prototype.GetAttribute=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),Zg(WI(this.ptr,A,I),$g)},kC.prototype.GetAttributeByUniqueId=kC.prototype.GetAttributeByUniqueId=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),Zg(VI(this.ptr,A,I),$g)},kC.prototype.GetMetadata=kC.prototype.GetMetadata=function(A){return A&&"object"==typeof A&&(A=A.ptr),Zg(_I(this.ptr,A),QC)},kC.prototype.GetAttributeMetadata=kC.prototype.GetAttributeMetadata=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),Zg(TI(this.ptr,A,I),QC)},kC.prototype.GetFaceFromMesh=kC.prototype.GetFaceFromMesh=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!mI(this.ptr,A,I,g)},kC.prototype.GetTriangleStripsFromMesh=kC.prototype.GetTriangleStripsFromMesh=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),ZI(this.ptr,A,I)},kC.prototype.GetTrianglesUInt16Array=kC.prototype.GetTrianglesUInt16Array=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!xI(this.ptr,A,I,g)},kC.prototype.GetTrianglesUInt32Array=kC.prototype.GetTrianglesUInt32Array=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!XI(this.ptr,A,I,g)},kC.prototype.GetAttributeFloat=kC.prototype.GetAttributeFloat=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!jI(this.ptr,A,I,g)},kC.prototype.GetAttributeFloatForAllPoints=kC.prototype.GetAttributeFloatForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!OI(this.ptr,A,I,g)},kC.prototype.GetAttributeIntForAllPoints=kC.prototype.GetAttributeIntForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!vI(this.ptr,A,I,g)},kC.prototype.GetAttributeInt8ForAllPoints=kC.prototype.GetAttributeInt8ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!zI(this.ptr,A,I,g)},kC.prototype.GetAttributeUInt8ForAllPoints=kC.prototype.GetAttributeUInt8ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!PI(this.ptr,A,I,g)},kC.prototype.GetAttributeInt16ForAllPoints=kC.prototype.GetAttributeInt16ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!$I(this.ptr,A,I,g)},kC.prototype.GetAttributeUInt16ForAllPoints=kC.prototype.GetAttributeUInt16ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!Ag(this.ptr,A,I,g)},kC.prototype.GetAttributeInt32ForAllPoints=kC.prototype.GetAttributeInt32ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!Ig(this.ptr,A,I,g)},kC.prototype.GetAttributeUInt32ForAllPoints=kC.prototype.GetAttributeUInt32ForAllPoints=function(A,I,g){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),!!gg(this.ptr,A,I,g)},kC.prototype.GetAttributeDataArrayForAllPoints=kC.prototype.GetAttributeDataArrayForAllPoints=function(A,I,g,C,Q){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),g&&"object"==typeof g&&(g=g.ptr),C&&"object"==typeof C&&(C=C.ptr),Q&&"object"==typeof Q&&(Q=Q.ptr),!!Cg(this.ptr,A,I,g,C,Q)},kC.prototype.SkipAttributeTransform=kC.prototype.SkipAttributeTransform=function(A){A&&"object"==typeof A&&(A=A.ptr),Qg(this.ptr,A)},kC.prototype.GetEncodedGeometryType_Deprecated=kC.prototype.GetEncodedGeometryType_Deprecated=function(A){return A&&"object"==typeof A&&(A=A.ptr),Bg(this.ptr,A)},kC.prototype.DecodeBufferToPointCloud=kC.prototype.DecodeBufferToPointCloud=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),Zg(Eg(this.ptr,A,I),BC)},kC.prototype.DecodeBufferToMesh=kC.prototype.DecodeBufferToMesh=function(A,I){return A&&"object"==typeof A&&(A=A.ptr),I&&"object"==typeof I&&(I=I.ptr),Zg(ig(this.ptr,A,I),BC)},kC.prototype.__destroy__=kC.prototype.__destroy__=function(){og(this.ptr)},function(){function A(){Q.ATTRIBUTE_INVALID_TRANSFORM=ag(),Q.ATTRIBUTE_NO_TRANSFORM=rg(),Q.ATTRIBUTE_QUANTIZATION_TRANSFORM=Dg(),Q.ATTRIBUTE_OCTAHEDRON_TRANSFORM=eg(),Q.INVALID=fg(),Q.POSITION=kg(),Q.NORMAL=tg(),Q.COLOR=Ng(),Q.TEX_COORD=sg(),Q.GENERIC=Fg(),Q.INVALID_GEOMETRY_TYPE=ng(),Q.POINT_CLOUD=Rg(),Q.TRIANGULAR_MESH=yg(),Q.DT_INVALID=Gg(),Q.DT_INT8=cg(),Q.DT_UINT8=wg(),Q.DT_INT16=bg(),Q.DT_UINT16=Ug(),Q.DT_INT32=hg(),Q.DT_UINT32=Jg(),Q.DT_INT64=Sg(),Q.DT_UINT64=Yg(),Q.DT_FLOAT32=Kg(),Q.DT_FLOAT64=Mg(),Q.DT_BOOL=lg(),Q.DT_TYPES_COUNT=Lg(),Q.OK=dg(),Q.DRACO_ERROR=ug(),Q.IO_ERROR=pg(),Q.INVALID_PARAMETER=Hg(),Q.UNSUPPORTED_VERSION=qg(),Q.UNKNOWN_VERSION=Wg()}W?A():V(A)}(),"function"==typeof Q.onModuleParsed&&Q.onModuleParsed(),Q.Decoder.prototype.GetEncodedGeometryType=function(A){if(A.__class__&&A.__class__===Q.DecoderBuffer)return Q.Decoder.prototype.GetEncodedGeometryType_Deprecated(A);if(A.byteLength<8)return Q.INVALID_GEOMETRY_TYPE;switch(A[7]){case 0:return Q.POINT_CLOUD;case 1:return Q.TRIANGULAR_MESH;default:return Q.INVALID_GEOMETRY_TYPE}},A.ready});A.exports=C}(I);var F=I.exports;const n={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array,10:Float64Array},R={9:5126,10:5126,1:5120,3:5122,5:5124,2:5121,4:5123,6:5125},y={1:"SCALAR",2:"VEC2",3:"VEC3"};let G=null,c=null;function w(A,I){return G||c?c?c.then(()=>b(A,I)):b(A,I):(c=F({wasmBinary:" "}).then(A=>{G=A,c=null}),c.then(()=>b(A,I)))}function b(A,I){const g=new G.Decoder,C=new G.MetadataQuerier;if(I.skipAttributeTransform){const{attributes:A}=I;for(const I in A){const C=A[I];C>=0&&g.SkipAttributeTransform(C)}}const Q=new G.DecoderBuffer;A instanceof DataView?Q.Init(new Int8Array(A.buffer,A.byteOffset,A.byteLength),A.byteLength):Q.Init(new Int8Array(A),A.byteLength);const B=g.GetEncodedGeometryType(Q);let E,i=null;if(B===G.TRIANGULAR_MESH)E=new G.Mesh,i=g.DecodeBufferToMesh(Q,E);else{if(B!==G.POINT_CLOUD){throw new Error("Draco Error: Unknown geometry type: "+B)}E=new G.PointCloud,i=g.DecodeBufferToPointCloud(Q,E)}if(!i.ok()||0===E.ptr)throw new Error("Draco Error: Decoding failed: "+i.error_msg());const o=function(A,I,g,C,Q,B){const E={indices:null,attributes:{}};for(const I in C){let i=C[I];const o=Q&&Q[I];if(i<0&&(i=A.GetAttributeId(g,C[I])),-1===i)continue;const a=A.GetAttributeByUniqueId(g,i),r=a.data_type();if(!r)continue;const D=U(A,g,r,a,o,B);D.name=I,E.attributes[I]=D}if(I===G.TRIANGULAR_MESH){const I=g.num_faces(),C=new Uint32Array(3*I),Q=new G.DracoInt32Array;let B=0;for(let E=0;E<I;E++){A.GetFaceFromMesh(g,E,Q);for(let A=0;A<3;A++)C[3*E+A]=Q.GetValue(A),C[3*E+A]>B&&(B=C[3*E+A])}const i=new(B<65536?Uint16Array:Uint32Array)(C);E.indices={array:i,itemSize:1,byteLength:i.byteLength,byteOffset:0,byteStride:0,name:"indices",count:C.length,componentType:h(B)},G.destroy(Q)}return G.destroy(g),E}(g,B,E,I.attributes,I.metadatas,C);return G.destroy(Q),G.destroy(g),G.destroy(C),Promise.resolve(o)}function U(A,I,g,C,Q,B){const E=n[g],i=C.num_components(),o=I.num_points(),a=o*i;let r,D=new G.AttributeQuantizationTransform,e=D.InitFromAttribute(C);if(e){const A=new Array(i);for(let I=0;I<i;++I)A[I]=D.min_value(I);r={quantizationBits:D.quantization_bits(),minValues:A,range:D.range(),octEncoded:!1}}G.destroy(D),D=new G.AttributeOctahedronTransform,e=D.InitFromAttribute(C),e&&(r={quantizationBits:D.quantization_bits(),octEncoded:!0}),G.destroy(D);let f=null;if(r)f=function(A,I,g,C,Q){let B,E;C.quantizationBits<=8?(E=new G.DracoUInt8Array,B=new Uint8Array(Q),I.GetAttributeUInt8ForAllPoints(A,g,E)):(E=new G.DracoUInt16Array,B=new Uint16Array(Q),I.GetAttributeUInt16ForAllPoints(A,g,E));for(let A=0;A<Q;++A)B[A]=E.GetValue(A);return G.destroy(E),B}(I,A,C,r,a);else{let g;switch(E){case Float32Array:g=new G.DracoFloat32Array,A.GetAttributeFloatForAllPoints(I,C,g),f=new Float32Array(a);break;case Int8Array:g=new G.DracoInt8Array,A.GetAttributeInt8ForAllPoints(I,C,g),f=new Int8Array(a);break;case Int16Array:g=new G.DracoInt16Array,A.GetAttributeInt16ForAllPoints(I,C,g),f=new Int16Array(a);break;case Int32Array:g=new G.DracoInt32Array,A.GetAttributeInt32ForAllPoints(I,C,g),f=new Int32Array(a);break;case Uint8Array:g=new G.DracoUInt8Array,A.GetAttributeUInt8ForAllPoints(I,C,g),f=new Uint8Array(a);break;case Uint16Array:g=new G.DracoUInt16Array,A.GetAttributeUInt16ForAllPoints(I,C,g),f=new Uint16Array(a);break;case Uint32Array:g=new G.DracoUInt32Array,A.GetAttributeUInt32ForAllPoints(I,C,g),f=new Uint32Array(a);break;default:throw new Error("Draco Error: Unexpected attribute type: "+E&&E.name)}for(let A=0;A<a;A++)f[A]=g.GetValue(A);G.destroy(g)}const k={};if(Q){const g=A.GetAttributeMetadata(I,C.unique_id());if(g.ptr)for(let A=0;A<Q.length;A++){const I=S(Q[A].type),C=Q[A].name;k[C]={},k[C].type=Q[A].type,k[C].value=B[I](g,C)}}const t={array:f,meta:k,componentType:J(f),count:o,byteOffset:0,byteStride:0,byteLength:a*f.BYTES_PER_ELEMENT,type:y[i],itemSize:i};return r&&(t.quantization=r),t}function h(A){return A<65536?5123:5125}function J(A){let I;for(const g in n)if(A.constructor===n[g]){I=g;break}return R[I]}function S(A){return"double"===A?"GetDoubleEntry":"string"===A?"GetStringEntry":"int"===A?"GetIntEntry":null}return function(...A){const I=w(...A);return Promise.resolve(I)}}()),A.draco______decoder};if("object"!=typeof exports||"undefined"==typeof module)return A;require("@maptalks/gl").transcoders.registerTranscoder("draco",A)}))}();/*!
 * @maptalks/transcoders.crn v0.97.4
 * LICENSE : ISC
 * (c) 2022-2024 maptalks.com
 */
!function(){!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):((e="undefined"!=typeof globalThis?globalThis:e||self).maptalksgl=e.maptalksgl||{},e.maptalksgl.transcoders=e.maptalksgl.transcoders||{},e.maptalksgl.transcoders.crn=r())}(this,(function(){"use strict";const transcoder=function(){const getGlobal=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},currentGlobal=getGlobal();return currentGlobal.crn______decoder||(currentGlobal.crn______decoder=function(){var Module;Module||(Module=(void 0!==Module?Module:null)||{});var moduleOverrides={};for(var key in Module)Module.hasOwnProperty(key)&&(moduleOverrides[key]=Module[key]);var ENVIRONMENT_IS_WEB=!1,ENVIRONMENT_IS_WORKER=!1,ENVIRONMENT_IS_NODE=!1,ENVIRONMENT_IS_SHELL=!1,nodeFS,nodePath;if(Module.ENVIRONMENT)if("WEB"===Module.ENVIRONMENT)ENVIRONMENT_IS_WEB=!0;else if("WORKER"===Module.ENVIRONMENT)ENVIRONMENT_IS_WORKER=!0;else if("NODE"===Module.ENVIRONMENT)ENVIRONMENT_IS_NODE=!0;else{if("SHELL"!==Module.ENVIRONMENT)throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.");ENVIRONMENT_IS_SHELL=!0}else ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"function"==typeof require&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER,ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE)Module.print||(Module.print=console.log),Module.printErr||(Module.printErr=console.warn),Module.read=function(e,r){nodeFS||(nodeFS=require("fs")),nodePath||(nodePath=require("path")),e=nodePath.normalize(e);var i=nodeFS.readFileSync(e);return r?i:i.toString()},Module.readBinary=function(e){var r=Module.read(e,!0);return r.buffer||(r=new Uint8Array(r)),assert(r.buffer),r},Module.load=function(e){globalEval(read(e))},Module.thisProgram||(Module.thisProgram=process.argv.length>1?process.argv[1].replace(/\\/g,"/"):"unknown-program"),Module.arguments=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),process.on("uncaughtException",(function(e){if(!(e instanceof ExitStatus))throw e})),Module.inspect=function(){return"[Emscripten Module object]"};else if(ENVIRONMENT_IS_SHELL)Module.print||(Module.print=print),"undefined"!=typeof printErr&&(Module.printErr=printErr),Module.read="undefined"!=typeof read?read:function(){throw"no read() available"},Module.readBinary=function(e){if("function"==typeof readbuffer)return new Uint8Array(readbuffer(e));var r=read(e,"binary");return assert("object"==typeof r),r},"undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:void 0!==arguments&&(Module.arguments=arguments),"function"==typeof quit&&(Module.quit=function(e,r){quit(e)});else{if(!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER)throw"Unknown runtime environment. Where are we?";if(Module.read=function(e){var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},ENVIRONMENT_IS_WORKER&&(Module.readBinary=function(e){var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Module.readAsync=function(e,r,i){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="arraybuffer",n.onload=function(){200==n.status||0==n.status&&n.response?r(n.response):i()},n.onerror=i,n.send(null)},void 0!==arguments&&(Module.arguments=arguments),"undefined"!=typeof console)Module.print||(Module.print=function(e){console.log(e)}),Module.printErr||(Module.printErr=function(e){console.warn(e)});else{var TRY_USE_DUMP=!1;Module.print||(Module.print=TRY_USE_DUMP&&"undefined"!=typeof dump?function(e){dump(e)}:function(e){})}ENVIRONMENT_IS_WORKER&&(Module.load=importScripts),void 0===Module.setWindowTitle&&(Module.setWindowTitle=function(e){document.title=e})}function globalEval(e){eval.call(null,e)}for(var key in!Module.load&&Module.read&&(Module.load=function(e){globalEval(Module.read(e))}),Module.print||(Module.print=function(){}),Module.printErr||(Module.printErr=Module.print),Module.arguments||(Module.arguments=[]),Module.thisProgram||(Module.thisProgram="./this.program"),Module.quit||(Module.quit=function(e,r){throw r}),Module.print=Module.print,Module.printErr=Module.printErr,Module.preRun=[],Module.postRun=[],moduleOverrides)moduleOverrides.hasOwnProperty(key)&&(Module[key]=moduleOverrides[key]);moduleOverrides=void 0;var Runtime={setTempRet0:function(e){return tempRet0=e,e},getTempRet0:function(){return tempRet0},stackSave:function(){return STACKTOP},stackRestore:function(e){STACKTOP=e},getNativeTypeSize:function(e){switch(e){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===e[e.length-1])return Runtime.QUANTUM_SIZE;if("i"===e[0]){var r=parseInt(e.substr(1));return assert(r%8==0),r/8}return 0}},getNativeFieldSize:function(e){return Math.max(Runtime.getNativeTypeSize(e),Runtime.QUANTUM_SIZE)},STACK_ALIGN:16,prepVararg:function(e,r){return"double"===r||"i64"===r?7&e&&(assert(4==(7&e)),e+=4):assert(0==(3&e)),e},getAlignSize:function(e,r,i){return i||"i64"!=e&&"double"!=e?e?Math.min(r||(e?Runtime.getNativeFieldSize(e):0),Runtime.QUANTUM_SIZE):Math.min(r,8):8},dynCall:function(e,r,i){return i&&i.length?Module["dynCall_"+e].apply(null,[r].concat(i)):Module["dynCall_"+e].call(null,r)},functionPointers:[],addFunction:function(e){for(var r=0;r<Runtime.functionPointers.length;r++)if(!Runtime.functionPointers[r])return Runtime.functionPointers[r]=e,2*(1+r);throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."},removeFunction:function(e){Runtime.functionPointers[(e-2)/2]=null},warnOnce:function(e){Runtime.warnOnce.shown||(Runtime.warnOnce.shown={}),Runtime.warnOnce.shown[e]||(Runtime.warnOnce.shown[e]=1,Module.printErr(e))},funcWrappers:{},getFuncWrapper:function(e,r){assert(r),Runtime.funcWrappers[r]||(Runtime.funcWrappers[r]={});var i=Runtime.funcWrappers[r];return i[e]||(i[e]=1===r.length?function(){return Runtime.dynCall(r,e)}:2===r.length?function(i){return Runtime.dynCall(r,e,[i])}:function(){return Runtime.dynCall(r,e,Array.prototype.slice.call(arguments))}),i[e]},getCompilerSetting:function(e){throw"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work"},stackAlloc:function(e){var r=STACKTOP;return STACKTOP=(STACKTOP=STACKTOP+e|0)+15&-16,r},staticAlloc:function(e){var r=STATICTOP;return STATICTOP=(STATICTOP=STATICTOP+e|0)+15&-16,r},dynamicAlloc:function(e){var r=HEAP32[DYNAMICTOP_PTR>>2],i=-16&(r+e+15|0);if((HEAP32[DYNAMICTOP_PTR>>2]=i,i>=TOTAL_MEMORY)&&!enlargeMemory())return HEAP32[DYNAMICTOP_PTR>>2]=r,0;return r},alignMemory:function(e,r){return e=Math.ceil(e/(r||16))*(r||16)},makeBigInt:function(e,r,i){return i?+(e>>>0)+4294967296*+(r>>>0):+(e>>>0)+4294967296*+(0|r)},GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module.Runtime=Runtime;var ABORT=0,cwrap,ccall;function assert(e,r){e||abort("Assertion failed: "+r)}function getCFunc(ident){var func=Module["_"+ident];if(!func)try{func=eval("_"+ident)}catch(e){}return assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)"),func}function setValue(e,r,i,n){switch("*"===(i=i||"i8").charAt(i.length-1)&&(i="i32"),i){case"i1":case"i8":HEAP8[e>>0]=r;break;case"i16":HEAP16[e>>1]=r;break;case"i32":HEAP32[e>>2]=r;break;case"i64":tempI64=[r>>>0,(tempDouble=r,+Math_abs(tempDouble)>=1?tempDouble>0?(0|Math_min(+Math_floor(tempDouble/4294967296),4294967295))>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[e>>2]=tempI64[0],HEAP32[e+4>>2]=tempI64[1];break;case"float":HEAPF32[e>>2]=r;break;case"double":HEAPF64[e>>3]=r;break;default:abort("invalid type for setValue: "+i)}}function getValue(e,r,i){switch("*"===(r=r||"i8").charAt(r.length-1)&&(r="i32"),r){case"i1":case"i8":return HEAP8[e>>0];case"i16":return HEAP16[e>>1];case"i32":case"i64":return HEAP32[e>>2];case"float":return HEAPF32[e>>2];case"double":return HEAPF64[e>>3];default:abort("invalid type for setValue: "+r)}return null}!function(){var JSfuncs={stackSave:function(){Runtime.stackSave()},stackRestore:function(){Runtime.stackRestore()},arrayToC:function(e){var r=Runtime.stackAlloc(e.length);return writeArrayToMemory(e,r),r},stringToC:function(e){var r=0;if(null!=e&&0!==e){var i=1+(e.length<<2);stringToUTF8(e,r=Runtime.stackAlloc(i),i)}return r}},toC={string:JSfuncs.stringToC,array:JSfuncs.arrayToC};ccall=function(e,r,i,n,t){var o=getCFunc(e),a=[],u=0;if(n)for(var f=0;f<n.length;f++){var l=toC[i[f]];l?(0===u&&(u=Runtime.stackSave()),a[f]=l(n[f])):a[f]=n[f]}var c=o.apply(null,a);if("string"===r&&(c=Pointer_stringify(c)),0!==u){if(t&&t.async)return void EmterpreterAsync.asyncFinalizers.push((function(){Runtime.stackRestore(u)}));Runtime.stackRestore(u)}return c};var sourceRegex=/^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/;function parseJSFunc(e){var r=e.toString().match(sourceRegex).slice(1);return{arguments:r[0],body:r[1],returnValue:r[2]}}var JSsource=null;function ensureJSsource(){if(!JSsource)for(var e in JSsource={},JSfuncs)JSfuncs.hasOwnProperty(e)&&(JSsource[e]=parseJSFunc(JSfuncs[e]))}cwrap=function cwrap(ident,returnType,argTypes){argTypes=argTypes||[];var cfunc=getCFunc(ident),numericArgs=argTypes.every((function(e){return"number"===e})),numericRet="string"!==returnType;if(numericRet&&numericArgs)return cfunc;var argNames=argTypes.map((function(e,r){return"$"+r})),funcstr="(function("+argNames.join(",")+") {",nargs=argTypes.length;if(!numericArgs){ensureJSsource(),funcstr+="var stack = "+JSsource.stackSave.body+";";for(var i=0;i<nargs;i++){var arg=argNames[i],type=argTypes[i];if("number"!==type){var convertCode=JSsource[type+"ToC"];funcstr+="var "+convertCode.arguments+" = "+arg+";",funcstr+=convertCode.body+";",funcstr+=arg+"=("+convertCode.returnValue+");"}}}var cfuncname=parseJSFunc((function(){return cfunc})).returnValue;if(funcstr+="var ret = "+cfuncname+"("+argNames.join(",")+");",!numericRet){var strgfy=parseJSFunc((function(){return Pointer_stringify})).returnValue;funcstr+="ret = "+strgfy+"(ret);"}return numericArgs||(ensureJSsource(),funcstr+=JSsource.stackRestore.body.replace("()","(stack)")+";"),funcstr+="return ret})",eval(funcstr)}}(),Module.ccall=ccall,Module.cwrap=cwrap,Module.setValue=setValue,Module.getValue=getValue;var ALLOC_NORMAL=0,ALLOC_STACK=1,ALLOC_STATIC=2,ALLOC_DYNAMIC=3,ALLOC_NONE=4;function allocate(e,r,i,n){var t,o;"number"==typeof e?(t=!0,o=e):(t=!1,o=e.length);var a,u="string"==typeof r?r:null;if(a=i==ALLOC_NONE?n:["function"==typeof _malloc?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][void 0===i?ALLOC_STATIC:i](Math.max(o,u?1:r.length)),t){var f;n=a;for(assert(0==(3&a)),f=a+(-4&o);n<f;n+=4)HEAP32[n>>2]=0;for(f=a+o;n<f;)HEAP8[n++>>0]=0;return a}if("i8"===u)return HEAPU8.set(e.subarray||e.slice?e:new Uint8Array(e),a),a;for(var l,c,s,d=0;d<o;){var _=e[d];"function"==typeof _&&(_=Runtime.getFunctionIndex(_)),0!==(l=u||r[d])?("i64"==l&&(l="i32"),setValue(a+d,_,l),s!==l&&(c=Runtime.getNativeTypeSize(l),s=l),d+=c):d++}return a}function getMemory(e){return staticSealed?runtimeInitialized?_malloc(e):Runtime.dynamicAlloc(e):Runtime.staticAlloc(e)}function Pointer_stringify(e,r){if(0===r||!e)return"";for(var i,n=0,t=0;n|=i=HEAPU8[e+t>>0],(0!=i||r)&&(t++,!r||t!=r););r||(r=t);var o="";if(n<128){for(var a;r>0;)a=String.fromCharCode.apply(String,HEAPU8.subarray(e,e+Math.min(r,1024))),o=o?o+a:a,e+=1024,r-=1024;return o}return Module.UTF8ToString(e)}function AsciiToString(e){for(var r="";;){var i=HEAP8[e++>>0];if(!i)return r;r+=String.fromCharCode(i)}}function stringToAscii(e,r){return writeAsciiToMemory(e,r,!1)}Module.ALLOC_NORMAL=ALLOC_NORMAL,Module.ALLOC_STACK=ALLOC_STACK,Module.ALLOC_STATIC=ALLOC_STATIC,Module.ALLOC_DYNAMIC=ALLOC_DYNAMIC,Module.ALLOC_NONE=ALLOC_NONE,Module.allocate=allocate,Module.getMemory=getMemory,Module.Pointer_stringify=Pointer_stringify,Module.AsciiToString=AsciiToString,Module.stringToAscii=stringToAscii;var UTF8Decoder="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function UTF8ArrayToString(e,r){for(var i=r;e[i];)++i;if(i-r>16&&e.subarray&&UTF8Decoder)return UTF8Decoder.decode(e.subarray(r,i));for(var n,t,o,a,u,f="";;){if(!(n=e[r++]))return f;if(128&n)if(t=63&e[r++],192!=(224&n))if(o=63&e[r++],224==(240&n)?n=(15&n)<<12|t<<6|o:(a=63&e[r++],240==(248&n)?n=(7&n)<<18|t<<12|o<<6|a:(u=63&e[r++],n=248==(252&n)?(3&n)<<24|t<<18|o<<12|a<<6|u:(1&n)<<30|t<<24|o<<18|a<<12|u<<6|63&e[r++])),n<65536)f+=String.fromCharCode(n);else{var l=n-65536;f+=String.fromCharCode(55296|l>>10,56320|1023&l)}else f+=String.fromCharCode((31&n)<<6|t);else f+=String.fromCharCode(n)}}function UTF8ToString(e){return UTF8ArrayToString(HEAPU8,e)}function stringToUTF8Array(e,r,i,n){if(!(n>0))return 0;for(var t=i,o=i+n-1,a=0;a<e.length;++a){var u=e.charCodeAt(a);if(u>=55296&&u<=57343&&(u=65536+((1023&u)<<10)|1023&e.charCodeAt(++a)),u<=127){if(i>=o)break;r[i++]=u}else if(u<=2047){if(i+1>=o)break;r[i++]=192|u>>6,r[i++]=128|63&u}else if(u<=65535){if(i+2>=o)break;r[i++]=224|u>>12,r[i++]=128|u>>6&63,r[i++]=128|63&u}else if(u<=2097151){if(i+3>=o)break;r[i++]=240|u>>18,r[i++]=128|u>>12&63,r[i++]=128|u>>6&63,r[i++]=128|63&u}else if(u<=67108863){if(i+4>=o)break;r[i++]=248|u>>24,r[i++]=128|u>>18&63,r[i++]=128|u>>12&63,r[i++]=128|u>>6&63,r[i++]=128|63&u}else{if(i+5>=o)break;r[i++]=252|u>>30,r[i++]=128|u>>24&63,r[i++]=128|u>>18&63,r[i++]=128|u>>12&63,r[i++]=128|u>>6&63,r[i++]=128|63&u}}return r[i]=0,i-t}function stringToUTF8(e,r,i){return stringToUTF8Array(e,HEAPU8,r,i)}function lengthBytesUTF8(e){for(var r=0,i=0;i<e.length;++i){var n=e.charCodeAt(i);n>=55296&&n<=57343&&(n=65536+((1023&n)<<10)|1023&e.charCodeAt(++i)),n<=127?++r:r+=n<=2047?2:n<=65535?3:n<=2097151?4:n<=67108863?5:6}return r}function demangle(e){var r=Module.___cxa_demangle||Module.__cxa_demangle;if(r){try{var i=e.substr(1),n=lengthBytesUTF8(i)+1,t=_malloc(n);stringToUTF8(i,t,n);var o=_malloc(4),a=r(t,0,0,o);if(0===getValue(o,"i32")&&a)return Pointer_stringify(a)}catch(e){}finally{t&&_free(t),o&&_free(o),a&&_free(a)}return e}return Runtime.warnOnce("warning: build with  -s DEMANGLE_SUPPORT=1  to link in libcxxabi demangling"),e}function demangleAll(e){return e.replace(/__Z[\w\d_]+/g,(function(e){var r=demangle(e);return e===r?e:e+" ["+r+"]"}))}function jsStackTrace(){var e=new Error;if(!e.stack){try{throw new Error(0)}catch(r){e=r}if(!e.stack)return"(no stack trace available)"}return e.stack.toString()}function stackTrace(){var e=jsStackTrace();return Module.extraStackTrace&&(e+="\n"+Module.extraStackTrace()),demangleAll(e)}Module.UTF8ArrayToString=UTF8ArrayToString,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8Array=stringToUTF8Array,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,"undefined"!=typeof TextDecoder&&new TextDecoder("utf-16le"),Module.stackTrace=stackTrace;var WASM_PAGE_SIZE=65536,ASMJS_PAGE_SIZE=16777216,MIN_TOTAL_MEMORY=16777216,HEAP,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,STATIC_BASE,STATICTOP,staticSealed,STACK_BASE,STACKTOP,STACK_MAX,DYNAMIC_BASE,DYNAMICTOP_PTR,byteLength;function alignUp(e,r){return e%r>0&&(e+=r-e%r),e}function updateGlobalBuffer(e){Module.buffer=buffer=e}function updateGlobalBufferViews(){Module.HEAP8=HEAP8=new Int8Array(buffer),Module.HEAP16=HEAP16=new Int16Array(buffer),Module.HEAP32=HEAP32=new Int32Array(buffer),Module.HEAPU8=HEAPU8=new Uint8Array(buffer),Module.HEAPU16=HEAPU16=new Uint16Array(buffer),Module.HEAPU32=HEAPU32=new Uint32Array(buffer),Module.HEAPF32=HEAPF32=new Float32Array(buffer),Module.HEAPF64=HEAPF64=new Float64Array(buffer)}function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with  -s TOTAL_MEMORY=X  with X higher than the current value "+TOTAL_MEMORY+", (2) compile with  -s ALLOW_MEMORY_GROWTH=1  which allows increasing the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or (4) if you want malloc to return NULL (0) instead of this abort, compile with  -s ABORTING_MALLOC=0 ")}function enlargeMemory(){var e=Module.usingWasm?WASM_PAGE_SIZE:ASMJS_PAGE_SIZE,r=2147483648-e;if(HEAP32[DYNAMICTOP_PTR>>2]>r)return!1;var i=TOTAL_MEMORY;for(TOTAL_MEMORY=Math.max(TOTAL_MEMORY,MIN_TOTAL_MEMORY);TOTAL_MEMORY<HEAP32[DYNAMICTOP_PTR>>2];)TOTAL_MEMORY=TOTAL_MEMORY<=536870912?alignUp(2*TOTAL_MEMORY,e):Math.min(alignUp((3*TOTAL_MEMORY+2147483648)/4,e),r);var n=Module.reallocBuffer(TOTAL_MEMORY);return n&&n.byteLength==TOTAL_MEMORY?(updateGlobalBuffer(n),updateGlobalBufferViews(),!0):(TOTAL_MEMORY=i,!1)}STATIC_BASE=STATICTOP=STACK_BASE=STACKTOP=STACK_MAX=DYNAMIC_BASE=DYNAMICTOP_PTR=0,staticSealed=!1,Module.reallocBuffer||(Module.reallocBuffer=function(e){var r;try{if(ArrayBuffer.transfer)r=ArrayBuffer.transfer(buffer,e);else{var i=HEAP8;r=new ArrayBuffer(e),new Int8Array(r).set(i)}}catch(e){return!1}return!!_emscripten_replace_memory(r)&&r});try{byteLength=Function.prototype.call.bind(Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength").get),byteLength(new ArrayBuffer(4))}catch(e){byteLength=function(e){return e.byteLength}}var TOTAL_STACK=Module.TOTAL_STACK||5242880,TOTAL_MEMORY=Module.TOTAL_MEMORY||16777216;function getTotalMemory(){return TOTAL_MEMORY}if(TOTAL_MEMORY<TOTAL_STACK&&Module.printErr("TOTAL_MEMORY should be larger than TOTAL_STACK, was "+TOTAL_MEMORY+"! (TOTAL_STACK="+TOTAL_STACK+")"),buffer=Module.buffer?Module.buffer:new ArrayBuffer(TOTAL_MEMORY),updateGlobalBufferViews(),HEAP32[0]=1668509029,HEAP16[1]=25459,115!==HEAPU8[2]||99!==HEAPU8[3])throw"Runtime error: expected the system to be little-endian!";function callRuntimeCallbacks(e){for(;e.length>0;){var r=e.shift();if("function"!=typeof r){var i=r.func;"number"==typeof i?void 0===r.arg?Module.dynCall_v(i):Module.dynCall_vi(i,r.arg):i(void 0===r.arg?null:r.arg)}else r()}}Module.HEAP=HEAP,Module.buffer=buffer,Module.HEAP8=HEAP8,Module.HEAP16=HEAP16,Module.HEAP32=HEAP32,Module.HEAPU8=HEAPU8,Module.HEAPU16=HEAPU16,Module.HEAPU32=HEAPU32,Module.HEAPF32=HEAPF32,Module.HEAPF64=HEAPF64;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATEXIT__=[],__ATPOSTRUN__=[],runtimeInitialized=!1;function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){runtimeInitialized||(runtimeInitialized=!0,callRuntimeCallbacks(__ATINIT__))}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__)}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(e){__ATPRERUN__.unshift(e)}function addOnInit(e){__ATINIT__.unshift(e)}function addOnPreMain(e){__ATMAIN__.unshift(e)}function addOnExit(e){__ATEXIT__.unshift(e)}function addOnPostRun(e){__ATPOSTRUN__.unshift(e)}function intArrayFromString(e,r,i){var n=i>0?i:lengthBytesUTF8(e)+1,t=new Array(n),o=stringToUTF8Array(e,t,0,t.length);return r&&(t.length=o),t}function intArrayToString(e){for(var r=[],i=0;i<e.length;i++){var n=e[i];n>255&&(n&=255),r.push(String.fromCharCode(n))}return r.join("")}function writeStringToMemory(e,r,i){var n,t;Runtime.warnOnce("writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!"),i&&(t=r+lengthBytesUTF8(e),n=HEAP8[t]),stringToUTF8(e,r,1/0),i&&(HEAP8[t]=n)}function writeArrayToMemory(e,r){HEAP8.set(e,r)}function writeAsciiToMemory(e,r,i){for(var n=0;n<e.length;++n)HEAP8[r++>>0]=e.charCodeAt(n);i||(HEAP8[r>>0]=0)}Module.addOnPreRun=addOnPreRun,Module.addOnInit=addOnInit,Module.addOnPreMain=addOnPreMain,Module.addOnExit=addOnExit,Module.addOnPostRun=addOnPostRun,Module.intArrayFromString=intArrayFromString,Module.intArrayToString=intArrayToString,Module.writeStringToMemory=writeStringToMemory,Module.writeArrayToMemory=writeArrayToMemory,Module.writeAsciiToMemory=writeAsciiToMemory,Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(e,r){var i=65535&e,n=65535&r;return i*n+((e>>>16)*n+i*(r>>>16)<<16)|0}),Math.imul=Math.imul,Math.clz32||(Math.clz32=function(e){e>>>=0;for(var r=0;r<32;r++)if(e&1<<31-r)return r;return 32}),Math.clz32=Math.clz32,Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Math.trunc=Math.trunc;var Math_abs=Math.abs,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_min=Math.min,runDependencies=0,dependenciesFulfilled=null;function addRunDependency(e){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(e){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&dependenciesFulfilled){var r=dependenciesFulfilled;dependenciesFulfilled=null,r()}}Module.addRunDependency=addRunDependency,Module.removeRunDependency=removeRunDependency,Module.preloadedImages={},Module.preloadedAudios={},STATIC_BASE=Runtime.GLOBAL_BASE,STATICTOP=STATIC_BASE+6192,__ATINIT__.push(),allocate([228,2,0,0,81,16,0,0,12,3,0,0,177,16,0,0,32,0,0,0,0,0,0,0,12,3,0,0,94,16,0,0,48,0,0,0,0,0,0,0,228,2,0,0,127,16,0,0,12,3,0,0,140,16,0,0,16,0,0,0,0,0,0,0,12,3,0,0,183,17,0,0,32,0,0,0,0,0,0,0,12,3,0,0,147,17,0,0,72,0,0,0,0,0,0,0,108,0,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,32,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,19,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,1,0,0,5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,2,0,0,0,40,20,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,16,0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,56,0,0,0,1,0,0,0,5,0,0,0,3,0,0,0,4,0,0,0,5,0,0,0,2,0,0,0,2,0,0,0,2,0,0,0,37,115,40,37,117,41,58,32,65,115,115,101,114,116,105,111,110,32,102,97,105,108,117,114,101,58,32,34,37,115,34,10,0,109,95,115,105,122,101,32,60,61,32,109,95,99,97,112,97,99,105,116,121,0,46,47,105,110,99,92,99,114,110,95,100,101,99,111,109,112,46,104,0,109,105,110,95,110,101,119,95,99,97,112,97,99,105,116,121,32,60,32,40,48,120,55,70,70,70,48,48,48,48,85,32,47,32,101,108,101,109,101,110,116,95,115,105,122,101,41,0,110,101,119,95,99,97,112,97,99,105,116,121,32,38,38,32,40,110,101,119,95,99,97,112,97,99,105,116,121,32,62,32,109,95,99,97,112,97,99,105,116,121,41,0,110,117,109,95,99,111,100,101,115,91,99,93,0,115,111,114,116,101,100,95,112,111,115,32,60,32,116,111,116,97,108,95,117,115,101,100,95,115,121,109,115,0,112,67,111,100,101,115,105,122,101,115,91,115,121,109,95,105,110,100,101,120,93,32,61,61,32,99,111,100,101,115,105,122,101,0,116,32,60,32,40,49,85,32,60,60,32,116,97,98,108,101,95,98,105,116,115,41,0,109,95,108,111,111,107,117,112,91,116,93,32,61,61,32,99,85,73,78,84,51,50,95,77,65,88,0,99,114,110,100,95,109,97,108,108,111,99,58,32,115,105,122,101,32,116,111,111,32,98,105,103,0,99,114,110,100,95,109,97,108,108,111,99,58,32,111,117,116,32,111,102,32,109,101,109,111,114,121,0,40,40,117,105,110,116,51,50,41,112,95,110,101,119,32,38,32,40,67,82,78,68,95,77,73,78,95,65,76,76,79,67,95,65,76,73,71,78,77,69,78,84,32,45,32,49,41,41,32,61,61,32,48,0,99,114,110,100,95,114,101,97,108,108,111,99,58,32,98,97,100,32,112,116,114,0,99,114,110,100,95,102,114,101,101,58,32,98,97,100,32,112,116,114,0,102,97,108,115,101,0,40,116,111,116,97,108,95,115,121,109,115,32,62,61,32,49,41,32,38,38,32,40,116,111,116,97,108,95,115,121,109,115,32,60,61,32,112,114,101,102,105,120,95,99,111,100,105,110,103,58,58,99,77,97,120,83,117,112,112,111,114,116,101,100,83,121,109,115,41,0,17,18,19,20,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15,16,48,0,110,117,109,95,98,105,116,115,32,60,61,32,51,50,85,0,109,95,98,105,116,95,99,111,117,110,116,32,60,61,32,99,66,105,116,66,117,102,83,105,122,101,0,116,32,33,61,32,99,85,73,78,84,51,50,95,77,65,88,0,109,111,100,101,108,46,109,95,99,111,100,101,95,115,105,122,101,115,91,115,121,109,93,32,61,61,32,108,101,110,0,0,2,3,1,0,2,3,4,5,6,7,1,40,108,101,110,32,62,61,32,49,41,32,38,38,32,40,108,101,110,32,60,61,32,99,77,97,120,69,120,112,101,99,116,101,100,67,111,100,101,83,105,122,101,41,0,105,32,60,32,109,95,115,105,122,101,0,110,101,120,116,95,108,101,118,101,108,95,111,102,115,32,62,32,99,117,114,95,108,101,118,101,108,95,111,102,115,0,1,2,2,3,3,3,3,4,0,0,0,0,0,0,1,1,0,1,0,1,0,0,1,2,1,2,0,0,0,1,0,2,1,0,2,0,0,1,2,3,110,117,109,32,38,38,32,40,110,117,109,32,61,61,32,126,110,117,109,95,99,104,101,99,107,41,0,17,0,10,0,17,17,17,0,0,0,0,5,0,0,0,0,0,0,9,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,15,10,17,17,17,3,10,7,0,1,19,9,11,11,0,0,9,6,11,0,0,11,0,6,17,0,0,0,17,17,17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,17,0,10,10,17,17,17,0,10,0,0,2,0,9,11,0,0,0,9,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,13,0,0,0,4,13,0,0,0,0,9,14,0,0,0,0,0,14,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,0,15,0,0,0,0,9,16,0,0,0,0,0,16,0,0,16,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,18,0,0,0,18,18,18,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,10,0,0,0,0,9,11,0,0,0,0,0,11,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,12,0,0,0,0,9,12,0,0,0,0,0,12,0,0,12,0,0,45,43,32,32,32,48,88,48,120,0,40,110,117,108,108,41,0,45,48,88,43,48,88,32,48,88,45,48,120,43,48,120,32,48,120,0,105,110,102,0,73,78,70,0,110,97,110,0,78,65,78,0,48,49,50,51,52,53,54,55,56,57,65,66,67,68,69,70,46,0,84,33,34,25,13,1,2,3,17,75,28,12,16,4,11,29,18,30,39,104,110,111,112,113,98,32,5,6,15,19,20,21,26,8,22,7,40,36,23,24,9,10,14,27,31,37,35,131,130,125,38,42,43,60,61,62,63,67,71,74,77,88,89,90,91,92,93,94,95,96,97,99,100,101,102,103,105,106,107,108,114,115,116,121,122,123,124,0,73,108,108,101,103,97,108,32,98,121,116,101,32,115,101,113,117,101,110,99,101,0,68,111,109,97,105,110,32,101,114,114,111,114,0,82,101,115,117,108,116,32,110,111,116,32,114,101,112,114,101,115,101,110,116,97,98,108,101,0,78,111,116,32,97,32,116,116,121,0,80,101,114,109,105,115,115,105,111,110,32,100,101,110,105,101,100,0,79,112,101,114,97,116,105,111,110,32,110,111,116,32,112,101,114,109,105,116,116,101,100,0,78,111,32,115,117,99,104,32,102,105,108,101,32,111,114,32,100,105,114,101,99,116,111,114,121,0,78,111,32,115,117,99,104,32,112,114,111,99,101,115,115,0,70,105,108,101,32,101,120,105,115,116,115,0,86,97,108,117,101,32,116,111,111,32,108,97,114,103,101,32,102,111,114,32,100,97,116,97,32,116,121,112,101,0,78,111,32,115,112,97,99,101,32,108,101,102,116,32,111,110,32,100,101,118,105,99,101,0,79,117,116,32,111,102,32,109,101,109,111,114,121,0,82,101,115,111,117,114,99,101,32,98,117,115,121,0,73,110,116,101,114,114,117,112,116,101,100,32,115,121,115,116,101,109,32,99,97,108,108,0,82,101,115,111,117,114,99,101,32,116,101,109,112,111,114,97,114,105,108,121,32,117,110,97,118,97,105,108,97,98,108,101,0,73,110,118,97,108,105,100,32,115,101,101,107,0,67,114,111,115,115,45,100,101,118,105,99,101,32,108,105,110,107,0,82,101,97,100,45,111,110,108,121,32,102,105,108,101,32,115,121,115,116,101,109,0,68,105,114,101,99,116,111,114,121,32,110,111,116,32,101,109,112,116,121,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,112,101,101,114,0,79,112,101,114,97,116,105,111,110,32,116,105,109,101,100,32,111,117,116,0,67,111,110,110,101,99,116,105,111,110,32,114,101,102,117,115,101,100,0,72,111,115,116,32,105,115,32,100,111,119,110,0,72,111,115,116,32,105,115,32,117,110,114,101,97,99,104,97,98,108,101,0,65,100,100,114,101,115,115,32,105,110,32,117,115,101,0,66,114,111,107,101,110,32,112,105,112,101,0,73,47,79,32,101,114,114,111,114,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,32,111,114,32,97,100,100,114,101,115,115,0,66,108,111,99,107,32,100,101,118,105,99,101,32,114,101,113,117,105,114,101,100,0,78,111,32,115,117,99,104,32,100,101,118,105,99,101,0,78,111,116,32,97,32,100,105,114,101,99,116,111,114,121,0,73,115,32,97,32,100,105,114,101,99,116,111,114,121,0,84,101,120,116,32,102,105,108,101,32,98,117,115,121,0,69,120,101,99,32,102,111,114,109,97,116,32,101,114,114,111,114,0,73,110,118,97,108,105,100,32,97,114,103,117,109,101,110,116,0,65,114,103,117,109,101,110,116,32,108,105,115,116,32,116,111,111,32,108,111,110,103,0,83,121,109,98,111,108,105,99,32,108,105,110,107,32,108,111,111,112,0,70,105,108,101,110,97,109,101,32,116,111,111,32,108,111,110,103,0,84,111,111,32,109,97,110,121,32,111,112,101,110,32,102,105,108,101,115,32,105,110,32,115,121,115,116,101,109,0,78,111,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,115,32,97,118,97,105,108,97,98,108,101,0,66,97,100,32,102,105,108,101,32,100,101,115,99,114,105,112,116,111,114,0,78,111,32,99,104,105,108,100,32,112,114,111,99,101,115,115,0,66,97,100,32,97,100,100,114,101,115,115,0,70,105,108,101,32,116,111,111,32,108,97,114,103,101,0,84,111,111,32,109,97,110,121,32,108,105,110,107,115,0,78,111,32,108,111,99,107,115,32,97,118,97,105,108,97,98,108,101,0,82,101,115,111,117,114,99,101,32,100,101,97,100,108,111,99,107,32,119,111,117,108,100,32,111,99,99,117,114,0,83,116,97,116,101,32,110,111,116,32,114,101,99,111,118,101,114,97,98,108,101,0,80,114,101,118,105,111,117,115,32,111,119,110,101,114,32,100,105,101,100,0,79,112,101,114,97,116,105,111,110,32,99,97,110,99,101,108,101,100,0,70,117,110,99,116,105,111,110,32,110,111,116,32,105,109,112,108,101,109,101,110,116,101,100,0,78,111,32,109,101,115,115,97,103,101,32,111,102,32,100,101,115,105,114,101,100,32,116,121,112,101,0,73,100,101,110,116,105,102,105,101,114,32,114,101,109,111,118,101,100,0,68,101,118,105,99,101,32,110,111,116,32,97,32,115,116,114,101,97,109,0,78,111,32,100,97,116,97,32,97,118,97,105,108,97,98,108,101,0,68,101,118,105,99,101,32,116,105,109,101,111,117,116,0,79,117,116,32,111,102,32,115,116,114,101,97,109,115,32,114,101,115,111,117,114,99,101,115,0,76,105,110,107,32,104,97,115,32,98,101,101,110,32,115,101,118,101,114,101,100,0,80,114,111,116,111,99,111,108,32,101,114,114,111,114,0,66,97,100,32,109,101,115,115,97,103,101,0,70,105,108,101,32,100,101,115,99,114,105,112,116,111,114,32,105,110,32,98,97,100,32,115,116,97,116,101,0,78,111,116,32,97,32,115,111,99,107,101,116,0,68,101,115,116,105,110,97,116,105,111,110,32,97,100,100,114,101,115,115,32,114,101,113,117,105,114,101,100,0,77,101,115,115,97,103,101,32,116,111,111,32,108,97,114,103,101,0,80,114,111,116,111,99,111,108,32,119,114,111,110,103,32,116,121,112,101,32,102,111,114,32,115,111,99,107,101,116,0,80,114,111,116,111,99,111,108,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,80,114,111,116,111,99,111,108,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,83,111,99,107,101,116,32,116,121,112,101,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,78,111,116,32,115,117,112,112,111,114,116,101,100,0,80,114,111,116,111,99,111,108,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,0,65,100,100,114,101,115,115,32,102,97,109,105,108,121,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,98,121,32,112,114,111,116,111,99,111,108,0,65,100,100,114,101,115,115,32,110,111,116,32,97,118,97,105,108,97,98,108,101,0,78,101,116,119,111,114,107,32,105,115,32,100,111,119,110,0,78,101,116,119,111,114,107,32,117,110,114,101,97,99,104,97,98,108,101,0,67,111,110,110,101,99,116,105,111,110,32,114,101,115,101,116,32,98,121,32,110,101,116,119,111,114,107,0,67,111,110,110,101,99,116,105,111,110,32,97,98,111,114,116,101,100,0,78,111,32,98,117,102,102,101,114,32,115,112,97,99,101,32,97,118,97,105,108,97,98,108,101,0,83,111,99,107,101,116,32,105,115,32,99,111,110,110,101,99,116,101,100,0,83,111,99,107,101,116,32,110,111,116,32,99,111,110,110,101,99,116,101,100,0,67,97,110,110,111,116,32,115,101,110,100,32,97,102,116,101,114,32,115,111,99,107,101,116,32,115,104,117,116,100,111,119,110,0,79,112,101,114,97,116,105,111,110,32,97,108,114,101,97,100,121,32,105,110,32,112,114,111,103,114,101,115,115,0,79,112,101,114,97,116,105,111,110,32,105,110,32,112,114,111,103,114,101,115,115,0,83,116,97,108,101,32,102,105,108,101,32,104,97,110,100,108,101,0,82,101,109,111,116,101,32,73,47,79,32,101,114,114,111,114,0,81,117,111,116,97,32,101,120,99,101,101,100,101,100,0,78,111,32,109,101,100,105,117,109,32,102,111,117,110,100,0,87,114,111,110,103,32,109,101,100,105,117,109,32,116,121,112,101,0,78,111,32,101,114,114,111,114,32,105,110,102,111,114,109,97,116,105,111,110,0,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,58,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,101,120,99,101,112,116,105,111,110,32,111,102,32,116,121,112,101,32,37,115,0,116,101,114,109,105,110,97,116,105,110,103,32,119,105,116,104,32,37,115,32,102,111,114,101,105,103,110,32,101,120,99,101,112,116,105,111,110,0,116,101,114,109,105,110,97,116,105,110,103,0,117,110,99,97,117,103,104,116,0,83,116,57,101,120,99,101,112,116,105,111,110,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,83,116,57,116,121,112,101,95,105,110,102,111,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,112,116,104,114,101,97,100,95,111,110,99,101,32,102,97,105,108,117,114,101,32,105,110,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,95,102,97,115,116,40,41,0,99,97,110,110,111,116,32,99,114,101,97,116,101,32,112,116,104,114,101,97,100,32,107,101,121,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,99,97,110,110,111,116,32,122,101,114,111,32,111,117,116,32,116,104,114,101,97,100,32,118,97,108,117,101,32,102,111,114,32,95,95,99,120,97,95,103,101,116,95,103,108,111,98,97,108,115,40,41,0,116,101,114,109,105,110,97,116,101,95,104,97,110,100,108,101,114,32,117,110,101,120,112,101,99,116,101,100,108,121,32,114,101,116,117,114,110,101,100,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,57,95,95,112,111,105,110,116,101,114,95,116,121,112,101,95,105,110,102,111,69,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,112,98,97,115,101,95,116,121,112,101,95,105,110,102,111,69,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE);var tempDoublePtr=STATICTOP;function _abort(){Module.abort()}function __ZSt18uncaught_exceptionv(){return!!__ZSt18uncaught_exceptionv.uncaught_exception}STATICTOP+=16;var EXCEPTIONS={last:0,caught:[],infos:{},deAdjust:function(e){if(!e||EXCEPTIONS.infos[e])return e;for(var r in EXCEPTIONS.infos){if(EXCEPTIONS.infos[r].adjusted===e)return r}return e},addRef:function(e){e&&EXCEPTIONS.infos[e].refcount++},decRef:function(e){if(e){var r=EXCEPTIONS.infos[e];assert(r.refcount>0),r.refcount--,0!==r.refcount||r.rethrown||(r.destructor&&Module.dynCall_vi(r.destructor,e),delete EXCEPTIONS.infos[e],___cxa_free_exception(e))}},clearRef:function(e){e&&(EXCEPTIONS.infos[e].refcount=0)}};function ___cxa_begin_catch(e){var r=EXCEPTIONS.infos[e];return r&&!r.caught&&(r.caught=!0,__ZSt18uncaught_exceptionv.uncaught_exception--),r&&(r.rethrown=!1),EXCEPTIONS.caught.push(e),EXCEPTIONS.addRef(EXCEPTIONS.deAdjust(e)),e}function _pthread_once(e,r){_pthread_once.seen||(_pthread_once.seen={}),e in _pthread_once.seen||(Module.dynCall_v(r),_pthread_once.seen[e]=1)}function _emscripten_memcpy_big(e,r,i){return HEAPU8.set(HEAPU8.subarray(r,r+i),e),e}var SYSCALLS={varargs:0,get:function(e){return SYSCALLS.varargs+=4,HEAP32[SYSCALLS.varargs-4>>2]},getStr:function(){return Pointer_stringify(SYSCALLS.get())},get64:function(){var e=SYSCALLS.get(),r=SYSCALLS.get();return assert(e>=0?0===r:-1===r),e},getZero:function(){assert(0===SYSCALLS.get())}};function ___syscall6(e,r){SYSCALLS.varargs=r;try{var i=SYSCALLS.getStreamFromFD();return FS.close(i),0}catch(e){return"undefined"!=typeof FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}var cttz_i8=allocate([8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0],"i8",ALLOC_STATIC),PTHREAD_SPECIFIC={};function _pthread_getspecific(e){return PTHREAD_SPECIFIC[e]||0}function ___setErrNo(e){return Module.___errno_location&&(HEAP32[Module.___errno_location()>>2]=e),e}var PTHREAD_SPECIFIC_NEXT_KEY=1,ERRNO_CODES={EPERM:1,ENOENT:2,ESRCH:3,EINTR:4,EIO:5,ENXIO:6,E2BIG:7,ENOEXEC:8,EBADF:9,ECHILD:10,EAGAIN:11,EWOULDBLOCK:11,ENOMEM:12,EACCES:13,EFAULT:14,ENOTBLK:15,EBUSY:16,EEXIST:17,EXDEV:18,ENODEV:19,ENOTDIR:20,EISDIR:21,EINVAL:22,ENFILE:23,EMFILE:24,ENOTTY:25,ETXTBSY:26,EFBIG:27,ENOSPC:28,ESPIPE:29,EROFS:30,EMLINK:31,EPIPE:32,EDOM:33,ERANGE:34,ENOMSG:42,EIDRM:43,ECHRNG:44,EL2NSYNC:45,EL3HLT:46,EL3RST:47,ELNRNG:48,EUNATCH:49,ENOCSI:50,EL2HLT:51,EDEADLK:35,ENOLCK:37,EBADE:52,EBADR:53,EXFULL:54,ENOANO:55,EBADRQC:56,EBADSLT:57,EDEADLOCK:35,EBFONT:59,ENOSTR:60,ENODATA:61,ETIME:62,ENOSR:63,ENONET:64,ENOPKG:65,EREMOTE:66,ENOLINK:67,EADV:68,ESRMNT:69,ECOMM:70,EPROTO:71,EMULTIHOP:72,EDOTDOT:73,EBADMSG:74,ENOTUNIQ:76,EBADFD:77,EREMCHG:78,ELIBACC:79,ELIBBAD:80,ELIBSCN:81,ELIBMAX:82,ELIBEXEC:83,ENOSYS:38,ENOTEMPTY:39,ENAMETOOLONG:36,ELOOP:40,EOPNOTSUPP:95,EPFNOSUPPORT:96,ECONNRESET:104,ENOBUFS:105,EAFNOSUPPORT:97,EPROTOTYPE:91,ENOTSOCK:88,ENOPROTOOPT:92,ESHUTDOWN:108,ECONNREFUSED:111,EADDRINUSE:98,ECONNABORTED:103,ENETUNREACH:101,ENETDOWN:100,ETIMEDOUT:110,EHOSTDOWN:112,EHOSTUNREACH:113,EINPROGRESS:115,EALREADY:114,EDESTADDRREQ:89,EMSGSIZE:90,EPROTONOSUPPORT:93,ESOCKTNOSUPPORT:94,EADDRNOTAVAIL:99,ENETRESET:102,EISCONN:106,ENOTCONN:107,ETOOMANYREFS:109,EUSERS:87,EDQUOT:122,ESTALE:116,ENOTSUP:95,ENOMEDIUM:123,EILSEQ:84,EOVERFLOW:75,ECANCELED:125,ENOTRECOVERABLE:131,EOWNERDEAD:130,ESTRPIPE:86};function _pthread_key_create(e,r){return 0==e?ERRNO_CODES.EINVAL:(HEAP32[e>>2]=PTHREAD_SPECIFIC_NEXT_KEY,PTHREAD_SPECIFIC[PTHREAD_SPECIFIC_NEXT_KEY]=0,PTHREAD_SPECIFIC_NEXT_KEY++,0)}function ___resumeException(e){throw EXCEPTIONS.last||(EXCEPTIONS.last=e),e+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch."}function ___cxa_find_matching_catch(){var e=EXCEPTIONS.last;if(!e)return 0|(Runtime.setTempRet0(0),0);var r=EXCEPTIONS.infos[e],i=r.type;if(!i)return 0|(Runtime.setTempRet0(0),e);var n=Array.prototype.slice.call(arguments);Module.___cxa_is_pointer_type(i),___cxa_find_matching_catch.buffer||(___cxa_find_matching_catch.buffer=_malloc(4)),HEAP32[___cxa_find_matching_catch.buffer>>2]=e,e=___cxa_find_matching_catch.buffer;for(var t=0;t<n.length;t++)if(n[t]&&Module.___cxa_can_catch(n[t],i,e))return r.adjusted=e=HEAP32[e>>2],0|(Runtime.setTempRet0(n[t]),e);return e=HEAP32[e>>2],0|(Runtime.setTempRet0(i),e)}function ___gxx_personality_v0(){}function _pthread_setspecific(e,r){return e in PTHREAD_SPECIFIC?(PTHREAD_SPECIFIC[e]=r,0):ERRNO_CODES.EINVAL}function ___syscall140(e,r){SYSCALLS.varargs=r;try{var i=SYSCALLS.getStreamFromFD(),n=(SYSCALLS.get(),SYSCALLS.get()),t=SYSCALLS.get(),o=SYSCALLS.get(),a=n;return FS.llseek(i,a,o),HEAP32[t>>2]=i.position,i.getdents&&0===a&&0===o&&(i.getdents=null),0}catch(e){return"undefined"!=typeof FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall146(e,r){SYSCALLS.varargs=r;try{var i=SYSCALLS.get(),n=SYSCALLS.get(),t=SYSCALLS.get(),o=0;___syscall146.buffer||(___syscall146.buffers=[null,[],[]],___syscall146.printChar=function(e,r){var i=___syscall146.buffers[e];assert(i),0===r||10===r?((1===e?Module.print:Module.printErr)(UTF8ArrayToString(i,0)),i.length=0):i.push(r)});for(var a=0;a<t;a++){for(var u=HEAP32[n+8*a>>2],f=HEAP32[n+(8*a+4)>>2],l=0;l<f;l++)___syscall146.printChar(i,HEAPU8[u+l]);o+=f}return o}catch(e){return"undefined"!=typeof FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function ___syscall54(e,r){SYSCALLS.varargs=r;try{return 0}catch(e){return"undefined"!=typeof FS&&e instanceof FS.ErrnoError||abort(e),-e.errno}}function invoke_iiii(e,r,i,n){try{return Module.dynCall_iiii(e,r,i,n)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_viiiii(e,r,i,n,t,o){try{Module.dynCall_viiiii(e,r,i,n,t,o)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_vi(e,r){try{Module.dynCall_vi(e,r)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_ii(e,r){try{return Module.dynCall_ii(e,r)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_viii(e,r,i,n){try{Module.dynCall_viii(e,r,i,n)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_v(e){try{Module.dynCall_v(e)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_viiiiii(e,r,i,n,t,o,a){try{Module.dynCall_viiiiii(e,r,i,n,t,o,a)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}function invoke_viiii(e,r,i,n,t){try{Module.dynCall_viiii(e,r,i,n,t)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;Module.setThrew(1,0)}}__ATEXIT__.push((function(){var e=Module._fflush;e&&e(0);var r=___syscall146.printChar;if(r){var i=___syscall146.buffers;i[1].length&&r(1,10),i[2].length&&r(2,10)}})),DYNAMICTOP_PTR=allocate(1,"i32",ALLOC_STATIC),STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP),STACK_MAX=STACK_BASE+TOTAL_STACK,DYNAMIC_BASE=Runtime.alignMemory(STACK_MAX),HEAP32[DYNAMICTOP_PTR>>2]=DYNAMIC_BASE,staticSealed=!0,Module.asmGlobalArg={Math,Int8Array,Int16Array,Int32Array,Uint8Array,Uint16Array,Uint32Array,Float32Array,Float64Array,NaN:NaN,Infinity:1/0,byteLength},Module.asmLibraryArg={abort,assert,enlargeMemory,getTotalMemory,abortOnCannotGrowMemory,invoke_iiii,invoke_viiiii,invoke_vi,invoke_ii,invoke_viii,invoke_v,invoke_viiiiii,invoke_viiii,_pthread_getspecific,___syscall54,_pthread_setspecific,___gxx_personality_v0,___syscall6,___setErrNo,_abort,___cxa_begin_catch,_pthread_once,_emscripten_memcpy_big,_pthread_key_create,___syscall140,___resumeException,___cxa_find_matching_catch,___syscall146,__ZSt18uncaught_exceptionv,DYNAMICTOP_PTR,tempDoublePtr,ABORT,STACKTOP,STACK_MAX,cttz_i8};var asm=function(e,r,i){var n=e.Int8Array,t=new n(i),o=e.Int16Array,a=new o(i),u=e.Int32Array,f=new u(i),l=e.Uint8Array,c=new l(i),s=e.Uint16Array,d=new s(i),_=e.Uint32Array;new _(i);var E=e.Float32Array;new E(i);var T=e.Float64Array,M=new T(i),A=e.byteLength,h=0|r.DYNAMICTOP_PTR,b=0|r.tempDoublePtr,m=0|r.STACKTOP,p=0|r.cttz_i8,S=0,v=e.Math.imul,k=e.Math.clz32,R=r.abort,y=r.enlargeMemory,g=r.getTotalMemory,O=r.abortOnCannotGrowMemory,w=r._pthread_getspecific,P=r.___syscall54,C=r._pthread_setspecific,N=r.___syscall6,I=r.___setErrNo,L=r._abort,D=r._pthread_once,F=r._emscripten_memcpy_big,U=r._pthread_key_create,H=r.___syscall140,x=r.___syscall146;function B(e){e|=0;var r,i=0,n=0,t=0,o=0,a=0,u=0,l=0,c=0,s=0,d=0,_=0,E=0,T=0,M=0,A=0,h=0,b=0,p=0,S=0,v=0;r=m,m=m+16|0,E=r;do{if(e>>>0<245){if(3&(n=(_=0|f[1144])>>>(e=(s=e>>>0<11?16:e+11&-8)>>>3))|0)return(0|(e=4616+((i=(1&n^1)+e|0)<<1<<2)|0))==(0|(a=0|f[(o=(t=0|f[(n=e+8|0)>>2])+8|0)>>2]))?f[1144]=_&~(1<<i):(f[a+12>>2]=e,f[n>>2]=a),f[t+4>>2]=3|(v=i<<3),f[(v=t+v+4|0)>>2]=1|f[v>>2],m=r,0|(v=o);if(s>>>0>(d=0|f[1146])>>>0){if(0|n)return i=((i=n<<e&((i=2<<e)|0-i))&0-i)-1|0,(0|(i=4616+((t=((n=(i>>>=u=i>>>12&16)>>>5&8)|u|(o=(i>>>=n)>>>2&4)|(e=(i>>>=o)>>>1&2)|(t=(i>>>=e)>>>1&1))+(i>>>t)|0)<<1<<2)|0))==(0|(n=0|f[(u=(o=0|f[(e=i+8|0)>>2])+8|0)>>2]))?f[1144]=e=_&~(1<<t):(f[n+12>>2]=i,f[e>>2]=n,e=_),a=(t<<3)-s|0,f[o+4>>2]=3|s,f[(t=o+s|0)+4>>2]=1|a,f[t+a>>2]=a,0|d&&(o=0|f[1149],n=4616+((i=d>>>3)<<1<<2)|0,e&(i=1<<i)?i=0|f[(e=n+8|0)>>2]:(f[1144]=e|i,i=n,e=n+8|0),f[e>>2]=o,f[i+12>>2]=o,f[o+8>>2]=i,f[o+12>>2]=n),f[1146]=a,f[1149]=t,m=r,0|(v=u);if(l=0|f[1145]){if(n=(l&0-l)-1|0,n=(-8&f[(e=0|f[4880+(((a=(n>>>=u=n>>>12&16)>>>5&8)|u|(c=(n>>>=a)>>>2&4)|(t=(n>>>=c)>>>1&2)|(e=(n>>>=t)>>>1&1))+(n>>>e)<<2)>>2])+4>>2])-s|0,t=0|f[e+16+((0==(0|f[e+16>>2])&1)<<2)>>2]){do{n=(c=(u=(-8&f[t+4>>2])-s|0)>>>0<n>>>0)?u:n,e=c?t:e,t=0|f[t+16+((0==(0|f[t+16>>2])&1)<<2)>>2]}while(0!=(0|t));c=e,a=n}else c=e,a=n;if(c>>>0<(u=c+s|0)>>>0){o=0|f[c+24>>2],i=0|f[c+12>>2];do{if((0|i)==(0|c)){if(!(i=0|f[(e=c+20|0)>>2])&&!(i=0|f[(e=c+16|0)>>2])){n=0;break}for(;;)if(0|(t=0|f[(n=i+20|0)>>2]))i=t,e=n;else{if(!(t=0|f[(n=i+16|0)>>2]))break;i=t,e=n}f[e>>2]=0,n=i}else f[(n=0|f[c+8>>2])+12>>2]=i,f[i+8>>2]=n,n=i}while(0);do{if(0|o){if((0|c)==(0|f[(e=4880+((i=0|f[c+28>>2])<<2)|0)>>2])){if(f[e>>2]=n,!n){f[1145]=l&~(1<<i);break}}else if(f[o+16+(((0|f[o+16>>2])!=(0|c)&1)<<2)>>2]=n,!n)break;f[n+24>>2]=o,0|(i=0|f[c+16>>2])&&(f[n+16>>2]=i,f[i+24>>2]=n),0|(i=0|f[c+20>>2])&&(f[n+20>>2]=i,f[i+24>>2]=n)}}while(0);return a>>>0<16?(f[c+4>>2]=3|(v=a+s|0),f[(v=c+v+4|0)>>2]=1|f[v>>2]):(f[c+4>>2]=3|s,f[u+4>>2]=1|a,f[u+a>>2]=a,0|d&&(t=0|f[1149],n=4616+((i=d>>>3)<<1<<2)|0,_&(i=1<<i)?i=0|f[(e=n+8|0)>>2]:(f[1144]=_|i,i=n,e=n+8|0),f[e>>2]=t,f[i+12>>2]=t,f[t+8>>2]=i,f[t+12>>2]=n),f[1146]=a,f[1149]=u),m=r,0|(v=c+8|0)}_=s}else _=s}else _=s}else if(e>>>0<=4294967231)if(s=-8&(e=e+11|0),c=0|f[1145]){t=0-s|0,l=(e>>>=8)?s>>>0>16777215?31:s>>>((l=14-((d=((S=e<<(_=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|_|(l=((S<<=d)+245760|0)>>>16&2))+(S<<l>>>15)|0)+7|0)&1|l<<1:0,n=0|f[4880+(l<<2)>>2];e:do{if(n)for(e=0,u=s<<(31==(0|l)?0:25-(l>>>1)|0),a=0;;){if((o=(-8&f[n+4>>2])-s|0)>>>0<t>>>0){if(!o){e=n,t=0,o=n,S=61;break e}e=n,t=o}if(a=0==(0|(o=0|f[n+20>>2]))|(0|o)==(0|(n=0|f[n+16+(u>>>31<<2)>>2]))?a:o,o=0==(0|n)){n=a,S=57;break}u<<=1&(1^o)}else n=0,e=0,S=57}while(0);if(57==(0|S)){if(0==(0|n)&0==(0|e)){if(!(e=c&((e=2<<l)|0-e))){_=s;break}_=(e&0-e)-1|0,e=0,n=0|f[4880+(((a=(_>>>=u=_>>>12&16)>>>5&8)|u|(l=(_>>>=a)>>>2&4)|(d=(_>>>=l)>>>1&2)|(n=(_>>>=d)>>>1&1))+(_>>>n)<<2)>>2]}n?(o=n,S=61):(l=e,u=t)}if(61==(0|S))for(;;){if(S=0,n=(_=(n=(-8&f[o+4>>2])-s|0)>>>0<t>>>0)?n:t,e=_?o:e,!(o=0|f[o+16+((0==(0|f[o+16>>2])&1)<<2)>>2])){l=e,u=n;break}t=n,S=61}if(0!=(0|l)&&u>>>0<((0|f[1146])-s|0)>>>0){if(l>>>0>=(a=l+s|0)>>>0)return m=r,0|(v=0);o=0|f[l+24>>2],i=0|f[l+12>>2];do{if((0|i)==(0|l)){if(!(i=0|f[(e=l+20|0)>>2])&&!(i=0|f[(e=l+16|0)>>2])){i=0;break}for(;;)if(0|(t=0|f[(n=i+20|0)>>2]))i=t,e=n;else{if(!(t=0|f[(n=i+16|0)>>2]))break;i=t,e=n}f[e>>2]=0}else f[(v=0|f[l+8>>2])+12>>2]=i,f[i+8>>2]=v}while(0);do{if(o){if((0|l)==(0|f[(n=4880+((e=0|f[l+28>>2])<<2)|0)>>2])){if(f[n>>2]=i,!i){f[1145]=t=c&~(1<<e);break}}else if(f[o+16+(((0|f[o+16>>2])!=(0|l)&1)<<2)>>2]=i,!i){t=c;break}f[i+24>>2]=o,0|(e=0|f[l+16>>2])&&(f[i+16>>2]=e,f[e+24>>2]=i),(e=0|f[l+20>>2])?(f[i+20>>2]=e,f[e+24>>2]=i,t=c):t=c}else t=c}while(0);do{if(u>>>0>=16){if(f[l+4>>2]=3|s,f[a+4>>2]=1|u,f[a+u>>2]=u,i=u>>>3,u>>>0<256){n=4616+(i<<1<<2)|0,(e=0|f[1144])&(i=1<<i)?i=0|f[(e=n+8|0)>>2]:(f[1144]=e|i,i=n,e=n+8|0),f[e>>2]=a,f[i+12>>2]=a,f[a+8>>2]=i,f[a+12>>2]=n;break}if(n=4880+((i=(i=u>>>8)?u>>>0>16777215?31:u>>>((i=14-((p=((v=i<<(S=(i+1048320|0)>>>16&8))+520192|0)>>>16&4)|S|(i=((v<<=p)+245760|0)>>>16&2))+(v<<i>>>15)|0)+7|0)&1|i<<1:0)<<2)|0,f[a+28>>2]=i,f[(e=a+16|0)+4>>2]=0,f[e>>2]=0,!(t&(e=1<<i))){f[1145]=t|e,f[n>>2]=a,f[a+24>>2]=n,f[a+12>>2]=a,f[a+8>>2]=a;break}for(e=u<<(31==(0|i)?0:25-(i>>>1)|0),n=0|f[n>>2];;){if((-8&f[n+4>>2]|0)==(0|u)){S=97;break}if(!(i=0|f[(t=n+16+(e>>>31<<2)|0)>>2])){S=96;break}e<<=1,n=i}if(96==(0|S)){f[t>>2]=a,f[a+24>>2]=n,f[a+12>>2]=a,f[a+8>>2]=a;break}if(97==(0|S)){f[(v=0|f[(S=n+8|0)>>2])+12>>2]=a,f[S>>2]=a,f[a+8>>2]=v,f[a+12>>2]=n,f[a+24>>2]=0;break}}else f[l+4>>2]=3|(v=u+s|0),f[(v=l+v+4|0)>>2]=1|f[v>>2]}while(0);return m=r,0|(v=l+8|0)}_=s}else _=s;else _=-1}while(0);if((n=0|f[1146])>>>0>=_>>>0)return e=0|f[1149],(i=n-_|0)>>>0>15?(f[1149]=v=e+_|0,f[1146]=i,f[v+4>>2]=1|i,f[v+i>>2]=i,f[e+4>>2]=3|_):(f[1146]=0,f[1149]=0,f[e+4>>2]=3|n,f[(v=e+n+4|0)>>2]=1|f[v>>2]),m=r,0|(v=e+8|0);if((u=0|f[1147])>>>0>_>>>0)return f[1147]=p=u-_|0,f[1150]=S=(v=0|f[1150])+_|0,f[S+4>>2]=1|p,f[v+4>>2]=3|_,m=r,0|(v=v+8|0);if(0|f[1262]?e=0|f[1264]:(f[1264]=4096,f[1263]=4096,f[1265]=-1,f[1266]=-1,f[1267]=0,f[1255]=0,f[E>>2]=e=-16&E^1431655768,f[1262]=e,e=4096),l=_+48|0,(s=(a=e+(c=_+47|0)|0)&(o=0-e|0))>>>0<=_>>>0)return m=r,0|(v=0);if(0|(e=0|f[1254])&&(E=(d=0|f[1252])+s|0)>>>0<=d>>>0|E>>>0>e>>>0)return m=r,0|(v=0);e:do{if(4&f[1255])i=0,S=133;else{n=0|f[1150];r:do{if(n){for(t=5024;!((e=0|f[t>>2])>>>0<=n>>>0&&(e+(0|f[(A=t+4|0)>>2])|0)>>>0>n>>>0);){if(!(e=0|f[t+8>>2])){S=118;break r}t=e}if((i=a-u&o)>>>0<2147483647)if((0|(e=0|He(0|i)))==((0|f[t>>2])+(0|f[A>>2])|0)){if(-1!=(0|e)){u=i,a=e,S=135;break e}}else t=e,S=126;else i=0}else S=118}while(0);do{if(118==(0|S))if(-1!=(0|(n=0|He(0)))&&(M=(i=(0==((M=(T=0|f[1263])+-1|0)&(i=n)|0)?0:(M+i&0-T)-i|0)+s|0)+(T=0|f[1252])|0,i>>>0>_>>>0&i>>>0<2147483647)){if(0|(A=0|f[1254])&&M>>>0<=T>>>0|M>>>0>A>>>0){i=0;break}if((0|(e=0|He(0|i)))==(0|n)){u=i,a=n,S=135;break e}t=e,S=126}else i=0}while(0);do{if(126==(0|S)){if(n=0-i|0,!(l>>>0>i>>>0&i>>>0<2147483647&-1!=(0|t))){if(-1==(0|t)){i=0;break}u=i,a=t,S=135;break e}if((e=c-i+(e=0|f[1264])&0-e)>>>0>=2147483647){u=i,a=t,S=135;break e}if(-1==(0|He(0|e))){He(0|n),i=0;break}u=e+i|0,a=t,S=135;break e}}while(0);f[1255]=4|f[1255],S=133}}while(0);if(133==(0|S)&&s>>>0<2147483647&&!(-1==(0|(p=0|He(0|s)))|1^(b=(h=(A=0|He(0))-p|0)>>>0>(_+40|0)>>>0)|p>>>0<A>>>0&-1!=(0|p)&-1!=(0|A)^1)&&(u=b?h:i,a=p,S=135),135==(0|S)){f[1252]=i=(0|f[1252])+u|0,i>>>0>(0|f[1253])>>>0&&(f[1253]=i),c=0|f[1150];do{if(c){for(i=5024;;){if((0|a)==((e=0|f[i>>2])+(t=0|f[(n=i+4|0)>>2])|0)){S=145;break}if(!(o=0|f[i+8>>2]))break;i=o}if(145==(0|S)&&0==(8&f[i+12>>2]|0)&&c>>>0<a>>>0&c>>>0>=e>>>0){f[n>>2]=t+u,S=c+(v=0==(7&(v=c+8|0)|0)?0:0-v&7)|0,v=u-v+(0|f[1147])|0,f[1150]=S,f[1147]=v,f[S+4>>2]=1|v,f[S+v+4>>2]=40,f[1151]=f[1266];break}for(a>>>0<(0|f[1148])>>>0&&(f[1148]=a),n=a+u|0,i=5024;;){if((0|f[i>>2])==(0|n)){S=153;break}if(!(e=0|f[i+8>>2]))break;i=e}if(153==(0|S)&&0==(8&f[i+12>>2]|0)){f[i>>2]=a,f[(d=i+4|0)>>2]=(0|f[d>>2])+u,s=(d=a+(0==(7&(d=a+8|0)|0)?0:0-d&7)|0)+_|0,l=(i=n+(0==(7&(i=n+8|0)|0)?0:0-i&7)|0)-d-_|0,f[d+4>>2]=3|_;do{if((0|i)!=(0|c)){if((0|i)==(0|f[1149])){f[1146]=v=(0|f[1146])+l|0,f[1149]=s,f[s+4>>2]=1|v,f[s+v>>2]=v;break}if(1==(3&(e=0|f[i+4>>2])|0)){u=-8&e,t=e>>>3;e:do{if(e>>>0<256){if((0|(n=0|f[i+12>>2]))==(0|(e=0|f[i+8>>2]))){f[1144]=f[1144]&~(1<<t);break}f[e+12>>2]=n,f[n+8>>2]=e;break}a=0|f[i+24>>2],e=0|f[i+12>>2];do{if((0|e)==(0|i)){if(!(e=0|f[(n=(t=i+16|0)+4|0)>>2])){if(!(e=0|f[t>>2])){e=0;break}n=t}for(;;)if(0|(o=0|f[(t=e+20|0)>>2]))e=o,n=t;else{if(!(o=0|f[(t=e+16|0)>>2]))break;e=o,n=t}f[n>>2]=0}else f[(v=0|f[i+8>>2])+12>>2]=e,f[e+8>>2]=v}while(0);if(!a)break;t=4880+((n=0|f[i+28>>2])<<2)|0;do{if((0|i)==(0|f[t>>2])){if(f[t>>2]=e,0|e)break;f[1145]=f[1145]&~(1<<n);break e}if(f[a+16+(((0|f[a+16>>2])!=(0|i)&1)<<2)>>2]=e,!e)break e}while(0);if(f[e+24>>2]=a,0|(t=0|f[(n=i+16|0)>>2])&&(f[e+16>>2]=t,f[t+24>>2]=e),!(n=0|f[n+4>>2]))break;f[e+20>>2]=n,f[n+24>>2]=e}while(0);i=i+u|0,o=u+l|0}else o=l;if(f[(i=i+4|0)>>2]=-2&f[i>>2],f[s+4>>2]=1|o,f[s+o>>2]=o,i=o>>>3,o>>>0<256){n=4616+(i<<1<<2)|0,(e=0|f[1144])&(i=1<<i)?i=0|f[(e=n+8|0)>>2]:(f[1144]=e|i,i=n,e=n+8|0),f[e>>2]=s,f[i+12>>2]=s,f[s+8>>2]=i,f[s+12>>2]=n;break}i=o>>>8;do{if(i){if(o>>>0>16777215){i=31;break}i=o>>>((i=14-((p=((v=i<<(S=(i+1048320|0)>>>16&8))+520192|0)>>>16&4)|S|(i=((v<<=p)+245760|0)>>>16&2))+(v<<i>>>15)|0)+7|0)&1|i<<1}else i=0}while(0);if(t=4880+(i<<2)|0,f[s+28>>2]=i,f[(e=s+16|0)+4>>2]=0,f[e>>2]=0,!((e=0|f[1145])&(n=1<<i))){f[1145]=e|n,f[t>>2]=s,f[s+24>>2]=t,f[s+12>>2]=s,f[s+8>>2]=s;break}for(e=o<<(31==(0|i)?0:25-(i>>>1)|0),n=0|f[t>>2];;){if((-8&f[n+4>>2]|0)==(0|o)){S=194;break}if(!(i=0|f[(t=n+16+(e>>>31<<2)|0)>>2])){S=193;break}e<<=1,n=i}if(193==(0|S)){f[t>>2]=s,f[s+24>>2]=n,f[s+12>>2]=s,f[s+8>>2]=s;break}if(194==(0|S)){f[(v=0|f[(S=n+8|0)>>2])+12>>2]=s,f[S>>2]=s,f[s+8>>2]=v,f[s+12>>2]=n,f[s+24>>2]=0;break}}else f[1147]=v=(0|f[1147])+l|0,f[1150]=s,f[s+4>>2]=1|v}while(0);return m=r,0|(v=d+8|0)}for(i=5024;!((e=0|f[i>>2])>>>0<=c>>>0&&(v=e+(0|f[i+4>>2])|0)>>>0>c>>>0);)i=0|f[i+8>>2];i=(e=(e=(o=v+-47|0)+(0==(7&(e=o+8|0)|0)?0:0-e&7)|0)>>>0<(o=c+16|0)>>>0?c:e)+8|0,S=a+(n=0==(7&(n=a+8|0)|0)?0:0-n&7)|0,n=u+-40-n|0,f[1150]=S,f[1147]=n,f[S+4>>2]=1|n,f[S+n+4>>2]=40,f[1151]=f[1266],f[(n=e+4|0)>>2]=27,f[i>>2]=f[1256],f[i+4>>2]=f[1257],f[i+8>>2]=f[1258],f[i+12>>2]=f[1259],f[1256]=a,f[1257]=u,f[1259]=0,f[1258]=i,i=e+24|0;do{S=i,f[(i=i+4|0)>>2]=7}while((S+8|0)>>>0<v>>>0);if((0|e)!=(0|c)){if(a=e-c|0,f[n>>2]=-2&f[n>>2],f[c+4>>2]=1|a,f[e>>2]=a,i=a>>>3,a>>>0<256){n=4616+(i<<1<<2)|0,(e=0|f[1144])&(i=1<<i)?i=0|f[(e=n+8|0)>>2]:(f[1144]=e|i,i=n,e=n+8|0),f[e>>2]=c,f[i+12>>2]=c,f[c+8>>2]=i,f[c+12>>2]=n;break}if(t=4880+((n=(i=a>>>8)?a>>>0>16777215?31:a>>>((n=14-((p=((v=i<<(S=(i+1048320|0)>>>16&8))+520192|0)>>>16&4)|S|(n=((v<<=p)+245760|0)>>>16&2))+(v<<n>>>15)|0)+7|0)&1|n<<1:0)<<2)|0,f[c+28>>2]=n,f[c+20>>2]=0,f[o>>2]=0,!((i=0|f[1145])&(e=1<<n))){f[1145]=i|e,f[t>>2]=c,f[c+24>>2]=t,f[c+12>>2]=c,f[c+8>>2]=c;break}for(e=a<<(31==(0|n)?0:25-(n>>>1)|0),n=0|f[t>>2];;){if((-8&f[n+4>>2]|0)==(0|a)){S=216;break}if(!(i=0|f[(t=n+16+(e>>>31<<2)|0)>>2])){S=215;break}e<<=1,n=i}if(215==(0|S)){f[t>>2]=c,f[c+24>>2]=n,f[c+12>>2]=c,f[c+8>>2]=c;break}if(216==(0|S)){f[(v=0|f[(S=n+8|0)>>2])+12>>2]=c,f[S>>2]=c,f[c+8>>2]=v,f[c+12>>2]=n,f[c+24>>2]=0;break}}}else{0==(0|(v=0|f[1148]))|a>>>0<v>>>0&&(f[1148]=a),f[1256]=a,f[1257]=u,f[1259]=0,f[1153]=f[1262],f[1152]=-1,i=0;do{f[(v=4616+(i<<1<<2)|0)+12>>2]=v,f[v+8>>2]=v,i=i+1|0}while(32!=(0|i));S=a+(v=0==(7&(v=a+8|0)|0)?0:0-v&7)|0,v=u+-40-v|0,f[1150]=S,f[1147]=v,f[S+4>>2]=1|v,f[S+v+4>>2]=40,f[1151]=f[1266]}}while(0);if((i=0|f[1147])>>>0>_>>>0)return f[1147]=p=i-_|0,f[1150]=S=(v=0|f[1150])+_|0,f[S+4>>2]=1|p,f[v+4>>2]=3|_,m=r,0|(v=v+8|0)}return v=0|Er(),f[v>>2]=12,m=r,0|(v=0)}function Y(e,r,i,n,o,a){e|=0,r=+r,i|=0,n|=0,o|=0,a|=0;var u,l=0,s=0,d=0,_=0,E=0,T=0,M=0,A=0,h=0,b=0,p=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0,C=0,N=0,I=0,L=0;u=m,m=m+560|0,d=u+8|0,I=L=u+524|0,_=u+512|0,f[(p=u)>>2]=0,N=_+12|0,qe(r),(0|S)<0?(r=-r,P=1,w=2087):(P=0!=(2049&o|0)&1,w=0==(2048&o|0)?0==(1&o|0)?2088:2093:2090),qe(r),C=2146435072&S;do{if(C>>>0<2146435072|2146435072==(0|C)&!1){if((l=0!=(A=2*+_r(r,p)))&&(f[p>>2]=(0|f[p>>2])-1),97==(0|(R=32|a))){M=0==(0|(h=32&a))?w:w+9|0,T=2|P,l=12-n|0;do{if(!(n>>>0>11|0==(0|l))){r=8;do{l=l+-1|0,r*=16}while(0!=(0|l));if(45==(0|t[M>>0])){r=-(r+(-A-r));break}r=A+r-r;break}r=A}while(0);(0|(l=0|Ce(l=(0|(s=0|f[p>>2]))<0?0-s|0:s,((0|l)<0)<<31>>31,N)))==(0|N)&&(t[(l=_+11|0)>>0]=48),t[l+-1>>0]=43+(s>>31&2),t[(E=l+-2|0)>>0]=a+15,_=(0|n)<1,d=0==(8&o|0),l=L;do{s=l+1|0,t[l>>0]=c[2122+(C=~~r)>>0]|h,r=16*(r-+(0|C)),1!=(s-I|0)||d&_&0==r?l=s:(t[s>>0]=46,l=l+2|0)}while(0!=r);C=l-I|0,De(e,32,i,l=(I=N-E|0)+T+(N=0!=(0|n)&(C+-2|0)<(0|n)?n+2|0:C)|0,o),rr(e,M,T),De(e,48,i,l,65536^o),rr(e,L,C),De(e,48,N-C|0,0,0),rr(e,E,I),De(e,32,i,l,8192^o);break}s=(0|n)<0?6:n,l?(f[p>>2]=l=(0|f[p>>2])-28|0,r=268435456*A):(r=A,l=0|f[p>>2]),d=C=(0|l)<0?d:d+288|0;do{f[d>>2]=g=~~r>>>0,d=d+4|0,r=1e9*(r-+(g>>>0))}while(0!=r);if((0|l)>0)for(_=C,T=d;;){if(E=(0|l)<29?l:29,(l=T+-4|0)>>>0>=_>>>0){d=0;do{k=0|Ge(0|(y=0|Qe(0|(y=0|ze(0|f[l>>2],0,0|E)),0|S,0|d,0)),0|(g=S),1e9,0),f[l>>2]=k,d=0|ar(0|y,0|g,1e9,0),l=l+-4|0}while(l>>>0>=_>>>0);d&&(f[(_=_+-4|0)>>2]=d)}for(d=T;!(d>>>0<=_>>>0||0|f[(l=d+-4|0)>>2]);)d=l;if(f[p>>2]=l=(0|f[p>>2])-E|0,!((0|l)>0))break;T=d}else _=C;if((0|l)<0){n=1+((s+25|0)/9|0)|0,b=102==(0|R);do{if(h=(0|(h=0-l|0))<9?h:9,_>>>0<d>>>0){E=(1<<h)-1|0,T=1e9>>>h,M=0,l=_;do{f[l>>2]=((g=0|f[l>>2])>>>h)+M,M=0|v(g&E,T),l=l+4|0}while(l>>>0<d>>>0);l=0==(0|f[_>>2])?_+4|0:_,M?(f[d>>2]=M,_=l,l=d+4|0):(_=l,l=d)}else _=0==(0|f[_>>2])?_+4|0:_,l=d;d=(l-(d=b?C:_)>>2|0)>(0|n)?d+(n<<2)|0:l,f[p>>2]=l=(0|f[p>>2])+h|0}while((0|l)<0);l=_,n=d}else l=_,n=d;if(g=C,l>>>0<n>>>0){if(d=9*(g-l>>2)|0,(E=0|f[l>>2])>>>0>=10){_=10;do{_=10*_|0,d=d+1|0}while(E>>>0>=_>>>0)}}else d=0;if((0|(_=s-(102!=(0|R)?d:0)+(((k=0!=(0|s))&(b=103==(0|R)))<<31>>31)|0))<((9*(n-g>>2)|0)-9|0)){if(h=C+4+(((0|(_=_+9216|0))/9|0)-1024<<2)|0,(0|(_=1+((0|_)%9|0)|0))<9){E=10;do{E=10*E|0,_=_+1|0}while(9!=(0|_))}else E=10;if((_=(h+4|0)==(0|n))&0==(0|(M=((T=0|f[h>>2])>>>0)%(E>>>0)|0)))_=h;else if(A=0==(1&((T>>>0)/(E>>>0)|0)|0)?9007199254740992:9007199254740994,r=M>>>0<(y=(0|E)/2|0)>>>0?.5:_&(0|M)==(0|y)?1:1.5,P&&(r=(y=45==(0|t[w>>0]))?-r:r,A=y?-A:A),f[h>>2]=_=T-M|0,A+r!=A){if(f[h>>2]=y=_+E|0,y>>>0>999999999)for(d=h;_=d+-4|0,f[d>>2]=0,_>>>0<l>>>0&&(f[(l=l+-4|0)>>2]=0),f[_>>2]=y=1+(0|f[_>>2])|0,y>>>0>999999999;)d=_;else _=h;if(d=9*(g-l>>2)|0,(T=0|f[l>>2])>>>0>=10){E=10;do{E=10*E|0,d=d+1|0}while(T>>>0>=E>>>0)}}else _=h;_=n>>>0>(_=_+4|0)>>>0?_:n,y=l}else _=n,y=l;for(R=_;;){if(R>>>0<=y>>>0){p=0;break}if(0|f[(l=R+-4|0)>>2]){p=1;break}R=l}n=0-d|0;do{if(b){if((0|(l=(1&(1^k))+s|0))>(0|d)&(0|d)>-5?(E=a+-1|0,s=l+-1-d|0):(E=a+-2|0,s=l+-1|0),!(l=8&o)){if(p&&0!=(0|(O=0|f[R+-4>>2])))if((O>>>0)%10|0)_=0;else{_=0,l=10;do{l=10*l|0,_=_+1|0}while(!(0|(O>>>0)%(l>>>0)))}else _=9;if(l=(9*(R-g>>2)|0)-9|0,102==(32|E)){s=(0|s)<(0|(h=(0|(h=l-_|0))>0?h:0))?s:h,h=0;break}s=(0|s)<(0|(h=(0|(h=l+d-_|0))>0?h:0))?s:h,h=0;break}h=l}else E=a,h=8&o}while(0);if(T=0!=(0|(b=s|h))&1,M=102==(32|E))k=0,l=(0|d)>0?d:0;else{if(((_=N)-(l=0|Ce(l=(0|d)<0?n:d,((0|l)<0)<<31>>31,N))|0)<2)do{t[(l=l+-1|0)>>0]=48}while((_-l|0)<2);t[l+-1>>0]=43+(d>>31&2),t[(l=l+-2|0)>>0]=E,k=l,l=_-l|0}if(De(e,32,i,l=P+1+s+T+l|0,o),rr(e,w,P),De(e,48,i,l,65536^o),M){T=h=L+9|0,M=L+8|0,_=E=y>>>0>C>>>0?C:y;do{if(d=0|Ce(0|f[_>>2],0,h),(0|_)==(0|E))(0|d)==(0|h)&&(t[M>>0]=48,d=M);else if(d>>>0>L>>>0){ke(0|L,48,d-I|0);do{d=d+-1|0}while(d>>>0>L>>>0)}rr(e,d,T-d|0),_=_+4|0}while(_>>>0<=C>>>0);if(0|b&&rr(e,2138,1),_>>>0<R>>>0&(0|s)>0)for(;;){if((d=0|Ce(0|f[_>>2],0,h))>>>0>L>>>0){ke(0|L,48,d-I|0);do{d=d+-1|0}while(d>>>0>L>>>0)}if(rr(e,d,(0|s)<9?s:9),d=s+-9|0,!((_=_+4|0)>>>0<R>>>0&(0|s)>9)){s=d;break}s=d}De(e,48,s+9|0,9,0)}else{if(b=p?R:y+4|0,(0|s)>-1){h=0==(0|h),n=p=L+9|0,T=0-I|0,M=L+8|0,E=y;do{(0|(d=0|Ce(0|f[E>>2],0,p)))==(0|p)&&(t[M>>0]=48,d=M);do{if((0|E)==(0|y)){if(_=d+1|0,rr(e,d,1),h&(0|s)<1){d=_;break}rr(e,2138,1),d=_}else{if(d>>>0<=L>>>0)break;ke(0|L,48,d+T|0);do{d=d+-1|0}while(d>>>0>L>>>0)}}while(0);rr(e,d,(0|s)>(0|(I=n-d|0))?I:s),s=s-I|0,E=E+4|0}while(E>>>0<b>>>0&(0|s)>-1)}De(e,48,s+18|0,18,0),rr(e,k,N-k|0)}De(e,32,i,l,8192^o)}else L=0!=(32&a|0),De(e,32,i,l=P+3|0,-65537&o),rr(e,w,P),rr(e,r!=r|!1?L?2114:2118:L?2106:2110,3),De(e,32,i,l,8192^o)}while(0);return m=u,0|((0|l)<(0|i)?i:l)}function V(e,r,i,n,o){e|=0,i|=0,n|=0,o|=0;var u,l,c,s,d,_,E,T,A,h=0,b=0,p=0,v=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0,C=0,N=0,I=0;A=m,m=m+64|0,_=A,I=A+24|0,E=A+8|0,T=A+20|0,f[(d=A+16|0)>>2]=r|=0,u=0!=(0|e),c=l=I+40|0,I=I+39|0,s=E+4|0,b=0,h=0,R=0;e:for(;;){do{if((0|h)>-1){if((0|b)>(2147483647-h|0)){h=0|Er(),f[h>>2]=75,h=-1;break}h=b+h|0;break}}while(0);if(!((b=0|t[r>>0])<<24>>24)){N=87;break}p=r;r:for(;;){switch(b<<24>>24){case 37:b=p,N=9;break r;case 0:b=p;break r}f[d>>2]=C=p+1|0,b=0|t[C>>0],p=C}r:do{if(9==(0|N))for(;;){if(N=0,37!=(0|t[p+1>>0]))break r;if(b=b+1|0,f[d>>2]=p=p+2|0,37!=(0|t[p>>0]))break;N=9}}while(0);if(b=b-r|0,u&&rr(e,r,b),0|b)r=p;else{(b=(0|t[(v=p+1|0)>>0])-48|0)>>>0<10?(P=(C=36==(0|t[p+2>>0]))?b:-1,R=C?1:R,v=C?p+3|0:v):P=-1,f[d>>2]=v,p=((b=0|t[v>>0])<<24>>24)-32|0;r:do{if(p>>>0<32)for(k=0,y=b;;){if(!(75913&(b=1<<p))){b=y;break r}if(k|=b,f[d>>2]=v=v+1|0,(p=((b=0|t[v>>0])<<24>>24)-32|0)>>>0>=32)break;y=b}else k=0}while(0);if(b<<24>>24==42){if((b=(0|t[(p=v+1|0)>>0])-48|0)>>>0<10&&36==(0|t[v+2>>0]))f[o+(b<<2)>>2]=10,b=0|f[n+((0|t[p>>0])-48<<3)>>2],R=1,v=v+3|0;else{if(0|R){h=-1;break}u?(b=0|f[(R=3+(0|f[i>>2])&-4)>>2],f[i>>2]=R+4,R=0,v=p):(b=0,R=0,v=p)}f[d>>2]=v,b=(C=(0|b)<0)?0-b|0:b,k=C?8192|k:k}else{if((0|(b=0|xe(d)))<0){h=-1;break}v=0|f[d>>2]}do{if(46==(0|t[v>>0])){if(42!=(0|t[v+1>>0])){f[d>>2]=v+1,p=0|xe(d),v=0|f[d>>2];break}if((p=(0|t[(y=v+2|0)>>0])-48|0)>>>0<10&&36==(0|t[v+3>>0])){f[o+(p<<2)>>2]=10,p=0|f[n+((0|t[y>>0])-48<<3)>>2],f[d>>2]=v=v+4|0;break}if(0|R){h=-1;break e}u?(p=0|f[(C=3+(0|f[i>>2])&-4)>>2],f[i>>2]=C+4):p=0,f[d>>2]=y,v=y}else p=-1}while(0);for(w=0;;){if(((0|t[v>>0])-65|0)>>>0>57){h=-1;break e}if(f[d>>2]=C=v+1|0,!(((g=255&(y=0|t[(0|t[v>>0])-65+(1606+(58*w|0))>>0]))+-1|0)>>>0<8))break;w=g,v=C}if(!(y<<24>>24)){h=-1;break}O=(0|P)>-1;do{if(y<<24>>24==19){if(O){h=-1;break e}N=49}else{if(O){f[o+(P<<2)>>2]=g,P=0|f[(O=n+(P<<3)|0)+4>>2],f[(N=_)>>2]=f[O>>2],f[N+4>>2]=P,N=49;break}if(!u){h=0;break e}ie(_,g,i)}}while(0);if(49!=(0|N)||(N=0,u)){v=0!=(0|w)&3==(15&(v=0|t[v>>0])|0)?-33&v:v,O=-65537&k,P=0==(8192&k|0)?k:O;r:do{switch(0|v){case 110:switch((255&w)<<24>>24){case 0:case 1:f[f[_>>2]>>2]=h,b=0,r=C;continue e;case 2:f[(b=0|f[_>>2])>>2]=h,f[b+4>>2]=((0|h)<0)<<31>>31,b=0,r=C;continue e;case 3:a[f[_>>2]>>1]=h,b=0,r=C;continue e;case 4:t[f[_>>2]>>0]=h,b=0,r=C;continue e;case 6:f[f[_>>2]>>2]=h,b=0,r=C;continue e;case 7:f[(b=0|f[_>>2])>>2]=h,f[b+4>>2]=((0|h)<0)<<31>>31,b=0,r=C;continue e;default:b=0,r=C;continue e}case 112:v=120,p=p>>>0>8?p:8,r=8|P,N=61;break;case 88:case 120:r=P,N=61;break;case 111:k=0,y=2070,p=0==(8&P|0)|(0|p)>(0|(O=c-(g=0|Xe(r=0|f[(v=_)>>2],v=0|f[v+4>>2],l))|0))?p:O+1|0,O=P,N=67;break;case 105:case 100:if(r=0|f[(v=_)>>2],(0|(v=0|f[v+4>>2]))<0){r=0|Ze(0,0,0|r,0|v),v=S,f[(k=_)>>2]=r,f[k+4>>2]=v,k=1,y=2070,N=66;break r}k=0!=(2049&P|0)&1,y=0==(2048&P|0)?0==(1&P|0)?2070:2072:2071,N=66;break r;case 117:k=0,y=2070,r=0|f[(v=_)>>2],v=0|f[v+4>>2],N=66;break;case 99:t[I>>0]=f[_>>2],r=I,k=0,y=2070,g=l,v=1,p=O;break;case 109:v=0|Er(),v=0|ir(0|f[v>>2]),N=71;break;case 115:v=0|(v=0|f[_>>2])?v:2080,N=71;break;case 67:f[E>>2]=f[_>>2],f[s>>2]=0,f[_>>2]=E,g=-1,v=E,N=75;break;case 83:r=0|f[_>>2],p?(g=p,v=r,N=75):(De(e,32,b,0,P),r=0,N=84);break;case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:b=0|Y(e,+M[_>>3],b,p,P,v),r=C;continue e;default:k=0,y=2070,g=l,v=p,p=P}}while(0);r:do{if(61==(0|N))g=0|Be(w=0|f[(P=_)>>2],P=0|f[P+4>>2],l,32&v),k=(y=0==(8&r|0)|0==(0|w)&0==(0|P))?0:2,y=y?2070:2070+(v>>4)|0,O=r,r=w,v=P,N=67;else if(66==(0|N))g=0|Ce(r,v,l),O=P,N=67;else if(71==(0|N))N=0,r=v,k=0,y=2070,g=(w=0==(0|(P=0|Me(v,0,p))))?v+p|0:P,v=w?p:P-v|0,p=O;else if(75==(0|N)){for(N=0,y=v,r=0,p=0;(k=0|f[y>>2])&&!((0|(p=0|nr(T,k)))<0|p>>>0>(g-r|0)>>>0)&&g>>>0>(r=p+r|0)>>>0;)y=y+4|0;if((0|p)<0){h=-1;break e}if(De(e,32,b,r,P),r)for(k=0;;){if(!(p=0|f[v>>2])){N=84;break r}if((0|(k=(p=0|nr(T,p))+k|0))>(0|r)){N=84;break r}if(rr(e,T,p),k>>>0>=r>>>0){N=84;break}v=v+4|0}else r=0,N=84}}while(0);if(67==(0|N))N=0,P=0!=(0|p)|(v=0!=(0|r)|0!=(0|v)),v=c-g+(1&(1^v))|0,r=P?g:l,g=l,v=P?(0|p)>(0|v)?p:v:p,p=(0|p)>-1?-65537&O:O;else if(84==(0|N)){N=0,De(e,32,b,r,8192^P),b=(0|b)>(0|r)?b:r,r=C;continue}De(e,32,b=(0|b)<(0|(P=(O=(0|v)<(0|(w=g-r|0))?w:v)+k|0))?P:b,P,p),rr(e,y,k),De(e,48,b,P,65536^p),De(e,48,O,w,0),rr(e,r,w),De(e,32,b,P,8192^p),r=C}else b=0,r=C}}e:do{if(87==(0|N)&&!e)if(R){for(h=1;r=0|f[o+(h<<2)>>2];)if(ie(n+(h<<3)|0,r,i),(0|(h=h+1|0))>=10){h=1;break e}for(;;){if(0|f[o+(h<<2)>>2]){h=-1;break e}if((0|(h=h+1|0))>=10){h=1;break}}}else h=0}while(0);return m=A,0|h}function X(e,r){r|=0;var i,n,o,a,u,l,s,d,_,E,T,M,A,h,b,p=0,S=0,v=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0;if(b=m,m=m+704|0,A=b+144|0,M=b+128|0,T=b+112|0,E=b+96|0,_=b+80|0,d=b+64|0,s=b+48|0,h=b+32|0,i=b+16|0,y=b,o=b+184|0,P=b+160|0,!(a=0|function(e,r){e|=0;var i,n,t,o,a=0,u=0,l=0,s=0;if(o=m,m=m+528|0,n=o,i=o+16|0,!(r=r|0))return m=o,0|(s=0);if(r>>>0<=16)return s=0|Te(e,r),m=o,0|s;if(t=0|Te(e,r+-16|0),(0|(r=0|f[(s=e+20|0)>>2]))<16){u=e+4|0,l=e+8|0,a=e+16|0;do{(0|(e=0|f[u>>2]))==(0|f[l>>2])?e=0:(f[u>>2]=e+1,e=0|c[e>>0]),f[s>>2]=r=r+8|0,(0|r)>=33&&(f[n>>2]=866,f[n+4>>2]=3208,f[n+8>>2]=1366,We(i,812,n),Le(i),r=0|f[s>>2]),f[a>>2]=e=e<<32-r|f[a>>2]}while((0|r)<16)}else a=e=e+16|0,e=0|f[e>>2];return f[a>>2]=e<<16,f[s>>2]=r+-16,m=o,0|(s=e>>>16|t<<16)}(e|=0,14)))return function(e){var r,i,n,o,a,u=0;a=m,m=m+544|0,o=a+16|0,i=a,n=a+32|0,f[(e=e|0)>>2]=0,0|(r=0|f[(u=e+4|0)>>2])&&(7&r?(f[i>>2]=866,f[i+4>>2]=2506,f[i+8>>2]=1232,We(n,812,i),Le(n)):Oe(r,0,0,1,0),f[u>>2]=0,f[e+8>>2]=0,f[e+12>>2]=0);if(t[e+16>>0]=0,!(u=0|f[(e=e+20|0)>>2]))return void(m=a);_e(u),7&u?(f[o>>2]=866,f[o+4>>2]=2506,f[o+8>>2]=1232,We(n,812,o),Le(n)):Oe(u,0,0,1,0);f[e>>2]=0,m=a}(r),m=b,0|(P=1);if(u=r+4|0,(0|(p=0|f[(l=r+8|0)>>2]))!=(0|a)){if(p>>>0<=a>>>0){do{if((0|f[r+12>>2])>>>0<a>>>0){if(0|te(u,a,(p+1|0)==(0|a),1,0)){p=0|f[l>>2];break}return t[r+16>>0]=1,m=b,0|(P=0)}}while(0);ke((0|f[u>>2])+p|0,0,a-p|0)}f[l>>2]=a}if(ke(0|f[u>>2],0,0|a),(0|(p=0|f[(n=e+20|0)>>2]))<5){k=e+4|0,R=e+8|0,v=e+16|0;do{(0|(S=0|f[k>>2]))==(0|f[R>>2])?S=0:(f[k>>2]=S+1,S=0|c[S>>0]),f[n>>2]=p=p+8|0,(0|p)>=33&&(f[y>>2]=866,f[y+4>>2]=3208,f[y+8>>2]=1366,We(o,812,y),Le(o),p=0|f[n>>2]),f[v>>2]=S=S<<32-p|f[v>>2]}while((0|p)<5)}else v=S=e+16|0,S=0|f[S>>2];if(O=S>>>27,f[v>>2]=S<<5,f[n>>2]=p+-5,(O+-1|0)>>>0>20)return m=b,0|(P=0);f[P+20>>2]=0,f[P>>2]=0,f[P+4>>2]=0,f[P+8>>2]=0,f[P+12>>2]=0,t[P+16>>0]=0,p=P+4|0,S=P+8|0;e:do{if(0|te(p,21,0,1,0)){ke((g=0|f[p>>2])+(k=0|f[S>>2])|0,0,21-k|0),f[S>>2]=21,k=e+4|0,R=e+8|0,y=e+16|0,v=0;do{if((0|(p=0|f[n>>2]))<3)do{(0|(S=0|f[k>>2]))==(0|f[R>>2])?S=0:(f[k>>2]=S+1,S=0|c[S>>0]),f[n>>2]=p=p+8|0,(0|p)>=33&&(f[i>>2]=866,f[i+4>>2]=3208,f[i+8>>2]=1366,We(o,812,i),Le(o),p=0|f[n>>2]),f[y>>2]=S=S<<32-p|f[y>>2]}while((0|p)<3);else S=0|f[y>>2];f[y>>2]=S<<3,f[n>>2]=p+-3,t[g+(0|c[1327+v>>0])>>0]=S>>>29,v=v+1|0}while((0|v)!=(0|O));if(0|se(P)){y=e+4|0,g=e+8|0,O=e+16|0,p=0;r:do{R=a-p|0,v=0|ee(e,P);i:do{if(v>>>0<17)(0|f[l>>2])>>>0<=p>>>0&&(f[h>>2]=866,f[h+4>>2]=910,f[h+8>>2]=1497,We(o,812,h),Le(o)),t[(0|f[u>>2])+p>>0]=v,p=p+1|0;else switch(0|v){case 17:if((0|(S=0|f[n>>2]))<3)do{(0|(v=0|f[y>>2]))==(0|f[g>>2])?v=0:(f[y>>2]=v+1,v=0|c[v>>0]),f[n>>2]=S=S+8|0,(0|S)>=33&&(f[s>>2]=866,f[s+4>>2]=3208,f[s+8>>2]=1366,We(o,812,s),Le(o),S=0|f[n>>2]),f[O>>2]=v=v<<32-S|f[O>>2]}while((0|S)<3);else v=0|f[O>>2];if(f[O>>2]=v<<3,f[n>>2]=S+-3,S=(v=3+(v>>>29)|0)>>>0>R>>>0){p=0;break e}p=(S?0:v)+p|0;break i;case 18:if((0|(S=0|f[n>>2]))<7)do{(0|(v=0|f[y>>2]))==(0|f[g>>2])?v=0:(f[y>>2]=v+1,v=0|c[v>>0]),f[n>>2]=S=S+8|0,(0|S)>=33&&(f[d>>2]=866,f[d+4>>2]=3208,f[d+8>>2]=1366,We(o,812,d),Le(o),S=0|f[n>>2]),f[O>>2]=v=v<<32-S|f[O>>2]}while((0|S)<7);else v=0|f[O>>2];if(f[O>>2]=v<<7,f[n>>2]=S+-7,S=(v=11+(v>>>25)|0)>>>0>R>>>0){p=0;break e}p=(S?0:v)+p|0;break i;default:if((v+-19|0)>>>0>=2){w=81;break r}if(S=0|f[n>>2],19==(0|v)){if((0|S)<2)for(v=S;(0|(S=0|f[y>>2]))==(0|f[g>>2])?k=0:(f[y>>2]=S+1,k=0|c[S>>0]),f[n>>2]=S=v+8|0,(0|S)>=33&&(f[_>>2]=866,f[_+4>>2]=3208,f[_+8>>2]=1366,We(o,812,_),Le(o),S=0|f[n>>2]),f[O>>2]=v=k<<32-S|f[O>>2],(0|S)<2;)v=S;else v=0|f[O>>2];f[O>>2]=v<<2,v>>>=30,k=3,S=S+-2|0}else{if((0|S)<6)do{(0|(v=0|f[y>>2]))==(0|f[g>>2])?v=0:(f[y>>2]=v+1,v=0|c[v>>0]),f[n>>2]=S=S+8|0,(0|S)>=33&&(f[E>>2]=866,f[E+4>>2]=3208,f[E+8>>2]=1366,We(o,812,E),Le(o),S=0|f[n>>2]),f[O>>2]=v=v<<32-S|f[O>>2]}while((0|S)<6);else v=0|f[O>>2];f[O>>2]=v<<6,v>>>=26,k=7,S=S+-6|0}if(f[n>>2]=S,0==(0|p)|(v=v+k|0)>>>0>R>>>0){p=0;break e}if((0|f[l>>2])>>>0<=(S=p+-1|0)>>>0&&(f[T>>2]=866,f[T+4>>2]=910,f[T+8>>2]=1497,We(o,812,T),Le(o)),!((k=0|t[(0|f[u>>2])+S>>0])<<24>>24)){p=0;break e}if(p>>>0>=(S=v+p|0)>>>0)break i;do{(0|f[l>>2])>>>0<=p>>>0&&(f[M>>2]=866,f[M+4>>2]=910,f[M+8>>2]=1497,We(o,812,M),Le(o)),t[(0|f[u>>2])+p>>0]=k,p=p+1|0}while((0|p)!=(0|S));p=S}}while(0)}while(a>>>0>p>>>0);if(81==(0|w)){f[A>>2]=866,f[A+4>>2]=3149,f[A+8>>2]=1348,We(o,812,A),Le(o),p=0;break}p=(0|a)==(0|p)?0|se(r):0}else p=0}else t[P+16>>0]=1,p=0}while(0);return pe(P),m=b,0|(P=p)}function G(e,r,i,n){i|=0;var o,u,l,s,_,E,T=0,M=0,A=0,h=0,b=0,p=0,S=0,v=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0,C=0,N=0,I=0,L=0,D=0,F=0,U=0;if(E=m,m=m+880|0,F=E+144|0,_=E+128|0,s=E+112|0,l=E+96|0,L=E+80|0,w=E+64|0,g=E+48|0,O=E+32|0,v=E+16|0,S=E,o=E+360|0,u=E+296|0,U=E+224|0,y=E+156|0,0==(0|(r|=0))|(n|=0)>>>0>11)return m=E,0|(U=0);f[(e|=0)>>2]=r,M=(T=U)+68|0;do{f[T>>2]=0,T=T+4|0}while((0|T)<(0|M));T=0;do{M=U+((255&(D=0|t[i+T>>0]))<<2)|0,D<<24>>24&&(f[M>>2]=1+(0|f[M>>2])),T=T+1|0}while((0|T)!=(0|r));for(M=0,A=0,h=0,b=-1,p=1;(T=0|f[U+(p<<2)>>2])?(f[u+((k=p+-1|0)<<2)>>2]=M,f[e+28+(k<<2)>>2]=1+((M=T+M|0)+-1<<(D=16-p|0)|(1<<D)-1),f[e+96+(k<<2)>>2]=A,f[y+(p<<2)>>2]=A,k=T+A|0,h=h>>>0>p>>>0?h:p,b=b>>>0<p>>>0?b:p):(f[e+28+(p+-1<<2)>>2]=0,k=A),17!=(0|(p=p+1|0));)M<<=1,A=k;f[e+4>>2]=k,M=e+172|0;do{if(k>>>0>(0|f[M>>2])>>>0){(T=k+-1|0)&k?(T|=T>>>16,T|=T>>>8,T|=T>>>4,T=(T=1+((T|=T>>>2)>>>1|T)|0)>>>0>r>>>0?r:T):T=k,f[M>>2]=T,T=0|f[(A=e+176|0)>>2];do{if(0|T){if(D=0|f[T+-4>>2],T=T+-8|0,0!=(0|D)&&(0|D)==(0|~f[T>>2])||(f[S>>2]=866,f[S+4>>2]=651,f[S+8>>2]=1579,We(o,812,S),Le(o)),7&T){f[v>>2]=866,f[v+4>>2]=2506,f[v+8>>2]=1232,We(o,812,v),Le(o);break}Oe(T,0,0,1,0);break}}while(0);if(M=0|Se(8+((T=0|(T=0|f[M>>2])?T:1)<<1)|0,0)){f[M+4>>2]=T,f[M>>2]=~T,f[A>>2]=M+8,R=24;break}f[A>>2]=0,n=0;break}R=24}while(0);e:do{if(24==(0|R)){t[(D=e+24|0)>>0]=b,t[e+25>>0]=h,A=e+176|0,M=0;do{T=255&(I=0|t[i+M>>0]),I<<24>>24&&(0|f[U+(T<<2)>>2]||(f[O>>2]=866,f[O+4>>2]=2276,f[O+8>>2]=977,We(o,812,O),Le(o)),f[(I=y+(T<<2)|0)>>2]=(T=0|f[I>>2])+1,T>>>0>=k>>>0&&(f[g>>2]=866,f[g+4>>2]=2280,f[g+8>>2]=990,We(o,812,g),Le(o)),a[(0|f[A>>2])+(T<<1)>>1]=M),M=M+1|0}while((0|M)!=(0|r));if(f[(I=e+8|0)>>2]=N=(0|c[D>>0])>>>0<n>>>0?n:0,C=0!=(0|N)){P=1<<N,T=e+164|0;do{if(P>>>0>(0|f[T>>2])>>>0){f[T>>2]=P,T=0|f[(A=e+168|0)>>2];do{if(0|T){if(O=0|f[T+-4>>2],T=T+-8|0,0!=(0|O)&&(0|O)==(0|~f[T>>2])||(f[w>>2]=866,f[w+4>>2]=651,f[w+8>>2]=1579,We(o,812,w),Le(o)),7&T){f[L>>2]=866,f[L+4>>2]=2506,f[L+8>>2]=1232,We(o,812,L),Le(o);break}Oe(T,0,0,1,0);break}}while(0);if(M=0|Se((T=P<<2)+8|0,0)){L=M+8|0,f[M+4>>2]=P,f[M>>2]=~P,f[A>>2]=L,M=L;break}f[A>>2]=0,n=0;break e}T=P<<2,A=M=e+168|0,M=0|f[M>>2]}while(0);ke(0|M,-1,0|T),g=e+176|0,y=1;do{if(0|f[U+(y<<2)>>2]&&(w=1<<(O=N-y|0),M=0|f[u+((T=y+-1|0)<<2)>>2],T>>>0>=16&&(f[l>>2]=866,f[l+4>>2]=1960,f[l+8>>2]=1453,We(o,812,l),Le(o)),M>>>0<=(r=0==(0|(r=0|f[e+28+(T<<2)>>2]))?-1:(r+-1|0)>>>(16-y|0))>>>0)){k=(0|f[e+96+(T<<2)>>2])-M|0,R=y<<16;do{(0|c[i+(T=0|d[(0|f[g>>2])+(k+M<<1)>>1])>>0])!=(0|y)&&(f[s>>2]=866,f[s+4>>2]=2322,f[s+8>>2]=1019,We(o,812,s),Le(o)),v=M<<O,p=T|R,b=0;do{(S=b+v|0)>>>0>=P>>>0&&(f[_>>2]=866,f[_+4>>2]=2328,f[_+8>>2]=1053,We(o,812,_),Le(o)),-1!=(0|f[(T=0|f[A>>2])+(S<<2)>>2])&&(f[F>>2]=866,f[F+4>>2]=2330,f[F+8>>2]=1076,We(o,812,F),Le(o),T=0|f[A>>2]),f[T+(S<<2)>>2]=p,b=b+1|0}while(b>>>0<w>>>0);M=M+1|0}while(M>>>0<=r>>>0)}y=y+1|0}while(N>>>0>=y>>>0)}f[(T=e+96|0)>>2]=(0|f[T>>2])-(0|f[u>>2]),f[(T=e+100|0)>>2]=(0|f[T>>2])-(0|f[u+4>>2]),f[(T=e+104|0)>>2]=(0|f[T>>2])-(0|f[u+8>>2]),f[(T=e+108|0)>>2]=(0|f[T>>2])-(0|f[u+12>>2]),f[(T=e+112|0)>>2]=(0|f[T>>2])-(0|f[u+16>>2]),f[(T=e+116|0)>>2]=(0|f[T>>2])-(0|f[u+20>>2]),f[(T=e+120|0)>>2]=(0|f[T>>2])-(0|f[u+24>>2]),f[(T=e+124|0)>>2]=(0|f[T>>2])-(0|f[u+28>>2]),f[(T=e+128|0)>>2]=(0|f[T>>2])-(0|f[u+32>>2]),f[(T=e+132|0)>>2]=(0|f[T>>2])-(0|f[u+36>>2]),f[(T=e+136|0)>>2]=(0|f[T>>2])-(0|f[u+40>>2]),f[(T=e+140|0)>>2]=(0|f[T>>2])-(0|f[u+44>>2]),f[(T=e+144|0)>>2]=(0|f[T>>2])-(0|f[u+48>>2]),f[(T=e+148|0)>>2]=(0|f[T>>2])-(0|f[u+52>>2]),f[(T=e+152|0)>>2]=(0|f[T>>2])-(0|f[u+56>>2]),f[(T=e+156|0)>>2]=(0|f[T>>2])-(0|f[u+60>>2]),f[(T=e+16|0)>>2]=0,f[(M=e+20|0)>>2]=c[D>>0];r:do{if(C){do{if(!n)break r;F=n,n=n+-1|0}while(!(0|f[U+(F<<2)>>2]));if(f[T>>2]=f[e+28+(n<<2)>>2],f[M>>2]=n=N+1|0,n>>>0<=h>>>0){for(;!(0|f[U+(n<<2)>>2]);)if((n=n+1|0)>>>0>h>>>0)break r;f[M>>2]=n}}}while(0);f[e+92>>2]=-1,f[e+160>>2]=1048575,f[e+12>>2]=32-(0|f[I>>2]),n=1}}while(0);return m=E,0|(U=n)}function K(e,r,i,n,o,a,u,l){r|=0,i|=0;var s,_,E,T,M,A,h,b,p,S,v,k,R,y,g,O,w,P,C,N,I,L,D,F,U,H,x,B=0,Y=0,V=0,X=0,G=0,K=0,W=0,z=0,j=0,J=0,Z=0,q=0,Q=0,$=0,re=0,ie=0,ne=0,te=0,oe=0,ae=0,ue=0,fe=0,le=0,ce=0,se=0;if(x=m,m=m+640|0,F=x+80|0,D=x+64|0,L=x+48|0,H=x+32|0,U=x+16|0,I=x,C=x+128|0,N=x+112|0,M=x+96|0,h=0|f[(A=(e|=0)+272|0)>>2],b=(0|c[(se=0|f[e+88>>2])+63>>0])<<8|0|c[se+64>>0],p=255&(se=0|t[se+17>>0]),!(se<<24>>24))return m=x,1;S=0==(0|(l|=0)),k=(v=(u|=0)+-1|0)<<5,R=l+-1|0,y=(n|=0)<<1,g=e+92|0,O=e+116|0,w=e+164|0,P=e+268|0,se=e+212|0,T=0==(1&(o|=0)|0),E=0==(1&(a|=0)|0),_=e+288|0,s=e+284|0,ce=0,e=0,a=0,o=0,i=0,B=1;do{if(!S)for(fe=0|f[r+(ce<<2)>>2],le=0;;){if(V=0==(0|(ue=1&le)),ae=(ue<<6^64)-32|0,ue=(ue<<1^2)-1|0,(0|(Y=V?0:v))!=(0|(te=V?u:-1)))for(oe=E|(0|le)!=(0|R),ne=V?fe:fe+k|0;;){1==(0|B)&&(B=512|ee(g,O)),ie=7&B,B>>>=3,X=0|c[1539+ie>>0],V=0;do{Q=(0|ee(g,w))+i|0,(0|f[A>>2])>>>0<=(i=(re=($=Q-h|0)>>31)&Q|$&~re)>>>0&&(f[I>>2]=866,f[I+4>>2]=910,f[I+8>>2]=1497,We(C,812,I),Le(C)),f[N+(V<<2)>>2]=d[(0|f[P>>2])+(i<<1)>>1],V=V+1|0}while(V>>>0<X>>>0);V=0;do{Q=(0|ee(g,w))+a|0,(0|f[A>>2])>>>0<=(a=(re=($=Q-h|0)>>31)&Q|$&~re)>>>0&&(f[U>>2]=866,f[U+4>>2]=910,f[U+8>>2]=1497,We(C,812,U),Le(C)),f[M+(V<<2)>>2]=d[(0|f[P>>2])+(a<<1)>>1],V=V+1|0}while(V>>>0<X>>>0);for(re=T|(0|Y)!=(0|v),Q=0,$=ne;;){if(J=oe|0==(0|Q),Z=Q<<1,re)for(z=0,j=$;o=(o=(W=(q=(0|ee(g,se))+o|0)-b|0)>>31)&q|W&~o,e=(e=(q=(W=(0|ee(g,se))+e|0)-b|0)>>31)&W|q&~e,J&&(W=0|c[z+Z+(1547+(ie<<2))>>0],(V=0|f[_>>2])>>>0<=(X=3*o|0)>>>0&&(f[H>>2]=866,f[H+4>>2]=910,f[H+8>>2]=1497,We(C,812,H),Le(C),V=0|f[_>>2]),X=(G=0|f[s>>2])+(X<<1)|0,V>>>0>(K=3*e|0)>>>0?V=G:(f[L>>2]=866,f[L+4>>2]=910,f[L+8>>2]=1497,We(C,812,L),Le(C),V=0|f[s>>2]),q=V+(K<<1)|0,f[j>>2]=(0|d[X>>1])<<16|f[N+(W<<2)>>2],f[j+4>>2]=(0|d[X+4>>1])<<16|0|d[X+2>>1],f[j+8>>2]=(0|d[q>>1])<<16|f[M+(W<<2)>>2],f[j+12>>2]=(0|d[q+4>>1])<<16|0|d[q+2>>1]),2!=(0|(z=z+1|0));)j=j+16|0;else for(q=1^J,J=1547+(ie<<2)+Z|0,z=0,j=$;o=(o=(W=(Z=(0|ee(g,se))+o|0)-b|0)>>31)&Z|W&~o,e=(e=(Z=(W=(0|ee(g,se))+e|0)-b|0)>>31)&W|Z&~e,0!=(0|z)|q||(W=0|c[J>>0],(V=0|f[_>>2])>>>0<=(X=3*o|0)>>>0&&(f[D>>2]=866,f[D+4>>2]=910,f[D+8>>2]=1497,We(C,812,D),Le(C),V=0|f[_>>2]),X=(G=0|f[s>>2])+(X<<1)|0,V>>>0>(K=3*e|0)>>>0?V=G:(f[F>>2]=866,f[F+4>>2]=910,f[F+8>>2]=1497,We(C,812,F),Le(C),V=0|f[s>>2]),Z=V+(K<<1)|0,f[j>>2]=(0|d[X>>1])<<16|f[N+(W<<2)>>2],f[j+4>>2]=(0|d[X+4>>1])<<16|0|d[X+2>>1],f[j+8>>2]=(0|d[Z>>1])<<16|f[M+(W<<2)>>2],f[j+12>>2]=(0|d[Z+4>>1])<<16|0|d[Z+2>>1]),2!=(0|(z=z+1|0));)j=j+16|0;if(2==(0|(Q=Q+1|0)))break;$=$+n|0}if((0|(Y=ue+Y|0))==(0|te))break;ne=ne+ae|0}if((0|(le=le+1|0))==(0|l))break;fe=fe+y|0}ce=ce+1|0}while((0|ce)!=(0|p));return m=x,1}function W(e){var r=0,i=0,n=0,t=0,o=0,a=0,u=0,l=0;if(e|=0){t=0|f[1148],l=(i=e+-8|0)+(r=-8&(e=0|f[e+-4>>2]))|0;do{if(1&e)u=i,a=i;else{if(!(3&e))return;if(o=(n=0|f[i>>2])+r|0,(a=i+(0-n)|0)>>>0<t>>>0)return;if((0|a)==(0|f[1149])){if(3!=(3&(r=0|f[(e=l+4|0)>>2])|0)){u=a,r=o;break}return f[1146]=o,f[e>>2]=-2&r,f[a+4>>2]=1|o,void(f[a+o>>2]=o)}if(i=n>>>3,n>>>0<256){if((0|(r=0|f[a+12>>2]))==(0|(e=0|f[a+8>>2]))){f[1144]=f[1144]&~(1<<i),u=a,r=o;break}f[e+12>>2]=r,f[r+8>>2]=e,u=a,r=o;break}t=0|f[a+24>>2],e=0|f[a+12>>2];do{if((0|e)==(0|a)){if(!(e=0|f[(r=(i=a+16|0)+4|0)>>2])){if(!(e=0|f[i>>2])){e=0;break}r=i}for(;;)if(0|(n=0|f[(i=e+20|0)>>2]))e=n,r=i;else{if(!(n=0|f[(i=e+16|0)>>2]))break;e=n,r=i}f[r>>2]=0}else f[(u=0|f[a+8>>2])+12>>2]=e,f[e+8>>2]=u}while(0);if(t){if((0|a)==(0|f[(i=4880+((r=0|f[a+28>>2])<<2)|0)>>2])){if(f[i>>2]=e,!e){f[1145]=f[1145]&~(1<<r),u=a,r=o;break}}else if(f[t+16+(((0|f[t+16>>2])!=(0|a)&1)<<2)>>2]=e,!e){u=a,r=o;break}f[e+24>>2]=t,0|(i=0|f[(r=a+16|0)>>2])&&(f[e+16>>2]=i,f[i+24>>2]=e),(r=0|f[r+4>>2])?(f[e+20>>2]=r,f[r+24>>2]=e,u=a,r=o):(u=a,r=o)}else u=a,r=o}}while(0);if(!(a>>>0>=l>>>0)&&1&(n=0|f[(e=l+4|0)>>2])){if(2&n)f[e>>2]=-2&n,f[u+4>>2]=1|r,f[a+r>>2]=r,t=r;else{if(e=0|f[1149],(0|l)==(0|f[1150])){if(f[1147]=l=(0|f[1147])+r|0,f[1150]=u,f[u+4>>2]=1|l,(0|u)!=(0|e))return;return f[1149]=0,void(f[1146]=0)}if((0|l)==(0|e))return f[1146]=l=(0|f[1146])+r|0,f[1149]=a,f[u+4>>2]=1|l,void(f[a+l>>2]=l);t=(-8&n)+r|0,i=n>>>3;do{if(n>>>0<256){if((0|(e=0|f[l+12>>2]))==(0|(r=0|f[l+8>>2]))){f[1144]=f[1144]&~(1<<i);break}f[r+12>>2]=e,f[e+8>>2]=r;break}o=0|f[l+24>>2],e=0|f[l+12>>2];do{if((0|e)==(0|l)){if(!(e=0|f[(r=(i=l+16|0)+4|0)>>2])){if(!(e=0|f[i>>2])){i=0;break}r=i}for(;;)if(0|(n=0|f[(i=e+20|0)>>2]))e=n,r=i;else{if(!(n=0|f[(i=e+16|0)>>2]))break;e=n,r=i}f[r>>2]=0,i=e}else f[(i=0|f[l+8>>2])+12>>2]=e,f[e+8>>2]=i,i=e}while(0);if(0|o){if((0|l)==(0|f[(r=4880+((e=0|f[l+28>>2])<<2)|0)>>2])){if(f[r>>2]=i,!i){f[1145]=f[1145]&~(1<<e);break}}else if(f[o+16+(((0|f[o+16>>2])!=(0|l)&1)<<2)>>2]=i,!i)break;f[i+24>>2]=o,0|(r=0|f[(e=l+16|0)>>2])&&(f[i+16>>2]=r,f[r+24>>2]=i),0|(e=0|f[e+4>>2])&&(f[i+20>>2]=e,f[e+24>>2]=i)}}while(0);if(f[u+4>>2]=1|t,f[a+t>>2]=t,(0|u)==(0|f[1149]))return void(f[1146]=t)}if(e=t>>>3,t>>>0<256)return i=4616+(e<<1<<2)|0,(r=0|f[1144])&(e=1<<e)?e=0|f[(r=i+8|0)>>2]:(f[1144]=r|e,e=i,r=i+8|0),f[r>>2]=u,f[e+12>>2]=u,f[u+8>>2]=e,void(f[u+12>>2]=i);n=4880+((e=(e=t>>>8)?t>>>0>16777215?31:t>>>((e=14-((o=((l=e<<(a=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(e=((l<<=o)+245760|0)>>>16&2))+(l<<e>>>15)|0)+7|0)&1|e<<1:0)<<2)|0,f[u+28>>2]=e,f[u+20>>2]=0,f[u+16>>2]=0,r=0|f[1145],i=1<<e;do{if(r&i){for(r=t<<(31==(0|e)?0:25-(e>>>1)|0),i=0|f[n>>2];;){if((-8&f[i+4>>2]|0)==(0|t)){e=73;break}if(!(e=0|f[(n=i+16+(r>>>31<<2)|0)>>2])){e=72;break}r<<=1,i=e}if(72==(0|e)){f[n>>2]=u,f[u+24>>2]=i,f[u+12>>2]=u,f[u+8>>2]=u;break}if(73==(0|e)){f[(l=0|f[(a=i+8|0)>>2])+12>>2]=u,f[a>>2]=u,f[u+8>>2]=l,f[u+12>>2]=i,f[u+24>>2]=0;break}}else f[1145]=r|i,f[n>>2]=u,f[u+24>>2]=n,f[u+12>>2]=u,f[u+8>>2]=u}while(0);if(f[1152]=l=(0|f[1152])-1|0,!l){for(e=5032;e=0|f[e>>2];)e=e+8|0;f[1152]=-1}}}}function z(e,r,i,n,o,a,u,l){r|=0,i|=0;var s,_,E,T,M,A,h,b,p,S,v,k,R,y,g,O,w,P,C,N,I,L,D,F,U,H,x,B,Y,V,X,G,K,W,z,j=0,J=0,Z=0,q=0,Q=0,$=0,re=0,ie=0,ne=0,te=0,oe=0,ae=0,ue=0,fe=0,le=0,ce=0,se=0,de=0,_e=0,Ee=0,Te=0,Me=0;if(z=m,m=m+640|0,G=z+80|0,X=z+64|0,V=z+48|0,W=z+32|0,K=z+16|0,Y=z,x=z+128|0,B=z+112|0,A=z+96|0,b=0|f[(h=(e|=0)+240|0)>>2],S=0|f[(p=e+256|0)>>2],k=0|f[(v=e+272|0)>>2],R=(0|c[(Me=0|f[e+88>>2])+63>>0])<<8|0|c[Me+64>>0],y=255&(Me=0|t[Me+17>>0]),!(Me<<24>>24))return m=z,1;g=0==(0|(l|=0)),w=(O=(u|=0)+-1|0)<<5,P=l+-1|0,C=(n|=0)<<1,N=e+92|0,I=e+116|0,L=e+164|0,D=e+268|0,F=e+140|0,U=e+236|0,H=e+212|0,Me=e+188|0,M=0==(1&(o|=0)|0),T=0==(1&(a|=0)|0),_=e+288|0,E=e+284|0,s=e+252|0,Te=0,e=0,a=0,o=0,i=0,j=1;do{if(!g)for(_e=0|f[r+(Te<<2)>>2],Ee=0;;){if(Z=0==(0|(de=1&Ee)),se=(de<<6^64)-32|0,de=(de<<1^2)-1|0,(0|(J=Z?0:O))!=(0|(le=Z?u:-1)))for(ce=T|(0|Ee)!=(0|P),fe=Z?_e:_e+w|0;;){1==(0|j)&&(j=512|ee(N,I)),ue=7&j,j>>>=3,q=0|c[1539+ue>>0],Z=0;do{te=(0|ee(N,L))+a|0,(0|f[v>>2])>>>0<=(a=(ae=(oe=te-k|0)>>31)&te|oe&~ae)>>>0&&(f[Y>>2]=866,f[Y+4>>2]=910,f[Y+8>>2]=1497,We(x,812,Y),Le(x)),f[A+(Z<<2)>>2]=d[(0|f[D>>2])+(a<<1)>>1],Z=Z+1|0}while(Z>>>0<q>>>0);Z=0;do{te=(0|ee(N,F))+i|0,(0|f[h>>2])>>>0<=(i=(ae=(oe=te-b|0)>>31)&te|oe&~ae)>>>0&&(f[K>>2]=866,f[K+4>>2]=910,f[K+8>>2]=1497,We(x,812,K),Le(x)),f[B+(Z<<2)>>2]=f[(0|f[U>>2])+(i<<2)>>2],Z=Z+1|0}while(Z>>>0<q>>>0);for(ae=M|(0|J)!=(0|O),te=0,oe=fe;;){if(re=ce|0==(0|te),ie=te<<1,ae)for(Q=0,$=oe;e=(e=(q=(ne=(0|ee(N,H))+e|0)-R|0)>>31)&ne|q&~e,o=(o=(ne=(q=(0|ee(N,Me))+o|0)-S|0)>>31)&q|ne&~o,re&&(Z=0|c[Q+ie+(1547+(ue<<2))>>0],(0|f[_>>2])>>>0<=(q=3*e|0)>>>0&&(f[W>>2]=866,f[W+4>>2]=910,f[W+8>>2]=1497,We(x,812,W),Le(x)),f[$>>2]=(0|d[(ne=(0|f[E>>2])+(q<<1)|0)>>1])<<16|f[A+(Z<<2)>>2],f[$+4>>2]=(0|d[ne+4>>1])<<16|0|d[ne+2>>1],f[$+8>>2]=f[B+(Z<<2)>>2],(0|f[p>>2])>>>0<=o>>>0&&(f[V>>2]=866,f[V+4>>2]=910,f[V+8>>2]=1497,We(x,812,V),Le(x)),f[$+12>>2]=f[(0|f[s>>2])+(o<<2)>>2]),2!=(0|(Q=Q+1|0));)$=$+16|0;else for(ne=1^re,re=1547+(ue<<2)+ie|0,Q=0,$=oe;e=(e=(q=(ie=(0|ee(N,H))+e|0)-R|0)>>31)&ie|q&~e,o=(o=(ie=(q=(0|ee(N,Me))+o|0)-S|0)>>31)&q|ie&~o,0!=(0|Q)|ne||(Z=0|c[re>>0],(0|f[_>>2])>>>0<=(q=3*e|0)>>>0&&(f[X>>2]=866,f[X+4>>2]=910,f[X+8>>2]=1497,We(x,812,X),Le(x)),f[$>>2]=(0|d[(ie=(0|f[E>>2])+(q<<1)|0)>>1])<<16|f[A+(Z<<2)>>2],f[$+4>>2]=(0|d[ie+4>>1])<<16|0|d[ie+2>>1],f[$+8>>2]=f[B+(Z<<2)>>2],(0|f[p>>2])>>>0<=o>>>0&&(f[G>>2]=866,f[G+4>>2]=910,f[G+8>>2]=1497,We(x,812,G),Le(x)),f[$+12>>2]=f[(0|f[s>>2])+(o<<2)>>2]),2!=(0|(Q=Q+1|0));)$=$+16|0;if(2==(0|(te=te+1|0)))break;oe=oe+n|0}if((0|(J=de+J|0))==(0|le))break;fe=fe+se|0}if((0|(Ee=Ee+1|0))==(0|l))break;_e=_e+C|0}Te=Te+1|0}while((0|Te)!=(0|y));return m=z,1}function j(e,r){var i=0,n=0,t=0,o=0,a=0,u=0,l=0;l=(e|=0)+(r|=0)|0,i=0|f[e+4>>2];do{if(1&i)u=e,i=r;else{if(!(3&i))return;if(a=(n=0|f[e>>2])+r|0,(0|(o=e+(0-n)|0))==(0|f[1149])){if(3!=(3&(i=0|f[(e=l+4|0)>>2])|0)){u=o,i=a;break}return f[1146]=a,f[e>>2]=-2&i,f[o+4>>2]=1|a,void(f[o+a>>2]=a)}if(r=n>>>3,n>>>0<256){if((0|(i=0|f[o+12>>2]))==(0|(e=0|f[o+8>>2]))){f[1144]=f[1144]&~(1<<r),u=o,i=a;break}f[e+12>>2]=i,f[i+8>>2]=e,u=o,i=a;break}t=0|f[o+24>>2],e=0|f[o+12>>2];do{if((0|e)==(0|o)){if(!(e=0|f[(i=(r=o+16|0)+4|0)>>2])){if(!(e=0|f[r>>2])){e=0;break}i=r}for(;;)if(0|(n=0|f[(r=e+20|0)>>2]))e=n,i=r;else{if(!(n=0|f[(r=e+16|0)>>2]))break;e=n,i=r}f[i>>2]=0}else f[(u=0|f[o+8>>2])+12>>2]=e,f[e+8>>2]=u}while(0);if(t){if((0|o)==(0|f[(r=4880+((i=0|f[o+28>>2])<<2)|0)>>2])){if(f[r>>2]=e,!e){f[1145]=f[1145]&~(1<<i),u=o,i=a;break}}else if(f[t+16+(((0|f[t+16>>2])!=(0|o)&1)<<2)>>2]=e,!e){u=o,i=a;break}f[e+24>>2]=t,0|(r=0|f[(i=o+16|0)>>2])&&(f[e+16>>2]=r,f[r+24>>2]=e),(i=0|f[i+4>>2])?(f[e+20>>2]=i,f[i+24>>2]=e,u=o,i=a):(u=o,i=a)}else u=o,i=a}}while(0);if(2&(n=0|f[(e=l+4|0)>>2]))f[e>>2]=-2&n,f[u+4>>2]=1|i,f[u+i>>2]=i;else{if(e=0|f[1149],(0|l)==(0|f[1150])){if(f[1147]=l=(0|f[1147])+i|0,f[1150]=u,f[u+4>>2]=1|l,(0|u)!=(0|e))return;return f[1149]=0,void(f[1146]=0)}if((0|l)==(0|e))return f[1146]=l=(0|f[1146])+i|0,f[1149]=u,f[u+4>>2]=1|l,void(f[u+l>>2]=l);o=(-8&n)+i|0,r=n>>>3;do{if(n>>>0<256){if((0|(e=0|f[l+12>>2]))==(0|(i=0|f[l+8>>2]))){f[1144]=f[1144]&~(1<<r);break}f[i+12>>2]=e,f[e+8>>2]=i;break}t=0|f[l+24>>2],e=0|f[l+12>>2];do{if((0|e)==(0|l)){if(!(e=0|f[(i=(r=l+16|0)+4|0)>>2])){if(!(e=0|f[r>>2])){r=0;break}i=r}for(;;)if(0|(n=0|f[(r=e+20|0)>>2]))e=n,i=r;else{if(!(n=0|f[(r=e+16|0)>>2]))break;e=n,i=r}f[i>>2]=0,r=e}else f[(r=0|f[l+8>>2])+12>>2]=e,f[e+8>>2]=r,r=e}while(0);if(0|t){if((0|l)==(0|f[(i=4880+((e=0|f[l+28>>2])<<2)|0)>>2])){if(f[i>>2]=r,!r){f[1145]=f[1145]&~(1<<e);break}}else if(f[t+16+(((0|f[t+16>>2])!=(0|l)&1)<<2)>>2]=r,!r)break;f[r+24>>2]=t,0|(i=0|f[(e=l+16|0)>>2])&&(f[r+16>>2]=i,f[i+24>>2]=r),0|(e=0|f[e+4>>2])&&(f[r+20>>2]=e,f[e+24>>2]=r)}}while(0);if(f[u+4>>2]=1|o,f[u+o>>2]=o,(0|u)==(0|f[1149]))return void(f[1146]=o);i=o}if(e=i>>>3,i>>>0<256)return r=4616+(e<<1<<2)|0,(i=0|f[1144])&(e=1<<e)?e=0|f[(i=r+8|0)>>2]:(f[1144]=i|e,e=r,i=r+8|0),f[i>>2]=u,f[e+12>>2]=u,f[u+8>>2]=e,void(f[u+12>>2]=r);if(t=4880+((e=(e=i>>>8)?i>>>0>16777215?31:i>>>((e=14-((o=((l=e<<(a=(e+1048320|0)>>>16&8))+520192|0)>>>16&4)|a|(e=((l<<=o)+245760|0)>>>16&2))+(l<<e>>>15)|0)+7|0)&1|e<<1:0)<<2)|0,f[u+28>>2]=e,f[u+20>>2]=0,f[u+16>>2]=0,!((r=0|f[1145])&(n=1<<e)))return f[1145]=r|n,f[t>>2]=u,f[u+24>>2]=t,f[u+12>>2]=u,void(f[u+8>>2]=u);for(r=i<<(31==(0|e)?0:25-(e>>>1)|0),n=0|f[t>>2];;){if((-8&f[n+4>>2]|0)==(0|i)){e=69;break}if(!(e=0|f[(t=n+16+(r>>>31<<2)|0)>>2])){e=68;break}r<<=1,n=e}return 68==(0|e)?(f[t>>2]=u,f[u+24>>2]=n,f[u+12>>2]=u,void(f[u+8>>2]=u)):69==(0|e)?(f[(l=0|f[(a=n+8|0)>>2])+12>>2]=u,f[a>>2]=u,f[u+8>>2]=l,f[u+12>>2]=n,void(f[u+24>>2]=0)):void 0}function J(e){var r,i,n,o,u,l,s=0,d=0,_=0,E=0,T=0,M=0,A=0,h=0,b=0,p=0,S=0,v=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0,C=0,N=0,I=0,L=0,D=0,F=0,U=0,H=0,x=0,B=0,Y=0,V=0,G=0,K=0,W=0,z=0;if(l=m,m=m+2416|0,M=l,T=l+1904|0,K=l+1880|0,n=l+980|0,o=l+80|0,u=l+16|0,r=(0|c[(d=0|f[(e|=0)+88>>2])+63>>0])<<8|0|c[d+64>>0],s=(0|f[e+4>>2])+((0|c[d+58>>0])<<8|(0|c[d+57>>0])<<16|0|c[d+59>>0])|0,!(d=(0|c[d+61>>0])<<8|(0|c[d+60>>0])<<16|0|c[d+62>>0]))return m=l,0|(K=0);if(f[(i=e+92|0)>>2]=s,f[e+96>>2]=s,f[e+104>>2]=d,f[e+100>>2]=s+d,f[e+108>>2]=0,f[e+112>>2]=0,f[K+20>>2]=0,f[K>>2]=0,f[K+4>>2]=0,f[K+8>>2]=0,f[K+12>>2]=0,t[K+16>>0]=0,0|X(i,K)){for(s=0,d=-7,_=-7;f[n+(s<<2)>>2]=_,f[o+(s<<2)>>2]=d,E=(0|_)>6,225!=(0|(s=s+1|0));)d=(1&E)+d|0,_=E?-7:_+1|0;d=(s=u)+64|0;do{f[s>>2]=0,s=s+4|0}while((0|s)<(0|d));E=e+284|0,d=3*r|0,s=0|f[(_=e+288|0)>>2];e:do{if((0|s)==(0|d))A=13;else{if(s>>>0<=d>>>0){do{if((0|f[e+292>>2])>>>0<d>>>0){if(0|te(E,d,(s+1|0)==(0|d),2,0)){s=0|f[_>>2];break}t[e+296>>0]=1,s=0;break e}}while(0);ke((0|f[E>>2])+(s<<1)|0,0,d-s<<1|0)}f[_>>2]=d,A=13}}while(0);do{if(13==(0|A)){if(!r){f[M>>2]=866,f[M+4>>2]=910,f[M+8>>2]=1497,We(T,812,M),Le(T),s=1;break}for(B=u+48|0,Y=u+52|0,V=u+56|0,G=u+60|0,O=0,s=0|f[E>>2],d=0|f[u>>2],_=0|f[(w=u+4|0)>>2],E=0|f[(P=u+8|0)>>2],e=0|f[(C=u+12|0)>>2],T=0|f[(N=u+16|0)>>2],M=0|f[(I=u+20|0)>>2],A=0|f[(L=u+24|0)>>2],h=0|f[(D=u+28|0)>>2],b=0|f[(F=u+32|0)>>2],p=0|f[(U=u+36|0)>>2],S=0|f[(H=u+40|0)>>2],v=0|f[(x=u+44|0)>>2],k=0,R=0,y=0,g=0;z=0|ee(i,K),d=d+(0|f[n+(z<<2)>>2])&7,_=_+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),E=E+(0|f[n+(z<<2)>>2])&7,e=e+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),T=T+(0|f[n+(z<<2)>>2])&7,M=M+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),A=A+(0|f[n+(z<<2)>>2])&7,h=h+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),b=b+(0|f[n+(z<<2)>>2])&7,p=p+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),S=S+(0|f[n+(z<<2)>>2])&7,v=v+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),k=k+(0|f[n+(z<<2)>>2])&7,R=R+(0|f[o+(z<<2)>>2])&7,z=0|ee(i,K),y=y+(0|f[n+(z<<2)>>2])&7,g=g+(0|f[o+(z<<2)>>2])&7,a[s>>1]=(0|c[1445+_>>0])<<3|0|c[1445+d>>0]|(0|c[1445+E>>0])<<6|(0|c[1445+e>>0])<<9|(0|c[1445+T>>0])<<12|(z=0|c[1445+M>>0])<<15,a[s+2>>1]=(0|c[1445+A>>0])<<2|z>>>1|(0|c[1445+h>>0])<<5|(0|c[1445+b>>0])<<8|(0|c[1445+p>>0])<<11|(W=0|c[1445+S>>0])<<14,a[s+4>>1]=(0|c[1445+v>>0])<<1|W>>>2|(0|c[1445+k>>0])<<4|(0|c[1445+R>>0])<<7|(0|c[1445+y>>0])<<10|(0|c[1445+g>>0])<<13,!((O=O+1|0)>>>0>=r>>>0);)s=s+6|0;f[u>>2]=d,f[w>>2]=_,f[P>>2]=E,f[C>>2]=e,f[N>>2]=T,f[I>>2]=M,f[L>>2]=A,f[D>>2]=h,f[F>>2]=b,f[U>>2]=p,f[H>>2]=S,f[x>>2]=v,f[B>>2]=k,f[Y>>2]=R,f[V>>2]=y,f[G>>2]=g,s=1}}while(0)}else s=0;return pe(K),m=l,0|(z=s)}function Z(e){var r,i,n,o,a,u,l=0,s=0,d=0,_=0,E=0,T=0,M=0,A=0,h=0,b=0,p=0,S=0,v=0,k=0,R=0,y=0,g=0,O=0,w=0,P=0,C=0,N=0,I=0,L=0,D=0,F=0,U=0,H=0,x=0,B=0,Y=0,V=0,G=0;if(u=m,m=m+1008|0,T=u,E=u+496|0,w=u+472|0,n=u+276|0,o=u+80|0,a=u+16|0,r=(0|c[(s=0|f[(e|=0)+88>>2])+47>>0])<<8|0|c[s+48>>0],l=(0|f[e+4>>2])+((0|c[s+42>>0])<<8|(0|c[s+41>>0])<<16|0|c[s+43>>0])|0,!(s=(0|c[s+45>>0])<<8|(0|c[s+44>>0])<<16|0|c[s+46>>0]))return m=u,0|(w=0);if(f[(i=e+92|0)>>2]=l,f[e+96>>2]=l,f[e+104>>2]=s,f[e+100>>2]=l+s,f[e+108>>2]=0,f[e+112>>2]=0,f[w+20>>2]=0,f[w>>2]=0,f[w+4>>2]=0,f[w+8>>2]=0,f[w+12>>2]=0,t[w+16>>0]=0,0|X(i,w)){for(l=0,s=-3,d=-3;f[n+(l<<2)>>2]=d,f[o+(l<<2)>>2]=s,_=(0|d)>2,49!=(0|(l=l+1|0));)s=(1&_)+s|0,d=_?-3:d+1|0;s=(l=a)+64|0;do{f[l>>2]=0,l=l+4|0}while((0|l)<(0|s));d=e+252|0,l=0|f[(s=e+256|0)>>2];e:do{if((0|l)==(0|r))M=13;else{if(l>>>0<=r>>>0){do{if((0|f[e+260>>2])>>>0<r>>>0){if(0|te(d,r,(l+1|0)==(0|r),4,0)){l=0|f[s>>2];break}t[e+264>>0]=1,l=0;break e}}while(0);ke((0|f[d>>2])+(l<<2)|0,0,r-l<<2|0)}f[s>>2]=r,M=13}}while(0);do{if(13==(0|M)){if(!r){f[T>>2]=866,f[T+4>>2]=910,f[T+8>>2]=1497,We(E,812,T),Le(E),l=1;break}for(E=a+8|0,T=a+12|0,M=a+16|0,A=a+20|0,h=a+24|0,b=a+28|0,p=a+32|0,S=a+36|0,v=a+40|0,k=a+44|0,R=a+48|0,y=a+52|0,g=a+56|0,O=a+60|0,_=0,l=0|f[d>>2],s=0|f[(e=a+4|0)>>2],d=0|f[a>>2];V=0|ee(i,w),d=d+(0|f[n+(V<<2)>>2])&3,s=s+(0|f[o+(V<<2)>>2])&3,V=0|ee(i,w),f[E>>2]=G=(0|f[E>>2])+(0|f[n+(V<<2)>>2])&3,f[T>>2]=V=(0|f[T>>2])+(0|f[o+(V<<2)>>2])&3,B=0|ee(i,w),f[M>>2]=Y=(0|f[M>>2])+(0|f[n+(B<<2)>>2])&3,f[A>>2]=B=(0|f[A>>2])+(0|f[o+(B<<2)>>2])&3,H=0|ee(i,w),f[h>>2]=x=(0|f[h>>2])+(0|f[n+(H<<2)>>2])&3,f[b>>2]=H=(0|f[b>>2])+(0|f[o+(H<<2)>>2])&3,F=0|ee(i,w),f[p>>2]=U=(0|f[p>>2])+(0|f[n+(F<<2)>>2])&3,f[S>>2]=F=(0|f[S>>2])+(0|f[o+(F<<2)>>2])&3,L=0|ee(i,w),f[v>>2]=D=(0|f[v>>2])+(0|f[n+(L<<2)>>2])&3,f[k>>2]=L=(0|f[k>>2])+(0|f[o+(L<<2)>>2])&3,N=0|ee(i,w),f[R>>2]=I=(0|f[R>>2])+(0|f[n+(N<<2)>>2])&3,f[y>>2]=N=(0|f[y>>2])+(0|f[o+(N<<2)>>2])&3,P=0|ee(i,w),f[g>>2]=C=(0|f[g>>2])+(0|f[n+(P<<2)>>2])&3,f[O>>2]=P=(0|f[O>>2])+(0|f[o+(P<<2)>>2])&3,f[l>>2]=(0|c[1441+s>>0])<<2|0|c[1441+d>>0]|(0|c[1441+G>>0])<<4|(0|c[1441+V>>0])<<6|(0|c[1441+Y>>0])<<8|(0|c[1441+B>>0])<<10|(0|c[1441+x>>0])<<12|(0|c[1441+H>>0])<<14|(0|c[1441+U>>0])<<16|(0|c[1441+F>>0])<<18|(0|c[1441+D>>0])<<20|(0|c[1441+L>>0])<<22|(0|c[1441+I>>0])<<24|(0|c[1441+N>>0])<<26|(0|c[1441+C>>0])<<28|(0|c[1441+P>>0])<<30,!((_=_+1|0)>>>0>=r>>>0);)l=l+4|0;f[a>>2]=d,f[e>>2]=s,l=1}}while(0)}else l=0;return pe(w),m=u,0|(G=l)}function q(e,r,i,n,o,a,u,l){r|=0,i|=0;var s,_,E,T,M,A,h,b,p,S,v,k,R,y,g,O,w,P,C,N,I,L,D,F,U=0,H=0,x=0,B=0,Y=0,V=0,X=0,G=0,K=0,W=0,z=0,j=0,J=0,Z=0,q=0,Q=0,$=0,re=0;if(F=m,m=m+592|0,I=F+48|0,D=F+32|0,L=F+16|0,N=F,P=F+80|0,C=F+64|0,A=0|f[(M=(e|=0)+272|0)>>2],h=(0|c[(re=0|f[e+88>>2])+63>>0])<<8|0|c[re+64>>0],b=255&(re=0|t[re+17>>0]),!(re<<24>>24))return m=F,1;p=0==(0|(l|=0)),v=(S=(u|=0)+-1|0)<<4,k=l+-1|0,R=(n|=0)<<1,y=e+92|0,g=e+116|0,O=e+164|0,w=e+268|0,re=e+212|0,T=0==(1&(o|=0)|0),E=0==(1&(a|=0)|0),_=e+288|0,s=e+284|0,$=0,o=0,i=0,a=1;do{if(!p)for(q=0|f[r+($<<2)>>2],Q=0;;){if(U=0==(0|(Z=1&Q)),J=(Z<<5^32)-16|0,Z=(Z<<1^2)-1|0,(0|(e=U?0:S))!=(0|(z=U?u:-1)))for(j=E|(0|Q)!=(0|k),W=U?q:q+v|0;;){1==(0|a)&&(a=512|ee(y,g)),K=7&a,a>>>=3,H=0|c[1539+K>>0],U=0;do{V=(0|ee(y,O))+i|0,(0|f[M>>2])>>>0<=(i=(G=(X=V-A|0)>>31)&V|X&~G)>>>0&&(f[N>>2]=866,f[N+4>>2]=910,f[N+8>>2]=1497,We(P,812,N),Le(P)),f[C+(U<<2)>>2]=d[(0|f[w>>2])+(i<<1)>>1],U=U+1|0}while(U>>>0<H>>>0);for(G=T|(0|e)!=(0|S),V=0,X=W;Y=j|0==(0|V),H=V<<1,B=(B=(x=(U=(0|ee(y,re))+o|0)-h|0)>>31)&U|x&~B,G?(Y&&(o=0|c[1547+(K<<2)+H>>0],(0|f[_>>2])>>>0<=(U=3*B|0)>>>0&&(f[L>>2]=866,f[L+4>>2]=910,f[L+8>>2]=1497,We(P,812,L),Le(P)),f[X>>2]=(0|d[(x=(0|f[s>>2])+(U<<1)|0)>>1])<<16|f[C+(o<<2)>>2],f[X+4>>2]=(0|d[x+4>>1])<<16|0|d[x+2>>1]),x=X+8|0,o=(o=(B=(U=(0|ee(y,re))+B|0)-h|0)>>31)&U|B&~o,Y&&(U=0|c[1547+(K<<2)+(1|H)>>0],(0|f[_>>2])>>>0<=(H=3*o|0)>>>0&&(f[I>>2]=866,f[I+4>>2]=910,f[I+8>>2]=1497,We(P,812,I),Le(P)),f[x>>2]=(0|d[(Y=(0|f[s>>2])+(H<<1)|0)>>1])<<16|f[C+(U<<2)>>2],f[X+12>>2]=(0|d[Y+4>>1])<<16|0|d[Y+2>>1])):(Y&&(o=0|c[1547+(K<<2)+H>>0],(0|f[_>>2])>>>0<=(U=3*B|0)>>>0&&(f[D>>2]=866,f[D+4>>2]=910,f[D+8>>2]=1497,We(P,812,D),Le(P)),f[X>>2]=(0|d[(Y=(0|f[s>>2])+(U<<1)|0)>>1])<<16|f[C+(o<<2)>>2],f[X+4>>2]=(0|d[Y+4>>1])<<16|0|d[Y+2>>1]),o=(o=(Y=(B=(0|ee(y,re))+B|0)-h|0)>>31)&B|Y&~o),2!=(0|(V=V+1|0));)X=X+n|0;if((0|(e=Z+e|0))==(0|z))break;W=W+J|0}if((0|(Q=Q+1|0))==(0|l))break;q=q+R|0}$=$+1|0}while((0|$)!=(0|b));return m=F,1}function Q(e,r,i,n,t){t|=0;var o=0,a=0,u=0,l=0,c=0,s=0,d=0,_=0,E=0,T=0;if(s=e|=0,a=i|=0,u=_=n|=0,!(c=l=r|=0))return o=0!=(0|t),u?o?(f[t>>2]=0|e,f[t+4>>2]=0&r,0|(S=_=0,t=0)):0|(S=_=0,t=0):(o&&(f[t>>2]=(s>>>0)%(a>>>0),f[t+4>>2]=0),0|(S=_=0,t=(s>>>0)/(a>>>0)>>>0));o=0==(0|u);do{if(a){if(!o){if((o=(0|k(0|u))-(0|k(0|c))|0)>>>0<=31){a=d=o+1|0,e=s>>>(d>>>0)&(r=o-31>>31)|c<<(u=31-o|0),r&=c>>>(d>>>0),o=0,u=s<<u;break}return t?(f[t>>2]=0|e,f[t+4>>2]=l|0&r,0|(S=_=0,t=0)):0|(S=_=0,t=0)}if((o=a-1|0)&a|0){a=u=33+(0|k(0|a))-(0|k(0|c))|0,e=(d=32-u|0)-1>>31&c>>>((E=u-32|0)>>>0)|(c<<d|s>>>(u>>>0))&(r=E>>31),r&=c>>>(u>>>0),o=s<<(T=64-u|0)&(l=d>>31),u=(c<<T|s>>>(E>>>0))&l|s<<d&u-33>>31;break}return 0|t&&(f[t>>2]=o&s,f[t+4>>2]=0),1==(0|a)?0|(S=E=l|0&r,T=0|e):(T=0|Ye(0|a),0|(S=E=c>>>(T>>>0)|0,T=c<<32-T|s>>>(T>>>0)|0))}if(o)return 0|t&&(f[t>>2]=(c>>>0)%(a>>>0),f[t+4>>2]=0),0|(S=E=0,T=(c>>>0)/(a>>>0)>>>0);if(!s)return 0|t&&(f[t>>2]=0,f[t+4>>2]=(c>>>0)%(u>>>0)),0|(S=E=0,T=(c>>>0)/(u>>>0)>>>0);if(!((o=u-1|0)&u))return 0|t&&(f[t>>2]=0|e,f[t+4>>2]=o&c|0&r),E=0,T=c>>>((0|Ye(0|u))>>>0),0|(S=E,T);if((o=(0|k(0|u))-(0|k(0|c))|0)>>>0<=30){a=r=o+1|0,e=c<<(u=31-o|0)|s>>>(r>>>0),r=c>>>(r>>>0),o=0,u=s<<u;break}return t?(f[t>>2]=0|e,f[t+4>>2]=l|0&r,0|(S=E=0,T=0)):0|(S=E=0,T=0)}while(0);if(a){c=0|Qe(0|(d=0|i),0|(s=_|0&n),-1,-1),i=S,l=u,u=0;do{n=l,l=o>>>31|l<<1,o=u|o<<1,Ze(0|c,0|i,0|(n=e<<1|n>>>31|0),0|(_=e>>>31|r<<1|0)),u=1&(E=(T=S)>>31|((0|T)<0?-1:0)<<1),e=0|Ze(0|n,0|_,E&d|0,(((0|T)<0?-1:0)>>31|((0|T)<0?-1:0)<<1)&s|0),r=S,a=a-1|0}while(0!=(0|a));c=l,l=0}else c=u,l=0,u=0;return a=0,0|t&&(f[t>>2]=e,f[t+4>>2]=r),0|(S=E=(0|o)>>>31|(c|a)<<1|0&(a<<1|o>>>31)|l,T=-2&(o<<1|0)|u)}function $(e){var r,i,n,o,a,u=0,l=0,s=0,d=0,_=0,E=0,T=0,M=0;if(a=m,m=m+576|0,E=a,d=a+64|0,M=a+16|0,i=(e|=0)+236|0,(0|(l=0|f[(_=e+240|0)>>2]))!=(0|(o=(0|c[(u=0|f[(s=e+88|0)>>2])+39>>0])<<8|0|c[u+40>>0]))){if(l>>>0<=o>>>0){do{if((0|f[e+244>>2])>>>0<o>>>0){if(0|te(i,o,(l+1|0)==(0|o),4,0)){u=0|f[_>>2];break}return t[e+248>>0]=1,m=a,0|(M=0)}u=l}while(0);ke((0|f[i>>2])+(u<<2)|0,0,o-u<<2|0),u=0|f[s>>2]}f[_>>2]=o}if(l=(0|f[e+4>>2])+((0|c[u+34>>0])<<8|(0|c[u+33>>0])<<16|0|c[u+35>>0])|0,!(u=(0|c[u+37>>0])<<8|(0|c[u+36>>0])<<16|0|c[u+38>>0]))return m=a,0|(M=0);if(f[(n=e+92|0)>>2]=l,f[e+96>>2]=l,f[e+104>>2]=u,f[e+100>>2]=l+u,f[e+108>>2]=0,f[e+112>>2]=0,T=M+20|0,f[M>>2]=0,f[M+4>>2]=0,f[M+8>>2]=0,f[M+12>>2]=0,t[M+16>>0]=0,r=M+24|0,f[M+44>>2]=0,f[T>>2]=0,f[T+4>>2]=0,f[T+8>>2]=0,f[T+12>>2]=0,f[T+16>>2]=0,t[T+20>>0]=0,0|X(n,M)&&0|X(n,r))if(0|f[_>>2]||(f[E>>2]=866,f[E+4>>2]=910,f[E+8>>2]=1497,We(d,812,E),Le(d)),o)for(E=0,T=0,l=0|f[i>>2],s=0,e=0,u=0,d=0,_=0;;){if(E=(0|ee(n,M))+E&31,_=(0|ee(n,r))+_&63,d=(0|ee(n,M))+d&31,u=(0|ee(n,M))+u|0,e=(0|ee(n,r))+e&63,s=(0|ee(n,M))+s&31,f[l>>2]=_<<5|E<<11|d|u<<27|e<<21|s<<16,(T=T+1|0)>>>0>=o>>>0){u=1;break}l=l+4|0,u&=31}else u=1;else u=0;return pe(M+24|0),pe(M),m=a,0|(M=u)}function ee(e,r){var i,n,t,o,a,u,l,s,_=0,E=0,T=0,M=0,A=0,h=0;s=m,m=m+576|0,t=s+48|0,a=s+32|0,o=s+16|0,n=s,l=s+64|0,u=0|f[(r|=0)+20>>2],(0|(i=0|f[(h=(e|=0)+20|0)>>2]))<24?(E=(_=0|f[(A=e+4|0)>>2])>>>0<(T=0|f[e+8>>2])>>>0,(0|i)<16?(E?(M=(0|c[_>>0])<<8,_=_+1|0):M=0,_>>>0<T>>>0?(T=0|c[_>>0],_=_+1|0):T=0,f[A>>2]=_,f[h>>2]=i+16,E=16,_=T|M):(E?(f[A>>2]=_+1,_=0|c[_>>0]):_=0,f[h>>2]=i+8,E=24),f[(A=e+16|0)>>2]=T=f[A>>2]|_<<E-i):(A=T=e+16|0,T=0|f[T>>2]),M=1+(T>>>16)|0;do{if(!(M>>>0<=(0|f[u+16>>2])>>>0)){for(E=0|f[u+20>>2];M>>>0>(0|f[u+28+((_=E+-1|0)<<2)>>2])>>>0;)E=E+1|0;if((_=(T>>>(32-E|0))+(0|f[u+96+(_<<2)>>2])|0)>>>0<(0|f[r>>2])>>>0){_=0|d[(0|f[u+176>>2])+(_<<1)>>1];break}return f[t>>2]=866,f[t+4>>2]=3275,f[t+8>>2]=1348,We(l,812,t),Le(l),m=s,0|(h=0)}-1==(0|(E=0|f[(0|f[u+168>>2])+(T>>>(32-(0|f[u+8>>2])|0)<<2)>>2]))&&(f[n>>2]=866,f[n+4>>2]=3253,f[n+8>>2]=1393,We(l,812,n),Le(l)),_=65535&E,E>>>=16,(0|f[r+8>>2])>>>0<=_>>>0&&(f[o>>2]=866,f[o+4>>2]=909,f[o+8>>2]=1497,We(l,812,o),Le(l)),(0|c[(0|f[r+4>>2])+_>>0])!=(0|E)&&(f[a>>2]=866,f[a+4>>2]=3257,f[a+8>>2]=1410,We(l,812,a),Le(l))}while(0);return f[A>>2]=f[A>>2]<<E,f[h>>2]=(0|f[h>>2])-E,m=s,0|(h=_)}function re(e){var r,i,n,o,a,u=0,l=0,c=0;if(a=m,m=m+576|0,c=a+48|0,n=a+32|0,i=a+16|0,r=a,o=a+64|0,f[(e|=0)>>2]=0,0|(l=0|f[(u=e+284|0)>>2])&&(7&l?(f[r>>2]=866,f[r+4>>2]=2506,f[r+8>>2]=1232,We(o,812,r),Le(o)):Oe(l,0,0,1,0),f[u>>2]=0,f[e+288>>2]=0,f[e+292>>2]=0),t[e+296>>0]=0,0|(l=0|f[(u=e+268|0)>>2])&&(7&l?(f[i>>2]=866,f[i+4>>2]=2506,f[i+8>>2]=1232,We(o,812,i),Le(o)):Oe(l,0,0,1,0),f[u>>2]=0,f[e+272>>2]=0,f[e+276>>2]=0),t[e+280>>0]=0,0|(l=0|f[(u=e+252|0)>>2])&&(7&l?(f[n>>2]=866,f[n+4>>2]=2506,f[n+8>>2]=1232,We(o,812,n),Le(o)):Oe(l,0,0,1,0),f[u>>2]=0,f[e+256>>2]=0,f[e+260>>2]=0),t[e+264>>0]=0,!(l=0|f[(u=e+236|0)>>2]))return t[(c=e+248|0)>>0]=0,pe(c=e+212|0),pe(c=e+188|0),pe(c=e+164|0),pe(c=e+140|0),pe(c=e+116|0),void(m=a);7&l?(f[c>>2]=866,f[c+4>>2]=2506,f[c+8>>2]=1232,We(o,812,c),Le(o)):Oe(l,0,0,1,0),f[u>>2]=0,f[e+240>>2]=0,f[e+244>>2]=0,t[(c=e+248|0)>>0]=0,pe(c=e+212|0),pe(c=e+188|0),pe(c=e+164|0),pe(c=e+140|0),pe(c=e+116|0),m=a}function ie(e,r,i){e|=0,r|=0,i|=0;var n=0,t=0,o=0;e:do{if(r>>>0<=20){switch(0|r){case 9:r=0|f[(n=3+(0|f[i>>2])&-4)>>2],f[i>>2]=n+4,f[e>>2]=r;break e;case 10:r=0|f[(n=3+(0|f[i>>2])&-4)>>2],f[i>>2]=n+4,f[(n=e)>>2]=r,f[n+4>>2]=((0|r)<0)<<31>>31;break e;case 11:r=0|f[(n=3+(0|f[i>>2])&-4)>>2],f[i>>2]=n+4,f[(n=e)>>2]=r,f[n+4>>2]=0;break e;case 12:t=0|f[(r=n=7+(0|f[i>>2])&-8)>>2],r=0|f[r+4>>2],f[i>>2]=n+8,f[(n=e)>>2]=t,f[n+4>>2]=r;break e;case 13:n=0|f[(t=3+(0|f[i>>2])&-4)>>2],f[i>>2]=t+4,f[(t=e)>>2]=n=(65535&n)<<16>>16,f[t+4>>2]=((0|n)<0)<<31>>31;break e;case 14:n=0|f[(t=3+(0|f[i>>2])&-4)>>2],f[i>>2]=t+4,f[(t=e)>>2]=65535&n,f[t+4>>2]=0;break e;case 15:n=0|f[(t=3+(0|f[i>>2])&-4)>>2],f[i>>2]=t+4,f[(t=e)>>2]=n=(255&n)<<24>>24,f[t+4>>2]=((0|n)<0)<<31>>31;break e;case 16:n=0|f[(t=3+(0|f[i>>2])&-4)>>2],f[i>>2]=t+4,f[(t=e)>>2]=255&n,f[t+4>>2]=0;break e;case 17:case 18:o=+M[(t=7+(0|f[i>>2])&-8)>>3],f[i>>2]=t+8,M[e>>3]=o;break e;default:break e}}}while(0)}function ne(e){var r,i,n,o,u=0,l=0,s=0,d=0,_=0;if(o=m,m=m+560|0,r=o,s=o+40|0,_=o+16|0,i=(0|c[(l=0|f[(e|=0)+88>>2])+55>>0])<<8|0|c[l+56>>0],u=(0|f[e+4>>2])+((0|c[l+50>>0])<<8|(0|c[l+49>>0])<<16|0|c[l+51>>0])|0,!(l=(0|c[l+53>>0])<<8|(0|c[l+52>>0])<<16|0|c[l+54>>0]))return m=o,0|(_=0);f[(n=e+92|0)>>2]=u,f[e+96>>2]=u,f[e+104>>2]=l,f[e+100>>2]=u+l,f[e+108>>2]=0,f[e+112>>2]=0,f[_+20>>2]=0,f[_>>2]=0,f[_+4>>2]=0,f[_+8>>2]=0,f[_+12>>2]=0,t[_+16>>0]=0;e:do{if(0|X(n,_)){if(d=e+268|0,(0|(u=0|f[(l=e+272|0)>>2]))!=(0|i)){if(u>>>0<=i>>>0){do{if((0|f[e+276>>2])>>>0<i>>>0){if(0|te(d,i,(u+1|0)==(0|i),2,0)){u=0|f[l>>2];break}t[e+280>>0]=1,u=0;break e}}while(0);ke((0|f[d>>2])+(u<<1)|0,0,i-u<<1|0)}f[l>>2]=i}if(!i){f[r>>2]=866,f[r+4>>2]=910,f[r+8>>2]=1497,We(s,812,r),Le(s),u=1;break}for(l=0,e=0,s=0,u=0|f[d>>2];;){if(s=(d=0|ee(n,_))+s&255,e=(0|ee(n,_))+e&255,a[u>>1]=e<<8|s,(l=l+1|0)>>>0>=i>>>0){u=1;break}u=u+2|0}}else u=0}while(0);return pe(_),m=o,0|(_=u)}function te(e,r,i,n,t){r|=0,i|=0,n|=0,t|=0;var o,a,u,l,c,s,d=0,_=0,E=0,T=0;if(s=m,m=m+576|0,l=s+48|0,o=s+32|0,_=s+16|0,d=s,u=s+64|0,c=s+60|0,(0|f[(a=(e|=0)+4|0)>>2])>>>0>(0|f[(T=e+8|0)>>2])>>>0&&(f[d>>2]=866,f[d+4>>2]=2123,f[d+8>>2]=845,We(u,812,d),Le(u)),(2147418112/(n>>>0)|0)>>>0<=r>>>0&&(f[_>>2]=866,f[_+4>>2]=2124,f[_+8>>2]=885,We(u,812,_),Le(u)),(d=0|f[T>>2])>>>0>=r>>>0)return m=s,0|(T=1);if(i&&0!=((E=r+-1|0)&r|0)?(r=E>>>16|E,r|=r>>>8,r|=r>>>4,(r=1+((r|=r>>>2)>>>1|r)|0)?i=9:(r=0,i=10)):i=9,9==(0|i)&&r>>>0<=d>>>0&&(i=10),10==(0|i)&&(f[o>>2]=866,f[o+4>>2]=2133,f[o+8>>2]=933,We(u,812,o),Le(u)),E=0|v(r,n),t)if(_=0|Se(E,c)){vr[0&t](_,0|f[e>>2],0|f[a>>2]),d=0|f[e>>2];do{if(0|d){if(7&d){f[l>>2]=866,f[l+4>>2]=2506,f[l+8>>2]=1232,We(u,812,l),Le(u);break}Oe(d,0,0,1,0);break}}while(0);f[e>>2]=_,i=20}else r=0;else(d=0|function(e,r,i,n){r|=0,i|=0,n|=0;var t,o,a,u,l,c=0;if(l=m,m=m+560|0,c=l+32|0,o=l+16|0,t=l,a=l+48|0,u=l+44|0,7&(e=e|0)|0)return f[t>>2]=866,f[t+4>>2]=2506,f[t+8>>2]=1210,We(a,812,t),Le(a),m=l,0|(c=0);if(r>>>0>2147418112)return f[o>>2]=866,f[o+4>>2]=2506,f[o+8>>2]=1103,We(a,812,o),Le(a),m=l,0|(c=0);f[u>>2]=r,e=0|Oe(e,r,u,n,0),0|i&&(f[i>>2]=f[u>>2]);7&e|0&&(f[c>>2]=866,f[c+4>>2]=2558,f[c+8>>2]=1156,We(a,812,c),Le(a));return m=l,0|(c=e)}(0|f[e>>2],E,c,1))?(f[e>>2]=d,i=20):r=0;return 20==(0|i)&&((d=0|f[c>>2])>>>0>E>>>0&&(r=(d>>>0)/(n>>>0)|0),f[T>>2]=r,r=1),m=s,0|(T=r)}function oe(e,r){var i,n,o,a,u,l,c,s,d,_,E=0,T=0;if(_=m,m=m+528|0,d=_,l=_+16|0,0==(0|(e|=0))|(r|=0)>>>0<62)return m=_,0|(T=0);if(!(c=0|Se(300,0)))return m=_,0|(T=0);f[c>>2]=519686845,f[c+4>>2]=0,f[c+8>>2]=0,s=c+88|0,i=c+136|0,n=c+160|0,o=c+184|0,a=c+208|0,u=c+232|0,f[(E=c+252|0)>>2]=0,f[E+4>>2]=0,f[E+8>>2]=0,t[E+12>>0]=0,f[(E=c+268|0)>>2]=0,f[E+4>>2]=0,f[E+8>>2]=0,t[E+12>>0]=0,f[(E=c+284|0)>>2]=0,f[E+4>>2]=0,f[E+8>>2]=0,t[E+12>>0]=0,T=(E=s)+44|0;do{f[E>>2]=0,E=E+4|0}while((0|E)<(0|T));return t[s+44>>0]=0,f[i>>2]=0,f[i+4>>2]=0,f[i+8>>2]=0,f[i+12>>2]=0,f[i+16>>2]=0,t[i+20>>0]=0,f[n>>2]=0,f[n+4>>2]=0,f[n+8>>2]=0,f[n+12>>2]=0,f[n+16>>2]=0,t[n+20>>0]=0,f[o>>2]=0,f[o+4>>2]=0,f[o+8>>2]=0,f[o+12>>2]=0,f[o+16>>2]=0,t[o+20>>0]=0,f[a>>2]=0,f[a+4>>2]=0,f[a+8>>2]=0,f[a+12>>2]=0,f[a+16>>2]=0,t[a+20>>0]=0,f[u>>2]=0,f[u+4>>2]=0,f[u+8>>2]=0,f[u+12>>2]=0,t[u+16>>0]=0,0|he(c,e,r)?(m=_,0|(T=c)):(re(c),7&c?(f[d>>2]=866,f[d+4>>2]=2506,f[d+8>>2]=1232,We(l,812,d),Le(l),m=_,0|(T=0)):(Oe(c,0,0,1,0),m=_,0|(T=0)))}function ae(e,r,i,n,o,a,u){r|=0,i|=0,n|=0,o|=0,a|=0;var l,s=0,d=0,_=0;if(d=(((d=(c[(_=0|f[(e|=0)+88>>2])+14>>0]<<8|c[_+15>>0])>>>(u|=0))>>>0>1?d:1)+3|0)>>>2,u=0|v(s=(((s=(c[_+12>>0]<<8|c[_+13>>0])>>>u)>>>0>1?s:1)+3|0)>>>2,(u=0|t[(_=_+18|0)>>0])<<24>>24==0|u<<24>>24==9?8:16),a){if(!(0==(3&a|0)&u>>>0<=a>>>0))return 0|(o=0);u=a}if((0|v(u,d))>>>0>o>>>0)return 0|(o=0);if(a=(s+1|0)>>>1,l=(d+1|0)>>>1,!i)return 0|(o=0);switch(f[e+92>>2]=r,f[e+96>>2]=r,f[e+104>>2]=i,f[e+100>>2]=r+i,f[e+108>>2]=0,f[e+112>>2]=0,0|t[_>>0]){case 0:if(!(0|function(e,r,i,n,o,a,u,l){r|=0,i|=0;var s,d,_,E,T,M,A,h,b,p,S,k,R,y,g,O,w,P,C,N,I,L,D,F,U,H,x,B,Y,V,X,G,K=0,W=0,z=0,j=0,J=0,Z=0,q=0,Q=0,$=0,re=0,ie=0,ne=0,te=0,oe=0,ae=0,ue=0,fe=0,le=0;if(G=m,m=m+656|0,V=G+112|0,B=G+96|0,x=G+80|0,H=G+64|0,U=G+48|0,X=G+32|0,Y=G+16|0,F=G,L=G+144|0,D=G+128|0,y=0|f[(R=(e|=0)+240|0)>>2],O=0|f[(g=e+256|0)>>2],w=255&(ue=0|t[17+(0|f[e+88>>2])>>0]),!(ue<<24>>24))return m=G,1;C=0==(0|(l|=0)),I=(N=(u|=0)+-1|0)<<4,ue=l+-1|0,A=0!=(1&(a|=0)|0),h=(n|=0)<<1,b=e+92|0,p=e+116|0,S=e+140|0,k=e+236|0,M=0!=(1&(o|=0)|0),T=e+188|0,s=e+252|0,d=(P=n>>>2)+1|0,_=P+2|0,E=P+3|0,ae=0,a=0,i=0,o=1;do{if(!C)for(te=0|f[r+(ae<<2)>>2],oe=0;;){if(W=0==(0|(ie=1&oe)),re=(ie<<5^32)-16|0,ie=(ie<<1^2)-1|0,ne=A&(e=(0|oe)==(0|ue)),(0|(K=W?0:N))!=(0|($=W?u:-1)))for(Q=A&e^1,q=W?te:te+I|0;;){1==(0|o)&&(o=512|ee(b,p)),Z=7&o,o>>>=3,W=0|c[1539+Z>>0],e=0;do{z=(0|ee(b,S))+i|0,(0|f[R>>2])>>>0<=(i=(J=(j=z-y|0)>>31)&z|j&~J)>>>0&&(f[F>>2]=866,f[F+4>>2]=910,f[F+8>>2]=1497,We(L,812,F),Le(L)),f[D+(e<<2)>>2]=f[(0|f[k>>2])+(i<<2)>>2],e=e+1|0}while(e>>>0<W>>>0);if(ne|(J=M&(0|K)==(0|N))){j=0;do{e=q+(0|v(j,n))|0,z=0==(0|j)|Q,W=j<<1,a=(a=(fe=(le=(0|ee(b,T))+a|0)-O|0)>>31)&le|fe&~a;do{if(J){if(!z){a=(a=(le=(fe=(0|ee(b,T))+a|0)-O|0)>>31)&fe|le&~a;break}f[e>>2]=f[D+((0|c[1547+(Z<<2)+W>>0])<<2)>>2],(0|f[g>>2])>>>0<=a>>>0&&(f[B>>2]=866,f[B+4>>2]=910,f[B+8>>2]=1497,We(L,812,B),Le(L)),f[e+4>>2]=f[(0|f[s>>2])+(a<<2)>>2],a=(a=(le=(fe=(0|ee(b,T))+a|0)-O|0)>>31)&fe|le&~a}else z&&(f[e>>2]=f[D+((0|c[1547+(Z<<2)+W>>0])<<2)>>2],(0|f[g>>2])>>>0<=a>>>0&&(f[x>>2]=866,f[x+4>>2]=910,f[x+8>>2]=1497,We(L,812,x),Le(L)),f[e+4>>2]=f[(0|f[s>>2])+(a<<2)>>2]),e=e+8|0,a=(a=(le=(fe=(0|ee(b,T))+a|0)-O|0)>>31)&fe|le&~a,z&&(f[e>>2]=f[D+((0|c[1547+(Z<<2)+(1|W)>>0])<<2)>>2],(0|f[g>>2])>>>0<=a>>>0&&(f[V>>2]=866,f[V+4>>2]=910,f[V+8>>2]=1497,We(L,812,V),Le(L)),f[e+4>>2]=f[(0|f[s>>2])+(a<<2)>>2])}while(0);j=j+1|0}while(2!=(0|j))}else f[q>>2]=f[D+((0|c[1547+(Z<<2)>>0])<<2)>>2],fe=(0|ee(b,T))+a|0,(0|f[g>>2])>>>0<=(a=(a=(le=fe-O|0)>>31)&fe|le&~a)>>>0&&(f[Y>>2]=866,f[Y+4>>2]=910,f[Y+8>>2]=1497,We(L,812,Y),Le(L)),f[q+4>>2]=f[(0|f[s>>2])+(a<<2)>>2],f[q+8>>2]=f[D+((0|c[1547+(Z<<2)+1>>0])<<2)>>2],fe=(0|ee(b,T))+a|0,(0|f[g>>2])>>>0<=(a=(a=(le=fe-O|0)>>31)&fe|le&~a)>>>0&&(f[X>>2]=866,f[X+4>>2]=910,f[X+8>>2]=1497,We(L,812,X),Le(L)),f[q+12>>2]=f[(0|f[s>>2])+(a<<2)>>2],f[q+(P<<2)>>2]=f[D+((0|c[1547+(Z<<2)+2>>0])<<2)>>2],fe=(0|ee(b,T))+a|0,(0|f[g>>2])>>>0<=(a=(a=(le=fe-O|0)>>31)&fe|le&~a)>>>0&&(f[U>>2]=866,f[U+4>>2]=910,f[U+8>>2]=1497,We(L,812,U),Le(L)),f[q+(d<<2)>>2]=f[(0|f[s>>2])+(a<<2)>>2],f[q+(_<<2)>>2]=f[D+((0|c[1547+(Z<<2)+3>>0])<<2)>>2],fe=(0|ee(b,T))+a|0,(0|f[g>>2])>>>0<=(a=(a=(le=fe-O|0)>>31)&fe|le&~a)>>>0&&(f[H>>2]=866,f[H+4>>2]=910,f[H+8>>2]=1497,We(L,812,H),Le(L)),f[q+(E<<2)>>2]=f[(0|f[s>>2])+(a<<2)>>2];if((0|(K=ie+K|0))==(0|$))break;q=q+re|0}if((0|(oe=oe+1|0))==(0|l))break;te=te+h|0}ae=ae+1|0}while((0|ae)!=(0|w));return m=G,1}(e,n,o,u,s,d,a,l)))return 0|(o=0);break;case 4:case 6:case 5:case 3:case 2:if(!(0|z(e,n,o,u,s,d,a,l)))return 0|(o=0);break;case 9:if(!(0|q(e,n,o,u,s,d,a,l)))return 0|(o=0);break;case 8:case 7:if(!(0|K(e,n,o,u,s,d,a,l)))return 0|(o=0);break;default:return 0|(o=0)}return 0|(o=1)}function ue(e,r,i){e|=0,r|=0;var n,o,a=0;if((0|(i|=0))>=8192)return 0|F(0|e,0|r,0|i);if(o=0|e,n=e+i|0,(3&e)==(3&r)){for(;3&e;){if(!i)return 0|o;t[e>>0]=0|t[r>>0],e=e+1|0,r=r+1|0,i=i-1|0}for(a=(i=-4&n|0)-64|0;(0|e)<=(0|a);)f[e>>2]=f[r>>2],f[e+4>>2]=f[r+4>>2],f[e+8>>2]=f[r+8>>2],f[e+12>>2]=f[r+12>>2],f[e+16>>2]=f[r+16>>2],f[e+20>>2]=f[r+20>>2],f[e+24>>2]=f[r+24>>2],f[e+28>>2]=f[r+28>>2],f[e+32>>2]=f[r+32>>2],f[e+36>>2]=f[r+36>>2],f[e+40>>2]=f[r+40>>2],f[e+44>>2]=f[r+44>>2],f[e+48>>2]=f[r+48>>2],f[e+52>>2]=f[r+52>>2],f[e+56>>2]=f[r+56>>2],f[e+60>>2]=f[r+60>>2],e=e+64|0,r=r+64|0;for(;(0|e)<(0|i);)f[e>>2]=f[r>>2],e=e+4|0,r=r+4|0}else for(i=n-4|0;(0|e)<(0|i);)t[e>>0]=0|t[r>>0],t[e+1>>0]=0|t[r+1>>0],t[e+2>>0]=0|t[r+2>>0],t[e+3>>0]=0|t[r+3>>0],e=e+4|0,r=r+4|0;for(;(0|e)<(0|n);)t[e>>0]=0|t[r>>0],e=e+1|0,r=r+1|0;return 0|o}function fe(e,r,i){r|=0,i|=0;var n,t,o,a,u,l=0,c=0,s=0,d=0,_=0,E=0;u=m,m=m+48|0,a=u+16|0,s=u,f[(c=u+32|0)>>2]=l=0|f[(t=(e|=0)+28|0)>>2],f[c+4>>2]=l=(0|f[(o=e+20|0)>>2])-l|0,f[c+8>>2]=r,f[c+12>>2]=i,l=l+i|0,f[s>>2]=f[(n=e+60|0)>>2],f[s+4>>2]=c,f[s+8>>2]=2,s=0|$e(0|x(146,0|s));e:do{if((0|l)!=(0|s)){for(r=2;!((0|s)<0);)if(l=l-s|0,r=((_=s>>>0>(E=0|f[c+4>>2])>>>0)<<31>>31)+r|0,f[(c=_?c+8|0:c)>>2]=(0|f[c>>2])+(E=s-(_?E:0)|0),f[(_=c+4|0)>>2]=(0|f[_>>2])-E,f[a>>2]=f[n>>2],f[a+4>>2]=c,f[a+8>>2]=r,(0|l)==(0|(s=0|$e(0|x(146,0|a))))){d=3;break e}f[e+16>>2]=0,f[t>>2]=0,f[o>>2]=0,f[e>>2]=32|f[e>>2],i=2==(0|r)?0:i-(0|f[c+4>>2])|0}else d=3}while(0);return 3==(0|d)&&(f[e+16>>2]=(E=0|f[e+44>>2])+(0|f[e+48>>2]),f[t>>2]=E,f[o>>2]=E),m=u,0|i}function le(e,r,i){e|=0,r|=0,i|=0;var n,o,a,u,l,c=0,s=0,d=0,_=0,E=0,T=0,M=0;l=m,m=m+224|0,n=l+120|0,a=l,u=l+136|0,s=(c=o=l+80|0)+40|0;do{f[c>>2]=0,c=c+4|0}while((0|c)<(0|s));return f[n>>2]=f[i>>2],(0|V(0,r,n,a,o))<0?i=-1:(M=32&(i=0|f[e>>2]),(0|t[e+74>>0])<1&&(f[e>>2]=-33&i),0|f[(c=e+48|0)>>2]?i=0|V(e,r,n,a,o):(d=0|f[(s=e+44|0)>>2],f[s>>2]=u,f[(_=e+28|0)>>2]=u,f[(E=e+20|0)>>2]=u,f[c>>2]=80,f[(T=e+16|0)>>2]=u+80,i=0|V(e,r,n,a,o),d&&(br[7&f[e+36>>2]](e,0,0),i=0==(0|f[E>>2])?-1:i,f[s>>2]=d,f[c>>2]=0,f[T>>2]=0,f[_>>2]=0,f[E>>2]=0)),f[e>>2]=(c=0|f[e>>2])|M,i=0==(32&c|0)?i:-1),m=l,0|i}function ce(e,r,i,n){r|=0,n|=0;var o,u,l,c,s,d,_,E=0,T=0;_=m,m=m+64|0,d=(e|=0)+(0|f[(T=0|f[e>>2])+-8>>2])|0,T=0|f[T+-4>>2],f[(s=_)>>2]=i|=0,f[s+4>>2]=e,f[s+8>>2]=r,f[s+12>>2]=n,r=s+20|0,n=s+24|0,o=s+28|0,u=s+32|0,l=s+40|0,c=(E=e=s+16|0)+36|0;do{f[E>>2]=0,E=E+4|0}while((0|E)<(0|c));a[e+36>>1]=0,t[e+38>>0]=0;e:do{if(0|tr(T,i))f[s+48>>2]=1,Rr[3&f[20+(0|f[T>>2])>>2]](T,s,d,d,1,0),e=1==(0|f[n>>2])?d:0;else{switch(mr[3&f[24+(0|f[T>>2])>>2]](T,s,d,1,0),0|f[s+36>>2]){case 0:e=1==(0|f[l>>2])&1==(0|f[o>>2])&1==(0|f[u>>2])?0|f[r>>2]:0;break e;case 1:break;default:e=0;break e}if(1!=(0|f[n>>2])&&!(0==(0|f[l>>2])&1==(0|f[o>>2])&1==(0|f[u>>2]))){e=0;break}e=0|f[e>>2]}}while(0);return m=_,0|e}function se(e){var r,i=0,n=0,t=0,o=0,a=0,u=0,l=0;if(r=m,m=m+544|0,u=r+16|0,i=r,o=r+32|0,((n=0|f[(a=(e|=0)+8|0)>>2])+-1|0)>>>0>=8192&&(f[i>>2]=866,f[i+4>>2]=3006,f[i+8>>2]=1257,We(o,812,i),Le(o)),f[e>>2]=n,(i=0|f[(t=e+20|0)>>2])?l=n:((i=0|Se(180,0))?(f[(l=i+164|0)>>2]=0,f[l+4>>2]=0,f[l+8>>2]=0,f[l+12>>2]=0):i=0,f[t>>2]=i,l=0|f[e>>2]),0|f[a>>2]?u=l:(f[u>>2]=866,f[u+4>>2]=910,f[u+8>>2]=1497,We(o,812,u),Le(o),u=0|f[e>>2]),o=0|f[e+4>>2],!(u>>>0>16))return e=0|G(i,l,o,e=0),m=r,0|e;for(n=u,t=0;a=t+1|0,n>>>0>3;)n>>>=1,t=a;return e=0|G(i,l,o,e=255&((e=t+2+(32!=(0|a)&1<<a>>>0<u>>>0&1)|0)>>>0<11?e:11)),m=r,0|e}function de(e,r,i){r|=0,i|=0;var n,o=0,a=0,u=0,l=0,c=0,s=0,d=0,_=0,E=0;u=0|or(0|f[(e|=0)+8>>2],n=1794895138+(0|f[e>>2])|0),o=0|or(0|f[e+12>>2],n),a=0|or(0|f[e+16>>2],n);e:do{if(u>>>0<r>>>2>>>0&&(E=r-(u<<2)|0,o>>>0<E>>>0&a>>>0<E>>>0)&&0==(3&(a|o)|0)){for(E=o>>>2,_=a>>>2,d=0;;){if(o=0|or(0|f[e+((a=(l=(s=d+(c=u>>>1)|0)<<1)+E|0)<<2)>>2],n),!((a=0|or(0|f[e+(a+1<<2)>>2],n))>>>0<r>>>0&o>>>0<(r-a|0)>>>0)){o=0;break e}if(0|t[e+(a+o)>>0]){o=0;break e}if(!(o=0|Ue(i,e+a|0)))break;if(o=(0|o)<0,1==(0|u)){o=0;break e}d=o?d:s,u=o?c:u-c|0}a=0|or(0|f[e+((o=l+_|0)<<2)>>2],n),o=(o=0|or(0|f[e+(o+1<<2)>>2],n))>>>0<r>>>0&a>>>0<(r-o|0)>>>0&&0==(0|t[e+(o+a)>>0])?e+o|0:0}else o=0}while(0);return 0|o}function _e(e){var r,i,n,t,o,a,u=0,l=0;a=m,m=m+576|0,t=a+48|0,o=a+32|0,i=a+16|0,r=a,n=a+64|0,u=0|f[(e|=0)+168>>2];do{if(0|u){if(l=0|f[u+-4>>2],u=u+-8|0,0!=(0|l)&&(0|l)==(0|~f[u>>2])||(f[r>>2]=866,f[r+4>>2]=651,f[r+8>>2]=1579,We(n,812,r),Le(n)),7&u){f[i>>2]=866,f[i+4>>2]=2506,f[i+8>>2]=1232,We(n,812,i),Le(n);break}Oe(u,0,0,1,0);break}}while(0);if(u=0|f[e+176>>2])return l=0|f[u+-4>>2],u=u+-8|0,0!=(0|l)&&(0|l)==(0|~f[u>>2])||(f[o>>2]=866,f[o+4>>2]=651,f[o+8>>2]=1579,We(n,812,o),Le(n)),7&u?(f[t>>2]=866,f[t+4>>2]=2506,f[t+8>>2]=1232,We(n,812,t),Le(n),void(m=a)):(Oe(u,0,0,1,0),void(m=a));m=a}function Ee(e,r,i){var n;return 0!=(0|(e|=0))&(r|=0)>>>0>73&0!=(0|(i|=0))?40!=(0|f[i>>2])||18552!=((0|c[e>>0])<<8|0|c[e+1>>0]|0)||((0|c[e+2>>0])<<8|0|c[e+3>>0])>>>0<74||((0|c[e+7>>0])<<16|(0|c[e+6>>0])<<24|(0|c[e+8>>0])<<8|0|c[e+9>>0])>>>0>r>>>0?0|(i=0):(f[i+4>>2]=(0|c[e+12>>0])<<8|0|c[e+13>>0],f[i+8>>2]=(0|c[e+14>>0])<<8|0|c[e+15>>0],f[i+12>>2]=c[e+16>>0],f[i+16>>2]=c[e+17>>0],f[(n=i+32|0)>>2]=c[(r=e+18|0)>>0],f[n+4>>2]=0,f[i+20>>2]=(r=0|t[r>>0])<<24>>24==0|r<<24>>24==9?8:16,f[i+24>>2]=(0|c[e+26>>0])<<16|(0|c[e+25>>0])<<24|(0|c[e+27>>0])<<8|0|c[e+28>>0],f[i+28>>2]=(0|c[e+30>>0])<<16|(0|c[e+29>>0])<<24|(0|c[e+31>>0])<<8|0|c[e+32>>0],0|(i=1)):0|(i=0)}function Te(e,r){e|=0;var i,n,t,o=0,a=0,u=0,l=0,s=0;if(t=m,m=m+544|0,s=t+16|0,o=t,l=t+32|0,(r|=0)>>>0>=33&&(f[o>>2]=866,f[o+4>>2]=3199,f[o+8>>2]=1350,We(l,812,o),Le(l)),(0|(o=0|f[(n=e+20|0)>>2]))>=(0|r))return u=a=e+16|0,l=o,s=(a=0|f[a>>2])>>>(s=32-r|0),f[u>>2]=a<<=r,f[n>>2]=r=l-r|0,m=t,0|s;a=e+4|0,u=e+8|0,i=e+16|0;do{(0|(e=0|f[a>>2]))==(0|f[u>>2])?e=0:(f[a>>2]=e+1,e=0|c[e>>0]),f[n>>2]=o=o+8|0,(0|o)>=33&&(f[s>>2]=866,f[s+4>>2]=3208,f[s+8>>2]=1366,We(l,812,s),Le(l),o=0|f[n>>2]),f[i>>2]=e=e<<32-o|f[i>>2]}while((0|o)<(0|r));return s=e>>>(s=32-r|0),f[i>>2]=l=e<<r,f[n>>2]=r=o-r|0,m=t,0|s}function Me(e,r,i){e|=0;var n=0,o=0,a=0,u=0;a=255&(r|=0),n=0!=(0|(i|=0));e:do{if(n&0!=(3&e|0))for(o=255&r;;){if((0|t[e>>0])==o<<24>>24){u=6;break e}if(!((n=0!=(0|(i=i+-1|0)))&0!=(3&(e=e+1|0)|0))){u=5;break}}else u=5}while(0);5==(0|u)&&(n?u=6:i=0);e:do{if(6==(0|u)&&(0|t[e>>0])!=(o=255&r)<<24>>24){n=0|v(a,16843009);r:do{if(i>>>0>3){for(;!((-2139062144&(a=f[e>>2]^n)^-2139062144)&a+-16843009|0);)if(e=e+4|0,(i=i+-4|0)>>>0<=3){u=11;break r}}else u=11}while(0);if(11==(0|u)&&!i){i=0;break}for(;;){if((0|t[e>>0])==o<<24>>24)break e;if(e=e+1|0,!(i=i+-1|0)){i=0;break}}}}while(0);return 0|(0|i?e:0)}function Ae(e,r,i,n,t){r|=0,i|=0,n|=0;var o,a,u,l=0,s=0,d=0;return u=m,m=m+528|0,d=u,s=u+16|0,(l=(l=(t|=0)+1|0)>>>0<(0|c[(o=0|f[(e|=0)+88>>2])+16>>0])>>>0?(0|c[o+70+(l<<2)+1>>0])<<16|(0|c[o+70+(l<<2)>>0])<<24|(0|c[o+70+(l<<2)+2>>0])<<8|0|c[o+70+(l<<2)+3>>0]:0|f[e+8>>2])>>>0>(a=(0|c[o+70+(t<<2)+1>>0])<<16|(0|c[o+70+(t<<2)>>0])<<24|(0|c[o+70+(t<<2)+2>>0])<<8|0|c[o+70+(t<<2)+3>>0])>>>0?(d=0|ae(e,s=(s=0|f[(s=e+4|0)>>2])+a|0,d=l-a|0,r,i,n,t),m=u,0|d):(f[d>>2]=866,f[d+4>>2]=3694,f[d+8>>2]=1508,We(s,812,d),Le(s),d=0|ae(e,s=(s=0|f[(s=e+4|0)>>2])+a|0,d=l-a|0,r,i,n,t),m=u,0|d)}function he(e,r,i){e|=0;var n=0,t=0;if(!(0==(0|(r|=0))|(i|=0)>>>0<74||18552!=((0|c[r>>0])<<8|0|c[r+1>>0]|0))&&((0|c[r+2>>0])<<8|0|c[r+3>>0])>>>0>=74&&((0|c[r+7>>0])<<16|(0|c[r+6>>0])<<24|(0|c[r+8>>0])<<8|0|c[r+9>>0])>>>0<=i>>>0){if(f[(n=e+88|0)>>2]=r,f[e+4>>2]=r,f[e+8>>2]=i,!(0|function(e){var r,i=0,n=0,t=0;if(t=(e|=0)+92|0,i=(0|f[e+4>>2])+((0|c[(n=0|f[(r=e+88|0)>>2])+68>>0])<<8|(0|c[n+67>>0])<<16|0|c[n+69>>0])|0,!(n=(0|c[n+65>>0])<<8|0|c[n+66>>0]))return 0|(t=0);if(f[t>>2]=i,f[e+96>>2]=i,f[e+104>>2]=n,f[e+100>>2]=i+n,f[e+108>>2]=0,f[e+112>>2]=0,!(0|X(t,e+116|0)))return 0|(t=0);i=0|f[r>>2];do{if((0|c[i+39>>0])<<8|0|c[i+40>>0]){if(!(0|X(t,e+140|0)))return 0|(t=0);if(0|X(t,e+188|0)){i=0|f[r>>2];break}return 0|(t=0)}if(!((0|c[i+55>>0])<<8|0|c[i+56>>0]))return 0|(t=0)}while(0);if((0|c[i+55>>0])<<8|0|c[i+56>>0]|0){if(!(0|X(t,e+164|0)))return 0|(t=0);if(!(0|X(t,e+212|0)))return 0|(t=0)}return 0|(t=1)}(e)))return 0|(t=0);if((0|c[(r=0|f[n>>2])+39>>0])<<8|0|c[r+40>>0]?0|$(e)&&0|Z(e)&&(r=0|f[n>>2],t=11):t=11,11==(0|t)){if(!((0|c[r+55>>0])<<8|0|c[r+56>>0]))return 0|(t=1);if(0|ne(e)&&0|J(e))return 0|(t=1)}return 0|(t=0)}return f[e+88>>2]=0,0|(t=0)}function be(e,r,i){e|=0,r|=0;var n=0,o=0,a=0,u=0,l=0;(o=0|f[(n=(i|=0)+16|0)>>2])?a=5:0|Fe(i)?n=0:(o=0|f[n>>2],a=5);e:do{if(5==(0|a)){if(n=u=0|f[(l=i+20|0)>>2],(o-u|0)>>>0<r>>>0){n=0|br[7&f[i+36>>2]](i,e,r);break}r:do{if((0|t[i+75>>0])>-1){for(u=r;;){if(!u){a=0,o=e;break r}if(10==(0|t[e+(o=u+-1|0)>>0]))break;u=o}if((n=0|br[7&f[i+36>>2]](i,e,u))>>>0<u>>>0)break e;a=u,o=e+u|0,r=r-u|0,n=0|f[l>>2]}else a=0,o=e}while(0);ue(0|n,0|o,0|r),f[l>>2]=(0|f[l>>2])+r,n=a+r|0}}while(0);return 0|n}function me(e,r,i){e|=0,r|=0,i|=0;do{if(e){if(r>>>0<128){t[e>>0]=r,e=1;break}if(i=188+(0|Tr())|0,!(0|f[f[i>>2]>>2])){if(57216==(-128&r|0)){t[e>>0]=r,e=1;break}e=0|Er(),f[e>>2]=84,e=-1;break}if(r>>>0<2048){t[e>>0]=r>>>6|192,t[e+1>>0]=63&r|128,e=2;break}if(r>>>0<55296|57344==(-8192&r|0)){t[e>>0]=r>>>12|224,t[e+1>>0]=r>>>6&63|128,t[e+2>>0]=63&r|128,e=3;break}if((r+-65536|0)>>>0<1048576){t[e>>0]=r>>>18|240,t[e+1>>0]=r>>>12&63|128,t[e+2>>0]=r>>>6&63|128,t[e+3>>0]=63&r|128,e=4;break}e=0|Er(),f[e>>2]=84,e=-1;break}e=1}while(0);return 0|e}function pe(e){var r,i,n=0,o=0,a=0;i=m,m=m+544|0,a=i+16|0,o=i,r=i+32|0,n=0|f[(e|=0)+20>>2];do{if(0|n){if(_e(n),7&n){f[o>>2]=866,f[o+4>>2]=2506,f[o+8>>2]=1232,We(r,812,o),Le(r);break}Oe(n,0,0,1,0);break}}while(0);if(!(o=0|f[(n=e+4|0)>>2]))return t[(a=e+16|0)>>0]=0,void(m=i);7&o?(f[a>>2]=866,f[a+4>>2]=2506,f[a+8>>2]=1232,We(r,812,a),Le(r)):Oe(o,0,0,1,0),f[n>>2]=0,f[e+8>>2]=0,f[e+12>>2]=0,t[(a=e+16|0)>>0]=0,m=i}function Se(e,r){r|=0;var i,n,t,o,a=0,u=0,l=0;return o=m,m=m+560|0,l=o+32|0,t=o+16|0,a=o,n=o+48|0,i=o+44|0,(u=0|(u=(e|=0)+3&-4)?u:4)>>>0>2147418112?(f[a>>2]=866,f[a+4>>2]=2506,f[a+8>>2]=1103,We(n,812,a),Le(n),m=o,0|(l=0)):(f[i>>2]=u,e=0|Oe(0,u,i,1,0),a=0|f[i>>2],0|r&&(f[r>>2]=a),0==(0|e)|a>>>0<u>>>0?(f[t>>2]=866,f[t+4>>2]=2506,f[t+8>>2]=1129,We(n,812,t),Le(n),e=0):7&e&&(f[l>>2]=866,f[l+4>>2]=2533,f[l+8>>2]=1156,We(n,812,l),Le(n)),m=o,0|(l=e))}function ve(e,r,i,n){e|=0,r|=0,i|=0,n|=0;var o,a,u=0,l=0,c=0,s=0,d=0;a=m,m=m+128|0,u=a+124|0,c=604,o=(l=d=a)+124|0;do{f[l>>2]=f[c>>2],l=l+4|0,c=c+4|0}while((0|l)<(0|o));return(r+-1|0)>>>0>2147483646?r?(r=0|Er(),f[r>>2]=75,r=-1):(e=u,r=1,s=4):s=4,4==(0|s)&&(f[d+48>>2]=s=r>>>0>(s=-2-e|0)>>>0?s:r,f[(u=d+20|0)>>2]=e,f[d+44>>2]=e,r=e+s|0,f[(e=d+16|0)>>2]=r,f[d+28>>2]=r,r=0|le(d,i,n),s&&(t[(d=0|f[u>>2])+(((0|d)==(0|f[e>>2]))<<31>>31)>>0]=0)),m=a,0|r}function ke(e,r,i){r|=0;var n,o=0,a=0,u=0;if(n=(e|=0)+(i|=0)|0,r&=255,(0|i)>=67){for(;3&e;)t[e>>0]=r,e=e+1|0;for(a=(o=-4&n|0)-64|0,u=r|r<<8|r<<16|r<<24;(0|e)<=(0|a);)f[e>>2]=u,f[e+4>>2]=u,f[e+8>>2]=u,f[e+12>>2]=u,f[e+16>>2]=u,f[e+20>>2]=u,f[e+24>>2]=u,f[e+28>>2]=u,f[e+32>>2]=u,f[e+36>>2]=u,f[e+40>>2]=u,f[e+44>>2]=u,f[e+48>>2]=u,f[e+52>>2]=u,f[e+56>>2]=u,f[e+60>>2]=u,e=e+64|0;for(;(0|e)<(0|o);)f[e>>2]=u,e=e+4|0}for(;(0|e)<(0|n);)t[e>>0]=r,e=e+1|0;return n-i|0}function Re(e,r,i,n,o){e|=0,i|=0,n|=0,o|=0;var a=0,u=0,l=0,c=0;t[(r|=0)+53>>0]=1;do{if((0|f[r+4>>2])==(0|n)){if(t[r+52>>0]=1,l=r+54|0,c=r+48|0,u=r+24|0,e=r+36|0,!(a=0|f[(n=r+16|0)>>2])){if(f[n>>2]=i,f[u>>2]=o,f[e>>2]=1,!(1==(0|f[c>>2])&1==(0|o)))break;t[l>>0]=1;break}if((0|a)!=(0|i)){f[e>>2]=1+(0|f[e>>2]),t[l>>0]=1;break}2==(0|(e=0|f[u>>2]))&&(f[u>>2]=o,e=o),1==(0|f[c>>2])&1==(0|e)&&(t[l>>0]=1)}}while(0)}function ye(e,r){e|=0;var i,n,o,a=0,u=0,l=0,s=0;o=m,m=m+16|0,t[(i=o)>>0]=n=255&(r|=0),(l=0|f[(u=e+16|0)>>2])?s=4:0|Fe(e)?a=-1:(l=0|f[u>>2],s=4);do{if(4==(0|s)){if((u=0|f[(s=e+20|0)>>2])>>>0<l>>>0&&(0|(a=255&r))!=(0|t[e+75>>0])){f[s>>2]=u+1,t[u>>0]=n;break}a=1==(0|br[7&f[e+36>>2]](e,i,1))?0|c[i>>0]:-1}}while(0);return m=o,0|a}function ge(e,r){r|=0;var i,n=0,o=0,a=0,u=0;i=255&(e|=0),n=255&e,u=3;do{if(3==(0|u)){if((0|n)!=(0|t[r+75>>0])&&(a=0|f[(o=r+20|0)>>2])>>>0<(0|f[r+16>>2])>>>0){f[o>>2]=a+1,t[a>>0]=i;break}n=0|ye(r,e)}}while(0);return 0|n}function Oe(e,r,i,n,t){e|=0,r|=0,i|=0,n|=0,t|=0;do{if(e){if(!r){if(W(e),!i){r=0;break}f[i>>2]=0,r=0;break}n?e=0==(0|(r=0|Ne(e,r)))?e:r:r=0,i&&(t=0|Ke(e),f[i>>2]=t)}else r=0|B(r),i&&(e=r?0|Ke(r):0,f[i>>2]=e)}while(0);return 0|r}function we(e){var r,i=0,n=0;r=e|=0;e:do{if(3&r)for(i=r;;){if(!(0|t[e>>0])){e=i;break e}if(!(3&(i=e=e+1|0))){n=4;break}}else n=4}while(0);if(4==(0|n)){for(;!((-2139062144&(i=0|f[e>>2])^-2139062144)&i+-16843009);)e=e+4|0;if((255&i)<<24>>24)do{e=e+1|0}while(0!=(0|t[e>>0]))}return e-r|0}function Pe(e,r){e|=0,r|=0;var i=0,n=0;for(n=0;;){if((0|c[2140+n>>0])==(0|e)){e=2;break}if(87==(0|(i=n+1|0))){i=2228,n=87,e=5;break}n=i}if(2==(0|e)&&(n?(i=2228,e=5):i=2228),5==(0|e))for(;;){do{e=i,i=i+1|0}while(0!=(0|t[e>>0]));if(!(n=n+-1|0))break;e=5}return 0|function(e,r){return 0|function(e,r){e|=0,r=(r|=0)?0|de(0|f[r>>2],0|f[r+4>>2],e):0;return 0|(0|r?r:e)}(e|=0,r|=0)}(i,0|f[r+20>>2])}function Ce(e,r,i){i|=0;var n=0;if((r|=0)>>>0>0|0==(0|r)&(e|=0)>>>0>4294967295){for(;n=0|Ge(0|e,0|r,10,0),t[(i=i+-1|0)>>0]=255&n|48,n=e,e=0|ar(0|e,0|r,10,0),r>>>0>9|9==(0|r)&n>>>0>4294967295;)r=S;r=e}else r=e;if(r)for(;t[(i=i+-1|0)>>0]=48|(r>>>0)%10,!(r>>>0<10);)r=(r>>>0)/10|0;return 0|i}function Ne(e,r){r|=0;var i=0,n=0;return(e|=0)?r>>>0>4294967231?(r=0|Er(),f[r>>2]=12,0|(r=0)):0|(i=0|function(e,r){r|=0;var i,n,t=0,o=0,a=0,u=0,l=0,c=0,s=0,d=0;if(i=(e|=0)+(t=-8&(s=0|f[(d=e+4|0)>>2]))|0,!(3&s))return r>>>0<256?0|(e=0):t>>>0>=(r+4|0)>>>0&&(t-r|0)>>>0<=f[1264]<<1>>>0?0|e:0|(e=0);if(t>>>0>=r>>>0)return(t=t-r|0)>>>0<=15||(c=e+r|0,f[d>>2]=1&s|r|2,f[c+4>>2]=3|t,f[(d=c+t+4|0)>>2]=1|f[d>>2],j(c,t)),0|e;if((0|i)==(0|f[1150]))return t=(c=(0|f[1147])+t|0)-r|0,o=e+r|0,c>>>0<=r>>>0?0|(e=0):(f[d>>2]=1&s|r|2,f[o+4>>2]=1|t,f[1150]=o,f[1147]=t,0|e);if((0|i)==(0|f[1149]))return(a=(0|f[1146])+t|0)>>>0<r>>>0?0|(e=0):(o=1&s,(t=a-r|0)>>>0>15?(c=(s=e+r|0)+t|0,f[d>>2]=o|r|2,f[s+4>>2]=1|t,f[c>>2]=t,f[(o=c+4|0)>>2]=-2&f[o>>2],o=s):(f[d>>2]=o|a|2,f[(o=e+a+4|0)>>2]=1|f[o>>2],o=0,t=0),f[1146]=t,f[1149]=o,0|e);if(2&(o=0|f[i+4>>2])|0)return 0|(e=0);if((n=(-8&o)+t|0)>>>0<r>>>0)return 0|(e=0);c=n-r|0,a=o>>>3;do{if(o>>>0<256){if((0|(t=0|f[i+12>>2]))==(0|(o=0|f[i+8>>2]))){f[1144]=f[1144]&~(1<<a);break}f[o+12>>2]=t,f[t+8>>2]=o;break}l=0|f[i+24>>2],t=0|f[i+12>>2];do{if((0|t)==(0|i)){if(t=0|f[(o=(a=i+16|0)+4|0)>>2])u=o;else{if(!(t=0|f[a>>2])){a=0;break}u=a}for(;;)if(0|(o=0|f[(a=t+20|0)>>2]))t=o,u=a;else{if(!(a=0|f[(o=t+16|0)>>2]))break;t=a,u=o}f[u>>2]=0,a=t}else f[(a=0|f[i+8>>2])+12>>2]=t,f[t+8>>2]=a,a=t}while(0);if(0|l){if((0|i)==(0|f[(o=4880+((t=0|f[i+28>>2])<<2)|0)>>2])){if(f[o>>2]=a,!a){f[1145]=f[1145]&~(1<<t);break}}else if(f[l+16+(((0|f[l+16>>2])!=(0|i)&1)<<2)>>2]=a,!a)break;f[a+24>>2]=l,0|(o=0|f[(t=i+16|0)>>2])&&(f[a+16>>2]=o,f[o+24>>2]=a),0|(t=0|f[t+4>>2])&&(f[a+20>>2]=t,f[t+24>>2]=a)}}while(0);return t=1&s,c>>>0<16?(f[d>>2]=n|t|2,f[(d=e+n+4|0)>>2]=1|f[d>>2],0|e):(s=e+r|0,f[d>>2]=t|r|2,f[s+4>>2]=3|c,f[(d=s+c+4|0)>>2]=1|f[d>>2],j(s,c),0|e)}(e+-8|0,r>>>0<11?16:r+11&-8))?0|(r=i+8|0):(i=0|B(r))?(ue(0|i,0|e,0|((n=(-8&(n=0|f[e+-4>>2]))-(0==(3&n|0)?8:4)|0)>>>0<r>>>0?n:r)),W(e),0|(r=i)):0|(r=0):0|(r=0|B(r))}function Ie(e,r,i,n){e|=0,i|=0,n|=0;var o,a,u;o=0|f[(e=(r|=0)+16|0)>>2],a=r+36|0,u=r+24|0;do{if(o){if((0|o)!=(0|i)){f[a>>2]=1+(0|f[a>>2]),f[u>>2]=2,t[r+54>>0]=1;break}2==(0|f[u>>2])&&(f[u>>2]=n)}else f[e>>2]=i,f[u>>2]=n,f[a>>2]=1}while(0)}function Le(e){e|=0;var r,i=0,n=0;r=0|f[119];do{if((0|er(e,r))<0)e=1;else{if(10!=(0|t[r+75>>0])&&(n=0|f[(i=r+20|0)>>2])>>>0<(0|f[r+16>>2])>>>0){f[i>>2]=n+1,t[n>>0]=10,e=0;break}e=(0|ye(r,10))<0}}while(0);return e<<31>>31|0}function De(e,r,i,n,t){e|=0,r|=0;var o,a;if(a=m,m=m+256|0,o=a,(0|(i|=0))>(0|(n|=0))&0==(73728&(t|=0)|0)){if(ke(0|o,0|r,0|((t=i-n|0)>>>0<256?t:256)),t>>>0>255){r=i-n|0;do{rr(e,o,256),t=t+-256|0}while(t>>>0>255);t=255&r}rr(e,o,t)}m=a}function Fe(e){var r=0,i=0;return t[(r=(e|=0)+74|0)>>0]=(i=0|t[r>>0])+255|i,8&(r=0|f[e>>2])?(f[e>>2]=32|r,e=-1):(f[e+8>>2]=0,f[e+4>>2]=0,f[e+28>>2]=i=0|f[e+44>>2],f[e+20>>2]=i,f[e+16>>2]=i+(0|f[e+48>>2]),e=0),0|e}function Ue(e,r){var i=0,n=0;if(n=0|t[(r|=0)>>0],(i=0|t[(e|=0)>>0])<<24>>24==0||i<<24>>24!=n<<24>>24)e=n;else{do{i=0|t[(e=e+1|0)>>0],n=0|t[(r=r+1|0)>>0]}while(i<<24>>24!=0&&i<<24>>24==n<<24>>24);e=n}return(255&i)-(255&e)|0}function He(e){var r,i;return(0|(i=(e|=0)+15&-16|0))>0&(0|(e=(r=0|f[h>>2])+i|0))<(0|r)|(0|e)<0?(O(),I(12),-1):(f[h>>2]=e,(0|e)>(0|g())&&0==(0|y())?(f[h>>2]=r,I(12),-1):0|r)}function xe(e){var r=0,i=0,n=0;if((n=(0|t[(i=0|f[(e|=0)>>2])>>0])-48|0)>>>0<10){r=0;do{r=n+(10*r|0)|0,f[e>>2]=i=i+1|0,n=(0|t[i>>0])-48|0}while(n>>>0<10)}else r=0;return 0|r}function Be(e,r,i,n){if(i|=0,n|=0,!(0==(0|(e|=0))&0==(0|(r|=0))))do{t[(i=i+-1|0)>>0]=0|c[2122+(15&e)>>0]|n,e=0|je(0|e,0|r,4),r=S}while(!(0==(0|e)&0==(0|r)));return 0|i}function Ye(e){var r=0;return(0|(r=0|t[p+(255&(e|=0))>>0]))<8?0|r:(0|(r=0|t[p+(e>>8&255)>>0]))<8?r+8|0:(0|(r=0|t[p+(e>>16&255)>>0]))<8?r+16|0:24+(0|t[p+(e>>>24)>>0])|0}function Ve(e,r,i,n){n|=0;var t=0;(0|f[(r|=0)+4>>2])==(0|(i|=0))&&1!=(0|f[(t=r+28|0)>>2])&&(f[t>>2]=n)}function Xe(e,r,i){if(i|=0,!(0==(0|(e|=0))&0==(0|(r|=0))))do{t[(i=i+-1|0)>>0]=7&e|48,e=0|je(0|e,0|r,3),r=S}while(!(0==(0|e)&0==(0|r)));return 0|i}function Ge(e,r,i,n){var t,o;return o=m,m=m+16|0,Q(e|=0,r|=0,i|=0,n|=0,t=0|o),m=o,0|(S=0|f[t+4>>2],0|f[t>>2])}function Ke(e){var r=0;return(e|=0)?0|(1==(0|(e=3&(r=0|f[e+-4>>2])))?0:(-8&r)-(0==(0|e)?8:4)|0):0}function We(e,r,i){e|=0,r|=0;var n,t;return n=m,m=m+16|0,f[(t=n)>>2]=i|=0,i=0|function(e,r,i){return 0|ve(e|=0,2147483647,r|=0,i|=0)}(e,r,t),m=n,0|i}function ze(e,r,i){return e|=0,r|=0,(0|(i|=0))<32?(S=r<<i|(e&(1<<i)-1<<32-i)>>>32-i,e<<i):(S=e<<i-32,0)}function je(e,r,i){return e|=0,r|=0,(0|(i|=0))<32?(S=r>>>i,e>>>i|(r&(1<<i)-1)<<32-i):(S=0,r>>>i-32|0)}function Je(e,r){e|=0;var i;i=m,m=m+16|0,f[i>>2]=r|=0,le(r=0|f[26],e,i),ge(10,r),L()}function Ze(e,r,i,n){return 0|(S=n=(r|=0)-(n|=0)-((i|=0)>>>0>(e|=0)>>>0|0)>>>0,e-i>>>0|0)}function qe(e){return M[b>>3]=e=+e,S=0|f[b+4>>2],0|(0|f[b>>2])}function Qe(e,r,i,n){return 0|(S=(r|=0)+(n|=0)+((i=(e|=0)+(i|=0)>>>0)>>>0<e>>>0|0)>>>0,0|i)}function $e(e){var r=0;return(e|=0)>>>0>4294963200&&(r=0|Er(),f[r>>2]=0-e,e=-1),0|e}function er(e,r){r|=0;var i;return((0|function(e,r,i,n){var t;return e|=0,n|=0,t=0|v(i|=0,r|=0),i=0==(0|r)?0:i,(0|(e=0|be(e,t,n)))!=(0|t)&&(i=(e>>>0)/(r>>>0)|0),0|i}(e|=0,1,i=0|we(e),r))!=(0|i))<<31>>31|0}function rr(e,r,i){r|=0,i|=0,32&f[(e|=0)>>2]||be(r,i,e)}function ir(e){e|=0;var r;return r=188+(0|Tr())|0,0|Pe(e,0|f[r>>2])}function nr(e,r){return r|=0,0|(e=(e|=0)?0|me(e,r,0):0)}function tr(e,r,i){return(0|(e|=0))==(0|(r|=0))|0}function or(e,r){r|=0;var i;return i=0|ur(0|(e|=0)),0|(0==(0|r)?e:i)}function ar(e,r,i,n){return 0|Q(e|=0,r|=0,i|=0,n|=0,0)}function ur(e){return(255&(e|=0))<<24|(e>>8&255)<<16|(e>>16&255)<<8|e>>>24|0}function fr(e,r,i,n,t,o){R(6)}function lr(e,r,i,n,t){R(1)}function cr(e){!function(e){W(e|=0)}(e|=0)}function sr(e,r,i,n){R(7)}function dr(e,r,i){return R(0),0}function _r(e,r){return+ +function e(r,i){i|=0;var n,t,o=0;switch(M[b>>3]=r=+r,2047&(t=0|je(0|(o=0|f[b>>2]),0|(n=0|f[b+4>>2]),52))){case 0:0!=r?(r=+e(0x10000000000000000*r,i),o=(0|f[i>>2])-64|0):o=0,f[i>>2]=o;break;case 2047:break;default:f[i>>2]=(2047&t)-1022,f[b>>2]=o,f[b+4>>2]=-2146435073&n|1071644672,r=+M[b>>3]}return+r}(e=+e,r|=0)}function Er(){return 64+(0|Tr())|0}function Tr(){return 232}function Mr(e){}function Ar(e){R(2)}function hr(){R(5)}var br=[dr,fe,function(e,r,i){var n,t,o;return r|=0,i|=0,t=m,m=m+32|0,n=t+20|0,f[(o=t)>>2]=f[(e|=0)+60>>2],f[o+4>>2]=0,f[o+8>>2]=r,f[o+12>>2]=n,f[o+16>>2]=i,(0|$e(0|H(140,0|o)))<0?(f[n>>2]=-1,e=-1):e=0|f[n>>2],m=t,0|e},function(e,r,i){r|=0,i|=0;var n,o=0;return n=m,m=m+32|0,o=n,f[(e|=0)+36>>2]=1,0==(64&f[e>>2]|0)&&(f[o>>2]=f[e+60>>2],f[o+4>>2]=21523,f[o+8>>2]=n+16,0|P(54,0|o))&&(t[e+75>>0]=-1),o=0|fe(e,r,i),m=n,0|o},function(e,r,i){var n,t;return ue(0|(t=0|f[(n=(e|=0)+20|0)>>2]),0|(r|=0),0|(e=(e=(0|f[e+16>>2])-t|0)>>>0>(i|=0)>>>0?i:e)),f[n>>2]=(0|f[n>>2])+e,0|i},function(e,r,i){i|=0;var n,t,o=0,a=0;if(t=m,m=m+64|0,n=t,0|tr(e|=0,r|=0))r=1;else if(0!=(0|r)&&0!=(0|(a=0|ce(r,32,16,0)))){o=(r=n+4|0)+52|0;do{f[r>>2]=0,r=r+4|0}while((0|r)<(0|o));f[n>>2]=a,f[n+8>>2]=e,f[n+12>>2]=-1,f[n+48>>2]=1,yr[3&f[28+(0|f[a>>2])>>2]](a,n,0|f[i>>2],1),1==(0|f[n+24>>2])?(f[i>>2]=f[n+16>>2],r=1):r=0}else r=0;return m=t,0|r},dr,dr],mr=[lr,function(e,r,i,n,o){e|=0,r|=0,i|=0,n|=0;var a=0;do{if(0|tr(e,0|f[r+8>>2]))Ve(0,r,i,n);else if(0|tr(e,0|f[r>>2])){if(e=r+32|0,(0|f[r+16>>2])!=(0|i)&&(0|f[(a=r+20|0)>>2])!=(0|i)){f[e>>2]=n,f[a>>2]=i,f[(n=r+40|0)>>2]=1+(0|f[n>>2]),1==(0|f[r+36>>2])&&2==(0|f[r+24>>2])&&(t[r+54>>0]=1),f[r+44>>2]=4;break}1==(0|n)&&(f[e>>2]=1)}}while(0)},function(e,r,i,n,o){e|=0,r|=0,i|=0,n|=0,o|=0;var a=0,u=0,l=0,c=0;do{if(0|tr(e,0|f[r+8>>2]))Ve(0,r,i,n);else{if(a=e+8|0,!(0|tr(e,0|f[r>>2]))){mr[3&f[24+(0|f[(l=0|f[a>>2])>>2])>>2]](l,r,i,n,o);break}if(e=r+32|0,(0|f[r+16>>2])!=(0|i)&&(0|f[(u=r+20|0)>>2])!=(0|i)){if(f[e>>2]=n,4==(0|f[(n=r+44|0)>>2]))break;t[(e=r+52|0)>>0]=0,t[(c=r+53|0)>>0]=0,Rr[3&f[20+(0|f[(a=0|f[a>>2])>>2])>>2]](a,r,i,i,1,o),0|t[c>>0]?0|t[e>>0]?e=3:(e=3,l=11):(e=4,l=11),11==(0|l)&&(f[u>>2]=i,f[(c=r+40|0)>>2]=1+(0|f[c>>2]),1==(0|f[r+36>>2])&&2==(0|f[r+24>>2])&&(t[r+54>>0]=1)),f[n>>2]=e;break}1==(0|n)&&(f[e>>2]=1)}}while(0)},lr],pr=[Ar,Mr,cr,Mr,Mr,cr,function(e){var r;r=m,m=m+16|0,W(e|=0),0|C(0|f[1285],0)?Je(4406,r):m=r},Ar],Sr=[function(e){return R(3),0},function(e){var r,i;return r=m,m=m+16|0,i=r,e=0|function(e){return 0|(e|=0)}(0|f[(e|=0)+60>>2]),f[i>>2]=e,e=0|$e(0|N(6,0|i)),m=r,0|e}],vr=[function(e,r,i){R(4)}],kr=[hr,function(){var e,r,i,n=0,t=0,o=0,a=0,u=0;a=m,m=m+48|0,i=a+32|0,e=a+24|0,u=a+16|0,r=a,a=a+36|0,0|(n=0|function(){var e,r=0;if(e=m,m=m+16|0,!(0|D(5136,2)))return r=0|w(0|f[1285]),m=e,0|r;Je(4307,e);return 0}())&&0|(o=0|f[n>>2])&&(1126902528==(-256&(t=0|f[(n=o+48|0)>>2])|0)&1129074247==(0|(n=0|f[n+4>>2]))||(f[e>>2]=4168,Je(4118,e)),f[a>>2]=n=1126902529==(0|t)&1129074247==(0|n)?0|f[o+44>>2]:o+80|0,n=0|f[(o=0|f[o>>2])+4>>2],0|br[7&f[16+(0|f[2])>>2]](8,o,a)?(u=0|Sr[1&f[8+(0|f[(u=0|f[a>>2])>>2])>>2]](u),f[r>>2]=4168,f[r+4>>2]=n,f[r+8>>2]=u,Je(4032,r)):(f[u>>2]=4168,f[u+4>>2]=n,Je(4077,u))),Je(4156,i)},function(){var e;e=m,m=m+16|0,0|U(5140,6)?Je(4356,e):m=e},hr],Rr=[fr,function(e,r,i,n,t,o){i|=0,n|=0,t|=0,0|tr(e|=0,0|f[(r|=0)+8>>2])&&Re(0,r,i,n,t)},function(e,r,i,n,t,o){i|=0,n|=0,t|=0,o|=0,0|tr(e|=0,0|f[(r|=0)+8>>2])?Re(0,r,i,n,t):Rr[3&f[20+(0|f[(e=0|f[e+8>>2])>>2])>>2]](e,r,i,n,t,o)},fr],yr=[sr,function(e,r,i,n){i|=0,n|=0,0|tr(e|=0,0|f[(r|=0)+8>>2])&&Ie(0,r,i,n)},function(e,r,i,n){i|=0,n|=0,0|tr(e|=0,0|f[(r|=0)+8>>2])?Ie(0,r,i,n):yr[3&f[28+(0|f[(e=0|f[e+8>>2])>>2])>>2]](e,r,i,n)},sr];return{stackSave:function(){return 0|m},_i64Subtract:Ze,_crn_get_bytes_per_block:function(e,r){e|=0,r|=0;var i,n,t,o=0;switch(t=m,m=m+576|0,n=t+40|0,i=t+56|0,f[(o=t)>>2]=40,Ee(e,r,o),e=0|f[(r=o+32|0)+4>>2],0|f[r>>2]){case 0:if(!e)return m=t,0|(o=8);e=14;break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:e=e?14:13;break;case 9:case 10:if(!e)return m=t,0|(o=8);e=14;break;default:e=14}return 13==(0|e)?(m=t,0|(o=16)):14==(0|e)?(f[n>>2]=866,f[n+4>>2]=2672,f[n+8>>2]=1251,We(i,812,n),Le(i),m=t,0|(o=0)):0},setThrew:function(e,r){},dynCall_viii:function(e,r,i,n){vr[0&(e|=0)](0|(r|=0),0|(i|=0),0|(n|=0))},_bitshift64Lshr:je,_bitshift64Shl:ze,dynCall_viiii:function(e,r,i,n,t){yr[3&(e|=0)](0|(r|=0),0|(i|=0),0|(n|=0),0|(t|=0))},setTempRet0:function(e){S=e|=0},_crn_decompress:function(e,r,i,n,t,o){e|=0,r|=0,i|=0,n|=0,t|=0,o|=0;var a,u,l,c,s=0,d=0,_=0,E=0,T=0;switch(c=m,m=m+592|0,l=c+56|0,_=c+40|0,a=c+72|0,u=c+68|0,f[(T=c)>>2]=40,Ee(e,r,T),s=(0|f[T+4>>2])>>>t,d=(0|f[T+8>>2])>>>t,n=0|f[(T=T+32|0)+4>>2],0|f[T>>2]){case 0:n?E=14:T=8;break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:E=n?14:13;break;case 9:case 10:n?E=14:T=8;break;default:E=14}13==(0|E)?T=16:14==(0|E)&&(f[_>>2]=866,f[_+4>>2]=2672,f[_+8>>2]=1251,We(a,812,_),Le(a),T=0),f[u>>2]=i,E=0|oe(e,r),r=o+t|0;do{if(r>>>0>t>>>0){if(!E){for(n=i;n=n+(0|v(0|v((s+3|0)>>>2,T),(d+3|0)>>>2))|0,(0|(t=t+1|0))!=(0|r);)d>>>=1,s>>>=1;f[u>>2]=n;break}for(e=d,n=i;d=0|v((s+3|0)>>>2,T),t>>>0>15|(_=0|v(d,(e+3|0)>>>2))>>>0<8||519686845!=(0|f[E>>2])||(Ae(E,u,_,d,t),n=0|f[u>>2]),f[u>>2]=n=n+_|0,(0|(t=t+1|0))!=(0|r);)e>>>=1,s>>>=1}}while(0);if(E){if(519686845==(0|f[E>>2]))return re(E),7&E?(f[l>>2]=866,f[l+4>>2]=2506,f[l+8>>2]=1232,We(a,812,l),Le(a),void(m=c)):(Oe(E,0,0,1,0),void(m=c));m=c}else m=c},_memset:ke,_sbrk:He,_memcpy:ue,stackAlloc:function(e){var r;return r=m,m=(m=m+(e|=0)|0)+15&-16,0|r},_crn_get_height:function(e,r){var i,n;return e|=0,r|=0,n=m,m=m+48|0,f[(i=n)>>2]=40,Ee(e,r,i),m=n,0|f[i+8>>2]},dynCall_vi:function(e,r){pr[7&(e|=0)](0|(r|=0))},getTempRet0:function(){return 0|S},_crn_get_levels:function(e,r){var i,n;return e|=0,r|=0,n=m,m=m+48|0,f[(i=n)>>2]=40,Ee(e,r,i),m=n,0|f[i+12>>2]},_crn_get_uncompressed_size:function(e,r,i){e|=0,r|=0,i|=0;var n,t,o,a,u=0,l=0;switch(a=m,m=m+576|0,o=a+40|0,t=a+56|0,f[(l=a)>>2]=40,Ee(e,r,l),n=(3+((0|f[l+4>>2])>>>i)|0)>>>2,r=(3+((0|f[l+8>>2])>>>i)|0)>>>2,e=0|f[(i=l+32|0)+4>>2],0|f[i>>2]){case 0:e?u=14:e=8;break;case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:u=e?14:13;break;case 9:case 10:e?u=14:e=8;break;default:u=14}return 13==(0|u)?e=16:14==(0|u)&&(f[o>>2]=866,f[o+4>>2]=2672,f[o+8>>2]=1251,We(t,812,o),Le(t),e=0),l=0|v(0|v(r,n),e),m=a,0|l},_i64Add:Qe,dynCall_iiii:function(e,r,i,n){return 0|br[7&(e|=0)](0|(r|=0),0|(i|=0),0|(n|=0))},_emscripten_get_global_libc:function(){return 5072},dynCall_ii:function(e,r){return 0|Sr[1&(e|=0)](0|(r|=0))},___udivdi3:ar,_llvm_bswap_i32:ur,dynCall_viiiii:function(e,r,i,n,t,o){mr[3&(e|=0)](0|(r|=0),0|(i|=0),0|(n|=0),0|(t|=0),0|(o|=0))},___cxa_can_catch:function(e,r,i){var n,t;return e|=0,r|=0,t=m,m=m+16|0,f[(n=t)>>2]=f[(i|=0)>>2],(e=0|br[7&f[16+(0|f[e>>2])>>2]](e,r,n))&&(f[i>>2]=f[n>>2]),m=t,1&e|0},_free:W,runPostSets:function(){},dynCall_viiiiii:function(e,r,i,n,t,o,a){Rr[3&(e|=0)](0|(r|=0),0|(i|=0),0|(n|=0),0|(t|=0),0|(o|=0),0|(a|=0))},establishStackSpace:function(e,r){m=e|=0},___uremdi3:Ge,___cxa_is_pointer_type:function(e){return 1&(e=(e|=0)?0!=(0|ce(e,32,88,0)):0)|0},stackRestore:function(e){m=e|=0},_malloc:B,_emscripten_replace_memory:function(e){return!(16777215&A(e)||A(e)<=16777215||A(e)>2147483648)&&(t=new n(e),a=new o(e),f=new u(e),c=new l(e),d=new s(e),new _(e),new E(e),M=new T(e),i=e,!0)},dynCall_v:function(e){kr[3&(e|=0)]()},_crn_get_width:function(e,r){var i,n;return e|=0,r|=0,n=m,m=m+48|0,f[(i=n)>>2]=40,Ee(e,r,i),m=n,0|f[i+4>>2]},_crn_get_dxt_format:function(e,r){var i,n;return e|=0,r|=0,n=m,m=m+48|0,f[(i=n)>>2]=40,Ee(e,r,i),m=n,0|f[i+32>>2]}}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer);Module.stackSave=asm.stackSave,Module.getTempRet0=asm.getTempRet0,Module._memset=asm._memset,Module.setThrew=asm.setThrew,Module._bitshift64Lshr=asm._bitshift64Lshr,Module._bitshift64Shl=asm._bitshift64Shl,Module.setTempRet0=asm.setTempRet0,Module._crn_decompress=asm._crn_decompress,Module._crn_get_bytes_per_block=asm._crn_get_bytes_per_block,Module._sbrk=asm._sbrk,Module._memcpy=asm._memcpy,Module.stackAlloc=asm.stackAlloc,Module._crn_get_height=asm._crn_get_height,Module._i64Subtract=asm._i64Subtract,Module._crn_get_levels=asm._crn_get_levels,Module._crn_get_uncompressed_size=asm._crn_get_uncompressed_size,Module._i64Add=asm._i64Add,Module._emscripten_get_global_libc=asm._emscripten_get_global_libc,Module.___udivdi3=asm.___udivdi3,Module._llvm_bswap_i32=asm._llvm_bswap_i32,Module.___cxa_can_catch=asm.___cxa_can_catch;var _free=Module._free=asm._free;Module.runPostSets=asm.runPostSets,Module.establishStackSpace=asm.establishStackSpace,Module.___uremdi3=asm.___uremdi3,Module.___cxa_is_pointer_type=asm.___cxa_is_pointer_type,Module.stackRestore=asm.stackRestore;var _malloc=Module._malloc=asm._malloc,_emscripten_replace_memory=Module._emscripten_replace_memory=asm._emscripten_replace_memory,initialStackTop;function ExitStatus(e){this.name="ExitStatus",this.message="Program terminated with exit("+e+")",this.status=e}function run(e){function r(){Module.calledRun||(Module.calledRun=!0,ABORT||(ensureInitRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),Module._main&&shouldRunNow&&Module.callMain(e),postRun()))}e=e||Module.arguments,runDependencies>0||(preRun(),runDependencies>0||Module.calledRun||(Module.setStatus?(Module.setStatus("Running..."),setTimeout((function(){setTimeout((function(){Module.setStatus("")}),1),r()}),1)):r()))}function exit(e,r){r&&Module.noExitRuntime||(Module.noExitRuntime||(ABORT=!0,STACKTOP=initialStackTop,exitRuntime(),Module.onExit&&Module.onExit(e)),ENVIRONMENT_IS_NODE&&process.exit(e),Module.quit(e,new ExitStatus(e)))}Module._crn_get_width=asm._crn_get_width,Module._crn_get_dxt_format=asm._crn_get_dxt_format,Module.dynCall_iiii=asm.dynCall_iiii,Module.dynCall_viiiii=asm.dynCall_viiiii,Module.dynCall_vi=asm.dynCall_vi,Module.dynCall_ii=asm.dynCall_ii,Module.dynCall_viii=asm.dynCall_viii,Module.dynCall_v=asm.dynCall_v,Module.dynCall_viiiiii=asm.dynCall_viiiiii,Module.dynCall_viiii=asm.dynCall_viiii,Runtime.stackAlloc=Module.stackAlloc,Runtime.stackSave=Module.stackSave,Runtime.stackRestore=Module.stackRestore,Runtime.establishStackSpace=Module.establishStackSpace,Runtime.setTempRet0=Module.setTempRet0,Runtime.getTempRet0=Module.getTempRet0,Module.asm=asm,ExitStatus.prototype=new Error,ExitStatus.prototype.constructor=ExitStatus,dependenciesFulfilled=function e(){Module.calledRun||run(),Module.calledRun||(dependenciesFulfilled=e)},Module.callMain=Module.callMain=function(e){e=e||[],ensureInitRuntime();var r=e.length+1;function i(){for(var e=0;e<3;e++)n.push(0)}var n=[allocate(intArrayFromString(Module.thisProgram),"i8",ALLOC_NORMAL)];i();for(var t=0;t<r-1;t+=1)n.push(allocate(intArrayFromString(e[t]),"i8",ALLOC_NORMAL)),i();n.push(0),n=allocate(n,"i32",ALLOC_NORMAL);try{exit(Module._main(r,n,0),!0)}catch(e){if(e instanceof ExitStatus)return;if("SimulateInfiniteLoop"==e)return void(Module.noExitRuntime=!0);var o=e;e&&"object"==typeof e&&e.stack&&(o=[e,e.stack]),Module.printErr("exception thrown: "+o),Module.quit(1,e)}},Module.run=Module.run=run,Module.exit=Module.exit=exit;var abortDecorators=[];function abort(e){Module.onAbort&&Module.onAbort(e),void 0!==e?(Module.print(e),Module.printErr(e),e=JSON.stringify(e)):e="",ABORT=!0;var r="abort("+e+") at "+stackTrace()+"\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.";throw abortDecorators&&abortDecorators.forEach((function(i){r=i(r,e)})),r}if(Module.abort=Module.abort=abort,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),Module.noExitRuntime=!0,run();var crunch=Module;function isNil(e){return null==e}
/*!
     * @license
     *
     * Copyright (c) 2014, Brandon Jones. All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without modification,
     * are permitted provided that the following conditions are met:
     *
     *  * Redistributions of source code must retain the above copyright notice, this
     *  list of conditions and the following disclaimer.
     *  * Redistributions in binary form must reproduce the above copyright notice,
     *  this list of conditions and the following disclaimer in the documentation
     *  and/or other materials provided with the distribution.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
     * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
     * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
     * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
     * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     */const PixelFormat={RGB_DXT1:33776,RGBA_DXT1:33777,RGBA_DXT3:33778,RGBA_DXT5:33779,RGB_ETC1:36196,RGB_PVRTC_4BPPV1:35840,RGB_PVRTC_2BPPV1:35841,RGBA_PVRTC_4BPPV1:35842,RGBA_PVRTC_2BPPV1:35843,compressedTextureSizeInBytes:function(e,r,i){switch(e){case PixelFormat.RGB_DXT1:case PixelFormat.RGBA_DXT1:case PixelFormat.RGB_ETC1:return Math.floor((r+3)/4)*Math.floor((i+3)/4)*8;case PixelFormat.RGBA_DXT3:case PixelFormat.RGBA_DXT5:return Math.floor((r+3)/4)*Math.floor((i+3)/4)*16;case PixelFormat.RGB_PVRTC_4BPPV1:case PixelFormat.RGBA_PVRTC_4BPPV1:return Math.floor((Math.max(r,8)*Math.max(i,8)*4+7)/8);case PixelFormat.RGB_PVRTC_2BPPV1:case PixelFormat.RGBA_PVRTC_2BPPV1:return Math.floor((Math.max(r,16)*Math.max(i,8)*2+7)/8);default:return 0}}},CRN_FORMAT={cCRNFmtInvalid:-1,cCRNFmtDXT1:0,cCRNFmtDXT3:1,cCRNFmtDXT5:2},DXT_FORMAT_MAP={};let dst,dxtData;DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT1]=PixelFormat.RGB_DXT1,DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT3]=PixelFormat.RGBA_DXT3,DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT5]=PixelFormat.RGBA_DXT5;let cachedDstSize=0;function arrayBufferCopy(e,r,i,n){let t;const o=i/4,a=n%4,u=new Uint32Array(e.buffer,0,(n-a)/4),f=new Uint32Array(r.buffer);for(t=0;t<u.length;t++)f[o+t]=u[t];for(t=n-a;t<n;t++)r[i+t]=e[t]}function transcodeCRNToDXT(e){const r=e.byteLength,i=new Uint8Array(e),n=crunch._malloc(r);arrayBufferCopy(i,crunch.HEAPU8,n,r);const t=crunch._crn_get_dxt_format(n,r),o=DXT_FORMAT_MAP[t];if(isNil(o))throw new Error("Unsupported compressed format.");const a=crunch._crn_get_levels(n,r);let u=crunch._crn_get_width(n,r),f=crunch._crn_get_height(n,r);o!==PixelFormat.RGB_DXT1&&o!==PixelFormat.RGBA_DXT3&&o!==PixelFormat.RGBA_DXT5||(u%4!=0&&(u+=4-u%4),f%4!=0&&(f+=4-f%4));let l,c=0;for(l=0;l<a;++l)c+=PixelFormat.compressedTextureSizeInBytes(o,u>>l,f>>l);cachedDstSize<c&&(isNil(dst)||crunch._free(dst),dst=crunch._malloc(c),dxtData=new Uint8Array(crunch.HEAPU8.buffer,dst,c),cachedDstSize=c),crunch._crn_decompress(n,r,dst,c,0,a),crunch._free(n);const s=PixelFormat.compressedTextureSizeInBytes(o,u,f),d=dxtData.subarray(0,s),_=new Uint8Array(s);return _.set(d,0),{format:o,width:u,height:f,data:_,transferList:[_.buffer]}}const promisify=function(...e){const r=transcodeCRNToDXT.call(this,...e);return Promise.resolve(r)};return promisify}()),currentGlobal.crn______decoder};if("object"!=typeof exports||"undefined"==typeof module)return transcoder;{const e=require("@maptalks/gl");e.transcoders.registerTranscoder("crn",transcoder)}}))}();/*!
 * @maptalks/transcoders.ktx2 v0.97.4
 * LICENSE : ISC
 * (c) 2022-2024 maptalks.com
 */
!function(){!function(A,B){"object"==typeof exports&&"undefined"!=typeof module?module.exports=B():"function"==typeof define&&define.amd?define(B):((A="undefined"!=typeof globalThis?globalThis:A||self).maptalksgl=A.maptalksgl||{},A.maptalksgl.transcoders=A.maptalksgl.transcoders||{},A.maptalksgl.transcoders.ktx2=B())}(this,(function(){"use strict";const A=function(){const A=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();return A.ktx______decoder||(A.ktx______decoder=function(){const A=function(A){for(var B=atob(A),Q=B.length,g=new Uint8Array(Q),E=0;E<Q;E++)g[E]=B.charCodeAt(E);return g.buffer}(" ");var B,Q=(B="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(A){var Q,g,E=void 0!==(A=A||{})?A:{};E.ready=new Promise((function(A,B){Q=A,g=B}));var I,C,D,w,F={};for(I in E)E.hasOwnProperty(I)&&(F[I]=E[I]);C="object"==typeof window,D="function"==typeof importScripts,w="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node;var G,U="";C||w||D?(C||D)&&(D?U=self.location.href:"undefined"!=typeof document&&document.currentScript&&(U=document.currentScript.src),B&&(U=B),U=0!==U.indexOf("blob:")?U.substr(0,U.lastIndexOf("/")+1):"",D&&(G=function(A){var B=new XMLHttpRequest;return B.open("GET",A,!1),B.responseType="arraybuffer",B.send(null),new Uint8Array(B.response)})):(G=function(A){var B;return"function"==typeof readbuffer?new Uint8Array(readbuffer(A)):(k("object"==typeof(B=read(A,"binary"))),B)},"undefined"!=typeof scriptArgs&&scriptArgs,"undefined"!=typeof print&&("undefined"==typeof console&&(console={}),console.log=print,console.warn=console.error="undefined"!=typeof printErr?printErr:print));var H,o,i=E.print||console.log.bind(console),R=E.printErr||console.warn.bind(console);for(I in F)F.hasOwnProperty(I)&&(E[I]=F[I]);F=null,E.wasmBinary&&(H=E.wasmBinary),"object"!=typeof WebAssembly&&p("no native wasm support detected");var M=!1;function k(A,B){A||p("Assertion failed: "+B)}var S="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function h(A,B,Q){for(var g=B+Q,E=B;A[E]&&!(E>=g);)++E;if(E-B>16&&A.subarray&&S)return S.decode(A.subarray(B,E));for(var I="";B<E;){var C=A[B++];if(128&C){var D=63&A[B++];if(192!=(224&C)){var w=63&A[B++];if((C=224==(240&C)?(15&C)<<12|D<<6|w:(7&C)<<18|D<<12|w<<6|63&A[B++])<65536)I+=String.fromCharCode(C);else{var F=C-65536;I+=String.fromCharCode(55296|F>>10,56320|1023&F)}}else I+=String.fromCharCode((31&C)<<6|D)}else I+=String.fromCharCode(C)}return I}function s(A,B){return A?h(Y,A,B):""}var c,y,Y,J,L,a,N,f,K,x,t="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function d(A,B){for(var Q=A,g=Q>>1,E=g+B/2;!(g>=E)&&L[g];)++g;if((Q=g<<1)-A>32&&t)return t.decode(Y.subarray(A,Q));for(var I="",C=0;!(C>=B/2);++C){var D=J[A+2*C>>1];if(0==D)break;I+=String.fromCharCode(D)}return I}function P(A,B,Q){if(void 0===Q&&(Q=2147483647),Q<2)return 0;for(var g=B,E=(Q-=2)<2*A.length?Q/2:A.length,I=0;I<E;++I){var C=A.charCodeAt(I);J[B>>1]=C,B+=2}return J[B>>1]=0,B-g}function T(A){return 2*A.length}function V(A,B){for(var Q=0,g="";!(Q>=B/4);){var E=a[A+4*Q>>2];if(0==E)break;if(++Q,E>=65536){var I=E-65536;g+=String.fromCharCode(55296|I>>10,56320|1023&I)}else g+=String.fromCharCode(E)}return g}function n(A,B,Q){if(void 0===Q&&(Q=2147483647),Q<4)return 0;for(var g=B,E=g+Q-4,I=0;I<A.length;++I){var C=A.charCodeAt(I);if(C>=55296&&C<=57343&&(C=65536+((1023&C)<<10)|1023&A.charCodeAt(++I)),a[B>>2]=C,(B+=4)+4>E)break}return a[B>>2]=0,B-g}function e(A){for(var B=0,Q=0;Q<A.length;++Q){var g=A.charCodeAt(Q);g>=55296&&g<=57343&&++Q,B+=4}return B}function W(A){c=A,E.HEAP8=y=new Int8Array(A),E.HEAP16=J=new Int16Array(A),E.HEAP32=a=new Int32Array(A),E.HEAPU8=Y=new Uint8Array(A),E.HEAPU16=L=new Uint16Array(A),E.HEAPU32=N=new Uint32Array(A),E.HEAPF32=f=new Float32Array(A),E.HEAPF64=K=new Float64Array(A)}var l=[],q=[],O=[],Z=[],r=0,b=null;function p(A){E.onAbort&&E.onAbort(A),R(A+=""),M=!0,A="abort("+A+"). Build with -s ASSERTIONS=1 for more info.";var B=new WebAssembly.RuntimeError(A);throw g(B),B}function X(A,B){return String.prototype.startsWith?A.startsWith(B):0===A.indexOf(B)}function z(A){return X(A,"data:application/octet-stream;base64,")}function m(A){return X(A,"file://")}E.preloadedImages={},E.preloadedAudios={};var j,u="basis_transcoder.wasm";function v(){try{if(H)return new Uint8Array(H);if(G)return G(u);throw"both async and sync fetching of the wasm failed"}catch(A){p(A)}}function $(A){for(;A.length>0;){var B=A.shift();if("function"!=typeof B){var Q=B.func;"number"==typeof Q?void 0===B.arg?x.get(Q)():x.get(Q)(B.arg):Q(void 0===B.arg?null:B.arg)}else B(E)}}z(u)||(j=u,u=E.locateFile?E.locateFile(j,U):U+j);var _={};function AA(A){for(;A.length;){var B=A.pop();A.pop()(B)}}function BA(A){return this.fromWireType(N[A>>2])}var QA={},gA={},EA={};function IA(A){if(void 0===A)return"_unknown";var B=(A=A.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return B>=48&&B<=57?"_"+A:A}function CA(A,B){return A=IA(A),new Function("body","return function "+A+'() {\n    "use strict";    return body.apply(this, arguments);\n};\n')(B)}function DA(A,B){var Q=CA(B,(function(A){this.name=B,this.message=A;var Q=new Error(A).stack;void 0!==Q&&(this.stack=this.toString()+"\n"+Q.replace(/^Error(:[^\n]*)?\n/,""))}));return Q.prototype=Object.create(A.prototype),Q.prototype.constructor=Q,Q.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},Q}var wA=void 0;function FA(A){throw new wA(A)}function GA(A,B,Q){function g(B){var g=Q(B);g.length!==A.length&&FA("Mismatched type converter count");for(var E=0;E<A.length;++E)MA(A[E],g[E])}A.forEach((function(A){EA[A]=B}));var E=new Array(B.length),I=[],C=0;B.forEach((function(A,B){gA.hasOwnProperty(A)?E[B]=gA[A]:(I.push(A),QA.hasOwnProperty(A)||(QA[A]=[]),QA[A].push((function(){E[B]=gA[A],++C===I.length&&g(E)})))})),0===I.length&&g(E)}function UA(A){switch(A){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+A)}}var HA=void 0;function oA(A){for(var B="",Q=A;Y[Q];)B+=HA[Y[Q++]];return B}var iA=void 0;function RA(A){throw new iA(A)}function MA(A,B,Q){if(Q=Q||{},!("argPackAdvance"in B))throw new TypeError("registerType registeredInstance requires argPackAdvance");var g=B.name;if(A||RA('type "'+g+'" must have a positive integer typeid pointer'),gA.hasOwnProperty(A)){if(Q.ignoreDuplicateRegistrations)return;RA("Cannot register type '"+g+"' twice")}if(gA[A]=B,delete EA[A],QA.hasOwnProperty(A)){var E=QA[A];delete QA[A],E.forEach((function(A){A()}))}}function kA(A){if(!(this instanceof xA))return!1;if(!(A instanceof xA))return!1;for(var B=this.$$.ptrType.registeredClass,Q=this.$$.ptr,g=A.$$.ptrType.registeredClass,E=A.$$.ptr;B.baseClass;)Q=B.upcast(Q),B=B.baseClass;for(;g.baseClass;)E=g.upcast(E),g=g.baseClass;return B===g&&Q===E}function SA(A){RA(A.$$.ptrType.registeredClass.name+" instance already deleted")}var hA=!1;function sA(A){}function cA(A){A.count.value-=1,0===A.count.value&&function(A){A.smartPtr?A.smartPtrType.rawDestructor(A.smartPtr):A.ptrType.registeredClass.rawDestructor(A.ptr)}(A)}function yA(A){return"undefined"==typeof FinalizationGroup?(yA=function(A){return A},A):(hA=new FinalizationGroup((function(A){for(var B=A.next();!B.done;B=A.next()){var Q=B.value;Q.ptr?cA(Q):console.warn("object already deleted: "+Q.ptr)}})),sA=function(A){hA.unregister(A.$$)},(yA=function(A){return hA.register(A,A.$$,A.$$),A})(A))}function YA(){if(this.$$.ptr||SA(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var A,B=yA(Object.create(Object.getPrototypeOf(this),{$$:{value:(A=this.$$,{count:A.count,deleteScheduled:A.deleteScheduled,preservePointerOnDelete:A.preservePointerOnDelete,ptr:A.ptr,ptrType:A.ptrType,smartPtr:A.smartPtr,smartPtrType:A.smartPtrType})}}));return B.$$.count.value+=1,B.$$.deleteScheduled=!1,B}function JA(){this.$$.ptr||SA(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&RA("Object already scheduled for deletion"),sA(this),cA(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function LA(){return!this.$$.ptr}var aA=void 0,NA=[];function fA(){for(;NA.length;){var A=NA.pop();A.$$.deleteScheduled=!1,A.delete()}}function KA(){return this.$$.ptr||SA(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&RA("Object already scheduled for deletion"),NA.push(this),1===NA.length&&aA&&aA(fA),this.$$.deleteScheduled=!0,this}function xA(){}var tA={};function dA(A,B,Q){if(void 0===A[B].overloadTable){var g=A[B];A[B]=function(){return A[B].overloadTable.hasOwnProperty(arguments.length)||RA("Function '"+Q+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+A[B].overloadTable+")!"),A[B].overloadTable[arguments.length].apply(this,arguments)},A[B].overloadTable=[],A[B].overloadTable[g.argCount]=g}}function PA(A,B,Q){E.hasOwnProperty(A)?((void 0===Q||void 0!==E[A].overloadTable&&void 0!==E[A].overloadTable[Q])&&RA("Cannot register public name '"+A+"' twice"),dA(E,A,A),E.hasOwnProperty(Q)&&RA("Cannot register multiple overloads of a function with the same number of arguments ("+Q+")!"),E[A].overloadTable[Q]=B):(E[A]=B,void 0!==Q&&(E[A].numArguments=Q))}function TA(A,B,Q,g,E,I,C,D){this.name=A,this.constructor=B,this.instancePrototype=Q,this.rawDestructor=g,this.baseClass=E,this.getActualType=I,this.upcast=C,this.downcast=D,this.pureVirtualFunctions=[]}function VA(A,B,Q){for(;B!==Q;)B.upcast||RA("Expected null or instance of "+Q.name+", got an instance of "+B.name),A=B.upcast(A),B=B.baseClass;return A}function nA(A,B){return null===B?(this.isReference&&RA("null is not a valid "+this.name),0):(B.$$||RA('Cannot pass "'+oB(B)+'" as a '+this.name),B.$$.ptr||RA("Cannot pass deleted object as a pointer of type "+this.name),VA(B.$$.ptr,B.$$.ptrType.registeredClass,this.registeredClass))}function eA(A,B){var Q;if(null===B)return this.isReference&&RA("null is not a valid "+this.name),this.isSmartPointer?(Q=this.rawConstructor(),null!==A&&A.push(this.rawDestructor,Q),Q):0;if(B.$$||RA('Cannot pass "'+oB(B)+'" as a '+this.name),B.$$.ptr||RA("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&B.$$.ptrType.isConst&&RA("Cannot convert argument of type "+(B.$$.smartPtrType?B.$$.smartPtrType.name:B.$$.ptrType.name)+" to parameter type "+this.name),Q=VA(B.$$.ptr,B.$$.ptrType.registeredClass,this.registeredClass),this.isSmartPointer)switch(void 0===B.$$.smartPtr&&RA("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:B.$$.smartPtrType===this?Q=B.$$.smartPtr:RA("Cannot convert argument of type "+(B.$$.smartPtrType?B.$$.smartPtrType.name:B.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:Q=B.$$.smartPtr;break;case 2:if(B.$$.smartPtrType===this)Q=B.$$.smartPtr;else{var g=B.clone();Q=this.rawShare(Q,GB((function(){g.delete()}))),null!==A&&A.push(this.rawDestructor,Q)}break;default:RA("Unsupporting sharing policy")}return Q}function WA(A,B){return null===B?(this.isReference&&RA("null is not a valid "+this.name),0):(B.$$||RA('Cannot pass "'+oB(B)+'" as a '+this.name),B.$$.ptr||RA("Cannot pass deleted object as a pointer of type "+this.name),B.$$.ptrType.isConst&&RA("Cannot convert argument of type "+B.$$.ptrType.name+" to parameter type "+this.name),VA(B.$$.ptr,B.$$.ptrType.registeredClass,this.registeredClass))}function lA(A){return this.rawGetPointee&&(A=this.rawGetPointee(A)),A}function qA(A){this.rawDestructor&&this.rawDestructor(A)}function OA(A){null!==A&&A.delete()}function ZA(){return Object.keys(pA).length}function rA(){var A=[];for(var B in pA)pA.hasOwnProperty(B)&&A.push(pA[B]);return A}function bA(A){aA=A,NA.length&&aA&&aA(fA)}var pA={};function XA(A,B){return B=function(A,B){for(void 0===B&&RA("ptr should not be undefined");A.baseClass;)B=A.upcast(B),A=A.baseClass;return B}(A,B),pA[B]}function zA(A,B){return B.ptrType&&B.ptr||FA("makeClassHandle requires ptr and ptrType"),!!B.smartPtrType!=!!B.smartPtr&&FA("Both smartPtrType and smartPtr must be specified"),B.count={value:1},yA(Object.create(A,{$$:{value:B}}))}function mA(A){var B=this.getPointee(A);if(!B)return this.destructor(A),null;var Q=XA(this.registeredClass,B);if(void 0!==Q){if(0===Q.$$.count.value)return Q.$$.ptr=B,Q.$$.smartPtr=A,Q.clone();var g=Q.clone();return this.destructor(A),g}function E(){return zA(this.registeredClass.instancePrototype,this.isSmartPointer?{ptrType:this.pointeeType,ptr:B,smartPtrType:this,smartPtr:A}:{ptrType:this,ptr:A})}var I,C=this.registeredClass.getActualType(B),D=tA[C];if(!D)return E.call(this);var w=function A(B,Q,g){if(Q===g)return B;if(void 0===g.baseClass)return null;var E=A(B,Q,g.baseClass);return null===E?null:g.downcast(E)}(B,this.registeredClass,(I=this.isConst?D.constPointerType:D.pointerType).registeredClass);return null===w?E.call(this):zA(I.registeredClass.instancePrototype,this.isSmartPointer?{ptrType:I,ptr:w,smartPtrType:this,smartPtr:A}:{ptrType:I,ptr:w})}function jA(A,B,Q,g,E,I,C,D,w,F,G){this.name=A,this.registeredClass=B,this.isReference=Q,this.isConst=g,this.isSmartPointer=E,this.pointeeType=I,this.sharingPolicy=C,this.rawGetPointee=D,this.rawConstructor=w,this.rawShare=F,this.rawDestructor=G,E||void 0!==B.baseClass?this.toWireType=eA:g?(this.toWireType=nA,this.destructorFunction=null):(this.toWireType=WA,this.destructorFunction=null)}function uA(A,B,Q){E.hasOwnProperty(A)||FA("Replacing nonexistant public symbol"),void 0!==E[A].overloadTable&&void 0!==Q?E[A].overloadTable[Q]=B:(E[A]=B,E[A].argCount=Q)}function vA(A,B,Q){return-1!=A.indexOf("j")?function(A,B,Q){return Q&&Q.length?E["dynCall_"+A].apply(null,[B].concat(Q)):E["dynCall_"+A].call(null,B)}(A,B,Q):x.get(B).apply(null,Q)}function $A(A,B){var Q=-1!=(A=oA(A)).indexOf("j")?function(A,B){k(A.indexOf("j")>=0,"getDynCaller should only be called with i64 sigs");var Q=[];return function(){Q.length=arguments.length;for(var g=0;g<arguments.length;g++)Q[g]=arguments[g];return vA(A,B,Q)}}(A,B):x.get(B);return"function"!=typeof Q&&RA("unknown function pointer with signature "+A+": "+B),Q}var _A=void 0;function AB(A){var B=KB(A),Q=oA(B);return fB(B),Q}function BB(A,B){var Q=[],g={};throw B.forEach((function A(B){g[B]||gA[B]||(EA[B]?EA[B].forEach(A):(Q.push(B),g[B]=!0))})),new _A(A+": "+Q.map(AB).join([", "]))}function QB(A,B){for(var Q=[],g=0;g<A;g++)Q.push(a[(B>>2)+g]);return Q}function gB(A,B){if(!(A instanceof Function))throw new TypeError("new_ called with constructor type "+typeof A+" which is not a function");var Q=CA(A.name||"unknownFunctionName",(function(){}));Q.prototype=A.prototype;var g=new Q,E=A.apply(g,B);return E instanceof Object?E:g}function EB(A,B,Q,g,E){var I=B.length;I<2&&RA("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var C=null!==B[1]&&null!==Q,D=!1,w=1;w<B.length;++w)if(null!==B[w]&&void 0===B[w].destructorFunction){D=!0;break}var F="void"!==B[0].name,G="",U="";for(w=0;w<I-2;++w)G+=(0!==w?", ":"")+"arg"+w,U+=(0!==w?", ":"")+"arg"+w+"Wired";var H="return function "+IA(A)+"("+G+") {\nif (arguments.length !== "+(I-2)+") {\nthrowBindingError('function "+A+" called with ' + arguments.length + ' arguments, expected "+(I-2)+" args!');\n}\n";D&&(H+="var destructors = [];\n");var o=D?"destructors":"null",i=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],R=[RA,g,E,AA,B[0],B[1]];for(C&&(H+="var thisWired = classParam.toWireType("+o+", this);\n"),w=0;w<I-2;++w)H+="var arg"+w+"Wired = argType"+w+".toWireType("+o+", arg"+w+"); // "+B[w+2].name+"\n",i.push("argType"+w),R.push(B[w+2]);if(C&&(U="thisWired"+(U.length>0?", ":"")+U),H+=(F?"var rv = ":"")+"invoker(fn"+(U.length>0?", ":"")+U+");\n",D)H+="runDestructors(destructors);\n";else for(w=C?1:2;w<B.length;++w){var M=1===w?"thisWired":"arg"+(w-2)+"Wired";null!==B[w].destructorFunction&&(H+=M+"_dtor("+M+"); // "+B[w].name+"\n",i.push(M+"_dtor"),R.push(B[w].destructorFunction))}return F&&(H+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),i.push(H+="}\n"),gB(Function,i).apply(null,R)}var IB=[],CB=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function DB(A){A>4&&0==--CB[A].refcount&&(CB[A]=void 0,IB.push(A))}function wB(){for(var A=0,B=5;B<CB.length;++B)void 0!==CB[B]&&++A;return A}function FB(){for(var A=5;A<CB.length;++A)if(void 0!==CB[A])return CB[A];return null}function GB(A){switch(A){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var B=IB.length?IB.pop():CB.length;return CB[B]={refcount:1,value:A},B}}function UB(A,B,Q){switch(B){case 0:return function(A){return this.fromWireType((Q?y:Y)[A])};case 1:return function(A){return this.fromWireType((Q?J:L)[A>>1])};case 2:return function(A){return this.fromWireType((Q?a:N)[A>>2])};default:throw new TypeError("Unknown integer type: "+A)}}function HB(A,B){var Q=gA[A];return void 0===Q&&RA(B+" has unknown type "+AB(A)),Q}function oB(A){if(null===A)return"null";var B=typeof A;return"object"===B||"array"===B||"function"===B?A.toString():""+A}function iB(A,B){switch(B){case 2:return function(A){return this.fromWireType(f[A>>2])};case 3:return function(A){return this.fromWireType(K[A>>3])};default:throw new TypeError("Unknown float type: "+A)}}function RB(A,B,Q){switch(B){case 0:return Q?function(A){return y[A]}:function(A){return Y[A]};case 1:return Q?function(A){return J[A>>1]}:function(A){return L[A>>1]};case 2:return Q?function(A){return a[A>>2]}:function(A){return N[A>>2]};default:throw new TypeError("Unknown integer type: "+A)}}function MB(A){return A||RA("Cannot use deleted val. handle = "+A),CB[A].value}var kB={};function SB(A){var B=kB[A];return void 0===B?oA(A):B}var hB=[];function sB(){return"object"==typeof globalThis?globalThis:Function("return this")()}var cB={};function yB(A){try{return o.grow(A-c.byteLength+65535>>>16),W(o.buffer),1}catch(A){}}var YB={mappings:{},buffers:[null,[],[]],printChar:function(A,B){var Q=YB.buffers[A];0===B||10===B?((1===A?i:R)(h(Q,0)),Q.length=0):Q.push(B)},varargs:void 0,get:function(){return YB.varargs+=4,a[YB.varargs-4>>2]},getStr:function(A){return s(A)},get64:function(A,B){return A}};wA=E.InternalError=DA(Error,"InternalError"),function(){for(var A=new Array(256),B=0;B<256;++B)A[B]=String.fromCharCode(B);HA=A}(),iA=E.BindingError=DA(Error,"BindingError"),xA.prototype.isAliasOf=kA,xA.prototype.clone=YA,xA.prototype.delete=JA,xA.prototype.isDeleted=LA,xA.prototype.deleteLater=KA,jA.prototype.getPointee=lA,jA.prototype.destructor=qA,jA.prototype.argPackAdvance=8,jA.prototype.readValueFromPointer=BA,jA.prototype.deleteObject=OA,jA.prototype.fromWireType=mA,E.getInheritedInstanceCount=ZA,E.getLiveInheritedInstances=rA,E.flushPendingDeletes=fA,E.setDelayFunction=bA,_A=E.UnboundTypeError=DA(Error,"UnboundTypeError"),E.count_emval_handles=wB,E.get_first_emval=FB,q.push({func:function(){aB()}});var JB={t:function(A){var B=_[A];delete _[A];var Q=B.rawConstructor,g=B.rawDestructor,E=B.fields;GA([A],E.map((function(A){return A.getterReturnType})).concat(E.map((function(A){return A.setterArgumentType}))),(function(A){var I={};return E.forEach((function(B,Q){var g=A[Q],C=B.getter,D=B.getterContext,w=A[Q+E.length],F=B.setter,G=B.setterContext;I[B.fieldName]={read:function(A){return g.fromWireType(C(D,A))},write:function(A,B){var Q=[];F(G,A,w.toWireType(Q,B)),AA(Q)}}})),[{name:B.name,fromWireType:function(A){var B={};for(var Q in I)B[Q]=I[Q].read(A);return g(A),B},toWireType:function(A,B){for(var E in I)if(!(E in B))throw new TypeError('Missing field:  "'+E+'"');var C=Q();for(E in I)I[E].write(C,B[E]);return null!==A&&A.push(g,C),C},argPackAdvance:8,readValueFromPointer:BA,destructorFunction:g}]}))},I:function(A,B,Q,g,E){var I=UA(Q);MA(A,{name:B=oA(B),fromWireType:function(A){return!!A},toWireType:function(A,B){return B?g:E},argPackAdvance:8,readValueFromPointer:function(A){var g;if(1===Q)g=y;else if(2===Q)g=J;else{if(4!==Q)throw new TypeError("Unknown boolean type size: "+B);g=a}return this.fromWireType(g[A>>I])},destructorFunction:null})},x:function(A,B,Q,g,E,I,C,D,w,F,G,U,H){G=oA(G),I=$A(E,I),D&&(D=$A(C,D)),F&&(F=$A(w,F)),H=$A(U,H);var o=IA(G);PA(o,(function(){BB("Cannot construct "+G+" due to unbound types",[g])})),GA([A,B,Q],g?[g]:[],(function(B){var Q,E;B=B[0],E=g?(Q=B.registeredClass).instancePrototype:xA.prototype;var C=CA(o,(function(){if(Object.getPrototypeOf(this)!==w)throw new iA("Use 'new' to construct "+G);if(void 0===U.constructor_body)throw new iA(G+" has no accessible constructor");var A=U.constructor_body[arguments.length];if(void 0===A)throw new iA("Tried to invoke ctor of "+G+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(U.constructor_body).toString()+") parameters instead!");return A.apply(this,arguments)})),w=Object.create(E,{constructor:{value:C}});C.prototype=w;var U=new TA(G,C,w,H,Q,I,D,F),i=new jA(G,U,!0,!1,!1),R=new jA(G+"*",U,!1,!1,!1),M=new jA(G+" const*",U,!1,!0,!1);return tA[A]={pointerType:R,constPointerType:M},uA(o,C),[i,R,M]}))},w:function(A,B,Q,g,E,I){k(B>0);var C=QB(B,Q);E=$A(g,E);var D=[I],w=[];GA([],[A],(function(A){var Q="constructor "+(A=A[0]).name;if(void 0===A.registeredClass.constructor_body&&(A.registeredClass.constructor_body=[]),void 0!==A.registeredClass.constructor_body[B-1])throw new iA("Cannot register multiple constructors with identical number of parameters ("+(B-1)+") for class '"+A.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return A.registeredClass.constructor_body[B-1]=function(){BB("Cannot construct "+A.name+" due to unbound types",C)},GA([],C,(function(g){return A.registeredClass.constructor_body[B-1]=function(){arguments.length!==B-1&&RA(Q+" called with "+arguments.length+" arguments, expected "+(B-1)),w.length=0,D.length=B;for(var A=1;A<B;++A)D[A]=g[A].toWireType(w,arguments[A-1]);var I=E.apply(null,D);return AA(w),g[0].fromWireType(I)},[]})),[]}))},d:function(A,B,Q,g,E,I,C,D){var w=QB(Q,g);B=oA(B),I=$A(E,I),GA([],[A],(function(A){var g=(A=A[0]).name+"."+B;function E(){BB("Cannot call "+g+" due to unbound types",w)}D&&A.registeredClass.pureVirtualFunctions.push(B);var F=A.registeredClass.instancePrototype,G=F[B];return void 0===G||void 0===G.overloadTable&&G.className!==A.name&&G.argCount===Q-2?(E.argCount=Q-2,E.className=A.name,F[B]=E):(dA(F,B,g),F[B].overloadTable[Q-2]=E),GA([],w,(function(E){var D=EB(g,E,A,I,C);return void 0===F[B].overloadTable?(D.argCount=Q-2,F[B]=D):F[B].overloadTable[Q-2]=D,[]})),[]}))},k:function(A,B,Q){A=oA(A),GA([],[B],(function(B){return E[A]=(B=B[0]).fromWireType(Q),[]}))},H:function(A,B){MA(A,{name:B=oA(B),fromWireType:function(A){var B=CB[A].value;return DB(A),B},toWireType:function(A,B){return GB(B)},argPackAdvance:8,readValueFromPointer:BA,destructorFunction:null})},n:function(A,B,Q,g){var E=UA(Q);function I(){}B=oA(B),I.values={},MA(A,{name:B,constructor:I,fromWireType:function(A){return this.constructor.values[A]},toWireType:function(A,B){return B.value},argPackAdvance:8,readValueFromPointer:UB(B,E,g),destructorFunction:null}),PA(B,I)},a:function(A,B,Q){var g=HB(A,"enum");B=oA(B);var E=g.constructor,I=Object.create(g.constructor.prototype,{value:{value:Q},constructor:{value:CA(g.name+"_"+B,(function(){}))}});E.values[Q]=I,E[B]=I},A:function(A,B,Q){var g=UA(Q);MA(A,{name:B=oA(B),fromWireType:function(A){return A},toWireType:function(A,B){if("number"!=typeof B&&"boolean"!=typeof B)throw new TypeError('Cannot convert "'+oB(B)+'" to '+this.name);return B},argPackAdvance:8,readValueFromPointer:iB(B,g),destructorFunction:null})},i:function(A,B,Q,g,E,I){var C=QB(B,Q);A=oA(A),E=$A(g,E),PA(A,(function(){BB("Cannot call "+A+" due to unbound types",C)}),B-1),GA([],C,(function(Q){var g=[Q[0],null].concat(Q.slice(1));return uA(A,EB(A,g,null,E,I),B-1),[]}))},j:function(A,B,Q,g,E){B=oA(B),-1===E&&(E=4294967295);var I=UA(Q),C=function(A){return A};if(0===g){var D=32-8*Q;C=function(A){return A<<D>>>D}}var w=-1!=B.indexOf("unsigned");MA(A,{name:B,fromWireType:C,toWireType:function(A,Q){if("number"!=typeof Q&&"boolean"!=typeof Q)throw new TypeError('Cannot convert "'+oB(Q)+'" to '+this.name);if(Q<g||Q>E)throw new TypeError('Passing a number "'+oB(Q)+'" from JS side to C/C++ side to an argument of type "'+B+'", which is outside the valid range ['+g+", "+E+"]!");return w?Q>>>0:0|Q},argPackAdvance:8,readValueFromPointer:RB(B,I,0!==g),destructorFunction:null})},h:function(A,B,Q){var g=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][B];function E(A){return new g(c,N[1+(A>>=2)],N[A])}MA(A,{name:Q=oA(Q),fromWireType:E,argPackAdvance:8,readValueFromPointer:E},{ignoreDuplicateRegistrations:!0})},B:function(A,B){var Q="std::string"===(B=oA(B));MA(A,{name:B,fromWireType:function(A){var B,g=N[A>>2];if(Q)for(var E=A+4,I=0;I<=g;++I){var C=A+4+I;if(I==g||0==Y[C]){var D=s(E,C-E);void 0===B?B=D:(B+=String.fromCharCode(0),B+=D),E=C+1}}else{var w=new Array(g);for(I=0;I<g;++I)w[I]=String.fromCharCode(Y[A+4+I]);B=w.join("")}return fB(A),B},toWireType:function(A,B){B instanceof ArrayBuffer&&(B=new Uint8Array(B));var g="string"==typeof B;g||B instanceof Uint8Array||B instanceof Uint8ClampedArray||B instanceof Int8Array||RA("Cannot pass non-string to std::string");var E=(Q&&g?function(){return function(A){for(var B=0,Q=0;Q<A.length;++Q){var g=A.charCodeAt(Q);g>=55296&&g<=57343&&(g=65536+((1023&g)<<10)|1023&A.charCodeAt(++Q)),g<=127?++B:B+=g<=2047?2:g<=65535?3:4}return B}(B)}:function(){return B.length})(),I=NB(4+E+1);if(N[I>>2]=E,Q&&g)!function(A,B,Q,g){if(!(g>0))return 0;for(var E=Q+g-1,I=0;I<A.length;++I){var C=A.charCodeAt(I);if(C>=55296&&C<=57343&&(C=65536+((1023&C)<<10)|1023&A.charCodeAt(++I)),C<=127){if(Q>=E)break;B[Q++]=C}else if(C<=2047){if(Q+1>=E)break;B[Q++]=192|C>>6,B[Q++]=128|63&C}else if(C<=65535){if(Q+2>=E)break;B[Q++]=224|C>>12,B[Q++]=128|C>>6&63,B[Q++]=128|63&C}else{if(Q+3>=E)break;B[Q++]=240|C>>18,B[Q++]=128|C>>12&63,B[Q++]=128|C>>6&63,B[Q++]=128|63&C}}B[Q]=0}(B,Y,I+4,E+1);else if(g)for(var C=0;C<E;++C){var D=B.charCodeAt(C);D>255&&(fB(I),RA("String has UTF-16 code units that do not fit in 8 bits")),Y[I+4+C]=D}else for(C=0;C<E;++C)Y[I+4+C]=B[C];return null!==A&&A.push(fB,I),I},argPackAdvance:8,readValueFromPointer:BA,destructorFunction:function(A){fB(A)}})},v:function(A,B,Q){var g,E,I,C,D;Q=oA(Q),2===B?(g=d,E=P,C=T,I=function(){return L},D=1):4===B&&(g=V,E=n,C=e,I=function(){return N},D=2),MA(A,{name:Q,fromWireType:function(A){for(var Q,E=N[A>>2],C=I(),w=A+4,F=0;F<=E;++F){var G=A+4+F*B;if(F==E||0==C[G>>D]){var U=g(w,G-w);void 0===Q?Q=U:(Q+=String.fromCharCode(0),Q+=U),w=G+B}}return fB(A),Q},toWireType:function(A,g){"string"!=typeof g&&RA("Cannot pass non-string to C++ string type "+Q);var I=C(g),w=NB(4+I+B);return N[w>>2]=I>>D,E(g,w+4,I+B),null!==A&&A.push(fB,w),w},argPackAdvance:8,readValueFromPointer:BA,destructorFunction:function(A){fB(A)}})},u:function(A,B,Q,g,E,I){_[A]={name:oA(B),rawConstructor:$A(Q,g),rawDestructor:$A(E,I),fields:[]}},c:function(A,B,Q,g,E,I,C,D,w,F){_[A].fields.push({fieldName:oA(B),getterReturnType:Q,getter:$A(g,E),getterContext:I,setterArgumentType:C,setter:$A(D,w),setterContext:F})},J:function(A,B){MA(A,{isVoid:!0,name:B=oA(B),argPackAdvance:0,fromWireType:function(){},toWireType:function(A,B){}})},m:function(A,B,Q){A=MB(A),B=HB(B,"emval::as");var g=[],E=GB(g);return a[Q>>2]=E,B.toWireType(g,A)},s:function(A,B,Q,g){(A=hB[A])(B=MB(B),Q=SB(Q),null,g)},b:DB,y:function(A){return 0===A?GB(sB()):(A=SB(A),GB(sB()[A]))},p:function(A,B){for(var Q=function(A,B){for(var Q=new Array(A),g=0;g<A;++g)Q[g]=HB(a[(B>>2)+g],"parameter "+g);return Q}(A,B),g=Q[0],E=g.name+"_$"+Q.slice(1).map((function(A){return A.name})).join("_")+"$",I=["retType"],C=[g],D="",w=0;w<A-1;++w)D+=(0!==w?", ":"")+"arg"+w,I.push("argType"+w),C.push(Q[1+w]);var F="return function "+IA("methodCaller_"+E)+"(handle, name, destructors, args) {\n",G=0;for(w=0;w<A-1;++w)F+="    var arg"+w+" = argType"+w+".readValueFromPointer(args"+(G?"+"+G:"")+");\n",G+=Q[w+1].argPackAdvance;for(F+="    var rv = handle[name]("+D+");\n",w=0;w<A-1;++w)Q[w+1].deleteObject&&(F+="    argType"+w+".deleteObject(arg"+w+");\n");g.isVoid||(F+="    return retType.toWireType(destructors, rv);\n"),I.push(F+="};\n");var U,H=gB(Function,I).apply(null,C);return U=hB.length,hB.push(H),U},r:function(A){return A=SB(A),GB(E[A])},e:function(A,B){return GB((A=MB(A))[B=MB(B)])},g:function(A){A>4&&(CB[A].refcount+=1)},q:function(A,B,Q,g){A=MB(A);var I=cB[B];return I||(I=function(A){for(var B="",Q=0;Q<A;++Q)B+=(0!==Q?", ":"")+"arg"+Q;var g="return function emval_allocator_"+A+"(constructor, argTypes, args) {\n";for(Q=0;Q<A;++Q)g+="var argType"+Q+" = requireRegisteredType(Module['HEAP32'][(argTypes >>> 2) + "+Q+'], "parameter '+Q+'");\nvar arg'+Q+" = argType"+Q+".readValueFromPointer(args);\nargs += argType"+Q+"['argPackAdvance'];\n";return g+="var obj = new constructor("+B+");\nreturn __emval_register(obj);\n}\n",new Function("requireRegisteredType","Module","__emval_register",g)(HB,E,GB)}(B),cB[B]=I),I(A,Q,g)},f:function(A){return GB(SB(A))},l:function(A){AA(CB[A].value),DB(A)},o:function(){p()},E:function(A,B,Q){Y.copyWithin(A,B,B+Q)},F:function(A){var B=Y.length;if((A>>>=0)>2147483648)return!1;for(var Q,g,E=1;E<=4;E*=2){var I=B*(1+.2/E);if(I=Math.min(I,A+100663296),yB(Math.min(2147483648,((Q=Math.max(16777216,A,I))%(g=65536)>0&&(Q+=g-Q%g),Q))))return!0}return!1},G:function(A){return 0},C:function(A,B,Q,g,E){},z:function(A,B,Q,g){for(var E=0,I=0;I<Q;I++){for(var C=a[B+8*I>>2],D=a[B+(8*I+4)>>2],w=0;w<D;w++)YB.printChar(A,Y[C+w]);E+=D}return a[g>>2]=E,0},D:function(A){}};!function(){var A={a:JB};function B(A,B){E.asm=A.exports,W((o=E.asm.K).buffer),x=E.asm.L,function(A){if(r--,E.monitorRunDependencies&&E.monitorRunDependencies(r),0==r&&b){var B=b;b=null,B()}}()}function Q(A){B(A.instance)}function I(B){return(H||!C&&!D||"function"!=typeof fetch||m(u)?Promise.resolve().then(v):fetch(u,{credentials:"same-origin"}).then((function(A){if(!A.ok)throw"failed to load wasm binary file at '"+u+"'";return A.arrayBuffer()})).catch((function(){return v()}))).then((function(B){return WebAssembly.instantiate(B,A)})).then(B,(function(A){R("failed to asynchronously prepare wasm: "+A),p(A)}))}if(r++,E.monitorRunDependencies&&E.monitorRunDependencies(r),E.instantiateWasm)try{return E.instantiateWasm(A,B)}catch(A){return R("Module.instantiateWasm callback failed with error: "+A),!1}(H||"function"!=typeof WebAssembly.instantiateStreaming||z(u)||m(u)||"function"!=typeof fetch?I(Q):fetch(u,{credentials:"same-origin"}).then((function(B){return WebAssembly.instantiateStreaming(B,A).then(Q,(function(A){return R("wasm streaming compile failed: "+A),R("falling back to ArrayBuffer instantiation"),I(Q)}))}))).catch(g)}();var LB,aB=E.___wasm_call_ctors=function(){return(aB=E.___wasm_call_ctors=E.asm.M).apply(null,arguments)},NB=E._malloc=function(){return(NB=E._malloc=E.asm.N).apply(null,arguments)},fB=E._free=function(){return(fB=E._free=E.asm.O).apply(null,arguments)},KB=E.___getTypeName=function(){return(KB=E.___getTypeName=E.asm.P).apply(null,arguments)};function xB(A){function B(){LB||(LB=!0,E.calledRun=!0,M||($(q),$(O),Q(E),E.onRuntimeInitialized&&E.onRuntimeInitialized(),function(){if(E.postRun)for("function"==typeof E.postRun&&(E.postRun=[E.postRun]);E.postRun.length;)A=E.postRun.shift(),Z.unshift(A);var A;$(Z)}()))}r>0||(function(){if(E.preRun)for("function"==typeof E.preRun&&(E.preRun=[E.preRun]);E.preRun.length;)A=E.preRun.shift(),l.unshift(A);var A;$(l)}(),r>0||(E.setStatus?(E.setStatus("Running..."),setTimeout((function(){setTimeout((function(){E.setStatus("")}),1),B()}),1)):B()))}if(E.___embind_register_native_and_builtin_types=function(){return(E.___embind_register_native_and_builtin_types=E.asm.Q).apply(null,arguments)},E.dynCall_jiji=function(){return(E.dynCall_jiji=E.asm.R).apply(null,arguments)},b=function A(){LB||xB(),LB||(b=A)},E.run=xB,E.preInit)for("function"==typeof E.preInit&&(E.preInit=[E.preInit]);E.preInit.length>0;)E.preInit.pop()();return xB(),A.ready});let g,E=null;const I=Q({wasmBinary:A,wasmBinaryFile:"./lib/basis_transcoder.wasm"}).then(A=>{g=A,E=A.KTX2File,A.initializeBasis()});function C(A,B,Q){throw B.close(),B.delete(),new Error(Q)}function D(A,B={}){const{supportedFormats:Q,id:D}=B;return I.then(()=>function(A,B,Q){const I=new Uint8Array(B),D=new E(I);let w=D.getWidth(),F=D.getHeight();const G=w,U=F,H=D.getLevels(),o=D.getHasAlpha();if(!(w>0&&F>0&&H>0))throw D.close(),D.delete(),new Error("Invalid KTX2 file");const i=D.getDFDColorModel(),R=g.transcoder_texture_format;let M,k;163===i?Q.etc?(M=o?37496:37492,k=o?R.cTFETC2_RGBA:R.cTFETC1_RGB):Q.etc1&&!o?(M=36196,k=R.cTFETC1_RGB):Q.s3tc?(M=o?33779:33776,k=o?R.cTFBC3_RGBA:R.cTFBC1_RGB):Q.pvrtc?(M=o?35842:35840,k=o?R.cTFPVRTC1_4_RGBA:R.cTFPVRTC1_4_RGB):Q.astc?(M=37808,k=R.cTFASTC_4x4_RGBA):Q.bc7?(M=36492,k=R.cTFBC7_RGBA):C(0,D,"No transcoding format target available for ETC1S compressed ktx2."):166===i&&(Q.astc?(M=37808,k=R.cTFASTC_4x4_RGBA):Q.bc7?(M=36492,k=R.cTFBC7_RGBA):Q.s3tc?(M=o?33779:33776,k=o?R.cTFBC3_RGBA:R.cTFBC1_RGB):Q.etc?(M=o?37496:37492,k=o?R.cTFETC2_RGBA:R.cTFETC1_RGB):Q.etc1&&!o?(M=36196,k=R.cTFETC1_RGB):Q.pvrtc?(M=o?35842:35840,k=o?R.cTFPVRTC1_4_RGBA:R.cTFPVRTC1_4_RGB):C(0,D,"No transcoding format target available for UASTC compressed ktx2."));const S=[];D.startTranscoding()||C(0,D,"startTranscoding() failed");const h=[];for(let A=0;A<H;++A){w=G>>A,F=U>>A;const B=D.getImageTranscodedSizeInBytes(A,0,0,k.value),Q=new Uint8Array(B);D.transcodeImage(Q,A,0,0,k.value,0,-1,-1)||C(0,D,"transcodeImage() failed."),S.push(Q.buffer),h.push(Q)}return D.close(),D.delete(),{format:M,width:G,height:U,mipmap:h}}(0,A,Q))}return function(...A){const B=D.call(this,...A);return Promise.resolve(B)}}()),A.ktx______decoder};if("object"!=typeof exports||"undefined"==typeof module)return A;require("@maptalks/gl").transcoders.registerTranscoder("ktx2",A)}))}();/*!
 * maptalks.routeplayer v0.1.0
 * LICENSE : MIT
 * (c) 2016-2018 maptalks.org
 */
/*!
 * requires maptalks@^0.23.0 
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],e):e(t.maptalks=t.maptalks||{},t.maptalks)}(this,function(t,y){"use strict";var r=function(){function i(t,e){for(var r=0;r<e.length;r++){var i=e[r];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}return function(t,e,r){return e&&i(t.prototype,e),r&&i(t,r),t}}();function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):function(t,e){for(var r=Object.getOwnPropertyNames(e),i=0;i<r.length;i++){var n=r[i],o=Object.getOwnPropertyDescriptor(e,n);o&&o.configurable&&void 0===t[n]&&Object.defineProperty(t,n,o)}}(t,e))}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var s=function(){function e(t){a(this,e),this.route=t,this.path=t.path}return e.prototype.getCoordinates=function(t,e){if(t<this.getStart()||t>this.getEnd())return null;for(var r=null,i=0,n=this.path.length;i<n;i++)if(t<this.path[i][2]){r=i;break}null===r&&(r=this.path.length-1);var o=this.path[r-1],a=this.path[r],s=(t-o[2])/(a[2]-o[2]),p=o[0]+(a[0]-o[0])*s,l=o[1]+(a[1]-o[1])*s,h=new y.Coordinate(p,l),u=e.coordinateToViewPoint(h);return{coordinate:h,viewPoint:u,degree:y.Util.computeDegree(e.coordinateToViewPoint(new y.Coordinate(o)),u),index:r}},e.prototype.getStart=function(){return this.path[0][2]},e.prototype.getEnd=function(){return this.path[this.getCount()-1][2]},e.prototype.getCount=function(){return this.path.length},r(e,[{key:"markerSymbol",get:function(){return this.route.markerSymbol},set:function(t){this.route.markerSymbol=t,this._painter&&this._painter.marker&&this._painter.marker.setSymbol(t)}},{key:"lineSymbol",get:function(){return this.route.lineSymbol},set:function(t){this.route.lineSymbol=t,this._painter&&this._painter.marker&&this._painter.line.setSymbol(t)}}]),e}(),i=function(n){function o(t,e,r){a(this,o);var i=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}(this,n.call(this,r));return Array.isArray(t)||(t=[t]),i.id=y.Util.UID(),i._map=e,i._setup(t),i}return e(o,n),o.prototype.remove=function(){return this.markerLayer&&(this.finish(),this.markerLayer.remove(),this.lineLayer.remove(),delete this.markerLayer,delete this.lineLayer,delete this._map),this},o.prototype.play=function(){return"running"===this.player.playState||(this.player.play(),this.fire("playstart")),this},o.prototype.pause=function(){return"paused"===this.player.playState||(this.player.pause(),this.fire("playpause")),this},o.prototype.cancel=function(){return this.player.cancel(),this.played=0,this._createPlayer(),this._step({styles:{t:0}}),this.fire("playcancel"),this},o.prototype.finish=function(){return"finished"===this.player.playState||(this.player.finish(),this._step({styles:{t:1}}),this.fire("playfinish")),this},o.prototype.getStartTime=function(){return this.startTime||0},o.prototype.getEndTime=function(){return this.endTime||0},o.prototype.getCurrentTime=function(){return this.played?this.startTime+this.played:this.startTime},o.prototype.setTime=function(t){return this.played=t-this.startTime,this.played<0&&(this.played=0),this._resetPlayer(),this},o.prototype.getUnitTime=function(){return this.options.unitTime},o.prototype.setUnitTime=function(t){this.options.unitTime=+t,this._resetPlayer()},o.prototype.getCurrentCoordinates=function(t){return t||(t=0),this.routes[t]&&this.routes[t]._painter?this.routes[t]._painter.marker.getCoordinates():null},o.prototype.getMarkerSymbol=function(t){return this.routes&&this.routes[t]?this.routes[t].markerSymbol:null},o.prototype.setMarkerSymbol=function(t,e){return this.routes&&this.routes[t]&&(this.routes[t].markerSymbol=e),this},o.prototype.getLineSymbol=function(t){return this.routes&&this.routes[t]?this.routes[t].lineSymbol:null},o.prototype.setLineSymbol=function(t,e){return this.routes&&this.routes[t]&&(this.routes[t].lineSymbol=e),this},o.prototype._resetPlayer=function(){var t=this.player&&"running"===this.player.playState;t&&this.player.finish(),this._createPlayer(),t&&this.player.play()},o.prototype._step=function(t){if(t.state&&"running"!==t.state.playState)"finished"===t.state.playState&&this.fire("playfinish");else{this.played=this.duration*t.styles.t;for(var e=0,r=this.routes.length;e<r;e++)this._drawRoute(this.routes[e],this.startTime+this.played);this.fire("playing")}},o.prototype._drawRoute=function(t,e){if(this._map){var r=t.getCoordinates(e,this._map);if(r){if(t._painter||(t._painter={}),t._painter.marker)t._painter.marker.setCoordinates(r.coordinate);else{var i=new y.Marker(r.coordinate,{symbol:t.markerSymbol||this.options.markerSymbol}).addTo(this.markerLayer);t._painter.marker=i}if(!t._painter.line){var n=new y.LineString(t.path,{symbol:t.lineSymbol||this.options.lineSymbol}).addTo(this.lineLayer);t._painter.line=n}}else t._painter&&t._painter.marker&&(t._painter.marker.remove(),delete t._painter.marker)}},o.prototype._setup=function(t){for(var e=t.map(function(t){return new s(t)}),r=e[0].getStart(),i=e[0].getEnd(),n=1;n<e.length;n++){var o=e[n];o.getStart()<r&&(r=o.getStart()),o.getEnd()>i&&(i=o.getEnd())}this.routes=e,this.startTime=r,this.endTime=i,this.played=0,this.duration=i-r,this._createLayers(),this._createPlayer()},o.prototype._createPlayer=function(){var t=(this.duration-this.played)/this.options.unitTime,e=void 0,r=this._map._getRenderer();r.callInFrameLoop&&(e=function(t){r.callInFrameLoop(t)}),this.player=y.animation.Animation.animate({t:[this.played/this.duration,1]},{framer:e,speed:t,easing:"linear"},this._step.bind(this))},o.prototype._createLayers=function(){this.lineLayer=new y.VectorLayer(y.INTERNAL_LAYER_PREFIX+"_routeplay_r_"+this.id).addTo(this._map),this.markerLayer=new y.VectorLayer(y.INTERNAL_LAYER_PREFIX+"_routeplay_m_"+this.id).addTo(this._map)},o}(y.Eventable(y.Class));i.mergeOptions({unitTime:1e3,showRoutes:!0,markerSymbol:null,lineSymbol:{lineWidth:2,lineColor:"#004A8D"}}),t.Route=s,t.RoutePlayer=i,Object.defineProperty(t,"__esModule",{value:!0})});/*!
 * maptalks.markercluster v0.8.8
 * LICENSE : MIT
 * (c) 2016-2024 maptalks.org
 */
(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('maptalks')) :
	typeof define === 'function' && define.amd ? define(['exports', 'maptalks'], factory) :
	(factory((global.maptalks = global.maptalks || {}),global.maptalks));
}(this, (function (exports,maptalks) { 'use strict';

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass); }

var options = {
    'maxClusterRadius': 160,
    'textSumProperty': null,
    'symbol': null,
    'drawClusterText': true,
    'textSymbol': null,
    'animation': true,
    'animationDuration': 450,
    'maxClusterZoom': null,
    'noClusterWithOneMarker': true,
    'forceRenderOnZooming': true
};

var ClusterLayer = function (_maptalks$VectorLayer) {
    _inherits(ClusterLayer, _maptalks$VectorLayer);

    function ClusterLayer() {
        _classCallCheck(this, ClusterLayer);

        return _possibleConstructorReturn(this, _maptalks$VectorLayer.apply(this, arguments));
    }

    /**
     * Reproduce a ClusterLayer from layer's profile JSON.
     * @param  {Object} json - layer's profile JSON
     * @return {maptalks.ClusterLayer}
     * @static
     * @private
     * @function
     */
    ClusterLayer.fromJSON = function fromJSON(json) {
        if (!json || json['type'] !== 'ClusterLayer') {
            return null;
        }
        var layer = new ClusterLayer(json['id'], json['options']);
        var geoJSONs = json['geometries'];
        var geometries = [];
        for (var i = 0; i < geoJSONs.length; i++) {
            var geo = maptalks.Geometry.fromJSON(geoJSONs[i]);
            if (geo) {
                geometries.push(geo);
            }
        }
        layer.addGeometry(geometries);
        return layer;
    };

    ClusterLayer.prototype.addMarker = function addMarker(markers) {
        return this.addGeometry(markers);
    };

    ClusterLayer.prototype.addGeometry = function addGeometry(markers) {
        for (var i = 0, len = markers.length; i <= len; i++) {
            if (!markers[i] instanceof maptalks.Marker) {
                throw new Error('Only a point(Marker) can be added into a ClusterLayer');
            }
        }
        return _maptalks$VectorLayer.prototype.addGeometry.apply(this, arguments);
    };

    ClusterLayer.prototype.onConfig = function onConfig(conf) {
        _maptalks$VectorLayer.prototype.onConfig.call(this, conf);
        if (conf['maxClusterRadius'] || conf['symbol'] || conf['drawClusterText'] || conf['textSymbol'] || conf['maxClusterZoom']) {
            var renderer$$1 = this._getRenderer();
            if (renderer$$1) {
                renderer$$1.render();
            }
        }
        return this;
    };

    /**
     * Identify the clusters on the given coordinate
     * @param  {maptalks.Coordinate} coordinate   - coordinate to identify
     * @return {Object|Geometry[]}  result: cluster { center : [cluster's center], children : [geometries in the cluster] } or markers
     */


    ClusterLayer.prototype.identify = function identify(coordinate, options) {
        var map = this.getMap(),
            maxZoom = this.options['maxClusterZoom'];
        if (maxZoom && map && map.getZoom() > maxZoom) {
            return _maptalks$VectorLayer.prototype.identify.call(this, coordinate, options);
        }
        if (this._getRenderer()) {
            return this._getRenderer().identify(coordinate, options);
        }
        return null;
    };

    /**
     * Export the ClusterLayer's JSON.
     * @return {Object} layer's JSON
     */


    ClusterLayer.prototype.toJSON = function toJSON() {
        var json = _maptalks$VectorLayer.prototype.toJSON.call(this);
        json['type'] = 'ClusterLayer';
        return json;
    };
    /**
     * Get the ClusterLayer's current clusters
     * @return {Object} layer's clusters
     **/


    ClusterLayer.prototype.getClusters = function getClusters() {
        var renderer$$1 = this._getRenderer();
        if (renderer$$1) {
            return renderer$$1._currentClusters || [];
        }
        return [];
    };

    return ClusterLayer;
}(maptalks.VectorLayer);

// merge to define ClusterLayer's default options.
ClusterLayer.mergeOptions(options);

// register ClusterLayer's JSON type for JSON deserialization.
ClusterLayer.registerJSONType('ClusterLayer');

var defaultTextSymbol = {
    'textFaceName': '"microsoft yahei"',
    'textSize': 16,
    'textDx': 0,
    'textDy': 0
};

var defaultSymbol = {
    'markerType': 'ellipse',
    'markerFill': { property: 'count', type: 'interval', stops: [[0, 'rgb(135, 196, 240)'], [9, '#1bbc9b'], [99, 'rgb(216, 115, 149)']] },
    'markerFillOpacity': 0.7,
    'markerLineOpacity': 1,
    'markerLineWidth': 3,
    'markerLineColor': '#fff',
    'markerWidth': { property: 'count', type: 'interval', stops: [[0, 40], [9, 60], [99, 80]] },
    'markerHeight': { property: 'count', type: 'interval', stops: [[0, 40], [9, 60], [99, 80]] }
};

ClusterLayer.registerRenderer('canvas', function (_maptalks$renderer$Ve) {
    _inherits(_class, _maptalks$renderer$Ve);

    function _class(layer) {
        _classCallCheck(this, _class);

        var _this2 = _possibleConstructorReturn(this, _maptalks$renderer$Ve.call(this, layer));

        _this2._animated = true;
        _this2._refreshStyle();
        _this2._clusterNeedRedraw = true;
        return _this2;
    }

    _class.prototype.checkResources = function checkResources() {
        var symbol = this.layer.options['symbol'] || defaultSymbol;
        var resources = _maptalks$renderer$Ve.prototype.checkResources.apply(this, arguments);
        if (symbol !== this._symbolResourceChecked) {
            var res = maptalks.Util.getExternalResources(symbol, true);
            if (res) {
                resources.push.apply(resources, res);
            }
            this._symbolResourceChecked = symbol;
            this.onSymbolChanged()
        }
        return resources;
    };

    _class.prototype.draw = function draw() {
        if (!this.canvas) {
            this.prepareCanvas();
        }
        var map = this.getMap();
        var zoom = map.getZoom();
        var maxClusterZoom = this.layer.options['maxClusterZoom'];
        if (maxClusterZoom && zoom > maxClusterZoom) {
            delete this._currentClusters;
            this._markersToDraw = this.layer._geoList;
            _maptalks$renderer$Ve.prototype.draw.apply(this, arguments);
            return;
        }
        if (this._clusterNeedRedraw) {
            this._clearDataCache();
            this._computeGrid();
            this._clusterNeedRedraw = false;
        }
        var zoomClusters = this._clusterCache[zoom] ? this._clusterCache[zoom]['clusters'] : null;

        var clusters = this._getClustersToDraw(zoomClusters);
        clusters.zoom = zoom;
        this._drawLayer(clusters);
    };

    _class.prototype._getClustersToDraw = function _getClustersToDraw(zoomClusters) {
        this._markersToDraw = [];
        var map = this.getMap();
        var font = maptalks.StringUtil.getFont(this._textSymbol),
            digitLen = maptalks.StringUtil.stringLength('9', font).toPoint();
        var extent = map.getContainerExtent(),
            clusters = [];
        var pt = void 0,
            pExt = void 0,
            sprite = void 0,
            width = void 0,
            height = void 0;
        for (var p in zoomClusters) {
            this._currentGrid = zoomClusters[p];
            if (zoomClusters[p]['count'] === 1 && this.layer.options['noClusterWithOneMarker']) {
                var marker = zoomClusters[p]['children'][0];
                marker._cluster = zoomClusters[p];
                this._markersToDraw.push(marker);
                continue;
            }
            sprite = this._getSprite();
            width = sprite.canvas.width;
            height = sprite.canvas.height;
            pt = map._prjToContainerPoint(zoomClusters[p]['center']);
            pExt = new maptalks.PointExtent(pt.sub(width, height), pt.add(width, height));
            if (!extent.intersects(pExt)) {
                continue;
            }

            if (!zoomClusters[p]['textSize']) {
                var text = this._getClusterText(zoomClusters[p]);
                zoomClusters[p]['textSize'] = new maptalks.Point(digitLen.x * text.length, digitLen.y)._multi(1 / 2);
            }
            clusters.push(zoomClusters[p]);
        }
        return clusters;
    };

    _class.prototype.drawOnInteracting = function drawOnInteracting() {
        if (this._currentClusters) {
            this._drawClusters(this._currentClusters, 1);
        }
        _maptalks$renderer$Ve.prototype.drawOnInteracting.apply(this, arguments);
    };

    _class.prototype._getCurrentNeedRenderGeos = function _getCurrentNeedRenderGeos() {
        if (this._markersToDraw) {
            return this._markersToDraw;
        }
        return [];
    };

    _class.prototype.forEachGeo = function forEachGeo(fn, context) {
        if (this._markersToDraw) {
            this._markersToDraw.forEach(function (g) {
                if (context) {
                    fn.call(context, g);
                } else {
                    fn(g);
                }
            });
        }
    };

    _class.prototype.onGeometryShow = function onGeometryShow() {
        this._clusterNeedRedraw = true;
        _maptalks$renderer$Ve.prototype.onGeometryShow.apply(this, arguments);
    };

    _class.prototype.onGeometryHide = function onGeometryHide() {
        this._clusterNeedRedraw = true;
        _maptalks$renderer$Ve.prototype.onGeometryHide.apply(this, arguments);
    };

    _class.prototype.onGeometryAdd = function onGeometryAdd() {
        this._clusterNeedRedraw = true;
        _maptalks$renderer$Ve.prototype.onGeometryAdd.apply(this, arguments);
    };

    _class.prototype.onGeometryRemove = function onGeometryRemove() {
        this._clusterNeedRedraw = true;
        _maptalks$renderer$Ve.prototype.onGeometryRemove.apply(this, arguments);
    };

    _class.prototype.onGeometryPositionChange = function onGeometryPositionChange() {
        this._clusterNeedRedraw = true;
        _maptalks$renderer$Ve.prototype.onGeometryPositionChange.apply(this, arguments);
    };

    _class.prototype.onRemove = function onRemove() {
        this._clearDataCache();
    };

    _class.prototype.identify = function identify(coordinate, options) {
        var map = this.getMap(),
            maxZoom = this.layer.options['maxClusterZoom'];
        if (maxZoom && map.getZoom() > maxZoom) {
            return _maptalks$renderer$Ve.prototype.identify.call(this, coordinate, options);
        }
        if (this._currentClusters) {
            var point = map.coordinateToContainerPoint(coordinate);
            var old = this._currentGrid;
            for (var i = 0; i < this._currentClusters.length; i++) {
                var c = this._currentClusters[i];
                var pt = map._prjToContainerPoint(c['center']);
                this._currentGrid = c;
                var markerWidth = this._getSprite().canvas.width;

                if (point.distanceTo(pt) <= markerWidth) {
                    return {
                        'center': map.getProjection().unproject(c.center.copy()),
                        'children': c.children.slice(0)
                    };
                }
            }
            this._currentGrid = old;
        }

        // if no clusters is hit, identify markers
        if (this._markersToDraw && this._markersToDraw[0]) {
            var _point = map.coordinateToContainerPoint(coordinate);
            return this.layer._hitGeos(this._markersToDraw, _point, options);
        }
        return null;
    };

    _class.prototype.onSymbolChanged = function onSymbolChanged() {
        this._refreshStyle();
        this._computeGrid();
        this._stopAnim();
        this.setToRedraw();
    };

    _class.prototype._refreshStyle = function _refreshStyle() {
        var _this3 = this;

        var symbol = this.layer.options['symbol'] || defaultSymbol;
        var textSymbol = this.layer.options['textSymbol'] || defaultTextSymbol;
        var argFn = function argFn() {
            return [_this3.getMap().getZoom(), _this3._currentGrid];
        };
        this._symbol = maptalks.MapboxUtil.loadFunctionTypes(symbol, argFn);
        this._textSymbol = maptalks.MapboxUtil.loadFunctionTypes(textSymbol, argFn);
    };

    _class.prototype._drawLayer = function _drawLayer(clusters) {
        var _this4 = this;

        var parentClusters = this._currentClusters || clusters;
        this._currentClusters = clusters;
        delete this._clusterMaskExtent;
        var layer = this.layer;
        //if (layer.options['animation'] && this._animated && this._inout === 'out') {
        if (layer.options['animation'] && this._animated && this._inout) {
            var dr = [0, 1];
            if (this._inout === 'in') {
                dr = [1, 0];
            }
            this._player = maptalks.animation.Animation.animate({ 'd': dr }, { 'speed': layer.options['animationDuration'], 'easing': 'inAndOut' }, function (frame) {
                if (frame.state.playState === 'finished') {
                    _this4._animated = false;
                    _this4._drawClusters(clusters, 1);
                    _this4._drawMarkers();
                    _this4.completeRender();
                } else {
                    if (_this4._inout === 'in') {
                        _this4._drawClustersFrame(clusters, parentClusters, frame.styles.d);
                    } else {
                        _this4._drawClustersFrame(parentClusters, clusters, frame.styles.d);
                    }
                    _this4.setCanvasUpdated();
                }
            }).play();
        } else {
            this._animated = false;
            this._drawClusters(clusters, 1);
            this._drawMarkers();
            this.completeRender();
        }
    };

    _class.prototype._drawMarkers = function _drawMarkers() {
        _maptalks$renderer$Ve.prototype.drawGeos.call(this, this._clusterMaskExtent);
    };

    _class.prototype._drawClustersFrame = function _drawClustersFrame(parentClusters, toClusters, ratio) {
        var _this5 = this;

        this._clusterMaskExtent = this.prepareCanvas();
        var map = this.getMap(),
            drawn = {};
        if (parentClusters) {
            parentClusters.forEach(function (c) {
                var p = map._prjToContainerPoint(c['center']);
                if (!drawn[c.key]) {
                    drawn[c.key] = 1;
                    _this5._drawCluster(p, c, 1 - ratio);
                }
            });
        }
        if (ratio === 0 || !toClusters) {
            return;
        }
        var z = parentClusters.zoom,
            r = map._getResolution(z) * this.layer.options['maxClusterRadius'],
            min = this._markerExtent.getMin();
        toClusters.forEach(function (c) {
            var pt = map._prjToContainerPoint(c['center']);
            var center = c.center;
            var pgx = Math.floor((center.x - min.x) / r),
                pgy = Math.floor((center.y - min.y) / r);
            var pkey = pgx + '_' + pgy;
            var parent = _this5._clusterCache[z] ? _this5._clusterCache[z]['clusterMap'][pkey] : null;
            if (parent) {
                var pp = map._prjToContainerPoint(parent['center']);
                pt = pp.add(pt.sub(pp)._multi(ratio));
            }
            _this5._drawCluster(pt, c, ratio > 0.5 ? 1 : ratio);
        });
    };

    _class.prototype._drawClusters = function _drawClusters(clusters, ratio) {
        var _this6 = this;

        if (!clusters) {
            return;
        }
        this._clusterMaskExtent = this.prepareCanvas();
        var map = this.getMap();
        clusters.forEach(function (c) {
            var pt = map._prjToContainerPoint(c['center']);
            _this6._drawCluster(pt, c, ratio > 0.5 ? 1 : ratio);
        });
    };

    _class.prototype._drawCluster = function _drawCluster(pt, cluster, op) {
        this._currentGrid = cluster;
        var ctx = this.context;
        var sprite = this._getSprite();
        var opacity = ctx.globalAlpha;
        if (opacity * op === 0) {
            return;
        }
        ctx.globalAlpha = opacity * op;
        if (sprite) {
            var pos = pt.add(sprite.offset)._sub(sprite.canvas.width / 2, sprite.canvas.height / 2);
            ctx.drawImage(sprite.canvas, pos.x, pos.y);
        }

        if (this.layer.options['drawClusterText'] && cluster['textSize']) {
            maptalks.Canvas.prepareCanvasFont(ctx, this._textSymbol);
            ctx.textBaseline = 'middle';
            var dx = this._textSymbol['textDx'] || 0;
            var dy = this._textSymbol['textDy'] || 0;
            var text = this._getClusterText(cluster);
            maptalks.Canvas.fillText(ctx, text, pt.sub(cluster['textSize'].x, 0)._add(dx, dy));
        }
        ctx.globalAlpha = opacity;
    };

    _class.prototype._getClusterText = function _getClusterText(cluster) {
        var text = this.layer.options['textSumProperty'] ? cluster['textSumProperty'] : cluster['count'];
        return text + '';
    };

    _class.prototype._getSprite = function _getSprite() {
        if (!this._spriteCache) {
            this._spriteCache = {};
        }
        var key = maptalks.Util.getSymbolStamp(this._symbol);
        if (!this._spriteCache[key]) {
            this._spriteCache[key] = new maptalks.Marker([0, 0], { 'symbol': this._symbol })._getSprite(this.resources, this.getMap().CanvasClass);
        }
        return this._spriteCache[key];
    };

    _class.prototype._initGridSystem = function _initGridSystem() {
        var points = [];
        var extent = void 0,
            c = void 0;
        this.layer.forEach(function (g) {
            if (!g.isVisible()) {
                return;
            }
            c = g._getPrjCoordinates();
            if (!extent) {
                extent = g._getPrjExtent();
            } else {
                extent = extent._combine(g._getPrjExtent());
            }
            points.push({
                x: c.x,
                y: c.y,
                id: g._getInternalId(),
                geometry: g
            });
        });
        this._markerExtent = extent;
        this._markerPoints = points;
    };

    _class.prototype._computeGrid = function _computeGrid() {
        var map = this.getMap(),
            zoom = map.getZoom();
        if (!this._markerExtent) {
            this._initGridSystem();
        }
        if (!this._clusterCache) {
            this._clusterCache = {};
        }
        var pre = map._getResolution(map.getMinZoom()) > map._getResolution(map.getMaxZoom()) ? zoom - 1 : zoom + 1;
        if (this._clusterCache[pre] && this._clusterCache[pre].length === this.layer.getCount()) {
            this._clusterCache[zoom] = this._clusterCache[pre];
        }
        if (!this._clusterCache[zoom]) {
            this._clusterCache[zoom] = this._computeZoomGrid(zoom);
        }
    };

    _class.prototype._computeZoomGrid = function _computeZoomGrid(zoom) {
        if (!this._markerExtent) {
            return null;
        }
        var map = this.getMap(),
            r = map._getResolution(zoom) * this.layer.options['maxClusterRadius'],
            preT = map._getResolution(zoom - 1) ? map._getResolution(zoom - 1) * this.layer.options['maxClusterRadius'] : null;
        var preCache = this._clusterCache[zoom - 1];
        if (!preCache && zoom - 1 >= map.getMinZoom()) {
            this._clusterCache[zoom - 1] = preCache = this._computeZoomGrid(zoom - 1);
        }
        // 1. format extent of markers to grids with raidus of r
        // 2. find point's grid in the grids
        // 3. sum up the point into the grid's collection
        var points = this._markerPoints;
        var sumProperty = this.layer.options['textSumProperty'];
        var grids = {},
            min = this._markerExtent.getMin();
        var gx = void 0,
            gy = void 0,
            key = void 0,
            pgx = void 0,
            pgy = void 0,
            pkey = void 0;
        for (var i = 0, len = points.length; i < len; i++) {
            var geo = points[i].geometry;
            var sumProp = 0;

            if (sumProperty && geo.getProperties() && geo.getProperties()[sumProperty]) {
                sumProp = geo.getProperties()[sumProperty];
            }

            gx = Math.floor((points[i].x - min.x) / r);
            gy = Math.floor((points[i].y - min.y) / r);
            key = gx + '_' + gy;
            if (!grids[key]) {
                grids[key] = {
                    'sum': new maptalks.Coordinate(points[i].x, points[i].y),
                    'center': new maptalks.Coordinate(points[i].x, points[i].y),
                    'count': 1,
                    'textSumProperty': sumProp,
                    'children': [geo],
                    'key': key + ''
                };
                if (preT && preCache) {
                    pgx = Math.floor((points[i].x - min.x) / preT);
                    pgy = Math.floor((points[i].y - min.y) / preT);
                    pkey = pgx + '_' + pgy;
                    grids[key]['parent'] = preCache['clusterMap'][pkey];
                }
            } else {

                grids[key]['sum']._add(new maptalks.Coordinate(points[i].x, points[i].y));
                grids[key]['count']++;
                grids[key]['center'] = grids[key]['sum'].multi(1 / grids[key]['count']);
                grids[key]['children'].push(geo);
                grids[key]['textSumProperty'] += sumProp;
            }
        }
        return this._mergeClusters(grids, r / 2);
    };

    _class.prototype._mergeClusters = function _mergeClusters(grids, r) {
        var clusterMap = {};
        for (var p in grids) {
            clusterMap[p] = grids[p];
        }

        // merge adjacent clusters
        var merging = {};

        var visited = {};
        // find clusters need to merge
        var c1 = void 0,
            c2 = void 0;
        for (var _p in grids) {
            c1 = grids[_p];
            if (visited[c1.key]) {
                continue;
            }
            var gxgy = c1.key.split('_');
            var gx = +gxgy[0],
                gy = +gxgy[1];
            //traverse adjacent grids
            for (var ii = -1; ii <= 1; ii++) {
                for (var iii = -1; iii <= 1; iii++) {
                    if (ii === 0 && iii === 0) {
                        continue;
                    }
                    var key2 = gx + ii + '_' + (gy + iii);
                    c2 = grids[key2];
                    if (c2 && this._distanceTo(c1['center'], c2['center']) <= r) {
                        if (!merging[c1.key]) {
                            merging[c1.key] = [];
                        }
                        merging[c1.key].push(c2);
                        visited[c2.key] = 1;
                    }
                }
            }
        }

        //merge clusters
        for (var m in merging) {
            var grid = grids[m];
            if (!grid) {
                continue;
            }
            var toMerge = merging[m];
            for (var i = 0; i < toMerge.length; i++) {
                if (grids[toMerge[i].key]) {
                    grid['sum']._add(toMerge[i].sum);
                    grid['count'] += toMerge[i].count;
                    grid['textSumProperty'] += toMerge[i].textSumProperty;
                    grid['children'] = grid['children'].concat(toMerge[i].children);
                    clusterMap[toMerge[i].key] = grid;
                    delete grids[toMerge[i].key];
                }
            }
            grid['center'] = grid['sum'].multi(1 / grid['count']);
        }

        return {
            'clusters': grids,
            'clusterMap': clusterMap
        };
    };

    _class.prototype._distanceTo = function _distanceTo(c1, c2) {
        var x = c1.x - c2.x,
            y = c1.y - c2.y;
        return Math.sqrt(x * x + y * y);
    };

    _class.prototype._stopAnim = function _stopAnim() {
        if (this._player && this._player.playState !== 'finished') {
            this._player.finish();
        }
    };

    _class.prototype.onZoomStart = function onZoomStart(param) {
        this._stopAnim();
        _maptalks$renderer$Ve.prototype.onZoomStart.call(this, param);
    };

    _class.prototype.onZoomEnd = function onZoomEnd(param) {
        if (this.layer.isEmpty() || !this.layer.isVisible()) {
            _maptalks$renderer$Ve.prototype.onZoomEnd.apply(this, arguments);
            return;
        }
        this._inout = param['from'] > param['to'] ? 'in' : 'out';
        this._animated = true;
        this._computeGrid();
        _maptalks$renderer$Ve.prototype.onZoomEnd.apply(this, arguments);
    };

    _class.prototype._clearDataCache = function _clearDataCache() {
        this._stopAnim();
        delete this._markerExtent;
        delete this._markerPoints;
        delete this._clusterCache;
        delete this._zoomInClusters;
    };

    return _class;
}(maptalks.renderer.VectorLayerCanvasRenderer));

exports.ClusterLayer = ClusterLayer;

Object.defineProperty(exports, '__esModule', { value: true });

// typeof console !== 'undefined' && console.log('maptalks.markercluster v0.8.8');

})));
/*!
 * maptalks.plotsymbol v0.6.0
 * LICENSE : MIT
 * (c) 2016-2022 maptalks.org
 */
/*!
 * requires maptalks@>=0.44.1 
 */
(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('maptalks')) :
	typeof define === 'function' && define.amd ? define(['exports', 'maptalks'], factory) :
	(factory((global.maptalks = global.maptalks || {}),global.maptalks));
}(this, (function (exports,maptalks) { 'use strict';

var pointGeometry = Point$1;

/**
 * A standalone point geometry with useful accessor, comparison, and
 * modification methods.
 *
 * @class Point
 * @param {Number} x the x-coordinate. this could be longitude or screen
 * pixels, or any other sort of unit.
 * @param {Number} y the y-coordinate. this could be latitude or screen
 * pixels, or any other sort of unit.
 * @example
 * var point = new Point(-77, 38);
 */
function Point$1(x, y) {
    this.x = x;
    this.y = y;
}

Point$1.prototype = {

    /**
     * Clone this point, returning a new point that can be modified
     * without affecting the old one.
     * @return {Point} the clone
     */
    clone: function clone() {
        return new Point$1(this.x, this.y);
    },

    /**
     * Add this point's x & y coordinates to another point,
     * yielding a new point.
     * @param {Point} p the other point
     * @return {Point} output point
     */
    add: function add(p) {
        return this.clone()._add(p);
    },

    /**
     * Subtract this point's x & y coordinates to from point,
     * yielding a new point.
     * @param {Point} p the other point
     * @return {Point} output point
     */
    sub: function sub(p) {
        return this.clone()._sub(p);
    },

    /**
     * Multiply this point's x & y coordinates by point,
     * yielding a new point.
     * @param {Point} p the other point
     * @return {Point} output point
     */
    multByPoint: function multByPoint(p) {
        return this.clone()._multByPoint(p);
    },

    /**
     * Divide this point's x & y coordinates by point,
     * yielding a new point.
     * @param {Point} p the other point
     * @return {Point} output point
     */
    divByPoint: function divByPoint(p) {
        return this.clone()._divByPoint(p);
    },

    /**
     * Multiply this point's x & y coordinates by a factor,
     * yielding a new point.
     * @param {Point} k factor
     * @return {Point} output point
     */
    mult: function mult(k) {
        return this.clone()._mult(k);
    },

    /**
     * Divide this point's x & y coordinates by a factor,
     * yielding a new point.
     * @param {Point} k factor
     * @return {Point} output point
     */
    div: function div(k) {
        return this.clone()._div(k);
    },

    /**
     * Rotate this point around the 0, 0 origin by an angle a,
     * given in radians
     * @param {Number} a angle to rotate around, in radians
     * @return {Point} output point
     */
    rotate: function rotate(a) {
        return this.clone()._rotate(a);
    },

    /**
     * Rotate this point around p point by an angle a,
     * given in radians
     * @param {Number} a angle to rotate around, in radians
     * @param {Point} p Point to rotate around
     * @return {Point} output point
     */
    rotateAround: function rotateAround(a, p) {
        return this.clone()._rotateAround(a, p);
    },

    /**
     * Multiply this point by a 4x1 transformation matrix
     * @param {Array<Number>} m transformation matrix
     * @return {Point} output point
     */
    matMult: function matMult(m) {
        return this.clone()._matMult(m);
    },

    /**
     * Calculate this point but as a unit vector from 0, 0, meaning
     * that the distance from the resulting point to the 0, 0
     * coordinate will be equal to 1 and the angle from the resulting
     * point to the 0, 0 coordinate will be the same as before.
     * @return {Point} unit vector point
     */
    unit: function unit() {
        return this.clone()._unit();
    },

    /**
     * Compute a perpendicular point, where the new y coordinate
     * is the old x coordinate and the new x coordinate is the old y
     * coordinate multiplied by -1
     * @return {Point} perpendicular point
     */
    perp: function perp() {
        return this.clone()._perp();
    },

    /**
     * Return a version of this point with the x & y coordinates
     * rounded to integers.
     * @return {Point} rounded point
     */
    round: function round() {
        return this.clone()._round();
    },

    /**
     * Return the magitude of this point: this is the Euclidean
     * distance from the 0, 0 coordinate to this point's x and y
     * coordinates.
     * @return {Number} magnitude
     */
    mag: function mag() {
        return Math.sqrt(this.x * this.x + this.y * this.y);
    },

    /**
     * Judge whether this point is equal to another point, returning
     * true or false.
     * @param {Point} other the other point
     * @return {boolean} whether the points are equal
     */
    equals: function equals(other) {
        return this.x === other.x && this.y === other.y;
    },

    /**
     * Calculate the distance from this point to another point
     * @param {Point} p the other point
     * @return {Number} distance
     */
    dist: function dist(p) {
        return Math.sqrt(this.distSqr(p));
    },

    /**
     * Calculate the distance from this point to another point,
     * without the square root step. Useful if you're comparing
     * relative distances.
     * @param {Point} p the other point
     * @return {Number} distance
     */
    distSqr: function distSqr(p) {
        var dx = p.x - this.x,
            dy = p.y - this.y;
        return dx * dx + dy * dy;
    },

    /**
     * Get the angle from the 0, 0 coordinate to this point, in radians
     * coordinates.
     * @return {Number} angle
     */
    angle: function angle() {
        return Math.atan2(this.y, this.x);
    },

    /**
     * Get the angle from this point to another point, in radians
     * @param {Point} b the other point
     * @return {Number} angle
     */
    angleTo: function angleTo(b) {
        return Math.atan2(this.y - b.y, this.x - b.x);
    },

    /**
     * Get the angle between this point and another point, in radians
     * @param {Point} b the other point
     * @return {Number} angle
     */
    angleWith: function angleWith(b) {
        return this.angleWithSep(b.x, b.y);
    },

    /*
     * Find the angle of the two vectors, solving the formula for
     * the cross product a x b = |a||b|sin(θ) for θ.
     * @param {Number} x the x-coordinate
     * @param {Number} y the y-coordinate
     * @return {Number} the angle in radians
     */
    angleWithSep: function angleWithSep(x, y) {
        return Math.atan2(this.x * y - this.y * x, this.x * x + this.y * y);
    },

    _matMult: function _matMult(m) {
        var x = m[0] * this.x + m[1] * this.y,
            y = m[2] * this.x + m[3] * this.y;
        this.x = x;
        this.y = y;
        return this;
    },

    _add: function _add(p) {
        this.x += p.x;
        this.y += p.y;
        return this;
    },

    _sub: function _sub(p) {
        this.x -= p.x;
        this.y -= p.y;
        return this;
    },

    _mult: function _mult(k) {
        this.x *= k;
        this.y *= k;
        return this;
    },

    _div: function _div(k) {
        this.x /= k;
        this.y /= k;
        return this;
    },

    _multByPoint: function _multByPoint(p) {
        this.x *= p.x;
        this.y *= p.y;
        return this;
    },

    _divByPoint: function _divByPoint(p) {
        this.x /= p.x;
        this.y /= p.y;
        return this;
    },

    _unit: function _unit() {
        this._div(this.mag());
        return this;
    },

    _perp: function _perp() {
        var y = this.y;
        this.y = this.x;
        this.x = -y;
        return this;
    },

    _rotate: function _rotate(angle) {
        var cos = Math.cos(angle),
            sin = Math.sin(angle),
            x = cos * this.x - sin * this.y,
            y = sin * this.x + cos * this.y;
        this.x = x;
        this.y = y;
        return this;
    },

    _rotateAround: function _rotateAround(angle, p) {
        var cos = Math.cos(angle),
            sin = Math.sin(angle),
            x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),
            y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
        this.x = x;
        this.y = y;
        return this;
    },

    _round: function _round() {
        this.x = Math.round(this.x);
        this.y = Math.round(this.y);
        return this;
    }
};

/**
 * Construct a point from an array if necessary, otherwise if the input
 * is already a Point, or an unknown type, return it unchanged
 * @param {Array<Number>|Point|*} a any kind of input value
 * @return {Point} constructed point, or passed-through value.
 * @example
 * // this
 * var point = Point.convert([0, 1]);
 * // is equivalent to
 * var point = new Point(0, 1);
 */
Point$1.convert = function (a) {
    if (a instanceof Point$1) {
        return a;
    }
    if (Array.isArray(a)) {
        return new Point$1(a[0], a[1]);
    }
    return a;
};

var FITTING_COUNT = 100;
var HALF_PI = Math.PI / 2;
var ZERO_TOLERANCE = 0.0001;

function _defaults(obj, defaults) { var keys = Object.getOwnPropertyNames(defaults); for (var i = 0; i < keys.length; i++) { var key = keys[i]; var value = Object.getOwnPropertyDescriptor(defaults, key); if (value && value.configurable && obj[key] === undefined) { Object.defineProperty(obj, key, value); } } return obj; }











var classCallCheck = function (instance, Constructor) {
  if (!(instance instanceof Constructor)) {
    throw new TypeError("Cannot call a class as a function");
  }
};











var inherits = function (subClass, superClass) {
  if (typeof superClass !== "function" && superClass !== null) {
    throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
  }

  subClass.prototype = Object.create(superClass && superClass.prototype, {
    constructor: {
      value: subClass,
      enumerable: false,
      writable: true,
      configurable: true
    }
  });
  if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : _defaults(subClass, superClass);
};











var possibleConstructorReturn = function (self, call) {
  if (!self) {
    throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  }

  return call && (typeof call === "object" || typeof call === "function") ? call : self;
};

/**
 * There are many interpolation method
 * based on code finished by @sakitam-fdd https://github.com/sakitam-fdd/maptalks.plot.git
 */
var Coordinate$1 = maptalks.Coordinate;
var Canvas$1 = maptalks.Canvas;

/**
 *                  nextNormal
 *    currentVertex    ↑
 *                .________. nextVertex
 *                |\
 *     normal  ←  | \ joinNormal
 *                |
 *     prevVertex !
 *
 * get join normal between 2 line segments
 * @param  {[type]} normal     [description]
 * @param  {[type]} nextNormal [description]
 * @return {[type]}            [description]
 */
function getJoinNormal(normal, nextNormal) {
    var joinNormal = normal.add(nextNormal)._unit();
    var cosHalfAngle = joinNormal.x * nextNormal.x + joinNormal.y * nextNormal.y;
    var miterLength = 1 / cosHalfAngle;
    return joinNormal._mult(miterLength);
}

function getPlotPair(vertex, normal, lineWidth) {
    // first plot pair
    var dx = normal.x * lineWidth;
    var dy = normal.y * lineWidth;
    var p1 = vertex.add(dx, dy);
    var p2 = vertex.add(-dx, -dy);
    return [p1, p2];
}

/**
   * Get arrow body for given vertexes.
   * @param  {maptalks.Coordinate[]} vertexes    - input vertexes
   * @param  {[type]} lineWidth [description]
   * @param  {[type]} map       [description]
   * @param  {[type]} ratio     [description]
   * @return {[type]}           [description]
   */
var getArrowBody = function getArrowBody(vertexes, lineWidth, map, ratio, arrowLength) {
    lineWidth /= 2;
    var arrowWidth = void 0;
    var currentLen = 0;
    var upPlots = [],
        downPlots = [];
    var pair = void 0;
    // let dx, dy;
    var current = void 0,
        prev = void 0,
        next = void 0;
    var normal = void 0,
        currentNormal = void 0,
        nextNormal = void 0;
    for (var i = 1, l = vertexes.length; i < l; i++) {
        current = new pointGeometry(vertexes[i].x, vertexes[i].y);
        prev = new pointGeometry(vertexes[i - 1].x, vertexes[i - 1].y);
        if (ratio && arrowLength) {
            currentLen += current.dist(prev);
            arrowWidth = (1 - (1 - ratio) * currentLen / arrowLength) * lineWidth;
        } else {
            arrowWidth = lineWidth;
        }

        if (i < l - 1) {
            next = new pointGeometry(vertexes[i + 1].x, vertexes[i + 1].y);
        } else {
            next = null;
        }
        normal = current.sub(prev)._unit()._perp();
        if (i === 1) {
            pair = getPlotPair(vertexes[i - 1], normal, lineWidth, map);
            upPlots.push(pair[0]);
            downPlots.push(pair[1]);
        }
        if (next) {
            nextNormal = next.sub(current)._unit()._perp();
            currentNormal = getJoinNormal(normal, nextNormal);
        } else {
            currentNormal = normal;
        }
        if (isNaN(currentNormal.x) || isNaN(currentNormal.y)) {
            continue;
        }
        pair = getPlotPair(vertexes[i], currentNormal, arrowWidth, map);
        upPlots.push(pair[0]);
        downPlots.push(pair[1]);
    }
    return [upPlots, downPlots];
};

/**
 * 计算两个坐标之间的距离
 * @param pnt1
 * @param pnt2
 * @returns {number}
 * @constructor
 */
var MathDistance = function MathDistance(pnt1, pnt2) {
    return Math.sqrt(Math.pow(pnt1[0] - pnt2[0], 2) + Math.pow(pnt1[1] - pnt2[1], 2));
};

/**
 * 计算距离
 * @param measurer
 * @param pnt1
 * @param pnt2
 * @returns {*}
 */
var pointDistance = function pointDistance(measurer, pnt1, pnt2) {
    return measurer.measureLength(Coordinate$1.toCoordinates(pnt1), Coordinate$1.toCoordinates(pnt2));
};
/**
 * 插值弓形线段点
 * @param measurer
 * @param center
 * @param radius
 * @param startAngle
 * @param endAngle
 * @param numberOfPoints
 * @returns {null}
 */
var getSectorPoints = function getSectorPoints(measurer, center, radius, startAngle, endAngle) {
    var numberOfPoints = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 100;
    var dx = null,
        dy = null,
        angleDiff = endAngle - startAngle;

    var points = [];
    angleDiff = angleDiff < 0 ? angleDiff + Math.PI * 2 : angleDiff;
    for (var i = 0; i < numberOfPoints; i++) {
        var rad = angleDiff * i / numberOfPoints + startAngle;
        dx = radius * Math.cos(rad);
        dy = radius * Math.sin(rad);
        var vertex = measurer.locate({
            'x': center[0],
            'y': center[1]
        }, dx, dy);
        points.push([vertex['x'], vertex['y']]);
    }
    return points;
};
/**
 * 计算点集合的总距离
 * @param points
 * @returns {number}
 */
var wholeDistance = function wholeDistance(points) {
    var distance = 0;
    if (points && Array.isArray(points) && points.length > 0) {
        points.forEach(function (item, index) {
            if (index < points.length - 1) {
                distance += MathDistance(item, points[index + 1]);
            }
        });
    }
    return distance;
};
/**
 * 获取基础长度
 * @param points
 * @returns {number}
 */
var getBaseLength = function getBaseLength(points) {
    return Math.pow(wholeDistance(points), 0.99);
};

/**
 * 求取两个坐标的中间值
 * @param point1
 * @param point2
 * @returns {[*,*]}
 * @constructor
 */
var Mid = function Mid(point1, point2) {
    return [(point1[0] + point2[0]) / 2, (point1[1] + point2[1]) / 2];
};

/**
 * 获取交集的点
 * @param pntA
 * @param pntB
 * @param pntC
 * @param pntD
 * @returns {[*,*]}
 */


/**
 * 通过三个点确定一个圆的中心点
 * @param point1
 * @param point2
 * @param point3
 */


/**
 * 获取方位角（地平经度）
 * @param startPoint
 * @param endPoint
 * @returns {*}
 */
var getAzimuth = function getAzimuth(startPoint, endPoint) {
    var azimuth = void 0;
    var angle = Math.asin(Math.abs(endPoint[1] - startPoint[1]) / MathDistance(startPoint, endPoint));
    if (endPoint[1] >= startPoint[1] && endPoint[0] >= startPoint[0]) {
        azimuth = angle + Math.PI;
    } else if (endPoint[1] >= startPoint[1] && endPoint[0] < startPoint[0]) {
        azimuth = Math.PI * 2 - angle;
    } else if (endPoint[1] < startPoint[1] && endPoint[0] < startPoint[0]) {
        azimuth = angle;
    } else if (endPoint[1] < startPoint[1] && endPoint[0] >= startPoint[0]) {
        azimuth = Math.PI - angle;
    }
    return azimuth;
};

/**
 * 通过三个点获取方位角
 * @param pntA
 * @param pntB
 * @param pntC
 * @returns {number}
 */
var getAngleOfThreePoints = function getAngleOfThreePoints(pntA, pntB, pntC) {
    var angle = getAzimuth(pntB, pntA) - getAzimuth(pntB, pntC);
    return angle < 0 ? angle + Math.PI * 2 : angle;
};

/**
 * 判断是否是顺时针
 * @param pnt1
 * @param pnt2
 * @param pnt3
 * @returns {boolean}
 */
var isClockWise = function isClockWise(pnt1, pnt2, pnt3) {
    return (pnt3[1] - pnt1[1]) * (pnt2[0] - pnt1[0]) > (pnt2[1] - pnt1[1]) * (pnt3[0] - pnt1[0]);
};

/**
 * 获取立方值
 * @param t
 * @param startPnt
 * @param cPnt1
 * @param cPnt2
 * @param endPnt
 * @returns {[*,*]}
 */
var getCubicValue = function getCubicValue(t, startPnt, cPnt1, cPnt2, endPnt) {
    t = Math.max(Math.min(t, 1), 0);
    var tp = 1 - t,
        t2 = t * t;

    var t3 = t2 * t;
    var tp2 = tp * tp;
    var tp3 = tp2 * tp;
    var x = tp3 * startPnt[0] + 3 * tp2 * t * cPnt1[0] + 3 * tp * t2 * cPnt2[0] + t3 * endPnt[0];
    var y = tp3 * startPnt[1] + 3 * tp2 * t * cPnt1[1] + 3 * tp * t2 * cPnt2[1] + t3 * endPnt[1];
    return [x, y];
};

/**
 * 根据起止点和旋转方向求取第三个点
 * @param startPnt
 * @param endPnt
 * @param angle
 * @param distance
 * @param clockWise
 * @returns {[*,*]}
 */
var getThirdPoint = function getThirdPoint(startPnt, endPnt, angle, distance, clockWise) {
    var azimuth = getAzimuth(startPnt, endPnt);
    var alpha = clockWise ? azimuth + angle : azimuth - angle;
    var dx = distance * Math.cos(alpha);
    var dy = distance * Math.sin(alpha);
    return [endPnt[0] + dx, endPnt[1] + dy];
};

/**
 * 插值弓形线段点
 * @param center
 * @param radius
 * @param startAngle
 * @param endAngle
 * @returns {null}
 */


/**
 * 获取默认三点的内切圆
 * @param pnt1
 * @param pnt2
 * @param pnt3
 * @returns {[*,*]}
 */
var getNormal = function getNormal(pnt1, pnt2, pnt3) {
    var dX1 = pnt1[0] - pnt2[0];
    var dY1 = pnt1[1] - pnt2[1];
    var d1 = Math.sqrt(dX1 * dX1 + dY1 * dY1);
    dX1 /= d1;
    dY1 /= d1;
    var dX2 = pnt3[0] - pnt2[0];
    var dY2 = pnt3[1] - pnt2[1];
    var d2 = Math.sqrt(dX2 * dX2 + dY2 * dY2);
    dX2 /= d2;
    dY2 /= d2;
    var uX = dX1 + dX2;
    var uY = dY1 + dY2;
    return [uX, uY];
};

/**
 * getBisectorNormals
 * @param t
 * @param pnt1
 * @param pnt2
 * @param pnt3
 * @returns {[*,*]}
 */
var getBisectorNormals = function getBisectorNormals(t, pnt1, pnt2, pnt3) {
    var normal = getNormal(pnt1, pnt2, pnt3);
    var bisectorNormalRight = null,
        bisectorNormalLeft = null,
        dt = null,
        x = null,
        y = null;

    var dist = Math.sqrt(normal[0] * normal[0] + normal[1] * normal[1]);
    var uX = normal[0] / dist;
    var uY = normal[1] / dist;
    var d1 = MathDistance(pnt1, pnt2);
    var d2 = MathDistance(pnt2, pnt3);
    if (dist > ZERO_TOLERANCE) {
        if (isClockWise(pnt1, pnt2, pnt3)) {
            dt = t * d1;
            x = pnt2[0] - dt * uY;
            y = pnt2[1] + dt * uX;
            bisectorNormalRight = [x, y];
            dt = t * d2;
            x = pnt2[0] + dt * uY;
            y = pnt2[1] - dt * uX;
            bisectorNormalLeft = [x, y];
        } else {
            dt = t * d1;
            x = pnt2[0] + dt * uY;
            y = pnt2[1] - dt * uX;
            bisectorNormalRight = [x, y];
            dt = t * d2;
            x = pnt2[0] - dt * uY;
            y = pnt2[1] + dt * uX;
            bisectorNormalLeft = [x, y];
        }
    } else {
        x = pnt2[0] + t * (pnt1[0] - pnt2[0]);
        y = pnt2[1] + t * (pnt1[1] - pnt2[1]);
        bisectorNormalRight = [x, y];
        x = pnt2[0] + t * (pnt3[0] - pnt2[0]);
        y = pnt2[1] + t * (pnt3[1] - pnt2[1]);
        bisectorNormalLeft = [x, y];
    }
    return [bisectorNormalRight, bisectorNormalLeft];
};

/**
 * 获取左边控制点
 * @param controlPoints
 * @returns {[*,*]}
 */


/**
 * 获取右边控制点
 * @param controlPoints
 * @param t
 * @returns {[*,*]}
 */


/**
 * 插值曲线点
 * @param t
 * @param controlPoints
 * @returns {null}
 */


/**
 * 获取阶乘数据
 * @param n
 * @returns {number}
 */
var getFactorial = function getFactorial(n) {
    var result = 1;
    switch (n) {
        case n <= 1:
            result = 1;
            break;
        case n === 2:
            result = 2;
            break;
        case n === 3:
            result = 6;
            break;
        case n === 24:
            result = 24;
            break;
        case n === 5:
            result = 120;
            break;
        default:
            for (var i = 1; i <= n; i++) {
                result *= i;
            }
            break;
    }
    return result;
};

/**
 * 获取二项分布
 * @param n
 * @param index
 * @returns {number}
 */
var getBinomialFactor = function getBinomialFactor(n, index) {
    return getFactorial(n) / (getFactorial(index) * getFactorial(n - index));
};

/**
 * 贝塞尔曲线
 * @param points
 * @returns {*}
 */
var getBezierPoints = function getBezierPoints(points) {
    if (points.length <= 2) {
        return points;
    } else {
        var bezierPoints = [];
        var n = points.length - 1;
        for (var t = 0; t <= 1; t += 0.01) {
            var x = 0,
                y = 0;

            for (var index = 0; index <= n; index++) {
                var factor = getBinomialFactor(n, index);
                var a = Math.pow(t, index);
                var b = Math.pow(1 - t, n - index);
                x += factor * a * b * points[index][0];
                y += factor * a * b * points[index][1];
            }
            bezierPoints.push([x, y]);
        }
        bezierPoints.push(points[n]);
        return bezierPoints;
    }
};

/**
 * 得到二次线性因子
 * @param k
 * @param t
 * @returns {number}
 */


/**
 * 插值线性点
 * @param points
 * @returns {*}
 */






/**
     * 判断是否为对象
     * @param value
     * @returns {boolean}
     */




//和maptalks.Canvas.paintSmoothLine类似，只不过去掉了begainPath的逻辑
var paintSmoothLine = function paintSmoothLine(ctx, points, lineOpacity, smoothValue, draw, close, tailIdx, tailRatio) {
    //推算 cubic 贝塞尔曲线片段的起终点和控制点坐标
    //t0: 片段起始比例 0-1
    //t1: 片段结束比例 0-1
    //x1, y1, 曲线起点
    //bx1, by1, bx2, by2，曲线控制点
    //x2, y2  曲线终点
    //结果是曲线片段的起点，2个控制点坐标和终点坐标
    //https://stackoverflow.com/questions/878862/drawing-part-of-a-b%C3%A9zier-curve-by-reusing-a-basic-b%C3%A9zier-curve-function/879213#879213
    function interpolate(t0, t1, x1, y1, bx1, by1, bx2, by2, x2, y2) {
        var u0 = 1.0 - t0;
        var u1 = 1.0 - t1;

        var qxa = x1 * u0 * u0 + bx1 * 2 * t0 * u0 + bx2 * t0 * t0;
        var qxb = x1 * u1 * u1 + bx1 * 2 * t1 * u1 + bx2 * t1 * t1;
        var qxc = bx1 * u0 * u0 + bx2 * 2 * t0 * u0 + x2 * t0 * t0;
        var qxd = bx1 * u1 * u1 + bx2 * 2 * t1 * u1 + x2 * t1 * t1;

        var qya = y1 * u0 * u0 + by1 * 2 * t0 * u0 + by2 * t0 * t0;
        var qyb = y1 * u1 * u1 + by1 * 2 * t1 * u1 + by2 * t1 * t1;
        var qyc = by1 * u0 * u0 + by2 * 2 * t0 * u0 + y2 * t0 * t0;
        var qyd = by1 * u1 * u1 + by2 * 2 * t1 * u1 + y2 * t1 * t1;

        // const xa = qxa * u0 + qxc * t0;
        var xb = qxa * u1 + qxc * t1;
        var xc = qxb * u0 + qxd * t0;
        var xd = qxb * u1 + qxd * t1;

        // const ya = qya * u0 + qyc * t0;
        var yb = qya * u1 + qyc * t1;
        var yc = qyb * u0 + qyd * t0;
        var yd = qyb * u1 + qyd * t1;

        return [xb, yb, xc, yc, xd, yd];
    }

    //from http://www.antigrain.com/research/bezier_interpolation/
    function getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, t) {
        // Assume we need to calculate the control
        // points between (x1,y1) and (x2,y2).
        // Then x0,y0 - the previous vertex,
        //      x3,y3 - the next one.
        var xc1 = (x0 + x1) / 2.0,
            yc1 = (y0 + y1) / 2.0;
        var xc2 = (x1 + x2) / 2.0,
            yc2 = (y1 + y2) / 2.0;
        var xc3 = (x2 + x3) / 2.0,
            yc3 = (y2 + y3) / 2.0;

        var len1 = Math.sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
        var len2 = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        var len3 = Math.sqrt((x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2));

        var k1 = len1 / (len1 + len2);
        var k2 = len2 / (len2 + len3);

        var xm1 = xc1 + (xc2 - xc1) * k1,
            ym1 = yc1 + (yc2 - yc1) * k1;

        var xm2 = xc2 + (xc3 - xc2) * k2,
            ym2 = yc2 + (yc3 - yc2) * k2;

        // Resulting control points. Here smoothValue is mentioned
        // above coefficient K whose value should be in range [0...1].
        var ctrl1X = xm1 + (xc2 - xm1) * smoothValue + x1 - xm1,
            ctrl1Y = ym1 + (yc2 - ym1) * smoothValue + y1 - ym1,
            ctrl2X = xm2 + (xc2 - xm2) * smoothValue + x2 - xm2,
            ctrl2Y = ym2 + (yc2 - ym2) * smoothValue + y2 - ym2;

        var ctrlPoints = [ctrl1X, ctrl1Y, ctrl2X, ctrl2Y];
        if (t < 1) {
            return interpolate(0, t, x1, y1, ctrl1X, ctrl1Y, ctrl2X, ctrl2Y, x2, y2);
        } else {
            return ctrlPoints;
        }
    }

    function path(ctx, points, lineOpacity, fillOpacity, lineDashArray) {
        if (!maptalks.Util.isArrayHasData(points)) {
            return;
        }
        Canvas$1._path(ctx, points, lineDashArray, lineOpacity);
        Canvas$1._stroke(ctx, lineOpacity);
    }

    if (!points) {
        return null;
    }
    if (points.length <= 2 || !smoothValue) {
        if (draw) {
            path(ctx, points, lineOpacity);
        }
        return null;
    }

    var count = points.length;
    var l = close ? count : count - 1;

    if (tailRatio !== undefined) l -= Math.max(l - tailIdx - 1, 0);
    var preCtrlPoints = void 0;
    for (var i = 0; i < l; i++) {
        var x1 = points[i].x,
            y1 = points[i].y;

        var x0 = void 0,
            y0 = void 0,
            x2 = void 0,
            y2 = void 0,
            x3 = void 0,
            y3 = void 0;
        if (i - 1 < 0) {
            if (!close) {
                x0 = points[i + 1].x;
                y0 = points[i + 1].y;
            } else {
                x0 = points[l - 1].x;
                y0 = points[l - 1].y;
            }
        } else {
            x0 = points[i - 1].x;
            y0 = points[i - 1].y;
        }
        if (i + 1 < count) {
            x2 = points[i + 1].x;
            y2 = points[i + 1].y;
        } else {
            x2 = points[i + 1 - count].x;
            y2 = points[i + 1 - count].y;
        }
        if (i + 2 < count) {
            x3 = points[i + 2].x;
            y3 = points[i + 2].y;
        } else if (!close) {
            x3 = points[i].x;
            y3 = points[i].y;
        } else {
            x3 = points[i + 2 - count].x;
            y3 = points[i + 2 - count].y;
        }

        var ctrlPoints = getCubicControlPoints(x0, y0, x1, y1, x2, y2, x3, y3, smoothValue, i === l - 1 ? tailRatio : 1);
        if (i === l - 1 && tailRatio >= 0 && tailRatio < 1) {
            if (ctx) {
                ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], ctrlPoints[4], ctrlPoints[5]);
            }
            points.splice(l - 1, count - (l - 1) - 1);
            var lastPoint = new pointGeometry(ctrlPoints[4], ctrlPoints[5]);
            lastPoint.prevCtrlPoint = new pointGeometry(ctrlPoints[2], ctrlPoints[3]);
            points.push(lastPoint);
            count = points.length;
        } else if (ctx) {
            ctx.bezierCurveTo(ctrlPoints[0], ctrlPoints[1], ctrlPoints[2], ctrlPoints[3], x2, y2);
        }
        points[i].nextCtrlPoint = ctrlPoints.slice(0, 2);
        points[i].prevCtrlPoint = preCtrlPoints ? preCtrlPoints.slice(2) : null;
        preCtrlPoints = ctrlPoints;
    }
    if (!close && points[1].prevCtrlPoint) {
        points[0].nextCtrlPoint = points[1].prevCtrlPoint;
        delete points[0].prevCtrlPoint;
    }
    if (!points[count - 1].prevCtrlPoint) {
        points[count - 1].prevCtrlPoint = points[count - 2].nextCtrlPoint;
    }
    if (draw) {
        Canvas$1._stroke(ctx, lineOpacity);
    }
    return points;
};

/**
 * @property {Object} options
 */
var options = {
    'widthRatio': 0.10,
    'arrowStyle': [],
    'tailWidthFactor': 0.1,
    'headWidthFactor': 1,
    'neckWidthFactor': 0.2,
    'headAngle': Math.PI / 8.5,
    'neckAngle': Math.PI / 13
};

/**
 * @classdesc Curve style LineString
 * @class
 * @category geometry
 * @extends {maptalks.LineString}
 * @param {maptalks.Coordinate[]|Number[][]} coordinates - coordinates of the line string
 * @param {Object} [options=null]   - construct options defined in [maptalks.StraightArrow]{@link maptalks.StraightArrow#options}
 * @example
 * var curve = new maptalks.StraightArrow(
 *     [
 *         [121.47083767181408,31.214448123476995],
 *         [121.4751292062378,31.215475523000404],
 *         [121.47869117980943,31.211916269810335]
 *     ],
 *     {
 *         symbol : {
 *             'lineWidth': 5
 *         }
 *     }
 * ).addTo(layer);
 */

var StraightArrow = function (_maptalks$Curve) {
    inherits(StraightArrow, _maptalks$Curve);

    function StraightArrow() {
        classCallCheck(this, StraightArrow);
        return possibleConstructorReturn(this, _maptalks$Curve.apply(this, arguments));
    }

    StraightArrow.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var arrow = new StraightArrow(feature['geometry']['coordinates'], json['options']);
        arrow.setProperties(feature['properties']);
        return arrow;
    };

    StraightArrow.prototype._toJSON = function _toJSON(options) {
        return {
            'feature': this.toGeoJSON(options),
            'subType': 'StraightArrow'
        };
    };

    StraightArrow.prototype.startEdit = function startEdit() {
        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

        options.newVertexHandleSymbol = {
            'markerType': 'ellipse',
            'markerFill': '#fff',
            'markerLineColor': '#000',
            'markerLineWidth': 2,
            'markerWidth': 10,
            'markerHeight': 10,
            'opacity': 0
        };
        return _maptalks$Curve.prototype.startEdit.call(this, options);
    };

    StraightArrow.prototype._getPaintParams = function _getPaintParams() {
        var map = this.getMap();
        var zoomScale = map.getGLScale();
        var points = this._getPath2DPoints(this._getPrjCoordinates());
        if (points.length <= 1) {
            return null;
        }
        var length = this._get2DLength();
        var lineWidth = length * this.options['widthRatio'];

        var arrowPairs = getArrowBody(points, lineWidth, this.getMap());
        var h1 = arrowPairs[0][arrowPairs[0].length - 1],
            h2 = arrowPairs[1][arrowPairs[1].length - 1];
        var arrowHead = this._getArrowHead(h1, h2, points, lineWidth, 1, 0.8, 1.4, 2.2, 0.7, 2.3);
        var plots = [];
        plots.push.apply(plots, arrowPairs[0]);
        plots.push.apply(plots, arrowHead);
        for (var i = arrowPairs[1].length - 1; i >= 0; i--) {
            plots.push(arrowPairs[1][i]);
        }
        // convert to point in maxZoom
        plots = plots.map(function (p) {
            return p.multi(zoomScale);
        });
        return [plots, [arrowPairs[0].length, arrowHead.length, arrowPairs[1].length]];
    };

    StraightArrow.prototype._paintOn = function _paintOn(ctx, points, segs, lineOpacity, fillOpacity, lineDasharray) {
        ctx.beginPath();
        var seg = void 0;
        //draw body upside
        var i = 0;
        ctx.moveTo(points[0].x, points[0].y);
        seg = points.slice(0, segs[0]);
        // this._quadraticCurve(ctx, seg);
        paintSmoothLine(ctx, seg, lineOpacity, 0.7, true);
        //draw head
        i += segs[0];
        maptalks.Canvas._path(ctx, points.slice(i, i + segs[1]), lineDasharray, lineOpacity);
        //draw body downside
        i += segs[1];
        seg = points.slice(i, i + segs[2]);
        //this._quadraticCurve(ctx, seg);
        paintSmoothLine(ctx, seg, lineOpacity, 0.7, true);
        this._closeArrow(ctx, points[points.length - 1], points[0]);
        maptalks.Canvas._stroke(ctx, lineOpacity);
        maptalks.Canvas.fillCanvas(ctx, fillOpacity, points[0].x, points[0].y);
    };

    StraightArrow.prototype._closeArrow = function _closeArrow(ctx) {
        ctx.closePath();
    };

    /**
     * Get points of arrow head
     * @param  {maptalks.Point} h1   - head point 1
     * @param  {maptalks.Point} h2   - head point 2
     * @param  {maptalks.Point} points   - all points
     * @param  {Number} lineWidth    - line width
     * @return {maptalks.Point[]}
     */


    StraightArrow.prototype._getArrowHead = function _getArrowHead(h1, h2, points, lineWidth, lineRatio, f1, f2, hScale1, hScale2, h1h2Ratio) {
        var arrowHead = this._getArrowHeadPoint(h1, h2, points[points.length - 1], lineWidth * lineRatio, f1, hScale1);
        var vertex01 = new maptalks.Point((arrowHead[0].x + arrowHead[1].x) / 2, (arrowHead[0].y + arrowHead[1].y) / 2);
        var head0 = this._getArrowHeadPoint(arrowHead[0], arrowHead[1], vertex01, lineWidth * lineRatio, f2, hScale2)[0];
        var vertex21 = new maptalks.Point((arrowHead[2].x + arrowHead[1].x) / 2, (arrowHead[2].y + arrowHead[1].y) / 2);
        var head2 = this._getArrowHeadPoint(arrowHead[2], arrowHead[1], vertex21, lineWidth * lineRatio, f2, hScale2)[0];
        var arrowPoints = void 0;
        if (points.length === 2) {
            arrowPoints = [h1, head0, arrowHead[1], head2, h2];
        } else {
            var besierPoints = paintSmoothLine(null, points, null, 0.8, false);
            var controlPoint = new maptalks.Point(besierPoints[besierPoints.length - 1].prevCtrlPoint);
            //计算控制点与最后一个点构成的延长线上的某一点
            var lastPoint = points[points.length - 1];
            var sub = lastPoint.sub(controlPoint);
            if (sub.x === 0 && sub.y === 0) {
                return [h1, head0, arrowHead[1], head2, h2];
            }
            var h1h2Length = h1.distanceTo(h2);
            var direction = sub.unit();
            var headPoint = new maptalks.Point(lastPoint.x + direction.x * h1h2Length * h1h2Ratio, lastPoint.y + direction.y * h1h2Length * h1h2Ratio);
            arrowPoints = [h1, head0, headPoint, head2, h2];
        }
        return arrowPoints;
    };

    StraightArrow.prototype._getArrowHeadPoint = function _getArrowHeadPoint(h1, h2, vertex, lineWidth, f, hScale) {
        if (!hScale) {
            hScale = 1;
        }
        h1 = new pointGeometry(h1.x, h1.y);
        h2 = new pointGeometry(h2.x, h2.y);
        var normal = h1.sub(h2)._unit();
        var head0 = vertex.add(lineWidth * normal.x * f, lineWidth * normal.y * f);
        var head2 = vertex.add(lineWidth * -normal.x * f, lineWidth * -normal.y * f);
        normal._perp()._mult(-1);
        var head1 = vertex.add(hScale * lineWidth * normal.x, hScale * lineWidth * normal.y);
        return [head0, head1, head2];
    };

    return StraightArrow;
}(maptalks.Curve);

StraightArrow.mergeOptions(options);

StraightArrow.registerJSONType('StraightArrow');

maptalks.DrawTool.registerMode('StraightArrow', {
    action: ['click', 'mousemove', 'dblclick'],
    create: function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new StraightArrow(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    update: function update(projection, prjPath, geometry) {
        var prjCoords = void 0;
        if (Array.isArray(prjPath)) {
            prjCoords = prjPath;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(prjPath);
        }
        var path = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(path);
        geometry._setPrjCoordinates(prjCoords);
    },
    generate: function generate(geometry) {
        return geometry;
    }
});

/**
 * @property {Object} options
 */
var options$1 = {
    'widthRatio': 0.20,
    'arrowStyle': []
};

/**
 * @classdesc Curve style LineString
 * @class
 * @category geometry
 * @extends {maptalks.LineString}
 * @param {maptalks.Coordinate[]|Number[][]} coordinates - coordinates of the line string
 * @param {Object} [options=null]   - construct options defined in [maptalks.DiagonalArrow]{@link maptalks.DiagonalArrow#options}
 * @example
 * var curve = new maptalks.DiagonalArrow(
 *     [
 *         [121.47083767181408,31.214448123476995],
 *         [121.4751292062378,31.215475523000404],
 *         [121.47869117980943,31.211916269810335]
 *     ],
 *     {
 *         symbol : {
 *             'lineWidth' : 5
 *         }
 *     }
 * ).addTo(layer);
 */

var DiagonalArrow = function (_StraightArrow) {
    inherits(DiagonalArrow, _StraightArrow);

    function DiagonalArrow() {
        classCallCheck(this, DiagonalArrow);
        return possibleConstructorReturn(this, _StraightArrow.apply(this, arguments));
    }

    DiagonalArrow.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var arrow = new DiagonalArrow(feature['geometry']['coordinates'], json['options']);
        arrow.setProperties(feature['properties']);
        return arrow;
    };

    DiagonalArrow.prototype._toJSON = function _toJSON(options) {
        return {
            'feature': this.toGeoJSON(options),
            'subType': 'DiagonalArrow'
        };
    };

    DiagonalArrow.prototype._getPaintParams = function _getPaintParams() {
        var points = this._getPath2DPoints(this._getPrjCoordinates());
        if (points.length <= 1) {
            return null;
        }
        var zoomScale = this.getMap().getGLScale();
        var length = this._get2DLength();
        var lineWidth = length * this.options['widthRatio'];

        var arrowPairs = getArrowBody(points, lineWidth, this.getMap(), 0.15, length);
        var h1 = arrowPairs[0][arrowPairs[0].length - 1],
            h2 = arrowPairs[1][arrowPairs[1].length - 1];
        var arrowHead = this._getArrowHead(h1, h2, points, lineWidth, 0.3, 0.6, 1.4, 2.2, 0.8, 3.3);
        var plots = [];
        plots.push.apply(plots, arrowPairs[0]);
        plots.push.apply(plots, arrowHead);
        for (var i = arrowPairs[1].length - 1; i >= 0; i--) {
            plots.push(arrowPairs[1][i]);
        }
        // convert to point in maxZoom
        plots = plots.map(function (p) {
            return p.multi(zoomScale);
        });
        return [plots, [arrowPairs[0].length, arrowHead.length, arrowPairs[1].length]];
    };

    return DiagonalArrow;
}(StraightArrow);

DiagonalArrow.mergeOptions(options$1);

DiagonalArrow.registerJSONType('DiagonalArrow');

maptalks.DrawTool.registerMode('DiagonalArrow', {
    'action': ['click', 'mousemove', 'dblclick'],
    'create': function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new DiagonalArrow(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    'update': function update(projection, prjPath, geometry) {
        var prjCoords = void 0;
        if (Array.isArray(prjPath)) {
            prjCoords = prjPath;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(prjPath);
        }
        var path = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(path);
        geometry._setPrjCoordinates(prjCoords);
    },
    'generate': function generate(geometry) {
        return geometry;
    }
});

/**
 * @property {Object} options
 */
var options$2 = {
    'widthRatio': 0.20,
    'arrowStyle': []
};

/**
 * @classdesc Curve style LineString
 * @class
 * @category geometry
 * @extends {maptalks.LineString}
 * @param {maptalks.Coordinate[]|Number[][]} coordinates - coordinates of the line string
 * @param {Object} [options=null]   - construct options defined in [maptalks.DoveTailDiagonalArrow]{@link maptalks.DoveTailDiagonalArrow#options}
 * @example
 * var curve = new maptalks.DoveTailDiagonalArrow(
 *     [
 *         [121.47083767181408,31.214448123476995],
 *         [121.4751292062378,31.215475523000404],
 *         [121.47869117980943,31.211916269810335]
 *     ],
 *     {
 *         symbol : {
 *             'lineWidth' : 5
 *         }
 *     }
 * ).addTo(layer);
 */

var DoveTailDiagonalArrow = function (_DiagonalArrow) {
    inherits(DoveTailDiagonalArrow, _DiagonalArrow);

    function DoveTailDiagonalArrow() {
        classCallCheck(this, DoveTailDiagonalArrow);
        return possibleConstructorReturn(this, _DiagonalArrow.apply(this, arguments));
    }

    DoveTailDiagonalArrow.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var arrow = new DoveTailDiagonalArrow(feature['geometry']['coordinates'], json['options']);
        arrow.setProperties(feature['properties']);
        return arrow;
    };

    DoveTailDiagonalArrow.prototype._toJSON = function _toJSON(options) {
        return {
            'feature': this.toGeoJSON(options),
            'subType': 'DoveTailDiagonalArrow'
        };
    };

    DoveTailDiagonalArrow.prototype._closeArrow = function _closeArrow(ctx, last, first) {
        var pitch = this.getMap().getPitch();
        var t1 = new pointGeometry(last.x, last.y);
        var t2 = new pointGeometry(first.x, first.y);
        var m = new pointGeometry(t1.x + t2.x, t1.y + t2.y).mult(1 / 2);
        var dist = -t1.dist(t2);
        var normal = t1.sub(t2)._unit()._perp();
        var max = 0.618;
        var min = 0.1;
        var maxPitch = 80; //map's default max pitch
        var ratio = max - pitch * (max - min) / maxPitch;
        var xc = m.x + dist * ratio * normal.x,
            yc = m.y + dist * ratio * normal.y;
        ctx.lineTo(xc, yc);
        ctx.closePath();
    };

    return DoveTailDiagonalArrow;
}(DiagonalArrow);

DoveTailDiagonalArrow.mergeOptions(options$2);

DoveTailDiagonalArrow.registerJSONType('DoveTailDiagonalArrow');

maptalks.DrawTool.registerMode('DoveTailDiagonalArrow', {
    'action': ['click', 'mousemove', 'dblclick'],
    'create': function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new DoveTailDiagonalArrow(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    'update': function update(projection, prjPath, geometry) {
        var prjCoords = void 0;
        if (Array.isArray(prjPath)) {
            prjCoords = prjPath;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(prjPath);
        }
        var path = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(path);
        geometry._setPrjCoordinates(prjCoords);
    },
    'generate': function generate(geometry) {
        return geometry;
    }
});

var InterpolationGeometry = function (_maptalks$Curve) {
    inherits(InterpolationGeometry, _maptalks$Curve);

    function InterpolationGeometry() {
        classCallCheck(this, InterpolationGeometry);
        return possibleConstructorReturn(this, _maptalks$Curve.apply(this, arguments));
    }

    InterpolationGeometry.prototype.startEdit = function startEdit() {
        var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};

        options.newVertexHandleSymbol = {
            'markerType': 'ellipse',
            'markerFill': '#fff',
            'markerLineColor': '#000',
            'markerLineWidth': 2,
            'markerWidth': 10,
            'markerHeight': 10,
            'opacity': 0
        };
        return _maptalks$Curve.prototype.startEdit.call(this, options);
    };

    InterpolationGeometry.prototype._getPaintParams = function _getPaintParams() {
        var map = this.getMap();
        var zoomScale = map.getGLScale();
        var coordinates = this._generate();
        if (!coordinates) {
            return null;
        }
        var projection = this._getProjection();
        if (!projection) {
            return null;
        }
        this._verifyProjection();
        var prjCoords = this._projectCoords(coordinates);
        var points = this._getPath2DPoints(prjCoords);
        points = points.map(function (p) {
            return p.multi(zoomScale);
        });
        return [points, []];
    };

    InterpolationGeometry.prototype._paintOn = function _paintOn(ctx, points, segs, lineOpacity, fillOpacity) {
        if (points.length <= 0) {
            return;
        }
        ctx.strokeStyle = this.getSymbol()['lineColor'] || '#f00';
        ctx.beginPath();
        ctx.moveTo(points[0].x, points[0].y);
        for (var i = 1; i < points.length; i++) {
            ctx.lineTo(points[i].x, points[i].y);
        }
        ctx.closePath();
        maptalks.Canvas._stroke(ctx, lineOpacity);
        maptalks.Canvas.fillCanvas(ctx, fillOpacity, points[0].x, points[0].y);
    };

    return InterpolationGeometry;
}(maptalks.Curve);

var _options = {
    headHeightFactor: 0.25,
    headWidthFactor: 0.3,
    neckHeightFactor: 0.85,
    neckWidthFactor: 0.15
};

var DoubleArrow = function (_InterprolationGeomet) {
    inherits(DoubleArrow, _InterprolationGeomet);

    function DoubleArrow(coordinates) {
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        classCallCheck(this, DoubleArrow);

        var _this = possibleConstructorReturn(this, _InterprolationGeomet.call(this, coordinates, options));

        _this.type = 'DoubleArrow';
        _this.connetPoints = [];
        _this.symmetricalPoints = [];
        return _this;
    }

    /**
     * 处理插值
     */


    DoubleArrow.prototype._generate = function _generate() {
        var points = [];
        var coordinates = this.getCoordinates();
        var count = coordinates.length;
        var _points = maptalks.Coordinate.toNumberArrays(coordinates);
        if (count < 2) {
            return null;
        } else if (count === 2) {
            this.setCoordinates(coordinates);
            return null;
        } else {
            var _ref = [_points[0], _points[1], _points[2]],
                pnt1 = _ref[0],
                pnt2 = _ref[1],
                pnt3 = _ref[2];

            if (count === 3) {
                this.symmetricalPoints = DoubleArrow.getSymmetricalPoints(pnt1, pnt2, pnt3);
                this.connetPoints = Mid(pnt1, pnt2);
            } else if (count === 4) {
                this.symmetricalPoints = _points[3];
                this.connetPoints = Mid(pnt1, pnt2);
            } else if (count > 4) {
                //this._drawTool.disable();
            }
            var leftArrowPoints = undefined,
                rightArrowPoints = undefined;

            if (isClockWise(pnt1, pnt2, pnt3)) {
                leftArrowPoints = DoubleArrow.getArrowPoints(pnt1, this.connetPoints, this.symmetricalPoints, false);
                rightArrowPoints = DoubleArrow.getArrowPoints(this.connetPoints, pnt2, pnt3, true);
            } else {
                leftArrowPoints = DoubleArrow.getArrowPoints(pnt2, this.connetPoints, pnt3, false);
                rightArrowPoints = DoubleArrow.getArrowPoints(this.connetPoints, pnt1, this.symmetricalPoints, true);
            }
            var m = leftArrowPoints.length;
            var t = (m - 5) / 2;
            var llBodyPoints = leftArrowPoints.slice(0, t);
            var lArrowPoints = leftArrowPoints.slice(t, t + 5);
            var lrBodyPoints = leftArrowPoints.slice(t + 5, m);
            var rlBodyPoints = rightArrowPoints.slice(0, t);
            var rArrowPoints = rightArrowPoints.slice(t, t + 5);
            var rrBodyPoints = rightArrowPoints.slice(t + 5, m);
            rlBodyPoints = getBezierPoints(rlBodyPoints);
            var bodyPoints = getBezierPoints(rrBodyPoints.concat(llBodyPoints.slice(1)));
            lrBodyPoints = getBezierPoints(lrBodyPoints);
            points = rlBodyPoints.concat(rArrowPoints, bodyPoints, lArrowPoints, lrBodyPoints);
            points = points.map(function (p) {
                return new maptalks.Coordinate(p);
            });
        }
        return points;
    };

    /**
     * 获取geom类型
     * @returns {string}
     */


    DoubleArrow.prototype.getPlotType = function getPlotType() {
        return this.type;
    };

    DoubleArrow.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
        var coordinates = maptalks.Coordinate.toNumberArrays([this.getShell()]);
        return {
            'type': 'Polygon',
            'coordinates': coordinates
        };
    };

    DoubleArrow.prototype._toJSON = function _toJSON(options) {
        var opts = maptalks.Util.extend({}, options);
        var coordinates = this.getCoordinates();
        opts.geometry = false;
        var feature = this.toGeoJSON(opts);
        feature['geometry'] = {
            'type': 'Polygon'
        };
        return {
            'feature': feature,
            'subType': 'DoubleArrow',
            'coordinates': coordinates
        };
    };

    /**
     * 插值箭形上的点
     * @param pnt1
     * @param pnt2
     * @param pnt3
     * @param clockWise
     * @returns {*[]}
     */


    DoubleArrow.getArrowPoints = function getArrowPoints(pnt1, pnt2, pnt3, clockWise) {
        var midPnt = Mid(pnt1, pnt2);
        var len = MathDistance(midPnt, pnt3);
        var midPnt1 = getThirdPoint(pnt3, midPnt, 0, len * 0.3, true);
        var midPnt2 = getThirdPoint(pnt3, midPnt, 0, len * 0.5, true);
        midPnt1 = getThirdPoint(midPnt, midPnt1, HALF_PI, len / 5, clockWise);
        midPnt2 = getThirdPoint(midPnt, midPnt2, HALF_PI, len / 4, clockWise);
        var points = [midPnt, midPnt1, midPnt2, pnt3];
        var arrowPnts = DoubleArrow._getArrowHeadPoints(points);
        if (arrowPnts && Array.isArray(arrowPnts) && arrowPnts.length > 0) {
            var _ref2 = [arrowPnts[0], arrowPnts[4]],
                neckLeftPoint = _ref2[0],
                neckRightPoint = _ref2[1];

            var tailWidthFactor = MathDistance(pnt1, pnt2) / getBaseLength(points) / 2;
            var bodyPnts = DoubleArrow._getArrowBodyPoints(points, neckLeftPoint, neckRightPoint, tailWidthFactor);
            if (bodyPnts) {
                var n = bodyPnts.length;
                var lPoints = bodyPnts.slice(0, n / 2);
                var rPoints = bodyPnts.slice(n / 2, n);
                lPoints.push(neckLeftPoint);
                rPoints.push(neckRightPoint);
                lPoints = lPoints.reverse();
                lPoints.push(pnt2);
                rPoints = rPoints.reverse();
                rPoints.push(pnt1);
                return lPoints.reverse().concat(arrowPnts, rPoints);
            }
        }
        return null;
    };

    /**
     * 插值头部点
     * @param points
     * @returns {*[]}
     */


    DoubleArrow._getArrowHeadPoints = function _getArrowHeadPoints(points) {
        var len = getBaseLength(points);
        var headHeight = len * _options.headHeightFactor;
        var headPnt = points[points.length - 1];
        var headWidth = headHeight * _options.headWidthFactor;
        var neckWidth = headHeight * _options.neckWidthFactor;
        var neckHeight = headHeight * _options.neckHeightFactor;
        var headEndPnt = getThirdPoint(points[points.length - 2], headPnt, 0, headHeight, true);
        var neckEndPnt = getThirdPoint(points[points.length - 2], headPnt, 0, neckHeight, true);
        var headLeft = getThirdPoint(headPnt, headEndPnt, HALF_PI, headWidth, false);
        var headRight = getThirdPoint(headPnt, headEndPnt, HALF_PI, headWidth, true);
        var neckLeft = getThirdPoint(headPnt, neckEndPnt, HALF_PI, neckWidth, false);
        var neckRight = getThirdPoint(headPnt, neckEndPnt, HALF_PI, neckWidth, true);
        return [neckLeft, headLeft, headPnt, headRight, neckRight];
    };

    /**
     * 插值面部分数据
     * @param points
     * @param neckLeft
     * @param neckRight
     * @param tailWidthFactor
     * @returns {*|T[]|string}
     */


    DoubleArrow._getArrowBodyPoints = function _getArrowBodyPoints(points, neckLeft, neckRight, tailWidthFactor) {
        var allLen = wholeDistance(points);
        var len = getBaseLength(points);
        var tailWidth = len * tailWidthFactor;
        var neckWidth = MathDistance(neckLeft, neckRight);
        var widthDif = (tailWidth - neckWidth) / 2;
        var tempLen = 0;
        var leftBodyPnts = [];
        var rightBodyPnts = [];
        for (var i = 1; i < points.length - 1; i++) {
            var angle = getAngleOfThreePoints(points[i - 1], points[i], points[i + 1]) / 2;
            tempLen += MathDistance(points[i - 1], points[i]);
            var w = (tailWidth / 2 - tempLen / allLen * widthDif) / Math.sin(angle);
            var left = getThirdPoint(points[i - 1], points[i], Math.PI - angle, w, true);
            var right = getThirdPoint(points[i - 1], points[i], angle, w, false);
            leftBodyPnts.push(left);
            rightBodyPnts.push(right);
        }
        return leftBodyPnts.concat(rightBodyPnts);
    };

    /**
     * 获取对称点
     * @param linePnt1
     * @param linePnt2
     * @param point
     * @returns {undefined}
     */


    DoubleArrow.getSymmetricalPoints = function getSymmetricalPoints(linePnt1, linePnt2, point) {
        var midPnt = Mid(linePnt1, linePnt2);
        var len = MathDistance(midPnt, point);
        var angle = getAngleOfThreePoints(linePnt1, midPnt, point);
        var symPnt = undefined,
            distance1 = undefined,
            distance2 = undefined,
            mid = undefined;

        if (angle < HALF_PI) {
            distance1 = len * Math.sin(angle);
            distance2 = len * Math.cos(angle);
            mid = getThirdPoint(linePnt1, midPnt, HALF_PI, distance1, false);
            symPnt = getThirdPoint(midPnt, mid, HALF_PI, distance2, true);
        } else if (angle >= HALF_PI && angle < Math.PI) {
            distance1 = len * Math.sin(Math.PI - angle);
            distance2 = len * Math.cos(Math.PI - angle);
            mid = getThirdPoint(linePnt1, midPnt, HALF_PI, distance1, false);
            symPnt = getThirdPoint(midPnt, mid, HALF_PI, distance2, false);
        } else if (angle >= Math.PI && angle < Math.PI * 1.5) {
            distance1 = len * Math.sin(angle - Math.PI);
            distance2 = len * Math.cos(angle - Math.PI);
            mid = getThirdPoint(linePnt1, midPnt, HALF_PI, distance1, true);
            symPnt = getThirdPoint(midPnt, mid, HALF_PI, distance2, true);
        } else {
            distance1 = len * Math.sin(Math.PI * 2 - angle);
            distance2 = len * Math.cos(Math.PI * 2 - angle);
            mid = getThirdPoint(linePnt1, midPnt, HALF_PI, distance1, true);
            symPnt = getThirdPoint(midPnt, mid, HALF_PI, distance2, false);
        }
        return symPnt;
    };

    DoubleArrow.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var doubleArrow = new DoubleArrow(json['coordinates'], json['options']);
        doubleArrow.setProperties(feature['properties']);
        return doubleArrow;
    };

    return DoubleArrow;
}(InterpolationGeometry);

DoubleArrow.registerJSONType('DoubleArrow');

maptalks.DrawTool.registerMode('DoubleArrow', {
    action: ['click', 'mousemove', 'dblclick'],
    create: function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new maptalks.LineString(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    update: function update(projection, path, geometry, e) {
        var symbol = geometry.getSymbol();
        var prjCoords = void 0;
        if (Array.isArray(path)) {
            prjCoords = path;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(path);
        }
        var coordinates = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(coordinates);
        geometry._setPrjCoordinates(prjCoords);

        var layer = geometry.getLayer();
        if (layer) {
            var map = layer.getMap();
            var doublearrow = layer.getGeometryById('doublearrow');
            if (!doublearrow && path.length >= 3) {
                doublearrow = new DoubleArrow(path, {
                    'id': 'doublearrow'
                });
                doublearrow._drawTool = e.drawTool || map['_map_tool'];
                doublearrow.addTo(layer);
                if (symbol) {
                    doublearrow.setSymbol(symbol);
                }
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
            if (doublearrow) {
                doublearrow.setCoordinates(coordinates);
                doublearrow._setPrjCoordinates(path);
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
        }
    },
    generate: function generate(geometry) {
        var symbol = geometry.getSymbol();
        symbol.lineOpacity = 1;
        var coordinates = geometry.getCoordinates();
        if (coordinates.length > 4) {
            coordinates = coordinates.slice(0, 4);
        }
        return new DoubleArrow(coordinates, {
            'symbol': symbol
        });
    }
});

var ClosedCurve = function (_InterprolationGeomet) {
    inherits(ClosedCurve, _InterprolationGeomet);

    function ClosedCurve(coordinates) {
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        classCallCheck(this, ClosedCurve);

        var _this = possibleConstructorReturn(this, _InterprolationGeomet.call(this, coordinates, options));

        _this.type = 'ClosedCurve';
        _this._offset = 0.3;
        if (coordinates) {
            _this.setCoordinates(coordinates);
        }
        return _this;
    }

    /**
     * 获取geom类型
     * @returns {string}
     */


    ClosedCurve.prototype.getPlotType = function getPlotType() {
        return this.type;
    };

    /**
     * 处理插值
     * @returns {*}
     * @private
     */


    ClosedCurve.prototype._generate = function _generate() {
        var coordinates = this.getCoordinates();
        var count = coordinates.length;
        if (count < 2) {
            return null;
        } else if (count === 2) {
            this.setCoordinates(coordinates);
            return null;
        } else {
            var points = maptalks.Coordinate.toNumberArrays(coordinates);
            points.push(points[0], points[1]);
            var normals = [],
                pList = [];

            for (var i = 0; i < points.length - 2; i++) {
                var normalPoints = getBisectorNormals(this._offset, points[i], points[i + 1], points[i + 2]);
                normals = normals.concat(normalPoints);
            }
            var _count = normals.length;
            normals = [normals[_count - 1]].concat(normals.slice(0, _count - 1));
            for (var _i = 0; _i < points.length - 2; _i++) {
                var pnt1 = points[_i];
                var pnt2 = points[_i + 1];
                pList.push(pnt1);
                for (var t = 0; t <= FITTING_COUNT; t++) {
                    var pnt = getCubicValue(t / FITTING_COUNT, pnt1, normals[_i * 2], normals[_i * 2 + 1], pnt2);
                    pList.push(pnt);
                }
                pList.push(pnt2);
            }
            pList = pList.map(function (p) {
                return new maptalks.Coordinate(p);
            });
            return pList;
        }
    };

    ClosedCurve.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
        var coordinates = maptalks.Coordinate.toNumberArrays([this.getShell()]);
        return {
            'type': 'Polygon',
            'coordinates': coordinates
        };
    };

    ClosedCurve.prototype._toJSON = function _toJSON(options) {
        var opts = maptalks.Util.extend({}, options);
        var coordinates = this.getCoordinates();
        opts.geometry = false;
        var feature = this.toGeoJSON(opts);
        feature['geometry'] = {
            'type': 'Polygon'
        };
        return {
            'feature': feature,
            'subType': 'ClosedCurve',
            'coordinates': coordinates
        };
    };

    ClosedCurve.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var _closedCurve = new ClosedCurve(json['coordinates'], json['options']);
        _closedCurve.setProperties(feature['properties']);
        return _closedCurve;
    };

    return ClosedCurve;
}(InterpolationGeometry);

ClosedCurve.registerJSONType('ClosedCurve');

maptalks.DrawTool.registerMode('ClosedCurve', {
    action: ['click', 'mousemove', 'dblclick'],
    create: function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new maptalks.LineString(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    update: function update(projection, path, geometry) {
        var symbol = geometry.getSymbol();
        var prjCoords = void 0;
        if (Array.isArray(path)) {
            prjCoords = path;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(path);
        }
        var coordinates = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(coordinates);
        geometry._setPrjCoordinates(prjCoords);

        var layer = geometry.getLayer();
        if (layer) {
            var doublearrow = layer.getGeometryById('closedcurve');
            if (!doublearrow && path.length >= 3) {
                doublearrow = new ClosedCurve([path], {
                    'id': 'closedcurve'
                });
                doublearrow.addTo(layer);
                if (symbol) {
                    doublearrow.setSymbol(symbol);
                }
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
            if (doublearrow) {
                doublearrow.setCoordinates(coordinates);
                doublearrow._setPrjCoordinates(path);
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
        }
    },
    generate: function generate(geometry) {
        var symbol = geometry.getSymbol();
        symbol.lineOpacity = 1;
        return new ClosedCurve(geometry.getCoordinates(), {
            'symbol': symbol
        });
    }
});

var PSector = function (_InterprolationGeomet) {
    inherits(PSector, _InterprolationGeomet);

    function PSector(coordinates) {
        var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
        classCallCheck(this, PSector);

        var _this = possibleConstructorReturn(this, _InterprolationGeomet.call(this, coordinates, options));

        _this.type = 'Sector';
        if (coordinates) {
            _this.setCoordinates(coordinates);
        }
        return _this;
    }

    /**
     * 获取geom类型
     * @returns {string}
     */


    PSector.prototype.getPlotType = function getPlotType() {
        return this.type;
    };

    /**
     * handle coordinates
     * @private
     */


    PSector.prototype._generate = function _generate() {
        var points = [];
        var coordinates = this.getCoordinates();
        var count = coordinates.length;
        var _points = maptalks.Coordinate.toNumberArrays(coordinates);
        if (count <= 2) {
            this.setCoordinates(_points);
            return null;
        } else if (count === 3) {
            var _ref = [_points[0], _points[1], _points[2]],
                center = _ref[0],
                pnt2 = _ref[1],
                pnt3 = _ref[2];

            var measurer = this._getMeasurer();
            var radius = pointDistance(measurer, pnt2, center);
            var startAngle = getAzimuth(pnt2, center);
            var endAngle = getAzimuth(pnt3, center);
            var pList = getSectorPoints(measurer, center, radius, startAngle, endAngle);
            pList.push(center, pList[0]);
            points = pList.map(function (p) {
                return new maptalks.Coordinate(p);
            });
        } else if (count > 3) {
            // this._drawTool.endDraw();
        }
        return points;
    };

    PSector.prototype._exportGeoJSONGeometry = function _exportGeoJSONGeometry() {
        var coordinates = maptalks.Coordinate.toNumberArrays([this.getShell()]);
        return {
            'type': 'Polygon',
            'coordinates': coordinates
        };
    };

    PSector.prototype._toJSON = function _toJSON(options) {
        var opts = maptalks.Util.extend({}, options);
        var coordinates = this.getCoordinates();
        opts.geometry = false;
        var feature = this.toGeoJSON(opts);
        feature['geometry'] = {
            'type': 'Polygon'
        };
        return {
            'feature': feature,
            'subType': 'PSector',
            'coordinates': coordinates
        };
    };

    PSector.fromJSON = function fromJSON(json) {
        var feature = json['feature'];
        var _geometry = new PSector(json['coordinates'], json['options']);
        _geometry.setProperties(feature['properties']);
        return _geometry;
    };

    return PSector;
}(InterpolationGeometry);

PSector.registerJSONType('PSector');

maptalks.DrawTool.registerMode('PSector', {
    action: ['click', 'mousemove', 'dblclick'],
    create: function create(projection, prjPath) {
        var path = prjPath.map(function (c) {
            return projection.unproject(c);
        });
        var line = new maptalks.LineString(path);
        line._setPrjCoordinates(prjPath);
        return line;
    },
    update: function update(projection, path, geometry, e) {
        var symbol = geometry.getSymbol();
        var prjCoords = void 0;
        if (Array.isArray(path)) {
            prjCoords = path;
        } else {
            prjCoords = geometry._getPrjCoordinates();
            prjCoords.push(path);
        }
        var coordinates = prjCoords.map(function (c) {
            return projection.unproject(c);
        });
        geometry.setCoordinates(coordinates);
        geometry._setPrjCoordinates(prjCoords);
        var layer = geometry.getLayer();
        if (layer) {
            var map = layer.getMap();
            var sector = layer.getGeometryById('sector');
            if (!sector && path.length >= 3) {
                sector = new PSector(path, {
                    'id': 'sector'
                });
                sector._drawTool = e.drawTool || map['_map_tool'];
                sector.addTo(layer);
                var pSymbol = maptalks.Util.extendSymbol(symbol, {});
                if (pSymbol) {
                    sector.setSymbol(pSymbol);
                }
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
            if (sector) {
                sector.setCoordinates(coordinates);
                sector._setPrjCoordinates(prjCoords);
                geometry.updateSymbol({
                    lineOpacity: 0
                });
            }
        }
    },
    generate: function generate(geometry) {
        var symbol = geometry.getSymbol();
        symbol.lineOpacity = 1;
        var coordinates = geometry.getCoordinates();
        if (coordinates.length > 3) {
            coordinates = coordinates.slice(0, 3);
        }
        return new PSector(coordinates, {
            'symbol': symbol
        });
    }
});

exports.StraightArrow = StraightArrow;
exports.DiagonalArrow = DiagonalArrow;
exports.DoveTailDiagonalArrow = DoveTailDiagonalArrow;
exports.DoubleArrow = DoubleArrow;
exports.ClosedCurve = ClosedCurve;
exports.PSector = PSector;

Object.defineProperty(exports, '__esModule', { value: true });

// typeof console !== 'undefined' && console.log('maptalks.plotsymbol v0.6.0, requires maptalks@>=0.44.1.');

})));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],t):t(e.maptalks=e.maptalks||{},e.maptalks)}(this,function(e,t){"use strict";function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):function(e,t){for(var r=Object.getOwnPropertyNames(t),o=0;o<r.length;o++){var i=r[o],n=Object.getOwnPropertyDescriptor(t,i);n&&n.configurable&&void 0===e[i]&&Object.defineProperty(e,i,n)}}(e,t))}var o=t.Util.extend,i={uppercase:!1,detectRetina:!1},n={transparent:!0,format:"png32",f:"image"},a=function(e){function t(t,r){var i;i=e.call(this,t)||this;var a=o({},n);for(var p in r)p in i.options||(a[p]=r[p]);return i.arcParams=a,i.setOptions(r),i.setZIndex(r.zIndex),i.onConfig(),i}r(t,e);var a=t.prototype;return a.getTileUrl=function(t,r,o){var n=this.getSpatialReference().getResolution(o),a=this._getTileConfig().getTilePrjExtent(t,r,n),p=a.getMax(),s=a.getMin(),c=[s.x,s.y,p.x,p.y].join(","),l=(this.getSpatialReference().getProjection()||this.getMap().getProjection()).code.split(":").pop();this.arcParams.bboxSR=l,this.arcParams.imageSR=l;var f=this.getTileSize();this.arcParams.size=f.width+","+f.height;var u=this.getMap().getDevicePixelRatio(),g=i.detectRetina?u:1;this.arcParams.dpi=90*g;var m=e.prototype.getTileUrl.call(this,t,r,o);return m+function(e,t,r){var o=[];for(var i in e)o.push(encodeURIComponent(r?i.toUpperCase():i)+"="+encodeURIComponent(e[i]));return(t&&-1!==t.indexOf("?")?"&":"?")+o.join("&")}(this.arcParams,m,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+c},a.onConfig=function(){var e=this.options.urlTemplate;this.options.urlTemplate=e.replace(/MapServer\/?$/,"MapServer/export").replace(/ImageServer\/?$/,"ImageServer/exportImage")},a.toJSON=function(){return{type:"ArcGISTileLayer",id:this.getId(),options:this.config()}},t.fromJSON=function(e){return e&&"ArcGISTileLayer"===e.type?new t(e.id,e.options):null},t}(t.TileLayer);a.registerJSONType("ArcGISTileLayer"),a.mergeOptions(i),e.ArcGISTileLayer=a,Object.defineProperty(e,"__esModule",{value:!0})});/**
 * dat-gui JavaScript Controller Library
 * http://code.google.com/p/dat-gui
 *
 * Copyright 2011 Data Arts Team, Google Creative Lab
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.dat={})}(this,function(e){"use strict";function t(e,t){var n=e.__state.conversionName.toString(),o=Math.round(e.r),i=Math.round(e.g),r=Math.round(e.b),s=e.a,a=Math.round(e.h),l=e.s.toFixed(1),d=e.v.toFixed(1);if(t||"THREE_CHAR_HEX"===n||"SIX_CHAR_HEX"===n){for(var c=e.hex.toString(16);c.length<6;)c="0"+c;return"#"+c}return"CSS_RGB"===n?"rgb("+o+","+i+","+r+")":"CSS_RGBA"===n?"rgba("+o+","+i+","+r+","+s+")":"HEX"===n?"0x"+e.hex.toString(16):"RGB_ARRAY"===n?"["+o+","+i+","+r+"]":"RGBA_ARRAY"===n?"["+o+","+i+","+r+","+s+"]":"RGB_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+"}":"RGBA_OBJ"===n?"{r:"+o+",g:"+i+",b:"+r+",a:"+s+"}":"HSV_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+"}":"HSVA_OBJ"===n?"{h:"+a+",s:"+l+",v:"+d+",a:"+s+"}":"unknown format"}function n(e,t,n){Object.defineProperty(e,t,{get:function(){return"RGB"===this.__state.space?this.__state[t]:(I.recalculateRGB(this,t,n),this.__state[t])},set:function(e){"RGB"!==this.__state.space&&(I.recalculateRGB(this,t,n),this.__state.space="RGB"),this.__state[t]=e}})}function o(e,t){Object.defineProperty(e,t,{get:function(){return"HSV"===this.__state.space?this.__state[t]:(I.recalculateHSV(this),this.__state[t])},set:function(e){"HSV"!==this.__state.space&&(I.recalculateHSV(this),this.__state.space="HSV"),this.__state[t]=e}})}function i(e){if("0"===e||S.isUndefined(e))return 0;var t=e.match(U);return S.isNull(t)?0:parseFloat(t[1])}function r(e){var t=e.toString();return t.indexOf(".")>-1?t.length-t.indexOf(".")-1:0}function s(e,t){var n=Math.pow(10,t);return Math.round(e*n)/n}function a(e,t,n,o,i){return o+(e-t)/(n-t)*(i-o)}function l(e,t,n,o){e.style.background="",S.each(ee,function(i){e.style.cssText+="background: "+i+"linear-gradient("+t+", "+n+" 0%, "+o+" 100%); "})}function d(e){e.style.background="",e.style.cssText+="background: -moz-linear-gradient(top,  #ff0000 0%, #ff00ff 17%, #0000ff 34%, #00ffff 50%, #00ff00 67%, #ffff00 84%, #ff0000 100%);",e.style.cssText+="background: -webkit-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -o-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: -ms-linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);",e.style.cssText+="background: linear-gradient(top,  #ff0000 0%,#ff00ff 17%,#0000ff 34%,#00ffff 50%,#00ff00 67%,#ffff00 84%,#ff0000 100%);"}function c(e,t,n){var o=document.createElement("li");return t&&o.appendChild(t),n?e.__ul.insertBefore(o,n):e.__ul.appendChild(o),e.onResize(),o}function u(e){X.unbind(window,"resize",e.__resizeHandler),e.saveToLocalStorageIfPossible&&X.unbind(window,"unload",e.saveToLocalStorageIfPossible)}function _(e,t){var n=e.__preset_select[e.__preset_select.selectedIndex];n.innerHTML=t?n.value+"*":n.value}function h(e,t,n){if(n.__li=t,n.__gui=e,S.extend(n,{options:function(t){if(arguments.length>1){var o=n.__li.nextElementSibling;return n.remove(),f(e,n.object,n.property,{before:o,factoryArgs:[S.toArray(arguments)]})}if(S.isArray(t)||S.isObject(t)){var i=n.__li.nextElementSibling;return n.remove(),f(e,n.object,n.property,{before:i,factoryArgs:[t]})}},name:function(e){return n.__li.firstElementChild.firstElementChild.innerHTML=e,n},listen:function(){return n.__gui.listen(n),n},remove:function(){return n.__gui.remove(n),n}}),n instanceof q){var o=new Q(n.object,n.property,{min:n.__min,max:n.__max,step:n.__step});S.each(["updateDisplay","onChange","onFinishChange","step","min","max"],function(e){var t=n[e],i=o[e];n[e]=o[e]=function(){var e=Array.prototype.slice.call(arguments);return i.apply(o,e),t.apply(n,e)}}),X.addClass(t,"has-slider"),n.domElement.insertBefore(o.domElement,n.domElement.firstElementChild)}else if(n instanceof Q){var i=function(t){if(S.isNumber(n.__min)&&S.isNumber(n.__max)){var o=n.__li.firstElementChild.firstElementChild.innerHTML,i=n.__gui.__listening.indexOf(n)>-1;n.remove();var r=f(e,n.object,n.property,{before:n.__li.nextElementSibling,factoryArgs:[n.__min,n.__max,n.__step]});return r.name(o),i&&r.listen(),r}return t};n.min=S.compose(i,n.min),n.max=S.compose(i,n.max)}else n instanceof K?(X.bind(t,"click",function(){X.fakeEvent(n.__checkbox,"click")}),X.bind(n.__checkbox,"click",function(e){e.stopPropagation()})):n instanceof Z?(X.bind(t,"click",function(){X.fakeEvent(n.__button,"click")}),X.bind(t,"mouseover",function(){X.addClass(n.__button,"hover")}),X.bind(t,"mouseout",function(){X.removeClass(n.__button,"hover")})):n instanceof $&&(X.addClass(t,"color"),n.updateDisplay=S.compose(function(e){return t.style.borderLeftColor=n.__color.toString(),e},n.updateDisplay),n.updateDisplay());n.setValue=S.compose(function(t){return e.getRoot().__preset_select&&n.isModified()&&_(e.getRoot(),!0),t},n.setValue)}function p(e,t){var n=e.getRoot(),o=n.__rememberedObjects.indexOf(t.object);if(-1!==o){var i=n.__rememberedObjectIndecesToControllers[o];if(void 0===i&&(i={},n.__rememberedObjectIndecesToControllers[o]=i),i[t.property]=t,n.load&&n.load.remembered){var r=n.load.remembered,s=void 0;if(r[e.preset])s=r[e.preset];else{if(!r[se])return;s=r[se]}if(s[o]&&void 0!==s[o][t.property]){var a=s[o][t.property];t.initialValue=a,t.setValue(a)}}}}function f(e,t,n,o){if(void 0===t[n])throw new Error('Object "'+t+'" has no property "'+n+'"');var i=void 0;if(o.color)i=new $(t,n);else{var r=[t,n].concat(o.factoryArgs);i=ne.apply(e,r)}o.before instanceof z&&(o.before=o.before.__li),p(e,i),X.addClass(i.domElement,"c");var s=document.createElement("span");X.addClass(s,"property-name"),s.innerHTML=i.property;var a=document.createElement("div");a.appendChild(s),a.appendChild(i.domElement);var l=c(e,a,o.before);return X.addClass(l,he.CLASS_CONTROLLER_ROW),i instanceof $?X.addClass(l,"color"):X.addClass(l,H(i.getValue())),h(e,l,i),e.__controllers.push(i),i}function m(e,t){return document.location.href+"."+t}function g(e,t,n){var o=document.createElement("option");o.innerHTML=t,o.value=t,e.__preset_select.appendChild(o),n&&(e.__preset_select.selectedIndex=e.__preset_select.length-1)}function b(e,t){t.style.display=e.useLocalStorage?"block":"none"}function v(e){var t=e.__save_row=document.createElement("li");X.addClass(e.domElement,"has-save"),e.__ul.insertBefore(t,e.__ul.firstChild),X.addClass(t,"save-row");var n=document.createElement("span");n.innerHTML="&nbsp;",X.addClass(n,"button gears");var o=document.createElement("span");o.innerHTML="Save",X.addClass(o,"button"),X.addClass(o,"save");var i=document.createElement("span");i.innerHTML="New",X.addClass(i,"button"),X.addClass(i,"save-as");var r=document.createElement("span");r.innerHTML="Revert",X.addClass(r,"button"),X.addClass(r,"revert");var s=e.__preset_select=document.createElement("select");if(e.load&&e.load.remembered?S.each(e.load.remembered,function(t,n){g(e,n,n===e.preset)}):g(e,se,!1),X.bind(s,"change",function(){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].innerHTML=e.__preset_select[t].value;e.preset=this.value}),t.appendChild(s),t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(r),ae){var a=document.getElementById("dg-local-explain"),l=document.getElementById("dg-local-storage");document.getElementById("dg-save-locally").style.display="block","true"===localStorage.getItem(m(e,"isLocal"))&&l.setAttribute("checked","checked"),b(e,a),X.bind(l,"change",function(){e.useLocalStorage=!e.useLocalStorage,b(e,a)})}var d=document.getElementById("dg-new-constructor");X.bind(d,"keydown",function(e){!e.metaKey||67!==e.which&&67!==e.keyCode||le.hide()}),X.bind(n,"click",function(){d.innerHTML=JSON.stringify(e.getSaveObject(),void 0,2),le.show(),d.focus(),d.select()}),X.bind(o,"click",function(){e.save()}),X.bind(i,"click",function(){var t=prompt("Enter a new preset name.");t&&e.saveAs(t)}),X.bind(r,"click",function(){e.revert()})}function y(e){function t(t){return t.preventDefault(),e.width+=i-t.clientX,e.onResize(),i=t.clientX,!1}function n(){X.removeClass(e.__closeButton,he.CLASS_DRAG),X.unbind(window,"mousemove",t),X.unbind(window,"mouseup",n)}function o(o){return o.preventDefault(),i=o.clientX,X.addClass(e.__closeButton,he.CLASS_DRAG),X.bind(window,"mousemove",t),X.bind(window,"mouseup",n),!1}var i=void 0;e.__resize_handle=document.createElement("div"),S.extend(e.__resize_handle.style,{width:"6px",marginLeft:"-3px",height:"200px",cursor:"ew-resize",position:"absolute"}),X.bind(e.__resize_handle,"mousedown",o),X.bind(e.__closeButton,"mousedown",o),e.domElement.insertBefore(e.__resize_handle,e.domElement.firstElementChild)}function w(e,t){e.domElement.style.width=t+"px",e.__save_row&&e.autoPlace&&(e.__save_row.style.width=t+"px"),e.__closeButton&&(e.__closeButton.style.width=t+"px")}function x(e,t){var n={};return S.each(e.__rememberedObjects,function(o,i){var r={},s=e.__rememberedObjectIndecesToControllers[i];S.each(s,function(e,n){r[n]=t?e.initialValue:e.getValue()}),n[i]=r}),n}function E(e){for(var t=0;t<e.__preset_select.length;t++)e.__preset_select[t].value===e.preset&&(e.__preset_select.selectedIndex=t)}function C(e){0!==e.length&&oe.call(window,function(){C(e)}),S.each(e,function(e){e.updateDisplay()})}var A=Array.prototype.forEach,k=Array.prototype.slice,S={BREAK:{},extend:function(e){return this.each(k.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(t[n])||(e[n]=t[n])}.bind(this))},this),e},defaults:function(e){return this.each(k.call(arguments,1),function(t){(this.isObject(t)?Object.keys(t):[]).forEach(function(n){this.isUndefined(e[n])&&(e[n]=t[n])}.bind(this))},this),e},compose:function(){var e=k.call(arguments);return function(){for(var t=k.call(arguments),n=e.length-1;n>=0;n--)t=[e[n].apply(this,t)];return t[0]}},each:function(e,t,n){if(e)if(A&&e.forEach&&e.forEach===A)e.forEach(t,n);else if(e.length===e.length+0){var o=void 0,i=void 0;for(o=0,i=e.length;o<i;o++)if(o in e&&t.call(n,e[o],o)===this.BREAK)return}else for(var r in e)if(t.call(n,e[r],r)===this.BREAK)return},defer:function(e){setTimeout(e,0)},debounce:function(e,t,n){var o=void 0;return function(){var i=this,r=arguments,s=n||!o;clearTimeout(o),o=setTimeout(function(){o=null,n||e.apply(i,r)},t),s&&e.apply(i,r)}},toArray:function(e){return e.toArray?e.toArray():k.call(e)},isUndefined:function(e){return void 0===e},isNull:function(e){return null===e},isNaN:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){return isNaN(e)}),isArray:Array.isArray||function(e){return e.constructor===Array},isObject:function(e){return e===Object(e)},isNumber:function(e){return e===e+0},isString:function(e){return e===e+""},isBoolean:function(e){return!1===e||!0===e},isFunction:function(e){return"[object Function]"===Object.prototype.toString.call(e)}},O=[{litmus:S.isString,conversions:{THREE_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9])([A-F0-9])([A-F0-9])$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString()+t[1].toString()+t[2].toString()+t[2].toString()+t[3].toString()+t[3].toString(),0)}},write:t},SIX_CHAR_HEX:{read:function(e){var t=e.match(/^#([A-F0-9]{6})$/i);return null!==t&&{space:"HEX",hex:parseInt("0x"+t[1].toString(),0)}},write:t},CSS_RGB:{read:function(e){var t=e.match(/^rgb\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3])}},write:t},CSS_RGBA:{read:function(e){var t=e.match(/^rgba\(\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*,\s*(.+)\s*\)/);return null!==t&&{space:"RGB",r:parseFloat(t[1]),g:parseFloat(t[2]),b:parseFloat(t[3]),a:parseFloat(t[4])}},write:t}}},{litmus:S.isNumber,conversions:{HEX:{read:function(e){return{space:"HEX",hex:e,conversionName:"HEX"}},write:function(e){return e.hex}}}},{litmus:S.isArray,conversions:{RGB_ARRAY:{read:function(e){return 3===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2]}},write:function(e){return[e.r,e.g,e.b]}},RGBA_ARRAY:{read:function(e){return 4===e.length&&{space:"RGB",r:e[0],g:e[1],b:e[2],a:e[3]}},write:function(e){return[e.r,e.g,e.b,e.a]}}}},{litmus:S.isObject,conversions:{RGBA_OBJ:{read:function(e){return!!(S.isNumber(e.r)&&S.isNumber(e.g)&&S.isNumber(e.b)&&S.isNumber(e.a))&&{space:"RGB",r:e.r,g:e.g,b:e.b,a:e.a}},write:function(e){return{r:e.r,g:e.g,b:e.b,a:e.a}}},RGB_OBJ:{read:function(e){return!!(S.isNumber(e.r)&&S.isNumber(e.g)&&S.isNumber(e.b))&&{space:"RGB",r:e.r,g:e.g,b:e.b}},write:function(e){return{r:e.r,g:e.g,b:e.b}}},HSVA_OBJ:{read:function(e){return!!(S.isNumber(e.h)&&S.isNumber(e.s)&&S.isNumber(e.v)&&S.isNumber(e.a))&&{space:"HSV",h:e.h,s:e.s,v:e.v,a:e.a}},write:function(e){return{h:e.h,s:e.s,v:e.v,a:e.a}}},HSV_OBJ:{read:function(e){return!!(S.isNumber(e.h)&&S.isNumber(e.s)&&S.isNumber(e.v))&&{space:"HSV",h:e.h,s:e.s,v:e.v}},write:function(e){return{h:e.h,s:e.s,v:e.v}}}}}],T=void 0,L=void 0,R=function(){L=!1;var e=arguments.length>1?S.toArray(arguments):arguments[0];return S.each(O,function(t){if(t.litmus(e))return S.each(t.conversions,function(t,n){if(T=t.read(e),!1===L&&!1!==T)return L=T,T.conversionName=n,T.conversion=t,S.BREAK}),S.BREAK}),L},B=void 0,N={hsv_to_rgb:function(e,t,n){var o=Math.floor(e/60)%6,i=e/60-Math.floor(e/60),r=n*(1-t),s=n*(1-i*t),a=n*(1-(1-i)*t),l=[[n,a,r],[s,n,r],[r,n,a],[r,s,n],[a,r,n],[n,r,s]][o];return{r:255*l[0],g:255*l[1],b:255*l[2]}},rgb_to_hsv:function(e,t,n){var o=Math.min(e,t,n),i=Math.max(e,t,n),r=i-o,s=void 0,a=void 0;return 0===i?{h:NaN,s:0,v:0}:(a=r/i,s=e===i?(t-n)/r:t===i?2+(n-e)/r:4+(e-t)/r,(s/=6)<0&&(s+=1),{h:360*s,s:a,v:i/255})},rgb_to_hex:function(e,t,n){var o=this.hex_with_component(0,2,e);return o=this.hex_with_component(o,1,t),o=this.hex_with_component(o,0,n)},component_from_hex:function(e,t){return e>>8*t&255},hex_with_component:function(e,t,n){return n<<(B=8*t)|e&~(255<<B)}},H="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},F=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},P=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),j=function e(t,n,o){null===t&&(t=Function.prototype);var i=Object.getOwnPropertyDescriptor(t,n);if(void 0===i){var r=Object.getPrototypeOf(t);return null===r?void 0:e(r,n,o)}if("value"in i)return i.value;var s=i.get;if(void 0!==s)return s.call(o)},D=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)},V=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t},I=function(){function e(){if(F(this,e),this.__state=R.apply(this,arguments),!1===this.__state)throw new Error("Failed to interpret color arguments");this.__state.a=this.__state.a||1}return P(e,[{key:"toString",value:function(){return t(this)}},{key:"toHexString",value:function(){return t(this,!0)}},{key:"toOriginal",value:function(){return this.__state.conversion.write(this)}}]),e}();I.recalculateRGB=function(e,t,n){if("HEX"===e.__state.space)e.__state[t]=N.component_from_hex(e.__state.hex,n);else{if("HSV"!==e.__state.space)throw new Error("Corrupted color state");S.extend(e.__state,N.hsv_to_rgb(e.__state.h,e.__state.s,e.__state.v))}},I.recalculateHSV=function(e){var t=N.rgb_to_hsv(e.r,e.g,e.b);S.extend(e.__state,{s:t.s,v:t.v}),S.isNaN(t.h)?S.isUndefined(e.__state.h)&&(e.__state.h=0):e.__state.h=t.h},I.COMPONENTS=["r","g","b","h","s","v","hex","a"],n(I.prototype,"r",2),n(I.prototype,"g",1),n(I.prototype,"b",0),o(I.prototype,"h"),o(I.prototype,"s"),o(I.prototype,"v"),Object.defineProperty(I.prototype,"a",{get:function(){return this.__state.a},set:function(e){this.__state.a=e}}),Object.defineProperty(I.prototype,"hex",{get:function(){return"HEX"!==!this.__state.space&&(this.__state.hex=N.rgb_to_hex(this.r,this.g,this.b)),this.__state.hex},set:function(e){this.__state.space="HEX",this.__state.hex=e}});var z=function(){function e(t,n){F(this,e),this.initialValue=t[n],this.domElement=document.createElement("div"),this.object=t,this.property=n,this.__onChange=void 0,this.__onFinishChange=void 0}return P(e,[{key:"onChange",value:function(e){return this.__onChange=e,this}},{key:"onFinishChange",value:function(e){return this.__onFinishChange=e,this}},{key:"setValue",value:function(e){return this.object[this.property]=e,this.__onChange&&this.__onChange.call(this,e),this.updateDisplay(),this}},{key:"getValue",value:function(){return this.object[this.property]}},{key:"updateDisplay",value:function(){return this}},{key:"isModified",value:function(){return this.initialValue!==this.getValue()}}]),e}(),M={HTMLEvents:["change"],MouseEvents:["click","mousemove","mousedown","mouseup","mouseover"],KeyboardEvents:["keydown"]},G={};S.each(M,function(e,t){S.each(e,function(e){G[e]=t})});var U=/(\d+(\.\d+)?)px/,X={makeSelectable:function(e,t){void 0!==e&&void 0!==e.style&&(e.onselectstart=t?function(){return!1}:function(){},e.style.MozUserSelect=t?"auto":"none",e.style.KhtmlUserSelect=t?"auto":"none",e.unselectable=t?"on":"off")},makeFullscreen:function(e,t,n){var o=n,i=t;S.isUndefined(i)&&(i=!0),S.isUndefined(o)&&(o=!0),e.style.position="absolute",i&&(e.style.left=0,e.style.right=0),o&&(e.style.top=0,e.style.bottom=0)},fakeEvent:function(e,t,n,o){var i=n||{},r=G[t];if(!r)throw new Error("Event type "+t+" not supported.");var s=document.createEvent(r);switch(r){case"MouseEvents":var a=i.x||i.clientX||0,l=i.y||i.clientY||0;s.initMouseEvent(t,i.bubbles||!1,i.cancelable||!0,window,i.clickCount||1,0,0,a,l,!1,!1,!1,!1,0,null);break;case"KeyboardEvents":var d=s.initKeyboardEvent||s.initKeyEvent;S.defaults(i,{cancelable:!0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,keyCode:void 0,charCode:void 0}),d(t,i.bubbles||!1,i.cancelable,window,i.ctrlKey,i.altKey,i.shiftKey,i.metaKey,i.keyCode,i.charCode);break;default:s.initEvent(t,i.bubbles||!1,i.cancelable||!0)}S.defaults(s,o),e.dispatchEvent(s)},bind:function(e,t,n,o){var i=o||!1;return e.addEventListener?e.addEventListener(t,n,i):e.attachEvent&&e.attachEvent("on"+t,n),X},unbind:function(e,t,n,o){var i=o||!1;return e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent&&e.detachEvent("on"+t,n),X},addClass:function(e,t){if(void 0===e.className)e.className=t;else if(e.className!==t){var n=e.className.split(/ +/);-1===n.indexOf(t)&&(n.push(t),e.className=n.join(" ").replace(/^\s+/,"").replace(/\s+$/,""))}return X},removeClass:function(e,t){if(t)if(e.className===t)e.removeAttribute("class");else{var n=e.className.split(/ +/),o=n.indexOf(t);-1!==o&&(n.splice(o,1),e.className=n.join(" "))}else e.className=void 0;return X},hasClass:function(e,t){return new RegExp("(?:^|\\s+)"+t+"(?:\\s+|$)").test(e.className)||!1},getWidth:function(e){var t=getComputedStyle(e);return i(t["border-left-width"])+i(t["border-right-width"])+i(t["padding-left"])+i(t["padding-right"])+i(t.width)},getHeight:function(e){var t=getComputedStyle(e);return i(t["border-top-width"])+i(t["border-bottom-width"])+i(t["padding-top"])+i(t["padding-bottom"])+i(t.height)},getOffset:function(e){var t=e,n={left:0,top:0};if(t.offsetParent)do{n.left+=t.offsetLeft,n.top+=t.offsetTop,t=t.offsetParent}while(t);return n},isActive:function(e){return e===document.activeElement&&(e.type||e.href)}},K=function(e){function t(e,n){F(this,t);var o=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),i=o;return o.__prev=o.getValue(),o.__checkbox=document.createElement("input"),o.__checkbox.setAttribute("type","checkbox"),X.bind(o.__checkbox,"change",function(){i.setValue(!i.__prev)},!1),o.domElement.appendChild(o.__checkbox),o.updateDisplay(),o}return D(t,z),P(t,[{key:"setValue",value:function(e){var n=j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),this.__prev=this.getValue(),n}},{key:"updateDisplay",value:function(){return!0===this.getValue()?(this.__checkbox.setAttribute("checked","checked"),this.__checkbox.checked=!0,this.__prev=!0):(this.__checkbox.checked=!1,this.__prev=!1),j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Y=function(e){function t(e,n,o){F(this,t);var i=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=o,s=i;if(i.__select=document.createElement("select"),S.isArray(r)){var a={};S.each(r,function(e){a[e]=e}),r=a}return S.each(r,function(e,t){var n=document.createElement("option");n.innerHTML=t,n.setAttribute("value",e),s.__select.appendChild(n)}),i.updateDisplay(),X.bind(i.__select,"change",function(){var e=this.options[this.selectedIndex].value;s.setValue(e)}),i.domElement.appendChild(i.__select),i}return D(t,z),P(t,[{key:"setValue",value:function(e){var n=j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,e);return this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue()),n}},{key:"updateDisplay",value:function(){return X.isActive(this.__select)?this:(this.__select.value=this.getValue(),j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this))}}]),t}(),J=function(e){function t(e,n){function o(){r.setValue(r.__input.value)}F(this,t);var i=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=i;return i.__input=document.createElement("input"),i.__input.setAttribute("type","text"),X.bind(i.__input,"keyup",o),X.bind(i.__input,"change",o),X.bind(i.__input,"blur",function(){r.__onFinishChange&&r.__onFinishChange.call(r,r.getValue())}),X.bind(i.__input,"keydown",function(e){13===e.keyCode&&this.blur()}),i.updateDisplay(),i.domElement.appendChild(i.__input),i}return D(t,z),P(t,[{key:"updateDisplay",value:function(){return X.isActive(this.__input)||(this.__input.value=this.getValue()),j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),W=function(e){function t(e,n,o){F(this,t);var i=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),s=o||{};return i.__min=s.min,i.__max=s.max,i.__step=s.step,S.isUndefined(i.__step)?0===i.initialValue?i.__impliedStep=1:i.__impliedStep=Math.pow(10,Math.floor(Math.log(Math.abs(i.initialValue))/Math.LN10))/10:i.__impliedStep=i.__step,i.__precision=r(i.__impliedStep),i}return D(t,z),P(t,[{key:"setValue",value:function(e){var n=e;return void 0!==this.__min&&n<this.__min?n=this.__min:void 0!==this.__max&&n>this.__max&&(n=this.__max),void 0!==this.__step&&n%this.__step!=0&&(n=Math.round(n/this.__step)*this.__step),j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"setValue",this).call(this,n)}},{key:"min",value:function(e){return this.__min=e,this}},{key:"max",value:function(e){return this.__max=e,this}},{key:"step",value:function(e){return this.__step=e,this.__impliedStep=e,this.__precision=r(e),this}}]),t}(),Q=function(e){function t(e,n,o){function i(){l.__onFinishChange&&l.__onFinishChange.call(l,l.getValue())}function r(e){var t=d-e.clientY;l.setValue(l.getValue()+t*l.__impliedStep),d=e.clientY}function s(){X.unbind(window,"mousemove",r),X.unbind(window,"mouseup",s),i()}F(this,t);var a=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,o));a.__truncationSuspended=!1;var l=a,d=void 0;return a.__input=document.createElement("input"),a.__input.setAttribute("type","text"),X.bind(a.__input,"change",function(){var e=parseFloat(l.__input.value);S.isNaN(e)||l.setValue(e)}),X.bind(a.__input,"blur",function(){i()}),X.bind(a.__input,"mousedown",function(e){X.bind(window,"mousemove",r),X.bind(window,"mouseup",s),d=e.clientY}),X.bind(a.__input,"keydown",function(e){13===e.keyCode&&(l.__truncationSuspended=!0,this.blur(),l.__truncationSuspended=!1,i())}),a.updateDisplay(),a.domElement.appendChild(a.__input),a}return D(t,W),P(t,[{key:"updateDisplay",value:function(){return this.__input.value=this.__truncationSuspended?this.getValue():s(this.getValue(),this.__precision),j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),q=function(e){function t(e,n,o,i,r){function s(e){e.preventDefault();var t=_.__background.getBoundingClientRect();return _.setValue(a(e.clientX,t.left,t.right,_.__min,_.__max)),!1}function l(){X.unbind(window,"mousemove",s),X.unbind(window,"mouseup",l),_.__onFinishChange&&_.__onFinishChange.call(_,_.getValue())}function d(e){var t=e.touches[0].clientX,n=_.__background.getBoundingClientRect();_.setValue(a(t,n.left,n.right,_.__min,_.__max))}function c(){X.unbind(window,"touchmove",d),X.unbind(window,"touchend",c),_.__onFinishChange&&_.__onFinishChange.call(_,_.getValue())}F(this,t);var u=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n,{min:o,max:i,step:r})),_=u;return u.__background=document.createElement("div"),u.__foreground=document.createElement("div"),X.bind(u.__background,"mousedown",function(e){document.activeElement.blur(),X.bind(window,"mousemove",s),X.bind(window,"mouseup",l),s(e)}),X.bind(u.__background,"touchstart",function(e){1===e.touches.length&&(X.bind(window,"touchmove",d),X.bind(window,"touchend",c),d(e))}),X.addClass(u.__background,"slider"),X.addClass(u.__foreground,"slider-fg"),u.updateDisplay(),u.__background.appendChild(u.__foreground),u.domElement.appendChild(u.__background),u}return D(t,W),P(t,[{key:"updateDisplay",value:function(){var e=(this.getValue()-this.__min)/(this.__max-this.__min);return this.__foreground.style.width=100*e+"%",j(t.prototype.__proto__||Object.getPrototypeOf(t.prototype),"updateDisplay",this).call(this)}}]),t}(),Z=function(e){function t(e,n,o){F(this,t);var i=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n)),r=i;return i.__button=document.createElement("div"),i.__button.innerHTML=void 0===o?"Fire":o,X.bind(i.__button,"click",function(e){return e.preventDefault(),r.fire(),!1}),X.addClass(i.__button,"button"),i.domElement.appendChild(i.__button),i}return D(t,z),P(t,[{key:"fire",value:function(){this.__onChange&&this.__onChange.call(this),this.getValue().call(this.object),this.__onFinishChange&&this.__onFinishChange.call(this,this.getValue())}}]),t}(),$=function(e){function t(e,n){function o(e){u(e),X.bind(window,"mousemove",u),X.bind(window,"touchmove",u),X.bind(window,"mouseup",r),X.bind(window,"touchend",r)}function i(e){_(e),X.bind(window,"mousemove",_),X.bind(window,"touchmove",_),X.bind(window,"mouseup",s),X.bind(window,"touchend",s)}function r(){X.unbind(window,"mousemove",u),X.unbind(window,"touchmove",u),X.unbind(window,"mouseup",r),X.unbind(window,"touchend",r),c()}function s(){X.unbind(window,"mousemove",_),X.unbind(window,"touchmove",_),X.unbind(window,"mouseup",s),X.unbind(window,"touchend",s),c()}function a(){var e=R(this.value);!1!==e?(p.__color.__state=e,p.setValue(p.__color.toOriginal())):this.value=p.__color.toString()}function c(){p.__onFinishChange&&p.__onFinishChange.call(p,p.__color.toOriginal())}function u(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=p.__saturation_field.getBoundingClientRect(),n=e.touches&&e.touches[0]||e,o=n.clientX,i=n.clientY,r=(o-t.left)/(t.right-t.left),s=1-(i-t.top)/(t.bottom-t.top);return s>1?s=1:s<0&&(s=0),r>1?r=1:r<0&&(r=0),p.__color.v=s,p.__color.s=r,p.setValue(p.__color.toOriginal()),!1}function _(e){-1===e.type.indexOf("touch")&&e.preventDefault();var t=p.__hue_field.getBoundingClientRect(),n=1-((e.touches&&e.touches[0]||e).clientY-t.top)/(t.bottom-t.top);return n>1?n=1:n<0&&(n=0),p.__color.h=360*n,p.setValue(p.__color.toOriginal()),!1}F(this,t);var h=V(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e,n));h.__color=new I(h.getValue()),h.__temp=new I(0);var p=h;h.domElement=document.createElement("div"),X.makeSelectable(h.domElement,!1),h.__selector=document.createElement("div"),h.__selector.className="selector",h.__saturation_field=document.createElement("div"),h.__saturation_field.className="saturation-field",h.__field_knob=document.createElement("div"),h.__field_knob.className="field-knob",h.__field_knob_border="2px solid ",h.__hue_knob=document.createElement("div"),h.__hue_knob.className="hue-knob",h.__hue_field=document.createElement("div"),h.__hue_field.className="hue-field",h.__input=document.createElement("input"),h.__input.type="text",h.__input_textShadow="0 1px 1px ",X.bind(h.__input,"keydown",function(e){13===e.keyCode&&a.call(this)}),X.bind(h.__input,"blur",a),X.bind(h.__selector,"mousedown",function(){X.addClass(this,"drag").bind(window,"mouseup",function(){X.removeClass(p.__selector,"drag")})}),X.bind(h.__selector,"touchstart",function(){X.addClass(this,"drag").bind(window,"touchend",function(){X.removeClass(p.__selector,"drag")})});var f=document.createElement("div");return S.extend(h.__selector.style,{width:"122px",height:"102px",padding:"3px",backgroundColor:"#222",boxShadow:"0px 1px 3px rgba(0,0,0,0.3)"}),S.extend(h.__field_knob.style,{position:"absolute",width:"12px",height:"12px",border:h.__field_knob_border+(h.__color.v<.5?"#fff":"#000"),boxShadow:"0px 1px 3px rgba(0,0,0,0.5)",borderRadius:"12px",zIndex:1}),S.extend(h.__hue_knob.style,{position:"absolute",width:"15px",height:"2px",borderRight:"4px solid #fff",zIndex:1}),S.extend(h.__saturation_field.style,{width:"100px",height:"100px",border:"1px solid #555",marginRight:"3px",display:"inline-block",cursor:"pointer"}),S.extend(f.style,{width:"100%",height:"100%",background:"none"}),l(f,"top","rgba(0,0,0,0)","#000"),S.extend(h.__hue_field.style,{width:"15px",height:"100px",border:"1px solid #555",cursor:"ns-resize",position:"absolute",top:"3px",right:"3px"}),d(h.__hue_field),S.extend(h.__input.style,{outline:"none",textAlign:"center",color:"#fff",border:0,fontWeight:"bold",textShadow:h.__input_textShadow+"rgba(0,0,0,0.7)"}),X.bind(h.__saturation_field,"mousedown",o),X.bind(h.__saturation_field,"touchstart",o),X.bind(h.__field_knob,"mousedown",o),X.bind(h.__field_knob,"touchstart",o),X.bind(h.__hue_field,"mousedown",i),X.bind(h.__hue_field,"touchstart",i),h.__saturation_field.appendChild(f),h.__selector.appendChild(h.__field_knob),h.__selector.appendChild(h.__saturation_field),h.__selector.appendChild(h.__hue_field),h.__hue_field.appendChild(h.__hue_knob),h.domElement.appendChild(h.__input),h.domElement.appendChild(h.__selector),h.updateDisplay(),h}return D(t,z),P(t,[{key:"updateDisplay",value:function(){var e=R(this.getValue());if(!1!==e){var t=!1;S.each(I.COMPONENTS,function(n){if(!S.isUndefined(e[n])&&!S.isUndefined(this.__color.__state[n])&&e[n]!==this.__color.__state[n])return t=!0,{}},this),t&&S.extend(this.__color.__state,e)}S.extend(this.__temp.__state,this.__color.__state),this.__temp.a=1;var n=this.__color.v<.5||this.__color.s>.5?255:0,o=255-n;S.extend(this.__field_knob.style,{marginLeft:100*this.__color.s-7+"px",marginTop:100*(1-this.__color.v)-7+"px",backgroundColor:this.__temp.toHexString(),border:this.__field_knob_border+"rgb("+n+","+n+","+n+")"}),this.__hue_knob.style.marginTop=100*(1-this.__color.h/360)+"px",this.__temp.s=1,this.__temp.v=1,l(this.__saturation_field,"left","#fff",this.__temp.toHexString()),this.__input.value=this.__color.toString(),S.extend(this.__input.style,{backgroundColor:this.__color.toHexString(),color:"rgb("+n+","+n+","+n+")",textShadow:this.__input_textShadow+"rgba("+o+","+o+","+o+",.7)"})}}]),t}(),ee=["-moz-","-o-","-webkit-","-ms-",""],te={load:function(e,t){var n=t||document,o=n.createElement("link");o.type="text/css",o.rel="stylesheet",o.href=e,n.getElementsByTagName("head")[0].appendChild(o)},inject:function(e,t){var n=t||document,o=document.createElement("style");o.type="text/css",o.innerHTML=e;var i=n.getElementsByTagName("head")[0];try{i.appendChild(o)}catch(e){}}},ne=function(e,t){var n=e[t];return S.isArray(arguments[2])||S.isObject(arguments[2])?new Y(e,t,arguments[2]):S.isNumber(n)?S.isNumber(arguments[2])&&S.isNumber(arguments[3])?S.isNumber(arguments[4])?new q(e,t,arguments[2],arguments[3],arguments[4]):new q(e,t,arguments[2],arguments[3]):S.isNumber(arguments[4])?new Q(e,t,{min:arguments[2],max:arguments[3],step:arguments[4]}):new Q(e,t,{min:arguments[2],max:arguments[3]}):S.isString(n)?new J(e,t):S.isFunction(n)?new Z(e,t,""):S.isBoolean(n)?new K(e,t):null},oe=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,1e3/60)},ie=function(){function e(){F(this,e),this.backgroundElement=document.createElement("div"),S.extend(this.backgroundElement.style,{backgroundColor:"rgba(0,0,0,0.8)",top:0,left:0,display:"none",zIndex:"1000",opacity:0,WebkitTransition:"opacity 0.2s linear",transition:"opacity 0.2s linear"}),X.makeFullscreen(this.backgroundElement),this.backgroundElement.style.position="fixed",this.domElement=document.createElement("div"),S.extend(this.domElement.style,{position:"fixed",display:"none",zIndex:"1001",opacity:0,WebkitTransition:"-webkit-transform 0.2s ease-out, opacity 0.2s linear",transition:"transform 0.2s ease-out, opacity 0.2s linear"}),document.body.appendChild(this.backgroundElement),document.body.appendChild(this.domElement);var t=this;X.bind(this.backgroundElement,"click",function(){t.hide()})}return P(e,[{key:"show",value:function(){var e=this;this.backgroundElement.style.display="block",this.domElement.style.display="block",this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)",this.layout(),S.defer(function(){e.backgroundElement.style.opacity=1,e.domElement.style.opacity=1,e.domElement.style.webkitTransform="scale(1)"})}},{key:"hide",value:function(){var e=this,t=function t(){e.domElement.style.display="none",e.backgroundElement.style.display="none",X.unbind(e.domElement,"webkitTransitionEnd",t),X.unbind(e.domElement,"transitionend",t),X.unbind(e.domElement,"oTransitionEnd",t)};X.bind(this.domElement,"webkitTransitionEnd",t),X.bind(this.domElement,"transitionend",t),X.bind(this.domElement,"oTransitionEnd",t),this.backgroundElement.style.opacity=0,this.domElement.style.opacity=0,this.domElement.style.webkitTransform="scale(1.1)"}},{key:"layout",value:function(){this.domElement.style.left=window.innerWidth/2-X.getWidth(this.domElement)/2+"px",this.domElement.style.top=window.innerHeight/2-X.getHeight(this.domElement)/2+"px"}}]),e}(),re=function(e){if(e&&"undefined"!=typeof window){var t=document.createElement("style");return t.setAttribute("type","text/css"),t.innerHTML=e,document.head.appendChild(t),e}}(".dg ul{list-style:none;margin:0;padding:0;width:100%;clear:both}.dg.ac{position:fixed;top:0;left:0;right:0;height:0;z-index:0}.dg:not(.ac) .main{overflow:hidden}.dg.main{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear}.dg.main.taller-than-window{overflow-y:auto}.dg.main.taller-than-window .close-button{opacity:1;margin-top:-1px;border-top:1px solid #2c2c2c}.dg.main ul.closed .close-button{opacity:1 !important}.dg.main:hover .close-button,.dg.main .close-button.drag{opacity:1}.dg.main .close-button{-webkit-transition:opacity .1s linear;-o-transition:opacity .1s linear;-moz-transition:opacity .1s linear;transition:opacity .1s linear;border:0;line-height:19px;height:20px;cursor:pointer;text-align:center;background-color:#000}.dg.main .close-button.close-top{position:relative}.dg.main .close-button.close-bottom{position:absolute}.dg.main .close-button:hover{background-color:#111}.dg.a{float:right;margin-right:15px;overflow-y:visible}.dg.a.has-save>ul.close-top{margin-top:0}.dg.a.has-save>ul.close-bottom{margin-top:27px}.dg.a.has-save>ul.closed{margin-top:0}.dg.a .save-row{top:0;z-index:1002}.dg.a .save-row.close-top{position:relative}.dg.a .save-row.close-bottom{position:fixed}.dg li{-webkit-transition:height .1s ease-out;-o-transition:height .1s ease-out;-moz-transition:height .1s ease-out;transition:height .1s ease-out;-webkit-transition:overflow .1s linear;-o-transition:overflow .1s linear;-moz-transition:overflow .1s linear;transition:overflow .1s linear}.dg li:not(.folder){cursor:auto;height:27px;line-height:27px;padding:0 4px 0 5px}.dg li.folder{padding:0;border-left:4px solid rgba(0,0,0,0)}.dg li.title{cursor:pointer;margin-left:-4px}.dg .closed li:not(.title),.dg .closed ul li,.dg .closed ul li>*{height:0;overflow:hidden;border:0}.dg .cr{clear:both;padding-left:3px;height:27px;overflow:hidden}.dg .property-name{cursor:default;float:left;clear:left;width:40%;overflow:hidden;text-overflow:ellipsis}.dg .c{float:left;width:60%;position:relative}.dg .c input[type=text]{border:0;margin-top:4px;padding:3px;width:100%;float:right}.dg .has-slider input[type=text]{width:30%;margin-left:0}.dg .slider{float:left;width:66%;margin-left:-5px;margin-right:0;height:19px;margin-top:4px}.dg .slider-fg{height:100%}.dg .c input[type=checkbox]{margin-top:7px}.dg .c select{margin-top:5px}.dg .cr.function,.dg .cr.function .property-name,.dg .cr.function *,.dg .cr.boolean,.dg .cr.boolean *{cursor:pointer}.dg .cr.color{overflow:visible}.dg .selector{display:none;position:absolute;margin-left:-9px;margin-top:23px;z-index:10}.dg .c:hover .selector,.dg .selector.drag{display:block}.dg li.save-row{padding:0}.dg li.save-row .button{display:inline-block;padding:0px 6px}.dg.dialogue{background-color:#222;width:460px;padding:15px;font-size:13px;line-height:15px}#dg-new-constructor{padding:10px;color:#222;font-family:Monaco, monospace;font-size:10px;border:0;resize:none;box-shadow:inset 1px 1px 1px #888;word-wrap:break-word;margin:12px 0;display:block;width:440px;overflow-y:scroll;height:100px;position:relative}#dg-local-explain{display:none;font-size:11px;line-height:17px;border-radius:3px;background-color:#333;padding:8px;margin-top:10px}#dg-local-explain code{font-size:10px}#dat-gui-save-locally{display:none}.dg{color:#eee;font:11px 'Lucida Grande', sans-serif;text-shadow:0 -1px 0 #111}.dg.main::-webkit-scrollbar{width:5px;background:#1a1a1a}.dg.main::-webkit-scrollbar-corner{height:0;display:none}.dg.main::-webkit-scrollbar-thumb{border-radius:5px;background:#676767}.dg li:not(.folder){background:#1a1a1a;border-bottom:1px solid #2c2c2c}.dg li.save-row{line-height:25px;background:#dad5cb;border:0}.dg li.save-row select{margin-left:5px;width:108px}.dg li.save-row .button{margin-left:5px;margin-top:1px;border-radius:2px;font-size:9px;line-height:7px;padding:4px 4px 5px 4px;background:#c5bdad;color:#fff;text-shadow:0 1px 0 #b0a58f;box-shadow:0 -1px 0 #b0a58f;cursor:pointer}.dg li.save-row .button.gears{background:#c5bdad url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAANCAYAAAB/9ZQ7AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAQJJREFUeNpiYKAU/P//PwGIC/ApCABiBSAW+I8AClAcgKxQ4T9hoMAEUrxx2QSGN6+egDX+/vWT4e7N82AMYoPAx/evwWoYoSYbACX2s7KxCxzcsezDh3evFoDEBYTEEqycggWAzA9AuUSQQgeYPa9fPv6/YWm/Acx5IPb7ty/fw+QZblw67vDs8R0YHyQhgObx+yAJkBqmG5dPPDh1aPOGR/eugW0G4vlIoTIfyFcA+QekhhHJhPdQxbiAIguMBTQZrPD7108M6roWYDFQiIAAv6Aow/1bFwXgis+f2LUAynwoIaNcz8XNx3Dl7MEJUDGQpx9gtQ8YCueB+D26OECAAQDadt7e46D42QAAAABJRU5ErkJggg==) 2px 1px no-repeat;height:7px;width:8px}.dg li.save-row .button:hover{background-color:#bab19e;box-shadow:0 -1px 0 #b0a58f}.dg li.folder{border-bottom:0}.dg li.title{padding-left:16px;background:#000 url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlI+hKgFxoCgAOw==) 6px 10px no-repeat;cursor:pointer;border-bottom:1px solid rgba(255,255,255,0.2)}.dg .closed li.title{background-image:url(data:image/gif;base64,R0lGODlhBQAFAJEAAP////Pz8////////yH5BAEAAAIALAAAAAAFAAUAAAIIlGIWqMCbWAEAOw==)}.dg .cr.boolean{border-left:3px solid #806787}.dg .cr.color{border-left:3px solid}.dg .cr.function{border-left:3px solid #e61d5f}.dg .cr.number{border-left:3px solid #2FA1D6}.dg .cr.number input[type=text]{color:#2FA1D6}.dg .cr.string{border-left:3px solid #1ed36f}.dg .cr.string input[type=text]{color:#1ed36f}.dg .cr.function:hover,.dg .cr.boolean:hover{background:#111}.dg .c input[type=text]{background:#303030;outline:none}.dg .c input[type=text]:hover{background:#3c3c3c}.dg .c input[type=text]:focus{background:#494949;color:#fff}.dg .c .slider{background:#303030;cursor:ew-resize}.dg .c .slider-fg{background:#2FA1D6;max-width:100%}.dg .c .slider:hover{background:#3c3c3c}.dg .c .slider:hover .slider-fg{background:#44abda}\n");te.inject(re);var se="Default",ae=function(){try{return!!window.localStorage}catch(e){return!1}}(),le=void 0,de=!0,ce=void 0,ue=!1,_e=[],he=function e(t){var n=this,o=t||{};this.domElement=document.createElement("div"),this.__ul=document.createElement("ul"),this.domElement.appendChild(this.__ul),X.addClass(this.domElement,"dg"),this.__folders={},this.__controllers=[],this.__rememberedObjects=[],this.__rememberedObjectIndecesToControllers=[],this.__listening=[],o=S.defaults(o,{closeOnTop:!1,autoPlace:!0,width:e.DEFAULT_WIDTH}),o=S.defaults(o,{resizable:o.autoPlace,hideable:o.autoPlace}),S.isUndefined(o.load)?o.load={preset:se}:o.preset&&(o.load.preset=o.preset),S.isUndefined(o.parent)&&o.hideable&&_e.push(this),o.resizable=S.isUndefined(o.parent)&&o.resizable,o.autoPlace&&S.isUndefined(o.scrollable)&&(o.scrollable=!0);var i=ae&&"true"===localStorage.getItem(m(this,"isLocal")),r=void 0,s=void 0;if(Object.defineProperties(this,{parent:{get:function(){return o.parent}},scrollable:{get:function(){return o.scrollable}},autoPlace:{get:function(){return o.autoPlace}},closeOnTop:{get:function(){return o.closeOnTop}},preset:{get:function(){return n.parent?n.getRoot().preset:o.load.preset},set:function(e){n.parent?n.getRoot().preset=e:o.load.preset=e,E(this),n.revert()}},width:{get:function(){return o.width},set:function(e){o.width=e,w(n,e)}},name:{get:function(){return o.name},set:function(e){o.name=e,s&&(s.innerHTML=o.name)}},closed:{get:function(){return o.closed},set:function(t){o.closed=t,o.closed?X.addClass(n.__ul,e.CLASS_CLOSED):X.removeClass(n.__ul,e.CLASS_CLOSED),this.onResize(),n.__closeButton&&(n.__closeButton.innerHTML=t?e.TEXT_OPEN:e.TEXT_CLOSED)}},load:{get:function(){return o.load}},useLocalStorage:{get:function(){return i},set:function(e){ae&&(i=e,e?X.bind(window,"unload",r):X.unbind(window,"unload",r),localStorage.setItem(m(n,"isLocal"),e))}}}),S.isUndefined(o.parent)){if(this.closed=o.closed||!1,X.addClass(this.domElement,e.CLASS_MAIN),X.makeSelectable(this.domElement,!1),ae&&i){n.useLocalStorage=!0;var a=localStorage.getItem(m(this,"gui"));a&&(o.load=JSON.parse(a))}this.__closeButton=document.createElement("div"),this.__closeButton.innerHTML=e.TEXT_CLOSED,X.addClass(this.__closeButton,e.CLASS_CLOSE_BUTTON),o.closeOnTop?(X.addClass(this.__closeButton,e.CLASS_CLOSE_TOP),this.domElement.insertBefore(this.__closeButton,this.domElement.childNodes[0])):(X.addClass(this.__closeButton,e.CLASS_CLOSE_BOTTOM),this.domElement.appendChild(this.__closeButton)),X.bind(this.__closeButton,"click",function(){n.closed=!n.closed})}else{void 0===o.closed&&(o.closed=!0);var l=document.createTextNode(o.name);X.addClass(l,"controller-name"),s=c(n,l);X.addClass(this.__ul,e.CLASS_CLOSED),X.addClass(s,"title"),X.bind(s,"click",function(e){return e.preventDefault(),n.closed=!n.closed,!1}),o.closed||(this.closed=!1)}o.autoPlace&&(S.isUndefined(o.parent)&&(de&&(ce=document.createElement("div"),X.addClass(ce,"dg"),X.addClass(ce,e.CLASS_AUTO_PLACE_CONTAINER),document.body.appendChild(ce),de=!1),ce.appendChild(this.domElement),X.addClass(this.domElement,e.CLASS_AUTO_PLACE)),this.parent||w(n,o.width)),this.__resizeHandler=function(){n.onResizeDebounced()},X.bind(window,"resize",this.__resizeHandler),X.bind(this.__ul,"webkitTransitionEnd",this.__resizeHandler),X.bind(this.__ul,"transitionend",this.__resizeHandler),X.bind(this.__ul,"oTransitionEnd",this.__resizeHandler),this.onResize(),o.resizable&&y(this),r=function(){ae&&"true"===localStorage.getItem(m(n,"isLocal"))&&localStorage.setItem(m(n,"gui"),JSON.stringify(n.getSaveObject()))},this.saveToLocalStorageIfPossible=r,o.parent||function(){var e=n.getRoot();e.width+=1,S.defer(function(){e.width-=1})}()};he.toggleHide=function(){ue=!ue,S.each(_e,function(e){e.domElement.style.display=ue?"none":""})},he.CLASS_AUTO_PLACE="a",he.CLASS_AUTO_PLACE_CONTAINER="ac",he.CLASS_MAIN="main",he.CLASS_CONTROLLER_ROW="cr",he.CLASS_TOO_TALL="taller-than-window",he.CLASS_CLOSED="closed",he.CLASS_CLOSE_BUTTON="close-button",he.CLASS_CLOSE_TOP="close-top",he.CLASS_CLOSE_BOTTOM="close-bottom",he.CLASS_DRAG="drag",he.DEFAULT_WIDTH=245,he.TEXT_CLOSED="Close Controls",he.TEXT_OPEN="Open Controls",he._keydownHandler=function(e){"text"===document.activeElement.type||72!==e.which&&72!==e.keyCode||he.toggleHide()},X.bind(window,"keydown",he._keydownHandler,!1),S.extend(he.prototype,{add:function(e,t){return f(this,e,t,{factoryArgs:Array.prototype.slice.call(arguments,2)})},addColor:function(e,t){return f(this,e,t,{color:!0})},remove:function(e){this.__ul.removeChild(e.__li),this.__controllers.splice(this.__controllers.indexOf(e),1);var t=this;S.defer(function(){t.onResize()})},destroy:function(){if(this.parent)throw new Error("Only the root GUI should be removed with .destroy(). For subfolders, use gui.removeFolder(folder) instead.");this.autoPlace&&ce.removeChild(this.domElement);var e=this;S.each(this.__folders,function(t){e.removeFolder(t)}),X.unbind(window,"keydown",he._keydownHandler,!1),u(this)},addFolder:function(e){if(void 0!==this.__folders[e])throw new Error('You already have a folder in this GUI by the name "'+e+'"');var t={name:e,parent:this};t.autoPlace=this.autoPlace,this.load&&this.load.folders&&this.load.folders[e]&&(t.closed=this.load.folders[e].closed,t.load=this.load.folders[e]);var n=new he(t);this.__folders[e]=n;var o=c(this,n.domElement);return X.addClass(o,"folder"),n},removeFolder:function(e){this.__ul.removeChild(e.domElement.parentElement),delete this.__folders[e.name],this.load&&this.load.folders&&this.load.folders[e.name]&&delete this.load.folders[e.name],u(e);var t=this;S.each(e.__folders,function(t){e.removeFolder(t)}),S.defer(function(){t.onResize()})},open:function(){this.closed=!1},close:function(){this.closed=!0},hide:function(){this.domElement.style.display="none"},show:function(){this.domElement.style.display=""},onResize:function(){var e=this.getRoot();if(e.scrollable){var t=X.getOffset(e.__ul).top,n=0;S.each(e.__ul.childNodes,function(t){e.autoPlace&&t===e.__save_row||(n+=X.getHeight(t))}),window.innerHeight-t-20<n?(X.addClass(e.domElement,he.CLASS_TOO_TALL),e.__ul.style.height=window.innerHeight-t-20+"px"):(X.removeClass(e.domElement,he.CLASS_TOO_TALL),e.__ul.style.height="auto")}e.__resize_handle&&S.defer(function(){e.__resize_handle.style.height=e.__ul.offsetHeight+"px"}),e.__closeButton&&(e.__closeButton.style.width=e.width+"px")},onResizeDebounced:S.debounce(function(){this.onResize()},50),remember:function(){if(S.isUndefined(le)&&((le=new ie).domElement.innerHTML='<div id="dg-save" class="dg dialogue">\n\n  Here\'s the new load parameter for your <code>GUI</code>\'s constructor:\n\n  <textarea id="dg-new-constructor"></textarea>\n\n  <div id="dg-save-locally">\n\n    <input id="dg-local-storage" type="checkbox"/> Automatically save\n    values to <code>localStorage</code> on exit.\n\n    <div id="dg-local-explain">The values saved to <code>localStorage</code> will\n      override those passed to <code>dat.GUI</code>\'s constructor. This makes it\n      easier to work incrementally, but <code>localStorage</code> is fragile,\n      and your friends may not see the same values you do.\n\n    </div>\n\n  </div>\n\n</div>'),this.parent)throw new Error("You can only call remember on a top level GUI.");var e=this;S.each(Array.prototype.slice.call(arguments),function(t){0===e.__rememberedObjects.length&&v(e),-1===e.__rememberedObjects.indexOf(t)&&e.__rememberedObjects.push(t)}),this.autoPlace&&w(this,this.width)},getRoot:function(){for(var e=this;e.parent;)e=e.parent;return e},getSaveObject:function(){var e=this.load;return e.closed=this.closed,this.__rememberedObjects.length>0&&(e.preset=this.preset,e.remembered||(e.remembered={}),e.remembered[this.preset]=x(this)),e.folders={},S.each(this.__folders,function(t,n){e.folders[n]=t.getSaveObject()}),e},save:function(){this.load.remembered||(this.load.remembered={}),this.load.remembered[this.preset]=x(this),_(this,!1),this.saveToLocalStorageIfPossible()},saveAs:function(e){this.load.remembered||(this.load.remembered={},this.load.remembered[se]=x(this,!0)),this.load.remembered[e]=x(this),this.preset=e,g(this,e,!0),this.saveToLocalStorageIfPossible()},revert:function(e){S.each(this.__controllers,function(t){this.getRoot().load.remembered?p(e||this.getRoot(),t):t.setValue(t.initialValue),t.__onFinishChange&&t.__onFinishChange.call(t,t.getValue())},this),S.each(this.__folders,function(e){e.revert(e)}),e||_(this.getRoot(),!1)},listen:function(e){var t=0===this.__listening.length;this.__listening.push(e),t&&C(this.__listening)},updateDisplay:function(){S.each(this.__controllers,function(e){e.updateDisplay()}),S.each(this.__folders,function(e){e.updateDisplay()})}});var pe={Color:I,math:N,interpret:R},fe={Controller:z,BooleanController:K,OptionController:Y,StringController:J,NumberController:W,NumberControllerBox:Q,NumberControllerSlider:q,FunctionController:Z,ColorController:$},me={dom:X},ge={GUI:he},be=he,ve={color:pe,controllers:fe,dom:me,gui:ge,GUI:be};e.color=pe,e.controllers=fe,e.dom=me,e.gui=ge,e.GUI=be,e.default=ve,Object.defineProperty(e,"__esModule",{value:!0})});
/* axios v0.19.0 | (c) 2019 by Matt Zabriskie */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(5),a=n(22),u=n(11),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"[object ArrayBuffer]"===j.call(e)}function s(e){return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===j.call(e)}function d(e){return"[object File]"===j.call(e)}function l(e){return"[object Blob]"===j.call(e)}function h(e){return"[object Function]"===j.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function g(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.call(null,e[s],s,e)}function w(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=w(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)v(arguments[n],e);return t}function b(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=b(t[n],e):"object"==typeof e?t[n]=b({},e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)v(arguments[n],e);return t}function E(e,t,n){return v(t,function(t,r){n&&"function"==typeof t?e[r]=S(t,n):e[r]=t}),e}var S=n(3),R=n(4),j=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:o,isBuffer:R,isFormData:s,isArrayBufferView:i,isString:a,isNumber:u,isObject:f,isUndefined:c,isDate:p,isFile:d,isBlob:l,isFunction:h,isStream:m,isURLSearchParams:y,isStandardBrowserEnv:x,forEach:v,merge:w,deepMerge:b,extend:E,trim:g}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t){/*!
	 * Determine if an object is a Buffer
	 *
	 * @author   Feross Aboukhadijeh <https://feross.org>
	 * @license  MIT
	 */
e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new i,response:new i}}var o=n(2),s=n(6),i=n(7),a=n(8),u=n(22);r.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=u(this.defaults,e),e.method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},r.prototype.getUri=function(e){return e=u(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(o.isURLSearchParams(t))s=t.toString();else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(r(t)+"="+r(e))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),s=n(9),i=n(10),a=n(11),u=n(20),c=n(21);e.exports=function(e){r(e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=s(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(r(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?e=n(13):"undefined"!=typeof XMLHttpRequest&&(e=n(13)),e}var s=n(2),i=n(12),a={"Content-Type":"application/x-www-form-urlencoded"},u={adapter:o(),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)?e:s.isArrayBufferView(e)?e.buffer:s.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):s.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(14),s=n(6),i=n(17),a=n(18),u=n(15);e.exports=function(e){return new Promise(function(t,c){var f=e.data,p=e.headers;r.isFormData(f)&&delete p["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",h=e.auth.password||"";p.Authorization="Basic "+btoa(l+":"+h)}if(d.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?d.response:d.responseText,s={data:r,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};o(t,c,s),d=null}},d.onabort=function(){d&&(c(u("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){c(u("Network Error",e,null,d)),d=null},d.ontimeout=function(){c(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var m=n(19),y=(e.withCredentials||a(e.url))&&e.xsrfCookieName?m.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){"undefined"==typeof f&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),c(e),d=null)}),void 0===f&&(f=null),d.send(f)})}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(16);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={};return r.forEach(["url","method","params","data"],function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(["headers","auth","proxy"],function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
//# sourceMappingURL=axios.min.map// threejs.org/license
(function(k,Ba){"object"===typeof exports&&"undefined"!==typeof module?Ba(exports):"function"===typeof define&&define.amd?define(["exports"],Ba):(k=k||self,Ba(k.THREE={}))})(this,function(k){function Ba(){}function w(a,b){this.x=a||0;this.y=b||0}function ua(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1}function n(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0}function Y(){this.elements=[1,0,0,0,1,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}
function W(a,b,c,d,e,f,g,h,l,m){Object.defineProperty(this,"id",{value:Ri++});this.uuid=L.generateUUID();this.name="";this.image=void 0!==a?a:W.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:W.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:1001;this.wrapT=void 0!==d?d:1001;this.magFilter=void 0!==e?e:1006;this.minFilter=void 0!==f?f:1008;this.anisotropy=void 0!==l?l:1;this.format=void 0!==g?g:1023;this.type=void 0!==h?h:1009;this.offset=new w(0,0);this.repeat=new w(1,1);this.center=new w(0,0);this.rotation=
0;this.matrixAutoUpdate=!0;this.matrix=new Y;this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:3E3;this.version=0;this.onUpdate=null}function aa(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1}function la(a,b,c){this.width=a;this.height=b;this.scissor=new aa(0,0,a,b);this.scissorTest=!1;this.viewport=new aa(0,0,a,b);c=c||{};this.texture=new W(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy,
c.encoding);this.texture.image={};this.texture.image.width=a;this.texture.image.height=b;this.texture.generateMipmaps=void 0!==c.generateMipmaps?c.generateMipmaps:!1;this.texture.minFilter=void 0!==c.minFilter?c.minFilter:1006;this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0;this.depthTexture=void 0!==c.depthTexture?c.depthTexture:null}function Of(a,b,c){la.call(this,a,b,c);this.samples=4}function U(){this.elements=[1,0,0,0,0,
1,0,0,0,0,1,0,0,0,0,1];0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function Qb(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||Qb.DefaultOrder}function Pf(){this.mask=1}function B(){Object.defineProperty(this,"id",{value:Si++});this.uuid=L.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=B.DefaultUp.clone();var a=new n,b=new Qb,c=new ua,d=new n(1,1,1);b._onChange(function(){c.setFromEuler(b,
!1)});c._onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:a},rotation:{configurable:!0,enumerable:!0,value:b},quaternion:{configurable:!0,enumerable:!0,value:c},scale:{configurable:!0,enumerable:!0,value:d},modelViewMatrix:{value:new U},normalMatrix:{value:new Y}});this.matrix=new U;this.matrixWorld=new U;this.matrixAutoUpdate=B.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new Pf;this.visible=!0;
this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}}function wd(){B.call(this);this.type="Scene";this.overrideMaterial=this.fog=this.background=null;this.autoUpdate=!0;"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function ab(a,b){this.min=void 0!==a?a:new n(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new n(-Infinity,-Infinity,-Infinity)}function Qf(a,b,c,d,e){var f;var g=0;for(f=
a.length-3;g<=f;g+=3){Rb.fromArray(a,g);var h=e.x*Math.abs(Rb.x)+e.y*Math.abs(Rb.y)+e.z*Math.abs(Rb.z),l=b.dot(Rb),m=c.dot(Rb),q=d.dot(Rb);if(Math.max(-Math.max(l,m,q),Math.min(l,m,q))>h)return!1}return!0}function nb(a,b){this.center=void 0!==a?a:new n;this.radius=void 0!==b?b:0}function Sb(a,b){this.origin=void 0!==a?a:new n;this.direction=void 0!==b?b:new n}function R(a,b,c){this.a=void 0!==a?a:new n;this.b=void 0!==b?b:new n;this.c=void 0!==c?c:new n}function H(a,b,c){return void 0===b&&void 0===
c?this.set(a):this.setRGB(a,b,c)}function Rf(a,b,c){0>c&&(c+=1);1<c&&--c;return c<1/6?a+6*(b-a)*c:.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a}function Sf(a){return.04045>a?.0773993808*a:Math.pow(.9478672986*a+.0521327014,2.4)}function Tf(a){return.0031308>a?12.92*a:1.055*Math.pow(a,.41666)-.055}function zc(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d&&d.isVector3?d:new n;this.vertexNormals=Array.isArray(d)?d:[];this.color=e&&e.isColor?e:new H;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=
void 0!==f?f:0}function M(){Object.defineProperty(this,"id",{value:Ti++});this.uuid=L.generateUUID();this.name="";this.type="Material";this.fog=!0;this.blending=1;this.side=0;this.vertexTangents=this.flatShading=!1;this.vertexColors=0;this.opacity=1;this.transparent=!1;this.blendSrc=204;this.blendDst=205;this.blendEquation=100;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=3;this.depthWrite=this.depthTest=!0;this.stencilWriteMask=255;this.stencilFunc=519;this.stencilRef=
0;this.stencilFuncMask=255;this.stencilZPass=this.stencilZFail=this.stencilFail=7680;this.stencilWrite=!1;this.clippingPlanes=null;this.clipShadows=this.clipIntersection=!1;this.shadowSide=null;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.dithering=!1;this.alphaTest=0;this.premultipliedAlpha=!1;this.toneMapped=this.visible=!0;this.userData={};this.needsUpdate=!0}function Ga(a){M.call(this);this.type="MeshBasicMaterial";this.color=
new H(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphTargets=this.skinning=!1;this.setValues(a)}function O(a,b,c){if(Array.isArray(a))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.name="";this.array=
a;this.itemSize=b;this.count=void 0!==a?a.length/b:0;this.normalized=!0===c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0}function xd(a,b,c){O.call(this,new Int8Array(a),b,c)}function yd(a,b,c){O.call(this,new Uint8Array(a),b,c)}function zd(a,b,c){O.call(this,new Uint8ClampedArray(a),b,c)}function Ad(a,b,c){O.call(this,new Int16Array(a),b,c)}function Tb(a,b,c){O.call(this,new Uint16Array(a),b,c)}function Bd(a,b,c){O.call(this,new Int32Array(a),b,c)}function Ub(a,b,c){O.call(this,
new Uint32Array(a),b,c)}function A(a,b,c){O.call(this,new Float32Array(a),b,c)}function Cd(a,b,c){O.call(this,new Float64Array(a),b,c)}function jh(){this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1}function kh(a){if(0===a.length)return-Infinity;for(var b=
a[0],c=1,d=a.length;c<d;++c)a[c]>b&&(b=a[c]);return b}function E(){Object.defineProperty(this,"id",{value:Ui+=2});this.uuid=L.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity};this.userData={}}function ja(a,b){B.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new E;this.material=void 0!==b?b:new Ga({color:16777215*Math.random()});this.drawMode=
0;this.updateMorphTargets()}function lh(a,b,c,d,e,f,g,h){if(null===(1===b.side?d.intersectTriangle(g,f,e,!0,h):d.intersectTriangle(e,f,g,2!==b.side,h)))return null;Ee.copy(h);Ee.applyMatrix4(a.matrixWorld);b=c.ray.origin.distanceTo(Ee);return b<c.near||b>c.far?null:{distance:b,point:Ee.clone(),object:a}}function Fe(a,b,c,d,e,f,g,h,l,m,q){Vb.fromBufferAttribute(e,l);Wb.fromBufferAttribute(e,m);Xb.fromBufferAttribute(e,q);e=a.morphTargetInfluences;if(b.morphTargets&&f&&e){Uf.set(0,0,0);Vf.set(0,0,0);
Wf.set(0,0,0);for(var u=0,t=f.length;u<t;u++){var k=e[u],p=f[u];0!==k&&(mh.fromBufferAttribute(p,l),nh.fromBufferAttribute(p,m),oh.fromBufferAttribute(p,q),Uf.addScaledVector(mh.sub(Vb),k),Vf.addScaledVector(nh.sub(Wb),k),Wf.addScaledVector(oh.sub(Xb),k))}Vb.add(Uf);Wb.add(Vf);Xb.add(Wf)}if(a=lh(a,b,c,d,Vb,Wb,Xb,Dd))g&&(Ac.fromBufferAttribute(g,l),Bc.fromBufferAttribute(g,m),Cc.fromBufferAttribute(g,q),a.uv=R.getUV(Dd,Vb,Wb,Xb,Ac,Bc,Cc,new w)),h&&(Ac.fromBufferAttribute(h,l),Bc.fromBufferAttribute(h,
m),Cc.fromBufferAttribute(h,q),a.uv2=R.getUV(Dd,Vb,Wb,Xb,Ac,Bc,Cc,new w)),g=new zc(l,m,q),R.getNormal(Vb,Wb,Xb,g.normal),a.face=g;return a}function F(){Object.defineProperty(this,"id",{value:Vi+=2});this.uuid=L.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=
this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.verticesNeedUpdate=this.elementsNeedUpdate=!1}function Yb(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];e&&(e.isColor||e.isMatrix3||e.isMatrix4||e.isVector2||e.isVector3||e.isVector4||e.isTexture)?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}function Da(a){for(var b={},c=0;c<a.length;c++){var d=Yb(a[c]),e;for(e in d)b[e]=d[e]}return b}function ma(a){M.call(this);this.type="ShaderMaterial";
this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.clipping=this.lights=this.fog=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,
1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;this.uniformsNeedUpdate=!1;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))}function bb(){B.call(this);this.type="Camera";this.matrixWorldInverse=new U;this.projectionMatrix=new U;this.projectionMatrixInverse=new U}function na(a,b,c,d){bb.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:50;this.zoom=1;this.near=void 0!==
c?c:.1;this.far=void 0!==d?d:2E3;this.focus=10;this.aspect=void 0!==b?b:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()}function Dc(a,b,c,d){B.call(this);this.type="CubeCamera";var e=new na(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new n(1,0,0));this.add(e);var f=new na(90,1,a,b);f.up.set(0,-1,0);f.lookAt(new n(-1,0,0));this.add(f);var g=new na(90,1,a,b);g.up.set(0,0,1);g.lookAt(new n(0,1,0));this.add(g);var h=new na(90,1,a,b);h.up.set(0,0,-1);h.lookAt(new n(0,-1,0));
this.add(h);var l=new na(90,1,a,b);l.up.set(0,-1,0);l.lookAt(new n(0,0,1));this.add(l);var m=new na(90,1,a,b);m.up.set(0,-1,0);m.lookAt(new n(0,0,-1));this.add(m);d=d||{format:1022,magFilter:1006,minFilter:1006};this.renderTarget=new Ab(c,c,d);this.renderTarget.texture.name="CubeCamera";this.update=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=a.getRenderTarget(),d=this.renderTarget,q=d.texture.generateMipmaps;d.texture.generateMipmaps=!1;a.setRenderTarget(d,0);a.render(b,e);a.setRenderTarget(d,
1);a.render(b,f);a.setRenderTarget(d,2);a.render(b,g);a.setRenderTarget(d,3);a.render(b,h);a.setRenderTarget(d,4);a.render(b,l);d.texture.generateMipmaps=q;a.setRenderTarget(d,5);a.render(b,m);a.setRenderTarget(c)};this.clear=function(a,b,c,d){for(var e=a.getRenderTarget(),f=this.renderTarget,g=0;6>g;g++)a.setRenderTarget(f,g),a.clear(b,c,d);a.setRenderTarget(e)}}function Ab(a,b,c){la.call(this,a,b,c)}function Zb(a,b,c,d,e,f,g,h,l,m,q,u){W.call(this,null,f,g,h,l,m,d,e,q,u);this.image={data:a||null,
width:b||1,height:c||1};this.magFilter=void 0!==l?l:1003;this.minFilter=void 0!==m?m:1003;this.flipY=this.generateMipmaps=!1;this.unpackAlignment=1;this.needsUpdate=!0}function cb(a,b){this.normal=void 0!==a?a:new n(1,0,0);this.constant=void 0!==b?b:0}function Ed(a,b,c,d,e,f){this.planes=[void 0!==a?a:new cb,void 0!==b?b:new cb,void 0!==c?c:new cb,void 0!==d?d:new cb,void 0!==e?e:new cb,void 0!==f?f:new cb]}function Xf(){function a(e,f){!1!==c&&(d(e,f),b.requestAnimationFrame(a))}var b=null,c=!1,
d=null;return{start:function(){!0!==c&&null!==d&&(b.requestAnimationFrame(a),c=!0)},stop:function(){c=!1},setAnimationLoop:function(a){d=a},setContext:function(a){b=a}}}function Wi(a){function b(b,c){var d=b.array,e=b.dynamic?35048:35044,h=a.createBuffer();a.bindBuffer(c,h);a.bufferData(c,d,e);b.onUploadCallback();c=5126;d instanceof Float32Array?c=5126:d instanceof Float64Array?console.warn("THREE.WebGLAttributes: Unsupported data buffer format: Float64Array."):d instanceof Uint16Array?c=5123:d instanceof
Int16Array?c=5122:d instanceof Uint32Array?c=5125:d instanceof Int32Array?c=5124:d instanceof Int8Array?c=5120:d instanceof Uint8Array&&(c=5121);return{buffer:h,type:c,bytesPerElement:d.BYTES_PER_ELEMENT,version:b.version}}var c=new WeakMap;return{get:function(a){a.isInterleavedBufferAttribute&&(a=a.data);return c.get(a)},remove:function(b){b.isInterleavedBufferAttribute&&(b=b.data);var d=c.get(b);d&&(a.deleteBuffer(d.buffer),c.delete(b))},update:function(d,e){d.isInterleavedBufferAttribute&&(d=d.data);
var f=c.get(d);if(void 0===f)c.set(d,b(d,e));else if(f.version<d.version){var g=d,h=g.array,l=g.updateRange;a.bindBuffer(e,f.buffer);!1===g.dynamic?a.bufferData(e,h,35044):-1===l.count?a.bufferSubData(e,0,h):0===l.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):(a.bufferSubData(e,l.offset*h.BYTES_PER_ELEMENT,h.subarray(l.offset,l.offset+l.count)),l.count=-1);
f.version=d.version}}}}function Fd(a,b,c,d){F.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new $b(a,b,c,d));this.mergeVertices()}function $b(a,b,c,d){E.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};a=a||1;b=b||1;var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,l=a/c,m=b/d,q=[],u=[],t=[],k=[];for(a=0;a<h;a++){var p=a*m-f;for(b=0;b<
g;b++)u.push(b*l-e,-p,0),t.push(0,0,1),k.push(b/c),k.push(1-a/d)}for(a=0;a<d;a++)for(b=0;b<c;b++)e=b+g*(a+1),f=b+1+g*(a+1),h=b+1+g*a,q.push(b+g*a,e,h),q.push(e,f,h);this.setIndex(q);this.addAttribute("position",new A(u,3));this.addAttribute("normal",new A(t,3));this.addAttribute("uv",new A(k,2))}function Xi(a,b,c,d){function e(a,c){b.buffers.color.setClear(a.r,a.g,a.b,c,d)}var f=new H(0),g=0,h,l,m=null,q=0;return{getClearColor:function(){return f},setClearColor:function(a,b){f.set(a);g=void 0!==b?
b:1;e(f,g)},getClearAlpha:function(){return g},setClearAlpha:function(a){g=a;e(f,g)},render:function(b,d,k,p){d=d.background;k=a.vr;(k=k.getSession&&k.getSession())&&"additive"===k.environmentBlendMode&&(d=null);null===d?(e(f,g),m=null,q=0):d&&d.isColor&&(e(d,1),p=!0,m=null,q=0);(a.autoClear||p)&&a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil);if(d&&(d.isCubeTexture||d.isWebGLRenderTargetCube)){void 0===l&&(l=new ja(new Gd(1,1,1),new ma({type:"BackgroundCubeMaterial",uniforms:Yb(db.cube.uniforms),
vertexShader:db.cube.vertexShader,fragmentShader:db.cube.fragmentShader,side:1,depthTest:!1,depthWrite:!1,fog:!1})),l.geometry.removeAttribute("normal"),l.geometry.removeAttribute("uv"),l.onBeforeRender=function(a,b,c){this.matrixWorld.copyPosition(c.matrixWorld)},Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.tCube.value}}),c.update(l));p=d.isWebGLRenderTargetCube?d.texture:d;l.material.uniforms.tCube.value=p;l.material.uniforms.tFlip.value=d.isWebGLRenderTargetCube?
1:-1;if(m!==d||q!==p.version)l.material.needsUpdate=!0,m=d,q=p.version;b.unshift(l,l.geometry,l.material,0,0,null)}else if(d&&d.isTexture){void 0===h&&(h=new ja(new $b(2,2),new ma({type:"BackgroundMaterial",uniforms:Yb(db.background.uniforms),vertexShader:db.background.vertexShader,fragmentShader:db.background.fragmentShader,side:0,depthTest:!1,depthWrite:!1,fog:!1})),h.geometry.removeAttribute("normal"),Object.defineProperty(h.material,"map",{get:function(){return this.uniforms.t2D.value}}),c.update(h));
h.material.uniforms.t2D.value=d;!0===d.matrixAutoUpdate&&d.updateMatrix();h.material.uniforms.uvTransform.value.copy(d.matrix);if(m!==d||q!==d.version)h.material.needsUpdate=!0,m=d,q=d.version;b.unshift(h,h.geometry,h.material,0,0,null)}}}}function Yi(a,b,c,d){var e;this.setMode=function(a){e=a};this.render=function(b,d){a.drawArrays(e,b,d);c.update(d,e)};this.renderInstances=function(f,g,h,l){if(0!==l){if(d.isWebGL2){f=a;var m="drawArraysInstanced"}else if(f=b.get("ANGLE_instanced_arrays"),m="drawArraysInstancedANGLE",
null===f){console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");return}f[m](e,g,h,l);c.update(h,e,l)}}}function Zi(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(35633,36338).precision&&0<a.getShaderPrecisionFormat(35632,36338).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(35633,36337).precision&&0<a.getShaderPrecisionFormat(35632,36337).precision?
"mediump":"lowp"}var e,f="undefined"!==typeof WebGL2RenderingContext&&a instanceof WebGL2RenderingContext,g=void 0!==c.precision?c.precision:"highp",h=d(g);h!==g&&(console.warn("THREE.WebGLRenderer:",g,"not supported, using",h,"instead."),g=h);c=!0===c.logarithmicDepthBuffer;h=a.getParameter(34930);var l=a.getParameter(35660),m=a.getParameter(3379),q=a.getParameter(34076),u=a.getParameter(34921),t=a.getParameter(36347),k=a.getParameter(36348),p=a.getParameter(36349),v=0<l,x=f||!!b.get("OES_texture_float"),
n=v&&x,y=f?a.getParameter(36183):0;return{isWebGL2:f,getMaxAnisotropy:function(){if(void 0!==e)return e;var c=b.get("EXT_texture_filter_anisotropic");return e=null!==c?a.getParameter(c.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0},getMaxPrecision:d,precision:g,logarithmicDepthBuffer:c,maxTextures:h,maxVertexTextures:l,maxTextureSize:m,maxCubemapSize:q,maxAttributes:u,maxVertexUniforms:t,maxVaryings:k,maxFragmentUniforms:p,vertexTextures:v,floatFragmentTextures:x,floatVertexTextures:n,maxSamples:y}}function $i(){function a(){m.value!==
d&&(m.value=d,m.needsUpdate=0<e);c.numPlanes=e;c.numIntersection=0}function b(a,b,d,e){var f=null!==a?a.length:0,g=null;if(0!==f){g=m.value;if(!0!==e||null===g){e=d+4*f;b=b.matrixWorldInverse;l.getNormalMatrix(b);if(null===g||g.length<e)g=new Float32Array(e);for(e=0;e!==f;++e,d+=4)h.copy(a[e]).applyMatrix4(b,l),h.normal.toArray(g,d),g[d+3]=h.constant}m.value=g;m.needsUpdate=!0}c.numPlanes=f;return g}var c=this,d=null,e=0,f=!1,g=!1,h=new cb,l=new Y,m={value:null,needsUpdate:!1};this.uniform=m;this.numIntersection=
this.numPlanes=0;this.init=function(a,c,g){var h=0!==a.length||c||0!==e||f;f=c;d=b(a,g,0);e=a.length;return h};this.beginShadows=function(){g=!0;b(null)};this.endShadows=function(){g=!1;a()};this.setState=function(c,h,l,k,p,v){if(!f||null===c||0===c.length||g&&!l)g?b(null):a();else{l=g?0:e;var q=4*l,u=p.clippingState||null;m.value=u;u=b(c,k,q,v);for(c=0;c!==q;++c)u[c]=d[c];p.clippingState=u;this.numIntersection=h?this.numPlanes:0;this.numPlanes+=l}}}function aj(a){var b={};return{get:function(c){if(void 0!==
b[c])return b[c];switch(c){case "WEBGL_depth_texture":var d=a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");break;case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||
a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}}}function bj(a,b,c){function d(a){var e=a.target;a=f.get(e);null!==a.index&&b.remove(a.index);for(var h in a.attributes)b.remove(a.attributes[h]);e.removeEventListener("dispose",
d);f.delete(e);if(h=g.get(a))b.remove(h),g.delete(a);c.memory.geometries--}function e(a){var c=[],d=a.index,e=a.attributes.position;if(null!==d){var f=d.array;d=d.version;e=0;for(var h=f.length;e<h;e+=3){var k=f[e+0],p=f[e+1],v=f[e+2];c.push(k,p,p,v,v,k)}}else for(f=e.array,d=e.version,e=0,h=f.length/3-1;e<h;e+=3)k=e+0,p=e+1,v=e+2,c.push(k,p,p,v,v,k);c=new (65535<kh(c)?Ub:Tb)(c,1);c.version=d;b.update(c,34963);(f=g.get(a))&&b.remove(f);g.set(a,c)}var f=new WeakMap,g=new WeakMap;return{get:function(a,
b){var e=f.get(b);if(e)return e;b.addEventListener("dispose",d);b.isBufferGeometry?e=b:b.isGeometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new E).setFromObject(a)),e=b._bufferGeometry);f.set(b,e);c.memory.geometries++;return e},update:function(a){var c=a.index,d=a.attributes;null!==c&&b.update(c,34963);for(var e in d)b.update(d[e],34962);a=a.morphAttributes;for(e in a){c=a[e];d=0;for(var f=c.length;d<f;d++)b.update(c[d],34962)}},getWireframeAttribute:function(a){var b=g.get(a);if(b){var c=
a.index;null!==c&&b.version<c.version&&e(a)}else e(a);return g.get(a)}}}function cj(a,b,c,d){var e,f,g;this.setMode=function(a){e=a};this.setIndex=function(a){f=a.type;g=a.bytesPerElement};this.render=function(b,d){a.drawElements(e,d,f,b*g);c.update(d,e)};this.renderInstances=function(h,l,m,q){if(0!==q){if(d.isWebGL2){h=a;var u="drawElementsInstanced"}else if(h=b.get("ANGLE_instanced_arrays"),u="drawElementsInstancedANGLE",null===h){console.error("THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
return}h[u](e,m,f,l*g,q);c.update(m,e,q)}}}function dj(a){var b={frame:0,calls:0,triangles:0,points:0,lines:0};return{memory:{geometries:0,textures:0},render:b,programs:null,autoReset:!0,reset:function(){b.frame++;b.calls=0;b.triangles=0;b.points=0;b.lines=0},update:function(a,d,e){e=e||1;b.calls++;switch(d){case 4:b.triangles+=a/3*e;break;case 5:case 6:b.triangles+=e*(a-2);break;case 1:b.lines+=a/2*e;break;case 3:b.lines+=e*(a-1);break;case 2:b.lines+=e*a;break;case 0:b.points+=e*a;break;default:console.error("THREE.WebGLInfo: Unknown draw mode:",
d)}}}}function ej(a,b){return Math.abs(b[1])-Math.abs(a[1])}function fj(a){var b={},c=new Float32Array(8);return{update:function(d,e,f,g){var h=d.morphTargetInfluences,l=h.length;d=b[e.id];if(void 0===d){d=[];for(var m=0;m<l;m++)d[m]=[m,0];b[e.id]=d}var q=f.morphTargets&&e.morphAttributes.position;f=f.morphNormals&&e.morphAttributes.normal;for(m=0;m<l;m++){var u=d[m];0!==u[1]&&(q&&e.removeAttribute("morphTarget"+m),f&&e.removeAttribute("morphNormal"+m))}for(m=0;m<l;m++)u=d[m],u[0]=m,u[1]=h[m];d.sort(ej);
for(m=0;8>m;m++){if(u=d[m])if(h=u[0],l=u[1]){q&&e.addAttribute("morphTarget"+m,q[h]);f&&e.addAttribute("morphNormal"+m,f[h]);c[m]=l;continue}c[m]=0}g.getUniforms().setValue(a,"morphTargetInfluences",c)}}}function gj(a,b,c,d){var e={};return{update:function(a){var f=d.render.frame,h=a.geometry,l=b.get(a,h);e[l.id]!==f&&(h.isGeometry&&l.updateFromObject(a),b.update(l),e[l.id]=f);a.isInstancedMesh&&c.update(a.instanceMatrix,34962);return l},dispose:function(){e={}}}}function ob(a,b,c,d,e,f,g,h,l,m){a=
void 0!==a?a:[];W.call(this,a,void 0!==b?b:301,c,d,e,f,void 0!==g?g:1022,h,l,m);this.flipY=!1}function Ec(a,b,c,d){W.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=!0}function Fc(a,b,c,d){W.call(this,null);this.image={data:a||null,width:b||1,height:c||1,depth:d||1};this.minFilter=this.magFilter=1003;this.wrapR=1001;this.flipY=this.generateMipmaps=!1;this.needsUpdate=
!0}function Gc(a,b,c){var d=a[0];if(0>=d||0<d)return a;var e=b*c,f=ph[e];void 0===f&&(f=new Float32Array(e),ph[e]=f);if(0!==b)for(d.toArray(f,0),d=1,e=0;d!==b;++d)e+=c,a[d].toArray(f,e);return f}function La(a,b){if(a.length!==b.length)return!1;for(var c=0,d=a.length;c<d;c++)if(a[c]!==b[c])return!1;return!0}function Ha(a,b){for(var c=0,d=b.length;c<d;c++)a[c]=b[c]}function qh(a,b){var c=rh[b];void 0===c&&(c=new Int32Array(b),rh[b]=c);for(var d=0;d!==b;++d)c[d]=a.allocateTextureUnit();return c}function hj(a,
b){var c=this.cache;c[0]!==b&&(a.uniform1f(this.addr,b),c[0]=b)}function ij(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y)a.uniform2f(this.addr,b.x,b.y),c[0]=b.x,c[1]=b.y}else La(c,b)||(a.uniform2fv(this.addr,b),Ha(c,b))}function jj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z)a.uniform3f(this.addr,b.x,b.y,b.z),c[0]=b.x,c[1]=b.y,c[2]=b.z}else if(void 0!==b.r){if(c[0]!==b.r||c[1]!==b.g||c[2]!==b.b)a.uniform3f(this.addr,b.r,b.g,b.b),c[0]=b.r,c[1]=b.g,
c[2]=b.b}else La(c,b)||(a.uniform3fv(this.addr,b),Ha(c,b))}function kj(a,b){var c=this.cache;if(void 0!==b.x){if(c[0]!==b.x||c[1]!==b.y||c[2]!==b.z||c[3]!==b.w)a.uniform4f(this.addr,b.x,b.y,b.z,b.w),c[0]=b.x,c[1]=b.y,c[2]=b.z,c[3]=b.w}else La(c,b)||(a.uniform4fv(this.addr,b),Ha(c,b))}function lj(a,b){var c=this.cache,d=b.elements;void 0===d?La(c,b)||(a.uniformMatrix2fv(this.addr,!1,b),Ha(c,b)):La(c,d)||(sh.set(d),a.uniformMatrix2fv(this.addr,!1,sh),Ha(c,d))}function mj(a,b){var c=this.cache,d=b.elements;
void 0===d?La(c,b)||(a.uniformMatrix3fv(this.addr,!1,b),Ha(c,b)):La(c,d)||(th.set(d),a.uniformMatrix3fv(this.addr,!1,th),Ha(c,d))}function nj(a,b){var c=this.cache,d=b.elements;void 0===d?La(c,b)||(a.uniformMatrix4fv(this.addr,!1,b),Ha(c,b)):La(c,d)||(uh.set(d),a.uniformMatrix4fv(this.addr,!1,uh),Ha(c,d))}function oj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTexture2D(b||vh,e)}function pj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();
d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture2DArray(b||qj,e)}function rj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.setTexture3D(b||sj,e)}function tj(a,b,c){var d=this.cache,e=c.allocateTextureUnit();d[0]!==e&&(a.uniform1i(this.addr,e),d[0]=e);c.safeSetTextureCube(b||wh,e)}function uj(a,b){var c=this.cache;c[0]!==b&&(a.uniform1i(this.addr,b),c[0]=b)}function vj(a,b){var c=this.cache;La(c,b)||(a.uniform2iv(this.addr,b),Ha(c,b))}function wj(a,
b){var c=this.cache;La(c,b)||(a.uniform3iv(this.addr,b),Ha(c,b))}function xj(a,b){var c=this.cache;La(c,b)||(a.uniform4iv(this.addr,b),Ha(c,b))}function yj(a){switch(a){case 5126:return hj;case 35664:return ij;case 35665:return jj;case 35666:return kj;case 35674:return lj;case 35675:return mj;case 35676:return nj;case 35678:case 36198:return oj;case 35679:return rj;case 35680:return tj;case 36289:return pj;case 5124:case 35670:return uj;case 35667:case 35671:return vj;case 35668:case 35672:return wj;
case 35669:case 35673:return xj}}function zj(a,b){a.uniform1fv(this.addr,b)}function Aj(a,b){a.uniform1iv(this.addr,b)}function Bj(a,b){a.uniform2iv(this.addr,b)}function Cj(a,b){a.uniform3iv(this.addr,b)}function Dj(a,b){a.uniform4iv(this.addr,b)}function Ej(a,b){b=Gc(b,this.size,2);a.uniform2fv(this.addr,b)}function Fj(a,b){b=Gc(b,this.size,3);a.uniform3fv(this.addr,b)}function Gj(a,b){b=Gc(b,this.size,4);a.uniform4fv(this.addr,b)}function Hj(a,b){b=Gc(b,this.size,4);a.uniformMatrix2fv(this.addr,
!1,b)}function Ij(a,b){b=Gc(b,this.size,9);a.uniformMatrix3fv(this.addr,!1,b)}function Jj(a,b){b=Gc(b,this.size,16);a.uniformMatrix4fv(this.addr,!1,b)}function Kj(a,b,c){var d=b.length,e=qh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTexture2D(b[a]||vh,e[a])}function Lj(a,b,c){var d=b.length,e=qh(c,d);a.uniform1iv(this.addr,e);for(a=0;a!==d;++a)c.safeSetTextureCube(b[a]||wh,e[a])}function Mj(a){switch(a){case 5126:return zj;case 35664:return Ej;case 35665:return Fj;case 35666:return Gj;
case 35674:return Hj;case 35675:return Ij;case 35676:return Jj;case 35678:return Kj;case 35680:return Lj;case 5124:case 35670:return Aj;case 35667:case 35671:return Bj;case 35668:case 35672:return Cj;case 35669:case 35673:return Dj}}function Nj(a,b,c){this.id=a;this.addr=c;this.cache=[];this.setValue=yj(b.type)}function xh(a,b,c){this.id=a;this.addr=c;this.cache=[];this.size=b.size;this.setValue=Mj(b.type)}function yh(a){this.id=a;this.seq=[];this.map={}}function Bb(a,b){this.seq=[];this.map={};for(var c=
a.getProgramParameter(b,35718),d=0;d<c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,l=h.length;for(Yf.lastIndex=0;;){var m=Yf.exec(h),q=Yf.lastIndex,u=m[1],k=m[3];"]"===m[2]&&(u|=0);if(void 0===k||"["===k&&q+2===l){h=g;e=void 0===k?new Nj(u,e,f):new xh(u,e,f);h.seq.push(e);h.map[e.id]=e;break}else k=g.map[u],void 0===k&&(k=new yh(u),u=g,g=k,u.seq.push(g),u.map[g.id]=g),g=k}}}function zh(a,b,c){b=a.createShader(b);a.shaderSource(b,c);a.compileShader(b);return b}
function Ah(a){switch(a){case 3E3:return["Linear","( value )"];case 3001:return["sRGB","( value )"];case 3002:return["RGBE","( value )"];case 3004:return["RGBM","( value, 7.0 )"];case 3005:return["RGBM","( value, 16.0 )"];case 3006:return["RGBD","( value, 256.0 )"];case 3007:return["Gamma","( value, float( GAMMA_FACTOR ) )"];case 3003:return["LogLuv","( value )"];default:throw Error("unsupported encoding: "+a);}}function Bh(a,b,c){var d=a.getShaderParameter(b,35713),e=a.getShaderInfoLog(b).trim();
if(d&&""===e)return"";a=a.getShaderSource(b).split("\n");for(b=0;b<a.length;b++)a[b]=b+1+": "+a[b];a=a.join("\n");return"THREE.WebGLShader: gl.getShaderInfoLog() "+c+"\n"+e+a}function Ge(a,b){b=Ah(b);return"vec4 "+a+"( vec4 value ) { return "+b[0]+"ToLinear"+b[1]+"; }"}function Oj(a,b){b=Ah(b);return"vec4 "+a+"( vec4 value ) { return LinearTo"+b[0]+b[1]+"; }"}function Pj(a,b){switch(b){case 1:b="Linear";break;case 2:b="Reinhard";break;case 3:b="Uncharted2";break;case 4:b="OptimizedCineon";break;case 5:b=
"ACESFilmic";break;default:throw Error("unsupported toneMapping: "+b);}return"vec3 "+a+"( vec3 color ) { return "+b+"ToneMapping( color ); }"}function Qj(a,b,c){a=a||{};return[a.derivatives||b.envMapCubeUV||b.bumpMap||b.tangentSpaceNormalMap||b.clearcoatNormalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&c.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&c.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":
"",(a.shaderTextureLOD||b.envMap)&&c.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(Hd).join("\n")}function Rj(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function Hd(a){return""!==a}function Ch(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_RECT_AREA_LIGHTS/g,b.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,
b.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,b.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS/g,b.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,b.numPointLightShadows)}function Dh(a,b){return a.replace(/NUM_CLIPPING_PLANES/g,b.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,b.numClippingPlanes-b.numClipIntersection)}function Zf(a,b){a=N[b];if(void 0===a)throw Error("Can not resolve #include <"+b+">");return a.replace($f,Zf)}function Eh(a,b,c,d){a="";for(b=parseInt(b);b<parseInt(c);b++)a+=
d.replace(/\[ i \]/g,"[ "+b+" ]").replace(/UNROLLED_LOOP_INDEX/g,b);return a}function Fh(a){var b="precision "+a.precision+" float;\nprecision "+a.precision+" int;";"highp"===a.precision?b+="\n#define HIGH_PRECISION":"mediump"===a.precision?b+="\n#define MEDIUM_PRECISION":"lowp"===a.precision&&(b+="\n#define LOW_PRECISION");return b}function Sj(a){var b="SHADOWMAP_TYPE_BASIC";1===a.shadowMapType?b="SHADOWMAP_TYPE_PCF":2===a.shadowMapType?b="SHADOWMAP_TYPE_PCF_SOFT":3===a.shadowMapType&&(b="SHADOWMAP_TYPE_VSM");
return b}function Tj(a,b){var c="ENVMAP_TYPE_CUBE";if(a.envMap)switch(b.envMap.mapping){case 301:case 302:c="ENVMAP_TYPE_CUBE";break;case 306:case 307:c="ENVMAP_TYPE_CUBE_UV";break;case 303:case 304:c="ENVMAP_TYPE_EQUIREC";break;case 305:c="ENVMAP_TYPE_SPHERE"}return c}function Uj(a,b){var c="ENVMAP_MODE_REFLECTION";if(a.envMap)switch(b.envMap.mapping){case 302:case 304:c="ENVMAP_MODE_REFRACTION"}return c}function Vj(a,b){var c="ENVMAP_BLENDING_MULTIPLY";if(a.envMap)switch(b.combine){case 0:c="ENVMAP_BLENDING_MULTIPLY";
break;case 1:c="ENVMAP_BLENDING_MIX";break;case 2:c="ENVMAP_BLENDING_ADD"}return c}function Wj(a,b,c,d,e,f){var g=a.getContext(),h=d.defines,l=e.vertexShader,m=e.fragmentShader,q=Sj(f),u=Tj(f,d),k=Uj(f,d),r=Vj(f,d),p=0<a.gammaFactor?a.gammaFactor:1,v=f.isWebGL2?"":Qj(d.extensions,f,b),x=Rj(h),n=g.createProgram(),y=(h=a.getRenderTarget())&&h.isWebGLMultiviewRenderTarget?h.numViews:0;d.isRawShaderMaterial?(h=[x].filter(Hd).join("\n"),0<h.length&&(h+="\n"),b=[v,x].filter(Hd).join("\n"),0<b.length&&(b+=
"\n")):(h=[Fh(f),"#define SHADER_NAME "+e.name,x,f.instancing?"#define USE_INSTANCING":"",f.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+p,"#define MAX_BONES "+f.maxBones,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp2?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.envMap?"#define USE_ENVMAP":"",f.envMap?"#define "+k:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":
"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.normalMap&&f.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",f.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",f.displacementMap&&f.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",f.specularMap?"#define USE_SPECULARMAP":"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.vertexTangents?
"#define USE_TANGENT":"",f.vertexColors?"#define USE_COLOR":"",f.vertexUvs?"#define USE_UV":"",f.flatShading?"#define FLAT_SHADED":"",f.skinning?"#define USE_SKINNING":"",f.useVertexTexture?"#define BONE_TEXTURE":"",f.morphTargets?"#define USE_MORPHTARGETS":"",f.morphNormals&&!1===f.flatShading?"#define USE_MORPHNORMALS":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+q:"",f.sizeAttenuation?
"#define USE_SIZEATTENUATION":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(f.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;",
"#ifdef USE_TANGENT","\tattribute vec4 tangent;","#endif","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;",
"\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(Hd).join("\n"),b=[v,Fh(f),"#define SHADER_NAME "+e.name,x,f.alphaTest?"#define ALPHATEST "+f.alphaTest+(f.alphaTest%1?"":".0"):"","#define GAMMA_FACTOR "+p,f.useFog&&f.fog?"#define USE_FOG":"",f.useFog&&f.fogExp2?"#define FOG_EXP2":"",f.map?"#define USE_MAP":"",f.matcap?"#define USE_MATCAP":"",f.envMap?"#define USE_ENVMAP":
"",f.envMap?"#define "+u:"",f.envMap?"#define "+k:"",f.envMap?"#define "+r:"",f.lightMap?"#define USE_LIGHTMAP":"",f.aoMap?"#define USE_AOMAP":"",f.emissiveMap?"#define USE_EMISSIVEMAP":"",f.bumpMap?"#define USE_BUMPMAP":"",f.normalMap?"#define USE_NORMALMAP":"",f.normalMap&&f.objectSpaceNormalMap?"#define OBJECTSPACE_NORMALMAP":"",f.normalMap&&f.tangentSpaceNormalMap?"#define TANGENTSPACE_NORMALMAP":"",f.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",f.specularMap?"#define USE_SPECULARMAP":
"",f.roughnessMap?"#define USE_ROUGHNESSMAP":"",f.metalnessMap?"#define USE_METALNESSMAP":"",f.alphaMap?"#define USE_ALPHAMAP":"",f.sheen?"#define USE_SHEEN":"",f.vertexTangents?"#define USE_TANGENT":"",f.vertexColors?"#define USE_COLOR":"",f.vertexUvs?"#define USE_UV":"",f.gradientMap?"#define USE_GRADIENTMAP":"",f.flatShading?"#define FLAT_SHADED":"",f.doubleSided?"#define DOUBLE_SIDED":"",f.flipSided?"#define FLIP_SIDED":"",f.shadowMapEnabled?"#define USE_SHADOWMAP":"",f.shadowMapEnabled?"#define "+
q:"",f.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",f.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",f.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",f.logarithmicDepthBuffer&&(f.isWebGL2||b.get("EXT_frag_depth"))?"#define USE_LOGDEPTHBUF_EXT":"",(d.extensions&&d.extensions.shaderTextureLOD||f.envMap)&&(f.isWebGL2||b.get("EXT_shader_texture_lod"))?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",0!==f.toneMapping?"#define TONE_MAPPING":
"",0!==f.toneMapping?N.tonemapping_pars_fragment:"",0!==f.toneMapping?Pj("toneMapping",f.toneMapping):"",f.dithering?"#define DITHERING":"",f.outputEncoding||f.mapEncoding||f.matcapEncoding||f.envMapEncoding||f.emissiveMapEncoding?N.encodings_pars_fragment:"",f.mapEncoding?Ge("mapTexelToLinear",f.mapEncoding):"",f.matcapEncoding?Ge("matcapTexelToLinear",f.matcapEncoding):"",f.envMapEncoding?Ge("envMapTexelToLinear",f.envMapEncoding):"",f.emissiveMapEncoding?Ge("emissiveMapTexelToLinear",f.emissiveMapEncoding):
"",f.outputEncoding?Oj("linearToOutputTexel",f.outputEncoding):"",f.depthPacking?"#define DEPTH_PACKING "+d.depthPacking:"","\n"].filter(Hd).join("\n"));l=l.replace($f,Zf);l=Ch(l,f);l=Dh(l,f);m=m.replace($f,Zf);m=Ch(m,f);m=Dh(m,f);l=l.replace(Gh,Eh);m=m.replace(Gh,Eh);f.isWebGL2&&!d.isRawShaderMaterial&&(q=!1,u=/^\s*#version\s+300\s+es\s*\n/,d.isShaderMaterial&&null!==l.match(u)&&null!==m.match(u)&&(q=!0,l=l.replace(u,""),m=m.replace(u,"")),h="#version 300 es\n\n#define attribute in\n#define varying out\n#define texture2D texture\n"+
h,b=["#version 300 es\n\n#define varying in",q?"":"out highp vec4 pc_fragColor;",q?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth\n#define texture2D texture\n#define textureCube texture\n#define texture2DProj textureProj\n#define texture2DLodEXT textureLod\n#define texture2DProjLodEXT textureProjLod\n#define textureCubeLodEXT textureLod\n#define texture2DGradEXT textureGrad\n#define texture2DProjGradEXT textureProjGrad\n#define textureCubeGradEXT textureGrad"].join("\n")+
"\n"+b,0<y&&(h=h.replace("#version 300 es\n",["#version 300 es\n\n#extension GL_OVR_multiview2 : require","layout(num_views = "+y+") in;","#define VIEW_ID gl_ViewID_OVR"].join("\n")),h=h.replace("uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat4 viewMatrix;\nuniform mat3 normalMatrix;",["uniform mat4 modelViewMatrices["+y+"];","uniform mat4 projectionMatrices["+y+"];","uniform mat4 viewMatrices["+y+"];","uniform mat3 normalMatrices["+y+"];","#define modelViewMatrix modelViewMatrices[VIEW_ID]\n#define projectionMatrix projectionMatrices[VIEW_ID]\n#define viewMatrix viewMatrices[VIEW_ID]\n#define normalMatrix normalMatrices[VIEW_ID]"].join("\n")),
b=b.replace("#version 300 es\n","#version 300 es\n\n#extension GL_OVR_multiview2 : require\n#define VIEW_ID gl_ViewID_OVR"),b=b.replace("uniform mat4 viewMatrix;",["uniform mat4 viewMatrices["+y+"];","#define viewMatrix viewMatrices[VIEW_ID]"].join("\n"))));m=b+m;l=zh(g,35633,h+l);m=zh(g,35632,m);g.attachShader(n,l);g.attachShader(n,m);void 0!==d.index0AttributeName?g.bindAttribLocation(n,0,d.index0AttributeName):!0===f.morphTargets&&g.bindAttribLocation(n,0,"position");g.linkProgram(n);if(a.debug.checkShaderErrors){a=
g.getProgramInfoLog(n).trim();f=g.getShaderInfoLog(l).trim();q=g.getShaderInfoLog(m).trim();k=u=!0;if(!1===g.getProgramParameter(n,35714))u=!1,r=Bh(g,l,"vertex"),p=Bh(g,m,"fragment"),console.error("THREE.WebGLProgram: shader error: ",g.getError(),"35715",g.getProgramParameter(n,35715),"gl.getProgramInfoLog",a,r,p);else if(""!==a)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",a);else if(""===f||""===q)k=!1;k&&(this.diagnostics={runnable:u,material:d,programLog:a,vertexShader:{log:f,prefix:h},
fragmentShader:{log:q,prefix:b}})}g.deleteShader(l);g.deleteShader(m);var V;this.getUniforms=function(){void 0===V&&(V=new Bb(g,n));return V};var P;this.getAttributes=function(){if(void 0===P){for(var a={},b=g.getProgramParameter(n,35721),c=0;c<b;c++){var d=g.getActiveAttrib(n,c).name;a[d]=g.getAttribLocation(n,d)}P=a}return P};this.destroy=function(){g.deleteProgram(n);this.program=void 0};this.name=e.name;this.id=Xj++;this.code=c;this.usedTimes=1;this.program=n;this.vertexShader=l;this.fragmentShader=
m;this.numMultiviewViews=y;return this}function Yj(a,b,c){function d(a,b){if(a)a.isTexture?c=a.encoding:a.isWebGLRenderTarget&&(console.warn("THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead."),c=a.texture.encoding);else var c=3E3;3E3===c&&b&&(c=3007);return c}var e=[],f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distanceRGBA",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",
MeshToonMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"},g="precision supportsVertexTextures instancing map mapEncoding matcap matcapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap objectSpaceNormalMap tangentSpaceNormalMap clearcoatNormalMap displacementMap specularMap roughnessMap metalnessMap gradientMap alphaMap combine vertexColors vertexTangents fog useFog fogExp2 flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights numRectAreaLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes numClipIntersection depthPacking dithering sheen".split(" ");
this.getParameters=function(b,e,g,q,u,k,r){var h=f[b.type];if(r.isSkinnedMesh){var l=r.skeleton.bones;if(c.floatVertexTextures)l=1024;else{var m=Math.min(Math.floor((c.maxVertexUniforms-20)/4),l.length);m<l.length?(console.warn("THREE.WebGLRenderer: Skeleton has "+l.length+" bones. This GPU supports "+m+"."),l=0):l=m}}else l=0;m=c.precision;null!==b.precision&&(m=c.getMaxPrecision(b.precision),m!==b.precision&&console.warn("THREE.WebGLProgram.getParameters:",b.precision,"not supported, using",m,"instead."));
var t=a.getRenderTarget();return{isWebGL2:c.isWebGL2,shaderID:h,precision:m,instancing:!0===r.isInstancedMesh,supportsVertexTextures:c.vertexTextures,outputEncoding:d(t?t.texture:null,a.gammaOutput),map:!!b.map,mapEncoding:d(b.map,a.gammaInput),matcap:!!b.matcap,matcapEncoding:d(b.matcap,a.gammaInput),envMap:!!b.envMap,envMapMode:b.envMap&&b.envMap.mapping,envMapEncoding:d(b.envMap,a.gammaInput),envMapCubeUV:!!b.envMap&&(306===b.envMap.mapping||307===b.envMap.mapping),lightMap:!!b.lightMap,aoMap:!!b.aoMap,
emissiveMap:!!b.emissiveMap,emissiveMapEncoding:d(b.emissiveMap,a.gammaInput),bumpMap:!!b.bumpMap,normalMap:!!b.normalMap,objectSpaceNormalMap:1===b.normalMapType,tangentSpaceNormalMap:0===b.normalMapType,clearcoatNormalMap:!!b.clearcoatNormalMap,displacementMap:!!b.displacementMap,roughnessMap:!!b.roughnessMap,metalnessMap:!!b.metalnessMap,specularMap:!!b.specularMap,alphaMap:!!b.alphaMap,gradientMap:!!b.gradientMap,sheen:!!b.sheen,combine:b.combine,vertexTangents:b.normalMap&&b.vertexTangents,vertexColors:b.vertexColors,
vertexUvs:!!b.map||!!b.bumpMap||!!b.normalMap||!!b.specularMap||!!b.alphaMap||!!b.emissiveMap||!!b.roughnessMap||!!b.metalnessMap||!!b.clearcoatNormalMap,fog:!!q,useFog:b.fog,fogExp2:q&&q.isFogExp2,flatShading:b.flatShading,sizeAttenuation:b.sizeAttenuation,logarithmicDepthBuffer:c.logarithmicDepthBuffer,skinning:b.skinning&&0<l,maxBones:l,useVertexTexture:c.floatVertexTextures,morphTargets:b.morphTargets,morphNormals:b.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,
numDirLights:e.directional.length,numPointLights:e.point.length,numSpotLights:e.spot.length,numRectAreaLights:e.rectArea.length,numHemiLights:e.hemi.length,numDirLightShadows:e.directionalShadowMap.length,numPointLightShadows:e.pointShadowMap.length,numSpotLightShadows:e.spotShadowMap.length,numClippingPlanes:u,numClipIntersection:k,dithering:b.dithering,shadowMapEnabled:a.shadowMap.enabled&&0<g.length,shadowMapType:a.shadowMap.type,toneMapping:b.toneMapped?a.toneMapping:0,physicallyCorrectLights:a.physicallyCorrectLights,
premultipliedAlpha:b.premultipliedAlpha,alphaTest:b.alphaTest,doubleSided:2===b.side,flipSided:1===b.side,depthPacking:void 0!==b.depthPacking?b.depthPacking:!1}};this.getProgramCode=function(b,c){var d=[];c.shaderID?d.push(c.shaderID):(d.push(b.fragmentShader),d.push(b.vertexShader));if(void 0!==b.defines)for(var e in b.defines)d.push(e),d.push(b.defines[e]);for(e=0;e<g.length;e++)d.push(c[g[e]]);d.push(b.onBeforeCompile.toString());d.push(a.gammaOutput);d.push(a.gammaFactor);return d.join()};this.acquireProgram=
function(c,d,f,g){for(var h,l=0,m=e.length;l<m;l++){var q=e[l];if(q.code===g){h=q;++h.usedTimes;break}}void 0===h&&(h=new Wj(a,b,g,c,d,f),e.push(h));return h};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=e.indexOf(a);e[b]=e[e.length-1];e.pop();a.destroy()}};this.programs=e}function Zj(){var a=new WeakMap;return{get:function(b){var c=a.get(b);void 0===c&&(c={},a.set(b,c));return c},remove:function(b){a.delete(b)},update:function(b,c,d){a.get(b)[c]=d},dispose:function(){a=new WeakMap}}}
function ak(a,b){return a.groupOrder!==b.groupOrder?a.groupOrder-b.groupOrder:a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.program!==b.program?a.program.id-b.program.id:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function bk(a,b){return a.groupOrder!==b.groupOrder?a.groupOrder-b.groupOrder:a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function Hh(){function a(a,d,e,m,q,u){var g=b[c];void 0===g?(g={id:a.id,
object:a,geometry:d,material:e,program:e.program||f,groupOrder:m,renderOrder:a.renderOrder,z:q,group:u},b[c]=g):(g.id=a.id,g.object=a,g.geometry=d,g.material=e,g.program=e.program||f,g.groupOrder=m,g.renderOrder=a.renderOrder,g.z=q,g.group=u);c++;return g}var b=[],c=0,d=[],e=[],f={id:-1};return{opaque:d,transparent:e,init:function(){c=0;d.length=0;e.length=0},push:function(b,c,f,m,q,u){b=a(b,c,f,m,q,u);(!0===f.transparent?e:d).push(b)},unshift:function(b,c,f,m,q,u){b=a(b,c,f,m,q,u);(!0===f.transparent?
e:d).unshift(b)},sort:function(){1<d.length&&d.sort(ak);1<e.length&&e.sort(bk)}}}function ck(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){var e=b.get(c);if(void 0===e){var f=new Hh;b.set(c,new WeakMap);b.get(c).set(d,f);c.addEventListener("dispose",a)}else f=e.get(d),void 0===f&&(f=new Hh,e.set(d,f));return f},dispose:function(){b=new WeakMap}}}function dk(){var a={};return{get:function(b){if(void 0!==a[b.id])return a[b.id];switch(b.type){case "DirectionalLight":var c=
{direction:new n,color:new H,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new w};break;case "SpotLight":c={position:new n,direction:new n,color:new H,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new w};break;case "PointLight":c={position:new n,color:new H,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new w,shadowCameraNear:1,shadowCameraFar:1E3};break;case "HemisphereLight":c={direction:new n,skyColor:new H,groundColor:new H};
break;case "RectAreaLight":c={color:new H,position:new n,halfWidth:new n,halfHeight:new n}}return a[b.id]=c}}}function ek(a,b){return(b.castShadow?1:0)-(a.castShadow?1:0)}function fk(){for(var a=new dk,b={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],
rectArea:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1},c=0;9>c;c++)b.probe.push(new n);var d=new n,e=new U,f=new U;return{setup:function(c,h,l){for(var g=0,q=0,u=0,k=0;9>k;k++)b.probe[k].set(0,0,0);var r=h=0,p=0,v=0,n=0,z=0,y=0,V=0;l=l.matrixWorldInverse;c.sort(ek);k=0;for(var P=c.length;k<P;k++){var C=c[k],Cb=C.color,w=C.intensity,A=C.distance,wa=C.shadow&&C.shadow.map?C.shadow.map.texture:null;if(C.isAmbientLight)g+=Cb.r*
w,q+=Cb.g*w,u+=Cb.b*w;else if(C.isLightProbe)for(wa=0;9>wa;wa++)b.probe[wa].addScaledVector(C.sh.coefficients[wa],w);else if(C.isDirectionalLight){var G=a.get(C);G.color.copy(C.color).multiplyScalar(C.intensity);G.direction.setFromMatrixPosition(C.matrixWorld);d.setFromMatrixPosition(C.target.matrixWorld);G.direction.sub(d);G.direction.transformDirection(l);if(G.shadow=C.castShadow)w=C.shadow,G.shadowBias=w.bias,G.shadowRadius=w.radius,G.shadowMapSize=w.mapSize,b.directionalShadowMap[h]=wa,b.directionalShadowMatrix[h]=
C.shadow.matrix,z++;b.directional[h]=G;h++}else if(C.isSpotLight){G=a.get(C);G.position.setFromMatrixPosition(C.matrixWorld);G.position.applyMatrix4(l);G.color.copy(Cb).multiplyScalar(w);G.distance=A;G.direction.setFromMatrixPosition(C.matrixWorld);d.setFromMatrixPosition(C.target.matrixWorld);G.direction.sub(d);G.direction.transformDirection(l);G.coneCos=Math.cos(C.angle);G.penumbraCos=Math.cos(C.angle*(1-C.penumbra));G.decay=C.decay;if(G.shadow=C.castShadow)w=C.shadow,G.shadowBias=w.bias,G.shadowRadius=
w.radius,G.shadowMapSize=w.mapSize,b.spotShadowMap[p]=wa,b.spotShadowMatrix[p]=C.shadow.matrix,V++;b.spot[p]=G;p++}else if(C.isRectAreaLight)G=a.get(C),G.color.copy(Cb).multiplyScalar(w),G.position.setFromMatrixPosition(C.matrixWorld),G.position.applyMatrix4(l),f.identity(),e.copy(C.matrixWorld),e.premultiply(l),f.extractRotation(e),G.halfWidth.set(.5*C.width,0,0),G.halfHeight.set(0,.5*C.height,0),G.halfWidth.applyMatrix4(f),G.halfHeight.applyMatrix4(f),b.rectArea[v]=G,v++;else if(C.isPointLight){G=
a.get(C);G.position.setFromMatrixPosition(C.matrixWorld);G.position.applyMatrix4(l);G.color.copy(C.color).multiplyScalar(C.intensity);G.distance=C.distance;G.decay=C.decay;if(G.shadow=C.castShadow)w=C.shadow,G.shadowBias=w.bias,G.shadowRadius=w.radius,G.shadowMapSize=w.mapSize,G.shadowCameraNear=w.camera.near,G.shadowCameraFar=w.camera.far,b.pointShadowMap[r]=wa,b.pointShadowMatrix[r]=C.shadow.matrix,y++;b.point[r]=G;r++}else C.isHemisphereLight&&(G=a.get(C),G.direction.setFromMatrixPosition(C.matrixWorld),
G.direction.transformDirection(l),G.direction.normalize(),G.skyColor.copy(C.color).multiplyScalar(w),G.groundColor.copy(C.groundColor).multiplyScalar(w),b.hemi[n]=G,n++)}b.ambient[0]=g;b.ambient[1]=q;b.ambient[2]=u;c=b.hash;if(c.directionalLength!==h||c.pointLength!==r||c.spotLength!==p||c.rectAreaLength!==v||c.hemiLength!==n||c.numDirectionalShadows!==z||c.numPointShadows!==y||c.numSpotShadows!==V)b.directional.length=h,b.spot.length=p,b.rectArea.length=v,b.point.length=r,b.hemi.length=n,b.directionalShadowMap.length=
z,b.pointShadowMap.length=y,b.spotShadowMap.length=V,b.directionalShadowMatrix.length=z,b.pointShadowMatrix.length=y,b.spotShadowMatrix.length=V,c.directionalLength=h,c.pointLength=r,c.spotLength=p,c.rectAreaLength=v,c.hemiLength=n,c.numDirectionalShadows=z,c.numPointShadows=y,c.numSpotShadows=V,b.version=gk++},state:b}}function Ih(){var a=new fk,b=[],c=[];return{init:function(){b.length=0;c.length=0},state:{lightsArray:b,shadowsArray:c,lights:a},setupLights:function(d){a.setup(b,c,d)},pushLight:function(a){b.push(a)},
pushShadow:function(a){c.push(a)}}}function hk(){function a(c){c=c.target;c.removeEventListener("dispose",a);b.delete(c)}var b=new WeakMap;return{get:function(c,d){if(!1===b.has(c)){var e=new Ih;b.set(c,new WeakMap);b.get(c).set(d,e);c.addEventListener("dispose",a)}else!1===b.get(c).has(d)?(e=new Ih,b.get(c).set(d,e)):e=b.get(c).get(d);return e},dispose:function(){b=new WeakMap}}}function Db(a){M.call(this);this.type="MeshDepthMaterial";this.depthPacking=3200;this.morphTargets=this.skinning=!1;this.displacementMap=
this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.fog=!1;this.setValues(a)}function Eb(a){M.call(this);this.type="MeshDistanceMaterial";this.referencePosition=new n;this.nearDistance=1;this.farDistance=1E3;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.fog=!1;this.setValues(a)}function Jh(a,b,c){function d(b,c,d,e,f,g){var h=b.geometry;
var l=m;var p=b.customDepthMaterial;d.isPointLight&&(l=q,p=b.customDistanceMaterial);p?l=p:(p=!1,c.morphTargets&&(h&&h.isBufferGeometry?p=h.morphAttributes&&h.morphAttributes.position&&0<h.morphAttributes.position.length:h&&h.isGeometry&&(p=h.morphTargets&&0<h.morphTargets.length)),b.isSkinnedMesh&&!1===c.skinning&&console.warn("THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:",b),b=b.isSkinnedMesh&&c.skinning,h=0,p&&(h|=1),b&&(h|=2),l=l[h]);a.localClippingEnabled&&!0===
c.clipShadows&&0!==c.clippingPlanes.length&&(h=l.uuid,p=c.uuid,b=u[h],void 0===b&&(b={},u[h]=b),h=b[p],void 0===h&&(h=l.clone(),b[p]=h),l=h);l.visible=c.visible;l.wireframe=c.wireframe;l.side=3===g?null!=c.shadowSide?c.shadowSide:c.side:null!=c.shadowSide?c.shadowSide:k[c.side];l.clipShadows=c.clipShadows;l.clippingPlanes=c.clippingPlanes;l.clipIntersection=c.clipIntersection;l.wireframeLinewidth=c.wireframeLinewidth;l.linewidth=c.linewidth;d.isPointLight&&l.isMeshDistanceMaterial&&(l.referencePosition.setFromMatrixPosition(d.matrixWorld),
l.nearDistance=e,l.farDistance=f);return l}function e(c,g,h,l,m){if(!1!==c.visible){if(c.layers.test(g.layers)&&(c.isMesh||c.isLine||c.isPoints)&&(c.castShadow||c.receiveShadow&&3===m)&&(!c.frustumCulled||f.intersectsObject(c))){c.modelViewMatrix.multiplyMatrices(h.matrixWorldInverse,c.matrixWorld);var q=b.update(c),u=c.material;if(Array.isArray(u))for(var k=q.groups,p=0,t=k.length;p<t;p++){var r=k[p],v=u[r.materialIndex];v&&v.visible&&(v=d(c,v,l,h.near,h.far,m),a.renderBufferDirect(h,null,q,v,c,
r))}else u.visible&&(v=d(c,u,l,h.near,h.far,m),a.renderBufferDirect(h,null,q,v,c,null))}c=c.children;q=0;for(u=c.length;q<u;q++)e(c[q],g,h,l,m)}}var f=new Ed,g=new w,h=new w,l=new aa,m=Array(4),q=Array(4),u={},k={0:1,1:0,2:2},r=new ma({defines:{SAMPLE_RATE:.25,HALF_SAMPLE_RATE:.125},uniforms:{shadow_pass:{value:null},resolution:{value:new w},radius:{value:4}},vertexShader:"void main() {\n\tgl_Position = vec4( position, 1.0 );\n}",fragmentShader:"uniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n#include <packing>\nvoid main() {\n  float mean = 0.0;\n  float squared_mean = 0.0;\n  \n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy  ) / resolution ) );\n  for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n    #ifdef HORIZONAL_PASS\n      vec2 distribution = decodeHalfRGBA ( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n      mean += distribution.x;\n      squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n    #else\n      float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0,  i )  * radius ) / resolution ) );\n      mean += depth;\n      squared_mean += depth * depth;\n    #endif\n  }\n  mean = mean * HALF_SAMPLE_RATE;\n  squared_mean = squared_mean * HALF_SAMPLE_RATE;\n  float std_dev = pow( squared_mean - mean * mean, 0.5 );\n  gl_FragColor = encodeHalfRGBA( vec2( mean, std_dev ) );\n}"}),
p=r.clone();p.defines.HORIZONAL_PASS=1;var v=new E;v.addAttribute("position",new O(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));var n=new ja(v,r);for(v=0;4!==v;++v){var z=0!==(v&1),y=0!==(v&2),V=new Db({depthPacking:3201,morphTargets:z,skinning:y});m[v]=V;z=new Eb({morphTargets:z,skinning:y});q[v]=z}var P=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=1;this.render=function(d,m,q){if(!1!==P.enabled&&(!1!==P.autoUpdate||!1!==P.needsUpdate)&&0!==d.length){var u=a.getRenderTarget(),
k=a.getActiveCubeFace(),t=a.getActiveMipmapLevel(),v=a.state;v.setBlending(0);v.buffers.color.setClear(1,1,1,1);v.buffers.depth.setTest(!0);v.setScissorTest(!1);for(var x=0,y=d.length;x<y;x++){var z=d[x],T=z.shadow;if(void 0===T)console.warn("THREE.WebGLShadowMap:",z,"has no shadow.");else{g.copy(T.mapSize);var X=T.getFrameExtents();g.multiply(X);h.copy(T.mapSize);if(g.x>c||g.y>c)console.warn("THREE.WebGLShadowMap:",z,"has shadow exceeding max texture size, reducing"),g.x>c&&(h.x=Math.floor(c/X.x),
g.x=h.x*X.x,T.mapSize.x=h.x),g.y>c&&(h.y=Math.floor(c/X.y),g.y=h.y*X.y,T.mapSize.y=h.y);null!==T.map||T.isPointLightShadow||3!==this.type||(X={minFilter:1006,magFilter:1006,format:1023},T.map=new la(g.x,g.y,X),T.map.texture.name=z.name+".shadowMap",T.mapPass=new la(g.x,g.y,X),T.camera.updateProjectionMatrix());null===T.map&&(X={minFilter:1003,magFilter:1003,format:1023},T.map=new la(g.x,g.y,X),T.map.texture.name=z.name+".shadowMap",T.camera.updateProjectionMatrix());a.setRenderTarget(T.map);a.clear();
X=T.getViewportCount();for(var V=0;V<X;V++){var C=T.getViewport(V);l.set(h.x*C.x,h.y*C.y,h.x*C.z,h.y*C.w);v.viewport(l);T.updateMatrices(z,q,V);f=T.getFrustum();e(m,q,T.camera,z,this.type)}T.isPointLightShadow||3!==this.type||(z=T,T=q,X=b.update(n),r.uniforms.shadow_pass.value=z.map.texture,r.uniforms.resolution.value=z.mapSize,r.uniforms.radius.value=z.radius,a.setRenderTarget(z.mapPass),a.clear(),a.renderBufferDirect(T,null,X,r,n,null),p.uniforms.shadow_pass.value=z.mapPass.texture,p.uniforms.resolution.value=
z.mapSize,p.uniforms.radius.value=z.radius,a.setRenderTarget(z.map),a.clear(),a.renderBufferDirect(T,null,X,p,n,null))}}P.needsUpdate=!1;a.setRenderTarget(u,k,t)}}}function ik(a,b,c,d){function e(b,c,d){var e=new Uint8Array(4),f=a.createTexture();a.bindTexture(b,f);a.texParameteri(b,10241,9728);a.texParameteri(b,10240,9728);for(b=0;b<d;b++)a.texImage2D(c+b,0,6408,1,1,0,6408,5121,e);return f}function f(c,e){z[c]=1;0===y[c]&&(a.enableVertexAttribArray(c),y[c]=1);V[c]!==e&&((d.isWebGL2?a:b.get("ANGLE_instanced_arrays"))[d.isWebGL2?
"vertexAttribDivisor":"vertexAttribDivisorANGLE"](c,e),V[c]=e)}function g(b){!0!==P[b]&&(a.enable(b),P[b]=!0)}function h(b){!1!==P[b]&&(a.disable(b),P[b]=!1)}function l(b,d,e,f,l,m,q,u){if(0===b)A&&(h(3042),A=!1);else if(A||(g(3042),A=!0),5!==b){if(b!==B||u!==T){if(100!==wa||100!==E)a.blendEquation(32774),E=wa=100;if(u)switch(b){case 1:a.blendFuncSeparate(1,771,1,771);break;case 2:a.blendFunc(1,1);break;case 3:a.blendFuncSeparate(0,0,769,771);break;case 4:a.blendFuncSeparate(0,768,0,770);break;default:console.error("THREE.WebGLState: Invalid blending: ",
b)}else switch(b){case 1:a.blendFuncSeparate(770,771,1,771);break;case 2:a.blendFunc(770,1);break;case 3:a.blendFunc(0,769);break;case 4:a.blendFunc(0,768);break;default:console.error("THREE.WebGLState: Invalid blending: ",b)}H=I=ag=G=null;B=b;T=u}}else{l=l||d;m=m||e;q=q||f;if(d!==wa||l!==E)a.blendEquationSeparate(c.convert(d),c.convert(l)),wa=d,E=l;if(e!==G||f!==ag||m!==I||q!==H)a.blendFuncSeparate(c.convert(e),c.convert(f),c.convert(m),c.convert(q)),G=e,ag=f,I=m,H=q;B=b;T=null}}function m(b){X!==
b&&(b?a.frontFace(2304):a.frontFace(2305),X=b)}function q(b){0!==b?(g(2884),b!==bg&&(1===b?a.cullFace(1029):2===b?a.cullFace(1028):a.cullFace(1032))):h(2884);bg=b}function u(b,c,d){if(b){if(g(32823),ha!==c||bc!==d)a.polygonOffset(c,d),ha=c,bc=d}else h(32823)}function k(b){void 0===b&&(b=33984+D-1);Pa!==b&&(a.activeTexture(b),Pa=b)}var r=new function(){var b=!1,c=new aa,d=null,e=new aa(0,0,0,0);return{setMask:function(c){d===c||b||(a.colorMask(c,c,c,c),d=c)},setLocked:function(a){b=a},setClear:function(b,
d,f,g,h){!0===h&&(b*=g,d*=g,f*=g);c.set(b,d,f,g);!1===e.equals(c)&&(a.clearColor(b,d,f,g),e.copy(c))},reset:function(){b=!1;d=null;e.set(-1,0,0,0)}}},p=new function(){var b=!1,c=null,d=null,e=null;return{setTest:function(a){a?g(2929):h(2929)},setMask:function(d){c===d||b||(a.depthMask(d),c=d)},setFunc:function(b){if(d!==b){if(b)switch(b){case 0:a.depthFunc(512);break;case 1:a.depthFunc(519);break;case 2:a.depthFunc(513);break;case 3:a.depthFunc(515);break;case 4:a.depthFunc(514);break;case 5:a.depthFunc(518);
break;case 6:a.depthFunc(516);break;case 7:a.depthFunc(517);break;default:a.depthFunc(515)}else a.depthFunc(515);d=b}},setLocked:function(a){b=a},setClear:function(b){e!==b&&(a.clearDepth(b),e=b)},reset:function(){b=!1;e=d=c=null}}},v=new function(){var b=!1,c=null,d=null,e=null,f=null,l=null,m=null,q=null,u=null;return{setTest:function(a){b||(a?g(2960):h(2960))},setMask:function(d){c===d||b||(a.stencilMask(d),c=d)},setFunc:function(b,c,g){if(d!==b||e!==c||f!==g)a.stencilFunc(b,c,g),d=b,e=c,f=g},
setOp:function(b,c,d){if(l!==b||m!==c||q!==d)a.stencilOp(b,c,d),l=b,m=c,q=d},setLocked:function(a){b=a},setClear:function(b){u!==b&&(a.clearStencil(b),u=b)},reset:function(){b=!1;u=q=m=l=f=e=d=c=null}}},n=a.getParameter(34921),z=new Uint8Array(n),y=new Uint8Array(n),V=new Uint8Array(n),P={},C=null,w=null,A=null,B=null,wa=null,G=null,ag=null,E=null,I=null,H=null,T=!1,X=null,bg=null,ac=null,ha=null,bc=null,D=a.getParameter(35661),dg=!1;n=0;n=a.getParameter(7938);-1!==n.indexOf("WebGL")?(n=parseFloat(/^WebGL ([0-9])/.exec(n)[1]),
dg=1<=n):-1!==n.indexOf("OpenGL ES")&&(n=parseFloat(/^OpenGL ES ([0-9])/.exec(n)[1]),dg=2<=n);var Pa=null,eg={},F=new aa,O=new aa,K={};K[3553]=e(3553,3553,1);K[34067]=e(34067,34069,6);r.setClear(0,0,0,1);p.setClear(1);v.setClear(0);g(2929);p.setFunc(3);m(!1);q(1);g(2884);l(0);return{buffers:{color:r,depth:p,stencil:v},initAttributes:function(){for(var a=0,b=z.length;a<b;a++)z[a]=0},enableAttribute:function(a){f(a,0)},enableAttributeAndDivisor:f,disableUnusedAttributes:function(){for(var b=0,c=y.length;b!==
c;++b)y[b]!==z[b]&&(a.disableVertexAttribArray(b),y[b]=0)},enable:g,disable:h,getCompressedTextureFormats:function(){if(null===C&&(C=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")||b.get("WEBGL_compressed_texture_astc")))for(var c=a.getParameter(34467),d=0;d<c.length;d++)C.push(c[d]);return C},useProgram:function(b){return w!==b?(a.useProgram(b),w=b,!0):!1},setBlending:l,setMaterial:function(a,b){2===a.side?h(2884):g(2884);
var c=1===a.side;b&&(c=!c);m(c);1===a.blending&&!1===a.transparent?l(0):l(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,a.premultipliedAlpha);p.setFunc(a.depthFunc);p.setTest(a.depthTest);p.setMask(a.depthWrite);r.setMask(a.colorWrite);b=a.stencilWrite;v.setTest(b);b&&(v.setMask(a.stencilWriteMask),v.setFunc(a.stencilFunc,a.stencilRef,a.stencilFuncMask),v.setOp(a.stencilFail,a.stencilZFail,a.stencilZPass));u(a.polygonOffset,a.polygonOffsetFactor,
a.polygonOffsetUnits)},setFlipSided:m,setCullFace:q,setLineWidth:function(b){b!==ac&&(dg&&a.lineWidth(b),ac=b)},setPolygonOffset:u,setScissorTest:function(a){a?g(3089):h(3089)},activeTexture:k,bindTexture:function(b,c){null===Pa&&k();var d=eg[Pa];void 0===d&&(d={type:void 0,texture:void 0},eg[Pa]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c||K[b]),d.type=b,d.texture=c},compressedTexImage2D:function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}},
texImage2D:function(){try{a.texImage2D.apply(a,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}},texImage3D:function(){try{a.texImage3D.apply(a,arguments)}catch(Z){console.error("THREE.WebGLState:",Z)}},scissor:function(b){!1===F.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),F.copy(b))},viewport:function(b){!1===O.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),O.copy(b))},reset:function(){for(var b=0;b<y.length;b++)1===y[b]&&(a.disableVertexAttribArray(b),y[b]=0);P={};Pa=C=null;eg={};bg=X=B=w=null;r.reset();
p.reset();v.reset()}}}function jk(a,b,c,d,e,f,g){function h(a,b){return E?new OffscreenCanvas(a,b):document.createElementNS("http://www.w3.org/1999/xhtml","canvas")}function l(a,b,c,d){var e=1;if(a.width>d||a.height>d)e=d/Math.max(a.width,a.height);if(1>e||!0===b){if("undefined"!==typeof HTMLImageElement&&a instanceof HTMLImageElement||"undefined"!==typeof HTMLCanvasElement&&a instanceof HTMLCanvasElement||"undefined"!==typeof ImageBitmap&&a instanceof ImageBitmap)return d=b?L.floorPowerOfTwo:Math.floor,
b=d(e*a.width),e=d(e*a.height),void 0===G&&(G=h(b,e)),c=c?h(b,e):G,c.width=b,c.height=e,c.getContext("2d").drawImage(a,0,0,b,e),console.warn("THREE.WebGLRenderer: Texture has been resized from ("+a.width+"x"+a.height+") to ("+b+"x"+e+")."),c;"data"in a&&console.warn("THREE.WebGLRenderer: Image in DataTexture is too big ("+a.width+"x"+a.height+").")}return a}function m(a){return L.isPowerOfTwo(a.width)&&L.isPowerOfTwo(a.height)}function q(a,b){return a.generateMipmaps&&b&&1003!==a.minFilter&&1006!==
a.minFilter}function u(b,c,e,f){a.generateMipmap(b);d.get(c).__maxMipLevel=Math.log(Math.max(e,f))*Math.LOG2E}function k(a,c){if(!e.isWebGL2)return a;var d=a;6403===a&&(5126===c&&(d=33326),5131===c&&(d=33325),5121===c&&(d=33321));6407===a&&(5126===c&&(d=34837),5131===c&&(d=34843),5121===c&&(d=32849));6408===a&&(5126===c&&(d=34836),5131===c&&(d=34842),5121===c&&(d=32856));33325===d||33326===d||34842===d||34836===d?b.get("EXT_color_buffer_float"):(34843===d||34837===d)&&console.warn("THREE.WebGLRenderer: Floating point textures with RGB format not supported. Please use RGBA instead.");
return d}function r(a){return 1003===a||1004===a||1005===a?9728:9729}function p(b){b=b.target;b.removeEventListener("dispose",p);var c=d.get(b);void 0!==c.__webglInit&&(a.deleteTexture(c.__webglTexture),d.remove(b));b.isVideoTexture&&wa.delete(b);g.memory.textures--}function v(b){b=b.target;b.removeEventListener("dispose",v);var c=d.get(b),e=d.get(b.texture);if(b){void 0!==e.__webglTexture&&a.deleteTexture(e.__webglTexture);b.depthTexture&&b.depthTexture.dispose();if(b.isWebGLRenderTargetCube)for(e=
0;6>e;e++)a.deleteFramebuffer(c.__webglFramebuffer[e]),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer[e]);else a.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&a.deleteRenderbuffer(c.__webglDepthbuffer);if(b.isWebGLMultiviewRenderTarget){a.deleteTexture(c.__webglColorTexture);a.deleteTexture(c.__webglDepthStencilTexture);g.memory.textures-=2;e=0;for(var f=c.__webglViewFramebuffers.length;e<f;e++)a.deleteFramebuffer(c.__webglViewFramebuffers[e])}d.remove(b.texture);
d.remove(b)}g.memory.textures--}function n(a,b){var e=d.get(a);if(a.isVideoTexture){var f=g.render.frame;wa.get(a)!==f&&(wa.set(a,f),a.update())}if(0<a.version&&e.__version!==a.version)if(f=a.image,void 0===f)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined");else if(!1===f.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete");else{C(e,a,b);return}c.activeTexture(33984+b);c.bindTexture(3553,e.__webglTexture)}function z(b,
g){if(6===b.image.length){var h=d.get(b);if(0<b.version&&h.__version!==b.version){P(h,b);c.activeTexture(33984+g);c.bindTexture(34067,h.__webglTexture);a.pixelStorei(37440,b.flipY);var p=b&&b.isCompressedTexture;g=b.image[0]&&b.image[0].isDataTexture;for(var t=[],r=0;6>r;r++)t[r]=p||g?g?b.image[r].image:b.image[r]:l(b.image[r],!1,!0,e.maxCubemapSize);var v=t[0],n=m(v)||e.isWebGL2,x=f.convert(b.format),y=f.convert(b.type),z=k(x,y);V(34067,b,n);if(p){for(r=0;6>r;r++){var T=t[r].mipmaps;for(p=0;p<T.length;p++){var X=
T[p];1023!==b.format&&1022!==b.format?-1<c.getCompressedTextureFormats().indexOf(x)?c.compressedTexImage2D(34069+r,p,z,X.width,X.height,0,X.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):c.texImage2D(34069+r,p,z,X.width,X.height,0,x,y,X.data)}}h.__maxMipLevel=T.length-1}else{T=b.mipmaps;for(r=0;6>r;r++)if(g)for(c.texImage2D(34069+r,0,z,t[r].width,t[r].height,0,x,y,t[r].data),p=0;p<T.length;p++)X=T[p],X=X.image[r].image,c.texImage2D(34069+
r,p+1,z,X.width,X.height,0,x,y,X.data);else for(c.texImage2D(34069+r,0,z,x,y,t[r]),p=0;p<T.length;p++)X=T[p],c.texImage2D(34069+r,p+1,z,x,y,X.image[r]);h.__maxMipLevel=T.length}q(b,n)&&u(34067,b,v.width,v.height);h.__version=b.version;if(b.onUpdate)b.onUpdate(b)}else c.activeTexture(33984+g),c.bindTexture(34067,h.__webglTexture)}}function y(a,b){c.activeTexture(33984+b);c.bindTexture(34067,d.get(a).__webglTexture)}function V(c,g,h){h?(a.texParameteri(c,10242,f.convert(g.wrapS)),a.texParameteri(c,
10243,f.convert(g.wrapT)),32879!==c&&35866!==c||a.texParameteri(c,32882,f.convert(g.wrapR)),a.texParameteri(c,10240,f.convert(g.magFilter)),a.texParameteri(c,10241,f.convert(g.minFilter))):(a.texParameteri(c,10242,33071),a.texParameteri(c,10243,33071),32879!==c&&35866!==c||a.texParameteri(c,32882,33071),1001===g.wrapS&&1001===g.wrapT||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping."),a.texParameteri(c,10240,
r(g.magFilter)),a.texParameteri(c,10241,r(g.minFilter)),1003!==g.minFilter&&1006!==g.minFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter."));!(h=b.get("EXT_texture_filter_anisotropic"))||1015===g.type&&null===b.get("OES_texture_float_linear")||1016===g.type&&null===(e.isWebGL2||b.get("OES_texture_half_float_linear"))||!(1<g.anisotropy||d.get(g).__currentAnisotropy)||(a.texParameterf(c,h.TEXTURE_MAX_ANISOTROPY_EXT,
Math.min(g.anisotropy,e.getMaxAnisotropy())),d.get(g).__currentAnisotropy=g.anisotropy)}function P(b,c){void 0===b.__webglInit&&(b.__webglInit=!0,c.addEventListener("dispose",p),b.__webglTexture=a.createTexture(),g.memory.textures++)}function C(b,d,g){var h=3553;d.isDataTexture2DArray&&(h=35866);d.isDataTexture3D&&(h=32879);P(b,d);c.activeTexture(33984+g);c.bindTexture(h,b.__webglTexture);a.pixelStorei(37440,d.flipY);a.pixelStorei(37441,d.premultiplyAlpha);a.pixelStorei(3317,d.unpackAlignment);g=
e.isWebGL2?!1:1001!==d.wrapS||1001!==d.wrapT||1003!==d.minFilter&&1006!==d.minFilter;g=g&&!1===m(d.image);g=l(d.image,g,!1,e.maxTextureSize);var p=m(g)||e.isWebGL2,t=f.convert(d.format),r=f.convert(d.type),v=k(t,r);V(h,d,p);var n=d.mipmaps;if(d.isDepthTexture){v=6402;if(1015===d.type){if(!e.isWebGL2)throw Error("Float Depth Texture only supported in WebGL2.0");v=36012}else e.isWebGL2&&(v=33189);1026===d.format&&6402===v&&1012!==d.type&&1014!==d.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture."),
d.type=1012,r=f.convert(d.type));1027===d.format&&(v=34041,1020!==d.type&&(console.warn("THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture."),d.type=1020,r=f.convert(d.type)));c.texImage2D(3553,0,v,g.width,g.height,0,t,r,null)}else if(d.isDataTexture)if(0<n.length&&p){for(var x=0,y=n.length;x<y;x++)h=n[x],c.texImage2D(3553,x,v,h.width,h.height,0,t,r,h.data);d.generateMipmaps=!1;b.__maxMipLevel=n.length-1}else c.texImage2D(3553,0,v,g.width,g.height,0,t,r,g.data),b.__maxMipLevel=
0;else if(d.isCompressedTexture){x=0;for(y=n.length;x<y;x++)h=n[x],1023!==d.format&&1022!==d.format?-1<c.getCompressedTextureFormats().indexOf(t)?c.compressedTexImage2D(3553,x,v,h.width,h.height,0,h.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):c.texImage2D(3553,x,v,h.width,h.height,0,t,r,h.data);b.__maxMipLevel=n.length-1}else if(d.isDataTexture2DArray)c.texImage3D(35866,0,v,g.width,g.height,g.depth,0,t,r,g.data),b.__maxMipLevel=
0;else if(d.isDataTexture3D)c.texImage3D(32879,0,v,g.width,g.height,g.depth,0,t,r,g.data),b.__maxMipLevel=0;else if(0<n.length&&p){x=0;for(y=n.length;x<y;x++)h=n[x],c.texImage2D(3553,x,v,t,r,h);d.generateMipmaps=!1;b.__maxMipLevel=n.length-1}else c.texImage2D(3553,0,v,t,r,g),b.__maxMipLevel=0;q(d,p)&&u(3553,d,g.width,g.height);b.__version=d.version;if(d.onUpdate)d.onUpdate(d)}function w(b,e,g,h){var l=f.convert(e.texture.format),m=f.convert(e.texture.type),q=k(l,m);c.texImage2D(h,0,q,e.width,e.height,
0,l,m,null);a.bindFramebuffer(36160,b);a.framebufferTexture2D(36160,g,h,d.get(e.texture).__webglTexture,0);a.bindFramebuffer(36160,null)}function A(b,c,d){a.bindRenderbuffer(36161,b);if(c.depthBuffer&&!c.stencilBuffer)d?(d=B(c),a.renderbufferStorageMultisample(36161,d,33189,c.width,c.height)):a.renderbufferStorage(36161,33189,c.width,c.height),a.framebufferRenderbuffer(36160,36096,36161,b);else if(c.depthBuffer&&c.stencilBuffer)d?(d=B(c),a.renderbufferStorageMultisample(36161,d,35056,c.width,c.height)):
a.renderbufferStorage(36161,34041,c.width,c.height),a.framebufferRenderbuffer(36160,33306,36161,b);else{b=f.convert(c.texture.format);var e=f.convert(c.texture.type);b=k(b,e);d?(d=B(c),a.renderbufferStorageMultisample(36161,d,b,c.width,c.height)):a.renderbufferStorage(36161,b,c.width,c.height)}a.bindRenderbuffer(36161,null)}function B(a){return e.isWebGL2&&a.isWebGLMultisampleRenderTarget?Math.min(e.maxSamples,a.samples):0}var wa=new WeakMap,G,E="undefined"!==typeof OffscreenCanvas&&null!==(new OffscreenCanvas(1,
1)).getContext("2d"),I=0,H=!1,D=!1;this.allocateTextureUnit=function(){var a=I;a>=e.maxTextures&&console.warn("THREE.WebGLTextures: Trying to use "+a+" texture units while this GPU supports only "+e.maxTextures);I+=1;return a};this.resetTextureUnits=function(){I=0};this.setTexture2D=n;this.setTexture2DArray=function(a,b){var e=d.get(a);0<a.version&&e.__version!==a.version?C(e,a,b):(c.activeTexture(33984+b),c.bindTexture(35866,e.__webglTexture))};this.setTexture3D=function(a,b){var e=d.get(a);0<a.version&&
e.__version!==a.version?C(e,a,b):(c.activeTexture(33984+b),c.bindTexture(32879,e.__webglTexture))};this.setTextureCube=z;this.setTextureCubeDynamic=y;this.setupRenderTarget=function(h){var l=d.get(h),p=d.get(h.texture);h.addEventListener("dispose",v);p.__webglTexture=a.createTexture();g.memory.textures++;var t=!0===h.isWebGLRenderTargetCube,r=!0===h.isWebGLMultisampleRenderTarget,x=!0===h.isWebGLMultiviewRenderTarget,y=m(h)||e.isWebGL2;if(t){l.__webglFramebuffer=[];for(var z=0;6>z;z++)l.__webglFramebuffer[z]=
a.createFramebuffer()}else if(l.__webglFramebuffer=a.createFramebuffer(),r)if(e.isWebGL2){l.__webglMultisampledFramebuffer=a.createFramebuffer();l.__webglColorRenderbuffer=a.createRenderbuffer();a.bindRenderbuffer(36161,l.__webglColorRenderbuffer);r=f.convert(h.texture.format);var C=f.convert(h.texture.type);r=k(r,C);C=B(h);a.renderbufferStorageMultisample(36161,C,r,h.width,h.height);a.bindFramebuffer(36160,l.__webglMultisampledFramebuffer);a.framebufferRenderbuffer(36160,36064,36161,l.__webglColorRenderbuffer);
a.bindRenderbuffer(36161,null);h.depthBuffer&&(l.__webglDepthRenderbuffer=a.createRenderbuffer(),A(l.__webglDepthRenderbuffer,h,!0));a.bindFramebuffer(36160,null)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.");else if(x){z=h.width;var P=h.height;r=h.numViews;a.bindFramebuffer(36160,l.__webglFramebuffer);var G=b.get("OVR_multiview2");g.memory.textures+=2;C=a.createTexture();a.bindTexture(35866,C);a.texParameteri(35866,10240,9728);a.texParameteri(35866,
10241,9728);a.texImage3D(35866,0,32856,z,P,r,0,6408,5121,null);G.framebufferTextureMultiviewOVR(36160,36064,C,0,0,r);var wa=a.createTexture();a.bindTexture(35866,wa);a.texParameteri(35866,10240,9728);a.texParameteri(35866,10241,9728);a.texImage3D(35866,0,35056,z,P,r,0,34041,34042,null);G.framebufferTextureMultiviewOVR(36160,33306,wa,0,0,r);P=Array(r);for(z=0;z<r;++z)P[z]=a.createFramebuffer(),a.bindFramebuffer(36160,P[z]),a.framebufferTextureLayer(36160,36064,C,0,z);l.__webglColorTexture=C;l.__webglDepthStencilTexture=
wa;l.__webglViewFramebuffers=P;a.bindFramebuffer(36160,null);a.bindTexture(35866,null)}if(t){c.bindTexture(34067,p.__webglTexture);V(34067,h.texture,y);for(z=0;6>z;z++)w(l.__webglFramebuffer[z],h,36064,34069+z);q(h.texture,y)&&u(34067,h.texture,h.width,h.height);c.bindTexture(34067,null)}else x||(c.bindTexture(3553,p.__webglTexture),V(3553,h.texture,y),w(l.__webglFramebuffer,h,36064,3553),q(h.texture,y)&&u(3553,h.texture,h.width,h.height),c.bindTexture(3553,null));if(h.depthBuffer){l=d.get(h);p=!0===
h.isWebGLRenderTargetCube;if(h.depthTexture){if(p)throw Error("target.depthTexture not supported in Cube render targets");if(h&&h.isWebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported");a.bindFramebuffer(36160,l.__webglFramebuffer);if(!h.depthTexture||!h.depthTexture.isDepthTexture)throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");d.get(h.depthTexture).__webglTexture&&h.depthTexture.image.width===h.width&&h.depthTexture.image.height===
h.height||(h.depthTexture.image.width=h.width,h.depthTexture.image.height=h.height,h.depthTexture.needsUpdate=!0);n(h.depthTexture,0);l=d.get(h.depthTexture).__webglTexture;if(1026===h.depthTexture.format)a.framebufferTexture2D(36160,36096,3553,l,0);else if(1027===h.depthTexture.format)a.framebufferTexture2D(36160,33306,3553,l,0);else throw Error("Unknown depthTexture format");}else if(p)for(l.__webglDepthbuffer=[],p=0;6>p;p++)a.bindFramebuffer(36160,l.__webglFramebuffer[p]),l.__webglDepthbuffer[p]=
a.createRenderbuffer(),A(l.__webglDepthbuffer[p],h);else a.bindFramebuffer(36160,l.__webglFramebuffer),l.__webglDepthbuffer=a.createRenderbuffer(),A(l.__webglDepthbuffer,h);a.bindFramebuffer(36160,null)}};this.updateRenderTargetMipmap=function(a){var b=a.texture,f=m(a)||e.isWebGL2;if(q(b,f)){f=a.isWebGLRenderTargetCube?34067:3553;var g=d.get(b).__webglTexture;c.bindTexture(f,g);u(f,b,a.width,a.height);c.bindTexture(f,null)}};this.updateMultisampleRenderTarget=function(b){if(b.isWebGLMultisampleRenderTarget)if(e.isWebGL2){var c=
d.get(b);a.bindFramebuffer(36008,c.__webglMultisampledFramebuffer);a.bindFramebuffer(36009,c.__webglFramebuffer);c=b.width;var f=b.height,g=16384;b.depthBuffer&&(g|=256);b.stencilBuffer&&(g|=1024);a.blitFramebuffer(0,0,c,f,0,0,c,f,g,9728)}else console.warn("THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.")};this.safeSetTexture2D=function(a,b){a&&a.isWebGLRenderTarget&&(!1===H&&(console.warn("THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead."),
H=!0),a=a.texture);n(a,b)};this.safeSetTextureCube=function(a,b){a&&a.isWebGLRenderTargetCube&&(!1===D&&(console.warn("THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead."),D=!0),a=a.texture);a&&a.isCubeTexture||Array.isArray(a.image)&&6===a.image.length?z(a,b):y(a,b)}}function Kh(a,b,c){return{convert:function(a){if(1E3===a)return 10497;if(1001===a)return 33071;if(1002===a)return 33648;if(1003===a)return 9728;if(1004===a)return 9984;
if(1005===a)return 9986;if(1006===a)return 9729;if(1007===a)return 9985;if(1008===a)return 9987;if(1009===a)return 5121;if(1017===a)return 32819;if(1018===a)return 32820;if(1019===a)return 33635;if(1010===a)return 5120;if(1011===a)return 5122;if(1012===a)return 5123;if(1013===a)return 5124;if(1014===a)return 5125;if(1015===a)return 5126;if(1016===a){if(c.isWebGL2)return 5131;var d=b.get("OES_texture_half_float");if(null!==d)return d.HALF_FLOAT_OES}if(1021===a)return 6406;if(1022===a)return 6407;if(1023===
a)return 6408;if(1024===a)return 6409;if(1025===a)return 6410;if(1026===a)return 6402;if(1027===a)return 34041;if(1028===a)return 6403;if(100===a)return 32774;if(101===a)return 32778;if(102===a)return 32779;if(200===a)return 0;if(201===a)return 1;if(202===a)return 768;if(203===a)return 769;if(204===a)return 770;if(205===a)return 771;if(206===a)return 772;if(207===a)return 773;if(208===a)return 774;if(209===a)return 775;if(210===a)return 776;if(33776===a||33777===a||33778===a||33779===a)if(d=b.get("WEBGL_compressed_texture_s3tc"),
null!==d){if(33776===a)return d.COMPRESSED_RGB_S3TC_DXT1_EXT;if(33777===a)return d.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(33778===a)return d.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(33779===a)return d.COMPRESSED_RGBA_S3TC_DXT5_EXT}if(35840===a||35841===a||35842===a||35843===a)if(d=b.get("WEBGL_compressed_texture_pvrtc"),null!==d){if(35840===a)return d.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(35841===a)return d.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(35842===a)return d.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(35843===a)return d.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}if(36196===
a&&(d=b.get("WEBGL_compressed_texture_etc1"),null!==d))return d.COMPRESSED_RGB_ETC1_WEBGL;if(37808===a||37809===a||37810===a||37811===a||37812===a||37813===a||37814===a||37815===a||37816===a||37817===a||37818===a||37819===a||37820===a||37821===a)if(d=b.get("WEBGL_compressed_texture_astc"),null!==d)return a;if(103===a||104===a){if(c.isWebGL2){if(103===a)return 32775;if(104===a)return 32776}d=b.get("EXT_blend_minmax");if(null!==d){if(103===a)return d.MIN_EXT;if(104===a)return d.MAX_EXT}}if(1020===a){if(c.isWebGL2)return 34042;
d=b.get("WEBGL_depth_texture");if(null!==d)return d.UNSIGNED_INT_24_8_WEBGL}return 0}}}function fg(a,b,c,d){la.call(this,a,b,d);this.stencilBuffer=this.depthBuffer=!1;this.numViews=c}function kk(a,b){function c(a){if(a.isArrayCamera)return a.cameras;q[0]=a;return q}function d(a){if(void 0===a.isArrayCamera)return!0;a=a.cameras;if(a.length>r)return!1;for(var b=1,c=a.length;b<c;b++)if(a[0].viewport.z!==a[b].viewport.z||a[0].viewport.w!==a[b].viewport.w)return!1;return!0}var e=a.extensions,f=a.properties,
g,h,l,m,q,u,k,r=0;this.isAvailable=function(){if(void 0===k){var a=e.get("OVR_multiview2");if(k=null!==a&&!1===b.getContextAttributes().antialias)for(r=b.getParameter(a.MAX_VIEWS_OVR),g=new fg(0,0,2),u=new w,m=[],l=[],q=[],a=0;a<r;a++)m[a]=new U,l[a]=new Y}return k};this.attachCamera=function(b){if(!1!==d(b)){(h=a.getRenderTarget())?u.set(h.width,h.height):a.getDrawingBufferSize(u);if(b.isArrayCamera){var c=b.cameras[0].viewport;g.setSize(c.z,c.w);g.setNumViews(b.cameras.length)}else g.setSize(u.x,
u.y),g.setNumViews(2);a.setRenderTarget(g)}};this.detachCamera=function(c){if(g===a.getRenderTarget()){a.setRenderTarget(h);var d=g,e=d.numViews,l=f.get(d).__webglViewFramebuffers,m=d.width;d=d.height;if(c.isArrayCamera)for(var q=0;q<e;q++){var k=c.cameras[q].viewport,p=k.x,r=k.y,t=p+k.z;k=r+k.w;b.bindFramebuffer(36008,l[q]);b.blitFramebuffer(0,0,m,d,p,r,t,k,16384,9728)}else b.bindFramebuffer(36008,l[0]),b.blitFramebuffer(0,0,m,d,0,0,u.x,u.y,16384,9728)}};this.updateCameraProjectionMatricesUniform=
function(a,d){a=c(a);for(var e=0;e<a.length;e++)m[e].copy(a[e].projectionMatrix);d.setValue(b,"projectionMatrices",m)};this.updateCameraViewMatricesUniform=function(a,d){a=c(a);for(var e=0;e<a.length;e++)m[e].copy(a[e].matrixWorldInverse);d.setValue(b,"viewMatrices",m)};this.updateObjectMatricesUniforms=function(a,d,e){d=c(d);for(var f=0;f<d.length;f++)m[f].multiplyMatrices(d[f].matrixWorldInverse,a.matrixWorld),l[f].getNormalMatrix(m[f]);e.setValue(b,"modelViewMatrices",m);e.setValue(b,"normalMatrices",
l)}}function Hc(){B.call(this);this.type="Group"}function Jd(a){na.call(this);this.cameras=a||[]}function Lh(a,b,c){Mh.setFromMatrixPosition(b.matrixWorld);Nh.setFromMatrixPosition(c.matrixWorld);var d=Mh.distanceTo(Nh),e=b.projectionMatrix.elements,f=c.projectionMatrix.elements,g=e[14]/(e[10]-1);c=e[14]/(e[10]+1);var h=(e[9]+1)/e[5],l=(e[9]-1)/e[5],m=(e[8]-1)/e[0],q=(f[8]+1)/f[0];e=g*m;f=g*q;q=d/(-m+q);m=q*-m;b.matrixWorld.decompose(a.position,a.quaternion,a.scale);a.translateX(m);a.translateZ(q);
a.matrixWorld.compose(a.position,a.quaternion,a.scale);a.matrixWorldInverse.getInverse(a.matrixWorld);b=g+q;g=c+q;a.projectionMatrix.makePerspective(e-m,f+(d-m),h*c/g*b,l*c/g*b,b,g)}function gg(a){function b(){return null!==h&&!0===h.isPresenting}function c(){if(b()){var c=h.getEyeParameters("left");e=2*c.renderWidth*r;f=c.renderHeight*r;Cb=a.getPixelRatio();a.getSize(C);a.setDrawingBufferSize(e,f,1);y.viewport.set(0,0,e/2,f);V.viewport.set(e/2,0,e/2,f);B.start();g.dispatchEvent({type:"sessionstart"})}else g.enabled&&
a.setDrawingBufferSize(C.width,C.height,Cb),B.stop(),g.dispatchEvent({type:"sessionend"})}function d(a,b){null!==b&&4===b.length&&a.set(b[0]*e,b[1]*f,b[2]*e,b[3]*f)}var e,f,g=this,h=null,l=null,m=null,q=[],u=new U,k=new U,r=1,p="local-floor";"undefined"!==typeof window&&"VRFrameData"in window&&(l=new window.VRFrameData,window.addEventListener("vrdisplaypresentchange",c,!1));var v=new U,x=new ua,z=new n,y=new na;y.viewport=new aa;y.layers.enable(1);var V=new na;V.viewport=new aa;V.layers.enable(2);
var P=new Jd([y,V]);P.layers.enable(1);P.layers.enable(2);var C=new w,Cb,A=[];this.enabled=!1;this.getController=function(a){var b=q[a];void 0===b&&(b=new Hc,b.matrixAutoUpdate=!1,b.visible=!1,q[a]=b);return b};this.getDevice=function(){return h};this.setDevice=function(a){void 0!==a&&(h=a);B.setContext(a)};this.setFramebufferScaleFactor=function(a){r=a};this.setReferenceSpaceType=function(a){p=a};this.setPoseTarget=function(a){void 0!==a&&(m=a)};this.getCamera=function(a){var c="local-floor"===p?
1.6:0;if(!1===b())return a.position.set(0,c,0),a.rotation.set(0,0,0),a;h.depthNear=a.near;h.depthFar=a.far;h.getFrameData(l);if("local-floor"===p){var e=h.stageParameters;e?u.fromArray(e.sittingToStandingTransform):u.makeTranslation(0,c,0)}c=l.pose;e=null!==m?m:a;e.matrix.copy(u);e.matrix.decompose(e.position,e.quaternion,e.scale);null!==c.orientation&&(x.fromArray(c.orientation),e.quaternion.multiply(x));null!==c.position&&(x.setFromRotationMatrix(u),z.fromArray(c.position),z.applyQuaternion(x),
e.position.add(z));e.updateMatrixWorld();y.near=a.near;V.near=a.near;y.far=a.far;V.far=a.far;y.matrixWorldInverse.fromArray(l.leftViewMatrix);V.matrixWorldInverse.fromArray(l.rightViewMatrix);k.getInverse(u);"local-floor"===p&&(y.matrixWorldInverse.multiply(k),V.matrixWorldInverse.multiply(k));a=e.parent;null!==a&&(v.getInverse(a.matrixWorld),y.matrixWorldInverse.multiply(v),V.matrixWorldInverse.multiply(v));y.matrixWorld.getInverse(y.matrixWorldInverse);V.matrixWorld.getInverse(V.matrixWorldInverse);
y.projectionMatrix.fromArray(l.leftProjectionMatrix);V.projectionMatrix.fromArray(l.rightProjectionMatrix);Lh(P,y,V);a=h.getLayers();a.length&&(a=a[0],d(y.viewport,a.leftBounds),d(V.viewport,a.rightBounds));a:for(a=0;a<q.length;a++){c=q[a];b:{e=a;for(var f=navigator.getGamepads&&navigator.getGamepads(),g=0,r=0,t=f.length;g<t;g++){var n=f[g];if(n&&("Daydream Controller"===n.id||"Gear VR Controller"===n.id||"Oculus Go Controller"===n.id||"OpenVR Gamepad"===n.id||n.id.startsWith("Oculus Touch")||n.id.startsWith("HTC Vive Focus")||
n.id.startsWith("Spatial Controller"))){if(r===e){e=n;break b}r++}}e=void 0}if(void 0!==e&&void 0!==e.pose){if(null===e.pose)break a;f=e.pose;!1===f.hasPosition&&c.position.set(.2,-.6,-.05);null!==f.position&&c.position.fromArray(f.position);null!==f.orientation&&c.quaternion.fromArray(f.orientation);c.matrix.compose(c.position,c.quaternion,c.scale);c.matrix.premultiply(u);c.matrix.decompose(c.position,c.quaternion,c.scale);c.matrixWorldNeedsUpdate=!0;c.visible=!0;f="Daydream Controller"===e.id?0:
1;void 0===A[a]&&(A[a]=!1);A[a]!==e.buttons[f].pressed&&(A[a]=e.buttons[f].pressed,!0===A[a]?c.dispatchEvent({type:"selectstart"}):(c.dispatchEvent({type:"selectend"}),c.dispatchEvent({type:"select"})))}else c.visible=!1}return P};this.getStandingMatrix=function(){return u};this.isPresenting=b;var B=new Xf;this.setAnimationLoop=function(a){B.setAnimationLoop(a);b()&&B.start()};this.submitFrame=function(){b()&&h.submitFrame()};this.dispose=function(){"undefined"!==typeof window&&window.removeEventListener("vrdisplaypresentchange",
c)};this.setFrameOfReferenceType=function(){console.warn("THREE.WebVRManager: setFrameOfReferenceType() has been deprecated.")}}function Oh(a,b){function c(){return null!==l&&null!==m}function d(a){for(var b=0;b<k.length;b++)r[b]===a.inputSource&&k[b].dispatchEvent({type:a.type})}function e(){a.setFramebuffer(null);a.setRenderTarget(a.getRenderTarget());y.stop();h.dispatchEvent({type:"sessionend"})}function f(a){m=a;y.setContext(l);y.start();h.dispatchEvent({type:"sessionstart"})}function g(a,b){null===
b?a.matrixWorld.copy(a.matrix):a.matrixWorld.multiplyMatrices(b.matrixWorld,a.matrix);a.matrixWorldInverse.getInverse(a.matrixWorld)}var h=this,l=null,m=null,q="local-floor",u=null,k=[],r=[],p=new na;p.layers.enable(1);p.viewport=new aa;var n=new na;n.layers.enable(2);n.viewport=new aa;var x=new Jd([p,n]);x.layers.enable(1);x.layers.enable(2);this.enabled=!1;this.getController=function(a){var b=k[a];void 0===b&&(b=new Hc,b.matrixAutoUpdate=!1,b.visible=!1,k[a]=b);return b};this.setFramebufferScaleFactor=
function(){};this.setReferenceSpaceType=function(a){q=a};this.getSession=function(){return l};this.setSession=function(a){l=a;null!==l&&(l.addEventListener("select",d),l.addEventListener("selectstart",d),l.addEventListener("selectend",d),l.addEventListener("end",e),l.updateRenderState({baseLayer:new XRWebGLLayer(l,b)}),l.requestReferenceSpace(q).then(f),r=l.inputSources,l.addEventListener("inputsourceschange",function(){r=l.inputSources;console.log(r);for(var a=0;a<k.length;a++)k[a].userData.inputSource=
r[a]}))};this.getCamera=function(a){if(c()){var b=a.parent,d=x.cameras;g(x,b);for(var e=0;e<d.length;e++)g(d[e],b);a.matrixWorld.copy(x.matrixWorld);a=a.children;e=0;for(b=a.length;e<b;e++)a[e].updateMatrixWorld(!0);Lh(x,p,n);return x}return a};this.isPresenting=c;var z=null,y=new Xf;y.setAnimationLoop(function(b,c){u=c.getViewerPose(m);if(null!==u){var d=u.views,e=l.renderState.baseLayer;a.setFramebuffer(e.framebuffer);for(var f=0;f<d.length;f++){var g=d[f],h=e.getViewport(g),q=x.cameras[f];q.matrix.fromArray(g.transform.inverse.matrix).getInverse(q.matrix);
q.projectionMatrix.fromArray(g.projectionMatrix);q.viewport.set(h.x,h.y,h.width,h.height);0===f&&x.matrix.copy(q.matrix)}}for(f=0;f<k.length;f++){d=k[f];if(e=r[f])if(e=c.getPose(e.targetRaySpace,m),null!==e){d.matrix.fromArray(e.transform.matrix);d.matrix.decompose(d.position,d.rotation,d.scale);d.visible=!0;continue}d.visible=!1}z&&z(b)});this.setAnimationLoop=function(a){z=a};this.dispose=function(){};this.getStandingMatrix=function(){console.warn("THREE.WebXRManager: getStandingMatrix() is no longer needed.");
return new U};this.getDevice=function(){console.warn("THREE.WebXRManager: getDevice() has been deprecated.")};this.setDevice=function(){console.warn("THREE.WebXRManager: setDevice() has been deprecated.")};this.setFrameOfReferenceType=function(){console.warn("THREE.WebXRManager: setFrameOfReferenceType() has been deprecated.")};this.submitFrame=function(){}}function hg(a){var b;function c(){ra=new aj(J);Ea=new Zi(J,ra,a);!1===Ea.isWebGL2&&(ra.get("WEBGL_depth_texture"),ra.get("OES_texture_float"),
ra.get("OES_texture_half_float"),ra.get("OES_texture_half_float_linear"),ra.get("OES_standard_derivatives"),ra.get("OES_element_index_uint"),ra.get("ANGLE_instanced_arrays"));ra.get("OES_texture_float_linear");la=new Kh(J,ra,Ea);ba=new ik(J,ra,la,Ea);ba.scissor(ca.copy(ja).multiplyScalar(fa).floor());ba.viewport(W.copy(ia).multiplyScalar(fa).floor());ea=new dj(J);Y=new Zj;R=new jk(J,ra,ba,Y,Ea,la,ea);pa=new Wi(J);xa=new bj(J,pa,ea);sa=new gj(J,xa,pa,ea);ya=new fj(J);oa=new Yj(F,ra,Ea);va=new ck;ua=
new hk;ma=new Xi(F,ba,sa,A);Aa=new Yi(J,ra,ea,Ea);Ba=new cj(J,ra,ea,Ea);ea.programs=oa.programs;F.capabilities=Ea;F.extensions=ra;F.properties=Y;F.renderLists=va;F.state=ba;F.info=ea}function d(a){a.preventDefault();console.log("THREE.WebGLRenderer: Context Lost.");O=!0}function e(){console.log("THREE.WebGLRenderer: Context Restored.");O=!1;c()}function f(a){a=a.target;a.removeEventListener("dispose",f);g(a);Y.remove(a)}function g(a){var b=Y.get(a).program;a.program=void 0;void 0!==b&&oa.releaseProgram(b)}
function h(a,b){a.render(function(a){F.renderBufferImmediate(a,b)})}function l(a,b,c,d){if(!1!==a.visible){if(a.layers.test(b.layers))if(a.isGroup)c=a.renderOrder;else if(a.isLOD)!0===a.autoUpdate&&a.update(b);else if(a.isLight)D.pushLight(a),a.castShadow&&D.pushShadow(a);else if(a.isSprite){if(!a.frustumCulled||cg.intersectsSprite(a)){d&&Fb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(Id);var e=sa.update(a),f=a.material;f.visible&&G.push(a,e,f,c,Fb.z,null)}}else if(a.isImmediateRenderObject)d&&
Fb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(Id),G.push(a,null,a.material,c,Fb.z,null);else if(a.isMesh||a.isLine||a.isPoints)if(a.isSkinnedMesh&&a.skeleton.frame!==ea.render.frame&&(a.skeleton.update(),a.skeleton.frame=ea.render.frame),!a.frustumCulled||cg.intersectsObject(a))if(d&&Fb.setFromMatrixPosition(a.matrixWorld).applyMatrix4(Id),e=sa.update(a),f=a.material,Array.isArray(f))for(var g=e.groups,h=0,m=g.length;h<m;h++){var q=g[h],k=f[q.materialIndex];k&&k.visible&&G.push(a,e,k,c,Fb.z,
q)}else f.visible&&G.push(a,e,f,c,Fb.z,null);a=a.children;h=0;for(m=a.length;h<m;h++)l(a[h],b,c,d)}}function m(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,l=g.geometry,m=void 0===d?g.material:d;g=g.group;if(c.isArrayCamera)if(Pa=c,ka.enabled&&ta.isAvailable())q(h,b,c,l,m,g);else for(var k=c.cameras,u=0,p=k.length;u<p;u++){var r=k[u];h.layers.test(r.layers)&&(ba.viewport(W.copy(r.viewport)),D.setupLights(r),q(h,b,r,l,m,g))}else Pa=null,q(h,b,c,l,m,g)}}function q(a,c,d,e,f,g){a.onBeforeRender(F,
c,d,e,f,g);D=ua.get(c,Pa||d);a.modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,a.matrixWorld);a.normalMatrix.getNormalMatrix(a.modelViewMatrix);if(a.isImmediateRenderObject){ba.setMaterial(f);var l=k(d,c.fog,f,a);bc=b=null;S=!1;h(a,l)}else F.renderBufferDirect(d,c.fog,e,f,a,g);a.onAfterRender(F,c,d,e,f,g);D=ua.get(c,Pa||d)}function u(a,b,c){var d=Y.get(a),e=D.state.lights,h=e.state.version;c=oa.getParameters(a,e.state,D.state.shadowsArray,b,Oa.numPlanes,Oa.numIntersection,c);var l=oa.getProgramCode(a,
c),m=d.program,q=!0;if(void 0===m)a.addEventListener("dispose",f);else if(m.code!==l)g(a);else{if(d.lightsStateVersion!==h)d.lightsStateVersion=h;else if(void 0!==c.shaderID)return;q=!1}q&&(c.shaderID?(l=db[c.shaderID],d.shader={name:a.type,uniforms:Yb(l.uniforms),vertexShader:l.vertexShader,fragmentShader:l.fragmentShader}):d.shader={name:a.type,uniforms:a.uniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader},a.onBeforeCompile(d.shader,F),l=oa.getProgramCode(a,c),m=oa.acquireProgram(a,
d.shader,c,l),d.program=m,a.program=m);c=m.getAttributes();if(a.morphTargets)for(l=a.numSupportedMorphTargets=0;l<F.maxMorphTargets;l++)0<=c["morphTarget"+l]&&a.numSupportedMorphTargets++;if(a.morphNormals)for(l=a.numSupportedMorphNormals=0;l<F.maxMorphNormals;l++)0<=c["morphNormal"+l]&&a.numSupportedMorphNormals++;c=d.shader.uniforms;if(!a.isShaderMaterial&&!a.isRawShaderMaterial||!0===a.clipping)d.numClippingPlanes=Oa.numPlanes,d.numIntersection=Oa.numIntersection,c.clippingPlanes=Oa.uniform;d.fog=
b;d.needsLights=a.isMeshLambertMaterial||a.isMeshPhongMaterial||a.isMeshStandardMaterial||a.isShadowMaterial||a.isShaderMaterial&&!0===a.lights;d.lightsStateVersion=h;d.needsLights&&(c.ambientLightColor.value=e.state.ambient,c.lightProbe.value=e.state.probe,c.directionalLights.value=e.state.directional,c.spotLights.value=e.state.spot,c.rectAreaLights.value=e.state.rectArea,c.pointLights.value=e.state.point,c.hemisphereLights.value=e.state.hemi,c.directionalShadowMap.value=e.state.directionalShadowMap,
c.directionalShadowMatrix.value=e.state.directionalShadowMatrix,c.spotShadowMap.value=e.state.spotShadowMap,c.spotShadowMatrix.value=e.state.spotShadowMatrix,c.pointShadowMap.value=e.state.pointShadowMap,c.pointShadowMatrix.value=e.state.pointShadowMatrix);a=d.program.getUniforms();a=Bb.seqWithValue(a.seq,c);d.uniformsList=a}function k(a,b,c,d){R.resetTextureUnits();var e=Y.get(c),f=D.state.lights;He&&(qa||a!==Q)&&Oa.setState(c.clippingPlanes,c.clipIntersection,c.clipShadows,a,e,a===Q&&c.id===ha);
!1===c.needsUpdate&&(void 0===e.program?c.needsUpdate=!0:c.fog&&e.fog!==b?c.needsUpdate=!0:e.needsLights&&e.lightsStateVersion!==f.state.version?c.needsUpdate=!0:void 0===e.numClippingPlanes||e.numClippingPlanes===Oa.numPlanes&&e.numIntersection===Oa.numIntersection||(c.needsUpdate=!0));c.needsUpdate&&(u(c,b,d),c.needsUpdate=!1);var g=!1,h=!1,l=!1;f=e.program;var m=f.getUniforms(),q=e.shader.uniforms;ba.useProgram(f.program)&&(l=h=g=!0);c.id!==ha&&(ha=c.id,h=!0);if(g||Q!==a){0<f.numMultiviewViews?
ta.updateCameraProjectionMatricesUniform(a,m):m.setValue(J,"projectionMatrix",a.projectionMatrix);Ea.logarithmicDepthBuffer&&m.setValue(J,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));Q!==a&&(Q=a,l=h=!0);if(c.isShaderMaterial||c.isMeshPhongMaterial||c.isMeshStandardMaterial||c.envMap)g=m.map.cameraPosition,void 0!==g&&g.setValue(J,Fb.setFromMatrixPosition(a.matrixWorld));if(c.isMeshPhongMaterial||c.isMeshLambertMaterial||c.isMeshBasicMaterial||c.isMeshStandardMaterial||c.isShaderMaterial||c.skinning)0<
f.numMultiviewViews?ta.updateCameraViewMatricesUniform(a,m):m.setValue(J,"viewMatrix",a.matrixWorldInverse)}if(c.skinning&&(m.setOptional(J,d,"bindMatrix"),m.setOptional(J,d,"bindMatrixInverse"),g=d.skeleton)){var k=g.bones;if(Ea.floatVertexTextures){if(void 0===g.boneTexture){k=Math.sqrt(4*k.length);k=L.ceilPowerOfTwo(k);k=Math.max(k,4);var t=new Float32Array(k*k*4);t.set(g.boneMatrices);var n=new Zb(t,k,k,1023,1015);g.boneMatrices=t;g.boneTexture=n;g.boneTextureSize=k}m.setValue(J,"boneTexture",
g.boneTexture,R);m.setValue(J,"boneTextureSize",g.boneTextureSize)}else m.setOptional(J,g,"boneMatrices")}if(h||e.receiveShadow!==d.receiveShadow)e.receiveShadow=d.receiveShadow,m.setValue(J,"receiveShadow",d.receiveShadow);h&&(m.setValue(J,"toneMappingExposure",F.toneMappingExposure),m.setValue(J,"toneMappingWhitePoint",F.toneMappingWhitePoint),e.needsLights&&(h=l,q.ambientLightColor.needsUpdate=h,q.lightProbe.needsUpdate=h,q.directionalLights.needsUpdate=h,q.pointLights.needsUpdate=h,q.spotLights.needsUpdate=
h,q.rectAreaLights.needsUpdate=h,q.hemisphereLights.needsUpdate=h),b&&c.fog&&(q.fogColor.value.copy(b.color),b.isFog?(q.fogNear.value=b.near,q.fogFar.value=b.far):b.isFogExp2&&(q.fogDensity.value=b.density)),c.isMeshBasicMaterial?r(q,c):c.isMeshLambertMaterial?(r(q,c),c.emissiveMap&&(q.emissiveMap.value=c.emissiveMap)):c.isMeshPhongMaterial?(r(q,c),c.isMeshToonMaterial?(p(q,c),c.gradientMap&&(q.gradientMap.value=c.gradientMap)):p(q,c)):c.isMeshStandardMaterial?(r(q,c),c.isMeshPhysicalMaterial?(v(q,
c),q.reflectivity.value=c.reflectivity,q.clearcoat.value=c.clearcoat,q.clearcoatRoughness.value=c.clearcoatRoughness,c.sheen&&q.sheen.value.copy(c.sheen),c.clearcoatNormalMap&&(q.clearcoatNormalScale.value.copy(c.clearcoatNormalScale),q.clearcoatNormalMap.value=c.clearcoatNormalMap,1===c.side&&q.clearcoatNormalScale.value.negate()),q.transparency.value=c.transparency):v(q,c)):c.isMeshMatcapMaterial?(r(q,c),c.matcap&&(q.matcap.value=c.matcap),c.bumpMap&&(q.bumpMap.value=c.bumpMap,q.bumpScale.value=
c.bumpScale,1===c.side&&(q.bumpScale.value*=-1)),c.normalMap&&(q.normalMap.value=c.normalMap,q.normalScale.value.copy(c.normalScale),1===c.side&&q.normalScale.value.negate()),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isMeshDepthMaterial?(r(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):
c.isMeshDistanceMaterial?(r(q,c),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias),q.referencePosition.value.copy(c.referencePosition),q.nearDistance.value=c.nearDistance,q.farDistance.value=c.farDistance):c.isMeshNormalMaterial?(r(q,c),c.bumpMap&&(q.bumpMap.value=c.bumpMap,q.bumpScale.value=c.bumpScale,1===c.side&&(q.bumpScale.value*=-1)),c.normalMap&&(q.normalMap.value=c.normalMap,q.normalScale.value.copy(c.normalScale),
1===c.side&&q.normalScale.value.negate()),c.displacementMap&&(q.displacementMap.value=c.displacementMap,q.displacementScale.value=c.displacementScale,q.displacementBias.value=c.displacementBias)):c.isLineBasicMaterial?(q.diffuse.value.copy(c.color),q.opacity.value=c.opacity,c.isLineDashedMaterial&&(q.dashSize.value=c.dashSize,q.totalSize.value=c.dashSize+c.gapSize,q.scale.value=c.scale)):c.isPointsMaterial?(q.diffuse.value.copy(c.color),q.opacity.value=c.opacity,q.size.value=c.size*fa,q.scale.value=
.5*Z,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isSpriteMaterial?(q.diffuse.value.copy(c.color),q.opacity.value=c.opacity,q.rotation.value=c.rotation,q.map.value=c.map,null!==c.map&&(!0===c.map.matrixAutoUpdate&&c.map.updateMatrix(),q.uvTransform.value.copy(c.map.matrix))):c.isShadowMaterial&&(q.color.value.copy(c.color),q.opacity.value=c.opacity),void 0!==q.ltc_1&&(q.ltc_1.value=I.LTC_1),void 0!==q.ltc_2&&(q.ltc_2.value=
I.LTC_2),Bb.upload(J,e.uniformsList,q,R));c.isShaderMaterial&&!0===c.uniformsNeedUpdate&&(Bb.upload(J,e.uniformsList,q,R),c.uniformsNeedUpdate=!1);c.isSpriteMaterial&&m.setValue(J,"center",d.center);0<f.numMultiviewViews?ta.updateObjectMatricesUniforms(d,a,m):(m.setValue(J,"modelViewMatrix",d.modelViewMatrix),m.setValue(J,"normalMatrix",d.normalMatrix));m.setValue(J,"modelMatrix",d.matrixWorld);return f}function r(a,b){a.opacity.value=b.opacity;b.color&&a.diffuse.value.copy(b.color);b.emissive&&a.emissive.value.copy(b.emissive).multiplyScalar(b.emissiveIntensity);
b.map&&(a.map.value=b.map);b.alphaMap&&(a.alphaMap.value=b.alphaMap);b.specularMap&&(a.specularMap.value=b.specularMap);b.envMap&&(a.envMap.value=b.envMap,a.flipEnvMap.value=b.envMap.isCubeTexture?-1:1,a.reflectivity.value=b.reflectivity,a.refractionRatio.value=b.refractionRatio,a.maxMipLevel.value=Y.get(b.envMap).__maxMipLevel);b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.aoMap&&(a.aoMap.value=b.aoMap,a.aoMapIntensity.value=b.aoMapIntensity);if(b.map)var c=
b.map;else b.specularMap?c=b.specularMap:b.displacementMap?c=b.displacementMap:b.normalMap?c=b.normalMap:b.bumpMap?c=b.bumpMap:b.roughnessMap?c=b.roughnessMap:b.metalnessMap?c=b.metalnessMap:b.alphaMap?c=b.alphaMap:b.emissiveMap&&(c=b.emissiveMap);void 0!==c&&(c.isWebGLRenderTarget&&(c=c.texture),!0===c.matrixAutoUpdate&&c.updateMatrix(),a.uvTransform.value.copy(c.matrix))}function p(a,b){a.specular.value.copy(b.specular);a.shininess.value=Math.max(b.shininess,1E-4);b.emissiveMap&&(a.emissiveMap.value=
b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias)}function v(a,b){a.roughness.value=b.roughness;a.metalness.value=b.metalness;b.roughnessMap&&(a.roughnessMap.value=
b.roughnessMap);b.metalnessMap&&(a.metalnessMap.value=b.metalnessMap);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale,1===b.side&&(a.bumpScale.value*=-1));b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale),1===b.side&&a.normalScale.value.negate());b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);
b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}a=a||{};var x=void 0!==a.canvas?a.canvas:document.createElementNS("http://www.w3.org/1999/xhtml","canvas"),z=void 0!==a.context?a.context:null,y=void 0!==a.alpha?a.alpha:!1,V=void 0!==a.depth?a.depth:!0,P=void 0!==a.stencil?a.stencil:!0,C=void 0!==a.antialias?a.antialias:!1,A=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,B=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,E=void 0!==a.powerPreference?a.powerPreference:"default",
H=void 0!==a.failIfMajorPerformanceCaveat?a.failIfMajorPerformanceCaveat:!1,G=null,D=null;this.domElement=x;this.debug={checkShaderErrors:!0};this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=!1;this.toneMappingWhitePoint=this.toneMappingExposure=this.toneMapping=1;this.maxMorphTargets=8;this.maxMorphNormals=4;var F=this,
O=!1,M=null,T=0,X=0,N=null,ac=null,ha=-1;var bc=b=null;var S=!1;var Q=null,Pa=null,W=new aa,ca=new aa,da=null,K=x.width,Z=x.height,fa=1,ia=new aa(0,0,K,Z),ja=new aa(0,0,K,Z),na=!1,cg=new Ed,Oa=new $i,He=!1,qa=!1,Id=new U,Fb=new n;try{y={alpha:y,depth:V,stencil:P,antialias:C,premultipliedAlpha:A,preserveDrawingBuffer:B,powerPreference:E,failIfMajorPerformanceCaveat:H,xrCompatible:!0};x.addEventListener("webglcontextlost",d,!1);x.addEventListener("webglcontextrestored",e,!1);var J=z||x.getContext("webgl",
y)||x.getContext("experimental-webgl",y);if(null===J){if(null!==x.getContext("webgl"))throw Error("Error creating WebGL context with your selected attributes.");throw Error("Error creating WebGL context.");}void 0===J.getShaderPrecisionFormat&&(J.getShaderPrecisionFormat=function(){return{rangeMin:1,rangeMax:1,precision:1}})}catch(Ph){throw console.error("THREE.WebGLRenderer: "+Ph.message),Ph;}var ra,Ea,ba,ea,Y,R,pa,xa,sa,oa,va,ua,ma,ya,Aa,Ba,la;c();var ka="undefined"!==typeof navigator&&"xr"in navigator&&
"supportsSession"in navigator.xr?new Oh(F,J):new gg(F);this.vr=ka;var ta=new kk(F,J),Da=new Jh(F,sa,Ea.maxTextureSize);this.shadowMap=Da;this.getContext=function(){return J};this.getContextAttributes=function(){return J.getContextAttributes()};this.forceContextLoss=function(){var a=ra.get("WEBGL_lose_context");a&&a.loseContext()};this.forceContextRestore=function(){var a=ra.get("WEBGL_lose_context");a&&a.restoreContext()};this.getPixelRatio=function(){return fa};this.setPixelRatio=function(a){void 0!==
a&&(fa=a,this.setSize(K,Z,!1))};this.getSize=function(a){void 0===a&&(console.warn("WebGLRenderer: .getsize() now requires a Vector2 as an argument"),a=new w);return a.set(K,Z)};this.setSize=function(a,b,c){ka.isPresenting()?console.warn("THREE.WebGLRenderer: Can't change size while VR device is presenting."):(K=a,Z=b,x.width=Math.floor(a*fa),x.height=Math.floor(b*fa),!1!==c&&(x.style.width=a+"px",x.style.height=b+"px"),this.setViewport(0,0,a,b))};this.getDrawingBufferSize=function(a){void 0===a&&
(console.warn("WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument"),a=new w);return a.set(K*fa,Z*fa).floor()};this.setDrawingBufferSize=function(a,b,c){K=a;Z=b;fa=c;x.width=Math.floor(a*c);x.height=Math.floor(b*c);this.setViewport(0,0,a,b)};this.getCurrentViewport=function(a){void 0===a&&(console.warn("WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument"),a=new aa);return a.copy(W)};this.getViewport=function(a){return a.copy(ia)};this.setViewport=function(a,
b,c,d){a.isVector4?ia.set(a.x,a.y,a.z,a.w):ia.set(a,b,c,d);ba.viewport(W.copy(ia).multiplyScalar(fa).floor())};this.getScissor=function(a){return a.copy(ja)};this.setScissor=function(a,b,c,d){a.isVector4?ja.set(a.x,a.y,a.z,a.w):ja.set(a,b,c,d);ba.scissor(ca.copy(ja).multiplyScalar(fa).floor())};this.getScissorTest=function(){return na};this.setScissorTest=function(a){ba.setScissorTest(na=a)};this.getClearColor=function(){return ma.getClearColor()};this.setClearColor=function(){ma.setClearColor.apply(ma,
arguments)};this.getClearAlpha=function(){return ma.getClearAlpha()};this.setClearAlpha=function(){ma.setClearAlpha.apply(ma,arguments)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=16384;if(void 0===b||b)d|=256;if(void 0===c||c)d|=1024;J.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.dispose=function(){x.removeEventListener("webglcontextlost",d,!1);x.removeEventListener("webglcontextrestored",
e,!1);va.dispose();ua.dispose();Y.dispose();sa.dispose();ka.dispose();za.stop()};this.renderBufferImmediate=function(a,b){ba.initAttributes();var c=Y.get(a);a.hasPositions&&!c.position&&(c.position=J.createBuffer());a.hasNormals&&!c.normal&&(c.normal=J.createBuffer());a.hasUvs&&!c.uv&&(c.uv=J.createBuffer());a.hasColors&&!c.color&&(c.color=J.createBuffer());b=b.getAttributes();a.hasPositions&&(J.bindBuffer(34962,c.position),J.bufferData(34962,a.positionArray,35048),ba.enableAttribute(b.position),
J.vertexAttribPointer(b.position,3,5126,!1,0,0));a.hasNormals&&(J.bindBuffer(34962,c.normal),J.bufferData(34962,a.normalArray,35048),ba.enableAttribute(b.normal),J.vertexAttribPointer(b.normal,3,5126,!1,0,0));a.hasUvs&&(J.bindBuffer(34962,c.uv),J.bufferData(34962,a.uvArray,35048),ba.enableAttribute(b.uv),J.vertexAttribPointer(b.uv,2,5126,!1,0,0));a.hasColors&&(J.bindBuffer(34962,c.color),J.bufferData(34962,a.colorArray,35048),ba.enableAttribute(b.color),J.vertexAttribPointer(b.color,3,5126,!1,0,0));
ba.disableUnusedAttributes();J.drawArrays(4,0,a.count);a.count=0};this.renderBufferDirect=function(a,c,d,e,f,g){var h=f.isMesh&&0>f.matrixWorld.determinant();ba.setMaterial(e,h);var l=k(a,c,e,f),m=!1;if(b!==d.id||bc!==l.id||S!==(!0===e.wireframe))b=d.id,bc=l.id,S=!0===e.wireframe,m=!0;f.morphTargetInfluences&&(ya.update(f,d,e,l),m=!0);h=d.index;var q=d.attributes.position;c=1;!0===e.wireframe&&(h=xa.getWireframeAttribute(d),c=2);a=Aa;if(null!==h){var u=pa.get(h);a=Ba;a.setIndex(u)}if(m){if(!1!==Ea.isWebGL2||
!f.isInstancedMesh&&!d.isInstancedBufferGeometry||null!==ra.get("ANGLE_instanced_arrays")){ba.initAttributes();m=d.attributes;l=l.getAttributes();var r=e.defaultAttributeValues;for(w in l){var p=l[w];if(0<=p){var t=m[w];if(void 0!==t){var n=t.normalized,v=t.itemSize,x=pa.get(t);if(void 0!==x){var y=x.buffer,z=x.type;x=x.bytesPerElement;if(t.isInterleavedBufferAttribute){var C=t.data,V=C.stride;t=t.offset;C&&C.isInstancedInterleavedBuffer?(ba.enableAttributeAndDivisor(p,C.meshPerAttribute),void 0===
d.maxInstancedCount&&(d.maxInstancedCount=C.meshPerAttribute*C.count)):ba.enableAttribute(p);J.bindBuffer(34962,y);J.vertexAttribPointer(p,v,z,n,V*x,t*x)}else t.isInstancedBufferAttribute?(ba.enableAttributeAndDivisor(p,t.meshPerAttribute),void 0===d.maxInstancedCount&&(d.maxInstancedCount=t.meshPerAttribute*t.count)):ba.enableAttribute(p),J.bindBuffer(34962,y),J.vertexAttribPointer(p,v,z,n,0,0)}}else if("instanceMatrix"===w)x=pa.get(f.instanceMatrix),void 0!==x&&(y=x.buffer,z=x.type,ba.enableAttributeAndDivisor(p+
0,1),ba.enableAttributeAndDivisor(p+1,1),ba.enableAttributeAndDivisor(p+2,1),ba.enableAttributeAndDivisor(p+3,1),J.bindBuffer(34962,y),J.vertexAttribPointer(p+0,4,z,!1,64,0),J.vertexAttribPointer(p+1,4,z,!1,64,16),J.vertexAttribPointer(p+2,4,z,!1,64,32),J.vertexAttribPointer(p+3,4,z,!1,64,48));else if(void 0!==r&&(n=r[w],void 0!==n))switch(n.length){case 2:J.vertexAttrib2fv(p,n);break;case 3:J.vertexAttrib3fv(p,n);break;case 4:J.vertexAttrib4fv(p,n);break;default:J.vertexAttrib1fv(p,n)}}}ba.disableUnusedAttributes()}null!==
h&&J.bindBuffer(34963,u.buffer)}u=Infinity;null!==h?u=h.count:void 0!==q&&(u=q.count);h=d.drawRange.start*c;q=null!==g?g.start*c:0;var w=Math.max(h,q);g=Math.max(0,Math.min(u,h+d.drawRange.count*c,q+(null!==g?g.count*c:Infinity))-1-w+1);if(0!==g){if(f.isMesh)if(!0===e.wireframe)ba.setLineWidth(e.wireframeLinewidth*(null===N?fa:1)),a.setMode(1);else switch(f.drawMode){case 0:a.setMode(4);break;case 1:a.setMode(5);break;case 2:a.setMode(6)}else f.isLine?(e=e.linewidth,void 0===e&&(e=1),ba.setLineWidth(e*
(null===N?fa:1)),f.isLineSegments?a.setMode(1):f.isLineLoop?a.setMode(2):a.setMode(3)):f.isPoints?a.setMode(0):f.isSprite&&a.setMode(4);f.isInstancedMesh?a.renderInstances(d,w,g,f.count):d.isInstancedBufferGeometry?a.renderInstances(d,w,g,d.maxInstancedCount):a.render(w,g)}};this.compile=function(a,b){D=ua.get(a,b);D.init();a.traverse(function(a){a.isLight&&(D.pushLight(a),a.castShadow&&D.pushShadow(a))});D.setupLights(b);a.traverse(function(b){if(b.material)if(Array.isArray(b.material))for(var c=
0;c<b.material.length;c++)u(b.material[c],a.fog,b);else u(b.material,a.fog,b)})};var Ca=null,za=new Xf;za.setAnimationLoop(function(a){ka.isPresenting()||Ca&&Ca(a)});"undefined"!==typeof window&&za.setContext(window);this.setAnimationLoop=function(a){Ca=a;ka.setAnimationLoop(a);za.start()};this.render=function(a,c,d,e){if(void 0!==d){console.warn("THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.");var f=d}if(void 0!==e){console.warn("THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.");
var g=e}c&&c.isCamera?O||(bc=b=null,S=!1,ha=-1,Q=null,!0===a.autoUpdate&&a.updateMatrixWorld(),null===c.parent&&c.updateMatrixWorld(),ka.enabled&&(c=ka.getCamera(c)),D=ua.get(a,c),D.init(),a.onBeforeRender(F,a,c,f||N),Id.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse),cg.setFromMatrix(Id),qa=this.localClippingEnabled,He=Oa.init(this.clippingPlanes,qa,c),G=va.get(a,c),G.init(),l(a,c,0,F.sortObjects),!0===F.sortObjects&&G.sort(),He&&Oa.beginShadows(),Da.render(D.state.shadowsArray,a,c),D.setupLights(c),
He&&Oa.endShadows(),this.info.autoReset&&this.info.reset(),void 0!==f&&this.setRenderTarget(f),ka.enabled&&ta.isAvailable()&&ta.attachCamera(c),ma.render(G,a,c,g),d=G.opaque,e=G.transparent,a.overrideMaterial?(f=a.overrideMaterial,d.length&&m(d,a,c,f),e.length&&m(e,a,c,f)):(d.length&&m(d,a,c),e.length&&m(e,a,c)),a.onAfterRender(F,a,c),null!==N&&(R.updateRenderTargetMipmap(N),R.updateMultisampleRenderTarget(N)),ba.buffers.depth.setTest(!0),ba.buffers.depth.setMask(!0),ba.buffers.color.setMask(!0),
ba.setPolygonOffset(!1),ka.enabled&&(ta.isAvailable()&&ta.detachCamera(c),ka.submitFrame()),D=G=null):console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.")};this.setFramebuffer=function(a){M!==a&&J.bindFramebuffer(36160,a);M=a};this.getActiveCubeFace=function(){return T};this.getActiveMipmapLevel=function(){return X};this.getRenderTarget=function(){return N};this.setRenderTarget=function(a,b,c){N=a;T=b;X=c;a&&void 0===Y.get(a).__webglFramebuffer&&R.setupRenderTarget(a);
var d=M,e=!1;a?(d=Y.get(a).__webglFramebuffer,a.isWebGLRenderTargetCube?(d=d[b||0],e=!0):d=a.isWebGLMultisampleRenderTarget?Y.get(a).__webglMultisampledFramebuffer:d,W.copy(a.viewport),ca.copy(a.scissor),da=a.scissorTest):(W.copy(ia).multiplyScalar(fa).floor(),ca.copy(ja).multiplyScalar(fa).floor(),da=na);ac!==d&&(J.bindFramebuffer(36160,d),ac=d);ba.viewport(W);ba.scissor(ca);ba.setScissorTest(da);e&&(a=Y.get(a.texture),J.framebufferTexture2D(36160,36064,34069+(b||0),a.__webglTexture,c||0))};this.readRenderTargetPixels=
function(a,b,c,d,e,f,g){if(a&&a.isWebGLRenderTarget){var h=Y.get(a).__webglFramebuffer;a.isWebGLRenderTargetCube&&void 0!==g&&(h=h[g]);if(h){g=!1;h!==ac&&(J.bindFramebuffer(36160,h),g=!0);try{var l=a.texture,m=l.format,q=l.type;1023!==m&&la.convert(m)!==J.getParameter(35739)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):1009===q||la.convert(q)===J.getParameter(35738)||1015===q&&(Ea.isWebGL2||ra.get("OES_texture_float")||
ra.get("WEBGL_color_buffer_float"))||1016===q&&(Ea.isWebGL2?ra.get("EXT_color_buffer_float"):ra.get("EXT_color_buffer_half_float"))?36053===J.checkFramebufferStatus(36160)?0<=b&&b<=a.width-d&&0<=c&&c<=a.height-e&&J.readPixels(b,c,d,e,la.convert(m),la.convert(q),f):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{g&&
J.bindFramebuffer(36160,ac)}}}else console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.")};this.copyFramebufferToTexture=function(a,b,c){var d=b.image.width,e=b.image.height,f=la.convert(b.format);R.setTexture2D(b,0);J.copyTexImage2D(3553,c||0,f,a.x,a.y,d,e,0)};this.copyTextureToTexture=function(a,b,c,d){var e=b.image.width,f=b.image.height,g=la.convert(c.format),h=la.convert(c.type);R.setTexture2D(c,0);b.isDataTexture?J.texSubImage2D(3553,d||0,a.x,
a.y,e,f,g,h,b.image.data):J.texSubImage2D(3553,d||0,a.x,a.y,g,h,b.image)};"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}function Ie(a,b){this.name="";this.color=new H(a);this.density=void 0!==b?b:2.5E-4}function Je(a,b,c){this.name="";this.color=new H(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3}function Gb(a,b){this.array=a;this.stride=b;this.count=void 0!==a?a.length/b:0;this.dynamic=!1;this.updateRange={offset:0,count:-1};
this.version=0}function Kd(a,b,c,d){this.data=a;this.itemSize=b;this.offset=c;this.normalized=!0===d}function Hb(a){M.call(this);this.type="SpriteMaterial";this.color=new H(16777215);this.map=null;this.rotation=0;this.transparent=this.sizeAttenuation=!0;this.setValues(a)}function Ld(a){B.call(this);this.type="Sprite";if(void 0===Ic){Ic=new E;var b=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]);b=new Gb(b,5);Ic.setIndex([0,1,2,0,2,3]);Ic.addAttribute("position",new Kd(b,3,
0,!1));Ic.addAttribute("uv",new Kd(b,2,3,!1))}this.geometry=Ic;this.material=void 0!==a?a:new Hb;this.center=new w(.5,.5)}function Ke(a,b,c,d,e,f){Jc.subVectors(a,c).addScalar(.5).multiply(d);void 0!==e?(Md.x=f*Jc.x-e*Jc.y,Md.y=e*Jc.x+f*Jc.y):Md.copy(Jc);a.copy(b);a.x+=Md.x;a.y+=Md.y;a.applyMatrix4(Qh)}function Nd(){B.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]}});this.autoUpdate=!0}function Od(a,b){a&&a.isGeometry&&console.error("THREE.SkinnedMesh no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");
ja.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new U;this.bindMatrixInverse=new U}function Le(a,b){a=a||[];this.bones=a.slice(0);this.boneMatrices=new Float32Array(16*this.bones.length);this.frame=-1;if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton boneInverses is the wrong length."),this.boneInverses=[],a=0,b=this.bones.length;a<b;a++)this.boneInverses.push(new U)}function ig(){B.call(this);
this.type="Bone"}function jg(a,b,c){ja.call(this,a,b);this.instanceMatrix=new O(new Float32Array(16*c),16);this.count=c}function Q(a){M.call(this);this.type="LineBasicMaterial";this.color=new H(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.setValues(a)}function xa(a,b,c){1===c&&console.error("THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.");B.call(this);this.type="Line";this.geometry=void 0!==a?a:new E;this.material=void 0!==b?b:new Q({color:16777215*
Math.random()})}function ca(a,b){xa.call(this,a,b);this.type="LineSegments"}function Me(a,b){xa.call(this,a,b);this.type="LineLoop"}function Qa(a){M.call(this);this.type="PointsMaterial";this.color=new H(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.morphTargets=!1;this.setValues(a)}function Kc(a,b){B.call(this);this.type="Points";this.geometry=void 0!==a?a:new E;this.material=void 0!==b?b:new Qa({color:16777215*Math.random()});this.updateMorphTargets()}function kg(a,b,c,d,e,f,
g){var h=lg.distanceSqToPoint(a);h<c&&(c=new n,lg.closestPointToPoint(a,c),c.applyMatrix4(d),a=e.ray.origin.distanceTo(c),a<e.near||a>e.far||f.push({distance:a,distanceToRay:Math.sqrt(h),point:c,index:b,face:null,object:g}))}function mg(a,b,c,d,e,f,g,h,l){W.call(this,a,b,c,d,e,f,g,h,l);this.format=void 0!==g?g:1022;this.minFilter=void 0!==f?f:1006;this.magFilter=void 0!==e?e:1006;this.generateMipmaps=!1}function Lc(a,b,c,d,e,f,g,h,l,m,q,k){W.call(this,null,f,g,h,l,m,d,e,q,k);this.image={width:b,height:c};
this.mipmaps=a;this.generateMipmaps=this.flipY=!1}function Pd(a,b,c,d,e,f,g,h,l){W.call(this,a,b,c,d,e,f,g,h,l);this.needsUpdate=!0}function Qd(a,b,c,d,e,f,g,h,l,m){m=void 0!==m?m:1026;if(1026!==m&&1027!==m)throw Error("DepthTexture format must be either THREE.DepthFormat or THREE.DepthStencilFormat");void 0===c&&1026===m&&(c=1012);void 0===c&&1027===m&&(c=1020);W.call(this,null,d,e,f,g,h,m,c,l);this.image={width:a,height:b};this.magFilter=void 0!==g?g:1003;this.minFilter=void 0!==h?h:1003;this.generateMipmaps=
this.flipY=!1}function Mc(a){E.call(this);this.type="WireframeGeometry";var b=[],c,d,e,f=[0,0],g={},h=["a","b","c"];if(a&&a.isGeometry){var l=a.faces;var m=0;for(d=l.length;m<d;m++){var q=l[m];for(c=0;3>c;c++){var k=q[h[c]];var t=q[h[(c+1)%3]];f[0]=Math.min(k,t);f[1]=Math.max(k,t);k=f[0]+","+f[1];void 0===g[k]&&(g[k]={index1:f[0],index2:f[1]})}}for(k in g)m=g[k],h=a.vertices[m.index1],b.push(h.x,h.y,h.z),h=a.vertices[m.index2],b.push(h.x,h.y,h.z)}else if(a&&a.isBufferGeometry)if(h=new n,null!==a.index){l=
a.attributes.position;q=a.index;var r=a.groups;0===r.length&&(r=[{start:0,count:q.count,materialIndex:0}]);a=0;for(e=r.length;a<e;++a)for(m=r[a],c=m.start,d=m.count,m=c,d=c+d;m<d;m+=3)for(c=0;3>c;c++)k=q.getX(m+c),t=q.getX(m+(c+1)%3),f[0]=Math.min(k,t),f[1]=Math.max(k,t),k=f[0]+","+f[1],void 0===g[k]&&(g[k]={index1:f[0],index2:f[1]});for(k in g)m=g[k],h.fromBufferAttribute(l,m.index1),b.push(h.x,h.y,h.z),h.fromBufferAttribute(l,m.index2),b.push(h.x,h.y,h.z)}else for(l=a.attributes.position,m=0,d=
l.count/3;m<d;m++)for(c=0;3>c;c++)g=3*m+c,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z),g=3*m+(c+1)%3,h.fromBufferAttribute(l,g),b.push(h.x,h.y,h.z);this.addAttribute("position",new A(b,3))}function Rd(a,b,c){F.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};this.fromBufferGeometry(new Nc(a,b,c));this.mergeVertices()}function Nc(a,b,c){E.call(this);this.type="ParametricBufferGeometry";this.parameters={func:a,slices:b,stacks:c};var d=[],e=[],f=[],g=[],h=new n,
l=new n,m=new n,q=new n,k=new n,t,r;3>a.length&&console.error("THREE.ParametricGeometry: Function must now modify a Vector3 as third parameter.");var p=b+1;for(t=0;t<=c;t++){var v=t/c;for(r=0;r<=b;r++){var x=r/b;a(x,v,l);e.push(l.x,l.y,l.z);0<=x-1E-5?(a(x-1E-5,v,m),q.subVectors(l,m)):(a(x+1E-5,v,m),q.subVectors(m,l));0<=v-1E-5?(a(x,v-1E-5,m),k.subVectors(l,m)):(a(x,v+1E-5,m),k.subVectors(m,l));h.crossVectors(q,k).normalize();f.push(h.x,h.y,h.z);g.push(x,v)}}for(t=0;t<c;t++)for(r=0;r<b;r++)a=t*p+r+
1,h=(t+1)*p+r+1,l=(t+1)*p+r,d.push(t*p+r,a,l),d.push(a,h,l);this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",new A(f,3));this.addAttribute("uv",new A(g,2))}function Sd(a,b,c,d){F.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};this.fromBufferGeometry(new Ca(a,b,c,d));this.mergeVertices()}function Ca(a,b,c,d){function e(a){h.push(a.x,a.y,a.z)}function f(b,c){b*=3;c.x=a[b+0];c.y=a[b+1];c.z=a[b+2]}function g(a,b,c,
d){0>d&&1===a.x&&(l[b]=a.x-1);0===c.x&&0===c.z&&(l[b]=d/2/Math.PI+.5)}E.call(this);this.type="PolyhedronBufferGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;var h=[],l=[];(function(a){for(var c=new n,d=new n,g=new n,h=0;h<b.length;h+=3){f(b[h+0],c);f(b[h+1],d);f(b[h+2],g);var l,m,k=c,z=d,y=g,w=Math.pow(2,a),P=[];for(m=0;m<=w;m++){P[m]=[];var C=k.clone().lerp(y,m/w),A=z.clone().lerp(y,m/w),B=w-m;for(l=0;l<=B;l++)P[m][l]=0===l&&m===w?C:C.clone().lerp(A,l/B)}for(m=0;m<
w;m++)for(l=0;l<2*(w-m)-1;l++)k=Math.floor(l/2),0===l%2?(e(P[m][k+1]),e(P[m+1][k]),e(P[m][k])):(e(P[m][k+1]),e(P[m+1][k+1]),e(P[m+1][k]))}})(d);(function(a){for(var b=new n,c=0;c<h.length;c+=3)b.x=h[c+0],b.y=h[c+1],b.z=h[c+2],b.normalize().multiplyScalar(a),h[c+0]=b.x,h[c+1]=b.y,h[c+2]=b.z})(c);(function(){for(var a=new n,b=0;b<h.length;b+=3)a.x=h[b+0],a.y=h[b+1],a.z=h[b+2],l.push(Math.atan2(a.z,-a.x)/2/Math.PI+.5,1-(Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5));a=new n;b=new n;for(var c=
new n,d=new n,e=new w,f=new w,k=new w,x=0,z=0;x<h.length;x+=9,z+=6){a.set(h[x+0],h[x+1],h[x+2]);b.set(h[x+3],h[x+4],h[x+5]);c.set(h[x+6],h[x+7],h[x+8]);e.set(l[z+0],l[z+1]);f.set(l[z+2],l[z+3]);k.set(l[z+4],l[z+5]);d.copy(a).add(b).add(c).divideScalar(3);var y=Math.atan2(d.z,-d.x);g(e,z+0,a,y);g(f,z+2,b,y);g(k,z+4,c,y)}for(a=0;a<l.length;a+=6)b=l[a+0],c=l[a+2],d=l[a+4],e=Math.min(b,c,d),.9<Math.max(b,c,d)&&.1>e&&(.2>b&&(l[a+0]+=1),.2>c&&(l[a+2]+=1),.2>d&&(l[a+4]+=1))})();this.addAttribute("position",
new A(h,3));this.addAttribute("normal",new A(h.slice(),3));this.addAttribute("uv",new A(l,2));0===d?this.computeVertexNormals():this.normalizeNormals()}function Td(a,b){F.call(this);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Oc(a,b));this.mergeVertices()}function Oc(a,b){Ca.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Ud(a,b){F.call(this);
this.type="OctahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new cc(a,b));this.mergeVertices()}function cc(a,b){Ca.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Vd(a,b){F.call(this);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Pc(a,b));this.mergeVertices()}function Pc(a,b){var c=
(1+Math.sqrt(5))/2;Ca.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronBufferGeometry";this.parameters={radius:a,detail:b}}function Wd(a,b){F.call(this);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b};this.fromBufferGeometry(new Qc(a,b));this.mergeVertices()}function Qc(a,b){var c=
(1+Math.sqrt(5))/2,d=1/c;Ca.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronBufferGeometry";this.parameters=
{radius:a,detail:b}}function Xd(a,b,c,d,e,f){F.call(this);this.type="TubeGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};void 0!==f&&console.warn("THREE.TubeGeometry: taper has been removed.");a=new dc(a,b,c,d,e);this.tangents=a.tangents;this.normals=a.normals;this.binormals=a.binormals;this.fromBufferGeometry(a);this.mergeVertices()}function dc(a,b,c,d,e){function f(e){q=a.getPointAt(e/b,q);var f=g.normals[e];e=g.binormals[e];for(t=0;t<=d;t++){var m=t/d*Math.PI*
2,k=Math.sin(m);m=-Math.cos(m);l.x=m*f.x+k*e.x;l.y=m*f.y+k*e.y;l.z=m*f.z+k*e.z;l.normalize();p.push(l.x,l.y,l.z);h.x=q.x+c*l.x;h.y=q.y+c*l.y;h.z=q.z+c*l.z;r.push(h.x,h.y,h.z)}}E.call(this);this.type="TubeBufferGeometry";this.parameters={path:a,tubularSegments:b,radius:c,radialSegments:d,closed:e};b=b||64;c=c||1;d=d||8;e=e||!1;var g=a.computeFrenetFrames(b,e);this.tangents=g.tangents;this.normals=g.normals;this.binormals=g.binormals;var h=new n,l=new n,m=new w,q=new n,k,t,r=[],p=[],v=[],x=[];for(k=
0;k<b;k++)f(k);f(!1===e?b:0);for(k=0;k<=b;k++)for(t=0;t<=d;t++)m.x=k/b,m.y=t/d,v.push(m.x,m.y);(function(){for(t=1;t<=b;t++)for(k=1;k<=d;k++){var a=(d+1)*t+(k-1),c=(d+1)*t+k,e=(d+1)*(t-1)+k;x.push((d+1)*(t-1)+(k-1),a,e);x.push(a,c,e)}})();this.setIndex(x);this.addAttribute("position",new A(r,3));this.addAttribute("normal",new A(p,3));this.addAttribute("uv",new A(v,2))}function Yd(a,b,c,d,e,f,g){F.call(this);this.type="TorusKnotGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,
p:e,q:f};void 0!==g&&console.warn("THREE.TorusKnotGeometry: heightScale has been deprecated. Use .scale( x, y, z ) instead.");this.fromBufferGeometry(new Rc(a,b,c,d,e,f));this.mergeVertices()}function Rc(a,b,c,d,e,f){function g(a,b,c,d,e){var f=Math.sin(a);b=c/b*a;c=Math.cos(b);e.x=d*(2+c)*.5*Math.cos(a);e.y=d*(2+c)*f*.5;e.z=d*Math.sin(b)*.5}E.call(this);this.type="TorusKnotBufferGeometry";this.parameters={radius:a,tube:b,tubularSegments:c,radialSegments:d,p:e,q:f};a=a||1;b=b||.4;c=Math.floor(c)||
64;d=Math.floor(d)||8;e=e||2;f=f||3;var h=[],l=[],m=[],q=[],k,t=new n,r=new n,p=new n,v=new n,x=new n,z=new n,y=new n;for(k=0;k<=c;++k){var w=k/c*e*Math.PI*2;g(w,e,f,a,p);g(w+.01,e,f,a,v);z.subVectors(v,p);y.addVectors(v,p);x.crossVectors(z,y);y.crossVectors(x,z);x.normalize();y.normalize();for(w=0;w<=d;++w){var P=w/d*Math.PI*2,C=-b*Math.cos(P);P=b*Math.sin(P);t.x=p.x+(C*y.x+P*x.x);t.y=p.y+(C*y.y+P*x.y);t.z=p.z+(C*y.z+P*x.z);l.push(t.x,t.y,t.z);r.subVectors(t,p).normalize();m.push(r.x,r.y,r.z);q.push(k/
c);q.push(w/d)}}for(w=1;w<=c;w++)for(k=1;k<=d;k++)a=(d+1)*w+(k-1),b=(d+1)*w+k,e=(d+1)*(w-1)+k,h.push((d+1)*(w-1)+(k-1),a,e),h.push(a,b,e);this.setIndex(h);this.addAttribute("position",new A(l,3));this.addAttribute("normal",new A(m,3));this.addAttribute("uv",new A(q,2))}function Zd(a,b,c,d,e){F.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};this.fromBufferGeometry(new Sc(a,b,c,d,e));this.mergeVertices()}function Sc(a,b,c,d,e){E.call(this);
this.type="TorusBufferGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||1;b=b||.4;c=Math.floor(c)||8;d=Math.floor(d)||6;e=e||2*Math.PI;var f=[],g=[],h=[],l=[],m=new n,q=new n,k=new n,t,r;for(t=0;t<=c;t++)for(r=0;r<=d;r++){var p=r/d*e,v=t/c*Math.PI*2;q.x=(a+b*Math.cos(v))*Math.cos(p);q.y=(a+b*Math.cos(v))*Math.sin(p);q.z=b*Math.sin(v);g.push(q.x,q.y,q.z);m.x=a*Math.cos(p);m.y=a*Math.sin(p);k.subVectors(q,m).normalize();h.push(k.x,k.y,k.z);l.push(r/d);l.push(t/
c)}for(t=1;t<=c;t++)for(r=1;r<=d;r++)a=(d+1)*(t-1)+r-1,b=(d+1)*(t-1)+r,e=(d+1)*t+r,f.push((d+1)*t+r-1,a,e),f.push(a,b,e);this.setIndex(f);this.addAttribute("position",new A(g,3));this.addAttribute("normal",new A(h,3));this.addAttribute("uv",new A(l,2))}function Rh(a,b,c,d,e){for(var f,g=0,h=b,l=c-d;h<c;h+=d)g+=(a[l]-a[h])*(a[h+1]+a[l+1]),l=h;if(e===0<g)for(e=b;e<c;e+=d)f=Sh(e,a[e],a[e+1],f);else for(e=c-d;e>=b;e-=d)f=Sh(e,a[e],a[e+1],f);f&&ec(f,f.next)&&($d(f),f=f.next);return f}function ae(a,b){if(!a)return a;
b||(b=a);do{var c=!1;if(a.steiner||!ec(a,a.next)&&0!==sa(a.prev,a,a.next))a=a.next;else{$d(a);a=b=a.prev;if(a===a.next)break;c=!0}}while(c||a!==b);return b}function be(a,b,c,d,e,f,g){if(a){if(!g&&f){var h=a,l=h;do null===l.z&&(l.z=ng(l.x,l.y,d,e,f)),l.prevZ=l.prev,l=l.nextZ=l.next;while(l!==h);l.prevZ.nextZ=null;l.prevZ=null;h=l;var m,q,k,t,r=1;do{l=h;var p=h=null;for(q=0;l;){q++;var n=l;for(m=k=0;m<r&&(k++,n=n.nextZ,n);m++);for(t=r;0<k||0<t&&n;)0!==k&&(0===t||!n||l.z<=n.z)?(m=l,l=l.nextZ,k--):(m=
n,n=n.nextZ,t--),p?p.nextZ=m:h=m,m.prevZ=p,p=m;l=n}p.nextZ=null;r*=2}while(1<q)}for(h=a;a.prev!==a.next;){l=a.prev;n=a.next;if(f)p=lk(a,d,e,f);else a:if(p=a,q=p.prev,k=p,r=p.next,0<=sa(q,k,r))p=!1;else{for(m=p.next.next;m!==p.prev;){if(Tc(q.x,q.y,k.x,k.y,r.x,r.y,m.x,m.y)&&0<=sa(m.prev,m,m.next)){p=!1;break a}m=m.next}p=!0}if(p)b.push(l.i/c),b.push(a.i/c),b.push(n.i/c),$d(a),h=a=n.next;else if(a=n,a===h){if(!g)be(ae(a),b,c,d,e,f,1);else if(1===g){g=b;h=c;l=a;do n=l.prev,p=l.next.next,!ec(n,p)&&Th(n,
l,l.next,p)&&ce(n,p)&&ce(p,n)&&(g.push(n.i/h),g.push(l.i/h),g.push(p.i/h),$d(l),$d(l.next),l=a=p),l=l.next;while(l!==a);a=l;be(a,b,c,d,e,f,2)}else if(2===g)a:{g=a;do{for(h=g.next.next;h!==g.prev;){if(l=g.i!==h.i){l=g;n=h;if(p=l.next.i!==n.i&&l.prev.i!==n.i){b:{p=l;do{if(p.i!==l.i&&p.next.i!==l.i&&p.i!==n.i&&p.next.i!==n.i&&Th(p,p.next,l,n)){p=!0;break b}p=p.next}while(p!==l);p=!1}p=!p}if(p=p&&ce(l,n)&&ce(n,l)){p=l;q=!1;k=(l.x+n.x)/2;n=(l.y+n.y)/2;do p.y>n!==p.next.y>n&&p.next.y!==p.y&&k<(p.next.x-
p.x)*(n-p.y)/(p.next.y-p.y)+p.x&&(q=!q),p=p.next;while(p!==l);p=q}l=p}if(l){a=Uh(g,h);g=ae(g,g.next);a=ae(a,a.next);be(g,b,c,d,e,f);be(a,b,c,d,e,f);break a}h=h.next}g=g.next}while(g!==a)}break}}}}function lk(a,b,c,d){var e=a.prev,f=a.next;if(0<=sa(e,a,f))return!1;var g=e.x>a.x?e.x>f.x?e.x:f.x:a.x>f.x?a.x:f.x,h=e.y>a.y?e.y>f.y?e.y:f.y:a.y>f.y?a.y:f.y,l=ng(e.x<a.x?e.x<f.x?e.x:f.x:a.x<f.x?a.x:f.x,e.y<a.y?e.y<f.y?e.y:f.y:a.y<f.y?a.y:f.y,b,c,d);b=ng(g,h,b,c,d);c=a.prevZ;for(d=a.nextZ;c&&c.z>=l&&d&&d.z<=
b;){if(c!==a.prev&&c!==a.next&&Tc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=sa(c.prev,c,c.next))return!1;c=c.prevZ;if(d!==a.prev&&d!==a.next&&Tc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=sa(d.prev,d,d.next))return!1;d=d.nextZ}for(;c&&c.z>=l;){if(c!==a.prev&&c!==a.next&&Tc(e.x,e.y,a.x,a.y,f.x,f.y,c.x,c.y)&&0<=sa(c.prev,c,c.next))return!1;c=c.prevZ}for(;d&&d.z<=b;){if(d!==a.prev&&d!==a.next&&Tc(e.x,e.y,a.x,a.y,f.x,f.y,d.x,d.y)&&0<=sa(d.prev,d,d.next))return!1;d=d.nextZ}return!0}function mk(a,b){return a.x-b.x}
function nk(a,b){var c=b,d=a.x,e=a.y,f=-Infinity;do{if(e<=c.y&&e>=c.next.y&&c.next.y!==c.y){var g=c.x+(e-c.y)*(c.next.x-c.x)/(c.next.y-c.y);if(g<=d&&g>f){f=g;if(g===d){if(e===c.y)return c;if(e===c.next.y)return c.next}var h=c.x<c.next.x?c:c.next}}c=c.next}while(c!==b);if(!h)return null;if(d===f)return h.prev;b=h;g=h.x;var l=h.y,m=Infinity;for(c=h.next;c!==b;){if(d>=c.x&&c.x>=g&&d!==c.x&&Tc(e<l?d:f,e,g,l,e<l?f:d,e,c.x,c.y)){var q=Math.abs(e-c.y)/(d-c.x);(q<m||q===m&&c.x>h.x)&&ce(c,a)&&(h=c,m=q)}c=
c.next}return h}function ng(a,b,c,d,e){a=32767*(a-c)*e;b=32767*(b-d)*e;a=(a|a<<8)&16711935;a=(a|a<<4)&252645135;a=(a|a<<2)&858993459;b=(b|b<<8)&16711935;b=(b|b<<4)&252645135;b=(b|b<<2)&858993459;return(a|a<<1)&1431655765|((b|b<<1)&1431655765)<<1}function ok(a){var b=a,c=a;do{if(b.x<c.x||b.x===c.x&&b.y<c.y)c=b;b=b.next}while(b!==a);return c}function Tc(a,b,c,d,e,f,g,h){return 0<=(e-g)*(b-h)-(a-g)*(f-h)&&0<=(a-g)*(d-h)-(c-g)*(b-h)&&0<=(c-g)*(f-h)-(e-g)*(d-h)}function sa(a,b,c){return(b.y-a.y)*(c.x-
b.x)-(b.x-a.x)*(c.y-b.y)}function ec(a,b){return a.x===b.x&&a.y===b.y}function Th(a,b,c,d){return ec(a,c)&&ec(b,d)||ec(a,d)&&ec(c,b)?!0:0<sa(a,b,c)!==0<sa(a,b,d)&&0<sa(c,d,a)!==0<sa(c,d,b)}function ce(a,b){return 0>sa(a.prev,a,a.next)?0<=sa(a,b,a.next)&&0<=sa(a,a.prev,b):0>sa(a,b,a.prev)||0>sa(a,a.next,b)}function Uh(a,b){var c=new og(a.i,a.x,a.y),d=new og(b.i,b.x,b.y),e=a.next,f=b.prev;a.next=b;b.prev=a;c.next=e;e.prev=c;d.next=c;c.prev=d;f.next=d;d.prev=f;return d}function Sh(a,b,c,d){a=new og(a,
b,c);d?(a.next=d.next,a.prev=d,d.next.prev=a,d.next=a):(a.prev=a,a.next=a);return a}function $d(a){a.next.prev=a.prev;a.prev.next=a.next;a.prevZ&&(a.prevZ.nextZ=a.nextZ);a.nextZ&&(a.nextZ.prevZ=a.prevZ)}function og(a,b,c){this.i=a;this.x=b;this.y=c;this.nextZ=this.prevZ=this.z=this.next=this.prev=null;this.steiner=!1}function Vh(a){var b=a.length;2<b&&a[b-1].equals(a[0])&&a.pop()}function Wh(a,b){for(var c=0;c<b.length;c++)a.push(b[c].x),a.push(b[c].y)}function fc(a,b){F.call(this);this.type="ExtrudeGeometry";
this.parameters={shapes:a,options:b};this.fromBufferGeometry(new eb(a,b));this.mergeVertices()}function eb(a,b){function c(a){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function g(a,b,c){var d=a.x-b.x;var e=a.y-b.y;var f=c.x-a.x;var g=c.y-a.y,h=d*d+e*e;if(Math.abs(d*g-e*f)>Number.EPSILON){var l=Math.sqrt(h),m=Math.sqrt(f*f+g*g);h=b.x-e/l;b=b.y+d/l;g=((c.x-g/m-h)*g-(c.y+f/m-b)*f)/(d*g-e*f);f=h+d*g-a.x;d=b+e*g-a.y;e=f*f+
d*d;if(2>=e)return new w(f,d);e=Math.sqrt(e/2)}else a=!1,d>Number.EPSILON?f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(f=-e,e=Math.sqrt(h)):(f=d,d=e,e=Math.sqrt(h/2));return new w(f/e,d/e)}function h(a,b){for(K=a.length;0<=--K;){var c=K;var f=K-1;0>f&&(f=a.length-1);var g,h=y+2*E;for(g=0;g<h;g++){var l=Y*g,m=Y*(g+1),q=b+f+l,k=b+f+m;m=b+c+m;p(b+c+l);p(q);p(m);p(q);p(k);p(m);l=e.length/3;l=G.generateSideWallUV(d,e,l-6,l-3,l-2,l-1);v(l[0]);
v(l[1]);v(l[3]);v(l[1]);v(l[2]);v(l[3])}}}function l(a,b,c){x.push(a);x.push(b);x.push(c)}function k(a,b,c){p(a);p(b);p(c);a=e.length/3;a=G.generateTopUV(d,e,a-3,a-2,a-1);v(a[0]);v(a[1]);v(a[2])}function p(a){e.push(x[3*a]);e.push(x[3*a+1]);e.push(x[3*a+2])}function v(a){f.push(a.x);f.push(a.y)}var x=[],z=void 0!==b.curveSegments?b.curveSegments:12,y=void 0!==b.steps?b.steps:1,V=void 0!==b.depth?b.depth:100,P=void 0!==b.bevelEnabled?b.bevelEnabled:!0,C=void 0!==b.bevelThickness?b.bevelThickness:6,
A=void 0!==b.bevelSize?b.bevelSize:C-2,B=void 0!==b.bevelOffset?b.bevelOffset:0,E=void 0!==b.bevelSegments?b.bevelSegments:3,D=b.extrudePath,G=void 0!==b.UVGenerator?b.UVGenerator:pk;void 0!==b.amount&&(console.warn("THREE.ExtrudeBufferGeometry: amount has been renamed to depth."),V=b.amount);var F=!1;if(D){var H=D.getSpacedPoints(y);F=!0;P=!1;var I=D.computeFrenetFrames(y,!1);var O=new n;var T=new n;var X=new n}P||(B=A=C=E=0);var M;z=a.extractPoints(z);a=z.shape;var N=z.holes;if(!pb.isClockWise(a)){a=
a.reverse();var ha=0;for(M=N.length;ha<M;ha++){var L=N[ha];pb.isClockWise(L)&&(N[ha]=L.reverse())}}var U=pb.triangulateShape(a,N),W=a;ha=0;for(M=N.length;ha<M;ha++)L=N[ha],a=a.concat(L);var Q,Y=a.length,S,ca=U.length;z=[];var K=0;var Z=W.length;var fa=Z-1;for(Q=K+1;K<Z;K++,fa++,Q++)fa===Z&&(fa=0),Q===Z&&(Q=0),z[K]=g(W[K],W[fa],W[Q]);D=[];var ea=z.concat();ha=0;for(M=N.length;ha<M;ha++){L=N[ha];var aa=[];K=0;Z=L.length;fa=Z-1;for(Q=K+1;K<Z;K++,fa++,Q++)fa===Z&&(fa=0),Q===Z&&(Q=0),aa[K]=g(L[K],L[fa],
L[Q]);D.push(aa);ea=ea.concat(aa)}for(fa=0;fa<E;fa++){Z=fa/E;var da=C*Math.cos(Z*Math.PI/2);Q=A*Math.sin(Z*Math.PI/2)+B;K=0;for(Z=W.length;K<Z;K++){var R=c(W[K],z[K],Q);l(R.x,R.y,-da)}ha=0;for(M=N.length;ha<M;ha++)for(L=N[ha],aa=D[ha],K=0,Z=L.length;K<Z;K++)R=c(L[K],aa[K],Q),l(R.x,R.y,-da)}Q=A+B;for(K=0;K<Y;K++)R=P?c(a[K],ea[K],Q):a[K],F?(T.copy(I.normals[0]).multiplyScalar(R.x),O.copy(I.binormals[0]).multiplyScalar(R.y),X.copy(H[0]).add(T).add(O),l(X.x,X.y,X.z)):l(R.x,R.y,0);for(Z=1;Z<=y;Z++)for(K=
0;K<Y;K++)R=P?c(a[K],ea[K],Q):a[K],F?(T.copy(I.normals[Z]).multiplyScalar(R.x),O.copy(I.binormals[Z]).multiplyScalar(R.y),X.copy(H[Z]).add(T).add(O),l(X.x,X.y,X.z)):l(R.x,R.y,V/y*Z);for(fa=E-1;0<=fa;fa--){Z=fa/E;da=C*Math.cos(Z*Math.PI/2);Q=A*Math.sin(Z*Math.PI/2)+B;K=0;for(Z=W.length;K<Z;K++)R=c(W[K],z[K],Q),l(R.x,R.y,V+da);ha=0;for(M=N.length;ha<M;ha++)for(L=N[ha],aa=D[ha],K=0,Z=L.length;K<Z;K++)R=c(L[K],aa[K],Q),F?l(R.x,R.y+H[y-1].y,H[y-1].x+da):l(R.x,R.y,V+da)}(function(){var a=e.length/3;if(P){var b=
0*Y;for(K=0;K<ca;K++)S=U[K],k(S[2]+b,S[1]+b,S[0]+b);b=Y*(y+2*E);for(K=0;K<ca;K++)S=U[K],k(S[0]+b,S[1]+b,S[2]+b)}else{for(K=0;K<ca;K++)S=U[K],k(S[2],S[1],S[0]);for(K=0;K<ca;K++)S=U[K],k(S[0]+Y*y,S[1]+Y*y,S[2]+Y*y)}d.addGroup(a,e.length/3-a,0)})();(function(){var a=e.length/3,b=0;h(W,b);b+=W.length;ha=0;for(M=N.length;ha<M;ha++)L=N[ha],h(L,b),b+=L.length;d.addGroup(a,e.length/3-a,1)})()}E.call(this);this.type="ExtrudeBufferGeometry";this.parameters={shapes:a,options:b};a=Array.isArray(a)?a:[a];for(var d=
this,e=[],f=[],g=0,h=a.length;g<h;g++)c(a[g]);this.addAttribute("position",new A(e,3));this.addAttribute("uv",new A(f,2));this.computeVertexNormals()}function Xh(a,b,c){c.shapes=[];if(Array.isArray(a))for(var d=0,e=a.length;d<e;d++)c.shapes.push(a[d].uuid);else c.shapes.push(a.uuid);void 0!==b.extrudePath&&(c.options.extrudePath=b.extrudePath.toJSON());return c}function de(a,b){F.call(this);this.type="TextGeometry";this.parameters={text:a,parameters:b};this.fromBufferGeometry(new Uc(a,b));this.mergeVertices()}
function Uc(a,b){b=b||{};var c=b.font;if(!c||!c.isFont)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new F;a=c.generateShapes(a,b.size);b.depth=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);eb.call(this,a,b);this.type="TextBufferGeometry"}function ee(a,b,c,d,e,f,g){F.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,
heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new Ib(a,b,c,d,e,f,g));this.mergeVertices()}function Ib(a,b,c,d,e,f,g){E.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||1;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||6);d=void 0!==d?d:0;e=void 0!==e?e:2*Math.PI;f=void 0!==f?f:0;g=void 0!==g?g:Math.PI;var h=Math.min(f+g,Math.PI),l,m,
q=0,k=[],t=new n,r=new n,p=[],v=[],x=[],z=[];for(m=0;m<=c;m++){var y=[],w=m/c,P=0;0==m&&0==f?P=.5/b:m==c&&h==Math.PI&&(P=-.5/b);for(l=0;l<=b;l++){var C=l/b;t.x=-a*Math.cos(d+C*e)*Math.sin(f+w*g);t.y=a*Math.cos(f+w*g);t.z=a*Math.sin(d+C*e)*Math.sin(f+w*g);v.push(t.x,t.y,t.z);r.copy(t).normalize();x.push(r.x,r.y,r.z);z.push(C+P,1-w);y.push(q++)}k.push(y)}for(m=0;m<c;m++)for(l=0;l<b;l++)a=k[m][l+1],d=k[m][l],e=k[m+1][l],g=k[m+1][l+1],(0!==m||0<f)&&p.push(a,d,g),(m!==c-1||h<Math.PI)&&p.push(d,e,g);this.setIndex(p);
this.addAttribute("position",new A(v,3));this.addAttribute("normal",new A(x,3));this.addAttribute("uv",new A(z,2))}function fe(a,b,c,d,e,f){F.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};this.fromBufferGeometry(new Vc(a,b,c,d,e,f));this.mergeVertices()}function Vc(a,b,c,d,e,f){E.call(this);this.type="RingBufferGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,
thetaLength:f};a=a||.5;b=b||1;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):1;var g=[],h=[],l=[],m=[],q=a,k=(b-a)/d,t=new n,r=new w,p,v;for(p=0;p<=d;p++){for(v=0;v<=c;v++)a=e+v/c*f,t.x=q*Math.cos(a),t.y=q*Math.sin(a),h.push(t.x,t.y,t.z),l.push(0,0,1),r.x=(t.x/b+1)/2,r.y=(t.y/b+1)/2,m.push(r.x,r.y);q+=k}for(p=0;p<d;p++)for(b=p*(c+1),v=0;v<c;v++)a=v+b,e=a+c+1,f=a+c+2,q=a+1,g.push(a,e,q),g.push(e,f,q);this.setIndex(g);this.addAttribute("position",new A(h,
3));this.addAttribute("normal",new A(l,3));this.addAttribute("uv",new A(m,2))}function ge(a,b,c,d){F.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};this.fromBufferGeometry(new Wc(a,b,c,d));this.mergeVertices()}function Wc(a,b,c,d){E.call(this);this.type="LatheBufferGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=Math.floor(b)||12;c=c||0;d=d||2*Math.PI;d=L.clamp(d,0,2*Math.PI);var e=[],f=[],g=[],h=1/b,l=new n,m=new w,q;for(q=
0;q<=b;q++){var k=c+q*h*d;var t=Math.sin(k),r=Math.cos(k);for(k=0;k<=a.length-1;k++)l.x=a[k].x*t,l.y=a[k].y,l.z=a[k].x*r,f.push(l.x,l.y,l.z),m.x=q/b,m.y=k/(a.length-1),g.push(m.x,m.y)}for(q=0;q<b;q++)for(k=0;k<a.length-1;k++)c=k+q*a.length,h=c+a.length,l=c+a.length+1,m=c+1,e.push(c,h,m),e.push(h,l,m);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("uv",new A(g,2));this.computeVertexNormals();if(d===2*Math.PI)for(d=this.attributes.normal.array,e=new n,f=new n,g=new n,c=
b*a.length*3,k=q=0;q<a.length;q++,k+=3)e.x=d[k+0],e.y=d[k+1],e.z=d[k+2],f.x=d[c+k+0],f.y=d[c+k+1],f.z=d[c+k+2],g.addVectors(e,f).normalize(),d[k+0]=d[c+k+0]=g.x,d[k+1]=d[c+k+1]=g.y,d[k+2]=d[c+k+2]=g.z}function gc(a,b){F.call(this);this.type="ShapeGeometry";"object"===typeof b&&(console.warn("THREE.ShapeGeometry: Options parameter has been removed."),b=b.curveSegments);this.parameters={shapes:a,curveSegments:b};this.fromBufferGeometry(new hc(a,b));this.mergeVertices()}function hc(a,b){function c(a){var c,
h=e.length/3;a=a.extractPoints(b);var m=a.shape,k=a.holes;!1===pb.isClockWise(m)&&(m=m.reverse());a=0;for(c=k.length;a<c;a++){var q=k[a];!0===pb.isClockWise(q)&&(k[a]=q.reverse())}var n=pb.triangulateShape(m,k);a=0;for(c=k.length;a<c;a++)q=k[a],m=m.concat(q);a=0;for(c=m.length;a<c;a++)q=m[a],e.push(q.x,q.y,0),f.push(0,0,1),g.push(q.x,q.y);a=0;for(c=n.length;a<c;a++)m=n[a],d.push(m[0]+h,m[1]+h,m[2]+h),l+=3}E.call(this);this.type="ShapeBufferGeometry";this.parameters={shapes:a,curveSegments:b};b=b||
12;var d=[],e=[],f=[],g=[],h=0,l=0;if(!1===Array.isArray(a))c(a);else for(var m=0;m<a.length;m++)c(a[m]),this.addGroup(h,l,m),h+=l,l=0;this.setIndex(d);this.addAttribute("position",new A(e,3));this.addAttribute("normal",new A(f,3));this.addAttribute("uv",new A(g,2))}function Yh(a,b){b.shapes=[];if(Array.isArray(a))for(var c=0,d=a.length;c<d;c++)b.shapes.push(a[c].uuid);else b.shapes.push(a.uuid);return b}function Xc(a,b){E.call(this);this.type="EdgesGeometry";this.parameters={thresholdAngle:b};var c=
[];b=Math.cos(L.DEG2RAD*(void 0!==b?b:1));var d=[0,0],e={},f=["a","b","c"];if(a.isBufferGeometry){var g=new F;g.fromBufferGeometry(a)}else g=a.clone();g.mergeVertices();g.computeFaceNormals();a=g.vertices;g=g.faces;for(var h=0,l=g.length;h<l;h++)for(var m=g[h],k=0;3>k;k++){var u=m[f[k]];var n=m[f[(k+1)%3]];d[0]=Math.min(u,n);d[1]=Math.max(u,n);u=d[0]+","+d[1];void 0===e[u]?e[u]={index1:d[0],index2:d[1],face1:h,face2:void 0}:e[u].face2=h}for(u in e)if(d=e[u],void 0===d.face2||g[d.face1].normal.dot(g[d.face2].normal)<=
b)f=a[d.index1],c.push(f.x,f.y,f.z),f=a[d.index2],c.push(f.x,f.y,f.z);this.addAttribute("position",new A(c,3))}function ic(a,b,c,d,e,f,g,h){F.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new qb(a,b,c,d,e,f,g,h));this.mergeVertices()}function qb(a,b,c,d,e,f,g,h){function l(c){var e,f=new w,l=new n,q=0,v=!0===c?a:b,y=!0===c?1:-1;var A=p;for(e=1;e<=d;e++)u.push(0,
x*y,0),t.push(0,y,0),r.push(.5,.5),p++;var B=p;for(e=0;e<=d;e++){var E=e/d*h+g,D=Math.cos(E);E=Math.sin(E);l.x=v*E;l.y=x*y;l.z=v*D;u.push(l.x,l.y,l.z);t.push(0,y,0);f.x=.5*D+.5;f.y=.5*E*y+.5;r.push(f.x,f.y);p++}for(e=0;e<d;e++)f=A+e,l=B+e,!0===c?k.push(l,l+1,f):k.push(l+1,l,f),q+=3;m.addGroup(z,q,!0===c?1:2);z+=q}E.call(this);this.type="CylinderBufferGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};var m=this;
a=void 0!==a?a:1;b=void 0!==b?b:1;c=c||1;d=Math.floor(d)||8;e=Math.floor(e)||1;f=void 0!==f?f:!1;g=void 0!==g?g:0;h=void 0!==h?h:2*Math.PI;var k=[],u=[],t=[],r=[],p=0,v=[],x=c/2,z=0;(function(){var f,l,q=new n,w=new n,A=0,B=(b-a)/c;for(l=0;l<=e;l++){var E=[],D=l/e,G=D*(b-a)+a;for(f=0;f<=d;f++){var F=f/d,H=F*h+g,I=Math.sin(H);H=Math.cos(H);w.x=G*I;w.y=-D*c+x;w.z=G*H;u.push(w.x,w.y,w.z);q.set(I,B,H).normalize();t.push(q.x,q.y,q.z);r.push(F,1-D);E.push(p++)}v.push(E)}for(f=0;f<d;f++)for(l=0;l<e;l++)q=
v[l+1][f],w=v[l+1][f+1],B=v[l][f+1],k.push(v[l][f],q,B),k.push(q,w,B),A+=6;m.addGroup(z,A,0);z+=A})();!1===f&&(0<a&&l(!0),0<b&&l(!1));this.setIndex(k);this.addAttribute("position",new A(u,3));this.addAttribute("normal",new A(t,3));this.addAttribute("uv",new A(r,2))}function he(a,b,c,d,e,f,g){ic.call(this,0,a,b,c,d,e,f,g);this.type="ConeGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function ie(a,b,c,d,e,f,g){qb.call(this,0,a,
b,c,d,e,f,g);this.type="ConeBufferGeometry";this.parameters={radius:a,height:b,radialSegments:c,heightSegments:d,openEnded:e,thetaStart:f,thetaLength:g}}function je(a,b,c,d){F.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new Yc(a,b,c,d));this.mergeVertices()}function Yc(a,b,c,d){E.call(this);this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||1;b=void 0!==b?Math.max(3,
b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e=[],f=[],g=[],h=[],l,m=new n,k=new w;f.push(0,0,0);g.push(0,0,1);h.push(.5,.5);var u=0;for(l=3;u<=b;u++,l+=3){var t=c+u/b*d;m.x=a*Math.cos(t);m.y=a*Math.sin(t);f.push(m.x,m.y,m.z);g.push(0,0,1);k.x=(f[l]/a+1)/2;k.y=(f[l+1]/a+1)/2;h.push(k.x,k.y)}for(l=1;l<=b;l++)e.push(l,l+1,0);this.setIndex(e);this.addAttribute("position",new A(f,3));this.addAttribute("normal",new A(g,3));this.addAttribute("uv",new A(h,2))}function jc(a){M.call(this);this.type=
"ShadowMaterial";this.color=new H(0);this.transparent=!0;this.setValues(a)}function Zc(a){ma.call(this,a);this.type="RawShaderMaterial"}function fb(a){M.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=new H(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new H(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=
0;this.normalScale=new w(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function kc(a){fb.call(this);this.defines={STANDARD:"",PHYSICAL:""};this.type="MeshPhysicalMaterial";this.reflectivity=
.5;this.clearcoatRoughness=this.clearcoat=0;this.sheen=null;this.clearcoatNormalScale=new w(1,1);this.clearcoatNormalMap=null;this.transparency=0;this.setValues(a)}function Ra(a){M.call(this);this.type="MeshPhongMaterial";this.color=new H(16777215);this.specular=new H(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new H(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=
null;this.normalMapType=0;this.normalScale=new w(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function lc(a){Ra.call(this);this.defines={TOON:""};this.type="MeshToonMaterial";this.gradientMap=
null;this.setValues(a)}function mc(a){M.call(this);this.type="MeshNormalMaterial";this.bumpMap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new w(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.morphNormals=this.morphTargets=this.skinning=this.fog=!1;this.setValues(a)}function nc(a){M.call(this);this.type="MeshLambertMaterial";this.color=new H(16777215);this.lightMap=this.map=null;this.lightMapIntensity=
1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new H(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=0;this.reflectivity=1;this.refractionRatio=.98;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function oc(a){M.call(this);this.defines={MATCAP:""};this.type="MeshMatcapMaterial";this.color=new H(16777215);this.bumpMap=
this.map=this.matcap=null;this.bumpScale=1;this.normalMap=null;this.normalMapType=0;this.normalScale=new w(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.alphaMap=null;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)}function pc(a){Q.call(this);this.type="LineDashedMaterial";this.scale=1;this.dashSize=3;this.gapSize=1;this.setValues(a)}function Ia(a,b,c,d){this.parameterPositions=a;this._cachedIndex=0;this.resultBuffer=void 0!==d?d:new b.constructor(c);
this.sampleValues=b;this.valueSize=c}function Ne(a,b,c,d){Ia.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0}function ke(a,b,c,d){Ia.call(this,a,b,c,d)}function Oe(a,b,c,d){Ia.call(this,a,b,c,d)}function oa(a,b,c,d){if(void 0===a)throw Error("THREE.KeyframeTrack: track name is undefined");if(void 0===b||0===b.length)throw Error("THREE.KeyframeTrack: no keyframes in track named "+a);this.name=a;this.times=pa.convertArray(b,this.TimeBufferType);this.values=
pa.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation)}function Pe(a,b,c){oa.call(this,a,b,c)}function Qe(a,b,c,d){oa.call(this,a,b,c,d)}function $c(a,b,c,d){oa.call(this,a,b,c,d)}function Re(a,b,c,d){Ia.call(this,a,b,c,d)}function le(a,b,c,d){oa.call(this,a,b,c,d)}function Se(a,b,c,d){oa.call(this,a,b,c,d)}function ad(a,b,c,d){oa.call(this,a,b,c,d)}function Ma(a,b,c){this.name=a;this.tracks=c;this.duration=void 0!==b?b:-1;this.uuid=L.generateUUID();0>this.duration&&
this.resetDuration()}function qk(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return $c;case "vector":case "vector2":case "vector3":case "vector4":return ad;case "color":return Qe;case "quaternion":return le;case "bool":case "boolean":return Pe;case "string":return Se}throw Error("THREE.KeyframeTrack: Unsupported typeName: "+a);}function rk(a){if(void 0===a.type)throw Error("THREE.KeyframeTrack: track type undefined, can not parse");var b=qk(a.type);
if(void 0===a.times){var c=[],d=[];pa.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)}function pg(a,b,c){var d=this,e=!1,f=0,g=0,h=void 0,l=[];this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};
this.itemError=function(a){if(void 0!==d.onError)d.onError(a)};this.resolveURL=function(a){return h?h(a):a};this.setURLModifier=function(a){h=a;return this};this.addHandler=function(a,b){l.push(a,b);return this};this.removeHandler=function(a){a=l.indexOf(a);-1!==a&&l.splice(a,2);return this};this.getHandler=function(a){for(var b=0,c=l.length;b<c;b+=2){var d=l[b+1];if(l[b].test(a))return d}return null}}function S(a){this.manager=void 0!==a?a:Zh;this.crossOrigin="anonymous";this.resourcePath=this.path=
""}function Na(a){S.call(this,a)}function qg(a){S.call(this,a)}function rg(a){S.call(this,a)}function Te(a){S.call(this,a)}function bd(a){S.call(this,a)}function Ue(a){S.call(this,a)}function Ve(a){S.call(this,a)}function D(){this.type="Curve";this.arcLengthDivisions=200}function Ja(a,b,c,d,e,f,g,h){D.call(this);this.type="EllipseCurve";this.aX=a||0;this.aY=b||0;this.xRadius=c||1;this.yRadius=d||1;this.aStartAngle=e||0;this.aEndAngle=f||2*Math.PI;this.aClockwise=g||!1;this.aRotation=h||0}function cd(a,
b,c,d,e,f){Ja.call(this,a,b,c,c,d,e,f);this.type="ArcCurve"}function sg(){var a=0,b=0,c=0,d=0;return{initCatmullRom:function(e,f,g,h,l){e=l*(g-e);h=l*(h-f);a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},initNonuniformCatmullRom:function(e,f,g,h,l,m,k){e=((f-e)/l-(g-e)/(l+m)+(g-f)/m)*m;h=((g-f)/m-(h-f)/(m+k)+(h-g)/k)*m;a=f;b=e;c=-3*f+3*g-2*e-h;d=2*f-2*g+e+h},calc:function(e){var f=e*e;return a+b*e+c*f+d*f*e}}}function ya(a,b,c,d){D.call(this);this.type="CatmullRomCurve3";this.points=a||[];this.closed=b||
!1;this.curveType=c||"centripetal";this.tension=d||.5}function $h(a,b,c,d,e){b=.5*(d-b);e=.5*(e-c);var f=a*a;return(2*c-2*d+b+e)*a*f+(-3*c+3*d-2*b-e)*f+b*a+c}function me(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}function ne(a,b,c,d,e){var f=1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}function Sa(a,b,c,d){D.call(this);this.type="CubicBezierCurve";this.v0=a||new w;this.v1=b||new w;this.v2=c||new w;this.v3=d||new w}function gb(a,b,c,d){D.call(this);this.type="CubicBezierCurve3";
this.v0=a||new n;this.v1=b||new n;this.v2=c||new n;this.v3=d||new n}function za(a,b){D.call(this);this.type="LineCurve";this.v1=a||new w;this.v2=b||new w}function Ta(a,b){D.call(this);this.type="LineCurve3";this.v1=a||new n;this.v2=b||new n}function Ua(a,b,c){D.call(this);this.type="QuadraticBezierCurve";this.v0=a||new w;this.v1=b||new w;this.v2=c||new w}function hb(a,b,c){D.call(this);this.type="QuadraticBezierCurve3";this.v0=a||new n;this.v1=b||new n;this.v2=c||new n}function Va(a){D.call(this);
this.type="SplineCurve";this.points=a||[]}function rb(){D.call(this);this.type="CurvePath";this.curves=[];this.autoClose=!1}function Wa(a){rb.call(this);this.type="Path";this.currentPoint=new w;a&&this.setFromPoints(a)}function Jb(a){Wa.call(this,a);this.uuid=L.generateUUID();this.type="Shape";this.holes=[]}function da(a,b){B.call(this);this.type="Light";this.color=new H(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0}function We(a,b,c){da.call(this,a,c);this.type="HemisphereLight";this.castShadow=
void 0;this.position.copy(B.DefaultUp);this.updateMatrix();this.groundColor=new H(b)}function ib(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new w(512,512);this.mapPass=this.map=null;this.matrix=new U;this._frustum=new Ed;this._frameExtents=new w(1,1);this._viewportCount=1;this._viewports=[new aa(0,0,1,1)]}function Xe(){ib.call(this,new na(50,1,.5,500))}function Ye(a,b,c,d,e,f){da.call(this,a,b);this.type="SpotLight";this.position.copy(B.DefaultUp);this.updateMatrix();this.target=new B;
Object.defineProperty(this,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new Xe}function tg(){ib.call(this,new na(90,1,.5,500));this._frameExtents=new w(4,2);this._viewportCount=6;this._viewports=[new aa(2,1,1,1),new aa(0,1,1,1),new aa(3,1,1,1),new aa(1,1,1,1),new aa(3,0,1,1),new aa(1,0,1,1)];this._cubeDirections=[new n(1,
0,0),new n(-1,0,0),new n(0,0,1),new n(0,0,-1),new n(0,1,0),new n(0,-1,0)];this._cubeUps=[new n(0,1,0),new n(0,1,0),new n(0,1,0),new n(0,1,0),new n(0,0,1),new n(0,0,-1)]}function Ze(a,b,c,d){da.call(this,a,b);this.type="PointLight";Object.defineProperty(this,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new tg}function oe(a,b,c,d,e,f){bb.call(this);this.type="OrthographicCamera";
this.zoom=1;this.view=null;this.left=void 0!==a?a:-1;this.right=void 0!==b?b:1;this.top=void 0!==c?c:1;this.bottom=void 0!==d?d:-1;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()}function $e(){ib.call(this,new oe(-5,5,5,-5,.5,500))}function af(a,b){da.call(this,a,b);this.type="DirectionalLight";this.position.copy(B.DefaultUp);this.updateMatrix();this.target=new B;this.shadow=new $e}function bf(a,b){da.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0}
function cf(a,b,c,d){da.call(this,a,b);this.type="RectAreaLight";this.width=void 0!==c?c:10;this.height=void 0!==d?d:10}function df(a){S.call(this,a);this.textures={}}function ef(){E.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0}function ff(a,b,c,d){"number"===typeof c&&(d=c,c=!1,console.error("THREE.InstancedBufferAttribute: The constructor now expects normalized as the third argument."));O.call(this,a,b,c);this.meshPerAttribute=d||1}function gf(a){S.call(this,a)}function hf(a){S.call(this,
a)}function ug(a){"undefined"===typeof createImageBitmap&&console.warn("THREE.ImageBitmapLoader: createImageBitmap() not supported.");"undefined"===typeof fetch&&console.warn("THREE.ImageBitmapLoader: fetch() not supported.");S.call(this,a);this.options=void 0}function vg(){this.type="ShapePath";this.color=new H;this.subPaths=[];this.currentPath=null}function wg(a){this.type="Font";this.data=a}function xg(a){S.call(this,a)}function jf(a){S.call(this,a)}function kf(){this.coefficients=[];for(var a=
0;9>a;a++)this.coefficients.push(new n)}function Xa(a,b){da.call(this,void 0,b);this.sh=void 0!==a?a:new kf}function yg(a,b,c){Xa.call(this,void 0,c);a=(new H).set(a);c=(new H).set(b);b=new n(a.r,a.g,a.b);a=new n(c.r,c.g,c.b);c=Math.sqrt(Math.PI);var d=c*Math.sqrt(.75);this.sh.coefficients[0].copy(b).add(a).multiplyScalar(c);this.sh.coefficients[1].copy(b).sub(a).multiplyScalar(d)}function zg(a,b){Xa.call(this,void 0,b);a=(new H).set(a);this.sh.coefficients[0].set(a.r,a.g,a.b).multiplyScalar(2*Math.sqrt(Math.PI))}
function ai(){this.type="StereoCamera";this.aspect=1;this.eyeSep=.064;this.cameraL=new na;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new na;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1;this._cache={focus:null,fov:null,aspect:null,near:null,far:null,zoom:null,eyeSep:null}}function Ag(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1}function Bg(){B.call(this);this.type="AudioListener";this.context=Cg.getContext();
this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null;this.timeDelta=0;this._clock=new Ag}function dd(a){B.call(this);this.type="Audio";this.listener=a;this.context=a.context;this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.buffer=null;this.detune=0;this.loop=!1;this.offset=this.startTime=0;this.duration=void 0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filters=[]}
function Dg(a){dd.call(this,a);this.panner=this.context.createPanner();this.panner.panningModel="HRTF";this.panner.connect(this.gain)}function Eg(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)}function Fg(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=
this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0}function bi(a,b,c){c=c||Aa.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)}function Aa(a,b,c){this.path=b;this.parsedPath=c||Aa.parseTrackName(b);this.node=Aa.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a}function ci(){this.uuid=L.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var a={};this._indicesByUUID=a;
for(var b=0,c=arguments.length;b!==c;++b)a[arguments[b].uuid]=b;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var d=this;this.stats={objects:{get total(){return d._objects.length},get inUse(){return this.total-d.nCachedObjects_}},get bindingsPerObject(){return d._bindings.length}}}function di(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:2400,endingEnd:2400},e=0;e!==b;++e){var f=a[e].createInterpolant(null);
c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=2201;this._loopCount=-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0}function Gg(a){this._root=a;this._initMemoryManager();
this.time=this._accuIndex=0;this.timeScale=1}function lf(a,b){"string"===typeof a&&(console.warn("THREE.Uniform: Type parameter is no longer needed."),a=b);this.value=a}function Hg(a,b,c){Gb.call(this,a,b);this.meshPerAttribute=c||1}function ei(a,b,c,d){this.ray=new Sb(a,b);this.near=c||0;this.far=d||Infinity;this.camera=null;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");
return this.Points}}})}function fi(a,b){return a.distance-b.distance}function Ig(a,b,c,d){if(!1!==a.visible&&(a.raycast(b,c),!0===d)){a=a.children;d=0;for(var e=a.length;d<e;d++)Ig(a[d],b,c,!0)}}function gi(a,b,c){this.radius=void 0!==a?a:1;this.phi=void 0!==b?b:0;this.theta=void 0!==c?c:0;return this}function hi(a,b,c){this.radius=void 0!==a?a:1;this.theta=void 0!==b?b:0;this.y=void 0!==c?c:0;return this}function Jg(a,b){this.min=void 0!==a?a:new w(Infinity,Infinity);this.max=void 0!==b?b:new w(-Infinity,
-Infinity)}function Kg(a,b){this.start=void 0!==a?a:new n;this.end=void 0!==b?b:new n}function pe(a){B.call(this);this.material=a;this.render=function(){}}function qe(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16711680;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=3*c.faces.length:c&&c.isBufferGeometry&&(b=c.attributes.normal.count);c=new E;b=new A(6*b,3);c.addAttribute("position",b);ca.call(this,c,new Q({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}
function ed(a,b){B.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=b;a=new E;b=[0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,-1,0,1,0,0,0,0,1,1,0,0,0,0,-1,1];for(var c=0,d=1;32>c;c++,d++){var e=c/32*Math.PI*2,f=d/32*Math.PI*2;b.push(Math.cos(e),Math.sin(e),1,Math.cos(f),Math.sin(f),1)}a.addAttribute("position",new A(b,3));b=new Q({fog:!1});this.cone=new ca(a,b);this.add(this.cone);this.update()}function ii(a){var b=[];a&&a.isBone&&b.push(a);for(var c=
0;c<a.children.length;c++)b.push.apply(b,ii(a.children[c]));return b}function fd(a){for(var b=ii(a),c=new E,d=[],e=[],f=new H(0,0,1),g=new H(0,1,0),h=0;h<b.length;h++){var l=b[h];l.parent&&l.parent.isBone&&(d.push(0,0,0),d.push(0,0,0),e.push(f.r,f.g,f.b),e.push(g.r,g.g,g.b))}c.addAttribute("position",new A(d,3));c.addAttribute("color",new A(e,3));d=new Q({vertexColors:2,depthTest:!1,depthWrite:!1,transparent:!0});ca.call(this,c,d);this.root=a;this.bones=b;this.matrix=a.matrixWorld;this.matrixAutoUpdate=
!1}function gd(a,b,c){this.light=a;this.light.updateMatrixWorld();this.color=c;a=new Ib(b,4,2);b=new Ga({wireframe:!0,fog:!1});ja.call(this,a,b);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1;this.update()}function hd(a,b){this.type="RectAreaLightHelper";this.light=a;this.color=b;a=new E;a.addAttribute("position",new A([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3));a.computeBoundingSphere();b=new Q({fog:!1});xa.call(this,a,b);a=new E;a.addAttribute("position",new A([1,1,0,-1,1,0,-1,-1,0,1,1,
0,-1,-1,0,1,-1,0],3));a.computeBoundingSphere();this.add(new ja(a,new Ga({side:1,fog:!1})));this.update()}function id(a,b,c){B.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;a=new cc(b);a.rotateY(.5*Math.PI);this.material=new Ga({wireframe:!0,fog:!1});void 0===this.color&&(this.material.vertexColors=2);b=a.getAttribute("position");b=new Float32Array(3*b.count);a.addAttribute("color",new O(b,3));this.add(new ja(a,this.material));
this.update()}function jd(a,b){this.lightProbe=a;this.size=b;a=new ma({defines:{GAMMA_OUTPUT:""},uniforms:{sh:{value:this.lightProbe.sh.coefficients},intensity:{value:this.lightProbe.intensity}},vertexShader:"varying vec3 vNormal;\nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"#define RECIPROCAL_PI 0.318309886\nvec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {\n\t// matrix is assumed to be orthogonal\n\treturn normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );\n}\nvec3 linearToOutput( in vec3 a ) {\n\t#ifdef GAMMA_OUTPUT\n\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n\t#else\n\t\treturn a;\n\t#endif\n}\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\t// normal is assumed to have unit length\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nuniform vec3 sh[ 9 ]; // sh coefficients\nuniform float intensity; // light probe intensity\nvarying vec3 vNormal;\nvoid main() {\n\tvec3 normal = normalize( vNormal );\n\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, sh );\n\tvec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;\n\toutgoingLight = linearToOutput( outgoingLight );\n\tgl_FragColor = vec4( outgoingLight, 1.0 );\n}"});
b=new Ib(1,32,16);ja.call(this,b,a);this.onBeforeRender()}function mf(a,b,c,d){a=a||10;b=b||10;c=new H(void 0!==c?c:4473924);d=new H(void 0!==d?d:8947848);var e=b/2,f=a/b,g=a/2;a=[];for(var h=[],l=0,m=0,k=-g;l<=b;l++,k+=f){a.push(-g,0,k,g,0,k);a.push(k,0,-g,k,0,g);var n=l===e?c:d;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3;n.toArray(h,m);m+=3}b=new E;b.addAttribute("position",new A(a,3));b.addAttribute("color",new A(h,3));c=new Q({vertexColors:2});ca.call(this,b,c)}function nf(a,b,
c,d,e,f){a=a||10;b=b||16;c=c||8;d=d||64;e=new H(void 0!==e?e:4473924);f=new H(void 0!==f?f:8947848);var g=[],h=[],l;for(l=0;l<=b;l++){var m=l/b*2*Math.PI;var k=Math.sin(m)*a;m=Math.cos(m)*a;g.push(0,0,0);g.push(k,0,m);var n=l&1?e:f;h.push(n.r,n.g,n.b);h.push(n.r,n.g,n.b)}for(l=0;l<=c;l++){n=l&1?e:f;var t=a-a/c*l;for(b=0;b<d;b++)m=b/d*2*Math.PI,k=Math.sin(m)*t,m=Math.cos(m)*t,g.push(k,0,m),h.push(n.r,n.g,n.b),m=(b+1)/d*2*Math.PI,k=Math.sin(m)*t,m=Math.cos(m)*t,g.push(k,0,m),h.push(n.r,n.g,n.b)}a=new E;
a.addAttribute("position",new A(g,3));a.addAttribute("color",new A(h,3));g=new Q({vertexColors:2});ca.call(this,a,g)}function kd(a,b,c,d){this.audio=a;this.range=b||1;this.divisionsInnerAngle=c||16;this.divisionsOuterAngle=d||2;a=new E;b=new Float32Array(3*(3*(this.divisionsInnerAngle+2*this.divisionsOuterAngle)+3));a.addAttribute("position",new O(b,3));b=new Q({color:65280});c=new Q({color:16776960});xa.call(this,a,[c,b]);this.update()}function re(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;
a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;(c=this.object.geometry)&&c.isGeometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new E;b=new A(6*b,3);c.addAttribute("position",b);ca.call(this,c,new Q({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()}function ld(a,b,c){B.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.color=c;void 0===
b&&(b=1);a=new E;a.addAttribute("position",new A([-b,b,0,b,b,0,b,-b,0,-b,-b,0,-b,b,0],3));b=new Q({fog:!1});this.lightPlane=new xa(a,b);this.add(this.lightPlane);a=new E;a.addAttribute("position",new A([0,0,0,0,0,1],3));this.targetLine=new xa(a,b);this.add(this.targetLine);this.update()}function se(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){f.push(0,0,0);g.push(b.r,b.g,b.b);void 0===h[a]&&(h[a]=[]);h[a].push(f.length/3-1)}var d=new E,e=new Q({color:16777215,vertexColors:1}),f=[],g=[],h={},
l=new H(16755200),m=new H(16711680),k=new H(43775),n=new H(16777215),t=new H(3355443);b("n1","n2",l);b("n2","n4",l);b("n4","n3",l);b("n3","n1",l);b("f1","f2",l);b("f2","f4",l);b("f4","f3",l);b("f3","f1",l);b("n1","f1",l);b("n2","f2",l);b("n3","f3",l);b("n4","f4",l);b("p","n1",m);b("p","n2",m);b("p","n3",m);b("p","n4",m);b("u1","u2",k);b("u2","u3",k);b("u3","u1",k);b("c","t",n);b("p","c",t);b("cn1","cn2",t);b("cn3","cn4",t);b("cf1","cf2",t);b("cf3","cf4",t);d.addAttribute("position",new A(f,3));d.addAttribute("color",
new A(g,3));ca.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix&&this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=h;this.update()}function qa(a,b,c,d,e,f,g){of.set(e,f,g).unproject(d);a=b[a];if(void 0!==a)for(c=c.getAttribute("position"),b=0,d=a.length;b<d;b++)c.setXYZ(a[b],of.x,of.y,of.z)}function sb(a,b){this.object=a;void 0===b&&(b=16776960);a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new Float32Array(24),
d=new E;d.setIndex(new O(a,1));d.addAttribute("position",new O(c,3));ca.call(this,d,new Q({color:b}));this.matrixAutoUpdate=!1;this.update()}function te(a,b){this.type="Box3Helper";this.box=a;b=b||16776960;a=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);var c=new E;c.setIndex(new O(a,1));c.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1],3));ca.call(this,c,new Q({color:b}));this.geometry.computeBoundingSphere()}function ue(a,b,c){this.type=
"PlaneHelper";this.plane=a;this.size=void 0===b?1:b;a=void 0!==c?c:16776960;b=new E;b.addAttribute("position",new A([1,-1,1,-1,1,1,-1,-1,1,1,1,1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,0,0,1,0,0,0],3));b.computeBoundingSphere();xa.call(this,b,new Q({color:a}));b=new E;b.addAttribute("position",new A([1,1,1,-1,1,1,-1,-1,1,1,1,1,-1,-1,1,1,-1,1],3));b.computeBoundingSphere();this.add(new ja(b,new Ga({color:a,opacity:.2,transparent:!0,depthWrite:!1})))}function tb(a,b,c,d,e,f){B.call(this);void 0===a&&(a=new n(0,
0,1));void 0===b&&(b=new n(0,0,0));void 0===c&&(c=1);void 0===d&&(d=16776960);void 0===e&&(e=.2*c);void 0===f&&(f=.2*e);void 0===pf&&(pf=new E,pf.addAttribute("position",new A([0,0,0,0,1,0],3)),Lg=new qb(0,.5,1,5,1),Lg.translate(0,-.5,0));this.position.copy(b);this.line=new xa(pf,new Q({color:d}));this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new ja(Lg,new Ga({color:d}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(a);this.setLength(c,e,f)}function ve(a){a=a||
1;var b=[0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a];a=new E;a.addAttribute("position",new A(b,3));a.addAttribute("color",new A([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1],3));b=new Q({vertexColors:2});ca.call(this,a,b)}function ji(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ya.call(this,a);this.type="catmullrom";this.closed=!0}function ki(a){console.warn("THREE.SplineCurve3 has been deprecated. Use THREE.CatmullRomCurve3 instead.");ya.call(this,a);this.type=
"catmullrom"}function Mg(a){console.warn("THREE.Spline has been removed. Use THREE.CatmullRomCurve3 instead.");ya.call(this,a);this.type="catmullrom"}void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Number.isInteger&&(Number.isInteger=function(a){return"number"===typeof a&&isFinite(a)&&Math.floor(a)===a});void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});!1==="name"in Function.prototype&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*([^\(\s]*)/)[1]}});
void 0===Object.assign&&(Object.assign=function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert undefined or null to object");for(var b=Object(a),c=1;c<arguments.length;c++){var d=arguments[c];if(void 0!==d&&null!==d)for(var e in d)Object.prototype.hasOwnProperty.call(d,e)&&(b[e]=d[e])}return b});Object.assign(Ba.prototype,{addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&c[a].push(b)},
hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)},removeEventListener:function(a,b){void 0!==this._listeners&&(a=this._listeners[a],void 0!==a&&(b=a.indexOf(b),-1!==b&&a.splice(b,1)))},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;b=b.slice(0);for(var c=0,d=b.length;c<d;c++)b[c].call(this,a)}}}});for(var va=[],we=0;256>we;we++)va[we]=(16>we?"0":"")+
we.toString(16);var L={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a=4294967295*Math.random()|0,b=4294967295*Math.random()|0,c=4294967295*Math.random()|0,d=4294967295*Math.random()|0;return(va[a&255]+va[a>>8&255]+va[a>>16&255]+va[a>>24&255]+"-"+va[b&255]+va[b>>8&255]+"-"+va[b>>16&15|64]+va[b>>24&255]+"-"+va[c&63|128]+va[c>>8&255]+"-"+va[c>>16&255]+va[c>>24&255]+va[d&255]+va[d>>8&255]+va[d>>16&255]+va[d>>24&255]).toUpperCase()},clamp:function(a,b,c){return Math.max(b,Math.min(c,
a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},lerp:function(a,b,c){return(1-c)*a+c*b},smoothstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*
(.5-Math.random())},degToRad:function(a){return a*L.DEG2RAD},radToDeg:function(a){return a*L.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},ceilPowerOfTwo:function(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))},floorPowerOfTwo:function(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}};Object.defineProperties(w.prototype,{width:{get:function(){return this.x},set:function(a){this.x=a}},height:{get:function(){return this.y},set:function(a){this.y=a}}});Object.assign(w.prototype,
{isVector2:!0,set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,
this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),
this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},applyMatrix3:function(a){var b=this.x,c=this.y;a=a.elements;this.x=a[0]*b+a[3]*c+a[6];this.y=
a[1]*b+a[4]*c+a[7];return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||
1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*
a.x+this.y*a.y},cross:function(a){return this.x*a.y-this.y*a.x},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length()||1)},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=
this.x-a.x;a=this.y-a.y;return b*b+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];return this},toArray:function(a,
b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);return this},rotateAround:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=this.x-a.x,e=this.y-a.y;this.x=d*c-e*b+a.x;this.y=d*b+e*c+a.y;return this}});Object.assign(ua,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=
c[d+0],l=c[d+1],m=c[d+2];c=c[d+3];d=e[f+0];var k=e[f+1],n=e[f+2];e=e[f+3];if(c!==e||h!==d||l!==k||m!==n){f=1-g;var t=h*d+l*k+m*n+c*e,r=0<=t?1:-1,p=1-t*t;p>Number.EPSILON&&(p=Math.sqrt(p),t=Math.atan2(p,t*r),f=Math.sin(f*t)/p,g=Math.sin(g*t)/p);r*=g;h=h*f+d*r;l=l*f+k*r;m=m*f+n*r;c=c*f+e*r;f===1-g&&(g=1/Math.sqrt(h*h+l*l+m*m+c*c),h*=g,l*=g,m*=g,c*=g)}a[b]=h;a[b+1]=l;a[b+2]=m;a[b+3]=c}});Object.defineProperties(ua.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},
y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this._onChangeCallback()}},w:{get:function(){return this._w},set:function(a){this._w=a;this._onChangeCallback()}}});Object.assign(ua.prototype,{isQuaternion:!0,set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=
a.x;this._y=a.y;this._z=a.z;this._w=a.w;this._onChangeCallback();return this},setFromEuler:function(a,b){if(!a||!a.isEuler)throw Error("THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.");var c=a._x,d=a._y,e=a._z;a=a.order;var f=Math.cos,g=Math.sin,h=f(c/2),l=f(d/2);f=f(e/2);c=g(c/2);d=g(d/2);e=g(e/2);"XYZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"YXZ"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f-c*l*e,this._z=
h*l*e-c*d*f,this._w=h*l*f+c*d*e):"ZXY"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f-c*d*e):"ZYX"===a?(this._x=c*l*f-h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f+c*d*e):"YZX"===a?(this._x=c*l*f+h*d*e,this._y=h*d*f+c*l*e,this._z=h*l*e-c*d*f,this._w=h*l*f-c*d*e):"XZY"===a&&(this._x=c*l*f-h*d*e,this._y=h*d*f-c*l*e,this._z=h*l*e+c*d*f,this._w=h*l*f+c*d*e);!1!==b&&this._onChangeCallback();return this},setFromAxisAngle:function(a,b){b/=2;var c=Math.sin(b);
this._x=a.x*c;this._y=a.y*c;this._z=a.z*c;this._w=Math.cos(b);this._onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],l=b[6];b=b[10];var m=c+f+b;0<m?(c=.5/Math.sqrt(m+1),this._w=.25/c,this._x=(l-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(l-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=.25*c,this._z=(g+l)/
c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+l)/c,this._z=.25*c);this._onChangeCallback();return this},setFromUnitVectors:function(a,b){var c=a.dot(b)+1;1E-6>c?(c=0,Math.abs(a.x)>Math.abs(a.z)?(this._x=-a.y,this._y=a.x,this._z=0):(this._x=0,this._y=-a.z,this._z=a.y)):(this._x=a.y*b.z-a.z*b.y,this._y=a.z*b.x-a.x*b.z,this._z=a.x*b.y-a.y*b.x);this._w=c;return this.normalize()},angleTo:function(a){return 2*Math.acos(Math.abs(L.clamp(this.dot(a),-1,1)))},rotateTowards:function(a,
b){var c=this.angleTo(a);if(0===c)return this;this.slerp(a,Math.min(1,b/c));return this},inverse:function(){return this.conjugate()},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this._onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=
this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this._onChangeCallback();return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},premultiply:function(a){return this.multiplyQuaternions(a,this)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z;a=a._w;
var f=b._x,g=b._y,h=b._z;b=b._w;this._x=c*b+a*f+d*h-e*g;this._y=d*b+a*g+e*f-c*h;this._z=e*b+a*h+c*g-d*f;this._w=a*b-c*f-d*g-e*h;this._onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;a=1-g*g;if(a<=Number.EPSILON)return g=1-b,this._w=g*
f+b*this._w,this._x=g*c+b*this._x,this._y=g*d+b*this._y,this._z=g*e+b*this._z,this.normalize(),this._onChangeCallback(),this;a=Math.sqrt(a);var h=Math.atan2(a,g);g=Math.sin((1-b)*h)/a;b=Math.sin(b*h)/a;this._w=f*g+this._w*b;this._x=c*g+this._x*b;this._y=d*g+this._y*b;this._z=e*g+this._z*b;this._onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];
this._w=a[b+3];this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});var Ng=new n,li=new ua;Object.assign(n.prototype,{isVector3:!0,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=
a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},
add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),
this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=
a;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(a){a&&a.isEuler||console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");return this.applyQuaternion(li.setFromEuler(a))},applyAxisAngle:function(a,b){return this.applyQuaternion(li.setFromAxisAngle(a,b))},applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*
d;this.z=a[2]*b+a[5]*c+a[8]*d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,l=a*c+g*b-e*d,m=a*d+e*c-f*b;b=-e*b-f*c-g*d;this.x=h*a+b*-e+l*-g-m*-f;this.y=l*a+b*-f+m*-e-h*-g;this.z=m*a+b*-g+h*-f-l*-e;return this},
project:function(a){return this.applyMatrix4(a.matrixWorldInverse).applyMatrix4(a.projectionMatrix)},unproject:function(a){return this.applyMatrix4(a.projectionMatrixInverse).applyMatrix4(a.matrixWorld)},transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;return this.normalize()},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/
a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,
Math.min(b,this.z));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=
0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+
Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},cross:function(a,b){return void 0!==b?(console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b)):this.crossVectors(this,
a)},crossVectors:function(a,b){var c=a.x,d=a.y;a=a.z;var e=b.x,f=b.y;b=b.z;this.x=d*b-a*f;this.y=a*e-c*b;this.z=c*f-d*e;return this},projectOnVector:function(a){var b=a.dot(this)/a.lengthSq();return this.copy(a).multiplyScalar(b)},projectOnPlane:function(a){Ng.copy(this).projectOnVector(a);return this.sub(Ng)},reflect:function(a){return this.sub(Ng.copy(a).multiplyScalar(2*this.dot(a)))},angleTo:function(a){var b=Math.sqrt(this.lengthSq()*a.lengthSq());0===b&&console.error("THREE.Vector3: angleTo() can't handle zero length vectors.");
a=this.dot(a)/b;return Math.acos(L.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},manhattanDistanceTo:function(a){return Math.abs(this.x-a.x)+Math.abs(this.y-a.y)+Math.abs(this.z-a.z)},setFromSpherical:function(a){return this.setFromSphericalCoords(a.radius,a.phi,a.theta)},setFromSphericalCoords:function(a,b,c){var d=Math.sin(b)*a;this.x=d*Math.sin(c);this.y=Math.cos(b)*
a;this.z=d*Math.cos(c);return this},setFromCylindrical:function(a){return this.setFromCylindricalCoords(a.radius,a.theta,a.y)},setFromCylindricalCoords:function(a,b,c){this.x=a*Math.sin(b);this.y=c;this.z=a*Math.cos(b);return this},setFromMatrixPosition:function(a){a=a.elements;this.x=a[12];this.y=a[13];this.z=a[14];return this},setFromMatrixScale:function(a){var b=this.setFromMatrixColumn(a,0).length(),c=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=b;this.y=
c;this.z=a;return this},setFromMatrixColumn:function(a,b){return this.fromArray(a.elements,4*b)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute().");
this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);return this}});var qc=new n;Object.assign(Y.prototype,{isMatrix3:!0,set:function(a,b,c,d,e,f,g,h,l){var m=this.elements;m[0]=a;m[1]=d;m[2]=g;m[3]=b;m[4]=e;m[5]=h;m[6]=c;m[7]=f;m[8]=l;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){var b=this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=
a[7];b[8]=a[8];return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},applyToBufferAttribute:function(a){for(var b=0,c=a.count;b<c;b++)qc.x=a.getX(b),qc.y=a.getY(b),qc.z=a.getZ(b),qc.applyMatrix3(this),a.setXYZ(b,qc.x,qc.y,qc.z);return a},multiply:function(a){return this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;
a=c[0];var e=c[3],f=c[6],g=c[1],h=c[4],l=c[7],m=c[2],k=c[5];c=c[8];var n=d[0],t=d[3],r=d[6],p=d[1],v=d[4],x=d[7],z=d[2],y=d[5];d=d[8];b[0]=a*n+e*p+f*z;b[3]=a*t+e*v+f*y;b[6]=a*r+e*x+f*d;b[1]=g*n+h*p+l*z;b[4]=g*t+h*v+l*y;b[7]=g*r+h*x+l*d;b[2]=m*n+k*p+c*z;b[5]=m*t+k*v+c*y;b[8]=m*r+k*x+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;b[5]*=a;b[8]*=a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],
f=a[4],g=a[5],h=a[6],l=a[7];a=a[8];return b*f*a-b*g*l-c*e*a+c*g*h+d*e*l-d*f*h},getInverse:function(a,b){a&&a.isMatrix4&&console.error("THREE.Matrix3: .getInverse() no longer takes a Matrix4 argument.");var c=a.elements;a=this.elements;var d=c[0],e=c[1],f=c[2],g=c[3],h=c[4],l=c[5],m=c[6],k=c[7];c=c[8];var n=c*h-l*k,t=l*m-c*g,r=k*g-h*m,p=d*n+e*t+f*r;if(0===p){if(!0===b)throw Error("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");console.warn("THREE.Matrix3: .getInverse() can't invert matrix, determinant is 0");
return this.identity()}b=1/p;a[0]=n*b;a[1]=(f*k-c*e)*b;a[2]=(l*e-f*h)*b;a[3]=t*b;a[4]=(c*d-f*m)*b;a[5]=(f*g-l*d)*b;a[6]=r*b;a[7]=(e*m-k*d)*b;a[8]=(h*d-e*g)*b;return this},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[3];a[3]=b;b=a[2];a[2]=a[6];a[6]=b;b=a[5];a[5]=a[7];a[7]=b;return this},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()},transposeIntoArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=
b[2];a[7]=b[5];a[8]=b[8];return this},setUvTransform:function(a,b,c,d,e,f,g){var h=Math.cos(e);e=Math.sin(e);this.set(c*h,c*e,-c*(h*f+e*g)+f+a,-d*e,d*h,-d*(-e*f+h*g)+g+b,0,0,1)},scale:function(a,b){var c=this.elements;c[0]*=a;c[3]*=a;c[6]*=a;c[1]*=b;c[4]*=b;c[7]*=b;return this},rotate:function(a){var b=Math.cos(a);a=Math.sin(a);var c=this.elements,d=c[0],e=c[3],f=c[6],g=c[1],h=c[4],l=c[7];c[0]=b*d+a*g;c[3]=b*e+a*h;c[6]=b*f+a*l;c[1]=-a*d+b*g;c[4]=-a*e+b*h;c[7]=-a*f+b*l;return this},translate:function(a,
b){var c=this.elements;c[0]+=a*c[2];c[3]+=a*c[5];c[6]+=a*c[8];c[1]+=b*c[2];c[4]+=b*c[5];c[7]+=b*c[8];return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;9>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;9>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];
return a}});var md,Kb={getDataURL:function(a){if("undefined"==typeof HTMLCanvasElement)return a.src;if(!(a instanceof HTMLCanvasElement)){void 0===md&&(md=document.createElementNS("http://www.w3.org/1999/xhtml","canvas"));md.width=a.width;md.height=a.height;var b=md.getContext("2d");a instanceof ImageData?b.putImageData(a,0,0):b.drawImage(a,0,0,a.width,a.height);a=md}return 2048<a.width||2048<a.height?a.toDataURL("image/jpeg",.6):a.toDataURL("image/png")}},Ri=0;W.DEFAULT_IMAGE=void 0;W.DEFAULT_MAPPING=
300;W.prototype=Object.assign(Object.create(Ba.prototype),{constructor:W,isTexture:!0,updateMatrix:function(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=
a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.center.copy(a.center);this.rotation=a.rotation;this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrix.copy(a.matrix);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){var b=void 0===a||"string"===typeof a;if(!b&&void 0!==a.textures[this.uuid])return a.textures[this.uuid];
var c={metadata:{version:4.5,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,type:this.type,encoding:this.encoding,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};
if(void 0!==this.image){var d=this.image;void 0===d.uuid&&(d.uuid=L.generateUUID());if(!b&&void 0===a.images[d.uuid]){if(Array.isArray(d)){var e=[];for(var f=0,g=d.length;f<g;f++)e.push(Kb.getDataURL(d[f]))}else e=Kb.getDataURL(d);a.images[d.uuid]={uuid:d.uuid,url:e}}c.image=d.uuid}b||(a.textures[this.uuid]=c);return c},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(300!==this.mapping)return a;a.applyMatrix3(this.matrix);if(0>a.x||1<a.x)switch(this.wrapS){case 1E3:a.x-=
Math.floor(a.x);break;case 1001:a.x=0>a.x?0:1;break;case 1002:a.x=1===Math.abs(Math.floor(a.x)%2)?Math.ceil(a.x)-a.x:a.x-Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case 1E3:a.y-=Math.floor(a.y);break;case 1001:a.y=0>a.y?0:1;break;case 1002:a.y=1===Math.abs(Math.floor(a.y)%2)?Math.ceil(a.y)-a.y:a.y-Math.floor(a.y)}this.flipY&&(a.y=1-a.y);return a}});Object.defineProperty(W.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.defineProperties(aa.prototype,{width:{get:function(){return this.z},
set:function(a){this.z=a}},height:{get:function(){return this.w},set:function(a){this.w=a}}});Object.assign(aa.prototype,{isVector4:!0,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;
break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+a);}return this},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),
this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,
b);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){this.x*=a;this.y*=a;this.z*=a;this.w*=a;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=a[2]*b+a[6]*c+a[10]*d+a[14]*
e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){a=a.elements;var b=a[0];var c=a[4];var d=a[8],e=a[1],f=a[5],g=a[9];var h=a[2];var l=a[6];var m=a[10];if(.01>Math.abs(c-e)&&.01>Math.abs(d-h)&&.01>Math.abs(g-l)){if(.1>Math.abs(c+
e)&&.1>Math.abs(d+h)&&.1>Math.abs(g+l)&&.1>Math.abs(b+f+m-3))return this.set(1,0,0,0),this;a=Math.PI;b=(b+1)/2;f=(f+1)/2;m=(m+1)/2;c=(c+e)/4;d=(d+h)/4;g=(g+l)/4;b>f&&b>m?.01>b?(l=0,c=h=.707106781):(l=Math.sqrt(b),h=c/l,c=d/l):f>m?.01>f?(l=.707106781,h=0,c=.707106781):(h=Math.sqrt(f),l=c/h,c=g/h):.01>m?(h=l=.707106781,c=0):(c=Math.sqrt(m),l=d/c,h=g/c);this.set(l,h,c,a);return this}a=Math.sqrt((l-g)*(l-g)+(d-h)*(d-h)+(e-c)*(e-c));.001>Math.abs(a)&&(a=1);this.x=(l-g)/a;this.y=(d-h)/a;this.z=(e-c)/a;
this.w=Math.acos((b+f+m-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));this.w=Math.max(a.w,Math.min(b.w,
this.w));return this},clampScalar:function(a,b){this.x=Math.max(a,Math.min(b,this.x));this.y=Math.max(a,Math.min(b,this.y));this.z=Math.max(a,Math.min(b,this.z));this.w=Math.max(a,Math.min(b,this.w));return this},clampLength:function(a,b){var c=this.length();return this.divideScalar(c||1).multiplyScalar(Math.max(a,Math.min(b,c)))},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);
this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;
this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},manhattanLength:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length()||1)},setLength:function(a){return this.normalize().multiplyScalar(a)},
lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){return this.subVectors(b,a).multiplyScalar(c).add(a)},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=
this.w;return a},fromBufferAttribute:function(a,b,c){void 0!==c&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute().");this.x=a.getX(b);this.y=a.getY(b);this.z=a.getZ(b);this.w=a.getW(b);return this}});la.prototype=Object.assign(Object.create(Ba.prototype),{constructor:la,isWebGLRenderTarget:!0,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.texture.image.width=a,this.texture.image.height=b,this.dispose();this.viewport.set(0,0,
a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Of.prototype=Object.assign(Object.create(la.prototype),{constructor:Of,isWebGLMultisampleRenderTarget:!0,copy:function(a){la.prototype.copy.call(this,
a);this.samples=a.samples;return this}});var Ka=new n,ea=new U,sk=new n(0,0,0),tk=new n(1,1,1),Lb=new n,qf=new n,ka=new n;Object.assign(U.prototype,{isMatrix4:!0,set:function(a,b,c,d,e,f,g,h,l,m,k,n,t,r,p,v){var q=this.elements;q[0]=a;q[4]=b;q[8]=c;q[12]=d;q[1]=e;q[5]=f;q[9]=g;q[13]=h;q[2]=l;q[6]=m;q[10]=k;q[14]=n;q[3]=t;q[7]=r;q[11]=p;q[15]=v;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new U).fromArray(this.elements)},copy:function(a){var b=
this.elements;a=a.elements;b[0]=a[0];b[1]=a[1];b[2]=a[2];b[3]=a[3];b[4]=a[4];b[5]=a[5];b[6]=a[6];b[7]=a[7];b[8]=a[8];b[9]=a[9];b[10]=a[10];b[11]=a[11];b[12]=a[12];b[13]=a[13];b[14]=a[14];b[15]=a[15];return this},copyPosition:function(a){var b=this.elements;a=a.elements;b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){a.setFromMatrixColumn(this,0);b.setFromMatrixColumn(this,1);c.setFromMatrixColumn(this,2);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,
b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(a){var b=this.elements,c=a.elements,d=1/Ka.setFromMatrixColumn(a,0).length(),e=1/Ka.setFromMatrixColumn(a,1).length();a=1/Ka.setFromMatrixColumn(a,2).length();b[0]=c[0]*d;b[1]=c[1]*d;b[2]=c[2]*d;b[3]=0;b[4]=c[4]*e;b[5]=c[5]*e;b[6]=c[6]*e;b[7]=0;b[8]=c[8]*a;b[9]=c[9]*a;b[10]=c[10]*a;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromEuler:function(a){a&&a.isEuler||console.error("THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c);c=Math.sin(c);var g=Math.cos(d);d=Math.sin(d);var h=Math.cos(e);e=Math.sin(e);if("XYZ"===a.order){a=f*h;var l=f*e,m=c*h,k=c*e;b[0]=g*h;b[4]=-g*e;b[8]=d;b[1]=l+m*d;b[5]=a-k*d;b[9]=-c*g;b[2]=k-a*d;b[6]=m+l*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a+k*c,b[4]=m*c-l,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=l*c-m,b[6]=k+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,l=g*e,m=d*h,k=d*e,b[0]=a-k*c,b[4]=-f*e,b[8]=m+l*c,b[1]=l+m*c,b[5]=f*h,b[9]=
k-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,l=f*e,m=c*h,k=c*e,b[0]=g*h,b[4]=m*d-l,b[8]=a*d+k,b[1]=g*e,b[5]=k*d+a,b[9]=l*d-m,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=k-a*e,b[8]=m*e+l,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=l*e+m,b[10]=a-k*e):"XZY"===a.order&&(a=f*g,l=f*d,m=c*g,k=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+k,b[5]=f*h,b[9]=l*e-m,b[2]=m*e-l,b[6]=c*h,b[10]=k*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){return this.compose(sk,
a,tk)},lookAt:function(a,b,c){var d=this.elements;ka.subVectors(a,b);0===ka.lengthSq()&&(ka.z=1);ka.normalize();Lb.crossVectors(c,ka);0===Lb.lengthSq()&&(1===Math.abs(c.z)?ka.x+=1E-4:ka.z+=1E-4,ka.normalize(),Lb.crossVectors(c,ka));Lb.normalize();qf.crossVectors(ka,Lb);d[0]=Lb.x;d[4]=qf.x;d[8]=ka.x;d[1]=Lb.y;d[5]=qf.y;d[9]=ka.y;d[2]=Lb.z;d[6]=qf.z;d[10]=ka.z;return this},multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),
this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements;b=this.elements;a=c[0];var e=c[4],f=c[8],g=c[12],h=c[1],l=c[5],m=c[9],k=c[13],n=c[2],t=c[6],r=c[10],p=c[14],v=c[3],x=c[7],z=c[11];c=c[15];var y=d[0],w=d[4],A=d[8],C=d[12],B=d[1],E=d[5],D=d[9],F=d[13],G=d[2],H=d[6],I=d[10],L=d[14],M=d[3],N=d[7],O=d[11];d=d[15];b[0]=a*y+e*B+f*G+g*M;b[4]=a*w+e*E+f*H+g*N;b[8]=a*A+e*D+f*I+
g*O;b[12]=a*C+e*F+f*L+g*d;b[1]=h*y+l*B+m*G+k*M;b[5]=h*w+l*E+m*H+k*N;b[9]=h*A+l*D+m*I+k*O;b[13]=h*C+l*F+m*L+k*d;b[2]=n*y+t*B+r*G+p*M;b[6]=n*w+t*E+r*H+p*N;b[10]=n*A+t*D+r*I+p*O;b[14]=n*C+t*F+r*L+p*d;b[3]=v*y+x*B+z*G+c*M;b[7]=v*w+x*E+z*H+c*N;b[11]=v*A+x*D+z*I+c*O;b[15]=v*C+x*F+z*L+c*d;return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToBufferAttribute:function(a){for(var b=
0,c=a.count;b<c;b++)Ka.x=a.getX(b),Ka.y=a.getY(b),Ka.z=a.getZ(b),Ka.applyMatrix4(this),a.setXYZ(b,Ka.x,Ka.y,Ka.z);return a},determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],l=a[13],m=a[2],k=a[6],n=a[10],t=a[14];return a[3]*(+e*h*k-d*l*k-e*g*n+c*l*n+d*g*t-c*h*t)+a[7]*(+b*h*t-b*l*n+e*f*n-d*f*t+d*l*m-e*h*m)+a[11]*(+b*l*k-b*g*t-e*f*k+c*f*t+e*g*m-c*l*m)+a[15]*(-d*g*m-b*h*k+b*g*n+d*f*k-c*f*n+c*h*m)},transpose:function(){var a=this.elements;var b=a[1];a[1]=a[4];
a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},setPosition:function(a,b,c){var d=this.elements;a.isVector3?(d[12]=a.x,d[13]=a.y,d[14]=a.z):(d[12]=a,d[13]=b,d[14]=c);return this},getInverse:function(a,b){var c=this.elements,d=a.elements;a=d[0];var e=d[1],f=d[2],g=d[3],h=d[4],l=d[5],m=d[6],k=d[7],n=d[8],t=d[9],r=d[10],p=d[11],v=d[12],x=d[13],z=d[14];d=d[15];var y=t*z*k-x*r*k+x*m*p-l*z*p-t*m*d+l*r*d,
w=v*r*k-n*z*k-v*m*p+h*z*p+n*m*d-h*r*d,A=n*x*k-v*t*k+v*l*p-h*x*p-n*l*d+h*t*d,C=v*t*m-n*x*m-v*l*r+h*x*r+n*l*z-h*t*z,B=a*y+e*w+f*A+g*C;if(0===B){if(!0===b)throw Error("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");console.warn("THREE.Matrix4: .getInverse() can't invert matrix, determinant is 0");return this.identity()}b=1/B;c[0]=y*b;c[1]=(x*r*g-t*z*g-x*f*p+e*z*p+t*f*d-e*r*d)*b;c[2]=(l*z*g-x*m*g+x*f*k-e*z*k-l*f*d+e*m*d)*b;c[3]=(t*m*g-l*r*g-t*f*k+e*r*k+l*f*p-e*m*p)*b;c[4]=w*b;c[5]=
(n*z*g-v*r*g+v*f*p-a*z*p-n*f*d+a*r*d)*b;c[6]=(v*m*g-h*z*g-v*f*k+a*z*k+h*f*d-a*m*d)*b;c[7]=(h*r*g-n*m*g+n*f*k-a*r*k-h*f*p+a*m*p)*b;c[8]=A*b;c[9]=(v*t*g-n*x*g-v*e*p+a*x*p+n*e*d-a*t*d)*b;c[10]=(h*x*g-v*l*g+v*e*k-a*x*k-h*e*d+a*l*d)*b;c[11]=(n*l*g-h*t*g-n*e*k+a*t*k+h*e*p-a*l*p)*b;c[12]=C*b;c[13]=(n*x*f-v*t*f+v*e*r-a*x*r-n*e*z+a*t*z)*b;c[14]=(v*l*f-h*x*f-v*e*m+a*x*m+h*e*z-a*l*z)*b;c[15]=(h*t*f-n*l*f+n*e*m-a*t*m-h*e*r+a*l*r)*b;return this},scale:function(a){var b=this.elements,c=a.x,d=a.y;a=a.z;b[0]*=c;
b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=
Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b);b=Math.sin(b);var d=1-c,e=a.x,f=a.y;a=a.z;var g=d*e,h=d*f;this.set(g*e+c,g*f-b*a,g*a+b*f,0,g*f+b*a,h*f+c,h*a-b*e,0,g*a-b*f,h*a+b*e,d*a*a+c,0,0,0,0,1);return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},makeShear:function(a,
b,c){this.set(1,b,c,0,a,1,c,0,a,b,1,0,0,0,0,1);return this},compose:function(a,b,c){var d=this.elements,e=b._x,f=b._y,g=b._z,h=b._w,l=e+e,m=f+f,k=g+g;b=e*l;var n=e*m;e*=k;var t=f*m;f*=k;g*=k;l*=h;m*=h;h*=k;k=c.x;var r=c.y;c=c.z;d[0]=(1-(t+g))*k;d[1]=(n+h)*k;d[2]=(e-m)*k;d[3]=0;d[4]=(n-h)*r;d[5]=(1-(b+g))*r;d[6]=(f+l)*r;d[7]=0;d[8]=(e+m)*c;d[9]=(f-l)*c;d[10]=(1-(b+t))*c;d[11]=0;d[12]=a.x;d[13]=a.y;d[14]=a.z;d[15]=1;return this},decompose:function(a,b,c){var d=this.elements,e=Ka.set(d[0],d[1],d[2]).length(),
f=Ka.set(d[4],d[5],d[6]).length(),g=Ka.set(d[8],d[9],d[10]).length();0>this.determinant()&&(e=-e);a.x=d[12];a.y=d[13];a.z=d[14];ea.copy(this);a=1/e;d=1/f;var h=1/g;ea.elements[0]*=a;ea.elements[1]*=a;ea.elements[2]*=a;ea.elements[4]*=d;ea.elements[5]*=d;ea.elements[6]*=d;ea.elements[8]*=h;ea.elements[9]*=h;ea.elements[10]*=h;b.setFromRotationMatrix(ea);c.x=e;c.y=f;c.z=g;return this},makePerspective:function(a,b,c,d,e,f){void 0===f&&console.warn("THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.");
var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(c-d);g[9]=(c+d)/(c-d);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=1/(b-a),l=1/(c-d),m=1/(f-e);g[0]=2*h;g[4]=0;g[8]=0;g[12]=-((b+a)*h);g[1]=0;g[5]=2*l;g[9]=0;g[13]=-((c+d)*l);g[2]=0;g[6]=0;g[10]=-2*m;g[14]=-((f+e)*m);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;
a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a,b){void 0===b&&(b=0);for(var c=0;16>c;c++)this.elements[c]=a[c+b];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a}});var mi=new U,ni=new ua;Qb.RotationOrders=
"XYZ YZX ZXY XZY YXZ ZYX".split(" ");Qb.DefaultOrder="XYZ";Object.defineProperties(Qb.prototype,{x:{get:function(){return this._x},set:function(a){this._x=a;this._onChangeCallback()}},y:{get:function(){return this._y},set:function(a){this._y=a;this._onChangeCallback()}},z:{get:function(){return this._z},set:function(a){this._z=a;this._onChangeCallback()}},order:{get:function(){return this._order},set:function(a){this._order=a;this._onChangeCallback()}}});Object.assign(Qb.prototype,{isEuler:!0,set:function(a,
b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this._onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this._onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=L.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],l=e[5],m=e[9],k=e[2],n=e[6];e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.9999999>Math.abs(g)?
(this._x=Math.atan2(-m,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(n,l),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(m,-1,1)),.9999999>Math.abs(m)?(this._y=Math.atan2(g,e),this._z=Math.atan2(h,l)):(this._y=Math.atan2(-k,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(n,-1,1)),.9999999>Math.abs(n)?(this._y=Math.atan2(-k,e),this._z=Math.atan2(-f,l)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(k,-1,1)),.9999999>Math.abs(k)?(this._x=Math.atan2(n,e),this._z=Math.atan2(h,a)):
(this._x=0,this._z=Math.atan2(-f,l))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.9999999>Math.abs(h)?(this._x=Math.atan2(-m,l),this._y=Math.atan2(-k,a)):(this._x=0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.9999999>Math.abs(f)?(this._x=Math.atan2(n,l),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-m,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;!1!==c&&this._onChangeCallback();return this},setFromQuaternion:function(a,
b,c){mi.makeRotationFromQuaternion(a);return this.setFromRotationMatrix(mi,b,c)},setFromVector3:function(a,b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(a){ni.setFromEuler(this);return this.setFromQuaternion(ni,a)},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this._onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=
[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new n(this._x,this._y,this._z)},_onChange:function(a){this._onChangeCallback=a;return this},_onChangeCallback:function(){}});Object.assign(Pf.prototype,{set:function(a){this.mask=1<<a|0},enable:function(a){this.mask=this.mask|1<<a|0},enableAll:function(){this.mask=-1},toggle:function(a){this.mask^=1<<a|0},disable:function(a){this.mask&=~(1<<a|
0)},disableAll:function(){this.mask=0},test:function(a){return 0!==(this.mask&a.mask)}});var Si=0,oi=new n,nd=new ua,ub=new U,rf=new n,xe=new n,uk=new n,vk=new ua,pi=new n(1,0,0),qi=new n(0,1,0),ri=new n(0,0,1),wk={type:"added"},xk={type:"removed"};B.DefaultUp=new n(0,1,0);B.DefaultMatrixAutoUpdate=!0;B.prototype=Object.assign(Object.create(Ba.prototype),{constructor:B,isObject3D:!0,onBeforeRender:function(){},onAfterRender:function(){},applyMatrix:function(a){this.matrixAutoUpdate&&this.updateMatrix();
this.matrix.premultiply(a);this.matrix.decompose(this.position,this.quaternion,this.scale)},applyQuaternion:function(a){this.quaternion.premultiply(a);return this},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(a,b){nd.setFromAxisAngle(a,b);
this.quaternion.multiply(nd);return this},rotateOnWorldAxis:function(a,b){nd.setFromAxisAngle(a,b);this.quaternion.premultiply(nd);return this},rotateX:function(a){return this.rotateOnAxis(pi,a)},rotateY:function(a){return this.rotateOnAxis(qi,a)},rotateZ:function(a){return this.rotateOnAxis(ri,a)},translateOnAxis:function(a,b){oi.copy(a).applyQuaternion(this.quaternion);this.position.add(oi.multiplyScalar(b));return this},translateX:function(a){return this.translateOnAxis(pi,a)},translateY:function(a){return this.translateOnAxis(qi,
a)},translateZ:function(a){return this.translateOnAxis(ri,a)},localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(a){return a.applyMatrix4(ub.getInverse(this.matrixWorld))},lookAt:function(a,b,c){a.isVector3?rf.copy(a):rf.set(a,b,c);a=this.parent;this.updateWorldMatrix(!0,!1);xe.setFromMatrixPosition(this.matrixWorld);this.isCamera||this.isLight?ub.lookAt(xe,rf,this.up):ub.lookAt(rf,xe,this.up);this.quaternion.setFromRotationMatrix(ub);a&&(ub.extractRotation(a.matrixWorld),
nd.setFromRotationMatrix(ub),this.quaternion.premultiply(nd.inverse()))},add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a&&a.isObject3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,this.children.push(a),a.dispatchEvent(wk)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",a);return this},remove:function(a){if(1<
arguments.length){for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);return this}b=this.children.indexOf(a);-1!==b&&(a.parent=null,this.children.splice(b,1),a.dispatchEvent(xk));return this},attach:function(a){this.updateWorldMatrix(!0,!1);ub.getInverse(this.matrixWorld);null!==a.parent&&(a.parent.updateWorldMatrix(!0,!1),ub.multiply(a.parent.matrixWorld));a.applyMatrix(ub);a.updateWorldMatrix(!1,!1);this.add(a);return this},getObjectById:function(a){return this.getObjectByProperty("id",
a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByProperty(a,b);if(void 0!==e)return e}},getWorldPosition:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldPosition() target is now required"),a=new n);this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldQuaternion() target is now required"),
a=new ua);this.updateMatrixWorld(!0);this.matrixWorld.decompose(xe,a,uk);return a},getWorldScale:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldScale() target is now required"),a=new n);this.updateMatrixWorld(!0);this.matrixWorld.decompose(xe,vk,a);return a},getWorldDirection:function(a){void 0===a&&(console.warn("THREE.Object3D: .getWorldDirection() target is now required"),a=new n);this.updateMatrixWorld(!0);var b=this.matrixWorld.elements;return a.set(b[8],b[9],b[10]).normalize()},
raycast:function(){},traverse:function(a){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverse(a)},traverseVisible:function(a){if(!1!==this.visible){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){this.matrixAutoUpdate&&
this.updateMatrix();if(this.matrixWorldNeedsUpdate||a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].updateMatrixWorld(a)},updateWorldMatrix:function(a,b){var c=this.parent;!0===a&&null!==c&&c.updateWorldMatrix(!0,!1);this.matrixAutoUpdate&&this.updateMatrix();null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,
this.matrix);if(!0===b)for(a=this.children,b=0,c=a.length;b<c;b++)a[b].updateWorldMatrix(!1,!0)},toJSON:function(a){function b(b,c){void 0===b[c.uuid]&&(b[c.uuid]=c.toJSON(a));return c.uuid}function c(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var d=void 0===a||"string"===typeof a,e={};d&&(a={geometries:{},materials:{},textures:{},images:{},shapes:{}},e.metadata={version:4.5,type:"Object",generator:"Object3D.toJSON"});var f={};f.uuid=this.uuid;f.type=this.type;""!==
this.name&&(f.name=this.name);!0===this.castShadow&&(f.castShadow=!0);!0===this.receiveShadow&&(f.receiveShadow=!0);!1===this.visible&&(f.visible=!1);!1===this.frustumCulled&&(f.frustumCulled=!1);0!==this.renderOrder&&(f.renderOrder=this.renderOrder);"{}"!==JSON.stringify(this.userData)&&(f.userData=this.userData);f.layers=this.layers.mask;f.matrix=this.matrix.toArray();!1===this.matrixAutoUpdate&&(f.matrixAutoUpdate=!1);this.isMesh&&0!==this.drawMode&&(f.drawMode=this.drawMode);if(this.isMesh||this.isLine||
this.isPoints){f.geometry=b(a.geometries,this.geometry);var g=this.geometry.parameters;if(void 0!==g&&void 0!==g.shapes)if(g=g.shapes,Array.isArray(g))for(var h=0,l=g.length;h<l;h++)b(a.shapes,g[h]);else b(a.shapes,g)}if(void 0!==this.material)if(Array.isArray(this.material)){g=[];h=0;for(l=this.material.length;h<l;h++)g.push(b(a.materials,this.material[h]));f.material=g}else f.material=b(a.materials,this.material);if(0<this.children.length)for(f.children=[],h=0;h<this.children.length;h++)f.children.push(this.children[h].toJSON(a).object);
if(d){d=c(a.geometries);h=c(a.materials);l=c(a.textures);var m=c(a.images);g=c(a.shapes);0<d.length&&(e.geometries=d);0<h.length&&(e.materials=h);0<l.length&&(e.textures=l);0<m.length&&(e.images=m);0<g.length&&(e.shapes=g)}e.object=f;return e},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);
this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.layers.mask=a.layers.mask;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(b=0;b<a.children.length;b++)this.add(a.children[b].clone());return this}});wd.prototype=Object.assign(Object.create(B.prototype),{constructor:wd,isScene:!0,
copy:function(a,b){B.prototype.copy.call(this,a,b);null!==a.background&&(this.background=a.background.clone());null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this},toJSON:function(a){var b=B.prototype.toJSON.call(this,a);null!==this.background&&(b.object.background=this.background.toJSON(a));null!==this.fog&&(b.object.fog=this.fog.toJSON());return b},dispose:function(){this.dispatchEvent({type:"dispose"})}});
var vb=[new n,new n,new n,new n,new n,new n,new n,new n],jb=new n,od=new n,pd=new n,qd=new n,Mb=new n,Nb=new n,rc=new n,ye=new n,sf=new n,tf=new n,Rb=new n;Object.assign(ab.prototype,{isBox3:!0,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,l=a.length;h<l;h+=3){var m=a[h],k=a[h+1],n=a[h+2];m<b&&(b=m);k<c&&(c=k);n<d&&(d=n);m>e&&(e=m);k>f&&(f=k);n>g&&(g=n)}this.min.set(b,c,d);
this.max.set(e,f,g);return this},setFromBufferAttribute:function(a){for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,l=a.count;h<l;h++){var m=a.getX(h),k=a.getY(h),n=a.getZ(h);m<b&&(b=m);k<c&&(c=k);n<d&&(d=n);m>e&&(e=m);k>f&&(f=k);n>g&&(g=n)}this.min.set(b,c,d);this.max.set(e,f,g);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(a,b){b=jb.copy(b).multiplyScalar(.5);
this.min.copy(a).sub(b);this.max.copy(a).add(b);return this},setFromObject:function(a){this.makeEmpty();return this.expandByObject(a)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},getCenter:function(a){void 0===
a&&(console.warn("THREE.Box3: .getCenter() target is now required"),a=new n);return this.isEmpty()?a.set(0,0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box3: .getSize() target is now required"),a=new n);return this.isEmpty()?a.set(0,0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);
this.max.addScalar(a);return this},expandByObject:function(a){var b;a.updateWorldMatrix(!1,!1);var c=a.geometry;if(void 0!==c)if(c.isGeometry){var d=c.vertices;c=0;for(b=d.length;c<b;c++)jb.copy(d[c]),jb.applyMatrix4(a.matrixWorld),this.expandByPoint(jb)}else if(c.isBufferGeometry&&(d=c.attributes.position,void 0!==d))for(c=0,b=d.count;c<b;c++)jb.fromBufferAttribute(d,c).applyMatrix4(a.matrixWorld),this.expandByPoint(jb);a=a.children;c=0;for(b=a.length;c<b;c++)this.expandByObject(a[c]);return this},
containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box3: .getParameter() target is now required"),b=new n);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),
(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(a){this.clampPoint(a.center,jb);return jb.distanceToSquared(a.center)<=a.radius*a.radius},intersectsPlane:function(a){if(0<a.normal.x){var b=a.normal.x*this.min.x;var c=a.normal.x*this.max.x}else b=a.normal.x*this.max.x,c=a.normal.x*this.min.x;0<a.normal.y?(b+=a.normal.y*this.min.y,
c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=-a.constant&&c>=-a.constant},intersectsTriangle:function(a){if(this.isEmpty())return!1;this.getCenter(ye);sf.subVectors(this.max,ye);od.subVectors(a.a,ye);pd.subVectors(a.b,ye);qd.subVectors(a.c,ye);Mb.subVectors(pd,od);Nb.subVectors(qd,pd);rc.subVectors(od,qd);a=[0,-Mb.z,Mb.y,0,-Nb.z,Nb.y,0,-rc.z,
rc.y,Mb.z,0,-Mb.x,Nb.z,0,-Nb.x,rc.z,0,-rc.x,-Mb.y,Mb.x,0,-Nb.y,Nb.x,0,-rc.y,rc.x,0];if(!Qf(a,od,pd,qd,sf))return!1;a=[1,0,0,0,1,0,0,0,1];if(!Qf(a,od,pd,qd,sf))return!1;tf.crossVectors(Mb,Nb);a=[tf.x,tf.y,tf.z];return Qf(a,od,pd,qd,sf)},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box3: .clampPoint() target is now required"),b=new n);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return jb.copy(a).clamp(this.min,this.max).sub(a).length()},getBoundingSphere:function(a){void 0===
a&&console.error("THREE.Box3: .getBoundingSphere() target is now required");this.getCenter(a.center);a.radius=.5*this.getSize(jb).length();return a},intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(a){if(this.isEmpty())return this;vb[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(a);vb[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(a);
vb[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(a);vb[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(a);vb[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(a);vb[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(a);vb[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(a);vb[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(a);this.setFromPoints(vb);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&
a.max.equals(this.max)}});var yk=new ab;Object.assign(nb.prototype,{set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(a,b){var c=this.center;void 0!==b?c.copy(b):yk.setFromPoints(a).getCenter(c);for(var d=b=0,e=a.length;d<e;d++)b=Math.max(b,c.distanceToSquared(a[d]));this.radius=Math.sqrt(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},empty:function(){return 0>=
this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(a.distanceToPoint(this.center))<=this.radius},clampPoint:function(a,b){var c=this.center.distanceToSquared(a);
void 0===b&&(console.warn("THREE.Sphere: .clampPoint() target is now required"),b=new n);b.copy(a);c>this.radius*this.radius&&(b.sub(this.center).normalize(),b.multiplyScalar(this.radius).add(this.center));return b},getBoundingBox:function(a){void 0===a&&(console.warn("THREE.Sphere: .getBoundingBox() target is now required"),a=new ab);a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},
translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}});var wb=new n,Og=new n,uf=new n,Ob=new n,Pg=new n,vf=new n,Qg=new n;Object.assign(Sb.prototype,{set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){void 0===b&&(console.warn("THREE.Ray: .at() target is now required"),
b=new n);return b.copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize();return this},recast:function(a){this.origin.copy(this.at(a,wb));return this},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Ray: .closestPointToPoint() target is now required"),b=new n);b.subVectors(a,this.origin);a=b.dot(this.direction);return 0>a?b.copy(this.origin):b.copy(this.direction).multiplyScalar(a).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},
distanceSqToPoint:function(a){var b=wb.subVectors(a,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(a);wb.copy(this.direction).multiplyScalar(b).add(this.origin);return wb.distanceToSquared(a)},distanceSqToSegment:function(a,b,c,d){Og.copy(a).add(b).multiplyScalar(.5);uf.copy(b).sub(a).normalize();Ob.copy(this.origin).sub(Og);var e=.5*a.distanceTo(b),f=-this.direction.dot(uf),g=Ob.dot(this.direction),h=-Ob.dot(uf),l=Ob.lengthSq(),m=Math.abs(1-f*f);if(0<m){a=f*h-g;b=f*
g-h;var k=e*m;0<=a?b>=-k?b<=k?(e=1/m,a*=e,b*=e,f=a*(a+f*b+2*g)+b*(f*a+b+2*h)+l):(b=e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):(b=-e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l):b<=-k?(a=Math.max(0,-(-f*e+g)),b=0<a?-e:Math.min(Math.max(-e,-h),e),f=-a*a+b*(b+2*h)+l):b<=k?(a=0,b=Math.min(Math.max(-e,-h),e),f=b*(b+2*h)+l):(a=Math.max(0,-(f*e+g)),b=0<a?e:Math.min(Math.max(-e,-h),e),f=-a*a+b*(b+2*h)+l)}else b=0<f?-e:e,a=Math.max(0,-(f*b+g)),f=-a*a+b*(b+2*h)+l;c&&c.copy(this.direction).multiplyScalar(a).add(this.origin);
d&&d.copy(uf).multiplyScalar(b).add(Og);return f},intersectSphere:function(a,b){wb.subVectors(a.center,this.origin);var c=wb.dot(this.direction),d=wb.dot(wb)-c*c;a=a.radius*a.radius;if(d>a)return null;a=Math.sqrt(a-d);d=c-a;c+=a;return 0>d&&0>c?null:0>d?this.at(c,b):this.at(d,b)},intersectsSphere:function(a){return this.distanceSqToPoint(a.center)<=a.radius*a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+
a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){a=this.distanceToPlane(a);return null===a?null:this.at(a,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c=1/this.direction.x;var d=1/this.direction.y;var e=1/this.direction.z,f=this.origin;if(0<=c){var g=(a.min.x-f.x)*c;c*=a.max.x-f.x}else g=(a.max.x-f.x)*c,c*=a.min.x-f.x;if(0<=d){var h=(a.min.y-f.y)*d;d*=a.max.y-f.y}else h=(a.max.y-
f.y)*d,d*=a.min.y-f.y;if(g>d||h>c)return null;if(h>g||g!==g)g=h;if(d<c||c!==c)c=d;0<=e?(h=(a.min.z-f.z)*e,a=(a.max.z-f.z)*e):(h=(a.max.z-f.z)*e,a=(a.min.z-f.z)*e);if(g>a||h>c)return null;if(h>g||g!==g)g=h;if(a<c||c!==c)c=a;return 0>c?null:this.at(0<=g?g:c,b)},intersectsBox:function(a){return null!==this.intersectBox(a,wb)},intersectTriangle:function(a,b,c,d,e){Pg.subVectors(b,a);vf.subVectors(c,a);Qg.crossVectors(Pg,vf);b=this.direction.dot(Qg);if(0<b){if(d)return null;d=1}else if(0>b)d=-1,b=-b;else return null;
Ob.subVectors(this.origin,a);a=d*this.direction.dot(vf.crossVectors(Ob,vf));if(0>a)return null;c=d*this.direction.dot(Pg.cross(Ob));if(0>c||a+c>b)return null;a=-d*Ob.dot(Qg);return 0>a?null:this.at(a/b,e)},applyMatrix4:function(a){this.origin.applyMatrix4(a);this.direction.transformDirection(a);return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}});var Ya=new n,xb=new n,Rg=new n,yb=new n,rd=new n,sd=new n,si=new n,Sg=new n,Tg=new n,Ug=new n;Object.assign(R,
{getNormal:function(a,b,c,d){void 0===d&&(console.warn("THREE.Triangle: .getNormal() target is now required"),d=new n);d.subVectors(c,b);Ya.subVectors(a,b);d.cross(Ya);a=d.lengthSq();return 0<a?d.multiplyScalar(1/Math.sqrt(a)):d.set(0,0,0)},getBarycoord:function(a,b,c,d,e){Ya.subVectors(d,b);xb.subVectors(c,b);Rg.subVectors(a,b);a=Ya.dot(Ya);b=Ya.dot(xb);c=Ya.dot(Rg);var f=xb.dot(xb);d=xb.dot(Rg);var g=a*f-b*b;void 0===e&&(console.warn("THREE.Triangle: .getBarycoord() target is now required"),e=new n);
if(0===g)return e.set(-2,-1,-1);g=1/g;f=(f*c-b*d)*g;a=(a*d-b*c)*g;return e.set(1-f-a,a,f)},containsPoint:function(a,b,c,d){R.getBarycoord(a,b,c,d,yb);return 0<=yb.x&&0<=yb.y&&1>=yb.x+yb.y},getUV:function(a,b,c,d,e,f,g,h){this.getBarycoord(a,b,c,d,yb);h.set(0,0);h.addScaledVector(e,yb.x);h.addScaledVector(f,yb.y);h.addScaledVector(g,yb.z);return h},isFrontFacing:function(a,b,c,d){Ya.subVectors(c,b);xb.subVectors(a,b);return 0>Ya.cross(xb).dot(d)?!0:!1}});Object.assign(R.prototype,{set:function(a,b,
c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},getArea:function(){Ya.subVectors(this.c,this.b);xb.subVectors(this.a,this.b);return.5*Ya.cross(xb).length()},getMidpoint:function(a){void 0===a&&(console.warn("THREE.Triangle: .getMidpoint() target is now required"),
a=new n);return a.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},getNormal:function(a){return R.getNormal(this.a,this.b,this.c,a)},getPlane:function(a){void 0===a&&(console.warn("THREE.Triangle: .getPlane() target is now required"),a=new n);return a.setFromCoplanarPoints(this.a,this.b,this.c)},getBarycoord:function(a,b){return R.getBarycoord(a,this.a,this.b,this.c,b)},getUV:function(a,b,c,d,e){return R.getUV(a,this.a,this.b,this.c,b,c,d,e)},containsPoint:function(a){return R.containsPoint(a,
this.a,this.b,this.c)},isFrontFacing:function(a){return R.isFrontFacing(this.a,this.b,this.c,a)},intersectsBox:function(a){return a.intersectsTriangle(this)},closestPointToPoint:function(a,b){void 0===b&&(console.warn("THREE.Triangle: .closestPointToPoint() target is now required"),b=new n);var c=this.a,d=this.b,e=this.c;rd.subVectors(d,c);sd.subVectors(e,c);Sg.subVectors(a,c);var f=rd.dot(Sg),g=sd.dot(Sg);if(0>=f&&0>=g)return b.copy(c);Tg.subVectors(a,d);var h=rd.dot(Tg),l=sd.dot(Tg);if(0<=h&&l<=
h)return b.copy(d);var m=f*l-h*g;if(0>=m&&0<=f&&0>=h)return d=f/(f-h),b.copy(c).addScaledVector(rd,d);Ug.subVectors(a,e);a=rd.dot(Ug);var k=sd.dot(Ug);if(0<=k&&a<=k)return b.copy(e);f=a*g-f*k;if(0>=f&&0<=g&&0>=k)return m=g/(g-k),b.copy(c).addScaledVector(sd,m);g=h*k-a*l;if(0>=g&&0<=l-h&&0<=a-k)return si.subVectors(e,d),m=(l-h)/(l-h+(a-k)),b.copy(d).addScaledVector(si,m);e=1/(g+f+m);d=f*e;m*=e;return b.copy(c).addScaledVector(rd,d).addScaledVector(sd,m)},equals:function(a){return a.a.equals(this.a)&&
a.b.equals(this.b)&&a.c.equals(this.c)}});var zk={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,
darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,
green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,
lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,
palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,
steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},Fa={h:0,s:0,l:0},wf={h:0,s:0,l:0};Object.assign(H.prototype,{isColor:!0,r:1,g:1,b:1,set:function(a){a&&a.isColor?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a;return this},setHex:function(a){a=Math.floor(a);
this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(a,b,c){a=L.euclideanModulo(a,1);b=L.clamp(b,0,1);c=L.clamp(c,0,1);0===b?this.r=this.g=this.b=c:(b=.5>=c?c*(1+b):c+b-c*b,c=2*c-b,this.r=Rf(c,b,a+1/3),this.g=Rf(c,b,a),this.b=Rf(c,b,a-1/3));return this},setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=
/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)%\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,
parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){d=parseFloat(c[1])/360;var e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=
parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0<a.length&&(c=zk[a],void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,b){void 0===b&&(b=2);this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);
return this},copyLinearToGamma:function(a,b){void 0===b&&(b=2);b=0<b?1/b:1;this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},convertGammaToLinear:function(a){this.copyGammaToLinear(this,a);return this},convertLinearToGamma:function(a){this.copyLinearToGamma(this,a);return this},copySRGBToLinear:function(a){this.r=Sf(a.r);this.g=Sf(a.g);this.b=Sf(a.b);return this},copyLinearToSRGB:function(a){this.r=Tf(a.r);this.g=Tf(a.g);this.b=Tf(a.b);return this},convertSRGBToLinear:function(){this.copySRGBToLinear(this);
return this},convertLinearToSRGB:function(){this.copyLinearToSRGB(this);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){void 0===a&&(console.warn("THREE.Color: .getHSL() target is now required"),a={h:0,s:0,l:0});var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=(f+e)/2;if(f===e)f=g=0;else{var l=e-f;f=.5>=h?l/(e+f):l/(2-e-f);switch(e){case b:g=(c-
d)/l+(c<d?6:0);break;case c:g=(d-b)/l+2;break;case d:g=(b-c)/l+4}g/=6}a.h=g;a.s=f;a.l=h;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(a,b,c){this.getHSL(Fa);Fa.h+=a;Fa.s+=b;Fa.l+=c;this.setHSL(Fa.h,Fa.s,Fa.l);return this},add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,b){this.r=a.r+b.r;this.g=a.g+b.g;this.b=a.b+b.b;return this},addScalar:function(a){this.r+=a;this.g+=a;this.b+=a;return this},
sub:function(a){this.r=Math.max(0,this.r-a.r);this.g=Math.max(0,this.g-a.g);this.b=Math.max(0,this.b-a.b);return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},lerpHSL:function(a,b){this.getHSL(Fa);a.getHSL(wf);a=L.lerp(Fa.h,wf.h,b);var c=L.lerp(Fa.s,wf.s,b);b=L.lerp(Fa.l,wf.l,b);this.setHSL(a,c,b);return this},
equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,b){void 0===b&&(b=0);this.r=a[b];this.g=a[b+1];this.b=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.r;a[b+1]=this.g;a[b+2]=this.b;return a},toJSON:function(){return this.getHex()}});Object.assign(zc.prototype,{clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);this.color.copy(a.color);
this.materialIndex=a.materialIndex;for(var b=0,c=a.vertexNormals.length;b<c;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(c=a.vertexColors.length;b<c;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}});var Ti=0;M.prototype=Object.assign(Object.create(Ba.prototype),{constructor:M,isMaterial:!0,onBeforeCompile:function(){},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else if("shading"===
b)console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead."),this.flatShading=1===c?!0:!1;else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d&&d.isColor?d.set(c):d&&d.isVector3&&c&&c.isVector3?d.copy(c):this[b]=c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a||"string"===typeof a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.5,
type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color&&this.color.isColor&&(d.color=this.color.getHex());void 0!==this.roughness&&(d.roughness=this.roughness);void 0!==this.metalness&&(d.metalness=this.metalness);this.sheen&&this.sheen.isColor&&(d.sheen=this.sheen.getHex());this.emissive&&this.emissive.isColor&&(d.emissive=this.emissive.getHex());this.emissiveIntensity&&1!==this.emissiveIntensity&&(d.emissiveIntensity=this.emissiveIntensity);
this.specular&&this.specular.isColor&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);void 0!==this.clearcoat&&(d.clearcoat=this.clearcoat);void 0!==this.clearcoatRoughness&&(d.clearcoatRoughness=this.clearcoatRoughness);this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(d.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(a).uuid,d.clearcoatNormalScale=this.clearcoatNormalScale.toArray());this.map&&this.map.isTexture&&(d.map=this.map.toJSON(a).uuid);
this.matcap&&this.matcap.isTexture&&(d.matcap=this.matcap.toJSON(a).uuid);this.alphaMap&&this.alphaMap.isTexture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap&&this.lightMap.isTexture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.aoMap&&this.aoMap.isTexture&&(d.aoMap=this.aoMap.toJSON(a).uuid,d.aoMapIntensity=this.aoMapIntensity);this.bumpMap&&this.bumpMap.isTexture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);this.normalMap&&this.normalMap.isTexture&&(d.normalMap=
this.normalMap.toJSON(a).uuid,d.normalMapType=this.normalMapType,d.normalScale=this.normalScale.toArray());this.displacementMap&&this.displacementMap.isTexture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,d.displacementBias=this.displacementBias);this.roughnessMap&&this.roughnessMap.isTexture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap&&this.metalnessMap.isTexture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap&&
this.emissiveMap.isTexture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap&&this.specularMap.isTexture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap&&this.envMap.isTexture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity,d.refractionRatio=this.refractionRatio,void 0!==this.combine&&(d.combine=this.combine),void 0!==this.envMapIntensity&&(d.envMapIntensity=this.envMapIntensity));this.gradientMap&&this.gradientMap.isTexture&&(d.gradientMap=this.gradientMap.toJSON(a).uuid);
void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);1!==this.blending&&(d.blending=this.blending);!0===this.flatShading&&(d.flatShading=this.flatShading);0!==this.side&&(d.side=this.side);0!==this.vertexColors&&(d.vertexColors=this.vertexColors);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);d.depthFunc=this.depthFunc;d.depthTest=this.depthTest;d.depthWrite=this.depthWrite;d.stencilWrite=this.stencilWrite;
d.stencilWriteMask=this.stencilWriteMask;d.stencilFunc=this.stencilFunc;d.stencilRef=this.stencilRef;d.stencilFuncMask=this.stencilFuncMask;d.stencilFail=this.stencilFail;d.stencilZFail=this.stencilZFail;d.stencilZPass=this.stencilZPass;this.rotation&&0!==this.rotation&&(d.rotation=this.rotation);!0===this.polygonOffset&&(d.polygonOffset=!0);0!==this.polygonOffsetFactor&&(d.polygonOffsetFactor=this.polygonOffsetFactor);0!==this.polygonOffsetUnits&&(d.polygonOffsetUnits=this.polygonOffsetUnits);this.linewidth&&
1!==this.linewidth&&(d.linewidth=this.linewidth);void 0!==this.dashSize&&(d.dashSize=this.dashSize);void 0!==this.gapSize&&(d.gapSize=this.gapSize);void 0!==this.scale&&(d.scale=this.scale);!0===this.dithering&&(d.dithering=!0);0<this.alphaTest&&(d.alphaTest=this.alphaTest);!0===this.premultipliedAlpha&&(d.premultipliedAlpha=this.premultipliedAlpha);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);"round"!==this.wireframeLinecap&&
(d.wireframeLinecap=this.wireframeLinecap);"round"!==this.wireframeLinejoin&&(d.wireframeLinejoin=this.wireframeLinejoin);!0===this.morphTargets&&(d.morphTargets=!0);!0===this.morphNormals&&(d.morphNormals=!0);!0===this.skinning&&(d.skinning=!0);!1===this.visible&&(d.visible=!1);!1===this.toneMapped&&(d.toneMapped=!1);"{}"!==JSON.stringify(this.userData)&&(d.userData=this.userData);c&&(c=b(a.textures),a=b(a.images),0<c.length&&(d.textures=c),0<a.length&&(d.images=a));return d},clone:function(){return(new this.constructor).copy(this)},
copy:function(a){this.name=a.name;this.fog=a.fog;this.blending=a.blending;this.side=a.side;this.flatShading=a.flatShading;this.vertexColors=a.vertexColors;this.opacity=a.opacity;this.transparent=a.transparent;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.stencilWrite=
a.stencilWrite;this.stencilWriteMask=a.stencilWriteMask;this.stencilFunc=a.stencilFunc;this.stencilRef=a.stencilRef;this.stencilFuncMask=a.stencilFuncMask;this.stencilFail=a.stencilFail;this.stencilZFail=a.stencilZFail;this.stencilZPass=a.stencilZPass;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.dithering=a.dithering;this.alphaTest=a.alphaTest;this.premultipliedAlpha=
a.premultipliedAlpha;this.visible=a.visible;this.toneMapped=a.toneMapped;this.userData=JSON.parse(JSON.stringify(a.userData));this.clipShadows=a.clipShadows;this.clipIntersection=a.clipIntersection;var b=a.clippingPlanes,c=null;if(null!==b){var d=b.length;c=Array(d);for(var e=0;e!==d;++e)c[e]=b[e].clone()}this.clippingPlanes=c;this.shadowSide=a.shadowSide;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});Ga.prototype=Object.create(M.prototype);Ga.prototype.constructor=Ga;Ga.prototype.isMeshBasicMaterial=
!0;Ga.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;
this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};Object.defineProperty(O.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(O.prototype,{isBufferAttribute:!0,onUploadCallback:function(){},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.name=a.name;this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.count=a.count;this.normalized=a.normalized;this.dynamic=a.dynamic;
return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<e;d++)this.array[a+d]=b.array[c+d];return this},copyArray:function(a){this.array.set(a);return this},copyColorsArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",d),f=new H);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyVector2sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<
e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",d),f=new w);b[c++]=f.x;b[c++]=f.y}return this},copyVector3sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",d),f=new n);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z}return this},copyVector4sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",
d),f=new aa);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z;b[c++]=f.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*
this.itemSize+3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,c){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;this.array[a+3]=e;return this},onUpload:function(a){this.onUploadCallback=a;return this},clone:function(){return(new this.constructor(this.array,
this.itemSize)).copy(this)},toJSON:function(){return{itemSize:this.itemSize,type:this.array.constructor.name,array:Array.prototype.slice.call(this.array),normalized:this.normalized}}});xd.prototype=Object.create(O.prototype);xd.prototype.constructor=xd;yd.prototype=Object.create(O.prototype);yd.prototype.constructor=yd;zd.prototype=Object.create(O.prototype);zd.prototype.constructor=zd;Ad.prototype=Object.create(O.prototype);Ad.prototype.constructor=Ad;Tb.prototype=Object.create(O.prototype);Tb.prototype.constructor=
Tb;Bd.prototype=Object.create(O.prototype);Bd.prototype.constructor=Bd;Ub.prototype=Object.create(O.prototype);Ub.prototype.constructor=Ub;A.prototype=Object.create(O.prototype);A.prototype.constructor=A;Cd.prototype=Object.create(O.prototype);Cd.prototype.constructor=Cd;Object.assign(jh.prototype,{computeGroups:function(a){var b=[],c=void 0;a=a.faces;for(var d=0;d<a.length;d++){var e=a[d];if(e.materialIndex!==c){c=e.materialIndex;void 0!==f&&(f.count=3*d-f.start,b.push(f));var f={start:3*d,materialIndex:c}}}void 0!==
f&&(f.count=3*d-f.start,b.push(f));this.groups=b},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length;if(0<h){var l=[];for(var m=0;m<h;m++)l[m]={name:g[m].name,data:[]};this.morphTargets.position=l}var k=a.morphNormals,n=k.length;if(0<n){var t=[];for(m=0;m<n;m++)t[m]={name:k[m].name,data:[]};this.morphTargets.normal=t}var r=a.skinIndices,p=a.skinWeights,v=r.length===c.length,x=p.length===c.length;0<c.length&&
0===b.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(m=0;m<b.length;m++){var z=b[m];this.vertices.push(c[z.a],c[z.b],c[z.c]);var y=z.vertexNormals;3===y.length?this.normals.push(y[0],y[1],y[2]):(y=z.normal,this.normals.push(y,y,y));y=z.vertexColors;3===y.length?this.colors.push(y[0],y[1],y[2]):(y=z.color,this.colors.push(y,y,y));!0===e&&(y=d[0][m],void 0!==y?this.uvs.push(y[0],y[1],y[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",
m),this.uvs.push(new w,new w,new w)));!0===f&&(y=d[1][m],void 0!==y?this.uvs2.push(y[0],y[1],y[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new w,new w,new w)));for(y=0;y<h;y++){var A=g[y].vertices;l[y].data.push(A[z.a],A[z.b],A[z.c])}for(y=0;y<n;y++)A=k[y].vertexNormals[m],t[y].data.push(A.a,A.b,A.c);v&&this.skinIndices.push(r[z.a],r[z.b],r[z.c]);x&&this.skinWeights.push(p[z.a],p[z.b],p[z.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;
this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this}});var Ui=1,kb=new U,Vg=new B,xf=new n,sc=new ab,Wg=new ab,Za=new n;E.prototype=Object.assign(Object.create(Ba.prototype),{constructor:E,isBufferGeometry:!0,getIndex:function(){return this.index},
setIndex:function(a){Array.isArray(a)?this.index=new (65535<kh(a)?Ub:Tb)(a,1):this.index=a},addAttribute:function(a,b,c){return b&&b.isBufferAttribute||b&&b.isInterleavedBufferAttribute?"index"===a?(console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(b),this):this.setAttribute(a,b):(console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new O(b,c)))},getAttribute:function(a){return this.attributes[a]},
setAttribute:function(a,b){this.attributes[a]=b;return this},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,c){this.groups.push({start:a,count:b,materialIndex:void 0!==c?c:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToBufferAttribute(b),b.needsUpdate=!0);var c=this.attributes.normal;void 0!==c&&(b=(new Y).getNormalMatrix(a),
b.applyToBufferAttribute(c),c.needsUpdate=!0);c=this.attributes.tangent;void 0!==c&&(b=(new Y).getNormalMatrix(a),b.applyToBufferAttribute(c),c.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(a){kb.makeRotationX(a);this.applyMatrix(kb);return this},rotateY:function(a){kb.makeRotationY(a);this.applyMatrix(kb);return this},rotateZ:function(a){kb.makeRotationZ(a);this.applyMatrix(kb);return this},
translate:function(a,b,c){kb.makeTranslation(a,b,c);this.applyMatrix(kb);return this},scale:function(a,b,c){kb.makeScale(a,b,c);this.applyMatrix(kb);return this},lookAt:function(a){Vg.lookAt(a);Vg.updateMatrix();this.applyMatrix(Vg.matrix);return this},center:function(){this.computeBoundingBox();this.boundingBox.getCenter(xf).negate();this.translate(xf.x,xf.y,xf.z);return this},setFromObject:function(a){var b=a.geometry;if(a.isPoints||a.isLine){a=new A(3*b.vertices.length,3);var c=new A(3*b.colors.length,
3);this.addAttribute("position",a.copyVector3sArray(b.vertices));this.addAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new A(b.lineDistances.length,1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&(this.boundingBox=b.boundingBox.clone())}else a.isMesh&&b&&b.isGeometry&&this.fromGeometry(b);return this},setFromPoints:function(a){for(var b=
[],c=0,d=a.length;c<d;c++){var e=a[c];b.push(e.x,e.y,e.z||0)}this.addAttribute("position",new A(b,3));return this},updateFromObject:function(a){var b=a.geometry;if(a.isMesh){var c=b.__directGeometry;!0===b.elementsNeedUpdate&&(c=void 0,b.elementsNeedUpdate=!1);if(void 0===c)return this.fromGeometry(b);c.verticesNeedUpdate=b.verticesNeedUpdate;c.normalsNeedUpdate=b.normalsNeedUpdate;c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=
!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=!1;b.uvsNeedUpdate=!1;b.groupsNeedUpdate=!1;b=c}!0===b.verticesNeedUpdate&&(c=this.attributes.position,void 0!==c&&(c.copyVector3sArray(b.vertices),c.needsUpdate=!0),b.verticesNeedUpdate=!1);!0===b.normalsNeedUpdate&&(c=this.attributes.normal,void 0!==c&&(c.copyVector3sArray(b.normals),c.needsUpdate=!0),b.normalsNeedUpdate=!1);!0===b.colorsNeedUpdate&&(c=this.attributes.color,void 0!==c&&(c.copyColorsArray(b.colors),c.needsUpdate=!0),b.colorsNeedUpdate=
!1);b.uvsNeedUpdate&&(c=this.attributes.uv,void 0!==c&&(c.copyVector2sArray(b.uvs),c.needsUpdate=!0),b.uvsNeedUpdate=!1);b.lineDistancesNeedUpdate&&(c=this.attributes.lineDistance,void 0!==c&&(c.copyArray(b.lineDistances),c.needsUpdate=!0),b.lineDistancesNeedUpdate=!1);b.groupsNeedUpdate&&(b.computeGroups(a.geometry),this.groups=b.groups,b.groupsNeedUpdate=!1);return this},fromGeometry:function(a){a.__directGeometry=(new jh).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=
new Float32Array(3*a.vertices.length);this.addAttribute("position",(new O(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new O(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),this.addAttribute("color",(new O(b,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new O(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=
new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new O(b,2)).copyVector2sArray(a.uvs2)));this.groups=a.groups;for(var c in a.morphTargets){b=[];for(var d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new A(3*g.data.length,3);h.name=g.name;b.push(h.copyVector3sArray(g.data))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new A(4*a.skinIndices.length,4),this.addAttribute("skinIndex",c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new A(4*a.skinWeights.length,
4),this.addAttribute("skinWeight",c.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ab);var a=this.attributes.position,b=this.morphAttributes.position;if(void 0!==a){if(this.boundingBox.setFromBufferAttribute(a),b){a=0;for(var c=b.length;a<c;a++)sc.setFromBufferAttribute(b[a]),this.boundingBox.expandByPoint(sc.min),
this.boundingBox.expandByPoint(sc.max)}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new nb);var a=this.attributes.position,b=this.morphAttributes.position;if(a){var c=this.boundingSphere.center;
sc.setFromBufferAttribute(a);if(b)for(var d=0,e=b.length;d<e;d++){var f=b[d];Wg.setFromBufferAttribute(f);sc.expandByPoint(Wg.min);sc.expandByPoint(Wg.max)}sc.getCenter(c);var g=0;d=0;for(e=a.count;d<e;d++)Za.fromBufferAttribute(a,d),g=Math.max(g,c.distanceToSquared(Za));if(b)for(d=0,e=b.length;d<e;d++){f=b[d];a=0;for(var h=f.count;a<h;a++)Za.fromBufferAttribute(f,a),g=Math.max(g,c.distanceToSquared(Za))}this.boundingSphere.radius=Math.sqrt(g);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',
this)}},computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,b=this.attributes;if(b.position){var c=b.position.array;if(void 0===b.normal)this.addAttribute("normal",new O(new Float32Array(c.length),3));else for(var d=b.normal.array,e=0,f=d.length;e<f;e++)d[e]=0;d=b.normal.array;var g=new n,h=new n,l=new n,m=new n,k=new n;if(a){var u=a.array;e=0;for(f=a.count;e<f;e+=3){a=3*u[e+0];var t=3*u[e+1];var r=3*u[e+2];g.fromArray(c,a);h.fromArray(c,t);l.fromArray(c,r);m.subVectors(l,
h);k.subVectors(g,h);m.cross(k);d[a]+=m.x;d[a+1]+=m.y;d[a+2]+=m.z;d[t]+=m.x;d[t+1]+=m.y;d[t+2]+=m.z;d[r]+=m.x;d[r+1]+=m.y;d[r+2]+=m.z}}else for(e=0,f=c.length;e<f;e+=9)g.fromArray(c,e),h.fromArray(c,e+3),l.fromArray(c,e+6),m.subVectors(l,h),k.subVectors(g,h),m.cross(k),d[e]=m.x,d[e+1]=m.y,d[e+2]=m.z,d[e+3]=m.x,d[e+4]=m.y,d[e+5]=m.z,d[e+6]=m.x,d[e+7]=m.y,d[e+8]=m.z;this.normalizeNormals();b.normal.needsUpdate=!0}},merge:function(a,b){if(a&&a.isBufferGeometry){void 0===b&&(b=0,console.warn("THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge."));
var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d]){var e=c[d].array,f=a.attributes[d],g=f.array,h=f.itemSize*b;f=Math.min(g.length,e.length-h);for(var l=0;l<f;l++,h++)e[h]=g[l]}return this}console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a)},normalizeNormals:function(){for(var a=this.attributes.normal,b=0,c=a.count;b<c;b++)Za.x=a.getX(b),Za.y=a.getY(b),Za.z=a.getZ(b),Za.normalize(),a.setXYZ(b,Za.x,Za.y,Za.z)},toNonIndexed:function(){function a(a,
b){var c=a.array;a=a.itemSize;for(var d=new c.constructor(b.length*a),e,f=0,g=0,h=b.length;g<h;g++){e=b[g]*a;for(var l=0;l<a;l++)d[f++]=c[e++]}return new O(d,a)}if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var b=new E,c=this.index.array,d=this.attributes,e;for(e in d){var f=d[e];f=a(f,c);b.addAttribute(e,f)}var g=this.morphAttributes;for(e in g){var h=[],l=g[e];d=0;for(var m=l.length;d<m;d++)f=l[d],f=a(f,c),h.push(f);b.morphAttributes[e]=
h}c=this.groups;d=0;for(e=c.length;d<e;d++)f=c[d],b.addGroup(f.start,f.count,f.materialIndex);return b},toJSON:function(){var a={metadata:{version:4.5,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);0<Object.keys(this.userData).length&&(a.userData=this.userData);if(void 0!==this.parameters){var b=this.parameters;for(m in b)void 0!==b[m]&&(a[m]=b[m]);return a}a.data={attributes:{}};b=this.index;null!==b&&(a.data.index={type:b.array.constructor.name,
array:Array.prototype.slice.call(b.array)});var c=this.attributes;for(m in c){b=c[m];var d=b.toJSON();""!==b.name&&(d.name=b.name);a.data.attributes[m]=d}c={};var e=!1;for(m in this.morphAttributes){for(var f=this.morphAttributes[m],g=[],h=0,l=f.length;h<l;h++)b=f[h],d=b.toJSON(),""!==b.name&&(d.name=b.name),g.push(d);0<g.length&&(c[m]=g,e=!0)}e&&(a.data.morphAttributes=c);var m=this.groups;0<m.length&&(a.data.groups=JSON.parse(JSON.stringify(m)));m=this.boundingSphere;null!==m&&(a.data.boundingSphere=
{center:m.center.toArray(),radius:m.radius});return a},clone:function(){return(new E).copy(this)},copy:function(a){var b;this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var c=a.index;null!==c&&this.setIndex(c.clone());c=a.attributes;for(g in c)this.addAttribute(g,c[g].clone());var d=a.morphAttributes;for(g in d){var e=[],f=d[g];c=0;for(b=f.length;c<b;c++)e.push(f[c].clone());this.morphAttributes[g]=e}var g=a.groups;
c=0;for(b=g.length;c<b;c++)d=g[c],this.addGroup(d.start,d.count,d.materialIndex);g=a.boundingBox;null!==g&&(this.boundingBox=g.clone());g=a.boundingSphere;null!==g&&(this.boundingSphere=g.clone());this.drawRange.start=a.drawRange.start;this.drawRange.count=a.drawRange.count;this.userData=a.userData;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});var ti=new U,tc=new Sb,Xg=new nb,Vb=new n,Wb=new n,Xb=new n,mh=new n,nh=new n,oh=new n,Uf=new n,Vf=new n,Wf=new n,Ac=new w,Bc=new w,
Cc=new w,Dd=new n,Ee=new n;ja.prototype=Object.assign(Object.create(B.prototype),{constructor:ja,isMesh:!0,setDrawMode:function(a){this.drawMode=a},copy:function(a){B.prototype.copy.call(this,a);this.drawMode=a.drawMode;void 0!==a.morphTargetInfluences&&(this.morphTargetInfluences=a.morphTargetInfluences.slice());void 0!==a.morphTargetDictionary&&(this.morphTargetDictionary=Object.assign({},a.morphTargetDictionary));return this},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=
a.morphAttributes;var b=Object.keys(a);if(0<b.length){var c=a[b[0]];if(void 0!==c)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++){var d=c[a].name||String(a);this.morphTargetInfluences.push(0);this.morphTargetDictionary[d]=a}}}else a=a.morphTargets,void 0!==a&&0<a.length&&console.error("THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")},raycast:function(a,b){var c=this.geometry,d=this.material,e=this.matrixWorld;
if(void 0!==d&&(null===c.boundingSphere&&c.computeBoundingSphere(),Xg.copy(c.boundingSphere),Xg.applyMatrix4(e),!1!==a.ray.intersectsSphere(Xg)&&(ti.getInverse(e),tc.copy(a.ray).applyMatrix4(ti),null===c.boundingBox||!1!==tc.intersectsBox(c.boundingBox))))if(c.isBufferGeometry){var f=c.index;e=c.attributes.position;var g=c.morphAttributes.position,h=c.attributes.uv,l=c.attributes.uv2,m=c.groups,k=c.drawRange,n,t;if(null!==f)if(Array.isArray(d)){var r=0;for(n=m.length;r<n;r++){var p=m[r];var v=d[p.materialIndex];
var x=Math.max(p.start,k.start);for(t=c=Math.min(p.start+p.count,k.start+k.count);x<t;x+=3){c=f.getX(x);var z=f.getX(x+1);var y=f.getX(x+2);if(c=Fe(this,v,a,tc,e,g,h,l,c,z,y))c.faceIndex=Math.floor(x/3),c.face.materialIndex=p.materialIndex,b.push(c)}}}else for(x=Math.max(0,k.start),c=Math.min(f.count,k.start+k.count),r=x,n=c;r<n;r+=3){if(c=f.getX(r),z=f.getX(r+1),y=f.getX(r+2),c=Fe(this,d,a,tc,e,g,h,l,c,z,y))c.faceIndex=Math.floor(r/3),b.push(c)}else if(void 0!==e)if(Array.isArray(d))for(r=0,n=m.length;r<
n;r++)for(p=m[r],v=d[p.materialIndex],x=Math.max(p.start,k.start),t=c=Math.min(p.start+p.count,k.start+k.count);x<t;x+=3){if(c=x,z=x+1,y=x+2,c=Fe(this,v,a,tc,e,g,h,l,c,z,y))c.faceIndex=Math.floor(x/3),c.face.materialIndex=p.materialIndex,b.push(c)}else for(x=Math.max(0,k.start),c=Math.min(e.count,k.start+k.count),r=x,n=c;r<n;r+=3)if(c=r,z=r+1,y=r+2,c=Fe(this,d,a,tc,e,g,h,l,c,z,y))c.faceIndex=Math.floor(r/3),b.push(c)}else if(c.isGeometry)for(e=Array.isArray(d),g=c.vertices,h=c.faces,c=c.faceVertexUvs[0],
0<c.length&&(f=c),r=0,n=h.length;r<n;r++)if(p=h[r],c=e?d[p.materialIndex]:d,void 0!==c&&(l=g[p.a],m=g[p.b],k=g[p.c],c=lh(this,c,a,tc,l,m,k,Dd)))f&&f[r]&&(v=f[r],Ac.copy(v[0]),Bc.copy(v[1]),Cc.copy(v[2]),c.uv=R.getUV(Dd,l,m,k,Ac,Bc,Cc,new w)),c.face=p,c.faceIndex=r,b.push(c)},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Vi=0,lb=new U,Yg=new B,yf=new n;F.prototype=Object.assign(Object.create(Ba.prototype),{constructor:F,isGeometry:!0,applyMatrix:function(a){for(var b=
(new Y).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);c=0;for(d=this.faces.length;c<d;c++){a=this.faces[c];a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(a){lb.makeRotationX(a);this.applyMatrix(lb);
return this},rotateY:function(a){lb.makeRotationY(a);this.applyMatrix(lb);return this},rotateZ:function(a){lb.makeRotationZ(a);this.applyMatrix(lb);return this},translate:function(a,b,c){lb.makeTranslation(a,b,c);this.applyMatrix(lb);return this},scale:function(a,b,c){lb.makeScale(a,b,c);this.applyMatrix(lb);return this},lookAt:function(a){Yg.lookAt(a);Yg.updateMatrix();this.applyMatrix(Yg.matrix);return this},fromBufferGeometry:function(a){function b(a,b,d,e){var f=void 0===h?[]:[c.colors[a].clone(),
c.colors[b].clone(),c.colors[d].clone()],k=void 0===g?[]:[(new n).fromArray(g,3*a),(new n).fromArray(g,3*b),(new n).fromArray(g,3*d)];e=new zc(a,b,d,k,f,e);c.faces.push(e);void 0!==l&&c.faceVertexUvs[0].push([(new w).fromArray(l,2*a),(new w).fromArray(l,2*b),(new w).fromArray(l,2*d)]);void 0!==m&&c.faceVertexUvs[1].push([(new w).fromArray(m,2*a),(new w).fromArray(m,2*b),(new w).fromArray(m,2*d)])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes;if(void 0===e.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),
this;var f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,l=void 0!==e.uv?e.uv.array:void 0,m=void 0!==e.uv2?e.uv2.array:void 0;void 0!==m&&(this.faceVertexUvs[1]=[]);for(e=0;e<f.length;e+=3)c.vertices.push((new n).fromArray(f,e)),void 0!==h&&c.colors.push((new H).fromArray(h,e));var k=a.groups;if(0<k.length)for(e=0;e<k.length;e++){f=k[e];var u=f.start,t=u;for(u+=f.count;t<u;t+=3)void 0!==d?b(d[t],d[t+1],d[t+2],f.materialIndex):b(t,t+1,t+2,f.materialIndex)}else if(void 0!==
d)for(e=0;e<d.length;e+=3)b(d[e],d[e+1],d[e+2]);else for(e=0;e<f.length/3;e+=3)b(e,e+1,e+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());return this},center:function(){this.computeBoundingBox();this.boundingBox.getCenter(yf).negate();this.translate(yf.x,yf.y,yf.z);return this},normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius;
b=0===b?1:1/b;var c=new U;c.set(b,0,0,-b*a.x,0,b,0,-b*a.y,0,0,b,-b*a.z,0,0,0,1);this.applyMatrix(c);return this},computeFaceNormals:function(){for(var a=new n,b=new n,c=0,d=this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g);b.subVectors(f,g);a.cross(b);a.normalize();e.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var b;var c=Array(this.vertices.length);var d=0;for(b=this.vertices.length;d<b;d++)c[d]=new n;
if(a){var e=new n,f=new n;a=0;for(d=this.faces.length;a<d;a++){b=this.faces[a];var g=this.vertices[b.a];var h=this.vertices[b.b];var l=this.vertices[b.c];e.subVectors(l,h);f.subVectors(g,h);e.cross(f);c[b.a].add(e);c[b.b].add(e);c[b.c].add(e)}}else for(this.computeFaceNormals(),a=0,d=this.faces.length;a<d;a++)b=this.faces[a],c[b.a].add(b.normal),c[b.b].add(b.normal),c[b.c].add(b.normal);d=0;for(b=this.vertices.length;d<b;d++)c[d].normalize();a=0;for(d=this.faces.length;a<d;a++)b=this.faces[a],g=b.vertexNormals,
3===g.length?(g[0].copy(c[b.a]),g[1].copy(c[b.b]),g[2].copy(c[b.c])):(g[0]=c[b.a].clone(),g[1]=c[b.b].clone(),g[2]=c[b.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeFlatVertexNormals:function(){var a;this.computeFaceNormals();var b=0;for(a=this.faces.length;b<a;b++){var c=this.faces[b];var d=c.vertexNormals;3===d.length?(d[0].copy(c.normal),d[1].copy(c.normal),d[2].copy(c.normal)):(d[0]=c.normal.clone(),d[1]=c.normal.clone(),d[2]=c.normal.clone())}0<this.faces.length&&(this.normalsNeedUpdate=
!0)},computeMorphNormals:function(){var a,b;var c=0;for(b=this.faces.length;c<b;c++){var d=this.faces[c];d.__originalFaceNormal?d.__originalFaceNormal.copy(d.normal):d.__originalFaceNormal=d.normal.clone();d.__originalVertexNormals||(d.__originalVertexNormals=[]);var e=0;for(a=d.vertexNormals.length;e<a;e++)d.__originalVertexNormals[e]?d.__originalVertexNormals[e].copy(d.vertexNormals[e]):d.__originalVertexNormals[e]=d.vertexNormals[e].clone()}var f=new F;f.faces=this.faces;e=0;for(a=this.morphTargets.length;e<
a;e++){if(!this.morphNormals[e]){this.morphNormals[e]={};this.morphNormals[e].faceNormals=[];this.morphNormals[e].vertexNormals=[];d=this.morphNormals[e].faceNormals;var g=this.morphNormals[e].vertexNormals;c=0;for(b=this.faces.length;c<b;c++){var h=new n;var l={a:new n,b:new n,c:new n};d.push(h);g.push(l)}}g=this.morphNormals[e];f.vertices=this.morphTargets[e].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],h=g.faceNormals[c],l=g.vertexNormals[c],
h.copy(d.normal),l.a.copy(d.vertexNormals[0]),l.b.copy(d.vertexNormals[1]),l.c.copy(d.vertexNormals[2])}c=0;for(b=this.faces.length;c<b;c++)d=this.faces[c],d.normal=d.__originalFaceNormal,d.vertexNormals=d.__originalVertexNormals},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new ab);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new nb);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,
b,c){if(a&&a.isGeometry){var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,l=a.faces,m=this.colors,k=a.colors;void 0===c&&(c=0);void 0!==b&&(d=(new Y).getNormalMatrix(b));for(var n=0,t=g.length;n<t;n++){var r=g[n].clone();void 0!==b&&r.applyMatrix4(b);f.push(r)}n=0;for(t=k.length;n<t;n++)m.push(k[n].clone());n=0;for(t=l.length;n<t;n++){g=l[n];var p=g.vertexNormals;k=g.vertexColors;m=new zc(g.a+e,g.b+e,g.c+e);m.normal.copy(g.normal);void 0!==d&&m.normal.applyMatrix3(d).normalize();
b=0;for(f=p.length;b<f;b++)r=p[b].clone(),void 0!==d&&r.applyMatrix3(d).normalize(),m.vertexNormals.push(r);m.color.copy(g.color);b=0;for(f=k.length;b<f;b++)r=k[b],m.vertexColors.push(r.clone());m.materialIndex=g.materialIndex+c;h.push(m)}n=0;for(t=a.faceVertexUvs.length;n<t;n++)for(c=a.faceVertexUvs[n],void 0===this.faceVertexUvs[n]&&(this.faceVertexUvs[n]=[]),b=0,f=c.length;b<f;b++){d=c[b];e=[];h=0;for(l=d.length;h<l;h++)e.push(d[h].clone());this.faceVertexUvs[n].push(e)}}else console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",
a)},mergeMesh:function(a){a&&a.isMesh?(a.matrixAutoUpdate&&a.updateMatrix(),this.merge(a.geometry,a.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",a)},mergeVertices:function(){var a={},b=[],c=[],d=Math.pow(10,4),e;var f=0;for(e=this.vertices.length;f<e;f++){var g=this.vertices[f];g=Math.round(g.x*d)+"_"+Math.round(g.y*d)+"_"+Math.round(g.z*d);void 0===a[g]?(a[g]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[g]]}a=[];f=0;for(e=this.faces.length;f<e;f++)for(d=
this.faces[f],d.a=c[d.a],d.b=c[d.b],d.c=c[d.c],d=[d.a,d.b,d.c],g=0;3>g;g++)if(d[g]===d[(g+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(d=a[f],this.faces.splice(d,1),c=0,e=this.faceVertexUvs.length;c<e;c++)this.faceVertexUvs[c].splice(d,1);f=this.vertices.length-b.length;this.vertices=b;return f},setFromPoints:function(a){this.vertices=[];for(var b=0,c=a.length;b<c;b++){var d=a[b];this.vertices.push(new n(d.x,d.y,d.z||0))}return this},sortFacesByMaterialIndex:function(){for(var a=this.faces,
b=a.length,c=0;c<b;c++)a[c]._id=c;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var d=this.faceVertexUvs[0],e=this.faceVertexUvs[1],f,g;d&&d.length===b&&(f=[]);e&&e.length===b&&(g=[]);for(c=0;c<b;c++){var h=a[c]._id;f&&f.push(d[h]);g&&g.push(e[h])}f&&(this.faceVertexUvs[0]=f);g&&(this.faceVertexUvs[1]=g)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==k[b])return k[b];k[b]=l.length/3;l.push(a.x,
a.y,a.z);return k[b]}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==u[b])return u[b];u[b]=n.length;n.push(a.getHex());return u[b]}function d(a){var b=a.x.toString()+a.y.toString();if(void 0!==r[b])return r[b];r[b]=t.length/2;t.push(a.x,a.y);return r[b]}var e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==this.parameters){var f=this.parameters,g;for(g in f)void 0!==f[g]&&
(e[g]=f[g]);return e}f=[];for(g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}h=[];var l=[],k={},n=[],u={},t=[],r={};for(g=0;g<this.faces.length;g++){var p=this.faces[g],v=void 0!==this.faceVertexUvs[0][g],x=0<p.normal.length(),z=0<p.vertexNormals.length,y=1!==p.color.r||1!==p.color.g||1!==p.color.b,w=0<p.vertexColors.length,A=0;A=a(A,0,0);A=a(A,1,!0);A=a(A,2,!1);A=a(A,3,v);A=a(A,4,x);A=a(A,5,z);A=a(A,6,y);A=a(A,7,w);h.push(A);h.push(p.a,p.b,p.c);h.push(p.materialIndex);
v&&(v=this.faceVertexUvs[0][g],h.push(d(v[0]),d(v[1]),d(v[2])));x&&h.push(b(p.normal));z&&(x=p.vertexNormals,h.push(b(x[0]),b(x[1]),b(x[2])));y&&h.push(c(p.color));w&&(p=p.vertexColors,h.push(c(p[0]),c(p[1]),c(p[2])))}e.data={};e.data.vertices=f;e.data.normals=l;0<n.length&&(e.data.colors=n);0<t.length&&(e.data.uvs=[t]);e.data.faces=h;return e},clone:function(){return(new F).copy(this)},copy:function(a){var b,c,d;this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=
[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.name=a.name;var e=a.vertices;var f=0;for(b=e.length;f<b;f++)this.vertices.push(e[f].clone());e=a.colors;f=0;for(b=e.length;f<b;f++)this.colors.push(e[f].clone());e=a.faces;f=0;for(b=e.length;f<b;f++)this.faces.push(e[f].clone());f=0;for(b=a.faceVertexUvs.length;f<b;f++){var g=a.faceVertexUvs[f];void 0===this.faceVertexUvs[f]&&(this.faceVertexUvs[f]=[]);e=0;for(c=g.length;e<
c;e++){var h=g[e],l=[];var k=0;for(d=h.length;k<d;k++)l.push(h[k].clone());this.faceVertexUvs[f].push(l)}}k=a.morphTargets;f=0;for(b=k.length;f<b;f++){d={};d.name=k[f].name;if(void 0!==k[f].vertices)for(d.vertices=[],e=0,c=k[f].vertices.length;e<c;e++)d.vertices.push(k[f].vertices[e].clone());if(void 0!==k[f].normals)for(d.normals=[],e=0,c=k[f].normals.length;e<c;e++)d.normals.push(k[f].normals[e].clone());this.morphTargets.push(d)}k=a.morphNormals;f=0;for(b=k.length;f<b;f++){d={};if(void 0!==k[f].vertexNormals)for(d.vertexNormals=
[],e=0,c=k[f].vertexNormals.length;e<c;e++)g=k[f].vertexNormals[e],h={},h.a=g.a.clone(),h.b=g.b.clone(),h.c=g.c.clone(),d.vertexNormals.push(h);if(void 0!==k[f].faceNormals)for(d.faceNormals=[],e=0,c=k[f].faceNormals.length;e<c;e++)d.faceNormals.push(k[f].faceNormals[e].clone());this.morphNormals.push(d)}e=a.skinWeights;f=0;for(b=e.length;f<b;f++)this.skinWeights.push(e[f].clone());e=a.skinIndices;f=0;for(b=e.length;f<b;f++)this.skinIndices.push(e[f].clone());e=a.lineDistances;f=0;for(b=e.length;f<
b;f++)this.lineDistances.push(e[f]);f=a.boundingBox;null!==f&&(this.boundingBox=f.clone());f=a.boundingSphere;null!==f&&(this.boundingSphere=f.clone());this.elementsNeedUpdate=a.elementsNeedUpdate;this.verticesNeedUpdate=a.verticesNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.lineDistancesNeedUpdate=a.lineDistancesNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}});
var Zg=function(a){function b(b,d,e,f,g,h){a.call(this);this.type="BoxGeometry";this.parameters={width:b,height:d,depth:e,widthSegments:f,heightSegments:g,depthSegments:h};this.fromBufferGeometry(new Gd(b,d,e,f,g,h));this.mergeVertices()}a&&(b.__proto__=a);b.prototype=Object.create(a&&a.prototype);return b.prototype.constructor=b}(F),Gd=function(a){function b(b,d,e,f,g,h){function c(a,b,c,d,e,f,g,h,l,m,w){var x=f/l,z=g/m,y=f/2,A=g/2,C=h/2;g=l+1;var B=m+1,E=f=0,D,F,G=new n;for(F=0;F<B;F++){var H=F*
z-A;for(D=0;D<g;D++)G[a]=(D*x-y)*d,G[b]=H*e,G[c]=C,u.push(G.x,G.y,G.z),G[a]=0,G[b]=0,G[c]=0<h?1:-1,t.push(G.x,G.y,G.z),r.push(D/l),r.push(1-F/m),f+=1}for(F=0;F<m;F++)for(D=0;D<l;D++)a=p+D+g*(F+1),b=p+(D+1)+g*(F+1),c=p+(D+1)+g*F,q.push(p+D+g*F,a,c),q.push(a,b,c),E+=6;k.addGroup(v,E,w);v+=E;p+=f}a.call(this);this.type="BoxBufferGeometry";this.parameters={width:b,height:d,depth:e,widthSegments:f,heightSegments:g,depthSegments:h};var k=this;b=b||1;d=d||1;e=e||1;f=Math.floor(f)||1;g=Math.floor(g)||1;h=
Math.floor(h)||1;var q=[],u=[],t=[],r=[],p=0,v=0;c("z","y","x",-1,-1,e,d,b,h,g,0);c("z","y","x",1,-1,e,d,-b,h,g,1);c("x","z","y",1,1,b,e,d,f,h,2);c("x","z","y",1,-1,b,e,-d,f,h,3);c("x","y","z",1,-1,b,d,e,f,g,4);c("x","y","z",-1,-1,b,d,-e,f,g,5);this.setIndex(q);this.addAttribute("position",new A(u,3));this.addAttribute("normal",new A(t,3));this.addAttribute("uv",new A(r,2))}a&&(b.__proto__=a);b.prototype=Object.create(a&&a.prototype);return b.prototype.constructor=b}(E),Ak={clone:Yb,merge:Da};ma.prototype=
Object.create(M.prototype);ma.prototype.constructor=ma;ma.prototype.isShaderMaterial=!0;ma.prototype.copy=function(a){M.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=Yb(a.uniforms);this.defines=Object.assign({},a.defines);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.lights=a.lights;this.clipping=a.clipping;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;this.extensions=
a.extensions;return this};ma.prototype.toJSON=function(a){var b=M.prototype.toJSON.call(this,a);b.uniforms={};for(var c in this.uniforms){var d=this.uniforms[c].value;b.uniforms[c]=d&&d.isTexture?{type:"t",value:d.toJSON(a).uuid}:d&&d.isColor?{type:"c",value:d.getHex()}:d&&d.isVector2?{type:"v2",value:d.toArray()}:d&&d.isVector3?{type:"v3",value:d.toArray()}:d&&d.isVector4?{type:"v4",value:d.toArray()}:d&&d.isMatrix3?{type:"m3",value:d.toArray()}:d&&d.isMatrix4?{type:"m4",value:d.toArray()}:{value:d}}0<
Object.keys(this.defines).length&&(b.defines=this.defines);b.vertexShader=this.vertexShader;b.fragmentShader=this.fragmentShader;a={};for(var e in this.extensions)!0===this.extensions[e]&&(a[e]=!0);0<Object.keys(a).length&&(b.extensions=a);return b};bb.prototype=Object.assign(Object.create(B.prototype),{constructor:bb,isCamera:!0,copy:function(a,b){B.prototype.copy.call(this,a,b);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);this.projectionMatrixInverse.copy(a.projectionMatrixInverse);
return this},getWorldDirection:function(a){void 0===a&&(console.warn("THREE.Camera: .getWorldDirection() target is now required"),a=new n);this.updateMatrixWorld(!0);var b=this.matrixWorld.elements;return a.set(-b[8],-b[9],-b[10]).normalize()},updateMatrixWorld:function(a){B.prototype.updateMatrixWorld.call(this,a);this.matrixWorldInverse.getInverse(this.matrixWorld)},clone:function(){return(new this.constructor).copy(this)}});na.prototype=Object.assign(Object.create(bb.prototype),{constructor:na,
isPerspectiveCamera:!0,copy:function(a,b){bb.prototype.copy.call(this,a,b);this.fov=a.fov;this.zoom=a.zoom;this.near=a.near;this.far=a.far;this.focus=a.focus;this.aspect=a.aspect;this.view=null===a.view?null:Object.assign({},a.view);this.filmGauge=a.filmGauge;this.filmOffset=a.filmOffset;return this},setFocalLength:function(a){a=.5*this.getFilmHeight()/a;this.fov=2*L.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()},getFocalLength:function(){var a=Math.tan(.5*L.DEG2RAD*this.fov);return.5*this.getFilmHeight()/
a},getEffectiveFOV:function(){return 2*L.RAD2DEG*Math.atan(Math.tan(.5*L.DEG2RAD*this.fov)/this.zoom)},getFilmWidth:function(){return this.filmGauge*Math.min(this.aspect,1)},getFilmHeight:function(){return this.filmGauge/Math.max(this.aspect,1)},setViewOffset:function(a,b,c,d,e,f){this.aspect=a/b;null===this.view&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=
d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=this.near,b=a*Math.tan(.5*L.DEG2RAD*this.fov)/this.zoom,c=2*b,d=this.aspect*c,e=-.5*d,f=this.view;if(null!==this.view&&this.view.enabled){var g=f.fullWidth,h=f.fullHeight;e+=f.offsetX*d/g;b-=f.offsetY*c/h;d*=f.width/g;c*=f.height/h}f=this.filmOffset;0!==f&&(e+=a*f/this.getFilmWidth());this.projectionMatrix.makePerspective(e,
e+d,b,b-c,a,this.far);this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(a){a=B.prototype.toJSON.call(this,a);a.object.fov=this.fov;a.object.zoom=this.zoom;a.object.near=this.near;a.object.far=this.far;a.object.focus=this.focus;a.object.aspect=this.aspect;null!==this.view&&(a.object.view=Object.assign({},this.view));a.object.filmGauge=this.filmGauge;a.object.filmOffset=this.filmOffset;return a}});Dc.prototype=Object.create(B.prototype);Dc.prototype.constructor=Dc;Ab.prototype=
Object.create(la.prototype);Ab.prototype.constructor=Ab;Ab.prototype.isWebGLRenderTargetCube=!0;Ab.prototype.fromEquirectangularTexture=function(a,b){this.texture.type=b.type;this.texture.format=b.format;this.texture.encoding=b.encoding;var c=new wd,d=new ma({type:"CubemapFromEquirect",uniforms:Yb({tEquirect:{value:null}}),vertexShader:"varying vec3 vWorldDirection;\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",
fragmentShader:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n}",side:1,blending:0});d.uniforms.tEquirect.value=b;b=new ja(new Gd(5,
5,5),d);c.add(b);d=new Dc(1,10,1);d.renderTarget=this;d.renderTarget.texture.name="CubeCameraTexture";d.update(a,c);b.geometry.dispose();b.material.dispose();return this};Zb.prototype=Object.create(W.prototype);Zb.prototype.constructor=Zb;Zb.prototype.isDataTexture=!0;var $g=new n,Bk=new n,Ck=new Y;Object.assign(cb.prototype,{isPlane:!0,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,
b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(a,b,c){b=$g.subVectors(c,b).cross(Bk.subVectors(a,b)).normalize();this.setFromNormalAndCoplanarPoint(b,a);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=
-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){void 0===b&&(console.warn("THREE.Plane: .projectPoint() target is now required"),b=new n);return b.copy(this.normal).multiplyScalar(-this.distanceToPoint(a)).add(a)},intersectLine:function(a,b){void 0===b&&(console.warn("THREE.Plane: .intersectLine() target is now required"),b=new n);var c=
a.delta($g),d=this.normal.dot(c);if(0===d){if(0===this.distanceToPoint(a.start))return b.copy(a.start)}else if(d=-(a.start.dot(this.normal)+this.constant)/d,!(0>d||1<d))return b.copy(c).multiplyScalar(d).add(a.start)},intersectsLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){void 0===a&&(console.warn("THREE.Plane: .coplanarPoint() target is now required"),
a=new n);return a.copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(a,b){b=b||Ck.getNormalMatrix(a);a=this.coplanarPoint($g).applyMatrix4(a);b=this.normal.applyMatrix3(b).normalize();this.constant=-a.dot(b);return this},translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}});var td=new nb,zf=new n;Object.assign(Ed.prototype,{set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);
g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],l=c[6],k=c[7],n=c[8],u=c[9],t=c[10],r=c[11],p=c[12],v=c[13],x=c[14];c=c[15];b[0].setComponents(f-a,k-g,r-n,c-p).normalize();b[1].setComponents(f+a,k+g,r+n,c+p).normalize();b[2].setComponents(f+
d,k+h,r+u,c+v).normalize();b[3].setComponents(f-d,k-h,r-u,c-v).normalize();b[4].setComponents(f-e,k-l,r-t,c-x).normalize();b[5].setComponents(f+e,k+l,r+t,c+x).normalize();return this},intersectsObject:function(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();td.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);return this.intersectsSphere(td)},intersectsSprite:function(a){td.center.set(0,0,0);td.radius=.7071067811865476;td.applyMatrix4(a.matrixWorld);return this.intersectsSphere(td)},
intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(a){for(var b=this.planes,c=0;6>c;c++){var d=b[c];zf.x=0<d.normal.x?a.max.x:a.min.x;zf.y=0<d.normal.y?a.max.y:a.min.y;zf.z=0<d.normal.z?a.max.z:a.min.z;if(0>d.distanceToPoint(zf))return!1}return!0},containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}});var N={alphamap_fragment:"#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif",
alphamap_pars_fragment:"#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif",alphatest_fragment:"#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif",aomap_fragment:"#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif",
aomap_pars_fragment:"#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif",begin_vertex:"vec3 transformed = vec3( position );",beginnormal_vertex:"vec3 objectNormal = vec3( normal );\n#ifdef USE_TANGENT\n\tvec3 objectTangent = vec3( tangent.xyz );\n#endif",bsdfs:"vec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\tif( cutoffDistance > 0.0 ) {\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t}\n\treturn distanceFalloff;\n#else\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n#endif\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\treturn Fr * fresnel + F0;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\tconst float LUT_SIZE  = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS  = 0.5 / LUT_SIZE;\n\tfloat dotNV = saturate( dot( N, V ) );\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\treturn uv;\n}\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\tfloat l = length( f );\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n}\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\tfloat x = dot( v1, v2 );\n\tfloat y = abs( x );\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\treturn cross( v1, v2 ) * theta_sintheta;\n}\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 );\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\treturn vec3( result );\n}\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\treturn specularColor * brdf.x + brdf.y;\n}\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619;\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n#if defined( USE_SHEEN )\nfloat D_Charlie(float roughness, float NoH) {\n\tfloat invAlpha  = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125);\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\nfloat V_Neubelt(float NoV, float NoL) {\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n}\n#endif",
bumpmap_pars_fragment:"#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif",
clipping_planes_fragment:"#if NUM_CLIPPING_PLANES > 0\n\tvec4 plane;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\t\tbool clipped = true;\n\t\t#pragma unroll_loop\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vViewPosition, plane.xyz ) > plane.w ) && clipped;\n\t\t}\n\t\tif ( clipped ) discard;\n\t#endif\n#endif",
clipping_planes_pars_fragment:"#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif",clipping_planes_pars_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvarying vec3 vViewPosition;\n#endif",clipping_planes_vertex:"#if NUM_CLIPPING_PLANES > 0 && ! defined( STANDARD ) && ! defined( PHONG ) && ! defined( MATCAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif",
color_fragment:"#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif",color_pars_fragment:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_pars_vertex:"#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif",color_vertex:"#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif",common:"#define PI 3.14159265359\n#define PI2 6.28318530718\n#define PI_HALF 1.5707963267949\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nmat3 transposeMat3( const in mat3 m ) {\n\tmat3 tmp;\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\treturn tmp;\n}\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\treturn dot( weights, color.rgb );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n  return m[ 2 ][ 3 ] == - 1.0;\n}",
cube_uv_reflection_fragment:"#ifdef ENVMAP_TYPE_CUBE_UV\n#define cubeUV_textureSize (1024.0)\nint getFaceFromDirection(vec3 direction) {\n\tvec3 absDirection = abs(direction);\n\tint face = -1;\n\tif( absDirection.x > absDirection.z ) {\n\t\tif(absDirection.x > absDirection.y )\n\t\t\tface = direction.x > 0.0 ? 0 : 3;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\telse {\n\t\tif(absDirection.z > absDirection.y )\n\t\t\tface = direction.z > 0.0 ? 2 : 5;\n\t\telse\n\t\t\tface = direction.y > 0.0 ? 1 : 4;\n\t}\n\treturn face;\n}\n#define cubeUV_maxLods1  (log2(cubeUV_textureSize*0.25) - 1.0)\n#define cubeUV_rangeClamp (exp2((6.0 - 1.0) * 2.0))\nvec2 MipLevelInfo( vec3 vec, float roughnessLevel, float roughness ) {\n\tfloat scale = exp2(cubeUV_maxLods1 - roughnessLevel);\n\tfloat dxRoughness = dFdx(roughness);\n\tfloat dyRoughness = dFdy(roughness);\n\tvec3 dx = dFdx( vec * scale * dxRoughness );\n\tvec3 dy = dFdy( vec * scale * dyRoughness );\n\tfloat d = max( dot( dx, dx ), dot( dy, dy ) );\n\td = clamp(d, 1.0, cubeUV_rangeClamp);\n\tfloat mipLevel = 0.5 * log2(d);\n\treturn vec2(floor(mipLevel), fract(mipLevel));\n}\n#define cubeUV_maxLods2 (log2(cubeUV_textureSize*0.25) - 2.0)\n#define cubeUV_rcpTextureSize (1.0 / cubeUV_textureSize)\nvec2 getCubeUV(vec3 direction, float roughnessLevel, float mipLevel) {\n\tmipLevel = roughnessLevel > cubeUV_maxLods2 - 3.0 ? 0.0 : mipLevel;\n\tfloat a = 16.0 * cubeUV_rcpTextureSize;\n\tvec2 exp2_packed = exp2( vec2( roughnessLevel, mipLevel ) );\n\tvec2 rcp_exp2_packed = vec2( 1.0 ) / exp2_packed;\n\tfloat powScale = exp2_packed.x * exp2_packed.y;\n\tfloat scale = rcp_exp2_packed.x * rcp_exp2_packed.y * 0.25;\n\tfloat mipOffset = 0.75*(1.0 - rcp_exp2_packed.y) * rcp_exp2_packed.x;\n\tbool bRes = mipLevel == 0.0;\n\tscale =  bRes && (scale < a) ? a : scale;\n\tvec3 r;\n\tvec2 offset;\n\tint face = getFaceFromDirection(direction);\n\tfloat rcpPowScale = 1.0 / powScale;\n\tif( face == 0) {\n\t\tr = vec3(direction.x, -direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 1) {\n\t\tr = vec3(direction.y, direction.x, direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 2) {\n\t\tr = vec3(direction.z, direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.75 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? a : offset.y;\n\t}\n\telse if( face == 3) {\n\t\tr = vec3(direction.x, direction.z, direction.y);\n\t\toffset = vec2(0.0+mipOffset,0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse if( face == 4) {\n\t\tr = vec3(direction.y, direction.x, -direction.z);\n\t\toffset = vec2(scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\telse {\n\t\tr = vec3(direction.z, -direction.x, direction.y);\n\t\toffset = vec2(2.0*scale+mipOffset, 0.5 * rcpPowScale);\n\t\toffset.y = bRes && (offset.y < 2.0*a) ? 0.0 : offset.y;\n\t}\n\tr = normalize(r);\n\tfloat texelOffset = 0.5 * cubeUV_rcpTextureSize;\n\tvec2 s = ( r.yz / abs( r.x ) + vec2( 1.0 ) ) * 0.5;\n\tvec2 base = offset + vec2( texelOffset );\n\treturn base + s * ( scale - 2.0 * texelOffset );\n}\n#define cubeUV_maxLods3 (log2(cubeUV_textureSize*0.25) - 3.0)\nvec4 textureCubeUV( sampler2D envMap, vec3 reflectedDirection, float roughness ) {\n\tfloat roughnessVal = roughness* cubeUV_maxLods3;\n\tfloat r1 = floor(roughnessVal);\n\tfloat r2 = r1 + 1.0;\n\tfloat t = fract(roughnessVal);\n\tvec2 mipInfo = MipLevelInfo(reflectedDirection, r1, roughness);\n\tfloat s = mipInfo.y;\n\tfloat level0 = mipInfo.x;\n\tfloat level1 = level0 + 1.0;\n\tlevel1 = level1 > 5.0 ? 5.0 : level1;\n\tlevel0 += min( floor( s + 0.5 ), 5.0 );\n\tvec2 uv_10 = getCubeUV(reflectedDirection, r1, level0);\n\tvec4 color10 = envMapTexelToLinear(texture2D(envMap, uv_10));\n\tvec2 uv_20 = getCubeUV(reflectedDirection, r2, level0);\n\tvec4 color20 = envMapTexelToLinear(texture2D(envMap, uv_20));\n\tvec4 result = mix(color10, color20, t);\n\treturn vec4(result.rgb, 1.0);\n}\n#endif",
defaultnormal_vertex:"vec3 transformedNormal = objectNormal;\n#ifdef USE_INSTANCING\n\ttransformedNormal = mat3( instanceMatrix ) * transformedNormal;\n#endif\ntransformedNormal = normalMatrix * transformedNormal;\n#ifdef FLIP_SIDED\n\ttransformedNormal = - transformedNormal;\n#endif\n#ifdef USE_TANGENT\n\tvec3 transformedTangent = normalMatrix * objectTangent;\n\t#ifdef FLIP_SIDED\n\t\ttransformedTangent = - transformedTangent;\n\t#endif\n#endif",displacementmap_pars_vertex:"#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif",
displacementmap_vertex:"#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n#endif",emissivemap_fragment:"#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif",emissivemap_pars_fragment:"#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif",
encodings_fragment:"gl_FragColor = linearToOutputTexel( gl_FragColor );",encodings_pars_fragment:"\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\tD = min( floor( D ) / 255.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value )  {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}",
envmap_fragment:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\treflectVec = normalize( reflectVec );\n\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\treflectVec = normalize( reflectVec );\n\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) );\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#else\n\t\tvec4 envColor = vec4( 0.0 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif",
envmap_common_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif",envmap_pars_fragment:"#ifdef USE_ENVMAP\n\tuniform float reflectivity;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif",
envmap_pars_vertex:"#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\t\t#define ENV_WORLDPOS\n\t#endif\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif",envmap_physical_pars_fragment:"#if defined( USE_ENVMAP )\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t  vec3 reflectVec = reflect( -viewDir, normal );\n\t\t  reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\t\t#else\n\t\t  vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, queryReflectVec, roughness );\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = asin( clamp( reflectVec.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\t\t\tsampleUV.x = atan( reflectVec.z, reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = normalize( ( viewMatrix * vec4( reflectVec, 0.0 ) ).xyz + vec3( 0.0,0.0,1.0 ) );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif",
envmap_vertex:"#ifdef USE_ENVMAP\n\t#ifdef ENV_WORLDPOS\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif",fog_vertex:"#ifdef USE_FOG\n\tfogDepth = -mvPosition.z;\n#endif",
fog_pars_vertex:"#ifdef USE_FOG\n\tvarying float fogDepth;\n#endif",fog_fragment:"#ifdef USE_FOG\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif",fog_pars_fragment:"#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif",
gradientmap_pars_fragment:"#ifdef TOON\n\tuniform sampler2D gradientMap;\n\tvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\t\tfloat dotNL = dot( normal, lightDirection );\n\t\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\t\t#ifdef USE_GRADIENTMAP\n\t\t\treturn texture2D( gradientMap, coord ).rgb;\n\t\t#else\n\t\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\t\t#endif\n\t}\n#endif",lightmap_fragment:"#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif",
lightmap_pars_fragment:"#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif",lights_lambert_vertex:"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif",
lights_pars_begin:"uniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\treturn result;\n}\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\treturn irradiance;\n}\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t\tfloat shadowCameraNear;\n\t\tfloat shadowCameraFar;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight  ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( angleCos > spotLight.coneCos ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_RECT_AREA_LIGHTS > 0\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\tuniform sampler2D ltc_1;\tuniform sampler2D ltc_2;\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif",
lights_phong_fragment:"BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;",lights_phong_pars_fragment:"varying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\t#ifdef TOON\n\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t#else\n\t\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\t\tvec3 irradiance = dotNL * directLight.color;\n\t#endif\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)",
lights_physical_fragment:"PhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\n#ifdef REFLECTIVITY\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n#else\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n#endif\n#ifdef CLEARCOAT\n\tmaterial.clearcoat = saturate( clearcoat );\tmaterial.clearcoatRoughness = clamp( clearcoatRoughness, 0.04, 1.0 );\n#endif\n#ifdef USE_SHEEN\n\tmaterial.sheenColor = sheen;\n#endif",
lights_physical_pars_fragment:"struct PhysicalMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n};\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n}\n#if NUM_RECT_AREA_LIGHTS > 0\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight;\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3(    0, 1,    0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\t}\n#endif\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tccIrradiance *= PI;\n\t\t#endif\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\t#ifdef CLEARCOAT\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\t#else\n\t\tfloat clearcoatDHR = 0.0;\n\t#endif\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n}\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n}",
lights_fragment_begin:"\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\n#ifdef CLEARCOAT\n\tgeometry.clearcoatNormal = clearcoatNormal;\n#endif\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( pointLight.shadow, directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( spotLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectLight.color *= all( bvec3( directionalLight.shadow, directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\tRectAreaLight rectAreaLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 iblIrradiance = vec3( 0.0 );\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\t#pragma unroll_loop\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n#endif\n#if defined( RE_IndirectSpecular )\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n#endif",
lights_fragment_maps:"#if defined( RE_IndirectDiffuse )\n\t#ifdef USE_LIGHTMAP\n\t\tvec3 lightMapIrradiance = texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tlightMapIrradiance *= PI;\n\t\t#endif\n\t\tirradiance += lightMapIrradiance;\n\t#endif\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( geometry, maxMipLevel );\n\t#endif\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tradiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\t#ifdef CLEARCOAT\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\t#endif\n#endif",
lights_fragment_end:"#if defined( RE_IndirectDiffuse )\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( RE_IndirectSpecular )\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n#endif",logdepthbuf_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tgl_FragDepthEXT = vIsPerspective == 1.0 ? log2( vFragDepth ) * logDepthBufFC * 0.5 : gl_FragCoord.z;\n#endif",logdepthbuf_pars_fragment:"#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n#endif",
logdepthbuf_pars_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\t#else\n\t\tuniform float logDepthBufFC;\n\t#endif\n#endif",logdepthbuf_vertex:"#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\t#else\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\t\t\tgl_Position.z *= gl_Position.w;\n\t\t}\n\t#endif\n#endif",
map_fragment:"#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif",map_pars_fragment:"#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif",map_particle_fragment:"#ifdef USE_MAP\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n#endif",map_particle_pars_fragment:"#ifdef USE_MAP\n\tuniform mat3 uvTransform;\n\tuniform sampler2D map;\n#endif",
metalnessmap_fragment:"float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.b;\n#endif",metalnessmap_pars_fragment:"#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif",morphnormal_vertex:"#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif",
morphtarget_pars_vertex:"#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif",morphtarget_vertex:"#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif",
normal_fragment_begin:"#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\t#ifdef USE_TANGENT\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t#endif\n#endif\nvec3 geometryNormal = normal;",
normal_fragment_maps:"#ifdef OBJECTSPACE_NORMALMAP\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t#ifdef FLIP_SIDED\n\t\tnormal = - normal;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#endif\n\tnormal = normalize( normalMatrix * normal );\n#elif defined( TANGENTSPACE_NORMALMAP )\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tnormal = normalize( vTBN * mapN );\n\t#else\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, normalScale, normalMap );\n\t#endif\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif",
normalmap_pars_fragment:"#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\n\tuniform mat3 normalMatrix;\n#endif\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec2 normalScale, in sampler2D normalMap ) {\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s );\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy *= normalScale;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tbool frontFacing = dot( cross( S, T ), N ) > 0.0;\n\t\t\tmapN.xy *= ( float( frontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#endif\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif",
clearcoat_normal_fragment_begin:"#ifdef CLEARCOAT\n\tvec3 clearcoatNormal = geometryNormal;\n#endif",clearcoat_normal_fragment_maps:"#ifdef USE_CLEARCOAT_NORMALMAP\n\t#ifdef USE_TANGENT\n\t\tmat3 vTBN = mat3( tangent, bitangent, clearcoatNormal );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = clearcoatNormalScale * mapN.xy;\n\t\tclearcoatNormal = normalize( vTBN * mapN );\n\t#else\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatNormalScale, clearcoatNormalMap );\n\t#endif\n#endif",
clearcoat_normalmap_pars_fragment:"#ifdef USE_CLEARCOAT_NORMALMAP\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n#endif",packing:"vec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\nconst float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256.,  256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\nconst float ShiftRight8 = 1. / 256.;\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8;\treturn r * PackUpscale;\n}\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\nvec4 encodeHalfRGBA ( vec2 v ) {\n\tvec4 encoded = vec4( 0.0 );\n\tconst vec2 offset = vec2( 1.0 / 255.0, 0.0 );\n\tencoded.xy = vec2( v.x, fract( v.x * 255.0 ) );\n\tencoded.xy = encoded.xy - ( encoded.yy * offset );\n\tencoded.zw = vec2( v.y, fract( v.y * 255.0 ) );\n\tencoded.zw = encoded.zw - ( encoded.ww * offset );\n\treturn encoded;\n}\nvec2 decodeHalfRGBA( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}",
premultiplied_alpha_fragment:"#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif",project_vertex:"vec4 mvPosition = vec4( transformed, 1.0 );\n#ifdef USE_INSTANCING\n\tmvPosition = instanceMatrix * mvPosition;\n#endif\nmvPosition = modelViewMatrix * mvPosition;\ngl_Position = projectionMatrix * mvPosition;",dithering_fragment:"#ifdef DITHERING\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n#endif",dithering_pars_fragment:"#ifdef DITHERING\n\tvec3 dithering( vec3 color ) {\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\t\treturn color + dither_shift_RGB;\n\t}\n#endif",
roughnessmap_fragment:"float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.g;\n#endif",roughnessmap_pars_fragment:"#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif",shadowmap_pars_fragment:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\t\treturn decodeHalfRGBA( texture2D( shadow, uv ) );\n\t}\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\t\tfloat occlusion = 1.0;\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\t\tfloat hard_shadow = step( compare , distribution.x );\n\t\tif (hard_shadow != 1.0 ) {\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance );\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 );\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\t\t}\n\t\treturn occlusion;\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = ( floor( uv * size - 0.5 ) + 0.5 ) * texelSize;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tfloat shadow = 1.0;\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tshadow = (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#else\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn shadow;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear );\t\tdp += shadowBias;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif",
shadowmap_pars_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\t#endif\n#endif",
shadowmap_vertex:"#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif",
shadowmask_pars_fragment:"float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLight directionalLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= all( bvec2( directionalLight.shadow, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLight spotLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= all( bvec2( spotLight.shadow, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLight pointLight;\n\t#pragma unroll_loop\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= all( bvec2( pointLight.shadow, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}",
skinbase_vertex:"#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif",skinning_pars_vertex:"#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif",
skinning_vertex:"#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n#endif",skinnormal_vertex:"#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\t#ifdef USE_TANGENT\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\t#endif\n#endif",
specularmap_fragment:"float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif",specularmap_pars_fragment:"#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif",tonemapping_fragment:"#if defined( TONE_MAPPING )\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif",tonemapping_pars_fragment:"#ifndef saturate\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n\treturn toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\tcolor *= toneMappingExposure;\n\treturn saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) );\n}",
uv_pars_fragment:"#ifdef USE_UV\n\tvarying vec2 vUv;\n#endif",uv_pars_vertex:"#ifdef USE_UV\n\tvarying vec2 vUv;\n\tuniform mat3 uvTransform;\n#endif",uv_vertex:"#ifdef USE_UV\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n#endif",uv2_pars_fragment:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif",uv2_pars_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif",uv2_vertex:"#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif",
worldpos_vertex:"#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\t#ifdef USE_INSTANCING\n\t\tworldPosition = instanceMatrix * worldPosition;\n\t#endif\n\tworldPosition = modelMatrix * worldPosition;\n#endif",background_frag:"uniform sampler2D t2D;\nvarying vec2 vUv;\nvoid main() {\n\tvec4 texColor = texture2D( t2D, vUv );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",
background_vert:"varying vec2 vUv;\nuniform mat3 uvTransform;\nvoid main() {\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n}",cube_frag:"uniform samplerCube tCube;\nuniform float tFlip;\nuniform float opacity;\nvarying vec3 vWorldDirection;\nvoid main() {\n\tvec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\tgl_FragColor.a *= opacity;\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",
cube_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\tgl_Position.z = gl_Position.w;\n}",depth_frag:"#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( 1.0 - gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}",
depth_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}",
distanceRGBA_frag:"#define DISTANCE\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist );\n\tgl_FragColor = packDepthToRGBA( dist );\n}",
distanceRGBA_vert:"#define DISTANCE\nvarying vec3 vWorldPosition;\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_DISPLACEMENTMAP\n\t\t#include <beginnormal_vertex>\n\t\t#include <morphnormal_vertex>\n\t\t#include <skinnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition.xyz;\n}",
equirect_frag:"uniform sampler2D tEquirect;\nvarying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvec3 direction = normalize( vWorldDirection );\n\tvec2 sampleUV;\n\tsampleUV.y = asin( clamp( direction.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\tgl_FragColor = mapTexelToLinear( texColor );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n}",
equirect_vert:"varying vec3 vWorldDirection;\n#include <common>\nvoid main() {\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n}",linedashed_frag:"uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",
linedashed_vert:"uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}",
meshbasic_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\t#ifdef USE_LIGHTMAP\n\t\treflectedLight.indirectDiffuse += texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#else\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\t#endif\n\t#include <aomap_fragment>\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",
meshbasic_vert:"#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n\t#include <fog_vertex>\n}",
meshlambert_frag:"uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\t#else\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\t#endif\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",
meshlambert_vert:"#define LAMBERT\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",
meshmatcap_frag:"#define MATCAP\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5;\n\t#ifdef USE_MATCAP\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\t#else\n\t\tvec4 matcapColor = vec4( 1.0 );\n\t#endif\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",
meshmatcap_vert:"#define MATCAP\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#ifndef FLAT_SHADED\n\t\tvNormal = normalize( transformedNormal );\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n\tvViewPosition = - mvPosition.xyz;\n}",
meshphong_frag:"#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_pars_fragment>\n#include <gradientmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",
meshphong_vert:"#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",
meshphysical_frag:"#define STANDARD\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <envmap_common_pars_fragment>\n#include <envmap_physical_pars_fragment>\n#include <fog_pars_fragment>\n#include <lights_pars_begin>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <clearcoat_normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\t#include <clearcoat_normal_fragment_begin>\n\t#include <clearcoat_normal_fragment_maps>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_fragment_begin>\n\t#include <lights_fragment_maps>\n\t#include <lights_fragment_end>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n\t#include <premultiplied_alpha_fragment>\n\t#include <dithering_fragment>\n}",
meshphysical_vert:"#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",
normal_frag:"#define NORMAL\nuniform float opacity;\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <packing>\n#include <uv_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\t#include <logdepthbuf_fragment>\n\t#include <normal_fragment_begin>\n\t#include <normal_fragment_maps>\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n}",
normal_vert:"#define NORMAL\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvarying vec3 vViewPosition;\n#endif\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n\t#ifdef USE_TANGENT\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\t#endif\n#endif\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n\t#ifdef USE_TANGENT\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\t#endif\n#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <displacementmap_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n}",
points_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",
points_vert:"uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <fog_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\tgl_PointSize = size;\n\t#ifdef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <fog_vertex>\n}",
shadow_frag:"uniform vec3 color;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars_begin>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\nvoid main() {\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\t#include <fog_fragment>\n}",shadow_vert:"#include <fog_pars_vertex>\n#include <shadowmap_pars_vertex>\nvoid main() {\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n\t#include <fog_vertex>\n}",
sprite_frag:"uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}",
sprite_vert:"uniform float rotation;\nuniform vec2 center;\n#include <common>\n#include <uv_pars_vertex>\n#include <fog_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\t#ifndef USE_SIZEATTENUATION\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\t#endif\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\tmvPosition.xy += rotatedPosition;\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <fog_vertex>\n}"},
I={common:{diffuse:{value:new H(15658734)},opacity:{value:1},map:{value:null},uvTransform:{value:new Y},alphaMap:{value:null}},specularmap:{specularMap:{value:null}},envmap:{envMap:{value:null},flipEnvMap:{value:-1},reflectivity:{value:1},refractionRatio:{value:.98},maxMipLevel:{value:0}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1}},emissivemap:{emissiveMap:{value:null}},bumpmap:{bumpMap:{value:null},bumpScale:{value:1}},normalmap:{normalMap:{value:null},
normalScale:{value:new w(1,1)}},displacementmap:{displacementMap:{value:null},displacementScale:{value:1},displacementBias:{value:0}},roughnessmap:{roughnessMap:{value:null}},metalnessmap:{metalnessMap:{value:null}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:2.5E-4},fogNear:{value:1},fogFar:{value:2E3},fogColor:{value:new H(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{},shadow:{},shadowBias:{},
shadowRadius:{},shadowMapSize:{}}},directionalShadowMap:{value:[]},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{}}},spotShadowMap:{value:[]},spotShadowMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{},shadow:{},shadowBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},
pointShadowMap:{value:[]},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}}},points:{diffuse:{value:new H(15658734)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},uvTransform:{value:new Y}},sprite:{diffuse:{value:new H(15658734)},opacity:{value:1},center:{value:new w(.5,.5)},rotation:{value:0},map:{value:null},uvTransform:{value:new Y}}},db=
{basic:{uniforms:Da([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.fog]),vertexShader:N.meshbasic_vert,fragmentShader:N.meshbasic_frag},lambert:{uniforms:Da([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.fog,I.lights,{emissive:{value:new H(0)}}]),vertexShader:N.meshlambert_vert,fragmentShader:N.meshlambert_frag},phong:{uniforms:Da([I.common,I.specularmap,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.gradientmap,I.fog,I.lights,{emissive:{value:new H(0)},
specular:{value:new H(1118481)},shininess:{value:30}}]),vertexShader:N.meshphong_vert,fragmentShader:N.meshphong_frag},standard:{uniforms:Da([I.common,I.envmap,I.aomap,I.lightmap,I.emissivemap,I.bumpmap,I.normalmap,I.displacementmap,I.roughnessmap,I.metalnessmap,I.fog,I.lights,{emissive:{value:new H(0)},roughness:{value:.5},metalness:{value:.5},envMapIntensity:{value:1}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag},matcap:{uniforms:Da([I.common,I.bumpmap,I.normalmap,I.displacementmap,
I.fog,{matcap:{value:null}}]),vertexShader:N.meshmatcap_vert,fragmentShader:N.meshmatcap_frag},points:{uniforms:Da([I.points,I.fog]),vertexShader:N.points_vert,fragmentShader:N.points_frag},dashed:{uniforms:Da([I.common,I.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:N.linedashed_vert,fragmentShader:N.linedashed_frag},depth:{uniforms:Da([I.common,I.displacementmap]),vertexShader:N.depth_vert,fragmentShader:N.depth_frag},normal:{uniforms:Da([I.common,I.bumpmap,I.normalmap,
I.displacementmap,{opacity:{value:1}}]),vertexShader:N.normal_vert,fragmentShader:N.normal_frag},sprite:{uniforms:Da([I.sprite,I.fog]),vertexShader:N.sprite_vert,fragmentShader:N.sprite_frag},background:{uniforms:{uvTransform:{value:new Y},t2D:{value:null}},vertexShader:N.background_vert,fragmentShader:N.background_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:N.cube_vert,fragmentShader:N.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:N.equirect_vert,
fragmentShader:N.equirect_frag},distanceRGBA:{uniforms:Da([I.common,I.displacementmap,{referencePosition:{value:new n},nearDistance:{value:1},farDistance:{value:1E3}}]),vertexShader:N.distanceRGBA_vert,fragmentShader:N.distanceRGBA_frag},shadow:{uniforms:Da([I.lights,I.fog,{color:{value:new H(0)},opacity:{value:1}}]),vertexShader:N.shadow_vert,fragmentShader:N.shadow_frag}};db.physical={uniforms:Da([db.standard.uniforms,{transparency:{value:0},clearcoat:{value:0},clearcoatRoughness:{value:0},sheen:{value:new H(0)},
clearcoatNormalScale:{value:new w(1,1)},clearcoatNormalMap:{value:null}}]),vertexShader:N.meshphysical_vert,fragmentShader:N.meshphysical_frag};Fd.prototype=Object.create(F.prototype);Fd.prototype.constructor=Fd;$b.prototype=Object.create(E.prototype);$b.prototype.constructor=$b;ob.prototype=Object.create(W.prototype);ob.prototype.constructor=ob;ob.prototype.isCubeTexture=!0;Object.defineProperty(ob.prototype,"images",{get:function(){return this.image},set:function(a){this.image=a}});Ec.prototype=
Object.create(W.prototype);Ec.prototype.constructor=Ec;Ec.prototype.isDataTexture2DArray=!0;Fc.prototype=Object.create(W.prototype);Fc.prototype.constructor=Fc;Fc.prototype.isDataTexture3D=!0;var vh=new W,qj=new Ec,sj=new Fc,wh=new ob,ph=[],rh=[],uh=new Float32Array(16),th=new Float32Array(9),sh=new Float32Array(4);xh.prototype.updateCache=function(a){var b=this.cache;a instanceof Float32Array&&b.length!==a.length&&(this.cache=new Float32Array(a.length));Ha(b,a)};yh.prototype.setValue=function(a,
b,c){for(var d=this.seq,e=0,f=d.length;e!==f;++e){var g=d[e];g.setValue(a,b[g.id],c)}};var Yf=/([\w\d_]+)(\])?(\[|\.)?/g;Bb.prototype.setValue=function(a,b,c,d){b=this.map[b];void 0!==b&&b.setValue(a,c,d)};Bb.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};Bb.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};Bb.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in
b&&c.push(f)}return c};var Xj=0,$f=/^[ \t]*#include +<([\w\d./]+)>/gm,Gh=/#pragma unroll_loop[\s]+?for \( int i = (\d+); i < (\d+); i \+\+ \) \{([\s\S]+?)(?=\})\}/g,gk=0;Db.prototype=Object.create(M.prototype);Db.prototype.constructor=Db;Db.prototype.isMeshDepthMaterial=!0;Db.prototype.copy=function(a){M.prototype.copy.call(this,a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;
this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};Eb.prototype=Object.create(M.prototype);Eb.prototype.constructor=Eb;Eb.prototype.isMeshDistanceMaterial=!0;Eb.prototype.copy=function(a){M.prototype.copy.call(this,a);this.referencePosition.copy(a.referencePosition);this.nearDistance=a.nearDistance;this.farDistance=a.farDistance;this.skinning=a.skinning;this.morphTargets=a.morphTargets;
this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;return this};fg.prototype=Object.assign(Object.create(la.prototype),{constructor:fg,isWebGLMultiviewRenderTarget:!0,copy:function(a){la.prototype.copy.call(this,a);this.numViews=a.numViews;return this},setNumViews:function(a){this.numViews!==a&&(this.numViews=a,this.dispose());return this}});Hc.prototype=Object.assign(Object.create(B.prototype),
{constructor:Hc,isGroup:!0});Jd.prototype=Object.assign(Object.create(na.prototype),{constructor:Jd,isArrayCamera:!0});var Mh=new n,Nh=new n;Object.assign(gg.prototype,Ba.prototype);Object.assign(Oh.prototype,Ba.prototype);Object.assign(Ie.prototype,{isFogExp2:!0,clone:function(){return new Ie(this.color,this.density)},toJSON:function(){return{type:"FogExp2",color:this.color.getHex(),density:this.density}}});Object.assign(Je.prototype,{isFog:!0,clone:function(){return new Je(this.color,this.near,
this.far)},toJSON:function(){return{type:"Fog",color:this.color.getHex(),near:this.near,far:this.far}}});Object.defineProperty(Gb.prototype,"needsUpdate",{set:function(a){!0===a&&this.version++}});Object.assign(Gb.prototype,{isInterleavedBuffer:!0,onUploadCallback:function(){},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.count=a.count;this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;
c*=b.stride;for(var d=0,e=this.stride;d<e;d++)this.array[a+d]=b.array[c+d];return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},clone:function(){return(new this.constructor).copy(this)},onUpload:function(a){this.onUploadCallback=a;return this}});Object.defineProperties(Kd.prototype,{count:{get:function(){return this.data.count}},array:{get:function(){return this.data.array}}});Object.assign(Kd.prototype,{isInterleavedBufferAttribute:!0,setX:function(a,b){this.data.array[a*
this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+this.offset]},getY:function(a){return this.data.array[a*this.data.stride+this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+
this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,c){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;this.data.array[a+3]=e;return this}});
Hb.prototype=Object.create(M.prototype);Hb.prototype.constructor=Hb;Hb.prototype.isSpriteMaterial=!0;Hb.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;this.sizeAttenuation=a.sizeAttenuation;return this};var Ic,ze=new n,ud=new n,vd=new n,Jc=new w,Md=new w,Qh=new U,Af=new n,Ae=new n,Bf=new n,ui=new w,ah=new w,vi=new w;Ld.prototype=Object.assign(Object.create(B.prototype),{constructor:Ld,isSprite:!0,raycast:function(a,b){null===
a.camera&&console.error('THREE.Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.');ud.setFromMatrixScale(this.matrixWorld);Qh.copy(a.camera.matrixWorld);this.modelViewMatrix.multiplyMatrices(a.camera.matrixWorldInverse,this.matrixWorld);vd.setFromMatrixPosition(this.modelViewMatrix);a.camera.isPerspectiveCamera&&!1===this.material.sizeAttenuation&&ud.multiplyScalar(-vd.z);var c=this.material.rotation;if(0!==c){var d=Math.cos(c);var e=Math.sin(c)}c=this.center;Ke(Af.set(-.5,
-.5,0),vd,c,ud,e,d);Ke(Ae.set(.5,-.5,0),vd,c,ud,e,d);Ke(Bf.set(.5,.5,0),vd,c,ud,e,d);ui.set(0,0);ah.set(1,0);vi.set(1,1);var f=a.ray.intersectTriangle(Af,Ae,Bf,!1,ze);if(null===f&&(Ke(Ae.set(-.5,.5,0),vd,c,ud,e,d),ah.set(0,1),f=a.ray.intersectTriangle(Af,Bf,Ae,!1,ze),null===f))return;e=a.ray.origin.distanceTo(ze);e<a.near||e>a.far||b.push({distance:e,point:ze.clone(),uv:R.getUV(ze,Af,Ae,Bf,ui,ah,vi,new w),face:null,object:this})},clone:function(){return(new this.constructor(this.material)).copy(this)},
copy:function(a){B.prototype.copy.call(this,a);void 0!==a.center&&this.center.copy(a.center);return this}});var Cf=new n,wi=new n;Nd.prototype=Object.assign(Object.create(B.prototype),{constructor:Nd,isLOD:!0,copy:function(a){B.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b<c;b++){var d=a[b];this.addLevel(d.object.clone(),d.distance)}return this},addLevel:function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=this.levels,d=0;d<c.length&&!(b<c[d].distance);d++);c.splice(d,0,{distance:b,
object:a});this.add(a);return this},getObjectForDistance:function(a){for(var b=this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-1].object},raycast:function(a,b){Cf.setFromMatrixPosition(this.matrixWorld);var c=a.ray.origin.distanceTo(Cf);this.getObjectForDistance(c).raycast(a,b)},update:function(a){var b=this.levels;if(1<b.length){Cf.setFromMatrixPosition(a.matrixWorld);wi.setFromMatrixPosition(this.matrixWorld);a=Cf.distanceTo(wi);b[0].object.visible=!0;for(var c=1,d=b.length;c<
d;c++)if(a>=b[c].distance)b[c-1].object.visible=!1,b[c].object.visible=!0;else break;for(;c<d;c++)b[c].object.visible=!1}},toJSON:function(a){a=B.prototype.toJSON.call(this,a);a.object.levels=[];for(var b=this.levels,c=0,d=b.length;c<d;c++){var e=b[c];a.object.levels.push({object:e.object.uuid,distance:e.distance})}return a}});Od.prototype=Object.assign(Object.create(ja.prototype),{constructor:Od,isSkinnedMesh:!0,bind:function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),
b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)},pose:function(){this.skeleton.pose()},normalizeSkinWeights:function(){for(var a=new aa,b=this.geometry.attributes.skinWeight,c=0,d=b.count;c<d;c++){a.x=b.getX(c);a.y=b.getY(c);a.z=b.getZ(c);a.w=b.getW(c);var e=1/a.manhattanLength();Infinity!==e?a.multiplyScalar(e):a.set(1,0,0,0);b.setXYZW(c,a.x,a.y,a.z,a.w)}},updateMatrixWorld:function(a){ja.prototype.updateMatrixWorld.call(this,a);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):
"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh: Unrecognized bindMode: "+this.bindMode)},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var xi=new U,Dk=new U;Object.assign(Le.prototype,{calculateInverses:function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new U;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}},pose:function(){var a,b;
var c=0;for(b=this.bones.length;c<b;c++)(a=this.bones[c])&&a.matrixWorld.getInverse(this.boneInverses[c]);c=0;for(b=this.bones.length;c<b;c++)if(a=this.bones[c])a.parent&&a.parent.isBone?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale)},update:function(){for(var a=this.bones,b=this.boneInverses,c=this.boneMatrices,d=this.boneTexture,e=0,f=a.length;e<f;e++)xi.multiplyMatrices(a[e]?a[e].matrixWorld:
Dk,b[e]),xi.toArray(c,16*e);void 0!==d&&(d.needsUpdate=!0)},clone:function(){return new Le(this.bones,this.boneInverses)},getBoneByName:function(a){for(var b=0,c=this.bones.length;b<c;b++){var d=this.bones[b];if(d.name===a)return d}}});ig.prototype=Object.assign(Object.create(B.prototype),{constructor:ig,isBone:!0});jg.prototype=Object.assign(Object.create(ja.prototype),{constructor:jg,isInstancedMesh:!0,raycast:function(){},setMatrixAt:function(a,b){b.toArray(this.instanceMatrix.array,16*a)},updateMorphTargets:function(){}});
Q.prototype=Object.create(M.prototype);Q.prototype.constructor=Q;Q.prototype.isLineBasicMaterial=!0;Q.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;return this};var yi=new n,zi=new n,Ai=new U,Df=new Sb,Be=new nb;xa.prototype=Object.assign(Object.create(B.prototype),{constructor:xa,isLine:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=
a.attributes.position,c=[0],d=1,e=b.count;d<e;d++)yi.fromBufferAttribute(b,d-1),zi.fromBufferAttribute(b,d),c[d]=c[d-1],c[d]+=yi.distanceTo(zi);a.addAttribute("lineDistance",new A(c,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(a.isGeometry)for(b=a.vertices,c=a.lineDistances,c[0]=0,d=1,e=b.length;d<e;d++)c[d]=c[d-1],c[d]+=b[d-1].distanceTo(b[d]);return this},raycast:function(a,b){var c=a.linePrecision,d=this.geometry,
e=this.matrixWorld;null===d.boundingSphere&&d.computeBoundingSphere();Be.copy(d.boundingSphere);Be.applyMatrix4(e);Be.radius+=c;if(!1!==a.ray.intersectsSphere(Be)){Ai.getInverse(e);Df.copy(a.ray).applyMatrix4(Ai);c/=(this.scale.x+this.scale.y+this.scale.z)/3;c*=c;var f=new n,g=new n;e=new n;var h=new n,l=this&&this.isLineSegments?2:1;if(d.isBufferGeometry){var k=d.index,q=d.attributes.position.array;if(null!==k){k=k.array;d=0;for(var u=k.length-1;d<u;d+=l){var t=k[d+1];f.fromArray(q,3*k[d]);g.fromArray(q,
3*t);t=Df.distanceSqToSegment(f,g,h,e);t>c||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}}else for(d=0,u=q.length/3-1;d<u;d+=l)f.fromArray(q,3*d),g.fromArray(q,3*d+3),t=Df.distanceSqToSegment(f,g,h,e),t>c||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),
index:d,face:null,faceIndex:null,object:this}))}else if(d.isGeometry)for(f=d.vertices,g=f.length,d=0;d<g-1;d+=l)t=Df.distanceSqToSegment(f[d],f[d+1],h,e),t>c||(h.applyMatrix4(this.matrixWorld),t=a.ray.origin.distanceTo(h),t<a.near||t>a.far||b.push({distance:t,point:e.clone().applyMatrix4(this.matrixWorld),index:d,face:null,faceIndex:null,object:this}))}},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});var Ef=new n,Ff=new n;ca.prototype=Object.assign(Object.create(xa.prototype),
{constructor:ca,isLineSegments:!0,computeLineDistances:function(){var a=this.geometry;if(a.isBufferGeometry)if(null===a.index){for(var b=a.attributes.position,c=[],d=0,e=b.count;d<e;d+=2)Ef.fromBufferAttribute(b,d),Ff.fromBufferAttribute(b,d+1),c[d]=0===d?0:c[d-1],c[d+1]=c[d]+Ef.distanceTo(Ff);a.addAttribute("lineDistance",new A(c,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else if(a.isGeometry)for(b=a.vertices,c=a.lineDistances,
d=0,e=b.length;d<e;d+=2)Ef.copy(b[d]),Ff.copy(b[d+1]),c[d]=0===d?0:c[d-1],c[d+1]=c[d]+Ef.distanceTo(Ff);return this}});Me.prototype=Object.assign(Object.create(xa.prototype),{constructor:Me,isLineLoop:!0});Qa.prototype=Object.create(M.prototype);Qa.prototype.constructor=Qa;Qa.prototype.isPointsMaterial=!0;Qa.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.morphTargets=a.morphTargets;return this};
var Bi=new U,lg=new Sb,Ce=new nb,Gf=new n;Kc.prototype=Object.assign(Object.create(B.prototype),{constructor:Kc,isPoints:!0,raycast:function(a,b){var c=this.geometry,d=this.matrixWorld,e=a.params.Points.threshold;null===c.boundingSphere&&c.computeBoundingSphere();Ce.copy(c.boundingSphere);Ce.applyMatrix4(d);Ce.radius+=e;if(!1!==a.ray.intersectsSphere(Ce))if(Bi.getInverse(d),lg.copy(a.ray).applyMatrix4(Bi),e/=(this.scale.x+this.scale.y+this.scale.z)/3,e*=e,c.isBufferGeometry){var f=c.index;c=c.attributes.position.array;
if(null!==f){var g=f.array;f=0;for(var h=g.length;f<h;f++){var l=g[f];Gf.fromArray(c,3*l);kg(Gf,l,e,d,a,b,this)}}else for(f=0,g=c.length/3;f<g;f++)Gf.fromArray(c,3*f),kg(Gf,f,e,d,a,b,this)}else for(c=c.vertices,f=0,g=c.length;f<g;f++)kg(c[f],f,e,d,a,b,this)},updateMorphTargets:function(){var a=this.geometry;if(a.isBufferGeometry){a=a.morphAttributes;var b=Object.keys(a);if(0<b.length){var c=a[b[0]];if(void 0!==c)for(this.morphTargetInfluences=[],this.morphTargetDictionary={},a=0,b=c.length;a<b;a++){var d=
c[a].name||String(a);this.morphTargetInfluences.push(0);this.morphTargetDictionary[d]=a}}}else a=a.morphTargets,void 0!==a&&0<a.length&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")},clone:function(){return(new this.constructor(this.geometry,this.material)).copy(this)}});mg.prototype=Object.assign(Object.create(W.prototype),{constructor:mg,isVideoTexture:!0,update:function(){var a=this.image;a.readyState>=a.HAVE_CURRENT_DATA&&
(this.needsUpdate=!0)}});Lc.prototype=Object.create(W.prototype);Lc.prototype.constructor=Lc;Lc.prototype.isCompressedTexture=!0;Pd.prototype=Object.create(W.prototype);Pd.prototype.constructor=Pd;Pd.prototype.isCanvasTexture=!0;Qd.prototype=Object.create(W.prototype);Qd.prototype.constructor=Qd;Qd.prototype.isDepthTexture=!0;Mc.prototype=Object.create(E.prototype);Mc.prototype.constructor=Mc;Rd.prototype=Object.create(F.prototype);Rd.prototype.constructor=Rd;Nc.prototype=Object.create(E.prototype);
Nc.prototype.constructor=Nc;Sd.prototype=Object.create(F.prototype);Sd.prototype.constructor=Sd;Ca.prototype=Object.create(E.prototype);Ca.prototype.constructor=Ca;Td.prototype=Object.create(F.prototype);Td.prototype.constructor=Td;Oc.prototype=Object.create(Ca.prototype);Oc.prototype.constructor=Oc;Ud.prototype=Object.create(F.prototype);Ud.prototype.constructor=Ud;cc.prototype=Object.create(Ca.prototype);cc.prototype.constructor=cc;Vd.prototype=Object.create(F.prototype);Vd.prototype.constructor=
Vd;Pc.prototype=Object.create(Ca.prototype);Pc.prototype.constructor=Pc;Wd.prototype=Object.create(F.prototype);Wd.prototype.constructor=Wd;Qc.prototype=Object.create(Ca.prototype);Qc.prototype.constructor=Qc;Xd.prototype=Object.create(F.prototype);Xd.prototype.constructor=Xd;dc.prototype=Object.create(E.prototype);dc.prototype.constructor=dc;dc.prototype.toJSON=function(){var a=E.prototype.toJSON.call(this);a.path=this.parameters.path.toJSON();return a};Yd.prototype=Object.create(F.prototype);Yd.prototype.constructor=
Yd;Rc.prototype=Object.create(E.prototype);Rc.prototype.constructor=Rc;Zd.prototype=Object.create(F.prototype);Zd.prototype.constructor=Zd;Sc.prototype=Object.create(E.prototype);Sc.prototype.constructor=Sc;var Ek={triangulate:function(a,b,c){c=c||2;var d=b&&b.length,e=d?b[0]*c:a.length,f=Rh(a,0,e,c,!0),g=[];if(!f||f.next===f.prev)return g;var h;if(d){var l=c;d=[];var k;var n=0;for(k=b.length;n<k;n++){var u=b[n]*l;var t=n<k-1?b[n+1]*l:a.length;u=Rh(a,u,t,l,!1);u===u.next&&(u.steiner=!0);d.push(ok(u))}d.sort(mk);
for(n=0;n<d.length;n++){b=d[n];l=f;if(l=nk(b,l))b=Uh(l,b),ae(b,b.next);f=ae(f,f.next)}}if(a.length>80*c){var r=h=a[0];var p=d=a[1];for(l=c;l<e;l+=c)n=a[l],b=a[l+1],n<r&&(r=n),b<p&&(p=b),n>h&&(h=n),b>d&&(d=b);h=Math.max(h-r,d-p);h=0!==h?1/h:0}be(f,g,c,r,p,h);return g}},pb={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e<b;d=e++)c+=a[d].x*a[e].y-a[e].x*a[d].y;return.5*c},isClockWise:function(a){return 0>pb.area(a)},triangulateShape:function(a,b){var c=[],d=[],e=[];Vh(a);Wh(c,a);var f=a.length;b.forEach(Vh);
for(a=0;a<b.length;a++)d.push(f),f+=b[a].length,Wh(c,b[a]);b=Ek.triangulate(c,d);for(a=0;a<b.length;a+=3)e.push(b.slice(a,a+3));return e}};fc.prototype=Object.create(F.prototype);fc.prototype.constructor=fc;fc.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return Xh(this.parameters.shapes,this.parameters.options,a)};eb.prototype=Object.create(E.prototype);eb.prototype.constructor=eb;eb.prototype.toJSON=function(){var a=E.prototype.toJSON.call(this);return Xh(this.parameters.shapes,
this.parameters.options,a)};var pk={generateTopUV:function(a,b,c,d,e){a=b[3*d];d=b[3*d+1];var f=b[3*e];e=b[3*e+1];return[new w(b[3*c],b[3*c+1]),new w(a,d),new w(f,e)]},generateSideWallUV:function(a,b,c,d,e,f){a=b[3*c];var g=b[3*c+1];c=b[3*c+2];var h=b[3*d],l=b[3*d+1];d=b[3*d+2];var k=b[3*e],n=b[3*e+1];e=b[3*e+2];var u=b[3*f],t=b[3*f+1];b=b[3*f+2];return.01>Math.abs(g-l)?[new w(a,1-c),new w(h,1-d),new w(k,1-e),new w(u,1-b)]:[new w(g,1-c),new w(l,1-d),new w(n,1-e),new w(t,1-b)]}};de.prototype=Object.create(F.prototype);
de.prototype.constructor=de;Uc.prototype=Object.create(eb.prototype);Uc.prototype.constructor=Uc;ee.prototype=Object.create(F.prototype);ee.prototype.constructor=ee;Ib.prototype=Object.create(E.prototype);Ib.prototype.constructor=Ib;fe.prototype=Object.create(F.prototype);fe.prototype.constructor=fe;Vc.prototype=Object.create(E.prototype);Vc.prototype.constructor=Vc;ge.prototype=Object.create(F.prototype);ge.prototype.constructor=ge;Wc.prototype=Object.create(E.prototype);Wc.prototype.constructor=
Wc;gc.prototype=Object.create(F.prototype);gc.prototype.constructor=gc;gc.prototype.toJSON=function(){var a=F.prototype.toJSON.call(this);return Yh(this.parameters.shapes,a)};hc.prototype=Object.create(E.prototype);hc.prototype.constructor=hc;hc.prototype.toJSON=function(){var a=E.prototype.toJSON.call(this);return Yh(this.parameters.shapes,a)};Xc.prototype=Object.create(E.prototype);Xc.prototype.constructor=Xc;ic.prototype=Object.create(F.prototype);ic.prototype.constructor=ic;qb.prototype=Object.create(E.prototype);
qb.prototype.constructor=qb;he.prototype=Object.create(ic.prototype);he.prototype.constructor=he;ie.prototype=Object.create(qb.prototype);ie.prototype.constructor=ie;je.prototype=Object.create(F.prototype);je.prototype.constructor=je;Yc.prototype=Object.create(E.prototype);Yc.prototype.constructor=Yc;var ta=Object.freeze({WireframeGeometry:Mc,ParametricGeometry:Rd,ParametricBufferGeometry:Nc,TetrahedronGeometry:Td,TetrahedronBufferGeometry:Oc,OctahedronGeometry:Ud,OctahedronBufferGeometry:cc,IcosahedronGeometry:Vd,
IcosahedronBufferGeometry:Pc,DodecahedronGeometry:Wd,DodecahedronBufferGeometry:Qc,PolyhedronGeometry:Sd,PolyhedronBufferGeometry:Ca,TubeGeometry:Xd,TubeBufferGeometry:dc,TorusKnotGeometry:Yd,TorusKnotBufferGeometry:Rc,TorusGeometry:Zd,TorusBufferGeometry:Sc,TextGeometry:de,TextBufferGeometry:Uc,SphereGeometry:ee,SphereBufferGeometry:Ib,RingGeometry:fe,RingBufferGeometry:Vc,PlaneGeometry:Fd,PlaneBufferGeometry:$b,LatheGeometry:ge,LatheBufferGeometry:Wc,ShapeGeometry:gc,ShapeBufferGeometry:hc,ExtrudeGeometry:fc,
ExtrudeBufferGeometry:eb,EdgesGeometry:Xc,ConeGeometry:he,ConeBufferGeometry:ie,CylinderGeometry:ic,CylinderBufferGeometry:qb,CircleGeometry:je,CircleBufferGeometry:Yc,BoxGeometry:Zg,BoxBufferGeometry:Gd});jc.prototype=Object.create(M.prototype);jc.prototype.constructor=jc;jc.prototype.isShadowMaterial=!0;jc.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);return this};Zc.prototype=Object.create(ma.prototype);Zc.prototype.constructor=Zc;Zc.prototype.isRawShaderMaterial=
!0;fb.prototype=Object.create(M.prototype);fb.prototype.constructor=fb;fb.prototype.isMeshStandardMaterial=!0;fb.prototype.copy=function(a){M.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;
this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=
a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};kc.prototype=Object.create(fb.prototype);kc.prototype.constructor=kc;kc.prototype.isMeshPhysicalMaterial=!0;kc.prototype.copy=function(a){fb.prototype.copy.call(this,a);this.defines={STANDARD:"",PHYSICAL:""};this.reflectivity=a.reflectivity;this.clearcoat=a.clearcoat;this.clearcoatRoughness=
a.clearcoatRoughness;this.sheen=a.sheen?(this.sheen||new H).copy(a.sheen):null;this.clearcoatNormalMap=a.clearcoatNormalMap;this.clearcoatNormalScale.copy(a.clearcoatNormalScale);this.transparency=a.transparency;return this};Ra.prototype=Object.create(M.prototype);Ra.prototype.constructor=Ra;Ra.prototype.isMeshPhongMaterial=!0;Ra.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=
a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=
a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};lc.prototype=Object.create(Ra.prototype);lc.prototype.constructor=lc;lc.prototype.isMeshToonMaterial=
!0;lc.prototype.copy=function(a){Ra.prototype.copy.call(this,a);this.gradientMap=a.gradientMap;return this};mc.prototype=Object.create(M.prototype);mc.prototype.constructor=mc;mc.prototype.isMeshNormalMaterial=!0;mc.prototype.copy=function(a){M.prototype.copy.call(this,a);this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;
this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};nc.prototype=Object.create(M.prototype);nc.prototype.constructor=nc;nc.prototype.isMeshLambertMaterial=!0;nc.prototype.copy=function(a){M.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=
a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.skinning=a.skinning;
this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};oc.prototype=Object.create(M.prototype);oc.prototype.constructor=oc;oc.prototype.isMeshMatcapMaterial=!0;oc.prototype.copy=function(a){M.prototype.copy.call(this,a);this.defines={MATCAP:""};this.color.copy(a.color);this.matcap=a.matcap;this.map=a.map;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalMapType=a.normalMapType;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;
this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.alphaMap=a.alphaMap;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};pc.prototype=Object.create(Q.prototype);pc.prototype.constructor=pc;pc.prototype.isLineDashedMaterial=!0;pc.prototype.copy=function(a){Q.prototype.copy.call(this,a);this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;return this};var Fk=Object.freeze({ShadowMaterial:jc,SpriteMaterial:Hb,
RawShaderMaterial:Zc,ShaderMaterial:ma,PointsMaterial:Qa,MeshPhysicalMaterial:kc,MeshStandardMaterial:fb,MeshPhongMaterial:Ra,MeshToonMaterial:lc,MeshNormalMaterial:mc,MeshLambertMaterial:nc,MeshDepthMaterial:Db,MeshDistanceMaterial:Eb,MeshBasicMaterial:Ga,MeshMatcapMaterial:oc,LineDashedMaterial:pc,LineBasicMaterial:Q,Material:M}),pa={arraySlice:function(a,b,c){return pa.isTypedArray(a)?new a.constructor(a.subarray(b,void 0!==c?c:a.length)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&
a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,l=0;l!==b;++l)e[g++]=a[h+l];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==
f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),c.push(g)),f=a[e++];while(void 0!==f)}}}};Object.assign(Ia.prototype,{evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a<
d)){for(var f=c+2;;){if(void 0===d){if(a<e)break d;this._cachedIndex=c=b.length;return this.afterEnd_(c-1,a,e)}if(c===f)break;e=d;d=b[++c];if(a<d)break b}d=b.length;break c}if(a>=e)break a;else{f=b[1];a<f&&(c=2,e=f);for(f=c-2;;){if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(c===f)break;d=e;e=b[--c-1];if(a>=e)break b}d=c;c=0}}for(;c<d;)e=c+d>>>1,a<b[e]?d=e:c=e+1;d=b[c];e=b[c-1];if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(void 0===d)return this._cachedIndex=
c=b.length,this.afterEnd_(c-1,e,a)}this._cachedIndex=c;this.intervalChanged_(c,e,d)}return this.interpolate_(c,e,a,d)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(a){var b=this.resultBuffer,c=this.sampleValues,d=this.valueSize;a*=d;for(var e=0;e!==d;++e)b[e]=c[a+e];return b},interpolate_:function(){throw Error("call to abstract method");},intervalChanged_:function(){}});Object.assign(Ia.prototype,{beforeStart_:Ia.prototype.copySampleValue_,
afterEnd_:Ia.prototype.copySampleValue_});Ne.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Ne,DefaultSettings_:{endingStart:2400,endingEnd:2400},intervalChanged_:function(a,b,c){var d=this.parameterPositions,e=a-2,f=a+1,g=d[e],h=d[f];if(void 0===g)switch(this.getSettings_().endingStart){case 2401:e=a;g=2*b-c;break;case 2402:e=d.length-2;g=b+d[e]-d[e+1];break;default:e=a,g=c}if(void 0===h)switch(this.getSettings_().endingEnd){case 2401:f=a;h=2*c-b;break;case 2402:f=1;h=c+d[1]-d[0];
break;default:f=a-1,h=b}a=.5*(c-b);d=this.valueSize;this._weightPrev=a/(b-g);this._weightNext=a/(h-c);this._offsetPrev=e*d;this._offsetNext=f*d},interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g,l=this._offsetPrev,k=this._offsetNext,n=this._weightPrev,u=this._weightNext,t=(c-b)/(d-b);c=t*t;d=c*t;b=-n*d+2*n*c-n*t;n=(1+n)*d+(-1.5-2*n)*c+(-.5+n)*t+1;t=(-1-u)*d+(1.5+u)*c+.5*t;u=u*d-u*c;for(c=0;c!==g;++c)e[c]=b*f[l+c]+n*f[h+c]+t*f[a+c]+u*f[k+c];
return e}});ke.prototype=Object.assign(Object.create(Ia.prototype),{constructor:ke,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g;b=(c-b)/(d-b);c=1-b;for(d=0;d!==g;++d)e[d]=f[h+d]*c+f[a+d]*b;return e}});Oe.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Oe,interpolate_:function(a){return this.copySampleValue_(a-1)}});Object.assign(oa,{toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);else{b={name:a.name,
times:pa.convertArray(a.times,Array),values:pa.convertArray(a.values,Array)};var c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b}});Object.assign(oa.prototype,{constructor:oa,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:2301,InterpolantFactoryMethodDiscrete:function(a){return new Oe(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new ke(this.times,this.values,this.getValueSize(),
a)},InterpolantFactoryMethodSmooth:function(a){return new Ne(this.times,this.values,this.getValueSize(),a)},setInterpolation:function(a){switch(a){case 2300:var b=this.InterpolantFactoryMethodDiscrete;break;case 2301:b=this.InterpolantFactoryMethodLinear;break;case 2302:b=this.InterpolantFactoryMethodSmooth}if(void 0===b){b="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);
else throw Error(b);console.warn("THREE.KeyframeTrack:",b);return this}this.createInterpolant=b;return this},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return 2300;case this.InterpolantFactoryMethodLinear:return 2301;case this.InterpolantFactoryMethodSmooth:return 2302}},getValueSize:function(){return this.values.length/this.times.length},shift:function(a){if(0!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]+=a;return this},scale:function(a){if(1!==
a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]*=a;return this},trim:function(a,b){for(var c=this.times,d=c.length,e=0,f=d-1;e!==d&&c[e]<a;)++e;for(;-1!==f&&c[f]>b;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),a=this.getValueSize(),this.times=pa.arraySlice(c,e,f),this.values=pa.arraySlice(this.values,e*a,f*a);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("THREE.KeyframeTrack: Invalid value size in track.",this),a=!1);var c=this.times;
b=this.values;var d=c.length;0===d&&(console.error("THREE.KeyframeTrack: Track is empty.",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("THREE.KeyframeTrack: Time is not a valid number.",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("THREE.KeyframeTrack: Out of order keys.",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&pa.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("THREE.KeyframeTrack: Value is not a valid number.",
this,f,d);a=!1;break}return a},optimize:function(){for(var a=this.times,b=this.values,c=this.getValueSize(),d=2302===this.getInterpolation(),e=1,f=a.length-1,g=1;g<f;++g){var h=!1,l=a[g];if(l!==a[g+1]&&(1!==g||l!==l[0]))if(d)h=!0;else{var k=g*c,n=k-c,u=k+c;for(l=0;l!==c;++l){var t=b[k+l];if(t!==b[n+l]||t!==b[u+l]){h=!0;break}}}if(h){if(g!==e)for(a[e]=a[g],h=g*c,k=e*c,l=0;l!==c;++l)b[k+l]=b[h+l];++e}}if(0<f){a[e]=a[f];h=f*c;k=e*c;for(l=0;l!==c;++l)b[k+l]=b[h+l];++e}e!==a.length&&(this.times=pa.arraySlice(a,
0,e),this.values=pa.arraySlice(b,0,e*c));return this},clone:function(){var a=pa.arraySlice(this.times,0),b=pa.arraySlice(this.values,0);a=new this.constructor(this.name,a,b);a.createInterpolant=this.createInterpolant;return a}});Pe.prototype=Object.assign(Object.create(oa.prototype),{constructor:Pe,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});Qe.prototype=Object.assign(Object.create(oa.prototype),
{constructor:Qe,ValueTypeName:"color"});$c.prototype=Object.assign(Object.create(oa.prototype),{constructor:$c,ValueTypeName:"number"});Re.prototype=Object.assign(Object.create(Ia.prototype),{constructor:Re,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;b=(c-b)/(d-b);for(c=a+g;a!==c;a+=4)ua.slerpFlat(e,0,f,a-g,f,a,b);return e}});le.prototype=Object.assign(Object.create(oa.prototype),{constructor:le,ValueTypeName:"quaternion",DefaultInterpolation:2301,
InterpolantFactoryMethodLinear:function(a){return new Re(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});Se.prototype=Object.assign(Object.create(oa.prototype),{constructor:Se,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:2300,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});ad.prototype=Object.assign(Object.create(oa.prototype),{constructor:ad,ValueTypeName:"vector"});Object.assign(Ma,{parse:function(a){for(var b=
[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(rk(c[e]).scale(d));return new Ma(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b,uuid:a.uuid};for(var d=0,e=c.length;d!==e;++d)b.push(oa.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c,d){for(var e=b.length,f=[],g=0;g<e;g++){var h=[],l=[];h.push((g+e-1)%e,g,(g+1)%e);l.push(0,1,0);var k=pa.getKeyframeOrder(h);h=pa.sortedArray(h,1,k);l=pa.sortedArray(l,1,k);d||0!==
h[0]||(h.push(e),l.push(l[0]));f.push((new $c(".morphTargetInfluences["+b[g].name+"]",h,l)).scale(1/c))}return new Ma(a,-1,f)},findByName:function(a,b){var c=a;Array.isArray(a)||(c=a.geometry&&a.geometry.animations||a.animations);for(a=0;a<c.length;a++)if(c[a].name===b)return c[a];return null},CreateClipsFromMorphTargetSequences:function(a,b,c){for(var d={},e=/^([\w-]*?)([\d]+)$/,f=0,g=a.length;f<g;f++){var h=a[f],l=h.name.match(e);if(l&&1<l.length){var k=l[1];(l=d[k])||(d[k]=l=[]);l.push(h)}}a=[];
for(k in d)a.push(Ma.CreateFromMorphTargetSequence(k,d[k],b,c));return a},parseAnimation:function(a,b){if(!a)return console.error("THREE.AnimationClip: No animation in JSONLoader data."),null;var c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];pa.flattenJSON(c,f,g,d);0!==f.length&&e.push(new a(b,f,g))}},d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30;a=a.hierarchy||[];for(var h=0;h<a.length;h++){var l=a[h].keys;if(l&&0!==l.length)if(l[0].morphTargets){f={};for(var k=0;k<l.length;k++)if(l[k].morphTargets)for(var n=
0;n<l[k].morphTargets.length;n++)f[l[k].morphTargets[n]]=-1;for(var u in f){var t=[],r=[];for(n=0;n!==l[k].morphTargets.length;++n){var p=l[k];t.push(p.time);r.push(p.morphTarget===u?1:0)}d.push(new $c(".morphTargetInfluence["+u+"]",t,r))}f=f.length*(g||1)}else k=".bones["+b[h].name+"]",c(ad,k+".position",l,"pos",d),c(le,k+".quaternion",l,"rot",d),c(ad,k+".scale",l,"scl",d)}return 0===d.length?null:new Ma(e,f,d)}});Object.assign(Ma.prototype,{resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==
c;++b){var d=this.tracks[b];a=Math.max(a,d.times[d.times.length-1])}this.duration=a;return this},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},validate:function(){for(var a=!0,b=0;b<this.tracks.length;b++)a=a&&this.tracks[b].validate();return a},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this},clone:function(){for(var a=[],b=0;b<this.tracks.length;b++)a.push(this.tracks[b].clone());return new Ma(this.name,
this.duration,a)}});var uc={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}},Zh=new pg;Object.assign(S.prototype,{load:function(){},parse:function(){},setCrossOrigin:function(a){this.crossOrigin=a;return this},setPath:function(a){this.path=a;return this},setResourcePath:function(a){this.resourcePath=a;return this}});var $a={};Na.prototype=
Object.assign(Object.create(S.prototype),{constructor:Na,load:function(a,b,c,d){void 0===a&&(a="");void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=uc.get(a);if(void 0!==f)return e.manager.itemStart(a),setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;if(void 0!==$a[a])$a[a].push({onLoad:b,onProgress:c,onError:d});else{var g=a.match(/^data:(.*?)(;base64)?,(.*)$/);if(g){c=g[1];var h=!!g[2];g=g[3];g=decodeURIComponent(g);h&&(g=atob(g));try{var l=(this.responseType||
"").toLowerCase();switch(l){case "arraybuffer":case "blob":var k=new Uint8Array(g.length);for(h=0;h<g.length;h++)k[h]=g.charCodeAt(h);var n="blob"===l?new Blob([k.buffer],{type:c}):k.buffer;break;case "document":n=(new DOMParser).parseFromString(g,c);break;case "json":n=JSON.parse(g);break;default:n=g}setTimeout(function(){b&&b(n);e.manager.itemEnd(a)},0)}catch(t){setTimeout(function(){d&&d(t);e.manager.itemError(a);e.manager.itemEnd(a)},0)}}else{$a[a]=[];$a[a].push({onLoad:b,onProgress:c,onError:d});
var u=new XMLHttpRequest;u.open("GET",a,!0);u.addEventListener("load",function(b){var c=this.response;uc.add(a,c);var d=$a[a];delete $a[a];if(200===this.status||0===this.status){0===this.status&&console.warn("THREE.FileLoader: HTTP Status 0 received.");for(var f=0,g=d.length;f<g;f++){var h=d[f];if(h.onLoad)h.onLoad(c)}}else{f=0;for(g=d.length;f<g;f++)if(h=d[f],h.onError)h.onError(b);e.manager.itemError(a)}e.manager.itemEnd(a)},!1);u.addEventListener("progress",function(b){for(var c=$a[a],d=0,e=c.length;d<
e;d++){var f=c[d];if(f.onProgress)f.onProgress(b)}},!1);u.addEventListener("error",function(b){var c=$a[a];delete $a[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemError(a);e.manager.itemEnd(a)},!1);u.addEventListener("abort",function(b){var c=$a[a];delete $a[a];for(var d=0,f=c.length;d<f;d++){var g=c[d];if(g.onError)g.onError(b)}e.manager.itemError(a);e.manager.itemEnd(a)},!1);void 0!==this.responseType&&(u.responseType=this.responseType);void 0!==this.withCredentials&&
(u.withCredentials=this.withCredentials);u.overrideMimeType&&u.overrideMimeType(void 0!==this.mimeType?this.mimeType:"text/plain");for(h in this.requestHeader)u.setRequestHeader(h,this.requestHeader[h]);u.send(null)}e.manager.itemStart(a);return u}},setResponseType:function(a){this.responseType=a;return this},setWithCredentials:function(a){this.withCredentials=a;return this},setMimeType:function(a){this.mimeType=a;return this},setRequestHeader:function(a){this.requestHeader=a;return this}});qg.prototype=
Object.assign(Object.create(S.prototype),{constructor:qg,load:function(a,b,c,d){var e=this,f=new Na(e.manager);f.setPath(e.path);f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){for(var b=[],c=0;c<a.length;c++){var d=Ma.parse(a[c]);b.push(d)}return b}});rg.prototype=Object.assign(Object.create(S.prototype),{constructor:rg,load:function(a,b,c,d){function e(e){l.load(a[e],function(a){a=f.parse(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};k+=1;6===
k&&(1===a.mipmapCount&&(h.minFilter=1006),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new Lc;h.image=g;var l=new Na(this.manager);l.setPath(this.path);l.setResponseType("arraybuffer");if(Array.isArray(a))for(var k=0,n=0,u=a.length;n<u;++n)e(n);else l.load(a,function(a){a=f.parse(a,!0);if(a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,d=0;d<c;d++){g[d]={mipmaps:[]};for(var e=0;e<a.mipmapCount;e++)g[d].mipmaps.push(a.mipmaps[d*a.mipmapCount+e]),g[d].format=a.format,g[d].width=
a.width,g[d].height=a.height}else h.image.width=a.width,h.image.height=a.height,h.mipmaps=a.mipmaps;1===a.mipmapCount&&(h.minFilter=1006);h.format=a.format;h.needsUpdate=!0;b&&b(h)},c,d);return h}});Te.prototype=Object.assign(Object.create(S.prototype),{constructor:Te,load:function(a,b,c,d){var e=this,f=new Zb,g=new Na(this.manager);g.setResponseType("arraybuffer");g.setPath(this.path);g.load(a,function(a){if(a=e.parse(a))void 0!==a.image?f.image=a.image:void 0!==a.data&&(f.image.width=a.width,f.image.height=
a.height,f.image.data=a.data),f.wrapS=void 0!==a.wrapS?a.wrapS:1001,f.wrapT=void 0!==a.wrapT?a.wrapT:1001,f.magFilter=void 0!==a.magFilter?a.magFilter:1006,f.minFilter=void 0!==a.minFilter?a.minFilter:1008,f.anisotropy=void 0!==a.anisotropy?a.anisotropy:1,void 0!==a.format&&(f.format=a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps),1===a.mipmapCount&&(f.minFilter=1006),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}});bd.prototype=Object.assign(Object.create(S.prototype),
{constructor:bd,load:function(a,b,c,d){function e(){l.removeEventListener("load",e,!1);l.removeEventListener("error",f,!1);uc.add(a,this);b&&b(this);g.manager.itemEnd(a)}function f(b){l.removeEventListener("load",e,!1);l.removeEventListener("error",f,!1);d&&d(b);g.manager.itemError(a);g.manager.itemEnd(a)}void 0!==this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var g=this,h=uc.get(a);if(void 0!==h)return g.manager.itemStart(a),setTimeout(function(){b&&b(h);g.manager.itemEnd(a)},0),h;var l=
document.createElementNS("http://www.w3.org/1999/xhtml","img");l.addEventListener("load",e,!1);l.addEventListener("error",f,!1);"data:"!==a.substr(0,5)&&void 0!==this.crossOrigin&&(l.crossOrigin=this.crossOrigin);g.manager.itemStart(a);l.src=a;return l}});Ue.prototype=Object.assign(Object.create(S.prototype),{constructor:Ue,load:function(a,b,c,d){function e(c){g.load(a[c],function(a){f.images[c]=a;h++;6===h&&(f.needsUpdate=!0,b&&b(f))},void 0,d)}var f=new ob,g=new bd(this.manager);g.setCrossOrigin(this.crossOrigin);
g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f}});Ve.prototype=Object.assign(Object.create(S.prototype),{constructor:Ve,load:function(a,b,c,d){var e=new W,f=new bd(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);f.load(a,function(c){e.image=c;c=0<a.search(/\.jpe?g($|\?)/i)||0===a.search(/^data:image\/jpeg/);e.format=c?1022:1023;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e}});Object.assign(D.prototype,{getPoint:function(){console.warn("THREE.Curve: .getPoint() not implemented.");
return null},getPointAt:function(a,b){a=this.getUtoTmapping(a);return this.getPoint(a,b)},getPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));return b},getSpacedPoints:function(a){void 0===a&&(a=5);for(var b=[],c=0;c<=a;c++)b.push(this.getPointAt(c/a));return b},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){void 0===a&&(a=this.arcLengthDivisions);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;
this.needsUpdate=!1;var b=[],c=this.getPoint(0),d,e=0;b.push(0);for(d=1;d<=a;d++){var f=this.getPoint(d/a);e+=f.distanceTo(c);b.push(e);c=f}return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=c.length;b=b?b:a*c[d-1];for(var e=0,f=d-1,g;e<=f;)if(a=Math.floor(e+(f-e)/2),g=c[a]-b,0>g)e=a+1;else if(0<g)f=a-1;else{f=a;break}a=f;if(c[a]===b)return a/(d-1);e=c[a];return(a+(b-e)/(c[a+1]-e))/(d-1)},getTangent:function(a){var b=
a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()},getTangentAt:function(a){a=this.getUtoTmapping(a);return this.getTangent(a)},computeFrenetFrames:function(a,b){var c=new n,d=[],e=[],f=[],g=new n,h=new U,l;for(l=0;l<=a;l++){var k=l/a;d[l]=this.getTangentAt(k);d[l].normalize()}e[0]=new n;f[0]=new n;l=Number.MAX_VALUE;k=Math.abs(d[0].x);var q=Math.abs(d[0].y),u=Math.abs(d[0].z);k<=l&&(l=k,c.set(1,0,0));q<=l&&(l=q,c.set(0,1,0));u<=l&&c.set(0,
0,1);g.crossVectors(d[0],c).normalize();e[0].crossVectors(d[0],g);f[0].crossVectors(d[0],e[0]);for(l=1;l<=a;l++)e[l]=e[l-1].clone(),f[l]=f[l-1].clone(),g.crossVectors(d[l-1],d[l]),g.length()>Number.EPSILON&&(g.normalize(),c=Math.acos(L.clamp(d[l-1].dot(d[l]),-1,1)),e[l].applyMatrix4(h.makeRotationAxis(g,c))),f[l].crossVectors(d[l],e[l]);if(!0===b)for(c=Math.acos(L.clamp(e[0].dot(e[a]),-1,1)),c/=a,0<d[0].dot(g.crossVectors(e[0],e[a]))&&(c=-c),l=1;l<=a;l++)e[l].applyMatrix4(h.makeRotationAxis(d[l],
c*l)),f[l].crossVectors(d[l],e[l]);return{tangents:d,normals:e,binormals:f}},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this},toJSON:function(){var a={metadata:{version:4.5,type:"Curve",generator:"Curve.toJSON"}};a.arcLengthDivisions=this.arcLengthDivisions;a.type=this.type;return a},fromJSON:function(a){this.arcLengthDivisions=a.arcLengthDivisions;return this}});Ja.prototype=Object.create(D.prototype);Ja.prototype.constructor=
Ja;Ja.prototype.isEllipseCurve=!0;Ja.prototype.getPoint=function(a,b){b=b||new w;for(var c=2*Math.PI,d=this.aEndAngle-this.aStartAngle,e=Math.abs(d)<Number.EPSILON;0>d;)d+=c;for(;d>c;)d-=c;d<Number.EPSILON&&(d=e?0:c);!0!==this.aClockwise||e||(d=d===c?-c:d-c);c=this.aStartAngle+a*d;a=this.aX+this.xRadius*Math.cos(c);var f=this.aY+this.yRadius*Math.sin(c);0!==this.aRotation&&(c=Math.cos(this.aRotation),d=Math.sin(this.aRotation),e=a-this.aX,f-=this.aY,a=e*c-f*d+this.aX,f=e*d+f*c+this.aY);return b.set(a,
f)};Ja.prototype.copy=function(a){D.prototype.copy.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};Ja.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.aX=this.aX;a.aY=this.aY;a.xRadius=this.xRadius;a.yRadius=this.yRadius;a.aStartAngle=this.aStartAngle;a.aEndAngle=this.aEndAngle;a.aClockwise=this.aClockwise;a.aRotation=
this.aRotation;return a};Ja.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.aX=a.aX;this.aY=a.aY;this.xRadius=a.xRadius;this.yRadius=a.yRadius;this.aStartAngle=a.aStartAngle;this.aEndAngle=a.aEndAngle;this.aClockwise=a.aClockwise;this.aRotation=a.aRotation;return this};cd.prototype=Object.create(Ja.prototype);cd.prototype.constructor=cd;cd.prototype.isArcCurve=!0;var Hf=new n,bh=new sg,ch=new sg,dh=new sg;ya.prototype=Object.create(D.prototype);ya.prototype.constructor=ya;ya.prototype.isCatmullRomCurve3=
!0;ya.prototype.getPoint=function(a,b){b=b||new n;var c=this.points,d=c.length;a*=d-(this.closed?0:1);var e=Math.floor(a);a-=e;this.closed?e+=0<e?0:(Math.floor(Math.abs(e)/d)+1)*d:0===a&&e===d-1&&(e=d-2,a=1);if(this.closed||0<e)var f=c[(e-1)%d];else Hf.subVectors(c[0],c[1]).add(c[0]),f=Hf;var g=c[e%d];var h=c[(e+1)%d];this.closed||e+2<d?c=c[(e+2)%d]:(Hf.subVectors(c[d-1],c[d-2]).add(c[d-1]),c=Hf);if("centripetal"===this.curveType||"chordal"===this.curveType){var l="chordal"===this.curveType?.5:.25;
d=Math.pow(f.distanceToSquared(g),l);e=Math.pow(g.distanceToSquared(h),l);l=Math.pow(h.distanceToSquared(c),l);1E-4>e&&(e=1);1E-4>d&&(d=e);1E-4>l&&(l=e);bh.initNonuniformCatmullRom(f.x,g.x,h.x,c.x,d,e,l);ch.initNonuniformCatmullRom(f.y,g.y,h.y,c.y,d,e,l);dh.initNonuniformCatmullRom(f.z,g.z,h.z,c.z,d,e,l)}else"catmullrom"===this.curveType&&(bh.initCatmullRom(f.x,g.x,h.x,c.x,this.tension),ch.initCatmullRom(f.y,g.y,h.y,c.y,this.tension),dh.initCatmullRom(f.z,g.z,h.z,c.z,this.tension));b.set(bh.calc(a),
ch.calc(a),dh.calc(a));return b};ya.prototype.copy=function(a){D.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};ya.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());a.closed=this.closed;a.curveType=this.curveType;a.tension=this.tension;return a};
ya.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new n).fromArray(d))}this.closed=a.closed;this.curveType=a.curveType;this.tension=a.tension;return this};Sa.prototype=Object.create(D.prototype);Sa.prototype.constructor=Sa;Sa.prototype.isCubicBezierCurve=!0;Sa.prototype.getPoint=function(a,b){b=b||new w;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ne(a,c.x,d.x,e.x,f.x),ne(a,c.y,d.y,e.y,
f.y));return b};Sa.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};Sa.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};Sa.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};
gb.prototype=Object.create(D.prototype);gb.prototype.constructor=gb;gb.prototype.isCubicBezierCurve3=!0;gb.prototype.getPoint=function(a,b){b=b||new n;var c=this.v0,d=this.v1,e=this.v2,f=this.v3;b.set(ne(a,c.x,d.x,e.x,f.x),ne(a,c.y,d.y,e.y,f.y),ne(a,c.z,d.z,e.z,f.z));return b};gb.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);this.v3.copy(a.v3);return this};gb.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v0=this.v0.toArray();
a.v1=this.v1.toArray();a.v2=this.v2.toArray();a.v3=this.v3.toArray();return a};gb.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);this.v3.fromArray(a.v3);return this};za.prototype=Object.create(D.prototype);za.prototype.constructor=za;za.prototype.isLineCurve=!0;za.prototype.getPoint=function(a,b){b=b||new w;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};za.prototype.getPointAt=
function(a,b){return this.getPoint(a,b)};za.prototype.getTangent=function(){return this.v2.clone().sub(this.v1).normalize()};za.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};za.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};za.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ta.prototype=
Object.create(D.prototype);Ta.prototype.constructor=Ta;Ta.prototype.isLineCurve3=!0;Ta.prototype.getPoint=function(a,b){b=b||new n;1===a?b.copy(this.v2):(b.copy(this.v2).sub(this.v1),b.multiplyScalar(a).add(this.v1));return b};Ta.prototype.getPointAt=function(a,b){return this.getPoint(a,b)};Ta.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};Ta.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v1=this.v1.toArray();a.v2=this.v2.toArray();
return a};Ta.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Ua.prototype=Object.create(D.prototype);Ua.prototype.constructor=Ua;Ua.prototype.isQuadraticBezierCurve=!0;Ua.prototype.getPoint=function(a,b){b=b||new w;var c=this.v0,d=this.v1,e=this.v2;b.set(me(a,c.x,d.x,e.x),me(a,c.y,d.y,e.y));return b};Ua.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};
Ua.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};Ua.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};hb.prototype=Object.create(D.prototype);hb.prototype.constructor=hb;hb.prototype.isQuadraticBezierCurve3=!0;hb.prototype.getPoint=function(a,b){b=b||new n;var c=this.v0,d=this.v1,e=this.v2;b.set(me(a,c.x,
d.x,e.x),me(a,c.y,d.y,e.y),me(a,c.z,d.z,e.z));return b};hb.prototype.copy=function(a){D.prototype.copy.call(this,a);this.v0.copy(a.v0);this.v1.copy(a.v1);this.v2.copy(a.v2);return this};hb.prototype.toJSON=function(){var a=D.prototype.toJSON.call(this);a.v0=this.v0.toArray();a.v1=this.v1.toArray();a.v2=this.v2.toArray();return a};hb.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.v0.fromArray(a.v0);this.v1.fromArray(a.v1);this.v2.fromArray(a.v2);return this};Va.prototype=Object.create(D.prototype);
Va.prototype.constructor=Va;Va.prototype.isSplineCurve=!0;Va.prototype.getPoint=function(a,b){b=b||new w;var c=this.points,d=(c.length-1)*a;a=Math.floor(d);d-=a;var e=c[0===a?a:a-1],f=c[a],g=c[a>c.length-2?c.length-1:a+1];c=c[a>c.length-3?c.length-1:a+2];b.set($h(d,e.x,f.x,g.x,c.x),$h(d,e.y,f.y,g.y,c.y));return b};Va.prototype.copy=function(a){D.prototype.copy.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++)this.points.push(a.points[b].clone());return this};Va.prototype.toJSON=function(){var a=
D.prototype.toJSON.call(this);a.points=[];for(var b=0,c=this.points.length;b<c;b++)a.points.push(this.points[b].toArray());return a};Va.prototype.fromJSON=function(a){D.prototype.fromJSON.call(this,a);this.points=[];for(var b=0,c=a.points.length;b<c;b++){var d=a.points[b];this.points.push((new w).fromArray(d))}return this};var eh=Object.freeze({ArcCurve:cd,CatmullRomCurve3:ya,CubicBezierCurve:Sa,CubicBezierCurve3:gb,EllipseCurve:Ja,LineCurve:za,LineCurve3:Ta,QuadraticBezierCurve:Ua,QuadraticBezierCurve3:hb,
SplineCurve:Va});rb.prototype=Object.assign(Object.create(D.prototype),{constructor:rb,add:function(a){this.curves.push(a)},closePath:function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new za(b,a))},getPoint:function(a){var b=a*this.getLength(),c=this.getCurveLengths();for(a=0;a<c.length;){if(c[a]>=b)return b=c[a]-b,a=this.curves[a],c=a.getLength(),a.getPointAt(0===c?0:1-b/c);a++}return null},getLength:function(){var a=this.getCurveLengths();
return a[a.length-1]},updateArcLengths:function(){this.needsUpdate=!0;this.cacheLengths=null;this.getCurveLengths()},getCurveLengths:function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a},getSpacedPoints:function(a){void 0===a&&(a=40);for(var b=[],c=0;c<=a;c++)b.push(this.getPoint(c/a));this.autoClose&&b.push(b[0]);return b},getPoints:function(a){a=
a||12;for(var b=[],c,d=0,e=this.curves;d<e.length;d++){var f=e[d];f=f.getPoints(f&&f.isEllipseCurve?2*a:f&&(f.isLineCurve||f.isLineCurve3)?1:f&&f.isSplineCurve?a*f.points.length:a);for(var g=0;g<f.length;g++){var h=f[g];c&&c.equals(h)||(b.push(h),c=h)}}this.autoClose&&1<b.length&&!b[b.length-1].equals(b[0])&&b.push(b[0]);return b},copy:function(a){D.prototype.copy.call(this,a);this.curves=[];for(var b=0,c=a.curves.length;b<c;b++)this.curves.push(a.curves[b].clone());this.autoClose=a.autoClose;return this},
toJSON:function(){var a=D.prototype.toJSON.call(this);a.autoClose=this.autoClose;a.curves=[];for(var b=0,c=this.curves.length;b<c;b++)a.curves.push(this.curves[b].toJSON());return a},fromJSON:function(a){D.prototype.fromJSON.call(this,a);this.autoClose=a.autoClose;this.curves=[];for(var b=0,c=a.curves.length;b<c;b++){var d=a.curves[b];this.curves.push((new eh[d.type]).fromJSON(d))}return this}});Wa.prototype=Object.assign(Object.create(rb.prototype),{constructor:Wa,setFromPoints:function(a){this.moveTo(a[0].x,
a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)},moveTo:function(a,b){this.currentPoint.set(a,b)},lineTo:function(a,b){var c=new za(this.currentPoint.clone(),new w(a,b));this.curves.push(c);this.currentPoint.set(a,b)},quadraticCurveTo:function(a,b,c,d){a=new Ua(this.currentPoint.clone(),new w(a,b),new w(c,d));this.curves.push(a);this.currentPoint.set(c,d)},bezierCurveTo:function(a,b,c,d,e,f){a=new Sa(this.currentPoint.clone(),new w(a,b),new w(c,d),new w(e,f));this.curves.push(a);
this.currentPoint.set(e,f)},splineThru:function(a){var b=[this.currentPoint.clone()].concat(a);b=new Va(b);this.curves.push(b);this.currentPoint.copy(a[a.length-1])},arc:function(a,b,c,d,e,f){this.absarc(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f)},absarc:function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)},ellipse:function(a,b,c,d,e,f,g,h){this.absellipse(a+this.currentPoint.x,b+this.currentPoint.y,c,d,e,f,g,h)},absellipse:function(a,b,c,d,e,f,g,h){a=new Ja(a,b,c,d,e,f,g,h);0<this.curves.length&&
(b=a.getPoint(0),b.equals(this.currentPoint)||this.lineTo(b.x,b.y));this.curves.push(a);a=a.getPoint(1);this.currentPoint.copy(a)},copy:function(a){rb.prototype.copy.call(this,a);this.currentPoint.copy(a.currentPoint);return this},toJSON:function(){var a=rb.prototype.toJSON.call(this);a.currentPoint=this.currentPoint.toArray();return a},fromJSON:function(a){rb.prototype.fromJSON.call(this,a);this.currentPoint.fromArray(a.currentPoint);return this}});Jb.prototype=Object.assign(Object.create(Wa.prototype),
{constructor:Jb,getPointsHoles:function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b},extractPoints:function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}},copy:function(a){Wa.prototype.copy.call(this,a);this.holes=[];for(var b=0,c=a.holes.length;b<c;b++)this.holes.push(a.holes[b].clone());return this},toJSON:function(){var a=Wa.prototype.toJSON.call(this);a.uuid=this.uuid;a.holes=[];for(var b=0,c=this.holes.length;b<c;b++)a.holes.push(this.holes[b].toJSON());
return a},fromJSON:function(a){Wa.prototype.fromJSON.call(this,a);this.uuid=a.uuid;this.holes=[];for(var b=0,c=a.holes.length;b<c;b++){var d=a.holes[b];this.holes.push((new Wa).fromJSON(d))}return this}});da.prototype=Object.assign(Object.create(B.prototype),{constructor:da,isLight:!0,copy:function(a){B.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this},toJSON:function(a){a=B.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=
this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);void 0!==this.shadow&&(a.object.shadow=this.shadow.toJSON());return a}});We.prototype=Object.assign(Object.create(da.prototype),{constructor:We,isHemisphereLight:!0,copy:function(a){da.prototype.copy.call(this,
a);this.groundColor.copy(a.groundColor);return this}});Object.assign(ib.prototype,{_projScreenMatrix:new U,_lightPositionWorld:new n,_lookTarget:new n,getViewportCount:function(){return this._viewportCount},getFrustum:function(){return this._frustum},updateMatrices:function(a){var b=this.camera,c=this.matrix,d=this._projScreenMatrix,e=this._lookTarget,f=this._lightPositionWorld;f.setFromMatrixPosition(a.matrixWorld);b.position.copy(f);e.setFromMatrixPosition(a.target.matrixWorld);b.lookAt(e);b.updateMatrixWorld();
d.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);this._frustum.setFromMatrix(d);c.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);c.multiply(b.projectionMatrix);c.multiply(b.matrixWorldInverse)},getViewport:function(a){return this._viewports[a]},getFrameExtents:function(){return this._frameExtents},copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var a=
{};0!==this.bias&&(a.bias=this.bias);1!==this.radius&&(a.radius=this.radius);if(512!==this.mapSize.x||512!==this.mapSize.y)a.mapSize=this.mapSize.toArray();a.camera=this.camera.toJSON(!1).object;delete a.camera.matrix;return a}});Xe.prototype=Object.assign(Object.create(ib.prototype),{constructor:Xe,isSpotLightShadow:!0,updateMatrices:function(a,b,c){var d=this.camera,e=2*L.RAD2DEG*a.angle,f=this.mapSize.width/this.mapSize.height,g=a.distance||d.far;if(e!==d.fov||f!==d.aspect||g!==d.far)d.fov=e,d.aspect=
f,d.far=g,d.updateProjectionMatrix();ib.prototype.updateMatrices.call(this,a,b,c)}});Ye.prototype=Object.assign(Object.create(da.prototype),{constructor:Ye,isSpotLight:!0,copy:function(a){da.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});tg.prototype=Object.assign(Object.create(ib.prototype),{constructor:tg,isPointLightShadow:!0,updateMatrices:function(a,b,
c){b=this.camera;var d=this.matrix,e=this._lightPositionWorld,f=this._lookTarget,g=this._projScreenMatrix;e.setFromMatrixPosition(a.matrixWorld);b.position.copy(e);f.copy(b.position);f.add(this._cubeDirections[c]);b.up.copy(this._cubeUps[c]);b.lookAt(f);b.updateMatrixWorld();d.makeTranslation(-e.x,-e.y,-e.z);g.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);this._frustum.setFromMatrix(g)}});Ze.prototype=Object.assign(Object.create(da.prototype),{constructor:Ze,isPointLight:!0,copy:function(a){da.prototype.copy.call(this,
a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this}});oe.prototype=Object.assign(Object.create(bb.prototype),{constructor:oe,isOrthographicCamera:!0,copy:function(a,b){bb.prototype.copy.call(this,a,b);this.left=a.left;this.right=a.right;this.top=a.top;this.bottom=a.bottom;this.near=a.near;this.far=a.far;this.zoom=a.zoom;this.view=null===a.view?null:Object.assign({},a.view);return this},setViewOffset:function(a,b,c,d,e,f){null===this.view&&(this.view={enabled:!0,
fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1});this.view.enabled=!0;this.view.fullWidth=a;this.view.fullHeight=b;this.view.offsetX=c;this.view.offsetY=d;this.view.width=e;this.view.height=f;this.updateProjectionMatrix()},clearViewOffset:function(){null!==this.view&&(this.view.enabled=!1);this.updateProjectionMatrix()},updateProjectionMatrix:function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/
2,e=c-a;c+=a;a=d+b;b=d-b;if(null!==this.view&&this.view.enabled){c=this.zoom/(this.view.width/this.view.fullWidth);b=this.zoom/(this.view.height/this.view.fullHeight);var f=(this.right-this.left)/this.view.width;d=(this.top-this.bottom)/this.view.height;e+=this.view.offsetX/c*f;c=e+this.view.width/c*f;a-=this.view.offsetY/b*d;b=a-this.view.height/b*d}this.projectionMatrix.makeOrthographic(e,c,a,b,this.near,this.far);this.projectionMatrixInverse.getInverse(this.projectionMatrix)},toJSON:function(a){a=
B.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;a.object.far=this.far;null!==this.view&&(a.object.view=Object.assign({},this.view));return a}});$e.prototype=Object.assign(Object.create(ib.prototype),{constructor:$e,isDirectionalLightShadow:!0,updateMatrices:function(a,b,c){ib.prototype.updateMatrices.call(this,a,b,c)}});af.prototype=Object.assign(Object.create(da.prototype),
{constructor:af,isDirectionalLight:!0,copy:function(a){da.prototype.copy.call(this,a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this}});bf.prototype=Object.assign(Object.create(da.prototype),{constructor:bf,isAmbientLight:!0});cf.prototype=Object.assign(Object.create(da.prototype),{constructor:cf,isRectAreaLight:!0,copy:function(a){da.prototype.copy.call(this,a);this.width=a.width;this.height=a.height;return this},toJSON:function(a){a=da.prototype.toJSON.call(this,a);a.object.width=
this.width;a.object.height=this.height;return a}});df.prototype=Object.assign(Object.create(S.prototype),{constructor:df,load:function(a,b,c,d){var e=this,f=new Na(e.manager);f.setPath(e.path);f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){function b(a){void 0===c[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return c[a]}var c=this.textures,d=new Fk[a.type];void 0!==a.uuid&&(d.uuid=a.uuid);void 0!==a.name&&(d.name=a.name);void 0!==a.color&&d.color.setHex(a.color);
void 0!==a.roughness&&(d.roughness=a.roughness);void 0!==a.metalness&&(d.metalness=a.metalness);void 0!==a.sheen&&(d.sheen=(new H).setHex(a.sheen));void 0!==a.emissive&&d.emissive.setHex(a.emissive);void 0!==a.specular&&d.specular.setHex(a.specular);void 0!==a.shininess&&(d.shininess=a.shininess);void 0!==a.clearcoat&&(d.clearcoat=a.clearcoat);void 0!==a.clearcoatRoughness&&(d.clearcoatRoughness=a.clearcoatRoughness);void 0!==a.vertexColors&&(d.vertexColors=a.vertexColors);void 0!==a.fog&&(d.fog=
a.fog);void 0!==a.flatShading&&(d.flatShading=a.flatShading);void 0!==a.blending&&(d.blending=a.blending);void 0!==a.combine&&(d.combine=a.combine);void 0!==a.side&&(d.side=a.side);void 0!==a.opacity&&(d.opacity=a.opacity);void 0!==a.transparent&&(d.transparent=a.transparent);void 0!==a.alphaTest&&(d.alphaTest=a.alphaTest);void 0!==a.depthTest&&(d.depthTest=a.depthTest);void 0!==a.depthWrite&&(d.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(d.colorWrite=a.colorWrite);void 0!==a.stencilWrite&&(d.stencilWrite=
a.stencilWrite);void 0!==a.stencilWriteMask&&(d.stencilWriteMask=a.stencilWriteMask);void 0!==a.stencilFunc&&(d.stencilFunc=a.stencilFunc);void 0!==a.stencilRef&&(d.stencilRef=a.stencilRef);void 0!==a.stencilFuncMask&&(d.stencilFuncMask=a.stencilFuncMask);void 0!==a.stencilFail&&(d.stencilFail=a.stencilFail);void 0!==a.stencilZFail&&(d.stencilZFail=a.stencilZFail);void 0!==a.stencilZPass&&(d.stencilZPass=a.stencilZPass);void 0!==a.wireframe&&(d.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&
(d.wireframeLinewidth=a.wireframeLinewidth);void 0!==a.wireframeLinecap&&(d.wireframeLinecap=a.wireframeLinecap);void 0!==a.wireframeLinejoin&&(d.wireframeLinejoin=a.wireframeLinejoin);void 0!==a.rotation&&(d.rotation=a.rotation);1!==a.linewidth&&(d.linewidth=a.linewidth);void 0!==a.dashSize&&(d.dashSize=a.dashSize);void 0!==a.gapSize&&(d.gapSize=a.gapSize);void 0!==a.scale&&(d.scale=a.scale);void 0!==a.polygonOffset&&(d.polygonOffset=a.polygonOffset);void 0!==a.polygonOffsetFactor&&(d.polygonOffsetFactor=
a.polygonOffsetFactor);void 0!==a.polygonOffsetUnits&&(d.polygonOffsetUnits=a.polygonOffsetUnits);void 0!==a.skinning&&(d.skinning=a.skinning);void 0!==a.morphTargets&&(d.morphTargets=a.morphTargets);void 0!==a.morphNormals&&(d.morphNormals=a.morphNormals);void 0!==a.dithering&&(d.dithering=a.dithering);void 0!==a.visible&&(d.visible=a.visible);void 0!==a.toneMapped&&(d.toneMapped=a.toneMapped);void 0!==a.userData&&(d.userData=a.userData);if(void 0!==a.uniforms)for(var e in a.uniforms){var f=a.uniforms[e];
d.uniforms[e]={};switch(f.type){case "t":d.uniforms[e].value=b(f.value);break;case "c":d.uniforms[e].value=(new H).setHex(f.value);break;case "v2":d.uniforms[e].value=(new w).fromArray(f.value);break;case "v3":d.uniforms[e].value=(new n).fromArray(f.value);break;case "v4":d.uniforms[e].value=(new aa).fromArray(f.value);break;case "m3":d.uniforms[e].value=(new Y).fromArray(f.value);case "m4":d.uniforms[e].value=(new U).fromArray(f.value);break;default:d.uniforms[e].value=f.value}}void 0!==a.defines&&
(d.defines=a.defines);void 0!==a.vertexShader&&(d.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(d.fragmentShader=a.fragmentShader);if(void 0!==a.extensions)for(var g in a.extensions)d.extensions[g]=a.extensions[g];void 0!==a.shading&&(d.flatShading=1===a.shading);void 0!==a.size&&(d.size=a.size);void 0!==a.sizeAttenuation&&(d.sizeAttenuation=a.sizeAttenuation);void 0!==a.map&&(d.map=b(a.map));void 0!==a.matcap&&(d.matcap=b(a.matcap));void 0!==a.alphaMap&&(d.alphaMap=b(a.alphaMap),d.transparent=
!0);void 0!==a.bumpMap&&(d.bumpMap=b(a.bumpMap));void 0!==a.bumpScale&&(d.bumpScale=a.bumpScale);void 0!==a.normalMap&&(d.normalMap=b(a.normalMap));void 0!==a.normalMapType&&(d.normalMapType=a.normalMapType);void 0!==a.normalScale&&(e=a.normalScale,!1===Array.isArray(e)&&(e=[e,e]),d.normalScale=(new w).fromArray(e));void 0!==a.displacementMap&&(d.displacementMap=b(a.displacementMap));void 0!==a.displacementScale&&(d.displacementScale=a.displacementScale);void 0!==a.displacementBias&&(d.displacementBias=
a.displacementBias);void 0!==a.roughnessMap&&(d.roughnessMap=b(a.roughnessMap));void 0!==a.metalnessMap&&(d.metalnessMap=b(a.metalnessMap));void 0!==a.emissiveMap&&(d.emissiveMap=b(a.emissiveMap));void 0!==a.emissiveIntensity&&(d.emissiveIntensity=a.emissiveIntensity);void 0!==a.specularMap&&(d.specularMap=b(a.specularMap));void 0!==a.envMap&&(d.envMap=b(a.envMap));void 0!==a.envMapIntensity&&(d.envMapIntensity=a.envMapIntensity);void 0!==a.reflectivity&&(d.reflectivity=a.reflectivity);void 0!==a.refractionRatio&&
(d.refractionRatio=a.refractionRatio);void 0!==a.lightMap&&(d.lightMap=b(a.lightMap));void 0!==a.lightMapIntensity&&(d.lightMapIntensity=a.lightMapIntensity);void 0!==a.aoMap&&(d.aoMap=b(a.aoMap));void 0!==a.aoMapIntensity&&(d.aoMapIntensity=a.aoMapIntensity);void 0!==a.gradientMap&&(d.gradientMap=b(a.gradientMap));void 0!==a.clearcoatNormalMap&&(d.clearcoatNormalMap=b(a.clearcoatNormalMap));void 0!==a.clearcoatNormalScale&&(d.clearcoatNormalScale=(new w).fromArray(a.clearcoatNormalScale));return d},
setTextures:function(a){this.textures=a;return this}});var fh={decodeText:function(a){if("undefined"!==typeof TextDecoder)return(new TextDecoder).decode(a);for(var b="",c=0,d=a.length;c<d;c++)b+=String.fromCharCode(a[c]);try{return decodeURIComponent(escape(b))}catch(e){return b}},extractUrlBase:function(a){var b=a.lastIndexOf("/");return-1===b?"./":a.substr(0,b+1)}};ef.prototype=Object.assign(Object.create(E.prototype),{constructor:ef,isInstancedBufferGeometry:!0,copy:function(a){E.prototype.copy.call(this,
a);this.maxInstancedCount=a.maxInstancedCount;return this},clone:function(){return(new this.constructor).copy(this)},toJSON:function(){var a=E.prototype.toJSON.call(this);a.maxInstancedCount=this.maxInstancedCount;a.isInstancedBufferGeometry=!0;return a}});ff.prototype=Object.assign(Object.create(O.prototype),{constructor:ff,isInstancedBufferAttribute:!0,copy:function(a){O.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this},toJSON:function(){var a=O.prototype.toJSON.call(this);
a.meshPerAttribute=this.meshPerAttribute;a.isInstancedBufferAttribute=!0;return a}});gf.prototype=Object.assign(Object.create(S.prototype),{constructor:gf,load:function(a,b,c,d){var e=this,f=new Na(e.manager);f.setPath(e.path);f.load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){var b=a.isInstancedBufferGeometry?new ef:new E,c=a.data.index;if(void 0!==c){var d=new gh[c.type](c.array);b.setIndex(new O(d,1))}c=a.data.attributes;for(var e in c){var f=c[e];d=new gh[f.type](f.array);
d=new (f.isInstancedBufferAttribute?ff:O)(d,f.itemSize,f.normalized);void 0!==f.name&&(d.name=f.name);b.addAttribute(e,d)}var g=a.data.morphAttributes;if(g)for(e in g){var h=g[e],l=[];c=0;for(var k=h.length;c<k;c++)f=h[c],d=new gh[f.type](f.array),d=new O(d,f.itemSize,f.normalized),void 0!==f.name&&(d.name=f.name),l.push(d);b.morphAttributes[e]=l}e=a.data.groups||a.data.drawcalls||a.data.offsets;if(void 0!==e)for(c=0,f=e.length;c!==f;++c)d=e[c],b.addGroup(d.start,d.count,d.materialIndex);c=a.data.boundingSphere;
void 0!==c&&(e=new n,void 0!==c.center&&e.fromArray(c.center),b.boundingSphere=new nb(e,c.radius));a.name&&(b.name=a.name);a.userData&&(b.userData=a.userData);return b}});var gh={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:"undefined"!==typeof Uint8ClampedArray?Uint8ClampedArray:Uint8Array,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};hf.prototype=Object.assign(Object.create(S.prototype),
{constructor:hf,load:function(a,b,c,d){var e=this,f=""===this.path?fh.extractUrlBase(a):this.path;this.resourcePath=this.resourcePath||f;f=new Na(e.manager);f.setPath(this.path);f.load(a,function(c){var f=null;try{f=JSON.parse(c)}catch(l){void 0!==d&&d(l);console.error("THREE:ObjectLoader: Can't parse "+a+".",l.message);return}c=f.metadata;void 0===c||void 0===c.type||"geometry"===c.type.toLowerCase()?console.error("THREE.ObjectLoader: Can't load "+a):e.parse(f,b)},c,d)},parse:function(a,b){var c=
this.parseShape(a.shapes);c=this.parseGeometries(a.geometries,c);var d=this.parseImages(a.images,function(){void 0!==b&&b(e)});d=this.parseTextures(a.textures,d);d=this.parseMaterials(a.materials,d);var e=this.parseObject(a.object,c,d);a.animations&&(e.animations=this.parseAnimations(a.animations));void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseShape:function(a){var b={};if(void 0!==a)for(var c=0,d=a.length;c<d;c++){var e=(new Jb).fromJSON(a[c]);b[e.uuid]=e}return b},parseGeometries:function(a,
b){var c={};if(void 0!==a)for(var d=new gf,e=0,f=a.length;e<f;e++){var g=a[e];switch(g.type){case "PlaneGeometry":case "PlaneBufferGeometry":var h=new ta[g.type](g.width,g.height,g.widthSegments,g.heightSegments);break;case "BoxGeometry":case "BoxBufferGeometry":case "CubeGeometry":h=new ta[g.type](g.width,g.height,g.depth,g.widthSegments,g.heightSegments,g.depthSegments);break;case "CircleGeometry":case "CircleBufferGeometry":h=new ta[g.type](g.radius,g.segments,g.thetaStart,g.thetaLength);break;
case "CylinderGeometry":case "CylinderBufferGeometry":h=new ta[g.type](g.radiusTop,g.radiusBottom,g.height,g.radialSegments,g.heightSegments,g.openEnded,g.thetaStart,g.thetaLength);break;case "ConeGeometry":case "ConeBufferGeometry":h=new ta[g.type](g.radius,g.height,g.radialSegments,g.heightSegments,g.openEnded,g.thetaStart,g.thetaLength);break;case "SphereGeometry":case "SphereBufferGeometry":h=new ta[g.type](g.radius,g.widthSegments,g.heightSegments,g.phiStart,g.phiLength,g.thetaStart,g.thetaLength);
break;case "DodecahedronGeometry":case "DodecahedronBufferGeometry":case "IcosahedronGeometry":case "IcosahedronBufferGeometry":case "OctahedronGeometry":case "OctahedronBufferGeometry":case "TetrahedronGeometry":case "TetrahedronBufferGeometry":h=new ta[g.type](g.radius,g.detail);break;case "RingGeometry":case "RingBufferGeometry":h=new ta[g.type](g.innerRadius,g.outerRadius,g.thetaSegments,g.phiSegments,g.thetaStart,g.thetaLength);break;case "TorusGeometry":case "TorusBufferGeometry":h=new ta[g.type](g.radius,
g.tube,g.radialSegments,g.tubularSegments,g.arc);break;case "TorusKnotGeometry":case "TorusKnotBufferGeometry":h=new ta[g.type](g.radius,g.tube,g.tubularSegments,g.radialSegments,g.p,g.q);break;case "TubeGeometry":case "TubeBufferGeometry":h=new ta[g.type]((new eh[g.path.type]).fromJSON(g.path),g.tubularSegments,g.radius,g.radialSegments,g.closed);break;case "LatheGeometry":case "LatheBufferGeometry":h=new ta[g.type](g.points,g.segments,g.phiStart,g.phiLength);break;case "PolyhedronGeometry":case "PolyhedronBufferGeometry":h=
new ta[g.type](g.vertices,g.indices,g.radius,g.details);break;case "ShapeGeometry":case "ShapeBufferGeometry":h=[];for(var l=0,k=g.shapes.length;l<k;l++){var n=b[g.shapes[l]];h.push(n)}h=new ta[g.type](h,g.curveSegments);break;case "ExtrudeGeometry":case "ExtrudeBufferGeometry":h=[];l=0;for(k=g.shapes.length;l<k;l++)n=b[g.shapes[l]],h.push(n);l=g.options.extrudePath;void 0!==l&&(g.options.extrudePath=(new eh[l.type]).fromJSON(l));h=new ta[g.type](h,g.options);break;case "BufferGeometry":case "InstancedBufferGeometry":h=
d.parse(g);break;case "Geometry":"THREE"in window&&"LegacyJSONLoader"in THREE?h=(new THREE.LegacyJSONLoader).parse(g,this.resourcePath).geometry:console.error('THREE.ObjectLoader: You have to import LegacyJSONLoader in order load geometry data of type "Geometry".');break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+g.type+'"');continue}h.uuid=g.uuid;void 0!==g.name&&(h.name=g.name);!0===h.isBufferGeometry&&void 0!==g.userData&&(h.userData=g.userData);c[g.uuid]=h}return c},
parseMaterials:function(a,b){var c={},d={};if(void 0!==a){var e=new df;e.setTextures(b);b=0;for(var f=a.length;b<f;b++){var g=a[b];if("MultiMaterial"===g.type){for(var h=[],l=0;l<g.materials.length;l++){var k=g.materials[l];void 0===c[k.uuid]&&(c[k.uuid]=e.parse(k));h.push(c[k.uuid])}d[g.uuid]=h}else void 0===c[g.uuid]&&(c[g.uuid]=e.parse(g)),d[g.uuid]=c[g.uuid]}}return d},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c],e=Ma.parse(d);void 0!==d.uuid&&(e.uuid=d.uuid);b.push(e)}return b},
parseImages:function(a,b){function c(a){d.manager.itemStart(a);return f.load(a,function(){d.manager.itemEnd(a)},void 0,function(){d.manager.itemError(a);d.manager.itemEnd(a)})}var d=this,e={};if(void 0!==a&&0<a.length){b=new pg(b);var f=new bd(b);f.setCrossOrigin(this.crossOrigin);b=0;for(var g=a.length;b<g;b++){var h=a[b],l=h.url;if(Array.isArray(l)){e[h.uuid]=[];for(var k=0,n=l.length;k<n;k++){var u=l[k];u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(u)?u:d.resourcePath+u;e[h.uuid].push(c(u))}}else u=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(h.url)?
h.url:d.resourcePath+h.url,e[h.uuid]=c(u)}}return e},parseTextures:function(a,b){function c(a,b){if("number"===typeof a)return a;console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",a);return b[a]}var d={};if(void 0!==a)for(var e=0,f=a.length;e<f;e++){var g=a[e];void 0===g.image&&console.warn('THREE.ObjectLoader: No "image" specified for',g.uuid);void 0===b[g.image]&&console.warn("THREE.ObjectLoader: Undefined image",g.image);var h=Array.isArray(b[g.image])?new ob(b[g.image]):
new W(b[g.image]);h.needsUpdate=!0;h.uuid=g.uuid;void 0!==g.name&&(h.name=g.name);void 0!==g.mapping&&(h.mapping=c(g.mapping,Gk));void 0!==g.offset&&h.offset.fromArray(g.offset);void 0!==g.repeat&&h.repeat.fromArray(g.repeat);void 0!==g.center&&h.center.fromArray(g.center);void 0!==g.rotation&&(h.rotation=g.rotation);void 0!==g.wrap&&(h.wrapS=c(g.wrap[0],Ci),h.wrapT=c(g.wrap[1],Ci));void 0!==g.format&&(h.format=g.format);void 0!==g.type&&(h.type=g.type);void 0!==g.encoding&&(h.encoding=g.encoding);
void 0!==g.minFilter&&(h.minFilter=c(g.minFilter,Di));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter,Di));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);void 0!==g.flipY&&(h.flipY=g.flipY);void 0!==g.premultiplyAlpha&&(h.premultiplyAlpha=g.premultiplyAlpha);void 0!==g.unpackAlignment&&(h.unpackAlignment=g.unpackAlignment);d[g.uuid]=h}return d},parseObject:function(a,b,c){function d(a){void 0===b[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",a);return b[a]}function e(a){if(void 0!==
a){if(Array.isArray(a)){for(var b=[],d=0,e=a.length;d<e;d++){var f=a[d];void 0===c[f]&&console.warn("THREE.ObjectLoader: Undefined material",f);b.push(c[f])}return b}void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined material",a);return c[a]}}switch(a.type){case "Scene":var f=new wd;void 0!==a.background&&Number.isInteger(a.background)&&(f.background=new H(a.background));void 0!==a.fog&&("Fog"===a.fog.type?f.fog=new Je(a.fog.color,a.fog.near,a.fog.far):"FogExp2"===a.fog.type&&(f.fog=new Ie(a.fog.color,
a.fog.density)));break;case "PerspectiveCamera":f=new na(a.fov,a.aspect,a.near,a.far);void 0!==a.focus&&(f.focus=a.focus);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.filmGauge&&(f.filmGauge=a.filmGauge);void 0!==a.filmOffset&&(f.filmOffset=a.filmOffset);void 0!==a.view&&(f.view=Object.assign({},a.view));break;case "OrthographicCamera":f=new oe(a.left,a.right,a.top,a.bottom,a.near,a.far);void 0!==a.zoom&&(f.zoom=a.zoom);void 0!==a.view&&(f.view=Object.assign({},a.view));break;case "AmbientLight":f=
new bf(a.color,a.intensity);break;case "DirectionalLight":f=new af(a.color,a.intensity);break;case "PointLight":f=new Ze(a.color,a.intensity,a.distance,a.decay);break;case "RectAreaLight":f=new cf(a.color,a.intensity,a.width,a.height);break;case "SpotLight":f=new Ye(a.color,a.intensity,a.distance,a.angle,a.penumbra,a.decay);break;case "HemisphereLight":f=new We(a.color,a.groundColor,a.intensity);break;case "SkinnedMesh":console.warn("THREE.ObjectLoader.parseObject() does not support SkinnedMesh yet.");
case "Mesh":f=d(a.geometry);var g=e(a.material);f=f.bones&&0<f.bones.length?new Od(f,g):new ja(f,g);void 0!==a.drawMode&&f.setDrawMode(a.drawMode);break;case "LOD":f=new Nd;break;case "Line":f=new xa(d(a.geometry),e(a.material),a.mode);break;case "LineLoop":f=new Me(d(a.geometry),e(a.material));break;case "LineSegments":f=new ca(d(a.geometry),e(a.material));break;case "PointCloud":case "Points":f=new Kc(d(a.geometry),e(a.material));break;case "Sprite":f=new Ld(e(a.material));break;case "Group":f=
new Hc;break;default:f=new B}f.uuid=a.uuid;void 0!==a.name&&(f.name=a.name);void 0!==a.matrix?(f.matrix.fromArray(a.matrix),void 0!==a.matrixAutoUpdate&&(f.matrixAutoUpdate=a.matrixAutoUpdate),f.matrixAutoUpdate&&f.matrix.decompose(f.position,f.quaternion,f.scale)):(void 0!==a.position&&f.position.fromArray(a.position),void 0!==a.rotation&&f.rotation.fromArray(a.rotation),void 0!==a.quaternion&&f.quaternion.fromArray(a.quaternion),void 0!==a.scale&&f.scale.fromArray(a.scale));void 0!==a.castShadow&&
(f.castShadow=a.castShadow);void 0!==a.receiveShadow&&(f.receiveShadow=a.receiveShadow);a.shadow&&(void 0!==a.shadow.bias&&(f.shadow.bias=a.shadow.bias),void 0!==a.shadow.radius&&(f.shadow.radius=a.shadow.radius),void 0!==a.shadow.mapSize&&f.shadow.mapSize.fromArray(a.shadow.mapSize),void 0!==a.shadow.camera&&(f.shadow.camera=this.parseObject(a.shadow.camera)));void 0!==a.visible&&(f.visible=a.visible);void 0!==a.frustumCulled&&(f.frustumCulled=a.frustumCulled);void 0!==a.renderOrder&&(f.renderOrder=
a.renderOrder);void 0!==a.userData&&(f.userData=a.userData);void 0!==a.layers&&(f.layers.mask=a.layers);if(void 0!==a.children){g=a.children;for(var h=0;h<g.length;h++)f.add(this.parseObject(g[h],b,c))}if("LOD"===a.type)for(a=a.levels,g=0;g<a.length;g++){h=a[g];var l=f.getObjectByProperty("uuid",h.object);void 0!==l&&f.addLevel(l,h.distance)}return f}});var Gk={UVMapping:300,CubeReflectionMapping:301,CubeRefractionMapping:302,EquirectangularReflectionMapping:303,EquirectangularRefractionMapping:304,
SphericalReflectionMapping:305,CubeUVReflectionMapping:306,CubeUVRefractionMapping:307},Ci={RepeatWrapping:1E3,ClampToEdgeWrapping:1001,MirroredRepeatWrapping:1002},Di={NearestFilter:1003,NearestMipmapNearestFilter:1004,NearestMipmapLinearFilter:1005,LinearFilter:1006,LinearMipmapNearestFilter:1007,LinearMipmapLinearFilter:1008};ug.prototype=Object.assign(Object.create(S.prototype),{constructor:ug,setOptions:function(a){this.options=a;return this},load:function(a,b,c,d){void 0===a&&(a="");void 0!==
this.path&&(a=this.path+a);a=this.manager.resolveURL(a);var e=this,f=uc.get(a);if(void 0!==f)return e.manager.itemStart(a),setTimeout(function(){b&&b(f);e.manager.itemEnd(a)},0),f;fetch(a).then(function(a){return a.blob()}).then(function(a){return void 0===e.options?createImageBitmap(a):createImageBitmap(a,e.options)}).then(function(c){uc.add(a,c);b&&b(c);e.manager.itemEnd(a)}).catch(function(b){d&&d(b);e.manager.itemError(a);e.manager.itemEnd(a)});e.manager.itemStart(a)}});Object.assign(vg.prototype,
{moveTo:function(a,b){this.currentPath=new Wa;this.subPaths.push(this.currentPath);this.currentPath.moveTo(a,b)},lineTo:function(a,b){this.currentPath.lineTo(a,b)},quadraticCurveTo:function(a,b,c,d){this.currentPath.quadraticCurveTo(a,b,c,d)},bezierCurveTo:function(a,b,c,d,e,f){this.currentPath.bezierCurveTo(a,b,c,d,e,f)},splineThru:function(a){this.currentPath.splineThru(a)},toShapes:function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new Jb;f.curves=e.curves;b.push(f)}return b}
function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],l=h.x-g.x,k=h.y-g.y;if(Math.abs(k)>Number.EPSILON){if(0>k&&(g=b[f],l=-l,h=b[e],k=-k),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=k*(a.x-g.x)-l*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||g.x<=a.x&&a.x<=h.x))return!0}return d}var e=pb.isClockWise,f=this.subPaths;if(0===f.length)return[];if(!0===b)return c(f);b=[];if(1===f.length){var g=f[0];var h=new Jb;h.curves=g.curves;
b.push(h);return b}var l=!e(f[0].getPoints());l=a?!l:l;h=[];var k=[],n=[],u=0;k[u]=void 0;n[u]=[];for(var t=0,r=f.length;t<r;t++){g=f[t];var p=g.getPoints();var v=e(p);(v=a?!v:v)?(!l&&k[u]&&u++,k[u]={s:new Jb,p:p},k[u].s.curves=g.curves,l&&u++,n[u]=[]):n[u].push({h:g,p:p[0]})}if(!k[0])return c(f);if(1<k.length){t=!1;a=[];e=0;for(f=k.length;e<f;e++)h[e]=[];e=0;for(f=k.length;e<f;e++)for(g=n[e],v=0;v<g.length;v++){l=g[v];u=!0;for(p=0;p<k.length;p++)d(l.p,k[p].p)&&(e!==p&&a.push({froms:e,tos:p,hole:v}),
u?(u=!1,h[p].push(l)):t=!0);u&&h[e].push(l)}0<a.length&&(t||(n=h))}t=0;for(e=k.length;t<e;t++)for(h=k[t].s,b.push(h),a=n[t],f=0,g=a.length;f<g;f++)h.holes.push(a[f].h);return b}});Object.assign(wg.prototype,{isFont:!0,generateShapes:function(a,b){void 0===b&&(b=100);var c=[],d=b;b=this.data;var e=Array.from?Array.from(a):String(a).split("");d/=b.resolution;var f=(b.boundingBox.yMax-b.boundingBox.yMin+b.underlineThickness)*d;a=[];for(var g=0,h=0,l=0;l<e.length;l++){var k=e[l];if("\n"===k)g=0,h-=f;
else{var n=k;k=d;var u=g,t=h,r=b,p=r.glyphs[n]||r.glyphs["?"];if(p){n=new vg;if(p.o){r=p._cachedOutline||(p._cachedOutline=p.o.split(" "));for(var v=0,x=r.length;v<x;)switch(r[v++]){case "m":var w=r[v++]*k+u;var y=r[v++]*k+t;n.moveTo(w,y);break;case "l":w=r[v++]*k+u;y=r[v++]*k+t;n.lineTo(w,y);break;case "q":var A=r[v++]*k+u;var B=r[v++]*k+t;var C=r[v++]*k+u;var D=r[v++]*k+t;n.quadraticCurveTo(C,D,A,B);break;case "b":A=r[v++]*k+u,B=r[v++]*k+t,C=r[v++]*k+u,D=r[v++]*k+t,w=r[v++]*k+u,y=r[v++]*k+t,n.bezierCurveTo(C,
D,w,y,A,B)}}k={offsetX:p.ha*k,path:n}}else console.error('THREE.Font: character "'+n+'" does not exists in font family '+r.familyName+"."),k=void 0;g+=k.offsetX;a.push(k.path)}}b=0;for(e=a.length;b<e;b++)Array.prototype.push.apply(c,a[b].toShapes());return c}});xg.prototype=Object.assign(Object.create(S.prototype),{constructor:xg,load:function(a,b,c,d){var e=this,f=new Na(this.manager);f.setPath(this.path);f.load(a,function(a){try{var c=JSON.parse(a)}catch(l){console.warn("THREE.FontLoader: typeface.js support is being deprecated. Use typeface.json instead."),
c=JSON.parse(a.substring(65,a.length-2))}a=e.parse(c);b&&b(a)},c,d)},parse:function(a){return new wg(a)}});var If,Cg={getContext:function(){void 0===If&&(If=new (window.AudioContext||window.webkitAudioContext));return If},setContext:function(a){If=a}};jf.prototype=Object.assign(Object.create(S.prototype),{constructor:jf,load:function(a,b,c,d){var e=new Na(this.manager);e.setResponseType("arraybuffer");e.setPath(this.path);e.load(a,function(a){a=a.slice(0);Cg.getContext().decodeAudioData(a,function(a){b(a)})},
c,d)}});Object.assign(kf.prototype,{isSphericalHarmonics3:!0,set:function(a){for(var b=0;9>b;b++)this.coefficients[b].copy(a[b]);return this},zero:function(){for(var a=0;9>a;a++)this.coefficients[a].set(0,0,0);return this},getAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.282095);b.addScale(e[1],.488603*d);b.addScale(e[2],.488603*a);b.addScale(e[3],.488603*c);b.addScale(e[4],1.092548*c*d);b.addScale(e[5],1.092548*d*a);b.addScale(e[6],.315392*(3*a*a-1));
b.addScale(e[7],1.092548*c*a);b.addScale(e[8],.546274*(c*c-d*d));return b},getIrradianceAt:function(a,b){var c=a.x,d=a.y;a=a.z;var e=this.coefficients;b.copy(e[0]).multiplyScalar(.886227);b.addScale(e[1],1.023328*d);b.addScale(e[2],1.023328*a);b.addScale(e[3],1.023328*c);b.addScale(e[4],.858086*c*d);b.addScale(e[5],.858086*d*a);b.addScale(e[6],.743125*a*a-.247708);b.addScale(e[7],.858086*c*a);b.addScale(e[8],.429043*(c*c-d*d));return b},add:function(a){for(var b=0;9>b;b++)this.coefficients[b].add(a.coefficients[b]);
return this},scale:function(a){for(var b=0;9>b;b++)this.coefficients[b].multiplyScalar(a);return this},lerp:function(a,b){for(var c=0;9>c;c++)this.coefficients[c].lerp(a.coefficients[c],b);return this},equals:function(a){for(var b=0;9>b;b++)if(!this.coefficients[b].equals(a.coefficients[b]))return!1;return!0},copy:function(a){return this.set(a.coefficients)},clone:function(){return(new this.constructor).copy(this)},fromArray:function(a,b){void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].fromArray(a,
b+3*d);return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);for(var c=this.coefficients,d=0;9>d;d++)c[d].toArray(a,b+3*d);return a}});Object.assign(kf,{getBasisAt:function(a,b){var c=a.x,d=a.y;a=a.z;b[0]=.282095;b[1]=.488603*d;b[2]=.488603*a;b[3]=.488603*c;b[4]=1.092548*c*d;b[5]=1.092548*d*a;b[6]=.315392*(3*a*a-1);b[7]=1.092548*c*a;b[8]=.546274*(c*c-d*d)}});Xa.prototype=Object.assign(Object.create(da.prototype),{constructor:Xa,isLightProbe:!0,copy:function(a){da.prototype.copy.call(this,
a);this.sh.copy(a.sh);this.intensity=a.intensity;return this},toJSON:function(a){return da.prototype.toJSON.call(this,a)}});yg.prototype=Object.assign(Object.create(Xa.prototype),{constructor:yg,isHemisphereLightProbe:!0,copy:function(a){Xa.prototype.copy.call(this,a);return this},toJSON:function(a){return Xa.prototype.toJSON.call(this,a)}});zg.prototype=Object.assign(Object.create(Xa.prototype),{constructor:zg,isAmbientLightProbe:!0,copy:function(a){Xa.prototype.copy.call(this,a);return this},toJSON:function(a){return Xa.prototype.toJSON.call(this,
a)}});var Ei=new U,Fi=new U;Object.assign(ai.prototype,{update:function(a){var b=this._cache;if(b.focus!==a.focus||b.fov!==a.fov||b.aspect!==a.aspect*this.aspect||b.near!==a.near||b.far!==a.far||b.zoom!==a.zoom||b.eyeSep!==this.eyeSep){b.focus=a.focus;b.fov=a.fov;b.aspect=a.aspect*this.aspect;b.near=a.near;b.far=a.far;b.zoom=a.zoom;b.eyeSep=this.eyeSep;var c=a.projectionMatrix.clone(),d=b.eyeSep/2,e=d*b.near/b.focus,f=b.near*Math.tan(L.DEG2RAD*b.fov*.5)/b.zoom;Fi.elements[12]=-d;Ei.elements[12]=d;
d=-f*b.aspect+e;var g=f*b.aspect+e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraL.projectionMatrix.copy(c);d=-f*b.aspect-e;g=f*b.aspect-e;c.elements[0]=2*b.near/(g-d);c.elements[8]=(g+d)/(g-d);this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(a.matrixWorld).multiply(Fi);this.cameraR.matrixWorld.copy(a.matrixWorld).multiply(Ei)}});Object.assign(Ag.prototype,{start:function(){this.oldTime=this.startTime=("undefined"===typeof performance?Date:performance).now();
this.elapsedTime=0;this.running=!0},stop:function(){this.getElapsedTime();this.autoStart=this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;if(this.autoStart&&!this.running)return this.start(),0;if(this.running){var b=("undefined"===typeof performance?Date:performance).now();a=(b-this.oldTime)/1E3;this.oldTime=b;this.elapsedTime+=a}return a}});var vc=new n,Gi=new ua,Hk=new n,wc=new n;Bg.prototype=Object.assign(Object.create(B.prototype),
{constructor:Bg,getInput:function(){return this.gain},removeFilter:function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null);return this},getFilter:function(){return this.filter},setFilter:function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);
this.filter.connect(this.context.destination);return this},getMasterVolume:function(){return this.gain.gain.value},setMasterVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this},updateMatrixWorld:function(a){B.prototype.updateMatrixWorld.call(this,a);a=this.context.listener;var b=this.up;this.timeDelta=this._clock.getDelta();this.matrixWorld.decompose(vc,Gi,Hk);wc.set(0,0,-1).applyQuaternion(Gi);if(a.positionX){var c=this.context.currentTime+this.timeDelta;
a.positionX.linearRampToValueAtTime(vc.x,c);a.positionY.linearRampToValueAtTime(vc.y,c);a.positionZ.linearRampToValueAtTime(vc.z,c);a.forwardX.linearRampToValueAtTime(wc.x,c);a.forwardY.linearRampToValueAtTime(wc.y,c);a.forwardZ.linearRampToValueAtTime(wc.z,c);a.upX.linearRampToValueAtTime(b.x,c);a.upY.linearRampToValueAtTime(b.y,c);a.upZ.linearRampToValueAtTime(b.z,c)}else a.setPosition(vc.x,vc.y,vc.z),a.setOrientation(wc.x,wc.y,wc.z,b.x,b.y,b.z)}});dd.prototype=Object.assign(Object.create(B.prototype),
{constructor:dd,getOutput:function(){return this.gain},setNodeSource:function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this},setMediaElementSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaNode";this.source=this.context.createMediaElementSource(a);this.connect();return this},setMediaStreamSource:function(a){this.hasPlaybackControl=!1;this.sourceType="mediaStreamNode";this.source=this.context.createMediaStreamSource(a);this.connect();
return this},setBuffer:function(a){this.buffer=a;this.sourceType="buffer";this.autoplay&&this.play();return this},play:function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.buffer;a.loop=this.loop;a.onended=this.onEnded.bind(this);this.startTime=this.context.currentTime;a.start(this.startTime,this.offset,
this.duration);this.isPlaying=!0;this.source=a;this.setDetune(this.detune);this.setPlaybackRate(this.playbackRate);return this.connect()}},pause:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return!0===this.isPlaying&&(this.source.stop(),this.source.onended=null,this.offset+=(this.context.currentTime-this.startTime)*this.playbackRate,this.isPlaying=!1),this},stop:function(){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");
else return this.source.stop(),this.source.onended=null,this.offset=0,this.isPlaying=!1,this},connect:function(){if(0<this.filters.length){this.source.connect(this.filters[0]);for(var a=1,b=this.filters.length;a<b;a++)this.filters[a-1].connect(this.filters[a]);this.filters[this.filters.length-1].connect(this.getOutput())}else this.source.connect(this.getOutput());return this},disconnect:function(){if(0<this.filters.length){this.source.disconnect(this.filters[0]);for(var a=1,b=this.filters.length;a<
b;a++)this.filters[a-1].disconnect(this.filters[a]);this.filters[this.filters.length-1].disconnect(this.getOutput())}else this.source.disconnect(this.getOutput());return this},getFilters:function(){return this.filters},setFilters:function(a){a||(a=[]);!0===this.isPlaying?(this.disconnect(),this.filters=a,this.connect()):this.filters=a;return this},setDetune:function(a){this.detune=a;if(void 0!==this.source.detune)return!0===this.isPlaying&&this.source.detune.setTargetAtTime(this.detune,this.context.currentTime,
.01),this},getDetune:function(){return this.detune},getFilter:function(){return this.getFilters()[0]},setFilter:function(a){return this.setFilters(a?[a]:[])},setPlaybackRate:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.playbackRate=a,!0===this.isPlaying&&this.source.playbackRate.setTargetAtTime(this.playbackRate,this.context.currentTime,.01),this},getPlaybackRate:function(){return this.playbackRate},onEnded:function(){this.isPlaying=
!1},getLoop:function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.loop},setLoop:function(a){if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else return this.loop=a,!0===this.isPlaying&&(this.source.loop=this.loop),this},getVolume:function(){return this.gain.gain.value},setVolume:function(a){this.gain.gain.setTargetAtTime(a,this.context.currentTime,.01);return this}});var xc=new n,Hi=
new ua,Ik=new n,yc=new n;Dg.prototype=Object.assign(Object.create(dd.prototype),{constructor:Dg,getOutput:function(){return this.panner},getRefDistance:function(){return this.panner.refDistance},setRefDistance:function(a){this.panner.refDistance=a;return this},getRolloffFactor:function(){return this.panner.rolloffFactor},setRolloffFactor:function(a){this.panner.rolloffFactor=a;return this},getDistanceModel:function(){return this.panner.distanceModel},setDistanceModel:function(a){this.panner.distanceModel=
a;return this},getMaxDistance:function(){return this.panner.maxDistance},setMaxDistance:function(a){this.panner.maxDistance=a;return this},setDirectionalCone:function(a,b,c){this.panner.coneInnerAngle=a;this.panner.coneOuterAngle=b;this.panner.coneOuterGain=c;return this},updateMatrixWorld:function(a){B.prototype.updateMatrixWorld.call(this,a);if(!0!==this.hasPlaybackControl||!1!==this.isPlaying)if(this.matrixWorld.decompose(xc,Hi,Ik),yc.set(0,0,1).applyQuaternion(Hi),a=this.panner,a.positionX){var b=
this.context.currentTime+this.listener.timeDelta;a.positionX.linearRampToValueAtTime(xc.x,b);a.positionY.linearRampToValueAtTime(xc.y,b);a.positionZ.linearRampToValueAtTime(xc.z,b);a.orientationX.linearRampToValueAtTime(yc.x,b);a.orientationY.linearRampToValueAtTime(yc.y,b);a.orientationZ.linearRampToValueAtTime(yc.z,b)}else a.setPosition(xc.x,xc.y,xc.z),a.setOrientation(yc.x,yc.y,yc.z)}});Object.assign(Eg.prototype,{getFrequencyData:function(){this.analyser.getByteFrequencyData(this.data);return this.data},
getAverageFrequency:function(){for(var a=0,b=this.getFrequencyData(),c=0;c<b.length;c++)a+=b[c];return a/b.length}});Object.assign(Fg.prototype,{accumulate:function(a,b){var c=this.buffer,d=this.valueSize;a=a*d+d;var e=this.cumulativeWeight;if(0===e){for(e=0;e!==d;++e)c[a+e]=c[e];e=b}else e+=b,this._mixBufferRegion(c,a,0,b/e,d);this.cumulativeWeight=e},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.binding;this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,
a,3*b,1-d,b);d=b;for(var f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d){ua.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=
b+g;a[h]=a[h]*f+a[c+g]*d}}});var Jk=/[\[\]\.:\/]/g,Kk="[^"+"\\[\\]\\.:\\/".replace("\\.","")+"]",Lk=/((?:WC+[\/:])*)/.source.replace("WC","[^\\[\\]\\.:\\/]"),Mk=/(WCOD+)?/.source.replace("WCOD",Kk),Nk=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Ok=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC","[^\\[\\]\\.:\\/]"),Pk=new RegExp("^"+Lk+Mk+Nk+Ok+"$"),Qk=["material","materials","bones"];Object.assign(bi.prototype,{getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];
void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].unbind()}});Object.assign(Aa,{Composite:bi,create:function(a,b,c){return a&&a.isAnimationObjectGroup?new Aa.Composite(a,b,c):new Aa(a,
b,c)},sanitizeNodeName:function(a){return a.replace(/\s/g,"_").replace(Jk,"")},parseTrackName:function(a){var b=Pk.exec(a);if(!b)throw Error("PropertyBinding: Cannot parse trackName: "+a);b={nodeName:b[2],objectName:b[3],objectIndex:b[4],propertyName:b[5],propertyIndex:b[6]};var c=b.nodeName&&b.nodeName.lastIndexOf(".");if(void 0!==c&&-1!==c){var d=b.nodeName.substring(c+1);-1!==Qk.indexOf(d)&&(b.nodeName=b.nodeName.substring(0,c),b.objectName=d)}if(null===b.propertyName||0===b.propertyName.length)throw Error("PropertyBinding: can not parse propertyName from trackName: "+
a);return b},findNode:function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=a.skeleton.getBoneByName(b);if(void 0!==c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var e=a[c];if(e.name===b||e.uuid===b||(e=d(e.children)))return e}return null};if(a=d(a.children))return a}return null}});Object.assign(Aa.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},BindingType:{Direct:0,EntireArray:1,ArrayElement:2,
HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)a[b++]=c[d]},function(a,b){a[b]=this.resolvedProperty[this.propertyIndex]},function(a,b){this.resolvedProperty.toArray(a,b)}],SetterByBindingTypeAndVersioning:[[function(a,b){this.targetObject[this.propertyName]=a[b]},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.needsUpdate=
!0},function(a,b){this.targetObject[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.needsUpdate=!0},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty[this.propertyIndex]=a[b]},function(a,
b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty.fromArray(a,b)},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.matrixWorldNeedsUpdate=!0}]],getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,
b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=Aa.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error("THREE.PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!a.material.materials){console.error("THREE.PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",
this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error("THREE.PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}a=a.skeleton.bones;for(c=0;c<a.length;c++)if(a[c].name===f){f=c;break}break;default:if(void 0===a[c]){console.error("THREE.PropertyBinding: Can not bind to objectName of node undefined.",this);return}a=a[c]}if(void 0!==f){if(void 0===a[f]){console.error("THREE.PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",
this,a);return}a=a[f]}}f=a[d];if(void 0===f)console.error("THREE.PropertyBinding: Trying to update property for track: "+b.nodeName+"."+d+" but it wasn't found.",a);else{b=this.Versioning.None;this.targetObject=a;void 0!==a.needsUpdate?b=this.Versioning.NeedsUpdate:void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate);c=this.BindingType.Direct;if(void 0!==e){if("morphTargetInfluences"===d){if(!a.geometry){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",
this);return}if(a.geometry.isBufferGeometry){if(!a.geometry.morphAttributes){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}for(c=0;c<this.node.geometry.morphAttributes.position.length;c++)if(a.geometry.morphAttributes.position[c].name===e){e=c;break}}else{if(!a.geometry.morphTargets){console.error("THREE.PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphTargets.",
this);return}for(c=0;c<this.node.geometry.morphTargets.length;c++)if(a.geometry.morphTargets[c].name===e){e=c;break}}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=e}else void 0!==f.fromArray&&void 0!==f.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=f):Array.isArray(f)?(c=this.BindingType.EntireArray,this.resolvedProperty=f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}}else console.error("THREE.PropertyBinding: Trying to update node for track: "+
this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}});Object.assign(Aa.prototype,{_getValue_unbound:Aa.prototype.getValue,_setValue_unbound:Aa.prototype.setValue});Object.assign(ci.prototype,{isAnimationObjectGroup:!0,add:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._paths,f=this._parsedPaths,g=this._bindings,h=g.length,l=void 0,k=0,n=arguments.length;k!==
n;++k){var u=arguments[k],t=u.uuid,r=d[t];if(void 0===r){r=b++;d[t]=r;a.push(u);t=0;for(var p=h;t!==p;++t)g[t].push(new Aa(u,e[t],f[t]))}else if(r<c){l=a[r];var v=--c;p=a[v];d[p.uuid]=r;a[r]=p;d[t]=v;a[v]=u;t=0;for(p=h;t!==p;++t){var w=g[t],z=w[r];w[r]=w[v];void 0===z&&(z=new Aa(u,e[t],f[t]));w[v]=z}}else a[r]!==l&&console.error("THREE.AnimationObjectGroup: Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes.")}this.nCachedObjects_=
c},remove:function(){for(var a=this._objects,b=this.nCachedObjects_,c=this._indicesByUUID,d=this._bindings,e=d.length,f=0,g=arguments.length;f!==g;++f){var h=arguments[f],l=h.uuid,k=c[l];if(void 0!==k&&k>=b){var n=b++,u=a[n];c[u.uuid]=k;a[k]=u;c[l]=n;a[n]=h;h=0;for(l=e;h!==l;++h){u=d[h];var t=u[k];u[k]=u[n];u[n]=t}}}this.nCachedObjects_=b},uncache:function(){for(var a=this._objects,b=a.length,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var l=
arguments[g].uuid,k=d[l];if(void 0!==k)if(delete d[l],k<c){l=--c;var n=a[l],u=--b,t=a[u];d[n.uuid]=k;a[k]=n;d[t.uuid]=l;a[l]=t;a.pop();n=0;for(t=f;n!==t;++n){var r=e[n],p=r[u];r[k]=r[l];r[l]=p;r.pop()}}else for(u=--b,t=a[u],d[t.uuid]=k,a[k]=t,a.pop(),n=0,t=f;n!==t;++n)r=e[n],r[k]=r[u],r.pop()}this.nCachedObjects_=c},subscribe_:function(a,b){var c=this._bindingsIndicesByPath,d=c[a],e=this._bindings;if(void 0!==d)return e[d];var f=this._paths,g=this._parsedPaths,h=this._objects,l=this.nCachedObjects_,
k=Array(h.length);d=e.length;c[a]=d;f.push(a);g.push(b);e.push(k);c=l;for(d=h.length;c!==d;++c)k[c]=new Aa(h[c],a,b);return k},unsubscribe_:function(a){var b=this._bindingsIndicesByPath,c=b[a];if(void 0!==c){var d=this._paths,e=this._parsedPaths,f=this._bindings,g=f.length-1,h=f[g];b[a[g]]=c;f[c]=h;f.pop();e[c]=e[g];e.pop();d[c]=d[g];d.pop()}}});Object.assign(di.prototype,{play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},
reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},startAt:function(a){this._startTime=a;return this},setLoop:function(a,b){this.loop=a;this.repetitions=b;return this},setEffectiveWeight:function(a){this.weight=a;
this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,0,1)},fadeOut:function(a){return this._scheduleFading(a,1,0)},crossFadeFrom:function(a,b,c){a.fadeOut(b);this.fadeIn(b);if(c){c=this._clip.duration;var d=a._clip.duration,e=c/d;a.warp(1,d/c,b);this.warp(e,1,b)}return this},crossFadeTo:function(a,b,c){return a.crossFadeFrom(this,b,c)},stopFading:function(){var a=this._weightInterpolant;
null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=this.paused?0:a;return this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(a){this.timeScale=this._clip.duration/a;return this.stopWarping()},syncWith:function(a){this.time=a.time;this.timeScale=a.timeScale;return this.stopWarping()},halt:function(a){return this.warp(this._effectiveTimeScale,
0,a)},warp:function(a,b,c){var d=this._mixer,e=d.time,f=this._timeScaleInterpolant,g=this.timeScale;null===f&&(this._timeScaleInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;d[1]=e+c;f[0]=a/g;f[1]=b/g;return this},stopWarping:function(){var a=this._timeScaleInterpolant;null!==a&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||
this._mixer._root},_update:function(a,b,c,d){if(this.enabled){var e=this._startTime;if(null!==e){b=(a-e)*c;if(0>b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a){b=this._interpolants;e=this._propertyBindings;for(var f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,a)}}else this._updateWeight(a)},_updateWeight:function(a){var b=0;if(this.enabled){b=this.weight;var c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0];
b*=d;a>c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){b=this.timeScale;var c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0];b*=d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.paused=!0:this.timeScale=b)}}return this._effectiveTimeScale=b},_updateTime:function(a){var b=this.time+a,c=this._clip.duration,d=this.loop,e=this._loopCount,f=2202===d;if(0===a)return-1===
e?b:f&&1===(e&1)?c-b:b;if(2200===d)a:{if(-1===e&&(this._loopCount=0,this._setEndings(!0,!0,!1)),b>=c)b=c;else if(0>b)b=0;else{this.time=b;break a}this.clampWhenFinished?this.paused=!0:this.enabled=!1;this.time=b;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1})}else{-1===e&&(0<=a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===this.repetitions,!0,f));if(b>=c||0>b){d=Math.floor(b/c);b-=c*d;e+=Math.abs(d);var g=this.repetitions-e;0>=g?(this.clampWhenFinished?
this.paused=!0:this.enabled=!1,this.time=b=0<a?c:0,this._mixer.dispatchEvent({type:"finished",action:this,direction:0<a?1:-1})):(1===g?(a=0>a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f),this._loopCount=e,this.time=b,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:d}))}else this.time=b;if(f&&1===(e&1))return c-b}return b},_setEndings:function(a,b,c){var d=this._interpolantSettings;c?(d.endingStart=2401,d.endingEnd=2401):(d.endingStart=a?this.zeroSlopeAtStart?2401:2400:2402,d.endingEnd=
b?this.zeroSlopeAtEnd?2401:2400:2402)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}});Gg.prototype=Object.assign(Object.create(Ba.prototype),{constructor:Gg,_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings;a=a._interpolants;var g=c.uuid,h=this._bindingsByRootAndName,
k=h[g];void 0===k&&(k={},h[g]=k);for(h=0;h!==e;++h){var m=d[h],n=m.name,u=k[n];if(void 0===u){u=f[h];if(void 0!==u){null===u._cacheIndex&&(++u.referenceCount,this._addInactiveBinding(u,g,n));continue}u=new Fg(Aa.create(c,n,b&&b._propertyBindings[h].binding.parsedPath),m.ValueTypeName,m.getValueSize());++u.referenceCount;this._addInactiveBinding(u,g,n)}f[h]=u;a[h].resultBuffer=u.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,
c=a._clip.uuid,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=
[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},
_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&a<this._nActiveActions},_addInactiveAction:function(a,b,c){var d=this._actions,e=this._actionsByClip,f=e[b];void 0===f?(f={knownActions:[a],actionByRoot:{}},a._byClipCacheIndex=0,e[b]=f):(b=f.knownActions,a._byClipCacheIndex=b.length,b.push(a));a._cacheIndex=d.length;d.push(a);f.actionByRoot[c]=a},_removeInactiveAction:function(a){var b=this._actions,c=b[b.length-1],d=a._cacheIndex;c._cacheIndex=d;b[d]=c;b.pop();a._cacheIndex=null;b=a._clip.uuid;
c=this._actionsByClip;d=c[b];var e=d.knownActions,f=e[e.length-1],g=a._byClipCacheIndex;f._byClipCacheIndex=g;e[g]=f;e.pop();a._byClipCacheIndex=null;delete d.actionByRoot[(a._localRoot||this._root).uuid];0===e.length&&delete c[b];this._removeInactiveBindingsForAction(a)},_removeInactiveBindingsForAction:function(a){a=a._propertyBindings;for(var b=0,c=a.length;b!==c;++b){var d=a[b];0===--d.referenceCount&&this._removeInactiveBinding(d)}},_lendAction:function(a){var b=this._actions,c=a._cacheIndex,
d=this._nActiveActions++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackAction:function(a){var b=this._actions,c=a._cacheIndex,d=--this._nActiveActions,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_addInactiveBinding:function(a,b,c){var d=this._bindingsByRootAndName,e=d[b],f=this._bindings;void 0===e&&(e={},d[b]=e);e[c]=a;a._cacheIndex=f.length;f.push(a)},_removeInactiveBinding:function(a){var b=this._bindings,c=a.binding,d=c.rootNode.uuid;c=c.path;var e=this._bindingsByRootAndName,
f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];0===Object.keys(f).length&&delete e[d]},_lendBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=this._nActiveBindings++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,
c=a[b];void 0===c&&(c=new ke(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,e=b[d];a.__cacheIndex=d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1),clipAction:function(a,b){var c=b||this._root,d=c.uuid;c="string"===typeof a?Ma.findByName(c,a):a;a=null!==c?c.uuid:a;var e=
this._actionsByClip[a],f=null;if(void 0!==e){f=e.actionByRoot[d];if(void 0!==f)return f;f=e.knownActions[0];null===c&&(c=f._clip)}if(null===c)return null;b=new di(this,c,b);this._bindAction(b,f);this._addInactiveAction(b,a,d);return b},existingAction:function(a,b){var c=b||this._root;b=c.uuid;c="string"===typeof a?Ma.findByName(c,a):a;a=this._actionsByClip[c?c.uuid:a];return void 0!==a?a.actionByRoot[b]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,
d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==c;++g)b[g]._update(d,a,e,f);a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},setTime:function(a){for(var b=this.time=0;b<this._actions.length;b++)this._actions[b].time=0;return this.update(a)},
getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.uuid;var c=this._actionsByClip,d=c[a];if(void 0!==d){d=d.knownActions;for(var e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip;for(d in b){var c=b[d].actionByRoot[a];void 0!==c&&
(this._deactivateAction(c),this._removeInactiveAction(c))}var d=this._bindingsByRootAndName[a];if(void 0!==d)for(var e in d)a=d[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){a=this.existingAction(a,b);null!==a&&(this._deactivateAction(a),this._removeInactiveAction(a))}});lf.prototype.clone=function(){return new lf(void 0===this.value.clone?this.value:this.value.clone())};Hg.prototype=Object.assign(Object.create(Gb.prototype),{constructor:Hg,isInstancedInterleavedBuffer:!0,
copy:function(a){Gb.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this}});Object.assign(ei.prototype,{linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(a,b){b&&b.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(b.matrixWorld),this.ray.direction.set(a.x,a.y,.5).unproject(b).sub(this.ray.origin).normalize(),this.camera=b):b&&b.isOrthographicCamera?(this.ray.origin.set(a.x,a.y,(b.near+b.far)/(b.near-b.far)).unproject(b),this.ray.direction.set(0,
0,-1).transformDirection(b.matrixWorld),this.camera=b):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(a,b,c){c=c||[];Ig(a,this,c,b);c.sort(fi);return c},intersectObjects:function(a,b,c){c=c||[];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),c;for(var d=0,e=a.length;d<e;d++)Ig(a[d],this,c,b);c.sort(fi);return c}});Object.assign(gi.prototype,{set:function(a,b,c){this.radius=a;this.phi=b;this.theta=c;return this},
clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.phi=a.phi;this.theta=a.theta;return this},makeSafe:function(){this.phi=Math.max(1E-6,Math.min(Math.PI-1E-6,this.phi));return this},setFromVector3:function(a){return this.setFromCartesianCoords(a.x,a.y,a.z)},setFromCartesianCoords:function(a,b,c){this.radius=Math.sqrt(a*a+b*b+c*c);0===this.radius?this.phi=this.theta=0:(this.theta=Math.atan2(a,c),this.phi=Math.acos(L.clamp(b/this.radius,-1,1)));return this}});
Object.assign(hi.prototype,{set:function(a,b,c){this.radius=a;this.theta=b;this.y=c;return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.radius=a.radius;this.theta=a.theta;this.y=a.y;return this},setFromVector3:function(a){return this.setFromCartesianCoords(a.x,a.y,a.z)},setFromCartesianCoords:function(a,b,c){this.radius=Math.sqrt(a*a+c*c);this.theta=Math.atan2(a,c);this.y=b;return this}});var Ii=new w;Object.assign(Jg.prototype,{set:function(a,b){this.min.copy(a);
this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(a,b){b=Ii.copy(b).multiplyScalar(.5);this.min.copy(a).sub(b);this.max.copy(a).add(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<
this.min.x||this.max.y<this.min.y},getCenter:function(a){void 0===a&&(console.warn("THREE.Box2: .getCenter() target is now required"),a=new w);return this.isEmpty()?a.set(0,0):a.addVectors(this.min,this.max).multiplyScalar(.5)},getSize:function(a){void 0===a&&(console.warn("THREE.Box2: .getSize() target is now required"),a=new w);return this.isEmpty()?a.set(0,0):a.subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);
this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y},getParameter:function(a,b){void 0===b&&(console.warn("THREE.Box2: .getParameter() target is now required"),b=new w);return b.set((a.x-this.min.x)/(this.max.x-this.min.x),
(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y?!1:!0},clampPoint:function(a,b){void 0===b&&(console.warn("THREE.Box2: .clampPoint() target is now required"),b=new w);return b.copy(a).clamp(this.min,this.max)},distanceToPoint:function(a){return Ii.copy(a).clamp(this.min,this.max).sub(a).length()},intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);
this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}});var Ji=new n,Jf=new n;Object.assign(Kg.prototype,{set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},getCenter:function(a){void 0===a&&(console.warn("THREE.Line3: .getCenter() target is now required"),
a=new n);return a.addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){void 0===a&&(console.warn("THREE.Line3: .delta() target is now required"),a=new n);return a.subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},at:function(a,b){void 0===b&&(console.warn("THREE.Line3: .at() target is now required"),b=new n);return this.delta(b).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(a,
b){Ji.subVectors(a,this.start);Jf.subVectors(this.end,this.start);a=Jf.dot(Jf);a=Jf.dot(Ji)/a;b&&(a=L.clamp(a,0,1));return a},closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);void 0===c&&(console.warn("THREE.Line3: .closestPointToPoint() target is now required"),c=new n);return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}});
pe.prototype=Object.create(B.prototype);pe.prototype.constructor=pe;pe.prototype.isImmediateRenderObject=!0;var mb=new n,zb=new n,hh=new Y,Rk=["a","b","c"];qe.prototype=Object.create(ca.prototype);qe.prototype.constructor=qe;qe.prototype.update=function(){this.object.updateMatrixWorld(!0);hh.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,b=this.geometry.attributes.position,c=this.object.geometry;if(c&&c.isGeometry)for(var d=c.vertices,e=c.faces,f=c=0,g=e.length;f<g;f++)for(var h=
e[f],k=0,m=h.vertexNormals.length;k<m;k++){var n=h.vertexNormals[k];mb.copy(d[h[Rk[k]]]).applyMatrix4(a);zb.copy(n).applyMatrix3(hh).normalize().multiplyScalar(this.size).add(mb);b.setXYZ(c,mb.x,mb.y,mb.z);c+=1;b.setXYZ(c,zb.x,zb.y,zb.z);c+=1}else if(c&&c.isBufferGeometry)for(d=c.attributes.position,e=c.attributes.normal,k=c=0,m=d.count;k<m;k++)mb.set(d.getX(k),d.getY(k),d.getZ(k)).applyMatrix4(a),zb.set(e.getX(k),e.getY(k),e.getZ(k)),zb.applyMatrix3(hh).normalize().multiplyScalar(this.size).add(mb),
b.setXYZ(c,mb.x,mb.y,mb.z),c+=1,b.setXYZ(c,zb.x,zb.y,zb.z),c+=1;b.needsUpdate=!0};var Ki=new n;ed.prototype=Object.create(B.prototype);ed.prototype.constructor=ed;ed.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};ed.prototype.update=function(){this.light.updateMatrixWorld();var a=this.light.distance?this.light.distance:1E3,b=a*Math.tan(this.light.angle);this.cone.scale.set(b,b,a);Ki.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(Ki);
void 0!==this.color?this.cone.material.color.set(this.color):this.cone.material.color.copy(this.light.color)};var Pb=new n,Kf=new U,ih=new U;fd.prototype=Object.create(ca.prototype);fd.prototype.constructor=fd;fd.prototype.updateMatrixWorld=function(a){var b=this.bones,c=this.geometry,d=c.getAttribute("position");ih.getInverse(this.root.matrixWorld);for(var e=0,f=0;e<b.length;e++){var g=b[e];g.parent&&g.parent.isBone&&(Kf.multiplyMatrices(ih,g.matrixWorld),Pb.setFromMatrixPosition(Kf),d.setXYZ(f,
Pb.x,Pb.y,Pb.z),Kf.multiplyMatrices(ih,g.parent.matrixWorld),Pb.setFromMatrixPosition(Kf),d.setXYZ(f+1,Pb.x,Pb.y,Pb.z),f+=2)}c.getAttribute("position").needsUpdate=!0;B.prototype.updateMatrixWorld.call(this,a)};gd.prototype=Object.create(ja.prototype);gd.prototype.constructor=gd;gd.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};gd.prototype.update=function(){void 0!==this.color?this.material.color.set(this.color):this.material.color.copy(this.light.color)};hd.prototype=
Object.create(xa.prototype);hd.prototype.constructor=hd;hd.prototype.update=function(){this.scale.set(.5*this.light.width,.5*this.light.height,1);if(void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);var a=this.material.color,b=Math.max(a.r,a.g,a.b);1<b&&a.multiplyScalar(1/b);this.children[0].material.color.copy(this.material.color)}};hd.prototype.dispose=function(){this.geometry.dispose();
this.material.dispose();this.children[0].geometry.dispose();this.children[0].material.dispose()};var Sk=new n,Li=new H,Mi=new H;id.prototype=Object.create(B.prototype);id.prototype.constructor=id;id.prototype.dispose=function(){this.children[0].geometry.dispose();this.children[0].material.dispose()};id.prototype.update=function(){var a=this.children[0];if(void 0!==this.color)this.material.color.set(this.color);else{var b=a.geometry.getAttribute("color");Li.copy(this.light.color);Mi.copy(this.light.groundColor);
for(var c=0,d=b.count;c<d;c++){var e=c<d/2?Li:Mi;b.setXYZ(c,e.r,e.g,e.b)}b.needsUpdate=!0}a.lookAt(Sk.setFromMatrixPosition(this.light.matrixWorld).negate())};jd.prototype=Object.create(ja.prototype);jd.prototype.constructor=jd;jd.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};jd.prototype.onBeforeRender=function(){this.position.copy(this.lightProbe.position);this.scale.set(1,1,1).multiplyScalar(this.size);this.material.uniforms.intensity.value=this.lightProbe.intensity};
mf.prototype=Object.assign(Object.create(ca.prototype),{constructor:mf,copy:function(a){ca.prototype.copy.call(this,a);this.geometry.copy(a.geometry);this.material.copy(a.material);return this},clone:function(){return(new this.constructor).copy(this)}});nf.prototype=Object.create(ca.prototype);nf.prototype.constructor=nf;kd.prototype=Object.create(xa.prototype);kd.prototype.constructor=kd;kd.prototype.update=function(){function a(a,b,d,e){d=(b-a)/d;r.setXYZ(k,0,0,0);m++;for(n=a;n<b;n+=d)u=k+m,r.setXYZ(u,
Math.sin(n)*c,0,Math.cos(n)*c),r.setXYZ(u+1,Math.sin(Math.min(n+d,b))*c,0,Math.cos(Math.min(n+d,b))*c),r.setXYZ(u+2,0,0,0),m+=3;t.addGroup(k,m,e);k+=m;m=0}var b=this.audio,c=this.range,d=this.divisionsInnerAngle,e=this.divisionsOuterAngle,f=L.degToRad(b.panner.coneInnerAngle);b=L.degToRad(b.panner.coneOuterAngle);var g=f/2,h=b/2,k=0,m=0,n,u,t=this.geometry,r=t.attributes.position;t.clearGroups();a(-h,-g,e,0);a(-g,g,d,1);a(g,h,e,0);r.needsUpdate=!0;f===b&&(this.material[0].visible=!1)};kd.prototype.dispose=
function(){this.geometry.dispose();this.material[0].dispose();this.material[1].dispose()};var De=new n,Lf=new n,Ni=new Y;re.prototype=Object.create(ca.prototype);re.prototype.constructor=re;re.prototype.update=function(){this.object.updateMatrixWorld(!0);Ni.getNormalMatrix(this.object.matrixWorld);var a=this.object.matrixWorld,b=this.geometry.attributes.position,c=this.object.geometry,d=c.vertices;c=c.faces;for(var e=0,f=0,g=c.length;f<g;f++){var h=c[f],k=h.normal;De.copy(d[h.a]).add(d[h.b]).add(d[h.c]).divideScalar(3).applyMatrix4(a);
Lf.copy(k).applyMatrix3(Ni).normalize().multiplyScalar(this.size).add(De);b.setXYZ(e,De.x,De.y,De.z);e+=1;b.setXYZ(e,Lf.x,Lf.y,Lf.z);e+=1}b.needsUpdate=!0};var Oi=new n,Mf=new n,Pi=new n;ld.prototype=Object.create(B.prototype);ld.prototype.constructor=ld;ld.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};ld.prototype.update=function(){Oi.setFromMatrixPosition(this.light.matrixWorld);
Mf.setFromMatrixPosition(this.light.target.matrixWorld);Pi.subVectors(Mf,Oi);this.lightPlane.lookAt(Mf);void 0!==this.color?(this.lightPlane.material.color.set(this.color),this.targetLine.material.color.set(this.color)):(this.lightPlane.material.color.copy(this.light.color),this.targetLine.material.color.copy(this.light.color));this.targetLine.lookAt(Mf);this.targetLine.scale.z=Pi.length()};var of=new n,ia=new bb;se.prototype=Object.create(ca.prototype);se.prototype.constructor=se;se.prototype.update=
function(){var a=this.geometry,b=this.pointMap;ia.projectionMatrixInverse.copy(this.camera.projectionMatrixInverse);qa("c",b,a,ia,0,0,-1);qa("t",b,a,ia,0,0,1);qa("n1",b,a,ia,-1,-1,-1);qa("n2",b,a,ia,1,-1,-1);qa("n3",b,a,ia,-1,1,-1);qa("n4",b,a,ia,1,1,-1);qa("f1",b,a,ia,-1,-1,1);qa("f2",b,a,ia,1,-1,1);qa("f3",b,a,ia,-1,1,1);qa("f4",b,a,ia,1,1,1);qa("u1",b,a,ia,.7,1.1,-1);qa("u2",b,a,ia,-.7,1.1,-1);qa("u3",b,a,ia,0,2,-1);qa("cf1",b,a,ia,-1,0,1);qa("cf2",b,a,ia,1,0,1);qa("cf3",b,a,ia,0,-1,1);qa("cf4",
b,a,ia,0,1,1);qa("cn1",b,a,ia,-1,0,-1);qa("cn2",b,a,ia,1,0,-1);qa("cn3",b,a,ia,0,-1,-1);qa("cn4",b,a,ia,0,1,-1);a.getAttribute("position").needsUpdate=!0};var Nf=new ab;sb.prototype=Object.create(ca.prototype);sb.prototype.constructor=sb;sb.prototype.update=function(a){void 0!==a&&console.warn("THREE.BoxHelper: .update() has no longer arguments.");void 0!==this.object&&Nf.setFromObject(this.object);if(!Nf.isEmpty()){a=Nf.min;var b=Nf.max,c=this.geometry.attributes.position,d=c.array;d[0]=b.x;d[1]=
b.y;d[2]=b.z;d[3]=a.x;d[4]=b.y;d[5]=b.z;d[6]=a.x;d[7]=a.y;d[8]=b.z;d[9]=b.x;d[10]=a.y;d[11]=b.z;d[12]=b.x;d[13]=b.y;d[14]=a.z;d[15]=a.x;d[16]=b.y;d[17]=a.z;d[18]=a.x;d[19]=a.y;d[20]=a.z;d[21]=b.x;d[22]=a.y;d[23]=a.z;c.needsUpdate=!0;this.geometry.computeBoundingSphere()}};sb.prototype.setFromObject=function(a){this.object=a;this.update();return this};sb.prototype.copy=function(a){ca.prototype.copy.call(this,a);this.object=a.object;return this};sb.prototype.clone=function(){return(new this.constructor).copy(this)};
te.prototype=Object.create(ca.prototype);te.prototype.constructor=te;te.prototype.updateMatrixWorld=function(a){var b=this.box;b.isEmpty()||(b.getCenter(this.position),b.getSize(this.scale),this.scale.multiplyScalar(.5),B.prototype.updateMatrixWorld.call(this,a))};ue.prototype=Object.create(xa.prototype);ue.prototype.constructor=ue;ue.prototype.updateMatrixWorld=function(a){var b=-this.plane.constant;1E-8>Math.abs(b)&&(b=1E-8);this.scale.set(.5*this.size,.5*this.size,b);this.children[0].material.side=
0>b?1:0;this.lookAt(this.plane.normal);B.prototype.updateMatrixWorld.call(this,a)};var Qi=new n,pf,Lg;tb.prototype=Object.create(B.prototype);tb.prototype.constructor=tb;tb.prototype.setDirection=function(a){.99999<a.y?this.quaternion.set(0,0,0,1):-.99999>a.y?this.quaternion.set(1,0,0,0):(Qi.set(a.z,0,-a.x).normalize(),this.quaternion.setFromAxisAngle(Qi,Math.acos(a.y)))};tb.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(1E-4,a-b),1);this.line.updateMatrix();
this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};tb.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};tb.prototype.copy=function(a){B.prototype.copy.call(this,a,!1);this.line.copy(a.line);this.cone.copy(a.cone);return this};tb.prototype.clone=function(){return(new this.constructor).copy(this)};ve.prototype=Object.create(ca.prototype);ve.prototype.constructor=ve;D.create=function(a,b){console.log("THREE.Curve.create() has been deprecated");
a.prototype=Object.create(D.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};Object.assign(rb.prototype,{createPointsGeometry:function(a){console.warn("THREE.CurvePath: .createPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");a=this.getPoints(a);return this.createGeometry(a)},createSpacedPointsGeometry:function(a){console.warn("THREE.CurvePath: .createSpacedPointsGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");
a=this.getSpacedPoints(a);return this.createGeometry(a)},createGeometry:function(a){console.warn("THREE.CurvePath: .createGeometry() has been removed. Use new THREE.Geometry().setFromPoints( points ) instead.");for(var b=new F,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new n(e.x,e.y,e.z||0))}return b}});Object.assign(Wa.prototype,{fromPoints:function(a){console.warn("THREE.Path: .fromPoints() has been renamed to .setFromPoints().");this.setFromPoints(a)}});ji.prototype=Object.create(ya.prototype);
ki.prototype=Object.create(ya.prototype);Mg.prototype=Object.create(ya.prototype);Object.assign(Mg.prototype,{initFromArray:function(){console.error("THREE.Spline: .initFromArray() has been removed.")},getControlPointsArray:function(){console.error("THREE.Spline: .getControlPointsArray() has been removed.")},reparametrizeByArcLength:function(){console.error("THREE.Spline: .reparametrizeByArcLength() has been removed.")}});mf.prototype.setColors=function(){console.error("THREE.GridHelper: setColors() has been deprecated, pass them in the constructor instead.")};
fd.prototype.update=function(){console.error("THREE.SkeletonHelper: update() no longer needs to be called.")};Object.assign(S.prototype,{extractUrlBase:function(a){console.warn("THREE.Loader: .extractUrlBase() has been deprecated. Use THREE.LoaderUtils.extractUrlBase() instead.");return fh.extractUrlBase(a)}});S.Handlers={add:function(){console.error("THREE.Loader: Handlers.add() has been removed. Use LoadingManager.addHandler() instead.")},get:function(){console.error("THREE.Loader: Handlers.get() has been removed. Use LoadingManager.getHandler() instead.")}};
Object.assign(hf.prototype,{setTexturePath:function(a){console.warn("THREE.ObjectLoader: .setTexturePath() has been renamed to .setResourcePath().");return this.setResourcePath(a)}});Object.assign(Jg.prototype,{center:function(a){console.warn("THREE.Box2: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");
return this.intersectsBox(a)},size:function(a){console.warn("THREE.Box2: .size() has been renamed to .getSize().");return this.getSize(a)}});Object.assign(ab.prototype,{center:function(a){console.warn("THREE.Box3: .center() has been renamed to .getCenter().");return this.getCenter(a)},empty:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()},isIntersectionBox:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");
return this.intersectsBox(a)},isIntersectionSphere:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)},size:function(a){console.warn("THREE.Box3: .size() has been renamed to .getSize().");return this.getSize(a)}});Kg.prototype.center=function(a){console.warn("THREE.Line3: .center() has been renamed to .getCenter().");return this.getCenter(a)};Object.assign(L,{random16:function(){console.warn("THREE.Math: .random16() has been deprecated. Use Math.random() instead.");
return Math.random()},nearestPowerOfTwo:function(a){console.warn("THREE.Math: .nearestPowerOfTwo() has been renamed to .floorPowerOfTwo().");return L.floorPowerOfTwo(a)},nextPowerOfTwo:function(a){console.warn("THREE.Math: .nextPowerOfTwo() has been renamed to .ceilPowerOfTwo().");return L.ceilPowerOfTwo(a)}});Object.assign(Y.prototype,{flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix3: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},multiplyVector3:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");
return a.applyMatrix3(this)},multiplyVector3Array:function(){console.error("THREE.Matrix3: .multiplyVector3Array() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix3: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix3: .applyToVector3Array() has been removed.")}});Object.assign(U.prototype,{extractPosition:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");
return this.copyPosition(a)},flattenToArrayOffset:function(a,b){console.warn("THREE.Matrix4: .flattenToArrayOffset() has been deprecated. Use .toArray() instead.");return this.toArray(a,b)},getPosition:function(){console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return(new n).setFromMatrixColumn(this,3)},setRotationFromQuaternion:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");
return this.makeRotationFromQuaternion(a)},multiplyToArray:function(){console.warn("THREE.Matrix4: .multiplyToArray() has been removed.")},multiplyVector3:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector4:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},multiplyVector3Array:function(){console.error("THREE.Matrix4: .multiplyVector3Array() has been removed.")},
rotateAxis:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");a.transformDirection(this)},crossVector:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)},translate:function(){console.error("THREE.Matrix4: .translate() has been removed.")},rotateX:function(){console.error("THREE.Matrix4: .rotateX() has been removed.")},rotateY:function(){console.error("THREE.Matrix4: .rotateY() has been removed.")},
rotateZ:function(){console.error("THREE.Matrix4: .rotateZ() has been removed.")},rotateByAxis:function(){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")},applyToBuffer:function(a){console.warn("THREE.Matrix4: .applyToBuffer() has been removed. Use matrix.applyToBufferAttribute( attribute ) instead.");return this.applyToBufferAttribute(a)},applyToVector3Array:function(){console.error("THREE.Matrix4: .applyToVector3Array() has been removed.")},makeFrustum:function(a,b,c,d,e,f){console.warn("THREE.Matrix4: .makeFrustum() has been removed. Use .makePerspective( left, right, top, bottom, near, far ) instead.");
return this.makePerspective(a,b,d,c,e,f)}});cb.prototype.isIntersectionLine=function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)};ua.prototype.multiplyVector3=function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)};Object.assign(Sb.prototype,{isIntersectionBox:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");
return this.intersectsBox(a)},isIntersectionPlane:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)},isIntersectionSphere:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}});Object.assign(R.prototype,{area:function(){console.warn("THREE.Triangle: .area() has been renamed to .getArea().");return this.getArea()},barycoordFromPoint:function(a,
b){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return this.getBarycoord(a,b)},midpoint:function(a){console.warn("THREE.Triangle: .midpoint() has been renamed to .getMidpoint().");return this.getMidpoint(a)},normal:function(a){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");return this.getNormal(a)},plane:function(a){console.warn("THREE.Triangle: .plane() has been renamed to .getPlane().");return this.getPlane(a)}});Object.assign(R,
{barycoordFromPoint:function(a,b,c,d,e){console.warn("THREE.Triangle: .barycoordFromPoint() has been renamed to .getBarycoord().");return R.getBarycoord(a,b,c,d,e)},normal:function(a,b,c,d){console.warn("THREE.Triangle: .normal() has been renamed to .getNormal().");return R.getNormal(a,b,c,d)}});Object.assign(Jb.prototype,{extractAllPoints:function(a){console.warn("THREE.Shape: .extractAllPoints() has been removed. Use .extractPoints() instead.");return this.extractPoints(a)},extrude:function(a){console.warn("THREE.Shape: .extrude() has been removed. Use ExtrudeGeometry() instead.");
return new fc(this,a)},makeGeometry:function(a){console.warn("THREE.Shape: .makeGeometry() has been removed. Use ShapeGeometry() instead.");return new gc(this,a)}});Object.assign(w.prototype,{fromAttribute:function(a,b,c){console.warn("THREE.Vector2: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector2: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},
lengthManhattan:function(){console.warn("THREE.Vector2: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(n.prototype,{setEulerFromRotationMatrix:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")},setEulerFromQuaternion:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")},getPositionFromMatrix:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");
return this.setFromMatrixPosition(a)},getScaleFromMatrix:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");return this.setFromMatrixScale(a)},getColumnFromMatrix:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(b,a)},applyProjection:function(a){console.warn("THREE.Vector3: .applyProjection() has been removed. Use .applyMatrix4( m ) instead.");return this.applyMatrix4(a)},
fromAttribute:function(a,b,c){console.warn("THREE.Vector3: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},distanceToManhattan:function(a){console.warn("THREE.Vector3: .distanceToManhattan() has been renamed to .manhattanDistanceTo().");return this.manhattanDistanceTo(a)},lengthManhattan:function(){console.warn("THREE.Vector3: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(aa.prototype,
{fromAttribute:function(a,b,c){console.warn("THREE.Vector4: .fromAttribute() has been renamed to .fromBufferAttribute().");return this.fromBufferAttribute(a,b,c)},lengthManhattan:function(){console.warn("THREE.Vector4: .lengthManhattan() has been renamed to .manhattanLength().");return this.manhattanLength()}});Object.assign(F.prototype,{computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}});
Object.assign(B.prototype,{getChildByName:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)},renderDepth:function(){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")},translate:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)},getWorldRotation:function(){console.error("THREE.Object3D: .getWorldRotation() has been removed. Use THREE.Object3D.getWorldQuaternion( target ) instead.")}});
Object.defineProperties(B.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
Object.defineProperties(Nd.prototype,{objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}});Object.defineProperty(Le.prototype,"useVertexTexture",{get:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")},set:function(){console.warn("THREE.Skeleton: useVertexTexture has been removed.")}});Od.prototype.initBones=function(){console.error("THREE.SkinnedMesh: initBones() has been removed.")};Object.defineProperty(D.prototype,
"__arcLengthDivisions",{get:function(){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");return this.arcLengthDivisions},set:function(a){console.warn("THREE.Curve: .__arcLengthDivisions is now .arcLengthDivisions.");this.arcLengthDivisions=a}});na.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==b&&(this.filmGauge=b);this.setFocalLength(a)};Object.defineProperties(da.prototype,
{onlyShadow:{set:function(){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");
this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");this.shadow.camera.far=a}},shadowCameraVisible:{set:function(){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},
shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(O.prototype,
{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Use .count instead.");return this.array.length}}});Object.assign(O.prototype,{copyIndicesArray:function(){console.error("THREE.BufferAttribute: .copyIndicesArray() has been removed.")},setArray:function(a){console.warn("THREE.BufferAttribute: .setArray has been deprecated. Use BufferGeometry .setAttribute to replace/resize attribute buffers");this.count=void 0!==a?a.length/this.itemSize:0;this.array=a;return this}});
Object.assign(E.prototype,{addIndex:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)},addDrawCall:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)},clearDrawCalls:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()},computeTangents:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")},
computeOffsets:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}});Object.defineProperties(E.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}}});Object.assign(Gb.prototype,{setArray:function(a){console.warn("THREE.InterleavedBuffer: .setArray has been deprecated. Use BufferGeometry .setAttribute to replace/resize attribute buffers");
this.count=void 0!==a?a.length/this.stride:0;this.array=a;return this}});Object.assign(eb.prototype,{getArrays:function(){console.error("THREE.ExtrudeBufferGeometry: .getArrays() has been removed.")},addShapeList:function(){console.error("THREE.ExtrudeBufferGeometry: .addShapeList() has been removed.")},addShape:function(){console.error("THREE.ExtrudeBufferGeometry: .addShape() has been removed.")}});Object.defineProperties(lf.prototype,{dynamic:{set:function(){console.warn("THREE.Uniform: .dynamic has been removed. Use object.onBeforeRender() instead.")}},
onUpdate:{value:function(){console.warn("THREE.Uniform: .onUpdate() has been removed. Use object.onBeforeRender() instead.");return this}}});Object.defineProperties(M.prototype,{wrapAround:{get:function(){console.warn("THREE.Material: .wrapAround has been removed.")},set:function(){console.warn("THREE.Material: .wrapAround has been removed.")}},overdraw:{get:function(){console.warn("THREE.Material: .overdraw has been removed.")},set:function(){console.warn("THREE.Material: .overdraw has been removed.")}},
wrapRGB:{get:function(){console.warn("THREE.Material: .wrapRGB has been removed.");return new H}},shading:{get:function(){console.error("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.")},set:function(a){console.warn("THREE."+this.type+": .shading has been removed. Use the boolean .flatShading instead.");this.flatShading=1===a}},stencilMask:{get:function(){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead.");return this.stencilFuncMask},
set:function(a){console.warn("THREE."+this.type+": .stencilMask has been removed. Use .stencilFuncMask instead.");this.stencilFuncMask=a}}});Object.defineProperties(Ra.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});Object.defineProperties(ma.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");
return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});Object.assign(hg.prototype,{clearTarget:function(a,b,c,d){console.warn("THREE.WebGLRenderer: .clearTarget() has been deprecated. Use .setRenderTarget() and .clear() instead.");this.setRenderTarget(a);this.clear(b,c,d)},animate:function(a){console.warn("THREE.WebGLRenderer: .animate() is now .setAnimationLoop().");this.setAnimationLoop(a)},
getCurrentRenderTarget:function(){console.warn("THREE.WebGLRenderer: .getCurrentRenderTarget() is now .getRenderTarget().");return this.getRenderTarget()},getMaxAnisotropy:function(){console.warn("THREE.WebGLRenderer: .getMaxAnisotropy() is now .capabilities.getMaxAnisotropy().");return this.capabilities.getMaxAnisotropy()},getPrecision:function(){console.warn("THREE.WebGLRenderer: .getPrecision() is now .capabilities.precision.");return this.capabilities.precision},resetGLState:function(){console.warn("THREE.WebGLRenderer: .resetGLState() is now .state.reset().");
return this.state.reset()},supportsFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")},supportsHalfFloatTextures:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")},supportsStandardDerivatives:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");
return this.extensions.get("OES_standard_derivatives")},supportsCompressedTextureS3TC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");return this.extensions.get("WEBGL_compressed_texture_s3tc")},supportsCompressedTexturePVRTC:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")},
supportsBlendMinMax:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")},supportsVertexTextures:function(){console.warn("THREE.WebGLRenderer: .supportsVertexTextures() is now .capabilities.vertexTextures.");return this.capabilities.vertexTextures},supportsInstancedArrays:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");
return this.extensions.get("ANGLE_instanced_arrays")},enableScissorTest:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");this.setScissorTest(a)},initMaterial:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")},addPrePlugin:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")},addPostPlugin:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")},updateShadowMap:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")},
setFaceCulling:function(){console.warn("THREE.WebGLRenderer: .setFaceCulling() has been removed.")},allocTextureUnit:function(){console.warn("THREE.WebGLRenderer: .allocTextureUnit() has been removed.")},setTexture:function(){console.warn("THREE.WebGLRenderer: .setTexture() has been removed.")},setTexture2D:function(){console.warn("THREE.WebGLRenderer: .setTexture2D() has been removed.")},setTextureCube:function(){console.warn("THREE.WebGLRenderer: .setTextureCube() has been removed.")},getActiveMipMapLevel:function(){console.warn("THREE.WebGLRenderer: .getActiveMipMapLevel() is now .getActiveMipmapLevel().");
return this.getActiveMipmapLevel()}});Object.defineProperties(hg.prototype,{shadowMapEnabled:{get:function(){return this.shadowMap.enabled},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");this.shadowMap.type=a}},shadowMapCullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")},
set:function(){console.warn("THREE.WebGLRenderer: .shadowMapCullFace has been removed. Set Material.shadowSide instead.")}},context:{get:function(){console.warn("THREE.WebGLRenderer: .context has been removed. Use .getContext() instead.");return this.getContext()}}});Object.defineProperties(Jh.prototype,{cullFace:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.cullFace has been removed. Set Material.shadowSide instead.")}},
renderReverseSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderReverseSided has been removed. Set Material.shadowSide instead.")}},renderSingleSided:{get:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")},set:function(){console.warn("THREE.WebGLRenderer: .shadowMap.renderSingleSided has been removed. Set Material.shadowSide instead.")}}});
Object.defineProperties(Ab.prototype,{activeCubeFace:{set:function(){console.warn("THREE.WebGLRenderTargetCube: .activeCubeFace has been removed. It is now the second parameter of WebGLRenderer.setRenderTarget().")}},activeMipMapLevel:{set:function(){console.warn("THREE.WebGLRenderTargetCube: .activeMipMapLevel has been removed. It is now the third parameter of WebGLRenderer.setRenderTarget().")}}});Object.defineProperties(la.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");
return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");return this.texture.magFilter},
set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");return this.texture.anisotropy},
set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat},set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");
this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");
return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});Object.defineProperties(gg.prototype,{standing:{set:function(){console.warn("THREE.WebVRManager: .standing has been removed.")}},userHeight:{set:function(){console.warn("THREE.WebVRManager: .userHeight has been removed.")}}});dd.prototype.load=function(a){console.warn("THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.");
var b=this;(new jf).load(a,function(a){b.setBuffer(a)});return this};Eg.prototype.getData=function(){console.warn("THREE.AudioAnalyser: .getData() is now .getFrequencyData().");return this.getFrequencyData()};Dc.prototype.updateCubeMap=function(a,b){console.warn("THREE.CubeCamera: .updateCubeMap() is now .update().");return this.update(a,b)};Kb.crossOrigin=void 0;Kb.loadTexture=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=
new Ve;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};Kb.loadTextureCube=function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var e=new Ue;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a};Kb.loadCompressedTexture=function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")};Kb.loadCompressedTextureCube=
function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")};"undefined"!==typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"109"}}));k.ACESFilmicToneMapping=5;k.AddEquation=100;k.AddOperation=2;k.AdditiveBlending=2;k.AlphaFormat=1021;k.AlwaysDepth=1;k.AlwaysStencilFunc=519;k.AmbientLight=bf;k.AmbientLightProbe=zg;k.AnimationClip=Ma;k.AnimationLoader=qg;k.AnimationMixer=Gg;k.AnimationObjectGroup=
ci;k.AnimationUtils=pa;k.ArcCurve=cd;k.ArrayCamera=Jd;k.ArrowHelper=tb;k.Audio=dd;k.AudioAnalyser=Eg;k.AudioContext=Cg;k.AudioListener=Bg;k.AudioLoader=jf;k.AxesHelper=ve;k.AxisHelper=function(a){console.warn("THREE.AxisHelper has been renamed to THREE.AxesHelper.");return new ve(a)};k.BackSide=1;k.BasicDepthPacking=3200;k.BasicShadowMap=0;k.BinaryTextureLoader=function(a){console.warn("THREE.BinaryTextureLoader has been renamed to THREE.DataTextureLoader.");return new Te(a)};k.Bone=ig;k.BooleanKeyframeTrack=
Pe;k.BoundingBoxHelper=function(a,b){console.warn("THREE.BoundingBoxHelper has been deprecated. Creating a THREE.BoxHelper instead.");return new sb(a,b)};k.Box2=Jg;k.Box3=ab;k.Box3Helper=te;k.BoxBufferGeometry=Gd;k.BoxGeometry=Zg;k.BoxHelper=sb;k.BufferAttribute=O;k.BufferGeometry=E;k.BufferGeometryLoader=gf;k.ByteType=1010;k.Cache=uc;k.Camera=bb;k.CameraHelper=se;k.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been removed")};k.CanvasTexture=Pd;k.CatmullRomCurve3=ya;k.CineonToneMapping=
4;k.CircleBufferGeometry=Yc;k.CircleGeometry=je;k.ClampToEdgeWrapping=1001;k.Clock=Ag;k.ClosedSplineCurve3=ji;k.Color=H;k.ColorKeyframeTrack=Qe;k.CompressedTexture=Lc;k.CompressedTextureLoader=rg;k.ConeBufferGeometry=ie;k.ConeGeometry=he;k.CubeCamera=Dc;k.CubeGeometry=Zg;k.CubeReflectionMapping=301;k.CubeRefractionMapping=302;k.CubeTexture=ob;k.CubeTextureLoader=Ue;k.CubeUVReflectionMapping=306;k.CubeUVRefractionMapping=307;k.CubicBezierCurve=Sa;k.CubicBezierCurve3=gb;k.CubicInterpolant=Ne;k.CullFaceBack=
1;k.CullFaceFront=2;k.CullFaceFrontBack=3;k.CullFaceNone=0;k.Curve=D;k.CurvePath=rb;k.CustomBlending=5;k.CylinderBufferGeometry=qb;k.CylinderGeometry=ic;k.Cylindrical=hi;k.DataTexture=Zb;k.DataTexture2DArray=Ec;k.DataTexture3D=Fc;k.DataTextureLoader=Te;k.DecrementStencilOp=7683;k.DecrementWrapStencilOp=34056;k.DefaultLoadingManager=Zh;k.DepthFormat=1026;k.DepthStencilFormat=1027;k.DepthTexture=Qd;k.DirectionalLight=af;k.DirectionalLightHelper=ld;k.DirectionalLightShadow=$e;k.DiscreteInterpolant=Oe;
k.DodecahedronBufferGeometry=Qc;k.DodecahedronGeometry=Wd;k.DoubleSide=2;k.DstAlphaFactor=206;k.DstColorFactor=208;k.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new O(a,b)).setDynamic(!0)};k.EdgesGeometry=Xc;k.EdgesHelper=function(a,b){console.warn("THREE.EdgesHelper has been removed. Use THREE.EdgesGeometry instead.");return new ca(new Xc(a.geometry),new Q({color:void 0!==b?
b:16777215}))};k.EllipseCurve=Ja;k.EqualDepth=4;k.EqualStencilFunc=514;k.EquirectangularReflectionMapping=303;k.EquirectangularRefractionMapping=304;k.Euler=Qb;k.EventDispatcher=Ba;k.ExtrudeBufferGeometry=eb;k.ExtrudeGeometry=fc;k.Face3=zc;k.Face4=function(a,b,c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new zc(a,b,c,e,f,g)};k.FaceColors=1;k.FaceNormalsHelper=re;k.FileLoader=Na;k.FlatShading=1;k.Float32Attribute=function(a,b){console.warn("THREE.Float32Attribute has been removed. Use new THREE.Float32BufferAttribute() instead.");
return new A(a,b)};k.Float32BufferAttribute=A;k.Float64Attribute=function(a,b){console.warn("THREE.Float64Attribute has been removed. Use new THREE.Float64BufferAttribute() instead.");return new Cd(a,b)};k.Float64BufferAttribute=Cd;k.FloatType=1015;k.Fog=Je;k.FogExp2=Ie;k.Font=wg;k.FontLoader=xg;k.FrontFaceDirectionCCW=1;k.FrontFaceDirectionCW=0;k.FrontSide=0;k.Frustum=Ed;k.GammaEncoding=3007;k.Geometry=F;k.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");
if(b.isMesh){b.matrixAutoUpdate&&b.updateMatrix();var d=b.matrix;b=b.geometry}a.merge(b,d,c)},center:function(a){console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.");return a.center()}};k.GreaterDepth=6;k.GreaterEqualDepth=5;k.GreaterEqualStencilFunc=518;k.GreaterStencilFunc=516;k.GridHelper=mf;k.Group=Hc;k.HalfFloatType=1016;k.HemisphereLight=We;k.HemisphereLightHelper=id;k.HemisphereLightProbe=yg;k.IcosahedronBufferGeometry=Pc;k.IcosahedronGeometry=
Vd;k.ImageBitmapLoader=ug;k.ImageLoader=bd;k.ImageUtils=Kb;k.ImmediateRenderObject=pe;k.IncrementStencilOp=7682;k.IncrementWrapStencilOp=34055;k.InstancedBufferAttribute=ff;k.InstancedBufferGeometry=ef;k.InstancedInterleavedBuffer=Hg;k.InstancedMesh=jg;k.Int16Attribute=function(a,b){console.warn("THREE.Int16Attribute has been removed. Use new THREE.Int16BufferAttribute() instead.");return new Ad(a,b)};k.Int16BufferAttribute=Ad;k.Int32Attribute=function(a,b){console.warn("THREE.Int32Attribute has been removed. Use new THREE.Int32BufferAttribute() instead.");
return new Bd(a,b)};k.Int32BufferAttribute=Bd;k.Int8Attribute=function(a,b){console.warn("THREE.Int8Attribute has been removed. Use new THREE.Int8BufferAttribute() instead.");return new xd(a,b)};k.Int8BufferAttribute=xd;k.IntType=1013;k.InterleavedBuffer=Gb;k.InterleavedBufferAttribute=Kd;k.Interpolant=Ia;k.InterpolateDiscrete=2300;k.InterpolateLinear=2301;k.InterpolateSmooth=2302;k.InvertStencilOp=5386;k.JSONLoader=function(){console.error("THREE.JSONLoader has been removed.")};k.KeepStencilOp=7680;
k.KeyframeTrack=oa;k.LOD=Nd;k.LatheBufferGeometry=Wc;k.LatheGeometry=ge;k.Layers=Pf;k.LensFlare=function(){console.error("THREE.LensFlare has been moved to /examples/js/objects/Lensflare.js")};k.LessDepth=2;k.LessEqualDepth=3;k.LessEqualStencilFunc=515;k.LessStencilFunc=513;k.Light=da;k.LightProbe=Xa;k.LightProbeHelper=jd;k.LightShadow=ib;k.Line=xa;k.Line3=Kg;k.LineBasicMaterial=Q;k.LineCurve=za;k.LineCurve3=Ta;k.LineDashedMaterial=pc;k.LineLoop=Me;k.LinePieces=1;k.LineSegments=ca;k.LineStrip=0;k.LinearEncoding=
3E3;k.LinearFilter=1006;k.LinearInterpolant=ke;k.LinearMipMapLinearFilter=1008;k.LinearMipMapNearestFilter=1007;k.LinearMipmapLinearFilter=1008;k.LinearMipmapNearestFilter=1007;k.LinearToneMapping=1;k.Loader=S;k.LoaderUtils=fh;k.LoadingManager=pg;k.LogLuvEncoding=3003;k.LoopOnce=2200;k.LoopPingPong=2202;k.LoopRepeat=2201;k.LuminanceAlphaFormat=1025;k.LuminanceFormat=1024;k.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2,ROTATE:0,DOLLY:1,PAN:2};k.Material=M;k.MaterialLoader=df;k.Math=L;k.Matrix3=Y;k.Matrix4=U;k.MaxEquation=
104;k.Mesh=ja;k.MeshBasicMaterial=Ga;k.MeshDepthMaterial=Db;k.MeshDistanceMaterial=Eb;k.MeshFaceMaterial=function(a){console.warn("THREE.MeshFaceMaterial has been removed. Use an Array instead.");return a};k.MeshLambertMaterial=nc;k.MeshMatcapMaterial=oc;k.MeshNormalMaterial=mc;k.MeshPhongMaterial=Ra;k.MeshPhysicalMaterial=kc;k.MeshStandardMaterial=fb;k.MeshToonMaterial=lc;k.MinEquation=103;k.MirroredRepeatWrapping=1002;k.MixOperation=1;k.MultiMaterial=function(a){void 0===a&&(a=[]);console.warn("THREE.MultiMaterial has been removed. Use an Array instead.");
a.isMultiMaterial=!0;a.materials=a;a.clone=function(){return a.slice()};return a};k.MultiplyBlending=4;k.MultiplyOperation=0;k.NearestFilter=1003;k.NearestMipMapLinearFilter=1005;k.NearestMipMapNearestFilter=1004;k.NearestMipmapLinearFilter=1005;k.NearestMipmapNearestFilter=1004;k.NeverDepth=0;k.NeverStencilFunc=512;k.NoBlending=0;k.NoColors=0;k.NoToneMapping=0;k.NormalBlending=1;k.NotEqualDepth=7;k.NotEqualStencilFunc=517;k.NumberKeyframeTrack=$c;k.Object3D=B;k.ObjectLoader=hf;k.ObjectSpaceNormalMap=
1;k.OctahedronBufferGeometry=cc;k.OctahedronGeometry=Ud;k.OneFactor=201;k.OneMinusDstAlphaFactor=207;k.OneMinusDstColorFactor=209;k.OneMinusSrcAlphaFactor=205;k.OneMinusSrcColorFactor=203;k.OrthographicCamera=oe;k.PCFShadowMap=1;k.PCFSoftShadowMap=2;k.ParametricBufferGeometry=Nc;k.ParametricGeometry=Rd;k.Particle=function(a){console.warn("THREE.Particle has been renamed to THREE.Sprite.");return new Ld(a)};k.ParticleBasicMaterial=function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");
return new Qa(a)};k.ParticleSystem=function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new Kc(a,b)};k.ParticleSystemMaterial=function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new Qa(a)};k.Path=Wa;k.PerspectiveCamera=na;k.Plane=cb;k.PlaneBufferGeometry=$b;k.PlaneGeometry=Fd;k.PlaneHelper=ue;k.PointCloud=function(a,b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new Kc(a,b)};
k.PointCloudMaterial=function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new Qa(a)};k.PointLight=Ze;k.PointLightHelper=gd;k.Points=Kc;k.PointsMaterial=Qa;k.PolarGridHelper=nf;k.PolyhedronBufferGeometry=Ca;k.PolyhedronGeometry=Sd;k.PositionalAudio=Dg;k.PositionalAudioHelper=kd;k.PropertyBinding=Aa;k.PropertyMixer=Fg;k.QuadraticBezierCurve=Ua;k.QuadraticBezierCurve3=hb;k.Quaternion=ua;k.QuaternionKeyframeTrack=le;k.QuaternionLinearInterpolant=Re;k.REVISION=
"109";k.RGBADepthPacking=3201;k.RGBAFormat=1023;k.RGBA_ASTC_10x10_Format=37819;k.RGBA_ASTC_10x5_Format=37816;k.RGBA_ASTC_10x6_Format=37817;k.RGBA_ASTC_10x8_Format=37818;k.RGBA_ASTC_12x10_Format=37820;k.RGBA_ASTC_12x12_Format=37821;k.RGBA_ASTC_4x4_Format=37808;k.RGBA_ASTC_5x4_Format=37809;k.RGBA_ASTC_5x5_Format=37810;k.RGBA_ASTC_6x5_Format=37811;k.RGBA_ASTC_6x6_Format=37812;k.RGBA_ASTC_8x5_Format=37813;k.RGBA_ASTC_8x6_Format=37814;k.RGBA_ASTC_8x8_Format=37815;k.RGBA_PVRTC_2BPPV1_Format=35843;k.RGBA_PVRTC_4BPPV1_Format=
35842;k.RGBA_S3TC_DXT1_Format=33777;k.RGBA_S3TC_DXT3_Format=33778;k.RGBA_S3TC_DXT5_Format=33779;k.RGBDEncoding=3006;k.RGBEEncoding=3002;k.RGBEFormat=1023;k.RGBFormat=1022;k.RGBM16Encoding=3005;k.RGBM7Encoding=3004;k.RGB_ETC1_Format=36196;k.RGB_PVRTC_2BPPV1_Format=35841;k.RGB_PVRTC_4BPPV1_Format=35840;k.RGB_S3TC_DXT1_Format=33776;k.RawShaderMaterial=Zc;k.Ray=Sb;k.Raycaster=ei;k.RectAreaLight=cf;k.RectAreaLightHelper=hd;k.RedFormat=1028;k.ReinhardToneMapping=2;k.RepeatWrapping=1E3;k.ReplaceStencilOp=
7681;k.ReverseSubtractEquation=102;k.RingBufferGeometry=Vc;k.RingGeometry=fe;k.Scene=wd;k.SceneUtils={createMultiMaterialObject:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},detach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")},attach:function(){console.error("THREE.SceneUtils has been moved to /examples/js/utils/SceneUtils.js")}};k.ShaderChunk=N;k.ShaderLib=db;k.ShaderMaterial=ma;k.ShadowMaterial=
jc;k.Shape=Jb;k.ShapeBufferGeometry=hc;k.ShapeGeometry=gc;k.ShapePath=vg;k.ShapeUtils=pb;k.ShortType=1011;k.Skeleton=Le;k.SkeletonHelper=fd;k.SkinnedMesh=Od;k.SmoothShading=2;k.Sphere=nb;k.SphereBufferGeometry=Ib;k.SphereGeometry=ee;k.Spherical=gi;k.SphericalHarmonics3=kf;k.SphericalReflectionMapping=305;k.Spline=Mg;k.SplineCurve=Va;k.SplineCurve3=ki;k.SpotLight=Ye;k.SpotLightHelper=ed;k.SpotLightShadow=Xe;k.Sprite=Ld;k.SpriteMaterial=Hb;k.SrcAlphaFactor=204;k.SrcAlphaSaturateFactor=210;k.SrcColorFactor=
202;k.StereoCamera=ai;k.StringKeyframeTrack=Se;k.SubtractEquation=101;k.SubtractiveBlending=3;k.TOUCH={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3};k.TangentSpaceNormalMap=0;k.TetrahedronBufferGeometry=Oc;k.TetrahedronGeometry=Td;k.TextBufferGeometry=Uc;k.TextGeometry=de;k.Texture=W;k.TextureLoader=Ve;k.TorusBufferGeometry=Sc;k.TorusGeometry=Zd;k.TorusKnotBufferGeometry=Rc;k.TorusKnotGeometry=Yd;k.Triangle=R;k.TriangleFanDrawMode=2;k.TriangleStripDrawMode=1;k.TrianglesDrawMode=0;k.TubeBufferGeometry=
dc;k.TubeGeometry=Xd;k.UVMapping=300;k.Uint16Attribute=function(a,b){console.warn("THREE.Uint16Attribute has been removed. Use new THREE.Uint16BufferAttribute() instead.");return new Tb(a,b)};k.Uint16BufferAttribute=Tb;k.Uint32Attribute=function(a,b){console.warn("THREE.Uint32Attribute has been removed. Use new THREE.Uint32BufferAttribute() instead.");return new Ub(a,b)};k.Uint32BufferAttribute=Ub;k.Uint8Attribute=function(a,b){console.warn("THREE.Uint8Attribute has been removed. Use new THREE.Uint8BufferAttribute() instead.");
return new yd(a,b)};k.Uint8BufferAttribute=yd;k.Uint8ClampedAttribute=function(a,b){console.warn("THREE.Uint8ClampedAttribute has been removed. Use new THREE.Uint8ClampedBufferAttribute() instead.");return new zd(a,b)};k.Uint8ClampedBufferAttribute=zd;k.Uncharted2ToneMapping=3;k.Uniform=lf;k.UniformsLib=I;k.UniformsUtils=Ak;k.UnsignedByteType=1009;k.UnsignedInt248Type=1020;k.UnsignedIntType=1014;k.UnsignedShort4444Type=1017;k.UnsignedShort5551Type=1018;k.UnsignedShort565Type=1019;k.UnsignedShortType=
1012;k.VSMShadowMap=3;k.Vector2=w;k.Vector3=n;k.Vector4=aa;k.VectorKeyframeTrack=ad;k.Vertex=function(a,b,c){console.warn("THREE.Vertex has been removed. Use THREE.Vector3 instead.");return new n(a,b,c)};k.VertexColors=2;k.VertexNormalsHelper=qe;k.VideoTexture=mg;k.WebGLMultisampleRenderTarget=Of;k.WebGLRenderTarget=la;k.WebGLRenderTargetCube=Ab;k.WebGLRenderer=hg;k.WebGLUtils=Kh;k.WireframeGeometry=Mc;k.WireframeHelper=function(a,b){console.warn("THREE.WireframeHelper has been removed. Use THREE.WireframeGeometry instead.");
return new ca(new Mc(a.geometry),new Q({color:void 0!==b?b:16777215}))};k.WrapAroundEnding=2402;k.XHRLoader=function(a){console.warn("THREE.XHRLoader has been renamed to THREE.FileLoader.");return new Na(a)};k.ZeroCurvatureEnding=2400;k.ZeroFactor=200;k.ZeroSlopeEnding=2401;k.ZeroStencilOp=0;k.sRGBEncoding=3001;Object.defineProperty(k,"__esModule",{value:!0})});(function webpackUniversalModuleDefinition(root, factory) {
    if (typeof exports === 'object' && typeof module === 'object')
        module.exports = factory();
    else if (typeof define === 'function' && define.amd)
        define([], factory);
    else {
        var a = factory();
        for (var i in a)(typeof exports === 'object' ? exports : root)[i] = a[i];
    }
})(typeof self !== 'undefined' ? self : this, function () {
    return (function (modules) { // webpackBootstrap
        // The module cache
        var installedModules = {};
        // The require function
        function __webpack_require__(moduleId) {
            // Check if module is in cache
            if (installedModules[moduleId]) {
                return installedModules[moduleId].exports;
            }
            // Create a new module (and put it into the cache)
            var module = installedModules[moduleId] = {
                i: moduleId,
                l: false,
                exports: {}
            };

            // Execute the module function
            modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);

            // Flag the module as loaded
            module.l = true;
            // Return the exports of the module
            return module.exports;
        }
        // expose the modules object (__webpack_modules__)
        __webpack_require__.m = modules;
        // expose the module cache
        __webpack_require__.c = installedModules;
        // define getter function for harmony exports
        __webpack_require__.d = function (exports, name, getter) {
            if (!__webpack_require__.o(exports, name)) {
                Object.defineProperty(exports, name, {
                    configurable: false,
                    enumerable: true,
                    get: getter
                });
            }
        };
        // getDefaultExport function for compatibility with non-harmony modules
        __webpack_require__.n = function (module) {
            var getter = module && module.__esModule ?
                function getDefault() {
                    return module['default'];
                } :
                function getModuleExports() {
                    return module;
                };
            __webpack_require__.d(getter, 'a', getter);
            return getter;
        };
        // Object.prototype.hasOwnProperty.call
        __webpack_require__.o = function (object, property) {
            return Object.prototype.hasOwnProperty.call(object, property);
        };
        // __webpack_public_path__
        __webpack_require__.p = "";
        // Load entry module and return exports
        return __webpack_require__(__webpack_require__.s = 5);
    })
    ([
        //0
        (function (module, exports, __webpack_require__) {

            module.exports.VectorTile = __webpack_require__(6);
            module.exports.VectorTileFeature = __webpack_require__(2);
            module.exports.VectorTileLayer = __webpack_require__(1);
        }),
        //1
        (function (module, exports, __webpack_require__) {

            "use strict";


            var VectorTileFeature = __webpack_require__(2);

            module.exports = VectorTileLayer;

            function VectorTileLayer(pbf, end) {
                // Public
                this.version = 1;
                this.name = null;
                this.extent = 4096;
                this.length = 0;

                // Private
                this._pbf = pbf;
                this._keys = [];
                this._values = [];
                this._features = [];

                pbf.readFields(readLayer, this, end);

                this.length = this._features.length;
            }

            function readLayer(tag, layer, pbf) {
                if (tag === 15) layer.version = pbf.readVarint();
                else if (tag === 1) layer.name = pbf.readString();
                else if (tag === 5) layer.extent = pbf.readVarint();
                else if (tag === 2) layer._features.push(pbf.pos);
                else if (tag === 3) layer._keys.push(pbf.readString());
                else if (tag === 4) layer._values.push(readValueMessage(pbf));
            }

            function readValueMessage(pbf) {
                var value = null,
                    end = pbf.readVarint() + pbf.pos;

                while (pbf.pos < end) {
                    var tag = pbf.readVarint() >> 3;

                    value = tag === 1 ? pbf.readString() :
                        tag === 2 ? pbf.readFloat() :
                        tag === 3 ? pbf.readDouble() :
                        tag === 4 ? pbf.readVarint64() :
                        tag === 5 ? pbf.readVarint() :
                        tag === 6 ? pbf.readSVarint() :
                        tag === 7 ? pbf.readBoolean() : null;
                }

                return value;
            }

            // return feature `i` from this layer as a `VectorTileFeature`
            VectorTileLayer.prototype.feature = function (i) {
                if (i < 0 || i >= this._features.length) throw new Error('feature index out of bounds');

                this._pbf.pos = this._features[i];

                var end = this._pbf.readVarint() + this._pbf.pos;
                return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
            };
        }),
        //2
        (function (module, exports, __webpack_require__) {

            "use strict";


            var Point = __webpack_require__(3);

            module.exports = VectorTileFeature;

            function VectorTileFeature(pbf, end, extent, keys, values) {
                // Public
                this.properties = {};
                this.extent = extent;
                this.type = 0;

                // Private
                this._pbf = pbf;
                this._geometry = -1;
                this._keys = keys;
                this._values = values;

                pbf.readFields(readFeature, this, end);
            }

            function readFeature(tag, feature, pbf) {
                if (tag == 1) feature.id = pbf.readVarint();
                else if (tag == 2) readTag(pbf, feature);
                else if (tag == 3) feature.type = pbf.readVarint();
                else if (tag == 4) feature._geometry = pbf.pos;
            }

            function readTag(pbf, feature) {
                var end = pbf.readVarint() + pbf.pos;

                while (pbf.pos < end) {
                    var key = feature._keys[pbf.readVarint()],
                        value = feature._values[pbf.readVarint()];
                    feature.properties[key] = value;
                }
            }

            VectorTileFeature.types = ['Unknown', 'Point', 'LineString', 'Polygon'];

            VectorTileFeature.prototype.loadGeometry = function () {
                var pbf = this._pbf;
                pbf.pos = this._geometry;

                var end = pbf.readVarint() + pbf.pos,
                    cmd = 1,
                    length = 0,
                    x = 0,
                    y = 0,
                    lines = [],
                    line;

                while (pbf.pos < end) {
                    if (length <= 0) {
                        var cmdLen = pbf.readVarint();
                        cmd = cmdLen & 0x7;
                        length = cmdLen >> 3;
                    }

                    length--;

                    if (cmd === 1 || cmd === 2) {
                        x += pbf.readSVarint();
                        y += pbf.readSVarint();

                        if (cmd === 1) { // moveTo
                            if (line) lines.push(line);
                            line = [];
                        }

                        line.push(new Point(x, y));

                    } else if (cmd === 7) {

                        // Workaround for https://github.com/mapbox/mapnik-vector-tile/issues/90
                        if (line) {
                            line.push(line[0].clone()); // closePolygon
                        }

                    } else {
                        throw new Error('unknown command ' + cmd);
                    }
                }

                if (line) lines.push(line);

                return lines;
            };

            VectorTileFeature.prototype.bbox = function () {
                var pbf = this._pbf;
                pbf.pos = this._geometry;

                var end = pbf.readVarint() + pbf.pos,
                    cmd = 1,
                    length = 0,
                    x = 0,
                    y = 0,
                    x1 = Infinity,
                    x2 = -Infinity,
                    y1 = Infinity,
                    y2 = -Infinity;

                while (pbf.pos < end) {
                    if (length <= 0) {
                        var cmdLen = pbf.readVarint();
                        cmd = cmdLen & 0x7;
                        length = cmdLen >> 3;
                    }

                    length--;

                    if (cmd === 1 || cmd === 2) {
                        x += pbf.readSVarint();
                        y += pbf.readSVarint();
                        if (x < x1) x1 = x;
                        if (x > x2) x2 = x;
                        if (y < y1) y1 = y;
                        if (y > y2) y2 = y;

                    } else if (cmd !== 7) {
                        throw new Error('unknown command ' + cmd);
                    }
                }

                return [x1, y1, x2, y2];
            };

            VectorTileFeature.prototype.toGeoJSON = function (x, y, z) {
                var size = this.extent * Math.pow(2, z),
                    x0 = this.extent * x,
                    y0 = this.extent * y,
                    coords = this.loadGeometry(),
                    type = VectorTileFeature.types[this.type],
                    i, j;

                function project(line) {
                    for (var j = 0; j < line.length; j++) {
                        var p = line[j],
                            y2 = 180 - (p.y + y0) * 360 / size;
                        line[j] = [
                            (p.x + x0) * 360 / size - 180,
                            360 / Math.PI * Math.atan(Math.exp(y2 * Math.PI / 180)) - 90
                        ];
                    }
                }

                switch (this.type) {
                    case 1:
                        var points = [];
                        for (i = 0; i < coords.length; i++) {
                            points[i] = coords[i][0];
                        }
                        coords = points;
                        project(coords);
                        break;

                    case 2:
                        for (i = 0; i < coords.length; i++) {
                            project(coords[i]);
                        }
                        break;

                    case 3:
                        coords = classifyRings(coords);
                        for (i = 0; i < coords.length; i++) {
                            for (j = 0; j < coords[i].length; j++) {
                                project(coords[i][j]);
                            }
                        }
                        break;
                }

                if (coords.length === 1) {
                    coords = coords[0];
                } else {
                    type = 'Multi' + type;
                }

                var result = {
                    type: "Feature",
                    geometry: {
                        type: type,
                        coordinates: coords
                    },
                    properties: this.properties
                };

                if ('id' in this) {
                    result.id = this.id;
                }

                return result;
            };

            // classifies an array of rings into polygons with outer rings and holes

            function classifyRings(rings) {
                var len = rings.length;

                if (len <= 1) return [rings];

                var polygons = [],
                    polygon,
                    ccw;

                for (var i = 0; i < len; i++) {
                    var area = signedArea(rings[i]);
                    if (area === 0) continue;

                    if (ccw === undefined) ccw = area < 0;

                    if (ccw === area < 0) {
                        if (polygon) polygons.push(polygon);
                        polygon = [rings[i]];

                    } else {
                        polygon.push(rings[i]);
                    }
                }
                if (polygon) polygons.push(polygon);

                return polygons;
            }

            function signedArea(ring) {
                var sum = 0;
                for (var i = 0, len = ring.length, j = len - 1, p1, p2; i < len; j = i++) {
                    p1 = ring[i];
                    p2 = ring[j];
                    sum += (p2.x - p1.x) * (p1.y + p2.y);
                }
                return sum;
            }


            /***/
        }),
        /* 3 */
        /***/
        (function (module, exports, __webpack_require__) {

            "use strict";


            module.exports = Point;

            function Point(x, y) {
                this.x = x;
                this.y = y;
            }

            Point.prototype = {

                clone: function () {
                    return new Point(this.x, this.y);
                },

                add: function (p) {
                    return this.clone()._add(p);
                },

                sub: function (p) {
                    return this.clone()._sub(p);
                },

                multByPoint: function (p) {
                    return this.clone()._multByPoint(p);
                },

                divByPoint: function (p) {
                    return this.clone()._divByPoint(p);
                },

                mult: function (k) {
                    return this.clone()._mult(k);
                },

                div: function (k) {
                    return this.clone()._div(k);
                },

                rotate: function (a) {
                    return this.clone()._rotate(a);
                },

                rotateAround: function (a, p) {
                    return this.clone()._rotateAround(a, p);
                },

                matMult: function (m) {
                    return this.clone()._matMult(m);
                },

                /**
                 * Calculate this point but as a unit vector from 0, 0, meaning
                 * that the distance from the resulting point to the 0, 0
                 * coordinate will be equal to 1 and the angle from the resulting
                 * point to the 0, 0 coordinate will be the same as before.
                 * @return {Point} unit vector point
                 */
                unit: function () {
                    return this.clone()._unit();
                },

                /**
                 * Compute a perpendicular point, where the new y coordinate
                 * is the old x coordinate and the new x coordinate is the old y
                 * coordinate multiplied by -1
                 * @return {Point} perpendicular point
                 */
                perp: function () {
                    return this.clone()._perp();
                },

                /**
                 * Return a version of this point with the x & y coordinates
                 * rounded to integers.
                 * @return {Point} rounded point
                 */
                round: function () {
                    return this.clone()._round();
                },

                /**
                 * Return the magitude of this point: this is the Euclidean
                 * distance from the 0, 0 coordinate to this point's x and y
                 * coordinates.
                 * @return {Number} magnitude
                 */
                mag: function () {
                    return Math.sqrt(this.x * this.x + this.y * this.y);
                },

                /**
                 * Judge whether this point is equal to another point, returning
                 * true or false.
                 * @param {Point} other the other point
                 * @return {boolean} whether the points are equal
                 */
                equals: function (other) {
                    return this.x === other.x &&
                        this.y === other.y;
                },

                /**
                 * Calculate the distance from this point to another point
                 * @param {Point} p the other point
                 * @return {Number} distance
                 */
                dist: function (p) {
                    return Math.sqrt(this.distSqr(p));
                },

                /**
                 * Calculate the distance from this point to another point,
                 * without the square root step. Useful if you're comparing
                 * relative distances.
                 * @param {Point} p the other point
                 * @return {Number} distance
                 */
                distSqr: function (p) {
                    var dx = p.x - this.x,
                        dy = p.y - this.y;
                    return dx * dx + dy * dy;
                },

                /**
                 * Get the angle from the 0, 0 coordinate to this point, in radians
                 * coordinates.
                 * @return {Number} angle
                 */
                angle: function () {
                    return Math.atan2(this.y, this.x);
                },

                /**
                 * Get the angle from this point to another point, in radians
                 * @param {Point} b the other point
                 * @return {Number} angle
                 */
                angleTo: function (b) {
                    return Math.atan2(this.y - b.y, this.x - b.x);
                },

                /**
                 * Get the angle between this point and another point, in radians
                 * @param {Point} b the other point
                 * @return {Number} angle
                 */
                angleWith: function (b) {
                    return this.angleWithSep(b.x, b.y);
                },

                /*
                 * Find the angle of the two vectors, solving the formula for
                 * the cross product a x b = |a||b|sin(θ) for θ.
                 * @param {Number} x the x-coordinate
                 * @param {Number} y the y-coordinate
                 * @return {Number} the angle in radians
                 */
                angleWithSep: function (x, y) {
                    return Math.atan2(
                        this.x * y - this.y * x,
                        this.x * x + this.y * y);
                },

                _matMult: function (m) {
                    var x = m[0] * this.x + m[1] * this.y,
                        y = m[2] * this.x + m[3] * this.y;
                    this.x = x;
                    this.y = y;
                    return this;
                },

                _add: function (p) {
                    this.x += p.x;
                    this.y += p.y;
                    return this;
                },

                _sub: function (p) {
                    this.x -= p.x;
                    this.y -= p.y;
                    return this;
                },

                _mult: function (k) {
                    this.x *= k;
                    this.y *= k;
                    return this;
                },

                _div: function (k) {
                    this.x /= k;
                    this.y /= k;
                    return this;
                },

                _multByPoint: function (p) {
                    this.x *= p.x;
                    this.y *= p.y;
                    return this;
                },

                _divByPoint: function (p) {
                    this.x /= p.x;
                    this.y /= p.y;
                    return this;
                },

                _unit: function () {
                    this._div(this.mag());
                    return this;
                },

                _perp: function () {
                    var y = this.y;
                    this.y = this.x;
                    this.x = -y;
                    return this;
                },

                _rotate: function (angle) {
                    var cos = Math.cos(angle),
                        sin = Math.sin(angle),
                        x = cos * this.x - sin * this.y,
                        y = sin * this.x + cos * this.y;
                    this.x = x;
                    this.y = y;
                    return this;
                },

                _rotateAround: function (angle, p) {
                    var cos = Math.cos(angle),
                        sin = Math.sin(angle),
                        x = p.x + cos * (this.x - p.x) - sin * (this.y - p.y),
                        y = p.y + sin * (this.x - p.x) + cos * (this.y - p.y);
                    this.x = x;
                    this.y = y;
                    return this;
                },

                _round: function () {
                    this.x = Math.round(this.x);
                    this.y = Math.round(this.y);
                    return this;
                }
            };

            /**
             * Construct a point from an array if necessary, otherwise if the input
             * is already a Point, or an unknown type, return it unchanged
             * @param {Array<Number>|Point|*} a any kind of input value
             * @return {Point} constructed point, or passed-through value.
             * @example
             * // this
             * var point = Point.convert([0, 1]);
             * // is equivalent to
             * var point = new Point(0, 1);
             */
            Point.convert = function (a) {
                if (a instanceof Point) {
                    return a;
                }
                if (Array.isArray(a)) {
                    return new Point(a[0], a[1]);
                }
                return a;
            };


            /***/
        }),
        /* 4 */
        /***/
        (function (module, exports, __webpack_require__) {

            "use strict";


            module.exports = Pbf;

            var ieee754 = __webpack_require__(7);

            function Pbf(buf) {
                this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
                this.pos = 0;
                this.type = 0;
                this.length = this.buf.length;
            }

            Pbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum
            Pbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64
            Pbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields
            Pbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32

            var SHIFT_LEFT_32 = (1 << 16) * (1 << 16),
                SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;

            // Threshold chosen based on both benchmarking and knowledge about browser string
            // data structures (which currently switch structure types at 12 bytes or more)
            var TEXT_DECODER_MIN_LENGTH = 12;
            var utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');

            Pbf.prototype = {

                destroy: function () {
                    this.buf = null;
                },

                // === READING =================================================================

                readFields: function (readField, result, end) {
                    end = end || this.length;

                    while (this.pos < end) {
                        var val = this.readVarint(),
                            tag = val >> 3,
                            startPos = this.pos;

                        this.type = val & 0x7;
                        readField(tag, result, this);

                        if (this.pos === startPos) this.skip(val);
                    }
                    return result;
                },

                readMessage: function (readField, result) {
                    return this.readFields(readField, result, this.readVarint() + this.pos);
                },

                readFixed32: function () {
                    var val = readUInt32(this.buf, this.pos);
                    this.pos += 4;
                    return val;
                },

                readSFixed32: function () {
                    var val = readInt32(this.buf, this.pos);
                    this.pos += 4;
                    return val;
                },

                // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)

                readFixed64: function () {
                    var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
                    this.pos += 8;
                    return val;
                },

                readSFixed64: function () {
                    var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
                    this.pos += 8;
                    return val;
                },

                readFloat: function () {
                    var val = ieee754.read(this.buf, this.pos, true, 23, 4);
                    this.pos += 4;
                    return val;
                },

                readDouble: function () {
                    var val = ieee754.read(this.buf, this.pos, true, 52, 8);
                    this.pos += 8;
                    return val;
                },

                readVarint: function (isSigned) {
                    var buf = this.buf,
                        val, b;

                    b = buf[this.pos++];
                    val = b & 0x7f;
                    if (b < 0x80) return val;
                    b = buf[this.pos++];
                    val |= (b & 0x7f) << 7;
                    if (b < 0x80) return val;
                    b = buf[this.pos++];
                    val |= (b & 0x7f) << 14;
                    if (b < 0x80) return val;
                    b = buf[this.pos++];
                    val |= (b & 0x7f) << 21;
                    if (b < 0x80) return val;
                    b = buf[this.pos];
                    val |= (b & 0x0f) << 28;

                    return readVarintRemainder(val, isSigned, this);
                },

                readVarint64: function () { // for compatibility with v2.0.1
                    return this.readVarint(true);
                },

                readSVarint: function () {
                    var num = this.readVarint();
                    return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding
                },

                readBoolean: function () {
                    return Boolean(this.readVarint());
                },

                readString: function () {
                    var end = this.readVarint() + this.pos;
                    var pos = this.pos;
                    this.pos = end;

                    if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
                        // longer strings are fast with the built-in browser TextDecoder API
                        return readUtf8TextDecoder(this.buf, pos, end);
                    }
                    // short strings are fast with our custom implementation
                    return readUtf8(this.buf, pos, end);
                },

                readBytes: function () {
                    var end = this.readVarint() + this.pos,
                        buffer = this.buf.subarray(this.pos, end);
                    this.pos = end;
                    return buffer;
                },

                // verbose for performance reasons; doesn't affect gzipped size

                readPackedVarint: function (arr, isSigned) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readVarint(isSigned));
                    return arr;
                },
                readPackedSVarint: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readSVarint());
                    return arr;
                },
                readPackedBoolean: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readBoolean());
                    return arr;
                },
                readPackedFloat: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readFloat());
                    return arr;
                },
                readPackedDouble: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readDouble());
                    return arr;
                },
                readPackedFixed32: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readFixed32());
                    return arr;
                },
                readPackedSFixed32: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readSFixed32());
                    return arr;
                },
                readPackedFixed64: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readFixed64());
                    return arr;
                },
                readPackedSFixed64: function (arr) {
                    if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());
                    var end = readPackedEnd(this);
                    arr = arr || [];
                    while (this.pos < end) arr.push(this.readSFixed64());
                    return arr;
                },

                skip: function (val) {
                    var type = val & 0x7;
                    if (type === Pbf.Varint)
                        while (this.buf[this.pos++] > 0x7f) {}
                    else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;
                    else if (type === Pbf.Fixed32) this.pos += 4;
                    else if (type === Pbf.Fixed64) this.pos += 8;
                    else throw new Error('Unimplemented type: ' + type);
                },

                // === WRITING =================================================================

                writeTag: function (tag, type) {
                    this.writeVarint((tag << 3) | type);
                },

                realloc: function (min) {
                    var length = this.length || 16;

                    while (length < this.pos + min) length *= 2;

                    if (length !== this.length) {
                        var buf = new Uint8Array(length);
                        buf.set(this.buf);
                        this.buf = buf;
                        this.length = length;
                    }
                },

                finish: function () {
                    this.length = this.pos;
                    this.pos = 0;
                    return this.buf.subarray(0, this.length);
                },

                writeFixed32: function (val) {
                    this.realloc(4);
                    writeInt32(this.buf, val, this.pos);
                    this.pos += 4;
                },

                writeSFixed32: function (val) {
                    this.realloc(4);
                    writeInt32(this.buf, val, this.pos);
                    this.pos += 4;
                },

                writeFixed64: function (val) {
                    this.realloc(8);
                    writeInt32(this.buf, val & -1, this.pos);
                    writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
                    this.pos += 8;
                },

                writeSFixed64: function (val) {
                    this.realloc(8);
                    writeInt32(this.buf, val & -1, this.pos);
                    writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
                    this.pos += 8;
                },

                writeVarint: function (val) {
                    val = +val || 0;

                    if (val > 0xfffffff || val < 0) {
                        writeBigVarint(val, this);
                        return;
                    }

                    this.realloc(4);

                    this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0);
                    if (val <= 0x7f) return;
                    this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0);
                    if (val <= 0x7f) return;
                    this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0);
                    if (val <= 0x7f) return;
                    this.buf[this.pos++] = (val >>> 7) & 0x7f;
                },

                writeSVarint: function (val) {
                    this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
                },

                writeBoolean: function (val) {
                    this.writeVarint(Boolean(val));
                },

                writeString: function (str) {
                    str = String(str);
                    this.realloc(str.length * 4);

                    this.pos++; // reserve 1 byte for short string length

                    var startPos = this.pos;
                    // write the string directly to the buffer and see how much was written
                    this.pos = writeUtf8(this.buf, str, this.pos);
                    var len = this.pos - startPos;

                    if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);

                    // finally, write the message length in the reserved place and restore the position
                    this.pos = startPos - 1;
                    this.writeVarint(len);
                    this.pos += len;
                },

                writeFloat: function (val) {
                    this.realloc(4);
                    ieee754.write(this.buf, val, this.pos, true, 23, 4);
                    this.pos += 4;
                },

                writeDouble: function (val) {
                    this.realloc(8);
                    ieee754.write(this.buf, val, this.pos, true, 52, 8);
                    this.pos += 8;
                },

                writeBytes: function (buffer) {
                    var len = buffer.length;
                    this.writeVarint(len);
                    this.realloc(len);
                    for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];
                },

                writeRawMessage: function (fn, obj) {
                    this.pos++; // reserve 1 byte for short message length

                    // write the message directly to the buffer and see how much was written
                    var startPos = this.pos;
                    fn(obj, this);
                    var len = this.pos - startPos;

                    if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);

                    // finally, write the message length in the reserved place and restore the position
                    this.pos = startPos - 1;
                    this.writeVarint(len);
                    this.pos += len;
                },

                writeMessage: function (tag, fn, obj) {
                    this.writeTag(tag, Pbf.Bytes);
                    this.writeRawMessage(fn, obj);
                },

                writePackedVarint: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedVarint, arr);
                },
                writePackedSVarint: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedSVarint, arr);
                },
                writePackedBoolean: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedBoolean, arr);
                },
                writePackedFloat: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedFloat, arr);
                },
                writePackedDouble: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedDouble, arr);
                },
                writePackedFixed32: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedFixed32, arr);
                },
                writePackedSFixed32: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr);
                },
                writePackedFixed64: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedFixed64, arr);
                },
                writePackedSFixed64: function (tag, arr) {
                    if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr);
                },

                writeBytesField: function (tag, buffer) {
                    this.writeTag(tag, Pbf.Bytes);
                    this.writeBytes(buffer);
                },
                writeFixed32Field: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed32);
                    this.writeFixed32(val);
                },
                writeSFixed32Field: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed32);
                    this.writeSFixed32(val);
                },
                writeFixed64Field: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed64);
                    this.writeFixed64(val);
                },
                writeSFixed64Field: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed64);
                    this.writeSFixed64(val);
                },
                writeVarintField: function (tag, val) {
                    this.writeTag(tag, Pbf.Varint);
                    this.writeVarint(val);
                },
                writeSVarintField: function (tag, val) {
                    this.writeTag(tag, Pbf.Varint);
                    this.writeSVarint(val);
                },
                writeStringField: function (tag, str) {
                    this.writeTag(tag, Pbf.Bytes);
                    this.writeString(str);
                },
                writeFloatField: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed32);
                    this.writeFloat(val);
                },
                writeDoubleField: function (tag, val) {
                    this.writeTag(tag, Pbf.Fixed64);
                    this.writeDouble(val);
                },
                writeBooleanField: function (tag, val) {
                    this.writeVarintField(tag, Boolean(val));
                }
            };

            function readVarintRemainder(l, s, p) {
                var buf = p.buf,
                    h, b;

                b = buf[p.pos++];
                h = (b & 0x70) >> 4;
                if (b < 0x80) return toNum(l, h, s);
                b = buf[p.pos++];
                h |= (b & 0x7f) << 3;
                if (b < 0x80) return toNum(l, h, s);
                b = buf[p.pos++];
                h |= (b & 0x7f) << 10;
                if (b < 0x80) return toNum(l, h, s);
                b = buf[p.pos++];
                h |= (b & 0x7f) << 17;
                if (b < 0x80) return toNum(l, h, s);
                b = buf[p.pos++];
                h |= (b & 0x7f) << 24;
                if (b < 0x80) return toNum(l, h, s);
                b = buf[p.pos++];
                h |= (b & 0x01) << 31;
                if (b < 0x80) return toNum(l, h, s);

                throw new Error('Expected varint not more than 10 bytes');
            }

            function readPackedEnd(pbf) {
                return pbf.type === Pbf.Bytes ?
                    pbf.readVarint() + pbf.pos : pbf.pos + 1;
            }

            function toNum(low, high, isSigned) {
                if (isSigned) {
                    return high * 0x100000000 + (low >>> 0);
                }

                return ((high >>> 0) * 0x100000000) + (low >>> 0);
            }

            function writeBigVarint(val, pbf) {
                var low, high;

                if (val >= 0) {
                    low = (val % 0x100000000) | 0;
                    high = (val / 0x100000000) | 0;
                } else {
                    low = ~(-val % 0x100000000);
                    high = ~(-val / 0x100000000);

                    if (low ^ 0xffffffff) {
                        low = (low + 1) | 0;
                    } else {
                        low = 0;
                        high = (high + 1) | 0;
                    }
                }

                if (val >= 0x10000000000000000 || val < -0x10000000000000000) {
                    throw new Error('Given varint doesn\'t fit into 10 bytes');
                }

                pbf.realloc(10);

                writeBigVarintLow(low, high, pbf);
                writeBigVarintHigh(high, pbf);
            }

            function writeBigVarintLow(low, high, pbf) {
                pbf.buf[pbf.pos++] = low & 0x7f | 0x80;
                low >>>= 7;
                pbf.buf[pbf.pos++] = low & 0x7f | 0x80;
                low >>>= 7;
                pbf.buf[pbf.pos++] = low & 0x7f | 0x80;
                low >>>= 7;
                pbf.buf[pbf.pos++] = low & 0x7f | 0x80;
                low >>>= 7;
                pbf.buf[pbf.pos] = low & 0x7f;
            }

            function writeBigVarintHigh(high, pbf) {
                var lsb = (high & 0x07) << 4;

                pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0);
                if (!high) return;
                pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0);
                if (!high) return;
                pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0);
                if (!high) return;
                pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0);
                if (!high) return;
                pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0);
                if (!high) return;
                pbf.buf[pbf.pos++] = high & 0x7f;
            }

            function makeRoomForExtraLength(startPos, len, pbf) {
                var extraLen =
                    len <= 0x3fff ? 1 :
                    len <= 0x1fffff ? 2 :
                    len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));

                // if 1 byte isn't enough for encoding message length, shift the data to the right
                pbf.realloc(extraLen);
                for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];
            }

            function writePackedVarint(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]);
            }

            function writePackedSVarint(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]);
            }

            function writePackedFloat(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]);
            }

            function writePackedDouble(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]);
            }

            function writePackedBoolean(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]);
            }

            function writePackedFixed32(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]);
            }

            function writePackedSFixed32(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]);
            }

            function writePackedFixed64(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]);
            }

            function writePackedSFixed64(arr, pbf) {
                for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]);
            }

            // Buffer code below from https://github.com/feross/buffer, MIT-licensed

            function readUInt32(buf, pos) {
                return ((buf[pos]) |
                        (buf[pos + 1] << 8) |
                        (buf[pos + 2] << 16)) +
                    (buf[pos + 3] * 0x1000000);
            }

            function writeInt32(buf, val, pos) {
                buf[pos] = val;
                buf[pos + 1] = (val >>> 8);
                buf[pos + 2] = (val >>> 16);
                buf[pos + 3] = (val >>> 24);
            }

            function readInt32(buf, pos) {
                return ((buf[pos]) |
                        (buf[pos + 1] << 8) |
                        (buf[pos + 2] << 16)) +
                    (buf[pos + 3] << 24);
            }

            function readUtf8(buf, pos, end) {
                var str = '';
                var i = pos;

                while (i < end) {
                    var b0 = buf[i];
                    var c = null; // codepoint
                    var bytesPerSequence =
                        b0 > 0xEF ? 4 :
                        b0 > 0xDF ? 3 :
                        b0 > 0xBF ? 2 : 1;

                    if (i + bytesPerSequence > end) break;

                    var b1, b2, b3;

                    if (bytesPerSequence === 1) {
                        if (b0 < 0x80) {
                            c = b0;
                        }
                    } else if (bytesPerSequence === 2) {
                        b1 = buf[i + 1];
                        if ((b1 & 0xC0) === 0x80) {
                            c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);
                            if (c <= 0x7F) {
                                c = null;
                            }
                        }
                    } else if (bytesPerSequence === 3) {
                        b1 = buf[i + 1];
                        b2 = buf[i + 2];
                        if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {
                            c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);
                            if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {
                                c = null;
                            }
                        }
                    } else if (bytesPerSequence === 4) {
                        b1 = buf[i + 1];
                        b2 = buf[i + 2];
                        b3 = buf[i + 3];
                        if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {
                            c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);
                            if (c <= 0xFFFF || c >= 0x110000) {
                                c = null;
                            }
                        }
                    }

                    if (c === null) {
                        c = 0xFFFD;
                        bytesPerSequence = 1;

                    } else if (c > 0xFFFF) {
                        c -= 0x10000;
                        str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);
                        c = 0xDC00 | c & 0x3FF;
                    }

                    str += String.fromCharCode(c);
                    i += bytesPerSequence;
                }

                return str;
            }

            function readUtf8TextDecoder(buf, pos, end) {
                return utf8TextDecoder.decode(buf.subarray(pos, end));
            }

            function writeUtf8(buf, str, pos) {
                for (var i = 0, c, lead; i < str.length; i++) {
                    c = str.charCodeAt(i); // code point

                    if (c > 0xD7FF && c < 0xE000) {
                        if (lead) {
                            if (c < 0xDC00) {
                                buf[pos++] = 0xEF;
                                buf[pos++] = 0xBF;
                                buf[pos++] = 0xBD;
                                lead = c;
                                continue;
                            } else {
                                c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;
                                lead = null;
                            }
                        } else {
                            if (c > 0xDBFF || (i + 1 === str.length)) {
                                buf[pos++] = 0xEF;
                                buf[pos++] = 0xBF;
                                buf[pos++] = 0xBD;
                            } else {
                                lead = c;
                            }
                            continue;
                        }
                    } else if (lead) {
                        buf[pos++] = 0xEF;
                        buf[pos++] = 0xBF;
                        buf[pos++] = 0xBD;
                        lead = null;
                    }

                    if (c < 0x80) {
                        buf[pos++] = c;
                    } else {
                        if (c < 0x800) {
                            buf[pos++] = c >> 0x6 | 0xC0;
                        } else {
                            if (c < 0x10000) {
                                buf[pos++] = c >> 0xC | 0xE0;
                            } else {
                                buf[pos++] = c >> 0x12 | 0xF0;
                                buf[pos++] = c >> 0xC & 0x3F | 0x80;
                            }
                            buf[pos++] = c >> 0x6 & 0x3F | 0x80;
                        }
                        buf[pos++] = c & 0x3F | 0x80;
                    }
                }
                return pos;
            }

        }),
        //5
        (function (module, __webpack_exports__, __webpack_require__) {

            "use strict";
            Object.defineProperty(__webpack_exports__, "__esModule", {
                value: true
            });
            /* harmony export (immutable) */
            __webpack_exports__["mvt2GeoJSON"] = mvt2GeoJSON;
            /* harmony export (immutable) */
            __webpack_exports__["geojsonTile2Pbf"] = geojsonTile2Pbf;

            var VectorTile = __webpack_require__(0).VectorTile;
            var Protobuf = __webpack_require__(4);
            var vtpbf = __webpack_require__(8)

            // eslint-disable-next-line consistent-return
            function mvt2GeoJSON(data, x, y, z) {
                if (data) {
                    var tile = new VectorTile(new Protobuf(data));
                    var layers = tile.layers || {};
                    var result = {};
                    for (var layerkey in layers) {
                        result[layerkey] = [];
                        var layer = layers[layerkey] || {};
                        const len = layer.length;
                        let i = 0;
                        while (i < len) {
                            const feature = layer.feature(i);
                            const geojson = feature.toGeoJSON(x, y, z);
                            result[layerkey].push(geojson);
                            i++;
                        }
                    }
                    return result;
                }
            }

            function geojsonTile2Pbf(layerName, tile) {
                var data = {};
                data[layerName] = tile;
                var buff = vtpbf.fromGeojsonVt(data);
                return buff;

            }
        }),
        //6
        (function (module, exports, __webpack_require__) {

            "use strict";


            var VectorTileLayer = __webpack_require__(1);

            module.exports = VectorTile;

            function VectorTile(pbf, end) {
                this.layers = pbf.readFields(readTile, {}, end);
            }

            function readTile(tag, layers, pbf) {
                if (tag === 3) {
                    var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
                    if (layer.length) layers[layer.name] = layer;
                }
            }
        }),
        //7
        (function (module, exports) {

            exports.read = function (buffer, offset, isLE, mLen, nBytes) {
                var e, m
                var eLen = (nBytes * 8) - mLen - 1
                var eMax = (1 << eLen) - 1
                var eBias = eMax >> 1
                var nBits = -7
                var i = isLE ? (nBytes - 1) : 0
                var d = isLE ? -1 : 1
                var s = buffer[offset + i]

                i += d

                e = s & ((1 << (-nBits)) - 1)
                s >>= (-nBits)
                nBits += eLen
                for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}

                m = e & ((1 << (-nBits)) - 1)
                e >>= (-nBits)
                nBits += mLen
                for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}

                if (e === 0) {
                    e = 1 - eBias
                } else if (e === eMax) {
                    return m ? NaN : ((s ? -1 : 1) * Infinity)
                } else {
                    m = m + Math.pow(2, mLen)
                    e = e - eBias
                }
                return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
            }

            exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
                var e, m, c
                var eLen = (nBytes * 8) - mLen - 1
                var eMax = (1 << eLen) - 1
                var eBias = eMax >> 1
                var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
                var i = isLE ? 0 : (nBytes - 1)
                var d = isLE ? 1 : -1
                var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0

                value = Math.abs(value)

                if (isNaN(value) || value === Infinity) {
                    m = isNaN(value) ? 1 : 0
                    e = eMax
                } else {
                    e = Math.floor(Math.log(value) / Math.LN2)
                    if (value * (c = Math.pow(2, -e)) < 1) {
                        e--
                        c *= 2
                    }
                    if (e + eBias >= 1) {
                        value += rt / c
                    } else {
                        value += rt * Math.pow(2, 1 - eBias)
                    }
                    if (value * c >= 2) {
                        e++
                        c /= 2
                    }

                    if (e + eBias >= eMax) {
                        m = 0
                        e = eMax
                    } else if (e + eBias >= 1) {
                        m = ((value * c) - 1) * Math.pow(2, mLen)
                        e = e + eBias
                    } else {
                        m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
                        e = 0
                    }
                }

                for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}

                e = (e << mLen) | m
                eLen += mLen
                for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}

                buffer[offset + i - d] |= s * 128
            }
        }),
        //8
        (function (module, exports, __webpack_require__) {

            var Pbf = __webpack_require__(4)
            var GeoJSONWrapper = __webpack_require__(9)

            module.exports = fromVectorTileJs
            module.exports.fromVectorTileJs = fromVectorTileJs
            module.exports.fromGeojsonVt = fromGeojsonVt
            module.exports.GeoJSONWrapper = GeoJSONWrapper

            /**
             * Serialize a vector-tile-js-created tile to pbf
             *
             * @param {Object} tile
             * @return {Buffer} uncompressed, pbf-serialized tile data
             */
            function fromVectorTileJs(tile) {
                var out = new Pbf()
                writeTile(tile, out)
                return out.finish()
            }

            /**
             * Serialized a geojson-vt-created tile to pbf.
             *
             * @param {Object} layers - An object mapping layer names to geojson-vt-created vector tile objects
             * @param {Object} [options] - An object specifying the vector-tile specification version and extent that were used to create `layers`.
             * @param {Number} [options.version=1] - Version of vector-tile spec used
             * @param {Number} [options.extent=4096] - Extent of the vector tile
             * @return {Buffer} uncompressed, pbf-serialized tile data
             */
            function fromGeojsonVt(layers, options) {
                options = options || {}
                var l = {}
                for (var k in layers) {
                    l[k] = new GeoJSONWrapper(layers[k].features, options)
                    l[k].name = k
                    l[k].version = options.version
                    l[k].extent = options.extent
                }
                return fromVectorTileJs({
                    layers: l
                })
            }

            function writeTile(tile, pbf) {
                for (var key in tile.layers) {
                    pbf.writeMessage(3, writeLayer, tile.layers[key])
                }
            }

            function writeLayer(layer, pbf) {
                pbf.writeVarintField(15, layer.version || 1)
                pbf.writeStringField(1, layer.name || '')
                pbf.writeVarintField(5, layer.extent || 4096)

                var i
                var context = {
                    keys: [],
                    values: [],
                    keycache: {},
                    valuecache: {}
                }

                for (i = 0; i < layer.length; i++) {
                    context.feature = layer.feature(i)
                    pbf.writeMessage(2, writeFeature, context)
                }

                var keys = context.keys
                for (i = 0; i < keys.length; i++) {
                    pbf.writeStringField(3, keys[i])
                }

                var values = context.values
                for (i = 0; i < values.length; i++) {
                    pbf.writeMessage(4, writeValue, values[i])
                }
            }

            function writeFeature(context, pbf) {
                var feature = context.feature

                if (feature.id !== undefined) {
                    pbf.writeVarintField(1, feature.id)
                }

                pbf.writeMessage(2, writeProperties, context)
                pbf.writeVarintField(3, feature.type)
                pbf.writeMessage(4, writeGeometry, feature)
            }

            function writeProperties(context, pbf) {
                var feature = context.feature
                var keys = context.keys
                var values = context.values
                var keycache = context.keycache
                var valuecache = context.valuecache

                for (var key in feature.properties) {
                    var keyIndex = keycache[key]
                    if (typeof keyIndex === 'undefined') {
                        keys.push(key)
                        keyIndex = keys.length - 1
                        keycache[key] = keyIndex
                    }
                    pbf.writeVarint(keyIndex)

                    var value = feature.properties[key]
                    var type = typeof value
                    if (type !== 'string' && type !== 'boolean' && type !== 'number') {
                        value = JSON.stringify(value)
                    }
                    var valueKey = type + ':' + value
                    var valueIndex = valuecache[valueKey]
                    if (typeof valueIndex === 'undefined') {
                        values.push(value)
                        valueIndex = values.length - 1
                        valuecache[valueKey] = valueIndex
                    }
                    pbf.writeVarint(valueIndex)
                }
            }

            function command(cmd, length) {
                return (length << 3) + (cmd & 0x7)
            }

            function zigzag(num) {
                return (num << 1) ^ (num >> 31)
            }

            function writeGeometry(feature, pbf) {
                var geometry = feature.loadGeometry()
                var type = feature.type
                var x = 0
                var y = 0
                var rings = geometry.length
                for (var r = 0; r < rings; r++) {
                    var ring = geometry[r]
                    var count = 1
                    if (type === 1) {
                        count = ring.length
                    }
                    pbf.writeVarint(command(1, count)) // moveto
                    // do not write polygon closing path as lineto
                    var lineCount = type === 3 ? ring.length - 1 : ring.length
                    for (var i = 0; i < lineCount; i++) {
                        if (i === 1 && type !== 1) {
                            pbf.writeVarint(command(2, lineCount - 1)) // lineto
                        }
                        var dx = ring[i].x - x
                        var dy = ring[i].y - y
                        pbf.writeVarint(zigzag(dx))
                        pbf.writeVarint(zigzag(dy))
                        x += dx
                        y += dy
                    }
                    if (type === 3) {
                        pbf.writeVarint(command(7, 1)) // closepath
                    }
                }
            }

            function writeValue(value, pbf) {
                var type = typeof value
                if (type === 'string') {
                    pbf.writeStringField(1, value)
                } else if (type === 'boolean') {
                    pbf.writeBooleanField(7, value)
                } else if (type === 'number') {
                    if (value % 1 !== 0) {
                        pbf.writeDoubleField(3, value)
                    } else if (value < 0) {
                        pbf.writeSVarintField(6, value)
                    } else {
                        pbf.writeVarintField(5, value)
                    }
                }
            }
        }),
        //9
        (function (module, exports, __webpack_require__) {

            "use strict";


            var Point = __webpack_require__(3)
            var VectorTileFeature = __webpack_require__(0).VectorTileFeature

            module.exports = GeoJSONWrapper

            // conform to vectortile api
            function GeoJSONWrapper(features, options) {
                this.options = options || {}
                this.features = features
                this.length = features.length
            }

            GeoJSONWrapper.prototype.feature = function (i) {
                return new FeatureWrapper(this.features[i], this.options.extent)
            }

            function FeatureWrapper(feature, extent) {
                this.id = typeof feature.id === 'number' ? feature.id : undefined
                this.type = feature.type
                this.rawGeometry = feature.type === 1 ? [feature.geometry] : feature.geometry
                this.properties = feature.tags
                this.extent = extent || 4096
            }

            FeatureWrapper.prototype.loadGeometry = function () {
                var rings = this.rawGeometry
                this.geometry = []

                for (var i = 0; i < rings.length; i++) {
                    var ring = rings[i]
                    var newRing = []
                    for (var j = 0; j < ring.length; j++) {
                        newRing.push(new Point(ring[j][0], ring[j][1]))
                    }
                    this.geometry.push(newRing)
                }
                return this.geometry
            }

            FeatureWrapper.prototype.bbox = function () {
                if (!this.geometry) this.loadGeometry()

                var rings = this.geometry
                var x1 = Infinity
                var x2 = -Infinity
                var y1 = Infinity
                var y2 = -Infinity

                for (var i = 0; i < rings.length; i++) {
                    var ring = rings[i]

                    for (var j = 0; j < ring.length; j++) {
                        var coord = ring[j]

                        x1 = Math.min(x1, coord.x)
                        x2 = Math.max(x2, coord.x)
                        y1 = Math.min(y1, coord.y)
                        y2 = Math.max(y2, coord.y)
                    }
                }

                return [x1, y1, x2, y2]
            }

            FeatureWrapper.prototype.toGeoJSON = VectorTileFeature.prototype.toGeoJSON
        })
    ]);
});/**
 * @author WestLangley / http://github.com/WestLangley
 *
 * parameters = {
 *  color: <hex>,
 *  linewidth: <float>,
 *  dashed: <boolean>,
 *  dashScale: <float>,
 *  dashSize: <float>,
 *  gapSize: <float>,
 *  resolution: <Vector2>, // to be set by renderer
 * }
 */

THREE.UniformsLib.line = {

	linewidth: {
		value: 1
	},
	resolution: {
		value: new THREE.Vector2(1, 1)
	},
	dashScale: {
		value: 1
	},
	dashSize: {
		value: 1
	},
	gapSize: {
		value: 1
	} // todo FIX - maybe change to totalSize

};

THREE.ShaderLib['line'] = {

	uniforms: THREE.UniformsUtils.merge([
		THREE.UniformsLib.common,
		THREE.UniformsLib.fog,
		THREE.UniformsLib.line
	]),

	vertexShader: `
		#include <common>
		#include <color_pars_vertex>
		#include <fog_pars_vertex>
		#include <logdepthbuf_pars_vertex>
		#include <clipping_planes_pars_vertex>

		uniform float linewidth;
		uniform vec2 resolution;

		attribute vec3 instanceStart;
		attribute vec3 instanceEnd;

		attribute vec3 instanceColorStart;
		attribute vec3 instanceColorEnd;

		varying vec2 vUv;

		#ifdef USE_DASH

			uniform float dashScale;
			attribute float instanceDistanceStart;
			attribute float instanceDistanceEnd;
			varying float vLineDistance;

		#endif

		void trimSegment( const in vec4 start, inout vec4 end ) {

			// trim end segment so it terminates between the camera plane and the near plane

			// conservative estimate of the near plane
			float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column
			float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column
			float nearEstimate = - 0.5 * b / a;

			float alpha = ( nearEstimate - start.z ) / ( end.z - start.z );

			end.xyz = mix( start.xyz, end.xyz, alpha );

		}

		void main() {

			#ifdef USE_COLOR

				vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;

			#endif

			#ifdef USE_DASH

				vLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;

			#endif

			float aspect = resolution.x / resolution.y;

			vUv = uv;

			// camera space
			vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );
			vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );

			// special case for perspective projection, and segments that terminate either in, or behind, the camera plane
			// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space
			// but we need to perform ndc-space calculations in the shader, so we must address this issue directly
			// perhaps there is a more elegant solution -- WestLangley

			bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column

			if ( perspective ) {

				if ( start.z < 0.0 && end.z >= 0.0 ) {

					trimSegment( start, end );

				} else if ( end.z < 0.0 && start.z >= 0.0 ) {

					trimSegment( end, start );

				}

			}

			// clip space
			vec4 clipStart = projectionMatrix * start;
			vec4 clipEnd = projectionMatrix * end;

			// ndc space
			vec2 ndcStart = clipStart.xy / clipStart.w;
			vec2 ndcEnd = clipEnd.xy / clipEnd.w;

			// direction
			vec2 dir = ndcEnd - ndcStart;

			// account for clip-space aspect ratio
			dir.x *= aspect;
			dir = normalize( dir );

			// perpendicular to dir
			vec2 offset = vec2( dir.y, - dir.x );

			// undo aspect ratio adjustment
			dir.x /= aspect;
			offset.x /= aspect;

			// sign flip
			if ( position.x < 0.0 ) offset *= - 1.0;

			// endcaps
			if ( position.y < 0.0 ) {

				offset += - dir;

			} else if ( position.y > 1.0 ) {

				offset += dir;

			}

			// adjust for linewidth
			offset *= linewidth;

			// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...
			offset /= resolution.y;

			// select end
			vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;

			// back to clip space
			offset *= clip.w;

			clip.xy += offset;

			gl_Position = clip;

			vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation

			#include <logdepthbuf_vertex>
			#include <clipping_planes_vertex>
			#include <fog_vertex>

		}
		`,

	fragmentShader: `
		uniform vec3 diffuse;
		uniform float opacity;

		#ifdef USE_DASH

			uniform float dashSize;
			uniform float gapSize;

		#endif

		varying float vLineDistance;

		#include <common>
		#include <color_pars_fragment>
		#include <fog_pars_fragment>
		#include <logdepthbuf_pars_fragment>
		#include <clipping_planes_pars_fragment>

		varying vec2 vUv;

		void main() {

			#include <clipping_planes_fragment>

			#ifdef USE_DASH

				if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps

				if ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX

			#endif

			if ( abs( vUv.y ) > 1.0 ) {

				float a = vUv.x;
				float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;
				float len2 = a * a + b * b;

				if ( len2 > 1.0 ) discard;

			}

			vec4 diffuseColor = vec4( diffuse, opacity );

			#include <logdepthbuf_fragment>
			#include <color_fragment>

			gl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );

			#include <premultiplied_alpha_fragment>
			#include <tonemapping_fragment>
			#include <encodings_fragment>
			#include <fog_fragment>

		}
		`
};

THREE.LineMaterial = function (parameters) {

	THREE.ShaderMaterial.call(this, {

		type: 'LineMaterial',

		uniforms: THREE.UniformsUtils.clone(THREE.ShaderLib['line'].uniforms),

		vertexShader: THREE.ShaderLib['line'].vertexShader,
		fragmentShader: THREE.ShaderLib['line'].fragmentShader

	});

	this.dashed = false;

	Object.defineProperties(this, {

		color: {

			enumerable: true,

			get: function () {

				return this.uniforms.diffuse.value;

			},

			set: function (value) {

				this.uniforms.diffuse.value = value;

			}

		},

		linewidth: {

			enumerable: true,

			get: function () {

				return this.uniforms.linewidth.value;

			},

			set: function (value) {

				this.uniforms.linewidth.value = value;

			}

		},

		dashScale: {

			enumerable: true,

			get: function () {

				return this.uniforms.dashScale.value;

			},

			set: function (value) {

				this.uniforms.dashScale.value = value;

			}

		},

		dashSize: {

			enumerable: true,

			get: function () {

				return this.uniforms.dashSize.value;

			},

			set: function (value) {

				this.uniforms.dashSize.value = value;

			}

		},

		gapSize: {

			enumerable: true,

			get: function () {

				return this.uniforms.gapSize.value;

			},

			set: function (value) {

				this.uniforms.gapSize.value = value;

			}

		},

		resolution: {

			enumerable: true,

			get: function () {

				return this.uniforms.resolution.value;

			},

			set: function (value) {

				this.uniforms.resolution.value.copy(value);

			}

		}

	});

	this.setValues(parameters);

};

THREE.LineMaterial.prototype = Object.create(THREE.ShaderMaterial.prototype);
THREE.LineMaterial.prototype.constructor = THREE.LineMaterial;

THREE.LineMaterial.prototype.isLineMaterial = true;

THREE.LineMaterial.prototype.copy = function (source) {

	THREE.ShaderMaterial.prototype.copy.call(this, source);

	this.color.copy(source.color);

	this.linewidth = source.linewidth;

	this.resolution = source.resolution;

	// todo

	return this;

};/**
 * @author alteredq / http://alteredqualia.com/
 */

THREE.EffectComposer = function ( renderer, renderTarget ) {

	this.renderer = renderer;

	if ( renderTarget === undefined ) {

		var parameters = {
			minFilter: THREE.LinearFilter,
			magFilter: THREE.LinearFilter,
			format: THREE.RGBAFormat,
			stencilBuffer: false
		};

		var size = renderer.getDrawingBufferSize( new THREE.Vector2() );
		renderTarget = new THREE.WebGLRenderTarget( size.width, size.height, parameters );
		renderTarget.texture.name = 'EffectComposer.rt1';

	}

	this.renderTarget1 = renderTarget;
	this.renderTarget2 = renderTarget.clone();
	this.renderTarget2.texture.name = 'EffectComposer.rt2';

	this.writeBuffer = this.renderTarget1;
	this.readBuffer = this.renderTarget2;

	this.renderToScreen = true;

	this.passes = [];

	// dependencies

	if ( THREE.CopyShader === undefined ) {

		console.error( 'THREE.EffectComposer relies on THREE.CopyShader' );

	}

	if ( THREE.ShaderPass === undefined ) {

		console.error( 'THREE.EffectComposer relies on THREE.ShaderPass' );

	}

	this.copyPass = new THREE.ShaderPass( THREE.CopyShader );

	this._previousFrameTime = Date.now();

};

Object.assign( THREE.EffectComposer.prototype, {

	swapBuffers: function () {

		var tmp = this.readBuffer;
		this.readBuffer = this.writeBuffer;
		this.writeBuffer = tmp;

	},

	addPass: function ( pass ) {

		this.passes.push( pass );

		var size = this.renderer.getDrawingBufferSize( new THREE.Vector2() );
		pass.setSize( size.width, size.height );

	},

	insertPass: function ( pass, index ) {

		this.passes.splice( index, 0, pass );

	},

	isLastEnabledPass: function ( passIndex ) {

		for ( var i = passIndex + 1; i < this.passes.length; i ++ ) {

			if ( this.passes[ i ].enabled ) {

				return false;

			}

		}

		return true;

	},

	render: function ( deltaTime ) {

		// deltaTime value is in seconds

		if ( deltaTime === undefined ) {

			deltaTime = ( Date.now() - this._previousFrameTime ) * 0.001;

		}

		this._previousFrameTime = Date.now();

		var currentRenderTarget = this.renderer.getRenderTarget();

		var maskActive = false;

		var pass, i, il = this.passes.length;

		for ( i = 0; i < il; i ++ ) {

			pass = this.passes[ i ];

			if ( pass.enabled === false ) continue;

			pass.renderToScreen = ( this.renderToScreen && this.isLastEnabledPass( i ) );
			pass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime, maskActive );

			if ( pass.needsSwap ) {

				if ( maskActive ) {

					var context = this.renderer.context;

					context.stencilFunc( context.NOTEQUAL, 1, 0xffffffff );

					this.copyPass.render( this.renderer, this.writeBuffer, this.readBuffer, deltaTime );

					context.stencilFunc( context.EQUAL, 1, 0xffffffff );

				}

				this.swapBuffers();

			}

			if ( THREE.MaskPass !== undefined ) {

				if ( pass instanceof THREE.MaskPass ) {

					maskActive = true;

				} else if ( pass instanceof THREE.ClearMaskPass ) {

					maskActive = false;

				}

			}

		}

		this.renderer.setRenderTarget( currentRenderTarget );

	},

	reset: function ( renderTarget ) {

		if ( renderTarget === undefined ) {

			var size = this.renderer.getDrawingBufferSize( new THREE.Vector2() );

			renderTarget = this.renderTarget1.clone();
			renderTarget.setSize( size.width, size.height );

		}

		this.renderTarget1.dispose();
		this.renderTarget2.dispose();
		this.renderTarget1 = renderTarget;
		this.renderTarget2 = renderTarget.clone();

		this.writeBuffer = this.renderTarget1;
		this.readBuffer = this.renderTarget2;

	},

	setSize: function ( width, height ) {

		this.renderTarget1.setSize( width, height );
		this.renderTarget2.setSize( width, height );

		for ( var i = 0; i < this.passes.length; i ++ ) {

			this.passes[ i ].setSize( width, height );

		}

	}

} );


THREE.Pass = function () {

	// if set to true, the pass is processed by the composer
	this.enabled = true;

	// if set to true, the pass indicates to swap read and write buffer after rendering
	this.needsSwap = true;

	// if set to true, the pass clears its buffer before rendering
	this.clear = false;

	// if set to true, the result of the pass is rendered to screen. This is set automatically by EffectComposer.
	this.renderToScreen = false;

};

Object.assign( THREE.Pass.prototype, {

	setSize: function ( width, height ) {},

	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {

		console.error( 'THREE.Pass: .render() must be implemented in derived pass.' );

	}

} );

// Helper for passes that need to fill the viewport with a single quad.
THREE.Pass.FullScreenQuad = ( function () {

	var camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
	var geometry = new THREE.PlaneBufferGeometry( 2, 2 );

	var FullScreenQuad = function ( material ) {

		this._mesh = new THREE.Mesh( geometry, material );

	};

	Object.defineProperty( FullScreenQuad.prototype, 'material', {

		get: function () {

			return this._mesh.material;

		},

		set: function ( value ) {

			this._mesh.material = value;

		}

	} );

	Object.assign( FullScreenQuad.prototype, {

		render: function ( renderer ) {

			renderer.render( this._mesh, camera );

		}

	} );

	return FullScreenQuad;

} )();
/**
 * @author alteredq / http://alteredqualia.com/
 */

THREE.RenderPass = function ( scene, camera, overrideMaterial, clearColor, clearAlpha ) {

	THREE.Pass.call( this );

	this.scene = scene;
	this.camera = camera;

	this.overrideMaterial = overrideMaterial;

	this.clearColor = clearColor;
	this.clearAlpha = ( clearAlpha !== undefined ) ? clearAlpha : 0;

	this.clear = true;
	this.clearDepth = false;
	this.needsSwap = false;

};

THREE.RenderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {

	constructor: THREE.RenderPass,

	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {

		var oldAutoClear = renderer.autoClear;
		renderer.autoClear = false;

		this.scene.overrideMaterial = this.overrideMaterial;

		var oldClearColor, oldClearAlpha;

		if ( this.clearColor ) {

			oldClearColor = renderer.getClearColor().getHex();
			oldClearAlpha = renderer.getClearAlpha();

			renderer.setClearColor( this.clearColor, this.clearAlpha );

		}

		if ( this.clearDepth ) {

			renderer.clearDepth();

		}

		renderer.setRenderTarget( this.renderToScreen ? null : readBuffer );

		// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
		if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
		renderer.render( this.scene, this.camera );

		if ( this.clearColor ) {

			renderer.setClearColor( oldClearColor, oldClearAlpha );

		}

		this.scene.overrideMaterial = null;
		renderer.autoClear = oldAutoClear;

	}

} );
/**
 * @author alteredq / http://alteredqualia.com/
 *
 * Full-screen textured quad shader
 */

THREE.CopyShader = {

	uniforms: {

		"tDiffuse": { value: null },
		"opacity":  { value: 1.0 }

	},

	vertexShader: [

		"varying vec2 vUv;",

		"void main() {",

			"vUv = uv;",
			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

		"}"

	].join( "\n" ),

	fragmentShader: [

		"uniform float opacity;",

		"uniform sampler2D tDiffuse;",

		"varying vec2 vUv;",

		"void main() {",

			"vec4 texel = texture2D( tDiffuse, vUv );",
			"gl_FragColor = opacity * texel;",

		"}"

	].join( "\n" )

};
/**
 * @author alteredq / http://alteredqualia.com/
 */

THREE.ShaderPass = function ( shader, textureID ) {

	THREE.Pass.call( this );

	this.textureID = ( textureID !== undefined ) ? textureID : "tDiffuse";

	if ( shader instanceof THREE.ShaderMaterial ) {

		this.uniforms = shader.uniforms;

		this.material = shader;

	} else if ( shader ) {

		this.uniforms = THREE.UniformsUtils.clone( shader.uniforms );

		this.material = new THREE.ShaderMaterial( {

			defines: Object.assign( {}, shader.defines ),
			uniforms: this.uniforms,
			vertexShader: shader.vertexShader,
			fragmentShader: shader.fragmentShader

		} );

	}

	this.fsQuad = new THREE.Pass.FullScreenQuad( this.material );
};

THREE.ShaderPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {

	constructor: THREE.ShaderPass,

	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {

		if ( this.uniforms[ this.textureID ] ) {

			this.uniforms[ this.textureID ].value = readBuffer.texture;

		}

		this.fsQuad.material = this.material;

		if ( this.renderToScreen ) {

			renderer.setRenderTarget( null );
			this.fsQuad.render( renderer );

		} else {

			renderer.setRenderTarget( writeBuffer );
			// TODO: Avoid using autoClear properties, see https://github.com/mrdoob/three.js/pull/15571#issuecomment-465669600
			if ( this.clear ) renderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );
			this.fsQuad.render( renderer );

		}

	}

} );
/**
 * @author bhouston / http://clara.io/
 *
 * Luminosity
 * http://en.wikipedia.org/wiki/Luminosity
 */

THREE.LuminosityHighPassShader = {

  shaderID: "luminosityHighPass",

	uniforms: {

		"tDiffuse": { value: null },
		"luminosityThreshold": { value: 1.0 },
		"smoothWidth": { value: 1.0 },
		"defaultColor": { value: new THREE.Color( 0x000000 ) },
		"defaultOpacity":  { value: 0.0 }

	},

	vertexShader: [

		"varying vec2 vUv;",

		"void main() {",

			"vUv = uv;",

			"gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",

		"}"

	].join("\n"),

	fragmentShader: [

		"uniform sampler2D tDiffuse;",
		"uniform vec3 defaultColor;",
		"uniform float defaultOpacity;",
		"uniform float luminosityThreshold;",
		"uniform float smoothWidth;",

		"varying vec2 vUv;",

		"void main() {",

			"vec4 texel = texture2D( tDiffuse, vUv );",

			"vec3 luma = vec3( 0.299, 0.587, 0.114 );",

			"float v = dot( texel.xyz, luma );",

			"vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );",

			"float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );",

			"gl_FragColor = mix( outputColor, texel, alpha );",

		"}"

	].join("\n")

};
// https://github.com/mrdoob/three.js/issues/14104

/**
 * @author spidersharma / http://eduperiment.com/
 *
 * Inspired from Unreal Engine
 * https://docs.unrealengine.com/latest/INT/Engine/Rendering/PostProcessEffects/Bloom/
 */
THREE.UnrealBloomPass = function ( resolution, strength, radius, threshold ) {

	THREE.Pass.call( this );

	this.strength = ( strength !== undefined ) ? strength : 1;
	this.radius = radius;
	this.threshold = threshold;
	this.resolution = ( resolution !== undefined ) ? new THREE.Vector2( resolution.x, resolution.y ) : new THREE.Vector2( 256, 256 );

	// create color only once here, reuse it later inside the render function
	this.clearColor = new THREE.Color( 0, 0, 0 );

	// render targets
	var pars = { minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter, format: THREE.RGBAFormat };
	this.renderTargetsHorizontal = [];
	this.renderTargetsVertical = [];
	this.nMips = 5;
	var resx = Math.round( this.resolution.x / 2 );
	var resy = Math.round( this.resolution.y / 2 );

	this.renderTargetBright = new THREE.WebGLRenderTarget( resx, resy, pars );
	this.renderTargetBright.texture.name = "UnrealBloomPass.bright";
	this.renderTargetBright.texture.generateMipmaps = false;

	for ( var i = 0; i < this.nMips; i ++ ) {

		var renderTargetHorizonal = new THREE.WebGLRenderTarget( resx, resy, pars );

		renderTargetHorizonal.texture.name = "UnrealBloomPass.h" + i;
		renderTargetHorizonal.texture.generateMipmaps = false;

		this.renderTargetsHorizontal.push( renderTargetHorizonal );

		var renderTargetVertical = new THREE.WebGLRenderTarget( resx, resy, pars );

		renderTargetVertical.texture.name = "UnrealBloomPass.v" + i;
		renderTargetVertical.texture.generateMipmaps = false;

		this.renderTargetsVertical.push( renderTargetVertical );

		resx = Math.round( resx / 2 );

		resy = Math.round( resy / 2 );

	}

	// luminosity high pass material

	if ( THREE.LuminosityHighPassShader === undefined )
		console.error( "THREE.UnrealBloomPass relies on THREE.LuminosityHighPassShader" );

	var highPassShader = THREE.LuminosityHighPassShader;
	this.highPassUniforms = THREE.UniformsUtils.clone( highPassShader.uniforms );

	this.highPassUniforms[ "luminosityThreshold" ].value = threshold;
	this.highPassUniforms[ "smoothWidth" ].value = 0.01;

	this.materialHighPassFilter = new THREE.ShaderMaterial( {
		uniforms: this.highPassUniforms,
		vertexShader: highPassShader.vertexShader,
		fragmentShader: highPassShader.fragmentShader,
		defines: {}
	} );

	// Gaussian Blur Materials
	this.separableBlurMaterials = [];
	var kernelSizeArray = [ 3, 5, 7, 9, 11 ];
	var resx = Math.round( this.resolution.x / 2 );
	var resy = Math.round( this.resolution.y / 2 );

	for ( var i = 0; i < this.nMips; i ++ ) {

		this.separableBlurMaterials.push( this.getSeperableBlurMaterial( kernelSizeArray[ i ] ) );

		this.separableBlurMaterials[ i ].uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );

		resx = Math.round( resx / 2 );

		resy = Math.round( resy / 2 );

	}

	// Composite material
	this.compositeMaterial = this.getCompositeMaterial( this.nMips );
	this.compositeMaterial.uniforms[ "blurTexture1" ].value = this.renderTargetsVertical[ 0 ].texture;
	this.compositeMaterial.uniforms[ "blurTexture2" ].value = this.renderTargetsVertical[ 1 ].texture;
	this.compositeMaterial.uniforms[ "blurTexture3" ].value = this.renderTargetsVertical[ 2 ].texture;
	this.compositeMaterial.uniforms[ "blurTexture4" ].value = this.renderTargetsVertical[ 3 ].texture;
	this.compositeMaterial.uniforms[ "blurTexture5" ].value = this.renderTargetsVertical[ 4 ].texture;
	this.compositeMaterial.uniforms[ "bloomStrength" ].value = strength;
	this.compositeMaterial.uniforms[ "bloomRadius" ].value = 0.1;
	this.compositeMaterial.needsUpdate = true;

	var bloomFactors = [ 1.0, 0.8, 0.6, 0.4, 0.2 ];
	this.compositeMaterial.uniforms[ "bloomFactors" ].value = bloomFactors;
	this.bloomTintColors = [ new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ),
							 new THREE.Vector3( 1, 1, 1 ), new THREE.Vector3( 1, 1, 1 ) ];
	this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors;

	// copy material
	if ( THREE.CopyShader === undefined ) {

		console.error( "THREE.BloomPass relies on THREE.CopyShader" );

	}

	var copyShader = THREE.CopyShader;

	this.copyUniforms = THREE.UniformsUtils.clone( copyShader.uniforms );
	this.copyUniforms[ "opacity" ].value = 1.0;

	this.materialCopy = new THREE.ShaderMaterial( {
		uniforms: this.copyUniforms,
		vertexShader: copyShader.vertexShader,
		fragmentShader: copyShader.fragmentShader,
		blending: THREE.AdditiveBlending,
		depthTest: false,
		depthWrite: false,
		transparent: true
	} );

	this.enabled = true;
	this.needsSwap = false;

	this.oldClearColor = new THREE.Color();
	this.oldClearAlpha = 1;

	this.basic = new THREE.MeshBasicMaterial();

	this.fsQuad = new THREE.Pass.FullScreenQuad( null );

};

THREE.UnrealBloomPass.prototype = Object.assign( Object.create( THREE.Pass.prototype ), {

	constructor: THREE.UnrealBloomPass,

	dispose: function () {

		for ( var i = 0; i < this.renderTargetsHorizontal.length; i ++ ) {

			this.renderTargetsHorizontal[ i ].dispose();

		}

		for ( var i = 0; i < this.renderTargetsVertical.length; i ++ ) {

			this.renderTargetsVertical[ i ].dispose();

		}

		this.renderTargetBright.dispose();

	},

	setSize: function ( width, height ) {

		var resx = Math.round( width / 2 );
		var resy = Math.round( height / 2 );

		this.renderTargetBright.setSize( resx, resy );

		for ( var i = 0; i < this.nMips; i ++ ) {

			this.renderTargetsHorizontal[ i ].setSize( resx, resy );
			this.renderTargetsVertical[ i ].setSize( resx, resy );

			this.separableBlurMaterials[ i ].uniforms[ "texSize" ].value = new THREE.Vector2( resx, resy );

			resx = Math.round( resx / 2 );
			resy = Math.round( resy / 2 );

		}

	},

	render: function ( renderer, writeBuffer, readBuffer, deltaTime, maskActive ) {

		this.oldClearColor.copy( renderer.getClearColor() );
		this.oldClearAlpha = renderer.getClearAlpha();
		var oldAutoClear = renderer.autoClear;
		renderer.autoClear = false;

		renderer.setClearColor( this.clearColor, 0 );

		if ( maskActive ) renderer.context.disable( renderer.context.STENCIL_TEST );

		// Render input to screen

		if ( this.renderToScreen ) {

			this.fsQuad.material = this.basic;
			this.basic.map = readBuffer.texture;

			renderer.setRenderTarget( null );
			renderer.clear();
			this.fsQuad.render( renderer );

		}

		// 1. Extract Bright Areas

		this.highPassUniforms[ "tDiffuse" ].value = readBuffer.texture;
		this.highPassUniforms[ "luminosityThreshold" ].value = this.threshold;
		this.fsQuad.material = this.materialHighPassFilter;

		renderer.setRenderTarget( this.renderTargetBright );
		renderer.clear();
		this.fsQuad.render( renderer );

		// 2. Blur All the mips progressively

		var inputRenderTarget = this.renderTargetBright;

		for ( var i = 0; i < this.nMips; i ++ ) {

			this.fsQuad.material = this.separableBlurMaterials[ i ];

			this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = inputRenderTarget.texture;
			this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionX;
			renderer.setRenderTarget( this.renderTargetsHorizontal[ i ] );
			renderer.clear();
			this.fsQuad.render( renderer );

			this.separableBlurMaterials[ i ].uniforms[ "colorTexture" ].value = this.renderTargetsHorizontal[ i ].texture;
			this.separableBlurMaterials[ i ].uniforms[ "direction" ].value = THREE.UnrealBloomPass.BlurDirectionY;
			renderer.setRenderTarget( this.renderTargetsVertical[ i ] );
			renderer.clear();
			this.fsQuad.render( renderer );

			inputRenderTarget = this.renderTargetsVertical[ i ];

		}

		// Composite All the mips

		this.fsQuad.material = this.compositeMaterial;
		this.compositeMaterial.uniforms[ "bloomStrength" ].value = this.strength;
		this.compositeMaterial.uniforms[ "bloomRadius" ].value = this.radius;
		this.compositeMaterial.uniforms[ "bloomTintColors" ].value = this.bloomTintColors;

		renderer.setRenderTarget( this.renderTargetsHorizontal[ 0 ] );
		renderer.clear();
		this.fsQuad.render( renderer );

		// Blend it additively over the input texture

		this.fsQuad.material = this.materialCopy;
		this.copyUniforms[ "tDiffuse" ].value = this.renderTargetsHorizontal[ 0 ].texture;

		if ( maskActive ) renderer.context.enable( renderer.context.STENCIL_TEST );


		if ( this.renderToScreen ) {

			renderer.setRenderTarget( null );
			this.fsQuad.render( renderer );

		} else {

			renderer.setRenderTarget( readBuffer );
			this.fsQuad.render( renderer );

		}

		// Restore renderer settings

		renderer.setClearColor( this.oldClearColor, this.oldClearAlpha );
		renderer.autoClear = oldAutoClear;

	},

	getSeperableBlurMaterial: function ( kernelRadius ) {

		return new THREE.ShaderMaterial( {

			defines: {
				"KERNEL_RADIUS": kernelRadius,
				"SIGMA": kernelRadius
			},

			uniforms: {
				"colorTexture": { value: null },
				"texSize": { value: new THREE.Vector2( 0.5, 0.5 ) },
				"direction": { value: new THREE.Vector2( 0.5, 0.5 ) }
			},

			vertexShader:
				"varying vec2 vUv;\n\
				void main() {\n\
					vUv = uv;\n\
					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
				}",

			fragmentShader:
				"#include <common>\
				varying vec2 vUv;\n\
				uniform sampler2D colorTexture;\n\
				uniform vec2 texSize;\
				uniform vec2 direction;\
				\
				float gaussianPdf(in float x, in float sigma) {\
					return 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\
				}\
				void main() {\n\
					vec2 invSize = 1.0 / texSize;\
					float fSigma = float(SIGMA);\
					float weightSum = gaussianPdf(0.0, fSigma);\
					float alphaSum = 0.0;\
					vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\
					for( int i = 1; i < KERNEL_RADIUS; i ++ ) {\
						float x = float(i);\
						float w = gaussianPdf(x, fSigma);\
						vec2 uvOffset = direction * invSize * x;\
						vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\
						vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\
						diffuseSum += (sample1.rgb + sample2.rgb) * w;\
						alphaSum += (sample1.a + sample2.a) * w;\
						weightSum += 2.0 * w;\
					}\
					gl_FragColor = vec4(diffuseSum/weightSum, alphaSum/weightSum);\n\
				}"
		} );

	},

	getCompositeMaterial: function ( nMips ) {

		return new THREE.ShaderMaterial( {

			defines: {
				"NUM_MIPS": nMips
			},

			uniforms: {
				"blurTexture1": { value: null },
				"blurTexture2": { value: null },
				"blurTexture3": { value: null },
				"blurTexture4": { value: null },
				"blurTexture5": { value: null },
				"dirtTexture": { value: null },
				"bloomStrength": { value: 1.0 },
				"bloomFactors": { value: null },
				"bloomTintColors": { value: null },
				"bloomRadius": { value: 0.0 }
			},

			vertexShader:
				"varying vec2 vUv;\n\
				void main() {\n\
					vUv = uv;\n\
					gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\
				}",

			fragmentShader:
				"varying vec2 vUv;\
				uniform sampler2D blurTexture1;\
				uniform sampler2D blurTexture2;\
				uniform sampler2D blurTexture3;\
				uniform sampler2D blurTexture4;\
				uniform sampler2D blurTexture5;\
				uniform sampler2D dirtTexture;\
				uniform float bloomStrength;\
				uniform float bloomRadius;\
				uniform float bloomFactors[NUM_MIPS];\
				uniform vec3 bloomTintColors[NUM_MIPS];\
				\
				float lerpBloomFactor(const in float factor) { \
					float mirrorFactor = 1.2 - factor;\
					return mix(factor, mirrorFactor, bloomRadius);\
				}\
				\
				void main() {\
					gl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \
													 lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \
													 lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \
													 lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \
													 lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\
				}"
		} );

	}

} );

THREE.UnrealBloomPass.BlurDirectionX = new THREE.Vector2( 1.0, 0.0 );
THREE.UnrealBloomPass.BlurDirectionY = new THREE.Vector2( 0.0, 1.0 );/**
 * https://github.com/spite/THREE.MeshLine
 * 修改备注：增加uv动画功能
 */
;(function() {

"use strict";

var root = this

var has_require = typeof require !== 'undefined'

var THREE = root.THREE || has_require && require('three')
if( !THREE )
	throw new Error( 'MeshLine requires three.js' )

function MeshLine() {

	this.positions = [];

	this.previous = [];
	this.next = [];
	this.side = [];
	this.width = [];
	this.indices_array = [];
	this.uvs = [];
	this.counters = [];
	this.geometry = new THREE.BufferGeometry();

	this.widthCallback = null;

	// Used to raycast
	this.matrixWorld = new THREE.Matrix4();
}

MeshLine.prototype.setMatrixWorld = function(matrixWorld) {
	this.matrixWorld = matrixWorld;
}


MeshLine.prototype.setGeometry = function( g, c ) {
	
	this.widthCallback = c;

	this.positions = [];
	this.counters = [];
	// g.computeBoundingBox();
	// g.computeBoundingSphere();

	// set the normals
	// g.computeVertexNormals();
	if( g instanceof THREE.Geometry ) {
		for( var j = 0; j < g.vertices.length; j++ ) {
			var v = g.vertices[ j ];
			var c = j/g.vertices.length;
			this.positions.push( v.x, v.y, v.z );
			this.positions.push( v.x, v.y, v.z );
			this.counters.push(c);
			this.counters.push(c);
		}
	}

	if( g instanceof THREE.BufferGeometry ) {
		// read attribute positions ?
	}

	if( g instanceof Float32Array || g instanceof Array ) {
		for( var j = 0; j < g.length; j += 3 ) {
			var c = j/g.length;
			this.positions.push( g[ j ], g[ j + 1 ], g[ j + 2 ] );
			this.positions.push( g[ j ], g[ j + 1 ], g[ j + 2 ] );
			this.counters.push(c);
			this.counters.push(c);
		}
	}

	this.process();

}

MeshLine.prototype.raycast = ( function () {

	var inverseMatrix = new THREE.Matrix4();
	var ray = new THREE.Ray();
	var sphere = new THREE.Sphere();

	return function raycast( raycaster, intersects ) {

		var precision = raycaster.linePrecision;
		var precisionSq = precision * precision;
		var interRay = new THREE.Vector3();

		var geometry = this.geometry;

		if ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();

		// Checking boundingSphere distance to ray

		sphere.copy( geometry.boundingSphere );
		sphere.applyMatrix4( this.matrixWorld );

		if ( raycaster.ray.intersectSphere( sphere, interRay ) === false ) {

			return;

		}

		inverseMatrix.getInverse( this.matrixWorld );
		ray.copy( raycaster.ray ).applyMatrix4( inverseMatrix );

		var vStart = new THREE.Vector3();
		var vEnd = new THREE.Vector3();
		var interSegment = new THREE.Vector3();
		var step = this instanceof THREE.LineSegments ? 2 : 1;

		if ( geometry instanceof THREE.BufferGeometry ) {

			var index = geometry.index;
			var attributes = geometry.attributes;

			if ( index !== null ) {

				var indices = index.array;
				var positions = attributes.position.array;

				for ( var i = 0, l = indices.length - 1; i < l; i += step ) {

					var a = indices[ i ];
					var b = indices[ i + 1 ];

					vStart.fromArray( positions, a * 3 );
					vEnd.fromArray( positions, b * 3 );

					var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );

					if ( distSq > precisionSq ) continue;

					interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation

					var distance = raycaster.ray.origin.distanceTo( interRay );

					if ( distance < raycaster.near || distance > raycaster.far ) continue;

					intersects.push( {

						distance: distance,
						// What do we want? intersection point on the ray or on the segment??
						// point: raycaster.ray.at( distance ),
						point: interSegment.clone().applyMatrix4( this.matrixWorld ),
						index: i,
						face: null,
						faceIndex: null,
						object: this

					} );

				}

			} else {

				var positions = attributes.position.array;

				for ( var i = 0, l = positions.length / 3 - 1; i < l; i += step ) {

					vStart.fromArray( positions, 3 * i );
					vEnd.fromArray( positions, 3 * i + 3 );

					var distSq = ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );

					if ( distSq > precisionSq ) continue;

					interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation

					var distance = raycaster.ray.origin.distanceTo( interRay );

					if ( distance < raycaster.near || distance > raycaster.far ) continue;

					intersects.push( {

						distance: distance,
						// What do we want? intersection point on the ray or on the segment??
						// point: raycaster.ray.at( distance ),
						point: interSegment.clone().applyMatrix4( this.matrixWorld ),
						index: i,
						face: null,
						faceIndex: null,
						object: this

					} );

				}

			}

		} else if ( geometry instanceof THREE.Geometry ) {

			var vertices = geometry.vertices;
			var nbVertices = vertices.length;

			for ( var i = 0; i < nbVertices - 1; i += step ) {

				var distSq = ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );

				if ( distSq > precisionSq ) continue;

				interRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation

				var distance = raycaster.ray.origin.distanceTo( interRay );

				if ( distance < raycaster.near || distance > raycaster.far ) continue;

				intersects.push( {

					distance: distance,
					// What do we want? intersection point on the ray or on the segment??
					// point: raycaster.ray.at( distance ),
					point: interSegment.clone().applyMatrix4( this.matrixWorld ),
					index: i,
					face: null,
					faceIndex: null,
					object: this

				} );

			}

		}

	};

}() );


MeshLine.prototype.compareV3 = function( a, b ) {

	var aa = a * 6;
	var ab = b * 6;
	return ( this.positions[ aa ] === this.positions[ ab ] ) && ( this.positions[ aa + 1 ] === this.positions[ ab + 1 ] ) && ( this.positions[ aa + 2 ] === this.positions[ ab + 2 ] );

}

MeshLine.prototype.copyV3 = function( a ) {

	var aa = a * 6;
	return [ this.positions[ aa ], this.positions[ aa + 1 ], this.positions[ aa + 2 ] ];

}

MeshLine.prototype.process = function() {

	var l = this.positions.length / 6;

	this.previous = [];
	this.next = [];
	this.side = [];
	this.width = [];
	this.indices_array = [];
	this.uvs = [];

	for( var j = 0; j < l; j++ ) {
		this.side.push( 1 );
		this.side.push( -1 );
	}

	var w;
	for( var j = 0; j < l; j++ ) {
		if( this.widthCallback ) w = this.widthCallback( j / ( l -1 ) );
		else w = 1;
		this.width.push( w );
		this.width.push( w );
	}

	for( var j = 0; j < l; j++ ) {
		this.uvs.push( j / ( l - 1 ), 0 );
		this.uvs.push( j / ( l - 1 ), 1 );
	}

	var v;

	if( this.compareV3( 0, l - 1 ) ){
		v = this.copyV3( l - 2 );
	} else {
		v = this.copyV3( 0 );
	}
	this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] );
	this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] );
	for( var j = 0; j < l - 1; j++ ) {
		v = this.copyV3( j );
		this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] );
		this.previous.push( v[ 0 ], v[ 1 ], v[ 2 ] );
	}

	for( var j = 1; j < l; j++ ) {
		v = this.copyV3( j );
		this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] );
		this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] );
	}

	if( this.compareV3( l - 1, 0 ) ){
		v = this.copyV3( 1 );
	} else {
		v = this.copyV3( l - 1 );
	}
	this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] );
	this.next.push( v[ 0 ], v[ 1 ], v[ 2 ] );

	for( var j = 0; j < l - 1; j++ ) {
		var n = j * 2;
		this.indices_array.push( n, n + 1, n + 2 );
		this.indices_array.push( n + 2, n + 1, n + 3 );
	}

	if (!this.attributes) {
		this.attributes = {
			position: new THREE.BufferAttribute( new Float32Array( this.positions ), 3 ),
			previous: new THREE.BufferAttribute( new Float32Array( this.previous ), 3 ),
			next: new THREE.BufferAttribute( new Float32Array( this.next ), 3 ),
			side: new THREE.BufferAttribute( new Float32Array( this.side ), 1 ),
			width: new THREE.BufferAttribute( new Float32Array( this.width ), 1 ),
			uv: new THREE.BufferAttribute( new Float32Array( this.uvs ), 2 ),
			index: new THREE.BufferAttribute( new Uint16Array( this.indices_array ), 1 ),
			counters: new THREE.BufferAttribute( new Float32Array( this.counters ), 1 )
		}
	} else {
		this.attributes.position.copyArray(new Float32Array(this.positions));
		this.attributes.position.needsUpdate = true;
		this.attributes.previous.copyArray(new Float32Array(this.previous));
		this.attributes.previous.needsUpdate = true;
		this.attributes.next.copyArray(new Float32Array(this.next));
		this.attributes.next.needsUpdate = true;
		this.attributes.side.copyArray(new Float32Array(this.side));
		this.attributes.side.needsUpdate = true;
		this.attributes.width.copyArray(new Float32Array(this.width));
		this.attributes.width.needsUpdate = true;
		this.attributes.uv.copyArray(new Float32Array(this.uvs));
		this.attributes.uv.needsUpdate = true;
		this.attributes.index.copyArray(new Uint16Array(this.indices_array));
		this.attributes.index.needsUpdate = true;
	}

	// this.geometry.setAttribute( 'position', this.attributes.position );
	// this.geometry.setAttribute( 'previous', this.attributes.previous );
	// this.geometry.setAttribute( 'next', this.attributes.next );
	// this.geometry.setAttribute( 'side', this.attributes.side );
	// this.geometry.setAttribute( 'width', this.attributes.width );
	// this.geometry.setAttribute( 'uv', this.attributes.uv );
	// this.geometry.setAttribute( 'counters', this.attributes.counters );

	this.geometry.addAttribute( 'position', this.attributes.position );
	this.geometry.addAttribute( 'previous', this.attributes.previous );
	this.geometry.addAttribute( 'next', this.attributes.next );
	this.geometry.addAttribute( 'side', this.attributes.side );
	this.geometry.addAttribute( 'width', this.attributes.width );
	this.geometry.addAttribute( 'uv', this.attributes.uv );
	this.geometry.addAttribute( 'counters', this.attributes.counters );

	this.geometry.setIndex( this.attributes.index );

}

function memcpy (src, srcOffset, dst, dstOffset, length) {
	var i

	src = src.subarray || src.slice ? src : src.buffer
	dst = dst.subarray || dst.slice ? dst : dst.buffer

	src = srcOffset ? src.subarray ?
	src.subarray(srcOffset, length && srcOffset + length) :
	src.slice(srcOffset, length && srcOffset + length) : src

	if (dst.set) {
		dst.set(src, dstOffset)
	} else {
		for (i=0; i<src.length; i++) {
			dst[i + dstOffset] = src[i]
		}
	}

	return dst
}

/**
 * Fast method to advance the line by one position.  The oldest position is removed.
 * @param position
 */
MeshLine.prototype.advance = function(position) {

	var positions = this.attributes.position.array;
	var previous = this.attributes.previous.array;
	var next = this.attributes.next.array;
	var l = positions.length;

	// PREVIOUS
	memcpy( positions, 0, previous, 0, l );

	// POSITIONS
	memcpy( positions, 6, positions, 0, l - 6 );

	positions[l - 6] = position.x;
	positions[l - 5] = position.y;
	positions[l - 4] = position.z;
	positions[l - 3] = position.x;
	positions[l - 2] = position.y;
	positions[l - 1] = position.z;

	// NEXT
	memcpy( positions, 6, next, 0, l - 6 );

	next[l - 6]  = position.x;
	next[l - 5]  = position.y;
	next[l - 4]  = position.z;
	next[l - 3]  = position.x;
	next[l - 2]  = position.y;
	next[l - 1]  = position.z;

	this.attributes.position.needsUpdate = true;
	this.attributes.previous.needsUpdate = true;
	this.attributes.next.needsUpdate = true;

};

THREE.ShaderChunk[ 'meshline_vert' ] = [
	'',
	THREE.ShaderChunk.logdepthbuf_pars_vertex,
	THREE.ShaderChunk.fog_pars_vertex,
	'',
	'attribute vec3 previous;',
	'attribute vec3 next;',
	'attribute float side;',
	'attribute float width;',
	'attribute float counters;',
	'',
	'uniform vec2 resolution;',
	'uniform float lineWidth;',
	'uniform vec3 color;',
	'uniform float opacity;',
	'uniform float near;',
	'uniform float far;',
	'uniform float sizeAttenuation;',
	'uniform vec2 offset;',
	'',
	'varying vec2 vUV;',
	'varying vec4 vColor;',
	'varying float vCounters;',
	'',
	'vec2 fix( vec4 i, float aspect ) {',
	'',
	'    vec2 res = i.xy / i.w;',
	'    res.x *= aspect;',
	'	 vCounters = counters;',
	'    return res;',
	'',
	'}',
	'',
	'void main() {',
	'',
	'    float aspect = resolution.x / resolution.y;',
	'    float pixelWidthRatio = 1. / (resolution.x * projectionMatrix[0][0]);',
	'',
	'    vColor = vec4( color, opacity );',
	'    vUV = uv + offset;',
	'',
	'    mat4 m = projectionMatrix * modelViewMatrix;',
	'    vec4 finalPosition = m * vec4( position, 1.0 );',
	'    vec4 prevPos = m * vec4( previous, 1.0 );',
	'    vec4 nextPos = m * vec4( next, 1.0 );',
	'',
	'    vec2 currentP = fix( finalPosition, aspect );',
	'    vec2 prevP = fix( prevPos, aspect );',
	'    vec2 nextP = fix( nextPos, aspect );',
	'',
	'    float pixelWidth = finalPosition.w * pixelWidthRatio;',
	'    float w = 1.8 * pixelWidth * lineWidth * width;',
	'',
	'    if( sizeAttenuation == 1. ) {',
	'        w = 1.8 * lineWidth * width;',
	'    }',
	'',
	'    vec2 dir;',
	'    if( nextP == currentP ) dir = normalize( currentP - prevP );',
	'    else if( prevP == currentP ) dir = normalize( nextP - currentP );',
	'    else {',
	'        vec2 dir1 = normalize( currentP - prevP );',
	'        vec2 dir2 = normalize( nextP - currentP );',
	'        dir = normalize( dir1 + dir2 );',
	'',
	'        vec2 perp = vec2( -dir1.y, dir1.x );',
	'        vec2 miter = vec2( -dir.y, dir.x );',
	'        //w = clamp( w / dot( miter, perp ), 0., 4. * lineWidth * width );',
	'',
	'    }',
	'',
	'    //vec2 normal = ( cross( vec3( dir, 0. ), vec3( 0., 0., 1. ) ) ).xy;',
	'    vec2 normal = vec2( -dir.y, dir.x );',
	'    normal.x /= aspect;',
	'    normal *= .5 * w;',
	'',
	'    vec4 offset = vec4( normal * side, 0.0, 1.0 );',
	'    finalPosition.xy += offset.xy;',
	'',
	'    gl_Position = finalPosition;',
	'',
	THREE.ShaderChunk.logdepthbuf_vertex,
  THREE.ShaderChunk.fog_vertex && '    vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );',
  THREE.ShaderChunk.fog_vertex,
	'}'
].join( '\r\n' );

THREE.ShaderChunk[ 'meshline_frag' ] = [
	'',
	THREE.ShaderChunk.fog_pars_fragment,
	THREE.ShaderChunk.logdepthbuf_pars_fragment,
	'',
	'uniform sampler2D map;',
	'uniform sampler2D alphaMap;',
	'uniform float useMap;',
	'uniform float useAlphaMap;',
	'uniform float useDash;',
	'uniform float dashArray;',
	'uniform float dashOffset;',
	'uniform float dashRatio;',
	'uniform float visibility;',
	'uniform float alphaTest;',
	'uniform vec2 repeat;',
	'',
	'varying vec2 vUV;',
	'varying vec4 vColor;',
	'varying float vCounters;',
	'',
	'void main() {',
	'',
	THREE.ShaderChunk.logdepthbuf_fragment,
	'',
	'    vec4 c = vColor;',
	'    if( useMap == 1. ) c *= texture2D( map, vUV * repeat );',
	'    if( useAlphaMap == 1. ) c.a *= texture2D( alphaMap, vUV * repeat ).a;',
	'    if( c.a < alphaTest ) discard;',
	'    if( useDash == 1. ){',
	'        c.a *= ceil(mod(vCounters + dashOffset, dashArray) - (dashArray * dashRatio));',
	'    }',
	'    gl_FragColor = c;',
	'    gl_FragColor.a *= step(vCounters, visibility);',
	'',
	THREE.ShaderChunk.fog_fragment,
	'}'
].join( '\r\n' );

function MeshLineMaterial( parameters ) {

	THREE.ShaderMaterial.call( this, {
		uniforms: Object.assign({},
			THREE.UniformsLib.fog,
			{
				lineWidth: { value: 1 },
				map: { value: null },
				useMap: { value: 0 },
				alphaMap: { value: null },
				useAlphaMap: { value: 0 },
				color: { value: new THREE.Color( 0xffffff ) },
				opacity: { value: 1 },
				resolution: { value: new THREE.Vector2( 1, 1 ) },
				sizeAttenuation: { value: 1 },
				near: { value: 1 },
				far: { value: 1 },
				dashArray: { value: 0 },
				dashOffset: { value: 0 },
				dashRatio: { value: 0.5 },
				useDash: { value: 0 },
				visibility: {value: 1 },
				alphaTest: {value: 0 },
				repeat: { value: new THREE.Vector2( 1, 1 ) },
				offset: { value: new THREE.Vector2( 1, 1 ) },
			}
		),

		vertexShader: THREE.ShaderChunk.meshline_vert,

		fragmentShader: THREE.ShaderChunk.meshline_frag,

	} );

	this.type = 'MeshLineMaterial';

	Object.defineProperties( this, {
		lineWidth: {
			enumerable: true,
			get: function () {
				return this.uniforms.lineWidth.value;
			},
			set: function ( value ) {
				this.uniforms.lineWidth.value = value;
			}
		},
		map: {
			enumerable: true,
			get: function () {
				return this.uniforms.map.value;
			},
			set: function ( value ) {
				this.uniforms.map.value = value;
			}
		},
		useMap: {
			enumerable: true,
			get: function () {
				return this.uniforms.useMap.value;
			},
			set: function ( value ) {
				this.uniforms.useMap.value = value;
			}
		},
		alphaMap: {
			enumerable: true,
			get: function () {
				return this.uniforms.alphaMap.value;
			},
			set: function ( value ) {
				this.uniforms.alphaMap.value = value;
			}
		},
		useAlphaMap: {
			enumerable: true,
			get: function () {
				return this.uniforms.useAlphaMap.value;
			},
			set: function ( value ) {
				this.uniforms.useAlphaMap.value = value;
			}
		},
		color: {
			enumerable: true,
			get: function () {
				return this.uniforms.color.value;
			},
			set: function ( value ) {
				this.uniforms.color.value = value;
			}
		},
		opacity: {
			enumerable: true,
			get: function () {
				return this.uniforms.opacity.value;
			},
			set: function ( value ) {
				this.uniforms.opacity.value = value;
			}
		},
		resolution: {
			enumerable: true,
			get: function () {
				return this.uniforms.resolution.value;
			},
			set: function ( value ) {
				this.uniforms.resolution.value.copy( value );
			}
		},
		sizeAttenuation: {
			enumerable: true,
			get: function () {
				return this.uniforms.sizeAttenuation.value;
			},
			set: function ( value ) {
				this.uniforms.sizeAttenuation.value = value;
			}
		},
		near: {
			enumerable: true,
			get: function () {
				return this.uniforms.near.value;
			},
			set: function ( value ) {
				this.uniforms.near.value = value;
			}
		},
		far: {
			enumerable: true,
			get: function () {
				return this.uniforms.far.value;
			},
			set: function ( value ) {
				this.uniforms.far.value = value;
			}
		},
		dashArray: {
			enumerable: true,
			get: function () {
				return this.uniforms.dashArray.value;
			},
			set: function ( value ) {
				this.uniforms.dashArray.value = value;
				this.useDash = ( value !== 0 ) ? 1 : 0
			}
		},
		dashOffset: {
			enumerable: true,
			get: function () {
				return this.uniforms.dashOffset.value;
			},
			set: function ( value ) {
				this.uniforms.dashOffset.value = value;
			}
		},
		dashRatio: {
			enumerable: true,
			get: function () {
				return this.uniforms.dashRatio.value;
			},
			set: function ( value ) {
				this.uniforms.dashRatio.value = value;
			}
		},
		useDash: {
			enumerable: true,
			get: function () {
				return this.uniforms.useDash.value;
			},
			set: function ( value ) {
				this.uniforms.useDash.value = value;
			}
		},
		visibility: {
			enumerable: true,
			get: function () {
				return this.uniforms.visibility.value;
			},
			set: function ( value ) {
				this.uniforms.visibility.value = value;
			}
		},
		alphaTest: {
			enumerable: true,
			get: function () {
				return this.uniforms.alphaTest.value;
			},
			set: function ( value ) {
				this.uniforms.alphaTest.value = value;
			}
		},
		repeat: {
			enumerable: true,
			get: function () {
				return this.uniforms.repeat.value;
			},
			set: function ( value ) {
				this.uniforms.repeat.value.copy( value );
			}
		},
	});

	this.setValues( parameters );
}

MeshLineMaterial.prototype = Object.create( THREE.ShaderMaterial.prototype );
MeshLineMaterial.prototype.constructor = MeshLineMaterial;
MeshLineMaterial.prototype.isMeshLineMaterial = true;

MeshLineMaterial.prototype.copy = function ( source ) {

	THREE.ShaderMaterial.prototype.copy.call( this, source );

	this.lineWidth = source.lineWidth;
	this.map = source.map;
	this.useMap = source.useMap;
	this.alphaMap = source.alphaMap;
	this.useAlphaMap = source.useAlphaMap;
	this.color.copy( source.color );
	this.opacity = source.opacity;
	this.resolution.copy( source.resolution );
	this.sizeAttenuation = source.sizeAttenuation;
	this.near = source.near;
	this.far = source.far;
	this.dashArray.copy( source.dashArray );
	this.dashOffset.copy( source.dashOffset );
	this.dashRatio.copy( source.dashRatio );
	this.useDash = source.useDash;
	this.visibility = source.visibility;
	this.alphaTest = source.alphaTest;
	this.repeat.copy( source.repeat );

	return this;

};

if( typeof exports !== 'undefined' ) {
	if( typeof module !== 'undefined' && module.exports ) {
		exports = module.exports = { MeshLine: MeshLine, MeshLineMaterial: MeshLineMaterial };
	}
	exports.MeshLine = MeshLine;
	exports.MeshLineMaterial = MeshLineMaterial;
}
else {
	root.MeshLine = MeshLine;
	root.MeshLineMaterial = MeshLineMaterial;
}

}).call(this);
/*!
 * maptalks.three v0.20.2
 * LICENSE : MIT
 * (c) 2016-2022 maptalks.org
 */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("three")):"function"==typeof define&&define.amd?define(["exports","maptalks","three"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.THREE)}(this,(function(t,e,n){"use strict";function i(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var r=i(e),o=i(n);const s=parseInt(o.REVISION.replace("dev",""));function a(t,e,n){return s>109?t.setAttribute(e,n):t.addAttribute(e,n),t}function c(){return!o.VertexColors||o.VertexColors};class h extends o.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type="LineSegmentsGeometry";this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),a(this,"position",new o.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),a(this,"uv",new o.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix(t){var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;return void 0!==e&&(t.applyToBufferAttribute(e),t.applyToBufferAttribute(n),e.data.needsUpdate=!0),null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this}setPositions(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var n=new o.InstancedInterleavedBuffer(e,6,1);return a(this,"instanceStart",new o.InterleavedBufferAttribute(n,3,0)),a(this,"instanceEnd",new o.InterleavedBufferAttribute(n,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){var e;t instanceof Float32Array?e=t:Array.isArray(t)&&(e=new Float32Array(t));var n=new o.InstancedInterleavedBuffer(e,6,1);return a(this,"instanceColorStart",new o.InterleavedBufferAttribute(n,3,0)),a(this,"instanceColorEnd",new o.InterleavedBufferAttribute(n,3,3)),this}fromWireframeGeometry(t){return this.setPositions(t.attributes.position.array),this}fromEdgesGeometry(t){return this.setPositions(t.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new o.WireframeGeometry(t.geometry)),this}fromLineSegements(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}computeBoundingBox(){var t=new o.Box3;null===this.boundingBox&&(this.boundingBox=new o.Box3);var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;void 0!==e&&void 0!==n&&(this.boundingBox.setFromBufferAttribute(e),t.setFromBufferAttribute(n),this.boundingBox.union(t))}computeBoundingSphere(){var t=new o.Vector3;null===this.boundingSphere&&(this.boundingSphere=new o.Sphere),null===this.boundingBox&&this.computeBoundingBox();var e=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(void 0!==e&&void 0!==n){var i=this.boundingSphere.center;this.boundingBox.getCenter(i);for(var r=0,s=0,a=e.count;s<a;s++)t.fromBufferAttribute(e,s),r=Math.max(r,i.distanceToSquared(t)),t.fromBufferAttribute(n,s),r=Math.max(r,i.distanceToSquared(t));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}copy(t){return this}}const l={},u={};l.line={linewidth:{value:1},resolution:{value:new o.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},u.line={uniforms:o.UniformsUtils.merge([o.UniformsLib.common,o.UniformsLib.fog,l.line]),vertexShader:"\n\t\t#include <common>\n\t\t#include <color_pars_vertex>\n\t\t#include <fog_pars_vertex>\n\t\t#include <logdepthbuf_pars_vertex>\n\t\t#include <clipping_planes_pars_vertex>\n\n\t\tuniform float linewidth;\n\t\tuniform vec2 resolution;\n\n\t\tattribute vec3 instanceStart;\n\t\tattribute vec3 instanceEnd;\n\n\t\tattribute vec3 instanceColorStart;\n\t\tattribute vec3 instanceColorEnd;\n\n\t\tvarying vec2 vUv;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashScale;\n\t\t\tattribute float instanceDistanceStart;\n\t\t\tattribute float instanceDistanceEnd;\n\t\t\tvarying float vLineDistance;\n\n\t\t#endif\n\n\t\tvoid trimSegment( const in vec4 start, inout vec4 end ) {\n\n\t\t\t// trim end segment so it terminates between the camera plane and the near plane\n\n\t\t\t// conservative estimate of the near plane\n\t\t\tfloat a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n\t\t\tfloat b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\t\t\tfloat nearEstimate = - 0.5 * b / a;\n\n\t\t\tfloat alpha = ( nearEstimate - start.z ) / ( end.z - start.z );\n\n\t\t\tend.xyz = mix( start.xyz, end.xyz, alpha );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\t#ifdef USE_COLOR\n\n\t\t\t\tvColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n\t\t\t#endif\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tvLineDistance = ( position.y < 0.5 ) ? dashScale * instanceDistanceStart : dashScale * instanceDistanceEnd;\n\n\t\t\t#endif\n\n\t\t\tfloat aspect = resolution.x / resolution.y;\n\n\t\t\tvUv = uv;\n\n\t\t\t// camera space\n\t\t\tvec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n\t\t\tvec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n\t\t\t// special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n\t\t\t// clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n\t\t\t// but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n\t\t\t// perhaps there is a more elegant solution -- WestLangley\n\n\t\t\tbool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n\t\t\tif ( perspective ) {\n\n\t\t\t\tif ( start.z < 0.0 && end.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( start, end );\n\n\t\t\t\t} else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n\t\t\t\t\ttrimSegment( end, start );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// clip space\n\t\t\tvec4 clipStart = projectionMatrix * start;\n\t\t\tvec4 clipEnd = projectionMatrix * end;\n\n\t\t\t// ndc space\n\t\t\tvec2 ndcStart = clipStart.xy / clipStart.w;\n\t\t\tvec2 ndcEnd = clipEnd.xy / clipEnd.w;\n\n\t\t\t// direction\n\t\t\tvec2 dir = ndcEnd - ndcStart;\n\n\t\t\t// account for clip-space aspect ratio\n\t\t\tdir.x *= aspect;\n\t\t\tdir = normalize( dir );\n\n\t\t\t// perpendicular to dir\n\t\t\tvec2 offset = vec2( dir.y, - dir.x );\n\n\t\t\t// undo aspect ratio adjustment\n\t\t\tdir.x /= aspect;\n\t\t\toffset.x /= aspect;\n\n\t\t\t// sign flip\n\t\t\tif ( position.x < 0.0 ) offset *= - 1.0;\n\n\t\t\t// endcaps\n\t\t\tif ( position.y < 0.0 ) {\n\n\t\t\t\toffset += - dir;\n\n\t\t\t} else if ( position.y > 1.0 ) {\n\n\t\t\t\toffset += dir;\n\n\t\t\t}\n\n\t\t\t// adjust for linewidth\n\t\t\toffset *= linewidth;\n\n\t\t\t// adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n\t\t\toffset /= resolution.y;\n\n\t\t\t// select end\n\t\t\tvec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n\t\t\t// back to clip space\n\t\t\toffset *= clip.w;\n\n\t\t\tclip.xy += offset;\n\n\t\t\tgl_Position = clip;\n\n\t\t\tvec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n\t\t\t#include <logdepthbuf_vertex>\n\t\t\t#include <clipping_planes_vertex>\n\t\t\t#include <fog_vertex>\n\n\t\t}\n\t\t",fragmentShader:"\n\t\tuniform vec3 diffuse;\n\t\tuniform float opacity;\n\n\t\t#ifdef USE_DASH\n\n\t\t\tuniform float dashSize;\n\t\t\tuniform float gapSize;\n\n\t\t#endif\n\n\t\tvarying float vLineDistance;\n\n\t\t#include <common>\n\t\t#include <color_pars_fragment>\n\t\t#include <fog_pars_fragment>\n\t\t#include <logdepthbuf_pars_fragment>\n\t\t#include <clipping_planes_pars_fragment>\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\t#include <clipping_planes_fragment>\n\n\t\t\t#ifdef USE_DASH\n\n\t\t\t\tif ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n\t\t\t\tif ( mod( vLineDistance, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n\t\t\t#endif\n\n\t\t\tif ( abs( vUv.y ) > 1.0 ) {\n\n\t\t\t\tfloat a = vUv.x;\n\t\t\t\tfloat b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n\t\t\t\tfloat len2 = a * a + b * b;\n\n\t\t\t\tif ( len2 > 1.0 ) discard;\n\n\t\t\t}\n\n\t\t\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t\t\t#include <logdepthbuf_fragment>\n\t\t\t#include <color_fragment>\n\n\t\t\tgl_FragColor = vec4( diffuseColor.rgb, diffuseColor.a );\n\n\t\t\t#include <premultiplied_alpha_fragment>\n\t\t\t#include <tonemapping_fragment>\n\t\t\t#include <encodings_fragment>\n\t\t\t#include <fog_fragment>\n\n\t\t}\n\t\t"};class d extends o.ShaderMaterial{constructor(t){super({uniforms:o.UniformsUtils.clone(u.line.uniforms),vertexShader:u.line.vertexShader,fragmentShader:u.line.fragmentShader}),this.dashed=!0,this.isLineMaterial=!0,this.type="LineMaterial",Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}}}),this.setValues(t)}}class f extends o.Mesh{constructor(t,e){super(t,e),this.isLineSegments2=!0,this.type="LineSegments2",this.geometry=void 0!==t?t:new h,this.material=void 0!==e?e:new d({color:16777215*Math.random()})}computeLineDistances(){var t=new o.Vector3,e=new o.Vector3,n=this.geometry,i=n.attributes.instanceStart,r=n.attributes.instanceEnd;if(!i||!r)return this;for(var s=new Float32Array(2*i.data.count),c=0,h=0,l=i.data.count;c<l;c++,h+=2)t.fromBufferAttribute(i,c),e.fromBufferAttribute(r,c),s[h]=0===h?0:s[h-1],s[h+1]=s[h]+t.distanceTo(e);var u=new o.InstancedInterleavedBuffer(s,2,1);return a(n,"instanceDistanceStart",new o.InterleavedBufferAttribute(u,1,0)),a(n,"instanceDistanceEnd",new o.InterleavedBufferAttribute(u,1,1)),this}}class g extends h{constructor(){super(),this.isLineGeometry=!0,this.type="LineGeometry"}fromLine(t){var e=t.geometry;return e.isGeometry?this.setPositions(e.vertices):e.isBufferGeometry&&this.setPositions(e.position.array),this}}class p extends f{constructor(t,e){super(t,e),this.isLine2=!0,this.type="Line2",this.geometry=void 0!==t?t:new g,this.material=void 0!==e?e:new d({color:16777215*Math.random()})}copy(t){return this}}const y={interactive:!0,altitude:0,minZoom:0,maxZoom:30,asynchronous:!1};function x(){}class v extends(r.Eventable(x)){constructor(t){super(),this.isAdd=!1,this._mouseover=!1,this._visible=!0,this._zoomVisible=!0,this.picked=!1,this.isBaseObject=!0,void 0===t&&(t=r.Util.GUID()),this.id=t}addTo(t){return t&&"ThreeLayer"===t.type?t.addMesh([this]):console.error("layer only support maptalks.ThreeLayer"),this}remove(){const t=this.getLayer();return t&&t.removeMesh([this]),this}getObject3d(){return this.object3d}getId(){return this.id}setId(t){const e=this.getId();return this.id=t,this._fire("idchange",{old:e,new:t,target:this}),this}getType(){return this.type}getOptions(){return this.options}getProperties(){return(this.options||{}).properties}setProperties(t){const e=Object.assign({},this.getProperties());return this.options.properties=t,this._fire("propertieschange",{old:e,new:t,target:this}),this}getLayer(){return this.options.layer}getMap(){const t=this.getLayer();if(t)return t.getMap()}getCenter(){const t=this.getOptions(),{coordinate:e,lineString:n,polygon:i}=t;if(e)return e instanceof r.Coordinate?e:new r.Coordinate(e);{const t=i||n;if(t&&t.getCenter)return t.getCenter()}}getAltitude(){return this.getOptions().altitude}setAltitude(t){if(r.Util.isNumber(t)){const e=this.getLayer().distanceToVector3(t,t).x;if(this.getObject3d().position.z=e,this.options.altitude=t,this.pickObject3d&&(this.pickObject3d.position.z=e),this._baseObjects&&Array.isArray(this._baseObjects))for(let t=0,n=this._baseObjects.length;t<n;t++)this._baseObjects[t]&&(this._baseObjects[t].getObject3d().position.z=e)}return this}show(){return this._zoomVisible&&(this.getObject3d().visible=!0,this._fire("show")),this._visible=!0,this}hide(){return this.getObject3d().visible=!1,this._fire("hide"),this._visible=!1,this}isVisible(){return!!this.getObject3d().visible}getSymbol(){return this.getObject3d().material}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0,t.vertexColors=this.getObject3d().material.vertexColors;const e=this.getObject3d().material.clone();this.getObject3d().material=t,this._fire("symbolchange",{old:e,new:t,target:this})}return this}setInfoWindow(t){return this.removeInfoWindow(),this.infoWindow=new r.ui.InfoWindow(t),this.infoWindow.addTo(this),this}getInfoWindow(){return this.infoWindow}openInfoWindow(t){return(t=t||this.getCenter())instanceof r.Coordinate||(t=new r.Coordinate(t)),t&&this.infoWindow&&this.infoWindow.show(t),this}closeInfoWindow(){return this.infoWindow&&this.infoWindow.hide(),this}removeInfoWindow(){return this.infoWindow&&(this.infoWindow.remove(),delete this.infoWindow),this}setToolTip(t,e){return this.removeToolTip(),this.toolTip=new r.ui.ToolTip(t,e),this.toolTip.addTo(this),this}getToolTip(){return this.toolTip}openToolTip(t){return(t=t||this.getCenter())instanceof r.Coordinate||(t=new r.Coordinate(t)),t&&this.toolTip&&this.toolTip.show(t),this}closeToolTip(){return this.toolTip&&this.toolTip.hide(),this}removeToolTip(){return this.toolTip&&(this.toolTip.remove(),delete this.toolTip),this}animateShow(t={},e){this._showPlayer&&this._showPlayer.cancel(),r.Util.isFunction(t)&&(e=t={});const n=t.duration||1e3,i=t.easing||"out",o=this._showPlayer=r.animation.Animation.animate({scale:1},{duration:n,easing:i},(t=>{const n=t.styles.scale;n>0&&(this.getObject3d().scale.z=n),e&&e(t,n)}));return o.play(),o}getMinZoom(){return this.getOptions().minZoom}getMaxZoom(){return this.getOptions().maxZoom}isAsynchronous(){return this.getOptions().asynchronous}fire(t,e){return this._fire(t,e),this._vt&&this._vt.onSelectMesh&&this._vt.onSelectMesh(t,e),this}config(){return this}setPickObject3d(t){return this.pickObject3d=t,this.pickObject3d.__parent=this,this}_initOptions(t){return this.options=r.Util.extend({},y,t),this}_createMesh(t,e){return this.object3d=new o.Mesh(t,e),this.object3d.__parent=this,this}_createGroup(){return this.object3d=new o.Group,this.object3d.__parent=this,this}_createLine(t,e){return this.object3d=new o.Line(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_createLine2(t,e){return this.object3d=new p(t,e),this.object3d.computeLineDistances(),this.object3d.__parent=this,this}_createPoints(t,e){return this.object3d=new o.Points(t,e),this.object3d.__parent=this,this}_createLineSegments(t,e){return this.object3d=new o.LineSegments(t,e),this._computeLineDistances(t),this.object3d.__parent=this,this}_computeLineDistances(t){const e=t.attributes.position.array,n=t.attributes.position.count,i=new Float32Array(n);i[0]=0;const r=new o.Vector3(0,0,0),s=new o.Vector3(0,0,0);for(let t=1;t<n;t++){const n=3*(t-1);r.x=e[n],r.y=e[n+1],r.z=e[n+2];const o=3*t;s.x=e[o],s.y=e[o+1],s.z=e[o+2];const a=s.distanceTo(r);i[t]=i[t-1]+a}a(t,"lineDistance",new o.BufferAttribute(i,1))}}function m(t){const{position:e,normal:n,uv:i,indices:r}=b(t),s=new o.BufferGeometry,c=new Float32Array(e.length);return c.fill(1,0,e.length),a(s,"color",new o.BufferAttribute(c,3)),a(s,"normal",new o.BufferAttribute(n,3)),a(s,"position",new o.BufferAttribute(e,3)),i&&i.length&&a(s,"uv",new o.BufferAttribute(i,2)),s.setIndex(new o.BufferAttribute(r,1)),s}function b(t){const e={},n={};for(let i=0;i<t.length;++i){const r=t[i];for(const t in r)void 0===e[t]&&(e[t]=[],n[t]=0),e[t].push(r[t]),n[t]+=r[t].length}const i={};let r=0;const o=new Uint32Array(n.indices);for(const t in e)if("indices"===t){const n=e[t];let i=0;for(let t=0,s=n.length;t<s;t++){const s=n[t];for(let t=0,e=s.length;t<e;t++)o[i]=s[t]+r,i++;r+=e.position[t].length/3}}else{const r=_(e[t],n[t]);if(!r)return null;i[t]=r}return i.indices=o,i}function _(t,e){const n=new Float32Array(e);let i=0;for(let e=0;e<t.length;++e)n.set(t[e],i),i+=t[e].length;return n}function w(t){const{position:e,normal:n,uv:i,indices:r}=t,s=new o.BufferGeometry;return a(s,"normal",new o.BufferAttribute(new Float32Array(n),3)),a(s,"position",new o.BufferAttribute(new Float32Array(e),3)),a(s,"uv",new o.BufferAttribute(new Float32Array(i),2)),s.setIndex(new o.BufferAttribute(new Uint32Array(r),1)),s}function M(t){const e=new o.BufferGeometry;return a(e,"normal",t.getAttribute("normal")),a(e,"position",t.getAttribute("position").clone()),e.setIndex(t.getIndex()),e}let O;function S(){if(!O){const t=1e-6;O=new o.BoxBufferGeometry(t,t,t)}return O}S();var A=Object.freeze({__proto__:null,mergeBufferGeometries:m,mergeBufferGeometriesAttribute:b,generateBufferGeometry:w,generatePickBufferGeometry:M,getDefaultBufferGeometry:S});const j={},C=new o.BoxBufferGeometry(1,1,1);C.translate(0,0,.5);const T=new o.Color("#fff"),L=new o.Color("#fff");function P(t){const{height:e,radialSegments:n,radius:i}=t,r=function(t=6){if(!j[t]){const e=new o.CylinderBufferGeometry(1,1,1,t,1);e.rotateX(Math.PI/2),e.translate(0,0,.5),e.rotateZ(Math.PI/6),j[t]=e}return j[t]}(n).clone();return r.scale(i,i,e),r}function k(t,e,n,i="y",r=0){let s=0;"y"===i?s=1:"z"===i&&(s=2);const c=t.attributes.position.array,h=c.length;L.setStyle(e),T.setStyle(n);const l=new Float32Array(h);for(let t=0;t<h;t+=3){c[t+s]>r?(l[t]=T.r,l[t+1]=T.g,l[t+2]=T.b):(l[t]=L.r,l[t+1]=L.g,l[t+2]=L.b)}return a(t,"color",new o.BufferAttribute(l,3,!0)),l}function B(t){const e=[],n=t.length;let i=0;for(let e=0;e<n;e++){const{color:n}=t[e].attributes;n&&(i+=n.array.length)}const r=new Float32Array(i);let s=0;for(let n=0,i=t.length;n<i;n++){const{color:i,normal:o,position:a,uv:c}=t[n].attributes,h=t[n].index;i&&(r.set(i.array,s),s+=i.array.length),e.push({normal:o.array,uv:c.array,position:a.array,indices:h.array})}const c=m(e);r.length&&a(c,"color",new o.BufferAttribute(r,3,!0));for(let e=0,n=t.length;e<n;e++)t[e].dispose();return c}function z(){return C}const E={radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61"};class V extends v{constructor(t,e,n,i){e=r.Util.extend({},E,e,{layer:i,coordinate:t}),super(),this._initOptions(e);const{height:o,radius:s,topColor:a,bottomColor:h,altitude:l}=e;e.height=i.distanceToVector3(o,o).x,e.radius=i.distanceToVector3(s,s).x,e._radius=this.options.radius,e._height=this.options.height;const u=P(e);a&&(k(u,h,a,"z",e.height/2),n.vertexColors=c()),this._createMesh(u,n);const d=i.distanceToVector3(l,l).x,f=i.coordinateToVector3(t,d);this.getObject3d().position.copy(f),this.type="Bar"}}const U=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];function I(t){return t.geometry?t.geometry.type:null}function R(t){const e=I(t);if(e)for(let t=0,n=U.length;t<n;t++)if(U[t]===e)return!0;return!1}function F(t){const e=I(t);return!(!e||e!==U[4]&&e!==U[5])}function G(t){const e=I(t);return!(!e||e!==U[2]&&e!==U[3])}function Z(t){const e=I(t);return!(!e||e!==U[0]&&e!==U[1])}function D(t){const e=I(t);return!!(e&&e.indexOf("Multi")>-1)}function H(t){return t.geometry?t.geometry.coordinates:[]}function J(t,e){const n=I(t);if(!n||!t.geometry)return null;const i=t.geometry.coordinates;if(!i)return null;let o=0,s=0,a=0;switch(n){case"Point":o=i[0],s=i[1],a++;break;case"MultiPoint":case"LineString":for(let t=0,e=i.length;t<e;t++)o+=i[t][0],s+=i[t][1],a++;break;case"MultiLineString":case"Polygon":for(let t=0,e=i.length;t<e;t++)for(let e=0,n=i[t].length;e<n;e++)o+=i[t][e][0],s+=i[t][e][1],a++;break;case"MultiPolygon":for(let t=0,e=i.length;t<e;t++)for(let e=0,n=i[t].length;e<n;e++)for(let n=0,r=i[t][e].length;n<r;n++)o+=i[t][e][n][0],s+=i[t][e][n][1],a++}const c=o/a,h=s/a;return e?(e.x=c,e.y=h,e):new r.Coordinate(c,h)}function Q(t){const e=I(t);if(!e||!t.geometry)return null;const n=t.geometry,i=t.properties||{},r=n.coordinates;if(!r)return null;const o=[];let s;switch(e){case"MultiPoint":s="Point";break;case"MultiLineString":s="LineString";break;case"MultiPolygon":s="Polygon"}if(s)for(let t=0,e=r.length;t<e;t++)o.push({type:"Feature",geometry:{type:s,coordinates:r[t]},properties:i});else o.push(t);return o}var W=Object.freeze({__proto__:null,isGeoJSON:R,isGeoJSONPolygon:F,isGeoJSONLine:G,isGeoJSONPoint:Z,isGeoJSONMulti:D,getGeoJSONCoordinates:H,getGeoJSONCenter:J,spliteGeoJSONMulti:Q}),q={exports:{}};function N(t,e,n){n=n||2;var i,r,o,s,a,c,h,l=e&&e.length,u=l?e[0]*n:t.length,d=K(t,0,u,n,!0),f=[];if(!d||d.next===d.prev)return f;if(l&&(d=function(t,e,n,i){var r,o,s,a=[];for(r=0,o=e.length;r<o;r++)(s=K(t,e[r]*i,r<o-1?e[r+1]*i:t.length,i,!1))===s.next&&(s.steiner=!0),a.push(at(s));for(a.sort(it),r=0;r<a.length;r++)rt(a[r],n),n=X(n,n.next);return n}(t,e,d,n)),t.length>80*n){i=o=t[0],r=s=t[1];for(var g=n;g<u;g+=n)(a=t[g])<i&&(i=a),(c=t[g+1])<r&&(r=c),a>o&&(o=a),c>s&&(s=c);h=0!==(h=Math.max(o-i,s-r))?1/h:0}return $(d,f,n,i,r,h),f}function K(t,e,n,i,r){var o,s;if(r===bt(t,e,n,i)>0)for(o=e;o<n;o+=i)s=xt(o,t[o],t[o+1],s);else for(o=n-i;o>=e;o-=i)s=xt(o,t[o],t[o+1],s);return s&&ut(s,s.next)&&(vt(s),s=s.next),s}function X(t,e){if(!t)return t;e||(e=t);var n,i=t;do{if(n=!1,i.steiner||!ut(i,i.next)&&0!==lt(i.prev,i,i.next))i=i.next;else{if(vt(i),(i=e=i.prev)===i.next)break;n=!0}}while(n||i!==e);return e}function $(t,e,n,i,r,o,s){if(t){!s&&o&&function(t,e,n,i){var r=t;do{null===r.z&&(r.z=st(r.x,r.y,e,n,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){var e,n,i,r,o,s,a,c,h=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,i=n,a=0,e=0;e<h&&(a++,i=i.nextZ);e++);for(c=h;a>0||c>0&&i;)0!==a&&(0===c||!i||n.z<=i.z)?(r=n,n=n.nextZ,a--):(r=i,i=i.nextZ,c--),o?o.nextZ=r:t=r,r.prevZ=o,o=r;n=i}o.nextZ=null,h*=2}while(s>1)}(r)}(t,i,r,o);for(var a,c,h=t;t.prev!==t.next;)if(a=t.prev,c=t.next,o?tt(t,i,r,o):Y(t))e.push(a.i/n),e.push(t.i/n),e.push(c.i/n),vt(t),t=c.next,h=c.next;else if((t=c)===h){s?1===s?$(t=et(X(t),e,n),e,n,i,r,o,2):2===s&&nt(t,e,n,i,r,o):$(X(t),e,n,i,r,o,1);break}}}function Y(t){var e=t.prev,n=t,i=t.next;if(lt(e,n,i)>=0)return!1;for(var r=t.next.next;r!==t.prev;){if(ct(e.x,e.y,n.x,n.y,i.x,i.y,r.x,r.y)&&lt(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function tt(t,e,n,i){var r=t.prev,o=t,s=t.next;if(lt(r,o,s)>=0)return!1;for(var a=r.x<o.x?r.x<s.x?r.x:s.x:o.x<s.x?o.x:s.x,c=r.y<o.y?r.y<s.y?r.y:s.y:o.y<s.y?o.y:s.y,h=r.x>o.x?r.x>s.x?r.x:s.x:o.x>s.x?o.x:s.x,l=r.y>o.y?r.y>s.y?r.y:s.y:o.y>s.y?o.y:s.y,u=st(a,c,e,n,i),d=st(h,l,e,n,i),f=t.prevZ,g=t.nextZ;f&&f.z>=u&&g&&g.z<=d;){if(f!==t.prev&&f!==t.next&&ct(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&lt(f.prev,f,f.next)>=0)return!1;if(f=f.prevZ,g!==t.prev&&g!==t.next&&ct(r.x,r.y,o.x,o.y,s.x,s.y,g.x,g.y)&&lt(g.prev,g,g.next)>=0)return!1;g=g.nextZ}for(;f&&f.z>=u;){if(f!==t.prev&&f!==t.next&&ct(r.x,r.y,o.x,o.y,s.x,s.y,f.x,f.y)&&lt(f.prev,f,f.next)>=0)return!1;f=f.prevZ}for(;g&&g.z<=d;){if(g!==t.prev&&g!==t.next&&ct(r.x,r.y,o.x,o.y,s.x,s.y,g.x,g.y)&&lt(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function et(t,e,n){var i=t;do{var r=i.prev,o=i.next.next;!ut(r,o)&&dt(r,i,i.next,o)&&pt(r,o)&&pt(o,r)&&(e.push(r.i/n),e.push(i.i/n),e.push(o.i/n),vt(i),vt(i.next),i=t=o),i=i.next}while(i!==t);return X(i)}function nt(t,e,n,i,r,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&ht(s,a)){var c=yt(s,a);return s=X(s,s.next),c=X(c,c.next),$(s,e,n,i,r,o),void $(c,e,n,i,r,o)}a=a.next}s=s.next}while(s!==t)}function it(t,e){return t.x-e.x}function rt(t,e){if(e=function(t,e){var n,i=e,r=t.x,o=t.y,s=-1/0;do{if(o<=i.y&&o>=i.next.y&&i.next.y!==i.y){var a=i.x+(o-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(a<=r&&a>s){if(s=a,a===r){if(o===i.y)return i;if(o===i.next.y)return i.next}n=i.x<i.next.x?i:i.next}}i=i.next}while(i!==e);if(!n)return null;if(r===s)return n;var c,h=n,l=n.x,u=n.y,d=1/0;i=n;do{r>=i.x&&i.x>=l&&r!==i.x&&ct(o<u?r:s,o,l,u,o<u?s:r,o,i.x,i.y)&&(c=Math.abs(o-i.y)/(r-i.x),pt(i,t)&&(c<d||c===d&&(i.x>n.x||i.x===n.x&&ot(n,i)))&&(n=i,d=c)),i=i.next}while(i!==h);return n}(t,e)){var n=yt(e,t);X(n,n.next)}}function ot(t,e){return lt(t.prev,t,e.prev)<0&&lt(e.next,t,t.next)<0}function st(t,e,n,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*r)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-i)*r)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function at(t){var e=t,n=t;do{(e.x<n.x||e.x===n.x&&e.y<n.y)&&(n=e),e=e.next}while(e!==t);return n}function ct(t,e,n,i,r,o,s,a){return(r-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(i-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(r-s)*(i-a)>=0}function ht(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&dt(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&(pt(t,e)&&pt(e,t)&&function(t,e){var n=t,i=!1,r=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&r<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(i=!i),n=n.next}while(n!==t);return i}(t,e)&&(lt(t.prev,t,e.prev)||lt(t,e.prev,e))||ut(t,e)&&lt(t.prev,t,t.next)>0&&lt(e.prev,e,e.next)>0)}function lt(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function ut(t,e){return t.x===e.x&&t.y===e.y}function dt(t,e,n,i){var r=gt(lt(t,e,n)),o=gt(lt(t,e,i)),s=gt(lt(n,i,t)),a=gt(lt(n,i,e));return r!==o&&s!==a||(!(0!==r||!ft(t,n,e))||(!(0!==o||!ft(t,i,e))||(!(0!==s||!ft(n,t,i))||!(0!==a||!ft(n,e,i)))))}function ft(t,e,n){return e.x<=Math.max(t.x,n.x)&&e.x>=Math.min(t.x,n.x)&&e.y<=Math.max(t.y,n.y)&&e.y>=Math.min(t.y,n.y)}function gt(t){return t>0?1:t<0?-1:0}function pt(t,e){return lt(t.prev,t,t.next)<0?lt(t,e,t.next)>=0&&lt(t,t.prev,e)>=0:lt(t,e,t.prev)<0||lt(t,t.next,e)<0}function yt(t,e){var n=new mt(t.i,t.x,t.y),i=new mt(e.i,e.x,e.y),r=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=r,r.prev=n,i.next=n,n.prev=i,o.next=i,i.prev=o,i}function xt(t,e,n,i){var r=new mt(t,e,n);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function vt(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function mt(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function bt(t,e,n,i){for(var r=0,o=e,s=n-i;o<n;o+=i)r+=(t[s]-t[o])*(t[o+1]+t[s+1]),s=o;return r}q.exports=N,q.exports.default=N,N.deviation=function(t,e,n,i){var r=e&&e.length,o=r?e[0]*n:t.length,s=Math.abs(bt(t,0,o,n));if(r)for(var a=0,c=e.length;a<c;a++){var h=e[a]*n,l=a<c-1?e[a+1]*n:t.length;s-=Math.abs(bt(t,h,l,n))}var u=0;for(a=0;a<i.length;a+=3){var d=i[a]*n,f=i[a+1]*n,g=i[a+2]*n;u+=Math.abs((t[d]-t[g])*(t[f+1]-t[d+1])-(t[d]-t[f])*(t[g+1]-t[d+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)},N.flatten=function(t){for(var e=t[0][0].length,n={vertices:[],holes:[],dimensions:e},i=0,r=0;r<t.length;r++){for(var o=0;o<t[r].length;o++)for(var s=0;s<e;s++)n.vertices.push(t[r][o][s]);r>0&&(i+=t[r-1].length,n.holes.push(i))}return n};var _t=q.exports;function wt(t,e,n){var i=e[0],r=e[1],o=n[0]-i,s=n[1]-r;if(0!==o||0!==s){var a=((t[0]-i)*o+(t[1]-r)*s)/(o*o+s*s);a>1?(i=n[0],r=n[1]):a>0&&(i+=o*a,r+=s*a)}return(o=t[0]-i)*o+(s=t[1]-r)*s}function Mt(t,e,n,i,r){for(var o,s=i,a=e+1;a<n;a++){var c=wt(t[a],t[e],t[n]);c>s&&(o=a,s=c)}s>i&&(o-e>1&&Mt(t,e,o,i,r),r.push(t[o]),n-o>1&&Mt(t,o,n,i,r))}function Ot(t,e){var n=t.length-1,i=[t[0]];return Mt(t,0,n,e,i),i.push(t[n]),i}function St(t,e,n){if(t.length<=2)return t;var i=void 0!==e?e*e:1;return t=Ot(t=n?t:function(t,e){for(var n,i,r,o,s,a=t[0],c=[a],h=1,l=t.length;h<l;h++)n=t[h],r=a,o=void 0,s=void 0,o=(i=n)[0]-r[0],s=i[1]-r[1],o*o+s*s>e&&(c.push(n),a=n);return a!==n&&c.push(n),c}(t,i),i)}function At(t,e){return t[0]*e[0]+t[1]*e[1]}function jt(t,e){const n=e[0],i=e[1],r=Math.sqrt(n*n+i*i);return t[0]=n/r,t[1]=i/r,t}function Ct(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t[2]=e[2]+n[2]*i,t}function Tt(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function Lt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function Pt(t,e){const n=e[0],i=e[1],r=e[2],o=Math.sqrt(n*n+i*i+r*r);return t[0]=n/o,t[1]=i/o,t[2]=r/o,t}function kt(t,e,n){var i=e[0],r=e[1],o=e[2],s=n[0],a=n[1],c=n[2];return t[0]=r*c-o*a,t[1]=o*s-i*c,t[2]=i*a-r*s,t}const Bt=[];function zt(t,e,n,i){const r=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}(e,n),o=Math.acos(r)*i;return Ct(Bt,n,e,-r),function(t,e){const n=e[0],i=e[1],r=e[2],o=Math.sqrt(n*n+i*i+r*r);t[0]=n/o,t[1]=i/o,t[2]=r/o}(Bt,Bt),function(t,e,n){t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n}(t,e,Math.cos(o)),Ct(t,t,Bt,Math.sin(o)),t}function Et(t,e,n,i,r,o,s,a,c,h){const l=s-r,u=a-o,d=(l*(e-o)-u*(t-r))/(u*(n-t)-l*(i-e));return c&&(c[h=h||0]=t+d*(n-t),c[h+1]=e+d*(i-e)),d}function Vt(t,e,n){if(n-e<3)return 0;let i=0;for(let r=2*(n-1),o=2*e;o<2*n;){const e=t[r],n=t[r+1],s=t[o],a=t[o+1];r=o,o+=2,i+=e*a-s*n}return i}function Ut(t,e,n=2){return _t(t,e,n)}const It=[],Rt=[],Ft=[];function Gt(t,e,n,i,r,o,s,a,c){const h=null!=s;let l,u,d,f=r,g=null;h&&(g=new Uint32Array(i-n));let p=[];for(let r=n;r<i;r++){const y=r===i-1?n:r+1,x=r===n?i-1:r-1,v=t[2*x],m=t[2*x+1],b=t[2*r],_=t[2*r+1],w=t[2*y],M=t[2*y+1];It[0]=b-v,It[1]=_-m,Rt[0]=w-b,Rt[1]=M-_,jt(It,It),jt(Rt,Rt),h&&(g[r]=f);let O,S,A=!1;if(a||r!==n)if(a||r!==i-1){Tt(Ft,Rt,It);const t=Ft[1];Ft[1]=-Ft[0],Ft[0]=t,jt(Ft,Ft);const n=At(Ft,Rt),i=Math.sqrt(1-n*n),r=o*Math.min(10,1/i),a=o*n<0;if(h&&1/i>s&&a){const t=b+Ft[0]*o,n=_+Ft[1]*o,r=Math.acos(i)/2,s=Math.tan(r)*Math.abs(o);e[2*f]=t+Ft[1]*s,e[2*f+1]=n-Ft[0]*s,f++,e[2*f]=t-Ft[1]*s,e[2*f+1]=n+Ft[0]*s,f++}else O=b+Ft[0]*r,S=_+Ft[1]*r,A=!0;if(A){if(c&&null!=l){const t=Et(v,m,l,u,b,_,O,S,p,0);t>=-.01&&t<=1.01&&(e[2*d]=O=p[0],e[2*d+1]=S=p[1])}l=e[2*f]=O,u=e[2*f+1]=S,d=f,f++}}else Ft[0]=It[1],Ft[1]=-It[0],jt(Ft,Ft),O=b+Ft[0]*o,S=_+Ft[1]*o,A=!0;else Ft[0]=Rt[1],Ft[1]=-Rt[0],jt(Ft,Ft),l=e[2*f]=b+Ft[0]*o,u=e[2*f+1]=_+Ft[1]*o,d=f,f++}return g}function Zt(t,e,n,i,r,o,s,a){const c=null!=s;let h=r,l=null;c&&(l=new Uint32Array(i-n));for(let r=n;r<i;r++){const u=r===i-1?n:r+1,d=r===n?i-1:r-1,f=t[2*d],g=t[2*d+1],p=t[2*r],y=t[2*r+1],x=t[2*u],v=t[2*u+1];if(It[0]=p-f,It[1]=y-g,Rt[0]=x-p,Rt[1]=v-y,jt(It,It),jt(Rt,Rt),c&&(l[r]=h),a||r!==n)if(a||r!==i-1){Tt(Ft,Rt,It);const t=Ft[1];Ft[1]=-Ft[0],Ft[0]=t,jt(Ft,Ft);const n=At(Ft,Rt),i=Math.sqrt(1-n*n),r=o*Math.min(10,1/i),a=o*n<0;if(c&&1/i>s&&a){const t=p+Ft[0]*o,n=y+Ft[1]*o,r=Math.acos(i)/2,s=Math.tan(r)*Math.abs(o);e[2*h]=t+Ft[1]*s,e[2*h+1]=n-Ft[0]*s,h++,e[2*h]=t-Ft[1]*s,e[2*h+1]=n+Ft[0]*s,h++}else e[2*h]=p+Ft[0]*r,e[2*h+1]=y+Ft[1]*r,h++}else Ft[0]=It[1],Ft[1]=-It[0],jt(Ft,Ft),e[2*h]=p+Ft[0]*o,e[2*h+1]=y+Ft[1]*o,h++;else Ft[0]=Rt[1],Ft[1]=-Rt[0],jt(Ft,Ft),e[2*h]=p+Ft[0]*o,e[2*h+1]=y+Ft[1]*o,h++}return l}function Dt(t,e,n,i,r){const o=null!=i?[]:new Float32Array(t.length);if(Gt(t,o,0,e&&e.length?e[0]:t.length/2,0,n,i,r,!0),e)for(let s=0;s<e.length;s++){const a=e[s];Gt(t,o,a,e[s+1]||t.length/2,null!=i?o.length/2:a,n,i,r,!1)}return o}function Ht(t,e,n,i){for(let r=0;r<Math.floor((i-n)/2);r++)for(let o=0;o<e;o++){const s=(r+n)*e+o,a=(i-r-1)*e+o,c=t[s];t[s]=t[a],t[a]=c}return t}function Jt(t,e){let n=t.length/2,i=0,r=e&&e.length?e[0]:n;Vt(t,i,r)>0&&Ht(t,2,i,r);for(let o=1;o<(e?e.length:0)+1;o++)i=e[o-1],r=e[o]||n,Vt(t,i,r)<0&&Ht(t,2,i,r)}function Qt(t){t.depth=t.depth||1,t.bevelSize=t.bevelSize||0,t.bevelSegments=null==t.bevelSegments?2:t.bevelSegments,t.smoothBevel=t.smoothBevel||!1,t.simplify=t.simplify||0,null==t.smoothSide&&(t.smoothSide="auto"),null==t.smoothSideThreshold&&(t.smoothSideThreshold=.9),"number"==typeof t.depth&&(t.bevelSize=Math.min(t.bevelSegments>0?t.bevelSize:0,t.depth/2)),t.bevelSize>0||(t.bevelSegments=0),t.bevelSegments=Math.round(t.bevelSegments);const e=t.boundingRect;if(t.translate=t.translate||[0,0],t.scale=t.scale||[1,1],t.fitRect){let n=null==t.fitRect.x?e.x||0:t.fitRect.x,i=null==t.fitRect.y?e.y||0:t.fitRect.y,r=t.fitRect.width,o=t.fitRect.height;null==r?null!=o?r=o/e.height*e.width:(r=e.width,o=e.height):null==o&&(o=r/e.width*e.height),t.scale=[r/e.width,o/e.height],t.translate=[(n-e.x)*t.scale[0],(i-e.y)*t.scale[1]]}}const Wt=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]];function qt(t,e,n){let i=0,r=t[e],o=t[e+1];const s=r,a=o;for(let s=e+2;s<n;s+=2){const e=t[s],n=t[s+1];i+=Math.sqrt((e-r)*(e-r)+(n-o)*(n-o)),r=e,o=n}return i+=Math.sqrt((r-s)*(r-s)+(o-a)*(o-a)),i}function Nt(t,{vertices:e,topVertices:n,splittedMap:i,depth:r,rect:o},s,a,c,h){const l=a-s,u=h.smoothBevel?1:2,d=Math.min(r/2,h.bevelSize),f=h.bevelSegments,g=c.vertex,p=c.ringPerimeter,y=Math.max(o.width,o.height,r,p);function x(t){const n=(t+1)%l,i=e[2*t],r=e[2*t+1],o=e[2*n],s=e[2*n+1];return i===o&&r===s}if(d>0){const o=[0,0,1],a=[],h=[0,0,-1],p=[];let v=0,m=new Float32Array(l);for(let b=0;b<2;b++){const _=0===b?r-d:d;for(let r=0;r<=f*u;r++){let w,M,O=0;for(let S=0;S<l;S++){const A=2*(S%l+s),j=i?2*i[A/2]:A;a[0]=e[A]-n[j],a[1]=e[A+1]-n[j+1],a[2]=0;const C=Math.sqrt(a[0]*a[0]+a[1]*a[1]);a[0]/=C,a[1]/=C;const T=(Math.floor(r/u)+r%u)/f;0===b?zt(p,o,a,T):zt(p,a,h,T);const L=0===b?T:1-T,P=d*Math.sin(L*Math.PI/2),k=C*Math.cos(L*Math.PI/2),B=d*C/Math.sqrt(P*P+k*k),z=p[0]*B+n[j],E=p[1]*B+n[j+1],V=p[2]*B+_;if(t.position[3*c.vertex]=z,t.position[3*c.vertex+1]=E,t.position[3*c.vertex+2]=V,S>0&&(O+=Math.sqrt((w-z)*(w-z)+(M-E)*(M-E))),r>0||b>0){let e=3*(c.vertex-l),n=t.position[e],i=t.position[e+1],r=t.position[e+2];m[S]+=Math.sqrt((n-z)*(n-z)+(i-E)*(i-E)+(r-V)*(r-V))}if(t.uv[2*c.vertex]=O/y,t.uv[2*c.vertex+1]=m[S]/y,w=z,M=E,c.vertex++,!x(S)&&(u>1&&r%u||1===u&&r>=1))for(let e=0;e<6;e++){const n=(Wt[e][0]+S)%l,i=Wt[e][1]+v;t.indices[c.index++]=(i-1)*l+n+g}}v++}}}else for(let n=0;n<2;n++){const i=0===n?r-d:d;let o,a,h=0;for(let n=0;n<l;n++){const r=2*(n%l+s),u=e[r],d=e[r+1];t.position[3*c.vertex]=u,t.position[3*c.vertex+1]=d,t.position[3*c.vertex+2]=i,n>0&&(h+=Math.sqrt((o-u)*(o-u)+(a-d)*(a-d))),t.uv[2*c.vertex]=h/y,t.uv[2*c.vertex+1]=i/y,o=u,a=d,c.vertex++}}const v=d>0?f*u+1:1;for(let e=0;e<l;e++)if(!x(e))for(let n=0;n<6;n++){const i=(Wt[n][0]+e)%l,r=Wt[n][1]+v;t.indices[c.index++]=(r-1)*l+i+g}}function Kt({indices:t,topVertices:e,rect:n,depth:i},r,o,s){if(e.length<=4)return;const a=o.vertex,c=t.length;for(let e=0;e<c;e++)r.indices[o.index++]=a+t[e];const h=Math.max(n.width,n.height);for(let t=0;t<(s.excludeBottom?1:2);t++)for(let s=0;s<e.length;s+=2){const a=e[s],c=e[s+1];r.position[3*o.vertex]=a,r.position[3*o.vertex+1]=c,r.position[3*o.vertex+2]=(1-t)*i,r.uv[2*o.vertex]=(a-n.x)/h,r.uv[2*o.vertex+1]=(c-n.y)/h,o.vertex++}if(!s.excludeBottom){const n=e.length/2;for(let e=0;e<c;e+=3)for(let i=0;i<3;i++)r.indices[o.index++]=a+n+t[e+2-i]}}function Xt(t,e,n,i){const r=null==n||"auto"===n;if(!0===n)return{vertices:t,holes:e};const o=[],s=e&&[],a=t.length/2,c=[],h=[],l=[];let u=0,d=0;const f=(e?e.length:0)+1;for(let n=0;n<f;n++){0===n?d=e&&e.length?e[0]:a:(u=e[n-1],d=e[n]||a);for(let e=u;e<d;e++){const n=t[2*e],s=t[2*e+1],a=e===d-1?u:e+1,f=t[2*a],g=t[2*a+1];if(r){const r=e===u?d-1:e-1,a=t[2*r],p=t[2*r+1];c[0]=a-n,c[1]=p-s,h[0]=f-n,h[1]=g-s,jt(c,c),jt(h,h);1-(.5*At(c,h)+.5)>i?(o.push(n,s),l.push(e)):(o.push(n,s,n,s),l.push(e,e))}else o.push(n,s,n,s),l.push(e,e)}n<f-1&&s&&s.push(o.length/2)}return{vertices:new Float32Array(o),splittedMap:l,holes:s}}function $t(t,e){let n=0,i=0;for(let r=0;r<t.length;r++){const{indices:o,vertices:s,splittedMap:a,topVertices:c,depth:h}=t[r],l=Math.min(h/2,e.bevelSize)>0?e.bevelSegments:0,u=t[r].holes||[];n+=o.length*(e.excludeBottom?1:2),i+=c.length/2*(e.excludeBottom?1:2);const d=2+2*l;let f=0,g=0;for(let t=0;t<u.length+1;t++){0===t?g=u.length?u[0]:s.length/2:(f=u[t-1],g=u[t]||s.length/2);n+=6*((a?a[g-1]+1:g)-(a?a[f]:f))*(d-1);const r=g-f;i+=r*d+(e.smoothBevel?0:l*r*2)}}const r={position:new Float32Array(3*i),indices:new(i>65535?Uint32Array:Uint16Array)(n),uv:new Float32Array(2*i)},o={vertex:0,index:0,ringPerimeter:0};for(let n=0;n<t.length;n++)Kt(t[n],r,o,e);for(let n=0;n<t.length;n++){const{holes:i,vertices:s}=t[n],a=s.length/2;let c=0,h=i&&i.length?i[0]:a;if(o.ringPerimeter=qt(t[n].topVertices,c,h),Nt(r,t[n],c,h,o,e),i)for(let s=0;s<i.length;s++)c=i[s],h=i[s+1]||a,o.ringPerimeter=qt(t[n].topVertices,c,h),Nt(r,t[n],c,h,o,e)}for(let t=0;t<r.uv.length;t++){const e=r.uv[t];e>0&&Math.round(e)===e?r.uv[t]=1:r.uv[t]=e%1}return r.normal=function(t,e){function n(t,e,n,i){t[0]=e,t[1]=n,t[2]=i}const i=[],r=[],o=[],s=[],a=[],c=[],h=t.length,l=new Float32Array(e.length);for(let u=0;u<h;){const h=3*t[u++],d=3*t[u++],f=3*t[u++];n(i,e[h],e[h+1],e[h+2]),n(r,e[d],e[d+1],e[d+2]),n(o,e[f],e[f+1],e[f+2]),Lt(s,i,r),Lt(a,r,o),kt(c,s,a);for(let t=0;t<3;t++)l[h+t]=l[h+t]+c[t],l[d+t]=l[d+t]+c[t],l[f+t]=l[f+t]+c[t]}for(var u=0;u<l.length;)n(c,l[u],l[u+1],l[u+2]),Pt(c,c),l[u++]=c[0],l[u++]=c[1],l[u++]=c[2];return l}(r.indices,r.position),r.boundingRect=t[0]&&t[0].rect,r}function Yt(t,e,n){const i=n.lineWidth,r=t.length,o=new Float32Array(2*r),s=n.translate||[0,0],a=n.scale||[1,1];for(let e=0,n=0;e<r;e++)o[n++]=t[e][0]*a[0]+s[0],o[n++]=t[e][1]*a[1]+s[1];Vt(o,0,r)<0&&Ht(o,2,0,r);const c=[],h=[],l=n.miterLimit,u=Zt(o,h,0,r,0,-i/2,l,!1);Ht(o,2,0,r);const d=Zt(o,c,0,r,0,-i/2,l,!1),f=(c.length+h.length)/2,g=new Float32Array(2*f);let p=0;const y=h.length/2;for(let t=0;t<h.length;t++)g[p++]=h[t];for(let t=0;t<c.length;t++)g[p++]=c[t];const x=new(f>65535?Uint32Array:Uint16Array)(3*(2*(r-1)+(f-2*r)));let v=0;for(let t=0;t<r-1;t++){const e=t+1;x[v++]=y-1-u[t],x[v++]=y-1-u[t]-1,x[v++]=d[t]+1+y,x[v++]=y-1-u[t],x[v++]=d[t]+1+y,x[v++]=d[t]+y,d[e]-d[t]==2?(x[v++]=d[t]+2+y,x[v++]=d[t]+1+y,x[v++]=y-u[e]-1):u[e]-u[t]==2&&(x[v++]=d[e]+y,x[v++]=y-1-(u[t]+1),x[v++]=y-1-(u[t]+2))}const m=n.bevelSize>0?Dt(g,[],n.bevelSize,null,!0):g,b=n.boundingRect,_=Xt(g,null,n.smoothSide,n.smoothSideThreshold);return{vertices:_.vertices,rawVertices:m,splittedMap:_.splittedMap,indices:x,topVertices:m,rect:{x:b.x*a[0]+s[0],y:b.y*a[1]+s[1],width:b.width*a[0],height:b.height*a[1]},depth:"function"==typeof n.depth?n.depth(e):n.depth,holes:[]}}function te(t,e){const n=[];for(let i=0;i<t.length;i++){const r=t[i],o=[],s=r.length;let a=r[s-1][0],c=r[s-1][1],h=0;for(let t=0;t<s;t++){let n=r[t][0],i=r[t][1];const s=n-a,l=i-c;h+=Math.sqrt(s*s+l*l),h>e&&(o.push(r[t]),h=0),a=n,c=i}o.length>=3&&n.push(o)}return n.length>0?n:null}function ee(t,e){const n=[];for(let i=0;i<t.length;i++){let r=t[i];r=St(r,e,!0),r.length>=3&&n.push(r)}return n.length>0?n:null}function ne(t,e){e=Object.assign({},e);const n=[1/0,1/0],i=[-1/0,-1/0];for(let e=0;e<t.length;e++)re(t[e][0],n,i);e.boundingRect=e.boundingRect||{x:n[0],y:n[1],width:i[0]-n[0],height:i[1]-n[1]},Qt(e);const r=[],o=e.translate||[0,0],s=e.scale||[1,1],a=e.boundingRect,c={x:a.x*s[0]+o[0],y:a.y*s[1]+o[1],width:a.width*s[0],height:a.height*s[1]},h=Math.min(a.width,a.height)/1e5;for(let n=0;n<t.length;n++){let i=te(t[n],h);if(!i)continue;const a=e.simplify/Math.max(s[0],s[1]);if(a>0&&(i=ee(i,a)),!i)continue;const{vertices:l,holes:u,dimensions:d}=_t.flatten(i);for(let t=0;t<l.length;)l[t]=l[t++]*s[0]+o[0],l[t]=l[t++]*s[1]+o[1];if(Jt(l,u),2!==d)throw new Error("Only 2D polygon points are supported");const f=e.bevelSize>0?Dt(l,u,e.bevelSize,null,!0):l,g=Ut(f,u,d),p=Xt(l,u,e.smoothSide,e.smoothSideThreshold);r.push({indices:g,vertices:p.vertices,rawVertices:l,topVertices:f,holes:p.holes,splittedMap:p.splittedMap,rect:c,depth:"function"==typeof e.depth?e.depth(n):e.depth})}return $t(r,e)}function ie(t,e){e=Object.assign({},e);const n=[1/0,1/0],i=[-1/0,-1/0];for(let e=0;e<t.length;e++)re(t[e],n,i);e.boundingRect=e.boundingRect||{x:n[0],y:n[1],width:i[0]-n[0],height:i[1]-n[1]},Qt(e);const r=e.scale||[1,1];null==e.lineWidth&&(e.lineWidth=1),null==e.miterLimit&&(e.miterLimit=2);const o=[];for(let n=0;n<t.length;n++){let i=t[n];const s=e.simplify/Math.max(r[0],r[1]);s>0&&(i=St(i,s,!0)),o.push(Yt(i,n,e))}return $t(o,e)}function re(t,e,n){for(let i=0;i<t.length;i++)e[0]=Math.min(t[i][0],e[0]),e[1]=Math.min(t[i][1],e[1]),n[0]=Math.max(t[i][0],n[0]),n[1]=Math.max(t[i][1],n[1])}var oe=Object.freeze({__proto__:null,triangulate:Ut,flatten:function(t){return _t.flatten(t)},offsetPolygon:Dt,extrudePolygon:ne,extrudePolyline:ie,extrudeGeoJSON:function(t,e){e=Object.assign({},e);const n=[],i=[],r=[],o=[],s=[1/0,1/0],a=[-1/0,-1/0];for(let e=0;e<t.features.length;e++){const c=t.features[e].geometry;if(c&&c.coordinates)switch(c.type){case"LineString":n.push(c.coordinates),r.push(e),re(c.coordinates,s,a);break;case"MultiLineString":for(let t=0;t<c.coordinates.length;t++)n.push(c.coordinates[t]),r.push(e),re(c.coordinates[t],s,a);break;case"Polygon":i.push(c.coordinates),o.push(e),re(c.coordinates[0],s,a);break;case"MultiPolygon":for(let t=0;t<c.coordinates.length;t++)i.push(c.coordinates[t]),o.push(e),re(c.coordinates[t][0],s,a)}}e.boundingRect=e.boundingRect||{x:s[0],y:s[1],width:a[0]-s[0],height:a[1]-s[1]};const c=e.depth;return{polyline:ie(n,Object.assign(e,{depth:function(e){return"function"==typeof c?c(t.features[r[e]]):c}})),polygon:ne(i,Object.assign(e,{depth:function(e){return"function"==typeof c?c(t.features[o[e]]):c}}))}}});function se(t,e,n={}){return void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]}function ae(t=[]){let e=0,n=0;const i=t.length;for(let o=0;o<i;o++){const{coordinate:i,lnglat:s,lnglats:a,xy:c,xys:h}=t[o],l=i||s||a||c||h||t[o];let u,d;Array.isArray(l)?(u=l[0],d=l[1]):l instanceof r.Coordinate&&(u=l.x,d=l.y),e+=u,n+=d}return new r.Coordinate(e/i,n/i)}function ce(t,e,n,i){if(void 0===e||"number"!=typeof e||0===e)return 0;let r;r=t instanceof o.BufferGeometry?t.attributes.position.array:Array.isArray(t)||t instanceof Float32Array?t:t.position;let s=0;if(r){i?(void 0===i[e]&&(i[e]=n.distanceToVector3(e,e).x),s=i[e]):s=n.distanceToVector3(e,e).x;const t=r.length;if(r[0]instanceof o.Vector3)for(let e=0;e<t;e++)r[e].z+=s;else for(let e=0;e<t;e+=3)r[e+2]+=s}return s}function he(t){const e=t.length;let n=0;for(let i=0;i<e;i++){const{count:e}=t[i].position;n+=e}return new Float32Array(3*n)}function le(t=[]){const e=t.length,n=new Float64Array(2*e);for(let i=0;i<e;i++){let e,r;const o=t[i];o.x?(e=o.x,r=o.y):(e=o[0],r=o[1]),n[2*i]=e,n[2*i+1]=r}return n.buffer}const ue=new o.Color("#fff"),de=new o.Color("#fff");function fe(t,e,n,i){const{position:r,normal:s,uv:c,indices:h}=ge(t,e,n,i),l=new Float32Array(r.length);l.fill(1,0,r.length);const u=new o.BufferGeometry;return a(u,"color",new o.BufferAttribute(l,3)),a(u,"normal",new o.BufferAttribute(s,3)),a(u,"position",new o.BufferAttribute(r,3)),a(u,"uv",new o.BufferAttribute(c,2)),u.setIndex(new o.Uint32BufferAttribute(h,1)),u}function ge(t,e,n,i,r,o){const s=ye(t,n,i,r,!1);if(!s)return null;o?(null==o[e]&&(o[e]=n.distanceToVector3(e,e).x),e=o[e]):e=n.distanceToVector3(e,e).x;const{position:a,normal:c,uv:h,indices:l}=ne(s,{depth:e});return{position:a,normal:c,uv:h,indices:l}}function pe(t,e,n,i){void 0===i&&(i=0);const r=t.attributes.position.array,s=r.length;let c;if(de.setStyle(e),ue.setStyle(n),Array.isArray(i)){let t=0;for(let e=0,n=i.length;e<n;e++){const{count:n}=i[e].position;t+=3*n}c=new Float32Array(t)}else c=new Float32Array(r.length);if(Array.isArray(i))for(let t=0,e=i.length;t<e;t++){const{middleZ:e,start:n,end:o}=i[t].position;for(let t=n;t<o;t+=3){r[t+2]>e?(c[t]=ue.r,c[t+1]=ue.g,c[t+2]=ue.b):(c[t]=de.r,c[t+1]=de.g,c[t+2]=de.b)}}else for(let t=0;t<s;t+=3){r[t+2]>i?(c[t]=ue.r,c[t+1]=ue.g,c[t+2]=ue.b):(c[t]=de.r,c[t+1]=de.g,c[t+2]=de.b)}return a(t,"color",new o.BufferAttribute(c,3,!0)),c}function ye(t,e,n,i,o=!1){if(!t)return null;let s=[];if(t instanceof r.MultiPolygon)s=t.getGeometries().map((r=>xe(r,e,n||t.getCenter(),i,o)));else if(t instanceof r.Polygon){const r=xe(t,e,n||t.getCenter(),i,o);s.push(r)}else if(F(t))if(D(t)){const r=Q(t);for(let a=0,c=r.length;a<c;a++)s.push(xe(r[a],e,n||J(t),i,o))}else{const r=xe(t,e,n||J(t),i,o);s.push(r)}return s}function xe(t,e,n,i,o=!1){let s,a,c;if(F(t)){const e=H(t);s=e[0],a=e.slice(1,e.length),n=n||J(t)}else t instanceof r.Polygon&&(s=t.getShell(),a=t.getHoles(),n=n||t.getCenter());i=i||e.coordinateToVector3(n),c=o?e.coordinatiesToGLFloatArray(s,i).positons2d:e.coordinatiesToGLArray(s,i);const h=[o?c.buffer:c];if(a&&a.length>0)for(let t=0,n=a.length;t<n;t++){let n;n=o?e.coordinatiesToGLFloatArray(a[t],i).positons2d:e.coordinatiesToGLArray(a[t],i),h.push(o?n.buffer:n)}return h}function ve(t){if(!t)return null;let e=[];if(t instanceof r.MultiPolygon)e=t.getGeometries().map((t=>me(t,!1)));else if(t instanceof r.Polygon){const n=me(t,!1);e.push(n)}else if(F(t))if(D(t)){const n=Q(t);for(let t=0,i=n.length;t<i;t++)e.push(me(n[t],!0))}else{const n=me(t,!0);e.push(n)}return e}function me(t,e){let n,i;if(e){const e=H(t);n=e[0],i=e.slice(1,e.length)}else t instanceof r.Polygon&&(n=t.getShell(),i=t.getHoles());const o=[le(n)];if(i&&i.length>0)for(let t=0,e=i.length;t<e;t++){const e=le(i[t]);o.push(e)}return o}var be=Object.freeze({__proto__:null,getExtrudeGeometry:fe,getExtrudeGeometryParams:ge,initVertexColors:pe,getPolygonPositions:ye,getSinglePolygonPositions:xe,getPolygonArrayBuffer:ve,getSinglePolygonArrayBuffer:me});function _e(t,e,n,i=!0){const s=[];let a,c;if(Array.isArray(t)&&t[0]instanceof o.Vector3)for(let e=0,n=t.length;e<n;e++){const n=t[e];s.push(n)}else{Array.isArray(t)&&(t=new r.LineString(t));const o=0;let h,l;R(t)?(h=H(t),n||(l=J(t))):t instanceof r.LineString&&(h=t.getCoordinates(),n||(l=t.getCenter()));const u=e.coordinateToVector3(n||l);if(i)for(let t=0,n=h.length;t<n;t++){const n=h[t],i=e.coordinateToVector3(n,o).sub(u);s.push(i)}else{const t=e.coordinatiesToGLFloatArray(h,u);a=t.positions,c=t.positons2d}}if(!i)return{positions:a,positionsV:s,positions2d:c,arrayBuffer:c.buffer};c=new Float32Array(2*s.length),a=new Float32Array(3*s.length);for(let t=0,e=s.length;t<e;t++){const e=3*t,n=s[t];a[e]=n.x,a[e+1]=n.y,a[e+2]=n.z;const i=2*t;c[i]=n.x,c[i+1]=n.y}return{positions:a,positionsV:s,positions2d:c,arrayBuffer:c.buffer}}function we(t,e,n,i){const r=[],o=[],s=[];for(let e=0,n=t.length;e<n;e++){const n=t[e];for(let t=0,e=n.length;t<e;t++){const e=n[t];if(s.length>0){e.join(",").toString()!==s[s.length-1].join(",").toString()&&s.push(e)}else s.push(e)}}for(let t=0,a=s.length;t<a;t++){const a=s[t];let c;const h=a.join(",").toString();c=n&&n[h]?n[h]:e.coordinateToVector3(a,0).sub(i),o.push(c),r.push(c.x,c.y,c.z)}return{positions:r,positionsV:o,lnglats:s}}function Me(t,e=1,n=1,i,r){const o=_e(t,i,r).positionsV,s=[];for(let t=0,e=o.length;t<e;t++){const e=o[t];s.push([e.x,e.y])}const{indices:a,position:c,normal:h,uv:l}=ie([s],{lineWidth:e,depth:n});return{position:c,normal:h,indices:a,uv:l}}function Oe(t){let e,n=[];return t instanceof r.MultiLineString?(n=t.getGeometries(),e=t.getCenter()):t instanceof r.LineString?(n.push(t),e=t.getCenter()):R(t)&&(e=J(t),D(t)?n=Q(t):n.push(t)),{lineStrings:n,center:e}}function Se(t){const e=new Float32Array(2*t.length-6);let n=0;for(let i=0,r=t.length/3;i<r;i++){const o=t[3*i],s=t[3*i+1],a=t[3*i+2];if(i>0&&i<r-1){const t=3*n;e[t]=o,e[t+1]=s,e[t+2]=a,n++}const c=3*n;e[c]=o,e[c+1]=s,e[c+2]=a,n++}return e}function Ae(t){let e=0;const n=t.length;if(1===n)return t[0];for(let i=0;i<n;i++)e+=t[i].length;const i=new Float32Array(e);let r=0;for(let e=0;e<n;e++)i.set(t[e],r),r+=t[e].length;return i}function je(t){return t instanceof r.LineString?le(t.getCoordinates()):G(t)?le(t.geometry.coordinates):void 0}let Ce;function Te(){return Ce||(Ce=new o.BufferGeometry,a(Ce,"position",new o.BufferAttribute(new Float32Array(3),3))),Ce}var Le=Object.freeze({__proto__:null,getLinePosition:_e,getExtrudeLineGeometry:function(t,e=1,n=1,i,r){const{indices:s,position:c,normal:h,uv:l}=Me(t,e,n,i,r),u=new o.BufferGeometry;return a(u,"position",new o.BufferAttribute(c,3)),a(u,"normal",new o.BufferAttribute(h,3)),a(u,"uv",new o.BufferAttribute(l,2)),u.setIndex(new o.BufferAttribute(s,1)),u},getChunkLinesPosition:we,getExtrudeLineParams:Me,LineStringSplit:Oe,setLineSegmentPosition:function(t,e){for(let n=0,i=e.length;n<i;n++){const r=e[n];n>0&&n<i-1&&t.push(r.x,r.y,r.z),t.push(r.x,r.y,r.z)}},getLineSegmentPosition:Se,mergeLinePositions:Ae,getLineArrayBuffer:je,getDefaultLineGeometry:Te});let Pe;var ke;function Be(){return r.worker||console.error("maptalks.worker is not defined,You can't use ThreeVectorTileLayer"),!ke&&Pe&&(ke=new Pe("__maptalks.three__")),ke}function ze(t,e,n={}){return void 0!==t&&"number"==typeof t&&0!==t?(void 0===n[t]&&(n[t]=e.distanceToVector3(t,t).x),n[t]):0}function Ee(t,e,n,i,r=[]){const o=n.isMercator();let s,a,c;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(c=n.coordinateToVector3(e));const h=[],l=[],u={},d=t.length;for(let s=0;s<d;s++){const a=t[s],d=r[s]?r[s]:G(i[s])?i[s].properties:i[s].getProperties()||{};e||(c=n.coordinateToVector3(d.center));let f=d.width||1,g=d.height||1,p=d.bottomHeight||0;f=ze(f,n,u),g=ze(g,n,u),p=ze(p,n,u);const y=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];let r;r=o?je(i):_e(i,n,e,!1).arrayBuffer,l.push(r),y.push(r)}const x={id:d.id,data:y,height:g,width:f,bottomHeight:p};o&&(x.center=[c.x,c.y]),h.push(x)}return{datas:h,transfer:l,glRes:s,matrix:a,center:o?[c.x,c.y]:null}}function Ve(t,e,n,i,r=[]){const o=n.isMercator();let s,a,c;if(o){const t=n.getMap();s=t.getGLRes(),a=t.getSpatialReference().getTransformation().matrix}e&&(c=n.coordinateToVector3(e));const h=[],l=[],u={},d=t.length;for(let s=0;s<d;s++){const a=t[s],d=r[s]?r[s]:G(i[s])?i[s].properties:i[s].getProperties()||{};e||(c=n.coordinateToVector3(d.center));let f=d.bottomHeight||0;f=ze(f,n,u);const g=[];for(let t=0,i=a.length;t<i;t++){const i=a[t];if(o){const t=je(i);g.push(t),g.push(t)}else{const t=_e(i,n,e,!1).arrayBuffer;l.push(t),g.push(t)}}const p={id:d.id,data:g,bottomHeight:f};o&&(p.center=[c.x,c.y]),h.push(p)}return{datas:h,transfer:l,glRes:s,matrix:a,center:o?[c.x,c.y]:null}}function Ue(t){return t.map((t=>t.data))}function Ie(t){return t.map((t=>t.baseObject.getOptions()))}r.worker&&(Pe=class extends r.worker.Actor{test(t,e){this.send(t,null,e)}pushQueue(t={}){const{type:e,data:n,callback:i,layer:r,key:o,center:s,lineStrings:a,options:c,id:h}=t;let l;e.indexOf("ExtrudePolygon")>-1?l=function(t=[],e,n,i=[]){const r=n.isMercator();let o,s,a;if(r){const t=n.getMap();o=t.getGLRes(),s=t.getSpatialReference().getTransformation().matrix}e&&(a=n.coordinateToVector3(e));const c=t.length,h=[],l=[],u={};for(let o=0;o<c;o++){const s=t[o],c=s,d=i[o]?i[o]:F(c)?c.properties:c.getProperties()||{};let f;e||(a=n.coordinateToVector3(d.center)),f=r?ve(s):ye(s,n,d.center||e,a,!0);for(let t=0,e=f.length;t<e;t++){const e=f[t];for(let t=0,n=e.length;t<n;t++)l.push(e[t])}let g=d.height||1,p=d.bottomHeight||0;g=ze(g,n,u),p=ze(p,n,u);const y={id:d.id,data:f,height:g,bottomHeight:p};r&&(y.center=[a.x,a.y]),h.push(y),c._properties&&delete c._properties}return{datas:h,transfer:l,glRes:o,matrix:s,center:r?[a.x,a.y]:null}}(n,s,r,c):"ExtrudeLines"===e?l=Ee(n,s,r,a):"Point"===e||("Line"===e||"FatLine"===e?l=Ve(n,s,r,a,c):"Lines"===e||"FatLines"===e?l=Ve(n,s,r,a):"ExtrudeLine"===e&&(l=Ee(n,s,r,a,c))),l?this.send({type:e,datas:l.datas,glRes:l.glRes,matrix:l.matrix,center:l.center},l.transfer,(function(t,e){t&&console.error(t),e.key=o,e.id=h,i(e)})):console.error(`not support '${e}' worker`)}});class Re{constructor(){this.queueMap={},this.tempQueue=[],this.time=this.getCurrentTime(),this.deQueueCount=5,this.resultQueue=[]}getCurrentTime(){return r.Util.now()}loop(){this.deQueue()}push(t){return this.tempQueue.push(t),t.id&&(this.queueMap[t.id]=t),this}reset(){return this.time=this.getCurrentTime(),this.tempQueue=[],this}pushResult(t){if(t)return Array.isArray(t)||(t=[t]),t.forEach((t=>{this.resultQueue.push(t)})),this}deQueue(){if(!this.resultQueue.length)return this;const t=this.deQueueCount;return(this.resultQueue.slice(0,t)||[]).forEach((t=>{const{id:e}=t;if(this.queueMap[e]){const{baseObject:n}=this.queueMap[e];n&&n._workerLoad&&n._workerLoad(t),delete this.queueMap[e]}})),this.resultQueue.splice(0,t),this}}const Fe=new class extends Re{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Be().pushQueue({type:"ExtrudePolygon",layer:this.tempQueue[0].layer,data:Ue(this.tempQueue),options:Ie(this.tempQueue),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},Ge=new class extends Re{loop(){if(this.tempQueue.length){const t=Be();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudePolygons",layer:e.layer,data:e.data,key:e.key,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},Ze=new class extends Re{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Be().pushQueue({type:"ExtrudeLine",layer:this.tempQueue[0].layer,data:Ue(this.tempQueue),options:Ie(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},De=new class extends Re{loop(){if(this.tempQueue.length){const t=Be();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"ExtrudeLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},He=new class extends Re{constructor(){super(),this.deQueueCount=200}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Be().pushQueue({type:"Line",layer:this.tempQueue[0].layer,data:Ue(this.tempQueue),options:Ie(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},Je=new class extends Re{loop(){if(this.tempQueue.length){const t=Be();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"Lines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},Qe=new class extends Re{constructor(){super(),this.deQueueCount=100}loop(){if((this.getCurrentTime()-this.time>=32||this.tempQueue.length>=1e3)&&this.tempQueue.length){Be().pushQueue({type:"FatLine",layer:this.tempQueue[0].layer,data:Ue(this.tempQueue),options:Ie(this.tempQueue),lineStrings:this.tempQueue.map((t=>t.lineString)),callback:t=>{this.pushResult(t)}}),this.reset()}super.loop()}},We=new class extends Re{loop(){if(this.tempQueue.length){const t=Be();this.tempQueue.forEach((e=>{t.pushQueue({id:e.id,type:"FatLines",layer:e.layer,data:e.data,key:e.key,lineStrings:e.lineStrings,center:e.center,callback:t=>{this.pushResult(t)}})})),this.reset()}super.loop()}},qe={isRunning:!1,loop(){Fe.loop(),Ge.loop(),Ze.loop(),De.loop(),He.loop(),Je.loop(),Qe.loop(),We.loop(),r.Util.requestAnimFrame(qe.loop)},star(){qe.isRunning||(qe.isRunning=!0,qe.loop())}};function Ne(t){const e=[];return t&&t.length&&t.forEach((t=>{t=t instanceof o.Color?t:new o.Color(t),e.push(t.r,t.g,t.b)})),e}const Ke={altitude:0,bottomHeight:0,colors:null};class Xe extends v{constructor(t,e,n,i){e=r.Util.extend({},Ke,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{lineStrings:s,center:h}=Oe(t),{asynchronous:l}=e;let u;if(l){u=Te();const n=r.Util.GUID();this.getOptions().id=n,this.getOptions().center=h,He.push({id:n,data:s,layer:i,key:e.key,lineString:t,baseObject:this})}else{const t=[];for(let e=0,n=s.length;e<n;e++){const n=s[e],{positions:r}=_e(n,i,h,!1);t.push(Se(r))}const r=Ae(t);u=new o.BufferGeometry,a(u,"position",new o.BufferAttribute(r,3)),ce(u,e.bottomHeight,i);const l=Ne(e.colors);l&&l.length&&(a(u,"color",new o.Float32BufferAttribute(l,3)),n.vertexColors=c())}this._createLineSegments(u,n);const{altitude:d}=e,f=i.distanceToVector3(d,d).x,g=i.coordinateToVector3(h,f);this.getObject3d().position.copy(g),this.type="Line"}_workerLoad(t){const e=new o.BufferGeometry;a(e,"position",new o.BufferAttribute(new Float32Array(t.position),3));const n=Ne(this.getOptions().colors),i=this.getObject3d(),r=i.material;n&&n.length&&(a(e,"color",new o.Float32BufferAttribute(n,3)),r.vertexColors=c()),this._computeLineDistances(e),i.geometry=e,i.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const $e={bottomHeight:0,width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61"};class Ye extends v{constructor(t,e,n,i){e=r.Util.extend({},$e,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{height:o,width:s,bottomColor:a,topColor:h,bottomHeight:l,altitude:u,asynchronous:d}=e,f=i.distanceToVector3(o,o).x,g=i.distanceToVector3(s,s).x,{lineStrings:p,center:y}=Oe(t);let x;if(d){x=S();const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=y,Ze.push({id:e,data:p,layer:i,center:y,lineString:t,baseObject:this})}else{const t=[];let e=0;const r={};for(let n=0,o=p.length;n<o;n++){const o=Me(p[n],g,f,i,y);e=ce(o,l,i,r),t.push(o)}x=m(t),h&&(pe(x,a,h,e+f/2),n.vertexColors=c())}this._createMesh(x,n);const v=i.distanceToVector3(u,u).x,b=i.coordinateToVector3(y,v);this.getObject3d().position.copy(b),this.type="ExtrudeLine"}_workerLoad(t){const e=w(t),{topColor:n,bottomColor:i,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(n){const t=this.getLayer();pe(e,i,n,t.distanceToVector3(r,r).x+t.distanceToVector3(o,o).x/2),a.vertexColors=c()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const tn={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61"};class en extends v{constructor(t,e,n,i){e=r.Util.extend({},tn,e,{layer:i,polygon:t}),super(),this._initOptions(e);const{height:o,topColor:s,bottomColor:a,altitude:h,bottomHeight:l,asynchronous:u}=e;let d;const f=F(t)?J(t):t.getCenter();if(u){d=S();const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=f,Fe.push({data:t,layer:i,id:e,baseObject:this})}else{d=fe(t,o,i);const e=ce(d,l,i);if(s){pe(d,a,s,e+i.distanceToVector3(o,o).x/2),n.vertexColors=c()}}this._createMesh(d,n);const g=i.distanceToVector3(h,h).x,p=i.coordinateToVector3(f,g);this.getObject3d().position.copy(p),this.type="ExtrudePolygon"}_workerLoad(t){const e=w(t),{topColor:n,bottomColor:i,bottomHeight:r,height:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(n){const t=this.getLayer();pe(e,i,n,t.distanceToVector3(r,r).x+t.distanceToVector3(o,o).x/2),a.vertexColors=c()}s.geometry=e,s.material.needsUpdate=!0,this._fire("workerload",{target:this})}}const nn={altitude:0,coordinate:null};class rn extends v{constructor(t,e={},n){e.coordinate||(console.warn("coordinate is null,it is important to locate the model"),e.coordinate=n.getMap().getCenter()),e=r.Util.extend({},nn,e,{layer:n,model:t}),super(),this._initOptions(e),this._createGroup(),this.getObject3d().add(t);const{altitude:i,coordinate:o}=e,s=n.distanceToVector3(i,i).x,a=n.coordinateToVector3(o,s);this.getObject3d().position.copy(a),this.type="Model"}}const on=Math.PI/180;function sn(t){return t.getCoordinates().map((t=>t.toArray()))}function an(t){return t*on}function cn(t,e){if(!t||!e)return 0;Array.isArray(t)||(t=t.toArray()),Array.isArray(e)||(e=e.toArray());let n=an(t[1]);const i=an(e[1]),r=n-i,o=an(t[0])-an(e[0]);return n=2*Math.asin(Math.sqrt(Math.pow(Math.sin(r/2),2)+Math.cos(n)*Math.cos(i)*Math.pow(Math.sin(o/2),2))),n*=6378137,Math.round(1e5*n)/1e5}function hn(t,e){const{len:n,c1:i,c2:r}=t,o=r[0]-i[0],s=r[1]-i[1],a=e/n;return[i[0]+a*o,i[1]+a*s]}function ln(t,e=10){e=Math.max(e,1),Array.isArray(t)||(t=sn(t));const n=t.length;let i=[],r=0;for(let e=0;e<n-1;e++){const n=cn(t[e],t[e+1]),o=Math.floor(n);i.push({c1:t[e],len:o,c2:t[e+1]}),r+=o}if(r<=e){return i.map((t=>[t.c1,t.c2]))}if(1===i.length&&i[0].len<=e)return[[i[0].c1,i[0].c2]];const o=i.length;let s,a=0,c=0;const h=[];let l=[i[0].c1];for(;a<o;){const{len:t,c2:n}=i[a];if(c+=t,c<e&&(l.push(n),a===o-1&&h.push(l),a++),c===e&&(l.push(n),c=0,h.push(l),l=[n],a++),c>e){const n=t-c+e;s=hn(i[a],n),l.push(s),h.push(l),c=0,i[a].c1=s,i[a].len=t-n,l=[],l.push(s)}}return h}var un=Object.freeze({__proto__:null,distance:cn,lineLength:function(t){let e=t;Array.isArray(t)||(e=sn(t));let n=0;for(let t=0,i=e.length;t<i-1;t++)n+=cn(e[t],e[t+1]);return n},lineSlice:ln});const dn=1e3;function fn(t,e,n,i){const r=e.length;t.attributes.normal.count=r,t.attributes.position.count=r;const o=t.attributes.position.array,s=t.attributes.normal.array;for(let t=0;t<r;t++)o[t]=e[t],s[t]=n[t];t.index.count=i.length;for(let e=0,n=i.length;e<n;e++)t.index.array[e]=i[e]}const gn={trail:5,chunkLength:50,width:2,height:1,speed:1,altitude:0,interactive:!1};class pn extends v{constructor(t,e,n,i){e=r.Util.extend({},gn,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{width:s,height:c,altitude:h,speed:l,chunkLength:u,trail:d}=e;let f,g;R(t)?(f=J(t),g=H(t)):(f=t.getCenter(),g=t);const p=ln(g,u),y=i.coordinateToVector3(f),x={};for(let t=0,e=p.length;t<e;t++){const e=p[t];for(let t=0,n=e.length;t<n;t++){const n=e[t],r=n.join(",").toString();x[r]||(x[r]=i.coordinateToVector3(n).sub(y))}}const v=we(p.slice(0,1),i,x,y).positionsV,m=new o.BufferGeometry,b=new Float32Array(3e3),_=new Float32Array(3e3),w=new Uint16Array(dn);a(m,"position",new o.BufferAttribute(b,3)),a(m,"normal",new o.BufferAttribute(_,3)),m.setIndex(new o.BufferAttribute(w,1));const M=i.distanceToVector3(s,s).x,O=i.distanceToVector3(c,c).x,S=Me(v,M,O,i);fn(m,S.position,S.normal,S.indices),this._createMesh(m,n);const A=i.distanceToVector3(h,h).x,j=i.coordinateToVector3(f,A);this.getObject3d().position.copy(j),this._params={index:0,chunkLines:p,geometries:[],layer:i,trail:Math.max(1,d),lineWidth:M,depth:O,speed:Math.min(1,l),idx:0,loaded:!1,positionMap:x,centerPt:y},this._init(this._params),this.type="ExtrudeLineTrail"}_init(t){const{layer:e,trail:n,lineWidth:i,depth:r,chunkLines:o,positionMap:s,centerPt:a}=t,c=o.length,h=[];for(let t=0;t<c;t++){const c=we(o.slice(t,t+n),e,s,a).positionsV;h.push(Me(c,i,r,e))}this._params.geometries=h,this._params.loaded=!0}_animation(){const{index:t,geometries:e,speed:n,idx:i,chunkLines:r,trail:o,lineWidth:s,depth:a,loaded:c,layer:h,positionMap:l,centerPt:u}=this._params;if(!c)return;const d=Math.round(t);if(d>i){this._params.idx++;let t=e[d];if(!t){t=Me(we(r.slice(d,d+o),h,l,u).positionsV,s,a,h),e[d]=t}const n=this.getObject3d();fn(n.geometry,t.position,t.normal,t.indices),n.geometry.attributes.position.needsUpdate=!0,n.geometry.attributes.normal.needsUpdate=!0,n.geometry.index.needsUpdate=!0}t>=r.length-1&&(this._params.index=-1,this._params.idx=-1),this._params.index+=n}}const yn=["click","mousemove","mousedown","mouseup","dblclick","contextmenu"].join(" ").toString(),xn=new o.MeshBasicMaterial;xn.vertexColors=c();const vn=t=>class extends t{_initBaseObjectsEvent(t){if(t&&Array.isArray(t)&&t.length)for(let e=0,n=t.length;e<n;e++){const n=t[e];this._proxyEvent(n)}return this}_proxyEvent(t){t.on("add",(t=>{this._showGeometry(t.target,!0)})),t.on("remove",(t=>{this._showGeometry(t.target,!1)})),t.on("mouseout",(t=>{this._mouseover=!1,this.fire("mouseout",Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))})),t.on(yn,(t=>{this.fire(t.type,Object.assign({},t,{target:this,selectMesh:this.getSelectMesh?this.getSelectMesh():null}))}))}_getHideGeometryIndex(t){const e=[];let n=0;for(let i=0,r=this._geometriesAttributes.length;i<r;i++)!0===this._geometriesAttributes[i].hide&&(e.push(i),n+=this._geometriesAttributes[i][t].count);return{indexs:e,count:n}}_updateAttribute(t,e){const{indexs:n}=this._getHideGeometryIndex(e),i=this._geometryCache.attributes[e].array,r=i.length;for(let e=0;e<r;e++)t.array[e]=i[e];let s=NaN;this.getObject3d()instanceof o.LineSegments&&(s=0);for(let i=0;i<n.length;i++){const r=n[i],{start:o,end:a}=this._geometriesAttributes[r][e];for(let e=o;e<a;e++)t.array[e]=s}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.position,"position"),r.attributes.position.needsUpdate=!0,this.isHide=e}return this}getSelectMesh(){const t=this._getIndex();if(null!=t)return{data:this._datas[t],baseObject:this._baseObjects[t]}}_getIndex(t){return null==t&&(t=this.faceIndex||this.index),t}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:n}=this,i=n.length,r=he(n);let s=0;for(let t=0;t<i;t++){const i=e.getColor(),o=i.getHex();this._colorMap[o]=t;const{count:a}=n[t].position;this._datas[t].colorIndex=o;for(let t=0;t<a;t++)r[s]=i.r,r[s+1]=i.g,r[s+2]=i.b,s+=3}a(t,"color",new o.BufferAttribute(r,3,!0));const c=e.getColor().getHex(),h=new o.Mesh(t,xn);h.position.copy(this.getObject3d().position),h._colorIndex=c,this.setPickObject3d(h)}},mn={altitude:0,height:1,bottomHeight:0,topColor:null,bottomColor:"#2d2f61"},bn=new r.Coordinate(0,0);class _n extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=t.length;0===o&&console.error("polygons is empty");let s=1/0,a=1/0,h=-1/0,l=-1/0;for(let e=0;e<o;e++){const n=t[e],i=n.getCenter?n.getCenter():J(n,bn);let o,c;Array.isArray(i)?(o=i[0],c=i[1]):i instanceof r.Coordinate&&(o=i.x,c=i.y),s=Math.min(s,o),a=Math.min(a,c),h=Math.max(h,o),l=Math.max(l,c)}const u=new r.Coordinate((s+h)/2,(a+l)/2);e=r.Util.extend({},mn,e,{layer:i,polygons:t,coordinate:u});const{topColor:d,bottomColor:f,altitude:g,asynchronous:p}=e;let y;const x=[],v=[],b=[];if(super(),p)y=S(),Ge.push({id:r.Util.GUID(),layer:i,key:e.key,center:u,data:t,baseObject:this});else{const e=i.coordinateToVector3(u),r=[];let s=0,a=0,h=0,l=0;const g={};for(let n=0;n<o;n++){const o=t[n],c=F(o)?o.properties:o.getProperties()||{},d=c.height||1,f=c.bottomHeight||0,p=ge(o,d,i,u,e,g);r.push(p);const y=ce(p,f,i,g),{position:x,normal:m,uv:_,indices:w}=p,M=w.length/3;v[n]=[s+1,s+M],s+=M;const O=x.length/3,S=m.length/3,A=_.length/2;b[n]={position:{middleZ:y+g[d]/2,count:O,start:a,end:a+3*O},normal:{count:S,start:h,end:h+3*S},uv:{count:A,start:l,end:l+2*A},hide:!1},a+=3*O,h+=3*S,l+=2*A}y=m(r),d&&(pe(y,f,d,b),n.vertexColors=c())}this._initOptions(e),this._createMesh(y,n);const _=i.distanceToVector3(g,g).x,w=i.coordinateToVector3(u,_);this.getObject3d().position.copy(w),this._faceMap=v,this._baseObjects=x,this._datas=t,this._geometriesAttributes=b,this.faceIndex=null,this._geometryCache=y.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(x),p||(this._setPickObject3d(),this._init()),this.type="ExtrudePolygons"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,F(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new en(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{faceMap:e,geometriesAttributes:n}=t;this._faceMap=e,this._geometriesAttributes=n;const i=w(t);this._geometryCache=M(i);const{topColor:r,bottomColor:o}=this.getOptions(),s=this.getObject3d(),a=s.material;if(r&&(pe(i,o,r,n),a.vertexColors=c()),s.geometry=i,s.material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}function wn(t,e,n){const i=t.project(n),r=e.width/2,o=e.height/2;return{x:Math.round(i.x*r+r),y:Math.round(-i.y*o+o)}}var Mn=Object.freeze({__proto__:null,vectors2Pixel:function(t,e,n,i=0,r){return t[0]instanceof o.Vector3||(t=function(t,e=0,n){const i=[],r={};for(let s=0,a=t.length;s<a;s+=3){let a=t[s],c=t[s+1],h=t[s+2];e>0&&(h+=se(e,n,r)),i.push(new o.Vector3(a,c,h))}return i}(t,i,r)),t.map((t=>wn(t,e,n)))},vector2Pixel:wn});const On={altitude:0,height:0,color:null},Sn=new o.Vector3;class An extends v{constructor(t,e,n,i){e=r.Util.extend({},On,e,{layer:i,coordinate:t}),super();let{height:s,altitude:c,color:h,size:l}=e;const u=[],d=[];h&&(h=h instanceof o.Color?h:new o.Color(h),d.push(h.r,h.g,h.b));const f=i.distanceToVector3(s,s).x,g=i.coordinateToVector3(t,f);u.push(0,0,g.z);const p=new o.BufferGeometry;a(p,"position",new o.Float32BufferAttribute(u,3,!0)),d.length&&a(p,"color",new o.Float32BufferAttribute(d,3,!0)),void 0!==l&&a(p,"size",new o.Float32BufferAttribute([l],1,!0)),e.positions=g,this._initOptions(e),this._createPoints(p,n);const y=i.distanceToVector3(c,c).x,x=new o.Vector3(g.x,g.y,y);this.getObject3d().position.copy(x),this.type="Point"}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().positions,o=this.getOptions().altitude;let s=this.getObject3d().material.size;void 0===s&&(s=this.options.size||1);const a=this.getMap().coordToContainerPoint(t),c=e.distanceToVector3(o,o).x;Sn.x=r.x,Sn.y=r.y,Sn.z=r.z+c;const h=wn(Sn,n,i);return Math.sqrt(Math.pow(a.x-h.x,2)+Math.pow(a.y-h.y,2))<=s/2}}function jn(t,e){const{minx:n,miny:i,maxx:r,maxy:o}=t,[s,a]=e;return n<=s&&s<=r&&i<=a&&a<=o}class Cn{constructor(t,e,n,i){this.minlng=t,this.minlat=e,this.maxlng=n,this.maxlat=i,this.minx=1/0,this.miny=1/0,this.maxx=-1/0,this.maxy=-1/0,this.coordinates=[],this.positions=[],this.indexs=[],this.key=null}updateBBoxPixel(t){let e=1/0,n=1/0,i=-1/0,o=-1/0;const{minlng:s,minlat:a,maxlng:c,maxlat:h}=this;return[[s,a],[s,h],[c,a],[c,h]].map((t=>new r.Coordinate(t))).map((e=>t.coordToContainerPoint(e))).forEach((t=>{e=Math.min(e,t.x),n=Math.min(n,t.y),i=Math.max(i,t.x),o=Math.max(o,t.y)})),this.minx=e,this.miny=n,this.maxx=i,this.maxy=o,this}containsCoordinate(t){let e,n;Array.isArray(t)?(e=t[0],n=t[1]):t instanceof r.Coordinate&&(e=t.x,n=t.y);const{minlng:i,minlat:o,maxlng:s,maxlat:a}=this;return i<=e&&e<=s&&o<=n&&n<=a}isRecCross(t,e){const{x:n,y:i}=t,r={minx:n-e/2,miny:i-e/2,maxx:n+e/2,maxy:i+e/2},{minx:o,miny:s,maxx:a,maxy:c}=r;return!!(jn(this,[o,s])||jn(this,[o,c])||jn(this,[a,s])||jn(this,[a,c])||jn(r,[this.minx,this.miny])||jn(r,[this.minx,this.maxy])||jn(r,[this.maxx,this.miny])||jn(r,[this.maxx,this.maxy]))}static initGrids(t,e,n,i){const r=[],o=(n-t)/30,s=(i-e)/30;let a=t,c=e;for(let n=0;n<30;n++){a=t+n*o;for(let t=0;t<30;t++){c=e+t*s;const i=new Cn(a,c,a+o,c+s);i.key=t+"-"+n,r.push(i)}}return{grids:r,averageX:o,averageY:s,ROWS:30,COLS:30}}}const Tn={altitude:0},Ln=new o.Vector3;function Pn(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n}class kn extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]),e=r.Util.extend({},Tn,e,{layer:i,points:t});let s=1/0,c=1/0,h=-1/0,l=-1/0;for(let e=0,n=t.length;e<n;e++){const{coordinate:n}=t[e];let i,o;Array.isArray(n)?(i=n[0],o=n[1]):n instanceof r.Coordinate&&(i=n.x,o=n.y),t[e].coords=[i,o],s=Math.min(s,i),c=Math.min(c,o),h=Math.max(h,i),l=Math.max(l,o)}const u=i.coordinateToVector3([(s+h)/2,(c+l)/2]),{grids:d,averageX:f,averageY:g,ROWS:p,COLS:y}=Cn.initGrids(s,c,h,l);d.length;const x=new Float32Array(3*t.length),v=[],m=new Float32Array(3*t.length),b=new Float32Array(t.length),_=[],w=[],M={};let O=0,S=!1,A=!1;const j=new o.Vector3(0,0,0);for(let e=0,n=t.length;e<n;e++){let{coordinate:n,height:r,color:a,size:h,coords:l}=t[e];const y=3*e;a&&(S=!0,a=a instanceof o.Color?a:new o.Color(a),m[y]=a.r,m[y+1]=a.g,m[y+2]=a.b),h&&(A=!0,b[e]=h,O=Math.max(O,h));const _=se(r,i,M),C=i.coordinateToVector3(n,_);j.x=C.x,j.y=C.y,j.z=C.z,j.sub(u),x[y]=j.x,x[y+1]=j.y,x[y+2]=j.z,v.push(C),w[e]={position:{count:1,start:3*e,end:3*e+3},hide:!1};let T=Pn((l[1]-c)/g,4),L=Pn((l[0]-s)/f,4);T-=1,L-=1,T=Math.max(0,T),L=Math.max(0,L),T=Math.ceil(T),L=Math.ceil(L);const P=L*p+T;d[P]&&(d[P].positions.push(C),d[P].indexs.push(e))}const C=new o.BufferGeometry;a(C,"position",new o.BufferAttribute(x,3,!0)),S&&a(C,"color",new o.BufferAttribute(m,3,!0)),A&&a(C,"size",new o.BufferAttribute(b,1,!0)),e.positions=v,super(),this._initOptions(e),this._createPoints(C,n);const T=e.altitude,L=i.distanceToVector3(T,T).x,P=u.clone();P.z=L,this.getObject3d().position.copy(P),this._baseObjects=_,this._datas=t,this.faceIndex=null,this._geometriesAttributes=w,this._geometryCache=C.clone(),this.isHide=!1,this._initBaseObjectsEvent(_),this._grids=d,this._bindMapEvents(),this.type="Points",this.maxSize=O}_bindMapEvents(){const t=this.getMap(),e="zoomstart zooming zoomend movestart moving moveend pitch rotate";this.on("add",(()=>{this._updateGrids(),t.on(e,this._updateGrids,this)})),this.on("remove",(()=>{t.off(e,this._updateGrids,this)}))}_updateGrids(){const t=this.getMap();this._grids.forEach((e=>{e.indexs.length&&e.updateBBoxPixel(t)}))}getSelectMesh(){const t=this.faceIndex;if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],{coordinate:n,height:i,color:r,size:o}=e;this._baseObjects[t]=new An(n,{height:i,index:t,color:r,size:o},this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){const e=this.getLayer(),n=this.getMap().getSize(),i=this.getLayer().getCamera(),r=this.getOptions().altitude,o=this.getMap(),s=e.distanceToVector3(r,r).x;let a=this.getObject3d().material.size;const c=void 0===a,h=o.coordToContainerPoint(t),l=[];if(this._grids.forEach((t=>{t.indexs.length&&t.isRecCross(h,c?this.maxSize:a)&&l.push(t)})),l.length<1)return!1;for(let t=0,e=l.length;t<e;t++)for(let e=l[t].positions.length-1;e>=0;e--){c&&(a=this._datas[l[t].indexs[e]].size||1);const r=l[t].positions[e];Ln.x=r.x,Ln.y=r.y,Ln.z=r.z+s;const o=wn(Ln,n,i);if(Math.sqrt(Math.pow(h.x-o.x,2)+Math.pow(h.y-o.y,2))<=a/2)return this.faceIndex=l[t].indexs[e],!0}return!1}}const Bn={coordinate:"",radius:10,height:100,radialSegments:6,altitude:0,topColor:"",bottomColor:"#2d2f61"};class zn extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=t.length,s=ae(t),a=i.coordinateToVector3(s),h=[],l=[],u=[],d=[];let f=0,g=0,p=0,y=0;const x={};for(let e=0;e<o;e++){const o=r.Util.extend({index:e},Bn,t[e]),{radius:s,radialSegments:v,altitude:m,topColor:b,bottomColor:_,height:w,coordinate:M}=o,O=se(s,i,x),S=se(w,i,x),A=se(m,i,x),j=P({radius:O,height:S,radialSegments:v});b&&(k(j,_,b,"z",S/2),n.vertexColors=c());const C=i.coordinateToVector3(M).sub(a),T=j.attributes.position.array;for(let t=0,e=T.length;t<e;t+=3)T[t+2]+=A,T[t]+=C.x,T[t+1]+=C.y,T[t+2]+=C.z;h.push(j);const L=new V(M,o,n,i);l.push(L);const B=j.index.count/3;d[e]=[f+1,f+B],f+=B;const z=j.attributes.position.count,E=j.attributes.normal.count,U=j.attributes.uv.count;u[e]={position:{count:z,start:g,end:g+3*z},normal:{count:E,start:p,end:p+3*E},uv:{count:U,start:y,end:y+2*U},hide:!1},g+=3*z,p+=3*E,y+=2*U}super(),e=r.Util.extend({},{altitude:0,layer:i,points:t},e),this._initOptions(e);const v=B(h);this._createMesh(v,n);const m=e.altitude,b=i.distanceToVector3(m,m).x,_=a.clone();_.z=b,this.getObject3d().position.copy(_),this._faceMap=d,this._baseObjects=l,this._datas=t,this._geometriesAttributes=u,this.faceIndex=null,this._geometryCache=v.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(l),this._setPickObject3d(),this._init(),this.type="Bars"}identify(){return this.picked}}const En={width:3,height:1,altitude:0,topColor:null,bottomColor:"#2d2f61"};class Vn extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=[],s=[],a=t.length;for(let e=0;e<a;e++){const n=Oe(t[e]);o.push(n.center),s.push(n.lineStrings)}const h=ae(o);e=r.Util.extend({},En,e,{layer:i,lineStrings:t,coordinate:h});const{altitude:l,topColor:u,bottomColor:d,asynchronous:f}=e;let g;const p=[],y=[];if(super(),f)g=S(),De.push({id:r.Util.GUID(),layer:i,key:e.key,center:h,data:s,lineStrings:t,baseObject:this});else{const e=[];let o=0,l=[],f=0,p=0;const x={};for(let n=0;n<a;n++){const a=t[n],c=r.Util.extend({},En,R(a)?a.properties:a.getProperties(),{index:n}),{height:u,width:d,bottomHeight:g}=c,v=se(d,i,x),m=se(u,i,x),_=s[n],w=[];let M=0;for(let t=0,e=_.length;t<e;t++){const e=Me(_[t],v,m,i,h);M=ce(e,g,i,x),w.push(e)}const O=b(w);e.push(O);const{position:S,normal:A,indices:j}=O,C=j.length/3;l[n]=[o+1,o+C],o+=C;const T=S.length/3,L=A.length/3;y[n]={position:{middleZ:M+m/2,count:T,start:f,end:f+3*T},normal:{count:L,start:p,end:p+3*L},hide:!1},f+=3*T,p+=3*L}g=m(e),u&&(pe(g,d,u,y),n.vertexColors=c())}this._initOptions(e),this._createMesh(g,n);const x=i.distanceToVector3(l,l).x,v=i.coordinateToVector3(h,x);this.getObject3d().position.copy(v),this._faceMap=[],this._baseObjects=p,this._datas=t,this._geometriesAttributes=y,this.faceIndex=null,this._geometryCache=g.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(p),f||(this._setPickObject3d(),this._init()),this.type="ExtrudeLines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=Object.assign({},this.options,G(e)?e.properties:e.getProperties(),{index:t});this._baseObjects[t]=new Ye(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}identify(t){return this.picked}_workerLoad(t){const{faceMap:e,geometriesAttributes:n}=t;this._faceMap=e,this._geometriesAttributes=n;const i=w(t);this._geometryCache=M(i);const{topColor:r,bottomColor:o,bottomHeight:s,height:a}=this.getOptions(),h=this.getObject3d().material;if(r&&(pe(i,o,r,n),h.vertexColors=c()),this.getObject3d().geometry=i,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const Un={altitude:0,colors:null};class In extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const s=[],c=[],h=t.length;for(let e=0;e<h;e++){const n=Oe(t[e]);s.push(n.center),c.push(n.lineStrings)}const l=ae(s);e=r.Util.extend({},Un,e,{layer:i,lineStrings:t,coordinate:l}),super(),this._initOptions(e);const{asynchronous:u}=e;let d;const f=[],g={};let p=0,y=[],x=[],v=0,m=[];if(u)d=Te(),Je.push({id:r.Util.GUID(),layer:i,key:e.key,center:l,data:c,lineStrings:t,baseObject:this});else{for(let t=0;t<h;t++){const e=c[t];let n=0;for(let t=0,r=e.length;t<r;t++){const r=G(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=_e(e[t],i,l,!1);ce(o,r.bottomHeight,i,g),n+=o.length/3*2-2,m.push(Se(o))}const r=n;y[t]=[p,p+r],p+=r,x[t]={position:{count:n,start:v,end:v+3*n},hide:!1},v+=3*n}const t=Ae(m);d=new o.BufferGeometry,a(d,"position",new o.BufferAttribute(t,3))}this._createLineSegments(d,n);const{altitude:b}=e,_=i.distanceToVector3(b,b).x,w=i.coordinateToVector3(l,_);this.getObject3d().position.copy(w),this._faceMap=y,this._baseObjects=f,this._datas=t,this._geometriesAttributes=x,this.faceIndex=null,this.index=null,this._geometryCache=d.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(f),u||(this._setPickObject3d(),this._init()),this.type="Lines"}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=r.Util.extend({},this.getOptions(),{index:t},G(e)?e.properties:e.getProperties());this._baseObjects[t]=new Xe(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_setPickObject3d(){if(!this._colorMap)return;const t=this._geometryCache||this.getObject3d().geometry.clone(),e=this.getLayer().getPick(),{_geometriesAttributes:n}=this,i=n.length,r=he(n);let s=0;for(let t=0;t<i;t++){const i=e.getColor(),o=i.getHex();this._colorMap[o]=t;const{count:a}=n[t].position;this._datas[t].colorIndex=o;for(let t=0;t<a;t++)r[s]=i.r,r[s+1]=i.g,r[s+2]=i.b,s+=3}a(t,"color",new o.BufferAttribute(r,3,!0));const h=this.getObject3d().material.clone();h.color.set("#fff"),h.vertexColors=c();const l=e.getColor().getHex(),u=new o.LineSegments(t,h);u.position.copy(this.getObject3d().position),u._colorIndex=l,this.setPickObject3d(u)}identify(t){return this.picked}_workerLoad(t){const{position:e,faceMap:n,geometriesAttributes:i}=t;this._faceMap=n,this._geometriesAttributes=i;const r=new o.BufferGeometry;if(a(r,"position",new o.BufferAttribute(new Float32Array(e),3)),this._computeLineDistances(r),this._geometryCache=r.clone(),this.getObject3d().geometry=r,this.getObject3d().material.needsUpdate=!0,this._setPickObject3d(),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const Rn=[],Fn=[];function Gn(){return{waitingQueue:Rn,currentQueue:Fn}}function Zn(t,e){for(let n=0,i=t.length;n<i;n++){const i=t[n];if(i){const{key:r,callback:o}=i;if(e===r)return t.splice(n,1),o}}return null}const Dn=document.createElement("canvas");let Hn;function Jn(t,e=!1){if(Hn)return Hn;const n=Dn.getContext("2d");return n.clearRect(0,0,256,256),n.save(),Hn=Dn.toDataURL(),Hn}function Qn(t=1,e=1){let n;return"undefined"==typeof document||(n=document.createElement("canvas"),t&&(n.width=t),e&&(n.height=e)),n}Dn.width=Dn.height=256;class Wn extends r.TileLayer{constructor(t,e={}){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},e)),this._opts=null,this._layer=null,this.material=null,this.getMaterial=null,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime()}isAsynchronous(){return this._opts.worker}getBaseObjects(){const t=this._loadTiles,e=[];for(let n in t){const t=this._baseObjectKeys[n];if(t&&Array.isArray(t)&&t.length)for(let n=0,i=t.length;n<i;n++)e.push(t[n])}return e}onSelectMesh(t,e){}formatBaseObjects(t,e){return[]}loopMessage(t){}getTileData(t){const{key:e,url:n,callback:i,img:o}=t;r.Ajax.getJSON(n,{},(function(t,n){t?(console.error(t),i(e,null,o)):i(e,n,o)}))}_getCurentTileKeys(){const t=this.getTiles().tileGrids||[],e=[],n={};for(let i=0,r=t.length;i<r;i++){const r=t[i].tiles||[];for(let t=0,i=r.length;t<i;t++){const{id:i}=r[t];e.push(i),n[i]=!0}}return{keys:e,keysMap:n}}_isLoad(){const{keys:t}=this._getCurentTileKeys(),e=Object.keys(this._renderer.tilesInView);return t.length===e.length}_layerOnLoad(){const t=(new Date).getTime();if(t-this._layerLaodTime<20)return;this._layerLaodTime=t;const e=this._renderer.tilesInView,n=this._loadTiles,i=this._layer,r=this._baseObjectKeys,o=Object.keys(e).length,s=Object.keys(n).length,a=[];if(o&&s)for(let t in n)e[t]||r[t]&&(r[t]||[]).forEach((t=>{a.push(t)}));if(a.length&&i.removeMesh(a,!1),o&&s)for(let t in e)if(!n[t])if(r[t]){const e=r[t];i.addMesh(e)}else{const{x:e,y:n,z:i}=this._getXYZOfIndex(t);this.getTileUrl(e,n,i)}this._loadTiles=Object.assign({},e),this._diffCache()}_init(){}_workerLoad(t){const e=t.target._img;e.currentCount++,e.currentCount===e.needCount&&(e.src=Jn(e._key,this._opts.debug))}_generateBaseObjects(t,e,n){if(e&&n){const{keysMap:i}=this._getCurentTileKeys();if(!i[t])return void(n.src=Jn(0,this._opts.debug));const r=this.formatBaseObjects(t,e);if(r.length){n.needCount=r.length,n.currentCount=0;for(let e=0,i=r.length;e<i;e++){const i=r[e];i._img=n,i._vt=this,this.isVisible()||i.hide(),this._cachetile(t,i),i.isAsynchronous()||n.currentCount++}this._layer.addMesh(r,!1),n.needCount===n.currentCount&&(n.src=Jn(0,this._opts.debug)),this.isAsynchronous()?r.filter((t=>t.isAsynchronous())).forEach((t=>{t.on("workerload",this._workerLoad,this)})):n.src=Jn(0,this._opts.debug)}else n.src=Jn(0,this._opts.debug);this._loadTiles[t]=!0}else n&&(n.src=Jn(0,this._opts.debug))}_diffCache(){if(Object.keys(this._baseObjectKeys).length>this._renderer.tileCache.max){const t=this._renderer.tileCache.data,e=this._renderer.tilesInView,n=[];for(let i in this._baseObjectKeys)t[i]||e[i]||((this._baseObjectKeys[i]||[]).forEach((t=>{t.isAdd&&n.push(t)})),this._diposeBaseObject(i),delete this._baseObjectKeys[i]);n.length&&this._layer.removeMesh(n,!1)}}_diposeBaseObject(t){const e=this._baseObjectKeys[t];e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t._geometryCache&&t._geometryCache.dispose();const e=t._baseObjects;e&&e.length&&e.forEach((t=>{t.getObject3d().geometry.dispose(),t=null})),t._datas=null,t._geometriesAttributes=null,t._faceMap=null,t._colorMap=null,t.pickObject3d&&t.pickObject3d.geometry.dispose(),t=null}))}_cachetile(t,e){this._baseObjectKeys[t]||(this._baseObjectKeys[t]=[]),this._baseObjectKeys[t].push(e)}_getXYZOfIndex(t){const e=t.indexOf("_")>-1?"_":"-";let[n,i,r]=t.split(e).slice(1,4);return{x:parseInt(i),y:parseInt(n),z:parseInt(r)}}_getTileExtent(t,e,n){const i=this.getMap()._getResolution(n);return this._getTileConfig().getTilePrjExtent(t,e,i)}_getTileLngLatExtent(t,e,n){const i=this._getTileExtent(t,e,n);let o=i.getMax(),s=i.getMin();const a=this.getMap().getProjection();return s=a.unproject(s),o=a.unproject(o),new r.Extent(s,o)}}const qn={worker:!1};class Nn extends Wn{constructor(t,e={},n,i){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},qn,e)),this._opts=e,this._layer=i,this.getMaterial=n,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._layerLaodTime=(new Date).getTime(),this._init()}formatBaseObjects(t,e){const n=this._opts,i=[],s=this.isAsynchronous();for(let a in e){const c=e[a]||{};let h;if(Array.isArray(c)?h=c:"FeatureCollection"===c.type&&(h=c.features),h&&h.length){const e=[],l=[],u=[];for(let t=0,n=h.length;t<n;t++){const n=h[t];if(F(n))e.push(n);else if(G(n)){const t=Q(n);for(let e=0,n=t.length;e<n;e++)l.push(t[e])}else if(Z(n)){const t=Q(n);for(let e=0,n=t.length;e<n;e++)u.push(r.Util.extend({},t[e].properties,t[e],{coordinate:H(t[e])}))}}if(e.length){const o=this._getMaterial(a,e,t,c);if(o){const c=this._layer.toExtrudePolygons(e,r.Util.extend({},{topColor:"#fff",layerName:a,asynchronous:s,key:t},n),o);i.push(c)}}if(l.length){const e=this._getMaterial(a,l,t,c);if(e&&(e instanceof o.LineBasicMaterial||e instanceof o.LineDashedMaterial)){const t=this._layer.toLines(l,r.Util.extend({},{layerName:a,asynchronous:s},n),e);i.push(t)}}if(u.length){const e=this._getMaterial(a,u,t,c);if(e&&e instanceof o.PointsMaterial){const t=this._layer.toPoints(u,r.Util.extend({},{layerName:a,asynchronous:s},n),e);i.push(t)}}}}return i}loopMessage(t){const{currentQueue:e}=Gn();e.length>0&&this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=function(t){if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;!function(t){const e=Zn(Rn,t);e&&e(t)}((t.info||{}).id)},t.renderer.loadTileImage=(t,e,n)=>{t._key=n,function(t,e,n,i,r){const o={key:t,url:e,callback:n,img:i,vt:r};Fn.length<10?(Fn.push(o),r.loopMessage(o)):Rn.push(o)}(n,e,((t,e,n)=>{this._generateBaseObjects(t,e,n),function(t,e){if(Zn(Fn,t),Rn.length){Fn.push(Rn[0]),Rn.splice(0,1);const t=Fn[Fn.length-1];e.loopMessage(t)}}(t,this)}),t,this)}}))}_getMaterial(t,e,n,i){return this.getMaterial&&r.Util.isFunction(this.getMaterial)?this.getMaterial(t,e,n,i):null}}function Kn(t,e,n,i){const{position:r,uv:s,normal:c,indexs:h}=function(t,e,n,i){const r=t/n,o=e/i,s=-t/2,a=e/2,c=-e/2,h=(n+1)*(i+1),l=new Float32Array(3*h),u=new Float32Array(2*h),d=new Float32Array(3*h),f=new Uint32Array(10*h);let g=0,p=0,y=0;for(let h=0;h<=i;h++)for(let x=0;x<=n;x++){const v=s+r*x,m=a-o*h;l[g]=v,l[g+1]=m,l[g+2]=0,d[g]=0,d[g+1]=0,d[g+2]=1;const b=(v-s)/t,_=(m-c)/e;if(u[p]=b,u[p+1]=_,g+=3,p+=2,x<n&&h<i){const t=h*(n+1)+x,e=t+1,i=(n+1)*(h+1)+x,r=i+1;f[y]=t,f[y+1]=i,f[y+2]=e,f[y+3]=i,f[y+4]=r,f[y+5]=e,y+=6}}const x=new Uint32Array(y);for(let t=0,e=x.length;t<e;t++)x[t]=f[t];return{position:l,uv:u,normal:d,indexs:x}}(t,e,n,i),l=new o.BufferGeometry;return a(l,"position",new o.BufferAttribute(r,3)),a(l,"normal",new o.BufferAttribute(c,3)),a(l,"uv",new o.BufferAttribute(s,2)),l.setIndex(new o.BufferAttribute(h,1)),l}const Xn=new o.TextureLoader,$n=document.createElement("canvas");function Yn(t){if(!t)return null;let e;return"string"==typeof t?(e=new Image,e.src=t):t instanceof HTMLCanvasElement?(e=new Image,e.src=t.toDataURL()):t instanceof Image&&(e=new Image,e.src=t.src,e.crossOrigin=t.crossOrigin),e&&!e.crossOrigin&&(e.crossOrigin="Anonymous"),e}const ti={interactive:!1,altitude:0,image:null,imageWidth:256,imageHeight:256,texture:null};class ei extends v{constructor(t,e,n,i){e=r.Util.extend({},ti,e,{layer:i,extent:t});const{texture:o,image:s,altitude:a,imageHeight:c,imageWidth:h}=e;s||console.error("not find image"),t instanceof r.Extent||(t=new r.Extent(t));const{xmin:l,ymin:u,xmax:d,ymax:f}=t;let g=1/0,p=1/0,y=-1/0,x=-1/0;[[l,u],[l,f],[d,f],[d,u]].forEach((t=>{const e=i.coordinateToVector3(t),{x:n,y:r}=e;g=Math.min(n,g),p=Math.min(r,p),y=Math.max(n,y),x=Math.max(r,x)}));const v=Math.abs(y-g),m=Math.abs(x-p),b=Yn(s),_=Yn(o),w=Kn(v,m,h-1,c-1);super(),this._initOptions(e),this._createMesh(w,n);const M=i.distanceToVector3(a,a).x,O=i.coordinateToVector3(t.getCenter(),M);this.getObject3d().position.copy(O),n.transparent=!0,b&&(n.opacity=0,b.onload=()=>{const t=function(t,e=256,n=256){$n.width=e,$n.height=n;const i=$n.getContext("2d");return i.drawImage(t,0,0,e,n),i.getImageData(0,0,e,n).data}(b,h,c);let e=0;const r={};for(let n=0,o=t.length;n<o;n+=4){const o=se(.1*(256*t[n]*256+256*t[n+1]+t[n+2])-1e4,i,r);w.attributes.position.array[3*e+2]=o,e++}w.attributes.position.needsUpdate=!0,_?Xn.load(_.src,(t=>{n.map=t,n.opacity=1,n.needsUpdate=!0})):n.opacity=1},b.onerror=function(){console.error(`not load ${b.src}`)}),this.type="Terrain"}}const ni={scale:1,tileDivisor:4};class ii extends Wn{constructor(t,e={},n,i){super(r.Util.GUID(),r.Util.extend({urlTemplate:t},ni,e)),this._opts=e,this._layer=i,this.material=n,this._baseObjectKeys={},this._loadTiles={},this._add=null,this._imgQueue={},this._layerLaodTime=(new Date).getTime(),this._init()}isAsynchronous(){return!1}formatBaseObjects(t,e){const n=this.options,i=[],{scale:r,tileDivisor:o}=n,{x:s,y:a,z:c}=this._getXYZOfIndex(t),h=this.getMap().getZoom(),l=this.getTileUrl(s,a,c),[u,d]=this.options.tileSize,f=this._getTileLngLatExtent(s,a,c),g=this.material.clone();if(c+1>=Math.round(h)){const t=new ei(f,{image:e,imageWidth:u/o,imageHeight:d/o,texture:l},g,this._layer);t.getObject3d().scale.set(r,r,1),i.push(t)}return i}loopMessage(t){this.getTileData(t)}_init(){this.on("layerload",this._layerOnLoad),this.on("add",(()=>{if(!1===this._add){const t=this.getBaseObjects();this._layer.addMesh(t)}this._add=!0,this.intervalId=setInterval((()=>{this._isLoad()&&!this._layer.getMap().isInteracting()&&this.fire("layerload")}),1e3)})),this.on("remove",(()=>{this._add=!1;const t=this.getBaseObjects();this._layer.removeMesh(t),clearInterval(this.intervalId)})),this.on("show",(()=>{this.getBaseObjects().forEach((t=>{t.show()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.show()}))}})),this.on("hide",(()=>{this.getBaseObjects().forEach((t=>{t.hide()}));for(let t in this._baseObjectKeys){(this._baseObjectKeys[t]||[]).forEach((t=>{t.hide()}))}})),this.on("renderercreate",(t=>{t.renderer.loadTile=function(t){var e=this.layer.getTileSize(),n=new Image;return n.width=e.width,n.height=e.height,n.onload=this.onTileLoad.bind(this,n,t),n.onerror=this.onTileError.bind(this,n,t),this.loadTileImage(n,t.url,t.id),n},t.renderer.deleteTile=t=>{if(!t||!t.image)return;t.image.onload=null,t.image.onerror=null;const e=t.info||{},n=this._imgQueue[e.id];n&&(n.src="",n.onload=null,n.onerror=null,delete this._imgQueue[e.id])},t.renderer.loadTileImage=(t,e,n)=>{t._key=n;const i=new Image;this._imgQueue[n]=i;const r={key:n,url:e,rgbImage:i,callback:(t,e,n)=>{this._generateBaseObjects(t,e,n)},img:t,vt:this};this.loopMessage(r)}}))}}
/*!
     * Code from baidu mapv
     * License: BSD-3
     * https://github.com/huiyan-fe/mapv
     *
     */function ri(t){t=t||{},this.gradient=t.gradient||{.25:"rgba(0, 0, 255, 1)",.55:"rgba(0, 255, 0, 1)",.85:"rgba(255, 255, 0, 1)",1:"rgba(255, 0, 0, 1)"},this.maxSize=t.maxSize||35,this.minSize=t.minSize||0,this.max=t.max||100,this.min=t.min||0,this.initPalette()}function oi(t,e,n){var i=si(n),r=function(t){return t.min||0}(n),o=i-r,s=n.range||null,a=0,c=1024;s&&2===s.length&&(a=(s[0]-r)/o*1024),s&&2===s.length&&(c=(s[1]-r)/o*1024);for(var h,l=n.maxOpacity||.8,u=n.minOpacity||0,d=3,f=t.length;d<f;d+=4)h=4*t[d],t[d]/256>l&&(t[d]=256*l),t[d]/256<u&&(t[d]=256*u),h&&h>=a&&h<=c?(t[d-3]=e[h],t[d-2]=e[h+1],t[d-1]=e[h+2]):t[d]=0}function si(t){return t.max||100}function ai(t,e,n){var i=si(n),r=
/*!
     * Code from baidu mapv
     * License: BSD-3
     * https://github.com/huiyan-fe/mapv
     *
     */
function(t){var e=t/2,n=t+e,i=1e4,r=Qn(2*n,2*n),o=r.getContext("2d");return o.shadowBlur=e,o.shadowColor="black",o.shadowOffsetX=o.shadowOffsetY=i,o.beginPath(),o.arc(n-i,n-i,t,0,2*Math.PI,!0),o.closePath(),o.fill(),r}(n._size||n.size||13),o=r.width/2,s=r.height/2,a=e,c={};for(var h in a.forEach((function(t){var e=void 0===t.count?1:t.count,n=Math.min(1,e/i).toFixed(2);c[n]=c[n]||[],c[n].push(t)})),c)if(!isNaN(h)){var l=c[h];t.beginPath(),n.withoutAlpha||(t.globalAlpha=h),l.forEach((function(e){var n=e.coordinate,a=void 0===e.count?1:e.count;t.globalAlpha=a/i,t.drawImage(r,n[0]-o,n[1]-s)}))}}ri.prototype.setMax=function(t){this.max=t||100},ri.prototype.setMin=function(t){this.min=t||0},ri.prototype.setMaxSize=function(t){this.maxSize=t||35},ri.prototype.setMinSize=function(t){this.minSize=t||0},ri.prototype.initPalette=function(){var t=this.gradient,e=Qn(256,1),n=this.paletteCtx=e.getContext("2d"),i=n.createLinearGradient(0,0,256,1);for(var r in t)i.addColorStop(parseFloat(r),t[r]);n.fillStyle=i,n.fillRect(0,0,256,1)},ri.prototype.getColor=function(t){var e=this.getImageData(t);return"rgba("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]/256+")"},ri.prototype.getImageData=function(t){var e=this.paletteCtx.getImageData(0,0,256,1).data;if(void 0===t)return e;var n=this.max,i=this.min;t>n&&(t=n),t<i&&(t=i);var r=4*Math.floor((t-i)/(n-i)*255);return[e[r],e[r+1],e[r+2],e[r+3]]},ri.prototype.getSize=function(t){var e=this.max,n=this.min,i=this.maxSize,r=this.minSize;return t>e&&(t=e),t<n&&(t=n),e>n?r+(t-n)/(e-n)*(i-r):i},ri.prototype.getLegend=function(t){var e=this.gradient,n=t.width||20,i=t.height||180,r=Qn(n,i),o=r.getContext("2d"),s=o.createLinearGradient(0,i,0,0);for(var a in e)s.addColorStop(parseFloat(a),e[a]);return o.fillStyle=s,o.fillRect(0,0,n,i),r};var ci={draw:function(t,e,n){if(!(t.canvas.width<=0||t.canvas.height<=0)){var i=n.strength||.3;t.strokeStyle="rgba(0,0,0,"+i+")";var r=Qn(t.canvas.width,t.canvas.height),o=r.getContext("2d");o.scale(devicePixelRatio,devicePixelRatio),n=n||{},t.save();var s=new ri({gradient:n.gradient});if(ai(o,e,n),!n.absolute){var a=o.getImageData(0,0,t.canvas.width,t.canvas.height);oi(a.data,s.getImageData(),n),t.putImageData(a,0,0),t.restore()}s=null,r=null}},drawGray:ai,colorize:oi};const hi={altitude:0,interactive:!1,min:0,max:100,size:13,gradient:{.25:"rgb(0,0,255)",.55:"rgb(0,255,0)",.85:"yellow",1:"rgb(255,0,0)"},gridScale:.5},li=2048;class ui extends v{constructor(t,e,n,i){Array.isArray(t)||(t=[t]);let s=1/0,h=1/0,l=-1/0,u=-1/0;const d=[];for(let e=0,n=t.length;e<n;e++){const{coordinate:n,lnglat:r,xy:o}=t[e],a=n||r||o;if(!a){console.warn("not find coordinate");continue}const c=i.coordinateToVector3(a);d.push(c);const{x:f,y:g}=c;s=Math.min(s,f),h=Math.min(h,g),l=Math.max(l,f),u=Math.max(u,g)}e=r.Util.extend({},hi,e,{layer:i,points:t});let{gridScale:f,altitude:g}=e;const p=Math.abs(l-s),y=Math.abs(u-h),x=Math.max(p*f,y*f);if(x>li){console.warn(`gridScale: ${f} it's too big. I hope it's a smaller value,canvas max size is 2048* 2048`);f=li/(x/f)}const v=Math.ceil(p*f),m=Math.ceil(y*f),b=v/p,_=m/y,w=[];for(let e=0,n=d.length;e<n;e++){const n=d[e];n.x-=s,n.y-=h,n.x*=b,n.y*=_,n.y=m-n.y,w.push({coordinate:[n.x,n.y],count:t[e].count})}let M=Qn(v,m),O=M.getContext("2d");ci.drawGray(O,w,e);const S=O.getImageData(0,0,O.canvas.width,O.canvas.height);let A=-1/0;const j=new Float32Array(S.data.length/4),C=new Float32Array(S.data.length/4);for(let t=3,e=S.data.length,n=0;t<e;t+=4){const e=S.data[t];A=Math.max(A,e),C[n]=e,e<=0&&(j[n]=1),n++}const T=new ri({gradient:e.gradient});ci.colorize(S.data,T.getImageData(),e),M=null,O=null;const L=Kn(p,y,v-1,m-1),P=L.getIndex().array,k=L.attributes.position.array,B=new Float32Array(k.length),z=new Uint32Array(6*k.length),E=new o.Color;let V=0;for(let t=0,e=k.length,n=0,i=P.length,r=0,o=S.data.length,s=0;t<Math.max(e,i,o);t+=3){if(t<e){const e=C[s];e>0&&(k[t+2]=e/A)}if(n<i){const t=P[n],e=P[n+1],i=P[n+2];j[t]&&j[e]&&j[i]||(z[V]=t,z[V+1]=e,z[V+2]=i,V+=3)}if(r<o){const t=`rgb(${S.data[r]},${S.data[r+1]},${S.data[r+2]})`;E.setStyle(t),B[n]=E.r,B[n+1]=E.g,B[n+2]=E.b}n+=3,r+=4,s++}const U=new Uint32Array(V);for(let t=0;t<V;t++)U[t]=z[t];L.setIndex(new o.BufferAttribute(U,1)),a(L,"color",new o.BufferAttribute(B,3,!0)),n.vertexColors=c(),super(),this._initOptions(e),this._createMesh(L,n);const I=i.distanceToVector3(g,g).x;this.getObject3d().position.copy(new o.Vector3((s+l)/2,(h+u)/2,I)),this.type="HeatMap"}}const di=new o.Color;let fi=1;class gi{constructor(t){this.object3ds=[],this.layer=t,this.camera=t.getCamera(),this.renderer=t.getThreeRenderer(),this.pickingTexture=new o.WebGLRenderTarget(1,1),this.pickingScene=new o.Scene}getColor(){return di.setHex(fi),fi++,di}add(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=t,this.pickingScene.add(t))}return this}remove(t){if(t){const e=t._colorIndex;e&&(this.object3ds[e]=null,this.pickingScene.remove(t))}return this}isEmpty(){if(0===this.pickingScene.children.length)return!0;for(let t=0,e=this.pickingScene.children.length;t<e;t++){const e=this.pickingScene.children[t];if(e){const t=e.__parent;if(t&&!0===t.getOptions().interactive)return!1}}return!0}pick(t){if(!t)return;if(this.isEmpty())return;const{camera:e,renderer:n,pickingTexture:i,pickingScene:r,object3ds:o,layer:s}=this,a=this.pickingScene.children.length;for(let t=0;t<a;t++){const e=this.pickingScene.children[t];e&&e.__parent&&(e.__parent.picked=!1)}const{width:c,height:h}=s._getRenderer().canvas,l=i.width,u=i.height;c===l&&h===u||i.setSize(c,h),n.setRenderTarget(i),n.clear(),n.render(r,e);const d=new Uint8Array(4),{x:f,y:g}=t,p=window.devicePixelRatio,y=f*p,x=i.height-g*p;n.readRenderTargetPixels(i,Math.round(y),Math.round(x),1,1,d);const v=d[0]<<16|d[1]<<8|d[2],m=o[v];if(m)m.__parent&&(o[v].__parent.picked=!0);else for(let t=0;t<a;t++){const e=this.pickingScene.children[t];if(e&&e.__parent){const t=e.__parent;if(t._colorMap&&null!=t._colorMap[v]){t.picked=!0,t.index=t._colorMap[v];break}}}n.setRenderTarget(null)}}const pi={bottomHeight:0,altitude:0};class yi extends v{constructor(t,e,n,i){e=r.Util.extend({},pi,e,{layer:i,lineString:t}),super(),this._initOptions(e);const{asynchronous:o}=e,{lineStrings:s,center:a}=Oe(t),c=new g;let h;if(o){const e=r.Util.GUID();this.getOptions().id=e,this.getOptions().center=a,Qe.push({id:e,data:s,lineString:t,center:a,layer:i,baseObject:this})}else{const t=[],n={};for(let r=0,o=s.length;r<o;r++){const o=_e(s[r],i,a,!1).positions;ce(o,e.bottomHeight,i,n),t.push(Se(o))}h=Ae(t),c.setPositions(h)}this._setMaterialRes(i,n),this._createLine2(c,n);const{altitude:l}=e,u=i.distanceToVector3(l,l).x,d=i.coordinateToVector3(a,u);this.getObject3d().position.copy(d),o||(this._setPickObject3d(h,n.linewidth),this._init()),this.type="FatLine"}_init(){const t=this.getLayer().getPick();this.on("add",(()=>{t.add(this.pickObject3d)})),this.on("remove",(()=>{t.remove(this.pickObject3d)}))}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){const n=new g;n.setPositions(t);const i=this.getLayer().getPick().getColor(),r=[];for(let e=0,n=t.length/3;e<n;e++)r.push(i.r,i.g,i.b);n.setColors(r);const o=new d({color:"#fff",linewidth:e,vertexColors:c()});this._setMaterialRes(this.getLayer(),o);const s=i.getHex(),a=new p(n,o);a.position.copy(this.getObject3d().position),a._colorIndex=s,this.setPickObject3d(a)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}_workerLoad(t){const e=new Float32Array(t.position),n=this.getObject3d();if(n.geometry.setPositions(e),n.computeLineDistances(),this._setPickObject3d(e,n.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const xi={altitude:0,colors:null};class vi extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=[],s=[],a=t.length;for(let e=0;e<a;e++){const n=Oe(t[e]);o.push(n.center),s.push(n.lineStrings)}const c=ae(o);e=r.Util.extend({},xi,e,{layer:i,lineStrings:t,coordinate:c}),super(),this._initOptions(e);const{asynchronous:h}=e,l=new g,u=[],d={};let f,p,y=0,x=[],v=[],m=0,b=[];if(h)We.push({id:r.Util.GUID(),data:s,key:e.key,center:c,layer:i,baseObject:this,lineStrings:t});else{for(let t=0;t<a;t++){const e=s[t];let n=0;for(let t=0,r=e.length;t<r;t++){const r=G(e[t])?e[t].properties:e[t].getProperties()||{},{positions:o}=_e(e[t],i,c,!1);ce(o,r.bottomHeight,i,d),n+=o.length/3*2-2,b.push(Se(o))}const r=n;x[t]=[y,y+r],y+=r,v[t]={position:{count:n,start:m,end:m+3*n},instanceStart:{count:n,start:m,end:m+3*n},instanceEnd:{count:n,start:m,end:m+3*n},hide:!1},m+=3*n}f=Ae(b),l.setPositions(f)}this._setMaterialRes(i,n),this._createLine2(l,n);const{altitude:_}=e,w=i.distanceToVector3(_,_).x,M=i.coordinateToVector3(c,w);this.getObject3d().position.copy(M),this._faceMap=x,this._baseObjects=u,this._datas=t,this._geometriesAttributes=v,this.faceIndex=null,this.index=null,this._geometryCache=new g,h||(p=new Float32Array(f),this._geometryCache.setPositions(p)),this._colorMap={},this.isHide=!1,this._initBaseObjectsEvent(u),h||(this._setPickObject3d(p,n.linewidth),this._init()),this.type="FatLines"}_setMaterialRes(t,e){const n=t.getMap().getSize(),i=n.width,r=n.height;e.resolution.set(i,r)}_setPickObject3d(t,e){if(!this._colorMap)return;const n=this._geometryCache||new g;n.setPositions(t);const i=this.getLayer().getPick(),{_geometriesAttributes:r}=this,o=he(r);let s=0;for(let t=0,e=r.length;t<e;t++){const e=i.getColor(),n=e.getHex();this._colorMap[n]=t;const{count:a}=r[t].position;this._datas[t].colorIndex=n;for(let t=0;t<a;t++)o[s]=e.r,o[s+1]=e.g,o[s+2]=e.b,s+=3}n.setColors(o);const a=new d({color:"#fff",linewidth:e,vertexColors:c()});this._setMaterialRes(this.getLayer(),a);const h=i.getColor().getHex(),l=new p(n,a);l.position.copy(this.getObject3d().position),l._colorIndex=h,this.setPickObject3d(l)}identify(t){return this.picked}setSymbol(t){if(t&&t instanceof o.Material){t.needsUpdate=!0;const e=this.getMap().getSize(),n=e.width,i=e.height;t.resolution.set(n,i),this.getObject3d().material=t}return this}getSelectMesh(){const t=this._getIndex();if(null!=t){if(!this._baseObjects[t]){const e=this._datas[t],n=r.Util.extend({},this.getOptions(),{index:t},G(e)?e.properties:e.getProperties());this._baseObjects[t]=new yi(e,n,this.getObject3d().material,this.getLayer()),this._proxyEvent(this._baseObjects[t])}return{data:this._datas[t],baseObject:this._baseObjects[t]}}}_updateAttribute(t,e){const{indexs:n}=this._getHideGeometryIndex(e),i=this._geometryCache.attributes[e].array,r=i.length;for(let e=0;e<r;e++)t.array[e]=i[e];for(let i=0;i<n.length;i++){const r=n[i],{start:o,end:s}=this._geometriesAttributes[r][e];for(let e=o;e<s;e++)t.array[e]=-1e5}return this}_showGeometry(t,e){let n;if(t&&(n=t.getOptions().index),null!=n){const t=this._geometriesAttributes[n],{hide:i}=t;if(i===e)return this;t.hide=e;const r=this.getObject3d().geometry;this._updateAttribute(r.attributes.instanceStart,"instanceStart"),this._updateAttribute(r.attributes.instanceEnd,"instanceEnd"),r.attributes.instanceStart.data.needsUpdate=!0,r.attributes.instanceEnd.data.needsUpdate=!0,this.isHide=e}return this}_workerLoad(t){const{faceMap:e,geometriesAttributes:n}=t;this._faceMap=e,this._geometriesAttributes=n;const i=this.getObject3d(),r=new Float32Array(t.position),o=new Float32Array(r);if(i.geometry.setPositions(new Float32Array(r)),this._geometryCache.setPositions(o),this._setPickObject3d(o,i.material.linewidth),this._init(),this.isAdd){this.getLayer().getPick().add(this.pickObject3d)}this._fire("workerload",{target:this})}}const mi={radius:10,height:100,altitude:0,topColor:"",bottomColor:"#2d2f61"};class bi extends v{constructor(t,e,n,i){e=r.Util.extend({},mi,e,{layer:i,coordinate:t}),super(),this._initOptions(e);const{height:o,radius:s,topColor:a,bottomColor:h,altitude:l}=e,u=i.distanceToVector3(o,o).x,d=i.distanceToVector3(s,s).x,f=z().clone();f.scale(2*d,2*d,u),a&&(k(f,h,a,"z",u/2),n.vertexColors=c()),this._createMesh(f,n);const g=i.distanceToVector3(l,l).x,p=i.coordinateToVector3(t,g);this.getObject3d().position.copy(p),this.type="Box"}}const _i={radius:10,height:100,altitude:0,topColor:null,bottomColor:"#2d2f61"};class wi extends(vn(v)){constructor(t,e,n,i){Array.isArray(t)||(t=[t]);const o=t.length,s=ae(t),a=i.coordinateToVector3(s),h=[],l=[],u=[],d=[];let f=0,g=0,p=0,y=0;const x={};for(let e=0;e<o;e++){const o=r.Util.extend({index:e},_i,t[e]),{radius:s,altitude:v,topColor:m,bottomColor:b,height:_,coordinate:w}=o,M=se(s,i,x),O=se(_,i,x),S=se(v,i,x),A=z().clone();A.scale(2*M,2*M,O),m&&(k(A,b,m,"z",O/2),n.vertexColors=c());const j=i.coordinateToVector3(w).sub(a),C=A.attributes.position.array;for(let t=0,e=C.length;t<e;t+=3)C[t+2]+=S,C[t]+=j.x,C[t+1]+=j.y,C[t+2]+=j.z;h.push(A);const T=new bi(w,o,n,i);l.push(T);const L=A.index.count/3;d[e]=[f+1,f+L],f+=L;const P=A.attributes.position.count,B=A.attributes.normal.count,E=A.attributes.uv.count;u[e]={position:{count:P,start:g,end:g+3*P},normal:{count:B,start:p,end:p+3*B},uv:{count:E,start:y,end:y+2*E},hide:!1},g+=3*P,p+=3*B,y+=2*E}super(),e=r.Util.extend({},{altitude:0,layer:i,points:t},e),this._initOptions(e);const v=B(h);this._createMesh(v,n);const m=e.altitude,b=i.distanceToVector3(m,m).x,_=a.clone();_.z=b,this.getObject3d().position.copy(_),this._faceMap=d,this._baseObjects=l,this._datas=t,this._geometriesAttributes=u,this.faceIndex=null,this._geometryCache=v.clone(),this.isHide=!1,this._colorMap={},this._initBaseObjectsEvent(l),this._setPickObject3d(),this._init(),this.type="Boxs"}identify(t){return this.picked}}const Mi=Math.PI/180,Oi=[[4e3,220],[2e3,100],[1e3,30],[500,15],[100,5],[50,2],[10,1],[5,.7],[2,.1],[1,.05],[.5,.02],[.4,.01],[.1,.005],[.05,.002],[.01,.001]],Si=["mousemove","click","mousedown","mouseup","dblclick","contextmenu","touchstart","touchmove","touchend"],Ai=new r.Coordinate(0,0),ji=new r.Point(0,0),Ci="__webglFramebuffer";class Ti extends r.CanvasLayer{constructor(t,e){super(t,e),this._animationBaseObjectMap={},this._needsUpdate=!0,this._mousemoveTimeOut=0,this._baseObjects=[],this._delayMeshes=[],this.type="ThreeLayer"}isMercator(){const t=this.getMap();if(!t)return!1;const e=t.getSpatialReference(),n=e._projection,i=e._resolutions;return!!(n&&"EPSG:3857"===n.code&&i&&i.length&&156543===Math.floor(i[0])&&t.getGLRes)}isRendering(){const t=this.getMap();return!!t&&(t.isInteracting()||t.isAnimating())}prepareToDraw(...t){}draw(t,e,n,i,r,o){this.renderScene(o,this)}drawOnInteracting(t,e,n,i,r,o,s){this.renderScene(s,this)}coordinateToVector3(t,e=0){const n=this.getMap();if(!n)return null;const i=Array.isArray(t);i?(Ai.x=t[0],Ai.y=t[1]):t instanceof r.Coordinate||(t=new r.Coordinate(t));const s=Pi(n),a=ki(n,i?Ai:t,s,ji);return new o.Vector3(a.x,a.y,e)}coordinatiesToGLFloatArray(t,e){const n=this.getMap();if(!n)return null;const i=Pi(n),o=t.length,s=new Float32Array(2*o),a=new Float32Array(3*o);for(let c=0;c<o;c++){let o=t[c];const h=Array.isArray(o);h?(Ai.x=o[0],Ai.y=o[1]):o instanceof r.Coordinate||(o=new r.Coordinate(o));const l=ki(n,h?Ai:o,i,ji);l.x-=e.x,l.y-=e.y;const u=2*c;s[u]=l.x,s[u+1]=l.y;const d=3*c;a[d]=l.x,a[d+1]=l.y,a[d+2]=0}return{positions:a,positons2d:s}}coordinatiesToGLArray(t,e){const n=this.getMap();if(!n)return null;const i=Pi(n),o=t.length,s=new Array(o);for(let a=0;a<o;a++){let o=t[a];const c=Array.isArray(o);c?(Ai.x=o[0],Ai.y=o[1]):o instanceof r.Coordinate||(o=new r.Coordinate(o));const h=ki(n,c?Ai:o,i,ji);h.x-=e.x,h.y-=e.y,s[a]=[h.x,h.y]}return s}distanceToVector3(t,e,n){if(0===t&&0===e||!r.Util.isNumber(t)||!r.Util.isNumber(e))return new o.Vector3(0,0,0);const i=this.getMap(),s=Pi(i);let a=n||i.getCenter();a instanceof r.Coordinate||(a=new r.Coordinate(a));const c=i.locate(a,t,e),h=ki(i,a,s),l=ki(i,c,s),u=Math.abs(l.x-h.x)*r.Util.sign(t),d=Math.abs(l.y-h.y)*r.Util.sign(e);return new o.Vector3(u,d,0)}toShape(t){if(!t)return null;if(t instanceof r.MultiPolygon)return t.getGeometries().map((t=>this.toShape(t)));const e=t.getCenter(),n=this.coordinateToVector3(e),i=t.getShell().map((t=>{const e=this.coordinateToVector3(t).sub(n);return new o.Vector2(e.x,e.y)})),s=new o.Shape(i),a=t.getHoles();return a&&a.length>0&&(s.holes=a.map((t=>{const e=t.map((t=>{const e=this.coordinateToVector3(t).sub(n);return new o.Vector2(e.x,e.y)}));return new o.Shape(e)}))),s}toExtrudeMesh(t,e,n,i){if(!t)return null;if(t instanceof r.MultiPolygon)return t.getGeometries().map((t=>this.toExtrudeMesh(t,e,n,i)));const s=t.getCoordinates();s.forEach((t=>{for(let e=t.length-1;e>=1;e--)t[e].equals(t[e-1])&&t.splice(e,1)})),t.setCoordinates(s);const a=this.toShape(t),c=this.coordinateToVector3(t.getCenter());i=r.Util.isNumber(i)?i:e,i=this.distanceToVector3(i,i).x;const h=this.distanceToVector3(e,e).x,l={bevelEnabled:!1,bevelSize:1};l[parseInt(o.REVISION)>=93?"depth":"amount"]=i;const u=new o.ExtrudeGeometry(a,l);let d=u;o.BufferGeometry.prototype.fromGeometry&&(d=new o.BufferGeometry,d.fromGeometry(u));const f=new o.Mesh(d,n);return f.position.set(c.x,c.y,h-i),f}toExtrudePolygon(t,e,n){return new en(t,e,n,this)}toBar(t,e,n){return new V(t,e,n,this)}toLine(t,e,n){return new Xe(t,e,n,this)}toExtrudeLine(t,e,n){return new Ye(t,e,n,this)}toModel(t,e){return new rn(t,e,this)}toExtrudeLineTrail(t,e,n){return new pn(t,e,n,this)}toExtrudePolygons(t,e,n){return new _n(t,e,n,this)}toPoint(t,e,n){return new An(t,e,n,this)}toPoints(t,e,n){return new kn(t,e,n,this)}toBars(t,e,n){return new zn(t,e,n,this)}toExtrudeLines(t,e,n){return new Vn(t,e,n,this)}toLines(t,e,n){return new In(t,e,n,this)}toThreeVectorTileLayer(t,e,n){return new Nn(t,e,n,this)}toTerrain(t,e,n){return new ei(t,e,n,this)}toTerrainVectorTileLayer(t,e,n){return new ii(t,e,n,this)}toHeatMap(t,e,n){return new ui(t,e,n,this)}toFatLine(t,e,n){return new yi(t,e,n,this)}toFatLines(t,e,n){return new vi(t,e,n,this)}toBox(t,e,n){return new bi(t,e,n,this)}toBoxs(t,e,n){return new wi(t,e,n,this)}getBaseObjects(){return this.getMeshes().filter((t=>t instanceof v))}getMeshes(){const t=this.getScene();if(!t)return[];const e=[];for(let n=0,i=t.children.length;n<i;n++){const i=t.children[n];i instanceof o.Object3D&&!(i instanceof o.Camera)&&e.push(i.__parent||i)}return e}clear(){return this.clearMesh()}clearMesh(){const t=this.getScene();if(!t)return this;for(let e=t.children.length-1;e>=0;e--){const n=t.children[e];if(n instanceof o.Object3D&&!(n instanceof o.Camera)){t.remove(n);const e=n.__parent;e&&e instanceof v&&(e.isAdd=!1,e._fire("remove",{target:e}),delete this._animationBaseObjectMap[n.uuid])}}return this}lookAt(t){const e=this._getRenderer();return e&&e.context.lookAt(t),this}getCamera(){const t=this._getRenderer();return t?t.camera:null}getScene(){const t=this._getRenderer();return t?t.scene:null}renderScene(t,e){const n=this._getRenderer();return n&&(n.clearCanvas(),n.renderScene(t),e||n.setToRedraw()),this}loop(t=!1){const e=this._delayMeshes;if(!e.length)return;const n=this.getMap();if(!n||n.isAnimating()||n.isInteracting())return;const i=this.options.loopRenderCount||50,r=e.slice(0,i);r&&this.addMesh(r,t),e.splice(0,i)}renderPickScene(){const t=this._getRenderer();if(t){const e=t.pick;e&&e.pick(this._containerPoint)}return this}getThreeRenderer(){const t=this._getRenderer();return t?t.context:null}getPick(){const t=this._getRenderer();return t?t.pick:null}delayAddMesh(t){if(!t)return this;Array.isArray(t)||(t=[t]);for(let e=0,n=t.length;e<n;e++)this._delayMeshes.push(t[e]);return this}addMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const n=this.getScene();if(t.forEach((t=>{t instanceof v?(n.add(t.getObject3d()),t.isAdd||(t.isAdd=!0,t._fire("add",{target:t})),t._animation&&r.Util.isFunction(t._animation)&&(this._animationBaseObjectMap[t.getObject3d().uuid]=t)):t instanceof o.Object3D&&n.add(t)})),this._zoomend(),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}removeMesh(t,e=!0){if(!t)return this;Array.isArray(t)||(t=[t]);const n=this.getScene();if(t.forEach((t=>{if(t instanceof v){n.remove(t.getObject3d()),t.isAdd&&(t.isAdd=!1,t._fire("remove",{target:t})),t._animation&&r.Util.isFunction(t._animation)&&delete this._animationBaseObjectMap[t.getObject3d().uuid];const e=this._delayMeshes;if(e.length)for(let n=0,i=e.length;n<i;n++)if(e[n]===t){e.splice(n,1);break}}else t instanceof o.Object3D&&n.remove(t)})),e){const t=this._getRenderer();t&&t.setToRedraw()}return this}_initRaycaster(){return this._raycaster||(this._raycaster=new o.Raycaster,this._mouse=new o.Vector2),this}identify(t,e){if(!t)return console.error("coordinate is null,it should be Coordinate"),[];if(Array.isArray(t)&&(t=new r.Coordinate(t)),!(t instanceof r.Coordinate))return console.error("coordinate type is error,it should be Coordinate"),[];const n=this.getMap().coordToContainerPoint(t);this._containerPoint=n;const{x:i,y:a}=n;this._initRaycaster();const c=this._raycaster,h=this._mouse,l=this.getCamera(),u=this.getScene(),d=this.getMap().getSize();if(!u)return[];const f=d.width,g=d.height;h.x=i/f*2-1,h.y=-a/g*2+1,c.setFromCamera(h,l),function(t,e){s>113?t.params.Line.threshold=e:t.linePrecision=e}(c,this._getLinePrecision(this.getMap().getResolution()));const p=[],y=[];u.children.forEach((t=>{const e=t.__parent;if(e&&e.getOptions){const n=e;n.getOptions().interactive&&n.isVisible()&&(n.identify&&r.Util.isFunction(n.identify)?y.push(n):p.push(t))}else(t instanceof o.Mesh||t instanceof o.Group)&&p.push(t)}));let x=[];const v=c.intersectObjects(p,!0);v&&Array.isArray(v)&&v.length&&(x=v.map((t=>{let e=t.object;e=this._recursionMesh(e)||{};const n=e.__parent||e;return n.faceIndex=t.faceIndex,n.index=t.index,n}))),this.renderPickScene(),y.length&&y.forEach((e=>{e.identify(t)&&x.push(e)}));const m=x.length;for(let t=0;t<m;t++)if(x[t])for(let e=t+1;e<m;e++)x[t]===x[e]&&x.splice(e,1);const b=(e=r.Util.extend({},e)).count;return r.Util.isNumber(b)&&b>0?x.slice(0,b):x}_recursionMesh(t){for(;t&&t.parent!==this.getScene();)t=t.parent;return t}_getLinePrecision(t=10){for(let e=0,n=Oi.length;e<n;e++){const[n,i]=Oi[e];if(t>n)return i}return.01}_identifyBaseObjectEvents(t){if(!this.options.geometryEvents)return this;const e=this.map||this.getMap();if(e.isInteracting()||!e.options.geometryEvents)return this;const{type:n,coordinate:i}=t,o=r.Util.now();if(this._mousemoveTimeOut&&"mousemove"===n&&o-this._mousemoveTimeOut<64)return this;this._mousemoveTimeOut=o,e.resetCursor("default");const s=this.options.identifyCountOnEvent;let a=Math.max(0,r.Util.isNumber(s)?s:0);0===a&&(a=1/0);const c=this.identify(i,{count:a}),h=this.getScene();if(0===c.length&&h)for(let e=0,n=h.children.length;e<n;e++){const n=(h.children[e]||{}).__parent;n&&n.fire("empty",Object.assign({},t,{target:n}))}if("mousemove"===n){c.length&&e.setCursor("pointer");const r=[];this._baseObjects&&this._baseObjects.forEach((t=>{let e=!0;c.forEach((n=>{t===n&&(e=!1)})),e&&r.push(t)})),r.forEach((e=>{e&&e instanceof v&&(e.getSelectMesh?e.isHide||(e._mouseover=!1,e.fire("mouseout",Object.assign({},t,{target:e,type:"mouseout",selectMesh:null})),e.closeToolTip()):(e._mouseover=!1,e.fire("mouseout",Object.assign({},t,{target:e,type:"mouseout"})),e.closeToolTip()))})),c.forEach((e=>{if(e instanceof v){e._mouseover||(e.fire("mouseover",Object.assign({},t,{target:e,type:"mouseover",selectMesh:e.getSelectMesh?e.getSelectMesh():null})),e._mouseover=!0),e.fire(n,Object.assign({},t,{target:e,selectMesh:e.getSelectMesh?e.getSelectMesh():null}));const r=e.getToolTip();r&&!r._owner&&r.addTo(e),e.openToolTip(i)}})),this._baseObjects=c}else c.forEach((e=>{if(e instanceof v&&(e.fire(n,Object.assign({},t,{target:e,selectMesh:e.getSelectMesh?e.getSelectMesh():null})),"click"===n)){const t=e.getInfoWindow();t&&!t._owner&&t.addTo(e),e.openInfoWindow(i)}}));return this}_zoomend(){const t=this.getScene();if(!t)return;const e=this.getMap().getZoom();t.children.forEach((t=>{const n=t.__parent;if(n&&n.getOptions){const t=n;t.zoomChange&&r.Util.isFunction(t.zoomChange)&&t.zoomChange(e);const i=t.getMinZoom(),o=t.getMaxZoom();e<i||e>o?(t.isVisible()&&(t.getObject3d().visible=!1),t._zoomVisible=!1):i<=e&&e<=o&&(t._visible&&(t.getObject3d().visible=!0),t._zoomVisible=!0)}}))}onAdd(){super.onAdd();const t=this.map||this.getMap();return t?(Si.forEach((e=>{t.on(e,this._identifyBaseObjectEvents,this)})),this._needsUpdate=!0,this._animationBaseObjectMap||(this._animationBaseObjectMap={}),t.on("zooming zoomend",this._zoomend,this),this):this}onRemove(){super.onRemove();const t=this.map||this.getMap();return t?(Si.forEach((e=>{t.off(e,this._identifyBaseObjectEvents,this)})),t.off("zooming zoomend",this._zoomend,this),this):this}_callbackBaseObjectAnimation(){const t=this;if(t._animationBaseObjectMap)for(const e in t._animationBaseObjectMap){t._animationBaseObjectMap[e]._animation()}return this}_getFovRatio(){const t=this.getMap().getFov();return Math.tan(t/2*Mi)}}Ti.mergeOptions({renderer:"gl",doubleBuffer:!1,glOptions:null,geometryEvents:!0,identifyCountOnEvent:0,forceRenderOnZooming:!0,loopRenderCount:50});class Li extends r.renderer.CanvasLayerRenderer{constructor(){super(...arguments),this._renderTime=0,this._renderTarget=null}getPrepareParams(){return[this.scene,this.camera]}getDrawParams(){return[this.scene,this.camera]}_drawLayer(){super._drawLayer.apply(this,arguments)}hitDetect(){return!1}createCanvas(){super.createCanvas(),this.createContext()}createContext(){if(this.canvas.gl&&this.canvas.gl.wrap)this.gl=this.canvas.gl.wrap();else{const t=this.layer.options.glOptions||{alpha:!0,depth:!0,antialias:!0,stencil:!0,preserveDrawingBuffer:!1};t.preserveDrawingBuffer=!0,this.gl=this.gl||this._createGLContext(this.canvas,t)}this._initThreeRenderer(),this.layer.onCanvasCreate(this.context,this.scene,this.camera)}_initThreeRenderer(){this.matrix4=new o.Matrix4;const t=new o.WebGLRenderer({context:this.gl,alpha:!0});t.autoClear=!1,t.setClearColor(new o.Color(1,1,1),0),t.setSize(this.canvas.width,this.canvas.height),t.clear(),this.context=t;const e=this.scene=new o.Scene,n=this.layer.getMap(),i=n.getFov()*Math.PI/180,r=this.camera=new o.PerspectiveCamera(i,n.width/n.height,n.cameraNear,n.cameraFar);r.matrixAutoUpdate=!1,this._syncCamera(),e.add(r),this.pick=new gi(this.layer),qe.star()}onCanvasCreate(){super.onCanvasCreate()}resizeCanvas(t){if(!this.canvas)return;let e,n=this.getMap();e=t||n.getSize();const i=n.getDevicePixelRatio?n.getDevicePixelRatio():r.Browser.retina?2:1,o=this.canvas;o.height=i*e.height,o.width=i*e.width,this.layer._canvas&&o.style&&(o.style.width=e.width+"px",o.style.height=e.height+"px"),this.context.setSize(o.width,o.height)}clearCanvas(){this.canvas&&this.context.clear()}prepareCanvas(){return this.canvas?this.clearCanvas():this.createCanvas(),this.layer.fire("renderstart",{context:this.context}),null}renderScene(t){const e=r.Util.now();if(e-this._renderTime>=16&&(this.layer._callbackBaseObjectAnimation(),this._renderTime=e),this._syncCamera(),t&&t.renderTarget){const{width:e,height:n}=t.renderTarget.fbo;this._renderTarget?(this._renderTarget.viewport.set(0,0,e,n),this._renderTarget.scissor.set(0,0,e,n)):(this._renderTarget=new o.WebGLRenderTarget(e,n,{depthBuffer:!1}),this.context.setRenderTarget(this._renderTarget),this.context.render(this.scene,this.camera));const i=this.context.properties.get(this._renderTarget),r=i[Ci];i[Ci]=t.renderTarget.getFramebuffer(t.renderTarget.fbo),this.context.setRenderTarget(this._renderTarget),this.context.render(this.scene,this.camera),i[Ci]=r}else this.context.render(this.scene,this.camera);this.context.setRenderTarget(null),this.completeRender()}remove(){delete this._drawContext,this._renderTarget&&(this._renderTarget.dispose(),delete this._renderTarget),super.remove()}_syncCamera(){const t=this.getMap(),e=this.camera;e.matrix.elements=t.cameraWorldMatrix,e.projectionMatrix.elements=t.projMatrix,this.matrix4.invert?e.projectionMatrixInverse.elements=this.matrix4.copy(e.projectionMatrix).invert().elements:e.projectionMatrixInverse.elements=this.matrix4.getInverse(e.projectionMatrix).elements}_createGLContext(t,e){const n=["webgl2","webgl","experimental-webgl"];let i=null;for(let r=0;r<n.length;++r){try{i=t.getContext(n[r],e)}catch(t){}if(i)break}return i}}function Pi(t){return t.getGLRes?t.getGLRes():t.getGLZoom()}function ki(t,e,n,i){return t.coordToPointAtRes?t.coordToPointAtRes(e,n,i):t.coordinateToPoint(e,n,i)}Ti.registerRenderer("gl",Li),r.registerWorkerAdapter&&r.registerWorkerAdapter("__maptalks.three__",'(function(e){"use strict";var t=r,n=r;function r(e,t,n){n=n||2;var r,v,h,u,l,x,c,d=t&&t.length,g=d?t[0]*n:e.length,y=i(e,0,g,n,!0),m=[];if(!y||y.next===y.prev)return m;if(d&&(y=function(e,t,n,r){var o,v,h,u=[];for(o=0,v=t.length;o<v;o++)(h=i(e,t[o]*r,o<v-1?t[o+1]*r:e.length,r,!1))===h.next&&(h.steiner=!0),u.push(p(h));for(u.sort(f),o=0;o<u.length;o++)s(u[o],n),n=a(n,n.next);return n}(e,t,y,n)),e.length>80*n){r=h=e[0],v=u=e[1];for(var M=n;M<g;M+=n)(l=e[M])<r&&(r=l),(x=e[M+1])<v&&(v=x),l>h&&(h=l),x>u&&(u=x);c=0!==(c=Math.max(h-r,u-v))?1/c:0}return o(y,m,n,r,v,c),m}function i(e,t,n,r,i){var a,o;if(i===R(e,t,n,r)>0)for(a=t;a<n;a+=r)o=A(a,e[a],e[a+1],o);else for(a=n-r;a>=t;a-=r)o=A(a,e[a],e[a+1],o);return o&&m(o,o.next)&&(z(o),o=o.next),o}function a(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!m(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(z(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function o(e,t,n,r,i,f,s){if(e){!s&&f&&function(e,t,n,r){var i=e;do{null===i.z&&(i.z=c(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,a,o,v,h,u=1;do{for(n=e,e=null,a=null,o=0;n;){for(o++,r=n,v=0,t=0;t<u&&(v++,r=r.nextZ);t++);for(h=u;v>0||h>0&&r;)0!==v&&(0===h||!r||n.z<=r.z)?(i=n,n=n.nextZ,v--):(i=r,r=r.nextZ,h--),a?a.nextZ=i:e=i,i.prevZ=a,a=i;n=r}a.nextZ=null,u*=2}while(o>1)}(i)}(e,r,i,f);for(var x,p,d=e;e.prev!==e.next;)if(x=e.prev,p=e.next,f?h(e,r,i,f):v(e))t.push(x.i/n),t.push(e.i/n),t.push(p.i/n),z(e),e=p.next,d=p.next;else if((e=p)===d){s?1===s?o(e=u(a(e),t,n),t,n,r,i,f,2):2===s&&l(e,t,n,r,i,f):o(a(e),t,n,r,i,f,1);break}}}function v(e){var t=e.prev,n=e,r=e.next;if(y(t,n,r)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(d(t.x,t.y,n.x,n.y,r.x,r.y,i.x,i.y)&&y(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function h(e,t,n,r){var i=e.prev,a=e,o=e.next;if(y(i,a,o)>=0)return!1;for(var v=i.x<a.x?i.x<o.x?i.x:o.x:a.x<o.x?a.x:o.x,h=i.y<a.y?i.y<o.y?i.y:o.y:a.y<o.y?a.y:o.y,u=i.x>a.x?i.x>o.x?i.x:o.x:a.x>o.x?a.x:o.x,l=i.y>a.y?i.y>o.y?i.y:o.y:a.y>o.y?a.y:o.y,f=c(v,h,t,n,r),s=c(u,l,t,n,r),x=e.prevZ,p=e.nextZ;x&&x.z>=f&&p&&p.z<=s;){if(x!==e.prev&&x!==e.next&&d(i.x,i.y,a.x,a.y,o.x,o.y,x.x,x.y)&&y(x.prev,x,x.next)>=0)return!1;if(x=x.prevZ,p!==e.prev&&p!==e.next&&d(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;x&&x.z>=f;){if(x!==e.prev&&x!==e.next&&d(i.x,i.y,a.x,a.y,o.x,o.y,x.x,x.y)&&y(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;p&&p.z<=s;){if(p!==e.prev&&p!==e.next&&d(i.x,i.y,a.x,a.y,o.x,o.y,p.x,p.y)&&y(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function u(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!m(i,o)&&M(i,r,r.next,o)&&S(i,o)&&S(o,i)&&(t.push(i.i/n),t.push(r.i/n),t.push(o.i/n),z(r),z(r.next),r=e=o),r=r.next}while(r!==e);return a(r)}function l(e,t,n,r,i,v){var h=e;do{for(var u=h.next.next;u!==h.prev;){if(h.i!==u.i&&g(h,u)){var l=Z(h,u);return h=a(h,h.next),l=a(l,l.next),o(h,t,n,r,i,v),void o(l,t,n,r,i,v)}u=u.next}h=h.next}while(h!==e)}function f(e,t){return e.x-t.x}function s(e,t){if(t=function(e,t){var n,r=t,i=e.x,a=e.y,o=-1/0;do{if(a<=r.y&&a>=r.next.y&&r.next.y!==r.y){var v=r.x+(a-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(v<=i&&v>o){if(o=v,v===i){if(a===r.y)return r;if(a===r.next.y)return r.next}n=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!n)return null;if(i===o)return n;var h,u=n,l=n.x,f=n.y,s=1/0;r=n;do{i>=r.x&&r.x>=l&&i!==r.x&&d(a<f?i:o,a,l,f,a<f?o:i,a,r.x,r.y)&&(h=Math.abs(a-r.y)/(i-r.x),S(r,e)&&(h<s||h===s&&(r.x>n.x||r.x===n.x&&x(n,r)))&&(n=r,s=h)),r=r.next}while(r!==u);return n}(e,t)){var n=Z(t,e);a(t,t.next),a(n,n.next)}}function x(e,t){return y(e.prev,e,t.prev)<0&&y(t.next,e,e.next)<0}function c(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-r)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function p(e){var t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n}function d(e,t,n,r,i,a,o,v){return(i-o)*(t-v)-(e-o)*(a-v)>=0&&(e-o)*(r-v)-(n-o)*(t-v)>=0&&(n-o)*(a-v)-(i-o)*(r-v)>=0}function g(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&M(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(S(e,t)&&S(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,a=(e.y+t.y)/2;do{n.y>a!=n.next.y>a&&n.next.y!==n.y&&i<(n.next.x-n.x)*(a-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(y(e.prev,e,t.prev)||y(e,t.prev,t))||m(e,t)&&y(e.prev,e,e.next)>0&&y(t.prev,t,t.next)>0)}function y(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function m(e,t){return e.x===t.x&&e.y===t.y}function M(e,t,n,r){var i=w(y(e,t,n)),a=w(y(e,t,r)),o=w(y(n,r,e)),v=w(y(n,r,t));return i!==a&&o!==v||(!(0!==i||!b(e,n,t))||(!(0!==a||!b(e,r,t))||(!(0!==o||!b(n,e,r))||!(0!==v||!b(n,t,r)))))}function b(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function w(e){return e>0?1:e<0?-1:0}function S(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function Z(e,t){var n=new F(e.i,e.x,e.y),r=new F(t.i,t.x,t.y),i=e.next,a=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,a.next=r,r.prev=a,r}function A(e,t,n,r){var i=new F(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function z(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function F(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function R(e,t,n,r){for(var i=0,a=t,o=n-r;a<n;a+=r)i+=(e[o]-e[a])*(e[a+1]+e[o+1]),o=a;return i}function q(e,t,n){var r=t[0],i=t[1],a=n[0]-r,o=n[1]-i;if(0!==a||0!==o){var v=((e[0]-r)*a+(e[1]-i)*o)/(a*a+o*o);v>1?(r=n[0],i=n[1]):v>0&&(r+=a*v,i+=o*v)}return(a=e[0]-r)*a+(o=e[1]-i)*o}function P(e,t,n,r,i){for(var a,o=r,v=t+1;v<n;v++){var h=q(e[v],e[t],e[n]);h>o&&(a=v,o=h)}o>r&&(a-t>1&&P(e,t,a,r,i),i.push(e[a]),n-a>1&&P(e,a,n,r,i))}function L(e,t){var n=e.length-1,r=[e[0]];return P(e,0,n,t,r),r.push(e[n]),r}function V(e,t,n){if(e.length<=2)return e;var r=void 0!==t?t*t:1;return e=L(e=n?e:function(e,t){for(var n,r,i,a,o,v=e[0],h=[v],u=1,l=e.length;u<l;u++)n=e[u],i=v,a=void 0,o=void 0,a=(r=n)[0]-i[0],o=r[1]-i[1],a*a+o*o>t&&(h.push(n),v=n);return v!==n&&h.push(n),h}(e,r),r)}function B(e,t){return e[0]*t[0]+e[1]*t[1]}function E(e,t){var n=t[0],r=t[1],i=Math.sqrt(n*n+r*r);return e[0]=n/i,e[1]=r/i,e}function U(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function H(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function I(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function O(e,t){var n=t[0],r=t[1],i=t[2],a=Math.sqrt(n*n+r*r+i*i);return e[0]=n/a,e[1]=r/a,e[2]=i/a,e}function T(e,t,n){var r=t[0],i=t[1],a=t[2],o=n[0],v=n[1],h=n[2];return e[0]=i*h-a*v,e[1]=a*o-r*h,e[2]=r*v-i*o,e}r.deviation=function(e,t,n,r){var i=t&&t.length,a=i?t[0]*n:e.length,o=Math.abs(R(e,0,a,n));if(i)for(var v=0,h=t.length;v<h;v++){var u=t[v]*n,l=v<h-1?t[v+1]*n:e.length;o-=Math.abs(R(e,u,l,n))}var f=0;for(v=0;v<r.length;v+=3){var s=r[v]*n,x=r[v+1]*n,c=r[v+2]*n;f+=Math.abs((e[s]-e[c])*(e[x+1]-e[s+1])-(e[s]-e[x])*(e[c+1]-e[s+1]))}return 0===o&&0===f?0:Math.abs((f-o)/o)},r.flatten=function(e){for(var t=e[0][0].length,n={vertices:[],holes:[],dimensions:t},r=0,i=0;i<e.length;i++){for(var a=0;a<e[i].length;a++)for(var o=0;o<t;o++)n.vertices.push(e[i][a][o]);i>0&&(r+=e[i-1].length,n.holes.push(r))}return n},t.default=n;var W=[];function j(e,t,n,r){var i=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}(t,n),a=Math.acos(i)*r;return U(W,n,t,-i),function(e,t){var n=t[0],r=t[1],i=t[2],a=Math.sqrt(n*n+r*r+i*i);e[0]=n/a,e[1]=r/a,e[2]=i/a}(W,W),function(e,t,n){e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n}(e,t,Math.cos(a)),U(e,e,W,Math.sin(a)),e}function k(e,t,n,r,i,a,o,v,h,u){var l=o-i,f=v-a,s=(l*(t-a)-f*(e-i))/(f*(n-e)-l*(r-t));return h&&(h[u=u||0]=e+s*(n-e),h[u+1]=t+s*(r-t)),s}function _(e,t,n){if(n-t<3)return 0;for(var r=0,i=2*(n-1),a=2*t;a<2*n;){var o=e[i],v=e[i+1],h=e[a],u=e[a+1];i=a,a+=2,r+=o*u-h*v}return r}function D(e,n,r){return void 0===r&&(r=2),t(e,n,r)}var C=[],G=[],J=[];function K(e,t,n,r,i,a,o,v,h){var u,l,f,s=null!=o,x=i,c=null;s&&(c=new Uint32Array(r-n));for(var p=[],d=n;d<r;d++){var g=d===r-1?n:d+1,y=d===n?r-1:d-1,m=e[2*y],M=e[2*y+1],b=e[2*d],w=e[2*d+1],S=e[2*g],Z=e[2*g+1];C[0]=b-m,C[1]=w-M,G[0]=S-b,G[1]=Z-w,E(C,C),E(G,G),s&&(c[d]=x);var A=!1,z=void 0,F=void 0;if(v||d!==n)if(v||d!==r-1){H(J,G,C);var R=J[1];J[1]=-J[0],J[0]=R,E(J,J);var q=B(J,G),P=Math.sqrt(1-q*q),L=a*Math.min(10,1/P);if(s&&1/P>o&&a*q<0){var V=b+J[0]*a,U=w+J[1]*a,I=Math.acos(P)/2,O=Math.tan(I)*Math.abs(a);t[2*x]=V+J[1]*O,t[2*x+1]=U-J[0]*O,t[2*++x]=V-J[1]*O,t[2*x+1]=U+J[0]*O,x++}else z=b+J[0]*L,F=w+J[1]*L,A=!0;if(A){if(h&&null!=u){var T=k(m,M,u,l,b,w,z,F,p,0);T>=-.01&&T<=1.01&&(t[2*f]=z=p[0],t[2*f+1]=F=p[1])}u=t[2*x]=z,l=t[2*x+1]=F,f=x,x++}}else J[0]=C[1],J[1]=-C[0],E(J,J),z=b+J[0]*a,F=w+J[1]*a,A=!0;else J[0]=G[1],J[1]=-G[0],E(J,J),u=t[2*x]=b+J[0]*a,l=t[2*x+1]=w+J[1]*a,f=x,x++}return c}function N(e,t,n,r,i,a,o,v){var h=null!=o,u=i,l=null;h&&(l=new Uint32Array(r-n));for(var f=n;f<r;f++){var s=f===r-1?n:f+1,x=f===n?r-1:f-1,c=e[2*x],p=e[2*x+1],d=e[2*f],g=e[2*f+1],y=e[2*s],m=e[2*s+1];if(C[0]=d-c,C[1]=g-p,G[0]=y-d,G[1]=m-g,E(C,C),E(G,G),h&&(l[f]=u),v||f!==n)if(v||f!==r-1){H(J,G,C);var M=J[1];J[1]=-J[0],J[0]=M,E(J,J);var b=B(J,G),w=Math.sqrt(1-b*b),S=a*Math.min(10,1/w);if(h&&1/w>o&&a*b<0){var Z=d+J[0]*a,A=g+J[1]*a,z=Math.acos(w)/2,F=Math.tan(z)*Math.abs(a);t[2*u]=Z+J[1]*F,t[2*u+1]=A-J[0]*F,t[2*++u]=Z-J[1]*F,t[2*u+1]=A+J[0]*F,u++}else t[2*u]=d+J[0]*S,t[2*u+1]=g+J[1]*S,u++}else J[0]=C[1],J[1]=-C[0],E(J,J),t[2*u]=d+J[0]*a,t[2*u+1]=g+J[1]*a,u++;else J[0]=G[1],J[1]=-G[0],E(J,J),t[2*u]=d+J[0]*a,t[2*u+1]=g+J[1]*a,u++}return l}function Q(e,t,n,r,i){var a=null!=r?[]:new Float32Array(e.length);if(K(e,a,0,t&&t.length?t[0]:e.length/2,0,n,r,i,!0),t)for(var o=0;o<t.length;o++){var v=t[o];K(e,a,v,t[o+1]||e.length/2,null!=r?a.length/2:v,n,r,i,!1)}return a}function X(e,t,n,r){for(var i=0;i<Math.floor((r-n)/2);i++)for(var a=0;a<t;a++){var o=(i+n)*t+a,v=(r-i-1)*t+a,h=e[o];e[o]=e[v],e[v]=h}return e}function Y(e,t){var n=e.length/2,r=0,i=t&&t.length?t[0]:n;_(e,r,i)>0&&X(e,2,r,i);for(var a=1;a<(t?t.length:0)+1;a++)_(e,r=t[a-1],i=t[a]||n)<0&&X(e,2,r,i)}function $(e){e.depth=e.depth||1,e.bevelSize=e.bevelSize||0,e.bevelSegments=null==e.bevelSegments?2:e.bevelSegments,e.smoothBevel=e.smoothBevel||!1,e.simplify=e.simplify||0,null==e.smoothSide&&(e.smoothSide="auto"),null==e.smoothSideThreshold&&(e.smoothSideThreshold=.9),"number"==typeof e.depth&&(e.bevelSize=Math.min(e.bevelSegments>0?e.bevelSize:0,e.depth/2)),e.bevelSize>0||(e.bevelSegments=0),e.bevelSegments=Math.round(e.bevelSegments);var t=e.boundingRect;if(e.translate=e.translate||[0,0],e.scale=e.scale||[1,1],e.fitRect){var n=null==e.fitRect.x?t.x||0:e.fitRect.x,r=null==e.fitRect.y?t.y||0:e.fitRect.y,i=e.fitRect.width,a=e.fitRect.height;null==i?null!=a?i=a/t.height*t.width:(i=t.width,a=t.height):null==a&&(a=i/t.width*t.height),e.scale=[i/t.width,a/t.height],e.translate=[(n-t.x)*e.scale[0],(r-t.y)*e.scale[1]]}}var ee=[[0,0],[1,0],[1,1],[0,0],[1,1],[0,1]];function te(e,t,n){for(var r=0,i=e[t],a=e[t+1],o=i,v=a,h=t+2;h<n;h+=2){var u=e[h],l=e[h+1];r+=Math.sqrt((u-i)*(u-i)+(l-a)*(l-a)),i=u,a=l}return r+=Math.sqrt((i-o)*(i-o)+(a-v)*(a-v))}function ne(e,t,n,r,i,a){var o=t.vertices,v=t.topVertices,h=t.splittedMap,u=t.depth,l=t.rect,f=r-n,s=a.smoothBevel?1:2,x=Math.min(u/2,a.bevelSize),c=a.bevelSegments,p=i.vertex,d=i.ringPerimeter,g=Math.max(l.width,l.height,u,d);function y(e){var t=(e+1)%f,n=o[2*e],r=o[2*e+1],i=o[2*t],a=o[2*t+1];return n===i&&r===a}if(x>0)for(var m=[0,0,1],M=[],b=[0,0,-1],w=[],S=0,Z=new Float32Array(f),A=0;A<2;A++)for(var z=0===A?u-x:x,F=0;F<=c*s;F++){for(var R=0,q=void 0,P=void 0,L=0;L<f;L++){var V=2*(L%f+n),B=h?2*h[V/2]:V;M[0]=o[V]-v[B],M[1]=o[V+1]-v[B+1],M[2]=0;var E=Math.sqrt(M[0]*M[0]+M[1]*M[1]);M[0]/=E,M[1]/=E;var U=(Math.floor(F/s)+F%s)/c;0===A?j(w,m,M,U):j(w,M,b,U);var H=0===A?U:1-U,I=x*Math.sin(H*Math.PI/2),O=E*Math.cos(H*Math.PI/2),T=x*E/Math.sqrt(I*I+O*O),W=w[0]*T+v[B],k=w[1]*T+v[B+1],_=w[2]*T+z;if(e.position[3*i.vertex]=W,e.position[3*i.vertex+1]=k,e.position[3*i.vertex+2]=_,L>0&&(R+=Math.sqrt((q-W)*(q-W)+(P-k)*(P-k))),F>0||A>0){var D=3*(i.vertex-f),C=e.position[D],G=e.position[D+1],J=e.position[D+2];Z[L]+=Math.sqrt((C-W)*(C-W)+(G-k)*(G-k)+(J-_)*(J-_))}if(e.uv[2*i.vertex]=R/g,e.uv[2*i.vertex+1]=Z[L]/g,q=W,P=k,i.vertex++,!y(L)&&(s>1&&F%s||1===s&&F>=1))for(var K=0;K<6;K++){var N=(ee[K][0]+L)%f,Q=ee[K][1]+S;e.indices[i.index++]=(Q-1)*f+N+p}}S++}else for(var X=0;X<2;X++)for(var Y=0===X?u-x:x,$=0,te=void 0,ne=void 0,re=0;re<f;re++){var ie=2*(re%f+n),ae=o[ie],oe=o[ie+1];e.position[3*i.vertex]=ae,e.position[3*i.vertex+1]=oe,e.position[3*i.vertex+2]=Y,re>0&&($+=Math.sqrt((te-ae)*(te-ae)+(ne-oe)*(ne-oe))),e.uv[2*i.vertex]=$/g,e.uv[2*i.vertex+1]=Y/g,te=ae,ne=oe,i.vertex++}for(var ve=x>0?c*s+1:1,he=0;he<f;he++)if(!y(he))for(var ue=0;ue<6;ue++){var le=(ee[ue][0]+he)%f,fe=ee[ue][1]+ve;e.indices[i.index++]=(fe-1)*f+le+p}}function re(e,t,n,r){var i=e.indices,a=e.topVertices,o=e.rect,v=e.depth;if(!(a.length<=4)){for(var h=n.vertex,u=i.length,l=0;l<u;l++)t.indices[n.index++]=h+i[l];for(var f=Math.max(o.width,o.height),s=0;s<(r.excludeBottom?1:2);s++)for(var x=0;x<a.length;x+=2){var c=a[x],p=a[x+1];t.position[3*n.vertex]=c,t.position[3*n.vertex+1]=p,t.position[3*n.vertex+2]=(1-s)*v,t.uv[2*n.vertex]=(c-o.x)/f,t.uv[2*n.vertex+1]=(p-o.y)/f,n.vertex++}if(!r.excludeBottom)for(var d=a.length/2,g=0;g<u;g+=3)for(var y=0;y<3;y++)t.indices[n.index++]=h+d+i[g+2-y]}}function ie(e,t,n,r){var i=null==n||"auto"===n;if(!0===n)return{vertices:e,holes:t};for(var a=[],o=t&&[],v=e.length/2,h=[],u=[],l=[],f=0,s=0,x=(t?t.length:0)+1,c=0;c<x;c++){0===c?s=t&&t.length?t[0]:v:(f=t[c-1],s=t[c]||v);for(var p=f;p<s;p++){var d=e[2*p],g=e[2*p+1],y=p===s-1?f:p+1,m=e[2*y],M=e[2*y+1];if(i){var b=p===f?s-1:p-1,w=e[2*b],S=e[2*b+1];h[0]=w-d,h[1]=S-g,u[0]=m-d,u[1]=M-g,E(h,h),E(u,u),1-(.5*B(h,u)+.5)>r?(a.push(d,g),l.push(p)):(a.push(d,g,d,g),l.push(p,p))}else a.push(d,g,d,g),l.push(p,p)}c<x-1&&o&&o.push(a.length/2)}return{vertices:new Float32Array(a),splittedMap:l,holes:o}}function ae(e,t){for(var n=0,r=0,i=0;i<e.length;i++){var a=e[i],o=a.indices,v=a.vertices,h=a.splittedMap,u=a.topVertices,l=a.depth,f=Math.min(l/2,t.bevelSize)>0?t.bevelSegments:0,s=e[i].holes||[];n+=o.length*(t.excludeBottom?1:2),r+=u.length/2*(t.excludeBottom?1:2);for(var x=2+2*f,c=0,p=0,d=0;d<s.length+1;d++){0===d?p=s.length?s[0]:v.length/2:(c=s[d-1],p=s[d]||v.length/2),n+=6*((h?h[p-1]+1:p)-(h?h[c]:c))*(x-1);var g=p-c;r+=g*x+(t.smoothBevel?0:f*g*2)}}for(var y={position:new Float32Array(3*r),indices:new(r>65535?Uint32Array:Uint16Array)(n),uv:new Float32Array(2*r)},m={vertex:0,index:0,ringPerimeter:0},M=0;M<e.length;M++)re(e[M],y,m,t);for(var b=0;b<e.length;b++){var w=e[b],S=w.holes,Z=w.vertices.length/2,A=0,z=S&&S.length?S[0]:Z;if(m.ringPerimeter=te(e[b].topVertices,A,z),ne(y,e[b],A,z,m,t),S)for(var F=0;F<S.length;F++)A=S[F],z=S[F+1]||Z,m.ringPerimeter=te(e[b].topVertices,A,z),ne(y,e[b],A,z,m,t)}for(var R=0;R<y.uv.length;R++){var q=y.uv[R];q>0&&Math.round(q)===q?y.uv[R]=1:y.uv[R]=q%1}return y.normal=function(e,t){function n(e,t,n,r){e[0]=t,e[1]=n,e[2]=r}for(var r=[],i=[],a=[],o=[],v=[],h=[],u=e.length,l=new Float32Array(t.length),f=0;f<u;){var s=3*e[f++],x=3*e[f++],c=3*e[f++];n(r,t[s],t[s+1],t[s+2]),n(i,t[x],t[x+1],t[x+2]),n(a,t[c],t[c+1],t[c+2]),I(o,r,i),I(v,i,a),T(h,o,v);for(var p=0;p<3;p++)l[s+p]=l[s+p]+h[p],l[x+p]=l[x+p]+h[p],l[c+p]=l[c+p]+h[p]}for(var d=0;d<l.length;)n(h,l[d],l[d+1],l[d+2]),O(h,h),l[d++]=h[0],l[d++]=h[1],l[d++]=h[2];return l}(y.indices,y.position),y.boundingRect=e[0]&&e[0].rect,y}function oe(e,t,n){for(var r=n.lineWidth,i=e.length,a=new Float32Array(2*i),o=n.translate||[0,0],v=n.scale||[1,1],h=0,u=0;h<i;h++)a[u++]=e[h][0]*v[0]+o[0],a[u++]=e[h][1]*v[1]+o[1];_(a,0,i)<0&&X(a,2,0,i);var l=[],f=[],s=n.miterLimit,x=N(a,f,0,i,0,-r/2,s,!1);X(a,2,0,i);for(var c=N(a,l,0,i,0,-r/2,s,!1),p=(l.length+f.length)/2,d=new Float32Array(2*p),g=0,y=f.length/2,m=0;m<f.length;m++)d[g++]=f[m];for(var M=0;M<l.length;M++)d[g++]=l[M];for(var b=new(p>65535?Uint32Array:Uint16Array)(3*(2*(i-1)+(p-2*i))),w=0,S=0;S<i-1;S++){var Z=S+1;b[w++]=y-1-x[S],b[w++]=y-1-x[S]-1,b[w++]=c[S]+1+y,b[w++]=y-1-x[S],b[w++]=c[S]+1+y,b[w++]=c[S]+y,c[Z]-c[S]==2?(b[w++]=c[S]+2+y,b[w++]=c[S]+1+y,b[w++]=y-x[Z]-1):x[Z]-x[S]==2&&(b[w++]=c[Z]+y,b[w++]=y-1-(x[S]+1),b[w++]=y-1-(x[S]+2))}var A=n.bevelSize>0?Q(d,[],n.bevelSize,null,!0):d,z=n.boundingRect,F=ie(d,null,n.smoothSide,n.smoothSideThreshold);return{vertices:F.vertices,rawVertices:A,splittedMap:F.splittedMap,indices:b,topVertices:A,rect:{x:z.x*v[0]+o[0],y:z.y*v[1]+o[1],width:z.width*v[0],height:z.height*v[1]},depth:"function"==typeof n.depth?n.depth(t):n.depth,holes:[]}}function ve(e,t){for(var n=[],r=0;r<e.length;r++){for(var i=e[r],a=[],o=i.length,v=i[o-1][0],h=i[o-1][1],u=0,l=0;l<o;l++){var f=i[l][0],s=i[l][1],x=f-v,c=s-h;(u+=Math.sqrt(x*x+c*c))>t&&(a.push(i[l]),u=0),v=f,h=s}a.length>=3&&n.push(a)}return n.length>0?n:null}function he(e,t){for(var n=[],r=0;r<e.length;r++){var i=e[r];(i=V(i,t,!0)).length>=3&&n.push(i)}return n.length>0?n:null}function ue(e,t,n){for(var r=0;r<e.length;r++)t[0]=Math.min(e[r][0],t[0]),t[1]=Math.min(e[r][1],t[1]),n[0]=Math.max(e[r][0],n[0]),n[1]=Math.max(e[r][1],n[1])}var le={x:0,y:0},fe={x:0,y:0};function se(e,t,n,r){for(var i=e.length,a=0;a<i;a++){var o=e[a].data;t=e[a].center||t;for(var v=0,h=o.length;v<h;v++)for(var u=o[v],l=0,f=u.length;l<f;l++)e[a].data[v][l]=xe(u[l],t,n,r)}}function xe(e,t,n,r){for(var i,a=[],o=0,v=(i=n?new Float64Array(e):new Float32Array(e)).length;o<v;o+=2){var h=i[o],u=i[o+1];if(t&&n&&r){le.x=h,le.y=u;var l=be(le,fe);le.x=l.x,le.y=l.y,h=(l=we(r,le,n,fe)).x,u=l.y,h-=t[0],u-=t[1]}a.push([h,u])}return a}function ce(e,t){void 0===t&&(t=!1);for(var n=e.length,r=[],i=[],a=[],o=0,v=0,h=0,u=0,l=0;l<n;l++){var f=t?de(e[l]):pe(e[l]),s=e[l].bottomHeight||0,x=f.position,c=f.normal,p=f.uv,d=f.indices;i.push(f);var g=d.length/3;a[l]=[o+1,o+g],o+=g;var y=x.length/3,m=c.length/3,M=p.length/2;r[l]={position:{middleZ:s+(e[l].height||0)/2,count:y,start:v,end:v+3*y},normal:{count:m,start:h,end:h+3*m},uv:{count:M,start:u,end:u+2*M},hide:!1},v+=3*y,h+=3*m,u+=2*M}var b=function(e){for(var t={},n={},r=0;r<e.length;++r){var i=e[r];for(var a in i)void 0===t[a]&&(t[a]=[],n[a]=0),t[a].push(i[a]),n[a]+=i[a].length}var o={},v=0,h=[];for(var u in t)if("indices"===u)for(var l=t[u],f=0,s=l.length;f<s;f++){for(var x=l[f],c=0,p=x.length;c<p;c++)h.push(x[c]+v);v+=t.position[f].length/3}else{var d=ge(t[u],n[u]);if(!d)return null;o[u]=d}return o.indices=new Uint32Array(h),o}(i),w=b.position,S=b.normal,Z=b.uv,A=b.indices;return{position:w.buffer,normal:S.buffer,uv:Z.buffer,indices:A.buffer,faceMap:a,geometriesAttributes:r}}function pe(e){var n=e.data,r=e.height,i=e.bottomHeight,a=function(e,n){n=Object.assign({},n);for(var r=[1/0,1/0],i=[-1/0,-1/0],a=0;a<e.length;a++)ue(e[a][0],r,i);n.boundingRect=n.boundingRect||{x:r[0],y:r[1],width:i[0]-r[0],height:i[1]-r[1]},$(n);for(var o=[],v=n.translate||[0,0],h=n.scale||[1,1],u=n.boundingRect,l={x:u.x*h[0]+v[0],y:u.y*h[1]+v[1],width:u.width*h[0],height:u.height*h[1]},f=Math.min(u.width,u.height)/1e5,s=0;s<e.length;s++){var x=ve(e[s],f);if(x){var c=n.simplify/Math.max(h[0],h[1]);if(c>0&&(x=he(x,c)),x){for(var p=t.flatten(x),d=p.vertices,g=p.holes,y=p.dimensions,m=0;m<d.length;)d[m]=d[m++]*h[0]+v[0],d[m]=d[m++]*h[1]+v[1];if(Y(d,g),2!==y)throw new Error("Only 2D polygon points are supported");var M=n.bevelSize>0?Q(d,g,n.bevelSize,null,!0):d,b=D(M,g,y),w=ie(d,g,n.smoothSide,n.smoothSideThreshold);o.push({indices:b,vertices:w.vertices,rawVertices:d,topVertices:M,holes:w.holes,splittedMap:w.splittedMap,rect:l,depth:"function"==typeof n.depth?n.depth(s):n.depth})}}}return ae(o,n)}(n,{depth:r}),o=a.position,v=a.normal,h=a.uv,u=a.indices;return ye(o,i),{position:o,normal:v,uv:h,indices:u}}function de(e){var t=e.data,n=e.height,r=e.width,i=e.bottomHeight,a=function(e,t){t=Object.assign({},t);for(var n=[1/0,1/0],r=[-1/0,-1/0],i=0;i<e.length;i++)ue(e[i],n,r);t.boundingRect=t.boundingRect||{x:n[0],y:n[1],width:r[0]-n[0],height:r[1]-n[1]},$(t);var a=t.scale||[1,1];null==t.lineWidth&&(t.lineWidth=1),null==t.miterLimit&&(t.miterLimit=2);for(var o=[],v=0;v<e.length;v++){var h=e[v],u=t.simplify/Math.max(a[0],a[1]);u>0&&(h=V(h,u,!0)),o.push(oe(h,v,t))}return ae(o,t)}(t,{lineWidth:r,depth:n}),o=a.position,v=a.normal,h=a.uv,u=a.indices;return ye(o,i),{position:o,normal:v,uv:h,indices:u}}function ge(e,t){for(var n=new Float32Array(t),r=0,i=0;i<e.length;++i)n.set(e[i],r),r+=e[i].length;return n}function ye(e,t){if(void 0!==t&&"number"==typeof t&&0!==t)for(var n=0,r=e.length;n<r;n+=3)e[n+2]+=t}var me=Math.PI/180,Me=6378137*Math.PI/180;function be(e,t){var n,r=85.0511287798,i=e.x,a=Math.max(Math.min(r,e.y),-r);n=0===a?0:Math.log(Math.tan((90+a)*me/2))/me;var o=i*Me,v=n*Me;return t?(t.x=o,t.y=v,t):{x:o,y:v}}function we(e,t,n,r){var i=e[0]*(t.x-e[2])/n,a=-e[1]*(t.y-e[3])/n;return r?(r.x=i,r.y=a,r):{x:i,y:a}}function Se(e){void 0===e&&(e=[]);for(var t=e.length,n=new Float32Array(3*t),r=0;r<t;r++){var i=e[r],a=3*r;n[a]=i[0],n[a+1]=i[1]}return n}function Ze(e){for(var t=new Float32Array(2*e.length-6),n=0,r=0,i=e.length/3;r<i;r++){var a=e[3*r],o=e[3*r+1],v=e[3*r+2];if(r>0&&r<i-1){var h=3*n;t[h]=a,t[h+1]=o,t[h+2]=v,n++}var u=3*n;t[u]=a,t[u+1]=o,t[u+2]=v,n++}return t}function Ae(e){var t=0,n=e.length;if(1===n)return e[0];for(var r=0;r<n;r++)t+=e[r].length;for(var i=new Float32Array(t),a=0,o=0;o<n;o++)i.set(e[o],a),a+=e[o].length;return i}e.initialize=function(){},e.onmessage=function(e,t){var n=e.data,r=n.type,i=n.datas,a=n.glRes,o=n.matrix,v=n.center;if("ExtrudePolygons"===r){se(i,v,a,o);var h=ce(i);t(null,h,[h.position,h.normal,h.uv,h.indices])}else if("ExtrudeLines"===r){for(var u=0,l=i.length;u<l;u++)for(var f=0,s=i[u].data.length;f<s;f++)i[u].data[f]=xe(i[u].data[f],i[u].center||v,a,o);var x=ce(i,!0);t(null,x,[x.position,x.normal,x.uv,x.indices])}else if("ExtrudePolygon"===r){var c=[],p=[];i.forEach((function(e){var t=[e];se(t,v,a,o);var n=ce(t),r=n.position,i=n.normal,h=n.uv,u=n.indices;c.push({id:e.id,position:r,normal:i,uv:h,indices:u}),p.push(r,i,h,u)})),t(null,c,p)}else if("Line"===r||"FatLine"===r){for(var d=[],g=[],y=0,m=i.length;y<m;y++){for(var M=[],b=0,w=i[y].data.length;b<w;b++){i[y].data[b]=xe(i[y].data[b],i[y].center||v,a,o);var S=Se(i[y].data[b]);M.push(Ze(S))}var Z=Ae(M);ye(Z,i[y].bottomHeight),d.push({id:i[y].id,position:Z.buffer}),g.push(Z.buffer)}t(null,d,g)}else if("Lines"===r||"FatLines"===r){for(var A=0,z=[],F=[],R=0,q=[],P=0,L=i.length;P<L;P++){for(var V=0,B=0,E=i[P].data.length;B<E;B++){i[P].data[B]=xe(i[P].data[B],i[P].center||v,a,o);var U=Se(i[P].data[B]);ye(U,i[P].bottomHeight),V+=U.length/3*2-2,q.push(Ze(U))}var H=V;z[P]=[A,A+H],A+=H,F[P]={position:{count:V,start:R,end:R+3*V},hide:!1},"FatLines"===r&&(F[P].instanceStart={count:V,start:R,end:R+3*V},F[P].instanceEnd={count:V,start:R,end:R+3*V}),R+=3*V}var I=Ae(q);t(null,{id:i.id,position:I.buffer,geometriesAttributes:F,faceMap:z},[I.buffer])}else if("ExtrudeLine"===r){for(var O=0,T=i.length;O<T;O++)for(var W=0,j=i[O].data.length;W<j;W++)i[O].data[W]=xe(i[O].data[W],i[O].center||v,a,o);var k=[],_=[];i.forEach((function(e){var t=ce([e],!0),n=t.position,r=t.normal,i=t.uv,a=t.indices;k.push({id:e.id,position:n,normal:r,uv:i,indices:a}),_.push(n,r,i,a)})),t(null,k,_)}},Object.defineProperty(e,"__esModule",{value:!0})})'),t.BaseObject=v,t.ExtrudeUtil=be,t.GeoJSONUtil=W,t.GeoUtil=un,t.IdentifyUtil=Mn,t.LineMaterial=d,t.LineUtil=Le,t.MergeGeometryUtil=A,t.MergedMixin=vn,t.ThreeLayer=Ti,t.ThreeRenderer=Li,t.geometryExtrude=oe,Object.defineProperty(t,"__esModule",{value:!0})}));
(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
    typeof define === 'function' && define.amd ? define(['exports'], factory) :
    (factory((global.turf = {})));
}(this, (function (exports) { 'use strict';

    /**
     * @module helpers
     */

    /**
     * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
     *
     * @memberof helpers
     * @type {number}
     */
    let earthRadius = 6371008.8;

    /**
     * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
     *
     * @memberof helpers
     * @type {Object}
     */
    let factors = {
        centimeters: earthRadius * 100,
        centimetres: earthRadius * 100,
        degrees: 180 / Math.PI, // See https://github.com/Turfjs/turf/issues/1406
        feet: earthRadius * 3.28084,
        inches: earthRadius * 39.370,
        kilometers: earthRadius / 1000,
        kilometres: earthRadius / 1000,
        meters: earthRadius,
        metres: earthRadius,
        miles: earthRadius / 1609.344,
        millimeters: earthRadius * 1000,
        millimetres: earthRadius * 1000,
        nauticalmiles: earthRadius / 1852,
        radians: 1,
        yards: earthRadius / 1.0936,
    };

    /**
     * Area of measurement factors based on 1 square meter.
     *
     * @memberof helpers
     * @type {Object}
     */
    let areaFactors = {
        acres: 0.000247105,
        centimeters: 10000,
        centimetres: 10000,
        feet: 10.763910417,
        inches: 1550.003100006,
        kilometers: 0.000001,
        kilometres: 0.000001,
        meters: 1,
        metres: 1,
        miles: 3.86e-7,
        millimeters: 1000000,
        millimetres: 1000000,
        yards: 1.195990046,
    };

    /**
     * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
     *
     * @name feature
     * @param {Geometry} geometry input geometry
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature} a GeoJSON Feature
     * @example
     * var geometry = {
     *   'type': 'Point',
     *   'coordinates': [110, 50]
     * };
     *
     * var feature = turf.feature(geometry);
     *
     * //=feature
     */
    function feature(geometry, properties, options) {
        options = checkIfOptionsExist(options);
        const feat = {type: 'Feature'};
        if (options.id === 0 || options.id) { feat.id = options.id; }
        if (options.bbox) { feat.bbox = options.bbox; }
        feat.properties = properties || {};
        feat.geometry = geometry;
        return feat;
    }

    /**
     * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
     * For GeometryCollection type use `helpers.geometryCollection`
     *
     * @name geometry
     * @param {string} type Geometry Type
     * @param {Array<any>} coordinates Coordinates
     * @returns {Geometry} a GeoJSON Geometry
     * @example
     * var type = 'Point';
     * var coordinates = [110, 50];
     * var geometry = turf.geometry(type, coordinates);
     * // => geometry
     */
    function geometry(type, coordinates) {
        switch (type) {
        case 'Point': return point(coordinates).geometry;
        case 'LineString': return lineString(coordinates).geometry;
        case 'Polygon': return polygon(coordinates).geometry;
        case 'MultiPoint': return multiPoint(coordinates).geometry;
        case 'MultiLineString': return multiLineString(coordinates).geometry;
        case 'MultiPolygon': return multiPolygon(coordinates).geometry;
        default: throw new Error(type + ' is invalid');
        }
    }

    /**
     * Creates a {@link Point} {@link Feature} from a Position.
     *
     * @name point
     * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<Point>} a Point feature
     * @example
     * var point = turf.point([-75.343, 39.984]);
     *
     * //=point
     */
    function point(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        const geom = {
            type: 'Point',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
     *
     * @name points
     * @param {Array<Array<number>>} coordinates an array of Points
     * @param {Object} [properties={}] Translate these properties to each Feature
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
     * associated with the FeatureCollection
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<Point>} Point Feature
     * @example
     * var points = turf.points([
     *   [-75, 39],
     *   [-80, 45],
     *   [-78, 50]
     * ]);
     *
     * //=points
     */
    function points(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        return featureCollection(coordinates.map((coords) => {
            return point(coords, properties);
        }), options);
    }

    /**
     * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
     *
     * @name polygon
     * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<Polygon>} Polygon Feature
     * @example
     * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
     *
     * //=polygon
     */
    function polygon(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        for (const ring of coordinates) {
            if (ring.length < 4) {
                throw new Error('Each LinearRing of a Polygon must have 4 or more Positions.');
            }
            for (let j = 0; j < ring[ring.length - 1].length; j++) {
                // Check if first point of Polygon contains two numbers
                if (ring[ring.length - 1][j] !== ring[0][j]) {
                    throw new Error('First and last Position are not equivalent.');
                }
            }
        }
        const geom = {
            type: 'Polygon',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
     *
     * @name polygons
     * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
     * @example
     * var polygons = turf.polygons([
     *   [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
     *   [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
     * ]);
     *
     * //=polygons
     */
    function polygons(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        return featureCollection(coordinates.map((coords) => {
            return polygon(coords, properties);
        }), options);
    }

    /**
     * Creates a {@link LineString} {@link Feature} from an Array of Positions.
     *
     * @name lineString
     * @param {Array<Array<number>>} coordinates an array of Positions
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<LineString>} LineString Feature
     * @example
     * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
     * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
     *
     * //=linestring1
     * //=linestring2
     */
    function lineString(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        if (coordinates.length < 2) { throw new Error('coordinates must be an array of two or more positions'); }
        const geom = {
            type: 'LineString',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
     *
     * @name lineStrings
     * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
     * associated with the FeatureCollection
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<LineString>} LineString FeatureCollection
     * @example
     * var linestrings = turf.lineStrings([
     *   [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
     *   [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
     * ]);
     *
     * //=linestrings
     */
    function lineStrings(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        return featureCollection(coordinates.map((coords) => {
            return lineString(coords, properties);
        }), options);
    }

    /**
     * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
     *
     * @name featureCollection
     * @param {Feature[]} features input features
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {FeatureCollection} FeatureCollection of Features
     * @example
     * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
     * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
     * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
     *
     * var collection = turf.featureCollection([
     *   locationA,
     *   locationB,
     *   locationC
     * ]);
     *
     * //=collection
     */
    function featureCollection(features, options) {
        options = checkIfOptionsExist(options);
        const fc = {type: 'FeatureCollection'};
        if (options.id) { fc.id = options.id; }
        if (options.bbox) { fc.bbox = options.bbox; }
        fc.features = features;
        return fc;
    }

    /**
     * Creates a {@link Feature<MultiLineString>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiLineString
     * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiLineString>} a MultiLineString feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
     *
     * //=multiLine
     */
    function multiLineString(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        const geom = {
            type: 'MultiLineString',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link Feature<MultiPoint>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiPoint
     * @param {Array<Array<number>>} coordinates an array of Positions
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiPoint>} a MultiPoint feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiPt = turf.multiPoint([[0,0],[10,10]]);
     *
     * //=multiPt
     */
    function multiPoint(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        const geom = {
            type: 'MultiPoint',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link Feature<MultiPolygon>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiPolygon
     * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiPolygon>} a multipolygon feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
     *
     * //=multiPoly
     *
     */
    function multiPolygon(coordinates, properties, options) {
        options = checkIfOptionsExist(options);
        const geom = {
            type: 'MultiPolygon',
            coordinates,
        };
        return feature(geom, properties, options);
    }

    /**
     * Creates a {@link Feature<GeometryCollection>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name geometryCollection
     * @param {Array<Geometry>} geometries an array of GeoJSON Geometries
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
     * @example
     * var pt = turf.geometry('Point', [100, 0]);
     * var line = turf.geometry('LineString', [[101, 0], [102, 1]]);
     * var collection = turf.geometryCollection([pt, line]);
     *
     * // => collection
     */
    function geometryCollection(geometries, properties, options) {
        options = checkIfOptionsExist(options);
        const geom = {
            type: 'GeometryCollection',
            geometries,
        };
        return feature(geom, properties, options);
    }

    /**
     * Round number to precision
     *
     * @param {number} num Number
     * @param {number} [precision=0] Precision
     * @returns {number} rounded number
     * @example
     * turf.round(120.4321)
     * //=120
     *
     * turf.round(120.4321, 2)
     * //=120.43
     */
    function round(num, precision) {
        if (precision && !(precision >= 0)) { throw new Error('precision must be a positive number'); }
        const multiplier = Math.pow(10, precision || 0);
        return Math.round(num * multiplier) / multiplier;
    }

    /**
     * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @name radiansToLength
     * @param {number} radians in radians across the sphere
     * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} distance
     */
    function radiansToLength(radians, units) {
        if (radians === undefined || radians === null) throw new Error('radians is required');
        if (units && typeof units !== 'string') throw new Error('units must be a string');

        var factor = factors[units || 'kilometers'];
        if (!factor) { throw new Error(units + ' units is invalid'); }
        return radians * factor;
    }

    /**
     * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @name lengthToRadians
     * @param {number} distance in real units
     * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} radians
     */
    function lengthToRadians(distance, units) {
        if (distance === undefined || distance === null) throw new Error('distance is required');
        if (units && typeof units !== 'string') throw new Error('units must be a string');

        var factor = factors[units || 'kilometers'];
        if (!factor) { throw new Error(units + ' units is invalid'); }
        return distance / factor;
    }

    /**
     * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
     *
     * @name lengthToDegrees
     * @param {number} distance in real units
     * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} degrees
     */
    function lengthToDegrees(distance, units) {
        if (units === null) units = 'kilometers';
        return radiansToDegrees(lengthToRadians(distance, units));
    }

    /**
     * Converts any bearing angle from the north line direction (positive clockwise)
     * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
     *
     * @name bearingToAzimuth
     * @param {number} bearing angle, between -180 and +180 degrees
     * @returns {number} angle between 0 and 360 degrees
     */
    function bearingToAzimuth(bearing) {
        if (bearing === null || bearing === undefined) throw new Error('bearing is required');

        let angle = bearing % 360;
        if (angle < 0) { angle += 360; }
        return angle;
    }

    /**
     * Converts an angle in radians to degrees
     *
     * @name radiansToDegrees
     * @param {number} radians angle in radians
     * @returns {number} degrees between 0 and 360 degrees
     */
    function radiansToDegrees(radians) {
        if (radians === null || radians === undefined) throw new Error('radians is required');

        const degrees = radians % (2 * Math.PI);
        return degrees * 180 / Math.PI;
    }

    /**
     * Converts an angle in degrees to radians
     *
     * @name degreesToRadians
     * @param {number} degrees angle between 0 and 360 degrees
     * @returns {number} angle in radians
     */
    function degreesToRadians(degrees) {
        if (degrees === null || degrees === undefined) throw new Error('degrees is required');

        const radians = degrees % 360;
        return radians * Math.PI / 180;
    }

    /**
     * Converts a length to the requested unit.
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @param {number} length to be converted
     * @param {Units} [originalUnit='kilometers'] of the length
     * @param {Units} [finalUnit='kilometers'] returned unit
     * @returns {number} the converted length
     */
    function convertLength(length, originalUnit, finalUnit) {
        if (length === null || length === undefined) throw new Error('length is required');

        return radiansToLength(lengthToRadians(length, originalUnit), finalUnit || 'kilometers');
    }

    /**
     * Converts a area to the requested unit.
     * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
     * @param {number} area to be converted
     * @param {Units} [originalUnit='meters'] of the distance
     * @param {Units} [finalUnit='kilometers'] returned unit
     * @returns {number} the converted distance
     */
    function convertArea(area, originalUnit, finalUnit) {
        if (area === null || area === undefined) throw new Error('area is required');
        if (!(area >= 0)) throw new Error('area must be a positive number');

        var startFactor = areaFactors[originalUnit || 'meters'];
        if (!startFactor) throw new Error('invalid original units');

        var finalFactor = areaFactors[finalUnit || 'kilometers'];
        if (!finalFactor) throw new Error('invalid final units');

        return (area / startFactor) * finalFactor;
    }

    /**
     * isNumber
     *
     * @param {*} num Number to validate
     * @returns {boolean} true/false
     * @example
     * turf.isNumber(123)
     * //=true
     * turf.isNumber('foo')
     * //=false
     */
    function isNumber(num) {
        return !isNaN(num) && num !== null && !Array.isArray(num);
    }

    /**
     * isObject
     *
     * @param {*} input variable to validate
     * @returns {boolean} true/false
     * @example
     * turf.isObject({elevation: 10})
     * //=true
     * turf.isObject('foo')
     * //=false
     */
    function isObject(input) {
        return (!!input) && (input.constructor === Object);
    }

    /**
     * Validate BBox
     *
     * @private
     * @param {Array<number>} bbox BBox to validate
     * @returns {void}
     * @throws Error if BBox is not valid
     * @example
     * validateBBox([-180, -40, 110, 50])
     * //=OK
     * validateBBox([-180, -40])
     * //=Error
     * validateBBox('Foo')
     * //=Error
     * validateBBox(5)
     * //=Error
     * validateBBox(null)
     * //=Error
     * validateBBox(undefined)
     * //=Error
     */
    function validateBBox(bbox) {
        if (!bbox) { throw new Error('bbox is required'); }
        if (!Array.isArray(bbox)) { throw new Error('bbox must be an Array'); }
        if (bbox.length !== 4 && bbox.length !== 6) { throw new Error('bbox must be an Array of 4 or 6 numbers'); }
        bbox.forEach((num) => {
            if (!isNumber(num)) { throw new Error('bbox must only contain numbers'); }
        });
    }

    /**
     * Validate Id
     *
     * @private
     * @param {string|number} id Id to validate
     * @returns {void}
     * @throws Error if Id is not valid
     * @example
     * validateId([-180, -40, 110, 50])
     * //=Error
     * validateId([-180, -40])
     * //=Error
     * validateId('Foo')
     * //=OK
     * validateId(5)
     * //=OK
     * validateId(null)
     * //=Error
     * validateId(undefined)
     * //=Error
     */
    function validateId(id) {
        if (!id) { throw new Error('id is required'); }
        if (['string', 'number'].indexOf(typeof id) === -1) { throw new Error('id must be a number or a string'); }
    }

    function checkIfOptionsExist(options) {
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        return options;
    }

    // Deprecated methods
    function radians2degrees() {
        throw new Error('method has been renamed to `radiansToDegrees`');
    }

    function degrees2radians() {
        throw new Error('method has been renamed to `degreesToRadians`');
    }

    function distanceToDegrees() {
        throw new Error('method has been renamed to `lengthToDegrees`');
    }

    function distanceToRadians() {
        throw new Error('method has been renamed to `lengthToRadians`');
    }

    function radiansToDistance() {
        throw new Error('method has been renamed to `radiansToLength`');
    }

    function bearingToAngle() {
        throw new Error('method has been renamed to `bearingToAzimuth`');
    }

    function convertDistance() {
        throw new Error('method has been renamed to `convertLength`');
    }

    var index = /*#__PURE__*/Object.freeze({
        earthRadius: earthRadius,
        factors: factors,
        areaFactors: areaFactors,
        feature: feature,
        geometry: geometry,
        point: point,
        points: points,
        polygon: polygon,
        polygons: polygons,
        lineString: lineString,
        lineStrings: lineStrings,
        featureCollection: featureCollection,
        multiLineString: multiLineString,
        multiPoint: multiPoint,
        multiPolygon: multiPolygon,
        geometryCollection: geometryCollection,
        round: round,
        radiansToLength: radiansToLength,
        lengthToRadians: lengthToRadians,
        lengthToDegrees: lengthToDegrees,
        bearingToAzimuth: bearingToAzimuth,
        radiansToDegrees: radiansToDegrees,
        degreesToRadians: degreesToRadians,
        convertLength: convertLength,
        convertArea: convertArea,
        isNumber: isNumber,
        isObject: isObject,
        validateBBox: validateBBox,
        validateId: validateId,
        checkIfOptionsExist: checkIfOptionsExist,
        radians2degrees: radians2degrees,
        degrees2radians: degrees2radians,
        distanceToDegrees: distanceToDegrees,
        distanceToRadians: distanceToRadians,
        radiansToDistance: radiansToDistance,
        bearingToAngle: bearingToAngle,
        convertDistance: convertDistance
    });

    /**
     * Callback for coordEach
     *
     * @callback coordEachCallback
     * @param {Array<number>} currentCoord The current coordinate being processed.
     * @param {number} coordIndex The current index of the coordinate being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     */

    /**
     * Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
     *
     * @name coordEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)
     * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=currentCoord
     *   //=coordIndex
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     * });
     */
    function coordEach(geojson, callback, excludeWrapCoord) {
        // Handles null Geometry -- Skips this GeoJSON
        if (geojson === null) return;
        var j, k, l, geometry$$1, stopG, coords,
            geometryMaybeCollection,
            wrapShrink = 0,
            coordIndex = 0,
            isGeometryCollection,
            type = geojson.type,
            isFeatureCollection = type === 'FeatureCollection',
            isFeature = type === 'Feature',
            stop = isFeatureCollection ? geojson.features.length : 1;

        // This logic may look a little weird. The reason why it is that way
        // is because it's trying to be fast. GeoJSON supports multiple kinds
        // of objects at its root: FeatureCollection, Features, Geometries.
        // This function has the responsibility of handling all of them, and that
        // means that some of the `for` loops you see below actually just don't apply
        // to certain inputs. For instance, if you give this just a
        // Point geometry, then both loops are short-circuited and all we do
        // is gradually rename the input until it's called 'geometry'.
        //
        // This also aims to allocate as few resources as possible: just a
        // few numbers and booleans, rather than any temporary arrays as would
        // be required with the normalization approach.
        for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
            geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
                (isFeature ? geojson.geometry : geojson));
            isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
            stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;

            for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
                var multiFeatureIndex = 0;
                var geometryIndex = 0;
                geometry$$1 = isGeometryCollection ?
                    geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;

                // Handles null Geometry -- Skips this geometry
                if (geometry$$1 === null) continue;
                coords = geometry$$1.coordinates;
                var geomType = geometry$$1.type;

                wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;

                switch (geomType) {
                case null:
                    break;
                case 'Point':
                    if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                    coordIndex++;
                    multiFeatureIndex++;
                    break;
                case 'LineString':
                case 'MultiPoint':
                    for (j = 0; j < coords.length; j++) {
                        if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                        coordIndex++;
                        if (geomType === 'MultiPoint') multiFeatureIndex++;
                    }
                    if (geomType === 'LineString') multiFeatureIndex++;
                    break;
                case 'Polygon':
                case 'MultiLineString':
                    for (j = 0; j < coords.length; j++) {
                        for (k = 0; k < coords[j].length - wrapShrink; k++) {
                            if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                            coordIndex++;
                        }
                        if (geomType === 'MultiLineString') multiFeatureIndex++;
                        if (geomType === 'Polygon') geometryIndex++;
                    }
                    if (geomType === 'Polygon') multiFeatureIndex++;
                    break;
                case 'MultiPolygon':
                    for (j = 0; j < coords.length; j++) {
                        geometryIndex = 0;
                        for (k = 0; k < coords[j].length; k++) {
                            for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
                                if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                                coordIndex++;
                            }
                            geometryIndex++;
                        }
                        multiFeatureIndex++;
                    }
                    break;
                case 'GeometryCollection':
                    for (j = 0; j < geometry$$1.geometries.length; j++)
                        if (coordEach(geometry$$1.geometries[j], callback, excludeWrapCoord) === false) return false;
                    break;
                default:
                    throw new Error('Unknown Geometry Type');
                }
            }
        }
    }

    /**
     * Callback for coordReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback coordReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Array<number>} currentCoord The current coordinate being processed.
     * @param {number} coordIndex The current index of the coordinate being processed.
     * Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     */

    /**
     * Reduce coordinates in any GeoJSON object, similar to Array.reduce()
     *
     * @name coordReduce
     * @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=previousValue
     *   //=currentCoord
     *   //=coordIndex
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   return currentCoord;
     * });
     */
    function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
        var previousValue = initialValue;
        coordEach(geojson, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
            if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
            else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex);
        }, excludeWrapCoord);
        return previousValue;
    }

    /**
     * Callback for propEach
     *
     * @callback propEachCallback
     * @param {Object} currentProperties The current Properties being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Iterate over properties in any GeoJSON object, similar to Array.forEach()
     *
     * @name propEach
     * @param {FeatureCollection|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentProperties, featureIndex)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.propEach(features, function (currentProperties, featureIndex) {
     *   //=currentProperties
     *   //=featureIndex
     * });
     */
    function propEach(geojson, callback) {
        var i;
        switch (geojson.type) {
        case 'FeatureCollection':
            for (i = 0; i < geojson.features.length; i++) {
                if (callback(geojson.features[i].properties, i) === false) break;
            }
            break;
        case 'Feature':
            callback(geojson.properties, 0);
            break;
        }
    }


    /**
     * Callback for propReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback propReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {*} currentProperties The current Properties being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Reduce properties in any GeoJSON object into a single value,
     * similar to how Array.reduce works. However, in this case we lazily run
     * the reduction, so an array of all properties is unnecessary.
     *
     * @name propReduce
     * @param {FeatureCollection|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
     *   //=previousValue
     *   //=currentProperties
     *   //=featureIndex
     *   return currentProperties
     * });
     */
    function propReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        propEach(geojson, function (currentProperties, featureIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
            else previousValue = callback(previousValue, currentProperties, featureIndex);
        });
        return previousValue;
    }

    /**
     * Callback for featureEach
     *
     * @callback featureEachCallback
     * @param {Feature<any>} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Iterate over features in any GeoJSON object, similar to
     * Array.forEach.
     *
     * @name featureEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentFeature, featureIndex)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {foo: 'bar'}),
     *   turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.featureEach(features, function (currentFeature, featureIndex) {
     *   //=currentFeature
     *   //=featureIndex
     * });
     */
    function featureEach(geojson, callback) {
        if (geojson.type === 'Feature') {
            callback(geojson, 0);
        } else if (geojson.type === 'FeatureCollection') {
            for (var i = 0; i < geojson.features.length; i++) {
                if (callback(geojson.features[i], i) === false) break;
            }
        }
    }

    /**
     * Callback for featureReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback featureReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Reduce features in any GeoJSON object, similar to Array.reduce().
     *
     * @name featureReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
     *   //=previousValue
     *   //=currentFeature
     *   //=featureIndex
     *   return currentFeature
     * });
     */
    function featureReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        featureEach(geojson, function (currentFeature, featureIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
            else previousValue = callback(previousValue, currentFeature, featureIndex);
        });
        return previousValue;
    }

    /**
     * Get all coordinates from any GeoJSON object.
     *
     * @name coordAll
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @returns {Array<Array<number>>} coordinate position array
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {foo: 'bar'}),
     *   turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * var coords = turf.coordAll(features);
     * //= [[26, 37], [36, 53]]
     */
    function coordAll(geojson) {
        var coords = [];
        coordEach(geojson, function (coord) {
            coords.push(coord);
        });
        return coords;
    }

    /**
     * Callback for geomEach
     *
     * @callback geomEachCallback
     * @param {Geometry} currentGeometry The current Geometry being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {Object} featureProperties The current Feature Properties being processed.
     * @param {Array<number>} featureBBox The current Feature BBox being processed.
     * @param {number|string} featureId The current Feature Id being processed.
     */

    /**
     * Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
     *
     * @name geomEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
     *   //=currentGeometry
     *   //=featureIndex
     *   //=featureProperties
     *   //=featureBBox
     *   //=featureId
     * });
     */
    function geomEach(geojson, callback) {
        var i, j, g, geometry$$1, stopG,
            geometryMaybeCollection,
            isGeometryCollection,
            featureProperties,
            featureBBox,
            featureId,
            featureIndex = 0,
            isFeatureCollection = geojson.type === 'FeatureCollection',
            isFeature = geojson.type === 'Feature',
            stop = isFeatureCollection ? geojson.features.length : 1;

        // This logic may look a little weird. The reason why it is that way
        // is because it's trying to be fast. GeoJSON supports multiple kinds
        // of objects at its root: FeatureCollection, Features, Geometries.
        // This function has the responsibility of handling all of them, and that
        // means that some of the `for` loops you see below actually just don't apply
        // to certain inputs. For instance, if you give this just a
        // Point geometry, then both loops are short-circuited and all we do
        // is gradually rename the input until it's called 'geometry'.
        //
        // This also aims to allocate as few resources as possible: just a
        // few numbers and booleans, rather than any temporary arrays as would
        // be required with the normalization approach.
        for (i = 0; i < stop; i++) {

            geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
                (isFeature ? geojson.geometry : geojson));
            featureProperties = (isFeatureCollection ? geojson.features[i].properties :
                (isFeature ? geojson.properties : {}));
            featureBBox = (isFeatureCollection ? geojson.features[i].bbox :
                (isFeature ? geojson.bbox : undefined));
            featureId = (isFeatureCollection ? geojson.features[i].id :
                (isFeature ? geojson.id : undefined));
            isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
            stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;

            for (g = 0; g < stopG; g++) {
                geometry$$1 = isGeometryCollection ?
                    geometryMaybeCollection.geometries[g] : geometryMaybeCollection;

                // Handle null Geometry
                if (geometry$$1 === null) {
                    if (callback(null, featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    continue;
                }
                switch (geometry$$1.type) {
                case 'Point':
                case 'LineString':
                case 'MultiPoint':
                case 'Polygon':
                case 'MultiLineString':
                case 'MultiPolygon': {
                    if (callback(geometry$$1, featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    break;
                }
                case 'GeometryCollection': {
                    for (j = 0; j < geometry$$1.geometries.length; j++) {
                        if (callback(geometry$$1.geometries[j], featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    }
                    break;
                }
                default:
                    throw new Error('Unknown Geometry Type');
                }
            }
            // Only increase `featureIndex` per each feature
            featureIndex++;
        }
    }

    /**
     * Callback for geomReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback geomReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Geometry} currentGeometry The current Geometry being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {Object} featureProperties The current Feature Properties being processed.
     * @param {Array<number>} featureBBox The current Feature BBox being processed.
     * @param {number|string} featureId The current Feature Id being processed.
     */

    /**
     * Reduce geometry in any GeoJSON object, similar to Array.reduce().
     *
     * @name geomReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
     *   //=previousValue
     *   //=currentGeometry
     *   //=featureIndex
     *   //=featureProperties
     *   //=featureBBox
     *   //=featureId
     *   return currentGeometry
     * });
     */
    function geomReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        geomEach(geojson, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
            else previousValue = callback(previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId);
        });
        return previousValue;
    }

    /**
     * Callback for flattenEach
     *
     * @callback flattenEachCallback
     * @param {Feature} currentFeature The current flattened feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     */

    /**
     * Iterate over flattened features in any GeoJSON object, similar to
     * Array.forEach.
     *
     * @name flattenEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentFeature, featureIndex, multiFeatureIndex)
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
     * ]);
     *
     * turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) {
     *   //=currentFeature
     *   //=featureIndex
     *   //=multiFeatureIndex
     * });
     */
    function flattenEach(geojson, callback) {
        geomEach(geojson, function (geometry$$1, featureIndex, properties, bbox, id) {
            // Callback for single geometry
            var type = (geometry$$1 === null) ? null : geometry$$1.type;
            switch (type) {
            case null:
            case 'Point':
            case 'LineString':
            case 'Polygon':
                if (callback(feature(geometry$$1, properties, {bbox: bbox, id: id}), featureIndex, 0) === false) return false;
                return;
            }

            var geomType;

            // Callback for multi-geometry
            switch (type) {
            case 'MultiPoint':
                geomType = 'Point';
                break;
            case 'MultiLineString':
                geomType = 'LineString';
                break;
            case 'MultiPolygon':
                geomType = 'Polygon';
                break;
            }

            for (var multiFeatureIndex = 0; multiFeatureIndex < geometry$$1.coordinates.length; multiFeatureIndex++) {
                var coordinate = geometry$$1.coordinates[multiFeatureIndex];
                var geom = {
                    type: geomType,
                    coordinates: coordinate
                };
                if (callback(feature(geom, properties), featureIndex, multiFeatureIndex) === false) return false;
            }
        });
    }

    /**
     * Callback for flattenReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback flattenReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     */

    /**
     * Reduce flattened features in any GeoJSON object, similar to Array.reduce().
     *
     * @name flattenReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
     * ]);
     *
     * turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {
     *   //=previousValue
     *   //=currentFeature
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   return currentFeature
     * });
     */
    function flattenReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        flattenEach(geojson, function (currentFeature, featureIndex, multiFeatureIndex) {
            if (featureIndex === 0 && multiFeatureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
            else previousValue = callback(previousValue, currentFeature, featureIndex, multiFeatureIndex);
        });
        return previousValue;
    }

    /**
     * Callback for segmentEach
     *
     * @callback segmentEachCallback
     * @param {Feature<LineString>} currentSegment The current Segment being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     * @param {number} segmentIndex The current index of the Segment being processed.
     * @returns {void}
     */

    /**
     * Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
     * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON
     * @param {Function} callback a method that takes (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)
     * @returns {void}
     * @example
     * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
     *
     * // Iterate over GeoJSON by 2-vertex segments
     * turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
     *   //=currentSegment
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   //=segmentIndex
     * });
     *
     * // Calculate the total number of segments
     * var total = 0;
     * turf.segmentEach(polygon, function () {
     *     total++;
     * });
     */
    function segmentEach(geojson, callback) {
        flattenEach(geojson, function (feature$$1, featureIndex, multiFeatureIndex) {
            var segmentIndex = 0;

            // Exclude null Geometries
            if (!feature$$1.geometry) return;
            // (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
            var type = feature$$1.geometry.type;
            if (type === 'Point' || type === 'MultiPoint') return;

            // Generate 2-vertex line segments
            var previousCoords;
            var previousFeatureIndex = 0;
            var previousMultiIndex = 0;
            var prevGeomIndex = 0;
            if (coordEach(feature$$1, function (currentCoord, coordIndex, featureIndexCoord, multiPartIndexCoord, geometryIndex) {
                // Simulating a meta.coordReduce() since `reduce` operations cannot be stopped by returning `false`
                if (previousCoords === undefined || featureIndex > previousFeatureIndex || multiPartIndexCoord > previousMultiIndex || geometryIndex > prevGeomIndex) {
                    previousCoords = currentCoord;
                    previousFeatureIndex = featureIndex;
                    previousMultiIndex = multiPartIndexCoord;
                    prevGeomIndex = geometryIndex;
                    segmentIndex = 0;
                    return;
                }
                var currentSegment = lineString([previousCoords, currentCoord], feature$$1.properties);
                if (callback(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) === false) return false;
                segmentIndex++;
                previousCoords = currentCoord;
            }) === false) return false;
        });
    }

    /**
     * Callback for segmentReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback segmentReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature<LineString>} currentSegment The current Segment being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     * @param {number} segmentIndex The current index of the Segment being processed.
     */

    /**
     * Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
     * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON
     * @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {void}
     * @example
     * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
     *
     * // Iterate over GeoJSON by 2-vertex segments
     * turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
     *   //= previousSegment
     *   //= currentSegment
     *   //= featureIndex
     *   //= multiFeatureIndex
     *   //= geometryIndex
     *   //= segmentInex
     *   return currentSegment
     * });
     *
     * // Calculate the total number of segments
     * var initialValue = 0
     * var total = turf.segmentReduce(polygon, function (previousValue) {
     *     previousValue++;
     *     return previousValue;
     * }, initialValue);
     */
    function segmentReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        var started = false;
        segmentEach(geojson, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
            if (started === false && initialValue === undefined) previousValue = currentSegment;
            else previousValue = callback(previousValue, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex);
            started = true;
        });
        return previousValue;
    }

    /**
     * Callback for lineEach
     *
     * @callback lineEachCallback
     * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed
     * @param {number} featureIndex The current index of the Feature being processed
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed
     * @param {number} geometryIndex The current index of the Geometry being processed
     */

    /**
     * Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
     * similar to Array.forEach.
     *
     * @name lineEach
     * @param {Geometry|Feature<LineString|Polygon|MultiLineString|MultiPolygon>} geojson object
     * @param {Function} callback a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)
     * @example
     * var multiLine = turf.multiLineString([
     *   [[26, 37], [35, 45]],
     *   [[36, 53], [38, 50], [41, 55]]
     * ]);
     *
     * turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=currentLine
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     * });
     */
    function lineEach(geojson, callback) {
        // validation
        if (!geojson) throw new Error('geojson is required');

        flattenEach(geojson, function (feature$$1, featureIndex, multiFeatureIndex) {
            if (feature$$1.geometry === null) return;
            var type = feature$$1.geometry.type;
            var coords = feature$$1.geometry.coordinates;
            switch (type) {
            case 'LineString':
                if (callback(feature$$1, featureIndex, multiFeatureIndex, 0, 0) === false) return false;
                break;
            case 'Polygon':
                for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
                    if (callback(lineString(coords[geometryIndex], feature$$1.properties), featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                }
                break;
            }
        });
    }

    /**
     * Callback for lineReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback lineReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed.
     * @param {number} featureIndex The current index of the Feature being processed
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed
     * @param {number} geometryIndex The current index of the Geometry being processed
     */

    /**
     * Reduce features in any GeoJSON object, similar to Array.reduce().
     *
     * @name lineReduce
     * @param {Geometry|Feature<LineString|Polygon|MultiLineString|MultiPolygon>} geojson object
     * @param {Function} callback a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var multiPoly = turf.multiPolygon([
     *   turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
     *   turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
     * ]);
     *
     * turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=previousValue
     *   //=currentLine
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   return currentLine
     * });
     */
    function lineReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        lineEach(geojson, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentLine;
            else previousValue = callback(previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex);
        });
        return previousValue;
    }

    /**
     * Finds a particular 2-vertex LineString Segment from a GeoJSON using `../meta` indexes.
     *
     * Negative indexes are permitted.
     * Point & MultiPoint will always return null.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.featureIndex=0] Feature Index
     * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index
     * @param {number} [options.geometryIndex=0] Geometry Index
     * @param {number} [options.segmentIndex=0] Segment Index
     * @param {Object} [options.properties={}] Translate Properties to output LineString
     * @param {BBox} [options.bbox={}] Translate BBox to output LineString
     * @param {number|string} [options.id={}] Translate Id to output LineString
     * @returns {Feature<LineString>} 2-vertex GeoJSON Feature LineString
     * @example
     * var multiLine = turf.multiLineString([
     *     [[10, 10], [50, 30], [30, 40]],
     *     [[-10, -10], [-50, -30], [-30, -40]]
     * ]);
     *
     * // First Segment (defaults are 0)
     * turf.findSegment(multiLine);
     * // => Feature<LineString<[[10, 10], [50, 30]]>>
     *
     * // First Segment of 2nd Multi Feature
     * turf.findSegment(multiLine, {multiFeatureIndex: 1});
     * // => Feature<LineString<[[-10, -10], [-50, -30]]>>
     *
     * // Last Segment of Last Multi Feature
     * turf.findSegment(multiLine, {multiFeatureIndex: -1, segmentIndex: -1});
     * // => Feature<LineString<[[-50, -30], [-30, -40]]>>
     */
    function findSegment(geojson, options) {
        // Optional Parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var featureIndex = options.featureIndex || 0;
        var multiFeatureIndex = options.multiFeatureIndex || 0;
        var geometryIndex = options.geometryIndex || 0;
        var segmentIndex = options.segmentIndex || 0;

        // Find FeatureIndex
        var properties = options.properties;
        var geometry$$1;

        switch (geojson.type) {
        case 'FeatureCollection':
            if (featureIndex < 0) featureIndex = geojson.features.length + featureIndex;
            properties = properties || geojson.features[featureIndex].properties;
            geometry$$1 = geojson.features[featureIndex].geometry;
            break;
        case 'Feature':
            properties = properties || geojson.properties;
            geometry$$1 = geojson.geometry;
            break;
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
        case 'Polygon':
        case 'MultiLineString':
        case 'MultiPolygon':
            geometry$$1 = geojson;
            break;
        default:
            throw new Error('geojson is invalid');
        }

        // Find SegmentIndex
        if (geometry$$1 === null) return null;
        var coords = geometry$$1.coordinates;
        switch (geometry$$1.type) {
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
            if (segmentIndex < 0) segmentIndex = coords.length + segmentIndex - 1;
            return lineString([coords[segmentIndex], coords[segmentIndex + 1]], properties, options);
        case 'Polygon':
            if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
            if (segmentIndex < 0) segmentIndex = coords[geometryIndex].length + segmentIndex - 1;
            return lineString([coords[geometryIndex][segmentIndex], coords[geometryIndex][segmentIndex + 1]], properties, options);
        case 'MultiLineString':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;
            return lineString([coords[multiFeatureIndex][segmentIndex], coords[multiFeatureIndex][segmentIndex + 1]], properties, options);
        case 'MultiPolygon':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (geometryIndex < 0) geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
            if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;
            return lineString([coords[multiFeatureIndex][geometryIndex][segmentIndex], coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]], properties, options);
        }
        throw new Error('geojson is invalid');
    }

    /**
     * Finds a particular Point from a GeoJSON using `../meta` indexes.
     *
     * Negative indexes are permitted.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.featureIndex=0] Feature Index
     * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index
     * @param {number} [options.geometryIndex=0] Geometry Index
     * @param {number} [options.coordIndex=0] Coord Index
     * @param {Object} [options.properties={}] Translate Properties to output Point
     * @param {BBox} [options.bbox={}] Translate BBox to output Point
     * @param {number|string} [options.id={}] Translate Id to output Point
     * @returns {Feature<Point>} 2-vertex GeoJSON Feature Point
     * @example
     * var multiLine = turf.multiLineString([
     *     [[10, 10], [50, 30], [30, 40]],
     *     [[-10, -10], [-50, -30], [-30, -40]]
     * ]);
     *
     * // First Segment (defaults are 0)
     * turf.findPoint(multiLine);
     * // => Feature<Point<[10, 10]>>
     *
     * // First Segment of the 2nd Multi-Feature
     * turf.findPoint(multiLine, {multiFeatureIndex: 1});
     * // => Feature<Point<[-10, -10]>>
     *
     * // Last Segment of last Multi-Feature
     * turf.findPoint(multiLine, {multiFeatureIndex: -1, coordIndex: -1});
     * // => Feature<Point<[-30, -40]>>
     */
    function findPoint(geojson, options) {
        // Optional Parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var featureIndex = options.featureIndex || 0;
        var multiFeatureIndex = options.multiFeatureIndex || 0;
        var geometryIndex = options.geometryIndex || 0;
        var coordIndex = options.coordIndex || 0;

        // Find FeatureIndex
        var properties = options.properties;
        var geometry$$1;

        switch (geojson.type) {
        case 'FeatureCollection':
            if (featureIndex < 0) featureIndex = geojson.features.length + featureIndex;
            properties = properties || geojson.features[featureIndex].properties;
            geometry$$1 = geojson.features[featureIndex].geometry;
            break;
        case 'Feature':
            properties = properties || geojson.properties;
            geometry$$1 = geojson.geometry;
            break;
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
        case 'Polygon':
        case 'MultiLineString':
        case 'MultiPolygon':
            geometry$$1 = geojson;
            break;
        default:
            throw new Error('geojson is invalid');
        }

        // Find Coord Index
        if (geometry$$1 === null) return null;
        var coords = geometry$$1.coordinates;
        switch (geometry$$1.type) {
        case 'Point':
            return point(coords, properties, options);
        case 'MultiPoint':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            return point(coords[multiFeatureIndex], properties, options);
        case 'LineString':
            if (coordIndex < 0) coordIndex = coords.length + coordIndex;
            return point(coords[coordIndex], properties, options);
        case 'Polygon':
            if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
            if (coordIndex < 0) coordIndex = coords[geometryIndex].length + coordIndex;
            return point(coords[geometryIndex][coordIndex], properties, options);
        case 'MultiLineString':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (coordIndex < 0) coordIndex = coords[multiFeatureIndex].length + coordIndex;
            return point(coords[multiFeatureIndex][coordIndex], properties, options);
        case 'MultiPolygon':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (geometryIndex < 0) geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
            if (coordIndex < 0) coordIndex = coords[multiFeatureIndex][geometryIndex].length - coordIndex;
            return point(coords[multiFeatureIndex][geometryIndex][coordIndex], properties, options);
        }
        throw new Error('geojson is invalid');
    }

    var index$1 = /*#__PURE__*/Object.freeze({
        coordEach: coordEach,
        coordReduce: coordReduce,
        propEach: propEach,
        propReduce: propReduce,
        featureEach: featureEach,
        featureReduce: featureReduce,
        coordAll: coordAll,
        geomEach: geomEach,
        geomReduce: geomReduce,
        flattenEach: flattenEach,
        flattenReduce: flattenReduce,
        segmentEach: segmentEach,
        segmentReduce: segmentReduce,
        lineEach: lineEach,
        lineReduce: lineReduce,
        findSegment: findSegment,
        findPoint: findPoint
    });

    /**
     * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
     *
     * @name bbox
     * @param {GeoJSON} geojson any GeoJSON object
     * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
     * @example
     * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
     * var bbox = turf.bbox(line);
     * var bboxPolygon = turf.bboxPolygon(bbox);
     *
     * //addToMap
     * var addToMap = [line, bboxPolygon]
     */
    function bbox(geojson) {
        const result = [Infinity, Infinity, -Infinity, -Infinity];
        coordEach(geojson, (coord) => {
            if (result[0] > coord[0]) { result[0] = coord[0]; }
            if (result[1] > coord[1]) { result[1] = coord[1]; }
            if (result[2] < coord[0]) { result[2] = coord[0]; }
            if (result[3] < coord[1]) { result[3] = coord[1]; }
        });
        return result;
    }

    /**
     * Unwrap a coordinate from a Point Feature, Geometry or a single coordinate.
     *
     * @name getCoord
     * @param {Array<number>|Geometry<Point>|Feature<Point>} coord GeoJSON Point or an Array of numbers
     * @returns {Array<number>} coordinates
     * @example
     * var pt = turf.point([10, 10]);
     *
     * var coord = turf.getCoord(pt);
     * //= [10, 10]
     */
    function getCoord(coord) {
        if (!coord) { throw new Error('coord is required'); }

        if (!Array.isArray(coord)) {
            if (coord.type === 'Feature' && coord.geometry !== null && coord.geometry.type === 'Point') {
                return coord.geometry.coordinates;
            }
            if (coord.type === 'Point') {
                return coord.coordinates;
            }
        }
        if (Array.isArray(coord) && coord.length >= 2 && !Array.isArray(coord[0]) && !Array.isArray(coord[1])) {
            return coord;
        }

        throw new Error('coord must be GeoJSON Point or an Array of numbers');
    }

    /**
     * Unwrap coordinates from a Feature, Geometry Object or an Array
     *
     * @name getCoords
     * @param {Array<any>|Geometry|Feature} coords Feature, Geometry Object or an Array
     * @returns {Array<any>} coordinates
     * @example
     * var poly = turf.polygon([[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]);
     *
     * var coords = turf.getCoords(poly);
     * //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]]
     */
    function getCoords(coords) {
        if (Array.isArray(coords)) { return coords; }

        // Feature
        if (coords.type === 'Feature') {
            if (coords.geometry !== null) { return coords.geometry.coordinates; }
        } else {
            // Geometry
            if (coords.coordinates) { return coords.coordinates; }
        }

        throw new Error('coords must be GeoJSON Feature, Geometry Object or an Array');
    }

    /**
     * Checks if coordinates contains a number
     *
     * @name containsNumber
     * @param {Array<any>} coordinates GeoJSON Coordinates
     * @returns {boolean} true if Array contains a number
     */
    function containsNumber(coordinates) {
        if (coordinates.length > 1 && isNumber(coordinates[0]) && isNumber(coordinates[1])) {
            return true;
        }

        if (Array.isArray(coordinates[0]) && coordinates[0].length) {
            return containsNumber(coordinates[0]);
        }
        throw new Error('coordinates must only contain numbers');
    }

    /**
     * Enforce expectations about types of GeoJSON objects for Turf.
     *
     * @name geojsonType
     * @param {GeoJSON} value any GeoJSON object
     * @param {string} type expected GeoJSON type
     * @param {string} name name of calling function
     * @throws {Error} if value is not the expected type.
     */
    function geojsonType(value, type, name) {
        if (!type || !name) { throw new Error('type and name required'); }

        if (!value || value.type !== type) {
            throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + value.type);
        }
    }

    /**
     * Enforce expectations about types of {@link Feature} inputs for Turf.
     * Internally this uses {@link geojsonType} to judge geometry types.
     *
     * @name featureOf
     * @param {Feature} feature a feature with an expected geometry type
     * @param {string} type expected GeoJSON type
     * @param {string} name name of calling function
     * @throws {Error} error if value is not the expected type.
     */
    function featureOf(feature$$1, type, name) {
        if (!feature$$1) { throw new Error('No feature passed'); }
        if (!name) { throw new Error('.featureOf() requires a name'); }
        if (!feature$$1 || feature$$1.type !== 'Feature' || !feature$$1.geometry) {
            throw new Error('Invalid input to ' + name + ', Feature with geometry required');
        }
        if (!feature$$1.geometry || feature$$1.geometry.type !== type) {
            throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + feature$$1.geometry.type);
        }
    }

    /**
     * Enforce expectations about types of {@link FeatureCollection} inputs for Turf.
     * Internally this uses {@link geojsonType} to judge geometry types.
     *
     * @name collectionOf
     * @param {FeatureCollection} featureCollection a FeatureCollection for which features will be judged
     * @param {string} type expected GeoJSON type
     * @param {string} name name of calling function
     * @throws {Error} if value is not the expected type.
     */
    function collectionOf(featureCollection$$1, type, name) {
        if (!featureCollection$$1) { throw new Error('No featureCollection passed'); }
        if (!name) { throw new Error('.collectionOf() requires a name'); }
        if (!featureCollection$$1 || featureCollection$$1.type !== 'FeatureCollection') {
            throw new Error('Invalid input to ' + name + ', FeatureCollection required');
        }
        for (const feature$$1 of featureCollection$$1.features) {
            if (!feature$$1 || feature$$1.type !== 'Feature' || !feature$$1.geometry) {
                throw new Error('Invalid input to ' + name + ', Feature with geometry required');
            }
            if (!feature$$1.geometry || feature$$1.geometry.type !== type) {
                throw new Error('Invalid input to ' + name + ': must be a ' + type + ', given ' + feature$$1.geometry.type);
            }
        }
    }

    /**
     * Get Geometry from Feature or Geometry Object
     *
     * @param {Feature|Geometry} geojson GeoJSON Feature or Geometry Object
     * @returns {Geometry|null} GeoJSON Geometry Object
     * @throws {Error} if geojson is not a Feature or Geometry Object
     * @example
     * var point = {
     *   'type': 'Feature',
     *   'properties': {},
     *   'geometry': {
     *     'type': 'Point',
     *     'coordinates': [110, 40]
     *   }
     * }
     * var geom = turf.getGeom(point)
     * //={'type': 'Point', 'coordinates': [110, 40]}
     */
    function getGeom(geojson){
        if (geojson.type === 'Feature') { return geojson.geometry; }
        return geojson;
    }

    /**
     * Get GeoJSON object's type, Geometry type is prioritize.
     *
     * @param {GeoJSON} geojson GeoJSON object
     * @param {string} [name='geojson'] name of the variable to display in error message
     * @returns {string} GeoJSON type
     * @example
     * var point = {
     *   'type': 'Feature',
     *   'properties': {},
     *   'geometry': {
     *     'type': 'Point',
     *     'coordinates': [110, 40]
     *   }
     * }
     * var geom = turf.getType(point)
     * //='Point'
     */
    function getType(geojson, name) {
        if (geojson.type === 'FeatureCollection') { return 'FeatureCollection'; }
        if (geojson.type === 'GeometryCollection') { return 'GeometryCollection'; }
        if (geojson.type === 'Feature' && geojson.geometry !== null) { return geojson.geometry.type; }
        return geojson.type;
    }

    var index$2 = /*#__PURE__*/Object.freeze({
        getCoord: getCoord,
        getCoords: getCoords,
        containsNumber: containsNumber,
        geojsonType: geojsonType,
        featureOf: featureOf,
        collectionOf: collectionOf,
        getGeom: getGeom,
        getType: getType
    });

    /**
     * @license GNU Affero General Public License.
     * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
     * v. 1.2.0
     * https://github.com/RaumZeit/MarchingSquares.js
     */

    /**
     * Compute the isocontour(s) of a scalar 2D field given
     * a certain threshold by applying the Marching Squares
     * Algorithm. The function returns a list of path coordinates
     */
    var defaultSettings = {
        successCallback: null,
        verbose: false
    };

    var settings = {};

    function isoContours(data, threshold, options) {
        /* process options */
        options = options ? options : {};

        var optionKeys = Object.keys(defaultSettings);

        for (var i = 0; i < optionKeys.length; i++) {
            var key = optionKeys[i];
            var val = options[key];
            val = ((typeof val !== 'undefined') && (val !== null)) ? val : defaultSettings[key];

            settings[key] = val;
        }

        if (settings.verbose)
            console.log('MarchingSquaresJS-isoContours: computing isocontour for ' + threshold);

        var ret = contourGrid2Paths(computeContourGrid(data, threshold));

        if (typeof settings.successCallback === 'function')
            settings.successCallback(ret);

        return ret;
    }

    /*
      Thats all for the public interface, below follows the actual
      implementation
    */

    /*
    ################################
    Isocontour implementation below
    ################################
    */

    /* assume that x1 == 1 &&  x0 == 0 */
    function interpolateX(y, y0, y1) {
        return (y - y0) / (y1 - y0);
    }

    /* compute the isocontour 4-bit grid */
    function computeContourGrid(data, threshold) {
        var rows = data.length - 1;
        var cols = data[0].length - 1;
        var ContourGrid = { rows: rows, cols: cols, cells: [] };

        for (var j = 0; j < rows; ++j) {
            ContourGrid.cells[j] = [];
            for (var i = 0; i < cols; ++i) {
                /* compose the 4-bit corner representation */
                var cval = 0;

                var tl = data[j + 1][i];
                var tr = data[j + 1][i + 1];
                var br = data[j][i + 1];
                var bl = data[j][i];

                if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
                    continue;
                }
                cval |= ((tl >= threshold) ? 8 : 0);
                cval |= ((tr >= threshold) ? 4 : 0);
                cval |= ((br >= threshold) ? 2 : 0);
                cval |= ((bl >= threshold) ? 1 : 0);

                /* resolve ambiguity for cval == 5 || 10 via averaging */
                var flipped = false;
                if (cval === 5 || cval === 10) {
                    var average = (tl + tr + br + bl) / 4;
                    if (cval === 5 && (average < threshold)) {
                        cval = 10;
                        flipped = true;
                    } else if (cval === 10 && (average < threshold)) {
                        cval = 5;
                        flipped = true;
                    }
                }

                /* add cell to ContourGrid if it contains edges */
                if (cval !== 0 && cval !== 15) {
                    var top, bottom, left, right;
                    top = bottom = left = right = 0.5;
                    /* interpolate edges of cell */
                    if (cval === 1) {
                        left    = 1 - interpolateX(threshold, tl, bl);
                        bottom  = 1 - interpolateX(threshold, br, bl);
                    } else if (cval === 2) {
                        bottom  = interpolateX(threshold, bl, br);
                        right   = 1 - interpolateX(threshold, tr, br);
                    } else if (cval === 3) {
                        left    = 1 - interpolateX(threshold, tl, bl);
                        right   = 1 - interpolateX(threshold, tr, br);
                    } else if (cval === 4) {
                        top     = interpolateX(threshold, tl, tr);
                        right   = interpolateX(threshold, br, tr);
                    } else if (cval === 5) {
                        top     = interpolateX(threshold, tl, tr);
                        right   = interpolateX(threshold, br, tr);
                        bottom  = 1 - interpolateX(threshold, br, bl);
                        left    = 1 - interpolateX(threshold, tl, bl);
                    } else if (cval === 6) {
                        bottom  = interpolateX(threshold, bl, br);
                        top     = interpolateX(threshold, tl, tr);
                    } else if (cval === 7) {
                        left    = 1 - interpolateX(threshold, tl, bl);
                        top     = interpolateX(threshold, tl, tr);
                    } else if (cval === 8) {
                        left    = interpolateX(threshold, bl, tl);
                        top     = 1 - interpolateX(threshold, tr, tl);
                    } else if (cval === 9) {
                        bottom  = 1 - interpolateX(threshold, br, bl);
                        top     = 1 - interpolateX(threshold, tr, tl);
                    } else if (cval === 10) {
                        top     = 1 - interpolateX(threshold, tr, tl);
                        right   = 1 - interpolateX(threshold, tr, br);
                        bottom  = interpolateX(threshold, bl, br);
                        left    = interpolateX(threshold, bl, tl);
                    } else if (cval === 11) {
                        top     = 1 - interpolateX(threshold, tr, tl);
                        right   = 1 - interpolateX(threshold, tr, br);
                    } else if (cval === 12) {
                        left    = interpolateX(threshold, bl, tl);
                        right   = interpolateX(threshold, br, tr);
                    } else if (cval === 13) {
                        bottom  = 1 - interpolateX(threshold, br, bl);
                        right   = interpolateX(threshold, br, tr);
                    } else if (cval === 14) {
                        left    = interpolateX(threshold, bl, tl);
                        bottom  = interpolateX(threshold, bl, br);
                    } else {
                        console.log('MarchingSquaresJS-isoContours: Illegal cval detected: ' + cval);
                    }
                    ContourGrid.cells[j][i] = {
                        cval: cval,
                        flipped: flipped,
                        top: top,
                        right: right,
                        bottom: bottom,
                        left: left
                    };
                }

            }
        }

        return ContourGrid;
    }

    function isSaddle(cell) {
        return cell.cval === 5 || cell.cval === 10;
    }

    function isTrivial(cell) {
        return cell.cval === 0 || cell.cval === 15;
    }

    function clearCell(cell) {
        if ((!isTrivial(cell)) && (cell.cval !== 5) && (cell.cval !== 10)) {
            cell.cval = 15;
        }
    }

    function getXY(cell, edge) {
        if (edge === 'top') {
            return [cell.top, 1.0];
        } else if (edge === 'bottom') {
            return [cell.bottom, 0.0];
        } else if (edge === 'right') {
            return [1.0, cell.right];
        } else if (edge === 'left') {
            return [0.0, cell.left];
        }
    }

    function contourGrid2Paths(grid) {
        var paths = [];
        var path_idx = 0;
        var rows = grid.rows;
        var cols = grid.cols;
        var epsilon = 1e-7;

        grid.cells.forEach(function (g, j) {
            g.forEach(function (gg, i) {
                if ((typeof gg !== 'undefined') && (!isSaddle(gg)) && (!isTrivial(gg))) {
                    var p = tracePath(grid.cells, j, i);
                    var merged = false;
                    /* we may try to merge paths at this point */
                    if (p.info === 'mergeable') {
                        /*
                search backwards through the path array to find an entry
                that starts with where the current path ends...
              */
                        var x = p.path[p.path.length - 1][0],
                            y = p.path[p.path.length - 1][1];

                        for (var k = path_idx - 1; k >= 0; k--) {
                            if ((Math.abs(paths[k][0][0] - x) <= epsilon) && (Math.abs(paths[k][0][1] - y) <= epsilon)) {
                                for (var l = p.path.length - 2; l >= 0; --l) {
                                    paths[k].unshift(p.path[l]);
                                }
                                merged = true;
                                break;
                            }
                        }
                    }
                    if (!merged)
                        paths[path_idx++] = p.path;
                }
            });
        });

        return paths;
    }

    /*
      construct consecutive line segments from starting cell by
      walking arround the enclosed area clock-wise
      */
    function tracePath(grid, j, i) {
        var maxj = grid.length;
        var p = [];
        var dxContour = [0, 0, 1, 1, 0, 0, 0, 0, -1, 0, 1, 1, -1, 0, -1, 0];
        var dyContour = [0, -1, 0, 0, 1, 1, 1, 1, 0, -1, 0, 0, 0, -1, 0, 0];
        var dx, dy;
        var startEdge = ['none', 'left', 'bottom', 'left', 'right', 'none', 'bottom', 'left', 'top', 'top', 'none', 'top', 'right', 'right', 'bottom', 'none'];
        var nextEdge  = ['none', 'bottom', 'right', 'right', 'top', 'top', 'top', 'top', 'left', 'bottom', 'right', 'right', 'left', 'bottom', 'left', 'none'];
        var edge;

        var startCell   = grid[j][i];
        var currentCell = grid[j][i];

        var cval = currentCell.cval;
        var edge = startEdge[cval];

        var pt = getXY(currentCell, edge);

        /* push initial segment */
        p.push([i + pt[0], j + pt[1]]);
        edge = nextEdge[cval];
        pt = getXY(currentCell, edge);
        p.push([i + pt[0], j + pt[1]]);
        clearCell(currentCell);

        /* now walk arround the enclosed area in clockwise-direction */
        var k = i + dxContour[cval];
        var l = j + dyContour[cval];
        var prev_cval = cval;

        while ((k >= 0) && (l >= 0) && (l < maxj) && ((k != i) || (l != j))) {
            currentCell = grid[l][k];
            if (typeof currentCell === 'undefined') { /* path ends here */
                //console.log(k + " " + l + " is undefined, stopping path!");
                break;
            }
            cval = currentCell.cval;
            if ((cval === 0) || (cval === 15)) {
                return { path: p, info: 'mergeable' };
            }
            edge  = nextEdge[cval];
            dx    = dxContour[cval];
            dy    = dyContour[cval];
            if ((cval === 5) || (cval === 10)) {
                /* select upper or lower band, depending on previous cells cval */
                if (cval === 5) {
                    if (currentCell.flipped) { /* this is actually a flipped case 10 */
                        if (dyContour[prev_cval] === -1) {
                            edge  = 'left';
                            dx    = -1;
                            dy    = 0;
                        } else {
                            edge  = 'right';
                            dx    = 1;
                            dy    = 0;
                        }
                    } else { /* real case 5 */
                        if (dxContour[prev_cval] === -1) {
                            edge  = 'bottom';
                            dx    = 0;
                            dy    = -1;
                        }
                    }
                } else if (cval === 10) {
                    if (currentCell.flipped) { /* this is actually a flipped case 5 */
                        if (dxContour[prev_cval] === -1) {
                            edge  = 'top';
                            dx    = 0;
                            dy    = 1;
                        } else {
                            edge  = 'bottom';
                            dx    = 0;
                            dy    = -1;
                        }
                    } else {  /* real case 10 */
                        if (dyContour[prev_cval] === 1) {
                            edge  = 'left';
                            dx    = -1;
                            dy    = 0;
                        }
                    }
                }
            }
            pt = getXY(currentCell, edge);
            p.push([k + pt[0], l + pt[1]]);
            clearCell(currentCell);
            k += dx;
            l += dy;
            prev_cval = cval;
        }

        return { path: p, info: 'closed' };
    }

    /**
     * Takes a {@link Point} grid and returns a correspondent matrix {Array<Array<number>>}
     * of the 'property' values
     *
     * @name gridToMatrix
     * @param {FeatureCollection<Point>} grid of points
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
     * @param {boolean} [options.flip=false] returns the matrix upside-down
     * @param {boolean} [options.flags=false] flags, adding a `matrixPosition` array field ([row, column]) to its properties,
     * the grid points with coordinates on the matrix
     * @returns {Array<Array<number>>} matrix of property values
     * @example
     *   var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
     *   var cellSize = 3;
     *   var grid = turf.pointGrid(extent, cellSize);
     *   // add a random property to each point between 0 and 60
     *   for (var i = 0; i < grid.features.length; i++) {
     *     grid.features[i].properties.elevation = (Math.random() * 60);
     *   }
     *   gridToMatrix(grid);
     *   //= [
     *     [ 1, 13, 10,  9, 10, 13, 18],
     *     [34,  8,  5,  4,  5,  8, 13],
     *     [10,  5,  2,  1,  2,  5,  4],
     *     [ 0,  4, 56, 19,  1,  4,  9],
     *     [10,  5,  2,  1,  2,  5, 10],
     *     [57,  8,  5,  4,  5,  0, 57],
     *     [ 3, 13, 10,  9,  5, 13, 18],
     *     [18, 13, 10,  9, 78, 13, 18]
     *   ]
     */
    function gridToMatrix(grid, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var zProperty = options.zProperty || 'elevation';
        var flip = options.flip;
        var flags = options.flags;

        // validation
        collectionOf(grid, 'Point', 'input must contain Points');

        var pointsMatrix = sortPointsByLatLng(grid, flip);

        var matrix = [];
        // create property matrix from sorted points
        // looping order matters here
        for (var r = 0; r < pointsMatrix.length; r++) {
            var pointRow = pointsMatrix[r];
            var row = [];
            for (var c = 0; c < pointRow.length; c++) {
                var point$$1 = pointRow[c];
                // Check if zProperty exist
                if (point$$1.properties[zProperty]) row.push(point$$1.properties[zProperty]);
                else row.push(0);
                // add flags
                if (flags === true) point$$1.properties.matrixPosition = [r, c];
            }
            matrix.push(row);
        }

        return matrix;
    }

    /**
     * Sorts points by latitude and longitude, creating a 2-dimensional array of points
     *
     * @private
     * @param {FeatureCollection<Point>} points GeoJSON Point features
     * @param {boolean} [flip=false] returns the matrix upside-down
     * @returns {Array<Array<Point>>} points ordered by latitude and longitude
     */
    function sortPointsByLatLng(points$$1, flip) {
        var pointsByLatitude = {};

        // divide points by rows with the same latitude
        featureEach(points$$1, function (point$$1) {
            var lat = getCoords(point$$1)[1];
            if (!pointsByLatitude[lat]) pointsByLatitude[lat] = [];
            pointsByLatitude[lat].push(point$$1);
        });

        // sort points (with the same latitude) by longitude
        var orderedRowsByLatitude = Object.keys(pointsByLatitude).map(function (lat) {
            var row = pointsByLatitude[lat];
            var rowOrderedByLongitude = row.sort(function (a, b) {
                return getCoords(a)[0] - getCoords(b)[0];
            });
            return rowOrderedByLongitude;
        });

        // sort rows (of points with the same latitude) by latitude
        var pointMatrix = orderedRowsByLatitude.sort(function (a, b) {
            if (flip) return getCoords(a[0])[1] - getCoords(b[0])[1];
            else return getCoords(b[0])[1] - getCoords(a[0])[1];
        });

        return pointMatrix;
    }

    /**
     * Takes a grid {@link FeatureCollection} of {@link Point} features with z-values and an array of
     * value breaks and generates [isolines](http://en.wikipedia.org/wiki/Isoline).
     *
     * @name isolines
     * @param {FeatureCollection<Point>} pointGrid input points
     * @param {Array<number>} breaks values of `zProperty` where to draw isolines
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
     * @param {Object} [options.commonProperties={}] GeoJSON properties passed to ALL isolines
     * @param {Array<Object>} [options.breaksProperties=[]] GeoJSON properties passed, in order, to the correspondent isoline;
     * the breaks array will define the order in which the isolines are created
     * @returns {FeatureCollection<MultiLineString>} a FeatureCollection of {@link MultiLineString} features representing isolines
     * @example
     * // create a grid of points with random z-values in their properties
     * var extent = [0, 30, 20, 50];
     * var cellWidth = 100;
     * var pointGrid = turf.pointGrid(extent, cellWidth, {units: 'miles'});
     *
     * for (var i = 0; i < pointGrid.features.length; i++) {
     *     pointGrid.features[i].properties.temperature = Math.random() * 10;
     * }
     * var breaks = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
     *
     * var lines = turf.isolines(pointGrid, breaks, {zProperty: 'temperature'});
     *
     * //addToMap
     * var addToMap = [lines];
     */
    function isolines(pointGrid, breaks, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var zProperty = options.zProperty || 'elevation';
        var commonProperties = options.commonProperties || {};
        var breaksProperties = options.breaksProperties || [];

        // Input validation
        collectionOf(pointGrid, 'Point', 'Input must contain Points');
        if (!breaks) throw new Error('breaks is required');
        if (!Array.isArray(breaks)) throw new Error('breaks must be an Array');
        if (!isObject(commonProperties)) throw new Error('commonProperties must be an Object');
        if (!Array.isArray(breaksProperties)) throw new Error('breaksProperties must be an Array');

        // Isoline methods
        var matrix = gridToMatrix(pointGrid, {zProperty: zProperty, flip: true});
        var createdIsoLines = createIsoLines(matrix, breaks, zProperty, commonProperties, breaksProperties);
        var scaledIsolines = rescaleIsolines(createdIsoLines, matrix, pointGrid);

        return featureCollection(scaledIsolines);
    }

    /**
     * Creates the isolines lines (featuresCollection of MultiLineString features) from the 2D data grid
     *
     * Marchingsquares process the grid data as a 3D representation of a function on a 2D plane, therefore it
     * assumes the points (x-y coordinates) are one 'unit' distance. The result of the isolines function needs to be
     * rescaled, with turfjs, to the original area and proportions on the map
     *
     * @private
     * @param {Array<Array<number>>} matrix Grid Data
     * @param {Array<number>} breaks Breaks
     * @param {string} zProperty name of the z-values property
     * @param {Object} [commonProperties={}] GeoJSON properties passed to ALL isolines
     * @param {Object} [breaksProperties=[]] GeoJSON properties passed to the correspondent isoline
     * @returns {Array<MultiLineString>} isolines
     */
    function createIsoLines(matrix, breaks, zProperty, commonProperties, breaksProperties) {
        var results = [];
        for (var i = 1; i < breaks.length; i++) {
            var threshold = +breaks[i]; // make sure it's a number

            var properties = Object.assign(
                {},
                commonProperties,
                breaksProperties[i]
            );
            properties[zProperty] = threshold;
            var isoline = multiLineString(isoContours(matrix, threshold), properties);

            results.push(isoline);
        }
        return results;
    }

    /**
     * Translates and scales isolines
     *
     * @private
     * @param {Array<MultiLineString>} createdIsoLines to be rescaled
     * @param {Array<Array<number>>} matrix Grid Data
     * @param {Object} points Points by Latitude
     * @returns {Array<MultiLineString>} isolines
     */
    function rescaleIsolines(createdIsoLines, matrix, points$$1) {

        // get dimensions (on the map) of the original grid
        var gridBbox = bbox(points$$1); // [ minX, minY, maxX, maxY ]
        var originalWidth = gridBbox[2] - gridBbox[0];
        var originalHeigth = gridBbox[3] - gridBbox[1];

        // get origin, which is the first point of the last row on the rectangular data on the map
        var x0 = gridBbox[0];
        var y0 = gridBbox[1];

        // get number of cells per side
        var matrixWidth = matrix[0].length - 1;
        var matrixHeight = matrix.length - 1;

        // calculate the scaling factor between matrix and rectangular grid on the map
        var scaleX = originalWidth / matrixWidth;
        var scaleY = originalHeigth / matrixHeight;

        var resize = function (point$$1) {
            point$$1[0] = point$$1[0] * scaleX + x0;
            point$$1[1] = point$$1[1] * scaleY + y0;
        };

        // resize and shift each point/line of the createdIsoLines
        createdIsoLines.forEach(function (isoline) {
            coordEach(isoline, resize);
        });
        return createdIsoLines;
    }

    var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

    function unwrapExports (x) {
    	return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
    }

    function createCommonjsModule(fn, module) {
    	return module = { exports: {} }, fn(module, module.exports), module.exports;
    }

    var quickselect = createCommonjsModule(function (module, exports) {
    (function (global, factory) {
    	module.exports = factory();
    }(commonjsGlobal, (function () {
    function quickselect(arr, k, left, right, compare) {
        quickselectStep(arr, k, left || 0, right || (arr.length - 1), compare || defaultCompare);
    }

    function quickselectStep(arr, k, left, right, compare) {

        while (right > left) {
            if (right - left > 600) {
                var n = right - left + 1;
                var m = k - left + 1;
                var z = Math.log(n);
                var s = 0.5 * Math.exp(2 * z / 3);
                var sd = 0.5 * Math.sqrt(z * s * (n - s) / n) * (m - n / 2 < 0 ? -1 : 1);
                var newLeft = Math.max(left, Math.floor(k - m * s / n + sd));
                var newRight = Math.min(right, Math.floor(k + (n - m) * s / n + sd));
                quickselectStep(arr, k, newLeft, newRight, compare);
            }

            var t = arr[k];
            var i = left;
            var j = right;

            swap(arr, left, k);
            if (compare(arr[right], t) > 0) swap(arr, left, right);

            while (i < j) {
                swap(arr, i, j);
                i++;
                j--;
                while (compare(arr[i], t) < 0) i++;
                while (compare(arr[j], t) > 0) j--;
            }

            if (compare(arr[left], t) === 0) swap(arr, left, j);
            else {
                j++;
                swap(arr, j, right);
            }

            if (j <= k) left = j + 1;
            if (k <= j) right = j - 1;
        }
    }

    function swap(arr, i, j) {
        var tmp = arr[i];
        arr[i] = arr[j];
        arr[j] = tmp;
    }

    function defaultCompare(a, b) {
        return a < b ? -1 : a > b ? 1 : 0;
    }

    return quickselect;

    })));
    });

    var quickselect$1 = /*#__PURE__*/Object.freeze({
        default: quickselect,
        __moduleExports: quickselect
    });

    var quickselect$2 = ( quickselect$1 && quickselect ) || quickselect$1;

    var rbush_1 = rbush;
    var default_1 = rbush;



    function rbush(maxEntries, format) {
        if (!(this instanceof rbush)) return new rbush(maxEntries, format);

        // max entries in a node is 9 by default; min node fill is 40% for best performance
        this._maxEntries = Math.max(4, maxEntries || 9);
        this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));

        if (format) {
            this._initFormat(format);
        }

        this.clear();
    }

    rbush.prototype = {

        all: function () {
            return this._all(this.data, []);
        },

        search: function (bbox) {

            var node = this.data,
                result = [],
                toBBox = this.toBBox;

            if (!intersects(bbox, node)) return result;

            var nodesToSearch = [],
                i, len, child, childBBox;

            while (node) {
                for (i = 0, len = node.children.length; i < len; i++) {

                    child = node.children[i];
                    childBBox = node.leaf ? toBBox(child) : child;

                    if (intersects(bbox, childBBox)) {
                        if (node.leaf) result.push(child);
                        else if (contains(bbox, childBBox)) this._all(child, result);
                        else nodesToSearch.push(child);
                    }
                }
                node = nodesToSearch.pop();
            }

            return result;
        },

        collides: function (bbox) {

            var node = this.data,
                toBBox = this.toBBox;

            if (!intersects(bbox, node)) return false;

            var nodesToSearch = [],
                i, len, child, childBBox;

            while (node) {
                for (i = 0, len = node.children.length; i < len; i++) {

                    child = node.children[i];
                    childBBox = node.leaf ? toBBox(child) : child;

                    if (intersects(bbox, childBBox)) {
                        if (node.leaf || contains(bbox, childBBox)) return true;
                        nodesToSearch.push(child);
                    }
                }
                node = nodesToSearch.pop();
            }

            return false;
        },

        load: function (data) {
            if (!(data && data.length)) return this;

            if (data.length < this._minEntries) {
                for (var i = 0, len = data.length; i < len; i++) {
                    this.insert(data[i]);
                }
                return this;
            }

            // recursively build the tree with the given data from scratch using OMT algorithm
            var node = this._build(data.slice(), 0, data.length - 1, 0);

            if (!this.data.children.length) {
                // save as is if tree is empty
                this.data = node;

            } else if (this.data.height === node.height) {
                // split root if trees have the same height
                this._splitRoot(this.data, node);

            } else {
                if (this.data.height < node.height) {
                    // swap trees if inserted one is bigger
                    var tmpNode = this.data;
                    this.data = node;
                    node = tmpNode;
                }

                // insert the small tree into the large tree at appropriate level
                this._insert(node, this.data.height - node.height - 1, true);
            }

            return this;
        },

        insert: function (item) {
            if (item) this._insert(item, this.data.height - 1);
            return this;
        },

        clear: function () {
            this.data = createNode([]);
            return this;
        },

        remove: function (item, equalsFn) {
            if (!item) return this;

            var node = this.data,
                bbox = this.toBBox(item),
                path = [],
                indexes = [],
                i, parent, index, goingUp;

            // depth-first iterative tree traversal
            while (node || path.length) {

                if (!node) { // go up
                    node = path.pop();
                    parent = path[path.length - 1];
                    i = indexes.pop();
                    goingUp = true;
                }

                if (node.leaf) { // check current node
                    index = findItem(item, node.children, equalsFn);

                    if (index !== -1) {
                        // item found, remove the item and condense tree upwards
                        node.children.splice(index, 1);
                        path.push(node);
                        this._condense(path);
                        return this;
                    }
                }

                if (!goingUp && !node.leaf && contains(node, bbox)) { // go down
                    path.push(node);
                    indexes.push(i);
                    i = 0;
                    parent = node;
                    node = node.children[0];

                } else if (parent) { // go right
                    i++;
                    node = parent.children[i];
                    goingUp = false;

                } else node = null; // nothing found
            }

            return this;
        },

        toBBox: function (item) { return item; },

        compareMinX: compareNodeMinX,
        compareMinY: compareNodeMinY,

        toJSON: function () { return this.data; },

        fromJSON: function (data) {
            this.data = data;
            return this;
        },

        _all: function (node, result) {
            var nodesToSearch = [];
            while (node) {
                if (node.leaf) result.push.apply(result, node.children);
                else nodesToSearch.push.apply(nodesToSearch, node.children);

                node = nodesToSearch.pop();
            }
            return result;
        },

        _build: function (items, left, right, height) {

            var N = right - left + 1,
                M = this._maxEntries,
                node;

            if (N <= M) {
                // reached leaf level; return leaf
                node = createNode(items.slice(left, right + 1));
                calcBBox(node, this.toBBox);
                return node;
            }

            if (!height) {
                // target height of the bulk-loaded tree
                height = Math.ceil(Math.log(N) / Math.log(M));

                // target number of root entries to maximize storage utilization
                M = Math.ceil(N / Math.pow(M, height - 1));
            }

            node = createNode([]);
            node.leaf = false;
            node.height = height;

            // split the items into M mostly square tiles

            var N2 = Math.ceil(N / M),
                N1 = N2 * Math.ceil(Math.sqrt(M)),
                i, j, right2, right3;

            multiSelect(items, left, right, N1, this.compareMinX);

            for (i = left; i <= right; i += N1) {

                right2 = Math.min(i + N1 - 1, right);

                multiSelect(items, i, right2, N2, this.compareMinY);

                for (j = i; j <= right2; j += N2) {

                    right3 = Math.min(j + N2 - 1, right2);

                    // pack each entry recursively
                    node.children.push(this._build(items, j, right3, height - 1));
                }
            }

            calcBBox(node, this.toBBox);

            return node;
        },

        _chooseSubtree: function (bbox, node, level, path) {

            var i, len, child, targetNode, area, enlargement, minArea, minEnlargement;

            while (true) {
                path.push(node);

                if (node.leaf || path.length - 1 === level) break;

                minArea = minEnlargement = Infinity;

                for (i = 0, len = node.children.length; i < len; i++) {
                    child = node.children[i];
                    area = bboxArea(child);
                    enlargement = enlargedArea(bbox, child) - area;

                    // choose entry with the least area enlargement
                    if (enlargement < minEnlargement) {
                        minEnlargement = enlargement;
                        minArea = area < minArea ? area : minArea;
                        targetNode = child;

                    } else if (enlargement === minEnlargement) {
                        // otherwise choose one with the smallest area
                        if (area < minArea) {
                            minArea = area;
                            targetNode = child;
                        }
                    }
                }

                node = targetNode || node.children[0];
            }

            return node;
        },

        _insert: function (item, level, isNode) {

            var toBBox = this.toBBox,
                bbox = isNode ? item : toBBox(item),
                insertPath = [];

            // find the best node for accommodating the item, saving all nodes along the path too
            var node = this._chooseSubtree(bbox, this.data, level, insertPath);

            // put the item into the node
            node.children.push(item);
            extend(node, bbox);

            // split on node overflow; propagate upwards if necessary
            while (level >= 0) {
                if (insertPath[level].children.length > this._maxEntries) {
                    this._split(insertPath, level);
                    level--;
                } else break;
            }

            // adjust bboxes along the insertion path
            this._adjustParentBBoxes(bbox, insertPath, level);
        },

        // split overflowed node into two
        _split: function (insertPath, level) {

            var node = insertPath[level],
                M = node.children.length,
                m = this._minEntries;

            this._chooseSplitAxis(node, m, M);

            var splitIndex = this._chooseSplitIndex(node, m, M);

            var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
            newNode.height = node.height;
            newNode.leaf = node.leaf;

            calcBBox(node, this.toBBox);
            calcBBox(newNode, this.toBBox);

            if (level) insertPath[level - 1].children.push(newNode);
            else this._splitRoot(node, newNode);
        },

        _splitRoot: function (node, newNode) {
            // split root node
            this.data = createNode([node, newNode]);
            this.data.height = node.height + 1;
            this.data.leaf = false;
            calcBBox(this.data, this.toBBox);
        },

        _chooseSplitIndex: function (node, m, M) {

            var i, bbox1, bbox2, overlap, area, minOverlap, minArea, index;

            minOverlap = minArea = Infinity;

            for (i = m; i <= M - m; i++) {
                bbox1 = distBBox(node, 0, i, this.toBBox);
                bbox2 = distBBox(node, i, M, this.toBBox);

                overlap = intersectionArea(bbox1, bbox2);
                area = bboxArea(bbox1) + bboxArea(bbox2);

                // choose distribution with minimum overlap
                if (overlap < minOverlap) {
                    minOverlap = overlap;
                    index = i;

                    minArea = area < minArea ? area : minArea;

                } else if (overlap === minOverlap) {
                    // otherwise choose distribution with minimum area
                    if (area < minArea) {
                        minArea = area;
                        index = i;
                    }
                }
            }

            return index;
        },

        // sorts node children by the best axis for split
        _chooseSplitAxis: function (node, m, M) {

            var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX,
                compareMinY = node.leaf ? this.compareMinY : compareNodeMinY,
                xMargin = this._allDistMargin(node, m, M, compareMinX),
                yMargin = this._allDistMargin(node, m, M, compareMinY);

            // if total distributions margin value is minimal for x, sort by minX,
            // otherwise it's already sorted by minY
            if (xMargin < yMargin) node.children.sort(compareMinX);
        },

        // total margin of all possible split distributions where each node is at least m full
        _allDistMargin: function (node, m, M, compare) {

            node.children.sort(compare);

            var toBBox = this.toBBox,
                leftBBox = distBBox(node, 0, m, toBBox),
                rightBBox = distBBox(node, M - m, M, toBBox),
                margin = bboxMargin(leftBBox) + bboxMargin(rightBBox),
                i, child;

            for (i = m; i < M - m; i++) {
                child = node.children[i];
                extend(leftBBox, node.leaf ? toBBox(child) : child);
                margin += bboxMargin(leftBBox);
            }

            for (i = M - m - 1; i >= m; i--) {
                child = node.children[i];
                extend(rightBBox, node.leaf ? toBBox(child) : child);
                margin += bboxMargin(rightBBox);
            }

            return margin;
        },

        _adjustParentBBoxes: function (bbox, path, level) {
            // adjust bboxes along the given tree path
            for (var i = level; i >= 0; i--) {
                extend(path[i], bbox);
            }
        },

        _condense: function (path) {
            // go through the path, removing empty nodes and updating bboxes
            for (var i = path.length - 1, siblings; i >= 0; i--) {
                if (path[i].children.length === 0) {
                    if (i > 0) {
                        siblings = path[i - 1].children;
                        siblings.splice(siblings.indexOf(path[i]), 1);

                    } else this.clear();

                } else calcBBox(path[i], this.toBBox);
            }
        },

        _initFormat: function (format) {
            // data format (minX, minY, maxX, maxY accessors)

            // uses eval-type function compilation instead of just accepting a toBBox function
            // because the algorithms are very sensitive to sorting functions performance,
            // so they should be dead simple and without inner calls

            var compareArr = ['return a', ' - b', ';'];

            this.compareMinX = new Function('a', 'b', compareArr.join(format[0]));
            this.compareMinY = new Function('a', 'b', compareArr.join(format[1]));

            this.toBBox = new Function('a',
                'return {minX: a' + format[0] +
                ', minY: a' + format[1] +
                ', maxX: a' + format[2] +
                ', maxY: a' + format[3] + '};');
        }
    };

    function findItem(item, items, equalsFn) {
        if (!equalsFn) return items.indexOf(item);

        for (var i = 0; i < items.length; i++) {
            if (equalsFn(item, items[i])) return i;
        }
        return -1;
    }

    // calculate node's bbox from bboxes of its children
    function calcBBox(node, toBBox) {
        distBBox(node, 0, node.children.length, toBBox, node);
    }

    // min bounding rectangle of node children from k to p-1
    function distBBox(node, k, p, toBBox, destNode) {
        if (!destNode) destNode = createNode(null);
        destNode.minX = Infinity;
        destNode.minY = Infinity;
        destNode.maxX = -Infinity;
        destNode.maxY = -Infinity;

        for (var i = k, child; i < p; i++) {
            child = node.children[i];
            extend(destNode, node.leaf ? toBBox(child) : child);
        }

        return destNode;
    }

    function extend(a, b) {
        a.minX = Math.min(a.minX, b.minX);
        a.minY = Math.min(a.minY, b.minY);
        a.maxX = Math.max(a.maxX, b.maxX);
        a.maxY = Math.max(a.maxY, b.maxY);
        return a;
    }

    function compareNodeMinX(a, b) { return a.minX - b.minX; }
    function compareNodeMinY(a, b) { return a.minY - b.minY; }

    function bboxArea(a)   { return (a.maxX - a.minX) * (a.maxY - a.minY); }
    function bboxMargin(a) { return (a.maxX - a.minX) + (a.maxY - a.minY); }

    function enlargedArea(a, b) {
        return (Math.max(b.maxX, a.maxX) - Math.min(b.minX, a.minX)) *
               (Math.max(b.maxY, a.maxY) - Math.min(b.minY, a.minY));
    }

    function intersectionArea(a, b) {
        var minX = Math.max(a.minX, b.minX),
            minY = Math.max(a.minY, b.minY),
            maxX = Math.min(a.maxX, b.maxX),
            maxY = Math.min(a.maxY, b.maxY);

        return Math.max(0, maxX - minX) *
               Math.max(0, maxY - minY);
    }

    function contains(a, b) {
        return a.minX <= b.minX &&
               a.minY <= b.minY &&
               b.maxX <= a.maxX &&
               b.maxY <= a.maxY;
    }

    function intersects(a, b) {
        return b.minX <= a.maxX &&
               b.minY <= a.maxY &&
               b.maxX >= a.minX &&
               b.maxY >= a.minY;
    }

    function createNode(children) {
        return {
            children: children,
            height: 1,
            leaf: true,
            minX: Infinity,
            minY: Infinity,
            maxX: -Infinity,
            maxY: -Infinity
        };
    }

    // sort an array so that items come in groups of n unsorted items, with groups sorted between each other;
    // combines selection algorithm with binary divide & conquer approach

    function multiSelect(arr, left, right, n, compare) {
        var stack = [left, right],
            mid;

        while (stack.length) {
            right = stack.pop();
            left = stack.pop();

            if (right - left <= n) continue;

            mid = left + Math.ceil((right - left) / n / 2) * n;
            quickselect$2(arr, mid, left, right, compare);

            stack.push(left, mid, mid, right);
        }
    }
    rbush_1.default = default_1;

    var twoProduct_1 = twoProduct;

    var SPLITTER = +(Math.pow(2, 27) + 1.0);

    function twoProduct(a, b, result) {
      var x = a * b;

      var c = SPLITTER * a;
      var abig = c - a;
      var ahi = c - abig;
      var alo = a - ahi;

      var d = SPLITTER * b;
      var bbig = d - b;
      var bhi = d - bbig;
      var blo = b - bhi;

      var err1 = x - (ahi * bhi);
      var err2 = err1 - (alo * bhi);
      var err3 = err2 - (ahi * blo);

      var y = alo * blo - err3;

      if(result) {
        result[0] = y;
        result[1] = x;
        return result
      }

      return [ y, x ]
    }

    var twoProduct$1 = /*#__PURE__*/Object.freeze({
        default: twoProduct_1,
        __moduleExports: twoProduct_1
    });

    var robustSum = linearExpansionSum;

    //Easy case: Add two scalars
    function scalarScalar(a, b) {
      var x = a + b;
      var bv = x - a;
      var av = x - bv;
      var br = b - bv;
      var ar = a - av;
      var y = ar + br;
      if(y) {
        return [y, x]
      }
      return [x]
    }

    function linearExpansionSum(e, f) {
      var ne = e.length|0;
      var nf = f.length|0;
      if(ne === 1 && nf === 1) {
        return scalarScalar(e[0], f[0])
      }
      var n = ne + nf;
      var g = new Array(n);
      var count = 0;
      var eptr = 0;
      var fptr = 0;
      var abs = Math.abs;
      var ei = e[eptr];
      var ea = abs(ei);
      var fi = f[fptr];
      var fa = abs(fi);
      var a, b;
      if(ea < fa) {
        b = ei;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
          ea = abs(ei);
        }
      } else {
        b = fi;
        fptr += 1;
        if(fptr < nf) {
          fi = f[fptr];
          fa = abs(fi);
        }
      }
      if((eptr < ne && ea < fa) || (fptr >= nf)) {
        a = ei;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
          ea = abs(ei);
        }
      } else {
        a = fi;
        fptr += 1;
        if(fptr < nf) {
          fi = f[fptr];
          fa = abs(fi);
        }
      }
      var x = a + b;
      var bv = x - a;
      var y = b - bv;
      var q0 = y;
      var q1 = x;
      var _x, _bv, _av, _br, _ar;
      while(eptr < ne && fptr < nf) {
        if(ea < fa) {
          a = ei;
          eptr += 1;
          if(eptr < ne) {
            ei = e[eptr];
            ea = abs(ei);
          }
        } else {
          a = fi;
          fptr += 1;
          if(fptr < nf) {
            fi = f[fptr];
            fa = abs(fi);
          }
        }
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        }
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
      }
      while(eptr < ne) {
        a = ei;
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        }
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
        }
      }
      while(fptr < nf) {
        a = fi;
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        } 
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
        fptr += 1;
        if(fptr < nf) {
          fi = f[fptr];
        }
      }
      if(q0) {
        g[count++] = q0;
      }
      if(q1) {
        g[count++] = q1;
      }
      if(!count) {
        g[count++] = 0.0;  
      }
      g.length = count;
      return g
    }

    var robustSum$1 = /*#__PURE__*/Object.freeze({
        default: robustSum,
        __moduleExports: robustSum
    });

    var twoSum = fastTwoSum;

    function fastTwoSum(a, b, result) {
    	var x = a + b;
    	var bv = x - a;
    	var av = x - bv;
    	var br = b - bv;
    	var ar = a - av;
    	if(result) {
    		result[0] = ar + br;
    		result[1] = x;
    		return result
    	}
    	return [ar+br, x]
    }

    var twoSum$1 = /*#__PURE__*/Object.freeze({
        default: twoSum,
        __moduleExports: twoSum
    });

    var twoProduct$2 = ( twoProduct$1 && twoProduct_1 ) || twoProduct$1;

    var twoSum$2 = ( twoSum$1 && twoSum ) || twoSum$1;

    var robustScale = scaleLinearExpansion;

    function scaleLinearExpansion(e, scale) {
      var n = e.length;
      if(n === 1) {
        var ts = twoProduct$2(e[0], scale);
        if(ts[0]) {
          return ts
        }
        return [ ts[1] ]
      }
      var g = new Array(2 * n);
      var q = [0.1, 0.1];
      var t = [0.1, 0.1];
      var count = 0;
      twoProduct$2(e[0], scale, q);
      if(q[0]) {
        g[count++] = q[0];
      }
      for(var i=1; i<n; ++i) {
        twoProduct$2(e[i], scale, t);
        var pq = q[1];
        twoSum$2(pq, t[0], q);
        if(q[0]) {
          g[count++] = q[0];
        }
        var a = t[1];
        var b = q[1];
        var x = a + b;
        var bv = x - a;
        var y = b - bv;
        q[1] = x;
        if(y) {
          g[count++] = y;
        }
      }
      if(q[1]) {
        g[count++] = q[1];
      }
      if(count === 0) {
        g[count++] = 0.0;
      }
      g.length = count;
      return g
    }

    var robustScale$1 = /*#__PURE__*/Object.freeze({
        default: robustScale,
        __moduleExports: robustScale
    });

    var robustDiff = robustSubtract;

    //Easy case: Add two scalars
    function scalarScalar$1(a, b) {
      var x = a + b;
      var bv = x - a;
      var av = x - bv;
      var br = b - bv;
      var ar = a - av;
      var y = ar + br;
      if(y) {
        return [y, x]
      }
      return [x]
    }

    function robustSubtract(e, f) {
      var ne = e.length|0;
      var nf = f.length|0;
      if(ne === 1 && nf === 1) {
        return scalarScalar$1(e[0], -f[0])
      }
      var n = ne + nf;
      var g = new Array(n);
      var count = 0;
      var eptr = 0;
      var fptr = 0;
      var abs = Math.abs;
      var ei = e[eptr];
      var ea = abs(ei);
      var fi = -f[fptr];
      var fa = abs(fi);
      var a, b;
      if(ea < fa) {
        b = ei;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
          ea = abs(ei);
        }
      } else {
        b = fi;
        fptr += 1;
        if(fptr < nf) {
          fi = -f[fptr];
          fa = abs(fi);
        }
      }
      if((eptr < ne && ea < fa) || (fptr >= nf)) {
        a = ei;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
          ea = abs(ei);
        }
      } else {
        a = fi;
        fptr += 1;
        if(fptr < nf) {
          fi = -f[fptr];
          fa = abs(fi);
        }
      }
      var x = a + b;
      var bv = x - a;
      var y = b - bv;
      var q0 = y;
      var q1 = x;
      var _x, _bv, _av, _br, _ar;
      while(eptr < ne && fptr < nf) {
        if(ea < fa) {
          a = ei;
          eptr += 1;
          if(eptr < ne) {
            ei = e[eptr];
            ea = abs(ei);
          }
        } else {
          a = fi;
          fptr += 1;
          if(fptr < nf) {
            fi = -f[fptr];
            fa = abs(fi);
          }
        }
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        }
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
      }
      while(eptr < ne) {
        a = ei;
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        }
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
        eptr += 1;
        if(eptr < ne) {
          ei = e[eptr];
        }
      }
      while(fptr < nf) {
        a = fi;
        b = q0;
        x = a + b;
        bv = x - a;
        y = b - bv;
        if(y) {
          g[count++] = y;
        } 
        _x = q1 + x;
        _bv = _x - q1;
        _av = _x - _bv;
        _br = x - _bv;
        _ar = q1 - _av;
        q0 = _ar + _br;
        q1 = _x;
        fptr += 1;
        if(fptr < nf) {
          fi = -f[fptr];
        }
      }
      if(q0) {
        g[count++] = q0;
      }
      if(q1) {
        g[count++] = q1;
      }
      if(!count) {
        g[count++] = 0.0;  
      }
      g.length = count;
      return g
    }

    var robustDiff$1 = /*#__PURE__*/Object.freeze({
        default: robustDiff,
        __moduleExports: robustDiff
    });

    var robustSum$2 = ( robustSum$1 && robustSum ) || robustSum$1;

    var robustScale$2 = ( robustScale$1 && robustScale ) || robustScale$1;

    var robustSubtract$1 = ( robustDiff$1 && robustDiff ) || robustDiff$1;

    var orientation_1 = createCommonjsModule(function (module) {






    var NUM_EXPAND = 5;

    var EPSILON     = 1.1102230246251565e-16;
    var ERRBOUND3   = (3.0 + 16.0 * EPSILON) * EPSILON;
    var ERRBOUND4   = (7.0 + 56.0 * EPSILON) * EPSILON;

    function cofactor(m, c) {
      var result = new Array(m.length-1);
      for(var i=1; i<m.length; ++i) {
        var r = result[i-1] = new Array(m.length-1);
        for(var j=0,k=0; j<m.length; ++j) {
          if(j === c) {
            continue
          }
          r[k++] = m[i][j];
        }
      }
      return result
    }

    function matrix(n) {
      var result = new Array(n);
      for(var i=0; i<n; ++i) {
        result[i] = new Array(n);
        for(var j=0; j<n; ++j) {
          result[i][j] = ["m", j, "[", (n-i-1), "]"].join("");
        }
      }
      return result
    }

    function sign(n) {
      if(n & 1) {
        return "-"
      }
      return ""
    }

    function generateSum(expr) {
      if(expr.length === 1) {
        return expr[0]
      } else if(expr.length === 2) {
        return ["sum(", expr[0], ",", expr[1], ")"].join("")
      } else {
        var m = expr.length>>1;
        return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("")
      }
    }

    function determinant(m) {
      if(m.length === 2) {
        return [["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("")]
      } else {
        var expr = [];
        for(var i=0; i<m.length; ++i) {
          expr.push(["scale(", generateSum(determinant(cofactor(m, i))), ",", sign(i), m[0][i], ")"].join(""));
        }
        return expr
      }
    }

    function orientation(n) {
      var pos = [];
      var neg = [];
      var m = matrix(n);
      var args = [];
      for(var i=0; i<n; ++i) {
        if((i&1)===0) {
          pos.push.apply(pos, determinant(cofactor(m, i)));
        } else {
          neg.push.apply(neg, determinant(cofactor(m, i)));
        }
        args.push("m" + i);
      }
      var posExpr = generateSum(pos);
      var negExpr = generateSum(neg);
      var funcName = "orientation" + n + "Exact";
      var code = ["function ", funcName, "(", args.join(), "){var p=", posExpr, ",n=", negExpr, ",d=sub(p,n);\
return d[d.length-1];};return ", funcName].join("");
      var proc = new Function("sum", "prod", "scale", "sub", code);
      return proc(robustSum$2, twoProduct$2, robustScale$2, robustSubtract$1)
    }

    var orientation3Exact = orientation(3);
    var orientation4Exact = orientation(4);

    var CACHED = [
      function orientation0() { return 0 },
      function orientation1() { return 0 },
      function orientation2(a, b) { 
        return b[0] - a[0]
      },
      function orientation3(a, b, c) {
        var l = (a[1] - c[1]) * (b[0] - c[0]);
        var r = (a[0] - c[0]) * (b[1] - c[1]);
        var det = l - r;
        var s;
        if(l > 0) {
          if(r <= 0) {
            return det
          } else {
            s = l + r;
          }
        } else if(l < 0) {
          if(r >= 0) {
            return det
          } else {
            s = -(l + r);
          }
        } else {
          return det
        }
        var tol = ERRBOUND3 * s;
        if(det >= tol || det <= -tol) {
          return det
        }
        return orientation3Exact(a, b, c)
      },
      function orientation4(a,b,c,d) {
        var adx = a[0] - d[0];
        var bdx = b[0] - d[0];
        var cdx = c[0] - d[0];
        var ady = a[1] - d[1];
        var bdy = b[1] - d[1];
        var cdy = c[1] - d[1];
        var adz = a[2] - d[2];
        var bdz = b[2] - d[2];
        var cdz = c[2] - d[2];
        var bdxcdy = bdx * cdy;
        var cdxbdy = cdx * bdy;
        var cdxady = cdx * ady;
        var adxcdy = adx * cdy;
        var adxbdy = adx * bdy;
        var bdxady = bdx * ady;
        var det = adz * (bdxcdy - cdxbdy) 
                + bdz * (cdxady - adxcdy)
                + cdz * (adxbdy - bdxady);
        var permanent = (Math.abs(bdxcdy) + Math.abs(cdxbdy)) * Math.abs(adz)
                      + (Math.abs(cdxady) + Math.abs(adxcdy)) * Math.abs(bdz)
                      + (Math.abs(adxbdy) + Math.abs(bdxady)) * Math.abs(cdz);
        var tol = ERRBOUND4 * permanent;
        if ((det > tol) || (-det > tol)) {
          return det
        }
        return orientation4Exact(a,b,c,d)
      }
    ];

    function slowOrient(args) {
      var proc = CACHED[args.length];
      if(!proc) {
        proc = CACHED[args.length] = orientation(args.length);
      }
      return proc.apply(undefined, args)
    }

    function generateOrientationProc() {
      while(CACHED.length <= NUM_EXPAND) {
        CACHED.push(orientation(CACHED.length));
      }
      var args = [];
      var procArgs = ["slow"];
      for(var i=0; i<=NUM_EXPAND; ++i) {
        args.push("a" + i);
        procArgs.push("o" + i);
      }
      var code = [
        "function getOrientation(", args.join(), "){switch(arguments.length){case 0:case 1:return 0;"
      ];
      for(var i=2; i<=NUM_EXPAND; ++i) {
        code.push("case ", i, ":return o", i, "(", args.slice(0, i).join(), ");");
      }
      code.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation");
      procArgs.push(code.join(""));

      var proc = Function.apply(undefined, procArgs);
      module.exports = proc.apply(undefined, [slowOrient].concat(CACHED));
      for(var i=0; i<=NUM_EXPAND; ++i) {
        module.exports[i] = CACHED[i];
      }
    }

    generateOrientationProc();
    });

    var orientation = /*#__PURE__*/Object.freeze({
        default: orientation_1,
        __moduleExports: orientation_1
    });

    var require$$0 = ( orientation && orientation_1 ) || orientation;

    var monotoneConvexHull2d = monotoneConvexHull2D;

    var orient = require$$0[3];

    function monotoneConvexHull2D(points) {
      var n = points.length;

      if(n < 3) {
        var result = new Array(n);
        for(var i=0; i<n; ++i) {
          result[i] = i;
        }

        if(n === 2 &&
           points[0][0] === points[1][0] &&
           points[0][1] === points[1][1]) {
          return [0]
        }

        return result
      }

      //Sort point indices along x-axis
      var sorted = new Array(n);
      for(var i=0; i<n; ++i) {
        sorted[i] = i;
      }
      sorted.sort(function(a,b) {
        var d = points[a][0]-points[b][0];
        if(d) {
          return d
        }
        return points[a][1] - points[b][1]
      });

      //Construct upper and lower hulls
      var lower = [sorted[0], sorted[1]];
      var upper = [sorted[0], sorted[1]];

      for(var i=2; i<n; ++i) {
        var idx = sorted[i];
        var p   = points[idx];

        //Insert into lower list
        var m = lower.length;
        while(m > 1 && orient(
            points[lower[m-2]], 
            points[lower[m-1]], 
            p) <= 0) {
          m -= 1;
          lower.pop();
        }
        lower.push(idx);

        //Insert into upper list
        m = upper.length;
        while(m > 1 && orient(
            points[upper[m-2]], 
            points[upper[m-1]], 
            p) >= 0) {
          m -= 1;
          upper.pop();
        }
        upper.push(idx);
      }

      //Merge lists together
      var result = new Array(upper.length + lower.length - 2);
      var ptr    = 0;
      for(var i=0, nl=lower.length; i<nl; ++i) {
        result[ptr++] = lower[i];
      }
      for(var j=upper.length-2; j>0; --j) {
        result[ptr++] = upper[j];
      }

      //Return result
      return result
    }

    var monotoneConvexHull2d$1 = /*#__PURE__*/Object.freeze({
        default: monotoneConvexHull2d,
        __moduleExports: monotoneConvexHull2d
    });

    var tinyqueue = TinyQueue;
    var default_1$1 = TinyQueue;

    function TinyQueue(data, compare) {
        if (!(this instanceof TinyQueue)) return new TinyQueue(data, compare);

        this.data = data || [];
        this.length = this.data.length;
        this.compare = compare || defaultCompare;

        if (this.length > 0) {
            for (var i = (this.length >> 1) - 1; i >= 0; i--) this._down(i);
        }
    }

    function defaultCompare(a, b) {
        return a < b ? -1 : a > b ? 1 : 0;
    }

    TinyQueue.prototype = {

        push: function (item) {
            this.data.push(item);
            this.length++;
            this._up(this.length - 1);
        },

        pop: function () {
            if (this.length === 0) return undefined;

            var top = this.data[0];
            this.length--;

            if (this.length > 0) {
                this.data[0] = this.data[this.length];
                this._down(0);
            }
            this.data.pop();

            return top;
        },

        peek: function () {
            return this.data[0];
        },

        _up: function (pos) {
            var data = this.data;
            var compare = this.compare;
            var item = data[pos];

            while (pos > 0) {
                var parent = (pos - 1) >> 1;
                var current = data[parent];
                if (compare(item, current) >= 0) break;
                data[pos] = current;
                pos = parent;
            }

            data[pos] = item;
        },

        _down: function (pos) {
            var data = this.data;
            var compare = this.compare;
            var halfLength = this.length >> 1;
            var item = data[pos];

            while (pos < halfLength) {
                var left = (pos << 1) + 1;
                var right = left + 1;
                var best = data[left];

                if (right < this.length && compare(data[right], best) < 0) {
                    left = right;
                    best = data[right];
                }
                if (compare(best, item) >= 0) break;

                data[pos] = best;
                pos = left;
            }

            data[pos] = item;
        }
    };
    tinyqueue.default = default_1$1;

    var tinyqueue$1 = /*#__PURE__*/Object.freeze({
        default: tinyqueue,
        __moduleExports: tinyqueue
    });

    var pointInPolygon = function (point, vs) {
        // ray-casting algorithm based on
        // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
        
        var x = point[0], y = point[1];
        
        var inside = false;
        for (var i = 0, j = vs.length - 1; i < vs.length; j = i++) {
            var xi = vs[i][0], yi = vs[i][1];
            var xj = vs[j][0], yj = vs[j][1];
            
            var intersect = ((yi > y) != (yj > y))
                && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
            if (intersect) inside = !inside;
        }
        
        return inside;
    };

    var pointInPolygon$1 = /*#__PURE__*/Object.freeze({
        default: pointInPolygon,
        __moduleExports: pointInPolygon
    });

    var convexHull = ( monotoneConvexHull2d$1 && monotoneConvexHull2d ) || monotoneConvexHull2d$1;

    var Queue = ( tinyqueue$1 && tinyqueue ) || tinyqueue$1;

    var pointInPolygon$2 = ( pointInPolygon$1 && pointInPolygon ) || pointInPolygon$1;

    var orient$1 = require$$0[3];

    var concaveman_1 = concaveman;
    var default_1$2 = concaveman;

    function concaveman(points, concavity, lengthThreshold) {
        // a relative measure of concavity; higher value means simpler hull
        concavity = Math.max(0, concavity === undefined ? 2 : concavity);

        // when a segment goes below this length threshold, it won't be drilled down further
        lengthThreshold = lengthThreshold || 0;

        // start with a convex hull of the points
        var hull = fastConvexHull(points);

        // index the points with an R-tree
        var tree = rbush_1(16, ['[0]', '[1]', '[0]', '[1]']).load(points);

        // turn the convex hull into a linked list and populate the initial edge queue with the nodes
        var queue = [];
        for (var i = 0, last; i < hull.length; i++) {
            var p = hull[i];
            tree.remove(p);
            last = insertNode(p, last);
            queue.push(last);
        }

        // index the segments with an R-tree (for intersection checks)
        var segTree = rbush_1(16);
        for (i = 0; i < queue.length; i++) segTree.insert(updateBBox(queue[i]));

        var sqConcavity = concavity * concavity;
        var sqLenThreshold = lengthThreshold * lengthThreshold;

        // process edges one by one
        while (queue.length) {
            var node = queue.shift();
            var a = node.p;
            var b = node.next.p;

            // skip the edge if it's already short enough
            var sqLen = getSqDist(a, b);
            if (sqLen < sqLenThreshold) continue;

            var maxSqLen = sqLen / sqConcavity;

            // find the best connection point for the current edge to flex inward to
            p = findCandidate(tree, node.prev.p, a, b, node.next.next.p, maxSqLen, segTree);

            // if we found a connection and it satisfies our concavity measure
            if (p && Math.min(getSqDist(p, a), getSqDist(p, b)) <= maxSqLen) {
                // connect the edge endpoints through this point and add 2 new edges to the queue
                queue.push(node);
                queue.push(insertNode(p, node));

                // update point and segment indexes
                tree.remove(p);
                segTree.remove(node);
                segTree.insert(updateBBox(node));
                segTree.insert(updateBBox(node.next));
            }
        }

        // convert the resulting hull linked list to an array of points
        node = last;
        var concave = [];
        do {
            concave.push(node.p);
            node = node.next;
        } while (node !== last);

        concave.push(node.p);

        return concave;
    }

    function findCandidate(tree, a, b, c, d, maxDist, segTree) {
        var queue = new Queue(null, compareDist);
        var node = tree.data;

        // search through the point R-tree with a depth-first search using a priority queue
        // in the order of distance to the edge (b, c)
        while (node) {
            for (var i = 0; i < node.children.length; i++) {
                var child = node.children[i];

                var dist = node.leaf ? sqSegDist(child, b, c) : sqSegBoxDist(b, c, child);
                if (dist > maxDist) continue; // skip the node if it's farther than we ever need

                queue.push({
                    node: child,
                    dist: dist
                });
            }

            while (queue.length && !queue.peek().node.children) {
                var item = queue.pop();
                var p = item.node;

                // skip all points that are as close to adjacent edges (a,b) and (c,d),
                // and points that would introduce self-intersections when connected
                var d0 = sqSegDist(p, a, b);
                var d1 = sqSegDist(p, c, d);
                if (item.dist < d0 && item.dist < d1 &&
                    noIntersections(b, p, segTree) &&
                    noIntersections(c, p, segTree)) return p;
            }

            node = queue.pop();
            if (node) node = node.node;
        }

        return null;
    }

    function compareDist(a, b) {
        return a.dist - b.dist;
    }

    // square distance from a segment bounding box to the given one
    function sqSegBoxDist(a, b, bbox) {
        if (inside(a, bbox) || inside(b, bbox)) return 0;
        var d1 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.minY, bbox.maxX, bbox.minY);
        if (d1 === 0) return 0;
        var d2 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.minY, bbox.minX, bbox.maxY);
        if (d2 === 0) return 0;
        var d3 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.maxX, bbox.minY, bbox.maxX, bbox.maxY);
        if (d3 === 0) return 0;
        var d4 = sqSegSegDist(a[0], a[1], b[0], b[1], bbox.minX, bbox.maxY, bbox.maxX, bbox.maxY);
        if (d4 === 0) return 0;
        return Math.min(d1, d2, d3, d4);
    }

    function inside(a, bbox) {
        return a[0] >= bbox.minX &&
               a[0] <= bbox.maxX &&
               a[1] >= bbox.minY &&
               a[1] <= bbox.maxY;
    }

    // check if the edge (a,b) doesn't intersect any other edges
    function noIntersections(a, b, segTree) {
        var minX = Math.min(a[0], b[0]);
        var minY = Math.min(a[1], b[1]);
        var maxX = Math.max(a[0], b[0]);
        var maxY = Math.max(a[1], b[1]);

        var edges = segTree.search({minX: minX, minY: minY, maxX: maxX, maxY: maxY});
        for (var i = 0; i < edges.length; i++) {
            if (intersects$1(edges[i].p, edges[i].next.p, a, b)) return false;
        }
        return true;
    }

    // check if the edges (p1,q1) and (p2,q2) intersect
    function intersects$1(p1, q1, p2, q2) {
        return p1 !== q2 && q1 !== p2 &&
            orient$1(p1, q1, p2) > 0 !== orient$1(p1, q1, q2) > 0 &&
            orient$1(p2, q2, p1) > 0 !== orient$1(p2, q2, q1) > 0;
    }

    // update the bounding box of a node's edge
    function updateBBox(node) {
        var p1 = node.p;
        var p2 = node.next.p;
        node.minX = Math.min(p1[0], p2[0]);
        node.minY = Math.min(p1[1], p2[1]);
        node.maxX = Math.max(p1[0], p2[0]);
        node.maxY = Math.max(p1[1], p2[1]);
        return node;
    }

    // speed up convex hull by filtering out points inside quadrilateral formed by 4 extreme points
    function fastConvexHull(points) {
        var left = points[0];
        var top = points[0];
        var right = points[0];
        var bottom = points[0];

        // find the leftmost, rightmost, topmost and bottommost points
        for (var i = 0; i < points.length; i++) {
            var p = points[i];
            if (p[0] < left[0]) left = p;
            if (p[0] > right[0]) right = p;
            if (p[1] < top[1]) top = p;
            if (p[1] > bottom[1]) bottom = p;
        }

        // filter out points that are inside the resulting quadrilateral
        var cull = [left, top, right, bottom];
        var filtered = cull.slice();
        for (i = 0; i < points.length; i++) {
            if (!pointInPolygon$2(points[i], cull)) filtered.push(points[i]);
        }

        // get convex hull around the filtered points
        var indices = convexHull(filtered);

        // return the hull as array of points (rather than indices)
        var hull = [];
        for (i = 0; i < indices.length; i++) hull.push(filtered[indices[i]]);
        return hull;
    }

    // create a new node in a doubly linked list
    function insertNode(p, prev) {
        var node = {
            p: p,
            prev: null,
            next: null,
            minX: 0,
            minY: 0,
            maxX: 0,
            maxY: 0
        };

        if (!prev) {
            node.prev = node;
            node.next = node;

        } else {
            node.next = prev.next;
            node.prev = prev;
            prev.next.prev = node;
            prev.next = node;
        }
        return node;
    }

    // square distance between 2 points
    function getSqDist(p1, p2) {

        var dx = p1[0] - p2[0],
            dy = p1[1] - p2[1];

        return dx * dx + dy * dy;
    }

    // square distance from a point to a segment
    function sqSegDist(p, p1, p2) {

        var x = p1[0],
            y = p1[1],
            dx = p2[0] - x,
            dy = p2[1] - y;

        if (dx !== 0 || dy !== 0) {

            var t = ((p[0] - x) * dx + (p[1] - y) * dy) / (dx * dx + dy * dy);

            if (t > 1) {
                x = p2[0];
                y = p2[1];

            } else if (t > 0) {
                x += dx * t;
                y += dy * t;
            }
        }

        dx = p[0] - x;
        dy = p[1] - y;

        return dx * dx + dy * dy;
    }

    // segment to segment distance, ported from http://geomalgorithms.com/a07-_distance.html by Dan Sunday
    function sqSegSegDist(x0, y0, x1, y1, x2, y2, x3, y3) {
        var ux = x1 - x0;
        var uy = y1 - y0;
        var vx = x3 - x2;
        var vy = y3 - y2;
        var wx = x0 - x2;
        var wy = y0 - y2;
        var a = ux * ux + uy * uy;
        var b = ux * vx + uy * vy;
        var c = vx * vx + vy * vy;
        var d = ux * wx + uy * wy;
        var e = vx * wx + vy * wy;
        var D = a * c - b * b;

        var sc, sN, tc, tN;
        var sD = D;
        var tD = D;

        if (D === 0) {
            sN = 0;
            sD = 1;
            tN = e;
            tD = c;
        } else {
            sN = b * e - c * d;
            tN = a * e - b * d;
            if (sN < 0) {
                sN = 0;
                tN = e;
                tD = c;
            } else if (sN > sD) {
                sN = sD;
                tN = e + b;
                tD = c;
            }
        }

        if (tN < 0.0) {
            tN = 0.0;
            if (-d < 0.0) sN = 0.0;
            else if (-d > a) sN = sD;
            else {
                sN = -d;
                sD = a;
            }
        } else if (tN > tD) {
            tN = tD;
            if ((-d + b) < 0.0) sN = 0;
            else if (-d + b > a) sN = sD;
            else {
                sN = -d + b;
                sD = a;
            }
        }

        sc = sN === 0 ? 0 : sN / sD;
        tc = tN === 0 ? 0 : tN / tD;

        var cx = (1 - sc) * x0 + sc * x1;
        var cy = (1 - sc) * y0 + sc * y1;
        var cx2 = (1 - tc) * x2 + tc * x3;
        var cy2 = (1 - tc) * y2 + tc * y3;
        var dx = cx2 - cx;
        var dy = cy2 - cy;

        return dx * dx + dy * dy;
    }
    concaveman_1.default = default_1$2;

    /**
     * Takes a {@link Feature} or a {@link FeatureCollection} and returns a convex hull {@link Polygon}.
     *
     * Internally this uses
     * the [convex-hull](https://github.com/mikolalysenko/convex-hull) module that implements a
     * [monotone chain hull](http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain).
     *
     * @name convex
     * @param {GeoJSON} geojson input Feature or FeatureCollection
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.concavity=Infinity] 1 - thin shape. Infinity - convex hull.
     * @param {Object} [options.properties={}] Translate Properties to Feature
     * @returns {Feature<Polygon>} a convex hull
     * @example
     * var points = turf.featureCollection([
     *   turf.point([10.195312, 43.755225]),
     *   turf.point([10.404052, 43.8424511]),
     *   turf.point([10.579833, 43.659924]),
     *   turf.point([10.360107, 43.516688]),
     *   turf.point([10.14038, 43.588348]),
     *   turf.point([10.195312, 43.755225])
     * ]);
     *
     * var hull = turf.convex(points);
     *
     * //addToMap
     * var addToMap = [points, hull]
     */
    function convex(geojson, options) {
        options = checkIfOptionsExist(options);

        // Default parameters
        options.concavity = options.concavity || Infinity;

        // Container
        const points$$1 = [];

        // Convert all points to flat 2D coordinate Array
        coordEach(geojson, (coord) => {
            points$$1.push([coord[0], coord[1]]);
        });
        if (!points$$1.length) { return null; }

        const convexHull = concaveman_1(points$$1, options.concavity);

        // Convex hull should have at least 3 different vertices in order to create a valid polygon
        if (convexHull.length > 3) {
            return polygon([convexHull]);
        }
        return null;
    }

    // http://en.wikipedia.org/wiki/Even%E2%80%93odd_rule
    // modified from: https://github.com/substack/point-in-polygon/blob/master/index.js
    // which was modified from http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
    /**
     * Takes a {@link Point} and a {@link Polygon} or {@link MultiPolygon} and determines if the point
     * resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.
     *
     * @name booleanPointInPolygon
     * @param {Coord} point input point
     * @param {Feature<Polygon|MultiPolygon>} polygon input polygon or multipolygon
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.ignoreBoundary=false] True if polygon boundary should be ignored when determining if
     * the point is inside the polygon otherwise false.
     * @returns {boolean} `true` if the Point is inside the Polygon; `false` if the Point is not inside the Polygon
     * @example
     * var pt = turf.point([-77, 44]);
     * var poly = turf.polygon([[
     *   [-81, 41],
     *   [-81, 47],
     *   [-72, 47],
     *   [-72, 41],
     *   [-81, 41]
     * ]]);
     *
     * turf.booleanPointInPolygon(pt, poly);
     * //= true
     */
    function booleanPointInPolygon(point$$1, polygon$$1, options) {
        options = checkIfOptionsExist(options);
        // validation
        if (!point$$1) { throw new Error('point is required'); }
        if (!polygon$$1) { throw new Error('polygon is required'); }

        const pt = getCoord(point$$1);
        const geom = getGeom(polygon$$1);
        const type = geom.type;
        const bbox = polygon$$1.bbox;
        let polys = geom.coordinates;

        // Quick elimination if point is not inside bbox
        if (bbox && inBBox(pt, bbox) === false) {
            return false;
        }
        // normalize to multipolygon
        if (type === 'Polygon') {
            polys = [polys];
        }
        let insidePoly = false;
        for (let i = 0; i < polys.length && !insidePoly; i++) {
            // check if it is in the outer ring first
            if (inRing(pt, polys[i][0], options.ignoreBoundary)) {
                let inHole = false;
                let k = 1;
                // check for the point in any of the holes
                while (k < polys[i].length && !inHole) {
                    if (inRing(pt, polys[i][k], !options.ignoreBoundary)) {
                        inHole = true;
                    }
                    k++;
                }
                if (!inHole) {
                    insidePoly = true;
                }
            }
        }
        return insidePoly;
    }

    /**
     * inRing
     *
     * @private
     * @param {Array<number>} pt [x,y]
     * @param {Array<Array<number>>} ring [[x,y], [x,y],..]
     * @param {boolean} ignoreBoundary ignoreBoundary
     * @returns {boolean} inRing
     */
    function inRing(pt, ring, ignoreBoundary) {
        let isInside = false;
        if (ring[0][0] === ring[ring.length - 1][0] && ring[0][1] === ring[ring.length - 1][1]) {
            ring = ring.slice(0, ring.length - 1);
        }
        for (let i = 0, j = ring.length - 1; i < ring.length; j = i++) {
            const xi = ring[i][0];
            const yi = ring[i][1];
            const xj = ring[j][0];
            const yj = ring[j][1];
            const onBoundary = (pt[1] * (xi - xj) + yi * (xj - pt[0]) + yj * (pt[0] - xi) === 0) &&
                ((xi - pt[0]) * (xj - pt[0]) <= 0) && ((yi - pt[1]) * (yj - pt[1]) <= 0);
            if (onBoundary) {
                return !ignoreBoundary;
            }
            const intersect = ((yi > pt[1]) !== (yj > pt[1])) &&
                (pt[0] < (xj - xi) * (pt[1] - yi) / (yj - yi) + xi);
            if (intersect) {
                isInside = !isInside;
            }
        }
        return isInside;
    }
    /**
     * inBBox
     *
     * @private
     * @param {Position} pt point [x,y]
     * @param {BBox} bbox BBox [west, south, east, north]
     * @returns {boolean} true/false if point is inside BBox
     */
    function inBBox(pt, bbox) {
        return bbox[0] <= pt[0] &&
            bbox[1] <= pt[1] &&
            bbox[2] >= pt[0] &&
            bbox[3] >= pt[1];
    }

    /**
     * Finds {@link Points} that fall within {@link (Multi)Polygon(s)}.
     *
     * @name pointsWithinPolygon
     * @param {Feauture|FeatureCollection<Point>} points Points as input search
     * @param {FeatureCollection|Geoemtry|Feature<Polygon|MultiPolygon>} polygons Points must be within these (Multi)Polygon(s)
     * @returns {FeatureCollection<Point>} points that land within at least one polygon
     * @example
     * var points = turf.points([
     *     [-46.6318, -23.5523],
     *     [-46.6246, -23.5325],
     *     [-46.6062, -23.5513],
     *     [-46.663, -23.554],
     *     [-46.643, -23.557]
     * ]);
     *
     * var searchWithin = turf.polygon([[
     *     [-46.653,-23.543],
     *     [-46.634,-23.5346],
     *     [-46.613,-23.543],
     *     [-46.614,-23.559],
     *     [-46.631,-23.567],
     *     [-46.653,-23.560],
     *     [-46.653,-23.543]
     * ]]);
     *
     * var ptsWithin = turf.pointsWithinPolygon(points, searchWithin);
     *
     * //addToMap
     * var addToMap = [points, searchWithin, ptsWithin]
     * turf.featureEach(ptsWithin, function (currentFeature) {
     *   currentFeature.properties['marker-size'] = 'large';
     *   currentFeature.properties['marker-color'] = '#000';
     * });
     */
    function pointsWithinPolygon(points$$1, polygons$$1) {
        var results = [];
        geomEach(polygons$$1, function (polygon$$1) {
            featureEach(points$$1, function (point$$1) {
                if (booleanPointInPolygon(point$$1, polygon$$1)) results.push(point$$1);
            });
        });
        return featureCollection(results);
    }

    //http://en.wikipedia.org/wiki/Haversine_formula
    //http://www.movable-type.co.uk/scripts/latlong.html

    /**
     * Calculates the distance between two {@link Point|points} in degrees, radians, miles, or kilometers.
     * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
     *
     * @name distance
     * @param {Coord} from origin point
     * @param {Coord} to destination point
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
     * @returns {number} distance between the two points
     * @example
     * var from = turf.point([-75.343, 39.984]);
     * var to = turf.point([-75.534, 39.123]);
     * var options = {units: 'miles'};
     *
     * var distance = turf.distance(from, to, options);
     *
     * //addToMap
     * var addToMap = [from, to];
     * from.properties.distance = distance;
     * to.properties.distance = distance;
     */
    function distance(from, to, options) {
        options = checkIfOptionsExist(options);
        var coordinates1 = getCoord(from);
        var coordinates2 = getCoord(to);
        var dLat = degreesToRadians((coordinates2[1] - coordinates1[1]));
        var dLon = degreesToRadians((coordinates2[0] - coordinates1[0]));
        var lat1 = degreesToRadians(coordinates1[1]);
        var lat2 = degreesToRadians(coordinates2[1]);

        var a = Math.pow(Math.sin(dLat / 2), 2) +
              Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);

        return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units);
    }

    // http://en.wikipedia.org/wiki/Delaunay_triangulation

    /**
     * Takes a set of {@link Point|points} and creates a
     * [Triangulated Irregular Network](http://en.wikipedia.org/wiki/Triangulated_irregular_network),
     * or a TIN for short, returned as a collection of Polygons. These are often used
     * for developing elevation contour maps or stepped heat visualizations.
     *
     * If an optional z-value property is provided then it is added as properties called `a`, `b`,
     * and `c` representing its value at each of the points that represent the corners of the
     * triangle.
     *
     * @name tin
     * @param {FeatureCollection<Point>} points input points
     * @param {String} [z] name of the property from which to pull z values
     * This is optional: if not given, then there will be no extra data added to the derived triangles.
     * @returns {FeatureCollection<Polygon>} TIN output
     * @example
     * // generate some random point data
     * var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]});
     *
     * // add a random property to each point between 0 and 9
     * for (var i = 0; i < points.features.length; i++) {
     *   points.features[i].properties.z = ~~(Math.random() * 9);
     * }
     * var tin = turf.tin(points, 'z');
     *
     * //addToMap
     * var addToMap = [tin, points]
     * for (var i = 0; i < tin.features.length; i++) {
     *   var properties  = tin.features[i].properties;
     *   properties.fill = '#' + properties.a + properties.b + properties.c;
     * }
     */
    function tin(points$$1, z){
        // break down points
        let isPointZ = false;
        return featureCollection(triangulate(points$$1.features.map(function (p) {
            const point$$1 = {
                x: p.geometry.coordinates[0],
                y: p.geometry.coordinates[1],
            };
            if (z) {
                point$$1.z = p.properties[z];
            } else if (p.geometry.coordinates.length === 3) {
                isPointZ = true;
                point$$1.z = p.geometry.coordinates[2];
            }
            return point$$1;
        })).map(function (triangle) {

            const a = [triangle.a.x, triangle.a.y];
            const b = [triangle.b.x, triangle.b.y];
            const c = [triangle.c.x, triangle.c.y];
            let properties = {};

            // Add z coordinates to triangle points if user passed
            // them in that way otherwise add it as a property.
            if (isPointZ) {
                a.push(triangle.a.z);
                b.push(triangle.b.z);
                c.push(triangle.c.z);
            } else {
                properties = {
                    a: triangle.a.z,
                    b: triangle.b.z,
                    c: triangle.c.z,
                };
            }

            return polygon([[a, b, c, a]], properties);

        }));
    }

    function Triangle(a, b, c) {
        this.a = a;
        this.b = b;
        this.c = c;

        var A = b.x - a.x,
            B = b.y - a.y,
            C = c.x - a.x,
            D = c.y - a.y,
            E = A * (a.x + b.x) + B * (a.y + b.y),
            F = C * (a.x + c.x) + D * (a.y + c.y),
            G = 2 * (A * (c.y - b.y) - B * (c.x - b.x)),
            dx, dy;

        // If the points of the triangle are collinear, then just find the
        // extremes and use the midpoint as the center of the circumcircle.
        this.x = (D * E - B * F) / G;
        this.y = (A * F - C * E) / G;
        dx = this.x - a.x;
        dy = this.y - a.y;
        this.r = dx * dx + dy * dy;
    }

    function byX(a, b) {
        return b.x - a.x;
    }

    function dedup(edges) {
        let j = edges.length;
        let a;
        let b;
        let i;
        let m;
        let n;

        outer:
        while (j) {
            b = edges[--j];
            a = edges[--j];
            i = j;
            while (i) {
                n = edges[--i];
                m = edges[--i];
                if ((a === m && b === n) || (a === n && b === m)) {
                    edges.splice(j, 2);
                    edges.splice(i, 2);
                    j -= 2;
                    continue outer;
                }
            }
        }
    }

    function triangulate(vertices) {
        // Bail if there aren't enough vertices to form any triangles.
        if (vertices.length < 3) {
            return [];
        }

        // Ensure the vertex array is in order of descending X coordinate
        // (which is needed to ensure a subquadratic runtime), and then find
        // the bounding box around the points.
        vertices.sort(byX);

        let i = vertices.length - 1;
        const xmin = vertices[i].x;
        const xmax = vertices[0].x;
        let ymin = vertices[i].y;
        let ymax = ymin;
        const epsilon = 1e-12;

        let a;
        let b;
        let c;
        let A;
        let B;
        let G;

        while (i--) {
            if (vertices[i].y < ymin) {
                ymin = vertices[i].y;
            }
            if (vertices[i].y > ymax) {
                ymax = vertices[i].y;
            }
        }

        // Find a supertriangle, which is a triangle that surrounds all the
        // vertices. This is used like something of a sentinel value to remove
        // cases in the main algorithm, and is removed before we return any
        // results.

        // Once found, put it in the "open" list. (The "open" list is for
        // triangles who may still need to be considered; the "closed" list is
        // for triangles which do not.)
        let dx = xmax - xmin;
        let dy = ymax - ymin;
        const dmax = (dx > dy) ? dx : dy;
        const xmid = (xmax + xmin) * 0.5;
        const ymid = (ymax + ymin) * 0.5;
        const open = [
                new Triangle({
                    __sentinel: true,
                    x: xmid - 20 * dmax,
                    y: ymid - dmax,
                }, {
                    __sentinel: true,
                    x: xmid,
                    y: ymid + 20 * dmax,
                }, {
                    __sentinel: true,
                    x: xmid + 20 * dmax,
                    y: ymid - dmax,
                },
                )];
        const closed = [];
        const edges = [];
        let j;

        // Incrementally add each vertex to the mesh.
        i = vertices.length;
        while (i--) {
            // For each open triangle, check to see if the current point is
            // inside it's circumcircle. If it is, remove the triangle and add
            // it's edges to an edge list.
            edges.length = 0;
            j = open.length;
            while (j--) {
                // If this point is to the right of this triangle's circumcircle,
                // then this triangle should never get checked again. Remove it
                // from the open list, add it to the closed list, and skip.
                dx = vertices[i].x - open[j].x;
                if (dx > 0 && dx * dx > open[j].r) {
                    closed.push(open[j]);
                    open.splice(j, 1);
                    continue;
                }

                // If not, skip this triangle.
                dy = vertices[i].y - open[j].y;
                if (dx * dx + dy * dy > open[j].r) {
                    continue;
                }

                // Remove the triangle and add it's edges to the edge list.
                edges.push(
                    open[j].a, open[j].b,
                    open[j].b, open[j].c,
                    open[j].c, open[j].a,
                );
                open.splice(j, 1);
            }

            // Remove any doubled edges.
            dedup(edges);

            // Add a new triangle for each edge.
            j = edges.length;
            while (j) {
                b = edges[--j];
                a = edges[--j];
                c = vertices[i];
                // Avoid adding colinear triangles (which have error-prone
                // circumcircles)
                A = b.x - a.x;
                B = b.y - a.y;
                G = 2 * (A * (c.y - b.y) - B * (c.x - b.x));
                if (Math.abs(G) > epsilon) {
                    open.push(new Triangle(a, b, c));
                }
            }
        }

        // Copy any remaining open triangles to the closed list, and then
        // remove any triangles that share a vertex with the supertriangle.
        Array.prototype.push.apply(closed, open);

        i = closed.length;
        while (i--) {
            if (closed[i].a.__sentinel ||
                closed[i].b.__sentinel ||
                closed[i].c.__sentinel) {
                closed.splice(i, 1);
        }
            }

        return closed;
    }

    /**
     * nodejs heap, classic array implementation
     *
     * Items are stored in a balanced binary tree packed into an array where
     * node is at [i], left child is at [2*i], right at [2*i+1].  Root is at [1].
     *
     * Copyright (C) 2014-2017 Andras Radics
     * Licensed under the Apache License, Version 2.0
     */

    var qheap = Heap;

    function isBeforeDefault( a, b ) { return a < b; }

    function Heap( opts ) {
        opts = opts || {};
        if (typeof opts === 'function') opts = {compar: opts};

        if (opts.compar) {
            this._isBefore = function(a, b) { return opts.compar(a,b) < 0 };
        } else if (opts.comparBefore) {
            this._isBefore = opts.comparBefore;
        } else {
            this._isBefore = isBeforeDefault;
        }
        this.length = 0;
        this._freeSpace = opts.freeSpace ? this._trimArraySize : false;
        this._list = new Array(opts.size || 100);
    }

    Heap.prototype._list = null;
    Heap.prototype._compar = null;
    Heap.prototype._isBefore = null;
    Heap.prototype._freeSpace = null;
    Heap.prototype.length = 0;

    /*
     * insert new item at end, and bubble up
     */
    Heap.prototype.insert = function Heap_insert( item ) {
        var idx = ++this.length;
        var list = this._list;
        list[idx] = item;

        while (idx > 1) {
            var parentidx = idx >> 1;
            var parentval = list[parentidx];
            if (!(this._isBefore(item, parentval))) break;
            list[idx] = parentval;
            idx = parentidx;
        }
        list[idx] = item;
    };
    Heap.prototype.append = Heap.prototype.insert;
    Heap.prototype.push = Heap.prototype.insert;
    Heap.prototype.unshift = Heap.prototype.insert;
    Heap.prototype.enqueue = Heap.prototype.insert;

    Heap.prototype.peek = function Heap_peek( ) {
        return this.length > 0 ? this._list[1] : undefined;
    };

    Heap.prototype.size = function Heap_size( ) {
        return this.length;
    };

    /*
     * return the root, and bubble down last item from top root position
     * when bubbling down, r: root idx, c: child sub-tree root idx, cv: child root value
     * Note that the child at (c == this.length) does not have to be tested in the loop,
     * since its value is the one being bubbled down, so can loop `while (c < len)`.
     *
     * Note that a redundant (c < len &&) test before the c vs c+1 compar lets node v0.10
     * run 4x faster; v4, v5 and v6 run faster without it if using _isBefore and not
     * raw _compar.
     *
     * Note that this version runs faster than the two-pass pull-up-new-root then
     * bubble-up-last-value-from-hole approach (except when inserting pre-sorted data).
     */
    Heap.prototype.remove = function Heap_remove( ) {
        if (this.length < 1) return undefined;
        var ret = this._list[1];
        var itm = this._list[this.length];

        var r = 1, c = 2, cv;
        var len = this.length;
        while (c < len) {
            cv = this._list[c];
            if (this._isBefore(this._list[c+1], cv)) { cv = this._list[c+1] ; c = c+1; }
            if (!(this._isBefore(cv, itm))) break;
            this._list[r] = cv;
            r = c;
            c = c << 1;
        }
        this._list[len] = 0;
        this.length = --len;
        if (len) this._list[r] = itm;
        if (this._freeSpace) this._freeSpace(this._list, len);

        return ret;
    };
    Heap.prototype.shift = Heap.prototype.remove;
    Heap.prototype.pop = Heap.prototype.remove;
    Heap.prototype.dequeue = Heap.prototype.remove;

    /*
     * Free unused storage slots in the _list.
     * The default is to unconditionally gc, use the options to omit when not useful.
     */
    Heap.prototype.gc = function Heap_gc( options ) {
        if (!options) options = {};

        var minListLength = options.minLength;      // smallest list that will be gc-d
        if (minListLength === undefined) minListLength = 0;

        var minListFull = options.minFull;          // list utilization below which to gc
        if (minListFull === undefined) minListFull = 1.00;

        if (this._list.length >= minListLength && (this.length < this._list.length * minListFull)) {
            // gc reallocates the array to free the unused storage slots at the end
            // use splice to actually free memory; 7% slower than setting .length
            // note: list.slice makes the array slower to insert to??  splice is better
            this._list.splice(this.length+1, this._list.length);
        }
    };

    Heap.prototype._trimArraySize = function Heap__trimArraySize( list, len ) {
        if (len > 10000 && list.length > 4 * len) {
            // use slice to actually free memory; 7% slower than setting .length
            // note: list.slice makes the array slower to insert to??  splice is better
            list.splice(len+1, list.length);
        }
    };

    Heap.prototype._check = function Heap__check( ) {
        var isBefore = this._isBefore;
        var _compar = function(a, b) { return isBefore(a, b) ? -1 : 1 };

        var i, p, fail = 0;
        for (i=this.length; i>1; i--) {
            // error if parent should go after child, but not if don`t care
            p = i >>> 1;
            // swapping the values must change their ordering, otherwise the
            // comparison is a tie.  (Ie, consider the ordering func (a <= b)
            // that for some values reports both that a < b and b < a.)
            if (_compar(this._list[p], this._list[i]) > 0 &&
                _compar(this._list[i], this._list[p]) < 0)
            {
                fail = i;
            }
        }
        if (fail) console.log("failed at", (fail >>> 1), fail);
        return !fail;
    };

    // optimize access
    Heap.prototype = Heap.prototype;

    var qheap$1 = /*#__PURE__*/Object.freeze({
        default: qheap,
        __moduleExports: qheap
    });

    var require$$0$1 = ( qheap$1 && qheap ) || qheap$1;

    var qheap$2 = require$$0$1;

    /* Javascript doesn't do integer math. Everything is
     * floating point with percision Number.EPSILON.
     *
     * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/EPSILON
     */

    // IE Polyfill
    if (Number.EPSILON === undefined) Number.EPSILON = Math.pow(2, -52);

    const EPSILON_SQ = Number.EPSILON * Number.EPSILON;

    /* FLP comparator */
    const cmp = (a, b) => {
      // check if they're both 0
      if (-Number.EPSILON < a && a < Number.EPSILON) {
        if (-Number.EPSILON < b && b < Number.EPSILON) {
          return 0
        }
      }

      // check if they're flp equal
      if ((a - b) * (a - b) < EPSILON_SQ * a * b) {
        return 0
      }

      // normal comparison
      return a < b ? -1 : 1
    };

    /* FLP point comparator, favors point encountered first by sweep line */
    const cmpPoints = (aPt, bPt) => {
      // fist compare X, then compare Y

      let a = aPt.x;
      let b = bPt.x;

      // inlined version of cmp() for performance boost
      if (
        a <= -Number.EPSILON ||
        Number.EPSILON <= a ||
        b <= -Number.EPSILON ||
        Number.EPSILON <= b
      ) {
        const diff = a - b;
        if (diff * diff >= EPSILON_SQ * a * b) {
          return a < b ? -1 : 1
        }
      }

      a = aPt.y;
      b = bPt.y;

      // inlined version of cmp() for performance boost
      if (
        a <= -Number.EPSILON ||
        Number.EPSILON <= a ||
        b <= -Number.EPSILON ||
        Number.EPSILON <= b
      ) {
        const diff = a - b;
        if (diff * diff >= EPSILON_SQ * a * b) {
          return a < b ? -1 : 1
        }
      }

      // they're the same
      return 0
    };

    /* Cross Product of two vectors with first point at origin */
    const crossProduct = (a, b) => a.x * b.y - a.y * b.x;

    /* Dot Product of two vectors with first point at origin */
    const dotProduct = (a, b) => a.x * b.x + a.y * b.y;

    /* Comparator for two vectors with same starting point */
    const compareVectorAngles = (basePt, endPt1, endPt2) => {
      const v1 = { x: endPt1.x - basePt.x, y: endPt1.y - basePt.y };
      const v2 = { x: endPt2.x - basePt.x, y: endPt2.y - basePt.y };
      const kross = crossProduct(v1, v2);
      return cmp(kross, 0)
    };

    const length = v => Math.sqrt(dotProduct(v, v));

    /* Get the sine of the angle from pShared -> pAngle to pShaed -> pBase */
    const sineOfAngle = (pShared, pBase, pAngle) => {
      const vBase = { x: pBase.x - pShared.x, y: pBase.y - pShared.y };
      const vAngle = { x: pAngle.x - pShared.x, y: pAngle.y - pShared.y };
      return crossProduct(vAngle, vBase) / length(vAngle) / length(vBase)
    };

    /* Get the cosine of the angle from pShared -> pAngle to pShaed -> pBase */
    const cosineOfAngle = (pShared, pBase, pAngle) => {
      const vBase = { x: pBase.x - pShared.x, y: pBase.y - pShared.y };
      const vAngle = { x: pAngle.x - pShared.x, y: pAngle.y - pShared.y };
      return dotProduct(vAngle, vBase) / length(vAngle) / length(vBase)
    };

    /* Given input geometry as a standard array-of-arrays geojson-style
     * geometry, return one that uses objects as points, for better perf */
    const pointsAsObjects = geom => {
      // we can handle well-formed multipolys and polys
      const output = [];
      if (!Array.isArray(geom)) {
        throw new Error('Input is not a Polygon or MultiPolygon')
      }
      for (let i = 0, iMax = geom.length; i < iMax; i++) {
        if (!Array.isArray(geom[i])) {
          throw new Error('Input is not a Polygon or MultiPolygon')
        }
        output.push([]);
        for (let j = 0, jMax = geom[i].length; j < jMax; j++) {
          if (!Array.isArray(geom[i][j])) {
            throw new Error('Input is not a Polygon or MultiPolygon')
          }
          if (geom[i][j].length === 2) {
            output[i].push({ x: geom[i][j][0], y: geom[i][j][1] });
            continue
          }
          output[i].push([]);
          for (let k = 0, kMax = geom[i][j].length; k < kMax; k++) {
            if (!Array.isArray(geom[i][j][k]) || geom[i][j][k].length !== 2) {
              throw new Error('Input is not a Polygon or MultiPolygon')
            }
            output[i][j].push({ x: geom[i][j][k][0], y: geom[i][j][k][1] });
          }
        }
      }
      return output
    };

    /* WARN: input modified directly */
    const forceMultiPoly = geom => {
      if (Array.isArray(geom)) {
        if (geom.length === 0) return // allow empty multipolys

        if (Array.isArray(geom[0])) {
          if (Array.isArray(geom[0][0])) {
            if (
              typeof geom[0][0][0].x === 'number' &&
              typeof geom[0][0][0].y === 'number'
            ) {
              // multipolygon
              return
            }
          }
          if (
            typeof geom[0][0].x === 'number' &&
            typeof geom[0][0].y === 'number'
          ) {
            // polygon
            geom.unshift(geom.splice(0));
            return
          }
        }
      }
      throw new Error('Unrecognized input - not a polygon nor multipolygon')
    };

    /* WARN: input modified directly */
    const cleanMultiPoly = multipoly => {
      let i = 0;
      while (i < multipoly.length) {
        const poly = multipoly[i];
        if (poly.length === 0) {
          multipoly.splice(i, 1);
          continue
        }

        const exteriorRing = poly[0];
        cleanRing(exteriorRing);
        // poly is dropped if exteriorRing is degenerate
        if (exteriorRing.length === 0) {
          multipoly.splice(i, 1);
          continue
        }

        let j = 1;
        while (j < poly.length) {
          const interiorRing = poly[j];
          cleanRing(interiorRing);
          if (interiorRing.length === 0) poly.splice(j, 1);
          else j++;
        }

        i++;
      }
    };

    /* Clean ring:
     *  - remove duplicate points
     *  - remove colinear points
     *  - remove rings with no area (less than 3 distinct points)
     *  - close rings (last point should equal first)
     *
     * WARN: input modified directly */
    const cleanRing = ring => {
      if (ring.length === 0) return
      if (cmpPoints(ring[0], ring[ring.length - 1]) !== 0) {
        ring.push({ x: ring[0].x, y: ring[0].y }); // copy by value
      }

      const isPointUncessary = (prevPt, pt, nextPt) =>
        cmpPoints(prevPt, pt) === 0 ||
        cmpPoints(pt, nextPt) === 0 ||
        compareVectorAngles(pt, prevPt, nextPt) === 0;

      let i = 1;
      while (i < ring.length - 1) {
        if (isPointUncessary(ring[i - 1], ring[i], ring[i + 1])) ring.splice(i, 1);
        else i++;
      }

      // check the first/last point as well
      while (ring.length > 2) {
        if (!isPointUncessary(ring[ring.length - 2], ring[0], ring[1])) break
        ring.splice(0, 1);
        ring.splice(ring.length - 1, 1);
        ring.push(ring[0]);
      }

      // if our ring has less than 3 distinct points now (so is degenerate)
      // shrink it down to the empty array to communicate to our caller to
      // drop it
      while (ring.length < 4 && ring.length > 0) ring.pop();
    };

    /* Scan the already-linked events of the segments for any
     * self-intersecting input rings (which are not supported) */
    const errorOnSelfIntersectingRings = segments => {
      for (let i = 0, iMax = segments.length; i < iMax; i++) {
        const seg = segments[i];

        const evt = seg.flowIntoSE;

        if (evt.linkedEvents.length > 2) {
          const evtsThisRing = evt.linkedEvents.filter(
            other => other.segment.ringIn === seg.ringIn
          );
          if (evtsThisRing.length > 2) {
            evtsThisRing.sort(evt.getLeftmostComparator(evt.otherSE));
            const leftMostEvt = evtsThisRing[1]; // skip ourself
            const rightMostEvt = evtsThisRing[evtsThisRing.length - 1];

            // both the segment on our immediate left and right will flow
            // 'out' in intersection point was a touch and not a crossing
            if (
              leftMostEvt.segment.flowIntoSE === leftMostEvt ||
              rightMostEvt.segment.flowIntoSE === rightMostEvt
            ) {
              throw new Error(
                `Self-intersecting, crossing input ring found at ` +
                  `[${evt.point.x}, ${evt.point.y}]`
              )
            }
          }
        }
      }
    };

    class Operation {
      constructor () {
        this.types = {
          INTERSECTION: 0,
          UNION: 1,
          XOR: 2,
          DIFFERENCE: 3
        };
      }

      register (type, numMultiPolys) {
        this.type = type;
        this.numMultiPolys = numMultiPolys;
      }
    }

    // global to register details about the operation on
    const operation = new Operation();

    class SweepEvent {
      static compareBefore (a, b) {
        // favor event with a point that the sweep line hits first
        const cmpX = cmp(a.point.x, b.point.x);
        if (cmpX !== 0) return cmpX < 0

        const cmpY = cmp(a.point.y, b.point.y);
        if (cmpY !== 0) return cmpY < 0

        // favor right events over left
        if (a.isLeft !== b.isLeft) return !a.isLeft

        // favor events where the line segment is lower
        const pointSegCmp = a.segment.comparePoint(b.otherSE.point);
        if (pointSegCmp !== 0) return pointSegCmp > 0

        // as a tie-breaker, favor lower segment creation id
        const aId = a.segment.ringIn.id;
        const bId = b.segment.ringIn.id;
        if (aId !== bId) return aId < bId

        // NOTE:  We don't sort on segment length because that changes
        //        as segments are divided.

        // they appear to be the same point... are they?
        if (a === b) return false

        throw new Error(
          `SweepEvent comparison failed at [${a.point.x}, ${a.point.y}]... ` +
            `equal but not identical?`
        )
      }

      constructor (point, segment) {
        this.point = point;
        this.segment = segment;
        this.linkedEvents = [this];
      }

      link (other) {
        const otherLE = other.linkedEvents;
        for (let i = 0, iMax = otherLE.length; i < iMax; i++) {
          const evt = otherLE[i];
          this.linkedEvents.push(evt);
          evt.linkedEvents = this.linkedEvents;
        }
      }

      getAvailableLinkedEvents () {
        const events = [];
        for (let i = 0, iMax = this.linkedEvents.length; i < iMax; i++) {
          const evt = this.linkedEvents[i];
          if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult) {
            events.push(evt);
          }
        }
        return events
      }

      /**
       * Returns a comparator function for sorting linked events that will
       * favor the event that will give us the smallest left-side angle.
       * All ring construction starts as low as possible heading to the right,
       * so by always turning left as sharp as possible we'll get polygons
       * without uncessary loops & holes.
       *
       * The comparator function has a compute cache such that it avoids
       * re-computing already-computed values.
       */
      getLeftmostComparator (baseEvent) {
        const cache = new Map();

        const fillCache = linkedEvent => {
          const nextEvent = linkedEvent.otherSE;
          cache.set(linkedEvent, {
            sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
            cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
          });
        };

        return (a, b) => {
          if (!cache.has(a)) fillCache(a);
          if (!cache.has(b)) fillCache(b);

          const { sine: asine, cosine: acosine } = cache.get(a);
          const { sine: bsine, cosine: bcosine } = cache.get(b);

          const cmpZeroASine = cmp(asine, 0);
          const cmpZeroBSine = cmp(bsine, 0);

          if (cmpZeroASine >= 0 && cmpZeroBSine >= 0) return cmp(bcosine, acosine)
          if (cmpZeroASine < 0 && cmpZeroBSine < 0) return cmp(acosine, bcosine)
          return cmp(bsine, asine)
        }
      }

      get isLeft () {
        return this === this.segment.leftSE
      }

      get isRight () {
        return this === this.segment.rightSE
      }

      get otherSE () {
        return this.segment.getOtherSE(this)
      }
    }

    /**
     * A bounding box has the format:
     *
     *  { ll: { x: xmin, y: ymin }, ur: { x: xmax, y: ymax } }
     *
     */

    const isInBbox = (bbox, point) => {
      const xmin = bbox.ll.x;
      const ymin = bbox.ll.y;
      const xmax = bbox.ur.x;
      const ymax = bbox.ur.y;
      const xpt = point.x;
      const ypt = point.y;
      return (
        cmp(xmin, xpt) <= 0 &&
        cmp(xpt, xmax) <= 0 &&
        cmp(ymin, ypt) <= 0 &&
        cmp(ypt, ymax) <= 0
      )
    };

    const doBboxesOverlap = (b1, b2) =>
      !(
        cmp(b2.ur.x, b1.ll.x) < 0 ||
        cmp(b1.ur.x, b2.ll.x) < 0 ||
        cmp(b2.ur.y, b1.ll.y) < 0 ||
        cmp(b1.ur.y, b2.ll.y) < 0
      );

    /* Returns either null, or a bbox (aka an ordered pair of points)
     * If there is only one point of overlap, a bbox with identical points
     * will be returned */
    const getBboxOverlap = (b1, b2) => {
      if (!doBboxesOverlap(b1, b2)) return null

      // find the middle two X values
      const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
      const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;

      // find the middle two Y values
      const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
      const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;

      // put those middle values together to get the overlap
      return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } }
    };

    /* Returns a list of unique corners.
     * Will contain one, two or four points */
    const getUniqueCorners = bbox => {
      const xmin = bbox.ll.x;
      const ymin = bbox.ll.y;
      const xmax = bbox.ur.x;
      const ymax = bbox.ur.y;
      const xEq = cmp(xmin, xmax) === 0;
      const yEq = cmp(ymin, ymax) === 0;
      if (xEq && yEq) return [{ x: xmin, y: ymin }]
      if (xEq) return [{ x: xmin, y: ymin }, { x: xmin, y: ymax }]
      if (yEq) return [{ x: xmin, y: ymin }, { x: xmax, y: ymin }]
      return [
        { x: xmin, y: ymin },
        { x: xmin, y: ymax },
        { x: xmax, y: ymin },
        { x: xmax, y: ymax }
      ]
    };

    class Segment {
      static compare (a, b) {
        if (a === b) return 0

        const alx = a.leftSE.point.x;
        const aly = a.leftSE.point.y;
        const blx = b.leftSE.point.x;
        const bly = b.leftSE.point.y;
        const arx = a.rightSE.point.x;
        const brx = b.rightSE.point.x;

        // check if they're even in the same vertical plane
        if (cmp(brx, alx) < 0) return 1
        if (cmp(arx, blx) < 0) return -1

        const cmpLeft = a.comparePoint(b.leftSE.point);
        const cmpLX = cmp(alx, blx);

        // are a and b colinear?
        if (
          cmpLeft === 0 &&
          a.comparePoint(b.rightSE.point) === 0 &&
          b.comparePoint(a.leftSE.point) === 0 &&
          b.comparePoint(a.rightSE.point) === 0
        ) {
          // colinear segments with non-matching left-endpoints, consider
          // the more-left endpoint to be earlier
          if (cmpLX !== 0) return cmpLX

          // colinear segments with matching left-endpoints, fall back
          // on creation order of segments as a tie-breaker
          // NOTE: we do not use segment length to break a tie here, because
          //       when segments are split their length changes
          if (a.ringIn.id !== b.ringIn.id) {
            return a.ringIn.id < b.ringIn.id ? -1 : 1
          }
        } else {
          // not colinear

          // if the our left endpoints are not in the same vertical line,
          // consider a vertical line at the rightmore of the two left endpoints,
          // consider the segment that intersects lower with that line to be earlier
          if (cmpLX < 0) return cmpLeft === 1 ? -1 : 1
          if (cmpLX > 0) return b.comparePoint(a.leftSE.point) === 1 ? 1 : -1

          // if our left endpoints match, consider the segment
          // that angles more downward to be earlier
          if (cmpLX === 0 && cmp(a.leftSE.point.y, b.leftSE.point.y) === 0) {
            return a.comparePoint(b.rightSE.point) > 0 ? -1 : 1
          }

          // left endpoints are in the same vertical line but don't overlap exactly,
          // lower means ealier
          return cmp(aly, bly)
        }

        throw new Error(
          `Segment comparison (from [${a.leftSE.point.x}, ${a.leftSR.point.y}])` +
            ` -> to [${a.rightSE.point.x}, ${a.rightSE.point.y}]) failed... ` +
            ` segments equal but not identical?`
        )
      }

      constructor (point1, point2, ring) {
        this.ringIn = ring;
        this.ringOut = null;

        const ptCmp = cmpPoints(point1, point2);
        let lp;
        let rp;
        if (ptCmp < 0) {
          lp = point1;
          rp = point2;
          this.flowL2R = true;
        } else if (ptCmp > 0) {
          lp = point2;
          rp = point1;
          this.flowL2R = false;
        } else {
          throw new Error(
            `Tried to create degenerate segment at [${point1.x}, ${point1.y}]`
          )
        }

        this.leftSE = new SweepEvent(lp, this);
        this.rightSE = new SweepEvent(rp, this);

        // cache of dynamically computed properies
        this._clearCache();
      }

      clone () {
        const seg = new Segment(this.leftSE.point, this.rightSE.point, this.ringIn);
        seg.flowL2R = this.flowL2R;
        return seg
      }

      get bbox () {
        const y1 = this.leftSE.point.y;
        const y2 = this.rightSE.point.y;
        return {
          ll: { x: this.leftSE.point.x, y: y1 < y2 ? y1 : y2 },
          ur: { x: this.rightSE.point.x, y: y1 > y2 ? y1 : y2 }
        }
      }

      /* A vector from the left point to the right */
      get vector () {
        return {
          x: this.rightSE.point.x - this.leftSE.point.x,
          y: this.rightSE.point.y - this.leftSE.point.y
        }
      }

      get isVertical () {
        return cmp(this.leftSE.point.x, this.rightSE.point.x) === 0
      }

      /* In the original ringIn, which event came second */
      get flowIntoSE () {
        return this.flowL2R ? this.rightSE : this.leftSE
      }

      getOtherSE (se) {
        if (se === this.leftSE) return this.rightSE
        if (se === this.rightSE) return this.leftSE
        throw new Error('may only be called by own sweep events')
      }

      isAnEndpoint (point) {
        return (
          cmpPoints(point, this.leftSE.point) === 0 ||
          cmpPoints(point, this.rightSE.point) === 0
        )
      }

      isPointOn (point) {
        return isInBbox(this.bbox, point) && this.comparePoint(point) === 0
      }

      /* Compare this segment with a point. Return value indicates
       *    1: point is below segment
       *    0: point is colinear to segment
       *   -1: point is above segment */
      comparePoint (point) {
        if (this.isAnEndpoint(point)) return 0
        return compareVectorAngles(point, this.leftSE.point, this.rightSE.point)
      }

      /**
       * Given another segment, returns an array of intersection points
       * between the two segments. The returned array can contain:
       *  * zero points:  no intersection b/t segments
       *  * one point:    segments intersect once
       *  * two points:   segments overlap. Endpoints of overlap returned.
       *                  Will be ordered as sweep line would encounter them.
       */
      getIntersections (other) {
        // If bboxes don't overlap, there can't be any intersections
        const bboxOverlap = getBboxOverlap(this.bbox, other.bbox);
        if (bboxOverlap === null) return []

        // The general algorithim doesn't handle overlapping colinear segments.
        // Overlapping colinear segments, if present, will have intersections
        // of one pair of opposing corners of the bbox overlap. Thus we just
        // manually check those coordinates.
        //
        // Note this also handles the cases of a collapsed bbox (just one point)
        // and semi-collapsed bbox (a vertical or horizontal line) as well.
        //
        // In addition, in the case of a T-intersection, this ensures that the
        // interseciton returned matches exactly an endpoint - no rounding error.
        const intersections = [];
        const bboxCorners = getUniqueCorners(bboxOverlap);
        for (let i = 0, iMax = bboxCorners.length; i < iMax; i++) {
          const point = bboxCorners[i];
          // test if this point is an intersection
          if (
            (this.isAnEndpoint(point) && other.isPointOn(point)) ||
            (other.isAnEndpoint(point) && this.isPointOn(point))
          ) {
            intersections.push(point);
          }
        }
        if (intersections.length > 0) return intersections

        // General case for non-overlapping segments.
        // This algorithm is based on Schneider and Eberly.
        // http://www.cimec.org.ar/~ncalvo/Schneider_Eberly.pdf - pg 244
        const al = this.leftSE.point;
        const bl = other.leftSE.point;
        const va = this.vector;
        const vb = other.vector;
        const ve = { x: bl.x - al.x, y: bl.y - al.y };
        const kross = crossProduct(va, vb);

        // not on line segment a
        const s = crossProduct(ve, vb) / kross;
        if (cmp(s, 0) < 0 || cmp(1, s) < 0) return []

        const t = crossProduct(ve, va) / kross;
        if (cmp(t, 0) < 0 || cmp(1, t) < 0) return []

        // intersection is in a midpoint of both lines, let's average them and
        // bound the result by org bbox (otherwise leftSE and rightSE could swap)
        let x = (al.x + s * va.x + bl.x + t * vb.x) / 2;
        let y = (al.y + s * va.y + bl.y + t * vb.y) / 2;
        if (x < bboxOverlap.ll.x) x = bboxOverlap.ll.x;
        if (x > bboxOverlap.ur.x) x = bboxOverlap.ur.x;
        if (y < bboxOverlap.ll.y) y = bboxOverlap.ll.y;
        if (y > bboxOverlap.ur.y) y = bboxOverlap.ur.y;
        return [{ x: x, y: y }]
      }

      /**
       * Split the given segment into multiple segments on the given points.
       *  * The existing segment will retain it's leftSE and a new rightSE will be
       *    generated for it.
       *  * A new segment will be generated which will adopt the original segment's
       *    rightSE, and a new leftSE will be generated for it.
       *  * If there are more than two points given to split on, new segments
       *    in the middle will be generated with new leftSE and rightSE's.
       *  * An array of the newly generated SweepEvents will be returned.
       */
      split (points) {
        // sort them and unique-ify them
        points.sort(cmpPoints);
        points = points.filter(
          (pt, i, pts) => i === 0 || cmpPoints(pts[i - 1], pt) !== 0
        );

        for (let i = 0, iMax = points.length; i < iMax; i++) {
          const pt = points[i];
          if (this.isAnEndpoint(pt)) {
            throw new Error(
              `Cannot split segment upon endpoint at [${pt.x}, ${pt.y}]`
            )
          }
        }

        const point = points.shift();
        const newSeg = this.clone();
        newSeg.leftSE = new SweepEvent(point, newSeg);
        newSeg.rightSE = this.rightSE;
        this.rightSE.segment = newSeg;
        this.rightSE = new SweepEvent(point, this);
        const newEvents = [this.rightSE, newSeg.leftSE];

        if (points.length > 0) {
          const moreNewEvents = newSeg.split(points);
          for (let i = 0, iMax = moreNewEvents.length; i < iMax; i++) {
            newEvents.push(moreNewEvents[i]);
          }
        }
        return newEvents
      }

      registerPrev (other) {
        this.prev = other;
        this._clearCache();
      }

      registerRingOut (ring) {
        this.ringOut = ring;
      }

      /* The first segment previous segment chain that is in the result */
      get prevInResult () {
        const key = 'prevInResult';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _prevInResult () {
        let prev = this.prev;
        while (prev && !prev.isInResult) prev = prev.prev;
        return prev
      }

      /* The segments, including ourselves, for which we overlap perfectly */
      get coincidents () {
        const key = 'coincidents';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _coincidents () {
        // a coincident will have both left and right sweepEvents linked with us
        const coincidents = [];
        const leftLinkedEvents = this.leftSE.linkedEvents;
        const rightLinkedEvents = this.rightSE.linkedEvents;
        for (let i = 0, iMax = leftLinkedEvents.length; i < iMax; i++) {
          const leftSE = leftLinkedEvents[i];
          if (!leftSE.isLeft) continue
          if (leftSE.segment.rightSE.linkedEvents !== rightLinkedEvents) continue
          coincidents.push(leftSE.segment);
        }

        if (coincidents.length > 0) {
          // put the 'winner' at the front
          // arbitary - winner is the one with lowest ringId
          coincidents.sort((a, b) => a.ringIn.id - b.ringIn.id);

          // set this in all our coincident's caches so they don't have to calc it
          for (let i = 0, iMax = coincidents.length; i < iMax; i++) {
            coincidents[i]._cache['coincidents'] = coincidents;
          }
        }
        return coincidents
      }

      get prevNotCoincident () {
        const key = 'prevNotCoincident';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _prevNotCoincident () {
        // iterating backwards from next to prev
        let next = this;
        let prev = this.prev;
        while (prev && next.coincidents === prev.coincidents) {
          next = prev;
          prev = prev.prev;
        }
        return prev
      }

      /* Does the sweep line, when it intersects this segment, enter the ring? */
      get sweepLineEntersRing () {
        const key = 'sweepLineEntersRing';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _sweepLineEntersRing () {
        // opposite of previous segment on the same ring
        let prev = this.prevNotCoincident;
        while (prev) {
          for (let i = 0, iMax = prev.coincidents.length; i < iMax; i++) {
            const seg = prev.coincidents[i];
            if (seg.ringIn === this.ringIn) return !seg.sweepLineEntersRing
          }
          prev = prev.prevNotCoincident;
        }
        return true
      }

      /* Does the sweep line, when it intersects this segment, enter the polygon? */
      get sweepLineEntersPoly () {
        if (!this.isValidEdgeForPoly) return false
        return this.ringIn.isExterior === this.sweepLineEntersRing
      }

      /* Does the sweep line, when it intersects this segment, exit the polygon? */
      get sweepLineExitsPoly () {
        if (!this.isValidEdgeForPoly) return false
        return this.ringIn.isExterior !== this.sweepLineEntersRing
      }

      /* Array of input rings this segment is inside of (not on boundary) */
      get ringsInsideOf () {
        const key = 'ringsInsideOf';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _ringsInsideOf () {
        if (!this.prev) return []

        // coincidents always share the same rings. Return same array to save mem
        if (this.coincidents === this.prev.coincidents) {
          return this.prev.ringsInsideOf
        }

        let rings = [];
        let prevRingsInsideOf = this.prev.ringsInsideOf;
        let prevRingsEntering = this.prev.getRingsEntering();
        let ringsExiting = this.getRingsExiting();

        // rings our prev was inside of all count, except those we're exiting
        for (let i = 0, iMax = prevRingsInsideOf.length; i < iMax; i++) {
          const ring = prevRingsInsideOf[i];
          if (!ringsExiting.includes(ring)) rings.push(ring);
        }

        // rings our prev was entering of all count, except those we're exiting
        for (let i = 0, iMax = prevRingsEntering.length; i < iMax; i++) {
          const ring = prevRingsEntering[i];
          if (!ringsExiting.includes(ring)) rings.push(ring);
        }

        return rings
      }

      /* Array of input rings this segment is on boundary of */
      getRingsOnEdgeOf () {
        const rings = [];
        for (let i = 0, iMax = this.coincidents.length; i < iMax; i++) {
          rings.push(this.coincidents[i].ringIn);
        }
        return rings
      }

      /* Array of input rings this segment is on boundary of,
       * and for which the sweep line enters when intersecting there */
      getRingsEntering () {
        const rings = [];
        for (let i = 0, iMax = this.coincidents.length; i < iMax; i++) {
          const segment = this.coincidents[i];
          if (!segment.sweepLineEntersRing) continue
          rings.push(segment.ringIn);
        }
        return rings
      }

      /* Array of input rings this segment is on boundary of,
       * and for which the sweep line exits when intersecting there */
      getRingsExiting () {
        const rings = [];
        for (let i = 0, iMax = this.coincidents.length; i < iMax; i++) {
          const segment = this.coincidents[i];
          if (segment.sweepLineEntersRing) continue
          rings.push(segment.ringIn);
        }
        return rings
      }

      /* Is this segment valid on our own polygon? (ie not outside exterior ring) */
      get isValidEdgeForPoly () {
        const key = 'isValidEdgeForPoly';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _isValidEdgeForPoly () {
        // SLER: sweep line entering orientation
        let sameSLER;
        let diffSLER;
        if (this.sweepLineEntersRing) {
          sameSLER = this.getRingsEntering();
          diffSLER = this.getRingsExiting();
        } else {
          diffSLER = this.getRingsEntering();
          sameSLER = this.getRingsExiting();
        }
        return this.ringIn.isValid(sameSLER, diffSLER, this.ringsInsideOf)
      }

      /* Array of multipolys this segment is inside of */
      getMultiPolysInsideOf () {
        const mps = [];
        for (let i = 0, iMax = this.ringsInsideOf.length; i < iMax; i++) {
          const poly = this.ringsInsideOf[i].poly;
          if (mps.includes(poly.multiPoly)) continue
          if (!poly.isInside(this.getRingsOnEdgeOf(), this.ringsInsideOf)) continue
          mps.push(poly.multiPoly);
        }
        return mps
      }

      /* The multipolys on one side of us */
      getMultiPolysSLPEnters (multiPolysInsideOf) {
        // start with the multipolys we're fully inside
        const mps = multiPolysInsideOf.slice();
        // add the multipolys we have the sweep line entering
        for (let i = 0, iMax = this.coincidents.length; i < iMax; i++) {
          const seg = this.coincidents[i];
          if (!seg.sweepLineEntersPoly) continue
          const mp = seg.ringIn.poly.multiPoly;
          if (!mps.includes(mp)) mps.push(mp);
        }
        return mps
      }

      /* The multipolys on the other side of us */
      getMultiPolysSLPExits (multiPolysInsideOf) {
        // start with the multipolys we're fully inside
        const mps = multiPolysInsideOf.slice();
        // add the multipolys we have the sweep line entering
        for (let i = 0, iMax = this.coincidents.length; i < iMax; i++) {
          const seg = this.coincidents[i];
          if (!seg.sweepLineExitsPoly) continue
          const mp = seg.ringIn.poly.multiPoly;
          if (!mps.includes(mp)) mps.push(mp);
        }
        return mps
      }

      /* Is this segment part of the final result? */
      get isInResult () {
        const key = 'isInResult';
        if (this._cache[key] === undefined) this._cache[key] = this[`_${key}`]();
        return this._cache[key]
      }

      _isInResult () {
        // if it's not the coincidence winner, it's not in the resul
        if (this !== this.coincidents[0]) return false

        const multiPolysInsideOf = this.getMultiPolysInsideOf();
        const multiPolysSLPEnters = this.getMultiPolysSLPEnters(multiPolysInsideOf);
        const multiPolysSLPExits = this.getMultiPolysSLPExits(multiPolysInsideOf);

        switch (operation.type) {
          case operation.types.UNION:
            // UNION - included iff:
            //  * On one side of us there is 0 poly interiors AND
            //  * On the other side there is 1 or more.
            const noEnters = multiPolysSLPEnters.length === 0;
            const noExits = multiPolysSLPExits.length === 0;
            return noEnters !== noExits

          case operation.types.INTERSECTION:
            // INTERSECTION - included iff:
            //  * on one side of us all multipolys are rep. with poly interiors AND
            //  * on the other side of us, not all multipolys are repsented
            //    with poly interiors
            let least;
            let most;
            if (multiPolysSLPEnters.length < multiPolysSLPExits.length) {
              least = multiPolysSLPEnters.length;
              most = multiPolysSLPExits.length;
            } else {
              least = multiPolysSLPExits.length;
              most = multiPolysSLPEnters.length;
            }
            return most === operation.numMultiPolys && least < most

          case operation.types.XOR:
            // XOR - included iff:
            //  * the difference between the number of multipolys represented
            //    with poly interiors on our two sides is an odd number
            const diff = Math.abs(
              multiPolysSLPEnters.length - multiPolysSLPExits.length
            );
            return diff % 2 === 1

          case operation.types.DIFFERENCE:
            // DIFFERENCE included iff:
            //  * on exactly one side, we have just the subject
            const isJustSubject = mps => mps.length === 1 && mps[0].isSubject;
            return (
              isJustSubject(multiPolysSLPEnters) !==
              isJustSubject(multiPolysSLPExits)
            )

          default:
            throw new Error(`Unrecognized operation type found ${operation.type}`)
        }
      }

      _clearCache () {
        this._cache = {};
      }
    }

    // Give rings unique ID's to get consistent sorting of segments
    // and sweep events when all else is identical
    let ringId = 0;

    class Ring {
      constructor (geomRing, poly) {
        this.id = ringId++;
        this.poly = poly;
        this.segments = [];

        for (let i = 1, iMax = geomRing.length; i < iMax; i++) {
          this.segments.push(new Segment(geomRing[i - 1], geomRing[i], this));
        }
      }

      getSweepEvents () {
        const sweepEvents = [];
        for (let i = 0, iMax = this.segments.length; i < iMax; i++) {
          const segment = this.segments[i];
          sweepEvents.push(segment.leftSE);
          sweepEvents.push(segment.rightSE);
        }
        return sweepEvents
      }

      get isExterior () {
        return this.poly.exteriorRing === this
      }

      get isInterior () {
        return this.poly.exteriorRing !== this
      }

      /* Given a segment on this rings with these relationships to other rings,
       * is it a valid segment of the ring's poly? */
      isValid (ringsSameSLER, ringsDiffSLER, ringsInsideOf) {
        const exterior = this.poly.exteriorRing;
        const interiors = this.poly.interiorRings;

        if (this === exterior) {
          // exterior segments inside or interior, nope
          for (let i = 0, iMax = ringsInsideOf.length; i < iMax; i++) {
            if (interiors.includes(ringsInsideOf[i])) return false
          }

          // overlap with an interior of same SWL orientatio, nope
          for (let i = 0, iMax = ringsSameSLER.length; i < iMax; i++) {
            if (interiors.includes(ringsSameSLER[i])) return false
          }

          return true
        }

        // interior rings that aren't inside the exterior nor
        // overlapping with different SWE
        if (!ringsInsideOf.includes(exterior)) {
          if (!ringsDiffSLER.includes(exterior)) return false
        }

        // interior rings inside another interior, nope
        for (let i = 0, iMax = ringsInsideOf.length; i < iMax; i++) {
          if (interiors.includes(ringsInsideOf[i])) return false
        }

        // overlapping interiors with different sweep line orientation, nope
        for (let i = 0, iMax = ringsDiffSLER.length; i < iMax; i++) {
          if (interiors.includes(ringsDiffSLER[i])) return false
        }

        return true
      }
    }

    class Poly {
      constructor (geomPoly, multiPoly) {
        this.exteriorRing = new Ring(geomPoly[0], this);
        this.interiorRings = [];
        for (let i = 1, iMax = geomPoly.length; i < iMax; i++) {
          this.interiorRings.push(new Ring(geomPoly[i], this));
        }
        this.multiPoly = multiPoly;
      }

      getSweepEvents () {
        const sweepEvents = this.exteriorRing.getSweepEvents();
        for (let i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
          const ringSweepEvents = this.interiorRings[i].getSweepEvents();
          for (let j = 0, jMax = ringSweepEvents.length; j < jMax; j++) {
            sweepEvents.push(ringSweepEvents[j]);
          }
        }
        return sweepEvents
      }

      /* Given a segment with these rings, is that segment inside this polygon? */
      isInside (ringsOnEdgeOf, ringsInsideOf) {
        // if we're on an edge, we can't be inside
        for (let i = 0, iMax = ringsOnEdgeOf.length; i < iMax; i++) {
          if (ringsOnEdgeOf[i].poly === this) return false
        }

        // we need to be inside the exterior, and nothing else
        let isInsideExterior = false;
        for (let i = 0, iMax = ringsInsideOf.length; i < iMax; i++) {
          const ring = ringsInsideOf[i];
          if (ring.poly !== this) continue
          if (ring.isInterior) return false
          isInsideExterior = true;
        }
        return isInsideExterior
      }
    }

    class MultiPoly {
      constructor (geomMultiPoly) {
        this.polys = [];
        for (let i = 0, iMax = geomMultiPoly.length; i < iMax; i++) {
          this.polys.push(new Poly(geomMultiPoly[i], this));
        }
        this.isSubject = false;
      }

      markAsSubject () {
        this.isSubject = true;
      }

      getSweepEvents () {
        const sweepEvents = [];
        for (let i = 0, iMax = this.polys.length; i < iMax; i++) {
          const polySweepEvents = this.polys[i].getSweepEvents();
          for (let j = 0, jMax = polySweepEvents.length; j < jMax; j++) {
            sweepEvents.push(polySweepEvents[j]);
          }
        }
        return sweepEvents
      }
    }

    class Ring$1 {
      /* Given the segments from the sweep line pass, compute & return a series
       * of closed rings from all the segments marked to be part of the result */
      static factory (allSegments) {
        const ringsOut = [];

        for (let i = 0, iMax = allSegments.length; i < iMax; i++) {
          const segment = allSegments[i];
          if (!segment.isInResult || segment.ringOut) continue

          let prevEvent = null;
          let event = segment.leftSE;
          let nextEvent = segment.rightSE;
          const events = [event];

          const startingLE = event.linkedEvents;
          const intersectionLEs = [];

          /* Walk the chain of linked events to form a closed ring */
          while (true) {
            prevEvent = event;
            event = nextEvent;
            events.push(event);

            /* Is the ring complete? */
            if (event.linkedEvents === startingLE) break

            while (true) {
              const availableLEs = event.getAvailableLinkedEvents();

              /* Did we hit a dead end? This shouldn't happen. Indicates some earlier
               * part of the algorithm malfunctioned... please file a bug report. */
              if (availableLEs.length === 0) {
                const firstPt = events[0].point;
                const lastPt = events[events.length - 1].point;
                throw new Error(
                  `Unable to complete output ring starting at [${firstPt.x},` +
                    ` ${firstPt.y}]. Last matching segment found ends at ` +
                    ` [${lastPt.x}, ${lastPt.y}].`
                )
              }

              /* Only one way to go, so cotinue on the path */
              if (availableLEs.length === 1) {
                nextEvent = availableLEs[0].otherSE;
                break
              }

              /* We must have an intersection. Check for a completed loop */
              let indexLE = null;
              for (let j = 0, jMax = intersectionLEs.length; j < jMax; j++) {
                if (intersectionLEs[j].linkedEvents === event.linkedEvents) {
                  indexLE = j;
                  break
                }
              }
              /* Found a completed loop. Cut that off and make a ring */
              if (indexLE !== null) {
                const intersectionLE = intersectionLEs.splice(indexLE)[0];
                const ringEvents = events.splice(intersectionLE.index);
                ringEvents.unshift(ringEvents[0].otherSE);
                ringsOut.push(new Ring$1(ringEvents.reverse()));
                continue
              }
              /* register the intersection */
              intersectionLEs.push({
                index: events.length,
                linkedEvents: event.linkedEvents
              });
              /* Choose the left-most option to continue the walk */
              const comparator = event.getLeftmostComparator(prevEvent);
              nextEvent = availableLEs.sort(comparator)[0].otherSE;
              break
            }
          }

          ringsOut.push(new Ring$1(events));
        }
        return ringsOut
      }

      constructor (events) {
        this.events = events;
        for (let i = 0, iMax = events.length; i < iMax; i++) {
          events[i].segment.registerRingOut(this);
        }
        this.poly = null;
        this._clearCache();
      }

      registerPoly (poly) {
        this.poly = poly;
      }

      getGeom () {
        // Remove superfluous points (ie extra points along a straight line),
        const points = [[this.events[0].point.x, this.events[0].point.y]];
        for (let i = 1, iMax = this.events.length - 1; i < iMax; i++) {
          const prevPt = this.events[i - 1].point;
          const pt = this.events[i].point;
          const nextPt = this.events[i + 1].point;
          if (compareVectorAngles(pt, prevPt, nextPt) === 0) continue
          points.push([pt.x, pt.y]);
        }

        // check if the starting point is necessary
        const prevPt = this.events[this.events.length - 2].point;
        const pt = this.events[0].point;
        const nextPt = this.events[1].point;
        if (compareVectorAngles(pt, prevPt, nextPt) === 0) points.shift();

        // ring was all (within rounding error of angle calc) colinear points
        if (points.length === 0) return null

        points.push(points[0]);
        return this.isExteriorRing ? points : points.reverse()
      }

      get enclosingRing () {
        return this._getCached('enclosingRing')
      }

      get isExteriorRing () {
        return this._getCached('isExteriorRing')
      }

      _clearCache () {
        this._cache = {};
      }

      _getCached (propName, calcMethod) {
        // if this._cache[something] isn't set, fill it with this._something()
        if (this._cache[propName] === undefined) {
          this._cache[propName] = this[`_${propName}`].bind(this)();
        }
        return this._cache[propName]
      }

      _isExteriorRing () {
        if (!this.enclosingRing) return true
        if (!this.enclosingRing.enclosingRing) return false
        // an island in hole is a whole new polygon
        return this.enclosingRing.enclosingRing.isExteriorRing
      }

      /* Returns the ring that encloses this one, if any */
      _enclosingRing () {
        let prevSeg = this.events[0].segment.prevInResult;
        while (prevSeg && prevSeg.ringOut === this) prevSeg = prevSeg.prevInResult;
        let prevPrevSeg = prevSeg ? prevSeg.prevInResult : null;

        while (true) {
          // no segment found, thus no ring can enclose us
          if (!prevSeg) return null

          // no segments below prev segment found, thus the ring of the prev
          // segment must loop back around and enclose us
          if (!prevPrevSeg) return prevSeg.ringOut

          // if the two segments are of different rings, the ring of the prev
          // segment must either loop around us or the ring of the prev prev
          // seg, which would make us and the ring of the prev peers
          if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
            if (prevPrevSeg.ringOut.enclosingRing !== prevSeg.ringOut) {
              return prevSeg.ringOut
            } else return prevSeg.ringOut.enclosingRing
          }

          // two segments are from the same ring, so this was a penisula
          // of that ring. iterate downward, keep searching
          prevSeg = prevPrevSeg.prevInResult;
          prevPrevSeg = prevSeg ? prevSeg.prevInResult : null;
        }
      }
    }

    class Poly$1 {
      constructor (exteriorRing) {
        this.exteriorRing = exteriorRing;
        exteriorRing.registerPoly(this);
        this.interiorRings = [];
      }

      addInterior (ring) {
        this.interiorRings.push(ring);
        ring.registerPoly(this);
      }

      getGeom () {
        const geom = [this.exteriorRing.getGeom()];
        // exterior ring was all (within rounding error of angle calc) colinear points
        if (geom[0] === null) return null
        for (let i = 0, iMax = this.interiorRings.length; i < iMax; i++) {
          const ringGeom = this.interiorRings[i].getGeom();
          // interior ring was all (within rounding error of angle calc) colinear points
          if (ringGeom === null) continue
          geom.push(ringGeom);
        }
        return geom
      }
    }

    class MultiPoly$1 {
      constructor (rings) {
        this.rings = rings;
        this.polys = this._composePolys(rings);
      }

      getGeom () {
        const geom = [];
        for (let i = 0, iMax = this.polys.length; i < iMax; i++) {
          const polyGeom = this.polys[i].getGeom();
          // exterior ring was all (within rounding error of angle calc) colinear points
          if (polyGeom === null) continue
          geom.push(polyGeom);
        }
        return geom
      }

      _composePolys (rings) {
        const polys = [];
        for (let i = 0, iMax = rings.length; i < iMax; i++) {
          const ring = rings[i];
          if (ring.poly) continue
          if (ring.isExteriorRing) polys.push(new Poly$1(ring));
          else {
            if (!ring.enclosingRing.poly) polys.push(new Poly$1(ring.enclosingRing));
            ring.enclosingRing.poly.addInterior(ring);
          }
        }
        return polys
      }
    }

    /* follows "An implementation of top-down splaying"
     * by D. Sleator <sleator@cs.cmu.edu> March 1992
     */

    /**
     * @typedef {*} Key
     */


    /**
     * @typedef {*} Value
     */


    /**
     * @typedef {function(node:Node):void} Visitor
     */


    /**
     * @typedef {function(a:Key, b:Key):number} Comparator
     */


    /**
     * @param {function(node:Node):string} NodePrinter
     */


    /**
     * @typedef {Object}  Node
     * @property {Key}    Key
     * @property {Value=} data
     * @property {Node}   left
     * @property {Node}   right
     */

    class Node {

      constructor (key, data) {
        this.key    = key;
        this.data   = data;
        this.left   = null;
        this.right  = null;
      }
    }

    function DEFAULT_COMPARE (a, b) { return a > b ? 1 : a < b ? -1 : 0; }


    /**
     * Simple top down splay, not requiring i to be in the tree t.
     * @param {Key} i
     * @param {Node?} t
     * @param {Comparator} comparator
     */
    function splay (i, t, comparator) {
      if (t === null) return t;
      let l, r, y;
      const N = new Node();
      l = r = N;

      while (true) {
        const cmp = comparator(i, t.key);
        //if (i < t.key) {
        if (cmp < 0) {
          if (t.left === null) break;
          //if (i < t.left.key) {
          if (comparator(i, t.left.key) < 0) {
            y = t.left;                           /* rotate right */
            t.left = y.right;
            y.right = t;
            t = y;
            if (t.left === null) break;
          }
          r.left = t;                               /* link right */
          r = t;
          t = t.left;
        //} else if (i > t.key) {
        } else if (cmp > 0) {
          if (t.right === null) break;
          //if (i > t.right.key) {
          if (comparator(i, t.right.key) > 0) {
            y = t.right;                          /* rotate left */
            t.right = y.left;
            y.left = t;
            t = y;
            if (t.right === null) break;
          }
          l.right = t;                              /* link left */
          l = t;
          t = t.right;
        } else {
          break;
        }
      }
      /* assemble */
      l.right = t.left;
      r.left = t.right;
      t.left = N.right;
      t.right = N.left;
      return t;
    }


    /**
     * @param  {Key}        i
     * @param  {Value}      data
     * @param  {Comparator} comparator
     * @param  {Tree}       tree
     * @return {Node}      root
     */
    function insert (i, data, t, comparator, tree) {
      const node = new Node(i, data);

      tree._size++;

      if (t === null) {
        node.left = node.right = null;
        return node;
      }

      t = splay(i, t, comparator);
      const cmp = comparator(i, t.key);
      if (cmp < 0) {
        node.left = t.left;
        node.right = t;
        t.left = null;
      } else if (cmp >= 0) {
        node.right = t.right;
        node.left = t;
        t.right = null;
      }
      return node;
    }


    /**
     * Insert i into the tree t, unless it's already there.
     * @param  {Key}        i
     * @param  {Value}      data
     * @param  {Comparator} comparator
     * @param  {Tree}       tree
     * @return {Node}       root
     */
    function add (i, data, t, comparator, tree) {
      const node = new Node(i, data);

      if (t === null) {
        node.left = node.right = null;
        tree._size++;
        return node;
      }

      t = splay(i, t, comparator);
      const cmp = comparator(i, t.key);
      if (cmp === 0) return t;
      else {
        if (cmp < 0) {
          node.left = t.left;
          node.right = t;
          t.left = null;
        } else if (cmp > 0) {
          node.right = t.right;
          node.left = t;
          t.right = null;
        }
        tree._size++;
        return node;
      }
    }


    /**
     * Deletes i from the tree if it's there
     * @param {Key}        i
     * @param {Tree}       tree
     * @param {Comparator} comparator
     * @param {Tree}       tree
     * @return {Node}      new root
     */
    function remove (i, t, comparator, tree) {
      let x;
      if (t === null) return null;
      t = splay(i, t, comparator);
      if (i === t.key) {               /* found it */
        if (t.left === null) {
          x = t.right;
        } else {
          x = splay(i, t.left, comparator);
          x.right = t.right;
        }
        tree._size--;
        return x;
      }
      return t;                         /* It wasn't there */
    }


    function split (key, v, comparator) {
      let left, right;
      if (v === null) {
        left = right = null;
      } else {
        v = splay(key, v, comparator);

        const cmp = comparator(v.key, key);
        if (cmp === 0) {
          left  = v.left;
          right = v.right;
        } else if (cmp < 0) {
          right   = v.right;
          v.right = null;
          left    = v;
        } else {
          left   = v.left;
          v.left = null;
          right  = v;
        }
      }
      return { left, right };
    }


    function merge (left, right, comparator) {
      if (right === null) return left;
      if (left  === null) return right;

      right = splay(left.key, right, comparator);
      right.left = left;
      return right;
    }


    /**
     * Prints level of the tree
     * @param  {Node}                        root
     * @param  {String}                      prefix
     * @param  {Boolean}                     isTail
     * @param  {Array<string>}               out
     * @param  {Function(node:Node):String}  printNode
     */
    function printRow (root, prefix, isTail, out, printNode) {
      if (root) {
        out(`${ prefix }${ isTail ? '└── ' : '├── ' }${ printNode(root) }\n`);
        const indent = prefix + (isTail ? '    ' : '│   ');
        if (root.left)  printRow(root.left,  indent, false, out, printNode);
        if (root.right) printRow(root.right, indent, true,  out, printNode);
      }
    }


    class Tree {

      constructor (comparator = DEFAULT_COMPARE) {
        this._comparator = comparator;
        this._root = null;
        this._size = 0;
      }


      /**
       * Inserts a key, allows duplicates
       * @param  {Key}    key
       * @param  {Value=} data
       * @return {Node|null}
       */
      insert (key, data) {
        return this._root = insert(key, data, this._root, this._comparator, this);
      }


      /**
       * Adds a key, if it is not present in the tree
       * @param  {Key}    key
       * @param  {Value=} data
       * @return {Node|null}
       */
      add (key, data) {
        return this._root = add(key, data, this._root, this._comparator, this);
      }


      /**
       * @param  {Key} key
       * @return {Node|null}
       */
      remove (key) {
        this._root = remove(key, this._root, this._comparator, this);
      }


      /**
       * Removes and returns the node with smallest key
       * @return {?Node}
       */
      pop () {
        let node = this._root;
        if (node) {
          while (node.left) node = node.left;
          this._root = splay(node.key,  this._root, this._comparator);
          this._root = remove(node.key, this._root, this._comparator, this);
          return { key: node.key, data: node.data };
        }
        return null;
      }


      /**
       * @param  {Key} key
       * @return {Node|null}
       */
      findStatic (key) {
        let current   = this._root;
        const compare = this._comparator;
        while (current) {
          const cmp = compare(key, current.key);
          if (cmp === 0)    return current;
          else if (cmp < 0) current = current.left;
          else              current = current.right;
        }
        return null;
      }


      /**
       * @param  {Key} key
       * @return {Node|null}
       */
      find (key) {
        if (this._root) {
          this._root = splay(key, this._root, this._comparator);
          if (this._comparator(key, this._root.key) !== 0) return null;
        }
        return this._root;
      }


      /**
       * @param  {Key} key
       * @return {Boolean}
       */
      contains (key) {
        let current   = this._root;
        const compare = this._comparator;
        while (current) {
          const cmp = compare(key, current.key);
          if (cmp === 0)    return true;
          else if (cmp < 0) current = current.left;
          else              current = current.right;
        }
        return false;
      }


      /**
       * @param  {Visitor} visitor
       * @param  {*=}      ctx
       * @return {SplayTree}
       */
      forEach (visitor, ctx) {
        let current = this._root;
        const Q = [];  /* Initialize stack s */
        let done = false;

        while (!done) {
          if (current !==  null) {
            Q.push(current);
            current = current.left;
          } else {
            if (Q.length !== 0) {
              current = Q.pop();
              visitor.call(ctx, current);

              current = current.right;
            } else done = true;
          }
        }
        return this;
      }


      /**
       * Walk key range from `low` to `high`. Stops if `fn` returns a value.
       * @param  {Key}      low
       * @param  {Key}      high
       * @param  {Function} fn
       * @param  {*?}       ctx
       * @return {SplayTree}
       */
      range (low, high, fn, ctx) {
        const Q = [];
        const compare = this._comparator;
        let node = this._root, cmp;

        while (Q.length !== 0 || node) {
          if (node) {
            Q.push(node);
            node = node.left;
          } else {
            node = Q.pop();
            cmp = compare(node.key, high);
            if (cmp > 0) {
              break;
            } else if (compare(node.key, low) >= 0) {
              if (fn.call(ctx, node)) return this; // stop if smth is returned
            }
            node = node.right;
          }
        }
        return this;
      }


      /**
       * Returns array of keys
       * @return {Array<Key>}
       */
      keys () {
        const keys = [];
        this.forEach(({ key }) => keys.push(key));
        return keys;
      }


      /**
       * Returns array of all the data in the nodes
       * @return {Array<Value>}
       */
      values () {
        const values = [];
        this.forEach(({ data }) => values.push(data));
        return values;
      }


      /**
       * @return {Key|null}
       */
      min() {
        if (this._root) return this.minNode(this._root).key;
        return null;
      }


      /**
       * @return {Key|null}
       */
      max() {
        if (this._root) return this.maxNode(this._root).key;
        return null;
      }


      /**
       * @return {Node|null}
       */
      minNode(t = this._root) {
        if (t) while (t.left) t = t.left;
        return t;
      }


      /**
       * @return {Node|null}
       */
      maxNode(t = this._root) {
        if (t) while (t.right) t = t.right;
        return t;
      }


      /**
       * Returns node at given index
       * @param  {number} index
       * @return {?Node}
       */
      at (index) {
        let current = this._root, done = false, i = 0;
        const Q = [];

        while (!done) {
          if (current) {
            Q.push(current);
            current = current.left;
          } else {
            if (Q.length > 0) {
              current = Q.pop();
              if (i === index) return current;
              i++;
              current = current.right;
            } else done = true;
          }
        }
        return null;
      }


      /**
       * @param  {Node}   d
       * @return {Node|null}
       */
      next (d) {
        let root = this._root;
        let successor = null;

        if (d.right) {
          successor = d.right;
          while (successor.left) successor = successor.left;
          return successor;
        }

        const comparator = this._comparator;
        while (root) {
          const cmp = comparator(d.key, root.key);
          if (cmp === 0) break;
          else if (cmp < 0) {
            successor = root;
            root = root.left;
          } else root = root.right;
        }

        return successor;
      }


      /**
       * @param  {Node} d
       * @return {Node|null}
       */
      prev (d) {
        let root = this._root;
        let predecessor = null;

        if (d.left !== null) {
          predecessor = d.left;
          while (predecessor.right) predecessor = predecessor.right;
          return predecessor;
        }

        const comparator = this._comparator;
        while (root) {
          const cmp = comparator(d.key, root.key);
          if (cmp === 0) break;
          else if (cmp < 0) root = root.left;
          else {
            predecessor = root;
            root = root.right;
          }
        }
        return predecessor;
      }


      /**
       * @return {SplayTree}
       */
      clear() {
        this._root = null;
        this._size = 0;
        return this;
      }


      /**
       * @return {NodeList}
       */
      toList() {
        return toList(this._root);
      }


      /**
       * Bulk-load items. Both array have to be same size
       * @param  {Array<Key>}    keys
       * @param  {Array<Value>}  [values]
       * @param  {Boolean}       [presort=false] Pre-sort keys and values, using
       *                                         tree's comparator. Sorting is done
       *                                         in-place
       * @return {AVLTree}
       */
      load (keys = [], values = [], presort = false) {
        let size = keys.length;
        const comparator = this._comparator;

        // sort if needed
        if (presort) sort(keys, values, 0, size - 1, comparator);

        if (this._root === null) { // empty tree
          this._root = loadRecursive(this._root, keys, values, 0, size);
          this._size = size;
        } else { // that re-builds the whole tree from two in-order traversals
          const mergedList = mergeLists(this.toList(), createList(keys, values), comparator);
          size = this._size + size;
          this._root = sortedListToBST({ head: mergedList }, 0, size);
        }
        return this;
      }


      /**
       * @return {Boolean}
       */
      isEmpty() { return this._root === null; }

      get size () { return this._size; }


      /**
       * @param  {NodePrinter=} printNode
       * @return {String}
       */
      toString (printNode = (n) => n.key) {
        const out = [];
        printRow(this._root, '', true, (v) => out.push(v), printNode);
        return out.join('');
      }


      update (key, newKey, newData) {
        const comparator = this._comparator;
        let { left, right } = split(key, this._root, comparator);
        this._size--;
        if (comparator(key, newKey) < 0) {
          right = insert(newKey, newData, right, comparator, this);
        } else {
          left = insert(newKey, newData, left, comparator, this);
        }
        this._root = merge(left, right, comparator);
      }


      split(key) {
        return split(key, this._root, this._comparator);
      }
    }


    function loadRecursive (parent, keys, values, start, end) {
      const size = end - start;
      if (size > 0) {
        const middle = start + Math.floor(size / 2);
        const key    = keys[middle];
        const data   = values[middle];
        const node   = { key, data, parent };
        node.left    = loadRecursive(node, keys, values, start, middle);
        node.right   = loadRecursive(node, keys, values, middle + 1, end);
        return node;
      }
      return null;
    }


    function createList(keys, values) {
      const head = { next: null };
      let p = head;
      for (let i = 0; i < keys.length; i++) {
        p = p.next = { key: keys[i], data: values[i] };
      }
      p.next = null;
      return head.next;
    }


    function toList (root) {
      var current = root;
      var Q = [], done = false;

      const head = { next: null };
      let p = head;

      while (!done) {
        if (current) {
          Q.push(current);
          current = current.left;
        } else {
          if (Q.length > 0) {
            current = p = p.next = Q.pop();
            current = current.right;
          } else done = true;
        }
      }
      p.next = null; // that'll work even if the tree was empty
      return head.next;
    }


    function sortedListToBST(list, start, end) {
      const size = end - start;
      if (size > 0) {
        const middle = start + Math.floor(size / 2);
        const left = sortedListToBST(list, start, middle);

        const root = list.head;
        root.left = left;

        list.head = list.head.next;

        root.right = sortedListToBST(list, middle + 1, end);
        return root;
      }
      return null;
    }


    function mergeLists (l1, l2, compare = (a, b) => a - b) {
      const head = {}; // dummy
      let p = head;

      let p1 = l1;
      let p2 = l2;

      while (p1 !== null && p2 !== null) {
        if (compare(p1.key, p2.key) < 0) {
          p.next = p1;
          p1 = p1.next;
        } else {
          p.next = p2;
          p2 = p2.next;
        }
        p = p.next;
      }

      if (p1 !== null)      p.next = p1;
      else if (p2 !== null) p.next = p2;

      return head.next;
    }


    function sort(keys, values, left, right, compare) {
      if (left >= right) return;

      const pivot = keys[(left + right) >> 1];
      let i = left - 1;
      let j = right + 1;

      while (true) {
        do i++; while (compare(keys[i], pivot) < 0);
        do j--; while (compare(keys[j], pivot) > 0);
        if (i >= j) break;

        let tmp = keys[i];
        keys[i] = keys[j];
        keys[j] = tmp;

        tmp = values[i];
        values[i] = values[j];
        values[j] = tmp;
      }

      sort(keys, values,  left,     j, compare);
      sort(keys, values, j + 1, right, compare);
    }

    /**
     * NOTE:  We must be careful not to change any segments while
     *        they are in the SplayTree. AFAIK, there's no way to tell
     *        the tree to rebalance itself - thus before splitting
     *        a segment that's in the tree, we remove it from the tree,
     *        do the split, then re-insert it. (Even though splitting a
     *        segment *shouldn't* change its correct position in the
     *        sweep line tree, the reality is because of rounding errors,
     *        it sometimes does.)
     */

    class SweepLine {
      constructor (comparator = Segment.compare) {
        this.tree = new Tree(comparator);
        this.segments = [];
        this.prevEvent = null;
      }

      process (event) {
        const segment = event.segment;
        const newEvents = [];
        const node = event.isLeft
          ? this.tree.insert(segment)
          : this.tree.find(segment);

        const prevNode = this.tree.prev(node);
        const prevSeg = prevNode ? prevNode.key : null;

        const nextNode = this.tree.next(node);
        const nextSeg = nextNode ? nextNode.key : null;

        if (event.isLeft) {
          const mySplitters = [];

          // Check for intersections against the previous segment in the sweep line
          if (prevSeg) {
            const prevInters = prevSeg.getIntersections(segment);
            if (prevInters.length > 0) {
              const newEventsFromSplit = this._possibleSplit(prevSeg, prevInters);
              for (let i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
                newEvents.push(newEventsFromSplit[i]);
              }
              for (let i = 0, iMax = prevInters.length; i < iMax; i++) {
                const pt = prevInters[i];
                if (!segment.isAnEndpoint(pt)) mySplitters.push(pt);
              }
            }
          }

          // Check for intersections against the next segment in the sweep line
          if (nextSeg) {
            const nextInters = nextSeg.getIntersections(segment);
            if (nextInters.length > 0) {
              const newEventsFromSplit = this._possibleSplit(nextSeg, nextInters);
              for (let i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
                newEvents.push(newEventsFromSplit[i]);
              }
              for (let i = 0, iMax = nextInters.length; i < iMax; i++) {
                const pt = nextInters[i];
                if (!segment.isAnEndpoint(pt)) mySplitters.push(pt);
              }
            }
          }

          // did we get some intersections?
          if (newEvents.length > 0 || mySplitters.length > 0) {
            this.tree.remove(segment);

            if (mySplitters.length > 0) {
              const newEventsFromSplit = segment.split(mySplitters);
              for (let i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
                newEvents.push(newEventsFromSplit[i]);
              }
            }

            // Make sure sweep line ordering is totally consistent for later
            // use with the segment 'prev' pointers - re-do the current event.
            newEvents.push(event);
            return newEvents
          }

          this.segments.push(segment);
          segment.registerPrev(prevSeg);
        } else {
          // event.isRight

          // since we're about to be removed from the sweep line, check for
          // intersections between our previous and next segments
          if (prevSeg && nextSeg) {
            const inters = prevSeg.getIntersections(nextSeg);
            if (inters.length > 0) {
              let newEventsFromSplit = this._possibleSplit(prevSeg, inters);
              for (let i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
                newEvents.push(newEventsFromSplit[i]);
              }
              newEventsFromSplit = this._possibleSplit(nextSeg, inters);
              for (let i = 0, iMax = newEventsFromSplit.length; i < iMax; i++) {
                newEvents.push(newEventsFromSplit[i]);
              }
            }
          }

          this.tree.remove(segment);
        }

        if (this.prevEvent && cmpPoints(this.prevEvent.point, event.point) === 0) {
          this.prevEvent.link(event);
        }
        this.prevEvent = event;

        return newEvents
      }

      _possibleSplit (segment, intersections) {
        const splitters = [];
        for (let i = 0, iMax = intersections.length; i < iMax; i++) {
          const pt = intersections[i];
          if (!segment.isAnEndpoint(pt)) splitters.push(pt);
        }

        let newEvents;
        if (splitters.length > 0) {
          this.tree.remove(segment);
          newEvents = segment.split(splitters);
          this.tree.insert(segment);
        } else newEvents = [];
        return newEvents
      }
    }

    function doIt (operationType, geom, moreGeoms) {
      /* Make a copy of the input geometry with points as objects, for perf */
      const geoms = [pointsAsObjects(geom)];
      for (let i = 0, iMax = moreGeoms.length; i < iMax; i++) {
        geoms.push(pointsAsObjects(moreGeoms[i]));
      }

      /* Clean inputs */
      for (let i = 0, iMax = geoms.length; i < iMax; i++) {
        forceMultiPoly(geoms[i]);
        cleanMultiPoly(geoms[i]);
      }

      /* Convert inputs to MultiPoly objects, mark subject & register operation */
      const multipolys = [];
      for (let i = 0, iMax = geoms.length; i < iMax; i++) {
        multipolys.push(new MultiPoly(geoms[i]));
      }
      multipolys[0].markAsSubject();
      operation.register(operationType, multipolys.length);

      /* Put segment endpoints in a priority queue */
      const queue = new qheap$2({ comparBefore: SweepEvent.compareBefore });
      for (let i = 0, iMax = multipolys.length; i < iMax; i++) {
        const sweepEvents = multipolys[i].getSweepEvents();
        for (let j = 0, jMax = sweepEvents.length; j < jMax; j++) {
          queue.insert(sweepEvents[j]);
        }
      }

      /* Pass the sweep line over those endpoints */
      const sweepLine = new SweepLine();
      while (queue.length) {
        const newEvents = sweepLine.process(queue.remove());
        for (let i = 0, iMax = newEvents.length; i < iMax; i++) {
          queue.insert(newEvents[i]);
        }
      }

      /* Error on self-crossing input rings */
      errorOnSelfIntersectingRings(sweepLine.segments);

      /* Collect and compile segments we're keeping into a multipolygon */
      const ringsOut = Ring$1.factory(sweepLine.segments);
      const result = new MultiPoly$1(ringsOut);
      return result.getGeom()
    }

    const union = (geom, ...moreGeoms) => {
      return doIt(operation.types.UNION, geom, moreGeoms)
    };

    const intersection = (geom, ...moreGeoms) => {
      return doIt(operation.types.INTERSECTION, geom, moreGeoms)
    };

    const difference = (subjectGeom, ...clippingGeoms) => {
      return doIt(operation.types.DIFFERENCE, subjectGeom, clippingGeoms)
    };

    /**
     * Takes two or more {@link Polygon|polygons} and returns a combined polygon. If the input polygons are not contiguous, this function returns a {@link MultiPolygon} feature.
     *
     * @name union
     * @param {Feature<Polygon|MultiPolygon>} fc a FeatureCollection containting polygons or multipolygons to union
     * @returns {Feature<(Polygon|MultiPolygon)>} a combined {@link Polygon} or {@link MultiPolygon} feature
     * @example
     * var poly1 = turf.polygon([[
     *     [-82.574787, 35.594087],
     *     [-82.574787, 35.615581],
     *     [-82.545261, 35.615581],
     *     [-82.545261, 35.594087],
     *     [-82.574787, 35.594087]
     * ]], {"fill": "#0f0"});
     * var poly2 = turf.polygon([[
     *     [-82.560024, 35.585153],
     *     [-82.560024, 35.602602],
     *     [-82.52964, 35.602602],
     *     [-82.52964, 35.585153],
     *     [-82.560024, 35.585153]
     * ]], {"fill": "#00f"});
     *
     * var union = turf.union(poly1, poly2);
     *
     * //addToMap
     * var addToMap = [poly1, poly2, union];
     */
    function union$1(fc) {

        const args = [];
        geomEach(fc, function (geom) {
            if (geom.type === 'Polygon') args.push(geom.coordinates);
            else geom.coordinates.forEach(function (contour) {
                args.push(contour);
            });
        });
        var unioned = union(args);
        if (unioned.length === 0) return null;
        else return multiPolygon(unioned);
    }

    /**
     * Dissolves a FeatureCollection of {@link polygon} features, filtered by an optional property name:value.
     * Note that {@link mulitpolygon} features within the collection are not supported
     *
     * @name dissolve
     * @param {FeatureCollection<Polygon>} fc input feature collection to be dissolved
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.propertyName] features with equals 'propertyName' in `properties` will be merged
     * @returns {FeatureCollection<Polygon>} a FeatureCollection containing the dissolved polygons
     * @example
     * var features = turf.featureCollection([
     *   turf.polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]], {combine: 'yes'}),
     *   turf.polygon([[[0, -1], [0, 0], [1, 0], [1, -1], [0,-1]]], {combine: 'yes'}),
     *   turf.polygon([[[1,-1],[1, 0], [2, 0], [2, -1], [1, -1]]], {combine: 'no'}),
     * ]);
     *
     * var dissolved = turf.dissolve(features, {propertyName: 'combine'});
     *
     * //addToMap
     * var addToMap = [features, dissolved]
     */
    function dissolve(fc, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var propertyName = options.propertyName;

        // Input validation
        collectionOf(fc, 'Polygon', 'dissolve');

        // Main
        const outFeatures = [];
        if (options.propertyName === null) {
            return union$1(fc);
        } else {
            let uniquePropertyVals = {};
            featureEach(fc, function (feature$$1) {
                if (!uniquePropertyVals.hasOwnProperty(feature$$1.properties[propertyName])) {
                    uniquePropertyVals[feature$$1.properties[propertyName]] = [];
                }
                uniquePropertyVals[feature$$1.properties[propertyName]].push(feature$$1);
            });
            var vals = Object.keys(uniquePropertyVals);
            for (var i = 0; i < vals.length; i++) {
                outFeatures.push(union$1(featureCollection(uniquePropertyVals[vals[i]])));
            }
        }

        return featureCollection(outFeatures);
    }

    /**
     * Takes a set of {@link Point|points} and returns a concave hull Polygon or MultiPolygon.
     * Internally, this uses [turf-tin](https://github.com/Turfjs/turf-tin) to generate geometries.
     * We also recommend checking out [concaveman](https://github.com/mapbox/concaveman) for a more performant
     * solution although it does not offer a maxEdge setting.
     *
     * @name concave
     * @param {FeatureCollection<Point>} points input points
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.maxEdge=Infinity] the length (in 'units') of an edge necessary for part of the
     * hull to become concave.
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
     * @returns {Feature<(Polygon|MultiPolygon)>|null} a concave hull (null value is returned if unable to compute hull)
     * @example
     * var points = turf.featureCollection([
     *   turf.point([-63.601226, 44.642643]),
     *   turf.point([-63.591442, 44.651436]),
     *   turf.point([-63.580799, 44.648749]),
     *   turf.point([-63.573589, 44.641788]),
     *   turf.point([-63.587665, 44.64533]),
     *   turf.point([-63.595218, 44.64765])
     * ]);
     * var options = {units: 'miles', maxEdge: 1};
     *
     * var hull = turf.concave(points, options);
     *
     * //addToMap
     * var addToMap = [points, hull]
     */
    function concave(points$$1, options) {
        options = checkIfOptionsExist(options);

        const maxEdge = options.maxEdge || Infinity;

        const cleaned = removeDuplicates(points$$1);

        const tinPolys = tin(cleaned);
        // calculate length of all edges and area of all triangles
        // and remove triangles that fail the max length test
        tinPolys.features = tinPolys.features.filter((triangle) => {
            const pt1 = triangle.geometry.coordinates[0][0];
            const pt2 = triangle.geometry.coordinates[0][1];
            const pt3 = triangle.geometry.coordinates[0][2];
            const dist1 = distance(pt1, pt2, options);
            const dist2 = distance(pt2, pt3, options);
            const dist3 = distance(pt1, pt3, options);
            return (dist1 <= maxEdge && dist2 <= maxEdge && dist3 <= maxEdge);
        });

        if (tinPolys.features.length < 1) { return null; }

        // merge the adjacent triangles
        return dissolve(tinPolys);
    }

    /**
     * Removes duplicated points in a collection returning a new collection
     *
     * @private
     * @param {FeatureCollection<Point>} points to be cleaned
     * @returns {FeatureCollection<Point>} cleaned set of points
     */
    function removeDuplicates(points$$1) {
        const cleaned = [];
        const existing = {};

        featureEach(points$$1, (pt) => {
            if (!pt.geometry) { return; }
            const key = pt.geometry.coordinates.join("-");
            if (!existing.hasOwnProperty(key)) {
                cleaned.push(pt);
                existing[key] = true;
            }
        });
        return featureCollection(cleaned);
    }

    /**
     * Merges a specified property from a FeatureCollection of points into a
     * FeatureCollection of polygons. Given an `inProperty` on points and an `outProperty`
     * for polygons, this finds every point that lies within each polygon, collects the
     * `inProperty` values from those points, and adds them as an array to `outProperty`
     * on the polygon.
     *
     * @name collect
     * @param {FeatureCollection<Polygon>} polygons polygons with values on which to aggregate
     * @param {FeatureCollection<Point>} points points to be aggregated
     * @param {string} inProperty property to be nested from
     * @param {string} outProperty property to be nested into
     * @returns {FeatureCollection<Polygon>} polygons with properties listed based on `outField`
     * @example
     * var poly1 = turf.polygon([[[0,0],[10,0],[10,10],[0,10],[0,0]]]);
     * var poly2 = turf.polygon([[[10,0],[20,10],[20,20],[20,0],[10,0]]]);
     * var polyFC = turf.featureCollection([poly1, poly2]);
     * var pt1 = turf.point([5,5], {population: 200});
     * var pt2 = turf.point([1,3], {population: 600});
     * var pt3 = turf.point([14,2], {population: 100});
     * var pt4 = turf.point([13,1], {population: 200});
     * var pt5 = turf.point([19,7], {population: 300});
     * var pointFC = turf.featureCollection([pt1, pt2, pt3, pt4, pt5]);
     * var collected = turf.collect(polyFC, pointFC, 'population', 'values');
     * var values = collected.features[0].properties.values
     * //=values => [200, 600]
     *
     * //addToMap
     * var addToMap = [pointFC, collected]
     */
    function collect(polygons, points, inProperty, outProperty) {
        var rtree = rbush_1(6);

        var treeItems = points.features.map(function (item) {
            return {
                minX: item.geometry.coordinates[0],
                minY: item.geometry.coordinates[1],
                maxX: item.geometry.coordinates[0],
                maxY: item.geometry.coordinates[1],
                property: item.properties[inProperty]
            };
        });

        rtree.load(treeItems);
        polygons.features.forEach(function (poly) {

            if (!poly.properties) {
                poly.properties = {};
            }
            var bbox$$1 = bbox(poly);
            var potentialPoints = rtree.search({minX: bbox$$1[0], minY: bbox$$1[1], maxX: bbox$$1[2], maxY: bbox$$1[3]});
            var values = [];
            potentialPoints.forEach(function (pt) {
                if (booleanPointInPolygon([pt.minX, pt.minY], poly)) {
                    values.push(pt.property);
                }
            });

            poly.properties[outProperty] = values;
        });

        return polygons;
    }

    /**
     * Returns a cloned copy of the passed GeoJSON Object, including possible 'Foreign Members'.
     * ~3-5x faster than the common JSON.parse + JSON.stringify combo method.
     *
     * @name clone
     * @param {GeoJSON} geojson GeoJSON Object
     * @returns {GeoJSON} cloned GeoJSON Object
     * @example
     * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]], {color: 'red'});
     *
     * var lineCloned = turf.clone(line);
     */
    function clone(geojson) {
        if (!geojson) { throw new Error('geojson is required'); }

        switch (geojson.type) {
        case 'Feature':
            return cloneFeature(geojson);
        case 'FeatureCollection':
            return cloneFeatureCollection(geojson);
        case 'Point':
        case 'LineString':
        case 'Polygon':
        case 'MultiPoint':
        case 'MultiLineString':
        case 'MultiPolygon':
        case 'GeometryCollection':
            return cloneGeometry(geojson);
        default:
            throw new Error('unknown GeoJSON type');
        }
    }

    /**
     * Clone Feature
     *
     * @private
     * @param {Feature<any>} geojson GeoJSON Feature
     * @returns {Feature<any>} cloned Feature
     */
    function cloneFeature(geojson) {
        const cloned = {type: 'Feature'};
        // Preserve Foreign Members
        Object.keys(geojson).forEach(function (key) {
            switch (key) {
            case 'type':
            case 'properties':
            case 'geometry':
                return;
            default:
                cloned[key] = geojson[key];
            }
        });
        // Add properties & geometry last
        cloned.properties = cloneProperties(geojson.properties);
        cloned.geometry = cloneGeometry(geojson.geometry);
        return cloned;
    }

    /**
     * Clone Properties
     *
     * @private
     * @param {Object} properties GeoJSON Properties
     * @returns {Object} cloned Properties
     */
    function cloneProperties(properties) {
        const cloned = {};
        if (!properties) { return cloned; }
        Object.keys(properties).forEach(function (key) {
            const value = properties[key];
            if (typeof value === 'object') {
                if (value === null) {
                    // handle null
                    cloned[key] = null;
                } else if (Array.isArray(value)) {
                    // handle Array
                    cloned[key] = value.map(function (item) {
                        return item;
                    });
                } else {
                    // handle generic Object
                    cloned[key] = cloneProperties(value);
                }
            } else { cloned[key] = value; }
        });
        return cloned;
    }

    /**
     * Clone Feature Collection
     *
     * @private
     * @param {FeatureCollection<any>} geojson GeoJSON Feature Collection
     * @returns {FeatureCollection<any>} cloned Feature Collection
     */
    function cloneFeatureCollection(geojson) {
        const cloned = {type: 'FeatureCollection'};

        // Preserve Foreign Members
        Object.keys(geojson).forEach(function (key) {
            switch (key) {
            case 'type':
            case 'features':
                return;
            default:
                cloned[key] = geojson[key];
            }
        });
        // Add features
        cloned.features = geojson.features.map(function (feature) {
            return cloneFeature(feature);
        });
        return cloned;
    }

    /**
     * Clone Geometry
     *
     * @private
     * @param {Geometry<any>} geometry GeoJSON Geometry
     * @returns {Geometry<any>} cloned Geometry
     */
    function cloneGeometry(geometry) {
        const geom = {type: geometry.type};
        if (geometry.bbox) { geom.bbox = geometry.bbox; }

        if (geometry.type === 'GeometryCollection') {
            geom.geometries = geometry.geometries.map(function (g) {
                return cloneGeometry(g);
            });
            return geom;
        }
        geom.coordinates = deepSlice(geometry.coordinates);
        return geom;
    }

    /**
     * Deep Slice coordinates
     *
     * @private
     * @param {Coordinates} coords Coordinates
     * @returns {Coordinates} all coordinates sliced
     */
    function deepSlice(coords) {
        const cloned = coords;
        if (typeof cloned[0] !== 'object') { return cloned.slice(); }
        return cloned.map(function (coord) {
            return deepSlice(coord);
        });
    }

    /**
     * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.
     *
     * @name flip
     * @param {GeoJSON} geojson input features
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates
     * @example
     * var serbia = turf.point([20.566406, 43.421008]);
     *
     * var saudiArabia = turf.flip(serbia);
     *
     * //addToMap
     * var addToMap = [serbia, saudiArabia];
     */
    function flip(geojson, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var mutate = options.mutate;

        if (!geojson) throw new Error('geojson is required');
        // ensure that we don't modify features in-place and changes to the
        // output do not change the previous feature, including changes to nested
        // properties.
        if (mutate === false || mutate === undefined) geojson = clone(geojson);

        coordEach(geojson, function (coord) {
            var x = coord[0];
            var y = coord[1];
            coord[0] = y;
            coord[1] = x;
        });
        return geojson;
    }

    // To-Do => Improve Typescript GeoJSON handling

    /**
     * Removes redundant coordinates from any GeoJSON Geometry.
     *
     * @name cleanCoords
     * @param {Geometry|Feature} geojson Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated
     * @returns {Geometry|Feature} the cleaned input Feature/Geometry
     * @example
     * var line = turf.lineString([[0, 0], [0, 2], [0, 5], [0, 8], [0, 8], [0, 10]]);
     * var multiPoint = turf.multiPoint([[0, 0], [0, 0], [2, 2]]);
     *
     * turf.cleanCoords(line).geometry.coordinates;
     * //= [[0, 0], [0, 10]]
     *
     * turf.cleanCoords(multiPoint).geometry.coordinates;
     * //= [[0, 0], [2, 2]]
     */
    function cleanCoords(geojson, options) {
        options = checkIfOptionsExist(options);
        // Backwards compatible with v4.0
         var mutate = (typeof options === 'object') ? options.mutate : options;
        if (!geojson) throw new Error('geojson is required');
        var type = getType(geojson);

        // Store new "clean" points in this Array
        var newCoords = [];

        switch (type) {
        case 'LineString':
            newCoords = cleanLine(geojson);
            break;
        case 'MultiLineString':
        case 'Polygon':
            getCoords(geojson).forEach(function (line) {
                newCoords.push(cleanLine(line));
            });
            break;
        case 'MultiPolygon':
            getCoords(geojson).forEach(function (polygons$$1) {
                var polyPoints = [];
                polygons$$1.forEach(function (ring) {
                    polyPoints.push(cleanLine(ring));
                });
                newCoords.push(polyPoints);
            });
            break;
        case 'Point':
            return geojson;
        case 'MultiPoint':
            var existing = {};
            getCoords(geojson).forEach(function (coord) {
                var key = coord.join('-');
                if (!existing.hasOwnProperty(key)) {
                    newCoords.push(coord);
                    existing[key] = true;
                }
            });
            break;
        default:
            throw new Error(type + ' geometry not supported');
        }

        // Support input mutation
        if (geojson.coordinates) {
            if (mutate === true) {
                geojson.coordinates = newCoords;
                return geojson;
            }
            return {type: type, coordinates: newCoords};
        } else {
            if (mutate === true) {
                geojson.geometry.coordinates = newCoords;
                return geojson;
            }
            return feature({type: type, coordinates: newCoords}, geojson.properties, {bbox: geojson.bbox, id: geojson.id});
        }
    }

    /**
     * Clean Coords
     *
     * @private
     * @param {Array<number>|LineString} line Line
     * @returns {Array<number>} Cleaned coordinates
     */
    function cleanLine(line) {

        var points$$1 = getCoords(line);
        // handle "clean" segment
        if (points$$1.length === 2 && !equals(points$$1[0], points$$1[1])) return points$$1;

        var newPoints = [];
        var secondToLast = points$$1.length - 1;
        var newPointsLength = newPoints.length;

        newPoints.push(points$$1[0]);
        for (var i = 1; i < secondToLast; i++) {
            var prevAddedPoint = newPoints[newPoints.length - 1];
            if ((points$$1[i][0] === prevAddedPoint[0]) && (points$$1[i][1] === prevAddedPoint[1])) continue;
            else {
                newPoints.push(points$$1[i]);
                newPointsLength = newPoints.length;
                if (newPointsLength > 2) {
                    if (isPointOnLineSegment(newPoints[newPointsLength - 3], newPoints[newPointsLength - 1], newPoints[newPointsLength - 2])) newPoints.splice(newPoints.length - 2, 1);
                }
            }
        }
        newPoints.push(points$$1[points$$1.length - 1]);

        newPointsLength = newPoints.length;
        if (equals(points$$1[0], points$$1[points$$1.length - 1]) && newPointsLength < 4) throw new Error('invalid polygon');
        if (isPointOnLineSegment(newPoints[newPointsLength - 3], newPoints[newPointsLength - 1], newPoints[newPointsLength - 2])) newPoints.splice(newPoints.length - 2, 1);

        return newPoints;
    }

    /**
     * Compares two points and returns if they are equals
     *
     * @private
     * @param {Position} pt1 point
     * @param {Position} pt2 point
     * @returns {boolean} true if they are equals
     */
    function equals(pt1, pt2) {
        return pt1[0] === pt2[0] && pt1[1] === pt2[1];
    }

    /**
     * Returns if `point` is on the segment between `start` and `end`.
     * Borrowed from `@turf/boolean-point-on-line` to speed up the evaluation (instead of using the module as dependency)
     *
     * @private
     * @param {Position} start coord pair of start of line
     * @param {Position} end coord pair of end of line
     * @param {Position} point coord pair of point to check
     * @returns {boolean} true/false
     */
    function isPointOnLineSegment(start, end, point$$1) {
        var x = point$$1[0], y = point$$1[1];
        var startX = start[0], startY = start[1];
        var endX = end[0], endY = end[1];

        var dxc = x - startX;
        var dyc = y - startY;
        var dxl = endX - startX;
        var dyl = endY - startY;
        var cross = dxc * dyl - dyc * dxl;

        if (cross !== 0) return false;
        else if (Math.abs(dxl) >= Math.abs(dyl)) return dxl > 0 ? startX <= x && x <= endX : endX <= x && x <= startX;
        else return dyl > 0 ? startY <= y && y <= endY : endY <= y && y <= startY;
    }

    /*
     (c) 2013, Vladimir Agafonkin
     Simplify.js, a high-performance JS polyline simplification library
     mourner.github.io/simplify-js
    */

    // to suit your point format, run search/replace for '.x' and '.y';
    // for 3D version, see 3d branch (configurability would draw significant performance overhead)

    // square distance between 2 points
    function getSqDist$1(p1, p2) {

        var dx = p1.x - p2.x,
            dy = p1.y - p2.y;

        return dx * dx + dy * dy;
    }

    // square distance from a point to a segment
    function getSqSegDist(p, p1, p2) {

        var x = p1.x,
            y = p1.y,
            dx = p2.x - x,
            dy = p2.y - y;

        if (dx !== 0 || dy !== 0) {

            var t = ((p.x - x) * dx + (p.y - y) * dy) / (dx * dx + dy * dy);

            if (t > 1) {
                x = p2.x;
                y = p2.y;

            } else if (t > 0) {
                x += dx * t;
                y += dy * t;
            }
        }

        dx = p.x - x;
        dy = p.y - y;

        return dx * dx + dy * dy;
    }
    // rest of the code doesn't care about point format

    // basic distance-based simplification
    function simplifyRadialDist(points, sqTolerance) {

        var prevPoint = points[0],
            newPoints = [prevPoint],
            point;

        for (var i = 1, len = points.length; i < len; i++) {
            point = points[i];

            if (getSqDist$1(point, prevPoint) > sqTolerance) {
                newPoints.push(point);
                prevPoint = point;
            }
        }

        if (prevPoint !== point) newPoints.push(point);

        return newPoints;
    }

    function simplifyDPStep(points, first, last, sqTolerance, simplified) {
        var maxSqDist = sqTolerance,
            index;

        for (var i = first + 1; i < last; i++) {
            var sqDist = getSqSegDist(points[i], points[first], points[last]);

            if (sqDist > maxSqDist) {
                index = i;
                maxSqDist = sqDist;
            }
        }

        if (maxSqDist > sqTolerance) {
            if (index - first > 1) simplifyDPStep(points, first, index, sqTolerance, simplified);
            simplified.push(points[index]);
            if (last - index > 1) simplifyDPStep(points, index, last, sqTolerance, simplified);
        }
    }

    // simplification using Ramer-Douglas-Peucker algorithm
    function simplifyDouglasPeucker(points, sqTolerance) {
        var last = points.length - 1;

        var simplified = [points[0]];
        simplifyDPStep(points, 0, last, sqTolerance, simplified);
        simplified.push(points[last]);

        return simplified;
    }

    // both algorithms combined for awesome performance
    function simplify(points, tolerance, highestQuality) {

        if (points.length <= 2) return points;

        var sqTolerance = tolerance !== undefined ? tolerance * tolerance : 1;

        points = highestQuality ? points : simplifyRadialDist(points, sqTolerance);
        points = simplifyDouglasPeucker(points, sqTolerance);

        return points;
    }

    /**
     * Takes a {@link GeoJSON} object and returns a simplified version. Internally uses
     * [simplify-js](http://mourner.github.io/simplify-js/) to perform simplification using the Ramer-Douglas-Peucker algorithm.
     *
     * @name simplify
     * @param {GeoJSON} geojson object to be simplified
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.tolerance=1] simplification tolerance
     * @param {boolean} [options.highQuality=false] whether or not to spend more time to create a higher-quality simplification with a different algorithm
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} a simplified GeoJSON
     * @example
     * var geojson = turf.polygon([[
     *   [-70.603637, -33.399918],
     *   [-70.614624, -33.395332],
     *   [-70.639343, -33.392466],
     *   [-70.659942, -33.394759],
     *   [-70.683975, -33.404504],
     *   [-70.697021, -33.419406],
     *   [-70.701141, -33.434306],
     *   [-70.700454, -33.446339],
     *   [-70.694274, -33.458369],
     *   [-70.682601, -33.465816],
     *   [-70.668869, -33.472117],
     *   [-70.646209, -33.473835],
     *   [-70.624923, -33.472117],
     *   [-70.609817, -33.468107],
     *   [-70.595397, -33.458369],
     *   [-70.587158, -33.442901],
     *   [-70.587158, -33.426283],
     *   [-70.590591, -33.414248],
     *   [-70.594711, -33.406224],
     *   [-70.603637, -33.399918]
     * ]]);
     * var options = {tolerance: 0.01, highQuality: false};
     * var simplified = turf.simplify(geojson, options);
     *
     * //addToMap
     * var addToMap = [geojson, simplified]
     */
    function simplify$1(geojson, options) {
        // Optional parameters
        options = checkIfOptionsExist(options);
        var tolerance = options.tolerance !== undefined ? options.tolerance : 1;
        var highQuality = options.highQuality || false;
        var mutate = options.mutate || false;

        if (!geojson) throw new Error('geojson is required');
        if (tolerance && tolerance < 0) throw new Error('invalid tolerance');

        // Clone geojson to avoid side effects
        if (mutate !== true) geojson = clone(geojson);

        geomEach(geojson, function (geom) {
            simplifyGeom(geom, tolerance, highQuality);
        });
        return geojson;
    }

    /**
     * Simplifies a feature's coordinates
     *
     * @private
     * @param {Geometry} geometry to be simplified
     * @param {number} [tolerance=1] simplification tolerance
     * @param {boolean} [highQuality=false] whether or not to spend more time to create a higher-quality simplification with a different algorithm
     * @returns {Geometry} output
     */
    function simplifyGeom(geometry$$1, tolerance, highQuality) {
        var type = geometry$$1.type;

        // "unsimplyfiable" geometry types
        if (type === 'Point' || type === 'MultiPoint') return geometry$$1;

        // Remove any extra coordinates
        cleanCoords(geometry$$1, {mutate: true});

        var coordinates = geometry$$1.coordinates;
        switch (type) {
        case 'LineString':
            geometry$$1['coordinates'] = simplifyLine(coordinates, tolerance, highQuality);
            break;
        case 'MultiLineString':
            geometry$$1['coordinates'] = coordinates.map(function (lines) {
                return simplifyLine(lines, tolerance, highQuality);
            });
            break;
        case 'Polygon':
            geometry$$1['coordinates'] = simplifyPolygon(coordinates, tolerance, highQuality);
            break;
        case 'MultiPolygon':
            geometry$$1['coordinates'] = coordinates.map(function (rings) {
                return simplifyPolygon(rings, tolerance, highQuality);
            });
        }
        return geometry$$1;
    }


    /**
     * Simplifies the coordinates of a LineString with simplify-js
     *
     * @private
     * @param {Array<number>} coordinates to be processed
     * @param {number} tolerance simplification tolerance
     * @param {boolean} highQuality whether or not to spend more time to create a higher-quality
     * @returns {Array<Array<number>>} simplified coords
     */
    function simplifyLine(coordinates, tolerance, highQuality) {
        return simplify(coordinates.map(function (coord) {
            return {x: coord[0], y: coord[1], z: coord[2]};
        }), tolerance, highQuality).map(function (coords) {
            return (coords.z) ? [coords.x, coords.y, coords.z] : [coords.x, coords.y];
        });
    }


    /**
     * Simplifies the coordinates of a Polygon with simplify-js
     *
     * @private
     * @param {Array<number>} coordinates to be processed
     * @param {number} tolerance simplification tolerance
     * @param {boolean} highQuality whether or not to spend more time to create a higher-quality
     * @returns {Array<Array<Array<number>>>} simplified coords
     */
    function simplifyPolygon(coordinates, tolerance, highQuality) {
        return coordinates.map(function (ring) {
            var pts = ring.map(function (coord) {
                return {x: coord[0], y: coord[1]};
            });
            if (pts.length < 4) {
                throw new Error('invalid polygon');
            }
            var simpleRing = simplify(pts, tolerance, highQuality).map(function (coords) {
                return [coords.x, coords.y];
            });
            //remove 1 percent of tolerance until enough points to make a triangle
            while (!checkValidity(simpleRing)) {
                tolerance -= tolerance * 0.01;
                simpleRing = simplify(pts, tolerance, highQuality).map(function (coords) {
                    return [coords.x, coords.y];
                });
            }
            if (
                (simpleRing[simpleRing.length - 1][0] !== simpleRing[0][0]) ||
                (simpleRing[simpleRing.length - 1][1] !== simpleRing[0][1])) {
                simpleRing.push(simpleRing[0]);
            }
            return simpleRing;
        });
    }


    /**
     * Returns true if ring has at least 3 coordinates and its first coordinate is the same as its last
     *
     * @private
     * @param {Array<number>} ring coordinates to be checked
     * @returns {boolean} true if valid
     */
    function checkValidity(ring) {
        if (ring.length < 3) return false;
        //if the last point is the same as the first, it's not a triangle
        return !(ring.length === 3 && ((ring[2][0] === ring[0][0]) && (ring[2][1] === ring[0][1])));
    }

    var spline = createCommonjsModule(function (module, exports) {
    exports.__esModule = true;
    /**
     * BezierSpline
     * https://github.com/leszekr/bezier-spline-js
     *
     * @private
     * @copyright
     * Copyright (c) 2013 Leszek Rybicki
     *
     * Permission is hereby granted, free of charge, to any person obtaining a copy
     * of this software and associated documentation files (the "Software"), to deal
     * in the Software without restriction, including without limitation the rights
     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
     * copies of the Software, and to permit persons to whom the Software is
     * furnished to do so, subject to the following conditions:
     *
     * The above copyright notice and this permission notice shall be included in all
     * copies or substantial portions of the Software.
     *
     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
     * SOFTWARE.
     */
    var Spline = /** @class */ (function () {
        function Spline(options) {
            this.points = options.points || [];
            this.duration = options.duration || 10000;
            this.sharpness = options.sharpness || 0.85;
            this.centers = [];
            this.controls = [];
            this.stepLength = options.stepLength || 60;
            this.length = this.points.length;
            this.delay = 0;
            // this is to ensure compatibility with the 2d version
            for (var i = 0; i < this.length; i++) {
                this.points[i].z = this.points[i].z || 0;
            }
            for (var i = 0; i < this.length - 1; i++) {
                var p1 = this.points[i];
                var p2 = this.points[i + 1];
                this.centers.push({
                    x: (p1.x + p2.x) / 2,
                    y: (p1.y + p2.y) / 2,
                    z: (p1.z + p2.z) / 2
                });
            }
            this.controls.push([this.points[0], this.points[0]]);
            for (var i = 0; i < this.centers.length - 1; i++) {
                var p1 = this.centers[i];
                var p2 = this.centers[i + 1];
                var dx = this.points[i + 1].x - (this.centers[i].x + this.centers[i + 1].x) / 2;
                var dy = this.points[i + 1].y - (this.centers[i].y + this.centers[i + 1].y) / 2;
                var dz = this.points[i + 1].z - (this.centers[i].y + this.centers[i + 1].z) / 2;
                this.controls.push([{
                        x: (1.0 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i].x + dx),
                        y: (1.0 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i].y + dy),
                        z: (1.0 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i].z + dz)
                    },
                    {
                        x: (1.0 - this.sharpness) * this.points[i + 1].x + this.sharpness * (this.centers[i + 1].x + dx),
                        y: (1.0 - this.sharpness) * this.points[i + 1].y + this.sharpness * (this.centers[i + 1].y + dy),
                        z: (1.0 - this.sharpness) * this.points[i + 1].z + this.sharpness * (this.centers[i + 1].z + dz)
                    }]);
            }
            this.controls.push([this.points[this.length - 1], this.points[this.length - 1]]);
            this.steps = this.cacheSteps(this.stepLength);
            return this;
        }
        /**
         * Caches an array of equidistant (more or less) points on the curve.
         */
        Spline.prototype.cacheSteps = function (mindist) {
            var steps = [];
            var laststep = this.pos(0);
            steps.push(0);
            for (var t = 0; t < this.duration; t += 10) {
                var step = this.pos(t);
                var dist = Math.sqrt((step.x - laststep.x) * (step.x - laststep.x) +
                    (step.y - laststep.y) * (step.y - laststep.y) +
                    (step.z - laststep.z) * (step.z - laststep.z));
                if (dist > mindist) {
                    steps.push(t);
                    laststep = step;
                }
            }
            return steps;
        };
        /**
         * returns angle and speed in the given point in the curve
         */
        Spline.prototype.vector = function (t) {
            var p1 = this.pos(t + 10);
            var p2 = this.pos(t - 10);
            return {
                angle: 180 * Math.atan2(p1.y - p2.y, p1.x - p2.x) / 3.14,
                speed: Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) +
                    (p2.y - p1.y) * (p2.y - p1.y) +
                    (p2.z - p1.z) * (p2.z - p1.z))
            };
        };
        /**
         * Gets the position of the point, given time.
         *
         * WARNING: The speed is not constant. The time it takes between control points is constant.
         *
         * For constant speed, use Spline.steps[i];
         */
        Spline.prototype.pos = function (time) {
            var t = time - this.delay;
            if (t < 0) {
                t = 0;
            }
            if (t > this.duration) {
                t = this.duration - 1;
            }
            // t = t-this.delay;
            var t2 = (t) / this.duration;
            if (t2 >= 1) {
                return this.points[this.length - 1];
            }
            var n = Math.floor((this.points.length - 1) * t2);
            var t1 = (this.length - 1) * t2 - n;
            return bezier(t1, this.points[n], this.controls[n][1], this.controls[n + 1][0], this.points[n + 1]);
        };
        return Spline;
    }());
    exports["default"] = Spline;
    function bezier(t, p1, c1, c2, p2) {
        var b = B(t);
        var pos = {
            x: p2.x * b[0] + c2.x * b[1] + c1.x * b[2] + p1.x * b[3],
            y: p2.y * b[0] + c2.y * b[1] + c1.y * b[2] + p1.y * b[3],
            z: p2.z * b[0] + c2.z * b[1] + c1.z * b[2] + p1.z * b[3]
        };
        return pos;
    }
    function B(t) {
        var t2 = t * t;
        var t3 = t2 * t;
        return [(t3), (3 * t2 * (1 - t)), (3 * t * (1 - t) * (1 - t)), ((1 - t) * (1 - t) * (1 - t))];
    }
    });

    var Spline = unwrapExports(spline);

    /**
     * Takes a {@link LineString|line} and returns a curved version
     * by applying a [Bezier spline](http://en.wikipedia.org/wiki/B%C3%A9zier_spline)
     * algorithm.
     *
     * The bezier spline implementation is by [Leszek Rybicki](http://leszek.rybicki.cc/).
     *
     * @name bezierSpline
     * @param {Feature<LineString>} line input LineString
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] Translate properties to output
     * @param {number} [options.resolution=10000] time in milliseconds between points
     * @param {number} [options.sharpness=0.85] a measure of how curvy the path should be between splines
     * @returns {Feature<LineString>} curved line
     * @example
     * var line = turf.lineString([
     *   [-76.091308, 18.427501],
     *   [-76.695556, 18.729501],
     *   [-76.552734, 19.40443],
     *   [-74.61914, 19.134789],
     *   [-73.652343, 20.07657],
     *   [-73.157958, 20.210656]
     * ]);
     *
     * var curved = turf.bezierSpline(line);
     *
     * //addToMap
     * var addToMap = [line, curved]
     * curved.properties = { stroke: '#0F0' };
     */
    function bezier(line, options) {
        options = checkIfOptionsExist(options);
        // Optional params
        const resolution = options.resolution || 10000;
        const sharpness = options.sharpness || 0.85;

        const coords = [];
        const points$$1 = getGeom(line).coordinates.map((pt) => {
            return {x: pt[0], y: pt[1]};
        });
        const spline$$1 = new Spline({
            duration: resolution,
            points: points$$1,
            sharpness,
        });

        for (let i = 0; i < spline$$1.duration; i += 10) {
            const pos = spline$$1.pos(i);
            if (Math.floor(i / 100) % 2 === 0) {
                coords.push([pos.x, pos.y]);
            }
        }
        return lineString(coords, options.properties);
    }

    /**
     * Takes a set of {@link Point|points} and a set of {@link Polygon|polygons} and performs a spatial join.
     *
     * @name tag
     * @param {FeatureCollection<Point>} points input points
     * @param {FeatureCollection<Polygon>} polygons input polygons
     * @param {string} field property in `polygons` to add to joined {<Point>} features
     * @param {string} outField property in `points` in which to store joined property from `polygons`
     * @returns {FeatureCollection<Point>} points with `containingPolyId` property containing values from `polyId`
     * @example
     * var pt1 = turf.point([-77, 44]);
     * var pt2 = turf.point([-77, 38]);
     * var poly1 = turf.polygon([[
     *   [-81, 41],
     *   [-81, 47],
     *   [-72, 47],
     *   [-72, 41],
     *   [-81, 41]
     * ]], {pop: 3000});
     * var poly2 = turf.polygon([[
     *   [-81, 35],
     *   [-81, 41],
     *   [-72, 41],
     *   [-72, 35],
     *   [-81, 35]
     * ]], {pop: 1000});
     *
     * var points = turf.featureCollection([pt1, pt2]);
     * var polygons = turf.featureCollection([poly1, poly2]);
     *
     * var tagged = turf.tag(points, polygons, 'pop', 'population');
     *
     * //addToMap
     * var addToMap = [tagged, polygons]
     */
    function tag(points, polygons, field, outField) {
        // prevent mutations
        points = clone(points);
        polygons = clone(polygons);
        featureEach(points, function (pt) {
            if (!pt.properties) pt.properties = {};
            featureEach(polygons, function (poly) {
                if (pt.properties[outField] === undefined) {
                    if (booleanPointInPolygon(pt, poly)) pt.properties[outField] = poly.properties[field];
                }
            });
        });
        return points;
    }

    // http://stackoverflow.com/questions/11935175/sampling-a-random-subset-from-an-array

    /**
     * Takes a {@link FeatureCollection} and returns a FeatureCollection with given number of {@link Feature|features} at random.
     *
     * @name sample
     * @param {FeatureCollection} featurecollection set of input features
     * @param {number} num number of features to select
     * @returns {FeatureCollection} a FeatureCollection with `n` features
     * @example
     * var points = turf.randomPoint(100, {bbox: [-80, 30, -60, 60]});
     *
     * var sample = turf.sample(points, 5);
     *
     * //addToMap
     * var addToMap = [points, sample]
     * turf.featureEach(sample, function (currentFeature) {
     *   currentFeature.properties['marker-size'] = 'large';
     *   currentFeature.properties['marker-color'] = '#000';
     * });
     */
    function sample(featurecollection, num) {
        if (!featurecollection) throw new Error('featurecollection is required');
        if (num === null || num === undefined) throw new Error('num is required');
        if (typeof num !== 'number') throw new Error('num must be a number');

        var outFC = featureCollection(getRandomSubarray(featurecollection.features, num));
        return outFC;
    }

    function getRandomSubarray(arr, size) {
        var shuffled = arr.slice(0), i = arr.length, min = i - size, temp, index;
        while (i-- > min) {
            index = Math.floor((i + 1) * Math.random());
            temp = shuffled[index];
            shuffled[index] = shuffled[i];
            shuffled[i] = temp;
        }
        return shuffled.slice(min);
    }

    /**
     * Takes a bbox and returns an equivalent {@link Polygon|polygon}.
     *
     * @name bboxPolygon
     * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
     * @param {Object} [options={}] Optional parameters
     * @param {Properties} [options.properties={}] Translate properties to Polygon
     * @param {string|number} [options.id={}] Translate Id to Polygon
     * @returns {Feature<Polygon>} a Polygon representation of the bounding box
     * @example
     * var bbox = [0, 0, 10, 10];
     *
     * var poly = turf.bboxPolygon(bbox);
     *
     * //addToMap
     * var addToMap = [poly]
     */
    function bboxPolygon(bbox, options) {
        options = checkIfOptionsExist(options);

        // Convert BBox positions to Numbers
        // No performance loss for including Number()
        // https://github.com/Turfjs/turf/issues/1119
        const west = Number(bbox[0]);
        const south = Number(bbox[1]);
        const east = Number(bbox[2]);
        const north = Number(bbox[3]);

        if (bbox.length === 6) { throw new Error('@turf/bbox-polygon does not support BBox with 6 positions'); }

        const lowLeft = [west, south];
        const topLeft = [west, north];
        const topRight = [east, north];
        const lowRight = [east, south];

        return polygon([[
            lowLeft,
            lowRight,
            topRight,
            topLeft,
            lowLeft,
        ]], options.properties, {bbox, id: options.id});
    }

    /**
     * Takes any number of features and returns a rectangular {@link Polygon} that encompasses all vertices.
     *
     * @name envelope
     * @param {GeoJSON} geojson input features
     * @returns {Feature<Polygon>} a rectangular Polygon feature that encompasses all vertices
     * @example
     * var features = turf.featureCollection([
     *   turf.point([-75.343, 39.984], {"name": "Location A"}),
     *   turf.point([-75.833, 39.284], {"name": "Location B"}),
     *   turf.point([-75.534, 39.123], {"name": "Location C"})
     * ]);
     *
     * var enveloped = turf.envelope(features);
     *
     * //addToMap
     * var addToMap = [features, enveloped];
     */
    function envelope(geojson) {
        return bboxPolygon(bbox(geojson));
    }

    /**
     * Takes a bounding box and calculates the minimum square bounding box that
     * would contain the input.
     *
     * @name square
     * @param {BBox} bbox extent in [west, south, east, north] order
     * @returns {BBox} a square surrounding `bbox`
     * @example
     * var bbox = [-20, -20, -15, 0];
     * var squared = turf.square(bbox);
     *
     * //addToMap
     * var addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
     */
    function square(bbox) {
        var west = bbox[0];
        var south = bbox[1];
        var east = bbox[2];
        var north = bbox[3];

        var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);
        var verticalDistance = distance(bbox.slice(0, 2), [west, north]);
        if (horizontalDistance >= verticalDistance) {
            var verticalMidpoint = (south + north) / 2;
            return [
                west,
                verticalMidpoint - ((east - west) / 2),
                east,
                verticalMidpoint + ((east - west) / 2)
            ];
        } else {
            var horizontalMidpoint = (west + east) / 2;
            return [
                horizontalMidpoint - ((north - south) / 2),
                south,
                horizontalMidpoint + ((north - south) / 2),
                north
            ];
        }
    }

    // http://en.wikipedia.org/wiki/Haversine_formula

    /**
     * Takes a {@link Point} and calculates the location of a destination point given a distance in
     * degrees, radians, miles, or kilometers; and bearing in degrees.
     * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
     *
     * @name destination
     * @param {Coord} origin starting point
     * @param {number} distance distance from the origin point
     * @param {number} bearing ranging from -180 to 180
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
     * @param {Object} [options.properties={}] Translate properties to Point
     * @returns {Feature<Point>} destination point
     * @example
     * var point = turf.point([-75.343, 39.984]);
     * var distance = 50;
     * var bearing = 90;
     * var options = {units: 'miles'};
     *
     * var destination = turf.destination(point, distance, bearing, options);
     *
     * //addToMap
     * var addToMap = [point, destination]
     * destination.properties['marker-color'] = '#f00';
     * point.properties['marker-color'] = '#0f0';
     */
    function destination(origin, distance, bearing, options) {

        options = checkIfOptionsExist(options);
        // Handle input
        const coordinates1 = getCoord(origin);
        const longitude1 = degreesToRadians(coordinates1[0]);
        const latitude1 = degreesToRadians(coordinates1[1]);
        const bearingRad = degreesToRadians(bearing);
        const radians = lengthToRadians(distance, options.units);

        // Main
        const latitude2 = Math.asin(Math.sin(latitude1) * Math.cos(radians) +
            Math.cos(latitude1) * Math.sin(radians) * Math.cos(bearingRad));
        const longitude2 = longitude1 + Math.atan2(Math.sin(bearingRad) * Math.sin(radians) * Math.cos(latitude1),
            Math.cos(radians) - Math.sin(latitude1) * Math.sin(latitude2));
        const lng = radiansToDegrees(longitude2);
        const lat = radiansToDegrees(latitude2);

        return point([lng, lat], options.properties);
    }

    /**
     * Takes a {@link Point} and calculates the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.
     *
     * @name circle
     * @param {Feature<Point>|number[]} center center point
     * @param {number} radius radius of the circle
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.steps=64] number of steps
     * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
     * @param {Object} [options.properties={}] properties
     * @returns {Feature<Polygon>} circle polygon
     * @example
     * var center = [-75.343, 39.984];
     * var radius = 5;
     * var options = {steps, units, properties{foo, radius, options);
     *
     * //addToMap
     * var addToMap = [turf.point(center), circle]
     */
    function circle(center, radius, options) {
        options = checkIfOptionsExist(options);
        // default params
        const steps = options.steps || 64;
        const properties = options.properties ? options.properties : (!Array.isArray(center) && center.type === 'Feature' && center.properties) ? center.properties : {};

        // main
        const coordinates = [];
        for (let i = 0; i < steps; i++) {
            coordinates.push(destination(center, radius, i * -360 / steps, options).geometry.coordinates);
        }
        coordinates.push(coordinates[0]);

        return polygon([coordinates], properties);
    }

    // http://en.wikipedia.org/wiki/Haversine_formula
    // http://www.movable-type.co.uk/scripts/latlong.html

    /**
     * Takes two {@link Point|points} and finds the geographic bearing between them,
     * i.e. the angle measured in degrees from the north line (0 degrees)
     *
     * @name bearing
     * @param {Coord} start starting Point
     * @param {Coord} end ending Point
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.final=false] calculates the final bearing if true
     * @returns {number} bearing in decimal degrees, between -180 and 180 degrees (positive clockwise)
     * @example
     * var point1 = turf.point([-75.343, 39.984]);
     * var point2 = turf.point([-75.534, 39.123]);
     *
     * var bearing = turf.bearing(point1, point2);
     *
     * //addToMap
     * var addToMap = [point1, point2]
     * point1.properties['marker-color'] = '#f00'
     * point2.properties['marker-color'] = '#0f0'
     * point1.properties.bearing = bearing
     */
    function bearing(start, end, options) {

        options = checkIfOptionsExist(options);

        // Reverse calculation
        if (options.final === true) { return calculateFinalBearing(start, end); }

        const coordinates1 = getCoord(start);
        const coordinates2 = getCoord(end);

        const lon1 = degreesToRadians(coordinates1[0]);
        const lon2 = degreesToRadians(coordinates2[0]);
        const lat1 = degreesToRadians(coordinates1[1]);
        const lat2 = degreesToRadians(coordinates2[1]);
        const a = Math.sin(lon2 - lon1) * Math.cos(lat2);
        const b = Math.cos(lat1) * Math.sin(lat2) -
            Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);

        return radiansToDegrees(Math.atan2(a, b));
    }

    /**
     * Calculates Final Bearing
     *
     * @private
     * @param {Coord} start starting Point
     * @param {Coord} end ending Point
     * @returns {number} bearing
     */
    function calculateFinalBearing(start, end) {
        // Swap start & end
        let bear = bearing(end, start);
        bear = (bear + 180) % 360;
        return bear;
    }

    /**
     * Takes two {@link Point|points} and returns a point midway between them.
     * The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.
     *
     * @name midpoint
     * @param {Coord} point1 first point
     * @param {Coord} point2 second point
     * @returns {Feature<Point>} a point midway between `pt1` and `pt2`
     * @example
     * var point1 = turf.point([144.834823, -37.771257]);
     * var point2 = turf.point([145.14244, -37.830937]);
     *
     * var midpoint = turf.midpoint(point1, point2);
     *
     * //addToMap
     * var addToMap = [point1, point2, midpoint];
     * midpoint.properties['marker-color'] = '#f00';
     */
    function midpoint(point1, point2) {
        var dist = distance(point1, point2);
        var heading = bearing(point1, point2);
        var midpoint = destination(point1, dist / 2, heading);

        return midpoint;
    }

    /**
     * Takes a {@link Feature} or {@link FeatureCollection} and returns the absolute center point of all features.
     *
     * @name center
     * @param {GeoJSON} geojson GeoJSON to be centered
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
     * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point
     * @param {Object} [options.id={}] Translate GeoJSON Id to Point
     * @returns {Feature<Point>} a Point feature at the absolute center point of all input features
     * @example
     * var features = turf.points([
     *   [-97.522259, 35.4691],
     *   [-97.502754, 35.463455],
     *   [-97.508269, 35.463245]
     * ]);
     *
     * var center = turf.center(features);
     *
     * //addToMap
     * var addToMap = [features, center]
     * center.properties['marker-size'] = 'large';
     * center.properties['marker-color'] = '#000';
     */
    function center(geojson, options) {
        options = checkIfOptionsExist(options);

        const ext = bbox(geojson);
        const x = (ext[0] + ext[2]) / 2;
        const y = (ext[1] + ext[3]) / 2;
        return point([x, y], options.properties, options);
    }

    /**
     * Takes one or more features and calculates the centroid using the mean of all vertices.
     * This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.
     *
     * @name centroid
     * @param {GeoJSON} geojson GeoJSON to be centered
     * @param {Object} [options={}] Optional Parameters
     * @param {Object} [options.properties={}] an Object that is used as the {@link Feature}'s properties
     * @returns {Feature<Point>} the centroid of the input features
     * @example
     * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
     *
     * var centroid = turf.centroid(polygon);
     *
     * //addToMap
     * var addToMap = [polygon, centroid]
     */
    function centroid(geojson, options) {
        options = checkIfOptionsExist(options);
        let xSum = 0;
        let ySum = 0;
        let len = 0;
        coordEach(geojson, function (coord) {
            xSum += coord[0];
            ySum += coord[1];
            len++;
        });
        return point([xSum / len, ySum / len], options.properties);
    }

    /**
     * Takes any {@link Feature} or a {@link FeatureCollection} and returns its [center of mass](https://en.wikipedia.org/wiki/Center_of_mass) using this formula: [Centroid of Polygon](https://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon).
     *
     * @name centerOfMass
     * @param {GeoJSON} geojson GeoJSON to be centered
     * @param {Object} [options={}] Optional Parameters
     * @param {Object} [options.properties={}] Translate Properties to Feature
     * @returns {Feature<Point>} the center of mass
     * @example
     * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
     *
     * var center = turf.centerOfMass(polygon);
     *
     * //addToMap
     * var addToMap = [polygon, center]
     */
    function centerOfMass(geojson, options) {
        options = checkIfOptionsExist(options);
        switch (getType(geojson)) {
        case 'Point':
            return point(getCoord(geojson), options.properties);
        case 'Polygon':
            var coords = [];
            coordEach(geojson, function (coord) {
                coords.push(coord);
            });
     
            // First, we neutralize the feature (set it around coordinates [0,0]) to prevent rounding errors
            // We take any point to translate all the points around 0
            var centre = centroid(geojson, {properties: options.properties});
            var translation = centre.geometry.coordinates;
            var sx = 0;
            var sy = 0;
            var sArea = 0;
            var i, pi, pj, xi, xj, yi, yj, a;

            var neutralizedPoints = coords.map(function (point$$1) {
                return [
                    point$$1[0] - translation[0],
                    point$$1[1] - translation[1]
                ];
            });

            for (i = 0; i < coords.length - 1; i++) {
                // pi is the current point
                pi = neutralizedPoints[i];
                xi = pi[0];
                yi = pi[1];

                // pj is the next point (pi+1)
                pj = neutralizedPoints[i + 1];
                xj = pj[0];
                yj = pj[1];

                // a is the common factor to compute the signed area and the final coordinates
                a = xi * yj - xj * yi;

                // sArea is the sum used to compute the signed area
                sArea += a;

                // sx and sy are the sums used to compute the final coordinates
                sx += (xi + xj) * a;
                sy += (yi + yj) * a;
            }

            // Shape has no area: fallback on turf.centroid
            if (sArea === 0) {
                return centre;
            } else {
                // Compute the signed area, and factorize 1/6A
                var area = sArea * 0.5;
                var areaFactor = 1 / (6 * area);

                // Compute the final coordinates, adding back the values that have been neutralized
                return point([
                    translation[0] + areaFactor * sx,
                    translation[1] + areaFactor * sy
                ], options.properties);
            }
        default:
            // Not a polygon: Compute the convex hull and work with that
            var hull = convex(geojson);

            if (hull) return centerOfMass(hull, {properties: options.properties});
            // Hull is empty: fallback on the centroid
            else return centroid(geojson, {properties: options.properties});
        }
    }

    /**
     * Combines a {@link FeatureCollection} of {@link Point}, {@link LineString}, or {@link Polygon} features
     * into {@link MultiPoint}, {@link MultiLineString}, or {@link MultiPolygon} features.
     *
     * @name combine
     * @param {FeatureCollection<Point|LineString|Polygon>} fc a FeatureCollection of any type
     * @returns {FeatureCollection<MultiPoint|MultiLineString|MultiPolygon>} a FeatureCollection of corresponding type to input
     * @example
     * var fc = turf.featureCollection([
     *   turf.point([19.026432, 47.49134]),
     *   turf.point([19.074497, 47.509548])
     * ]);
     *
     * var combined = turf.combine(fc);
     *
     * //addToMap
     * var addToMap = [combined]
     */
    function combine(fc) {
        var groups = {
            MultiPoint: {coordinates: [], properties: []},
            MultiLineString: {coordinates: [], properties: []},
            MultiPolygon: {coordinates: [], properties: []}
        };

        var multiMapping = Object.keys(groups).reduce(function (memo, item) {
            memo[item.replace('Multi', '')] = item;
            return memo;
        }, {});

        function addToGroup(feature$$1, key, multi) {
            if (!multi) {
                groups[key].coordinates.push(feature$$1.geometry.coordinates);
            } else {
                groups[key].coordinates = groups[key].coordinates.concat(feature$$1.geometry.coordinates);
            }
            groups[key].properties.push(feature$$1.properties);
        }

        featureEach(fc, function (feature$$1) {
            if (!feature$$1.geometry) return;
            if (groups[feature$$1.geometry.type]) {
                addToGroup(feature$$1, feature$$1.geometry.type, true);
            } else if (multiMapping[feature$$1.geometry.type]) {
                addToGroup(feature$$1, multiMapping[feature$$1.geometry.type], false);
            }
        });

        return featureCollection(Object.keys(groups)
            .filter(function (key) {
                return groups[key].coordinates.length;
            })
            .sort()
            .map(function (key) {
                var geometry$$1 = { type: key, coordinates: groups[key].coordinates };
                var properties = { collectedProperties: groups[key].properties };
                return feature(geometry$$1, properties);
            }));
    }

    /**
     * Takes a feature or set of features and returns all positions as {@link Point|points}.
     *
     * @name explode
     * @param {GeoJSON} geojson input features
     * @returns {FeatureCollection<point>} points representing the exploded input features
     * @throws {Error} if it encounters an unknown geometry type
     * @example
     * var polygon = turf.polygon([[[-81, 41], [-88, 36], [-84, 31], [-80, 33], [-77, 39], [-81, 41]]]);
     *
     * var explode = turf.explode(polygon);
     *
     * //addToMap
     * var addToMap = [polygon, explode]
     */
    function explode(geojson) {
        var points$$1 = [];
        if (geojson.type === 'FeatureCollection') {
            featureEach(geojson, function (feature$$1) {
                coordEach(feature$$1, function (coord) {
                    points$$1.push(point(coord, feature$$1.properties));
                });
            });
        } else {
            coordEach(geojson, function (coord) {
                points$$1.push(point(coord, geojson.properties));
            });
        }
        return featureCollection(points$$1);
    }

    var earcut_1 = earcut;
    var default_1$3 = earcut;

    function earcut(data, holeIndices, dim) {

        dim = dim || 2;

        var hasHoles = holeIndices && holeIndices.length,
            outerLen = hasHoles ? holeIndices[0] * dim : data.length,
            outerNode = linkedList(data, 0, outerLen, dim, true),
            triangles = [];

        if (!outerNode) return triangles;

        var minX, minY, maxX, maxY, x, y, invSize;

        if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);

        // if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
        if (data.length > 80 * dim) {
            minX = maxX = data[0];
            minY = maxY = data[1];

            for (var i = dim; i < outerLen; i += dim) {
                x = data[i];
                y = data[i + 1];
                if (x < minX) minX = x;
                if (y < minY) minY = y;
                if (x > maxX) maxX = x;
                if (y > maxY) maxY = y;
            }

            // minX, minY and invSize are later used to transform coords into integers for z-order calculation
            invSize = Math.max(maxX - minX, maxY - minY);
            invSize = invSize !== 0 ? 1 / invSize : 0;
        }

        earcutLinked(outerNode, triangles, dim, minX, minY, invSize);

        return triangles;
    }

    // create a circular doubly linked list from polygon points in the specified winding order
    function linkedList(data, start, end, dim, clockwise) {
        var i, last;

        if (clockwise === (signedArea(data, start, end, dim) > 0)) {
            for (i = start; i < end; i += dim) last = insertNode$1(i, data[i], data[i + 1], last);
        } else {
            for (i = end - dim; i >= start; i -= dim) last = insertNode$1(i, data[i], data[i + 1], last);
        }

        if (last && equals$1(last, last.next)) {
            removeNode(last);
            last = last.next;
        }

        return last;
    }

    // eliminate colinear or duplicate points
    function filterPoints(start, end) {
        if (!start) return start;
        if (!end) end = start;

        var p = start,
            again;
        do {
            again = false;

            if (!p.steiner && (equals$1(p, p.next) || area(p.prev, p, p.next) === 0)) {
                removeNode(p);
                p = end = p.prev;
                if (p === p.next) break;
                again = true;

            } else {
                p = p.next;
            }
        } while (again || p !== end);

        return end;
    }

    // main ear slicing loop which triangulates a polygon (given as a linked list)
    function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
        if (!ear) return;

        // interlink polygon nodes in z-order
        if (!pass && invSize) indexCurve(ear, minX, minY, invSize);

        var stop = ear,
            prev, next;

        // iterate through ears, slicing them one by one
        while (ear.prev !== ear.next) {
            prev = ear.prev;
            next = ear.next;

            if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
                // cut off the triangle
                triangles.push(prev.i / dim);
                triangles.push(ear.i / dim);
                triangles.push(next.i / dim);

                removeNode(ear);

                // skipping the next vertice leads to less sliver triangles
                ear = next.next;
                stop = next.next;

                continue;
            }

            ear = next;

            // if we looped through the whole remaining polygon and can't find any more ears
            if (ear === stop) {
                // try filtering points and slicing again
                if (!pass) {
                    earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);

                // if this didn't work, try curing all small self-intersections locally
                } else if (pass === 1) {
                    ear = cureLocalIntersections(ear, triangles, dim);
                    earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);

                // as a last resort, try splitting the remaining polygon into two
                } else if (pass === 2) {
                    splitEarcut(ear, triangles, dim, minX, minY, invSize);
                }

                break;
            }
        }
    }

    // check whether a polygon node forms a valid ear with adjacent nodes
    function isEar(ear) {
        var a = ear.prev,
            b = ear,
            c = ear.next;

        if (area(a, b, c) >= 0) return false; // reflex, can't be an ear

        // now make sure we don't have other points inside the potential ear
        var p = ear.next.next;

        while (p !== ear.prev) {
            if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
                area(p.prev, p, p.next) >= 0) return false;
            p = p.next;
        }

        return true;
    }

    function isEarHashed(ear, minX, minY, invSize) {
        var a = ear.prev,
            b = ear,
            c = ear.next;

        if (area(a, b, c) >= 0) return false; // reflex, can't be an ear

        // triangle bbox; min & max are calculated like this for speed
        var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
            minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
            maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
            maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);

        // z-order range for the current triangle bbox;
        var minZ = zOrder(minTX, minTY, minX, minY, invSize),
            maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);

        var p = ear.prevZ,
            n = ear.nextZ;

        // look for points inside the triangle in both directions
        while (p && p.z >= minZ && n && n.z <= maxZ) {
            if (p !== ear.prev && p !== ear.next &&
                pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
                area(p.prev, p, p.next) >= 0) return false;
            p = p.prevZ;

            if (n !== ear.prev && n !== ear.next &&
                pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
                area(n.prev, n, n.next) >= 0) return false;
            n = n.nextZ;
        }

        // look for remaining points in decreasing z-order
        while (p && p.z >= minZ) {
            if (p !== ear.prev && p !== ear.next &&
                pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
                area(p.prev, p, p.next) >= 0) return false;
            p = p.prevZ;
        }

        // look for remaining points in increasing z-order
        while (n && n.z <= maxZ) {
            if (n !== ear.prev && n !== ear.next &&
                pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
                area(n.prev, n, n.next) >= 0) return false;
            n = n.nextZ;
        }

        return true;
    }

    // go through all polygon nodes and cure small local self-intersections
    function cureLocalIntersections(start, triangles, dim) {
        var p = start;
        do {
            var a = p.prev,
                b = p.next.next;

            if (!equals$1(a, b) && intersects$2(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {

                triangles.push(a.i / dim);
                triangles.push(p.i / dim);
                triangles.push(b.i / dim);

                // remove two nodes involved
                removeNode(p);
                removeNode(p.next);

                p = start = b;
            }
            p = p.next;
        } while (p !== start);

        return p;
    }

    // try splitting polygon into two and triangulate them independently
    function splitEarcut(start, triangles, dim, minX, minY, invSize) {
        // look for a valid diagonal that divides the polygon into two
        var a = start;
        do {
            var b = a.next.next;
            while (b !== a.prev) {
                if (a.i !== b.i && isValidDiagonal(a, b)) {
                    // split the polygon in two by the diagonal
                    var c = splitPolygon(a, b);

                    // filter colinear points around the cuts
                    a = filterPoints(a, a.next);
                    c = filterPoints(c, c.next);

                    // run earcut on each half
                    earcutLinked(a, triangles, dim, minX, minY, invSize);
                    earcutLinked(c, triangles, dim, minX, minY, invSize);
                    return;
                }
                b = b.next;
            }
            a = a.next;
        } while (a !== start);
    }

    // link every hole into the outer loop, producing a single-ring polygon without holes
    function eliminateHoles(data, holeIndices, outerNode, dim) {
        var queue = [],
            i, len, start, end, list;

        for (i = 0, len = holeIndices.length; i < len; i++) {
            start = holeIndices[i] * dim;
            end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
            list = linkedList(data, start, end, dim, false);
            if (list === list.next) list.steiner = true;
            queue.push(getLeftmost(list));
        }

        queue.sort(compareX);

        // process holes from left to right
        for (i = 0; i < queue.length; i++) {
            eliminateHole(queue[i], outerNode);
            outerNode = filterPoints(outerNode, outerNode.next);
        }

        return outerNode;
    }

    function compareX(a, b) {
        return a.x - b.x;
    }

    // find a bridge between vertices that connects hole with an outer ring and and link it
    function eliminateHole(hole, outerNode) {
        outerNode = findHoleBridge(hole, outerNode);
        if (outerNode) {
            var b = splitPolygon(outerNode, hole);
            filterPoints(b, b.next);
        }
    }

    // David Eberly's algorithm for finding a bridge between hole and outer polygon
    function findHoleBridge(hole, outerNode) {
        var p = outerNode,
            hx = hole.x,
            hy = hole.y,
            qx = -Infinity,
            m;

        // find a segment intersected by a ray from the hole's leftmost point to the left;
        // segment's endpoint with lesser x will be potential connection point
        do {
            if (hy <= p.y && hy >= p.next.y && p.next.y !== p.y) {
                var x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
                if (x <= hx && x > qx) {
                    qx = x;
                    if (x === hx) {
                        if (hy === p.y) return p;
                        if (hy === p.next.y) return p.next;
                    }
                    m = p.x < p.next.x ? p : p.next;
                }
            }
            p = p.next;
        } while (p !== outerNode);

        if (!m) return null;

        if (hx === qx) return m.prev; // hole touches outer segment; pick lower endpoint

        // look for points inside the triangle of hole point, segment intersection and endpoint;
        // if there are no points found, we have a valid connection;
        // otherwise choose the point of the minimum angle with the ray as connection point

        var stop = m,
            mx = m.x,
            my = m.y,
            tanMin = Infinity,
            tan;

        p = m.next;

        while (p !== stop) {
            if (hx >= p.x && p.x >= mx && hx !== p.x &&
                    pointInTriangle(hy < my ? hx : qx, hy, mx, my, hy < my ? qx : hx, hy, p.x, p.y)) {

                tan = Math.abs(hy - p.y) / (hx - p.x); // tangential

                if ((tan < tanMin || (tan === tanMin && p.x > m.x)) && locallyInside(p, hole)) {
                    m = p;
                    tanMin = tan;
                }
            }

            p = p.next;
        }

        return m;
    }

    // interlink polygon nodes in z-order
    function indexCurve(start, minX, minY, invSize) {
        var p = start;
        do {
            if (p.z === null) p.z = zOrder(p.x, p.y, minX, minY, invSize);
            p.prevZ = p.prev;
            p.nextZ = p.next;
            p = p.next;
        } while (p !== start);

        p.prevZ.nextZ = null;
        p.prevZ = null;

        sortLinked(p);
    }

    // Simon Tatham's linked list merge sort algorithm
    // http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html
    function sortLinked(list) {
        var i, p, q, e, tail, numMerges, pSize, qSize,
            inSize = 1;

        do {
            p = list;
            list = null;
            tail = null;
            numMerges = 0;

            while (p) {
                numMerges++;
                q = p;
                pSize = 0;
                for (i = 0; i < inSize; i++) {
                    pSize++;
                    q = q.nextZ;
                    if (!q) break;
                }
                qSize = inSize;

                while (pSize > 0 || (qSize > 0 && q)) {

                    if (pSize !== 0 && (qSize === 0 || !q || p.z <= q.z)) {
                        e = p;
                        p = p.nextZ;
                        pSize--;
                    } else {
                        e = q;
                        q = q.nextZ;
                        qSize--;
                    }

                    if (tail) tail.nextZ = e;
                    else list = e;

                    e.prevZ = tail;
                    tail = e;
                }

                p = q;
            }

            tail.nextZ = null;
            inSize *= 2;

        } while (numMerges > 1);

        return list;
    }

    // z-order of a point given coords and inverse of the longer side of data bbox
    function zOrder(x, y, minX, minY, invSize) {
        // coords are transformed into non-negative 15-bit integer range
        x = 32767 * (x - minX) * invSize;
        y = 32767 * (y - minY) * invSize;

        x = (x | (x << 8)) & 0x00FF00FF;
        x = (x | (x << 4)) & 0x0F0F0F0F;
        x = (x | (x << 2)) & 0x33333333;
        x = (x | (x << 1)) & 0x55555555;

        y = (y | (y << 8)) & 0x00FF00FF;
        y = (y | (y << 4)) & 0x0F0F0F0F;
        y = (y | (y << 2)) & 0x33333333;
        y = (y | (y << 1)) & 0x55555555;

        return x | (y << 1);
    }

    // find the leftmost node of a polygon ring
    function getLeftmost(start) {
        var p = start,
            leftmost = start;
        do {
            if (p.x < leftmost.x) leftmost = p;
            p = p.next;
        } while (p !== start);

        return leftmost;
    }

    // check if a point lies within a convex triangle
    function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
        return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 &&
               (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 &&
               (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
    }

    // check if a diagonal between two polygon nodes is valid (lies in polygon interior)
    function isValidDiagonal(a, b) {
        return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) &&
               locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b);
    }

    // signed area of a triangle
    function area(p, q, r) {
        return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
    }

    // check if two points are equal
    function equals$1(p1, p2) {
        return p1.x === p2.x && p1.y === p2.y;
    }

    // check if two segments intersect
    function intersects$2(p1, q1, p2, q2) {
        if ((equals$1(p1, q1) && equals$1(p2, q2)) ||
            (equals$1(p1, q2) && equals$1(p2, q1))) return true;
        return area(p1, q1, p2) > 0 !== area(p1, q1, q2) > 0 &&
               area(p2, q2, p1) > 0 !== area(p2, q2, q1) > 0;
    }

    // check if a polygon diagonal intersects any polygon segments
    function intersectsPolygon(a, b) {
        var p = a;
        do {
            if (p.i !== a.i && p.next.i !== a.i && p.i !== b.i && p.next.i !== b.i &&
                    intersects$2(p, p.next, a, b)) return true;
            p = p.next;
        } while (p !== a);

        return false;
    }

    // check if a polygon diagonal is locally inside the polygon
    function locallyInside(a, b) {
        return area(a.prev, a, a.next) < 0 ?
            area(a, b, a.next) >= 0 && area(a, a.prev, b) >= 0 :
            area(a, b, a.prev) < 0 || area(a, a.next, b) < 0;
    }

    // check if the middle point of a polygon diagonal is inside the polygon
    function middleInside(a, b) {
        var p = a,
            inside = false,
            px = (a.x + b.x) / 2,
            py = (a.y + b.y) / 2;
        do {
            if (((p.y > py) !== (p.next.y > py)) && p.next.y !== p.y &&
                    (px < (p.next.x - p.x) * (py - p.y) / (p.next.y - p.y) + p.x))
                inside = !inside;
            p = p.next;
        } while (p !== a);

        return inside;
    }

    // link two polygon vertices with a bridge; if the vertices belong to the same ring, it splits polygon into two;
    // if one belongs to the outer ring and another to a hole, it merges it into a single ring
    function splitPolygon(a, b) {
        var a2 = new Node$1(a.i, a.x, a.y),
            b2 = new Node$1(b.i, b.x, b.y),
            an = a.next,
            bp = b.prev;

        a.next = b;
        b.prev = a;

        a2.next = an;
        an.prev = a2;

        b2.next = a2;
        a2.prev = b2;

        bp.next = b2;
        b2.prev = bp;

        return b2;
    }

    // create a node and optionally link it with previous one (in a circular doubly linked list)
    function insertNode$1(i, x, y, last) {
        var p = new Node$1(i, x, y);

        if (!last) {
            p.prev = p;
            p.next = p;

        } else {
            p.next = last.next;
            p.prev = last;
            last.next.prev = p;
            last.next = p;
        }
        return p;
    }

    function removeNode(p) {
        p.next.prev = p.prev;
        p.prev.next = p.next;

        if (p.prevZ) p.prevZ.nextZ = p.nextZ;
        if (p.nextZ) p.nextZ.prevZ = p.prevZ;
    }

    function Node$1(i, x, y) {
        // vertice index in coordinates array
        this.i = i;

        // vertex coordinates
        this.x = x;
        this.y = y;

        // previous and next vertice nodes in a polygon ring
        this.prev = null;
        this.next = null;

        // z-order curve value
        this.z = null;

        // previous and next nodes in z-order
        this.prevZ = null;
        this.nextZ = null;

        // indicates whether this is a steiner point
        this.steiner = false;
    }

    // return a percentage difference between the polygon area and its triangulation area;
    // used to verify correctness of triangulation
    earcut.deviation = function (data, holeIndices, dim, triangles) {
        var hasHoles = holeIndices && holeIndices.length;
        var outerLen = hasHoles ? holeIndices[0] * dim : data.length;

        var polygonArea = Math.abs(signedArea(data, 0, outerLen, dim));
        if (hasHoles) {
            for (var i = 0, len = holeIndices.length; i < len; i++) {
                var start = holeIndices[i] * dim;
                var end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
                polygonArea -= Math.abs(signedArea(data, start, end, dim));
            }
        }

        var trianglesArea = 0;
        for (i = 0; i < triangles.length; i += 3) {
            var a = triangles[i] * dim;
            var b = triangles[i + 1] * dim;
            var c = triangles[i + 2] * dim;
            trianglesArea += Math.abs(
                (data[a] - data[c]) * (data[b + 1] - data[a + 1]) -
                (data[a] - data[b]) * (data[c + 1] - data[a + 1]));
        }

        return polygonArea === 0 && trianglesArea === 0 ? 0 :
            Math.abs((trianglesArea - polygonArea) / polygonArea);
    };

    function signedArea(data, start, end, dim) {
        var sum = 0;
        for (var i = start, j = end - dim; i < end; i += dim) {
            sum += (data[j] - data[i]) * (data[i + 1] + data[j + 1]);
            j = i;
        }
        return sum;
    }

    // turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
    earcut.flatten = function (data) {
        var dim = data[0][0].length,
            result = {vertices: [], holes: [], dimensions: dim},
            holeIndex = 0;

        for (var i = 0; i < data.length; i++) {
            for (var j = 0; j < data[i].length; j++) {
                for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
            }
            if (i > 0) {
                holeIndex += data[i - 1].length;
                result.holes.push(holeIndex);
            }
        }
        return result;
    };
    earcut_1.default = default_1$3;

    /**
     * Tesselates a {@link Feature<Polygon>} into a {@link FeatureCollection<Polygon>} of triangles
     * using [earcut](https://github.com/mapbox/earcut).
     *
     * @name tesselate
     * @param {Feature<Polygon>} poly the polygon to tesselate
     * @returns {FeatureCollection<Polygon>} a geometrycollection feature
     * @example
     * var poly = turf.polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]]);
     * var triangles = turf.tesselate(poly);
     *
     * //addToMap
     * var addToMap = [poly, triangles]
     */
    function tesselate(poly) {
        if (!poly.geometry || (poly.geometry.type !== 'Polygon' && poly.geometry.type !== 'MultiPolygon')) {
            throw new Error('input must be a Polygon or MultiPolygon');
        }

        var fc = {type: 'FeatureCollection', features: []};

        if (poly.geometry.type === 'Polygon') {
            fc.features = processPolygon(poly.geometry.coordinates);
        } else {
            poly.geometry.coordinates.forEach(function (coordinates) {
                fc.features = fc.features.concat(processPolygon(coordinates));
            });
        }

        return fc;
    }

    function processPolygon(coordinates) {
        var data = flattenCoords(coordinates);
        var dim = 2;
        var result = earcut_1(data.vertices, data.holes, dim);

        var features = [];
        var vertices = [];

        result.forEach(function (vert, i) {
            var index = result[i];
            vertices.push([data.vertices[index * dim], data.vertices[index * dim + 1]]);
        });

        for (var i = 0; i < vertices.length; i += 3) {
            var coords = vertices.slice(i, i + 3);
            coords.push(vertices[i]);
            features.push(polygon([coords]));
        }

        return features;
    }

    function flattenCoords(data) {
        var dim = data[0][0].length,
            result = {vertices: [], holes: [], dimensions: dim},
            holeIndex = 0;

        for (var i = 0; i < data.length; i++) {
            for (var j = 0; j < data[i].length; j++) {
                for (var d = 0; d < dim; d++) result.vertices.push(data[i][j][d]);
            }
            if (i > 0) {
                holeIndex += data[i - 1].length;
                result.holes.push(holeIndex);
            }
        }

        return result;
    }

    /**
     * Takes a reference {@link Point|point} and a FeatureCollection of Features
     * with Point geometries and returns the
     * point from the FeatureCollection closest to the reference. This calculation
     * is geodesic.
     *
     * @name nearestPoint
     * @param {Coord} targetPoint the reference point
     * @param {FeatureCollection<Point>} points against input point set
     * @returns {Feature<Point>} the closest point in the set to the reference point
     * @example
     * var targetPoint = turf.point([28.965797, 41.010086], {"marker-color": "#0F0"});
     * var points = turf.featureCollection([
     *     turf.point([28.973865, 41.011122]),
     *     turf.point([28.948459, 41.024204]),
     *     turf.point([28.938674, 41.013324])
     * ]);
     *
     * var nearest = turf.nearestPoint(targetPoint, points);
     *
     * //addToMap
     * var addToMap = [targetPoint, points, nearest];
     * nearest.properties['marker-color'] = '#F00';
     */
    function nearestPoint(targetPoint, points) {
        // Input validation
        if (!targetPoint) throw new Error('targetPoint is required');
        if (!points) throw new Error('points is required');

        let nearest = null;
        let minDist = Infinity;
        let bestFeatureIndex = 0;
        featureEach(points,  function (pt, featureIndex) {
            const distanceToPoint = distance(targetPoint, pt);
            if (distanceToPoint < minDist) {
                bestFeatureIndex = featureIndex;
                minDist = distanceToPoint;
            }
        });
        nearest = clone(points.features[bestFeatureIndex]);
        nearest.properties.featureIndex = bestFeatureIndex;
        nearest.properties.distanceToPoint = minDist;
        return nearest;
    }

    /**
     * Creates a {@link FeatureCollection} of 2-vertex {@link LineString} segments from a
     * {@link LineString|(Multi)LineString} or {@link Polygon|(Multi)Polygon}.
     *
     * @name lineSegment
     * @param {GeoJSON} geojson GeoJSON Polygon or LineString
     * @returns {FeatureCollection<LineString>} 2-vertex line segments
     * @example
     * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
     * var segments = turf.lineSegment(polygon);
     *
     * //addToMap
     * var addToMap = [polygon, segments]
     */
    function lineSegment(geojson) {
        if (!geojson) { throw new Error('geojson is required'); }

        const results = [];
        flattenEach(geojson, function (feature$$1) {
            lineSegmentFeature(feature$$1, results);
        });
        return featureCollection(results);
    }

    /**
     * Line Segment
     *
     * @private
     * @param {Feature<LineString|Polygon>} geojson Line or polygon feature
     * @param {Array} results push to results
     * @returns {void}
     */
    function lineSegmentFeature(geojson, results) {
        let coords = [];
        const geometry$$1 = geojson.geometry;
        if (geometry$$1 !== null) {
            switch (geometry$$1.type) {
            case 'Polygon':
                coords = getCoords(geometry$$1);
                break;
            case 'LineString':
                coords = [getCoords(geometry$$1)];
            }
            coords.forEach(function (coord) {
                const segments = createSegments(coord, geojson.properties);
                segments.forEach(function (segment) {
                    segment.id = results.length;
                    results.push(segment);
                });
            });
        }
    }

    /**
     * Create Segments from LineString coordinates
     *
     * @private
     * @param {Array<Array<number>>} coords LineString coordinates
     * @param {*} properties GeoJSON properties
     * @returns {Array<Feature<LineString>>} line segments
     */
    function createSegments(coords, properties) {
        const segments = [];
        coords.reduce(function (previousCoords, currentCoords) {
            const segment = lineString([previousCoords, currentCoords], properties);
            segment.bbox = bbox$1(previousCoords, currentCoords);
            segments.push(segment);
            return currentCoords;
        });
        return segments;
    }

    /**
     * Create BBox between two coordinates (faster than ../bbox)
     *
     * @private
     * @param {Array<number>} coords1 Point coordinate
     * @param {Array<number>} coords2 Point coordinate
     * @returns {BBox} [west, south, east, north]
     */
    function bbox$1(coords1, coords2) {
        const x1 = coords1[0];
        const y1 = coords1[1];
        const x2 = coords2[0];
        const y2 = coords2[1];
        const west = (x1 < x2) ? x1 : x2;
        const south = (y1 < y2) ? y1 : y2;
        const east = (x1 > x2) ? x1 : x2;
        const north = (y1 > y2) ? y1 : y2;
        return [west, south, east, north];
    }

    var helpers = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });
    /**
     * @module helpers
     */
    /**
     * Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth.
     *
     * @memberof helpers
     * @type {number}
     */
    exports.earthRadius = 6371008.8;
    /**
     * Unit of measurement factors using a spherical (non-ellipsoid) earth radius.
     *
     * @memberof helpers
     * @type {Object}
     */
    exports.factors = {
        centimeters: exports.earthRadius * 100,
        centimetres: exports.earthRadius * 100,
        degrees: exports.earthRadius / 111325,
        feet: exports.earthRadius * 3.28084,
        inches: exports.earthRadius * 39.370,
        kilometers: exports.earthRadius / 1000,
        kilometres: exports.earthRadius / 1000,
        meters: exports.earthRadius,
        metres: exports.earthRadius,
        miles: exports.earthRadius / 1609.344,
        millimeters: exports.earthRadius * 1000,
        millimetres: exports.earthRadius * 1000,
        nauticalmiles: exports.earthRadius / 1852,
        radians: 1,
        yards: exports.earthRadius / 1.0936,
    };
    /**
     * Units of measurement factors based on 1 meter.
     *
     * @memberof helpers
     * @type {Object}
     */
    exports.unitsFactors = {
        centimeters: 100,
        centimetres: 100,
        degrees: 1 / 111325,
        feet: 3.28084,
        inches: 39.370,
        kilometers: 1 / 1000,
        kilometres: 1 / 1000,
        meters: 1,
        metres: 1,
        miles: 1 / 1609.344,
        millimeters: 1000,
        millimetres: 1000,
        nauticalmiles: 1 / 1852,
        radians: 1 / exports.earthRadius,
        yards: 1 / 1.0936,
    };
    /**
     * Area of measurement factors based on 1 square meter.
     *
     * @memberof helpers
     * @type {Object}
     */
    exports.areaFactors = {
        acres: 0.000247105,
        centimeters: 10000,
        centimetres: 10000,
        feet: 10.763910417,
        inches: 1550.003100006,
        kilometers: 0.000001,
        kilometres: 0.000001,
        meters: 1,
        metres: 1,
        miles: 3.86e-7,
        millimeters: 1000000,
        millimetres: 1000000,
        yards: 1.195990046,
    };
    /**
     * Wraps a GeoJSON {@link Geometry} in a GeoJSON {@link Feature}.
     *
     * @name feature
     * @param {Geometry} geometry input geometry
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature} a GeoJSON Feature
     * @example
     * var geometry = {
     *   "type": "Point",
     *   "coordinates": [110, 50]
     * };
     *
     * var feature = turf.feature(geometry);
     *
     * //=feature
     */
    function feature(geom, properties, options) {
        if (options === void 0) { options = {}; }
        var feat = { type: "Feature" };
        if (options.id === 0 || options.id) {
            feat.id = options.id;
        }
        if (options.bbox) {
            feat.bbox = options.bbox;
        }
        feat.properties = properties || {};
        feat.geometry = geom;
        return feat;
    }
    exports.feature = feature;
    /**
     * Creates a GeoJSON {@link Geometry} from a Geometry string type & coordinates.
     * For GeometryCollection type use `helpers.geometryCollection`
     *
     * @name geometry
     * @param {string} type Geometry Type
     * @param {Array<any>} coordinates Coordinates
     * @param {Object} [options={}] Optional Parameters
     * @returns {Geometry} a GeoJSON Geometry
     * @example
     * var type = "Point";
     * var coordinates = [110, 50];
     * var geometry = turf.geometry(type, coordinates);
     * // => geometry
     */
    function geometry(type, coordinates, options) {
        if (options === void 0) { options = {}; }
        switch (type) {
            case "Point": return point(coordinates).geometry;
            case "LineString": return lineString(coordinates).geometry;
            case "Polygon": return polygon(coordinates).geometry;
            case "MultiPoint": return multiPoint(coordinates).geometry;
            case "MultiLineString": return multiLineString(coordinates).geometry;
            case "MultiPolygon": return multiPolygon(coordinates).geometry;
            default: throw new Error(type + " is invalid");
        }
    }
    exports.geometry = geometry;
    /**
     * Creates a {@link Point} {@link Feature} from a Position.
     *
     * @name point
     * @param {Array<number>} coordinates longitude, latitude position (each in decimal degrees)
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<Point>} a Point feature
     * @example
     * var point = turf.point([-75.343, 39.984]);
     *
     * //=point
     */
    function point(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        var geom = {
            type: "Point",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.point = point;
    /**
     * Creates a {@link Point} {@link FeatureCollection} from an Array of Point coordinates.
     *
     * @name points
     * @param {Array<Array<number>>} coordinates an array of Points
     * @param {Object} [properties={}] Translate these properties to each Feature
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
     * associated with the FeatureCollection
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<Point>} Point Feature
     * @example
     * var points = turf.points([
     *   [-75, 39],
     *   [-80, 45],
     *   [-78, 50]
     * ]);
     *
     * //=points
     */
    function points(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        return featureCollection(coordinates.map(function (coords) {
            return point(coords, properties);
        }), options);
    }
    exports.points = points;
    /**
     * Creates a {@link Polygon} {@link Feature} from an Array of LinearRings.
     *
     * @name polygon
     * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<Polygon>} Polygon Feature
     * @example
     * var polygon = turf.polygon([[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]], { name: 'poly1' });
     *
     * //=polygon
     */
    function polygon(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
            var ring = coordinates_1[_i];
            if (ring.length < 4) {
                throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
            }
            for (var j = 0; j < ring[ring.length - 1].length; j++) {
                // Check if first point of Polygon contains two numbers
                if (ring[ring.length - 1][j] !== ring[0][j]) {
                    throw new Error("First and last Position are not equivalent.");
                }
            }
        }
        var geom = {
            type: "Polygon",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.polygon = polygon;
    /**
     * Creates a {@link Polygon} {@link FeatureCollection} from an Array of Polygon coordinates.
     *
     * @name polygons
     * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygon coordinates
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<Polygon>} Polygon FeatureCollection
     * @example
     * var polygons = turf.polygons([
     *   [[[-5, 52], [-4, 56], [-2, 51], [-7, 54], [-5, 52]]],
     *   [[[-15, 42], [-14, 46], [-12, 41], [-17, 44], [-15, 42]]],
     * ]);
     *
     * //=polygons
     */
    function polygons(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        return featureCollection(coordinates.map(function (coords) {
            return polygon(coords, properties);
        }), options);
    }
    exports.polygons = polygons;
    /**
     * Creates a {@link LineString} {@link Feature} from an Array of Positions.
     *
     * @name lineString
     * @param {Array<Array<number>>} coordinates an array of Positions
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<LineString>} LineString Feature
     * @example
     * var linestring1 = turf.lineString([[-24, 63], [-23, 60], [-25, 65], [-20, 69]], {name: 'line 1'});
     * var linestring2 = turf.lineString([[-14, 43], [-13, 40], [-15, 45], [-10, 49]], {name: 'line 2'});
     *
     * //=linestring1
     * //=linestring2
     */
    function lineString(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        if (coordinates.length < 2) {
            throw new Error("coordinates must be an array of two or more positions");
        }
        var geom = {
            type: "LineString",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.lineString = lineString;
    /**
     * Creates a {@link LineString} {@link FeatureCollection} from an Array of LineString coordinates.
     *
     * @name lineStrings
     * @param {Array<Array<Array<number>>>} coordinates an array of LinearRings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north]
     * associated with the FeatureCollection
     * @param {string|number} [options.id] Identifier associated with the FeatureCollection
     * @returns {FeatureCollection<LineString>} LineString FeatureCollection
     * @example
     * var linestrings = turf.lineStrings([
     *   [[-24, 63], [-23, 60], [-25, 65], [-20, 69]],
     *   [[-14, 43], [-13, 40], [-15, 45], [-10, 49]]
     * ]);
     *
     * //=linestrings
     */
    function lineStrings(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        return featureCollection(coordinates.map(function (coords) {
            return lineString(coords, properties);
        }), options);
    }
    exports.lineStrings = lineStrings;
    /**
     * Takes one or more {@link Feature|Features} and creates a {@link FeatureCollection}.
     *
     * @name featureCollection
     * @param {Feature[]} features input features
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {FeatureCollection} FeatureCollection of Features
     * @example
     * var locationA = turf.point([-75.343, 39.984], {name: 'Location A'});
     * var locationB = turf.point([-75.833, 39.284], {name: 'Location B'});
     * var locationC = turf.point([-75.534, 39.123], {name: 'Location C'});
     *
     * var collection = turf.featureCollection([
     *   locationA,
     *   locationB,
     *   locationC
     * ]);
     *
     * //=collection
     */
    function featureCollection(features, options) {
        if (options === void 0) { options = {}; }
        var fc = { type: "FeatureCollection" };
        if (options.id) {
            fc.id = options.id;
        }
        if (options.bbox) {
            fc.bbox = options.bbox;
        }
        fc.features = features;
        return fc;
    }
    exports.featureCollection = featureCollection;
    /**
     * Creates a {@link Feature<MultiLineString>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiLineString
     * @param {Array<Array<Array<number>>>} coordinates an array of LineStrings
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiLineString>} a MultiLineString feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiLine = turf.multiLineString([[[0,0],[10,10]]]);
     *
     * //=multiLine
     */
    function multiLineString(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        var geom = {
            type: "MultiLineString",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.multiLineString = multiLineString;
    /**
     * Creates a {@link Feature<MultiPoint>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiPoint
     * @param {Array<Array<number>>} coordinates an array of Positions
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiPoint>} a MultiPoint feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiPt = turf.multiPoint([[0,0],[10,10]]);
     *
     * //=multiPt
     */
    function multiPoint(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        var geom = {
            type: "MultiPoint",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.multiPoint = multiPoint;
    /**
     * Creates a {@link Feature<MultiPolygon>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name multiPolygon
     * @param {Array<Array<Array<Array<number>>>>} coordinates an array of Polygons
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<MultiPolygon>} a multipolygon feature
     * @throws {Error} if no coordinates are passed
     * @example
     * var multiPoly = turf.multiPolygon([[[[0,0],[0,10],[10,10],[10,0],[0,0]]]]);
     *
     * //=multiPoly
     *
     */
    function multiPolygon(coordinates, properties, options) {
        if (options === void 0) { options = {}; }
        var geom = {
            type: "MultiPolygon",
            coordinates: coordinates,
        };
        return feature(geom, properties, options);
    }
    exports.multiPolygon = multiPolygon;
    /**
     * Creates a {@link Feature<GeometryCollection>} based on a
     * coordinate array. Properties can be added optionally.
     *
     * @name geometryCollection
     * @param {Array<Geometry>} geometries an array of GeoJSON Geometries
     * @param {Object} [properties={}] an Object of key-value pairs to add as properties
     * @param {Object} [options={}] Optional Parameters
     * @param {Array<number>} [options.bbox] Bounding Box Array [west, south, east, north] associated with the Feature
     * @param {string|number} [options.id] Identifier associated with the Feature
     * @returns {Feature<GeometryCollection>} a GeoJSON GeometryCollection Feature
     * @example
     * var pt = turf.geometry("Point", [100, 0]);
     * var line = turf.geometry("LineString", [[101, 0], [102, 1]]);
     * var collection = turf.geometryCollection([pt, line]);
     *
     * // => collection
     */
    function geometryCollection(geometries, properties, options) {
        if (options === void 0) { options = {}; }
        var geom = {
            type: "GeometryCollection",
            geometries: geometries,
        };
        return feature(geom, properties, options);
    }
    exports.geometryCollection = geometryCollection;
    /**
     * Round number to precision
     *
     * @param {number} num Number
     * @param {number} [precision=0] Precision
     * @returns {number} rounded number
     * @example
     * turf.round(120.4321)
     * //=120
     *
     * turf.round(120.4321, 2)
     * //=120.43
     */
    function round(num, precision) {
        if (precision === void 0) { precision = 0; }
        if (precision && !(precision >= 0)) {
            throw new Error("precision must be a positive number");
        }
        var multiplier = Math.pow(10, precision || 0);
        return Math.round(num * multiplier) / multiplier;
    }
    exports.round = round;
    /**
     * Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @name radiansToLength
     * @param {number} radians in radians across the sphere
     * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} distance
     */
    function radiansToLength(radians, units) {
        if (units === void 0) { units = "kilometers"; }
        var factor = exports.factors[units];
        if (!factor) {
            throw new Error(units + " units is invalid");
        }
        return radians * factor;
    }
    exports.radiansToLength = radiansToLength;
    /**
     * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @name lengthToRadians
     * @param {number} distance in real units
     * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} radians
     */
    function lengthToRadians(distance, units) {
        if (units === void 0) { units = "kilometers"; }
        var factor = exports.factors[units];
        if (!factor) {
            throw new Error(units + " units is invalid");
        }
        return distance / factor;
    }
    exports.lengthToRadians = lengthToRadians;
    /**
     * Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet
     *
     * @name lengthToDegrees
     * @param {number} distance in real units
     * @param {string} [units="kilometers"] can be degrees, radians, miles, or kilometers inches, yards, metres,
     * meters, kilometres, kilometers.
     * @returns {number} degrees
     */
    function lengthToDegrees(distance, units) {
        return radiansToDegrees(lengthToRadians(distance, units));
    }
    exports.lengthToDegrees = lengthToDegrees;
    /**
     * Converts any bearing angle from the north line direction (positive clockwise)
     * and returns an angle between 0-360 degrees (positive clockwise), 0 being the north line
     *
     * @name bearingToAzimuth
     * @param {number} bearing angle, between -180 and +180 degrees
     * @returns {number} angle between 0 and 360 degrees
     */
    function bearingToAzimuth(bearing) {
        var angle = bearing % 360;
        if (angle < 0) {
            angle += 360;
        }
        return angle;
    }
    exports.bearingToAzimuth = bearingToAzimuth;
    /**
     * Converts an angle in radians to degrees
     *
     * @name radiansToDegrees
     * @param {number} radians angle in radians
     * @returns {number} degrees between 0 and 360 degrees
     */
    function radiansToDegrees(radians) {
        var degrees = radians % (2 * Math.PI);
        return degrees * 180 / Math.PI;
    }
    exports.radiansToDegrees = radiansToDegrees;
    /**
     * Converts an angle in degrees to radians
     *
     * @name degreesToRadians
     * @param {number} degrees angle between 0 and 360 degrees
     * @returns {number} angle in radians
     */
    function degreesToRadians(degrees) {
        var radians = degrees % 360;
        return radians * Math.PI / 180;
    }
    exports.degreesToRadians = degreesToRadians;
    /**
     * Converts a length to the requested unit.
     * Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
     *
     * @param {number} length to be converted
     * @param {Units} [originalUnit="kilometers"] of the length
     * @param {Units} [finalUnit="kilometers"] returned unit
     * @returns {number} the converted length
     */
    function convertLength(length, originalUnit, finalUnit) {
        if (originalUnit === void 0) { originalUnit = "kilometers"; }
        if (finalUnit === void 0) { finalUnit = "kilometers"; }
        if (!(length >= 0)) {
            throw new Error("length must be a positive number");
        }
        return radiansToLength(lengthToRadians(length, originalUnit), finalUnit);
    }
    exports.convertLength = convertLength;
    /**
     * Converts a area to the requested unit.
     * Valid units: kilometers, kilometres, meters, metres, centimetres, millimeters, acres, miles, yards, feet, inches
     * @param {number} area to be converted
     * @param {Units} [originalUnit="meters"] of the distance
     * @param {Units} [finalUnit="kilometers"] returned unit
     * @returns {number} the converted distance
     */
    function convertArea(area, originalUnit, finalUnit) {
        if (originalUnit === void 0) { originalUnit = "meters"; }
        if (finalUnit === void 0) { finalUnit = "kilometers"; }
        if (!(area >= 0)) {
            throw new Error("area must be a positive number");
        }
        var startFactor = exports.areaFactors[originalUnit];
        if (!startFactor) {
            throw new Error("invalid original units");
        }
        var finalFactor = exports.areaFactors[finalUnit];
        if (!finalFactor) {
            throw new Error("invalid final units");
        }
        return (area / startFactor) * finalFactor;
    }
    exports.convertArea = convertArea;
    /**
     * isNumber
     *
     * @param {*} num Number to validate
     * @returns {boolean} true/false
     * @example
     * turf.isNumber(123)
     * //=true
     * turf.isNumber('foo')
     * //=false
     */
    function isNumber(num) {
        return !isNaN(num) && num !== null && !Array.isArray(num) && !/^\s*$/.test(num);
    }
    exports.isNumber = isNumber;
    /**
     * isObject
     *
     * @param {*} input variable to validate
     * @returns {boolean} true/false
     * @example
     * turf.isObject({elevation: 10})
     * //=true
     * turf.isObject('foo')
     * //=false
     */
    function isObject(input) {
        return (!!input) && (input.constructor === Object);
    }
    exports.isObject = isObject;
    /**
     * Validate BBox
     *
     * @private
     * @param {Array<number>} bbox BBox to validate
     * @returns {void}
     * @throws Error if BBox is not valid
     * @example
     * validateBBox([-180, -40, 110, 50])
     * //=OK
     * validateBBox([-180, -40])
     * //=Error
     * validateBBox('Foo')
     * //=Error
     * validateBBox(5)
     * //=Error
     * validateBBox(null)
     * //=Error
     * validateBBox(undefined)
     * //=Error
     */
    function validateBBox(bbox) {
        if (!bbox) {
            throw new Error("bbox is required");
        }
        if (!Array.isArray(bbox)) {
            throw new Error("bbox must be an Array");
        }
        if (bbox.length !== 4 && bbox.length !== 6) {
            throw new Error("bbox must be an Array of 4 or 6 numbers");
        }
        bbox.forEach(function (num) {
            if (!isNumber(num)) {
                throw new Error("bbox must only contain numbers");
            }
        });
    }
    exports.validateBBox = validateBBox;
    /**
     * Validate Id
     *
     * @private
     * @param {string|number} id Id to validate
     * @returns {void}
     * @throws Error if Id is not valid
     * @example
     * validateId([-180, -40, 110, 50])
     * //=Error
     * validateId([-180, -40])
     * //=Error
     * validateId('Foo')
     * //=OK
     * validateId(5)
     * //=OK
     * validateId(null)
     * //=Error
     * validateId(undefined)
     * //=Error
     */
    function validateId(id) {
        if (!id) {
            throw new Error("id is required");
        }
        if (["string", "number"].indexOf(typeof id) === -1) {
            throw new Error("id must be a number or a string");
        }
    }
    exports.validateId = validateId;
    // Deprecated methods
    function radians2degrees() {
        throw new Error("method has been renamed to `radiansToDegrees`");
    }
    exports.radians2degrees = radians2degrees;
    function degrees2radians() {
        throw new Error("method has been renamed to `degreesToRadians`");
    }
    exports.degrees2radians = degrees2radians;
    function distanceToDegrees() {
        throw new Error("method has been renamed to `lengthToDegrees`");
    }
    exports.distanceToDegrees = distanceToDegrees;
    function distanceToRadians() {
        throw new Error("method has been renamed to `lengthToRadians`");
    }
    exports.distanceToRadians = distanceToRadians;
    function radiansToDistance() {
        throw new Error("method has been renamed to `radiansToLength`");
    }
    exports.radiansToDistance = radiansToDistance;
    function bearingToAngle() {
        throw new Error("method has been renamed to `bearingToAzimuth`");
    }
    exports.bearingToAngle = bearingToAngle;
    function convertDistance() {
        throw new Error("method has been renamed to `convertLength`");
    }
    exports.convertDistance = convertDistance;
    });

    unwrapExports(helpers);
    var helpers_1 = helpers.earthRadius;
    var helpers_2 = helpers.factors;
    var helpers_3 = helpers.unitsFactors;
    var helpers_4 = helpers.areaFactors;
    var helpers_5 = helpers.feature;
    var helpers_6 = helpers.geometry;
    var helpers_7 = helpers.point;
    var helpers_8 = helpers.points;
    var helpers_9 = helpers.polygon;
    var helpers_10 = helpers.polygons;
    var helpers_11 = helpers.lineString;
    var helpers_12 = helpers.lineStrings;
    var helpers_13 = helpers.featureCollection;
    var helpers_14 = helpers.multiLineString;
    var helpers_15 = helpers.multiPoint;
    var helpers_16 = helpers.multiPolygon;
    var helpers_17 = helpers.geometryCollection;
    var helpers_18 = helpers.round;
    var helpers_19 = helpers.radiansToLength;
    var helpers_20 = helpers.lengthToRadians;
    var helpers_21 = helpers.lengthToDegrees;
    var helpers_22 = helpers.bearingToAzimuth;
    var helpers_23 = helpers.radiansToDegrees;
    var helpers_24 = helpers.degreesToRadians;
    var helpers_25 = helpers.convertLength;
    var helpers_26 = helpers.convertArea;
    var helpers_27 = helpers.isNumber;
    var helpers_28 = helpers.isObject;
    var helpers_29 = helpers.validateBBox;
    var helpers_30 = helpers.validateId;
    var helpers_31 = helpers.radians2degrees;
    var helpers_32 = helpers.degrees2radians;
    var helpers_33 = helpers.distanceToDegrees;
    var helpers_34 = helpers.distanceToRadians;
    var helpers_35 = helpers.radiansToDistance;
    var helpers_36 = helpers.bearingToAngle;
    var helpers_37 = helpers.convertDistance;

    var meta = createCommonjsModule(function (module, exports) {

    Object.defineProperty(exports, '__esModule', { value: true });



    /**
     * Callback for coordEach
     *
     * @callback coordEachCallback
     * @param {Array<number>} currentCoord The current coordinate being processed.
     * @param {number} coordIndex The current index of the coordinate being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     */

    /**
     * Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
     *
     * @name coordEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)
     * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.coordEach(features, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=currentCoord
     *   //=coordIndex
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     * });
     */
    function coordEach(geojson, callback, excludeWrapCoord) {
        // Handles null Geometry -- Skips this GeoJSON
        if (geojson === null) return;
        var j, k, l, geometry, stopG, coords,
            geometryMaybeCollection,
            wrapShrink = 0,
            coordIndex = 0,
            isGeometryCollection,
            type = geojson.type,
            isFeatureCollection = type === 'FeatureCollection',
            isFeature = type === 'Feature',
            stop = isFeatureCollection ? geojson.features.length : 1;

        // This logic may look a little weird. The reason why it is that way
        // is because it's trying to be fast. GeoJSON supports multiple kinds
        // of objects at its root: FeatureCollection, Features, Geometries.
        // This function has the responsibility of handling all of them, and that
        // means that some of the `for` loops you see below actually just don't apply
        // to certain inputs. For instance, if you give this just a
        // Point geometry, then both loops are short-circuited and all we do
        // is gradually rename the input until it's called 'geometry'.
        //
        // This also aims to allocate as few resources as possible: just a
        // few numbers and booleans, rather than any temporary arrays as would
        // be required with the normalization approach.
        for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
            geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :
                (isFeature ? geojson.geometry : geojson));
            isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
            stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;

            for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
                var multiFeatureIndex = 0;
                var geometryIndex = 0;
                geometry = isGeometryCollection ?
                    geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;

                // Handles null Geometry -- Skips this geometry
                if (geometry === null) continue;
                coords = geometry.coordinates;
                var geomType = geometry.type;

                wrapShrink = (excludeWrapCoord && (geomType === 'Polygon' || geomType === 'MultiPolygon')) ? 1 : 0;

                switch (geomType) {
                case null:
                    break;
                case 'Point':
                    if (callback(coords, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                    coordIndex++;
                    multiFeatureIndex++;
                    break;
                case 'LineString':
                case 'MultiPoint':
                    for (j = 0; j < coords.length; j++) {
                        if (callback(coords[j], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                        coordIndex++;
                        if (geomType === 'MultiPoint') multiFeatureIndex++;
                    }
                    if (geomType === 'LineString') multiFeatureIndex++;
                    break;
                case 'Polygon':
                case 'MultiLineString':
                    for (j = 0; j < coords.length; j++) {
                        for (k = 0; k < coords[j].length - wrapShrink; k++) {
                            if (callback(coords[j][k], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                            coordIndex++;
                        }
                        if (geomType === 'MultiLineString') multiFeatureIndex++;
                        if (geomType === 'Polygon') geometryIndex++;
                    }
                    if (geomType === 'Polygon') multiFeatureIndex++;
                    break;
                case 'MultiPolygon':
                    for (j = 0; j < coords.length; j++) {
                        geometryIndex = 0;
                        for (k = 0; k < coords[j].length; k++) {
                            for (l = 0; l < coords[j][k].length - wrapShrink; l++) {
                                if (callback(coords[j][k][l], coordIndex, featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                                coordIndex++;
                            }
                            geometryIndex++;
                        }
                        multiFeatureIndex++;
                    }
                    break;
                case 'GeometryCollection':
                    for (j = 0; j < geometry.geometries.length; j++)
                        if (coordEach(geometry.geometries[j], callback, excludeWrapCoord) === false) return false;
                    break;
                default:
                    throw new Error('Unknown Geometry Type');
                }
            }
        }
    }

    /**
     * Callback for coordReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback coordReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Array<number>} currentCoord The current coordinate being processed.
     * @param {number} coordIndex The current index of the coordinate being processed.
     * Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     */

    /**
     * Reduce coordinates in any GeoJSON object, similar to Array.reduce()
     *
     * @name coordReduce
     * @param {FeatureCollection|Geometry|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentCoord, coordIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @param {boolean} [excludeWrapCoord=false] whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.coordReduce(features, function (previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=previousValue
     *   //=currentCoord
     *   //=coordIndex
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   return currentCoord;
     * });
     */
    function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
        var previousValue = initialValue;
        coordEach(geojson, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
            if (coordIndex === 0 && initialValue === undefined) previousValue = currentCoord;
            else previousValue = callback(previousValue, currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex);
        }, excludeWrapCoord);
        return previousValue;
    }

    /**
     * Callback for propEach
     *
     * @callback propEachCallback
     * @param {Object} currentProperties The current Properties being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Iterate over properties in any GeoJSON object, similar to Array.forEach()
     *
     * @name propEach
     * @param {FeatureCollection|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentProperties, featureIndex)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.propEach(features, function (currentProperties, featureIndex) {
     *   //=currentProperties
     *   //=featureIndex
     * });
     */
    function propEach(geojson, callback) {
        var i;
        switch (geojson.type) {
        case 'FeatureCollection':
            for (i = 0; i < geojson.features.length; i++) {
                if (callback(geojson.features[i].properties, i) === false) break;
            }
            break;
        case 'Feature':
            callback(geojson.properties, 0);
            break;
        }
    }


    /**
     * Callback for propReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback propReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {*} currentProperties The current Properties being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Reduce properties in any GeoJSON object into a single value,
     * similar to how Array.reduce works. However, in this case we lazily run
     * the reduction, so an array of all properties is unnecessary.
     *
     * @name propReduce
     * @param {FeatureCollection|Feature} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentProperties, featureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.propReduce(features, function (previousValue, currentProperties, featureIndex) {
     *   //=previousValue
     *   //=currentProperties
     *   //=featureIndex
     *   return currentProperties
     * });
     */
    function propReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        propEach(geojson, function (currentProperties, featureIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentProperties;
            else previousValue = callback(previousValue, currentProperties, featureIndex);
        });
        return previousValue;
    }

    /**
     * Callback for featureEach
     *
     * @callback featureEachCallback
     * @param {Feature<any>} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Iterate over features in any GeoJSON object, similar to
     * Array.forEach.
     *
     * @name featureEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentFeature, featureIndex)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {foo: 'bar'}),
     *   turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.featureEach(features, function (currentFeature, featureIndex) {
     *   //=currentFeature
     *   //=featureIndex
     * });
     */
    function featureEach(geojson, callback) {
        if (geojson.type === 'Feature') {
            callback(geojson, 0);
        } else if (geojson.type === 'FeatureCollection') {
            for (var i = 0; i < geojson.features.length; i++) {
                if (callback(geojson.features[i], i) === false) break;
            }
        }
    }

    /**
     * Callback for featureReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback featureReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     */

    /**
     * Reduce features in any GeoJSON object, similar to Array.reduce().
     *
     * @name featureReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {"foo": "bar"}),
     *   turf.point([36, 53], {"hello": "world"})
     * ]);
     *
     * turf.featureReduce(features, function (previousValue, currentFeature, featureIndex) {
     *   //=previousValue
     *   //=currentFeature
     *   //=featureIndex
     *   return currentFeature
     * });
     */
    function featureReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        featureEach(geojson, function (currentFeature, featureIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
            else previousValue = callback(previousValue, currentFeature, featureIndex);
        });
        return previousValue;
    }

    /**
     * Get all coordinates from any GeoJSON object.
     *
     * @name coordAll
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @returns {Array<Array<number>>} coordinate position array
     * @example
     * var features = turf.featureCollection([
     *   turf.point([26, 37], {foo: 'bar'}),
     *   turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * var coords = turf.coordAll(features);
     * //= [[26, 37], [36, 53]]
     */
    function coordAll(geojson) {
        var coords = [];
        coordEach(geojson, function (coord) {
            coords.push(coord);
        });
        return coords;
    }

    /**
     * Callback for geomEach
     *
     * @callback geomEachCallback
     * @param {Geometry} currentGeometry The current Geometry being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {Object} featureProperties The current Feature Properties being processed.
     * @param {Array<number>} featureBBox The current Feature BBox being processed.
     * @param {number|string} featureId The current Feature Id being processed.
     */

    /**
     * Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
     *
     * @name geomEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
     * @returns {void}
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.geomEach(features, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
     *   //=currentGeometry
     *   //=featureIndex
     *   //=featureProperties
     *   //=featureBBox
     *   //=featureId
     * });
     */
    function geomEach(geojson, callback) {
        var i, j, g, geometry, stopG,
            geometryMaybeCollection,
            isGeometryCollection,
            featureProperties,
            featureBBox,
            featureId,
            featureIndex = 0,
            isFeatureCollection = geojson.type === 'FeatureCollection',
            isFeature = geojson.type === 'Feature',
            stop = isFeatureCollection ? geojson.features.length : 1;

        // This logic may look a little weird. The reason why it is that way
        // is because it's trying to be fast. GeoJSON supports multiple kinds
        // of objects at its root: FeatureCollection, Features, Geometries.
        // This function has the responsibility of handling all of them, and that
        // means that some of the `for` loops you see below actually just don't apply
        // to certain inputs. For instance, if you give this just a
        // Point geometry, then both loops are short-circuited and all we do
        // is gradually rename the input until it's called 'geometry'.
        //
        // This also aims to allocate as few resources as possible: just a
        // few numbers and booleans, rather than any temporary arrays as would
        // be required with the normalization approach.
        for (i = 0; i < stop; i++) {

            geometryMaybeCollection = (isFeatureCollection ? geojson.features[i].geometry :
                (isFeature ? geojson.geometry : geojson));
            featureProperties = (isFeatureCollection ? geojson.features[i].properties :
                (isFeature ? geojson.properties : {}));
            featureBBox = (isFeatureCollection ? geojson.features[i].bbox :
                (isFeature ? geojson.bbox : undefined));
            featureId = (isFeatureCollection ? geojson.features[i].id :
                (isFeature ? geojson.id : undefined));
            isGeometryCollection = (geometryMaybeCollection) ? geometryMaybeCollection.type === 'GeometryCollection' : false;
            stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;

            for (g = 0; g < stopG; g++) {
                geometry = isGeometryCollection ?
                    geometryMaybeCollection.geometries[g] : geometryMaybeCollection;

                // Handle null Geometry
                if (geometry === null) {
                    if (callback(null, featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    continue;
                }
                switch (geometry.type) {
                case 'Point':
                case 'LineString':
                case 'MultiPoint':
                case 'Polygon':
                case 'MultiLineString':
                case 'MultiPolygon': {
                    if (callback(geometry, featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    break;
                }
                case 'GeometryCollection': {
                    for (j = 0; j < geometry.geometries.length; j++) {
                        if (callback(geometry.geometries[j], featureIndex, featureProperties, featureBBox, featureId) === false) return false;
                    }
                    break;
                }
                default:
                    throw new Error('Unknown Geometry Type');
                }
            }
            // Only increase `featureIndex` per each feature
            featureIndex++;
        }
    }

    /**
     * Callback for geomReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback geomReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Geometry} currentGeometry The current Geometry being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {Object} featureProperties The current Feature Properties being processed.
     * @param {Array<number>} featureBBox The current Feature BBox being processed.
     * @param {number|string} featureId The current Feature Id being processed.
     */

    /**
     * Reduce geometry in any GeoJSON object, similar to Array.reduce().
     *
     * @name geomReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.point([36, 53], {hello: 'world'})
     * ]);
     *
     * turf.geomReduce(features, function (previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
     *   //=previousValue
     *   //=currentGeometry
     *   //=featureIndex
     *   //=featureProperties
     *   //=featureBBox
     *   //=featureId
     *   return currentGeometry
     * });
     */
    function geomReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        geomEach(geojson, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentGeometry;
            else previousValue = callback(previousValue, currentGeometry, featureIndex, featureProperties, featureBBox, featureId);
        });
        return previousValue;
    }

    /**
     * Callback for flattenEach
     *
     * @callback flattenEachCallback
     * @param {Feature} currentFeature The current flattened feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     */

    /**
     * Iterate over flattened features in any GeoJSON object, similar to
     * Array.forEach.
     *
     * @name flattenEach
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (currentFeature, featureIndex, multiFeatureIndex)
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
     * ]);
     *
     * turf.flattenEach(features, function (currentFeature, featureIndex, multiFeatureIndex) {
     *   //=currentFeature
     *   //=featureIndex
     *   //=multiFeatureIndex
     * });
     */
    function flattenEach(geojson, callback) {
        geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) {
            // Callback for single geometry
            var type = (geometry === null) ? null : geometry.type;
            switch (type) {
            case null:
            case 'Point':
            case 'LineString':
            case 'Polygon':
                if (callback(helpers.feature(geometry, properties, {bbox: bbox, id: id}), featureIndex, 0) === false) return false;
                return;
            }

            var geomType;

            // Callback for multi-geometry
            switch (type) {
            case 'MultiPoint':
                geomType = 'Point';
                break;
            case 'MultiLineString':
                geomType = 'LineString';
                break;
            case 'MultiPolygon':
                geomType = 'Polygon';
                break;
            }

            for (var multiFeatureIndex = 0; multiFeatureIndex < geometry.coordinates.length; multiFeatureIndex++) {
                var coordinate = geometry.coordinates[multiFeatureIndex];
                var geom = {
                    type: geomType,
                    coordinates: coordinate
                };
                if (callback(helpers.feature(geom, properties), featureIndex, multiFeatureIndex) === false) return false;
            }
        });
    }

    /**
     * Callback for flattenReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback flattenReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature} currentFeature The current Feature being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     */

    /**
     * Reduce flattened features in any GeoJSON object, similar to Array.reduce().
     *
     * @name flattenReduce
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON object
     * @param {Function} callback a method that takes (previousValue, currentFeature, featureIndex, multiFeatureIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var features = turf.featureCollection([
     *     turf.point([26, 37], {foo: 'bar'}),
     *     turf.multiPoint([[40, 30], [36, 53]], {hello: 'world'})
     * ]);
     *
     * turf.flattenReduce(features, function (previousValue, currentFeature, featureIndex, multiFeatureIndex) {
     *   //=previousValue
     *   //=currentFeature
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   return currentFeature
     * });
     */
    function flattenReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        flattenEach(geojson, function (currentFeature, featureIndex, multiFeatureIndex) {
            if (featureIndex === 0 && multiFeatureIndex === 0 && initialValue === undefined) previousValue = currentFeature;
            else previousValue = callback(previousValue, currentFeature, featureIndex, multiFeatureIndex);
        });
        return previousValue;
    }

    /**
     * Callback for segmentEach
     *
     * @callback segmentEachCallback
     * @param {Feature<LineString>} currentSegment The current Segment being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     * @param {number} segmentIndex The current index of the Segment being processed.
     * @returns {void}
     */

    /**
     * Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()
     * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON
     * @param {Function} callback a method that takes (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex)
     * @returns {void}
     * @example
     * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
     *
     * // Iterate over GeoJSON by 2-vertex segments
     * turf.segmentEach(polygon, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
     *   //=currentSegment
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   //=segmentIndex
     * });
     *
     * // Calculate the total number of segments
     * var total = 0;
     * turf.segmentEach(polygon, function () {
     *     total++;
     * });
     */
    function segmentEach(geojson, callback) {
        flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {
            var segmentIndex = 0;

            // Exclude null Geometries
            if (!feature.geometry) return;
            // (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
            var type = feature.geometry.type;
            if (type === 'Point' || type === 'MultiPoint') return;

            // Generate 2-vertex line segments
            var previousCoords;
            var previousFeatureIndex = 0;
            var previousMultiIndex = 0;
            var prevGeomIndex = 0;
            if (coordEach(feature, function (currentCoord, coordIndex, featureIndexCoord, multiPartIndexCoord, geometryIndex) {
                // Simulating a meta.coordReduce() since `reduce` operations cannot be stopped by returning `false`
                if (previousCoords === undefined || featureIndex > previousFeatureIndex || multiPartIndexCoord > previousMultiIndex || geometryIndex > prevGeomIndex) {
                    previousCoords = currentCoord;
                    previousFeatureIndex = featureIndex;
                    previousMultiIndex = multiPartIndexCoord;
                    prevGeomIndex = geometryIndex;
                    segmentIndex = 0;
                    return;
                }
                var currentSegment = helpers.lineString([previousCoords, currentCoord], feature.properties);
                if (callback(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) === false) return false;
                segmentIndex++;
                previousCoords = currentCoord;
            }) === false) return false;
        });
    }

    /**
     * Callback for segmentReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback segmentReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature<LineString>} currentSegment The current Segment being processed.
     * @param {number} featureIndex The current index of the Feature being processed.
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed.
     * @param {number} geometryIndex The current index of the Geometry being processed.
     * @param {number} segmentIndex The current index of the Segment being processed.
     */

    /**
     * Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()
     * (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson any GeoJSON
     * @param {Function} callback a method that takes (previousValue, currentSegment, currentIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {void}
     * @example
     * var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
     *
     * // Iterate over GeoJSON by 2-vertex segments
     * turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
     *   //= previousSegment
     *   //= currentSegment
     *   //= featureIndex
     *   //= multiFeatureIndex
     *   //= geometryIndex
     *   //= segmentInex
     *   return currentSegment
     * });
     *
     * // Calculate the total number of segments
     * var initialValue = 0
     * var total = turf.segmentReduce(polygon, function (previousValue) {
     *     previousValue++;
     *     return previousValue;
     * }, initialValue);
     */
    function segmentReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        var started = false;
        segmentEach(geojson, function (currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) {
            if (started === false && initialValue === undefined) previousValue = currentSegment;
            else previousValue = callback(previousValue, currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex);
            started = true;
        });
        return previousValue;
    }

    /**
     * Callback for lineEach
     *
     * @callback lineEachCallback
     * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed
     * @param {number} featureIndex The current index of the Feature being processed
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed
     * @param {number} geometryIndex The current index of the Geometry being processed
     */

    /**
     * Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,
     * similar to Array.forEach.
     *
     * @name lineEach
     * @param {Geometry|Feature<LineString|Polygon|MultiLineString|MultiPolygon>} geojson object
     * @param {Function} callback a method that takes (currentLine, featureIndex, multiFeatureIndex, geometryIndex)
     * @example
     * var multiLine = turf.multiLineString([
     *   [[26, 37], [35, 45]],
     *   [[36, 53], [38, 50], [41, 55]]
     * ]);
     *
     * turf.lineEach(multiLine, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=currentLine
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     * });
     */
    function lineEach(geojson, callback) {
        // validation
        if (!geojson) throw new Error('geojson is required');

        flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {
            if (feature.geometry === null) return;
            var type = feature.geometry.type;
            var coords = feature.geometry.coordinates;
            switch (type) {
            case 'LineString':
                if (callback(feature, featureIndex, multiFeatureIndex, 0, 0) === false) return false;
                break;
            case 'Polygon':
                for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
                    if (callback(helpers.lineString(coords[geometryIndex], feature.properties), featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
                }
                break;
            }
        });
    }

    /**
     * Callback for lineReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback lineReduceCallback
     * @param {*} previousValue The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {Feature<LineString>} currentLine The current LineString|LinearRing being processed.
     * @param {number} featureIndex The current index of the Feature being processed
     * @param {number} multiFeatureIndex The current index of the Multi-Feature being processed
     * @param {number} geometryIndex The current index of the Geometry being processed
     */

    /**
     * Reduce features in any GeoJSON object, similar to Array.reduce().
     *
     * @name lineReduce
     * @param {Geometry|Feature<LineString|Polygon|MultiLineString|MultiPolygon>} geojson object
     * @param {Function} callback a method that takes (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var multiPoly = turf.multiPolygon([
     *   turf.polygon([[[12,48],[2,41],[24,38],[12,48]], [[9,44],[13,41],[13,45],[9,44]]]),
     *   turf.polygon([[[5, 5], [0, 0], [2, 2], [4, 4], [5, 5]]])
     * ]);
     *
     * turf.lineReduce(multiPoly, function (previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
     *   //=previousValue
     *   //=currentLine
     *   //=featureIndex
     *   //=multiFeatureIndex
     *   //=geometryIndex
     *   return currentLine
     * });
     */
    function lineReduce(geojson, callback, initialValue) {
        var previousValue = initialValue;
        lineEach(geojson, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {
            if (featureIndex === 0 && initialValue === undefined) previousValue = currentLine;
            else previousValue = callback(previousValue, currentLine, featureIndex, multiFeatureIndex, geometryIndex);
        });
        return previousValue;
    }

    /**
     * Finds a particular 2-vertex LineString Segment from a GeoJSON using `@turf/meta` indexes.
     *
     * Negative indexes are permitted.
     * Point & MultiPoint will always return null.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.featureIndex=0] Feature Index
     * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index
     * @param {number} [options.geometryIndex=0] Geometry Index
     * @param {number} [options.segmentIndex=0] Segment Index
     * @param {Object} [options.properties={}] Translate Properties to output LineString
     * @param {BBox} [options.bbox={}] Translate BBox to output LineString
     * @param {number|string} [options.id={}] Translate Id to output LineString
     * @returns {Feature<LineString>} 2-vertex GeoJSON Feature LineString
     * @example
     * var multiLine = turf.multiLineString([
     *     [[10, 10], [50, 30], [30, 40]],
     *     [[-10, -10], [-50, -30], [-30, -40]]
     * ]);
     *
     * // First Segment (defaults are 0)
     * turf.findSegment(multiLine);
     * // => Feature<LineString<[[10, 10], [50, 30]]>>
     *
     * // First Segment of 2nd Multi Feature
     * turf.findSegment(multiLine, {multiFeatureIndex: 1});
     * // => Feature<LineString<[[-10, -10], [-50, -30]]>>
     *
     * // Last Segment of Last Multi Feature
     * turf.findSegment(multiLine, {multiFeatureIndex: -1, segmentIndex: -1});
     * // => Feature<LineString<[[-50, -30], [-30, -40]]>>
     */
    function findSegment(geojson, options) {
        // Optional Parameters
        options = options || {};
        if (!helpers.isObject(options)) throw new Error('options is invalid');
        var featureIndex = options.featureIndex || 0;
        var multiFeatureIndex = options.multiFeatureIndex || 0;
        var geometryIndex = options.geometryIndex || 0;
        var segmentIndex = options.segmentIndex || 0;

        // Find FeatureIndex
        var properties = options.properties;
        var geometry;

        switch (geojson.type) {
        case 'FeatureCollection':
            if (featureIndex < 0) featureIndex = geojson.features.length + featureIndex;
            properties = properties || geojson.features[featureIndex].properties;
            geometry = geojson.features[featureIndex].geometry;
            break;
        case 'Feature':
            properties = properties || geojson.properties;
            geometry = geojson.geometry;
            break;
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
        case 'Polygon':
        case 'MultiLineString':
        case 'MultiPolygon':
            geometry = geojson;
            break;
        default:
            throw new Error('geojson is invalid');
        }

        // Find SegmentIndex
        if (geometry === null) return null;
        var coords = geometry.coordinates;
        switch (geometry.type) {
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
            if (segmentIndex < 0) segmentIndex = coords.length + segmentIndex - 1;
            return helpers.lineString([coords[segmentIndex], coords[segmentIndex + 1]], properties, options);
        case 'Polygon':
            if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
            if (segmentIndex < 0) segmentIndex = coords[geometryIndex].length + segmentIndex - 1;
            return helpers.lineString([coords[geometryIndex][segmentIndex], coords[geometryIndex][segmentIndex + 1]], properties, options);
        case 'MultiLineString':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;
            return helpers.lineString([coords[multiFeatureIndex][segmentIndex], coords[multiFeatureIndex][segmentIndex + 1]], properties, options);
        case 'MultiPolygon':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (geometryIndex < 0) geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
            if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;
            return helpers.lineString([coords[multiFeatureIndex][geometryIndex][segmentIndex], coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]], properties, options);
        }
        throw new Error('geojson is invalid');
    }

    /**
     * Finds a particular Point from a GeoJSON using `@turf/meta` indexes.
     *
     * Negative indexes are permitted.
     *
     * @param {FeatureCollection|Feature|Geometry} geojson Any GeoJSON Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.featureIndex=0] Feature Index
     * @param {number} [options.multiFeatureIndex=0] Multi-Feature Index
     * @param {number} [options.geometryIndex=0] Geometry Index
     * @param {number} [options.coordIndex=0] Coord Index
     * @param {Object} [options.properties={}] Translate Properties to output Point
     * @param {BBox} [options.bbox={}] Translate BBox to output Point
     * @param {number|string} [options.id={}] Translate Id to output Point
     * @returns {Feature<Point>} 2-vertex GeoJSON Feature Point
     * @example
     * var multiLine = turf.multiLineString([
     *     [[10, 10], [50, 30], [30, 40]],
     *     [[-10, -10], [-50, -30], [-30, -40]]
     * ]);
     *
     * // First Segment (defaults are 0)
     * turf.findPoint(multiLine);
     * // => Feature<Point<[10, 10]>>
     *
     * // First Segment of the 2nd Multi-Feature
     * turf.findPoint(multiLine, {multiFeatureIndex: 1});
     * // => Feature<Point<[-10, -10]>>
     *
     * // Last Segment of last Multi-Feature
     * turf.findPoint(multiLine, {multiFeatureIndex: -1, coordIndex: -1});
     * // => Feature<Point<[-30, -40]>>
     */
    function findPoint(geojson, options) {
        // Optional Parameters
        options = options || {};
        if (!helpers.isObject(options)) throw new Error('options is invalid');
        var featureIndex = options.featureIndex || 0;
        var multiFeatureIndex = options.multiFeatureIndex || 0;
        var geometryIndex = options.geometryIndex || 0;
        var coordIndex = options.coordIndex || 0;

        // Find FeatureIndex
        var properties = options.properties;
        var geometry;

        switch (geojson.type) {
        case 'FeatureCollection':
            if (featureIndex < 0) featureIndex = geojson.features.length + featureIndex;
            properties = properties || geojson.features[featureIndex].properties;
            geometry = geojson.features[featureIndex].geometry;
            break;
        case 'Feature':
            properties = properties || geojson.properties;
            geometry = geojson.geometry;
            break;
        case 'Point':
        case 'MultiPoint':
            return null;
        case 'LineString':
        case 'Polygon':
        case 'MultiLineString':
        case 'MultiPolygon':
            geometry = geojson;
            break;
        default:
            throw new Error('geojson is invalid');
        }

        // Find Coord Index
        if (geometry === null) return null;
        var coords = geometry.coordinates;
        switch (geometry.type) {
        case 'Point':
            return helpers.point(coords, properties, options);
        case 'MultiPoint':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            return helpers.point(coords[multiFeatureIndex], properties, options);
        case 'LineString':
            if (coordIndex < 0) coordIndex = coords.length + coordIndex;
            return helpers.point(coords[coordIndex], properties, options);
        case 'Polygon':
            if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
            if (coordIndex < 0) coordIndex = coords[geometryIndex].length + coordIndex;
            return helpers.point(coords[geometryIndex][coordIndex], properties, options);
        case 'MultiLineString':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (coordIndex < 0) coordIndex = coords[multiFeatureIndex].length + coordIndex;
            return helpers.point(coords[multiFeatureIndex][coordIndex], properties, options);
        case 'MultiPolygon':
            if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
            if (geometryIndex < 0) geometryIndex = coords[multiFeatureIndex].length + geometryIndex;
            if (coordIndex < 0) coordIndex = coords[multiFeatureIndex][geometryIndex].length - coordIndex;
            return helpers.point(coords[multiFeatureIndex][geometryIndex][coordIndex], properties, options);
        }
        throw new Error('geojson is invalid');
    }

    exports.coordEach = coordEach;
    exports.coordReduce = coordReduce;
    exports.propEach = propEach;
    exports.propReduce = propReduce;
    exports.featureEach = featureEach;
    exports.featureReduce = featureReduce;
    exports.coordAll = coordAll;
    exports.geomEach = geomEach;
    exports.geomReduce = geomReduce;
    exports.flattenEach = flattenEach;
    exports.flattenReduce = flattenReduce;
    exports.segmentEach = segmentEach;
    exports.segmentReduce = segmentReduce;
    exports.lineEach = lineEach;
    exports.lineReduce = lineReduce;
    exports.findSegment = findSegment;
    exports.findPoint = findPoint;
    });

    var index$4 = unwrapExports(meta);
    var meta_1 = meta.coordEach;
    var meta_2 = meta.coordReduce;
    var meta_3 = meta.propEach;
    var meta_4 = meta.propReduce;
    var meta_5 = meta.featureEach;
    var meta_6 = meta.featureReduce;
    var meta_7 = meta.coordAll;
    var meta_8 = meta.geomEach;
    var meta_9 = meta.geomReduce;
    var meta_10 = meta.flattenEach;
    var meta_11 = meta.flattenReduce;
    var meta_12 = meta.segmentEach;
    var meta_13 = meta.segmentReduce;
    var meta_14 = meta.lineEach;
    var meta_15 = meta.lineReduce;
    var meta_16 = meta.findSegment;
    var meta_17 = meta.findPoint;

    var meta$1 = /*#__PURE__*/Object.freeze({
        default: index$4,
        __moduleExports: meta,
        coordEach: meta_1,
        coordReduce: meta_2,
        propEach: meta_3,
        propReduce: meta_4,
        featureEach: meta_5,
        featureReduce: meta_6,
        coordAll: meta_7,
        geomEach: meta_8,
        geomReduce: meta_9,
        flattenEach: meta_10,
        flattenReduce: meta_11,
        segmentEach: meta_12,
        segmentReduce: meta_13,
        lineEach: meta_14,
        lineReduce: meta_15,
        findSegment: meta_16,
        findPoint: meta_17
    });

    var meta_1$1 = ( meta$1 && index$4 ) || meta$1;

    var bbox_1 = createCommonjsModule(function (module, exports) {
    Object.defineProperty(exports, "__esModule", { value: true });

    /**
     * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
     *
     * @name bbox
     * @param {GeoJSON} geojson any GeoJSON object
     * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
     * @example
     * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
     * var bbox = turf.bbox(line);
     * var bboxPolygon = turf.bboxPolygon(bbox);
     *
     * //addToMap
     * var addToMap = [line, bboxPolygon]
     */
    function bbox(geojson) {
        var result = [Infinity, Infinity, -Infinity, -Infinity];
        meta_1$1.coordEach(geojson, function (coord) {
            if (result[0] > coord[0]) {
                result[0] = coord[0];
            }
            if (result[1] > coord[1]) {
                result[1] = coord[1];
            }
            if (result[2] < coord[0]) {
                result[2] = coord[0];
            }
            if (result[3] < coord[1]) {
                result[3] = coord[1];
            }
        });
        return result;
    }
    exports.default = bbox;
    });

    var index$5 = unwrapExports(bbox_1);

    var bbox$2 = /*#__PURE__*/Object.freeze({
        default: index$5,
        __moduleExports: bbox_1
    });

    var require$$0$2 = ( bbox$2 && index$5 ) || bbox$2;

    var turfBBox = require$$0$2.default;
    var featureEach$1 = meta_1$1.featureEach;
    var coordEach$1 = meta_1$1.coordEach;
    var polygon$1 = helpers.polygon;
    var featureCollection$1 = helpers.featureCollection;

    /**
     * GeoJSON implementation of [RBush](https://github.com/mourner/rbush#rbush) spatial index.
     *
     * @name rbush
     * @param {number} [maxEntries=9] defines the maximum number of entries in a tree node. 9 (used by default) is a
     * reasonable choice for most applications. Higher value means faster insertion and slower search, and vice versa.
     * @returns {RBush} GeoJSON RBush
     * @example
     * var geojsonRbush = require('geojson-rbush').default;
     * var tree = geojsonRbush();
     */
    function geojsonRbush(maxEntries) {
        var tree = rbush_1(maxEntries);
        /**
         * [insert](https://github.com/mourner/rbush#data-format)
         *
         * @param {Feature} feature insert single GeoJSON Feature
         * @returns {RBush} GeoJSON RBush
         * @example
         * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
         * tree.insert(poly)
         */
        tree.insert = function (feature) {
            if (feature.type !== 'Feature') throw new Error('invalid feature');
            feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
            return rbush_1.prototype.insert.call(this, feature);
        };

        /**
         * [load](https://github.com/mourner/rbush#bulk-inserting-data)
         *
         * @param {FeatureCollection|Array<Feature>} features load entire GeoJSON FeatureCollection
         * @returns {RBush} GeoJSON RBush
         * @example
         * var polys = turf.polygons([
         *     [[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]],
         *     [[[-93, 32], [-83, 32], [-83, 39], [-93, 39], [-93, 32]]]
         * ]);
         * tree.load(polys);
         */
        tree.load = function (features) {
            var load = [];
            // Load an Array of Features
            if (Array.isArray(features)) {
                features.forEach(function (feature) {
                    if (feature.type !== 'Feature') throw new Error('invalid features');
                    feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
                    load.push(feature);
                });
            } else {
                // Load a FeatureCollection
                featureEach$1(features, function (feature) {
                    if (feature.type !== 'Feature') throw new Error('invalid features');
                    feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
                    load.push(feature);
                });
            }
            return rbush_1.prototype.load.call(this, load);
        };

        /**
         * [remove](https://github.com/mourner/rbush#removing-data)
         *
         * @param {Feature} feature remove single GeoJSON Feature
         * @param {Function} equals Pass a custom equals function to compare by value for removal.
         * @returns {RBush} GeoJSON RBush
         * @example
         * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
         *
         * tree.remove(poly);
         */
        tree.remove = function (feature, equals) {
            if (feature.type !== 'Feature') throw new Error('invalid feature');
            feature.bbox = feature.bbox ? feature.bbox : turfBBox(feature);
            return rbush_1.prototype.remove.call(this, feature, equals);
        };

        /**
         * [clear](https://github.com/mourner/rbush#removing-data)
         *
         * @returns {RBush} GeoJSON Rbush
         * @example
         * tree.clear()
         */
        tree.clear = function () {
            return rbush_1.prototype.clear.call(this);
        };

        /**
         * [search](https://github.com/mourner/rbush#search)
         *
         * @param {BBox|FeatureCollection|Feature} geojson search with GeoJSON
         * @returns {FeatureCollection} all features that intersects with the given GeoJSON.
         * @example
         * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
         *
         * tree.search(poly);
         */
        tree.search = function (geojson) {
            var features = rbush_1.prototype.search.call(this, this.toBBox(geojson));
            return featureCollection$1(features);
        };

        /**
         * [collides](https://github.com/mourner/rbush#collisions)
         *
         * @param {BBox|FeatureCollection|Feature} geojson collides with GeoJSON
         * @returns {boolean} true if there are any items intersecting the given GeoJSON, otherwise false.
         * @example
         * var poly = turf.polygon([[[-78, 41], [-67, 41], [-67, 48], [-78, 48], [-78, 41]]]);
         *
         * tree.collides(poly);
         */
        tree.collides = function (geojson) {
            return rbush_1.prototype.collides.call(this, this.toBBox(geojson));
        };

        /**
         * [all](https://github.com/mourner/rbush#search)
         *
         * @returns {FeatureCollection} all the features in RBush
         * @example
         * tree.all()
         */
        tree.all = function () {
            var features = rbush_1.prototype.all.call(this);
            return featureCollection$1(features);
        };

        /**
         * [toJSON](https://github.com/mourner/rbush#export-and-import)
         *
         * @returns {any} export data as JSON object
         * @example
         * var exported = tree.toJSON()
         */
        tree.toJSON = function () {
            return rbush_1.prototype.toJSON.call(this);
        };

        /**
         * [fromJSON](https://github.com/mourner/rbush#export-and-import)
         *
         * @param {any} json import previously exported data
         * @returns {RBush} GeoJSON RBush
         * @example
         * var exported = {
         *   "children": [
         *     {
         *       "type": "Feature",
         *       "geometry": {
         *         "type": "Point",
         *         "coordinates": [110, 50]
         *       },
         *       "properties": {},
         *       "bbox": [110, 50, 110, 50]
         *     }
         *   ],
         *   "height": 1,
         *   "leaf": true,
         *   "minX": 110,
         *   "minY": 50,
         *   "maxX": 110,
         *   "maxY": 50
         * }
         * tree.fromJSON(exported)
         */
        tree.fromJSON = function (json) {
            return rbush_1.prototype.fromJSON.call(this, json);
        };

        /**
         * Converts GeoJSON to {minX, minY, maxX, maxY} schema
         *
         * @private
         * @param {BBox|FeatureCollection|Feature} geojson feature(s) to retrieve BBox from
         * @returns {Object} converted to {minX, minY, maxX, maxY}
         */
        tree.toBBox = function (geojson) {
            var bbox;
            if (geojson.bbox) bbox = geojson.bbox;
            else if (Array.isArray(geojson) && geojson.length === 4) bbox = geojson;
            else if (Array.isArray(geojson) && geojson.length === 6) bbox = [geojson[0], geojson[1], geojson[3], geojson[4]];
            else if (geojson.type === 'Feature') bbox = turfBBox(geojson);
            else if (geojson.type === 'FeatureCollection') bbox = turfBBox(geojson);
            else throw new Error('invalid geojson')

            return {
                minX: bbox[0],
                minY: bbox[1],
                maxX: bbox[2],
                maxY: bbox[3]
            };
        };
        return tree;
    }

    var geojsonRbush_1 = geojsonRbush;
    var default_1$4 = geojsonRbush;
    geojsonRbush_1.default = default_1$4;

    /**
     * Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
     *
     * @name lineIntersect
     * @param {GeoJSON} line1 any LineString or Polygon
     * @param {GeoJSON} line2 any LineString or Polygon
     * @returns {FeatureCollection<Point>} point(s) that intersect both
     * @example
     * var line1 = turf.lineString([[126, -11], [129, -21]]);
     * var line2 = turf.lineString([[123, -18], [131, -14]]);
     * var intersects = turf.lineIntersect(line1, line2);
     *
     * //addToMap
     * var addToMap = [line1, line2, intersects]
     */
    function lineIntersect(line1, line2) {
        const unique = {};
        const results = [];

        // First, normalize geometries to features
        // Then, handle simple 2-vertex segments
        if (line1.type === 'LineString') { line1 = feature(line1); }
        if (line2.type === 'LineString') { line2 = feature(line2); }
        if (line1.type === 'Feature' &&
            line2.type === 'Feature' &&
            line1.geometry !== null &&
            line2.geometry !== null &&
            line1.geometry.type === 'LineString' &&
            line2.geometry.type === 'LineString' &&
            line1.geometry.coordinates.length === 2 &&
            line2.geometry.coordinates.length === 2) {
            const intersect = intersects$3(line1, line2);
            if (intersect) { results.push(intersect); }
            return featureCollection(results);
        }

        // Handles complex GeoJSON Geometries
        const tree = geojsonRbush_1();
        tree.load(lineSegment(line2));
        featureEach(lineSegment(line1), function (segment)  {
            featureEach(tree.search(segment), function (match) {
                const intersect = intersects$3(segment, match);
                if (intersect) {
                    // prevent duplicate points https://github.com/Turfjs/turf/issues/688
                    const key = getCoords(intersect).join(',');
                    if (!unique[key]) {
                        unique[key] = true;
                        results.push(intersect);
                    }
                }
            });
        });
        return featureCollection(results);
    }

    /**
     * Find a point that intersects LineStrings with two coordinates each
     *
     * @private
     * @param {Feature<LineString>} line1 GeoJSON LineString (Must only contain 2 coordinates)
     * @param {Feature<LineString>} line2 GeoJSON LineString (Must only contain 2 coordinates)
     * @returns {Feature<Point>} intersecting GeoJSON Point
     */
    function intersects$3(line1, line2) {
        const coords1 = getCoords(line1);
        const coords2 = getCoords(line2);
        if (coords1.length !== 2) {
            throw new Error('<intersects> line1 must only contain 2 coordinates');
        }
        if (coords2.length !== 2) {
            throw new Error('<intersects> line2 must only contain 2 coordinates');
        }
        const x1 = coords1[0][0];
        const y1 = coords1[0][1];
        const x2 = coords1[1][0];
        const y2 = coords1[1][1];
        const x3 = coords2[0][0];
        const y3 = coords2[0][1];
        const x4 = coords2[1][0];
        const y4 = coords2[1][1];
        const denom = ((y4 - y3) * (x2 - x1)) - ((x4 - x3) * (y2 - y1));
        const numeA = ((x4 - x3) * (y1 - y3)) - ((y4 - y3) * (x1 - x3));
        const numeB = ((x2 - x1) * (y1 - y3)) - ((y2 - y1) * (x1 - x3));

        if (denom === 0) {
            if (numeA === 0 && numeB === 0) {
                return null;
            }
            return null;
        }

        const uA = numeA / denom;
        const uB = numeB / denom;

        if (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1) {
            const x = x1 + (uA * (x2 - x1));
            const y = y1 + (uA * (y2 - y1));
            return point([x, y]);
        }
        return null;
    }

    /**
     * Takes a {@link Point} and a {@link LineString} and calculates the closest Point on the (Multi)LineString.
     *
     * @name nearestPointOnLine
     * @param {Geometry|Feature<LineString|MultiLineString>} lines lines to snap to
     * @param {Geometry|Feature<Point>|number[]} pt point to snap from
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
     * @returns {Feature<Point>} closest point on the `line` to `point`. The properties object will contain three values: `index`: closest point was found on nth line part, `dist`: distance between pt and the closest point, `location`: distance along the line between start and the closest point.
     * @example
     * var line = turf.lineString([
     *     [-77.031669, 38.878605],
     *     [-77.029609, 38.881946],
     *     [-77.020339, 38.884084],
     *     [-77.025661, 38.885821],
     *     [-77.021884, 38.889563],
     *     [-77.019824, 38.892368]
     * ]);
     * var pt = turf.point([-77.037076, 38.884017]);
     *
     * var snapped = turf.nearestPointOnLine(line, pt, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [line, pt, snapped];
     * snapped.properties['marker-color'] = '#00f';
     */
    function nearestPointOnLine(lines, pt, options) {
        let closestPt = point([Infinity, Infinity], {
            dist: Infinity
        });

        let length = 0.0;
        flattenEach(lines, function (line) {
            const coords = getCoords(line);

            for (let i = 0; i < coords.length - 1; i++) {
                //start
                const start = point(coords[i]);
                start.properties.dist = distance(pt, start, options);
                //stop
                const stop = point(coords[i + 1]);
                stop.properties.dist = distance(pt, stop, options);
                // sectionLength
                const sectionLength = distance(start, stop, options);
                //perpendicular
                const heightDistance = Math.max(start.properties.dist, stop.properties.dist);
                const direction = bearing(start, stop);
                const perpendicularPt1 = destination(pt, heightDistance, direction + 90, options);
                const perpendicularPt2 = destination(pt, heightDistance, direction - 90, options);
                const intersect = lineIntersect(
                    lineString([perpendicularPt1.geometry.coordinates, perpendicularPt2.geometry.coordinates]),
                    lineString([start.geometry.coordinates, stop.geometry.coordinates])
                );
                let intersectPt = null;
                if (intersect.features.length > 0) {
                    intersectPt = intersect.features[0];
                    intersectPt.properties.dist = distance(pt, intersectPt, options);
                    intersectPt.properties.location = length + distance(start, intersectPt, options);
                }

                if (start.properties.dist < closestPt.properties.dist) {
                    closestPt = start;
                    closestPt.properties.index = i;
                    closestPt.properties.location = length;
                }
                if (stop.properties.dist < closestPt.properties.dist) {
                    closestPt = stop;
                    closestPt.properties.index = i + 1;
                    closestPt.properties.location = length + sectionLength;
                }
                if (intersectPt && intersectPt.properties.dist < closestPt.properties.dist) {
                    closestPt = intersectPt;
                    closestPt.properties.index = i;
                }
                // update length
                length += sectionLength;
            }

        });

        return closestPt;
    }

    // https://en.wikipedia.org/wiki/Rhumb_line

    /**
     * Calculates the distance along a rhumb line between two {@link Point|points} in degrees, radians,
     * miles, or kilometers.
     *
     * @name rhumbDistance
     * @param {Coord} from origin point
     * @param {Coord} to destination point
     * @param {Object} [options] Optional parameters
     * @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
     * @returns {number} distance between the two points
     * @example
     * var from = turf.point([-75.343, 39.984]);
     * var to = turf.point([-75.534, 39.123]);
     * var options = {units: 'miles'};
     *
     * var distance = turf.rhumbDistance(from, to, options);
     *
     * //addToMap
     * var addToMap = [from, to];
     * from.properties.distance = distance;
     * to.properties.distance = distance;
     */
    function rhumbDistance(from, to, options) {
        options = checkIfOptionsExist(options);
        const origin = getCoord(from);
        const destination = getCoord(to);

        // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)
        // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678
        destination[0] += (destination[0] - origin[0] > 180) ? -360 : (origin[0] - destination[0] > 180) ? 360 : 0;
        const distanceInMeters = calculateRhumbDistance(origin, destination);
        const distance = convertLength(distanceInMeters, "meters", options.units);
        return distance;
    }

    /**
     * Returns the distance travelling from ‘this’ point to destination point along a rhumb line.
     * Adapted from Geodesy: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
     *
     * @private
     * @param   {Array<number>} origin point.
     * @param   {Array<number>} destination point.
     * @param   {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).
     * @returns {number} Distance in km between this point and destination point (same units as radius).
     *
     * @example
     *     var p1 = new LatLon(51.127, 1.338);
     *     var p2 = new LatLon(50.964, 1.853);
     *     var d = p1.distanceTo(p2); // 40.31 km
     */
    function calculateRhumbDistance(origin, destination, radius) {
        // φ => phi
        // λ => lambda
        // ψ => psi
        // Δ => Delta
        // δ => delta
        // θ => theta

        radius = (radius === undefined) ? earthRadius : Number(radius);
        // see www.edwilliams.org/avform.htm#Rhumb

        const R = radius;
        const phi1 = origin[1] * Math.PI / 180;
        const phi2 = destination[1] * Math.PI / 180;
        const DeltaPhi = phi2 - phi1;
        let DeltaLambda = Math.abs(destination[0] - origin[0]) * Math.PI / 180;
        // if dLon over 180° take shorter rhumb line across the anti-meridian:
        if (DeltaLambda > Math.PI) { DeltaLambda -= 2 * Math.PI; }

        // on Mercator projection, longitude distances shrink by latitude; q is the 'stretch factor'
        // q becomes ill-conditioned along E-W line (0/0); use empirical tolerance to avoid it
        const DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
        const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);

        // distance is pythagoras on 'stretched' Mercator projection
        const delta = Math.sqrt(DeltaPhi * DeltaPhi + q * q * DeltaLambda * DeltaLambda); // angular distance in radians
        const dist = delta * R;

        return dist;
    }

    // Taken from http://geomalgorithms.com/a02-_lines.html

    /**
     * Returns the minimum distance between a {@link Point} and a {@link LineString}, being the distance from a line the
     * minimum distance between the point and any segment of the `LineString`.
     *
     * @name pointToLineDistance
     * @param {Feature<Point>|Array<number>} pt Feature or Geometry
     * @param {Feature<LineString>} line GeoJSON Feature or Geometry
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be anything supported by turf/convertLength
     * (ex: degrees, radians, miles, or kilometers)
     * @param {string} [options.method='geodesic'] wether to calculate the distance based on geodesic (spheroid) or
     * planar (flat) method. Valid options are 'geodesic' or 'planar'.
     * @returns {number} distance between point and line
     * @example
     * var pt = turf.point([0, 0]);
     * var line = turf.lineString([[1, 1],[-1, 1]]);
     *
     * var distance = turf.pointToLineDistance(pt, line, {units: 'miles'});
     * //=69.11854715938406
     */
    function pointToLineDistance(pt, line, options) {

        options = checkIfOptionsExist(options);

        // Optional parameters
        if (!options.method) { options.method = 'geodesic'; }
        if (!options.units) { options.units = 'kilometers'; }

        // validation
        if (!pt) { throw new Error('pt is required'); }
        if (Array.isArray(pt)) {
            pt = point(pt);
        } else if (pt.type === 'Point') {
            pt = feature(pt);
        } else { featureOf(pt, 'Point', 'point'); }

        if (!line) { throw new Error('line is required'); }
        if (Array.isArray(line)) {
            line = lineString(line);
        } else if (line.type === 'LineString') {
            line = feature(line);
        } else {
            featureOf(line, 'LineString', 'line');
        }

        let distance$$1 = Infinity;
        const p = pt.geometry.coordinates;
        segmentEach(line, function (segment) {
            const a = segment.geometry.coordinates[0];
            const b = segment.geometry.coordinates[1];
            const d = distanceToSegment(p, a, b, options);
            if (d < distance$$1) { distance$$1 = d; }
        });
        return convertLength(distance$$1, 'degrees', options.units);
    }

    /**
     * Returns the distance between a point P on a segment AB.
     *
     * @private
     * @param {Array<number>} p external point
     * @param {Array<number>} a first segment point
     * @param {Array<number>} b second segment point
     * @param {Object} [options={}] Optional parameters
     * @returns {number} distance
     */
    function distanceToSegment(p, a, b, options) {
        const v = [b[0] - a[0],  b[1] - a[1]];
        const w = [p[0] - a[0],  p[1] - a[1]];

        const c1 = dot(w, v);
        if (c1 <= 0) { return calcDistance(p, a, {method: options.method, units: 'degrees'}); }
        const c2 = dot(v, v);
        if (c2 <= c1) { return calcDistance(p, b, {method: options.method, units: 'degrees'}); }
        const b2 = c1 / c2;
        const Pb = [a[0] + (b2 * v[0]), a[1] + (b2 * v[1])];
        return calcDistance(p, Pb, {method: options.method, units: 'degrees'});
    }

    function dot(u, v) {
        return (u[0] * v[0] + u[1] * v[1]);
    }

    function calcDistance(a, b, options) {
        return options.method === 'planar' ? rhumbDistance(a, b, options) : distance(a, b, options);
    }

    /*
    object-assign
    (c) Sindre Sorhus
    @license MIT
    */
    /* eslint-disable no-unused-vars */
    var getOwnPropertySymbols = Object.getOwnPropertySymbols;
    var hasOwnProperty = Object.prototype.hasOwnProperty;
    var propIsEnumerable = Object.prototype.propertyIsEnumerable;

    function toObject(val) {
    	if (val === null || val === undefined) {
    		throw new TypeError('Object.assign cannot be called with null or undefined');
    	}

    	return Object(val);
    }

    function shouldUseNative() {
    	try {
    		if (!Object.assign) {
    			return false;
    		}

    		// Detect buggy property enumeration order in older V8 versions.

    		// https://bugs.chromium.org/p/v8/issues/detail?id=4118
    		var test1 = new String('abc');  // eslint-disable-line no-new-wrappers
    		test1[5] = 'de';
    		if (Object.getOwnPropertyNames(test1)[0] === '5') {
    			return false;
    		}

    		// https://bugs.chromium.org/p/v8/issues/detail?id=3056
    		var test2 = {};
    		for (var i = 0; i < 10; i++) {
    			test2['_' + String.fromCharCode(i)] = i;
    		}
    		var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
    			return test2[n];
    		});
    		if (order2.join('') !== '0123456789') {
    			return false;
    		}

    		// https://bugs.chromium.org/p/v8/issues/detail?id=3056
    		var test3 = {};
    		'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
    			test3[letter] = letter;
    		});
    		if (Object.keys(Object.assign({}, test3)).join('') !==
    				'abcdefghijklmnopqrst') {
    			return false;
    		}

    		return true;
    	} catch (err) {
    		// We don't expect any of the above to throw, but better to be safe.
    		return false;
    	}
    }

    var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
    	var from;
    	var to = toObject(target);
    	var symbols;

    	for (var s = 1; s < arguments.length; s++) {
    		from = Object(arguments[s]);

    		for (var key in from) {
    			if (hasOwnProperty.call(from, key)) {
    				to[key] = from[key];
    			}
    		}

    		if (getOwnPropertySymbols) {
    			symbols = getOwnPropertySymbols(from);
    			for (var i = 0; i < symbols.length; i++) {
    				if (propIsEnumerable.call(from, symbols[i])) {
    					to[symbols[i]] = from[symbols[i]];
    				}
    			}
    		}
    	}

    	return to;
    };

    /**
     * Returns the closest {@link Point|point}, of a {@link FeatureCollection|collection} of points,
     * to a {@link LineString|line}. The returned point has a `dist` property indicating its distance to the line.
     *
     * @name nearestPointToLine
     * @param {FeatureCollection|GeometryCollection<Point>} points Point Collection
     * @param {Feature|Geometry<LineString>} line Line Feature
     * @param {Object} [options] Optional parameters
     * @param {string} [options.units='kilometers'] unit of the output distance property
     * (eg: degrees, radians, miles, or kilometers)
     * @param {Object} [options.properties={}] Translate Properties to Point
     * @returns {Feature<Point>} the closest point
     * @example
     * var pt1 = turf.point([0, 0]);
     * var pt2 = turf.point([0.5, 0.5]);
     * var points = turf.featureCollection([pt1, pt2]);
     * var line = turf.lineString([[1,1], [-1,1]]);
     *
     * var nearest = turf.nearestPointToLine(points, line);
     *
     * //addToMap
     * var addToMap = [nearest, line];
     */
    function nearestPointToLine(points$$1, line, options) {
        options = checkIfOptionsExist(options);
        const units = options.units;
        const properties = options.properties || {};

        // validation
        const pts = normalize(points$$1);
        if (!pts.features.length) { throw new Error('points must contain features'); }

        if (!line) { throw new Error('line is required'); }
        if (getType(line) !== 'LineString') { throw new Error('line must be a LineString'); }

        let dist = Infinity;
        let pt = null;

        featureEach(pts, function (point$$1) {
            const d = pointToLineDistance(point$$1, line, { units });
            if (d < dist) {
                dist = d;
                pt = point$$1;
            }
        });
        /**
         * Translate Properties to final Point, priorities:
         * 1. options.properties
         * 2. inherent Point properties
         * 3. dist custom properties created by NearestPointToLine
         */
        if (pt) { pt.properties = objectAssign({dist}, pt.properties, properties); }
        return pt;
    }

    /**
     * Convert Collection to FeatureCollection
     *
     * @private
     * @param {FeatureCollection|GeometryCollection} points Points
     * @returns {FeatureCollection<Point>} points
     */
    function normalize(points$$1) {
        const features = [];
        const type = points$$1.geometry ? points$$1.geometry.type : points$$1.type;
        switch (type) {
        case 'GeometryCollection':
            geomEach(points$$1, function (geom) {
                if (geom.type === 'Point') { features.push({type: 'Feature', properties: {}, geometry: geom}); }
            });
            return {type: 'FeatureCollection', features};
        case 'FeatureCollection':
            points$$1.features = points$$1.features.filter(function (feature$$1) {
                return feature$$1.geometry.type === 'Point';
            });
            return points$$1;
        default:
            throw new Error('points must be a Point Collection');
        }
    }

    /**
     * Takes a triangular plane as a {@link Polygon}
     * and a {@link Point} within that triangle and returns the z-value
     * at that point. The Polygon should have properties `a`, `b`, and `c`
     * that define the values at its three corners. Alternatively, the z-values
     * of each triangle point can be provided by their respective 3rd coordinate
     * if their values are not provided as properties.
     *
     * @name planepoint
     * @param {Coord} point the Point for which a z-value will be calculated
     * @param {Feature<Polygon>} triangle a Polygon feature with three vertices
     * @returns {number} the z-value for `interpolatedPoint`
     * @example
     * var point = turf.point([-75.3221, 39.529]);
     * // "a", "b", and "c" values represent the values of the coordinates in order.
     * var triangle = turf.polygon([[
     *   [-75.1221, 39.57],
     *   [-75.58, 39.18],
     *   [-75.97, 39.86],
     *   [-75.1221, 39.57]
     * ]], {
     *   "a": 11,
     *   "b": 122,
     *   "c": 44
     * });
     *
     * var zValue = turf.planepoint(point, triangle);
     * point.properties.zValue = zValue;
     *
     * //addToMap
     * var addToMap = [triangle, point];
     */
    function planepoint(point, triangle) {
        // Normalize input
        var coord = getCoord(point);
        var geom = getGeom(triangle);
        var coords = geom.coordinates;
        var outer = coords[0];
        if (outer.length < 4) throw new Error('OuterRing of a Polygon must have 4 or more Positions.');
        var properties = triangle.properties || {};
        var a = properties.a;
        var b = properties.b;
        var c = properties.c;

        // Planepoint
        var x = coord[0];
        var y = coord[1];
        var x1 = outer[0][0];
        var y1 = outer[0][1];
        var z1 = (a !== undefined ? a : outer[0][2]);
        var x2 = outer[1][0];
        var y2 = outer[1][1];
        var z2 = (b !== undefined ? b : outer[1][2]);
        var x3 = outer[2][0];
        var y3 = outer[2][1];
        var z3 = (c !== undefined ? c : outer[2][2]);
        var z = (z3 * (x - x1) * (y - y2) + z1 * (x - x2) * (y - y3) + z2 * (x - x3) * (y - y1) -
                 z2 * (x - x1) * (y - y3) - z3 * (x - x2) * (y - y1) - z1 * (x - x3) * (y - y2)) /
               ((x - x1) * (y - y2) + (x - x2) * (y - y3) + (x - x3) * (y - y1) -
                (x - x1) * (y - y3) - (x - x2) * (y - y1) - (x - x3) * (y - y2));

        return z;
    }

    /**
     * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
     * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
     * returns {@link Point|points} at all self-intersections.
     *
     * @name kinks
     * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
     * @returns {FeatureCollection<Point>} self-intersections
     * @example
     * var poly = turf.polygon([[
     *   [-12.034835, 8.901183],
     *   [-12.060413, 8.899826],
     *   [-12.03638, 8.873199],
     *   [-12.059383, 8.871418],
     *   [-12.034835, 8.901183]
     * ]]);
     *
     * var kinks = turf.kinks(poly);
     *
     * //addToMap
     * var addToMap = [poly, kinks]
     */
    function kinks(featureIn) {
        let coordinates = null;
        let feature$$1 = null;
        const results = {
            type: 'FeatureCollection',
            features: [],
        };
        if (featureIn.type === 'Feature') {
            feature$$1 = featureIn.geometry;
        } else {
            feature$$1 = featureIn;
        }
        if (feature$$1.type === 'LineString') {
            coordinates = [feature$$1.coordinates];
        } else if (feature$$1.type === 'MultiLineString') {
            coordinates = feature$$1.coordinates;
        } else if (feature$$1.type === 'MultiPolygon') {
            coordinates = [].concat.apply([], feature$$1.coordinates);
        } else if (feature$$1.type === 'Polygon') {
            coordinates = feature$$1.coordinates;
        } else {
            throw new Error('Input must be a LineString, MultiLineString, ' +
                'Polygon, or MultiPolygon Feature or Geometry');
        }
        coordinates.forEach(function (line1) {
            coordinates.forEach(function (line2) {
                for (let i = 0; i < line1.length - 1; i++) {
                    // start iteration at i, intersections for k < i have already
                    // been checked in previous outer loop iterations
                    for (let k = i; k < line2.length - 1; k++) {
                        if (line1 === line2) {
                            // segments are adjacent and always share a vertex, not a kink
                            if (Math.abs(i - k) === 1) {
                                continue;
                            }
                            // first and last segment in a closed lineString or ring always share a vertex, not a kink
                            if (
                                // segments are first and last segment of lineString
                                i === 0 &&
                                k === line1.length - 2 &&
                                // lineString is closed
                                line1[i][0] === line1[line1.length - 1][0] &&
                                line1[i][1] === line1[line1.length - 1][1]
                            ) {
                                continue;
                            }
                        }

                        const intersection = lineIntersects(line1[i][0], line1[i][1], line1[i + 1][0], line1[i + 1][1],
                            line2[k][0], line2[k][1], line2[k + 1][0], line2[k + 1][1]);
                        if (intersection) {
                            results.features.push(point([intersection[0], intersection[1]]));
                        }
                    }
                }
            });
        });
        return results;
    }

    // modified from http://jsfiddle.net/justin_c_rounds/Gd2S2/light/
    function lineIntersects(
        line1StartX,
        line1StartY,
        line1EndX,
        line1EndY,
        line2StartX,
        line2StartY,
        line2EndX,
        line2EndY) {
        // if the lines intersect, the result contains the x and y of the
        // intersection (treating the lines as infinite) and booleans for whether
        // line segment 1 or line segment 2 contain the point
        let denominator;
        let a;
        let b;
        let numerator1;
        let numerator2;
        const result = {
            x: null,
            y: null,
            onLine1: false,
            onLine2: false,
        };
        denominator = ((line2EndY - line2StartY) * (line1EndX - line1StartX)) - ((line2EndX - line2StartX) * (line1EndY - line1StartY));
        if (denominator === 0) {
            if (result.x !== null && result.y !== null) {
                return result;
            } else {
                return false;
            }
        }
        a = line1StartY - line2StartY;
        b = line1StartX - line2StartX;
        numerator1 = ((line2EndX - line2StartX) * a) - ((line2EndY - line2StartY) * b);
        numerator2 = ((line1EndX - line1StartX) * a) - ((line1EndY - line1StartY) * b);
        a = numerator1 / denominator;
        b = numerator2 / denominator;

        // if we cast these lines infinitely in both directions, they intersect here:
        result.x = line1StartX + (a * (line1EndX - line1StartX));
        result.y = line1StartY + (a * (line1EndY - line1StartY));

        // if line1 is a segment and line2 is infinite, they intersect if:
        if (a >= 0 && a <= 1) {
            result.onLine1 = true;
        }
        // if line2 is a segment and line1 is infinite, they intersect if:
        if (b >= 0 && b <= 1) {
            result.onLine2 = true;
        }
        // if line1 and line2 are segments, they intersect if both of the above are true
        if (result.onLine1 && result.onLine2) {
            return [result.x, result.y];
        } else {
            return false;
        }
    }

    /**
     * Takes a Feature or FeatureCollection and returns a {@link Point} guaranteed to be on the surface of the feature.
     *
     * * Given a {@link Polygon}, the point will be in the area of the polygon
     * * Given a {@link LineString}, the point will be along the string
     * * Given a {@link Point}, the point will the same as the input
     *
     * @name pointOnFeature
     * @param {GeoJSON} geojson any Feature or FeatureCollection
     * @returns {Feature<Point>} a point on the surface of `input`
     * @example
     * var polygon = turf.polygon([[
     *   [116, -36],
     *   [131, -32],
     *   [146, -43],
     *   [155, -25],
     *   [133, -9],
     *   [111, -22],
     *   [116, -36]
     * ]]);
     *
     * var pointOnPolygon = turf.pointOnFeature(polygon);
     *
     * //addToMap
     * var addToMap = [polygon, pointOnPolygon];
     */
    function pointOnFeature(geojson) {
        // normalize
        var fc = normalize$1(geojson);

        // get centroid
        var cent = center(fc);

        // check to see if centroid is on surface
        var onSurface = false;
        var i = 0;
        while (!onSurface && i < fc.features.length) {
            var geom = fc.features[i].geometry;
            var x, y, x1, y1, x2, y2, k;
            var onLine = false;
            if (geom.type === 'Point') {
                if (cent.geometry.coordinates[0] === geom.coordinates[0] &&
                    cent.geometry.coordinates[1] === geom.coordinates[1]) {
                    onSurface = true;
                }
            } else if (geom.type === 'MultiPoint') {
                var onMultiPoint = false;
                k = 0;
                while (!onMultiPoint && k < geom.coordinates.length) {
                    if (cent.geometry.coordinates[0] === geom.coordinates[k][0] &&
              cent.geometry.coordinates[1] === geom.coordinates[k][1]) {
                        onSurface = true;
                        onMultiPoint = true;
                    }
                    k++;
                }
            } else if (geom.type === 'LineString') {
                k = 0;
                while (!onLine && k < geom.coordinates.length - 1) {
                    x = cent.geometry.coordinates[0];
                    y = cent.geometry.coordinates[1];
                    x1 = geom.coordinates[k][0];
                    y1 = geom.coordinates[k][1];
                    x2 = geom.coordinates[k + 1][0];
                    y2 = geom.coordinates[k + 1][1];
                    if (pointOnSegment(x, y, x1, y1, x2, y2)) {
                        onLine = true;
                        onSurface = true;
                    }
                    k++;
                }
            } else if (geom.type === 'MultiLineString') {
                var j = 0;
                while (j < geom.coordinates.length) {
                    onLine = false;
                    k = 0;
                    var line = geom.coordinates[j];
                    while (!onLine && k < line.length - 1) {
                        x = cent.geometry.coordinates[0];
                        y = cent.geometry.coordinates[1];
                        x1 = line[k][0];
                        y1 = line[k][1];
                        x2 = line[k + 1][0];
                        y2 = line[k + 1][1];
                        if (pointOnSegment(x, y, x1, y1, x2, y2)) {
                            onLine = true;
                            onSurface = true;
                        }
                        k++;
                    }
                    j++;
                }
            } else if (geom.type === 'Polygon' || geom.type === 'MultiPolygon') {
                if (booleanPointInPolygon(cent, geom)) {
                    onSurface = true;
                }
            }
            i++;
        }
        if (onSurface) {
            return cent;
        } else {
            var vertices = featureCollection([]);
            for (i = 0; i < fc.features.length; i++) {
                vertices.features = vertices.features.concat(explode(fc.features[i]).features);
            }
            // Remove distanceToPoint properties from nearestPoint()
            return point(nearestPoint(cent, vertices).geometry.coordinates);
        }
    }

    /**
     * Normalizes any GeoJSON to a FeatureCollection
     *
     * @private
     * @name normalize
     * @param {GeoJSON} geojson Any GeoJSON
     * @returns {FeatureCollection} FeatureCollection
     */
    function normalize$1(geojson) {
        if (geojson.type !== 'FeatureCollection') {
            if (geojson.type !== 'Feature') {
                return featureCollection([feature(geojson)]);
            }
            return featureCollection([geojson]);
        }
        return geojson;
    }

    function pointOnSegment(x, y, x1, y1, x2, y2) {
        var ab = Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
        var ap = Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
        var pb = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
        return ab === ap + pb;
    }

    /**
     * Takes one or more features and returns their area in square meters.
     *
     * @name area
     * @param {GeoJSON} geojson input GeoJSON feature(s)
     * @returns {number} area in square meters
     * @example
     * var polygon = turf.polygon([[[125, -15], [113, -22], [154, -27], [144, -15], [125, -15]]]);
     *
     * var area = turf.area(polygon);
     *
     * //addToMap
     * var addToMap = [polygon]
     * polygon.properties.area = area
     */
    function area$1(geojson) {
        return geomReduce(geojson, (value, geom) => {
            return value + calculateArea(geom);
        }, 0);
    }

    /**
     * Calculate Area
     *
     * @private
     * @param {Geometry} geom GeoJSON Geometries
     * @returns {number} area
     */
    function calculateArea(geom) {
        let total = 0;
        let i;
        switch (geom.type) {
        case 'Polygon':
            return polygonArea(geom.coordinates);
        case 'MultiPolygon':
            for (i = 0; i < geom.coordinates.length; i++) {
                total += polygonArea(geom.coordinates[i]);
            }
            return total;
        case 'Point':
        case 'MultiPoint':
        case 'LineString':
        case 'MultiLineString':
            return 0;
        }
        return 0;
    }

    function polygonArea(coords) {
        let total = 0;
        if (coords && coords.length > 0) {
            total += Math.abs(ringArea(coords[0]));
            for (let i = 1; i < coords.length; i++) {
                total -= Math.abs(ringArea(coords[i]));
            }
        }
        return total;
    }

    /**
     * @private
     * Calculate the approximate area of the polygon were it projected onto the earth.
     * Note that this area will be positive if ring is oriented clockwise, otherwise it will be negative.
     *
     * Reference:
     * Robert. G. Chamberlain and William H. Duquette, 'Some Algorithms for Polygons on a Sphere',
     * JPL Publication 07-03, Jet Propulsion
     * Laboratory, Pasadena, CA, June 2007 http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409
     *
     * @param {Array<Array<number>>} coords Ring Coordinates
     * @returns {number} The approximate signed geodesic area of the polygon in square meters.
     */
    function ringArea(coords) {
        let p1;
        let p2;
        let p3;
        let lowerIndex;
        let middleIndex;
        let upperIndex;
        let i;
        let total = 0;
        const coordsLength = coords.length;

        if (coordsLength > 2) {
            for (i = 0; i < coordsLength; i++) {
                if (i === coordsLength - 2) { // i = N-2
                    lowerIndex = coordsLength - 2;
                    middleIndex = coordsLength - 1;
                    upperIndex = 0;
                } else if (i === coordsLength - 1) { // i = N-1
                    lowerIndex = coordsLength - 1;
                    middleIndex = 0;
                    upperIndex = 1;
                } else { // i = 0 to N-3
                    lowerIndex = i;
                    middleIndex = i + 1;
                    upperIndex = i + 2;
                }
                p1 = coords[lowerIndex];
                p2 = coords[middleIndex];
                p3 = coords[upperIndex];
                total += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
            }

            total = total * earthRadius * earthRadius / 2;
        }
        return total;
    }

    function rad(num) {
        return num * Math.PI / 180;
    }

    // https://en.wikipedia.org/wiki/Rhumb_line

    /**
     * Takes two {@link Point|points} and finds the bearing angle between them along a Rhumb line
     * i.e. the angle measured in degrees start the north line (0 degrees)
     *
     * @name rhumbBearing
     * @param {Coord} start starting Point
     * @param {Coord} end ending Point
     * @param {Object} [options] Optional parameters
     * @param {boolean} [options.final=false] calculates the final bearing if true
     * @returns {number} bearing from north in decimal degrees, between -180 and 180 degrees (positive clockwise)
     * @example
     * var point1 = turf.point([-75.343, 39.984], {"marker-color": "#F00"});
     * var point2 = turf.point([-75.534, 39.123], {"marker-color": "#00F"});
     *
     * var bearing = turf.rhumbBearing(point1, point2);
     *
     * //addToMap
     * var addToMap = [point1, point2];
     * point1.properties.bearing = bearing;
     * point2.properties.bearing = bearing;
     */
    function rhumbBearing(start, end, options) {
        options = checkIfOptionsExist(options);
        let bear360;
        if (options.final) { bear360 = calculateRhumbBearing(getCoord(end), getCoord(start));
        } else { bear360 = calculateRhumbBearing(getCoord(start), getCoord(end)); }

        const bear180 = (bear360 > 180) ? - (360 - bear360) : bear360;

        return bear180;
    }

    /**
     * Returns the bearing from ‘this’ point to destination point along a rhumb line.
     * Adapted from Geodesy: https://github.com/chrisveness/geodesy/blob/master/latlon-spherical.js
     *
     * @private
     * @param   {Array<number>} from - origin point.
     * @param   {Array<number>} to - destination point.
     * @returns {number} Bearing in degrees from north.
     * @example
     * var p1 = new LatLon(51.127, 1.338);
     * var p2 = new LatLon(50.964, 1.853);
     * var d = p1.rhumbBearingTo(p2); // 116.7 m
     */
    function calculateRhumbBearing(from, to) {
        // φ => phi
        // Δλ => deltaLambda
        // Δψ => deltaPsi
        // θ => theta
        const phi1 = degreesToRadians(from[1]);
        const phi2 = degreesToRadians(to[1]);
        let deltaLambda = degreesToRadians((to[0] - from[0]));
        // if deltaLambdaon over 180° take shorter rhumb line across the anti-meridian:
        if (deltaLambda > Math.PI) { deltaLambda -= 2 * Math.PI; }
        if (deltaLambda < -Math.PI) { deltaLambda += 2 * Math.PI; }

        const deltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));

        const theta = Math.atan2(deltaLambda, deltaPsi);

        return (radiansToDegrees(theta) + 360) % 360;
    }

    // https://en.wikipedia.org/wiki/Rhumb_line

    /**
     * Returns the destination {@link Point} having travelled the given distance along a Rhumb line from the
     * origin Point with the (varant) given bearing.
     *
     * @name rhumbDestination
     * @param {Coord} origin starting point
     * @param {number} distance distance from the starting point
     * @param {number} bearing varant bearing angle ranging from -180 to 180 degrees from north
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
     * @param {Object} [options.properties={}] translate properties to destination point
     * @returns {Feature<Point>} Destination point.
     * @example
     * var pt = ...point([-75.343, 39.984], {"marker-color": "F00"});
     * var distance = 50;
     * var bearing = 90;
     * var options = {units: 'miles'};
     *
     * var destination = ...rhumbDestination(pt, distance, bearing, options);
     *
     * //addToMap
     * var addToMap = [pt, destination]
     * destination.properties['marker-color'] = '#00F';
     */
    function rhumbDestination(origin, distance, bearing, options) {
        options = checkIfOptionsExist(options);
        const wasNegativeDistance = distance < 0;
        let distanceInMeters = convertLength(Math.abs(distance), options.units, "meters");
        if (wasNegativeDistance) distanceInMeters = -Math.abs(distanceInMeters);
        const coords = getCoord(origin);
        const destination = calculateRhumbDestination(coords, distanceInMeters, bearing);

        // compensate the crossing of the 180th meridian (https://macwright.org/2016/09/26/the-180th-meridian.html)
        // solution from https://github.com/mapbox/mapbox-gl-js/issues/3250#issuecomment-294887678
        destination[0] += (destination[0] - coords[0] > 180) ? -360 : (coords[0] - destination[0] > 180) ? 360 : 0;
        return point(destination, options.properties);
    }

    /**
     * Returns the destination point having travelled along a rhumb line from origin point the given
     * distance on the  given bearing.
     * Adapted from Geodesy: http://www.movable-type.co.uk/scripts/latlong.html#rhumblines
     *
     * @private
     * @param   {Array<number>} origin - point
     * @param   {number} distance - Distance travelled, in same units as earth radius (default: metres).
     * @param   {number} bearing - Bearing in degrees from north.
     * @param   {number} [radius=6371e3] - (Mean) radius of earth (defaults to radius in metres).
     * @returns {Array<number>} Destination point.
     */
    function calculateRhumbDestination(origin, distance, bearing, radius) {
        // φ => phi
        // λ => lambda
        // ψ => psi
        // Δ => Delta
        // δ => delta
        // θ => theta

        radius = (radius === undefined) ? earthRadius : Number(radius);

        const delta = distance / radius; // angular distance in radians
        const lambda1 = origin[0] * Math.PI / 180; // to radians, but without normalize to 𝜋
        const phi1 = degreesToRadians(origin[1]);
        const theta = degreesToRadians(bearing);

        const DeltaPhi = delta * Math.cos(theta);
        let phi2 = phi1 + DeltaPhi;

        // check for some daft bugger going past the pole, normalise latitude if so
        if (Math.abs(phi2) > Math.PI / 2) { phi2 = phi2 > 0 ? Math.PI - phi2 : -Math.PI - phi2; }

        const DeltaPsi = Math.log(Math.tan(phi2 / 2 + Math.PI / 4) / Math.tan(phi1 / 2 + Math.PI / 4));
        // E-W course becomes ill-conditioned with 0/0
        const q = Math.abs(DeltaPsi) > 10e-12 ? DeltaPhi / DeltaPsi : Math.cos(phi1);

        const DeltaLambda = delta * Math.sin(theta) / q;
        const lambda2 = lambda1 + DeltaLambda;

        return [((lambda2 * 180 / Math.PI) + 540) % 360 - 180, phi2 * 180 / Math.PI]; // normalise to −180..+180°
    }

    /**
     * Takes a {@link LineString} and returns a {@link Point} at a specified distance along the line.
     *
     * @name along
     * @param {Feature<LineString>} line input line
     * @param {number} distance distance along the line
     * @param {Object} [options] Optional parameters
     * @param {string} [options.units="kilometers"] can be degrees, radians, miles, or kilometers
     * @returns {Feature<Point>} Point `distance` `units` along the line
     * @example
     * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]]);
     * var options = {units: 'miles'};
     *
     * var along = turf.along(line, 200, options);
     *
     * //addToMap
     * var addToMap = [along, line]
     */
    function along(line, distance, options) {
        options = checkIfOptionsExist(options);

        const geom = getGeom(line);
        const coords = geom.coordinates;
        let travelled = 0;
        for (let i = 0; i < coords.length; i++) {
            if (distance >= travelled && i === coords.length - 1) {
                break;
            } else if (travelled >= distance) {
                const overshot = distance - travelled;
                if (!overshot) {
                    return point(coords[i]);
                } else {
                    const direction = rhumbBearing(coords[i], coords[i - 1]) - 180;
                    const interpolated = rhumbDestination(coords[i], overshot, direction, options);
                    return interpolated;
                }
            } else {
                travelled += rhumbDistance(coords[i], coords[i + 1], options);
            }
        }
        return point(coords[coords.length - 1]);
    }

    /**
     * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
     *
     * @name length
     * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers
     * @returns {number} length of GeoJSON
     * @example
     * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);
     * var length = turf.length(line, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [line];
     * line.properties.distance = length;
     */
    function length$1(geojson, options) {
        // Calculate distance from 2-vertex line segments
        return segmentReduce(geojson, function (previousValue, segment) {
            const coords = segment.geometry.coordinates;
            return previousValue + distance(coords[0], coords[1], options);
        }, 0);
    }

    /**
     * Takes a {@link LineString|line}, a start {@link Point}, and a stop point
     * and returns a subsection of the line in-between those points.
     * The start & stop points don't need to fall exactly on the line.
     *
     * This can be useful for extracting only the part of a route between waypoints.
     *
     * @name lineSlice
     * @param {Coord} startPt starting point
     * @param {Coord} stopPt stopping point
     * @param {Feature<LineString>|LineString} line line to slice
     * @returns {Feature<LineString>} sliced line
     * @example
     * var line = turf.lineString([
     *     [-77.031669, 38.878605],
     *     [-77.029609, 38.881946],
     *     [-77.020339, 38.884084],
     *     [-77.025661, 38.885821],
     *     [-77.021884, 38.889563],
     *     [-77.019824, 38.892368]
     * ]);
     * var start = turf.point([-77.029609, 38.881946]);
     * var stop = turf.point([-77.021884, 38.889563]);
     *
     * var sliced = turf.lineSlice(start, stop, line);
     *
     * //addToMap
     * var addToMap = [start, stop, line]
     */
    function lineSlice(startPt, stopPt, line) {
        // Validation
        var coords = getCoords(line);
        if (getType(line) !== 'LineString') throw new Error('line must be a LineString');

        var startVertex = nearestPointOnLine(line, startPt);
        var stopVertex = nearestPointOnLine(line, stopPt);
        var ends;
        if (startVertex.properties.index <= stopVertex.properties.index) {
            ends = [startVertex, stopVertex];
        } else {
            ends = [stopVertex, startVertex];
        }
        var clipCoords = [ends[0].geometry.coordinates];
        for (var i = ends[0].properties.index + 1; i < ends[1].properties.index + 1; i++) {
            clipCoords.push(coords[i]);
        }
        clipCoords.push(ends[1].geometry.coordinates);
        return lineString(clipCoords, line.properties);
    }

    /**
     * Takes a {@link LineString|line}, a specified distance along the line to a start {@link Point},
     * and a specified  distance along the line to a stop point
     * and returns a subsection of the line in-between those points.
     *
     * This can be useful for extracting only the part of a route between two distances.
     *
     * @name lineSliceAlong
     * @param {Feature<LineString>|LineString} line input line
     * @param {number} startDist distance along the line to starting point
     * @param {number} stopDist distance along the line to ending point
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
     * @returns {Feature<LineString>} sliced line
     * @example
     * var line = turf.lineString([[7, 45], [9, 45], [14, 40], [14, 41]]);
     * var start = 12.5;
     * var stop = 25;
     * var sliced = turf.lineSliceAlong(line, start, stop, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [line, start, stop, sliced]
     */
    function lineSliceAlong(line, startDist, stopDist, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');

        var coords;
        var slice = [];

        // Validation
        if (line.type === 'Feature') coords = line.geometry.coordinates;
        else if (line.type === 'LineString') coords = line.coordinates;
        else throw new Error('input must be a LineString Feature or Geometry');

        var travelled = 0;
        var overshot, direction, interpolated;
        for (var i = 0; i < coords.length; i++) {
            if (startDist >= travelled && i === coords.length - 1) throw new Error('Start distance is beyond length of line');
            else if (travelled > startDist && slice.length === 0) {
                overshot = startDist - travelled;
                if (!overshot) {
                    slice.push(coords[i]);
                    return lineString(slice);
                }
                direction = rhumbBearing(coords[i], coords[i - 1]) - 180;
                interpolated = rhumbDestination(coords[i], overshot, direction, options);
                slice.push(interpolated.geometry.coordinates);
            }

            if (travelled >= stopDist) {
                overshot = stopDist - travelled;
                if (!overshot) {
                    slice.push(coords[i]);
                    return lineString(slice);
                }
                direction = rhumbBearing(coords[i], coords[i - 1]) - 180;
                interpolated = rhumbDestination(coords[i], overshot, direction, options);
                slice.push(interpolated.geometry.coordinates);
                return lineString(slice);
            }

            if (travelled >= startDist) {
                slice.push(coords[i]);
            }

            if (i === coords.length - 1) {
                return lineString(slice);
            }

            travelled += rhumbDistance(coords[i], coords[i + 1], options);
        }
        return lineString(coords[coords.length - 1]);
    }

    /**
     * Returns true if a point is on a line. Accepts a optional parameter to ignore the
     * start and end vertices of the linestring.
     *
     * @name booleanPointOnLine
     * @param {Coord} pt GeoJSON Point
     * @param {Feature<LineString>} line GeoJSON LineString
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.ignoreEndVertices=false] whether to ignore the start and end vertices.
     * @returns {boolean} true/false
     * @example
     * var pt = turf.point([0, 0]);
     * var line = turf.lineString([[-1, -1],[1, 1],[1.5, 2.2]]);
     * var isPointOnLine = turf.booleanPointOnLine(pt, line);
     * //=true
     */
    function booleanPointOnLine(pt, line, options) {

        options = checkIfOptionsExist(options);
        // Normalize inputs
        const ptCoords = getCoord(pt);
        const lineCoords = getCoords(line);

        // Main
        for (let i = 0; i < lineCoords.length - 1; i++) {
            let ignoreBoundary = false;
            if (options.ignoreEndVertices) {
                if (i === 0) { ignoreBoundary = 'start'; }
                if (i === lineCoords.length - 2) { ignoreBoundary = 'end'; }
                if (i === 0 && i + 1 === lineCoords.length - 1) { ignoreBoundary = 'both'; }
            }
            if (isPointOnLineSegment$1(lineCoords[i], lineCoords[i + 1], ptCoords, ignoreBoundary)) { return true; }
        }
        return false;
    }

    // See http://stackoverflow.com/a/4833823/1979085
    /**
     * @private
     * @param {Position} lineSegmentStart coord pair of start of line
     * @param {Position} lineSegmentEnd coord pair of end of line
     * @param {Position} pt coord pair of point to check
     * @param {boolean|string} excludeBoundary whether the point is allowed to fall on the line ends.
     * If true which end to ignore.
     * @returns {boolean} true/false
     */
    function isPointOnLineSegment$1(lineSegmentStart, lineSegmentEnd, pt, excludeBoundary) {
        const x = pt[0];
        const y = pt[1];
        const x1 = lineSegmentStart[0];
        const y1 = lineSegmentStart[1];
        const x2 = lineSegmentEnd[0];
        const y2 = lineSegmentEnd[1];
        const dxc = pt[0] - x1;
        const dyc = pt[1] - y1;
        const dxl = x2 - x1;
        const dyl = y2 - y1;
        const cross = dxc * dyl - dyc * dxl;
        if (cross !== 0) {
            return false;
        }
        if (!excludeBoundary) {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? x1 <= x && x <= x2 : x2 <= x && x <= x1;
            }
            return dyl > 0 ? y1 <= y && y <= y2 : y2 <= y && y <= y1;
        } else if (excludeBoundary === 'start') {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? x1 < x && x <= x2 : x2 <= x && x < x1;
            }
            return dyl > 0 ? y1 < y && y <= y2 : y2 <= y && y < y1;
        } else if (excludeBoundary === 'end') {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? x1 <= x && x < x2 : x2 < x && x <= x1;
            }
            return dyl > 0 ? y1 <= y && y < y2 : y2 < y && y <= y1;
        } else if (excludeBoundary === 'both') {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? x1 < x && x < x2 : x2 < x && x < x1;
            }
            return dyl > 0 ? y1 < y && y < y2 : y2 < y && y < y1;
        }
        return false;
    }

    /**
     * Boolean-within returns true if the first geometry is completely within the second geometry.
     * The interiors of both geometries must intersect and, the interior and boundary of the primary (geometry a)
     * must not intersect the exterior of the secondary (geometry b).
     * Boolean-within returns the exact opposite result of the `@turf/boolean-contains`.
     *
     * @name booleanWithin
     * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false
     * @example
     * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
     * var point = turf.point([1, 2]);
     *
     * turf.booleanWithin(point, line);
     * //=true
     */
    function booleanWithin(feature1, feature2) {
        var geom1 = getGeom(feature1);
        var geom2 = getGeom(feature2);
        var type1 = geom1.type;
        var type2 = geom2.type;

        switch (type1) {
        case 'Point':
            switch (type2) {
            case 'MultiPoint':
                return isPointInMultiPoint(geom1, geom2);
            case 'LineString':
                return booleanPointOnLine(geom1, geom2, {ignoreEndVertices: true});
            case 'Polygon':
            case 'MultiPolygon':
                return booleanPointInPolygon(geom1, geom2, {ignoreBoundary: true});
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        case 'MultiPoint':
            switch (type2) {
            case 'MultiPoint':
                return isMultiPointInMultiPoint(geom1, geom2);
            case 'LineString':
                return isMultiPointOnLine(geom1, geom2);
            case 'Polygon':
            case 'MultiPolygon':
                return isMultiPointInPoly(geom1, geom2);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        case 'LineString':
            switch (type2) {
            case 'LineString':
                return isLineOnLine(geom1, geom2);
            case 'Polygon':
            case 'MultiPolygon':
                return isLineInPoly(geom1, geom2);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        case 'Polygon':
            switch (type2) {
            case 'Polygon':
            case 'MultiPolygon':
                return isPolyInPoly(geom1, geom2);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        default:
            throw new Error('feature1 ' + type1 + ' geometry not supported');
        }
    }

    function isPointInMultiPoint(point, multiPoint) {
        var i;
        var output = false;
        for (i = 0; i < multiPoint.coordinates.length; i++) {
            if (compareCoords(multiPoint.coordinates[i], point.coordinates)) {
                output = true;
                break;
            }
        }
        return output;
    }

    function isMultiPointInMultiPoint(multiPoint1, multiPoint2) {
        for (var i = 0; i < multiPoint1.coordinates.length; i++) {
            var anyMatch = false;
            for (var i2 = 0; i2 < multiPoint2.coordinates.length; i2++) {
                if (compareCoords(multiPoint1.coordinates[i], multiPoint2.coordinates[i2])) {
                    anyMatch = true;
                }
            }
            if (!anyMatch) {
                return false;
            }
        }
        return true;
    }

    function isMultiPointOnLine(multiPoint, lineString) {
        var foundInsidePoint = false;

        for (var i = 0; i < multiPoint.coordinates.length; i++) {
            if (!booleanPointOnLine(multiPoint.coordinates[i], lineString)) {
                return false;
            }
            if (!foundInsidePoint) {
                foundInsidePoint = booleanPointOnLine(multiPoint.coordinates[i], lineString, {ignoreEndVertices: true});
            }
        }
        return foundInsidePoint;
    }

    function isMultiPointInPoly(multiPoint, polygon) {
        var output = true;
        for (var i = 0; i < multiPoint.coordinates.length; i++) {
            var isInside = booleanPointInPolygon(multiPoint.coordinates[1], polygon);
            if (!isInside) {
                output = false;
                break;
            }
            {
                isInside = booleanPointInPolygon(multiPoint.coordinates[1], polygon, {ignoreBoundary: true});
            }
        }
        return output && isInside;
    }

    function isLineOnLine(lineString1, lineString2) {
        for (var i = 0; i < lineString1.coordinates.length; i++) {
            if (!booleanPointOnLine(lineString1.coordinates[i], lineString2)) {
                return false;
            }
        }
        return true;
    }

    function isLineInPoly(linestring, polygon) {
        var polyBbox = bbox(polygon);
        var lineBbox = bbox(linestring);
        if (!doBBoxOverlap(polyBbox, lineBbox)) {
            return false;
        }
        var foundInsidePoint = false;

        for (var i = 0; i < linestring.coordinates.length - 1; i++) {
            if (!booleanPointInPolygon(linestring.coordinates[i], polygon)) {
                return false;
            }
            if (!foundInsidePoint) {
                foundInsidePoint = booleanPointInPolygon(linestring.coordinates[i], polygon, {ignoreBoundary: true});
            }
            if (!foundInsidePoint) {
                var midpoint = getMidpoint(linestring.coordinates[i], linestring.coordinates[i + 1]);
                foundInsidePoint = booleanPointInPolygon(midpoint, polygon, {ignoreBoundary: true});

            }
        }
        return foundInsidePoint;
    }

    /**
     * Is Polygon2 in Polygon1
     * Only takes into account outer rings
     *
     * @private
     * @param {Geometry|Feature<Polygon>} feature1 Polygon1
     * @param {Geometry|Feature<Polygon>} feature2 Polygon2
     * @returns {boolean} true/false
     */
    function isPolyInPoly(feature1, feature2) {
        var poly1Bbox = bbox(feature1);
        var poly2Bbox = bbox(feature2);
        if (!doBBoxOverlap(poly2Bbox, poly1Bbox)) {
            return false;
        }
        for (var i = 0; i < feature1.coordinates[0].length; i++) {
            if (!booleanPointInPolygon(feature1.coordinates[0][i], feature2)) {
                return false;
            }
        }
        return true;
    }

    function doBBoxOverlap(bbox1, bbox2) {
        if (bbox1[0] > bbox2[0]) return false;
        if (bbox1[2] < bbox2[2]) return false;
        if (bbox1[1] > bbox2[1]) return false;
        if (bbox1[3] < bbox2[3]) return false;
        return true;
    }

    /**
     * compareCoords
     *
     * @private
     * @param {Position} pair1 point [x,y]
     * @param {Position} pair2 point [x,y]
     * @returns {boolean} true/false if coord pairs match
     */
    function compareCoords(pair1, pair2) {
        return pair1[0] === pair2[0] && pair1[1] === pair2[1];
    }

    /**
     * getMidpoint
     *
     * @private
     * @param {Position} pair1 point [x,y]
     * @param {Position} pair2 point [x,y]
     * @returns {Position} midpoint of pair1 and pair2
     */
    function getMidpoint(pair1, pair2) {
        return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];
    }

    /**
     * Creates a {@link Point} grid from a bounding box, {@link FeatureCollection} or {@link Feature}.
     *
     * @name pointGrid
     * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
     * @param {number} cellSide the distance between points, in units
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees, radians, miles, or kilometers
     * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
     * @param {Object} [options.properties={}] passed to each point of the grid
     * @returns {FeatureCollection<Point>} grid of points
     * @example
     * var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
     * var cellSide = 3;
     * var options = {units: 'miles'};
     *
     * var grid = turf.pointGrid(extent, cellSide, options);
     *
     * //addToMap
     * var addToMap = [grid];
     */
    function pointGrid(bbox, cellSide, options) {
        options = checkIfOptionsExist(options);
        // Default parameters
        if (options.mask && !options.units) options.units = 'kilometers';

        // Containers
        var results = [];

        // Typescript handles the Type Validation
        // if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');
        // if (!isNumber(cellSide)) throw new Error('cellSide is invalid');
        // if (!bbox) throw new Error('bbox is required');
        // if (!Array.isArray(bbox)) throw new Error('bbox must be array');
        // if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');
        // if (mask && ['Polygon', 'MultiPolygon'].indexOf(getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');

        var west = bbox[0];
        var south = bbox[1];
        var east = bbox[2];
        var north = bbox[3];

        var xFraction = cellSide / (distance([west, south], [east, south], options));
        var cellWidth = xFraction * (east - west);
        var yFraction = cellSide / (distance([west, south], [west, north], options));
        var cellHeight = yFraction * (north - south);

        var bboxWidth = (east - west);
        var bboxHeight = (north - south);
        var columns = Math.floor(bboxWidth / cellWidth);
        var rows = Math.floor(bboxHeight / cellHeight);

        // adjust origin of the grid
        var deltaX = (bboxWidth - columns * cellWidth) / 2;
        var deltaY = (bboxHeight - rows * cellHeight) / 2;

        var currentX = west + deltaX;
        while (currentX <= east) {
            var currentY = south + deltaY;
            while (currentY <= north) {
                var cellPt = point([currentX, currentY], options.properties);
                if (options.mask) {
                    if (booleanWithin(cellPt, options.mask)) results.push(cellPt);
                } else {
                    results.push(cellPt);
                }
                currentY += cellHeight;
            }
            currentX += cellWidth;
        }

        return featureCollection(results);
    }

    /**
     * Takes a GeoJSON Feature or FeatureCollection and truncates the precision of the geometry.
     *
     * @name truncate
     * @param {GeoJSON} geojson any GeoJSON Feature, FeatureCollection, Geometry or GeometryCollection.
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.precision=6] coordinate decimal precision
     * @param {number} [options.coordinates=3] maximum number of coordinates (primarly used to remove z coordinates)
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} layer with truncated geometry
     * @example
     * var point = turf.point([
     *     70.46923055566859,
     *     58.11088890802906,
     *     1508
     * ]);
     * var options = {precision: 3, coordinates: 2};
     * var truncated = turf.truncate(point, options);
     * //=truncated.geometry.coordinates => [70.469, 58.111]
     *
     * //addToMap
     * var addToMap = [truncated];
     */
    function truncate(geojson, options) {

        options = checkIfOptionsExist(options);
        // Optional parameters
        var precision = options.precision;
        var coordinates = options.coordinates;
        var mutate = options.mutate;

        // default params
        precision = (precision === undefined || precision === null || isNaN(precision)) ? 6 : precision;
        coordinates = (coordinates === undefined || coordinates === null || isNaN(coordinates)) ? 3 : coordinates;

        // validation
        if (!geojson) throw new Error('<geojson> is required');
        if (typeof precision !== 'number') throw new Error('<precision> must be a number');
        if (typeof coordinates !== 'number') throw new Error('<coordinates> must be a number');

        // prevent input mutation
        if (mutate === false || mutate === undefined) geojson = JSON.parse(JSON.stringify(geojson));

        var factor = Math.pow(10, precision);

        // Truncate Coordinates
        coordEach(geojson, function (coords) {
            truncateCoords(coords, factor, coordinates);
        });
        return geojson;
    }

    /**
     * Truncate Coordinates - Mutates coordinates in place
     *
     * @private
     * @param {Array<any>} coords Geometry Coordinates
     * @param {number} factor rounding factor for coordinate decimal precision
     * @param {number} coordinates maximum number of coordinates (primarly used to remove z coordinates)
     * @returns {Array<any>} mutated coordinates
     */
    function truncateCoords(coords, factor, coordinates) {
        // Remove extra coordinates (usually elevation coordinates and more)
        if (coords.length > coordinates) coords.splice(coordinates, coords.length);

        // Truncate coordinate decimals
        for (var i = 0; i < coords.length; i++) {
            coords[i] = Math.round(coords[i] * factor) / factor;
        }
        return coords;
    }

    /**
     * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
     *
     * @name flatten
     * @param {GeoJSON} geojson any valid GeoJSON Object
     * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features
     * @example
     * var multiGeometry = turf.multiPolygon([
     *   [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
     *   [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
     *   [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
     * ]);
     *
     * var flatten = turf.flatten(multiGeometry);
     *
     * //addToMap
     * var addToMap = [flatten]
     */
    function flatten(geojson) {
        if (!geojson) throw new Error('geojson is required');

        var results = [];
        flattenEach(geojson, function (feature$$1) {
            results.push(feature$$1);
        });
        return featureCollection(results);
    }

    /**
     * Divides a {@link LineString} into chunks of a specified length.
     * If the line is shorter than the segment length then the original line is returned.
     *
     * @name lineChunk
     * @param {FeatureCollection|Geometry|Feature<LineString|MultiLineString>} geojson the lines to split
     * @param {number} segmentLength how long to make each segment
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] units can be degrees, radians, miles, or kilometers
     * @param {boolean} [options.reverse=false] reverses coordinates to start the first chunked segment at the end
     * @returns {FeatureCollection<LineString>} collection of line segments
     * @example
     * var line = turf.lineString([[-95, 40], [-93, 45], [-85, 50]]);
     *
     * var chunk = turf.lineChunk(line, 15, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [chunk];
     */
    function lineChunk(geojson, segmentLength, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var units = options.units;
        var reverse = options.reverse;

        // Validation
        if (!geojson) throw new Error('geojson is required');
        if (segmentLength <= 0) throw new Error('segmentLength must be greater than 0');

        // Container
        var results = [];

        // Flatten each feature to simple LineString
        flattenEach(geojson, function (feature$$1) {
            // reverses coordinates to start the first chunked segment at the end
            if (reverse) feature$$1.geometry.coordinates = feature$$1.geometry.coordinates.reverse();

            sliceLineSegments(feature$$1, segmentLength, units, function (segment) {
                results.push(segment);
            });
        });
        return featureCollection(results);
    }

    /**
     * Slice Line Segments
     *
     * @private
     * @param {Feature<LineString>} line GeoJSON LineString
     * @param {number} segmentLength how long to make each segment
     * @param {string}[units='kilometers'] units can be degrees, radians, miles, or kilometers
     * @param {Function} callback iterate over sliced line segments
     * @returns {void}
     */
    function sliceLineSegments(line, segmentLength, units, callback) {
        var lineLength = length$1(line, {units: units});

        // If the line is shorter than the segment length then the orginal line is returned.
        if (lineLength <= segmentLength) return callback(line);

        var numberOfSegments = lineLength / segmentLength;

        // If numberOfSegments is integer, no need to plus 1
        if (!Number.isInteger(numberOfSegments)) {
            numberOfSegments = Math.floor(numberOfSegments) + 1;
        }

        for (var i = 0; i < numberOfSegments; i++) {
            var outline = lineSliceAlong(line, segmentLength * i, segmentLength * (i + 1), {units: units});
            callback(outline, i);
        }
    }

    // Find self-intersections in geojson polygon (possibly with interior rings)

    function isects (feature, filterFn, useSpatialIndex) {
        if (feature.geometry.type !== 'Polygon') throw new Error('The input feature must be a Polygon');
        if (useSpatialIndex === undefined) useSpatialIndex = 1;

        var coord = feature.geometry.coordinates;

        var output = [];
        var seen = {};

        if (useSpatialIndex) {
            var allEdgesAsRbushTreeItems = [];
            for (var ring0 = 0; ring0 < coord.length; ring0++) {
                for (var edge0 = 0; edge0 < coord[ring0].length - 1; edge0++) {
                    allEdgesAsRbushTreeItems.push(rbushTreeItem(ring0, edge0));
                }
            }
            var tree = rbush_1();
            tree.load(allEdgesAsRbushTreeItems);
        }

        for (var ringA = 0; ringA < coord.length; ringA++) {
            for (var edgeA = 0; edgeA < coord[ringA].length - 1; edgeA++) {
                if (useSpatialIndex) {
                    var bboxOverlaps = tree.search(rbushTreeItem(ringA, edgeA));
                    bboxOverlaps.forEach(function (bboxIsect) {
                        var ring1 = bboxIsect.ring;
                        var edge1 = bboxIsect.edge;
                        ifIsectAddToOutput(ringA, edgeA, ring1, edge1);
                    });
                } else {
                    for (var ring1 = 0; ring1 < coord.length; ring1++) {
                        for (var edge1 = 0; edge1 < coord[ring1].length - 1; edge1++) {
                            // TODO: speedup possible if only interested in unique: start last two loops at ringA and edgeA+1
                            ifIsectAddToOutput(ringA, edgeA, ring1, edge1);
                        }
                    }
                }
            }
        }

        if (!filterFn) output = {type: 'Feature', geometry: {type: 'MultiPoint', coordinates: output}};
        return output;

        // Function to check if two edges intersect and add the intersection to the output
        function ifIsectAddToOutput(ring0, edge0, ring1, edge1) {
            var start0 = coord[ring0][edge0];
            var end0 = coord[ring0][edge0 + 1];
            var start1 = coord[ring1][edge1];
            var end1 = coord[ring1][edge1 + 1];

            var isect = intersect(start0, end0, start1, end1);

            if (isect === null) return; // discard parallels and coincidence
            var frac0;
            var frac1;
            if (end0[0] !== start0[0]) {
                frac0 = (isect[0] - start0[0]) / (end0[0] - start0[0]);
            } else {
                frac0 = (isect[1] - start0[1]) / (end0[1] - start0[1]);
            }
            if (end1[0] !== start1[0]) {
                frac1 = (isect[0] - start1[0]) / (end1[0] - start1[0]);
            } else {
                frac1 = (isect[1] - start1[1]) / (end1[1] - start1[1]);
            }
            if (frac0 >= 1 || frac0 <= 0 || frac1 >= 1 || frac1 <= 0) return; // require segment intersection

            var key = isect;
            var unique = !seen[key];
            if (unique) {
                seen[key] = true;
            }

            if (filterFn) {
                output.push(filterFn(isect, ring0, edge0, start0, end0, frac0, ring1, edge1, start1, end1, frac1, unique));
            } else {
                output.push(isect);
            }
        }

        // Function to return a rbush tree item given an ring and edge number
        function rbushTreeItem(ring, edge) {

            var start = coord[ring][edge];
            var end = coord[ring][edge + 1];
            var minX;
            var maxX;
            var minY;
            var maxY;
            if (start[0] < end[0]) {
                minX = start[0];
                maxX = end[0];
            } else {
                minX = end[0];
                maxX = start[0];
            }
            if (start[1] < end[1]) {
                minY = start[1];
                maxY = end[1];
            } else {
                minY = end[1];
                maxY = start[1];
            }
            return {minX: minX, minY: minY, maxX: maxX, maxY: maxY, ring: ring, edge: edge};
        }
    }

    // Function to compute where two lines (not segments) intersect. From https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
    function intersect(start0, end0, start1, end1) {
        if (equalArrays(start0, start1) || equalArrays(start0, end1) || equalArrays(end0, start1) || equalArrays(end1, start1)) return null;
        var x0 = start0[0],
            y0 = start0[1],
            x1 = end0[0],
            y1 = end0[1],
            x2 = start1[0],
            y2 = start1[1],
            x3 = end1[0],
            y3 = end1[1];
        var denom = (x0 - x1) * (y2 - y3) - (y0 - y1) * (x2 - x3);
        if (denom === 0) return null;
        var x4 = ((x0 * y1 - y0 * x1) * (x2 - x3) - (x0 - x1) * (x2 * y3 - y2 * x3)) / denom;
        var y4 = ((x0 * y1 - y0 * x1) * (y2 - y3) - (y0 - y1) * (x2 * y3 - y2 * x3)) / denom;
        return [x4, y4];
    }

    // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript
    function equalArrays(array1, array2) {
        // if the other array is a falsy value, return
        if (!array1 || !array2)
            return false;

        // compare lengths - can save a lot of time
        if (array1.length !== array2.length)
            return false;

        for (var i = 0, l = array1.length; i < l; i++) {
            // Check if we have nested arrays
            if (array1[i] instanceof Array && array2[i] instanceof Array) {
                // recurse into the nested arrays
                if (!equalArrays(array1[i], array2[i]))
                    return false;
            } else if (array1[i] !== array2[i]) {
                // Warning - two different object instances will never be equal: {x:20} !== {x:20}
                return false;
            }
        }
        return true;
    }

    /**
     * Takes a complex (i.e. self-intersecting) geojson polygon, and breaks it down into its composite simple, non-self-intersecting one-ring polygons.
     *
     * @module simplepolygon
     * @param {Feature} feature Input polygon. This polygon may be unconform the {@link https://en.wikipedia.org/wiki/Simple_Features|Simple Features standard} in the sense that it's inner and outer rings may cross-intersect or self-intersect, that the outer ring must not contain the optional inner rings and that the winding number must not be positive for the outer and negative for the inner rings.
     * @return {FeatureCollection} Feature collection containing the simple, non-self-intersecting one-ring polygon features that the complex polygon is composed of. These simple polygons have properties such as their parent polygon, winding number and net winding number.
     *
     * @example
     * var poly = {
     *   "type": "Feature",
     *   "geometry": {
     *     "type": "Polygon",
     *     "coordinates": [[[0,0],[2,0],[0,2],[2,2],[0,0]]]
     *   }
     * };
     *
     * var result = simplepolygon(poly);
     *
     * // =result
     * // which will be a featureCollection of two polygons, one with coordinates [[[0,0],[2,0],[1,1],[0,0]]], parent -1, winding 1 and net winding 1, and one with coordinates [[[1,1],[0,2],[2,2],[1,1]]], parent -1, winding -1 and net winding -1
     */
    function simplepolygon (feature$$1) {
        // Check input
        if (feature$$1.type != 'Feature') throw new Error('The input must a geojson object of type Feature');
        if ((feature$$1.geometry === undefined) || (feature$$1.geometry == null)) throw new Error('The input must a geojson object with a non-empty geometry');
        if (feature$$1.geometry.type != 'Polygon') throw new Error('The input must be a geojson Polygon');

        // Process input
        var numRings = feature$$1.geometry.coordinates.length;
        var vertices = [];
        for (var i = 0; i < numRings; i++) {
            var ring = feature$$1.geometry.coordinates[i];
            if (!equalArrays$1(ring[0], ring[ring.length - 1])) {
                ring.push(ring[0]); // Close input ring if it is not
            }
            vertices.push.apply(vertices, ring.slice(0, ring.length - 1));
        }
        if (!isUnique(vertices)) throw new Error('The input polygon may not have duplicate vertices (except for the first and last vertex of each ring)');
        var numvertices = vertices.length; // number of input ring vertices, with the last closing vertices not counted

        // Compute self-intersections
        var selfIsectsData = isects(feature$$1, function filterFn(isect, ring0, edge0, start0, end0, frac0, ring1, edge1, start1, end1, frac1, unique) {
            return [isect, ring0, edge0, start0, end0, frac0, ring1, edge1, start1, end1, frac1, unique];
        });
        var numSelfIsect = selfIsectsData.length;

        // If no self-intersections are found, the input rings are the output rings. Hence, we must only compute their winding numbers, net winding numbers and (since ohers rings could lie outside the first ring) parents.
        if (numSelfIsect == 0) {
            var outputFeatureArray = [];
            for (var i = 0; i < numRings; i++) {
                outputFeatureArray.push(polygon([feature$$1.geometry.coordinates[i]], {parent: -1, winding: windingOfRing(feature$$1.geometry.coordinates[i])}));
            }
            var output = featureCollection(outputFeatureArray);
            determineParents();
            setNetWinding();

            return output;
        }

        // If self-intersections are found, we will compute the output rings with the help of two intermediate variables
        // First, we build the pseudo vertex list and intersection list
        // The Pseudo vertex list is an array with for each ring an array with for each edge an array containing the pseudo-vertices (as made by their constructor) that have this ring and edge as ringAndEdgeIn, sorted for each edge by their fractional distance on this edge. It's length hence equals numRings.
        var pseudoVtxListByRingAndEdge = [];
        // The intersection list is an array containing intersections (as made by their constructor). First all numvertices ring-vertex-intersections, then all self-intersections (intra- and inter-ring). The order of the latter is not important but is permanent once given.
        var isectList = [];
        // Adding ring-pseudo-vertices to pseudoVtxListByRingAndEdge and ring-vertex-intersections to isectList
        for (var i = 0; i < numRings; i++) {
            pseudoVtxListByRingAndEdge.push([]);
            for (var j = 0; j < feature$$1.geometry.coordinates[i].length - 1; j++) {
                // Each edge will feature one ring-pseudo-vertex in its array, on the last position. i.e. edge j features the ring-pseudo-vertex of the ring vertex j+1, which has ringAndEdgeIn = [i,j], on the last position.
                pseudoVtxListByRingAndEdge[i].push([new PseudoVtx(feature$$1.geometry.coordinates[i][(j + 1).modulo(feature$$1.geometry.coordinates[i].length - 1)], 1, [i, j], [i, (j + 1).modulo(feature$$1.geometry.coordinates[i].length - 1)], undefined)]);
                // The first numvertices elements in isectList correspond to the ring-vertex-intersections
                isectList.push(new Isect(feature$$1.geometry.coordinates[i][j], [i, (j - 1).modulo(feature$$1.geometry.coordinates[i].length - 1)], [i, j], undefined, undefined, false, true));
            }
        }
        // Adding intersection-pseudo-vertices to pseudoVtxListByRingAndEdge and self-intersections to isectList
        for (var i = 0; i < numSelfIsect; i++) {
        // Adding intersection-pseudo-vertices made using selfIsectsData to pseudoVtxListByRingAndEdge's array corresponding to the incomming ring and edge
            pseudoVtxListByRingAndEdge[selfIsectsData[i][1]][selfIsectsData[i][2]].push(new PseudoVtx(selfIsectsData[i][0], selfIsectsData[i][5], [selfIsectsData[i][1], selfIsectsData[i][2]], [selfIsectsData[i][6], selfIsectsData[i][7]], undefined));
            // selfIsectsData contains double mentions of each intersection, but we only want to add them once to isectList
            if (selfIsectsData[i][11]) isectList.push(new Isect(selfIsectsData[i][0], [selfIsectsData[i][1], selfIsectsData[i][2]], [selfIsectsData[i][6], selfIsectsData[i][7]], undefined, undefined, true, true));
        }
        var numIsect = isectList.length;
        // Sort edge arrays of pseudoVtxListByRingAndEdge by the fractional distance 'param'
        for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
            for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
                pseudoVtxListByRingAndEdge[i][j].sort(function (a, b) { return (a.param < b.param) ? -1 : 1; });
            }
        }

        // Make a spatial index of intersections, in preperation for the following two steps
        var allIsectsAsIsectRbushTreeItem = [];
        for (var i = 0; i < numIsect; i++) {
            allIsectsAsIsectRbushTreeItem.push({minX: isectList[i].coord[0], minY: isectList[i].coord[1], maxX: isectList[i].coord[0], maxY: isectList[i].coord[1], index: i}); // could pass isect: isectList[i], but not necessary
        }
        var isectRbushTree = rbush_1();
        isectRbushTree.load(allIsectsAsIsectRbushTreeItem);

        // Now we will teach each intersection in isectList which is the next intersection along both it's [ring, edge]'s, in two steps.
        // First, we find the next intersection for each pseudo-vertex in pseudoVtxListByRingAndEdge:
        // For each pseudovertex in pseudoVtxListByRingAndEdge (3 loops) look at the next pseudovertex on that edge and find the corresponding intersection by comparing coordinates
        for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
            for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
                for (var k = 0; k < pseudoVtxListByRingAndEdge[i][j].length; k++) {
                    var coordToFind;
                    if (k == pseudoVtxListByRingAndEdge[i][j].length - 1) { // If it's the last pseudoVertex on that edge, then the next pseudoVertex is the first one on the next edge of that ring.
                        coordToFind = pseudoVtxListByRingAndEdge[i][(j + 1).modulo(feature$$1.geometry.coordinates[i].length - 1)][0].coord;
                    } else {
                        coordToFind = pseudoVtxListByRingAndEdge[i][j][k + 1].coord;
                    }
                    var IsectRbushTreeItemFound = isectRbushTree.search({minX: coordToFind[0], minY: coordToFind[1], maxX: coordToFind[0], maxY: coordToFind[1]})[0]; // We can take [0] of the result, because there is only one isect correponding to a pseudo-vertex
                    pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn = IsectRbushTreeItemFound.index;
                }
            }
        }

        // Second, we port this knowledge of the next intersection over to the intersections in isectList, by finding the intersection corresponding to each pseudo-vertex and copying the pseudo-vertex' knownledge of the next-intersection over to the intersection
        for (var i = 0; i < pseudoVtxListByRingAndEdge.length; i++) {
            for (var j = 0; j < pseudoVtxListByRingAndEdge[i].length; j++) {
                for (var k = 0; k < pseudoVtxListByRingAndEdge[i][j].length; k++) {
                    var coordToFind = pseudoVtxListByRingAndEdge[i][j][k].coord;
                    var IsectRbushTreeItemFound = isectRbushTree.search({minX: coordToFind[0], minY: coordToFind[1], maxX: coordToFind[0], maxY: coordToFind[1]})[0]; // We can take [0] of the result, because there is only one isect correponding to a pseudo-vertex
                    var l = IsectRbushTreeItemFound.index;
                    if (l < numvertices) { // Special treatment at ring-vertices: we correct the misnaming that happened in the previous block, since ringAndEdgeOut = ringAndEdge2 for ring vertices.
                        isectList[l].nxtIsectAlongRingAndEdge2 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
                    } else { // Port the knowledge of the next intersection from the pseudo-vertices to the intersections, depending on how the edges are labeled in the pseudo-vertex and intersection.
                        if (equalArrays$1(isectList[l].ringAndEdge1, pseudoVtxListByRingAndEdge[i][j][k].ringAndEdgeIn)) {
                            isectList[l].nxtIsectAlongRingAndEdge1 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
                        } else {
                            isectList[l].nxtIsectAlongRingAndEdge2 = pseudoVtxListByRingAndEdge[i][j][k].nxtIsectAlongEdgeIn;
                        }
                    }
                }
            }
        }
        // This explains why, eventhough when we will walk away from an intersection, we will walk way from the corresponding pseudo-vertex along edgeOut, pseudo-vertices have the property 'nxtIsectAlongEdgeIn' in stead of some propery 'nxtPseudoVtxAlongEdgeOut'. This is because this property (which is easy to find out) is used in the above for nxtIsectAlongRingAndEdge1 and nxtIsectAlongRingAndEdge2!

        // Before we start walking over the intersections to build the output rings, we prepare a queue that stores information on intersections we still have to deal with, and put at least one intersection in it.
        // This queue will contain information on intersections where we can start walking from once the current walk is finished, and its parent output ring (the smallest output ring it lies within, -1 if no parent or parent unknown yet) and its winding number (which we can already determine).
        var queue = [];
        // For each output ring, add the ring-vertex-intersection with the smalles x-value (i.e. the left-most) as a start intersection. By choosing such an extremal intersections, we are sure to start at an intersection that is a convex vertex of its output ring. By adding them all to the queue, we are sure that no rings will be forgotten. If due to ring-intersections such an intersection will be encountered while walking, it will be removed from the queue.
        var i = 0;
        for (var j = 0; j < numRings; j++) {
            var leftIsect = i;
            for (var k = 0; k < feature$$1.geometry.coordinates[j].length - 1; k++) {
                if (isectList[i].coord[0] < isectList[leftIsect].coord[0]) {
                    leftIsect = i;
                }
                i++;
            }
            // Compute winding at this left-most ring-vertex-intersection. We thus this by using our knowledge that this extremal vertex must be a convex vertex.
            // We first find the intersection before and after it, and then use them to determine the winding number of the corresponding output ring, since we know that an extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it would not be is because the winding number we use to compute it is wrong
            var isectAfterLeftIsect = isectList[leftIsect].nxtIsectAlongRingAndEdge2;
            for (var k = 0; k < isectList.length; k++) {
                if ((isectList[k].nxtIsectAlongRingAndEdge1 == leftIsect) || (isectList[k].nxtIsectAlongRingAndEdge2 == leftIsect)) {
                    var isectBeforeLeftIsect = k;
                    break;
                }
            }
            var windingAtIsect = isConvex([isectList[isectBeforeLeftIsect].coord, isectList[leftIsect].coord, isectList[isectAfterLeftIsect].coord], true) ? 1 : -1;

            queue.push({isect: leftIsect, parent: -1, winding: windingAtIsect});
        }
        // Sort the queue by the same criterion used to find the leftIsect: the left-most leftIsect must be last in the queue, such that it will be popped first, such that we will work from out to in regarding input rings. This assumtion is used when predicting the winding number and parent of a new queue member.
        queue.sort(function (a, b) { return (isectList[a.isect].coord > isectList[b.isect].coord) ? -1 : 1; });

        // Initialise output
        var outputFeatureArray = [];

        // While the queue is not empty, take the last object (i.e. its intersection) out and start making an output ring by walking in the direction that has not been walked away over yet.
        while (queue.length > 0) {
        // Get the last object out of the queue
            var popped = queue.pop();
            var startIsect = popped.isect;
            var currentOutputRingParent = popped.parent;
            var currentOutputRingWinding = popped.winding;
            // Make new output ring and add vertex from starting intersection
            var currentOutputRing = outputFeatureArray.length;
            var currentOutputRingCoords = [isectList[startIsect].coord];
            // Set up the variables used while walking over intersections: 'currentIsect', 'nxtIsect' and 'walkingRingAndEdge'
            var currentIsect = startIsect;
            if (isectList[startIsect].ringAndEdge1Walkable) {
                var walkingRingAndEdge = isectList[startIsect].ringAndEdge1;
                var nxtIsect = isectList[startIsect].nxtIsectAlongRingAndEdge1;
            } else {
                var walkingRingAndEdge = isectList[startIsect].ringAndEdge2;
                var nxtIsect = isectList[startIsect].nxtIsectAlongRingAndEdge2;
            }
            // While we have not arrived back at the same intersection, keep walking
            while (!equalArrays$1(isectList[startIsect].coord, isectList[nxtIsect].coord)) {
                currentOutputRingCoords.push(isectList[nxtIsect].coord);
                // If the next intersection is queued, we can remove it, because we will go there now.
                var nxtIsectInQueue = undefined;
                for (var i = 0; i < queue.length; i++) { if (queue[i].isect == nxtIsect) { nxtIsectInQueue = i; break; } }
                if (nxtIsectInQueue != undefined) {
                    queue.splice(nxtIsectInQueue, 1);
                }
                // Arriving at this new intersection, we know which will be our next walking ring and edge (if we came from 1 we will walk away from 2 and vice versa),
                // So we can set it as our new walking ring and intersection and remember that we (will) have walked over it
                // If we have never walked away from this new intersection along the other ring and edge then we will soon do, add the intersection (and the parent wand winding number) to the queue
                // (We can predict the winding number and parent as follows: if the edge is convex, the other output ring started from there will have the alternate winding and lie outside of the current one, and thus have the same parent ring as the current ring. Otherwise, it will have the same winding number and lie inside of the current ring. We are, however, only sure of this of an output ring started from there does not enclose the current ring. This is why the initial queue's intersections must be sorted such that outer ones come out first.)
                // We then update the other two walking variables.
                if (equalArrays$1(walkingRingAndEdge, isectList[nxtIsect].ringAndEdge1)) {
                    walkingRingAndEdge = isectList[nxtIsect].ringAndEdge2;
                    isectList[nxtIsect].ringAndEdge2Walkable = false;
                    if (isectList[nxtIsect].ringAndEdge1Walkable) {
                        var pushing = {isect: nxtIsect};
                        if (isConvex([isectList[currentIsect].coord, isectList[nxtIsect].coord, isectList[isectList[nxtIsect].nxtIsectAlongRingAndEdge2].coord], currentOutputRingWinding == 1)) {
                            pushing.parent = currentOutputRingParent;
                            pushing.winding = -currentOutputRingWinding;
                        } else {
                            pushing.parent = currentOutputRing;
                            pushing.winding = currentOutputRingWinding;
                        }
                        queue.push(pushing);
                    }
                    currentIsect = nxtIsect;
                    nxtIsect = isectList[nxtIsect].nxtIsectAlongRingAndEdge2;
                } else {
                    walkingRingAndEdge = isectList[nxtIsect].ringAndEdge1;
                    isectList[nxtIsect].ringAndEdge1Walkable = false;
                    if (isectList[nxtIsect].ringAndEdge2Walkable) {
                        var pushing = {isect: nxtIsect};
                        if (isConvex([isectList[currentIsect].coord, isectList[nxtIsect].coord, isectList[isectList[nxtIsect].nxtIsectAlongRingAndEdge1].coord], currentOutputRingWinding == 1)) {
                            pushing.parent = currentOutputRingParent;
                            pushing.winding = -currentOutputRingWinding;
                        } else {
                            pushing.parent = currentOutputRing;
                            pushing.winding = currentOutputRingWinding;
                        }
                        queue.push(pushing);
                    }
                    currentIsect = nxtIsect;
                    nxtIsect = isectList[nxtIsect].nxtIsectAlongRingAndEdge1;
                }
            }
            // Close output ring
            currentOutputRingCoords.push(isectList[nxtIsect].coord);
            // Push output ring to output
            outputFeatureArray.push(polygon([currentOutputRingCoords], {index: currentOutputRing, parent: currentOutputRingParent, winding: currentOutputRingWinding, netWinding: undefined}));
        }

        var output = featureCollection(outputFeatureArray);

        determineParents();

        setNetWinding();

        // These functions are also used if no intersections are found
        function determineParents() {
            var featuresWithoutParent = [];
            for (var i = 0; i < output.features.length; i++) {
                if (output.features[i].properties.parent == -1) featuresWithoutParent.push(i);
            }
            if (featuresWithoutParent.length > 1) {
                for (var i = 0; i < featuresWithoutParent.length; i++) {
                    var parent = -1;
                    var parentArea = Infinity;
                    for (var j = 0; j < output.features.length; j++) {
                        if (featuresWithoutParent[i] == j) continue;
                        if (booleanPointInPolygon(output.features[featuresWithoutParent[i]].geometry.coordinates[0][0], output.features[j], {ignoreBoundary: true})) {
                            if (area$1(output.features[j]) < parentArea) {
                                parent = j;
                            }
                        }
                    }
                    output.features[featuresWithoutParent[i]].properties.parent = parent;
                }
            }
        }

        function setNetWinding() {
            for (var i = 0; i < output.features.length; i++) {
                if (output.features[i].properties.parent == -1) {
                    var netWinding = output.features[i].properties.winding;
                    output.features[i].properties.netWinding = netWinding;
                    setNetWindingOfChildren(i, netWinding);
                }
            }
        }

        function setNetWindingOfChildren(parent, ParentNetWinding) {
            for (var i = 0; i < output.features.length; i++) {
                if (output.features[i].properties.parent == parent) {
                    var netWinding = ParentNetWinding + output.features[i].properties.winding;
                    output.features[i].properties.netWinding = netWinding;
                    setNetWindingOfChildren(i, netWinding);
                }
            }
        }


        return output;
    }


    // Constructor for (ring- or intersection-) pseudo-vertices.
    var PseudoVtx = function (coord, param, ringAndEdgeIn, ringAndEdgeOut, nxtIsectAlongEdgeIn) {
        this.coord = coord; // [x,y] of this pseudo-vertex
        this.param = param; // fractional distance of this intersection on incomming edge
        this.ringAndEdgeIn = ringAndEdgeIn; // [ring index, edge index] of incomming edge
        this.ringAndEdgeOut = ringAndEdgeOut; // [ring index, edge index] of outgoing edge
        this.nxtIsectAlongEdgeIn = nxtIsectAlongEdgeIn; // The next intersection when following the incomming edge (so not when following ringAndEdgeOut!)
    };

    // Constructor for an intersection. There are two intersection-pseudo-vertices per self-intersection and one ring-pseudo-vertex per ring-vertex-intersection. Their labels 1 and 2 are not assigned a particular meaning but are permanent once given.
    var Isect = function (coord, ringAndEdge1, ringAndEdge2, nxtIsectAlongRingAndEdge1, nxtIsectAlongRingAndEdge2, ringAndEdge1Walkable, ringAndEdge2Walkable) {
        this.coord = coord; // [x,y] of this intersection
        this.ringAndEdge1 = ringAndEdge1; // first edge of this intersection
        this.ringAndEdge2 = ringAndEdge2; // second edge of this intersection
        this.nxtIsectAlongRingAndEdge1 = nxtIsectAlongRingAndEdge1; // the next intersection when following ringAndEdge1
        this.nxtIsectAlongRingAndEdge2 = nxtIsectAlongRingAndEdge2; // the next intersection when following ringAndEdge2
        this.ringAndEdge1Walkable = ringAndEdge1Walkable; // May we (still) walk away from this intersection over ringAndEdge1?
        this.ringAndEdge2Walkable = ringAndEdge2Walkable; // May we (still) walk away from this intersection over ringAndEdge2?
    };

    // Function to determine if three consecutive points of a simple, non-self-intersecting ring make up a convex vertex, assuming the ring is right- or lefthanded
    function isConvex(pts, righthanded) {
        // 'pts' is an [x,y] pair
        // 'righthanded' is a boolean
        if (typeof (righthanded) === 'undefined') righthanded = true;
        if (pts.length != 3) throw new Error('This function requires an array of three points [x,y]');
        var d = (pts[1][0] - pts[0][0]) * (pts[2][1] - pts[0][1]) - (pts[1][1] - pts[0][1]) * (pts[2][0] - pts[0][0]);
        return (d >= 0) == righthanded;
    }

    // Function to compute winding of simple, non-self-intersecting ring
    function windingOfRing(ring) {
        // 'ring' is an array of [x,y] pairs with the last equal to the first
        // Compute the winding number based on the vertex with the smallest x-value, it precessor and successor. An extremal vertex of a simple, non-self-intersecting ring is always convex, so the only reason it is not is because the winding number we use to compute it is wrong
        var leftVtx = 0;
        for (var i = 0; i < ring.length - 1; i++) { if (ring[i][0] < ring[leftVtx][0]) leftVtx = i; }
        if (isConvex([ring[(leftVtx - 1).modulo(ring.length - 1)], ring[leftVtx], ring[(leftVtx + 1).modulo(ring.length - 1)]], true)) {
            var winding = 1;
        } else {
            var winding = -1;
        }
        return winding;
    }

    // Function to compare Arrays of numbers. From http://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript
    function equalArrays$1(array1, array2) {
        // if the other array is a falsy value, return
        if (!array1 || !array2)
            return false;

        // compare lengths - can save a lot of time
        if (array1.length != array2.length)
            return false;

        for (var i = 0, l = array1.length; i < l; i++) {
            // Check if we have nested arrays
            if (array1[i] instanceof Array && array2[i] instanceof Array) {
                // recurse into the nested arrays
                if (!equalArrays$1(array1[i], array2[i]))
                    return false;
            } else if (array1[i] != array2[i]) {
                // Warning - two different object instances will never be equal: {x:20} != {x:20}
                return false;
            }
        }
        return true;
    }

    // Fix Javascript modulo for negative number. From http://stackoverflow.com/questions/4467539/javascript-modulo-not-behaving
    Number.prototype.modulo = function (n) {
        return ((this % n) + n) % n;
    };

    // Function to check if array is unique (i.e. all unique elements, i.e. no duplicate elements)
    function isUnique(array) {
        var u = {};
        var isUnique = 1;
        for (var i = 0, l = array.length; i < l; ++i) {
            if (u.hasOwnProperty(array[i])) {
                isUnique = 0;
                break;
            }
            u[array[i]] = 1;
        }
        return isUnique;
    }

    /**
     * Takes a kinked polygon and returns a feature collection of polygons that have no kinks.
     * Uses [simplepolygon](https://github.com/mclaeysb/simplepolygon) internally.
     *
     * @name unkinkPolygon
     * @param {FeatureCollection|Feature<Polygon|MultiPolygon>} geojson GeoJSON Polygon or MultiPolygon
     * @returns {FeatureCollection<Polygon>} Unkinked polygons
     * @example
     * var poly = turf.polygon([[[0, 0], [2, 0], [0, 2], [2, 2], [0, 0]]]);
     *
     * var result = turf.unkinkPolygon(poly);
     *
     * //addToMap
     * var addToMap = [poly, result]
     */
    function unkinkPolygon(geojson) {
        var features = [];
        flattenEach(geojson, function (feature$$1) {
            if (feature$$1.geometry.type !== 'Polygon') return;
            featureEach(simplepolygon(feature$$1), function (poly) {
                features.push(polygon(poly.geometry.coordinates, feature$$1.properties));
            });
        });
        return featureCollection(features);
    }

    var D2R = Math.PI / 180;
    var R2D = 180 / Math.PI;

    var Coord = function (lon, lat) {
        this.lon = lon;
        this.lat = lat;
        this.x = D2R * lon;
        this.y = D2R * lat;
    };

    Coord.prototype.view = function () {
        return String(this.lon).slice(0, 4) + ',' + String(this.lat).slice(0, 4);
    };

    Coord.prototype.antipode = function () {
        var anti_lat = -1 * this.lat;
        var anti_lon = (this.lon < 0) ? 180 + this.lon : (180 - this.lon) * -1;
        return new Coord(anti_lon, anti_lat);
    };

    var LineString = function () {
        this.coords = [];
        this.length = 0;
    };

    LineString.prototype.move_to = function (coord) {
        this.length++;
        this.coords.push(coord);
    };

    var Arc = function (properties) {
        this.properties = properties || {};
        this.geometries = [];
    };

    Arc.prototype.json = function () {
        if (this.geometries.length <= 0) {
            return {'geometry': { 'type': 'LineString', 'coordinates': null },
                'type': 'Feature', 'properties': this.properties
            };
        } else if (this.geometries.length === 1) {
            return {'geometry': { 'type': 'LineString', 'coordinates': this.geometries[0].coords },
                'type': 'Feature', 'properties': this.properties
            };
        } else {
            var multiline = [];
            for (var i = 0; i < this.geometries.length; i++) {
                multiline.push(this.geometries[i].coords);
            }
            return {'geometry': { 'type': 'MultiLineString', 'coordinates': multiline },
                'type': 'Feature', 'properties': this.properties
            };
        }
    };

    // TODO - output proper multilinestring
    Arc.prototype.wkt = function () {
        var wkt_string = '';
        var wkt = 'LINESTRING(';
        var collect = function (c) { wkt += c[0] + ' ' + c[1] + ','; };
        for (var i = 0; i < this.geometries.length; i++) {
            if (this.geometries[i].coords.length === 0) {
                return 'LINESTRING(empty)';
            } else {
                var coords = this.geometries[i].coords;
                coords.forEach(collect);
                wkt_string += wkt.substring(0, wkt.length - 1) + ')';
            }
        }
        return wkt_string;
    };

    /*
     * http://en.wikipedia.org/wiki/Great-circle_distance
     *
     */
    var GreatCircle = function (start, end, properties) {
        if (!start || start.x === undefined || start.y === undefined) {
            throw new Error('GreatCircle constructor expects two args: start and end objects with x and y properties');
        }
        if (!end || end.x === undefined || end.y === undefined) {
            throw new Error('GreatCircle constructor expects two args: start and end objects with x and y properties');
        }
        this.start = new Coord(start.x, start.y);
        this.end = new Coord(end.x, end.y);
        this.properties = properties || {};

        var w = this.start.x - this.end.x;
        var h = this.start.y - this.end.y;
        var z = Math.pow(Math.sin(h / 2.0), 2) +
                    Math.cos(this.start.y) *
                       Math.cos(this.end.y) *
                         Math.pow(Math.sin(w / 2.0), 2);
        this.g = 2.0 * Math.asin(Math.sqrt(z));

        if (this.g === Math.PI) {
            throw new Error('it appears ' + start.view() + ' and ' + end.view() + ' are \'antipodal\', e.g diametrically opposite, thus there is no single route but rather infinite');
        } else if (isNaN(this.g)) {
            throw new Error('could not calculate great circle between ' + start + ' and ' + end);
        }
    };

    /*
     * http://williams.best.vwh.net/avform.htm#Intermediate
     */
    GreatCircle.prototype.interpolate = function (f) {
        var A = Math.sin((1 - f) * this.g) / Math.sin(this.g);
        var B = Math.sin(f * this.g) / Math.sin(this.g);
        var x = A * Math.cos(this.start.y) * Math.cos(this.start.x) + B * Math.cos(this.end.y) * Math.cos(this.end.x);
        var y = A * Math.cos(this.start.y) * Math.sin(this.start.x) + B * Math.cos(this.end.y) * Math.sin(this.end.x);
        var z = A * Math.sin(this.start.y) + B * Math.sin(this.end.y);
        var lat = R2D * Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
        var lon = R2D * Math.atan2(y, x);
        return [lon, lat];
    };



    /*
     * Generate points along the great circle
     */
    GreatCircle.prototype.Arc = function (npoints, options) {
        var first_pass = [];
        if (!npoints || npoints <= 2) {
            first_pass.push([this.start.lon, this.start.lat]);
            first_pass.push([this.end.lon, this.end.lat]);
        } else {
            var delta = 1.0 / (npoints - 1);
            for (var i = 0; i < npoints; ++i) {
                var step = delta * i;
                var pair = this.interpolate(step);
                first_pass.push(pair);
            }
        }
        /* partial port of dateline handling from:
          gdal/ogr/ogrgeometryfactory.cpp

          TODO - does not handle all wrapping scenarios yet
        */
        var bHasBigDiff = false;
        var dfMaxSmallDiffLong = 0;
        // from http://www.gdal.org/ogr2ogr.html
        // -datelineoffset:
        // (starting with GDAL 1.10) offset from dateline in degrees (default long. = +/- 10deg, geometries within 170deg to -170deg will be splited)
        var dfDateLineOffset = options && options.offset ? options.offset : 10;
        var dfLeftBorderX = 180 - dfDateLineOffset;
        var dfRightBorderX = -180 + dfDateLineOffset;
        var dfDiffSpace = 360 - dfDateLineOffset;

        // https://github.com/OSGeo/gdal/blob/7bfb9c452a59aac958bff0c8386b891edf8154ca/gdal/ogr/ogrgeometryfactory.cpp#L2342
        for (var j = 1; j < first_pass.length; ++j) {
            var dfPrevX = first_pass[j - 1][0];
            var dfX = first_pass[j][0];
            var dfDiffLong = Math.abs(dfX - dfPrevX);
            if (dfDiffLong > dfDiffSpace &&
                ((dfX > dfLeftBorderX && dfPrevX < dfRightBorderX) || (dfPrevX > dfLeftBorderX && dfX < dfRightBorderX))) {
                bHasBigDiff = true;
            } else if (dfDiffLong > dfMaxSmallDiffLong) {
                dfMaxSmallDiffLong = dfDiffLong;
            }
        }

        var poMulti = [];
        if (bHasBigDiff && dfMaxSmallDiffLong < dfDateLineOffset) {
            var poNewLS = [];
            poMulti.push(poNewLS);
            for (var k = 0; k < first_pass.length; ++k) {
                var dfX0 = parseFloat(first_pass[k][0]);
                if (k > 0 &&  Math.abs(dfX0 - first_pass[k - 1][0]) > dfDiffSpace) {
                    var dfX1 = parseFloat(first_pass[k - 1][0]);
                    var dfY1 = parseFloat(first_pass[k - 1][1]);
                    var dfX2 = parseFloat(first_pass[k][0]);
                    var dfY2 = parseFloat(first_pass[k][1]);
                    if (dfX1 > -180 && dfX1 < dfRightBorderX && dfX2 === 180 &&
                        k + 1 < first_pass.length &&
                       first_pass[k - 1][0] > -180 && first_pass[k - 1][0] < dfRightBorderX) {
                        poNewLS.push([-180, first_pass[k][1]]);
                        k++;
                        poNewLS.push([first_pass[k][0], first_pass[k][1]]);
                        continue;
                    } else if (dfX1 > dfLeftBorderX && dfX1 < 180 && dfX2 === -180 &&
                         k + 1 < first_pass.length &&
                         first_pass[k - 1][0] > dfLeftBorderX && first_pass[k - 1][0] < 180) {
                        poNewLS.push([180, first_pass[k][1]]);
                        k++;
                        poNewLS.push([first_pass[k][0], first_pass[k][1]]);
                        continue;
                    }

                    if (dfX1 < dfRightBorderX && dfX2 > dfLeftBorderX) {
                        // swap dfX1, dfX2
                        var tmpX = dfX1;
                        dfX1 = dfX2;
                        dfX2 = tmpX;
                        // swap dfY1, dfY2
                        var tmpY = dfY1;
                        dfY1 = dfY2;
                        dfY2 = tmpY;
                    }
                    if (dfX1 > dfLeftBorderX && dfX2 < dfRightBorderX) {
                        dfX2 += 360;
                    }

                    if (dfX1 <= 180 && dfX2 >= 180 && dfX1 < dfX2) {
                        var dfRatio = (180 - dfX1) / (dfX2 - dfX1);
                        var dfY = dfRatio * dfY2 + (1 - dfRatio) * dfY1;
                        poNewLS.push([first_pass[k - 1][0] > dfLeftBorderX ? 180 : -180, dfY]);
                        poNewLS = [];
                        poNewLS.push([first_pass[k - 1][0] > dfLeftBorderX ? -180 : 180, dfY]);
                        poMulti.push(poNewLS);
                    } else {
                        poNewLS = [];
                        poMulti.push(poNewLS);
                    }
                    poNewLS.push([dfX0, first_pass[k][1]]);
                } else {
                    poNewLS.push([first_pass[k][0], first_pass[k][1]]);
                }
            }
        } else {
            // add normally
            var poNewLS0 = [];
            poMulti.push(poNewLS0);
            for (var l = 0; l < first_pass.length; ++l) {
                poNewLS0.push([first_pass[l][0], first_pass[l][1]]);
            }
        }

        var arc = new Arc(this.properties);
        for (var m = 0; m < poMulti.length; ++m) {
            var line = new LineString();
            arc.geometries.push(line);
            var points = poMulti[m];
            for (var j0 = 0; j0 < points.length; ++j0) {
                line.move_to(points[j0]);
            }
        }
        return arc;
    };

    /**
     * Calculate great circles routes as {@link LineString}
     *
     * @name greatCircle
     * @param {Coord} start source point feature
     * @param {Coord} end destination point feature
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] line feature properties
     * @param {number} [options.npoints=100] number of points
     * @param {number} [options.offset=10] offset controls the likelyhood that lines will
     * be split which cross the dateline. The higher the number the more likely.
     * @returns {Feature<LineString>} great circle line feature
     * @example
     * var start = turf.point([-122, 48]);
     * var end = turf.point([-77, 39]);
     *
     * var greatCircle = turf.greatCircle(start, end, {'name': 'Seattle to DC'});
     *
     * //addToMap
     * var addToMap = [start, end, greatCircle]
     */
    function greatCircle(start, end, options) {
        // Optional parameters
        options = options || {};
        if (typeof options !== 'object') throw new Error('options is invalid');
        var properties = options.properties;
        var npoints = options.npoints;
        var offset = options.offset;

        start = getCoord(start);
        end = getCoord(end);
        properties = properties || {};
        npoints = npoints || 100;
        offset = offset || 10;

        var generator = new GreatCircle({x: start[0], y: start[1]}, {x: end[0], y: end[1]}, properties);

        /* eslint-disable */
        var line = generator.Arc(npoints, {offset: offset});
        /* eslint-enable */

        return line.json();
    }

    /**
     * Split a LineString by another GeoJSON Feature.
     *
     * @name lineSplit
     * @param {Feature<LineString>} line LineString Feature to split
     * @param {Feature<any>} splitter Feature used to split line
     * @returns {FeatureCollection<LineString>} Split LineStrings
     * @example
     * var line = turf.lineString([[120, -25], [145, -25]]);
     * var splitter = turf.lineString([[130, -15], [130, -35]]);
     *
     * var split = turf.lineSplit(line, splitter);
     *
     * //addToMap
     * var addToMap = [line, splitter]
     */
    function lineSplit(line, splitter) {
        if (!line) throw new Error('line is required');
        if (!splitter) throw new Error('splitter is required');

        var lineType = getType(line);
        var splitterType = getType(splitter);

        if (lineType !== 'LineString') throw new Error('line must be LineString');
        if (splitterType === 'FeatureCollection') throw new Error('splitter cannot be a FeatureCollection');
        if (splitterType === 'GeometryCollection') throw new Error('splitter cannot be a GeometryCollection');

        // remove excessive decimals from splitter
        // to avoid possible approximation issues in rbush
        var truncatedSplitter = truncate(splitter, {precision: 7});

        switch (splitterType) {
        case 'Point':
            return splitLineWithPoint(line, truncatedSplitter);
        case 'MultiPoint':
            return splitLineWithPoints(line, truncatedSplitter);
        case 'LineString':
        case 'MultiLineString':
        case 'Polygon':
        case 'MultiPolygon':
            return splitLineWithPoints(line, lineIntersect(line, truncatedSplitter));
        }
    }

    /**
     * Split LineString with MultiPoint
     *
     * @private
     * @param {Feature<LineString>} line LineString
     * @param {FeatureCollection<Point>} splitter Point
     * @returns {FeatureCollection<LineString>} split LineStrings
     */
    function splitLineWithPoints(line, splitter) {
        var results = [];
        var tree = geojsonRbush_1();

        flattenEach(splitter, function (point$$1) {
            // Add index/id to features (needed for filter)
            results.forEach(function (feature$$1, index) {
                feature$$1.id = index;
            });
            // First Point - doesn't need to handle any previous line results
            if (!results.length) {
                results = splitLineWithPoint(line, point$$1).features;

                // Add Square BBox to each feature for GeoJSON-RBush
                results.forEach(function (feature$$1) {
                    if (!feature$$1.bbox) feature$$1.bbox = square(bbox(feature$$1));
                });
                tree.load(featureCollection(results));
            // Split with remaining points - lines might needed to be split multiple times
            } else {
                // Find all lines that are within the splitter's bbox
                var search = tree.search(point$$1);

                if (search.features.length) {
                    // RBush might return multiple lines - only process the closest line to splitter
                    var closestLine = findClosestFeature(point$$1, search);

                    // Remove closest line from results since this will be split into two lines
                    // This removes any duplicates inside the results & index
                    results = results.filter(function (feature$$1) { return feature$$1.id !== closestLine.id; });
                    tree.remove(closestLine);

                    // Append the two newly split lines into the results
                    featureEach(splitLineWithPoint(closestLine, point$$1), function (line) {
                        results.push(line);
                        tree.insert(line);
                    });
                }
            }
        });
        return featureCollection(results);
    }

    /**
     * Split LineString with Point
     *
     * @private
     * @param {Feature<LineString>} line LineString
     * @param {Feature<Point>} splitter Point
     * @returns {FeatureCollection<LineString>} split LineStrings
     */
    function splitLineWithPoint(line, splitter) {
        var results = [];

        // handle endpoints
        var startPoint = getCoords(line)[0];
        var endPoint = getCoords(line)[line.geometry.coordinates.length - 1];
        if (pointsEquals(startPoint, getCoord(splitter)) ||
            pointsEquals(endPoint, getCoord(splitter))) return featureCollection([line]);

        // Create spatial index
        var tree = geojsonRbush_1();
        var segments = lineSegment(line);
        tree.load(segments);

        // Find all segments that are within bbox of splitter
        var search = tree.search(splitter);

        // Return itself if point is not within spatial index
        if (!search.features.length) return featureCollection([line]);

        // RBush might return multiple lines - only process the closest line to splitter
        var closestSegment = findClosestFeature(splitter, search);

        // Initial value is the first point of the first segments (beginning of line)
        var initialValue = [startPoint];
        var lastCoords = featureReduce(segments, function (previous, current, index) {
            var currentCoords = getCoords(current)[1];
            var splitterCoords = getCoord(splitter);

            // Location where segment intersects with line
            if (index === closestSegment.id) {
                previous.push(splitterCoords);
                results.push(lineString(previous));
                // Don't duplicate splitter coordinate (Issue #688)
                if (pointsEquals(splitterCoords, currentCoords)) return [splitterCoords];
                return [splitterCoords, currentCoords];

            // Keep iterating over coords until finished or intersection is found
            } else {
                previous.push(currentCoords);
                return previous;
            }
        }, initialValue);
        // Append last line to final split results
        if (lastCoords.length > 1) {
            results.push(lineString(lastCoords));
        }
        return featureCollection(results);
    }


    /**
     * Find Closest Feature
     *
     * @private
     * @param {Feature<Point>} point Feature must be closest to this point
     * @param {FeatureCollection<LineString>} lines Collection of Features
     * @returns {Feature<LineString>} closest LineString
     */
    function findClosestFeature(point$$1, lines) {
        if (!lines.features.length) throw new Error('lines must contain features');
        // Filter to one segment that is the closest to the line
        if (lines.features.length === 1) return lines.features[0];

        var closestFeature;
        var closestDistance = Infinity;
        featureEach(lines, function (segment) {
            var pt = nearestPointOnLine(segment, point$$1);
            var dist = pt.properties.dist;
            if (dist < closestDistance) {
                closestFeature = segment;
                closestDistance = dist;
            }
        });
        return closestFeature;
    }

    /**
     * Compares two points and returns if they are equals
     *
     * @private
     * @param {Array<number>} pt1 point
     * @param {Array<number>} pt2 point
     * @returns {boolean} true if they are equals
     */
    function pointsEquals(pt1, pt2) {
        return pt1[0] === pt2[0] && pt1[1] === pt2[1];
    }

    /**
     * Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2;
     * 0 bearing is North of center point, positive clockwise.
     *
     * @name lineArc
     * @param {Coord} center center point
     * @param {number} radius radius of the circle
     * @param {number} bearing1 angle, in decimal degrees, of the first radius of the arc
     * @param {number} bearing2 angle, in decimal degrees, of the second radius of the arc
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.steps=64] number of steps
     * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
     * @returns {Feature<LineString>} line arc
     * @example
     * var center = turf.point([-75, 40]);
     * var radius = 5;
     * var bearing1 = 25;
     * var bearing2 = 47;
     *
     * var arc = turf.lineArc(center, radius, bearing1, bearing2);
     *
     * //addToMap
     * var addToMap = [center, arc]
     */
    function lineArc(center, radius, bearing1, bearing2, options) {
        options = checkIfOptionsExist(options);
        // default params
        const steps = options.steps || 64;

        const angle1 = convertAngleTo360(bearing1);
        const angle2 = convertAngleTo360(bearing2);
        const properties = (!Array.isArray(center) && center.type === "Feature")  ? center.properties : {};

        // handle angle parameters
        if (angle1 === angle2) {
            return lineString(circle(center, radius, options).geometry.coordinates[0], properties);
        }
        const arcStartDegree = angle1;
        const arcEndDegree = (angle1 < angle2) ? angle2 : angle2 + 360;

        let alfa = arcStartDegree;
        const coordinates = [];
        let i = 0;

        while (alfa < arcEndDegree) {
            coordinates.push(destination(center, radius, alfa, options).geometry.coordinates);
            i++;
            alfa = arcStartDegree + i * 360 / steps;
        }
        if (alfa > arcEndDegree) {
            coordinates.push(destination(center, radius, arcEndDegree, options).geometry.coordinates);
        }
        return lineString(coordinates, properties);
    }

    /**
     * Takes any angle in  degrees
     * and returns a valid angle between 0-360 degrees
     *
     * @private
     * @param {number} alfa angle between -180-180 degrees
     * @returns {number} angle between 0-360 degrees
     */
    function convertAngleTo360(alfa) {
        let beta = alfa % 360;
        if (beta < 0) {
            beta += 360;
        }
        return beta;
    }

    /**
     * Converts a {@link Polygon} to {@link LineString|(Multi)LineString} or {@link MultiPolygon} to a
     * {@link FeatureCollection} of {@link LineString|(Multi)LineString}.
     *
     * @name polygonToLine
     * @param {Feature<Polygon|MultiPolygon>} poly Feature to convert
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] translates GeoJSON properties to Feature
     * @returns {FeatureCollection|Feature<LineString|MultiLinestring>} converted (Multi)Polygon to (Multi)LineString
     * @example
     * var poly = turf.polygon([[[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]]);
     *
     * var line = turf.polygonToLine(poly);
     *
     * //addToMap
     * var addToMap = [line];
     */
    function polygonToLine (poly, options) {
        options = checkIfOptionsExist(options);
        const geom = getGeom(poly);
        if (!options.properties && poly.type === "Feature") { options.properties = poly.properties; }
        switch (geom.type) {
            case "Polygon": return polygonToLine$1(geom, options);
            case "MultiPolygon": return multiPolygonToLine(geom, options);
            default: throw new Error("invalid poly");
        }
    }

    /**
     * @private
     */
    function polygonToLine$1(poly, options) {
        options = checkIfOptionsExist(options);
        const geom = getGeom(poly);
        const type = geom.type;
        const coords = geom.coordinates;
        const properties = options.properties ? options.properties : poly.type === "Feature" ? poly.properties : {};

        return coordsToLine(coords, properties);
    }

    /**
     * @private
     */
    function multiPolygonToLine(multiPoly, options) {
        options = checkIfOptionsExist(options);
        const geom = getGeom(multiPoly);
        const type = geom.type;
        const coords = geom.coordinates;
        const properties = options.properties ? options.properties :
            multiPoly.type === "Feature" ? multiPoly.properties : {};

        const lines = [];
        coords.forEach(function (coord) {
            lines.push(coordsToLine(coord, properties));
        });
        return featureCollection(lines);
    }

    /**
     * @private
     */
    function coordsToLine(coords, properties) {
        if (coords.length > 1) { return multiLineString(coords, properties); }
        return lineString(coords[0], properties);
    }

    /**
     * Converts (Multi)LineString(s) to Polygon(s).
     *
     * @name lineToPolygon
     * @param {FeatureCollection|Feature<LineString|MultiLineString>} lines Features to convert
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] translates GeoJSON properties to Feature
     * @param {boolean} [options.autoComplete=true] auto complete linestrings (matches first & last coordinates)
     * @param {boolean} [options.orderCoords=true] sorts linestrings to place outer ring at the first position of the coordinates
     * @returns {Feature<Polygon|MultiPolygon>} converted to Polygons
     * @example
     * var line = turf.lineString([[125, -30], [145, -30], [145, -20], [125, -20], [125, -30]]);
     *
     * var polygon = turf.lineToPolygon(line);
     *
     * //addToMap
     * var addToMap = [polygon];
     */
    function lineToPolygon(lines, options) {
        // Optional parameters
        var properties = options.properties;
        var autoComplete = options.autoComplete;
        var orderCoords = options.orderCoords;

        // default params
        autoComplete = (autoComplete !== undefined) ? autoComplete : true;
        orderCoords = (orderCoords !== undefined) ? orderCoords : true;

        switch (lines.type) {
            case 'FeatureCollection':
                var coords = [];
                lines.features.forEach(function (line) {
                    coords.push(getCoords(lineStringToPolygon(line, {}, autoComplete, orderCoords)));
                });
                return multiPolygon(coords, properties);
            default:
                return lineStringToPolygon(lines, properties, autoComplete, orderCoords);
        }
    }

    /**
     * LineString to Polygon
     *
     * @private
     * @param {Feature<LineString|MultiLineString>} line line
     * @param {Object} [properties] translates GeoJSON properties to Feature
     * @param {boolean} [autoComplete=true] auto complete linestrings
     * @param {boolean} [orderCoords=true] sorts linestrings to place outer ring at the first position of the coordinates
     * @returns {Feature<Polygon>} line converted to Polygon
     */
    function lineStringToPolygon(line, properties, autoComplete, orderCoords) {
        properties = properties ? properties : (line.type === 'Feature') ? line.properties : {};
        var geom = getGeom(line);
        var coords = geom.coordinates;
        var type = geom.type;

        if (!coords.length) throw new Error('line must contain coordinates');

        switch (type) {
        case 'LineString':
            if (autoComplete) coords = autoCompleteCoords(coords);
            return polygon([coords], properties);
        case 'MultiLineString':
            var multiCoords = [];
            var largestArea = 0;

            coords.forEach(function (coord) {
                if (autoComplete) coord = autoCompleteCoords(coord);

                // Largest LineString to be placed in the first position of the coordinates array
                if (orderCoords) {
                    var area = calculateArea$1(bbox(lineString(coord)));
                    if (area > largestArea) {
                        multiCoords.unshift(coord);
                        largestArea = area;
                    } else multiCoords.push(coord);
                } else {
                    multiCoords.push(coord);
                }
            });
            return polygon(multiCoords, properties);
        default:
            throw new Error('geometry type ' + type + ' is not supported');
        }
    }

    /**
     * Auto Complete Coords - matches first & last coordinates
     *
     * @private
     * @param {Array<Array<number>>} coords Coordinates
     * @returns {Array<Array<number>>} auto completed coordinates
     */
    function autoCompleteCoords(coords) {
        var first = coords[0];
        var x1 = first[0];
        var y1 = first[1];
        var last = coords[coords.length - 1];
        var x2 = last[0];
        var y2 = last[1];
        if (x1 !== x2 || y1 !== y2) {
            coords.push(first);
        }
        return coords;
    }

    /**
     * area - quick approximate area calculation (used to sort)
     *
     * @private
     * @param {Array<number>} bbox BBox [west, south, east, north]
     * @returns {number} very quick area calculation
     */
    function calculateArea$1(bbox$$1) {
        var west = bbox$$1[0];
        var south = bbox$$1[1];
        var east = bbox$$1[2];
        var north = bbox$$1[3];
        return Math.abs(west - east) * Math.abs(south - north);
    }

    // Cohen-Sutherland line clippign algorithm, adapted to efficiently
    // handle polylines rather than just segments

    function lineclip(points, bbox, result) {

        var len = points.length,
            codeA = bitCode(points[0], bbox),
            part = [],
            i, a, b, codeB, lastCode;

        if (!result) result = [];

        for (i = 1; i < len; i++) {
            a = points[i - 1];
            b = points[i];
            codeB = lastCode = bitCode(b, bbox);

            while (true) {

                if (!(codeA | codeB)) { // accept
                    part.push(a);

                    if (codeB !== lastCode) { // segment went outside
                        part.push(b);

                        if (i < len - 1) { // start a new line
                            result.push(part);
                            part = [];
                        }
                    } else if (i === len - 1) {
                        part.push(b);
                    }
                    break;

                } else if (codeA & codeB) { // trivial reject
                    break;

                } else if (codeA) { // a outside, intersect with clip edge
                    a = intersect$1(a, b, codeA, bbox);
                    codeA = bitCode(a, bbox);

                } else { // b outside
                    b = intersect$1(a, b, codeB, bbox);
                    codeB = bitCode(b, bbox);
                }
            }

            codeA = lastCode;
        }

        if (part.length) result.push(part);

        return result;
    }

    // Sutherland-Hodgeman polygon clipping algorithm

    function polygonclip(points, bbox) {

        var result, edge, prev, prevInside, i, p, inside;

        // clip against each side of the clip rectangle
        for (edge = 1; edge <= 8; edge *= 2) {
            result = [];
            prev = points[points.length - 1];
            prevInside = !(bitCode(prev, bbox) & edge);

            for (i = 0; i < points.length; i++) {
                p = points[i];
                inside = !(bitCode(p, bbox) & edge);

                // if segment goes through the clip window, add an intersection
                if (inside !== prevInside) result.push(intersect$1(prev, p, edge, bbox));

                if (inside) result.push(p); // add a point if it's inside

                prev = p;
                prevInside = inside;
            }

            points = result;

            if (!points.length) break;
        }

        return result;
    }

    // intersect a segment against one of the 4 lines that make up the bbox

    function intersect$1(a, b, edge, bbox) {
        return edge & 8 ? [a[0] + (b[0] - a[0]) * (bbox[3] - a[1]) / (b[1] - a[1]), bbox[3]] : // top
               edge & 4 ? [a[0] + (b[0] - a[0]) * (bbox[1] - a[1]) / (b[1] - a[1]), bbox[1]] : // bottom
               edge & 2 ? [bbox[2], a[1] + (b[1] - a[1]) * (bbox[2] - a[0]) / (b[0] - a[0])] : // right
               edge & 1 ? [bbox[0], a[1] + (b[1] - a[1]) * (bbox[0] - a[0]) / (b[0] - a[0])] : // left
               null;
    }

    // bit code reflects the point position relative to the bbox:

    //         left  mid  right
    //    top  1001  1000  1010
    //    mid  0001  0000  0010
    // bottom  0101  0100  0110

    function bitCode(p, bbox) {
        var code = 0;

        if (p[0] < bbox[0]) code |= 1; // left
        else if (p[0] > bbox[2]) code |= 2; // right

        if (p[1] < bbox[1]) code |= 4; // bottom
        else if (p[1] > bbox[3]) code |= 8; // top

        return code;
    }

    /**
     * Takes a {@link Feature} and a bbox and clips the feature to the bbox using
     * [lineclip](https://github.com/mapbox/lineclip).
     * May result in degenerate edges when clipping Polygons.
     *
     * @name bboxClip
     * @param {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} feature feature to clip to the bbox
     * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
     * @returns {Feature<LineString|MultiLineString|Polygon|MultiPolygon>} clipped Feature
     * @example
     * var bbox = [0, 0, 10, 10];
     * var poly = turf.polygon([[[2, 2], [8, 4], [12, 8], [3, 7], [2, 2]]]);
     *
     * var clipped = turf.bboxClip(poly, bbox);
     *
     * //addToMap
     * var addToMap = [bbox, poly, clipped]
     */
    function bboxClip(feature$$1, bbox) {
        const geom = getGeom(feature$$1);
        const type = geom.type;
        const properties = feature$$1.type === 'Feature' ? feature$$1.properties : {};
        let coords = geom.coordinates;

        switch (type) {
        case 'LineString':
        case 'MultiLineString': //eslint-disable-line
            const lines = [];
            if (type === 'LineString') { coords = [coords]; }
            coords.forEach((line) => {
                lineclip(line, bbox, lines);
            });
            if (lines.length === 1) { return lineString(lines[0], properties); }
            return multiLineString(lines, properties);
        case 'Polygon':
            return polygon(clipPolygon(coords, bbox), properties);
        case 'MultiPolygon':
            return multiPolygon(coords.map((poly) => {
                return clipPolygon(poly, bbox);
            }), properties);
        default:
            throw new Error('geometry ' + type + ' not supported');
        }
    }

    function clipPolygon(rings, bbox) {
        const outRings = [];
        for (const ring of rings) {
            const clipped = polygonclip(ring, bbox);
            if (clipped.length > 0) {
                if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
                    clipped.push(clipped[0]);
                }
                if (clipped.length >= 4) {
                    outRings.push(clipped);
                }
            }
        }
        return outRings;
    }

    var keys = createCommonjsModule(function (module, exports) {
    exports = module.exports = typeof Object.keys === 'function'
      ? Object.keys : shim;

    exports.shim = shim;
    function shim (obj) {
      var keys = [];
      for (var key in obj) keys.push(key);
      return keys;
    }
    });
    var keys_1 = keys.shim;

    var keys$1 = /*#__PURE__*/Object.freeze({
        default: keys,
        __moduleExports: keys,
        shim: keys_1
    });

    var is_arguments = createCommonjsModule(function (module, exports) {
    var supportsArgumentsClass = (function(){
      return Object.prototype.toString.call(arguments)
    })() == '[object Arguments]';

    exports = module.exports = supportsArgumentsClass ? supported : unsupported;

    exports.supported = supported;
    function supported(object) {
      return Object.prototype.toString.call(object) == '[object Arguments]';
    }
    exports.unsupported = unsupported;
    function unsupported(object){
      return object &&
        typeof object == 'object' &&
        typeof object.length == 'number' &&
        Object.prototype.hasOwnProperty.call(object, 'callee') &&
        !Object.prototype.propertyIsEnumerable.call(object, 'callee') ||
        false;
    }});
    var is_arguments_1 = is_arguments.supported;
    var is_arguments_2 = is_arguments.unsupported;

    var is_arguments$1 = /*#__PURE__*/Object.freeze({
        default: is_arguments,
        __moduleExports: is_arguments,
        supported: is_arguments_1,
        unsupported: is_arguments_2
    });

    var objectKeys = ( keys$1 && keys ) || keys$1;

    var isArguments = ( is_arguments$1 && is_arguments ) || is_arguments$1;

    var deepEqual_1 = createCommonjsModule(function (module) {
    var pSlice = Array.prototype.slice;



    var deepEqual = module.exports = function (actual, expected, opts) {
      if (!opts) opts = {};
      // 7.1. All identical values are equivalent, as determined by ===.
      if (actual === expected) {
        return true;

      } else if (actual instanceof Date && expected instanceof Date) {
        return actual.getTime() === expected.getTime();

      // 7.3. Other pairs that do not both pass typeof value == 'object',
      // equivalence is determined by ==.
      } else if (!actual || !expected || typeof actual != 'object' && typeof expected != 'object') {
        return opts.strict ? actual === expected : actual == expected;

      // 7.4. For all other Object pairs, including Array objects, equivalence is
      // determined by having the same number of owned properties (as verified
      // with Object.prototype.hasOwnProperty.call), the same set of keys
      // (although not necessarily the same order), equivalent values for every
      // corresponding key, and an identical 'prototype' property. Note: this
      // accounts for both named and indexed properties on Arrays.
      } else {
        return objEquiv(actual, expected, opts);
      }
    };

    function isUndefinedOrNull(value) {
      return value === null || value === undefined;
    }

    function isBuffer (x) {
      if (!x || typeof x !== 'object' || typeof x.length !== 'number') return false;
      if (typeof x.copy !== 'function' || typeof x.slice !== 'function') {
        return false;
      }
      if (x.length > 0 && typeof x[0] !== 'number') return false;
      return true;
    }

    function objEquiv(a, b, opts) {
      var i, key;
      if (isUndefinedOrNull(a) || isUndefinedOrNull(b))
        return false;
      // an identical 'prototype' property.
      if (a.prototype !== b.prototype) return false;
      //~~~I've managed to break Object.keys through screwy arguments passing.
      //   Converting to array solves the problem.
      if (isArguments(a)) {
        if (!isArguments(b)) {
          return false;
        }
        a = pSlice.call(a);
        b = pSlice.call(b);
        return deepEqual(a, b, opts);
      }
      if (isBuffer(a)) {
        if (!isBuffer(b)) {
          return false;
        }
        if (a.length !== b.length) return false;
        for (i = 0; i < a.length; i++) {
          if (a[i] !== b[i]) return false;
        }
        return true;
      }
      try {
        var ka = objectKeys(a),
            kb = objectKeys(b);
      } catch (e) {//happens when one is a string literal and the other isn't
        return false;
      }
      // having the same number of owned properties (keys incorporates
      // hasOwnProperty)
      if (ka.length != kb.length)
        return false;
      //the same set of keys (although not necessarily the same order),
      ka.sort();
      kb.sort();
      //~~~cheap key test
      for (i = ka.length - 1; i >= 0; i--) {
        if (ka[i] != kb[i])
          return false;
      }
      //equivalent values for every corresponding key, and
      //~~~possibly expensive deep test
      for (i = ka.length - 1; i >= 0; i--) {
        key = ka[i];
        if (!deepEqual(a[key], b[key], opts)) return false;
      }
      return typeof a === typeof b;
    }
    });

    const equal = deepEqual_1;

    /**
     * Takes any LineString or Polygon and returns the overlapping lines between both features.
     *
     * @name lineOverlap
     * @param {Geometry|Feature<LineString|MultiLineString|Polygon|MultiPolygon>} line1 any LineString or Polygon
     * @param {Geometry|Feature<LineString|MultiLineString|Polygon|MultiPolygon>} line2 any LineString or Polygon
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.tolerance=0] Tolerance distance to match overlapping line segments (in kilometers)
     * @returns {FeatureCollection<LineString>} lines(s) that are overlapping between both features
     * @example
     * var line1 = turf.lineString([[115, -35], [125, -30], [135, -30], [145, -35]]);
     * var line2 = turf.lineString([[115, -25], [125, -30], [135, -30], [145, -25]]);
     *
     * var overlapping = turf.lineOverlap(line1, line2);
     *
     * //addToMap
     * var addToMap = [line1, line2, overlapping]
     */
    function lineOverlap(line1, line2, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var tolerance = options.tolerance || 0;

        // Containers
        var features = [];

        // Create Spatial Index
        var tree = geojsonRbush_1();

        const line = lineSegment(line1);
        tree.load(line);
        var overlapSegment;

        // Line Intersection

        // Iterate over line segments
        segmentEach(line2, function (segment) {
            var doesOverlaps = false;

            // Iterate over each segments which falls within the same bounds
            featureEach(tree.search(segment), function (match) {
                if (doesOverlaps === false) {
                    var coordsSegment = getCoords(segment).sort();
                    var coordsMatch = getCoords(match).sort();

                    // Segment overlaps feature
                    if (equal(coordsSegment, coordsMatch)) {
                        doesOverlaps = true;
                        // Overlaps already exists - only append last coordinate of segment
                        if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                        else overlapSegment = segment;
                    // Match segments which don't share nodes (Issue #901)
                    } else if (
                        (tolerance === 0) ?
                            booleanPointOnLine(coordsSegment[0], match) && booleanPointOnLine(coordsSegment[1], match) :
                            nearestPointOnLine(match, coordsSegment[0]).properties.dist <= tolerance &&
                            nearestPointOnLine(match, coordsSegment[1]).properties.dist <= tolerance) {
                        doesOverlaps = true;
                        if (overlapSegment) overlapSegment = concatSegment(overlapSegment, segment);
                        else overlapSegment = segment;
                    } else if (
                        (tolerance === 0) ?
                            booleanPointOnLine(coordsMatch[0], segment) && booleanPointOnLine(coordsMatch[1], segment) :
                            nearestPointOnLine(segment, coordsMatch[0]).properties.dist <= tolerance &&
                            nearestPointOnLine(segment, coordsMatch[1]).properties.dist <= tolerance) {
                        // Do not define (doesOverlap = true) since more matches can occur within the same segment
                        // doesOverlaps = true;
                        if (overlapSegment) overlapSegment = concatSegment(overlapSegment, match);
                        else overlapSegment = match;
                    }
                }
            });

            // Segment doesn't overlap - add overlaps to results & reset
            if (doesOverlaps === false && overlapSegment) {
                features.push(overlapSegment);
                overlapSegment = undefined;
            }
        });
        // Add last segment if exists
        if (overlapSegment) features.push(overlapSegment);

        return featureCollection(features);
    }


    /**
     * Concat Segment
     *
     * @private
     * @param {Feature<LineString>} line LineString
     * @param {Feature<LineString>} segment 2-vertex LineString
     * @returns {Feature<LineString>} concat linestring
     */
    function concatSegment(line, segment) {
        var coords = getCoords(segment);
        var lineCoords = getCoords(line);
        var start = lineCoords[0];
        var end = lineCoords[lineCoords.length - 1];
        var geom = line.geometry.coordinates;

        if (equal(coords[0], start)) geom.unshift(coords[1]);
        else if (equal(coords[0], end)) geom.push(coords[1]);
        else if (equal(coords[1], start)) geom.unshift(coords[0]);
        else if (equal(coords[1], end)) geom.push(coords[0]);
        return line;
    }

    /**
     * Creates a circular sector of a circle of given radius and center {@link Point},
     * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
     *
     * @name sector
     * @param {Coord} center center point
     * @param {number} radius radius of the circle
     * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
     * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
     * @param {number} [options.steps=64] number of steps
     * @returns {Feature<Polygon>} sector polygon
     * @example
     * var center = turf.point([-75, 40]);
     * var radius = 5;
     * var bearing1 = 25;
     * var bearing2 = 45;
     *
     * var sector = turf.sector(center, radius, bearing1, bearing2);
     *
     * //addToMap
     * var addToMap = [center, sector];
     */
    function sector(center, radius, bearing1, bearing2, options) {
        // Optional parameters
        options = checkIfOptionsExist(options);

        // validation
        if (!center) throw new Error('center is required');
        if (bearing1 === undefined || bearing1 === null) throw new Error('bearing1 is required');
        if (bearing2 === undefined || bearing2 === null) throw new Error('bearing2 is required');
        if (!radius) throw new Error('radius is required');
        if (typeof options !== 'object') throw new Error('options must be an object');

        if (convertAngleTo360$1(bearing1) === convertAngleTo360$1(bearing2)) {
            return circle(center, radius, options);
        }
        var coords = getCoords(center);
        var arc = lineArc(center, radius, bearing1, bearing2, options);
        var sliceCoords = [[coords]];
        coordEach(arc, function (currentCoords) {
            sliceCoords[0].push(currentCoords);
        });
        sliceCoords[0].push(coords);

        return polygon(sliceCoords, options.properties);
    }

    /**
     * Takes any angle in degrees
     * and returns a valid angle between 0-360 degrees
     *
     * @private
     * @param {number} alfa angle between -180-180 degrees
     * @returns {number} angle between 0-360 degrees
     */
    function convertAngleTo360$1(alfa) {
        var beta = alfa % 360;
        if (beta < 0) beta += 360;
        return beta;
    }

    /**
     * Finds the tangents of a {@link Polygon|(Multi)Polygon} from a {@link Point}.
     *
     * @name polygonTangents
     * @param {Coord} pt to calculate the tangent points from
     * @param {Feature<Polygon|MultiPolygon>} polygon to get tangents from
     * @returns {FeatureCollection<Point>} Feature Collection containing the two tangent points
     * @example
     * var polygon = turf.polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]]);
     * var point = turf.point([61, 5]);
     *
     * var tangents = turf.polygonTangents(point, polygon)
     *
     * //addToMap
     * var addToMap = [tangents, point, polygon];
     */
    function polygonTangents(pt, polygon$$1) {
        var pointCoords = getCoords(pt);
        var polyCoords = getCoords(polygon$$1);

        var rtan;
        var ltan;
        var enext;
        var eprev;

        var type = getType(polygon$$1);
        switch (type) {
        case 'Polygon':
            rtan = polyCoords[0][0];
            ltan = polyCoords[0][0];
            eprev = isLeft(polyCoords[0][0], polyCoords[0][polyCoords[0].length - 1], pointCoords);
            var out = processPolygon$1(polyCoords[0], pointCoords, eprev, enext, rtan, ltan);
            rtan = out[0];
            ltan = out[1];
            break;
        case 'MultiPolygon':
            rtan = polyCoords[0][0][0];
            ltan = polyCoords[0][0][0];
            eprev = isLeft(polyCoords[0][0][0], polyCoords[0][0][polyCoords[0][0].length - 1], pointCoords);
            polyCoords.forEach(function (ring) {
                var out = processPolygon$1(ring[0], pointCoords, eprev, enext, rtan, ltan);
                rtan = out[0];
                ltan = out[1];
            });
            break;
        }
        return featureCollection([point(rtan), point(ltan)]);
    }

    function processPolygon$1(polygonCoords, ptCoords, eprev, enext, rtan, ltan) {
        for (var i = 0; i < polygonCoords.length; i++) {
            var currentCoords = polygonCoords[i];
            var nextCoordPair = polygonCoords[i + 1];
            if (i === polygonCoords.length - 1) {
                nextCoordPair = polygonCoords[0];
            }
            enext = isLeft(currentCoords, nextCoordPair, ptCoords);
            if (eprev <= 0 && enext > 0) {
                if (!isBelow(ptCoords, currentCoords, rtan)) {
                    rtan = currentCoords;
                }
            } else if (eprev > 0 && enext <= 0) {
                if (!isAbove(ptCoords, currentCoords, ltan)) {
                    ltan = currentCoords;
                }
            }
            eprev = enext;
        }
        return [rtan, ltan];
    }

    function isAbove(point1, point2, point3) {
        return isLeft(point1, point2, point3) > 0;
    }

    function isBelow(point1, point2, point3) {
        return isLeft(point1, point2, point3) < 0;
    }

    function isLeft(point1, point2, point3) {
        return (point2[0] - point1[0]) * (point3[1] - point1[1]) - (point3[0] - point1[0]) * (point2[1] - point1[1]);
    }

    /**
     * Takes a ring and return true or false whether or not the ring is clockwise or counter-clockwise.
     *
     * @name booleanClockwise
     * @param {Feature<LineString>|LineString|Array<Array<number>>} line to be evaluated
     * @returns {boolean} true/false
     * @example
     * var clockwiseRing = turf.lineString([[0,0],[1,1],[1,0],[0,0]]);
     * var counterClockwiseRing = turf.lineString([[0,0],[1,0],[1,1],[0,0]]);
     *
     * turf.booleanClockwise(clockwiseRing)
     * //=true
     * turf.booleanClockwise(counterClockwiseRing)
     * //=false
     */
    function booleanClockwise(line) {
        const ring = getCoords(line);
        let sum = 0;
        let i = 1;
        let prev;
        let cur;

        while (i < ring.length) {
            prev = cur || ring[0];
            cur = ring[i];
            sum += ((cur[0] - prev[0]) * (cur[1] + prev[1]));
            i++;
        }
        return sum > 0;
    }

    /**
     * Rewind {@link LineString|(Multi)LineString} or {@link Polygon|(Multi)Polygon} outer ring counterclockwise and inner rings clockwise (Uses {@link http://en.wikipedia.org/wiki/Shoelace_formula|Shoelace Formula}).
     *
     * @name rewind
     * @param {GeoJSON} geojson input GeoJSON Polygon
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.reverse=false] enable reverse winding
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} rewind Polygon
     * @example
     * var polygon = turf.polygon([[[121, -29], [138, -29], [138, -18], [121, -18], [121, -29]]]);
     *
     * var rewind = turf.rewind(polygon);
     *
     * //addToMap
     * var addToMap = [rewind];
     */
    function rewind(geojson, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var reverse = options.reverse || false;
        var mutate = options.mutate || false;

        // validation
        if (!geojson) throw new Error('<geojson> is required');
        if (typeof reverse !== 'boolean') throw new Error('<reverse> must be a boolean');
        if (typeof mutate !== 'boolean') throw new Error('<mutate> must be a boolean');

        // prevent input mutation
        if (mutate === false) geojson = clone(geojson);

        // Support Feature Collection or Geometry Collection
        var results = [];
        switch (geojson.type) {
        case 'GeometryCollection':
            geomEach(geojson, function (geometry$$1) {
                rewindFeature(geometry$$1, reverse);
            });
            return geojson;
        case 'FeatureCollection':
            featureEach(geojson, function (feature$$1) {
                featureEach(rewindFeature(feature$$1, reverse), function (result) {
                    results.push(result);
                });
            });
            return featureCollection(results);
        }
        // Support Feature or Geometry Objects
        return rewindFeature(geojson, reverse);
    }

    /**
     * Rewind
     *
     * @private
     * @param {Geometry|Feature<any>} geojson Geometry or Feature
     * @param {Boolean} [reverse=false] enable reverse winding
     * @returns {Geometry|Feature<any>} rewind Geometry or Feature
     */
    function rewindFeature(geojson, reverse) {
        var type = (geojson.type === 'Feature') ? geojson.geometry.type : geojson.type;

        // Support all GeoJSON Geometry Objects
        switch (type) {
        case 'GeometryCollection':
            geomEach(geojson, function (geometry$$1) {
                rewindFeature(geometry$$1, reverse);
            });
            return geojson;
        case 'LineString':
            rewindLineString(getCoords(geojson), reverse);
            return geojson;
        case 'Polygon':
            rewindPolygon(getCoords(geojson), reverse);
            return geojson;
        case 'MultiLineString':
            getCoords(geojson).forEach(function (lineCoords) {
                rewindLineString(lineCoords, reverse);
            });
            return geojson;
        case 'MultiPolygon':
            getCoords(geojson).forEach(function (lineCoords) {
                rewindPolygon(lineCoords, reverse);
            });
            return geojson;
        case 'Point':
        case 'MultiPoint':
            return geojson;
        }
    }

    /**
     * Rewind LineString - outer ring clockwise
     *
     * @private
     * @param {Array<Array<number>>} coords GeoJSON LineString geometry coordinates
     * @param {Boolean} [reverse=false] enable reverse winding
     * @returns {void} mutates coordinates
     */
    function rewindLineString(coords, reverse) {
        if (booleanClockwise(coords) === reverse) coords.reverse();
    }

    /**
     * Rewind Polygon - outer ring counterclockwise and inner rings clockwise.
     *
     * @private
     * @param {Array<Array<Array<number>>>} coords GeoJSON Polygon geometry coordinates
     * @param {Boolean} [reverse=false] enable reverse winding
     * @returns {void} mutates coordinates
     */
    function rewindPolygon(coords, reverse) {
        // outer ring
        if (booleanClockwise(coords[0]) !== reverse) {
            coords[0].reverse();
        }
        // inner rings
        for (var i = 1; i < coords.length; i++) {
            if (booleanClockwise(coords[i]) === reverse) {
                coords[i].reverse();
            }
        }
    }

    /**
     * Takes a {@link Point} grid and returns a correspondent matrix {Array<Array<number>>}
     * of the 'property' values
     *
     * @name gridToMatrix
     * @param {FeatureCollection<Point>} grid of points
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
     * @param {boolean} [options.flip=false] returns the matrix upside-down
     * @param {boolean} [options.flags=false] flags, adding a `matrixPosition` array field ([row, column]) to its properties,
     * the grid points with coordinates on the matrix
     * @returns {Array<Array<number>>} matrix of property values
     * @example
     *   var extent = [-70.823364, -33.553984, -70.473175, -33.302986];
     *   var cellSize = 3;
     *   var grid = turf.pointGrid(extent, cellSize);
     *   // add a random property to each point between 0 and 60
     *   for (var i = 0; i < grid.features.length; i++) {
     *     grid.features[i].properties.elevation = (Math.random() * 60);
     *   }
     *   gridToMatrix(grid);
     *   //= [
     *     [ 1, 13, 10,  9, 10, 13, 18],
     *     [34,  8,  5,  4,  5,  8, 13],
     *     [10,  5,  2,  1,  2,  5,  4],
     *     [ 0,  4, 56, 19,  1,  4,  9],
     *     [10,  5,  2,  1,  2,  5, 10],
     *     [57,  8,  5,  4,  5,  0, 57],
     *     [ 3, 13, 10,  9,  5, 13, 18],
     *     [18, 13, 10,  9, 78, 13, 18]
     *   ]
     */
    function gridToMatrix$1(grid, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var zProperty = options.zProperty || 'elevation';
        var flip = options.flip;
        var flags = options.flags;

        // validation
        collectionOf(grid, 'Point', 'input must contain Points');

        var pointsMatrix = sortPointsByLatLng$1(grid, flip);

        var matrix = [];
        // create property matrix from sorted points
        // looping order matters here
        for (var r = 0; r < pointsMatrix.length; r++) {
            var pointRow = pointsMatrix[r];
            var row = [];
            for (var c = 0; c < pointRow.length; c++) {
                var point$$1 = pointRow[c];
                // Check if zProperty exist
                if (point$$1.properties[zProperty]) row.push(point$$1.properties[zProperty]);
                else row.push(0);
                // add flags
                if (flags === true) point$$1.properties.matrixPosition = [r, c];
            }
            matrix.push(row);
        }

        return matrix;
    }

    /**
     * Sorts points by latitude and longitude, creating a 2-dimensional array of points
     *
     * @private
     * @param {FeatureCollection<Point>} points GeoJSON Point features
     * @param {boolean} [flip=false] returns the matrix upside-down
     * @returns {Array<Array<Point>>} points ordered by latitude and longitude
     */
    function sortPointsByLatLng$1(points$$1, flip) {
        var pointsByLatitude = {};

        // divide points by rows with the same latitude
        featureEach(points$$1, function (point$$1) {
            var lat = getCoords(point$$1)[1];
            if (!pointsByLatitude[lat]) pointsByLatitude[lat] = [];
            pointsByLatitude[lat].push(point$$1);
        });

        // sort points (with the same latitude) by longitude
        var orderedRowsByLatitude = Object.keys(pointsByLatitude).map(function (lat) {
            var row = pointsByLatitude[lat];
            var rowOrderedByLongitude = row.sort(function (a, b) {
                return getCoords(a)[0] - getCoords(b)[0];
            });
            return rowOrderedByLongitude;
        });

        // sort rows (of points with the same latitude) by latitude
        var pointMatrix = orderedRowsByLatitude.sort(function (a, b) {
            if (flip) return getCoords(a[0])[1] - getCoords(b[0])[1];
            else return getCoords(b[0])[1] - getCoords(a[0])[1];
        });

        return pointMatrix;
    }

    /*!
    * @license GNU Affero General Public License.
    * Copyright (c) 2015, 2015 Ronny Lorenz <ronny@tbi.univie.ac.at>
    * v. 1.2.0
    * https://github.com/RaumZeit/MarchingSquares.js
    */

    var defaultSettings$1 = {
        successCallback: null,
        verbose: false,
        polygons: false
    };

    var settings$1 = {};

    /*
      Compute isobands(s) of a scalar 2D field given a certain
      threshold and a bandwidth by applying the Marching Squares
      Algorithm. The function returns a list of path coordinates
      either for individual polygons within each grid cell, or the
      outline of connected polygons.
    */
    function isoBands(data, minV, bandwidth, options) {
        /* process options */
        options = options ? options : {};

        var optionKeys = Object.keys(defaultSettings$1);

        for (var i = 0; i < optionKeys.length; i++) {
            var key = optionKeys[i];
            var val = options[key];
            val = ((typeof val !== 'undefined') && (val !== null)) ? val : defaultSettings$1[key];

            settings$1[key] = val;
        }

        if (settings$1.verbose)
            console.log('MarchingSquaresJS-isoBands: computing isobands for [' + minV + ':' + (minV + bandwidth) + ']');

        var grid = computeBandGrid(data, minV, bandwidth);

        var ret;
        if (settings$1.polygons) {
            if (settings$1.verbose)
                console.log('MarchingSquaresJS-isoBands: returning single polygons for each grid cell');
            ret = BandGrid2Areas(grid);
        } else {
            if (settings$1.verbose)
                console.log('MarchingSquaresJS-isoBands: returning polygon paths for entire data grid');
            ret = BandGrid2AreaPaths(grid);
        }

        if (typeof settings$1.successCallback === 'function')
            settings$1.successCallback(ret);

        return ret;
    }

    /*
      Thats all for the public interface, below follows the actual
      implementation
    */

    /* Some private variables */
    var Node0 = 64,
        Node1 = 16,
        Node2 = 4,
        Node3 = 1;

    /*
      The look-up tables for tracing back the contour path
      of isoBands
    */

    var isoBandNextXTL = [];
    var isoBandNextYTL = [];
    var isoBandNextOTL = [];

    var isoBandNextXTR = [];
    var isoBandNextYTR = [];
    var isoBandNextOTR = [];

    var isoBandNextXRT = [];
    var isoBandNextYRT = [];
    var isoBandNextORT = [];

    var isoBandNextXRB = [];
    var isoBandNextYRB = [];
    var isoBandNextORB = [];

    var isoBandNextXBL = [];
    var isoBandNextYBL = [];
    var isoBandNextOBL = [];

    var isoBandNextXBR = [];
    var isoBandNextYBR = [];
    var isoBandNextOBR = [];

    var isoBandNextXLT = [];
    var isoBandNextYLT = [];
    var isoBandNextOLT = [];

    var isoBandNextXLB = [];
    var isoBandNextYLB = [];
    var isoBandNextOLB = [];

    isoBandNextXRT[85] = isoBandNextXRB[85] = -1;
    isoBandNextYRT[85] = isoBandNextYRB[85] = 0;
    isoBandNextORT[85] = isoBandNextORB[85] = 1;
    isoBandNextXLT[85] = isoBandNextXLB[85] = 1;
    isoBandNextYLT[85] = isoBandNextYLB[85] = 0;
    isoBandNextOLT[85] = isoBandNextOLB[85] = 1;

    isoBandNextXTL[85] = isoBandNextXTR[85] = 0;
    isoBandNextYTL[85] = isoBandNextYTR[85] = -1;
    isoBandNextOTL[85] = isoBandNextOBL[85] = 0;
    isoBandNextXBR[85] = isoBandNextXBL[85] = 0;
    isoBandNextYBR[85] = isoBandNextYBL[85] = 1;
    isoBandNextOTR[85] = isoBandNextOBR[85] = 1;


    /* triangle cases */
    isoBandNextXLB[1] = isoBandNextXLB[169] = 0;
    isoBandNextYLB[1] = isoBandNextYLB[169] = -1;
    isoBandNextOLB[1] = isoBandNextOLB[169] = 0;
    isoBandNextXBL[1] = isoBandNextXBL[169] = -1;
    isoBandNextYBL[1] = isoBandNextYBL[169] = 0;
    isoBandNextOBL[1] = isoBandNextOBL[169] = 0;

    isoBandNextXRB[4] = isoBandNextXRB[166] = 0;
    isoBandNextYRB[4] = isoBandNextYRB[166] = -1;
    isoBandNextORB[4] = isoBandNextORB[166] = 1;
    isoBandNextXBR[4] = isoBandNextXBR[166] = 1;
    isoBandNextYBR[4] = isoBandNextYBR[166] = 0;
    isoBandNextOBR[4] = isoBandNextOBR[166] = 0;

    isoBandNextXRT[16] = isoBandNextXRT[154] = 0;
    isoBandNextYRT[16] = isoBandNextYRT[154] = 1;
    isoBandNextORT[16] = isoBandNextORT[154] = 1;
    isoBandNextXTR[16] = isoBandNextXTR[154] = 1;
    isoBandNextYTR[16] = isoBandNextYTR[154] = 0;
    isoBandNextOTR[16] = isoBandNextOTR[154] = 1;

    isoBandNextXLT[64] = isoBandNextXLT[106] = 0;
    isoBandNextYLT[64] = isoBandNextYLT[106] = 1;
    isoBandNextOLT[64] = isoBandNextOLT[106] = 0;
    isoBandNextXTL[64] = isoBandNextXTL[106] = -1;
    isoBandNextYTL[64] = isoBandNextYTL[106] = 0;
    isoBandNextOTL[64] = isoBandNextOTL[106] = 1;

    /* single trapezoid cases */
    isoBandNextXLT[2] = isoBandNextXLT[168] = 0;
    isoBandNextYLT[2] = isoBandNextYLT[168] = -1;
    isoBandNextOLT[2] = isoBandNextOLT[168] = 1;
    isoBandNextXLB[2] = isoBandNextXLB[168] = 0;
    isoBandNextYLB[2] = isoBandNextYLB[168] = -1;
    isoBandNextOLB[2] = isoBandNextOLB[168] = 0;
    isoBandNextXBL[2] = isoBandNextXBL[168] = -1;
    isoBandNextYBL[2] = isoBandNextYBL[168] = 0;
    isoBandNextOBL[2] = isoBandNextOBL[168] = 0;
    isoBandNextXBR[2] = isoBandNextXBR[168] = -1;
    isoBandNextYBR[2] = isoBandNextYBR[168] = 0;
    isoBandNextOBR[2] = isoBandNextOBR[168] = 1;

    isoBandNextXRT[8] = isoBandNextXRT[162] = 0;
    isoBandNextYRT[8] = isoBandNextYRT[162] = -1;
    isoBandNextORT[8] = isoBandNextORT[162] = 0;
    isoBandNextXRB[8] = isoBandNextXRB[162] = 0;
    isoBandNextYRB[8] = isoBandNextYRB[162] = -1;
    isoBandNextORB[8] = isoBandNextORB[162] = 1;
    isoBandNextXBL[8] = isoBandNextXBL[162] = 1;
    isoBandNextYBL[8] = isoBandNextYBL[162] = 0;
    isoBandNextOBL[8] = isoBandNextOBL[162] = 1;
    isoBandNextXBR[8] = isoBandNextXBR[162] = 1;
    isoBandNextYBR[8] = isoBandNextYBR[162] = 0;
    isoBandNextOBR[8] = isoBandNextOBR[162] = 0;

    isoBandNextXRT[32] = isoBandNextXRT[138] = 0;
    isoBandNextYRT[32] = isoBandNextYRT[138] = 1;
    isoBandNextORT[32] = isoBandNextORT[138] = 1;
    isoBandNextXRB[32] = isoBandNextXRB[138] = 0;
    isoBandNextYRB[32] = isoBandNextYRB[138] = 1;
    isoBandNextORB[32] = isoBandNextORB[138] = 0;
    isoBandNextXTL[32] = isoBandNextXTL[138] = 1;
    isoBandNextYTL[32] = isoBandNextYTL[138] = 0;
    isoBandNextOTL[32] = isoBandNextOTL[138] = 0;
    isoBandNextXTR[32] = isoBandNextXTR[138] = 1;
    isoBandNextYTR[32] = isoBandNextYTR[138] = 0;
    isoBandNextOTR[32] = isoBandNextOTR[138] = 1;

    isoBandNextXLB[128] = isoBandNextXLB[42] = 0;
    isoBandNextYLB[128] = isoBandNextYLB[42] = 1;
    isoBandNextOLB[128] = isoBandNextOLB[42] = 1;
    isoBandNextXLT[128] = isoBandNextXLT[42] = 0;
    isoBandNextYLT[128] = isoBandNextYLT[42] = 1;
    isoBandNextOLT[128] = isoBandNextOLT[42] = 0;
    isoBandNextXTL[128] = isoBandNextXTL[42] = -1;
    isoBandNextYTL[128] = isoBandNextYTL[42] = 0;
    isoBandNextOTL[128] = isoBandNextOTL[42] = 1;
    isoBandNextXTR[128] = isoBandNextXTR[42] = -1;
    isoBandNextYTR[128] = isoBandNextYTR[42] = 0;
    isoBandNextOTR[128] = isoBandNextOTR[42] = 0;

    /* single rectangle cases */
    isoBandNextXRB[5] = isoBandNextXRB[165] = -1;
    isoBandNextYRB[5] = isoBandNextYRB[165] = 0;
    isoBandNextORB[5] = isoBandNextORB[165] = 0;
    isoBandNextXLB[5] = isoBandNextXLB[165] = 1;
    isoBandNextYLB[5] = isoBandNextYLB[165] = 0;
    isoBandNextOLB[5] = isoBandNextOLB[165] = 0;

    isoBandNextXBR[20] = isoBandNextXBR[150] = 0;
    isoBandNextYBR[20] = isoBandNextYBR[150] = 1;
    isoBandNextOBR[20] = isoBandNextOBR[150] = 1;
    isoBandNextXTR[20] = isoBandNextXTR[150] = 0;
    isoBandNextYTR[20] = isoBandNextYTR[150] = -1;
    isoBandNextOTR[20] = isoBandNextOTR[150] = 1;

    isoBandNextXRT[80] = isoBandNextXRT[90] = -1;
    isoBandNextYRT[80] = isoBandNextYRT[90] = 0;
    isoBandNextORT[80] = isoBandNextORT[90] = 1;
    isoBandNextXLT[80] = isoBandNextXLT[90] = 1;
    isoBandNextYLT[80] = isoBandNextYLT[90] = 0;
    isoBandNextOLT[80] = isoBandNextOLT[90] = 1;

    isoBandNextXBL[65] = isoBandNextXBL[105] = 0;
    isoBandNextYBL[65] = isoBandNextYBL[105] = 1;
    isoBandNextOBL[65] = isoBandNextOBL[105] = 0;
    isoBandNextXTL[65] = isoBandNextXTL[105] = 0;
    isoBandNextYTL[65] = isoBandNextYTL[105] = -1;
    isoBandNextOTL[65] = isoBandNextOTL[105] = 0;

    isoBandNextXRT[160] = isoBandNextXRT[10] = -1;
    isoBandNextYRT[160] = isoBandNextYRT[10] = 0;
    isoBandNextORT[160] = isoBandNextORT[10] = 1;
    isoBandNextXRB[160] = isoBandNextXRB[10] = -1;
    isoBandNextYRB[160] = isoBandNextYRB[10] = 0;
    isoBandNextORB[160] = isoBandNextORB[10] = 0;
    isoBandNextXLB[160] = isoBandNextXLB[10] = 1;
    isoBandNextYLB[160] = isoBandNextYLB[10] = 0;
    isoBandNextOLB[160] = isoBandNextOLB[10] = 0;
    isoBandNextXLT[160] = isoBandNextXLT[10] = 1;
    isoBandNextYLT[160] = isoBandNextYLT[10] = 0;
    isoBandNextOLT[160] = isoBandNextOLT[10] = 1;

    isoBandNextXBR[130] = isoBandNextXBR[40] = 0;
    isoBandNextYBR[130] = isoBandNextYBR[40] = 1;
    isoBandNextOBR[130] = isoBandNextOBR[40] = 1;
    isoBandNextXBL[130] = isoBandNextXBL[40] = 0;
    isoBandNextYBL[130] = isoBandNextYBL[40] = 1;
    isoBandNextOBL[130] = isoBandNextOBL[40] = 0;
    isoBandNextXTL[130] = isoBandNextXTL[40] = 0;
    isoBandNextYTL[130] = isoBandNextYTL[40] = -1;
    isoBandNextOTL[130] = isoBandNextOTL[40] = 0;
    isoBandNextXTR[130] = isoBandNextXTR[40] = 0;
    isoBandNextYTR[130] = isoBandNextYTR[40] = -1;
    isoBandNextOTR[130] = isoBandNextOTR[40] = 1;

    /* single hexagon cases */
    isoBandNextXRB[37] = isoBandNextXRB[133] = 0;
    isoBandNextYRB[37] = isoBandNextYRB[133] = 1;
    isoBandNextORB[37] = isoBandNextORB[133] = 1;
    isoBandNextXLB[37] = isoBandNextXLB[133] = 0;
    isoBandNextYLB[37] = isoBandNextYLB[133] = 1;
    isoBandNextOLB[37] = isoBandNextOLB[133] = 0;
    isoBandNextXTL[37] = isoBandNextXTL[133] = -1;
    isoBandNextYTL[37] = isoBandNextYTL[133] = 0;
    isoBandNextOTL[37] = isoBandNextOTL[133] = 0;
    isoBandNextXTR[37] = isoBandNextXTR[133] = 1;
    isoBandNextYTR[37] = isoBandNextYTR[133] = 0;
    isoBandNextOTR[37] = isoBandNextOTR[133] = 0;

    isoBandNextXBR[148] = isoBandNextXBR[22] = -1;
    isoBandNextYBR[148] = isoBandNextYBR[22] = 0;
    isoBandNextOBR[148] = isoBandNextOBR[22] = 0;
    isoBandNextXLB[148] = isoBandNextXLB[22] = 0;
    isoBandNextYLB[148] = isoBandNextYLB[22] = -1;
    isoBandNextOLB[148] = isoBandNextOLB[22] = 1;
    isoBandNextXLT[148] = isoBandNextXLT[22] = 0;
    isoBandNextYLT[148] = isoBandNextYLT[22] = 1;
    isoBandNextOLT[148] = isoBandNextOLT[22] = 1;
    isoBandNextXTR[148] = isoBandNextXTR[22] = -1;
    isoBandNextYTR[148] = isoBandNextYTR[22] = 0;
    isoBandNextOTR[148] = isoBandNextOTR[22] = 1;

    isoBandNextXRT[82] = isoBandNextXRT[88] = 0;
    isoBandNextYRT[82] = isoBandNextYRT[88] = -1;
    isoBandNextORT[82] = isoBandNextORT[88] = 1;
    isoBandNextXBR[82] = isoBandNextXBR[88] = 1;
    isoBandNextYBR[82] = isoBandNextYBR[88] = 0;
    isoBandNextOBR[82] = isoBandNextOBR[88] = 1;
    isoBandNextXBL[82] = isoBandNextXBL[88] = -1;
    isoBandNextYBL[82] = isoBandNextYBL[88] = 0;
    isoBandNextOBL[82] = isoBandNextOBL[88] = 1;
    isoBandNextXLT[82] = isoBandNextXLT[88] = 0;
    isoBandNextYLT[82] = isoBandNextYLT[88] = -1;
    isoBandNextOLT[82] = isoBandNextOLT[88] = 0;

    isoBandNextXRT[73] = isoBandNextXRT[97] = 0;
    isoBandNextYRT[73] = isoBandNextYRT[97] = 1;
    isoBandNextORT[73] = isoBandNextORT[97] = 0;
    isoBandNextXRB[73] = isoBandNextXRB[97] = 0;
    isoBandNextYRB[73] = isoBandNextYRB[97] = -1;
    isoBandNextORB[73] = isoBandNextORB[97] = 0;
    isoBandNextXBL[73] = isoBandNextXBL[97] = 1;
    isoBandNextYBL[73] = isoBandNextYBL[97] = 0;
    isoBandNextOBL[73] = isoBandNextOBL[97] = 0;
    isoBandNextXTL[73] = isoBandNextXTL[97] = 1;
    isoBandNextYTL[73] = isoBandNextYTL[97] = 0;
    isoBandNextOTL[73] = isoBandNextOTL[97] = 1;

    isoBandNextXRT[145] = isoBandNextXRT[25] = 0;
    isoBandNextYRT[145] = isoBandNextYRT[25] = -1;
    isoBandNextORT[145] = isoBandNextORT[25] = 0;
    isoBandNextXBL[145] = isoBandNextXBL[25] = 1;
    isoBandNextYBL[145] = isoBandNextYBL[25] = 0;
    isoBandNextOBL[145] = isoBandNextOBL[25] = 1;
    isoBandNextXLB[145] = isoBandNextXLB[25] = 0;
    isoBandNextYLB[145] = isoBandNextYLB[25] = 1;
    isoBandNextOLB[145] = isoBandNextOLB[25] = 1;
    isoBandNextXTR[145] = isoBandNextXTR[25] = -1;
    isoBandNextYTR[145] = isoBandNextYTR[25] = 0;
    isoBandNextOTR[145] = isoBandNextOTR[25] = 0;

    isoBandNextXRB[70] = isoBandNextXRB[100] = 0;
    isoBandNextYRB[70] = isoBandNextYRB[100] = 1;
    isoBandNextORB[70] = isoBandNextORB[100] = 0;
    isoBandNextXBR[70] = isoBandNextXBR[100] = -1;
    isoBandNextYBR[70] = isoBandNextYBR[100] = 0;
    isoBandNextOBR[70] = isoBandNextOBR[100] = 1;
    isoBandNextXLT[70] = isoBandNextXLT[100] = 0;
    isoBandNextYLT[70] = isoBandNextYLT[100] = -1;
    isoBandNextOLT[70] = isoBandNextOLT[100] = 1;
    isoBandNextXTL[70] = isoBandNextXTL[100] = 1;
    isoBandNextYTL[70] = isoBandNextYTL[100] = 0;
    isoBandNextOTL[70] = isoBandNextOTL[100] = 0;

    /* single pentagon cases */
    isoBandNextXRB[101] = isoBandNextXRB[69] = 0;
    isoBandNextYRB[101] = isoBandNextYRB[69] = 1;
    isoBandNextORB[101] = isoBandNextORB[69] = 0;
    isoBandNextXTL[101] = isoBandNextXTL[69] = 1;
    isoBandNextYTL[101] = isoBandNextYTL[69] = 0;
    isoBandNextOTL[101] = isoBandNextOTL[69] = 0;

    isoBandNextXLB[149] = isoBandNextXLB[21] = 0;
    isoBandNextYLB[149] = isoBandNextYLB[21] = 1;
    isoBandNextOLB[149] = isoBandNextOLB[21] = 1;
    isoBandNextXTR[149] = isoBandNextXTR[21] = -1;
    isoBandNextYTR[149] = isoBandNextYTR[21] = 0;
    isoBandNextOTR[149] = isoBandNextOTR[21] = 0;

    isoBandNextXBR[86] = isoBandNextXBR[84] = -1;
    isoBandNextYBR[86] = isoBandNextYBR[84] = 0;
    isoBandNextOBR[86] = isoBandNextOBR[84] = 1;
    isoBandNextXLT[86] = isoBandNextXLT[84] = 0;
    isoBandNextYLT[86] = isoBandNextYLT[84] = -1;
    isoBandNextOLT[86] = isoBandNextOLT[84] = 1;

    isoBandNextXRT[89] = isoBandNextXRT[81] = 0;
    isoBandNextYRT[89] = isoBandNextYRT[81] = -1;
    isoBandNextORT[89] = isoBandNextORT[81] = 0;
    isoBandNextXBL[89] = isoBandNextXBL[81] = 1;
    isoBandNextYBL[89] = isoBandNextYBL[81] = 0;
    isoBandNextOBL[89] = isoBandNextOBL[81] = 1;

    isoBandNextXRT[96] = isoBandNextXRT[74] = 0;
    isoBandNextYRT[96] = isoBandNextYRT[74] = 1;
    isoBandNextORT[96] = isoBandNextORT[74] = 0;
    isoBandNextXRB[96] = isoBandNextXRB[74] = -1;
    isoBandNextYRB[96] = isoBandNextYRB[74] = 0;
    isoBandNextORB[96] = isoBandNextORB[74] = 1;
    isoBandNextXLT[96] = isoBandNextXLT[74] = 1;
    isoBandNextYLT[96] = isoBandNextYLT[74] = 0;
    isoBandNextOLT[96] = isoBandNextOLT[74] = 0;
    isoBandNextXTL[96] = isoBandNextXTL[74] = 1;
    isoBandNextYTL[96] = isoBandNextYTL[74] = 0;
    isoBandNextOTL[96] = isoBandNextOTL[74] = 1;

    isoBandNextXRT[24] = isoBandNextXRT[146] = 0;
    isoBandNextYRT[24] = isoBandNextYRT[146] = -1;
    isoBandNextORT[24] = isoBandNextORT[146] = 1;
    isoBandNextXBR[24] = isoBandNextXBR[146] = 1;
    isoBandNextYBR[24] = isoBandNextYBR[146] = 0;
    isoBandNextOBR[24] = isoBandNextOBR[146] = 1;
    isoBandNextXBL[24] = isoBandNextXBL[146] = 0;
    isoBandNextYBL[24] = isoBandNextYBL[146] = 1;
    isoBandNextOBL[24] = isoBandNextOBL[146] = 1;
    isoBandNextXTR[24] = isoBandNextXTR[146] = 0;
    isoBandNextYTR[24] = isoBandNextYTR[146] = -1;
    isoBandNextOTR[24] = isoBandNextOTR[146] = 0;

    isoBandNextXRB[6] = isoBandNextXRB[164] = -1;
    isoBandNextYRB[6] = isoBandNextYRB[164] = 0;
    isoBandNextORB[6] = isoBandNextORB[164] = 1;
    isoBandNextXBR[6] = isoBandNextXBR[164] = -1;
    isoBandNextYBR[6] = isoBandNextYBR[164] = 0;
    isoBandNextOBR[6] = isoBandNextOBR[164] = 0;
    isoBandNextXLB[6] = isoBandNextXLB[164] = 0;
    isoBandNextYLB[6] = isoBandNextYLB[164] = -1;
    isoBandNextOLB[6] = isoBandNextOLB[164] = 1;
    isoBandNextXLT[6] = isoBandNextXLT[164] = 1;
    isoBandNextYLT[6] = isoBandNextYLT[164] = 0;
    isoBandNextOLT[6] = isoBandNextOLT[164] = 0;

    isoBandNextXBL[129] = isoBandNextXBL[41] = 0;
    isoBandNextYBL[129] = isoBandNextYBL[41] = 1;
    isoBandNextOBL[129] = isoBandNextOBL[41] = 1;
    isoBandNextXLB[129] = isoBandNextXLB[41] = 0;
    isoBandNextYLB[129] = isoBandNextYLB[41] = 1;
    isoBandNextOLB[129] = isoBandNextOLB[41] = 0;
    isoBandNextXTL[129] = isoBandNextXTL[41] = -1;
    isoBandNextYTL[129] = isoBandNextYTL[41] = 0;
    isoBandNextOTL[129] = isoBandNextOTL[41] = 0;
    isoBandNextXTR[129] = isoBandNextXTR[41] = 0;
    isoBandNextYTR[129] = isoBandNextYTR[41] = -1;
    isoBandNextOTR[129] = isoBandNextOTR[41] = 0;

    isoBandNextXBR[66] = isoBandNextXBR[104] = 0;
    isoBandNextYBR[66] = isoBandNextYBR[104] = 1;
    isoBandNextOBR[66] = isoBandNextOBR[104] = 0;
    isoBandNextXBL[66] = isoBandNextXBL[104] = -1;
    isoBandNextYBL[66] = isoBandNextYBL[104] = 0;
    isoBandNextOBL[66] = isoBandNextOBL[104] = 1;
    isoBandNextXLT[66] = isoBandNextXLT[104] = 0;
    isoBandNextYLT[66] = isoBandNextYLT[104] = -1;
    isoBandNextOLT[66] = isoBandNextOLT[104] = 0;
    isoBandNextXTL[66] = isoBandNextXTL[104] = 0;
    isoBandNextYTL[66] = isoBandNextYTL[104] = -1;
    isoBandNextOTL[66] = isoBandNextOTL[104] = 1;

    isoBandNextXRT[144] = isoBandNextXRT[26] = -1;
    isoBandNextYRT[144] = isoBandNextYRT[26] = 0;
    isoBandNextORT[144] = isoBandNextORT[26] = 0;
    isoBandNextXLB[144] = isoBandNextXLB[26] = 1;
    isoBandNextYLB[144] = isoBandNextYLB[26] = 0;
    isoBandNextOLB[144] = isoBandNextOLB[26] = 1;
    isoBandNextXLT[144] = isoBandNextXLT[26] = 0;
    isoBandNextYLT[144] = isoBandNextYLT[26] = 1;
    isoBandNextOLT[144] = isoBandNextOLT[26] = 1;
    isoBandNextXTR[144] = isoBandNextXTR[26] = -1;
    isoBandNextYTR[144] = isoBandNextYTR[26] = 0;
    isoBandNextOTR[144] = isoBandNextOTR[26] = 1;

    isoBandNextXRB[36] = isoBandNextXRB[134] = 0;
    isoBandNextYRB[36] = isoBandNextYRB[134] = 1;
    isoBandNextORB[36] = isoBandNextORB[134] = 1;
    isoBandNextXBR[36] = isoBandNextXBR[134] = 0;
    isoBandNextYBR[36] = isoBandNextYBR[134] = 1;
    isoBandNextOBR[36] = isoBandNextOBR[134] = 0;
    isoBandNextXTL[36] = isoBandNextXTL[134] = 0;
    isoBandNextYTL[36] = isoBandNextYTL[134] = -1;
    isoBandNextOTL[36] = isoBandNextOTL[134] = 1;
    isoBandNextXTR[36] = isoBandNextXTR[134] = 1;
    isoBandNextYTR[36] = isoBandNextYTR[134] = 0;
    isoBandNextOTR[36] = isoBandNextOTR[134] = 0;

    isoBandNextXRT[9] = isoBandNextXRT[161] = -1;
    isoBandNextYRT[9] = isoBandNextYRT[161] = 0;
    isoBandNextORT[9] = isoBandNextORT[161] = 0;
    isoBandNextXRB[9] = isoBandNextXRB[161] = 0;
    isoBandNextYRB[9] = isoBandNextYRB[161] = -1;
    isoBandNextORB[9] = isoBandNextORB[161] = 0;
    isoBandNextXBL[9] = isoBandNextXBL[161] = 1;
    isoBandNextYBL[9] = isoBandNextYBL[161] = 0;
    isoBandNextOBL[9] = isoBandNextOBL[161] = 0;
    isoBandNextXLB[9] = isoBandNextXLB[161] = 1;
    isoBandNextYLB[9] = isoBandNextYLB[161] = 0;
    isoBandNextOLB[9] = isoBandNextOLB[161] = 1;

    /* 8-sided cases */
    isoBandNextXRT[136] = 0;
    isoBandNextYRT[136] = 1;
    isoBandNextORT[136] = 1;
    isoBandNextXRB[136] = 0;
    isoBandNextYRB[136] = 1;
    isoBandNextORB[136] = 0;
    isoBandNextXBR[136] = -1;
    isoBandNextYBR[136] = 0;
    isoBandNextOBR[136] = 1;
    isoBandNextXBL[136] = -1;
    isoBandNextYBL[136] = 0;
    isoBandNextOBL[136] = 0;
    isoBandNextXLB[136] = 0;
    isoBandNextYLB[136] = -1;
    isoBandNextOLB[136] = 0;
    isoBandNextXLT[136] = 0;
    isoBandNextYLT[136] = -1;
    isoBandNextOLT[136] = 1;
    isoBandNextXTL[136] = 1;
    isoBandNextYTL[136] = 0;
    isoBandNextOTL[136] = 0;
    isoBandNextXTR[136] = 1;
    isoBandNextYTR[136] = 0;
    isoBandNextOTR[136] = 1;

    isoBandNextXRT[34] = 0;
    isoBandNextYRT[34] = -1;
    isoBandNextORT[34] = 0;
    isoBandNextXRB[34] = 0;
    isoBandNextYRB[34] = -1;
    isoBandNextORB[34] = 1;
    isoBandNextXBR[34] = 1;
    isoBandNextYBR[34] = 0;
    isoBandNextOBR[34] = 0;
    isoBandNextXBL[34] = 1;
    isoBandNextYBL[34] = 0;
    isoBandNextOBL[34] = 1;
    isoBandNextXLB[34] = 0;
    isoBandNextYLB[34] = 1;
    isoBandNextOLB[34] = 1;
    isoBandNextXLT[34] = 0;
    isoBandNextYLT[34] = 1;
    isoBandNextOLT[34] = 0;
    isoBandNextXTL[34] = -1;
    isoBandNextYTL[34] = 0;
    isoBandNextOTL[34] = 1;
    isoBandNextXTR[34] = -1;
    isoBandNextYTR[34] = 0;
    isoBandNextOTR[34] = 0;

    isoBandNextXRT[35] = 0;
    isoBandNextYRT[35] = 1;
    isoBandNextORT[35] = 1;
    isoBandNextXRB[35] = 0;
    isoBandNextYRB[35] = -1;
    isoBandNextORB[35] = 1;
    isoBandNextXBR[35] = 1;
    isoBandNextYBR[35] = 0;
    isoBandNextOBR[35] = 0;
    isoBandNextXBL[35] = -1;
    isoBandNextYBL[35] = 0;
    isoBandNextOBL[35] = 0;
    isoBandNextXLB[35] = 0;
    isoBandNextYLB[35] = -1;
    isoBandNextOLB[35] = 0;
    isoBandNextXLT[35] = 0;
    isoBandNextYLT[35] = 1;
    isoBandNextOLT[35] = 0;
    isoBandNextXTL[35] = -1;
    isoBandNextYTL[35] = 0;
    isoBandNextOTL[35] = 1;
    isoBandNextXTR[35] = 1;
    isoBandNextYTR[35] = 0;
    isoBandNextOTR[35] = 1;

    /* 6-sided cases */
    isoBandNextXRT[153] = 0;
    isoBandNextYRT[153] = 1;
    isoBandNextORT[153] = 1;
    isoBandNextXBL[153] = -1;
    isoBandNextYBL[153] = 0;
    isoBandNextOBL[153] = 0;
    isoBandNextXLB[153] = 0;
    isoBandNextYLB[153] = -1;
    isoBandNextOLB[153] = 0;
    isoBandNextXTR[153] = 1;
    isoBandNextYTR[153] = 0;
    isoBandNextOTR[153] = 1;

    isoBandNextXRB[102] = 0;
    isoBandNextYRB[102] = -1;
    isoBandNextORB[102] = 1;
    isoBandNextXBR[102] = 1;
    isoBandNextYBR[102] = 0;
    isoBandNextOBR[102] = 0;
    isoBandNextXLT[102] = 0;
    isoBandNextYLT[102] = 1;
    isoBandNextOLT[102] = 0;
    isoBandNextXTL[102] = -1;
    isoBandNextYTL[102] = 0;
    isoBandNextOTL[102] = 1;

    isoBandNextXRT[155] = 0;
    isoBandNextYRT[155] = -1;
    isoBandNextORT[155] = 0;
    isoBandNextXBL[155] = 1;
    isoBandNextYBL[155] = 0;
    isoBandNextOBL[155] = 1;
    isoBandNextXLB[155] = 0;
    isoBandNextYLB[155] = 1;
    isoBandNextOLB[155] = 1;
    isoBandNextXTR[155] = -1;
    isoBandNextYTR[155] = 0;
    isoBandNextOTR[155] = 0;

    isoBandNextXRB[103] = 0;
    isoBandNextYRB[103] = 1;
    isoBandNextORB[103] = 0;
    isoBandNextXBR[103] = -1;
    isoBandNextYBR[103] = 0;
    isoBandNextOBR[103] = 1;
    isoBandNextXLT[103] = 0;
    isoBandNextYLT[103] = -1;
    isoBandNextOLT[103] = 1;
    isoBandNextXTL[103] = 1;
    isoBandNextYTL[103] = 0;
    isoBandNextOTL[103] = 0;

    /* 7-sided cases */
    isoBandNextXRT[152] = 0;
    isoBandNextYRT[152] = 1;
    isoBandNextORT[152] = 1;
    isoBandNextXBR[152] = -1;
    isoBandNextYBR[152] = 0;
    isoBandNextOBR[152] = 1;
    isoBandNextXBL[152] = -1;
    isoBandNextYBL[152] = 0;
    isoBandNextOBL[152] = 0;
    isoBandNextXLB[152] = 0;
    isoBandNextYLB[152] = -1;
    isoBandNextOLB[152] = 0;
    isoBandNextXLT[152] = 0;
    isoBandNextYLT[152] = -1;
    isoBandNextOLT[152] = 1;
    isoBandNextXTR[152] = 1;
    isoBandNextYTR[152] = 0;
    isoBandNextOTR[152] = 1;

    isoBandNextXRT[156] = 0;
    isoBandNextYRT[156] = -1;
    isoBandNextORT[156] = 1;
    isoBandNextXBR[156] = 1;
    isoBandNextYBR[156] = 0;
    isoBandNextOBR[156] = 1;
    isoBandNextXBL[156] = -1;
    isoBandNextYBL[156] = 0;
    isoBandNextOBL[156] = 0;
    isoBandNextXLB[156] = 0;
    isoBandNextYLB[156] = -1;
    isoBandNextOLB[156] = 0;
    isoBandNextXLT[156] = 0;
    isoBandNextYLT[156] = 1;
    isoBandNextOLT[156] = 1;
    isoBandNextXTR[156] = -1;
    isoBandNextYTR[156] = 0;
    isoBandNextOTR[156] = 1;

    isoBandNextXRT[137] = 0;
    isoBandNextYRT[137] = 1;
    isoBandNextORT[137] = 1;
    isoBandNextXRB[137] = 0;
    isoBandNextYRB[137] = 1;
    isoBandNextORB[137] = 0;
    isoBandNextXBL[137] = -1;
    isoBandNextYBL[137] = 0;
    isoBandNextOBL[137] = 0;
    isoBandNextXLB[137] = 0;
    isoBandNextYLB[137] = -1;
    isoBandNextOLB[137] = 0;
    isoBandNextXTL[137] = 1;
    isoBandNextYTL[137] = 0;
    isoBandNextOTL[137] = 0;
    isoBandNextXTR[137] = 1;
    isoBandNextYTR[137] = 0;
    isoBandNextOTR[137] = 1;

    isoBandNextXRT[139] = 0;
    isoBandNextYRT[139] = 1;
    isoBandNextORT[139] = 1;
    isoBandNextXRB[139] = 0;
    isoBandNextYRB[139] = -1;
    isoBandNextORB[139] = 0;
    isoBandNextXBL[139] = 1;
    isoBandNextYBL[139] = 0;
    isoBandNextOBL[139] = 0;
    isoBandNextXLB[139] = 0;
    isoBandNextYLB[139] = 1;
    isoBandNextOLB[139] = 0;
    isoBandNextXTL[139] = -1;
    isoBandNextYTL[139] = 0;
    isoBandNextOTL[139] = 0;
    isoBandNextXTR[139] = 1;
    isoBandNextYTR[139] = 0;
    isoBandNextOTR[139] = 1;

    isoBandNextXRT[98] = 0;
    isoBandNextYRT[98] = -1;
    isoBandNextORT[98] = 0;
    isoBandNextXRB[98] = 0;
    isoBandNextYRB[98] = -1;
    isoBandNextORB[98] = 1;
    isoBandNextXBR[98] = 1;
    isoBandNextYBR[98] = 0;
    isoBandNextOBR[98] = 0;
    isoBandNextXBL[98] = 1;
    isoBandNextYBL[98] = 0;
    isoBandNextOBL[98] = 1;
    isoBandNextXLT[98] = 0;
    isoBandNextYLT[98] = 1;
    isoBandNextOLT[98] = 0;
    isoBandNextXTL[98] = -1;
    isoBandNextYTL[98] = 0;
    isoBandNextOTL[98] = 1;

    isoBandNextXRT[99] = 0;
    isoBandNextYRT[99] = 1;
    isoBandNextORT[99] = 0;
    isoBandNextXRB[99] = 0;
    isoBandNextYRB[99] = -1;
    isoBandNextORB[99] = 1;
    isoBandNextXBR[99] = 1;
    isoBandNextYBR[99] = 0;
    isoBandNextOBR[99] = 0;
    isoBandNextXBL[99] = -1;
    isoBandNextYBL[99] = 0;
    isoBandNextOBL[99] = 1;
    isoBandNextXLT[99] = 0;
    isoBandNextYLT[99] = -1;
    isoBandNextOLT[99] = 0;
    isoBandNextXTL[99] = 1;
    isoBandNextYTL[99] = 0;
    isoBandNextOTL[99] = 1;

    isoBandNextXRB[38] = 0;
    isoBandNextYRB[38] = -1;
    isoBandNextORB[38] = 1;
    isoBandNextXBR[38] = 1;
    isoBandNextYBR[38] = 0;
    isoBandNextOBR[38] = 0;
    isoBandNextXLB[38] = 0;
    isoBandNextYLB[38] = 1;
    isoBandNextOLB[38] = 1;
    isoBandNextXLT[38] = 0;
    isoBandNextYLT[38] = 1;
    isoBandNextOLT[38] = 0;
    isoBandNextXTL[38] = -1;
    isoBandNextYTL[38] = 0;
    isoBandNextOTL[38] = 1;
    isoBandNextXTR[38] = -1;
    isoBandNextYTR[38] = 0;
    isoBandNextOTR[38] = 0;

    isoBandNextXRB[39] = 0;
    isoBandNextYRB[39] = 1;
    isoBandNextORB[39] = 1;
    isoBandNextXBR[39] = -1;
    isoBandNextYBR[39] = 0;
    isoBandNextOBR[39] = 0;
    isoBandNextXLB[39] = 0;
    isoBandNextYLB[39] = -1;
    isoBandNextOLB[39] = 1;
    isoBandNextXLT[39] = 0;
    isoBandNextYLT[39] = 1;
    isoBandNextOLT[39] = 0;
    isoBandNextXTL[39] = -1;
    isoBandNextYTL[39] = 0;
    isoBandNextOTL[39] = 1;
    isoBandNextXTR[39] = 1;
    isoBandNextYTR[39] = 0;
    isoBandNextOTR[39] = 0;


    /*
      Define helper functions for the polygon_table
      */

    /* triangle cases */
    var p00 = function (cell) {
        return [[cell.bottomleft, 0], [0, 0], [0, cell.leftbottom]];
    };
    var p01 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0]];
    };
    var p02 = function (cell) {
        return [[cell.topright, 1], [1, 1], [1, cell.righttop]];
    };
    var p03 = function (cell) {
        return [[0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* trapezoid cases */
    var p04 = function (cell) {
        return [[cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.leftbottom], [0, cell.lefttop]];
    };
    var p05 = function (cell) {
        return [[cell.bottomright, 0], [cell.bottomleft, 0], [1, cell.righttop], [1, cell.rightbottom]];
    };
    var p06 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.topleft, 1], [cell.topright, 1]];
    };
    var p07 = function (cell) {
        return [[0, cell.leftbottom], [0, cell.lefttop], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* rectangle cases */
    var p08 = function (cell) {
        return [[0, 0], [0, cell.leftbottom], [1, cell.rightbottom], [1, 0]];
    };
    var p09 = function (cell) {
        return [[1, 0], [cell.bottomright, 0], [cell.topright, 1], [1, 1]];
    };
    var p10 = function (cell) {
        return [[1, 1], [1, cell.righttop], [0, cell.lefttop], [0, 1]];
    };
    var p11 = function (cell) {
        return [[cell.bottomleft, 0], [0, 0], [0, 1], [cell.topleft, 1]];
    };
    var p12 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [0, cell.leftbottom], [0, cell.lefttop]];
    };
    var p13 = function (cell) {
        return [[cell.topleft, 1], [cell.topright, 1], [cell.bottomright, 0], [cell.bottomleft, 0]];
    };
    /* square case */
    var p14 = function () {
        return [[0, 0], [0, 1], [1, 1], [1, 0]];
    };
    /* pentagon cases */
    var p15 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [0, 0], [0, 1], [cell.topleft, 1]];
    };
    /* 1211 || 1011 */
    var p16 = function (cell) {
        return [[cell.topright, 1], [1, 1], [1, 0], [0, 0], [0, cell.leftbottom]];
    };
    /* 2111 || 0111 */
    var p17 = function (cell) {
        return [[1, 0], [cell.bottomright, 0], [0, cell.lefttop], [0, 1], [1, 1]];
    };
    /* 1112 || 1110 */
    var p18 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomleft, 0], [0, 0], [0, 1]];
    };
    /* 1121 || 1101 */
    var p19 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* 1200 || 1022 */
    var p20 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomright, 0], [cell.bottomleft, 0], [cell.topright, 1]];
    };
    /* 0120 || 2102 */
    var p21 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0], [0, cell.leftbottom], [0, cell.lefttop]];
    };
    /* 0012 || 2210 */
    var p22 = function (cell) {
        return [[cell.topright, 1], [cell.bottomleft, 0], [0, 0], [0, cell.leftbottom], [cell.topleft, 1]];
    };
    /* 2001 || 0221 */
    var p23 = function (cell) {
        return [[cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* 1002 || 1220 */
    var p24 = function (cell) {
        return [[1, 1], [1, cell.righttop], [0, cell.leftbottom], [0, cell.lefttop], [cell.topright, 1]];
    };
    /* 2100 || 0122 */
    var p25 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* 0210 || 2012 */
    var p26 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.bottomleft, 0], [0, 0], [0, cell.leftbottom]];
    };
    /* 0021 || 2201 */
    /*hexagon cases */
    var p27 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [0, 0], [0, cell.leftbottom], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* 0211 || 2011 */
    var p28 = function (cell) {
        return [[1, 1], [1, 0], [cell.bottomright, 0], [0, cell.leftbottom], [0, cell.lefttop], [cell.topright, 1]];
    };
    /* 2110 || 0112 */
    var p29 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.lefttop], [0, 1]];
    };
    /* 1102 || 1120 */
    var p30 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.bottomleft, 0], [0, 0], [0, 1], [cell.topleft, 1]];
    };
    /* 1021 || 1201 */
    var p31 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomleft, 0], [0, 0], [0, cell.leftbottom], [cell.topright, 1]];
    };
    /* 2101 || 0121 */
    var p32 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0], [0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* 1012 || 1210 */
    /* 8-sided cases */
    var p33 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.leftbottom], [0, cell.lefttop], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* flipped == 1 state for 0202 and 2020 */
    /* 6-sided cases */
    var p34 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomleft, 0], [0, 0], [0, cell.leftbottom], [cell.topright, 1]];
    };
    /* 0101 with flipped == 1 || 2121 with flipped == 1 */
    var p35 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0], [0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* 1010 with flipped == 1 || 1212 with flipped == 1 */
    /* 7-sided cases */
    var p36 = function (cell) {
        return [[1, 1], [1, cell.righttop], [cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.leftbottom], [0, cell.lefttop], [cell.topright, 1]];
    };
    /* 2120 with flipped == 1 || 0102 with flipped == 1 */
    var p37 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.bottomleft, 0], [0, 0], [0, cell.leftbottom], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* 2021 with flipped == 1 || 0201 with flipped == 1 */
    var p38 = function (cell) {
        return [[1, cell.righttop], [1, cell.rightbottom], [cell.bottomright, 0], [cell.bottomleft, 0], [0, cell.lefttop], [0, 1], [cell.topleft, 1]];
    };
    /* 1202 with flipped == 1 || 1020 with flipped == 1 */
    var p39 = function (cell) {
        return [[1, cell.rightbottom], [1, 0], [cell.bottomright, 0], [0, cell.leftbottom], [0, cell.lefttop], [cell.topleft, 1], [cell.topright, 1]];
    };
    /* 0212 with flipped == 1 || 2010 with flipped == 1 */



    /*
      The lookup tables for edge number given the polygon
      is entered at a specific location
    */

    var isoBandEdgeRT = [];
    var isoBandEdgeRB = [];
    var isoBandEdgeBR = [];
    var isoBandEdgeBL = [];
    var isoBandEdgeLB = [];
    var isoBandEdgeLT = [];
    var isoBandEdgeTL = [];
    var isoBandEdgeTR = [];

    /* triangle cases */
    isoBandEdgeBL[1]    = isoBandEdgeLB[1]    = 18;
    isoBandEdgeBL[169]  = isoBandEdgeLB[169]  = 18;
    isoBandEdgeBR[4]    = isoBandEdgeRB[4]    = 12;
    isoBandEdgeBR[166]  = isoBandEdgeRB[166]  = 12;
    isoBandEdgeRT[16]   = isoBandEdgeTR[16]   = 4;
    isoBandEdgeRT[154]  = isoBandEdgeTR[154]  = 4;
    isoBandEdgeLT[64]   = isoBandEdgeTL[64]   = 22;
    isoBandEdgeLT[106]  = isoBandEdgeTL[106]  = 22;

    /* trapezoid cases */
    isoBandEdgeBR[2]    = isoBandEdgeLT[2]    = 17;
    isoBandEdgeBL[2]    = isoBandEdgeLB[2]    = 18;
    isoBandEdgeBR[168]  = isoBandEdgeLT[168]  = 17;
    isoBandEdgeBL[168]  = isoBandEdgeLB[168]  = 18;
    isoBandEdgeRT[8]    = isoBandEdgeBL[8]    = 9;
    isoBandEdgeRB[8]    = isoBandEdgeBR[8]    = 12;
    isoBandEdgeRT[162]  = isoBandEdgeBL[162]  = 9;
    isoBandEdgeRB[162]  = isoBandEdgeBR[162]  = 12;
    isoBandEdgeRT[32]   = isoBandEdgeTR[32]   = 4;
    isoBandEdgeRB[32]   = isoBandEdgeTL[32]   = 1;
    isoBandEdgeRT[138]  = isoBandEdgeTR[138]  = 4;
    isoBandEdgeRB[138]  = isoBandEdgeTL[138]  = 1;
    isoBandEdgeLB[128]  = isoBandEdgeTR[128]  = 21;
    isoBandEdgeLT[128]  = isoBandEdgeTL[128]  = 22;
    isoBandEdgeLB[42]   = isoBandEdgeTR[42]   = 21;
    isoBandEdgeLT[42]   = isoBandEdgeTL[42]   = 22;

    /* rectangle cases */
    isoBandEdgeRB[5] = isoBandEdgeLB[5] = 14;
    isoBandEdgeRB[165] = isoBandEdgeLB[165] = 14;
    isoBandEdgeBR[20] = isoBandEdgeTR[20] = 6;
    isoBandEdgeBR[150] = isoBandEdgeTR[150] = 6;
    isoBandEdgeRT[80] = isoBandEdgeLT[80] = 11;
    isoBandEdgeRT[90] = isoBandEdgeLT[90] = 11;
    isoBandEdgeBL[65] = isoBandEdgeTL[65] = 3;
    isoBandEdgeBL[105] = isoBandEdgeTL[105] = 3;
    isoBandEdgeRT[160] = isoBandEdgeLT[160] = 11;
    isoBandEdgeRB[160] = isoBandEdgeLB[160] = 14;
    isoBandEdgeRT[10] = isoBandEdgeLT[10] = 11;
    isoBandEdgeRB[10] = isoBandEdgeLB[10] = 14;
    isoBandEdgeBR[130] = isoBandEdgeTR[130] = 6;
    isoBandEdgeBL[130] = isoBandEdgeTL[130] = 3;
    isoBandEdgeBR[40] = isoBandEdgeTR[40] = 6;
    isoBandEdgeBL[40] = isoBandEdgeTL[40] = 3;

    /* pentagon cases */
    isoBandEdgeRB[101] = isoBandEdgeTL[101] = 1;
    isoBandEdgeRB[69] = isoBandEdgeTL[69] = 1;
    isoBandEdgeLB[149] = isoBandEdgeTR[149] = 21;
    isoBandEdgeLB[21] = isoBandEdgeTR[21] = 21;
    isoBandEdgeBR[86] = isoBandEdgeLT[86] = 17;
    isoBandEdgeBR[84] = isoBandEdgeLT[84] = 17;
    isoBandEdgeRT[89] = isoBandEdgeBL[89] = 9;
    isoBandEdgeRT[81] = isoBandEdgeBL[81] = 9;
    isoBandEdgeRT[96] = isoBandEdgeTL[96] = 0;
    isoBandEdgeRB[96] = isoBandEdgeLT[96] = 15;
    isoBandEdgeRT[74] = isoBandEdgeTL[74] = 0;
    isoBandEdgeRB[74] = isoBandEdgeLT[74] = 15;
    isoBandEdgeRT[24] = isoBandEdgeBR[24] = 8;
    isoBandEdgeBL[24] = isoBandEdgeTR[24] = 7;
    isoBandEdgeRT[146] = isoBandEdgeBR[146] = 8;
    isoBandEdgeBL[146] = isoBandEdgeTR[146] = 7;
    isoBandEdgeRB[6] = isoBandEdgeLT[6] = 15;
    isoBandEdgeBR[6] = isoBandEdgeLB[6] = 16;
    isoBandEdgeRB[164] = isoBandEdgeLT[164] = 15;
    isoBandEdgeBR[164] = isoBandEdgeLB[164] = 16;
    isoBandEdgeBL[129] = isoBandEdgeTR[129] = 7;
    isoBandEdgeLB[129] = isoBandEdgeTL[129] = 20;
    isoBandEdgeBL[41] = isoBandEdgeTR[41] = 7;
    isoBandEdgeLB[41] = isoBandEdgeTL[41] = 20;
    isoBandEdgeBR[66] = isoBandEdgeTL[66] = 2;
    isoBandEdgeBL[66] = isoBandEdgeLT[66] = 19;
    isoBandEdgeBR[104] = isoBandEdgeTL[104] = 2;
    isoBandEdgeBL[104] = isoBandEdgeLT[104] = 19;
    isoBandEdgeRT[144] = isoBandEdgeLB[144] = 10;
    isoBandEdgeLT[144] = isoBandEdgeTR[144] = 23;
    isoBandEdgeRT[26] = isoBandEdgeLB[26] = 10;
    isoBandEdgeLT[26] = isoBandEdgeTR[26] = 23;
    isoBandEdgeRB[36] = isoBandEdgeTR[36] = 5;
    isoBandEdgeBR[36] = isoBandEdgeTL[36] = 2;
    isoBandEdgeRB[134] = isoBandEdgeTR[134] = 5;
    isoBandEdgeBR[134] = isoBandEdgeTL[134] = 2;
    isoBandEdgeRT[9] = isoBandEdgeLB[9] = 10;
    isoBandEdgeRB[9] = isoBandEdgeBL[9] = 13;
    isoBandEdgeRT[161] = isoBandEdgeLB[161] = 10;
    isoBandEdgeRB[161] = isoBandEdgeBL[161] = 13;

    /* hexagon cases */
    isoBandEdgeRB[37] = isoBandEdgeTR[37] = 5;
    isoBandEdgeLB[37] = isoBandEdgeTL[37] = 20;
    isoBandEdgeRB[133] = isoBandEdgeTR[133] = 5;
    isoBandEdgeLB[133] = isoBandEdgeTL[133] = 20;
    isoBandEdgeBR[148] = isoBandEdgeLB[148] = 16;
    isoBandEdgeLT[148] = isoBandEdgeTR[148] = 23;
    isoBandEdgeBR[22] = isoBandEdgeLB[22] = 16;
    isoBandEdgeLT[22] = isoBandEdgeTR[22] = 23;
    isoBandEdgeRT[82] = isoBandEdgeBR[82] = 8;
    isoBandEdgeBL[82] = isoBandEdgeLT[82] = 19;
    isoBandEdgeRT[88] = isoBandEdgeBR[88] = 8;
    isoBandEdgeBL[88] = isoBandEdgeLT[88] = 19;
    isoBandEdgeRT[73] = isoBandEdgeTL[73] = 0;
    isoBandEdgeRB[73] = isoBandEdgeBL[73] = 13;
    isoBandEdgeRT[97] = isoBandEdgeTL[97] = 0;
    isoBandEdgeRB[97] = isoBandEdgeBL[97] = 13;
    isoBandEdgeRT[145] = isoBandEdgeBL[145] = 9;
    isoBandEdgeLB[145] = isoBandEdgeTR[145] = 21;
    isoBandEdgeRT[25] = isoBandEdgeBL[25] = 9;
    isoBandEdgeLB[25] = isoBandEdgeTR[25] = 21;
    isoBandEdgeRB[70] = isoBandEdgeTL[70] = 1;
    isoBandEdgeBR[70] = isoBandEdgeLT[70] = 17;
    isoBandEdgeRB[100] = isoBandEdgeTL[100] = 1;
    isoBandEdgeBR[100] = isoBandEdgeLT[100] = 17;

    /* 8-sided cases */
    isoBandEdgeRT[34] = isoBandEdgeBL[34] = 9;
    isoBandEdgeRB[34] = isoBandEdgeBR[34] = 12;
    isoBandEdgeLB[34] = isoBandEdgeTR[34] = 21;
    isoBandEdgeLT[34] = isoBandEdgeTL[34] = 22;
    isoBandEdgeRT[136] = isoBandEdgeTR[136] = 4;
    isoBandEdgeRB[136] = isoBandEdgeTL[136] = 1;
    isoBandEdgeBR[136] = isoBandEdgeLT[136] = 17;
    isoBandEdgeBL[136] = isoBandEdgeLB[136] = 18;
    isoBandEdgeRT[35] = isoBandEdgeTR[35] = 4;
    isoBandEdgeRB[35] = isoBandEdgeBR[35] = 12;
    isoBandEdgeBL[35] = isoBandEdgeLB[35] = 18;
    isoBandEdgeLT[35] = isoBandEdgeTL[35] = 22;

    /* 6-sided cases */
    isoBandEdgeRT[153] = isoBandEdgeTR[153] = 4;
    isoBandEdgeBL[153] = isoBandEdgeLB[153] = 18;
    isoBandEdgeRB[102] = isoBandEdgeBR[102] = 12;
    isoBandEdgeLT[102] = isoBandEdgeTL[102] = 22;
    isoBandEdgeRT[155] = isoBandEdgeBL[155] = 9;
    isoBandEdgeLB[155] = isoBandEdgeTR[155] = 23;
    isoBandEdgeRB[103] = isoBandEdgeTL[103] = 1;
    isoBandEdgeBR[103] = isoBandEdgeLT[103] = 17;

    /* 7-sided cases */
    isoBandEdgeRT[152] = isoBandEdgeTR[152] = 4;
    isoBandEdgeBR[152] = isoBandEdgeLT[152] = 17;
    isoBandEdgeBL[152] = isoBandEdgeLB[152] = 18;
    isoBandEdgeRT[156] = isoBandEdgeBR[156] = 8;
    isoBandEdgeBL[156] = isoBandEdgeLB[156] = 18;
    isoBandEdgeLT[156] = isoBandEdgeTR[156] = 23;
    isoBandEdgeRT[137] = isoBandEdgeTR[137] = 4;
    isoBandEdgeRB[137] = isoBandEdgeTL[137] = 1;
    isoBandEdgeBL[137] = isoBandEdgeLB[137] = 18;
    isoBandEdgeRT[139] = isoBandEdgeTR[139] = 4;
    isoBandEdgeRB[139] = isoBandEdgeBL[139] = 13;
    isoBandEdgeLB[139] = isoBandEdgeTL[139] = 20;
    isoBandEdgeRT[98] = isoBandEdgeBL[98] = 9;
    isoBandEdgeRB[98] = isoBandEdgeBR[98] = 12;
    isoBandEdgeLT[98] = isoBandEdgeTL[98] = 22;
    isoBandEdgeRT[99] = isoBandEdgeTL[99] = 0;
    isoBandEdgeRB[99] = isoBandEdgeBR[99] = 12;
    isoBandEdgeBL[99] = isoBandEdgeLT[99] = 19;
    isoBandEdgeRB[38] = isoBandEdgeBR[38] = 12;
    isoBandEdgeLB[38] = isoBandEdgeTR[38] = 21;
    isoBandEdgeLT[38] = isoBandEdgeTL[38] = 22;
    isoBandEdgeRB[39] = isoBandEdgeTR[39] = 5;
    isoBandEdgeBR[39] = isoBandEdgeLB[39] = 16;
    isoBandEdgeLT[39] = isoBandEdgeTL[39] = 22;

    /*
      The lookup tables for all different polygons that
      may appear within a grid cell
    */

    var polygon_table = [];

    /* triangle cases */
    polygon_table[1] = polygon_table[169] = p00; /* 2221 || 0001 */
    polygon_table[4] = polygon_table[166] = p01; /* 2212 || 0010 */
    polygon_table[16] = polygon_table[154] = p02; /* 2122 || 0100 */
    polygon_table[64] = polygon_table[106] = p03; /* 1222 || 1000 */

    /* trapezoid cases */
    polygon_table[168] = polygon_table[2] = p04; /* 2220 || 0002 */
    polygon_table[162] = polygon_table[8] = p05; /* 2202 || 0020 */
    polygon_table[138] = polygon_table[32] = p06; /* 2022 || 0200 */
    polygon_table[42] = polygon_table[128] = p07; /* 0222 || 2000 */

    /* rectangle cases */
    polygon_table[5] = polygon_table[165] = p08; /* 0011 || 2211 */
    polygon_table[20] = polygon_table[150] = p09; /* 0110 || 2112 */
    polygon_table[80] = polygon_table[90] = p10; /* 1100 || 1122 */
    polygon_table[65] = polygon_table[105] = p11; /* 1001 || 1221 */
    polygon_table[160] = polygon_table[10] = p12; /* 2200 || 0022 */
    polygon_table[130] = polygon_table[40] = p13; /* 2002 || 0220 */

    /* square case */
    polygon_table[85] = p14; /* 1111 */

    /* pentagon cases */
    polygon_table[101] = polygon_table[69] = p15; /* 1211 || 1011 */
    polygon_table[149] = polygon_table[21] = p16; /* 2111 || 0111 */
    polygon_table[86] = polygon_table[84] = p17; /* 1112 || 1110 */
    polygon_table[89] = polygon_table[81] = p18; /* 1121 || 1101 */
    polygon_table[96] = polygon_table[74] = p19; /* 1200 || 1022 */
    polygon_table[24] = polygon_table[146] = p20; /* 0120 || 2102 */
    polygon_table[6] = polygon_table[164] = p21; /* 0012 || 2210 */
    polygon_table[129] = polygon_table[41] = p22; /* 2001 || 0221 */
    polygon_table[66] = polygon_table[104] = p23; /* 1002 || 1220 */
    polygon_table[144] = polygon_table[26] = p24; /* 2100 || 0122 */
    polygon_table[36] = polygon_table[134] = p25; /* 0210 || 2012 */
    polygon_table[9] = polygon_table[161] = p26; /* 0021 || 2201 */

    /* hexagon cases */
    polygon_table[37] = polygon_table[133] = p27; /* 0211 || 2011 */
    polygon_table[148] = polygon_table[22] = p28; /* 2110 || 0112 */
    polygon_table[82] = polygon_table[88] = p29; /* 1102 || 1120 */
    polygon_table[73] = polygon_table[97] = p30; /* 1021 || 1201 */
    polygon_table[145] = polygon_table[25] = p31; /* 2101 || 0121 */
    polygon_table[70] = polygon_table[100] = p32; /* 1012 || 1210 */

    /* 8-sided cases */
    polygon_table[34] = function (c) { return [p07(c), p05(c)]; }; /* 0202 || 2020 with flipped == 0 */
    polygon_table[35] = p33; /* flipped == 1 state for 0202 and 2020 */
    polygon_table[136] = function (c) { return [p06(c), p04(c)]; }; /* 2020 || 0202 with flipped == 0 */

    /* 6-sided cases */
    polygon_table[153] = function (c) { return [p02(c), p00(c)]; }; /* 0101 with flipped == 0 || 2121 with flipped == 2 */
    polygon_table[102] = function (c) { return [p01(c), p03(c)]; }; /* 1010 with flipped == 0 || 1212 with flipped == 2 */
    polygon_table[155] = p34; /* 0101 with flipped == 1 || 2121 with flipped == 1 */
    polygon_table[103] = p35; /* 1010 with flipped == 1 || 1212 with flipped == 1 */

    /* 7-sided cases */
    polygon_table[152] = function (c) { return [p02(c), p04(c)]; }; /* 2120 with flipped == 2 || 0102 with flipped == 0 */
    polygon_table[156] = p36; /* 2120 with flipped == 1 || 0102 with flipped == 1 */
    polygon_table[137] = function (c) { return [p06(c), p00(c)]; }; /* 2021 with flipped == 2 || 0201 with flipped == 0 */
    polygon_table[139] = p37; /* 2021 with flipped == 1 || 0201 with flipped == 1 */
    polygon_table[98] = function (c) { return [p05(c), p03(c)]; }; /* 1202 with flipped == 2 || 1020 with flipped == 0 */
    polygon_table[99] = p38; /* 1202 with flipped == 1 || 1020 with flipped == 1 */
    polygon_table[38] = function (c) { return [p01(c), p07(c)]; }; /* 0212 with flipped == 2 || 2010 with flipped == 0 */
    polygon_table[39] = p39; /* 0212 with flipped == 1 || 2010 with flipped == 1 */


    /*
    ####################################
    Some small helper functions
    ####################################
    */

    /* assume that x1 == 1 &&  x0 == 0 */
    function interpolateX$1(y, y0, y1) {
        return (y - y0) / (y1 - y0);
    }

    function isArray(myArray) {
        return myArray.constructor.toString().indexOf('Array') > -1;
    }

    /*
    ####################################
    Below is the actual Marching Squares implementation
    ####################################
    */

    function computeBandGrid(data, minV, bandwidth) {
        var rows = data.length - 1;
        var cols = data[0].length - 1;
        var BandGrid = { rows: rows, cols: cols, cells: [] };

        var maxV = minV + Math.abs(bandwidth);

        for (var j = 0; j < rows; ++j) {
            BandGrid.cells[j] = [];
            for (var i = 0; i < cols; ++i) {
                /*  compose the 4-trit corner representation */
                var cval = 0;

                var tl = data[j + 1][i];
                var tr = data[j + 1][i + 1];
                var br = data[j][i + 1];
                var bl = data[j][i];

                if (isNaN(tl) || isNaN(tr) || isNaN(br) || isNaN(bl)) {
                    continue;
                }

                cval |= (tl < minV) ? 0 : (tl > maxV) ? 128 : 64;
                cval |= (tr < minV) ? 0 : (tr > maxV) ? 32 : 16;
                cval |= (br < minV) ? 0 : (br > maxV) ? 8 : 4;
                cval |= (bl < minV) ? 0 : (bl > maxV) ? 2 : 1;

                var cval_real = +cval;

                /* resolve ambiguity via averaging */
                var flipped = 0;
                if ((cval === 17)  || /* 0101 */
              (cval === 18)  || /* 0102 */
              (cval === 33)  || /* 0201 */
              (cval === 34)  || /* 0202 */
              (cval === 38)  || /* 0212 */
              (cval === 68)  || /* 1010 */
              (cval === 72)  || /* 1020 */
              (cval === 98)  || /* 1202 */
              (cval === 102)  || /* 1212 */
              (cval === 132)  || /* 2010 */
              (cval === 136)  || /* 2020 */
              (cval === 137)  || /* 2021 */
              (cval === 152)  || /* 2120 */
              (cval === 153) /* 2121 */
                ) {
                    var average = (tl + tr + br + bl) / 4;
                    /* set flipped state */
                    flipped = (average > maxV) ? 2 : (average < minV) ? 0 : 1;

                    /* adjust cval for flipped cases */

                    /* 8-sided cases */
                    if (cval === 34) {
                        if (flipped === 1) {
                            cval = 35;
                        } else if (flipped === 0) {
                            cval = 136;
                        }
                    } else if (cval === 136) {
                        if (flipped === 1) {
                            cval = 35;
                            flipped = 4;
                        } else if (flipped === 0) {
                            cval = 34;
                        }
                    }

                    /* 6-sided polygon cases */
                    else if (cval === 17) {
                        if (flipped === 1) {
                            cval = 155;
                            flipped = 4;
                        } else if (flipped === 0) {
                            cval = 153;
                        }
                    } else if (cval === 68) {
                        if (flipped === 1) {
                            cval = 103;
                            flipped = 4;
                        } else if (flipped === 0) {
                            cval = 102;
                        }
                    } else if (cval === 153) {
                        if (flipped === 1)
                            cval = 155;
                    } else if (cval === 102) {
                        if (flipped === 1)
                            cval = 103;
                    }

                    /* 7-sided polygon cases */
                    else if (cval === 152) {
                        if (flipped < 2) {
                            cval    = 156;
                            flipped = 1;
                        }
                    } else if (cval === 137) {
                        if (flipped < 2) {
                            cval = 139;
                            flipped = 1;
                        }
                    } else if (cval === 98) {
                        if (flipped < 2) {
                            cval    = 99;
                            flipped = 1;
                        }
                    } else if (cval === 38) {
                        if (flipped < 2) {
                            cval    = 39;
                            flipped = 1;
                        }
                    } else if (cval === 18) {
                        if (flipped > 0) {
                            cval = 156;
                            flipped = 4;
                        } else {
                            cval = 152;
                        }
                    } else if (cval === 33) {
                        if (flipped > 0) {
                            cval = 139;
                            flipped = 4;
                        } else {
                            cval = 137;
                        }
                    } else if (cval === 72) {
                        if (flipped > 0) {
                            cval = 99;
                            flipped = 4;
                        } else {
                            cval = 98;
                        }
                    } else if (cval === 132) {
                        if (flipped > 0) {
                            cval = 39;
                            flipped = 4;
                        } else {
                            cval = 38;
                        }
                    }
                }

                /* add cell to BandGrid if it contains at least one polygon-side */
                if ((cval != 0) && (cval != 170)) {
                    var topleft, topright, bottomleft, bottomright,
                        righttop, rightbottom, lefttop, leftbottom;

                    topleft = topright = bottomleft = bottomright = righttop =
                    rightbottom = lefttop = leftbottom = 0.5;

                    var edges = [];

                    /* do interpolation here */
                    /* 1st Triangles */
                    if (cval === 1) { /* 0001 */
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 169) { /* 2221 */
                        bottomleft = interpolateX$1(maxV, bl, br);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 4) { /* 0010 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        bottomright = interpolateX$1(minV, bl, br);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 166) { /* 2212 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 16) { /* 0100 */
                        righttop = interpolateX$1(minV, br, tr);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                    } else if (cval === 154) { /* 2122 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                    } else if (cval === 64) { /* 1000 */
                        lefttop = interpolateX$1(minV, bl, tl);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 106) { /* 1222 */
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeLT[cval]);
                    }
                    /* 2nd Trapezoids */
                    else if (cval === 168) { /* 2220 */
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 2) { /* 0002 */
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 162) { /* 2202 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 8) { /* 0020 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 138) { /* 2022 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 32) { /* 0200 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 42) { /* 0222 */
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeLB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 128) { /* 2000 */
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeLB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    }

                    /* 3rd rectangle cases */
                    if (cval === 5) { /* 0011 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 165) { /* 2211 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 20) { /* 0110 */
                        bottomright = interpolateX$1(minV, bl, br);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 150) { /* 2112 */
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 80) { /* 1100 */
                        righttop = interpolateX$1(minV, br, tr);
                        lefttop = interpolateX$1(minV, bl, tl);
                        edges.push(isoBandEdgeRT[cval]);
                    } else if (cval === 90) { /* 1122 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        edges.push(isoBandEdgeRT[cval]);
                    } else if (cval === 65) { /* 1001 */
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 105) { /* 1221 */
                        bottomleft = interpolateX$1(maxV, bl, br);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 160) { /* 2200 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 10) { /* 0022 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 130) { /* 2002 */
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 40) { /* 0220 */
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    }

                    /* 4th single pentagon cases */
                    else if (cval === 101) { /* 1211 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 69) { /* 1011 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 149) { /* 2111 */
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 21) { /* 0111 */
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 86) { /* 1112 */
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 84) { /* 1110 */
                        bottomright = interpolateX$1(minV, bl, br);
                        lefttop = interpolateX$1(minV, bl, tl);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 89) { /* 1121 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        bottomleft = interpolateX$1(maxV, bl, br);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 81) { /* 1101 */
                        righttop = interpolateX$1(minV, br, tr);
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 96) { /* 1200 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        lefttop = interpolateX$1(minV, bl, tl);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 74) { /* 1022 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 24) { /* 0120 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 146) { /* 2102 */
                        righttop = interpolateX$1(minV, br, tr);
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 6) { /* 0012 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 164) { /* 2210 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        bottomright = interpolateX$1(minV, bl, br);
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 129) { /* 2001 */
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeBL[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 41) { /* 0221 */
                        bottomleft = interpolateX$1(maxV, bl, br);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeBL[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 66) { /* 1002 */
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 104) { /* 1220 */
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        lefttop = interpolateX$1(minV, bl, tl);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeBL[cval]);
                        edges.push(isoBandEdgeTL[cval]);
                    } else if (cval === 144) { /* 2100 */
                        righttop = interpolateX$1(minV, br, tr);
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 26) { /* 0122 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 36) { /* 0210 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        bottomright = interpolateX$1(minV, bl, br);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 134) { /* 2012 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 9) { /* 0021 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        bottomleft = interpolateX$1(maxV, bl, br);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 161) { /* 2201 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    }

                    /* 5th single hexagon cases */
                    else if (cval === 37) { /* 0211 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        topleft = interpolateX$1(minV, tl, tr);
                        topright = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 133) { /* 2011 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        topleft = 1 - interpolateX$1(maxV, tr, tl);
                        topright = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 148) { /* 2110 */
                        bottomright = interpolateX$1(minV, bl, br);
                        leftbottom = interpolateX$1(minV, bl, tl);
                        lefttop = interpolateX$1(maxV, bl, tl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 22) { /* 0112 */
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                        lefttop = 1 - interpolateX$1(minV, tl, bl);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 82) { /* 1102 */
                        righttop = interpolateX$1(minV, br, tr);
                        bottomright = 1 - interpolateX$1(minV, br, bl);
                        bottomleft = 1 - interpolateX$1(maxV, br, bl);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 88) { /* 1120 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        bottomright = interpolateX$1(maxV, bl, br);
                        bottomleft = interpolateX$1(minV, bl, br);
                        lefttop = interpolateX$1(minV, bl, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 73) { /* 1021 */
                        righttop = 1 - interpolateX$1(minV, tr, br);
                        rightbottom = 1 - interpolateX$1(maxV, tr, br);
                        bottomleft = interpolateX$1(maxV, bl, br);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 97) { /* 1201 */
                        righttop = interpolateX$1(maxV, br, tr);
                        rightbottom = interpolateX$1(minV, br, tr);
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                    } else if (cval === 145) { /* 2101 */
                        righttop = interpolateX$1(minV, br, tr);
                        bottomleft = 1 - interpolateX$1(minV, br, bl);
                        leftbottom = interpolateX$1(maxV, bl, tl);
                        topright = 1 - interpolateX$1(maxV, tr, tl);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 25) { /* 0121 */
                        righttop = 1 - interpolateX$1(maxV, tr, br);
                        bottomleft = interpolateX$1(maxV, bl, br);
                        leftbottom = 1 - interpolateX$1(minV, tl, bl);
                        topright = interpolateX$1(minV, tl, tr);
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 70) { /* 1012 */
                        rightbottom = 1 - interpolateX$1(minV, tr, br);
                        bottomright = 1 - interpolateX$1(maxV, br, bl);
                        lefttop = 1 - interpolateX$1(maxV, tl, bl);
                        topleft = 1 - interpolateX$1(minV, tr, tl);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    } else if (cval === 100) { /* 1210 */
                        rightbottom = interpolateX$1(maxV, br, tr);
                        bottomright = interpolateX$1(minV, bl, br);
                        lefttop = interpolateX$1(minV, bl, tl);
                        topleft = interpolateX$1(maxV, tl, tr);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    }

                    /* 8-sided cases */
                    else if (cval === 34) { /* 0202 || 2020 with flipped == 0 */
                        if (flipped === 0) {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 35) { /* flipped == 1 state for 0202, and 2020 with flipped == 4*/
                        if (flipped === 4) {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 136) { /* 2020 || 0202 with flipped == 0 */
                        if (flipped === 0) {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    }

                    /* 6-sided polygon cases */
                    else if (cval === 153) { /* 0101 with flipped == 0 || 2121 with flipped == 2 */
                        if (flipped === 0) {
                            righttop = interpolateX$1(minV, br, tr);
                            bottomleft = 1 - interpolateX$1(minV, br, bl);
                            leftbottom = 1 - interpolateX$1(minV, tl, bl);
                            topright = interpolateX$1(minV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(maxV, tr, br);
                            bottomleft = interpolateX$1(maxV, bl, br);
                            leftbottom = interpolateX$1(maxV, bl, tl);
                            topright = 1 - interpolateX$1(maxV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 102) { /* 1010 with flipped == 0 || 1212 with flipped == 2 */
                        if (flipped === 0) {
                            rightbottom = 1 - interpolateX$1(minV, tr, br);
                            bottomright = interpolateX$1(minV, bl, br);
                            lefttop = interpolateX$1(minV, bl, tl);
                            topleft = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            rightbottom = interpolateX$1(maxV, br, tr);
                            bottomright = 1 - interpolateX$1(maxV, br, bl);
                            lefttop = 1 - interpolateX$1(maxV, tl, bl);
                            topleft = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 155) { /* 0101 with flipped == 4 || 2121 with flipped == 1 */
                        if (flipped === 4) {
                            righttop = interpolateX$1(minV, br, tr);
                            bottomleft = 1 - interpolateX$1(minV, br, bl);
                            leftbottom = 1 - interpolateX$1(minV, tl, bl);
                            topright = interpolateX$1(minV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(maxV, tr, br);
                            bottomleft = interpolateX$1(maxV, bl, br);
                            leftbottom = interpolateX$1(maxV, bl, tl);
                            topright = 1 - interpolateX$1(maxV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 103) { /* 1010 with flipped == 4 || 1212 with flipped == 1 */
                        if (flipped === 4) {
                            rightbottom = 1 - interpolateX$1(minV, tr, br);
                            bottomright = interpolateX$1(minV, bl, br);
                            lefttop = interpolateX$1(minV, bl, tl);
                            topleft = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            rightbottom = interpolateX$1(maxV, br, tr);
                            bottomright = 1 - interpolateX$1(maxV, br, bl);
                            lefttop = 1 - interpolateX$1(maxV, tl, bl);
                            topleft = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                    }

                    /* 7-sided polygon cases */
                    else if (cval === 152) { /* 2120 with flipped == 2 || 0102 with flipped == 0 */
                        if (flipped === 0) {
                            righttop = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topright = interpolateX$1(minV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topright = 1 - interpolateX$1(maxV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 156) { /* 2120 with flipped == 1 || 0102 with flipped == 4 */
                        if (flipped === 4) {
                            righttop = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topright = interpolateX$1(minV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topright = 1 - interpolateX$1(maxV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 137) { /* 2021 with flipped == 2 || 0201 with flipped == 0 */
                        if (flipped === 0) {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomleft = 1 - interpolateX$1(minV, br, bl);
                            leftbottom = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomleft = interpolateX$1(maxV, bl, br);
                            leftbottom = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 139) { /* 2021 with flipped == 1 || 0201 with flipped == 4 */
                        if (flipped === 4) {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomleft = 1 - interpolateX$1(minV, br, bl);
                            leftbottom = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        } else {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomleft = interpolateX$1(maxV, bl, br);
                            leftbottom = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                    } else if (cval === 98) { /* 1202 with flipped == 2 || 1020 with flipped == 0 */
                        if (flipped === 0) {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            lefttop = interpolateX$1(minV, bl, tl);
                            topleft = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            lefttop = 1 - interpolateX$1(maxV, tl, bl);
                            topleft = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 99) { /* 1202 with flipped == 1 || 1020 with flipped == 4 */
                        if (flipped === 4) {
                            righttop = 1 - interpolateX$1(minV, tr, br);
                            rightbottom = 1 - interpolateX$1(maxV, tr, br);
                            bottomright = interpolateX$1(maxV, bl, br);
                            bottomleft = interpolateX$1(minV, bl, br);
                            lefttop = interpolateX$1(minV, bl, tl);
                            topleft = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            righttop = interpolateX$1(maxV, br, tr);
                            rightbottom = interpolateX$1(minV, br, tr);
                            bottomright = 1 - interpolateX$1(minV, br, bl);
                            bottomleft = 1 - interpolateX$1(maxV, br, bl);
                            lefttop = 1 - interpolateX$1(maxV, tl, bl);
                            topleft = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRT[cval]);
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBL[cval]);
                    } else if (cval === 38) { /* 0212 with flipped == 2 || 2010 with flipped == 0 */
                        if (flipped === 0) {
                            rightbottom = 1 - interpolateX$1(minV, tr, br);
                            bottomright = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            rightbottom = interpolateX$1(maxV, br, tr);
                            bottomright = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeLB[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 39) { /* 0212 with flipped == 1 || 2010 with flipped == 4 */
                        if (flipped === 4) {
                            rightbottom = 1 - interpolateX$1(minV, tr, br);
                            bottomright = interpolateX$1(minV, bl, br);
                            leftbottom = interpolateX$1(minV, bl, tl);
                            lefttop = interpolateX$1(maxV, bl, tl);
                            topleft = 1 - interpolateX$1(maxV, tr, tl);
                            topright = 1 - interpolateX$1(minV, tr, tl);
                        } else {
                            rightbottom = interpolateX$1(maxV, br, tr);
                            bottomright = 1 - interpolateX$1(maxV, br, bl);
                            leftbottom = 1 - interpolateX$1(maxV, tl, bl);
                            lefttop = 1 - interpolateX$1(minV, tl, bl);
                            topleft = interpolateX$1(minV, tl, tr);
                            topright = interpolateX$1(maxV, tl, tr);
                        }
                        edges.push(isoBandEdgeRB[cval]);
                        edges.push(isoBandEdgeBR[cval]);
                        edges.push(isoBandEdgeLT[cval]);
                    } else if (cval === 85) {
                        righttop = 1;
                        rightbottom = 0;
                        bottomright = 1;
                        bottomleft = 0;
                        leftbottom = 0;
                        lefttop = 1;
                        topleft = 0;
                        topright = 1;
                    }

                    if (topleft < 0 || topleft > 1 || topright < 0 || topright > 1 || righttop < 0 || righttop > 1 || bottomright < 0 || bottomright > 1 || leftbottom < 0 || leftbottom > 1 || lefttop < 0 || lefttop > 1) {
                        console.log('MarchingSquaresJS-isoBands: ' + cval + ' ' + cval_real + ' ' + tl + ',' + tr + ',' + br + ',' + bl + ' ' + flipped + ' ' + topleft + ' ' + topright + ' ' + righttop + ' ' + rightbottom + ' ' + bottomright + ' ' + bottomleft + ' ' + leftbottom + ' ' + lefttop);
                    }

                    BandGrid.cells[j][i] = {
                        cval: cval,
                        cval_real: cval_real,
                        flipped: flipped,
                        topleft: topleft,
                        topright: topright,
                        righttop: righttop,
                        rightbottom: rightbottom,
                        bottomright: bottomright,
                        bottomleft: bottomleft,
                        leftbottom: leftbottom,
                        lefttop: lefttop,
                        edges: edges
                    };
                }
            }
        }

        return BandGrid;
    }

    function BandGrid2AreaPaths(grid) {
        var areas = [];
        var rows = grid.rows;
        var cols = grid.cols;
        var currentPolygon = [];

        for (var j = 0; j < rows; j++) {
            for (var i = 0; i < cols; i++) {
                if ((typeof grid.cells[j][i] !== 'undefined') && (grid.cells[j][i].edges.length > 0)) {
                    /* trace back polygon path starting from this cell */

                    var cell = grid.cells[j][i];

                    /* get start coordinates */

                    var prev  = getStartXY(cell),
                        next  = null,
                        p     = i,
                        q     = j;

                    if (prev !== null) {
                        currentPolygon.push([prev.p[0] + p, prev.p[1] + q]);
                        //console.log(cell);
                        //console.log("coords: " + (prev.p[0] + p) + " " + (prev.p[1] + q));
                    }

                    do {
                        //console.log(p + "," + q);
                        //console.log(grid.cells[q][p]);
                        //console.log(grid.cells[q][p].edges);
                        //console.log("from : " + prev.x + " " + prev.y + " " + prev.o);

                        next = getExitXY(grid.cells[q][p], prev.x, prev.y, prev.o);
                        if (next !== null) {
                            //console.log("coords: " + (next.p[0] + p) + " " + (next.p[1] + q));
                            currentPolygon.push([next.p[0] + p, next.p[1] + q]);
                            p += next.x;
                            q += next.y;
                            prev = next;
                        } else {
                            //console.log("getExitXY() returned null!");
                            break;
                        }
                        //console.log("to : " + next.x + " " + next.y + " " + next.o);
                        /* special case, where we've reached the grid boundaries */
                        if ((q < 0) || (q >= rows) || (p < 0) || (p >= cols) || (typeof grid.cells[q][p] === 'undefined')) {
                            /* to create a closed path, we need to trace our way
                    arround the missing data, until we find an entry
                    point again
                */

                            /* set back coordinates of current cell */
                            p -= next.x;
                            q -= next.y;

                            //console.log("reached boundary at " + p + " " + q);

                            var missing = traceOutOfGridPath(grid, p, q, next.x, next.y, next.o);
                            if (missing !== null) {
                                missing.path.forEach(function (pp) {
                                    //console.log("coords: " + (pp[0]) + " " + (pp[1]));
                                    currentPolygon.push(pp);
                                });
                                p = missing.i;
                                q = missing.j;
                                prev = missing;
                            } else {
                                break;
                            }
                            //console.log(grid.cells[q][p]);
                        }
                    } while ((typeof grid.cells[q][p] !== 'undefined') &&
                      (grid.cells[q][p].edges.length > 0));

                    areas.push(currentPolygon);
                    //console.log("next polygon");
                    //console.log(currentPolygon);
                    currentPolygon = [];
                    if (grid.cells[j][i].edges.length > 0)
                        i--;
                }
            }
        }
        return areas;
    }

    function traceOutOfGridPath(grid, i, j, d_x, d_y, d_o) {
        var cell = grid.cells[j][i];
        var cval = cell.cval_real;
        var p = i + d_x,
            q = j + d_y;
        var path = [];
        var closed = false;

        while (!closed) {
        //console.log("processing cell " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
            if ((typeof grid.cells[q] === 'undefined') || (typeof grid.cells[q][p] === 'undefined')) {
                //console.log("which is undefined");
                /* we can't move on, so we have to change direction to proceed further */

                /* go back to previous cell */
                q -= d_y;
                p -= d_x;
                cell = grid.cells[q][p];
                cval = cell.cval_real;

                /* check where we've left defined cells of the grid... */
                if (d_y === -1) { /* we came from top */
                    if (d_o === 0) {  /* exit left */
                        if (cval & Node3) { /* lower left node is within range, so we move left */
                            path.push([p, q]);
                            d_x = -1;
                            d_y = 0;
                            d_o = 0;
                        } else if (cval & Node2) { /* lower right node is within range, so we move right */
                            path.push([p + 1, q]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 0;
                        } else { /* close the path */
                            path.push([p + cell.bottomright, q]);
                            d_x = 0;
                            d_y = 1;
                            d_o = 1;
                            closed = true;
                            break;
                        }
                    } else if (cval & Node3) {
                        path.push([p, q]);
                        d_x = -1;
                        d_y = 0;
                        d_o = 0;
                    } else if (cval & Node2) {
                        path.push([p + cell.bottomright, q]);
                        d_x = 0;
                        d_y = 1;
                        d_o = 1;
                        closed = true;
                        break;
                    } else {
                        path.push([p + cell.bottomleft, q]);
                        d_x = 0;
                        d_y = 1;
                        d_o = 0;
                        closed = true;
                        break;
                    }
                } else if (d_y === 1) { /* we came from bottom */
                    //console.log("we came from bottom and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
                    if (d_o === 0) { /* exit left */
                        if (cval & Node1) { /* top right node is within range, so we move right */
                            path.push([p + 1, q + 1]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 1;
                        } else if (!(cval & Node0)) { /* found entry within same cell */
                            path.push([p + cell.topright, q + 1]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 1;
                            closed = true;
                            //console.log("found entry from bottom at " + p + "," + q);
                            break;
                        } else {
                            path.push([p + cell.topleft, q + 1]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 0;
                            closed = true;
                            break;
                        }
                    } else if (cval & Node1) {
                        path.push([p + 1, q + 1]);
                        d_x = 1;
                        d_y = 0;
                        d_o = 1;
                    } else { /* move right */
                        path.push([p + 1, q + 1]);
                        d_x = 1;
                        d_y = 0;
                        d_o = 1;
                        //console.log("wtf");
                        //break;
                    }
                } else if (d_x === -1) { /* we came from right */
                    //console.log("we came from right and hit a non-existing cell at " + (p + d_x) + "," + (q + d_y) + "!");
                    if (d_o === 0) {
                        //console.log("continue at bottom");
                        if (cval & Node0) {
                            path.push([p, q + 1]);
                            d_x = 0;
                            d_y = 1;
                            d_o = 0;
                            //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
                        } else if (!(cval & Node3)) { /* there has to be an entry into the regular grid again! */
                            //console.log("exiting top");
                            path.push([p, q + cell.lefttop]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 1;
                            closed = true;
                            break;
                        } else {
                            //console.log("exiting bottom");
                            path.push([p, q + cell.leftbottom]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 0;
                            closed = true;
                            break;
                        }
                    } else {
                        //console.log("continue at top");
                        if (cval & Node0) {
                            path.push([p, q + 1]);
                            d_x = 0;
                            d_y = 1;
                            d_o = 0;
                            //console.log("moving upwards to " + (p + d_x) + "," + (q + d_y) + "!");
                        } else { /* */
                            console.log('MarchingSquaresJS-isoBands: wtf');
                            break;
                        }
                    }
                } else if (d_x === 1) { /* we came from left */
                    //console.log("we came from left and hit a non-existing cell " + (p + d_x) + "," + (q + d_y) + "!");
                    if (d_o === 0) { /* exit bottom */
                        if (cval & Node2) {
                            path.push([p + 1, q]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 1;
                        } else {
                            path.push([p + 1, q + cell.rightbottom]);
                            d_x = -1;
                            d_y = 0;
                            d_o = 0;
                            closed = true;
                            break;
                        }
                    } else { /* exit top */
                        if (cval & Node2) {
                            path.push([p + 1, q]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 1;
                        } else if (!(cval & Node1)) {
                            path.push([p + 1, q + cell.rightbottom]);
                            d_x = -1;
                            d_y = 0;
                            d_o = 0;
                            closed = true;
                            break;
                        } else {
                            path.push([p + 1, q + cell.righttop]);
                            d_x = -1;
                            d_y = 0;
                            d_o = 1;
                            break;
                        }
                    }
                } else { /* we came from the same cell */
                    console.log('MarchingSquaresJS-isoBands: we came from nowhere!');
                    break;
                }

            } else { /* try to find an entry into the regular grid again! */
                cell = grid.cells[q][p];
                cval = cell.cval_real;
                //console.log("which is defined");

                if (d_x === -1) {
                    if (d_o === 0) {
                        /* try to go downwards */
                        if ((typeof grid.cells[q - 1] !== 'undefined') && (typeof grid.cells[q - 1][p] !== 'undefined')) {
                            d_x = 0;
                            d_y = -1;
                            d_o = 1;
                        } else if (cval & Node3) { /* proceed searching in x-direction */
                            //console.log("proceeding in x-direction!");
                            path.push([p, q]);
                        } else { /* we must have found an entry into the regular grid */
                            path.push([p + cell.bottomright, q]);
                            d_x = 0;
                            d_y = 1;
                            d_o = 1;
                            closed = true;
                            //console.log("found entry from bottom at " + p + "," + q);
                            break;
                        }
                    } else if (cval & Node0) { /* proceed searchin in x-direction */
                        console.log('MarchingSquaresJS-isoBands: proceeding in x-direction!');
                    } else { /* we must have found an entry into the regular grid */
                        console.log('MarchingSquaresJS-isoBands: found entry from top at ' + p + ',' + q);
                        break;
                    }
                } else if (d_x === 1) {
                    if (d_o === 0) {
                        console.log('MarchingSquaresJS-isoBands: wtf');
                        break;
                    } else {
                        /* try to go upwards */
                        if ((typeof grid.cells[q + 1] !== 'undefined') && (typeof grid.cells[q + 1][p] !== 'undefined')) {
                            d_x = 0;
                            d_y = 1;
                            d_o = 0;
                        } else if (cval & Node1) {
                            path.push([p + 1, q + 1]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 1;
                        } else { /* found an entry point into regular grid! */
                            path.push([p + cell.topleft, q + 1]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 0;
                            closed = true;
                            //console.log("found entry from bottom at " + p + "," + q);
                            break;
                        }
                    }
                } else if (d_y === -1) {
                    if (d_o === 1) {
                        /* try to go right */
                        if (typeof grid.cells[q][p + 1] !== 'undefined') {
                            d_x = 1;
                            d_y = 0;
                            d_o = 1;
                        } else if (cval & Node2) {
                            path.push([p + 1, q]);
                            d_x = 0;
                            d_y = -1;
                            d_o = 1;
                        } else { /* found entry into regular grid! */
                            path.push([p + 1, q + cell.righttop]);
                            d_x = -1;
                            d_y = 0;
                            d_o = 1;
                            closed = true;
                            //console.log("found entry from top at " + p + "," + q);
                            break;
                        }
                    } else {
                        console.log('MarchingSquaresJS-isoBands: wtf');
                        break;
                    }
                } else if (d_y === 1) {
                    if (d_o === 0) {
                        //console.log("we came from bottom left and proceed to the left");
                        /* try to go left */
                        if (typeof grid.cells[q][p - 1] !== 'undefined') {
                            d_x = -1;
                            d_y = 0;
                            d_o = 0;
                        } else if (cval & Node0) {
                            path.push([p, q + 1]);
                            d_x = 0;
                            d_y = 1;
                            d_o = 0;
                        } else { /* found an entry point into regular grid! */
                            path.push([p, q + cell.leftbottom]);
                            d_x = 1;
                            d_y = 0;
                            d_o = 0;
                            closed = true;
                            //console.log("found entry from bottom at " + p + "," + q);
                            break;
                        }
                    } else {
                        //console.log("we came from bottom right and proceed to the right");
                        console.log('MarchingSquaresJS-isoBands: wtf');
                        break;
                    }
                } else {
                    console.log('MarchingSquaresJS-isoBands: where did we came from???');
                    break;
                }

            }

            p += d_x;
            q += d_y;
            //console.log("going on to  " + p + "," + q + " via " + d_x + " " + d_y + " " + d_o);

            if ((p === i) && (q === j)) { /* bail out, once we've closed a circle path */
                break;
            }

        }

        //console.log("exit with " + p + "," + q + " " + d_x + " " + d_y + " " + d_o);
        return { path: path, i: p, j: q, x: d_x, y: d_y, o: d_o };
    }

    function deleteEdge(cell, edgeIdx) {
        delete cell.edges[edgeIdx];
        for (var k = edgeIdx + 1; k < cell.edges.length; k++) {
            cell.edges[k - 1] = cell.edges[k];
        }
        cell.edges.pop();
    }

    function getStartXY(cell) {

        if (cell.edges.length > 0) {
            var e = cell.edges[cell.edges.length - 1];
            //console.log("starting with edge " + e);
            var cval = cell.cval_real;
            switch (e) {
            case 0:   if (cval & Node1) { /* node 1 within range */
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            } else { /* node 1 below or above threshold */
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            }
            case 1:   if (cval & Node2) {
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            } else {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            }
            case 2:   if (cval & Node2) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            }
            case 3:   if (cval & Node3) {
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            } else {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            }
            case 4:   if (cval & Node1) {
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            } else {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            }
            case 5:   if (cval & Node2) {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            } else {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            }
            case 6:   if (cval & Node2) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            }
            case 7:   if (cval & Node3) {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            } else {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            }
            case 8:   if (cval & Node2) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            }
            case 9:   if (cval & Node3) {
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            } else {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            }
            case 10:  if (cval & Node3) {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            } else {
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            }
            case 11:  if (cval & Node0) {
                return {p: [1, cell.righttop], x: -1, y: 0, o: 1};
            } else {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            }
            case 12:  if (cval & Node2) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            }
            case 13:  if (cval & Node3) {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            } else {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            }
            case 14:  if (cval & Node3) {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            } else {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            }
            case 15:  if (cval & Node0) {
                return {p: [1, cell.rightbottom], x: -1, y: 0, o: 0};
            } else {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            }
            case 16:  if (cval & Node2) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            }
            case 17:  if (cval & Node0) {
                return {p: [cell.bottomright, 0], x: 0, y: 1, o: 1};
            } else {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            }
            case 18:  if (cval & Node3) {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            } else {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            }
            case 19:  if (cval & Node0) {
                return {p: [cell.bottomleft, 0], x: 0, y: 1, o: 0};
            } else {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            }
            case 20:  if (cval & Node0) {
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            } else {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            }
            case 21:  if (cval & Node1) {
                return {p: [0, cell.leftbottom], x: 1, y: 0, o: 0};
            } else {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            }
            case 22:  if (cval & Node0) {
                return {p: [cell.topleft, 1], x: 0, y: -1, o: 0};
            } else {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            }
            case 23:  if (cval & Node1) {
                return {p: [0, cell.lefttop], x: 1, y: 0, o: 1};
            } else {
                return {p: [cell.topright, 1], x: 0, y: -1, o: 1};
            }
            default:  console.log('MarchingSquaresJS-isoBands: edge index out of range!');
                console.log(cell);
                break;
            }
        }

        return null;
    }

    function getExitXY(cell, x, y, o) {

        var e, id_x, d_x, d_y, cval = cell.cval;
        var d_o;

        switch (x) {
        case -1:  switch (o) {
        case 0:   e = isoBandEdgeRB[cval];
            d_x = isoBandNextXRB[cval];
            d_y = isoBandNextYRB[cval];
            d_o = isoBandNextORB[cval];
            break;
        default:  e = isoBandEdgeRT[cval];
            d_x = isoBandNextXRT[cval];
            d_y = isoBandNextYRT[cval];
            d_o = isoBandNextORT[cval];
            break;
            }
            break;
        case 1:   switch (o) {
        case 0:   e = isoBandEdgeLB[cval];
            d_x = isoBandNextXLB[cval];
            d_y = isoBandNextYLB[cval];
            d_o = isoBandNextOLB[cval];
            break;
        default:  e = isoBandEdgeLT[cval];
            d_x = isoBandNextXLT[cval];
            d_y = isoBandNextYLT[cval];
            d_o = isoBandNextOLT[cval];
            break;
            }
            break;
        default:  switch (y) {
        case -1:  switch (o) {
        case 0:   e = isoBandEdgeTL[cval];
            d_x = isoBandNextXTL[cval];
            d_y = isoBandNextYTL[cval];
            d_o = isoBandNextOTL[cval];
            break;
        default:  e = isoBandEdgeTR[cval];
            d_x = isoBandNextXTR[cval];
            d_y = isoBandNextYTR[cval];
            d_o = isoBandNextOTR[cval];
            break;
            }
            break;
        case 1:   switch (o) {
        case 0:   e = isoBandEdgeBL[cval];
            d_x = isoBandNextXBL[cval];
            d_y = isoBandNextYBL[cval];
            d_o = isoBandNextOBL[cval];
            break;
        default:  e = isoBandEdgeBR[cval];
            d_x = isoBandNextXBR[cval];
            d_y = isoBandNextYBR[cval];
            d_o = isoBandNextOBR[cval];
            break;
            }
            break;
        default:  break;
            }
            break;
        }

        id_x = cell.edges.indexOf(e);
        if (typeof cell.edges[id_x] !== 'undefined') {
            deleteEdge(cell, id_x);
        } else {
        //console.log("wrong edges...");
        //console.log(x + " " + y + " " + o);
        //console.log(cell);
            return null;
        }

        cval = cell.cval_real;

        switch (e) {
        case 0:   if (cval & Node1) { /* node 1 within range */
            x = cell.topleft;
            y = 1;
        } else { /* node 1 below or above threshold */
            x = 1;
            y = cell.righttop;
        }
            break;
        case 1:   if (cval & Node2) {
            x = 1;
            y = cell.rightbottom;
        } else {
            x = cell.topleft;
            y = 1;
        }
            break;
        case 2:   if (cval & Node2) {
            x = cell.topleft;
            y = 1;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 3:   if (cval & Node3) {
            x = cell.bottomleft;
            y = 0;
        } else {
            x = cell.topleft;
            y = 1;
        }
            break;
        case 4:   if (cval & Node1) {
            x = cell.topright;
            y = 1;
        } else {
            x = 1;
            y = cell.righttop;
        }
            break;
        case 5:   if (cval & Node2) {
            x = 1;
            y = cell.rightbottom;
        } else {
            x = cell.topright;
            y = 1;
        }
            break;
        case 6:   if (cval & Node2) {
            x = cell.topright;
            y = 1;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 7:   if (cval & Node3) {
            x = cell.bottomleft;
            y = 0;
        } else {
            x = cell.topright;
            y = 1;
        }
            break;
        case 8:   if (cval & Node2) {
            x = 1;
            y = cell.righttop;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 9:   if (cval & Node3) {
            x = cell.bottomleft;
            y = 0;
        } else {
            x = 1;
            y = cell.righttop;
        }
            break;
        case 10:  if (cval & Node3) {
            x = 1;
            y = cell.righttop;
        } else {
            x = 0;
            y = cell.leftbottom;
        }
            break;
        case 11:  if (cval & Node0) {
            x = 0;
            y = cell.lefttop;
        } else {
            x = 1;
            y = cell.righttop;
        }
            break;
        case 12:  if (cval & Node2) {
            x = 1;
            y = cell.rightbottom;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 13:  if (cval & Node3) {
            x = cell.bottomleft;
            y = 0;
        } else {
            x = 1;
            y = cell.rightbottom;
        }
            break;
        case 14:  if (cval & Node3) {
            x = 1;
            y = cell.rightbottom;
        } else {
            x = 0;
            y = cell.leftbottom;
        }
            break;
        case 15:  if (cval & Node0) {
            x = 0;
            y = cell.lefttop;
        } else {
            x = 1;
            y = cell.rightbottom;
        }
            break;
        case 16:  if (cval & Node2) {
            x = 0;
            y = cell.leftbottom;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 17:  if (cval & Node0) {
            x = 0;
            y = cell.lefttop;
        } else {
            x = cell.bottomright;
            y = 0;
        }
            break;
        case 18:  if (cval & Node3) {
            x = cell.bottomleft;
            y = 0;
        } else {
            x = 0;
            y = cell.leftbottom;
        }
            break;
        case 19:  if (cval & Node0) {
            x = 0;
            y = cell.lefttop;
        } else {
            x = cell.bottomleft;
            y = 0;
        }
            break;
        case 20:  if (cval & Node0) {
            x = 0;
            y = cell.leftbottom;
        } else {
            x = cell.topleft;
            y = 1;
        }
            break;
        case 21:  if (cval & Node1) {
            x = cell.topright;
            y = 1;
        } else {
            x = 0;
            y = cell.leftbottom;
        }
            break;
        case 22:  if (cval & Node0) {
            x = 0;
            y = cell.lefttop;
        } else {
            x = cell.topleft;
            y = 1;
        }
            break;
        case 23:  if (cval & Node1) {
            x = cell.topright;
            y = 1;
        } else {
            x = 0;
            y = cell.lefttop;
        }
            break;
        default:  console.log('MarchingSquaresJS-isoBands: edge index out of range!');
            console.log(cell);
            return null;
        }

        if ((typeof x === 'undefined') || (typeof y === 'undefined') ||
          (typeof d_x === 'undefined') || (typeof d_y === 'undefined') ||
          (typeof d_o === 'undefined')) {
            console.log('MarchingSquaresJS-isoBands: undefined value!');
            console.log(cell);
            console.log(x + ' ' + y + ' ' + d_x + ' ' + d_y + ' ' + d_o);
        }
        return {p: [x, y], x: d_x, y: d_y, o: d_o};
    }

    function BandGrid2Areas(grid) {
        var areas = [];
        var area_idx = 0;

        grid.cells.forEach(function (g, j) {
            g.forEach(function (gg, i) {
                if (typeof gg !== 'undefined') {
                    var a = polygon_table[gg.cval](gg);
                    if ((typeof a === 'object') && isArray(a)) {
                        if ((typeof a[0] === 'object') && isArray(a[0])) {
                            if ((typeof a[0][0] === 'object') && isArray(a[0][0])) {
                                a.forEach(function (aa) {
                                    aa.forEach(function (aaa) {
                                        aaa[0] += i;
                                        aaa[1] += j;
                                    });
                                    areas[area_idx++] = aa;
                                });
                            } else {
                                a.forEach(function (aa) {
                                    aa[0] += i;
                                    aa[1] += j;
                                });
                                areas[area_idx++] = a;
                            }
                        } else {
                            console.log('MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates');
                        }
                    } else {
                        console.log('MarchingSquaresJS-isoBands: bandcell polygon with null coordinates');
                    }
                }
            });
        });

        return areas;
    }

    /**
     * Takes a grid {@link FeatureCollection} of {@link Point} features with z-values and an array of
     * value breaks and generates filled contour isobands.
     *
     * @name isobands
     * @param {FeatureCollection<Point>} pointGrid input points
     * @param {Array<number>} breaks where to draw contours
     * @param {Object} [options={}] options on output
     * @param {string} [options.zProperty='elevation'] the property name in `points` from which z-values will be pulled
     * @param {Object} [options.commonProperties={}] GeoJSON properties passed to ALL isobands
     * @param {Array<Object>} [options.breaksProperties=[]] GeoJSON properties passed, in order, to the correspondent isoband (order defined by breaks)
     * @returns {FeatureCollection<MultiPolygon>} a FeatureCollection of {@link MultiPolygon} features representing isobands
     */
    function isobands(pointGrid, breaks, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var zProperty = options.zProperty || 'elevation';
        var commonProperties = options.commonProperties || {};
        var breaksProperties = options.breaksProperties || [];

        // Validation
        collectionOf(pointGrid, 'Point', 'Input must contain Points');
        if (!breaks) throw new Error('breaks is required');
        if (!Array.isArray(breaks)) throw new Error('breaks is not an Array');
        if (!isObject(commonProperties)) throw new Error('commonProperties is not an Object');
        if (!Array.isArray(breaksProperties)) throw new Error('breaksProperties is not an Array');

        // Isoband methods
        var matrix = gridToMatrix$1(pointGrid, {zProperty: zProperty, flip: true});
        var contours = createContourLines(matrix, breaks, zProperty);
        contours = rescaleContours(contours, matrix, pointGrid);

        var multipolygons = contours.map(function (contour, index) {
            if (breaksProperties[index] && !isObject(breaksProperties[index])) {
                throw new Error('Each mappedProperty is required to be an Object');
            }
            // collect all properties
            var contourProperties = Object.assign(
                {},
                commonProperties,
                breaksProperties[index]
            );
            contourProperties[zProperty] = contour[zProperty];
            var multiP = multiPolygon(contour.groupedRings, contourProperties);
            return multiP;
        });

        return featureCollection(multipolygons);
    }

    /**
     * Creates the contours lines (featuresCollection of polygon features) from the 2D data grid
     *
     * Marchingsquares process the grid data as a 3D representation of a function on a 2D plane, therefore it
     * assumes the points (x-y coordinates) are one 'unit' distance. The result of the IsoBands function needs to be
     * rescaled, with turfjs, to the original area and proportions on the map
     *
     * @private
     * @param {Array<Array<number>>} matrix Grid Data
     * @param {Array<number>} breaks Breaks
     * @param {string} [property='elevation'] Property
     * @returns {Array<any>} contours
     */
    function createContourLines(matrix, breaks, property) {

        var contours = [];
        for (var i = 1; i < breaks.length; i++) {
            var lowerBand = +breaks[i - 1]; // make sure the breaks value is a number
            var upperBand = +breaks[i];

            var isobandsCoords = isoBands(matrix, lowerBand, upperBand - lowerBand);
            // as per GeoJson rules for creating a Polygon, make sure the first element
            // in the array of LinearRings represents the exterior ring (i.e. biggest area),
            // and any subsequent elements represent interior rings (i.e. smaller area);
            // this avoids rendering issues of the MultiPolygons on the map
            var nestedRings = orderByArea(isobandsCoords);
            var groupedRings = groupNestedRings(nestedRings);
            var obj = {};
            obj['groupedRings'] = groupedRings;
            obj[property] = lowerBand + '-' + upperBand;
            contours.push(obj);
        }
        return contours;
    }

    /**
     * Transform isobands of 2D grid to polygons for the map
     *
     * @private
     * @param {Array<any>} contours Contours
     * @param {Array<Array<number>>} matrix Grid Data
     * @param {Object} points Points by Latitude
     * @returns {Array<any>} contours
     */
    function rescaleContours(contours, matrix, points$$1) {

        // get dimensions (on the map) of the original grid
        var gridBbox = bbox(points$$1); // [ minX, minY, maxX, maxY ]
        var originalWidth = gridBbox[2] - gridBbox[0];
        var originalHeigth = gridBbox[3] - gridBbox[1];

        // get origin, which is the first point of the last row on the rectangular data on the map
        var x0 = gridBbox[0];
        var y0 = gridBbox[1];
        // get number of cells per side
        var matrixWidth = matrix[0].length - 1;
        var matrixHeight = matrix.length - 1;
        // calculate the scaling factor between matrix and rectangular grid on the map
        var scaleX = originalWidth / matrixWidth;
        var scaleY = originalHeigth / matrixHeight;

        var resize = function (point$$1) {
            point$$1[0] = point$$1[0] * scaleX + x0;
            point$$1[1] = point$$1[1] * scaleY + y0;
        };

        // resize and shift each point/line of the isobands
        contours.forEach(function (contour) {
            contour.groupedRings.forEach(function (lineRingSet) {
                lineRingSet.forEach(function (lineRing) {
                    lineRing.forEach(resize);
                });
            });
        });
        return contours;
    }


    /*  utility functions */


    /**
     * Returns an array of coordinates (of LinearRings) in descending order by area
     *
     * @private
     * @param {Array<LineString>} ringsCoords array of closed LineString
     * @returns {Array} array of the input LineString ordered by area
     */
    function orderByArea(ringsCoords) {
        var ringsWithArea = [];
        var areas = [];
        ringsCoords.forEach(function (coords) {
            // var poly = polygon([points]);
            var ringArea = area$1(polygon([coords]));
            // create an array of areas value
            areas.push(ringArea);
            // associate each lineRing with its area
            ringsWithArea.push({ring: coords, area: ringArea});
        });
        areas.sort(function (a, b) { // bigger --> smaller
            return b - a;
        });
        // create a new array of linearRings coordinates ordered by their area
        var orderedByArea = [];
        areas.forEach(function (area) {
            for (var lr = 0; lr < ringsWithArea.length; lr++) {
                if (ringsWithArea[lr].area === area) {
                    orderedByArea.push(ringsWithArea[lr].ring);
                    ringsWithArea.splice(lr, 1);
                    break;
                }
            }
        });
        return orderedByArea;
    }

    /**
     * Returns an array of arrays of coordinates, each representing
     * a set of (coordinates of) nested LinearRings,
     * i.e. the first ring contains all the others
     *
     * @private
     * @param {Array} orderedLinearRings array of coordinates (of LinearRings) in descending order by area
     * @returns {Array<Array>} Array of coordinates of nested LinearRings
     */
    function groupNestedRings(orderedLinearRings) {
        // create a list of the (coordinates of) LinearRings
        var lrList = orderedLinearRings.map(function (lr) {
            return {lrCoordinates: lr, grouped: false};
        });
        var groupedLinearRingsCoords = [];
        while (!allGrouped(lrList)) {
            for (var i = 0; i < lrList.length; i++) {
                if (!lrList[i].grouped) {
                    // create new group starting with the larger not already grouped ring
                    var group = [];
                    group.push(lrList[i].lrCoordinates);
                    lrList[i].grouped = true;
                    var outerMostPoly = polygon([lrList[i].lrCoordinates]);
                    // group all the rings contained by the outermost ring
                    for (var j = i + 1; j < lrList.length; j++) {
                        if (!lrList[j].grouped) {
                            var lrPoly = polygon([lrList[j].lrCoordinates]);
                            if (isInside(lrPoly, outerMostPoly)) {
                                group.push(lrList[j].lrCoordinates);
                                lrList[j].grouped = true;
                            }
                        }
                    }
                    // insert the new group
                    groupedLinearRingsCoords.push(group);
                }
            }
        }
        return groupedLinearRingsCoords;
    }

    /**
     * @private
     * @param {Polygon} testPolygon polygon of interest
     * @param {Polygon} targetPolygon polygon you want to compare with
     * @returns {boolean} true if test-Polygon is inside target-Polygon
     */
    function isInside(testPolygon, targetPolygon) {
        var points$$1 = explode(testPolygon);
        for (var i = 0; i < points$$1.features.length; i++) {
            if (!booleanPointInPolygon(points$$1.features[i], targetPolygon)) {
                return false;
            }
        }
        return true;
    }

    /**
     * @private
     * @param {Array<Object>} list list of objects which might contain the 'group' attribute
     * @returns {boolean} true if all the objects in the list are marked as grouped
     */
    function allGrouped(list) {
        for (var i = 0; i < list.length; i++) {
            if (list[i].grouped === false) {
                return false;
            }
        }
        return true;
    }

    /**
     * Rotates any geojson Feature or Geometry of a specified angle, around its `centroid` or a given `pivot` point;
     * all rotations follow the right-hand rule: https://en.wikipedia.org/wiki/Right-hand_rule
     *
     * @name transformRotate
     * @param {GeoJSON} geojson object to be rotated
     * @param {number} angle of rotation (along the vertical axis), from North in decimal degrees, negative clockwise
     * @param {Object} [options={}] Optional parameters
     * @param {Coord} [options.pivot='centroid'] point around which the rotation will be performed
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} the rotated GeoJSON feature
     * @example
     * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
     * var options = {pivot: [0, 25]};
     * var rotatedPoly = turf.transformRotate(poly, 10, options);
     *
     * //addToMap
     * var addToMap = [poly, rotatedPoly];
     * rotatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
     */
    function transformRotate(geojson, angle, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var pivot = options.pivot;
        var mutate = options.mutate;

        // Input validation
        if (!geojson) throw new Error('geojson is required');
        if (angle === undefined || angle === null || isNaN(angle)) throw new Error('angle is required');

        // Shortcut no-rotation
        if (angle === 0) return geojson;

        // Use centroid of GeoJSON if pivot is not provided
        if (!pivot) pivot = centroid(geojson);

        // Clone geojson to avoid side effects
        if (mutate === false || mutate === undefined) geojson = clone(geojson);

        // Rotate each coordinate
        coordEach(geojson, function (pointCoords) {
            var initialAngle = rhumbBearing(pivot, pointCoords);
            var finalAngle = initialAngle + angle;
            var distance = rhumbDistance(pivot, pointCoords);
            var newCoords = getCoords(rhumbDestination(pivot, distance, finalAngle));
            pointCoords[0] = newCoords[0];
            pointCoords[1] = newCoords[1];
        });
        return geojson;
    }

    /**
     * Scale a GeoJSON from a given point by a factor of scaling (ex: factor=2 would make the GeoJSON 200% larger).
     * If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.
     *
     * @name transformScale
     * @param {GeoJSON} geojson GeoJSON to be scaled
     * @param {number} factor of scaling, positive or negative values greater than 0
     * @param {Object} [options={}] Optional parameters
     * @param {string|Coord} [options.origin='centroid'] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} scaled GeoJSON
     * @example
     * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
     * var scaledPoly = turf.transformScale(poly, 3);
     *
     * //addToMap
     * var addToMap = [poly, scaledPoly];
     * scaledPoly.properties = {stroke: '#F00', 'stroke-width': 4};
     */
    function transformScale(geojson, factor, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var origin = options.origin;
        var mutate = options.mutate;

        // Input validation
        if (!geojson) throw new Error('geojson required');
        if (typeof factor !== 'number' || factor === 0) throw new Error('invalid factor');
        var originIsPoint = Array.isArray(origin) || typeof origin === 'object';

        // Clone geojson to avoid side effects
        if (mutate !== true) geojson = clone(geojson);

        // Scale each Feature separately
        if (geojson.type === 'FeatureCollection' && !originIsPoint) {
            featureEach(geojson, function (feature$$1, index) {
                geojson.features[index] = scale(feature$$1, factor, origin);
            });
            return geojson;
        }
        // Scale Feature/Geometry
        return scale(geojson, factor, origin);
    }

    /**
     * Scale Feature/Geometry
     *
     * @private
     * @param {Feature|Geometry} feature GeoJSON Feature/Geometry
     * @param {number} factor of scaling, positive or negative values greater than 0
     * @param {string|Coord} [origin="centroid"] Point from which the scaling will occur (string options: sw/se/nw/ne/center/centroid)
     * @returns {Feature|Geometry} scaled GeoJSON Feature/Geometry
     */
    function scale(feature$$1, factor, origin) {
        // Default params
        var isPoint = getType(feature$$1) === 'Point';
        origin = defineOrigin(feature$$1, origin);

        // Shortcut no-scaling
        if (factor === 1 || isPoint) return feature$$1;

        // Scale each coordinate
        coordEach(feature$$1, function (coord) {
            var originalDistance = rhumbDistance(origin, coord);
            var bearing = rhumbBearing(origin, coord);
            var newDistance = originalDistance * factor;
            var newCoord = getCoords(rhumbDestination(origin, newDistance, bearing));
            coord[0] = newCoord[0];
            coord[1] = newCoord[1];
            if (coord.length === 3) coord[2] *= factor;
        });

        return feature$$1;
    }

    /**
     * Define Origin
     *
     * @private
     * @param {GeoJSON} geojson GeoJSON
     * @param {string|Coord} origin sw/se/nw/ne/center/centroid
     * @returns {Feature<Point>} Point origin
     */
    function defineOrigin(geojson, origin) {
        // Default params
        if (origin === undefined || origin === null) origin = 'centroid';

        // Input Coord
        if (Array.isArray(origin) || typeof origin === 'object') return getCoord(origin);

        // Define BBox
        var bbox$$1 = (geojson.bbox) ? geojson.bbox : bbox(geojson);
        var west = bbox$$1[0];
        var south = bbox$$1[1];
        var east = bbox$$1[2];
        var north = bbox$$1[3];

        switch (origin) {
        case 'sw':
        case 'southwest':
        case 'westsouth':
        case 'bottomleft':
            return point([west, south]);
        case 'se':
        case 'southeast':
        case 'eastsouth':
        case 'bottomright':
            return point([east, south]);
        case 'nw':
        case 'northwest':
        case 'westnorth':
        case 'topleft':
            return point([west, north]);
        case 'ne':
        case 'northeast':
        case 'eastnorth':
        case 'topright':
            return point([east, north]);
        case 'center':
            return center(geojson);
        case undefined:
        case null:
        case 'centroid':
            return centroid(geojson);
        default:
            throw new Error('invalid origin');
        }
    }

    /**
     * Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line
     * on the provided direction angle.
     *
     * @name transformTranslate
     * @param {GeoJSON} geojson object to be translated
     * @param {number} distance length of the motion; negative values determine motion in opposite direction
     * @param {number} direction of the motion; angle from North in decimal degrees, positive clockwise
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] in which `distance` will be express; miles, kilometers, degrees, or radians
     * @param {number} [options.zTranslation=0] length of the vertical motion, same unit of distance
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} the translated GeoJSON object
     * @example
     * var poly = turf.polygon([[[0,29],[3.5,29],[2.5,32],[0,29]]]);
     * var translatedPoly = turf.transformTranslate(poly, 100, 35);
     *
     * //addToMap
     * var addToMap = [poly, translatedPoly];
     * translatedPoly.properties = {stroke: '#F00', 'stroke-width': 4};
     */
    function transformTranslate(geojson, distance, direction, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var units = options.units;
        var zTranslation = options.zTranslation;
        var mutate = options.mutate;

        // Input validation
        if (!geojson) throw new Error('geojson is required');
        if (distance === undefined || distance === null || isNaN(distance)) throw new Error('distance is required');
        if (zTranslation && typeof zTranslation !== 'number' && isNaN(zTranslation)) throw new Error('zTranslation is not a number');

        // Shortcut no-motion
        zTranslation = (zTranslation !== undefined) ? zTranslation : 0;
        if (distance === 0 && zTranslation === 0) return geojson;

        if (direction === undefined || direction === null || isNaN(direction)) throw new Error('direction is required');

        // Invert with negative distances
        if (distance < 0) {
            distance = -distance;
            direction = direction + 180;
        }

        // Clone geojson to avoid side effects
        if (mutate === false || mutate === undefined) geojson = clone(geojson);

        // Translate each coordinate
        coordEach(geojson, function (pointCoords) {
            var newCoords = getCoords(rhumbDestination(pointCoords, distance, direction, {units: units}));
            pointCoords[0] = newCoords[0];
            pointCoords[1] = newCoords[1];
            if (zTranslation && pointCoords.length === 3) pointCoords[2] += zTranslation;
        });
        return geojson;
    }

    /**
     * https://github.com/rook2pawn/node-intersection
     *
     * Author @rook2pawn
     */

    /**
     * AB
     *
     * @private
     * @param {Array<Array<number>>} segment - 2 vertex line segment
     * @returns {Array<number>} coordinates [x, y]
     */
    function ab(segment) {
        var start = segment[0];
        var end = segment[1];
        return [end[0] - start[0], end[1] - start[1]];
    }

    /**
     * Cross Product
     *
     * @private
     * @param {Array<number>} v1 coordinates [x, y]
     * @param {Array<number>} v2 coordinates [x, y]
     * @returns {Array<number>} Cross Product
     */
    function crossProduct$1(v1, v2) {
        return (v1[0] * v2[1]) - (v2[0] * v1[1]);
    }

    /**
     * Add
     *
     * @private
     * @param {Array<number>} v1 coordinates [x, y]
     * @param {Array<number>} v2 coordinates [x, y]
     * @returns {Array<number>} Add
     */
    function add$1(v1, v2) {
        return [v1[0] + v2[0], v1[1] + v2[1]];
    }

    /**
     * Sub
     *
     * @private
     * @param {Array<number>} v1 coordinates [x, y]
     * @param {Array<number>} v2 coordinates [x, y]
     * @returns {Array<number>} Sub
     */
    function sub(v1, v2) {
        return [v1[0] - v2[0], v1[1] - v2[1]];
    }

    /**
     * scalarMult
     *
     * @private
     * @param {number} s scalar
     * @param {Array<number>} v coordinates [x, y]
     * @returns {Array<number>} scalarMult
     */
    function scalarMult(s, v) {
        return [s * v[0], s * v[1]];
    }

    /**
     * Intersect Segments
     *
     * @private
     * @param {Array<number>} a coordinates [x, y]
     * @param {Array<number>} b coordinates [x, y]
     * @returns {Array<number>} intersection
     */
    function intersectSegments(a, b) {
        var p = a[0];
        var r = ab(a);
        var q = b[0];
        var s = ab(b);

        var cross = crossProduct$1(r, s);
        var qmp = sub(q, p);
        var numerator = crossProduct$1(qmp, s);
        var t = numerator / cross;
        var intersection = add$1(p, scalarMult(t, r));
        return intersection;
    }

    /**
     * Is Parallel
     *
     * @private
     * @param {Array<number>} a coordinates [x, y]
     * @param {Array<number>} b coordinates [x, y]
     * @returns {boolean} true if a and b are parallel (or co-linear)
     */
    function isParallel(a, b) {
        var r = ab(a);
        var s = ab(b);
        var cp = Math.abs(crossProduct$1(r, s));
        // return (crossProduct(r, s) === 0);
        return (cp < 0.0000001);
    }

    /**
     * Intersection
     *
     * @private
     * @param {Array<number>} a coordinates [x, y]
     * @param {Array<number>} b coordinates [x, y]
     * @returns {Array<number>|boolean} true if a and b are parallel (or co-linear)
     */
    function intersection$1(a, b) {
        if (isParallel(a, b)) return false;
        return intersectSegments(a, b);
    }

    /**
     * Takes a {@link LineString|line} and returns a {@link LineString|line} at offset by the specified distance.
     *
     * @name lineOffset
     * @param {Geometry|Feature<LineString|MultiLineString>} geojson input GeoJSON
     * @param {number} distance distance to offset the line (can be of negative value)
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] can be degrees, radians, miles, kilometers, inches, yards, meters
     * @returns {Feature<LineString|MultiLineString>} Line offset from the input line
     * @example
     * var line = turf.lineString([[-83, 30], [-84, 36], [-78, 41]], { "stroke": "#F00" });
     *
     * var offsetLine = turf.lineOffset(line, 2, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [offsetLine, line]
     * offsetLine.properties.stroke = "#00F"
     */
    function lineOffset(geojson, distance, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var units = options.units ? options.units : 'kilometers';

        // Valdiation
        if (!geojson) throw new Error('geojson is required');
        if (distance === undefined || distance === null || isNaN(distance)) throw new Error('distance is required');
        const distanceMeters = convertLength(distance, units, 'meters');

        var type = getType(geojson);
        var properties = geojson.properties;

        geojson = JSON.parse(JSON.stringify(geojson));

        switch (type) {
        case 'LineString':
            return lineOffsetFeature(geojson, distanceMeters);
        case 'MultiLineString':
            var coords = [];
            flattenEach(geojson, function (feature$$1) {
                coords.push(lineOffsetFeature(feature$$1, distanceMeters).geometry.coordinates);
            });
            return multiLineString(coords, properties);
        default:
            throw new Error('geometry ' + type + ' is not supported');
        }
    }

    /**
     * Line Offset
     *
     * @private
     * @param {Geometry|Feature<LineString>} line input line
     * @param {number} distance distance to offset the line (can be of negative value)
     * @param {string} [units=kilometers] units
     * @returns {Feature<LineString>} Line offset from the input line
     */
    function lineOffsetFeature(line, distance) {

        var centroid = centerOfMass(line);
        var utmZone = checkUtmZone(centroid.geometry);
        reprojectFeature(line, utmZone, true);

        var segments = [];
        var coords = getCoords(line);
        var finalCoords = [];
        coords.forEach(function (currentCoords, index) {
            if (index !== coords.length - 1) {
                var segment = processSegment(currentCoords, coords[index + 1], distance);
                segments.push(segment);
                if (index > 0) {
                    var seg2Coords = segments[index - 1];
                    var intersects = intersection$1(segment, seg2Coords);

                    // Handling for line segments that aren't straight
                    if (intersects !== false) {
                        seg2Coords[1] = intersects;
                        segment[0] = intersects;
                    }

                    finalCoords.push(seg2Coords[0]);
                    if (index === coords.length - 2) {
                        finalCoords.push(segment[0]);
                        finalCoords.push(segment[1]);
                    }
                }
                // Handling for lines that only have 1 segment
                if (coords.length === 2) {
                    finalCoords.push(segment[0]);
                    finalCoords.push(segment[1]);
                }
            }
        });
        var out = lineString(finalCoords, line.properties);
        reprojectFeature(out, utmZone, false);
        return out;
    }

    /**
     * Process Segment
     * Inspiration taken from http://stackoverflow.com/questions/2825412/draw-a-parallel-line
     *
     * @private
     * @param {Array<number>} point1 Point coordinates
     * @param {Array<number>} point2 Point coordinates
     * @param {number} offset Offset
     * @returns {Array<Array<number>>} offset points
     */
    function processSegment(point1, point2, offset) {
        var L = Math.sqrt((point1[0] - point2[0]) * (point1[0] - point2[0]) + (point1[1] - point2[1]) * (point1[1] - point2[1]));

        var out1x = point1[0] + offset * (point2[1] - point1[1]) / L;
        var out2x = point2[0] + offset * (point2[1] - point1[1]) / L;
        var out1y = point1[1] + offset * (point1[0] - point2[0]) / L;
        var out2y = point2[1] + offset * (point1[0] - point2[0]) / L;
        return [[out1x, out1y], [out2x, out2y]];
    }

    function reprojectFeature(feature$$1, utmZone, toUtm) {
        coordEach(feature$$1, function (coord, coordIndex) { //eslint-disable-line
            var blah = toUtm ? convertCoordToUtm(coord[0], coord[1], utmZone) : convertUtmToLatLon(coord[0], coord[1], utmZone);
            coord.length = 0;
            coord.push(blah[0], blah[1]);
        }, false);
    }

    function checkUtmZone(centerPoint) {

        const lat = centerPoint.coordinates[1];
        const lon = centerPoint.coordinates[0];
        let zoneNumber = Math.floor((lon + 180) / 6) + 1;
        let hemisphere = 'N';

        if (lon === 180) zoneNumber = 60;
        if (lat < 0.0) hemisphere = 'S';

        if (lat >= 56.0 && lat < 64.0 && lon >= 3.0 && lon < 12.0) zoneNumber = 32;

        return {zoneNumber, hemisphere};
    }

    function convertCoordToUtm(lon, lat, zone) {

        let falseEasting = 500e3;
        let falseNorthing = 10000e3;
        let λ0 = degreesToRadians(((zone.zoneNumber - 1) * 6 - 180 + 3));

        let mgrsLatBands = 'CDEFGHJKLMNPQRSTUVWXX'; // X is repeated for 80-84°N
        let latBand = mgrsLatBands.charAt(Math.floor(lat / 8 + 10));

        // adjust zone & central meridian for Norway
        if (zone === 31 && latBand === 'V' && lon >= 3) { zone++; degreesToRadians(λ0 += 6); }
        // adjust zone & central meridian for Svalbard
        if (zone === 32 && latBand === 'X' && lon <  9) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 32 && latBand === 'X' && lon >= 9) { zone++; degreesToRadians(λ0 += 6); }
        if (zone === 34 && latBand === 'X' && lon < 21) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 34 && latBand === 'X' && lon >= 21) { zone++; degreesToRadians(λ0 += 6); }
        if (zone === 36 && latBand === 'X' && lon < 33) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 36 && latBand === 'X' && lon >= 33) { zone++; degreesToRadians(λ0 += 6); }

        var φ = degreesToRadians(lat);      // latitude ± from equator
        var λ = degreesToRadians(lon) - λ0; // longitude ± from central meridian

        let a = 6378137;
        let f = 1 / 298.257223563;
        // WGS 84: a = 6378137, b = 6356752.314245, f = 1/298.257223563;

        let k0 = 0.9996; // UTM scale on the central meridian

        // ---- easting, northing: Karney 2011 Eq 7-14, 29, 35:

        let e = Math.sqrt(f * (2 - f)); // eccentricity
        let n = f / (2 - f);        // 3rd flattening
        let n2 = n * n, n3 = n * n2, n4 = n * n3, n5 = n * n4, n6 = n * n5; // TODO: compare Horner-form accuracy?

        let cosλ = Math.cos(λ), sinλ = Math.sin(λ);

        let τ = Math.tan(φ); // τ ≡ tanφ, τʹ ≡ tanφʹ; prime (ʹ) indicates angles on the conformal sphere
        let σ = Math.sinh(e * Math.atanh(e * τ / Math.sqrt(1 + τ * τ)));

        let τʹ = τ * Math.sqrt(1 + σ * σ) - σ * Math.sqrt(1 + τ * τ);

        let ξʹ = Math.atan2(τʹ, cosλ);
        let ηʹ = Math.asinh(sinλ / Math.sqrt(τʹ * τʹ + cosλ * cosλ));

        let A = a / (1 + n) * (1 + 1 / 4 * n2 + 1 / 64 * n4 + 1 / 256 * n6); // 2πA is the circumference of a meridian

        let α = [null, // note α is one-based array (6th order Krüger expressions)
            1 / 2 * n - 2 / 3 * n2 + 5 / 16 * n3 +   41 / 180 * n4 -     127 / 288 * n5 +      7891 / 37800 * n6,
            13 / 48 * n2 -  3 / 5 * n3 + 557 / 1440 * n4 +     281 / 630 * n5 - 1983433 / 1935360 * n6,
            61 / 240 * n3 -  103 / 140 * n4 + 15061 / 26880 * n5 +   167603 / 181440 * n6,
            49561 / 161280 * n4 -     179 / 168 * n5 + 6601661 / 7257600 * n6,
            34729 / 80640 * n5 - 3418889 / 1995840 * n6,
            212378941 / 319334400 * n6];

        let ξ = ξʹ;
        for (let j = 1; j <= 6; j++) ξ += α[j] * Math.sin(2 * j * ξʹ) * Math.cosh(2 * j * ηʹ);

        let η = ηʹ;
        for (let j = 1; j <= 6; j++) η += α[j] * Math.cos(2 * j * ξʹ) * Math.sinh(2 * j * ηʹ);

        let x = k0 * A * η;
        let y = k0 * A * ξ;

        x = x + falseEasting;
        if (y < 0) y = y + falseNorthing;

        return [y, x];
    }

    function convertUtmToLatLon(y, x, zone) {
        var z = zone.zoneNumber;
        var h = zone.hemisphere;

        var falseEasting = 500e3, falseNorthing = 10000e3;

        var a = 6378137, f = 1 / 298.257223563;

        var k0 = 0.9996; // UTM scale on the central meridian

        x = x - falseEasting;               // make x ± relative to central meridian
        y = h === 'S' ? y - falseNorthing : y; // make y ± relative to equator

        // ---- from Karney 2011 Eq 15-22, 36:

        var e = Math.sqrt(f * (2 - f)); // eccentricity
        var n = f / (2 - f);        // 3rd flattening
        var n2 = n * n, n3 = n * n2, n4 = n * n3, n5 = n * n4, n6 = n * n5;

        var A = a / (1 + n) * (1 + 1 / 4 * n2 + 1 / 64 * n4 + 1 / 256 * n6); // 2πA is the circumference of a meridian

        var η = x / (k0 * A);
        var ξ = y / (k0 * A);

        var β = [null, // note β is one-based array (6th order Krüger expressions)
            1 / 2 * n - 2 / 3 * n2 + 37 / 96 * n3 -    1 / 360 * n4 -   81 / 512 * n5 +    96199 / 604800 * n6,
                   1 / 48 * n2 +  1 / 15 * n3 - 437 / 1440 * n4 +   46 / 105 * n5 - 1118711 / 3870720 * n6,
                            17 / 480 * n3 -   37 / 840 * n4 - 209 / 4480 * n5 +      5569 / 90720 * n6,
                                     4397 / 161280 * n4 -   11 / 504 * n5 -  830251 / 7257600 * n6,
                                                   4583 / 161280 * n5 -  108847 / 3991680 * n6,
                                                                 20648693 / 638668800 * n6 ];

        var ξʹ = ξ;
        for (var j = 1; j <= 6; j++) ξʹ -= β[j] * Math.sin(2 * j * ξ) * Math.cosh(2 * j * η);

        var ηʹ = η;
        for (var j = 1; j <= 6; j++) ηʹ -= β[j] * Math.cos(2 * j * ξ) * Math.sinh(2 * j * η);

        var sinhηʹ = Math.sinh(ηʹ);
        var sinξʹ = Math.sin(ξʹ), cosξʹ = Math.cos(ξʹ);

        var τʹ = sinξʹ / Math.sqrt(sinhηʹ * sinhηʹ + cosξʹ * cosξʹ);

        var τi = τʹ;
        do {
            var σi = Math.sinh(e * Math.atanh(e * τi / Math.sqrt(1 + τi * τi)));
            var τiʹ = τi * Math.sqrt(1 + σi * σi) - σi * Math.sqrt(1 + τi * τi);
            var δτi = (τʹ - τiʹ) / Math.sqrt(1 + τiʹ * τiʹ)
                * (1 + (1 - e * e) * τi * τi) / ((1 - e * e) * Math.sqrt(1 + τi * τi));
            τi += δτi;
        } while (Math.abs(δτi) > 1e-12); // using IEEE 754 δτi -> 0 after 2-3 iterations
        // note relatively large convergence test as δτi toggles on ±1.12e-16 for eg 31 N 400000 5000000
        var τ = τi;

        var φ = Math.atan(τ);

        var λ = Math.atan2(sinhηʹ, cosξʹ);

        // ---- convergence: Karney 2011 Eq 26, 27

        var p = 1;
        for (var j = 1; j <= 6; j++) p -= 2 * j * β[j] * Math.cos(2 * j * ξ) * Math.cosh(2 * j * η);
        var q = 0;
        for (var j = 1; j <= 6; j++) q += 2 * j * β[j] * Math.sin(2 * j * ξ) * Math.sinh(2 * j * η);

        // ------------

        var λ0 = degreesToRadians((z - 1) * 6 - 180 + 3); // longitude of central meridian
        λ += λ0; // move λ from zonal to global coordinates

        // round to reasonable precision
        var lat = radiansToDegrees(φ); // nm precision (1nm = 10^-11°)
        var lon = radiansToDegrees(λ); // (strictly lat rounding should be φ⋅cosφ!)

        return [lon, lat];
    }

    /**
     * Returns the direction of the point q relative to the vector p1 -> p2.
     *
     * Implementation of geos::algorithm::CGAlgorithm::orientationIndex()
     * (same as geos::algorithm::CGAlgorithm::computeOrientation())
     *
     * @param {number[]} p1 - the origin point of the vector
     * @param {number[]} p2 - the final point of the vector
     * @param {number[]} q - the point to compute the direction to
     *
     * @returns {number} - 1 if q is ccw (left) from p1->p2,
     *    -1 if q is cw (right) from p1->p2,
     *     0 if q is colinear with p1->p2
     */
    function orientationIndex(p1, p2, q) {
        var dx1 = p2[0] - p1[0],
            dy1 = p2[1] - p1[1],
            dx2 = q[0] - p2[0],
            dy2 = q[1] - p2[1];

        return Math.sign(dx1 * dy2 - dx2 * dy1);
    }

    /**
     * Checks if two envelopes are equal.
     *
     * The function assumes that the arguments are envelopes, i.e.: Rectangular polygon
     *
     * @param {Feature<Polygon>} env1 - Envelope
     * @param {Feature<Polygon>} env2 - Envelope
     * @returns {boolean} - True if the envelopes are equal
     */
    function envelopeIsEqual(env1, env2) {
        var envX1 = env1.geometry.coordinates.map(function (c) { return c[0]; }),
            envY1 = env1.geometry.coordinates.map(function (c) { return c[1]; }),
            envX2 = env2.geometry.coordinates.map(function (c) { return c[0]; }),
            envY2 = env2.geometry.coordinates.map(function (c) { return c[1]; });

        return Math.max(null, envX1) === Math.max(null, envX2) &&
        Math.max(null, envY1) === Math.max(null, envY2) &&
        Math.min(null, envX1) === Math.min(null, envX2) &&
        Math.min(null, envY1) === Math.min(null, envY2);
    }

    /**
     * Check if a envelope is contained in other one.
     *
     * The function assumes that the arguments are envelopes, i.e.: Convex polygon
     * XXX: Envelopes are rectangular, checking if a point is inside a rectangule is something easy,
     * this could be further improved.
     *
     * @param {Feature<Polygon>} self - Envelope
     * @param {Feature<Polygon>} env - Envelope
     * @returns {boolean} - True if env is contained in self
     */
    function envelopeContains(self, env) {
        return env.geometry.coordinates[0].every(function (c) { return booleanPointInPolygon(point(c), self); });
    }

    /**
     * Checks if two coordinates are equal.
     *
     * @param {number[]} coord1 - First coordinate
     * @param {number[]} coord2 - Second coordinate
     * @returns {boolean} - True if coordinates are equal
     */
    function coordinatesEqual(coord1, coord2) {
        return coord1[0] === coord2[0] && coord1[1] === coord2[1];
    }

    /**
     * Node
     */
    var Node$2 = function Node(coordinates) {
        this.id = Node.buildId(coordinates);
        this.coordinates = coordinates; //< {Number[]}
        this.innerEdges = []; //< {Edge[]}

        // We wil store to (out) edges in an CCW order as geos::planargraph::DirectedEdgeStar does
        this.outerEdges = []; //< {Edge[]}
        this.outerEdgesSorted = false; //< {Boolean} flag that stores if the outer Edges had been sorted
    };

    Node$2.buildId = function buildId (coordinates) {
        return coordinates.join(',');
    };

    Node$2.prototype.removeInnerEdge = function removeInnerEdge (edge) {
        this.innerEdges = this.innerEdges.filter(function (e) { return e.from.id !== edge.from.id; });
    };

    Node$2.prototype.removeOuterEdge = function removeOuterEdge (edge) {
        this.outerEdges = this.outerEdges.filter(function (e) { return e.to.id !== edge.to.id; });
    };

    /**
     * Outer edges are stored CCW order.
     *
     * @memberof Node
     * @param {Edge} edge - Edge to add as an outerEdge.
     */
    Node$2.prototype.addOuterEdge = function addOuterEdge (edge) {
        this.outerEdges.push(edge);
        this.outerEdgesSorted = false;
    };

    /**
     * Sorts outer edges in CCW way.
     *
     * @memberof Node
     * @private
     */
    Node$2.prototype.sortOuterEdges = function sortOuterEdges () {
            var this$1 = this;

        if (!this.outerEdgesSorted) {
            //this.outerEdges.sort((a, b) => a.compareTo(b));
            // Using this comparator in order to be deterministic
            this.outerEdges.sort(function (a, b) {
                var aNode = a.to,
                    bNode = b.to;

                if (aNode.coordinates[0] - this$1.coordinates[0] >= 0 && bNode.coordinates[0] - this$1.coordinates[0] < 0)
                    { return 1; }
                if (aNode.coordinates[0] - this$1.coordinates[0] < 0 && bNode.coordinates[0] - this$1.coordinates[0] >= 0)
                    { return -1; }

                if (aNode.coordinates[0] - this$1.coordinates[0] === 0 && bNode.coordinates[0] - this$1.coordinates[0] === 0) {
                    if (aNode.coordinates[1] - this$1.coordinates[1] >= 0 || bNode.coordinates[1] - this$1.coordinates[1] >= 0)
                        { return aNode.coordinates[1] - bNode.coordinates[1]; }
                    return bNode.coordinates[1] - aNode.coordinates[1];
                }

                var det = orientationIndex(this$1.coordinates, aNode.coordinates, bNode.coordinates);
                if (det < 0)
                    { return 1; }
                if (det > 0)
                    { return -1; }

                var d1 = Math.pow(aNode.coordinates[0] - this$1.coordinates[0], 2) + Math.pow(aNode.coordinates[1] - this$1.coordinates[1], 2),
                    d2 = Math.pow(bNode.coordinates[0] - this$1.coordinates[0], 2) + Math.pow(bNode.coordinates[1] - this$1.coordinates[1], 2);

                return d1 - d2;
            });
            this.outerEdgesSorted = true;
        }
    };

    /**
     * Retrieves outer edges.
     *
     * They are sorted if they aren't in the CCW order.
     *
     * @memberof Node
     * @returns {Edge[]} - List of outer edges sorted in a CCW order.
     */
    Node$2.prototype.getOuterEdges = function getOuterEdges () {
        this.sortOuterEdges();
        return this.outerEdges;
    };

    Node$2.prototype.getOuterEdge = function getOuterEdge (i) {
        this.sortOuterEdges();
        return this.outerEdges[i];
    };

    Node$2.prototype.addInnerEdge = function addInnerEdge (edge) {
        this.innerEdges.push(edge);
    };

    /**
     * This class is inspired by GEOS's geos::operation::polygonize::PolygonizeDirectedEdge
     */
    var Edge = function Edge(from, to) {
        this.from = from; //< start
        this.to = to; //< End

        this.next = undefined; //< The edge to be computed after
        this.label = undefined; //< Used in order to detect Cut Edges (Bridges)
        this.symetric = undefined; //< The symetric edge of this
        this.ring = undefined; //< EdgeRing in which the Edge is

        this.from.addOuterEdge(this);
        this.to.addInnerEdge(this);
    };

    /**
     * Removes edge from from and to nodes.
     */
    Edge.prototype.getSymetric = function getSymetric () {
        if (!this.symetric) {
            this.symetric = new Edge(this.to, this.from);
            this.symetric.symetric = this;
        }

        return this.symetric;
    };

    Edge.prototype.deleteEdge = function deleteEdge () {
        this.from.removeOuterEdge(this);
        this.to.removeInnerEdge(this);
    };

    /**
     * Compares Edge equallity.
     *
     * An edge is equal to another, if the from and to nodes are the same.
     *
     * @param {Edge} edge - Another Edge
     * @returns {boolean} - True if Edges are equal, False otherwise
     */
    Edge.prototype.isEqual = function isEqual (edge) {
        return this.from.id === edge.from.id && this.to.id === edge.to.id;
    };

    Edge.prototype.toString = function toString () {
        return ("Edge { " + (this.from.id) + " -> " + (this.to.id) + " }");
    };

    /**
     * Returns a LineString representation of the Edge
     *
     * @returns {Feature<LineString>} - LineString representation of the Edge
     */
    Edge.prototype.toLineString = function toLineString () {
        return lineString([this.from.coordinates, this.to.coordinates]);
    };

    /**
     * Comparator of two edges.
     *
     * Implementation of geos::planargraph::DirectedEdge::compareTo.
     *
     * @param {Edge} edge - Another edge to compare with this one
     * @returns {number} -1 if this Edge has a greater angle with the positive x-axis than b,
     *      0 if the Edges are colinear,
     *      1 otherwise
     */
    Edge.prototype.compareTo = function compareTo (edge) {
        return orientationIndex(edge.from.coordinates, edge.to.coordinates, this.to.coordinates);
    };

    /**
     * Ring of edges which form a polygon.
     *
     * The ring may be either an outer shell or a hole.
     *
     * This class is inspired in GEOS's geos::operation::polygonize::EdgeRing
     */
    var EdgeRing = function EdgeRing() {
        this.edges = [];
        this.polygon = undefined; //< Caches Polygon representation
        this.envelope = undefined; //< Caches Envelope representation
    };

    var prototypeAccessors = { length: { configurable: true } };

    /**
     * Add an edge to the ring, inserting it in the last position.
     *
     * @memberof EdgeRing
     * @param {Edge} edge - Edge to be inserted
     */
    EdgeRing.prototype.push = function push (edge) {
    // Emulate Array getter ([]) behaviour
        this[this.edges.length] = edge;
        this.edges.push(edge);
        this.polygon = this.envelope = undefined;
    };

    /**
     * Get Edge.
     *
     * @memberof EdgeRing
     * @param {number} i - Index
     * @returns {Edge} - Edge in the i position
     */
    EdgeRing.prototype.get = function get (i) {
        return this.edges[i];
    };

    /**
     * Getter of length property.
     *
     * @memberof EdgeRing
     * @returns {number} - Length of the edge ring.
     */
    prototypeAccessors.length.get = function () {
        return this.edges.length;
    };

    /**
     * Similar to Array.prototype.forEach for the list of Edges in the EdgeRing.
     *
     * @memberof EdgeRing
     * @param {Function} f - The same function to be passed to Array.prototype.forEach
     */
    EdgeRing.prototype.forEach = function forEach (f) {
        this.edges.forEach(f);
    };

    /**
     * Similar to Array.prototype.map for the list of Edges in the EdgeRing.
     *
     * @memberof EdgeRing
     * @param {Function} f - The same function to be passed to Array.prototype.map
     * @returns {Array} - The mapped values in the function
     */
    EdgeRing.prototype.map = function map (f) {
        return this.edges.map(f);
    };

    /**
     * Similar to Array.prototype.some for the list of Edges in the EdgeRing.
     *
     * @memberof EdgeRing
     * @param {Function} f - The same function to be passed to Array.prototype.some
     * @returns {boolean} - True if an Edge check the condition
     */
    EdgeRing.prototype.some = function some (f) {
        return this.edges.some(f);
    };

    /**
     * Check if the ring is valid in geomtry terms.
     *
     * A ring must have either 0 or 4 or more points. The first and the last must be
     * equal (in 2D)
     * geos::geom::LinearRing::validateConstruction
     *
     * @memberof EdgeRing
     * @returns {boolean} - Validity of the EdgeRing
     */
    EdgeRing.prototype.isValid = function isValid () {
    // TODO: stub
        return true;
    };

    /**
     * Tests whether this ring is a hole.
     *
     * A ring is a hole if it is oriented counter-clockwise.
     * Similar implementation of geos::algorithm::CGAlgorithms::isCCW
     *
     * @memberof EdgeRing
     * @returns {boolean} - true: if it is a hole
     */
    EdgeRing.prototype.isHole = function isHole () {
            var this$1 = this;

    // XXX: Assuming Ring is valid
    // Find highest point
        var hiIndex = this.edges.reduce(function (high, edge, i) {
                if (edge.from.coordinates[1] > this$1.edges[high].from.coordinates[1])
                    { high = i; }
                return high;
            }, 0),
            iPrev = (hiIndex === 0 ? this.length : hiIndex) - 1,
            iNext = (hiIndex + 1) % this.length,
            disc = orientationIndex(this.edges[iPrev].from.coordinates, this.edges[hiIndex].from.coordinates, this.edges[iNext].from.coordinates);

        if (disc === 0)
            { return this.edges[iPrev].from.coordinates[0] > this.edges[iNext].from.coordinates[0]; }
        return disc > 0;
    };

    /**
     * Creates a MultiPoint representing the EdgeRing (discarts edges directions).
     *
     * @memberof EdgeRing
     * @returns {Feature<MultiPoint>} - Multipoint representation of the EdgeRing
     */
    EdgeRing.prototype.toMultiPoint = function toMultiPoint () {
        return multiPoint(this.edges.map(function (edge) { return edge.from.coordinates; }));
    };

    /**
     * Creates a Polygon representing the EdgeRing.
     *
     * @memberof EdgeRing
     * @returns {Feature<Polygon>} - Polygon representation of the Edge Ring
     */
    EdgeRing.prototype.toPolygon = function toPolygon () {
        if (this.polygon)
            { return this.polygon; }
        var coordinates = this.edges.map(function (edge) { return edge.from.coordinates; });
        coordinates.push(this.edges[0].from.coordinates);
        return (this.polygon = polygon([coordinates]));
    };

    /**
     * Calculates the envelope of the EdgeRing.
     *
     * @memberof EdgeRing
     * @returns {Feature<Polygon>} - envelope
     */
    EdgeRing.prototype.getEnvelope = function getEnvelope () {
        if (this.envelope)
            { return this.envelope; }
        return (this.envelope = envelope(this.toPolygon()));
    };

    /**
     * `geos::operation::polygonize::EdgeRing::findEdgeRingContaining`
     *
     * @param {EdgeRing} testEdgeRing - EdgeRing to look in the list
     * @param {EdgeRing[]} shellList - List of EdgeRing in which to search
     *
     * @returns {EdgeRing} - EdgeRing which contains the testEdgeRing
     */
    EdgeRing.findEdgeRingContaining = function findEdgeRingContaining (testEdgeRing, shellList) {
        var testEnvelope = testEdgeRing.getEnvelope();

        var minEnvelope,
            minShell;
        shellList.forEach(function (shell) {
            var tryEnvelope = shell.getEnvelope();

            if (minShell)
                { minEnvelope = minShell.getEnvelope(); }

            // the hole envelope cannot equal the shell envelope
            if (envelopeIsEqual(tryEnvelope, testEnvelope))
                { return; }

            if (envelopeContains(tryEnvelope, testEnvelope)) {
                var testPoint = testEdgeRing.map(function (edge) { return edge.from.coordinates; })
                    .find(function (pt) { return !shell.some(function (edge) { return coordinatesEqual(pt, edge.from.coordinates); }); });

                if (testPoint && shell.inside(point(testPoint))) {
                    if (!minShell || envelopeContains(minEnvelope, tryEnvelope))
                        { minShell = shell; }
                }
            }
        });

        return minShell;
    };

    /**
     * Checks if the point is inside the edgeRing
     *
     * @param {Feature<Point>} pt - Point to check if it is inside the edgeRing
     * @returns {boolean} - True if it is inside, False otherwise
     */
    EdgeRing.prototype.inside = function inside (pt) {
        return booleanPointInPolygon(pt, this.toPolygon());
    };

    Object.defineProperties( EdgeRing.prototype, prototypeAccessors );

    /**
     * Validates the geoJson.
     *
     * @param {GeoJSON} geoJson - input geoJson.
     * @throws {Error} if geoJson is invalid.
     */
    function validateGeoJson(geoJson) {
        if (!geoJson)
            { throw new Error('No geojson passed'); }

        if (geoJson.type !== 'FeatureCollection' &&
        geoJson.type !== 'GeometryCollection' &&
        geoJson.type !== 'MultiLineString' &&
        geoJson.type !== 'LineString' &&
        geoJson.type !== 'Feature'
        )
            { throw new Error(("Invalid input type '" + (geoJson.type) + "'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")); }
    }

    /**
     * Represents a planar graph of edges and nodes that can be used to compute a polygonization.
     *
     * Although, this class is inspired by GEOS's `geos::operation::polygonize::PolygonizeGraph`,
     * it isn't a rewrite. As regards algorithm, this class implements the same logic, but it
     * isn't a javascript transcription of the C++ source.
     *
     * This graph is directed (both directions are created)
     */
    var Graph = function Graph() {
        this.edges = []; //< {Edge[]} dirEdges

        // The key is the `id` of the Node (ie: coordinates.join(','))
        this.nodes = {};
    };

    /**
     * Removes Dangle Nodes (nodes with grade 1).
     */
    Graph.fromGeoJson = function fromGeoJson (geoJson) {
        validateGeoJson(geoJson);

        var graph = new Graph();
        flattenEach(geoJson, function (feature$$1) {
            featureOf(feature$$1, 'LineString', 'Graph::fromGeoJson');
            // When a LineString if formed by many segments, split them
            coordReduce(feature$$1, function (prev, cur) {
                if (prev) {
                    var start = graph.getNode(prev),
                        end = graph.getNode(cur);

                    graph.addEdge(start, end);
                }
                return cur;
            });
        });

        return graph;
    };

    /**
     * Creates or get a Node.
     *
     * @param {number[]} coordinates - Coordinates of the node
     * @returns {Node} - The created or stored node
     */
    Graph.prototype.getNode = function getNode (coordinates) {
        var id = Node$2.buildId(coordinates);
        var node = this.nodes[id];
        if (!node)
            { node = this.nodes[id] = new Node$2(coordinates); }

        return node;
    };

    /**
     * Adds an Edge and its symetricall.
     *
     * Edges are added symetrically, i.e.: we also add its symetric
     *
     * @param {Node} from - Node which starts the Edge
     * @param {Node} to - Node which ends the Edge
     */
    Graph.prototype.addEdge = function addEdge (from, to) {
        var edge = new Edge(from, to),
            symetricEdge = edge.getSymetric();

        this.edges.push(edge);
        this.edges.push(symetricEdge);
    };

    Graph.prototype.deleteDangles = function deleteDangles () {
            var this$1 = this;

        Object.keys(this.nodes)
            .map(function (id) { return this$1.nodes[id]; })
            .forEach(function (node) { return this$1._removeIfDangle(node); });
    };

    /**
     * Check if node is dangle, if so, remove it.
     *
     * It calls itself recursively, removing a dangling node might cause another dangling node
     *
     * @param {Node} node - Node to check if it's a dangle
     */
    Graph.prototype._removeIfDangle = function _removeIfDangle (node) {
            var this$1 = this;

    // As edges are directed and symetrical, we count only innerEdges
        if (node.innerEdges.length <= 1) {
            var outerNodes = node.getOuterEdges().map(function (e) { return e.to; });
            this.removeNode(node);
            outerNodes.forEach(function (n) { return this$1._removeIfDangle(n); });
        }
    };

    /**
     * Delete cut-edges (bridge edges).
     *
     * The graph will be traversed, all the edges will be labeled according the ring
     * in which they are. (The label is a number incremented by 1). Edges with the same
     * label are cut-edges.
     */
    Graph.prototype.deleteCutEdges = function deleteCutEdges () {
            var this$1 = this;

        this._computeNextCWEdges();
        this._findLabeledEdgeRings();

        // Cut-edges (bridges) are edges where both edges have the same label
        this.edges.forEach(function (edge) {
            if (edge.label === edge.symetric.label) {
                this$1.removeEdge(edge.symetric);
                this$1.removeEdge(edge);
            }
        });
    };

    /**
     * Set the `next` property of each Edge.
     *
     * The graph will be transversed in a CW form, so, we set the next of the symetrical edge as the previous one.
     * OuterEdges are sorted CCW.
     *
     * @param {Node} [node] - If no node is passed, the function calls itself for every node in the Graph
     */
    Graph.prototype._computeNextCWEdges = function _computeNextCWEdges (node) {
            var this$1 = this;

        if (typeof node === 'undefined') {
            Object.keys(this.nodes)
                .forEach(function (id) { return this$1._computeNextCWEdges(this$1.nodes[id]); });
        } else {
            node.getOuterEdges().forEach(function (edge, i) {
                node.getOuterEdge((i === 0 ? node.getOuterEdges().length : i) - 1).symetric.next = edge;
            });
        }
    };

    /**
     * Computes the next edge pointers going CCW around the given node, for the given edgering label.
     *
     * This algorithm has the effect of converting maximal edgerings into minimal edgerings
     *
     * XXX: method literally transcribed from `geos::operation::polygonize::PolygonizeGraph::computeNextCCWEdges`,
     * could be written in a more javascript way.
     *
     * @param {Node} node - Node
     * @param {number} label - Ring's label
     */
    Graph.prototype._computeNextCCWEdges = function _computeNextCCWEdges (node, label) {
        var edges = node.getOuterEdges();
        var firstOutDE,
            prevInDE;

        for (var i = edges.length - 1; i >= 0; --i) {
            var de = edges[i],
                sym = de.symetric,
                outDE = (void 0),
                inDE = (void 0);

            if (de.label === label)
                { outDE = de; }

            if (sym.label === label)
                { inDE = sym; }

            if (!outDE || !inDE) // This edge is not in edgering
                { continue; }

            if (inDE)
                { prevInDE = inDE; }

            if (outDE) {
                if (prevInDE) {
                    prevInDE.next = outDE;
                    prevInDE = undefined;
                }

                if (!firstOutDE)
                    { firstOutDE = outDE; }
            }
        }

        if (prevInDE)
            { prevInDE.next = firstOutDE; }
    };


    /**
     * Finds rings and labels edges according to which rings are.
     *
     * The label is a number which is increased for each ring.
     *
     * @returns {Edge[]} edges that start rings
     */
    Graph.prototype._findLabeledEdgeRings = function _findLabeledEdgeRings () {
        var edgeRingStarts = [];
        var label = 0;
        this.edges.forEach(function (edge) {
            if (edge.label >= 0)
                { return; }

            edgeRingStarts.push(edge);

            var e = edge;
            do {
                e.label = label;
                e = e.next;
            } while (!edge.isEqual(e));

            label++;
        });

        return edgeRingStarts;
    };

    /**
     * Computes the EdgeRings formed by the edges in this graph.
     *
     * @returns {EdgeRing[]} - A list of all the EdgeRings in the graph.
     */
    Graph.prototype.getEdgeRings = function getEdgeRings () {
            var this$1 = this;

        this._computeNextCWEdges();

        // Clear labels
        this.edges.forEach(function (edge) {
            edge.label = undefined;
        });

        this._findLabeledEdgeRings().forEach(function (edge) {
            // convertMaximalToMinimalEdgeRings
            this$1._findIntersectionNodes(edge).forEach(function (node) {
                this$1._computeNextCCWEdges(node, edge.label);
            });
        });

        var edgeRingList = [];

        // find all edgerings
        this.edges.forEach(function (edge) {
            if (edge.ring)
                { return; }
            edgeRingList.push(this$1._findEdgeRing(edge));
        });

        return edgeRingList;
    };

    /**
     * Find all nodes in a Maxima EdgeRing which are self-intersection nodes.
     *
     * @param {Node} startEdge - Start Edge of the Ring
     * @returns {Node[]} - intersection nodes
     */
    Graph.prototype._findIntersectionNodes = function _findIntersectionNodes (startEdge) {
        var intersectionNodes = [];
        var edge = startEdge;
        var loop = function () {
            // getDegree
            var degree = 0;
            edge.from.getOuterEdges().forEach(function (e) {
                if (e.label === startEdge.label)
                    { ++degree; }
            });

            if (degree > 1)
                { intersectionNodes.push(edge.from); }

            edge = edge.next;
        };

            do {
                loop();
            } while (!startEdge.isEqual(edge));

        return intersectionNodes;
    };

    /**
     * Get the edge-ring which starts from the provided Edge.
     *
     * @param {Edge} startEdge - starting edge of the edge ring
     * @returns {EdgeRing} - EdgeRing which start Edge is the provided one.
     */
    Graph.prototype._findEdgeRing = function _findEdgeRing (startEdge) {
        var edge = startEdge;
        var edgeRing = new EdgeRing();

        do {
            edgeRing.push(edge);
            edge.ring = edgeRing;
            edge = edge.next;
        } while (!startEdge.isEqual(edge));

        return edgeRing;
    };

    /**
     * Removes a node from the Graph.
     *
     * It also removes edges asociated to that node
     * @param {Node} node - Node to be removed
     */
    Graph.prototype.removeNode = function removeNode (node) {
            var this$1 = this;

        node.getOuterEdges().forEach(function (edge) { return this$1.removeEdge(edge); });
        node.innerEdges.forEach(function (edge) { return this$1.removeEdge(edge); });
        delete this.nodes[node.id];
    };

    /**
     * Remove edge from the graph and deletes the edge.
     *
     * @param {Edge} edge - Edge to be removed
     */
    Graph.prototype.removeEdge = function removeEdge (edge) {
        this.edges = this.edges.filter(function (e) { return !e.isEqual(edge); });
        edge.deleteEdge();
    };

    /**
     * Polygonizes {@link LineString|(Multi)LineString(s)} into {@link Polygons}.
     *
     * Implementation of GEOSPolygonize function (`geos::operation::polygonize::Polygonizer`).
     *
     * Polygonizes a set of lines that represents edges in a planar graph. Edges must be correctly
     * noded, i.e., they must only meet at their endpoints.
     *
     * The implementation correctly handles:
     *
     * - Dangles: edges which have one or both ends which are not incident on another edge endpoint.
     * - Cut Edges (bridges): edges that are connected at both ends but which do not form part of a polygon.
     *
     * @name polygonize
     * @param {FeatureCollection|Geometry|Feature<LineString|MultiLineString>} geoJson Lines in order to polygonize
     * @returns {FeatureCollection<Polygon>} Polygons created
     * @throws {Error} if geoJson is invalid.
     */
    function polygonize(geoJson) {
        var graph = Graph.fromGeoJson(geoJson);

        // 1. Remove dangle node
        graph.deleteDangles();

        // 2. Remove cut-edges (bridge edges)
        graph.deleteCutEdges();

        // 3. Get all holes and shells
        var holes = [],
            shells = [];

        graph.getEdgeRings()
            .filter(function (edgeRing) { return edgeRing.isValid(); })
            .forEach(function (edgeRing) {
                if (edgeRing.isHole())
                    { holes.push(edgeRing); }
                else
                    { shells.push(edgeRing); }
            });

        // 4. Assign Holes to Shells
        holes.forEach(function (hole) {
            if (EdgeRing.findEdgeRingContaining(hole, shells))
                { shells.push(hole); }
        });

        // 5. EdgeRings to Polygons
        return featureCollection(shells.map(function (shell) { return shell.toPolygon(); }));
    }

    /**
     * Boolean-disjoint returns (TRUE) if the intersection of the two geometries is an empty set.
     *
     * @name booleanDisjoint
     * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false
     * @example
     * var point = turf.point([2, 2]);
     * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
     *
     * turf.booleanDisjoint(line, point);
     * //=true
     */
    function booleanDisjoint(feature1, feature2) {
        let bool = true;
        flattenEach(feature1, (flatten1) => {
            flattenEach(feature2, (flatten2) => {
                if (bool === false) { return false; }
                bool = disjoint(flatten1.geometry, flatten2.geometry);
            });
        });
        return bool;
    }

    /**
     * Disjoint operation for simple Geometries (Point/LineString/Polygon)
     *
     * @private
     * @param {Geometry<any>} geom1 GeoJSON Geometry
     * @param {Geometry<any>} geom2 GeoJSON Geometry
     * @returns {boolean} true/false
     */
    function disjoint(geom1, geom2) {
        switch (geom1.type) {
        case 'Point':
            switch (geom2.type) {
            case 'Point':
                return !compareCoords$1(geom1.coordinates, geom2.coordinates);
            case 'LineString':
                return !isPointOnLine(geom2, geom1);
            case 'Polygon':
                return !booleanPointInPolygon(geom1, geom2);
            }
            /* istanbul ignore next */
            break;
        case 'LineString':
            switch (geom2.type) {
            case 'Point':
                return !isPointOnLine(geom1, geom2);
            case 'LineString':
                return !isLineOnLine$1(geom1, geom2);
            case 'Polygon':
                return !isLineInPoly$1(geom2, geom1);
            }
            /* istanbul ignore next */
            break;
        case 'Polygon':
            switch (geom2.type) {
            case 'Point':
                return !booleanPointInPolygon(geom2, geom1);
            case 'LineString':
                return !isLineInPoly$1(geom1, geom2);
            case 'Polygon':
                return !isPolyInPoly$1(geom2, geom1);
            }
        }
        return false;
    }

    // http://stackoverflow.com/a/11908158/1979085
    function isPointOnLine(lineString, pt) {
        for (let i = 0; i < lineString.coordinates.length - 1; i++) {
            if (isPointOnLineSegment$2(lineString.coordinates[i], lineString.coordinates[i + 1], pt.coordinates)) {
                return true;
            }
        }
        return false;
    }

    function isLineOnLine$1(lineString1, lineString2) {
        const doLinesIntersect = lineIntersect(lineString1, lineString2);
        if (doLinesIntersect.features.length > 0) {
            return true;
        }
        return false;
    }

    function isLineInPoly$1(polygon, lineString) {
        for (const coord of lineString.coordinates) {
            if (booleanPointInPolygon(coord, polygon)) {
                return true;
            }
        }
        const doLinesIntersect = lineIntersect(lineString, polygonToLine(polygon));
        if (doLinesIntersect.features.length > 0) {
            return true;
        }
        return false;
    }

    /**
     * Is Polygon (geom1) in Polygon (geom2)
     * Only takes into account outer rings
     * See http://stackoverflow.com/a/4833823/1979085
     *
     * @private
     * @param {Geometry|Feature<Polygon>} feature1 Polygon1
     * @param {Geometry|Feature<Polygon>} feature2 Polygon2
     * @returns {boolean} true/false
     */
    function isPolyInPoly$1(feature1, feature2) {
        for (const coord1 of feature1.coordinates[0]) {
            if (booleanPointInPolygon(coord1, feature2)) {
                return true;
            }
        }
        for (const coord2 of feature2.coordinates[0]) {
            if (booleanPointInPolygon(coord2, feature1)) {
                return true;
            }
        }
        const doLinesIntersect = lineIntersect(polygonToLine(feature1), polygonToLine(feature2));
        if (doLinesIntersect.features.length > 0) {
            return true;
        }
        return false;
    }

    function isPointOnLineSegment$2(lineSegmentStart, lineSegmentEnd, pt) {
        const dxc = pt[0] - lineSegmentStart[0];
        const dyc = pt[1] - lineSegmentStart[1];
        const dxl = lineSegmentEnd[0] - lineSegmentStart[0];
        const dyl = lineSegmentEnd[1] - lineSegmentStart[1];
        const cross = dxc * dyl - dyc * dxl;
        if (cross !== 0) {
            return false;
        }
        if (Math.abs(dxl) >= Math.abs(dyl)) {
            if (dxl > 0) {
                return lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0];
            } else {
                return lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];
            }
        } else if (dyl > 0) {
            return lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1];
        } else {
            return lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
        }
    }

    /**
     * compareCoords
     *
     * @private
     * @param {Position} pair1 point [x,y]
     * @param {Position} pair2 point [x,y]
     * @returns {boolean} true/false if coord pairs match
     */
    function compareCoords$1(pair1, pair2) {
        return pair1[0] === pair2[0] && pair1[1] === pair2[1];
    }

    /**
     * Boolean-contains returns True if the second geometry is completely contained by the first geometry.
     * The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b)
     * must not intersect the exterior of the primary (geometry a).
     * Boolean-contains returns the exact opposite result of the `@turf/boolean-within`.
     *
     * @name booleanContains
     * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false
     * @example
     * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
     * var point = turf.point([1, 2]);
     *
     * turf.booleanContains(line, point);
     * //=true
     */
    function booleanContains(feature1, feature2) {
        const geom1 = getGeom(feature1);
        const geom2 = getGeom(feature2);
        const type1 = geom1.type;
        const type2 = geom2.type;
        const coords1 = geom1.coordinates;
        const coords2 = geom2.coordinates;

        switch (type1) {
        case "Point":
            switch (type2) {
            case "Point":
                return compareCoords$2(coords1, coords2);
            default:
                throw new Error("feature2 " + type2 + " geometry not supported");
            }
        case "MultiPoint":
            switch (type2) {
            case "Point":
                return isPointInMultiPoint$1(geom1, geom2);
            case "MultiPoint":
                return isMultiPointInMultiPoint$1(geom1, geom2);
            default:
                throw new Error("feature2 " + type2 + " geometry not supported");
            }
        case "LineString":
            switch (type2) {
            case "Point":
                return booleanPointOnLine(geom2, geom1, {ignoreEndVertices: true});
            case "LineString":
                return isLineOnLine$2(geom1, geom2);
            case "MultiPoint":
                return isMultiPointOnLine$1(geom1, geom2);
            default:
                throw new Error("feature2 " + type2 + " geometry not supported");
            }
        case "Polygon":
            switch (type2) {
            case "Point":
                return booleanPointInPolygon(geom2, geom1, {ignoreBoundary: true});
            case "LineString":
                return isLineInPoly$2(geom1, geom2);
            case "Polygon":
                return isPolyInPoly$2(geom1, geom2);
            case "MultiPoint":
                return isMultiPointInPoly$1(geom1, geom2);
            default:
                throw new Error("feature2 " + type2 + " geometry not supported");
            }
        default:
            throw new Error("feature1 " + type1 + " geometry not supported");
        }
    }

    function isPointInMultiPoint$1(multiPoint$$1, pt) {
        let i;
        let output = false;
        for (i = 0; i < multiPoint$$1.coordinates.length; i++) {
            if (compareCoords$2(multiPoint$$1.coordinates[i], pt.coordinates)) {
                output = true;
                break;
            }
        }
        return output;
    }

    function isMultiPointInMultiPoint$1(multiPoint1, multiPoint2) {
        for (const coord2 of multiPoint2.coordinates) {
            let matchFound = false;
            for (const coord1 of multiPoint1.coordinates) {
                if (compareCoords$2(coord2, coord1)) {
                    matchFound = true;
                    break;
                }
            }
            if (!matchFound) {
                return false;
            }
        }
        return true;
    }

    function isMultiPointOnLine$1(lineString$$1, multiPoint$$1) {
        let haveFoundInteriorPoint = false;
        for (const coord of multiPoint$$1.coordinates) {
            if (booleanPointOnLine(coord, lineString$$1, {ignoreEndVertices: true})) {
                haveFoundInteriorPoint = true;
            }
            if (!booleanPointOnLine(coord, lineString$$1)) {
                return false;
            }
        }
        if (haveFoundInteriorPoint) {
            return true;
        }
        return false;
    }

    function isMultiPointInPoly$1(polygon$$1, multiPoint$$1) {
        for (const coord of multiPoint$$1.coordinates) {
            if (!booleanPointInPolygon(coord, polygon$$1, {ignoreBoundary: true})) {
                return false;
            }
        }
        return true;
    }

    function isLineOnLine$2(lineString1, lineString2) {
        let haveFoundInteriorPoint = false;
        for (const coords of lineString2.coordinates) {
            if (booleanPointOnLine({type: 'Point', coordinates: coords}, lineString1, { ignoreEndVertices: true })) {
                haveFoundInteriorPoint = true;
            }
            if (!booleanPointOnLine({type: 'Point', coordinates: coords}, lineString1, {ignoreEndVertices: false })) {
                return false;
            }
        }
        return haveFoundInteriorPoint;
    }

    function isLineInPoly$2(polygon$$1, linestring) {
        let i = 0;

        let pointInside = false;
        let pointOutside = false;

        const polyBbox = bbox(polygon$$1);
        const lineBbox = bbox(linestring);
        if (!doBBoxOverlap$1(polyBbox, lineBbox)) {
            return false;
        }
        for (i; i < linestring.coordinates.length; i++) {
            if (!booleanPointInPolygon({type: 'Point', coordinates: linestring.coordinates[i]}, polygon$$1, { ignoreBoundary: false })) {
                pointOutside = true;
                break;
            }
            if (!pointInside) {
                if (booleanPointInPolygon({type: 'Point', coordinates: linestring.coordinates[i]}, polygon$$1, { ignoreBoundary: true })) {
                    pointInside = true;
                }
                if (!pointInside && i < linestring.coordinates.length - 1) {
                    const midPoint = getMidpoint$1(linestring.coordinates[i], linestring.coordinates[i + 1]);
                    if (booleanPointInPolygon({type: "Point", coordinates: midPoint}, polygon$$1, { ignoreBoundary: true })) {
                        pointInside = true;
                    }
                }
            }
        }
        if (pointOutside) return false;
        return pointInside;
    }

    /**
     * Is Polygon2 in Polygon1
     * Only takes into account outer rings
     *
     * @private
     * @param {Geometry|Feature<Polygon>} feature1 Polygon1
     * @param {Geometry|Feature<Polygon>} feature2 Polygon2
     * @returns {boolean} true/false
     */
    function isPolyInPoly$2(feature1, feature2) {
        // Handle Nulls
        if (feature1.type === "Feature" && feature1.geometry === null) { return false; }
        if (feature2.type === "Feature" && feature2.geometry === null) { return false; }

        const poly1Bbox = bbox(feature1);
        const poly2Bbox = bbox(feature2);
        if (!doBBoxOverlap$1(poly1Bbox, poly2Bbox)) {
            return false;
        }

        const coords = getGeom(feature2).coordinates;
        for (const ring of coords) {
            for (const coord of ring) {
                if (!booleanPointInPolygon(coord, feature1)) {
                    return false;
                }
            }
        }
        return true;
    }

    function doBBoxOverlap$1(bbox1, bbox2) {
        if (bbox1[0] > bbox2[0]) { return false; }
        if (bbox1[2] < bbox2[2]) { return false; }
        if (bbox1[1] > bbox2[1]) { return false; }
        if (bbox1[3] < bbox2[3]) { return false; }
        return true;
    }

    /**
     * compareCoords
     *
     * @private
     * @param {Position} pair1 point [x,y]
     * @param {Position} pair2 point [x,y]
     * @returns {boolean} true/false if coord pairs match
     */
    function compareCoords$2(pair1, pair2) {
        return pair1[0] === pair2[0] && pair1[1] === pair2[1];
    }

    function getMidpoint$1(pair1, pair2) {
        return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2];
    }

    /**
     * Boolean-Crosses returns True if the intersection results in a geometry whose dimension is one less than
     * the maximum dimension of the two source geometries and the intersection set is interior to
     * both source geometries.
     *
     * Boolean-Crosses returns t (TRUE) for only multipoint/polygon, multipoint/linestring, linestring/linestring, linestring/polygon, and linestring/multipolygon comparisons.
     *
     * @name booleanCrosses
     * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false
     * @example
     * var line1 = turf.lineString([[-2, 2], [4, 2]]);
     * var line2 = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
     *
     * var cross = turf.booleanCrosses(line1, line2);
     * //=true
     */
    function booleanCrosses(feature1, feature2) {
        var geom1 = getGeom(feature1);
        var geom2 = getGeom(feature2);
        var type1 = geom1.type;
        var type2 = geom2.type;

        switch (type1) {
        case 'MultiPoint':
            switch (type2) {
            case 'LineString':
                return doMultiPointAndLineStringCross(geom1, geom2);
            case 'Polygon':
                return doesMultiPointCrossPoly(geom1, geom2);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        case 'LineString':
            switch (type2) {
            case 'MultiPoint': // An inverse operation
                return doMultiPointAndLineStringCross(geom2, geom1);
            case 'LineString':
                return doLineStringsCross(geom1, geom2);
            case 'Polygon':
                return doLineStringAndPolygonCross(geom1, geom2);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        case 'Polygon':
            switch (type2) {
            case 'MultiPoint': // An inverse operation
                return doesMultiPointCrossPoly(geom2, geom1);
            case 'LineString': // An inverse operation
                return doLineStringAndPolygonCross(geom2, geom1);
            default:
                throw new Error('feature2 ' + type2 + ' geometry not supported');
            }
        default:
            throw new Error('feature1 ' + type1 + ' geometry not supported');
        }
    }

    function doMultiPointAndLineStringCross(multiPoint$$1, lineString$$1) {
        var foundIntPoint = false;
        var foundExtPoint = false;
        var pointLength = multiPoint$$1.coordinates.length;
        var i = 0;
        while (i < pointLength && !foundIntPoint && !foundExtPoint) {
            for (var i2 = 0; i2 < lineString$$1.coordinates.length - 1; i2++) {
                var incEndVertices = true;
                if (i2 === 0 || i2 === lineString$$1.coordinates.length - 2) {
                    incEndVertices = false;
                }
                if (isPointOnLineSegment$3(lineString$$1.coordinates[i2], lineString$$1.coordinates[i2 + 1], multiPoint$$1.coordinates[i], incEndVertices)) {
                    foundIntPoint = true;
                } else {
                    foundExtPoint = true;
                }
            }
            i++;
        }
        return foundIntPoint && foundExtPoint;
    }

    function doLineStringsCross(lineString1, lineString2) {
        const intersections = lineIntersect(lineString1, lineString2);

        const endpoints = [
            lineString1.coordinates[0], lineString1.coordinates[lineString1.coordinates.length - 1],
            lineString2.coordinates[0], lineString2.coordinates[lineString2.coordinates.length - 1]
        ];

        // A line that touches another line should not cross
        const hasAnIntersectionWithoutEndpoints = intersections.features.some(function (feature$$1) {
            return !endpoints.some(compareCoords$3.bind(this, feature$$1.geometry.coordinates));
        });

        return hasAnIntersectionWithoutEndpoints;
    }

    function doLineStringAndPolygonCross(lineString$$1, polygon$$1) {
        const line = polygonToLine$1(polygon$$1);
        const doLinesIntersect = lineIntersect(lineString$$1, line);
        if (doLinesIntersect.features.length > 0) {
            return true;
        }
        return false;
    }

    function doesMultiPointCrossPoly(multiPoint$$1, polygon$$1) {
        var foundIntPoint = false;
        var foundExtPoint = false;
        var pointLength = multiPoint$$1.coordinates[0].length;
        var i = 0;
        while (i < pointLength && foundIntPoint && foundExtPoint) {
            if (booleanPointInPolygon(point(multiPoint$$1.coordinates[0][i]), polygon$$1)) {
                foundIntPoint = true;
            } else {
                foundExtPoint = true;
            }
            i++;
        }

        return foundExtPoint && foundExtPoint;
    }

    /**
     * Is a point on a line segment
     * Only takes into account outer rings
     * See http://stackoverflow.com/a/4833823/1979085
     *
     * @private
     * @param {number[]} lineSegmentStart coord pair of start of line
     * @param {number[]} lineSegmentEnd coord pair of end of line
     * @param {number[]} pt coord pair of point to check
     * @param {boolean} incEnd whether the point is allowed to fall on the line ends
     * @returns {boolean} true/false
     */
    function isPointOnLineSegment$3(lineSegmentStart, lineSegmentEnd, pt, incEnd) {
        var dxc = pt[0] - lineSegmentStart[0];
        var dyc = pt[1] - lineSegmentStart[1];
        var dxl = lineSegmentEnd[0] - lineSegmentStart[0];
        var dyl = lineSegmentEnd[1] - lineSegmentStart[1];
        var cross = dxc * dyl - dyc * dxl;
        if (cross !== 0) {
            return false;
        }
        if (incEnd) {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? lineSegmentStart[0] <= pt[0] && pt[0] <= lineSegmentEnd[0] : lineSegmentEnd[0] <= pt[0] && pt[0] <= lineSegmentStart[0];
            }
            return dyl > 0 ? lineSegmentStart[1] <= pt[1] && pt[1] <= lineSegmentEnd[1] : lineSegmentEnd[1] <= pt[1] && pt[1] <= lineSegmentStart[1];
        } else {
            if (Math.abs(dxl) >= Math.abs(dyl)) {
                return dxl > 0 ? lineSegmentStart[0] < pt[0] && pt[0] < lineSegmentEnd[0] : lineSegmentEnd[0] < pt[0] && pt[0] < lineSegmentStart[0];
            }
            return dyl > 0 ? lineSegmentStart[1] < pt[1] && pt[1] < lineSegmentEnd[1] : lineSegmentEnd[1] < pt[1] && pt[1] < lineSegmentStart[1];
        }
    }

    /**
     * compareCoords
     *
     * @private
     * @param {Position} pair1 point [x,y]
     * @param {Position} pair2 point [x,y]
     * @returns {boolean} true/false if coord pairs match
     */
    function compareCoords$3(pair1, pair2) {
        return pair1[0] === pair2[0] && pair1[1] === pair2[1];
    }

    //index.js


    var Equality = function(opt) {
      this.precision = opt && opt.precision ? opt.precision : 17;
      this.direction = opt && opt.direction ? opt.direction : false;
      this.pseudoNode = opt && opt.pseudoNode ? opt.pseudoNode : false;
      this.objectComparator = opt && opt.objectComparator ? opt.objectComparator : objectComparator;
    };

    Equality.prototype.compare = function(g1,g2) {
      if (g1.type !== g2.type || !sameLength(g1,g2)) return false;

      switch(g1.type) {
      case 'Point':
        return this.compareCoord(g1.coordinates, g2.coordinates);
        break;
      case 'LineString':
        return this.compareLine(g1.coordinates, g2.coordinates,0,false);
        break;
      case 'Polygon':
        return this.comparePolygon(g1,g2);
        break;
      case 'GeometryCollection':
        return this.compareGeometryCollection(g1, g2);
      case 'Feature':
        return this.compareFeature(g1, g2);
      case 'FeatureCollection':
        return this.compareFeatureCollection(g1, g2);
      default:
        if (g1.type.indexOf('Multi') === 0) {
          var context = this;
          var g1s = explode$1(g1);
          var g2s = explode$1(g2);
          return g1s.every(function(g1part) {
            return this.some(function(g2part) {
              return context.compare(g1part,g2part);
            });
          },g2s);
        }
      }
      return false;
    };

    function explode$1(g) {
      return g.coordinates.map(function(part) {
        return {
          type: g.type.replace('Multi', ''),
          coordinates: part}
      });
    }
    //compare length of coordinates/array
    function sameLength(g1,g2) {
       return g1.hasOwnProperty('coordinates') ?
        g1.coordinates.length === g2.coordinates.length
        : g1.length === g2.length;
    }

    // compare the two coordinates [x,y]
    Equality.prototype.compareCoord = function(c1,c2) {
      if (c1.length !== c2.length) {
        return false;
      }

      for (var i=0; i < c1.length; i++) {
        if (c1[i].toFixed(this.precision) !== c2[i].toFixed(this.precision)) {
          return false;
        }
      }
      return true;
    };

    Equality.prototype.compareLine = function(path1,path2,ind,isPoly) {
      if (!sameLength(path1,path2)) return false;
      var p1 = this.pseudoNode ? path1 : this.removePseudo(path1);
      var p2 = this.pseudoNode ? path2 : this.removePseudo(path2);
      if (isPoly && !this.compareCoord(p1[0],p2[0])) {
        // fix start index of both to same point
        p2 = this.fixStartIndex(p2,p1);
        if(!p2) return;
      }
      // for linestring ind =0 and for polygon ind =1
      var sameDirection = this.compareCoord(p1[ind],p2[ind]);
      if (this.direction || sameDirection
      ) {
        return this.comparePath(p1, p2);
      } else {
        if (this.compareCoord(p1[ind],p2[p2.length - (1+ind)])
        ) {
          return this.comparePath(p1.slice().reverse(), p2);
        }
        return false;
      }
    };
    Equality.prototype.fixStartIndex = function(sourcePath,targetPath) {
      //make sourcePath first point same as of targetPath
      var correctPath,ind = -1;
      for (var i=0; i< sourcePath.length; i++) {
        if(this.compareCoord(sourcePath[i],targetPath[0])) {
          ind = i;
          break;
        }
      }
      if (ind >= 0) {
        correctPath = [].concat(
          sourcePath.slice(ind,sourcePath.length),
          sourcePath.slice(1,ind+1));
      }
      return correctPath;
    };
    Equality.prototype.comparePath = function (p1,p2) {
      var cont = this;
      return p1.every(function(c,i) {
        return cont.compareCoord(c,this[i]);
      },p2);
    };

    Equality.prototype.comparePolygon = function(g1,g2) {
      if (this.compareLine(g1.coordinates[0],g2.coordinates[0],1,true)) {
        var holes1 = g1.coordinates.slice(1,g1.coordinates.length);
        var holes2 = g2.coordinates.slice(1,g2.coordinates.length);
        var cont = this;
        return holes1.every(function(h1) {
          return this.some(function(h2) {
            return cont.compareLine(h1,h2,1,true);
          });
        },holes2);
      } else {
        return false;
      }
    };

    Equality.prototype.compareGeometryCollection= function(g1,g2) {
      if (
        !sameLength(g1.geometries, g2.geometries) ||
        !this.compareBBox(g1,g2)
      ) {
        return false;
      }
      for (var i=0; i < g1.geometries.length; i++) {
        if (!this.compare(g1.geometries[i], g2.geometries[i])) {
          return false;
        }
      }
      return true
    };

    Equality.prototype.compareFeature = function(g1,g2) {
      if (
        g1.id !== g2.id ||
        !this.objectComparator(g1.properties, g2.properties) ||
        !this.compareBBox(g1,g2)
      ) {
        return false;
      }
      return this.compare(g1.geometry, g2.geometry);
    };

    Equality.prototype.compareFeatureCollection = function(g1,g2) {
      if (
        !sameLength(g1.features, g2.features) ||
        !this.compareBBox(g1,g2)
      ) {
        return false;
      }
      for (var i=0; i < g1.features.length; i++) {
        if (!this.compare(g1.features[i], g2.features[i])) {
          return false;
        }
      }
      return true
    };

    Equality.prototype.compareBBox = function(g1,g2) {
      if (
        (!g1.bbox && !g2.bbox) || 
        (
          g1.bbox && g2.bbox &&
          this.compareCoord(g1.bbox, g2.bbox)
        )
      )  {
        return true;
      }
      return false;
    };
    Equality.prototype.removePseudo = function(path) {
      //TODO to be implement
      return path;
    };

    function objectComparator(obj1, obj2) {
      return deepEqual_1(obj1, obj2, {strict: true});
    }

    var geojsonEquality = Equality;

    const GeoEquality = geojsonEquality;

    /**
     * Compares two geometries of the same dimension and returns true if their intersection set results in a geometry
     * different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString,
     * Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.
     *
     * @name booleanOverlap
     * @param  {Geometry|Feature<LineString|MultiLineString|Polygon|MultiPolygon>} feature1 input
     * @param  {Geometry|Feature<LineString|MultiLineString|Polygon|MultiPolygon>} feature2 input
     * @returns {boolean} true/false
     * @example
     * var poly1 = turf.polygon([[[0,0],[0,5],[5,5],[5,0],[0,0]]]);
     * var poly2 = turf.polygon([[[1,1],[1,6],[6,6],[6,1],[1,1]]]);
     * var poly3 = turf.polygon([[[10,10],[10,15],[15,15],[15,10],[10,10]]]);
     *
     * turf.booleanOverlap(poly1, poly2)
     * //=true
     * turf.booleanOverlap(poly2, poly3)
     * //=false
     */
    function booleanOverlap(feature1, feature2) {
        const geom1 = getGeom(feature1);
        const geom2 = getGeom(feature2);
        const type1 = geom1.type;
        const type2 = geom2.type;

        if (type1 === 'Point') throw new Error('Point geometry not supported');
        // features must be not equal
        const equality = new GeoEquality({precision: 6});
        if (equality.compare(feature1, feature2)) return false;

        let overlap = 0;

        switch (type1) {
        case 'MultiPoint': //eslint-disable-line
            const coords1 = coordAll(feature1);
            const coords2 = coordAll(feature2);
            coords1.forEach((coord1) => {
                coords2.forEach((coord2) => {
                    if (coord1[0] === coord2[0] && coord1[1] === coord2[1]) overlap++;
                });
            });
            break;

        case 'LineString':
        case 'MultiLineString':
            segmentEach(feature1, (segment1) => {
                segmentEach(feature2, (segment2) => {
                    if (lineOverlap(segment1, segment2).features.length) overlap++;
                });
            });
            break;

        case 'Polygon':
        case 'MultiPolygon':
            segmentEach(feature1, (segment1) => {
                segmentEach(feature2, (segment2) => {
                    if (lineIntersect(segment1, segment2).features.length) overlap++;
                });
            });
            break;
        }

        return overlap > 0;
    }

    const GeoEquality$1 = geojsonEquality;

    /**
     * Determine whether two geometries of the same type have identical X,Y coordinate values.
     * See http://edndoc.esri.com/arcsde/9.0/general_topics/understand_spatial_relations.htm
     *
     * @name booleanEqual
     * @param {Geometry|Feature} feature1 GeoJSON input
     * @param {Geometry|Feature} feature2 GeoJSON input
     * @returns {boolean} true if the objects are equal, false otherwise
     * @example
     * var pt1 = turf.point([0, 0]);
     * var pt2 = turf.point([0, 0]);
     * var pt3 = turf.point([1, 1]);
     *
     * turf.booleanEqual(pt1, pt2);
     * //= true
     * turf.booleanEqual(pt2, pt3);
     * //= false
     */
    function booleanEqual(feature1, feature2) {
        const type1 = getGeom(feature1).type;
        const type2 = getGeom(feature2).type;
        if (type1 !== type2) return false;

        const equality = new GeoEquality$1({precision: 6});
        return equality.compare(cleanCoords(feature1), cleanCoords(feature2));
    }

    var DBSCAN_1 = createCommonjsModule(function (module) {
    /**
     * DBSCAN - Density based clustering
     *
     * @author Lukasz Krawczyk <contact@lukaszkrawczyk.eu>
     * @copyright MIT
     */

    /**
     * DBSCAN class construcotr
     * @constructor
     *
     * @param {Array} dataset
     * @param {number} epsilon
     * @param {number} minPts
     * @param {function} distanceFunction
     * @returns {DBSCAN}
     */
    function DBSCAN(dataset, epsilon, minPts, distanceFunction) {
      /** @type {Array} */
      this.dataset = [];
      /** @type {number} */
      this.epsilon = 1;
      /** @type {number} */
      this.minPts = 2;
      /** @type {function} */
      this.distance = this._euclideanDistance;
      /** @type {Array} */
      this.clusters = [];
      /** @type {Array} */
      this.noise = [];

      // temporary variables used during computation

      /** @type {Array} */
      this._visited = [];
      /** @type {Array} */
      this._assigned = [];
      /** @type {number} */
      this._datasetLength = 0;

      this._init(dataset, epsilon, minPts, distanceFunction);
    }
    /******************************************************************************/
    // public functions

    /**
     * Start clustering
     *
     * @param {Array} dataset
     * @param {number} epsilon
     * @param {number} minPts
     * @param {function} distanceFunction
     * @returns {undefined}
     * @access public
     */
    DBSCAN.prototype.run = function(dataset, epsilon, minPts, distanceFunction) {
      this._init(dataset, epsilon, minPts, distanceFunction);

      for (var pointId = 0; pointId < this._datasetLength; pointId++) {
        // if point is not visited, check if it forms a cluster
        if (this._visited[pointId] !== 1) {
          this._visited[pointId] = 1;

          // if closest neighborhood is too small to form a cluster, mark as noise
          var neighbors = this._regionQuery(pointId);

          if (neighbors.length < this.minPts) {
            this.noise.push(pointId);
          } else {
            // create new cluster and add point
            var clusterId = this.clusters.length;
            this.clusters.push([]);
            this._addToCluster(pointId, clusterId);

            this._expandCluster(clusterId, neighbors);
          }
        }
      }

      return this.clusters;
    };

    /******************************************************************************/
    // protected functions

    /**
     * Set object properties
     *
     * @param {Array} dataset
     * @param {number} epsilon
     * @param {number} minPts
     * @param {function} distance
     * @returns {undefined}
     * @access protected
     */
    DBSCAN.prototype._init = function(dataset, epsilon, minPts, distance) {

      if (dataset) {

        if (!(dataset instanceof Array)) {
          throw Error('Dataset must be of type array, ' +
            typeof dataset + ' given');
        }

        this.dataset = dataset;
        this.clusters = [];
        this.noise = [];

        this._datasetLength = dataset.length;
        this._visited = new Array(this._datasetLength);
        this._assigned = new Array(this._datasetLength);
      }

      if (epsilon) {
        this.epsilon = epsilon;
      }

      if (minPts) {
        this.minPts = minPts;
      }

      if (distance) {
        this.distance = distance;
      }
    };

    /**
     * Expand cluster to closest points of given neighborhood
     *
     * @param {number} clusterId
     * @param {Array} neighbors
     * @returns {undefined}
     * @access protected
     */
    DBSCAN.prototype._expandCluster = function(clusterId, neighbors) {

      /**
       * It's very important to calculate length of neighbors array each time,
       * as the number of elements changes over time
       */
      for (var i = 0; i < neighbors.length; i++) {
        var pointId2 = neighbors[i];

        if (this._visited[pointId2] !== 1) {
          this._visited[pointId2] = 1;
          var neighbors2 = this._regionQuery(pointId2);

          if (neighbors2.length >= this.minPts) {
            neighbors = this._mergeArrays(neighbors, neighbors2);
          }
        }

        // add to cluster
        if (this._assigned[pointId2] !== 1) {
          this._addToCluster(pointId2, clusterId);
        }
      }
    };

    /**
     * Add new point to cluster
     *
     * @param {number} pointId
     * @param {number} clusterId
     */
    DBSCAN.prototype._addToCluster = function(pointId, clusterId) {
      this.clusters[clusterId].push(pointId);
      this._assigned[pointId] = 1;
    };

    /**
     * Find all neighbors around given point
     *
     * @param {number} pointId,
     * @param {number} epsilon
     * @returns {Array}
     * @access protected
     */
    DBSCAN.prototype._regionQuery = function(pointId) {
      var neighbors = [];

      for (var id = 0; id < this._datasetLength; id++) {
        var dist = this.distance(this.dataset[pointId], this.dataset[id]);
        if (dist < this.epsilon) {
          neighbors.push(id);
        }
      }

      return neighbors;
    };

    /******************************************************************************/
    // helpers

    /**
     * @param {Array} a
     * @param {Array} b
     * @returns {Array}
     * @access protected
     */
    DBSCAN.prototype._mergeArrays = function(a, b) {
      var len = b.length;

      for (var i = 0; i < len; i++) {
        var P = b[i];
        if (a.indexOf(P) < 0) {
          a.push(P);
        }
      }

      return a;
    };

    /**
     * Calculate euclidean distance in multidimensional space
     *
     * @param {Array} p
     * @param {Array} q
     * @returns {number}
     * @access protected
     */
    DBSCAN.prototype._euclideanDistance = function(p, q) {
      var sum = 0;
      var i = Math.min(p.length, q.length);

      while (i--) {
        sum += (p[i] - q[i]) * (p[i] - q[i]);
      }

      return Math.sqrt(sum);
    };

    if (module.exports) {
      module.exports = DBSCAN;
    }
    });

    var DBSCAN = /*#__PURE__*/Object.freeze({
        default: DBSCAN_1,
        __moduleExports: DBSCAN_1
    });

    var KMEANS_1 = createCommonjsModule(function (module) {
    /**
     * KMEANS clustering
     *
     * @author Lukasz Krawczyk <contact@lukaszkrawczyk.eu>
     * @copyright MIT
     */

    /**
     * KMEANS class constructor
     * @constructor
     *
     * @param {Array} dataset
     * @param {number} k - number of clusters
     * @param {function} distance - distance function
     * @returns {KMEANS}
     */
     function KMEANS(dataset, k, distance) {
      this.k = 3; // number of clusters
      this.dataset = []; // set of feature vectors
      this.assignments = []; // set of associated clusters for each feature vector
      this.centroids = []; // vectors for our clusters

      this.init(dataset, k, distance);
    }

    /**
     * @returns {undefined}
     */
    KMEANS.prototype.init = function(dataset, k, distance) {
      this.assignments = [];
      this.centroids = [];

      if (typeof dataset !== 'undefined') {
        this.dataset = dataset;
      }

      if (typeof k !== 'undefined') {
        this.k = k;
      }

      if (typeof distance !== 'undefined') {
        this.distance = distance;
      }
    };

    /**
     * @returns {undefined}
     */
    KMEANS.prototype.run = function(dataset, k) {
      this.init(dataset, k);

      var len = this.dataset.length;

      // initialize centroids
      for (var i = 0; i < this.k; i++) {
        this.centroids[i] = this.randomCentroid();
    	}

      var change = true;
      while(change) {

        // assign feature vectors to clusters
        change = this.assign();

        // adjust location of centroids
        for (var centroidId = 0; centroidId < this.k; centroidId++) {
          var mean = new Array(maxDim);
          var count = 0;

          // init mean vector
          for (var dim = 0; dim < maxDim; dim++) {
            mean[dim] = 0;
          }

          for (var j = 0; j < len; j++) {
            var maxDim = this.dataset[j].length;

            // if current cluster id is assigned to point
            if (centroidId === this.assignments[j]) {
              for (var dim = 0; dim < maxDim; dim++) {
                mean[dim] += this.dataset[j][dim];
              }
              count++;
            }
          }

          if (count > 0) {
            // if cluster contain points, adjust centroid position
            for (var dim = 0; dim < maxDim; dim++) {
              mean[dim] /= count;
            }
            this.centroids[centroidId] = mean;
          } else {
            // if cluster is empty, generate new random centroid
            this.centroids[centroidId] = this.randomCentroid();
            change = true;
          }
        }
      }

      return this.getClusters();
    };

    /**
     * Generate random centroid
     *
     * @returns {Array}
     */
    KMEANS.prototype.randomCentroid = function() {
      var maxId = this.dataset.length -1;
      var centroid;
      var id;

      do {
        id = Math.round(Math.random() * maxId);
        centroid = this.dataset[id];
      } while (this.centroids.indexOf(centroid) >= 0);

      return centroid;
    };

    /**
     * Assign points to clusters
     *
     * @returns {boolean}
     */
    KMEANS.prototype.assign = function() {
      var change = false;
      var len = this.dataset.length;
      var closestCentroid;

      for (var i = 0; i < len; i++) {
        closestCentroid = this.argmin(this.dataset[i], this.centroids, this.distance);

        if (closestCentroid != this.assignments[i]) {
          this.assignments[i] = closestCentroid;
          change = true;
        }
      }

      return change;
    };

    /**
     * Extract information about clusters
     *
     * @returns {undefined}
     */
    KMEANS.prototype.getClusters = function() {
      var clusters = new Array(this.k);
      var centroidId;

      for (var pointId = 0; pointId < this.assignments.length; pointId++) {
        centroidId = this.assignments[pointId];

        // init empty cluster
        if (typeof clusters[centroidId] === 'undefined') {
          clusters[centroidId] = [];
        }

        clusters[centroidId].push(pointId);
      }

      return clusters;
    };

    // utils

    /**
     * @params {Array} point
     * @params {Array.<Array>} set
     * @params {Function} f
     * @returns {number}
     */
    KMEANS.prototype.argmin = function(point, set, f) {
      var min = Number.MAX_VALUE;
      var arg = 0;
      var len = set.length;
      var d;

      for (var i = 0; i < len; i++) {
        d = f(point, set[i]);
        if (d < min) {
          min = d;
          arg = i;
        }
      }

      return arg;
    };

    /**
     * Euclidean distance
     *
     * @params {number} p
     * @params {number} q
     * @returns {number}
     */
    KMEANS.prototype.distance = function(p, q) {
      var sum = 0;
      var i = Math.min(p.length, q.length);

      while (i--) {
        var diff = p[i] - q[i];
        sum += diff * diff;
      }

      return Math.sqrt(sum);
    };

    if (module.exports) {
      module.exports = KMEANS;
    }
    });

    var KMEANS = /*#__PURE__*/Object.freeze({
        default: KMEANS_1,
        __moduleExports: KMEANS_1
    });

    var PriorityQueue_1 = createCommonjsModule(function (module) {
    /**
     * PriorityQueue
     * Elements in this queue are sorted according to their value
     *
     * @author Lukasz Krawczyk <contact@lukaszkrawczyk.eu>
     * @copyright MIT
     */

    /**
     * PriorityQueue class construcotr
     * @constructor
     *
     * @example
     * queue: [1,2,3,4]
     * priorities: [4,1,2,3]
     * > result = [1,4,2,3]
     *
     * @param {Array} elements
     * @param {Array} priorities
     * @param {string} sorting - asc / desc
     * @returns {PriorityQueue}
     */
    function PriorityQueue(elements, priorities, sorting) {
      /** @type {Array} */
      this._queue = [];
      /** @type {Array} */
      this._priorities = [];
      /** @type {string} */
      this._sorting = 'desc';

      this._init(elements, priorities, sorting);
    }
    /**
     * Insert element
     *
     * @param {Object} ele
     * @param {Object} priority
     * @returns {undefined}
     * @access public
     */
    PriorityQueue.prototype.insert = function(ele, priority) {
      var indexToInsert = this._queue.length;
      var index = indexToInsert;

      while (index--) {
        var priority2 = this._priorities[index];
        if (this._sorting === 'desc') {
          if (priority > priority2) {
            indexToInsert = index;
          }
        } else {
          if (priority < priority2) {
            indexToInsert = index;
          }
        }
      }

      this._insertAt(ele, priority, indexToInsert);
    };

    /**
     * Remove element
     *
     * @param {Object} ele
     * @returns {undefined}
     * @access public
     */
    PriorityQueue.prototype.remove = function(ele) {
      var index = this._queue.length;

      while (index--) {
        var ele2 = this._queue[index];
        if (ele === ele2) {
          this._queue.splice(index, 1);
          this._priorities.splice(index, 1);
          break;
        }
      }
    };

    /**
     * For each loop wrapper
     *
     * @param {function} func
     * @returs {undefined}
     * @access public
     */
    PriorityQueue.prototype.forEach = function(func) {
      this._queue.forEach(func);
    };

    /**
     * @returns {Array}
     * @access public
     */
    PriorityQueue.prototype.getElements = function() {
      return this._queue;
    };

    /**
     * @param {number} index
     * @returns {Object}
     * @access public
     */
    PriorityQueue.prototype.getElementPriority = function(index) {
      return this._priorities[index];
    };

    /**
     * @returns {Array}
     * @access public
     */
    PriorityQueue.prototype.getPriorities = function() {
      return this._priorities;
    };

    /**
     * @returns {Array}
     * @access public
     */
    PriorityQueue.prototype.getElementsWithPriorities = function() {
      var result = [];

      for (var i = 0, l = this._queue.length; i < l; i++) {
        result.push([this._queue[i], this._priorities[i]]);
      }

      return result;
    };

    /**
     * Set object properties
     *
     * @param {Array} elements
     * @param {Array} priorities
     * @returns {undefined}
     * @access protected
     */
    PriorityQueue.prototype._init = function(elements, priorities, sorting) {

      if (elements && priorities) {
        this._queue = [];
        this._priorities = [];

        if (elements.length !== priorities.length) {
          throw new Error('Arrays must have the same length');
        }

        for (var i = 0; i < elements.length; i++) {
          this.insert(elements[i], priorities[i]);
        }
      }

      if (sorting) {
        this._sorting = sorting;
      }
    };

    /**
     * Insert element at given position
     *
     * @param {Object} ele
     * @param {number} index
     * @returns {undefined}
     * @access protected
     */
    PriorityQueue.prototype._insertAt = function(ele, priority, index) {
      if (this._queue.length === index) {
        this._queue.push(ele);
        this._priorities.push(priority);
      } else {
        this._queue.splice(index, 0, ele);
        this._priorities.splice(index, 0, priority);
      }
    };

    if (module.exports) {
      module.exports = PriorityQueue;
    }
    });

    var PriorityQueue = /*#__PURE__*/Object.freeze({
        default: PriorityQueue_1,
        __moduleExports: PriorityQueue_1
    });

    var require$$0$3 = ( PriorityQueue && PriorityQueue_1 ) || PriorityQueue;

    var OPTICS_1 = createCommonjsModule(function (module) {
    /**
     * @requires ./PriorityQueue.js
     */

    if (module.exports) {
          var PriorityQueue = require$$0$3;
    }

    /**
     * OPTICS - Ordering points to identify the clustering structure
     *
     * @author Lukasz Krawczyk <contact@lukaszkrawczyk.eu>
     * @copyright MIT
     */

    /**
     * OPTICS class constructor
     * @constructor
     *
     * @param {Array} dataset
     * @param {number} epsilon
     * @param {number} minPts
     * @param {function} distanceFunction
     * @returns {OPTICS}
     */
    function OPTICS(dataset, epsilon, minPts, distanceFunction) {
      /** @type {number} */
      this.epsilon = 1;
      /** @type {number} */
      this.minPts = 1;
      /** @type {function} */
      this.distance = this._euclideanDistance;

      // temporary variables used during computation

      /** @type {Array} */
      this._reachability = [];
      /** @type {Array} */
      this._processed = [];
      /** @type {number} */
      this._coreDistance = 0;
      /** @type {Array} */
      this._orderedList = [];

      this._init(dataset, epsilon, minPts, distanceFunction);
    }

    /******************************************************************************/
    // pulic functions

    /**
     * Start clustering
     *
     * @param {Array} dataset
     * @returns {undefined}
     * @access public
     */
    OPTICS.prototype.run = function(dataset, epsilon, minPts, distanceFunction) {
      this._init(dataset, epsilon, minPts, distanceFunction);

      for (var pointId = 0, l = this.dataset.length; pointId < l; pointId++) {
        if (this._processed[pointId] !== 1) {
          this._processed[pointId] = 1;
          this.clusters.push([pointId]);
          var clusterId = this.clusters.length - 1;

          this._orderedList.push(pointId);
          var priorityQueue = new PriorityQueue(null, null, 'asc');
          var neighbors = this._regionQuery(pointId);

          // using priority queue assign elements to new cluster
          if (this._distanceToCore(pointId) !== undefined) {
            this._updateQueue(pointId, neighbors, priorityQueue);
            this._expandCluster(clusterId, priorityQueue);
          }
        }
      }

      return this.clusters;
    };

    /**
     * Generate reachability plot for all points
     *
     * @returns {array}
     * @access public
     */
    OPTICS.prototype.getReachabilityPlot = function() {
      var reachabilityPlot = [];

      for (var i = 0, l = this._orderedList.length; i < l; i++) {
        var pointId = this._orderedList[i];
        var distance = this._reachability[pointId];

        reachabilityPlot.push([pointId, distance]);
      }

      return reachabilityPlot;
    };

    /******************************************************************************/
    // protected functions

    /**
     * Set object properties
     *
     * @param {Array} dataset
     * @param {number} epsilon
     * @param {number} minPts
     * @param {function} distance
     * @returns {undefined}
     * @access protected
     */
    OPTICS.prototype._init = function(dataset, epsilon, minPts, distance) {

      if (dataset) {

        if (!(dataset instanceof Array)) {
          throw Error('Dataset must be of type array, ' +
            typeof dataset + ' given');
        }

        this.dataset = dataset;
        this.clusters = [];
        this._reachability = new Array(this.dataset.length);
        this._processed = new Array(this.dataset.length);
        this._coreDistance = 0;
        this._orderedList = [];
      }

      if (epsilon) {
        this.epsilon = epsilon;
      }

      if (minPts) {
        this.minPts = minPts;
      }

      if (distance) {
        this.distance = distance;
      }
    };

    /**
     * Update information in queue
     *
     * @param {number} pointId
     * @param {Array} neighbors
     * @param {PriorityQueue} queue
     * @returns {undefined}
     * @access protected
     */
    OPTICS.prototype._updateQueue = function(pointId, neighbors, queue) {
      var self = this;

      this._coreDistance = this._distanceToCore(pointId);
      neighbors.forEach(function(pointId2) {
        if (self._processed[pointId2] === undefined) {
          var dist = self.distance(self.dataset[pointId], self.dataset[pointId2]);
          var newReachableDistance = Math.max(self._coreDistance, dist);

          if (self._reachability[pointId2] === undefined) {
            self._reachability[pointId2] = newReachableDistance;
            queue.insert(pointId2, newReachableDistance);
          } else {
            if (newReachableDistance < self._reachability[pointId2]) {
              self._reachability[pointId2] = newReachableDistance;
              queue.remove(pointId2);
              queue.insert(pointId2, newReachableDistance);
            }
          }
        }
      });
    };

    /**
     * Expand cluster
     *
     * @param {number} clusterId
     * @param {PriorityQueue} queue
     * @returns {undefined}
     * @access protected
     */
    OPTICS.prototype._expandCluster = function(clusterId, queue) {
      var queueElements = queue.getElements();

      for (var p = 0, l = queueElements.length; p < l; p++) {
        var pointId = queueElements[p];
        if (this._processed[pointId] === undefined) {
          var neighbors = this._regionQuery(pointId);
          this._processed[pointId] = 1;

          this.clusters[clusterId].push(pointId);
          this._orderedList.push(pointId);

          if (this._distanceToCore(pointId) !== undefined) {
            this._updateQueue(pointId, neighbors, queue);
            this._expandCluster(clusterId, queue);
          }
        }
      }
    };

    /**
     * Calculating distance to cluster core
     *
     * @param {number} pointId
     * @returns {number}
     * @access protected
     */
    OPTICS.prototype._distanceToCore = function(pointId) {
      var l = this.epsilon;
      for (var coreDistCand = 0; coreDistCand < l; coreDistCand++) {
        var neighbors = this._regionQuery(pointId, coreDistCand);
        if (neighbors.length >= this.minPts) {
          return coreDistCand;
        }
      }

      return;
    };

    /**
     * Find all neighbors around given point
     *
     * @param {number} pointId
     * @param {number} epsilon
     * @returns {Array}
     * @access protected
     */
    OPTICS.prototype._regionQuery = function(pointId, epsilon) {
      epsilon = epsilon || this.epsilon;
      var neighbors = [];

      for (var id = 0, l = this.dataset.length; id < l; id++) {
        if (this.distance(this.dataset[pointId], this.dataset[id]) < epsilon) {
          neighbors.push(id);
        }
      }

      return neighbors;
    };

    /******************************************************************************/
    // helpers

    /**
     * Calculate euclidean distance in multidimensional space
     *
     * @param {Array} p
     * @param {Array} q
     * @returns {number}
     * @access protected
     */
    OPTICS.prototype._euclideanDistance = function(p, q) {
      var sum = 0;
      var i = Math.min(p.length, q.length);

      while (i--) {
        sum += (p[i] - q[i]) * (p[i] - q[i]);
      }

      return Math.sqrt(sum);
    };

    if (module.exports) {
      module.exports = OPTICS;
    }
    });

    var OPTICS = /*#__PURE__*/Object.freeze({
        default: OPTICS_1,
        __moduleExports: OPTICS_1
    });

    var require$$0$4 = ( DBSCAN && DBSCAN_1 ) || DBSCAN;

    var require$$1 = ( KMEANS && KMEANS_1 ) || KMEANS;

    var require$$2 = ( OPTICS && OPTICS_1 ) || OPTICS;

    var lib = createCommonjsModule(function (module) {
    if (module.exports) {
        module.exports = {
          DBSCAN: require$$0$4,
          KMEANS: require$$1,
          OPTICS: require$$2,
          PriorityQueue: require$$0$3
        };
    }
    });
    var lib_1 = lib.DBSCAN;
    var lib_2 = lib.KMEANS;
    var lib_3 = lib.OPTICS;
    var lib_4 = lib.PriorityQueue;

    /**
     * Takes a set of {@link Point|points} and partition them into clusters according to {@link DBSCAN's|https://en.wikipedia.org/wiki/DBSCAN} data clustering algorithm.
     *
     * @name clustersDbscan
     * @param {FeatureCollection<Point>} points to be clustered
     * @param {number} maxDistance Maximum Distance between any point of the cluster to generate the clusters (kilometers only)
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units=kilometers] in which `maxDistance` is expressed, can be degrees, radians, miles, or kilometers
     * @param {number} [options.minPoints=3] Minimum number of points to generate a single cluster,
     * points which do not meet this requirement will be classified as an 'edge' or 'noise'.
     * @returns {FeatureCollection<Point>} Clustered Points with an additional two properties associated to each Feature:
     * - {number} cluster - the associated clusterId
     * - {string} dbscan - type of point it has been classified as ('core'|'edge'|'noise')
     * @example
     * // create random points with random z-values in their properties
     * var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]});
     * var maxDistance = 100;
     * var clustered = turf.clustersDbscan(points, maxDistance);
     *
     * //addToMap
     * var addToMap = [clustered];
     */
    function clustersDbscan(points$$1, maxDistance, options) {

        options = checkIfOptionsExist(options);
        var minPoints = options.minPoints;
        var units = options.units;

        // Input validation
        collectionOf(points$$1, 'Point', 'Input must contain Points');
        if (maxDistance === null || maxDistance === undefined) throw new Error('maxDistance is required');
        if (!(Math.sign(maxDistance) > 0)) throw new Error('Invalid maxDistance');
        if (!(minPoints === undefined || minPoints === null || Math.sign(minPoints) > 0)) throw new Error('Invalid minPoints');

        if (!options.mutate) {
            // Clone points to prevent any mutations
            points$$1 = clone(points$$1, true);
        }

        // Defaults
        minPoints = minPoints || 3;

        // create clustered ids
        var dbscan = new lib.DBSCAN();
        var clusteredIds = dbscan.run(coordAll(points$$1), convertLength(maxDistance, units), minPoints, distance);

        // Tag points to Clusters ID
        var clusterId = -1;
        clusteredIds.forEach(function (clusterIds) {
            clusterId++;
            // assign cluster ids to input points
            clusterIds.forEach(function (idx) {
                var clusterPoint = points$$1.features[idx];
                if (!clusterPoint.properties) clusterPoint.properties = {};
                clusterPoint.properties.cluster = clusterId;
                clusterPoint.properties.dbscan = 'core';
            });
        });

        // handle noise points, if any
        // edges points are tagged by DBSCAN as both 'noise' and 'cluster' as they can "reach" less than 'minPoints' number of points
        dbscan.noise.forEach(function (noiseId) {
            var noisePoint = points$$1.features[noiseId];
            if (!noisePoint.properties) noisePoint.properties = {};
            if (noisePoint.properties.cluster) noisePoint.properties.dbscan = 'edge';
            else noisePoint.properties.dbscan = 'noise';
        });

        return points$$1;
    }

    var distance$1 = {
    	/**
      * Euclidean distance
      */
    	eudist: function eudist(v1, v2, sqrt) {
    		var len = v1.length;
    		var sum = 0;

    		for (var i = 0; i < len; i++) {
    			var d = (v1[i] || 0) - (v2[i] || 0);
    			sum += d * d;
    		}
    		// Square root not really needed
    		return sqrt ? Math.sqrt(sum) : sum;
    	},
    	mandist: function mandist(v1, v2, sqrt) {
    		var len = v1.length;
    		var sum = 0;

    		for (var i = 0; i < len; i++) {
    			sum += Math.abs((v1[i] || 0) - (v2[i] || 0));
    		}

    		// Square root not really needed
    		return sqrt ? Math.sqrt(sum) : sum;
    	},


    	/**
      * Unidimensional distance
      */
    	dist: function dist(v1, v2, sqrt) {
    		var d = Math.abs(v1 - v2);
    		return sqrt ? d : d * d;
    	}
    };
    var distance_1 = distance$1.eudist;
    var distance_2 = distance$1.mandist;
    var distance_3 = distance$1.dist;

    var distance$2 = /*#__PURE__*/Object.freeze({
        default: distance$1,
        __moduleExports: distance$1,
        eudist: distance_1,
        mandist: distance_2,
        dist: distance_3
    });

    var Distance = ( distance$2 && distance$1 ) || distance$2;

    var eudist = Distance.eudist,
        dist = Distance.dist;

    var kinit = {
    	kmrand: function kmrand(data, k) {
    		var map = {},
    		    ks = [],
    		    t = k << 2;
    		var len = data.length;
    		var multi = data[0].length > 0;

    		while (ks.length < k && t-- > 0) {
    			var d = data[Math.floor(Math.random() * len)];
    			var key = multi ? d.join("_") : "" + d;
    			if (!map[key]) {
    				map[key] = true;
    				ks.push(d);
    			}
    		}

    		if (ks.length < k) throw new Error("Error initializating clusters");else return ks;
    	},


    	/**
      * K-means++ initial centroid selection
      */
    	kmpp: function kmpp(data, k) {
    		var distance = data[0].length ? eudist : dist;
    		var ks = [],
    		    len = data.length;
    		var multi = data[0].length > 0;

    		// First random centroid
    		var c = data[Math.floor(Math.random() * len)];
    		var key = multi ? c.join("_") : "" + c;
    		ks.push(c);

    		// Retrieve next centroids
    		while (ks.length < k) {
    			// Min Distances between current centroids and data points
    			var dists = [],
    			    lk = ks.length;
    			var dsum = 0,
    			    prs = [];

    			for (var i = 0; i < len; i++) {
    				var min = Infinity;
    				for (var j = 0; j < lk; j++) {
    					var _dist = distance(data[i], ks[j]);
    					if (_dist <= min) min = _dist;
    				}
    				dists[i] = min;
    			}

    			// Sum all min distances
    			for (var _i = 0; _i < len; _i++) {
    				dsum += dists[_i];
    			}

    			// Probabilities and cummulative prob (cumsum)
    			for (var _i2 = 0; _i2 < len; _i2++) {
    				prs[_i2] = { i: _i2, v: data[_i2], pr: dists[_i2] / dsum, cs: 0 };
    			}

    			// Sort Probabilities
    			prs.sort(function (a, b) {
    				return a.pr - b.pr;
    			});

    			// Cummulative Probabilities
    			prs[0].cs = prs[0].pr;
    			for (var _i3 = 1; _i3 < len; _i3++) {
    				prs[_i3].cs = prs[_i3 - 1].cs + prs[_i3].pr;
    			}

    			// Randomize
    			var rnd = Math.random();

    			// Gets only the items whose cumsum >= rnd
    			var idx = 0;
    			while (idx < len - 1 && prs[idx++].cs < rnd) {}
    			ks.push(prs[idx - 1].v);
    			/*
       let done = false;
       while(!done) {
       	// this is our new centroid
       	c = prs[idx-1].v
       	key = multi? c.join("_") : `${c}`;
       	if(!map[key]) {
       		map[key] = true;
       		ks.push(c);
       		done = true;
       	}
       	else {
       		idx++;
       	}
       }
       */
    		}

    		return ks;
    	}
    };
    var kinit_1 = kinit.kmrand;
    var kinit_2 = kinit.kmpp;

    var kinit$1 = /*#__PURE__*/Object.freeze({
        default: kinit,
        __moduleExports: kinit,
        kmrand: kinit_1,
        kmpp: kinit_2
    });

    var ClusterInit = ( kinit$1 && kinit ) || kinit$1;

    /*jshint esversion: 6 */

    var eudist$1 = Distance.eudist,
        mandist = Distance.mandist,
        dist$1 = Distance.dist,
        kmrand = ClusterInit.kmrand,
        kmpp = ClusterInit.kmpp;

    var MAX = 10000;

    /**
     * Inits an array with values
     */
    function init(len, val, v) {
    	v = v || [];
    	for (var i = 0; i < len; i++) {
    		v[i] = val;
    	}return v;
    }

    function skmeans(data, k, initial, maxit) {
    	var ks = [],
    	    old = [],
    	    idxs = [],
    	    dist = [];
    	var conv = false,
    	    it = maxit || MAX;
    	var len = data.length,
    	    vlen = data[0].length,
    	    multi = vlen > 0;
    	var count = [];

    	if (!initial) {
    		var _idxs = {};
    		while (ks.length < k) {
    			var idx = Math.floor(Math.random() * len);
    			if (!_idxs[idx]) {
    				_idxs[idx] = true;
    				ks.push(data[idx]);
    			}
    		}
    	} else if (initial == "kmrand") {
    		ks = kmrand(data, k);
    	} else if (initial == "kmpp") {
    		ks = kmpp(data, k);
    	} else {
    		ks = initial;
    	}

    	do {
    		// Reset k count
    		init(k, 0, count);

    		// For each value in data, find the nearest centroid
    		for (var i = 0; i < len; i++) {
    			var min = Infinity,
    			    _idx = 0;
    			for (var j = 0; j < k; j++) {
    				// Multidimensional or unidimensional
    				var dist = multi ? eudist$1(data[i], ks[j]) : Math.abs(data[i] - ks[j]);
    				if (dist <= min) {
    					min = dist;
    					_idx = j;
    				}
    			}
    			idxs[i] = _idx; // Index of the selected centroid for that value
    			count[_idx]++; // Number of values for this centroid
    		}

    		// Recalculate centroids
    		var sum = [],
    		    old = [];
    		for (var _j = 0; _j < k; _j++) {
    			// Multidimensional or unidimensional
    			sum[_j] = multi ? init(vlen, 0, sum[_j]) : 0;
    			old[_j] = ks[_j];
    		}

    		// If multidimensional
    		if (multi) {
    			for (var _j2 = 0; _j2 < k; _j2++) {
    				ks[_j2] = [];
    			} // Sum values and count for each centroid
    			for (var _i = 0; _i < len; _i++) {
    				var _idx2 = idxs[_i],
    				    // Centroid for that item
    				vsum = sum[_idx2],
    				    // Sum values for this centroid
    				vect = data[_i]; // Current vector

    				// Accumulate value on the centroid for current vector
    				for (var h = 0; h < vlen; h++) {
    					vsum[h] += vect[h];
    				}
    			}
    			// Calculate the average for each centroid
    			conv = true;
    			for (var _j3 = 0; _j3 < k; _j3++) {
    				var ksj = ks[_j3],
    				    // Current centroid
    				sumj = sum[_j3],
    				    // Accumulated centroid values
    				oldj = old[_j3],
    				    // Old centroid value
    				cj = count[_j3]; // Number of elements for this centroid

    				// New average
    				for (var _h = 0; _h < vlen; _h++) {
    					ksj[_h] = sumj[_h] / cj || 0; // New centroid
    				}

    				// Find if centroids have moved
    				if (conv) {
    					for (var _h2 = 0; _h2 < vlen; _h2++) {
    						if (oldj[_h2] != ksj[_h2]) {
    							conv = false;
    							break;
    						}
    					}
    				}
    			}
    		}
    		// If unidimensional
    		else {
    				// Sum values and count for each centroid
    				for (var _i2 = 0; _i2 < len; _i2++) {
    					var _idx3 = idxs[_i2];
    					sum[_idx3] += data[_i2];
    				}
    				// Calculate the average for each centroid
    				for (var _j4 = 0; _j4 < k; _j4++) {
    					ks[_j4] = sum[_j4] / count[_j4] || 0; // New centroid
    				}
    				// Find if centroids have moved
    				conv = true;
    				for (var _j5 = 0; _j5 < k; _j5++) {
    					if (old[_j5] != ks[_j5]) {
    						conv = false;
    						break;
    					}
    				}
    			}

    		conv = conv || --it <= 0;
    	} while (!conv);

    	return {
    		it: MAX - it,
    		k: k,
    		idxs: idxs,
    		centroids: ks
    	};
    }

    var main = skmeans;

    /**
     * Takes a set of {@link Point|points} and partition them into clusters using the k-mean .
     * It uses the [k-means algorithm](https://en.wikipedia.org/wiki/K-means_clustering)
     *
     * @name clustersKmeans
     * @param {FeatureCollection<Point>} points to be clustered
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.numberOfClusters=Math.sqrt(numberOfPoints/2)] numberOfClusters that will be generated
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {FeatureCollection<Point>} Clustered Points with an additional two properties associated to each Feature:
     * - {number} cluster - the associated clusterId
     * - {[number, number]} centroid - Centroid of the cluster [Longitude, Latitude]
     * @example
     * // create random points with random z-values in their properties
     * var points = turf.randomPoint(100, {bbox: [0, 30, 20, 50]});
     * var options = {numberOfClusters: 7};
     * var clustered = turf.clustersKmeans(points, options);
     *
     * //addToMap
     * var addToMap = [clustered];
     */
    function clustersKmeans(points, options) {
        // Optional parameters
        options = options || {};
        if (typeof options !== 'object') throw new Error('options is invalid');
        var numberOfClusters = options.numberOfClusters;
        var mutate = options.mutate;

        // Input validation
        collectionOf(points, 'Point', 'Input must contain Points');

        // Default Params
        var count = points.features.length;
        numberOfClusters = numberOfClusters || Math.round(Math.sqrt(count / 2));

        // numberOfClusters can't be greater than the number of points
        // fallbacks to count
        if (numberOfClusters > count) numberOfClusters = count;

        // Clone points to prevent any mutations (enabled by default)
        if (mutate === false || mutate === undefined) points = clone(points, true);

        // collect points coordinates
        var data = coordAll(points);

        // create seed to avoid skmeans to drift
        var initialCentroids = data.slice(0, numberOfClusters);

        // create skmeans clusters
        var skmeansResult = main(data, numberOfClusters, initialCentroids);

        // store centroids {clusterId: [number, number]}
        var centroids = {};
        skmeansResult.centroids.forEach(function (coord, idx) {
            centroids[idx] = coord;
        });

        // add associated cluster number
        featureEach(points, function (point, index) {
            var clusterId = skmeansResult.idxs[index];
            point.properties.cluster = clusterId;
            point.properties.centroid = centroids[clusterId];
        });

        return points;
    }

    /**
     * Boolean-Parallel returns True if each segment of `line1` is parallel to the correspondent segment of `line2`
     *
     * @name booleanParallel
     * @param {Geometry|Feature<LineString>} line1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<LineString>} line2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false if the lines are parallel
     * @example
     * var line1 = turf.lineString([[0, 0], [0, 1]]);
     * var line2 = turf.lineString([[1, 0], [1, 1]]);
     *
     * turf.booleanParallel(line1, line2);
     * //=true
     */
    function booleanParallel(line1, line2) {
        // validation
        if (!line1) throw new Error('line1 is required');
        if (!line2) throw new Error('line2 is required');
        var type1 = getType$1(line1, 'line1');
        if (type1 !== 'LineString') throw new Error('line1 must be a LineString');
        var type2 = getType$1(line2, 'line2');
        if (type2 !== 'LineString') throw new Error('line2 must be a LineString');

        var segments1 = lineSegment(cleanCoords(line1)).features;
        var segments2 = lineSegment(cleanCoords(line2)).features;

        for (var i = 0; i < segments1.length; i++) {
            var segment1 = segments1[i].geometry.coordinates;
            if (!segments2[i]) break;
            var segment2 = segments2[i].geometry.coordinates;
            if (!isParallel$1(segment1, segment2)) return false;
        }
        return true;
    }


    /**
     * Compares slopes and return result
     *
     * @private
     * @param {Geometry|Feature<LineString>} segment1 Geometry or Feature
     * @param {Geometry|Feature<LineString>} segment2 Geometry or Feature
     * @returns {boolean} if slopes are equal
     */
    function isParallel$1(segment1, segment2) {
        var slope1 = helpers_22(rhumbBearing(segment1[0], segment1[1]));
        var slope2 = helpers_22(rhumbBearing(segment2[0], segment2[1]));
        return slope1 === slope2;
    }


    /**
     * Returns Feature's type
     *
     * @private
     * @param {Geometry|Feature<any>} geojson Geometry or Feature
     * @param {string} name of the variable
     * @returns {string} Feature's type
     */
    function getType$1(geojson, name) {
        if (geojson.geometry && geojson.geometry.type) return geojson.geometry.type;
        if (geojson.type) return geojson.type; // if GeoJSON geometry
        throw new Error('Invalid GeoJSON object for ' + name);
    }

    // javascript-astar 0.4.1
    // http://github.com/bgrins/javascript-astar
    // Freely distributable under the MIT License.
    // Implements the astar search algorithm in javascript using a Binary Heap.
    // Includes Binary Heap (with modifications) from Marijn Haverbeke.
    // http://eloquentjavascript.net/appendix2.html

    function pathTo(node) {
        var curr = node,
            path = [];
        while (curr.parent) {
            path.unshift(curr);
            curr = curr.parent;
        }
        return path;
    }

    function getHeap() {
        return new BinaryHeap(function (node) {
            return node.f;
        });
    }

    /**
     * Astar
     * @private
     */
    var astar = {
        /**
         * Perform an A* Search on a graph given a start and end node.
         *
         * @private
         * @memberof astar
         * @param {Graph} graph Graph
         * @param {GridNode} start Start
         * @param {GridNode} end End
         * @param {Object} [options] Options
         * @param {bool} [options.closest] Specifies whether to return the path to the closest node if the target is unreachable.
         * @param {Function} [options.heuristic] Heuristic function (see astar.heuristics).
         * @returns {Object} Search
         */
        search: function (graph, start, end, options) {
            graph.cleanDirty();
            options = options || {};
            var heuristic = options.heuristic || astar.heuristics.manhattan,
                closest = options.closest || false;

            var openHeap = getHeap(),
                closestNode = start; // set the start node to be the closest if required

            start.h = heuristic(start, end);

            openHeap.push(start);

            while (openHeap.size() > 0) {

                // Grab the lowest f(x) to process next.  Heap keeps this sorted for us.
                var currentNode = openHeap.pop();

                // End case -- result has been found, return the traced path.
                if (currentNode === end) {
                    return pathTo(currentNode);
                }

                // Normal case -- move currentNode from open to closed, process each of its neighbors.
                currentNode.closed = true;

                // Find all neighbors for the current node.
                var neighbors = graph.neighbors(currentNode);

                for (var i = 0, il = neighbors.length; i < il; ++i) {
                    var neighbor = neighbors[i];

                    if (neighbor.closed || neighbor.isWall()) {
                        // Not a valid node to process, skip to next neighbor.
                        continue;
                    }

                    // The g score is the shortest distance from start to current node.
                    // We need to check if the path we have arrived at this neighbor is the shortest one we have seen yet.
                    var gScore = currentNode.g + neighbor.getCost(currentNode),
                        beenVisited = neighbor.visited;

                    if (!beenVisited || gScore < neighbor.g) {

                        // Found an optimal (so far) path to this node.  Take score for node to see how good it is.
                        neighbor.visited = true;
                        neighbor.parent = currentNode;
                        neighbor.h = neighbor.h || heuristic(neighbor, end);
                        neighbor.g = gScore;
                        neighbor.f = neighbor.g + neighbor.h;
                        graph.markDirty(neighbor);
                        if (closest) {
                            // If the neighbour is closer than the current closestNode or if it's equally close but has
                            // a cheaper path than the current closest node then it becomes the closest node
                            if (neighbor.h < closestNode.h || (neighbor.h === closestNode.h && neighbor.g < closestNode.g)) {
                                closestNode = neighbor;
                            }
                        }

                        if (!beenVisited) {
                            // Pushing to heap will put it in proper place based on the 'f' value.
                            openHeap.push(neighbor);
                        } else {
                            // Already seen the node, but since it has been rescored we need to reorder it in the heap
                            openHeap.rescoreElement(neighbor);
                        }
                    }
                }
            }

            if (closest) {
                return pathTo(closestNode);
            }

            // No result was found - empty array signifies failure to find path.
            return [];
        },
        // See list of heuristics: http://theory.stanford.edu/~amitp/GameProgramming/Heuristics.html
        heuristics: {
            manhattan: function (pos0, pos1) {
                var d1 = Math.abs(pos1.x - pos0.x);
                var d2 = Math.abs(pos1.y - pos0.y);
                return d1 + d2;
            },
            diagonal: function (pos0, pos1) {
                var D = 1;
                var D2 = Math.sqrt(2);
                var d1 = Math.abs(pos1.x - pos0.x);
                var d2 = Math.abs(pos1.y - pos0.y);
                return (D * (d1 + d2)) + ((D2 - (2 * D)) * Math.min(d1, d2));
            }
        },
        cleanNode: function (node) {
            node.f = 0;
            node.g = 0;
            node.h = 0;
            node.visited = false;
            node.closed = false;
            node.parent = null;
        }
    };

    /**
     * A graph memory structure
     *
     * @private
     * @param {Array} gridIn 2D array of input weights
     * @param {Object} [options] Options
     * @param {boolean} [options.diagonal] Specifies whether diagonal moves are allowed
     * @returns {void} Graph
     */
    function Graph$1(gridIn, options) {
        options = options || {};
        this.nodes = [];
        this.diagonal = !!options.diagonal;
        this.grid = [];
        for (var x = 0; x < gridIn.length; x++) {
            this.grid[x] = [];

            for (var y = 0, row = gridIn[x]; y < row.length; y++) {
                var node = new GridNode(x, y, row[y]);
                this.grid[x][y] = node;
                this.nodes.push(node);
            }
        }
        this.init();
    }

    Graph$1.prototype.init = function () {
        this.dirtyNodes = [];
        for (var i = 0; i < this.nodes.length; i++) {
            astar.cleanNode(this.nodes[i]);
        }
    };

    Graph$1.prototype.cleanDirty = function () {
        for (var i = 0; i < this.dirtyNodes.length; i++) {
            astar.cleanNode(this.dirtyNodes[i]);
        }
        this.dirtyNodes = [];
    };

    Graph$1.prototype.markDirty = function (node) {
        this.dirtyNodes.push(node);
    };

    Graph$1.prototype.neighbors = function (node) {
        var ret = [],
            x = node.x,
            y = node.y,
            grid = this.grid;

        // West
        if (grid[x - 1] && grid[x - 1][y]) {
            ret.push(grid[x - 1][y]);
        }

        // East
        if (grid[x + 1] && grid[x + 1][y]) {
            ret.push(grid[x + 1][y]);
        }

        // South
        if (grid[x] && grid[x][y - 1]) {
            ret.push(grid[x][y - 1]);
        }

        // North
        if (grid[x] && grid[x][y + 1]) {
            ret.push(grid[x][y + 1]);
        }

        if (this.diagonal) {
            // Southwest
            if (grid[x - 1] && grid[x - 1][y - 1]) {
                ret.push(grid[x - 1][y - 1]);
            }

            // Southeast
            if (grid[x + 1] && grid[x + 1][y - 1]) {
                ret.push(grid[x + 1][y - 1]);
            }

            // Northwest
            if (grid[x - 1] && grid[x - 1][y + 1]) {
                ret.push(grid[x - 1][y + 1]);
            }

            // Northeast
            if (grid[x + 1] && grid[x + 1][y + 1]) {
                ret.push(grid[x + 1][y + 1]);
            }
        }

        return ret;
    };

    Graph$1.prototype.toString = function () {
        var graphString = [],
            nodes = this.grid, // when using grid
            rowDebug, row, y, l;
        for (var x = 0, len = nodes.length; x < len; x++) {
            rowDebug = [];
            row = nodes[x];
            for (y = 0, l = row.length; y < l; y++) {
                rowDebug.push(row[y].weight);
            }
            graphString.push(rowDebug.join(' '));
        }
        return graphString.join('\n');
    };

    function GridNode(x, y, weight) {
        this.x = x;
        this.y = y;
        this.weight = weight;
    }

    GridNode.prototype.toString = function () {
        return '[' + this.x + ' ' + this.y + ']';
    };

    GridNode.prototype.getCost = function (fromNeighbor) {
        // Take diagonal weight into consideration.
        if (fromNeighbor && fromNeighbor.x !== this.x && fromNeighbor.y !== this.y) {
            return this.weight * 1.41421;
        }
        return this.weight;
    };

    GridNode.prototype.isWall = function () {
        return this.weight === 0;
    };

    function BinaryHeap(scoreFunction) {
        this.content = [];
        this.scoreFunction = scoreFunction;
    }

    BinaryHeap.prototype = {
        push: function (element) {
            // Add the new element to the end of the array.
            this.content.push(element);

            // Allow it to sink down.
            this.sinkDown(this.content.length - 1);
        },
        pop: function () {
            // Store the first element so we can return it later.
            var result = this.content[0];
            // Get the element at the end of the array.
            var end = this.content.pop();
            // If there are any elements left, put the end element at the
            // start, and let it bubble up.
            if (this.content.length > 0) {
                this.content[0] = end;
                this.bubbleUp(0);
            }
            return result;
        },
        remove: function (node) {
            var i = this.content.indexOf(node);

            // When it is found, the process seen in 'pop' is repeated
            // to fill up the hole.
            var end = this.content.pop();

            if (i !== this.content.length - 1) {
                this.content[i] = end;

                if (this.scoreFunction(end) < this.scoreFunction(node)) {
                    this.sinkDown(i);
                } else {
                    this.bubbleUp(i);
                }
            }
        },
        size: function () {
            return this.content.length;
        },
        rescoreElement: function (node) {
            this.sinkDown(this.content.indexOf(node));
        },
        sinkDown: function (n) {
            // Fetch the element that has to be sunk.
            var element = this.content[n];

            // When at 0, an element can not sink any further.
            while (n > 0) {

                // Compute the parent element's index, and fetch it.
                var parentN = ((n + 1) >> 1) - 1,
                    parent = this.content[parentN];
                // Swap the elements if the parent is greater.
                if (this.scoreFunction(element) < this.scoreFunction(parent)) {
                    this.content[parentN] = element;
                    this.content[n] = parent;
                    // Update 'n' to continue at the new position.
                    n = parentN;
                // Found a parent that is less, no need to sink any further.
                } else {
                    break;
                }
            }
        },
        bubbleUp: function (n) {
            // Look up the target element and its score.
            var length = this.content.length,
                element = this.content[n],
                elemScore = this.scoreFunction(element);

            while (true) {
                // Compute the indices of the child elements.
                var child2N = (n + 1) << 1,
                    child1N = child2N - 1;
                // This is used to store the new position of the element, if any.
                var swap = null,
                    child1Score;
                // If the first child exists (is inside the array)...
                if (child1N < length) {
                    // Look it up and compute its score.
                    var child1 = this.content[child1N];
                    child1Score = this.scoreFunction(child1);

                    // If the score is less than our element's, we need to swap.
                    if (child1Score < elemScore) {
                        swap = child1N;
                    }
                }

                // Do the same checks for the other child.
                if (child2N < length) {
                    var child2 = this.content[child2N],
                        child2Score = this.scoreFunction(child2);
                    if (child2Score < (swap === null ? elemScore : child1Score)) {
                        swap = child2N;
                    }
                }

                // If the element needs to be moved, swap it, and continue.
                if (swap !== null) {
                    this.content[n] = this.content[swap];
                    this.content[swap] = element;
                    n = swap;
                // Otherwise, we are done.
                } else {
                    break;
                }
            }
        }
    };

    /**
     * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with
     * any {@link Feature} in {@link FeatureCollection<Polygon>| obstacles}
     *
     * @name shortestPath
     * @param {Coord} start point
     * @param {Coord} end point
     * @param {Object} [options={}] optional parameters
     * @param {Geometry|Feature|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel
     * @param {number} [options.minDistance] minimum distance between shortest path and obstacles
     * @param {string} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...
     * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated
     * @returns {Feature<LineString>} shortest path between start and end
     * @example
     * var start = [-5, -6];
     * var end = [9, -6];
     * var options = {
     *   obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]])
     * };
     *
     * var path = turf.shortestPath(start, end, options);
     *
     * //addToMap
     * var addToMap = [start, end, options.obstacles, path];
     */
    function shortestPath(start, end, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var resolution = options.resolution;
        var minDistance = options.minDistance;
        var obstacles = options.obstacles || featureCollection([]);

        // validation
        if (!start) throw new Error('start is required');
        if (!end) throw new Error('end is required');
        if (resolution && !isNumber(resolution) || resolution <= 0) throw new Error('options.resolution must be a number, greater than 0');
        if (minDistance) throw new Error('options.minDistance is not yet implemented');

        // Normalize Inputs
        var startCoord = getCoord(start);
        var endCoord = getCoord(end);
        start = point(startCoord);
        end = point(endCoord);

        // Handle obstacles
        switch (getType(obstacles)) {
        case 'FeatureCollection':
            if (obstacles.features.length === 0) return lineString([startCoord, endCoord]);
            break;
        case 'Polygon':
            obstacles = featureCollection([feature(getGeom(obstacles))]);
            break;
        default:
            throw new Error('invalid obstacles');
        }

        // define path grid area
        var collection = obstacles;
        collection.features.push(start);
        collection.features.push(end);
        var box = bbox(transformScale(bboxPolygon(bbox(collection)), 1.15)); // extend 15%
        if (!resolution) {
            var width = distance([box[0], box[1]], [box[2], box[1]], options);
            resolution = width / 100;
        }
        collection.features.pop();
        collection.features.pop();

        var west = box[0];
        var south = box[1];
        var east = box[2];
        var north = box[3];

        var xFraction = resolution / (distance([west, south], [east, south], options));
        var cellWidth = xFraction * (east - west);
        var yFraction = resolution / (distance([west, south], [west, north], options));
        var cellHeight = yFraction * (north - south);

        var bboxHorizontalSide = (east - west);
        var bboxVerticalSide = (north - south);
        var columns = Math.floor(bboxHorizontalSide / cellWidth);
        var rows = Math.floor(bboxVerticalSide / cellHeight);
        // adjust origin of the grid
        var deltaX = (bboxHorizontalSide - columns * cellWidth) / 2;
        var deltaY = (bboxVerticalSide - rows * cellHeight) / 2;

        // loop through points only once to speed up process
        // define matrix grid for A-star algorithm
        var pointMatrix = [];
        var matrix = [];

        var closestToStart = [];
        var closestToEnd = [];
        var minDistStart = Infinity;
        var minDistEnd = Infinity;
        var currentY = north - deltaY;
        var r = 0;
        while (currentY >= south) {
            // var currentY = south + deltaY;
            var matrixRow = [];
            var pointMatrixRow = [];
            var currentX = west + deltaX;
            var c = 0;
            while (currentX <= east) {
                var pt = point([currentX, currentY]);
                var isInsideObstacle = isInside$1(pt, obstacles);
                // feed obstacles matrix
                matrixRow.push(isInsideObstacle ? 0 : 1); // with javascript-astar
                // matrixRow.push(isInsideObstacle ? 1 : 0); // with astar-andrea
                // map point's coords
                pointMatrixRow.push(currentX + '|' + currentY);
                // set closest points
                var distStart = distance(pt, start);
                // if (distStart < minDistStart) {
                if (!isInsideObstacle && distStart < minDistStart) {
                    minDistStart = distStart;
                    closestToStart = {x: c, y: r};
                }
                var distEnd = distance(pt, end);
                // if (distEnd < minDistEnd) {
                if (!isInsideObstacle && distEnd < minDistEnd) {
                    minDistEnd = distEnd;
                    closestToEnd = {x: c, y: r};
                }
                currentX += cellWidth;
                c++;
            }
            matrix.push(matrixRow);
            pointMatrix.push(pointMatrixRow);
            currentY -= cellHeight;
            r++;
        }

        // find path on matrix grid

        // javascript-astar ----------------------
        var graph = new Graph$1(matrix, {diagonal: true});
        var startOnMatrix = graph.grid[closestToStart.y][closestToStart.x];
        var endOnMatrix = graph.grid[closestToEnd.y][closestToEnd.x];
        var result = astar.search(graph, startOnMatrix, endOnMatrix);

        var path = [startCoord];
        result.forEach(function (coord) {
            var coords = pointMatrix[coord.x][coord.y].split('|');
            path.push([+coords[0], +coords[1]]); // make sure coords are numbers
        });
        path.push(endCoord);
        // ---------------------------------------


        // astar-andrea ------------------------
        // var result = aStar(matrix, [closestToStart.x, closestToStart.y], [closestToEnd.x, closestToEnd.y], 'DiagonalFree');
        // var path = [start.geometry.coordinates];
        // result.forEach(function (coord) {
        //     var coords = pointMatrix[coord[1]][coord[0]].split('|');
        //     path.push([+coords[0], +coords[1]]); // make sure coords are numbers
        // });
        // path.push(end.geometry.coordinates);
        // ---------------------------------------


        return cleanCoords(lineString(path));
    }

    /**
     * Checks if Point is inside any of the Polygons
     *
     * @private
     * @param {Feature<Point>} pt to check
     * @param {FeatureCollection<Polygon>} polygons features
     * @returns {boolean} if inside or not
     */
    function isInside$1(pt, polygons$$1) {
        for (var i = 0; i < polygons$$1.features.length; i++) {
            if (booleanPointInPolygon(pt, polygons$$1.features[i])) {
                return true;
            }
        }
        return false;
    }

    function constant(x) {
      return function() {
        return x;
      };
    }

    function x(d) {
      return d[0];
    }

    function y(d) {
      return d[1];
    }

    function RedBlackTree() {
      this._ = null; // root node
    }

    function RedBlackNode(node) {
      node.U = // parent node
      node.C = // color - true for red, false for black
      node.L = // left node
      node.R = // right node
      node.P = // previous node
      node.N = null; // next node
    }

    RedBlackTree.prototype = {
      constructor: RedBlackTree,

      insert: function(after, node) {
        var parent, grandpa, uncle;

        if (after) {
          node.P = after;
          node.N = after.N;
          if (after.N) after.N.P = node;
          after.N = node;
          if (after.R) {
            after = after.R;
            while (after.L) after = after.L;
            after.L = node;
          } else {
            after.R = node;
          }
          parent = after;
        } else if (this._) {
          after = RedBlackFirst(this._);
          node.P = null;
          node.N = after;
          after.P = after.L = node;
          parent = after;
        } else {
          node.P = node.N = null;
          this._ = node;
          parent = null;
        }
        node.L = node.R = null;
        node.U = parent;
        node.C = true;

        after = node;
        while (parent && parent.C) {
          grandpa = parent.U;
          if (parent === grandpa.L) {
            uncle = grandpa.R;
            if (uncle && uncle.C) {
              parent.C = uncle.C = false;
              grandpa.C = true;
              after = grandpa;
            } else {
              if (after === parent.R) {
                RedBlackRotateLeft(this, parent);
                after = parent;
                parent = after.U;
              }
              parent.C = false;
              grandpa.C = true;
              RedBlackRotateRight(this, grandpa);
            }
          } else {
            uncle = grandpa.L;
            if (uncle && uncle.C) {
              parent.C = uncle.C = false;
              grandpa.C = true;
              after = grandpa;
            } else {
              if (after === parent.L) {
                RedBlackRotateRight(this, parent);
                after = parent;
                parent = after.U;
              }
              parent.C = false;
              grandpa.C = true;
              RedBlackRotateLeft(this, grandpa);
            }
          }
          parent = after.U;
        }
        this._.C = false;
      },

      remove: function(node) {
        if (node.N) node.N.P = node.P;
        if (node.P) node.P.N = node.N;
        node.N = node.P = null;

        var parent = node.U,
            sibling,
            left = node.L,
            right = node.R,
            next,
            red;

        if (!left) next = right;
        else if (!right) next = left;
        else next = RedBlackFirst(right);

        if (parent) {
          if (parent.L === node) parent.L = next;
          else parent.R = next;
        } else {
          this._ = next;
        }

        if (left && right) {
          red = next.C;
          next.C = node.C;
          next.L = left;
          left.U = next;
          if (next !== right) {
            parent = next.U;
            next.U = node.U;
            node = next.R;
            parent.L = node;
            next.R = right;
            right.U = next;
          } else {
            next.U = parent;
            parent = next;
            node = next.R;
          }
        } else {
          red = node.C;
          node = next;
        }

        if (node) node.U = parent;
        if (red) return;
        if (node && node.C) { node.C = false; return; }

        do {
          if (node === this._) break;
          if (node === parent.L) {
            sibling = parent.R;
            if (sibling.C) {
              sibling.C = false;
              parent.C = true;
              RedBlackRotateLeft(this, parent);
              sibling = parent.R;
            }
            if ((sibling.L && sibling.L.C)
                || (sibling.R && sibling.R.C)) {
              if (!sibling.R || !sibling.R.C) {
                sibling.L.C = false;
                sibling.C = true;
                RedBlackRotateRight(this, sibling);
                sibling = parent.R;
              }
              sibling.C = parent.C;
              parent.C = sibling.R.C = false;
              RedBlackRotateLeft(this, parent);
              node = this._;
              break;
            }
          } else {
            sibling = parent.L;
            if (sibling.C) {
              sibling.C = false;
              parent.C = true;
              RedBlackRotateRight(this, parent);
              sibling = parent.L;
            }
            if ((sibling.L && sibling.L.C)
              || (sibling.R && sibling.R.C)) {
              if (!sibling.L || !sibling.L.C) {
                sibling.R.C = false;
                sibling.C = true;
                RedBlackRotateLeft(this, sibling);
                sibling = parent.L;
              }
              sibling.C = parent.C;
              parent.C = sibling.L.C = false;
              RedBlackRotateRight(this, parent);
              node = this._;
              break;
            }
          }
          sibling.C = true;
          node = parent;
          parent = parent.U;
        } while (!node.C);

        if (node) node.C = false;
      }
    };

    function RedBlackRotateLeft(tree, node) {
      var p = node,
          q = node.R,
          parent = p.U;

      if (parent) {
        if (parent.L === p) parent.L = q;
        else parent.R = q;
      } else {
        tree._ = q;
      }

      q.U = parent;
      p.U = q;
      p.R = q.L;
      if (p.R) p.R.U = p;
      q.L = p;
    }

    function RedBlackRotateRight(tree, node) {
      var p = node,
          q = node.L,
          parent = p.U;

      if (parent) {
        if (parent.L === p) parent.L = q;
        else parent.R = q;
      } else {
        tree._ = q;
      }

      q.U = parent;
      p.U = q;
      p.L = q.R;
      if (p.L) p.L.U = p;
      q.R = p;
    }

    function RedBlackFirst(node) {
      while (node.L) node = node.L;
      return node;
    }

    function createEdge(left, right, v0, v1) {
      var edge = [null, null],
          index = edges.push(edge) - 1;
      edge.left = left;
      edge.right = right;
      if (v0) setEdgeEnd(edge, left, right, v0);
      if (v1) setEdgeEnd(edge, right, left, v1);
      cells[left.index].halfedges.push(index);
      cells[right.index].halfedges.push(index);
      return edge;
    }

    function createBorderEdge(left, v0, v1) {
      var edge = [v0, v1];
      edge.left = left;
      return edge;
    }

    function setEdgeEnd(edge, left, right, vertex) {
      if (!edge[0] && !edge[1]) {
        edge[0] = vertex;
        edge.left = left;
        edge.right = right;
      } else if (edge.left === right) {
        edge[1] = vertex;
      } else {
        edge[0] = vertex;
      }
    }

    // Liang–Barsky line clipping.
    function clipEdge(edge, x0, y0, x1, y1) {
      var a = edge[0],
          b = edge[1],
          ax = a[0],
          ay = a[1],
          bx = b[0],
          by = b[1],
          t0 = 0,
          t1 = 1,
          dx = bx - ax,
          dy = by - ay,
          r;

      r = x0 - ax;
      if (!dx && r > 0) return;
      r /= dx;
      if (dx < 0) {
        if (r < t0) return;
        if (r < t1) t1 = r;
      } else if (dx > 0) {
        if (r > t1) return;
        if (r > t0) t0 = r;
      }

      r = x1 - ax;
      if (!dx && r < 0) return;
      r /= dx;
      if (dx < 0) {
        if (r > t1) return;
        if (r > t0) t0 = r;
      } else if (dx > 0) {
        if (r < t0) return;
        if (r < t1) t1 = r;
      }

      r = y0 - ay;
      if (!dy && r > 0) return;
      r /= dy;
      if (dy < 0) {
        if (r < t0) return;
        if (r < t1) t1 = r;
      } else if (dy > 0) {
        if (r > t1) return;
        if (r > t0) t0 = r;
      }

      r = y1 - ay;
      if (!dy && r < 0) return;
      r /= dy;
      if (dy < 0) {
        if (r > t1) return;
        if (r > t0) t0 = r;
      } else if (dy > 0) {
        if (r < t0) return;
        if (r < t1) t1 = r;
      }

      if (!(t0 > 0) && !(t1 < 1)) return true; // TODO Better check?

      if (t0 > 0) edge[0] = [ax + t0 * dx, ay + t0 * dy];
      if (t1 < 1) edge[1] = [ax + t1 * dx, ay + t1 * dy];
      return true;
    }

    function connectEdge(edge, x0, y0, x1, y1) {
      var v1 = edge[1];
      if (v1) return true;

      var v0 = edge[0],
          left = edge.left,
          right = edge.right,
          lx = left[0],
          ly = left[1],
          rx = right[0],
          ry = right[1],
          fx = (lx + rx) / 2,
          fy = (ly + ry) / 2,
          fm,
          fb;

      if (ry === ly) {
        if (fx < x0 || fx >= x1) return;
        if (lx > rx) {
          if (!v0) v0 = [fx, y0];
          else if (v0[1] >= y1) return;
          v1 = [fx, y1];
        } else {
          if (!v0) v0 = [fx, y1];
          else if (v0[1] < y0) return;
          v1 = [fx, y0];
        }
      } else {
        fm = (lx - rx) / (ry - ly);
        fb = fy - fm * fx;
        if (fm < -1 || fm > 1) {
          if (lx > rx) {
            if (!v0) v0 = [(y0 - fb) / fm, y0];
            else if (v0[1] >= y1) return;
            v1 = [(y1 - fb) / fm, y1];
          } else {
            if (!v0) v0 = [(y1 - fb) / fm, y1];
            else if (v0[1] < y0) return;
            v1 = [(y0 - fb) / fm, y0];
          }
        } else {
          if (ly < ry) {
            if (!v0) v0 = [x0, fm * x0 + fb];
            else if (v0[0] >= x1) return;
            v1 = [x1, fm * x1 + fb];
          } else {
            if (!v0) v0 = [x1, fm * x1 + fb];
            else if (v0[0] < x0) return;
            v1 = [x0, fm * x0 + fb];
          }
        }
      }

      edge[0] = v0;
      edge[1] = v1;
      return true;
    }

    function clipEdges(x0, y0, x1, y1) {
      var i = edges.length,
          edge;

      while (i--) {
        if (!connectEdge(edge = edges[i], x0, y0, x1, y1)
            || !clipEdge(edge, x0, y0, x1, y1)
            || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon
                || Math.abs(edge[0][1] - edge[1][1]) > epsilon)) {
          delete edges[i];
        }
      }
    }

    function createCell(site) {
      return cells[site.index] = {
        site: site,
        halfedges: []
      };
    }

    function cellHalfedgeAngle(cell, edge) {
      var site = cell.site,
          va = edge.left,
          vb = edge.right;
      if (site === vb) vb = va, va = site;
      if (vb) return Math.atan2(vb[1] - va[1], vb[0] - va[0]);
      if (site === va) va = edge[1], vb = edge[0];
      else va = edge[0], vb = edge[1];
      return Math.atan2(va[0] - vb[0], vb[1] - va[1]);
    }

    function cellHalfedgeStart(cell, edge) {
      return edge[+(edge.left !== cell.site)];
    }

    function cellHalfedgeEnd(cell, edge) {
      return edge[+(edge.left === cell.site)];
    }

    function sortCellHalfedges() {
      for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) {
        if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) {
          var index = new Array(m),
              array = new Array(m);
          for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]);
          index.sort(function(i, j) { return array[j] - array[i]; });
          for (j = 0; j < m; ++j) array[j] = halfedges[index[j]];
          for (j = 0; j < m; ++j) halfedges[j] = array[j];
        }
      }
    }

    function clipCells(x0, y0, x1, y1) {
      var nCells = cells.length,
          iCell,
          cell,
          site,
          iHalfedge,
          halfedges,
          nHalfedges,
          start,
          startX,
          startY,
          end,
          endX,
          endY,
          cover = true;

      for (iCell = 0; iCell < nCells; ++iCell) {
        if (cell = cells[iCell]) {
          site = cell.site;
          halfedges = cell.halfedges;
          iHalfedge = halfedges.length;

          // Remove any dangling clipped edges.
          while (iHalfedge--) {
            if (!edges[halfedges[iHalfedge]]) {
              halfedges.splice(iHalfedge, 1);
            }
          }

          // Insert any border edges as necessary.
          iHalfedge = 0, nHalfedges = halfedges.length;
          while (iHalfedge < nHalfedges) {
            end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1];
            start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1];
            if (Math.abs(endX - startX) > epsilon || Math.abs(endY - startY) > epsilon) {
              halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(site, end,
                  Math.abs(endX - x0) < epsilon && y1 - endY > epsilon ? [x0, Math.abs(startX - x0) < epsilon ? startY : y1]
                  : Math.abs(endY - y1) < epsilon && x1 - endX > epsilon ? [Math.abs(startY - y1) < epsilon ? startX : x1, y1]
                  : Math.abs(endX - x1) < epsilon && endY - y0 > epsilon ? [x1, Math.abs(startX - x1) < epsilon ? startY : y0]
                  : Math.abs(endY - y0) < epsilon && endX - x0 > epsilon ? [Math.abs(startY - y0) < epsilon ? startX : x0, y0]
                  : null)) - 1);
              ++nHalfedges;
            }
          }

          if (nHalfedges) cover = false;
        }
      }

      // If there weren’t any edges, have the closest site cover the extent.
      // It doesn’t matter which corner of the extent we measure!
      if (cover) {
        var dx, dy, d2, dc = Infinity;

        for (iCell = 0, cover = null; iCell < nCells; ++iCell) {
          if (cell = cells[iCell]) {
            site = cell.site;
            dx = site[0] - x0;
            dy = site[1] - y0;
            d2 = dx * dx + dy * dy;
            if (d2 < dc) dc = d2, cover = cell;
          }
        }

        if (cover) {
          var v00 = [x0, y0], v01 = [x0, y1], v11 = [x1, y1], v10 = [x1, y0];
          cover.halfedges.push(
            edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1,
            edges.push(createBorderEdge(site, v01, v11)) - 1,
            edges.push(createBorderEdge(site, v11, v10)) - 1,
            edges.push(createBorderEdge(site, v10, v00)) - 1
          );
        }
      }

      // Lastly delete any cells with no edges; these were entirely clipped.
      for (iCell = 0; iCell < nCells; ++iCell) {
        if (cell = cells[iCell]) {
          if (!cell.halfedges.length) {
            delete cells[iCell];
          }
        }
      }
    }

    var circlePool = [];

    var firstCircle;

    function Circle() {
      RedBlackNode(this);
      this.x =
      this.y =
      this.arc =
      this.site =
      this.cy = null;
    }

    function attachCircle(arc) {
      var lArc = arc.P,
          rArc = arc.N;

      if (!lArc || !rArc) return;

      var lSite = lArc.site,
          cSite = arc.site,
          rSite = rArc.site;

      if (lSite === rSite) return;

      var bx = cSite[0],
          by = cSite[1],
          ax = lSite[0] - bx,
          ay = lSite[1] - by,
          cx = rSite[0] - bx,
          cy = rSite[1] - by;

      var d = 2 * (ax * cy - ay * cx);
      if (d >= -epsilon2) return;

      var ha = ax * ax + ay * ay,
          hc = cx * cx + cy * cy,
          x = (cy * ha - ay * hc) / d,
          y = (ax * hc - cx * ha) / d;

      var circle = circlePool.pop() || new Circle;
      circle.arc = arc;
      circle.site = cSite;
      circle.x = x + bx;
      circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y); // y bottom

      arc.circle = circle;

      var before = null,
          node = circles._;

      while (node) {
        if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) {
          if (node.L) node = node.L;
          else { before = node.P; break; }
        } else {
          if (node.R) node = node.R;
          else { before = node; break; }
        }
      }

      circles.insert(before, circle);
      if (!before) firstCircle = circle;
    }

    function detachCircle(arc) {
      var circle = arc.circle;
      if (circle) {
        if (!circle.P) firstCircle = circle.N;
        circles.remove(circle);
        circlePool.push(circle);
        RedBlackNode(circle);
        arc.circle = null;
      }
    }

    var beachPool = [];

    function Beach() {
      RedBlackNode(this);
      this.edge =
      this.site =
      this.circle = null;
    }

    function createBeach(site) {
      var beach = beachPool.pop() || new Beach;
      beach.site = site;
      return beach;
    }

    function detachBeach(beach) {
      detachCircle(beach);
      beaches.remove(beach);
      beachPool.push(beach);
      RedBlackNode(beach);
    }

    function removeBeach(beach) {
      var circle = beach.circle,
          x = circle.x,
          y = circle.cy,
          vertex = [x, y],
          previous = beach.P,
          next = beach.N,
          disappearing = [beach];

      detachBeach(beach);

      var lArc = previous;
      while (lArc.circle
          && Math.abs(x - lArc.circle.x) < epsilon
          && Math.abs(y - lArc.circle.cy) < epsilon) {
        previous = lArc.P;
        disappearing.unshift(lArc);
        detachBeach(lArc);
        lArc = previous;
      }

      disappearing.unshift(lArc);
      detachCircle(lArc);

      var rArc = next;
      while (rArc.circle
          && Math.abs(x - rArc.circle.x) < epsilon
          && Math.abs(y - rArc.circle.cy) < epsilon) {
        next = rArc.N;
        disappearing.push(rArc);
        detachBeach(rArc);
        rArc = next;
      }

      disappearing.push(rArc);
      detachCircle(rArc);

      var nArcs = disappearing.length,
          iArc;
      for (iArc = 1; iArc < nArcs; ++iArc) {
        rArc = disappearing[iArc];
        lArc = disappearing[iArc - 1];
        setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex);
      }

      lArc = disappearing[0];
      rArc = disappearing[nArcs - 1];
      rArc.edge = createEdge(lArc.site, rArc.site, null, vertex);

      attachCircle(lArc);
      attachCircle(rArc);
    }

    function addBeach(site) {
      var x = site[0],
          directrix = site[1],
          lArc,
          rArc,
          dxl,
          dxr,
          node = beaches._;

      while (node) {
        dxl = leftBreakPoint(node, directrix) - x;
        if (dxl > epsilon) node = node.L; else {
          dxr = x - rightBreakPoint(node, directrix);
          if (dxr > epsilon) {
            if (!node.R) {
              lArc = node;
              break;
            }
            node = node.R;
          } else {
            if (dxl > -epsilon) {
              lArc = node.P;
              rArc = node;
            } else if (dxr > -epsilon) {
              lArc = node;
              rArc = node.N;
            } else {
              lArc = rArc = node;
            }
            break;
          }
        }
      }

      createCell(site);
      var newArc = createBeach(site);
      beaches.insert(lArc, newArc);

      if (!lArc && !rArc) return;

      if (lArc === rArc) {
        detachCircle(lArc);
        rArc = createBeach(lArc.site);
        beaches.insert(newArc, rArc);
        newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site);
        attachCircle(lArc);
        attachCircle(rArc);
        return;
      }

      if (!rArc) { // && lArc
        newArc.edge = createEdge(lArc.site, newArc.site);
        return;
      }

      // else lArc !== rArc
      detachCircle(lArc);
      detachCircle(rArc);

      var lSite = lArc.site,
          ax = lSite[0],
          ay = lSite[1],
          bx = site[0] - ax,
          by = site[1] - ay,
          rSite = rArc.site,
          cx = rSite[0] - ax,
          cy = rSite[1] - ay,
          d = 2 * (bx * cy - by * cx),
          hb = bx * bx + by * by,
          hc = cx * cx + cy * cy,
          vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay];

      setEdgeEnd(rArc.edge, lSite, rSite, vertex);
      newArc.edge = createEdge(lSite, site, null, vertex);
      rArc.edge = createEdge(site, rSite, null, vertex);
      attachCircle(lArc);
      attachCircle(rArc);
    }

    function leftBreakPoint(arc, directrix) {
      var site = arc.site,
          rfocx = site[0],
          rfocy = site[1],
          pby2 = rfocy - directrix;

      if (!pby2) return rfocx;

      var lArc = arc.P;
      if (!lArc) return -Infinity;

      site = lArc.site;
      var lfocx = site[0],
          lfocy = site[1],
          plby2 = lfocy - directrix;

      if (!plby2) return lfocx;

      var hl = lfocx - rfocx,
          aby2 = 1 / pby2 - 1 / plby2,
          b = hl / plby2;

      if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx;

      return (rfocx + lfocx) / 2;
    }

    function rightBreakPoint(arc, directrix) {
      var rArc = arc.N;
      if (rArc) return leftBreakPoint(rArc, directrix);
      var site = arc.site;
      return site[1] === directrix ? site[0] : Infinity;
    }

    var epsilon = 1e-6;
    var epsilon2 = 1e-12;
    var beaches;
    var cells;
    var circles;
    var edges;

    function triangleArea(a, b, c) {
      return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]);
    }

    function lexicographic(a, b) {
      return b[1] - a[1]
          || b[0] - a[0];
    }

    function Diagram(sites, extent) {
      var site = sites.sort(lexicographic).pop(),
          x,
          y,
          circle;

      edges = [];
      cells = new Array(sites.length);
      beaches = new RedBlackTree;
      circles = new RedBlackTree;

      while (true) {
        circle = firstCircle;
        if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) {
          if (site[0] !== x || site[1] !== y) {
            addBeach(site);
            x = site[0], y = site[1];
          }
          site = sites.pop();
        } else if (circle) {
          removeBeach(circle.arc);
        } else {
          break;
        }
      }

      sortCellHalfedges();

      if (extent) {
        var x0 = +extent[0][0],
            y0 = +extent[0][1],
            x1 = +extent[1][0],
            y1 = +extent[1][1];
        clipEdges(x0, y0, x1, y1);
        clipCells(x0, y0, x1, y1);
      }

      this.edges = edges;
      this.cells = cells;

      beaches =
      circles =
      edges =
      cells = null;
    }

    Diagram.prototype = {
      constructor: Diagram,

      polygons: function() {
        var edges = this.edges;

        return this.cells.map(function(cell) {
          var polygon = cell.halfedges.map(function(i) { return cellHalfedgeStart(cell, edges[i]); });
          polygon.data = cell.site.data;
          return polygon;
        });
      },

      triangles: function() {
        var triangles = [],
            edges = this.edges;

        this.cells.forEach(function(cell, i) {
          if (!(m = (halfedges = cell.halfedges).length)) return;
          var site = cell.site,
              halfedges,
              j = -1,
              m,
              s0,
              e1 = edges[halfedges[m - 1]],
              s1 = e1.left === site ? e1.right : e1.left;

          while (++j < m) {
            s0 = s1;
            e1 = edges[halfedges[j]];
            s1 = e1.left === site ? e1.right : e1.left;
            if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) {
              triangles.push([site.data, s0.data, s1.data]);
            }
          }
        });

        return triangles;
      },

      links: function() {
        return this.edges.filter(function(edge) {
          return edge.right;
        }).map(function(edge) {
          return {
            source: edge.left.data,
            target: edge.right.data
          };
        });
      },

      find: function(x, y, radius) {
        var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell;

        // Use the previously-found cell, or start with an arbitrary one.
        while (!(cell = that.cells[i1])) if (++i1 >= n) return null;
        var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy;

        // Traverse the half-edges to find a closer cell, if any.
        do {
          cell = that.cells[i0 = i1], i1 = null;
          cell.halfedges.forEach(function(e) {
            var edge = that.edges[e], v = edge.left;
            if ((v === cell.site || !v) && !(v = edge.right)) return;
            var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy;
            if (v2 < d2) d2 = v2, i1 = v.index;
          });
        } while (i1 !== null);

        that._found = i0;

        return radius == null || d2 <= radius * radius ? cell.site : null;
      }
    };

    function voronoi() {
      var x$$1 = x,
          y$$1 = y,
          extent = null;

      function voronoi(data) {
        return new Diagram(data.map(function(d, i) {
          var s = [Math.round(x$$1(d, i, data) / epsilon) * epsilon, Math.round(y$$1(d, i, data) / epsilon) * epsilon];
          s.index = i;
          s.data = d;
          return s;
        }), extent);
      }

      voronoi.polygons = function(data) {
        return voronoi(data).polygons();
      };

      voronoi.links = function(data) {
        return voronoi(data).links();
      };

      voronoi.triangles = function(data) {
        return voronoi(data).triangles();
      };

      voronoi.x = function(_) {
        return arguments.length ? (x$$1 = typeof _ === "function" ? _ : constant(+_), voronoi) : x$$1;
      };

      voronoi.y = function(_) {
        return arguments.length ? (y$$1 = typeof _ === "function" ? _ : constant(+_), voronoi) : y$$1;
      };

      voronoi.extent = function(_) {
        return arguments.length ? (extent = _ == null ? null : [[+_[0][0], +_[0][1]], [+_[1][0], +_[1][1]]], voronoi) : extent && [[extent[0][0], extent[0][1]], [extent[1][0], extent[1][1]]];
      };

      voronoi.size = function(_) {
        return arguments.length ? (extent = _ == null ? null : [[0, 0], [+_[0], +_[1]]], voronoi) : extent && [extent[1][0] - extent[0][0], extent[1][1] - extent[0][1]];
      };

      return voronoi;
    }

    /**
     * @private
     * @param {Array<Array<number>>} coords representing a polygon
     * @returns {Feature<Polygon>} polygon
     */
    function coordsToPolygon(coords) {
        coords = coords.slice();
        coords.push(coords[0]);
        return polygon([coords]);
    }

    /**
     * Takes a FeatureCollection of points, and a bounding box, and returns a FeatureCollection
     * of Voronoi polygons.
     *
     * The Voronoi algorithim used comes from the d3-voronoi package.
     *
     * @name voronoi
     * @param {FeatureCollection<Point>} points to find the Voronoi polygons around.
     * @param {Object} [options={}] Optional parameters
     * @param {number[]} [options.bbox=[-180, -85, 180, -85]] clipping rectangle, in [minX, minY, maxX, MaxY] order.
     * @pararm {Boolean} [options.addPropertiesToPolygons=false] add properties to the polygons from the points
     * @returns {FeatureCollection<Polygon>} a set of polygons, one per input point.
     * @example
     * var options = {
     *   bbox: [-70, 40, -60, 60]
     * };
     * var points = turf.randomPoint(100, options);
     * var voronoiPolygons = turf.voronoi(points, options);
     *
     * //addToMap
     * var addToMap = [voronoiPolygons, points];
     */
    function voronoi$1(points$$1, options) {
        // Optional params
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var bbox = options.bbox || [-180, -85, 180, 85];

        // Input Validation
        if (!points$$1) throw new Error('points is required');
        if (!Array.isArray(bbox)) throw new Error('bbox is invalid');
        collectionOf(points$$1, 'Point', 'points');

        // Main
        var fc = featureCollection(
            voronoi()
                .x(function (feature$$1) { return feature$$1.geometry.coordinates[0]; })
                .y(function (feature$$1) { return feature$$1.geometry.coordinates[1]; })
                .extent([[bbox[0], bbox[1]], [bbox[2], bbox[3]]])
                .polygons(points$$1.features)
                .map(coordsToPolygon)
        );
        if (options.addPropertiesToPolygons) {
            fc.features.forEach(function (polygon$$1, i) {
                polygon$$1.properties = JSON.parse(JSON.stringify(points$$1.features[i].properties));
            });
        }
        return fc;
    }

    /**
     * Takes a {@link Point} and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision.
     *
     * @param {Coord} center center point
     * @param {number} xSemiAxis semi (major) axis of the ellipse along the x-axis
     * @param {number} ySemiAxis semi (minor) axis of the ellipse along the y-axis
     * @param {Object} [options={}] Optional parameters
     * @param {number} [options.angle=0] angle of rotation (along the vertical axis), from North in decimal degrees, negative clockwise
     * @param {Coord} [options.pivot='origin'] point around which the rotation will be performed
     * @param {number} [options.steps=64] number of steps
     * @param {string} [options.units='kilometers'] unit of measurement for axes
     * @param {Object} [options.properties={}] properties
     * @returns {Feature<Polygon>} ellipse polygon
     * @example
     * var center = [-75, 40];
     * var xSemiAxis = 5;
     * var ySemiAxis = 2;
     * var ellipse = turf.ellipse(center, xSemiAxis, ySemiAxis);
     *
     * //addToMap
     * var addToMap = [turf.point(center), ellipse]
     */
    function ellipse(center, xSemiAxis, ySemiAxis, options) {
        // Optional params
        options = options || {};
        var steps = options.steps || 64;
        var units = options.units || 'kilometers';
        var angle = options.angle || 0;
        var pivot = options.pivot || center;
        var properties = options.properties || center.properties || {};

        // validation
        if (!center) throw new Error('center is required');
        if (!xSemiAxis) throw new Error('xSemiAxis is required');
        if (!ySemiAxis) throw new Error('ySemiAxis is required');
        if (!isObject(options)) throw new Error('options must be an object');
        if (!isNumber(steps)) throw new Error('steps must be a number');
        if (!isNumber(angle)) throw new Error('angle must be a number');

        var centerCoords = getCoord(center);
        if (units === 'degrees') {
            var angleRad = degreesToRadians(angle);
        } else {
            xSemiAxis = rhumbDestination(center, xSemiAxis, 90, {units: units});
            ySemiAxis = rhumbDestination(center, ySemiAxis, 0, {units: units});
            xSemiAxis = getCoord(xSemiAxis)[0] - centerCoords[0];
            ySemiAxis = getCoord(ySemiAxis)[1] - centerCoords[1];
        }

        var coordinates = [];
        for (var i = 0; i < steps; i += 1) {
            var stepAngle = i * -360 / steps;
            var x = ((xSemiAxis * ySemiAxis) / Math.sqrt(Math.pow(ySemiAxis, 2) + (Math.pow(xSemiAxis, 2) * Math.pow(getTanDeg(stepAngle), 2))));
            var y = ((xSemiAxis * ySemiAxis) / Math.sqrt(Math.pow(xSemiAxis, 2) + (Math.pow(ySemiAxis, 2) / Math.pow(getTanDeg(stepAngle), 2))));

            if (stepAngle < -90 && stepAngle >= -270) x = -x;
            if (stepAngle < -180 && stepAngle >= -360) y = -y;
            if (units === 'degrees') {
                var newx = x * Math.cos(angleRad) + y * Math.sin(angleRad);
                var newy = y * Math.cos(angleRad) - x * Math.sin(angleRad);
                x = newx;
                y = newy;
            }

            coordinates.push([x + centerCoords[0], y + centerCoords[1]]);
        }
        coordinates.push(coordinates[0]);
        if (units === 'degrees') {
            return polygon([coordinates], properties);
        } else {
            return transformRotate(polygon([coordinates], properties), angle, { pivot: pivot });
        }
    }

    /**
     * Get Tan Degrees
     *
     * @private
     * @param {number} deg Degrees
     * @returns {number} Tan Degrees
     */
    function getTanDeg(deg) {
        var rad = deg * Math.PI / 180;
        return Math.tan(rad);
    }

    /**
     * Takes a {@link Feature} or {@link FeatureCollection} and returns the mean center. Can be weighted.
     *
     * @name centerMean
     * @param {GeoJSON} geojson GeoJSON to be centered
     * @param {Object} [options={}] Optional parameters
     * @param {Object} [options.properties={}] Translate GeoJSON Properties to Point
     * @param {Object} [options.bbox={}] Translate GeoJSON BBox to Point
     * @param {Object} [options.id={}] Translate GeoJSON Id to Point
     * @param {string} [options.weight] the property name used to weight the center
     * @returns {Feature<Point>} a Point feature at the mean center point of all input features
     * @example
     * var features = turf.featureCollection([
     *   turf.point([-97.522259, 35.4691], {value,
     *   turf.point([-97.502754, 35.463455], {value,
     *   turf.point([-97.508269, 35.463245], {value{weight, options);
     *
     * //addToMap
     * var addToMap = [features, mean]
     * mean.properties['marker-size'] = 'large';
     * mean.properties['marker-color'] = '#000';
     */
    function centerMean(geojson, options) {
        options = checkIfOptionsExist(options);

        var weightTerm = options.weight;
        let sumXs = 0;
        let sumYs = 0;
        let sumNs = 0;
        geomEach(geojson, function (geom, featureIndex, properties) {
            var weight = properties[weightTerm];
            weight = (weight === undefined || weight === null) ? 1 : weight;
            if (!isNumber(weight)) throw new Error('weight value must be a number for feature index ' + featureIndex);
            weight = Number(weight);
            if (weight > 0) {
                coordEach(geom, function (coord) {
                    sumXs += coord[0] * weight;
                    sumYs += coord[1] * weight;
                    sumNs += weight;
                });
            }
        });
        return point([sumXs / sumNs, sumYs / sumNs], options.properties);
    }

    /**
     * Takes a {@link FeatureCollection} of points and calculates the median center,
     * algorithimically. The median center is understood as the point that is
     * requires the least total travel from all other points.
     *
     * Turfjs has four different functions for calculating the center of a set of
     * data. Each is useful depending on circumstance.
     *
     * `../center` finds the simple center of a dataset, by finding the
     * midpoint between the extents of the data. That is, it divides in half the
     * farthest east and farthest west point as well as the farthest north and
     * farthest south.
     *
     * `../center-of-mass` imagines that the dataset is a sheet of paper.
     * The center of mass is where the sheet would balance on a fingertip.
     *
     * `../center-mean` takes the averages of all the coordinates and
     * produces a value that respects that. Unlike `../center`, it is
     * sensitive to clusters and outliers. It lands in the statistical middle of a
     * dataset, not the geographical. It can also be weighted, meaning certain
     * points are more important than others.
     *
     * `../center-median` takes the mean center and tries to find, iteratively,
     * a new point that requires the least amount of travel from all the points in
     * the dataset. It is not as sensitive to outliers as `../center-mean`, but it is
     * attracted to clustered data. It, too, can be weighted.
     *
     * **Bibliography**
     *
     * Harold W. Kuhn and Robert E. Kuenne, “An Efficient Algorithm for the
     * Numerical Solution of the Generalized Weber Problem in Spatial
     * Economics,” _Journal of Regional Science_ 4, no. 2 (1962),
     * doi{@link https, Gerald M. Barber, and David L. Rigby, _Elementary
     * Statistics for Geographers_, 3rd ed., New York, 2009, 150–151.
     *
     * @name centerMedian
     * @param {FeatureCollection<any>} features Any GeoJSON Feature Collection
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.weight] the property name used to weight the center
     * @param {number} [options.tolerance=0.001] the difference in distance between candidate medians at which point the algorighim stops iterating.
     * @param {number} [options.counter=10] how many attempts to find the median, should the tolerance be insufficient.
     * @returns {Feature<Point>} The median center of the collection
     * @example
     * var points = turf.points([[0, 0], [1, 0], [0, 1], [5, 8]]);
     * var medianCenter = turf.centerMedian(points);
     *
     * //addToMap
     * var addToMap = [points, medianCenter]
     */
    function centerMedian(features, options) {

        // Optional params
        options = checkIfOptionsExist(options);

        var counter = options.counter || 10;
        if (!isNumber(counter)) throw new Error('counter must be a number');
        var weightTerm = options.weight;


        // Calculate mean center:
        var meanCenter = centerMean(features, {weight: options.weight});

        // Calculate center of every feature:
        var centroids = featureCollection([]);
        featureEach(features, function (feature$$1) {
            centroids.features.push(centroid(feature$$1, {properties: {weight: feature$$1.properties[weightTerm]}}));
        });

        centroids.properties = {
            tolerance: options.tolerance,
            medianCandidates: []
        };
        return findMedian(meanCenter.geometry.coordinates, [0, 0], centroids, counter);
    }

    /**
     * Recursive function to find new candidate medians.
     *
     * @private
     * @param {Position} candidateMedian current candidate median
     * @param {Position} previousCandidate the previous candidate median
     * @param {FeatureCollection<Point>} centroids the collection of centroids whose median we are determining
     * @param {number} counter how many attempts to try before quitting.
     * @returns {Feature<Point>} the median center of the dataset.
     */
    function findMedian(candidateMedian, previousCandidate, centroids, counter) {
        var tolerance = centroids.properties.tolerance || 0.001;
        var candidateXsum = 0;
        var candidateYsum = 0;
        var kSum = 0;
        var centroidCount = 0;
        featureEach(centroids, function (theCentroid) {
            var weightValue = theCentroid.properties.weight;
            var weight = (weightValue === undefined || weightValue === null) ? 1 : weightValue;
            weight = Number(weight);
            if (!isNumber(weight)) throw new Error('weight value must be a number');
            if (weight > 0) {
                centroidCount += 1;
                var distanceFromCandidate = weight * distance(theCentroid, candidateMedian);
                if (distanceFromCandidate === 0) distanceFromCandidate = 1;
                var k = weight / distanceFromCandidate;
                candidateXsum += theCentroid.geometry.coordinates[0] * k;
                candidateYsum += theCentroid.geometry.coordinates[1] * k;
                kSum += k;
            }
        });
        if (centroidCount < 1) throw new Error('no features to measure');
        var candidateX = candidateXsum / kSum;
        var candidateY = candidateYsum / kSum;
        if (centroidCount === 1 || counter === 0 || (Math.abs(candidateX - previousCandidate[0]) < tolerance && Math.abs(candidateY - previousCandidate[1]) < tolerance)) {
            return point([candidateX, candidateY], {medianCandidates: centroids.properties.medianCandidates});
        } else {
            centroids.properties.medianCandidates.push([candidateX, candidateY]);
            return findMedian([candidateX, candidateY], candidateMedian, centroids, counter - 1);
        }
    }

    /**
     * Takes a {@link FeatureCollection} and returns a standard deviational ellipse,
     * also known as a “directional distribution.” The standard deviational ellipse
     * aims to show the direction and the distribution of a dataset by drawing
     * an ellipse that contains about one standard deviation’s worth (~ 70%) of the
     * data.
     *
     * This module mirrors the functionality of [Directional Distribution](http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-statistics-toolbox/directional-distribution.htm)
     * in ArcGIS and the [QGIS Standard Deviational Ellipse Plugin](http://arken.nmbu.no/~havatv/gis/qgisplugins/SDEllipse/)
     *
     * **Bibliography**
     *
     * • Robert S. Yuill, “The Standard Deviational Ellipse; An Updated Tool for
     * Spatial Description,” _Geografiska Annaler_ 53, no. 1 (1971): 28–39,
     * doi:{@link https://doi.org/10.2307/490885|10.2307/490885}.
     *
     * • Paul Hanly Furfey, “A Note on Lefever’s “Standard Deviational Ellipse,”
     * _American Journal of Sociology_ 33, no. 1 (1927): 94—98,
     * doi:{@link https://doi.org/10.1086/214336|10.1086/214336}.
     *
     *
     * @name standardDeviationalEllipse
     * @param {FeatureCollection<Point>} points GeoJSON points
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.weight] the property name used to weight the center
     * @param {number} [options.steps=64] number of steps for the polygon
     * @param {Object} [options.properties={}] properties to pass to the resulting ellipse
     * @returns {Feature<Polygon>} an elliptical Polygon that includes approximately 1 SD of the dataset within it.
     * @example
     *
     * var bbox = [-74, 40.72, -73.98, 40.74];
     * var points = turf.randomPoint(400, {bbox: bbox});
     * var sdEllipse = turf.standardDeviationalEllipse(points);
     *
     * //addToMap
     * var addToMap = [points, sdEllipse];
     *
     */
    function standardDeviationalEllipse(points$$1, options) {
        // Optional params
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var steps = options.steps || 64;
        var weightTerm = options.weight;
        var properties = options.properties || {};

        // Validation:
        if (!isNumber(steps)) throw new Error('steps must be a number');
        if (!isObject(properties)) throw new Error('properties must be a number');

        // Calculate mean center & number of features:
        var numberOfFeatures = coordAll(points$$1).length;
        var meanCenter = centerMean(points$$1, {weight: weightTerm});

        // Calculate angle of rotation:
        // [X, Y] = mean center of all [x, y].
        // theta = arctan( (A + B) / C )
        // A = sum((x - X)^2) - sum((y - Y)^2)
        // B = sqrt(A^2 + 4(sum((x - X)(y - Y))^2))
        // C = 2(sum((x - X)(y - Y)))

        var xDeviationSquaredSum = 0;
        var yDeviationSquaredSum = 0;
        var xyDeviationSum = 0;

        featureEach(points$$1, function (point$$1) {
            var weight = point$$1.properties[weightTerm] || 1;
            var deviation = getDeviations(getCoords(point$$1), getCoords(meanCenter));
            xDeviationSquaredSum += Math.pow(deviation.x, 2) * weight;
            yDeviationSquaredSum += Math.pow(deviation.y, 2) * weight;
            xyDeviationSum += deviation.x * deviation.y * weight;
        });

        var bigA = xDeviationSquaredSum - yDeviationSquaredSum;
        var bigB = Math.sqrt(Math.pow(bigA, 2) + 4 * Math.pow(xyDeviationSum, 2));
        var bigC = 2 * xyDeviationSum;
        var theta = Math.atan((bigA + bigB) / bigC);
        var thetaDeg = theta * 180 / Math.PI;

        // Calculate axes:
        // sigmaX = sqrt((1 / n - 2) * sum((((x - X) * cos(theta)) - ((y - Y) * sin(theta)))^2))
        // sigmaY = sqrt((1 / n - 2) * sum((((x - X) * sin(theta)) - ((y - Y) * cos(theta)))^2))
        var sigmaXsum = 0;
        var sigmaYsum = 0;
        var weightsum = 0;
        featureEach(points$$1, function (point$$1) {
            var weight = point$$1.properties[weightTerm] || 1;
            var deviation = getDeviations(getCoords(point$$1), getCoords(meanCenter));
            sigmaXsum += Math.pow((deviation.x * Math.cos(theta)) - (deviation.y * Math.sin(theta)), 2) * weight;
            sigmaYsum += Math.pow((deviation.x * Math.sin(theta)) + (deviation.y * Math.cos(theta)), 2) * weight;
            weightsum += weight;
        });

        var sigmaX = Math.sqrt(2 * sigmaXsum / weightsum);
        var sigmaY = Math.sqrt(2 * sigmaYsum / weightsum);

        var theEllipse = ellipse(meanCenter, sigmaX, sigmaY, {units: 'degrees', angle: thetaDeg, steps: steps, properties: properties});
        var pointsWithinEllipse = pointsWithinPolygon(points$$1, featureCollection([theEllipse]));
        var standardDeviationalEllipseProperties = {
            meanCenterCoordinates: getCoords(meanCenter),
            semiMajorAxis: sigmaX,
            semiMinorAxis: sigmaY,
            numberOfFeatures: numberOfFeatures,
            angle: thetaDeg,
            percentageWithinEllipse: 100 * coordAll(pointsWithinEllipse).length / numberOfFeatures
        };
        theEllipse.properties.standardDeviationalEllipse = standardDeviationalEllipseProperties;

        return theEllipse;
    }

    /**
     * Get x_i - X and y_i - Y
     *
     * @private
     * @param {Array} coordinates Array of [x_i, y_i]
     * @param {Array} center Array of [X, Y]
     * @returns {Object} { x: n, y: m }
     */
    function getDeviations(coordinates, center) {
        return {
            x: coordinates[0] - center[0],
            y: coordinates[1] - center[1]
        };
    }

    /**
     * Finds the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise)
     * angle with origin on the `startPoint-midPoint` segment, or its explementary angle if required.
     *
     * @name angle
     * @param {Coord} startPoint Start Point Coordinates
     * @param {Coord} midPoint Mid Point Coordinates
     * @param {Coord} endPoint End Point Coordinates
     * @param {Object} [options={}] Optional parameters
     * @param {boolean} [options.explementary=false] Returns the explementary angle instead (360 - angle)
     * @param {boolean} [options.mercator=false] if calculations should be performed over Mercator or WGS84 projection
     * @returns {number} Angle between the provided points, or its explementary.
     * @example
     * turf.angle([5, 5], [5, 6], [3, 4]);
     * //=45
     */
    function angle(startPoint, midPoint, endPoint, options) {
         options = checkIfOptionsExist(options);

        // Validation
        if (!startPoint) { throw new Error("startPoint is required"); }
        if (!midPoint) { throw new Error("midPoint is required"); }
        if (!endPoint) { throw new Error("endPoint is required"); }

        // Rename to shorter variables
        const A = startPoint;
        const O = midPoint;
        const B = endPoint;

        // Main
        const azimuthAO = bearingToAzimuth((options.mercator !== true) ? bearing(A, O) : rhumbBearing(A, O));
        const azimuthBO = bearingToAzimuth((options.mercator !== true) ? bearing(B, O) : rhumbBearing(B, O));
        const angleAO = Math.abs(azimuthAO - azimuthBO);

        // Explementary angle
        if (options.explementary === true) { return 360 - angleAO; }
        return angleAO;
    }

    /**
     * Smooths a {@link Polygon}. Based on [Chaikin's algorithm](http://graphics.cs.ucdavis.edu/education/CAGDNotes/Chaikins-Algorithm/Chaikins-Algorithm.html).
     * Warning: may create degenerate polygons.
     *
     * @name polygonSmooth
     * @param {FeatureCollection<Polygon>} inputPolys to smooth
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.iterations=1] THe number of times to smooth the polygon. A higher value means a smoother polygon.
     * @returns {FeatureCollection<Polygon>} FeatureCollection containing the smoothed polygon/poylgons
     * @example
     * var polygon = turf.polygon([[[11, 0], [22, 4], [31, 0], [31, 11], [21, 15], [11, 11], [11, 0]]]);
     *
     * var smoothed = turf.polygonSmooth(polygon)
     *
     * //addToMap
     * var addToMap = [smoothed, polygon];
     */
    function polygonSmooth(inputPolys, options) {
        var outPolys = [];
        // Optional parameters
        var iterations = options.iterations || 1;
        if (!inputPolys) throw new Error('inputPolys is required');

        geomEach(inputPolys, function (geom, geomIndex, properties) {
            var type = geom.type === 'Polygon' ? 'Polygon' : 'MultiPolygon';
            var outCoords = type === 'Polygon' ? [] : [[]];

            for (var i = 0; i < iterations; i++) {
                var tempOutput  = type === 'Polygon' ? [[]] : [[[]]];
                var poly = geom;
                if (i > 0) {
                    poly = type === 'Polygon' ? polygon(outCoords).geometry : multiPolygon(outCoords).geometry;
                }
                if (type === 'Polygon') processPolygon$2(poly, tempOutput);
                else processMultiPolygon(poly, tempOutput);
                outCoords = tempOutput.slice(0);
            }
            if (type === 'Polygon') outPolys.push(polygon(outCoords, properties));
            else outPolys.push(multiPolygon(outCoords, properties));
        });
        return featureCollection(outPolys);
    }

    /**
     * @private
     */
    function processPolygon$2(poly, tempOutput) {
        var prevGeomIndex = 0;
        var subtractCoordIndex = 0;
        coordEach(poly, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
            if (geometryIndex > prevGeomIndex) {
                prevGeomIndex = geometryIndex;
                subtractCoordIndex = coordIndex;
                tempOutput.push([]);
            }
            var realCoordIndex = coordIndex - subtractCoordIndex;
            var p1 = poly.coordinates[geometryIndex][realCoordIndex + 1];
            var p0x = currentCoord[0];
            var p0y = currentCoord[1];
            var p1x = p1[0];
            var p1y = p1[1];
            tempOutput[geometryIndex].push([0.75 * p0x + 0.25 * p1x, 0.75 * p0y + 0.25 * p1y]);
            tempOutput[geometryIndex].push([0.25 * p0x + 0.75 * p1x, 0.25 * p0y + 0.75 * p1y]);
        }, true);
        tempOutput.forEach(function (ring) {
            ring.push(ring[0]);
        });
    }

    /**
     * @private
     */
    function processMultiPolygon(poly, tempOutput) {
        var prevGeomIndex = 0;
        var subtractCoordIndex = 0;
        var prevMultiIndex = 0;
        coordEach(poly, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
            if (multiFeatureIndex > prevMultiIndex) {
                prevMultiIndex = multiFeatureIndex;
                subtractCoordIndex = coordIndex;
                tempOutput.push([[]]);
            }
            if (geometryIndex > prevGeomIndex) {
                prevGeomIndex = geometryIndex;
                subtractCoordIndex = coordIndex;
                tempOutput[multiFeatureIndex].push([]);
            }
            var realCoordIndex = coordIndex - subtractCoordIndex;
            var p1 = poly.coordinates[multiFeatureIndex][geometryIndex][realCoordIndex + 1];
            var p0x = currentCoord[0];
            var p0y = currentCoord[1];
            var p1x = p1[0];
            var p1y = p1[1];
            tempOutput[multiFeatureIndex][geometryIndex].push([0.75 * p0x + 0.25 * p1x, 0.75 * p0y + 0.25 * p1y]);
            tempOutput[multiFeatureIndex][geometryIndex].push([0.25 * p0x + 0.75 * p1x, 0.25 * p0y + 0.75 * p1y]);
        }, true);

        tempOutput.forEach(function (poly) {
          poly.forEach(function (ring) {
            ring.push(ring[0]);
          });
        });
    }

    /**
     * calcualte the Minkowski p-norm distance between two features.
     * @param {Point} feature1 point feature
     * @param {Point} feature2 point feature
     * @param {p} p p-norm 1=<p<=infinity 1: Manhattan distance 2: Euclidean distance
     * @returns {Number} the distance
     */
    function pNormDistance(feature1, feature2, p) {
        const coordinate1 = getCoord(feature1);
        const coordinate2 = getCoord(feature2);
        const xDiff = coordinate1[0] - coordinate2[0];
        const yDiff = coordinate1[1] - coordinate2[1];
        if (p === 1) {
            return Math.abs(xDiff) + Math.abs(yDiff);
        }
        return Math.pow((Math.pow(xDiff, p) + Math.pow(yDiff, p)), 1 / p);
    }

    /**
     *
     *
     * @name distanceWeight
     * @param {FeatureCollection<any>} fc FeatureCollection.
     * @param {Object} [options] option object.
     * @param {number} [options.threshold=10000] If the distance between neighbor and
     * target features is greater than threshold, the weight of that neighbor is 0.
     * @param {number} [options.p=2] Minkowski p-norm distance parameter.
     * 1: Manhattan distance. 2: Euclidean distance. 1=<p<=infinity.
     * @param {boolean} [options.binary=false] If true, weight=1 if d <= threshold otherwise weight=0.
     *  If false, weight=Math.pow(d, alpha).
     * @param {number} [options.alpha=-1] distance decay parameter.
     * A big value means the weight decay quickly as distance increases.
     * @param {boolean} [options.standardization=false] row standardization.
     * @returns {Array<Array<number>>} distance weight matrix.
     * @example
     *
     * var bbox = [-65, 40, -63, 42];
     * var dataset = turf.randomPoint(100, { bbox: bbox });
     * var result = turf.distanceWeight(dataset);
     */
    function distanceWeight(fc, options) {

        options = options || {};
        const threshold = options.threshold || 10000;
        const p = options.p || 2;
        const binary = options.binary || false;
        const alpha = options.alpha || -1;
        const rowTransform = options.standardization || false;

        const features = [];
        featureEach(fc, function (feature) {
            features.push(centroid(feature));
        });

        // computing the distance between the features
        const weights = [];
        for (let i = 0; i < features.length; i++) {
            weights[i] = [];
        }

        for (let i = 0; i < features.length; i++) {
            for (let j = i; j < features.length; j++) {
                if (i === j) {
                    weights[i][j] = 0;
                }
                const dis = pNormDistance(features[i], features[j], p);
                weights[i][j] = dis;
                weights[j][i] = dis;
            }
        }

        // binary or distance decay
        for (let i = 0; i < features.length; i++) {
            for (let j = 0; j < features.length; j++) {
                const dis = weights[i][j];
                if (dis === 0) {
                    continue;
                }
                if (binary) {
                    if (dis <= threshold) {
                        weights[i][j] = 1.0;
                    } else {
                        weights[i][j] = 0.0;
                    }
                } else {
                    if (dis <= threshold) { //eslint-disable-line
                        weights[i][j] = Math.pow(dis, alpha);
                    } else {
                        weights[i][j] = 0.0;
                    }
                }
            }
        }

        if (rowTransform) {
            for (let i = 0; i < features.length; i++) {
                const rowSum = weights[i].reduce(function (sum, currentVal) {
                    return sum + currentVal;
                }, 0);
                for (let j = 0; j < features.length; j++) {
                    weights[i][j] = weights[i][j] / rowSum;
                }
            }
        }

        return weights;

    }

    /**
     * Moran's I measures patterns of attribute values associated with features.
     * The method reveal whether similar values tend to occur near each other,
     * or whether high or low values are interspersed.
     *
     * Moran's I > 0 means a clusterd pattern.
     * Moran's I < 0 means a dispersed pattern.
     * Moran's I = 0 means a random pattern.
     *
     * In order to test the significance of the result. The z score is calculated.
     * A positive enough z-score (ex. >1.96) indicates clustering,
     * while a negative enough z-score (ex. <-1.96) indicates a dispersed pattern.
     *
     * the z-score can be calculated based on a normal or random assumption.
     *
     * **Bibliography***
     *
     * 1. [Moran's I](https://en.wikipedia.org/wiki/Moran%27s_I)
     *
     * 2. [pysal](http://pysal.readthedocs.io/en/latest/index.html)
     *
     * 3. Andy Mitchell, The ESRI Guide to GIS Analysis Volume 2: Spatial Measurements & Statistics.
     *
     * @name moranIndex
     * @param {FeatureCollection<any>} fc
     * @param {Object} options
     * @param {string} options.inputField the property name, must contain numeric values
     * @param {number} [options.threshold=100000] the distance threshold
     * @param {number} [options.p=2] the Minkowski p-norm distance parameter
     * @param {boolean} [options.binary=false] whether transfrom the distance to binary
     * @param {number} [options.alpha=-1] the distance decay parameter
     * @param {boolean} [options.standardization=true] wheter row standardization the distance
     * @returns {MoranIndex}
     * @example
     *
     * const bbox = [-65, 40, -63, 42];
     * const dataset = turf.randomPoint(100, { bbox: bbox });
     *
     * const result = turf.moranIndex(dataset, {
     *   inputField: 'CRIME',
     * });
     */

    function index$6(fc, options){

        const inputField = options.inputField;
        const threshold = options.threshold || 100000;
        const p = options.p || 2;
        const binary = options.binary || false;
        const alpha = options.alpha || -1;
        const standardization = options.standardization || true;

        const weight = distanceWeight(fc, {
            alpha,
            binary,
            p,
            standardization,
            threshold,
        });

        const y = [];
        featureEach(fc, function (feature) {
            const feaProperties = feature.properties || {};
            // validate inputField exists
            y.push(feaProperties[inputField]);
        });

        const yMean = mean(y);
        const yVar = variance(y);
        let weightSum = 0;
        let s0 = 0;
        let s1 = 0;
        let s2 = 0;
        const n = weight.length;
        // validate y.length is the same as weight.length
        for (let i = 0; i < n; i++) {
            let subS2 = 0;
            for (let j = 0; j < n; j++) {
                weightSum += weight[i][j] * (y[i] - yMean) * (y[j] - yMean);
                s0 += weight[i][j];
                s1 += Math.pow((weight[i][j] + weight[j][i]), 2);
                subS2 += weight[i][j] + weight[j][i];
            }
            s2 += Math.pow(subS2, 2);
        }
        s1 = 0.5 * s1;

        const moranIndex = weightSum / s0 / yVar;
        const expectedMoranIndex = -1 / (n - 1);
        const vNum = (n * n) * s1 - n * s2 + 3 * (s0 * s0);
        const vDen = (n - 1) * (n + 1) * (s0 * s0);
        const vNorm = vNum / vDen - (expectedMoranIndex * expectedMoranIndex);
        const stdNorm = Math.sqrt(vNorm);
        const zNorm = (moranIndex - expectedMoranIndex) / stdNorm;

        return {
            expectedMoranIndex,
            moranIndex,
            stdNorm,
            zNorm,
        };

    }

    /**
     * get mean of a list
     * @param {number[]} y
     * @returns {number}
     *
     */
    function mean(y) {
        let sum = 0;
        for (const item of y) {
            sum += item;
        }
        return sum / y.length;
    }
    /**
     * get variance of a list
     * @param {number[]} y
     * @returns {number}
     *
     */
    function variance(y) {
        const yMean = mean(y);
        let sum = 0;
        for (const item of y) {
            sum += Math.pow(item - yMean, 2);
        }
        return sum / y.length;
    }

    /**
     * @typedef {Object} MoranIndex
     * @property {number} moranIndex the moran's Index of the observed feature set
     * @property {number} expectedMoranIndex the moran's Index of the random distribution
     * @property {number} stdNorm the standard devitaion of the random distribution
     * @property {number} zNorm the z-score of the observe samples with regard to the random distribution
     */

    /**
     * Converts a WGS84 GeoJSON object into Mercator (EPSG:900913) projection
     *
     * @name toMercator
     * @param {GeoJSON|Position} geojson WGS84 GeoJSON object
     * @param {Object} [options] Optional parameters
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} Projected GeoJSON
     * @example
     * var pt = turf.point([-71,41]);
     * var converted = turf.toMercator(pt);
     *
     * //addToMap
     * var addToMap = [pt, converted];
     */
    function toMercator(geojson, options) {
        return convert(geojson, 'mercator', options);
    }

    /**
     * Converts a Mercator (EPSG:900913) GeoJSON object into WGS84 projection
     *
     * @name toWgs84
     * @param {GeoJSON|Position} geojson Mercator GeoJSON object
     * @param {Object} [options] Optional parameters
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} Projected GeoJSON
     * @example
     * var pt = turf.point([-7903683.846322424, 5012341.663847514]);
     * var converted = turf.toWgs84(pt);
     *
     * //addToMap
     * var addToMap = [pt, converted];
     */
    function toWgs84(geojson, options) {
        return convert(geojson, 'wgs84', options);
    }


    /**
     * Converts a GeoJSON coordinates to the defined `projection`
     *
     * @private
     * @param {GeoJSON} geojson GeoJSON Feature or Geometry
     * @param {string} projection defines the projection system to convert the coordinates to
     * @param {Object} [options] Optional parameters
     * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
     * @returns {GeoJSON} Converted GeoJSON
     */
    function convert(geojson, projection, options) {
        // Optional parameters
        options = options || {};
        var mutate = options.mutate;

        // Validation
        if (!geojson) throw new Error('geojson is required');

        // Handle Position
        if (Array.isArray(geojson) && isNumber(geojson[0])) geojson = (projection === 'mercator') ? convertToMercator(geojson) : convertToWgs84(geojson);

        // Handle GeoJSON
        else {
            // Handle possible data mutation
            if (mutate !== true) geojson = clone(geojson);

            coordEach(geojson, function (coord) {
                var newCoord = (projection === 'mercator') ? convertToMercator(coord) : convertToWgs84(coord);
                coord[0] = newCoord[0];
                coord[1] = newCoord[1];
            });
        }
        return geojson;
    }

    /**
     * Convert lon/lat values to 900913 x/y.
     * (from https://github.com/mapbox/sphericalmercator)
     *
     * @private
     * @param {Array<number>} lonLat WGS84 point
     * @returns {Array<number>} Mercator [x, y] point
     */
    function convertToMercator(lonLat) {
        var D2R = Math.PI / 180,
            // 900913 properties
            A = 6378137.0,
            MAXEXTENT = 20037508.342789244;

        // compensate longitudes passing the 180th meridian
        // from https://github.com/proj4js/proj4js/blob/master/lib/common/adjust_lon.js
        var adjusted = (Math.abs(lonLat[0]) <= 180) ? lonLat[0] : (lonLat[0] - (sign(lonLat[0]) * 360));
        var xy = [
            A * adjusted * D2R,
            A * Math.log(Math.tan((Math.PI * 0.25) + (0.5 * lonLat[1] * D2R)))
        ];

        // if xy value is beyond maxextent (e.g. poles), return maxextent
        if (xy[0] > MAXEXTENT) xy[0] = MAXEXTENT;
        if (xy[0] < -MAXEXTENT) xy[0] = -MAXEXTENT;
        if (xy[1] > MAXEXTENT) xy[1] = MAXEXTENT;
        if (xy[1] < -MAXEXTENT) xy[1] = -MAXEXTENT;

        return xy;
    }

    /**
     * Convert 900913 x/y values to lon/lat.
     * (from https://github.com/mapbox/sphericalmercator)
     *
     * @private
     * @param {Array<number>} xy Mercator [x, y] point
     * @returns {Array<number>} WGS84 [lon, lat] point
     */
    function convertToWgs84(xy) {
        // 900913 properties.
        var R2D = 180 / Math.PI;
        var A = 6378137.0;

        return [
            (xy[0] * R2D / A),
            ((Math.PI * 0.5) - 2.0 * Math.atan(Math.exp(-xy[1] / A))) * R2D
        ];
    }

    /**
     * Returns the sign of the input, or zero
     *
     * @private
     * @param {number} x input
     * @returns {number} -1|0|1 output
     */
    function sign(x) {
        return (x < 0) ? -1 : (x > 0) ? 1 : 0;
    }

    var index$7 = /*#__PURE__*/Object.freeze({
        toMercator: toMercator,
        toWgs84: toWgs84
    });

    /**
     * Returns a random position within a {@link bounding box}.
     *
     * @name randomPosition
     * @param {Array<number>} [bbox=[-180, -90, 180, 90]] a bounding box inside of which positions are placed.
     * @returns {Array<number>} Position [longitude, latitude]
     * @example
     * var position = turf.randomPosition([-180, -90, 180, 90])
     * //=position
     */
    function randomPosition(bbox) {
        if (isObject(bbox)) bbox = bbox.bbox;
        if (bbox && !Array.isArray(bbox)) throw new Error('bbox is invalid');
        if (bbox) return coordInBBox(bbox);
        else return [lon(), lat()];
    }

    /**
     * Returns a random {@link point}.
     *
     * @name randomPoint
     * @param {number} [count=1] how many geometries will be generated
     * @param {Object} [options={}] Optional parameters
     * @param {Array<number>} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
     * @returns {FeatureCollection<Point>} GeoJSON FeatureCollection of points
     * @example
     * var points = turf.randomPoint(25, {bbox: [-180, -90, 180, 90]})
     * //=points
     */
    function randomPoint(count, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var bbox = options.bbox;
        if (count === undefined || count === null) count = 1;

        var features = [];
        for (var i = 0; i < count; i++) {
            features.push(point(randomPosition(bbox)));
        }
        return featureCollection(features);
    }

    /**
     * Returns a random {@link polygon}.
     *
     * @name randomPolygon
     * @param {number} [count=1] how many geometries will be generated
     * @param {Object} [options={}] Optional parameters
     * @param {Array<number>} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
     * @param {number} [options.num_vertices=10] is how many coordinates each LineString will contain.
     * @param {number} [options.max_radial_length=10] is the maximum number of decimal degrees latitude or longitude that a vertex can reach out of the center of the Polygon.
     * @returns {FeatureCollection<Point>} GeoJSON FeatureCollection of points
     * @example
     * var polygons = turf.randomPolygon(25, {bbox: [-180, -90, 180, 90]})
     * //=polygons
     */
    function randomPolygon(count, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var bbox = options.bbox;
        var num_vertices = options.num_vertices;
        var max_radial_length = options.max_radial_length;
        if (count === undefined || count === null) count = 1;

        // Validation
        if (!isNumber(num_vertices)) num_vertices = 10;
        if (!isNumber(max_radial_length)) max_radial_length = 10;

        var features = [];
        for (var i = 0; i < count; i++) {
            var vertices = [],
                circle_offsets = Array.apply(null,
                    new Array(num_vertices + 1)).map(Math.random);

            circle_offsets.forEach(sumOffsets);
            circle_offsets.forEach(scaleOffsets);
            vertices[vertices.length - 1] = vertices[0]; // close the ring

            // center the polygon around something
            vertices = vertices.map(vertexToCoordinate(randomPosition(bbox)));
            features.push(polygon([vertices]));
        }

        function sumOffsets(cur, index, arr) {
            arr[index] = (index > 0) ? cur + arr[index - 1] : cur;
        }

        function scaleOffsets(cur) {
            cur = cur * 2 * Math.PI / circle_offsets[circle_offsets.length - 1];
            var radial_scaler = Math.random();
            vertices.push([
                radial_scaler * max_radial_length * Math.sin(cur),
                radial_scaler * max_radial_length * Math.cos(cur)
            ]);
        }

        return featureCollection(features);
    }

    /**
     * Returns a random {@link linestring}.
     *
     * @name randomLineString
     * @param {number} [count=1] how many geometries will be generated
     * @param {Object} [options={}] Optional parameters
     * @param {Array<number>} [options.bbox=[-180, -90, 180, 90]] a bounding box inside of which geometries are placed.
     * @param {number} [options.num_vertices=10] is how many coordinates each LineString will contain.
     * @param {number} [options.max_length=0.0001] is the maximum number of decimal degrees that a vertex can be from its predecessor
     * @param {number} [options.max_rotation=Math.PI / 8] is the maximum number of radians that a line segment can turn from the previous segment.
     * @returns {FeatureCollection<Point>} GeoJSON FeatureCollection of points
     * @example
     * var lineStrings = turf.randomLineString(25, {bbox: [-180, -90, 180, 90]})
     * //=lineStrings
     */
    function randomLineString(count, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        var bbox = options.bbox;
        var num_vertices = options.num_vertices;
        var max_length = options.max_length;
        var max_rotation = options.max_rotation;
        if (count === undefined || count === null) count = 1;

        // Default parameters
        if (!isNumber(num_vertices) || num_vertices < 2) num_vertices = 10;
        if (!isNumber(max_length)) max_length = 0.0001;
        if (!isNumber(max_rotation)) max_rotation = Math.PI / 8;

        var features = [];
        for (var i = 0; i < count; i++) {
            var startingPoint = randomPosition(bbox);
            var vertices = [startingPoint];
            for (var j = 0; j < num_vertices - 1; j++) {
                var priorAngle = (j === 0) ?
                    Math.random() * 2 * Math.PI :
                    Math.tan(
                        (vertices[j][1] - vertices[j - 1][1]) /
                  (vertices[j][0] - vertices[j - 1][0])
                    );
                var angle = priorAngle + (Math.random() - 0.5) * max_rotation * 2;
                var distance = Math.random() * max_length;
                vertices.push([
                    vertices[j][0] + distance * Math.cos(angle),
                    vertices[j][1] + distance * Math.sin(angle)
                ]);
            }
            features.push(lineString(vertices));
        }

        return featureCollection(features);
    }

    function vertexToCoordinate(hub) {
        return function (cur) { return [cur[0] + hub[0], cur[1] + hub[1]]; };
    }

    function rnd() { return Math.random() - 0.5; }
    function lon() { return rnd() * 360; }
    function lat() { return rnd() * 180; }

    function coordInBBox(bbox) {
        return [
            (Math.random() * (bbox[2] - bbox[0])) + bbox[0],
            (Math.random() * (bbox[3] - bbox[1])) + bbox[1]];
    }

    var index$8 = /*#__PURE__*/Object.freeze({
        randomPosition: randomPosition,
        randomPoint: randomPoint,
        randomPolygon: randomPolygon,
        randomLineString: randomLineString
    });

    /**
     * Get Cluster
     *
     * @name getCluster
     * @param {FeatureCollection} geojson GeoJSON Features
     * @param {*} filter Filter used on GeoJSON properties to get Cluster
     * @returns {FeatureCollection} Single Cluster filtered by GeoJSON Properties
     * @example
     * var geojson = turf.featureCollection([
     *     turf.point([0, 0], {'marker-symbol': 'circle'}),
     *     turf.point([2, 4], {'marker-symbol': 'star'}),
     *     turf.point([3, 6], {'marker-symbol': 'star'}),
     *     turf.point([5, 1], {'marker-symbol': 'square'}),
     *     turf.point([4, 2], {'marker-symbol': 'circle'})
     * ]);
     *
     * // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
     * var clustered = turf.clustersKmeans(geojson);
     *
     * // Retrieve first cluster (0)
     * var cluster = turf.getCluster(clustered, {cluster: 0});
     * //= cluster
     *
     * // Retrieve cluster based on custom properties
     * turf.getCluster(clustered, {'marker-symbol': 'circle'}).length;
     * //= 2
     * turf.getCluster(clustered, {'marker-symbol': 'square'}).length;
     * //= 1
     */
    function getCluster(geojson, filter) {
        // Validation
        if (!geojson) throw new Error('geojson is required');
        if (geojson.type !== 'FeatureCollection') throw new Error('geojson must be a FeatureCollection');
        if (filter === undefined || filter === null) throw new Error('filter is required');

        // Filter Features
        var features = [];
        featureEach(geojson, function (feature$$1) {
            if (applyFilter(feature$$1.properties, filter)) features.push(feature$$1);
        });
        return featureCollection(features);
    }

    /**
     * Callback for clusterEach
     *
     * @callback clusterEachCallback
     * @param {FeatureCollection} [cluster] The current cluster being processed.
     * @param {*} [clusterValue] Value used to create cluster being processed.
     * @param {number} [currentIndex] The index of the current element being processed in the array.Starts at index 0
     * @returns {void}
     */

    /**
     * clusterEach
     *
     * @name clusterEach
     * @param {FeatureCollection} geojson GeoJSON Features
     * @param {string|number} property GeoJSON property key/value used to create clusters
     * @param {Function} callback a method that takes (cluster, clusterValue, currentIndex)
     * @returns {void}
     * @example
     * var geojson = turf.featureCollection([
     *     turf.point([0, 0]),
     *     turf.point([2, 4]),
     *     turf.point([3, 6]),
     *     turf.point([5, 1]),
     *     turf.point([4, 2])
     * ]);
     *
     * // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
     * var clustered = turf.clustersKmeans(geojson);
     *
     * // Iterate over each cluster
     * turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue, currentIndex) {
     *     //= cluster
     *     //= clusterValue
     *     //= currentIndex
     * })
     *
     * // Calculate the total number of clusters
     * var total = 0
     * turf.clusterEach(clustered, 'cluster', function () {
     *     total++;
     * });
     *
     * // Create an Array of all the values retrieved from the 'cluster' property
     * var values = []
     * turf.clusterEach(clustered, 'cluster', function (cluster, clusterValue) {
     *     values.push(clusterValue);
     * });
     */
    function clusterEach(geojson, property, callback) {
        // Validation
        if (!geojson) throw new Error('geojson is required');
        if (geojson.type !== 'FeatureCollection') throw new Error('geojson must be a FeatureCollection');
        if (property === undefined || property === null) throw new Error('property is required');

        // Create clusters based on property values
        var bins = createBins(geojson, property);
        var values = Object.keys(bins);
        for (var index = 0; index < values.length; index++) {
            var value = values[index];
            var bin = bins[value];
            var features = [];
            for (var i = 0; i < bin.length; i++) {
                features.push(geojson.features[bin[i]]);
            }
            callback(featureCollection(features), value, index);
        }
    }

    /**
     * Callback for clusterReduce
     *
     * The first time the callback function is called, the values provided as arguments depend
     * on whether the reduce method has an initialValue argument.
     *
     * If an initialValue is provided to the reduce method:
     *  - The previousValue argument is initialValue.
     *  - The currentValue argument is the value of the first element present in the array.
     *
     * If an initialValue is not provided:
     *  - The previousValue argument is the value of the first element present in the array.
     *  - The currentValue argument is the value of the second element present in the array.
     *
     * @callback clusterReduceCallback
     * @param {*} [previousValue] The accumulated value previously returned in the last invocation
     * of the callback, or initialValue, if supplied.
     * @param {FeatureCollection} [cluster] The current cluster being processed.
     * @param {*} [clusterValue] Value used to create cluster being processed.
     * @param {number} [currentIndex] The index of the current element being processed in the
     * array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
     */

    /**
     * Reduce clusters in GeoJSON Features, similar to Array.reduce()
     *
     * @name clusterReduce
     * @param {FeatureCollection} geojson GeoJSON Features
     * @param {string|number} property GeoJSON property key/value used to create clusters
     * @param {Function} callback a method that takes (previousValue, cluster, clusterValue, currentIndex)
     * @param {*} [initialValue] Value to use as the first argument to the first call of the callback.
     * @returns {*} The value that results from the reduction.
     * @example
     * var geojson = turf.featureCollection([
     *     turf.point([0, 0]),
     *     turf.point([2, 4]),
     *     turf.point([3, 6]),
     *     turf.point([5, 1]),
     *     turf.point([4, 2])
     * ]);
     *
     * // Create a cluster using K-Means (adds `cluster` to GeoJSON properties)
     * var clustered = turf.clustersKmeans(geojson);
     *
     * // Iterate over each cluster and perform a calculation
     * var initialValue = 0
     * turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue, currentIndex) {
     *     //=previousValue
     *     //=cluster
     *     //=clusterValue
     *     //=currentIndex
     *     return previousValue++;
     * }, initialValue);
     *
     * // Calculate the total number of clusters
     * var total = turf.clusterReduce(clustered, 'cluster', function (previousValue) {
     *     return previousValue++;
     * }, 0);
     *
     * // Create an Array of all the values retrieved from the 'cluster' property
     * var values = turf.clusterReduce(clustered, 'cluster', function (previousValue, cluster, clusterValue) {
     *     return previousValue.concat(clusterValue);
     * }, []);
     */
    function clusterReduce(geojson, property, callback, initialValue) {
        var previousValue = initialValue;
        clusterEach(geojson, property, function (cluster, clusterValue, currentIndex) {
            if (currentIndex === 0 && initialValue === undefined) previousValue = cluster;
            else previousValue = callback(previousValue, cluster, clusterValue, currentIndex);
        });
        return previousValue;
    }

    /**
     * Create Bins
     *
     * @private
     * @param {FeatureCollection} geojson GeoJSON Features
     * @param {string|number} property Property values are used to create bins
     * @returns {Object} bins with Feature IDs
     * @example
     * var geojson = turf.featureCollection([
     *     turf.point([0, 0], {cluster: 0, foo: 'null'}),
     *     turf.point([2, 4], {cluster: 1, foo: 'bar'}),
     *     turf.point([5, 1], {0: 'foo'}),
     *     turf.point([3, 6], {cluster: 1}),
     * ]);
     * createBins(geojson, 'cluster');
     * //= { '0': [ 0 ], '1': [ 1, 3 ] }
     */
    function createBins(geojson, property) {
        var bins = {};

        featureEach(geojson, function (feature$$1, i) {
            var properties = feature$$1.properties || {};
            if (properties.hasOwnProperty(property)) {
                var value = properties[property];
                if (bins.hasOwnProperty(value)) bins[value].push(i);
                else bins[value] = [i];
            }
        });
        return bins;
    }

    /**
     * Apply Filter
     *
     * @private
     * @param {*} properties Properties
     * @param {*} filter Filter
     * @returns {boolean} applied Filter to properties
     */
    function applyFilter(properties, filter) {
        if (properties === undefined) return false;
        var filterType = typeof filter;

        // String & Number
        if (filterType === 'number' || filterType === 'string') return properties.hasOwnProperty(filter);
        // Array
        else if (Array.isArray(filter)) {
            for (var i = 0; i < filter.length; i++) {
                if (!applyFilter(properties, filter[i])) return false;
            }
            return true;
        // Object
        } else {
            return propertiesContainsFilter(properties, filter);
        }
    }

    /**
     * Properties contains filter (does not apply deepEqual operations)
     *
     * @private
     * @param {*} properties Properties
     * @param {Object} filter Filter
     * @returns {boolean} does filter equal Properties
     * @example
     * propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 0})
     * //= true
     * propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 1})
     * //= false
     */
    function propertiesContainsFilter(properties, filter) {
        var keys = Object.keys(filter);
        for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            if (properties[key] !== filter[key]) return false;
        }
        return true;
    }

    /**
     * Filter Properties
     *
     * @private
     * @param {*} properties Properties
     * @param {Array<string>} keys Used to filter Properties
     * @returns {*} filtered Properties
     * @example
     * filterProperties({foo: 'bar', cluster: 0}, ['cluster'])
     * //= {cluster: 0}
     */
    function filterProperties(properties, keys) {
        if (!keys) return {};
        if (!keys.length) return {};

        var newProperties = {};
        for (var i = 0; i < keys.length; i++) {
            var key = keys[i];
            if (properties.hasOwnProperty(key)) newProperties[key] = properties[key];
        }
        return newProperties;
    }

    var index$9 = /*#__PURE__*/Object.freeze({
        getCluster: getCluster,
        clusterEach: clusterEach,
        clusterReduce: clusterReduce,
        createBins: createBins,
        applyFilter: applyFilter,
        propertiesContainsFilter: propertiesContainsFilter,
        filterProperties: filterProperties
    });

    /**
     * Finds the difference between two {@link Polygon|polygons} by clipping the second polygon from the first.
     *
     * @name difference
     * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon feature
     * @param {Feature<Polygon|MultiPolygon>} polygon2 Polygon feature to difference from polygon1
     * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)
     * @example
     * var polygon1 = turf.polygon([[
     *   [128, -26],
     *   [141, -26],
     *   [141, -21],
     *   [128, -21],
     *   [128, -26]
     * ]], {
     *   "fill": "#F00",
     *   "fill-opacity": 0.1
     * });
     * var polygon2 = turf.polygon([[
     *   [126, -28],
     *   [140, -28],
     *   [140, -20],
     *   [126, -20],
     *   [126, -28]
     * ]], {
     *   "fill": "#00F",
     *   "fill-opacity": 0.1
     * });
     *
     * var difference = turf.difference(polygon1, polygon2);
     *
     * //addToMap
     * var addToMap = [polygon1, polygon2, difference];
     */
    function difference$1(polygon1, polygon2) {
        var geom1 = getGeom(polygon1);
        var geom2 = getGeom(polygon2);
        var properties = polygon1.properties || {};
        var differenced = difference(geom1.coordinates, geom2.coordinates);
        if (differenced.length === 0) return null;
        return multiPolygon(differenced, properties);
    }

    /**
     * Takes two {@link Polygon|polygon} or {@link MultiPolygon|multi-polygon} geometries and
     * finds their polygonal intersection. If they don't intersect, returns null.
     *
     * @name intersect
     * @param {Feature<Polygon | MultiPolygon>} poly1 the first polygon or multipolygon
     * @param {Feature<Polygon | MultiPolygon>} poly2 the second polygon or multipolygon
     * @param {Object} [options={}] Optional Parameters
     * @param {Object} [options.properties={}] Translate GeoJSON Properties to Feature
     * @returns {Feature|null} returns a feature representing the area they share (either a {@link Polygon} or
     * {@link MultiPolygon}). If they do not share any area, returns `null`.
     * @example
     * var poly1 = turf.polygon([[
     *   [-122.801742, 45.48565],
     *   [-122.801742, 45.60491],
     *   [-122.584762, 45.60491],
     *   [-122.584762, 45.48565],
     *   [-122.801742, 45.48565]
     * ]]);
     *
     * var poly2 = turf.polygon([[
     *   [-122.520217, 45.535693],
     *   [-122.64038, 45.553967],
     *   [-122.720031, 45.526554],
     *   [-122.669906, 45.507309],
     *   [-122.723464, 45.446643],
     *   [-122.532577, 45.408574],
     *   [-122.487258, 45.477466],
     *   [-122.520217, 45.535693]
     * ]]);
     *
     * var intersection = turf.intersect(poly1, poly2);
     *
     * //addToMap
     * var addToMap = [poly1, poly2, intersection];
     */
    function intersect$2(poly1, poly2, options) {
        options = checkIfOptionsExist(options);
        var properties = options.properties || {};

        const geom1 = getGeom(poly1);
        const geom2 = getGeom(poly2);

        const intersection$$1 = intersection(geom1.coordinates, geom2.coordinates);
        if (intersection$$1.length === 0) return null;
        return multiPolygon(intersection$$1, properties);
    }

    /**
     * Takes a bounding box and the diameter of the cell and returns a {@link FeatureCollection} of flat-topped
     * hexagons or triangles ({@link Polygon} features) aligned in an "odd-q" vertical grid as
     * described in [Hexagonal Grids](http://www.redblobgames.com/grids/hexagons/).
     *
     * @name hexGrid
     * @param {BBox} bbox extent in [minX, minY, maxX, maxY] order
     * @param {number} cellSide length of the side of the the hexagons or triangles, in units. It will also coincide with the
     * radius of the circumcircle of the hexagons.
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] used in calculating cell size, can be degrees, radians, miles, or kilometers
     * @param {Object} [options.properties={}] passed to each hexagon or triangle of the grid
     * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
     * @param {boolean} [options.triangles=false] whether to return as triangles instead of hexagons
     * @returns {FeatureCollection<Polygon>} a hexagonal grid
     * @example
     * var bbox = [-96,31,-84,40];
     * var cellSide = 50;
     * var options = {units: 'miles'};
     *
     * var hexgrid = turf.hexGrid(bbox, cellSide, options);
     *
     * //addToMap
     * var addToMap = [hexgrid];
     */
    function hexGrid(bbox, cellSide, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        // var units = options.units;
        const clonedProperties = JSON.stringify(options.properties || {});
        var triangles = options.triangles;
        var mask = options.mask;

        // validation
        if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');
        if (!isNumber(cellSide)) throw new Error('cellSide is invalid');
        if (!bbox) throw new Error('bbox is required');
        if (!Array.isArray(bbox)) throw new Error('bbox must be array');
        if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');
        if (mask && ['Polygon', 'MultiPolygon'].indexOf(getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');

        var west = bbox[0];
        var south = bbox[1];
        var east = bbox[2];
        var north = bbox[3];
        var centerY = (south + north) / 2;
        var centerX = (west + east) / 2;

        // https://github.com/Turfjs/turf/issues/758
        var xFraction = cellSide * 2 / (distance([west, centerY], [east, centerY], options));
        var cellWidth = xFraction * (east - west);
        var yFraction = cellSide * 2 / (distance([centerX, south], [centerX, north], options));
        var cellHeight = yFraction * (north - south);
        var radius = cellWidth / 2;

        var hex_width = radius * 2;
        var hex_height = Math.sqrt(3) / 2 * cellHeight;

        var box_width = east - west;
        var box_height = north - south;

        var x_interval = 3 / 4 * hex_width;
        var y_interval = hex_height;

        // adjust box_width so all hexagons will be inside the bbox
        var x_span = (box_width - hex_width) / (hex_width - radius / 2);
        var x_count = Math.floor(x_span);

        var x_adjust = ((x_count * x_interval - radius / 2) - box_width) / 2 - radius / 2 + x_interval / 2;

        // adjust box_height so all hexagons will be inside the bbox
        var y_count = Math.floor((box_height - hex_height) / hex_height);

        var y_adjust = (box_height - y_count * hex_height) / 2;

        var hasOffsetY = y_count * hex_height - box_height > hex_height / 2;
        if (hasOffsetY) {
            y_adjust -= hex_height / 4;
        }

        // Precompute cosines and sines of angles used in hexagon creation for performance gain
        var cosines = [];
        var sines = [];
        for (var i = 0; i < 6; i++) {
            var angle = 2 * Math.PI / 6 * i;
            cosines.push(Math.cos(angle));
            sines.push(Math.sin(angle));
        }

        var results = [];
        for (var x = 0; x <= x_count; x++) {
            for (var y = 0; y <= y_count; y++) {

                var isOdd = x % 2 === 1;
                if (y === 0 && isOdd) continue;
                if (y === 0 && hasOffsetY) continue;

                var center_x = x * x_interval + west - x_adjust;
                var center_y = y * y_interval + south + y_adjust;

                if (isOdd) {
                    center_y -= hex_height / 2;
                }

                if (triangles === true) {
                    hexTriangles(
                        [center_x, center_y],
                        cellWidth / 2,
                        cellHeight / 2,
                        JSON.parse(clonedProperties),
                        cosines,
                        sines).forEach(function (triangle) {
                        if (mask) {
                            if (intersect$2(mask, triangle)) results.push(triangle);
                        } else {
                            results.push(triangle);
                        }
                    });
                } else {
                    var hex = hexagon(
                        [center_x, center_y],
                        cellWidth / 2,
                        cellHeight / 2,
                        JSON.parse(clonedProperties),
                        cosines,
                        sines
                    );
                    if (mask) {
                        if (intersect$2(mask, hex)) results.push(hex);
                    } else {
                        results.push(hex);
                    }
                }
            }
        }

        return featureCollection(results);
    }

    /**
     * Creates hexagon
     *
     * @private
     * @param {Array<number>} center of the hexagon
     * @param {number} rx half hexagon width
     * @param {number} ry half hexagon height
     * @param {Object} properties passed to each hexagon
     * @param {Array<number>} cosines precomputed
     * @param {Array<number>} sines precomputed
     * @returns {Feature<Polygon>} hexagon
     */
    function hexagon(center, rx, ry, properties, cosines, sines) {
        var vertices = [];
        for (var i = 0; i < 6; i++) {
            var x = center[0] + rx * cosines[i];
            var y = center[1] + ry * sines[i];
            vertices.push([x, y]);
        }
        //first and last vertex must be the same
        vertices.push(vertices[0].slice());
        return polygon([vertices], properties);
    }

    /**
     * Creates triangles composing an hexagon
     *
     * @private
     * @param {Array<number>} center of the hexagon
     * @param {number} rx half triangle width
     * @param {number} ry half triangle height
     * @param {Object} properties passed to each triangle
     * @param {Array<number>} cosines precomputed
     * @param {Array<number>} sines precomputed
     * @returns {Array<Feature<Polygon>>} triangles
     */
    function hexTriangles(center, rx, ry, properties, cosines, sines) {
        var triangles = [];
        for (var i = 0; i < 6; i++) {
            var vertices = [];
            vertices.push(center);
            vertices.push([
                center[0] + rx * cosines[i],
                center[1] + ry * sines[i]
            ]);
            vertices.push([
                center[0] + rx * cosines[(i + 1) % 6],
                center[1] + ry * sines[(i + 1) % 6]
            ]);
            vertices.push(center);
            triangles.push(polygon([vertices], properties));
        }
        return triangles;
    }

    /**
     * Takes any type of {@link Polygon|polygon} and an optional mask and returns a {@link Polygon|polygon} exterior ring with holes.
     *
     * @name mask
     * @param {FeatureCollection|Feature<Polygon|MultiPolygon>} polygon GeoJSON Polygon or a Feature Collection of polygons, used as interior rings or holes.
     * @param {FeatureCollection|Feature<Polygon>} [mask] GeoJSON Polygon used as the exterior ring (if undefined, the world extent is used)
     * @returns {Feature<Polygon>} Masked Polygon (exterior ring with holes).
     * @example
     * var polygon = turf.polygon([[[112, -21], [116, -36], [146, -39], [153, -24], [133, -10], [112, -21]]]);
     * var mask = turf.polygon([[[90, -55], [170, -55], [170, 10], [90, 10], [90, -55]]]);
     *
     * var masked = turf.mask(polygon, mask);
     *
     * //addToMap
     * var addToMap = [masked]
     */
    function mask(polygon$$1, mask) {
        // Define mask
        var maskPolygon = createMask(mask);

        var polygonOuters = null;
        if (polygon$$1.type === 'FeatureCollection') polygonOuters = union$1(polygon$$1);
        else polygonOuters = union$1(featureCollection([polygon$$1]));

        polygonOuters.geometry.coordinates.forEach(function (contour) {
            maskPolygon.geometry.coordinates.push(contour[0]);
        });

        return maskPolygon;
    }

    /**
     * Create Mask Coordinates
     *
     * @private
     * @param {Feature<Polygon>} [mask] default to world if undefined
     * @returns {Feature<Polygon>} mask coordinate
     */
    function createMask(mask) {
        var world = [[[180, 90], [-180, 90], [-180, -90], [180, -90], [180, 90]]];
        var coordinates = mask && mask.geometry.coordinates || world;
        return polygon(coordinates);
    }

    /**
     * Boolean-intersects returns (TRUE) two geometries spatially intersect, by that we mean that one does not completely contain another.
     *
     * @name booleanIntersects
     * @param {Geometry|Feature<any>} feature1 GeoJSON Feature or Geometry
     * @param {Geometry|Feature<any>} feature2 GeoJSON Feature or Geometry
     * @returns {boolean} true/false
     * @example
     * var point = turf.point([2, 2]);
     * var line = turf.lineString([[1, 1], [1, 2], [1, 3], [1, 4]]);
     *
     * turf.booleanIntersects(line, point);
     * //=true
     */
    function booleanIntersects(feature1, feature2) {
        let bool = false;
        flattenEach(feature1, (flatten1) => {
            flattenEach(feature2, (flatten2) => {
                if (bool === true) { return true; }
                bool = !booleanDisjoint(flatten1.geometry, flatten2.geometry);
            });
        });
        return bool;
    }

    /**
     * Creates a grid of rectangles from a bounding box, {@link Feature} or {@link FeatureCollection}.
     *
     * @name rectangleGrid
     * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
     * @param {number} cellWidth of each cell, in units
     * @param {number} cellHeight of each cell, in units
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] units ("degrees", "radians", "miles", "kilometers") that the given cellWidth 
     * and cellHeight are expressed in. Converted at the southern border.
     * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
     * the grid Points will be created only inside it
     * @param {Object} [options.properties={}] passed to each point of the grid
     * @returns {FeatureCollection<Polygon>} a grid of polygons
     * @example
     * var bbox = [-95, 30 ,-85, 40];
     * var cellWidth = 50;
     * var cellHeight = 20;
     * var options = {units: 'miles'};
     *
     * var rectangleGrid = turf.rectangleGrid(bbox, cellWidth, cellHeight, options);
     *
     * //addToMap
     * var addToMap = [rectangleGrid]
     */
    function rectangleGrid(bbox, cellWidth, cellHeight, options) {
        // Containers
        const results = [];
        const west = bbox[0];
        const south = bbox[1];
        const east = bbox[2];
        const north = bbox[3];

        const xFraction = cellWidth / (distance([west, south], [east, south], options));
        const cellWidthDeg = xFraction * (east - west);
        const yFraction = cellHeight / (distance([west, south], [west, north], options));
        const cellHeightDeg = yFraction * (north - south);

        // rows & columns
        const bboxWidth = (east - west);
        const bboxHeight = (north - south);
        const columns = Math.floor(bboxWidth / cellWidthDeg);
        const rows = Math.floor(bboxHeight / cellHeightDeg);

        // if the grid does not fill the bbox perfectly, center it.
        const deltaX = (bboxWidth - columns * cellWidthDeg) / 2;
        const deltaY = (bboxHeight - rows * cellHeightDeg) / 2;

        // iterate over columns & rows
        let currentX = west + deltaX;
        for (let column = 0; column < columns; column++) {
            let currentY = south + deltaY;
            for (let row = 0; row < rows; row++) {
                const cellPoly = polygon([[
                    [currentX, currentY],
                    [currentX, currentY + cellHeightDeg],
                    [currentX + cellWidthDeg, currentY + cellHeightDeg],
                    [currentX + cellWidthDeg, currentY],
                    [currentX, currentY],
                ]], options.properties);
                if (options.mask) {
                    if (booleanIntersects(options.mask, cellPoly)) { results.push(cellPoly); }
                } else {
                    results.push(cellPoly);
                }

                currentY += cellHeightDeg;
            }
            currentX += cellWidthDeg;
        }
        return featureCollection(results);
    }

    /**
     * Creates a square grid from a bounding box, {@link Feature} or {@link FeatureCollection}.
     *
     * @name squareGrid
     * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
     * @param {number} cellSide of each cell, in units
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees,
     * radians, miles, or kilometers
     * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon,
     * the grid Points will be created only inside it
     * @param {Object} [options.properties={}] passed to each point of the grid
     * @returns {FeatureCollection<Polygon>} grid a grid of polygons
     * @example
     * var bbox = [-95, 30 ,-85, 40];
     * var cellSide = 50;
     * var options = {units: 'miles'};
     *
     * var squareGrid = turf.squareGrid(bbox, cellSide, options);
     *
     * //addToMap
     * var addToMap = [squareGrid]
     */

    function squareGrid(bbox, cellSide, options) {
        return rectangleGrid(bbox, cellSide, cellSide, options);
    }

    /**
     * Takes a bounding box and a cell depth and returns a set of triangular {@link Polygon|polygons} in a grid.
     *
     * @name triangleGrid
     * @param {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
     * @param {number} cellSide dimension of each cell
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units='kilometers'] used in calculating cellSide, can be degrees, radians, miles, or kilometers
     * @param {Feature<Polygon|MultiPolygon>} [options.mask] if passed a Polygon or MultiPolygon, the grid Points will be created only inside it
     * @param {Object} [options.properties={}] passed to each point of the grid
     * @returns {FeatureCollection<Polygon>} grid of polygons
     * @example
     * var bbox = [-95, 30 ,-85, 40];
     * var cellSide = 50;
     * var options = {units: 'miles'};
     *
     * var triangleGrid = turf.triangleGrid(bbox, cellSide, options);
     *
     * //addToMap
     * var addToMap = [triangleGrid];
     */
    function triangleGrid(bbox, cellSide, options) {
        // Optional parameters
        options = options || {};
        if (!isObject(options)) throw new Error('options is invalid');
        // var units = options.units;
        var properties = options.properties;
        var mask = options.mask;

        // Containers
        var results = [];

        // Input Validation
        if (cellSide === null || cellSide === undefined) throw new Error('cellSide is required');
        if (!isNumber(cellSide)) throw new Error('cellSide is invalid');
        if (!bbox) throw new Error('bbox is required');
        if (!Array.isArray(bbox)) throw new Error('bbox must be array');
        if (bbox.length !== 4) throw new Error('bbox must contain 4 numbers');
        if (mask && ['Polygon', 'MultiPolygon'].indexOf(getType(mask)) === -1) throw new Error('options.mask must be a (Multi)Polygon');

        // Main
        var xFraction = cellSide / (distance([bbox[0], bbox[1]], [bbox[2], bbox[1]], options));
        var cellWidth = xFraction * (bbox[2] - bbox[0]);
        var yFraction = cellSide / (distance([bbox[0], bbox[1]], [bbox[0], bbox[3]], options));
        var cellHeight = yFraction * (bbox[3] - bbox[1]);

        var xi = 0;
        var currentX = bbox[0];
        while (currentX <= bbox[2]) {
            var yi = 0;
            var currentY = bbox[1];
            while (currentY <= bbox[3]) {
                var cellTriangle1 = null;
                var cellTriangle2 = null;

                if (xi % 2 === 0 && yi % 2 === 0) {
                    cellTriangle1 = polygon([[
                        [currentX, currentY],
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY]
                    ]], properties);
                    cellTriangle2 = polygon([[
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY + cellHeight]
                    ]], properties);
                } else if (xi % 2 === 0 && yi % 2 === 1) {
                    cellTriangle1 = polygon([[
                        [currentX, currentY],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY]
                    ]], properties);
                    cellTriangle2 = polygon([[
                        [currentX, currentY],
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX, currentY]
                    ]], properties);
                } else if (yi % 2 === 0 && xi % 2 === 1) {
                    cellTriangle1 = polygon([[
                        [currentX, currentY],
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX, currentY]
                    ]], properties);
                    cellTriangle2 = polygon([[
                        [currentX, currentY],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY]
                    ]], properties);
                } else if (yi % 2 === 1 && xi % 2 === 1) {
                    cellTriangle1 = polygon([[
                        [currentX, currentY],
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY]
                    ]], properties);
                    cellTriangle2 = polygon([[
                        [currentX, currentY + cellHeight],
                        [currentX + cellWidth, currentY + cellHeight],
                        [currentX + cellWidth, currentY],
                        [currentX, currentY + cellHeight]
                    ]], properties);
                }
                if (mask) {
                    if (intersect$2(mask, cellTriangle1)) results.push(cellTriangle1);
                    if (intersect$2(mask, cellTriangle2)) results.push(cellTriangle2);
                } else {
                    results.push(cellTriangle1);
                    results.push(cellTriangle2);
                }

                currentY += cellHeight;
                yi++;
            }
            xi++;
            currentX += cellWidth;
        }
        return featureCollection(results);
    }

    /**
     * Takes a set of points and estimates their 'property' values on a grid using the [Inverse Distance Weighting (IDW) method](https://en.wikipedia.org/wiki/Inverse_distance_weighting).
     *
     * @name interpolate
     * @param {FeatureCollection<Point>} points with known value
     * @param {number} cellSize the distance across each grid point
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.gridType='square'] defines the output format based on a Grid Type (options: 'square' | 'point' | 'hex' | 'triangle')
     * @param {string} [options.property='elevation'] the property name in `points` from which z-values will be pulled, zValue fallbacks to 3rd coordinate if no property exists.
     * @param {string} [options.units='kilometers'] used in calculating cellSize, can be degrees, radians, miles, or kilometers
     * @param {number} [options.weight=1] exponent regulating the distance-decay weighting
     * @returns {FeatureCollection<Point|Polygon>} grid of points or polygons with interpolated 'property'
     * @example
     * var points = turf.randomPoint(30, {bbox: [50, 30, 70, 50]});
     *
     * // add a random property to each point
     * turf.featureEach(points, function(point) {
     *     point.properties.solRad = Math.random() * 50;
     * });
     * var options = {gridType: 'points', property: 'solRad', units: 'miles'};
     * var grid = turf.interpolate(points, 100, options);
     *
     * //addToMap
     * var addToMap = [grid];
     */
    function interpolate(points$$1, cellSize, options) {
        // Optional parameters
        options = options || {};
        if (typeof options !== 'object') throw new Error('options is invalid');
        var gridType = options.gridType;
        var property = options.property;
        var weight = options.weight;

        // validation
        if (!points$$1) throw new Error('points is required');
        collectionOf(points$$1, 'Point', 'input must contain Points');
        if (!cellSize) throw new Error('cellSize is required');
        if (weight !== undefined && typeof weight !== 'number') throw new Error('weight must be a number');

        // default values
        property = property || 'elevation';
        gridType = gridType || 'square';
        weight = weight || 1;

        var box = bbox(points$$1);
        var grid;
        switch (gridType) {
        case 'point':
        case 'points':
            grid = pointGrid(box, cellSize, options);
            break;
        case 'square':
        case 'squares':
            grid = squareGrid(box, cellSize, options);
            break;
        case 'hex':
        case 'hexes':
            grid = hexGrid(box, cellSize, options);
            break;
        case 'triangle':
        case 'triangles':
            grid = triangleGrid(box, cellSize, options);
            break;
        default:
            throw new Error('invalid gridType');
        }
        var results = [];
        featureEach(grid, function (gridFeature) {
            var zw = 0;
            var sw = 0;
            // calculate the distance from each input point to the grid points
            featureEach(points$$1, function (point$$1) {
                var gridPoint = (gridType === 'point') ? gridFeature : centroid(gridFeature);
                var d = distance(gridPoint, point$$1, options);
                var zValue;
                // property has priority for zValue, fallbacks to 3rd coordinate from geometry
                if (property !== undefined) zValue = point$$1.properties[property];
                if (zValue === undefined) zValue = point$$1.geometry.coordinates[2];
                if (zValue === undefined) throw new Error('zValue is missing');
                if (d === 0) zw = zValue;
                var w = 1.0 / Math.pow(d, weight);
                sw += w;
                zw += w * zValue;
            });
            // write interpolated value for each grid point
            var newFeature = clone(gridFeature);
            newFeature.properties[property] = zw / sw;
            results.push(newFeature);
        });
        return featureCollection(results);
    }

    /* Polyfill service v3.13.0
     * For detailed credits and licence information see http://github.com/financial-times/polyfill-service
     *
     * - Array.prototype.fill, License: CC0 */

    if (!('fill' in Array.prototype)) {
      Object.defineProperty(Array.prototype, 'fill', {
        configurable: true,
        value: function fill (value) {
          if (this === undefined || this === null) {
            throw new TypeError(this + ' is not an object')
          }

          var arrayLike = Object(this);

          var length = Math.max(Math.min(arrayLike.length, 9007199254740991), 0) || 0;

          var relativeStart = 1 in arguments ? parseInt(Number(arguments[1]), 10) || 0 : 0;

          relativeStart = relativeStart < 0 ? Math.max(length + relativeStart, 0) : Math.min(relativeStart, length);

          var relativeEnd = 2 in arguments && arguments[2] !== undefined ? parseInt(Number(arguments[2]), 10) || 0 : length;

          relativeEnd = relativeEnd < 0 ? Math.max(length + arguments[2], 0) : Math.min(relativeEnd, length);

          while (relativeStart < relativeEnd) {
            arrayLike[relativeStart] = value;

            ++relativeStart;
          }

          return arrayLike
        },
        writable: true
      });
    }

    /**
     * Polyfill for IE support
     */
    Number.isFinite = Number.isFinite || function (value) {
      return typeof value === 'number' && isFinite(value)
    };

    Number.isInteger = Number.isInteger || function (val) {
      return typeof val === 'number' &&
      isFinite(val) &&
      Math.floor(val) === val
    };

    Number.parseFloat = Number.parseFloat || parseFloat;

    Number.isNaN = Number.isNaN || function (value) {
      return value !== value // eslint-disable-line
    };

    /**
     * Polyfill for IE support
     */
    Math.trunc = Math.trunc || function (x) {
      return x < 0 ? Math.ceil(x) : Math.floor(x)
    };

    var NumberUtil = function NumberUtil () {};

    NumberUtil.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    NumberUtil.prototype.getClass = function getClass () {
      return NumberUtil
    };
    NumberUtil.prototype.equalsWithTolerance = function equalsWithTolerance (x1, x2, tolerance) {
      return Math.abs(x1 - x2) <= tolerance
    };

    var IllegalArgumentException = (function (Error) {
    	function IllegalArgumentException (message) {
    		Error.call(this, message);
    		this.name = 'IllegalArgumentException';
    		this.message = message;
    		this.stack = (new Error()).stack;
    	}

    	if ( Error ) IllegalArgumentException.__proto__ = Error;
    	IllegalArgumentException.prototype = Object.create( Error && Error.prototype );
    	IllegalArgumentException.prototype.constructor = IllegalArgumentException;

    	return IllegalArgumentException;
    }(Error));

    var Double = function Double () {};

    var staticAccessors$1 = { MAX_VALUE: { configurable: true } };

    Double.isNaN = function isNaN (n) { return Number.isNaN(n) };
    Double.doubleToLongBits = function doubleToLongBits (n) { return n };
    Double.longBitsToDouble = function longBitsToDouble (n) { return n };
    Double.isInfinite = function isInfinite (n) { return !Number.isFinite(n) };
    staticAccessors$1.MAX_VALUE.get = function () { return Number.MAX_VALUE };

    Object.defineProperties( Double, staticAccessors$1 );

    var Comparable = function Comparable () {};

    var Clonable = function Clonable () {};

    var Comparator = function Comparator () {};

    function Serializable () {}

    // import Assert from '../util/Assert'

    var Coordinate = function Coordinate () {
      this.x = null;
      this.y = null;
      this.z = null;
      if (arguments.length === 0) {
        this.x = 0.0;
        this.y = 0.0;
        this.z = Coordinate.NULL_ORDINATE;
      } else if (arguments.length === 1) {
        var c = arguments[0];
        this.x = c.x;
        this.y = c.y;
        this.z = c.z;
      } else if (arguments.length === 2) {
        this.x = arguments[0];
        this.y = arguments[1];
        this.z = Coordinate.NULL_ORDINATE;
      } else if (arguments.length === 3) {
        this.x = arguments[0];
        this.y = arguments[1];
        this.z = arguments[2];
      }
    };

    var staticAccessors = { DimensionalComparator: { configurable: true },serialVersionUID: { configurable: true },NULL_ORDINATE: { configurable: true },X: { configurable: true },Y: { configurable: true },Z: { configurable: true } };
    Coordinate.prototype.setOrdinate = function setOrdinate (ordinateIndex, value) {
      switch (ordinateIndex) {
        case Coordinate.X:
          this.x = value;
          break
        case Coordinate.Y:
          this.y = value;
          break
        case Coordinate.Z:
          this.z = value;
          break
        default:
          throw new IllegalArgumentException('Invalid ordinate index: ' + ordinateIndex)
      }
    };
    Coordinate.prototype.equals2D = function equals2D () {
      if (arguments.length === 1) {
        var other = arguments[0];
        if (this.x !== other.x) {
          return false
        }
        if (this.y !== other.y) {
          return false
        }
        return true
      } else if (arguments.length === 2) {
        var c = arguments[0];
        var tolerance = arguments[1];
        if (!NumberUtil.equalsWithTolerance(this.x, c.x, tolerance)) {
          return false
        }
        if (!NumberUtil.equalsWithTolerance(this.y, c.y, tolerance)) {
          return false
        }
        return true
      }
    };
    Coordinate.prototype.getOrdinate = function getOrdinate (ordinateIndex) {
      switch (ordinateIndex) {
        case Coordinate.X:
          return this.x
        case Coordinate.Y:
          return this.y
        case Coordinate.Z:
          return this.z
        default:
      }
      throw new IllegalArgumentException('Invalid ordinate index: ' + ordinateIndex)
    };
    Coordinate.prototype.equals3D = function equals3D (other) {
      return this.x === other.x &&
             this.y === other.y &&
             ((this.z === other.z || Double.isNaN(this.z)) &&
             Double.isNaN(other.z))
    };
    Coordinate.prototype.equals = function equals (other) {
      if (!(other instanceof Coordinate)) {
        return false
      }
      return this.equals2D(other)
    };
    Coordinate.prototype.equalInZ = function equalInZ (c, tolerance) {
      return NumberUtil.equalsWithTolerance(this.z, c.z, tolerance)
    };
    Coordinate.prototype.compareTo = function compareTo (o) {
      var other = o;
      if (this.x < other.x) { return -1 }
      if (this.x > other.x) { return 1 }
      if (this.y < other.y) { return -1 }
      if (this.y > other.y) { return 1 }
      return 0
    };
    Coordinate.prototype.clone = function clone () {
      // try {
      // var coord = null
      // return coord
      // } catch (e) {
      // if (e instanceof CloneNotSupportedException) {
      //   Assert.shouldNeverReachHere("this shouldn't happen because this class is Cloneable")
      //   return null
      // } else throw e
      // } finally {}
    };
    Coordinate.prototype.copy = function copy () {
      return new Coordinate(this)
    };
    Coordinate.prototype.toString = function toString () {
      return '(' + this.x + ', ' + this.y + ', ' + this.z + ')'
    };
    Coordinate.prototype.distance3D = function distance3D (c) {
      var dx = this.x - c.x;
      var dy = this.y - c.y;
      var dz = this.z - c.z;
      return Math.sqrt(dx * dx + dy * dy + dz * dz)
    };
    Coordinate.prototype.distance = function distance (c) {
      var dx = this.x - c.x;
      var dy = this.y - c.y;
      return Math.sqrt(dx * dx + dy * dy)
    };
    Coordinate.prototype.hashCode = function hashCode () {
      var result = 17;
      result = 37 * result + Coordinate.hashCode(this.x);
      result = 37 * result + Coordinate.hashCode(this.y);
      return result
    };
    Coordinate.prototype.setCoordinate = function setCoordinate (other) {
      this.x = other.x;
      this.y = other.y;
      this.z = other.z;
    };
    Coordinate.prototype.interfaces_ = function interfaces_ () {
      return [Comparable, Clonable, Serializable]
    };
    Coordinate.prototype.getClass = function getClass () {
      return Coordinate
    };
    Coordinate.hashCode = function hashCode () {
      if (arguments.length === 1) {
        var x = arguments[0];
        var f = Double.doubleToLongBits(x);
        return Math.trunc((f ^ f) >>> 32)
      }
    };
    staticAccessors.DimensionalComparator.get = function () { return DimensionalComparator };
    staticAccessors.serialVersionUID.get = function () { return 6683108902428366910 };
    staticAccessors.NULL_ORDINATE.get = function () { return Double.NaN };
    staticAccessors.X.get = function () { return 0 };
    staticAccessors.Y.get = function () { return 1 };
    staticAccessors.Z.get = function () { return 2 };

    Object.defineProperties( Coordinate, staticAccessors );

    var DimensionalComparator = function DimensionalComparator (dimensionsToTest) {
      this._dimensionsToTest = 2;
      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var dimensionsToTest$1 = arguments[0];
        if (dimensionsToTest$1 !== 2 && dimensionsToTest$1 !== 3) { throw new IllegalArgumentException('only 2 or 3 dimensions may be specified') }
        this._dimensionsToTest = dimensionsToTest$1;
      }
    };
    DimensionalComparator.prototype.compare = function compare (o1, o2) {
      var c1 = o1;
      var c2 = o2;
      var compX = DimensionalComparator.compare(c1.x, c2.x);
      if (compX !== 0) { return compX }
      var compY = DimensionalComparator.compare(c1.y, c2.y);
      if (compY !== 0) { return compY }
      if (this._dimensionsToTest <= 2) { return 0 }
      var compZ = DimensionalComparator.compare(c1.z, c2.z);
      return compZ
    };
    DimensionalComparator.prototype.interfaces_ = function interfaces_ () {
      return [Comparator]
    };
    DimensionalComparator.prototype.getClass = function getClass () {
      return DimensionalComparator
    };
    DimensionalComparator.compare = function compare (a, b) {
      if (a < b) { return -1 }
      if (a > b) { return 1 }
      if (Double.isNaN(a)) {
        if (Double.isNaN(b)) { return 0 }
        return -1
      }
      if (Double.isNaN(b)) { return 1 }
      return 0
    };

    // import hasInterface from '../../../../hasInterface'
    // import CoordinateSequence from './CoordinateSequence'

    var CoordinateSequenceFactory = function CoordinateSequenceFactory () {};

    CoordinateSequenceFactory.prototype.create = function create () {
      // if (arguments.length === 1) {
      // if (arguments[0] instanceof Array) {
      //   let coordinates = arguments[0]
      // } else if (hasInterface(arguments[0], CoordinateSequence)) {
      //   let coordSeq = arguments[0]
      // }
      // } else if (arguments.length === 2) {
      // let size = arguments[0]
      // let dimension = arguments[1]
      // }
    };
    CoordinateSequenceFactory.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CoordinateSequenceFactory.prototype.getClass = function getClass () {
      return CoordinateSequenceFactory
    };

    var Location = function Location () {};

    var staticAccessors$4 = { INTERIOR: { configurable: true },BOUNDARY: { configurable: true },EXTERIOR: { configurable: true },NONE: { configurable: true } };

    Location.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Location.prototype.getClass = function getClass () {
      return Location
    };
    Location.toLocationSymbol = function toLocationSymbol (locationValue) {
      switch (locationValue) {
        case Location.EXTERIOR:
          return 'e'
        case Location.BOUNDARY:
          return 'b'
        case Location.INTERIOR:
          return 'i'
        case Location.NONE:
          return '-'
        default:
      }
      throw new IllegalArgumentException('Unknown location value: ' + locationValue)
    };
    staticAccessors$4.INTERIOR.get = function () { return 0 };
    staticAccessors$4.BOUNDARY.get = function () { return 1 };
    staticAccessors$4.EXTERIOR.get = function () { return 2 };
    staticAccessors$4.NONE.get = function () { return -1 };

    Object.defineProperties( Location, staticAccessors$4 );

    var hasInterface = function (o, i) {
      return o.interfaces_ && o.interfaces_().indexOf(i) > -1
    };

    var MathUtil = function MathUtil () {};

    var staticAccessors$5 = { LOG_10: { configurable: true } };

    MathUtil.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MathUtil.prototype.getClass = function getClass () {
      return MathUtil
    };
    MathUtil.log10 = function log10 (x) {
      var ln = Math.log(x);
      if (Double.isInfinite(ln)) { return ln }
      if (Double.isNaN(ln)) { return ln }
      return ln / MathUtil.LOG_10
    };
    MathUtil.min = function min (v1, v2, v3, v4) {
      var min = v1;
      if (v2 < min) { min = v2; }
      if (v3 < min) { min = v3; }
      if (v4 < min) { min = v4; }
      return min
    };
    MathUtil.clamp = function clamp () {
      if (typeof arguments[2] === 'number' && (typeof arguments[0] === 'number' && typeof arguments[1] === 'number')) {
        var x = arguments[0];
        var min = arguments[1];
        var max = arguments[2];
        if (x < min) { return min }
        if (x > max) { return max }
        return x
      } else if (Number.isInteger(arguments[2]) && (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1]))) {
        var x$1 = arguments[0];
        var min$1 = arguments[1];
        var max$1 = arguments[2];
        if (x$1 < min$1) { return min$1 }
        if (x$1 > max$1) { return max$1 }
        return x$1
      }
    };
    MathUtil.wrap = function wrap (index, max) {
      if (index < 0) {
        return max - -index % max
      }
      return index % max
    };
    MathUtil.max = function max () {
      if (arguments.length === 3) {
        var v1 = arguments[0];
        var v2 = arguments[1];
        var v3 = arguments[2];
        var max = v1;
        if (v2 > max) { max = v2; }
        if (v3 > max) { max = v3; }
        return max
      } else if (arguments.length === 4) {
        var v1$1 = arguments[0];
        var v2$1 = arguments[1];
        var v3$1 = arguments[2];
        var v4 = arguments[3];
        var max$1 = v1$1;
        if (v2$1 > max$1) { max$1 = v2$1; }
        if (v3$1 > max$1) { max$1 = v3$1; }
        if (v4 > max$1) { max$1 = v4; }
        return max$1
      }
    };
    MathUtil.average = function average (x1, x2) {
      return (x1 + x2) / 2.0
    };
    staticAccessors$5.LOG_10.get = function () { return Math.log(10) };

    Object.defineProperties( MathUtil, staticAccessors$5 );

    var StringBuffer = function StringBuffer (str) {
      this.str = str;
    };
    StringBuffer.prototype.append = function append (e) {
      this.str += e;
    };

    StringBuffer.prototype.setCharAt = function setCharAt (i, c) {
      this.str = this.str.substr(0, i) + c + this.str.substr(i + 1);
    };

    StringBuffer.prototype.toString = function toString (e) {
      return this.str
    };

    var Integer = function Integer (value) {
      this.value = value;
    };
    Integer.prototype.intValue = function intValue () {
      return this.value
    };
    Integer.prototype.compareTo = function compareTo (o) {
      if (this.value < o) { return -1 }
      if (this.value > o) { return 1 }
      return 0
    };
    Integer.isNaN = function isNaN (n) { return Number.isNaN(n) };

    var Character = function Character () {};

    Character.isWhitespace = function isWhitespace (c) { return ((c <= 32 && c >= 0) || c === 127) };
    Character.toUpperCase = function toUpperCase (c) { return c.toUpperCase() };

    var DD = function DD () {
      this._hi = 0.0;
      this._lo = 0.0;
      if (arguments.length === 0) {
        this.init(0.0);
      } else if (arguments.length === 1) {
        if (typeof arguments[0] === 'number') {
          var x = arguments[0];
          this.init(x);
        } else if (arguments[0] instanceof DD) {
          var dd = arguments[0];
          this.init(dd);
        } else if (typeof arguments[0] === 'string') {
          var str = arguments[0];
          DD.call(this, DD.parse(str));
        }
      } else if (arguments.length === 2) {
        var hi = arguments[0];
        var lo = arguments[1];
        this.init(hi, lo);
      }
    };

    var staticAccessors$7 = { PI: { configurable: true },TWO_PI: { configurable: true },PI_2: { configurable: true },E: { configurable: true },NaN: { configurable: true },EPS: { configurable: true },SPLIT: { configurable: true },MAX_PRINT_DIGITS: { configurable: true },TEN: { configurable: true },ONE: { configurable: true },SCI_NOT_EXPONENT_CHAR: { configurable: true },SCI_NOT_ZERO: { configurable: true } };
    DD.prototype.le = function le (y) {
      return (this._hi < y._hi || this._hi === y._hi) && this._lo <= y._lo
    };
    DD.prototype.extractSignificantDigits = function extractSignificantDigits (insertDecimalPoint, magnitude) {
      var y = this.abs();
      var mag = DD.magnitude(y._hi);
      var scale = DD.TEN.pow(mag);
      y = y.divide(scale);
      if (y.gt(DD.TEN)) {
        y = y.divide(DD.TEN);
        mag += 1;
      } else if (y.lt(DD.ONE)) {
        y = y.multiply(DD.TEN);
        mag -= 1;
      }
      var decimalPointPos = mag + 1;
      var buf = new StringBuffer();
      var numDigits = DD.MAX_PRINT_DIGITS - 1;
      for (var i = 0; i <= numDigits; i++) {
        if (insertDecimalPoint && i === decimalPointPos) {
          buf.append('.');
        }
        var digit = Math.trunc(y._hi);
        if (digit < 0) {
          break
        }
        var rebiasBy10 = false;
        var digitChar = 0;
        if (digit > 9) {
          rebiasBy10 = true;
          digitChar = '9';
        } else {
          digitChar = '0' + digit;
        }
        buf.append(digitChar);
        y = y.subtract(DD.valueOf(digit)).multiply(DD.TEN);
        if (rebiasBy10) { y.selfAdd(DD.TEN); }
        var continueExtractingDigits = true;
        var remMag = DD.magnitude(y._hi);
        if (remMag < 0 && Math.abs(remMag) >= numDigits - i) { continueExtractingDigits = false; }
        if (!continueExtractingDigits) { break }
      }
      magnitude[0] = mag;
      return buf.toString()
    };
    DD.prototype.sqr = function sqr () {
      return this.multiply(this)
    };
    DD.prototype.doubleValue = function doubleValue () {
      return this._hi + this._lo
    };
    DD.prototype.subtract = function subtract () {
      if (arguments[0] instanceof DD) {
        var y = arguments[0];
        return this.add(y.negate())
      } else if (typeof arguments[0] === 'number') {
        var y$1 = arguments[0];
        return this.add(-y$1)
      }
    };
    DD.prototype.equals = function equals () {
      if (arguments.length === 1) {
        var y = arguments[0];
        return this._hi === y._hi && this._lo === y._lo
      }
    };
    DD.prototype.isZero = function isZero () {
      return this._hi === 0.0 && this._lo === 0.0
    };
    DD.prototype.selfSubtract = function selfSubtract () {
      if (arguments[0] instanceof DD) {
        var y = arguments[0];
        if (this.isNaN()) { return this }
        return this.selfAdd(-y._hi, -y._lo)
      } else if (typeof arguments[0] === 'number') {
        var y$1 = arguments[0];
        if (this.isNaN()) { return this }
        return this.selfAdd(-y$1, 0.0)
      }
    };
    DD.prototype.getSpecialNumberString = function getSpecialNumberString () {
      if (this.isZero()) { return '0.0' }
      if (this.isNaN()) { return 'NaN ' }
      return null
    };
    DD.prototype.min = function min (x) {
      if (this.le(x)) {
        return this
      } else {
        return x
      }
    };
    DD.prototype.selfDivide = function selfDivide () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof DD) {
          var y = arguments[0];
          return this.selfDivide(y._hi, y._lo)
        } else if (typeof arguments[0] === 'number') {
          var y$1 = arguments[0];
          return this.selfDivide(y$1, 0.0)
        }
      } else if (arguments.length === 2) {
        var yhi = arguments[0];
        var ylo = arguments[1];
        var hc = null;
        var tc = null;
        var hy = null;
        var ty = null;
        var C = null;
        var c = null;
        var U = null;
        var u = null;
        C = this._hi / yhi;
        c = DD.SPLIT * C;
        hc = c - C;
        u = DD.SPLIT * yhi;
        hc = c - hc;
        tc = C - hc;
        hy = u - yhi;
        U = C * yhi;
        hy = u - hy;
        ty = yhi - hy;
        u = hc * hy - U + hc * ty + tc * hy + tc * ty;
        c = (this._hi - U - u + this._lo - C * ylo) / yhi;
        u = C + c;
        this._hi = u;
        this._lo = C - u + c;
        return this
      }
    };
    DD.prototype.dump = function dump () {
      return 'DD<' + this._hi + ', ' + this._lo + '>'
    };
    DD.prototype.divide = function divide () {
      if (arguments[0] instanceof DD) {
        var y = arguments[0];
        var hc = null;
        var tc = null;
        var hy = null;
        var ty = null;
        var C = null;
        var c = null;
        var U = null;
        var u = null;
        C = this._hi / y._hi;
        c = DD.SPLIT * C;
        hc = c - C;
        u = DD.SPLIT * y._hi;
        hc = c - hc;
        tc = C - hc;
        hy = u - y._hi;
        U = C * y._hi;
        hy = u - hy;
        ty = y._hi - hy;
        u = hc * hy - U + hc * ty + tc * hy + tc * ty;
        c = (this._hi - U - u + this._lo - C * y._lo) / y._hi;
        u = C + c;
        var zhi = u;
        var zlo = C - u + c;
        return new DD(zhi, zlo)
      } else if (typeof arguments[0] === 'number') {
        var y$1 = arguments[0];
        if (Double.isNaN(y$1)) { return DD.createNaN() }
        return DD.copy(this).selfDivide(y$1, 0.0)
      }
    };
    DD.prototype.ge = function ge (y) {
      return (this._hi > y._hi || this._hi === y._hi) && this._lo >= y._lo
    };
    DD.prototype.pow = function pow (exp) {
      if (exp === 0.0) { return DD.valueOf(1.0) }
      var r = new DD(this);
      var s = DD.valueOf(1.0);
      var n = Math.abs(exp);
      if (n > 1) {
        while (n > 0) {
          if (n % 2 === 1) {
            s.selfMultiply(r);
          }
          n /= 2;
          if (n > 0) { r = r.sqr(); }
        }
      } else {
        s = r;
      }
      if (exp < 0) { return s.reciprocal() }
      return s
    };
    DD.prototype.ceil = function ceil () {
      if (this.isNaN()) { return DD.NaN }
      var fhi = Math.ceil(this._hi);
      var flo = 0.0;
      if (fhi === this._hi) {
        flo = Math.ceil(this._lo);
      }
      return new DD(fhi, flo)
    };
    DD.prototype.compareTo = function compareTo (o) {
      var other = o;
      if (this._hi < other._hi) { return -1 }
      if (this._hi > other._hi) { return 1 }
      if (this._lo < other._lo) { return -1 }
      if (this._lo > other._lo) { return 1 }
      return 0
    };
    DD.prototype.rint = function rint () {
      if (this.isNaN()) { return this }
      var plus5 = this.add(0.5);
      return plus5.floor()
    };
    DD.prototype.setValue = function setValue () {
      if (arguments[0] instanceof DD) {
        var value = arguments[0];
        this.init(value);
        return this
      } else if (typeof arguments[0] === 'number') {
        var value$1 = arguments[0];
        this.init(value$1);
        return this
      }
    };
    DD.prototype.max = function max (x) {
      if (this.ge(x)) {
        return this
      } else {
        return x
      }
    };
    DD.prototype.sqrt = function sqrt () {
      if (this.isZero()) { return DD.valueOf(0.0) }
      if (this.isNegative()) {
        return DD.NaN
      }
      var x = 1.0 / Math.sqrt(this._hi);
      var ax = this._hi * x;
      var axdd = DD.valueOf(ax);
      var diffSq = this.subtract(axdd.sqr());
      var d2 = diffSq._hi * (x * 0.5);
      return axdd.add(d2)
    };
    DD.prototype.selfAdd = function selfAdd () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof DD) {
          var y = arguments[0];
          return this.selfAdd(y._hi, y._lo)
        } else if (typeof arguments[0] === 'number') {
          var y$1 = arguments[0];
          var H = null;
          var h = null;
          var S = null;
          var s = null;
          var e = null;
          var f = null;
          S = this._hi + y$1;
          e = S - this._hi;
          s = S - e;
          s = y$1 - e + (this._hi - s);
          f = s + this._lo;
          H = S + f;
          h = f + (S - H);
          this._hi = H + h;
          this._lo = h + (H - this._hi);
          return this
        }
      } else if (arguments.length === 2) {
        var yhi = arguments[0];
        var ylo = arguments[1];
        var H$1 = null;
        var h$1 = null;
        var T = null;
        var t = null;
        var S$1 = null;
        var s$1 = null;
        var e$1 = null;
        var f$1 = null;
        S$1 = this._hi + yhi;
        T = this._lo + ylo;
        e$1 = S$1 - this._hi;
        f$1 = T - this._lo;
        s$1 = S$1 - e$1;
        t = T - f$1;
        s$1 = yhi - e$1 + (this._hi - s$1);
        t = ylo - f$1 + (this._lo - t);
        e$1 = s$1 + T;
        H$1 = S$1 + e$1;
        h$1 = e$1 + (S$1 - H$1);
        e$1 = t + h$1;
        var zhi = H$1 + e$1;
        var zlo = e$1 + (H$1 - zhi);
        this._hi = zhi;
        this._lo = zlo;
        return this
      }
    };
    DD.prototype.selfMultiply = function selfMultiply () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof DD) {
          var y = arguments[0];
          return this.selfMultiply(y._hi, y._lo)
        } else if (typeof arguments[0] === 'number') {
          var y$1 = arguments[0];
          return this.selfMultiply(y$1, 0.0)
        }
      } else if (arguments.length === 2) {
        var yhi = arguments[0];
        var ylo = arguments[1];
        var hx = null;
        var tx = null;
        var hy = null;
        var ty = null;
        var C = null;
        var c = null;
        C = DD.SPLIT * this._hi;
        hx = C - this._hi;
        c = DD.SPLIT * yhi;
        hx = C - hx;
        tx = this._hi - hx;
        hy = c - yhi;
        C = this._hi * yhi;
        hy = c - hy;
        ty = yhi - hy;
        c = hx * hy - C + hx * ty + tx * hy + tx * ty + (this._hi * ylo + this._lo * yhi);
        var zhi = C + c;
        hx = C - zhi;
        var zlo = c + hx;
        this._hi = zhi;
        this._lo = zlo;
        return this
      }
    };
    DD.prototype.selfSqr = function selfSqr () {
      return this.selfMultiply(this)
    };
    DD.prototype.floor = function floor () {
      if (this.isNaN()) { return DD.NaN }
      var fhi = Math.floor(this._hi);
      var flo = 0.0;
      if (fhi === this._hi) {
        flo = Math.floor(this._lo);
      }
      return new DD(fhi, flo)
    };
    DD.prototype.negate = function negate () {
      if (this.isNaN()) { return this }
      return new DD(-this._hi, -this._lo)
    };
    DD.prototype.clone = function clone () {
      // try {
      // return null
      // } catch (ex) {
      // if (ex instanceof CloneNotSupportedException) {
      //   return null
      // } else throw ex
      // } finally {}
    };
    DD.prototype.multiply = function multiply () {
      if (arguments[0] instanceof DD) {
        var y = arguments[0];
        if (y.isNaN()) { return DD.createNaN() }
        return DD.copy(this).selfMultiply(y)
      } else if (typeof arguments[0] === 'number') {
        var y$1 = arguments[0];
        if (Double.isNaN(y$1)) { return DD.createNaN() }
        return DD.copy(this).selfMultiply(y$1, 0.0)
      }
    };
    DD.prototype.isNaN = function isNaN () {
      return Double.isNaN(this._hi)
    };
    DD.prototype.intValue = function intValue () {
      return Math.trunc(this._hi)
    };
    DD.prototype.toString = function toString () {
      var mag = DD.magnitude(this._hi);
      if (mag >= -3 && mag <= 20) { return this.toStandardNotation() }
      return this.toSciNotation()
    };
    DD.prototype.toStandardNotation = function toStandardNotation () {
      var specialStr = this.getSpecialNumberString();
      if (specialStr !== null) { return specialStr }
      var magnitude = new Array(1).fill(null);
      var sigDigits = this.extractSignificantDigits(true, magnitude);
      var decimalPointPos = magnitude[0] + 1;
      var num = sigDigits;
      if (sigDigits.charAt(0) === '.') {
        num = '0' + sigDigits;
      } else if (decimalPointPos < 0) {
        num = '0.' + DD.stringOfChar('0', -decimalPointPos) + sigDigits;
      } else if (sigDigits.indexOf('.') === -1) {
        var numZeroes = decimalPointPos - sigDigits.length;
        var zeroes = DD.stringOfChar('0', numZeroes);
        num = sigDigits + zeroes + '.0';
      }
      if (this.isNegative()) { return '-' + num }
      return num
    };
    DD.prototype.reciprocal = function reciprocal () {
      var hc = null;
      var tc = null;
      var hy = null;
      var ty = null;
      var C = null;
      var c = null;
      var U = null;
      var u = null;
      C = 1.0 / this._hi;
      c = DD.SPLIT * C;
      hc = c - C;
      u = DD.SPLIT * this._hi;
      hc = c - hc;
      tc = C - hc;
      hy = u - this._hi;
      U = C * this._hi;
      hy = u - hy;
      ty = this._hi - hy;
      u = hc * hy - U + hc * ty + tc * hy + tc * ty;
      c = (1.0 - U - u - C * this._lo) / this._hi;
      var zhi = C + c;
      var zlo = C - zhi + c;
      return new DD(zhi, zlo)
    };
    DD.prototype.toSciNotation = function toSciNotation () {
      if (this.isZero()) { return DD.SCI_NOT_ZERO }
      var specialStr = this.getSpecialNumberString();
      if (specialStr !== null) { return specialStr }
      var magnitude = new Array(1).fill(null);
      var digits = this.extractSignificantDigits(false, magnitude);
      var expStr = DD.SCI_NOT_EXPONENT_CHAR + magnitude[0];
      if (digits.charAt(0) === '0') {
        throw new Error('Found leading zero: ' + digits)
      }
      var trailingDigits = '';
      if (digits.length > 1) { trailingDigits = digits.substring(1); }
      var digitsWithDecimal = digits.charAt(0) + '.' + trailingDigits;
      if (this.isNegative()) { return '-' + digitsWithDecimal + expStr }
      return digitsWithDecimal + expStr
    };
    DD.prototype.abs = function abs () {
      if (this.isNaN()) { return DD.NaN }
      if (this.isNegative()) { return this.negate() }
      return new DD(this)
    };
    DD.prototype.isPositive = function isPositive () {
      return (this._hi > 0.0 || this._hi === 0.0) && this._lo > 0.0
    };
    DD.prototype.lt = function lt (y) {
      return (this._hi < y._hi || this._hi === y._hi) && this._lo < y._lo
    };
    DD.prototype.add = function add () {
      if (arguments[0] instanceof DD) {
        var y = arguments[0];
        return DD.copy(this).selfAdd(y)
      } else if (typeof arguments[0] === 'number') {
        var y$1 = arguments[0];
        return DD.copy(this).selfAdd(y$1)
      }
    };
    DD.prototype.init = function init () {
      if (arguments.length === 1) {
        if (typeof arguments[0] === 'number') {
          var x = arguments[0];
          this._hi = x;
          this._lo = 0.0;
        } else if (arguments[0] instanceof DD) {
          var dd = arguments[0];
          this._hi = dd._hi;
          this._lo = dd._lo;
        }
      } else if (arguments.length === 2) {
        var hi = arguments[0];
        var lo = arguments[1];
        this._hi = hi;
        this._lo = lo;
      }
    };
    DD.prototype.gt = function gt (y) {
      return (this._hi > y._hi || this._hi === y._hi) && this._lo > y._lo
    };
    DD.prototype.isNegative = function isNegative () {
      return (this._hi < 0.0 || this._hi === 0.0) && this._lo < 0.0
    };
    DD.prototype.trunc = function trunc () {
      if (this.isNaN()) { return DD.NaN }
      if (this.isPositive()) { return this.floor(); } else { return this.ceil() }
    };
    DD.prototype.signum = function signum () {
      if (this._hi > 0) { return 1 }
      if (this._hi < 0) { return -1 }
      if (this._lo > 0) { return 1 }
      if (this._lo < 0) { return -1 }
      return 0
    };
    DD.prototype.interfaces_ = function interfaces_ () {
      return [Serializable, Comparable, Clonable]
    };
    DD.prototype.getClass = function getClass () {
      return DD
    };
    DD.sqr = function sqr (x) {
      return DD.valueOf(x).selfMultiply(x)
    };
    DD.valueOf = function valueOf () {
      if (typeof arguments[0] === 'string') {
        var str = arguments[0];
        return DD.parse(str)
      } else if (typeof arguments[0] === 'number') {
        var x = arguments[0];
        return new DD(x)
      }
    };
    DD.sqrt = function sqrt (x) {
      return DD.valueOf(x).sqrt()
    };
    DD.parse = function parse (str) {
      var i = 0;
      var strlen = str.length;
      while (Character.isWhitespace(str.charAt(i))) { i++; }
      var isNegative = false;
      if (i < strlen) {
        var signCh = str.charAt(i);
        if (signCh === '-' || signCh === '+') {
          i++;
          if (signCh === '-') { isNegative = true; }
        }
      }
      var val = new DD();
      var numDigits = 0;
      var numBeforeDec = 0;
      var exp = 0;
      while (true) {
        if (i >= strlen) { break }
        var ch = str.charAt(i);
        i++;
        if (Character.isDigit(ch)) {
          var d = ch - '0';
          val.selfMultiply(DD.TEN);
          val.selfAdd(d);
          numDigits++;
          continue
        }
        if (ch === '.') {
          numBeforeDec = numDigits;
          continue
        }
        if (ch === 'e' || ch === 'E') {
          var expStr = str.substring(i);
          try {
            exp = Integer.parseInt(expStr);
          } catch (ex) {
            if (ex instanceof Error) {
              throw new Error('Invalid exponent ' + expStr + ' in string ' + str)
            } else { throw ex }
          } finally {}
          break
        }
        throw new Error("Unexpected character '" + ch + "' at position " + i + ' in string ' + str)
      }
      var val2 = val;
      var numDecPlaces = numDigits - numBeforeDec - exp;
      if (numDecPlaces === 0) {
        val2 = val;
      } else if (numDecPlaces > 0) {
        var scale = DD.TEN.pow(numDecPlaces);
        val2 = val.divide(scale);
      } else if (numDecPlaces < 0) {
        var scale$1 = DD.TEN.pow(-numDecPlaces);
        val2 = val.multiply(scale$1);
      }
      if (isNegative) {
        return val2.negate()
      }
      return val2
    };
    DD.createNaN = function createNaN () {
      return new DD(Double.NaN, Double.NaN)
    };
    DD.copy = function copy (dd) {
      return new DD(dd)
    };
    DD.magnitude = function magnitude (x) {
      var xAbs = Math.abs(x);
      var xLog10 = Math.log(xAbs) / Math.log(10);
      var xMag = Math.trunc(Math.floor(xLog10));
      var xApprox = Math.pow(10, xMag);
      if (xApprox * 10 <= xAbs) { xMag += 1; }
      return xMag
    };
    DD.stringOfChar = function stringOfChar (ch, len) {
      var buf = new StringBuffer();
      for (var i = 0; i < len; i++) {
        buf.append(ch);
      }
      return buf.toString()
    };
    staticAccessors$7.PI.get = function () { return new DD(3.141592653589793116e+00, 1.224646799147353207e-16) };
    staticAccessors$7.TWO_PI.get = function () { return new DD(6.283185307179586232e+00, 2.449293598294706414e-16) };
    staticAccessors$7.PI_2.get = function () { return new DD(1.570796326794896558e+00, 6.123233995736766036e-17) };
    staticAccessors$7.E.get = function () { return new DD(2.718281828459045091e+00, 1.445646891729250158e-16) };
    staticAccessors$7.NaN.get = function () { return new DD(Double.NaN, Double.NaN) };
    staticAccessors$7.EPS.get = function () { return 1.23259516440783e-32 };
    staticAccessors$7.SPLIT.get = function () { return 134217729.0 };
    staticAccessors$7.MAX_PRINT_DIGITS.get = function () { return 32 };
    staticAccessors$7.TEN.get = function () { return DD.valueOf(10.0) };
    staticAccessors$7.ONE.get = function () { return DD.valueOf(1.0) };
    staticAccessors$7.SCI_NOT_EXPONENT_CHAR.get = function () { return 'E' };
    staticAccessors$7.SCI_NOT_ZERO.get = function () { return '0.0E0' };

    Object.defineProperties( DD, staticAccessors$7 );

    var CGAlgorithmsDD = function CGAlgorithmsDD () {};

    var staticAccessors$6 = { DP_SAFE_EPSILON: { configurable: true } };

    CGAlgorithmsDD.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CGAlgorithmsDD.prototype.getClass = function getClass () {
      return CGAlgorithmsDD
    };
    CGAlgorithmsDD.orientationIndex = function orientationIndex (p1, p2, q) {
      var index = CGAlgorithmsDD.orientationIndexFilter(p1, p2, q);
      if (index <= 1) { return index }
      var dx1 = DD.valueOf(p2.x).selfAdd(-p1.x);
      var dy1 = DD.valueOf(p2.y).selfAdd(-p1.y);
      var dx2 = DD.valueOf(q.x).selfAdd(-p2.x);
      var dy2 = DD.valueOf(q.y).selfAdd(-p2.y);
      return dx1.selfMultiply(dy2).selfSubtract(dy1.selfMultiply(dx2)).signum()
    };
    CGAlgorithmsDD.signOfDet2x2 = function signOfDet2x2 (x1, y1, x2, y2) {
      var det = x1.multiply(y2).selfSubtract(y1.multiply(x2));
      return det.signum()
    };
    CGAlgorithmsDD.intersection = function intersection (p1, p2, q1, q2) {
      var denom1 = DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(DD.valueOf(p2.x).selfSubtract(p1.x));
      var denom2 = DD.valueOf(q2.x).selfSubtract(q1.x).selfMultiply(DD.valueOf(p2.y).selfSubtract(p1.y));
      var denom = denom1.subtract(denom2);
      var numx1 = DD.valueOf(q2.x).selfSubtract(q1.x).selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
      var numx2 = DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
      var numx = numx1.subtract(numx2);
      var fracP = numx.selfDivide(denom).doubleValue();
      var x = DD.valueOf(p1.x).selfAdd(DD.valueOf(p2.x).selfSubtract(p1.x).selfMultiply(fracP)).doubleValue();
      var numy1 = DD.valueOf(p2.x).selfSubtract(p1.x).selfMultiply(DD.valueOf(p1.y).selfSubtract(q1.y));
      var numy2 = DD.valueOf(p2.y).selfSubtract(p1.y).selfMultiply(DD.valueOf(p1.x).selfSubtract(q1.x));
      var numy = numy1.subtract(numy2);
      var fracQ = numy.selfDivide(denom).doubleValue();
      var y = DD.valueOf(q1.y).selfAdd(DD.valueOf(q2.y).selfSubtract(q1.y).selfMultiply(fracQ)).doubleValue();
      return new Coordinate(x, y)
    };
    CGAlgorithmsDD.orientationIndexFilter = function orientationIndexFilter (pa, pb, pc) {
      var detsum = null;
      var detleft = (pa.x - pc.x) * (pb.y - pc.y);
      var detright = (pa.y - pc.y) * (pb.x - pc.x);
      var det = detleft - detright;
      if (detleft > 0.0) {
        if (detright <= 0.0) {
          return CGAlgorithmsDD.signum(det)
        } else {
          detsum = detleft + detright;
        }
      } else if (detleft < 0.0) {
        if (detright >= 0.0) {
          return CGAlgorithmsDD.signum(det)
        } else {
          detsum = -detleft - detright;
        }
      } else {
        return CGAlgorithmsDD.signum(det)
      }
      var errbound = CGAlgorithmsDD.DP_SAFE_EPSILON * detsum;
      if (det >= errbound || -det >= errbound) {
        return CGAlgorithmsDD.signum(det)
      }
      return 2
    };
    CGAlgorithmsDD.signum = function signum (x) {
      if (x > 0) { return 1 }
      if (x < 0) { return -1 }
      return 0
    };
    staticAccessors$6.DP_SAFE_EPSILON.get = function () { return 1e-15 };

    Object.defineProperties( CGAlgorithmsDD, staticAccessors$6 );

    var CoordinateSequence = function CoordinateSequence () {};

    var staticAccessors$8 = { X: { configurable: true },Y: { configurable: true },Z: { configurable: true },M: { configurable: true } };

    staticAccessors$8.X.get = function () { return 0 };
    staticAccessors$8.Y.get = function () { return 1 };
    staticAccessors$8.Z.get = function () { return 2 };
    staticAccessors$8.M.get = function () { return 3 };
    CoordinateSequence.prototype.setOrdinate = function setOrdinate (index, ordinateIndex, value) {};
    CoordinateSequence.prototype.size = function size () {};
    CoordinateSequence.prototype.getOrdinate = function getOrdinate (index, ordinateIndex) {};
    CoordinateSequence.prototype.getCoordinate = function getCoordinate () {};
    CoordinateSequence.prototype.getCoordinateCopy = function getCoordinateCopy (i) {};
    CoordinateSequence.prototype.getDimension = function getDimension () {};
    CoordinateSequence.prototype.getX = function getX (index) {};
    CoordinateSequence.prototype.clone = function clone () {};
    CoordinateSequence.prototype.expandEnvelope = function expandEnvelope (env) {};
    CoordinateSequence.prototype.copy = function copy () {};
    CoordinateSequence.prototype.getY = function getY (index) {};
    CoordinateSequence.prototype.toCoordinateArray = function toCoordinateArray () {};
    CoordinateSequence.prototype.interfaces_ = function interfaces_ () {
      return [Clonable]
    };
    CoordinateSequence.prototype.getClass = function getClass () {
      return CoordinateSequence
    };

    Object.defineProperties( CoordinateSequence, staticAccessors$8 );

    var Exception = function Exception () {};

    var NotRepresentableException = (function (Exception$$1) {
      function NotRepresentableException () {
        Exception$$1.call(this, 'Projective point not representable on the Cartesian plane.');
      }

      if ( Exception$$1 ) NotRepresentableException.__proto__ = Exception$$1;
      NotRepresentableException.prototype = Object.create( Exception$$1 && Exception$$1.prototype );
      NotRepresentableException.prototype.constructor = NotRepresentableException;
      NotRepresentableException.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      NotRepresentableException.prototype.getClass = function getClass () {
        return NotRepresentableException
      };

      return NotRepresentableException;
    }(Exception));

    var System = function System () {};

    System.arraycopy = function arraycopy (src, srcPos, dest, destPos, len) {
      var c = 0;
      for (var i = srcPos; i < srcPos + len; i++) {
        dest[destPos + c] = src[i];
        c++;
      }
    };

    System.getProperty = function getProperty (name) {
      return {
        'line.separator': '\n'
      }[name]
    };

    var HCoordinate = function HCoordinate () {
      this.x = null;
      this.y = null;
      this.w = null;
      if (arguments.length === 0) {
        this.x = 0.0;
        this.y = 0.0;
        this.w = 1.0;
      } else if (arguments.length === 1) {
        var p = arguments[0];
        this.x = p.x;
        this.y = p.y;
        this.w = 1.0;
      } else if (arguments.length === 2) {
        if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
          var _x = arguments[0];
          var _y = arguments[1];
          this.x = _x;
          this.y = _y;
          this.w = 1.0;
        } else if (arguments[0] instanceof HCoordinate && arguments[1] instanceof HCoordinate) {
          var p1 = arguments[0];
          var p2 = arguments[1];
          this.x = p1.y * p2.w - p2.y * p1.w;
          this.y = p2.x * p1.w - p1.x * p2.w;
          this.w = p1.x * p2.y - p2.x * p1.y;
        } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
          var p1$1 = arguments[0];
          var p2$1 = arguments[1];
          this.x = p1$1.y - p2$1.y;
          this.y = p2$1.x - p1$1.x;
          this.w = p1$1.x * p2$1.y - p2$1.x * p1$1.y;
        }
      } else if (arguments.length === 3) {
        var _x$1 = arguments[0];
        var _y$1 = arguments[1];
        var _w = arguments[2];
        this.x = _x$1;
        this.y = _y$1;
        this.w = _w;
      } else if (arguments.length === 4) {
        var p1$2 = arguments[0];
        var p2$2 = arguments[1];
        var q1 = arguments[2];
        var q2 = arguments[3];
        var px = p1$2.y - p2$2.y;
        var py = p2$2.x - p1$2.x;
        var pw = p1$2.x * p2$2.y - p2$2.x * p1$2.y;
        var qx = q1.y - q2.y;
        var qy = q2.x - q1.x;
        var qw = q1.x * q2.y - q2.x * q1.y;
        this.x = py * qw - qy * pw;
        this.y = qx * pw - px * qw;
        this.w = px * qy - qx * py;
      }
    };
    HCoordinate.prototype.getY = function getY () {
      var a = this.y / this.w;
      if (Double.isNaN(a) || Double.isInfinite(a)) {
        throw new NotRepresentableException()
      }
      return a
    };
    HCoordinate.prototype.getX = function getX () {
      var a = this.x / this.w;
      if (Double.isNaN(a) || Double.isInfinite(a)) {
        throw new NotRepresentableException()
      }
      return a
    };
    HCoordinate.prototype.getCoordinate = function getCoordinate () {
      var p = new Coordinate();
      p.x = this.getX();
      p.y = this.getY();
      return p
    };
    HCoordinate.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    HCoordinate.prototype.getClass = function getClass () {
      return HCoordinate
    };
    HCoordinate.intersection = function intersection (p1, p2, q1, q2) {
      var px = p1.y - p2.y;
      var py = p2.x - p1.x;
      var pw = p1.x * p2.y - p2.x * p1.y;
      var qx = q1.y - q2.y;
      var qy = q2.x - q1.x;
      var qw = q1.x * q2.y - q2.x * q1.y;
      var x = py * qw - qy * pw;
      var y = qx * pw - px * qw;
      var w = px * qy - qx * py;
      var xInt = x / w;
      var yInt = y / w;
      if (Double.isNaN(xInt) || (Double.isInfinite(xInt) || Double.isNaN(yInt)) || Double.isInfinite(yInt)) {
        throw new NotRepresentableException()
      }
      return new Coordinate(xInt, yInt)
    };

    var Envelope = function Envelope () {
      this._minx = null;
      this._maxx = null;
      this._miny = null;
      this._maxy = null;
      if (arguments.length === 0) {
        this.init();
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          this.init(p.x, p.x, p.y, p.y);
        } else if (arguments[0] instanceof Envelope) {
          var env = arguments[0];
          this.init(env);
        }
      } else if (arguments.length === 2) {
        var p1 = arguments[0];
        var p2 = arguments[1];
        this.init(p1.x, p2.x, p1.y, p2.y);
      } else if (arguments.length === 4) {
        var x1 = arguments[0];
        var x2 = arguments[1];
        var y1 = arguments[2];
        var y2 = arguments[3];
        this.init(x1, x2, y1, y2);
      }
    };

    var staticAccessors$9 = { serialVersionUID: { configurable: true } };
    Envelope.prototype.getArea = function getArea () {
      return this.getWidth() * this.getHeight()
    };
    Envelope.prototype.equals = function equals (other) {
      if (!(other instanceof Envelope)) {
        return false
      }
      var otherEnvelope = other;
      if (this.isNull()) {
        return otherEnvelope.isNull()
      }
      return this._maxx === otherEnvelope.getMaxX() && this._maxy === otherEnvelope.getMaxY() && this._minx === otherEnvelope.getMinX() && this._miny === otherEnvelope.getMinY()
    };
    Envelope.prototype.intersection = function intersection (env) {
      if (this.isNull() || env.isNull() || !this.intersects(env)) { return new Envelope() }
      var intMinX = this._minx > env._minx ? this._minx : env._minx;
      var intMinY = this._miny > env._miny ? this._miny : env._miny;
      var intMaxX = this._maxx < env._maxx ? this._maxx : env._maxx;
      var intMaxY = this._maxy < env._maxy ? this._maxy : env._maxy;
      return new Envelope(intMinX, intMaxX, intMinY, intMaxY)
    };
    Envelope.prototype.isNull = function isNull () {
      return this._maxx < this._minx
    };
    Envelope.prototype.getMaxX = function getMaxX () {
      return this._maxx
    };
    Envelope.prototype.covers = function covers () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          return this.covers(p.x, p.y)
        } else if (arguments[0] instanceof Envelope) {
          var other = arguments[0];
          if (this.isNull() || other.isNull()) {
            return false
          }
          return other.getMinX() >= this._minx && other.getMaxX() <= this._maxx && other.getMinY() >= this._miny && other.getMaxY() <= this._maxy
        }
      } else if (arguments.length === 2) {
        var x = arguments[0];
        var y = arguments[1];
        if (this.isNull()) { return false }
        return x >= this._minx && x <= this._maxx && y >= this._miny && y <= this._maxy
      }
    };
    Envelope.prototype.intersects = function intersects () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof Envelope) {
          var other = arguments[0];
          if (this.isNull() || other.isNull()) {
            return false
          }
          return !(other._minx > this._maxx || other._maxx < this._minx || other._miny > this._maxy || other._maxy < this._miny)
        } else if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          return this.intersects(p.x, p.y)
        }
      } else if (arguments.length === 2) {
        var x = arguments[0];
        var y = arguments[1];
        if (this.isNull()) { return false }
        return !(x > this._maxx || x < this._minx || y > this._maxy || y < this._miny)
      }
    };
    Envelope.prototype.getMinY = function getMinY () {
      return this._miny
    };
    Envelope.prototype.getMinX = function getMinX () {
      return this._minx
    };
    Envelope.prototype.expandToInclude = function expandToInclude () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          this.expandToInclude(p.x, p.y);
        } else if (arguments[0] instanceof Envelope) {
          var other = arguments[0];
          if (other.isNull()) {
            return null
          }
          if (this.isNull()) {
            this._minx = other.getMinX();
            this._maxx = other.getMaxX();
            this._miny = other.getMinY();
            this._maxy = other.getMaxY();
          } else {
            if (other._minx < this._minx) {
              this._minx = other._minx;
            }
            if (other._maxx > this._maxx) {
              this._maxx = other._maxx;
            }
            if (other._miny < this._miny) {
              this._miny = other._miny;
            }
            if (other._maxy > this._maxy) {
              this._maxy = other._maxy;
            }
          }
        }
      } else if (arguments.length === 2) {
        var x = arguments[0];
        var y = arguments[1];
        if (this.isNull()) {
          this._minx = x;
          this._maxx = x;
          this._miny = y;
          this._maxy = y;
        } else {
          if (x < this._minx) {
            this._minx = x;
          }
          if (x > this._maxx) {
            this._maxx = x;
          }
          if (y < this._miny) {
            this._miny = y;
          }
          if (y > this._maxy) {
            this._maxy = y;
          }
        }
      }
    };
    Envelope.prototype.minExtent = function minExtent () {
      if (this.isNull()) { return 0.0 }
      var w = this.getWidth();
      var h = this.getHeight();
      if (w < h) { return w }
      return h
    };
    Envelope.prototype.getWidth = function getWidth () {
      if (this.isNull()) {
        return 0
      }
      return this._maxx - this._minx
    };
    Envelope.prototype.compareTo = function compareTo (o) {
      var env = o;
      if (this.isNull()) {
        if (env.isNull()) { return 0 }
        return -1
      } else {
        if (env.isNull()) { return 1 }
      }
      if (this._minx < env._minx) { return -1 }
      if (this._minx > env._minx) { return 1 }
      if (this._miny < env._miny) { return -1 }
      if (this._miny > env._miny) { return 1 }
      if (this._maxx < env._maxx) { return -1 }
      if (this._maxx > env._maxx) { return 1 }
      if (this._maxy < env._maxy) { return -1 }
      if (this._maxy > env._maxy) { return 1 }
      return 0
    };
    Envelope.prototype.translate = function translate (transX, transY) {
      if (this.isNull()) {
        return null
      }
      this.init(this.getMinX() + transX, this.getMaxX() + transX, this.getMinY() + transY, this.getMaxY() + transY);
    };
    Envelope.prototype.toString = function toString () {
      return 'Env[' + this._minx + ' : ' + this._maxx + ', ' + this._miny + ' : ' + this._maxy + ']'
    };
    Envelope.prototype.setToNull = function setToNull () {
      this._minx = 0;
      this._maxx = -1;
      this._miny = 0;
      this._maxy = -1;
    };
    Envelope.prototype.getHeight = function getHeight () {
      if (this.isNull()) {
        return 0
      }
      return this._maxy - this._miny
    };
    Envelope.prototype.maxExtent = function maxExtent () {
      if (this.isNull()) { return 0.0 }
      var w = this.getWidth();
      var h = this.getHeight();
      if (w > h) { return w }
      return h
    };
    Envelope.prototype.expandBy = function expandBy () {
      if (arguments.length === 1) {
        var distance = arguments[0];
        this.expandBy(distance, distance);
      } else if (arguments.length === 2) {
        var deltaX = arguments[0];
        var deltaY = arguments[1];
        if (this.isNull()) { return null }
        this._minx -= deltaX;
        this._maxx += deltaX;
        this._miny -= deltaY;
        this._maxy += deltaY;
        if (this._minx > this._maxx || this._miny > this._maxy) { this.setToNull(); }
      }
    };
    Envelope.prototype.contains = function contains () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof Envelope) {
          var other = arguments[0];
          return this.covers(other)
        } else if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          return this.covers(p)
        }
      } else if (arguments.length === 2) {
        var x = arguments[0];
        var y = arguments[1];
        return this.covers(x, y)
      }
    };
    Envelope.prototype.centre = function centre () {
      if (this.isNull()) { return null }
      return new Coordinate((this.getMinX() + this.getMaxX()) / 2.0, (this.getMinY() + this.getMaxY()) / 2.0)
    };
    Envelope.prototype.init = function init () {
      if (arguments.length === 0) {
        this.setToNull();
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Coordinate) {
          var p = arguments[0];
          this.init(p.x, p.x, p.y, p.y);
        } else if (arguments[0] instanceof Envelope) {
          var env = arguments[0];
          this._minx = env._minx;
          this._maxx = env._maxx;
          this._miny = env._miny;
          this._maxy = env._maxy;
        }
      } else if (arguments.length === 2) {
        var p1 = arguments[0];
        var p2 = arguments[1];
        this.init(p1.x, p2.x, p1.y, p2.y);
      } else if (arguments.length === 4) {
        var x1 = arguments[0];
        var x2 = arguments[1];
        var y1 = arguments[2];
        var y2 = arguments[3];
        if (x1 < x2) {
          this._minx = x1;
          this._maxx = x2;
        } else {
          this._minx = x2;
          this._maxx = x1;
        }
        if (y1 < y2) {
          this._miny = y1;
          this._maxy = y2;
        } else {
          this._miny = y2;
          this._maxy = y1;
        }
      }
    };
    Envelope.prototype.getMaxY = function getMaxY () {
      return this._maxy
    };
    Envelope.prototype.distance = function distance (env) {
      if (this.intersects(env)) { return 0 }
      var dx = 0.0;
      if (this._maxx < env._minx) { dx = env._minx - this._maxx; } else if (this._minx > env._maxx) { dx = this._minx - env._maxx; }
      var dy = 0.0;
      if (this._maxy < env._miny) { dy = env._miny - this._maxy; } else if (this._miny > env._maxy) { dy = this._miny - env._maxy; }
      if (dx === 0.0) { return dy }
      if (dy === 0.0) { return dx }
      return Math.sqrt(dx * dx + dy * dy)
    };
    Envelope.prototype.hashCode = function hashCode () {
      var result = 17;
      result = 37 * result + Coordinate.hashCode(this._minx);
      result = 37 * result + Coordinate.hashCode(this._maxx);
      result = 37 * result + Coordinate.hashCode(this._miny);
      result = 37 * result + Coordinate.hashCode(this._maxy);
      return result
    };
    Envelope.prototype.interfaces_ = function interfaces_ () {
      return [Comparable, Serializable]
    };
    Envelope.prototype.getClass = function getClass () {
      return Envelope
    };
    Envelope.intersects = function intersects () {
      if (arguments.length === 3) {
        var p1 = arguments[0];
        var p2 = arguments[1];
        var q = arguments[2];
        if (q.x >= (p1.x < p2.x ? p1.x : p2.x) && q.x <= (p1.x > p2.x ? p1.x : p2.x) && (q.y >= (p1.y < p2.y ? p1.y : p2.y) && q.y <= (p1.y > p2.y ? p1.y : p2.y))) {
          return true
        }
        return false
      } else if (arguments.length === 4) {
        var p1$1 = arguments[0];
        var p2$1 = arguments[1];
        var q1 = arguments[2];
        var q2 = arguments[3];
        var minq = Math.min(q1.x, q2.x);
        var maxq = Math.max(q1.x, q2.x);
        var minp = Math.min(p1$1.x, p2$1.x);
        var maxp = Math.max(p1$1.x, p2$1.x);
        if (minp > maxq) { return false }
        if (maxp < minq) { return false }
        minq = Math.min(q1.y, q2.y);
        maxq = Math.max(q1.y, q2.y);
        minp = Math.min(p1$1.y, p2$1.y);
        maxp = Math.max(p1$1.y, p2$1.y);
        if (minp > maxq) { return false }
        if (maxp < minq) { return false }
        return true
      }
    };
    staticAccessors$9.serialVersionUID.get = function () { return 5873921885273102420 };

    Object.defineProperties( Envelope, staticAccessors$9 );

    var regExes = {
      'typeStr': /^\s*(\w+)\s*\(\s*(.*)\s*\)\s*$/,
      'emptyTypeStr': /^\s*(\w+)\s*EMPTY\s*$/,
      'spaces': /\s+/,
      'parenComma': /\)\s*,\s*\(/,
      'doubleParenComma': /\)\s*\)\s*,\s*\(\s*\(/, // can't use {2} here
      'trimParens': /^\s*\(?(.*?)\)?\s*$/
    };

    /**
     * Class for reading and writing Well-Known Text.
     *
     * NOTE: Adapted from OpenLayers 2.11 implementation.
     */

    /** Create a new parser for WKT
     *
     * @param {GeometryFactory} geometryFactory
     * @return An instance of WKTParser.
     * @constructor
     * @private
     */
    var WKTParser = function WKTParser (geometryFactory) {
      this.geometryFactory = geometryFactory || new GeometryFactory();
    };
    /**
     * Deserialize a WKT string and return a geometry. Supports WKT for POINT,
     * MULTIPOINT, LINESTRING, LINEARRING, MULTILINESTRING, POLYGON, MULTIPOLYGON,
     * and GEOMETRYCOLLECTION.
     *
     * @param {String} wkt A WKT string.
     * @return {Geometry} A geometry instance.
     * @private
     */
    WKTParser.prototype.read = function read (wkt) {
      var geometry, type, str;
      wkt = wkt.replace(/[\n\r]/g, ' ');
      var matches = regExes.typeStr.exec(wkt);
      if (wkt.search('EMPTY') !== -1) {
        matches = regExes.emptyTypeStr.exec(wkt);
        matches[2] = undefined;
      }
      if (matches) {
        type = matches[1].toLowerCase();
        str = matches[2];
        if (parse$1[type]) {
          geometry = parse$1[type].apply(this, [str]);
        }
      }

      if (geometry === undefined) { throw new Error('Could not parse WKT ' + wkt) }

      return geometry
    };

    /**
     * Serialize a geometry into a WKT string.
     *
     * @param {Geometry} geometry A feature or array of features.
     * @return {String} The WKT string representation of the input geometries.
     * @private
     */
    WKTParser.prototype.write = function write (geometry) {
      return this.extractGeometry(geometry)
    };

    /**
     * Entry point to construct the WKT for a single Geometry object.
     *
     * @param {Geometry} geometry
     * @return {String} A WKT string of representing the geometry.
     * @private
     */
    WKTParser.prototype.extractGeometry = function extractGeometry (geometry) {
      var type = geometry.getGeometryType().toLowerCase();
      if (!extract$1[type]) {
        return null
      }
      var wktType = type.toUpperCase();
      var data;
      if (geometry.isEmpty()) {
        data = wktType + ' EMPTY';
      } else {
        data = wktType + '(' + extract$1[type].apply(this, [geometry]) + ')';
      }
      return data
    };

    /**
     * Object with properties corresponding to the geometry types. Property values
     * are functions that do the actual data extraction.
     * @private
     */
    var extract$1 = {
      coordinate: function coordinate (coordinate$1) {
        return coordinate$1.x + ' ' + coordinate$1.y
      },

      /**
       * Return a space delimited string of point coordinates.
       *
       * @param {Point}
       *          point
       * @return {String} A string of coordinates representing the point.
       */
      point: function point (point$1) {
        return extract$1.coordinate.call(this, point$1._coordinates._coordinates[0])
      },

      /**
       * Return a comma delimited string of point coordinates from a multipoint.
       *
       * @param {MultiPoint}
       *          multipoint
       * @return {String} A string of point coordinate strings representing the
       *         multipoint.
       */
      multipoint: function multipoint (multipoint$1) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = multipoint$1._geometries.length; i < len; ++i) {
          array.push('(' + extract$1.point.apply(this$1, [multipoint$1._geometries[i]]) + ')');
        }
        return array.join(',')
      },

      /**
       * Return a comma delimited string of point coordinates from a line.
       *
       * @param {LineString} linestring
       * @return {String} A string of point coordinate strings representing the linestring.
       */
      linestring: function linestring (linestring$1) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = linestring$1._points._coordinates.length; i < len; ++i) {
          array.push(extract$1.coordinate.apply(this$1, [linestring$1._points._coordinates[i]]));
        }
        return array.join(',')
      },

      linearring: function linearring (linearring$1) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = linearring$1._points._coordinates.length; i < len; ++i) {
          array.push(extract$1.coordinate.apply(this$1, [linearring$1._points._coordinates[i]]));
        }
        return array.join(',')
      },

      /**
       * Return a comma delimited string of linestring strings from a
       * multilinestring.
       *
       * @param {MultiLineString} multilinestring
       * @return {String} A string of of linestring strings representing the multilinestring.
       */
      multilinestring: function multilinestring (multilinestring$1) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = multilinestring$1._geometries.length; i < len; ++i) {
          array.push('(' +
            extract$1.linestring.apply(this$1, [multilinestring$1._geometries[i]]) +
            ')');
        }
        return array.join(',')
      },

      /**
       * Return a comma delimited string of linear ring arrays from a polygon.
       *
       * @param {Polygon} polygon
       * @return {String} An array of linear ring arrays representing the polygon.
       */
      polygon: function polygon (polygon$1) {
        var this$1 = this;

        var array = [];
        array.push('(' + extract$1.linestring.apply(this, [polygon$1._shell]) + ')');
        for (var i = 0, len = polygon$1._holes.length; i < len; ++i) {
          array.push('(' + extract$1.linestring.apply(this$1, [polygon$1._holes[i]]) + ')');
        }
        return array.join(',')
      },

      /**
       * Return an array of polygon arrays from a multipolygon.
       *
       * @param {MultiPolygon} multipolygon
       * @return {String} An array of polygon arrays representing the multipolygon.
       */
      multipolygon: function multipolygon (multipolygon$1) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = multipolygon$1._geometries.length; i < len; ++i) {
          array.push('(' + extract$1.polygon.apply(this$1, [multipolygon$1._geometries[i]]) + ')');
        }
        return array.join(',')
      },

      /**
       * Return the WKT portion between 'GEOMETRYCOLLECTION(' and ')' for an
       * geometrycollection.
       *
       * @param {GeometryCollection} collection
       * @return {String} internal WKT representation of the collection.
       */
      geometrycollection: function geometrycollection (collection) {
        var this$1 = this;

        var array = [];
        for (var i = 0, len = collection._geometries.length; i < len; ++i) {
          array.push(this$1.extractGeometry(collection._geometries[i]));
        }
        return array.join(',')
      }
    };

    /**
     * Object with properties corresponding to the geometry types. Property values
     * are functions that do the actual parsing.
     * @private
     */
    var parse$1 = {
      /**
       * Return point geometry given a point WKT fragment.
       *
       * @param {String} str A WKT fragment representing the point.
       * @return {Point} A point geometry.
       * @private
       */
      point: function point (str) {
        if (str === undefined) {
          return this.geometryFactory.createPoint()
        }

        var coords = str.trim().split(regExes.spaces);
        return this.geometryFactory.createPoint(new Coordinate(Number.parseFloat(coords[0]),
          Number.parseFloat(coords[1])))
      },

      /**
       * Return a multipoint geometry given a multipoint WKT fragment.
       *
       * @param {String} str A WKT fragment representing the multipoint.
       * @return {Point} A multipoint feature.
       * @private
       */
      multipoint: function multipoint (str) {
        var this$1 = this;

        if (str === undefined) {
          return this.geometryFactory.createMultiPoint()
        }

        var point;
        var points = str.trim().split(',');
        var components = [];
        for (var i = 0, len = points.length; i < len; ++i) {
          point = points[i].replace(regExes.trimParens, '$1');
          components.push(parse$1.point.apply(this$1, [point]));
        }
        return this.geometryFactory.createMultiPoint(components)
      },

      /**
       * Return a linestring geometry given a linestring WKT fragment.
       *
       * @param {String} str A WKT fragment representing the linestring.
       * @return {LineString} A linestring geometry.
       * @private
       */
      linestring: function linestring (str) {
        if (str === undefined) {
          return this.geometryFactory.createLineString()
        }

        var points = str.trim().split(',');
        var components = [];
        var coords;
        for (var i = 0, len = points.length; i < len; ++i) {
          coords = points[i].trim().split(regExes.spaces);
          components.push(new Coordinate(Number.parseFloat(coords[0]), Number.parseFloat(coords[1])));
        }
        return this.geometryFactory.createLineString(components)
      },

      /**
       * Return a linearring geometry given a linearring WKT fragment.
       *
       * @param {String} str A WKT fragment representing the linearring.
       * @return {LinearRing} A linearring geometry.
       * @private
       */
      linearring: function linearring (str) {
        if (str === undefined) {
          return this.geometryFactory.createLinearRing()
        }

        var points = str.trim().split(',');
        var components = [];
        var coords;
        for (var i = 0, len = points.length; i < len; ++i) {
          coords = points[i].trim().split(regExes.spaces);
          components.push(new Coordinate(Number.parseFloat(coords[0]), Number.parseFloat(coords[1])));
        }
        return this.geometryFactory.createLinearRing(components)
      },

      /**
       * Return a multilinestring geometry given a multilinestring WKT fragment.
       *
       * @param {String} str A WKT fragment representing the multilinestring.
       * @return {MultiLineString} A multilinestring geometry.
       * @private
       */
      multilinestring: function multilinestring (str) {
        var this$1 = this;

        if (str === undefined) {
          return this.geometryFactory.createMultiLineString()
        }

        var line;
        var lines = str.trim().split(regExes.parenComma);
        var components = [];
        for (var i = 0, len = lines.length; i < len; ++i) {
          line = lines[i].replace(regExes.trimParens, '$1');
          components.push(parse$1.linestring.apply(this$1, [line]));
        }
        return this.geometryFactory.createMultiLineString(components)
      },

      /**
       * Return a polygon geometry given a polygon WKT fragment.
       *
       * @param {String} str A WKT fragment representing the polygon.
       * @return {Polygon} A polygon geometry.
       * @private
       */
      polygon: function polygon (str) {
        var this$1 = this;

        if (str === undefined) {
          return this.geometryFactory.createPolygon()
        }

        var ring, linestring, linearring;
        var rings = str.trim().split(regExes.parenComma);
        var shell;
        var holes = [];
        for (var i = 0, len = rings.length; i < len; ++i) {
          ring = rings[i].replace(regExes.trimParens, '$1');
          linestring = parse$1.linestring.apply(this$1, [ring]);
          linearring = this$1.geometryFactory.createLinearRing(linestring._points);
          if (i === 0) {
            shell = linearring;
          } else {
            holes.push(linearring);
          }
        }
        return this.geometryFactory.createPolygon(shell, holes)
      },

      /**
       * Return a multipolygon geometry given a multipolygon WKT fragment.
       *
       * @param {String} str A WKT fragment representing the multipolygon.
       * @return {MultiPolygon} A multipolygon geometry.
       * @private
       */
      multipolygon: function multipolygon (str) {
        var this$1 = this;

        if (str === undefined) {
          return this.geometryFactory.createMultiPolygon()
        }

        var polygon;
        var polygons = str.trim().split(regExes.doubleParenComma);
        var components = [];
        for (var i = 0, len = polygons.length; i < len; ++i) {
          polygon = polygons[i].replace(regExes.trimParens, '$1');
          components.push(parse$1.polygon.apply(this$1, [polygon]));
        }
        return this.geometryFactory.createMultiPolygon(components)
      },

      /**
       * Return a geometrycollection given a geometrycollection WKT fragment.
       *
       * @param {String} str A WKT fragment representing the geometrycollection.
       * @return {GeometryCollection}
       * @private
       */
      geometrycollection: function geometrycollection (str) {
        var this$1 = this;

        if (str === undefined) {
          return this.geometryFactory.createGeometryCollection()
        }

        // separate components of the collection with |
        str = str.replace(/,\s*([A-Za-z])/g, '|$1');
        var wktArray = str.trim().split('|');
        var components = [];
        for (var i = 0, len = wktArray.length; i < len; ++i) {
          components.push(this$1.read(wktArray[i]));
        }
        return this.geometryFactory.createGeometryCollection(components)
      }
    };

    /**
     * Writes the Well-Known Text representation of a {@link Geometry}. The
     * Well-Known Text format is defined in the <A
     * HREF="http://www.opengis.org/techno/specs.htm"> OGC Simple Features
     * Specification for SQL</A>.
     * <p>
     * The <code>WKTWriter</code> outputs coordinates rounded to the precision
     * model. Only the maximum number of decimal places necessary to represent the
     * ordinates to the required precision will be output.
     * <p>
     * The SFS WKT spec does not define a special tag for {@link LinearRing}s.
     * Under the spec, rings are output as <code>LINESTRING</code>s.
     */

    /**
     * @param {GeometryFactory} geometryFactory
     * @constructor
     */
    var WKTWriter = function WKTWriter (geometryFactory) {
      this.parser = new WKTParser(geometryFactory);
    };

    /**
     * Converts a <code>Geometry</code> to its Well-known Text representation.
     *
     * @param {Geometry} geometry a <code>Geometry</code> to process.
     * @return {string} a <Geometry Tagged Text> string (see the OpenGIS Simple
     *       Features Specification).
     * @memberof WKTWriter
     */
    WKTWriter.prototype.write = function write (geometry) {
      return this.parser.write(geometry)
    };
    /**
     * Generates the WKT for a <tt>LINESTRING</tt> specified by two
     * {@link Coordinate}s.
     *
     * @param p0 the first coordinate.
     * @param p1 the second coordinate.
     *
     * @return the WKT.
     * @private
     */
    WKTWriter.toLineString = function toLineString (p0, p1) {
      if (arguments.length !== 2) {
        throw new Error('Not implemented')
      }
      return 'LINESTRING ( ' + p0.x + ' ' + p0.y + ', ' + p1.x + ' ' + p1.y + ' )'
    };

    var RuntimeException = (function (Error) {
      function RuntimeException (message) {
        Error.call(this, message);
        this.name = 'RuntimeException';
        this.message = message;
        this.stack = (new Error()).stack;
      }

      if ( Error ) RuntimeException.__proto__ = Error;
      RuntimeException.prototype = Object.create( Error && Error.prototype );
      RuntimeException.prototype.constructor = RuntimeException;

      return RuntimeException;
    }(Error));

    var AssertionFailedException = (function (RuntimeException$$1) {
      function AssertionFailedException () {
        RuntimeException$$1.call(this);
        if (arguments.length === 0) {
          RuntimeException$$1.call(this);
        } else if (arguments.length === 1) {
          var message = arguments[0];
          RuntimeException$$1.call(this, message);
        }
      }

      if ( RuntimeException$$1 ) AssertionFailedException.__proto__ = RuntimeException$$1;
      AssertionFailedException.prototype = Object.create( RuntimeException$$1 && RuntimeException$$1.prototype );
      AssertionFailedException.prototype.constructor = AssertionFailedException;
      AssertionFailedException.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      AssertionFailedException.prototype.getClass = function getClass () {
        return AssertionFailedException
      };

      return AssertionFailedException;
    }(RuntimeException));

    var Assert = function Assert () {};

    Assert.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Assert.prototype.getClass = function getClass () {
      return Assert
    };
    Assert.shouldNeverReachHere = function shouldNeverReachHere () {
      if (arguments.length === 0) {
        Assert.shouldNeverReachHere(null);
      } else if (arguments.length === 1) {
        var message = arguments[0];
        throw new AssertionFailedException('Should never reach here' + (message !== null ? ': ' + message : ''))
      }
    };
    Assert.isTrue = function isTrue () {
      var assertion;
      var message;
      if (arguments.length === 1) {
        assertion = arguments[0];
        Assert.isTrue(assertion, null);
      } else if (arguments.length === 2) {
        assertion = arguments[0];
        message = arguments[1];
        if (!assertion) {
          if (message === null) {
            throw new AssertionFailedException()
          } else {
            throw new AssertionFailedException(message)
          }
        }
      }
    };
    Assert.equals = function equals () {
      var expectedValue;
      var actualValue;
      var message;
      if (arguments.length === 2) {
        expectedValue = arguments[0];
        actualValue = arguments[1];
        Assert.equals(expectedValue, actualValue, null);
      } else if (arguments.length === 3) {
        expectedValue = arguments[0];
        actualValue = arguments[1];
        message = arguments[2];
        if (!actualValue.equals(expectedValue)) {
          throw new AssertionFailedException('Expected ' + expectedValue + ' but encountered ' + actualValue + (message !== null ? ': ' + message : ''))
        }
      }
    };

    var LineIntersector = function LineIntersector () {
      this._result = null;
      this._inputLines = Array(2).fill().map(function () { return Array(2); });
      this._intPt = new Array(2).fill(null);
      this._intLineIndex = null;
      this._isProper = null;
      this._pa = null;
      this._pb = null;
      this._precisionModel = null;
      this._intPt[0] = new Coordinate();
      this._intPt[1] = new Coordinate();
      this._pa = this._intPt[0];
      this._pb = this._intPt[1];
      this._result = 0;
    };

    var staticAccessors$10 = { DONT_INTERSECT: { configurable: true },DO_INTERSECT: { configurable: true },COLLINEAR: { configurable: true },NO_INTERSECTION: { configurable: true },POINT_INTERSECTION: { configurable: true },COLLINEAR_INTERSECTION: { configurable: true } };
    LineIntersector.prototype.getIndexAlongSegment = function getIndexAlongSegment (segmentIndex, intIndex) {
      this.computeIntLineIndex();
      return this._intLineIndex[segmentIndex][intIndex]
    };
    LineIntersector.prototype.getTopologySummary = function getTopologySummary () {
      var catBuf = new StringBuffer();
      if (this.isEndPoint()) { catBuf.append(' endpoint'); }
      if (this._isProper) { catBuf.append(' proper'); }
      if (this.isCollinear()) { catBuf.append(' collinear'); }
      return catBuf.toString()
    };
    LineIntersector.prototype.computeIntersection = function computeIntersection (p1, p2, p3, p4) {
      this._inputLines[0][0] = p1;
      this._inputLines[0][1] = p2;
      this._inputLines[1][0] = p3;
      this._inputLines[1][1] = p4;
      this._result = this.computeIntersect(p1, p2, p3, p4);
    };
    LineIntersector.prototype.getIntersectionNum = function getIntersectionNum () {
      return this._result
    };
    LineIntersector.prototype.computeIntLineIndex = function computeIntLineIndex () {
      if (arguments.length === 0) {
        if (this._intLineIndex === null) {
          this._intLineIndex = Array(2).fill().map(function () { return Array(2); });
          this.computeIntLineIndex(0);
          this.computeIntLineIndex(1);
        }
      } else if (arguments.length === 1) {
        var segmentIndex = arguments[0];
        var dist0 = this.getEdgeDistance(segmentIndex, 0);
        var dist1 = this.getEdgeDistance(segmentIndex, 1);
        if (dist0 > dist1) {
          this._intLineIndex[segmentIndex][0] = 0;
          this._intLineIndex[segmentIndex][1] = 1;
        } else {
          this._intLineIndex[segmentIndex][0] = 1;
          this._intLineIndex[segmentIndex][1] = 0;
        }
      }
    };
    LineIntersector.prototype.isProper = function isProper () {
      return this.hasIntersection() && this._isProper
    };
    LineIntersector.prototype.setPrecisionModel = function setPrecisionModel (precisionModel) {
      this._precisionModel = precisionModel;
    };
    LineIntersector.prototype.isInteriorIntersection = function isInteriorIntersection () {
        var this$1 = this;

      if (arguments.length === 0) {
        if (this.isInteriorIntersection(0)) { return true }
        if (this.isInteriorIntersection(1)) { return true }
        return false
      } else if (arguments.length === 1) {
        var inputLineIndex = arguments[0];
        for (var i = 0; i < this._result; i++) {
          if (!(this$1._intPt[i].equals2D(this$1._inputLines[inputLineIndex][0]) || this$1._intPt[i].equals2D(this$1._inputLines[inputLineIndex][1]))) {
            return true
          }
        }
        return false
      }
    };
    LineIntersector.prototype.getIntersection = function getIntersection (intIndex) {
      return this._intPt[intIndex]
    };
    LineIntersector.prototype.isEndPoint = function isEndPoint () {
      return this.hasIntersection() && !this._isProper
    };
    LineIntersector.prototype.hasIntersection = function hasIntersection () {
      return this._result !== LineIntersector.NO_INTERSECTION
    };
    LineIntersector.prototype.getEdgeDistance = function getEdgeDistance (segmentIndex, intIndex) {
      var dist = LineIntersector.computeEdgeDistance(this._intPt[intIndex], this._inputLines[segmentIndex][0], this._inputLines[segmentIndex][1]);
      return dist
    };
    LineIntersector.prototype.isCollinear = function isCollinear () {
      return this._result === LineIntersector.COLLINEAR_INTERSECTION
    };
    LineIntersector.prototype.toString = function toString () {
      return WKTWriter.toLineString(this._inputLines[0][0], this._inputLines[0][1]) + ' - ' + WKTWriter.toLineString(this._inputLines[1][0], this._inputLines[1][1]) + this.getTopologySummary()
    };
    LineIntersector.prototype.getEndpoint = function getEndpoint (segmentIndex, ptIndex) {
      return this._inputLines[segmentIndex][ptIndex]
    };
    LineIntersector.prototype.isIntersection = function isIntersection (pt) {
        var this$1 = this;

      for (var i = 0; i < this._result; i++) {
        if (this$1._intPt[i].equals2D(pt)) {
          return true
        }
      }
      return false
    };
    LineIntersector.prototype.getIntersectionAlongSegment = function getIntersectionAlongSegment (segmentIndex, intIndex) {
      this.computeIntLineIndex();
      return this._intPt[this._intLineIndex[segmentIndex][intIndex]]
    };
    LineIntersector.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    LineIntersector.prototype.getClass = function getClass () {
      return LineIntersector
    };
    LineIntersector.computeEdgeDistance = function computeEdgeDistance (p, p0, p1) {
      var dx = Math.abs(p1.x - p0.x);
      var dy = Math.abs(p1.y - p0.y);
      var dist = -1.0;
      if (p.equals(p0)) {
        dist = 0.0;
      } else if (p.equals(p1)) {
        if (dx > dy) { dist = dx; } else { dist = dy; }
      } else {
        var pdx = Math.abs(p.x - p0.x);
        var pdy = Math.abs(p.y - p0.y);
        if (dx > dy) { dist = pdx; } else { dist = pdy; }
        if (dist === 0.0 && !p.equals(p0)) {
          dist = Math.max(pdx, pdy);
        }
      }
      Assert.isTrue(!(dist === 0.0 && !p.equals(p0)), 'Bad distance calculation');
      return dist
    };
    LineIntersector.nonRobustComputeEdgeDistance = function nonRobustComputeEdgeDistance (p, p1, p2) {
      var dx = p.x - p1.x;
      var dy = p.y - p1.y;
      var dist = Math.sqrt(dx * dx + dy * dy);
      Assert.isTrue(!(dist === 0.0 && !p.equals(p1)), 'Invalid distance calculation');
      return dist
    };
    staticAccessors$10.DONT_INTERSECT.get = function () { return 0 };
    staticAccessors$10.DO_INTERSECT.get = function () { return 1 };
    staticAccessors$10.COLLINEAR.get = function () { return 2 };
    staticAccessors$10.NO_INTERSECTION.get = function () { return 0 };
    staticAccessors$10.POINT_INTERSECTION.get = function () { return 1 };
    staticAccessors$10.COLLINEAR_INTERSECTION.get = function () { return 2 };

    Object.defineProperties( LineIntersector, staticAccessors$10 );

    var RobustLineIntersector = (function (LineIntersector$$1) {
      function RobustLineIntersector () {
        LineIntersector$$1.apply(this, arguments);
      }

      if ( LineIntersector$$1 ) RobustLineIntersector.__proto__ = LineIntersector$$1;
      RobustLineIntersector.prototype = Object.create( LineIntersector$$1 && LineIntersector$$1.prototype );
      RobustLineIntersector.prototype.constructor = RobustLineIntersector;

      RobustLineIntersector.prototype.isInSegmentEnvelopes = function isInSegmentEnvelopes (intPt) {
        var env0 = new Envelope(this._inputLines[0][0], this._inputLines[0][1]);
        var env1 = new Envelope(this._inputLines[1][0], this._inputLines[1][1]);
        return env0.contains(intPt) && env1.contains(intPt)
      };
      RobustLineIntersector.prototype.computeIntersection = function computeIntersection () {
        if (arguments.length === 3) {
          var p = arguments[0];
          var p1 = arguments[1];
          var p2 = arguments[2];
          this._isProper = false;
          if (Envelope.intersects(p1, p2, p)) {
            if (CGAlgorithms.orientationIndex(p1, p2, p) === 0 && CGAlgorithms.orientationIndex(p2, p1, p) === 0) {
              this._isProper = true;
              if (p.equals(p1) || p.equals(p2)) {
                this._isProper = false;
              }
              this._result = LineIntersector$$1.POINT_INTERSECTION;
              return null
            }
          }
          this._result = LineIntersector$$1.NO_INTERSECTION;
        } else { return LineIntersector$$1.prototype.computeIntersection.apply(this, arguments) }
      };
      RobustLineIntersector.prototype.normalizeToMinimum = function normalizeToMinimum (n1, n2, n3, n4, normPt) {
        normPt.x = this.smallestInAbsValue(n1.x, n2.x, n3.x, n4.x);
        normPt.y = this.smallestInAbsValue(n1.y, n2.y, n3.y, n4.y);
        n1.x -= normPt.x;
        n1.y -= normPt.y;
        n2.x -= normPt.x;
        n2.y -= normPt.y;
        n3.x -= normPt.x;
        n3.y -= normPt.y;
        n4.x -= normPt.x;
        n4.y -= normPt.y;
      };
      RobustLineIntersector.prototype.safeHCoordinateIntersection = function safeHCoordinateIntersection (p1, p2, q1, q2) {
        var intPt = null;
        try {
          intPt = HCoordinate.intersection(p1, p2, q1, q2);
        } catch (e) {
          if (e instanceof NotRepresentableException) {
            intPt = RobustLineIntersector.nearestEndpoint(p1, p2, q1, q2);
          } else { throw e }
        } finally {}
        return intPt
      };
      RobustLineIntersector.prototype.intersection = function intersection (p1, p2, q1, q2) {
        var intPt = this.intersectionWithNormalization(p1, p2, q1, q2);
        if (!this.isInSegmentEnvelopes(intPt)) {
          intPt = new Coordinate(RobustLineIntersector.nearestEndpoint(p1, p2, q1, q2));
        }
        if (this._precisionModel !== null) {
          this._precisionModel.makePrecise(intPt);
        }
        return intPt
      };
      RobustLineIntersector.prototype.smallestInAbsValue = function smallestInAbsValue (x1, x2, x3, x4) {
        var x = x1;
        var xabs = Math.abs(x);
        if (Math.abs(x2) < xabs) {
          x = x2;
          xabs = Math.abs(x2);
        }
        if (Math.abs(x3) < xabs) {
          x = x3;
          xabs = Math.abs(x3);
        }
        if (Math.abs(x4) < xabs) {
          x = x4;
        }
        return x
      };
      RobustLineIntersector.prototype.checkDD = function checkDD (p1, p2, q1, q2, intPt) {
        var intPtDD = CGAlgorithmsDD.intersection(p1, p2, q1, q2);
        var isIn = this.isInSegmentEnvelopes(intPtDD);
        System.out.println('DD in env = ' + isIn + '  --------------------- ' + intPtDD);
        if (intPt.distance(intPtDD) > 0.0001) {
          System.out.println('Distance = ' + intPt.distance(intPtDD));
        }
      };
      RobustLineIntersector.prototype.intersectionWithNormalization = function intersectionWithNormalization (p1, p2, q1, q2) {
        var n1 = new Coordinate(p1);
        var n2 = new Coordinate(p2);
        var n3 = new Coordinate(q1);
        var n4 = new Coordinate(q2);
        var normPt = new Coordinate();
        this.normalizeToEnvCentre(n1, n2, n3, n4, normPt);
        var intPt = this.safeHCoordinateIntersection(n1, n2, n3, n4);
        intPt.x += normPt.x;
        intPt.y += normPt.y;
        return intPt
      };
      RobustLineIntersector.prototype.computeCollinearIntersection = function computeCollinearIntersection (p1, p2, q1, q2) {
        var p1q1p2 = Envelope.intersects(p1, p2, q1);
        var p1q2p2 = Envelope.intersects(p1, p2, q2);
        var q1p1q2 = Envelope.intersects(q1, q2, p1);
        var q1p2q2 = Envelope.intersects(q1, q2, p2);
        if (p1q1p2 && p1q2p2) {
          this._intPt[0] = q1;
          this._intPt[1] = q2;
          return LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        if (q1p1q2 && q1p2q2) {
          this._intPt[0] = p1;
          this._intPt[1] = p2;
          return LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        if (p1q1p2 && q1p1q2) {
          this._intPt[0] = q1;
          this._intPt[1] = p1;
          return q1.equals(p1) && !p1q2p2 && !q1p2q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        if (p1q1p2 && q1p2q2) {
          this._intPt[0] = q1;
          this._intPt[1] = p2;
          return q1.equals(p2) && !p1q2p2 && !q1p1q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        if (p1q2p2 && q1p1q2) {
          this._intPt[0] = q2;
          this._intPt[1] = p1;
          return q2.equals(p1) && !p1q1p2 && !q1p2q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        if (p1q2p2 && q1p2q2) {
          this._intPt[0] = q2;
          this._intPt[1] = p2;
          return q2.equals(p2) && !p1q1p2 && !q1p1q2 ? LineIntersector$$1.POINT_INTERSECTION : LineIntersector$$1.COLLINEAR_INTERSECTION
        }
        return LineIntersector$$1.NO_INTERSECTION
      };
      RobustLineIntersector.prototype.normalizeToEnvCentre = function normalizeToEnvCentre (n00, n01, n10, n11, normPt) {
        var minX0 = n00.x < n01.x ? n00.x : n01.x;
        var minY0 = n00.y < n01.y ? n00.y : n01.y;
        var maxX0 = n00.x > n01.x ? n00.x : n01.x;
        var maxY0 = n00.y > n01.y ? n00.y : n01.y;
        var minX1 = n10.x < n11.x ? n10.x : n11.x;
        var minY1 = n10.y < n11.y ? n10.y : n11.y;
        var maxX1 = n10.x > n11.x ? n10.x : n11.x;
        var maxY1 = n10.y > n11.y ? n10.y : n11.y;
        var intMinX = minX0 > minX1 ? minX0 : minX1;
        var intMaxX = maxX0 < maxX1 ? maxX0 : maxX1;
        var intMinY = minY0 > minY1 ? minY0 : minY1;
        var intMaxY = maxY0 < maxY1 ? maxY0 : maxY1;
        var intMidX = (intMinX + intMaxX) / 2.0;
        var intMidY = (intMinY + intMaxY) / 2.0;
        normPt.x = intMidX;
        normPt.y = intMidY;
        n00.x -= normPt.x;
        n00.y -= normPt.y;
        n01.x -= normPt.x;
        n01.y -= normPt.y;
        n10.x -= normPt.x;
        n10.y -= normPt.y;
        n11.x -= normPt.x;
        n11.y -= normPt.y;
      };
      RobustLineIntersector.prototype.computeIntersect = function computeIntersect (p1, p2, q1, q2) {
        this._isProper = false;
        if (!Envelope.intersects(p1, p2, q1, q2)) { return LineIntersector$$1.NO_INTERSECTION }
        var Pq1 = CGAlgorithms.orientationIndex(p1, p2, q1);
        var Pq2 = CGAlgorithms.orientationIndex(p1, p2, q2);
        if ((Pq1 > 0 && Pq2 > 0) || (Pq1 < 0 && Pq2 < 0)) {
          return LineIntersector$$1.NO_INTERSECTION
        }
        var Qp1 = CGAlgorithms.orientationIndex(q1, q2, p1);
        var Qp2 = CGAlgorithms.orientationIndex(q1, q2, p2);
        if ((Qp1 > 0 && Qp2 > 0) || (Qp1 < 0 && Qp2 < 0)) {
          return LineIntersector$$1.NO_INTERSECTION
        }
        var collinear = Pq1 === 0 && Pq2 === 0 && Qp1 === 0 && Qp2 === 0;
        if (collinear) {
          return this.computeCollinearIntersection(p1, p2, q1, q2)
        }
        if (Pq1 === 0 || Pq2 === 0 || Qp1 === 0 || Qp2 === 0) {
          this._isProper = false;
          if (p1.equals2D(q1) || p1.equals2D(q2)) {
            this._intPt[0] = p1;
          } else if (p2.equals2D(q1) || p2.equals2D(q2)) {
            this._intPt[0] = p2;
          } else if (Pq1 === 0) {
            this._intPt[0] = new Coordinate(q1);
          } else if (Pq2 === 0) {
            this._intPt[0] = new Coordinate(q2);
          } else if (Qp1 === 0) {
            this._intPt[0] = new Coordinate(p1);
          } else if (Qp2 === 0) {
            this._intPt[0] = new Coordinate(p2);
          }
        } else {
          this._isProper = true;
          this._intPt[0] = this.intersection(p1, p2, q1, q2);
        }
        return LineIntersector$$1.POINT_INTERSECTION
      };
      RobustLineIntersector.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      RobustLineIntersector.prototype.getClass = function getClass () {
        return RobustLineIntersector
      };
      RobustLineIntersector.nearestEndpoint = function nearestEndpoint (p1, p2, q1, q2) {
        var nearestPt = p1;
        var minDist = CGAlgorithms.distancePointLine(p1, q1, q2);
        var dist = CGAlgorithms.distancePointLine(p2, q1, q2);
        if (dist < minDist) {
          minDist = dist;
          nearestPt = p2;
        }
        dist = CGAlgorithms.distancePointLine(q1, p1, p2);
        if (dist < minDist) {
          minDist = dist;
          nearestPt = q1;
        }
        dist = CGAlgorithms.distancePointLine(q2, p1, p2);
        if (dist < minDist) {
          minDist = dist;
          nearestPt = q2;
        }
        return nearestPt
      };

      return RobustLineIntersector;
    }(LineIntersector));

    var RobustDeterminant = function RobustDeterminant () {};

    RobustDeterminant.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    RobustDeterminant.prototype.getClass = function getClass () {
      return RobustDeterminant
    };
    RobustDeterminant.orientationIndex = function orientationIndex (p1, p2, q) {
      var dx1 = p2.x - p1.x;
      var dy1 = p2.y - p1.y;
      var dx2 = q.x - p2.x;
      var dy2 = q.y - p2.y;
      return RobustDeterminant.signOfDet2x2(dx1, dy1, dx2, dy2)
    };
    RobustDeterminant.signOfDet2x2 = function signOfDet2x2 (x1, y1, x2, y2) {
      var sign = null;
      var swap = null;
      var k = null;
      sign = 1;
      if (x1 === 0.0 || y2 === 0.0) {
        if (y1 === 0.0 || x2 === 0.0) {
          return 0
        } else if (y1 > 0) {
          if (x2 > 0) {
            return -sign
          } else {
            return sign
          }
        } else {
          if (x2 > 0) {
            return sign
          } else {
            return -sign
          }
        }
      }
      if (y1 === 0.0 || x2 === 0.0) {
        if (y2 > 0) {
          if (x1 > 0) {
            return sign
          } else {
            return -sign
          }
        } else {
          if (x1 > 0) {
            return -sign
          } else {
            return sign
          }
        }
      }
      if (y1 > 0.0) {
        if (y2 > 0.0) {
          if (y1 <= y2) ; else {
            sign = -sign;
            swap = x1;
            x1 = x2;
            x2 = swap;
            swap = y1;
            y1 = y2;
            y2 = swap;
          }
        } else {
          if (y1 <= -y2) {
            sign = -sign;
            x2 = -x2;
            y2 = -y2;
          } else {
            swap = x1;
            x1 = -x2;
            x2 = swap;
            swap = y1;
            y1 = -y2;
            y2 = swap;
          }
        }
      } else {
        if (y2 > 0.0) {
          if (-y1 <= y2) {
            sign = -sign;
            x1 = -x1;
            y1 = -y1;
          } else {
            swap = -x1;
            x1 = x2;
            x2 = swap;
            swap = -y1;
            y1 = y2;
            y2 = swap;
          }
        } else {
          if (y1 >= y2) {
            x1 = -x1;
            y1 = -y1;
            x2 = -x2;
            y2 = -y2;
          } else {
            sign = -sign;
            swap = -x1;
            x1 = -x2;
            x2 = swap;
            swap = -y1;
            y1 = -y2;
            y2 = swap;
          }
        }
      }
      if (x1 > 0.0) {
        if (x2 > 0.0) {
          if (x1 <= x2) ; else {
            return sign
          }
        } else {
          return sign
        }
      } else {
        if (x2 > 0.0) {
          return -sign
        } else {
          if (x1 >= x2) {
            sign = -sign;
            x1 = -x1;
            x2 = -x2;
          } else {
            return -sign
          }
        }
      }
      while (true) {
        k = Math.floor(x2 / x1);
        x2 = x2 - k * x1;
        y2 = y2 - k * y1;
        if (y2 < 0.0) {
          return -sign
        }
        if (y2 > y1) {
          return sign
        }
        if (x1 > x2 + x2) {
          if (y1 < y2 + y2) {
            return sign
          }
        } else {
          if (y1 > y2 + y2) {
            return -sign
          } else {
            x2 = x1 - x2;
            y2 = y1 - y2;
            sign = -sign;
          }
        }
        if (y2 === 0.0) {
          if (x2 === 0.0) {
            return 0
          } else {
            return -sign
          }
        }
        if (x2 === 0.0) {
          return sign
        }
        k = Math.floor(x1 / x2);
        x1 = x1 - k * x2;
        y1 = y1 - k * y2;
        if (y1 < 0.0) {
          return sign
        }
        if (y1 > y2) {
          return -sign
        }
        if (x2 > x1 + x1) {
          if (y2 < y1 + y1) {
            return -sign
          }
        } else {
          if (y2 > y1 + y1) {
            return sign
          } else {
            x1 = x2 - x1;
            y1 = y2 - y1;
            sign = -sign;
          }
        }
        if (y1 === 0.0) {
          if (x1 === 0.0) {
            return 0
          } else {
            return sign
          }
        }
        if (x1 === 0.0) {
          return -sign
        }
      }
    };

    var RayCrossingCounter = function RayCrossingCounter () {
      this._p = null;
      this._crossingCount = 0;
      this._isPointOnSegment = false;
      var p = arguments[0];
      this._p = p;
    };
    RayCrossingCounter.prototype.countSegment = function countSegment (p1, p2) {
      if (p1.x < this._p.x && p2.x < this._p.x) { return null }
      if (this._p.x === p2.x && this._p.y === p2.y) {
        this._isPointOnSegment = true;
        return null
      }
      if (p1.y === this._p.y && p2.y === this._p.y) {
        var minx = p1.x;
        var maxx = p2.x;
        if (minx > maxx) {
          minx = p2.x;
          maxx = p1.x;
        }
        if (this._p.x >= minx && this._p.x <= maxx) {
          this._isPointOnSegment = true;
        }
        return null
      }
      if ((p1.y > this._p.y && p2.y <= this._p.y) || (p2.y > this._p.y && p1.y <= this._p.y)) {
        var x1 = p1.x - this._p.x;
        var y1 = p1.y - this._p.y;
        var x2 = p2.x - this._p.x;
        var y2 = p2.y - this._p.y;
        var xIntSign = RobustDeterminant.signOfDet2x2(x1, y1, x2, y2);
        if (xIntSign === 0.0) {
          this._isPointOnSegment = true;
          return null
        }
        if (y2 < y1) { xIntSign = -xIntSign; }
        if (xIntSign > 0.0) {
          this._crossingCount++;
        }
      }
    };
    RayCrossingCounter.prototype.isPointInPolygon = function isPointInPolygon () {
      return this.getLocation() !== Location.EXTERIOR
    };
    RayCrossingCounter.prototype.getLocation = function getLocation () {
      if (this._isPointOnSegment) { return Location.BOUNDARY }
      if (this._crossingCount % 2 === 1) {
        return Location.INTERIOR
      }
      return Location.EXTERIOR
    };
    RayCrossingCounter.prototype.isOnSegment = function isOnSegment () {
      return this._isPointOnSegment
    };
    RayCrossingCounter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    RayCrossingCounter.prototype.getClass = function getClass () {
      return RayCrossingCounter
    };
    RayCrossingCounter.locatePointInRing = function locatePointInRing () {
      if (arguments[0] instanceof Coordinate && hasInterface(arguments[1], CoordinateSequence)) {
        var p = arguments[0];
        var ring = arguments[1];
        var counter = new RayCrossingCounter(p);
        var p1 = new Coordinate();
        var p2 = new Coordinate();
        for (var i = 1; i < ring.size(); i++) {
          ring.getCoordinate(i, p1);
          ring.getCoordinate(i - 1, p2);
          counter.countSegment(p1, p2);
          if (counter.isOnSegment()) { return counter.getLocation() }
        }
        return counter.getLocation()
      } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Array) {
        var p$1 = arguments[0];
        var ring$1 = arguments[1];
        var counter$1 = new RayCrossingCounter(p$1);
        for (var i$1 = 1; i$1 < ring$1.length; i$1++) {
          var p1$1 = ring$1[i$1];
          var p2$1 = ring$1[i$1 - 1];
          counter$1.countSegment(p1$1, p2$1);
          if (counter$1.isOnSegment()) { return counter$1.getLocation() }
        }
        return counter$1.getLocation()
      }
    };

    var CGAlgorithms = function CGAlgorithms () {};

    var staticAccessors$3 = { CLOCKWISE: { configurable: true },RIGHT: { configurable: true },COUNTERCLOCKWISE: { configurable: true },LEFT: { configurable: true },COLLINEAR: { configurable: true },STRAIGHT: { configurable: true } };

    CGAlgorithms.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CGAlgorithms.prototype.getClass = function getClass () {
      return CGAlgorithms
    };
    CGAlgorithms.orientationIndex = function orientationIndex (p1, p2, q) {
      return CGAlgorithmsDD.orientationIndex(p1, p2, q)
    };
    CGAlgorithms.signedArea = function signedArea () {
      if (arguments[0] instanceof Array) {
        var ring = arguments[0];
        if (ring.length < 3) { return 0.0 }
        var sum = 0.0;
        var x0 = ring[0].x;
        for (var i = 1; i < ring.length - 1; i++) {
          var x = ring[i].x - x0;
          var y1 = ring[i + 1].y;
          var y2 = ring[i - 1].y;
          sum += x * (y2 - y1);
        }
        return sum / 2.0
      } else if (hasInterface(arguments[0], CoordinateSequence)) {
        var ring$1 = arguments[0];
        var n = ring$1.size();
        if (n < 3) { return 0.0 }
        var p0 = new Coordinate();
        var p1 = new Coordinate();
        var p2 = new Coordinate();
        ring$1.getCoordinate(0, p1);
        ring$1.getCoordinate(1, p2);
        var x0$1 = p1.x;
        p2.x -= x0$1;
        var sum$1 = 0.0;
        for (var i$1 = 1; i$1 < n - 1; i$1++) {
          p0.y = p1.y;
          p1.x = p2.x;
          p1.y = p2.y;
          ring$1.getCoordinate(i$1 + 1, p2);
          p2.x -= x0$1;
          sum$1 += p1.x * (p0.y - p2.y);
        }
        return sum$1 / 2.0
      }
    };
    CGAlgorithms.distanceLineLine = function distanceLineLine (A, B, C, D) {
      if (A.equals(B)) { return CGAlgorithms.distancePointLine(A, C, D) }
      if (C.equals(D)) { return CGAlgorithms.distancePointLine(D, A, B) }
      var noIntersection = false;
      if (!Envelope.intersects(A, B, C, D)) {
        noIntersection = true;
      } else {
        var denom = (B.x - A.x) * (D.y - C.y) - (B.y - A.y) * (D.x - C.x);
        if (denom === 0) {
          noIntersection = true;
        } else {
          var rNumb = (A.y - C.y) * (D.x - C.x) - (A.x - C.x) * (D.y - C.y);
          var sNum = (A.y - C.y) * (B.x - A.x) - (A.x - C.x) * (B.y - A.y);
          var s = sNum / denom;
          var r = rNumb / denom;
          if (r < 0 || r > 1 || s < 0 || s > 1) {
            noIntersection = true;
          }
        }
      }
      if (noIntersection) {
        return MathUtil.min(CGAlgorithms.distancePointLine(A, C, D), CGAlgorithms.distancePointLine(B, C, D), CGAlgorithms.distancePointLine(C, A, B), CGAlgorithms.distancePointLine(D, A, B))
      }
      return 0.0
    };
    CGAlgorithms.isPointInRing = function isPointInRing (p, ring) {
      return CGAlgorithms.locatePointInRing(p, ring) !== Location.EXTERIOR
    };
    CGAlgorithms.computeLength = function computeLength (pts) {
      var n = pts.size();
      if (n <= 1) { return 0.0 }
      var len = 0.0;
      var p = new Coordinate();
      pts.getCoordinate(0, p);
      var x0 = p.x;
      var y0 = p.y;
      for (var i = 1; i < n; i++) {
        pts.getCoordinate(i, p);
        var x1 = p.x;
        var y1 = p.y;
        var dx = x1 - x0;
        var dy = y1 - y0;
        len += Math.sqrt(dx * dx + dy * dy);
        x0 = x1;
        y0 = y1;
      }
      return len
    };
    CGAlgorithms.isCCW = function isCCW (ring) {
      var nPts = ring.length - 1;
      if (nPts < 3) { throw new IllegalArgumentException('Ring has fewer than 4 points, so orientation cannot be determined') }
      var hiPt = ring[0];
      var hiIndex = 0;
      for (var i = 1; i <= nPts; i++) {
        var p = ring[i];
        if (p.y > hiPt.y) {
          hiPt = p;
          hiIndex = i;
        }
      }
      var iPrev = hiIndex;
      do {
        iPrev = iPrev - 1;
        if (iPrev < 0) { iPrev = nPts; }
      } while (ring[iPrev].equals2D(hiPt) && iPrev !== hiIndex)
      var iNext = hiIndex;
      do {
        iNext = (iNext + 1) % nPts;
      } while (ring[iNext].equals2D(hiPt) && iNext !== hiIndex)
      var prev = ring[iPrev];
      var next = ring[iNext];
      if (prev.equals2D(hiPt) || next.equals2D(hiPt) || prev.equals2D(next)) { return false }
      var disc = CGAlgorithms.computeOrientation(prev, hiPt, next);
      var isCCW = false;
      if (disc === 0) {
        isCCW = prev.x > next.x;
      } else {
        isCCW = disc > 0;
      }
      return isCCW
    };
    CGAlgorithms.locatePointInRing = function locatePointInRing (p, ring) {
      return RayCrossingCounter.locatePointInRing(p, ring)
    };
    CGAlgorithms.distancePointLinePerpendicular = function distancePointLinePerpendicular (p, A, B) {
      var len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y);
      var s = ((A.y - p.y) * (B.x - A.x) - (A.x - p.x) * (B.y - A.y)) / len2;
      return Math.abs(s) * Math.sqrt(len2)
    };
    CGAlgorithms.computeOrientation = function computeOrientation (p1, p2, q) {
      return CGAlgorithms.orientationIndex(p1, p2, q)
    };
    CGAlgorithms.distancePointLine = function distancePointLine () {
      if (arguments.length === 2) {
        var p = arguments[0];
        var line = arguments[1];
        if (line.length === 0) { throw new IllegalArgumentException('Line array must contain at least one vertex') }
        var minDistance = p.distance(line[0]);
        for (var i = 0; i < line.length - 1; i++) {
          var dist = CGAlgorithms.distancePointLine(p, line[i], line[i + 1]);
          if (dist < minDistance) {
            minDistance = dist;
          }
        }
        return minDistance
      } else if (arguments.length === 3) {
        var p$1 = arguments[0];
        var A = arguments[1];
        var B = arguments[2];
        if (A.x === B.x && A.y === B.y) { return p$1.distance(A) }
        var len2 = (B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y);
        var r = ((p$1.x - A.x) * (B.x - A.x) + (p$1.y - A.y) * (B.y - A.y)) / len2;
        if (r <= 0.0) { return p$1.distance(A) }
        if (r >= 1.0) { return p$1.distance(B) }
        var s = ((A.y - p$1.y) * (B.x - A.x) - (A.x - p$1.x) * (B.y - A.y)) / len2;
        return Math.abs(s) * Math.sqrt(len2)
      }
    };
    CGAlgorithms.isOnLine = function isOnLine (p, pt) {
      var lineIntersector = new RobustLineIntersector();
      for (var i = 1; i < pt.length; i++) {
        var p0 = pt[i - 1];
        var p1 = pt[i];
        lineIntersector.computeIntersection(p, p0, p1);
        if (lineIntersector.hasIntersection()) {
          return true
        }
      }
      return false
    };
    staticAccessors$3.CLOCKWISE.get = function () { return -1 };
    staticAccessors$3.RIGHT.get = function () { return CGAlgorithms.CLOCKWISE };
    staticAccessors$3.COUNTERCLOCKWISE.get = function () { return 1 };
    staticAccessors$3.LEFT.get = function () { return CGAlgorithms.COUNTERCLOCKWISE };
    staticAccessors$3.COLLINEAR.get = function () { return 0 };
    staticAccessors$3.STRAIGHT.get = function () { return CGAlgorithms.COLLINEAR };

    Object.defineProperties( CGAlgorithms, staticAccessors$3 );

    var GeometryComponentFilter = function GeometryComponentFilter () {};

    GeometryComponentFilter.prototype.filter = function filter (geom) {};
    GeometryComponentFilter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryComponentFilter.prototype.getClass = function getClass () {
      return GeometryComponentFilter
    };

    var Geometry = function Geometry () {
      var factory = arguments[0];

      this._envelope = null;
      this._factory = null;
      this._SRID = null;
      this._userData = null;
      this._factory = factory;
      this._SRID = factory.getSRID();
    };

    var staticAccessors$11 = { serialVersionUID: { configurable: true },SORTINDEX_POINT: { configurable: true },SORTINDEX_MULTIPOINT: { configurable: true },SORTINDEX_LINESTRING: { configurable: true },SORTINDEX_LINEARRING: { configurable: true },SORTINDEX_MULTILINESTRING: { configurable: true },SORTINDEX_POLYGON: { configurable: true },SORTINDEX_MULTIPOLYGON: { configurable: true },SORTINDEX_GEOMETRYCOLLECTION: { configurable: true },geometryChangedFilter: { configurable: true } };
    Geometry.prototype.isGeometryCollection = function isGeometryCollection () {
      return this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION
    };
    Geometry.prototype.getFactory = function getFactory () {
      return this._factory
    };
    Geometry.prototype.getGeometryN = function getGeometryN (n) {
      return this
    };
    Geometry.prototype.getArea = function getArea () {
      return 0.0
    };
    Geometry.prototype.isRectangle = function isRectangle () {
      return false
    };
    Geometry.prototype.equals = function equals () {
      if (arguments[0] instanceof Geometry) {
        var g$1 = arguments[0];
        if (g$1 === null) { return false }
        return this.equalsTopo(g$1)
      } else if (arguments[0] instanceof Object) {
        var o = arguments[0];
        if (!(o instanceof Geometry)) { return false }
        var g = o;
        return this.equalsExact(g)
      }
    };
    Geometry.prototype.equalsExact = function equalsExact (other) {
      return this === other || this.equalsExact(other, 0)
    };
    Geometry.prototype.geometryChanged = function geometryChanged () {
      this.apply(Geometry.geometryChangedFilter);
    };
    Geometry.prototype.geometryChangedAction = function geometryChangedAction () {
      this._envelope = null;
    };
    Geometry.prototype.equalsNorm = function equalsNorm (g) {
      if (g === null) { return false }
      return this.norm().equalsExact(g.norm())
    };
    Geometry.prototype.getLength = function getLength () {
      return 0.0
    };
    Geometry.prototype.getNumGeometries = function getNumGeometries () {
      return 1
    };
    Geometry.prototype.compareTo = function compareTo () {
      if (arguments.length === 1) {
        var o = arguments[0];
        var other = o;
        if (this.getSortIndex() !== other.getSortIndex()) {
          return this.getSortIndex() - other.getSortIndex()
        }
        if (this.isEmpty() && other.isEmpty()) {
          return 0
        }
        if (this.isEmpty()) {
          return -1
        }
        if (other.isEmpty()) {
          return 1
        }
        return this.compareToSameClass(o)
      } else if (arguments.length === 2) {
        var other$1 = arguments[0];
        var comp = arguments[1];
        if (this.getSortIndex() !== other$1.getSortIndex()) {
          return this.getSortIndex() - other$1.getSortIndex()
        }
        if (this.isEmpty() && other$1.isEmpty()) {
          return 0
        }
        if (this.isEmpty()) {
          return -1
        }
        if (other$1.isEmpty()) {
          return 1
        }
        return this.compareToSameClass(other$1, comp)
      }
    };
    Geometry.prototype.getUserData = function getUserData () {
      return this._userData
    };
    Geometry.prototype.getSRID = function getSRID () {
      return this._SRID
    };
    Geometry.prototype.getEnvelope = function getEnvelope () {
      return this.getFactory().toGeometry(this.getEnvelopeInternal())
    };
    Geometry.prototype.checkNotGeometryCollection = function checkNotGeometryCollection (g) {
      if (g.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION) {
        throw new IllegalArgumentException('This method does not support GeometryCollection arguments')
      }
    };
    Geometry.prototype.equal = function equal (a, b, tolerance) {
      if (tolerance === 0) {
        return a.equals(b)
      }
      return a.distance(b) <= tolerance
    };
    Geometry.prototype.norm = function norm () {
      var copy = this.copy();
      copy.normalize();
      return copy
    };
    Geometry.prototype.getPrecisionModel = function getPrecisionModel () {
      return this._factory.getPrecisionModel()
    };
    Geometry.prototype.getEnvelopeInternal = function getEnvelopeInternal () {
      if (this._envelope === null) {
        this._envelope = this.computeEnvelopeInternal();
      }
      return new Envelope(this._envelope)
    };
    Geometry.prototype.setSRID = function setSRID (SRID) {
      this._SRID = SRID;
    };
    Geometry.prototype.setUserData = function setUserData (userData) {
      this._userData = userData;
    };
    Geometry.prototype.compare = function compare (a, b) {
      var i = a.iterator();
      var j = b.iterator();
      while (i.hasNext() && j.hasNext()) {
        var aElement = i.next();
        var bElement = j.next();
        var comparison = aElement.compareTo(bElement);
        if (comparison !== 0) {
          return comparison
        }
      }
      if (i.hasNext()) {
        return 1
      }
      if (j.hasNext()) {
        return -1
      }
      return 0
    };
    Geometry.prototype.hashCode = function hashCode () {
      return this.getEnvelopeInternal().hashCode()
    };
    Geometry.prototype.isGeometryCollectionOrDerived = function isGeometryCollectionOrDerived () {
      if (this.getSortIndex() === Geometry.SORTINDEX_GEOMETRYCOLLECTION || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOINT || this.getSortIndex() === Geometry.SORTINDEX_MULTILINESTRING || this.getSortIndex() === Geometry.SORTINDEX_MULTIPOLYGON) {
        return true
      }
      return false
    };
    Geometry.prototype.interfaces_ = function interfaces_ () {
      return [Clonable, Comparable, Serializable]
    };
    Geometry.prototype.getClass = function getClass () {
      return Geometry
    };
    Geometry.hasNonEmptyElements = function hasNonEmptyElements (geometries) {
      for (var i = 0; i < geometries.length; i++) {
        if (!geometries[i].isEmpty()) {
          return true
        }
      }
      return false
    };
    Geometry.hasNullElements = function hasNullElements (array) {
      for (var i = 0; i < array.length; i++) {
        if (array[i] === null) {
          return true
        }
      }
      return false
    };
    staticAccessors$11.serialVersionUID.get = function () { return 8763622679187376702 };
    staticAccessors$11.SORTINDEX_POINT.get = function () { return 0 };
    staticAccessors$11.SORTINDEX_MULTIPOINT.get = function () { return 1 };
    staticAccessors$11.SORTINDEX_LINESTRING.get = function () { return 2 };
    staticAccessors$11.SORTINDEX_LINEARRING.get = function () { return 3 };
    staticAccessors$11.SORTINDEX_MULTILINESTRING.get = function () { return 4 };
    staticAccessors$11.SORTINDEX_POLYGON.get = function () { return 5 };
    staticAccessors$11.SORTINDEX_MULTIPOLYGON.get = function () { return 6 };
    staticAccessors$11.SORTINDEX_GEOMETRYCOLLECTION.get = function () { return 7 };
    staticAccessors$11.geometryChangedFilter.get = function () { return geometryChangedFilter };

    Object.defineProperties( Geometry, staticAccessors$11 );

    var geometryChangedFilter = function geometryChangedFilter () {};

    geometryChangedFilter.interfaces_ = function interfaces_ () {
      return [GeometryComponentFilter]
    };
    geometryChangedFilter.filter = function filter (geom) {
      geom.geometryChangedAction();
    };

    var CoordinateFilter = function CoordinateFilter () {};

    CoordinateFilter.prototype.filter = function filter (coord) {};
    CoordinateFilter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CoordinateFilter.prototype.getClass = function getClass () {
      return CoordinateFilter
    };

    var BoundaryNodeRule = function BoundaryNodeRule () {};

    var staticAccessors$12 = { Mod2BoundaryNodeRule: { configurable: true },EndPointBoundaryNodeRule: { configurable: true },MultiValentEndPointBoundaryNodeRule: { configurable: true },MonoValentEndPointBoundaryNodeRule: { configurable: true },MOD2_BOUNDARY_RULE: { configurable: true },ENDPOINT_BOUNDARY_RULE: { configurable: true },MULTIVALENT_ENDPOINT_BOUNDARY_RULE: { configurable: true },MONOVALENT_ENDPOINT_BOUNDARY_RULE: { configurable: true },OGC_SFS_BOUNDARY_RULE: { configurable: true } };

    BoundaryNodeRule.prototype.isInBoundary = function isInBoundary (boundaryCount) {};
    BoundaryNodeRule.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BoundaryNodeRule.prototype.getClass = function getClass () {
      return BoundaryNodeRule
    };
    staticAccessors$12.Mod2BoundaryNodeRule.get = function () { return Mod2BoundaryNodeRule };
    staticAccessors$12.EndPointBoundaryNodeRule.get = function () { return EndPointBoundaryNodeRule };
    staticAccessors$12.MultiValentEndPointBoundaryNodeRule.get = function () { return MultiValentEndPointBoundaryNodeRule };
    staticAccessors$12.MonoValentEndPointBoundaryNodeRule.get = function () { return MonoValentEndPointBoundaryNodeRule };
    staticAccessors$12.MOD2_BOUNDARY_RULE.get = function () { return new Mod2BoundaryNodeRule() };
    staticAccessors$12.ENDPOINT_BOUNDARY_RULE.get = function () { return new EndPointBoundaryNodeRule() };
    staticAccessors$12.MULTIVALENT_ENDPOINT_BOUNDARY_RULE.get = function () { return new MultiValentEndPointBoundaryNodeRule() };
    staticAccessors$12.MONOVALENT_ENDPOINT_BOUNDARY_RULE.get = function () { return new MonoValentEndPointBoundaryNodeRule() };
    staticAccessors$12.OGC_SFS_BOUNDARY_RULE.get = function () { return BoundaryNodeRule.MOD2_BOUNDARY_RULE };

    Object.defineProperties( BoundaryNodeRule, staticAccessors$12 );

    var Mod2BoundaryNodeRule = function Mod2BoundaryNodeRule () {};

    Mod2BoundaryNodeRule.prototype.isInBoundary = function isInBoundary (boundaryCount) {
      return boundaryCount % 2 === 1
    };
    Mod2BoundaryNodeRule.prototype.interfaces_ = function interfaces_ () {
      return [BoundaryNodeRule]
    };
    Mod2BoundaryNodeRule.prototype.getClass = function getClass () {
      return Mod2BoundaryNodeRule
    };

    var EndPointBoundaryNodeRule = function EndPointBoundaryNodeRule () {};

    EndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary (boundaryCount) {
      return boundaryCount > 0
    };
    EndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_ () {
      return [BoundaryNodeRule]
    };
    EndPointBoundaryNodeRule.prototype.getClass = function getClass () {
      return EndPointBoundaryNodeRule
    };

    var MultiValentEndPointBoundaryNodeRule = function MultiValentEndPointBoundaryNodeRule () {};

    MultiValentEndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary (boundaryCount) {
      return boundaryCount > 1
    };
    MultiValentEndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_ () {
      return [BoundaryNodeRule]
    };
    MultiValentEndPointBoundaryNodeRule.prototype.getClass = function getClass () {
      return MultiValentEndPointBoundaryNodeRule
    };

    var MonoValentEndPointBoundaryNodeRule = function MonoValentEndPointBoundaryNodeRule () {};

    MonoValentEndPointBoundaryNodeRule.prototype.isInBoundary = function isInBoundary (boundaryCount) {
      return boundaryCount === 1
    };
    MonoValentEndPointBoundaryNodeRule.prototype.interfaces_ = function interfaces_ () {
      return [BoundaryNodeRule]
    };
    MonoValentEndPointBoundaryNodeRule.prototype.getClass = function getClass () {
      return MonoValentEndPointBoundaryNodeRule
    };

    // import Iterator from './Iterator'

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Collection.html
     *
     * @constructor
     * @private
     */
    var Collection = function Collection () {};

    Collection.prototype.add = function add () {};

    /**
     * Appends all of the elements in the specified collection to the end of this
     * list, in the order that they are returned by the specified collection's
     * iterator (optional operation).
     * @param {javascript.util.Collection} c
     * @return {boolean}
     */
    Collection.prototype.addAll = function addAll () {};

    /**
     * Returns true if this collection contains no elements.
     * @return {boolean}
     */
    Collection.prototype.isEmpty = function isEmpty () {};

    /**
     * Returns an iterator over the elements in this collection.
     * @return {javascript.util.Iterator}
     */
    Collection.prototype.iterator = function iterator () {};

    /**
     * Returns an iterator over the elements in this collection.
     * @return {number}
     */
    Collection.prototype.size = function size () {};

    /**
     * Returns an array containing all of the elements in this collection.
     * @return {Array}
     */
    Collection.prototype.toArray = function toArray () {};

    /**
     * Removes a single instance of the specified element from this collection if it
     * is present. (optional)
     * @param {Object} e
     * @return {boolean}
     */
    Collection.prototype.remove = function remove () {};

    /**
     * @param {string=} message Optional message
     * @extends {Error}
     * @constructor
     * @private
     */
    function IndexOutOfBoundsException (message) {
      this.message = message || '';
    }
    IndexOutOfBoundsException.prototype = new Error();

    /**
     * @type {string}
     */
    IndexOutOfBoundsException.prototype.name = 'IndexOutOfBoundsException';

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Iterator.html
     * @constructor
     * @private
     */
    var Iterator = function Iterator () {};

    Iterator.prototype.hasNext = function hasNext () {};

    /**
     * Returns the next element in the iteration.
     * @return {Object}
     */
    Iterator.prototype.next = function next () {};

    /**
     * Removes from the underlying collection the last element returned by the
     * iterator (optional operation).
     */
    Iterator.prototype.remove = function remove () {};

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/List.html
     *
     * @extends {javascript.util.Collection}
     * @constructor
     * @private
     */
    var List = (function (Collection$$1) {
      function List () {
        Collection$$1.apply(this, arguments);
      }

      if ( Collection$$1 ) List.__proto__ = Collection$$1;
      List.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
      List.prototype.constructor = List;

      List.prototype.get = function get () { };

      /**
       * Replaces the element at the specified position in this list with the
       * specified element (optional operation).
       * @param {number} index
       * @param {Object} e
       * @return {Object}
       */
      List.prototype.set = function set () { };

      /**
       * Returns true if this collection contains no elements.
       * @return {boolean}
       */
      List.prototype.isEmpty = function isEmpty () { };

      return List;
    }(Collection));

    /**
     * @param {string=} message Optional message
     * @extends {Error}
     * @constructor
     * @private
     */
    function NoSuchElementException (message) {
      this.message = message || '';
    }
    NoSuchElementException.prototype = new Error();

    /**
     * @type {string}
     */
    NoSuchElementException.prototype.name = 'NoSuchElementException';

    // import OperationNotSupported from './OperationNotSupported'

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/ArrayList.html
     *
     * @extends List
     * @private
     */
    var ArrayList = (function (List$$1) {
      function ArrayList () {
        List$$1.call(this);
        this.array_ = [];

        if (arguments[0] instanceof Collection) {
          this.addAll(arguments[0]);
        }
      }

      if ( List$$1 ) ArrayList.__proto__ = List$$1;
      ArrayList.prototype = Object.create( List$$1 && List$$1.prototype );
      ArrayList.prototype.constructor = ArrayList;

      ArrayList.prototype.ensureCapacity = function ensureCapacity () {};
      ArrayList.prototype.interfaces_ = function interfaces_ () { return [List$$1, Collection] };

      /**
       * @override
       */
      ArrayList.prototype.add = function add (e) {
        if (arguments.length === 1) {
          this.array_.push(e);
        } else {
          this.array_.splice(arguments[0], arguments[1]);
        }
        return true
      };

      ArrayList.prototype.clear = function clear () {
        this.array_ = [];
      };

      /**
       * @override
       */
      ArrayList.prototype.addAll = function addAll (c) {
        var this$1 = this;

        for (var i = c.iterator(); i.hasNext();) {
          this$1.add(i.next());
        }
        return true
      };

      /**
       * @override
       */
      ArrayList.prototype.set = function set (index, element) {
        var oldElement = this.array_[index];
        this.array_[index] = element;
        return oldElement
      };

      /**
       * @override
       */
      ArrayList.prototype.iterator = function iterator () {
        return new Iterator_(this)
      };

      /**
       * @override
       */
      ArrayList.prototype.get = function get (index) {
        if (index < 0 || index >= this.size()) {
          throw new IndexOutOfBoundsException()
        }

        return this.array_[index]
      };

      /**
       * @override
       */
      ArrayList.prototype.isEmpty = function isEmpty () {
        return this.array_.length === 0
      };

      /**
       * @override
       */
      ArrayList.prototype.size = function size () {
        return this.array_.length
      };

      /**
       * @override
       */
      ArrayList.prototype.toArray = function toArray () {
        var this$1 = this;

        var array = [];

        for (var i = 0, len = this.array_.length; i < len; i++) {
          array.push(this$1.array_[i]);
        }

        return array
      };

      /**
       * @override
       */
      ArrayList.prototype.remove = function remove (o) {
        var this$1 = this;

        var found = false;

        for (var i = 0, len = this.array_.length; i < len; i++) {
          if (this$1.array_[i] === o) {
            this$1.array_.splice(i, 1);
            found = true;
            break
          }
        }

        return found
      };

      return ArrayList;
    }(List));

    /**
     * @extends {Iterator}
     * @param {ArrayList} arrayList
     * @constructor
     * @private
     */
    var Iterator_ = (function (Iterator$$1) {
      function Iterator_ (arrayList) {
        Iterator$$1.call(this);
        /**
         * @type {ArrayList}
         * @private
        */
        this.arrayList_ = arrayList;
        /**
         * @type {number}
         * @private
        */
        this.position_ = 0;
      }

      if ( Iterator$$1 ) Iterator_.__proto__ = Iterator$$1;
      Iterator_.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
      Iterator_.prototype.constructor = Iterator_;

      /**
       * @override
       */
      Iterator_.prototype.next = function next () {
        if (this.position_ === this.arrayList_.size()) {
          throw new NoSuchElementException()
        }
        return this.arrayList_.get(this.position_++)
      };

      /**
       * @override
       */
      Iterator_.prototype.hasNext = function hasNext () {
        if (this.position_ < this.arrayList_.size()) {
          return true
        } else {
          return false
        }
      };

      /**
       * TODO: should be in ListIterator
       * @override
       */
      Iterator_.prototype.set = function set (element) {
        return this.arrayList_.set(this.position_ - 1, element)
      };

      /**
       * @override
       */
      Iterator_.prototype.remove = function remove () {
        this.arrayList_.remove(this.arrayList_.get(this.position_));
      };

      return Iterator_;
    }(Iterator));

    var CoordinateList = (function (ArrayList$$1) {
      function CoordinateList () {
        ArrayList$$1.call(this);
        if (arguments.length === 0) ; else if (arguments.length === 1) {
          var coord = arguments[0];
          this.ensureCapacity(coord.length);
          this.add(coord, true);
        } else if (arguments.length === 2) {
          var coord$1 = arguments[0];
          var allowRepeated = arguments[1];
          this.ensureCapacity(coord$1.length);
          this.add(coord$1, allowRepeated);
        }
      }

      if ( ArrayList$$1 ) CoordinateList.__proto__ = ArrayList$$1;
      CoordinateList.prototype = Object.create( ArrayList$$1 && ArrayList$$1.prototype );
      CoordinateList.prototype.constructor = CoordinateList;

      var staticAccessors = { coordArrayType: { configurable: true } };
      staticAccessors.coordArrayType.get = function () { return new Array(0).fill(null) };
      CoordinateList.prototype.getCoordinate = function getCoordinate (i) {
        return this.get(i)
      };
      CoordinateList.prototype.addAll = function addAll () {
        var this$1 = this;

        if (arguments.length === 2) {
          var coll = arguments[0];
          var allowRepeated = arguments[1];
          var isChanged = false;
          for (var i = coll.iterator(); i.hasNext();) {
            this$1.add(i.next(), allowRepeated);
            isChanged = true;
          }
          return isChanged
        } else { return ArrayList$$1.prototype.addAll.apply(this, arguments) }
      };
      CoordinateList.prototype.clone = function clone () {
        var this$1 = this;

        var clone = ArrayList$$1.prototype.clone.call(this);
        for (var i = 0; i < this.size(); i++) {
          clone.add(i, this$1.get(i).copy());
        }
        return clone
      };
      CoordinateList.prototype.toCoordinateArray = function toCoordinateArray () {
        return this.toArray(CoordinateList.coordArrayType)
      };
      CoordinateList.prototype.add = function add () {
        var this$1 = this;

        if (arguments.length === 1) {
          var coord = arguments[0];
          ArrayList$$1.prototype.add.call(this, coord);
        } else if (arguments.length === 2) {
          if (arguments[0] instanceof Array && typeof arguments[1] === 'boolean') {
            var coord$1 = arguments[0];
            var allowRepeated = arguments[1];
            this.add(coord$1, allowRepeated, true);
            return true
          } else if (arguments[0] instanceof Coordinate && typeof arguments[1] === 'boolean') {
            var coord$2 = arguments[0];
            var allowRepeated$1 = arguments[1];
            if (!allowRepeated$1) {
              if (this.size() >= 1) {
                var last = this.get(this.size() - 1);
                if (last.equals2D(coord$2)) { return null }
              }
            }
            ArrayList$$1.prototype.add.call(this, coord$2);
          } else if (arguments[0] instanceof Object && typeof arguments[1] === 'boolean') {
            var obj = arguments[0];
            var allowRepeated$2 = arguments[1];
            this.add(obj, allowRepeated$2);
            return true
          }
        } else if (arguments.length === 3) {
          if (typeof arguments[2] === 'boolean' && (arguments[0] instanceof Array && typeof arguments[1] === 'boolean')) {
            var coord$3 = arguments[0];
            var allowRepeated$3 = arguments[1];
            var direction = arguments[2];
            if (direction) {
              for (var i$1 = 0; i$1 < coord$3.length; i$1++) {
                this$1.add(coord$3[i$1], allowRepeated$3);
              }
            } else {
              for (var i$2 = coord$3.length - 1; i$2 >= 0; i$2--) {
                this$1.add(coord$3[i$2], allowRepeated$3);
              }
            }
            return true
          } else if (typeof arguments[2] === 'boolean' && (Number.isInteger(arguments[0]) && arguments[1] instanceof Coordinate)) {
            var i$3 = arguments[0];
            var coord$4 = arguments[1];
            var allowRepeated$4 = arguments[2];
            if (!allowRepeated$4) {
              var size = this.size();
              if (size > 0) {
                if (i$3 > 0) {
                  var prev = this.get(i$3 - 1);
                  if (prev.equals2D(coord$4)) { return null }
                }
                if (i$3 < size) {
                  var next = this.get(i$3);
                  if (next.equals2D(coord$4)) { return null }
                }
              }
            }
            ArrayList$$1.prototype.add.call(this, i$3, coord$4);
          }
        } else if (arguments.length === 4) {
          var coord$5 = arguments[0];
          var allowRepeated$5 = arguments[1];
          var start = arguments[2];
          var end = arguments[3];
          var inc = 1;
          if (start > end) { inc = -1; }
          for (var i = start; i !== end; i += inc) {
            this$1.add(coord$5[i], allowRepeated$5);
          }
          return true
        }
      };
      CoordinateList.prototype.closeRing = function closeRing () {
        if (this.size() > 0) { this.add(new Coordinate(this.get(0)), false); }
      };
      CoordinateList.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      CoordinateList.prototype.getClass = function getClass () {
        return CoordinateList
      };

      Object.defineProperties( CoordinateList, staticAccessors );

      return CoordinateList;
    }(ArrayList));

    var CoordinateArrays = function CoordinateArrays () {};

    var staticAccessors$13 = { ForwardComparator: { configurable: true },BidirectionalComparator: { configurable: true },coordArrayType: { configurable: true } };

    staticAccessors$13.ForwardComparator.get = function () { return ForwardComparator };
    staticAccessors$13.BidirectionalComparator.get = function () { return BidirectionalComparator };
    staticAccessors$13.coordArrayType.get = function () { return new Array(0).fill(null) };

    CoordinateArrays.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CoordinateArrays.prototype.getClass = function getClass () {
      return CoordinateArrays
    };
    CoordinateArrays.isRing = function isRing (pts) {
      if (pts.length < 4) { return false }
      if (!pts[0].equals2D(pts[pts.length - 1])) { return false }
      return true
    };
    CoordinateArrays.ptNotInList = function ptNotInList (testPts, pts) {
      for (var i = 0; i < testPts.length; i++) {
        var testPt = testPts[i];
        if (CoordinateArrays.indexOf(testPt, pts) < 0) { return testPt }
      }
      return null
    };
    CoordinateArrays.scroll = function scroll (coordinates, firstCoordinate) {
      var i = CoordinateArrays.indexOf(firstCoordinate, coordinates);
      if (i < 0) { return null }
      var newCoordinates = new Array(coordinates.length).fill(null);
      System.arraycopy(coordinates, i, newCoordinates, 0, coordinates.length - i);
      System.arraycopy(coordinates, 0, newCoordinates, coordinates.length - i, i);
      System.arraycopy(newCoordinates, 0, coordinates, 0, coordinates.length);
    };
    CoordinateArrays.equals = function equals () {
      if (arguments.length === 2) {
        var coord1 = arguments[0];
        var coord2 = arguments[1];
        if (coord1 === coord2) { return true }
        if (coord1 === null || coord2 === null) { return false }
        if (coord1.length !== coord2.length) { return false }
        for (var i = 0; i < coord1.length; i++) {
          if (!coord1[i].equals(coord2[i])) { return false }
        }
        return true
      } else if (arguments.length === 3) {
        var coord1$1 = arguments[0];
        var coord2$1 = arguments[1];
        var coordinateComparator = arguments[2];
        if (coord1$1 === coord2$1) { return true }
        if (coord1$1 === null || coord2$1 === null) { return false }
        if (coord1$1.length !== coord2$1.length) { return false }
        for (var i$1 = 0; i$1 < coord1$1.length; i$1++) {
          if (coordinateComparator.compare(coord1$1[i$1], coord2$1[i$1]) !== 0) { return false }
        }
        return true
      }
    };
    CoordinateArrays.intersection = function intersection (coordinates, env) {
      var coordList = new CoordinateList();
      for (var i = 0; i < coordinates.length; i++) {
        if (env.intersects(coordinates[i])) { coordList.add(coordinates[i], true); }
      }
      return coordList.toCoordinateArray()
    };
    CoordinateArrays.hasRepeatedPoints = function hasRepeatedPoints (coord) {
      for (var i = 1; i < coord.length; i++) {
        if (coord[i - 1].equals(coord[i])) {
          return true
        }
      }
      return false
    };
    CoordinateArrays.removeRepeatedPoints = function removeRepeatedPoints (coord) {
      if (!CoordinateArrays.hasRepeatedPoints(coord)) { return coord }
      var coordList = new CoordinateList(coord, false);
      return coordList.toCoordinateArray()
    };
    CoordinateArrays.reverse = function reverse (coord) {
      var last = coord.length - 1;
      var mid = Math.trunc(last / 2);
      for (var i = 0; i <= mid; i++) {
        var tmp = coord[i];
        coord[i] = coord[last - i];
        coord[last - i] = tmp;
      }
    };
    CoordinateArrays.removeNull = function removeNull (coord) {
      var nonNull = 0;
      for (var i = 0; i < coord.length; i++) {
        if (coord[i] !== null) { nonNull++; }
      }
      var newCoord = new Array(nonNull).fill(null);
      if (nonNull === 0) { return newCoord }
      var j = 0;
      for (var i$1 = 0; i$1 < coord.length; i$1++) {
        if (coord[i$1] !== null) { newCoord[j++] = coord[i$1]; }
      }
      return newCoord
    };
    CoordinateArrays.copyDeep = function copyDeep () {
      if (arguments.length === 1) {
        var coordinates = arguments[0];
        var copy = new Array(coordinates.length).fill(null);
        for (var i = 0; i < coordinates.length; i++) {
          copy[i] = new Coordinate(coordinates[i]);
        }
        return copy
      } else if (arguments.length === 5) {
        var src = arguments[0];
        var srcStart = arguments[1];
        var dest = arguments[2];
        var destStart = arguments[3];
        var length = arguments[4];
        for (var i$1 = 0; i$1 < length; i$1++) {
          dest[destStart + i$1] = new Coordinate(src[srcStart + i$1]);
        }
      }
    };
    CoordinateArrays.isEqualReversed = function isEqualReversed (pts1, pts2) {
      for (var i = 0; i < pts1.length; i++) {
        var p1 = pts1[i];
        var p2 = pts2[pts1.length - i - 1];
        if (p1.compareTo(p2) !== 0) { return false }
      }
      return true
    };
    CoordinateArrays.envelope = function envelope (coordinates) {
      var env = new Envelope();
      for (var i = 0; i < coordinates.length; i++) {
        env.expandToInclude(coordinates[i]);
      }
      return env
    };
    CoordinateArrays.toCoordinateArray = function toCoordinateArray (coordList) {
      return coordList.toArray(CoordinateArrays.coordArrayType)
    };
    CoordinateArrays.atLeastNCoordinatesOrNothing = function atLeastNCoordinatesOrNothing (n, c) {
      return c.length >= n ? c : []
    };
    CoordinateArrays.indexOf = function indexOf (coordinate, coordinates) {
      for (var i = 0; i < coordinates.length; i++) {
        if (coordinate.equals(coordinates[i])) {
          return i
        }
      }
      return -1
    };
    CoordinateArrays.increasingDirection = function increasingDirection (pts) {
      for (var i = 0; i < Math.trunc(pts.length / 2); i++) {
        var j = pts.length - 1 - i;
        var comp = pts[i].compareTo(pts[j]);
        if (comp !== 0) { return comp }
      }
      return 1
    };
    CoordinateArrays.compare = function compare (pts1, pts2) {
      var i = 0;
      while (i < pts1.length && i < pts2.length) {
        var compare = pts1[i].compareTo(pts2[i]);
        if (compare !== 0) { return compare }
        i++;
      }
      if (i < pts2.length) { return -1 }
      if (i < pts1.length) { return 1 }
      return 0
    };
    CoordinateArrays.minCoordinate = function minCoordinate (coordinates) {
      var minCoord = null;
      for (var i = 0; i < coordinates.length; i++) {
        if (minCoord === null || minCoord.compareTo(coordinates[i]) > 0) {
          minCoord = coordinates[i];
        }
      }
      return minCoord
    };
    CoordinateArrays.extract = function extract (pts, start, end) {
      start = MathUtil.clamp(start, 0, pts.length);
      end = MathUtil.clamp(end, -1, pts.length);
      var npts = end - start + 1;
      if (end < 0) { npts = 0; }
      if (start >= pts.length) { npts = 0; }
      if (end < start) { npts = 0; }
      var extractPts = new Array(npts).fill(null);
      if (npts === 0) { return extractPts }
      var iPts = 0;
      for (var i = start; i <= end; i++) {
        extractPts[iPts++] = pts[i];
      }
      return extractPts
    };

    Object.defineProperties( CoordinateArrays, staticAccessors$13 );

    var ForwardComparator = function ForwardComparator () {};

    ForwardComparator.prototype.compare = function compare (o1, o2) {
      var pts1 = o1;
      var pts2 = o2;
      return CoordinateArrays.compare(pts1, pts2)
    };
    ForwardComparator.prototype.interfaces_ = function interfaces_ () {
      return [Comparator]
    };
    ForwardComparator.prototype.getClass = function getClass () {
      return ForwardComparator
    };

    var BidirectionalComparator = function BidirectionalComparator () {};

    BidirectionalComparator.prototype.compare = function compare (o1, o2) {
      var pts1 = o1;
      var pts2 = o2;
      if (pts1.length < pts2.length) { return -1 }
      if (pts1.length > pts2.length) { return 1 }
      if (pts1.length === 0) { return 0 }
      var forwardComp = CoordinateArrays.compare(pts1, pts2);
      var isEqualRev = CoordinateArrays.isEqualReversed(pts1, pts2);
      if (isEqualRev) { return 0 }
      return forwardComp
    };
    BidirectionalComparator.prototype.OLDcompare = function OLDcompare (o1, o2) {
      var pts1 = o1;
      var pts2 = o2;
      if (pts1.length < pts2.length) { return -1 }
      if (pts1.length > pts2.length) { return 1 }
      if (pts1.length === 0) { return 0 }
      var dir1 = CoordinateArrays.increasingDirection(pts1);
      var dir2 = CoordinateArrays.increasingDirection(pts2);
      var i1 = dir1 > 0 ? 0 : pts1.length - 1;
      var i2 = dir2 > 0 ? 0 : pts1.length - 1;
      for (var i = 0; i < pts1.length; i++) {
        var comparePt = pts1[i1].compareTo(pts2[i2]);
        if (comparePt !== 0) { return comparePt }
        i1 += dir1;
        i2 += dir2;
      }
      return 0
    };
    BidirectionalComparator.prototype.interfaces_ = function interfaces_ () {
      return [Comparator]
    };
    BidirectionalComparator.prototype.getClass = function getClass () {
      return BidirectionalComparator
    };

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Map.html
     *
     * @constructor
     * @private
     */
    var Map$1 = function Map () {};

    Map$1.prototype.get = function get () {};
    /**
     * Associates the specified value with the specified key in this map (optional
     * operation).
     * @param {Object} key
     * @param {Object} value
     * @return {Object}
     */
    Map$1.prototype.put = function put () {};

    /**
     * Returns the number of key-value mappings in this map.
     * @return {number}
     */
    Map$1.prototype.size = function size () {};

    /**
     * Returns a Collection view of the values contained in this map.
     * @return {javascript.util.Collection}
     */
    Map$1.prototype.values = function values () {};

    /**
     * Returns a {@link Set} view of the mappings contained in this map.
     * The set is backed by the map, so changes to the map are
     * reflected in the set, and vice-versa.If the map is modified
     * while an iteration over the set is in progress (except through
     * the iterator's own <tt>remove</tt> operation, or through the
     * <tt>setValue</tt> operation on a map entry returned by the
     * iterator) the results of the iteration are undefined.The set
     * supports element removal, which removes the corresponding
     * mapping from the map, via the <tt>Iterator.remove</tt>,
     * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt> and
     * <tt>clear</tt> operations.It does not support the
     * <tt>add</tt> or <tt>addAll</tt> operations.
     *
     * @return {Set} a set view of the mappings contained in this map
     */
    Map$1.prototype.entrySet = function entrySet () {};

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/SortedMap.html
     *
     * @extends {Map}
     * @constructor
     * @private
     */
    var SortedMap = (function (Map) {
    	function SortedMap () {
    		Map.apply(this, arguments);
    	}if ( Map ) SortedMap.__proto__ = Map;
    	SortedMap.prototype = Object.create( Map && Map.prototype );
    	SortedMap.prototype.constructor = SortedMap;

    	

    	return SortedMap;
    }(Map$1));

    /**
     * @param {string=} message Optional message
     * @extends {Error}
     * @constructor
     * @private
     */
    function OperationNotSupported (message) {
      this.message = message || '';
    }
    OperationNotSupported.prototype = new Error();

    /**
     * @type {string}
     */
    OperationNotSupported.prototype.name = 'OperationNotSupported';

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Set.html
     *
     * @extends {Collection}
     * @constructor
     * @private
     */
    function Set() {}
    Set.prototype = new Collection();


    /**
     * Returns true if this set contains the specified element. More formally,
     * returns true if and only if this set contains an element e such that (o==null ?
     * e==null : o.equals(e)).
     * @param {Object} e
     * @return {boolean}
     */
    Set.prototype.contains = function() {};

    /**
     * @see http://docs.oracle.com/javase/6/docs/api/java/util/HashSet.html
     *
     * @extends {javascript.util.Set}
     * @constructor
     * @private
     */
    var HashSet = (function (Set$$1) {
      function HashSet () {
        Set$$1.call(this);
        this.array_ = [];

        if (arguments[0] instanceof Collection) {
          this.addAll(arguments[0]);
        }
      }

      if ( Set$$1 ) HashSet.__proto__ = Set$$1;
      HashSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
      HashSet.prototype.constructor = HashSet;

      /**
       * @override
       */
      HashSet.prototype.contains = function contains (o) {
        var this$1 = this;

        for (var i = 0, len = this.array_.length; i < len; i++) {
          var e = this$1.array_[i];
          if (e === o) {
            return true
          }
        }
        return false
      };

      /**
       * @override
       */
      HashSet.prototype.add = function add (o) {
        if (this.contains(o)) {
          return false
        }

        this.array_.push(o);

        return true
      };

      /**
       * @override
       */
      HashSet.prototype.addAll = function addAll (c) {
        var this$1 = this;

        for (var i = c.iterator(); i.hasNext();) {
          this$1.add(i.next());
        }
        return true
      };

      /**
       * @override
       */
      HashSet.prototype.remove = function remove (o) {
        // throw new javascript.util.OperationNotSupported()
        throw new Error()
      };

      /**
       * @override
       */
      HashSet.prototype.size = function size () {
        return this.array_.length
      };

      /**
       * @override
       */
      HashSet.prototype.isEmpty = function isEmpty () {
        return this.array_.length === 0
      };

      /**
       * @override
       */
      HashSet.prototype.toArray = function toArray () {
        var this$1 = this;

        var array = [];

        for (var i = 0, len = this.array_.length; i < len; i++) {
          array.push(this$1.array_[i]);
        }

        return array
      };

      /**
       * @override
       */
      HashSet.prototype.iterator = function iterator () {
        return new Iterator_$1(this)
      };

      return HashSet;
    }(Set));

    /**
       * @extends {Iterator}
       * @param {HashSet} hashSet
       * @constructor
       * @private
       */
    var Iterator_$1 = (function (Iterator$$1) {
      function Iterator_ (hashSet) {
        Iterator$$1.call(this);
        /**
         * @type {HashSet}
         * @private
         */
        this.hashSet_ = hashSet;
        /**
         * @type {number}
         * @private
         */
        this.position_ = 0;
      }

      if ( Iterator$$1 ) Iterator_.__proto__ = Iterator$$1;
      Iterator_.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
      Iterator_.prototype.constructor = Iterator_;

      /**
       * @override
       */
      Iterator_.prototype.next = function next () {
        if (this.position_ === this.hashSet_.size()) {
          throw new NoSuchElementException()
        }
        return this.hashSet_.array_[this.position_++]
      };

      /**
       * @override
       */
      Iterator_.prototype.hasNext = function hasNext () {
        if (this.position_ < this.hashSet_.size()) {
          return true
        } else {
          return false
        }
      };

      /**
       * @override
       */
      Iterator_.prototype.remove = function remove () {
        throw new OperationNotSupported()
      };

      return Iterator_;
    }(Iterator));

    var BLACK = 0;
    var RED = 1;
    function colorOf (p) { return (p === null ? BLACK : p.color) }
    function parentOf (p) { return (p === null ? null : p.parent) }
    function setColor (p, c) { if (p !== null) { p.color = c; } }
    function leftOf (p) { return (p === null ? null : p.left) }
    function rightOf (p) { return (p === null ? null : p.right) }

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/TreeMap.html
     *
     * @extends {SortedMap}
     * @constructor
     * @private
     */
    function TreeMap () {
      /**
       * @type {Object}
       * @private
       */
      this.root_ = null;
      /**
       * @type {number}
       * @private
      */
      this.size_ = 0;
    }
    TreeMap.prototype = new SortedMap();

    /**
     * @override
     */
    TreeMap.prototype.get = function (key) {
      var p = this.root_;
      while (p !== null) {
        var cmp = key['compareTo'](p.key);
        if (cmp < 0) { p = p.left; }
        else if (cmp > 0) { p = p.right; }
        else { return p.value }
      }
      return null
    };

    /**
     * @override
     */
    TreeMap.prototype.put = function (key, value) {
      if (this.root_ === null) {
        this.root_ = {
          key: key,
          value: value,
          left: null,
          right: null,
          parent: null,
          color: BLACK,
          getValue: function getValue () { return this.value },
          getKey: function getKey () { return this.key }
        };
        this.size_ = 1;
        return null
      }
      var t = this.root_;
      var parent;
      var cmp;
      do {
        parent = t;
        cmp = key['compareTo'](t.key);
        if (cmp < 0) {
          t = t.left;
        } else if (cmp > 0) {
          t = t.right;
        } else {
          var oldValue = t.value;
          t.value = value;
          return oldValue
        }
      } while (t !== null)
      var e = {
        key: key,
        left: null,
        right: null,
        value: value,
        parent: parent,
        color: BLACK,
        getValue: function getValue () { return this.value },
        getKey: function getKey () { return this.key }
      };
      if (cmp < 0) {
        parent.left = e;
      } else {
        parent.right = e;
      }
      this.fixAfterInsertion(e);
      this.size_++;
      return null
    };

    /**
     * @param {Object} x
     */
    TreeMap.prototype.fixAfterInsertion = function (x) {
      var this$1 = this;

      x.color = RED;
      while (x != null && x !== this.root_ && x.parent.color === RED) {
        if (parentOf(x) === leftOf(parentOf(parentOf(x)))) {
          var y = rightOf(parentOf(parentOf(x)));
          if (colorOf(y) === RED) {
            setColor(parentOf(x), BLACK);
            setColor(y, BLACK);
            setColor(parentOf(parentOf(x)), RED);
            x = parentOf(parentOf(x));
          } else {
            if (x === rightOf(parentOf(x))) {
              x = parentOf(x);
              this$1.rotateLeft(x);
            }
            setColor(parentOf(x), BLACK);
            setColor(parentOf(parentOf(x)), RED);
            this$1.rotateRight(parentOf(parentOf(x)));
          }
        } else {
          var y$1 = leftOf(parentOf(parentOf(x)));
          if (colorOf(y$1) === RED) {
            setColor(parentOf(x), BLACK);
            setColor(y$1, BLACK);
            setColor(parentOf(parentOf(x)), RED);
            x = parentOf(parentOf(x));
          } else {
            if (x === leftOf(parentOf(x))) {
              x = parentOf(x);
              this$1.rotateRight(x);
            }
            setColor(parentOf(x), BLACK);
            setColor(parentOf(parentOf(x)), RED);
            this$1.rotateLeft(parentOf(parentOf(x)));
          }
        }
      }
      this.root_.color = BLACK;
    };

    /**
     * @override
     */
    TreeMap.prototype.values = function () {
      var arrayList = new ArrayList();
      var p = this.getFirstEntry();
      if (p !== null) {
        arrayList.add(p.value);
        while ((p = TreeMap.successor(p)) !== null) {
          arrayList.add(p.value);
        }
      }
      return arrayList
    };

    /**
     * @override
     */
    TreeMap.prototype.entrySet = function () {
      var hashSet = new HashSet();
      var p = this.getFirstEntry();
      if (p !== null) {
        hashSet.add(p);
        while ((p = TreeMap.successor(p)) !== null) {
          hashSet.add(p);
        }
      }
      return hashSet
    };

    /**
     * @param {Object} p
     */
    TreeMap.prototype.rotateLeft = function (p) {
      if (p != null) {
        var r = p.right;
        p.right = r.left;
        if (r.left != null) { r.left.parent = p; }
        r.parent = p.parent;
        if (p.parent === null) { this.root_ = r; } else if (p.parent.left === p) { p.parent.left = r; } else { p.parent.right = r; }
        r.left = p;
        p.parent = r;
      }
    };

    /**
     * @param {Object} p
     */
    TreeMap.prototype.rotateRight = function (p) {
      if (p != null) {
        var l = p.left;
        p.left = l.right;
        if (l.right != null) { l.right.parent = p; }
        l.parent = p.parent;
        if (p.parent === null) { this.root_ = l; } else if (p.parent.right === p) { p.parent.right = l; } else { p.parent.left = l; }
        l.right = p;
        p.parent = l;
      }
    };

    /**
     * @return {Object}
     */
    TreeMap.prototype.getFirstEntry = function () {
      var p = this.root_;
      if (p != null) {
        while (p.left != null) {
          p = p.left;
        }
      }
      return p
    };

    /**
     * @param {Object} t
     * @return {Object}
     * @private
     */
    TreeMap.successor = function (t) {
      if (t === null) { return null } else if (t.right !== null) {
        var p = t.right;
        while (p.left !== null) {
          p = p.left;
        }
        return p
      } else {
        var p$1 = t.parent;
        var ch = t;
        while (p$1 !== null && ch === p$1.right) {
          ch = p$1;
          p$1 = p$1.parent;
        }
        return p$1
      }
    };

    /**
     * @override
     */
    TreeMap.prototype.size = function () {
      return this.size_
    };

    var Lineal = function Lineal () {};

    Lineal.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Lineal.prototype.getClass = function getClass () {
      return Lineal
    };

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/SortedSet.html
     *
     * @extends {Set}
     * @constructor
     * @private
     */
    function SortedSet () {}
    SortedSet.prototype = new Set();

    // import Iterator from './Iterator'
    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/TreeSet.html
     *
     * @extends {SortedSet}
     * @constructor
     * @private
     */
    function TreeSet () {
      /**
       * @type {Array}
       * @private
      */
      this.array_ = [];

      if (arguments[0] instanceof Collection) {
        this.addAll(arguments[0]);
      }
    }
    TreeSet.prototype = new SortedSet();

    /**
     * @override
     */
    TreeSet.prototype.contains = function (o) {
      var this$1 = this;

      for (var i = 0, len = this.array_.length; i < len; i++) {
        var e = this$1.array_[i];
        if (e['compareTo'](o) === 0) {
          return true
        }
      }
      return false
    };

    /**
     * @override
     */
    TreeSet.prototype.add = function (o) {
      var this$1 = this;

      if (this.contains(o)) {
        return false
      }

      for (var i = 0, len = this.array_.length; i < len; i++) {
        var e = this$1.array_[i];
        if (e['compareTo'](o) === 1) {
          this$1.array_.splice(i, 0, o);
          return true
        }
      }

      this.array_.push(o);

      return true
    };

    /**
     * @override
     */
    TreeSet.prototype.addAll = function (c) {
      var this$1 = this;

      for (var i = c.iterator(); i.hasNext();) {
        this$1.add(i.next());
      }
      return true
    };

    /**
     * @override
     */
    TreeSet.prototype.remove = function (e) {
      throw new OperationNotSupported()
    };

    /**
     * @override
     */
    TreeSet.prototype.size = function () {
      return this.array_.length
    };

    /**
     * @override
     */
    TreeSet.prototype.isEmpty = function () {
      return this.array_.length === 0
    };

    /**
     * @override
     */
    TreeSet.prototype.toArray = function () {
      var this$1 = this;

      var array = [];

      for (var i = 0, len = this.array_.length; i < len; i++) {
        array.push(this$1.array_[i]);
      }

      return array
    };

    /**
     * @override
     */
    TreeSet.prototype.iterator = function () {
      return new Iterator_$2(this)
    };

    /**
     * @extends {javascript.util.Iterator}
     * @param {javascript.util.TreeSet} treeSet
     * @constructor
     * @private
     */
    var Iterator_$2 = function (treeSet) {
      /**
       * @type {javascript.util.TreeSet}
       * @private
       */
      this.treeSet_ = treeSet;
      /**
       * @type {number}
       * @private
       */
      this.position_ = 0;
    };

    /**
     * @override
     */
    Iterator_$2.prototype.next = function () {
      if (this.position_ === this.treeSet_.size()) {
        throw new NoSuchElementException()
      }
      return this.treeSet_.array_[this.position_++]
    };

    /**
     * @override
     */
    Iterator_$2.prototype.hasNext = function () {
      if (this.position_ < this.treeSet_.size()) {
        return true
      } else {
        return false
      }
    };

    /**
     * @override
     */
    Iterator_$2.prototype.remove = function () {
      throw new OperationNotSupported()
    };

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Arrays.html
     *
     * @constructor
     * @private
     */
    var Arrays = function Arrays () {};

    Arrays.sort = function sort () {
      var a = arguments[0];
      var i;
      var t;
      var comparator;
      var compare;
      if (arguments.length === 1) {
        compare = function (a, b) {
          return a.compareTo(b)
        };
        a.sort(compare);
      } else if (arguments.length === 2) {
        comparator = arguments[1];
        compare = function (a, b) {
          return comparator['compare'](a, b)
        };
        a.sort(compare);
      } else if (arguments.length === 3) {
        t = a.slice(arguments[1], arguments[2]);
        t.sort();
        var r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
        a.splice(0, a.length);
        for (i = 0; i < r.length; i++) {
          a.push(r[i]);
        }
      } else if (arguments.length === 4) {
        t = a.slice(arguments[1], arguments[2]);
        comparator = arguments[3];
        compare = function (a, b) {
          return comparator['compare'](a, b)
        };
        t.sort(compare);
        r = a.slice(0, arguments[1]).concat(t, a.slice(arguments[2], a.length));
        a.splice(0, a.length);
        for (i = 0; i < r.length; i++) {
          a.push(r[i]);
        }
      }
    };
    /**
     * @param {Array} array
     * @return {ArrayList}
     */
    Arrays.asList = function asList (array) {
      var arrayList = new ArrayList();
      for (var i = 0, len = array.length; i < len; i++) {
        arrayList.add(array[i]);
      }
      return arrayList
    };

    var Dimension = function Dimension () {};

    var staticAccessors$14 = { P: { configurable: true },L: { configurable: true },A: { configurable: true },FALSE: { configurable: true },TRUE: { configurable: true },DONTCARE: { configurable: true },SYM_FALSE: { configurable: true },SYM_TRUE: { configurable: true },SYM_DONTCARE: { configurable: true },SYM_P: { configurable: true },SYM_L: { configurable: true },SYM_A: { configurable: true } };

    staticAccessors$14.P.get = function () { return 0 };
    staticAccessors$14.L.get = function () { return 1 };
    staticAccessors$14.A.get = function () { return 2 };
    staticAccessors$14.FALSE.get = function () { return -1 };
    staticAccessors$14.TRUE.get = function () { return -2 };
    staticAccessors$14.DONTCARE.get = function () { return -3 };
    staticAccessors$14.SYM_FALSE.get = function () { return 'F' };
    staticAccessors$14.SYM_TRUE.get = function () { return 'T' };
    staticAccessors$14.SYM_DONTCARE.get = function () { return '*' };
    staticAccessors$14.SYM_P.get = function () { return '0' };
    staticAccessors$14.SYM_L.get = function () { return '1' };
    staticAccessors$14.SYM_A.get = function () { return '2' };

    Dimension.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Dimension.prototype.getClass = function getClass () {
      return Dimension
    };
    Dimension.toDimensionSymbol = function toDimensionSymbol (dimensionValue) {
      switch (dimensionValue) {
        case Dimension.FALSE:
          return Dimension.SYM_FALSE
        case Dimension.TRUE:
          return Dimension.SYM_TRUE
        case Dimension.DONTCARE:
          return Dimension.SYM_DONTCARE
        case Dimension.P:
          return Dimension.SYM_P
        case Dimension.L:
          return Dimension.SYM_L
        case Dimension.A:
          return Dimension.SYM_A
        default:
      }
      throw new IllegalArgumentException('Unknown dimension value: ' + dimensionValue)
    };
    Dimension.toDimensionValue = function toDimensionValue (dimensionSymbol) {
      switch (Character.toUpperCase(dimensionSymbol)) {
        case Dimension.SYM_FALSE:
          return Dimension.FALSE
        case Dimension.SYM_TRUE:
          return Dimension.TRUE
        case Dimension.SYM_DONTCARE:
          return Dimension.DONTCARE
        case Dimension.SYM_P:
          return Dimension.P
        case Dimension.SYM_L:
          return Dimension.L
        case Dimension.SYM_A:
          return Dimension.A
        default:
      }
      throw new IllegalArgumentException('Unknown dimension symbol: ' + dimensionSymbol)
    };

    Object.defineProperties( Dimension, staticAccessors$14 );

    var GeometryFilter = function GeometryFilter () {};

    GeometryFilter.prototype.filter = function filter (geom) {};
    GeometryFilter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryFilter.prototype.getClass = function getClass () {
      return GeometryFilter
    };

    var CoordinateSequenceFilter = function CoordinateSequenceFilter () {};

    CoordinateSequenceFilter.prototype.filter = function filter (seq, i) {};
    CoordinateSequenceFilter.prototype.isDone = function isDone () {};
    CoordinateSequenceFilter.prototype.isGeometryChanged = function isGeometryChanged () {};
    CoordinateSequenceFilter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CoordinateSequenceFilter.prototype.getClass = function getClass () {
      return CoordinateSequenceFilter
    };

    var GeometryCollection = (function (Geometry$$1) {
      function GeometryCollection (geometries, factory) {
        Geometry$$1.call(this, factory);
        this._geometries = geometries || [];

        if (Geometry$$1.hasNullElements(this._geometries)) {
          throw new IllegalArgumentException('geometries must not contain null elements')
        }
      }

      if ( Geometry$$1 ) GeometryCollection.__proto__ = Geometry$$1;
      GeometryCollection.prototype = Object.create( Geometry$$1 && Geometry$$1.prototype );
      GeometryCollection.prototype.constructor = GeometryCollection;

      var staticAccessors = { serialVersionUID: { configurable: true } };
      GeometryCollection.prototype.computeEnvelopeInternal = function computeEnvelopeInternal () {
        var this$1 = this;

        var envelope = new Envelope();
        for (var i = 0; i < this._geometries.length; i++) {
          envelope.expandToInclude(this$1._geometries[i].getEnvelopeInternal());
        }
        return envelope
      };
      GeometryCollection.prototype.getGeometryN = function getGeometryN (n) {
        return this._geometries[n]
      };
      GeometryCollection.prototype.getSortIndex = function getSortIndex () {
        return Geometry$$1.SORTINDEX_GEOMETRYCOLLECTION
      };
      GeometryCollection.prototype.getCoordinates = function getCoordinates () {
        var this$1 = this;

        var coordinates = new Array(this.getNumPoints()).fill(null);
        var k = -1;
        for (var i = 0; i < this._geometries.length; i++) {
          var childCoordinates = this$1._geometries[i].getCoordinates();
          for (var j = 0; j < childCoordinates.length; j++) {
            k++;
            coordinates[k] = childCoordinates[j];
          }
        }
        return coordinates
      };
      GeometryCollection.prototype.getArea = function getArea () {
        var this$1 = this;

        var area = 0.0;
        for (var i = 0; i < this._geometries.length; i++) {
          area += this$1._geometries[i].getArea();
        }
        return area
      };
      GeometryCollection.prototype.equalsExact = function equalsExact () {
        var this$1 = this;

        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          var otherCollection = other;
          if (this._geometries.length !== otherCollection._geometries.length) {
            return false
          }
          for (var i = 0; i < this._geometries.length; i++) {
            if (!this$1._geometries[i].equalsExact(otherCollection._geometries[i], tolerance)) {
              return false
            }
          }
          return true
        } else { return Geometry$$1.prototype.equalsExact.apply(this, arguments) }
      };
      GeometryCollection.prototype.normalize = function normalize () {
        var this$1 = this;

        for (var i = 0; i < this._geometries.length; i++) {
          this$1._geometries[i].normalize();
        }
        Arrays.sort(this._geometries);
      };
      GeometryCollection.prototype.getCoordinate = function getCoordinate () {
        if (this.isEmpty()) { return null }
        return this._geometries[0].getCoordinate()
      };
      GeometryCollection.prototype.getBoundaryDimension = function getBoundaryDimension () {
        var this$1 = this;

        var dimension = Dimension.FALSE;
        for (var i = 0; i < this._geometries.length; i++) {
          dimension = Math.max(dimension, this$1._geometries[i].getBoundaryDimension());
        }
        return dimension
      };
      GeometryCollection.prototype.getDimension = function getDimension () {
        var this$1 = this;

        var dimension = Dimension.FALSE;
        for (var i = 0; i < this._geometries.length; i++) {
          dimension = Math.max(dimension, this$1._geometries[i].getDimension());
        }
        return dimension
      };
      GeometryCollection.prototype.getLength = function getLength () {
        var this$1 = this;

        var sum = 0.0;
        for (var i = 0; i < this._geometries.length; i++) {
          sum += this$1._geometries[i].getLength();
        }
        return sum
      };
      GeometryCollection.prototype.getNumPoints = function getNumPoints () {
        var this$1 = this;

        var numPoints = 0;
        for (var i = 0; i < this._geometries.length; i++) {
          numPoints += this$1._geometries[i].getNumPoints();
        }
        return numPoints
      };
      GeometryCollection.prototype.getNumGeometries = function getNumGeometries () {
        return this._geometries.length
      };
      GeometryCollection.prototype.reverse = function reverse () {
        var this$1 = this;

        var n = this._geometries.length;
        var revGeoms = new Array(n).fill(null);
        for (var i = 0; i < this._geometries.length; i++) {
          revGeoms[i] = this$1._geometries[i].reverse();
        }
        return this.getFactory().createGeometryCollection(revGeoms)
      };
      GeometryCollection.prototype.compareToSameClass = function compareToSameClass () {
        var this$1 = this;

        if (arguments.length === 1) {
          var o = arguments[0];
          var theseElements = new TreeSet(Arrays.asList(this._geometries));
          var otherElements = new TreeSet(Arrays.asList(o._geometries));
          return this.compare(theseElements, otherElements)
        } else if (arguments.length === 2) {
          var o$1 = arguments[0];
          var comp = arguments[1];
          var gc = o$1;
          var n1 = this.getNumGeometries();
          var n2 = gc.getNumGeometries();
          var i = 0;
          while (i < n1 && i < n2) {
            var thisGeom = this$1.getGeometryN(i);
            var otherGeom = gc.getGeometryN(i);
            var holeComp = thisGeom.compareToSameClass(otherGeom, comp);
            if (holeComp !== 0) { return holeComp }
            i++;
          }
          if (i < n1) { return 1 }
          if (i < n2) { return -1 }
          return 0
        }
      };
      GeometryCollection.prototype.apply = function apply () {
        var this$1 = this;

        if (hasInterface(arguments[0], CoordinateFilter)) {
          var filter = arguments[0];
          for (var i = 0; i < this._geometries.length; i++) {
            this$1._geometries[i].apply(filter);
          }
        } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
          var filter$1 = arguments[0];
          if (this._geometries.length === 0) { return null }
          for (var i$1 = 0; i$1 < this._geometries.length; i$1++) {
            this$1._geometries[i$1].apply(filter$1);
            if (filter$1.isDone()) {
              break
            }
          }
          if (filter$1.isGeometryChanged()) { this.geometryChanged(); }
        } else if (hasInterface(arguments[0], GeometryFilter)) {
          var filter$2 = arguments[0];
          filter$2.filter(this);
          for (var i$2 = 0; i$2 < this._geometries.length; i$2++) {
            this$1._geometries[i$2].apply(filter$2);
          }
        } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
          var filter$3 = arguments[0];
          filter$3.filter(this);
          for (var i$3 = 0; i$3 < this._geometries.length; i$3++) {
            this$1._geometries[i$3].apply(filter$3);
          }
        }
      };
      GeometryCollection.prototype.getBoundary = function getBoundary () {
        this.checkNotGeometryCollection(this);
        Assert.shouldNeverReachHere();
        return null
      };
      GeometryCollection.prototype.clone = function clone () {
        var this$1 = this;

        var gc = Geometry$$1.prototype.clone.call(this);
        gc._geometries = new Array(this._geometries.length).fill(null);
        for (var i = 0; i < this._geometries.length; i++) {
          gc._geometries[i] = this$1._geometries[i].clone();
        }
        return gc
      };
      GeometryCollection.prototype.getGeometryType = function getGeometryType () {
        return 'GeometryCollection'
      };
      GeometryCollection.prototype.copy = function copy () {
        var this$1 = this;

        var geometries = new Array(this._geometries.length).fill(null);
        for (var i = 0; i < geometries.length; i++) {
          geometries[i] = this$1._geometries[i].copy();
        }
        return new GeometryCollection(geometries, this._factory)
      };
      GeometryCollection.prototype.isEmpty = function isEmpty () {
        var this$1 = this;

        for (var i = 0; i < this._geometries.length; i++) {
          if (!this$1._geometries[i].isEmpty()) {
            return false
          }
        }
        return true
      };
      GeometryCollection.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      GeometryCollection.prototype.getClass = function getClass () {
        return GeometryCollection
      };
      staticAccessors.serialVersionUID.get = function () { return -5694727726395021467 };

      Object.defineProperties( GeometryCollection, staticAccessors );

      return GeometryCollection;
    }(Geometry));

    var MultiLineString = (function (GeometryCollection$$1) {
      function MultiLineString () {
        GeometryCollection$$1.apply(this, arguments);
      }

      if ( GeometryCollection$$1 ) MultiLineString.__proto__ = GeometryCollection$$1;
      MultiLineString.prototype = Object.create( GeometryCollection$$1 && GeometryCollection$$1.prototype );
      MultiLineString.prototype.constructor = MultiLineString;

      var staticAccessors = { serialVersionUID: { configurable: true } };

      MultiLineString.prototype.getSortIndex = function getSortIndex () {
        return Geometry.SORTINDEX_MULTILINESTRING
      };
      MultiLineString.prototype.equalsExact = function equalsExact () {
        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance)
        } else { return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments) }
      };
      MultiLineString.prototype.getBoundaryDimension = function getBoundaryDimension () {
        if (this.isClosed()) {
          return Dimension.FALSE
        }
        return 0
      };
      MultiLineString.prototype.isClosed = function isClosed () {
        var this$1 = this;

        if (this.isEmpty()) {
          return false
        }
        for (var i = 0; i < this._geometries.length; i++) {
          if (!this$1._geometries[i].isClosed()) {
            return false
          }
        }
        return true
      };
      MultiLineString.prototype.getDimension = function getDimension () {
        return 1
      };
      MultiLineString.prototype.reverse = function reverse () {
        var this$1 = this;

        var nLines = this._geometries.length;
        var revLines = new Array(nLines).fill(null);
        for (var i = 0; i < this._geometries.length; i++) {
          revLines[nLines - 1 - i] = this$1._geometries[i].reverse();
        }
        return this.getFactory().createMultiLineString(revLines)
      };
      MultiLineString.prototype.getBoundary = function getBoundary () {
        return new BoundaryOp(this).getBoundary()
      };
      MultiLineString.prototype.getGeometryType = function getGeometryType () {
        return 'MultiLineString'
      };
      MultiLineString.prototype.copy = function copy () {
        var this$1 = this;

        var lineStrings = new Array(this._geometries.length).fill(null);
        for (var i = 0; i < lineStrings.length; i++) {
          lineStrings[i] = this$1._geometries[i].copy();
        }
        return new MultiLineString(lineStrings, this._factory)
      };
      MultiLineString.prototype.interfaces_ = function interfaces_ () {
        return [Lineal]
      };
      MultiLineString.prototype.getClass = function getClass () {
        return MultiLineString
      };
      staticAccessors.serialVersionUID.get = function () { return 8166665132445433741 };

      Object.defineProperties( MultiLineString, staticAccessors );

      return MultiLineString;
    }(GeometryCollection));

    var BoundaryOp = function BoundaryOp () {
      this._geom = null;
      this._geomFact = null;
      this._bnRule = null;
      this._endpointMap = null;
      if (arguments.length === 1) {
        var geom = arguments[0];
        var bnRule = BoundaryNodeRule.MOD2_BOUNDARY_RULE;
        this._geom = geom;
        this._geomFact = geom.getFactory();
        this._bnRule = bnRule;
      } else if (arguments.length === 2) {
        var geom$1 = arguments[0];
        var bnRule$1 = arguments[1];
        this._geom = geom$1;
        this._geomFact = geom$1.getFactory();
        this._bnRule = bnRule$1;
      }
    };
    BoundaryOp.prototype.boundaryMultiLineString = function boundaryMultiLineString (mLine) {
      if (this._geom.isEmpty()) {
        return this.getEmptyMultiPoint()
      }
      var bdyPts = this.computeBoundaryCoordinates(mLine);
      if (bdyPts.length === 1) {
        return this._geomFact.createPoint(bdyPts[0])
      }
      return this._geomFact.createMultiPointFromCoords(bdyPts)
    };
    BoundaryOp.prototype.getBoundary = function getBoundary () {
      if (this._geom instanceof LineString$1) { return this.boundaryLineString(this._geom) }
      if (this._geom instanceof MultiLineString) { return this.boundaryMultiLineString(this._geom) }
      return this._geom.getBoundary()
    };
    BoundaryOp.prototype.boundaryLineString = function boundaryLineString (line) {
      if (this._geom.isEmpty()) {
        return this.getEmptyMultiPoint()
      }
      if (line.isClosed()) {
        var closedEndpointOnBoundary = this._bnRule.isInBoundary(2);
        if (closedEndpointOnBoundary) {
          return line.getStartPoint()
        } else {
          return this._geomFact.createMultiPoint()
        }
      }
      return this._geomFact.createMultiPoint([line.getStartPoint(), line.getEndPoint()])
    };
    BoundaryOp.prototype.getEmptyMultiPoint = function getEmptyMultiPoint () {
      return this._geomFact.createMultiPoint()
    };
    BoundaryOp.prototype.computeBoundaryCoordinates = function computeBoundaryCoordinates (mLine) {
        var this$1 = this;

      var bdyPts = new ArrayList();
      this._endpointMap = new TreeMap();
      for (var i = 0; i < mLine.getNumGeometries(); i++) {
        var line = mLine.getGeometryN(i);
        if (line.getNumPoints() === 0) { continue }
        this$1.addEndpoint(line.getCoordinateN(0));
        this$1.addEndpoint(line.getCoordinateN(line.getNumPoints() - 1));
      }
      for (var it = this._endpointMap.entrySet().iterator(); it.hasNext();) {
        var entry = it.next();
        var counter = entry.getValue();
        var valence = counter.count;
        if (this$1._bnRule.isInBoundary(valence)) {
          bdyPts.add(entry.getKey());
        }
      }
      return CoordinateArrays.toCoordinateArray(bdyPts)
    };
    BoundaryOp.prototype.addEndpoint = function addEndpoint (pt) {
      var counter = this._endpointMap.get(pt);
      if (counter === null) {
        counter = new Counter();
        this._endpointMap.put(pt, counter);
      }
      counter.count++;
    };
    BoundaryOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BoundaryOp.prototype.getClass = function getClass () {
      return BoundaryOp
    };
    BoundaryOp.getBoundary = function getBoundary () {
      if (arguments.length === 1) {
        var g = arguments[0];
        var bop = new BoundaryOp(g);
        return bop.getBoundary()
      } else if (arguments.length === 2) {
        var g$1 = arguments[0];
        var bnRule = arguments[1];
        var bop$1 = new BoundaryOp(g$1, bnRule);
        return bop$1.getBoundary()
      }
    };

    var Counter = function Counter () {
      this.count = null;
    };
    Counter.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Counter.prototype.getClass = function getClass () {
      return Counter
    };

    // boundary

    function PrintStream () {}

    function StringReader () {}

    var DecimalFormat = function DecimalFormat () {};

    function ByteArrayOutputStream () {}

    function IOException () {}

    function LineNumberReader () {}

    var StringUtil = function StringUtil () {};

    var staticAccessors$15 = { NEWLINE: { configurable: true },SIMPLE_ORDINATE_FORMAT: { configurable: true } };

    StringUtil.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    StringUtil.prototype.getClass = function getClass () {
      return StringUtil
    };
    StringUtil.chars = function chars (c, n) {
      var ch = new Array(n).fill(null);
      for (var i = 0; i < n; i++) {
        ch[i] = c;
      }
      return String(ch)
    };
    StringUtil.getStackTrace = function getStackTrace () {
      if (arguments.length === 1) {
        var t = arguments[0];
        var os = new ByteArrayOutputStream();
        var ps = new PrintStream(os);
        t.printStackTrace(ps);
        return os.toString()
      } else if (arguments.length === 2) {
        var t$1 = arguments[0];
        var depth = arguments[1];
        var stackTrace = '';
        var stringReader = new StringReader(StringUtil.getStackTrace(t$1));
        var lineNumberReader = new LineNumberReader(stringReader);
        for (var i = 0; i < depth; i++) {
          try {
            stackTrace += lineNumberReader.readLine() + StringUtil.NEWLINE;
          } catch (e) {
            if (e instanceof IOException) {
              Assert.shouldNeverReachHere();
            } else { throw e }
          } finally {}
        }
        return stackTrace
      }
    };
    StringUtil.split = function split (s, separator) {
      var separatorlen = separator.length;
      var tokenList = new ArrayList();
      var tmpString = '' + s;
      var pos = tmpString.indexOf(separator);
      while (pos >= 0) {
        var token = tmpString.substring(0, pos);
        tokenList.add(token);
        tmpString = tmpString.substring(pos + separatorlen);
        pos = tmpString.indexOf(separator);
      }
      if (tmpString.length > 0) { tokenList.add(tmpString); }
      var res = new Array(tokenList.size()).fill(null);
      for (var i = 0; i < res.length; i++) {
        res[i] = tokenList.get(i);
      }
      return res
    };
    StringUtil.toString = function toString () {
      if (arguments.length === 1) {
        var d = arguments[0];
        return StringUtil.SIMPLE_ORDINATE_FORMAT.format(d)
      }
    };
    StringUtil.spaces = function spaces (n) {
      return StringUtil.chars(' ', n)
    };
    staticAccessors$15.NEWLINE.get = function () { return System.getProperty('line.separator') };
    staticAccessors$15.SIMPLE_ORDINATE_FORMAT.get = function () { return new DecimalFormat('0.#') };

    Object.defineProperties( StringUtil, staticAccessors$15 );

    var CoordinateSequences = function CoordinateSequences () {};

    CoordinateSequences.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CoordinateSequences.prototype.getClass = function getClass () {
      return CoordinateSequences
    };
    CoordinateSequences.copyCoord = function copyCoord (src, srcPos, dest, destPos) {
      var minDim = Math.min(src.getDimension(), dest.getDimension());
      for (var dim = 0; dim < minDim; dim++) {
        dest.setOrdinate(destPos, dim, src.getOrdinate(srcPos, dim));
      }
    };
    CoordinateSequences.isRing = function isRing (seq) {
      var n = seq.size();
      if (n === 0) { return true }
      if (n <= 3) { return false }
      return seq.getOrdinate(0, CoordinateSequence.X) === seq.getOrdinate(n - 1, CoordinateSequence.X) && seq.getOrdinate(0, CoordinateSequence.Y) === seq.getOrdinate(n - 1, CoordinateSequence.Y)
    };
    CoordinateSequences.isEqual = function isEqual (cs1, cs2) {
      var cs1Size = cs1.size();
      var cs2Size = cs2.size();
      if (cs1Size !== cs2Size) { return false }
      var dim = Math.min(cs1.getDimension(), cs2.getDimension());
      for (var i = 0; i < cs1Size; i++) {
        for (var d = 0; d < dim; d++) {
          var v1 = cs1.getOrdinate(i, d);
          var v2 = cs2.getOrdinate(i, d);
          if (cs1.getOrdinate(i, d) === cs2.getOrdinate(i, d)) { continue }
          if (Double.isNaN(v1) && Double.isNaN(v2)) { continue }
          return false
        }
      }
      return true
    };
    CoordinateSequences.extend = function extend (fact, seq, size) {
      var newseq = fact.create(size, seq.getDimension());
      var n = seq.size();
      CoordinateSequences.copy(seq, 0, newseq, 0, n);
      if (n > 0) {
        for (var i = n; i < size; i++) { CoordinateSequences.copy(seq, n - 1, newseq, i, 1); }
      }
      return newseq
    };
    CoordinateSequences.reverse = function reverse (seq) {
      var last = seq.size() - 1;
      var mid = Math.trunc(last / 2);
      for (var i = 0; i <= mid; i++) {
        CoordinateSequences.swap(seq, i, last - i);
      }
    };
    CoordinateSequences.swap = function swap (seq, i, j) {
      if (i === j) { return null }
      for (var dim = 0; dim < seq.getDimension(); dim++) {
        var tmp = seq.getOrdinate(i, dim);
        seq.setOrdinate(i, dim, seq.getOrdinate(j, dim));
        seq.setOrdinate(j, dim, tmp);
      }
    };
    CoordinateSequences.copy = function copy (src, srcPos, dest, destPos, length) {
      for (var i = 0; i < length; i++) {
        CoordinateSequences.copyCoord(src, srcPos + i, dest, destPos + i);
      }
    };
    CoordinateSequences.toString = function toString () {
      if (arguments.length === 1) {
        var cs = arguments[0];
        var size = cs.size();
        if (size === 0) { return '()' }
        var dim = cs.getDimension();
        var buf = new StringBuffer();
        buf.append('(');
        for (var i = 0; i < size; i++) {
          if (i > 0) { buf.append(' '); }
          for (var d = 0; d < dim; d++) {
            if (d > 0) { buf.append(','); }
            buf.append(StringUtil.toString(cs.getOrdinate(i, d)));
          }
        }
        buf.append(')');
        return buf.toString()
      }
    };
    CoordinateSequences.ensureValidRing = function ensureValidRing (fact, seq) {
      var n = seq.size();
      if (n === 0) { return seq }
      if (n <= 3) { return CoordinateSequences.createClosedRing(fact, seq, 4) }
      var isClosed = seq.getOrdinate(0, CoordinateSequence.X) === seq.getOrdinate(n - 1, CoordinateSequence.X) && seq.getOrdinate(0, CoordinateSequence.Y) === seq.getOrdinate(n - 1, CoordinateSequence.Y);
      if (isClosed) { return seq }
      return CoordinateSequences.createClosedRing(fact, seq, n + 1)
    };
    CoordinateSequences.createClosedRing = function createClosedRing (fact, seq, size) {
      var newseq = fact.create(size, seq.getDimension());
      var n = seq.size();
      CoordinateSequences.copy(seq, 0, newseq, 0, n);
      for (var i = n; i < size; i++) { CoordinateSequences.copy(seq, 0, newseq, i, 1); }
      return newseq
    };

    var LineString$1 = (function (Geometry$$1) {
      function LineString (points, factory) {
        Geometry$$1.call(this, factory);
        this._points = null;
        this.init(points);
      }

      if ( Geometry$$1 ) LineString.__proto__ = Geometry$$1;
      LineString.prototype = Object.create( Geometry$$1 && Geometry$$1.prototype );
      LineString.prototype.constructor = LineString;

      var staticAccessors = { serialVersionUID: { configurable: true } };
      LineString.prototype.computeEnvelopeInternal = function computeEnvelopeInternal () {
        if (this.isEmpty()) {
          return new Envelope()
        }
        return this._points.expandEnvelope(new Envelope())
      };
      LineString.prototype.isRing = function isRing () {
        return this.isClosed() && this.isSimple()
      };
      LineString.prototype.getSortIndex = function getSortIndex () {
        return Geometry$$1.SORTINDEX_LINESTRING
      };
      LineString.prototype.getCoordinates = function getCoordinates () {
        return this._points.toCoordinateArray()
      };
      LineString.prototype.equalsExact = function equalsExact () {
        var this$1 = this;

        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          var otherLineString = other;
          if (this._points.size() !== otherLineString._points.size()) {
            return false
          }
          for (var i = 0; i < this._points.size(); i++) {
            if (!this$1.equal(this$1._points.getCoordinate(i), otherLineString._points.getCoordinate(i), tolerance)) {
              return false
            }
          }
          return true
        } else { return Geometry$$1.prototype.equalsExact.apply(this, arguments) }
      };
      LineString.prototype.normalize = function normalize () {
        var this$1 = this;

        for (var i = 0; i < Math.trunc(this._points.size() / 2); i++) {
          var j = this$1._points.size() - 1 - i;
          if (!this$1._points.getCoordinate(i).equals(this$1._points.getCoordinate(j))) {
            if (this$1._points.getCoordinate(i).compareTo(this$1._points.getCoordinate(j)) > 0) {
              CoordinateSequences.reverse(this$1._points);
            }
            return null
          }
        }
      };
      LineString.prototype.getCoordinate = function getCoordinate () {
        if (this.isEmpty()) { return null }
        return this._points.getCoordinate(0)
      };
      LineString.prototype.getBoundaryDimension = function getBoundaryDimension () {
        if (this.isClosed()) {
          return Dimension.FALSE
        }
        return 0
      };
      LineString.prototype.isClosed = function isClosed () {
        if (this.isEmpty()) {
          return false
        }
        return this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints() - 1))
      };
      LineString.prototype.getEndPoint = function getEndPoint () {
        if (this.isEmpty()) {
          return null
        }
        return this.getPointN(this.getNumPoints() - 1)
      };
      LineString.prototype.getDimension = function getDimension () {
        return 1
      };
      LineString.prototype.getLength = function getLength () {
        return CGAlgorithms.computeLength(this._points)
      };
      LineString.prototype.getNumPoints = function getNumPoints () {
        return this._points.size()
      };
      LineString.prototype.reverse = function reverse () {
        var seq = this._points.copy();
        CoordinateSequences.reverse(seq);
        var revLine = this.getFactory().createLineString(seq);
        return revLine
      };
      LineString.prototype.compareToSameClass = function compareToSameClass () {
        var this$1 = this;

        if (arguments.length === 1) {
          var o = arguments[0];
          var line = o;
          var i = 0;
          var j = 0;
          while (i < this._points.size() && j < line._points.size()) {
            var comparison = this$1._points.getCoordinate(i).compareTo(line._points.getCoordinate(j));
            if (comparison !== 0) {
              return comparison
            }
            i++;
            j++;
          }
          if (i < this._points.size()) {
            return 1
          }
          if (j < line._points.size()) {
            return -1
          }
          return 0
        } else if (arguments.length === 2) {
          var o$1 = arguments[0];
          var comp = arguments[1];
          var line$1 = o$1;
          return comp.compare(this._points, line$1._points)
        }
      };
      LineString.prototype.apply = function apply () {
        var this$1 = this;

        if (hasInterface(arguments[0], CoordinateFilter)) {
          var filter = arguments[0];
          for (var i = 0; i < this._points.size(); i++) {
            filter.filter(this$1._points.getCoordinate(i));
          }
        } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
          var filter$1 = arguments[0];
          if (this._points.size() === 0) { return null }
          for (var i$1 = 0; i$1 < this._points.size(); i$1++) {
            filter$1.filter(this$1._points, i$1);
            if (filter$1.isDone()) { break }
          }
          if (filter$1.isGeometryChanged()) { this.geometryChanged(); }
        } else if (hasInterface(arguments[0], GeometryFilter)) {
          var filter$2 = arguments[0];
          filter$2.filter(this);
        } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
          var filter$3 = arguments[0];
          filter$3.filter(this);
        }
      };
      LineString.prototype.getBoundary = function getBoundary () {
        return new BoundaryOp(this).getBoundary()
      };
      LineString.prototype.isEquivalentClass = function isEquivalentClass (other) {
        return other instanceof LineString
      };
      LineString.prototype.clone = function clone () {
        var ls = Geometry$$1.prototype.clone.call(this);
        ls._points = this._points.clone();
        return ls
      };
      LineString.prototype.getCoordinateN = function getCoordinateN (n) {
        return this._points.getCoordinate(n)
      };
      LineString.prototype.getGeometryType = function getGeometryType () {
        return 'LineString'
      };
      LineString.prototype.copy = function copy () {
        return new LineString(this._points.copy(), this._factory)
      };
      LineString.prototype.getCoordinateSequence = function getCoordinateSequence () {
        return this._points
      };
      LineString.prototype.isEmpty = function isEmpty () {
        return this._points.size() === 0
      };
      LineString.prototype.init = function init (points) {
        if (points === null) {
          points = this.getFactory().getCoordinateSequenceFactory().create([]);
        }
        if (points.size() === 1) {
          throw new IllegalArgumentException('Invalid number of points in LineString (found ' + points.size() + ' - must be 0 or >= 2)')
        }
        this._points = points;
      };
      LineString.prototype.isCoordinate = function isCoordinate (pt) {
        var this$1 = this;

        for (var i = 0; i < this._points.size(); i++) {
          if (this$1._points.getCoordinate(i).equals(pt)) {
            return true
          }
        }
        return false
      };
      LineString.prototype.getStartPoint = function getStartPoint () {
        if (this.isEmpty()) {
          return null
        }
        return this.getPointN(0)
      };
      LineString.prototype.getPointN = function getPointN (n) {
        return this.getFactory().createPoint(this._points.getCoordinate(n))
      };
      LineString.prototype.interfaces_ = function interfaces_ () {
        return [Lineal]
      };
      LineString.prototype.getClass = function getClass () {
        return LineString
      };
      staticAccessors.serialVersionUID.get = function () { return 3110669828065365560 };

      Object.defineProperties( LineString, staticAccessors );

      return LineString;
    }(Geometry));

    var Puntal = function Puntal () {};

    Puntal.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Puntal.prototype.getClass = function getClass () {
      return Puntal
    };

    var Point = (function (Geometry$$1) {
      function Point (coordinates, factory) {
        Geometry$$1.call(this, factory);
        this._coordinates = coordinates || null;
        this.init(this._coordinates);
      }

      if ( Geometry$$1 ) Point.__proto__ = Geometry$$1;
      Point.prototype = Object.create( Geometry$$1 && Geometry$$1.prototype );
      Point.prototype.constructor = Point;

      var staticAccessors = { serialVersionUID: { configurable: true } };
      Point.prototype.computeEnvelopeInternal = function computeEnvelopeInternal () {
        if (this.isEmpty()) {
          return new Envelope()
        }
        var env = new Envelope();
        env.expandToInclude(this._coordinates.getX(0), this._coordinates.getY(0));
        return env
      };
      Point.prototype.getSortIndex = function getSortIndex () {
        return Geometry$$1.SORTINDEX_POINT
      };
      Point.prototype.getCoordinates = function getCoordinates () {
        return this.isEmpty() ? [] : [this.getCoordinate()]
      };
      Point.prototype.equalsExact = function equalsExact () {
        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          if (this.isEmpty() && other.isEmpty()) {
            return true
          }
          if (this.isEmpty() !== other.isEmpty()) {
            return false
          }
          return this.equal(other.getCoordinate(), this.getCoordinate(), tolerance)
        } else { return Geometry$$1.prototype.equalsExact.apply(this, arguments) }
      };
      Point.prototype.normalize = function normalize () {};
      Point.prototype.getCoordinate = function getCoordinate () {
        return this._coordinates.size() !== 0 ? this._coordinates.getCoordinate(0) : null
      };
      Point.prototype.getBoundaryDimension = function getBoundaryDimension () {
        return Dimension.FALSE
      };
      Point.prototype.getDimension = function getDimension () {
        return 0
      };
      Point.prototype.getNumPoints = function getNumPoints () {
        return this.isEmpty() ? 0 : 1
      };
      Point.prototype.reverse = function reverse () {
        return this.copy()
      };
      Point.prototype.getX = function getX () {
        if (this.getCoordinate() === null) {
          throw new Error('getX called on empty Point')
        }
        return this.getCoordinate().x
      };
      Point.prototype.compareToSameClass = function compareToSameClass () {
        if (arguments.length === 1) {
          var other = arguments[0];
          var point$1 = other;
          return this.getCoordinate().compareTo(point$1.getCoordinate())
        } else if (arguments.length === 2) {
          var other$1 = arguments[0];
          var comp = arguments[1];
          var point = other$1;
          return comp.compare(this._coordinates, point._coordinates)
        }
      };
      Point.prototype.apply = function apply () {
        if (hasInterface(arguments[0], CoordinateFilter)) {
          var filter = arguments[0];
          if (this.isEmpty()) {
            return null
          }
          filter.filter(this.getCoordinate());
        } else if (hasInterface(arguments[0], CoordinateSequenceFilter)) {
          var filter$1 = arguments[0];
          if (this.isEmpty()) { return null }
          filter$1.filter(this._coordinates, 0);
          if (filter$1.isGeometryChanged()) { this.geometryChanged(); }
        } else if (hasInterface(arguments[0], GeometryFilter)) {
          var filter$2 = arguments[0];
          filter$2.filter(this);
        } else if (hasInterface(arguments[0], GeometryComponentFilter)) {
          var filter$3 = arguments[0];
          filter$3.filter(this);
        }
      };
      Point.prototype.getBoundary = function getBoundary () {
        return this.getFactory().createGeometryCollection(null)
      };
      Point.prototype.clone = function clone () {
        var p = Geometry$$1.prototype.clone.call(this);
        p._coordinates = this._coordinates.clone();
        return p
      };
      Point.prototype.getGeometryType = function getGeometryType () {
        return 'Point'
      };
      Point.prototype.copy = function copy () {
        return new Point(this._coordinates.copy(), this._factory)
      };
      Point.prototype.getCoordinateSequence = function getCoordinateSequence () {
        return this._coordinates
      };
      Point.prototype.getY = function getY () {
        if (this.getCoordinate() === null) {
          throw new Error('getY called on empty Point')
        }
        return this.getCoordinate().y
      };
      Point.prototype.isEmpty = function isEmpty () {
        return this._coordinates.size() === 0
      };
      Point.prototype.init = function init (coordinates) {
        if (coordinates === null) {
          coordinates = this.getFactory().getCoordinateSequenceFactory().create([]);
        }
        Assert.isTrue(coordinates.size() <= 1);
        this._coordinates = coordinates;
      };
      Point.prototype.isSimple = function isSimple () {
        return true
      };
      Point.prototype.interfaces_ = function interfaces_ () {
        return [Puntal]
      };
      Point.prototype.getClass = function getClass () {
        return Point
      };
      staticAccessors.serialVersionUID.get = function () { return 4902022702746614570 };

      Object.defineProperties( Point, staticAccessors );

      return Point;
    }(Geometry));

    var Polygonal = function Polygonal () {};

    Polygonal.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Polygonal.prototype.getClass = function getClass () {
      return Polygonal
    };

    var Polygon = (function (Geometry$$1) {
      function Polygon (shell, holes, factory) {
        Geometry$$1.call(this, factory);
        this._shell = null;
        this._holes = null;
        if (shell === null) {
          shell = this.getFactory().createLinearRing();
        }
        if (holes === null) {
          holes = [];
        }
        if (Geometry$$1.hasNullElements(holes)) {
          throw new IllegalArgumentException('holes must not contain null elements')
        }
        if (shell.isEmpty() && Geometry$$1.hasNonEmptyElements(holes)) {
          throw new IllegalArgumentException('shell is empty but holes are not')
        }
        this._shell = shell;
        this._holes = holes;
      }

      if ( Geometry$$1 ) Polygon.__proto__ = Geometry$$1;
      Polygon.prototype = Object.create( Geometry$$1 && Geometry$$1.prototype );
      Polygon.prototype.constructor = Polygon;

      var staticAccessors = { serialVersionUID: { configurable: true } };
      Polygon.prototype.computeEnvelopeInternal = function computeEnvelopeInternal () {
        return this._shell.getEnvelopeInternal()
      };
      Polygon.prototype.getSortIndex = function getSortIndex () {
        return Geometry$$1.SORTINDEX_POLYGON
      };
      Polygon.prototype.getCoordinates = function getCoordinates () {
        var this$1 = this;

        if (this.isEmpty()) {
          return []
        }
        var coordinates = new Array(this.getNumPoints()).fill(null);
        var k = -1;
        var shellCoordinates = this._shell.getCoordinates();
        for (var x = 0; x < shellCoordinates.length; x++) {
          k++;
          coordinates[k] = shellCoordinates[x];
        }
        for (var i = 0; i < this._holes.length; i++) {
          var childCoordinates = this$1._holes[i].getCoordinates();
          for (var j = 0; j < childCoordinates.length; j++) {
            k++;
            coordinates[k] = childCoordinates[j];
          }
        }
        return coordinates
      };
      Polygon.prototype.getArea = function getArea () {
        var this$1 = this;

        var area = 0.0;
        area += Math.abs(CGAlgorithms.signedArea(this._shell.getCoordinateSequence()));
        for (var i = 0; i < this._holes.length; i++) {
          area -= Math.abs(CGAlgorithms.signedArea(this$1._holes[i].getCoordinateSequence()));
        }
        return area
      };
      Polygon.prototype.isRectangle = function isRectangle () {
        if (this.getNumInteriorRing() !== 0) { return false }
        if (this._shell === null) { return false }
        if (this._shell.getNumPoints() !== 5) { return false }
        var seq = this._shell.getCoordinateSequence();
        var env = this.getEnvelopeInternal();
        for (var i = 0; i < 5; i++) {
          var x = seq.getX(i);
          if (!(x === env.getMinX() || x === env.getMaxX())) { return false }
          var y = seq.getY(i);
          if (!(y === env.getMinY() || y === env.getMaxY())) { return false }
        }
        var prevX = seq.getX(0);
        var prevY = seq.getY(0);
        for (var i$1 = 1; i$1 <= 4; i$1++) {
          var x$1 = seq.getX(i$1);
          var y$1 = seq.getY(i$1);
          var xChanged = x$1 !== prevX;
          var yChanged = y$1 !== prevY;
          if (xChanged === yChanged) { return false }
          prevX = x$1;
          prevY = y$1;
        }
        return true
      };
      Polygon.prototype.equalsExact = function equalsExact () {
        var this$1 = this;

        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          var otherPolygon = other;
          var thisShell = this._shell;
          var otherPolygonShell = otherPolygon._shell;
          if (!thisShell.equalsExact(otherPolygonShell, tolerance)) {
            return false
          }
          if (this._holes.length !== otherPolygon._holes.length) {
            return false
          }
          for (var i = 0; i < this._holes.length; i++) {
            if (!this$1._holes[i].equalsExact(otherPolygon._holes[i], tolerance)) {
              return false
            }
          }
          return true
        } else { return Geometry$$1.prototype.equalsExact.apply(this, arguments) }
      };
      Polygon.prototype.normalize = function normalize () {
        var this$1 = this;

        if (arguments.length === 0) {
          this.normalize(this._shell, true);
          for (var i = 0; i < this._holes.length; i++) {
            this$1.normalize(this$1._holes[i], false);
          }
          Arrays.sort(this._holes);
        } else if (arguments.length === 2) {
          var ring = arguments[0];
          var clockwise = arguments[1];
          if (ring.isEmpty()) {
            return null
          }
          var uniqueCoordinates = new Array(ring.getCoordinates().length - 1).fill(null);
          System.arraycopy(ring.getCoordinates(), 0, uniqueCoordinates, 0, uniqueCoordinates.length);
          var minCoordinate = CoordinateArrays.minCoordinate(ring.getCoordinates());
          CoordinateArrays.scroll(uniqueCoordinates, minCoordinate);
          System.arraycopy(uniqueCoordinates, 0, ring.getCoordinates(), 0, uniqueCoordinates.length);
          ring.getCoordinates()[uniqueCoordinates.length] = uniqueCoordinates[0];
          if (CGAlgorithms.isCCW(ring.getCoordinates()) === clockwise) {
            CoordinateArrays.reverse(ring.getCoordinates());
          }
        }
      };
      Polygon.prototype.getCoordinate = function getCoordinate () {
        return this._shell.getCoordinate()
      };
      Polygon.prototype.getNumInteriorRing = function getNumInteriorRing () {
        return this._holes.length
      };
      Polygon.prototype.getBoundaryDimension = function getBoundaryDimension () {
        return 1
      };
      Polygon.prototype.getDimension = function getDimension () {
        return 2
      };
      Polygon.prototype.getLength = function getLength () {
        var this$1 = this;

        var len = 0.0;
        len += this._shell.getLength();
        for (var i = 0; i < this._holes.length; i++) {
          len += this$1._holes[i].getLength();
        }
        return len
      };
      Polygon.prototype.getNumPoints = function getNumPoints () {
        var this$1 = this;

        var numPoints = this._shell.getNumPoints();
        for (var i = 0; i < this._holes.length; i++) {
          numPoints += this$1._holes[i].getNumPoints();
        }
        return numPoints
      };
      Polygon.prototype.reverse = function reverse () {
        var this$1 = this;

        var poly = this.copy();
        poly._shell = this._shell.copy().reverse();
        poly._holes = new Array(this._holes.length).fill(null);
        for (var i = 0; i < this._holes.length; i++) {
          poly._holes[i] = this$1._holes[i].copy().reverse();
        }
        return poly
      };
      Polygon.prototype.convexHull = function convexHull () {
        return this.getExteriorRing().convexHull()
      };
      Polygon.prototype.compareToSameClass = function compareToSameClass () {
        var this$1 = this;

        if (arguments.length === 1) {
          var o = arguments[0];
          var thisShell = this._shell;
          var otherShell = o._shell;
          return thisShell.compareToSameClass(otherShell)
        } else if (arguments.length === 2) {
          var o$1 = arguments[0];
          var comp = arguments[1];
          var poly = o$1;
          var thisShell$1 = this._shell;
          var otherShell$1 = poly._shell;
          var shellComp = thisShell$1.compareToSameClass(otherShell$1, comp);
          if (shellComp !== 0) { return shellComp }
          var nHole1 = this.getNumInteriorRing();
          var nHole2 = poly.getNumInteriorRing();
          var i = 0;
          while (i < nHole1 && i < nHole2) {
            var thisHole = this$1.getInteriorRingN(i);
            var otherHole = poly.getInteriorRingN(i);
            var holeComp = thisHole.compareToSameClass(otherHole, comp);
            if (holeComp !== 0) { return holeComp }
            i++;
          }
          if (i < nHole1) { return 1 }
          if (i < nHole2) { return -1 }
          return 0
        }
      };
      Polygon.prototype.apply = function apply (filter) {
        var this$1 = this;

        if (hasInterface(filter, CoordinateFilter)) {
          this._shell.apply(filter);
          for (var i$1 = 0; i$1 < this._holes.length; i$1++) {
            this$1._holes[i$1].apply(filter);
          }
        } else if (hasInterface(filter, CoordinateSequenceFilter)) {
          this._shell.apply(filter);
          if (!filter.isDone()) {
            for (var i$2 = 0; i$2 < this._holes.length; i$2++) {
              this$1._holes[i$2].apply(filter);
              if (filter.isDone()) { break }
            }
          }
          if (filter.isGeometryChanged()) { this.geometryChanged(); }
        } else if (hasInterface(filter, GeometryFilter)) {
          filter.filter(this);
        } else if (hasInterface(filter, GeometryComponentFilter)) {
          filter.filter(this);
          this._shell.apply(filter);
          for (var i = 0; i < this._holes.length; i++) {
            this$1._holes[i].apply(filter);
          }
        }
      };
      Polygon.prototype.getBoundary = function getBoundary () {
        var this$1 = this;

        if (this.isEmpty()) {
          return this.getFactory().createMultiLineString()
        }
        var rings = new Array(this._holes.length + 1).fill(null);
        rings[0] = this._shell;
        for (var i = 0; i < this._holes.length; i++) {
          rings[i + 1] = this$1._holes[i];
        }
        if (rings.length <= 1) { return this.getFactory().createLinearRing(rings[0].getCoordinateSequence()) }
        return this.getFactory().createMultiLineString(rings)
      };
      Polygon.prototype.clone = function clone () {
        var this$1 = this;

        var poly = Geometry$$1.prototype.clone.call(this);
        poly._shell = this._shell.clone();
        poly._holes = new Array(this._holes.length).fill(null);
        for (var i = 0; i < this._holes.length; i++) {
          poly._holes[i] = this$1._holes[i].clone();
        }
        return poly
      };
      Polygon.prototype.getGeometryType = function getGeometryType () {
        return 'Polygon'
      };
      Polygon.prototype.copy = function copy () {
        var this$1 = this;

        var shell = this._shell.copy();
        var holes = new Array(this._holes.length).fill(null);
        for (var i = 0; i < holes.length; i++) {
          holes[i] = this$1._holes[i].copy();
        }
        return new Polygon(shell, holes, this._factory)
      };
      Polygon.prototype.getExteriorRing = function getExteriorRing () {
        return this._shell
      };
      Polygon.prototype.isEmpty = function isEmpty () {
        return this._shell.isEmpty()
      };
      Polygon.prototype.getInteriorRingN = function getInteriorRingN (n) {
        return this._holes[n]
      };
      Polygon.prototype.interfaces_ = function interfaces_ () {
        return [Polygonal]
      };
      Polygon.prototype.getClass = function getClass () {
        return Polygon
      };
      staticAccessors.serialVersionUID.get = function () { return -3494792200821764533 };

      Object.defineProperties( Polygon, staticAccessors );

      return Polygon;
    }(Geometry));

    var MultiPoint = (function (GeometryCollection$$1) {
      function MultiPoint () {
        GeometryCollection$$1.apply(this, arguments);
      }

      if ( GeometryCollection$$1 ) MultiPoint.__proto__ = GeometryCollection$$1;
      MultiPoint.prototype = Object.create( GeometryCollection$$1 && GeometryCollection$$1.prototype );
      MultiPoint.prototype.constructor = MultiPoint;

      var staticAccessors = { serialVersionUID: { configurable: true } };

      MultiPoint.prototype.getSortIndex = function getSortIndex () {
        return Geometry.SORTINDEX_MULTIPOINT
      };
      MultiPoint.prototype.isValid = function isValid () {
        return true
      };
      MultiPoint.prototype.equalsExact = function equalsExact () {
        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance)
        } else { return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments) }
      };
      MultiPoint.prototype.getCoordinate = function getCoordinate () {
        if (arguments.length === 1) {
          var n = arguments[0];
          return this._geometries[n].getCoordinate()
        } else { return GeometryCollection$$1.prototype.getCoordinate.apply(this, arguments) }
      };
      MultiPoint.prototype.getBoundaryDimension = function getBoundaryDimension () {
        return Dimension.FALSE
      };
      MultiPoint.prototype.getDimension = function getDimension () {
        return 0
      };
      MultiPoint.prototype.getBoundary = function getBoundary () {
        return this.getFactory().createGeometryCollection(null)
      };
      MultiPoint.prototype.getGeometryType = function getGeometryType () {
        return 'MultiPoint'
      };
      MultiPoint.prototype.copy = function copy () {
        var this$1 = this;

        var points = new Array(this._geometries.length).fill(null);
        for (var i = 0; i < points.length; i++) {
          points[i] = this$1._geometries[i].copy();
        }
        return new MultiPoint(points, this._factory)
      };
      MultiPoint.prototype.interfaces_ = function interfaces_ () {
        return [Puntal]
      };
      MultiPoint.prototype.getClass = function getClass () {
        return MultiPoint
      };
      staticAccessors.serialVersionUID.get = function () { return -8048474874175355449 };

      Object.defineProperties( MultiPoint, staticAccessors );

      return MultiPoint;
    }(GeometryCollection));

    var LinearRing = (function (LineString$$1) {
      function LinearRing (points, factory) {
        if (points instanceof Coordinate && factory instanceof GeometryFactory) {
          points = factory.getCoordinateSequenceFactory().create(points);
        }
        LineString$$1.call(this, points, factory);
        this.validateConstruction();
      }

      if ( LineString$$1 ) LinearRing.__proto__ = LineString$$1;
      LinearRing.prototype = Object.create( LineString$$1 && LineString$$1.prototype );
      LinearRing.prototype.constructor = LinearRing;

      var staticAccessors = { MINIMUM_VALID_SIZE: { configurable: true },serialVersionUID: { configurable: true } };
      LinearRing.prototype.getSortIndex = function getSortIndex () {
        return Geometry.SORTINDEX_LINEARRING
      };
      LinearRing.prototype.getBoundaryDimension = function getBoundaryDimension () {
        return Dimension.FALSE
      };
      LinearRing.prototype.isClosed = function isClosed () {
        if (this.isEmpty()) {
          return true
        }
        return LineString$$1.prototype.isClosed.call(this)
      };
      LinearRing.prototype.reverse = function reverse () {
        var seq = this._points.copy();
        CoordinateSequences.reverse(seq);
        var rev = this.getFactory().createLinearRing(seq);
        return rev
      };
      LinearRing.prototype.validateConstruction = function validateConstruction () {
        if (!this.isEmpty() && !LineString$$1.prototype.isClosed.call(this)) {
          throw new IllegalArgumentException('Points of LinearRing do not form a closed linestring')
        }
        if (this.getCoordinateSequence().size() >= 1 && this.getCoordinateSequence().size() < LinearRing.MINIMUM_VALID_SIZE) {
          throw new IllegalArgumentException('Invalid number of points in LinearRing (found ' + this.getCoordinateSequence().size() + ' - must be 0 or >= 4)')
        }
      };
      LinearRing.prototype.getGeometryType = function getGeometryType () {
        return 'LinearRing'
      };
      LinearRing.prototype.copy = function copy () {
        return new LinearRing(this._points.copy(), this._factory)
      };
      LinearRing.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      LinearRing.prototype.getClass = function getClass () {
        return LinearRing
      };
      staticAccessors.MINIMUM_VALID_SIZE.get = function () { return 4 };
      staticAccessors.serialVersionUID.get = function () { return -4261142084085851829 };

      Object.defineProperties( LinearRing, staticAccessors );

      return LinearRing;
    }(LineString$1));

    var MultiPolygon = (function (GeometryCollection$$1) {
      function MultiPolygon () {
        GeometryCollection$$1.apply(this, arguments);
      }

      if ( GeometryCollection$$1 ) MultiPolygon.__proto__ = GeometryCollection$$1;
      MultiPolygon.prototype = Object.create( GeometryCollection$$1 && GeometryCollection$$1.prototype );
      MultiPolygon.prototype.constructor = MultiPolygon;

      var staticAccessors = { serialVersionUID: { configurable: true } };

      MultiPolygon.prototype.getSortIndex = function getSortIndex () {
        return Geometry.SORTINDEX_MULTIPOLYGON
      };
      MultiPolygon.prototype.equalsExact = function equalsExact () {
        if (arguments.length === 2) {
          var other = arguments[0];
          var tolerance = arguments[1];
          if (!this.isEquivalentClass(other)) {
            return false
          }
          return GeometryCollection$$1.prototype.equalsExact.call(this, other, tolerance)
        } else { return GeometryCollection$$1.prototype.equalsExact.apply(this, arguments) }
      };
      MultiPolygon.prototype.getBoundaryDimension = function getBoundaryDimension () {
        return 1
      };
      MultiPolygon.prototype.getDimension = function getDimension () {
        return 2
      };
      MultiPolygon.prototype.reverse = function reverse () {
        var this$1 = this;

        var n = this._geometries.length;
        var revGeoms = new Array(n).fill(null);
        for (var i = 0; i < this._geometries.length; i++) {
          revGeoms[i] = this$1._geometries[i].reverse();
        }
        return this.getFactory().createMultiPolygon(revGeoms)
      };
      MultiPolygon.prototype.getBoundary = function getBoundary () {
        var this$1 = this;

        if (this.isEmpty()) {
          return this.getFactory().createMultiLineString()
        }
        var allRings = new ArrayList();
        for (var i = 0; i < this._geometries.length; i++) {
          var polygon = this$1._geometries[i];
          var rings = polygon.getBoundary();
          for (var j = 0; j < rings.getNumGeometries(); j++) {
            allRings.add(rings.getGeometryN(j));
          }
        }
        var allRingsArray = new Array(allRings.size()).fill(null);
        return this.getFactory().createMultiLineString(allRings.toArray(allRingsArray))
      };
      MultiPolygon.prototype.getGeometryType = function getGeometryType () {
        return 'MultiPolygon'
      };
      MultiPolygon.prototype.copy = function copy () {
        var this$1 = this;

        var polygons = new Array(this._geometries.length).fill(null);
        for (var i = 0; i < polygons.length; i++) {
          polygons[i] = this$1._geometries[i].copy();
        }
        return new MultiPolygon(polygons, this._factory)
      };
      MultiPolygon.prototype.interfaces_ = function interfaces_ () {
        return [Polygonal]
      };
      MultiPolygon.prototype.getClass = function getClass () {
        return MultiPolygon
      };
      staticAccessors.serialVersionUID.get = function () { return -551033529766975875 };

      Object.defineProperties( MultiPolygon, staticAccessors );

      return MultiPolygon;
    }(GeometryCollection));

    var GeometryEditor = function GeometryEditor (factory) {
      this._factory = factory || null;
      this._isUserDataCopied = false;
    };

    var staticAccessors$16 = { NoOpGeometryOperation: { configurable: true },CoordinateOperation: { configurable: true },CoordinateSequenceOperation: { configurable: true } };
    GeometryEditor.prototype.setCopyUserData = function setCopyUserData (isUserDataCopied) {
      this._isUserDataCopied = isUserDataCopied;
    };
    GeometryEditor.prototype.edit = function edit (geometry, operation) {
      if (geometry === null) { return null }
      var result = this.editInternal(geometry, operation);
      if (this._isUserDataCopied) {
        result.setUserData(geometry.getUserData());
      }
      return result
    };
    GeometryEditor.prototype.editInternal = function editInternal (geometry, operation) {
      if (this._factory === null) { this._factory = geometry.getFactory(); }
      if (geometry instanceof GeometryCollection) {
        return this.editGeometryCollection(geometry, operation)
      }
      if (geometry instanceof Polygon) {
        return this.editPolygon(geometry, operation)
      }
      if (geometry instanceof Point) {
        return operation.edit(geometry, this._factory)
      }
      if (geometry instanceof LineString$1) {
        return operation.edit(geometry, this._factory)
      }
      Assert.shouldNeverReachHere('Unsupported Geometry class: ' + geometry.getClass().getName());
      return null
    };
    GeometryEditor.prototype.editGeometryCollection = function editGeometryCollection (collection, operation) {
        var this$1 = this;

      var collectionForType = operation.edit(collection, this._factory);
      var geometries = new ArrayList();
      for (var i = 0; i < collectionForType.getNumGeometries(); i++) {
        var geometry = this$1.edit(collectionForType.getGeometryN(i), operation);
        if (geometry === null || geometry.isEmpty()) {
          continue
        }
        geometries.add(geometry);
      }
      if (collectionForType.getClass() === MultiPoint) {
        return this._factory.createMultiPoint(geometries.toArray([]))
      }
      if (collectionForType.getClass() === MultiLineString) {
        return this._factory.createMultiLineString(geometries.toArray([]))
      }
      if (collectionForType.getClass() === MultiPolygon) {
        return this._factory.createMultiPolygon(geometries.toArray([]))
      }
      return this._factory.createGeometryCollection(geometries.toArray([]))
    };
    GeometryEditor.prototype.editPolygon = function editPolygon (polygon, operation) {
        var this$1 = this;

      var newPolygon = operation.edit(polygon, this._factory);
      if (newPolygon === null) { newPolygon = this._factory.createPolygon(null); }
      if (newPolygon.isEmpty()) {
        return newPolygon
      }
      var shell = this.edit(newPolygon.getExteriorRing(), operation);
      if (shell === null || shell.isEmpty()) {
        return this._factory.createPolygon()
      }
      var holes = new ArrayList();
      for (var i = 0; i < newPolygon.getNumInteriorRing(); i++) {
        var hole = this$1.edit(newPolygon.getInteriorRingN(i), operation);
        if (hole === null || hole.isEmpty()) {
          continue
        }
        holes.add(hole);
      }
      return this._factory.createPolygon(shell, holes.toArray([]))
    };
    GeometryEditor.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryEditor.prototype.getClass = function getClass () {
      return GeometryEditor
    };
    GeometryEditor.GeometryEditorOperation = function GeometryEditorOperation () {};
    staticAccessors$16.NoOpGeometryOperation.get = function () { return NoOpGeometryOperation };
    staticAccessors$16.CoordinateOperation.get = function () { return CoordinateOperation };
    staticAccessors$16.CoordinateSequenceOperation.get = function () { return CoordinateSequenceOperation };

    Object.defineProperties( GeometryEditor, staticAccessors$16 );

    var NoOpGeometryOperation = function NoOpGeometryOperation () {};

    NoOpGeometryOperation.prototype.edit = function edit (geometry, factory) {
      return geometry
    };
    NoOpGeometryOperation.prototype.interfaces_ = function interfaces_ () {
      return [GeometryEditor.GeometryEditorOperation]
    };
    NoOpGeometryOperation.prototype.getClass = function getClass () {
      return NoOpGeometryOperation
    };

    var CoordinateOperation = function CoordinateOperation () {};

    CoordinateOperation.prototype.edit = function edit (geometry, factory) {
      var coords = this.editCoordinates(geometry.getCoordinates(), geometry);
      if (coords === null) { return geometry }
      if (geometry instanceof LinearRing) {
        return factory.createLinearRing(coords)
      }
      if (geometry instanceof LineString$1) {
        return factory.createLineString(coords)
      }
      if (geometry instanceof Point) {
        if (coords.length > 0) {
          return factory.createPoint(coords[0])
        } else {
          return factory.createPoint()
        }
      }
      return geometry
    };
    CoordinateOperation.prototype.interfaces_ = function interfaces_ () {
      return [GeometryEditor.GeometryEditorOperation]
    };
    CoordinateOperation.prototype.getClass = function getClass () {
      return CoordinateOperation
    };

    var CoordinateSequenceOperation = function CoordinateSequenceOperation () {};

    CoordinateSequenceOperation.prototype.edit = function edit (geometry, factory) {
      if (geometry instanceof LinearRing) {
        return factory.createLinearRing(this.edit(geometry.getCoordinateSequence(), geometry))
      }
      if (geometry instanceof LineString$1) {
        return factory.createLineString(this.edit(geometry.getCoordinateSequence(), geometry))
      }
      if (geometry instanceof Point) {
        return factory.createPoint(this.edit(geometry.getCoordinateSequence(), geometry))
      }
      return geometry
    };
    CoordinateSequenceOperation.prototype.interfaces_ = function interfaces_ () {
      return [GeometryEditor.GeometryEditorOperation]
    };
    CoordinateSequenceOperation.prototype.getClass = function getClass () {
      return CoordinateSequenceOperation
    };

    var CoordinateArraySequence = function CoordinateArraySequence () {
      var this$1 = this;

      this._dimension = 3;
      this._coordinates = null;
      if (arguments.length === 1) {
        if (arguments[0] instanceof Array) {
          this._coordinates = arguments[0];
          this._dimension = 3;
        } else if (Number.isInteger(arguments[0])) {
          var size = arguments[0];
          this._coordinates = new Array(size).fill(null);
          for (var i = 0; i < size; i++) {
            this$1._coordinates[i] = new Coordinate();
          }
        } else if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordSeq = arguments[0];
          if (coordSeq === null) {
            this._coordinates = new Array(0).fill(null);
            return null
          }
          this._dimension = coordSeq.getDimension();
          this._coordinates = new Array(coordSeq.size()).fill(null);
          for (var i$1 = 0; i$1 < this._coordinates.length; i$1++) {
            this$1._coordinates[i$1] = coordSeq.getCoordinateCopy(i$1);
          }
        }
      } else if (arguments.length === 2) {
        if (arguments[0] instanceof Array && Number.isInteger(arguments[1])) {
          var coordinates = arguments[0];
          var dimension = arguments[1];
          this._coordinates = coordinates;
          this._dimension = dimension;
          if (coordinates === null) { this._coordinates = new Array(0).fill(null); }
        } else if (Number.isInteger(arguments[0]) && Number.isInteger(arguments[1])) {
          var size$1 = arguments[0];
          var dimension$1 = arguments[1];
          this._coordinates = new Array(size$1).fill(null);
          this._dimension = dimension$1;
          for (var i$2 = 0; i$2 < size$1; i$2++) {
            this$1._coordinates[i$2] = new Coordinate();
          }
        }
      }
    };

    var staticAccessors$18 = { serialVersionUID: { configurable: true } };
    CoordinateArraySequence.prototype.setOrdinate = function setOrdinate (index, ordinateIndex, value) {
      switch (ordinateIndex) {
        case CoordinateSequence.X:
          this._coordinates[index].x = value;
          break
        case CoordinateSequence.Y:
          this._coordinates[index].y = value;
          break
        case CoordinateSequence.Z:
          this._coordinates[index].z = value;
          break
        default:
          throw new IllegalArgumentException('invalid ordinateIndex')
      }
    };
    CoordinateArraySequence.prototype.size = function size () {
      return this._coordinates.length
    };
    CoordinateArraySequence.prototype.getOrdinate = function getOrdinate (index, ordinateIndex) {
      switch (ordinateIndex) {
        case CoordinateSequence.X:
          return this._coordinates[index].x
        case CoordinateSequence.Y:
          return this._coordinates[index].y
        case CoordinateSequence.Z:
          return this._coordinates[index].z
        default:
      }
      return Double.NaN
    };
    CoordinateArraySequence.prototype.getCoordinate = function getCoordinate () {
      if (arguments.length === 1) {
        var i = arguments[0];
        return this._coordinates[i]
      } else if (arguments.length === 2) {
        var index = arguments[0];
        var coord = arguments[1];
        coord.x = this._coordinates[index].x;
        coord.y = this._coordinates[index].y;
        coord.z = this._coordinates[index].z;
      }
    };
    CoordinateArraySequence.prototype.getCoordinateCopy = function getCoordinateCopy (i) {
      return new Coordinate(this._coordinates[i])
    };
    CoordinateArraySequence.prototype.getDimension = function getDimension () {
      return this._dimension
    };
    CoordinateArraySequence.prototype.getX = function getX (index) {
      return this._coordinates[index].x
    };
    CoordinateArraySequence.prototype.clone = function clone () {
        var this$1 = this;

      var cloneCoordinates = new Array(this.size()).fill(null);
      for (var i = 0; i < this._coordinates.length; i++) {
        cloneCoordinates[i] = this$1._coordinates[i].clone();
      }
      return new CoordinateArraySequence(cloneCoordinates, this._dimension)
    };
    CoordinateArraySequence.prototype.expandEnvelope = function expandEnvelope (env) {
        var this$1 = this;

      for (var i = 0; i < this._coordinates.length; i++) {
        env.expandToInclude(this$1._coordinates[i]);
      }
      return env
    };
    CoordinateArraySequence.prototype.copy = function copy () {
        var this$1 = this;

      var cloneCoordinates = new Array(this.size()).fill(null);
      for (var i = 0; i < this._coordinates.length; i++) {
        cloneCoordinates[i] = this$1._coordinates[i].copy();
      }
      return new CoordinateArraySequence(cloneCoordinates, this._dimension)
    };
    CoordinateArraySequence.prototype.toString = function toString () {
        var this$1 = this;

      if (this._coordinates.length > 0) {
        var strBuf = new StringBuffer(17 * this._coordinates.length);
        strBuf.append('(');
        strBuf.append(this._coordinates[0]);
        for (var i = 1; i < this._coordinates.length; i++) {
          strBuf.append(', ');
          strBuf.append(this$1._coordinates[i]);
        }
        strBuf.append(')');
        return strBuf.toString()
      } else {
        return '()'
      }
    };
    CoordinateArraySequence.prototype.getY = function getY (index) {
      return this._coordinates[index].y
    };
    CoordinateArraySequence.prototype.toCoordinateArray = function toCoordinateArray () {
      return this._coordinates
    };
    CoordinateArraySequence.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateSequence, Serializable]
    };
    CoordinateArraySequence.prototype.getClass = function getClass () {
      return CoordinateArraySequence
    };
    staticAccessors$18.serialVersionUID.get = function () { return -915438501601840650 };

    Object.defineProperties( CoordinateArraySequence, staticAccessors$18 );

    var CoordinateArraySequenceFactory = function CoordinateArraySequenceFactory () {};

    var staticAccessors$17 = { serialVersionUID: { configurable: true },instanceObject: { configurable: true } };

    CoordinateArraySequenceFactory.prototype.readResolve = function readResolve () {
      return CoordinateArraySequenceFactory.instance()
    };
    CoordinateArraySequenceFactory.prototype.create = function create () {
      if (arguments.length === 1) {
        if (arguments[0] instanceof Array) {
          var coordinates = arguments[0];
          return new CoordinateArraySequence(coordinates)
        } else if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordSeq = arguments[0];
          return new CoordinateArraySequence(coordSeq)
        }
      } else if (arguments.length === 2) {
        var size = arguments[0];
        var dimension = arguments[1];
        if (dimension > 3) { dimension = 3; }
        if (dimension < 2) { return new CoordinateArraySequence(size) }
        return new CoordinateArraySequence(size, dimension)
      }
    };
    CoordinateArraySequenceFactory.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateSequenceFactory, Serializable]
    };
    CoordinateArraySequenceFactory.prototype.getClass = function getClass () {
      return CoordinateArraySequenceFactory
    };
    CoordinateArraySequenceFactory.instance = function instance () {
      return CoordinateArraySequenceFactory.instanceObject
    };

    staticAccessors$17.serialVersionUID.get = function () { return -4099577099607551657 };
    staticAccessors$17.instanceObject.get = function () { return new CoordinateArraySequenceFactory() };

    Object.defineProperties( CoordinateArraySequenceFactory, staticAccessors$17 );

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/HashMap.html
     *
     * @extends {javascript.util.Map}
     * @constructor
     * @private
     */
    var HashMap = (function (MapInterface) {
      function HashMap () {
        MapInterface.call(this);
        this.map_ = new Map();
      }

      if ( MapInterface ) HashMap.__proto__ = MapInterface;
      HashMap.prototype = Object.create( MapInterface && MapInterface.prototype );
      HashMap.prototype.constructor = HashMap;
      /**
       * @override
       */
      HashMap.prototype.get = function get (key) {
        return this.map_.get(key) || null
      };

      /**
       * @override
       */
      HashMap.prototype.put = function put (key, value) {
        this.map_.set(key, value);
        return value
      };

      /**
       * @override
       */
      HashMap.prototype.values = function values () {
        var arrayList = new ArrayList();
        var it = this.map_.values();
        var o = it.next();
        while (!o.done) {
          arrayList.add(o.value);
          o = it.next();
        }
        return arrayList
      };

      /**
       * @override
       */
      HashMap.prototype.entrySet = function entrySet () {
        var hashSet = new HashSet();
        this.map_.entries().forEach(function (entry) { return hashSet.add(entry); });
        return hashSet
      };

      /**
       * @override
       */
      HashMap.prototype.size = function size () {
        return this.map_.size()
      };

      return HashMap;
    }(Map$1));

    var PrecisionModel = function PrecisionModel () {
      this._modelType = null;
      this._scale = null;
      if (arguments.length === 0) {
        this._modelType = PrecisionModel.FLOATING;
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Type) {
          var modelType = arguments[0];
          this._modelType = modelType;
          if (modelType === PrecisionModel.FIXED) {
            this.setScale(1.0);
          }
        } else if (typeof arguments[0] === 'number') {
          var scale = arguments[0];
          this._modelType = PrecisionModel.FIXED;
          this.setScale(scale);
        } else if (arguments[0] instanceof PrecisionModel) {
          var pm = arguments[0];
          this._modelType = pm._modelType;
          this._scale = pm._scale;
        }
      }
    };

    var staticAccessors$19 = { serialVersionUID: { configurable: true },maximumPreciseValue: { configurable: true } };
    PrecisionModel.prototype.equals = function equals (other) {
      if (!(other instanceof PrecisionModel)) {
        return false
      }
      var otherPrecisionModel = other;
      return this._modelType === otherPrecisionModel._modelType && this._scale === otherPrecisionModel._scale
    };
    PrecisionModel.prototype.compareTo = function compareTo (o) {
      var other = o;
      var sigDigits = this.getMaximumSignificantDigits();
      var otherSigDigits = other.getMaximumSignificantDigits();
      return new Integer(sigDigits).compareTo(new Integer(otherSigDigits))
    };
    PrecisionModel.prototype.getScale = function getScale () {
      return this._scale
    };
    PrecisionModel.prototype.isFloating = function isFloating () {
      return this._modelType === PrecisionModel.FLOATING || this._modelType === PrecisionModel.FLOATING_SINGLE
    };
    PrecisionModel.prototype.getType = function getType () {
      return this._modelType
    };
    PrecisionModel.prototype.toString = function toString () {
      var description = 'UNKNOWN';
      if (this._modelType === PrecisionModel.FLOATING) {
        description = 'Floating';
      } else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
        description = 'Floating-Single';
      } else if (this._modelType === PrecisionModel.FIXED) {
        description = 'Fixed (Scale=' + this.getScale() + ')';
      }
      return description
    };
    PrecisionModel.prototype.makePrecise = function makePrecise () {
      if (typeof arguments[0] === 'number') {
        var val = arguments[0];
        if (Double.isNaN(val)) { return val }
        if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
          var floatSingleVal = val;
          return floatSingleVal
        }
        if (this._modelType === PrecisionModel.FIXED) {
          return Math.round(val * this._scale) / this._scale
        }
        return val
      } else if (arguments[0] instanceof Coordinate) {
        var coord = arguments[0];
        if (this._modelType === PrecisionModel.FLOATING) { return null }
        coord.x = this.makePrecise(coord.x);
        coord.y = this.makePrecise(coord.y);
      }
    };
    PrecisionModel.prototype.getMaximumSignificantDigits = function getMaximumSignificantDigits () {
      var maxSigDigits = 16;
      if (this._modelType === PrecisionModel.FLOATING) {
        maxSigDigits = 16;
      } else if (this._modelType === PrecisionModel.FLOATING_SINGLE) {
        maxSigDigits = 6;
      } else if (this._modelType === PrecisionModel.FIXED) {
        maxSigDigits = 1 + Math.trunc(Math.ceil(Math.log(this.getScale()) / Math.log(10)));
      }
      return maxSigDigits
    };
    PrecisionModel.prototype.setScale = function setScale (scale) {
      this._scale = Math.abs(scale);
    };
    PrecisionModel.prototype.interfaces_ = function interfaces_ () {
      return [Serializable, Comparable]
    };
    PrecisionModel.prototype.getClass = function getClass () {
      return PrecisionModel
    };
    PrecisionModel.mostPrecise = function mostPrecise (pm1, pm2) {
      if (pm1.compareTo(pm2) >= 0) { return pm1 }
      return pm2
    };
    staticAccessors$19.serialVersionUID.get = function () { return 7777263578777803835 };
    staticAccessors$19.maximumPreciseValue.get = function () { return 9007199254740992.0 };

    Object.defineProperties( PrecisionModel, staticAccessors$19 );

    var Type = function Type (name) {
      this._name = name || null;
      Type.nameToTypeMap.put(name, this);
    };

    var staticAccessors$1$1 = { serialVersionUID: { configurable: true },nameToTypeMap: { configurable: true } };
    Type.prototype.readResolve = function readResolve () {
      return Type.nameToTypeMap.get(this._name)
    };
    Type.prototype.toString = function toString () {
      return this._name
    };
    Type.prototype.interfaces_ = function interfaces_ () {
      return [Serializable]
    };
    Type.prototype.getClass = function getClass () {
      return Type
    };
    staticAccessors$1$1.serialVersionUID.get = function () { return -5528602631731589822 };
    staticAccessors$1$1.nameToTypeMap.get = function () { return new HashMap() };

    Object.defineProperties( Type, staticAccessors$1$1 );

    PrecisionModel.Type = Type;
    PrecisionModel.FIXED = new Type('FIXED');
    PrecisionModel.FLOATING = new Type('FLOATING');
    PrecisionModel.FLOATING_SINGLE = new Type('FLOATING SINGLE');

    var GeometryFactory = function GeometryFactory () {
      this._precisionModel = new PrecisionModel();
      this._SRID = 0;
      this._coordinateSequenceFactory = GeometryFactory.getDefaultCoordinateSequenceFactory();

      if (arguments.length === 0) ; else if (arguments.length === 1) {
        if (hasInterface(arguments[0], CoordinateSequenceFactory)) {
          this._coordinateSequenceFactory = arguments[0];
        } else if (arguments[0] instanceof PrecisionModel) {
          this._precisionModel = arguments[0];
        }
      } else if (arguments.length === 2) {
        this._precisionModel = arguments[0];
        this._SRID = arguments[1];
      } else if (arguments.length === 3) {
        this._precisionModel = arguments[0];
        this._SRID = arguments[1];
        this._coordinateSequenceFactory = arguments[2];
      }
    };

    var staticAccessors$2 = { serialVersionUID: { configurable: true } };
    GeometryFactory.prototype.toGeometry = function toGeometry (envelope) {
      if (envelope.isNull()) {
        return this.createPoint(null)
      }
      if (envelope.getMinX() === envelope.getMaxX() && envelope.getMinY() === envelope.getMaxY()) {
        return this.createPoint(new Coordinate(envelope.getMinX(), envelope.getMinY()))
      }
      if (envelope.getMinX() === envelope.getMaxX() || envelope.getMinY() === envelope.getMaxY()) {
        return this.createLineString([new Coordinate(envelope.getMinX(), envelope.getMinY()), new Coordinate(envelope.getMaxX(), envelope.getMaxY())])
      }
      return this.createPolygon(this.createLinearRing([new Coordinate(envelope.getMinX(), envelope.getMinY()), new Coordinate(envelope.getMinX(), envelope.getMaxY()), new Coordinate(envelope.getMaxX(), envelope.getMaxY()), new Coordinate(envelope.getMaxX(), envelope.getMinY()), new Coordinate(envelope.getMinX(), envelope.getMinY())]), null)
    };
    GeometryFactory.prototype.createLineString = function createLineString (coordinates) {
      if (!coordinates) { return new LineString$1(this.getCoordinateSequenceFactory().create([]), this) }
      else if (coordinates instanceof Array) { return new LineString$1(this.getCoordinateSequenceFactory().create(coordinates), this) }
      else if (hasInterface(coordinates, CoordinateSequence)) { return new LineString$1(coordinates, this) }
    };
    GeometryFactory.prototype.createMultiLineString = function createMultiLineString () {
      if (arguments.length === 0) {
        return new MultiLineString(null, this)
      } else if (arguments.length === 1) {
        var lineStrings = arguments[0];
        return new MultiLineString(lineStrings, this)
      }
    };
    GeometryFactory.prototype.buildGeometry = function buildGeometry (geomList) {
      var geomClass = null;
      var isHeterogeneous = false;
      var hasGeometryCollection = false;
      for (var i = geomList.iterator(); i.hasNext();) {
        var geom = i.next();
        var partClass = geom.getClass();
        if (geomClass === null) {
          geomClass = partClass;
        }
        if (partClass !== geomClass) {
          isHeterogeneous = true;
        }
        if (geom.isGeometryCollectionOrDerived()) { hasGeometryCollection = true; }
      }
      if (geomClass === null) {
        return this.createGeometryCollection()
      }
      if (isHeterogeneous || hasGeometryCollection) {
        return this.createGeometryCollection(GeometryFactory.toGeometryArray(geomList))
      }
      var geom0 = geomList.iterator().next();
      var isCollection = geomList.size() > 1;
      if (isCollection) {
        if (geom0 instanceof Polygon) {
          return this.createMultiPolygon(GeometryFactory.toPolygonArray(geomList))
        } else if (geom0 instanceof LineString$1) {
          return this.createMultiLineString(GeometryFactory.toLineStringArray(geomList))
        } else if (geom0 instanceof Point) {
          return this.createMultiPoint(GeometryFactory.toPointArray(geomList))
        }
        Assert.shouldNeverReachHere('Unhandled class: ' + geom0.getClass().getName());
      }
      return geom0
    };
    GeometryFactory.prototype.createMultiPointFromCoords = function createMultiPointFromCoords (coordinates) {
      return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null)
    };
    GeometryFactory.prototype.createPoint = function createPoint () {
      if (arguments.length === 0) {
        return this.createPoint(this.getCoordinateSequenceFactory().create([]))
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Coordinate) {
          var coordinate = arguments[0];
          return this.createPoint(coordinate !== null ? this.getCoordinateSequenceFactory().create([coordinate]) : null)
        } else if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordinates = arguments[0];
          return new Point(coordinates, this)
        }
      }
    };
    GeometryFactory.prototype.getCoordinateSequenceFactory = function getCoordinateSequenceFactory () {
      return this._coordinateSequenceFactory
    };
    GeometryFactory.prototype.createPolygon = function createPolygon () {
      if (arguments.length === 0) {
        return new Polygon(null, null, this)
      } else if (arguments.length === 1) {
        if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordinates = arguments[0];
          return this.createPolygon(this.createLinearRing(coordinates))
        } else if (arguments[0] instanceof Array) {
          var coordinates$1 = arguments[0];
          return this.createPolygon(this.createLinearRing(coordinates$1))
        } else if (arguments[0] instanceof LinearRing) {
          var shell = arguments[0];
          return this.createPolygon(shell, null)
        }
      } else if (arguments.length === 2) {
        var shell$1 = arguments[0];
        var holes = arguments[1];
        return new Polygon(shell$1, holes, this)
      }
    };
    GeometryFactory.prototype.getSRID = function getSRID () {
      return this._SRID
    };
    GeometryFactory.prototype.createGeometryCollection = function createGeometryCollection () {
      if (arguments.length === 0) {
        return new GeometryCollection(null, this)
      } else if (arguments.length === 1) {
        var geometries = arguments[0];
        return new GeometryCollection(geometries, this)
      }
    };
    GeometryFactory.prototype.createGeometry = function createGeometry (g) {
      var editor = new GeometryEditor(this);
      return editor.edit(g, {
        edit: function () {
          if (arguments.length === 2) {
            var coordSeq = arguments[0];
            // const geometry = arguments[1]
            return this._coordinateSequenceFactory.create(coordSeq)
          }
        }
      })
    };
    GeometryFactory.prototype.getPrecisionModel = function getPrecisionModel () {
      return this._precisionModel
    };
    GeometryFactory.prototype.createLinearRing = function createLinearRing () {
      if (arguments.length === 0) {
        return this.createLinearRing(this.getCoordinateSequenceFactory().create([]))
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Array) {
          var coordinates = arguments[0];
          return this.createLinearRing(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null)
        } else if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordinates$1 = arguments[0];
          return new LinearRing(coordinates$1, this)
        }
      }
    };
    GeometryFactory.prototype.createMultiPolygon = function createMultiPolygon () {
      if (arguments.length === 0) {
        return new MultiPolygon(null, this)
      } else if (arguments.length === 1) {
        var polygons = arguments[0];
        return new MultiPolygon(polygons, this)
      }
    };
    GeometryFactory.prototype.createMultiPoint = function createMultiPoint () {
        var this$1 = this;

      if (arguments.length === 0) {
        return new MultiPoint(null, this)
      } else if (arguments.length === 1) {
        if (arguments[0] instanceof Array) {
          var point = arguments[0];
          return new MultiPoint(point, this)
        } else if (arguments[0] instanceof Array) {
          var coordinates = arguments[0];
          return this.createMultiPoint(coordinates !== null ? this.getCoordinateSequenceFactory().create(coordinates) : null)
        } else if (hasInterface(arguments[0], CoordinateSequence)) {
          var coordinates$1 = arguments[0];
          if (coordinates$1 === null) {
            return this.createMultiPoint(new Array(0).fill(null))
          }
          var points = new Array(coordinates$1.size()).fill(null);
          for (var i = 0; i < coordinates$1.size(); i++) {
            var ptSeq = this$1.getCoordinateSequenceFactory().create(1, coordinates$1.getDimension());
            CoordinateSequences.copy(coordinates$1, i, ptSeq, 0, 1);
            points[i] = this$1.createPoint(ptSeq);
          }
          return this.createMultiPoint(points)
        }
      }
    };
    GeometryFactory.prototype.interfaces_ = function interfaces_ () {
      return [Serializable]
    };
    GeometryFactory.prototype.getClass = function getClass () {
      return GeometryFactory
    };
    GeometryFactory.toMultiPolygonArray = function toMultiPolygonArray (multiPolygons) {
      var multiPolygonArray = new Array(multiPolygons.size()).fill(null);
      return multiPolygons.toArray(multiPolygonArray)
    };
    GeometryFactory.toGeometryArray = function toGeometryArray (geometries) {
      if (geometries === null) { return null }
      var geometryArray = new Array(geometries.size()).fill(null);
      return geometries.toArray(geometryArray)
    };
    GeometryFactory.getDefaultCoordinateSequenceFactory = function getDefaultCoordinateSequenceFactory () {
      return CoordinateArraySequenceFactory.instance()
    };
    GeometryFactory.toMultiLineStringArray = function toMultiLineStringArray (multiLineStrings) {
      var multiLineStringArray = new Array(multiLineStrings.size()).fill(null);
      return multiLineStrings.toArray(multiLineStringArray)
    };
    GeometryFactory.toLineStringArray = function toLineStringArray (lineStrings) {
      var lineStringArray = new Array(lineStrings.size()).fill(null);
      return lineStrings.toArray(lineStringArray)
    };
    GeometryFactory.toMultiPointArray = function toMultiPointArray (multiPoints) {
      var multiPointArray = new Array(multiPoints.size()).fill(null);
      return multiPoints.toArray(multiPointArray)
    };
    GeometryFactory.toLinearRingArray = function toLinearRingArray (linearRings) {
      var linearRingArray = new Array(linearRings.size()).fill(null);
      return linearRings.toArray(linearRingArray)
    };
    GeometryFactory.toPointArray = function toPointArray (points) {
      var pointArray = new Array(points.size()).fill(null);
      return points.toArray(pointArray)
    };
    GeometryFactory.toPolygonArray = function toPolygonArray (polygons) {
      var polygonArray = new Array(polygons.size()).fill(null);
      return polygons.toArray(polygonArray)
    };
    GeometryFactory.createPointFromInternalCoord = function createPointFromInternalCoord (coord, exemplar) {
      exemplar.getPrecisionModel().makePrecise(coord);
      return exemplar.getFactory().createPoint(coord)
    };
    staticAccessors$2.serialVersionUID.get = function () { return -6820524753094095635 };

    Object.defineProperties( GeometryFactory, staticAccessors$2 );

    var geometryTypes = ['Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon'];

    /**
     * Class for reading and writing Well-Known Text.Create a new parser for GeoJSON
     * NOTE: Adapted from OpenLayers 2.11 implementation.
     */

    /**
     * Create a new parser for GeoJSON
     *
     * @param {GeometryFactory} geometryFactory
     * @return An instance of GeoJsonParser.
     * @constructor
     * @private
     */
    var GeoJSONParser = function GeoJSONParser (geometryFactory) {
      this.geometryFactory = geometryFactory || new GeometryFactory();
    };
    /**
     * Deserialize a GeoJSON object and return the Geometry or Feature(Collection) with JSTS Geometries
     *
     * @param {}
     *        A GeoJSON object.
     * @return {} A Geometry instance or object representing a Feature(Collection) with Geometry instances.
     * @private
     */
    GeoJSONParser.prototype.read = function read (json) {
      var obj;
      if (typeof json === 'string') {
        obj = JSON.parse(json);
      } else {
        obj = json;
      }

      var type = obj.type;

      if (!parse[type]) {
        throw new Error('Unknown GeoJSON type: ' + obj.type)
      }

      if (geometryTypes.indexOf(type) !== -1) {
        return parse[type].apply(this, [obj.coordinates])
      } else if (type === 'GeometryCollection') {
        return parse[type].apply(this, [obj.geometries])
      }

      // feature or feature collection
      return parse[type].apply(this, [obj])
    };

    /**
     * Serialize a Geometry object into GeoJSON
     *
     * @param {Geometry}
     *        geometry A Geometry or array of Geometries.
     * @return {Object} A GeoJSON object represting the input Geometry/Geometries.
     * @private
     */
    GeoJSONParser.prototype.write = function write (geometry) {
      var type = geometry.getGeometryType();

      if (!extract[type]) {
        throw new Error('Geometry is not supported')
      }

      return extract[type].apply(this, [geometry])
    };

    var parse = {
      /**
       * Parse a GeoJSON Feature object
       *
       * @param {Object}
       *          obj Object to parse.
       *
       * @return {Object} Feature with geometry/bbox converted to JSTS Geometries.
       */
      Feature: function (obj) {
        var feature = {};

        // copy features
        for (var key in obj) {
          feature[key] = obj[key];
        }

        // parse geometry
        if (obj.geometry) {
          var type = obj.geometry.type;
          if (!parse[type]) {
            throw new Error('Unknown GeoJSON type: ' + obj.type)
          }
          feature.geometry = this.read(obj.geometry);
        }

        // bbox
        if (obj.bbox) {
          feature.bbox = parse.bbox.apply(this, [obj.bbox]);
        }

        return feature
      },

      /**
       * Parse a GeoJSON FeatureCollection object
       *
       * @param {Object}
       *          obj Object to parse.
       *
       * @return {Object} FeatureCollection with geometry/bbox converted to JSTS Geometries.
       */
      FeatureCollection: function (obj) {
        var this$1 = this;

        var featureCollection = {};

        if (obj.features) {
          featureCollection.features = [];

          for (var i = 0; i < obj.features.length; ++i) {
            featureCollection.features.push(this$1.read(obj.features[i]));
          }
        }

        if (obj.bbox) {
          featureCollection.bbox = this.parse.bbox.apply(this, [obj.bbox]);
        }

        return featureCollection
      },

      /**
       * Convert the ordinates in an array to an array of Coordinates
       *
       * @param {Array}
       *          array Array with {Number}s.
       *
       * @return {Array} Array with Coordinates.
       */
      coordinates: function (array) {
        var coordinates = [];
        for (var i = 0; i < array.length; ++i) {
          var sub = array[i];
          coordinates.push(new Coordinate(sub[0], sub[1]));
        }
        return coordinates
      },

      /**
       * Convert the bbox to a LinearRing
       *
       * @param {Array}
       *          array Array with [xMin, yMin, xMax, yMax].
       *
       * @return {Array} Array with Coordinates.
       */
      bbox: function (array) {
        return this.geometryFactory.createLinearRing([
          new Coordinate(array[0], array[1]),
          new Coordinate(array[2], array[1]),
          new Coordinate(array[2], array[3]),
          new Coordinate(array[0], array[3]),
          new Coordinate(array[0], array[1])
        ])
      },

      /**
       * Convert an Array with ordinates to a Point
       *
       * @param {Array}
       *          array Array with ordinates.
       *
       * @return {Point} Point.
       */
      Point: function (array) {
        var coordinate = new Coordinate(array[0], array[1]);
        return this.geometryFactory.createPoint(coordinate)
      },

      /**
       * Convert an Array with coordinates to a MultiPoint
       *
       * @param {Array}
       *          array Array with coordinates.
       *
       * @return {MultiPoint} MultiPoint.
       */
      MultiPoint: function (array) {
        var this$1 = this;

        var points = [];
        for (var i = 0; i < array.length; ++i) {
          points.push(parse.Point.apply(this$1, [array[i]]));
        }
        return this.geometryFactory.createMultiPoint(points)
      },

      /**
       * Convert an Array with coordinates to a LineString
       *
       * @param {Array}
       *          array Array with coordinates.
       *
       * @return {LineString} LineString.
       */
      LineString: function (array) {
        var coordinates = parse.coordinates.apply(this, [array]);
        return this.geometryFactory.createLineString(coordinates)
      },

      /**
       * Convert an Array with coordinates to a MultiLineString
       *
       * @param {Array}
       *          array Array with coordinates.
       *
       * @return {MultiLineString} MultiLineString.
       */
      MultiLineString: function (array) {
        var this$1 = this;

        var lineStrings = [];
        for (var i = 0; i < array.length; ++i) {
          lineStrings.push(parse.LineString.apply(this$1, [array[i]]));
        }
        return this.geometryFactory.createMultiLineString(lineStrings)
      },

      /**
       * Convert an Array to a Polygon
       *
       * @param {Array}
       *          array Array with shell and holes.
       *
       * @return {Polygon} Polygon.
       */
      Polygon: function (array) {
        var this$1 = this;

        var shellCoordinates = parse.coordinates.apply(this, [array[0]]);
        var shell = this.geometryFactory.createLinearRing(shellCoordinates);
        var holes = [];
        for (var i = 1; i < array.length; ++i) {
          var hole = array[i];
          var coordinates = parse.coordinates.apply(this$1, [hole]);
          var linearRing = this$1.geometryFactory.createLinearRing(coordinates);
          holes.push(linearRing);
        }
        return this.geometryFactory.createPolygon(shell, holes)
      },

      /**
       * Convert an Array to a MultiPolygon
       *
       * @param {Array}
       *          array Array of arrays with shell and rings.
       *
       * @return {MultiPolygon} MultiPolygon.
       */
      MultiPolygon: function (array) {
        var this$1 = this;

        var polygons = [];
        for (var i = 0; i < array.length; ++i) {
          var polygon = array[i];
          polygons.push(parse.Polygon.apply(this$1, [polygon]));
        }
        return this.geometryFactory.createMultiPolygon(polygons)
      },

      /**
       * Convert an Array to a GeometryCollection
       *
       * @param {Array}
       *          array Array of GeoJSON geometries.
       *
       * @return {GeometryCollection} GeometryCollection.
       */
      GeometryCollection: function (array) {
        var this$1 = this;

        var geometries = [];
        for (var i = 0; i < array.length; ++i) {
          var geometry = array[i];
          geometries.push(this$1.read(geometry));
        }
        return this.geometryFactory.createGeometryCollection(geometries)
      }
    };

    var extract = {
      /**
       * Convert a Coordinate to an Array
       *
       * @param {Coordinate}
       *          coordinate Coordinate to convert.
       *
       * @return {Array} Array of ordinates.
       */
      coordinate: function (coordinate) {
        return [coordinate.x, coordinate.y]
      },

      /**
       * Convert a Point to a GeoJSON object
       *
       * @param {Point}
       *          point Point to convert.
       *
       * @return {Array} Array of 2 ordinates (paired to a coordinate).
       */
      Point: function (point) {
        var array = extract.coordinate.apply(this, [point.getCoordinate()]);
        return {
          type: 'Point',
          coordinates: array
        }
      },

      /**
       * Convert a MultiPoint to a GeoJSON object
       *
       * @param {MultiPoint}
       *          multipoint MultiPoint to convert.
       *
       * @return {Array} Array of coordinates.
       */
      MultiPoint: function (multipoint) {
        var this$1 = this;

        var array = [];
        for (var i = 0; i < multipoint._geometries.length; ++i) {
          var point = multipoint._geometries[i];
          var geoJson = extract.Point.apply(this$1, [point]);
          array.push(geoJson.coordinates);
        }
        return {
          type: 'MultiPoint',
          coordinates: array
        }
      },

      /**
       * Convert a LineString to a GeoJSON object
       *
       * @param {LineString}
       *          linestring LineString to convert.
       *
       * @return {Array} Array of coordinates.
       */
      LineString: function (linestring) {
        var this$1 = this;

        var array = [];
        var coordinates = linestring.getCoordinates();
        for (var i = 0; i < coordinates.length; ++i) {
          var coordinate = coordinates[i];
          array.push(extract.coordinate.apply(this$1, [coordinate]));
        }
        return {
          type: 'LineString',
          coordinates: array
        }
      },

      /**
       * Convert a MultiLineString to a GeoJSON object
       *
       * @param {MultiLineString}
       *          multilinestring MultiLineString to convert.
       *
       * @return {Array} Array of Array of coordinates.
       */
      MultiLineString: function (multilinestring) {
        var this$1 = this;

        var array = [];
        for (var i = 0; i < multilinestring._geometries.length; ++i) {
          var linestring = multilinestring._geometries[i];
          var geoJson = extract.LineString.apply(this$1, [linestring]);
          array.push(geoJson.coordinates);
        }
        return {
          type: 'MultiLineString',
          coordinates: array
        }
      },

      /**
       * Convert a Polygon to a GeoJSON object
       *
       * @param {Polygon}
       *          polygon Polygon to convert.
       *
       * @return {Array} Array with shell, holes.
       */
      Polygon: function (polygon) {
        var this$1 = this;

        var array = [];
        var shellGeoJson = extract.LineString.apply(this, [polygon._shell]);
        array.push(shellGeoJson.coordinates);
        for (var i = 0; i < polygon._holes.length; ++i) {
          var hole = polygon._holes[i];
          var holeGeoJson = extract.LineString.apply(this$1, [hole]);
          array.push(holeGeoJson.coordinates);
        }
        return {
          type: 'Polygon',
          coordinates: array
        }
      },

      /**
       * Convert a MultiPolygon to a GeoJSON object
       *
       * @param {MultiPolygon}
       *          multipolygon MultiPolygon to convert.
       *
       * @return {Array} Array of polygons.
       */
      MultiPolygon: function (multipolygon) {
        var this$1 = this;

        var array = [];
        for (var i = 0; i < multipolygon._geometries.length; ++i) {
          var polygon = multipolygon._geometries[i];
          var geoJson = extract.Polygon.apply(this$1, [polygon]);
          array.push(geoJson.coordinates);
        }
        return {
          type: 'MultiPolygon',
          coordinates: array
        }
      },

      /**
       * Convert a GeometryCollection to a GeoJSON object
       *
       * @param {GeometryCollection}
       *          collection GeometryCollection to convert.
       *
       * @return {Array} Array of geometries.
       */
      GeometryCollection: function (collection) {
        var this$1 = this;

        var array = [];
        for (var i = 0; i < collection._geometries.length; ++i) {
          var geometry = collection._geometries[i];
          var type = geometry.getGeometryType();
          array.push(extract[type].apply(this$1, [geometry]));
        }
        return {
          type: 'GeometryCollection',
          geometries: array
        }
      }
    };

    /**
     * Converts a geometry in GeoJSON to a {@link Geometry}.
     */

    /**
     * A <code>GeoJSONReader</code> is parameterized by a <code>GeometryFactory</code>,
     * to allow it to create <code>Geometry</code> objects of the appropriate
     * implementation. In particular, the <code>GeometryFactory</code> determines
     * the <code>PrecisionModel</code> and <code>SRID</code> that is used.
     *
     * @param {GeometryFactory} geometryFactory
     * @constructor
     */
    var GeoJSONReader = function GeoJSONReader (geometryFactory) {
      this.geometryFactory = geometryFactory || new GeometryFactory();
      this.precisionModel = this.geometryFactory.getPrecisionModel();
      this.parser = new GeoJSONParser(this.geometryFactory);
    };
    /**
     * Reads a GeoJSON representation of a {@link Geometry}
     *
     * Will also parse GeoJSON Features/FeatureCollections as custom objects.
     *
     * @param {Object|String} geoJson a GeoJSON Object or String.
     * @return {Geometry|Object} a <code>Geometry or Feature/FeatureCollection representation.</code>
     * @memberof GeoJSONReader
     */
    GeoJSONReader.prototype.read = function read (geoJson) {
      var geometry = this.parser.read(geoJson);

      if (this.precisionModel.getType() === PrecisionModel.FIXED) {
        this.reducePrecision(geometry);
      }

      return geometry
    };

    // NOTE: this is a hack
    GeoJSONReader.prototype.reducePrecision = function reducePrecision (geometry) {
        var this$1 = this;

      var i, len;

      if (geometry.coordinate) {
        this.precisionModel.makePrecise(geometry.coordinate);
      } else if (geometry.points) {
        for (i = 0, len = geometry.points.length; i < len; i++) {
          this$1.precisionModel.makePrecise(geometry.points[i]);
        }
      } else if (geometry.geometries) {
        for (i = 0, len = geometry.geometries.length; i < len; i++) {
          this$1.reducePrecision(geometry.geometries[i]);
        }
      }
    };

    /**
     * @module GeoJSONWriter
     */

    /**
     * Writes the GeoJSON representation of a {@link Geometry}. The
     * The GeoJSON format is defined <A
     * HREF="http://geojson.org/geojson-spec.html">here</A>.
     */

    /**
     * The <code>GeoJSONWriter</code> outputs coordinates rounded to the precision
     * model. Only the maximum number of decimal places necessary to represent the
     * ordinates to the required precision will be output.
     *
     * @param {GeometryFactory} geometryFactory
     * @constructor
     */
    var GeoJSONWriter = function GeoJSONWriter () {
      this.parser = new GeoJSONParser(this.geometryFactory);
    };
    /**
     * Converts a <code>Geometry</code> to its GeoJSON representation.
     *
     * @param {Geometry}
     *        geometry a <code>Geometry</code> to process.
     * @return {Object} The GeoJSON representation of the Geometry.
     * @memberof GeoJSONWriter
     */
    GeoJSONWriter.prototype.write = function write (geometry) {
      return this.parser.write(geometry)
    };

    /* eslint-disable no-undef */

    // io

    var Position = function Position () {};

    var staticAccessors$20 = { ON: { configurable: true },LEFT: { configurable: true },RIGHT: { configurable: true } };

    Position.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Position.prototype.getClass = function getClass () {
      return Position
    };
    Position.opposite = function opposite (position) {
      if (position === Position.LEFT) { return Position.RIGHT }
      if (position === Position.RIGHT) { return Position.LEFT }
      return position
    };
    staticAccessors$20.ON.get = function () { return 0 };
    staticAccessors$20.LEFT.get = function () { return 1 };
    staticAccessors$20.RIGHT.get = function () { return 2 };

    Object.defineProperties( Position, staticAccessors$20 );

    /**
     * @param {string=} message Optional message
     * @extends {Error}
     * @constructor
     * @private
     */
    function EmptyStackException (message) {
      this.message = message || '';
    }
    EmptyStackException.prototype = new Error();

    /**
     * @type {string}
     */
    EmptyStackException.prototype.name = 'EmptyStackException';

    /**
     * @see http://download.oracle.com/javase/6/docs/api/java/util/Stack.html
     *
     * @extends {List}
     * @constructor
     * @private
     */
    function Stack () {
      /**
       * @type {Array}
       * @private
       */
      this.array_ = [];
    }
    Stack.prototype = new List();

    /**
     * @override
     */
    Stack.prototype.add = function (e) {
      this.array_.push(e);
      return true
    };

    /**
     * @override
     */
    Stack.prototype.get = function (index) {
      if (index < 0 || index >= this.size()) {
        throw new Error()
      }

      return this.array_[index]
    };

    /**
     * Pushes an item onto the top of this stack.
     * @param {Object} e
     * @return {Object}
     */
    Stack.prototype.push = function (e) {
      this.array_.push(e);
      return e
    };

    /**
     * Pushes an item onto the top of this stack.
     * @param {Object} e
     * @return {Object}
     */
    Stack.prototype.pop = function (e) {
      if (this.array_.length === 0) {
        throw new EmptyStackException()
      }

      return this.array_.pop()
    };

    /**
     * Looks at the object at the top of this stack without removing it from the
     * stack.
     * @return {Object}
     */
    Stack.prototype.peek = function () {
      if (this.array_.length === 0) {
        throw new EmptyStackException()
      }

      return this.array_[this.array_.length - 1]
    };

    /**
     * Tests if this stack is empty.
     * @return {boolean} true if and only if this stack contains no items; false
     *         otherwise.
     */
    Stack.prototype.empty = function () {
      if (this.array_.length === 0) {
        return true
      } else {
        return false
      }
    };

    /**
     * @return {boolean}
     */
    Stack.prototype.isEmpty = function () {
      return this.empty()
    };

    /**
     * Returns the 1-based position where an object is on this stack. If the object
     * o occurs as an item in this stack, this method returns the distance from the
     * top of the stack of the occurrence nearest the top of the stack; the topmost
     * item on the stack is considered to be at distance 1. The equals method is
     * used to compare o to the items in this stack.
     *
     * NOTE: does not currently actually use equals. (=== is used)
     *
     * @param {Object} o
     * @return {number} the 1-based position from the top of the stack where the
     *         object is located; the return value -1 indicates that the object is
     *         not on the stack.
     */
    Stack.prototype.search = function (o) {
      return this.array_.indexOf(o)
    };

    /**
     * @return {number}
     * @export
     */
    Stack.prototype.size = function () {
      return this.array_.length
    };

    /**
     * @return {Array}
     */
    Stack.prototype.toArray = function () {
      var this$1 = this;

      var array = [];

      for (var i = 0, len = this.array_.length; i < len; i++) {
        array.push(this$1.array_[i]);
      }

      return array
    };

    var RightmostEdgeFinder = function RightmostEdgeFinder () {
      this._minIndex = -1;
      this._minCoord = null;
      this._minDe = null;
      this._orientedDe = null;
    };
    RightmostEdgeFinder.prototype.getCoordinate = function getCoordinate () {
      return this._minCoord
    };
    RightmostEdgeFinder.prototype.getRightmostSide = function getRightmostSide (de, index) {
      var side = this.getRightmostSideOfSegment(de, index);
      if (side < 0) { side = this.getRightmostSideOfSegment(de, index - 1); }
      if (side < 0) {
        this._minCoord = null;
        this.checkForRightmostCoordinate(de);
      }
      return side
    };
    RightmostEdgeFinder.prototype.findRightmostEdgeAtVertex = function findRightmostEdgeAtVertex () {
      var pts = this._minDe.getEdge().getCoordinates();
      Assert.isTrue(this._minIndex > 0 && this._minIndex < pts.length, 'rightmost point expected to be interior vertex of edge');
      var pPrev = pts[this._minIndex - 1];
      var pNext = pts[this._minIndex + 1];
      var orientation = CGAlgorithms.computeOrientation(this._minCoord, pNext, pPrev);
      var usePrev = false;
      if (pPrev.y < this._minCoord.y && pNext.y < this._minCoord.y && orientation === CGAlgorithms.COUNTERCLOCKWISE) {
        usePrev = true;
      } else if (pPrev.y > this._minCoord.y && pNext.y > this._minCoord.y && orientation === CGAlgorithms.CLOCKWISE) {
        usePrev = true;
      }
      if (usePrev) {
        this._minIndex = this._minIndex - 1;
      }
    };
    RightmostEdgeFinder.prototype.getRightmostSideOfSegment = function getRightmostSideOfSegment (de, i) {
      var e = de.getEdge();
      var coord = e.getCoordinates();
      if (i < 0 || i + 1 >= coord.length) { return -1 }
      if (coord[i].y === coord[i + 1].y) { return -1 }
      var pos = Position.LEFT;
      if (coord[i].y < coord[i + 1].y) { pos = Position.RIGHT; }
      return pos
    };
    RightmostEdgeFinder.prototype.getEdge = function getEdge () {
      return this._orientedDe
    };
    RightmostEdgeFinder.prototype.checkForRightmostCoordinate = function checkForRightmostCoordinate (de) {
        var this$1 = this;

      var coord = de.getEdge().getCoordinates();
      for (var i = 0; i < coord.length - 1; i++) {
        if (this$1._minCoord === null || coord[i].x > this$1._minCoord.x) {
          this$1._minDe = de;
          this$1._minIndex = i;
          this$1._minCoord = coord[i];
        }
      }
    };
    RightmostEdgeFinder.prototype.findRightmostEdgeAtNode = function findRightmostEdgeAtNode () {
      var node = this._minDe.getNode();
      var star = node.getEdges();
      this._minDe = star.getRightmostEdge();
      if (!this._minDe.isForward()) {
        this._minDe = this._minDe.getSym();
        this._minIndex = this._minDe.getEdge().getCoordinates().length - 1;
      }
    };
    RightmostEdgeFinder.prototype.findEdge = function findEdge (dirEdgeList) {
        var this$1 = this;

      for (var i = dirEdgeList.iterator(); i.hasNext();) {
        var de = i.next();
        if (!de.isForward()) { continue }
        this$1.checkForRightmostCoordinate(de);
      }
      Assert.isTrue(this._minIndex !== 0 || this._minCoord.equals(this._minDe.getCoordinate()), 'inconsistency in rightmost processing');
      if (this._minIndex === 0) {
        this.findRightmostEdgeAtNode();
      } else {
        this.findRightmostEdgeAtVertex();
      }
      this._orientedDe = this._minDe;
      var rightmostSide = this.getRightmostSide(this._minDe, this._minIndex);
      if (rightmostSide === Position.LEFT) {
        this._orientedDe = this._minDe.getSym();
      }
    };
    RightmostEdgeFinder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    RightmostEdgeFinder.prototype.getClass = function getClass () {
      return RightmostEdgeFinder
    };

    var TopologyException = (function (RuntimeException$$1) {
      function TopologyException (msg, pt) {
        RuntimeException$$1.call(this, TopologyException.msgWithCoord(msg, pt));
        this.pt = pt ? new Coordinate(pt) : null;
        this.name = 'TopologyException';
      }

      if ( RuntimeException$$1 ) TopologyException.__proto__ = RuntimeException$$1;
      TopologyException.prototype = Object.create( RuntimeException$$1 && RuntimeException$$1.prototype );
      TopologyException.prototype.constructor = TopologyException;
      TopologyException.prototype.getCoordinate = function getCoordinate () {
        return this.pt
      };
      TopologyException.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      TopologyException.prototype.getClass = function getClass () {
        return TopologyException
      };
      TopologyException.msgWithCoord = function msgWithCoord (msg, pt) {
        if (!pt) { return msg + ' [ ' + pt + ' ]' }
        return msg
      };

      return TopologyException;
    }(RuntimeException));

    var LinkedList = function LinkedList () {
      this.array_ = [];
    };
    LinkedList.prototype.addLast = function addLast (e) {
      this.array_.push(e);
    };
    LinkedList.prototype.removeFirst = function removeFirst () {
      return this.array_.shift()
    };
    LinkedList.prototype.isEmpty = function isEmpty () {
      return this.array_.length === 0
    };

    var BufferSubgraph = function BufferSubgraph () {
      this._finder = null;
      this._dirEdgeList = new ArrayList();
      this._nodes = new ArrayList();
      this._rightMostCoord = null;
      this._env = null;
      this._finder = new RightmostEdgeFinder();
    };
    BufferSubgraph.prototype.clearVisitedEdges = function clearVisitedEdges () {
      for (var it = this._dirEdgeList.iterator(); it.hasNext();) {
        var de = it.next();
        de.setVisited(false);
      }
    };
    BufferSubgraph.prototype.getRightmostCoordinate = function getRightmostCoordinate () {
      return this._rightMostCoord
    };
    BufferSubgraph.prototype.computeNodeDepth = function computeNodeDepth (n) {
        var this$1 = this;

      var startEdge = null;
      for (var i = n.getEdges().iterator(); i.hasNext();) {
        var de = i.next();
        if (de.isVisited() || de.getSym().isVisited()) {
          startEdge = de;
          break
        }
      }
      if (startEdge === null) { throw new TopologyException('unable to find edge to compute depths at ' + n.getCoordinate()) }
      n.getEdges().computeDepths(startEdge);
      for (var i$1 = n.getEdges().iterator(); i$1.hasNext();) {
        var de$1 = i$1.next();
        de$1.setVisited(true);
        this$1.copySymDepths(de$1);
      }
    };
    BufferSubgraph.prototype.computeDepth = function computeDepth (outsideDepth) {
      this.clearVisitedEdges();
      var de = this._finder.getEdge();
      // const n = de.getNode()
      // const label = de.getLabel()
      de.setEdgeDepths(Position.RIGHT, outsideDepth);
      this.copySymDepths(de);
      this.computeDepths(de);
    };
    BufferSubgraph.prototype.create = function create (node) {
      this.addReachable(node);
      this._finder.findEdge(this._dirEdgeList);
      this._rightMostCoord = this._finder.getCoordinate();
    };
    BufferSubgraph.prototype.findResultEdges = function findResultEdges () {
      for (var it = this._dirEdgeList.iterator(); it.hasNext();) {
        var de = it.next();
        if (de.getDepth(Position.RIGHT) >= 1 && de.getDepth(Position.LEFT) <= 0 && !de.isInteriorAreaEdge()) {
          de.setInResult(true);
        }
      }
    };
    BufferSubgraph.prototype.computeDepths = function computeDepths (startEdge) {
        var this$1 = this;

      var nodesVisited = new HashSet();
      var nodeQueue = new LinkedList();
      var startNode = startEdge.getNode();
      nodeQueue.addLast(startNode);
      nodesVisited.add(startNode);
      startEdge.setVisited(true);
      while (!nodeQueue.isEmpty()) {
        var n = nodeQueue.removeFirst();
        nodesVisited.add(n);
        this$1.computeNodeDepth(n);
        for (var i = n.getEdges().iterator(); i.hasNext();) {
          var de = i.next();
          var sym = de.getSym();
          if (sym.isVisited()) { continue }
          var adjNode = sym.getNode();
          if (!nodesVisited.contains(adjNode)) {
            nodeQueue.addLast(adjNode);
            nodesVisited.add(adjNode);
          }
        }
      }
    };
    BufferSubgraph.prototype.compareTo = function compareTo (o) {
      var graph = o;
      if (this._rightMostCoord.x < graph._rightMostCoord.x) {
        return -1
      }
      if (this._rightMostCoord.x > graph._rightMostCoord.x) {
        return 1
      }
      return 0
    };
    BufferSubgraph.prototype.getEnvelope = function getEnvelope () {
      if (this._env === null) {
        var edgeEnv = new Envelope();
        for (var it = this._dirEdgeList.iterator(); it.hasNext();) {
          var dirEdge = it.next();
          var pts = dirEdge.getEdge().getCoordinates();
          for (var i = 0; i < pts.length - 1; i++) {
            edgeEnv.expandToInclude(pts[i]);
          }
        }
        this._env = edgeEnv;
      }
      return this._env
    };
    BufferSubgraph.prototype.addReachable = function addReachable (startNode) {
        var this$1 = this;

      var nodeStack = new Stack();
      nodeStack.add(startNode);
      while (!nodeStack.empty()) {
        var node = nodeStack.pop();
        this$1.add(node, nodeStack);
      }
    };
    BufferSubgraph.prototype.copySymDepths = function copySymDepths (de) {
      var sym = de.getSym();
      sym.setDepth(Position.LEFT, de.getDepth(Position.RIGHT));
      sym.setDepth(Position.RIGHT, de.getDepth(Position.LEFT));
    };
    BufferSubgraph.prototype.add = function add (node, nodeStack) {
        var this$1 = this;

      node.setVisited(true);
      this._nodes.add(node);
      for (var i = node.getEdges().iterator(); i.hasNext();) {
        var de = i.next();
        this$1._dirEdgeList.add(de);
        var sym = de.getSym();
        var symNode = sym.getNode();
        if (!symNode.isVisited()) { nodeStack.push(symNode); }
      }
    };
    BufferSubgraph.prototype.getNodes = function getNodes () {
      return this._nodes
    };
    BufferSubgraph.prototype.getDirectedEdges = function getDirectedEdges () {
      return this._dirEdgeList
    };
    BufferSubgraph.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    BufferSubgraph.prototype.getClass = function getClass () {
      return BufferSubgraph
    };

    var TopologyLocation = function TopologyLocation () {
      var this$1 = this;

      this.location = null;
      if (arguments.length === 1) {
        if (arguments[0] instanceof Array) {
          var location = arguments[0];
          this.init(location.length);
        } else if (Number.isInteger(arguments[0])) {
          var on = arguments[0];
          this.init(1);
          this.location[Position.ON] = on;
        } else if (arguments[0] instanceof TopologyLocation) {
          var gl = arguments[0];
          this.init(gl.location.length);
          if (gl !== null) {
            for (var i = 0; i < this.location.length; i++) {
              this$1.location[i] = gl.location[i];
            }
          }
        }
      } else if (arguments.length === 3) {
        var on$1 = arguments[0];
        var left = arguments[1];
        var right = arguments[2];
        this.init(3);
        this.location[Position.ON] = on$1;
        this.location[Position.LEFT] = left;
        this.location[Position.RIGHT] = right;
      }
    };
    TopologyLocation.prototype.setAllLocations = function setAllLocations (locValue) {
        var this$1 = this;

      for (var i = 0; i < this.location.length; i++) {
        this$1.location[i] = locValue;
      }
    };
    TopologyLocation.prototype.isNull = function isNull () {
        var this$1 = this;

      for (var i = 0; i < this.location.length; i++) {
        if (this$1.location[i] !== Location.NONE) { return false }
      }
      return true
    };
    TopologyLocation.prototype.setAllLocationsIfNull = function setAllLocationsIfNull (locValue) {
        var this$1 = this;

      for (var i = 0; i < this.location.length; i++) {
        if (this$1.location[i] === Location.NONE) { this$1.location[i] = locValue; }
      }
    };
    TopologyLocation.prototype.isLine = function isLine () {
      return this.location.length === 1
    };
    TopologyLocation.prototype.merge = function merge (gl) {
        var this$1 = this;

      if (gl.location.length > this.location.length) {
        var newLoc = new Array(3).fill(null);
        newLoc[Position.ON] = this.location[Position.ON];
        newLoc[Position.LEFT] = Location.NONE;
        newLoc[Position.RIGHT] = Location.NONE;
        this.location = newLoc;
      }
      for (var i = 0; i < this.location.length; i++) {
        if (this$1.location[i] === Location.NONE && i < gl.location.length) { this$1.location[i] = gl.location[i]; }
      }
    };
    TopologyLocation.prototype.getLocations = function getLocations () {
      return this.location
    };
    TopologyLocation.prototype.flip = function flip () {
      if (this.location.length <= 1) { return null }
      var temp = this.location[Position.LEFT];
      this.location[Position.LEFT] = this.location[Position.RIGHT];
      this.location[Position.RIGHT] = temp;
    };
    TopologyLocation.prototype.toString = function toString () {
      var buf = new StringBuffer();
      if (this.location.length > 1) { buf.append(Location.toLocationSymbol(this.location[Position.LEFT])); }
      buf.append(Location.toLocationSymbol(this.location[Position.ON]));
      if (this.location.length > 1) { buf.append(Location.toLocationSymbol(this.location[Position.RIGHT])); }
      return buf.toString()
    };
    TopologyLocation.prototype.setLocations = function setLocations (on, left, right) {
      this.location[Position.ON] = on;
      this.location[Position.LEFT] = left;
      this.location[Position.RIGHT] = right;
    };
    TopologyLocation.prototype.get = function get (posIndex) {
      if (posIndex < this.location.length) { return this.location[posIndex] }
      return Location.NONE
    };
    TopologyLocation.prototype.isArea = function isArea () {
      return this.location.length > 1
    };
    TopologyLocation.prototype.isAnyNull = function isAnyNull () {
        var this$1 = this;

      for (var i = 0; i < this.location.length; i++) {
        if (this$1.location[i] === Location.NONE) { return true }
      }
      return false
    };
    TopologyLocation.prototype.setLocation = function setLocation () {
      if (arguments.length === 1) {
        var locValue = arguments[0];
        this.setLocation(Position.ON, locValue);
      } else if (arguments.length === 2) {
        var locIndex = arguments[0];
        var locValue$1 = arguments[1];
        this.location[locIndex] = locValue$1;
      }
    };
    TopologyLocation.prototype.init = function init (size) {
      this.location = new Array(size).fill(null);
      this.setAllLocations(Location.NONE);
    };
    TopologyLocation.prototype.isEqualOnSide = function isEqualOnSide (le, locIndex) {
      return this.location[locIndex] === le.location[locIndex]
    };
    TopologyLocation.prototype.allPositionsEqual = function allPositionsEqual (loc) {
        var this$1 = this;

      for (var i = 0; i < this.location.length; i++) {
        if (this$1.location[i] !== loc) { return false }
      }
      return true
    };
    TopologyLocation.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    TopologyLocation.prototype.getClass = function getClass () {
      return TopologyLocation
    };

    var Label = function Label () {
      this.elt = new Array(2).fill(null);
      if (arguments.length === 1) {
        if (Number.isInteger(arguments[0])) {
          var onLoc = arguments[0];
          this.elt[0] = new TopologyLocation(onLoc);
          this.elt[1] = new TopologyLocation(onLoc);
        } else if (arguments[0] instanceof Label) {
          var lbl = arguments[0];
          this.elt[0] = new TopologyLocation(lbl.elt[0]);
          this.elt[1] = new TopologyLocation(lbl.elt[1]);
        }
      } else if (arguments.length === 2) {
        var geomIndex = arguments[0];
        var onLoc$1 = arguments[1];
        this.elt[0] = new TopologyLocation(Location.NONE);
        this.elt[1] = new TopologyLocation(Location.NONE);
        this.elt[geomIndex].setLocation(onLoc$1);
      } else if (arguments.length === 3) {
        var onLoc$2 = arguments[0];
        var leftLoc = arguments[1];
        var rightLoc = arguments[2];
        this.elt[0] = new TopologyLocation(onLoc$2, leftLoc, rightLoc);
        this.elt[1] = new TopologyLocation(onLoc$2, leftLoc, rightLoc);
      } else if (arguments.length === 4) {
        var geomIndex$1 = arguments[0];
        var onLoc$3 = arguments[1];
        var leftLoc$1 = arguments[2];
        var rightLoc$1 = arguments[3];
        this.elt[0] = new TopologyLocation(Location.NONE, Location.NONE, Location.NONE);
        this.elt[1] = new TopologyLocation(Location.NONE, Location.NONE, Location.NONE);
        this.elt[geomIndex$1].setLocations(onLoc$3, leftLoc$1, rightLoc$1);
      }
    };
    Label.prototype.getGeometryCount = function getGeometryCount () {
      var count = 0;
      if (!this.elt[0].isNull()) { count++; }
      if (!this.elt[1].isNull()) { count++; }
      return count
    };
    Label.prototype.setAllLocations = function setAllLocations (geomIndex, location) {
      this.elt[geomIndex].setAllLocations(location);
    };
    Label.prototype.isNull = function isNull (geomIndex) {
      return this.elt[geomIndex].isNull()
    };
    Label.prototype.setAllLocationsIfNull = function setAllLocationsIfNull () {
      if (arguments.length === 1) {
        var location = arguments[0];
        this.setAllLocationsIfNull(0, location);
        this.setAllLocationsIfNull(1, location);
      } else if (arguments.length === 2) {
        var geomIndex = arguments[0];
        var location$1 = arguments[1];
        this.elt[geomIndex].setAllLocationsIfNull(location$1);
      }
    };
    Label.prototype.isLine = function isLine (geomIndex) {
      return this.elt[geomIndex].isLine()
    };
    Label.prototype.merge = function merge (lbl) {
        var this$1 = this;

      for (var i = 0; i < 2; i++) {
        if (this$1.elt[i] === null && lbl.elt[i] !== null) {
          this$1.elt[i] = new TopologyLocation(lbl.elt[i]);
        } else {
          this$1.elt[i].merge(lbl.elt[i]);
        }
      }
    };
    Label.prototype.flip = function flip () {
      this.elt[0].flip();
      this.elt[1].flip();
    };
    Label.prototype.getLocation = function getLocation () {
      if (arguments.length === 1) {
        var geomIndex = arguments[0];
        return this.elt[geomIndex].get(Position.ON)
      } else if (arguments.length === 2) {
        var geomIndex$1 = arguments[0];
        var posIndex = arguments[1];
        return this.elt[geomIndex$1].get(posIndex)
      }
    };
    Label.prototype.toString = function toString () {
      var buf = new StringBuffer();
      if (this.elt[0] !== null) {
        buf.append('A:');
        buf.append(this.elt[0].toString());
      }
      if (this.elt[1] !== null) {
        buf.append(' B:');
        buf.append(this.elt[1].toString());
      }
      return buf.toString()
    };
    Label.prototype.isArea = function isArea () {
      if (arguments.length === 0) {
        return this.elt[0].isArea() || this.elt[1].isArea()
      } else if (arguments.length === 1) {
        var geomIndex = arguments[0];
        return this.elt[geomIndex].isArea()
      }
    };
    Label.prototype.isAnyNull = function isAnyNull (geomIndex) {
      return this.elt[geomIndex].isAnyNull()
    };
    Label.prototype.setLocation = function setLocation () {
      if (arguments.length === 2) {
        var geomIndex = arguments[0];
        var location = arguments[1];
        this.elt[geomIndex].setLocation(Position.ON, location);
      } else if (arguments.length === 3) {
        var geomIndex$1 = arguments[0];
        var posIndex = arguments[1];
        var location$1 = arguments[2];
        this.elt[geomIndex$1].setLocation(posIndex, location$1);
      }
    };
    Label.prototype.isEqualOnSide = function isEqualOnSide (lbl, side) {
      return this.elt[0].isEqualOnSide(lbl.elt[0], side) && this.elt[1].isEqualOnSide(lbl.elt[1], side)
    };
    Label.prototype.allPositionsEqual = function allPositionsEqual (geomIndex, loc) {
      return this.elt[geomIndex].allPositionsEqual(loc)
    };
    Label.prototype.toLine = function toLine (geomIndex) {
      if (this.elt[geomIndex].isArea()) { this.elt[geomIndex] = new TopologyLocation(this.elt[geomIndex].location[0]); }
    };
    Label.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Label.prototype.getClass = function getClass () {
      return Label
    };
    Label.toLineLabel = function toLineLabel (label) {
      var lineLabel = new Label(Location.NONE);
      for (var i = 0; i < 2; i++) {
        lineLabel.setLocation(i, label.getLocation(i));
      }
      return lineLabel
    };

    var EdgeRing$1 = function EdgeRing () {
      this._startDe = null;
      this._maxNodeDegree = -1;
      this._edges = new ArrayList();
      this._pts = new ArrayList();
      this._label = new Label(Location.NONE);
      this._ring = null;
      this._isHole = null;
      this._shell = null;
      this._holes = new ArrayList();
      this._geometryFactory = null;
      var start = arguments[0];
      var geometryFactory = arguments[1];
      this._geometryFactory = geometryFactory;
      this.computePoints(start);
      this.computeRing();
    };
    EdgeRing$1.prototype.computeRing = function computeRing () {
        var this$1 = this;

      if (this._ring !== null) { return null }
      var coord = new Array(this._pts.size()).fill(null);
      for (var i = 0; i < this._pts.size(); i++) {
        coord[i] = this$1._pts.get(i);
      }
      this._ring = this._geometryFactory.createLinearRing(coord);
      this._isHole = CGAlgorithms.isCCW(this._ring.getCoordinates());
    };
    EdgeRing$1.prototype.isIsolated = function isIsolated () {
      return this._label.getGeometryCount() === 1
    };
    EdgeRing$1.prototype.computePoints = function computePoints (start) {
        var this$1 = this;

      this._startDe = start;
      var de = start;
      var isFirstEdge = true;
      do {
        if (de === null) { throw new TopologyException('Found null DirectedEdge') }
        if (de.getEdgeRing() === this$1) { throw new TopologyException('Directed Edge visited twice during ring-building at ' + de.getCoordinate()) }
        this$1._edges.add(de);
        var label = de.getLabel();
        Assert.isTrue(label.isArea());
        this$1.mergeLabel(label);
        this$1.addPoints(de.getEdge(), de.isForward(), isFirstEdge);
        isFirstEdge = false;
        this$1.setEdgeRing(de, this$1);
        de = this$1.getNext(de);
      } while (de !== this._startDe)
    };
    EdgeRing$1.prototype.getLinearRing = function getLinearRing () {
      return this._ring
    };
    EdgeRing$1.prototype.getCoordinate = function getCoordinate (i) {
      return this._pts.get(i)
    };
    EdgeRing$1.prototype.computeMaxNodeDegree = function computeMaxNodeDegree () {
        var this$1 = this;

      this._maxNodeDegree = 0;
      var de = this._startDe;
      do {
        var node = de.getNode();
        var degree = node.getEdges().getOutgoingDegree(this$1);
        if (degree > this$1._maxNodeDegree) { this$1._maxNodeDegree = degree; }
        de = this$1.getNext(de);
      } while (de !== this._startDe)
      this._maxNodeDegree *= 2;
    };
    EdgeRing$1.prototype.addPoints = function addPoints (edge, isForward, isFirstEdge) {
        var this$1 = this;

      var edgePts = edge.getCoordinates();
      if (isForward) {
        var startIndex = 1;
        if (isFirstEdge) { startIndex = 0; }
        for (var i = startIndex; i < edgePts.length; i++) {
          this$1._pts.add(edgePts[i]);
        }
      } else {
        var startIndex$1 = edgePts.length - 2;
        if (isFirstEdge) { startIndex$1 = edgePts.length - 1; }
        for (var i$1 = startIndex$1; i$1 >= 0; i$1--) {
          this$1._pts.add(edgePts[i$1]);
        }
      }
    };
    EdgeRing$1.prototype.isHole = function isHole () {
      return this._isHole
    };
    EdgeRing$1.prototype.setInResult = function setInResult () {
      var de = this._startDe;
      do {
        de.getEdge().setInResult(true);
        de = de.getNext();
      } while (de !== this._startDe)
    };
    EdgeRing$1.prototype.containsPoint = function containsPoint (p) {
      var shell = this.getLinearRing();
      var env = shell.getEnvelopeInternal();
      if (!env.contains(p)) { return false }
      if (!CGAlgorithms.isPointInRing(p, shell.getCoordinates())) { return false }
      for (var i = this._holes.iterator(); i.hasNext();) {
        var hole = i.next();
        if (hole.containsPoint(p)) { return false }
      }
      return true
    };
    EdgeRing$1.prototype.addHole = function addHole (ring) {
      this._holes.add(ring);
    };
    EdgeRing$1.prototype.isShell = function isShell () {
      return this._shell === null
    };
    EdgeRing$1.prototype.getLabel = function getLabel () {
      return this._label
    };
    EdgeRing$1.prototype.getEdges = function getEdges () {
      return this._edges
    };
    EdgeRing$1.prototype.getMaxNodeDegree = function getMaxNodeDegree () {
      if (this._maxNodeDegree < 0) { this.computeMaxNodeDegree(); }
      return this._maxNodeDegree
    };
    EdgeRing$1.prototype.getShell = function getShell () {
      return this._shell
    };
    EdgeRing$1.prototype.mergeLabel = function mergeLabel () {
      if (arguments.length === 1) {
        var deLabel = arguments[0];
        this.mergeLabel(deLabel, 0);
        this.mergeLabel(deLabel, 1);
      } else if (arguments.length === 2) {
        var deLabel$1 = arguments[0];
        var geomIndex = arguments[1];
        var loc = deLabel$1.getLocation(geomIndex, Position.RIGHT);
        if (loc === Location.NONE) { return null }
        if (this._label.getLocation(geomIndex) === Location.NONE) {
          this._label.setLocation(geomIndex, loc);
          return null
        }
      }
    };
    EdgeRing$1.prototype.setShell = function setShell (shell) {
      this._shell = shell;
      if (shell !== null) { shell.addHole(this); }
    };
    EdgeRing$1.prototype.toPolygon = function toPolygon (geometryFactory) {
        var this$1 = this;

      var holeLR = new Array(this._holes.size()).fill(null);
      for (var i = 0; i < this._holes.size(); i++) {
        holeLR[i] = this$1._holes.get(i).getLinearRing();
      }
      var poly = geometryFactory.createPolygon(this.getLinearRing(), holeLR);
      return poly
    };
    EdgeRing$1.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeRing$1.prototype.getClass = function getClass () {
      return EdgeRing$1
    };

    var MinimalEdgeRing = (function (EdgeRing$$1) {
      function MinimalEdgeRing () {
        var start = arguments[0];
        var geometryFactory = arguments[1];
        EdgeRing$$1.call(this, start, geometryFactory);
      }

      if ( EdgeRing$$1 ) MinimalEdgeRing.__proto__ = EdgeRing$$1;
      MinimalEdgeRing.prototype = Object.create( EdgeRing$$1 && EdgeRing$$1.prototype );
      MinimalEdgeRing.prototype.constructor = MinimalEdgeRing;
      MinimalEdgeRing.prototype.setEdgeRing = function setEdgeRing (de, er) {
        de.setMinEdgeRing(er);
      };
      MinimalEdgeRing.prototype.getNext = function getNext (de) {
        return de.getNextMin()
      };
      MinimalEdgeRing.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      MinimalEdgeRing.prototype.getClass = function getClass () {
        return MinimalEdgeRing
      };

      return MinimalEdgeRing;
    }(EdgeRing$1));

    var MaximalEdgeRing = (function (EdgeRing$$1) {
      function MaximalEdgeRing () {
        var start = arguments[0];
        var geometryFactory = arguments[1];
        EdgeRing$$1.call(this, start, geometryFactory);
      }

      if ( EdgeRing$$1 ) MaximalEdgeRing.__proto__ = EdgeRing$$1;
      MaximalEdgeRing.prototype = Object.create( EdgeRing$$1 && EdgeRing$$1.prototype );
      MaximalEdgeRing.prototype.constructor = MaximalEdgeRing;
      MaximalEdgeRing.prototype.buildMinimalRings = function buildMinimalRings () {
        var this$1 = this;

        var minEdgeRings = new ArrayList();
        var de = this._startDe;
        do {
          if (de.getMinEdgeRing() === null) {
            var minEr = new MinimalEdgeRing(de, this$1._geometryFactory);
            minEdgeRings.add(minEr);
          }
          de = de.getNext();
        } while (de !== this._startDe)
        return minEdgeRings
      };
      MaximalEdgeRing.prototype.setEdgeRing = function setEdgeRing (de, er) {
        de.setEdgeRing(er);
      };
      MaximalEdgeRing.prototype.linkDirectedEdgesForMinimalEdgeRings = function linkDirectedEdgesForMinimalEdgeRings () {
        var this$1 = this;

        var de = this._startDe;
        do {
          var node = de.getNode();
          node.getEdges().linkMinimalDirectedEdges(this$1);
          de = de.getNext();
        } while (de !== this._startDe)
      };
      MaximalEdgeRing.prototype.getNext = function getNext (de) {
        return de.getNext()
      };
      MaximalEdgeRing.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      MaximalEdgeRing.prototype.getClass = function getClass () {
        return MaximalEdgeRing
      };

      return MaximalEdgeRing;
    }(EdgeRing$1));

    var GraphComponent = function GraphComponent () {
      this._label = null;
      this._isInResult = false;
      this._isCovered = false;
      this._isCoveredSet = false;
      this._isVisited = false;
      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var label = arguments[0];
        this._label = label;
      }
    };
    GraphComponent.prototype.setVisited = function setVisited (isVisited) {
      this._isVisited = isVisited;
    };
    GraphComponent.prototype.setInResult = function setInResult (isInResult) {
      this._isInResult = isInResult;
    };
    GraphComponent.prototype.isCovered = function isCovered () {
      return this._isCovered
    };
    GraphComponent.prototype.isCoveredSet = function isCoveredSet () {
      return this._isCoveredSet
    };
    GraphComponent.prototype.setLabel = function setLabel (label) {
      this._label = label;
    };
    GraphComponent.prototype.getLabel = function getLabel () {
      return this._label
    };
    GraphComponent.prototype.setCovered = function setCovered (isCovered) {
      this._isCovered = isCovered;
      this._isCoveredSet = true;
    };
    GraphComponent.prototype.updateIM = function updateIM (im) {
      Assert.isTrue(this._label.getGeometryCount() >= 2, 'found partial label');
      this.computeIM(im);
    };
    GraphComponent.prototype.isInResult = function isInResult () {
      return this._isInResult
    };
    GraphComponent.prototype.isVisited = function isVisited () {
      return this._isVisited
    };
    GraphComponent.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GraphComponent.prototype.getClass = function getClass () {
      return GraphComponent
    };

    var Node$3 = (function (GraphComponent$$1) {
      function Node () {
        GraphComponent$$1.call(this);
        this._coord = null;
        this._edges = null;
        var coord = arguments[0];
        var edges = arguments[1];
        this._coord = coord;
        this._edges = edges;
        this._label = new Label(0, Location.NONE);
      }

      if ( GraphComponent$$1 ) Node.__proto__ = GraphComponent$$1;
      Node.prototype = Object.create( GraphComponent$$1 && GraphComponent$$1.prototype );
      Node.prototype.constructor = Node;
      Node.prototype.isIncidentEdgeInResult = function isIncidentEdgeInResult () {
        for (var it = this.getEdges().getEdges().iterator(); it.hasNext();) {
          var de = it.next();
          if (de.getEdge().isInResult()) { return true }
        }
        return false
      };
      Node.prototype.isIsolated = function isIsolated () {
        return this._label.getGeometryCount() === 1
      };
      Node.prototype.getCoordinate = function getCoordinate () {
        return this._coord
      };
      Node.prototype.print = function print (out) {
        out.println('node ' + this._coord + ' lbl: ' + this._label);
      };
      Node.prototype.computeIM = function computeIM (im) {};
      Node.prototype.computeMergedLocation = function computeMergedLocation (label2, eltIndex) {
        var loc = Location.NONE;
        loc = this._label.getLocation(eltIndex);
        if (!label2.isNull(eltIndex)) {
          var nLoc = label2.getLocation(eltIndex);
          if (loc !== Location.BOUNDARY) { loc = nLoc; }
        }
        return loc
      };
      Node.prototype.setLabel = function setLabel () {
        if (arguments.length === 2) {
          var argIndex = arguments[0];
          var onLocation = arguments[1];
          if (this._label === null) {
            this._label = new Label(argIndex, onLocation);
          } else { this._label.setLocation(argIndex, onLocation); }
        } else { return GraphComponent$$1.prototype.setLabel.apply(this, arguments) }
      };
      Node.prototype.getEdges = function getEdges () {
        return this._edges
      };
      Node.prototype.mergeLabel = function mergeLabel () {
        var this$1 = this;

        if (arguments[0] instanceof Node) {
          var n = arguments[0];
          this.mergeLabel(n._label);
        } else if (arguments[0] instanceof Label) {
          var label2 = arguments[0];
          for (var i = 0; i < 2; i++) {
            var loc = this$1.computeMergedLocation(label2, i);
            var thisLoc = this$1._label.getLocation(i);
            if (thisLoc === Location.NONE) { this$1._label.setLocation(i, loc); }
          }
        }
      };
      Node.prototype.add = function add (e) {
        this._edges.insert(e);
        e.setNode(this);
      };
      Node.prototype.setLabelBoundary = function setLabelBoundary (argIndex) {
        if (this._label === null) { return null }
        var loc = Location.NONE;
        if (this._label !== null) { loc = this._label.getLocation(argIndex); }
        var newLoc = null;
        switch (loc) {
          case Location.BOUNDARY:
            newLoc = Location.INTERIOR;
            break
          case Location.INTERIOR:
            newLoc = Location.BOUNDARY;
            break
          default:
            newLoc = Location.BOUNDARY;
            break
        }
        this._label.setLocation(argIndex, newLoc);
      };
      Node.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      Node.prototype.getClass = function getClass () {
        return Node
      };

      return Node;
    }(GraphComponent));

    var NodeMap = function NodeMap () {
      this.nodeMap = new TreeMap();
      this.nodeFact = null;
      var nodeFact = arguments[0];
      this.nodeFact = nodeFact;
    };
    NodeMap.prototype.find = function find (coord) {
      return this.nodeMap.get(coord)
    };
    NodeMap.prototype.addNode = function addNode () {
      if (arguments[0] instanceof Coordinate) {
        var coord = arguments[0];
        var node = this.nodeMap.get(coord);
        if (node === null) {
          node = this.nodeFact.createNode(coord);
          this.nodeMap.put(coord, node);
        }
        return node
      } else if (arguments[0] instanceof Node$3) {
        var n = arguments[0];
        var node$1 = this.nodeMap.get(n.getCoordinate());
        if (node$1 === null) {
          this.nodeMap.put(n.getCoordinate(), n);
          return n
        }
        node$1.mergeLabel(n);
        return node$1
      }
    };
    NodeMap.prototype.print = function print (out) {
      for (var it = this.iterator(); it.hasNext();) {
        var n = it.next();
        n.print(out);
      }
    };
    NodeMap.prototype.iterator = function iterator () {
      return this.nodeMap.values().iterator()
    };
    NodeMap.prototype.values = function values () {
      return this.nodeMap.values()
    };
    NodeMap.prototype.getBoundaryNodes = function getBoundaryNodes (geomIndex) {
      var bdyNodes = new ArrayList();
      for (var i = this.iterator(); i.hasNext();) {
        var node = i.next();
        if (node.getLabel().getLocation(geomIndex) === Location.BOUNDARY) { bdyNodes.add(node); }
      }
      return bdyNodes
    };
    NodeMap.prototype.add = function add (e) {
      var p = e.getCoordinate();
      var n = this.addNode(p);
      n.add(e);
    };
    NodeMap.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    NodeMap.prototype.getClass = function getClass () {
      return NodeMap
    };

    var Quadrant = function Quadrant () {};

    var staticAccessors$21 = { NE: { configurable: true },NW: { configurable: true },SW: { configurable: true },SE: { configurable: true } };

    Quadrant.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Quadrant.prototype.getClass = function getClass () {
      return Quadrant
    };
    Quadrant.isNorthern = function isNorthern (quad) {
      return quad === Quadrant.NE || quad === Quadrant.NW
    };
    Quadrant.isOpposite = function isOpposite (quad1, quad2) {
      if (quad1 === quad2) { return false }
      var diff = (quad1 - quad2 + 4) % 4;
      if (diff === 2) { return true }
      return false
    };
    Quadrant.commonHalfPlane = function commonHalfPlane (quad1, quad2) {
      if (quad1 === quad2) { return quad1 }
      var diff = (quad1 - quad2 + 4) % 4;
      if (diff === 2) { return -1 }
      var min = quad1 < quad2 ? quad1 : quad2;
      var max = quad1 > quad2 ? quad1 : quad2;
      if (min === 0 && max === 3) { return 3 }
      return min
    };
    Quadrant.isInHalfPlane = function isInHalfPlane (quad, halfPlane) {
      if (halfPlane === Quadrant.SE) {
        return quad === Quadrant.SE || quad === Quadrant.SW
      }
      return quad === halfPlane || quad === halfPlane + 1
    };
    Quadrant.quadrant = function quadrant () {
      if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
        var dx = arguments[0];
        var dy = arguments[1];
        if (dx === 0.0 && dy === 0.0) { throw new IllegalArgumentException('Cannot compute the quadrant for point ( ' + dx + ', ' + dy + ' )') }
        if (dx >= 0.0) {
          if (dy >= 0.0) { return Quadrant.NE; } else { return Quadrant.SE }
        } else {
          if (dy >= 0.0) { return Quadrant.NW; } else { return Quadrant.SW }
        }
      } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        if (p1.x === p0.x && p1.y === p0.y) { throw new IllegalArgumentException('Cannot compute the quadrant for two identical points ' + p0) }
        if (p1.x >= p0.x) {
          if (p1.y >= p0.y) { return Quadrant.NE; } else { return Quadrant.SE }
        } else {
          if (p1.y >= p0.y) { return Quadrant.NW; } else { return Quadrant.SW }
        }
      }
    };
    staticAccessors$21.NE.get = function () { return 0 };
    staticAccessors$21.NW.get = function () { return 1 };
    staticAccessors$21.SW.get = function () { return 2 };
    staticAccessors$21.SE.get = function () { return 3 };

    Object.defineProperties( Quadrant, staticAccessors$21 );

    var EdgeEnd = function EdgeEnd () {
      this._edge = null;
      this._label = null;
      this._node = null;
      this._p0 = null;
      this._p1 = null;
      this._dx = null;
      this._dy = null;
      this._quadrant = null;
      if (arguments.length === 1) {
        var edge = arguments[0];
        this._edge = edge;
      } else if (arguments.length === 3) {
        var edge$1 = arguments[0];
        var p0 = arguments[1];
        var p1 = arguments[2];
        var label = null;
        this._edge = edge$1;
        this.init(p0, p1);
        this._label = label;
      } else if (arguments.length === 4) {
        var edge$2 = arguments[0];
        var p0$1 = arguments[1];
        var p1$1 = arguments[2];
        var label$1 = arguments[3];
        this._edge = edge$2;
        this.init(p0$1, p1$1);
        this._label = label$1;
      }
    };
    EdgeEnd.prototype.compareDirection = function compareDirection (e) {
      if (this._dx === e._dx && this._dy === e._dy) { return 0 }
      if (this._quadrant > e._quadrant) { return 1 }
      if (this._quadrant < e._quadrant) { return -1 }
      return CGAlgorithms.computeOrientation(e._p0, e._p1, this._p1)
    };
    EdgeEnd.prototype.getDy = function getDy () {
      return this._dy
    };
    EdgeEnd.prototype.getCoordinate = function getCoordinate () {
      return this._p0
    };
    EdgeEnd.prototype.setNode = function setNode (node) {
      this._node = node;
    };
    EdgeEnd.prototype.print = function print (out) {
      var angle = Math.atan2(this._dy, this._dx);
      var className = this.getClass().getName();
      var lastDotPos = className.lastIndexOf('.');
      var name = className.substring(lastDotPos + 1);
      out.print('  ' + name + ': ' + this._p0 + ' - ' + this._p1 + ' ' + this._quadrant + ':' + angle + '   ' + this._label);
    };
    EdgeEnd.prototype.compareTo = function compareTo (obj) {
      var e = obj;
      return this.compareDirection(e)
    };
    EdgeEnd.prototype.getDirectedCoordinate = function getDirectedCoordinate () {
      return this._p1
    };
    EdgeEnd.prototype.getDx = function getDx () {
      return this._dx
    };
    EdgeEnd.prototype.getLabel = function getLabel () {
      return this._label
    };
    EdgeEnd.prototype.getEdge = function getEdge () {
      return this._edge
    };
    EdgeEnd.prototype.getQuadrant = function getQuadrant () {
      return this._quadrant
    };
    EdgeEnd.prototype.getNode = function getNode () {
      return this._node
    };
    EdgeEnd.prototype.toString = function toString () {
      var angle = Math.atan2(this._dy, this._dx);
      var className = this.getClass().getName();
      var lastDotPos = className.lastIndexOf('.');
      var name = className.substring(lastDotPos + 1);
      return '  ' + name + ': ' + this._p0 + ' - ' + this._p1 + ' ' + this._quadrant + ':' + angle + '   ' + this._label
    };
    EdgeEnd.prototype.computeLabel = function computeLabel (boundaryNodeRule) {};
    EdgeEnd.prototype.init = function init (p0, p1) {
      this._p0 = p0;
      this._p1 = p1;
      this._dx = p1.x - p0.x;
      this._dy = p1.y - p0.y;
      this._quadrant = Quadrant.quadrant(this._dx, this._dy);
      Assert.isTrue(!(this._dx === 0 && this._dy === 0), 'EdgeEnd with identical endpoints found');
    };
    EdgeEnd.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    EdgeEnd.prototype.getClass = function getClass () {
      return EdgeEnd
    };

    var DirectedEdge = (function (EdgeEnd$$1) {
      function DirectedEdge () {
        var edge = arguments[0];
        var isForward = arguments[1];
        EdgeEnd$$1.call(this, edge);
        this._isForward = null;
        this._isInResult = false;
        this._isVisited = false;
        this._sym = null;
        this._next = null;
        this._nextMin = null;
        this._edgeRing = null;
        this._minEdgeRing = null;
        this._depth = [0, -999, -999];
        this._isForward = isForward;
        if (isForward) {
          this.init(edge.getCoordinate(0), edge.getCoordinate(1));
        } else {
          var n = edge.getNumPoints() - 1;
          this.init(edge.getCoordinate(n), edge.getCoordinate(n - 1));
        }
        this.computeDirectedLabel();
      }

      if ( EdgeEnd$$1 ) DirectedEdge.__proto__ = EdgeEnd$$1;
      DirectedEdge.prototype = Object.create( EdgeEnd$$1 && EdgeEnd$$1.prototype );
      DirectedEdge.prototype.constructor = DirectedEdge;
      DirectedEdge.prototype.getNextMin = function getNextMin () {
        return this._nextMin
      };
      DirectedEdge.prototype.getDepth = function getDepth (position) {
        return this._depth[position]
      };
      DirectedEdge.prototype.setVisited = function setVisited (isVisited) {
        this._isVisited = isVisited;
      };
      DirectedEdge.prototype.computeDirectedLabel = function computeDirectedLabel () {
        this._label = new Label(this._edge.getLabel());
        if (!this._isForward) { this._label.flip(); }
      };
      DirectedEdge.prototype.getNext = function getNext () {
        return this._next
      };
      DirectedEdge.prototype.setDepth = function setDepth (position, depthVal) {
        if (this._depth[position] !== -999) {
          if (this._depth[position] !== depthVal) { throw new TopologyException('assigned depths do not match', this.getCoordinate()) }
        }
        this._depth[position] = depthVal;
      };
      DirectedEdge.prototype.isInteriorAreaEdge = function isInteriorAreaEdge () {
        var this$1 = this;

        var isInteriorAreaEdge = true;
        for (var i = 0; i < 2; i++) {
          if (!(this$1._label.isArea(i) && this$1._label.getLocation(i, Position.LEFT) === Location.INTERIOR && this$1._label.getLocation(i, Position.RIGHT) === Location.INTERIOR)) {
            isInteriorAreaEdge = false;
          }
        }
        return isInteriorAreaEdge
      };
      DirectedEdge.prototype.setNextMin = function setNextMin (nextMin) {
        this._nextMin = nextMin;
      };
      DirectedEdge.prototype.print = function print (out) {
        EdgeEnd$$1.prototype.print.call(this, out);
        out.print(' ' + this._depth[Position.LEFT] + '/' + this._depth[Position.RIGHT]);
        out.print(' (' + this.getDepthDelta() + ')');
        if (this._isInResult) { out.print(' inResult'); }
      };
      DirectedEdge.prototype.setMinEdgeRing = function setMinEdgeRing (minEdgeRing) {
        this._minEdgeRing = minEdgeRing;
      };
      DirectedEdge.prototype.isLineEdge = function isLineEdge () {
        var isLine = this._label.isLine(0) || this._label.isLine(1);
        var isExteriorIfArea0 = !this._label.isArea(0) || this._label.allPositionsEqual(0, Location.EXTERIOR);
        var isExteriorIfArea1 = !this._label.isArea(1) || this._label.allPositionsEqual(1, Location.EXTERIOR);
        return isLine && isExteriorIfArea0 && isExteriorIfArea1
      };
      DirectedEdge.prototype.setEdgeRing = function setEdgeRing (edgeRing) {
        this._edgeRing = edgeRing;
      };
      DirectedEdge.prototype.getMinEdgeRing = function getMinEdgeRing () {
        return this._minEdgeRing
      };
      DirectedEdge.prototype.getDepthDelta = function getDepthDelta () {
        var depthDelta = this._edge.getDepthDelta();
        if (!this._isForward) { depthDelta = -depthDelta; }
        return depthDelta
      };
      DirectedEdge.prototype.setInResult = function setInResult (isInResult) {
        this._isInResult = isInResult;
      };
      DirectedEdge.prototype.getSym = function getSym () {
        return this._sym
      };
      DirectedEdge.prototype.isForward = function isForward () {
        return this._isForward
      };
      DirectedEdge.prototype.getEdge = function getEdge () {
        return this._edge
      };
      DirectedEdge.prototype.printEdge = function printEdge (out) {
        this.print(out);
        out.print(' ');
        if (this._isForward) { this._edge.print(out); } else { this._edge.printReverse(out); }
      };
      DirectedEdge.prototype.setSym = function setSym (de) {
        this._sym = de;
      };
      DirectedEdge.prototype.setVisitedEdge = function setVisitedEdge (isVisited) {
        this.setVisited(isVisited);
        this._sym.setVisited(isVisited);
      };
      DirectedEdge.prototype.setEdgeDepths = function setEdgeDepths (position, depth) {
        var depthDelta = this.getEdge().getDepthDelta();
        if (!this._isForward) { depthDelta = -depthDelta; }
        var directionFactor = 1;
        if (position === Position.LEFT) { directionFactor = -1; }
        var oppositePos = Position.opposite(position);
        var delta = depthDelta * directionFactor;
        var oppositeDepth = depth + delta;
        this.setDepth(position, depth);
        this.setDepth(oppositePos, oppositeDepth);
      };
      DirectedEdge.prototype.getEdgeRing = function getEdgeRing () {
        return this._edgeRing
      };
      DirectedEdge.prototype.isInResult = function isInResult () {
        return this._isInResult
      };
      DirectedEdge.prototype.setNext = function setNext (next) {
        this._next = next;
      };
      DirectedEdge.prototype.isVisited = function isVisited () {
        return this._isVisited
      };
      DirectedEdge.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      DirectedEdge.prototype.getClass = function getClass () {
        return DirectedEdge
      };
      DirectedEdge.depthFactor = function depthFactor (currLocation, nextLocation) {
        if (currLocation === Location.EXTERIOR && nextLocation === Location.INTERIOR) { return 1; } else if (currLocation === Location.INTERIOR && nextLocation === Location.EXTERIOR) { return -1 }
        return 0
      };

      return DirectedEdge;
    }(EdgeEnd));

    var NodeFactory = function NodeFactory () {};

    NodeFactory.prototype.createNode = function createNode (coord) {
      return new Node$3(coord, null)
    };
    NodeFactory.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    NodeFactory.prototype.getClass = function getClass () {
      return NodeFactory
    };

    var PlanarGraph = function PlanarGraph () {
      this._edges = new ArrayList();
      this._nodes = null;
      this._edgeEndList = new ArrayList();
      if (arguments.length === 0) {
        this._nodes = new NodeMap(new NodeFactory());
      } else if (arguments.length === 1) {
        var nodeFact = arguments[0];
        this._nodes = new NodeMap(nodeFact);
      }
    };
    PlanarGraph.prototype.printEdges = function printEdges (out) {
        var this$1 = this;

      out.println('Edges:');
      for (var i = 0; i < this._edges.size(); i++) {
        out.println('edge ' + i + ':');
        var e = this$1._edges.get(i);
        e.print(out);
        e.eiList.print(out);
      }
    };
    PlanarGraph.prototype.find = function find (coord) {
      return this._nodes.find(coord)
    };
    PlanarGraph.prototype.addNode = function addNode () {
      if (arguments[0] instanceof Node$3) {
        var node = arguments[0];
        return this._nodes.addNode(node)
      } else if (arguments[0] instanceof Coordinate) {
        var coord = arguments[0];
        return this._nodes.addNode(coord)
      }
    };
    PlanarGraph.prototype.getNodeIterator = function getNodeIterator () {
      return this._nodes.iterator()
    };
    PlanarGraph.prototype.linkResultDirectedEdges = function linkResultDirectedEdges () {
      for (var nodeit = this._nodes.iterator(); nodeit.hasNext();) {
        var node = nodeit.next();
        node.getEdges().linkResultDirectedEdges();
      }
    };
    PlanarGraph.prototype.debugPrintln = function debugPrintln (o) {
      System.out.println(o);
    };
    PlanarGraph.prototype.isBoundaryNode = function isBoundaryNode (geomIndex, coord) {
      var node = this._nodes.find(coord);
      if (node === null) { return false }
      var label = node.getLabel();
      if (label !== null && label.getLocation(geomIndex) === Location.BOUNDARY) { return true }
      return false
    };
    PlanarGraph.prototype.linkAllDirectedEdges = function linkAllDirectedEdges () {
      for (var nodeit = this._nodes.iterator(); nodeit.hasNext();) {
        var node = nodeit.next();
        node.getEdges().linkAllDirectedEdges();
      }
    };
    PlanarGraph.prototype.matchInSameDirection = function matchInSameDirection (p0, p1, ep0, ep1) {
      if (!p0.equals(ep0)) { return false }
      if (CGAlgorithms.computeOrientation(p0, p1, ep1) === CGAlgorithms.COLLINEAR && Quadrant.quadrant(p0, p1) === Quadrant.quadrant(ep0, ep1)) { return true }
      return false
    };
    PlanarGraph.prototype.getEdgeEnds = function getEdgeEnds () {
      return this._edgeEndList
    };
    PlanarGraph.prototype.debugPrint = function debugPrint (o) {
      System.out.print(o);
    };
    PlanarGraph.prototype.getEdgeIterator = function getEdgeIterator () {
      return this._edges.iterator()
    };
    PlanarGraph.prototype.findEdgeInSameDirection = function findEdgeInSameDirection (p0, p1) {
        var this$1 = this;

      for (var i = 0; i < this._edges.size(); i++) {
        var e = this$1._edges.get(i);
        var eCoord = e.getCoordinates();
        if (this$1.matchInSameDirection(p0, p1, eCoord[0], eCoord[1])) { return e }
        if (this$1.matchInSameDirection(p0, p1, eCoord[eCoord.length - 1], eCoord[eCoord.length - 2])) { return e }
      }
      return null
    };
    PlanarGraph.prototype.insertEdge = function insertEdge (e) {
      this._edges.add(e);
    };
    PlanarGraph.prototype.findEdgeEnd = function findEdgeEnd (e) {
      for (var i = this.getEdgeEnds().iterator(); i.hasNext();) {
        var ee = i.next();
        if (ee.getEdge() === e) { return ee }
      }
      return null
    };
    PlanarGraph.prototype.addEdges = function addEdges (edgesToAdd) {
        var this$1 = this;

      for (var it = edgesToAdd.iterator(); it.hasNext();) {
        var e = it.next();
        this$1._edges.add(e);
        var de1 = new DirectedEdge(e, true);
        var de2 = new DirectedEdge(e, false);
        de1.setSym(de2);
        de2.setSym(de1);
        this$1.add(de1);
        this$1.add(de2);
      }
    };
    PlanarGraph.prototype.add = function add (e) {
      this._nodes.add(e);
      this._edgeEndList.add(e);
    };
    PlanarGraph.prototype.getNodes = function getNodes () {
      return this._nodes.values()
    };
    PlanarGraph.prototype.findEdge = function findEdge (p0, p1) {
        var this$1 = this;

      for (var i = 0; i < this._edges.size(); i++) {
        var e = this$1._edges.get(i);
        var eCoord = e.getCoordinates();
        if (p0.equals(eCoord[0]) && p1.equals(eCoord[1])) { return e }
      }
      return null
    };
    PlanarGraph.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PlanarGraph.prototype.getClass = function getClass () {
      return PlanarGraph
    };
    PlanarGraph.linkResultDirectedEdges = function linkResultDirectedEdges (nodes) {
      for (var nodeit = nodes.iterator(); nodeit.hasNext();) {
        var node = nodeit.next();
        node.getEdges().linkResultDirectedEdges();
      }
    };

    var PolygonBuilder = function PolygonBuilder () {
      this._geometryFactory = null;
      this._shellList = new ArrayList();
      var geometryFactory = arguments[0];
      this._geometryFactory = geometryFactory;
    };
    PolygonBuilder.prototype.sortShellsAndHoles = function sortShellsAndHoles (edgeRings, shellList, freeHoleList) {
      for (var it = edgeRings.iterator(); it.hasNext();) {
        var er = it.next();
        if (er.isHole()) {
          freeHoleList.add(er);
        } else {
          shellList.add(er);
        }
      }
    };
    PolygonBuilder.prototype.computePolygons = function computePolygons (shellList) {
        var this$1 = this;

      var resultPolyList = new ArrayList();
      for (var it = shellList.iterator(); it.hasNext();) {
        var er = it.next();
        var poly = er.toPolygon(this$1._geometryFactory);
        resultPolyList.add(poly);
      }
      return resultPolyList
    };
    PolygonBuilder.prototype.placeFreeHoles = function placeFreeHoles (shellList, freeHoleList) {
        var this$1 = this;

      for (var it = freeHoleList.iterator(); it.hasNext();) {
        var hole = it.next();
        if (hole.getShell() === null) {
          var shell = this$1.findEdgeRingContaining(hole, shellList);
          if (shell === null) { throw new TopologyException('unable to assign hole to a shell', hole.getCoordinate(0)) }
          hole.setShell(shell);
        }
      }
    };
    PolygonBuilder.prototype.buildMinimalEdgeRings = function buildMinimalEdgeRings (maxEdgeRings, shellList, freeHoleList) {
        var this$1 = this;

      var edgeRings = new ArrayList();
      for (var it = maxEdgeRings.iterator(); it.hasNext();) {
        var er = it.next();
        if (er.getMaxNodeDegree() > 2) {
          er.linkDirectedEdgesForMinimalEdgeRings();
          var minEdgeRings = er.buildMinimalRings();
          var shell = this$1.findShell(minEdgeRings);
          if (shell !== null) {
            this$1.placePolygonHoles(shell, minEdgeRings);
            shellList.add(shell);
          } else {
            freeHoleList.addAll(minEdgeRings);
          }
        } else {
          edgeRings.add(er);
        }
      }
      return edgeRings
    };
    PolygonBuilder.prototype.containsPoint = function containsPoint (p) {
      for (var it = this._shellList.iterator(); it.hasNext();) {
        var er = it.next();
        if (er.containsPoint(p)) { return true }
      }
      return false
    };
    PolygonBuilder.prototype.buildMaximalEdgeRings = function buildMaximalEdgeRings (dirEdges) {
        var this$1 = this;

      var maxEdgeRings = new ArrayList();
      for (var it = dirEdges.iterator(); it.hasNext();) {
        var de = it.next();
        if (de.isInResult() && de.getLabel().isArea()) {
          if (de.getEdgeRing() === null) {
            var er = new MaximalEdgeRing(de, this$1._geometryFactory);
            maxEdgeRings.add(er);
            er.setInResult();
          }
        }
      }
      return maxEdgeRings
    };
    PolygonBuilder.prototype.placePolygonHoles = function placePolygonHoles (shell, minEdgeRings) {
      for (var it = minEdgeRings.iterator(); it.hasNext();) {
        var er = it.next();
        if (er.isHole()) {
          er.setShell(shell);
        }
      }
    };
    PolygonBuilder.prototype.getPolygons = function getPolygons () {
      var resultPolyList = this.computePolygons(this._shellList);
      return resultPolyList
    };
    PolygonBuilder.prototype.findEdgeRingContaining = function findEdgeRingContaining (testEr, shellList) {
      var testRing = testEr.getLinearRing();
      var testEnv = testRing.getEnvelopeInternal();
      var testPt = testRing.getCoordinateN(0);
      var minShell = null;
      var minEnv = null;
      for (var it = shellList.iterator(); it.hasNext();) {
        var tryShell = it.next();
        var tryRing = tryShell.getLinearRing();
        var tryEnv = tryRing.getEnvelopeInternal();
        if (minShell !== null) { minEnv = minShell.getLinearRing().getEnvelopeInternal(); }
        var isContained = false;
        if (tryEnv.contains(testEnv) && CGAlgorithms.isPointInRing(testPt, tryRing.getCoordinates())) { isContained = true; }
        if (isContained) {
          if (minShell === null || minEnv.contains(tryEnv)) {
            minShell = tryShell;
          }
        }
      }
      return minShell
    };
    PolygonBuilder.prototype.findShell = function findShell (minEdgeRings) {
      var shellCount = 0;
      var shell = null;
      for (var it = minEdgeRings.iterator(); it.hasNext();) {
        var er = it.next();
        if (!er.isHole()) {
          shell = er;
          shellCount++;
        }
      }
      Assert.isTrue(shellCount <= 1, 'found two shells in MinimalEdgeRing list');
      return shell
    };
    PolygonBuilder.prototype.add = function add () {
      if (arguments.length === 1) {
        var graph = arguments[0];
        this.add(graph.getEdgeEnds(), graph.getNodes());
      } else if (arguments.length === 2) {
        var dirEdges = arguments[0];
        var nodes = arguments[1];
        PlanarGraph.linkResultDirectedEdges(nodes);
        var maxEdgeRings = this.buildMaximalEdgeRings(dirEdges);
        var freeHoleList = new ArrayList();
        var edgeRings = this.buildMinimalEdgeRings(maxEdgeRings, this._shellList, freeHoleList);
        this.sortShellsAndHoles(edgeRings, this._shellList, freeHoleList);
        this.placeFreeHoles(this._shellList, freeHoleList);
      }
    };
    PolygonBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PolygonBuilder.prototype.getClass = function getClass () {
      return PolygonBuilder
    };

    var Boundable = function Boundable () {};

    Boundable.prototype.getBounds = function getBounds () {};
    Boundable.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Boundable.prototype.getClass = function getClass () {
      return Boundable
    };

    var ItemBoundable = function ItemBoundable () {
      this._bounds = null;
      this._item = null;
      var bounds = arguments[0];
      var item = arguments[1];
      this._bounds = bounds;
      this._item = item;
    };
    ItemBoundable.prototype.getItem = function getItem () {
      return this._item
    };
    ItemBoundable.prototype.getBounds = function getBounds () {
      return this._bounds
    };
    ItemBoundable.prototype.interfaces_ = function interfaces_ () {
      return [Boundable, Serializable]
    };
    ItemBoundable.prototype.getClass = function getClass () {
      return ItemBoundable
    };

    var PriorityQueue$1 = function PriorityQueue () {
      this._size = null;
      this._items = null;
      this._size = 0;
      this._items = new ArrayList();
      this._items.add(null);
    };
    PriorityQueue$1.prototype.poll = function poll () {
      if (this.isEmpty()) { return null }
      var minItem = this._items.get(1);
      this._items.set(1, this._items.get(this._size));
      this._size -= 1;
      this.reorder(1);
      return minItem
    };
    PriorityQueue$1.prototype.size = function size () {
      return this._size
    };
    PriorityQueue$1.prototype.reorder = function reorder (hole) {
        var this$1 = this;

      var child = null;
      var tmp = this._items.get(hole);
      for (; hole * 2 <= this._size; hole = child) {
        child = hole * 2;
        if (child !== this$1._size && this$1._items.get(child + 1).compareTo(this$1._items.get(child)) < 0) { child++; }
        if (this$1._items.get(child).compareTo(tmp) < 0) { this$1._items.set(hole, this$1._items.get(child)); } else { break }
      }
      this._items.set(hole, tmp);
    };
    PriorityQueue$1.prototype.clear = function clear () {
      this._size = 0;
      this._items.clear();
    };
    PriorityQueue$1.prototype.isEmpty = function isEmpty () {
      return this._size === 0
    };
    PriorityQueue$1.prototype.add = function add (x) {
        var this$1 = this;

      this._items.add(null);
      this._size += 1;
      var hole = this._size;
      this._items.set(0, x);
      for (; x.compareTo(this._items.get(Math.trunc(hole / 2))) < 0; hole /= 2) {
        this$1._items.set(hole, this$1._items.get(Math.trunc(hole / 2)));
      }
      this._items.set(hole, x);
    };
    PriorityQueue$1.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PriorityQueue$1.prototype.getClass = function getClass () {
      return PriorityQueue$1
    };

    var ItemVisitor = function ItemVisitor () {};

    ItemVisitor.prototype.visitItem = function visitItem (item) {};
    ItemVisitor.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    ItemVisitor.prototype.getClass = function getClass () {
      return ItemVisitor
    };

    var SpatialIndex = function SpatialIndex () {};

    SpatialIndex.prototype.insert = function insert (itemEnv, item) {};
    SpatialIndex.prototype.remove = function remove (itemEnv, item) {};
    SpatialIndex.prototype.query = function query () {
      // if (arguments.length === 1) {
      // const searchEnv = arguments[0]
      // } else if (arguments.length === 2) {
      // const searchEnv = arguments[0]
      // const visitor = arguments[1]
      // }
    };
    SpatialIndex.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SpatialIndex.prototype.getClass = function getClass () {
      return SpatialIndex
    };

    var AbstractNode = function AbstractNode () {
      this._childBoundables = new ArrayList();
      this._bounds = null;
      this._level = null;
      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var level = arguments[0];
        this._level = level;
      }
    };

    var staticAccessors$22 = { serialVersionUID: { configurable: true } };
    AbstractNode.prototype.getLevel = function getLevel () {
      return this._level
    };
    AbstractNode.prototype.size = function size () {
      return this._childBoundables.size()
    };
    AbstractNode.prototype.getChildBoundables = function getChildBoundables () {
      return this._childBoundables
    };
    AbstractNode.prototype.addChildBoundable = function addChildBoundable (childBoundable) {
      Assert.isTrue(this._bounds === null);
      this._childBoundables.add(childBoundable);
    };
    AbstractNode.prototype.isEmpty = function isEmpty () {
      return this._childBoundables.isEmpty()
    };
    AbstractNode.prototype.getBounds = function getBounds () {
      if (this._bounds === null) {
        this._bounds = this.computeBounds();
      }
      return this._bounds
    };
    AbstractNode.prototype.interfaces_ = function interfaces_ () {
      return [Boundable, Serializable]
    };
    AbstractNode.prototype.getClass = function getClass () {
      return AbstractNode
    };
    staticAccessors$22.serialVersionUID.get = function () { return 6493722185909573708 };

    Object.defineProperties( AbstractNode, staticAccessors$22 );

    var Collections = function Collections () {};

    Collections.reverseOrder = function reverseOrder () {
      return {
        compare: function compare (a, b) {
          return b.compareTo(a)
        }
      }
    };
    Collections.min = function min (l) {
      Collections.sort(l);
      return l.get(0)
    };
    Collections.sort = function sort (l, c) {
      var a = l.toArray();
      if (c) {
        Arrays.sort(a, c);
      } else {
        Arrays.sort(a);
      }
      var i = l.iterator();
      for (var pos = 0, alen = a.length; pos < alen; pos++) {
        i.next();
        i.set(a[pos]);
      }
    };
    Collections.singletonList = function singletonList (o) {
      var arrayList = new ArrayList();
      arrayList.add(o);
      return arrayList
    };

    var BoundablePair = function BoundablePair () {
      this._boundable1 = null;
      this._boundable2 = null;
      this._distance = null;
      this._itemDistance = null;
      var boundable1 = arguments[0];
      var boundable2 = arguments[1];
      var itemDistance = arguments[2];
      this._boundable1 = boundable1;
      this._boundable2 = boundable2;
      this._itemDistance = itemDistance;
      this._distance = this.distance();
    };
    BoundablePair.prototype.expandToQueue = function expandToQueue (priQ, minDistance) {
      var isComp1 = BoundablePair.isComposite(this._boundable1);
      var isComp2 = BoundablePair.isComposite(this._boundable2);
      if (isComp1 && isComp2) {
        if (BoundablePair.area(this._boundable1) > BoundablePair.area(this._boundable2)) {
          this.expand(this._boundable1, this._boundable2, priQ, minDistance);
          return null
        } else {
          this.expand(this._boundable2, this._boundable1, priQ, minDistance);
          return null
        }
      } else if (isComp1) {
        this.expand(this._boundable1, this._boundable2, priQ, minDistance);
        return null
      } else if (isComp2) {
        this.expand(this._boundable2, this._boundable1, priQ, minDistance);
        return null
      }
      throw new IllegalArgumentException('neither boundable is composite')
    };
    BoundablePair.prototype.isLeaves = function isLeaves () {
      return !(BoundablePair.isComposite(this._boundable1) || BoundablePair.isComposite(this._boundable2))
    };
    BoundablePair.prototype.compareTo = function compareTo (o) {
      var nd = o;
      if (this._distance < nd._distance) { return -1 }
      if (this._distance > nd._distance) { return 1 }
      return 0
    };
    BoundablePair.prototype.expand = function expand (bndComposite, bndOther, priQ, minDistance) {
        var this$1 = this;

      var children = bndComposite.getChildBoundables();
      for (var i = children.iterator(); i.hasNext();) {
        var child = i.next();
        var bp = new BoundablePair(child, bndOther, this$1._itemDistance);
        if (bp.getDistance() < minDistance) {
          priQ.add(bp);
        }
      }
    };
    BoundablePair.prototype.getBoundable = function getBoundable (i) {
      if (i === 0) { return this._boundable1 }
      return this._boundable2
    };
    BoundablePair.prototype.getDistance = function getDistance () {
      return this._distance
    };
    BoundablePair.prototype.distance = function distance () {
      if (this.isLeaves()) {
        return this._itemDistance.distance(this._boundable1, this._boundable2)
      }
      return this._boundable1.getBounds().distance(this._boundable2.getBounds())
    };
    BoundablePair.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    BoundablePair.prototype.getClass = function getClass () {
      return BoundablePair
    };
    BoundablePair.area = function area (b) {
      return b.getBounds().getArea()
    };
    BoundablePair.isComposite = function isComposite (item) {
      return item instanceof AbstractNode
    };

    var AbstractSTRtree = function AbstractSTRtree () {
      this._root = null;
      this._built = false;
      this._itemBoundables = new ArrayList();
      this._nodeCapacity = null;
      if (arguments.length === 0) {
        var nodeCapacity = AbstractSTRtree.DEFAULT_NODE_CAPACITY;
        this._nodeCapacity = nodeCapacity;
      } else if (arguments.length === 1) {
        var nodeCapacity$1 = arguments[0];
        Assert.isTrue(nodeCapacity$1 > 1, 'Node capacity must be greater than 1');
        this._nodeCapacity = nodeCapacity$1;
      }
    };

    var staticAccessors$23 = { IntersectsOp: { configurable: true },serialVersionUID: { configurable: true },DEFAULT_NODE_CAPACITY: { configurable: true } };
    AbstractSTRtree.prototype.getNodeCapacity = function getNodeCapacity () {
      return this._nodeCapacity
    };
    AbstractSTRtree.prototype.lastNode = function lastNode (nodes) {
      return nodes.get(nodes.size() - 1)
    };
    AbstractSTRtree.prototype.size = function size () {
        var this$1 = this;

      if (arguments.length === 0) {
        if (this.isEmpty()) {
          return 0
        }
        this.build();
        return this.size(this._root)
      } else if (arguments.length === 1) {
        var node = arguments[0];
        var size = 0;
        for (var i = node.getChildBoundables().iterator(); i.hasNext();) {
          var childBoundable = i.next();
          if (childBoundable instanceof AbstractNode) {
            size += this$1.size(childBoundable);
          } else if (childBoundable instanceof ItemBoundable) {
            size += 1;
          }
        }
        return size
      }
    };
    AbstractSTRtree.prototype.removeItem = function removeItem (node, item) {
      var childToRemove = null;
      for (var i = node.getChildBoundables().iterator(); i.hasNext();) {
        var childBoundable = i.next();
        if (childBoundable instanceof ItemBoundable) {
          if (childBoundable.getItem() === item) { childToRemove = childBoundable; }
        }
      }
      if (childToRemove !== null) {
        node.getChildBoundables().remove(childToRemove);
        return true
      }
      return false
    };
    AbstractSTRtree.prototype.itemsTree = function itemsTree () {
        var this$1 = this;

      if (arguments.length === 0) {
        this.build();
        var valuesTree = this.itemsTree(this._root);
        if (valuesTree === null) { return new ArrayList() }
        return valuesTree
      } else if (arguments.length === 1) {
        var node = arguments[0];
        var valuesTreeForNode = new ArrayList();
        for (var i = node.getChildBoundables().iterator(); i.hasNext();) {
          var childBoundable = i.next();
          if (childBoundable instanceof AbstractNode) {
            var valuesTreeForChild = this$1.itemsTree(childBoundable);
            if (valuesTreeForChild !== null) { valuesTreeForNode.add(valuesTreeForChild); }
          } else if (childBoundable instanceof ItemBoundable) {
            valuesTreeForNode.add(childBoundable.getItem());
          } else {
            Assert.shouldNeverReachHere();
          }
        }
        if (valuesTreeForNode.size() <= 0) { return null }
        return valuesTreeForNode
      }
    };
    AbstractSTRtree.prototype.insert = function insert (bounds, item) {
      Assert.isTrue(!this._built, 'Cannot insert items into an STR packed R-tree after it has been built.');
      this._itemBoundables.add(new ItemBoundable(bounds, item));
    };
    AbstractSTRtree.prototype.boundablesAtLevel = function boundablesAtLevel () {
        var this$1 = this;

      if (arguments.length === 1) {
        var level = arguments[0];
        var boundables = new ArrayList();
        this.boundablesAtLevel(level, this._root, boundables);
        return boundables
      } else if (arguments.length === 3) {
        var level$1 = arguments[0];
        var top = arguments[1];
        var boundables$1 = arguments[2];
        Assert.isTrue(level$1 > -2);
        if (top.getLevel() === level$1) {
          boundables$1.add(top);
          return null
        }
        for (var i = top.getChildBoundables().iterator(); i.hasNext();) {
          var boundable = i.next();
          if (boundable instanceof AbstractNode) {
            this$1.boundablesAtLevel(level$1, boundable, boundables$1);
          } else {
            Assert.isTrue(boundable instanceof ItemBoundable);
            if (level$1 === -1) {
              boundables$1.add(boundable);
            }
          }
        }
        return null
      }
    };
    AbstractSTRtree.prototype.query = function query () {
        var this$1 = this;

      if (arguments.length === 1) {
        var searchBounds = arguments[0];
        this.build();
        var matches = new ArrayList();
        if (this.isEmpty()) {
          return matches
        }
        if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds)) {
          this.query(searchBounds, this._root, matches);
        }
        return matches
      } else if (arguments.length === 2) {
        var searchBounds$1 = arguments[0];
        var visitor = arguments[1];
        this.build();
        if (this.isEmpty()) {
          return null
        }
        if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds$1)) {
          this.query(searchBounds$1, this._root, visitor);
        }
      } else if (arguments.length === 3) {
        if (hasInterface(arguments[2], ItemVisitor) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
          var searchBounds$2 = arguments[0];
          var node = arguments[1];
          var visitor$1 = arguments[2];
          var childBoundables = node.getChildBoundables();
          for (var i = 0; i < childBoundables.size(); i++) {
            var childBoundable = childBoundables.get(i);
            if (!this$1.getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds$2)) {
              continue
            }
            if (childBoundable instanceof AbstractNode) {
              this$1.query(searchBounds$2, childBoundable, visitor$1);
            } else if (childBoundable instanceof ItemBoundable) {
              visitor$1.visitItem(childBoundable.getItem());
            } else {
              Assert.shouldNeverReachHere();
            }
          }
        } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
          var searchBounds$3 = arguments[0];
          var node$1 = arguments[1];
          var matches$1 = arguments[2];
          var childBoundables$1 = node$1.getChildBoundables();
          for (var i$1 = 0; i$1 < childBoundables$1.size(); i$1++) {
            var childBoundable$1 = childBoundables$1.get(i$1);
            if (!this$1.getIntersectsOp().intersects(childBoundable$1.getBounds(), searchBounds$3)) {
              continue
            }
            if (childBoundable$1 instanceof AbstractNode) {
              this$1.query(searchBounds$3, childBoundable$1, matches$1);
            } else if (childBoundable$1 instanceof ItemBoundable) {
              matches$1.add(childBoundable$1.getItem());
            } else {
              Assert.shouldNeverReachHere();
            }
          }
        }
      }
    };
    AbstractSTRtree.prototype.build = function build () {
      if (this._built) { return null }
      this._root = this._itemBoundables.isEmpty() ? this.createNode(0) : this.createHigherLevels(this._itemBoundables, -1);
      this._itemBoundables = null;
      this._built = true;
    };
    AbstractSTRtree.prototype.getRoot = function getRoot () {
      this.build();
      return this._root
    };
    AbstractSTRtree.prototype.remove = function remove () {
        var this$1 = this;

      if (arguments.length === 2) {
        var searchBounds = arguments[0];
        var item = arguments[1];
        this.build();
        if (this.getIntersectsOp().intersects(this._root.getBounds(), searchBounds)) {
          return this.remove(searchBounds, this._root, item)
        }
        return false
      } else if (arguments.length === 3) {
        var searchBounds$1 = arguments[0];
        var node = arguments[1];
        var item$1 = arguments[2];
        var found = this.removeItem(node, item$1);
        if (found) { return true }
        var childToPrune = null;
        for (var i = node.getChildBoundables().iterator(); i.hasNext();) {
          var childBoundable = i.next();
          if (!this$1.getIntersectsOp().intersects(childBoundable.getBounds(), searchBounds$1)) {
            continue
          }
          if (childBoundable instanceof AbstractNode) {
            found = this$1.remove(searchBounds$1, childBoundable, item$1);
            if (found) {
              childToPrune = childBoundable;
              break
            }
          }
        }
        if (childToPrune !== null) {
          if (childToPrune.getChildBoundables().isEmpty()) {
            node.getChildBoundables().remove(childToPrune);
          }
        }
        return found
      }
    };
    AbstractSTRtree.prototype.createHigherLevels = function createHigherLevels (boundablesOfALevel, level) {
      Assert.isTrue(!boundablesOfALevel.isEmpty());
      var parentBoundables = this.createParentBoundables(boundablesOfALevel, level + 1);
      if (parentBoundables.size() === 1) {
        return parentBoundables.get(0)
      }
      return this.createHigherLevels(parentBoundables, level + 1)
    };
    AbstractSTRtree.prototype.depth = function depth () {
        var this$1 = this;

      if (arguments.length === 0) {
        if (this.isEmpty()) {
          return 0
        }
        this.build();
        return this.depth(this._root)
      } else if (arguments.length === 1) {
        var node = arguments[0];
        var maxChildDepth = 0;
        for (var i = node.getChildBoundables().iterator(); i.hasNext();) {
          var childBoundable = i.next();
          if (childBoundable instanceof AbstractNode) {
            var childDepth = this$1.depth(childBoundable);
            if (childDepth > maxChildDepth) { maxChildDepth = childDepth; }
          }
        }
        return maxChildDepth + 1
      }
    };
    AbstractSTRtree.prototype.createParentBoundables = function createParentBoundables (childBoundables, newLevel) {
        var this$1 = this;

      Assert.isTrue(!childBoundables.isEmpty());
      var parentBoundables = new ArrayList();
      parentBoundables.add(this.createNode(newLevel));
      var sortedChildBoundables = new ArrayList(childBoundables);
      Collections.sort(sortedChildBoundables, this.getComparator());
      for (var i = sortedChildBoundables.iterator(); i.hasNext();) {
        var childBoundable = i.next();
        if (this$1.lastNode(parentBoundables).getChildBoundables().size() === this$1.getNodeCapacity()) {
          parentBoundables.add(this$1.createNode(newLevel));
        }
        this$1.lastNode(parentBoundables).addChildBoundable(childBoundable);
      }
      return parentBoundables
    };
    AbstractSTRtree.prototype.isEmpty = function isEmpty () {
      if (!this._built) { return this._itemBoundables.isEmpty() }
      return this._root.isEmpty()
    };
    AbstractSTRtree.prototype.interfaces_ = function interfaces_ () {
      return [Serializable]
    };
    AbstractSTRtree.prototype.getClass = function getClass () {
      return AbstractSTRtree
    };
    AbstractSTRtree.compareDoubles = function compareDoubles (a, b) {
      return a > b ? 1 : a < b ? -1 : 0
    };
    staticAccessors$23.IntersectsOp.get = function () { return IntersectsOp };
    staticAccessors$23.serialVersionUID.get = function () { return -3886435814360241337 };
    staticAccessors$23.DEFAULT_NODE_CAPACITY.get = function () { return 10 };

    Object.defineProperties( AbstractSTRtree, staticAccessors$23 );

    var IntersectsOp = function IntersectsOp () {};

    var ItemDistance = function ItemDistance () {};

    ItemDistance.prototype.distance = function distance (item1, item2) {};
    ItemDistance.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    ItemDistance.prototype.getClass = function getClass () {
      return ItemDistance
    };

    var STRtree = (function (AbstractSTRtree$$1) {
      function STRtree (nodeCapacity) {
        nodeCapacity = nodeCapacity || STRtree.DEFAULT_NODE_CAPACITY;
        AbstractSTRtree$$1.call(this, nodeCapacity);
      }

      if ( AbstractSTRtree$$1 ) STRtree.__proto__ = AbstractSTRtree$$1;
      STRtree.prototype = Object.create( AbstractSTRtree$$1 && AbstractSTRtree$$1.prototype );
      STRtree.prototype.constructor = STRtree;

      var staticAccessors = { STRtreeNode: { configurable: true },serialVersionUID: { configurable: true },xComparator: { configurable: true },yComparator: { configurable: true },intersectsOp: { configurable: true },DEFAULT_NODE_CAPACITY: { configurable: true } };
      STRtree.prototype.createParentBoundablesFromVerticalSlices = function createParentBoundablesFromVerticalSlices (verticalSlices, newLevel) {
        var this$1 = this;

        Assert.isTrue(verticalSlices.length > 0);
        var parentBoundables = new ArrayList();
        for (var i = 0; i < verticalSlices.length; i++) {
          parentBoundables.addAll(this$1.createParentBoundablesFromVerticalSlice(verticalSlices[i], newLevel));
        }
        return parentBoundables
      };
      STRtree.prototype.createNode = function createNode (level) {
        return new STRtreeNode(level)
      };
      STRtree.prototype.size = function size () {
        if (arguments.length === 0) {
          return AbstractSTRtree$$1.prototype.size.call(this)
        } else { return AbstractSTRtree$$1.prototype.size.apply(this, arguments) }
      };
      STRtree.prototype.insert = function insert () {
        if (arguments.length === 2) {
          var itemEnv = arguments[0];
          var item = arguments[1];
          if (itemEnv.isNull()) {
            return null
          }
          AbstractSTRtree$$1.prototype.insert.call(this, itemEnv, item);
        } else { return AbstractSTRtree$$1.prototype.insert.apply(this, arguments) }
      };
      STRtree.prototype.getIntersectsOp = function getIntersectsOp () {
        return STRtree.intersectsOp
      };
      STRtree.prototype.verticalSlices = function verticalSlices (childBoundables, sliceCount) {
        var sliceCapacity = Math.trunc(Math.ceil(childBoundables.size() / sliceCount));
        var slices = new Array(sliceCount).fill(null);
        var i = childBoundables.iterator();
        for (var j = 0; j < sliceCount; j++) {
          slices[j] = new ArrayList();
          var boundablesAddedToSlice = 0;
          while (i.hasNext() && boundablesAddedToSlice < sliceCapacity) {
            var childBoundable = i.next();
            slices[j].add(childBoundable);
            boundablesAddedToSlice++;
          }
        }
        return slices
      };
      STRtree.prototype.query = function query () {
        if (arguments.length === 1) {
          var searchEnv = arguments[0];
          return AbstractSTRtree$$1.prototype.query.call(this, searchEnv)
        } else if (arguments.length === 2) {
          var searchEnv$1 = arguments[0];
          var visitor = arguments[1];
          AbstractSTRtree$$1.prototype.query.call(this, searchEnv$1, visitor);
        } else if (arguments.length === 3) {
          if (hasInterface(arguments[2], ItemVisitor) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
            var searchBounds = arguments[0];
            var node = arguments[1];
            var visitor$1 = arguments[2];
            AbstractSTRtree$$1.prototype.query.call(this, searchBounds, node, visitor$1);
          } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Object && arguments[1] instanceof AbstractNode)) {
            var searchBounds$1 = arguments[0];
            var node$1 = arguments[1];
            var matches = arguments[2];
            AbstractSTRtree$$1.prototype.query.call(this, searchBounds$1, node$1, matches);
          }
        }
      };
      STRtree.prototype.getComparator = function getComparator () {
        return STRtree.yComparator
      };
      STRtree.prototype.createParentBoundablesFromVerticalSlice = function createParentBoundablesFromVerticalSlice (childBoundables, newLevel) {
        return AbstractSTRtree$$1.prototype.createParentBoundables.call(this, childBoundables, newLevel)
      };
      STRtree.prototype.remove = function remove () {
        if (arguments.length === 2) {
          var itemEnv = arguments[0];
          var item = arguments[1];
          return AbstractSTRtree$$1.prototype.remove.call(this, itemEnv, item)
        } else { return AbstractSTRtree$$1.prototype.remove.apply(this, arguments) }
      };
      STRtree.prototype.depth = function depth () {
        if (arguments.length === 0) {
          return AbstractSTRtree$$1.prototype.depth.call(this)
        } else { return AbstractSTRtree$$1.prototype.depth.apply(this, arguments) }
      };
      STRtree.prototype.createParentBoundables = function createParentBoundables (childBoundables, newLevel) {
        Assert.isTrue(!childBoundables.isEmpty());
        var minLeafCount = Math.trunc(Math.ceil(childBoundables.size() / this.getNodeCapacity()));
        var sortedChildBoundables = new ArrayList(childBoundables);
        Collections.sort(sortedChildBoundables, STRtree.xComparator);
        var verticalSlices = this.verticalSlices(sortedChildBoundables, Math.trunc(Math.ceil(Math.sqrt(minLeafCount))));
        return this.createParentBoundablesFromVerticalSlices(verticalSlices, newLevel)
      };
      STRtree.prototype.nearestNeighbour = function nearestNeighbour () {
        if (arguments.length === 1) {
          if (hasInterface(arguments[0], ItemDistance)) {
            var itemDist = arguments[0];
            var bp = new BoundablePair(this.getRoot(), this.getRoot(), itemDist);
            return this.nearestNeighbour(bp)
          } else if (arguments[0] instanceof BoundablePair) {
            var initBndPair = arguments[0];
            return this.nearestNeighbour(initBndPair, Double.POSITIVE_INFINITY)
          }
        } else if (arguments.length === 2) {
          if (arguments[0] instanceof STRtree && hasInterface(arguments[1], ItemDistance)) {
            var tree = arguments[0];
            var itemDist$1 = arguments[1];
            var bp$1 = new BoundablePair(this.getRoot(), tree.getRoot(), itemDist$1);
            return this.nearestNeighbour(bp$1)
          } else if (arguments[0] instanceof BoundablePair && typeof arguments[1] === 'number') {
            var initBndPair$1 = arguments[0];
            var maxDistance = arguments[1];
            var distanceLowerBound = maxDistance;
            var minPair = null;
            var priQ = new PriorityQueue$1();
            priQ.add(initBndPair$1);
            while (!priQ.isEmpty() && distanceLowerBound > 0.0) {
              var bndPair = priQ.poll();
              var currentDistance = bndPair.getDistance();
              if (currentDistance >= distanceLowerBound) { break }
              if (bndPair.isLeaves()) {
                distanceLowerBound = currentDistance;
                minPair = bndPair;
              } else {
                bndPair.expandToQueue(priQ, distanceLowerBound);
              }
            }
            return [minPair.getBoundable(0).getItem(), minPair.getBoundable(1).getItem()]
          }
        } else if (arguments.length === 3) {
          var env = arguments[0];
          var item = arguments[1];
          var itemDist$2 = arguments[2];
          var bnd = new ItemBoundable(env, item);
          var bp$2 = new BoundablePair(this.getRoot(), bnd, itemDist$2);
          return this.nearestNeighbour(bp$2)[0]
        }
      };
      STRtree.prototype.interfaces_ = function interfaces_ () {
        return [SpatialIndex, Serializable]
      };
      STRtree.prototype.getClass = function getClass () {
        return STRtree
      };
      STRtree.centreX = function centreX (e) {
        return STRtree.avg(e.getMinX(), e.getMaxX())
      };
      STRtree.avg = function avg (a, b) {
        return (a + b) / 2
      };
      STRtree.centreY = function centreY (e) {
        return STRtree.avg(e.getMinY(), e.getMaxY())
      };
      staticAccessors.STRtreeNode.get = function () { return STRtreeNode };
      staticAccessors.serialVersionUID.get = function () { return 259274702368956900 };
      staticAccessors.xComparator.get = function () {
        return {
          interfaces_: function () {
            return [Comparator]
          },
          compare: function (o1, o2) {
            return AbstractSTRtree$$1.compareDoubles(STRtree.centreX(o1.getBounds()), STRtree.centreX(o2.getBounds()))
          }
        }
      };
      staticAccessors.yComparator.get = function () {
        return {
          interfaces_: function () {
            return [Comparator]
          },
          compare: function (o1, o2) {
            return AbstractSTRtree$$1.compareDoubles(STRtree.centreY(o1.getBounds()), STRtree.centreY(o2.getBounds()))
          }
        }
      };
      staticAccessors.intersectsOp.get = function () {
        return {
          interfaces_: function () {
            return [AbstractSTRtree$$1.IntersectsOp]
          },
          intersects: function (aBounds, bBounds) {
            return aBounds.intersects(bBounds)
          }
        }
      };
      staticAccessors.DEFAULT_NODE_CAPACITY.get = function () { return 10 };

      Object.defineProperties( STRtree, staticAccessors );

      return STRtree;
    }(AbstractSTRtree));

    var STRtreeNode = (function (AbstractNode$$1) {
      function STRtreeNode () {
        var level = arguments[0];
        AbstractNode$$1.call(this, level);
      }

      if ( AbstractNode$$1 ) STRtreeNode.__proto__ = AbstractNode$$1;
      STRtreeNode.prototype = Object.create( AbstractNode$$1 && AbstractNode$$1.prototype );
      STRtreeNode.prototype.constructor = STRtreeNode;
      STRtreeNode.prototype.computeBounds = function computeBounds () {
        var bounds = null;
        for (var i = this.getChildBoundables().iterator(); i.hasNext();) {
          var childBoundable = i.next();
          if (bounds === null) {
            bounds = new Envelope(childBoundable.getBounds());
          } else {
            bounds.expandToInclude(childBoundable.getBounds());
          }
        }
        return bounds
      };
      STRtreeNode.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      STRtreeNode.prototype.getClass = function getClass () {
        return STRtreeNode
      };

      return STRtreeNode;
    }(AbstractNode));

    var SegmentPointComparator = function SegmentPointComparator () {};

    SegmentPointComparator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SegmentPointComparator.prototype.getClass = function getClass () {
      return SegmentPointComparator
    };
    SegmentPointComparator.relativeSign = function relativeSign (x0, x1) {
      if (x0 < x1) { return -1 }
      if (x0 > x1) { return 1 }
      return 0
    };
    SegmentPointComparator.compare = function compare (octant, p0, p1) {
      if (p0.equals2D(p1)) { return 0 }
      var xSign = SegmentPointComparator.relativeSign(p0.x, p1.x);
      var ySign = SegmentPointComparator.relativeSign(p0.y, p1.y);
      switch (octant) {
        case 0:
          return SegmentPointComparator.compareValue(xSign, ySign)
        case 1:
          return SegmentPointComparator.compareValue(ySign, xSign)
        case 2:
          return SegmentPointComparator.compareValue(ySign, -xSign)
        case 3:
          return SegmentPointComparator.compareValue(-xSign, ySign)
        case 4:
          return SegmentPointComparator.compareValue(-xSign, -ySign)
        case 5:
          return SegmentPointComparator.compareValue(-ySign, -xSign)
        case 6:
          return SegmentPointComparator.compareValue(-ySign, xSign)
        case 7:
          return SegmentPointComparator.compareValue(xSign, -ySign)
        default:
      }
      Assert.shouldNeverReachHere('invalid octant value');
      return 0
    };
    SegmentPointComparator.compareValue = function compareValue (compareSign0, compareSign1) {
      if (compareSign0 < 0) { return -1 }
      if (compareSign0 > 0) { return 1 }
      if (compareSign1 < 0) { return -1 }
      if (compareSign1 > 0) { return 1 }
      return 0
    };

    var SegmentNode = function SegmentNode () {
      this._segString = null;
      this.coord = null;
      this.segmentIndex = null;
      this._segmentOctant = null;
      this._isInterior = null;
      var segString = arguments[0];
      var coord = arguments[1];
      var segmentIndex = arguments[2];
      var segmentOctant = arguments[3];
      this._segString = segString;
      this.coord = new Coordinate(coord);
      this.segmentIndex = segmentIndex;
      this._segmentOctant = segmentOctant;
      this._isInterior = !coord.equals2D(segString.getCoordinate(segmentIndex));
    };
    SegmentNode.prototype.getCoordinate = function getCoordinate () {
      return this.coord
    };
    SegmentNode.prototype.print = function print (out) {
      out.print(this.coord);
      out.print(' seg # = ' + this.segmentIndex);
    };
    SegmentNode.prototype.compareTo = function compareTo (obj) {
      var other = obj;
      if (this.segmentIndex < other.segmentIndex) { return -1 }
      if (this.segmentIndex > other.segmentIndex) { return 1 }
      if (this.coord.equals2D(other.coord)) { return 0 }
      return SegmentPointComparator.compare(this._segmentOctant, this.coord, other.coord)
    };
    SegmentNode.prototype.isEndPoint = function isEndPoint (maxSegmentIndex) {
      if (this.segmentIndex === 0 && !this._isInterior) { return true }
      if (this.segmentIndex === maxSegmentIndex) { return true }
      return false
    };
    SegmentNode.prototype.isInterior = function isInterior () {
      return this._isInterior
    };
    SegmentNode.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    SegmentNode.prototype.getClass = function getClass () {
      return SegmentNode
    };

    // import Iterator from '../../../../java/util/Iterator'
    var SegmentNodeList = function SegmentNodeList () {
      this._nodeMap = new TreeMap();
      this._edge = null;
      var edge = arguments[0];
      this._edge = edge;
    };
    SegmentNodeList.prototype.getSplitCoordinates = function getSplitCoordinates () {
        var this$1 = this;

      var coordList = new CoordinateList();
      this.addEndpoints();
      var it = this.iterator();
      var eiPrev = it.next();
      while (it.hasNext()) {
        var ei = it.next();
        this$1.addEdgeCoordinates(eiPrev, ei, coordList);
        eiPrev = ei;
      }
      return coordList.toCoordinateArray()
    };
    SegmentNodeList.prototype.addCollapsedNodes = function addCollapsedNodes () {
        var this$1 = this;

      var collapsedVertexIndexes = new ArrayList();
      this.findCollapsesFromInsertedNodes(collapsedVertexIndexes);
      this.findCollapsesFromExistingVertices(collapsedVertexIndexes);
      for (var it = collapsedVertexIndexes.iterator(); it.hasNext();) {
        var vertexIndex = it.next().intValue();
        this$1.add(this$1._edge.getCoordinate(vertexIndex), vertexIndex);
      }
    };
    SegmentNodeList.prototype.print = function print (out) {
      out.println('Intersections:');
      for (var it = this.iterator(); it.hasNext();) {
        var ei = it.next();
        ei.print(out);
      }
    };
    SegmentNodeList.prototype.findCollapsesFromExistingVertices = function findCollapsesFromExistingVertices (collapsedVertexIndexes) {
        var this$1 = this;

      for (var i = 0; i < this._edge.size() - 2; i++) {
        var p0 = this$1._edge.getCoordinate(i);
        // const p1 = this._edge.getCoordinate(i + 1)
        var p2 = this$1._edge.getCoordinate(i + 2);
        if (p0.equals2D(p2)) {
          collapsedVertexIndexes.add(new Integer(i + 1));
        }
      }
    };
    SegmentNodeList.prototype.addEdgeCoordinates = function addEdgeCoordinates (ei0, ei1, coordList) {
        var this$1 = this;

      // let npts = ei1.segmentIndex - ei0.segmentIndex + 2
      var lastSegStartPt = this._edge.getCoordinate(ei1.segmentIndex);
      var useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
      // if (!useIntPt1) {
      // npts--
      // }
      // const ipt = 0
      coordList.add(new Coordinate(ei0.coord), false);
      for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
        coordList.add(this$1._edge.getCoordinate(i));
      }
      if (useIntPt1) {
        coordList.add(new Coordinate(ei1.coord));
      }
    };
    SegmentNodeList.prototype.iterator = function iterator () {
      return this._nodeMap.values().iterator()
    };
    SegmentNodeList.prototype.addSplitEdges = function addSplitEdges (edgeList) {
        var this$1 = this;

      this.addEndpoints();
      this.addCollapsedNodes();
      var it = this.iterator();
      var eiPrev = it.next();
      while (it.hasNext()) {
        var ei = it.next();
        var newEdge = this$1.createSplitEdge(eiPrev, ei);
        edgeList.add(newEdge);
        eiPrev = ei;
      }
    };
    SegmentNodeList.prototype.findCollapseIndex = function findCollapseIndex (ei0, ei1, collapsedVertexIndex) {
      if (!ei0.coord.equals2D(ei1.coord)) { return false }
      var numVerticesBetween = ei1.segmentIndex - ei0.segmentIndex;
      if (!ei1.isInterior()) {
        numVerticesBetween--;
      }
      if (numVerticesBetween === 1) {
        collapsedVertexIndex[0] = ei0.segmentIndex + 1;
        return true
      }
      return false
    };
    SegmentNodeList.prototype.findCollapsesFromInsertedNodes = function findCollapsesFromInsertedNodes (collapsedVertexIndexes) {
        var this$1 = this;

      var collapsedVertexIndex = new Array(1).fill(null);
      var it = this.iterator();
      var eiPrev = it.next();
      while (it.hasNext()) {
        var ei = it.next();
        var isCollapsed = this$1.findCollapseIndex(eiPrev, ei, collapsedVertexIndex);
        if (isCollapsed) { collapsedVertexIndexes.add(new Integer(collapsedVertexIndex[0])); }
        eiPrev = ei;
      }
    };
    SegmentNodeList.prototype.getEdge = function getEdge () {
      return this._edge
    };
    SegmentNodeList.prototype.addEndpoints = function addEndpoints () {
      var maxSegIndex = this._edge.size() - 1;
      this.add(this._edge.getCoordinate(0), 0);
      this.add(this._edge.getCoordinate(maxSegIndex), maxSegIndex);
    };
    SegmentNodeList.prototype.createSplitEdge = function createSplitEdge (ei0, ei1) {
        var this$1 = this;

      var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
      var lastSegStartPt = this._edge.getCoordinate(ei1.segmentIndex);
      var useIntPt1 = ei1.isInterior() || !ei1.coord.equals2D(lastSegStartPt);
      if (!useIntPt1) {
        npts--;
      }
      var pts = new Array(npts).fill(null);
      var ipt = 0;
      pts[ipt++] = new Coordinate(ei0.coord);
      for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
        pts[ipt++] = this$1._edge.getCoordinate(i);
      }
      if (useIntPt1) { pts[ipt] = new Coordinate(ei1.coord); }
      return new NodedSegmentString(pts, this._edge.getData())
    };
    SegmentNodeList.prototype.add = function add (intPt, segmentIndex) {
      var eiNew = new SegmentNode(this._edge, intPt, segmentIndex, this._edge.getSegmentOctant(segmentIndex));
      var ei = this._nodeMap.get(eiNew);
      if (ei !== null) {
        Assert.isTrue(ei.coord.equals2D(intPt), 'Found equal nodes with different coordinates');
        return ei
      }
      this._nodeMap.put(eiNew, eiNew);
      return eiNew
    };
    SegmentNodeList.prototype.checkSplitEdgesCorrectness = function checkSplitEdgesCorrectness (splitEdges) {
      var edgePts = this._edge.getCoordinates();
      var split0 = splitEdges.get(0);
      var pt0 = split0.getCoordinate(0);
      if (!pt0.equals2D(edgePts[0])) { throw new RuntimeException('bad split edge start point at ' + pt0) }
      var splitn = splitEdges.get(splitEdges.size() - 1);
      var splitnPts = splitn.getCoordinates();
      var ptn = splitnPts[splitnPts.length - 1];
      if (!ptn.equals2D(edgePts[edgePts.length - 1])) { throw new RuntimeException('bad split edge end point at ' + ptn) }
    };
    SegmentNodeList.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SegmentNodeList.prototype.getClass = function getClass () {
      return SegmentNodeList
    };



    // class NodeVertexIterator {
    //   constructor () {
    //     this._nodeList = null
    //     this._edge = null
    //     this._nodeIt = null
    //     this._currNode = null
    //     this._nextNode = null
    //     this._currSegIndex = 0
    //     let nodeList = arguments[0]
    //     this._nodeList = nodeList
    //     this._edge = nodeList.getEdge()
    //     this._nodeIt = nodeList.iterator()
    //     this.readNextNode()
    //   }
    //   next () {
    //     if (this._currNode === null) {
    //       this._currNode = this._nextNode
    //       this._currSegIndex = this._currNode.segmentIndex
    //       this.readNextNode()
    //       return this._currNode
    //     }
    //     if (this._nextNode === null) return null
    //     if (this._nextNode.segmentIndex === this._currNode.segmentIndex) {
    //       this._currNode = this._nextNode
    //       this._currSegIndex = this._currNode.segmentIndex
    //       this.readNextNode()
    //       return this._currNode
    //     }
    //     if (this._nextNode.segmentIndex > this._currNode.segmentIndex) {}
    //     return null
    //   }
    //   remove () {
    //     // throw new UnsupportedOperationException(this.getClass().getName())
    //   }
    //   hasNext () {
    //     if (this._nextNode === null) return false
    //     return true
    //   }
    //   readNextNode () {
    //     if (this._nodeIt.hasNext()) this._nextNode = this._nodeIt.next(); else this._nextNode = null
    //   }
    //   interfaces_ () {
    //     return [Iterator]
    //   }
    //   getClass () {
    //     return NodeVertexIterator
    //   }
    // }

    var Octant = function Octant () {};

    Octant.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Octant.prototype.getClass = function getClass () {
      return Octant
    };
    Octant.octant = function octant () {
      if (typeof arguments[0] === 'number' && typeof arguments[1] === 'number') {
        var dx = arguments[0];
        var dy = arguments[1];
        if (dx === 0.0 && dy === 0.0) { throw new IllegalArgumentException('Cannot compute the octant for point ( ' + dx + ', ' + dy + ' )') }
        var adx = Math.abs(dx);
        var ady = Math.abs(dy);
        if (dx >= 0) {
          if (dy >= 0) {
            if (adx >= ady) { return 0; } else { return 1 }
          } else {
            if (adx >= ady) { return 7; } else { return 6 }
          }
        } else {
          if (dy >= 0) {
            if (adx >= ady) { return 3; } else { return 2 }
          } else {
            if (adx >= ady) { return 4; } else { return 5 }
          }
        }
      } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Coordinate) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        var dx$1 = p1.x - p0.x;
        var dy$1 = p1.y - p0.y;
        if (dx$1 === 0.0 && dy$1 === 0.0) { throw new IllegalArgumentException('Cannot compute the octant for two identical points ' + p0) }
        return Octant.octant(dx$1, dy$1)
      }
    };

    var SegmentString = function SegmentString () {};

    SegmentString.prototype.getCoordinates = function getCoordinates () {};
    SegmentString.prototype.size = function size () {};
    SegmentString.prototype.getCoordinate = function getCoordinate (i) {};
    SegmentString.prototype.isClosed = function isClosed () {};
    SegmentString.prototype.setData = function setData (data) {};
    SegmentString.prototype.getData = function getData () {};
    SegmentString.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SegmentString.prototype.getClass = function getClass () {
      return SegmentString
    };

    var NodableSegmentString = function NodableSegmentString () {};

    NodableSegmentString.prototype.addIntersection = function addIntersection (intPt, segmentIndex) {};
    NodableSegmentString.prototype.interfaces_ = function interfaces_ () {
      return [SegmentString]
    };
    NodableSegmentString.prototype.getClass = function getClass () {
      return NodableSegmentString
    };

    var NodedSegmentString = function NodedSegmentString () {
      this._nodeList = new SegmentNodeList(this);
      this._pts = null;
      this._data = null;
      var pts = arguments[0];
      var data = arguments[1];
      this._pts = pts;
      this._data = data;
    };
    NodedSegmentString.prototype.getCoordinates = function getCoordinates () {
      return this._pts
    };
    NodedSegmentString.prototype.size = function size () {
      return this._pts.length
    };
    NodedSegmentString.prototype.getCoordinate = function getCoordinate (i) {
      return this._pts[i]
    };
    NodedSegmentString.prototype.isClosed = function isClosed () {
      return this._pts[0].equals(this._pts[this._pts.length - 1])
    };
    NodedSegmentString.prototype.getSegmentOctant = function getSegmentOctant (index) {
      if (index === this._pts.length - 1) { return -1 }
      return this.safeOctant(this.getCoordinate(index), this.getCoordinate(index + 1))
    };
    NodedSegmentString.prototype.setData = function setData (data) {
      this._data = data;
    };
    NodedSegmentString.prototype.safeOctant = function safeOctant (p0, p1) {
      if (p0.equals2D(p1)) { return 0 }
      return Octant.octant(p0, p1)
    };
    NodedSegmentString.prototype.getData = function getData () {
      return this._data
    };
    NodedSegmentString.prototype.addIntersection = function addIntersection () {
      if (arguments.length === 2) {
        var intPt$1 = arguments[0];
        var segmentIndex = arguments[1];
        this.addIntersectionNode(intPt$1, segmentIndex);
      } else if (arguments.length === 4) {
        var li = arguments[0];
        var segmentIndex$1 = arguments[1];
        // const geomIndex = arguments[2]
        var intIndex = arguments[3];
        var intPt = new Coordinate(li.getIntersection(intIndex));
        this.addIntersection(intPt, segmentIndex$1);
      }
    };
    NodedSegmentString.prototype.toString = function toString () {
      return WKTWriter.toLineString(new CoordinateArraySequence(this._pts))
    };
    NodedSegmentString.prototype.getNodeList = function getNodeList () {
      return this._nodeList
    };
    NodedSegmentString.prototype.addIntersectionNode = function addIntersectionNode (intPt, segmentIndex) {
      var normalizedSegmentIndex = segmentIndex;
      var nextSegIndex = normalizedSegmentIndex + 1;
      if (nextSegIndex < this._pts.length) {
        var nextPt = this._pts[nextSegIndex];
        if (intPt.equals2D(nextPt)) {
          normalizedSegmentIndex = nextSegIndex;
        }
      }
      var ei = this._nodeList.add(intPt, normalizedSegmentIndex);
      return ei
    };
    NodedSegmentString.prototype.addIntersections = function addIntersections (li, segmentIndex, geomIndex) {
        var this$1 = this;

      for (var i = 0; i < li.getIntersectionNum(); i++) {
        this$1.addIntersection(li, segmentIndex, geomIndex, i);
      }
    };
    NodedSegmentString.prototype.interfaces_ = function interfaces_ () {
      return [NodableSegmentString]
    };
    NodedSegmentString.prototype.getClass = function getClass () {
      return NodedSegmentString
    };
    NodedSegmentString.getNodedSubstrings = function getNodedSubstrings () {
      if (arguments.length === 1) {
        var segStrings = arguments[0];
        var resultEdgelist = new ArrayList();
        NodedSegmentString.getNodedSubstrings(segStrings, resultEdgelist);
        return resultEdgelist
      } else if (arguments.length === 2) {
        var segStrings$1 = arguments[0];
        var resultEdgelist$1 = arguments[1];
        for (var i = segStrings$1.iterator(); i.hasNext();) {
          var ss = i.next();
          ss.getNodeList().addSplitEdges(resultEdgelist$1);
        }
      }
    };

    var LineSegment = function LineSegment () {
      this.p0 = null;
      this.p1 = null;
      if (arguments.length === 0) {
        this.p0 = new Coordinate();
        this.p1 = new Coordinate();
      } else if (arguments.length === 1) {
        var ls = arguments[0];
        this.p0 = new Coordinate(ls.p0);
        this.p1 = new Coordinate(ls.p1);
      } else if (arguments.length === 2) {
        this.p0 = arguments[0];
        this.p1 = arguments[1];
      } else if (arguments.length === 4) {
        var x0 = arguments[0];
        var y0 = arguments[1];
        var x1 = arguments[2];
        var y1 = arguments[3];
        this.p0 = new Coordinate(x0, y0);
        this.p1 = new Coordinate(x1, y1);
      }
    };

    var staticAccessors$24 = { serialVersionUID: { configurable: true } };
    LineSegment.prototype.minX = function minX () {
      return Math.min(this.p0.x, this.p1.x)
    };
    LineSegment.prototype.orientationIndex = function orientationIndex () {
      if (arguments[0] instanceof LineSegment) {
        var seg = arguments[0];
        var orient0 = CGAlgorithms.orientationIndex(this.p0, this.p1, seg.p0);
        var orient1 = CGAlgorithms.orientationIndex(this.p0, this.p1, seg.p1);
        if (orient0 >= 0 && orient1 >= 0) { return Math.max(orient0, orient1) }
        if (orient0 <= 0 && orient1 <= 0) { return Math.max(orient0, orient1) }
        return 0
      } else if (arguments[0] instanceof Coordinate) {
        var p = arguments[0];
        return CGAlgorithms.orientationIndex(this.p0, this.p1, p)
      }
    };
    LineSegment.prototype.toGeometry = function toGeometry (geomFactory) {
      return geomFactory.createLineString([this.p0, this.p1])
    };
    LineSegment.prototype.isVertical = function isVertical () {
      return this.p0.x === this.p1.x
    };
    LineSegment.prototype.equals = function equals (o) {
      if (!(o instanceof LineSegment)) {
        return false
      }
      var other = o;
      return this.p0.equals(other.p0) && this.p1.equals(other.p1)
    };
    LineSegment.prototype.intersection = function intersection (line) {
      var li = new RobustLineIntersector();
      li.computeIntersection(this.p0, this.p1, line.p0, line.p1);
      if (li.hasIntersection()) { return li.getIntersection(0) }
      return null
    };
    LineSegment.prototype.project = function project () {
      if (arguments[0] instanceof Coordinate) {
        var p = arguments[0];
        if (p.equals(this.p0) || p.equals(this.p1)) { return new Coordinate(p) }
        var r = this.projectionFactor(p);
        var coord = new Coordinate();
        coord.x = this.p0.x + r * (this.p1.x - this.p0.x);
        coord.y = this.p0.y + r * (this.p1.y - this.p0.y);
        return coord
      } else if (arguments[0] instanceof LineSegment) {
        var seg = arguments[0];
        var pf0 = this.projectionFactor(seg.p0);
        var pf1 = this.projectionFactor(seg.p1);
        if (pf0 >= 1.0 && pf1 >= 1.0) { return null }
        if (pf0 <= 0.0 && pf1 <= 0.0) { return null }
        var newp0 = this.project(seg.p0);
        if (pf0 < 0.0) { newp0 = this.p0; }
        if (pf0 > 1.0) { newp0 = this.p1; }
        var newp1 = this.project(seg.p1);
        if (pf1 < 0.0) { newp1 = this.p0; }
        if (pf1 > 1.0) { newp1 = this.p1; }
        return new LineSegment(newp0, newp1)
      }
    };
    LineSegment.prototype.normalize = function normalize () {
      if (this.p1.compareTo(this.p0) < 0) { this.reverse(); }
    };
    LineSegment.prototype.angle = function angle () {
      return Math.atan2(this.p1.y - this.p0.y, this.p1.x - this.p0.x)
    };
    LineSegment.prototype.getCoordinate = function getCoordinate (i) {
      if (i === 0) { return this.p0 }
      return this.p1
    };
    LineSegment.prototype.distancePerpendicular = function distancePerpendicular (p) {
      return CGAlgorithms.distancePointLinePerpendicular(p, this.p0, this.p1)
    };
    LineSegment.prototype.minY = function minY () {
      return Math.min(this.p0.y, this.p1.y)
    };
    LineSegment.prototype.midPoint = function midPoint () {
      return LineSegment.midPoint(this.p0, this.p1)
    };
    LineSegment.prototype.projectionFactor = function projectionFactor (p) {
      if (p.equals(this.p0)) { return 0.0 }
      if (p.equals(this.p1)) { return 1.0 }
      var dx = this.p1.x - this.p0.x;
      var dy = this.p1.y - this.p0.y;
      var len = dx * dx + dy * dy;
      if (len <= 0.0) { return Double.NaN }
      var r = ((p.x - this.p0.x) * dx + (p.y - this.p0.y) * dy) / len;
      return r
    };
    LineSegment.prototype.closestPoints = function closestPoints (line) {
      var intPt = this.intersection(line);
      if (intPt !== null) {
        return [intPt, intPt]
      }
      var closestPt = new Array(2).fill(null);
      var minDistance = Double.MAX_VALUE;
      var dist = null;
      var close00 = this.closestPoint(line.p0);
      minDistance = close00.distance(line.p0);
      closestPt[0] = close00;
      closestPt[1] = line.p0;
      var close01 = this.closestPoint(line.p1);
      dist = close01.distance(line.p1);
      if (dist < minDistance) {
        minDistance = dist;
        closestPt[0] = close01;
        closestPt[1] = line.p1;
      }
      var close10 = line.closestPoint(this.p0);
      dist = close10.distance(this.p0);
      if (dist < minDistance) {
        minDistance = dist;
        closestPt[0] = this.p0;
        closestPt[1] = close10;
      }
      var close11 = line.closestPoint(this.p1);
      dist = close11.distance(this.p1);
      if (dist < minDistance) {
        minDistance = dist;
        closestPt[0] = this.p1;
        closestPt[1] = close11;
      }
      return closestPt
    };
    LineSegment.prototype.closestPoint = function closestPoint (p) {
      var factor = this.projectionFactor(p);
      if (factor > 0 && factor < 1) {
        return this.project(p)
      }
      var dist0 = this.p0.distance(p);
      var dist1 = this.p1.distance(p);
      if (dist0 < dist1) { return this.p0 }
      return this.p1
    };
    LineSegment.prototype.maxX = function maxX () {
      return Math.max(this.p0.x, this.p1.x)
    };
    LineSegment.prototype.getLength = function getLength () {
      return this.p0.distance(this.p1)
    };
    LineSegment.prototype.compareTo = function compareTo (o) {
      var other = o;
      var comp0 = this.p0.compareTo(other.p0);
      if (comp0 !== 0) { return comp0 }
      return this.p1.compareTo(other.p1)
    };
    LineSegment.prototype.reverse = function reverse () {
      var temp = this.p0;
      this.p0 = this.p1;
      this.p1 = temp;
    };
    LineSegment.prototype.equalsTopo = function equalsTopo (other) {
      return this.p0.equals(other.p0) &&
            (this.p1.equals(other.p1) || this.p0.equals(other.p1)) &&
             this.p1.equals(other.p0)
    };
    LineSegment.prototype.lineIntersection = function lineIntersection (line) {
      try {
        var intPt = HCoordinate.intersection(this.p0, this.p1, line.p0, line.p1);
        return intPt
      } catch (ex) {
        if (ex instanceof NotRepresentableException) ; else { throw ex }
      } finally {}
      return null
    };
    LineSegment.prototype.maxY = function maxY () {
      return Math.max(this.p0.y, this.p1.y)
    };
    LineSegment.prototype.pointAlongOffset = function pointAlongOffset (segmentLengthFraction, offsetDistance) {
      var segx = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
      var segy = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
      var dx = this.p1.x - this.p0.x;
      var dy = this.p1.y - this.p0.y;
      var len = Math.sqrt(dx * dx + dy * dy);
      var ux = 0.0;
      var uy = 0.0;
      if (offsetDistance !== 0.0) {
        if (len <= 0.0) { throw new Error('Cannot compute offset from zero-length line segment') }
        ux = offsetDistance * dx / len;
        uy = offsetDistance * dy / len;
      }
      var offsetx = segx - uy;
      var offsety = segy + ux;
      var coord = new Coordinate(offsetx, offsety);
      return coord
    };
    LineSegment.prototype.setCoordinates = function setCoordinates () {
      if (arguments.length === 1) {
        var ls = arguments[0];
        this.setCoordinates(ls.p0, ls.p1);
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        this.p0.x = p0.x;
        this.p0.y = p0.y;
        this.p1.x = p1.x;
        this.p1.y = p1.y;
      }
    };
    LineSegment.prototype.segmentFraction = function segmentFraction (inputPt) {
      var segFrac = this.projectionFactor(inputPt);
      if (segFrac < 0.0) { segFrac = 0.0; } else if (segFrac > 1.0 || Double.isNaN(segFrac)) { segFrac = 1.0; }
      return segFrac
    };
    LineSegment.prototype.toString = function toString () {
      return 'LINESTRING( ' + this.p0.x + ' ' + this.p0.y + ', ' + this.p1.x + ' ' + this.p1.y + ')'
    };
    LineSegment.prototype.isHorizontal = function isHorizontal () {
      return this.p0.y === this.p1.y
    };
    LineSegment.prototype.distance = function distance () {
      if (arguments[0] instanceof LineSegment) {
        var ls = arguments[0];
        return CGAlgorithms.distanceLineLine(this.p0, this.p1, ls.p0, ls.p1)
      } else if (arguments[0] instanceof Coordinate) {
        var p = arguments[0];
        return CGAlgorithms.distancePointLine(p, this.p0, this.p1)
      }
    };
    LineSegment.prototype.pointAlong = function pointAlong (segmentLengthFraction) {
      var coord = new Coordinate();
      coord.x = this.p0.x + segmentLengthFraction * (this.p1.x - this.p0.x);
      coord.y = this.p0.y + segmentLengthFraction * (this.p1.y - this.p0.y);
      return coord
    };
    LineSegment.prototype.hashCode = function hashCode () {
      var bits0 = Double.doubleToLongBits(this.p0.x);
      bits0 ^= Double.doubleToLongBits(this.p0.y) * 31;
      var hash0 = Math.trunc(bits0) ^ Math.trunc(bits0 >> 32);
      var bits1 = Double.doubleToLongBits(this.p1.x);
      bits1 ^= Double.doubleToLongBits(this.p1.y) * 31;
      var hash1 = Math.trunc(bits1) ^ Math.trunc(bits1 >> 32);
      return hash0 ^ hash1
    };
    LineSegment.prototype.interfaces_ = function interfaces_ () {
      return [Comparable, Serializable]
    };
    LineSegment.prototype.getClass = function getClass () {
      return LineSegment
    };
    LineSegment.midPoint = function midPoint (p0, p1) {
      return new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2)
    };
    staticAccessors$24.serialVersionUID.get = function () { return 3252005833466256227 };

    Object.defineProperties( LineSegment, staticAccessors$24 );

    var MonotoneChainOverlapAction = function MonotoneChainOverlapAction () {
      this.tempEnv1 = new Envelope();
      this.tempEnv2 = new Envelope();
      this._overlapSeg1 = new LineSegment();
      this._overlapSeg2 = new LineSegment();
    };
    MonotoneChainOverlapAction.prototype.overlap = function overlap () {
      if (arguments.length === 2) ; else if (arguments.length === 4) {
        var mc1 = arguments[0];
        var start1 = arguments[1];
        var mc2 = arguments[2];
        var start2 = arguments[3];
        mc1.getLineSegment(start1, this._overlapSeg1);
        mc2.getLineSegment(start2, this._overlapSeg2);
        this.overlap(this._overlapSeg1, this._overlapSeg2);
      }
    };
    MonotoneChainOverlapAction.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChainOverlapAction.prototype.getClass = function getClass () {
      return MonotoneChainOverlapAction
    };

    var MonotoneChain = function MonotoneChain () {
      this._pts = null;
      this._start = null;
      this._end = null;
      this._env = null;
      this._context = null;
      this._id = null;
      var pts = arguments[0];
      var start = arguments[1];
      var end = arguments[2];
      var context = arguments[3];
      this._pts = pts;
      this._start = start;
      this._end = end;
      this._context = context;
    };
    MonotoneChain.prototype.getLineSegment = function getLineSegment (index, ls) {
      ls.p0 = this._pts[index];
      ls.p1 = this._pts[index + 1];
    };
    MonotoneChain.prototype.computeSelect = function computeSelect (searchEnv, start0, end0, mcs) {
      var p0 = this._pts[start0];
      var p1 = this._pts[end0];
      mcs.tempEnv1.init(p0, p1);
      if (end0 - start0 === 1) {
        mcs.select(this, start0);
        return null
      }
      if (!searchEnv.intersects(mcs.tempEnv1)) { return null }
      var mid = Math.trunc((start0 + end0) / 2);
      if (start0 < mid) {
        this.computeSelect(searchEnv, start0, mid, mcs);
      }
      if (mid < end0) {
        this.computeSelect(searchEnv, mid, end0, mcs);
      }
    };
    MonotoneChain.prototype.getCoordinates = function getCoordinates () {
        var this$1 = this;

      var coord = new Array(this._end - this._start + 1).fill(null);
      var index = 0;
      for (var i = this._start; i <= this._end; i++) {
        coord[index++] = this$1._pts[i];
      }
      return coord
    };
    MonotoneChain.prototype.computeOverlaps = function computeOverlaps (mc, mco) {
      this.computeOverlapsInternal(this._start, this._end, mc, mc._start, mc._end, mco);
    };
    MonotoneChain.prototype.setId = function setId (id) {
      this._id = id;
    };
    MonotoneChain.prototype.select = function select (searchEnv, mcs) {
      this.computeSelect(searchEnv, this._start, this._end, mcs);
    };
    MonotoneChain.prototype.getEnvelope = function getEnvelope () {
      if (this._env === null) {
        var p0 = this._pts[this._start];
        var p1 = this._pts[this._end];
        this._env = new Envelope(p0, p1);
      }
      return this._env
    };
    MonotoneChain.prototype.getEndIndex = function getEndIndex () {
      return this._end
    };
    MonotoneChain.prototype.getStartIndex = function getStartIndex () {
      return this._start
    };
    MonotoneChain.prototype.getContext = function getContext () {
      return this._context
    };
    MonotoneChain.prototype.getId = function getId () {
      return this._id
    };
    MonotoneChain.prototype.computeOverlapsInternal = function computeOverlapsInternal (start0, end0, mc, start1, end1, mco) {
      var p00 = this._pts[start0];
      var p01 = this._pts[end0];
      var p10 = mc._pts[start1];
      var p11 = mc._pts[end1];
      if (end0 - start0 === 1 && end1 - start1 === 1) {
        mco.overlap(this, start0, mc, start1);
        return null
      }
      mco.tempEnv1.init(p00, p01);
      mco.tempEnv2.init(p10, p11);
      if (!mco.tempEnv1.intersects(mco.tempEnv2)) { return null }
      var mid0 = Math.trunc((start0 + end0) / 2);
      var mid1 = Math.trunc((start1 + end1) / 2);
      if (start0 < mid0) {
        if (start1 < mid1) { this.computeOverlapsInternal(start0, mid0, mc, start1, mid1, mco); }
        if (mid1 < end1) { this.computeOverlapsInternal(start0, mid0, mc, mid1, end1, mco); }
      }
      if (mid0 < end0) {
        if (start1 < mid1) { this.computeOverlapsInternal(mid0, end0, mc, start1, mid1, mco); }
        if (mid1 < end1) { this.computeOverlapsInternal(mid0, end0, mc, mid1, end1, mco); }
      }
    };
    MonotoneChain.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChain.prototype.getClass = function getClass () {
      return MonotoneChain
    };

    var MonotoneChainBuilder = function MonotoneChainBuilder () {};

    MonotoneChainBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChainBuilder.prototype.getClass = function getClass () {
      return MonotoneChainBuilder
    };
    MonotoneChainBuilder.getChainStartIndices = function getChainStartIndices (pts) {
      var start = 0;
      var startIndexList = new ArrayList();
      startIndexList.add(new Integer(start));
      do {
        var last = MonotoneChainBuilder.findChainEnd(pts, start);
        startIndexList.add(new Integer(last));
        start = last;
      } while (start < pts.length - 1)
      var startIndex = MonotoneChainBuilder.toIntArray(startIndexList);
      return startIndex
    };
    MonotoneChainBuilder.findChainEnd = function findChainEnd (pts, start) {
      var safeStart = start;
      while (safeStart < pts.length - 1 && pts[safeStart].equals2D(pts[safeStart + 1])) {
        safeStart++;
      }
      if (safeStart >= pts.length - 1) {
        return pts.length - 1
      }
      var chainQuad = Quadrant.quadrant(pts[safeStart], pts[safeStart + 1]);
      var last = start + 1;
      while (last < pts.length) {
        if (!pts[last - 1].equals2D(pts[last])) {
          var quad = Quadrant.quadrant(pts[last - 1], pts[last]);
          if (quad !== chainQuad) { break }
        }
        last++;
      }
      return last - 1
    };
    MonotoneChainBuilder.getChains = function getChains () {
      if (arguments.length === 1) {
        var pts = arguments[0];
        return MonotoneChainBuilder.getChains(pts, null)
      } else if (arguments.length === 2) {
        var pts$1 = arguments[0];
        var context = arguments[1];
        var mcList = new ArrayList();
        var startIndex = MonotoneChainBuilder.getChainStartIndices(pts$1);
        for (var i = 0; i < startIndex.length - 1; i++) {
          var mc = new MonotoneChain(pts$1, startIndex[i], startIndex[i + 1], context);
          mcList.add(mc);
        }
        return mcList
      }
    };
    MonotoneChainBuilder.toIntArray = function toIntArray (list) {
      var array = new Array(list.size()).fill(null);
      for (var i = 0; i < array.length; i++) {
        array[i] = list.get(i).intValue();
      }
      return array
    };

    var Noder = function Noder () {};

    Noder.prototype.computeNodes = function computeNodes (segStrings) {};
    Noder.prototype.getNodedSubstrings = function getNodedSubstrings () {};
    Noder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Noder.prototype.getClass = function getClass () {
      return Noder
    };

    var SinglePassNoder = function SinglePassNoder () {
      this._segInt = null;
      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var segInt = arguments[0];
        this.setSegmentIntersector(segInt);
      }
    };
    SinglePassNoder.prototype.setSegmentIntersector = function setSegmentIntersector (segInt) {
      this._segInt = segInt;
    };
    SinglePassNoder.prototype.interfaces_ = function interfaces_ () {
      return [Noder]
    };
    SinglePassNoder.prototype.getClass = function getClass () {
      return SinglePassNoder
    };

    var MCIndexNoder = (function (SinglePassNoder$$1) {
      function MCIndexNoder (si) {
        if (si) { SinglePassNoder$$1.call(this, si); }
        else { SinglePassNoder$$1.call(this); }
        this._monoChains = new ArrayList();
        this._index = new STRtree();
        this._idCounter = 0;
        this._nodedSegStrings = null;
        this._nOverlaps = 0;
      }

      if ( SinglePassNoder$$1 ) MCIndexNoder.__proto__ = SinglePassNoder$$1;
      MCIndexNoder.prototype = Object.create( SinglePassNoder$$1 && SinglePassNoder$$1.prototype );
      MCIndexNoder.prototype.constructor = MCIndexNoder;

      var staticAccessors = { SegmentOverlapAction: { configurable: true } };
      MCIndexNoder.prototype.getMonotoneChains = function getMonotoneChains () {
        return this._monoChains
      };
      MCIndexNoder.prototype.getNodedSubstrings = function getNodedSubstrings () {
        return NodedSegmentString.getNodedSubstrings(this._nodedSegStrings)
      };
      MCIndexNoder.prototype.getIndex = function getIndex () {
        return this._index
      };
      MCIndexNoder.prototype.add = function add (segStr) {
        var this$1 = this;

        var segChains = MonotoneChainBuilder.getChains(segStr.getCoordinates(), segStr);
        for (var i = segChains.iterator(); i.hasNext();) {
          var mc = i.next();
          mc.setId(this$1._idCounter++);
          this$1._index.insert(mc.getEnvelope(), mc);
          this$1._monoChains.add(mc);
        }
      };
      MCIndexNoder.prototype.computeNodes = function computeNodes (inputSegStrings) {
        var this$1 = this;

        this._nodedSegStrings = inputSegStrings;
        for (var i = inputSegStrings.iterator(); i.hasNext();) {
          this$1.add(i.next());
        }
        this.intersectChains();
      };
      MCIndexNoder.prototype.intersectChains = function intersectChains () {
        var this$1 = this;

        var overlapAction = new SegmentOverlapAction(this._segInt);
        for (var i = this._monoChains.iterator(); i.hasNext();) {
          var queryChain = i.next();
          var overlapChains = this$1._index.query(queryChain.getEnvelope());
          for (var j = overlapChains.iterator(); j.hasNext();) {
            var testChain = j.next();
            if (testChain.getId() > queryChain.getId()) {
              queryChain.computeOverlaps(testChain, overlapAction);
              this$1._nOverlaps++;
            }
            if (this$1._segInt.isDone()) { return null }
          }
        }
      };
      MCIndexNoder.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      MCIndexNoder.prototype.getClass = function getClass () {
        return MCIndexNoder
      };
      staticAccessors.SegmentOverlapAction.get = function () { return SegmentOverlapAction };

      Object.defineProperties( MCIndexNoder, staticAccessors );

      return MCIndexNoder;
    }(SinglePassNoder));

    var SegmentOverlapAction = (function (MonotoneChainOverlapAction$$1) {
      function SegmentOverlapAction () {
        MonotoneChainOverlapAction$$1.call(this);
        this._si = null;
        var si = arguments[0];
        this._si = si;
      }

      if ( MonotoneChainOverlapAction$$1 ) SegmentOverlapAction.__proto__ = MonotoneChainOverlapAction$$1;
      SegmentOverlapAction.prototype = Object.create( MonotoneChainOverlapAction$$1 && MonotoneChainOverlapAction$$1.prototype );
      SegmentOverlapAction.prototype.constructor = SegmentOverlapAction;
      SegmentOverlapAction.prototype.overlap = function overlap () {
        if (arguments.length === 4) {
          var mc1 = arguments[0];
          var start1 = arguments[1];
          var mc2 = arguments[2];
          var start2 = arguments[3];
          var ss1 = mc1.getContext();
          var ss2 = mc2.getContext();
          this._si.processIntersections(ss1, start1, ss2, start2);
        } else { return MonotoneChainOverlapAction$$1.prototype.overlap.apply(this, arguments) }
      };
      SegmentOverlapAction.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      SegmentOverlapAction.prototype.getClass = function getClass () {
        return SegmentOverlapAction
      };

      return SegmentOverlapAction;
    }(MonotoneChainOverlapAction));

    var BufferParameters = function BufferParameters () {
      this._quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
      this._endCapStyle = BufferParameters.CAP_ROUND;
      this._joinStyle = BufferParameters.JOIN_ROUND;
      this._mitreLimit = BufferParameters.DEFAULT_MITRE_LIMIT;
      this._isSingleSided = false;
      this._simplifyFactor = BufferParameters.DEFAULT_SIMPLIFY_FACTOR;

      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var quadrantSegments = arguments[0];
        this.setQuadrantSegments(quadrantSegments);
      } else if (arguments.length === 2) {
        var quadrantSegments$1 = arguments[0];
        var endCapStyle = arguments[1];
        this.setQuadrantSegments(quadrantSegments$1);
        this.setEndCapStyle(endCapStyle);
      } else if (arguments.length === 4) {
        var quadrantSegments$2 = arguments[0];
        var endCapStyle$1 = arguments[1];
        var joinStyle = arguments[2];
        var mitreLimit = arguments[3];
        this.setQuadrantSegments(quadrantSegments$2);
        this.setEndCapStyle(endCapStyle$1);
        this.setJoinStyle(joinStyle);
        this.setMitreLimit(mitreLimit);
      }
    };

    var staticAccessors$25 = { CAP_ROUND: { configurable: true },CAP_FLAT: { configurable: true },CAP_SQUARE: { configurable: true },JOIN_ROUND: { configurable: true },JOIN_MITRE: { configurable: true },JOIN_BEVEL: { configurable: true },DEFAULT_QUADRANT_SEGMENTS: { configurable: true },DEFAULT_MITRE_LIMIT: { configurable: true },DEFAULT_SIMPLIFY_FACTOR: { configurable: true } };
    BufferParameters.prototype.getEndCapStyle = function getEndCapStyle () {
      return this._endCapStyle
    };
    BufferParameters.prototype.isSingleSided = function isSingleSided () {
      return this._isSingleSided
    };
    BufferParameters.prototype.setQuadrantSegments = function setQuadrantSegments (quadSegs) {
      this._quadrantSegments = quadSegs;
      if (this._quadrantSegments === 0) { this._joinStyle = BufferParameters.JOIN_BEVEL; }
      if (this._quadrantSegments < 0) {
        this._joinStyle = BufferParameters.JOIN_MITRE;
        this._mitreLimit = Math.abs(this._quadrantSegments);
      }
      if (quadSegs <= 0) {
        this._quadrantSegments = 1;
      }
      if (this._joinStyle !== BufferParameters.JOIN_ROUND) {
        this._quadrantSegments = BufferParameters.DEFAULT_QUADRANT_SEGMENTS;
      }
    };
    BufferParameters.prototype.getJoinStyle = function getJoinStyle () {
      return this._joinStyle
    };
    BufferParameters.prototype.setJoinStyle = function setJoinStyle (joinStyle) {
      this._joinStyle = joinStyle;
    };
    BufferParameters.prototype.setSimplifyFactor = function setSimplifyFactor (simplifyFactor) {
      this._simplifyFactor = simplifyFactor < 0 ? 0 : simplifyFactor;
    };
    BufferParameters.prototype.getSimplifyFactor = function getSimplifyFactor () {
      return this._simplifyFactor
    };
    BufferParameters.prototype.getQuadrantSegments = function getQuadrantSegments () {
      return this._quadrantSegments
    };
    BufferParameters.prototype.setEndCapStyle = function setEndCapStyle (endCapStyle) {
      this._endCapStyle = endCapStyle;
    };
    BufferParameters.prototype.getMitreLimit = function getMitreLimit () {
      return this._mitreLimit
    };
    BufferParameters.prototype.setMitreLimit = function setMitreLimit (mitreLimit) {
      this._mitreLimit = mitreLimit;
    };
    BufferParameters.prototype.setSingleSided = function setSingleSided (isSingleSided) {
      this._isSingleSided = isSingleSided;
    };
    BufferParameters.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferParameters.prototype.getClass = function getClass () {
      return BufferParameters
    };
    BufferParameters.bufferDistanceError = function bufferDistanceError (quadSegs) {
      var alpha = Math.PI / 2.0 / quadSegs;
      return 1 - Math.cos(alpha / 2.0)
    };
    staticAccessors$25.CAP_ROUND.get = function () { return 1 };
    staticAccessors$25.CAP_FLAT.get = function () { return 2 };
    staticAccessors$25.CAP_SQUARE.get = function () { return 3 };
    staticAccessors$25.JOIN_ROUND.get = function () { return 1 };
    staticAccessors$25.JOIN_MITRE.get = function () { return 2 };
    staticAccessors$25.JOIN_BEVEL.get = function () { return 3 };
    staticAccessors$25.DEFAULT_QUADRANT_SEGMENTS.get = function () { return 8 };
    staticAccessors$25.DEFAULT_MITRE_LIMIT.get = function () { return 5.0 };
    staticAccessors$25.DEFAULT_SIMPLIFY_FACTOR.get = function () { return 0.01 };

    Object.defineProperties( BufferParameters, staticAccessors$25 );

    var BufferInputLineSimplifier = function BufferInputLineSimplifier (inputLine) {
      this._distanceTol = null;
      this._isDeleted = null;
      this._angleOrientation = CGAlgorithms.COUNTERCLOCKWISE;
      this._inputLine = inputLine || null;
    };

    var staticAccessors$26 = { INIT: { configurable: true },DELETE: { configurable: true },KEEP: { configurable: true },NUM_PTS_TO_CHECK: { configurable: true } };
    BufferInputLineSimplifier.prototype.isDeletable = function isDeletable (i0, i1, i2, distanceTol) {
      var p0 = this._inputLine[i0];
      var p1 = this._inputLine[i1];
      var p2 = this._inputLine[i2];
      if (!this.isConcave(p0, p1, p2)) { return false }
      if (!this.isShallow(p0, p1, p2, distanceTol)) { return false }
      return this.isShallowSampled(p0, p1, i0, i2, distanceTol)
    };
    BufferInputLineSimplifier.prototype.deleteShallowConcavities = function deleteShallowConcavities () {
        var this$1 = this;

      var index = 1;
      // const maxIndex = this._inputLine.length - 1
      var midIndex = this.findNextNonDeletedIndex(index);
      var lastIndex = this.findNextNonDeletedIndex(midIndex);
      var isChanged = false;
      while (lastIndex < this._inputLine.length) {
        var isMiddleVertexDeleted = false;
        if (this$1.isDeletable(index, midIndex, lastIndex, this$1._distanceTol)) {
          this$1._isDeleted[midIndex] = BufferInputLineSimplifier.DELETE;
          isMiddleVertexDeleted = true;
          isChanged = true;
        }
        if (isMiddleVertexDeleted) { index = lastIndex; } else { index = midIndex; }
        midIndex = this$1.findNextNonDeletedIndex(index);
        lastIndex = this$1.findNextNonDeletedIndex(midIndex);
      }
      return isChanged
    };
    BufferInputLineSimplifier.prototype.isShallowConcavity = function isShallowConcavity (p0, p1, p2, distanceTol) {
      var orientation = CGAlgorithms.computeOrientation(p0, p1, p2);
      var isAngleToSimplify = orientation === this._angleOrientation;
      if (!isAngleToSimplify) { return false }
      var dist = CGAlgorithms.distancePointLine(p1, p0, p2);
      return dist < distanceTol
    };
    BufferInputLineSimplifier.prototype.isShallowSampled = function isShallowSampled (p0, p2, i0, i2, distanceTol) {
        var this$1 = this;

      var inc = Math.trunc((i2 - i0) / BufferInputLineSimplifier.NUM_PTS_TO_CHECK);
      if (inc <= 0) { inc = 1; }
      for (var i = i0; i < i2; i += inc) {
        if (!this$1.isShallow(p0, p2, this$1._inputLine[i], distanceTol)) { return false }
      }
      return true
    };
    BufferInputLineSimplifier.prototype.isConcave = function isConcave (p0, p1, p2) {
      var orientation = CGAlgorithms.computeOrientation(p0, p1, p2);
      var isConcave = orientation === this._angleOrientation;
      return isConcave
    };
    BufferInputLineSimplifier.prototype.simplify = function simplify (distanceTol) {
        var this$1 = this;

      this._distanceTol = Math.abs(distanceTol);
      if (distanceTol < 0) { this._angleOrientation = CGAlgorithms.CLOCKWISE; }
      this._isDeleted = new Array(this._inputLine.length).fill(null);
      var isChanged = false;
      do {
        isChanged = this$1.deleteShallowConcavities();
      } while (isChanged)
      return this.collapseLine()
    };
    BufferInputLineSimplifier.prototype.findNextNonDeletedIndex = function findNextNonDeletedIndex (index) {
      var next = index + 1;
      while (next < this._inputLine.length && this._isDeleted[next] === BufferInputLineSimplifier.DELETE) { next++; }
      return next
    };
    BufferInputLineSimplifier.prototype.isShallow = function isShallow (p0, p1, p2, distanceTol) {
      var dist = CGAlgorithms.distancePointLine(p1, p0, p2);
      return dist < distanceTol
    };
    BufferInputLineSimplifier.prototype.collapseLine = function collapseLine () {
        var this$1 = this;

      var coordList = new CoordinateList();
      for (var i = 0; i < this._inputLine.length; i++) {
        if (this$1._isDeleted[i] !== BufferInputLineSimplifier.DELETE) { coordList.add(this$1._inputLine[i]); }
      }
      return coordList.toCoordinateArray()
    };
    BufferInputLineSimplifier.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferInputLineSimplifier.prototype.getClass = function getClass () {
      return BufferInputLineSimplifier
    };
    BufferInputLineSimplifier.simplify = function simplify (inputLine, distanceTol) {
      var simp = new BufferInputLineSimplifier(inputLine);
      return simp.simplify(distanceTol)
    };
    staticAccessors$26.INIT.get = function () { return 0 };
    staticAccessors$26.DELETE.get = function () { return 1 };
    staticAccessors$26.KEEP.get = function () { return 1 };
    staticAccessors$26.NUM_PTS_TO_CHECK.get = function () { return 10 };

    Object.defineProperties( BufferInputLineSimplifier, staticAccessors$26 );

    var OffsetSegmentString = function OffsetSegmentString () {
      this._ptList = null;
      this._precisionModel = null;
      this._minimimVertexDistance = 0.0;
      this._ptList = new ArrayList();
    };

    var staticAccessors$28 = { COORDINATE_ARRAY_TYPE: { configurable: true } };
    OffsetSegmentString.prototype.getCoordinates = function getCoordinates () {
      var coord = this._ptList.toArray(OffsetSegmentString.COORDINATE_ARRAY_TYPE);
      return coord
    };
    OffsetSegmentString.prototype.setPrecisionModel = function setPrecisionModel (precisionModel) {
      this._precisionModel = precisionModel;
    };
    OffsetSegmentString.prototype.addPt = function addPt (pt) {
      var bufPt = new Coordinate(pt);
      this._precisionModel.makePrecise(bufPt);
      if (this.isRedundant(bufPt)) { return null }
      this._ptList.add(bufPt);
    };
    OffsetSegmentString.prototype.revere = function revere () {};
    OffsetSegmentString.prototype.addPts = function addPts (pt, isForward) {
        var this$1 = this;

      if (isForward) {
        for (var i = 0; i < pt.length; i++) {
          this$1.addPt(pt[i]);
        }
      } else {
        for (var i$1 = pt.length - 1; i$1 >= 0; i$1--) {
          this$1.addPt(pt[i$1]);
        }
      }
    };
    OffsetSegmentString.prototype.isRedundant = function isRedundant (pt) {
      if (this._ptList.size() < 1) { return false }
      var lastPt = this._ptList.get(this._ptList.size() - 1);
      var ptDist = pt.distance(lastPt);
      if (ptDist < this._minimimVertexDistance) { return true }
      return false
    };
    OffsetSegmentString.prototype.toString = function toString () {
      var fact = new GeometryFactory();
      var line = fact.createLineString(this.getCoordinates());
      return line.toString()
    };
    OffsetSegmentString.prototype.closeRing = function closeRing () {
      if (this._ptList.size() < 1) { return null }
      var startPt = new Coordinate(this._ptList.get(0));
      var lastPt = this._ptList.get(this._ptList.size() - 1);
      // const last2Pt = null
      // if (this._ptList.size() >= 2) last2Pt = this._ptList.get(this._ptList.size() - 2)
      if (startPt.equals(lastPt)) { return null }
      this._ptList.add(startPt);
    };
    OffsetSegmentString.prototype.setMinimumVertexDistance = function setMinimumVertexDistance (minimimVertexDistance) {
      this._minimimVertexDistance = minimimVertexDistance;
    };
    OffsetSegmentString.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OffsetSegmentString.prototype.getClass = function getClass () {
      return OffsetSegmentString
    };
    staticAccessors$28.COORDINATE_ARRAY_TYPE.get = function () { return new Array(0).fill(null) };

    Object.defineProperties( OffsetSegmentString, staticAccessors$28 );

    var Angle = function Angle () {};

    var staticAccessors$29 = { PI_TIMES_2: { configurable: true },PI_OVER_2: { configurable: true },PI_OVER_4: { configurable: true },COUNTERCLOCKWISE: { configurable: true },CLOCKWISE: { configurable: true },NONE: { configurable: true } };

    Angle.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Angle.prototype.getClass = function getClass () {
      return Angle
    };
    Angle.toDegrees = function toDegrees (radians) {
      return radians * 180 / Math.PI
    };
    Angle.normalize = function normalize (angle) {
      while (angle > Math.PI) { angle -= Angle.PI_TIMES_2; }
      while (angle <= -Math.PI) { angle += Angle.PI_TIMES_2; }
      return angle
    };
    Angle.angle = function angle () {
      if (arguments.length === 1) {
        var p = arguments[0];
        return Math.atan2(p.y, p.x)
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        var dx = p1.x - p0.x;
        var dy = p1.y - p0.y;
        return Math.atan2(dy, dx)
      }
    };
    Angle.isAcute = function isAcute (p0, p1, p2) {
      var dx0 = p0.x - p1.x;
      var dy0 = p0.y - p1.y;
      var dx1 = p2.x - p1.x;
      var dy1 = p2.y - p1.y;
      var dotprod = dx0 * dx1 + dy0 * dy1;
      return dotprod > 0
    };
    Angle.isObtuse = function isObtuse (p0, p1, p2) {
      var dx0 = p0.x - p1.x;
      var dy0 = p0.y - p1.y;
      var dx1 = p2.x - p1.x;
      var dy1 = p2.y - p1.y;
      var dotprod = dx0 * dx1 + dy0 * dy1;
      return dotprod < 0
    };
    Angle.interiorAngle = function interiorAngle (p0, p1, p2) {
      var anglePrev = Angle.angle(p1, p0);
      var angleNext = Angle.angle(p1, p2);
      return Math.abs(angleNext - anglePrev)
    };
    Angle.normalizePositive = function normalizePositive (angle) {
      if (angle < 0.0) {
        while (angle < 0.0) { angle += Angle.PI_TIMES_2; }
        if (angle >= Angle.PI_TIMES_2) { angle = 0.0; }
      } else {
        while (angle >= Angle.PI_TIMES_2) { angle -= Angle.PI_TIMES_2; }
        if (angle < 0.0) { angle = 0.0; }
      }
      return angle
    };
    Angle.angleBetween = function angleBetween (tip1, tail, tip2) {
      var a1 = Angle.angle(tail, tip1);
      var a2 = Angle.angle(tail, tip2);
      return Angle.diff(a1, a2)
    };
    Angle.diff = function diff (ang1, ang2) {
      var delAngle = null;
      if (ang1 < ang2) {
        delAngle = ang2 - ang1;
      } else {
        delAngle = ang1 - ang2;
      }
      if (delAngle > Math.PI) {
        delAngle = 2 * Math.PI - delAngle;
      }
      return delAngle
    };
    Angle.toRadians = function toRadians (angleDegrees) {
      return angleDegrees * Math.PI / 180.0
    };
    Angle.getTurn = function getTurn (ang1, ang2) {
      var crossproduct = Math.sin(ang2 - ang1);
      if (crossproduct > 0) {
        return Angle.COUNTERCLOCKWISE
      }
      if (crossproduct < 0) {
        return Angle.CLOCKWISE
      }
      return Angle.NONE
    };
    Angle.angleBetweenOriented = function angleBetweenOriented (tip1, tail, tip2) {
      var a1 = Angle.angle(tail, tip1);
      var a2 = Angle.angle(tail, tip2);
      var angDel = a2 - a1;
      if (angDel <= -Math.PI) { return angDel + Angle.PI_TIMES_2 }
      if (angDel > Math.PI) { return angDel - Angle.PI_TIMES_2 }
      return angDel
    };
    staticAccessors$29.PI_TIMES_2.get = function () { return 2.0 * Math.PI };
    staticAccessors$29.PI_OVER_2.get = function () { return Math.PI / 2.0 };
    staticAccessors$29.PI_OVER_4.get = function () { return Math.PI / 4.0 };
    staticAccessors$29.COUNTERCLOCKWISE.get = function () { return CGAlgorithms.COUNTERCLOCKWISE };
    staticAccessors$29.CLOCKWISE.get = function () { return CGAlgorithms.CLOCKWISE };
    staticAccessors$29.NONE.get = function () { return CGAlgorithms.COLLINEAR };

    Object.defineProperties( Angle, staticAccessors$29 );

    var OffsetSegmentGenerator = function OffsetSegmentGenerator () {
      this._maxCurveSegmentError = 0.0;
      this._filletAngleQuantum = null;
      this._closingSegLengthFactor = 1;
      this._segList = null;
      this._distance = 0.0;
      this._precisionModel = null;
      this._bufParams = null;
      this._li = null;
      this._s0 = null;
      this._s1 = null;
      this._s2 = null;
      this._seg0 = new LineSegment();
      this._seg1 = new LineSegment();
      this._offset0 = new LineSegment();
      this._offset1 = new LineSegment();
      this._side = 0;
      this._hasNarrowConcaveAngle = false;
      var precisionModel = arguments[0];
      var bufParams = arguments[1];
      var distance = arguments[2];
      this._precisionModel = precisionModel;
      this._bufParams = bufParams;
      this._li = new RobustLineIntersector();
      this._filletAngleQuantum = Math.PI / 2.0 / bufParams.getQuadrantSegments();
      if (bufParams.getQuadrantSegments() >= 8 && bufParams.getJoinStyle() === BufferParameters.JOIN_ROUND) { this._closingSegLengthFactor = OffsetSegmentGenerator.MAX_CLOSING_SEG_LEN_FACTOR; }
      this.init(distance);
    };

    var staticAccessors$27 = { OFFSET_SEGMENT_SEPARATION_FACTOR: { configurable: true },INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR: { configurable: true },CURVE_VERTEX_SNAP_DISTANCE_FACTOR: { configurable: true },MAX_CLOSING_SEG_LEN_FACTOR: { configurable: true } };
    OffsetSegmentGenerator.prototype.addNextSegment = function addNextSegment (p, addStartPoint) {
      this._s0 = this._s1;
      this._s1 = this._s2;
      this._s2 = p;
      this._seg0.setCoordinates(this._s0, this._s1);
      this.computeOffsetSegment(this._seg0, this._side, this._distance, this._offset0);
      this._seg1.setCoordinates(this._s1, this._s2);
      this.computeOffsetSegment(this._seg1, this._side, this._distance, this._offset1);
      if (this._s1.equals(this._s2)) { return null }
      var orientation = CGAlgorithms.computeOrientation(this._s0, this._s1, this._s2);
      var outsideTurn = (orientation === CGAlgorithms.CLOCKWISE && this._side === Position.LEFT) || (orientation === CGAlgorithms.COUNTERCLOCKWISE && this._side === Position.RIGHT);
      if (orientation === 0) {
        this.addCollinear(addStartPoint);
      } else if (outsideTurn) {
        this.addOutsideTurn(orientation, addStartPoint);
      } else {
        this.addInsideTurn(orientation, addStartPoint);
      }
    };
    OffsetSegmentGenerator.prototype.addLineEndCap = function addLineEndCap (p0, p1) {
      var seg = new LineSegment(p0, p1);
      var offsetL = new LineSegment();
      this.computeOffsetSegment(seg, Position.LEFT, this._distance, offsetL);
      var offsetR = new LineSegment();
      this.computeOffsetSegment(seg, Position.RIGHT, this._distance, offsetR);
      var dx = p1.x - p0.x;
      var dy = p1.y - p0.y;
      var angle = Math.atan2(dy, dx);
      switch (this._bufParams.getEndCapStyle()) {
        case BufferParameters.CAP_ROUND:
          this._segList.addPt(offsetL.p1);
          this.addFilletArc(p1, angle + Math.PI / 2, angle - Math.PI / 2, CGAlgorithms.CLOCKWISE, this._distance);
          this._segList.addPt(offsetR.p1);
          break
        case BufferParameters.CAP_FLAT:
          this._segList.addPt(offsetL.p1);
          this._segList.addPt(offsetR.p1);
          break
        case BufferParameters.CAP_SQUARE:
          var squareCapSideOffset = new Coordinate();
          squareCapSideOffset.x = Math.abs(this._distance) * Math.cos(angle);
          squareCapSideOffset.y = Math.abs(this._distance) * Math.sin(angle);
          var squareCapLOffset = new Coordinate(offsetL.p1.x + squareCapSideOffset.x, offsetL.p1.y + squareCapSideOffset.y);
          var squareCapROffset = new Coordinate(offsetR.p1.x + squareCapSideOffset.x, offsetR.p1.y + squareCapSideOffset.y);
          this._segList.addPt(squareCapLOffset);
          this._segList.addPt(squareCapROffset);
          break
        default:
      }
    };
    OffsetSegmentGenerator.prototype.getCoordinates = function getCoordinates () {
      var pts = this._segList.getCoordinates();
      return pts
    };
    OffsetSegmentGenerator.prototype.addMitreJoin = function addMitreJoin (p, offset0, offset1, distance) {
      var isMitreWithinLimit = true;
      var intPt = null;
      try {
        intPt = HCoordinate.intersection(offset0.p0, offset0.p1, offset1.p0, offset1.p1);
        var mitreRatio = distance <= 0.0 ? 1.0 : intPt.distance(p) / Math.abs(distance);
        if (mitreRatio > this._bufParams.getMitreLimit()) { isMitreWithinLimit = false; }
      } catch (ex) {
        if (ex instanceof NotRepresentableException) {
          intPt = new Coordinate(0, 0);
          isMitreWithinLimit = false;
        } else { throw ex }
      } finally {}
      if (isMitreWithinLimit) {
        this._segList.addPt(intPt);
      } else {
        this.addLimitedMitreJoin(offset0, offset1, distance, this._bufParams.getMitreLimit());
      }
    };
    OffsetSegmentGenerator.prototype.addFilletCorner = function addFilletCorner (p, p0, p1, direction, radius) {
      var dx0 = p0.x - p.x;
      var dy0 = p0.y - p.y;
      var startAngle = Math.atan2(dy0, dx0);
      var dx1 = p1.x - p.x;
      var dy1 = p1.y - p.y;
      var endAngle = Math.atan2(dy1, dx1);
      if (direction === CGAlgorithms.CLOCKWISE) {
        if (startAngle <= endAngle) { startAngle += 2.0 * Math.PI; }
      } else {
        if (startAngle >= endAngle) { startAngle -= 2.0 * Math.PI; }
      }
      this._segList.addPt(p0);
      this.addFilletArc(p, startAngle, endAngle, direction, radius);
      this._segList.addPt(p1);
    };
    OffsetSegmentGenerator.prototype.addOutsideTurn = function addOutsideTurn (orientation, addStartPoint) {
      if (this._offset0.p1.distance(this._offset1.p0) < this._distance * OffsetSegmentGenerator.OFFSET_SEGMENT_SEPARATION_FACTOR) {
        this._segList.addPt(this._offset0.p1);
        return null
      }
      if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_MITRE) {
        this.addMitreJoin(this._s1, this._offset0, this._offset1, this._distance);
      } else if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_BEVEL) {
        this.addBevelJoin(this._offset0, this._offset1);
      } else {
        if (addStartPoint) { this._segList.addPt(this._offset0.p1); }
        this.addFilletCorner(this._s1, this._offset0.p1, this._offset1.p0, orientation, this._distance);
        this._segList.addPt(this._offset1.p0);
      }
    };
    OffsetSegmentGenerator.prototype.createSquare = function createSquare (p) {
      this._segList.addPt(new Coordinate(p.x + this._distance, p.y + this._distance));
      this._segList.addPt(new Coordinate(p.x + this._distance, p.y - this._distance));
      this._segList.addPt(new Coordinate(p.x - this._distance, p.y - this._distance));
      this._segList.addPt(new Coordinate(p.x - this._distance, p.y + this._distance));
      this._segList.closeRing();
    };
    OffsetSegmentGenerator.prototype.addSegments = function addSegments (pt, isForward) {
      this._segList.addPts(pt, isForward);
    };
    OffsetSegmentGenerator.prototype.addFirstSegment = function addFirstSegment () {
      this._segList.addPt(this._offset1.p0);
    };
    OffsetSegmentGenerator.prototype.addLastSegment = function addLastSegment () {
      this._segList.addPt(this._offset1.p1);
    };
    OffsetSegmentGenerator.prototype.initSideSegments = function initSideSegments (s1, s2, side) {
      this._s1 = s1;
      this._s2 = s2;
      this._side = side;
      this._seg1.setCoordinates(s1, s2);
      this.computeOffsetSegment(this._seg1, side, this._distance, this._offset1);
    };
    OffsetSegmentGenerator.prototype.addLimitedMitreJoin = function addLimitedMitreJoin (offset0, offset1, distance, mitreLimit) {
      var basePt = this._seg0.p1;
      var ang0 = Angle.angle(basePt, this._seg0.p0);
      // const ang1 = Angle.angle(basePt, this._seg1.p1)
      var angDiff = Angle.angleBetweenOriented(this._seg0.p0, basePt, this._seg1.p1);
      var angDiffHalf = angDiff / 2;
      var midAng = Angle.normalize(ang0 + angDiffHalf);
      var mitreMidAng = Angle.normalize(midAng + Math.PI);
      var mitreDist = mitreLimit * distance;
      var bevelDelta = mitreDist * Math.abs(Math.sin(angDiffHalf));
      var bevelHalfLen = distance - bevelDelta;
      var bevelMidX = basePt.x + mitreDist * Math.cos(mitreMidAng);
      var bevelMidY = basePt.y + mitreDist * Math.sin(mitreMidAng);
      var bevelMidPt = new Coordinate(bevelMidX, bevelMidY);
      var mitreMidLine = new LineSegment(basePt, bevelMidPt);
      var bevelEndLeft = mitreMidLine.pointAlongOffset(1.0, bevelHalfLen);
      var bevelEndRight = mitreMidLine.pointAlongOffset(1.0, -bevelHalfLen);
      if (this._side === Position.LEFT) {
        this._segList.addPt(bevelEndLeft);
        this._segList.addPt(bevelEndRight);
      } else {
        this._segList.addPt(bevelEndRight);
        this._segList.addPt(bevelEndLeft);
      }
    };
    OffsetSegmentGenerator.prototype.computeOffsetSegment = function computeOffsetSegment (seg, side, distance, offset) {
      var sideSign = side === Position.LEFT ? 1 : -1;
      var dx = seg.p1.x - seg.p0.x;
      var dy = seg.p1.y - seg.p0.y;
      var len = Math.sqrt(dx * dx + dy * dy);
      var ux = sideSign * distance * dx / len;
      var uy = sideSign * distance * dy / len;
      offset.p0.x = seg.p0.x - uy;
      offset.p0.y = seg.p0.y + ux;
      offset.p1.x = seg.p1.x - uy;
      offset.p1.y = seg.p1.y + ux;
    };
    OffsetSegmentGenerator.prototype.addFilletArc = function addFilletArc (p, startAngle, endAngle, direction, radius) {
        var this$1 = this;

      var directionFactor = direction === CGAlgorithms.CLOCKWISE ? -1 : 1;
      var totalAngle = Math.abs(startAngle - endAngle);
      var nSegs = Math.trunc(totalAngle / this._filletAngleQuantum + 0.5);
      if (nSegs < 1) { return null }
      var initAngle = 0.0;
      var currAngleInc = totalAngle / nSegs;
      var currAngle = initAngle;
      var pt = new Coordinate();
      while (currAngle < totalAngle) {
        var angle = startAngle + directionFactor * currAngle;
        pt.x = p.x + radius * Math.cos(angle);
        pt.y = p.y + radius * Math.sin(angle);
        this$1._segList.addPt(pt);
        currAngle += currAngleInc;
      }
    };
    OffsetSegmentGenerator.prototype.addInsideTurn = function addInsideTurn (orientation, addStartPoint) {
      this._li.computeIntersection(this._offset0.p0, this._offset0.p1, this._offset1.p0, this._offset1.p1);
      if (this._li.hasIntersection()) {
        this._segList.addPt(this._li.getIntersection(0));
      } else {
        this._hasNarrowConcaveAngle = true;
        if (this._offset0.p1.distance(this._offset1.p0) < this._distance * OffsetSegmentGenerator.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR) {
          this._segList.addPt(this._offset0.p1);
        } else {
          this._segList.addPt(this._offset0.p1);
          if (this._closingSegLengthFactor > 0) {
            var mid0 = new Coordinate((this._closingSegLengthFactor * this._offset0.p1.x + this._s1.x) / (this._closingSegLengthFactor + 1), (this._closingSegLengthFactor * this._offset0.p1.y + this._s1.y) / (this._closingSegLengthFactor + 1));
            this._segList.addPt(mid0);
            var mid1 = new Coordinate((this._closingSegLengthFactor * this._offset1.p0.x + this._s1.x) / (this._closingSegLengthFactor + 1), (this._closingSegLengthFactor * this._offset1.p0.y + this._s1.y) / (this._closingSegLengthFactor + 1));
            this._segList.addPt(mid1);
          } else {
            this._segList.addPt(this._s1);
          }
          this._segList.addPt(this._offset1.p0);
        }
      }
    };
    OffsetSegmentGenerator.prototype.createCircle = function createCircle (p) {
      var pt = new Coordinate(p.x + this._distance, p.y);
      this._segList.addPt(pt);
      this.addFilletArc(p, 0.0, 2.0 * Math.PI, -1, this._distance);
      this._segList.closeRing();
    };
    OffsetSegmentGenerator.prototype.addBevelJoin = function addBevelJoin (offset0, offset1) {
      this._segList.addPt(offset0.p1);
      this._segList.addPt(offset1.p0);
    };
    OffsetSegmentGenerator.prototype.init = function init (distance) {
      this._distance = distance;
      this._maxCurveSegmentError = distance * (1 - Math.cos(this._filletAngleQuantum / 2.0));
      this._segList = new OffsetSegmentString();
      this._segList.setPrecisionModel(this._precisionModel);
      this._segList.setMinimumVertexDistance(distance * OffsetSegmentGenerator.CURVE_VERTEX_SNAP_DISTANCE_FACTOR);
    };
    OffsetSegmentGenerator.prototype.addCollinear = function addCollinear (addStartPoint) {
      this._li.computeIntersection(this._s0, this._s1, this._s1, this._s2);
      var numInt = this._li.getIntersectionNum();
      if (numInt >= 2) {
        if (this._bufParams.getJoinStyle() === BufferParameters.JOIN_BEVEL || this._bufParams.getJoinStyle() === BufferParameters.JOIN_MITRE) {
          if (addStartPoint) { this._segList.addPt(this._offset0.p1); }
          this._segList.addPt(this._offset1.p0);
        } else {
          this.addFilletCorner(this._s1, this._offset0.p1, this._offset1.p0, CGAlgorithms.CLOCKWISE, this._distance);
        }
      }
    };
    OffsetSegmentGenerator.prototype.closeRing = function closeRing () {
      this._segList.closeRing();
    };
    OffsetSegmentGenerator.prototype.hasNarrowConcaveAngle = function hasNarrowConcaveAngle () {
      return this._hasNarrowConcaveAngle
    };
    OffsetSegmentGenerator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OffsetSegmentGenerator.prototype.getClass = function getClass () {
      return OffsetSegmentGenerator
    };
    staticAccessors$27.OFFSET_SEGMENT_SEPARATION_FACTOR.get = function () { return 1.0E-3 };
    staticAccessors$27.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get = function () { return 1.0E-3 };
    staticAccessors$27.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get = function () { return 1.0E-6 };
    staticAccessors$27.MAX_CLOSING_SEG_LEN_FACTOR.get = function () { return 80 };

    Object.defineProperties( OffsetSegmentGenerator, staticAccessors$27 );

    var OffsetCurveBuilder = function OffsetCurveBuilder () {
      this._distance = 0.0;
      this._precisionModel = null;
      this._bufParams = null;
      var precisionModel = arguments[0];
      var bufParams = arguments[1];
      this._precisionModel = precisionModel;
      this._bufParams = bufParams;
    };
    OffsetCurveBuilder.prototype.getOffsetCurve = function getOffsetCurve (inputPts, distance) {
      this._distance = distance;
      if (distance === 0.0) { return null }
      var isRightSide = distance < 0.0;
      var posDistance = Math.abs(distance);
      var segGen = this.getSegGen(posDistance);
      if (inputPts.length <= 1) {
        this.computePointCurve(inputPts[0], segGen);
      } else {
        this.computeOffsetCurve(inputPts, isRightSide, segGen);
      }
      var curvePts = segGen.getCoordinates();
      if (isRightSide) { CoordinateArrays.reverse(curvePts); }
      return curvePts
    };
    OffsetCurveBuilder.prototype.computeSingleSidedBufferCurve = function computeSingleSidedBufferCurve (inputPts, isRightSide, segGen) {
      var distTol = this.simplifyTolerance(this._distance);
      if (isRightSide) {
        segGen.addSegments(inputPts, true);
        var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
        var n2 = simp2.length - 1;
        segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
        segGen.addFirstSegment();
        for (var i = n2 - 2; i >= 0; i--) {
          segGen.addNextSegment(simp2[i], true);
        }
      } else {
        segGen.addSegments(inputPts, false);
        var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
        var n1 = simp1.length - 1;
        segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
        segGen.addFirstSegment();
        for (var i$1 = 2; i$1 <= n1; i$1++) {
          segGen.addNextSegment(simp1[i$1], true);
        }
      }
      segGen.addLastSegment();
      segGen.closeRing();
    };
    OffsetCurveBuilder.prototype.computeRingBufferCurve = function computeRingBufferCurve (inputPts, side, segGen) {
      var distTol = this.simplifyTolerance(this._distance);
      if (side === Position.RIGHT) { distTol = -distTol; }
      var simp = BufferInputLineSimplifier.simplify(inputPts, distTol);
      var n = simp.length - 1;
      segGen.initSideSegments(simp[n - 1], simp[0], side);
      for (var i = 1; i <= n; i++) {
        var addStartPoint = i !== 1;
        segGen.addNextSegment(simp[i], addStartPoint);
      }
      segGen.closeRing();
    };
    OffsetCurveBuilder.prototype.computeLineBufferCurve = function computeLineBufferCurve (inputPts, segGen) {
      var distTol = this.simplifyTolerance(this._distance);
      var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
      var n1 = simp1.length - 1;
      segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
      for (var i = 2; i <= n1; i++) {
        segGen.addNextSegment(simp1[i], true);
      }
      segGen.addLastSegment();
      segGen.addLineEndCap(simp1[n1 - 1], simp1[n1]);
      var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
      var n2 = simp2.length - 1;
      segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
      for (var i$1 = n2 - 2; i$1 >= 0; i$1--) {
        segGen.addNextSegment(simp2[i$1], true);
      }
      segGen.addLastSegment();
      segGen.addLineEndCap(simp2[1], simp2[0]);
      segGen.closeRing();
    };
    OffsetCurveBuilder.prototype.computePointCurve = function computePointCurve (pt, segGen) {
      switch (this._bufParams.getEndCapStyle()) {
        case BufferParameters.CAP_ROUND:
          segGen.createCircle(pt);
          break
        case BufferParameters.CAP_SQUARE:
          segGen.createSquare(pt);
          break
        default:
      }
    };
    OffsetCurveBuilder.prototype.getLineCurve = function getLineCurve (inputPts, distance) {
      this._distance = distance;
      if (distance < 0.0 && !this._bufParams.isSingleSided()) { return null }
      if (distance === 0.0) { return null }
      var posDistance = Math.abs(distance);
      var segGen = this.getSegGen(posDistance);
      if (inputPts.length <= 1) {
        this.computePointCurve(inputPts[0], segGen);
      } else {
        if (this._bufParams.isSingleSided()) {
          var isRightSide = distance < 0.0;
          this.computeSingleSidedBufferCurve(inputPts, isRightSide, segGen);
        } else { this.computeLineBufferCurve(inputPts, segGen); }
      }
      var lineCoord = segGen.getCoordinates();
      return lineCoord
    };
    OffsetCurveBuilder.prototype.getBufferParameters = function getBufferParameters () {
      return this._bufParams
    };
    OffsetCurveBuilder.prototype.simplifyTolerance = function simplifyTolerance (bufDistance) {
      return bufDistance * this._bufParams.getSimplifyFactor()
    };
    OffsetCurveBuilder.prototype.getRingCurve = function getRingCurve (inputPts, side, distance) {
      this._distance = distance;
      if (inputPts.length <= 2) { return this.getLineCurve(inputPts, distance) }
      if (distance === 0.0) {
        return OffsetCurveBuilder.copyCoordinates(inputPts)
      }
      var segGen = this.getSegGen(distance);
      this.computeRingBufferCurve(inputPts, side, segGen);
      return segGen.getCoordinates()
    };
    OffsetCurveBuilder.prototype.computeOffsetCurve = function computeOffsetCurve (inputPts, isRightSide, segGen) {
      var distTol = this.simplifyTolerance(this._distance);
      if (isRightSide) {
        var simp2 = BufferInputLineSimplifier.simplify(inputPts, -distTol);
        var n2 = simp2.length - 1;
        segGen.initSideSegments(simp2[n2], simp2[n2 - 1], Position.LEFT);
        segGen.addFirstSegment();
        for (var i = n2 - 2; i >= 0; i--) {
          segGen.addNextSegment(simp2[i], true);
        }
      } else {
        var simp1 = BufferInputLineSimplifier.simplify(inputPts, distTol);
        var n1 = simp1.length - 1;
        segGen.initSideSegments(simp1[0], simp1[1], Position.LEFT);
        segGen.addFirstSegment();
        for (var i$1 = 2; i$1 <= n1; i$1++) {
          segGen.addNextSegment(simp1[i$1], true);
        }
      }
      segGen.addLastSegment();
    };
    OffsetCurveBuilder.prototype.getSegGen = function getSegGen (distance) {
      return new OffsetSegmentGenerator(this._precisionModel, this._bufParams, distance)
    };
    OffsetCurveBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OffsetCurveBuilder.prototype.getClass = function getClass () {
      return OffsetCurveBuilder
    };
    OffsetCurveBuilder.copyCoordinates = function copyCoordinates (pts) {
      var copy = new Array(pts.length).fill(null);
      for (var i = 0; i < copy.length; i++) {
        copy[i] = new Coordinate(pts[i]);
      }
      return copy
    };

    var SubgraphDepthLocater = function SubgraphDepthLocater () {
      this._subgraphs = null;
      this._seg = new LineSegment();
      this._cga = new CGAlgorithms();
      var subgraphs = arguments[0];
      this._subgraphs = subgraphs;
    };

    var staticAccessors$30 = { DepthSegment: { configurable: true } };
    SubgraphDepthLocater.prototype.findStabbedSegments = function findStabbedSegments () {
        var this$1 = this;

      if (arguments.length === 1) {
        var stabbingRayLeftPt = arguments[0];
        var stabbedSegments = new ArrayList();
        for (var i = this._subgraphs.iterator(); i.hasNext();) {
          var bsg = i.next();
          var env = bsg.getEnvelope();
          if (stabbingRayLeftPt.y < env.getMinY() || stabbingRayLeftPt.y > env.getMaxY()) { continue }
          this$1.findStabbedSegments(stabbingRayLeftPt, bsg.getDirectedEdges(), stabbedSegments);
        }
        return stabbedSegments
      } else if (arguments.length === 3) {
        if (hasInterface(arguments[2], List) && (arguments[0] instanceof Coordinate && arguments[1] instanceof DirectedEdge)) {
          var stabbingRayLeftPt$1 = arguments[0];
          var dirEdge = arguments[1];
          var stabbedSegments$1 = arguments[2];
          var pts = dirEdge.getEdge().getCoordinates();
          for (var i$1 = 0; i$1 < pts.length - 1; i$1++) {
            this$1._seg.p0 = pts[i$1];
            this$1._seg.p1 = pts[i$1 + 1];
            if (this$1._seg.p0.y > this$1._seg.p1.y) { this$1._seg.reverse(); }
            var maxx = Math.max(this$1._seg.p0.x, this$1._seg.p1.x);
            if (maxx < stabbingRayLeftPt$1.x) { continue }
            if (this$1._seg.isHorizontal()) { continue }
            if (stabbingRayLeftPt$1.y < this$1._seg.p0.y || stabbingRayLeftPt$1.y > this$1._seg.p1.y) { continue }
            if (CGAlgorithms.computeOrientation(this$1._seg.p0, this$1._seg.p1, stabbingRayLeftPt$1) === CGAlgorithms.RIGHT) { continue }
            var depth = dirEdge.getDepth(Position.LEFT);
            if (!this$1._seg.p0.equals(pts[i$1])) { depth = dirEdge.getDepth(Position.RIGHT); }
            var ds = new DepthSegment(this$1._seg, depth);
            stabbedSegments$1.add(ds);
          }
        } else if (hasInterface(arguments[2], List) && (arguments[0] instanceof Coordinate && hasInterface(arguments[1], List))) {
          var stabbingRayLeftPt$2 = arguments[0];
          var dirEdges = arguments[1];
          var stabbedSegments$2 = arguments[2];
          for (var i$2 = dirEdges.iterator(); i$2.hasNext();) {
            var de = i$2.next();
            if (!de.isForward()) { continue }
            this$1.findStabbedSegments(stabbingRayLeftPt$2, de, stabbedSegments$2);
          }
        }
      }
    };
    SubgraphDepthLocater.prototype.getDepth = function getDepth (p) {
      var stabbedSegments = this.findStabbedSegments(p);
      if (stabbedSegments.size() === 0) { return 0 }
      var ds = Collections.min(stabbedSegments);
      return ds._leftDepth
    };
    SubgraphDepthLocater.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SubgraphDepthLocater.prototype.getClass = function getClass () {
      return SubgraphDepthLocater
    };
    staticAccessors$30.DepthSegment.get = function () { return DepthSegment };

    Object.defineProperties( SubgraphDepthLocater, staticAccessors$30 );

    var DepthSegment = function DepthSegment () {
      this._upwardSeg = null;
      this._leftDepth = null;
      var seg = arguments[0];
      var depth = arguments[1];
      this._upwardSeg = new LineSegment(seg);
      this._leftDepth = depth;
    };
    DepthSegment.prototype.compareTo = function compareTo (obj) {
      var other = obj;
      if (this._upwardSeg.minX() >= other._upwardSeg.maxX()) { return 1 }
      if (this._upwardSeg.maxX() <= other._upwardSeg.minX()) { return -1 }
      var orientIndex = this._upwardSeg.orientationIndex(other._upwardSeg);
      if (orientIndex !== 0) { return orientIndex }
      orientIndex = -1 * other._upwardSeg.orientationIndex(this._upwardSeg);
      if (orientIndex !== 0) { return orientIndex }
      return this._upwardSeg.compareTo(other._upwardSeg)
    };
    DepthSegment.prototype.compareX = function compareX (seg0, seg1) {
      var compare0 = seg0.p0.compareTo(seg1.p0);
      if (compare0 !== 0) { return compare0 }
      return seg0.p1.compareTo(seg1.p1)
    };
    DepthSegment.prototype.toString = function toString () {
      return this._upwardSeg.toString()
    };
    DepthSegment.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    DepthSegment.prototype.getClass = function getClass () {
      return DepthSegment
    };

    var Triangle$1 = function Triangle (p0, p1, p2) {
      this.p0 = p0 || null;
      this.p1 = p1 || null;
      this.p2 = p2 || null;
    };
    Triangle$1.prototype.area = function area () {
      return Triangle$1.area(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.signedArea = function signedArea () {
      return Triangle$1.signedArea(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.interpolateZ = function interpolateZ (p) {
      if (p === null) { throw new IllegalArgumentException('Supplied point is null.') }
      return Triangle$1.interpolateZ(p, this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.longestSideLength = function longestSideLength () {
      return Triangle$1.longestSideLength(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.isAcute = function isAcute () {
      return Triangle$1.isAcute(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.circumcentre = function circumcentre () {
      return Triangle$1.circumcentre(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.area3D = function area3D () {
      return Triangle$1.area3D(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.centroid = function centroid () {
      return Triangle$1.centroid(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.inCentre = function inCentre () {
      return Triangle$1.inCentre(this.p0, this.p1, this.p2)
    };
    Triangle$1.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Triangle$1.prototype.getClass = function getClass () {
      return Triangle$1
    };
    Triangle$1.area = function area (a, b, c) {
      return Math.abs(((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2)
    };
    Triangle$1.signedArea = function signedArea (a, b, c) {
      return ((c.x - a.x) * (b.y - a.y) - (b.x - a.x) * (c.y - a.y)) / 2
    };
    Triangle$1.det = function det (m00, m01, m10, m11) {
      return m00 * m11 - m01 * m10
    };
    Triangle$1.interpolateZ = function interpolateZ (p, v0, v1, v2) {
      var x0 = v0.x;
      var y0 = v0.y;
      var a = v1.x - x0;
      var b = v2.x - x0;
      var c = v1.y - y0;
      var d = v2.y - y0;
      var det = a * d - b * c;
      var dx = p.x - x0;
      var dy = p.y - y0;
      var t = (d * dx - b * dy) / det;
      var u = (-c * dx + a * dy) / det;
      var z = v0.z + t * (v1.z - v0.z) + u * (v2.z - v0.z);
      return z
    };
    Triangle$1.longestSideLength = function longestSideLength (a, b, c) {
      var lenAB = a.distance(b);
      var lenBC = b.distance(c);
      var lenCA = c.distance(a);
      var maxLen = lenAB;
      if (lenBC > maxLen) { maxLen = lenBC; }
      if (lenCA > maxLen) { maxLen = lenCA; }
      return maxLen
    };
    Triangle$1.isAcute = function isAcute (a, b, c) {
      if (!Angle.isAcute(a, b, c)) { return false }
      if (!Angle.isAcute(b, c, a)) { return false }
      if (!Angle.isAcute(c, a, b)) { return false }
      return true
    };
    Triangle$1.circumcentre = function circumcentre (a, b, c) {
      var cx = c.x;
      var cy = c.y;
      var ax = a.x - cx;
      var ay = a.y - cy;
      var bx = b.x - cx;
      var by = b.y - cy;
      var denom = 2 * Triangle$1.det(ax, ay, bx, by);
      var numx = Triangle$1.det(ay, ax * ax + ay * ay, by, bx * bx + by * by);
      var numy = Triangle$1.det(ax, ax * ax + ay * ay, bx, bx * bx + by * by);
      var ccx = cx - numx / denom;
      var ccy = cy + numy / denom;
      return new Coordinate(ccx, ccy)
    };
    Triangle$1.perpendicularBisector = function perpendicularBisector (a, b) {
      var dx = b.x - a.x;
      var dy = b.y - a.y;
      var l1 = new HCoordinate(a.x + dx / 2.0, a.y + dy / 2.0, 1.0);
      var l2 = new HCoordinate(a.x - dy + dx / 2.0, a.y + dx + dy / 2.0, 1.0);
      return new HCoordinate(l1, l2)
    };
    Triangle$1.angleBisector = function angleBisector (a, b, c) {
      var len0 = b.distance(a);
      var len2 = b.distance(c);
      var frac = len0 / (len0 + len2);
      var dx = c.x - a.x;
      var dy = c.y - a.y;
      var splitPt = new Coordinate(a.x + frac * dx, a.y + frac * dy);
      return splitPt
    };
    Triangle$1.area3D = function area3D (a, b, c) {
      var ux = b.x - a.x;
      var uy = b.y - a.y;
      var uz = b.z - a.z;
      var vx = c.x - a.x;
      var vy = c.y - a.y;
      var vz = c.z - a.z;
      var crossx = uy * vz - uz * vy;
      var crossy = uz * vx - ux * vz;
      var crossz = ux * vy - uy * vx;
      var absSq = crossx * crossx + crossy * crossy + crossz * crossz;
      var area3D = Math.sqrt(absSq) / 2;
      return area3D
    };
    Triangle$1.centroid = function centroid (a, b, c) {
      var x = (a.x + b.x + c.x) / 3;
      var y = (a.y + b.y + c.y) / 3;
      return new Coordinate(x, y)
    };
    Triangle$1.inCentre = function inCentre (a, b, c) {
      var len0 = b.distance(c);
      var len1 = a.distance(c);
      var len2 = a.distance(b);
      var circum = len0 + len1 + len2;
      var inCentreX = (len0 * a.x + len1 * b.x + len2 * c.x) / circum;
      var inCentreY = (len0 * a.y + len1 * b.y + len2 * c.y) / circum;
      return new Coordinate(inCentreX, inCentreY)
    };

    var OffsetCurveSetBuilder = function OffsetCurveSetBuilder () {
      this._inputGeom = null;
      this._distance = null;
      this._curveBuilder = null;
      this._curveList = new ArrayList();
      var inputGeom = arguments[0];
      var distance = arguments[1];
      var curveBuilder = arguments[2];
      this._inputGeom = inputGeom;
      this._distance = distance;
      this._curveBuilder = curveBuilder;
    };
    OffsetCurveSetBuilder.prototype.addPoint = function addPoint (p) {
      if (this._distance <= 0.0) { return null }
      var coord = p.getCoordinates();
      var curve = this._curveBuilder.getLineCurve(coord, this._distance);
      this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);
    };
    OffsetCurveSetBuilder.prototype.addPolygon = function addPolygon (p) {
        var this$1 = this;

      var offsetDistance = this._distance;
      var offsetSide = Position.LEFT;
      if (this._distance < 0.0) {
        offsetDistance = -this._distance;
        offsetSide = Position.RIGHT;
      }
      var shell = p.getExteriorRing();
      var shellCoord = CoordinateArrays.removeRepeatedPoints(shell.getCoordinates());
      if (this._distance < 0.0 && this.isErodedCompletely(shell, this._distance)) { return null }
      if (this._distance <= 0.0 && shellCoord.length < 3) { return null }
      this.addPolygonRing(shellCoord, offsetDistance, offsetSide, Location.EXTERIOR, Location.INTERIOR);
      for (var i = 0; i < p.getNumInteriorRing(); i++) {
        var hole = p.getInteriorRingN(i);
        var holeCoord = CoordinateArrays.removeRepeatedPoints(hole.getCoordinates());
        if (this$1._distance > 0.0 && this$1.isErodedCompletely(hole, -this$1._distance)) { continue }
        this$1.addPolygonRing(holeCoord, offsetDistance, Position.opposite(offsetSide), Location.INTERIOR, Location.EXTERIOR);
      }
    };
    OffsetCurveSetBuilder.prototype.isTriangleErodedCompletely = function isTriangleErodedCompletely (triangleCoord, bufferDistance) {
      var tri = new Triangle$1(triangleCoord[0], triangleCoord[1], triangleCoord[2]);
      var inCentre = tri.inCentre();
      var distToCentre = CGAlgorithms.distancePointLine(inCentre, tri.p0, tri.p1);
      return distToCentre < Math.abs(bufferDistance)
    };
    OffsetCurveSetBuilder.prototype.addLineString = function addLineString (line) {
      if (this._distance <= 0.0 && !this._curveBuilder.getBufferParameters().isSingleSided()) { return null }
      var coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
      var curve = this._curveBuilder.getLineCurve(coord, this._distance);
      this.addCurve(curve, Location.EXTERIOR, Location.INTERIOR);
    };
    OffsetCurveSetBuilder.prototype.addCurve = function addCurve (coord, leftLoc, rightLoc) {
      if (coord === null || coord.length < 2) { return null }
      var e = new NodedSegmentString(coord, new Label(0, Location.BOUNDARY, leftLoc, rightLoc));
      this._curveList.add(e);
    };
    OffsetCurveSetBuilder.prototype.getCurves = function getCurves () {
      this.add(this._inputGeom);
      return this._curveList
    };
    OffsetCurveSetBuilder.prototype.addPolygonRing = function addPolygonRing (coord, offsetDistance, side, cwLeftLoc, cwRightLoc) {
      if (offsetDistance === 0.0 && coord.length < LinearRing.MINIMUM_VALID_SIZE) { return null }
      var leftLoc = cwLeftLoc;
      var rightLoc = cwRightLoc;
      if (coord.length >= LinearRing.MINIMUM_VALID_SIZE && CGAlgorithms.isCCW(coord)) {
        leftLoc = cwRightLoc;
        rightLoc = cwLeftLoc;
        side = Position.opposite(side);
      }
      var curve = this._curveBuilder.getRingCurve(coord, side, offsetDistance);
      this.addCurve(curve, leftLoc, rightLoc);
    };
    OffsetCurveSetBuilder.prototype.add = function add (g) {
      if (g.isEmpty()) { return null }
      if (g instanceof Polygon) { this.addPolygon(g); }
      else if (g instanceof LineString$1) { this.addLineString(g); }
      else if (g instanceof Point) { this.addPoint(g); }
      else if (g instanceof MultiPoint) { this.addCollection(g); }
      else if (g instanceof MultiLineString) { this.addCollection(g); }
      else if (g instanceof MultiPolygon) { this.addCollection(g); }
      else if (g instanceof GeometryCollection) { this.addCollection(g); }
      // else throw new UnsupportedOperationException(g.getClass().getName())
    };
    OffsetCurveSetBuilder.prototype.isErodedCompletely = function isErodedCompletely (ring, bufferDistance) {
      var ringCoord = ring.getCoordinates();
      // const minDiam = 0.0
      if (ringCoord.length < 4) { return bufferDistance < 0 }
      if (ringCoord.length === 4) { return this.isTriangleErodedCompletely(ringCoord, bufferDistance) }
      var env = ring.getEnvelopeInternal();
      var envMinDimension = Math.min(env.getHeight(), env.getWidth());
      if (bufferDistance < 0.0 && 2 * Math.abs(bufferDistance) > envMinDimension) { return true }
      return false
    };
    OffsetCurveSetBuilder.prototype.addCollection = function addCollection (gc) {
        var this$1 = this;

      for (var i = 0; i < gc.getNumGeometries(); i++) {
        var g = gc.getGeometryN(i);
        this$1.add(g);
      }
    };
    OffsetCurveSetBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OffsetCurveSetBuilder.prototype.getClass = function getClass () {
      return OffsetCurveSetBuilder
    };

    var PointOnGeometryLocator = function PointOnGeometryLocator () {};

    PointOnGeometryLocator.prototype.locate = function locate (p) {};
    PointOnGeometryLocator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PointOnGeometryLocator.prototype.getClass = function getClass () {
      return PointOnGeometryLocator
    };

    var GeometryCollectionIterator = function GeometryCollectionIterator () {
      this._parent = null;
      this._atStart = null;
      this._max = null;
      this._index = null;
      this._subcollectionIterator = null;
      var parent = arguments[0];
      this._parent = parent;
      this._atStart = true;
      this._index = 0;
      this._max = parent.getNumGeometries();
    };
    GeometryCollectionIterator.prototype.next = function next () {
      if (this._atStart) {
        this._atStart = false;
        if (GeometryCollectionIterator.isAtomic(this._parent)) { this._index++; }
        return this._parent
      }
      if (this._subcollectionIterator !== null) {
        if (this._subcollectionIterator.hasNext()) {
          return this._subcollectionIterator.next()
        } else {
          this._subcollectionIterator = null;
        }
      }
      if (this._index >= this._max) {
        throw new NoSuchElementException()
      }
      var obj = this._parent.getGeometryN(this._index++);
      if (obj instanceof GeometryCollection) {
        this._subcollectionIterator = new GeometryCollectionIterator(obj);
        return this._subcollectionIterator.next()
      }
      return obj
    };
    GeometryCollectionIterator.prototype.remove = function remove () {
      throw new Error(this.getClass().getName())
    };
    GeometryCollectionIterator.prototype.hasNext = function hasNext () {
      if (this._atStart) {
        return true
      }
      if (this._subcollectionIterator !== null) {
        if (this._subcollectionIterator.hasNext()) {
          return true
        }
        this._subcollectionIterator = null;
      }
      if (this._index >= this._max) {
        return false
      }
      return true
    };
    GeometryCollectionIterator.prototype.interfaces_ = function interfaces_ () {
      return [Iterator]
    };
    GeometryCollectionIterator.prototype.getClass = function getClass () {
      return GeometryCollectionIterator
    };
    GeometryCollectionIterator.isAtomic = function isAtomic (geom) {
      return !(geom instanceof GeometryCollection)
    };

    var SimplePointInAreaLocator = function SimplePointInAreaLocator () {
      this._geom = null;
      var geom = arguments[0];
      this._geom = geom;
    };
    SimplePointInAreaLocator.prototype.locate = function locate (p) {
      return SimplePointInAreaLocator.locate(p, this._geom)
    };
    SimplePointInAreaLocator.prototype.interfaces_ = function interfaces_ () {
      return [PointOnGeometryLocator]
    };
    SimplePointInAreaLocator.prototype.getClass = function getClass () {
      return SimplePointInAreaLocator
    };
    SimplePointInAreaLocator.isPointInRing = function isPointInRing (p, ring) {
      if (!ring.getEnvelopeInternal().intersects(p)) { return false }
      return CGAlgorithms.isPointInRing(p, ring.getCoordinates())
    };
    SimplePointInAreaLocator.containsPointInPolygon = function containsPointInPolygon (p, poly) {
      if (poly.isEmpty()) { return false }
      var shell = poly.getExteriorRing();
      if (!SimplePointInAreaLocator.isPointInRing(p, shell)) { return false }
      for (var i = 0; i < poly.getNumInteriorRing(); i++) {
        var hole = poly.getInteriorRingN(i);
        if (SimplePointInAreaLocator.isPointInRing(p, hole)) { return false }
      }
      return true
    };
    SimplePointInAreaLocator.containsPoint = function containsPoint (p, geom) {
      if (geom instanceof Polygon) {
        return SimplePointInAreaLocator.containsPointInPolygon(p, geom)
      } else if (geom instanceof GeometryCollection) {
        var geomi = new GeometryCollectionIterator(geom);
        while (geomi.hasNext()) {
          var g2 = geomi.next();
          if (g2 !== geom) { if (SimplePointInAreaLocator.containsPoint(p, g2)) { return true } }
        }
      }
      return false
    };
    SimplePointInAreaLocator.locate = function locate (p, geom) {
      if (geom.isEmpty()) { return Location.EXTERIOR }
      if (SimplePointInAreaLocator.containsPoint(p, geom)) { return Location.INTERIOR }
      return Location.EXTERIOR
    };

    var EdgeEndStar = function EdgeEndStar () {
      this._edgeMap = new TreeMap();
      this._edgeList = null;
      this._ptInAreaLocation = [Location.NONE, Location.NONE];
    };
    EdgeEndStar.prototype.getNextCW = function getNextCW (ee) {
      this.getEdges();
      var i = this._edgeList.indexOf(ee);
      var iNextCW = i - 1;
      if (i === 0) { iNextCW = this._edgeList.size() - 1; }
      return this._edgeList.get(iNextCW)
    };
    EdgeEndStar.prototype.propagateSideLabels = function propagateSideLabels (geomIndex) {
      var startLoc = Location.NONE;
      for (var it = this.iterator(); it.hasNext();) {
        var e = it.next();
        var label = e.getLabel();
        if (label.isArea(geomIndex) && label.getLocation(geomIndex, Position.LEFT) !== Location.NONE) { startLoc = label.getLocation(geomIndex, Position.LEFT); }
      }
      if (startLoc === Location.NONE) { return null }
      var currLoc = startLoc;
      for (var it$1 = this.iterator(); it$1.hasNext();) {
        var e$1 = it$1.next();
        var label$1 = e$1.getLabel();
        if (label$1.getLocation(geomIndex, Position.ON) === Location.NONE) { label$1.setLocation(geomIndex, Position.ON, currLoc); }
        if (label$1.isArea(geomIndex)) {
          var leftLoc = label$1.getLocation(geomIndex, Position.LEFT);
          var rightLoc = label$1.getLocation(geomIndex, Position.RIGHT);
          if (rightLoc !== Location.NONE) {
            if (rightLoc !== currLoc) { throw new TopologyException('side location conflict', e$1.getCoordinate()) }
            if (leftLoc === Location.NONE) {
              Assert.shouldNeverReachHere('found single null side (at ' + e$1.getCoordinate() + ')');
            }
            currLoc = leftLoc;
          } else {
            Assert.isTrue(label$1.getLocation(geomIndex, Position.LEFT) === Location.NONE, 'found single null side');
            label$1.setLocation(geomIndex, Position.RIGHT, currLoc);
            label$1.setLocation(geomIndex, Position.LEFT, currLoc);
          }
        }
      }
    };
    EdgeEndStar.prototype.getCoordinate = function getCoordinate () {
      var it = this.iterator();
      if (!it.hasNext()) { return null }
      var e = it.next();
      return e.getCoordinate()
    };
    EdgeEndStar.prototype.print = function print (out) {
      System.out.println('EdgeEndStar:   ' + this.getCoordinate());
      for (var it = this.iterator(); it.hasNext();) {
        var e = it.next();
        e.print(out);
      }
    };
    EdgeEndStar.prototype.isAreaLabelsConsistent = function isAreaLabelsConsistent (geomGraph) {
      this.computeEdgeEndLabels(geomGraph.getBoundaryNodeRule());
      return this.checkAreaLabelsConsistent(0)
    };
    EdgeEndStar.prototype.checkAreaLabelsConsistent = function checkAreaLabelsConsistent (geomIndex) {
      var edges = this.getEdges();
      if (edges.size() <= 0) { return true }
      var lastEdgeIndex = edges.size() - 1;
      var startLabel = edges.get(lastEdgeIndex).getLabel();
      var startLoc = startLabel.getLocation(geomIndex, Position.LEFT);
      Assert.isTrue(startLoc !== Location.NONE, 'Found unlabelled area edge');
      var currLoc = startLoc;
      for (var it = this.iterator(); it.hasNext();) {
        var e = it.next();
        var label = e.getLabel();
        Assert.isTrue(label.isArea(geomIndex), 'Found non-area edge');
        var leftLoc = label.getLocation(geomIndex, Position.LEFT);
        var rightLoc = label.getLocation(geomIndex, Position.RIGHT);
        if (leftLoc === rightLoc) {
          return false
        }
        if (rightLoc !== currLoc) {
          return false
        }
        currLoc = leftLoc;
      }
      return true
    };
    EdgeEndStar.prototype.findIndex = function findIndex (eSearch) {
        var this$1 = this;

      this.iterator();
      for (var i = 0; i < this._edgeList.size(); i++) {
        var e = this$1._edgeList.get(i);
        if (e === eSearch) { return i }
      }
      return -1
    };
    EdgeEndStar.prototype.iterator = function iterator () {
      return this.getEdges().iterator()
    };
    EdgeEndStar.prototype.getEdges = function getEdges () {
      if (this._edgeList === null) {
        this._edgeList = new ArrayList(this._edgeMap.values());
      }
      return this._edgeList
    };
    EdgeEndStar.prototype.getLocation = function getLocation (geomIndex, p, geom) {
      if (this._ptInAreaLocation[geomIndex] === Location.NONE) {
        this._ptInAreaLocation[geomIndex] = SimplePointInAreaLocator.locate(p, geom[geomIndex].getGeometry());
      }
      return this._ptInAreaLocation[geomIndex]
    };
    EdgeEndStar.prototype.toString = function toString () {
      var buf = new StringBuffer();
      buf.append('EdgeEndStar:   ' + this.getCoordinate());
      buf.append('\n');
      for (var it = this.iterator(); it.hasNext();) {
        var e = it.next();
        buf.append(e);
        buf.append('\n');
      }
      return buf.toString()
    };
    EdgeEndStar.prototype.computeEdgeEndLabels = function computeEdgeEndLabels (boundaryNodeRule) {
      for (var it = this.iterator(); it.hasNext();) {
        var ee = it.next();
        ee.computeLabel(boundaryNodeRule);
      }
    };
    EdgeEndStar.prototype.computeLabelling = function computeLabelling (geomGraph) {
        var this$1 = this;

      this.computeEdgeEndLabels(geomGraph[0].getBoundaryNodeRule());
      this.propagateSideLabels(0);
      this.propagateSideLabels(1);
      var hasDimensionalCollapseEdge = [false, false];
      for (var it = this.iterator(); it.hasNext();) {
        var e = it.next();
        var label = e.getLabel();
        for (var geomi = 0; geomi < 2; geomi++) {
          if (label.isLine(geomi) && label.getLocation(geomi) === Location.BOUNDARY) { hasDimensionalCollapseEdge[geomi] = true; }
        }
      }
      for (var it$1 = this.iterator(); it$1.hasNext();) {
        var e$1 = it$1.next();
        var label$1 = e$1.getLabel();
        for (var geomi$1 = 0; geomi$1 < 2; geomi$1++) {
          if (label$1.isAnyNull(geomi$1)) {
            var loc = Location.NONE;
            if (hasDimensionalCollapseEdge[geomi$1]) {
              loc = Location.EXTERIOR;
            } else {
              var p = e$1.getCoordinate();
              loc = this$1.getLocation(geomi$1, p, geomGraph);
            }
            label$1.setAllLocationsIfNull(geomi$1, loc);
          }
        }
      }
    };
    EdgeEndStar.prototype.getDegree = function getDegree () {
      return this._edgeMap.size()
    };
    EdgeEndStar.prototype.insertEdgeEnd = function insertEdgeEnd (e, obj) {
      this._edgeMap.put(e, obj);
      this._edgeList = null;
    };
    EdgeEndStar.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeEndStar.prototype.getClass = function getClass () {
      return EdgeEndStar
    };

    var DirectedEdgeStar = (function (EdgeEndStar$$1) {
      function DirectedEdgeStar () {
        EdgeEndStar$$1.call(this);
        this._resultAreaEdgeList = null;
        this._label = null;
        this._SCANNING_FOR_INCOMING = 1;
        this._LINKING_TO_OUTGOING = 2;
      }

      if ( EdgeEndStar$$1 ) DirectedEdgeStar.__proto__ = EdgeEndStar$$1;
      DirectedEdgeStar.prototype = Object.create( EdgeEndStar$$1 && EdgeEndStar$$1.prototype );
      DirectedEdgeStar.prototype.constructor = DirectedEdgeStar;
      DirectedEdgeStar.prototype.linkResultDirectedEdges = function linkResultDirectedEdges () {
        var this$1 = this;

        this.getResultAreaEdges();
        var firstOut = null;
        var incoming = null;
        var state = this._SCANNING_FOR_INCOMING;
        for (var i = 0; i < this._resultAreaEdgeList.size(); i++) {
          var nextOut = this$1._resultAreaEdgeList.get(i);
          var nextIn = nextOut.getSym();
          if (!nextOut.getLabel().isArea()) { continue }
          if (firstOut === null && nextOut.isInResult()) { firstOut = nextOut; }
          switch (state) {
            case this$1._SCANNING_FOR_INCOMING:
              if (!nextIn.isInResult()) { continue }
              incoming = nextIn;
              state = this$1._LINKING_TO_OUTGOING;
              break
            case this$1._LINKING_TO_OUTGOING:
              if (!nextOut.isInResult()) { continue }
              incoming.setNext(nextOut);
              state = this$1._SCANNING_FOR_INCOMING;
              break
            default:
          }
        }
        if (state === this._LINKING_TO_OUTGOING) {
          if (firstOut === null) { throw new TopologyException('no outgoing dirEdge found', this.getCoordinate()) }
          Assert.isTrue(firstOut.isInResult(), 'unable to link last incoming dirEdge');
          incoming.setNext(firstOut);
        }
      };
      DirectedEdgeStar.prototype.insert = function insert (ee) {
        var de = ee;
        this.insertEdgeEnd(de, de);
      };
      DirectedEdgeStar.prototype.getRightmostEdge = function getRightmostEdge () {
        var edges = this.getEdges();
        var size = edges.size();
        if (size < 1) { return null }
        var de0 = edges.get(0);
        if (size === 1) { return de0 }
        var deLast = edges.get(size - 1);
        var quad0 = de0.getQuadrant();
        var quad1 = deLast.getQuadrant();
        if (Quadrant.isNorthern(quad0) && Quadrant.isNorthern(quad1)) { return de0; } else if (!Quadrant.isNorthern(quad0) && !Quadrant.isNorthern(quad1)) { return deLast; } else {
          // const nonHorizontalEdge = null
          if (de0.getDy() !== 0) { return de0; } else if (deLast.getDy() !== 0) { return deLast }
        }
        Assert.shouldNeverReachHere('found two horizontal edges incident on node');
        return null
      };
      DirectedEdgeStar.prototype.print = function print (out) {
        System.out.println('DirectedEdgeStar: ' + this.getCoordinate());
        for (var it = this.iterator(); it.hasNext();) {
          var de = it.next();
          out.print('out ');
          de.print(out);
          out.println();
          out.print('in ');
          de.getSym().print(out);
          out.println();
        }
      };
      DirectedEdgeStar.prototype.getResultAreaEdges = function getResultAreaEdges () {
        var this$1 = this;

        if (this._resultAreaEdgeList !== null) { return this._resultAreaEdgeList }
        this._resultAreaEdgeList = new ArrayList();
        for (var it = this.iterator(); it.hasNext();) {
          var de = it.next();
          if (de.isInResult() || de.getSym().isInResult()) { this$1._resultAreaEdgeList.add(de); }
        }
        return this._resultAreaEdgeList
      };
      DirectedEdgeStar.prototype.updateLabelling = function updateLabelling (nodeLabel) {
        for (var it = this.iterator(); it.hasNext();) {
          var de = it.next();
          var label = de.getLabel();
          label.setAllLocationsIfNull(0, nodeLabel.getLocation(0));
          label.setAllLocationsIfNull(1, nodeLabel.getLocation(1));
        }
      };
      DirectedEdgeStar.prototype.linkAllDirectedEdges = function linkAllDirectedEdges () {
        var this$1 = this;

        this.getEdges();
        var prevOut = null;
        var firstIn = null;
        for (var i = this._edgeList.size() - 1; i >= 0; i--) {
          var nextOut = this$1._edgeList.get(i);
          var nextIn = nextOut.getSym();
          if (firstIn === null) { firstIn = nextIn; }
          if (prevOut !== null) { nextIn.setNext(prevOut); }
          prevOut = nextOut;
        }
        firstIn.setNext(prevOut);
      };
      DirectedEdgeStar.prototype.computeDepths = function computeDepths () {
        var this$1 = this;

        if (arguments.length === 1) {
          var de = arguments[0];
          var edgeIndex = this.findIndex(de);
          // const label = de.getLabel()
          var startDepth = de.getDepth(Position.LEFT);
          var targetLastDepth = de.getDepth(Position.RIGHT);
          var nextDepth = this.computeDepths(edgeIndex + 1, this._edgeList.size(), startDepth);
          var lastDepth = this.computeDepths(0, edgeIndex, nextDepth);
          if (lastDepth !== targetLastDepth) { throw new TopologyException('depth mismatch at ' + de.getCoordinate()) }
        } else if (arguments.length === 3) {
          var startIndex = arguments[0];
          var endIndex = arguments[1];
          var startDepth$1 = arguments[2];
          var currDepth = startDepth$1;
          for (var i = startIndex; i < endIndex; i++) {
            var nextDe = this$1._edgeList.get(i);
            // const label = nextDe.getLabel()
            nextDe.setEdgeDepths(Position.RIGHT, currDepth);
            currDepth = nextDe.getDepth(Position.LEFT);
          }
          return currDepth
        }
      };
      DirectedEdgeStar.prototype.mergeSymLabels = function mergeSymLabels () {
        for (var it = this.iterator(); it.hasNext();) {
          var de = it.next();
          var label = de.getLabel();
          label.merge(de.getSym().getLabel());
        }
      };
      DirectedEdgeStar.prototype.linkMinimalDirectedEdges = function linkMinimalDirectedEdges (er) {
        var this$1 = this;

        var firstOut = null;
        var incoming = null;
        var state = this._SCANNING_FOR_INCOMING;
        for (var i = this._resultAreaEdgeList.size() - 1; i >= 0; i--) {
          var nextOut = this$1._resultAreaEdgeList.get(i);
          var nextIn = nextOut.getSym();
          if (firstOut === null && nextOut.getEdgeRing() === er) { firstOut = nextOut; }
          switch (state) {
            case this$1._SCANNING_FOR_INCOMING:
              if (nextIn.getEdgeRing() !== er) { continue }
              incoming = nextIn;
              state = this$1._LINKING_TO_OUTGOING;
              break
            case this$1._LINKING_TO_OUTGOING:
              if (nextOut.getEdgeRing() !== er) { continue }
              incoming.setNextMin(nextOut);
              state = this$1._SCANNING_FOR_INCOMING;
              break
            default:
          }
        }
        if (state === this._LINKING_TO_OUTGOING) {
          Assert.isTrue(firstOut !== null, 'found null for first outgoing dirEdge');
          Assert.isTrue(firstOut.getEdgeRing() === er, 'unable to link last incoming dirEdge');
          incoming.setNextMin(firstOut);
        }
      };
      DirectedEdgeStar.prototype.getOutgoingDegree = function getOutgoingDegree () {
        if (arguments.length === 0) {
          var degree = 0;
          for (var it = this.iterator(); it.hasNext();) {
            var de = it.next();
            if (de.isInResult()) { degree++; }
          }
          return degree
        } else if (arguments.length === 1) {
          var er = arguments[0];
          var degree$1 = 0;
          for (var it$1 = this.iterator(); it$1.hasNext();) {
            var de$1 = it$1.next();
            if (de$1.getEdgeRing() === er) { degree$1++; }
          }
          return degree$1
        }
      };
      DirectedEdgeStar.prototype.getLabel = function getLabel () {
        return this._label
      };
      DirectedEdgeStar.prototype.findCoveredLineEdges = function findCoveredLineEdges () {
        var startLoc = Location.NONE;
        for (var it = this.iterator(); it.hasNext();) {
          var nextOut = it.next();
          var nextIn = nextOut.getSym();
          if (!nextOut.isLineEdge()) {
            if (nextOut.isInResult()) {
              startLoc = Location.INTERIOR;
              break
            }
            if (nextIn.isInResult()) {
              startLoc = Location.EXTERIOR;
              break
            }
          }
        }
        if (startLoc === Location.NONE) { return null }
        var currLoc = startLoc;
        for (var it$1 = this.iterator(); it$1.hasNext();) {
          var nextOut$1 = it$1.next();
          var nextIn$1 = nextOut$1.getSym();
          if (nextOut$1.isLineEdge()) {
            nextOut$1.getEdge().setCovered(currLoc === Location.INTERIOR);
          } else {
            if (nextOut$1.isInResult()) { currLoc = Location.EXTERIOR; }
            if (nextIn$1.isInResult()) { currLoc = Location.INTERIOR; }
          }
        }
      };
      DirectedEdgeStar.prototype.computeLabelling = function computeLabelling (geom) {
        var this$1 = this;

        EdgeEndStar$$1.prototype.computeLabelling.call(this, geom);
        this._label = new Label(Location.NONE);
        for (var it = this.iterator(); it.hasNext();) {
          var ee = it.next();
          var e = ee.getEdge();
          var eLabel = e.getLabel();
          for (var i = 0; i < 2; i++) {
            var eLoc = eLabel.getLocation(i);
            if (eLoc === Location.INTERIOR || eLoc === Location.BOUNDARY) { this$1._label.setLocation(i, Location.INTERIOR); }
          }
        }
      };
      DirectedEdgeStar.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      DirectedEdgeStar.prototype.getClass = function getClass () {
        return DirectedEdgeStar
      };

      return DirectedEdgeStar;
    }(EdgeEndStar));

    var OverlayNodeFactory = (function (NodeFactory$$1) {
      function OverlayNodeFactory () {
        NodeFactory$$1.apply(this, arguments);
      }

      if ( NodeFactory$$1 ) OverlayNodeFactory.__proto__ = NodeFactory$$1;
      OverlayNodeFactory.prototype = Object.create( NodeFactory$$1 && NodeFactory$$1.prototype );
      OverlayNodeFactory.prototype.constructor = OverlayNodeFactory;

      OverlayNodeFactory.prototype.createNode = function createNode (coord) {
        return new Node$3(coord, new DirectedEdgeStar())
      };
      OverlayNodeFactory.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      OverlayNodeFactory.prototype.getClass = function getClass () {
        return OverlayNodeFactory
      };

      return OverlayNodeFactory;
    }(NodeFactory));

    var OrientedCoordinateArray = function OrientedCoordinateArray () {
      this._pts = null;
      this._orientation = null;
      var pts = arguments[0];
      this._pts = pts;
      this._orientation = OrientedCoordinateArray.orientation(pts);
    };
    OrientedCoordinateArray.prototype.compareTo = function compareTo (o1) {
      var oca = o1;
      var comp = OrientedCoordinateArray.compareOriented(this._pts, this._orientation, oca._pts, oca._orientation);
      return comp
    };
    OrientedCoordinateArray.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    OrientedCoordinateArray.prototype.getClass = function getClass () {
      return OrientedCoordinateArray
    };
    OrientedCoordinateArray.orientation = function orientation (pts) {
      return CoordinateArrays.increasingDirection(pts) === 1
    };
    OrientedCoordinateArray.compareOriented = function compareOriented (pts1, orientation1, pts2, orientation2) {
      var dir1 = orientation1 ? 1 : -1;
      var dir2 = orientation2 ? 1 : -1;
      var limit1 = orientation1 ? pts1.length : -1;
      var limit2 = orientation2 ? pts2.length : -1;
      var i1 = orientation1 ? 0 : pts1.length - 1;
      var i2 = orientation2 ? 0 : pts2.length - 1;
      // const comp = 0
      while (true) {
        var compPt = pts1[i1].compareTo(pts2[i2]);
        if (compPt !== 0) { return compPt }
        i1 += dir1;
        i2 += dir2;
        var done1 = i1 === limit1;
        var done2 = i2 === limit2;
        if (done1 && !done2) { return -1 }
        if (!done1 && done2) { return 1 }
        if (done1 && done2) { return 0 }
      }
    };

    var EdgeList = function EdgeList () {
      this._edges = new ArrayList();
      this._ocaMap = new TreeMap();
    };
    EdgeList.prototype.print = function print (out) {
        var this$1 = this;

      out.print('MULTILINESTRING ( ');
      for (var j = 0; j < this._edges.size(); j++) {
        var e = this$1._edges.get(j);
        if (j > 0) { out.print(','); }
        out.print('(');
        var pts = e.getCoordinates();
        for (var i = 0; i < pts.length; i++) {
          if (i > 0) { out.print(','); }
          out.print(pts[i].x + ' ' + pts[i].y);
        }
        out.println(')');
      }
      out.print(')  ');
    };
    EdgeList.prototype.addAll = function addAll (edgeColl) {
        var this$1 = this;

      for (var i = edgeColl.iterator(); i.hasNext();) {
        this$1.add(i.next());
      }
    };
    EdgeList.prototype.findEdgeIndex = function findEdgeIndex (e) {
        var this$1 = this;

      for (var i = 0; i < this._edges.size(); i++) {
        if (this$1._edges.get(i).equals(e)) { return i }
      }
      return -1
    };
    EdgeList.prototype.iterator = function iterator () {
      return this._edges.iterator()
    };
    EdgeList.prototype.getEdges = function getEdges () {
      return this._edges
    };
    EdgeList.prototype.get = function get (i) {
      return this._edges.get(i)
    };
    EdgeList.prototype.findEqualEdge = function findEqualEdge (e) {
      var oca = new OrientedCoordinateArray(e.getCoordinates());
      var matchEdge = this._ocaMap.get(oca);
      return matchEdge
    };
    EdgeList.prototype.add = function add (e) {
      this._edges.add(e);
      var oca = new OrientedCoordinateArray(e.getCoordinates());
      this._ocaMap.put(oca, e);
    };
    EdgeList.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeList.prototype.getClass = function getClass () {
      return EdgeList
    };

    var SegmentIntersector = function SegmentIntersector () {};

    SegmentIntersector.prototype.processIntersections = function processIntersections (e0, segIndex0, e1, segIndex1) {};
    SegmentIntersector.prototype.isDone = function isDone () {};
    SegmentIntersector.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SegmentIntersector.prototype.getClass = function getClass () {
      return SegmentIntersector
    };

    var IntersectionAdder = function IntersectionAdder () {
      this._hasIntersection = false;
      this._hasProper = false;
      this._hasProperInterior = false;
      this._hasInterior = false;
      this._properIntersectionPoint = null;
      this._li = null;
      this._isSelfIntersection = null;
      this.numIntersections = 0;
      this.numInteriorIntersections = 0;
      this.numProperIntersections = 0;
      this.numTests = 0;
      var li = arguments[0];
      this._li = li;
    };
    IntersectionAdder.prototype.isTrivialIntersection = function isTrivialIntersection (e0, segIndex0, e1, segIndex1) {
      if (e0 === e1) {
        if (this._li.getIntersectionNum() === 1) {
          if (IntersectionAdder.isAdjacentSegments(segIndex0, segIndex1)) { return true }
          if (e0.isClosed()) {
            var maxSegIndex = e0.size() - 1;
            if ((segIndex0 === 0 && segIndex1 === maxSegIndex) ||
                (segIndex1 === 0 && segIndex0 === maxSegIndex)) {
              return true
            }
          }
        }
      }
      return false
    };
    IntersectionAdder.prototype.getProperIntersectionPoint = function getProperIntersectionPoint () {
      return this._properIntersectionPoint
    };
    IntersectionAdder.prototype.hasProperInteriorIntersection = function hasProperInteriorIntersection () {
      return this._hasProperInterior
    };
    IntersectionAdder.prototype.getLineIntersector = function getLineIntersector () {
      return this._li
    };
    IntersectionAdder.prototype.hasProperIntersection = function hasProperIntersection () {
      return this._hasProper
    };
    IntersectionAdder.prototype.processIntersections = function processIntersections (e0, segIndex0, e1, segIndex1) {
      if (e0 === e1 && segIndex0 === segIndex1) { return null }
      this.numTests++;
      var p00 = e0.getCoordinates()[segIndex0];
      var p01 = e0.getCoordinates()[segIndex0 + 1];
      var p10 = e1.getCoordinates()[segIndex1];
      var p11 = e1.getCoordinates()[segIndex1 + 1];
      this._li.computeIntersection(p00, p01, p10, p11);
      if (this._li.hasIntersection()) {
        this.numIntersections++;
        if (this._li.isInteriorIntersection()) {
          this.numInteriorIntersections++;
          this._hasInterior = true;
        }
        if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
          this._hasIntersection = true;
          e0.addIntersections(this._li, segIndex0, 0);
          e1.addIntersections(this._li, segIndex1, 1);
          if (this._li.isProper()) {
            this.numProperIntersections++;
            this._hasProper = true;
            this._hasProperInterior = true;
          }
        }
      }
    };
    IntersectionAdder.prototype.hasIntersection = function hasIntersection () {
      return this._hasIntersection
    };
    IntersectionAdder.prototype.isDone = function isDone () {
      return false
    };
    IntersectionAdder.prototype.hasInteriorIntersection = function hasInteriorIntersection () {
      return this._hasInterior
    };
    IntersectionAdder.prototype.interfaces_ = function interfaces_ () {
      return [SegmentIntersector]
    };
    IntersectionAdder.prototype.getClass = function getClass () {
      return IntersectionAdder
    };
    IntersectionAdder.isAdjacentSegments = function isAdjacentSegments (i1, i2) {
      return Math.abs(i1 - i2) === 1
    };

    var EdgeIntersection = function EdgeIntersection () {
      this.coord = null;
      this.segmentIndex = null;
      this.dist = null;
      var coord = arguments[0];
      var segmentIndex = arguments[1];
      var dist = arguments[2];
      this.coord = new Coordinate(coord);
      this.segmentIndex = segmentIndex;
      this.dist = dist;
    };
    EdgeIntersection.prototype.getSegmentIndex = function getSegmentIndex () {
      return this.segmentIndex
    };
    EdgeIntersection.prototype.getCoordinate = function getCoordinate () {
      return this.coord
    };
    EdgeIntersection.prototype.print = function print (out) {
      out.print(this.coord);
      out.print(' seg # = ' + this.segmentIndex);
      out.println(' dist = ' + this.dist);
    };
    EdgeIntersection.prototype.compareTo = function compareTo (obj) {
      var other = obj;
      return this.compare(other.segmentIndex, other.dist)
    };
    EdgeIntersection.prototype.isEndPoint = function isEndPoint (maxSegmentIndex) {
      if (this.segmentIndex === 0 && this.dist === 0.0) { return true }
      if (this.segmentIndex === maxSegmentIndex) { return true }
      return false
    };
    EdgeIntersection.prototype.toString = function toString () {
      return this.coord + ' seg # = ' + this.segmentIndex + ' dist = ' + this.dist
    };
    EdgeIntersection.prototype.getDistance = function getDistance () {
      return this.dist
    };
    EdgeIntersection.prototype.compare = function compare (segmentIndex, dist) {
      if (this.segmentIndex < segmentIndex) { return -1 }
      if (this.segmentIndex > segmentIndex) { return 1 }
      if (this.dist < dist) { return -1 }
      if (this.dist > dist) { return 1 }
      return 0
    };
    EdgeIntersection.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    EdgeIntersection.prototype.getClass = function getClass () {
      return EdgeIntersection
    };

    var EdgeIntersectionList = function EdgeIntersectionList () {
      this._nodeMap = new TreeMap();
      this.edge = null;
      var edge = arguments[0];
      this.edge = edge;
    };
    EdgeIntersectionList.prototype.print = function print (out) {
      out.println('Intersections:');
      for (var it = this.iterator(); it.hasNext();) {
        var ei = it.next();
        ei.print(out);
      }
    };
    EdgeIntersectionList.prototype.iterator = function iterator () {
      return this._nodeMap.values().iterator()
    };
    EdgeIntersectionList.prototype.addSplitEdges = function addSplitEdges (edgeList) {
        var this$1 = this;

      this.addEndpoints();
      var it = this.iterator();
      var eiPrev = it.next();
      while (it.hasNext()) {
        var ei = it.next();
        var newEdge = this$1.createSplitEdge(eiPrev, ei);
        edgeList.add(newEdge);
        eiPrev = ei;
      }
    };
    EdgeIntersectionList.prototype.addEndpoints = function addEndpoints () {
      var maxSegIndex = this.edge.pts.length - 1;
      this.add(this.edge.pts[0], 0, 0.0);
      this.add(this.edge.pts[maxSegIndex], maxSegIndex, 0.0);
    };
    EdgeIntersectionList.prototype.createSplitEdge = function createSplitEdge (ei0, ei1) {
        var this$1 = this;

      var npts = ei1.segmentIndex - ei0.segmentIndex + 2;
      var lastSegStartPt = this.edge.pts[ei1.segmentIndex];
      var useIntPt1 = ei1.dist > 0.0 || !ei1.coord.equals2D(lastSegStartPt);
      if (!useIntPt1) {
        npts--;
      }
      var pts = new Array(npts).fill(null);
      var ipt = 0;
      pts[ipt++] = new Coordinate(ei0.coord);
      for (var i = ei0.segmentIndex + 1; i <= ei1.segmentIndex; i++) {
        pts[ipt++] = this$1.edge.pts[i];
      }
      if (useIntPt1) { pts[ipt] = ei1.coord; }
      return new Edge$1(pts, new Label(this.edge._label))
    };
    EdgeIntersectionList.prototype.add = function add (intPt, segmentIndex, dist) {
      var eiNew = new EdgeIntersection(intPt, segmentIndex, dist);
      var ei = this._nodeMap.get(eiNew);
      if (ei !== null) {
        return ei
      }
      this._nodeMap.put(eiNew, eiNew);
      return eiNew
    };
    EdgeIntersectionList.prototype.isIntersection = function isIntersection (pt) {
      for (var it = this.iterator(); it.hasNext();) {
        var ei = it.next();
        if (ei.coord.equals(pt)) { return true }
      }
      return false
    };
    EdgeIntersectionList.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeIntersectionList.prototype.getClass = function getClass () {
      return EdgeIntersectionList
    };

    var MonotoneChainIndexer = function MonotoneChainIndexer () {};

    MonotoneChainIndexer.prototype.getChainStartIndices = function getChainStartIndices (pts) {
        var this$1 = this;

      var start = 0;
      var startIndexList = new ArrayList();
      startIndexList.add(new Integer(start));
      do {
        var last = this$1.findChainEnd(pts, start);
        startIndexList.add(new Integer(last));
        start = last;
      } while (start < pts.length - 1)
      var startIndex = MonotoneChainIndexer.toIntArray(startIndexList);
      return startIndex
    };
    MonotoneChainIndexer.prototype.findChainEnd = function findChainEnd (pts, start) {
      var chainQuad = Quadrant.quadrant(pts[start], pts[start + 1]);
      var last = start + 1;
      while (last < pts.length) {
        var quad = Quadrant.quadrant(pts[last - 1], pts[last]);
        if (quad !== chainQuad) { break }
        last++;
      }
      return last - 1
    };
    MonotoneChainIndexer.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChainIndexer.prototype.getClass = function getClass () {
      return MonotoneChainIndexer
    };
    MonotoneChainIndexer.toIntArray = function toIntArray (list) {
      var array = new Array(list.size()).fill(null);
      for (var i = 0; i < array.length; i++) {
        array[i] = list.get(i).intValue();
      }
      return array
    };

    var MonotoneChainEdge = function MonotoneChainEdge () {
      this.e = null;
      this.pts = null;
      this.startIndex = null;
      this.env1 = new Envelope();
      this.env2 = new Envelope();
      var e = arguments[0];
      this.e = e;
      this.pts = e.getCoordinates();
      var mcb = new MonotoneChainIndexer();
      this.startIndex = mcb.getChainStartIndices(this.pts);
    };
    MonotoneChainEdge.prototype.getCoordinates = function getCoordinates () {
      return this.pts
    };
    MonotoneChainEdge.prototype.getMaxX = function getMaxX (chainIndex) {
      var x1 = this.pts[this.startIndex[chainIndex]].x;
      var x2 = this.pts[this.startIndex[chainIndex + 1]].x;
      return x1 > x2 ? x1 : x2
    };
    MonotoneChainEdge.prototype.getMinX = function getMinX (chainIndex) {
      var x1 = this.pts[this.startIndex[chainIndex]].x;
      var x2 = this.pts[this.startIndex[chainIndex + 1]].x;
      return x1 < x2 ? x1 : x2
    };
    MonotoneChainEdge.prototype.computeIntersectsForChain = function computeIntersectsForChain () {
      if (arguments.length === 4) {
        var chainIndex0 = arguments[0];
        var mce = arguments[1];
        var chainIndex1 = arguments[2];
        var si = arguments[3];
        this.computeIntersectsForChain(this.startIndex[chainIndex0], this.startIndex[chainIndex0 + 1], mce, mce.startIndex[chainIndex1], mce.startIndex[chainIndex1 + 1], si);
      } else if (arguments.length === 6) {
        var start0 = arguments[0];
        var end0 = arguments[1];
        var mce$1 = arguments[2];
        var start1 = arguments[3];
        var end1 = arguments[4];
        var ei = arguments[5];
        var p00 = this.pts[start0];
        var p01 = this.pts[end0];
        var p10 = mce$1.pts[start1];
        var p11 = mce$1.pts[end1];
        if (end0 - start0 === 1 && end1 - start1 === 1) {
          ei.addIntersections(this.e, start0, mce$1.e, start1);
          return null
        }
        this.env1.init(p00, p01);
        this.env2.init(p10, p11);
        if (!this.env1.intersects(this.env2)) { return null }
        var mid0 = Math.trunc((start0 + end0) / 2);
        var mid1 = Math.trunc((start1 + end1) / 2);
        if (start0 < mid0) {
          if (start1 < mid1) { this.computeIntersectsForChain(start0, mid0, mce$1, start1, mid1, ei); }
          if (mid1 < end1) { this.computeIntersectsForChain(start0, mid0, mce$1, mid1, end1, ei); }
        }
        if (mid0 < end0) {
          if (start1 < mid1) { this.computeIntersectsForChain(mid0, end0, mce$1, start1, mid1, ei); }
          if (mid1 < end1) { this.computeIntersectsForChain(mid0, end0, mce$1, mid1, end1, ei); }
        }
      }
    };
    MonotoneChainEdge.prototype.getStartIndexes = function getStartIndexes () {
      return this.startIndex
    };
    MonotoneChainEdge.prototype.computeIntersects = function computeIntersects (mce, si) {
        var this$1 = this;

      for (var i = 0; i < this.startIndex.length - 1; i++) {
        for (var j = 0; j < mce.startIndex.length - 1; j++) {
          this$1.computeIntersectsForChain(i, mce, j, si);
        }
      }
    };
    MonotoneChainEdge.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChainEdge.prototype.getClass = function getClass () {
      return MonotoneChainEdge
    };

    var Depth = function Depth () {
      var this$1 = this;

      this._depth = Array(2).fill().map(function () { return Array(3); });
      for (var i = 0; i < 2; i++) {
        for (var j = 0; j < 3; j++) {
          this$1._depth[i][j] = Depth.NULL_VALUE;
        }
      }
    };

    var staticAccessors$31 = { NULL_VALUE: { configurable: true } };
    Depth.prototype.getDepth = function getDepth (geomIndex, posIndex) {
      return this._depth[geomIndex][posIndex]
    };
    Depth.prototype.setDepth = function setDepth (geomIndex, posIndex, depthValue) {
      this._depth[geomIndex][posIndex] = depthValue;
    };
    Depth.prototype.isNull = function isNull () {
        var this$1 = this;

      if (arguments.length === 0) {
        for (var i = 0; i < 2; i++) {
          for (var j = 0; j < 3; j++) {
            if (this$1._depth[i][j] !== Depth.NULL_VALUE) { return false }
          }
        }
        return true
      } else if (arguments.length === 1) {
        var geomIndex = arguments[0];
        return this._depth[geomIndex][1] === Depth.NULL_VALUE
      } else if (arguments.length === 2) {
        var geomIndex$1 = arguments[0];
        var posIndex = arguments[1];
        return this._depth[geomIndex$1][posIndex] === Depth.NULL_VALUE
      }
    };
    Depth.prototype.normalize = function normalize () {
        var this$1 = this;

      for (var i = 0; i < 2; i++) {
        if (!this$1.isNull(i)) {
          var minDepth = this$1._depth[i][1];
          if (this$1._depth[i][2] < minDepth) { minDepth = this$1._depth[i][2]; }
          if (minDepth < 0) { minDepth = 0; }
          for (var j = 1; j < 3; j++) {
            var newValue = 0;
            if (this$1._depth[i][j] > minDepth) { newValue = 1; }
            this$1._depth[i][j] = newValue;
          }
        }
      }
    };
    Depth.prototype.getDelta = function getDelta (geomIndex) {
      return this._depth[geomIndex][Position.RIGHT] - this._depth[geomIndex][Position.LEFT]
    };
    Depth.prototype.getLocation = function getLocation (geomIndex, posIndex) {
      if (this._depth[geomIndex][posIndex] <= 0) { return Location.EXTERIOR }
      return Location.INTERIOR
    };
    Depth.prototype.toString = function toString () {
      return 'A: ' + this._depth[0][1] + ',' + this._depth[0][2] + ' B: ' + this._depth[1][1] + ',' + this._depth[1][2]
    };
    Depth.prototype.add = function add () {
        var this$1 = this;

      if (arguments.length === 1) {
        var lbl = arguments[0];
        for (var i = 0; i < 2; i++) {
          for (var j = 1; j < 3; j++) {
            var loc = lbl.getLocation(i, j);
            if (loc === Location.EXTERIOR || loc === Location.INTERIOR) {
              if (this$1.isNull(i, j)) {
                this$1._depth[i][j] = Depth.depthAtLocation(loc);
              } else { this$1._depth[i][j] += Depth.depthAtLocation(loc); }
            }
          }
        }
      } else if (arguments.length === 3) {
        var geomIndex = arguments[0];
        var posIndex = arguments[1];
        var location = arguments[2];
        if (location === Location.INTERIOR) { this._depth[geomIndex][posIndex]++; }
      }
    };
    Depth.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    Depth.prototype.getClass = function getClass () {
      return Depth
    };
    Depth.depthAtLocation = function depthAtLocation (location) {
      if (location === Location.EXTERIOR) { return 0 }
      if (location === Location.INTERIOR) { return 1 }
      return Depth.NULL_VALUE
    };
    staticAccessors$31.NULL_VALUE.get = function () { return -1 };

    Object.defineProperties( Depth, staticAccessors$31 );

    var Edge$1 = (function (GraphComponent$$1) {
      function Edge () {
        GraphComponent$$1.call(this);
        this.pts = null;
        this._env = null;
        this.eiList = new EdgeIntersectionList(this);
        this._name = null;
        this._mce = null;
        this._isIsolated = true;
        this._depth = new Depth();
        this._depthDelta = 0;
        if (arguments.length === 1) {
          var pts = arguments[0];
          Edge.call(this, pts, null);
        } else if (arguments.length === 2) {
          var pts$1 = arguments[0];
          var label = arguments[1];
          this.pts = pts$1;
          this._label = label;
        }
      }

      if ( GraphComponent$$1 ) Edge.__proto__ = GraphComponent$$1;
      Edge.prototype = Object.create( GraphComponent$$1 && GraphComponent$$1.prototype );
      Edge.prototype.constructor = Edge;
      Edge.prototype.getDepth = function getDepth () {
        return this._depth
      };
      Edge.prototype.getCollapsedEdge = function getCollapsedEdge () {
        var newPts = new Array(2).fill(null);
        newPts[0] = this.pts[0];
        newPts[1] = this.pts[1];
        var newe = new Edge(newPts, Label.toLineLabel(this._label));
        return newe
      };
      Edge.prototype.isIsolated = function isIsolated () {
        return this._isIsolated
      };
      Edge.prototype.getCoordinates = function getCoordinates () {
        return this.pts
      };
      Edge.prototype.setIsolated = function setIsolated (isIsolated) {
        this._isIsolated = isIsolated;
      };
      Edge.prototype.setName = function setName (name) {
        this._name = name;
      };
      Edge.prototype.equals = function equals (o) {
        var this$1 = this;

        if (!(o instanceof Edge)) { return false }
        var e = o;
        if (this.pts.length !== e.pts.length) { return false }
        var isEqualForward = true;
        var isEqualReverse = true;
        var iRev = this.pts.length;
        for (var i = 0; i < this.pts.length; i++) {
          if (!this$1.pts[i].equals2D(e.pts[i])) {
            isEqualForward = false;
          }
          if (!this$1.pts[i].equals2D(e.pts[--iRev])) {
            isEqualReverse = false;
          }
          if (!isEqualForward && !isEqualReverse) { return false }
        }
        return true
      };
      Edge.prototype.getCoordinate = function getCoordinate () {
        if (arguments.length === 0) {
          if (this.pts.length > 0) { return this.pts[0] }
          return null
        } else if (arguments.length === 1) {
          var i = arguments[0];
          return this.pts[i]
        }
      };
      Edge.prototype.print = function print (out) {
        var this$1 = this;

        out.print('edge ' + this._name + ': ');
        out.print('LINESTRING (');
        for (var i = 0; i < this.pts.length; i++) {
          if (i > 0) { out.print(','); }
          out.print(this$1.pts[i].x + ' ' + this$1.pts[i].y);
        }
        out.print(')  ' + this._label + ' ' + this._depthDelta);
      };
      Edge.prototype.computeIM = function computeIM (im) {
        Edge.updateIM(this._label, im);
      };
      Edge.prototype.isCollapsed = function isCollapsed () {
        if (!this._label.isArea()) { return false }
        if (this.pts.length !== 3) { return false }
        if (this.pts[0].equals(this.pts[2])) { return true }
        return false
      };
      Edge.prototype.isClosed = function isClosed () {
        return this.pts[0].equals(this.pts[this.pts.length - 1])
      };
      Edge.prototype.getMaximumSegmentIndex = function getMaximumSegmentIndex () {
        return this.pts.length - 1
      };
      Edge.prototype.getDepthDelta = function getDepthDelta () {
        return this._depthDelta
      };
      Edge.prototype.getNumPoints = function getNumPoints () {
        return this.pts.length
      };
      Edge.prototype.printReverse = function printReverse (out) {
        var this$1 = this;

        out.print('edge ' + this._name + ': ');
        for (var i = this.pts.length - 1; i >= 0; i--) {
          out.print(this$1.pts[i] + ' ');
        }
        out.println('');
      };
      Edge.prototype.getMonotoneChainEdge = function getMonotoneChainEdge () {
        if (this._mce === null) { this._mce = new MonotoneChainEdge(this); }
        return this._mce
      };
      Edge.prototype.getEnvelope = function getEnvelope () {
        var this$1 = this;

        if (this._env === null) {
          this._env = new Envelope();
          for (var i = 0; i < this.pts.length; i++) {
            this$1._env.expandToInclude(this$1.pts[i]);
          }
        }
        return this._env
      };
      Edge.prototype.addIntersection = function addIntersection (li, segmentIndex, geomIndex, intIndex) {
        var intPt = new Coordinate(li.getIntersection(intIndex));
        var normalizedSegmentIndex = segmentIndex;
        var dist = li.getEdgeDistance(geomIndex, intIndex);
        var nextSegIndex = normalizedSegmentIndex + 1;
        if (nextSegIndex < this.pts.length) {
          var nextPt = this.pts[nextSegIndex];
          if (intPt.equals2D(nextPt)) {
            normalizedSegmentIndex = nextSegIndex;
            dist = 0.0;
          }
        }
        this.eiList.add(intPt, normalizedSegmentIndex, dist);
      };
      Edge.prototype.toString = function toString () {
        var this$1 = this;

        var buf = new StringBuffer();
        buf.append('edge ' + this._name + ': ');
        buf.append('LINESTRING (');
        for (var i = 0; i < this.pts.length; i++) {
          if (i > 0) { buf.append(','); }
          buf.append(this$1.pts[i].x + ' ' + this$1.pts[i].y);
        }
        buf.append(')  ' + this._label + ' ' + this._depthDelta);
        return buf.toString()
      };
      Edge.prototype.isPointwiseEqual = function isPointwiseEqual (e) {
        var this$1 = this;

        if (this.pts.length !== e.pts.length) { return false }
        for (var i = 0; i < this.pts.length; i++) {
          if (!this$1.pts[i].equals2D(e.pts[i])) {
            return false
          }
        }
        return true
      };
      Edge.prototype.setDepthDelta = function setDepthDelta (depthDelta) {
        this._depthDelta = depthDelta;
      };
      Edge.prototype.getEdgeIntersectionList = function getEdgeIntersectionList () {
        return this.eiList
      };
      Edge.prototype.addIntersections = function addIntersections (li, segmentIndex, geomIndex) {
        var this$1 = this;

        for (var i = 0; i < li.getIntersectionNum(); i++) {
          this$1.addIntersection(li, segmentIndex, geomIndex, i);
        }
      };
      Edge.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      Edge.prototype.getClass = function getClass () {
        return Edge
      };
      Edge.updateIM = function updateIM () {
        if (arguments.length === 2) {
          var label = arguments[0];
          var im = arguments[1];
          im.setAtLeastIfValid(label.getLocation(0, Position.ON), label.getLocation(1, Position.ON), 1);
          if (label.isArea()) {
            im.setAtLeastIfValid(label.getLocation(0, Position.LEFT), label.getLocation(1, Position.LEFT), 2);
            im.setAtLeastIfValid(label.getLocation(0, Position.RIGHT), label.getLocation(1, Position.RIGHT), 2);
          }
        } else { return GraphComponent$$1.prototype.updateIM.apply(this, arguments) }
      };

      return Edge;
    }(GraphComponent));

    var BufferBuilder = function BufferBuilder (bufParams) {
      this._workingPrecisionModel = null;
      this._workingNoder = null;
      this._geomFact = null;
      this._graph = null;
      this._edgeList = new EdgeList();
      this._bufParams = bufParams || null;
    };
    BufferBuilder.prototype.setWorkingPrecisionModel = function setWorkingPrecisionModel (pm) {
      this._workingPrecisionModel = pm;
    };
    BufferBuilder.prototype.insertUniqueEdge = function insertUniqueEdge (e) {
      var existingEdge = this._edgeList.findEqualEdge(e);
      if (existingEdge !== null) {
        var existingLabel = existingEdge.getLabel();
        var labelToMerge = e.getLabel();
        if (!existingEdge.isPointwiseEqual(e)) {
          labelToMerge = new Label(e.getLabel());
          labelToMerge.flip();
        }
        existingLabel.merge(labelToMerge);
        var mergeDelta = BufferBuilder.depthDelta(labelToMerge);
        var existingDelta = existingEdge.getDepthDelta();
        var newDelta = existingDelta + mergeDelta;
        existingEdge.setDepthDelta(newDelta);
      } else {
        this._edgeList.add(e);
        e.setDepthDelta(BufferBuilder.depthDelta(e.getLabel()));
      }
    };
    BufferBuilder.prototype.buildSubgraphs = function buildSubgraphs (subgraphList, polyBuilder) {
      var processedGraphs = new ArrayList();
      for (var i = subgraphList.iterator(); i.hasNext();) {
        var subgraph = i.next();
        var p = subgraph.getRightmostCoordinate();
        var locater = new SubgraphDepthLocater(processedGraphs);
        var outsideDepth = locater.getDepth(p);
        subgraph.computeDepth(outsideDepth);
        subgraph.findResultEdges();
        processedGraphs.add(subgraph);
        polyBuilder.add(subgraph.getDirectedEdges(), subgraph.getNodes());
      }
    };
    BufferBuilder.prototype.createSubgraphs = function createSubgraphs (graph) {
      var subgraphList = new ArrayList();
      for (var i = graph.getNodes().iterator(); i.hasNext();) {
        var node = i.next();
        if (!node.isVisited()) {
          var subgraph = new BufferSubgraph();
          subgraph.create(node);
          subgraphList.add(subgraph);
        }
      }
      Collections.sort(subgraphList, Collections.reverseOrder());
      return subgraphList
    };
    BufferBuilder.prototype.createEmptyResultGeometry = function createEmptyResultGeometry () {
      var emptyGeom = this._geomFact.createPolygon();
      return emptyGeom
    };
    BufferBuilder.prototype.getNoder = function getNoder (precisionModel) {
      if (this._workingNoder !== null) { return this._workingNoder }
      var noder = new MCIndexNoder();
      var li = new RobustLineIntersector();
      li.setPrecisionModel(precisionModel);
      noder.setSegmentIntersector(new IntersectionAdder(li));
      return noder
    };
    BufferBuilder.prototype.buffer = function buffer (g, distance) {
      var precisionModel = this._workingPrecisionModel;
      if (precisionModel === null) { precisionModel = g.getPrecisionModel(); }
      this._geomFact = g.getFactory();
      var curveBuilder = new OffsetCurveBuilder(precisionModel, this._bufParams);
      var curveSetBuilder = new OffsetCurveSetBuilder(g, distance, curveBuilder);
      var bufferSegStrList = curveSetBuilder.getCurves();
      if (bufferSegStrList.size() <= 0) {
        return this.createEmptyResultGeometry()
      }
      this.computeNodedEdges(bufferSegStrList, precisionModel);
      this._graph = new PlanarGraph(new OverlayNodeFactory());
      this._graph.addEdges(this._edgeList.getEdges());
      var subgraphList = this.createSubgraphs(this._graph);
      var polyBuilder = new PolygonBuilder(this._geomFact);
      this.buildSubgraphs(subgraphList, polyBuilder);
      var resultPolyList = polyBuilder.getPolygons();
      if (resultPolyList.size() <= 0) {
        return this.createEmptyResultGeometry()
      }
      var resultGeom = this._geomFact.buildGeometry(resultPolyList);
      return resultGeom
    };
    BufferBuilder.prototype.computeNodedEdges = function computeNodedEdges (bufferSegStrList, precisionModel) {
        var this$1 = this;

      var noder = this.getNoder(precisionModel);
      noder.computeNodes(bufferSegStrList);
      var nodedSegStrings = noder.getNodedSubstrings();
      for (var i = nodedSegStrings.iterator(); i.hasNext();) {
        var segStr = i.next();
        var pts = segStr.getCoordinates();
        if (pts.length === 2 && pts[0].equals2D(pts[1])) { continue }
        var oldLabel = segStr.getData();
        var edge = new Edge$1(segStr.getCoordinates(), new Label(oldLabel));
        this$1.insertUniqueEdge(edge);
      }
    };
    BufferBuilder.prototype.setNoder = function setNoder (noder) {
      this._workingNoder = noder;
    };
    BufferBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferBuilder.prototype.getClass = function getClass () {
      return BufferBuilder
    };
    BufferBuilder.depthDelta = function depthDelta (label) {
      var lLoc = label.getLocation(0, Position.LEFT);
      var rLoc = label.getLocation(0, Position.RIGHT);
      if (lLoc === Location.INTERIOR && rLoc === Location.EXTERIOR) { return 1; } else if (lLoc === Location.EXTERIOR && rLoc === Location.INTERIOR) { return -1 }
      return 0
    };
    BufferBuilder.convertSegStrings = function convertSegStrings (it) {
      var fact = new GeometryFactory();
      var lines = new ArrayList();
      while (it.hasNext()) {
        var ss = it.next();
        var line = fact.createLineString(ss.getCoordinates());
        lines.add(line);
      }
      return fact.buildGeometry(lines)
    };

    var ScaledNoder = function ScaledNoder () {
      this._noder = null;
      this._scaleFactor = null;
      this._offsetX = null;
      this._offsetY = null;
      this._isScaled = false;
      if (arguments.length === 2) {
        var noder = arguments[0];
        var scaleFactor = arguments[1];
        this._noder = noder;
        this._scaleFactor = scaleFactor;
        this._offsetX = 0.0;
        this._offsetY = 0.0;
        this._isScaled = !this.isIntegerPrecision();
      } else if (arguments.length === 4) {
        var noder$1 = arguments[0];
        var scaleFactor$1 = arguments[1];
        var offsetX = arguments[2];
        var offsetY = arguments[3];
        this._noder = noder$1;
        this._scaleFactor = scaleFactor$1;
        this._offsetX = offsetX;
        this._offsetY = offsetY;
        this._isScaled = !this.isIntegerPrecision();
      }
    };
    ScaledNoder.prototype.rescale = function rescale () {
        var this$1 = this;

      if (hasInterface(arguments[0], Collection)) {
        var segStrings = arguments[0];
        for (var i = segStrings.iterator(); i.hasNext();) {
          var ss = i.next();
          this$1.rescale(ss.getCoordinates());
        }
      } else if (arguments[0] instanceof Array) {
        var pts = arguments[0];
        // let p0 = null
        // let p1 = null
        // if (pts.length === 2) {
        // p0 = new Coordinate(pts[0])
        // p1 = new Coordinate(pts[1])
        // }
        for (var i$1 = 0; i$1 < pts.length; i$1++) {
          pts[i$1].x = pts[i$1].x / this$1._scaleFactor + this$1._offsetX;
          pts[i$1].y = pts[i$1].y / this$1._scaleFactor + this$1._offsetY;
        }
        if (pts.length === 2 && pts[0].equals2D(pts[1])) {
          System.out.println(pts);
        }
      }
    };
    ScaledNoder.prototype.scale = function scale () {
        var this$1 = this;

      if (hasInterface(arguments[0], Collection)) {
        var segStrings = arguments[0];
        var nodedSegmentStrings = new ArrayList();
        for (var i = segStrings.iterator(); i.hasNext();) {
          var ss = i.next();
          nodedSegmentStrings.add(new NodedSegmentString(this$1.scale(ss.getCoordinates()), ss.getData()));
        }
        return nodedSegmentStrings
      } else if (arguments[0] instanceof Array) {
        var pts = arguments[0];
        var roundPts = new Array(pts.length).fill(null);
        for (var i$1 = 0; i$1 < pts.length; i$1++) {
          roundPts[i$1] = new Coordinate(Math.round((pts[i$1].x - this$1._offsetX) * this$1._scaleFactor), Math.round((pts[i$1].y - this$1._offsetY) * this$1._scaleFactor), pts[i$1].z);
        }
        var roundPtsNoDup = CoordinateArrays.removeRepeatedPoints(roundPts);
        return roundPtsNoDup
      }
    };
    ScaledNoder.prototype.isIntegerPrecision = function isIntegerPrecision () {
      return this._scaleFactor === 1.0
    };
    ScaledNoder.prototype.getNodedSubstrings = function getNodedSubstrings () {
      var splitSS = this._noder.getNodedSubstrings();
      if (this._isScaled) { this.rescale(splitSS); }
      return splitSS
    };
    ScaledNoder.prototype.computeNodes = function computeNodes (inputSegStrings) {
      var intSegStrings = inputSegStrings;
      if (this._isScaled) { intSegStrings = this.scale(inputSegStrings); }
      this._noder.computeNodes(intSegStrings);
    };
    ScaledNoder.prototype.interfaces_ = function interfaces_ () {
      return [Noder]
    };
    ScaledNoder.prototype.getClass = function getClass () {
      return ScaledNoder
    };

    var NodingValidator = function NodingValidator () {
      this._li = new RobustLineIntersector();
      this._segStrings = null;
      var segStrings = arguments[0];
      this._segStrings = segStrings;
    };

    var staticAccessors$33 = { fact: { configurable: true } };
    NodingValidator.prototype.checkEndPtVertexIntersections = function checkEndPtVertexIntersections () {
        var this$1 = this;

      if (arguments.length === 0) {
        for (var i = this._segStrings.iterator(); i.hasNext();) {
          var ss = i.next();
          var pts = ss.getCoordinates();
          this$1.checkEndPtVertexIntersections(pts[0], this$1._segStrings);
          this$1.checkEndPtVertexIntersections(pts[pts.length - 1], this$1._segStrings);
        }
      } else if (arguments.length === 2) {
        var testPt = arguments[0];
        var segStrings = arguments[1];
        for (var i$1 = segStrings.iterator(); i$1.hasNext();) {
          var ss$1 = i$1.next();
          var pts$1 = ss$1.getCoordinates();
          for (var j = 1; j < pts$1.length - 1; j++) {
            if (pts$1[j].equals(testPt)) { throw new RuntimeException('found endpt/interior pt intersection at index ' + j + ' :pt ' + testPt) }
          }
        }
      }
    };
    NodingValidator.prototype.checkInteriorIntersections = function checkInteriorIntersections () {
        var this$1 = this;

      if (arguments.length === 0) {
        for (var i = this._segStrings.iterator(); i.hasNext();) {
          var ss0 = i.next();
          for (var j = this._segStrings.iterator(); j.hasNext();) {
            var ss1 = j.next();
            this$1.checkInteriorIntersections(ss0, ss1);
          }
        }
      } else if (arguments.length === 2) {
        var ss0$1 = arguments[0];
        var ss1$1 = arguments[1];
        var pts0 = ss0$1.getCoordinates();
        var pts1 = ss1$1.getCoordinates();
        for (var i0 = 0; i0 < pts0.length - 1; i0++) {
          for (var i1 = 0; i1 < pts1.length - 1; i1++) {
            this$1.checkInteriorIntersections(ss0$1, i0, ss1$1, i1);
          }
        }
      } else if (arguments.length === 4) {
        var e0 = arguments[0];
        var segIndex0 = arguments[1];
        var e1 = arguments[2];
        var segIndex1 = arguments[3];
        if (e0 === e1 && segIndex0 === segIndex1) { return null }
        var p00 = e0.getCoordinates()[segIndex0];
        var p01 = e0.getCoordinates()[segIndex0 + 1];
        var p10 = e1.getCoordinates()[segIndex1];
        var p11 = e1.getCoordinates()[segIndex1 + 1];
        this._li.computeIntersection(p00, p01, p10, p11);
        if (this._li.hasIntersection()) {
          if (this._li.isProper() || this.hasInteriorIntersection(this._li, p00, p01) || this.hasInteriorIntersection(this._li, p10, p11)) {
            throw new RuntimeException('found non-noded intersection at ' + p00 + '-' + p01 + ' and ' + p10 + '-' + p11)
          }
        }
      }
    };
    NodingValidator.prototype.checkValid = function checkValid () {
      this.checkEndPtVertexIntersections();
      this.checkInteriorIntersections();
      this.checkCollapses();
    };
    NodingValidator.prototype.checkCollapses = function checkCollapses () {
        var this$1 = this;

      if (arguments.length === 0) {
        for (var i = this._segStrings.iterator(); i.hasNext();) {
          var ss = i.next();
          this$1.checkCollapses(ss);
        }
      } else if (arguments.length === 1) {
        var ss$1 = arguments[0];
        var pts = ss$1.getCoordinates();
        for (var i$1 = 0; i$1 < pts.length - 2; i$1++) {
          this$1.checkCollapse(pts[i$1], pts[i$1 + 1], pts[i$1 + 2]);
        }
      }
    };
    NodingValidator.prototype.hasInteriorIntersection = function hasInteriorIntersection (li, p0, p1) {
      for (var i = 0; i < li.getIntersectionNum(); i++) {
        var intPt = li.getIntersection(i);
        if (!(intPt.equals(p0) || intPt.equals(p1))) { return true }
      }
      return false
    };
    NodingValidator.prototype.checkCollapse = function checkCollapse (p0, p1, p2) {
      if (p0.equals(p2)) { throw new RuntimeException('found non-noded collapse at ' + NodingValidator.fact.createLineString([p0, p1, p2])) }
    };
    NodingValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    NodingValidator.prototype.getClass = function getClass () {
      return NodingValidator
    };
    staticAccessors$33.fact.get = function () { return new GeometryFactory() };

    Object.defineProperties( NodingValidator, staticAccessors$33 );

    var HotPixel = function HotPixel () {
      this._li = null;
      this._pt = null;
      this._originalPt = null;
      this._ptScaled = null;
      this._p0Scaled = null;
      this._p1Scaled = null;
      this._scaleFactor = null;
      this._minx = null;
      this._maxx = null;
      this._miny = null;
      this._maxy = null;
      this._corner = new Array(4).fill(null);
      this._safeEnv = null;
      var pt = arguments[0];
      var scaleFactor = arguments[1];
      var li = arguments[2];
      this._originalPt = pt;
      this._pt = pt;
      this._scaleFactor = scaleFactor;
      this._li = li;
      if (scaleFactor <= 0) { throw new IllegalArgumentException('Scale factor must be non-zero') }
      if (scaleFactor !== 1.0) {
        this._pt = new Coordinate(this.scale(pt.x), this.scale(pt.y));
        this._p0Scaled = new Coordinate();
        this._p1Scaled = new Coordinate();
      }
      this.initCorners(this._pt);
    };

    var staticAccessors$34 = { SAFE_ENV_EXPANSION_FACTOR: { configurable: true } };
    HotPixel.prototype.intersectsScaled = function intersectsScaled (p0, p1) {
      var segMinx = Math.min(p0.x, p1.x);
      var segMaxx = Math.max(p0.x, p1.x);
      var segMiny = Math.min(p0.y, p1.y);
      var segMaxy = Math.max(p0.y, p1.y);
      var isOutsidePixelEnv = this._maxx < segMinx || this._minx > segMaxx || this._maxy < segMiny || this._miny > segMaxy;
      if (isOutsidePixelEnv) { return false }
      var intersects = this.intersectsToleranceSquare(p0, p1);
      Assert.isTrue(!(isOutsidePixelEnv && intersects), 'Found bad envelope test');
      return intersects
    };
    HotPixel.prototype.initCorners = function initCorners (pt) {
      var tolerance = 0.5;
      this._minx = pt.x - tolerance;
      this._maxx = pt.x + tolerance;
      this._miny = pt.y - tolerance;
      this._maxy = pt.y + tolerance;
      this._corner[0] = new Coordinate(this._maxx, this._maxy);
      this._corner[1] = new Coordinate(this._minx, this._maxy);
      this._corner[2] = new Coordinate(this._minx, this._miny);
      this._corner[3] = new Coordinate(this._maxx, this._miny);
    };
    HotPixel.prototype.intersects = function intersects (p0, p1) {
      if (this._scaleFactor === 1.0) { return this.intersectsScaled(p0, p1) }
      this.copyScaled(p0, this._p0Scaled);
      this.copyScaled(p1, this._p1Scaled);
      return this.intersectsScaled(this._p0Scaled, this._p1Scaled)
    };
    HotPixel.prototype.scale = function scale (val) {
      return Math.round(val * this._scaleFactor)
    };
    HotPixel.prototype.getCoordinate = function getCoordinate () {
      return this._originalPt
    };
    HotPixel.prototype.copyScaled = function copyScaled (p, pScaled) {
      pScaled.x = this.scale(p.x);
      pScaled.y = this.scale(p.y);
    };
    HotPixel.prototype.getSafeEnvelope = function getSafeEnvelope () {
      if (this._safeEnv === null) {
        var safeTolerance = HotPixel.SAFE_ENV_EXPANSION_FACTOR / this._scaleFactor;
        this._safeEnv = new Envelope(this._originalPt.x - safeTolerance, this._originalPt.x + safeTolerance, this._originalPt.y - safeTolerance, this._originalPt.y + safeTolerance);
      }
      return this._safeEnv
    };
    HotPixel.prototype.intersectsPixelClosure = function intersectsPixelClosure (p0, p1) {
      this._li.computeIntersection(p0, p1, this._corner[0], this._corner[1]);
      if (this._li.hasIntersection()) { return true }
      this._li.computeIntersection(p0, p1, this._corner[1], this._corner[2]);
      if (this._li.hasIntersection()) { return true }
      this._li.computeIntersection(p0, p1, this._corner[2], this._corner[3]);
      if (this._li.hasIntersection()) { return true }
      this._li.computeIntersection(p0, p1, this._corner[3], this._corner[0]);
      if (this._li.hasIntersection()) { return true }
      return false
    };
    HotPixel.prototype.intersectsToleranceSquare = function intersectsToleranceSquare (p0, p1) {
      var intersectsLeft = false;
      var intersectsBottom = false;
      this._li.computeIntersection(p0, p1, this._corner[0], this._corner[1]);
      if (this._li.isProper()) { return true }
      this._li.computeIntersection(p0, p1, this._corner[1], this._corner[2]);
      if (this._li.isProper()) { return true }
      if (this._li.hasIntersection()) { intersectsLeft = true; }
      this._li.computeIntersection(p0, p1, this._corner[2], this._corner[3]);
      if (this._li.isProper()) { return true }
      if (this._li.hasIntersection()) { intersectsBottom = true; }
      this._li.computeIntersection(p0, p1, this._corner[3], this._corner[0]);
      if (this._li.isProper()) { return true }
      if (intersectsLeft && intersectsBottom) { return true }
      if (p0.equals(this._pt)) { return true }
      if (p1.equals(this._pt)) { return true }
      return false
    };
    HotPixel.prototype.addSnappedNode = function addSnappedNode (segStr, segIndex) {
      var p0 = segStr.getCoordinate(segIndex);
      var p1 = segStr.getCoordinate(segIndex + 1);
      if (this.intersects(p0, p1)) {
        segStr.addIntersection(this.getCoordinate(), segIndex);
        return true
      }
      return false
    };
    HotPixel.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    HotPixel.prototype.getClass = function getClass () {
      return HotPixel
    };
    staticAccessors$34.SAFE_ENV_EXPANSION_FACTOR.get = function () { return 0.75 };

    Object.defineProperties( HotPixel, staticAccessors$34 );

    var MonotoneChainSelectAction = function MonotoneChainSelectAction () {
      this.tempEnv1 = new Envelope();
      this.selectedSegment = new LineSegment();
    };
    MonotoneChainSelectAction.prototype.select = function select () {
      if (arguments.length === 1) ; else if (arguments.length === 2) {
        var mc = arguments[0];
        var startIndex = arguments[1];
        mc.getLineSegment(startIndex, this.selectedSegment);
        this.select(this.selectedSegment);
      }
    };
    MonotoneChainSelectAction.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChainSelectAction.prototype.getClass = function getClass () {
      return MonotoneChainSelectAction
    };

    var MCIndexPointSnapper = function MCIndexPointSnapper () {
      this._index = null;
      var index = arguments[0];
      this._index = index;
    };

    var staticAccessors$35 = { HotPixelSnapAction: { configurable: true } };
    MCIndexPointSnapper.prototype.snap = function snap () {
      if (arguments.length === 1) {
        var hotPixel = arguments[0];
        return this.snap(hotPixel, null, -1)
      } else if (arguments.length === 3) {
        var hotPixel$1 = arguments[0];
        var parentEdge = arguments[1];
        var hotPixelVertexIndex = arguments[2];
        var pixelEnv = hotPixel$1.getSafeEnvelope();
        var hotPixelSnapAction = new HotPixelSnapAction(hotPixel$1, parentEdge, hotPixelVertexIndex);
        this._index.query(pixelEnv, {
          interfaces_: function () {
            return [ItemVisitor]
          },
          visitItem: function (item) {
            var testChain = item;
            testChain.select(pixelEnv, hotPixelSnapAction);
          }
        });
        return hotPixelSnapAction.isNodeAdded()
      }
    };
    MCIndexPointSnapper.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MCIndexPointSnapper.prototype.getClass = function getClass () {
      return MCIndexPointSnapper
    };
    staticAccessors$35.HotPixelSnapAction.get = function () { return HotPixelSnapAction };

    Object.defineProperties( MCIndexPointSnapper, staticAccessors$35 );

    var HotPixelSnapAction = (function (MonotoneChainSelectAction$$1) {
      function HotPixelSnapAction () {
        MonotoneChainSelectAction$$1.call(this);
        this._hotPixel = null;
        this._parentEdge = null;
        this._hotPixelVertexIndex = null;
        this._isNodeAdded = false;
        var hotPixel = arguments[0];
        var parentEdge = arguments[1];
        var hotPixelVertexIndex = arguments[2];
        this._hotPixel = hotPixel;
        this._parentEdge = parentEdge;
        this._hotPixelVertexIndex = hotPixelVertexIndex;
      }

      if ( MonotoneChainSelectAction$$1 ) HotPixelSnapAction.__proto__ = MonotoneChainSelectAction$$1;
      HotPixelSnapAction.prototype = Object.create( MonotoneChainSelectAction$$1 && MonotoneChainSelectAction$$1.prototype );
      HotPixelSnapAction.prototype.constructor = HotPixelSnapAction;
      HotPixelSnapAction.prototype.isNodeAdded = function isNodeAdded () {
        return this._isNodeAdded
      };
      HotPixelSnapAction.prototype.select = function select () {
        if (arguments.length === 2) {
          var mc = arguments[0];
          var startIndex = arguments[1];
          var ss = mc.getContext();
          if (this._parentEdge !== null) {
            if (ss === this._parentEdge && startIndex === this._hotPixelVertexIndex) { return null }
          }
          this._isNodeAdded = this._hotPixel.addSnappedNode(ss, startIndex);
        } else { return MonotoneChainSelectAction$$1.prototype.select.apply(this, arguments) }
      };
      HotPixelSnapAction.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      HotPixelSnapAction.prototype.getClass = function getClass () {
        return HotPixelSnapAction
      };

      return HotPixelSnapAction;
    }(MonotoneChainSelectAction));

    var InteriorIntersectionFinderAdder = function InteriorIntersectionFinderAdder () {
      this._li = null;
      this._interiorIntersections = null;
      var li = arguments[0];
      this._li = li;
      this._interiorIntersections = new ArrayList();
    };
    InteriorIntersectionFinderAdder.prototype.processIntersections = function processIntersections (e0, segIndex0, e1, segIndex1) {
        var this$1 = this;

      if (e0 === e1 && segIndex0 === segIndex1) { return null }
      var p00 = e0.getCoordinates()[segIndex0];
      var p01 = e0.getCoordinates()[segIndex0 + 1];
      var p10 = e1.getCoordinates()[segIndex1];
      var p11 = e1.getCoordinates()[segIndex1 + 1];
      this._li.computeIntersection(p00, p01, p10, p11);
      if (this._li.hasIntersection()) {
        if (this._li.isInteriorIntersection()) {
          for (var intIndex = 0; intIndex < this._li.getIntersectionNum(); intIndex++) {
            this$1._interiorIntersections.add(this$1._li.getIntersection(intIndex));
          }
          e0.addIntersections(this._li, segIndex0, 0);
          e1.addIntersections(this._li, segIndex1, 1);
        }
      }
    };
    InteriorIntersectionFinderAdder.prototype.isDone = function isDone () {
      return false
    };
    InteriorIntersectionFinderAdder.prototype.getInteriorIntersections = function getInteriorIntersections () {
      return this._interiorIntersections
    };
    InteriorIntersectionFinderAdder.prototype.interfaces_ = function interfaces_ () {
      return [SegmentIntersector]
    };
    InteriorIntersectionFinderAdder.prototype.getClass = function getClass () {
      return InteriorIntersectionFinderAdder
    };

    var MCIndexSnapRounder = function MCIndexSnapRounder () {
      this._pm = null;
      this._li = null;
      this._scaleFactor = null;
      this._noder = null;
      this._pointSnapper = null;
      this._nodedSegStrings = null;
      var pm = arguments[0];
      this._pm = pm;
      this._li = new RobustLineIntersector();
      this._li.setPrecisionModel(pm);
      this._scaleFactor = pm.getScale();
    };
    MCIndexSnapRounder.prototype.checkCorrectness = function checkCorrectness (inputSegmentStrings) {
      var resultSegStrings = NodedSegmentString.getNodedSubstrings(inputSegmentStrings);
      var nv = new NodingValidator(resultSegStrings);
      try {
        nv.checkValid();
      } catch (ex) {
        if (ex instanceof Exception) {
          ex.printStackTrace();
        } else { throw ex }
      } finally {}
    };
    MCIndexSnapRounder.prototype.getNodedSubstrings = function getNodedSubstrings () {
      return NodedSegmentString.getNodedSubstrings(this._nodedSegStrings)
    };
    MCIndexSnapRounder.prototype.snapRound = function snapRound (segStrings, li) {
      var intersections = this.findInteriorIntersections(segStrings, li);
      this.computeIntersectionSnaps(intersections);
      this.computeVertexSnaps(segStrings);
    };
    MCIndexSnapRounder.prototype.findInteriorIntersections = function findInteriorIntersections (segStrings, li) {
      var intFinderAdder = new InteriorIntersectionFinderAdder(li);
      this._noder.setSegmentIntersector(intFinderAdder);
      this._noder.computeNodes(segStrings);
      return intFinderAdder.getInteriorIntersections()
    };
    MCIndexSnapRounder.prototype.computeVertexSnaps = function computeVertexSnaps () {
        var this$1 = this;

      if (hasInterface(arguments[0], Collection)) {
        var edges = arguments[0];
        for (var i0 = edges.iterator(); i0.hasNext();) {
          var edge0 = i0.next();
          this$1.computeVertexSnaps(edge0);
        }
      } else if (arguments[0] instanceof NodedSegmentString) {
        var e = arguments[0];
        var pts0 = e.getCoordinates();
        for (var i = 0; i < pts0.length; i++) {
          var hotPixel = new HotPixel(pts0[i], this$1._scaleFactor, this$1._li);
          var isNodeAdded = this$1._pointSnapper.snap(hotPixel, e, i);
          if (isNodeAdded) {
            e.addIntersection(pts0[i], i);
          }
        }
      }
    };
    MCIndexSnapRounder.prototype.computeNodes = function computeNodes (inputSegmentStrings) {
      this._nodedSegStrings = inputSegmentStrings;
      this._noder = new MCIndexNoder();
      this._pointSnapper = new MCIndexPointSnapper(this._noder.getIndex());
      this.snapRound(inputSegmentStrings, this._li);
    };
    MCIndexSnapRounder.prototype.computeIntersectionSnaps = function computeIntersectionSnaps (snapPts) {
        var this$1 = this;

      for (var it = snapPts.iterator(); it.hasNext();) {
        var snapPt = it.next();
        var hotPixel = new HotPixel(snapPt, this$1._scaleFactor, this$1._li);
        this$1._pointSnapper.snap(hotPixel);
      }
    };
    MCIndexSnapRounder.prototype.interfaces_ = function interfaces_ () {
      return [Noder]
    };
    MCIndexSnapRounder.prototype.getClass = function getClass () {
      return MCIndexSnapRounder
    };

    var BufferOp = function BufferOp () {
      this._argGeom = null;
      this._distance = null;
      this._bufParams = new BufferParameters();
      this._resultGeometry = null;
      this._saveException = null;
      if (arguments.length === 1) {
        var g = arguments[0];
        this._argGeom = g;
      } else if (arguments.length === 2) {
        var g$1 = arguments[0];
        var bufParams = arguments[1];
        this._argGeom = g$1;
        this._bufParams = bufParams;
      }
    };

    var staticAccessors$32 = { CAP_ROUND: { configurable: true },CAP_BUTT: { configurable: true },CAP_FLAT: { configurable: true },CAP_SQUARE: { configurable: true },MAX_PRECISION_DIGITS: { configurable: true } };
    BufferOp.prototype.bufferFixedPrecision = function bufferFixedPrecision (fixedPM) {
      var noder = new ScaledNoder(new MCIndexSnapRounder(new PrecisionModel(1.0)), fixedPM.getScale());
      var bufBuilder = new BufferBuilder(this._bufParams);
      bufBuilder.setWorkingPrecisionModel(fixedPM);
      bufBuilder.setNoder(noder);
      this._resultGeometry = bufBuilder.buffer(this._argGeom, this._distance);
    };
    BufferOp.prototype.bufferReducedPrecision = function bufferReducedPrecision () {
        var this$1 = this;

      if (arguments.length === 0) {
        for (var precDigits = BufferOp.MAX_PRECISION_DIGITS; precDigits >= 0; precDigits--) {
          try {
            this$1.bufferReducedPrecision(precDigits);
          } catch (ex) {
            if (ex instanceof TopologyException) {
              this$1._saveException = ex;
            } else { throw ex }
          } finally {}
          if (this$1._resultGeometry !== null) { return null }
        }
        throw this._saveException
      } else if (arguments.length === 1) {
        var precisionDigits = arguments[0];
        var sizeBasedScaleFactor = BufferOp.precisionScaleFactor(this._argGeom, this._distance, precisionDigits);
        var fixedPM = new PrecisionModel(sizeBasedScaleFactor);
        this.bufferFixedPrecision(fixedPM);
      }
    };
    BufferOp.prototype.computeGeometry = function computeGeometry () {
      this.bufferOriginalPrecision();
      if (this._resultGeometry !== null) { return null }
      var argPM = this._argGeom.getFactory().getPrecisionModel();
      if (argPM.getType() === PrecisionModel.FIXED) { this.bufferFixedPrecision(argPM); } else { this.bufferReducedPrecision(); }
    };
    BufferOp.prototype.setQuadrantSegments = function setQuadrantSegments (quadrantSegments) {
      this._bufParams.setQuadrantSegments(quadrantSegments);
    };
    BufferOp.prototype.bufferOriginalPrecision = function bufferOriginalPrecision () {
      try {
        var bufBuilder = new BufferBuilder(this._bufParams);
        this._resultGeometry = bufBuilder.buffer(this._argGeom, this._distance);
      } catch (ex) {
        if (ex instanceof RuntimeException) {
          this._saveException = ex;
        } else { throw ex }
      } finally {}
    };
    BufferOp.prototype.getResultGeometry = function getResultGeometry (distance) {
      this._distance = distance;
      this.computeGeometry();
      return this._resultGeometry
    };
    BufferOp.prototype.setEndCapStyle = function setEndCapStyle (endCapStyle) {
      this._bufParams.setEndCapStyle(endCapStyle);
    };
    BufferOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferOp.prototype.getClass = function getClass () {
      return BufferOp
    };
    BufferOp.bufferOp = function bufferOp () {
      if (arguments.length === 2) {
        var g = arguments[0];
        var distance = arguments[1];
        var gBuf = new BufferOp(g);
        var geomBuf = gBuf.getResultGeometry(distance);
        return geomBuf
      } else if (arguments.length === 3) {
        if (Number.isInteger(arguments[2]) && (arguments[0] instanceof Geometry && typeof arguments[1] === 'number')) {
          var g$1 = arguments[0];
          var distance$1 = arguments[1];
          var quadrantSegments = arguments[2];
          var bufOp = new BufferOp(g$1);
          bufOp.setQuadrantSegments(quadrantSegments);
          var geomBuf$1 = bufOp.getResultGeometry(distance$1);
          return geomBuf$1
        } else if (arguments[2] instanceof BufferParameters && (arguments[0] instanceof Geometry && typeof arguments[1] === 'number')) {
          var g$2 = arguments[0];
          var distance$2 = arguments[1];
          var params = arguments[2];
          var bufOp$1 = new BufferOp(g$2, params);
          var geomBuf$2 = bufOp$1.getResultGeometry(distance$2);
          return geomBuf$2
        }
      } else if (arguments.length === 4) {
        var g$3 = arguments[0];
        var distance$3 = arguments[1];
        var quadrantSegments$1 = arguments[2];
        var endCapStyle = arguments[3];
        var bufOp$2 = new BufferOp(g$3);
        bufOp$2.setQuadrantSegments(quadrantSegments$1);
        bufOp$2.setEndCapStyle(endCapStyle);
        var geomBuf$3 = bufOp$2.getResultGeometry(distance$3);
        return geomBuf$3
      }
    };
    BufferOp.precisionScaleFactor = function precisionScaleFactor (g, distance, maxPrecisionDigits) {
      var env = g.getEnvelopeInternal();
      var envMax = MathUtil.max(Math.abs(env.getMaxX()), Math.abs(env.getMaxY()), Math.abs(env.getMinX()), Math.abs(env.getMinY()));
      var expandByDistance = distance > 0.0 ? distance : 0.0;
      var bufEnvMax = envMax + 2 * expandByDistance;
      var bufEnvPrecisionDigits = Math.trunc(Math.log(bufEnvMax) / Math.log(10) + 1.0);
      var minUnitLog10 = maxPrecisionDigits - bufEnvPrecisionDigits;
      var scaleFactor = Math.pow(10.0, minUnitLog10);
      return scaleFactor
    };
    staticAccessors$32.CAP_ROUND.get = function () { return BufferParameters.CAP_ROUND };
    staticAccessors$32.CAP_BUTT.get = function () { return BufferParameters.CAP_FLAT };
    staticAccessors$32.CAP_FLAT.get = function () { return BufferParameters.CAP_FLAT };
    staticAccessors$32.CAP_SQUARE.get = function () { return BufferParameters.CAP_SQUARE };
    staticAccessors$32.MAX_PRECISION_DIGITS.get = function () { return 12 };

    Object.defineProperties( BufferOp, staticAccessors$32 );

    var PointPairDistance = function PointPairDistance () {
      this._pt = [new Coordinate(), new Coordinate()];
      this._distance = Double.NaN;
      this._isNull = true;
    };
    PointPairDistance.prototype.getCoordinates = function getCoordinates () {
      return this._pt
    };
    PointPairDistance.prototype.getCoordinate = function getCoordinate (i) {
      return this._pt[i]
    };
    PointPairDistance.prototype.setMinimum = function setMinimum () {
      if (arguments.length === 1) {
        var ptDist = arguments[0];
        this.setMinimum(ptDist._pt[0], ptDist._pt[1]);
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        if (this._isNull) {
          this.initialize(p0, p1);
          return null
        }
        var dist = p0.distance(p1);
        if (dist < this._distance) { this.initialize(p0, p1, dist); }
      }
    };
    PointPairDistance.prototype.initialize = function initialize () {
      if (arguments.length === 0) {
        this._isNull = true;
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        this._pt[0].setCoordinate(p0);
        this._pt[1].setCoordinate(p1);
        this._distance = p0.distance(p1);
        this._isNull = false;
      } else if (arguments.length === 3) {
        var p0$1 = arguments[0];
        var p1$1 = arguments[1];
        var distance = arguments[2];
        this._pt[0].setCoordinate(p0$1);
        this._pt[1].setCoordinate(p1$1);
        this._distance = distance;
        this._isNull = false;
      }
    };
    PointPairDistance.prototype.getDistance = function getDistance () {
      return this._distance
    };
    PointPairDistance.prototype.setMaximum = function setMaximum () {
      if (arguments.length === 1) {
        var ptDist = arguments[0];
        this.setMaximum(ptDist._pt[0], ptDist._pt[1]);
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        if (this._isNull) {
          this.initialize(p0, p1);
          return null
        }
        var dist = p0.distance(p1);
        if (dist > this._distance) { this.initialize(p0, p1, dist); }
      }
    };
    PointPairDistance.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PointPairDistance.prototype.getClass = function getClass () {
      return PointPairDistance
    };

    var DistanceToPointFinder = function DistanceToPointFinder () {};

    DistanceToPointFinder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    DistanceToPointFinder.prototype.getClass = function getClass () {
      return DistanceToPointFinder
    };
    DistanceToPointFinder.computeDistance = function computeDistance () {
      if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof LineString$1 && arguments[1] instanceof Coordinate)) {
        var line = arguments[0];
        var pt = arguments[1];
        var ptDist = arguments[2];
        var coords = line.getCoordinates();
        var tempSegment = new LineSegment();
        for (var i = 0; i < coords.length - 1; i++) {
          tempSegment.setCoordinates(coords[i], coords[i + 1]);
          var closestPt = tempSegment.closestPoint(pt);
          ptDist.setMinimum(closestPt, pt);
        }
      } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof Polygon && arguments[1] instanceof Coordinate)) {
        var poly = arguments[0];
        var pt$1 = arguments[1];
        var ptDist$1 = arguments[2];
        DistanceToPointFinder.computeDistance(poly.getExteriorRing(), pt$1, ptDist$1);
        for (var i$1 = 0; i$1 < poly.getNumInteriorRing(); i$1++) {
          DistanceToPointFinder.computeDistance(poly.getInteriorRingN(i$1), pt$1, ptDist$1);
        }
      } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof Geometry && arguments[1] instanceof Coordinate)) {
        var geom = arguments[0];
        var pt$2 = arguments[1];
        var ptDist$2 = arguments[2];
        if (geom instanceof LineString$1) {
          DistanceToPointFinder.computeDistance(geom, pt$2, ptDist$2);
        } else if (geom instanceof Polygon) {
          DistanceToPointFinder.computeDistance(geom, pt$2, ptDist$2);
        } else if (geom instanceof GeometryCollection) {
          var gc = geom;
          for (var i$2 = 0; i$2 < gc.getNumGeometries(); i$2++) {
            var g = gc.getGeometryN(i$2);
            DistanceToPointFinder.computeDistance(g, pt$2, ptDist$2);
          }
        } else {
          ptDist$2.setMinimum(geom.getCoordinate(), pt$2);
        }
      } else if (arguments[2] instanceof PointPairDistance && (arguments[0] instanceof LineSegment && arguments[1] instanceof Coordinate)) {
        var segment = arguments[0];
        var pt$3 = arguments[1];
        var ptDist$3 = arguments[2];
        var closestPt$1 = segment.closestPoint(pt$3);
        ptDist$3.setMinimum(closestPt$1, pt$3);
      }
    };

    var BufferCurveMaximumDistanceFinder = function BufferCurveMaximumDistanceFinder (inputGeom) {
      this._maxPtDist = new PointPairDistance();
      this._inputGeom = inputGeom || null;
    };

    var staticAccessors$36 = { MaxPointDistanceFilter: { configurable: true },MaxMidpointDistanceFilter: { configurable: true } };
    BufferCurveMaximumDistanceFinder.prototype.computeMaxMidpointDistance = function computeMaxMidpointDistance (curve) {
      var distFilter = new MaxMidpointDistanceFilter(this._inputGeom);
      curve.apply(distFilter);
      this._maxPtDist.setMaximum(distFilter.getMaxPointDistance());
    };
    BufferCurveMaximumDistanceFinder.prototype.computeMaxVertexDistance = function computeMaxVertexDistance (curve) {
      var distFilter = new MaxPointDistanceFilter(this._inputGeom);
      curve.apply(distFilter);
      this._maxPtDist.setMaximum(distFilter.getMaxPointDistance());
    };
    BufferCurveMaximumDistanceFinder.prototype.findDistance = function findDistance (bufferCurve) {
      this.computeMaxVertexDistance(bufferCurve);
      this.computeMaxMidpointDistance(bufferCurve);
      return this._maxPtDist.getDistance()
    };
    BufferCurveMaximumDistanceFinder.prototype.getDistancePoints = function getDistancePoints () {
      return this._maxPtDist
    };
    BufferCurveMaximumDistanceFinder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferCurveMaximumDistanceFinder.prototype.getClass = function getClass () {
      return BufferCurveMaximumDistanceFinder
    };
    staticAccessors$36.MaxPointDistanceFilter.get = function () { return MaxPointDistanceFilter };
    staticAccessors$36.MaxMidpointDistanceFilter.get = function () { return MaxMidpointDistanceFilter };

    Object.defineProperties( BufferCurveMaximumDistanceFinder, staticAccessors$36 );

    var MaxPointDistanceFilter = function MaxPointDistanceFilter (geom) {
      this._maxPtDist = new PointPairDistance();
      this._minPtDist = new PointPairDistance();
      this._geom = geom || null;
    };
    MaxPointDistanceFilter.prototype.filter = function filter (pt) {
      this._minPtDist.initialize();
      DistanceToPointFinder.computeDistance(this._geom, pt, this._minPtDist);
      this._maxPtDist.setMaximum(this._minPtDist);
    };
    MaxPointDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance () {
      return this._maxPtDist
    };
    MaxPointDistanceFilter.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateFilter]
    };
    MaxPointDistanceFilter.prototype.getClass = function getClass () {
      return MaxPointDistanceFilter
    };

    var MaxMidpointDistanceFilter = function MaxMidpointDistanceFilter (geom) {
      this._maxPtDist = new PointPairDistance();
      this._minPtDist = new PointPairDistance();
      this._geom = geom || null;
    };
    MaxMidpointDistanceFilter.prototype.filter = function filter (seq, index) {
      if (index === 0) { return null }
      var p0 = seq.getCoordinate(index - 1);
      var p1 = seq.getCoordinate(index);
      var midPt = new Coordinate((p0.x + p1.x) / 2, (p0.y + p1.y) / 2);
      this._minPtDist.initialize();
      DistanceToPointFinder.computeDistance(this._geom, midPt, this._minPtDist);
      this._maxPtDist.setMaximum(this._minPtDist);
    };
    MaxMidpointDistanceFilter.prototype.isDone = function isDone () {
      return false
    };
    MaxMidpointDistanceFilter.prototype.isGeometryChanged = function isGeometryChanged () {
      return false
    };
    MaxMidpointDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance () {
      return this._maxPtDist
    };
    MaxMidpointDistanceFilter.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateSequenceFilter]
    };
    MaxMidpointDistanceFilter.prototype.getClass = function getClass () {
      return MaxMidpointDistanceFilter
    };

    var PolygonExtracter = function PolygonExtracter (comps) {
      this._comps = comps || null;
    };
    PolygonExtracter.prototype.filter = function filter (geom) {
      if (geom instanceof Polygon) { this._comps.add(geom); }
    };
    PolygonExtracter.prototype.interfaces_ = function interfaces_ () {
      return [GeometryFilter]
    };
    PolygonExtracter.prototype.getClass = function getClass () {
      return PolygonExtracter
    };
    PolygonExtracter.getPolygons = function getPolygons () {
      if (arguments.length === 1) {
        var geom = arguments[0];
        return PolygonExtracter.getPolygons(geom, new ArrayList())
      } else if (arguments.length === 2) {
        var geom$1 = arguments[0];
        var list = arguments[1];
        if (geom$1 instanceof Polygon) {
          list.add(geom$1);
        } else if (geom$1 instanceof GeometryCollection) {
          geom$1.apply(new PolygonExtracter(list));
        }
        return list
      }
    };

    var LinearComponentExtracter = function LinearComponentExtracter () {
      this._lines = null;
      this._isForcedToLineString = false;
      if (arguments.length === 1) {
        var lines = arguments[0];
        this._lines = lines;
      } else if (arguments.length === 2) {
        var lines$1 = arguments[0];
        var isForcedToLineString = arguments[1];
        this._lines = lines$1;
        this._isForcedToLineString = isForcedToLineString;
      }
    };
    LinearComponentExtracter.prototype.filter = function filter (geom) {
      if (this._isForcedToLineString && geom instanceof LinearRing) {
        var line = geom.getFactory().createLineString(geom.getCoordinateSequence());
        this._lines.add(line);
        return null
      }
      if (geom instanceof LineString$1) { this._lines.add(geom); }
    };
    LinearComponentExtracter.prototype.setForceToLineString = function setForceToLineString (isForcedToLineString) {
      this._isForcedToLineString = isForcedToLineString;
    };
    LinearComponentExtracter.prototype.interfaces_ = function interfaces_ () {
      return [GeometryComponentFilter]
    };
    LinearComponentExtracter.prototype.getClass = function getClass () {
      return LinearComponentExtracter
    };
    LinearComponentExtracter.getGeometry = function getGeometry () {
      if (arguments.length === 1) {
        var geom = arguments[0];
        return geom.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom))
      } else if (arguments.length === 2) {
        var geom$1 = arguments[0];
        var forceToLineString = arguments[1];
        return geom$1.getFactory().buildGeometry(LinearComponentExtracter.getLines(geom$1, forceToLineString))
      }
    };
    LinearComponentExtracter.getLines = function getLines () {
      if (arguments.length === 1) {
        var geom = arguments[0];
        return LinearComponentExtracter.getLines(geom, false)
      } else if (arguments.length === 2) {
        if (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], Collection)) {
          var geoms = arguments[0];
          var lines$1 = arguments[1];
          for (var i = geoms.iterator(); i.hasNext();) {
            var g = i.next();
            LinearComponentExtracter.getLines(g, lines$1);
          }
          return lines$1
        } else if (arguments[0] instanceof Geometry && typeof arguments[1] === 'boolean') {
          var geom$1 = arguments[0];
          var forceToLineString = arguments[1];
          var lines = new ArrayList();
          geom$1.apply(new LinearComponentExtracter(lines, forceToLineString));
          return lines
        } else if (arguments[0] instanceof Geometry && hasInterface(arguments[1], Collection)) {
          var geom$2 = arguments[0];
          var lines$2 = arguments[1];
          if (geom$2 instanceof LineString$1) {
            lines$2.add(geom$2);
          } else {
            geom$2.apply(new LinearComponentExtracter(lines$2));
          }
          return lines$2
        }
      } else if (arguments.length === 3) {
        if (typeof arguments[2] === 'boolean' && (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], Collection))) {
          var geoms$1 = arguments[0];
          var lines$3 = arguments[1];
          var forceToLineString$1 = arguments[2];
          for (var i$1 = geoms$1.iterator(); i$1.hasNext();) {
            var g$1 = i$1.next();
            LinearComponentExtracter.getLines(g$1, lines$3, forceToLineString$1);
          }
          return lines$3
        } else if (typeof arguments[2] === 'boolean' && (arguments[0] instanceof Geometry && hasInterface(arguments[1], Collection))) {
          var geom$3 = arguments[0];
          var lines$4 = arguments[1];
          var forceToLineString$2 = arguments[2];
          geom$3.apply(new LinearComponentExtracter(lines$4, forceToLineString$2));
          return lines$4
        }
      }
    };

    var PointLocator = function PointLocator () {
      this._boundaryRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
      this._isIn = null;
      this._numBoundaries = null;
      if (arguments.length === 0) ; else if (arguments.length === 1) {
        var boundaryRule = arguments[0];
        if (boundaryRule === null) { throw new IllegalArgumentException('Rule must be non-null') }
        this._boundaryRule = boundaryRule;
      }
    };
    PointLocator.prototype.locateInternal = function locateInternal () {
        var this$1 = this;

      if (arguments[0] instanceof Coordinate && arguments[1] instanceof Polygon) {
        var p = arguments[0];
        var poly = arguments[1];
        if (poly.isEmpty()) { return Location.EXTERIOR }
        var shell = poly.getExteriorRing();
        var shellLoc = this.locateInPolygonRing(p, shell);
        if (shellLoc === Location.EXTERIOR) { return Location.EXTERIOR }
        if (shellLoc === Location.BOUNDARY) { return Location.BOUNDARY }
        for (var i = 0; i < poly.getNumInteriorRing(); i++) {
          var hole = poly.getInteriorRingN(i);
          var holeLoc = this$1.locateInPolygonRing(p, hole);
          if (holeLoc === Location.INTERIOR) { return Location.EXTERIOR }
          if (holeLoc === Location.BOUNDARY) { return Location.BOUNDARY }
        }
        return Location.INTERIOR
      } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof LineString$1) {
        var p$1 = arguments[0];
        var l = arguments[1];
        if (!l.getEnvelopeInternal().intersects(p$1)) { return Location.EXTERIOR }
        var pt = l.getCoordinates();
        if (!l.isClosed()) {
          if (p$1.equals(pt[0]) || p$1.equals(pt[pt.length - 1])) {
            return Location.BOUNDARY
          }
        }
        if (CGAlgorithms.isOnLine(p$1, pt)) { return Location.INTERIOR }
        return Location.EXTERIOR
      } else if (arguments[0] instanceof Coordinate && arguments[1] instanceof Point) {
        var p$2 = arguments[0];
        var pt$1 = arguments[1];
        var ptCoord = pt$1.getCoordinate();
        if (ptCoord.equals2D(p$2)) { return Location.INTERIOR }
        return Location.EXTERIOR
      }
    };
    PointLocator.prototype.locateInPolygonRing = function locateInPolygonRing (p, ring) {
      if (!ring.getEnvelopeInternal().intersects(p)) { return Location.EXTERIOR }
      return CGAlgorithms.locatePointInRing(p, ring.getCoordinates())
    };
    PointLocator.prototype.intersects = function intersects (p, geom) {
      return this.locate(p, geom) !== Location.EXTERIOR
    };
    PointLocator.prototype.updateLocationInfo = function updateLocationInfo (loc) {
      if (loc === Location.INTERIOR) { this._isIn = true; }
      if (loc === Location.BOUNDARY) { this._numBoundaries++; }
    };
    PointLocator.prototype.computeLocation = function computeLocation (p, geom) {
        var this$1 = this;

      if (geom instanceof Point) {
        this.updateLocationInfo(this.locateInternal(p, geom));
      }
      if (geom instanceof LineString$1) {
        this.updateLocationInfo(this.locateInternal(p, geom));
      } else if (geom instanceof Polygon) {
        this.updateLocationInfo(this.locateInternal(p, geom));
      } else if (geom instanceof MultiLineString) {
        var ml = geom;
        for (var i = 0; i < ml.getNumGeometries(); i++) {
          var l = ml.getGeometryN(i);
          this$1.updateLocationInfo(this$1.locateInternal(p, l));
        }
      } else if (geom instanceof MultiPolygon) {
        var mpoly = geom;
        for (var i$1 = 0; i$1 < mpoly.getNumGeometries(); i$1++) {
          var poly = mpoly.getGeometryN(i$1);
          this$1.updateLocationInfo(this$1.locateInternal(p, poly));
        }
      } else if (geom instanceof GeometryCollection) {
        var geomi = new GeometryCollectionIterator(geom);
        while (geomi.hasNext()) {
          var g2 = geomi.next();
          if (g2 !== geom) { this$1.computeLocation(p, g2); }
        }
      }
    };
    PointLocator.prototype.locate = function locate (p, geom) {
      if (geom.isEmpty()) { return Location.EXTERIOR }
      if (geom instanceof LineString$1) {
        return this.locateInternal(p, geom)
      } else if (geom instanceof Polygon) {
        return this.locateInternal(p, geom)
      }
      this._isIn = false;
      this._numBoundaries = 0;
      this.computeLocation(p, geom);
      if (this._boundaryRule.isInBoundary(this._numBoundaries)) { return Location.BOUNDARY }
      if (this._numBoundaries > 0 || this._isIn) { return Location.INTERIOR }
      return Location.EXTERIOR
    };
    PointLocator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PointLocator.prototype.getClass = function getClass () {
      return PointLocator
    };

    var GeometryLocation = function GeometryLocation () {
      this._component = null;
      this._segIndex = null;
      this._pt = null;
      if (arguments.length === 2) {
        var component = arguments[0];
        var pt = arguments[1];
        GeometryLocation.call(this, component, GeometryLocation.INSIDE_AREA, pt);
      } else if (arguments.length === 3) {
        var component$1 = arguments[0];
        var segIndex = arguments[1];
        var pt$1 = arguments[2];
        this._component = component$1;
        this._segIndex = segIndex;
        this._pt = pt$1;
      }
    };

    var staticAccessors$38 = { INSIDE_AREA: { configurable: true } };
    GeometryLocation.prototype.isInsideArea = function isInsideArea () {
      return this._segIndex === GeometryLocation.INSIDE_AREA
    };
    GeometryLocation.prototype.getCoordinate = function getCoordinate () {
      return this._pt
    };
    GeometryLocation.prototype.getGeometryComponent = function getGeometryComponent () {
      return this._component
    };
    GeometryLocation.prototype.getSegmentIndex = function getSegmentIndex () {
      return this._segIndex
    };
    GeometryLocation.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryLocation.prototype.getClass = function getClass () {
      return GeometryLocation
    };
    staticAccessors$38.INSIDE_AREA.get = function () { return -1 };

    Object.defineProperties( GeometryLocation, staticAccessors$38 );

    var PointExtracter = function PointExtracter (pts) {
      this._pts = pts || null;
    };
    PointExtracter.prototype.filter = function filter (geom) {
      if (geom instanceof Point) { this._pts.add(geom); }
    };
    PointExtracter.prototype.interfaces_ = function interfaces_ () {
      return [GeometryFilter]
    };
    PointExtracter.prototype.getClass = function getClass () {
      return PointExtracter
    };
    PointExtracter.getPoints = function getPoints () {
      if (arguments.length === 1) {
        var geom = arguments[0];
        if (geom instanceof Point) {
          return Collections.singletonList(geom)
        }
        return PointExtracter.getPoints(geom, new ArrayList())
      } else if (arguments.length === 2) {
        var geom$1 = arguments[0];
        var list = arguments[1];
        if (geom$1 instanceof Point) {
          list.add(geom$1);
        } else if (geom$1 instanceof GeometryCollection) {
          geom$1.apply(new PointExtracter(list));
        }
        return list
      }
    };

    var ConnectedElementLocationFilter = function ConnectedElementLocationFilter () {
      this._locations = null;
      var locations = arguments[0];
      this._locations = locations;
    };
    ConnectedElementLocationFilter.prototype.filter = function filter (geom) {
      if (geom instanceof Point || geom instanceof LineString$1 || geom instanceof Polygon) { this._locations.add(new GeometryLocation(geom, 0, geom.getCoordinate())); }
    };
    ConnectedElementLocationFilter.prototype.interfaces_ = function interfaces_ () {
      return [GeometryFilter]
    };
    ConnectedElementLocationFilter.prototype.getClass = function getClass () {
      return ConnectedElementLocationFilter
    };
    ConnectedElementLocationFilter.getLocations = function getLocations (geom) {
      var locations = new ArrayList();
      geom.apply(new ConnectedElementLocationFilter(locations));
      return locations
    };

    var DistanceOp = function DistanceOp () {
      this._geom = null;
      this._terminateDistance = 0.0;
      this._ptLocator = new PointLocator();
      this._minDistanceLocation = null;
      this._minDistance = Double.MAX_VALUE;
      if (arguments.length === 2) {
        var g0 = arguments[0];
        var g1 = arguments[1];
        this._geom = [g0, g1];
        this._terminateDistance = 0.0;
      } else if (arguments.length === 3) {
        var g0$1 = arguments[0];
        var g1$1 = arguments[1];
        var terminateDistance = arguments[2];
        this._geom = new Array(2).fill(null);
        this._geom[0] = g0$1;
        this._geom[1] = g1$1;
        this._terminateDistance = terminateDistance;
      }
    };
    DistanceOp.prototype.computeContainmentDistance = function computeContainmentDistance () {
        var this$1 = this;

      if (arguments.length === 0) {
        var locPtPoly = new Array(2).fill(null);
        this.computeContainmentDistance(0, locPtPoly);
        if (this._minDistance <= this._terminateDistance) { return null }
        this.computeContainmentDistance(1, locPtPoly);
      } else if (arguments.length === 2) {
        var polyGeomIndex = arguments[0];
        var locPtPoly$1 = arguments[1];
        var locationsIndex = 1 - polyGeomIndex;
        var polys = PolygonExtracter.getPolygons(this._geom[polyGeomIndex]);
        if (polys.size() > 0) {
          var insideLocs = ConnectedElementLocationFilter.getLocations(this._geom[locationsIndex]);
          this.computeContainmentDistance(insideLocs, polys, locPtPoly$1);
          if (this._minDistance <= this._terminateDistance) {
            this._minDistanceLocation[locationsIndex] = locPtPoly$1[0];
            this._minDistanceLocation[polyGeomIndex] = locPtPoly$1[1];
            return null
          }
        }
      } else if (arguments.length === 3) {
        if (arguments[2] instanceof Array && (hasInterface(arguments[0], List) && hasInterface(arguments[1], List))) {
          var locs = arguments[0];
          var polys$1 = arguments[1];
          var locPtPoly$2 = arguments[2];
          for (var i = 0; i < locs.size(); i++) {
            var loc = locs.get(i);
            for (var j = 0; j < polys$1.size(); j++) {
              this$1.computeContainmentDistance(loc, polys$1.get(j), locPtPoly$2);
              if (this$1._minDistance <= this$1._terminateDistance) { return null }
            }
          }
        } else if (arguments[2] instanceof Array && (arguments[0] instanceof GeometryLocation && arguments[1] instanceof Polygon)) {
          var ptLoc = arguments[0];
          var poly = arguments[1];
          var locPtPoly$3 = arguments[2];
          var pt = ptLoc.getCoordinate();
          if (Location.EXTERIOR !== this._ptLocator.locate(pt, poly)) {
            this._minDistance = 0.0;
            locPtPoly$3[0] = ptLoc;
            locPtPoly$3[1] = new GeometryLocation(poly, pt);

            return null
          }
        }
      }
    };
    DistanceOp.prototype.computeMinDistanceLinesPoints = function computeMinDistanceLinesPoints (lines, points, locGeom) {
        var this$1 = this;

      for (var i = 0; i < lines.size(); i++) {
        var line = lines.get(i);
        for (var j = 0; j < points.size(); j++) {
          var pt = points.get(j);
          this$1.computeMinDistance(line, pt, locGeom);
          if (this$1._minDistance <= this$1._terminateDistance) { return null }
        }
      }
    };
    DistanceOp.prototype.computeFacetDistance = function computeFacetDistance () {
      var locGeom = new Array(2).fill(null);
      var lines0 = LinearComponentExtracter.getLines(this._geom[0]);
      var lines1 = LinearComponentExtracter.getLines(this._geom[1]);
      var pts0 = PointExtracter.getPoints(this._geom[0]);
      var pts1 = PointExtracter.getPoints(this._geom[1]);
      this.computeMinDistanceLines(lines0, lines1, locGeom);
      this.updateMinDistance(locGeom, false);
      if (this._minDistance <= this._terminateDistance) { return null }
      locGeom[0] = null;
      locGeom[1] = null;
      this.computeMinDistanceLinesPoints(lines0, pts1, locGeom);
      this.updateMinDistance(locGeom, false);
      if (this._minDistance <= this._terminateDistance) { return null }
      locGeom[0] = null;
      locGeom[1] = null;
      this.computeMinDistanceLinesPoints(lines1, pts0, locGeom);
      this.updateMinDistance(locGeom, true);
      if (this._minDistance <= this._terminateDistance) { return null }
      locGeom[0] = null;
      locGeom[1] = null;
      this.computeMinDistancePoints(pts0, pts1, locGeom);
      this.updateMinDistance(locGeom, false);
    };
    DistanceOp.prototype.nearestLocations = function nearestLocations () {
      this.computeMinDistance();
      return this._minDistanceLocation
    };
    DistanceOp.prototype.updateMinDistance = function updateMinDistance (locGeom, flip) {
      if (locGeom[0] === null) { return null }
      if (flip) {
        this._minDistanceLocation[0] = locGeom[1];
        this._minDistanceLocation[1] = locGeom[0];
      } else {
        this._minDistanceLocation[0] = locGeom[0];
        this._minDistanceLocation[1] = locGeom[1];
      }
    };
    DistanceOp.prototype.nearestPoints = function nearestPoints () {
      this.computeMinDistance();
      var nearestPts = [this._minDistanceLocation[0].getCoordinate(), this._minDistanceLocation[1].getCoordinate()];
      return nearestPts
    };
    DistanceOp.prototype.computeMinDistance = function computeMinDistance () {
        var this$1 = this;

      if (arguments.length === 0) {
        if (this._minDistanceLocation !== null) { return null }
        this._minDistanceLocation = new Array(2).fill(null);
        this.computeContainmentDistance();
        if (this._minDistance <= this._terminateDistance) { return null }
        this.computeFacetDistance();
      } else if (arguments.length === 3) {
        if (arguments[2] instanceof Array && (arguments[0] instanceof LineString$1 && arguments[1] instanceof Point)) {
          var line = arguments[0];
          var pt = arguments[1];
          var locGeom = arguments[2];
          if (line.getEnvelopeInternal().distance(pt.getEnvelopeInternal()) > this._minDistance) { return null }
          var coord0 = line.getCoordinates();
          var coord = pt.getCoordinate();
          for (var i = 0; i < coord0.length - 1; i++) {
            var dist = CGAlgorithms.distancePointLine(coord, coord0[i], coord0[i + 1]);
            if (dist < this$1._minDistance) {
              this$1._minDistance = dist;
              var seg = new LineSegment(coord0[i], coord0[i + 1]);
              var segClosestPoint = seg.closestPoint(coord);
              locGeom[0] = new GeometryLocation(line, i, segClosestPoint);
              locGeom[1] = new GeometryLocation(pt, 0, coord);
            }
            if (this$1._minDistance <= this$1._terminateDistance) { return null }
          }
        } else if (arguments[2] instanceof Array && (arguments[0] instanceof LineString$1 && arguments[1] instanceof LineString$1)) {
          var line0 = arguments[0];
          var line1 = arguments[1];
          var locGeom$1 = arguments[2];
          if (line0.getEnvelopeInternal().distance(line1.getEnvelopeInternal()) > this._minDistance) { return null }
          var coord0$1 = line0.getCoordinates();
          var coord1 = line1.getCoordinates();
          for (var i$1 = 0; i$1 < coord0$1.length - 1; i$1++) {
            for (var j = 0; j < coord1.length - 1; j++) {
              var dist$1 = CGAlgorithms.distanceLineLine(coord0$1[i$1], coord0$1[i$1 + 1], coord1[j], coord1[j + 1]);
              if (dist$1 < this$1._minDistance) {
                this$1._minDistance = dist$1;
                var seg0 = new LineSegment(coord0$1[i$1], coord0$1[i$1 + 1]);
                var seg1 = new LineSegment(coord1[j], coord1[j + 1]);
                var closestPt = seg0.closestPoints(seg1);
                locGeom$1[0] = new GeometryLocation(line0, i$1, closestPt[0]);
                locGeom$1[1] = new GeometryLocation(line1, j, closestPt[1]);
              }
              if (this$1._minDistance <= this$1._terminateDistance) { return null }
            }
          }
        }
      }
    };
    DistanceOp.prototype.computeMinDistancePoints = function computeMinDistancePoints (points0, points1, locGeom) {
        var this$1 = this;

      for (var i = 0; i < points0.size(); i++) {
        var pt0 = points0.get(i);
        for (var j = 0; j < points1.size(); j++) {
          var pt1 = points1.get(j);
          var dist = pt0.getCoordinate().distance(pt1.getCoordinate());
          if (dist < this$1._minDistance) {
            this$1._minDistance = dist;
            locGeom[0] = new GeometryLocation(pt0, 0, pt0.getCoordinate());
            locGeom[1] = new GeometryLocation(pt1, 0, pt1.getCoordinate());
          }
          if (this$1._minDistance <= this$1._terminateDistance) { return null }
        }
      }
    };
    DistanceOp.prototype.distance = function distance () {
      if (this._geom[0] === null || this._geom[1] === null) { throw new IllegalArgumentException('null geometries are not supported') }
      if (this._geom[0].isEmpty() || this._geom[1].isEmpty()) { return 0.0 }
      this.computeMinDistance();
      return this._minDistance
    };
    DistanceOp.prototype.computeMinDistanceLines = function computeMinDistanceLines (lines0, lines1, locGeom) {
        var this$1 = this;

      for (var i = 0; i < lines0.size(); i++) {
        var line0 = lines0.get(i);
        for (var j = 0; j < lines1.size(); j++) {
          var line1 = lines1.get(j);
          this$1.computeMinDistance(line0, line1, locGeom);
          if (this$1._minDistance <= this$1._terminateDistance) { return null }
        }
      }
    };
    DistanceOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    DistanceOp.prototype.getClass = function getClass () {
      return DistanceOp
    };
    DistanceOp.distance = function distance (g0, g1) {
      var distOp = new DistanceOp(g0, g1);
      return distOp.distance()
    };
    DistanceOp.isWithinDistance = function isWithinDistance (g0, g1, distance) {
      var distOp = new DistanceOp(g0, g1, distance);
      return distOp.distance() <= distance
    };
    DistanceOp.nearestPoints = function nearestPoints (g0, g1) {
      var distOp = new DistanceOp(g0, g1);
      return distOp.nearestPoints()
    };

    var PointPairDistance$2 = function PointPairDistance () {
      this._pt = [new Coordinate(), new Coordinate()];
      this._distance = Double.NaN;
      this._isNull = true;
    };
    PointPairDistance$2.prototype.getCoordinates = function getCoordinates () {
      return this._pt
    };
    PointPairDistance$2.prototype.getCoordinate = function getCoordinate (i) {
      return this._pt[i]
    };
    PointPairDistance$2.prototype.setMinimum = function setMinimum () {
      if (arguments.length === 1) {
        var ptDist = arguments[0];
        this.setMinimum(ptDist._pt[0], ptDist._pt[1]);
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        if (this._isNull) {
          this.initialize(p0, p1);
          return null
        }
        var dist = p0.distance(p1);
        if (dist < this._distance) { this.initialize(p0, p1, dist); }
      }
    };
    PointPairDistance$2.prototype.initialize = function initialize () {
      if (arguments.length === 0) {
        this._isNull = true;
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        this._pt[0].setCoordinate(p0);
        this._pt[1].setCoordinate(p1);
        this._distance = p0.distance(p1);
        this._isNull = false;
      } else if (arguments.length === 3) {
        var p0$1 = arguments[0];
        var p1$1 = arguments[1];
        var distance = arguments[2];
        this._pt[0].setCoordinate(p0$1);
        this._pt[1].setCoordinate(p1$1);
        this._distance = distance;
        this._isNull = false;
      }
    };
    PointPairDistance$2.prototype.toString = function toString () {
      return WKTWriter.toLineString(this._pt[0], this._pt[1])
    };
    PointPairDistance$2.prototype.getDistance = function getDistance () {
      return this._distance
    };
    PointPairDistance$2.prototype.setMaximum = function setMaximum () {
      if (arguments.length === 1) {
        var ptDist = arguments[0];
        this.setMaximum(ptDist._pt[0], ptDist._pt[1]);
      } else if (arguments.length === 2) {
        var p0 = arguments[0];
        var p1 = arguments[1];
        if (this._isNull) {
          this.initialize(p0, p1);
          return null
        }
        var dist = p0.distance(p1);
        if (dist > this._distance) { this.initialize(p0, p1, dist); }
      }
    };
    PointPairDistance$2.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PointPairDistance$2.prototype.getClass = function getClass () {
      return PointPairDistance$2
    };

    var DistanceToPoint = function DistanceToPoint () {};

    DistanceToPoint.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    DistanceToPoint.prototype.getClass = function getClass () {
      return DistanceToPoint
    };
    DistanceToPoint.computeDistance = function computeDistance () {
      if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof LineString$1 && arguments[1] instanceof Coordinate)) {
        var line = arguments[0];
        var pt = arguments[1];
        var ptDist = arguments[2];
        var tempSegment = new LineSegment();
        var coords = line.getCoordinates();
        for (var i = 0; i < coords.length - 1; i++) {
          tempSegment.setCoordinates(coords[i], coords[i + 1]);
          var closestPt = tempSegment.closestPoint(pt);
          ptDist.setMinimum(closestPt, pt);
        }
      } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof Polygon && arguments[1] instanceof Coordinate)) {
        var poly = arguments[0];
        var pt$1 = arguments[1];
        var ptDist$1 = arguments[2];
        DistanceToPoint.computeDistance(poly.getExteriorRing(), pt$1, ptDist$1);
        for (var i$1 = 0; i$1 < poly.getNumInteriorRing(); i$1++) {
          DistanceToPoint.computeDistance(poly.getInteriorRingN(i$1), pt$1, ptDist$1);
        }
      } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof Geometry && arguments[1] instanceof Coordinate)) {
        var geom = arguments[0];
        var pt$2 = arguments[1];
        var ptDist$2 = arguments[2];
        if (geom instanceof LineString$1) {
          DistanceToPoint.computeDistance(geom, pt$2, ptDist$2);
        } else if (geom instanceof Polygon) {
          DistanceToPoint.computeDistance(geom, pt$2, ptDist$2);
        } else if (geom instanceof GeometryCollection) {
          var gc = geom;
          for (var i$2 = 0; i$2 < gc.getNumGeometries(); i$2++) {
            var g = gc.getGeometryN(i$2);
            DistanceToPoint.computeDistance(g, pt$2, ptDist$2);
          }
        } else {
          ptDist$2.setMinimum(geom.getCoordinate(), pt$2);
        }
      } else if (arguments[2] instanceof PointPairDistance$2 && (arguments[0] instanceof LineSegment && arguments[1] instanceof Coordinate)) {
        var segment = arguments[0];
        var pt$3 = arguments[1];
        var ptDist$3 = arguments[2];
        var closestPt$1 = segment.closestPoint(pt$3);
        ptDist$3.setMinimum(closestPt$1, pt$3);
      }
    };

    var DiscreteHausdorffDistance = function DiscreteHausdorffDistance () {
      this._g0 = null;
      this._g1 = null;
      this._ptDist = new PointPairDistance$2();
      this._densifyFrac = 0.0;
      var g0 = arguments[0];
      var g1 = arguments[1];
      this._g0 = g0;
      this._g1 = g1;
    };

    var staticAccessors$39 = { MaxPointDistanceFilter: { configurable: true },MaxDensifiedByFractionDistanceFilter: { configurable: true } };
    DiscreteHausdorffDistance.prototype.getCoordinates = function getCoordinates () {
      return this._ptDist.getCoordinates()
    };
    DiscreteHausdorffDistance.prototype.setDensifyFraction = function setDensifyFraction (densifyFrac) {
      if (densifyFrac > 1.0 || densifyFrac <= 0.0) { throw new IllegalArgumentException('Fraction is not in range (0.0 - 1.0]') }
      this._densifyFrac = densifyFrac;
    };
    DiscreteHausdorffDistance.prototype.compute = function compute (g0, g1) {
      this.computeOrientedDistance(g0, g1, this._ptDist);
      this.computeOrientedDistance(g1, g0, this._ptDist);
    };
    DiscreteHausdorffDistance.prototype.distance = function distance () {
      this.compute(this._g0, this._g1);
      return this._ptDist.getDistance()
    };
    DiscreteHausdorffDistance.prototype.computeOrientedDistance = function computeOrientedDistance (discreteGeom, geom, ptDist) {
      var distFilter = new MaxPointDistanceFilter$1(geom);
      discreteGeom.apply(distFilter);
      ptDist.setMaximum(distFilter.getMaxPointDistance());
      if (this._densifyFrac > 0) {
        var fracFilter = new MaxDensifiedByFractionDistanceFilter(geom, this._densifyFrac);
        discreteGeom.apply(fracFilter);
        ptDist.setMaximum(fracFilter.getMaxPointDistance());
      }
    };
    DiscreteHausdorffDistance.prototype.orientedDistance = function orientedDistance () {
      this.computeOrientedDistance(this._g0, this._g1, this._ptDist);
      return this._ptDist.getDistance()
    };
    DiscreteHausdorffDistance.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    DiscreteHausdorffDistance.prototype.getClass = function getClass () {
      return DiscreteHausdorffDistance
    };
    DiscreteHausdorffDistance.distance = function distance () {
      if (arguments.length === 2) {
        var g0 = arguments[0];
        var g1 = arguments[1];
        var dist = new DiscreteHausdorffDistance(g0, g1);
        return dist.distance()
      } else if (arguments.length === 3) {
        var g0$1 = arguments[0];
        var g1$1 = arguments[1];
        var densifyFrac = arguments[2];
        var dist$1 = new DiscreteHausdorffDistance(g0$1, g1$1);
        dist$1.setDensifyFraction(densifyFrac);
        return dist$1.distance()
      }
    };
    staticAccessors$39.MaxPointDistanceFilter.get = function () { return MaxPointDistanceFilter$1 };
    staticAccessors$39.MaxDensifiedByFractionDistanceFilter.get = function () { return MaxDensifiedByFractionDistanceFilter };

    Object.defineProperties( DiscreteHausdorffDistance, staticAccessors$39 );

    var MaxPointDistanceFilter$1 = function MaxPointDistanceFilter () {
      this._maxPtDist = new PointPairDistance$2();
      this._minPtDist = new PointPairDistance$2();
      this._euclideanDist = new DistanceToPoint();
      this._geom = null;
      var geom = arguments[0];
      this._geom = geom;
    };
    MaxPointDistanceFilter$1.prototype.filter = function filter (pt) {
      this._minPtDist.initialize();
      DistanceToPoint.computeDistance(this._geom, pt, this._minPtDist);
      this._maxPtDist.setMaximum(this._minPtDist);
    };
    MaxPointDistanceFilter$1.prototype.getMaxPointDistance = function getMaxPointDistance () {
      return this._maxPtDist
    };
    MaxPointDistanceFilter$1.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateFilter]
    };
    MaxPointDistanceFilter$1.prototype.getClass = function getClass () {
      return MaxPointDistanceFilter$1
    };

    var MaxDensifiedByFractionDistanceFilter = function MaxDensifiedByFractionDistanceFilter () {
      this._maxPtDist = new PointPairDistance$2();
      this._minPtDist = new PointPairDistance$2();
      this._geom = null;
      this._numSubSegs = 0;
      var geom = arguments[0];
      var fraction = arguments[1];
      this._geom = geom;
      this._numSubSegs = Math.trunc(Math.round(1.0 / fraction));
    };
    MaxDensifiedByFractionDistanceFilter.prototype.filter = function filter (seq, index) {
        var this$1 = this;

      if (index === 0) { return null }
      var p0 = seq.getCoordinate(index - 1);
      var p1 = seq.getCoordinate(index);
      var delx = (p1.x - p0.x) / this._numSubSegs;
      var dely = (p1.y - p0.y) / this._numSubSegs;
      for (var i = 0; i < this._numSubSegs; i++) {
        var x = p0.x + i * delx;
        var y = p0.y + i * dely;
        var pt = new Coordinate(x, y);
        this$1._minPtDist.initialize();
        DistanceToPoint.computeDistance(this$1._geom, pt, this$1._minPtDist);
        this$1._maxPtDist.setMaximum(this$1._minPtDist);
      }
    };
    MaxDensifiedByFractionDistanceFilter.prototype.isDone = function isDone () {
      return false
    };
    MaxDensifiedByFractionDistanceFilter.prototype.isGeometryChanged = function isGeometryChanged () {
      return false
    };
    MaxDensifiedByFractionDistanceFilter.prototype.getMaxPointDistance = function getMaxPointDistance () {
      return this._maxPtDist
    };
    MaxDensifiedByFractionDistanceFilter.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateSequenceFilter]
    };
    MaxDensifiedByFractionDistanceFilter.prototype.getClass = function getClass () {
      return MaxDensifiedByFractionDistanceFilter
    };

    var BufferDistanceValidator = function BufferDistanceValidator (input, bufDistance, result) {
      this._minValidDistance = null;
      this._maxValidDistance = null;
      this._minDistanceFound = null;
      this._maxDistanceFound = null;
      this._isValid = true;
      this._errMsg = null;
      this._errorLocation = null;
      this._errorIndicator = null;
      this._input = input || null;
      this._bufDistance = bufDistance || null;
      this._result = result || null;
    };

    var staticAccessors$37 = { VERBOSE: { configurable: true },MAX_DISTANCE_DIFF_FRAC: { configurable: true } };
    BufferDistanceValidator.prototype.checkMaximumDistance = function checkMaximumDistance (input, bufCurve, maxDist) {
      var haus = new DiscreteHausdorffDistance(bufCurve, input);
      haus.setDensifyFraction(0.25);
      this._maxDistanceFound = haus.orientedDistance();
      if (this._maxDistanceFound > maxDist) {
        this._isValid = false;
        var pts = haus.getCoordinates();
        this._errorLocation = pts[1];
        this._errorIndicator = input.getFactory().createLineString(pts);
        this._errMsg = 'Distance between buffer curve and input is too large (' + this._maxDistanceFound + ' at ' + WKTWriter.toLineString(pts[0], pts[1]) + ')';
      }
    };
    BufferDistanceValidator.prototype.isValid = function isValid () {
      var posDistance = Math.abs(this._bufDistance);
      var distDelta = BufferDistanceValidator.MAX_DISTANCE_DIFF_FRAC * posDistance;
      this._minValidDistance = posDistance - distDelta;
      this._maxValidDistance = posDistance + distDelta;
      if (this._input.isEmpty() || this._result.isEmpty()) { return true }
      if (this._bufDistance > 0.0) {
        this.checkPositiveValid();
      } else {
        this.checkNegativeValid();
      }
      if (BufferDistanceValidator.VERBOSE) {
        System.out.println('Min Dist= ' + this._minDistanceFound + '  err= ' + (1.0 - this._minDistanceFound / this._bufDistance) + '  Max Dist= ' + this._maxDistanceFound + '  err= ' + (this._maxDistanceFound / this._bufDistance - 1.0));
      }
      return this._isValid
    };
    BufferDistanceValidator.prototype.checkNegativeValid = function checkNegativeValid () {
      if (!(this._input instanceof Polygon || this._input instanceof MultiPolygon || this._input instanceof GeometryCollection)) {
        return null
      }
      var inputCurve = this.getPolygonLines(this._input);
      this.checkMinimumDistance(inputCurve, this._result, this._minValidDistance);
      if (!this._isValid) { return null }
      this.checkMaximumDistance(inputCurve, this._result, this._maxValidDistance);
    };
    BufferDistanceValidator.prototype.getErrorIndicator = function getErrorIndicator () {
      return this._errorIndicator
    };
    BufferDistanceValidator.prototype.checkMinimumDistance = function checkMinimumDistance (g1, g2, minDist) {
      var distOp = new DistanceOp(g1, g2, minDist);
      this._minDistanceFound = distOp.distance();
      if (this._minDistanceFound < minDist) {
        this._isValid = false;
        var pts = distOp.nearestPoints();
        this._errorLocation = distOp.nearestPoints()[1];
        this._errorIndicator = g1.getFactory().createLineString(pts);
        this._errMsg = 'Distance between buffer curve and input is too small (' + this._minDistanceFound + ' at ' + WKTWriter.toLineString(pts[0], pts[1]) + ' )';
      }
    };
    BufferDistanceValidator.prototype.checkPositiveValid = function checkPositiveValid () {
      var bufCurve = this._result.getBoundary();
      this.checkMinimumDistance(this._input, bufCurve, this._minValidDistance);
      if (!this._isValid) { return null }
      this.checkMaximumDistance(this._input, bufCurve, this._maxValidDistance);
    };
    BufferDistanceValidator.prototype.getErrorLocation = function getErrorLocation () {
      return this._errorLocation
    };
    BufferDistanceValidator.prototype.getPolygonLines = function getPolygonLines (g) {
      var lines = new ArrayList();
      var lineExtracter = new LinearComponentExtracter(lines);
      var polys = PolygonExtracter.getPolygons(g);
      for (var i = polys.iterator(); i.hasNext();) {
        var poly = i.next();
        poly.apply(lineExtracter);
      }
      return g.getFactory().buildGeometry(lines)
    };
    BufferDistanceValidator.prototype.getErrorMessage = function getErrorMessage () {
      return this._errMsg
    };
    BufferDistanceValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferDistanceValidator.prototype.getClass = function getClass () {
      return BufferDistanceValidator
    };
    staticAccessors$37.VERBOSE.get = function () { return false };
    staticAccessors$37.MAX_DISTANCE_DIFF_FRAC.get = function () { return 0.012 };

    Object.defineProperties( BufferDistanceValidator, staticAccessors$37 );

    var BufferResultValidator = function BufferResultValidator (input, distance, result) {
      this._isValid = true;
      this._errorMsg = null;
      this._errorLocation = null;
      this._errorIndicator = null;
      this._input = input || null;
      this._distance = distance || null;
      this._result = result || null;
    };

    var staticAccessors$40 = { VERBOSE: { configurable: true },MAX_ENV_DIFF_FRAC: { configurable: true } };
    BufferResultValidator.prototype.isValid = function isValid () {
      this.checkPolygonal();
      if (!this._isValid) { return this._isValid }
      this.checkExpectedEmpty();
      if (!this._isValid) { return this._isValid }
      this.checkEnvelope();
      if (!this._isValid) { return this._isValid }
      this.checkArea();
      if (!this._isValid) { return this._isValid }
      this.checkDistance();
      return this._isValid
    };
    BufferResultValidator.prototype.checkEnvelope = function checkEnvelope () {
      if (this._distance < 0.0) { return null }
      var padding = this._distance * BufferResultValidator.MAX_ENV_DIFF_FRAC;
      if (padding === 0.0) { padding = 0.001; }
      var expectedEnv = new Envelope(this._input.getEnvelopeInternal());
      expectedEnv.expandBy(this._distance);
      var bufEnv = new Envelope(this._result.getEnvelopeInternal());
      bufEnv.expandBy(padding);
      if (!bufEnv.contains(expectedEnv)) {
        this._isValid = false;
        this._errorMsg = 'Buffer envelope is incorrect';
        this._errorIndicator = this._input.getFactory().toGeometry(bufEnv);
      }
      this.report('Envelope');
    };
    BufferResultValidator.prototype.checkDistance = function checkDistance () {
      var distValid = new BufferDistanceValidator(this._input, this._distance, this._result);
      if (!distValid.isValid()) {
        this._isValid = false;
        this._errorMsg = distValid.getErrorMessage();
        this._errorLocation = distValid.getErrorLocation();
        this._errorIndicator = distValid.getErrorIndicator();
      }
      this.report('Distance');
    };
    BufferResultValidator.prototype.checkArea = function checkArea () {
      var inputArea = this._input.getArea();
      var resultArea = this._result.getArea();
      if (this._distance > 0.0 && inputArea > resultArea) {
        this._isValid = false;
        this._errorMsg = 'Area of positive buffer is smaller than input';
        this._errorIndicator = this._result;
      }
      if (this._distance < 0.0 && inputArea < resultArea) {
        this._isValid = false;
        this._errorMsg = 'Area of negative buffer is larger than input';
        this._errorIndicator = this._result;
      }
      this.report('Area');
    };
    BufferResultValidator.prototype.checkPolygonal = function checkPolygonal () {
      if (!(this._result instanceof Polygon || this._result instanceof MultiPolygon)) { this._isValid = false; }
      this._errorMsg = 'Result is not polygonal';
      this._errorIndicator = this._result;
      this.report('Polygonal');
    };
    BufferResultValidator.prototype.getErrorIndicator = function getErrorIndicator () {
      return this._errorIndicator
    };
    BufferResultValidator.prototype.getErrorLocation = function getErrorLocation () {
      return this._errorLocation
    };
    BufferResultValidator.prototype.checkExpectedEmpty = function checkExpectedEmpty () {
      if (this._input.getDimension() >= 2) { return null }
      if (this._distance > 0.0) { return null }
      if (!this._result.isEmpty()) {
        this._isValid = false;
        this._errorMsg = 'Result is non-empty';
        this._errorIndicator = this._result;
      }
      this.report('ExpectedEmpty');
    };
    BufferResultValidator.prototype.report = function report (checkName) {
      if (!BufferResultValidator.VERBOSE) { return null }
      System.out.println('Check ' + checkName + ': ' + (this._isValid ? 'passed' : 'FAILED'));
    };
    BufferResultValidator.prototype.getErrorMessage = function getErrorMessage () {
      return this._errorMsg
    };
    BufferResultValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    BufferResultValidator.prototype.getClass = function getClass () {
      return BufferResultValidator
    };
    BufferResultValidator.isValidMsg = function isValidMsg (g, distance, result) {
      var validator = new BufferResultValidator(g, distance, result);
      if (!validator.isValid()) { return validator.getErrorMessage() }
      return null
    };
    BufferResultValidator.isValid = function isValid (g, distance, result) {
      var validator = new BufferResultValidator(g, distance, result);
      if (validator.isValid()) { return true }
      return false
    };
    staticAccessors$40.VERBOSE.get = function () { return false };
    staticAccessors$40.MAX_ENV_DIFF_FRAC.get = function () { return 0.012 };

    Object.defineProperties( BufferResultValidator, staticAccessors$40 );

    // operation.buffer

    var BasicSegmentString = function BasicSegmentString () {
      this._pts = null;
      this._data = null;
      var pts = arguments[0];
      var data = arguments[1];
      this._pts = pts;
      this._data = data;
    };
    BasicSegmentString.prototype.getCoordinates = function getCoordinates () {
      return this._pts
    };
    BasicSegmentString.prototype.size = function size () {
      return this._pts.length
    };
    BasicSegmentString.prototype.getCoordinate = function getCoordinate (i) {
      return this._pts[i]
    };
    BasicSegmentString.prototype.isClosed = function isClosed () {
      return this._pts[0].equals(this._pts[this._pts.length - 1])
    };
    BasicSegmentString.prototype.getSegmentOctant = function getSegmentOctant (index) {
      if (index === this._pts.length - 1) { return -1 }
      return Octant.octant(this.getCoordinate(index), this.getCoordinate(index + 1))
    };
    BasicSegmentString.prototype.setData = function setData (data) {
      this._data = data;
    };
    BasicSegmentString.prototype.getData = function getData () {
      return this._data
    };
    BasicSegmentString.prototype.toString = function toString () {
      return WKTWriter.toLineString(new CoordinateArraySequence(this._pts))
    };
    BasicSegmentString.prototype.interfaces_ = function interfaces_ () {
      return [SegmentString]
    };
    BasicSegmentString.prototype.getClass = function getClass () {
      return BasicSegmentString
    };

    var InteriorIntersectionFinder = function InteriorIntersectionFinder () {
      this._findAllIntersections = false;
      this._isCheckEndSegmentsOnly = false;
      this._li = null;
      this._interiorIntersection = null;
      this._intSegments = null;
      this._intersections = new ArrayList();
      this._intersectionCount = 0;
      this._keepIntersections = true;
      var li = arguments[0];
      this._li = li;
      this._interiorIntersection = null;
    };
    InteriorIntersectionFinder.prototype.getInteriorIntersection = function getInteriorIntersection () {
      return this._interiorIntersection
    };
    InteriorIntersectionFinder.prototype.setCheckEndSegmentsOnly = function setCheckEndSegmentsOnly (isCheckEndSegmentsOnly) {
      this._isCheckEndSegmentsOnly = isCheckEndSegmentsOnly;
    };
    InteriorIntersectionFinder.prototype.getIntersectionSegments = function getIntersectionSegments () {
      return this._intSegments
    };
    InteriorIntersectionFinder.prototype.count = function count () {
      return this._intersectionCount
    };
    InteriorIntersectionFinder.prototype.getIntersections = function getIntersections () {
      return this._intersections
    };
    InteriorIntersectionFinder.prototype.setFindAllIntersections = function setFindAllIntersections (findAllIntersections) {
      this._findAllIntersections = findAllIntersections;
    };
    InteriorIntersectionFinder.prototype.setKeepIntersections = function setKeepIntersections (keepIntersections) {
      this._keepIntersections = keepIntersections;
    };
    InteriorIntersectionFinder.prototype.processIntersections = function processIntersections (e0, segIndex0, e1, segIndex1) {
      if (!this._findAllIntersections && this.hasIntersection()) { return null }
      if (e0 === e1 && segIndex0 === segIndex1) { return null }
      if (this._isCheckEndSegmentsOnly) {
        var isEndSegPresent = this.isEndSegment(e0, segIndex0) || this.isEndSegment(e1, segIndex1);
        if (!isEndSegPresent) { return null }
      }
      var p00 = e0.getCoordinates()[segIndex0];
      var p01 = e0.getCoordinates()[segIndex0 + 1];
      var p10 = e1.getCoordinates()[segIndex1];
      var p11 = e1.getCoordinates()[segIndex1 + 1];
      this._li.computeIntersection(p00, p01, p10, p11);
      if (this._li.hasIntersection()) {
        if (this._li.isInteriorIntersection()) {
          this._intSegments = new Array(4).fill(null);
          this._intSegments[0] = p00;
          this._intSegments[1] = p01;
          this._intSegments[2] = p10;
          this._intSegments[3] = p11;
          this._interiorIntersection = this._li.getIntersection(0);
          if (this._keepIntersections) { this._intersections.add(this._interiorIntersection); }
          this._intersectionCount++;
        }
      }
    };
    InteriorIntersectionFinder.prototype.isEndSegment = function isEndSegment (segStr, index) {
      if (index === 0) { return true }
      if (index >= segStr.size() - 2) { return true }
      return false
    };
    InteriorIntersectionFinder.prototype.hasIntersection = function hasIntersection () {
      return this._interiorIntersection !== null
    };
    InteriorIntersectionFinder.prototype.isDone = function isDone () {
      if (this._findAllIntersections) { return false }
      return this._interiorIntersection !== null
    };
    InteriorIntersectionFinder.prototype.interfaces_ = function interfaces_ () {
      return [SegmentIntersector]
    };
    InteriorIntersectionFinder.prototype.getClass = function getClass () {
      return InteriorIntersectionFinder
    };
    InteriorIntersectionFinder.createAllIntersectionsFinder = function createAllIntersectionsFinder (li) {
      var finder = new InteriorIntersectionFinder(li);
      finder.setFindAllIntersections(true);
      return finder
    };
    InteriorIntersectionFinder.createAnyIntersectionFinder = function createAnyIntersectionFinder (li) {
      return new InteriorIntersectionFinder(li)
    };
    InteriorIntersectionFinder.createIntersectionCounter = function createIntersectionCounter (li) {
      var finder = new InteriorIntersectionFinder(li);
      finder.setFindAllIntersections(true);
      finder.setKeepIntersections(false);
      return finder
    };

    var FastNodingValidator = function FastNodingValidator () {
      this._li = new RobustLineIntersector();
      this._segStrings = null;
      this._findAllIntersections = false;
      this._segInt = null;
      this._isValid = true;
      var segStrings = arguments[0];
      this._segStrings = segStrings;
    };
    FastNodingValidator.prototype.execute = function execute () {
      if (this._segInt !== null) { return null }
      this.checkInteriorIntersections();
    };
    FastNodingValidator.prototype.getIntersections = function getIntersections () {
      return this._segInt.getIntersections()
    };
    FastNodingValidator.prototype.isValid = function isValid () {
      this.execute();
      return this._isValid
    };
    FastNodingValidator.prototype.setFindAllIntersections = function setFindAllIntersections (findAllIntersections) {
      this._findAllIntersections = findAllIntersections;
    };
    FastNodingValidator.prototype.checkInteriorIntersections = function checkInteriorIntersections () {
      this._isValid = true;
      this._segInt = new InteriorIntersectionFinder(this._li);
      this._segInt.setFindAllIntersections(this._findAllIntersections);
      var noder = new MCIndexNoder();
      noder.setSegmentIntersector(this._segInt);
      noder.computeNodes(this._segStrings);
      if (this._segInt.hasIntersection()) {
        this._isValid = false;
        return null
      }
    };
    FastNodingValidator.prototype.checkValid = function checkValid () {
      this.execute();
      if (!this._isValid) { throw new TopologyException(this.getErrorMessage(), this._segInt.getInteriorIntersection()) }
    };
    FastNodingValidator.prototype.getErrorMessage = function getErrorMessage () {
      if (this._isValid) { return 'no intersections found' }
      var intSegs = this._segInt.getIntersectionSegments();
      return 'found non-noded intersection between ' + WKTWriter.toLineString(intSegs[0], intSegs[1]) + ' and ' + WKTWriter.toLineString(intSegs[2], intSegs[3])
    };
    FastNodingValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    FastNodingValidator.prototype.getClass = function getClass () {
      return FastNodingValidator
    };
    FastNodingValidator.computeIntersections = function computeIntersections (segStrings) {
      var nv = new FastNodingValidator(segStrings);
      nv.setFindAllIntersections(true);
      nv.isValid();
      return nv.getIntersections()
    };

    var EdgeNodingValidator = function EdgeNodingValidator () {
      this._nv = null;
      var edges = arguments[0];
      this._nv = new FastNodingValidator(EdgeNodingValidator.toSegmentStrings(edges));
    };
    EdgeNodingValidator.prototype.checkValid = function checkValid () {
      this._nv.checkValid();
    };
    EdgeNodingValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeNodingValidator.prototype.getClass = function getClass () {
      return EdgeNodingValidator
    };
    EdgeNodingValidator.toSegmentStrings = function toSegmentStrings (edges) {
      var segStrings = new ArrayList();
      for (var i = edges.iterator(); i.hasNext();) {
        var e = i.next();
        segStrings.add(new BasicSegmentString(e.getCoordinates(), e));
      }
      return segStrings
    };
    EdgeNodingValidator.checkValid = function checkValid (edges) {
      var validator = new EdgeNodingValidator(edges);
      validator.checkValid();
    };

    var GeometryCollectionMapper = function GeometryCollectionMapper (mapOp) {
      this._mapOp = mapOp;
    };
    GeometryCollectionMapper.prototype.map = function map (gc) {
        var this$1 = this;

      var mapped = new ArrayList();
      for (var i = 0; i < gc.getNumGeometries(); i++) {
        var g = this$1._mapOp.map(gc.getGeometryN(i));
        if (!g.isEmpty()) { mapped.add(g); }
      }
      return gc.getFactory().createGeometryCollection(GeometryFactory.toGeometryArray(mapped))
    };
    GeometryCollectionMapper.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryCollectionMapper.prototype.getClass = function getClass () {
      return GeometryCollectionMapper
    };
    GeometryCollectionMapper.map = function map (gc, op) {
      var mapper = new GeometryCollectionMapper(op);
      return mapper.map(gc)
    };

    var LineBuilder = function LineBuilder () {
      this._op = null;
      this._geometryFactory = null;
      this._ptLocator = null;
      this._lineEdgesList = new ArrayList();
      this._resultLineList = new ArrayList();
      var op = arguments[0];
      var geometryFactory = arguments[1];
      var ptLocator = arguments[2];
      this._op = op;
      this._geometryFactory = geometryFactory;
      this._ptLocator = ptLocator;
    };
    LineBuilder.prototype.collectLines = function collectLines (opCode) {
        var this$1 = this;

      for (var it = this._op.getGraph().getEdgeEnds().iterator(); it.hasNext();) {
        var de = it.next();
        this$1.collectLineEdge(de, opCode, this$1._lineEdgesList);
        this$1.collectBoundaryTouchEdge(de, opCode, this$1._lineEdgesList);
      }
    };
    LineBuilder.prototype.labelIsolatedLine = function labelIsolatedLine (e, targetIndex) {
      var loc = this._ptLocator.locate(e.getCoordinate(), this._op.getArgGeometry(targetIndex));
      e.getLabel().setLocation(targetIndex, loc);
    };
    LineBuilder.prototype.build = function build (opCode) {
      this.findCoveredLineEdges();
      this.collectLines(opCode);
      this.buildLines(opCode);
      return this._resultLineList
    };
    LineBuilder.prototype.collectLineEdge = function collectLineEdge (de, opCode, edges) {
      var label = de.getLabel();
      var e = de.getEdge();
      if (de.isLineEdge()) {
        if (!de.isVisited() && OverlayOp.isResultOfOp(label, opCode) && !e.isCovered()) {
          edges.add(e);
          de.setVisitedEdge(true);
        }
      }
    };
    LineBuilder.prototype.findCoveredLineEdges = function findCoveredLineEdges () {
        var this$1 = this;

      for (var nodeit = this._op.getGraph().getNodes().iterator(); nodeit.hasNext();) {
        var node = nodeit.next();
        node.getEdges().findCoveredLineEdges();
      }
      for (var it = this._op.getGraph().getEdgeEnds().iterator(); it.hasNext();) {
        var de = it.next();
        var e = de.getEdge();
        if (de.isLineEdge() && !e.isCoveredSet()) {
          var isCovered = this$1._op.isCoveredByA(de.getCoordinate());
          e.setCovered(isCovered);
        }
      }
    };
    LineBuilder.prototype.labelIsolatedLines = function labelIsolatedLines (edgesList) {
        var this$1 = this;

      for (var it = edgesList.iterator(); it.hasNext();) {
        var e = it.next();
        var label = e.getLabel();
        if (e.isIsolated()) {
          if (label.isNull(0)) { this$1.labelIsolatedLine(e, 0); } else { this$1.labelIsolatedLine(e, 1); }
        }
      }
    };
    LineBuilder.prototype.buildLines = function buildLines (opCode) {
        var this$1 = this;

      for (var it = this._lineEdgesList.iterator(); it.hasNext();) {
        var e = it.next();
        // const label = e.getLabel()
        var line = this$1._geometryFactory.createLineString(e.getCoordinates());
        this$1._resultLineList.add(line);
        e.setInResult(true);
      }
    };
    LineBuilder.prototype.collectBoundaryTouchEdge = function collectBoundaryTouchEdge (de, opCode, edges) {
      var label = de.getLabel();
      if (de.isLineEdge()) { return null }
      if (de.isVisited()) { return null }
      if (de.isInteriorAreaEdge()) { return null }
      if (de.getEdge().isInResult()) { return null }
      Assert.isTrue(!(de.isInResult() || de.getSym().isInResult()) || !de.getEdge().isInResult());
      if (OverlayOp.isResultOfOp(label, opCode) && opCode === OverlayOp.INTERSECTION) {
        edges.add(de.getEdge());
        de.setVisitedEdge(true);
      }
    };
    LineBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    LineBuilder.prototype.getClass = function getClass () {
      return LineBuilder
    };

    var PointBuilder = function PointBuilder () {
      this._op = null;
      this._geometryFactory = null;
      this._resultPointList = new ArrayList();
      var op = arguments[0];
      var geometryFactory = arguments[1];
      // const ptLocator = arguments[2]
      this._op = op;
      this._geometryFactory = geometryFactory;
    };
    PointBuilder.prototype.filterCoveredNodeToPoint = function filterCoveredNodeToPoint (n) {
      var coord = n.getCoordinate();
      if (!this._op.isCoveredByLA(coord)) {
        var pt = this._geometryFactory.createPoint(coord);
        this._resultPointList.add(pt);
      }
    };
    PointBuilder.prototype.extractNonCoveredResultNodes = function extractNonCoveredResultNodes (opCode) {
        var this$1 = this;

      for (var nodeit = this._op.getGraph().getNodes().iterator(); nodeit.hasNext();) {
        var n = nodeit.next();
        if (n.isInResult()) { continue }
        if (n.isIncidentEdgeInResult()) { continue }
        if (n.getEdges().getDegree() === 0 || opCode === OverlayOp.INTERSECTION) {
          var label = n.getLabel();
          if (OverlayOp.isResultOfOp(label, opCode)) {
            this$1.filterCoveredNodeToPoint(n);
          }
        }
      }
    };
    PointBuilder.prototype.build = function build (opCode) {
      this.extractNonCoveredResultNodes(opCode);
      return this._resultPointList
    };
    PointBuilder.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    PointBuilder.prototype.getClass = function getClass () {
      return PointBuilder
    };

    var GeometryTransformer = function GeometryTransformer () {
      this._inputGeom = null;
      this._factory = null;
      this._pruneEmptyGeometry = true;
      this._preserveGeometryCollectionType = true;
      this._preserveCollections = false;
      this._preserveType = false;
    };
    GeometryTransformer.prototype.transformPoint = function transformPoint (geom, parent) {
      return this._factory.createPoint(this.transformCoordinates(geom.getCoordinateSequence(), geom))
    };
    GeometryTransformer.prototype.transformPolygon = function transformPolygon (geom, parent) {
        var this$1 = this;

      var isAllValidLinearRings = true;
      var shell = this.transformLinearRing(geom.getExteriorRing(), geom);
      if (shell === null || !(shell instanceof LinearRing) || shell.isEmpty()) { isAllValidLinearRings = false; }
      var holes = new ArrayList();
      for (var i = 0; i < geom.getNumInteriorRing(); i++) {
        var hole = this$1.transformLinearRing(geom.getInteriorRingN(i), geom);
        if (hole === null || hole.isEmpty()) {
          continue
        }
        if (!(hole instanceof LinearRing)) { isAllValidLinearRings = false; }
        holes.add(hole);
      }
      if (isAllValidLinearRings) { return this._factory.createPolygon(shell, holes.toArray([])); } else {
        var components = new ArrayList();
        if (shell !== null) { components.add(shell); }
        components.addAll(holes);
        return this._factory.buildGeometry(components)
      }
    };
    GeometryTransformer.prototype.createCoordinateSequence = function createCoordinateSequence (coords) {
      return this._factory.getCoordinateSequenceFactory().create(coords)
    };
    GeometryTransformer.prototype.getInputGeometry = function getInputGeometry () {
      return this._inputGeom
    };
    GeometryTransformer.prototype.transformMultiLineString = function transformMultiLineString (geom, parent) {
        var this$1 = this;

      var transGeomList = new ArrayList();
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var transformGeom = this$1.transformLineString(geom.getGeometryN(i), geom);
        if (transformGeom === null) { continue }
        if (transformGeom.isEmpty()) { continue }
        transGeomList.add(transformGeom);
      }
      return this._factory.buildGeometry(transGeomList)
    };
    GeometryTransformer.prototype.transformCoordinates = function transformCoordinates (coords, parent) {
      return this.copy(coords)
    };
    GeometryTransformer.prototype.transformLineString = function transformLineString (geom, parent) {
      return this._factory.createLineString(this.transformCoordinates(geom.getCoordinateSequence(), geom))
    };
    GeometryTransformer.prototype.transformMultiPoint = function transformMultiPoint (geom, parent) {
        var this$1 = this;

      var transGeomList = new ArrayList();
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var transformGeom = this$1.transformPoint(geom.getGeometryN(i), geom);
        if (transformGeom === null) { continue }
        if (transformGeom.isEmpty()) { continue }
        transGeomList.add(transformGeom);
      }
      return this._factory.buildGeometry(transGeomList)
    };
    GeometryTransformer.prototype.transformMultiPolygon = function transformMultiPolygon (geom, parent) {
        var this$1 = this;

      var transGeomList = new ArrayList();
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var transformGeom = this$1.transformPolygon(geom.getGeometryN(i), geom);
        if (transformGeom === null) { continue }
        if (transformGeom.isEmpty()) { continue }
        transGeomList.add(transformGeom);
      }
      return this._factory.buildGeometry(transGeomList)
    };
    GeometryTransformer.prototype.copy = function copy (seq) {
      return seq.copy()
    };
    GeometryTransformer.prototype.transformGeometryCollection = function transformGeometryCollection (geom, parent) {
        var this$1 = this;

      var transGeomList = new ArrayList();
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var transformGeom = this$1.transform(geom.getGeometryN(i));
        if (transformGeom === null) { continue }
        if (this$1._pruneEmptyGeometry && transformGeom.isEmpty()) { continue }
        transGeomList.add(transformGeom);
      }
      if (this._preserveGeometryCollectionType) { return this._factory.createGeometryCollection(GeometryFactory.toGeometryArray(transGeomList)) }
      return this._factory.buildGeometry(transGeomList)
    };
    GeometryTransformer.prototype.transform = function transform (inputGeom) {
      this._inputGeom = inputGeom;
      this._factory = inputGeom.getFactory();
      if (inputGeom instanceof Point) { return this.transformPoint(inputGeom, null) }
      if (inputGeom instanceof MultiPoint) { return this.transformMultiPoint(inputGeom, null) }
      if (inputGeom instanceof LinearRing) { return this.transformLinearRing(inputGeom, null) }
      if (inputGeom instanceof LineString$1) { return this.transformLineString(inputGeom, null) }
      if (inputGeom instanceof MultiLineString) { return this.transformMultiLineString(inputGeom, null) }
      if (inputGeom instanceof Polygon) { return this.transformPolygon(inputGeom, null) }
      if (inputGeom instanceof MultiPolygon) { return this.transformMultiPolygon(inputGeom, null) }
      if (inputGeom instanceof GeometryCollection) { return this.transformGeometryCollection(inputGeom, null) }
      throw new IllegalArgumentException('Unknown Geometry subtype: ' + inputGeom.getClass().getName())
    };
    GeometryTransformer.prototype.transformLinearRing = function transformLinearRing (geom, parent) {
      var seq = this.transformCoordinates(geom.getCoordinateSequence(), geom);
      if (seq === null) { return this._factory.createLinearRing(null) }
      var seqSize = seq.size();
      if (seqSize > 0 && seqSize < 4 && !this._preserveType) { return this._factory.createLineString(seq) }
      return this._factory.createLinearRing(seq)
    };
    GeometryTransformer.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryTransformer.prototype.getClass = function getClass () {
      return GeometryTransformer
    };

    var LineStringSnapper = function LineStringSnapper () {
      this._snapTolerance = 0.0;
      this._srcPts = null;
      this._seg = new LineSegment();
      this._allowSnappingToSourceVertices = false;
      this._isClosed = false;
      if (arguments[0] instanceof LineString$1 && typeof arguments[1] === 'number') {
        var srcLine = arguments[0];
        var snapTolerance = arguments[1];
        LineStringSnapper.call(this, srcLine.getCoordinates(), snapTolerance);
      } else if (arguments[0] instanceof Array && typeof arguments[1] === 'number') {
        var srcPts = arguments[0];
        var snapTolerance$1 = arguments[1];
        this._srcPts = srcPts;
        this._isClosed = LineStringSnapper.isClosed(srcPts);
        this._snapTolerance = snapTolerance$1;
      }
    };
    LineStringSnapper.prototype.snapVertices = function snapVertices (srcCoords, snapPts) {
        var this$1 = this;

      var end = this._isClosed ? srcCoords.size() - 1 : srcCoords.size();
      for (var i = 0; i < end; i++) {
        var srcPt = srcCoords.get(i);
        var snapVert = this$1.findSnapForVertex(srcPt, snapPts);
        if (snapVert !== null) {
          srcCoords.set(i, new Coordinate(snapVert));
          if (i === 0 && this$1._isClosed) { srcCoords.set(srcCoords.size() - 1, new Coordinate(snapVert)); }
        }
      }
    };
    LineStringSnapper.prototype.findSnapForVertex = function findSnapForVertex (pt, snapPts) {
        var this$1 = this;

      for (var i = 0; i < snapPts.length; i++) {
        if (pt.equals2D(snapPts[i])) { return null }
        if (pt.distance(snapPts[i]) < this$1._snapTolerance) { return snapPts[i] }
      }
      return null
    };
    LineStringSnapper.prototype.snapTo = function snapTo (snapPts) {
      var coordList = new CoordinateList(this._srcPts);
      this.snapVertices(coordList, snapPts);
      this.snapSegments(coordList, snapPts);
      var newPts = coordList.toCoordinateArray();
      return newPts
    };
    LineStringSnapper.prototype.snapSegments = function snapSegments (srcCoords, snapPts) {
        var this$1 = this;

      if (snapPts.length === 0) { return null }
      var distinctPtCount = snapPts.length;
      if (snapPts[0].equals2D(snapPts[snapPts.length - 1])) { distinctPtCount = snapPts.length - 1; }
      for (var i = 0; i < distinctPtCount; i++) {
        var snapPt = snapPts[i];
        var index = this$1.findSegmentIndexToSnap(snapPt, srcCoords);
        if (index >= 0) {
          srcCoords.add(index + 1, new Coordinate(snapPt), false);
        }
      }
    };
    LineStringSnapper.prototype.findSegmentIndexToSnap = function findSegmentIndexToSnap (snapPt, srcCoords) {
        var this$1 = this;

      var minDist = Double.MAX_VALUE;
      var snapIndex = -1;
      for (var i = 0; i < srcCoords.size() - 1; i++) {
        this$1._seg.p0 = srcCoords.get(i);
        this$1._seg.p1 = srcCoords.get(i + 1);
        if (this$1._seg.p0.equals2D(snapPt) || this$1._seg.p1.equals2D(snapPt)) {
          if (this$1._allowSnappingToSourceVertices) { continue; } else { return -1 }
        }
        var dist = this$1._seg.distance(snapPt);
        if (dist < this$1._snapTolerance && dist < minDist) {
          minDist = dist;
          snapIndex = i;
        }
      }
      return snapIndex
    };
    LineStringSnapper.prototype.setAllowSnappingToSourceVertices = function setAllowSnappingToSourceVertices (allowSnappingToSourceVertices) {
      this._allowSnappingToSourceVertices = allowSnappingToSourceVertices;
    };
    LineStringSnapper.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    LineStringSnapper.prototype.getClass = function getClass () {
      return LineStringSnapper
    };
    LineStringSnapper.isClosed = function isClosed (pts) {
      if (pts.length <= 1) { return false }
      return pts[0].equals2D(pts[pts.length - 1])
    };

    var GeometrySnapper = function GeometrySnapper (srcGeom) {
      this._srcGeom = srcGeom || null;
    };

    var staticAccessors$41 = { SNAP_PRECISION_FACTOR: { configurable: true } };
    GeometrySnapper.prototype.snapTo = function snapTo (snapGeom, snapTolerance) {
      var snapPts = this.extractTargetCoordinates(snapGeom);
      var snapTrans = new SnapTransformer(snapTolerance, snapPts);
      return snapTrans.transform(this._srcGeom)
    };
    GeometrySnapper.prototype.snapToSelf = function snapToSelf (snapTolerance, cleanResult) {
      var snapPts = this.extractTargetCoordinates(this._srcGeom);
      var snapTrans = new SnapTransformer(snapTolerance, snapPts, true);
      var snappedGeom = snapTrans.transform(this._srcGeom);
      var result = snappedGeom;
      if (cleanResult && hasInterface(result, Polygonal)) {
        result = snappedGeom.buffer(0);
      }
      return result
    };
    GeometrySnapper.prototype.computeSnapTolerance = function computeSnapTolerance (ringPts) {
      var minSegLen = this.computeMinimumSegmentLength(ringPts);
      var snapTol = minSegLen / 10;
      return snapTol
    };
    GeometrySnapper.prototype.extractTargetCoordinates = function extractTargetCoordinates (g) {
      var ptSet = new TreeSet();
      var pts = g.getCoordinates();
      for (var i = 0; i < pts.length; i++) {
        ptSet.add(pts[i]);
      }
      return ptSet.toArray(new Array(0).fill(null))
    };
    GeometrySnapper.prototype.computeMinimumSegmentLength = function computeMinimumSegmentLength (pts) {
      var minSegLen = Double.MAX_VALUE;
      for (var i = 0; i < pts.length - 1; i++) {
        var segLen = pts[i].distance(pts[i + 1]);
        if (segLen < minSegLen) { minSegLen = segLen; }
      }
      return minSegLen
    };
    GeometrySnapper.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometrySnapper.prototype.getClass = function getClass () {
      return GeometrySnapper
    };
    GeometrySnapper.snap = function snap (g0, g1, snapTolerance) {
      var snapGeom = new Array(2).fill(null);
      var snapper0 = new GeometrySnapper(g0);
      snapGeom[0] = snapper0.snapTo(g1, snapTolerance);
      var snapper1 = new GeometrySnapper(g1);
      snapGeom[1] = snapper1.snapTo(snapGeom[0], snapTolerance);
      return snapGeom
    };
    GeometrySnapper.computeOverlaySnapTolerance = function computeOverlaySnapTolerance () {
      if (arguments.length === 1) {
        var g = arguments[0];
        var snapTolerance = GeometrySnapper.computeSizeBasedSnapTolerance(g);
        var pm = g.getPrecisionModel();
        if (pm.getType() === PrecisionModel.FIXED) {
          var fixedSnapTol = 1 / pm.getScale() * 2 / 1.415;
          if (fixedSnapTol > snapTolerance) { snapTolerance = fixedSnapTol; }
        }
        return snapTolerance
      } else if (arguments.length === 2) {
        var g0 = arguments[0];
        var g1 = arguments[1];
        return Math.min(GeometrySnapper.computeOverlaySnapTolerance(g0), GeometrySnapper.computeOverlaySnapTolerance(g1))
      }
    };
    GeometrySnapper.computeSizeBasedSnapTolerance = function computeSizeBasedSnapTolerance (g) {
      var env = g.getEnvelopeInternal();
      var minDimension = Math.min(env.getHeight(), env.getWidth());
      var snapTol = minDimension * GeometrySnapper.SNAP_PRECISION_FACTOR;
      return snapTol
    };
    GeometrySnapper.snapToSelf = function snapToSelf (geom, snapTolerance, cleanResult) {
      var snapper0 = new GeometrySnapper(geom);
      return snapper0.snapToSelf(snapTolerance, cleanResult)
    };
    staticAccessors$41.SNAP_PRECISION_FACTOR.get = function () { return 1e-9 };

    Object.defineProperties( GeometrySnapper, staticAccessors$41 );

    var SnapTransformer = (function (GeometryTransformer$$1) {
      function SnapTransformer (snapTolerance, snapPts, isSelfSnap) {
        GeometryTransformer$$1.call(this);
        this._snapTolerance = snapTolerance || null;
        this._snapPts = snapPts || null;
        this._isSelfSnap = (isSelfSnap !== undefined) ? isSelfSnap : false;
      }

      if ( GeometryTransformer$$1 ) SnapTransformer.__proto__ = GeometryTransformer$$1;
      SnapTransformer.prototype = Object.create( GeometryTransformer$$1 && GeometryTransformer$$1.prototype );
      SnapTransformer.prototype.constructor = SnapTransformer;
      SnapTransformer.prototype.snapLine = function snapLine (srcPts, snapPts) {
        var snapper = new LineStringSnapper(srcPts, this._snapTolerance);
        snapper.setAllowSnappingToSourceVertices(this._isSelfSnap);
        return snapper.snapTo(snapPts)
      };
      SnapTransformer.prototype.transformCoordinates = function transformCoordinates (coords, parent) {
        var srcPts = coords.toCoordinateArray();
        var newPts = this.snapLine(srcPts, this._snapPts);
        return this._factory.getCoordinateSequenceFactory().create(newPts)
      };
      SnapTransformer.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      SnapTransformer.prototype.getClass = function getClass () {
        return SnapTransformer
      };

      return SnapTransformer;
    }(GeometryTransformer));

    var CommonBits = function CommonBits () {
      this._isFirst = true;
      this._commonMantissaBitsCount = 53;
      this._commonBits = 0;
      this._commonSignExp = null;
    };
    CommonBits.prototype.getCommon = function getCommon () {
      return Double.longBitsToDouble(this._commonBits)
    };
    CommonBits.prototype.add = function add (num) {
      var numBits = Double.doubleToLongBits(num);
      if (this._isFirst) {
        this._commonBits = numBits;
        this._commonSignExp = CommonBits.signExpBits(this._commonBits);
        this._isFirst = false;
        return null
      }
      var numSignExp = CommonBits.signExpBits(numBits);
      if (numSignExp !== this._commonSignExp) {
        this._commonBits = 0;
        return null
      }
      this._commonMantissaBitsCount = CommonBits.numCommonMostSigMantissaBits(this._commonBits, numBits);
      this._commonBits = CommonBits.zeroLowerBits(this._commonBits, 64 - (12 + this._commonMantissaBitsCount));
    };
    CommonBits.prototype.toString = function toString () {
      if (arguments.length === 1) {
        var bits = arguments[0];
        var x = Double.longBitsToDouble(bits);
        var numStr = Double.toBinaryString(bits);
        var padStr = '0000000000000000000000000000000000000000000000000000000000000000' + numStr;
        var bitStr = padStr.substring(padStr.length - 64);
        var str = bitStr.substring(0, 1) + '  ' + bitStr.substring(1, 12) + '(exp) ' + bitStr.substring(12) + ' [ ' + x + ' ]';
        return str
      }
    };
    CommonBits.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CommonBits.prototype.getClass = function getClass () {
      return CommonBits
    };
    CommonBits.getBit = function getBit (bits, i) {
      var mask = 1 << i;
      return (bits & mask) !== 0 ? 1 : 0
    };
    CommonBits.signExpBits = function signExpBits (num) {
      return num >> 52
    };
    CommonBits.zeroLowerBits = function zeroLowerBits (bits, nBits) {
      var invMask = (1 << nBits) - 1;
      var mask = ~invMask;
      var zeroed = bits & mask;
      return zeroed
    };
    CommonBits.numCommonMostSigMantissaBits = function numCommonMostSigMantissaBits (num1, num2) {
      var count = 0;
      for (var i = 52; i >= 0; i--) {
        if (CommonBits.getBit(num1, i) !== CommonBits.getBit(num2, i)) { return count }
        count++;
      }
      return 52
    };

    var CommonBitsRemover = function CommonBitsRemover () {
      this._commonCoord = null;
      this._ccFilter = new CommonCoordinateFilter();
    };

    var staticAccessors$42 = { CommonCoordinateFilter: { configurable: true },Translater: { configurable: true } };
    CommonBitsRemover.prototype.addCommonBits = function addCommonBits (geom) {
      var trans = new Translater(this._commonCoord);
      geom.apply(trans);
      geom.geometryChanged();
    };
    CommonBitsRemover.prototype.removeCommonBits = function removeCommonBits (geom) {
      if (this._commonCoord.x === 0.0 && this._commonCoord.y === 0.0) { return geom }
      var invCoord = new Coordinate(this._commonCoord);
      invCoord.x = -invCoord.x;
      invCoord.y = -invCoord.y;
      var trans = new Translater(invCoord);
      geom.apply(trans);
      geom.geometryChanged();
      return geom
    };
    CommonBitsRemover.prototype.getCommonCoordinate = function getCommonCoordinate () {
      return this._commonCoord
    };
    CommonBitsRemover.prototype.add = function add (geom) {
      geom.apply(this._ccFilter);
      this._commonCoord = this._ccFilter.getCommonCoordinate();
    };
    CommonBitsRemover.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CommonBitsRemover.prototype.getClass = function getClass () {
      return CommonBitsRemover
    };
    staticAccessors$42.CommonCoordinateFilter.get = function () { return CommonCoordinateFilter };
    staticAccessors$42.Translater.get = function () { return Translater };

    Object.defineProperties( CommonBitsRemover, staticAccessors$42 );

    var CommonCoordinateFilter = function CommonCoordinateFilter () {
      this._commonBitsX = new CommonBits();
      this._commonBitsY = new CommonBits();
    };
    CommonCoordinateFilter.prototype.filter = function filter (coord) {
      this._commonBitsX.add(coord.x);
      this._commonBitsY.add(coord.y);
    };
    CommonCoordinateFilter.prototype.getCommonCoordinate = function getCommonCoordinate () {
      return new Coordinate(this._commonBitsX.getCommon(), this._commonBitsY.getCommon())
    };
    CommonCoordinateFilter.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateFilter]
    };
    CommonCoordinateFilter.prototype.getClass = function getClass () {
      return CommonCoordinateFilter
    };

    var Translater = function Translater () {
      this.trans = null;
      var trans = arguments[0];
      this.trans = trans;
    };
    Translater.prototype.filter = function filter (seq, i) {
      var xp = seq.getOrdinate(i, 0) + this.trans.x;
      var yp = seq.getOrdinate(i, 1) + this.trans.y;
      seq.setOrdinate(i, 0, xp);
      seq.setOrdinate(i, 1, yp);
    };
    Translater.prototype.isDone = function isDone () {
      return false
    };
    Translater.prototype.isGeometryChanged = function isGeometryChanged () {
      return true
    };
    Translater.prototype.interfaces_ = function interfaces_ () {
      return [CoordinateSequenceFilter]
    };
    Translater.prototype.getClass = function getClass () {
      return Translater
    };

    var SnapOverlayOp = function SnapOverlayOp (g1, g2) {
      this._geom = new Array(2).fill(null);
      this._snapTolerance = null;
      this._cbr = null;
      this._geom[0] = g1;
      this._geom[1] = g2;
      this.computeSnapTolerance();
    };
    SnapOverlayOp.prototype.selfSnap = function selfSnap (geom) {
      var snapper0 = new GeometrySnapper(geom);
      var snapGeom = snapper0.snapTo(geom, this._snapTolerance);
      return snapGeom
    };
    SnapOverlayOp.prototype.removeCommonBits = function removeCommonBits (geom) {
      this._cbr = new CommonBitsRemover();
      this._cbr.add(geom[0]);
      this._cbr.add(geom[1]);
      var remGeom = new Array(2).fill(null);
      remGeom[0] = this._cbr.removeCommonBits(geom[0].copy());
      remGeom[1] = this._cbr.removeCommonBits(geom[1].copy());
      return remGeom
    };
    SnapOverlayOp.prototype.prepareResult = function prepareResult (geom) {
      this._cbr.addCommonBits(geom);
      return geom
    };
    SnapOverlayOp.prototype.getResultGeometry = function getResultGeometry (opCode) {
      var prepGeom = this.snap(this._geom);
      var result = OverlayOp.overlayOp(prepGeom[0], prepGeom[1], opCode);
      return this.prepareResult(result)
    };
    SnapOverlayOp.prototype.checkValid = function checkValid (g) {
      if (!g.isValid()) {
        System.out.println('Snapped geometry is invalid');
      }
    };
    SnapOverlayOp.prototype.computeSnapTolerance = function computeSnapTolerance () {
      this._snapTolerance = GeometrySnapper.computeOverlaySnapTolerance(this._geom[0], this._geom[1]);
    };
    SnapOverlayOp.prototype.snap = function snap (geom) {
      var remGeom = this.removeCommonBits(geom);
      var snapGeom = GeometrySnapper.snap(remGeom[0], remGeom[1], this._snapTolerance);
      return snapGeom
    };
    SnapOverlayOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SnapOverlayOp.prototype.getClass = function getClass () {
      return SnapOverlayOp
    };
    SnapOverlayOp.overlayOp = function overlayOp (g0, g1, opCode) {
      var op = new SnapOverlayOp(g0, g1);
      return op.getResultGeometry(opCode)
    };
    SnapOverlayOp.union = function union (g0, g1) {
      return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.UNION)
    };
    SnapOverlayOp.intersection = function intersection (g0, g1) {
      return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.INTERSECTION)
    };
    SnapOverlayOp.symDifference = function symDifference (g0, g1) {
      return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.SYMDIFFERENCE)
    };
    SnapOverlayOp.difference = function difference (g0, g1) {
      return SnapOverlayOp.overlayOp(g0, g1, OverlayOp.DIFFERENCE)
    };

    var SnapIfNeededOverlayOp = function SnapIfNeededOverlayOp (g1, g2) {
      this._geom = new Array(2).fill(null);
      this._geom[0] = g1;
      this._geom[1] = g2;
    };
    SnapIfNeededOverlayOp.prototype.getResultGeometry = function getResultGeometry (opCode) {
      var result = null;
      var isSuccess = false;
      var savedException = null;
      try {
        result = OverlayOp.overlayOp(this._geom[0], this._geom[1], opCode);
        { isSuccess = true; }
      } catch (ex) {
        if (ex instanceof RuntimeException) {
          savedException = ex;
        } else { throw ex }
      } finally {}
      if (!isSuccess) {
        try {
          result = SnapOverlayOp.overlayOp(this._geom[0], this._geom[1], opCode);
        } catch (ex) {
          if (ex instanceof RuntimeException) {
            throw savedException
          } else { throw ex }
        } finally {}
      }
      return result
    };
    SnapIfNeededOverlayOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SnapIfNeededOverlayOp.prototype.getClass = function getClass () {
      return SnapIfNeededOverlayOp
    };
    SnapIfNeededOverlayOp.overlayOp = function overlayOp (g0, g1, opCode) {
      var op = new SnapIfNeededOverlayOp(g0, g1);
      return op.getResultGeometry(opCode)
    };
    SnapIfNeededOverlayOp.union = function union (g0, g1) {
      return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.UNION)
    };
    SnapIfNeededOverlayOp.intersection = function intersection (g0, g1) {
      return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.INTERSECTION)
    };
    SnapIfNeededOverlayOp.symDifference = function symDifference (g0, g1) {
      return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.SYMDIFFERENCE)
    };
    SnapIfNeededOverlayOp.difference = function difference (g0, g1) {
      return SnapIfNeededOverlayOp.overlayOp(g0, g1, OverlayOp.DIFFERENCE)
    };

    var MonotoneChain$2 = function MonotoneChain () {
      this.mce = null;
      this.chainIndex = null;
      var mce = arguments[0];
      var chainIndex = arguments[1];
      this.mce = mce;
      this.chainIndex = chainIndex;
    };
    MonotoneChain$2.prototype.computeIntersections = function computeIntersections (mc, si) {
      this.mce.computeIntersectsForChain(this.chainIndex, mc.mce, mc.chainIndex, si);
    };
    MonotoneChain$2.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    MonotoneChain$2.prototype.getClass = function getClass () {
      return MonotoneChain$2
    };

    var SweepLineEvent = function SweepLineEvent () {
      this._label = null;
      this._xValue = null;
      this._eventType = null;
      this._insertEvent = null;
      this._deleteEventIndex = null;
      this._obj = null;
      if (arguments.length === 2) {
        var x = arguments[0];
        var insertEvent = arguments[1];
        this._eventType = SweepLineEvent.DELETE;
        this._xValue = x;
        this._insertEvent = insertEvent;
      } else if (arguments.length === 3) {
        var label = arguments[0];
        var x$1 = arguments[1];
        var obj = arguments[2];
        this._eventType = SweepLineEvent.INSERT;
        this._label = label;
        this._xValue = x$1;
        this._obj = obj;
      }
    };

    var staticAccessors$43 = { INSERT: { configurable: true },DELETE: { configurable: true } };
    SweepLineEvent.prototype.isDelete = function isDelete () {
      return this._eventType === SweepLineEvent.DELETE
    };
    SweepLineEvent.prototype.setDeleteEventIndex = function setDeleteEventIndex (deleteEventIndex) {
      this._deleteEventIndex = deleteEventIndex;
    };
    SweepLineEvent.prototype.getObject = function getObject () {
      return this._obj
    };
    SweepLineEvent.prototype.compareTo = function compareTo (o) {
      var pe = o;
      if (this._xValue < pe._xValue) { return -1 }
      if (this._xValue > pe._xValue) { return 1 }
      if (this._eventType < pe._eventType) { return -1 }
      if (this._eventType > pe._eventType) { return 1 }
      return 0
    };
    SweepLineEvent.prototype.getInsertEvent = function getInsertEvent () {
      return this._insertEvent
    };
    SweepLineEvent.prototype.isInsert = function isInsert () {
      return this._eventType === SweepLineEvent.INSERT
    };
    SweepLineEvent.prototype.isSameLabel = function isSameLabel (ev) {
      if (this._label === null) { return false }
      return this._label === ev._label
    };
    SweepLineEvent.prototype.getDeleteEventIndex = function getDeleteEventIndex () {
      return this._deleteEventIndex
    };
    SweepLineEvent.prototype.interfaces_ = function interfaces_ () {
      return [Comparable]
    };
    SweepLineEvent.prototype.getClass = function getClass () {
      return SweepLineEvent
    };
    staticAccessors$43.INSERT.get = function () { return 1 };
    staticAccessors$43.DELETE.get = function () { return 2 };

    Object.defineProperties( SweepLineEvent, staticAccessors$43 );

    var EdgeSetIntersector = function EdgeSetIntersector () {};

    EdgeSetIntersector.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    EdgeSetIntersector.prototype.getClass = function getClass () {
      return EdgeSetIntersector
    };

    var SegmentIntersector$2 = function SegmentIntersector () {
      this._hasIntersection = false;
      this._hasProper = false;
      this._hasProperInterior = false;
      this._properIntersectionPoint = null;
      this._li = null;
      this._includeProper = null;
      this._recordIsolated = null;
      this._isSelfIntersection = null;
      this._numIntersections = 0;
      this.numTests = 0;
      this._bdyNodes = null;
      this._isDone = false;
      this._isDoneWhenProperInt = false;
      var li = arguments[0];
      var includeProper = arguments[1];
      var recordIsolated = arguments[2];
      this._li = li;
      this._includeProper = includeProper;
      this._recordIsolated = recordIsolated;
    };
    SegmentIntersector$2.prototype.isTrivialIntersection = function isTrivialIntersection (e0, segIndex0, e1, segIndex1) {
      if (e0 === e1) {
        if (this._li.getIntersectionNum() === 1) {
          if (SegmentIntersector$2.isAdjacentSegments(segIndex0, segIndex1)) { return true }
          if (e0.isClosed()) {
            var maxSegIndex = e0.getNumPoints() - 1;
            if ((segIndex0 === 0 && segIndex1 === maxSegIndex) ||
                (segIndex1 === 0 && segIndex0 === maxSegIndex)) {
              return true
            }
          }
        }
      }
      return false
    };
    SegmentIntersector$2.prototype.getProperIntersectionPoint = function getProperIntersectionPoint () {
      return this._properIntersectionPoint
    };
    SegmentIntersector$2.prototype.setIsDoneIfProperInt = function setIsDoneIfProperInt (isDoneWhenProperInt) {
      this._isDoneWhenProperInt = isDoneWhenProperInt;
    };
    SegmentIntersector$2.prototype.hasProperInteriorIntersection = function hasProperInteriorIntersection () {
      return this._hasProperInterior
    };
    SegmentIntersector$2.prototype.isBoundaryPointInternal = function isBoundaryPointInternal (li, bdyNodes) {
      for (var i = bdyNodes.iterator(); i.hasNext();) {
        var node = i.next();
        var pt = node.getCoordinate();
        if (li.isIntersection(pt)) { return true }
      }
      return false
    };
    SegmentIntersector$2.prototype.hasProperIntersection = function hasProperIntersection () {
      return this._hasProper
    };
    SegmentIntersector$2.prototype.hasIntersection = function hasIntersection () {
      return this._hasIntersection
    };
    SegmentIntersector$2.prototype.isDone = function isDone () {
      return this._isDone
    };
    SegmentIntersector$2.prototype.isBoundaryPoint = function isBoundaryPoint (li, bdyNodes) {
      if (bdyNodes === null) { return false }
      if (this.isBoundaryPointInternal(li, bdyNodes[0])) { return true }
      if (this.isBoundaryPointInternal(li, bdyNodes[1])) { return true }
      return false
    };
    SegmentIntersector$2.prototype.setBoundaryNodes = function setBoundaryNodes (bdyNodes0, bdyNodes1) {
      this._bdyNodes = new Array(2).fill(null);
      this._bdyNodes[0] = bdyNodes0;
      this._bdyNodes[1] = bdyNodes1;
    };
    SegmentIntersector$2.prototype.addIntersections = function addIntersections (e0, segIndex0, e1, segIndex1) {
      if (e0 === e1 && segIndex0 === segIndex1) { return null }
      this.numTests++;
      var p00 = e0.getCoordinates()[segIndex0];
      var p01 = e0.getCoordinates()[segIndex0 + 1];
      var p10 = e1.getCoordinates()[segIndex1];
      var p11 = e1.getCoordinates()[segIndex1 + 1];
      this._li.computeIntersection(p00, p01, p10, p11);
      if (this._li.hasIntersection()) {
        if (this._recordIsolated) {
          e0.setIsolated(false);
          e1.setIsolated(false);
        }
        this._numIntersections++;
        if (!this.isTrivialIntersection(e0, segIndex0, e1, segIndex1)) {
          this._hasIntersection = true;
          if (this._includeProper || !this._li.isProper()) {
            e0.addIntersections(this._li, segIndex0, 0);
            e1.addIntersections(this._li, segIndex1, 1);
          }
          if (this._li.isProper()) {
            this._properIntersectionPoint = this._li.getIntersection(0).copy();
            this._hasProper = true;
            if (this._isDoneWhenProperInt) {
              this._isDone = true;
            }
            if (!this.isBoundaryPoint(this._li, this._bdyNodes)) { this._hasProperInterior = true; }
          }
        }
      }
    };
    SegmentIntersector$2.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SegmentIntersector$2.prototype.getClass = function getClass () {
      return SegmentIntersector$2
    };
    SegmentIntersector$2.isAdjacentSegments = function isAdjacentSegments (i1, i2) {
      return Math.abs(i1 - i2) === 1
    };

    var SimpleMCSweepLineIntersector = (function (EdgeSetIntersector$$1) {
      function SimpleMCSweepLineIntersector () {
        EdgeSetIntersector$$1.call(this);
        this.events = new ArrayList();
        this.nOverlaps = null;
      }

      if ( EdgeSetIntersector$$1 ) SimpleMCSweepLineIntersector.__proto__ = EdgeSetIntersector$$1;
      SimpleMCSweepLineIntersector.prototype = Object.create( EdgeSetIntersector$$1 && EdgeSetIntersector$$1.prototype );
      SimpleMCSweepLineIntersector.prototype.constructor = SimpleMCSweepLineIntersector;
      SimpleMCSweepLineIntersector.prototype.prepareEvents = function prepareEvents () {
        var this$1 = this;

        Collections.sort(this.events);
        for (var i = 0; i < this.events.size(); i++) {
          var ev = this$1.events.get(i);
          if (ev.isDelete()) {
            ev.getInsertEvent().setDeleteEventIndex(i);
          }
        }
      };
      SimpleMCSweepLineIntersector.prototype.computeIntersections = function computeIntersections () {
        var this$1 = this;

        if (arguments.length === 1) {
          var si = arguments[0];
          this.nOverlaps = 0;
          this.prepareEvents();
          for (var i = 0; i < this.events.size(); i++) {
            var ev = this$1.events.get(i);
            if (ev.isInsert()) {
              this$1.processOverlaps(i, ev.getDeleteEventIndex(), ev, si);
            }
            if (si.isDone()) {
              break
            }
          }
        } else if (arguments.length === 3) {
          if (arguments[2] instanceof SegmentIntersector$2 && (hasInterface(arguments[0], List) && hasInterface(arguments[1], List))) {
            var edges0 = arguments[0];
            var edges1 = arguments[1];
            var si$1 = arguments[2];
            this.addEdges(edges0, edges0);
            this.addEdges(edges1, edges1);
            this.computeIntersections(si$1);
          } else if (typeof arguments[2] === 'boolean' && (hasInterface(arguments[0], List) && arguments[1] instanceof SegmentIntersector$2)) {
            var edges = arguments[0];
            var si$2 = arguments[1];
            var testAllSegments = arguments[2];
            if (testAllSegments) { this.addEdges(edges, null); } else { this.addEdges(edges); }
            this.computeIntersections(si$2);
          }
        }
      };
      SimpleMCSweepLineIntersector.prototype.addEdge = function addEdge (edge, edgeSet) {
        var this$1 = this;

        var mce = edge.getMonotoneChainEdge();
        var startIndex = mce.getStartIndexes();
        for (var i = 0; i < startIndex.length - 1; i++) {
          var mc = new MonotoneChain$2(mce, i);
          var insertEvent = new SweepLineEvent(edgeSet, mce.getMinX(i), mc);
          this$1.events.add(insertEvent);
          this$1.events.add(new SweepLineEvent(mce.getMaxX(i), insertEvent));
        }
      };
      SimpleMCSweepLineIntersector.prototype.processOverlaps = function processOverlaps (start, end, ev0, si) {
        var this$1 = this;

        var mc0 = ev0.getObject();
        for (var i = start; i < end; i++) {
          var ev1 = this$1.events.get(i);
          if (ev1.isInsert()) {
            var mc1 = ev1.getObject();
            if (!ev0.isSameLabel(ev1)) {
              mc0.computeIntersections(mc1, si);
              this$1.nOverlaps++;
            }
          }
        }
      };
      SimpleMCSweepLineIntersector.prototype.addEdges = function addEdges () {
        var this$1 = this;

        if (arguments.length === 1) {
          var edges = arguments[0];
          for (var i = edges.iterator(); i.hasNext();) {
            var edge = i.next();
            this$1.addEdge(edge, edge);
          }
        } else if (arguments.length === 2) {
          var edges$1 = arguments[0];
          var edgeSet = arguments[1];
          for (var i$1 = edges$1.iterator(); i$1.hasNext();) {
            var edge$1 = i$1.next();
            this$1.addEdge(edge$1, edgeSet);
          }
        }
      };
      SimpleMCSweepLineIntersector.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      SimpleMCSweepLineIntersector.prototype.getClass = function getClass () {
        return SimpleMCSweepLineIntersector
      };

      return SimpleMCSweepLineIntersector;
    }(EdgeSetIntersector));

    var IntervalRTreeNode = function IntervalRTreeNode () {
      this._min = Double.POSITIVE_INFINITY;
      this._max = Double.NEGATIVE_INFINITY;
    };

    var staticAccessors$45 = { NodeComparator: { configurable: true } };
    IntervalRTreeNode.prototype.getMin = function getMin () {
      return this._min
    };
    IntervalRTreeNode.prototype.intersects = function intersects (queryMin, queryMax) {
      if (this._min > queryMax || this._max < queryMin) { return false }
      return true
    };
    IntervalRTreeNode.prototype.getMax = function getMax () {
      return this._max
    };
    IntervalRTreeNode.prototype.toString = function toString () {
      return WKTWriter.toLineString(new Coordinate(this._min, 0), new Coordinate(this._max, 0))
    };
    IntervalRTreeNode.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    IntervalRTreeNode.prototype.getClass = function getClass () {
      return IntervalRTreeNode
    };
    staticAccessors$45.NodeComparator.get = function () { return NodeComparator };

    Object.defineProperties( IntervalRTreeNode, staticAccessors$45 );

    var NodeComparator = function NodeComparator () {};

    NodeComparator.prototype.compare = function compare (o1, o2) {
      var n1 = o1;
      var n2 = o2;
      var mid1 = (n1._min + n1._max) / 2;
      var mid2 = (n2._min + n2._max) / 2;
      if (mid1 < mid2) { return -1 }
      if (mid1 > mid2) { return 1 }
      return 0
    };
    NodeComparator.prototype.interfaces_ = function interfaces_ () {
      return [Comparator]
    };
    NodeComparator.prototype.getClass = function getClass () {
      return NodeComparator
    };

    var IntervalRTreeLeafNode = (function (IntervalRTreeNode$$1) {
      function IntervalRTreeLeafNode () {
        IntervalRTreeNode$$1.call(this);
        this._item = null;
        var min = arguments[0];
        var max = arguments[1];
        var item = arguments[2];
        this._min = min;
        this._max = max;
        this._item = item;
      }

      if ( IntervalRTreeNode$$1 ) IntervalRTreeLeafNode.__proto__ = IntervalRTreeNode$$1;
      IntervalRTreeLeafNode.prototype = Object.create( IntervalRTreeNode$$1 && IntervalRTreeNode$$1.prototype );
      IntervalRTreeLeafNode.prototype.constructor = IntervalRTreeLeafNode;
      IntervalRTreeLeafNode.prototype.query = function query (queryMin, queryMax, visitor) {
        if (!this.intersects(queryMin, queryMax)) { return null }
        visitor.visitItem(this._item);
      };
      IntervalRTreeLeafNode.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      IntervalRTreeLeafNode.prototype.getClass = function getClass () {
        return IntervalRTreeLeafNode
      };

      return IntervalRTreeLeafNode;
    }(IntervalRTreeNode));

    var IntervalRTreeBranchNode = (function (IntervalRTreeNode$$1) {
      function IntervalRTreeBranchNode () {
        IntervalRTreeNode$$1.call(this);
        this._node1 = null;
        this._node2 = null;
        var n1 = arguments[0];
        var n2 = arguments[1];
        this._node1 = n1;
        this._node2 = n2;
        this.buildExtent(this._node1, this._node2);
      }

      if ( IntervalRTreeNode$$1 ) IntervalRTreeBranchNode.__proto__ = IntervalRTreeNode$$1;
      IntervalRTreeBranchNode.prototype = Object.create( IntervalRTreeNode$$1 && IntervalRTreeNode$$1.prototype );
      IntervalRTreeBranchNode.prototype.constructor = IntervalRTreeBranchNode;
      IntervalRTreeBranchNode.prototype.buildExtent = function buildExtent (n1, n2) {
        this._min = Math.min(n1._min, n2._min);
        this._max = Math.max(n1._max, n2._max);
      };
      IntervalRTreeBranchNode.prototype.query = function query (queryMin, queryMax, visitor) {
        if (!this.intersects(queryMin, queryMax)) {
          return null
        }
        if (this._node1 !== null) { this._node1.query(queryMin, queryMax, visitor); }
        if (this._node2 !== null) { this._node2.query(queryMin, queryMax, visitor); }
      };
      IntervalRTreeBranchNode.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      IntervalRTreeBranchNode.prototype.getClass = function getClass () {
        return IntervalRTreeBranchNode
      };

      return IntervalRTreeBranchNode;
    }(IntervalRTreeNode));

    var SortedPackedIntervalRTree = function SortedPackedIntervalRTree () {
      this._leaves = new ArrayList();
      this._root = null;
      this._level = 0;
    };
    SortedPackedIntervalRTree.prototype.buildTree = function buildTree () {
        var this$1 = this;

      Collections.sort(this._leaves, new IntervalRTreeNode.NodeComparator());
      var src = this._leaves;
      var temp = null;
      var dest = new ArrayList();
      while (true) {
        this$1.buildLevel(src, dest);
        if (dest.size() === 1) { return dest.get(0) }
        temp = src;
        src = dest;
        dest = temp;
      }
    };
    SortedPackedIntervalRTree.prototype.insert = function insert (min, max, item) {
      if (this._root !== null) { throw new Error('Index cannot be added to once it has been queried') }
      this._leaves.add(new IntervalRTreeLeafNode(min, max, item));
    };
    SortedPackedIntervalRTree.prototype.query = function query (min, max, visitor) {
      this.init();
      this._root.query(min, max, visitor);
    };
    SortedPackedIntervalRTree.prototype.buildRoot = function buildRoot () {
      if (this._root !== null) { return null }
      this._root = this.buildTree();
    };
    SortedPackedIntervalRTree.prototype.printNode = function printNode (node) {
      System.out.println(WKTWriter.toLineString(new Coordinate(node._min, this._level), new Coordinate(node._max, this._level)));
    };
    SortedPackedIntervalRTree.prototype.init = function init () {
      if (this._root !== null) { return null }
      this.buildRoot();
    };
    SortedPackedIntervalRTree.prototype.buildLevel = function buildLevel (src, dest) {
      this._level++;
      dest.clear();
      for (var i = 0; i < src.size(); i += 2) {
        var n1 = src.get(i);
        var n2 = i + 1 < src.size() ? src.get(i) : null;
        if (n2 === null) {
          dest.add(n1);
        } else {
          var node = new IntervalRTreeBranchNode(src.get(i), src.get(i + 1));
          dest.add(node);
        }
      }
    };
    SortedPackedIntervalRTree.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    SortedPackedIntervalRTree.prototype.getClass = function getClass () {
      return SortedPackedIntervalRTree
    };

    var ArrayListVisitor = function ArrayListVisitor () {
      this._items = new ArrayList();
    };
    ArrayListVisitor.prototype.visitItem = function visitItem (item) {
      this._items.add(item);
    };
    ArrayListVisitor.prototype.getItems = function getItems () {
      return this._items
    };
    ArrayListVisitor.prototype.interfaces_ = function interfaces_ () {
      return [ItemVisitor]
    };
    ArrayListVisitor.prototype.getClass = function getClass () {
      return ArrayListVisitor
    };

    var IndexedPointInAreaLocator = function IndexedPointInAreaLocator () {
      this._index = null;
      var g = arguments[0];
      if (!hasInterface(g, Polygonal)) { throw new IllegalArgumentException('Argument must be Polygonal') }
      this._index = new IntervalIndexedGeometry(g);
    };

    var staticAccessors$44 = { SegmentVisitor: { configurable: true },IntervalIndexedGeometry: { configurable: true } };
    IndexedPointInAreaLocator.prototype.locate = function locate (p) {
      var rcc = new RayCrossingCounter(p);
      var visitor = new SegmentVisitor(rcc);
      this._index.query(p.y, p.y, visitor);
      return rcc.getLocation()
    };
    IndexedPointInAreaLocator.prototype.interfaces_ = function interfaces_ () {
      return [PointOnGeometryLocator]
    };
    IndexedPointInAreaLocator.prototype.getClass = function getClass () {
      return IndexedPointInAreaLocator
    };
    staticAccessors$44.SegmentVisitor.get = function () { return SegmentVisitor };
    staticAccessors$44.IntervalIndexedGeometry.get = function () { return IntervalIndexedGeometry };

    Object.defineProperties( IndexedPointInAreaLocator, staticAccessors$44 );

    var SegmentVisitor = function SegmentVisitor () {
      this._counter = null;
      var counter = arguments[0];
      this._counter = counter;
    };
    SegmentVisitor.prototype.visitItem = function visitItem (item) {
      var seg = item;
      this._counter.countSegment(seg.getCoordinate(0), seg.getCoordinate(1));
    };
    SegmentVisitor.prototype.interfaces_ = function interfaces_ () {
      return [ItemVisitor]
    };
    SegmentVisitor.prototype.getClass = function getClass () {
      return SegmentVisitor
    };

    var IntervalIndexedGeometry = function IntervalIndexedGeometry () {
      this._index = new SortedPackedIntervalRTree();
      var geom = arguments[0];
      this.init(geom);
    };
    IntervalIndexedGeometry.prototype.init = function init (geom) {
        var this$1 = this;

      var lines = LinearComponentExtracter.getLines(geom);
      for (var i = lines.iterator(); i.hasNext();) {
        var line = i.next();
        var pts = line.getCoordinates();
        this$1.addLine(pts);
      }
    };
    IntervalIndexedGeometry.prototype.addLine = function addLine (pts) {
        var this$1 = this;

      for (var i = 1; i < pts.length; i++) {
        var seg = new LineSegment(pts[i - 1], pts[i]);
        var min = Math.min(seg.p0.y, seg.p1.y);
        var max = Math.max(seg.p0.y, seg.p1.y);
        this$1._index.insert(min, max, seg);
      }
    };
    IntervalIndexedGeometry.prototype.query = function query () {
      if (arguments.length === 2) {
        var min = arguments[0];
        var max = arguments[1];
        var visitor = new ArrayListVisitor();
        this._index.query(min, max, visitor);
        return visitor.getItems()
      } else if (arguments.length === 3) {
        var min$1 = arguments[0];
        var max$1 = arguments[1];
        var visitor$1 = arguments[2];
        this._index.query(min$1, max$1, visitor$1);
      }
    };
    IntervalIndexedGeometry.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    IntervalIndexedGeometry.prototype.getClass = function getClass () {
      return IntervalIndexedGeometry
    };

    var GeometryGraph = (function (PlanarGraph$$1) {
      function GeometryGraph () {
        PlanarGraph$$1.call(this);
        this._parentGeom = null;
        this._lineEdgeMap = new HashMap();
        this._boundaryNodeRule = null;
        this._useBoundaryDeterminationRule = true;
        this._argIndex = null;
        this._boundaryNodes = null;
        this._hasTooFewPoints = false;
        this._invalidPoint = null;
        this._areaPtLocator = null;
        this._ptLocator = new PointLocator();
        if (arguments.length === 2) {
          var argIndex = arguments[0];
          var parentGeom = arguments[1];
          var boundaryNodeRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
          this._argIndex = argIndex;
          this._parentGeom = parentGeom;
          this._boundaryNodeRule = boundaryNodeRule;
          if (parentGeom !== null) {
            this.add(parentGeom);
          }
        } else if (arguments.length === 3) {
          var argIndex$1 = arguments[0];
          var parentGeom$1 = arguments[1];
          var boundaryNodeRule$1 = arguments[2];
          this._argIndex = argIndex$1;
          this._parentGeom = parentGeom$1;
          this._boundaryNodeRule = boundaryNodeRule$1;
          if (parentGeom$1 !== null) {
            this.add(parentGeom$1);
          }
        }
      }

      if ( PlanarGraph$$1 ) GeometryGraph.__proto__ = PlanarGraph$$1;
      GeometryGraph.prototype = Object.create( PlanarGraph$$1 && PlanarGraph$$1.prototype );
      GeometryGraph.prototype.constructor = GeometryGraph;
      GeometryGraph.prototype.insertBoundaryPoint = function insertBoundaryPoint (argIndex, coord) {
        var n = this._nodes.addNode(coord);
        var lbl = n.getLabel();
        var boundaryCount = 1;
        var loc = Location.NONE;
        loc = lbl.getLocation(argIndex, Position.ON);
        if (loc === Location.BOUNDARY) { boundaryCount++; }
        var newLoc = GeometryGraph.determineBoundary(this._boundaryNodeRule, boundaryCount);
        lbl.setLocation(argIndex, newLoc);
      };
      GeometryGraph.prototype.computeSelfNodes = function computeSelfNodes () {
        if (arguments.length === 2) {
          var li = arguments[0];
          var computeRingSelfNodes = arguments[1];
          return this.computeSelfNodes(li, computeRingSelfNodes, false)
        } else if (arguments.length === 3) {
          var li$1 = arguments[0];
          var computeRingSelfNodes$1 = arguments[1];
          var isDoneIfProperInt = arguments[2];
          var si = new SegmentIntersector$2(li$1, true, false);
          si.setIsDoneIfProperInt(isDoneIfProperInt);
          var esi = this.createEdgeSetIntersector();
          var isRings = this._parentGeom instanceof LinearRing || this._parentGeom instanceof Polygon || this._parentGeom instanceof MultiPolygon;
          var computeAllSegments = computeRingSelfNodes$1 || !isRings;
          esi.computeIntersections(this._edges, si, computeAllSegments);
          this.addSelfIntersectionNodes(this._argIndex);
          return si
        }
      };
      GeometryGraph.prototype.computeSplitEdges = function computeSplitEdges (edgelist) {
        for (var i = this._edges.iterator(); i.hasNext();) {
          var e = i.next();
          e.eiList.addSplitEdges(edgelist);
        }
      };
      GeometryGraph.prototype.computeEdgeIntersections = function computeEdgeIntersections (g, li, includeProper) {
        var si = new SegmentIntersector$2(li, includeProper, true);
        si.setBoundaryNodes(this.getBoundaryNodes(), g.getBoundaryNodes());
        var esi = this.createEdgeSetIntersector();
        esi.computeIntersections(this._edges, g._edges, si);
        return si
      };
      GeometryGraph.prototype.getGeometry = function getGeometry () {
        return this._parentGeom
      };
      GeometryGraph.prototype.getBoundaryNodeRule = function getBoundaryNodeRule () {
        return this._boundaryNodeRule
      };
      GeometryGraph.prototype.hasTooFewPoints = function hasTooFewPoints () {
        return this._hasTooFewPoints
      };
      GeometryGraph.prototype.addPoint = function addPoint () {
        if (arguments[0] instanceof Point) {
          var p = arguments[0];
          var coord = p.getCoordinate();
          this.insertPoint(this._argIndex, coord, Location.INTERIOR);
        } else if (arguments[0] instanceof Coordinate) {
          var pt = arguments[0];
          this.insertPoint(this._argIndex, pt, Location.INTERIOR);
        }
      };
      GeometryGraph.prototype.addPolygon = function addPolygon (p) {
        var this$1 = this;

        this.addPolygonRing(p.getExteriorRing(), Location.EXTERIOR, Location.INTERIOR);
        for (var i = 0; i < p.getNumInteriorRing(); i++) {
          var hole = p.getInteriorRingN(i);
          this$1.addPolygonRing(hole, Location.INTERIOR, Location.EXTERIOR);
        }
      };
      GeometryGraph.prototype.addEdge = function addEdge (e) {
        this.insertEdge(e);
        var coord = e.getCoordinates();
        this.insertPoint(this._argIndex, coord[0], Location.BOUNDARY);
        this.insertPoint(this._argIndex, coord[coord.length - 1], Location.BOUNDARY);
      };
      GeometryGraph.prototype.addLineString = function addLineString (line) {
        var coord = CoordinateArrays.removeRepeatedPoints(line.getCoordinates());
        if (coord.length < 2) {
          this._hasTooFewPoints = true;
          this._invalidPoint = coord[0];
          return null
        }
        var e = new Edge$1(coord, new Label(this._argIndex, Location.INTERIOR));
        this._lineEdgeMap.put(line, e);
        this.insertEdge(e);
        Assert.isTrue(coord.length >= 2, 'found LineString with single point');
        this.insertBoundaryPoint(this._argIndex, coord[0]);
        this.insertBoundaryPoint(this._argIndex, coord[coord.length - 1]);
      };
      GeometryGraph.prototype.getInvalidPoint = function getInvalidPoint () {
        return this._invalidPoint
      };
      GeometryGraph.prototype.getBoundaryPoints = function getBoundaryPoints () {
        var coll = this.getBoundaryNodes();
        var pts = new Array(coll.size()).fill(null);
        var i = 0;
        for (var it = coll.iterator(); it.hasNext();) {
          var node = it.next();
          pts[i++] = node.getCoordinate().copy();
        }
        return pts
      };
      GeometryGraph.prototype.getBoundaryNodes = function getBoundaryNodes () {
        if (this._boundaryNodes === null) { this._boundaryNodes = this._nodes.getBoundaryNodes(this._argIndex); }
        return this._boundaryNodes
      };
      GeometryGraph.prototype.addSelfIntersectionNode = function addSelfIntersectionNode (argIndex, coord, loc) {
        if (this.isBoundaryNode(argIndex, coord)) { return null }
        if (loc === Location.BOUNDARY && this._useBoundaryDeterminationRule) { this.insertBoundaryPoint(argIndex, coord); } else { this.insertPoint(argIndex, coord, loc); }
      };
      GeometryGraph.prototype.addPolygonRing = function addPolygonRing (lr, cwLeft, cwRight) {
        if (lr.isEmpty()) { return null }
        var coord = CoordinateArrays.removeRepeatedPoints(lr.getCoordinates());
        if (coord.length < 4) {
          this._hasTooFewPoints = true;
          this._invalidPoint = coord[0];
          return null
        }
        var left = cwLeft;
        var right = cwRight;
        if (CGAlgorithms.isCCW(coord)) {
          left = cwRight;
          right = cwLeft;
        }
        var e = new Edge$1(coord, new Label(this._argIndex, Location.BOUNDARY, left, right));
        this._lineEdgeMap.put(lr, e);
        this.insertEdge(e);
        this.insertPoint(this._argIndex, coord[0], Location.BOUNDARY);
      };
      GeometryGraph.prototype.insertPoint = function insertPoint (argIndex, coord, onLocation) {
        var n = this._nodes.addNode(coord);
        var lbl = n.getLabel();
        if (lbl === null) {
          n._label = new Label(argIndex, onLocation);
        } else { lbl.setLocation(argIndex, onLocation); }
      };
      GeometryGraph.prototype.createEdgeSetIntersector = function createEdgeSetIntersector () {
        return new SimpleMCSweepLineIntersector()
      };
      GeometryGraph.prototype.addSelfIntersectionNodes = function addSelfIntersectionNodes (argIndex) {
        var this$1 = this;

        for (var i = this._edges.iterator(); i.hasNext();) {
          var e = i.next();
          var eLoc = e.getLabel().getLocation(argIndex);
          for (var eiIt = e.eiList.iterator(); eiIt.hasNext();) {
            var ei = eiIt.next();
            this$1.addSelfIntersectionNode(argIndex, ei.coord, eLoc);
          }
        }
      };
      GeometryGraph.prototype.add = function add () {
        if (arguments.length === 1) {
          var g = arguments[0];
          if (g.isEmpty()) { return null }
          if (g instanceof MultiPolygon) { this._useBoundaryDeterminationRule = false; }
          if (g instanceof Polygon) { this.addPolygon(g); }
          else if (g instanceof LineString$1) { this.addLineString(g); }
          else if (g instanceof Point) { this.addPoint(g); }
          else if (g instanceof MultiPoint) { this.addCollection(g); }
          else if (g instanceof MultiLineString) { this.addCollection(g); }
          else if (g instanceof MultiPolygon) { this.addCollection(g); }
          else if (g instanceof GeometryCollection) { this.addCollection(g); }
          else { throw new Error(g.getClass().getName()) }
        } else { return PlanarGraph$$1.prototype.add.apply(this, arguments) }
      };
      GeometryGraph.prototype.addCollection = function addCollection (gc) {
        var this$1 = this;

        for (var i = 0; i < gc.getNumGeometries(); i++) {
          var g = gc.getGeometryN(i);
          this$1.add(g);
        }
      };
      GeometryGraph.prototype.locate = function locate (pt) {
        if (hasInterface(this._parentGeom, Polygonal) && this._parentGeom.getNumGeometries() > 50) {
          if (this._areaPtLocator === null) {
            this._areaPtLocator = new IndexedPointInAreaLocator(this._parentGeom);
          }
          return this._areaPtLocator.locate(pt)
        }
        return this._ptLocator.locate(pt, this._parentGeom)
      };
      GeometryGraph.prototype.findEdge = function findEdge () {
        if (arguments.length === 1) {
          var line = arguments[0];
          return this._lineEdgeMap.get(line)
        } else { return PlanarGraph$$1.prototype.findEdge.apply(this, arguments) }
      };
      GeometryGraph.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      GeometryGraph.prototype.getClass = function getClass () {
        return GeometryGraph
      };
      GeometryGraph.determineBoundary = function determineBoundary (boundaryNodeRule, boundaryCount) {
        return boundaryNodeRule.isInBoundary(boundaryCount) ? Location.BOUNDARY : Location.INTERIOR
      };

      return GeometryGraph;
    }(PlanarGraph));

    var GeometryGraphOp = function GeometryGraphOp () {
      this._li = new RobustLineIntersector();
      this._resultPrecisionModel = null;
      this._arg = null;
      if (arguments.length === 1) {
        var g0 = arguments[0];
        this.setComputationPrecision(g0.getPrecisionModel());
        this._arg = new Array(1).fill(null);
        this._arg[0] = new GeometryGraph(0, g0);
      } else if (arguments.length === 2) {
        var g0$1 = arguments[0];
        var g1 = arguments[1];
        var boundaryNodeRule = BoundaryNodeRule.OGC_SFS_BOUNDARY_RULE;
        if (g0$1.getPrecisionModel().compareTo(g1.getPrecisionModel()) >= 0) { this.setComputationPrecision(g0$1.getPrecisionModel()); } else { this.setComputationPrecision(g1.getPrecisionModel()); }
        this._arg = new Array(2).fill(null);
        this._arg[0] = new GeometryGraph(0, g0$1, boundaryNodeRule);
        this._arg[1] = new GeometryGraph(1, g1, boundaryNodeRule);
      } else if (arguments.length === 3) {
        var g0$2 = arguments[0];
        var g1$1 = arguments[1];
        var boundaryNodeRule$1 = arguments[2];
        if (g0$2.getPrecisionModel().compareTo(g1$1.getPrecisionModel()) >= 0) { this.setComputationPrecision(g0$2.getPrecisionModel()); } else { this.setComputationPrecision(g1$1.getPrecisionModel()); }
        this._arg = new Array(2).fill(null);
        this._arg[0] = new GeometryGraph(0, g0$2, boundaryNodeRule$1);
        this._arg[1] = new GeometryGraph(1, g1$1, boundaryNodeRule$1);
      }
    };
    GeometryGraphOp.prototype.getArgGeometry = function getArgGeometry (i) {
      return this._arg[i].getGeometry()
    };
    GeometryGraphOp.prototype.setComputationPrecision = function setComputationPrecision (pm) {
      this._resultPrecisionModel = pm;
      this._li.setPrecisionModel(this._resultPrecisionModel);
    };
    GeometryGraphOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryGraphOp.prototype.getClass = function getClass () {
      return GeometryGraphOp
    };

    // operation.geometrygraph

    var GeometryMapper = function GeometryMapper () {};

    GeometryMapper.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryMapper.prototype.getClass = function getClass () {
      return GeometryMapper
    };
    GeometryMapper.map = function map () {
      if (arguments[0] instanceof Geometry && hasInterface(arguments[1], GeometryMapper.MapOp)) {
        var geom = arguments[0];
        var op = arguments[1];
        var mapped = new ArrayList();
        for (var i = 0; i < geom.getNumGeometries(); i++) {
          var g = op.map(geom.getGeometryN(i));
          if (g !== null) { mapped.add(g); }
        }
        return geom.getFactory().buildGeometry(mapped)
      } else if (hasInterface(arguments[0], Collection) && hasInterface(arguments[1], GeometryMapper.MapOp)) {
        var geoms = arguments[0];
        var op$1 = arguments[1];
        var mapped$1 = new ArrayList();
        for (var i$1 = geoms.iterator(); i$1.hasNext();) {
          var g$1 = i$1.next();
          var gr = op$1.map(g$1);
          if (gr !== null) { mapped$1.add(gr); }
        }
        return mapped$1
      }
    };
    GeometryMapper.MapOp = function MapOp () {};

    var OverlayOp = (function (GeometryGraphOp) {
      function OverlayOp () {
        var g0 = arguments[0];
        var g1 = arguments[1];
        GeometryGraphOp.call(this, g0, g1);
        this._ptLocator = new PointLocator();
        this._geomFact = null;
        this._resultGeom = null;
        this._graph = null;
        this._edgeList = new EdgeList();
        this._resultPolyList = new ArrayList();
        this._resultLineList = new ArrayList();
        this._resultPointList = new ArrayList();
        this._graph = new PlanarGraph(new OverlayNodeFactory());
        this._geomFact = g0.getFactory();
      }

      if ( GeometryGraphOp ) OverlayOp.__proto__ = GeometryGraphOp;
      OverlayOp.prototype = Object.create( GeometryGraphOp && GeometryGraphOp.prototype );
      OverlayOp.prototype.constructor = OverlayOp;
      OverlayOp.prototype.insertUniqueEdge = function insertUniqueEdge (e) {
        var existingEdge = this._edgeList.findEqualEdge(e);
        if (existingEdge !== null) {
          var existingLabel = existingEdge.getLabel();
          var labelToMerge = e.getLabel();
          if (!existingEdge.isPointwiseEqual(e)) {
            labelToMerge = new Label(e.getLabel());
            labelToMerge.flip();
          }
          var depth = existingEdge.getDepth();
          if (depth.isNull()) {
            depth.add(existingLabel);
          }
          depth.add(labelToMerge);
          existingLabel.merge(labelToMerge);
        } else {
          this._edgeList.add(e);
        }
      };
      OverlayOp.prototype.getGraph = function getGraph () {
        return this._graph
      };
      OverlayOp.prototype.cancelDuplicateResultEdges = function cancelDuplicateResultEdges () {
        for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext();) {
          var de = it.next();
          var sym = de.getSym();
          if (de.isInResult() && sym.isInResult()) {
            de.setInResult(false);
            sym.setInResult(false);
          }
        }
      };
      OverlayOp.prototype.isCoveredByLA = function isCoveredByLA (coord) {
        if (this.isCovered(coord, this._resultLineList)) { return true }
        if (this.isCovered(coord, this._resultPolyList)) { return true }
        return false
      };
      OverlayOp.prototype.computeGeometry = function computeGeometry (resultPointList, resultLineList, resultPolyList, opcode) {
        var geomList = new ArrayList();
        geomList.addAll(resultPointList);
        geomList.addAll(resultLineList);
        geomList.addAll(resultPolyList);
        if (geomList.isEmpty()) { return OverlayOp.createEmptyResult(opcode, this._arg[0].getGeometry(), this._arg[1].getGeometry(), this._geomFact) }
        return this._geomFact.buildGeometry(geomList)
      };
      OverlayOp.prototype.mergeSymLabels = function mergeSymLabels () {
        for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext();) {
          var node = nodeit.next();
          node.getEdges().mergeSymLabels();
        }
      };
      OverlayOp.prototype.isCovered = function isCovered (coord, geomList) {
        var this$1 = this;

        for (var it = geomList.iterator(); it.hasNext();) {
          var geom = it.next();
          var loc = this$1._ptLocator.locate(coord, geom);
          if (loc !== Location.EXTERIOR) { return true }
        }
        return false
      };
      OverlayOp.prototype.replaceCollapsedEdges = function replaceCollapsedEdges () {
        var newEdges = new ArrayList();
        for (var it = this._edgeList.iterator(); it.hasNext();) {
          var e = it.next();
          if (e.isCollapsed()) {
            it.remove();
            newEdges.add(e.getCollapsedEdge());
          }
        }
        this._edgeList.addAll(newEdges);
      };
      OverlayOp.prototype.updateNodeLabelling = function updateNodeLabelling () {
        for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext();) {
          var node = nodeit.next();
          var lbl = node.getEdges().getLabel();
          node.getLabel().merge(lbl);
        }
      };
      OverlayOp.prototype.getResultGeometry = function getResultGeometry (overlayOpCode) {
        this.computeOverlay(overlayOpCode);
        return this._resultGeom
      };
      OverlayOp.prototype.insertUniqueEdges = function insertUniqueEdges (edges) {
        var this$1 = this;

        for (var i = edges.iterator(); i.hasNext();) {
          var e = i.next();
          this$1.insertUniqueEdge(e);
        }
      };
      OverlayOp.prototype.computeOverlay = function computeOverlay (opCode) {
        this.copyPoints(0);
        this.copyPoints(1);
        this._arg[0].computeSelfNodes(this._li, false);
        this._arg[1].computeSelfNodes(this._li, false);
        this._arg[0].computeEdgeIntersections(this._arg[1], this._li, true);
        var baseSplitEdges = new ArrayList();
        this._arg[0].computeSplitEdges(baseSplitEdges);
        this._arg[1].computeSplitEdges(baseSplitEdges);
        // const splitEdges = baseSplitEdges
        this.insertUniqueEdges(baseSplitEdges);
        this.computeLabelsFromDepths();
        this.replaceCollapsedEdges();
        EdgeNodingValidator.checkValid(this._edgeList.getEdges());
        this._graph.addEdges(this._edgeList.getEdges());
        this.computeLabelling();
        this.labelIncompleteNodes();
        this.findResultAreaEdges(opCode);
        this.cancelDuplicateResultEdges();
        var polyBuilder = new PolygonBuilder(this._geomFact);
        polyBuilder.add(this._graph);
        this._resultPolyList = polyBuilder.getPolygons();
        var lineBuilder = new LineBuilder(this, this._geomFact, this._ptLocator);
        this._resultLineList = lineBuilder.build(opCode);
        var pointBuilder = new PointBuilder(this, this._geomFact, this._ptLocator);
        this._resultPointList = pointBuilder.build(opCode);
        this._resultGeom = this.computeGeometry(this._resultPointList, this._resultLineList, this._resultPolyList, opCode);
      };
      OverlayOp.prototype.labelIncompleteNode = function labelIncompleteNode (n, targetIndex) {
        var loc = this._ptLocator.locate(n.getCoordinate(), this._arg[targetIndex].getGeometry());
        n.getLabel().setLocation(targetIndex, loc);
      };
      OverlayOp.prototype.copyPoints = function copyPoints (argIndex) {
        var this$1 = this;

        for (var i = this._arg[argIndex].getNodeIterator(); i.hasNext();) {
          var graphNode = i.next();
          var newNode = this$1._graph.addNode(graphNode.getCoordinate());
          newNode.setLabel(argIndex, graphNode.getLabel().getLocation(argIndex));
        }
      };
      OverlayOp.prototype.findResultAreaEdges = function findResultAreaEdges (opCode) {
        for (var it = this._graph.getEdgeEnds().iterator(); it.hasNext();) {
          var de = it.next();
          var label = de.getLabel();
          if (label.isArea() && !de.isInteriorAreaEdge() && OverlayOp.isResultOfOp(label.getLocation(0, Position.RIGHT), label.getLocation(1, Position.RIGHT), opCode)) {
            de.setInResult(true);
          }
        }
      };
      OverlayOp.prototype.computeLabelsFromDepths = function computeLabelsFromDepths () {
        for (var it = this._edgeList.iterator(); it.hasNext();) {
          var e = it.next();
          var lbl = e.getLabel();
          var depth = e.getDepth();
          if (!depth.isNull()) {
            depth.normalize();
            for (var i = 0; i < 2; i++) {
              if (!lbl.isNull(i) && lbl.isArea() && !depth.isNull(i)) {
                if (depth.getDelta(i) === 0) {
                  lbl.toLine(i);
                } else {
                  Assert.isTrue(!depth.isNull(i, Position.LEFT), 'depth of LEFT side has not been initialized');
                  lbl.setLocation(i, Position.LEFT, depth.getLocation(i, Position.LEFT));
                  Assert.isTrue(!depth.isNull(i, Position.RIGHT), 'depth of RIGHT side has not been initialized');
                  lbl.setLocation(i, Position.RIGHT, depth.getLocation(i, Position.RIGHT));
                }
              }
            }
          }
        }
      };
      OverlayOp.prototype.computeLabelling = function computeLabelling () {
        var this$1 = this;

        for (var nodeit = this._graph.getNodes().iterator(); nodeit.hasNext();) {
          var node = nodeit.next();
          node.getEdges().computeLabelling(this$1._arg);
        }
        this.mergeSymLabels();
        this.updateNodeLabelling();
      };
      OverlayOp.prototype.labelIncompleteNodes = function labelIncompleteNodes () {
        var this$1 = this;

        // let nodeCount = 0
        for (var ni = this._graph.getNodes().iterator(); ni.hasNext();) {
          var n = ni.next();
          var label = n.getLabel();
          if (n.isIsolated()) {
            // nodeCount++
            if (label.isNull(0)) { this$1.labelIncompleteNode(n, 0); } else { this$1.labelIncompleteNode(n, 1); }
          }
          n.getEdges().updateLabelling(label);
        }
      };
      OverlayOp.prototype.isCoveredByA = function isCoveredByA (coord) {
        if (this.isCovered(coord, this._resultPolyList)) { return true }
        return false
      };
      OverlayOp.prototype.interfaces_ = function interfaces_ () {
        return []
      };
      OverlayOp.prototype.getClass = function getClass () {
        return OverlayOp
      };

      return OverlayOp;
    }(GeometryGraphOp));

    OverlayOp.overlayOp = function (geom0, geom1, opCode) {
      var gov = new OverlayOp(geom0, geom1);
      var geomOv = gov.getResultGeometry(opCode);
      return geomOv
    };
    OverlayOp.intersection = function (g, other) {
      if (g.isEmpty() || other.isEmpty()) { return OverlayOp.createEmptyResult(OverlayOp.INTERSECTION, g, other, g.getFactory()) }
      if (g.isGeometryCollection()) {
        var g2 = other;
        return GeometryCollectionMapper.map(g, {
          interfaces_: function () {
            return [GeometryMapper.MapOp]
          },
          map: function (g) {
            return g.intersection(g2)
          }
        })
      }
      g.checkNotGeometryCollection(g);
      g.checkNotGeometryCollection(other);
      return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.INTERSECTION)
    };
    OverlayOp.symDifference = function (g, other) {
      if (g.isEmpty() || other.isEmpty()) {
        if (g.isEmpty() && other.isEmpty()) { return OverlayOp.createEmptyResult(OverlayOp.SYMDIFFERENCE, g, other, g.getFactory()) }
        if (g.isEmpty()) { return other.copy() }
        if (other.isEmpty()) { return g.copy() }
      }
      g.checkNotGeometryCollection(g);
      g.checkNotGeometryCollection(other);
      return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.SYMDIFFERENCE)
    };
    OverlayOp.resultDimension = function (opCode, g0, g1) {
      var dim0 = g0.getDimension();
      var dim1 = g1.getDimension();
      var resultDimension = -1;
      switch (opCode) {
        case OverlayOp.INTERSECTION:
          resultDimension = Math.min(dim0, dim1);
          break
        case OverlayOp.UNION:
          resultDimension = Math.max(dim0, dim1);
          break
        case OverlayOp.DIFFERENCE:
          resultDimension = dim0;
          break
        case OverlayOp.SYMDIFFERENCE:
          resultDimension = Math.max(dim0, dim1);
          break
        default:
      }
      return resultDimension
    };
    OverlayOp.createEmptyResult = function (overlayOpCode, a, b, geomFact) {
      var result = null;
      switch (OverlayOp.resultDimension(overlayOpCode, a, b)) {
        case -1:
          result = geomFact.createGeometryCollection(new Array(0).fill(null));
          break
        case 0:
          result = geomFact.createPoint();
          break
        case 1:
          result = geomFact.createLineString();
          break
        case 2:
          result = geomFact.createPolygon();
          break
        default:
      }
      return result
    };
    OverlayOp.difference = function (g, other) {
      if (g.isEmpty()) { return OverlayOp.createEmptyResult(OverlayOp.DIFFERENCE, g, other, g.getFactory()) }
      if (other.isEmpty()) { return g.copy() }
      g.checkNotGeometryCollection(g);
      g.checkNotGeometryCollection(other);
      return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.DIFFERENCE)
    };
    OverlayOp.isResultOfOp = function () {
      if (arguments.length === 2) {
        var label = arguments[0];
        var opCode = arguments[1];
        var loc0 = label.getLocation(0);
        var loc1 = label.getLocation(1);
        return OverlayOp.isResultOfOp(loc0, loc1, opCode)
      } else if (arguments.length === 3) {
        var loc0$1 = arguments[0];
        var loc1$1 = arguments[1];
        var overlayOpCode = arguments[2];
        if (loc0$1 === Location.BOUNDARY) { loc0$1 = Location.INTERIOR; }
        if (loc1$1 === Location.BOUNDARY) { loc1$1 = Location.INTERIOR; }
        switch (overlayOpCode) {
          case OverlayOp.INTERSECTION:
            return loc0$1 === Location.INTERIOR && loc1$1 === Location.INTERIOR
          case OverlayOp.UNION:
            return loc0$1 === Location.INTERIOR || loc1$1 === Location.INTERIOR
          case OverlayOp.DIFFERENCE:
            return loc0$1 === Location.INTERIOR && loc1$1 !== Location.INTERIOR
          case OverlayOp.SYMDIFFERENCE:
            return (loc0$1 === Location.INTERIOR && loc1$1 !== Location.INTERIOR) || (loc0$1 !== Location.INTERIOR && loc1$1 === Location.INTERIOR)
          default:
        }
        return false
      }
    };
    OverlayOp.INTERSECTION = 1;
    OverlayOp.UNION = 2;
    OverlayOp.DIFFERENCE = 3;
    OverlayOp.SYMDIFFERENCE = 4;

    var FuzzyPointLocator = function FuzzyPointLocator () {
      this._g = null;
      this._boundaryDistanceTolerance = null;
      this._linework = null;
      this._ptLocator = new PointLocator();
      this._seg = new LineSegment();
      var g = arguments[0];
      var boundaryDistanceTolerance = arguments[1];
      this._g = g;
      this._boundaryDistanceTolerance = boundaryDistanceTolerance;
      this._linework = this.extractLinework(g);
    };
    FuzzyPointLocator.prototype.isWithinToleranceOfBoundary = function isWithinToleranceOfBoundary (pt) {
        var this$1 = this;

      for (var i = 0; i < this._linework.getNumGeometries(); i++) {
        var line = this$1._linework.getGeometryN(i);
        var seq = line.getCoordinateSequence();
        for (var j = 0; j < seq.size() - 1; j++) {
          seq.getCoordinate(j, this$1._seg.p0);
          seq.getCoordinate(j + 1, this$1._seg.p1);
          var dist = this$1._seg.distance(pt);
          if (dist <= this$1._boundaryDistanceTolerance) { return true }
        }
      }
      return false
    };
    FuzzyPointLocator.prototype.getLocation = function getLocation (pt) {
      if (this.isWithinToleranceOfBoundary(pt)) { return Location.BOUNDARY }
      return this._ptLocator.locate(pt, this._g)
    };
    FuzzyPointLocator.prototype.extractLinework = function extractLinework (g) {
      var extracter = new PolygonalLineworkExtracter();
      g.apply(extracter);
      var linework = extracter.getLinework();
      var lines = GeometryFactory.toLineStringArray(linework);
      return g.getFactory().createMultiLineString(lines)
    };
    FuzzyPointLocator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    FuzzyPointLocator.prototype.getClass = function getClass () {
      return FuzzyPointLocator
    };

    var PolygonalLineworkExtracter = function PolygonalLineworkExtracter () {
      this._linework = null;
      this._linework = new ArrayList();
    };
    PolygonalLineworkExtracter.prototype.getLinework = function getLinework () {
      return this._linework
    };
    PolygonalLineworkExtracter.prototype.filter = function filter (g) {
        var this$1 = this;

      if (g instanceof Polygon) {
        var poly = g;
        this._linework.add(poly.getExteriorRing());
        for (var i = 0; i < poly.getNumInteriorRing(); i++) {
          this$1._linework.add(poly.getInteriorRingN(i));
        }
      }
    };
    PolygonalLineworkExtracter.prototype.interfaces_ = function interfaces_ () {
      return [GeometryFilter]
    };
    PolygonalLineworkExtracter.prototype.getClass = function getClass () {
      return PolygonalLineworkExtracter
    };

    var OffsetPointGenerator = function OffsetPointGenerator () {
      this._g = null;
      this._doLeft = true;
      this._doRight = true;
      var g = arguments[0];
      this._g = g;
    };
    OffsetPointGenerator.prototype.extractPoints = function extractPoints (line, offsetDistance, offsetPts) {
        var this$1 = this;

      var pts = line.getCoordinates();
      for (var i = 0; i < pts.length - 1; i++) {
        this$1.computeOffsetPoints(pts[i], pts[i + 1], offsetDistance, offsetPts);
      }
    };
    OffsetPointGenerator.prototype.setSidesToGenerate = function setSidesToGenerate (doLeft, doRight) {
      this._doLeft = doLeft;
      this._doRight = doRight;
    };
    OffsetPointGenerator.prototype.getPoints = function getPoints (offsetDistance) {
        var this$1 = this;

      var offsetPts = new ArrayList();
      var lines = LinearComponentExtracter.getLines(this._g);
      for (var i = lines.iterator(); i.hasNext();) {
        var line = i.next();
        this$1.extractPoints(line, offsetDistance, offsetPts);
      }
      return offsetPts
    };
    OffsetPointGenerator.prototype.computeOffsetPoints = function computeOffsetPoints (p0, p1, offsetDistance, offsetPts) {
      var dx = p1.x - p0.x;
      var dy = p1.y - p0.y;
      var len = Math.sqrt(dx * dx + dy * dy);
      var ux = offsetDistance * dx / len;
      var uy = offsetDistance * dy / len;
      var midX = (p1.x + p0.x) / 2;
      var midY = (p1.y + p0.y) / 2;
      if (this._doLeft) {
        var offsetLeft = new Coordinate(midX - uy, midY + ux);
        offsetPts.add(offsetLeft);
      }
      if (this._doRight) {
        var offsetRight = new Coordinate(midX + uy, midY - ux);
        offsetPts.add(offsetRight);
      }
    };
    OffsetPointGenerator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OffsetPointGenerator.prototype.getClass = function getClass () {
      return OffsetPointGenerator
    };

    var OverlayResultValidator = function OverlayResultValidator () {
      this._geom = null;
      this._locFinder = null;
      this._location = new Array(3).fill(null);
      this._invalidLocation = null;
      this._boundaryDistanceTolerance = OverlayResultValidator.TOLERANCE;
      this._testCoords = new ArrayList();
      var a = arguments[0];
      var b = arguments[1];
      var result = arguments[2];
      this._boundaryDistanceTolerance = OverlayResultValidator.computeBoundaryDistanceTolerance(a, b);
      this._geom = [a, b, result];
      this._locFinder = [new FuzzyPointLocator(this._geom[0], this._boundaryDistanceTolerance), new FuzzyPointLocator(this._geom[1], this._boundaryDistanceTolerance), new FuzzyPointLocator(this._geom[2], this._boundaryDistanceTolerance)];
    };

    var staticAccessors$46 = { TOLERANCE: { configurable: true } };
    OverlayResultValidator.prototype.reportResult = function reportResult (overlayOp, location, expectedInterior) {
      System.out.println('Overlay result invalid - A:' + Location.toLocationSymbol(location[0]) + ' B:' + Location.toLocationSymbol(location[1]) + ' expected:' + (expectedInterior ? 'i' : 'e') + ' actual:' + Location.toLocationSymbol(location[2]));
    };
    OverlayResultValidator.prototype.isValid = function isValid (overlayOp) {
      this.addTestPts(this._geom[0]);
      this.addTestPts(this._geom[1]);
      var isValid = this.checkValid(overlayOp);
      return isValid
    };
    OverlayResultValidator.prototype.checkValid = function checkValid () {
        var this$1 = this;

      if (arguments.length === 1) {
        var overlayOp = arguments[0];
        for (var i = 0; i < this._testCoords.size(); i++) {
          var pt = this$1._testCoords.get(i);
          if (!this$1.checkValid(overlayOp, pt)) {
            this$1._invalidLocation = pt;
            return false
          }
        }
        return true
      } else if (arguments.length === 2) {
        var overlayOp$1 = arguments[0];
        var pt$1 = arguments[1];
        this._location[0] = this._locFinder[0].getLocation(pt$1);
        this._location[1] = this._locFinder[1].getLocation(pt$1);
        this._location[2] = this._locFinder[2].getLocation(pt$1);
        if (OverlayResultValidator.hasLocation(this._location, Location.BOUNDARY)) { return true }
        return this.isValidResult(overlayOp$1, this._location)
      }
    };
    OverlayResultValidator.prototype.addTestPts = function addTestPts (g) {
      var ptGen = new OffsetPointGenerator(g);
      this._testCoords.addAll(ptGen.getPoints(5 * this._boundaryDistanceTolerance));
    };
    OverlayResultValidator.prototype.isValidResult = function isValidResult (overlayOp, location) {
      var expectedInterior = OverlayOp.isResultOfOp(location[0], location[1], overlayOp);
      var resultInInterior = location[2] === Location.INTERIOR;
      var isValid = !(expectedInterior ^ resultInInterior);
      if (!isValid) { this.reportResult(overlayOp, location, expectedInterior); }
      return isValid
    };
    OverlayResultValidator.prototype.getInvalidLocation = function getInvalidLocation () {
      return this._invalidLocation
    };
    OverlayResultValidator.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    OverlayResultValidator.prototype.getClass = function getClass () {
      return OverlayResultValidator
    };
    OverlayResultValidator.hasLocation = function hasLocation (location, loc) {
      for (var i = 0; i < 3; i++) {
        if (location[i] === loc) { return true }
      }
      return false
    };
    OverlayResultValidator.computeBoundaryDistanceTolerance = function computeBoundaryDistanceTolerance (g0, g1) {
      return Math.min(GeometrySnapper.computeSizeBasedSnapTolerance(g0), GeometrySnapper.computeSizeBasedSnapTolerance(g1))
    };
    OverlayResultValidator.isValid = function isValid (a, b, overlayOp, result) {
      var validator = new OverlayResultValidator(a, b, result);
      return validator.isValid(overlayOp)
    };
    staticAccessors$46.TOLERANCE.get = function () { return 0.000001 };

    Object.defineProperties( OverlayResultValidator, staticAccessors$46 );

    // operation.overlay

    var GeometryCombiner = function GeometryCombiner (geoms) {
      this._geomFactory = null;
      this._skipEmpty = false;
      this._inputGeoms = null;
      this._geomFactory = GeometryCombiner.extractFactory(geoms);
      this._inputGeoms = geoms;
    };
    GeometryCombiner.prototype.extractElements = function extractElements (geom, elems) {
        var this$1 = this;

      if (geom === null) { return null }
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var elemGeom = geom.getGeometryN(i);
        if (this$1._skipEmpty && elemGeom.isEmpty()) { continue }
        elems.add(elemGeom);
      }
    };
    GeometryCombiner.prototype.combine = function combine () {
        var this$1 = this;

      var elems = new ArrayList();
      for (var i = this._inputGeoms.iterator(); i.hasNext();) {
        var g = i.next();
        this$1.extractElements(g, elems);
      }
      if (elems.size() === 0) {
        if (this._geomFactory !== null) {
          return this._geomFactory.createGeometryCollection(null)
        }
        return null
      }
      return this._geomFactory.buildGeometry(elems)
    };
    GeometryCombiner.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    GeometryCombiner.prototype.getClass = function getClass () {
      return GeometryCombiner
    };
    GeometryCombiner.combine = function combine () {
      if (arguments.length === 1) {
        var geoms = arguments[0];
        var combiner = new GeometryCombiner(geoms);
        return combiner.combine()
      } else if (arguments.length === 2) {
        var g0 = arguments[0];
        var g1 = arguments[1];
        var combiner$1 = new GeometryCombiner(GeometryCombiner.createList(g0, g1));
        return combiner$1.combine()
      } else if (arguments.length === 3) {
        var g0$1 = arguments[0];
        var g1$1 = arguments[1];
        var g2 = arguments[2];
        var combiner$2 = new GeometryCombiner(GeometryCombiner.createList(g0$1, g1$1, g2));
        return combiner$2.combine()
      }
    };
    GeometryCombiner.extractFactory = function extractFactory (geoms) {
      if (geoms.isEmpty()) { return null }
      return geoms.iterator().next().getFactory()
    };
    GeometryCombiner.createList = function createList () {
      if (arguments.length === 2) {
        var obj0 = arguments[0];
        var obj1 = arguments[1];
        var list = new ArrayList();
        list.add(obj0);
        list.add(obj1);
        return list
      } else if (arguments.length === 3) {
        var obj0$1 = arguments[0];
        var obj1$1 = arguments[1];
        var obj2 = arguments[2];
        var list$1 = new ArrayList();
        list$1.add(obj0$1);
        list$1.add(obj1$1);
        list$1.add(obj2);
        return list$1
      }
    };

    var CascadedPolygonUnion = function CascadedPolygonUnion () {
      this._inputPolys = null;
      this._geomFactory = null;
      var polys = arguments[0];
      this._inputPolys = polys;
      if (this._inputPolys === null) { this._inputPolys = new ArrayList(); }
    };

    var staticAccessors$47 = { STRTREE_NODE_CAPACITY: { configurable: true } };
    CascadedPolygonUnion.prototype.reduceToGeometries = function reduceToGeometries (geomTree) {
        var this$1 = this;

      var geoms = new ArrayList();
      for (var i = geomTree.iterator(); i.hasNext();) {
        var o = i.next();
        var geom = null;
        if (hasInterface(o, List)) {
          geom = this$1.unionTree(o);
        } else if (o instanceof Geometry) {
          geom = o;
        }
        geoms.add(geom);
      }
      return geoms
    };
    CascadedPolygonUnion.prototype.extractByEnvelope = function extractByEnvelope (env, geom, disjointGeoms) {
      var intersectingGeoms = new ArrayList();
      for (var i = 0; i < geom.getNumGeometries(); i++) {
        var elem = geom.getGeometryN(i);
        if (elem.getEnvelopeInternal().intersects(env)) { intersectingGeoms.add(elem); } else { disjointGeoms.add(elem); }
      }
      return this._geomFactory.buildGeometry(intersectingGeoms)
    };
    CascadedPolygonUnion.prototype.unionOptimized = function unionOptimized (g0, g1) {
      var g0Env = g0.getEnvelopeInternal();
      var g1Env = g1.getEnvelopeInternal();
      if (!g0Env.intersects(g1Env)) {
        var combo = GeometryCombiner.combine(g0, g1);
        return combo
      }
      if (g0.getNumGeometries() <= 1 && g1.getNumGeometries() <= 1) { return this.unionActual(g0, g1) }
      var commonEnv = g0Env.intersection(g1Env);
      return this.unionUsingEnvelopeIntersection(g0, g1, commonEnv)
    };
    CascadedPolygonUnion.prototype.union = function union () {
      if (this._inputPolys === null) { throw new Error('union() method cannot be called twice') }
      if (this._inputPolys.isEmpty()) { return null }
      this._geomFactory = this._inputPolys.iterator().next().getFactory();
      var index = new STRtree(CascadedPolygonUnion.STRTREE_NODE_CAPACITY);
      for (var i = this._inputPolys.iterator(); i.hasNext();) {
        var item = i.next();
        index.insert(item.getEnvelopeInternal(), item);
      }
      this._inputPolys = null;
      var itemTree = index.itemsTree();
      var unionAll = this.unionTree(itemTree);
      return unionAll
    };
    CascadedPolygonUnion.prototype.binaryUnion = function binaryUnion () {
      if (arguments.length === 1) {
        var geoms = arguments[0];
        return this.binaryUnion(geoms, 0, geoms.size())
      } else if (arguments.length === 3) {
        var geoms$1 = arguments[0];
        var start = arguments[1];
        var end = arguments[2];
        if (end - start <= 1) {
          var g0 = CascadedPolygonUnion.getGeometry(geoms$1, start);
          return this.unionSafe(g0, null)
        } else if (end - start === 2) {
          return this.unionSafe(CascadedPolygonUnion.getGeometry(geoms$1, start), CascadedPolygonUnion.getGeometry(geoms$1, start + 1))
        } else {
          var mid = Math.trunc((end + start) / 2);
          var g0$1 = this.binaryUnion(geoms$1, start, mid);
          var g1 = this.binaryUnion(geoms$1, mid, end);
          return this.unionSafe(g0$1, g1)
        }
      }
    };
    CascadedPolygonUnion.prototype.repeatedUnion = function repeatedUnion (geoms) {
      var union = null;
      for (var i = geoms.iterator(); i.hasNext();) {
        var g = i.next();
        if (union === null) { union = g.copy(); } else { union = union.union(g); }
      }
      return union
    };
    CascadedPolygonUnion.prototype.unionSafe = function unionSafe (g0, g1) {
      if (g0 === null && g1 === null) { return null }
      if (g0 === null) { return g1.copy() }
      if (g1 === null) { return g0.copy() }
      return this.unionOptimized(g0, g1)
    };
    CascadedPolygonUnion.prototype.unionActual = function unionActual (g0, g1) {
      return CascadedPolygonUnion.restrictToPolygons(g0.union(g1))
    };
    CascadedPolygonUnion.prototype.unionTree = function unionTree (geomTree) {
      var geoms = this.reduceToGeometries(geomTree);
      var union = this.binaryUnion(geoms);
      return union
    };
    CascadedPolygonUnion.prototype.unionUsingEnvelopeIntersection = function unionUsingEnvelopeIntersection (g0, g1, common) {
      var disjointPolys = new ArrayList();
      var g0Int = this.extractByEnvelope(common, g0, disjointPolys);
      var g1Int = this.extractByEnvelope(common, g1, disjointPolys);
      var union = this.unionActual(g0Int, g1Int);
      disjointPolys.add(union);
      var overallUnion = GeometryCombiner.combine(disjointPolys);
      return overallUnion
    };
    CascadedPolygonUnion.prototype.bufferUnion = function bufferUnion () {
      if (arguments.length === 1) {
        var geoms = arguments[0];
        var factory = geoms.get(0).getFactory();
        var gColl = factory.buildGeometry(geoms);
        var unionAll = gColl.buffer(0.0);
        return unionAll
      } else if (arguments.length === 2) {
        var g0 = arguments[0];
        var g1 = arguments[1];
        var factory$1 = g0.getFactory();
        var gColl$1 = factory$1.createGeometryCollection([g0, g1]);
        var unionAll$1 = gColl$1.buffer(0.0);
        return unionAll$1
      }
    };
    CascadedPolygonUnion.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    CascadedPolygonUnion.prototype.getClass = function getClass () {
      return CascadedPolygonUnion
    };
    CascadedPolygonUnion.restrictToPolygons = function restrictToPolygons (g) {
      if (hasInterface(g, Polygonal)) {
        return g
      }
      var polygons = PolygonExtracter.getPolygons(g);
      if (polygons.size() === 1) { return polygons.get(0) }
      return g.getFactory().createMultiPolygon(GeometryFactory.toPolygonArray(polygons))
    };
    CascadedPolygonUnion.getGeometry = function getGeometry (list, index) {
      if (index >= list.size()) { return null }
      return list.get(index)
    };
    CascadedPolygonUnion.union = function union (polys) {
      var op = new CascadedPolygonUnion(polys);
      return op.union()
    };
    staticAccessors$47.STRTREE_NODE_CAPACITY.get = function () { return 4 };

    Object.defineProperties( CascadedPolygonUnion, staticAccessors$47 );

    var UnionOp = function UnionOp () {};

    UnionOp.prototype.interfaces_ = function interfaces_ () {
      return []
    };
    UnionOp.prototype.getClass = function getClass () {
      return UnionOp
    };
    UnionOp.union = function union (g, other) {
      if (g.isEmpty() || other.isEmpty()) {
        if (g.isEmpty() && other.isEmpty()) { return OverlayOp.createEmptyResult(OverlayOp.UNION, g, other, g.getFactory()) }
        if (g.isEmpty()) { return other.copy() }
        if (other.isEmpty()) { return g.copy() }
      }
      g.checkNotGeometryCollection(g);
      g.checkNotGeometryCollection(other);
      return SnapIfNeededOverlayOp.overlayOp(g, other, OverlayOp.UNION)
    };

    /**
     * Calculates a buffer for input features for a given radius. Units supported are miles, kilometers, and degrees.
     *
     * When using a negative radius, the resulting geometry may be invalid if
     * it's too small compared to the radius magnitude. If the input is a
     * FeatureCollection, only valid members will be returned in the output
     * FeatureCollection - i.e., the output collection may have fewer members than
     * the input, or even be empty.
     *
     * @name buffer
     * @param {FeatureCollection|Geometry|Feature<any>} geojson input to be buffered
     * @param {number} radius distance to draw the buffer (negative values are allowed)
     * @param {Object} [options={}] Optional parameters
     * @param {string} [options.units="kilometers"] any of the options supported by turf units
     * @returns {FeatureCollection|Feature<Polygon|MultiPolygon>|undefined} buffered features
     * @example
     * var point = turf.point([-90.548630, 14.616599]);
     * var buffered = turf.buffer(point, 500, {units: 'miles'});
     *
     * //addToMap
     * var addToMap = [point, buffered]
     */
    function buffer(geojson, radius, options) {

        // Optional params
        options = checkIfOptionsExist(options);
        var units = options.units || 'kilometers';
        // var steps = options.steps || 64;

        // validation
        if (!geojson) throw new Error('geojson is required');
        if (typeof options !== 'object') throw new Error('options must be an object');
        // if (typeof steps !== 'number') throw new Error('steps must be an number');

        // Allow negative buffers ("erosion") or zero-sized buffers ("repair geometry")
        if (radius === undefined) throw new Error('radius is required');
        // if (steps <= 0) throw new Error('steps must be greater than 0');

        var distance = radiansToLength(lengthToRadians(radius, units), 'meters');
        var results = [];

        switch (geojson.type) {
        case 'GeometryCollection':
            geomEach(geojson, function (geometry$$1) {
                var buffered = bufferFeature(geometry$$1, distance);
                if (buffered) results.push(buffered);
            });
            return featureCollection(results);
        case 'FeatureCollection':
            featureEach(geojson, function (feature$$1) {
                var buffered = bufferFeature(feature$$1, distance);
                if (buffered) results.push(buffered);
            });
            return featureCollection(results);
        }
        return bufferFeature(geojson, distance);
    }

    /**
     * Buffer single Feature/Geometry
     *
     * @private
     * @param {Feature<any>} geojson input to be buffered
     * @param {number} radius distance to draw the buffer
     * @param {number} [steps=64] number of steps
     * @returns {Feature<Polygon|MultiPolygon>} buffered feature
     */
    function bufferFeature(geojson, radius) {
        var properties = geojson.properties || {};
        var geometry$$1 = (geojson.type === 'Feature') ? clone(geojson.geometry) : clone(geojson);

        var centroid = centerOfMass(geometry$$1);
        var utmZone = checkUtmZone$1(centroid.geometry);
        reprojectFeature$1(geometry$$1, utmZone, true);

        var reader = new GeoJSONReader();
        var geom = reader.read(geometry$$1);
        var buffered = BufferOp.bufferOp(geom, radius);
        var writer = new GeoJSONWriter();
        buffered = writer.write(buffered);

        if (coordsIsNaN(buffered.coordinates)) return undefined;
        reprojectFeature$1(buffered, utmZone, false);

        return (buffered.geometry) ? buffered : feature(buffered, properties);
    }

    /**
     * Coordinates isNaN
     *
     * @private
     * @param {Array<any>} coords GeoJSON Coordinates
     * @returns {boolean} if NaN exists
     */
    function coordsIsNaN(coords) {
        if (Array.isArray(coords[0])) return coordsIsNaN(coords[0]);
        return isNaN(coords[0]);
    }

    function reprojectFeature$1(feature$$1, utmZone, toUtm) {
        coordEach(feature$$1, function (coord, coordIndex) { //eslint-disable-line
            var blah = toUtm ? convertCoordToUtm$1(coord[0], coord[1], utmZone) : convertUtmToLatLon$1(coord[0], coord[1], utmZone);
            coord.length = 0;
            coord.push(blah[0], blah[1]);
        }, false);
    }

    function checkUtmZone$1(centerPoint) {

        const lat = centerPoint.coordinates[1];
        const lon = centerPoint.coordinates[0];
        let zoneNumber = Math.floor((lon + 180) / 6) + 1;
        let hemisphere = 'N';

        if (lon === 180) zoneNumber = 60;
        if (lat < 0.0) hemisphere = 'S';

        if (lat >= 56.0 && lat < 64.0 && lon >= 3.0 && lon < 12.0) zoneNumber = 32;

        return {zoneNumber, hemisphere};
    }

    function convertCoordToUtm$1(lon, lat, zone) {

        let falseEasting = 500e3;
        let falseNorthing = 10000e3;
        let λ0 = degreesToRadians(((zone.zoneNumber - 1) * 6 - 180 + 3));

        let mgrsLatBands = 'CDEFGHJKLMNPQRSTUVWXX'; // X is repeated for 80-84°N
        let latBand = mgrsLatBands.charAt(Math.floor(lat / 8 + 10));

        // adjust zone & central meridian for Norway
        if (zone === 31 && latBand === 'V' && lon >= 3) { zone++; degreesToRadians(λ0 += 6); }
        // adjust zone & central meridian for Svalbard
        if (zone === 32 && latBand === 'X' && lon <  9) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 32 && latBand === 'X' && lon >= 9) { zone++; degreesToRadians(λ0 += 6); }
        if (zone === 34 && latBand === 'X' && lon < 21) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 34 && latBand === 'X' && lon >= 21) { zone++; degreesToRadians(λ0 += 6); }
        if (zone === 36 && latBand === 'X' && lon < 33) { zone--; degreesToRadians(λ0 -= 6); }
        if (zone === 36 && latBand === 'X' && lon >= 33) { zone++; degreesToRadians(λ0 += 6); }

        var φ = degreesToRadians(lat);      // latitude ± from equator
        var λ = degreesToRadians(lon) - λ0; // longitude ± from central meridian

        let a = 6378137;
        let f = 1 / 298.257223563;
        // WGS 84: a = 6378137, b = 6356752.314245, f = 1/298.257223563;

        let k0 = 0.9996; // UTM scale on the central meridian

        // ---- easting, northing: Karney 2011 Eq 7-14, 29, 35:

        let e = Math.sqrt(f * (2 - f)); // eccentricity
        let n = f / (2 - f);        // 3rd flattening
        let n2 = n * n, n3 = n * n2, n4 = n * n3, n5 = n * n4, n6 = n * n5; // TODO: compare Horner-form accuracy?

        let cosλ = Math.cos(λ), sinλ = Math.sin(λ);

        let τ = Math.tan(φ); // τ ≡ tanφ, τʹ ≡ tanφʹ; prime (ʹ) indicates angles on the conformal sphere
        let σ = Math.sinh(e * Math.atanh(e * τ / Math.sqrt(1 + τ * τ)));

        let τʹ = τ * Math.sqrt(1 + σ * σ) - σ * Math.sqrt(1 + τ * τ);

        let ξʹ = Math.atan2(τʹ, cosλ);
        let ηʹ = Math.asinh(sinλ / Math.sqrt(τʹ * τʹ + cosλ * cosλ));

        let A = a / (1 + n) * (1 + 1 / 4 * n2 + 1 / 64 * n4 + 1 / 256 * n6); // 2πA is the circumference of a meridian

        let α = [null, // note α is one-based array (6th order Krüger expressions)
            1 / 2 * n - 2 / 3 * n2 + 5 / 16 * n3 +   41 / 180 * n4 -     127 / 288 * n5 +      7891 / 37800 * n6,
            13 / 48 * n2 -  3 / 5 * n3 + 557 / 1440 * n4 +     281 / 630 * n5 - 1983433 / 1935360 * n6,
            61 / 240 * n3 -  103 / 140 * n4 + 15061 / 26880 * n5 +   167603 / 181440 * n6,
            49561 / 161280 * n4 -     179 / 168 * n5 + 6601661 / 7257600 * n6,
            34729 / 80640 * n5 - 3418889 / 1995840 * n6,
            212378941 / 319334400 * n6];

        let ξ = ξʹ;
        for (let j = 1; j <= 6; j++) ξ += α[j] * Math.sin(2 * j * ξʹ) * Math.cosh(2 * j * ηʹ);

        let η = ηʹ;
        for (let j = 1; j <= 6; j++) η += α[j] * Math.cos(2 * j * ξʹ) * Math.sinh(2 * j * ηʹ);

        let x = k0 * A * η;
        let y = k0 * A * ξ;

        x = x + falseEasting;
        if (y < 0) y = y + falseNorthing;

        return [y, x];
    }

    function convertUtmToLatLon$1(y, x, zone) {
        var z = zone.zoneNumber;
        var h = zone.hemisphere;

        var falseEasting = 500e3, falseNorthing = 10000e3;

        var a = 6378137, f = 1 / 298.257223563;

        var k0 = 0.9996; // UTM scale on the central meridian

        x = x - falseEasting;               // make x ± relative to central meridian
        y = h === 'S' ? y - falseNorthing : y; // make y ± relative to equator

        // ---- from Karney 2011 Eq 15-22, 36:

        var e = Math.sqrt(f * (2 - f)); // eccentricity
        var n = f / (2 - f);        // 3rd flattening
        var n2 = n * n, n3 = n * n2, n4 = n * n3, n5 = n * n4, n6 = n * n5;

        var A = a / (1 + n) * (1 + 1 / 4 * n2 + 1 / 64 * n4 + 1 / 256 * n6); // 2πA is the circumference of a meridian

        var η = x / (k0 * A);
        var ξ = y / (k0 * A);

        var β = [null, // note β is one-based array (6th order Krüger expressions)
            1 / 2 * n - 2 / 3 * n2 + 37 / 96 * n3 -    1 / 360 * n4 -   81 / 512 * n5 +    96199 / 604800 * n6,
            1 / 48 * n2 +  1 / 15 * n3 - 437 / 1440 * n4 +   46 / 105 * n5 - 1118711 / 3870720 * n6,
            17 / 480 * n3 -   37 / 840 * n4 - 209 / 4480 * n5 +      5569 / 90720 * n6,
            4397 / 161280 * n4 -   11 / 504 * n5 -  830251 / 7257600 * n6,
            4583 / 161280 * n5 -  108847 / 3991680 * n6,
            20648693 / 638668800 * n6];

        var ξʹ = ξ;
        for (var j = 1; j <= 6; j++) ξʹ -= β[j] * Math.sin(2 * j * ξ) * Math.cosh(2 * j * η);

        var ηʹ = η;
        for (var j = 1; j <= 6; j++) ηʹ -= β[j] * Math.cos(2 * j * ξ) * Math.sinh(2 * j * η);  //eslint-disable-line

        var sinhηʹ = Math.sinh(ηʹ);
        var sinξʹ = Math.sin(ξʹ), cosξʹ = Math.cos(ξʹ);

        var τʹ = sinξʹ / Math.sqrt(sinhηʹ * sinhηʹ + cosξʹ * cosξʹ);

        var τi = τʹ;
        do {
            var σi = Math.sinh(e * Math.atanh(e * τi / Math.sqrt(1 + τi * τi)));
            var τiʹ = τi * Math.sqrt(1 + σi * σi) - σi * Math.sqrt(1 + τi * τi);
            var δτi = (τʹ - τiʹ) / Math.sqrt(1 + τiʹ * τiʹ) *
            (1 + (1 - e * e) * τi * τi) / ((1 - e * e) * Math.sqrt(1 + τi * τi));
            τi += δτi;
        } while (Math.abs(δτi) > 1e-12); // using IEEE 754 δτi -> 0 after 2-3 iterations
        // note relatively large convergence test as δτi toggles on ±1.12e-16 for eg 31 N 400000 5000000
        var τ = τi;

        var φ = Math.atan(τ);

        var λ = Math.atan2(sinhηʹ, cosξʹ);

        var λ0 = degreesToRadians((z - 1) * 6 - 180 + 3); // longitude of central meridian
        λ += λ0; // move λ from zonal to global coordinates

        // round to reasonable precision
        var lat = radiansToDegrees(φ); // nm precision (1nm = 10^-11°)
        var lon = radiansToDegrees(λ); // (strictly lat rounding should be φ⋅cosφ!)

        return [lon, lat];
    }

    /**
     * Turf is a modular geospatial analysis engine written in JavaScript. It performs geospatial
     * processing tasks with GeoJSON data and can be run on a server or in a browser.
     *
     * @module turf
     * @summary Geospatial analysis for JavaScript
     */

    exports.projection = index$7;
    exports.random = index$8;
    exports.clusters = index$9;
    exports.helpers = index;
    exports.invariant = index$2;
    exports.meta = index$1;
    exports.isolines = isolines;
    exports.convex = convex;
    exports.pointsWithinPolygon = pointsWithinPolygon;
    exports.concave = concave;
    exports.collect = collect;
    exports.flip = flip;
    exports.simplify = simplify$1;
    exports.bezierSpline = bezier;
    exports.tag = tag;
    exports.sample = sample;
    exports.envelope = envelope;
    exports.square = square;
    exports.circle = circle;
    exports.midpoint = midpoint;
    exports.center = center;
    exports.centerOfMass = centerOfMass;
    exports.centroid = centroid;
    exports.combine = combine;
    exports.distance = distance;
    exports.explode = explode;
    exports.bbox = bbox;
    exports.tesselate = tesselate;
    exports.bboxPolygon = bboxPolygon;
    exports.booleanPointInPolygon = booleanPointInPolygon;
    exports.nearestPoint = nearestPoint;
    exports.nearestPointOnLine = nearestPointOnLine;
    exports.nearestPointToLine = nearestPointToLine;
    exports.planepoint = planepoint;
    exports.tin = tin;
    exports.bearing = bearing;
    exports.destination = destination;
    exports.kinks = kinks;
    exports.pointOnFeature = pointOnFeature;
    exports.area = area$1;
    exports.along = along;
    exports.length = length$1;
    exports.lineSlice = lineSlice;
    exports.lineSliceAlong = lineSliceAlong;
    exports.pointGrid = pointGrid;
    exports.truncate = truncate;
    exports.flatten = flatten;
    exports.lineIntersect = lineIntersect;
    exports.lineChunk = lineChunk;
    exports.unkinkPolygon = unkinkPolygon;
    exports.greatCircle = greatCircle;
    exports.lineSegment = lineSegment;
    exports.lineSplit = lineSplit;
    exports.lineArc = lineArc;
    exports.polygonToLine = polygonToLine;
    exports.lineToPolygon = lineToPolygon;
    exports.bboxClip = bboxClip;
    exports.lineOverlap = lineOverlap;
    exports.sector = sector;
    exports.rhumbBearing = rhumbBearing;
    exports.rhumbDistance = rhumbDistance;
    exports.rhumbDestination = rhumbDestination;
    exports.polygonTangents = polygonTangents;
    exports.rewind = rewind;
    exports.isobands = isobands;
    exports.transformRotate = transformRotate;
    exports.transformScale = transformScale;
    exports.transformTranslate = transformTranslate;
    exports.lineOffset = lineOffset;
    exports.polygonize = polygonize;
    exports.booleanDisjoint = booleanDisjoint;
    exports.booleanContains = booleanContains;
    exports.booleanCrosses = booleanCrosses;
    exports.booleanClockwise = booleanClockwise;
    exports.booleanOverlap = booleanOverlap;
    exports.booleanPointOnLine = booleanPointOnLine;
    exports.booleanEqual = booleanEqual;
    exports.booleanWithin = booleanWithin;
    exports.clone = clone;
    exports.cleanCoords = cleanCoords;
    exports.clustersDbscan = clustersDbscan;
    exports.clustersKmeans = clustersKmeans;
    exports.pointToLineDistance = pointToLineDistance;
    exports.booleanParallel = booleanParallel;
    exports.shortestPath = shortestPath;
    exports.voronoi = voronoi$1;
    exports.ellipse = ellipse;
    exports.centerMean = centerMean;
    exports.centerMedian = centerMedian;
    exports.standardDeviationalEllipse = standardDeviationalEllipse;
    exports.angle = angle;
    exports.polygonSmooth = polygonSmooth;
    exports.moranIndex = index$6;
    exports.distanceWeight = distanceWeight;
    exports.difference = difference$1;
    exports.union = union$1;
    exports.intersect = intersect$2;
    exports.dissolve = dissolve;
    exports.hexGrid = hexGrid;
    exports.mask = mask;
    exports.squareGrid = squareGrid;
    exports.triangleGrid = triangleGrid;
    exports.interpolate = interpolate;
    exports.buffer = buffer;
    exports.pointOnSurface = pointOnFeature;
    exports.polygonToLineString = polygonToLine;
    exports.lineStringToPolygon = lineToPolygon;
    exports.inside = booleanPointInPolygon;
    exports.within = pointsWithinPolygon;
    exports.bezier = bezier;
    exports.nearest = nearestPoint;
    exports.pointOnLine = nearestPointOnLine;
    exports.lineDistance = length$1;
    exports.radians2degrees = radiansToDegrees;
    exports.degrees2radians = degreesToRadians;
    exports.distanceToDegrees = lengthToDegrees;
    exports.distanceToRadians = lengthToRadians;
    exports.radiansToDistance = radiansToLength;
    exports.bearingToAngle = bearingToAzimuth;
    exports.convertDistance = convertLength;
    exports.toMercator = toMercator;
    exports.toWgs84 = toWgs84;
    exports.randomPosition = randomPosition;
    exports.randomPoint = randomPoint;
    exports.randomPolygon = randomPolygon;
    exports.randomLineString = randomLineString;
    exports.getCluster = getCluster;
    exports.clusterEach = clusterEach;
    exports.clusterReduce = clusterReduce;
    exports.createBins = createBins;
    exports.applyFilter = applyFilter;
    exports.propertiesContainsFilter = propertiesContainsFilter;
    exports.filterProperties = filterProperties;
    exports.earthRadius = earthRadius;
    exports.factors = factors;
    exports.areaFactors = areaFactors;
    exports.feature = feature;
    exports.geometry = geometry;
    exports.point = point;
    exports.points = points;
    exports.polygon = polygon;
    exports.polygons = polygons;
    exports.lineString = lineString;
    exports.lineStrings = lineStrings;
    exports.featureCollection = featureCollection;
    exports.multiLineString = multiLineString;
    exports.multiPoint = multiPoint;
    exports.multiPolygon = multiPolygon;
    exports.geometryCollection = geometryCollection;
    exports.round = round;
    exports.radiansToLength = radiansToLength;
    exports.lengthToRadians = lengthToRadians;
    exports.lengthToDegrees = lengthToDegrees;
    exports.bearingToAzimuth = bearingToAzimuth;
    exports.radiansToDegrees = radiansToDegrees;
    exports.degreesToRadians = degreesToRadians;
    exports.convertLength = convertLength;
    exports.convertArea = convertArea;
    exports.isNumber = isNumber;
    exports.isObject = isObject;
    exports.validateBBox = validateBBox;
    exports.validateId = validateId;
    exports.checkIfOptionsExist = checkIfOptionsExist;
    exports.getCoord = getCoord;
    exports.getCoords = getCoords;
    exports.containsNumber = containsNumber;
    exports.geojsonType = geojsonType;
    exports.featureOf = featureOf;
    exports.collectionOf = collectionOf;
    exports.getGeom = getGeom;
    exports.getType = getType;
    exports.coordEach = coordEach;
    exports.coordReduce = coordReduce;
    exports.propEach = propEach;
    exports.propReduce = propReduce;
    exports.featureEach = featureEach;
    exports.featureReduce = featureReduce;
    exports.coordAll = coordAll;
    exports.geomEach = geomEach;
    exports.geomReduce = geomReduce;
    exports.flattenEach = flattenEach;
    exports.flattenReduce = flattenReduce;
    exports.segmentEach = segmentEach;
    exports.segmentReduce = segmentReduce;
    exports.lineEach = lineEach;
    exports.lineReduce = lineReduce;
    exports.findSegment = findSegment;
    exports.findPoint = findPoint;

    Object.defineProperty(exports, '__esModule', { value: true });

})));

/**
 * 
 * this is for test
 * 
 */

const PI = Math.PI / 180;
const R = 6378137;
const MINLENGTH = 1;

function formatLineArray(polyline) {
    const lnglats = polyline.getCoordinates();
    return lnglats.map(lnglat => {
        return lnglat.toArray();
    })
}

function degreesToRadians(d) {
    return d * PI;
}

function distance(c1, c2) {
    if (!c1 || !c2) {
        return 0;
    }
    if (!Array.isArray(c1)) {
        c1 = c1.toArray();
    }
    if (!Array.isArray(c2)) {
        c2 = c2.toArray();
    }
    let b = degreesToRadians(c1[1]);
    const d = degreesToRadians(c2[1]),
        e = b - d,
        f = degreesToRadians(c1[0]) - degreesToRadians(c2[0]);
    b = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(e / 2), 2) + Math.cos(b) * Math.cos(d) * Math.pow(Math.sin(f / 2), 2)));
    b *= R;
    return Math.round(b * 1E5) / 1E5;
}

function lineLength(polyline) {
    const lnglatArray = formatLineArray(polyline);
    let l = 0;
    for (let i = 0, len = lnglatArray.length; i < len - 1; i++) {
        l += distance(lnglatArray[i], lnglatArray[i + 1]);
    }
    return l;
}

function getLngLatKey(lnglat) {
    if (!Array.isArray(lnglat)) {
        lnglat = lnglat.toArray();
    }
    return lnglat.join('-').toString();
}

function getPercentLngLat(l, length) {
    const { len, c1, c2 } = l;
    const dx = c2[0] - c1[0],
        dy = c2[1] - c1[1],
        dh = (c2[2] || 0) - (c1[2] || 0);
    const percent = length / len;
    const lng = c1[0] + percent * dx;
    const lat = c1[1] + percent * dy;
    const h = (c1[2] || 0) + percent * dh;
    return [lng, lat, h];
}

function lineSlice(cs, lineChunkLength = 10) {
    lineChunkLength = Math.max(lineChunkLength, MINLENGTH);
    if (!Array.isArray(cs)) {
        cs = formatLineArray(cs);
    }
    const LEN = cs.length;
    let list = [];
    let totalLen = 0;
    for (let i = 0; i < LEN - 1; i++) {
        const len = distance(cs[i], cs[i + 1]);
        const floorlen = Math.floor(len);
        list.push({
            c1: cs[i],
            len: floorlen,
            c2: cs[i + 1]
        });
        totalLen += floorlen;
    }
    if (totalLen <= lineChunkLength) {
        const lnglats = list.map(d => {
            return [d.c1, d.c2];
        });
        return lnglats;
    }
    if (list.length === 1) {
        if (list[0].len <= lineChunkLength) {
            return [
                [list[0].c1, list[0].c2]
            ]
        }
    }
    const LNGLATSLEN = list.length;
    const first = list[0];
    // const last = list[list.length - 1];
    let idx = 0;
    let currentLngLat;
    let currentLen = 0;
    const lines = [];
    let lls = [first.c1];
    while (idx < LNGLATSLEN) {
        const { len, c2 } = list[idx];
        currentLen += len;
        if (currentLen < lineChunkLength) {
            lls.push(c2);
            if (idx === LNGLATSLEN - 1) {
                lines.push(lls);
            }
            idx++;
        }
        if (currentLen == lineChunkLength) {
            lls.push(c2);
            currentLen = 0;
            lines.push(lls);
            //next
            lls = [c2];
            idx++;
        }
        if (currentLen > lineChunkLength) {
            const offsetLen = (len - currentLen + lineChunkLength);
            currentLngLat = getPercentLngLat(list[idx], offsetLen);
            lls.push(currentLngLat);
            lines.push(lls);
            currentLen = 0;
            list[idx].c1 = currentLngLat;
            list[idx].len = len - offsetLen;
            //next
            lls = [];
            lls.push(currentLngLat);
        }
    }
    return lines;
}


function getLinePosition(lineString, layer, cenerter) {
    const positions = [];
    const positionsV = [];
    if (Array.isArray(lineString) && lineString[0] instanceof THREE.Vector3) {
        for (let i = 0, len = lineString.length; i < len; i++) {
            const v = lineString[i];
            positions.push(v.x, v.y, v.z);
            positionsV.push(v);
        }
    } else {
        if (Array.isArray(lineString)) lineString = new maptalks.LineString(lineString);
        if (!lineString || !(lineString instanceof maptalks.LineString)) return;
        const z = 0;
        const coordinates = lineString.getCoordinates();
        const centerPt = layer.coordinateToVector3(cenerter || lineString.getCenter());
        for (let i = 0, len = coordinates.length; i < len; i++) {
            let coordinate = coordinates[i];
            if (Array.isArray(coordinate)) {
                coordinate = new maptalks.Coordinate(coordinate);
            }
            const v = layer.coordinateToVector3(coordinate, z).sub(centerPt);
            positions.push(v.x, v.y, v.z);
            positionsV.push(v);
        }
    }
    return {
        positions: positions,
        positionsV: positionsV
    }
}


function getChunkLinesPosition(chunkLines, layer, positionMap, cenerPt) {
    const positions = [],
        positionsV = [], lnglats = [];
    for (let i = 0, len = chunkLines.length; i < len; i++) {
        const line = chunkLines[i];
        for (let j = 0, len1 = line.length; j < len1; j++) {
            const lnglat = line[j];
            if (lnglats.length > 0) {
                const key = lnglat.join(',').toString();
                const key1 = lnglats[lnglats.length - 1].join(',').toString();
                if (key !== key1) {
                    lnglats.push(lnglat);
                }
            } else {
                lnglats.push(lnglat);
            }
        }
    }
    const z = 0;
    lnglats.forEach(lnglat => {
        let v;
        const key = lnglat.join(',').toString();
        if (positionMap && positionMap[key]) {
            v = positionMap[key];
        } else {
            v = layer.coordinateToVector3(lnglat, z).sub(centerPt);
        }
        positionsV.push(v);
        positions.push(v.x, v.y, v.z);
    });
    return {
        positions: positions,
        positionsV: positionsV,
        lnglats: lnglats
    };
}


function setLineGeometryAttribute(geometry, ps) {
    const len = ps.length;
    var positions = geometry.attributes.position.array;
    for (let i = 0; i < len; i++) {
        positions[i] = ps[i];
    }
    geometry.setDrawRange(0, len / 3);
}




function _getLinePosition(lineString, layer) {
    const positions = [];
    const positionsV = [];
    if (Array.isArray(lineString) && lineString[0] instanceof THREE.Vector3) {
        for (let i = 0, len = lineString.length; i < len; i++) {
            const v = lineString[i];
            positions.push(v.x, v.y, v.z);
            positionsV.push(v);
        }
    } else {
        if (Array.isArray(lineString)) lineString = new maptalks.LineString(lineString);
        if (!lineString || !(lineString instanceof maptalks.LineString)) return;
        const z = 0;
        const coordinates = lineString.getCoordinates();
        for (let i = 0, len = coordinates.length; i < len; i++) {
            let coordinate = coordinates[i];
            if (Array.isArray(coordinate))
                coordinate = new maptalks.Coordinate(coordinate);
            const v = layer.coordinateToVector3(coordinate, z);
            positions.push(v.x, v.y, v.z);
            positionsV.push(v);
        }
    }
    return {
        positions: positions,
        positionsV: positionsV
    }
}



function _getChunkLinesPosition(chunkLines, layer) {
    const positions = [],
        positionsV = [], lnglats = [];
    for (let i = 0, len = chunkLines.length; i < len; i++) {
        const line = chunkLines[i];
        for (let j = 0, len1 = line.length; j < len1; j++) {
            const lnglat = line[j];
            if (lnglats.length > 0) {
                const key = lnglat.join(',').toString();
                const key1 = lnglats[lnglats.length - 1].join(',').toString();
                if (key !== key1) {
                    lnglats.push(lnglat);
                }
            } else {
                lnglats.push(lnglat);
            }
        }
    }
    let z = 0;
    lnglats.forEach(lnglat => {
        const h = lnglat[2];
        if (h) {
            z = layer.distanceToVector3(h, h).x;
        }
        const v = layer.coordinateToVector3(lnglat, z);
        positionsV.push(v);
        positions.push(v.x, v.y, v.z);
    });
    return {
        positions: positions,
        positionsV: positionsV,
        lnglats: lnglats
    };
}!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).earcut=e()}}(function(){return function i(u,f,o){function v(n,e){if(!f[n]){if(!u[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(y)return y(n,!0);var r=new Error("Cannot find module '"+n+"'");throw r.code="MODULE_NOT_FOUND",r}var x=f[n]={exports:{}};u[n][0].call(x.exports,function(e){return v(u[n][1][e]||e)},x,x.exports,i,u,f,o)}return f[n].exports}for(var y="function"==typeof require&&require,e=0;e<o.length;e++)v(o[e]);return v}({1:[function(e,n,t){"use strict";function r(e,n,t){t=t||2;var r,x,i,u,f,o,v,y=n&&n.length,p=y?n[0]*t:e.length,a=s(e,0,p,t,!0),l=[];if(!a||a.next===a.prev)return l;if(y&&(a=function(e,n,t,r){var x,i,u,f,o,v=[];for(x=0,i=n.length;x<i;x++)u=n[x]*r,f=x<i-1?n[x+1]*r:e.length,(o=s(e,u,f,r,!1))===o.next&&(o.steiner=!0),v.push(M(o));for(v.sort(Z),x=0;x<v.length;x++)g(v[x],t),t=c(t,t.next);return t}(e,n,a,t)),e.length>80*t){r=i=e[0],x=u=e[1];for(var h=t;h<p;h+=t)(f=e[h])<r&&(r=f),(o=e[h+1])<x&&(x=o),i<f&&(i=f),u<o&&(u=o);v=0!==(v=Math.max(i-r,u-x))?1/v:0}return d(a,l,t,r,x,v),l}function s(e,n,t,r,x){var i,u;if(x===0<D(e,n,t,r))for(i=n;i<t;i+=r)u=f(i,e[i],e[i+1],u);else for(i=t-r;n<=i;i-=r)u=f(i,e[i],e[i+1],u);return u&&h(u,u.next)&&(k(u),u=u.next),u}function c(e,n){if(!e)return e;n=n||e;var t,r=e;do{if(t=!1,r.steiner||!h(r,r.next)&&0!==m(r.prev,r,r.next))r=r.next;else{if(k(r),(r=n=r.prev)===r.next)break;t=!0}}while(t||r!==n);return n}function d(e,n,t,r,x,i,u){if(e){!u&&i&&function(e,n,t,r){var x=e;for(;null===x.z&&(x.z=w(x.x,x.y,n,t,r)),x.prevZ=x.prev,x.nextZ=x.next,x=x.next,x!==e;);x.prevZ.nextZ=null,x.prevZ=null,function(e){var n,t,r,x,i,u,f,o,v=1;do{for(t=e,i=e=null,u=0;t;){for(u++,r=t,n=f=0;n<v&&(f++,r=r.nextZ);n++);for(o=v;0<f||0<o&&r;)0!==f&&(0===o||!r||t.z<=r.z)?(t=(x=t).nextZ,f--):(r=(x=r).nextZ,o--),i?i.nextZ=x:e=x,x.prevZ=i,i=x;t=r}i.nextZ=null,v*=2}while(1<u)}(x)}(e,r,x,i);for(var f,o,v=e;e.prev!==e.next;)if(f=e.prev,o=e.next,i?p(e,r,x,i):y(e))n.push(f.i/t),n.push(e.i/t),n.push(o.i/t),k(e),e=o.next,v=o.next;else if((e=o)===v){u?1===u?d(e=a(c(e),n,t),n,t,r,x,i,2):2===u&&l(e,n,t,r,x,i):d(c(e),n,t,r,x,i,1);break}}}function y(e){var n=e.prev,t=e,r=e.next;if(0<=m(n,t,r))return!1;for(var x=e.next.next;x!==e.prev;){if(b(n.x,n.y,t.x,t.y,r.x,r.y,x.x,x.y)&&0<=m(x.prev,x,x.next))return!1;x=x.next}return!0}function p(e,n,t,r){var x=e.prev,i=e,u=e.next;if(0<=m(x,i,u))return!1;for(var f=x.x<i.x?x.x<u.x?x.x:u.x:i.x<u.x?i.x:u.x,o=x.y<i.y?x.y<u.y?x.y:u.y:i.y<u.y?i.y:u.y,v=x.x>i.x?x.x>u.x?x.x:u.x:i.x>u.x?i.x:u.x,y=x.y>i.y?x.y>u.y?x.y:u.y:i.y>u.y?i.y:u.y,p=w(f,o,n,t,r),a=w(v,y,n,t,r),l=e.prevZ,h=e.nextZ;l&&l.z>=p&&h&&h.z<=a;){if(l!==e.prev&&l!==e.next&&b(x.x,x.y,i.x,i.y,u.x,u.y,l.x,l.y)&&0<=m(l.prev,l,l.next))return!1;if(l=l.prevZ,h!==e.prev&&h!==e.next&&b(x.x,x.y,i.x,i.y,u.x,u.y,h.x,h.y)&&0<=m(h.prev,h,h.next))return!1;h=h.nextZ}for(;l&&l.z>=p;){if(l!==e.prev&&l!==e.next&&b(x.x,x.y,i.x,i.y,u.x,u.y,l.x,l.y)&&0<=m(l.prev,l,l.next))return!1;l=l.prevZ}for(;h&&h.z<=a;){if(h!==e.prev&&h!==e.next&&b(x.x,x.y,i.x,i.y,u.x,u.y,h.x,h.y)&&0<=m(h.prev,h,h.next))return!1;h=h.nextZ}return!0}function a(e,n,t){var r=e;do{var x=r.prev,i=r.next.next;!h(x,i)&&z(x,r,r.next,i)&&q(x,i)&&q(i,x)&&(n.push(x.i/t),n.push(r.i/t),n.push(i.i/t),k(r),k(r.next),r=e=i),r=r.next}while(r!==e);return c(r)}function l(e,n,t,r,x,i){var u,f,o=e;do{for(var v=o.next.next;v!==o.prev;){if(o.i!==v.i&&(f=v,(u=o).next.i!==f.i&&u.prev.i!==f.i&&!function(e,n){var t=e;do{if(t.i!==e.i&&t.next.i!==e.i&&t.i!==n.i&&t.next.i!==n.i&&z(t,t.next,e,n))return!0;t=t.next}while(t!==e);return!1}(u,f)&&(q(u,f)&&q(f,u)&&function(e,n){var t=e,r=!1,x=(e.x+n.x)/2,i=(e.y+n.y)/2;for(;t.y>i!=t.next.y>i&&t.next.y!==t.y&&x<(t.next.x-t.x)*(i-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next,t!==e;);return r}(u,f)&&(m(u.prev,u,f.prev)||m(u,f.prev,f))||h(u,f)&&0<m(u.prev,u,u.next)&&0<m(f.prev,f,f.next)))){var y=O(o,v);return o=c(o,o.next),y=c(y,y.next),d(o,n,t,r,x,i),void d(y,n,t,r,x,i)}v=v.next}o=o.next}while(o!==e)}function Z(e,n){return e.x-n.x}function g(e,n){if(n=function(e,n){var t,r=n,x=e.x,i=e.y,u=-1/0;do{if(i<=r.y&&i>=r.next.y&&r.next.y!==r.y){var f=r.x+(i-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=x&&u<f){if((u=f)===x){if(i===r.y)return r;if(i===r.next.y)return r.next}t=r.x<r.next.x?r:r.next}}r=r.next}while(r!==n);if(!t)return null;if(x===u)return t;var o,v=t,y=t.x,p=t.y,a=1/0;r=t;for(;x>=r.x&&r.x>=y&&x!==r.x&&b(i<p?x:u,i,y,p,i<p?u:x,i,r.x,r.y)&&(o=Math.abs(i-r.y)/(x-r.x),q(r,e)&&(o<a||o===a&&(r.x>t.x||r.x===t.x&&(h=r,m((l=t).prev,l,h.prev)<0&&m(h.next,l,l.next)<0)))&&(t=r,a=o)),r=r.next,r!==v;);var l,h;return t}(e,n)){var t=O(n,e);c(t,t.next)}}function w(e,n,t,r,x){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-t)*x)|e<<8))|e<<4))|e<<2))|e<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-r)*x)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function M(e){for(var n=e,t=e;(n.x<t.x||n.x===t.x&&n.y<t.y)&&(t=n),(n=n.next)!==e;);return t}function b(e,n,t,r,x,i,u,f){return 0<=(x-u)*(n-f)-(e-u)*(i-f)&&0<=(e-u)*(r-f)-(t-u)*(n-f)&&0<=(t-u)*(i-f)-(x-u)*(r-f)}function m(e,n,t){return(n.y-e.y)*(t.x-n.x)-(n.x-e.x)*(t.y-n.y)}function h(e,n){return e.x===n.x&&e.y===n.y}function z(e,n,t,r){var x=v(m(e,n,t)),i=v(m(e,n,r)),u=v(m(t,r,e)),f=v(m(t,r,n));return x!==i&&u!==f||(!(0!==x||!o(e,t,n))||(!(0!==i||!o(e,r,n))||(!(0!==u||!o(t,e,r))||!(0!==f||!o(t,n,r)))))}function o(e,n,t){return n.x<=Math.max(e.x,t.x)&&n.x>=Math.min(e.x,t.x)&&n.y<=Math.max(e.y,t.y)&&n.y>=Math.min(e.y,t.y)}function v(e){return 0<e?1:e<0?-1:0}function q(e,n){return m(e.prev,e,e.next)<0?0<=m(e,n,e.next)&&0<=m(e,e.prev,n):m(e,n,e.prev)<0||m(e,e.next,n)<0}function O(e,n){var t=new u(e.i,e.x,e.y),r=new u(n.i,n.x,n.y),x=e.next,i=n.prev;return(e.next=n).prev=e,(t.next=x).prev=t,(r.next=t).prev=r,(i.next=r).prev=i,r}function f(e,n,t,r){var x=new u(e,n,t);return r?(x.next=r.next,(x.prev=r).next.prev=x,r.next=x):(x.prev=x).next=x,x}function k(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function u(e,n,t){this.i=e,this.x=n,this.y=t,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function D(e,n,t,r){for(var x=0,i=n,u=t-r;i<t;i+=r)x+=(e[u]-e[i])*(e[i+1]+e[u+1]),u=i;return x}n.exports=r,(n.exports.default=r).deviation=function(e,n,t,r){var x=n&&n.length,i=x?n[0]*t:e.length,u=Math.abs(D(e,0,i,t));if(x)for(var f=0,o=n.length;f<o;f++){var v=n[f]*t,y=f<o-1?n[f+1]*t:e.length;u-=Math.abs(D(e,v,y,t))}var p=0;for(f=0;f<r.length;f+=3){var a=r[f]*t,l=r[f+1]*t,h=r[f+2]*t;p+=Math.abs((e[a]-e[h])*(e[1+l]-e[1+a])-(e[a]-e[l])*(e[1+h]-e[1+a]))}return 0===u&&0===p?0:Math.abs((p-u)/u)},r.flatten=function(e){for(var n=e[0][0].length,t={vertices:[],holes:[],dimensions:n},r=0,x=0;x<e.length;x++){for(var i=0;i<e[x].length;i++)for(var u=0;u<n;u++)t.vertices.push(e[x][i][u]);0<x&&(r+=e[x-1].length,t.holes.push(r))}return t}},{}]},{},[1])(1)});
// stats.js - http://github.com/mrdoob/stats.js
var Stats=function(){function h(a){c.appendChild(a.dom);return a}function k(a){for(var d=0;d<c.children.length;d++)c.children[d].style.display=d===a?"block":"none";l=a}var l=0,c=document.createElement("div");c.style.cssText="position:fixed;top:0;left:0;cursor:pointer;opacity:0.9;z-index:10000";c.addEventListener("click",function(a){a.preventDefault();k(++l%c.children.length)},!1);var g=(performance||Date).now(),e=g,a=0,r=h(new Stats.Panel("FPS","#0ff","#002")),f=h(new Stats.Panel("MS","#0f0","#020"));
if(self.performance&&self.performance.memory)var t=h(new Stats.Panel("MB","#f08","#201"));k(0);return{REVISION:16,dom:c,addPanel:h,showPanel:k,begin:function(){g=(performance||Date).now()},end:function(){a++;var c=(performance||Date).now();f.update(c-g,200);if(c>e+1E3&&(r.update(1E3*a/(c-e),100),e=c,a=0,t)){var d=performance.memory;t.update(d.usedJSHeapSize/1048576,d.jsHeapSizeLimit/1048576)}return c},update:function(){g=this.end()},domElement:c,setMode:k}};
Stats.Panel=function(h,k,l){var c=Infinity,g=0,e=Math.round,a=e(window.devicePixelRatio||1),r=80*a,f=48*a,t=3*a,u=2*a,d=3*a,m=15*a,n=74*a,p=30*a,q=document.createElement("canvas");q.width=r;q.height=f;q.style.cssText="width:80px;height:48px";var b=q.getContext("2d");b.font="bold "+9*a+"px Helvetica,Arial,sans-serif";b.textBaseline="top";b.fillStyle=l;b.fillRect(0,0,r,f);b.fillStyle=k;b.fillText(h,t,u);b.fillRect(d,m,n,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d,m,n,p);return{dom:q,update:function(f,
v){c=Math.min(c,f);g=Math.max(g,f);b.fillStyle=l;b.globalAlpha=1;b.fillRect(0,0,r,m);b.fillStyle=k;b.fillText(e(f)+" "+h+" ("+e(c)+"-"+e(g)+")",t,u);b.drawImage(q,d+a,m,n-a,p,d,m,n-a,p);b.fillRect(d+n-a,m,a,p);b.fillStyle=l;b.globalAlpha=.9;b.fillRect(d+n-a,m,a,e((1-f/v)*p))}}};"object"===typeof module&&(module.exports=Stats);
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks")):"function"==typeof define&&define.amd?define(["exports","maptalks"],e):e(t.maptalks=t.maptalks||{},t.maptalks)}(this,function(t,e){"use strict";function i(t,e){for(var i=Object.getOwnPropertyNames(e),a=0;a<i.length;a++){var r=i[a],n=Object.getOwnPropertyDescriptor(e,r);n&&n.configurable&&void 0===t[r]&&Object.defineProperty(t,r,n)}return t}function a(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function r(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):i(t,e))}var o=function(t,e){return e={exports:{}},t(e,e.exports),e.exports}(function(t){function e(t){if(!(this instanceof e))return new e(t);this._canvas=t="string"==typeof t?document.getElementById(t):t,this._ctx=t.getContext("2d"),this._width=t.width,this._height=t.height,this._max=1,this._data=[]}t.exports=e,e.prototype={defaultRadius:25,defaultGradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},data:function(t){return this._data=t,this},max:function(t){return this._max=t,this},add:function(t){return this._data.push(t),this},clear:function(){return this._data=[],this},radius:function(t,e){e=void 0===e?15:e;var i=this._circle=this._createCanvas(),a=i.getContext("2d"),r=this._r=t+e;return i.width=i.height=2*r,a.shadowOffsetX=a.shadowOffsetY=2*r,a.shadowBlur=e,a.shadowColor="black",a.beginPath(),a.arc(-r,-r,t,0,2*Math.PI,!0),a.closePath(),a.fill(),this},resize:function(){this._width=this._canvas.width,this._height=this._canvas.height},gradient:function(t){var e=this._createCanvas(),i=e.getContext("2d"),a=i.createLinearGradient(0,0,0,256);e.width=1,e.height=256;for(var r in t)a.addColorStop(+r,t[r]);return i.fillStyle=a,i.fillRect(0,0,1,256),this._grad=i.getImageData(0,0,1,256).data,this},draw:function(t){this._circle||this.radius(this.defaultRadius),this._grad||this.gradient(this.defaultGradient);var e=this._ctx;e.clearRect(0,0,this._width,this._height);for(var i,a=0,r=this._data.length;a<r;a++)i=this._data[a],e.globalAlpha=Math.max(i[2]/this._max,void 0===t?.05:t),e.drawImage(this._circle,i[0]-this._r,i[1]-this._r);var n=e.getImageData(0,0,this._width,this._height);return this._colorize(n.data,this._grad),e.putImageData(n,0,0),this},_colorize:function(t,e){for(var i,a=0,r=t.length;a<r;a+=4)(i=4*t[a+3])&&(t[a]=e[i],t[a+1]=e[i+1],t[a+2]=e[i+2])},_createCanvas:function(){return"undefined"!=typeof document?document.createElement("canvas"):new this._canvas.constructor}}}),s={max:1,gradient:{.4:"blue",.6:"cyan",.7:"lime",.8:"yellow",1:"red"},radius:25,blur:15,heatValueScale:1,minOpacity:.05},h=function(t){function i(e,n,o){a(this,i),Array.isArray(n)||(o=n,n=null);var s=r(this,t.call(this,e,o));return s._heats=n||[],s}return n(i,t),i.prototype.getData=function(){return this._heats},i.prototype.setData=function(t){return this._heats=t||[],this.redraw()},i.prototype.addPoint=function(t){return t?(t[0]&&Array.isArray(t[0])?e.Util.pushIn(this._heats,t):this._heats.push(t),this.redraw()):this},i.prototype.onConfig=function(t){for(var e in t)if(s[e])return this.redraw();return this},i.prototype.redraw=function(){var t=this._getRenderer();return t&&(t.clearHeatCache(),t.setToRedraw()),this},i.prototype.isEmpty=function(){return!this._heats.length},i.prototype.clear=function(){return this._heats=[],this.redraw(),this.fire("clear"),this},i.prototype.toJSON=function(t){t||(t={});var i={type:this.getJSONType(),id:this.getId(),options:this.config()},a=this.getData();if(t.clipExtent){var r=new e.Extent(t.clipExtent),n=this._getHeatRadius();n&&(r=r._expand(n));for(var o=[],s=0,h=a.length;s<h;s++)r.contains(new e.Coordinate(a[s][0],a[s][1]))&&o.push(a[s]);i.data=o}else i.data=a;return i},i.fromJSON=function(t){return t&&"HeatLayer"===t.type?new i(t.id,t.data,t.options):null},i.prototype._getHeatRadius=function(){return this._getRenderer()?this._getRenderer()._heatRadius:null},i}(e.Layer);h.mergeOptions(s),h.registerJSONType("HeatLayer"),h.registerRenderer("canvas",function(t){function i(){return a(this,i),r(this,t.apply(this,arguments))}return n(i,t),i.prototype.draw=function(){var t=this.getMap(),e=this.layer,i=t.getContainerExtent(),a=this.prepareCanvas(),r=i;if(a){if(!(a=a.convertTo(function(e){return t._pointToContainerPoint(e)})).intersects(i))return void this.completeRender();r=i.intersection(a)}this._heater||(this._heater=o(this.canvas)),this._heater.radius(e.options.radius||this._heater.defaultRadius,e.options.blur),e.options.gradient&&this._heater.gradient(e.options.gradient),this._heater.max(e.options.max),this._heatViews||(this._heatViews=[]);var n=e.getData();if(0!==n.length){var s=this._heatData(n,r);this._heater.data(s).draw(e.options.minOpacity),this.completeRender()}else this.completeRender()},i.prototype.drawOnInteracting=function(){this.draw()},i.prototype._heatData=function(t,i){var a=this.getMap(),r=this.layer,n=a.getProjection(),o=[],s=this._heater._r,h=void 0===r.options.max?1:r.options.max,c=s/2,u=[],d=a.offsetPlatform(),p=d.x%c,f=d.y%c,l=void 0,_=void 0,y=void 0,g=void 0,v=void 0,w=void 0;i=i.expand(s).convertTo(function(t){return new e.Point(a._containerPointToPrj(t))}),this._heatRadius=s;for(var m=0,x=t.length;m<x;m++)l=t[m],this._heatViews[m]||(this._heatViews[m]=n.project(new e.Coordinate(l[0],l[1]))),_=this._heatViews[m],i.contains(_)&&(_=a._prjToContainerPoint(_),g=Math.floor((_.x-p)/c)+2,v=Math.floor((_.y-f)/c)+2,w=(void 0!==l[2]?+l[2]:.1)*r.options.heatValueScale,u[v]=u[v]||[],(y=u[v][g])?(y[0]=(y[0]*y[2]+_.x*w)/(y[2]+w),y[1]=(y[1]*y[2]+_.y*w)/(y[2]+w),y[2]+=w):u[v][g]=[_.x,_.y,w]);for(var b=0,R=u.length;b<R;b++)if(u[b])for(var O=0,C=u[b].length;O<C;O++)(y=u[b][O])&&o.push([Math.round(y[0]),Math.round(y[1]),Math.min(y[2],h)]);return o},i.prototype.onZoomEnd=function(){delete this._heatViews,t.prototype.onZoomEnd.apply(this,arguments)},i.prototype.onResize=function(){t.prototype.onResize.apply(this,arguments),this.canvas&&(this._heater._width=this.canvas.width,this._heater._height=this.canvas.height)},i.prototype.onRemove=function(){this.clearHeatCache(),delete this._heater},i.prototype.clearHeatCache=function(){delete this._heatViews},i}(e.renderer.CanvasRenderer)),t.HeatLayer=h,Object.defineProperty(t,"__esModule",{value:!0}),"undefined"!=typeof console});function HashMap(){this.elements=new Array,this.size=function(){return this.elements.length},this.isEmpty=function(){return this.elements.length<1},this.clear=function(){this.elements=new Array},this.put=function(t,s){1==this.containsKey(t)&&this.containsValue(s)&&1!=this.remove(t)||this.elements.push({key:t,value:s})},this.remove=function(t){var s=!1;try{for(i=0;i<this.elements.length;i++)if(this.elements[i].key==t)return this.elements.splice(i,1),!0}catch(t){s=!1}return s},this.get=function(t){try{for(i=0;i<this.elements.length;i++)if(this.elements[i].key==t)return this.elements[i].value}catch(t){return null}},this.element=function(t){return t<0||t>=this.elements.length?null:this.elements[t]},this.containsKey=function(t){var s=!1;try{for(i=0;i<this.elements.length;i++)this.elements[i].key==t&&(s=!0)}catch(t){s=!1}return s},this.containsValue=function(t){var s=!1;try{for(i=0;i<this.elements.length;i++)this.elements[i].value==t&&(s=!0)}catch(t){s=!1}return s},this.keys=function(){var t=new Array;for(i=0;i<this.elements.length;i++)t.push(this.elements[i].key);return t},this.values=function(){var t=new Array;for(i=0;i<this.elements.length;i++)t.push(this.elements[i].value);return t},this.toString=function(){var t="";for(i=0;i<this.elements.length;i++)t+=this.elements[i].value+"&nbsp;&nbsp;";return t}}!function(){var t={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",prefix:""},s="webkit moz o ms khtml".split(" ");if(void 0!==document.exitFullscreen)t.supportsFullScreen=!0;else{for(var i=0,e=s.length;i<e;i++)if(t.prefix=s[i],void 0!==document[t.prefix+"CancelFullScreen"]){t.supportsFullScreen=!0;break}void 0!==document.msExitFullscreen&&(t.prefix="ms",t.supportsFullScreen=!0)}t.supportsFullScreen&&(t.fullScreenEventName="ms"===t.prefix?"MSFullscreenChange":t.prefix+"fullscreenchange",t.isFullScreen=function(){switch(this.prefix){case"":return document.fullscreen;case"webkit":return document.webkitIsFullScreen;case"ms":return document.msFullscreenElement;default:return document[this.prefix+"FullScreen"]}},t.requestFullScreen=function(t){try{switch(this.prefix){case"":return t.requestFullscreen();case"ms":return t.msRequestFullscreen();default:return t[this.prefix+"RequestFullScreen"]()}}catch(t){console.log(t)}},t.cancelFullScreen=function(){try{switch(this.prefix){case"":return document.exitFullscreen();case"ms":return document.msExitFullscreen();default:return document[this.prefix+"CancelFullScreen"]()}}catch(t){console.log(t)}}),window.fullScreenApi=t}(),!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).protoman=t()}(function(){var define,module,exports;return function e(n,a,h){function r(s,t){if(!a[s]){if(!n[s]){var i="function"==typeof require&&require;if(!t&&i)return i(s,!0);if(o)return o(s,!0);t=new Error("Cannot find module '"+s+"'");throw t.code="MODULE_NOT_FOUND",t}i=a[s]={exports:{}};n[s][0].call(i.exports,function(t){return r(n[s][1][t]||t)},i,i.exports,e,n,a,h)}return a[s].exports}for(var o="function"==typeof require&&require,t=0;t<h.length;t++)r(h[t]);return r}({1:[function(p,i,t){!function(t){function o(){}function e(t){return"function"==typeof t}function c(t){return Array.isArray(t)}var n="pending",a="fulfilled",h="rejected";function s(t){if(!e(t))throw new TypeError("resolver must be a function");this.state=n,this.value=void 0,this.queue=[],t!==o&&m(this,t)}function r(t,s,i){this.promise=t,this.callFulfilled=function(t){u(this.promise,t)},this.callRejected=function(t){f(this.promise,t)},e(s)&&(this.callFulfilled=function(t){l(this.promise,s,t)}),e(i)&&(this.callRejected=function(t){l(this.promise,i,t)})}function l(s,i,e){var n;try{t instanceof Function&&(n=t)}catch(t){n=p("immediate")}n.call(this,function(){var t;try{t=i(e)}catch(t){return f(s,t)}t===s?f(s,new TypeError("Cannot resolve promise with itself")):u(s,t)})}function u(t,s){try{var i=function(t){var s=t&&t.then;if(t&&("object"==typeof t||e(t))&&e(s))return function(){s.apply(t,arguments)}}(s);return i?m(t,i):(t.state=a,t.value=s,t.queue.forEach(function(t){t.callFulfilled(s)})),t}catch(i){return f(t,i)}}function f(t,s){return t.state=h,t.value=s,t.queue.forEach(function(t){t.callRejected(s)}),t}function m(s,t){var i=!1;try{t(function(t){i||(i=!0,u(s,t))},function(t){i||(i=!0,f(s,t))})}catch(t){i||(i=!0,f(s,t))}}(i.exports=s).prototype.then=function(t,s){var i;return!e(t)&&this.state===a||!e(s)&&this.state===h?this:(i=new this.constructor(o),this.state!==n?l(i,this.state===a?t:s,this.value):this.queue.push(new r(i,t,s)),i)},s.prototype.catch=function(t){return this.then(null,t)},s.resolve=function(t){return t instanceof this?t:u(new this(o),t)},s.reject=function(t){return f(new this(o),t)},s.all=function(t){var i=this;if(!c(t))return this.reject(new TypeError("must be an array"));var e=t.length,n=!1;if(!e)return this.resolve([]);for(var a=new Array(e),h=0,s=-1,r=new this(o);++s<e;)!function(t,s){i.resolve(t).then(function(t){a[s]=t,++h!==e||n||(n=!0,u(r,a))},function(t){n||(n=!0,f(r,t))})}(t[s],s);return r},s.race=function(t){if(!c(t))return this.reject(new TypeError("must be an array"));var s=t.length,i=!1;if(!s)return this.resolve([]);for(var e,n=-1,a=new this(o);++n<s;)e=t[n],this.resolve(e).then(function(t){i||(i=!0,u(a,t))},function(t){i||(i=!0,f(a,t))});return a}}.call(this,p("timers").setImmediate)},{immediate:4,timers:13}],2:[function(t,s,i){var u=Object.create||function(t){function s(){}return s.prototype=t,new s},h=Object.keys||function(t){var s,i=[];for(s in t)Object.prototype.hasOwnProperty.call(t,s)&&i.push(s);return s},e=Function.prototype.bind||function(t){var s=this;return function(){return s.apply(t,arguments)}};function n(){this._events&&Object.prototype.hasOwnProperty.call(this,"_events")||(this._events=u(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0}((s.exports=n).EventEmitter=n).prototype._events=void 0,n.prototype._maxListeners=void 0;var a,r=10;try{var o={};Object.defineProperty&&Object.defineProperty(o,"x",{value:0}),a=0===o.x}catch(t){a=!1}function c(t){return void 0===t._maxListeners?n.defaultMaxListeners:t._maxListeners}function l(t,s,i,e){var n,a;if("function"!=typeof i)throw new TypeError('"listener" argument must be a function');return(n=t._events)?(n.newListener&&(t.emit("newListener",s,i.listener||i),n=t._events),a=n[s]):(n=t._events=u(null),t._eventsCount=0),a?("function"==typeof a?a=n[s]=e?[i,a]:[a,i]:e?a.unshift(i):a.push(i),!a.warned&&(e=c(t))&&0<e&&a.length>e&&(a.warned=!0,(e=new Error("Possible EventEmitter memory leak detected. "+a.length+' "'+String(s)+'" listeners added. Use emitter.setMaxListeners() to increase limit.')).name="MaxListenersExceededWarning",e.emitter=t,e.type=s,e.count=a.length,"object"==typeof console)&&console.warn&&console.warn("%s: %s",e.name,e.message)):(a=n[s]=i,++t._eventsCount),t}function f(){if(!this.fired)switch(this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length){case 0:return this.listener.call(this.target);case 1:return this.listener.call(this.target,arguments[0]);case 2:return this.listener.call(this.target,arguments[0],arguments[1]);case 3:return this.listener.call(this.target,arguments[0],arguments[1],arguments[2]);default:for(var t=new Array(arguments.length),s=0;s<t.length;++s)t[s]=arguments[s];this.listener.apply(this.target,t)}}function m(t,s,i){t={fired:!1,wrapFn:void 0,target:t,type:s,listener:i},s=e.call(f,t);return s.listener=i,t.wrapFn=s}function p(t,s,i){t=t._events;if(t){t=t[s];if(t)if("function"==typeof t)return i?[t.listener||t]:[t];else if(i){var e=t;for(var n=new Array(e.length),a=0;a<n.length;++a)n[a]=e[a].listener||e[a];return n;return}else return U(t,t.length);else;}return[]}function d(t){var s=this._events;if(s){s=s[t];if("function"==typeof s)return 1;if(s)return s.length}return 0}function U(t,s){for(var i=new Array(s),e=0;e<s;++e)i[e]=t[e];return i}a?Object.defineProperty(n,"defaultMaxListeners",{enumerable:!0,get:function(){return r},set:function(t){if("number"!=typeof t||t<0||t!=t)throw new TypeError('"defaultMaxListeners" must be a positive number');r=t}}):n.defaultMaxListeners=r,n.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},n.prototype.getMaxListeners=function(){return c(this)},n.prototype.emit=function(t,s,i,L){var e,n,a,h,r,o,c="error"===t;if(o=this._events)c=c&&null==o.error;else if(!c)return!1;if(c){if((e=1<arguments.length?s:e)instanceof Error)throw e;c=new Error('Unhandled "error" event. ('+e+")");throw c.context=e,c}if(!(n=o[t]))return!1;var l="function"==typeof n;switch(a=arguments.length){case 1:var u=n,f=this;if(l)u.call(f);else for(var m=u.length,G=U(u,m),p=0;p<m;++p)G[p].call(f);break;case 2:var u=n,d=this,M=s;if(l)u.call(d,M);else for(var g=u.length,T=U(u,g),_=0;_<g;++_)T[_].call(d,M);break;case 3:var y=n,b=this,v=s,x=i;if(l)y.call(b,v,x);else for(var w=y.length,z=U(y,w),j=0;j<w;++j)z[j].call(b,v,x);break;case 4:var y=n,C=this,P=s,I=i,S=L;if(l)y.call(C,P,I,S);else for(var E=y.length,D=U(y,E),k=0;k<E;++k)D[k].call(C,P,I,S);break;default:for(h=new Array(a-1),r=1;r<a;r++)h[r-1]=arguments[r];var q=n,N=this,A=h;if(l)q.apply(N,A);else for(var F=q.length,R=U(q,F),O=0;O<F;++O)R[O].apply(N,A)}return!0},n.prototype.on=n.prototype.addListener=function(t,s){return l(this,t,s,!1)},n.prototype.prependListener=function(t,s){return l(this,t,s,!0)},n.prototype.once=function(t,s){if("function"!=typeof s)throw new TypeError('"listener" argument must be a function');return this.on(t,m(this,t,s)),this},n.prototype.prependOnceListener=function(t,s){if("function"!=typeof s)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,m(this,t,s)),this},n.prototype.removeListener=function(t,s){var i,e,n,a,h;if("function"!=typeof s)throw new TypeError('"listener" argument must be a function');if((e=this._events)&&(i=e[t]))if(i===s||i.listener===s)0==--this._eventsCount?this._events=u(null):(delete e[t],e.removeListener&&this.emit("removeListener",t,i.listener||s));else if("function"!=typeof i){for(n=-1,a=i.length-1;0<=a;a--)if(i[a]===s||i[a].listener===s){h=i[a].listener,n=a;break}if(n<0)return this;if(0===n)i.shift();else{var r=i;for(var o=n,c=o+1,l=r.length;c<l;o+=1,c+=1)r[o]=r[c];r.pop()}1===i.length&&(e[t]=i[0]),e.removeListener&&this.emit("removeListener",t,h||s)}return this},n.prototype.removeAllListeners=function(t){var s,i;if(i=this._events)if(i.removeListener){if(0===arguments.length){for(var e,n=h(i),a=0;a<n.length;++a)"removeListener"!==(e=n[a])&&this.removeAllListeners(e);this.removeAllListeners("removeListener"),this._events=u(null),this._eventsCount=0}else if("function"==typeof(s=i[t]))this.removeListener(t,s);else if(s)for(a=s.length-1;0<=a;a--)this.removeListener(t,s[a])}else 0===arguments.length?(this._events=u(null),this._eventsCount=0):i[t]&&(0==--this._eventsCount?this._events=u(null):delete i[t]);return this},n.prototype.listeners=function(t){return p(this,t,!0)},n.prototype.rawListeners=function(t){return p(this,t,!1)},n.listenerCount=function(t,s){return"function"==typeof t.listenerCount?t.listenerCount(s):d.call(t,s)},n.prototype.listenerCount=d,n.prototype.eventNames=function(){return 0<this._eventsCount?Reflect.ownKeys(this._events):[]}},{}],3:[function(t,i,s){!function(t){var s;"function"==typeof define&&define.amd?define([],t):"object"==typeof i?(s=i.exports=t()).HashMap=s:this.HashMap=t()}(function(){function e(t){switch(this.clear(),arguments.length){case 0:break;case 1:"length"in t?s(this,Array.prototype.concat.apply([],t)):this.copy(t);break;default:s(this,arguments)}}var i=e.prototype={constructor:e,get:function(t){t=this._data[this.hash(t)];return t&&t[1]},set:function(t,s){var i=this.hash(t);i in this._data||this.size++,this._data[i]=[t,s]},multi:function(){s(this,arguments)},copy:function(t){for(var s in t._data)s in this._data||this.size++,this._data[s]=t._data[s]},has:function(t){return this.hash(t)in this._data},search:function(t){for(var s in this._data)if(this._data[s][1]===t)return this._data[s][0];return null},delete:function(t){t=this.hash(t);t in this._data&&(this.size--,delete this._data[t])},type:function(t){var s=Object.prototype.toString.call(t).slice(8,-1).toLowerCase();return t||"domwindow"!==s&&"window"!==s?s:t+""},keys:function(){var i=[];return this.forEach(function(t,s){i.push(s)}),i},values:function(){var s=[];return this.forEach(function(t){s.push(t)}),s},entries:function(){var i=[];return this.forEach(function(t,s){i.push([s,t])}),i},count:function(){return this.size},clear:function(){this._data={},this.size=0},clone:function(){return new e(this)},hash:function(t){switch(this.type(t)){case"undefined":case"null":case"boolean":case"number":case"regexp":return t+"";case"date":return"♣"+t.getTime();case"string":return"♠"+t;case"array":for(var s=[],i=0;i<t.length;i++)s[i]=this.hash(t[i]);return"♥"+s.join("⁞");default:return t.hasOwnProperty("_hmuid_")||(t._hmuid_=++e.uid,Object.defineProperty&&Object.defineProperty(t,"_hmuid_",{enumerable:!1})),"♦"+t._hmuid_}},forEach:function(t,s){for(var i in this._data){i=this._data[i];t.call(s||this,i[1],i[0])}}};function s(t,s){for(var i=0;i<s.length;i+=2)t.set(s[i],s[i+1])}return e.uid=0,["set","multi","copy","delete","clear","forEach"].forEach(function(t){var s=i[t];i[t]=function(){return s.apply(this,arguments),this}}),e.prototype.remove=e.prototype.delete,e})},{}],4:[function(t,s,i){"use strict";var e,n,a,h=[t("./nextTick"),t("./mutation.js"),t("./messageChannel"),t("./stateChange"),t("./timeout")],r=-1,o=[],c=!1;function l(){e&&n&&(e=!1,n.length?o=n.concat(o):r=-1,o.length)&&u()}function u(){if(!e){e=!(c=!1);for(var t=o.length,s=setTimeout(l);t;){for(n=o,o=[];n&&++r<t;)n[r].run();r=-1,t=o.length}n=null,e=!(r=-1),clearTimeout(s)}}for(var f=-1,m=h.length;++f<m;)if(h[f]&&h[f].test&&h[f].test()){a=h[f].install(u);break}function p(t,s){this.fun=t,this.array=s}p.prototype.run=function(){var t=this.fun,s=this.array;switch(s.length){case 0:return t();case 1:return t(s[0]);case 2:return t(s[0],s[1]);case 3:return t(s[0],s[1],s[2]);default:return t.apply(null,s)}},s.exports=function(t){var s=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)s[i-1]=arguments[i];o.push(new p(t,s)),c||e||(c=!0,a())}},{"./messageChannel":5,"./mutation.js":6,"./nextTick":7,"./stateChange":8,"./timeout":9}],5:[function(t,s,e){!function(i){"use strict";e.test=function(){return!i.setImmediate&&void 0!==i.MessageChannel},e.install=function(t){var s=new i.MessageChannel;return s.port1.onmessage=t,function(){s.port2.postMessage(0)}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],6:[function(t,s,i){!function(e){"use strict";var n=e.MutationObserver||e.WebKitMutationObserver;i.test=function(){return n},i.install=function(t){var s=0,t=new n(t),i=e.document.createTextNode("");return t.observe(i,{characterData:!0}),function(){i.data=s=++s%2}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],7:[function(t,s,i){!function(s){"use strict";i.test=function(){return void 0!==s&&!s.browser},i.install=function(t){return function(){s.nextTick(t)}}}.call(this,t("_process"))},{_process:11}],8:[function(t,s,e){!function(i){"use strict";e.test=function(){return"document"in i&&"onreadystatechange"in i.document.createElement("script")},e.install=function(s){return function(){var t=i.document.createElement("script");return t.onreadystatechange=function(){s(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},i.document.documentElement.appendChild(t),s}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(t,s,i){"use strict";i.test=function(){return!0},i.install=function(t){return function(){setTimeout(t,0)}}},{}],10:[function(t,s,i){"function"==typeof Object.create?s.exports=function(t,s){s&&(t.super_=s,t.prototype=Object.create(s.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:s.exports=function(t,s){function i(){}s&&(t.super_=s,i.prototype=s.prototype,t.prototype=new i,t.prototype.constructor=t)}},{}],11:[function(t,s,i){var e,n,s=s.exports={};function a(){throw new Error("setTimeout has not been defined")}function h(){throw new Error("clearTimeout has not been defined")}function r(s){if(e===setTimeout)return setTimeout(s,0);if((e===a||!e)&&setTimeout)return(e=setTimeout)(s,0);try{return e(s,0)}catch(t){try{return e.call(null,s,0)}catch(t){return e.call(this,s,0)}}}try{e="function"==typeof setTimeout?setTimeout:a}catch(t){e=a}try{n="function"==typeof clearTimeout?clearTimeout:h}catch(t){n=h}var o,c=[],l=!1,u=-1;function f(){l&&o&&(l=!1,o.length?c=o.concat(c):u=-1,c.length)&&m()}function m(){if(!l){var t=r(f);l=!0;for(var s=c.length;s;){for(o=c,c=[];++u<s;)o&&o[u].run();u=-1,s=c.length}o=null,l=!1,function(s){if(n===clearTimeout)return clearTimeout(s);if((n===h||!n)&&clearTimeout)return(n=clearTimeout)(s);try{n(s)}catch(t){try{return n.call(null,s)}catch(t){return n.call(this,s)}}}(t)}}function p(t,s){this.fun=t,this.array=s}function d(){}s.nextTick=function(t){var s=new Array(arguments.length-1);if(1<arguments.length)for(var i=1;i<arguments.length;i++)s[i-1]=arguments[i];c.push(new p(t,s)),1!==c.length||l||r(m)},p.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=d,s.addListener=d,s.once=d,s.off=d,s.removeListener=d,s.removeAllListeners=d,s.emit=d,s.prependListener=d,s.prependOnceListener=d,s.listeners=function(t){return[]},s.binding=function(t){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(t){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},{}],12:[function(t,s,i){var e=t("inherits"),n=t("events").EventEmitter;function a(t){if(!(this instanceof a))return new a(t);n.call(this),this.concurrency=(t=t||{}).concurrency||1/0,this.timeout=t.timeout||0,this.autostart=t.autostart||!1,this.results=t.results||null,this.pending=0,this.session=0,this.running=!1,this.jobs=[],this.timers={}}function c(t){this.session++,this.running=!1,this.emit("end",t)}s.exports=a,e(s.exports.default=a,n),["pop","shift","indexOf","lastIndexOf"].forEach(function(t){a.prototype[t]=function(){return Array.prototype[t].apply(this.jobs,arguments)}}),a.prototype.slice=function(t,s){return this.jobs=this.jobs.slice(t,s),this},a.prototype.reverse=function(){return this.jobs.reverse(),this},["push","unshift","splice"].forEach(function(s){a.prototype[s]=function(){var t=Array.prototype[s].apply(this.jobs,arguments);return this.autostart&&this.start(),t}}),Object.defineProperty(a.prototype,"length",{get:function(){return this.pending+this.jobs.length}}),a.prototype.start=function(t){var i,e,n,a,h,r,o;function s(t,s){n&&i.session===a&&(n=!1,i.pending--,null!==h&&(delete i.timers[h],clearTimeout(h)),t?i.emit("error",t,e):!1===r&&(null!==o&&(i.results[o]=Array.prototype.slice.call(arguments,1)),i.emit("success",s,e)),i.session===a)&&(0===i.pending&&0===i.jobs.length?c.call(i):i.running&&i.start())}t&&function(i){var e=this;function n(t){e.end(t)}this.on("error",n),this.on("end",function t(s){e.removeListener("error",n),e.removeListener("end",t),i(s,this.results)})}.call(this,t),this.running=!0,this.pending>=this.concurrency||(0!==this.jobs.length?(e=(i=this).jobs.shift(),n=!0,a=this.session,r=!1,o=h=null,(t=e.timeout||this.timeout)&&(h=setTimeout(function(){r=!0,0<i.listeners("timeout").length?i.emit("timeout",s,e):s()},t),this.timers[h]=h),this.results&&(o=this.results.length,this.results[o]=null),this.pending++,i.emit("start",e),(t=e(s))&&t.then&&"function"==typeof t.then&&t.then(function(t){return s(null,t)}).catch(function(t){return s(t||!0)}),this.running&&0<this.jobs.length&&this.start()):0===this.pending&&c.call(this))},a.prototype.stop=function(){this.running=!1},a.prototype.end=function(t){(function(){for(var t in this.timers){var s=this.timers[t];delete this.timers[t],clearTimeout(s)}}).call(this),this.jobs.length=0,this.pending=0,c.call(this,t)}},{events:2,inherits:10}],13:[function(o,t,c){!function(t,s){var e=o("process/browser.js").nextTick,i=Function.prototype.apply,n=Array.prototype.slice,a={},h=0;function r(t,s){this._id=t,this._clearFn=s}c.setTimeout=function(){return new r(i.call(setTimeout,window,arguments),clearTimeout)},c.setInterval=function(){return new r(i.call(setInterval,window,arguments),clearInterval)},c.clearTimeout=c.clearInterval=function(t){t.close()},r.prototype.unref=r.prototype.ref=function(){},r.prototype.close=function(){this._clearFn.call(window,this._id)},c.enroll=function(t,s){clearTimeout(t._idleTimeoutId),t._idleTimeout=s},c.unenroll=function(t){clearTimeout(t._idleTimeoutId),t._idleTimeout=-1},c._unrefActive=c.active=function(t){clearTimeout(t._idleTimeoutId);var s=t._idleTimeout;0<=s&&(t._idleTimeoutId=setTimeout(function(){t._onTimeout&&t._onTimeout()},s))},c.setImmediate="function"==typeof t?t:function(t){var s=h++,i=!(arguments.length<2)&&n.call(arguments,1);return a[s]=!0,e(function(){a[s]&&(i?t.apply(null,i):t.call(null),c.clearImmediate(s))}),s},c.clearImmediate="function"==typeof s?s:function(t){delete a[t]}}.call(this,o("timers").setImmediate,o("timers").clearImmediate)},{"process/browser.js":11,timers:13}],14:[function(t,s,i){s.exports={bm:{obj:t("./src/base_utils/js/baseutil_Object"),checks:t("./src/base_utils/js/baseutil_Checks")},cm:{str:t("./src/common_utils/js/CommonUtil_String"),array:t("./src/common_utils/js/CommonUtil_Array"),math:t("./src/common_utils/js/CommonUtil_Math"),date:t("./src/common_utils/js/CommonUtil_Date"),ui:t("./src/common_utils/js/CommonUtil_UI")},datactn:{hashmap:t("hashmap"),queue:t("queue")},sm:{Evented:t("./src/senior_utils/js/SeniorUtil_Evented")},plugin_c:{async:{APromise:t("appoint"),Immediate:t("immediate")}},webgl:{check:t("./src/webgl_utils/js/webglutil_Checks")},gm:{dist:t("./src/geo_utils/js/GeoUtil_Distance"),angle:t("./src/geo_utils/js/GeoUtil_Angle")}}},{"./src/base_utils/js/baseutil_Checks":15,"./src/base_utils/js/baseutil_Object":16,"./src/common_utils/js/CommonUtil_Array":17,"./src/common_utils/js/CommonUtil_Date":18,"./src/common_utils/js/CommonUtil_Math":19,"./src/common_utils/js/CommonUtil_String":20,"./src/common_utils/js/CommonUtil_UI":21,"./src/geo_utils/js/GeoUtil_Angle":22,"./src/geo_utils/js/GeoUtil_Distance":23,"./src/senior_utils/js/SeniorUtil_Evented":24,"./src/webgl_utils/js/webglutil_Checks":25,appoint:1,hashmap:3,immediate:4,queue:12}],15:[function(require,module,exports){var basenutils_Checks=function(){this.isInnerFunction=function(t){return!("function"!=typeof t||!t.toString||!/native code/.test(t.toString()))},this.isAsyncAvaible=function(){try{eval("var func = async function(){}")}catch(t){return!1}return null!=Object.getPrototypeOf(func).constructor},this.getBrowserInfo=function(){var t,s,i;return navigator?(i="unknown",(s=null)!=(t=navigator.userAgent.toLocaleLowerCase()).match(/msie/)||null!=t.match(/trident/)?(s="IE",i=(null!=t.match(/msie ([\d.]+)/)?t.match(/msie ([\d.]+)/):t.match(/rv:([\d.]+)/))[1]):null!=t.match(/firefox/)?s="FireFox":null!=t.match(/ubrowser/)?s="UC":null!=t.match(/opera/)?s="Opera":null!=t.match(/bidubrowser/)?s="百度":null!=t.match(/metasr/)?s="搜狗":null!=t.match(/tencenttraveler/)||null!=t.match(/qqbrowse/)?s="QQ":null!=t.match(/maxthon/)?s="遨游":null!=t.match(/chrome/)?s=function(){var t,s=navigator.mimeTypes;for(t in s)if("application/vnd.chromium.remoting-viewer"==s[t].type)return 1}()?"360":"Chrome":null!=t.match(/safari/)&&(s="Safari"),{browserType:s,browserVersion:i}):{browserType:"unknown",browserVersion:"unknown"}}};module.exports=new basenutils_Checks},{}],16:[function(t,s,i){s.exports=new function(){this.copyObject=function(t){if(null===t||"object"!=typeof t)return t;if(t instanceof Date)return(s=new Date).setTime(t.getTime()),s;if(t instanceof Array){for(var s=[],i=0,e=t.length;i<e;++i)s[i]=this.copyObject(t[i]);return s}if(t instanceof Object){for(var n in s={},t)s[n]=this.copyObject(t[n]);return s}},this.extend=function(t){for(var s,i,e=1,n=arguments.length;e<n;e++)for(s in i=arguments[e])t[s]=i[s];return t},this.inherit=function(t,s){},this.bindObj=function(t,s){var i,e=Array.prototype.slice;return t.bind?t.bind.apply(t,e.call(arguments,1)):(i=e.call(arguments,2),function(){return t.apply(s,i.length?i.concat(e.call(arguments)):arguments)})}}},{}],17:[function(t,s,i){s.exports=new function(){Array.prototype.isInArray=function(t){for(var s=0;s<this.length;s++)if(this[s]==t)return!0;return!1},this.isArray=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},this.isInArray=function(t,s){if(t&&s)for(var i=0,e=s.length;i<e;i++)if(t==s[i])return!0;return!1},this.copyArray=function(t){return!t||0==t.length?[]:[].concat(JSON.parse(JSON.stringify(t)))}}},{}],18:[function(t,s,i){s.exports=new function(){this.regex1="-",this.regex2=":",this.digit_Default="00",this.profix_Digit_Single="0",this.profix_Digit_Double="",this._formateDigitStr=function(t){var s;return!t||isNaN(t)?this.digit_Default:(s=10<=(t=Math.abs(Math.round(t)))?100:10,(10<=t?this.profix_Digit_Double:this.profix_Digit_Single)+t%s)},this.formateDate=function(t){var s;if("number"==typeof t)s=new Date(t);else{if(t.constructor!==Date)return null;s=t}return s.getFullYear()+this.regex1+this._formateDigitStr(s.getMonth()+1)+this.regex1+this._formateDigitStr(s.getDate())+" "+this._formateDigitStr(s.getHours())+this.regex2+this._formateDigitStr(s.getMinutes())+this.regex2+this._formateDigitStr(s.getSeconds())},this.parseDate=function(t){if("string"==typeof t){var s=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);if(s&&3<s.length&&s.length<=5)return new Date(parseInt(s[1]),parseInt(s[2])-1,parseInt(s[3]));if((s=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/))&&7==s.length)return new Date(parseInt(s[1]),parseInt(s[2])-1,parseInt(s[3]),parseInt(s[4]),parseInt(s[5]),parseInt(s[6]));if((s=t.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/))&&7<s.length)return new Date(parseInt(s[1]),parseInt(s[2])-1,parseInt(s[3]),parseInt(s[4]),parseInt(s[5]),parseInt(s[6]),parseInt(s[7]))}return null}}},{}],19:[function(t,s,i){s.exports=new function(){this.cm_array=t("./CommonUtil_Array"),this.PI=Math.PI,this.PI_Half=this.PI/2,this.regex_degree="°",this.regex_minute="'",this.regex_second='"',this.regex_negative="-",this.formatDecimal=function(t,s){s=isNaN(s)?Math.pow(10,6):Math.pow(10,s);return Math.round(t*s)/s},this.getIntegerRand=function(t,s){switch(arguments.length){case 1:return parseInt(Math.random()*s+1);case 2:return parseInt(Math.random()*(t-s+1)+s);default:return 0}},this.getIntegerRandArray=function(t,s,i){if(t<=0)return[];var e=t;s?i-s+1<t&&(e=i-s+1):i+1<t&&(e=i+1);for(var n,a=[],h=0;h<e;h++){for(;n=this.getIntegerRand(s,i),this.cm_array.isInArray(n,a););a.push(n)}return a},this.formateDMSFromDigit=function(t){var s,i,e;return t?(s=(t=String(Math.abs(t)).split("."))[0],t="0."+t[1],e=(i=(t=String(60*t)).split("."))[0],t="0."+i[1],t*=60,s+"°"+e+"'"+formatDecimal(t,2)+'"'):"-1°"},this.formateDigitFromDMS=function(t){var s,i,e,n,a;return t?(i=1,(s=a=e=0)==(t=t.trim()).indexOf(this.regex_negative)&&(i=-1,t=t.slice(1)),0<t.indexOf(this.regex_degree)&&(e=(n=t.split(this.regex_degree))[0],t=n[1]),0<t.indexOf(this.regex_minute)&&(a=(n=t.split(this.regex_minute))[0],t=n[1]),0<t.indexOf(this.regex_second)&&(s=t.split(this.regex_second)[0]),(Math.abs(parseInt(e))+parseInt(a)/60+parseFloat(s)/3600)*i):-1}}},{"./CommonUtil_Array":17}],20:[function(t,s,i){s.exports=new function(){this.trim=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")},this.splitWords=function(t){return this.trim(t).split(/\s+/)},this.toHashCode=function(t){if(!t||!t.length)return 0;for(var s=0,i=0;s<t.length;s++)i=(i<<5)-i+t.charCodeAt(s)|0;return i}}},{}],21:[function(t,s,e){s.exports=new function(){this._dwnr=function(t,s){return 0==t?0:Math.floor(t/s)},this._wrapColor=function(t,s,i){return"#"+(t<16?"0"+t.toString(16):t.toString(16))+(s<16?"0"+s.toString(16):s.toString(16))+(i<16?"0"+i.toString(16):i.toString(16))},this.getColorSpectrum=function(t){var s;if(t)if(t<=0)s=16;else{if(t<=3)return["#ff0000","#ffff00","#0000ff"].slice(0,t);s=t}else s=16;for(var i=[],e=this._dwnr(1280,s),n=0;n<1280;n+=e){var a=this._dwnr(n,256),h=n%256;i.push(this._wrapColor(a<4?a<2?a<1?255:255-h:0:h,0<a?a<4?a<3?255:255-h:0:h,1<a?a<3?h:255:0))}return t<i.length?i.slice(0,t):i},this.toRGBA=function(t,s){var e=t.slice(1).split("");{if(/^[0-9A-Fa-f]{6}$/.test(e.join(""))||/^[0-9A-Fa-f]{3}$/.test(e.join(""))){if(3===e.length)for(i=-3;i<0;i++)e.splice(i,0,""+e.slice(i)[0]);return t=parseInt(e.slice(0,2).join(""),16)+","+parseInt(e.slice(2,4).join(""),16)+","+parseInt(e.slice(4,6).join(""),16),s?"rgba("+t+","+s+")":"rgb("+t+")"}return s?"rgba(0,0,0,"+s+")":"rgb(0,0,0)"}}}},{}],22:[function(t,s,i){s.exports=new function(){this.getAzimuth=function(t,s){var i=t[1],t=t[0],i=s[1]-i,s=s[0]-t,t=s/Math.sqrt(Math.pow(i,2)+Math.pow(s,2)),t=Math.acos(t)/Math.PI*180;return i<0&&s<0?(t=180-t,t+=180):i<0&&0<s&&(t=360-t),t}}},{}],23:[function(t,s,i){s.exports=new function(){this.getEuclideanDistance=function(t,s){if(t&&s)return Math.hypot(s[0]-t[0],s[1]-t[1])}}},{}],24:[function(i,e,t){!function(s,t){e.exports=function(){this.extend=null,this.handlers=null,this._triggeringCount=0,this.eventLoopCaller=null,this.init=function(){this.extend=i("../../base_utils/js/baseutil_Object").extend,this.handlers={},this._initEventLoopCaller.call(this)},this._emptyFunc=function(){},this._initEventLoopCaller=function(){try{t instanceof Function&&(this.eventLoopCaller=t)}catch(t){try{s instanceof Object&&(this.eventLoopCaller=s.nextTick)}catch(t){this.eventLoopCaller=i("immediate")}}},this.on=function(t,s){if(!t||!s)throw Error("eName or handler is missing...");if("string"!=typeof t||"function"!=typeof s)throw Error("type of eName or handler mismatched...");return Object.hasOwnProperty.call(this.handlers,t)||(this.handlers[t]=[]),this.handlers[t].push(s),this},this.once=function(t,s){if(!t||!s)throw Error("eName or handler is missing...");if("string"!=typeof t||"function"!=typeof s)throw Error("type of eName or handler mismatched...");var i=function(){this.off(t,s).off(t,i)}.bind(this),e=this.on(t,s);return e&&e.on(t,i),this},this.trigger=function(){for(var t,s,i,e,n,a=0,h=arguments.length;a<h;a++)"string"!=typeof(e=arguments[a])?s?i=i||e:s=e:t=e;if(t)return n={type:t,target:this.extend({},s||this)},(i=i||{}).sync=!!i.sync,Object.hasOwnProperty.call(this.handlers,t)&&(this._triggeringCount++,this.handlers[t].forEach(function(t){i.sync?t.call(this,n):this.eventLoopCaller(function(){t.call(this,n)}.bind(this))}.bind(this)),this._triggeringCount--),this;throw Error("type of eName must be string...")},this.off=function(t,e){if(!t)throw Error("eName or handler is missing...");if("string"!=typeof t)throw Error("type of eName must be string...");if(e){if("function"!=typeof e)throw Error("type of handler must be function...");Object.hasOwnProperty.call(this.handlers,t)&&this.handlers[t].forEach(function(t,s,i){t==e&&(0<this._triggeringCount&&(t=this._emptyFunc),i.splice(s,1))}.bind(this))}else{var s=this.handlers[t];0<this._triggeringCount&&s.forEach(function(t){this._emptyFunc}),this.handlers[t]=s=[]}return this},this.isListened=function(t){if(t){if("string"!=typeof t)throw Error("type of eName must be string...");if(Object.hasOwnProperty.call(this.handlers,t))return 0<this.handlers[t].length}else{var s=Object.keys(this.handlers),i=s.length;if(0<i)for(var e=0;e<i;e++)if(0<this.handlers[s].length)return!0}return!1},this.wipe=function(t){return t&&"string"==typeof t&&Object.hasOwnProperty.call(this.handlers,t)?(delete this.handlers[t],this):void 0},this.init()}}.call(this,i("_process"),i("timers").setImmediate)},{"../../base_utils/js/baseutil_Object":16,_process:11,immediate:4,timers:13}],25:[function(t,s,i){!function(t){s.exports=new function(){this._g=t,this._contextDefaultOptions={Alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!0},this._extend=function(t,s){for(var i in s)t[i]=s[i];return t},this.isWebGLAvailable=function(t){try{var s=t||document.createElement("canvas");return!(!this._g.WebGLRenderingContext||!s.getContext("webgl")&&!s.getContext("experimental-webgl"))}catch(t){return!1}},this.isWebGL2Available=function(t){try{var s=t||document.createElement("canvas");return!(!this._g.WebGL2RenderingContext||!s.getContext("webgl2"))}catch(t){return!1}},this.getWebGLErrorMessage=function(){return this.getErrorMessage(1)},this.getWebGL2ErrorMessage=function(){return this.getErrorMessage(2)},this.getErrorMessage=function(t){var s={1:this._g.WebGLRenderingContext,2:this._g.WebGL2RenderingContext},i='Your $0 does not seem to support <a href="http://khronos.org/webgl/wiki/Getting_a_WebGL_Implementation" style="color:#000">$1</a>',e=document.createElement("div");return e.id="webglmessage",e.style.fontFamily="monospace",e.style.fontSize="13px",e.style.fontWeight="normal",e.style.textAlign="center",e.style.background="#fff",e.style.color="#000",e.style.padding="1.5em",e.style.width="400px",e.style.margin="5em auto 0",i=(i=s[t]?i.replace("$0","graphics card"):i.replace("$0","browser")).replace("$1",{1:"WebGL",2:"WebGL 2"}[t]),e.innerHTML=i,e},this.getWebGLContext=function(t,s){if(!t||!t.getContext)throw new Error("canvas is not defined...");if(1==(s="object"==typeof s?this._extend(this._contextDefaultOptions,s):this._contextDefaultOptions).forcegl1){if(this.isWebGLAvailable(t))return console.log("Info from protoman_webgl: use webgl version 1.0 forcibly..."),t.getContext("webgl",s)||t.getContext("experimental-webgl",s)}else{if(this.isWebGL2Available(t))return console.log("Info from protoman_webgl: use webgl version 2.0..."),t.getContext("webgl2",s);if(this.isWebGLAvailable(t))return console.log("Info from protoman_webgl: use webgl version 1.0..."),t.getContext("webgl",s)||t.getContext("experimental-webgl",s)}throw new Error("your browser does not support WebGL")}}}.call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[14])(14)}),!function(){window.info4dev||(window.info4dev={});try{protoman.bm.checks.isInnerFunction(Promise)}catch(t){console.log("message from info4dev: "+t.message),window.Promise=protoman.plugin_c.async.APromise,console.log('message from info4dev: use Promise by plugin "APromise"')}try{protoman.bm.checks.isInnerFunction(setImmediate)}catch(t){console.log("message from info4dev: "+t.message),window.setImmediate=protoman.plugin_c.async.Immediate,console.log('message from info4dev: use setImmediate by plugin "immediate"')}window.info4dev.browserInfo=protoman.bm.checks.getBrowserInfo(),window.info4dev.hasAsync=protoman.bm.checks.isAsyncAvaible()}(),!function(t){var s;"object"==typeof exports?module.exports=t():"function"==typeof define&&define.amd?define(t):("undefined"!=typeof window?s=window:"undefined"!=typeof global?s=global:"undefined"!=typeof self&&(s=self),s.proj4=t())}(function(){return function e(n,a,h){function r(i,t){if(!a[i]){if(!n[i]){var s="function"==typeof require&&require;if(!t&&s)return s(i,!0);if(o)return o(i,!0);throw new Error("Cannot find module '"+i+"'")}t=a[i]={exports:{}};n[i][0].call(t.exports,function(t){var s=n[i][1][t];return r(s||t)},t,t.exports,e,n,a,h)}return a[i].exports}for(var o="function"==typeof require&&require,t=0;t<h.length;t++)r(h[t]);return r}({1:[function(t,s,i){var e=t("mgrs");function n(t,s,i){if(!(this instanceof n))return new n(t,s,i);var e;Array.isArray(t)?(this.x=t[0],this.y=t[1],this.z=t[2]||0):"object"==typeof t?(this.x=t.x,this.y=t.y,this.z=t.z||0):"string"==typeof t&&void 0===s?(e=t.split(","),this.x=parseFloat(e[0],10),this.y=parseFloat(e[1],10),this.z=parseFloat(e[2],10)||0):(this.x=t,this.y=s,this.z=i||0),console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}n.fromMGRS=function(t){return new n(e.toPoint(t))},n.prototype.toMGRS=function(t){return e.forward([this.x,this.y],t)},s.exports=n},{mgrs:67}],2:[function(t,s,i){var n=t("./parseCode"),a=t("./extend"),e=t("./projections"),h=t("./deriveConstants");function r(t,s){if(!(this instanceof r))return new r(t);s=s||function(t){if(t)throw t};var i,e=n(t);"object"==typeof e&&(e=h(e),i=r.projections.get(e.projName))?(a(this,e),a(this,i),this.init(),s(null,this)):s(t)}(r.projections=e).start(),s.exports=r},{"./deriveConstants":33,"./extend":34,"./parseCode":37,"./projections":39}],3:[function(t,s,i){s.exports=function(t,s,i){for(var e,n,a=i.x,h=i.y,r=i.z||0,o=0;o<3;o++)if(!s||2!==o||void 0!==i.z)switch(n=0===o?(e=a,"x"):1===o?(e=h,"y"):(e=r,"z"),t.axis[o]){case"e":i[n]=e;break;case"w":i[n]=-e;break;case"n":i[n]=e;break;case"s":i[n]=-e;break;case"u":void 0!==i[n]&&(i.z=e);break;case"d":void 0!==i[n]&&(i.z=-e);break;default:return null}return i}},{}],4:[function(t,s,i){var e=Math.PI/2,n=t("./sign");s.exports=function(t){return Math.abs(t)<e?t:t-n(t)*Math.PI}},{"./sign":21}],5:[function(t,s,i){var e=2*Math.PI,n=t("./sign");s.exports=function(t){return Math.abs(t)<=3.14159265359?t:t-n(t)*e}},{"./sign":21}],6:[function(t,s,i){s.exports=function(t){return 1<Math.abs(t)&&(t=1<t?1:-1),Math.asin(t)}},{}],7:[function(t,s,i){s.exports=function(t){return 1-.25*t*(1+t/16*(3+1.25*t))}},{}],8:[function(t,s,i){s.exports=function(t){return.375*t*(1+.25*t*(1+.46875*t))}},{}],9:[function(t,s,i){s.exports=function(t){return.05859375*t*t*(1+.75*t)}},{}],10:[function(t,s,i){s.exports=function(t){return t*t*t*(35/3072)}},{}],11:[function(t,s,i){s.exports=function(t,s,i){s*=i;return t/Math.sqrt(1-s*s)}},{}],12:[function(t,s,i){s.exports=function(t,s,i,e,n){for(var a,h=t/s,r=0;r<15;r++)if(h+=a=(t-(s*h-i*Math.sin(2*h)+e*Math.sin(4*h)-n*Math.sin(6*h)))/(s-2*i*Math.cos(2*h)+4*e*Math.cos(4*h)-6*n*Math.cos(6*h)),Math.abs(a)<=1e-10)return h;return NaN}},{}],13:[function(t,s,i){var o=Math.PI/2;s.exports=function(t,s){var i=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(s)-i)<1e-6)return s<0?-1*o:o;for(var e,n,a,h=Math.asin(.5*s),r=0;r<30;r++)if(e=Math.sin(h),n=Math.cos(h),a=t*e,h+=n=Math.pow(1-a*a,2)/(2*n)*(s/(1-t*t)-e/(1-a*a)+.5/t*Math.log((1-a)/(1+a))),Math.abs(n)<=1e-10)return h;return NaN}},{}],14:[function(t,s,i){s.exports=function(t,s,i,e,n){return t*n-s*Math.sin(2*n)+i*Math.sin(4*n)-e*Math.sin(6*n)}},{}],15:[function(t,s,i){s.exports=function(t,s,i){t*=s;return i/Math.sqrt(1-t*t)}},{}],16:[function(t,s,i){var h=Math.PI/2;s.exports=function(t,s){for(var i,e=.5*t,n=h-2*Math.atan(s),a=0;a<=15;a++)if(i=t*Math.sin(n),n+=i=h-2*Math.atan(s*Math.pow((1-i)/(1+i),e))-n,Math.abs(i)<=1e-10)return n;return-9999}},{}],17:[function(t,s,i){var e=.01953125,n=.01068115234375;s.exports=function(t){var s=[],i=(s[0]=1-t*(.25+t*(.046875+t*(e+t*n))),s[1]=t*(.75-t*(.046875+t*(e+t*n))),t*t);return s[2]=i*(.46875-t*(.013020833333333334+.007120768229166667*t)),s[3]=(i*=t)*(.3645833333333333-.005696614583333333*t),s[4]=i*t*.3076171875,s}},{}],18:[function(t,s,i){var o=t("./pj_mlfn");s.exports=function(t,s,i){for(var e=1/(1-s),n=t,a=20;a;--a){var h=Math.sin(n),r=1-s*h*h;if(n-=r=(o(n,h,Math.cos(n),i)-t)*(r*Math.sqrt(r))*e,Math.abs(r)<1e-10)return n}return n}},{"./pj_mlfn":19}],19:[function(t,s,i){s.exports=function(t,s,i,e){return e[0]*t-(i*=s)*(e[1]+(s*=s)*(e[2]+s*(e[3]+s*e[4])))}},{}],20:[function(t,s,i){s.exports=function(t,s){var i;return 1e-7<t?(1-t*t)*(s/(1-(i=t*s)*i)-.5/t*Math.log((1-i)/(1+i))):2*s}},{}],21:[function(t,s,i){s.exports=function(t){return t<0?-1:1}},{}],22:[function(t,s,i){s.exports=function(t,s){return Math.pow((1-t)/(1+t),s)}},{}],23:[function(t,s,i){s.exports=function(t){var s={x:t[0],y:t[1]};return 2<t.length&&(s.z=t[2]),3<t.length&&(s.m=t[3]),s}},{}],24:[function(t,s,i){var e=Math.PI/2;s.exports=function(t,s,i){i*=t,i=Math.pow((1-i)/(1+i),.5*t);return Math.tan(.5*(e-s))/i}},{}],25:[function(t,s,i){i.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"},i.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"},i.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"},i.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"},i.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"},i.potsdam={towgs84:"606.0,23.0,413.0",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"},i.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"},i.hermannskogel={towgs84:"653.0,-212.0,449.0",ellipse:"bessel",datumName:"Hermannskogel"},i.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"},i.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"},i.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"},i.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"},i.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"},i.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"},i.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"},i.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"}},{}],26:[function(t,s,i){i.MERIT={a:6378137,rf:298.257,ellipseName:"MERIT 1983"},i.SGS85={a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"},i.GRS80={a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"},i.IAU76={a:6378140,rf:298.257,ellipseName:"IAU 1976"},i.airy={a:6377563.396,b:6356256.91,ellipseName:"Airy 1830"},i.APL4={a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"},i.NWL9D={a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"},i.mod_airy={a:6377340.189,b:6356034.446,ellipseName:"Modified Airy"},i.andrae={a:6377104.43,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"},i.aust_SA={a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"},i.GRS67={a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"},i.bessel={a:6377397.155,rf:299.1528128,ellipseName:"Bessel 1841"},i.bess_nam={a:6377483.865,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"},i.clrk66={a:6378206.4,b:6356583.8,ellipseName:"Clarke 1866"},i.clrk80={a:6378249.145,rf:293.4663,ellipseName:"Clarke 1880 mod."},i.clrk58={a:6378293.645208759,rf:294.2606763692654,ellipseName:"Clarke 1858"},i.CPM={a:6375738.7,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"},i.delmbr={a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"},i.engelis={a:6378136.05,rf:298.2566,ellipseName:"Engelis 1985"},i.evrst30={a:6377276.345,rf:300.8017,ellipseName:"Everest 1830"},i.evrst48={a:6377304.063,rf:300.8017,ellipseName:"Everest 1948"},i.evrst56={a:6377301.243,rf:300.8017,ellipseName:"Everest 1956"},i.evrst69={a:6377295.664,rf:300.8017,ellipseName:"Everest 1969"},i.evrstSS={a:6377298.556,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"},i.fschr60={a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"},i.fschr60m={a:6378155,rf:298.3,ellipseName:"Fischer 1960"},i.fschr68={a:6378150,rf:298.3,ellipseName:"Fischer 1968"},i.helmert={a:6378200,rf:298.3,ellipseName:"Helmert 1906"},i.hough={a:6378270,rf:297,ellipseName:"Hough"},i.intl={a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"},i.kaula={a:6378163,rf:298.24,ellipseName:"Kaula 1961"},i.lerch={a:6378139,rf:298.257,ellipseName:"Lerch 1979"},i.mprts={a:6397300,rf:191,ellipseName:"Maupertius 1738"},i.new_intl={a:6378157.5,b:6356772.2,ellipseName:"New International 1967"},i.plessis={a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"},i.krass={a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"},i.SEasia={a:6378155,b:6356773.3205,ellipseName:"Southeast Asia"},i.walbeck={a:6376896,b:6355834.8467,ellipseName:"Walbeck"},i.WGS60={a:6378165,rf:298.3,ellipseName:"WGS 60"},i.WGS66={a:6378145,rf:298.25,ellipseName:"WGS 66"},i.WGS7={a:6378135,rf:298.26,ellipseName:"WGS 72"},i.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"},i.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"}},{}],27:[function(t,s,i){i.greenwich=0,i.lisbon=-9.131906111111,i.paris=2.337229166667,i.bogota=-74.080916666667,i.madrid=-3.687938888889,i.rome=12.452333333333,i.bern=7.439583333333,i.jakarta=106.807719444444,i.ferro=-17.666666666667,i.brussels=4.367975,i.stockholm=18.058277777778,i.athens=23.7163375,i.oslo=10.722916666667},{}],28:[function(t,s,i){i.ft={to_meter:.3048},i["us-ft"]={to_meter:1200/3937}},{}],29:[function(t,s,i){var e=t("./Proj"),n=t("./transform"),a=e("WGS84");function h(t,s,i){var e;return Array.isArray(i)?(e=n(t,s,i),3===i.length?[e.x,e.y,e.z]:[e.x,e.y]):n(t,s,i)}function r(t){return t instanceof e?t:t.oProj||e(t)}s.exports=function(s,i,t){s=r(s);var e=!1;return void 0===i?(i=s,s=a,e=!0):void 0===i.x&&!Array.isArray(i)||(t=i,i=s,s=a,e=!0),i=r(i),t?h(s,i,t):(t={forward:function(t){return h(s,i,t)},inverse:function(t){return h(i,s,t)}},e&&(t.oProj=i),t)}},{"./Proj":2,"./transform":65}],30:[function(t,s,i){function e(t){if(!(this instanceof e))return new e(t);this.datum_type=4,t&&(t.datumCode&&"none"===t.datumCode&&(this.datum_type=5),t.datum_params&&(this.datum_params=t.datum_params.map(parseFloat),0===this.datum_params[0]&&0===this.datum_params[1]&&0===this.datum_params[2]||(this.datum_type=1),3<this.datum_params.length)&&(0===this.datum_params[3]&&0===this.datum_params[4]&&0===this.datum_params[5]&&0===this.datum_params[6]||(this.datum_type=2,this.datum_params[3]*=n,this.datum_params[4]*=n,this.datum_params[5]*=n,this.datum_params[6]=this.datum_params[6]/1e6+1)),this.datum_type=t.grids?3:this.datum_type,this.a=t.a,this.b=t.b,this.es=t.es,this.ep2=t.ep2,3===this.datum_type)&&(this.grids=t.grids)}var y=Math.PI/2,n=484813681109536e-20,l=.3826834323650898;e.prototype={compare_datums:function(t){return this.datum_type===t.datum_type&&!(this.a!==t.a||5e-11<Math.abs(this.es-t.es))&&(1===this.datum_type?this.datum_params[0]===t.datum_params[0]&&this.datum_params[1]===t.datum_params[1]&&this.datum_params[2]===t.datum_params[2]:2===this.datum_type?this.datum_params[0]===t.datum_params[0]&&this.datum_params[1]===t.datum_params[1]&&this.datum_params[2]===t.datum_params[2]&&this.datum_params[3]===t.datum_params[3]&&this.datum_params[4]===t.datum_params[4]&&this.datum_params[5]===t.datum_params[5]&&this.datum_params[6]===t.datum_params[6]:3!==this.datum_type&&3!==t.datum_type||this.nadgrids===t.nadgrids)},geodetic_to_geocentric:function(t){var s,i,e,n=t.x,a=t.y,h=t.z||0;if(a<-y&&-1.001*y<a)a=-y;else if(y<a&&a<1.001*y)a=y;else if(a<-y||y<a)return null;return n>Math.PI&&(n-=2*Math.PI),e=Math.sin(a),a=Math.cos(a),s=((i=this.a/Math.sqrt(1-this.es*(e*e)))+h)*a*Math.cos(n),a=(i+h)*a*Math.sin(n),n=(i*(1-this.es)+h)*e,t.x=s,t.y=a,t.z=n,0},geocentric_to_geodetic:function(t){var s,i,e,n,a,h,r,o,c,l,u,f,m=1e-12,p=t.x,d=t.y,M=t.z||0,g=Math.sqrt(p*p+d*d),_=Math.sqrt(p*p+d*d+M*M);if(g/this.a<m){if(l=0,_/this.a<m)return u=y,void(f=-this.b)}else l=Math.atan2(d,p);for(s=M/_,i=g/_,e=1/Math.sqrt(1-this.es*(2-this.es)*i*i),n=i*(1-this.es)*e,a=s*e,c=0;c++,f=g*n+M*a-(o=this.a/Math.sqrt(1-this.es*a*a))*(1-this.es*a*a),o=this.es*o/(o+f),o=(r=s*(e=1/Math.sqrt(1-o*(2-o)*i*i)))*n-(h=i*(1-o)*e)*a,n=h,a=r,1e-24<o*o&&c<30;);return u=Math.atan(r/Math.abs(h)),t.x=l,t.y=u,t.z=f,t},geocentric_to_geodetic_noniter:function(t){var s,i,e,n,a,h=t.x,r=t.y,o=t.z||0,h=parseFloat(h),r=parseFloat(r),o=parseFloat(o),c=!1;if(0!==h)s=Math.atan2(r,h);else if(0<r)s=y;else if(r<0)s=-y;else if(c=!0,(s=0)<o)i=y;else{if(!(o<0))return i=y,void(e=-this.b);i=-y}return h=h*h+r*r,r=Math.sqrt(h),a=1.0026*o,h=Math.sqrt(a*a+h),a=o+this.b*this.ep2*((a=a/h)*a*a),h=r-this.a*this.es*(h=r/h)*h*h,n=a/(a=Math.sqrt(a*a+h*h)),h=h/a,a=this.a/Math.sqrt(1-this.es*n*n),e=l<=h?r/h-a:h<=-l?r/-h-a:o/n+a*(this.es-1),!1===c&&(i=Math.atan(n/h)),t.x=s,t.y=i,t.z=e,t},geocentric_to_wgs84:function(t){var s,i,e,n,a,h,r;1===this.datum_type?(t.x+=this.datum_params[0],t.y+=this.datum_params[1],t.z+=this.datum_params[2]):2===this.datum_type&&(a=this.datum_params[0],r=this.datum_params[1],s=this.datum_params[2],i=this.datum_params[3],e=this.datum_params[4],h=this.datum_params[5],a=(n=this.datum_params[6])*(t.x-h*t.y+e*t.z)+a,h=n*(h*t.x+t.y-i*t.z)+r,r=n*(-e*t.x+i*t.y+t.z)+s,t.x=a,t.y=h,t.z=r)},geocentric_from_wgs84:function(t){var s,i,e,n,a,h,r;1===this.datum_type?(t.x-=this.datum_params[0],t.y-=this.datum_params[1],t.z-=this.datum_params[2]):2===this.datum_type&&(a=this.datum_params[0],h=this.datum_params[1],r=this.datum_params[2],s=this.datum_params[3],i=this.datum_params[4],e=this.datum_params[5],n=this.datum_params[6],a=(t.x-a)/n,h=(t.y-h)/n,r=(t.z-r)/n,t.x=a+e*h-i*r,t.y=-e*a+h+s*r,t.z=i*a-s*h+r)}},s.exports=e},{}],31:[function(t,s,i){var f=.006694379990141316;s.exports=function(t,s,i){var e,n,a;function h(t){return 1===t||2===t}if(!t.compare_datums(s)&&5!==t.datum_type&&5!==s.datum_type){var r=t.a,o=t.es,c=s.a,l=s.es,u=t.datum_type;if(3===u)if(0===this.apply_gridshift(t,0,i))t.a=6378137,t.es=f;else{if(!t.datum_params)return t.a=r,t.es=t.es,i;for(e=1,n=0,a=t.datum_params.length;n<a;n++)e*=t.datum_params[n];if(0===e)return t.a=r,t.es=t.es,i;u=3<t.datum_params.length?2:1}3===s.datum_type&&(s.a=6378137,s.es=f),(t.es!==s.es||t.a!==s.a||h(u)||h(s.datum_type))&&(t.geodetic_to_geocentric(i),h(t.datum_type)&&t.geocentric_to_wgs84(i),h(s.datum_type)&&s.geocentric_from_wgs84(i),s.geocentric_to_geodetic(i)),3===s.datum_type&&this.apply_gridshift(s,1,i),t.a=r,t.es=o,s.a=c,s.es=l}return i}},{}],32:[function(t,s,i){var e=t("./global"),n=t("./projString"),a=t("./wkt");function h(t){var s=this;if(2===arguments.length){var i=arguments[1];"string"==typeof i?"+"===i.charAt(0)?h[t]=n(arguments[1]):h[t]=a(arguments[1]):h[t]=i}else if(1===arguments.length){if(Array.isArray(t))return t.map(function(t){Array.isArray(t)?h.apply(s,t):h(t)});if("string"==typeof t){if(t in h)return h[t]}else"EPSG"in t?h["EPSG:"+t.EPSG]=t:"ESRI"in t?h["ESRI:"+t.ESRI]=t:"IAU2000"in t?h["IAU2000:"+t.IAU2000]=t:console.log(t)}}e(h),s.exports=h},{"./global":35,"./projString":38,"./wkt":66}],33:[function(t,s,i){var e=t("./constants/Datum"),n=t("./constants/Ellipsoid"),a=t("./extend"),h=t("./datum");s.exports=function(t){var s;return t.datumCode&&"none"!==t.datumCode&&(s=e[t.datumCode])&&(t.datum_params=s.towgs84?s.towgs84.split(","):null,t.ellps=s.ellipse,t.datumName=s.datumName||t.datumCode),t.a||(s=n[t.ellps]||n.WGS84,a(t,s)),t.rf&&!t.b&&(t.b=(1-1/t.rf)*t.a),(0===t.rf||Math.abs(t.a-t.b)<1e-10)&&(t.sphere=!0,t.b=t.a),t.a2=t.a*t.a,t.b2=t.b*t.b,t.es=(t.a2-t.b2)/t.a2,t.e=Math.sqrt(t.es),t.R_A&&(t.a*=1-t.es*(.16666666666666666+t.es*(.04722222222222222+.022156084656084655*t.es)),t.a2=t.a*t.a,t.b2=t.b*t.b,t.es=0),t.ep2=(t.a2-t.b2)/t.b2,t.k0||(t.k0=1),t.axis||(t.axis="enu"),t.datum||(t.datum=h(t)),t}},{"./constants/Datum":25,"./constants/Ellipsoid":26,"./datum":30,"./extend":34}],34:[function(t,s,i){s.exports=function(t,s){var i,e;if(t=t||{},s)for(e in s)void 0!==(i=s[e])&&(t[e]=i);return t}},{}],35:[function(t,s,i){s.exports=function(t){t("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),t("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),t("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"),t.WGS84=t["EPSG:4326"],t["EPSG:3785"]=t["EPSG:3857"],t.GOOGLE=t["EPSG:3857"],t["EPSG:900913"]=t["EPSG:3857"],t["EPSG:102113"]=t["EPSG:3857"]}},{}],36:[function(t,s,i){var e=t("./core");e.defaultDatum="WGS84",e.Proj=t("./Proj"),e.WGS84=new e.Proj("WGS84"),e.Point=t("./Point"),e.toPoint=t("./common/toPoint"),e.defs=t("./defs"),e.transform=t("./transform"),e.mgrs=t("mgrs"),e.version=t("../package.json").version,t("./includedProjections")(e),s.exports=e},{"../package.json":68,"./Point":1,"./Proj":2,"./common/toPoint":23,"./core":29,"./defs":32,"./includedProjections":"hTEDpn","./transform":65,mgrs:67}],37:[function(t,s,i){var e=t("./defs"),n=t("./wkt"),a=t("./projString");s.exports=function(t){return"string"==typeof t?t in e?e[t]:(i=t,["GEOGCS","GEOCCS","PROJCS","LOCAL_CS"].reduce(function(t,s){return t+1+i.indexOf(s)},0)?n(t):"+"===t[0]?a(t):void 0):t;var i}},{"./defs":32,"./projString":38,"./wkt":66}],38:[function(t,s,i){var r=.017453292519943295,o=t("./constants/PrimeMeridian"),c=t("./constants/units");s.exports=function(t){var s,i,e,n={},a={},h=(t.split("+").map(function(t){return t.trim()}).filter(function(t){return t}).forEach(function(t){t=t.split("=");t.push(!0),a[t[0].toLowerCase()]=t[1]}),{proj:"projName",datum:"datumCode",rf:function(t){n.rf=parseFloat(t)},lat_0:function(t){n.lat0=t*r},lat_1:function(t){n.lat1=t*r},lat_2:function(t){n.lat2=t*r},lat_ts:function(t){n.lat_ts=t*r},lon_0:function(t){n.long0=t*r},lon_1:function(t){n.long1=t*r},lon_2:function(t){n.long2=t*r},alpha:function(t){n.alpha=parseFloat(t)*r},lonc:function(t){n.longc=t*r},x_0:function(t){n.x0=parseFloat(t)},y_0:function(t){n.y0=parseFloat(t)},k_0:function(t){n.k0=parseFloat(t)},k:function(t){n.k0=parseFloat(t)},a:function(t){n.a=parseFloat(t)},b:function(t){n.b=parseFloat(t)},r_a:function(){n.R_A=!0},zone:function(t){n.zone=parseInt(t,10)},south:function(){n.utmSouth=!0},towgs84:function(t){n.datum_params=t.split(",").map(function(t){return parseFloat(t)})},to_meter:function(t){n.to_meter=parseFloat(t)},units:function(t){c[n.units=t]&&(n.to_meter=c[t].to_meter)},from_greenwich:function(t){n.from_greenwich=t*r},pm:function(t){n.from_greenwich=(o[t]||parseFloat(t))*r},nadgrids:function(t){"@null"===t?n.datumCode="none":n.nadgrids=t},axis:function(t){var s="ewnsud";3===t.length&&-1!==s.indexOf(t.substr(0,1))&&-1!==s.indexOf(t.substr(1,1))&&-1!==s.indexOf(t.substr(2,1))&&(n.axis=t)}});for(s in a)i=a[s],s in h?"function"==typeof(e=h[s])?e(i):n[e]=i:n[s]=i;return"string"==typeof n.datumCode&&"WGS84"!==n.datumCode&&(n.datumCode=n.datumCode.toLowerCase()),n}},{"./constants/PrimeMeridian":27,"./constants/units":28}],39:[function(t,s,i){var e=[t("./projections/merc"),t("./projections/longlat")],n={},a=[];function h(t,s){var i=a.length;return t.names?((a[i]=t).names.forEach(function(t){n[t.toLowerCase()]=i}),this):(console.log(s),!0)}i.add=h,i.get=function(t){return!!t&&(t=t.toLowerCase(),void 0!==n[t]&&a[n[t]]?a[n[t]]:void 0)},i.start=function(){e.forEach(h)}},{"./projections/longlat":51,"./projections/merc":52}],40:[function(t,s,i){var e=t("../common/msfnz"),n=t("../common/qsfnz"),a=t("../common/adjust_lon"),o=t("../common/asinz");i.init=function(){Math.abs(this.lat1+this.lat2)<1e-10||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=e(this.e3,this.sin_po,this.cos_po),this.qs1=n(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=e(this.e3,this.sin_po,this.cos_po),this.qs2=n(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=n(this.e3,this.sin_po,this.cos_po),1e-10<Math.abs(this.lat1-this.lat2)?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)},i.forward=function(t){var s=t.x,i=t.y,i=(this.sin_phi=Math.sin(i),this.cos_phi=Math.cos(i),n(this.e3,this.sin_phi,this.cos_phi)),i=this.a*Math.sqrt(this.c-this.ns0*i)/this.ns0,s=this.ns0*a(s-this.long0),e=i*Math.sin(s)+this.x0,i=this.rh-i*Math.cos(s)+this.y0;return t.x=e,t.y=i,t},i.inverse=function(t){var s,i,e;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,e=0<=this.ns0?(i=Math.sqrt(t.x*t.x+t.y*t.y),1):(i=-Math.sqrt(t.x*t.x+t.y*t.y),-1),(s=0)!==i&&(s=Math.atan2(e*t.x,e*t.y)),e=i*this.ns0/this.a,e=this.sphere?Math.asin((this.c-e*e)/(2*this.ns0)):(i=(this.c-e*e)/this.ns0,this.phi1z(this.e3,i)),i=a(s/this.ns0+this.long0),t.x=i,t.y=e,t},i.phi1z=function(t,s){var i,e,n,a=o(.5*s);if(t<1e-10)return a;for(var h=t*t,r=1;r<=25;r++)if(a+=n=.5*(e=1-(i=t*(n=Math.sin(a)))*i)*e/Math.cos(a)*(s/(1-h)-n/e+.5/t*Math.log((1-i)/(1+i))),Math.abs(n)<=1e-7)return a;return null},i.names=["Albers_Conic_Equal_Area","Albers","aea"]},{"../common/adjust_lon":5,"../common/asinz":6,"../common/msfnz":15,"../common/qsfnz":20}],41:[function(t,s,i){var f=t("../common/adjust_lon"),m=Math.PI/2,p=1e-10,d=t("../common/mlfn"),M=t("../common/e0fn"),g=t("../common/e1fn"),_=t("../common/e2fn"),y=t("../common/e3fn"),b=t("../common/gN"),c=t("../common/asinz"),l=t("../common/imlfn");i.init=function(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)},i.forward=function(t){var s,i,e,n,a,h,r,o=t.x,c=t.y,l=Math.sin(t.y),u=Math.cos(t.y),o=f(o-this.long0);return this.sphere?Math.abs(this.sin_p12-1)<=p?(t.x=this.x0+this.a*(m-c)*Math.sin(o),t.y=this.y0-this.a*(m-c)*Math.cos(o)):Math.abs(this.sin_p12+1)<=p?(t.x=this.x0+this.a*(m+c)*Math.sin(o),t.y=this.y0+this.a*(m+c)*Math.cos(o)):(n=this.sin_p12*l+this.cos_p12*u*Math.cos(o),h=(n=Math.acos(n))/Math.sin(n),t.x=this.x0+this.a*h*u*Math.sin(o),t.y=this.y0+this.a*h*(this.cos_p12*l-this.sin_p12*u*Math.cos(o))):(h=M(this.es),s=g(this.es),e=_(this.es),r=y(this.es),Math.abs(this.sin_p12-1)<=p?(a=this.a*d(h,s,e,r,m),i=this.a*d(h,s,e,r,c),t.x=this.x0+(a-i)*Math.sin(o),t.y=this.y0-(a-i)*Math.cos(o)):Math.abs(this.sin_p12+1)<=p?(a=this.a*d(h,s,e,r,m),i=this.a*d(h,s,e,r,c),t.x=this.x0+(a+i)*Math.sin(o),t.y=this.y0+(a+i)*Math.cos(o)):(h=l/u,s=b(this.a,this.e,this.sin_p12),e=b(this.a,this.e,l),r=Math.atan((1-this.es)*h+this.es*s*this.sin_p12/(e*u)),a=0===(c=Math.atan2(Math.sin(o),this.cos_p12*Math.tan(r)-this.sin_p12*Math.cos(o)))?Math.asin(this.cos_p12*Math.sin(r)-this.sin_p12*Math.cos(r)):Math.abs(Math.abs(c)-Math.PI)<=p?-Math.asin(this.cos_p12*Math.sin(r)-this.sin_p12*Math.cos(r)):Math.asin(Math.sin(o)*Math.cos(r)/Math.sin(c)),i=this.e*this.sin_p12/Math.sqrt(1-this.es),l=this.e*this.cos_p12*Math.cos(c)/Math.sqrt(1-this.es),t.x=this.x0+(n=s*a*(1-(h=a*a)*(e=l*l)*(1-e)/6+(u=h*a)/8*(o=i*l)*(1-2*e)+(r=u*a)/120*(e*(4-7*e)-3*i*i*(1-7*e))-r*a/48*o))*Math.sin(c),t.y=this.y0+n*Math.cos(c))),t},i.inverse=function(t){var s,i,e,n,a,h,r,o;return t.x-=this.x0,t.y-=this.y0,this.sphere?(h=Math.sqrt(t.x*t.x+t.y*t.y))>2*m*this.a?void 0:(n=h/this.a,o=Math.sin(n),n=Math.cos(n),s=this.long0,Math.abs(h)<=p?i=this.lat0:(i=c(n*this.sin_p12+t.y*o*this.cos_p12/h),r=Math.abs(this.lat0)-m,s=Math.abs(r)<=p?0<=this.lat0?f(this.long0+Math.atan2(t.x,-t.y)):f(this.long0-Math.atan2(-t.x,t.y)):f(this.long0+Math.atan2(t.x*o,h*this.cos_p12*n-t.y*this.sin_p12*o))),t.x=s,t.y=i,t):(r=M(this.es),n=g(this.es),o=_(this.es),a=y(this.es),Math.abs(this.sin_p12-1)<=p?(e=this.a*d(r,n,o,a,m),h=Math.sqrt(t.x*t.x+t.y*t.y),i=l((e-h)/this.a,r,n,o,a),s=f(this.long0+Math.atan2(t.x,-1*t.y))):Math.abs(this.sin_p12+1)<=p?(e=this.a*d(r,n,o,a,m),h=Math.sqrt(t.x*t.x+t.y*t.y),i=l((h-e)/this.a,r,n,o,a),s=f(this.long0+Math.atan2(t.x,t.y))):(h=Math.sqrt(t.x*t.x+t.y*t.y),e=Math.atan2(t.x,t.y),r=b(this.a,this.e,this.sin_p12),n=Math.cos(e),a=-(o=this.e*this.cos_p12*n)*o/(1-this.es),o=3*this.es*(1-a)*this.sin_p12*this.cos_p12*n/(1-this.es),o=1-a*(r=(h=h/r)-a*(1+a)*Math.pow(h,3)/6-o*(1+3*a)*Math.pow(h,4)/24)*r/2-h*r*r*r/6,a=Math.asin(this.sin_p12*Math.cos(r)+this.cos_p12*Math.sin(r)*n),s=f(this.long0+Math.asin(Math.sin(e)*Math.sin(r)/Math.cos(a))),i=Math.atan((1-this.es*o*this.sin_p12/Math.sin(a))*Math.tan(a)/(1-this.es))),t.x=s,t.y=i,t)},i.names=["Azimuthal_Equidistant","aeqd"]},{"../common/adjust_lon":5,"../common/asinz":6,"../common/e0fn":7,"../common/e1fn":8,"../common/e2fn":9,"../common/e3fn":10,"../common/gN":11,"../common/imlfn":12,"../common/mlfn":14}],42:[function(t,s,i){var c=t("../common/mlfn"),e=t("../common/e0fn"),n=t("../common/e1fn"),a=t("../common/e2fn"),h=t("../common/e3fn"),l=t("../common/gN"),u=t("../common/adjust_lon"),f=t("../common/adjust_lat"),m=t("../common/imlfn"),p=Math.PI/2;i.init=function(){this.sphere||(this.e0=e(this.es),this.e1=n(this.es),this.e2=a(this.es),this.e3=h(this.es),this.ml0=this.a*c(this.e0,this.e1,this.e2,this.e3,this.lat0))},i.forward=function(t){var s,i,e,n,a,h,r=t.x,o=t.y,r=u(r-this.long0);return o=this.sphere?(h=this.a*Math.asin(Math.cos(o)*Math.sin(r)),this.a*(Math.atan2(Math.tan(o),Math.cos(r))-this.lat0)):(s=Math.sin(o),i=Math.cos(o),e=l(this.a,this.e,s),n=Math.tan(o)*Math.tan(o),h=e*(r=r*Math.cos(o))*(1-(r=r*r)*n*(1/6-(8-n+8*(a=this.es*i*i/(1-this.es)))*r/120)),this.a*c(this.e0,this.e1,this.e2,this.e3,o)-this.ml0+e*s/i*r*(.5+(5-n+6*a)*r/24)),t.x=h+this.x0,t.y=o+this.y0,t},i.inverse=function(t){t.x-=this.x0,t.y-=this.y0;var s=t.x/this.a,i=t.y/this.a;if(this.sphere)var e=i+this.lat0,n=Math.asin(Math.sin(e)*Math.cos(s)),e=Math.atan2(Math.tan(s),Math.cos(e));else{var a=this.ml0/this.a+i,a=m(a,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(a)-p)<=1e-10)return t.x=this.long0,t.y=p,i<0&&(t.y*=-1),t;var i=l(this.a,this.e,Math.sin(a)),h=i*i*i/this.a/this.a*(1-this.es),r=Math.pow(Math.tan(a),2),s=s*this.a/i,o=s*s;n=a-i*Math.tan(a)/h*s*s*(.5-(1+3*r)*s*s/24),e=s*(1-o*(r/3+(1+3*r)*r*o/15))/Math.cos(a)}return t.x=u(e+this.long0),t.y=f(n),t},i.names=["Cassini","Cassini_Soldner","cass"]},{"../common/adjust_lat":4,"../common/adjust_lon":5,"../common/e0fn":7,"../common/e1fn":8,"../common/e2fn":9,"../common/e3fn":10,"../common/gN":11,"../common/imlfn":12,"../common/mlfn":14}],43:[function(t,s,i){var n=t("../common/adjust_lon"),a=t("../common/qsfnz"),e=t("../common/msfnz"),h=t("../common/iqsfnz");i.init=function(){this.sphere||(this.k0=e(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))},i.forward=function(t){var s,i=t.x,e=t.y,i=n(i-this.long0);return i=this.sphere?(s=this.x0+this.a*i*Math.cos(this.lat_ts),this.y0+this.a*Math.sin(e)/Math.cos(this.lat_ts)):(e=a(this.e,Math.sin(e)),s=this.x0+this.a*this.k0*i,this.y0+this.a*e*.5/this.k0),t.x=s,t.y=i,t},i.inverse=function(t){var s,i;return t.x-=this.x0,t.y-=this.y0,this.sphere?(s=n(this.long0+t.x/this.a/Math.cos(this.lat_ts)),i=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(i=h(this.e,2*t.y*this.k0/this.a),s=n(this.long0+t.x/(this.a*this.k0))),t.x=s,t.y=i,t},i.names=["cea"]},{"../common/adjust_lon":5,"../common/iqsfnz":13,"../common/msfnz":15,"../common/qsfnz":20}],44:[function(t,s,i){var e=t("../common/adjust_lon"),n=t("../common/adjust_lat");i.init=function(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)},i.forward=function(t){var s=t.x,i=t.y,s=e(s-this.long0),i=n(i-this.lat0);return t.x=this.x0+this.a*s*this.rc,t.y=this.y0+this.a*i,t},i.inverse=function(t){var s=t.x,i=t.y;return t.x=e(this.long0+(s-this.x0)/(this.a*this.rc)),t.y=n(this.lat0+(i-this.y0)/this.a),t},i.names=["Equirectangular","Equidistant_Cylindrical","eqc"]},{"../common/adjust_lat":4,"../common/adjust_lon":5}],45:[function(t,s,i){var e=t("../common/e0fn"),n=t("../common/e1fn"),a=t("../common/e2fn"),h=t("../common/e3fn"),r=t("../common/msfnz"),o=t("../common/mlfn"),c=t("../common/adjust_lon"),l=t("../common/adjust_lat"),u=t("../common/imlfn");i.init=function(){Math.abs(this.lat1+this.lat2)<1e-10||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=e(this.es),this.e1=n(this.es),this.e2=a(this.es),this.e3=h(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=r(this.e,this.sinphi,this.cosphi),this.ml1=o(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<1e-10?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=r(this.e,this.sinphi,this.cosphi),this.ml2=o(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=o(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))},i.forward=function(t){var s=t.x,i=t.y,s=(i=this.sphere?this.a*(this.g-i):(i=o(this.e0,this.e1,this.e2,this.e3,i),this.a*(this.g-i)),this.ns*c(s-this.long0)),e=this.x0+i*Math.sin(s),i=this.y0+this.rh-i*Math.cos(s);return t.x=e,t.y=i,t},i.inverse=function(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0,i=0<=this.ns?(s=Math.sqrt(t.x*t.x+t.y*t.y),1):(s=-Math.sqrt(t.x*t.x+t.y*t.y),-1);var s,i,e,n,a=0;return 0!==s&&(a=Math.atan2(i*t.x,i*t.y)),this.sphere?(n=c(this.long0+a/this.ns),e=l(this.g-s/this.a)):(i=this.g-s/this.a,e=u(i,this.e0,this.e1,this.e2,this.e3),n=c(this.long0+a/this.ns)),t.x=n,t.y=e,t},i.names=["Equidistant_Conic","eqdc"]},{"../common/adjust_lat":4,"../common/adjust_lon":5,"../common/e0fn":7,"../common/e1fn":8,"../common/e2fn":9,"../common/e3fn":10,"../common/imlfn":12,"../common/mlfn":14,"../common/msfnz":15}],46:[function(t,s,i){var a=Math.PI/4,h=t("../common/srat"),r=Math.PI/2;i.init=function(){var t=Math.sin(this.lat0),s=Math.cos(this.lat0);s*=s,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*s*s/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+a)/(Math.pow(Math.tan(.5*this.lat0+a),this.C)*h(this.e*t,this.ratexp))},i.forward=function(t){var s=t.x,i=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*i+a),this.C)*h(this.e*Math.sin(i),this.ratexp))-r,t.x=this.C*s,t},i.inverse=function(t){for(var s=t.x/this.C,i=t.y,e=Math.pow(Math.tan(.5*i+a)/this.K,1/this.C),n=20;0<n&&(i=2*Math.atan(e*h(this.e*Math.sin(t.y),-.5*this.e))-r,!(Math.abs(i-t.y)<1e-14));--n)t.y=i;return n?(t.x=s,t.y=i,t):null},i.names=["gauss"]},{"../common/srat":22}],47:[function(t,s,i){var r=t("../common/adjust_lon"),a=t("../common/asinz");i.init=function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1},i.forward=function(t){var s,i=t.x,e=t.y,i=r(i-this.long0),n=Math.sin(e),e=Math.cos(e),a=Math.cos(i),h=this.sin_p14*n+this.cos_p14*e*a,h=0<h||Math.abs(h)<=1e-10?(s=this.x0+ +this.a*e*Math.sin(i)/h,this.y0+ +this.a*(this.cos_p14*n-this.sin_p14*e*a)/h):(s=this.x0+this.infinity_dist*e*Math.sin(i),this.y0+this.infinity_dist*(this.cos_p14*n-this.sin_p14*e*a));return t.x=s,t.y=h,t},i.inverse=function(t){var s,i,e,n;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,e=(s=Math.sqrt(t.x*t.x+t.y*t.y))?(e=Math.atan2(s,this.rc),i=Math.sin(e),e=Math.cos(e),n=a(e*this.sin_p14+t.y*i*this.cos_p14/s),e=Math.atan2(t.x*i,s*this.cos_p14*e-t.y*this.sin_p14*i),r(this.long0+e)):(n=this.phic0,0),t.x=e,t.y=n,t},i.names=["gnom"]},{"../common/adjust_lon":5,"../common/asinz":6}],48:[function(t,s,i){var n=t("../common/adjust_lon");i.init=function(){this.a=6377397.155,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.4334234309119251),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq},i.forward=function(t){var s=t.x,i=t.y,s=n(s-this.long0),e=Math.pow((1+this.e*Math.sin(i))/(1-this.e*Math.sin(i)),this.alfa*this.e/2),i=2*(Math.atan(this.k*Math.pow(Math.tan(i/2+this.s45),this.alfa)/e)-this.s45),e=-s*this.alfa,s=Math.asin(Math.cos(this.ad)*Math.sin(i)+Math.sin(this.ad)*Math.cos(i)*Math.cos(e)),i=Math.asin(Math.cos(i)*Math.sin(e)/Math.cos(s)),e=this.n*i,i=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(s/2+this.s45),this.n);return t.y=i*Math.cos(e),t.x=i*Math.sin(e),this.czech||(t.y*=-1,t.x*=-1),t},i.inverse=function(t){for(var s,i,e,n,a=t.x,h=(t.x=t.y,t.y=a,this.czech||(t.y*=-1,t.x*=-1),a=Math.sqrt(t.x*t.x+t.y*t.y),i=Math.atan2(t.y,t.x)/Math.sin(this.s0),a=2*(Math.atan(Math.pow(this.ro0/a,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),s=Math.asin(Math.cos(this.ad)*Math.sin(a)-Math.sin(this.ad)*Math.cos(a)*Math.cos(i)),a=Math.asin(Math.cos(a)*Math.sin(i)/Math.cos(s)),t.x=this.long0-a/this.alfa,e=s,n=0);t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(s/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(e))/(1-this.e*Math.sin(e)),this.e/2))-this.s45),Math.abs(e-t.y)<1e-10&&(n=1),e=t.y,h+=1,0===n&&h<15;);return 15<=h?null:t},i.names=["Krovak","krovak"]},{"../common/adjust_lon":5}],49:[function(t,s,i){var m=Math.PI/2,p=Math.PI/4,d=1e-10,M=t("../common/qsfnz"),g=t("../common/adjust_lon");i.S_POLE=1,i.N_POLE=2,i.EQUIT=3,i.OBLIQ=4,i.init=function(){var t,s=Math.abs(this.lat0);if(Math.abs(s-m)<d?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(s)<d?this.mode=this.EQUIT:this.mode=this.OBLIQ,0<this.es)switch(this.qp=M(this.e,1),this.mmf=.5/(1-this.es),this.apa=this.authset(this.es),this.mode){case this.N_POLE:case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),t=Math.sin(this.lat0),this.sinb1=M(this.e,t)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*t*t)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))},i.forward=function(t){var s,i,e,n,a,h,r,o,c,l,u=t.x,f=t.y,u=g(u-this.long0);if(this.sphere){if(a=Math.sin(f),l=Math.cos(f),e=Math.cos(u),this.mode===this.OBLIQ||this.mode===this.EQUIT){if((i=this.mode===this.EQUIT?1+l*e:1+this.sinph0*a+this.cosph0*l*e)<=d)return null;s=(i=Math.sqrt(2/i))*l*Math.sin(u),i*=this.mode===this.EQUIT?a:this.cosph0*a-this.sinph0*l*e}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(e=-e),Math.abs(f+this.phi0)<d)return null;i=p-.5*f,s=(i=2*(this.mode===this.S_POLE?Math.cos(i):Math.sin(i)))*Math.sin(u),i*=e}}else{switch(c=o=r=0,e=Math.cos(u),n=Math.sin(u),a=Math.sin(f),h=M(this.e,a),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(r=h/this.qp,o=Math.sqrt(1-r*r)),this.mode){case this.OBLIQ:c=1+this.sinb1*r+this.cosb1*o*e;break;case this.EQUIT:c=1+o*e;break;case this.N_POLE:c=m+f,h=this.qp-h;break;case this.S_POLE:c=f-m,h=this.qp+h}if(Math.abs(c)<d)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:c=Math.sqrt(2/c),i=this.mode===this.OBLIQ?this.ymf*c*(this.cosb1*r-this.sinb1*o*e):(c=Math.sqrt(2/(1+o*e)))*r*this.ymf,s=this.xmf*c*o*n;break;case this.N_POLE:case this.S_POLE:0<=h?(s=(c=Math.sqrt(h))*n,i=e*(this.mode===this.S_POLE?c:-c)):s=i=0}}return t.x=this.a*s+this.x0,t.y=this.a*i+this.y0,t},i.inverse=function(t){t.x-=this.x0,t.y-=this.y0;var s,i,e,n,a,h,r=t.x/this.a,o=t.y/this.a;if(this.sphere){var c,l=0,u=0,f=Math.sqrt(r*r+o*o);if(1<(c=.5*f))return null;switch(c=2*Math.asin(c),this.mode!==this.OBLIQ&&this.mode!==this.EQUIT||(u=Math.sin(c),l=Math.cos(c)),this.mode){case this.EQUIT:c=Math.abs(f)<=d?0:Math.asin(o*u/f),r*=u,o=l*f;break;case this.OBLIQ:c=Math.abs(f)<=d?this.phi0:Math.asin(l*this.sinph0+o*u*this.cosph0/f),r*=u*this.cosph0,o=(l-Math.sin(c)*this.sinph0)*f;break;case this.N_POLE:o=-o,c=m-c;break;case this.S_POLE:c-=m}s=0!==o||this.mode!==this.EQUIT&&this.mode!==this.OBLIQ?Math.atan2(r,o):0}else{if(h=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(r/=this.dd,o*=this.dd,(a=Math.sqrt(r*r+o*o))<d)return t.x=0,t.y=this.phi0,t;e=2*Math.asin(.5*a/this.rq),i=Math.cos(e),r*=e=Math.sin(e),o=this.mode===this.OBLIQ?(h=i*this.sinb1+o*e*this.cosb1/a,n=this.qp*h,a*this.cosb1*i-o*this.sinb1*e):(n=this.qp*(h=o*e/a),a*i)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(!(n=r*r+(o=this.mode===this.N_POLE?-o:o)*o))return t.x=0,t.y=this.phi0,t;h=1-n/this.qp,this.mode===this.S_POLE&&(h=-h)}s=Math.atan2(r,o),c=this.authlat(Math.asin(h),this.apa)}return t.x=g(this.long0+s),t.y=c,t},i.P00=.3333333333333333,i.P01=.17222222222222222,i.P02=.10257936507936508,i.P10=.06388888888888888,i.P11=.0664021164021164,i.P20=.016415012942191543,i.authset=function(t){var s,i=[];return i[0]=t*this.P00,i[0]+=(s=t*t)*this.P01,i[1]=s*this.P10,i[0]+=(s*=t)*this.P02,i[1]+=s*this.P11,i[2]=s*this.P20,i},i.authlat=function(t,s){var i=t+t;return t+s[0]*Math.sin(i)+s[1]*Math.sin(i+i)+s[2]*Math.sin(i+i+i)},i.names=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"]},{"../common/adjust_lon":5,"../common/qsfnz":20}],50:[function(t,s,i){var h=1e-10,r=t("../common/msfnz"),o=t("../common/tsfnz"),c=Math.PI/2,a=t("../common/sign"),l=t("../common/adjust_lon"),u=t("../common/phi2z");i.init=function(){var t,s,i,e,n,a;this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,Math.abs(this.lat1+this.lat2)<h||(t=this.b/this.a,this.e=Math.sqrt(1-t*t),t=Math.sin(this.lat1),s=Math.cos(this.lat1),s=r(this.e,t,s),i=o(this.e,this.lat1,t),n=Math.sin(this.lat2),e=Math.cos(this.lat2),e=r(this.e,n,e),n=o(this.e,this.lat2,n),a=o(this.e,this.lat0,Math.sin(this.lat0)),Math.abs(this.lat1-this.lat2)>h?this.ns=Math.log(s/e)/Math.log(i/n):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=s/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(a,this.ns),this.title)||(this.title="Lambert Conformal Conic")},i.forward=function(t){var s,i=t.x,e=t.y,n=(Math.abs(2*Math.abs(e)-Math.PI)<=h&&(e=a(e)*(c-2*h)),Math.abs(Math.abs(e)-c));if(h<n)n=o(this.e,e,Math.sin(e)),s=this.a*this.f0*Math.pow(n,this.ns);else{if(e*this.ns<=0)return null;s=0}n=this.ns*l(i-this.long0);return t.x=this.k0*(s*Math.sin(n))+this.x0,t.y=this.k0*(this.rh-s*Math.cos(n))+this.y0,t},i.inverse=function(t){var s,i,e=(t.x-this.x0)/this.k0,n=this.rh-(t.y-this.y0)/this.k0,a=0<this.ns?(s=Math.sqrt(e*e+n*n),1):(s=-Math.sqrt(e*e+n*n),-1),h=0;if(0!==s&&(h=Math.atan2(a*e,a*n)),0!==s||0<this.ns){if(a=1/this.ns,e=Math.pow(s/(this.a*this.f0),a),-9999===(i=u(this.e,e)))return null}else i=-c;return n=l(h/this.ns+this.long0),t.x=n,t.y=i,t},i.names=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"]},{"../common/adjust_lon":5,"../common/msfnz":15,"../common/phi2z":16,"../common/sign":21,"../common/tsfnz":24}],51:[function(t,s,i){function e(t){return t}i.init=function(){},i.forward=e,i.inverse=e,i.names=["longlat","identity"]},{}],52:[function(t,s,i){var e=t("../common/msfnz"),a=Math.PI/2,h=57.29577951308232,r=t("../common/adjust_lon"),o=Math.PI/4,c=t("../common/tsfnz"),n=t("../common/phi2z");i.init=function(){var t=this.b/this.a;this.es=1-t*t,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=e(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)},i.forward=function(t){var s,i,e=t.x,n=t.y;return 90<n*h&&n*h<-90&&180<e*h&&e*h<-180||Math.abs(Math.abs(n)-a)<=1e-10?null:(i=this.sphere?(s=this.x0+this.a*this.k0*r(e-this.long0),this.y0+this.a*this.k0*Math.log(Math.tan(o+.5*n))):(i=Math.sin(n),n=c(this.e,n,i),s=this.x0+this.a*this.k0*r(e-this.long0),this.y0-this.a*this.k0*Math.log(n)),t.x=s,t.y=i,t)},i.inverse=function(t){var s=t.x-this.x0,i=t.y-this.y0;if(this.sphere)e=a-2*Math.atan(Math.exp(-i/(this.a*this.k0)));else{var e,i=Math.exp(-i/(this.a*this.k0));if(-9999===(e=n(this.e,i)))return null}return i=r(this.long0+s/(this.a*this.k0)),t.x=i,t.y=e,t},i.names=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"]},{"../common/adjust_lon":5,"../common/msfnz":15,"../common/phi2z":16,"../common/tsfnz":24}],53:[function(t,s,i){var e=t("../common/adjust_lon");i.init=function(){},i.forward=function(t){var s=t.x,i=t.y,s=e(s-this.long0),s=this.x0+this.a*s,i=this.y0+this.a*Math.log(Math.tan(Math.PI/4+i/2.5))*1.25;return t.x=s,t.y=i,t},i.inverse=function(t){t.x-=this.x0,t.y-=this.y0;var s=e(this.long0+t.x/this.a),i=2.5*(Math.atan(Math.exp(.8*t.y/this.a))-Math.PI/4);return t.x=s,t.y=i,t},i.names=["Miller_Cylindrical","mill"]},{"../common/adjust_lon":5}],54:[function(t,s,i){var h=t("../common/adjust_lon");i.init=function(){},i.forward=function(t){for(var s=t.x,i=t.y,s=h(s-this.long0),e=i,n=Math.PI*Math.sin(i);;){var a=-(e+Math.sin(e)-n)/(1+Math.cos(e));if(e+=a,Math.abs(a)<1e-10)break}e/=2,Math.PI/2-Math.abs(i)<1e-10&&(s=0);i=.900316316158*this.a*s*Math.cos(e)+this.x0,s=1.4142135623731*this.a*Math.sin(e)+this.y0;return t.x=i,t.y=s,t},i.inverse=function(t){t.x-=this.x0,t.y-=this.y0,s=t.y/(1.4142135623731*this.a),.999999999999<Math.abs(s)&&(s=.999999999999),e=Math.asin(s);var s,i=h(this.long0+t.x/(.900316316158*this.a*Math.cos(e))),e=((i=i<-Math.PI?-Math.PI:i)>Math.PI&&(i=Math.PI),s=(2*e+Math.sin(2*e))/Math.PI,1<Math.abs(s)&&(s=1),Math.asin(s));return t.x=i,t.y=e,t},i.names=["Mollweide","moll"]},{"../common/adjust_lon":5}],55:[function(t,s,i){var w=484813681109536e-20;i.iterations=1,i.init=function(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013},i.forward=function(t){for(var s=t.x,i=t.y-this.lat0,s=s-this.long0,e=i/w*1e-5,i=s,n=1,a=0,h=1;h<=10;h++)a+=this.A[h]*(n*=e);var r,o=a,c=i,l=1,u=0,f=0,m=0;for(h=1;h<=6;h++)r=u*o+l*c,f=f+this.B_re[h]*(l=l*o-u*c)-this.B_im[h]*(u=r),m=m+this.B_im[h]*l+this.B_re[h]*u;return t.x=m*this.a+this.x0,t.y=f*this.a+this.y0,t},i.inverse=function(t){var s,i=t.x,e=t.y,i=i-this.x0,n=(e-this.y0)/this.a,a=i/this.a,h=1,r=0,o=0,c=0;for(M=1;M<=6;M++)s=r*n+h*a,o=o+this.C_re[M]*(h=h*n-r*a)-this.C_im[M]*(r=s),c=c+this.C_im[M]*h+this.C_re[M]*r;for(var l=0;l<this.iterations;l++){for(var u,f=o,m=c,p=n,d=a,M=2;M<=6;M++)u=m*o+f*c,f=f*o-m*c,m=u,p+=(M-1)*(this.B_re[M]*f-this.B_im[M]*m),d+=(M-1)*(this.B_im[M]*f+this.B_re[M]*m);var f=1,m=0,g=this.B_re[1],_=this.B_im[1];for(M=2;M<=6;M++)u=m*o+f*c,f=f*o-m*c,m=u,g+=M*(this.B_re[M]*f-this.B_im[M]*m),_+=M*(this.B_im[M]*f+this.B_re[M]*m);var y=g*g+_*_,o=(p*g+d*_)/y,c=(d*g-p*_)/y}var b=o,e=c,v=1,x=0;for(M=1;M<=9;M++)x+=this.D[M]*(v*=b);i=this.lat0+x*w*1e5,e=this.long0+e;return t.x=e,t.y=i,t},i.names=["New_Zealand_Map_Grid","nzmg"]},{}],56:[function(t,s,i){var r=t("../common/tsfnz"),o=t("../common/adjust_lon"),h=t("../common/phi2z"),c=Math.PI/2,l=Math.PI/4,u=1e-10;i.init=function(){this.no_off=this.no_off||!1,this.no_rot=this.no_rot||!1,isNaN(this.k0)&&(this.k0=1);var t,s,i,e,n=Math.sin(this.lat0),a=Math.cos(this.lat0),h=this.e*n,n=(this.bl=Math.sqrt(1+this.es/(1-this.es)*Math.pow(a,4)),this.al=this.a*this.bl*this.k0*Math.sqrt(1-this.es)/(1-h*h),r(this.e,this.lat0,n)),a=this.bl/a*Math.sqrt((1-this.es)/(1-h*h));a*a<1&&(a=1),isNaN(this.longc)?(h=r(this.e,this.lat1,Math.sin(this.lat1)),i=r(this.e,this.lat2,Math.sin(this.lat2)),0<=this.lat0?this.el=(a+Math.sqrt(a*a-1))*Math.pow(n,this.bl):this.el=(a-Math.sqrt(a*a-1))*Math.pow(n,this.bl),h=Math.pow(h,this.bl),i=Math.pow(i,this.bl),s=.5*((t=this.el/h)-1/t),e=(this.el*this.el-i*h)/(this.el*this.el+i*h),i=(i-h)/(i+h),h=o(this.long1-this.long2),this.long0=.5*(this.long1+this.long2)-Math.atan(e*Math.tan(.5*this.bl*h)/i)/this.bl,this.long0=o(this.long0),e=o(this.long1-this.long0),this.gamma0=Math.atan(Math.sin(this.bl*e)/s),this.alpha=Math.asin(a*Math.sin(this.gamma0))):(t=0<=this.lat0?a+Math.sqrt(a*a-1):a-Math.sqrt(a*a-1),this.el=t*Math.pow(n,this.bl),s=.5*(t-1/t),this.gamma0=Math.asin(Math.sin(this.alpha)/a),this.long0=this.longc-Math.asin(s*Math.tan(this.gamma0))/this.bl),this.no_off?this.uc=0:0<=this.lat0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(a*a-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(a*a-1),Math.cos(this.alpha))},i.forward=function(t){var s,i,e,n=t.x,a=t.y,n=o(n-this.long0);return a=Math.abs(Math.abs(a)-c)<=u?(s=0<a?-1:1,e=this.al/this.bl*Math.log(Math.tan(l+s*this.gamma0*.5)),-1*s*c*this.al/this.bl):(s=r(this.e,a,Math.sin(a)),s=.5*((a=this.el/Math.pow(s,this.bl))-1/a),a=.5*(a+1/a),i=Math.sin(this.bl*n),a=(s*Math.sin(this.gamma0)-i*Math.cos(this.gamma0))/a,e=Math.abs(Math.abs(a)-1)<=u?Number.POSITIVE_INFINITY:.5*this.al*Math.log((1-a)/(1+a))/this.bl,Math.abs(Math.cos(this.bl*n))<=u?this.al*this.bl*n:this.al*Math.atan2(s*Math.cos(this.gamma0)+i*Math.sin(this.gamma0),Math.cos(this.bl*n))/this.bl),this.no_rot?(t.x=this.x0+a,t.y=this.y0+e):(a-=this.uc,t.x=this.x0+e*Math.cos(this.alpha)+a*Math.sin(this.alpha),t.y=this.y0+a*Math.cos(this.alpha)-e*Math.sin(this.alpha)),t},i.inverse=function(t){this.no_rot?(i=t.y-this.y0,s=t.x-this.x0):(i=(t.x-this.x0)*Math.cos(this.alpha)-(t.y-this.y0)*Math.sin(this.alpha),s=(t.y-this.y0)*Math.cos(this.alpha)+(t.x-this.x0)*Math.sin(this.alpha),s+=this.uc);var s,i=Math.exp(-1*this.bl*i/this.al),e=.5*(i-1/i),i=.5*(i+1/i),n=Math.sin(this.bl*s/this.al),i=(n*Math.cos(this.gamma0)+e*Math.sin(this.gamma0))/i,a=Math.pow(this.el/Math.sqrt((1+i)/(1-i)),1/this.bl);return Math.abs(i-1)<u?(t.x=this.long0,t.y=c):Math.abs(1+i)<u?(t.x=this.long0,t.y=-1*c):(t.y=h(this.e,a),t.x=o(this.long0-Math.atan2(e*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*s/this.al))/this.bl)),t},i.names=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"]},{"../common/adjust_lon":5,"../common/phi2z":16,"../common/tsfnz":24}],57:[function(t,s,i){var e=t("../common/e0fn"),n=t("../common/e1fn"),a=t("../common/e2fn"),h=t("../common/e3fn"),p=t("../common/adjust_lon"),r=t("../common/adjust_lat"),d=t("../common/mlfn"),M=1e-10,o=t("../common/gN");i.init=function(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=e(this.es),this.e1=n(this.es),this.e2=a(this.es),this.e3=h(this.es),this.ml0=this.a*d(this.e0,this.e1,this.e2,this.e3,this.lat0)},i.forward=function(t){var s,i=t.x,e=t.y,i=p(i-this.long0),n=i*Math.sin(e);return e=this.sphere?Math.abs(e)<=M?(s=this.a*i,-1*this.a*this.lat0):(s=this.a*Math.sin(n)/Math.tan(e),this.a*(r(e-this.lat0)+(1-Math.cos(n))/Math.tan(e))):Math.abs(e)<=M?(s=this.a*i,-1*this.ml0):(s=(i=o(this.a,this.e,Math.sin(e))/Math.tan(e))*Math.sin(n),this.a*d(this.e0,this.e1,this.e2,this.e3,e)-this.ml0+i*(1-Math.cos(n))),t.x=s+this.x0,t.y=e+this.y0,t},i.inverse=function(t){var s,i,e,n,a,h,r=t.x-this.x0,o=t.y-this.y0;if(this.sphere)if(Math.abs(o+this.a*this.lat0)<=M)s=p(r/this.a+this.long0),i=0;else{for(var c,l=this.lat0+o/this.a,u=r*r/this.a/this.a+l*l,f=l,m=20;m;--m)if(f+=e=-1*(l*(f*(c=Math.tan(f))+1)-f-.5*(f*f+u)*c)/((f-l)/c-1),Math.abs(e)<=M){i=f;break}s=p(this.long0+Math.asin(r*Math.tan(f)/this.a)/Math.sin(i))}else if(Math.abs(o+this.ml0)<=M)i=0,s=p(this.long0+r/this.a);else{for(l=(this.ml0+o)/this.a,u=r*r/this.a/this.a+l*l,f=l,m=20;m;--m)if(h=this.e*Math.sin(f),n=Math.sqrt(1-h*h)*Math.tan(f),h=this.a*d(this.e0,this.e1,this.e2,this.e3,f),a=this.e0-2*this.e1*Math.cos(2*f)+4*this.e2*Math.cos(4*f)-6*this.e3*Math.cos(6*f),f-=e=(l*(n*(h=h/this.a)+1)-h-.5*n*(h*h+u))/(this.es*Math.sin(2*f)*(h*h+u-2*l*h)/(4*n)+(l-h)*(n*a-2/Math.sin(2*f))-a),Math.abs(e)<=M){i=f;break}n=Math.sqrt(1-this.es*Math.pow(Math.sin(i),2))*Math.tan(i),s=p(this.long0+Math.asin(r*n/this.a)/Math.sin(i))}return t.x=s,t.y=i,t},i.names=["Polyconic","poly"]},{"../common/adjust_lat":4,"../common/adjust_lon":5,"../common/e0fn":7,"../common/e1fn":8,"../common/e2fn":9,"../common/e3fn":10,"../common/gN":11,"../common/mlfn":14}],58:[function(t,s,i){var l=t("../common/adjust_lon"),a=t("../common/adjust_lat"),e=t("../common/pj_enfn"),u=t("../common/pj_mlfn"),h=t("../common/pj_inv_mlfn"),r=Math.PI/2,o=t("../common/asinz");i.init=function(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=e(this.es)},i.forward=function(t){var s=t.x,i=t.y,s=l(s-this.long0);if(this.sphere){if(this.m)for(var e=this.n*Math.sin(i),n=20;n;--n){var a=(this.m*i+Math.sin(i)-e)/(this.m+Math.cos(i));if(i-=a,Math.abs(a)<1e-10)break}else i=1!==this.n?Math.asin(this.n*Math.sin(i)):i;c=this.a*this.C_x*s*(this.m+Math.cos(i)),o=this.a*this.C_y*i}else var h=Math.sin(i),r=Math.cos(i),o=this.a*u(i,h,r,this.en),c=this.a*s*r/Math.sqrt(1-this.es*h*h);return t.x=c,t.y=o,t},i.inverse=function(t){var s,i,e,n;return t.x-=this.x0,e=t.x/this.a,t.y-=this.y0,s=t.y/this.a,this.sphere?(s/=this.C_y,e/=this.C_x*(this.m+Math.cos(s)),this.m?s=o((this.m*s+Math.sin(s))/this.n):1!==this.n&&(s=o(Math.sin(s)/this.n)),e=l(e+this.long0),s=a(s)):(s=h(t.y/this.a,this.es,this.en),(n=Math.abs(s))<r?(n=Math.sin(s),i=this.long0+t.x*Math.sqrt(1-this.es*n*n)/(this.a*Math.cos(s)),e=l(i)):n-1e-10<r&&(e=this.long0)),t.x=e,t.y=s,t},i.names=["Sinusoidal","sinu"]},{"../common/adjust_lat":4,"../common/adjust_lon":5,"../common/asinz":6,"../common/pj_enfn":17,"../common/pj_inv_mlfn":18,"../common/pj_mlfn":19}],59:[function(t,s,i){i.init=function(){var t=this.lat0,s=(this.lambda0=this.long0,Math.sin(t)),i=this.a,e=1/this.rf,e=2*e-Math.pow(e,2),n=this.e=Math.sqrt(e),i=(this.R=this.k0*i*Math.sqrt(1-e)/(1-e*Math.pow(s,2)),this.alpha=Math.sqrt(1+e/(1-e)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(s/this.alpha),Math.log(Math.tan(Math.PI/4+this.b0/2))),e=Math.log(Math.tan(Math.PI/4+t/2)),t=Math.log((1+n*s)/(1-n*s));this.K=i-this.alpha*e+this.alpha*n/2*t},i.forward=function(t){var s=Math.log(Math.tan(Math.PI/4-t.y/2)),i=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),s=-this.alpha*(s+i)+this.K,i=2*(Math.atan(Math.exp(s))-Math.PI/4),s=this.alpha*(t.x-this.lambda0),e=Math.atan(Math.sin(s)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(s))),i=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(s));return t.y=this.R/2*Math.log((1+Math.sin(i))/(1-Math.sin(i)))+this.y0,t.x=this.R*e+this.x0,t},i.inverse=function(t){for(var s,i=t.x-this.x0,e=t.y-this.y0,i=i/this.R,e=2*(Math.atan(Math.exp(e/this.R))-Math.PI/4),n=Math.asin(Math.cos(this.b0)*Math.sin(e)+Math.sin(this.b0)*Math.cos(e)*Math.cos(i)),i=Math.atan(Math.sin(i)/(Math.cos(this.b0)*Math.cos(i)-Math.sin(this.b0)*Math.tan(e))),e=this.lambda0+i/this.alpha,a=n,h=-1e3,r=0;1e-7<Math.abs(a-h);){if(20<++r)return;s=1/this.alpha*(Math.log(Math.tan(Math.PI/4+n/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(a))/2)),h=a,a=2*Math.atan(Math.exp(s))-Math.PI/2}return t.x=e,t.y=a,t},i.names=["somerc"]},{}],60:[function(t,s,i){var o=Math.PI/2,c=1e-10,e=t("../common/sign"),n=t("../common/msfnz"),l=t("../common/tsfnz"),h=t("../common/phi2z"),u=t("../common/adjust_lon");i.ssfn_=function(t,s,i){return s*=i,Math.tan(.5*(o+t))*Math.pow((1-s)/(1+s),.5*i)},i.init=function(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=c&&(this.k0=.5*(1+e(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=c&&(0<this.lat0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),1===this.k0&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=c&&(this.k0=.5*this.cons*n(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/l(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=n(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-o,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))},i.forward=function(t){var s,i,e=t.x,n=t.y,a=Math.sin(n),h=Math.cos(n),r=u(e-this.long0);return Math.abs(Math.abs(e-this.long0)-Math.PI)<=c&&Math.abs(n+this.lat0)<=c?(t.x=NaN,t.y=NaN):this.sphere?(s=2*this.k0/(1+this.sinlat0*a+this.coslat0*h*Math.cos(r)),t.x=this.a*s*h*Math.sin(r)+this.x0,t.y=this.a*s*(this.coslat0*a-this.sinlat0*h*Math.cos(r))+this.y0):(h=2*Math.atan(this.ssfn_(n,a,this.e))-o,i=Math.cos(h),h=Math.sin(h),Math.abs(this.coslat0)<=c?(n=l(this.e,n*this.con,this.con*a),a=2*this.a*this.k0*n/this.cons,t.x=this.x0+a*Math.sin(e-this.long0),t.y=this.y0-this.con*a*Math.cos(e-this.long0)):(Math.abs(this.sinlat0)<c?(s=2*this.a*this.k0/(1+i*Math.cos(r)),t.y=s*h):(s=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*h+this.cosX0*i*Math.cos(r))),t.y=s*(this.cosX0*h-this.sinX0*i*Math.cos(r))+this.y0),t.x=s*i*Math.sin(r)+this.x0)),t},i.inverse=function(t){t.x-=this.x0,t.y-=this.y0;var s,i,e,n,a=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere)i=2*Math.atan(a/(.5*this.a*this.k0)),e=this.long0,n=this.lat0,a<=c||(n=Math.asin(Math.cos(i)*this.sinlat0+t.y*Math.sin(i)*this.coslat0/a),e=Math.abs(this.coslat0)<c?0<this.lat0?u(this.long0+Math.atan2(t.x,-1*t.y)):u(this.long0+Math.atan2(t.x,t.y)):u(this.long0+Math.atan2(t.x*Math.sin(i),a*this.coslat0*Math.cos(i)-t.y*this.sinlat0*Math.sin(i))));else if(Math.abs(this.coslat0)<=c){if(a<=c)return n=this.lat0,e=this.long0,t.x=e,t.y=n,t;t.x*=this.con,t.y*=this.con,i=a*this.cons/(2*this.a*this.k0),n=this.con*h(this.e,i),e=this.con*u(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(a*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,a<=c?s=this.X0:(s=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/a),e=u(this.long0+Math.atan2(t.x*Math.sin(i),a*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),n=-1*h(this.e,Math.tan(.5*(o+s)));return t.x=e,t.y=n,t},i.names=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"]},{"../common/adjust_lon":5,"../common/msfnz":15,"../common/phi2z":16,"../common/sign":21,"../common/tsfnz":24}],61:[function(t,s,i){var a=t("./gauss"),h=t("../common/adjust_lon");i.init=function(){a.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))},i.forward=function(t){var s,i,e,n;return t.x=h(t.x-this.long0),a.forward.apply(this,[t]),s=Math.sin(t.y),i=Math.cos(t.y),e=Math.cos(t.x),n=this.k0*this.R2/(1+this.sinc0*s+this.cosc0*i*e),t.x=n*i*Math.sin(t.x),t.y=n*(this.cosc0*s-this.sinc0*i*e),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t},i.inverse=function(t){var s,i,e,n;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,n=(n=Math.sqrt(t.x*t.x+t.y*t.y))?(i=2*Math.atan2(n,this.R2),s=Math.sin(i),i=Math.cos(i),e=Math.asin(i*this.sinc0+t.y*s*this.cosc0/n),Math.atan2(t.x*s,n*this.cosc0*i-t.y*this.sinc0*s)):(e=this.phic0,0),t.x=n,t.y=e,a.inverse.apply(this,[t]),t.x=h(t.x+this.long0),t},i.names=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative"]},{"../common/adjust_lon":5,"./gauss":46}],62:[function(t,s,i){var e=t("../common/e0fn"),n=t("../common/e1fn"),a=t("../common/e2fn"),h=t("../common/e3fn"),u=t("../common/mlfn"),g=t("../common/adjust_lon"),_=Math.PI/2,y=t("../common/sign"),b=t("../common/asinz");i.init=function(){this.e0=e(this.es),this.e1=n(this.es),this.e2=a(this.es),this.e3=h(this.es),this.ml0=this.a*u(this.e0,this.e1,this.e2,this.e3,this.lat0)},i.forward=function(t){var s=t.x,i=t.y,s=g(s-this.long0),e=Math.sin(i),n=Math.cos(i);if(this.sphere){var a=n*Math.sin(s);if(Math.abs(Math.abs(a)-1)<1e-10)return 93;c=.5*this.a*this.k0*Math.log((1+a)/(1-a)),a=Math.acos(n*Math.cos(s)/Math.sqrt(1-a*a)),l=this.a*this.k0*((a=i<0?-a:a)-this.lat0)}else var s=n*s,h=Math.pow(s,2),n=this.ep2*Math.pow(n,2),r=Math.tan(i),o=Math.pow(r,2),a=1-this.es*Math.pow(e,2),e=this.a/Math.sqrt(a),a=this.a*u(this.e0,this.e1,this.e2,this.e3,i),c=this.k0*e*s*(1+h/6*(1-o+n+h/20*(5-18*o+Math.pow(o,2)+72*n-58*this.ep2)))+this.x0,l=this.k0*(a-this.ml0+e*r*(h*(.5+h/24*(5-o+9*n+4*Math.pow(n,2)+h/30*(61-58*o+Math.pow(o,2)+600*n-330*this.ep2)))))+this.y0;return t.x=c,t.y=l,t},i.inverse=function(t){var s;if(this.sphere){var i=Math.exp(t.x/(this.a*this.k0)),i=.5*(i-1/i),e=this.lat0+t.y/(this.a*this.k0),n=Math.cos(e),a=Math.sqrt((1-n*n)/(1+i*i)),h=b(a);e<0&&(h=-h),e=0==i&&0===n?this.long0:g(Math.atan2(i,n)+this.long0)}else{for(var r,o,c,l,u,f,m,p,i=t.x-this.x0,n=t.y-this.y0,d=a=(this.ml0+n/this.k0)/this.a,M=0;;M++){1;{if(d+=s=(a+this.e1*Math.sin(2*d)-this.e2*Math.sin(4*d)+this.e3*Math.sin(6*d))/this.e0-d,Math.abs(s)<=1e-10)break;if(6<=M)return 95}}e=Math.abs(d)<_?(p=Math.sin(d),r=Math.cos(d),o=Math.tan(d),c=this.ep2*Math.pow(r,2),l=Math.pow(c,2),u=Math.pow(o,2),f=Math.pow(u,2),a=1-this.es*Math.pow(p,2),m=(p=this.a/Math.sqrt(a))*(1-this.es)/a,i=i/(p*this.k0),h=d-p*o*(p=Math.pow(i,2))/m*(.5-p/24*(5+3*u+10*c-4*l-9*this.ep2-p/30*(61+90*u+298*c+45*f-252*this.ep2-3*l))),g(this.long0+i*(1-p/6*(1+2*u+c-p/20*(5-2*c+28*u-3*l+8*this.ep2+24*f)))/r)):(h=_*y(n),this.long0)}return t.x=e,t.y=h,t},i.names=["Transverse_Mercator","Transverse Mercator","tmerc"]},{"../common/adjust_lon":5,"../common/asinz":6,"../common/e0fn":7,"../common/e1fn":8,"../common/e2fn":9,"../common/e3fn":10,"../common/mlfn":14,"../common/sign":21}],63:[function(t,s,i){var e=t("./tmerc");i.dependsOn="tmerc",i.init=function(){this.zone&&(this.lat0=0,this.long0=.017453292519943295*(6*Math.abs(this.zone)-183),this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,e.init.apply(this),this.forward=e.forward,this.inverse=e.inverse)},i.names=["Universal Transverse Mercator System","utm"]},{"./tmerc":62}],64:[function(t,s,i){var u=t("../common/adjust_lon"),f=Math.PI/2,m=1e-10,p=t("../common/asinz");i.init=function(){this.R=this.a},i.forward=function(t){var s,i=t.x,e=t.y,i=u(i-this.long0),n=(Math.abs(e)<=m&&(s=this.x0+this.R*i,l=this.y0),p(2*Math.abs(e/Math.PI))),a=((Math.abs(i)<=m||Math.abs(Math.abs(e)-f)<=m)&&(s=this.x0,l=0<=e?this.y0+Math.PI*this.R*Math.tan(.5*n):this.y0+Math.PI*this.R*-Math.tan(.5*n)),.5*Math.abs(Math.PI/i-i/Math.PI)),h=a*a,r=Math.sin(n),n=Math.cos(n),n=n/(r+n-1),r=n*(2/r-1),o=r*r,c=Math.PI*this.R*(a*(n-o)+Math.sqrt(h*(n-o)*(n-o)-(o+h)*(n*n-o)))/(o+h),i=(s=this.x0+(c=i<0?-c:c),h+n),c=Math.PI*this.R*(r*i-a*Math.sqrt((o+h)*(1+h)-i*i))/(o+h),l=0<=e?this.y0+c:this.y0-c;return t.x=s,t.y=l,t},i.inverse=function(t){var s,i,e,n,a,h,r;return t.x-=this.x0,t.y-=this.y0,r=Math.PI*this.R,e=(s=t.x/r)*s+(i=t.y/r)*i,r=3*(i*i/(a=-2*(h=-Math.abs(i)*(1+e))+1+2*i*i+e*e)+(2*(n=h-2*i*i+s*s)*n*n/a/a/a-9*h*n/a/a)/27)/(h=(h-n*n/3/a)/a)/(h=2*Math.sqrt(-h/3)),1<Math.abs(r)&&(r=0<=r?1:-1),r=Math.acos(r)/3,h=0<=t.y?(-h*Math.cos(r+Math.PI/3)-n/3/a)*Math.PI:-(-h*Math.cos(r+Math.PI/3)-n/3/a)*Math.PI,r=Math.abs(s)<m?this.long0:u(this.long0+Math.PI*(e-1+Math.sqrt(1+2*(s*s-i*i)+e*e))/2/s),t.x=r,t.y=h,t},i.names=["Van_der_Grinten_I","VanDerGrinten","vandg"]},{"../common/adjust_lon":5,"../common/asinz":6}],65:[function(t,s,i){var h=.017453292519943295,r=57.29577951308232,o=t("./datum_transform"),c=t("./adjust_axis"),l=t("./Proj"),u=t("./common/toPoint");s.exports=function t(s,i,e){var n;function a(t,s){return(1===t.datum.datum_type||2===t.datum.datum_type)&&"WGS84"!==s.datumCode}return Array.isArray(e)&&(e=u(e)),s.datum&&i.datum&&(a(s,i)||a(i,s))&&(t(s,n=new l("WGS84"),e),s=n),"enu"!==s.axis&&c(s,!1,e),"longlat"===s.projName?(e.x*=h,e.y*=h):(s.to_meter&&(e.x*=s.to_meter,e.y*=s.to_meter),s.inverse(e)),s.from_greenwich&&(e.x+=s.from_greenwich),e=o(s.datum,i.datum,e),i.from_greenwich&&(e.x-=i.from_greenwich),"longlat"===i.projName?(e.x*=r,e.y*=r):(i.forward(e),i.to_meter&&(e.x/=i.to_meter,e.y/=i.to_meter)),"enu"!==i.axis&&c(i,!0,e),e}},{"./Proj":2,"./adjust_axis":3,"./common/toPoint":23,"./datum_transform":31}],66:[function(t,s,i){var e=.017453292519943295,n=t("./extend");function a(t,s,i){t[s]=i.map(function(t){var s={};return h(t,s),s}).reduce(function(t,s){return n(t,s)},{})}function h(t,s){var i;Array.isArray(t)?("PARAMETER"===(i=t.shift())&&(i=t.shift()),1===t.length?Array.isArray(t[0])?(s[i]={},h(t[0],s[i])):s[i]=t[0]:t.length?"TOWGS84"===i?s[i]=t:(s[i]={},-1<["UNIT","PRIMEM","VERT_DATUM"].indexOf(i)?(s[i]={name:t[0].toLowerCase(),convert:t[1]},3===t.length&&(s[i].auth=t[2])):"SPHEROID"===i?(s[i]={name:t[0],a:t[1],rf:t[2]},4===t.length&&(s[i].auth=t[3])):-1<["GEOGCS","GEOCCS","DATUM","VERT_CS","COMPD_CS","LOCAL_CS","FITTED_CS","LOCAL_DATUM"].indexOf(i)?(t[0]=["name",t[0]],a(s,i,t)):t.every(function(t){return Array.isArray(t)})?a(s,i,t):h(t,s[i])):s[i]=!0):s[t]=!0}function r(t){return t*e}function o(n){function t(t){var s=n.to_meter||1;return parseFloat(t,10)*s}"GEOGCS"===n.type?n.projName="longlat":"LOCAL_CS"===n.type?(n.projName="identity",n.local=!0):"object"==typeof n.PROJECTION?n.projName=Object.keys(n.PROJECTION)[0]:n.projName=n.PROJECTION,n.UNIT&&(n.units=n.UNIT.name.toLowerCase(),"metre"===n.units&&(n.units="meter"),n.UNIT.convert)&&("GEOGCS"===n.type?n.DATUM&&n.DATUM.SPHEROID&&(n.to_meter=parseFloat(n.UNIT.convert,10)*n.DATUM.SPHEROID.a):n.to_meter=parseFloat(n.UNIT.convert,10)),n.GEOGCS&&(n.GEOGCS.DATUM?n.datumCode=n.GEOGCS.DATUM.name.toLowerCase():n.datumCode=n.GEOGCS.name.toLowerCase(),"d_"===n.datumCode.slice(0,2)&&(n.datumCode=n.datumCode.slice(2)),"new_zealand_geodetic_datum_1949"!==n.datumCode&&"new_zealand_1949"!==n.datumCode||(n.datumCode="nzgd49"),"wgs_1984"===n.datumCode&&("Mercator_Auxiliary_Sphere"===n.PROJECTION&&(n.sphere=!0),n.datumCode="wgs84"),"_ferro"===n.datumCode.slice(-6)&&(n.datumCode=n.datumCode.slice(0,-6)),"_jakarta"===n.datumCode.slice(-8)&&(n.datumCode=n.datumCode.slice(0,-8)),~n.datumCode.indexOf("belge")&&(n.datumCode="rnb72"),n.GEOGCS.DATUM&&n.GEOGCS.DATUM.SPHEROID&&(n.ellps=n.GEOGCS.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),"international"===n.ellps.toLowerCase().slice(0,13)&&(n.ellps="intl"),n.a=n.GEOGCS.DATUM.SPHEROID.a,n.rf=parseFloat(n.GEOGCS.DATUM.SPHEROID.rf,10)),~n.datumCode.indexOf("osgb_1936"))&&(n.datumCode="osgb36"),n.b&&!isFinite(n.b)&&(n.b=n.a);[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_2","Standard_Parallel_2"],["false_easting","False_Easting"],["false_northing","False_Northing"],["central_meridian","Central_Meridian"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",r],["longitude_of_center","Longitude_Of_Center"],["longc","longitude_of_center",r],["x0","false_easting",t],["y0","false_northing",t],["long0","central_meridian",r],["lat0","latitude_of_origin",r],["lat0","standard_parallel_1",r],["lat1","standard_parallel_1",r],["lat2","standard_parallel_2",r],["alpha","azimuth",r],["srsCode","name"]].forEach(function(t){var s,i,e;s=n,i=(t=t)[0],e=t[1],!(i in s)&&e in s&&(s[i]=s[e],3===t.length)&&(s[i]=t[2](s[i]))}),n.long0||!n.longc||"Albers_Conic_Equal_Area"!==n.projName&&"Lambert_Azimuthal_Equal_Area"!==n.projName||(n.long0=n.longc),n.lat_ts||!n.lat1||"Stereographic_South_Pole"!==n.projName&&"Polar Stereographic (variant B)"!==n.projName||(n.lat0=r(0<n.lat1?90:-90),n.lat_ts=n.lat1)}s.exports=function(t,s){var t=JSON.parse((","+t).replace(/\s*\,\s*([A-Z_0-9]+?)(\[)/g,',["$1",').slice(1).replace(/\s*\,\s*([A-Z_0-9]+?)\]/g,',"$1"]').replace(/,\["VERTCS".+/,"")),i=t.shift(),e=t.shift(),e=(t.unshift(["name",e]),t.unshift(["type",i]),t.unshift("output"),{});return h(t,e),o(e.output),n(s,e.output)}},{"./extend":34}],67:[function(t,s,i){var e=6,m="AJSAJS",p="AFAFAF",d=65,M=73,g=79,_=86,y=90;function l(t){return t*(Math.PI/180)}function u(t){return t/Math.PI*180}function f(t){var s,i,e,n,a,h=t.northing,r=t.easting,o=t.zoneLetter,c=t.zoneNumber;return c<0||60<c?null:(a=6378137,r=r-5e5,h=h,o<"N"&&(h-=1e7),o=6*(c-1)-180+3,s=(c=.00669438)/(1-c),i=(h=h/.9996/6367449.145945056)+(3*(i=(1-Math.sqrt(1-c))/(1+Math.sqrt(1-c)))/2-27*i*i*i/32)*Math.sin(2*h)+(21*i*i/16-55*i*i*i*i/32)*Math.sin(4*h)+151*i*i*i/96*Math.sin(6*h),h=a/Math.sqrt(1-c*Math.sin(i)*Math.sin(i)),e=Math.tan(i)*Math.tan(i),n=s*Math.cos(i)*Math.cos(i),a=a*(1-c)/Math.pow(1-c*Math.sin(i)*Math.sin(i),1.5),c=r/(.9996*h),r=u(r=i-h*Math.tan(i)/a*(c*c/2-(5+3*e+10*n-4*n*n-9*s)*c*c*c*c/24+(61+90*e+298*n+45*e*e-252*s-3*n*n)*c*c*c*c*c*c/720)),h=o+u(h=(c-(1+2*e+n)*c*c*c/6+(5-2*n+28*e-3*n*n+8*s+24*e*e)*c*c*c*c*c/120)/Math.cos(i)),t.accuracy?{top:(a=f({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber})).lat,right:a.lon,bottom:r,left:h}:{lat:r,lon:h})}function b(t){t%=e;return t=0===t?e:t}function n(t){if(t&&0===t.length)throw"MGRSPoint coverting from nothing";for(var s,i=t.length,e=null,n="",a=0;!/[A-Z]/.test(s=t.charAt(a));){if(2<=a)throw"MGRSPoint bad conversion from: "+t;n+=s,a++}var h=parseInt(n,10);if(0===a||i<a+3)throw"MGRSPoint bad conversion from: "+t;var r=t.charAt(a++);if(r<="A"||"B"===r||"Y"===r||"Z"<=r||"I"===r||"O"===r)throw"MGRSPoint zone letter "+r+" not handled: "+t;for(var e=t.substring(a,a+=2),o=b(h),c=function(t,s){var i=m.charCodeAt(s-1),e=1e5,n=!1;for(;i!==t.charCodeAt(0);){if(++i===M&&i++,i===g&&i++,y<i){if(n)throw"Bad character: "+t;i=d,n=!0}e+=1e5}return e}(e.charAt(0),o),l=function(t,s){if("V"<t)throw"MGRSPoint given invalid Northing "+t;var i=p.charCodeAt(s-1),e=0,n=!1;for(;i!==t.charCodeAt(0);){if(++i===M&&i++,i===g&&i++,_<i){if(n)throw"Bad character: "+t;i=d,n=!0}e+=1e5}return e}(e.charAt(1),o);l<function(t){var s;switch(t){case"C":s=11e5;break;case"D":s=2e6;break;case"E":s=28e5;break;case"F":s=37e5;break;case"G":s=46e5;break;case"H":s=55e5;break;case"J":s=64e5;break;case"K":s=73e5;break;case"L":s=82e5;break;case"M":s=91e5;break;case"N":s=0;break;case"P":s=8e5;break;case"Q":s=17e5;break;case"R":s=26e5;break;case"S":s=35e5;break;case"T":s=44e5;break;case"U":s=53e5;break;case"V":s=62e5;break;case"W":s=7e6;break;case"X":s=79e5;break;default:s=-1}{if(0<=s)return s;throw"Invalid zone letter: "+t}}(r);)l+=2e6;e=i-a;if(e%2!=0)throw"MGRSPoint has to have an even number \nof digits after the zone letter and two 100km letters - front \nhalf for easting meters, second half for \nnorthing meters"+t;var u,f,o=e/2,i=0,e=0;return 0<o&&(u=1e5/Math.pow(10,o),f=t.substring(a,a+o),i=parseFloat(f)*u,f=t.substring(a+o),e=parseFloat(f)*u),{easting:i+c,northing:e+l,zoneLetter:r,zoneNumber:h,accuracy:u}}i.forward=function(t,s){return s=s||5,t=function(t){var s,i,e,n,a,h=t.lat,t=t.lon,r=.00669438,o=l(h),c=l(t);a=Math.floor((t+180)/6)+1,180===t&&(a=60);56<=h&&h<64&&3<=t&&t<12&&(a=32);72<=h&&h<84&&(0<=t&&t<9?a=31:9<=t&&t<21?a=33:21<=t&&t<33?a=35:33<=t&&t<42&&(a=37));t=l(6*(a-1)-180+3),s=r/(1-r),i=6378137/Math.sqrt(1-r*Math.sin(o)*Math.sin(o)),e=Math.tan(o)*Math.tan(o),n=s*Math.cos(o)*Math.cos(o),c=Math.cos(o)*(c-t),t=6378137*(.9983242984503243*o-.002514607064228144*Math.sin(2*o)+2639046602129982e-21*Math.sin(4*o)-35*r*r*r/3072*Math.sin(6*o));r=.9996*i*(c+(1-e+n)*c*c*c/6+(5-18*e+e*e+72*n-58*s)*c*c*c*c*c/120)+5e5,t=.9996*(t+i*Math.tan(o)*(c*c/2+(5-e+9*n+4*n*n)*c*c*c*c/24+(61-58*e+e*e+600*n-330*s)*c*c*c*c*c*c/720));h<0&&(t+=1e7);return{northing:Math.round(t),easting:Math.round(r),zoneNumber:a,zoneLetter:function(t){var s="Z";t<=84&&72<=t?s="X":t<72&&64<=t?s="W":t<64&&56<=t?s="V":t<56&&48<=t?s="U":t<48&&40<=t?s="T":t<40&&32<=t?s="S":t<32&&24<=t?s="R":t<24&&16<=t?s="Q":t<16&&8<=t?s="P":t<8&&0<=t?s="N":t<0&&-8<=t?s="M":t<-8&&-16<=t?s="L":t<-16&&-24<=t?s="K":t<-24&&-32<=t?s="J":t<-32&&-40<=t?s="H":t<-40&&-48<=t?s="G":t<-48&&-56<=t?s="F":t<-56&&-64<=t?s="E":t<-64&&-72<=t?s="D":t<-72&&-80<=t&&(s="C");return s}(h)}}({lat:t[1],lon:t[0]}),s=s,i="00000"+t.easting,e="00000"+t.northing,t.zoneNumber+t.zoneLetter+function(t,s,i){i=b(i),t=Math.floor(t/1e5),s=Math.floor(s/1e5)%20;return function(t,s,i){var i=i-1,e=m.charCodeAt(i),i=p.charCodeAt(i),t=e+t-1,s=i+s,n=!1;y<t&&(t=t-y+d-1,n=!0);(t===M||e<M&&M<t||(M<t||e<M)&&n)&&t++;(t===g||e<g&&g<t||(g<t||e<g)&&n)&&++t===M&&t++;y<t&&(t=t-y+d-1);n=_<s&&(s=s-_+d-1,!0);(s===M||i<M&&M<s||(M<s||i<M)&&n)&&s++;(s===g||i<g&&g<s||(g<s||i<g)&&n)&&++s===M&&s++;_<s&&(s=s-_+d-1);return String.fromCharCode(t)+String.fromCharCode(s)}(t,s,i)}(t.easting,t.northing,t.zoneNumber)+i.substr(i.length-5,s)+e.substr(e.length-5,s);var i,e},i.inverse=function(t){t=f(n(t.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat,t.lon,t.lat]:[t.left,t.bottom,t.right,t.top]},i.toPoint=function(t){t=f(n(t.toUpperCase()));return t.lat&&t.lon?[t.lon,t.lat]:[(t.left+t.right)/2,(t.top+t.bottom)/2]}},{}],68:[function(t,s,i){s.exports={name:"proj4",version:"2.3.14",description:"Proj4js is a JavaScript library to transform point coordinates from one coordinate system to another, including datum transformations.",main:"lib/index.js",directories:{test:"test",doc:"docs"},scripts:{test:"./node_modules/istanbul/lib/cli.js test ./node_modules/mocha/bin/_mocha test/test.js"},repository:{type:"git",url:"git://github.com/proj4js/proj4js.git"},author:"",license:"MIT",jam:{main:"dist/proj4.js",include:["dist/proj4.js","README.md","AUTHORS","LICENSE.md"]},devDependencies:{"grunt-cli":"~0.1.13",grunt:"~0.4.2","grunt-contrib-connect":"~0.6.0","grunt-contrib-jshint":"~0.8.0",chai:"~1.8.1",mocha:"~1.17.1","grunt-mocha-phantomjs":"~0.4.0",browserify:"~12.0.1","grunt-browserify":"~4.0.1","grunt-contrib-uglify":"~0.11.1",curl:"git://github.com/cujojs/curl.git",istanbul:"~0.2.4",tin:"~0.4.0"},dependencies:{mgrs:"~0.0.2"}}},{}],"./includedProjections":[function(t,s,i){s.exports=t("hTEDpn")},{}],hTEDpn:[function(t,s,i){var e=[t("./lib/projections/tmerc"),t("./lib/projections/utm"),t("./lib/projections/sterea"),t("./lib/projections/stere"),t("./lib/projections/somerc"),t("./lib/projections/omerc"),t("./lib/projections/lcc"),t("./lib/projections/krovak"),t("./lib/projections/cass"),t("./lib/projections/laea"),t("./lib/projections/aea"),t("./lib/projections/gnom"),t("./lib/projections/cea"),t("./lib/projections/eqc"),t("./lib/projections/poly"),t("./lib/projections/nzmg"),t("./lib/projections/mill"),t("./lib/projections/sinu"),t("./lib/projections/moll"),t("./lib/projections/eqdc"),t("./lib/projections/vandg"),t("./lib/projections/aeqd")];s.exports=function(s){e.forEach(function(t){s.Proj.projections.add(t)})}},{"./lib/projections/aea":40,"./lib/projections/aeqd":41,"./lib/projections/cass":42,"./lib/projections/cea":43,"./lib/projections/eqc":44,"./lib/projections/eqdc":45,"./lib/projections/gnom":47,"./lib/projections/krovak":48,"./lib/projections/laea":49,"./lib/projections/lcc":50,"./lib/projections/mill":53,"./lib/projections/moll":54,"./lib/projections/nzmg":55,"./lib/projections/omerc":56,"./lib/projections/poly":57,"./lib/projections/sinu":58,"./lib/projections/somerc":59,"./lib/projections/stere":60,"./lib/projections/sterea":61,"./lib/projections/tmerc":62,"./lib/projections/utm":63,"./lib/projections/vandg":64}]},{},[36])(36)}),!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).projzh=t()}(function(){return function e(n,a,h){function r(i,t){if(!a[i]){if(!n[i]){var s="function"==typeof require&&require;if(!t&&s)return s(i,!0);if(o)return o(i,!0);t=new Error("Cannot find module '"+i+"'");throw t.code="MODULE_NOT_FOUND",t}s=a[i]={exports:{}};n[i][0].call(s.exports,function(t){var s=n[i][1][t];return r(s||t)},s,s.exports,e,n,a,h)}return a[i].exports}for(var o="function"==typeof require&&require,t=0;t<h.length;t++)r(h[t]);return r}({1:[function(t,s,i){var e=t("../util").forEachPoint,n=t("./gcj-02"),a=3e3*Math.PI/180;function h(t,s,i){var e=t[i]-.0065,t=t[i+1]-.006,n=Math.sqrt(e*e+t*t)-2e-5*Math.sin(t*a),t=Math.atan2(t,e)-3e-6*Math.cos(e*a);return s[i]=n*Math.cos(t),s[i+1]=n*Math.sin(t),s}function r(t,s,i){var e=t[i],t=t[i+1],n=Math.sqrt(e*e+t*t)+2e-5*Math.sin(t*a),t=Math.atan2(t,e)+3e-6*Math.cos(e*a);return s[i]=n*Math.cos(t)+.0065,s[i+1]=n*Math.sin(t)+.006,s}i.toWGS84=function(t,s,i){t=e(h)(t,s,i);return n.toWGS84(t,t,i)},i.fromWGS84=function(t,s,i){t=n.fromWGS84(t,s,i);return e(r)(t,t,i)}},{"../util":8,"./gcj-02":2}],2:[function(t,s,i){var t=t("../util").forEachPoint,a=Math.PI,h=.006693421622965943;function r(t,s){n=2*(i=t-105)-100+3*(e=s-35)+.2*e*e+.1*i*e+.2*Math.sqrt(Math.abs(i));var i=n=(n=(n+=2*(20*Math.sin(6*i*a)+20*Math.sin(2*i*a))/3)+2*(20*Math.sin(e*a)+40*Math.sin(e/3*a))/3)+2*(160*Math.sin(e/12*a)+320*Math.sin(e*a/30))/3,e=function(t,s){s=300+t+2*s+.1*t*t+.1*t*s+.1*Math.sqrt(Math.abs(t));return s=(s=(s+=2*(20*Math.sin(6*t*a)+20*Math.sin(2*t*a))/3)+2*(20*Math.sin(t*a)+40*Math.sin(t/3*a))/3)+2*(150*Math.sin(t/12*a)+300*Math.sin(t/30*a))/3}(t-105,s-35),n=s/180*a,t=Math.sin(n),t=1-h*t*t,s=Math.sqrt(t),i=180*i/(6378245*(1-h)/(t*s)*a);return[180*e/(6378245/s*Math.cos(n)*a),i]}function o(t,s){return t<72.004||137.8347<t||s<.8293||55.8271<s}i.toWGS84=t(function(t,s,i){var e,n=t[i],t=t[i+1];o(n,t)||(n-=(e=r(n,t))[0],t-=e[1]),s[i]=n,s[i+1]=t}),i.fromWGS84=t(function(t,s,i){var e,n=t[i],t=t[i+1];o(n,t)||(n+=(e=r(n,t))[0],t+=e[1]),s[i]=n,s[i+1]=t})},{"../util":8}],3:[function(t,s,i){i.bd09=t("./bd-09"),i.gcj02=t("./gcj-02")},{"./bd-09":1,"./gcj-02":2}],4:[function(t,s,i){var e=t("./projection/index"),n=t("./datum/index");i.smerc2bmerc=function(t,s,i){t=e.sphericalMercator.inverse(t,s,i),t=n.bd09.fromWGS84(t,t,i);return e.baiduMercator.forward(t,t,i)},i.bmerc2smerc=function(t,s,i){t=e.baiduMercator.inverse(t,s,i),t=n.bd09.toWGS84(t,t,i);return e.sphericalMercator.forward(t,t,i)},i.bmerc2ll=function(t,s,i){t=e.baiduMercator.inverse(t,s,i);return n.bd09.toWGS84(t,t,i)},i.ll2bmerc=function(t,s,i){t=n.bd09.fromWGS84(t,s,i);return e.baiduMercator.forward(t,t,i)},i.ll2smerc=e.sphericalMercator.forward,i.smerc2ll=e.sphericalMercator.inverse,i.datum=n,i.projection=e},{"./datum/index":3,"./projection/index":6}],5:[function(t,s,i){var t=t("../util").forEachPoint,h=[12890594.86,8362377.87,5591021,3481989.83,1678043.12,0],c=[75,60,45,30,15,0],r=[[1.410526172116255e-8,898305509648872e-20,-1.9939833816331,200.9824383106796,-187.2403703815547,91.6087516669843,-23.38765649603339,2.57121317296198,-.03801003308653,17337981.2],[-7.435856389565537e-9,8983055097726239e-21,-.78625201886289,96.32687599759846,-1.85204757529826,-59.36935905485877,47.40033549296737,-16.50741931063887,2.28786674699375,10260144.86],[-3.030883460898826e-8,898305509983578e-20,.30071316287616,59.74293618442277,7.357984074871,-25.38371002664745,13.45380521110908,-3.29883767235584,.32710905363475,6856817.37],[-1.981981304930552e-8,8983055099779535e-21,.03278182852591,40.31678527705744,.65659298677277,-4.44255534477492,.85341911805263,.12923347998204,-.04625736007561,4482777.06],[3.09191371068437e-9,8983055096812155e-21,6995724062e-14,23.10934304144901,-.00023663490511,-.6321817810242,-.00663494467273,.03430082397953,-.00466043876332,2555164.4],[2.890871144776878e-9,8983055095805407e-21,-3.068298e-8,7.47137025468032,-353937994e-14,-.02145144861037,-1234426596e-14,.00010322952773,-323890364e-14,826088.5]],l=[[-.0015702102444,111320.7020616939,0x60e374c3105a3,-0x24bb4115e2e164,0x5cc55543bb0ae8,-0x7ce070193f3784,0x5e7ca61ddf8150,-0x261a578d8b24d0,0x665d60f3742ca,82.5],[.0008277824516172526,111320.7020463578,647795574.6671607,-4082003173.641316,10774905663.51142,-15171875531.51559,12053065338.62167,-5124939663.577472,913311935.9512032,67.5],[.00337398766765,111320.7020202162,4481351.045890365,-23393751.19931662,79682215.47186455,-115964993.2797253,97236711.15602145,-43661946.33752821,8477230.501135234,52.5],[.00220636496208,111320.7020209128,51751.86112841131,3796837.749470245,992013.7397791013,-1221952.21711287,1340652.697009075,-620943.6990984312,144416.9293806241,37.5],[-.0003441963504368392,111320.7020576856,278.2353980772752,2485758.690035394,6070.750963243378,54821.18345352118,9540.606633304236,-2710.55326746645,1405.483844121726,22.5],[-.0003218135878613132,111320.7020701615,.00369383431289,823725.6402795718,.46104986909093,2351.343141331292,1.58060784298199,8.77738589078284,.37238884252424,7.45]];function u(t,s,i,e){var n=t[i],t=t[i+1],a=e[0]+e[1]*Math.abs(n),h=Math.abs(t)/e[9],e=e[2]+e[3]*h+e[4]*h*h+e[5]*h*h*h+e[6]*h*h*h*h+e[7]*h*h*h*h*h+e[8]*h*h*h*h*h*h;s[i]=a*(n<0?-1:1),s[i+1]=e*(t<0?-1:1)}i.forward=t(function(t,s,i){for(var e,n,a=function(t,s,i){for(var e=i-s;i<t;)t-=e;for(;t<s;)t+=e;return t}(t[i],-180,180),h=(t=t[i+1],e=-74,n=74,t=Math.max(t,e),t=Math.min(t,n)),r=null,o=0;o<c.length;++o)if(c[o]<=h){r=l[o];break}if(null===r)for(o=c.length-1;0<=o;--o)if(h<=-c[o]){r=l[o];break}s[i]=a,s[i+1]=h,u(s,s,i,r)}),i.inverse=t(function(t,s,i){for(var e=Math.abs(t[i+1]),n=null,a=0;a<h.length;a++)if(h[a]<=e){n=r[a];break}u(t,s,i,n)})},{"../util":8}],6:[function(t,s,i){i.baiduMercator=t("./baidu-mercator"),i.sphericalMercator=t("./spherical-mercator")},{"./baidu-mercator":5,"./spherical-mercator":7}],7:[function(t,s,i){var t=t("../util").forEachPoint,n=6378137,a=85.0511287798,h=Math.PI/180;i.forward=t(function(t,s,i){var e=Math.max(Math.min(a,t[i+1]),-a),e=Math.sin(e*h);s[i]=n*t[i]*h,s[i+1]=n*Math.log((1+e)/(1-e))/2}),i.inverse=t(function(t,s,i){s[i]=t[i]/n/h,s[i+1]=(2*Math.atan(Math.exp(t[i+1]/n))-Math.PI/2)/h})},{"../util":8}],8:[function(t,s,i){i.forEachPoint=function(r){return function(t,s,i){for(var e=t.length,n=i||2,a=s||(2!==n?t.slice():new Array(e)),h=0;h<e;h+=n)r(t,a,h);return a}}},{}]},{},[4])(4)}),!function(){var t={hasClass:function(){},addClass:function(){},removeClass:function(){},toggleClass:function(){},hasClass:function(t,s){return 0!=(s=s||"").replace(/\s/g,"").length&&new RegExp(" "+s+" ").test(" "+t.className+" ")},addClass:function(t,s){this.hasClass(t,s)||(t.className=(t.className?t.className+" ":"")+s)},removeClass:function(t,s){if(this.hasClass(t,s)){for(var i=" "+t.className.replace(/[\t\r\n]/g,"")+" ";0<=i.indexOf(" "+s+" ");)i=i.replace(" "+s+" "," ");t.className=i.replace(/^\s+|\s+$/g,"")}},toggleClass:function(t,s){this.hasClass(t,s)?this.removeClass(t,s):this.addClass(t,s)}};window.handleClass=t}();var GPS={PI:3.141592653589793,x_pi:52.35987755982988,delta:function(t,s){var i=.006693421622965943,e=this.transformLat(s-105,t-35),s=this.transformLon(s-105,t-35),t=t/180*this.PI,n=1-i*(n=Math.sin(t))*n,a=Math.sqrt(n);return{lat:180*e/(6378245*(1-i)/(n*a)*this.PI),lon:180*s/(6378245/a*Math.cos(t)*this.PI)}},transformCoordinate:function(t,s){return"WGS-84"===t?"GCJ-02"===s?"gcj_encrypt":"BD-09"===s?"bd_encrypt_wps":void 0:"GCJ-02"===t?"WGS-84"===s?"gcj_decrypt":"BD-09"===s?"bd_encrypt":void 0:"BD-09"===t?"GCJ-02"===s?"bd_decrypt":"WGS-84"===s?"bd_decrypt_wps":void 0:void 0},gcj_encrypt:function(t,s){return this.outOfChina(t,s)?{lat:t,lon:s}:{lat:t+(t=this.delta(t,s)).lat,lon:s+t.lon}},gcj_decrypt:function(t,s){return this.outOfChina(t,s)?{lat:t,lon:s}:{lat:t-(t=this.delta(t,s)).lat,lon:s-t.lon}},gcj_decrypt_exact:function(t,s){for(var i=t-.01,e=s-.01,n=t+.01,a=s+.01,h=0;;){var r=(i+n)/2,o=(e+a)/2,c=this.gcj_encrypt(r,o),l=c.lat-t,c=c.lon-s;if(Math.abs(l)<1e-9&&Math.abs(c)<1e-9)break;if(0<l?n=r:i=r,0<c?a=o:e=o,1e4<++h)break}return{lat:r,lon:o}},bd_encrypt:function(t,s){var i=Math.sqrt(s*s+t*t)+2e-5*Math.sin(t*this.x_pi),t=Math.atan2(t,s)+3e-6*Math.cos(s*this.x_pi);return bdLon=i*Math.cos(t)+.0065,{lat:bdLat=i*Math.sin(t)+.006,lon:bdLon}},bd_decrypt:function(t,s){var s=s-.0065,t=t-.006,i=Math.sqrt(s*s+t*t)-2e-5*Math.sin(t*this.x_pi),t=Math.atan2(t,s)-3e-6*Math.cos(s*this.x_pi),s=i*Math.cos(t);return{lat:i*Math.sin(t),lon:s}},bd_encrypt_wps:function(t,s){t=gcj_encrypt(t,s);return bd_encrypt(t.lat,t.lng)},bd_decrypt_wps:function(t,s){t=bd_decrypt(t,s);return gcj_decrypt(t.lat,t.lng)},mercator_encrypt:function(t,s){s=20037508.34*s/180;return{lat:20037508.34*(Math.log(Math.tan((90+t)*this.PI/360))/(this.PI/180))/180,lon:s}},mercator_decrypt:function(t,s){s=s/20037508.34*180,t=t/20037508.34*180;return{lat:180/this.PI*(2*Math.atan(Math.exp(t*this.PI/180))-this.PI/2),lon:s}},distance:function(t,s,i,e){s=Math.cos(t*this.PI/180)*Math.cos(i*this.PI/180)*Math.cos((s-e)*this.PI/180)+Math.sin(t*this.PI/180)*Math.sin(i*this.PI/180);return(s=1<s?1:s)<-1&&(s=-1),6371e3*Math.acos(s)},outOfChina:function(t,s){return s<72.004||137.8347<s||t<.8293||55.8271<t},transformLat:function(t,s){var i=2*t-100+3*s+.2*s*s+.1*t*s+.2*Math.sqrt(Math.abs(t));return(i+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3)+2*(20*Math.sin(s*this.PI)+40*Math.sin(s/3*this.PI))/3+2*(160*Math.sin(s/12*this.PI)+320*Math.sin(s*this.PI/30))/3},transformLon:function(t,s){s=300+t+2*s+.1*t*t+.1*t*s+.1*Math.sqrt(Math.abs(t));return(s+=2*(20*Math.sin(6*t*this.PI)+20*Math.sin(2*t*this.PI))/3)+2*(20*Math.sin(t*this.PI)+40*Math.sin(t/3*this.PI))/3+2*(150*Math.sin(t/12*this.PI)+300*Math.sin(t/30*this.PI))/3}};var _0x3f98=['screen','FLhUf','linzU','InfoWindow','BDMap','polygonOffsetUnits','Baidu_dark_blue','UhtoI','JpzVD','rVYSN','toolbar-yjms\x20disabled','boundary','ThreeLayer','Feature','TPuyB','showText','BaseLayers','ZoaxR','toolbar-zbz','#3f70bc','LeuGE','sortLayers','duration','labelTextAnchor','TBItemZoom','vertex','ZzFPf','BDLayers.Lib.Overlays.MultiPolygon','#34495e','Attribution','qJDRB','max','VBloomLineLayer','latMin','vectorTileLayer','enableClip','layer','SQOES','DpmYX','zbz','sADjc','markerSymbol','_sub','dcHSz','Zyvaa','oMFVw','TBItem','attackarrow','endEdit','Geom','ZwJEq','RcRwA','features','statusURL','dragend','BfHSr','http://172.29.9.30:13000/point.png','2|4|0|3|1','xXSoa','TCOKL','kspfP','MXWDS','http://webst0{s}.is.autonavi.com/appmaptile?style=8&x={x}&y={y}&z={z}','PeEHU','XgRqT','ZkNbG','dKpKH','markers','[object\x20Array]','enableSimplify','blayer_geoq_v','preset-vt-3857','kkuWa','vectortilelayer','RFajQ','aRALv','123','iLOZD','linestring','Mesh','HNSxN','MCopW','EIwAR','toolbar-sf','wDeQy','changemodel','_round','split','dAmEZ','TargetDiv','BDLayers.Lib.Overlays.MarkerIcon','dEcrf','DMuKy','isRotating','ng:ng_print_bg','comp','kXukx','bloomPass','VwPvS','Color','GeoQ_StreetWarm','GhRlp','BDLayers.Lib.Layer.CBMVTLayer','Circle','MmkuM','getPrototypeOf','\x22\x20style=\x22font-size:\x20','http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=','sNnAS','VWaterLayer','blue','QGtlx','TBItemMapInitialState','crs','DoubleSide','arcline','gEkUR','ajBvV','rrqts','addPass','dPIxx','_isCoord','iqBzm','TileLayer','zbTrL','csOuA','+proj=longlat\x20+datum=WGS84\x20+no_defs','real_time_url','clear','CTGIB','touchZoom','EXhjB','Fvfpn','changeModel','_callbackBaseObjectAnimation','closePosition','JWXBL','getGeometryById','mapId','UXhiK','CLHih','data-bindClick','WPZdW','gIfQq','tileSystem','BDLayers.Lib.Overlays.MarkerBar','xKtcf','random','yjms','zoomend','jtts_traffic_normal_bdmap','bgcolor','containsKey','http://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}','control','ShjMY','jYtdh','error','wvZes','GeoJSONVectorTileLayer','2|0|3|1|4','dash','vlfel','overviewControl','nIEkU','active','toolbar-dw','bold','rgb(216,\x20115,\x20149)','emGGO','bind','.content-lng\x20input','JHfBL','DrawActiveState','lineSymbol','ANvCp','sWVVb','wgmvj','yiLLR','Ulhfo','BDLayers.Lib.Control.TBItemArea','drawControl','PlotSvg','yQMug','trim','oMXzr','info','fJDtK','hRbQN','IFJwt','MeshPhongMaterial','14px','请输入正确的纬度！','NMuUT','BWYkF','BufferGeometry','qqReE','getCompConfig','replace','MlXqp','登录信息错误','evUEn','uKqhm','highlight','nRIJr','_initOptions','uytiK','vmQOg','ArcConnectorLine','严重拥堵','setMask','textVerticalAlignment','IJkwD','fYKKf','pCHfG','_distance','http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer/tile/','bglinewidth','addCustomLayers','mpwDL','qeNHg','updateSymbol','addMeshToLayer','BDLayers.Lib.Layer.AMapGCJ02Layers','PMvkO','BujlX','TBItemDark','regItemClickExtendHandler','uOjno','rUrKQ','.maptalks-toolbar-vertical','Scale','drawLayer','removeMesh','delta','zIndex','vector','hZtZu','+proj=longlat\x20+datum=GCJ02','fromGeometry','NbcSZ','ItxmM','aTMad','mXkmO','pSIOM','textureUrl','Bipqk','MeshBasicMaterial','Vector2','bKTVB','jxUSP','KgchS','KYuFZ','UdpLo','addMesh','toThreeVectorTileLayer','aWICh','sguWX','kKXvW','<div\x20class=\x22','wPJYS','#41a6ec','prepareToDraw','arcarrow','RxTQL','lightgray','BDLayers','xgYnl','omtHm','slice','AmbientLight','BDLayers.LibViz.Layer.MVTLayer','tbitem_','textStyle','cancel','MarkerPopBg','pZBfP','ooqVn','HBFOu','HHlHx','msSaveBlob','tag','ocHMe','gxIKd','zQPcX','vertexShader','sqrt','dZNON','vUYDn','lPaNg','setCenter','matrix(1,0,0,1,200,200)','img1','renderToScreen','SYlqC','getGLRes','radius','kYBoJ','Util','stringify','HyuYq','json','CHdMu','BDLayers.Lib.Overlays.MarkerText','watersAll','Amap','anisotropy','sthYn','wrapT','UupeF','yvrKC','wgAPB','LDDDl','#DrawPop','QLPto','remove','lat','lSNWo','userData','tbitem_dark','containsPoint','qkHZa','YhcmY','username','EsnRR','setBearing','eNyiC','PZfoZ','tFKEx','],\x0a\x20\x20\x20\x20\x20\x20\x20\x20<br/>即:\x20东经','left','charCodeAt','getMode','gpFaE','ICTNG','getImageData','addMarkers','fOGrh','PIcSG','vWCXY','lineStyle','beige','Vqxks','setCoordinates','cusTileURLHandler','toDataURL','markerHeight','OhOHm','setId','kdbRZ','BayPX','innerHTML','SkyBoxLayer','areaControl','toolbar-cj','BaseObject','ZmTfU','removeMarkers','qHMth','BDLayers.Lib.Control.TBItemMagnifier','fdj','VMQgd','cszt','WwVZw','BDLayers.Lib.Layer.AMapLayers','kMfLU','KSY','HoENi','IZpAH','fontAltitude','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>','TjPMQ','VCGfo','parentNode','MWMYQ','zWhmp','pitchWithMap','\x20.toolbar-wx','BDLayers.LibViz.Layer.VMarkerLayer','marker','MEWyI','cQJza','<li\x20id=\x22toolbar-jtts\x22\x20class=\x22toolbar-jtts\x22\x20title=\x22交通态势\x22></li>','rgb(135,\x20196,\x20240)','lngMin','_createGroup','EJuVf','textFill','QlMxE','createBaseMapTools','EJiQc','xtjhY','pOgvh','#00FF7F','sxmdj','GeoQGCJ02Layers','drawend','http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}','sOmzV','maptalks-toolbar-compass-row','MCrMi','RpVRG','gARRx','textWrapCharacter','TwoNh','GeoQ_Community','setSceneConfig','sAVYX','class','composer','ceBzc','TzoiSswT9rWYy67VNq7CtnYPtzbcFS0C','dunVa','getSymbol','browserType','LineBasicMaterial','yIDSm','GJcNv','mapModelControl','streetBlue','aptKE','ohjeT','bYExa','zxRXo','PBAcb','FJXYd','value','rYBOj','_zoomLevel','MNaFG','MapFromJSON','dZqgi','toolbar-cmj','NGZvz','cKVhJ','hYlLJ','buSJO','mouseup','MarkerText','mapInitialState','AreaTool','isVisible','polygonOffset','MainMap','ViAHU','ConnectorLine','getFirstCoordinate','bloomEnable','qvNaU','purple','toolbar-dtdy','#FF0000','animateTo','maptalks-toolbar-vertical','draw','SkEvC','blayer_tbmap_s','.png','Point','JMZui','3\x22></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20',';border:1px\x20solid\x20#0c2c45;\x20padding:\x2010px\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09','zZUaa','markerLabel','rotation','records','TBItemArea','FTKcM','layerName','blayer_tdt_v','itemNavAll','XnaRo','dragPitch','XqhGo','vCODa','toolbar-nav','skiQp','horizontalAlignment','straightline','round','BDLayers.Lib.Overlays.Ellipse','QpMnd','FCskL','must\x20provide\x20a\x20valid\x20fromCRS\x20and\x20toCRS.','FvlPF','tuqvO','maptalks-toolbar-pitch-top','Yswdv','GeometryCollection','event','#f00','.DrawRectangle','properties','buzbB','ndpvI','Jtybb','OPwqB','FeatureCollection','#068bff','rWaFa','normal','AMapLayers','mapWrapper','fWRlV','shadowColor','number','src','Gwgbf','auto','elvrY','\x20.maptalks-toolbar-hx\x20.toolbar-','click','srzzw','BDLayers.Lib.Control.TBItemMapPrint','getProperties','TBItemClearAll','get','BDLayers.Lib.Overlays.CubicBezierCurve','RbpPl','30%','maptalks-toolbar-compass','services','GCeyI','BDLayers.Lib.Overlays.Label','lightred','renderPass','CRojA','https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILECOL={x}&TILEROW={y}&TILEMATRIX={z}&tk=','getToken','+proj=longlat\x20+datum=BD09','oeHbq','EsHYs','QBKMj','#b4b3b3','Vqngg','isAnimateShow','isEnabled','JiAyN','fIPBm','HeatLayer','target','qoxwo','svhDO','maptalks-toolbar-app','doubleClickZoom','njWQz','gDfyC','DirectionalLight','MiPcf','njDmq','finally','dvalue_lat','distanceControl','altitude','UIKgX','TGSAL','requestFullScreen','AJfSB','_glSence','nOVPi','always','CVWPz','ovqFY','ringeff','link_direc','QCrRk','NVIge','hasClass','arraybuffer','setActiveStyleSheet','removeStateLW','getSize','done','myellow','uSXdH','bQQyG','identity','pitch','time','http://172.29.9.30:13000/print-image/','bloom','getObject3d','DrawBoxactive','CBTileLayer','labelTextLineSpacing','document','nightMode','getLineMaterial','BDLayers.Lib.Control.TBItemMapModel','EPSG4326','intervelLines','surl','animationName','DrawTool','trajectoryCancel','straightarrow','minHeight','getContext','HxkBM','kWhTr','OrfCw','mouseover','YLThz','OiPrP','image/tiff','handlers','zvcBv','#none','VNItc','geometry','HCaKt','jsdTL','nAgzo','LOrFE','setPitch','TmQEN','mouseenter','MapView','normalize','ZqVSE','UAhHQ','popWindow','uKjZu','blayer_baidu_s','MTvWf','QJUsP','Vector','VZnIQ','eOJBl','minZoom','toGeometry','″，北纬','min','ApzyN','mdZRB','Polygon','mySvg','lrFws','zCGEn','xxYrf','toolbar-yjms','http://api{s}.map.bdimg.com/customimage/tile?&x={x}&y={y}&z={z}&customid=','tbitem_overview','BxJkJ','div','<div\x20class=\x22markerIconDialog\x20content\x22\x20style=\x22color:#000;width:\x20max-content;\x20height:\x20auto;\x20max-width:\x20350px;\x20background-color:\x20','DyUXq','getItem','copy','log','data','nyMbO','KwIpP','QYZsk','querySelector','iIlOm','naRBI','yuZqv','parse','GkqIN','fullScreenControl','ikkns','llkvB','CBDrawTool','dZFpx','href','getProjection','HildU','xnApW','TileBaseLayers','TBItemDistance','kZuvZ','isMoving','BDLayers.Lib.Layer.CBVectorClusterLayer','appendChild','hHnXK','uejpx','block','streetGray','保卫部制','rtGwV','ThHxL','body','SvgText','tbitem_magnifier','layermodal','Geometry','drawstart','http://online{s}.map.bdimg.com/onlinelabel/?qt=tile&x={x}&y={y}&z={z}&styles=sl&p=1&v=083&udt=20210809','BaseLayerType','lqnom','context','BDLayers.Lib.Layer.CBLayer','PDYyy','lmGNW','QYikT','cssFilter','.maptalks-close','HkgQl','Sfzaq','pnfau','../img/marker.png','polygonFill','012','point','uzZEz','foo','VHlUS','toHashCode','dataload','{z}/{y}/{x}','vqRru','JtMgR','IojLU','CBParticleLayer','zoomDiff','SJTDO','100','removeLayer','maptalks-toolbar-horizonal','VxuKL','isZooming','setSize','zEMfG','CRSTransform','sAXmX','dragPan','coordinateToVector3','content','getOptions','maptalks-scale','labelTextColor','message','removeGeometry','Baidu_dark','updateDataConfig','bd09ll_gcj02','mxSYL','getExtent','BDLayers.Lib.Overlays.MultiPoint','autoPan','dJzfG','Constant','trajectoryRemove','RingBufferGeometry','ewigX','rurze','uiMarker','proj','?format=','cos','black','dark','<div\x20class=\x22ui-marker-pop\x22\x20style=\x22position:\x20relative;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','BDLayers.Lib.Layer.GeoQGCJ02Layers','#FFFFFF','vertexShaderSource','setMenu','monospace','http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer/tile/','ymin','toolbar-sqdw','womMz','onclick','CBGroupGLLayer','IjyTG','zSPfU','wcHOK','RMhdY','PcVht','transform','targetDiv','SdmWR','HnOLA','tyLLP','EPSGB3857','FSToP','createImageData','BDLayers.Lib.Layer.CBGroupGLLayer','MwAvX','ucyPU','color','outLine','lineWidth','setToRedraw','px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20left:\x2050%;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20transform:\x20translateX(-50%);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20width:\x20','wYotJ','AdNGT','bringToFront','addLayer','congestion_level','addEventListener','iUkVs','http://shangetu{s}.map.bdimg.com/it/u=x={x};y={y};z={z};v=009;type=sate&fm=46&udt=20210809','isIconChangeToMap','x_pi','tavnY','removeAll','toolbar-yjms\x20active','HSGzp','dispose','isInteracting','jSXOs','TpRtM','ijVkT','toExtrudePolygons','auEzS','CwWmY','GLTFMarker','rkmXj','cmj','eQXHZ','fill','REguU','rIyie','middle','FVPVh','kIUxG','EPSG:3857','zQhFt','strength','itemClick','ygGAl','MiDqY','qPYjC','BcAXW','scaleControl','PFGCN','tnTem','zoomIn','Line','#1bbc9b','switchLng','http://t{s}.tianditu.gov.cn/DataServer?T=cva_c&x={x}&y={y}&l={z}&tk=','setProperties','clip','bdwkc','subdomains','bottom-left','坐标:\x20[','tbitem_area','DSVgC','FGTGm','IqHqG','insertAdjacentHTML','Clone','toGeoJSON','svgPath','Baidu_light','QqDbG','threshold','deg)\x20rotateZ(','tWQIm','IwKla','Tianditu','dragShadow','pin','DistanceTool','AUMtE','Ellipse','qWqZO','initComponent','点击切换工具栏方向','fmiNI','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20float\x20time;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20vec3\x20color;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20float\x20type;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20float\x20num;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20varying\x20vec2\x20vUv;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20void\x20main(){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20float\x20alpha\x20=\x201.0;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20float\x20dis\x20=\x20distance(vUv,vec2(0.5));//0-0.5\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if(dis\x20>\x200.5){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20discard;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if(type\x20==0.0){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20float\x20y\x20=\x20(sin(6.0\x20*\x20num\x20*(dis-time))\x20+\x201.0)/2.0;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alpha\x20=\x20smoothstep(1.0,0.0,abs(y-0.5)/0.5)\x20*\x20(0.5\x20-dis)\x20*\x202.;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}else\x20if(type\x20==1.0){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20float\x20step\x20=\x20fract(time*\x204.)*\x200.5;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if(dis<step){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20alpha\x20=\x20smoothstep(1.0,0.0,abs(step-dis)/0.15);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alpha\x20=1.-\x20abs(step-dis)/0.15;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}else{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alpha\x20=\x20smoothstep(1.0,0.0,abs(step-dis)/0.05);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20alpha\x20*=\x20(pow((0.5\x20-dis)*\x203.0,2.0));\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20gl_FragColor\x20=\x20vec4(color,alpha\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}','EdgesGeometry','iconSize','renderer','hWqJZ','GeoJSON','viewboxWidth','QUbBd','组件服务需要配置服务登录信息，请配置登录信息','ptDZl','hxzVr','NBufl','FfZCg','CBXQS','stroke-width','juxingqi','zoomControl','joIxI','saveToken','YaMsw','dnYJz','loaded','enable','hyhJU','hikVu','SlbrT','TextureLoader','rotateX(','rujgZ','ItQjF','CBLayerType','UpNQT','includes','coordinate','maptalks-toolbar-compass-box','TOLwk','TiandiTu4326','KRpaT','GeoQ_Community_GCJ02','_clearTailMarker','setZIndex','getMap','Unable\x20to\x20copy\x20obj!\x20Its\x20type\x20isn\x27t\x20supported.','tbitem_mapTraffic','name','DGbzL','\x20.toolbar-dw','createObjectURL','obj','PFpDJ','getDefault','OYaar','stroke','uahEq','set','YinGY','brGlP','Panel','symbol','BDLayers.Lib.Layer.CBImageLayer','BDLayers.Lib.Overlays.FromGeoJson','mesh','urlTemplate','VectorLayer','setOptions','KbrQa','addExtrudePolygon','YBmLZ','TGFlu','FreeHandLineString','can\x20not\x20find\x20layer\x20','extend','padding','导出图片','xpYCk','DRIxg','eventsPropagation','filter','light','wezaZ','tbitem_exportImage','material','toLowerCase','KSlKe','gNSCA','XFSBS','layer_geoms','QEtXC','Svg','请配置地图打印服务','ekCoq','TBItemNav','qdoXH','iTime','cbarcgistilelayer','autho','shadowBlur','sub','computeFaceNormals','KLMoK','phzlp','NgRtq','setItem','WebMapKeys','ShaderMaterial','ioGdk','tbitem_position','lzWsS','knUSM','splnN','_isArray','LineString','PuxQc','EPEoO','congestion_colour','seamlessZoom','qgGcv','plAYJ','oGaox','ellipse','mapTraffic','array','fitExtent','TrCAo','toString','trajectoryPlay','yvonw','Tools','interactive','subType','setRendererRenderScene','SxkwG','QyjRj','RjvGg','ljXuO','_toCRS','isArray','Bddel','TextBox','containerlng','klToM','uupEV','tilebaseOpt','IBFPX','hiOSl','_extend','ZWXCt','dst','drawendGeom','GeoQ_StreetGray_GCJ02','blc','EPSG:4326','visible','afaLh','initialize','wgCAV','removeMarker','toolbar-qchz','wMjJP','SYMJP','M\x20227,91\x20V\x20705\x20M\x20227,91\x20H\x20718\x20V\x20336\x20H\x20227\x20Z','RdBdn','link_congestion_colour','JljgN','result','minzoomv','zmjjd','textHaloFill','maxzoom','JaubM','Marker','\x0a\x20\x20uniform\x20vec3\x20\x20\x20\x20\x20\x20iResolution;\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20viewport\x20resolution\x20(in\x20pixels)\x0a\x20\x20uniform\x20float\x20\x20\x20\x20\x20iTime;\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20shader\x20playback\x20time\x20(in\x20seconds)\x0a\x20\x20uniform\x20sampler2D\x20iChannel0;\x20\x0a\x20\x20uniform\x20sampler2D\x20iChannel1;\x20\x0a\x0a\x20\x20const\x20vec3\x20waterColor\x20=\x20vec3(.1,\x20.6,\x20.9);\x0a\x0a\x20\x20void\x20mainImage(\x20out\x20vec4\x20fragColor,\x20in\x20vec2\x20fragCoord\x20)\x0a\x20\x20{\x0a\x20\x20\x20\x20\x20\x20vec2\x20uv\x20=\x20fragCoord.xy\x20/\x20iResolution.xy;\x0a\x20\x20\x20\x20\x20\x20vec2\x20growingUv\x20=\x20sin((uv\x20+\x20iTime\x20/\x2020.)\x20*\x203.);\x0a\x20\x20\x20\x20\x20\x20vec2\x20uv2\x20=\x20texture2D(iChannel0,\x20growingUv).rr;\x0a\x0a\x20\x20\x20\x20\x20\x20fragColor\x20=\x20vec4((1.\x20-\x20texture2D(iChannel1,\x20uv\x20*\x200.95\x20+\x20uv2\x20*\x200.05).rgb\x20*\x20(1.\x20-\x20waterColor)),\x201.0);\x0a\x20\x20}\x0a\x20\x20void\x20main(){\x0a\x20\x20\x20\x20\x20\x20mainImage(gl_FragColor,gl_FragCoord.xy);\x0a\x20\x20}\x0a\x20\x20','yXHza','hasOwnProperty','curve',';\x20position:\x20absolute;\x20bottom:\x20-20px;\x20left:\x2050%;\x20transform:\x20translateX(-50%)\x22>','CubicBezierCurve','addMarker','px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background:\x20','showHeight','logicalXDPI','JsVBh','blob','WfIzj','maptalks-overView','FJhHK','PlHsi','_transformCoordinate','1.3.0','ULKjC','confirmbtn','lastIndexOf','hasDarkLayer','WQlFL','NQksS','OLtAE','point_label','QaMPi','toLayer','BDLayers.Lib.Overlays.ConnectorLine','{name}','rgb(135,196,240)','Vector3','vertexColors','tokenHelper','cadetblue','BackSide','ZcfES','AwesomeMarker','maHmr','hmSFY','YjGdk','YXhuD','XnOiz','qeGsg','ZJhlU','.content-lat\x20input','xneg.jpg','_createMesh','GnBVJ','circle','_jsonType','01234567','BDLayers.Lib.Overlays.Rectangle','BDLayers.Extend.TBItemMapTraffic','gPFsC','sqdw','childNodes','QZPCa','.tif','kADgU','concat','Class','ombNu','yzifs','AUIlr','center','showCenter','jufXz','MCkXR','.markerIconDialog','KGoek','BDLayers.Lib.Overlays.AwesomeMarker','_clearMeasureLayers','oGsSs','UXvvN','linear','EPYRA','UtqOn','initialState','c24621295f4390b169da48d990e4bcbe','fAVeo','PkASa','removeClass','iaPYS','match','undefined','coordToPointAtRes','CZVxG','setZoom','IGuQr','IgEfK','#1e80f0','fvalue_lng','ccrYT','ATiYW','addControl','getAttribute','inputlat','projection','ybwWm','downloadURL','startEditText','vbUbB','BDLayers.Lib.Overlays.MarkerSvg','D3Layer','simplifyTolerance','vXIbm','dByFD','rotated','labelText','animateShow','gcBFx','Event','BDLayers.Lib.Control.TBItemMapTraffic','removeInfoWindow','toEx','gUyrs','BDLayers.LibViz.Layer.HeatLayer','DGaSO','拾取点位','toolbar-yy','MultiPolygon','maptalks-toolbar-bearing-left','NMLnl','KQpOr','function','VsPph','LtkuU','rotationAngle','2\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22','地图打印','CBLayer','stats','axios','distanceToVector3','RXYyn','Baidu','CBGLTFLayer','RepeatWrapping','geojson','xwwvS','fontColor','指北针','SXYfs','editable','vWOvg','yiHix','CBVectorClusterLayer','BDLayers.Lib.Control.TBItemScale','labelSymbol','aZblU','ulbIs','.maptalks-toolbar-hx','wrap','setContent','getMask','STXpb','nIEYq','canvas','geom','initBloom','getRenderer','gbayO','.maptalks-attribution','getLayers','labelTextSize','normal_url','trafficSituation','YAxId','QOqbI','init','BsuMc','eWJdk','qhJqH','tmHus','yDKDz','afWXG','enableAltitude','xmax','NeNEK','blayer_amap_v','pRjnX','selectable','vTFjM','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20varying\x20vec3\x20vWorldPosition;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20void\x20main()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20vec4\x20worldPosition\x20=\x20modelMatrix\x20*\x20vec4(\x20position,\x201.0\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20vWorldPosition\x20=\x20worldPosition.xyz;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20gl_Position\x20=\x20projectionMatrix\x20*\x20modelViewMatrix\x20*\x20vec4(\x20position,\x201.0\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}','4055b59f8241403a5944a9a87566e868','height','_blank','lngMax','Pshwt','TileMatrixSet','addGeometry','JPpcV','lwtBj','daQfo','maptalks-toolbar-drag','SMpVf','JrpyJ','SszTg','USE_DASH','containerPoint','ImageLayer','isbloom','zhfdK','&password=','MlirL','bSzIN','inputlng','Options','nvUrQ','labelTextHaloFill','iconType','JAedU','BDLayers.Lib.Layer.CBArcGISTileLayer','mrKqB','toFixed','PqYjO','BDLayers.Lib.Overlays.UIMarker','ArcCurve','PwQfu','rpUvI','inherit','DlkxB','PvQMA','getMaterial','linewidth','swXMK','WyAXT','maptalks-toolbar-icon','XEeTC','QrsIR','TBItemMapTraffic','缩放与指北针','lights','\x20.toolbar-cmj','_isNumber','xHaBT','WtOVR','xgtke','jpgUs','24px','pdf','then','bdmap','PjqWE','blayer_tbmap_v','ubGmR','polygonOffsetFactor','#000','MHSvR','/{z}/{y}/{x}','ZtDkl','camera','markerCoordinates','kDYhS','iySTe','heat','dashcolor','\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22','autoPanDuration','JbUyg','sceneConfig','selectDraw','cJOUH','single','Raster','markerStyle','zoom','textBox','zQEOT','smoothness','uMvDb','loadStateLW','path','FbEBB','LayerFromJSON','_bindMap','CBArcGISTileLayer','ebcCq','[name]','yQjJV','blayer_baidu_vdark','style','url','setStyle','BbRDa','tbitem_draw','texture','3|1|0|2|4','img2','<div\x20class=\x22position-content\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22title\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div><div\x20class=\x22icon-position\x22></div>定位</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20id=\x22closePosition\x22\x20class=\x22closeDraw\x22></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22content\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22content-value\x20content-lng\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09经度：\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div><input\x20class=\x22modal-input-po\x22\x20id=\x22inputlng\x22\x20type=\x22text\x22\x20value=\x220.0\x22\x20data-initialValue=\x220.0\x22/></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22modal-input-box\x22\x20id=\x22containerlng\x22\x20data-type=\x22digit\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22dvalue_lng\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>°</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22fvalue_lng\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>\x27</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22mvalue_lng\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>\x27\x27</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22tvalue_lng\x22\x20value=\x22E\x22\x20data-initialValue=\x22E\x22\x20disabled=\x22disabled\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22switch\x22\x20id=\x22switchLng\x22><div></div></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22content-value\x20content-lat\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09纬度：\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div><input\x20class=\x22modal-input-po\x22\x20id=\x22inputlat\x22\x20type=\x22text\x22\x20value=\x220.0\x22\x20data-initialValue=\x220.0\x22/></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22modal-input-box\x22\x20id=\x22containerlat\x22\x20data-type=\x22digit\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22dvalue_lat\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>°</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22fvalue_lat\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>\x27</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22mvalue_lat\x22\x20value=\x220\x22\x20data-initialValue=\x220\x22><label\x20class=\x22dmslabel\x22>\x27\x27</label>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<input\x20type=\x22text\x22\x20class=\x22dmsvalue\x22\x20id=\x22tvalue_lat\x22\x20value=\x22N\x22\x20data-initialValue=\x22N\x22\x20disabled=\x22disabled\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22switch\x22\x20id=\x22switchLat\x22><div></div></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22tip\x22\x20id=\x22positionTip\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22btn-commit\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<button\x20type=\x22button\x22\x20class=\x22btn\x20btn-primary\x22\x20id=\x22confirmbtn\x22>确认</button>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>','RApVh','layerid','kMsdZ','ygrxh','defines','gVXmZ','filesToPath','UMyad','arc','getBaseLayers','fupFf','printByMapfish','closeInfoWindow','ALyDe','http://map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/','Nnsch','BysbX','nqOfI','white','VGKEp','renderScene','textSymbol','IuAQl','<li\x20id=\x22toolbar-dtdy\x22\x20class=\x22toolbar-dtdy\x22\x20title=\x22地图打印\x22></li>','ICRhI','TianDiTuLayers','defaultSence','fileToPath','EaKUq','EoEsv','YRahq','fromJSON','OEBQa','transformLon','BDLayers.Lib.Overlays.VMarkerRingEff','finish','en-US','GroupGLLayer','outOfChina','layer_markers','uaGqH','compWrapper','hGfXn','children','_center','getHours','0px','forceRenderOnRotating','line','onblur','RFPgA','ECfsZ','mVIiK','setMinZoom','DynwM','\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22arrow\x22\x20style=\x22position:\x20absolute;\x20bottom:\x20-8px;\x20left:\x2050%;\x20transform:\x20translateX(-50%);\x20width:\x200;\x20height:\x200;\x20border-left:\x209px\x20solid\x20transparent;\x20border-right:\x209px\x20solid\x20transparent;\x20border-top:\x209px\x20solid\x20#fff;\x22></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x20</div>','gcj_encrypt','getThreeRenderer','cbgbH','feature','append','Release\x202.0','openMenu','QuzZD','revokeObjectURL','vIUGE','gcj02_wgs84','count','BDLayers.Lib.Layer.CBCanvasLayer','gzlXC','waters','play','MVTLayer','TBItemScale','PROJECTION','mBWua','rel','Jkigt','display','endAngle','extrudePolygons','qFhvF','JNKcc','NfQUq','Layer','mxzIi','QiEcI','BDLayers.Lib.Overlays.GeometryCollection','polygon_curved','getDrawMode','maptalks-toolbar-click','blayer_tbmap_d','TpbPk','NLtWW','ArvkQ','TBItemPosition','无夜间模式','DrawState','boxStyle','export','BSPoG','MultiLineString','getFullYear','TYPVV','nrWaC','QbkBf','BaiduLayers','tCfqP','cancelFullScreen','dragRotate','computeVertexNormals','kDAsG','IAIRv','textSize','SCekb','render','spatialReference','openInfoWindow','.DrawPoint','SOnKn','text','CYoDT','CIdNM','autoClear','http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=','Label','BDLayers.Lib.Overlays.Sector','Xfapi','KQIca','JAzAF','playing','BDLayers.Lib.Overlays.TextBox','SGtAQ','CmaGM','toolbar-wx','交通态势','substring','baseControl','mapPrint','vMFTx','CanvasLayer','flatarrow_curved','tbitem_fullScreen','obsBH','putImageData','strokeStyle','sSaPM','UQqdu','WoTnj','Nhpop','img','BDLayers.LibViz.Layer.VBloomLineLayer','MarkerSvg','GgnDs','UIMarker','NpkPj','itjoK','pause','azywS','BDLayers.Lib.Control.TBItem','gEZSI','sxfRt','BcpYS','qAtkG','UjmRM','PointLayer','normal_road_url','forEach','rEBru','srcElement','VpLMW','needsUpdate','Krxql','hide','pCYec','getBuildingsMaterial','mNggX','deviceXDPI','gTXDL','position','TBItemExportImage','arrowPlacement','BDLayers.Lib.Layer.CBParticleLayer','tbitem_zoom','tbitem_nav','lon','ZDZxA','markerFill','ymhdZ','level','rCFlb','kYrLq','_id','wujiaoxing','getBearing','markerLineWidth','labelTextAlign','TBItemDraw','Rectangle','drawImage','OLRuo','XOguW','BDLayers.Lib.BDMap.MapView','Lib','maptalks','UrQnA','nav','MDRZQ','isDisabled','rotate(180deg)','getId','AhObj','BDLayers.Lib.Layer.CBGLTFLayer','bzyoj','object','jBBTp','Phpsr','BDLayers.Lib.Overlays.Circle','Swvcb','azhNH','CBGeoJSONLayer','dsq','XoEas','http','gAzuL','date','EPSG3857','ZSTEA','test','labelTextVerticalAlignment','fromBufferGeometry','Zoom','gcj02Offset','login','http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/','disable','satelliteTileLayer','toJSON','pFlYQ','32px','setMap','ofwWB','DoDLm','HApwp','TBItemMagnifier','EzIvf','VNviI','anGbp','dgwFs','setUnitTime','forceRenderOnMoving','blayer_amap_s','vertical','ydeSc','blayer_geoq_vstreetBlue','setTime','Coordinate','rotateWithMap','Interactions','markerFillOpacity','ccoPI','FsNJS','line&dash','mtxji','MXPwD','isLoadTexture','ZgRdr','OxExb','OfLBW','恢复地图初始状态','LuogQ','transparent','MultiPoint','BDLayers.Lib.Overlays.ArcCurve','OXdFC','HQbug','XwCOY','\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22arrow\x22\x20style=\x22position:\x20absolute;\x20bottom:\x20-8px;\x20left:\x2050%;\x20transform:\x20translateX(-50%);\x20width:\x200;\x20height:\x200;\x20border-left:\x209px\x20solid\x20transparent;\x20border-right:\x209px\x20solid\x20transparent;\x20border-top:\x209px\x20solid\x20#fff;\x22></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x20</div>','flatarrow','jtts_traffic_bdmap','xMxvW','tezNE','BDLayers.Lib.Control.TBItemZoom','YNzPq','MgdGn','background','TiZbV','0.7','nokym','DKOpe','FDdep','kcaPK','popBackgroundColor','querySelectorAll','CLASS_NAME','eventsToStop','constructor','wOZEr','textHaloRadius','wgs84','animationDuration','xLpDx','FkItu','AxiiI','2|3|4|0|1','bdinfo','prototype','stylechanged','TGrBM','onfocus','sJmKN','Huqdn','getElementsByClassName','abs','QuadBezierCurve','timeEnd','urls','getElementById','dot','Overview','edittextend','pointer','streetWarm','options','\x20.toolbar-hz','lLGLf','width','create','stlqB','transformLat','getElByClass','nsiSD','browserInfo','_eachCoordinate','YMuSU','VVsbb','.apptitle','created','tbitem_mapModel','tbitem_clear','loginSystem','juxing','switchLat','setBaseLayer','toolbar-qp','olVhS','setZoomOnAdded','Control','mousemove','bearing','completeRender','0.0','darkTileLayer','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22ui-marker-pop-show\x22\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20style=\x22position:\x20absolute;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20block;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20top:\x20-','polygon','.DrawPolygon','infoWindow','PrDuy','lng','fMgnG','AMapGCJ02Layers','unshift','verticalAlignment','imgurl','GeoQ_StreetGray','BDLayers.Lib.Layer.CBTileLayer','tRqfm','WXTsg','TiandiTu','darkred','<div\x20class=\x22position-content\x20print-content\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22title\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div><div\x20class=\x22icon-print\x22></div>地图打印</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20id=\x22closePrint\x22\x20class=\x22closeDraw\x22></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22content\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22content-value\x20content-lng\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09打印文件名称：\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div><input\x20class=\x22modal-input-po\x22\x20id=\x22inputlng\x22\x20type=\x22text\x22\x20value=\x22\x22\x20data-initialValue=\x22\x22/></div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22tip\x22\x20id=\x22printTip\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22btn-commit\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<button\x20type=\x22button\x22\x20class=\x22btn\x20btn-primary\x22\x20id=\x22confirmPrintBtn\x22>打印</button>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09</div>','_triggeringCount','config','baidu','maptalks-toolbar-hx','linesAll','pTlHX','wrapS','EFpoe','isFlicker','VGMJZ','RenderPass','classList','maxzoomv','mred','red','bJWax','trigger','uniforms','xmin','AEhKZ','coordinates','withBox','def_markerlayer','TBItemFullScreen','ioLXf','addClass','rgbToHex','defaultZoom','SDoRr','pmvTA','repeat','TRplt','right','TrXNG','child','loadtileset','TBItemPickPoint','traffic','getMaxZoom',';border:1px\x20solid\x20#0c2c45;\x20padding:\x2010px\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09','zsehC','Map','TileBase','download','getDevicePixelRatio','#d31919','bubblePath','link_name','siEjE','getStyle','animate','beginPath','qEirP','_viewHistory','item','vUOmG','中度拥堵','TBItemCompass','-36.0','call','1\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22','KpKuM','RlIpv','SezIo','maptalks-toolbar-pitch-bottom','BDLayers.Lib.Control.TBItemOverview','BDLayers.Lib.Control.TBItemFullScreen','controlList','setTerrain','markerLineColor','zClyp','itemnav','toolsShow','className','CUPsZ','loadTrajectory','CRjHJ','getZoom','xVSBP','_animation','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>','WWURS','gcj02_bd09ll','KqYwL','Elevation','PUdWn','isFullScreen','gaPEa','hWFrV','brnxO','pdHzT','ZhWSs','textContent','RQMce','VMarkerRingEff','CodWV','iCupo','URL','xhXAq','sXLtw','kkznq','MvfAZ','apply','ztzoh','geoqTypeUrl','Overlays','load','sans-serif','marker0','push','BDLayers.Lib.Control.TBItemCompass','xTKLF','BDLayers.Lib.Overlays.Polygon','pBfgQ','PuCSA','mapView','iKOHp','nBrQd','yIuSR','exportImage','Nmdcf','maptalks-wrapper','fUDGs','drawOnAxis','#fff','offset','TileSystem','TRNpu','vAjgs','QqCqE','iconAnchor','jTGIG','LineMaterial','deg)','ZaUPR','OkBdp','ohuRz','Blank','textCoordinates','tImAu','RXiBz','OJhIS','animationColor','Satellite','lbSqv','DrawFinishFlag','catch','createElement','TlQnL','zpos.jpg','VPUAI','getElementsByTagName','markerType','ZzAWC','CBVectorLayer',';\x20color:\x20','xfBTd','distanceToPixel','orange','EuWcu','vadYO','dian','LineSegments','getTileData','tbitem_pickPoint','CBMVTLayer','jXVuW','mode','toFat','getMateriral','CBWMTSLayer','DgWhX','aZJvk','eiLQF','animation','LdZuN','getMarker','DWAby','DrawDiv','markerWidth','magnifierControl','_needsUpdate','maxAvailableZoom','rsdXP','lxUqC','textFaceName','QntYb','wDfpu','layers','minzooms','200','startEdit','mouseout','bPpdQ','VpzUO','oxkvO','PJGRI','atan2','link_congestion_level','fXnDO','pickPoint','KRyjW','caXKh','toolbar-jtts','nXsYm','getMonth','轻度拥堵','nGODb','AgFED','LIgvf','WTBds','fzceF','MNpzu','AbAnS','sJNSt','QRdHy','Extent','bubbleAnchor','LibViz','title','BuPhW','sin','getCoordinates','handledragging','UJdQq','setAttribute','fcSbv','colour_code','buildingTopColor','ecTmn','QcOXx','setSymbol','top','HEQRT','BDLayers.Lib.Layer.BaseLayers','MarkerImg','arcDegree','BaseLayerModel','SHgSO','bsTpE','rgEtf','imgUrl','coordinateToContainerPoint','getMinZoom','nYTiD','yneg.jpg','GrNVE','removeDomNode','oxucz','real_time_raod_url','VertexColors','请输入正确的经度！','DGgAe','maptalks-toolbar-bearing-right','zISPe','UuMue','midnight','EdPNJ','WGS84','SGaNv','DpokN','YySEx','GMhfa','cancelHighlight','PrCXv','createCircleRadiusLine','BDLayers.Lib.Overlays.QuadBezierCurve','NYKHA','fSUQV','OoCYL','放大镜','bIBZb','http://172.29.9.30:8080','VlBuS','XVdRy','.toolbar-yjms','NQKEd','domElement','xqcJC','eeyFK','IlBKf','put','aaoGF','BDLayers.LibViz.Layer.VBuildingLayer','YUZZN','Evented','utlMK','#9999FF','IIVUM','values','showBubble','color_url','?username=','GvyDd','status','navigator','jsyRj','iconName','loadNormalLW','JiPnQ','square','setTextSymbol','fragmentShaderSource','devicePixelRatio','disabled','Toolbar','YlOqE','PointText','FSpJV','MarkerIcon','whxEM','maxZoom','getStyleFormType','mapModel','removeChild','loadingLimit','JBTHA','UblVq','getPitch','FzfnU','vNMuh','OlJrQ','dkZHM','EvVxn','NvnNg','PfPJg','zeJcn','textWeight','getCenter','toHex','postProcess','UoRxT','oUUFk','lbzhL','jKJLx','OdrLD','rotateFlag','BDLayers.Lib.Control.TBItemMapInitialState','fAKvb','jTIvY','bubbleColor','blayer_tdt_s','geometries','IcHkt','shade','getPropertyValue','SVdUd','labelTextHaloRadius','getGeometry','KsYNm','iconColor','ZZfDE','baseLayers','bLvZt','code','3.0','arrowStyle','lineColor','aGEjw','LkcrU','nNJkE','showOn','EWBBC','renderend','compass','TBItemMapModel','oCDwe','\x20.maptalks-toolbar-hx\x20.toolbar-qchz','lightblue','mmQBH','/print-servlet-3.26.0/print/ng2/report.tif','MKZBM','tdMBj','interval','Extend','add','mapTool','opacity','gHiWy','VBuildingLayer','label','show','lOPGC','BSgFY','tSeaU',';\x20positions:\x20relative\x22>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09\x09<div\x20class=\x22label-text\x22\x20style=\x22font-weight:\x20bold;text-align:\x20center;min-width:\x20300px;font-size:\x20','isOutline','aVFdy','darkgreen','HyMwn','toArray','http://172.29.9.30:13000/bdmap-geoserver/ows?service=WMS','aZNPw',';\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x22ui-marker-close-btn\x22\x20onclick=\x22closeDialog()\x22\x20style=\x22position:\x20absolute;\x20top:\x2010px;\x20right:\x2020px;\x20color:\x20#000;\x20cursor:\x20pointer;\x22>X</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20','XzOWu','bringToBack','zh-CN','TNUOC','HRNGH','lines','speed','sanjiaoqi','nPeTg','ClusterLayer','lightgreen','itemClickExtendHandler','mapPrintUrl','AGHZQ','cblayer_','none','XSpWS','MultiLine','doublearrow','fontSize','BDLayers.Lib.Layer.GeoQLayers','draggable','indexOf','type','gQaPC','bbiTa','DDOim','PointLight','BDLayers.Lib.Control.TBItemDark','link_no','CBPointLayer','__proto__','labelTextWeight','addTo','arrow_curved','\x20BDLayers.Lib.Tools.CBDrawTool','printOver','kxSJt','getSeconds','XVNun','KCHzw','positionControl','JIHoq','xuVXh','NNoYH','outlineColor','pyXHg','GCJ02','gfphm','rTCDF','ngRng','GeoQLayers','fragmentShader','labelTextWrapCharacter','string','ZnuoK','DIgHV','bubbleSize','CubeTextureLoader','BDLayers.Lib.Overlays.Line','length','getShell','BDLayers.Lib.Overlays.MarkerImg','ZIHVn','Zngzo','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20varying\x20vec2\x20vUv;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20void\x20main(){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20vUv\x20=\x20uv;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20gl_Position\x20=\x20projectionMatrix\x20*\x20modelViewMatrix\x20*\x20vec4(position,\x201.0);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}','Sector','PIjJG','phQGm','TQGCg','distanceLayer','rnLxW','#toolbar-dtdy','setMode','jiWNP','.maptalks-tr-toolbar-app','format','RpFBX','BDLayers.Lib.Layer.TileBaseLayers','RKyCj','UWDeK','iIisU','bjEUm','map','cursor','GKVLV','identify','\x20.toolbar-cj','xgRAC','randomHashCode','ZBnpW','getInfoWindow','updateSceneConfig','keys','EuZVt','web-mercator','GeoJSONToGeometry','\x20BDLayers.Lib.Overlays.Geom','kwEUw','top-right','M514.796\x20954.637s-178.78-213.404-240.77-327.339c0\x200-252.042-292.805\x2079.395-523.695\x200\x200\x20193.649-119.169\x20399.711\x2057.102\x200\x200\x20180.781\x20155.167\x2037.013\x20412.125\x200.001-0.001-140.043\x20257.147-275.349\x20381.807z','getTileUrl','UvtZU','mapRotatePlayer','bZcaB','Style','drawTool','PqCkh','http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile//{z}/{y}/{x}','getCurrentCoordinates','HBNnO','xpos.jpg','ENCAZ','BvYOn','IoExQ','Wyenl','trajectoryPause','BDbtM','vgTSi','setInfoWindow'];(function(_0x43389c,_0x3f98bd){var _0x2d5591=function(_0x4b9d5a){while(--_0x4b9d5a){_0x43389c['push'](_0x43389c['shift']());}};_0x2d5591(++_0x3f98bd);}(_0x3f98,0x17e));var _0x2d55=function(_0x43389c,_0x3f98bd){_0x43389c=_0x43389c-0x0;var _0x2d5591=_0x3f98[_0x43389c];return _0x2d5591;};!function(_0x121720){window[_0x2d55('0x82f')]?protoman['bm'][_0x2d55('0x212')][_0x2d55('0x229')](_0x121720,window[_0x2d55('0x82f')]):window[_0x2d55('0x82f')]=_0x121720;}({'VERSION_NUMBER':_0x2d55('0x3ed'),'ImgPath':''}),function(){var _0x1f2a19={'cJOUH':function(_0x2f7eab,_0x196cca){return _0x2f7eab-_0x196cca;},'TQGCg':function(_0x1d22aa,_0x3dbe74){return _0x1d22aa-_0x3dbe74;},'wgCAV':function(_0x5edac7,_0x4d3f83){return _0x5edac7/_0x4d3f83;},'XgRqT':function(_0x1cb23f,_0x3e8766){return _0x1cb23f*_0x3e8766;},'BcpYS':function(_0x3972f4,_0xdceb2b){return _0x3972f4*_0xdceb2b;},'aZNPw':function(_0x5139bb,_0x25628e){return _0x5139bb/_0x25628e;},'KsYNm':function(_0x420483,_0x39792b){return _0x420483/_0x39792b;},'QJUsP':function(_0xcb9281,_0x2c83ad){return _0xcb9281+_0x2c83ad;},'AGHZQ':function(_0x2f2197,_0xad82b8){return _0x2f2197-_0xad82b8;},'Lmdpj':function(_0x498bd3,_0x1a4e5b){return _0x498bd3-_0x1a4e5b;},'UpEKx':function(_0x4430a3,_0xeb083b){return _0x4430a3-_0xeb083b;},'wQvTu':function(_0x23a9d8,_0x1a381f){return _0x23a9d8/_0x1a381f;},'QrsIR':function(_0x1fd4e2,_0x291540){return _0x1fd4e2/_0x291540;},'rpUvI':function(_0x24462e,_0x18c80c){return _0x24462e-_0x18c80c;},'dZNON':function(_0x4565a3,_0x28fbfd){return _0x4565a3<_0x28fbfd;},'fmiNI':function(_0x46885e,_0x259085){return _0x46885e<_0x259085;},'SszTg':function(_0x16a038,_0x85d66e){return _0x16a038+_0x85d66e;},'HyuYq':function(_0x66442d,_0x421cc0){return _0x66442d*_0x421cc0;},'SHgSO':function(_0x2b17e3,_0x42991d){return _0x2b17e3*_0x42991d;},'CNiCy':function(_0x54e806,_0x5167d7){return _0x54e806+_0x5167d7;},'DlkxB':function(_0x4513c6,_0x46a2d6){return _0x4513c6+_0x46a2d6;},'QLPto':function(_0x23541a,_0x16f9cc){return _0x23541a*_0x16f9cc;},'oeHbq':function(_0x6a7007,_0x2127b0){return _0x6a7007*_0x2127b0;},'aVFdy':function(_0x590b3f,_0x2a7aea){return _0x590b3f+_0x2a7aea;},'iJykC':function(_0x39b0a6,_0x415b13){return _0x39b0a6*_0x415b13;},'SGaNv':function(_0x3c3595,_0x5addc9){return _0x3c3595-_0x5addc9;},'IqHqG':function(_0x5ecdb1,_0x1dd507){return _0x5ecdb1*_0x1dd507;},'OxExb':function(_0x3b0ae2,_0x240d5a){return _0x3b0ae2+_0x240d5a;},'ijVkT':function(_0x19a113,_0x4bfe95){return _0x19a113+_0x4bfe95;},'RxTQL':function(_0x20b47a,_0x44cb7d){return _0x20b47a*_0x44cb7d;},'WQlFL':function(_0x2fca0b,_0x2d05d8){return _0x2fca0b*_0x2d05d8;},'BSgFY':function(_0x26a9cd,_0x3d7dda){return _0x26a9cd*_0x3d7dda;},'HRNGH':function(_0x1d3372,_0x2a0d4f){return _0x1d3372+_0x2a0d4f;},'OdrLD':function(_0x582b41,_0x4f649d){return _0x582b41+_0x4f649d;},'xKtcf':function(_0x5d4d66,_0xdf8347){return _0x5d4d66*_0xdf8347;},'eiLQF':function(_0x28d80a,_0x53067e){return _0x28d80a+_0x53067e;},'pOykx':function(_0x23bb47,_0x1ae0df){return _0x23bb47*_0x1ae0df;},'pTlHX':function(_0x5c0052,_0x1841ee){return _0x5c0052*_0x1841ee;},'AUMtE':function(_0x137c9e,_0x289146){return _0x137c9e*_0x289146;},'GrNVE':function(_0x36580f,_0x8f75aa){return _0x36580f+_0x8f75aa;},'qdoEw':function(_0x300d5e,_0x102a41){return _0x300d5e*_0x102a41;},'DsKEu':function(_0x3f7ee5,_0x1c7641){return _0x3f7ee5*_0x1c7641;},'ICMsX':function(_0x5d7220,_0x14fb1f){return _0x5d7220*_0x14fb1f;},'ohjeT':function(_0xbfade0,_0x37918d){return _0xbfade0*_0x37918d;},'EuWcu':function(_0x1c435f,_0x204288){return _0x1c435f*_0x204288;},'olVhS':function(_0x53e756,_0x24c335){return _0x53e756*_0x24c335;},'GvyDd':function(_0x42b2ee,_0x191d1a){return _0x42b2ee*_0x191d1a;},'dByFD':function(_0x101af1,_0x518af3){return _0x101af1+_0x518af3;},'PvQMA':function(_0x2ad245,_0x3e434f){return _0x2ad245+_0x3e434f;},'kwEUw':function(_0x5d3150,_0x5b15fe){return _0x5d3150*_0x5b15fe;},'FGTGm':function(_0x5dcd4a,_0x2b4a8d){return _0x5dcd4a+_0x2b4a8d;},'yQMug':function(_0x4b82a6,_0x109ec4){return _0x4b82a6/_0x109ec4;},'UXvvN':function(_0x5b8827,_0x174b8f){return _0x5b8827*_0x174b8f;},'kZuvZ':function(_0x4d9559,_0x53283e){return _0x4d9559+_0x53283e;},'ApzyN':function(_0x512750,_0x433263){return _0x512750*_0x433263;},'ZZfDE':function(_0x1045d3,_0x10b27e){return _0x1045d3*_0x10b27e;},'NwDTo':function(_0x1195ed,_0x593609){return _0x1195ed/_0x593609;},'XEeTC':function(_0x4b3290,_0x225b70){return _0x4b3290*_0x225b70;},'klToM':function(_0x4c70be,_0x1c6d58){return _0x4c70be/_0x1c6d58;},'ejnFX':function(_0x85fa8f,_0x5b1c85){return _0x85fa8f*_0x5b1c85;},'gIfQq':function(_0x3ab0ad,_0x3baf37){return _0x3ab0ad||_0x3baf37;},'hPaQy':_0x2d55('0x65'),'kYBoJ':function(_0x22001b,_0x35c564){return _0x22001b===_0x35c564;},'llkvB':_0x2d55('0x732'),'UuMue':function(_0x6abeb6,_0x17cca2){return _0x6abeb6===_0x17cca2;},'JWXBL':function(_0xef1d35,_0xfb7958){return _0xef1d35===_0xfb7958;},'KgchS':function(_0x11dbc7,_0x5c894d){return _0x11dbc7(_0x5c894d);},'WwVZw':function(_0xeafc2e,_0x29f509){return _0xeafc2e(_0x29f509);},'cQJza':'proj4','vUYDn':function(_0x26240c,_0x5c8905){return _0x26240c===_0x5c8905;},'NfQUq':'epsg:4326','LeuGE':_0x2d55('0x4db'),'aZJvk':function(_0x1caa0c,_0xdc655f){return _0x1caa0c===_0xdc655f;},'xhXAq':function(_0x2b96b9,_0x57b776){return _0x2b96b9!=_0x57b776;},'MHSvR':_0x2d55('0x7b'),'kInBI':_0x2d55('0x25b'),'HxkBM':function(_0x42d9cf,_0x89b079){return _0x42d9cf!==_0x89b079;},'aZblU':function(_0x9d780b,_0x547e90){return _0x9d780b==_0x547e90;},'mGabT':function(_0x522104,_0x227f73){return _0x522104==_0x227f73;},'KYuFZ':_0x2d55('0x6e3'),'IjyTG':_0x2d55('0x93'),'xqcJC':_0x2d55('0x813'),'IojLU':function(_0x136afe,_0x1f07b5){return _0x136afe!=_0x1f07b5;},'PmiyD':_0x2d55('0x2e2')};'use strict';var _0x47ddb0={'PI':Math['PI'],'x_pi':_0x1f2a19['ejnFX'](0xbb8,Math['PI'])/0xb4,'delta':function(_0x57df0b,_0x376d33){var _0x1de355=0x615305,_0x2d5ffb=0.006693421622965943,_0x355316=this[_0x2d55('0x4f9')](_0x1f2a19[_0x2d55('0x394')](_0x376d33,0x69),_0x1f2a19[_0x2d55('0x394')](_0x57df0b,0x23)),_0x376d33=this[_0x2d55('0x3d1')](_0x1f2a19['TQGCg'](_0x376d33,0x69),_0x57df0b-0x23),_0x57df0b=_0x1f2a19[_0x2d55('0x27d')](_0x57df0b,0xb4)*this['PI'],_0x2fac34=_0x1f2a19[_0x2d55('0x6f2')](0x1,_0x1f2a19[_0x2d55('0x765')](_0x2d5ffb*(_0x2fac34=Math[_0x2d55('0x600')](_0x57df0b)),_0x2fac34)),_0x5be000=Math[_0x2d55('0x843')](_0x2fac34);return{'lat':_0x1f2a19[_0x2d55('0x27d')](0xb4*_0x355316,_0x1f2a19[_0x2d55('0x452')](_0x1f2a19['BcpYS'](_0x1de355,0x1-_0x2d5ffb)/_0x1f2a19[_0x2d55('0x452')](_0x2fac34,_0x5be000),this['PI'])),'lon':_0x1f2a19[_0x2d55('0x6ab')](0xb4*_0x376d33,_0x1f2a19['BcpYS'](_0x1f2a19[_0x2d55('0x452')](_0x1f2a19[_0x2d55('0x680')](_0x1de355,_0x5be000),Math[_0x2d55('0x170')](_0x57df0b)),this['PI']))};},'wgs84_gcj02':function(_0x268249,_0xd0b5c8){return this[_0x2d55('0x3d6')](_0xd0b5c8,_0x268249)?[_0x268249,_0xd0b5c8]:[_0x268249+(_0x268249=this[_0x2d55('0x80f')](_0xd0b5c8,_0x268249))[_0x2d55('0x469')],_0x1f2a19[_0x2d55('0xf3')](_0xd0b5c8,_0x268249[_0x2d55('0x861')])];},'gcj02_wgs84':function(_0x5a35c7,_0x3cfee5){return this[_0x2d55('0x3d6')](_0x3cfee5,_0x5a35c7)?[_0x5a35c7,_0x3cfee5]:[_0x5a35c7-(_0x5a35c7=this[_0x2d55('0x80f')](_0x3cfee5,_0x5a35c7))[_0x2d55('0x469')],_0x1f2a19[_0x2d55('0x6ba')](_0x3cfee5,_0x5a35c7[_0x2d55('0x861')])];},'gcj02_wgs84_precise':function(_0x3719fa,_0xbf2265){for(var _0x2dd482=_0x1f2a19['Lmdpj'](_0xbf2265,0.01),_0x5c095b=_0x1f2a19['UpEKx'](_0x3719fa,0.01),_0x2e1209=_0x1f2a19[_0x2d55('0xf3')](_0xbf2265,0.01),_0x3e5bd6=_0x1f2a19[_0x2d55('0xf3')](_0x3719fa,0.01),_0x1a4e28=0x0;;){var _0x205ef5=_0x1f2a19['wQvTu'](_0x2dd482+_0x2e1209,0x2),_0x9e3088=_0x1f2a19[_0x2d55('0x373')](_0x1f2a19['QJUsP'](_0x5c095b,_0x3e5bd6),0x2),_0x1ccfc1=this[_0x2d55('0x3e8')](_0x205ef5,_0x9e3088),_0x1ec221=_0x1ccfc1[_0x2d55('0x861')]-_0xbf2265,_0x1ccfc1=_0x1f2a19[_0x2d55('0x369')](_0x1ccfc1[_0x2d55('0x469')],_0x3719fa);if(_0x1f2a19['dZNON'](Math['abs'](_0x1ec221),1e-9)&&Math[_0x2d55('0x4e9')](_0x1ccfc1)<1e-9)break;if(_0x1f2a19[_0x2d55('0x844')](0x0,_0x1ec221)?_0x2e1209=_0x205ef5:_0x2dd482=_0x205ef5,_0x1f2a19[_0x2d55('0x844')](0x0,_0x1ccfc1)?_0x3e5bd6=_0x9e3088:_0x5c095b=_0x9e3088,_0x1f2a19[_0x2d55('0x1e1')](0x2710,++_0x1a4e28))break;}return[_0x9e3088,_0x205ef5];},'gcj02_bd09ll':function(_0x2c68cb,_0x920ccb){var _0x42836d=Math['sqrt'](_0x1f2a19[_0x2d55('0x353')](_0x1f2a19[_0x2d55('0x851')](_0x2c68cb,_0x2c68cb),_0x920ccb*_0x920ccb))+_0x1f2a19[_0x2d55('0x611')](0.00002,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0x611')](_0x920ccb,this[_0x2d55('0x19d')]))),_0x920ccb=_0x1f2a19['CNiCy'](Math[_0x2d55('0x5e8')](_0x920ccb,_0x2c68cb),_0x1f2a19[_0x2d55('0x611')](0.000003,Math[_0x2d55('0x170')](_0x2c68cb*this['x_pi'])));return[_0x1f2a19[_0x2d55('0x36b')](_0x1f2a19[_0x2d55('0x85f')](_0x42836d,Math['cos'](_0x920ccb)),0.0065),_0x1f2a19[_0x2d55('0x94')](_0x42836d,Math['sin'](_0x920ccb))+0.006];},'bd09ll_gcj02':function(_0x29c476,_0x227d86){var _0x29c476=_0x29c476-0.0065,_0x227d86=_0x1f2a19[_0x2d55('0x369')](_0x227d86,0.006),_0x450001=Math[_0x2d55('0x843')](_0x1f2a19['aVFdy'](_0x1f2a19['iJykC'](_0x29c476,_0x29c476),_0x227d86*_0x227d86))-0.00002*Math[_0x2d55('0x600')](_0x227d86*this[_0x2d55('0x19d')]),_0x227d86=_0x1f2a19[_0x2d55('0x626')](Math['atan2'](_0x227d86,_0x29c476),_0x1f2a19[_0x2d55('0x1cd')](0.000003,Math[_0x2d55('0x170')](_0x29c476*this[_0x2d55('0x19d')])));return[_0x1f2a19[_0x2d55('0x1cd')](_0x450001,Math['cos'](_0x227d86)),_0x450001*Math[_0x2d55('0x600')](_0x227d86)];},'wgs84_bd09ll':function(_0x20989c,_0x499847){_0x20989c=this['wgs84_gcj02'](_0x20989c,_0x499847);return this[_0x2d55('0x575')](_0x20989c[0x0],_0x20989c[0x1]);},'bd09ll_wgs84':function(_0x253fbf,_0xea616b){_0x253fbf=this[_0x2d55('0x162')](_0x253fbf,_0xea616b);return this[_0x2d55('0x3f2')](_0x253fbf[0x0],_0x253fbf[0x1]);},'outOfChina':function(_0x654863,_0x344f17){return _0x1f2a19['fmiNI'](_0x344f17,72.004)||_0x1f2a19[_0x2d55('0x1e1')](137.8347,_0x344f17)||_0x1f2a19[_0x2d55('0x1e1')](_0x654863,0.8293)||55.8271<_0x654863;},'transformLat':function(_0x5ec68e,_0x11ca6e){var _0x5ba4c7=_0x1f2a19[_0x2d55('0x6a6')](_0x1f2a19[_0x2d55('0x4bb')](_0x1f2a19[_0x2d55('0x1a6')](_0x1f2a19[_0x2d55('0x1a6')](_0x1f2a19[_0x2d55('0x626')](0x2*_0x5ec68e,0x64),_0x1f2a19[_0x2d55('0x82d')](0x3,_0x11ca6e)),0.2*_0x11ca6e*_0x11ca6e),_0x1f2a19[_0x2d55('0x2a3')](0.1,_0x5ec68e)*_0x11ca6e),_0x1f2a19[_0x2d55('0x6a2')](0.2,Math[_0x2d55('0x843')](Math[_0x2d55('0x4e9')](_0x5ec68e))));return _0x1f2a19[_0x2d55('0x6b1')](_0x1f2a19[_0x2d55('0x672')](_0x5ba4c7+=_0x1f2a19[_0x2d55('0x373')](_0x1f2a19['xKtcf'](0x2,_0x1f2a19[_0x2d55('0x5d0')](_0x1f2a19[_0x2d55('0x7b7')](0x14,Math[_0x2d55('0x600')](_0x1f2a19['xKtcf'](_0x1f2a19['pOykx'](0x6,_0x5ec68e),this['PI']))),_0x1f2a19['pTlHX'](0x14,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0x528')](_0x1f2a19[_0x2d55('0x528')](0x2,_0x5ec68e),this['PI']))))),0x3),_0x1f2a19[_0x2d55('0x373')](_0x1f2a19[_0x2d55('0x1dc')](0x2,_0x1f2a19['GrNVE'](_0x1f2a19[_0x2d55('0x1dc')](0x14,Math[_0x2d55('0x600')](_0x1f2a19['qdoEw'](_0x11ca6e,this['PI']))),_0x1f2a19['DsKEu'](0x28,Math[_0x2d55('0x600')](_0x1f2a19['ICMsX'](_0x1f2a19[_0x2d55('0x373')](_0x11ca6e,0x3),this['PI']))))),0x3)),_0x1f2a19['QrsIR'](0x2*_0x1f2a19[_0x2d55('0x619')](_0x1f2a19[_0x2d55('0x27')](0xa0,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0x5c2')](_0x11ca6e/0xc,this['PI']))),_0x1f2a19[_0x2d55('0x509')](0x140,Math[_0x2d55('0x600')](_0x1f2a19['GvyDd'](_0x11ca6e,this['PI'])/0x1e))),0x3));},'transformLon':function(_0x3a2b03,_0x272b0e){_0x272b0e=_0x1f2a19[_0x2d55('0x619')](_0x1f2a19[_0x2d55('0x2f8')](_0x1f2a19[_0x2d55('0x2f8')](_0x1f2a19[_0x2d55('0x36c')](_0x1f2a19[_0x2d55('0x36c')](0x12c,_0x3a2b03),0x2*_0x272b0e),_0x1f2a19[_0x2d55('0x648')](0.1,_0x3a2b03)*_0x3a2b03),_0x1f2a19[_0x2d55('0x70f')](_0x1f2a19['kwEUw'](0.1,_0x3a2b03),_0x272b0e)),_0x1f2a19['kwEUw'](0.1,Math[_0x2d55('0x843')](Math[_0x2d55('0x4e9')](_0x3a2b03))));return _0x1f2a19[_0x2d55('0x1cc')](_0x1f2a19[_0x2d55('0x1cc')](_0x272b0e+=_0x1f2a19[_0x2d55('0x7dc')](_0x1f2a19[_0x2d55('0x2d7')](0x2,_0x1f2a19[_0x2d55('0x121')](_0x1f2a19['UXvvN'](0x14,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0xfb')](_0x1f2a19[_0x2d55('0xfb')](0x6,_0x3a2b03),this['PI']))),_0x1f2a19[_0x2d55('0xfb')](0x14,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0xfb')](_0x1f2a19[_0x2d55('0xfb')](0x2,_0x3a2b03),this['PI']))))),0x3),_0x1f2a19['ZZfDE'](0x2,_0x1f2a19[_0x2d55('0x121')](_0x1f2a19[_0x2d55('0x682')](0x14,Math[_0x2d55('0x600')](_0x3a2b03*this['PI'])),_0x1f2a19['ZZfDE'](0x28,Math['sin'](_0x1f2a19[_0x2d55('0x682')](_0x3a2b03/0x3,this['PI'])))))/0x3),_0x1f2a19['NwDTo'](_0x1f2a19[_0x2d55('0x372')](0x2,_0x1f2a19['kZuvZ'](_0x1f2a19[_0x2d55('0x372')](0x96,Math[_0x2d55('0x600')](_0x1f2a19[_0x2d55('0x26e')](_0x3a2b03,0xc)*this['PI'])),_0x1f2a19[_0x2d55('0x372')](0x12c,Math['sin'](_0x1f2a19['ejnFX'](_0x1f2a19[_0x2d55('0x26e')](_0x3a2b03,0x1e),this['PI']))))),0x3));}},_0x32064a={'crs':{'bd09ll':_0x1f2a19[_0x2d55('0x17f')],'gcj02':_0x1f2a19[_0x2d55('0x639')],'wgs84':_0x2d55('0x7a3')},'transform':function(_0x3d492f,_0x26324f,_0x24639a){var _0x1e7977=_0x2d55('0x3ad')['split']('|');var _0x31a828=0x0;while(!![]){switch(_0x1e7977[_0x31a828++]){case'0':if(this[_0x2d55('0x79e')](_0x3d492f))return this[_0x2d55('0x29d')](_0x3d492f,_0x26324f,_0x24639a);continue;case'1':if(_0x1f2a19[_0x2d55('0x7b4')](!_0x26324f,!_0x24639a))throw new Error(_0x1f2a19['hPaQy']);continue;case'2':if(this[_0x2d55('0x250')](_0x3d492f)){for(var _0x4ff94b=[],_0xd53816=0x0;_0x1f2a19[_0x2d55('0x1e1')](_0xd53816,_0x3d492f[_0x2d55('0x6e9')]);_0xd53816++)_0x4ff94b[_0x2d55('0x590')](this[_0x2d55('0x184')](_0x3d492f[_0xd53816],_0x26324f,_0x24639a));return _0x4ff94b;}continue;case'3':if(!_0x3d492f)return null;continue;case'4':return this['_transformGeoJSON'](_0x3d492f,_0x26324f,_0x24639a);}break;}},'_transformGeoJSON':function(_0xf9271a,_0x3f4971,_0x6ae1da){if(_0x1f2a19[_0x2d55('0x84e')](_0x1f2a19[_0x2d55('0x118')],_0xf9271a[_0x2d55('0x6c4')]))_0x1f6b9a=this[_0x2d55('0x184')](_0xf9271a[_0x2d55('0xe3')],_0x3f4971,_0x6ae1da),(_0x5f3c37=this['_extend']({},_0xf9271a))[_0x2d55('0xe3')]=_0x1f6b9a;else if(_0x1f2a19[_0x2d55('0x622')](_0x2d55('0x73'),_0xf9271a['type'])){for(var _0x13f736=_0xf9271a[_0x2d55('0x759')],_0x5f3c37=this['_extend']({},_0xf9271a),_0x19b3ac=[],_0x4f592b=0x0;_0x4f592b<_0x13f736[_0x2d55('0x6e9')];_0x4f592b++)_0x19b3ac[_0x2d55('0x590')](this[_0x2d55('0x184')](_0x13f736[_0x4f592b],_0x3f4971,_0x6ae1da));_0x5f3c37[_0x2d55('0x759')]=_0x19b3ac;}else if(_0x1f2a19[_0x2d55('0x7ad')]('GeometryCollection',_0xf9271a[_0x2d55('0x6c4')])){for(var _0x3a0bea=_0xf9271a['geometries'],_0x5f3c37=this[_0x2d55('0x273')]({},_0xf9271a),_0x2c426e=[],_0x4f592b=0x0;_0x4f592b<_0x3a0bea[_0x2d55('0x6e9')];_0x4f592b++)_0x2c426e[_0x2d55('0x590')](this['transform'](_0x3a0bea[_0x4f592b],_0x3f4971,_0x6ae1da));_0x5f3c37[_0x2d55('0x679')]=_0x2c426e;}else{var _0x5f3c37=this[_0x2d55('0x273')]({},_0xf9271a),_0x1f6b9a=this['_transformCoordinate'](_0xf9271a['coordinates'],_0x3f4971,_0x6ae1da);_0x5f3c37[_0x2d55('0x537')]=_0x1f6b9a;}return _0x5f3c37;},'_transformCoordinate':function(_0x3bed08,_0x314e64,_0x36f598){var _0x23ea86,_0x456b23=_0x314e64,_0x541532=_0x36f598;return _0x1f2a19[_0x2d55('0x8a2')]===_0x314e64[_0x2d55('0x6c4')]&&(_0x456b23=this[_0x2d55('0x269')](_0x314e64['properties'][_0x2d55('0x16e')])),_0x1f2a19['cQJza']===_0x36f598['type']&&(_0x541532=this['_toCRS'](_0x36f598[_0x2d55('0x6e')]['proj'])),_0x1f2a19[_0x2d55('0x845')](_0x456b23=_0x1f2a19['NfQUq']===(_0x456b23=_0x456b23[_0x2d55('0x234')]())?_0x1f2a19[_0x2d55('0x739')]:_0x456b23,_0x541532=_0x1f2a19[_0x2d55('0x845')](_0x1f2a19[_0x2d55('0x403')],_0x541532=_0x541532[_0x2d55('0x234')]())?_0x1f2a19[_0x2d55('0x739')]:_0x541532)?_0x3bed08:(_0x23ea86=_0x456b23+'_'+_0x541532,this[_0x2d55('0x4fd')](_0x3bed08,function(_0x3e593c){return _0x47ddb0[_0x23ea86](_0x1f2a19[_0x2d55('0x820')](parseFloat,_0x3e593c[0x0]),_0x1f2a19[_0x2d55('0x890')](parseFloat,_0x3e593c[0x1]));},this));},'_extend':function(_0x28e1bf,_0x4186e3){for(var _0x3af2d0 in _0x4186e3)_0x4186e3[_0x2d55('0x28f')](_0x3af2d0)&&(_0x28e1bf[_0x3af2d0]=_0x4186e3[_0x3af2d0]);return _0x28e1bf;},'_toCRS':function(_0x23dc3b){for(var _0x110bfb in this[_0x2d55('0x796')])if(_0x1f2a19[_0x2d55('0x5cf')](_0x23dc3b,this[_0x2d55('0x796')][_0x110bfb]))return _0x110bfb;return null;},'_eachCoordinate':function(_0x593380,_0x2db42c,_0x179825){if(this[_0x2d55('0x79e')](_0x593380))return _0x2db42c[_0x2d55('0x55e')](_0x179825,_0x593380);for(var _0x20ad0c=[],_0x1a3a6a=0x0,_0x4c0075=_0x593380[_0x2d55('0x6e9')];_0x1f2a19['fmiNI'](_0x1a3a6a,_0x4c0075);_0x1a3a6a++){var _0x265c4b,_0x4f19da=_0x593380[_0x1a3a6a];_0x1f2a19[_0x2d55('0x585')](null,_0x4f19da)&&(this[_0x2d55('0x79e')](_0x4f19da)?(_0x265c4b=_0x2db42c[_0x2d55('0x55e')](_0x179825,_0x4f19da),_0x20ad0c['push'](_0x265c4b)):this[_0x2d55('0x250')](_0x4f19da)&&_0x20ad0c['push'](this[_0x2d55('0x4fd')](_0x4f19da,_0x2db42c,_0x179825)));}return _0x20ad0c;},'_isCoord':function(_0x346286){return!!(this[_0x2d55('0x250')](_0x346286)&&this[_0x2d55('0x378')](_0x346286[0x0])&&this[_0x2d55('0x378')](_0x346286[0x1]));},'_isNumber':function(_0x3e97b6){return _0x1f2a19[_0x2d55('0x386')]==typeof _0x3e97b6&&!_0x1f2a19['WwVZw'](isNaN,_0x3e97b6);},'_isArray':function(_0x41068f){return!!_0x41068f&&(_0x1f2a19['kInBI']==typeof _0x41068f||_0x1f2a19['HxkBM'](null,_0x41068f['constructor'])&&_0x1f2a19[_0x2d55('0x323')](_0x41068f['constructor'],Array));},'_isString':function(_0x2120f9){return null!=_0x2120f9&&(_0x1f2a19['mGabT'](_0x1f2a19[_0x2d55('0x821')],typeof _0x2120f9)||_0x1f2a19[_0x2d55('0xd8')](null,_0x2120f9['constructor'])&&_0x2120f9[_0x2d55('0x4d8')]==String);}};_0x1f2a19['xhXAq'](_0x2d55('0x2e2'),typeof module)&&module['exports']&&(exports=module['exports']=_0x32064a),_0x1f2a19[_0x2d55('0x14b')](_0x1f2a19['PmiyD'],typeof window)&&(window[_0x2d55('0x47c')]=window['maptalks']||{},window[_0x2d55('0x47c')]['CRSTransform']=_0x32064a);}(),BDLayers[_0x2d55('0x2ca')]=function(){var _0x30b283={'ZgRdr':function(_0x5d4846,_0x13f1f3){return _0x5d4846==_0x13f1f3;},'kWhTr':'function','auEzS':function(_0x598eb6,_0x54ee92){return _0x598eb6<_0x54ee92;},'iUkVs':function(_0x581352,_0x3b0058){return _0x581352-_0x3b0058;},'vWOvg':_0x2d55('0x4d8'),'STXpb':function(_0x259503,_0x2f1ef5){return _0x259503===_0x2f1ef5;}};var _0xb832e3=arguments['length'],_0x5021dc=arguments[0x0],_0x5c0bd3=arguments[_0xb832e3-0x1],_0x222b80=_0x30b283[_0x2d55('0x4ba')](_0x30b283[_0x2d55('0xd9')],typeof _0x5c0bd3[_0x2d55('0x27c')])?_0x5c0bd3[_0x2d55('0x27c')]:function(){_0x5021dc[_0x2d55('0x4e2')]['initialize'][_0x2d55('0x589')](this,arguments);};if(_0x30b283[_0x2d55('0x1a8')](0x1,_0xb832e3)){_0xb832e3=[_0x222b80,_0x5021dc][_0x2d55('0x2c9')](Array[_0x2d55('0x4e2')][_0x2d55('0x832')][_0x2d55('0x55e')](arguments)[_0x2d55('0x832')](0x1,_0x30b283[_0x2d55('0x19a')](_0xb832e3,0x1)),_0x5c0bd3);BDLayers[_0x2d55('0x36a')][_0x2d55('0x589')](null,_0xb832e3);}else if(_0x222b80[_0x2d55('0x4e2')][_0x2d55('0x28f')](_0x30b283[_0x2d55('0x31e')])){var _0x2a5430,_0x243d36=BDLayers['Util'][_0x2d55('0x4f7')](new protoman['sm'][(_0x2d55('0x640'))]());for(_0x2a5430 in(_0x30b283[_0x2d55('0x329')]('IE',info4dev[_0x2d55('0x4fc')][_0x2d55('0x20')])?(delete(_0xb832e3=Object[_0x2d55('0x78e')](_0x243d36))[_0x2d55('0xdf')],delete _0xb832e3['_triggeringCount']):(delete _0x243d36[_0x2d55('0x6cc')]['handlers'],delete _0x243d36['__proto__'][_0x2d55('0x523')]),_0x5c0bd3))_0x243d36[_0x2a5430]=_0x5c0bd3[_0x2a5430];_0x222b80[_0x2d55('0x4e2')]=_0x243d36;}else _0x222b80[_0x2d55('0x4e2')]=_0x5c0bd3;return _0x222b80;},BDLayers[_0x2d55('0x36a')]=function(_0x228a6a,_0x4aa03f){var _0x1f25db={'vzDYH':function(_0x53df36,_0x2b6ee9){return _0x53df36==_0x2b6ee9;},'PDYyy':_0x2d55('0x30a')};function _0x49b48a(){}var _0x115545,_0x256a52,_0x7f70c2;for(_0x49b48a[_0x2d55('0x4e2')]=_0x4aa03f[_0x2d55('0x4e2')],_0x228a6a[_0x2d55('0x4e2')]=new _0x49b48a(),_0x115545=0x2,_0x256a52=arguments[_0x2d55('0x6e9')];_0x115545<_0x256a52;_0x115545++)_0x1f25db['vzDYH'](_0x1f25db[_0x2d55('0x137')],typeof(_0x7f70c2=arguments[_0x115545]))&&(_0x7f70c2=_0x7f70c2['prototype']),BDLayers['Util'][_0x2d55('0x229')](_0x228a6a[_0x2d55('0x4e2')],_0x7f70c2);},BDLayers['Lib']=BDLayers['Lib']||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x729')]=BDLayers['Lib'][_0x2d55('0x729')]||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x35d')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x35d')]||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]=BDLayers['Lib']['Layer']||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x4b2')]=BDLayers[_0x2d55('0x47b')]['Interactions']||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]=BDLayers['Lib']['Control']||{},BDLayers['Lib'][_0x2d55('0x716')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x716')]||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]=BDLayers[_0x2d55('0x47b')]['Constant']||{},BDLayers[_0x2d55('0x47b')]['Tools']=BDLayers[_0x2d55('0x47b')]['Tools']||{},BDLayers[_0x2d55('0x47b')][_0x2d55('0x2f5')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x2f5')]||{},BDLayers['LibViz']=BDLayers['LibViz']||{},BDLayers[_0x2d55('0x5fd')][_0x2d55('0x404')]=BDLayers[_0x2d55('0x5fd')]['Layer']||{},BDLayers[_0x2d55('0x5fd')][_0x2d55('0x716')]=BDLayers[_0x2d55('0x5fd')][_0x2d55('0x716')]||{},BDLayers[_0x2d55('0x5fd')][_0x2d55('0x58c')]=BDLayers[_0x2d55('0x5fd')][_0x2d55('0x58c')]||{},BDLayers['LibViz'][_0x2d55('0x2f5')]=BDLayers['LibViz']['D3Layer']||{},BDLayers[_0x2d55('0x699')]=BDLayers['Extend']||{},BDLayers[_0x2d55('0x84f')]=BDLayers['Util']||{},BDLayers[_0x2d55('0x84f')]['extend']=function(_0x3fff10,_0x4e8073){var _0x4c8d9d={'caXKh':function(_0x546ec5,_0x541975){return _0x546ec5||_0x541975;},'kkuWa':function(_0x25dfbc,_0x3e7cce){return _0x25dfbc===_0x3e7cce;},'maHmr':function(_0x1862f1,_0x193118){return _0x1862f1!==_0x193118;},'eeyFK':function(_0xa22fbd,_0x59c67c){return _0xa22fbd!==_0x59c67c;},'JIHoq':function(_0x28bf8f,_0x453316){return _0x28bf8f==_0x453316;},'Nhpop':'function','LDDDl':function(_0x5ad581,_0x5ba14a){return _0x5ad581 instanceof _0x5ba14a;},'CVWPz':_0x2d55('0x25e')};if(_0x3fff10=_0x4c8d9d[_0x2d55('0x5ed')](_0x3fff10,{}),_0x4e8073){for(var _0x27d0a8 in _0x4e8073){var _0x142b31=_0x4e8073[_0x27d0a8];_0x4c8d9d[_0x2d55('0x76d')](void 0x0,_0x142b31)||_0x4c8d9d[_0x2d55('0x2b3')](void 0x0,_0x3fff10[_0x27d0a8])&&_0x4c8d9d[_0x2d55('0x63a')](null,_0x3fff10[_0x27d0a8])||(_0x3fff10[_0x27d0a8]=_0x142b31);}!(_0x4c8d9d[_0x2d55('0x6d7')](_0x4c8d9d[_0x2d55('0x445')],typeof window['Event'])&&_0x4c8d9d[_0x2d55('0x85d')](_0x4e8073,window[_0x2d55('0x2fd')]))&&_0x4e8073['hasOwnProperty']&&_0x4e8073[_0x2d55('0x28f')](_0x4c8d9d[_0x2d55('0xb3')])&&(_0x3fff10[_0x2d55('0x25e')]=_0x4e8073['toString']);}return _0x3fff10;},BDLayers[_0x2d55('0x84f')][_0x2d55('0x4f7')]=Object[_0x2d55('0x4f7')]||function(){function _0x3b530e(){}return function(_0x577208){return _0x3b530e[_0x2d55('0x4e2')]=_0x577208,new _0x3b530e();};}(),BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')]=function(_0x3ef6c8,_0x198daf){var _0x1caf0f={'cjduF':_0x2d55('0x4f3')};for(var _0x188d8b in(_0x3ef6c8['hasOwnProperty'](_0x1caf0f['cjduF'])||(_0x3ef6c8[_0x2d55('0x4f3')]=_0x3ef6c8[_0x2d55('0x4f3')]?BDLayers[_0x2d55('0x84f')][_0x2d55('0x4f7')](_0x3ef6c8[_0x2d55('0x4f3')]):{}),_0x198daf))_0x3ef6c8[_0x2d55('0x4f3')][_0x188d8b]=_0x198daf[_0x188d8b];return _0x3ef6c8['options'];},BDLayers[_0x2d55('0x84f')]['Clone']=function(_0x41c32b){var _0x50626b={'EdPNJ':function(_0xddb6f1,_0x52b9b4){return _0xddb6f1===_0x52b9b4;},'nOVPi':_0x2d55('0x486'),'qHMth':function(_0x19d0ad,_0x3e51b9){return _0x19d0ad instanceof _0x3e51b9;},'nNJkE':function(_0x4f1680,_0xdba8c9){return _0x4f1680<_0xdba8c9;},'vIUGE':function(_0x4d04bd,_0x3b329b){return _0x4d04bd instanceof _0x3b329b;},'TezmM':_0x2d55('0x20c')};if(_0x50626b[_0x2d55('0x624')](null,_0x41c32b)||_0x50626b[_0x2d55('0xb1')]!=typeof _0x41c32b)return _0x41c32b;if(_0x50626b[_0x2d55('0x88b')](_0x41c32b,Date))return(_0x1a5efa=new Date())[_0x2d55('0x4af')](_0x41c32b['getTime']()),_0x1a5efa;if(_0x50626b['qHMth'](_0x41c32b,Array)){for(var _0x1a5efa=[],_0x4b7594=0x0,_0x55a417=_0x41c32b['length'];_0x50626b[_0x2d55('0x68b')](_0x4b7594,_0x55a417);++_0x4b7594)_0x1a5efa[_0x4b7594]=BDLayers[_0x2d55('0x84f')][_0x2d55('0x1cf')](_0x41c32b[_0x4b7594]);return _0x1a5efa;}if(_0x50626b[_0x2d55('0x3f1')](_0x41c32b,Object)){var _0xed2f49,_0x1a5efa={};for(_0xed2f49 in _0x41c32b)_0x41c32b['hasOwnProperty'](_0xed2f49)&&(_0x1a5efa[_0xed2f49]=BDLayers[_0x2d55('0x84f')]['Clone'](_0x41c32b[_0xed2f49]));return _0x1a5efa;}throw new Error(_0x50626b['TezmM']);},BDLayers[_0x2d55('0x84f')][_0x2d55('0x26a')]=Array[_0x2d55('0x26a')]||function(_0x5d7bae){var _0x11943e={'tdMBj':function(_0x1549ad,_0x2a3789){return _0x1549ad===_0x2a3789;},'lPaNg':_0x2d55('0x769')};return _0x11943e[_0x2d55('0x697')](_0x11943e[_0x2d55('0x846')],Object[_0x2d55('0x4e2')][_0x2d55('0x25e')][_0x2d55('0x55e')](_0x5d7bae));},BDLayers[_0x2d55('0x84f')][_0x2d55('0x146')]=function(_0x412dfa){var _0x13c1e7={'XoEas':function(_0x1e136a,_0x5d1128){return _0x1e136a<_0x5d1128;},'qgGcv':function(_0x1e57cb,_0x9207bd){return _0x1e57cb|_0x9207bd;},'AJfSB':function(_0x11a736,_0x131e4f){return _0x11a736+_0x131e4f;},'nwHVu':function(_0x1fe1e8,_0x1d44d3){return _0x1fe1e8<<_0x1d44d3;}};if(!_0x412dfa||!_0x412dfa[_0x2d55('0x6e9')])return 0x0;for(var _0x445021=0x0,_0x311774=0x0;_0x13c1e7[_0x2d55('0x48e')](_0x445021,_0x412dfa['length']);_0x445021++)_0x311774=_0x13c1e7[_0x2d55('0x256')](_0x13c1e7[_0x2d55('0xaf')](_0x13c1e7['nwHVu'](_0x311774,0x5)-_0x311774,_0x412dfa[_0x2d55('0x870')](_0x445021)),0x0);return _0x311774;},BDLayers[_0x2d55('0x84f')]['S4']=function(){var _0x1b8331={'TNUOC':function(_0x11a7f2,_0x4686b5){return _0x11a7f2+_0x4686b5;}};return(0x10000*_0x1b8331[_0x2d55('0x6b0')](0x1,Math['random']())|0x0)['toString'](0x10)[_0x2d55('0x438')](0x1);},BDLayers[_0x2d55('0x84f')][_0x2d55('0x706')]=function(){var _0x378548={'OhOHm':function(_0x1befec,_0x4effc9){return _0x1befec+_0x4effc9;},'HyMwn':function(_0x31ace7,_0x220862){return _0x31ace7+_0x220862;},'SYMJP':function(_0x25bfbc,_0x4a4b64){return _0x25bfbc+_0x4a4b64;},'odInL':function(_0x25b41a,_0x395456){return _0x25b41a+_0x395456;}};return _0x378548[_0x2d55('0x880')](_0x378548[_0x2d55('0x6a8')](_0x378548[_0x2d55('0x6a8')](_0x378548[_0x2d55('0x6a8')](_0x378548[_0x2d55('0x6a8')](_0x378548[_0x2d55('0x281')](_0x378548[_0x2d55('0x281')](_0x378548['odInL'](BDLayers[_0x2d55('0x84f')]['S4']()+BDLayers['Util']['S4'](),'-'),BDLayers[_0x2d55('0x84f')]['S4']()),'-'),BDLayers[_0x2d55('0x84f')]['S4']())+'-',BDLayers['Util']['S4']()),'-')+BDLayers[_0x2d55('0x84f')]['S4'](),BDLayers[_0x2d55('0x84f')]['S4']()),BDLayers[_0x2d55('0x84f')]['S4']());},BDLayers[_0x2d55('0x84f')]['getElByClass']=function(_0x30c586){return document['querySelector'](_0x30c586);},BDLayers[_0x2d55('0x84f')]['gcj02Offset']=function(_0x28c276){var _0x49c29f={'ZwJEq':_0x2d55('0x625'),'JiAyN':_0x2d55('0x6dc')};var _0x5d8070=this['layer'][_0x2d55('0x20b')](),_0x3312f7=_0x5d8070[_0x2d55('0x66b')](),_0x268749=maptalks[_0x2d55('0x156')]['transform'](_0x3312f7[_0x2d55('0x6a9')](),_0x49c29f[_0x2d55('0x757')],_0x49c29f[_0x2d55('0x9b')]);return _0x5d8070['coordToPoint'](_0x3312f7,_0x28c276)[_0x2d55('0x243')](_0x5d8070['coordToPoint'](new maptalks[(_0x2d55('0x4b0'))](_0x268749),_0x28c276))[_0x2d55('0x77b')]()[_0x2d55('0x6a9')]();},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')]={'EPSG4326':_0x2d55('0x279'),'EPSG3857':_0x2d55('0x1b4'),'EPSG4490':'EPSG:4490','EPSGB3857':_0x2d55('0x525')},BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x133')]={'TileBase':0x0,'TiandiTu':0x1,'TiandiTu4326':0x2,'Amap':0x4,'AmapGCJ02':0x5,'Baidu':0x6,'Baidu_dark':0x7,'Baidu_dark_blue':0x8,'Baidu_light':0x9,'GeoQ_StreetBlue':0xa,'GeoQ_StreetGray':0xb,'GeoQ_StreetWarm':0xc,'GeoQ_Community':0xd,'GeoQ_StreetBlue_GCJ02':0xe,'GeoQ_StreetGray_GCJ02':0xf,'GeoQ_StreetWarm_GCJ02':0x10,'GeoQ_Community_GCJ02':0x11,'TiandituTerrain':0x12,'OSMTerrain':0x13,'SeaMap':0x14,'Blank':0x15},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')]={'Vector':0x1,'Satellite':0x2},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x200')]={'Base':0x1,'Raster':0x2,'Geom':0x3,'Marker':0x4,'Appendage':0x5,'VectorRaster':0x6},BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x838')]={'Red':_0x2d55('0x531'),'Darkred':_0x2d55('0x521'),'Lightred':_0x2d55('0x8e'),'Orange':_0x2d55('0x5c1'),'Beige':_0x2d55('0x87a'),'Green':'green','Darkgreen':_0x2d55('0x6a7'),'Lightgreen':_0x2d55('0x6b7'),'Blue':_0x2d55('0x793'),'Darkblue':'darkblue','Lightblue':_0x2d55('0x693'),'Purple':_0x2d55('0x43'),'Darkpurple':'darkpurple','Pink':'pink','Cadetblue':_0x2d55('0x2af'),'White':_0x2d55('0x3c2'),'Gray':'gray','Lightgray':_0x2d55('0x82e'),'Black':_0x2d55('0x171')},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['MarkerHightLightValue']={'blue':'mblue','red':_0x2d55('0x530'),'yellow':_0x2d55('0xbf')},BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x411')]={'Start':0x1,'Drawing':0x2,'Stop':0x3},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x5b4')]={'click':0x1,'dbclick':0x2},BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x7d2')]={'Active':0x1,'Inactive':0x2},BDLayers['Lib'][_0x2d55('0x168')]['Drawingtype']={'Point':_0x2d55('0x5c4'),'StraightLine':_0x2d55('0x60'),'Circle':_0x2d55('0x2be'),'Rectangle':_0x2d55('0x505'),'Star':_0x2d55('0x471'),'Flag_Triangle':_0x2d55('0x6b4'),'Flag_Rectangle':_0x2d55('0x1f1'),'ArcLine':_0x2d55('0x798'),'PolyLine':_0x2d55('0x773'),'Curve':_0x2d55('0x290'),'Polygon':'polygon','CurvedPolygon':_0x2d55('0x408'),'StraightArrow':_0x2d55('0xd5'),'StraightArrow_Thick':_0x2d55('0x4c6'),'ArcArrow':_0x2d55('0x82c'),'AttackArrow':_0x2d55('0x754'),'PincerArrow':_0x2d55('0x6bf'),'PathArrow':_0x2d55('0x6cf'),'PathArrow_Thick':_0x2d55('0x43d')},BDLayers[_0x2d55('0x47b')]['Constant']['TileErrorUrl']='/img/tile404.png',BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x249')]={'Tianditu':_0x2d55('0x346'),'Baidu':_0x2d55('0x1d'),'Amap':_0x2d55('0x2dc')},BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')]=BDLayers['Class']({'id':null,'layer':null,'map':null,'visible':!0x0,'profix_def':_0x2d55('0x6bb'),'options':{},'initialize':function(_0x54e32c,_0x33e760){var _0x5b61f7={'tuqvO':function(_0x141731,_0x13758a){return _0x141731+_0x13758a;}};BDLayers['Util'][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),this['id']=_0x54e32c||_0x5b61f7[_0x2d55('0x67')](this['profix_def'],BDLayers[_0x2d55('0x84f')]['randomHashCode']()),_0x33e760&&BDLayers['Util'][_0x2d55('0x222')](this,_0x33e760);},'setMap':function(_0x4fabe0){this[_0x2d55('0x700')]=_0x4fabe0,this['layer']&&this[_0x2d55('0x700')]&&this[_0x2d55('0x749')][_0x2d55('0x6ce')](this[_0x2d55('0x700')]);},'setZIndex':function(_0x35bd52){this[_0x2d55('0x749')]&&this[_0x2d55('0x749')]['setZIndex'](_0x35bd52);},'setVisible':function(_0x276c20){_0x276c20?this[_0x2d55('0x749')][_0x2d55('0x6a0')]():this['layer'][_0x2d55('0x45d')]();},'getRenderer':function(){return this[_0x2d55('0x749')][_0x2d55('0x32e')]();},'getLayer':function(){return this[_0x2d55('0x749')];},'toJSON':function(){return this[_0x2d55('0x749')][_0x2d55('0x49d')]();},'getVisible':function(){},'CLASS_NAME':_0x2d55('0x136')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBTileLayer']=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib']['Layer'][_0x2d55('0x310')],{'boundary':null,'boundaryColor':_0x2d55('0x175'),'initialize':function(_0xee4f3b,_0x30e04e){var _0x5a74ff={'ECfsZ':'web-mercator','CLHih':function(_0x1a4d32,_0x3f8784){return _0x1a4d32==_0x3f8784;},'Aoatl':_0x2d55('0x30a'),'PsZdg':function(_0x548ec9,_0x3f648e){return _0x548ec9+_0x3f648e;},'sthYn':'cbtilelayer'};var _0x4f328f;BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x83e')]=_0x5a74ff[_0x2d55('0x858')],this['options'][_0x2d55('0x6c4')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['CBLayerType'][_0x2d55('0x396')],this[_0x2d55('0x4f3')][_0x2d55('0x65a')]=0x16,this[_0x2d55('0x4f3')][_0x2d55('0xf7')]=0x3,this[_0x2d55('0x4f3')][_0x2d55('0x5a0')]=[0x0,0x0],this['options'][_0x2d55('0x1c7')]=null,this[_0x2d55('0x4f3')][_0x2d55('0x13a')]=null,this[_0x2d55('0x4f3')][_0x2d55('0x7b5')]=null,this['options']['cusTileURLHandler']=null,BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0xee4f3b,_0x30e04e),this[_0x2d55('0x4f3')][_0x2d55('0x3a8')]instanceof Array?(_0xee4f3b=this[_0x2d55('0x4f3')][_0x2d55('0x3a8')][_0x2d55('0x700')](function(_0x6b078,_0x39d13d){_0x6b078={'urlTemplate':_0x6b078,'tileSystem':this[_0x2d55('0x4f3')][_0x2d55('0x7b5')]||maptalks[_0x2d55('0x5a1')][_0x2d55('0x214')]({'code':_0x5a74ff[_0x2d55('0x3e3')]}),'subdomains':this[_0x2d55('0x4f3')][_0x2d55('0x1c7')]?this[_0x2d55('0x4f3')][_0x2d55('0x1c7')][_0x2d55('0x77c')](''):null,'maxZoom':this['options'][_0x2d55('0x65a')][_0x39d13d],'minZoom':this['options'][_0x2d55('0xf7')][_0x39d13d],'offset':_0x5a74ff[_0x2d55('0x7b1')](_0x5a74ff['Aoatl'],typeof this[_0x2d55('0x4f3')][_0x2d55('0x5a0')])?this['options'][_0x2d55('0x5a0')][_0x2d55('0x7cf')](this):this[_0x2d55('0x4f3')]['offset']};return this['options'][_0x2d55('0x1e5')]&&(_0x6b078[_0x2d55('0x1e5')]=this[_0x2d55('0x4f3')][_0x2d55('0x1e5')][_0x39d13d]),new maptalks['TileLayer'](_0x5a74ff['PsZdg'](this['id'],_0x39d13d),_0x6b078);}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x749')]=new maptalks['GroupTileLayer'](this['id'],_0xee4f3b)):(_0x30e04e={'urlTemplate':this[_0x2d55('0x4f3')][_0x2d55('0x3a8')],'tileSystem':this[_0x2d55('0x4f3')][_0x2d55('0x7b5')]||maptalks[_0x2d55('0x5a1')][_0x2d55('0x214')]({'code':_0x2d55('0x70c')}),'subdomains':this[_0x2d55('0x4f3')][_0x2d55('0x1c7')]?this[_0x2d55('0x4f3')]['subdomains']['split'](''):null,'maxZoom':this['options'][_0x2d55('0x65a')],'minZoom':this[_0x2d55('0x4f3')][_0x2d55('0xf7')],'offset':_0x5a74ff[_0x2d55('0x7b1')](_0x2d55('0x30a'),typeof this[_0x2d55('0x4f3')][_0x2d55('0x5a0')])?this[_0x2d55('0x4f3')][_0x2d55('0x5a0')][_0x2d55('0x7cf')](this):this[_0x2d55('0x4f3')][_0x2d55('0x5a0')],'cssFilter':this[_0x2d55('0x4f3')][_0x2d55('0x13a')]||null},this[_0x2d55('0x4f3')][_0x2d55('0x1e5')]&&(_0x30e04e[_0x2d55('0x1e5')]=this[_0x2d55('0x4f3')][_0x2d55('0x1e5')]),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x7a0'))](this['id'],_0x30e04e),this[_0x2d55('0x4f3')][_0x2d55('0x87d')]&&((_0x4f328f=this)[_0x2d55('0x749')]['getTileUrl']=function(_0x5f2b56,_0x571b4f,_0x334bfd){_0x5f2b56=_0x4f328f[_0x2d55('0x4f3')][_0x2d55('0x87d')](_0x5f2b56,_0x571b4f,_0x334bfd);return maptalks[_0x2d55('0x7a0')][_0x2d55('0x4e2')][_0x2d55('0x712')][_0x2d55('0x55e')](this,_0x5f2b56['x'],_0x5f2b56['y'],_0x5f2b56['z']);})),this[_0x2d55('0x533')](_0x2d55('0x501'),this);},'remove':function(){this[_0x2d55('0x749')]&&this[_0x2d55('0x749')]['remove']();},'CLASS_NAME':_0x2d55('0x51d')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x5c8')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'layer':null,'initialize':function(_0x59745a,_0x3d0725){var _0x257c40={'QqDbG':_0x2d55('0x76c')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x424')]=null,this[_0x2d55('0x4f3')]['tileSystem']=null,BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x59745a,_0x3d0725),this['layer']=new maptalks['VectorTileLayer'](_0x59745a,{'urlTemplate':this[_0x2d55('0x4f3')][_0x2d55('0x3a8')],'spatialReference':this[_0x2d55('0x4f3')][_0x2d55('0x424')]||_0x257c40[_0x2d55('0x1d3')],'tileSystem':this[_0x2d55('0x4f3')]['tileSystem']||maptalks[_0x2d55('0x5a1')][_0x2d55('0x214')]({'code':_0x2d55('0x70c')}),'minZoom':this[_0x2d55('0x4f3')][_0x2d55('0xf7')]||0x3,'maxZoom':this[_0x2d55('0x4f3')][_0x2d55('0x65a')]||0x16,'features':this[_0x2d55('0x4f3')][_0x2d55('0x759')]||!0x1,'maxAvailableZoom':this[_0x2d55('0x4f3')][_0x2d55('0x5d9')]||0x16}),this['layer'][_0x2d55('0x3a9')](this['options'][_0x2d55('0x3a7')]);},'getLayer':function(){return this[_0x2d55('0x749')];},'getMap':function(){return this['layer'][_0x2d55('0x20b')]();},'getId':function(){return this[_0x2d55('0x749')][_0x2d55('0x482')]();},'isVisible':function(){return this[_0x2d55('0x749')][_0x2d55('0x3b')]();},'getRenderer':function(){return this[_0x2d55('0x749')][_0x2d55('0x32e')]();},'load':function(){return this[_0x2d55('0x749')][_0x2d55('0x58d')]();},'_bindMap':function(_0x13ac6f){return this['layer'][_0x2d55('0x3a1')](_0x13ac6f);},'show':function(){this['layer'][_0x2d55('0x6a0')]();},'hide':function(){this['layer']['hide']();},'config':function(_0x3bb09a){this[_0x2d55('0x749')][_0x2d55('0x524')](_0x3bb09a);},'fromJSON':function(_0x22209b){return new BDLayers[(_0x2d55('0x47b'))]['Layer']['CBMVTLayer'](_0x22209b['id'],_0x22209b[_0x2d55('0x4f3')]);},'toJSON':function(){return this[_0x2d55('0x749')]['toJSON']();},'identify':function(_0x462959,_0x55568b){return this[_0x2d55('0x749')][_0x2d55('0x703')](_0x462959,_0x55568b);},'setMap':function(_0x17505a){this[_0x2d55('0x700')]=_0x17505a;},'setVisible':function(_0x3443e6){_0x3443e6?this['layer'][_0x2d55('0x6a0')]():this[_0x2d55('0x749')][_0x2d55('0x45d')]();},'setStyle':function(_0x1b8f9d){_0x1b8f9d&&this[_0x2d55('0x749')][_0x2d55('0x3a9')](_0x1b8f9d);},'getStyle':function(){return this[_0x2d55('0x749')][_0x2d55('0x554')]();},'updateSymbol':function(_0x4bfc5b,_0x3def4e){this[_0x2d55('0x749')][_0x2d55('0x802')](_0x4bfc5b,_0x3def4e);},'updateDataConfig':function(_0x41257e,_0x4623b1){this[_0x2d55('0x749')][_0x2d55('0x161')](_0x41257e,_0x4623b1);},'updateSceneConfig':function(_0x4a8340,_0x5b8b8a){this[_0x2d55('0x749')][_0x2d55('0x709')](_0x4a8340,_0x5b8b8a);},'removeStyle':function(){this['layer'][_0x2d55('0x3a9')]({'style':null});},'getVisible':function(){},'setVisibleByFeature':function(_0x5aa03c,_0x531d91){this[_0x2d55('0x749')]['updateSymbol'](_0x5aa03c,{'visible':_0x531d91});},'CLASS_NAME':_0x2d55('0x78b')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x316')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'initialize':function(_0x4c3474,_0x170a5c){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this['options'],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x4c3474,_0x170a5c),this[_0x2d55('0x749')]=new maptalks['GLTFLayer'](_0x4c3474);},'setMap':function(_0x50482a){this['map']=_0x50482a;},'setVisible':function(_0x48cb5c){_0x48cb5c?this[_0x2d55('0x749')]['show']():this['layer'][_0x2d55('0x45d')]();},'getVisible':function(){},'setVisibleByFeature':function(_0x529bb3,_0x557391){this[_0x2d55('0x749')][_0x2d55('0x802')](_0x529bb3,{'visible':_0x557391});},'addGLTF':function(_0x56b35a,_0x526ea8,_0x42f499){_0x56b35a=new maptalks[(_0x2d55('0x1aa'))](_0x56b35a,_0x526ea8);_0x42f499&&_0x56b35a[_0x2d55('0x50a')](_0x42f499),_0x56b35a[_0x2d55('0x6ce')](this[_0x2d55('0x749')]);},'removeGLTF':function(_0x44fd15){_0x44fd15=this[_0x2d55('0x749')]['getGeometryById'](_0x44fd15);_0x44fd15&&this[_0x2d55('0x749')][_0x2d55('0x15f')](_0x44fd15);},'CLASS_NAME':_0x2d55('0x484')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CB3DtilesLayer']=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib']['Layer'][_0x2d55('0x310')],{'initialize':function(_0x26c9c0,_0xea06f1){var _0x453403={'GnBVJ':function(_0x2e6e11,_0x3e3b2){return _0x2e6e11 instanceof _0x3e3b2;},'yDKDz':function(_0x3c30e6,_0x4b4505){return _0x3c30e6 instanceof _0x4b4505;},'phzlp':_0x2d55('0x546')};BDLayers[_0x2d55('0x84f')]['extend'](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x26c9c0,_0xea06f1);const _0xd7d96=this;this['layer']=new maptalks['Geo3DTilesLayer'](_0x26c9c0,{'offset':function(_0x2c3f25){var _0x1edfb9,_0x3ceee4,_0xc57ad8;return!_0xea06f1[_0x2d55('0x5a0')]||_0x453403[_0x2d55('0x2bd')](_0xea06f1[_0x2d55('0x5a0')],Array)?_0xea06f1[_0x2d55('0x5a0')]&&_0x453403[_0x2d55('0x33c')](_0xea06f1[_0x2d55('0x5a0')],Array)?_0xea06f1[_0x2d55('0x5a0')]:[0x0,0x0]:(_0x3ceee4=(_0x1edfb9=_0xd7d96[_0x2d55('0x749')]['map'])[_0x2d55('0x84c')](),_0xc57ad8=maptalks[_0x2d55('0x156')][_0x2d55('0x184')](_0x2c3f25[_0x2d55('0x6a9')](),_0xea06f1['offset']['from'],_0xea06f1[_0x2d55('0x5a0')]['to']),_0xc57ad8=_0x1edfb9['coordToPointAtRes'](new maptalks['Coordinate'](_0xc57ad8),_0x3ceee4),_0x1edfb9[_0x2d55('0x2e3')](_0x2c3f25,_0x3ceee4)[_0x2d55('0x74f')](_0xc57ad8)[_0x2d55('0x77b')]()['toArray']());},'maxCacheSize':this[_0x2d55('0x4f3')]['maxCacheSize']||0x0,'loadingLimit':this[_0x2d55('0x4f3')][_0x2d55('0x65e')]||0x0,'services':this[_0x2d55('0x4f3')][_0x2d55('0x8b')]}),this[_0x2d55('0x749')]['once'](_0x453403[_0x2d55('0x246')],_0x1cfe48=>{_0x1cfe48=_0xd7d96[_0x2d55('0x749')][_0x2d55('0x164')](_0x1cfe48['index']);_0xd7d96['layer']['map'][_0x2d55('0x25c')](_0x1cfe48,0x0,{'animation':!0x1});});},'setMap':function(_0x186a04){this['map']=_0x186a04;},'setVisible':function(_0xf12de9){_0xf12de9?this['layer'][_0x2d55('0x6a0')]():this[_0x2d55('0x749')][_0x2d55('0x45d')]();},'getVisible':function(){},'CLASS_NAME':'BDLayers.Lib.Layer.CB3DtilesLayer'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x5bd')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBLayer'],{'layer_markers':null,'layer_geoms':null,'initialize':function(_0xdb2165,_0x4c6678){var _0x1ff145={'jiWNP':'created'};BDLayers[_0x2d55('0x84f')]['extend'](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')]['options']),this[_0x2d55('0x4f3')]['forceRenderOnMoving']=!0x1,this[_0x2d55('0x4f3')]['enableAltitude']=this[_0x2d55('0x4f3')][_0x2d55('0x33e')]||!0x1,BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')]['prototype'][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0xdb2165,_0x4c6678),this[_0x2d55('0x3d7')]=new HashMap(),this[_0x2d55('0x238')]=new HashMap(),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x221'))](this['id'],this[_0x2d55('0x4f3')]),this[_0x2d55('0x749')][_0x2d55('0x768')]=this[_0x2d55('0x3d7')],this['trigger'](_0x1ff145[_0x2d55('0x6f7')],this);},'addMarker':function(_0x1f875a){(_0x1f875a['getMarker']?_0x1f875a[_0x2d55('0x5d3')]():_0x1f875a)['addTo'](this[_0x2d55('0x749')]),this[_0x2d55('0x3d7')]['put'](_0x1f875a['id'],_0x1f875a);},'addMarkers':function(_0x35bb09){var _0x22464d=_0x35bb09['map'](function(_0x5803cb){return _0x5803cb[_0x2d55('0x5d3')]?_0x5803cb[_0x2d55('0x5d3')]():_0x5803cb;});this[_0x2d55('0x749')]['addGeometry'](_0x22464d),_0x35bb09[_0x2d55('0x457')](_0x1623d8=>{this[_0x2d55('0x3d7')][_0x2d55('0x63c')](_0x1623d8['id'],_0x1623d8);});},'removeMarker':function(_0x1aadd6){this[_0x2d55('0x749')][_0x2d55('0x15f')]([_0x1aadd6]),this['layer_markers'][_0x2d55('0x860')](_0x1aadd6);},'removeMarkers':function(_0x116a7a){this[_0x2d55('0x749')][_0x2d55('0x15f')](_0x116a7a),_0x116a7a[_0x2d55('0x457')](_0x3013a5=>{this[_0x2d55('0x3d7')][_0x2d55('0x860')](_0x3013a5);});},'getMarker':function(_0x22cad0){return this['layer_markers']['get'](_0x22cad0);},'getMarkers':function(){return this['layer_markers'][_0x2d55('0x644')]();},'addGeometry':function(_0x5841df){_0x5841df&&(this[_0x2d55('0x749')][_0x2d55('0x34c')](_0x5841df[_0x2d55('0x32c')]||_0x5841df),this['layer_geoms'][_0x2d55('0x63c')](_0x5841df['id'],_0x5841df));},'getExtent':function(){return this[_0x2d55('0x749')][_0x2d55('0x164')]();},'addGeometries':function(_0x490e52){var _0x3b19cd;_0x490e52&&(_0x3b19cd=_0x490e52[_0x2d55('0x700')](function(_0x223a68){return _0x223a68[_0x2d55('0x32c')]||_0x223a68;}),this[_0x2d55('0x749')][_0x2d55('0x34c')](_0x3b19cd),_0x490e52[_0x2d55('0x457')](_0x214308=>{this[_0x2d55('0x238')][_0x2d55('0x63c')](_0x214308['id'],_0x214308);}));},'removeGeometry':function(_0x19edca){this[_0x2d55('0x749')][_0x2d55('0x15f')]([_0x19edca]),this['layer_geoms']['remove'](_0x19edca);},'removeGeometries':function(_0x2c2764){this[_0x2d55('0x749')][_0x2d55('0x15f')](_0x2c2764),_0x2c2764[_0x2d55('0x457')](_0x1bca08=>{this[_0x2d55('0x238')][_0x2d55('0x860')](_0x1bca08);});},'getGeometry':function(_0x2b6a4f){return this['layer_geoms'][_0x2d55('0x86')](_0x2b6a4f);},'getGeometries':function(){return this[_0x2d55('0x238')][_0x2d55('0x644')]();},'removeAll':function(){this[_0x2d55('0x749')][_0x2d55('0x7a5')](),this[_0x2d55('0x3d7')][_0x2d55('0x7a5')](),this[_0x2d55('0x238')][_0x2d55('0x7a5')]();},'hide':function(){this[_0x2d55('0x749')][_0x2d55('0x45d')]();},'show':function(){this['layer']['show']();},'filter':function(_0x2193ce){return this['layer'][_0x2d55('0x22f')](_0x2193ce);},'setStyle':function(_0x2dee1e){this[_0x2d55('0x749')]['setStyle'](_0x2dee1e);},'getMask':function(){return this[_0x2d55('0x749')][_0x2d55('0x328')]();},'setMask':function(_0x3adfbc){this[_0x2d55('0x749')][_0x2d55('0x7f7')](_0x3adfbc);},'CLASS_NAME':'BDLayers.Lib.Layer.CBVectorLayer'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBCanvasLayer']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')],{'layer_markers':null,'layer_geoms':null,'initialize':function(_0x2a393a,_0x2ab244){var _0x426154={'EIwAR':'created'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__']['__proto__'][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x4aa')]=!0x1,this[_0x2d55('0x4f3')][_0x2d55('0x33e')]=this[_0x2d55('0x4f3')][_0x2d55('0x33e')]||!0x1,BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x2a393a,_0x2ab244),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x43c'))](this['id'],this[_0x2d55('0x4f3')]),this[_0x2d55('0x533')](_0x426154[_0x2d55('0x777')],this);},'getLayer':function(){return this['layer'];},'CLASS_NAME':_0x2d55('0x3f4')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x14c')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'layer_markers':null,'layer_geoms':null,'initialize':function(_0x203ffc,_0xecd442){var _0x3c7f03={'IIVUM':_0x2d55('0x501')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')]['forceRenderOnMoving']=!0x1,this[_0x2d55('0x4f3')][_0x2d55('0x33e')]=this[_0x2d55('0x4f3')][_0x2d55('0x33e')]||!0x1,BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x203ffc,_0xecd442),this[_0x2d55('0x749')]=new maptalks['ParticleLayer'](this['id'],this[_0x2d55('0x4f3')]),this[_0x2d55('0x533')](_0x3c7f03[_0x2d55('0x643')],this);},'getLayer':function(){return this[_0x2d55('0x749')];},'CLASS_NAME':_0x2d55('0x466')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBImageLayer']=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'layer_markers':null,'layer_geoms':null,'initialize':function(_0x3c9d12,_0x44a753){var _0x249341={'UvtZU':_0x2d55('0x501')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x4aa')]=!0x1,this[_0x2d55('0x4f3')][_0x2d55('0x33e')]=this['options'][_0x2d55('0x33e')]||!0x1,BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x3c9d12,_0x44a753),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x356'))](this['id'],this[_0x2d55('0x4f3')]),this[_0x2d55('0x533')](_0x249341[_0x2d55('0x713')],this);},'getLayer':function(){return this[_0x2d55('0x749')];},'CLASS_NAME':_0x2d55('0x21d')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x320')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'layer_markers':null,'initialize':function(_0x3d6fbe,_0x436fd7){var _0x120f48={'AIiuD':'children','HBNnO':_0x2d55('0x698'),'MWMYQ':_0x2d55('0x1'),'ooqVn':_0x2d55('0x7cd'),'CRojA':_0x2d55('0x59f'),'CHdMu':_0x2d55('0x3f3'),'ZhWSs':_0x2d55('0x501')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x4aa')]=!0x1,this['options'][_0x2d55('0x33e')]=!0x1,BDLayers[_0x2d55('0x47b')]['Layer']['CBLayer'][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x3d6fbe,_0x436fd7),this[_0x2d55('0x3d7')]=new HashMap(),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x6b6'))](this['id'],{'noClusterWithOneMarker':!0x0,'maxClusterZoom':0x12,'maxClusterRadius':_0x436fd7&&_0x436fd7[_0x2d55('0x84d')]?_0x436fd7['radius']:0x32,'symbol':{'markerType':_0x2d55('0x259'),'markerFill':{'property':_0x2d55('0x3f3'),'type':_0x120f48[_0x2d55('0x71b')],'stops':[[0x0,_0x120f48[_0x2d55('0x89b')]],[0x9,'#1bbc9b'],[0x63,_0x120f48[_0x2d55('0x83a')]]]},'markerFillOpacity':0.7,'markerLineOpacity':0x1,'markerLineWidth':0x3,'markerLineColor':_0x120f48[_0x2d55('0x90')],'markerWidth':{'property':_0x120f48[_0x2d55('0x853')],'type':_0x120f48[_0x2d55('0x71b')],'stops':[[0x0,0x28],[0x9,0x3c],[0x63,0x50]]},'markerHeight':{'property':_0x2d55('0x3f3'),'type':_0x120f48[_0x2d55('0x71b')],'stops':[[0x0,0x28],[0x9,0x3c],[0x63,0x50]]}},'drawClusterText':!0x0,'geometryEvents':!0x0,'single':!0x0}),this['layer']['markers']=this[_0x2d55('0x3d7')],setTimeout(function(){var _0x2b5099=this[_0x2d55('0x749')]['getMap']();_0x2b5099['on'](_0x2d55('0x81'),function(_0x339fec){var _0x26e54f=this[_0x2d55('0x749')]['identify'](_0x339fec[_0x2d55('0x203')]);_0x26e54f&&!Array[_0x2d55('0x26a')](_0x26e54f)&&_0x26e54f[_0x2d55('0x28f')]('center')&&_0x26e54f[_0x2d55('0x28f')](_0x120f48['AIiuD'])&&(_0x2b5099[_0x2d55('0x847')](_0x339fec['coordinate']),_0x2b5099[_0x2d55('0x1bf')]());}['bind'](this));}['bind'](this),0x32),this['trigger'](_0x120f48[_0x2d55('0x57e')],this);},'addMarker':function(_0x3df36b){_0x3df36b['getMarker']()[_0x2d55('0x6ce')](this['layer']),this[_0x2d55('0x3d7')][_0x2d55('0x63c')](_0x3df36b['id'],_0x3df36b);},'addMarkers':function(_0xcd5b46){var _0x5d2eeb=_0xcd5b46[_0x2d55('0x700')](function(_0x2b9c39){return _0x2b9c39[_0x2d55('0x5d3')]();});this[_0x2d55('0x749')][_0x2d55('0x34c')](_0x5d2eeb),_0xcd5b46[_0x2d55('0x457')](_0x4d2a43=>{this[_0x2d55('0x3d7')][_0x2d55('0x63c')](_0x4d2a43['id'],_0x4d2a43);});},'removeMarker':function(_0x1f25d7){this[_0x2d55('0x749')]['removeGeometry']([_0x1f25d7]),this['layer_markers'][_0x2d55('0x860')](_0x1f25d7);},'removeMarkers':function(_0x206b4b){this[_0x2d55('0x749')][_0x2d55('0x15f')](_0x206b4b),_0x206b4b[_0x2d55('0x457')](_0x3d3d46=>{this[_0x2d55('0x3d7')][_0x2d55('0x860')](_0x3d3d46);});},'getMarker':function(_0x11fbbb){return this['layer_markers'][_0x2d55('0x86')](_0x11fbbb);},'getMarkers':function(){return this['layer_markers'][_0x2d55('0x644')]();},'removeAll':function(){this['layer'][_0x2d55('0x7a5')](),this['layer_markers'][_0x2d55('0x7a5')]();},'CLASS_NAME':_0x2d55('0x123')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x5cd')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib']['Layer'][_0x2d55('0x310')],{'url':null,'layerName':null,'crs':'EPSG:3857','format':null,'initialize':function(_0x17efd9,_0x5a8697){var _0x4574cb={'nBrQd':'created'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')]['prototype']['initialize'][_0x2d55('0x55e')](this,_0x17efd9,_0x5a8697),this['url']=this[_0x2d55('0x4f3')][_0x2d55('0x3a8')],this['layerName']=this[_0x2d55('0x4f3')]['layerName'],this[_0x2d55('0x796')]=this[_0x2d55('0x4f3')]['crs'],this[_0x2d55('0x6f9')]=this[_0x2d55('0x4f3')][_0x2d55('0x6f9')],this['trigger'](_0x4574cb[_0x2d55('0x598')],this);},'load':function(_0x5aa262){var _0x19f3a6={'JpzVD':function(_0xf8eab2,_0x23462c){return _0xf8eab2(_0x23462c);},'NgEvA':'loaded','nIEkU':_0x2d55('0x7c2'),'bzYac':function(_0x45b975,_0x188da3){return _0x45b975==_0x188da3;},'QntYb':function(_0x550e8c,_0x503cb5){return _0x550e8c+_0x503cb5;},'tyLLP':function(_0x1fd9ff,_0x5456ad){return _0x1fd9ff+_0x5456ad;},'UpNQT':_0x2d55('0x16f'),'kbiHo':_0x2d55('0x228')};var _0x1d2dd7=this;maptalks['SpatialReference']['loadWMTS'](this['url'],function(_0x2fc650,_0x3576d3){var _0x32a44a=_0x2d55('0x75e')[_0x2d55('0x77c')]('|');var _0x53bc5b=0x0;while(!![]){switch(_0x32a44a[_0x53bc5b++]){case'0':_0x2fc650=_0x3576d3['find'](function(_0x4fdc24,_0x37a430,_0x3a4af8){return console[_0x2d55('0x10b')](_0x4fdc24),_0x544bb6[_0x2d55('0x2b5')](_0x4fdc24[_0x2d55('0x7df')][_0x2d55('0x56')],_0x1d2dd7[_0x2d55('0x56')])&&_0x544bb6[_0x2d55('0x2b5')](_0x4fdc24['info'][_0x2d55('0x34b')],_0x1d2dd7[_0x2d55('0x796')]);},_0x3576d3);continue;case'1':_0x1d2dd7[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x7a0'))](_0x1d2dd7['id'],_0x2fc650),_0x5aa262&&(_0x1d2dd7[_0x2d55('0x749')]?_0x19f3a6[_0x2d55('0x72d')](_0x5aa262,{'code':0x1,'message':_0x19f3a6['NgEvA']}):_0x5aa262({'code':0x0,'message':_0x19f3a6[_0x2d55('0x7c9')]}));continue;case'2':var _0x544bb6={'YjGdk':function(_0x358ec9,_0x28ba07){return _0x19f3a6['bzYac'](_0x358ec9,_0x28ba07);}};continue;case'3':if(_0x1d2dd7[_0x2d55('0x6f9')]&&(_0x2fc650[_0x2d55('0x220')]=_0x19f3a6[_0x2d55('0x5dd')](_0x19f3a6[_0x2d55('0x188')](_0x2fc650[_0x2d55('0x220')]['substr'](0x0,_0x2fc650[_0x2d55('0x220')][_0x2d55('0x2a1')]('?')),_0x19f3a6[_0x2d55('0x201')]),_0x1d2dd7[_0x2d55('0x6f9')]),_0x2fc650[_0x2d55('0x7df')][_0x2d55('0x220')]=_0x2fc650[_0x2d55('0x220')]),!_0x2fc650)throw new Error(_0x19f3a6['kbiHo']+_0x1d2dd7['layerName']);continue;case'4':if(_0x2fc650)throw new Error(_0x2fc650);continue;}break;}})[_0x2d55('0x7cf')](this);},'CLASS_NAME':'BDLayers.Lib.Layer.CBWMTSLayer'}),BDLayers['Lib']['Layer'][_0x2d55('0x3a2')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'initialize':function(_0xabf0a1,_0x4635c6){var _0x27b277={'uzZEz':_0x2d55('0x240'),'buzbB':_0x2d55('0x501')};BDLayers['Util']['extend'](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),this['options']['tag']=_0x27b277[_0x2d55('0x143')],this[_0x2d55('0x4f3')][_0x2d55('0x6c4')]=BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x200')][_0x2d55('0x396')],this[_0x2d55('0x4f3')][_0x2d55('0x65a')]=0x16,this[_0x2d55('0x4f3')][_0x2d55('0xf7')]=0x3,this['options'][_0x2d55('0x13a')]=null,BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')][_0x2d55('0x4e2')]['initialize']['call'](this,_0xabf0a1,_0x4635c6),this[_0x2d55('0x749')]=new maptalks['ArcGISTileLayer'](this['id'],{'urlTemplate':this[_0x2d55('0x4f3')][_0x2d55('0x3a8')],'maxZoom':this[_0x2d55('0x4f3')][_0x2d55('0x65a')],'minZoom':this[_0x2d55('0x4f3')]['minZoom'],'cssFilter':this[_0x2d55('0x4f3')]['cssFilter']||null}),this[_0x2d55('0x533')](_0x27b277[_0x2d55('0x6f')],this);},'CLASS_NAME':_0x2d55('0x362')}),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x17e')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'initialize':function(_0x27e1a5,_0x343127,_0x4ad01a){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x27e1a5,_0x4ad01a),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x3d5'))](_0x27e1a5,_0x343127,_0x4ad01a);},'getLayers':function(){return this[_0x2d55('0x749')][_0x2d55('0x331')]();},'addLayer':function(_0x2adc1d){this[_0x2d55('0x749')][_0x2d55('0x197')](_0x2adc1d);},'removeLayer':function(_0x2762cb){this['layer'][_0x2d55('0x150')](_0x2762cb);},'CLASS_NAME':_0x2d55('0x18c')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x48c')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'layer':null,'initialize':function(_0x4bb19e,_0x2ed52a){var _0x20dd1b={'MwAvX':_0x2d55('0x81'),'hikVu':_0x2d55('0x147')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),BDLayers['Lib'][_0x2d55('0x404')]['CBLayer'][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x4bb19e,_0x2ed52a),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x7c4'))](_0x4bb19e,_0x2ed52a),this[_0x2d55('0x749')]['on'](_0x20dd1b[_0x2d55('0x18d')],function(_0x40d694){this[_0x2d55('0x533')]('click',this);}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x749')]['on'](_0x20dd1b[_0x2d55('0x1fa')],function(_0x5d9eeb){this[_0x2d55('0x533')](_0x2d55('0x147'),_0x5d9eeb);}[_0x2d55('0x7cf')](this));},'setStyle':function(_0x154f60){this['layer'][_0x2d55('0x3a9')](_0x154f60);},'highlight':function(_0x2fe7d1){this[_0x2d55('0x749')][_0x2d55('0x7f0')](_0x2fe7d1);},'cancelHighlight':function(_0x3537b6){this[_0x2d55('0x749')][_0x2d55('0x62a')](_0x3537b6);},'getMap':function(){return this[_0x2d55('0x749')][_0x2d55('0x20b')]();},'getId':function(){return this[_0x2d55('0x749')][_0x2d55('0x482')]();},'isVisible':function(){return this[_0x2d55('0x749')][_0x2d55('0x3b')]();},'getRenderer':function(){return this[_0x2d55('0x749')][_0x2d55('0x32e')]();},'load':function(){return this[_0x2d55('0x749')][_0x2d55('0x58d')]();},'_bindMap':function(_0x1658ad){return this[_0x2d55('0x749')][_0x2d55('0x3a1')](_0x1658ad);},'show':function(){this[_0x2d55('0x749')][_0x2d55('0x6a0')]();},'hide':function(){this[_0x2d55('0x749')][_0x2d55('0x45d')]();},'CLASS_NAME':'BDLayers.Lib.Layer.CBGeoJSONLayer'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')]=BDLayers[_0x2d55('0x2ca')]({'projection':null,'layermodal':BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')]['Vector'],'zoomSetting':{'maxZoom':0x12,'minZoom':0x1},'darkTileLayer':null,'vectorTileLayer':null,'satelliteTileLayer':null,'boundary':null,'boundaryColor':_0x2d55('0x175'),'shadeLayer':null,'shadeOptions':null,'annotation':!0x0,'browserCache':!0x0,'initialize':function(_0x19d6c2){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x19d6c2&&(_0x19d6c2[_0x2d55('0x2ef')]&&(this[_0x2d55('0x2ef')]=_0x19d6c2[_0x2d55('0x2ef')]),_0x19d6c2['layermodal'])&&(this[_0x2d55('0x12f')]=_0x19d6c2[_0x2d55('0x12f')]);},'toMap':function(_0x4efe27){this['map']||(this[_0x2d55('0x700')]=_0x4efe27),this[_0x2d55('0x12f')]===BDLayers['Lib']['Constant'][_0x2d55('0x610')]['Vector']?_0x4efe27[_0x2d55('0x197')](this[_0x2d55('0x747')][_0x2d55('0x749')]):this[_0x2d55('0x12f')]===BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')]['Satellite']&&_0x4efe27[_0x2d55('0x197')](this['satelliteTileLayer'][_0x2d55('0x749')]);},'toLayer':function(_0x278ed0){var _0xe54acf={'ZoaxR':function(_0x46a3c4,_0x531ede){return _0x46a3c4===_0x531ede;}};return _0xe54acf[_0x2d55('0x736')](this[_0x2d55('0x12f')],BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')][_0x2d55('0xf4')])?_0x278ed0?this['darkTileLayer']?this['darkTileLayer']['layer']:null:this[_0x2d55('0x747')][_0x2d55('0x749')]:_0xe54acf[_0x2d55('0x736')](this[_0x2d55('0x12f')],BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x610')][_0x2d55('0x5b2')])?this['satelliteTileLayer'][_0x2d55('0x749')]:void 0x0;},'hasDarkLayer':function(){return!!this[_0x2d55('0x510')];},'changeModel':function(_0x158dbf){var _0x3780b0={'nveqz':function(_0x2339fb,_0x1bde09){return _0x2339fb===_0x1bde09;},'sWXWa':_0x2d55('0x77a')};return _0x3780b0['nveqz'](this[_0x2d55('0x12f')],BDLayers['Lib'][_0x2d55('0x168')]['BaseLayerModel'][_0x2d55('0xf4')])?this[_0x2d55('0x12f')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['BaseLayerModel'][_0x2d55('0x5b2')]:this[_0x2d55('0x12f')]===BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')][_0x2d55('0x5b2')]&&(this[_0x2d55('0x12f')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')][_0x2d55('0xf4')]),this[_0x2d55('0x533')](_0x3780b0['sWXWa'],this),this[_0x2d55('0x2a8')](_0x158dbf);},'toMapModel':function(){return this[_0x2d55('0x12f')];},'CLASS_NAME':_0x2d55('0x60d')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x3c9')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')],{'initialize':function(_0x16e748){var _0x3f465c={'UrQnA':function(_0x2b6cb7,_0x16ffb7){return _0x2b6cb7===_0x16ffb7;},'kspfP':_0x2d55('0x57'),'qdoXH':function(_0x40ff6e,_0x2be453){return _0x40ff6e+_0x2be453;},'QEtXC':_0x2d55('0x91'),'IlBKf':function(_0x36994e,_0x18f1bd){return _0x36994e+_0x18f1bd;},'hmSFY':_0x2d55('0x42c'),'YXYco':function(_0x15a1b8,_0x48bb2a){return _0x15a1b8+_0x48bb2a;},'HnOLA':_0x2d55('0x2c0'),'EsnRR':function(_0x2e2898,_0x33b9e2){return _0x2e2898+_0x33b9e2;},'OOtZV':'http://t{s}.tianditu.gov.cn/DataServer?T=vec_c&x={x}&y={y}&l={z}&tk=','sxmdj':_0x2d55('0x1c3'),'Pshwt':_0x2d55('0x678'),'tWQIm':'http://t{s}.tianditu.gov.cn/DataServer?T=img_c&x={x}&y={y}&l={z}&tk='};BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x16e748),_0x3f465c[_0x2d55('0x47d')](this[_0x2d55('0x2ef')],BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x492')])?(this[_0x2d55('0x747')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x3f465c[_0x2d55('0x761')],{'url':[_0x3f465c[_0x2d55('0x23e')](_0x3f465c[_0x2d55('0x239')],BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x249')][_0x2d55('0x1d8')]),_0x3f465c['IlBKf'](_0x3f465c[_0x2d55('0x2b4')],BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x249')]['Tianditu'])],'subdomains':_0x2d55('0x2c0'),'maxZoom':[18.7,18.7],'minZoom':[0x3,0x3]}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['CBTileLayer']('blayer_tdt_s',{'url':[_0x3f465c[_0x2d55('0x63b')](_0x2d55('0x790'),BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x249')][_0x2d55('0x1d8')]),_0x3f465c['YXYco'](_0x3f465c[_0x2d55('0x2b4')],BDLayers[_0x2d55('0x47b')]['Constant']['WebMapKeys'][_0x2d55('0x1d8')])],'subdomains':_0x3f465c[_0x2d55('0x187')],'maxZoom':[18.7,18.7],'minZoom':[0x3,0x3]})):this['projection']===BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x3fa')]['EPSG4326']&&(this[_0x2d55('0x747')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['CBTileLayer'](_0x2d55('0x57'),{'url':[_0x3f465c[_0x2d55('0x869')](_0x3f465c['OOtZV'],BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x249')][_0x2d55('0x1d8')]),_0x3f465c[_0x2d55('0x869')](_0x3f465c[_0x2d55('0xc')],BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x249')][_0x2d55('0x1d8')])],'tileSystem':[0x1,-0x1,-0xb4,0x5a],'subdomains':_0x3f465c[_0x2d55('0x187')],'maxZoom':[18.7,18.7],'minZoom':[0x3,0x3]}),this['satelliteTileLayer']=new BDLayers['Lib']['Layer'][(_0x2d55('0xc9'))](_0x3f465c[_0x2d55('0x34a')],{'url':[_0x3f465c['EsnRR'](_0x3f465c[_0x2d55('0x1d6')],BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x249')][_0x2d55('0x1d8')]),_0x3f465c[_0x2d55('0xc')]+BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['WebMapKeys'][_0x2d55('0x1d8')]],'tileSystem':[0x1,-0x1,-0xb4,0x5a],'subdomains':_0x3f465c[_0x2d55('0x187')],'maxZoom':[18.7,18.7],'minZoom':[0x3,0x3]}));},'CLASS_NAME':'BDLayers.Lib.Layer.TianDiTuLayers'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x41a')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['BaseLayers'],{'initialize':function(_0x5b2c64){var _0x32d393={'JiPnQ':_0x2d55('0x3a6'),'UoRxT':_0x2d55('0x141'),'zZUaa':function(_0x2a85f9,_0x3fe605){return _0x2a85f9+_0x3fe605;},'Phpsr':'blayer_baidu_v','WWURS':_0x2d55('0x103'),'pyXHg':'http://online{s}.map.bdimg.com/onlinelabel/qt=tile&x={x}&y={y}&z={z}&v=009&styles=pl&udt=20210809&scaler=1&p=1','hiOSl':'0123','RwzYK':_0x2d55('0x19b')};BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x735')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x5b2c64),this[_0x2d55('0x510')]=new BDLayers['Lib'][(_0x2d55('0x404'))]['CBTileLayer'](_0x32d393[_0x2d55('0x64e')],{'url':['http://api{s}.map.bdimg.com/customimage/tile?&x={x}&y={y}&z={z}&customid=dark'],'subdomains':_0x32d393[_0x2d55('0x66e')],'maxZoom':0x13,'minZoom':0x3}),_0x5b2c64[_0x2d55('0x3a7')]?this[_0x2d55('0x747')]=new BDLayers[(_0x2d55('0x47b'))]['Layer'][(_0x2d55('0xc9'))](_0x32d393['zZUaa'](_0x32d393[_0x2d55('0x488')],_0x5b2c64['style']),{'url':[_0x32d393[_0x2d55('0x50')](_0x32d393[_0x2d55('0x574')],_0x5b2c64[_0x2d55('0x3a7')])],'subdomains':_0x2d55('0x141'),'maxZoom':0x13,'minZoom':0x3}):this['vectorTileLayer']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x32d393[_0x2d55('0x488')],{'url':[_0x32d393[_0x2d55('0x6db')]],'subdomains':_0x32d393[_0x2d55('0x272')],'maxZoom':0x13,'minZoom':0x3}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x2d55('0xf1'),{'url':[_0x32d393['RwzYK'],_0x2d55('0x132')],'subdomains':_0x32d393['hiOSl'],'maxZoom':[0x13,0x13],'minZoom':[0x3,0x3]}),this[_0x2d55('0x533')]('created',this);},'CLASS_NAME':'BDLayers.Lib.Layer.BaiduLayers'}),BDLayers['Lib'][_0x2d55('0x404')]['AMapGCJ02Layers']=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib']['Layer'][_0x2d55('0x735')],{'initialize':function(_0x209650){var _0x12dce4={'pOgvh':_0x2d55('0x4ae'),'vadYO':_0x2d55('0x341'),'dBZpA':_0x2d55('0x7be'),'daQfo':_0x2d55('0x771'),'tRqfm':_0x2d55('0x4ab'),'WtxBp':'http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}','TrXNG':_0x2d55('0x763'),'rEBru':_0x2d55('0x501')};BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x209650),this[_0x2d55('0x510')]=new BDLayers['Lib'][(_0x2d55('0x404'))]['CBTileLayer'](_0x12dce4[_0x2d55('0xa')],{'url':[_0x2d55('0x719')],'maxZoom':18.7,'minZoom':0x3}),this['vectorTileLayer']=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x12dce4[_0x2d55('0x5c3')],{'url':[_0x12dce4['dBZpA']],'subdomains':_0x12dce4[_0x2d55('0x34f')],'maxZoom':18.7,'minZoom':0x3}),this['satelliteTileLayer']=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x12dce4[_0x2d55('0x51e')],{'url':[_0x12dce4['WtxBp'],_0x12dce4[_0x2d55('0x544')]],'subdomains':'123','maxZoom':[18.7,18.7],'minZoom':[0x3,0x3]}),this[_0x2d55('0x533')](_0x12dce4[_0x2d55('0x458')],this);},'CLASS_NAME':_0x2d55('0x804')}),BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x77')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')],{'initialize':function(_0x154e26){var _0x25b93c={'tSeaU':_0x2d55('0x341'),'RzDPw':_0x2d55('0x7be'),'JAedU':_0x2d55('0x771'),'yTuDM':_0x2d55('0xf'),'uIbVP':_0x2d55('0x763'),'ygGAl':_0x2d55('0x501')};BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x154e26),this['vectorTileLayer']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x25b93c[_0x2d55('0x6a3')],{'url':[_0x25b93c['RzDPw']],'subdomains':_0x25b93c[_0x2d55('0x361')],'maxZoom':0x12,'minZoom':0x3,'offset':BDLayers['Util'][_0x2d55('0x498')]}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['CBTileLayer'](_0x2d55('0x4ab'),{'url':[_0x25b93c['yTuDM'],_0x25b93c['uIbVP']],'subdomains':_0x25b93c[_0x2d55('0x361')],'maxZoom':[0x12,0x12],'minZoom':[0x3,0x3],'offset':BDLayers[_0x2d55('0x84f')]['gcj02Offset']}),this[_0x2d55('0x533')](_0x25b93c[_0x2d55('0x1b8')],this);},'CLASS_NAME':_0x2d55('0x891')}),BDLayers['Lib']['Layer'][_0x2d55('0x6e0')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')],{'zoomSetting':{'maxZoom':0x12,'minZoom':0x1},'geoqTypeUrl':{'streetBlue':_0x2d55('0x49a'),'streetGray':_0x2d55('0x7fd'),'streetWarm':_0x2d55('0x179'),'community':'http://map.geoq.cn/arcgis/rest/services/ChinaOnlineCommunity/MapServer/tile/'},'initialize':function(_0x5be9c4){var _0x37fa9f={'dunVa':_0x2d55('0x4ae'),'MiPcf':function(_0x12a5e3,_0x2b5a50){return _0x12a5e3+_0x2b5a50;},'XbKFi':'/{z}/{y}/{x}','dwclZ':function(_0x19e064,_0x142eaa){return _0x19e064+_0x142eaa;},'UQqdu':'blayer_geoq_v','WTBds':function(_0xd0163e,_0x132fc2){return _0xd0163e+_0x132fc2;},'zeJcn':_0x2d55('0x148'),'kdbRZ':_0x2d55('0x4ab'),'hWqJZ':'http://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}','dTmPZ':_0x2d55('0x763'),'DpmYX':_0x2d55('0x771')};BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x5be9c4),this[_0x2d55('0x510')]=new BDLayers['Lib']['Layer'][(_0x2d55('0xc9'))](_0x37fa9f[_0x2d55('0x1e')],{'url':[_0x37fa9f[_0x2d55('0xa6')](this[_0x2d55('0x58b')][_0x2d55('0x25')],_0x37fa9f['XbKFi'])],'maxZoom':0x12,'minZoom':0x3,'offset':BDLayers[_0x2d55('0x84f')][_0x2d55('0x498')]}),_0x5be9c4[_0x2d55('0x3a7')]?this['vectorTileLayer']=new BDLayers[(_0x2d55('0x47b'))]['Layer'][(_0x2d55('0xc9'))](_0x37fa9f['dwclZ'](_0x37fa9f['UQqdu'],_0x5be9c4[_0x2d55('0x3a7')]),{'url':[_0x37fa9f['WTBds'](this[_0x2d55('0x58b')][_0x5be9c4[_0x2d55('0x3a7')]],_0x37fa9f[_0x2d55('0x669')])],'maxZoom':0x12,'minZoom':0x3,'offset':BDLayers[_0x2d55('0x84f')]['gcj02Offset']}):this['vectorTileLayer']=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x37fa9f[_0x2d55('0x443')],{'url':[_0x37fa9f[_0x2d55('0x5f5')](this[_0x2d55('0x58b')][_0x2d55('0x25')],_0x37fa9f[_0x2d55('0x669')])],'maxZoom':0x12,'minZoom':0x3,'offset':BDLayers[_0x2d55('0x84f')][_0x2d55('0x498')]}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x37fa9f[_0x2d55('0x882')],{'url':[_0x37fa9f[_0x2d55('0x1e6')],_0x37fa9f['dTmPZ']],'subdomains':_0x37fa9f[_0x2d55('0x74b')],'maxZoom':[0x12,0x12],'minZoom':[0x3,0x3],'offset':BDLayers['Util'][_0x2d55('0x498')]}),this[_0x2d55('0x533')](_0x2d55('0x501'),this);},'CLASS_NAME':_0x2d55('0x6c1')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0xd')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x735')],{'zoomSetting':{'maxZoom':0x12,'minZoom':0x1},'geoqTypeUrl':{'streetBlue':_0x2d55('0x49a'),'streetGray':_0x2d55('0x7fd'),'streetWarm':_0x2d55('0x179'),'community':_0x2d55('0x3be')},'initialize':function(_0x3c3d2f){var _0x32c033={'wDeQy':_0x2d55('0x387'),'Sfzaq':function(_0x251e9a,_0x2c133c){return _0x251e9a+_0x2c133c;},'RXYyn':function(_0x152ec5,_0x138863){return _0x152ec5+_0x138863;},'aaoGF':_0x2d55('0x148'),'DfIKg':_0x2d55('0x76b'),'KLMoK':function(_0x29bde6,_0x110596){return _0x29bde6+_0x110596;},'WPZdW':'blayer_amap_s','ZSTEA':_0x2d55('0xf'),'ZkNbG':_0x2d55('0x763'),'lxUqC':_0x2d55('0x771')};BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x735')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x3c3d2f),this[_0x2d55('0x510')]=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))]('blayer_geoq_vstreetBlue',{'url':[this['geoqTypeUrl'][_0x2d55('0x25')]+_0x32c033[_0x2d55('0x779')]],'maxZoom':0x12,'minZoom':0x3}),_0x3c3d2f[_0x2d55('0x3a7')]?this[_0x2d55('0x747')]=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x32c033[_0x2d55('0x13d')](_0x2d55('0x76b'),_0x3c3d2f[_0x2d55('0x3a7')]),{'url':[_0x32c033[_0x2d55('0x314')](this[_0x2d55('0x58b')][_0x3c3d2f[_0x2d55('0x3a7')]],_0x32c033['aaoGF'])],'maxZoom':0x12,'minZoom':0x3}):this[_0x2d55('0x747')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x32c033['DfIKg'],{'url':[_0x32c033[_0x2d55('0x245')](this[_0x2d55('0x58b')][_0x2d55('0x25')],_0x32c033[_0x2d55('0x63d')])],'maxZoom':0x12,'minZoom':0x3}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x32c033[_0x2d55('0x7b3')],{'url':[_0x32c033[_0x2d55('0x493')],_0x32c033[_0x2d55('0x766')]],'subdomains':_0x32c033[_0x2d55('0x5db')],'maxZoom':[0x12,0x12],'minZoom':[0x3,0x3]}),this['trigger']('created',this);},'CLASS_NAME':_0x2d55('0x174')}),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x11f')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x735')],{'initialize':function(_0x1ed85a){var _0xaae9b6={'YlOqE':_0x2d55('0x40b'),'AbAnS':_0x2d55('0x382'),'ENCAZ':_0x2d55('0x501')};BDLayers[_0x2d55('0x47b')]['Layer']['BaseLayers'][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x1ed85a),this['darkTileLayer']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0xaae9b6[_0x2d55('0x655')],{'url':_0x1ed85a[_0x2d55('0x270')]['durl'],'subdomains':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x1c7')],'maxZoom':_0x1ed85a['tilebaseOpt'][_0x2d55('0x28a')],'minZoom':_0x1ed85a[_0x2d55('0x270')]['minzoom'],'offset':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x5a0')]||[0x0,0x0]}),this[_0x2d55('0x747')]=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0xaae9b6[_0x2d55('0x5f8')],{'url':_0x1ed85a[_0x2d55('0x270')]['vurl'],'subdomains':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x1c7')],'maxZoom':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x52f')],'minZoom':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x287')],'offset':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x5a0')]||[0x0,0x0]}),this[_0x2d55('0x49c')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xc9'))](_0x2d55('0x4a'),{'url':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0xd1')],'subdomains':_0x1ed85a[_0x2d55('0x270')]['subdomains'],'maxZoom':_0x1ed85a[_0x2d55('0x270')]['maxzooms'],'minZoom':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x5e0')],'offset':_0x1ed85a[_0x2d55('0x270')][_0x2d55('0x5a0')]||[0x0,0x0]}),this['trigger'](_0xaae9b6[_0x2d55('0x71d')],this);},'CLASS_NAME':_0x2d55('0x6fb')}),BDLayers[_0x2d55('0x47b')]['Overlays']['Marker']=BDLayers['Class']({'options':{'symbol':{'markerFile':null,'markerWidth':0x14,'markerHeight':0x14},'properties':{'foo':_0x2d55('0x2c')}},'marker':null,'initialize':function(_0x4e5564,_0xd67be1,_0x535cb2){var _0x58aeb6={'OEBQa':_0x2d55('0xea'),'GCeyI':_0x2d55('0x5e3'),'buSJO':_0x2d55('0x81')};BDLayers['Util'][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x535cb2&&BDLayers['Util'][_0x2d55('0x222')](this,_0x535cb2),this[_0x2d55('0x8a0')]=new maptalks[(_0x2d55('0x28c'))](_0xd67be1,{'id':_0x4e5564,'properties':this['options']['properties'],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this['options'][_0x2d55('0x31d')],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')]}),this[_0x2d55('0x8a0')]['on'](_0x58aeb6[_0x2d55('0x36')],function(_0x4de1ff){this[_0x2d55('0x533')](_0x2d55('0x81'),this);}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x8a0')]['on'](_0x58aeb6['OEBQa'],function(_0x1922e6){this[_0x2d55('0x533')](_0x58aeb6[_0x2d55('0x3d0')],this);}['bind'](this)),this[_0x2d55('0x8a0')]['on'](_0x58aeb6[_0x2d55('0x8c')],function(_0x212edc){this[_0x2d55('0x533')](_0x58aeb6[_0x2d55('0x8c')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x482')]();},'setMarkerStyle':function(_0x42fee4){var _0x4f83e5={'ombNu':'stylechanged'};this['marker']['updateSymbol'](_0x42fee4),this[_0x2d55('0x533')](_0x4f83e5[_0x2d55('0x2cb')],this);},'setRotationAngle':function(_0x2dd3ea){var _0x12232e={'gMCVm':_0x2d55('0x2f9')};this['marker'][_0x2d55('0x802')]({'markerRotation':this[_0x2d55('0x4f3')][_0x2d55('0x673')]&&_0x2dd3ea?_0x2dd3ea:this['options'][_0x2d55('0x30d')]}),this[_0x2d55('0x533')](_0x12232e['gMCVm'],this);},'getRotationAngle':function(){return this['options']['rotationAngle'];},'moveMarker':function(_0x10357e,_0x1b9baf,_0x3d6d32){var _0x5287a7={'JPpcV':function(_0x4d04e0,_0x243249){return _0x4d04e0-_0x243249;}};var _0x362520=this[_0x2d55('0x8a0')][_0x2d55('0x40')]();_0x1b9baf?this[_0x2d55('0x8a0')][_0x2d55('0x196')]()[_0x2d55('0x555')]({'translate':[_0x5287a7[_0x2d55('0x34d')](_0x10357e[0x0],_0x362520['x']),_0x5287a7['JPpcV'](_0x10357e[0x1],_0x362520['y'])]},{'duration':_0x1b9baf,'focus':_0x3d6d32}):this[_0x2d55('0x8a0')]['setCoordinates'](_0x10357e);},'setCoordinates':function(_0x2224f8){this[_0x2d55('0x8a0')][_0x2d55('0x87c')](_0x2224f8);},'setPopWindow':function(_0x165a79){this[_0x2d55('0x8a0')]&&(this['marker']['getInfoWindow']()&&(this[_0x2d55('0x8a0')][_0x2d55('0x3bc')](),this[_0x2d55('0x8a0')][_0x2d55('0x2ff')]()),this[_0x2d55('0x8a0')][_0x2d55('0x724')](_0x165a79),this['marker'][_0x2d55('0x425')]());},'setAltitude':function(_0x4a3684){this[_0x2d55('0x8a0')]['setAltitude'](_0x4a3684);},'startEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x755')]();},'toGeoJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x1d0')]();},'toJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x49d')]();},'setMenu':function(_0x1e6d81){this[_0x2d55('0x8a0')][_0x2d55('0x177')](_0x1e6d81);},'openMenu':function(){this['marker']['openMenu']();},'CLASS_NAME':_0x2d55('0x6eb')}),BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x44a')]=BDLayers[_0x2d55('0x2ca')]({'options':{'draggable':!0x1,'single':!0x1,'content':'','eventsPropagation':!0x1,'eventsToStop':null,'dx':0x0,'dy':0x0,'autoPan':!0x1,'autoPanDuration':0x258,'animation':null,'animationDuration':0x12c,'pitchWithMap':!0x1,'rotateWithMap':!0x1,'animationName':null,'animationColor':'yellow'},'uiMarker':null,'initialize':function(_0x2c493b,_0x171617,_0xafa4f9){var _0x49d63a={'CwDFa':_0x2d55('0x81')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0xafa4f9&&BDLayers['Util'][_0x2d55('0x222')](this,_0xafa4f9),this[_0x2d55('0x4f3')][_0x2d55('0xd2')]&&(this[_0x2d55('0x4f3')][_0x2d55('0x5b1')]?this[_0x2d55('0x4f3')][_0x2d55('0x15a')]=_0x2d55('0x828')+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+'\x20'+this[_0x2d55('0x4f3')][_0x2d55('0x5b1')]+_0x2d55('0x38f')+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+_0x2d55('0x55f')+this[_0x2d55('0x4f3')]['animationName']+_0x2d55('0x30e')+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+'3\x22></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+this[_0x2d55('0x4f3')][_0x2d55('0x15a')]+_0x2d55('0x897'):this[_0x2d55('0x4f3')][_0x2d55('0x15a')]=_0x2d55('0x828')+this['options'][_0x2d55('0xd2')]+'\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22'+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+_0x2d55('0x55f')+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+_0x2d55('0x30e')+this[_0x2d55('0x4f3')][_0x2d55('0xd2')]+_0x2d55('0x4e')+this[_0x2d55('0x4f3')][_0x2d55('0x15a')]+_0x2d55('0x897')),this[_0x2d55('0x16d')]=new maptalks['ui'][(_0x2d55('0x44a'))](_0x171617,{'id':_0x2c493b,'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'single':this[_0x2d55('0x4f3')][_0x2d55('0x395')],'content':this[_0x2d55('0x4f3')][_0x2d55('0x15a')],'eventsPropagation':this[_0x2d55('0x4f3')][_0x2d55('0x22e')],'eventsToStop':this[_0x2d55('0x4f3')][_0x2d55('0x4d7')],'dx':this[_0x2d55('0x4f3')]['dx'],'dy':this[_0x2d55('0x4f3')]['dy'],'autoPan':this[_0x2d55('0x4f3')][_0x2d55('0x166')],'autoPanDuration':this['options'][_0x2d55('0x390')],'animationName':this[_0x2d55('0x4f3')][_0x2d55('0xd2')],'animationColor':this['options']['animationColor'],'animation':this[_0x2d55('0x4f3')][_0x2d55('0x5d1')],'animationDuration':this[_0x2d55('0x4f3')][_0x2d55('0x4dc')],'pitchWithMap':this['options'][_0x2d55('0x89d')],'rotateWithMap':this[_0x2d55('0x4f3')][_0x2d55('0x4b1')],'verticalAlignment':this['options']['verticalAlignment']||''}),this[_0x2d55('0x16d')]['on'](_0x49d63a['CwDFa'],function(_0xae717a){this[_0x2d55('0x533')](_0x2d55('0x81'),this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x16d')];},'setAltitude':function(_0x5b2e41){this[_0x2d55('0x16d')]['setAltitude'](_0x5b2e41);},'setPopWindow':function(_0xc01f54){var _0x3290d6={'kcBwF':_0x2d55('0x59f')};if(this[_0x2d55('0x16d')]){_0xc01f54=_0x2d55('0x173')+this[_0x2d55('0x4f3')][_0x2d55('0x15a')]+_0x2d55('0x511')+(_0xc01f54[_0x2d55('0x347')]+0x14||0x140)+_0x2d55('0x193')+(_0xc01f54[_0x2d55('0x4f6')]||0x12c)+'px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20height:\x20'+(_0xc01f54['height']||0x12c)+_0x2d55('0x294')+(_0xc01f54[_0x2d55('0x4cd')]||_0x3290d6['kcBwF'])+_0x2d55('0x6ac')+_0xc01f54[_0x2d55('0x15a')]+_0x2d55('0x573');this[_0x2d55('0x16d')][_0x2d55('0x327')](_0xc01f54);let _0x533c18=this;closeDialog=function(){_0x533c18[_0x2d55('0x16d')][_0x2d55('0x327')](_0x533c18[_0x2d55('0x4f3')][_0x2d55('0x15a')]);};}},'CLASS_NAME':_0x2d55('0x366')}),BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x60e')]=BDLayers['Class']({'options':{'imgurl':'','rotateFlag':!0x0,'rotationAngle':0x0,'iconAnchor':[0x0,0x0],'iconSize':[0x20,0x20],'opacity':0x1,'labelText':null,'labelTextSize':null,'labelTextColor':null,'labelTextAnchor':null,'labelTextHaloFill':'#fff','labelTextHaloRadius':0x0,'altitude':0x0,'showBubble':!0x1,'bubblePath':_0x2d55('0x711'),'bubbleSize':[0x41,0x41],'bubbleAnchor':[0x0,0x17],'bubbleColor':'#068bff','draggable':!0x1,'visible':!0x0,'editable':!0x1},'marker':null,'initialize':function(_0x266ebf,_0x52c224,_0x4cfa2e){var _0xb84760={'PcVht':_0x2d55('0x81'),'ZWXCt':'sans-serif','azhNH':_0x2d55('0x2aa'),'UhtoI':_0x2d55('0x385'),'pdHzT':_0x2d55('0x39e')};BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),_0x4cfa2e&&BDLayers['Util'][_0x2d55('0x222')](this,_0x4cfa2e);var _0x4cfa2e={'markerFile':this[_0x2d55('0x4f3')][_0x2d55('0x51b')]||this[_0x2d55('0x4f3')][_0x2d55('0x614')],'markerWidth':this[_0x2d55('0x4f3')][_0x2d55('0x1e4')][0x0],'markerHeight':this['options']['iconSize'][0x1],'markerDx':this[_0x2d55('0x4f3')][_0x2d55('0x5a5')][0x0],'markerDy':this[_0x2d55('0x4f3')][_0x2d55('0x5a5')][0x1],'markerOpacity':this[_0x2d55('0x4f3')][_0x2d55('0x69c')],'markerRotation':this['options']['rotateFlag']?this['options'][_0x2d55('0x30d')]:0x0},_0x3992ee=null,_0x372c13={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]};this[_0x2d55('0x4f3')]['labelText']&&(_0x3992ee={'textFaceName':_0xb84760[_0x2d55('0x274')],'textName':_0xb84760[_0x2d55('0x48b')],'textSize':this[_0x2d55('0x4f3')][_0x2d55('0x332')]||0x14,'textFill':this['options']['labelTextColor']||_0xb84760[_0x2d55('0x72c')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x73c')][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelTextAnchor']?this[_0x2d55('0x4f3')]['labelTextAnchor'][0x1]:0x0,'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')],'textHaloRadius':this['options'][_0x2d55('0x67e')]},_0x372c13[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')]['labelText']),_0x3992ee=_0x3992ee?[_0x4cfa2e,_0x3992ee]:_0x4cfa2e,this['options'][_0x2d55('0x645')]&&(_0x3992ee=Array['isArray'](_0x3992ee)?_0x3992ee:[_0x4cfa2e])[_0x2d55('0x519')]({'markerType':_0xb84760[_0x2d55('0x57d')],'markerPath':[{'transform':_0x2d55('0x848'),'path':this[_0x2d55('0x4f3')]['bubblePath'],'fill':this[_0x2d55('0x4f3')][_0x2d55('0x677')]}],'markerPathWidth':0x640,'markerPathHeight':0x640,'markerWidth':this[_0x2d55('0x4f3')][_0x2d55('0x6e6')][0x0],'markerHeight':this[_0x2d55('0x4f3')][_0x2d55('0x6e6')][0x1],'markerDx':this['options'][_0x2d55('0x5fc')][0x0],'markerDy':this[_0x2d55('0x4f3')]['bubbleAnchor'][0x1]}),this[_0x2d55('0x8a0')]=new maptalks['Marker'](_0x52c224,{'id':_0x266ebf,'properties':_0x372c13,'symbol':_0x3992ee,'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'draggable':this[_0x2d55('0x4f3')]['draggable']}),this[_0x2d55('0x8a0')]['on'](_0xb84760[_0x2d55('0x183')],function(_0x18fef9){this[_0x2d55('0x533')](_0xb84760['PcVht'],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this['marker'];},'setCoordinates':function(_0x317ade){this[_0x2d55('0x8a0')]['setCoordinates'](_0x317ade);},'getId':function(){return this['marker'][_0x2d55('0x482')]();},'setMarkerStyle':function(_0xdffffb){this[_0x2d55('0x8a0')][_0x2d55('0x802')]({'markerFile':_0xdffffb[_0x2d55('0x51b')]||_0xdffffb[_0x2d55('0x614')]?_0xdffffb[_0x2d55('0x51b')]||_0xdffffb[_0x2d55('0x614')]:this[_0x2d55('0x4f3')]['imgurl']||this[_0x2d55('0x4f3')]['imgUrl'],'markerWidth':(_0xdffffb['iconSize']&&_0xdffffb[_0x2d55('0x1e4')][0x0]?_0xdffffb:this[_0x2d55('0x4f3')])[_0x2d55('0x1e4')][0x0],'markerHeight':(_0xdffffb['iconSize']&&_0xdffffb['iconSize'][0x1]?_0xdffffb:this[_0x2d55('0x4f3')])['iconSize'][0x1],'markerDx':(_0xdffffb['iconAnchor']&&_0xdffffb['iconAnchor'][0x0]?_0xdffffb:this[_0x2d55('0x4f3')])['iconAnchor'][0x0],'markerDy':(_0xdffffb[_0x2d55('0x5a5')]&&_0xdffffb[_0x2d55('0x5a5')][0x1]?_0xdffffb:this['options'])[_0x2d55('0x5a5')][0x1],'markerOpacity':_0xdffffb[_0x2d55('0x69c')]||this[_0x2d55('0x4f3')][_0x2d55('0x69c')]}),this[_0x2d55('0x533')](_0x2d55('0x4e3'),this);},'setMarkerProperties':function(_0x38c750){var _0x38c750={'altitude':_0x38c750[_0x2d55('0xab')]||this[_0x2d55('0x4f3')]['altitude'],'name':_0x38c750['labelText']||this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]},_0x242bdb=this[_0x2d55('0x8a0')][_0x2d55('0x84')]();return _0x242bdb[_0x2d55('0xab')]&&(_0x242bdb[_0x2d55('0xab')]=_0x38c750[_0x2d55('0xab')]),this[_0x2d55('0x8a0')][_0x2d55('0x1c4')](_0x242bdb);},'setRotationAngle':function(_0x6e3051){var _0x53491c={'FCskL':_0x2d55('0x2f9')};this[_0x2d55('0x8a0')][_0x2d55('0x802')]({'markerRotation':this[_0x2d55('0x4f3')][_0x2d55('0x673')]&&_0x6e3051?_0x6e3051:this['options'][_0x2d55('0x30d')]}),this[_0x2d55('0x533')](_0x53491c[_0x2d55('0x64')],this);},'getRotationAngle':function(){return this[_0x2d55('0x4f3')]['rotationAngle'];},'moveMarker':function(_0x46c3af,_0x563aac,_0x11c626){var _0x3a980f=this[_0x2d55('0x8a0')][_0x2d55('0x40')]();_0x563aac?this['marker']['bringToFront']()['animate']({'translate':[_0x46c3af[0x0]-_0x3a980f['x'],_0x46c3af[0x1]-_0x3a980f['y']]},{'duration':_0x563aac,'focus':_0x11c626}):this['marker'][_0x2d55('0x87c')](_0x46c3af);},'setPopWindow':function(_0x4a08f2){this[_0x2d55('0x8a0')]&&(this['marker'][_0x2d55('0x708')]()&&(this[_0x2d55('0x8a0')][_0x2d55('0x3bc')](),this[_0x2d55('0x8a0')][_0x2d55('0x2ff')]()),this[_0x2d55('0x8a0')][_0x2d55('0x724')](_0x4a08f2),this['marker']['openInfoWindow']());},'closePopWindow':function(){this[_0x2d55('0x8a0')]&&this[_0x2d55('0x8a0')]['getInfoWindow']()&&(this['marker']['closeInfoWindow'](),this[_0x2d55('0x8a0')][_0x2d55('0x2ff')]());},'remove':function(){this[_0x2d55('0x8a0')]&&this[_0x2d55('0x8a0')][_0x2d55('0x860')]();},'hide':function(){this[_0x2d55('0x8a0')]&&this[_0x2d55('0x8a0')][_0x2d55('0x45d')]();},'show':function(){this[_0x2d55('0x8a0')]&&this['marker'][_0x2d55('0x6a0')]();},'setAltitude':function(_0x4ccb74){this[_0x2d55('0x8a0')]['setAltitude'](_0x4ccb74);},'startEdit':function(){this['marker'][_0x2d55('0x5e2')]();},'endEdit':function(){this['marker']['endEdit']();},'toGeoJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x1d0')]();},'toJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x49d')]();},'setMenu':function(_0x3a470b){this['marker']['setMenu'](_0x3a470b);},'openMenu':function(){this[_0x2d55('0x8a0')][_0x2d55('0x3ee')]();},'CLASS_NAME':_0x2d55('0x6eb')}),BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x448')]=BDLayers[_0x2d55('0x2ca')]({'options':{'draggable':!0x1,'rotateFlag':!0x0,'rotationAngle':0x0,'iconAnchor':[0x0,0x0],'iconSize':[0x20,0x20],'opacity':0x1,'labelText':null,'labelTextSize':null,'labelTextColor':null,'labelTextAnchor':null,'labelTextHaloFill':_0x2d55('0x59f'),'labelTextHaloRadius':0x0,'altitude':0x0,'showBubble':!0x1,'bubblePath':_0x2d55('0x711'),'bubbleSize':[0x41,0x41],'bubbleAnchor':[0x0,0x17],'bubbleColor':_0x2d55('0x74')},'marker':null,'popWindow':null,'initialize':function(_0x15fd37,_0x2dfeba,_0x3d1079){var _0x40456a={'Gwgbf':'path','FDdep':'matrix(1,0,0,1,200,200)','PrCXv':function(_0x1a75b1,_0x43f25f){return _0x1a75b1+_0x43f25f;},'KCHzw':function(_0x23e431,_0x31ac8b){return _0x23e431+_0x31ac8b;},'TCOKL':_0x2d55('0x58e'),'WRttX':_0x2d55('0x2aa'),'xAbLB':_0x2d55('0x385'),'sAXmX':_0x2d55('0x81')};BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),_0x3d1079&&BDLayers[_0x2d55('0x84f')]['setOptions'](this,_0x3d1079);var _0x3d1079={'markerType':_0x40456a[_0x2d55('0x7d')],'markerPath':[{'transform':_0x40456a[_0x2d55('0x4d2')],'path':this[_0x2d55('0x4f3')][_0x2d55('0x1d1')],'fill':this[_0x2d55('0x4f3')]['iconColor']}],'markerPathWidth':0x640,'markerPathHeight':0x640,'markerWidth':this[_0x2d55('0x4f3')][_0x2d55('0x1e4')][0x0],'markerHeight':this[_0x2d55('0x4f3')]['iconSize'][0x1],'markerDx':this[_0x2d55('0x4f3')][_0x2d55('0x5a5')][0x0],'markerDy':this['options'][_0x2d55('0x5a5')][0x1],'markerOpacity':this['options']['opacity'],'markerRotation':this[_0x2d55('0x4f3')][_0x2d55('0x673')]?this[_0x2d55('0x4f3')][_0x2d55('0x30d')]:0x0},_0xed45af=null,_0x86cba5={'altitude':this['options'][_0x2d55('0xab')],'foo':this['options'][_0x2d55('0x645')]?_0x40456a[_0x2d55('0x62b')](_0x40456a[_0x2d55('0x62b')](this[_0x2d55('0x4f3')][_0x2d55('0x64c')],'-'),this[_0x2d55('0x4f3')][_0x2d55('0x677')]['split']('#')[0x1]):_0x40456a[_0x2d55('0x62b')](_0x40456a[_0x2d55('0x6d5')](this[_0x2d55('0x4f3')]['iconName'],'-'),this[_0x2d55('0x4f3')][_0x2d55('0x681')][_0x2d55('0x77c')]('#')[0x1])};this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]&&(_0xed45af={'textFaceName':_0x40456a[_0x2d55('0x760')],'textName':_0x40456a['WRttX'],'textSize':this['options'][_0x2d55('0x332')]||0x14,'textFill':this['options'][_0x2d55('0x15d')]||_0x40456a['xAbLB'],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this['options'][_0x2d55('0x73c')][0x0]:0x0,'textDy':this['options'][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x73c')][0x1]:0x0,'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')],'textHaloRadius':this[_0x2d55('0x4f3')][_0x2d55('0x67e')]},_0x86cba5['name']=this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]),_0xed45af=_0xed45af?[_0x3d1079,_0xed45af]:_0x3d1079,this[_0x2d55('0x4f3')][_0x2d55('0x645')]&&(_0xed45af=Array[_0x2d55('0x26a')](_0xed45af)?_0xed45af:[_0x3d1079])[_0x2d55('0x519')]({'markerType':_0x40456a[_0x2d55('0x7d')],'markerPath':[{'transform':_0x2d55('0x848'),'path':this[_0x2d55('0x4f3')][_0x2d55('0x551')],'fill':this[_0x2d55('0x4f3')]['bubbleColor']}],'markerPathWidth':0x640,'markerPathHeight':0x640,'markerWidth':this[_0x2d55('0x4f3')][_0x2d55('0x6e6')][0x0],'markerHeight':this[_0x2d55('0x4f3')][_0x2d55('0x6e6')][0x1],'markerDx':this[_0x2d55('0x4f3')][_0x2d55('0x5fc')][0x0],'markerDy':this[_0x2d55('0x4f3')][_0x2d55('0x5fc')][0x1]}),this['marker']=new maptalks['Marker'](_0x2dfeba,{'id':_0x15fd37,'draggable':this[_0x2d55('0x4f3')]['draggable'],'properties':_0x86cba5,'symbol':_0xed45af}),this[_0x2d55('0x8a0')]['on'](_0x40456a[_0x2d55('0x157')],function(_0x5b77c0){this['popWindow']&&(this[_0x2d55('0xef')][_0x2d55('0x3b')]()?this[_0x2d55('0xef')]['hide']():this['popWindow']['show'](this[_0x2d55('0x8a0')]['_coordinates'])),this[_0x2d55('0x533')](_0x2d55('0x81'),this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x482')]();},'setMarkerStyle':function(_0x6e5825){var _0xd637e6={'ZIHVn':'stylechanged'};this[_0x2d55('0x8a0')]['updateSymbol']({'markerFile':_0x6e5825[_0x2d55('0x51b')]||this[_0x2d55('0x4f3')]['imgurl'],'markerWidth':(_0x6e5825[_0x2d55('0x1e4')]&&_0x6e5825[_0x2d55('0x1e4')][0x0]?_0x6e5825:this[_0x2d55('0x4f3')])[_0x2d55('0x1e4')][0x0],'markerHeight':(_0x6e5825[_0x2d55('0x1e4')]&&_0x6e5825['iconSize'][0x1]?_0x6e5825:this['options'])[_0x2d55('0x1e4')][0x1],'markerDx':(_0x6e5825[_0x2d55('0x5a5')]&&_0x6e5825[_0x2d55('0x5a5')][0x0]?_0x6e5825:this[_0x2d55('0x4f3')])[_0x2d55('0x5a5')][0x0],'markerDy':(_0x6e5825[_0x2d55('0x5a5')]&&_0x6e5825[_0x2d55('0x5a5')][0x1]?_0x6e5825:this['options'])[_0x2d55('0x5a5')][0x1],'markerOpacity':_0x6e5825[_0x2d55('0x69c')]||this[_0x2d55('0x4f3')]['opacity']}),this['trigger'](_0xd637e6[_0x2d55('0x6ec')],this);},'setMarkerProperties':function(_0x1bf26c){var _0x1bf26c={'altitude':_0x1bf26c['altitude']||this[_0x2d55('0x4f3')]['altitude'],'name':_0x1bf26c['labelText']||this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]},_0x58826d=this[_0x2d55('0x8a0')][_0x2d55('0x84')]();return _0x58826d[_0x2d55('0xab')]&&(_0x58826d['altitude']=_0x1bf26c[_0x2d55('0xab')]),this[_0x2d55('0x8a0')][_0x2d55('0x1c4')](_0x58826d);},'setRotationAngle':function(_0x2191c6){var _0x1d172a={'BxJkJ':_0x2d55('0x2f9')};this[_0x2d55('0x8a0')][_0x2d55('0x802')]({'markerRotation':this[_0x2d55('0x4f3')]['rotateFlag']&&_0x2191c6?_0x2191c6:this[_0x2d55('0x4f3')]['rotationAngle']}),this[_0x2d55('0x533')](_0x1d172a[_0x2d55('0x105')],this);},'getRotationAngle':function(){return this[_0x2d55('0x4f3')]['rotationAngle'];},'moveMarker':function(_0xccd45c,_0x3d4300){var _0x145732={'OLRuo':function(_0x3c0e96,_0x398517){return _0x3c0e96-_0x398517;}};var _0xe51ec9=this[_0x2d55('0x8a0')][_0x2d55('0x40')]();_0x3d4300?this[_0x2d55('0x8a0')][_0x2d55('0x196')]()[_0x2d55('0x555')]({'translate':[_0xccd45c[0x0]-_0xe51ec9['x'],_0x145732[_0x2d55('0x478')](_0xccd45c[0x1],_0xe51ec9['y'])]},{'duration':_0x3d4300,'focus':!0x0}):this[_0x2d55('0x8a0')][_0x2d55('0x87c')](_0xccd45c);},'setPopWindow':function(_0x3b0855){this[_0x2d55('0x8a0')]&&(this[_0x2d55('0x8a0')][_0x2d55('0x708')]()&&(this[_0x2d55('0x8a0')]['closeInfoWindow'](),this[_0x2d55('0x8a0')][_0x2d55('0x2ff')]()),this[_0x2d55('0x8a0')][_0x2d55('0x724')](_0x3b0855),this[_0x2d55('0x8a0')][_0x2d55('0x425')]());},'setPopContent':function(_0x37eee7){var _0x585c50={'knUSM':_0x2d55('0x81'),'ohuRz':'#fff'};this[_0x2d55('0x8a0')]&&(_0x37eee7={'autoOpenOn':null,'autoCloseOn':_0x585c50[_0x2d55('0x24e')],'single':!0x0,'width':0x190,'minHeight':0x37,'custom':!0x0,'content':_0x2d55('0x107')+(this[_0x2d55('0x4f3')][_0x2d55('0x4d4')]||_0x585c50[_0x2d55('0x5ab')])+_0x2d55('0x4f')+_0x37eee7+_0x2d55('0x3e7')},this['popWindow']=new maptalks['ui'][(_0x2d55('0x728'))](_0x37eee7),this[_0x2d55('0xef')][_0x2d55('0x6ce')](this['marker']));},'startEdit':function(){this['marker'][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x755')]();},'toGeoJSON':function(){return this[_0x2d55('0x8a0')]['toGeoJSON']();},'toJSON':function(){return this['marker'][_0x2d55('0x49d')]();},'setMenu':function(_0x444233){this[_0x2d55('0x8a0')][_0x2d55('0x177')](_0x444233);},'openMenu':function(){this[_0x2d55('0x8a0')]['openMenu']();},'CLASS_NAME':_0x2d55('0x2f4')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x38')]=BDLayers[_0x2d55('0x2ca')]({'options':{'opacity':0x1,'labelText':null,'labelTextSize':null,'labelTextColor':null,'labelTextAnchor':null,'labelTextHaloFill':_0x2d55('0x59f'),'labelTextHaloRadius':0x5,'labelTextWrapWidth':null,'labelTextWrapCharacter':'\x0a','labelTextLineSpacing':0x0,'labelTextHorizontalAlignment':'middle','labelTextVerticalAlignment':_0x2d55('0x1b1'),'labelTextAlign':'center'},'marker':null,'initialize':function(_0x189a09,_0x2e8c24,_0x4d5435){var _0x5556be={'mXkmO':_0x2d55('0x81'),'OPwqB':'sans-serif','qPYjC':'{name}','Bipqk':_0x2d55('0x385')};BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),_0x4d5435&&BDLayers['Util']['setOptions'](this,_0x4d5435);var _0x4d5435={'textFaceName':_0x5556be[_0x2d55('0x72')],'textName':_0x5556be[_0x2d55('0x1ba')],'textSize':this['options'][_0x2d55('0x332')]||0x14,'textFill':this['options'][_0x2d55('0x15d')]||_0x5556be[_0x2d55('0x81b')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')]['labelTextAnchor'][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelTextAnchor']?this[_0x2d55('0x4f3')]['labelTextAnchor'][0x1]:0x0,'textHaloFill':this['options'][_0x2d55('0x35f')],'textHaloRadius':this[_0x2d55('0x4f3')][_0x2d55('0x67e')],'textWrapWidth':this['options']['labelTextWrapWidth'],'textWrapCharacter':this['options']['labelTextWrapCharacter'],'textLineSpacing':this['options'][_0x2d55('0xca')],'textHorizontalAlignment':this[_0x2d55('0x4f3')]['labelTextHorizontalAlignment'],'textVerticalAlignment':this[_0x2d55('0x4f3')][_0x2d55('0x495')],'textAlign':this[_0x2d55('0x4f3')][_0x2d55('0x474')]},_0x3a7d07={'name':this[_0x2d55('0x4f3')][_0x2d55('0x2fa')],'altitude':this[_0x2d55('0x4f3')]['altitude']||0x0};this[_0x2d55('0x8a0')]=new maptalks['Marker'](_0x2e8c24,{'id':_0x189a09,'properties':_0x3a7d07,'symbol':_0x4d5435}),this[_0x2d55('0x8a0')]['on'](_0x5556be[_0x2d55('0x818')],function(_0x86292f){this[_0x2d55('0x533')](_0x5556be['mXkmO'],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x482')]();},'startEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x755')]();},'toGeoJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x1d0')]();},'toJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x49d')]();},'setMenu':function(_0x4c74f3){this[_0x2d55('0x8a0')][_0x2d55('0x177')](_0x4c74f3);},'openMenu':function(){this[_0x2d55('0x8a0')][_0x2d55('0x3ee')]();},'CLASS_NAME':_0x2d55('0x854')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x658')]=BDLayers[_0x2d55('0x2ca')]({'options':{'draggable':!0x1,'single':!0x1,'eventsPropagation':!0x1,'eventsToStop':null,'dx':0x0,'dy':0x0,'autoPan':!0x1,'autoPanDuration':0x258,'pitchWithMap':!0x1,'rotateWithMap':!0x1},'uiMarker':null,'infoWindow':null,'initialize':function(_0x4b08ac,_0x9fe5d6,_0x1032b1){var _0x39c641={'PJGRI':_0x2d55('0x81'),'wECyS':_0x2d55('0x59f'),'Jkigt':_0x2d55('0x385')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x1032b1&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x1032b1),this[_0x2d55('0x142')]=_0x9fe5d6,this[_0x2d55('0x16d')]=new maptalks['ui']['UIMarker'](_0x9fe5d6,{'id':_0x4b08ac,'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'single':this['options']['single'],'content':'<div\x20class=\x22iconfont\x20'+this[_0x2d55('0x4f3')]['icon']+_0x2d55('0x78f')+(this[_0x2d55('0x4f3')]['iconSize']||0x10)+_0x2d55('0x5be')+(this[_0x2d55('0x4f3')][_0x2d55('0x681')]||_0x39c641['wECyS'])+_0x2d55('0x6a4')+(this[_0x2d55('0x4f3')][_0x2d55('0x332')]||0xc)+_0x2d55('0x5be')+(this['options'][_0x2d55('0x15d')]||_0x39c641[_0x2d55('0x3fd')])+_0x2d55('0x291')+(this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]||'')+'</div>\x0a\x09\x09\x09\x09\x09\x09\x09\x09\x09\x20</div>','eventsPropagation':this[_0x2d55('0x4f3')][_0x2d55('0x22e')],'eventsToStop':this[_0x2d55('0x4f3')][_0x2d55('0x4d7')],'dx':this[_0x2d55('0x4f3')]['dx'],'dy':this[_0x2d55('0x4f3')]['dy'],'autoPan':this[_0x2d55('0x4f3')][_0x2d55('0x166')],'autoPanDuration':this[_0x2d55('0x4f3')][_0x2d55('0x390')],'pitchWithMap':this[_0x2d55('0x4f3')][_0x2d55('0x89d')],'rotateWithMap':this[_0x2d55('0x4f3')][_0x2d55('0x4b1')]}),this[_0x2d55('0x16d')]['on'](_0x39c641[_0x2d55('0x5e7')],function(_0x4077d6){this['infoWindow']&&(this[_0x2d55('0x514')][_0x2d55('0x3b')]()?this[_0x2d55('0x514')][_0x2d55('0x45d')]():this[_0x2d55('0x514')][_0x2d55('0x6a0')](this[_0x2d55('0x16d')]['_coordinate'])),this[_0x2d55('0x533')](_0x39c641[_0x2d55('0x5e7')],this);}['bind'](this));},'getMarker':function(){return this[_0x2d55('0x16d')];},'removeMarker':function(){var _0xddaa0a={'YhcmY':_0x2d55('0x2d2'),'CmaGM':function(_0x5a2f1a,_0xce7a91){return _0x5a2f1a!=_0xce7a91;}};this[_0x2d55('0x16d')]['remove']();var _0x5e6a48=document['querySelector'](_0xddaa0a[_0x2d55('0x867')]);_0xddaa0a[_0x2d55('0x435')](null,_0x5e6a48)&&_0x5e6a48[_0x2d55('0x89a')]['removeChild'](_0x5e6a48);},'setPopContent':function(_0x316c8d){var _0x143498={'VHlUS':_0x2d55('0x81'),'NLtWW':_0x2d55('0x59f')};this[_0x2d55('0x16d')]&&(_0x316c8d={'autoOpenOn':null,'autoCloseOn':_0x143498[_0x2d55('0x145')],'single':!0x0,'width':0x190,'minHeight':0x37,'custom':!0x0,'dy':-0xf,'content':_0x2d55('0x107')+(this[_0x2d55('0x4f3')][_0x2d55('0x4d4')]||_0x143498[_0x2d55('0x40d')])+_0x2d55('0x54a')+_0x316c8d+_0x2d55('0x4c5')},this[_0x2d55('0x514')]=new maptalks['ui'][(_0x2d55('0x728'))](_0x316c8d),this[_0x2d55('0x514')][_0x2d55('0x6ce')](this['uiMarker']));},'CLASS_NAME':_0x2d55('0x77f')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')]=BDLayers[_0x2d55('0x2ca')]({'options':{'coordinates':null,'visible':!0x0,'editable':!0x0,'cursor':null,'shadowBlur':0x0,'shadowColor':_0x2d55('0x171'),'draggable':!0x1,'dragShadow':!0x1,'drawOnAxis':null,'symbol':null,'smoothness':0x0,'properties':{}},'id':null,'geom':null,'initialize':function(_0x51b170,_0x58bbd3){this['id']=_0x51b170,BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x58bbd3&&BDLayers['Util'][_0x2d55('0x222')](this,_0x58bbd3);},'toGeoJSON':function(){return this[_0x2d55('0x32c')]['toGeoJSON']();},'updateSymbol':function(_0x2481fa){this[_0x2d55('0x32c')][_0x2d55('0x802')](_0x2481fa);},'animate':function(_0x25c827){this[_0x2d55('0x32c')][_0x2d55('0x555')]({'symbol':_0x25c827[_0x2d55('0x21c')]},{'repeat':_0x25c827['repeat']});},'setAltitude':function(_0x49ec45){this['geom']['setAltitude'](_0x49ec45);},'copy':function(){return this[_0x2d55('0x32c')]['copy']();},'translate':function(_0x586d3f,_0x2c410a){return this[_0x2d55('0x32c')]['translate'](_0x586d3f,_0x2c410a);},'show':function(){this['geom']&&this[_0x2d55('0x32c')]['show']();},'hide':function(){this[_0x2d55('0x32c')]&&this[_0x2d55('0x32c')][_0x2d55('0x45d')]();},'getExtent':function(){return this['geom'][_0x2d55('0x164')]();},'filter':function(_0x5ef68e){return this[_0x2d55('0x32c')]['filter'](_0x5ef68e);},'setZIndex':function(_0x5e6868){this['geom']['setZIndex'](_0x5e6868);},'bringToFront':function(){this[_0x2d55('0x32c')]['bringToFront']();},'bringToBack':function(){this['geom'][_0x2d55('0x6ae')]();},'startEdit':function(){this['geom'][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x32c')][_0x2d55('0x755')]();},'containsPoint':function(_0x5bdf88){return this[_0x2d55('0x32c')][_0x2d55('0x865')](_0x5bdf88);},'toJSON':function(){return this['geom']['toJSON']();},'setMenu':function(_0x330e8b){this['geom'][_0x2d55('0x177')](_0x330e8b);},'openMenu':function(){this[_0x2d55('0x32c')]['openMenu']();},'CLASS_NAME':_0x2d55('0x70e')}),BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0xfd')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x2fa7e9,_0x307a29){var _0x5df3cf={'ucyPU':_0x2d55('0x81'),'XVNun':_0x2d55('0x4f1'),'nIEYq':_0x2d55('0x741'),'toMwK':_0x2d55('0x2ab'),'hRbQN':_0x2d55('0x58e'),'YzIKm':'{name}'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this['options']['cursor']=_0x5df3cf[_0x2d55('0x6d4')],this['options'][_0x2d55('0x21c')]={'lineColor':_0x5df3cf[_0x2d55('0x32a')],'lineWidth':0x2,'polygonFill':_0x5df3cf['toMwK'],'polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')]['prototype']['initialize'][_0x2d55('0x55e')](this,_0x2fa7e9,_0x307a29);_0x2fa7e9={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0,'foo':this['options']['foo']};this[_0x2d55('0x4f3')]['labelSymbol']&&this['options'][_0x2d55('0x322')][_0x2d55('0x2fa')]&&(this[_0x2d55('0x4f3')][_0x2d55('0x21c')]=[this['options'][_0x2d55('0x21c')]],this[_0x2d55('0x4f3')][_0x2d55('0x21c')]['push']({'textFaceName':_0x5df3cf[_0x2d55('0x7e1')],'textName':_0x5df3cf['YzIKm'],'textSize':this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x332')]||0x14,'textFill':this['options'][_0x2d55('0x322')][_0x2d55('0x15d')]||_0x2d55('0x385'),'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelTextAnchor']?this['options'][_0x2d55('0x322')][_0x2d55('0x73c')][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')][0x1]:0x0}),_0x2fa7e9[_0x2d55('0x20e')]=this['options']['labelSymbol'][_0x2d55('0x2fa')]),this[_0x2d55('0x32c')]=new maptalks[(_0x2d55('0xfd'))](this[_0x2d55('0x4f3')]['coordinates'],{'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this['options'][_0x2d55('0x242')],'shadowColor':this['options'][_0x2d55('0x7a')],'draggable':this['options'][_0x2d55('0x6c2')],'dragShadow':this[_0x2d55('0x4f3')]['dragShadow'],'drawOnAxis':this[_0x2d55('0x4f3')]['drawOnAxis'],'symbol':this[_0x2d55('0x4f3')]['symbol'],'properties':_0x2fa7e9,'smoothness':this['options'][_0x2d55('0x39b')]}),this[_0x2d55('0x32c')]['on'](_0x2d55('0x81'),function(_0x3ef2a9){this[_0x2d55('0x533')](_0x5df3cf[_0x2d55('0x18e')],this);}[_0x2d55('0x7cf')](this));},'getExtent':function(){return this['geom'][_0x2d55('0x164')]();},'animateShow':function(_0x31fb0f,_0x617e9e){this['geom'][_0x2d55('0x2fb')](_0x31fb0f,function(_0x3cec6a,_0xd7a98e){_0x617e9e&&_0x617e9e(_0x3cec6a,_0xd7a98e);});},'setPopWindow':function(_0x1f3b23){this[_0x2d55('0x32c')]&&(this[_0x2d55('0x32c')][_0x2d55('0x708')]()&&(this[_0x2d55('0x32c')]['closeInfoWindow'](),this[_0x2d55('0x32c')][_0x2d55('0x2ff')]()),this[_0x2d55('0x32c')]['setInfoWindow'](_0x1f3b23),this[_0x2d55('0x32c')][_0x2d55('0x425')]());},'CLASS_NAME':_0x2d55('0x593')}),BDLayers['Lib'][_0x2d55('0x58c')]['Line']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Overlays']['Geom'],{'initialize':function(_0xc9d74f,_0x51f658){var _0x4d5dce={'fMgnG':'click','ljXuO':_0x2d55('0x1c1')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x2d55('0x4f1'),this['options'][_0x2d55('0x21c')]={'lineColor':_0x4d5dce[_0x2d55('0x268')],'lineWidth':0x3},BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')]['prototype'][_0x2d55('0x27c')]['call'](this,_0xc9d74f,_0x51f658),this[_0x2d55('0x32c')]=new maptalks['LineString'](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'id':_0xc9d74f,'arrowStyle':this[_0x2d55('0x4f3')][_0x2d55('0x687')],'arrowPlacement':this[_0x2d55('0x4f3')]['arrowPlacement'],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this['options']['shadowBlur'],'shadowColor':this['options'][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'dragShadow':this['options'][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'properties':{'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0,'foo':this[_0x2d55('0x4f3')][_0x2d55('0x144')]},'enableSimplify':this[_0x2d55('0x4f3')][_0x2d55('0x76a')],'enableClip':this['options'][_0x2d55('0x748')],'simplifyTolerance':this[_0x2d55('0x4f3')][_0x2d55('0x2f6')]||0x2}),this[_0x2d55('0x32c')]['on'](_0x4d5dce[_0x2d55('0x517')],function(_0x5226a9){this['trigger'](_0x4d5dce[_0x2d55('0x517')],this);}[_0x2d55('0x7cf')](this));},'hide':function(){this[_0x2d55('0x32c')][_0x2d55('0x45d')]();},'animateShow':function(_0x1fbe35,_0x130c54){var _0x566cd9={'iqBzm':function(_0x3405db,_0xbe6cdd,_0x5ab279){return _0x3405db(_0xbe6cdd,_0x5ab279);}};this['geom']['animateShow'](_0x1fbe35,function(_0x2a815d,_0x507d93){_0x130c54&&_0x566cd9[_0x2d55('0x79f')](_0x130c54,_0x2a815d,_0x507d93);});},'setPopWindow':function(_0x4b813f){this[_0x2d55('0x32c')]&&(this[_0x2d55('0x32c')][_0x2d55('0x708')]()&&(this['geom'][_0x2d55('0x3bc')](),this['geom']['removeInfoWindow']()),this['geom']['setInfoWindow'](_0x4b813f),this[_0x2d55('0x32c')][_0x2d55('0x425')]());},'getCoordinates':function(){return this['geom'][_0x2d55('0x601')]();},'CLASS_NAME':_0x2d55('0x6e8')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x306')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x1f27e6,_0x265476){var _0x567852={'hHnXK':_0x2d55('0xdb'),'CZVxG':'rgb(135,196,240)','NMLnl':_0x2d55('0x81')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this['options'][_0x2d55('0x701')]='pointer',this[_0x2d55('0x4f3')][_0x2d55('0x21c')]={'lineColor':_0x2d55('0x741'),'lineWidth':0x2,'polygonFill':_0x567852[_0x2d55('0x2e4')],'polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['Geom'][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x1f27e6,_0x265476),this['geom']=new maptalks['MultiPolygon'](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'visible':this['options'][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')]['editable'],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')]['shadowBlur'],'shadowColor':this[_0x2d55('0x4f3')][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this['options']['drawOnAxis'],'symbol':this['options'][_0x2d55('0x21c')],'properties':{'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0}}),this[_0x2d55('0x32c')]['on'](_0x567852[_0x2d55('0x308')],function(_0x58b0be){this[_0x2d55('0x533')](_0x2d55('0x81'),this);}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x32c')]['on'](_0x567852[_0x2d55('0x125')],function(_0x2ccd87){this[_0x2d55('0x533')](_0x567852[_0x2d55('0x125')],this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x740')}),BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x6be')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')],{'initialize':function(_0x2b5d1d,_0x482ed6){var _0x2ded9c={'JAzAF':_0x2d55('0x81')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x2d55('0x4f1'),this[_0x2d55('0x4f3')][_0x2d55('0x21c')]={'lineColor':_0x2d55('0x1c1'),'lineWidth':0x3},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')]['prototype'][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x2b5d1d,_0x482ed6),this['geom']=new maptalks[(_0x2d55('0x415'))](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'arrowStyle':this[_0x2d55('0x4f3')][_0x2d55('0x687')],'arrowPlacement':this[_0x2d55('0x4f3')][_0x2d55('0x465')],'visible':this['options'][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')]['shadowColor'],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')][_0x2d55('0x59e')],'symbol':this['options'][_0x2d55('0x21c')],'properties':{'altitude':this[_0x2d55('0x4f3')]['altitude']||0x0}}),this[_0x2d55('0x32c')]['on'](_0x2ded9c[_0x2d55('0x431')],function(_0x15bbba){this[_0x2d55('0x533')](_0x2ded9c[_0x2d55('0x431')],this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':'BDLayers.Lib.Overlays.MultiLine'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x4c0')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x14bda6,_0x161192,_0x1d4c60){var _0x25bdc6={'TGSAL':_0x2d55('0x81')};BDLayers['Util']['extend'](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers['Lib'][_0x2d55('0x58c')]['Geom'][_0x2d55('0x4e2')]['initialize']['call'](this,_0x14bda6,_0x1d4c60),this['marker']=new maptalks['MultiPoint'](_0x161192,this[_0x2d55('0x4f3')]),this[_0x2d55('0x8a0')]['on'](_0x25bdc6[_0x2d55('0xad')],function(_0x30d72a){this[_0x2d55('0x533')](_0x25bdc6[_0x2d55('0xad')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'CLASS_NAME':_0x2d55('0x165')}),BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x2b2')]=BDLayers['Class']({'marker':null,'initialize':function(_0x3d41a0,_0x13ae50){var _0x4e6dc5={'lmGNW':_0x2d55('0x81')};BDLayers['Util'][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x13ae50&&BDLayers[_0x2d55('0x84f')]['setOptions'](this,_0x13ae50),this['marker']=new maptalks[(_0x2d55('0x2b2'))](_0x3d41a0,this['options']),this[_0x2d55('0x8a0')]['on'](_0x4e6dc5['lmGNW'],function(_0x5d27d0){this[_0x2d55('0x533')](_0x4e6dc5[_0x2d55('0x138')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'CLASS_NAME':_0x2d55('0x2d4')}),BDLayers['Lib']['Overlays'][_0x2d55('0x6a')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x1db289,_0xed358d){var _0x4a4cf6={'PIjJG':_0x2d55('0x81')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x756')]['prototype'][_0x2d55('0x27c')]['call'](this,_0x1db289,_0xed358d),_0xed358d=_0xed358d[_0x2d55('0x700')](_0x560b38=>_0x560b38[_0x2d55('0x32c')]||_0x560b38[_0x2d55('0x8a0')]),this[_0x2d55('0x32c')]=new maptalks[(_0x2d55('0x6a'))](_0xed358d),this[_0x2d55('0x32c')]['on'](_0x4a4cf6[_0x2d55('0x6f0')],function(_0x1d0208){this[_0x2d55('0x533')](_0x4a4cf6[_0x2d55('0x6f0')],this);}['bind'](this));},'CLASS_NAME':_0x2d55('0x407')}),BDLayers['Lib'][_0x2d55('0x58c')]['Rectangle']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x3c8e04,_0x406b92){var _0x29d2e3={'ANvCp':_0x2d55('0x4f1'),'lOPGC':_0x2d55('0x2ab'),'stlqB':_0x2d55('0x58e'),'qJDRB':_0x2d55('0x2aa'),'yvrKC':_0x2d55('0x385')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x29d2e3[_0x2d55('0x7d4')],this['options'][_0x2d55('0x21c')]={'lineColor':_0x2d55('0x741'),'lineWidth':0x2,'polygonFill':_0x29d2e3[_0x2d55('0x6a1')],'polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x3c8e04,_0x406b92);_0x3c8e04={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0,'foo':this[_0x2d55('0x4f3')][_0x2d55('0x144')]};this[_0x2d55('0x4f3')][_0x2d55('0x322')]&&this['options']['labelSymbol'][_0x2d55('0x2fa')]&&(this['options'][_0x2d55('0x21c')]=[this[_0x2d55('0x4f3')][_0x2d55('0x21c')]],this[_0x2d55('0x4f3')]['symbol']['push']({'textFaceName':_0x29d2e3[_0x2d55('0x4f8')],'textName':_0x29d2e3[_0x2d55('0x743')],'textSize':this[_0x2d55('0x4f3')]['labelSymbol']['labelTextSize']||0x14,'textFill':this['options'][_0x2d55('0x322')][_0x2d55('0x15d')]||_0x29d2e3[_0x2d55('0x85b')],'textDx':this['options']['labelSymbol'][_0x2d55('0x73c')]?this['options'][_0x2d55('0x322')]['labelTextAnchor'][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')][0x1]:0x0}),_0x3c8e04['name']=this[_0x2d55('0x4f3')]['labelSymbol']['labelText']),this['geom']=new maptalks['Rectangle'](this[_0x2d55('0x4f3')][_0x2d55('0x537')],this['options'][_0x2d55('0x4f6')],this[_0x2d55('0x4f3')]['height'],{'id':this[_0x2d55('0x4f3')]['id'],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this['options'][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')]['cursor'],'shadowBlur':this['options'][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')]['shadowColor'],'draggable':this['options'][_0x2d55('0x6c2')],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')]['drawOnAxis'],'symbol':this[_0x2d55('0x4f3')]['symbol'],'properties':_0x3c8e04}),this['geom']['on'](_0x2d55('0x81'),function(_0x1b5bfc){this['trigger']('click',this);}['bind'](this));},'CLASS_NAME':_0x2d55('0x2c1')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x78c')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')],{'initialize':function(_0x4f43d3,_0x33b2c2){var _0x1a6f73={'utlMK':_0x2d55('0x741'),'wYotJ':'sans-serif','bYExa':_0x2d55('0x2aa'),'wcHOK':_0x2d55('0x385'),'qFhvF':'click'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x2d55('0x4f1'),this[_0x2d55('0x4f3')][_0x2d55('0x21c')]={'lineColor':_0x1a6f73[_0x2d55('0x641')],'lineWidth':0x2,'polygonFill':'rgb(135,196,240)','polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x4f43d3,_0x33b2c2);_0x4f43d3={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0};this[_0x2d55('0x4f3')][_0x2d55('0x322')]&&this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x2fa')]&&(this['options'][_0x2d55('0x21c')]=[this[_0x2d55('0x4f3')][_0x2d55('0x21c')]],this['options'][_0x2d55('0x21c')][_0x2d55('0x590')]({'textFaceName':_0x1a6f73[_0x2d55('0x194')],'textName':_0x1a6f73[_0x2d55('0x28')],'textSize':this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelTextSize']||0x14,'textFill':this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x15d')]||_0x1a6f73[_0x2d55('0x181')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelSymbol']['labelTextAnchor']?this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')][0x1]:0x0}),_0x4f43d3[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x2fa')]),this[_0x2d55('0x32c')]=new maptalks['Circle'](this['options'][_0x2d55('0x2ce')],this['options'][_0x2d55('0x84d')],{'id':this[_0x2d55('0x4f3')]['id'],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this['options'][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this['options'][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'dragShadow':this['options'][_0x2d55('0x1d9')],'drawOnAxis':this['options'][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'properties':_0x4f43d3}),this[_0x2d55('0x32c')]['on'](_0x1a6f73[_0x2d55('0x401')],function(_0x32aaff){this[_0x2d55('0x533')]('click',this);}[_0x2d55('0x7cf')](this));},'getExtent':function(){return this[_0x2d55('0x32c')][_0x2d55('0x164')]();},'CLASS_NAME':_0x2d55('0x489')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x6ef')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib']['Overlays'][_0x2d55('0x756')],{'initialize':function(_0x32ddd8,_0xcea6c8){var _0x1e0e4c={'zxRXo':_0x2d55('0x81'),'DyUXq':_0x2d55('0x4f1'),'PswZy':'#34495e','PqYjO':_0x2d55('0x58e'),'ioLXf':'#000'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this['options'],this['__proto__'][_0x2d55('0x6cc')]['options']),this['options'][_0x2d55('0x701')]=_0x1e0e4c[_0x2d55('0x108')],this[_0x2d55('0x4f3')][_0x2d55('0x21c')]={'lineColor':_0x1e0e4c['PswZy'],'lineWidth':0x2,'polygonFill':_0x2d55('0x2ab'),'polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x32ddd8,_0xcea6c8);_0x32ddd8={'altitude':this['options'][_0x2d55('0xab')]||0x0};this[_0x2d55('0x4f3')]['labelSymbol']&&this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x2fa')]&&(this[_0x2d55('0x4f3')]['symbol']=[this[_0x2d55('0x4f3')][_0x2d55('0x21c')]],this[_0x2d55('0x4f3')][_0x2d55('0x21c')][_0x2d55('0x590')]({'textFaceName':_0x1e0e4c[_0x2d55('0x365')],'textName':'{name}','textSize':this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelTextSize']||0x14,'textFill':this['options'][_0x2d55('0x322')]['labelTextColor']||_0x1e0e4c[_0x2d55('0x53b')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')]['labelSymbol']['labelTextAnchor'][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x73c')][0x1]:0x0}),_0x32ddd8[_0x2d55('0x20e')]=this['options'][_0x2d55('0x322')][_0x2d55('0x2fa')]),this[_0x2d55('0x32c')]=new maptalks[(_0x2d55('0x6ef'))](this['options'][_0x2d55('0x2ce')],this[_0x2d55('0x4f3')]['radius'],this[_0x2d55('0x4f3')]['startAngle'],this[_0x2d55('0x4f3')][_0x2d55('0x3ff')],{'id':this[_0x2d55('0x4f3')]['id'],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')]['editable'],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this['options'][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')]['draggable'],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')]['drawOnAxis'],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'properties':_0x32ddd8}),this[_0x2d55('0x32c')]['on'](_0x2d55('0x81'),function(_0xcb3dcd){this[_0x2d55('0x533')](_0x1e0e4c[_0x2d55('0x29')],this);}[_0x2d55('0x7cf')](this));},'show':function(){this[_0x2d55('0x32c')]&&this['geom'][_0x2d55('0x6a0')]();},'hide':function(){this[_0x2d55('0x32c')]&&this[_0x2d55('0x32c')][_0x2d55('0x45d')]();},'CLASS_NAME':_0x2d55('0x42e')}),BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x1dd')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')],{'initialize':function(_0x52e2c6,_0x2fd0be){var _0x3e826c={'iCupo':'click','DynwM':_0x2d55('0x58e'),'tbEBl':_0x2d55('0x2aa'),'gUyrs':_0x2d55('0x385')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')]['cursor']='pointer',this[_0x2d55('0x4f3')][_0x2d55('0x21c')]={'lineColor':_0x2d55('0x741'),'lineWidth':0x2,'polygonFill':_0x2d55('0x2ab'),'polygonOpacity':0.6},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x52e2c6,_0x2fd0be);_0x52e2c6={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0};this[_0x2d55('0x4f3')]['labelSymbol']&&this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x2fa')]&&(this['options'][_0x2d55('0x21c')]=[this['options'][_0x2d55('0x21c')]],this[_0x2d55('0x4f3')][_0x2d55('0x21c')][_0x2d55('0x590')]({'textFaceName':_0x3e826c[_0x2d55('0x3e6')],'textName':_0x3e826c['tbEBl'],'textSize':this['options'][_0x2d55('0x322')][_0x2d55('0x332')]||0x14,'textFill':this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelTextColor']||_0x3e826c[_0x2d55('0x301')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')]['labelSymbol']['labelTextAnchor'][0x0]:0x0,'textDy':this['options'][_0x2d55('0x322')][_0x2d55('0x73c')]?this['options'][_0x2d55('0x322')][_0x2d55('0x73c')][0x1]:0x0}),_0x52e2c6[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelText']),this[_0x2d55('0x32c')]=new maptalks['Ellipse'](this[_0x2d55('0x4f3')][_0x2d55('0x2ce')],this[_0x2d55('0x4f3')]['width'],this[_0x2d55('0x4f3')][_0x2d55('0x347')],{'id':this[_0x2d55('0x4f3')]['id'],'visible':this[_0x2d55('0x4f3')]['visible']||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')]['draggable'],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')]['symbol'],'properties':_0x52e2c6}),this[_0x2d55('0x32c')]['on'](_0x3e826c[_0x2d55('0x583')],function(_0x59360f){this[_0x2d55('0x533')](_0x3e826c[_0x2d55('0x583')],this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x62')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x367')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x36bd31,_0x3c4582){var _0x1adbdd={'jBBTp':_0x2d55('0x4f1'),'OJhIS':_0x2d55('0x741'),'FkItu':_0x2d55('0x259'),'yIDSm':_0x2d55('0x6c'),'ICRhI':_0x2d55('0x73e'),'KRpaT':'sans-serif','OiPrP':_0x2d55('0x2aa'),'rrqts':_0x2d55('0x59f'),'CjTXW':'click'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),this['options'][_0x2d55('0x701')]=_0x1adbdd[_0x2d55('0x487')];let _0x22d529={'lineColor':_0x1adbdd[_0x2d55('0x5b0')],'lineWidth':0x3},_0x1c6275={'markerType':_0x1adbdd[_0x2d55('0x4de')],'markerWidth':0x8,'markerHeight':0x8,'markerFill':_0x1adbdd[_0x2d55('0x22')],'markerPlacement':_0x1adbdd[_0x2d55('0x3c8')]},_0x3e1f26={};BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x36bd31,_0x3c4582),_0x3c4582[_0x2d55('0x7d3')]&&Object['keys'](_0x3c4582['lineSymbol'])[_0x2d55('0x457')](_0x315942=>{_0x22d529[_0x315942]=_0x3c4582[_0x2d55('0x7d3')][_0x315942];}),_0x3c4582[_0x2d55('0x74e')]&&Object['keys'](_0x3c4582[_0x2d55('0x74e')])[_0x2d55('0x457')](_0x3f4904=>{_0x1c6275[_0x3f4904]=_0x3c4582[_0x2d55('0x74e')][_0x3f4904];});_0x36bd31={'altitude':this[_0x2d55('0x4f3')]['altitude']||0x0};this[_0x2d55('0x4f3')][_0x2d55('0x322')]&&this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelText']&&(_0x3e1f26={'textFaceName':_0x1adbdd[_0x2d55('0x207')],'textName':_0x1adbdd[_0x2d55('0xdd')],'textSize':this[_0x2d55('0x4f3')][_0x2d55('0x332')]||0x14,'textWeight':this['options'][_0x2d55('0x6cd')]||_0x2d55('0x7cc'),'textFill':this['options'][_0x2d55('0x15d')]||_0x2d55('0x6c'),'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')]||_0x1adbdd[_0x2d55('0x79b')],'textHaloRadius':this[_0x2d55('0x4f3')]['labelTextHaloRadius']||0x3,'textWrapCharacter':this['options'][_0x2d55('0x6e2')]?this[_0x2d55('0x4f3')][_0x2d55('0x15')]:'\x0a'},_0x36bd31[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')]['labelSymbol']['labelText']),this[_0x2d55('0x4f3')][_0x2d55('0x21c')]=[_0x22d529,_0x1c6275,_0x3e1f26],this[_0x2d55('0x32c')]=new maptalks[(_0x2d55('0x367'))](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'visible':this['options'][_0x2d55('0x27a')]||!0x0,'editable':this['options']['editable'],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')]['shadowColor'],'draggable':this[_0x2d55('0x4f3')]['draggable'],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'properties':_0x36bd31}),this[_0x2d55('0x32c')]['on'](_0x1adbdd['CjTXW'],function(_0x19cc20){this[_0x2d55('0x533')](_0x2d55('0x81'),this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x4c1')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x4ea')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Overlays'][_0x2d55('0x756')],{'initialize':function(_0x35cb86,_0x8acd7f){var _0x2717a8={'DDOim':'click','Aojbe':_0x2d55('0x741'),'TYPVV':_0x2d55('0x6c'),'xHaBT':_0x2d55('0x73e'),'nyMbO':_0x2d55('0x58e'),'iLOZD':_0x2d55('0x2aa'),'pFlYQ':_0x2d55('0x7cc')};BDLayers['Util'][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]='pointer';let _0x26ee84={'lineColor':_0x2717a8['Aojbe'],'lineWidth':0x3},_0x2d4db2={'markerType':_0x2d55('0x259'),'markerWidth':0x8,'markerHeight':0x8,'markerFill':_0x2717a8['TYPVV'],'markerPlacement':_0x2717a8[_0x2d55('0x379')]},_0x7027db={};BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['Geom'][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x35cb86,_0x8acd7f),_0x8acd7f[_0x2d55('0x879')]&&Object[_0x2d55('0x70a')](_0x8acd7f[_0x2d55('0x879')])[_0x2d55('0x457')](_0x4e80c6=>{_0x26ee84[_0x4e80c6]=_0x8acd7f['lineStyle'][_0x4e80c6];}),_0x8acd7f[_0x2d55('0x397')]&&Object[_0x2d55('0x70a')](_0x8acd7f[_0x2d55('0x397')])[_0x2d55('0x457')](_0x3fc3b6=>{_0x2d4db2[_0x3fc3b6]=_0x8acd7f[_0x2d55('0x397')][_0x3fc3b6];});var _0x5eeed1={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0};this[_0x2d55('0x4f3')][_0x2d55('0x322')]&&this[_0x2d55('0x4f3')]['labelSymbol'][_0x2d55('0x2fa')]&&(_0x7027db={'textFaceName':_0x2717a8[_0x2d55('0x10d')],'textName':_0x2717a8[_0x2d55('0x772')],'textSize':this[_0x2d55('0x4f3')]['labelTextSize']||0x14,'textWeight':this[_0x2d55('0x4f3')][_0x2d55('0x6cd')]||_0x2717a8[_0x2d55('0x49e')],'textFill':this[_0x2d55('0x4f3')][_0x2d55('0x15d')]||_0x2717a8[_0x2d55('0x417')],'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')]||'#fff','textHaloRadius':this[_0x2d55('0x4f3')][_0x2d55('0x67e')]||0x3,'textWrapCharacter':this[_0x2d55('0x4f3')][_0x2d55('0x6e2')]?this['options'][_0x2d55('0x15')]:'\x0a'},_0x5eeed1[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')][_0x2d55('0x322')][_0x2d55('0x2fa')]),this[_0x2d55('0x4f3')][_0x2d55('0x21c')]=[_0x26ee84,_0x2d4db2,_0x7027db],BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x35cb86,_0x8acd7f),this[_0x2d55('0x32c')]=new maptalks['QuadBezierCurve'](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this['options'][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')][_0x2d55('0x6c2')],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this['options'][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')]['symbol'],'properties':_0x5eeed1}),this[_0x2d55('0x32c')]['on'](_0x2717a8[_0x2d55('0x6c7')],function(_0x1eed2d){this[_0x2d55('0x533')](_0x2717a8[_0x2d55('0x6c7')],this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x62d')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['CubicBezierCurve']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['Geom'],{'initialize':function(_0x26d908,_0x329a8b){var _0x5ee140={'gzlXC':_0x2d55('0x81'),'mBWua':'pointer','siEjE':_0x2d55('0x741'),'fUCQD':_0x2d55('0x259'),'CwWmY':_0x2d55('0x6c'),'SdmWR':_0x2d55('0x73e'),'VNItc':_0x2d55('0x58e'),'Huqdn':_0x2d55('0x2aa'),'DgWhX':_0x2d55('0x7cc'),'vmQOg':_0x2d55('0x59f')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x5ee140[_0x2d55('0x3fb')];let _0x4e6aa6={'lineColor':_0x5ee140[_0x2d55('0x553')],'lineWidth':0x3},_0x21d5ee={'markerType':_0x5ee140['fUCQD'],'markerWidth':0x8,'markerHeight':0x8,'markerFill':_0x5ee140[_0x2d55('0x1a9')],'markerPlacement':_0x5ee140[_0x2d55('0x186')]},_0x2f0b45={};BDLayers['Lib']['Overlays'][_0x2d55('0x756')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x26d908,_0x329a8b),_0x329a8b[_0x2d55('0x879')]&&Object[_0x2d55('0x70a')](_0x329a8b['lineStyle'])[_0x2d55('0x457')](_0x1f1f56=>{_0x4e6aa6[_0x1f1f56]=_0x329a8b[_0x2d55('0x879')][_0x1f1f56];}),_0x329a8b['markerStyle']&&Object[_0x2d55('0x70a')](_0x329a8b[_0x2d55('0x397')])[_0x2d55('0x457')](_0x31661e=>{_0x21d5ee[_0x31661e]=_0x329a8b[_0x2d55('0x397')][_0x31661e];});var _0xc4e1e0={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0};this[_0x2d55('0x4f3')][_0x2d55('0x322')]&&this[_0x2d55('0x4f3')]['labelSymbol']['labelText']&&(_0x2f0b45={'textFaceName':_0x5ee140[_0x2d55('0xe2')],'textName':_0x5ee140[_0x2d55('0x4e7')],'textSize':this[_0x2d55('0x4f3')]['labelTextSize']||0x14,'textWeight':this['options'][_0x2d55('0x6cd')]||_0x5ee140[_0x2d55('0x5ce')],'textFill':this[_0x2d55('0x4f3')][_0x2d55('0x15d')]||_0x2d55('0x6c'),'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')]||_0x5ee140[_0x2d55('0x7f4')],'textHaloRadius':this['options'][_0x2d55('0x67e')]||0x3,'textWrapCharacter':this[_0x2d55('0x4f3')][_0x2d55('0x6e2')]?this[_0x2d55('0x4f3')][_0x2d55('0x15')]:'\x0a'},_0xc4e1e0[_0x2d55('0x20e')]=this[_0x2d55('0x4f3')][_0x2d55('0x322')]['labelText']),this[_0x2d55('0x4f3')][_0x2d55('0x21c')]=[_0x4e6aa6,_0x21d5ee,_0x2f0b45],BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['Geom'][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x26d908,_0x329a8b),this[_0x2d55('0x32c')]=new maptalks[(_0x2d55('0x292'))](this[_0x2d55('0x4f3')][_0x2d55('0x537')],{'visible':this[_0x2d55('0x4f3')]['visible']||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this[_0x2d55('0x4f3')][_0x2d55('0x701')],'shadowBlur':this['options']['shadowBlur'],'shadowColor':this['options'][_0x2d55('0x7a')],'draggable':this[_0x2d55('0x4f3')]['draggable'],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')]['drawOnAxis'],'symbol':this['options'][_0x2d55('0x21c')],'properties':_0xc4e1e0}),this['geom']['on'](_0x2d55('0x81'),function(_0x577f02){this['trigger'](_0x5ee140[_0x2d55('0x3f5')],this);}[_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x87')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x42d')]=BDLayers[_0x2d55('0x2ca')]({'options':{'draggable':!0x1,'editable':!0x0,'withBox':!0x1,'textSymbol':{'textFaceName':_0x2d55('0x178'),'textFill':_0x2d55('0x741'),'textHaloFill':_0x2d55('0x59f'),'textHaloRadius':0x4,'textSize':0x12,'textWeight':'bold','textVerticalAlignment':_0x2d55('0x60b')},'boxStyle':{'padding':[0xc,0x8],'verticalAlignment':_0x2d55('0x60b'),'horizontalAlignment':_0x2d55('0x86f'),'minWidth':0xc8,'minHeight':0x1e,'symbol':{'markerType':_0x2d55('0x64f'),'markerFill':_0x2d55('0x2ab'),'markerFillOpacity':0.9,'markerLineColor':_0x2d55('0x741'),'markerLineWidth':0x1}}},'marker':null,'initialize':function(_0x42283c,_0x1d5dc0,_0xb89d43){var _0x45cca0={'SJTDO':_0x2d55('0x81'),'njDmq':_0x2d55('0x75b'),'Nmdcf':_0x2d55('0x4f0'),'eXaQj':_0x2d55('0x178'),'rTCDF':_0x2d55('0x59f'),'RKyCj':'top','wgmvj':'left','gaPEa':_0x2d55('0x2ab'),'PqCkh':_0x2d55('0x741')};var _0x5c7a81;BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),_0xb89d43&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0xb89d43),_0xb89d43={'textFaceName':_0x45cca0['eXaQj'],'textFill':this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x5')]||_0x2d55('0x741'),'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x289')]||_0x45cca0[_0x2d55('0x6de')],'textHaloRadius':this['options'][_0x2d55('0x3c5')]['textHaloRadius']||0x0,'textSize':this[_0x2d55('0x4f3')]['textSymbol']['textSize']||0x12,'textWeight':this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x66a')]||_0x2d55('0x7cc'),'textVerticalAlignment':this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x7f8')]||_0x45cca0['RKyCj']},this['options'][_0x2d55('0x538')]&&(_0x5c7a81={'padding':this['options'][_0x2d55('0x412')][_0x2d55('0x22a')]||[0xc,0x8],'verticalAlignment':this[_0x2d55('0x4f3')]['boxStyle'][_0x2d55('0x51a')]||_0x45cca0[_0x2d55('0x6fc')],'horizontalAlignment':this[_0x2d55('0x4f3')][_0x2d55('0x412')][_0x2d55('0x5f')]||_0x45cca0[_0x2d55('0x7d6')],'minWidth':this['options'][_0x2d55('0x412')]['minWidth']||0xc8,'minHeight':this[_0x2d55('0x4f3')]['boxStyle'][_0x2d55('0xd6')]||0x1e,'symbol':this['options']['boxStyle']['symbol']||{'markerType':_0x2d55('0x64f'),'markerFill':_0x45cca0[_0x2d55('0x57a')],'markerFillOpacity':0.9,'markerLineColor':_0x45cca0[_0x2d55('0x718')],'markerLineWidth':0x1}}),this['options'][_0x2d55('0x538')]?this['marker']=new maptalks[(_0x2d55('0x42d'))](this['options'][_0x2d55('0x69f')],_0x1d5dc0,{'id':_0x42283c,'draggable':this['options'][_0x2d55('0x6c2')],'boxStyle':_0x5c7a81,'textSymbol':_0xb89d43,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')]}):this[_0x2d55('0x8a0')]=new maptalks[(_0x2d55('0x42d'))](this[_0x2d55('0x4f3')][_0x2d55('0x69f')],_0x1d5dc0,{'id':_0x42283c,'draggable':this['options']['draggable'],'textSymbol':_0xb89d43}),this[_0x2d55('0x8a0')]['on'](_0x45cca0[_0x2d55('0x14e')],function(_0x280e4d){this[_0x2d55('0x533')](_0x45cca0[_0x2d55('0x14e')],this);}[_0x2d55('0x7cf')](this)),this['marker']['on'](_0x45cca0[_0x2d55('0xa7')],function(_0x4298b6){this[_0x2d55('0x533')](_0x45cca0[_0x2d55('0xa7')],this);}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x8a0')]['on'](_0x45cca0['Nmdcf'],function(_0x4a0616){this['trigger'](_0x45cca0[_0x2d55('0x59b')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'startEditText':function(){this[_0x2d55('0x8a0')][_0x2d55('0x2f2')]();},'setTextSymbol':function(_0x4563a0){this[_0x2d55('0x8a0')][_0x2d55('0x650')]({'textFaceName':_0x4563a0[_0x2d55('0x5dc')]||this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x5dc')],'textFill':_0x4563a0[_0x2d55('0x5')]||this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x5')],'textHaloFill':_0x4563a0[_0x2d55('0x289')]||this[_0x2d55('0x4f3')]['textSymbol'][_0x2d55('0x289')],'textHaloRadius':_0x4563a0['textHaloRadius']||this['options'][_0x2d55('0x3c5')]['textHaloRadius'],'textSize':_0x4563a0[_0x2d55('0x421')]||this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x421')],'textWeight':_0x4563a0[_0x2d55('0x66a')]||this[_0x2d55('0x4f3')][_0x2d55('0x3c5')][_0x2d55('0x66a')]});},'startEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x755')]();},'CLASS_NAME':_0x2d55('0x8d')}),BDLayers[_0x2d55('0x47b')]['Overlays']['ConnectorLine']=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')][_0x2d55('0x756')],{'initialize':function(_0x1d9b69,_0x149f59){var _0x3fab18={'gEZSI':_0x2d55('0x4f1'),'iIisU':_0x2d55('0x1c1'),'SOnKn':_0x2d55('0xb2')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),this[_0x2d55('0x4f3')][_0x2d55('0x701')]=_0x3fab18[_0x2d55('0x450')],this[_0x2d55('0x4f3')]['symbol']={'lineColor':_0x3fab18[_0x2d55('0x6fe')],'lineWidth':0x3},BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['Geom'][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x1d9b69,_0x149f59),this[_0x2d55('0x4f3')]['arcDegree']?this['geom']=new maptalks[(_0x2d55('0x7f5'))](this[_0x2d55('0x4f3')][_0x2d55('0x7c')]['geom']||this[_0x2d55('0x4f3')][_0x2d55('0x7c')],this[_0x2d55('0x4f3')][_0x2d55('0x275')][_0x2d55('0x32c')]||this[_0x2d55('0x4f3')][_0x2d55('0x275')],{'arcDegree':this[_0x2d55('0x4f3')][_0x2d55('0x60f')],'showOn':this[_0x2d55('0x4f3')][_0x2d55('0x68c')]||_0x3fab18[_0x2d55('0x427')],'arrowStyle':this[_0x2d55('0x4f3')][_0x2d55('0x687')],'arrowPlacement':this[_0x2d55('0x4f3')][_0x2d55('0x465')],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this['options']['editable'],'cursor':this['options'][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')][_0x2d55('0x242')],'shadowColor':this[_0x2d55('0x4f3')]['shadowColor'],'draggable':this['options']['draggable'],'dragShadow':this[_0x2d55('0x4f3')][_0x2d55('0x1d9')],'drawOnAxis':this[_0x2d55('0x4f3')][_0x2d55('0x59e')],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')],'properties':{'altitude':this['options'][_0x2d55('0xab')]||0x0}}):this['geom']=new maptalks[(_0x2d55('0x3f'))](this[_0x2d55('0x4f3')]['src'][_0x2d55('0x32c')]||this['options']['src'],this[_0x2d55('0x4f3')]['dst']['geom']||this['options'][_0x2d55('0x275')],{'showOn':this[_0x2d55('0x4f3')][_0x2d55('0x68c')]||_0x3fab18[_0x2d55('0x427')],'arrowStyle':this[_0x2d55('0x4f3')]['arrowStyle'],'arrowPlacement':this[_0x2d55('0x4f3')][_0x2d55('0x465')],'visible':this[_0x2d55('0x4f3')][_0x2d55('0x27a')]||!0x0,'editable':this[_0x2d55('0x4f3')][_0x2d55('0x31d')],'cursor':this['options'][_0x2d55('0x701')],'shadowBlur':this[_0x2d55('0x4f3')]['shadowBlur'],'shadowColor':this[_0x2d55('0x4f3')]['shadowColor'],'draggable':this[_0x2d55('0x4f3')]['draggable'],'dragShadow':this['options'][_0x2d55('0x1d9')],'drawOnAxis':this['options']['drawOnAxis'],'symbol':this['options'][_0x2d55('0x21c')],'properties':{'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]||0x0}}),this[_0x2d55('0x32c')]['on']('click',function(_0x574565){this[_0x2d55('0x533')]('click',this);}['bind'](this));},'CLASS_NAME':_0x2d55('0x2a9')}),BDLayers[_0x2d55('0x47b')]['Overlays']['MarkerBar']=BDLayers[_0x2d55('0x2ca')]({'options':{'markerWidth':null,'markerHeight':null,'markerFill':null,'markerLineWidth':null,'markerLineColor':null,'labelText':null,'labelTextSize':null,'labelTextColor':null,'labelTextAnchor':null},'marker':null,'initialize':function(_0x37c7c9,_0x37f206,_0x662ff4){var _0x59e26a={'GMhfa':'click','JsVBh':'bar','EaDzd':_0x2d55('0x1c1'),'QZPCa':_0x2d55('0x59f'),'kIUxG':_0x2d55('0x58e'),'gbayO':'{name}','vbUbB':_0x2d55('0x385')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x662ff4&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x662ff4);var _0x662ff4={'markerType':_0x59e26a[_0x2d55('0x297')],'markerWidth':this['options'][_0x2d55('0x5d6')],'markerHeight':this['options'][_0x2d55('0x87f')],'markerFill':this[_0x2d55('0x4f3')]['markerFill']||_0x59e26a['EaDzd'],'markerLineWidth':this['options'][_0x2d55('0x473')]||0x2,'markerLineColor':this[_0x2d55('0x4f3')][_0x2d55('0x568')]||_0x59e26a[_0x2d55('0x2c6')]},_0x5c4343={'altitude':this['options'][_0x2d55('0xab')]||0x0};this['options'][_0x2d55('0x2fa')]&&((_0x662ff4=[_0x662ff4])[_0x2d55('0x590')]({'textFaceName':_0x59e26a[_0x2d55('0x1b3')],'textName':_0x59e26a[_0x2d55('0x32f')],'textSize':this[_0x2d55('0x4f3')][_0x2d55('0x332')]||0x14,'textFill':this[_0x2d55('0x4f3')]['labelTextColor']||_0x59e26a[_0x2d55('0x2f3')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x73c')][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')]['labelTextAnchor']?this['options']['labelTextAnchor'][0x1]:0x0}),_0x5c4343[_0x2d55('0x20e')]=this['options'][_0x2d55('0x2fa')]),this[_0x2d55('0x8a0')]=new maptalks[(_0x2d55('0x28c'))](_0x37f206,{'id':_0x37c7c9,'properties':_0x5c4343,'symbol':_0x662ff4}),this['marker']['on'](_0x2d55('0x81'),function(_0x564e99){this[_0x2d55('0x533')](_0x59e26a[_0x2d55('0x629')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return this['marker']['getId']();},'setMarkerStyle':function(_0x96bc10){var _0x4405fc={'DGgAe':'bar','Wjfbh':_0x2d55('0x1c1'),'rgTpl':_0x2d55('0x59f'),'qeGsg':_0x2d55('0x4e3')};this[_0x2d55('0x8a0')]['updateSymbol']({'markerType':_0x4405fc[_0x2d55('0x61f')],'markerWidth':_0x96bc10['markerWidth']||this[_0x2d55('0x4f3')][_0x2d55('0x5d6')],'markerHeight':_0x96bc10[_0x2d55('0x87f')]||this['options'][_0x2d55('0x87f')],'markerFill':_0x96bc10[_0x2d55('0x46b')]||this[_0x2d55('0x4f3')][_0x2d55('0x46b')]||_0x4405fc['Wjfbh'],'markerLineWidth':_0x96bc10[_0x2d55('0x473')]||this['options'][_0x2d55('0x473')]||0x2,'markerLineColor':_0x96bc10[_0x2d55('0x568')]||this[_0x2d55('0x4f3')][_0x2d55('0x568')]||_0x4405fc['rgTpl']}),this[_0x2d55('0x533')](_0x4405fc[_0x2d55('0x2b8')],this);},'animate':function(_0x26bd92,_0x11a11e,_0x528186){this[_0x2d55('0x8a0')][_0x2d55('0x555')](_0x26bd92,_0x11a11e,function(_0x3b49dc,_0x33ad2f){_0x528186&&_0x528186(_0x3b49dc);});},'startEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x8a0')][_0x2d55('0x755')]();},'toGeoJSON':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x1d0')]();},'toJSON':function(){return this[_0x2d55('0x8a0')]['toJSON']();},'setMenu':function(_0x1f5ca6){this[_0x2d55('0x8a0')]['setMenu'](_0x1f5ca6);},'openMenu':function(){this[_0x2d55('0x8a0')][_0x2d55('0x3ee')]();},'CLASS_NAME':_0x2d55('0x7b6')}),BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x26c')]=BDLayers['Class']({'options':{'content':'','coordinate':[],'width':0xc8,'height':0x5a,'draggable':!0x1,'editable':!0x0,'wrap':!0x0,'padding':[0xc,0x8],'verticalAlignment':_0x2d55('0x60b'),'horizontalAlignment':_0x2d55('0x543'),'symbol':{'textFaceName':'monospace','textFill':_0x2d55('0x741'),'textHaloFill':_0x2d55('0x59f'),'textHaloRadius':0x4,'textSize':0x12,'textWeight':_0x2d55('0x7cc')},'markerType':'square','markerFill':_0x2d55('0x2ab'),'markerFillOpacity':0.9,'markerLineColor':_0x2d55('0x741'),'markerLineWidth':0x1},'textBox':null,'initialize':function(_0x3ca34b,_0x47ec08){var _0x56df21={'PjqWE':_0x2d55('0x81'),'vCODa':_0x2d55('0x75b'),'KSlKe':'edittextend'};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x47ec08&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x47ec08),this[_0x2d55('0x399')]=new maptalks[(_0x2d55('0x26c'))](this['options'][_0x2d55('0x15a')],this[_0x2d55('0x4f3')][_0x2d55('0x203')],this[_0x2d55('0x4f3')]['width'],this[_0x2d55('0x4f3')][_0x2d55('0x347')],{'id':_0x3ca34b,'draggable':this['options']['draggable'],'textStyle':{'wrap':this['options'][_0x2d55('0x326')],'padding':this[_0x2d55('0x4f3')]['padding'],'verticalAlignment':this[_0x2d55('0x4f3')][_0x2d55('0x51a')],'horizontalAlignment':this['options']['horizontalAlignment'],'symbol':this[_0x2d55('0x4f3')][_0x2d55('0x21c')]},'boxSymbol':{'markerType':this['options'][_0x2d55('0x5bb')],'markerFill':this[_0x2d55('0x4f3')]['markerFill'],'markerFillOpacity':this[_0x2d55('0x4f3')][_0x2d55('0x4b3')],'markerLineColor':this['options'][_0x2d55('0x568')],'markerLineWidth':this[_0x2d55('0x4f3')][_0x2d55('0x473')]}}),this[_0x2d55('0x399')]['on'](_0x56df21[_0x2d55('0x381')],function(_0x1e803b){this[_0x2d55('0x533')](_0x56df21['PjqWE'],this);}['bind'](this)),this[_0x2d55('0x399')]['on'](_0x56df21[_0x2d55('0x5c')],function(_0x34bf95){this['trigger'](_0x56df21[_0x2d55('0x5c')],this);}['bind'](this)),this['textBox']['on'](_0x56df21[_0x2d55('0x235')],function(_0xcc2406){this[_0x2d55('0x533')](_0x56df21[_0x2d55('0x235')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x399')];},'startEditText':function(){this[_0x2d55('0x399')][_0x2d55('0x2f2')]();},'setTextStyle':function(_0x276ca4){this[_0x2d55('0x399')]['setTextStyle']({'symbol':{'textFaceName':_0x276ca4[_0x2d55('0x5dc')]||this[_0x2d55('0x4f3')][_0x2d55('0x21c')]['textFaceName'],'textFill':_0x276ca4['textFill']||this['options'][_0x2d55('0x21c')]['textFill'],'textHaloFill':_0x276ca4[_0x2d55('0x289')]||this[_0x2d55('0x4f3')][_0x2d55('0x21c')][_0x2d55('0x289')],'textHaloRadius':_0x276ca4['textHaloRadius']||this['options'][_0x2d55('0x21c')][_0x2d55('0x4da')],'textSize':_0x276ca4[_0x2d55('0x421')]||this['options'][_0x2d55('0x21c')]['textSize'],'textWeight':_0x276ca4[_0x2d55('0x66a')]||this[_0x2d55('0x4f3')][_0x2d55('0x21c')][_0x2d55('0x66a')]}});},'startEdit':function(){this['textBox'][_0x2d55('0x5e2')]();},'endEdit':function(){this[_0x2d55('0x399')]['endEdit']();},'CLASS_NAME':_0x2d55('0x433')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['PlotSvg']=BDLayers[_0x2d55('0x2ca')]({'options':{'draggable':!0x1,'editable':!0x1,'rotateFlag':!0x0,'rotationAngle':0x0,'iconAnchor':[0x0,0x0],'iconSize':[0x20,0x20],'viewboxWidth':0xdac,'viewboxHeight':0xdac,'opacity':0x1,'labelText':null,'labelTextSize':null,'labelTextColor':null,'labelTextAnchor':null,'labelTextHaloFill':_0x2d55('0x59f'),'labelTextHaloRadius':0x0,'altitude':0x0},'marker':null,'initialize':function(_0xcefc6a,_0x498ace,_0x21c8af){var _0x4f122e={'pmvTA':'click','HBFOu':_0x2d55('0x75b'),'skiQp':_0x2d55('0x39e'),'vyPMi':_0x2d55('0x58e'),'uKqhm':'#000'};BDLayers['Util'][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),_0x21c8af&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x21c8af);var _0x21c8af={'markerType':_0x4f122e[_0x2d55('0x5e')],'markerPath':this[_0x2d55('0x4f3')]['svgPath'],'markerPathWidth':this[_0x2d55('0x4f3')][_0x2d55('0x1e8')],'markerPathHeight':this[_0x2d55('0x4f3')]['viewboxHeight'],'markerWidth':this[_0x2d55('0x4f3')]['iconSize'][0x0],'markerHeight':this[_0x2d55('0x4f3')][_0x2d55('0x1e4')][0x1],'markerDx':this[_0x2d55('0x4f3')][_0x2d55('0x5a5')][0x0],'markerDy':this['options'][_0x2d55('0x5a5')][0x1],'markerOpacity':this[_0x2d55('0x4f3')]['opacity'],'markerRotation':this[_0x2d55('0x4f3')]['rotateFlag']?this['options']['rotationAngle']:0x0},_0x3bbe07=null,_0x429ed7={'altitude':this[_0x2d55('0x4f3')][_0x2d55('0xab')]};this['options']['labelText']&&(_0x3bbe07={'textFaceName':_0x4f122e['vyPMi'],'textName':'{name}','textSize':this['options'][_0x2d55('0x332')]||0x14,'textFill':this[_0x2d55('0x4f3')][_0x2d55('0x15d')]||_0x4f122e[_0x2d55('0x7ef')],'textDx':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this[_0x2d55('0x4f3')][_0x2d55('0x73c')][0x0]:0x0,'textDy':this[_0x2d55('0x4f3')][_0x2d55('0x73c')]?this['options'][_0x2d55('0x73c')][0x1]:0x0,'textHaloFill':this[_0x2d55('0x4f3')][_0x2d55('0x35f')],'textHaloRadius':this[_0x2d55('0x4f3')][_0x2d55('0x67e')]},_0x429ed7['name']=this['options'][_0x2d55('0x2fa')]),_0x3bbe07=_0x3bbe07?[_0x21c8af,_0x3bbe07]:_0x21c8af,this[_0x2d55('0x8a0')]=new maptalks[(_0x2d55('0x28c'))](_0x498ace,{'id':_0xcefc6a,'draggable':this[_0x2d55('0x4f3')]['draggable'],'editable':this[_0x2d55('0x4f3')]['editable'],'properties':_0x429ed7,'symbol':_0x3bbe07}),this[_0x2d55('0x8a0')]['on'](_0x4f122e[_0x2d55('0x540')],function(_0x3ae2c1){this['trigger'](_0x4f122e[_0x2d55('0x540')],this);}[_0x2d55('0x7cf')](this)),this['marker']['on'](_0x4f122e[_0x2d55('0x83b')],function(_0x5c20e8){this[_0x2d55('0x533')](_0x4f122e[_0x2d55('0x83b')],this);}[_0x2d55('0x7cf')](this));},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return this[_0x2d55('0x8a0')][_0x2d55('0x482')]();},'startEdit':function(){this[_0x2d55('0x8a0')]['startEdit']();},'isEditing':function(){return this[_0x2d55('0x8a0')]['isEditing']();},'endEdit':function(){this['marker'][_0x2d55('0x755')]();},'setMarkerStyle':function(_0x13561a){var _0x1c607e={'QCrRk':_0x2d55('0x4e3')};let _0x218a13=[];_0x13561a[_0x2d55('0x1d1')]&&(_0x218a13=_0x13561a[_0x2d55('0x1d1')]),this[_0x2d55('0x8a0')][_0x2d55('0x802')]({'markerFile':_0x13561a[_0x2d55('0x51b')]||this[_0x2d55('0x4f3')][_0x2d55('0x51b')],'markerWidth':(_0x13561a['iconSize']&&_0x13561a[_0x2d55('0x1e4')][0x0]?_0x13561a:this['options'])['iconSize'][0x0],'markerHeight':(_0x13561a[_0x2d55('0x1e4')]&&_0x13561a[_0x2d55('0x1e4')][0x1]?_0x13561a:this['options'])['iconSize'][0x1],'markerDx':(_0x13561a[_0x2d55('0x5a5')]&&_0x13561a[_0x2d55('0x5a5')][0x0]?_0x13561a:this['options'])[_0x2d55('0x5a5')][0x0],'markerDy':(_0x13561a['iconAnchor']&&_0x13561a['iconAnchor'][0x1]?_0x13561a:this[_0x2d55('0x4f3')])['iconAnchor'][0x1],'markerOpacity':_0x13561a[_0x2d55('0x69c')]||this[_0x2d55('0x4f3')][_0x2d55('0x69c')],'markerRotation':_0x13561a['rotationAngle']||this['options'][_0x2d55('0x30d')],'markerPath':_0x13561a[_0x2d55('0x1d1')]?_0x218a13:this[_0x2d55('0x4f3')][_0x2d55('0x1d1')]}),this[_0x2d55('0x533')](_0x1c607e[_0x2d55('0xb7')],this);},'setMarkerProperties':function(_0x1c303a){var _0x1c303a={'altitude':_0x1c303a[_0x2d55('0xab')]||this[_0x2d55('0x4f3')]['altitude'],'name':_0x1c303a[_0x2d55('0x2fa')]||this[_0x2d55('0x4f3')][_0x2d55('0x2fa')]},_0x3c58fe=this[_0x2d55('0x8a0')][_0x2d55('0x84')]();return _0x3c58fe[_0x2d55('0xab')]&&(_0x3c58fe['altitude']=_0x1c303a[_0x2d55('0xab')]),this[_0x2d55('0x8a0')][_0x2d55('0x1c4')](_0x3c58fe);},'setRotationAngle':function(_0x8cd559){var _0x59941b={'cbgbH':_0x2d55('0x2f9')};this['marker'][_0x2d55('0x802')]({'markerRotation':this[_0x2d55('0x4f3')][_0x2d55('0x673')]&&_0x8cd559?_0x8cd559:this[_0x2d55('0x4f3')][_0x2d55('0x30d')]}),this['trigger'](_0x59941b[_0x2d55('0x3ea')],this);},'getRotationAngle':function(){return this[_0x2d55('0x4f3')][_0x2d55('0x30d')];},'setPopWindow':function(_0x660e20){this[_0x2d55('0x8a0')]&&(this[_0x2d55('0x8a0')][_0x2d55('0x708')]()&&(this[_0x2d55('0x8a0')][_0x2d55('0x3bc')](),this['marker'][_0x2d55('0x2ff')]()),this[_0x2d55('0x8a0')][_0x2d55('0x724')](_0x660e20),this[_0x2d55('0x8a0')]['openInfoWindow']());},'CLASS_NAME':'BDLayers.Lib.Overlays.PlotSvg'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x58c')]['FromGeoJson']=BDLayers[_0x2d55('0x2ca')]({'geom':null,'initialize':function(_0x36d704){var _0x5cb87a={'FSToP':'click'};BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),this[_0x2d55('0x32c')]=maptalks['Geometry'][_0x2d55('0x3cf')](_0x36d704),this[_0x2d55('0x32c')]['on'](_0x5cb87a[_0x2d55('0x18a')],function(_0x15478a){this[_0x2d55('0x533')](_0x5cb87a['FSToP'],this);}[_0x2d55('0x7cf')](this));},'updateSymbol':function(_0x54bcc4){this['geom'][_0x2d55('0x802')](_0x54bcc4);},'setPopWindow':function(_0x5721a5){var _0x5cd77c={'wMjJP':_0x2d55('0x13b'),'bIBZb':_0x2d55('0x81')};this[_0x2d55('0x32c')]&&(this[_0x2d55('0x32c')]['getInfoWindow']()&&(this[_0x2d55('0x32c')][_0x2d55('0x3bc')](),this[_0x2d55('0x32c')][_0x2d55('0x2ff')]()),this['geom'][_0x2d55('0x724')](_0x5721a5),this[_0x2d55('0x32c')][_0x2d55('0x425')](),document['querySelector'](_0x5cd77c[_0x2d55('0x280')])[_0x2d55('0x199')](_0x5cd77c[_0x2d55('0x632')],function(){this[_0x2d55('0x533')]('closePopWindow');}[_0x2d55('0x7cf')](this)));},'closePopWindow':function(){this[_0x2d55('0x32c')]&&this[_0x2d55('0x32c')][_0x2d55('0x708')]()&&(this['geom'][_0x2d55('0x3bc')](),this['geom'][_0x2d55('0x2ff')]());},'hide':function(){this[_0x2d55('0x32c')]&&this[_0x2d55('0x32c')]['hide']();},'show':function(){this[_0x2d55('0x32c')]&&this[_0x2d55('0x32c')][_0x2d55('0x6a0')]();},'CLASS_NAME':_0x2d55('0x21e')}),BDLayers['Lib'][_0x2d55('0x58c')][_0x2d55('0x70d')]=BDLayers[_0x2d55('0x2ca')]({'initialize':function(_0x4b2a64){return BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0}),maptalks[_0x2d55('0x1e7')]['toGeometry'](_0x4b2a64);},'CLASS_NAME':'BDLayers.Lib.Overlays.GeoJSONToGeometry'}),BDLayers['Lib'][_0x2d55('0x261')][_0x2d55('0x119')]=BDLayers['Class']({'drawendGeom':null,'drawTool':null,'drawLayer':null,'distanceLayer':null,'mode':null,'boxHighlightStyle':{'markerType':'square','markerFill':'#00FF7F','markerFillOpacity':0.7,'markerLineColor':'#34495e','markerLineWidth':0x1},'textSymbol':{'textFaceName':_0x2d55('0x178'),'textFill':_0x2d55('0x741'),'textSize':0xe,'textWeight':_0x2d55('0x7cc'),'textHaloRadius':0x0},'svgPath':[{'path':_0x2d55('0x282'),'stroke-width':'38','stroke':_0x2d55('0x550'),'fill':_0x2d55('0xe1'),'fill-opacity':0x0}],'initialize':function(_0x416b36,_0x13e7db,_0x224798,_0x426bca,_0x46598c){var _0x44f5c6={'FJhHK':function(_0x6c5e88,_0x36c5f6){return _0x6c5e88|_0x36c5f6;},'CIwda':function(_0x3973ce,_0x11483b){return _0x3973ce+_0x11483b;},'fupFf':function(_0x386cfd,_0x2202fc){return _0x386cfd+_0x2202fc;},'ebcCq':function(_0x406fbf,_0x3022d0){return _0x406fbf+_0x3022d0;},'VQjAS':function(_0x4cc6b3,_0x905c28){return _0x4cc6b3+_0x905c28;},'kMfLU':function(_0x2819b2,_0x1bf785){return _0x2819b2+_0x1bf785;},'wDfpu':function(_0x4dc69b,_0x12f471){return _0x4dc69b+_0x12f471;},'evUEn':function(_0x2dfb23,_0x4cfef0){return _0x2dfb23+_0x4cfef0;},'eOJBl':function(_0x3e3f3c,_0x35f724){return _0x3e3f3c+_0x35f724;},'fWRlV':function(_0x1fbcda){return _0x1fbcda();},'lzWsS':function(_0x518530){return _0x518530();},'YBmLZ':_0x2d55('0x393'),'ecTmn':_0x2d55('0x75b'),'rkmXj':'positionchange','jsyRj':_0x2d55('0x4f0'),'QiEcI':'handledragging','HHlHx':function(_0x3fb1bc,_0x2276ab){return _0x3fb1bc==_0x2276ab;},'RdBdn':_0x2d55('0x23a'),'NMuUT':function(_0x2f6fcc){return _0x2f6fcc();},'kcaPK':_0x2d55('0x550'),'brGlP':'click','ZqVSE':_0x2d55('0x142'),'lrFws':_0x2d55('0x428'),'lbzhL':function(_0x5b65cd){return _0x5b65cd();},'UIKgX':'#34495e','fUDGs':function(_0x1fdf77,_0x43ecb5){return _0x1fdf77-_0x43ecb5;},'AMhBu':function(_0xe828e2,_0x11e8b4){return _0xe828e2*_0x11e8b4;},'ANahw':'center','kDAsG':_0x2d55('0x178'),'DoDLm':_0x2d55('0x59f'),'fJDtK':_0x2d55('0x7cc'),'ZzAWC':_0x2d55('0x2ab'),'UjmRM':'Circle','RQMce':'drawend','IGuQr':_0x2d55('0x80d'),'zQPcX':'distanceLayer','IuAQl':_0x2d55('0x131')};function _0x32164f(){return _0x44f5c6[_0x2d55('0x29b')](0x10000*_0x44f5c6['CIwda'](0x1,Math[_0x2d55('0x7b8')]()),0x0)[_0x2d55('0x25e')](0x10)[_0x2d55('0x438')](0x1);}function _0x3e173f(){return _0x44f5c6[_0x2d55('0x3ba')](_0x44f5c6[_0x2d55('0x3ba')](_0x44f5c6[_0x2d55('0x3a3')](_0x44f5c6['VQjAS'](_0x44f5c6[_0x2d55('0x892')](_0x44f5c6[_0x2d55('0x5de')](_0x44f5c6[_0x2d55('0x7ee')](_0x44f5c6[_0x2d55('0x7ee')](_0x44f5c6[_0x2d55('0xf6')](_0x44f5c6[_0x2d55('0xf6')](_0x32164f(),_0x44f5c6[_0x2d55('0x79')](_0x32164f)),'-'),_0x32164f()),'-'),_0x44f5c6[_0x2d55('0x79')](_0x32164f)),'-')+_0x44f5c6[_0x2d55('0x24d')](_0x32164f),'-'),_0x44f5c6[_0x2d55('0x24d')](_0x32164f)),_0x32164f()),_0x44f5c6['lzWsS'](_0x32164f));}BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),this[_0x2d55('0x80d')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['CBVectorLayer'](_0x44f5c6[_0x2d55('0x2e6')]),_0x13e7db[_0x2d55('0x7ff')](this[_0x2d55('0x80d')],0x3e8),this[_0x2d55('0x6f3')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x5bd'))](_0x44f5c6[_0x2d55('0x841')]),_0x13e7db[_0x2d55('0x7ff')](this[_0x2d55('0x6f3')],0x3e9),this[_0x2d55('0x717')]=new maptalks[(_0x2d55('0xd3'))]({'mode':_0x224798})[_0x2d55('0x6ce')](_0x13e7db['map'])[_0x2d55('0x49b')](),this[_0x2d55('0x717')]['on'](_0x44f5c6[_0x2d55('0x3c6')],function(_0x59ce93){this[_0x2d55('0x717')][_0x2d55('0x9a')]();}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x717')]['on'](_0x44f5c6[_0x2d55('0x580')],function(_0x4834a6){var _0x27a4fa={'rCFlb':'selectDraw','njWQz':_0x44f5c6[_0x2d55('0x64b')],'prezR':'dragend','xgRAC':_0x44f5c6[_0x2d55('0x406')],'yiLLR':_0x44f5c6['rkmXj']};if(this[_0x2d55('0x276')]=_0x4834a6[_0x2d55('0xe3')],_0x44f5c6['HHlHx'](_0x44f5c6[_0x2d55('0x283')],this[_0x2d55('0x409')]())){var _0x55f707=new BDLayers['Lib'][(_0x2d55('0x58c'))][(_0x2d55('0x7db'))](_0x44f5c6[_0x2d55('0x7e6')](_0x3e173f),[_0x4834a6[_0x2d55('0x203')]['x'],_0x4834a6[_0x2d55('0x203')]['y']],{'svgPath':this[_0x2d55('0x1d1')],'editable':!!_0x426bca,'draggable':!!_0x426bca,'rotationAngle':0x0,'viewboxWidth':0x5dc,'viewboxHeight':0x5dc,'iconSize':[0x64,0x64],'iconColor':_0x44f5c6[_0x2d55('0x4d3')],'iconAnchor':[0x0,0x32],'labelTextSize':0x10,'labelTextAnchor':[0x0,0xf]});this[_0x2d55('0x80d')][_0x2d55('0x293')](_0x55f707),_0x426bca?(_0x55f707['on'](_0x44f5c6['brGlP'],function(_0x478163){_0x55f707[_0x2d55('0x5e2')](),this[_0x2d55('0x533')](_0x44f5c6['YBmLZ'],_0x478163[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this)),_0x55f707['on'](_0x44f5c6[_0x2d55('0x608')],function(_0xac87d0){this[_0x2d55('0x533')](_0x2d55('0x75b'),_0xac87d0[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this))):_0x55f707['on'](_0x44f5c6[_0x2d55('0x21a')],function(_0xdb4c43){this[_0x2d55('0x533')](_0x2d55('0x393'),_0xdb4c43[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this));}else if(_0x44f5c6[_0x2d55('0xed')]==this[_0x2d55('0x409')]()){let _0x189804=_0x4834a6[_0x2d55('0xe3')];_0x189804[_0x2d55('0x881')](_0x3e173f()),this[_0x2d55('0x80d')]['addMarker'](_0x4834a6[_0x2d55('0xe3')]),_0x426bca&&_0x189804['on'](_0x44f5c6['brGlP'],function(_0x5c6971){_0x189804[_0x2d55('0x5e2')](),this[_0x2d55('0x533')](_0x27a4fa[_0x2d55('0x46e')],_0x4834a6);}[_0x2d55('0x7cf')](this));}else if(_0x44f5c6[_0x2d55('0x83c')](_0x44f5c6[_0x2d55('0xff')],this['getDrawMode']())){var _0x59ed83=new BDLayers['Lib'][(_0x2d55('0x58c'))][(_0x2d55('0x42d'))](_0x44f5c6[_0x2d55('0x670')](_0x3e173f),[_0x4834a6['coordinate']['x'],_0x4834a6['coordinate']['y']],{'draggable':!!_0x426bca,'textSymbol':this[_0x2d55('0x3c5')],'withBox':!0x0,'label':'','boxStyle':{'verticalAlignment':_0x2d55('0x1b1'),'minWidth':0xc8,'minHeight':0x32,'symbol':{'markerType':'square','markerFillOpacity':0.5,'markerLineColor':_0x44f5c6[_0x2d55('0xac')],'markerFill':_0x2d55('0x2ab'),'markerLineWidth':0x1}}});this['drawLayer']['addMarker'](_0x59ed83),_0x426bca&&_0x59ed83['on'](_0x2d55('0x75b'),function(_0x55f049){this[_0x2d55('0x533')](_0x2d55('0x75b'),_0x55f049['target']);}[_0x2d55('0x7cf')](this)),_0x59ed83['on'](_0x44f5c6[_0x2d55('0x21a')],function(_0x276f7d){_0x59ed83['startEditText'](),this[_0x2d55('0x533')](_0x27a4fa[_0x2d55('0x46e')],_0x276f7d[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this)),_0x59ed83['on'](_0x44f5c6[_0x2d55('0x64b')],function(_0x32a7bd){this[_0x2d55('0x533')](_0x27a4fa[_0x2d55('0xa3')],_0x32a7bd[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this)),_0x59ed83['startEditText']();}else if(_0x44f5c6[_0x2d55('0x83c')](_0x2d55('0x656'),this['getDrawMode']())){var _0x33b5bc=_0x13e7db[_0x2d55('0x700')][_0x2d55('0x570')](),_0x59ed83=new BDLayers['Lib'][(_0x2d55('0x58c'))][(_0x2d55('0x26c'))](_0x44f5c6[_0x2d55('0x670')](_0x3e173f),{'content':'','coordinate':[_0x4834a6['coordinate']['x'],_0x44f5c6[_0x2d55('0x59d')](_0x4834a6[_0x2d55('0x203')]['y'],_0x44f5c6['AMhBu'](0.002/0xc,_0x33b5bc))],'width':0x96,'height':0x1e,'draggable':!!_0x426bca,'wrap':!0x0,'padding':[0x2,0x8],'verticalAlignment':_0x2d55('0x60b'),'horizontalAlignment':_0x44f5c6['ANahw'],'symbol':{'textFaceName':_0x44f5c6[_0x2d55('0x41f')],'textFill':_0x44f5c6[_0x2d55('0xac')],'textHaloFill':_0x44f5c6[_0x2d55('0x4a2')],'textHaloRadius':0x4,'textSize':0x12,'textWeight':_0x44f5c6[_0x2d55('0x7e0')]},'markerType':_0x2d55('0x64f'),'markerFill':_0x44f5c6[_0x2d55('0x5bc')],'markerFillOpacity':0.5,'markerLineColor':_0x44f5c6[_0x2d55('0xac')],'markerLineWidth':0x1});this[_0x2d55('0x80d')][_0x2d55('0x293')](_0x59ed83),_0x59ed83[_0x2d55('0x8a0')]=this[_0x2d55('0x276')],this[_0x2d55('0x80d')][_0x2d55('0x34c')](_0x4834a6[_0x2d55('0xe3')]),_0x426bca&&(_0x59ed83['on'](_0x44f5c6[_0x2d55('0x608')],function(_0xa355ca){this[_0x2d55('0x533')](_0x27a4fa['prezR'],_0xa355ca[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this)),_0x4834a6['geometry'][_0x2d55('0x5e2')]()),_0x59ed83['on'](_0x44f5c6['brGlP'],function(_0x114011){this[_0x2d55('0x533')]('selectDraw',_0x114011[_0x2d55('0x9e')]);}['bind'](this)),_0x59ed83['on'](_0x44f5c6[_0x2d55('0x64b')],function(_0x2f2aaa){this[_0x2d55('0x533')](_0x27a4fa[_0x2d55('0xa3')],_0x2f2aaa['target']);}[_0x2d55('0x7cf')](this)),_0x59ed83[_0x2d55('0x2f2')]();}else{let _0xae2491=_0x4834a6[_0x2d55('0xe3')],_0x353f93=(_0xae2491[_0x2d55('0x881')](_0x3e173f()),this[_0x2d55('0x80d')][_0x2d55('0x34c')](_0xae2491),_0x46598c&&_0x44f5c6[_0x2d55('0x454')]===_0xae2491[_0x2d55('0x2bf')]&&this[_0x2d55('0x62c')](_0xae2491),this);_0x426bca?(_0xae2491['on'](_0x44f5c6[_0x2d55('0x21a')],function(){_0xae2491[_0x2d55('0x5e2')](),_0x46598c&&(_0x4834a6[_0x2d55('0xe3')]['on'](_0x27a4fa[_0x2d55('0x705')],function(_0x1cf22d){_0x353f93['createCircleRadiusLine'](_0x1cf22d[_0x2d55('0x9e')]);}),_0x4834a6[_0x2d55('0xe3')]['on'](_0x27a4fa[_0x2d55('0x7d7')],function(_0x219a87){_0x353f93[_0x2d55('0x62c')](_0x219a87[_0x2d55('0x9e')]);})),this['trigger'](_0x27a4fa[_0x2d55('0x46e')],_0x4834a6);}[_0x2d55('0x7cf')](this)),_0xae2491['on'](_0x2d55('0x75b'),function(_0x258fde){this[_0x2d55('0x533')](_0x44f5c6[_0x2d55('0x608')],_0x258fde[_0x2d55('0x9e')]);}[_0x2d55('0x7cf')](this))):_0xae2491['on'](_0x44f5c6[_0x2d55('0x21a')],function(_0x3a021f){_0x46598c&&(_0x3a021f[_0x2d55('0x9e')][_0x2d55('0xe3')]['on'](_0x2d55('0x602'),function(_0x43ba1f){_0x353f93['createCircleRadiusLine'](_0x43ba1f['target']);}),_0x3a021f['target'][_0x2d55('0xe3')]['on'](_0x44f5c6[_0x2d55('0x1ab')],function(_0x244236){_0x353f93[_0x2d55('0x62c')](_0x244236['target']);})),this[_0x2d55('0x533')](_0x44f5c6[_0x2d55('0x225')],_0x3a021f['target']);}[_0x2d55('0x7cf')](this));}this[_0x2d55('0x717')][_0x2d55('0x49b')](),this['trigger'](_0x44f5c6[_0x2d55('0x580')],this[_0x2d55('0x276')]);}['bind'](this));},'createCircleRadiusLine':function(_0x14f2d8){var _0x3ca03c={'hGocy':function(_0x4dcede,_0x41d099){return _0x4dcede+_0x41d099;},'YUZZN':'_distance','AhObj':function(_0x5bb9fc,_0x505d23){return _0x5bb9fc+_0x505d23;},'OlJrQ':_0x2d55('0x385'),'ulbIs':function(_0x5e4134,_0x24e81d){return _0x5e4134<_0x24e81d;},'rJnYD':function(_0x15a98c,_0x35ca22){return _0x15a98c+_0x35ca22;},'eQXHZ':function(_0x102f1e,_0x2fdee0){return _0x102f1e/_0x2fdee0;}};console[_0x2d55('0x10b')](this[_0x2d55('0x6f3')]),this[_0x2d55('0x6f3')][_0x2d55('0x67f')](_0x3ca03c['hGocy'](_0x14f2d8[_0x2d55('0x470')],_0x3ca03c[_0x2d55('0x63f')]))&&this['distanceLayer'][_0x2d55('0x15f')](_0x3ca03c[_0x2d55('0x483')](_0x14f2d8[_0x2d55('0x470')],_0x3ca03c[_0x2d55('0x63f')]));let _0xea3c0d=_0x14f2d8['getRadius']()[_0x2d55('0x364')](0x1);_0xea3c0d[_0x2d55('0x25e')]()[_0x2d55('0x202')]('.0')&&(_0xea3c0d=Math[_0x2d55('0x61')](_0xea3c0d));var _0x1bb6e1=_0x14f2d8['getCenter'](),_0x36e31d=_0x14f2d8[_0x2d55('0x6ea')]()[0x34],_0x1bb6e1=[[_0x1bb6e1['x'],_0x1bb6e1['y']],[_0x36e31d['x'],_0x36e31d['y']]],_0x36e31d=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x58c'))][(_0x2d55('0x1c0'))](_0x3ca03c[_0x2d55('0x483')](_0x14f2d8['_id'],_0x2d55('0x7fc')),{'coordinates':_0x1bb6e1,'symbol':{'lineColor':_0x3ca03c[_0x2d55('0x664')],'lineWidth':0x1,'textName':_0x3ca03c[_0x2d55('0x324')](0x3e8,_0xea3c0d)?_0x3ca03c['rJnYD'](_0x3ca03c[_0x2d55('0x1ad')](_0xea3c0d,0x3e8)[_0x2d55('0x364')](0x2),'km'):_0xea3c0d+'m','textPlacement':'line','textSize':0x14,'textDy':-0x14}});_0x36e31d['id']=_0x3ca03c['rJnYD'](_0x14f2d8[_0x2d55('0x470')],_0x3ca03c['YUZZN']),this[_0x2d55('0x6f3')][_0x2d55('0x34c')](_0x36e31d);},'setDrawMode':function(_0x921d97){var _0x44af4f={'QuzZD':function(_0x1ac9cd,_0x4cdfca){return _0x1ac9cd!==_0x4cdfca;},'JEjyj':function(_0x3f2484,_0x4b38dd){return _0x3f2484!==_0x4b38dd;},'whxEM':_0x2d55('0x23a'),'NVIge':'Point'};this[_0x2d55('0x5ca')]=_0x921d97,_0x44af4f['QuzZD'](_0x2d55('0x428'),this[_0x2d55('0x5ca')])&&_0x44af4f[_0x2d55('0x3ef')](_0x2d55('0x656'),this[_0x2d55('0x5ca')])&&_0x44af4f['JEjyj'](_0x44af4f[_0x2d55('0x659')],this[_0x2d55('0x5ca')])?this[_0x2d55('0x717')][_0x2d55('0x6f6')](_0x921d97):this['drawTool']['setMode'](_0x44af4f[_0x2d55('0xb8')]);},'setSymbol':function(_0x54fbd3){var _0x45f78e={'patLm':_0x2d55('0x428'),'UAhHQ':function(_0x3d41f6,_0x2ffc38){return _0x3d41f6===_0x2ffc38;},'lSNWo':_0x2d55('0x12d'),'rtGwV':_0x2d55('0x23a')};if(_0x45f78e['patLm']===this[_0x2d55('0x409')]())for(var _0x1d186a in _0x54fbd3)this[_0x2d55('0x3c5')][_0x1d186a]=_0x54fbd3[_0x1d186a];else _0x45f78e[_0x2d55('0xee')](_0x45f78e[_0x2d55('0x862')],this['getDrawMode']())||_0x45f78e['UAhHQ'](_0x45f78e[_0x2d55('0x12a')],this[_0x2d55('0x409')]())?this['svgPath']=_0x54fbd3:this[_0x2d55('0x717')][_0x2d55('0x60a')](_0x54fbd3);},'getDrawMode':function(){var _0x367730={'elvrY':function(_0x2521c0,_0x31cc43){return _0x2521c0!==_0x31cc43;},'VZnIQ':'text','qkHZa':_0x2d55('0x656'),'TGrBM':function(_0x41203c,_0x2e8c3f){return _0x41203c!==_0x2e8c3f;},'PZfoZ':_0x2d55('0x23a')};return _0x367730[_0x2d55('0x7f')](_0x367730[_0x2d55('0xf5')],this[_0x2d55('0x5ca')])&&_0x367730[_0x2d55('0x866')]!==this[_0x2d55('0x5ca')]&&_0x367730[_0x2d55('0x4e4')](_0x367730[_0x2d55('0x86c')],this[_0x2d55('0x5ca')])?this['drawTool'][_0x2d55('0x871')]():this[_0x2d55('0x5ca')];},'enable':function(){this[_0x2d55('0x717')][_0x2d55('0x1f8')]();},'disable':function(){this['drawTool'][_0x2d55('0x49b')]();},'clear':function(){this[_0x2d55('0x80d')]&&this[_0x2d55('0x80d')]['removeAll'](),this[_0x2d55('0x6f3')]&&this[_0x2d55('0x6f3')][_0x2d55('0x19f')]();},'removeDraw':function(_0x1ca14b,_0x1846c0){var _0x3d6496={'GhRlp':_0x2d55('0x80d'),'mmQBH':function(_0x1bb749,_0x2083c2){return _0x1bb749+_0x2083c2;},'nXsYm':_0x2d55('0x7fc')};_0x1ca14b['getLayer'](_0x3d6496[_0x2d55('0x78a')])['removeMarker'](_0x1846c0),this[_0x2d55('0x6f3')][_0x2d55('0x67f')](_0x3d6496['mmQBH'](_0x1846c0,_0x3d6496[_0x2d55('0x5ef')]))&&this[_0x2d55('0x6f3')]['removeGeometry'](_0x3d6496[_0x2d55('0x694')](_0x1846c0,_0x3d6496[_0x2d55('0x5ef')]));},'CLASS_NAME':_0x2d55('0x6d0')}),function(){var _0x41071e={'NeNEK':function(_0x3ed564,_0x5ce1cc){return _0x3ed564*_0x5ce1cc;},'mpwDL':function(_0x19c9c3,_0xe4044c){return _0x19c9c3/_0xe4044c;},'iTjoa':function(_0x52f1ba,_0x3b2882){return _0x52f1ba+_0x3b2882;},'gpFaE':function(_0x41fa64,_0x4ba8d0){return _0x41fa64-_0x4ba8d0;},'IcHkt':function(_0x234d06,_0x67619b){return _0x234d06(_0x67619b);},'ymhdZ':function(_0x3427b6,_0x4fe5aa){return _0x3427b6(_0x4fe5aa);},'zhfdK':function(_0x48e45d,_0x2925f9){return _0x48e45d==_0x2925f9;},'RFPgA':'get','EsHYs':function(_0x450649,_0x357492){return _0x450649(_0x357492);},'IwKla':function(_0x13b5bc,_0x1c25ef){return _0x13b5bc(_0x1c25ef);},'Swvcb':_0x2d55('0x4c'),'rUrKQ':_0x2d55('0x318'),'gPFsC':_0x2d55('0x428'),'mxSYL':_0x2d55('0x76'),'lfEaT':_0x2d55('0x7cc'),'XSpWS':_0x2d55('0x4cf'),'eQJKp':'#007FFD','ovqFY':_0x2d55('0x73'),'DGbzL':function(_0x3cdad6,_0x3390b1){return _0x3cdad6!=_0x3390b1;},'nsiSD':_0x2d55('0x39e'),'kYrLq':_0x2d55('0x4b'),'ztzoh':_0x2d55('0x75d'),'MmkuM':function(_0x147b7d,_0x1c6bf7){return _0x147b7d==_0x1c6bf7;},'hZtZu':function(_0x2e9b4c,_0x983bd7){return _0x2e9b4c+_0x983bd7;},'PIcSG':_0x2d55('0xc5'),'jpgUs':_0x2d55('0x48f'),'KNDAR':_0x2d55('0xb'),'TRNpu':_0x2d55('0xde'),'bsTpE':_0x2d55('0x6d1'),'srzzw':function(_0x260947,_0x5ea833,_0x1746c5){return _0x260947(_0x5ea833,_0x1746c5);},'TScZA':_0x2d55('0x7c2'),'rYBOj':function(_0xcf9608,_0x3d5e64){return _0xcf9608<_0x3d5e64;},'bSzIN':_0x2d55('0x142'),'MCrMi':_0x2d55('0x59f'),'uejpx':_0x2d55('0x7e4'),'xgtke':_0x2d55('0x50f'),'WSBYl':function(_0x364ee1,_0x4caf8a){return _0x364ee1<_0x4caf8a;},'ceBzc':_0x2d55('0x6aa'),'fcSbv':'image/png','TAWCU':'true','nPeTg':_0x2d55('0x783'),'fAKvb':_0x2d55('0x37e'),'ioGdk':function(_0x533589,_0x1e21ee,_0x31af26,_0x11bcc1){return _0x533589(_0x1e21ee,_0x31af26,_0x11bcc1);}};function _0x340e57(_0x6c7360){var _0xc2edd2={'x':0x0,'y':0x0},_0x6c7360=(_0xc2edd2['x']=_0x6c7360[_0x2d55('0x516')]*Math['PI']/0xb4*0x615299,_0x41071e[_0x2d55('0x340')](_0x6c7360[_0x2d55('0x861')],Math['PI'])/0xb4);return _0xc2edd2['y']=3189068.5*Math[_0x2d55('0x10b')](_0x41071e[_0x2d55('0x800')](_0x41071e['iTjoa'](0x1,Math[_0x2d55('0x600')](_0x6c7360)),_0x41071e[_0x2d55('0x872')](0x1,Math[_0x2d55('0x600')](_0x6c7360)))),_0xc2edd2;}function _0x451f95(_0x141530='get',_0x5922a4,_0x94767b={}){return new Promise((_0xeca69,_0xdbd1ad)=>{var _0x2fb002={'EPEoO':function(_0x23b16c,_0x2eb262){return _0x41071e[_0x2d55('0x67a')](_0x23b16c,_0x2eb262);},'tFKEx':function(_0x55e7a2,_0x5b2f64){return _0x41071e[_0x2d55('0x67a')](_0x55e7a2,_0x5b2f64);},'xxYrf':function(_0x6f57d6,_0x21a6bc){return _0x41071e[_0x2d55('0x46c')](_0x6f57d6,_0x21a6bc);}};_0x41071e[_0x2d55('0x358')](_0x41071e[_0x2d55('0x3e2')],_0x141530)?_0x41071e[_0x2d55('0x95')](axios,{'method':_0x141530,'url':_0x5922a4,'params':_0x94767b})[_0x2d55('0x37f')](_0x2fbbd4=>{_0x2fb002[_0x2d55('0x253')](_0xeca69,_0x2fbbd4);})[_0x2d55('0x5b5')](_0x17eaee=>{_0x2fb002[_0x2d55('0x86d')](_0xdbd1ad,_0x17eaee);}):_0x41071e['IwKla'](axios,{'method':_0x141530,'url':_0x5922a4,'data':_0x94767b})[_0x2d55('0x37f')](_0x1a40df=>{_0x2fb002[_0x2d55('0x101')](_0xeca69,_0x1a40df);})[_0x2d55('0x5b5')](_0x2d8b2b=>{_0x2fb002['xxYrf'](_0xdbd1ad,_0x2d8b2b);});});}window[_0x2d55('0x380')]||(window[_0x2d55('0x380')]={}),window['bdmap']['MapPrint']=new function(){var _0xf01773={'yzifs':function(_0x4bbaba,_0x2fc6da){return _0x41071e[_0x2d55('0x1d7')](_0x4bbaba,_0x2fc6da);},'zEMfG':_0x2d55('0x732'),'kDYhS':_0x41071e[_0x2d55('0x48a')],'yQjJV':_0x41071e[_0x2d55('0x80a')],'zCGEn':_0x41071e[_0x2d55('0x2c3')],'cIQXv':function(_0x2efae9,_0x2fecca){return _0x2efae9+_0x2fecca;},'sJmKN':_0x41071e[_0x2d55('0x163')],'mNggX':_0x41071e['lfEaT'],'Zyvaa':'#123456','RFajQ':_0x41071e[_0x2d55('0x6bd')],'ZTYbn':_0x2d55('0x3a4'),'VwPvS':_0x41071e['eQJKp'],'gVXmZ':_0x41071e[_0x2d55('0xb4')],'mtxji':function(_0x192253,_0x5e0b91){return _0x41071e[_0x2d55('0x20f')](_0x192253,_0x5e0b91);},'UWDeK':function(_0x534196,_0x4ec2d3){return _0x41071e[_0x2d55('0x358')](_0x534196,_0x4ec2d3);},'EoEsv':_0x41071e[_0x2d55('0x4fb')],'UMyad':_0x41071e[_0x2d55('0x46f')],'sNnAS':_0x41071e[_0x2d55('0x58a')],'ZDZxA':function(_0x3094ae,_0x4c26a5){return _0x41071e[_0x2d55('0x78d')](_0x3094ae,_0x4c26a5);},'gQaPC':function(_0x42adb4,_0x4b6b58){return _0x41071e[_0x2d55('0x812')](_0x42adb4,_0x4b6b58);},'Xfapi':_0x41071e[_0x2d55('0x877')],'gxOHm':_0x41071e[_0x2d55('0x37c')],'PFpDJ':_0x2d55('0x26c'),'csOuA':_0x41071e['KNDAR'],'Vqxks':'polygon','QGtlx':_0x2d55('0x3e0'),'VGMJZ':_0x41071e[_0x2d55('0x5a2')],'eqVtP':_0x41071e[_0x2d55('0x612')],'YMuSU':function(_0x1e5b96,_0x40e1ca,_0x20fbf6){return _0x41071e[_0x2d55('0x82')](_0x1e5b96,_0x40e1ca,_0x20fbf6);},'xfBTd':_0x41071e[_0x2d55('0x3e2')],'gTXDL':function(_0x10d76c,_0x439151){return _0x41071e[_0x2d55('0x812')](_0x10d76c,_0x439151);},'HCaKt':_0x41071e['TScZA'],'Srhwl':function(_0x4dfa31,_0x3afb8d){return _0x41071e[_0x2d55('0x2d')](_0x4dfa31,_0x3afb8d);},'QkjWk':_0x41071e[_0x2d55('0x35b')],'linzU':_0x2d55('0x45'),'vgTSi':_0x41071e[_0x2d55('0x12')],'vTFjM':'round','JBTHA':_0x2d55('0x58e'),'svhDO':_0x41071e[_0x2d55('0x126')],'BcAXW':_0x2d55('0x686'),'XVdRy':_0x41071e[_0x2d55('0x37b')],'iQmlO':_0x2d55('0x55d'),'cADQP':function(_0x3c93d7,_0x562887){return _0x41071e['WSBYl'](_0x3c93d7,_0x562887);},'EWBBC':_0x41071e[_0x2d55('0x1c')],'MDRZQ':_0x2d55('0x29e'),'rnLxW':_0x41071e[_0x2d55('0x605')],'hxzVr':_0x41071e['TAWCU'],'KwIpP':'WMS','cazVp':_0x41071e[_0x2d55('0x6b5')],'jSXOs':_0x41071e[_0x2d55('0x675')],'HEqWz':function(_0x547221,_0x168cc3,_0x273b91,_0x391ab7){return _0x41071e[_0x2d55('0x24b')](_0x547221,_0x168cc3,_0x273b91,_0x391ab7);},'JtMgR':'post','mVIiK':function(_0x1ab4d1,_0x4d8135,_0x5490dc){return _0x41071e['srzzw'](_0x1ab4d1,_0x4d8135,_0x5490dc);}};var _0x494632,_0x5cd136=new protoman['sm']['Evented']();for(_0x494632 in _0x5cd136)this[_0x494632]=_0x5cd136[_0x494632];this['dsq']=null,this[_0x2d55('0x3bb')]=async function({mapCenter:_0x509743=[13218395.22455643,3788607.55389211],scale:_0x2aaf14=0x1388,printUrlHost:_0x4c23ec=_0x2d55('0x633'),printUrl:_0x561182=_0x2d55('0x695'),printTitle:_0x3a37fb,map:_0x3479d1,baseLayer:_0x2844d6,baseMap:_0x1ce506=['ng-gcj02:ng-gcj02-s']}={}){var _0x855892={'GJcNv':function(_0x3e7a50,_0x2857bb){return _0xf01773[_0x2d55('0x2cc')](_0x3e7a50,_0x2857bb);},'RjvGg':_0xf01773[_0x2d55('0x38b')],'UYNTB':function(_0x3a2222,_0x2a3bb9){return _0xf01773[_0x2d55('0x4b7')](_0x3a2222,_0x2a3bb9);},'WyAXT':function(_0x1d4678,_0x53afbb){return _0xf01773[_0x2d55('0x6fd')](_0x1d4678,_0x53afbb);},'TjPMQ':'Label','yXHza':_0xf01773[_0x2d55('0x3cd')],'UJdQq':function(_0x15b2f1,_0x3ed467){return _0x15b2f1+_0x3ed467;},'bQbWY':_0xf01773[_0x2d55('0x3b7')],'nAgzo':_0xf01773[_0x2d55('0x791')],'FTKcM':function(_0x5631d9,_0xc99537){return _0xf01773[_0x2d55('0x46a')](_0x5631d9,_0xc99537);},'NgRtq':function(_0x578bc1,_0x5ec911){return _0xf01773[_0x2d55('0x6c5')](_0x578bc1,_0x5ec911);},'JUjcB':_0xf01773[_0x2d55('0x42f')],'IAIRv':_0xf01773['gxOHm'],'SQOES':function(_0x347315,_0x19ff59){return _0x347315-_0x19ff59;},'fYKKf':_0xf01773[_0x2d55('0x213')],'yiMpt':function(_0x3eda69,_0x296d62){return _0x3eda69-_0x296d62;},'KQIca':_0x2d55('0xfd'),'QYZsk':function(_0x54c06b,_0x137f28){return _0xf01773['mtxji'](_0x54c06b,_0x137f28);},'zmjjd':_0xf01773[_0x2d55('0x7a2')],'RlIpv':_0xf01773[_0x2d55('0x87b')],'cKVhJ':_0xf01773['gVXmZ'],'jxUSP':_0x2d55('0x732'),'rgEtf':_0xf01773[_0x2d55('0x3a5')],'sObdV':_0xf01773[_0x2d55('0x794')],'ajBvV':_0xf01773[_0x2d55('0x52c')],'flPvd':_0x2d55('0x2c7'),'EzIvf':_0xf01773['eqVtP'],'sxfRt':function(_0x181ac3,_0x58c5eb,_0x30359b){return _0xf01773[_0x2d55('0x4fe')](_0x181ac3,_0x58c5eb,_0x30359b);},'zClyp':_0xf01773[_0x2d55('0x5bf')],'gAzuL':function(_0x1b0fdd,_0x1968f4){return _0xf01773[_0x2d55('0x6c5')](_0x1b0fdd,_0x1968f4);},'lSUqG':function(_0x373502,_0x45bc18){return _0xf01773['gTXDL'](_0x373502,_0x45bc18);},'BbRDa':function(_0x3639cc,_0x35de96){return _0x3639cc==_0x35de96;},'HUYnR':_0xf01773[_0x2d55('0xe4')]};_0xf01773[_0x2d55('0x2cc')](clearInterval,this[_0x2d55('0x48d')]);var _0x4806c0,_0x3479d1=_0x3479d1[_0x2d55('0x49d')]();console[_0x2d55('0x10b')](_0x3479d1);let _0x4b1aef={},_0x25780a=[],_0x1d5d17=[];for(_0x4806c0 in(_0x3479d1['layers'][_0x2d55('0x457')](_0x1f2630=>{_0x1f2630['geometries']&&0x0<_0x1f2630['geometries']['length']&&_0x1f2630[_0x2d55('0x679')][_0x2d55('0x457')]((_0x12a4cd,_0x55895a)=>{var _0x4f8262={'TGFlu':function(_0xfa8e29,_0x3e725d){return _0x855892['GJcNv'](_0xfa8e29,_0x3e725d);}};if(_0x855892[_0x2d55('0x267')]==_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0xe3')][_0x2d55('0x6c4')]){if(!_0x12a4cd[_0x2d55('0x263')]||_0x855892['UYNTB'](_0x2d55('0x26c'),_0x12a4cd[_0x2d55('0x263')])){if(_0x12a4cd[_0x2d55('0x263')]&&_0x855892[_0x2d55('0x370')](_0x855892[_0x2d55('0x898')],_0x12a4cd[_0x2d55('0x263')]))return _0x12a4cd['options'][_0x2d55('0x27a')]?_0x25780a[_0x2d55('0x590')]({'textCoordinates':_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0xe3')][_0x2d55('0x537')],'textContent':_0x12a4cd[_0x2d55('0x15a')],'textStyle':_0x12a4cd['options'][_0x2d55('0x3c5')]}):void 0x0;let _0x1eeb4f,_0x2c04ad,_0x885e15;(_0x1eeb4f=Object[_0x2d55('0x4e2')][_0x2d55('0x25e')][_0x2d55('0x55e')](_0x12a4cd[_0x2d55('0x21c')])[_0x2d55('0x202')]('Array')?_0x855892[_0x2d55('0x370')](_0x855892[_0x2d55('0x28e')],_0x12a4cd[_0x2d55('0x21c')][0x0]['markerType'])?_0x855892[_0x2d55('0x603')](_0x2d55('0xc5'),_0x12a4cd[_0x2d55('0x3eb')]['properties'][_0x2d55('0x144')])+_0x855892['bQbWY']:_0x12a4cd[_0x2d55('0x21c')][0x0]['markerFile']:!_0x12a4cd[_0x2d55('0x21c')]||_0x12a4cd[_0x2d55('0x21c')][_0x2d55('0x5bb')]&&_0x855892[_0x2d55('0x370')](_0x2d55('0x1da'),_0x12a4cd[_0x2d55('0x21c')]['markerType'])?_0x855892[_0x2d55('0xe6')]:_0x855892[_0x2d55('0x55')](_0x855892[_0x2d55('0x28e')],_0x12a4cd[_0x2d55('0x21c')][_0x2d55('0x5bb')])?_0x855892[_0x2d55('0x247')](_0x855892['JUjcB'],_0x12a4cd['feature'][_0x2d55('0x6e')][_0x2d55('0x144')])+_0x2d55('0x4b'):_0x12a4cd[_0x2d55('0x21c')]['markerFile'])[_0x2d55('0x202')](_0x855892[_0x2d55('0x420')])||(_0x1eeb4f=(_0x15a8ab=_0x1eeb4f,(_0x33f34a=document[_0x2d55('0x5b6')](_0x2d55('0x446')))[_0x2d55('0x7c')]=_0x15a8ab,_0x15a8ab=_0x33f34a[_0x2d55('0x7c')],_0x33f34a[_0x2d55('0x7c')]=null,_0x15a8ab)),_0x2c04ad=_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0xe3')][_0x2d55('0x537')],_0x12a4cd[_0x2d55('0x3eb')]['properties']&&_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0x6e')][_0x2d55('0x20e')]?_0x885e15=_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0x6e')]['name']:_0x1f2630[_0x2d55('0x679')][_0x855892['SQOES'](_0x55895a,0x1)]&&_0x855892[_0x2d55('0x55')](_0x855892[_0x2d55('0x7fa')],_0x1f2630[_0x2d55('0x679')][_0x855892[_0x2d55('0x74a')](_0x55895a,0x1)]['subType'])&&(_0x885e15=_0x1f2630[_0x2d55('0x679')][_0x855892['yiMpt'](_0x55895a,0x1)][_0x2d55('0x15a')]),_0x4b1aef[_0x1eeb4f]||(_0x4b1aef[_0x1eeb4f]=[]),_0x4b1aef[_0x1eeb4f][_0x2d55('0x590')]({'markerImgUrl':_0x1eeb4f,'markerCoordinates':_0x2c04ad,'markerLabel':_0x885e15});}}else if(_0x855892[_0x2d55('0x55')](_0x855892[_0x2d55('0x430')],_0x12a4cd[_0x2d55('0x3eb')]['geometry'][_0x2d55('0x6c4')])){if(_0x855892[_0x2d55('0x10f')](_0x855892[_0x2d55('0x288')],_0x12a4cd[_0x2d55('0x21c')][_0x2d55('0x140')])){let _0xf5c633=[];_0x12a4cd['feature']['geometry'][_0x2d55('0x537')][0x0][_0x2d55('0x457')](_0x5ce797=>{_0x5ce797=_0x4f8262[_0x2d55('0x226')](_0x340e57,{'lat':_0x5ce797[0x1],'lng':_0x5ce797[0x0]});_0xf5c633[_0x2d55('0x590')]([_0x5ce797['x'],_0x5ce797['y']]);});_0x33f34a={'type':_0x2d55('0x732'),'properties':{},'geometry':{'type':_0x855892['KQIca'],'coordinates':[_0xf5c633]}};_0x1d5d17[_0x2d55('0x590')]({'type':_0x2d55('0x318'),'style':{'*':{'symbolizers':[{'fillColor':_0x12a4cd['symbol'][_0x2d55('0x140')],'strokeColor':_0x12a4cd['symbol']['lineColor'],'fillOpacity':0.6,'strokeOpacity':0x1,'strokeWidth':_0x12a4cd[_0x2d55('0x21c')][_0x2d55('0x191')],'pointRadius':0x6,'type':_0x855892[_0x2d55('0x561')]}]},'version':'2'},'geoJson':{'type':_0x855892[_0x2d55('0x34')],'features':[_0x33f34a]}});}}else if(_0x2d55('0x251')==_0x12a4cd[_0x2d55('0x3eb')][_0x2d55('0xe3')][_0x2d55('0x6c4')]&&_0x855892['QYZsk'](_0x2d55('0xb'),_0x12a4cd[_0x2d55('0x21c')]['lineColor'])){let _0x350f12=[];_0x12a4cd['feature'][_0x2d55('0xe3')][_0x2d55('0x537')][_0x2d55('0x457')](_0x178a98=>{_0x178a98=_0x340e57({'lat':_0x178a98[0x1],'lng':_0x178a98[0x0]});_0x350f12['push']([_0x178a98['x'],_0x178a98['y']]);});_0x15a8ab={'type':_0x855892[_0x2d55('0x81f')],'properties':{},'geometry':{'type':'MultiLineString','coordinates':[_0x350f12]}};_0x1d5d17[_0x2d55('0x590')]({'type':_0x855892[_0x2d55('0x613')],'style':{'*':{'symbolizers':[{'fillColor':_0x12a4cd[_0x2d55('0x21c')][_0x2d55('0x688')],'strokeColor':_0x12a4cd[_0x2d55('0x21c')]['lineColor'],'fillOpacity':0x1,'strokeOpacity':0x1,'strokeWidth':_0x12a4cd[_0x2d55('0x21c')]['lineWidth'],'pointRadius':0x6,'type':_0x855892['sObdV']}]},'version':'2'},'geoJson':{'type':_0x855892[_0x2d55('0x34')],'features':[_0x15a8ab]}});}var _0x15a8ab,_0x33f34a;});}),_0xf01773['Srhwl'](0x0,_0x25780a[_0x2d55('0x6e9')])&&_0x25780a[_0x2d55('0x457')](_0x1b2d84=>{var _0x517229=[],_0x284a94=_0xf01773[_0x2d55('0x2cc')](_0x340e57,{'lat':_0x1b2d84[_0x2d55('0x5ad')][0x1],'lng':_0x1b2d84[_0x2d55('0x5ad')][0x0]}),_0x284a94=[_0x284a94['x'],_0x284a94['y']],_0x284a94=(_0x517229['push']({'type':_0xf01773[_0x2d55('0x155')],'geometry':{'type':_0xf01773[_0x2d55('0x38b')],'coordinates':_0x284a94},'properties':{'name':_0x1b2d84[_0x2d55('0x57f')]}}),{'type':_0xf01773[_0x2d55('0x3a5')],'style':{'*':{'symbolizers':[{'type':_0xf01773[_0x2d55('0x100')],'fontColor':_0x1b2d84[_0x2d55('0x836')]['textFill'],'fontFamily':_0x1b2d84[_0x2d55('0x836')][_0x2d55('0x5dc')],'fontSize':_0xf01773['cIQXv'](_0x1b2d84[_0x2d55('0x836')][_0x2d55('0x421')],'px'),'fontStyle':_0xf01773[_0x2d55('0x4e6')],'fontWeight':_0xf01773[_0x2d55('0x460')],'haloColor':_0xf01773['Zyvaa'],'haloOpacity':_0xf01773[_0x2d55('0x76f')],'haloRadius':_0x2d55('0x686'),'label':_0xf01773['ZTYbn'],'fillColor':_0xf01773[_0x2d55('0x787')],'fillOpacity':0x0,'labelAlign':'cm','labelRotation':'0','labelXOffset':_0x2d55('0x50f'),'labelYOffset':_0x2d55('0x50f')}]},'version':'2'},'geoJson':{'type':_0xf01773[_0x2d55('0x3b5')],'features':_0x517229}});_0x1d5d17['push'](_0x284a94);}),_0x4b1aef)){let _0x38152e=[];_0x4b1aef[_0x4806c0][_0x2d55('0x457')](_0x53531f=>{var _0x31efce=_0x340e57({'lat':_0x53531f[_0x2d55('0x38a')][0x1],'lng':_0x53531f[_0x2d55('0x38a')][0x0]}),_0x31efce=[_0x31efce['x'],_0x31efce['y']];_0x38152e[_0x2d55('0x590')]({'type':_0xf01773[_0x2d55('0x155')],'geometry':{'type':_0xf01773[_0x2d55('0x38b')],'coordinates':_0x31efce},'properties':{'name':_0x53531f[_0x2d55('0x51')]}});});var _0x3faeb9={'type':_0xf01773[_0x2d55('0x3a5')],'style':{'*':{'symbolizers':[{'type':_0xf01773['QkjWk'],'fillColor':_0xf01773[_0x2d55('0x727')],'fillOpacity':0x0,'rotation':'0','externalGraphic':_0x4806c0,'pointRadius':0x1a,'strokeColor':_0xf01773['vgTSi'],'strokeOpacity':0x1,'strokeWidth':0x5,'strokeLinecap':_0xf01773[_0x2d55('0x344')],'strokeLinejoin':_0xf01773[_0x2d55('0x344')],'strokeDashstyle':_0x2d55('0x4ee')},{'type':_0xf01773[_0x2d55('0x100')],'fontColor':_0xf01773[_0x2d55('0x723')],'fontFamily':_0xf01773[_0x2d55('0x65f')],'fontSize':_0xf01773[_0x2d55('0xa0')],'fontStyle':_0xf01773[_0x2d55('0x4e6')],'fontWeight':_0xf01773['mNggX'],'haloColor':_0xf01773[_0x2d55('0x751')],'haloOpacity':_0xf01773[_0x2d55('0x76f')],'haloRadius':_0xf01773[_0x2d55('0x1bb')],'label':'[name]','fillColor':_0xf01773['VwPvS'],'fillOpacity':0x0,'labelAlign':'cm','labelRotation':'0','labelXOffset':_0xf01773[_0x2d55('0x635')],'labelYOffset':_0xf01773['iQmlO']}]},'version':'2'},'geoJson':{'type':_0xf01773[_0x2d55('0x3b5')],'features':_0x38152e}};_0x1d5d17[_0x2d55('0x590')](_0x3faeb9);}_0x2844d6&&_0xf01773['cADQP'](0x0,_0x2844d6[_0x2d55('0x6e9')])&&_0x1d5d17[_0x2d55('0x590')]({'baseURL':_0xf01773['EWBBC'],'opacity':0x1,'type':'WMS','version':_0xf01773['MDRZQ'],'layers':_0x2844d6,'imageFormat':_0xf01773[_0x2d55('0x6f4')],'customParams':{'TRANSPARENT':_0xf01773[_0x2d55('0x1ec')]}}),_0x1d5d17['push']({'baseURL':_0xf01773[_0x2d55('0x68d')],'opacity':0x1,'type':_0xf01773[_0x2d55('0x10e')],'version':_0xf01773[_0x2d55('0x47f')],'layers':_0x1ce506,'imageFormat':_0xf01773[_0x2d55('0x6f4')],'customParams':{'TRANSPARENT':_0xf01773[_0x2d55('0x1ec')]}}),_0x1d5d17[_0x2d55('0x590')]({'baseURL':_0xf01773[_0x2d55('0x68d')],'opacity':0x1,'type':_0xf01773[_0x2d55('0x10e')],'version':_0xf01773[_0x2d55('0x47f')],'layers':[_0xf01773['cazVp']],'imageFormat':_0xf01773['rnLxW'],'customParams':{'TRANSPARENT':_0xf01773[_0x2d55('0x1ec')]}});_0x3479d1={'layout':'T1','outputFormat':_0xf01773[_0x2d55('0x1a4')],'attributes':{'name':_0x3a37fb,'scale':_0x2aaf14,'map':{'projection':'EPSG:3857','dpi':0x48,'rotation':0x0,'longitudeFirst':!0x0,'scale':_0x2aaf14||0x1388,'center':_0x509743,'layers':_0x1d5d17}}};console[_0x2d55('0x10b')](JSON[_0x2d55('0x850')](_0x3479d1));const _0x250834=await _0xf01773['HEqWz'](_0x451f95,_0xf01773[_0x2d55('0x14a')],_0xf01773[_0x2d55('0x462')]('',_0x4c23ec)+_0x561182,_0x3479d1);_0xf01773[_0x2d55('0x2cc')](clearInterval,this[_0x2d55('0x48d')]),this['dsq']=_0xf01773[_0x2d55('0x3e4')](setInterval,async()=>{var _0x1b831d={'MNpzu':function(_0x437f76,_0x26a5fb){return _0x855892[_0x2d55('0x247')](_0x437f76,_0x26a5fb);},'ndpvI':function(_0x485751,_0x4fcc15){return _0x485751!==_0x4fcc15;},'ZzFPf':_0x855892[_0x2d55('0x79a')],'zWhmp':function(_0x20446b,_0x115440){return _0x855892[_0x2d55('0x247')](_0x20446b,_0x115440);},'zQhFt':_0x855892['flPvd'],'QTetS':_0x2d55('0x6bc'),'UXhiK':_0x855892[_0x2d55('0x4a5')]};var _0x1fcbdd=await _0x855892[_0x2d55('0x451')](_0x451f95,_0x855892[_0x2d55('0x569')],_0x855892[_0x2d55('0x490')](_0x855892[_0x2d55('0x490')]('',_0x4c23ec),_0x250834[_0x2d55('0x10c')][_0x2d55('0x75a')]));_0x1fcbdd[_0x2d55('0x10c')][_0x2d55('0xbe')]&&_0x855892[_0x2d55('0x55')]('finished',_0x1fcbdd[_0x2d55('0x10c')][_0x2d55('0x649')])?(clearInterval(this['dsq']),axios[_0x2d55('0x86')](_0x855892['lSUqG']('',_0x4c23ec)+_0x250834[_0x2d55('0x10c')][_0x2d55('0x2f1')],{'timeout':0xf4240,'responseType':_0x2d55('0x298')})['then'](_0xb68afd=>{var _0x1a39d2,_0x562784;console[_0x2d55('0x10b')](_0xb68afd[_0x2d55('0x10c')]),_0xb68afd&&(_0x1a39d2=(_0x1a39d2=new Date())[_0x2d55('0x416')]()+'.'+_0x1b831d[_0x2d55('0x5f7')](_0x1a39d2[_0x2d55('0x5f0')](),0x1)+'.'+_0x1a39d2['getDate']()+_0x2d55('0x129'),_0x1b831d[_0x2d55('0x70')](void 0x0,window[_0x2d55('0x64a')][_0x2d55('0x83d')])?window[_0x2d55('0x64a')][_0x2d55('0x83d')](new Blob([_0xb68afd[_0x2d55('0x10c')]],{'type':_0x1b831d['ZzFPf']}),_0x1b831d[_0x2d55('0x89c')](_0x1a39d2,_0x1b831d[_0x2d55('0x1b5')])):(_0xb68afd=window[_0x2d55('0x584')][_0x2d55('0x211')](new Blob([_0xb68afd[_0x2d55('0x10c')]],{'type':_0x1b831d[_0x2d55('0x73f')]})),(_0x562784=document[_0x2d55('0x5b6')]('a'))[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x1b831d['QTetS'],_0x562784[_0x2d55('0x11b')]=_0xb68afd,_0x562784[_0x2d55('0x604')](_0x2d55('0x54e'),_0x1a39d2+_0x1b831d['zQhFt']),document[_0x2d55('0x12c')][_0x2d55('0x124')](_0x562784),_0x562784[_0x2d55('0x81')](),document[_0x2d55('0x12c')]['removeChild'](_0x562784),window['URL'][_0x2d55('0x3f0')](_0xb68afd)));})['catch'](_0x2abec7=>{console[_0x2d55('0x10b')](_0x2abec7);})[_0x2d55('0xa8')](()=>{this[_0x2d55('0x533')](_0x1b831d[_0x2d55('0x7b0')]);})):_0x855892[_0x2d55('0x3aa')](_0x855892['HUYnR'],_0x1fcbdd[_0x2d55('0x10c')][_0x2d55('0x649')])&&(_0x855892[_0x2d55('0x23')](clearInterval,this[_0x2d55('0x48d')]),this['trigger'](_0x855892[_0x2d55('0x4a5')]));},0x7d0);}[_0x2d55('0x7cf')](this);}();}(),BDLayers['Lib'][_0x2d55('0x50b')]['TBItem']=BDLayers[_0x2d55('0x2ca')]({'id':null,'profix_def':_0x2d55('0x835'),'caption':'','icon':'','mapTool':null,'class':null,'title':null,'initialize':function(_0x51349a,_0x5eee56){var _0x53c6d3={'dnYJz':function(_0xeae6cc,_0x41b12b){return _0xeae6cc+_0x41b12b;}};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),this['id']=_0x51349a||_0x53c6d3[_0x2d55('0x1f6')](this['profix_def'],BDLayers[_0x2d55('0x84f')][_0x2d55('0x706')]());},'getItem':function(){return{'item':this['caption'],'class':this['class'],'title':this[_0x2d55('0x5fe')],'click':this[_0x2d55('0x1b7')][_0x2d55('0x7cf')](this)};},'itemClick':null,'CLASS_NAME':_0x2d55('0x44f')}),BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x120')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItem'],{'initialize':function(_0x36429d,_0x42f670){var _0x2ea40f={'ShjMY':'#34495e','lbSqv':_0x2d55('0x259'),'DRIxg':_0x2d55('0x1c1'),'BvYOn':'#000','JpaXa':_0x2d55('0x543'),'OfLBW':_0x2d55('0x64f'),'FJXYd':_0x2d55('0x97'),'eWJdk':_0x2d55('0x59f'),'WfIzj':_0x2d55('0x3d4')};this['title']='测距',this[_0x2d55('0x1a')]=_0x2d55('0x887'),BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x42f670),this[_0x2d55('0x69b')]||(this['mapTool']=new maptalks[(_0x2d55('0x1db'))]({'symbol':{'lineColor':_0x2ea40f[_0x2d55('0x7c0')],'lineWidth':0x2},'vertexSymbol':{'markerType':_0x2ea40f[_0x2d55('0x5b3')],'markerFill':_0x2ea40f[_0x2d55('0x22d')],'markerLineColor':_0x2ea40f['BvYOn'],'markerLineWidth':0x3,'markerWidth':0xa,'markerHeight':0xa},'labelOptions':{'textSymbol':{'textFaceName':_0x2d55('0x178'),'textFill':_0x2d55('0x59f'),'textLineSpacing':0x1,'textHorizontalAlignment':_0x2ea40f['JpaXa'],'textDx':0xf,'markerLineColor':_0x2d55('0x97'),'markerFill':_0x2ea40f['BvYOn']},'boxStyle':{'padding':[0x6,0x2],'symbol':{'markerType':_0x2ea40f[_0x2d55('0x4bc')],'markerFill':_0x2ea40f[_0x2d55('0x71e')],'markerFillOpacity':0.9,'markerLineColor':_0x2ea40f[_0x2d55('0x2b')]}}},'clearButtonSymbol':[{'markerType':_0x2d55('0x64f'),'markerFill':_0x2ea40f[_0x2d55('0x71e')],'markerLineColor':_0x2ea40f['FJXYd'],'markerLineWidth':0x2,'markerWidth':0xf,'markerHeight':0xf,'markerDx':0x14},{'markerType':'x','markerWidth':0xa,'markerHeight':0xa,'markerLineColor':_0x2ea40f[_0x2d55('0x339')],'markerDx':0x14}],'language':_0x2ea40f[_0x2d55('0x299')]}));},'itemClick':function(){var _0xbcdd85={'yiHix':'#DrawPop','yvonw':_0x2d55('0x7ca')};var _0x501278=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x501278,'active')?handleClass[_0x2d55('0x2df')](_0x501278,_0xbcdd85[_0x2d55('0x260')]):handleClass['addClass'](_0x501278,'active'),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this['options'][_0x2d55('0x185')]+'\x20.toolbar-cmj'),_0xbcdd85[_0x2d55('0x260')]),handleClass['removeClass'](document[_0x2d55('0x110')]('#'+this['options'][_0x2d55('0x185')]+_0x2d55('0x210')),_0xbcdd85[_0x2d55('0x260')]),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x4f4')),_0xbcdd85[_0x2d55('0x260')]),this[_0x2d55('0x4f3')][_0x2d55('0x566')][_0x2d55('0x1ac')][_0x2d55('0x69b')][_0x2d55('0x49b')](),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['dw']['mapTool'][_0x2d55('0x45d')](),this[_0x2d55('0x4f3')]['controlList']['dw'][_0x2d55('0x4f3')][_0x2d55('0x700')]['removeLayer'](_0x2d55('0x463')),document['querySelector'](_0x2d55('0x85e'))['style']['opacity']='0',setTimeout(function(){document[_0x2d55('0x110')](_0xbcdd85[_0x2d55('0x31f')])[_0x2d55('0x3a7')]['display']='none';},0xfa),this[_0x2d55('0x69b')][_0x2d55('0x9a')]()?this[_0x2d55('0x69b')][_0x2d55('0x49b')]():this[_0x2d55('0x69b')]['enable']();},'remove':function(){this[_0x2d55('0x69b')][_0x2d55('0x209')](),this[_0x2d55('0x69b')][_0x2d55('0x2d5')]();},'CLASS_NAME':'BDLayers.Lib.Control.TBItemDistance'}),BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x54')]=BDLayers['Class'](BDLayers['Lib'][_0x2d55('0x50b')]['TBItem'],{'initialize':function(_0xe5993a,_0x22c7c9){var _0x5a8a88={'NvnNg':_0x2d55('0x32'),'LtkuU':_0x2d55('0x59f'),'VlBuS':_0x2d55('0x259'),'EaKUq':_0x2d55('0x741'),'kxUyx':'#1bbc9b','ygrxh':_0x2d55('0x64f'),'RcRwA':_0x2d55('0x385'),'VsPph':_0x2d55('0x97'),'Fvfpn':_0x2d55('0x6af')};this['title']='测面积',this[_0x2d55('0x1a')]=_0x5a8a88[_0x2d55('0x667')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x22c7c9),this['mapTool']||(this[_0x2d55('0x69b')]=new maptalks[(_0x2d55('0x3a'))]({'symbol':{'lineColor':_0x2d55('0x1c1'),'lineWidth':0x2,'polygonFill':_0x5a8a88[_0x2d55('0x30c')],'polygonOpacity':0.3},'vertexSymbol':{'markerType':_0x5a8a88[_0x2d55('0x634')],'markerFill':_0x5a8a88[_0x2d55('0x3cc')],'markerLineColor':_0x5a8a88['kxUyx'],'markerLineWidth':0x3,'markerWidth':0xa,'markerHeight':0xa},'labelOptions':{'textSymbol':{'textFaceName':_0x2d55('0x178'),'textFill':_0x5a8a88[_0x2d55('0x30c')],'textLineSpacing':0x1,'textHorizontalAlignment':_0x2d55('0x543'),'textDx':0xf},'boxStyle':{'padding':[0x6,0x2],'symbol':{'markerType':_0x5a8a88[_0x2d55('0x3b3')],'markerFill':_0x5a8a88[_0x2d55('0x758')],'markerFillOpacity':0.9,'markerLineColor':_0x5a8a88[_0x2d55('0x30b')]}}},'clearButtonSymbol':[{'markerType':_0x5a8a88['ygrxh'],'markerFill':_0x5a8a88[_0x2d55('0x758')],'markerLineColor':_0x5a8a88[_0x2d55('0x30b')],'markerLineWidth':0x2,'markerWidth':0xf,'markerHeight':0xf,'markerDx':0x16},{'markerType':'x','markerWidth':0xa,'markerHeight':0xa,'markerLineColor':_0x5a8a88[_0x2d55('0x30c')],'markerDx':0x16}],'language':_0x5a8a88[_0x2d55('0x7a9')]}));},'itemClick':function(){var _0xdf55cf={'PlHsi':_0x2d55('0x6bc'),'TiZbV':'active','nFGZR':'position','FoeHN':_0x2d55('0x85e'),'OoCYL':function(_0x21128a,_0x4875a0,_0x430a80){return _0x21128a(_0x4875a0,_0x430a80);}};var _0x41f91f=window[_0x2d55('0x6b')]['srcElement'];handleClass[_0x2d55('0xb9')](_0x41f91f,_0x2d55('0x7ca'))?handleClass['removeClass'](_0x41f91f,_0xdf55cf[_0x2d55('0x4ce')]):handleClass['addClass'](_0x41f91f,_0xdf55cf['TiZbV']),handleClass['removeClass'](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x704')),_0xdf55cf[_0x2d55('0x4ce')]),handleClass['removeClass'](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x210')),_0x2d55('0x7ca')),handleClass['removeClass'](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')]['targetDiv']+_0x2d55('0x4f4')),_0x2d55('0x7ca')),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['cj'][_0x2d55('0x69b')][_0x2d55('0x49b')](),this[_0x2d55('0x4f3')]['controlList']['dw'][_0x2d55('0x69b')][_0x2d55('0x45d')](),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['dw'][_0x2d55('0x4f3')][_0x2d55('0x700')]['removeLayer'](_0xdf55cf['nFGZR']),document[_0x2d55('0x110')](_0xdf55cf['FoeHN'])[_0x2d55('0x3a7')][_0x2d55('0x69c')]='0',_0xdf55cf[_0x2d55('0x630')](setTimeout,function(){document[_0x2d55('0x110')]('#DrawPop')[_0x2d55('0x3a7')]['display']=_0xdf55cf[_0x2d55('0x29c')];},0xfa),this[_0x2d55('0x69b')]['isEnabled']()?this[_0x2d55('0x69b')][_0x2d55('0x49b')]():this[_0x2d55('0x69b')][_0x2d55('0x1f8')]();},'remove':function(){this[_0x2d55('0x69b')][_0x2d55('0x209')](),this[_0x2d55('0x69b')][_0x2d55('0x2d5')]();},'CLASS_NAME':_0x2d55('0x7d9')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItemZoom']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x753')],{'initialize':function(_0x458918,_0x452d8e){this[_0x2d55('0x5fe')]='缩放',this[_0x2d55('0x1a')]=_0x2d55('0x778'),this[_0x2d55('0x69b')]||(this[_0x2d55('0x69b')]=new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x497'))]({'position':_0x2d55('0x1c8'),'slider':!0x1,'zoomLevel':!0x0}));},'itemClick':function(){var _0x3bb4e6={'LuogQ':_0x2d55('0x7ca')};var _0x2e14b7=window[_0x2d55('0x6b')]['srcElement'];handleClass[_0x2d55('0xb9')](_0x2e14b7,_0x2d55('0x7ca'))?handleClass[_0x2d55('0x2df')](_0x2e14b7,_0x3bb4e6[_0x2d55('0x4be')]):handleClass[_0x2d55('0x53c')](_0x2e14b7,_0x3bb4e6[_0x2d55('0x4be')]),this[_0x2d55('0x69b')][_0x2d55('0x3b')]()?this[_0x2d55('0x69b')][_0x2d55('0x45d')]():this['mapTool'][_0x2d55('0x6a0')]();},'CLASS_NAME':_0x2d55('0x4ca')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x3f9')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x753')],{'initialize':function(_0x3375ed,_0x829cb2){var _0x12e911={'IZpAH':'toolbar-blc','vNMuh':_0x2d55('0x1c8')};this[_0x2d55('0x5fe')]='比例尺',this[_0x2d55('0x1a')]=_0x12e911[_0x2d55('0x895')],this['mapTool']||(this['mapTool']=new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x80c'))]({'position':_0x12e911[_0x2d55('0x663')],'maxWidth':0xc8,'metric':!0x0,'imperial':!0x1,'containerClass':_0x2d55('0x15c')}));},'itemClick':function(){var _0x35dc06={'HildU':_0x2d55('0x7ca'),'xwwvS':_0x2d55('0x15c'),'fXnDO':'pointer-events'};var _0x55aa07=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x55aa07,_0x35dc06[_0x2d55('0x11d')])?handleClass[_0x2d55('0x2df')](_0x55aa07,_0x35dc06[_0x2d55('0x11d')]):handleClass[_0x2d55('0x53c')](_0x55aa07,_0x35dc06[_0x2d55('0x11d')]),this[_0x2d55('0x69b')][_0x2d55('0x3b')]()?this[_0x2d55('0x69b')][_0x2d55('0x45d')]():(this['mapTool'][_0x2d55('0x6a0')](),document[_0x2d55('0x4e8')](_0x35dc06[_0x2d55('0x319')])[0x0][_0x2d55('0x89a')][_0x2d55('0x3a7')][_0x35dc06[_0x2d55('0x5ea')]]=_0x2d55('0x6bc'));},'CLASS_NAME':_0x2d55('0x321')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItemOverview']=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItem'],{'initialize':function(_0x37c2a9,_0xae0f4f){var _0xb3a6f8={'rsdXP':_0x2d55('0x305'),'ICTNG':_0x2d55('0x29a')};this[_0x2d55('0x5fe')]='鹰眼',this[_0x2d55('0x1a')]=_0xb3a6f8[_0x2d55('0x5da')],this[_0x2d55('0x69b')]||(this['mapTool']=new maptalks['control'][(_0x2d55('0x4ef'))]({'position':{'bottom':'0','right':'0'},'size':[0x12c,0xc8],'containerClass':_0xb3a6f8[_0x2d55('0x873')]}));},'itemClick':function(){var _0x2f721a={'NGZvz':_0x2d55('0x7ca')};var _0x1d4a4a=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x1d4a4a,_0x2f721a[_0x2d55('0x33')])?handleClass[_0x2d55('0x2df')](_0x1d4a4a,_0x2f721a[_0x2d55('0x33')]):handleClass[_0x2d55('0x53c')](_0x1d4a4a,_0x2f721a[_0x2d55('0x33')]),this[_0x2d55('0x69b')][_0x2d55('0x3b')]()?this[_0x2d55('0x69b')][_0x2d55('0x45d')]():this['mapTool'][_0x2d55('0x6a0')]();},'CLASS_NAME':_0x2d55('0x564')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x53a')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x50b')][_0x2d55('0x753')],{'initialize':function(_0x11335a,_0x5c24cf){var _0x5e17d0={'lqnom':_0x2d55('0x508')};this[_0x2d55('0x5fe')]='全屏',this[_0x2d55('0x1a')]=_0x5e17d0[_0x2d55('0x134')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x5c24cf);},'itemClick':function(){var _0x17a9eb={'DSVgC':_0x2d55('0x7ca')};var _0x47a543=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x47a543,_0x17a9eb[_0x2d55('0x1cb')])?handleClass[_0x2d55('0x2df')](_0x47a543,_0x17a9eb[_0x2d55('0x1cb')]):handleClass[_0x2d55('0x53c')](_0x47a543,_0x17a9eb['DSVgC']),this['options'][_0x2d55('0x700')][_0x2d55('0x579')]()?this['options']['map'][_0x2d55('0x41c')]():this['options'][_0x2d55('0x700')][_0x2d55('0xae')]();},'CLASS_NAME':_0x2d55('0x565')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItemMapModel']=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x50b')][_0x2d55('0x753')],{'initialize':function(_0x933088,_0x36f45f){var _0x4c11ba={'ydeSc':'矢量，卫星图层切换','ZnuoK':_0x2d55('0x436')};this[_0x2d55('0x5fe')]=_0x4c11ba[_0x2d55('0x4ad')],this[_0x2d55('0x1a')]=_0x4c11ba[_0x2d55('0x6e4')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x36f45f);},'itemClick':function(){var _0x3bdb22={'ALyDe':_0x2d55('0x7ca'),'nRIJr':_0x2d55('0x636')};var _0x20f2a3=window[_0x2d55('0x6b')]['srcElement'];handleClass[_0x2d55('0xb9')](_0x20f2a3,_0x3bdb22[_0x2d55('0x3bd')])?handleClass[_0x2d55('0x2df')](_0x20f2a3,_0x3bdb22[_0x2d55('0x3bd')]):handleClass[_0x2d55('0x53c')](_0x20f2a3,_0x3bdb22[_0x2d55('0x3bd')]);let _0x6a23b3=null,_0x20a960=null;_0x6a23b3=handleClass['hasClass'](document[_0x2d55('0x110')](_0x3bdb22[_0x2d55('0x7f1')]),_0x3bdb22[_0x2d55('0x3bd')])?(_0x20a960=this[_0x2d55('0x4f3')][_0x2d55('0x683')][_0x2d55('0x2a8')](!0x0),this[_0x2d55('0x4f3')][_0x2d55('0x683')][_0x2d55('0x7aa')](!0x0)):(_0x20a960=this[_0x2d55('0x4f3')]['baseLayers']['toLayer'](!0x1),this[_0x2d55('0x4f3')][_0x2d55('0x683')][_0x2d55('0x7aa')](!0x1)),this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x150')](_0x20a960),this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x197')](_0x6a23b3),_0x6a23b3[_0x2d55('0x6ae')]();},'CLASS_NAME':_0x2d55('0xce')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x807')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItem'],{'itemClickExtendHandler':null,'initialize':function(_0x2588d8,_0x15f00e){var _0x875b18={'DaFdo':'夜间模式','MvfAZ':_0x2d55('0x410'),'pSIOM':function(_0x113787,_0x63e2df){return _0x113787===_0x63e2df;},'MTvWf':'night','uahEq':_0x2d55('0x1a0'),'ubGmR':_0x2d55('0x102'),'ViAHU':_0x2d55('0x72f'),'NKbTN':_0x2d55('0x172')};var _0x3017f1=!!_0x15f00e['baseLayers']&&_0x15f00e[_0x2d55('0x683')]['hasDarkLayer'](),_0x83a009=_0x15f00e['map']['options']['initialState'];this['title']=_0x3017f1?_0x875b18['DaFdo']:_0x875b18[_0x2d55('0x588')],this[_0x2d55('0x1a')]=_0x3017f1?_0x875b18[_0x2d55('0x819')](_0x875b18[_0x2d55('0xf2')],_0x83a009)?_0x875b18[_0x2d55('0x217')]:_0x875b18[_0x2d55('0x383')]:_0x875b18[_0x2d55('0x3e')],BDLayers['Util'][_0x2d55('0x222')](this,_0x15f00e),_0x3017f1&&_0x875b18['MTvWf']===_0x83a009&&(this['setActiveStyleSheet'](_0x875b18['NKbTN']),_0x15f00e=this[_0x2d55('0x4f3')][_0x2d55('0x683')][_0x2d55('0x2a8')](!0x0),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['removeLayer'](this[_0x2d55('0x4f3')]['baseLayers'][_0x2d55('0x2a8')]()),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['addLayer'](_0x15f00e),_0x15f00e['bringToBack']());},'itemClick':function(){var _0x2ed329={'HoENi':'active','gxIKd':_0x2d55('0x172'),'zsehC':_0x2d55('0x76')};if(this[_0x2d55('0x4f3')]['baseLayers'][_0x2d55('0x2a2')]()){var _0x232e25=0x0,_0x22414f=window[_0x2d55('0x6b')]['srcElement'];handleClass[_0x2d55('0xb9')](_0x22414f,_0x2ed329[_0x2d55('0x894')])?handleClass[_0x2d55('0x2df')](_0x22414f,_0x2ed329[_0x2d55('0x894')]):handleClass[_0x2d55('0x53c')](_0x22414f,_0x2d55('0x7ca'));let _0x3f90cc=null,_0x11a5fc=null;_0x232e25=handleClass[_0x2d55('0xb9')](_0x22414f,_0x2ed329[_0x2d55('0x894')])?(this['setActiveStyleSheet'](_0x2ed329[_0x2d55('0x840')]),_0x3f90cc=this['options'][_0x2d55('0x683')][_0x2d55('0x2a8')](!0x0),_0x11a5fc=this[_0x2d55('0x4f3')][_0x2d55('0x683')]['toLayer'](!0x1),0x0):(this[_0x2d55('0xbb')](_0x2ed329[_0x2d55('0x54b')]),_0x3f90cc=this[_0x2d55('0x4f3')][_0x2d55('0x683')][_0x2d55('0x2a8')](!0x1),_0x11a5fc=this[_0x2d55('0x4f3')][_0x2d55('0x683')]['toLayer'](!0x0),0x1),this['options'][_0x2d55('0x700')][_0x2d55('0x150')](_0x11a5fc),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['addLayer'](_0x3f90cc),_0x3f90cc[_0x2d55('0x6ae')](),this[_0x2d55('0x6b8')]&&this[_0x2d55('0x6b8')](_0x232e25);}},'setActiveStyleSheet':function(_0x3262b2){var _0x5342fb={'UupeF':'link','MXPwD':function(_0x338388,_0x18a758){return _0x338388<_0x18a758;},'EuZVt':_0x2d55('0x3fc'),'HApwp':'style','FSpJV':function(_0x50ed60,_0x45f853){return _0x50ed60==_0x45f853;},'MEWyI':_0x2d55('0x5fe')};var _0x45bd60=document[_0x2d55('0x5ba')](_0x5342fb[_0x2d55('0x85a')]);if(_0x3262b2)for(var _0x196863=0x0;_0x5342fb[_0x2d55('0x4b8')](_0x196863,_0x45bd60['length']);_0x196863++)-0x1!=_0x45bd60[_0x196863][_0x2d55('0x2ed')](_0x5342fb[_0x2d55('0x70b')])[_0x2d55('0x6c3')](_0x5342fb[_0x2d55('0x4a3')])&&_0x45bd60[_0x196863]['getAttribute'](_0x2d55('0x5fe'))&&(_0x45bd60[_0x196863][_0x2d55('0x653')]=!0x0,_0x5342fb[_0x2d55('0x657')](_0x45bd60[_0x196863][_0x2d55('0x2ed')](_0x5342fb[_0x2d55('0x8a1')]),_0x3262b2))&&(_0x45bd60[_0x196863][_0x2d55('0x653')]=!0x1);},'regItemClickExtendHandler':function(_0x330391){_0x330391&&(this['itemClickExtendHandler']=_0x330391);},'CLASS_NAME':_0x2d55('0x6c9')}),BDLayers['Lib']['Control'][_0x2d55('0x55c')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x50b')][_0x2d55('0x753')],{'itemClickExtendHandler':null,'initialize':function(_0xb9be68,_0xc04fed){var _0x1f72f8={'EfySw':_0x2d55('0x8a'),'AgFED':_0x2d55('0x31b'),'FbEBB':_0x2d55('0x737')};this[_0x2d55('0x5fe')]=_0x1f72f8[_0x2d55('0x5f3')],this[_0x2d55('0x1a')]=_0x1f72f8[_0x2d55('0x39f')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0xc04fed);var _0x27f855=this;this[_0x2d55('0x4f3')][_0x2d55('0x700')]['on'](_0x2d55('0x37'),function(){var _0x1dc23d=document[_0x2d55('0x4e8')](_0x1f72f8['EfySw']);_0x1dc23d&&_0x1dc23d[0x0]&&(_0x1dc23d[0x0]['style']['transform']=_0x2d55('0x1fd')+_0x27f855['options'][_0x2d55('0x700')][_0x2d55('0x661')]()+_0x2d55('0x1d5')+_0x27f855[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x472')]()+'deg)');});},'itemClick':function(){var _0x10397d={'jYtdh':'rotateX(0deg)\x20rotateZ(0deg)','vqRru':function(_0x48dc74,_0x4ee930){return _0x48dc74+_0x4ee930;},'qoxwo':function(_0x139993,_0x22ce13){return _0x139993+_0x22ce13;},'dElun':function(_0x2a8499,_0x48a4cc){return _0x2a8499+_0x48a4cc;},'Yswdv':function(_0x188c78,_0x59a180){return _0x188c78-_0x59a180;},'qqReE':'active','oWtFa':_0x2d55('0x737'),'ttEVV':_0x2d55('0x307'),'jKJLx':_0x2d55('0x106'),'azywS':_0x2d55('0x620'),'VpzUO':_0x2d55('0x11'),'wgAPB':_0x2d55('0x204'),'GyNwZ':_0x2d55('0x59c'),'WoTnj':'maptalks-toolbar-pitch-top'};var _0x524175,_0x217974,_0x2cf3fc,_0x44ebca,_0x4402fb,_0x338cc4,_0x101468,_0x31e21e,_0x40465d=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass['hasClass'](_0x40465d,_0x10397d[_0x2d55('0x7e9')])?handleClass[_0x2d55('0x2df')](_0x40465d,_0x10397d[_0x2d55('0x7e9')]):handleClass[_0x2d55('0x53c')](_0x40465d,_0x10397d[_0x2d55('0x7e9')]),_0x40465d[_0x2d55('0x56c')]['includes'](_0x10397d['oWtFa'])&&handleClass['hasClass'](_0x40465d,_0x10397d[_0x2d55('0x7e9')])||this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x4f3')][_0x2d55('0x56a')]?((_0x40465d=document['createElement']('div'))['className']=_0x10397d['ttEVV'],(_0x4402fb=document[_0x2d55('0x5b6')](_0x10397d['jKJLx']))[_0x2d55('0x56c')]=_0x10397d['azywS'],(_0x44ebca=document[_0x2d55('0x5b6')](_0x10397d['jKJLx']))['className']=_0x2d55('0x68'),(_0x338cc4=document[_0x2d55('0x5b6')](_0x10397d[_0x2d55('0x671')]))[_0x2d55('0x56c')]=_0x2d55('0x563'),(_0x524175=document[_0x2d55('0x5b6')](_0x10397d[_0x2d55('0x671')]))['className']=_0x2d55('0x8a'),(_0x217974=document['createElement'](_0x10397d[_0x2d55('0x671')]))[_0x2d55('0x56c')]=_0x10397d[_0x2d55('0x5e5')],(_0x2cf3fc=document[_0x2d55('0x5b6')](_0x2d55('0x106')))[_0x2d55('0x56c')]=_0x10397d[_0x2d55('0x85c')],_0x2cf3fc[_0x2d55('0x124')](_0x44ebca),_0x2cf3fc['appendChild'](_0x4402fb),_0x2cf3fc[_0x2d55('0x124')](_0x40465d),_0x2cf3fc[_0x2d55('0x124')](_0x338cc4),_0x217974[_0x2d55('0x124')](_0x524175),_0x2cf3fc[_0x2d55('0x124')](_0x217974),document[_0x2d55('0x4e8')](_0x10397d['GyNwZ'])[0x0][_0x2d55('0x124')](_0x2cf3fc),_0x44ebca=document[_0x2d55('0x4e8')](_0x10397d['ttEVV']),_0x4402fb=document[_0x2d55('0x4e8')](_0x10397d[_0x2d55('0x44e')]),_0x40465d=document['getElementsByClassName'](_0x10397d[_0x2d55('0x444')]),_0x338cc4=document[_0x2d55('0x4e8')](_0x2d55('0x563')),(_0x31e21e=document[_0x2d55('0x4e8')]('maptalks-toolbar-compass'))&&_0x31e21e[0x0]&&(_0x31e21e[0x0][_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x2d55('0x1fd')+this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x661')]()+_0x2d55('0x1d5')+this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x472')]()+_0x2d55('0x5a8')),_0x101468=this,_0x31e21e[0x0]['onclick']=function(){_0x31e21e[0x0][_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x10397d[_0x2d55('0x7c1')],_0x101468['options'][_0x2d55('0x700')][_0x2d55('0x86a')](0x0),_0x101468[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0xe8')](0x0);},_0x44ebca[0x0][_0x2d55('0x17d')]=function(){var _0xacb6be=_0x10397d[_0x2d55('0x149')](_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0x472')](),0xf),_0x2a609d=_0x10397d[_0x2d55('0x149')](_0x101468[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x661')](),0xf);_0x31e21e[0x0][_0x2d55('0x3a7')]['transform']='rotateX('+_0x2a609d+_0x2d55('0x1d5')+_0xacb6be+_0x2d55('0x5a8'),_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0x86a')](_0xacb6be);},_0x4402fb[0x0]['onclick']=function(){var _0x2a2481=_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0x472')]()-0xf,_0x598db6=_0x10397d[_0x2d55('0x149')](_0x101468['options'][_0x2d55('0x700')]['getPitch'](),0xf);_0x31e21e[0x0][_0x2d55('0x3a7')]['transform']=_0x2d55('0x1fd')+_0x598db6+_0x2d55('0x1d5')+_0x2a2481+_0x2d55('0x5a8'),_0x101468['options'][_0x2d55('0x700')][_0x2d55('0x86a')](_0x2a2481);},_0x40465d[0x0][_0x2d55('0x17d')]=function(){var _0x5df563=_0x101468[_0x2d55('0x4f3')][_0x2d55('0x700')]['getBearing']()+0xf,_0x51b8f5=_0x10397d[_0x2d55('0x9f')](_0x101468[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x661')](),0xf);_0x31e21e[0x0]['style'][_0x2d55('0x184')]=_0x2d55('0x1fd')+_0x51b8f5+_0x2d55('0x1d5')+_0x5df563+_0x2d55('0x5a8'),_0x101468[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0xe8')](_0x51b8f5);},_0x338cc4[0x0][_0x2d55('0x17d')]=function(){var _0x3df866=_0x10397d['dElun'](_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0x472')](),0xf),_0x49df8c=_0x10397d[_0x2d55('0x69')](_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0x661')](),0xf);_0x31e21e[0x0][_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x2d55('0x1fd')+_0x49df8c+'deg)\x20rotateZ('+_0x3df866+'deg)',_0x101468[_0x2d55('0x4f3')]['map'][_0x2d55('0xe8')](_0x49df8c);}):(_0x31e21e=document[_0x2d55('0x4e8')](_0x10397d['wgAPB']))&&document[_0x2d55('0x4e8')](_0x2d55('0x59c'))[0x0][_0x2d55('0x65d')](_0x31e21e[0x0]);},'CLASS_NAME':_0x2d55('0x591')}),BDLayers[_0x2d55('0x47b')]['Control']['TBItemNav']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'initialize':function(_0x2d4568,_0x520504){var _0x2b10a8={'aGEjw':_0x2d55('0x375'),'ZmTfU':_0x2d55('0x5d')};this['title']=_0x2b10a8[_0x2d55('0x689')],this[_0x2d55('0x1a')]=_0x2b10a8[_0x2d55('0x889')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x520504);},'itemClick':function(){var _0x40629a={'TwoNh':_0x2d55('0x7ca')};var _0x1d484a=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x1d484a,_0x40629a[_0x2d55('0x16')])?handleClass['removeClass'](_0x1d484a,_0x40629a['TwoNh']):handleClass[_0x2d55('0x53c')](_0x1d484a,_0x40629a['TwoNh']),this[_0x2d55('0x4f3')]['map']['options']['itemnav']=!this['options']['map'][_0x2d55('0x4f3')]['itemnav'],this[_0x2d55('0x4f3')][_0x2d55('0x566')][_0x2d55('0x74c')]['itemClick'](),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['sf'][_0x2d55('0x1b7')]();},'CLASS_NAME':_0x2d55('0x4ca')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x795')]=BDLayers['Class'](BDLayers['Lib'][_0x2d55('0x50b')]['TBItem'],{'mapInitialState':null,'initialize':function(_0x879c8a,_0xb6957f){var _0x4f9392={'RpFBX':_0x2d55('0x4bd'),'LIgvf':'toolbar-cszt'};this[_0x2d55('0x5fe')]=_0x4f9392[_0x2d55('0x6fa')],this[_0x2d55('0x1a')]=_0x4f9392[_0x2d55('0x5f4')],BDLayers[_0x2d55('0x84f')]['setOptions'](this,_0xb6957f),mapInitialState={'bearing':_0xb6957f[_0x2d55('0x700')][_0x2d55('0x558')][0x0]['bearing'],'pitch':_0xb6957f[_0x2d55('0x700')]['_viewHistory'][0x0][_0x2d55('0xc3')],'center':[_0xb6957f[_0x2d55('0x700')][_0x2d55('0x3dc')]['x'],_0xb6957f['map'][_0x2d55('0x3dc')]['y']],'zoom':_0xb6957f[_0x2d55('0x700')][_0x2d55('0x2e')]};},'itemClick':function(){var _0x1fee52={'yMFoY':_0x2d55('0x737'),'QlMxE':_0x2d55('0x7ca'),'KbrQa':_0x2d55('0x8a')};var _0x4baf99;this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0xe8')](mapInitialState[_0x2d55('0xc3')]),this['options'][_0x2d55('0x700')][_0x2d55('0x86a')](mapInitialState['bearing']),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['setCenter'](mapInitialState[_0x2d55('0x2ce')]),this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x2e5')](mapInitialState['zoom']),handleClass[_0x2d55('0xb9')](document[_0x2d55('0x4e8')](_0x1fee52['yMFoY'])[0x0],_0x1fee52[_0x2d55('0x6')])&&(_0x4baf99=document['getElementsByClassName'](_0x1fee52[_0x2d55('0x223')]))&&_0x4baf99[0x0]&&(_0x4baf99[0x0][_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x2d55('0x1fd')+mapInitialState[_0x2d55('0xc3')]+_0x2d55('0x1d5')+mapInitialState[_0x2d55('0x50d')]+'deg)');},'CLASS_NAME':_0x2d55('0x674')}),BDLayers['Lib'][_0x2d55('0x50b')]['TBItemMapPrint']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'mapInitialState':null,'initialize':function(_0x473fb3,_0x551f22){var _0x304843={'EGavn':_0x2d55('0x30f'),'kWRtH':_0x2d55('0x44'),'fLYkb':_0x2d55('0x14f')};this['title']=_0x304843['EGavn'],this[_0x2d55('0x1a')]=_0x304843['kWRtH'],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x551f22),this[_0x2d55('0x69b')]||(this['mapTool']=new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x21b'))]({'position':{'bottom':_0x304843['fLYkb'],'right':'0'},'draggable':!0x0,'custom':!0x0,'content':_0x2d55('0x522')}));},'itemClick':function(){var _0x54aec7={'TRplt':'_blank','TGVUy':function(_0x3d6975,_0x4c0171){return _0x3d6975(_0x4c0171);},'iySTe':_0x2d55('0x23b')};options[_0x2d55('0x6b9')]?window['open'](options['mapPrintUrl'],_0x54aec7[_0x2d55('0x542')]):_0x54aec7['TGVUy'](alert,_0x54aec7[_0x2d55('0x38c')]);},'CLASS_NAME':_0x2d55('0x83')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x374')]=BDLayers['Class'](BDLayers['Lib'][_0x2d55('0x50b')][_0x2d55('0x753')],{'mapInitialState':null,'mapSetInterval':null,'initialize':function(_0x54528f,_0x34faf2){var _0x3ee9c3={'dZqgi':_0x2d55('0x437'),'dkZHM':_0x2d55('0x5ee')};this[_0x2d55('0x5fe')]=_0x3ee9c3[_0x2d55('0x31')],this['class']=_0x3ee9c3[_0x2d55('0x665')],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x34faf2);},'itemClick':function(){var _0x4525e9={'JljgN':_0x2d55('0x4c7'),'REguU':'active','FzfnU':_0x2d55('0x7bb'),'RApVh':function(_0x5edd15,_0x13439c,_0x388487){return _0x5edd15(_0x13439c,_0x388487);},'vAjgs':function(_0x54ddde,_0x3432d6){return _0x54ddde(_0x3432d6);}};var _0x42444e=window[_0x2d55('0x6b')]['srcElement'],_0x381a94=bdmap['compWrapper']()['getCompConfig']()[_0x2d55('0x548')];handleClass['hasClass'](_0x42444e,_0x4525e9['REguU'])?handleClass[_0x2d55('0x2df')](_0x42444e,_0x4525e9['REguU']):handleClass[_0x2d55('0x53c')](_0x42444e,_0x4525e9[_0x2d55('0x1af')]),handleClass[_0x2d55('0xb9')](_0x42444e,_0x4525e9[_0x2d55('0x1af')])?(bdmap[_0x2d55('0x784')]['trafficSituation'][_0x2d55('0x64d')](_0x381a94[_0x2d55('0x456')],{'map':this[_0x2d55('0x4f3')][_0x2d55('0x700')],'layers':this[_0x2d55('0x4f3')]['layers']},_0x4525e9[_0x2d55('0x662')]),bdmap[_0x2d55('0x784')][_0x2d55('0x334')]['loadStateLW'](_0x381a94[_0x2d55('0x3a8')],_0x381a94[_0x2d55('0x61c')],{'map':this[_0x2d55('0x4f3')][_0x2d55('0x700')],'layers':this['options']['layers']},'jtts_traffic_bdmap'),mapSetInterval=_0x4525e9[_0x2d55('0x3b0')](setInterval,()=>{bdmap['comp']['trafficSituation']['removeStateLW']({'map':this[_0x2d55('0x4f3')][_0x2d55('0x700')],'layers':this[_0x2d55('0x4f3')][_0x2d55('0x5df')]},_0x4525e9[_0x2d55('0x285')]),bdmap[_0x2d55('0x784')][_0x2d55('0x334')][_0x2d55('0x39d')](_0x381a94['url'],_0x381a94[_0x2d55('0x61c')],{'map':this[_0x2d55('0x4f3')]['map'],'layers':this[_0x2d55('0x4f3')][_0x2d55('0x5df')]},_0x4525e9[_0x2d55('0x285')]);},0xea60)):(_0x4525e9[_0x2d55('0x5a3')](clearInterval,mapSetInterval),bdmap['comp'][_0x2d55('0x334')][_0x2d55('0xbc')]({'map':this[_0x2d55('0x4f3')][_0x2d55('0x700')],'layers':this[_0x2d55('0x4f3')][_0x2d55('0x5df')]},_0x4525e9['FzfnU']),bdmap['comp'][_0x2d55('0x334')]['removeStateLW']({'map':this[_0x2d55('0x4f3')]['map'],'layers':this[_0x2d55('0x4f3')][_0x2d55('0x5df')]},_0x4525e9[_0x2d55('0x285')]));},'CLASS_NAME':_0x2d55('0x2fe')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItemPickPoint']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'infoWindow':null,'initialize':function(_0x5a56bc,_0x2b56bc){var _0x223b87={'vkmnq':_0x2d55('0x304')};this[_0x2d55('0x5fe')]=_0x223b87['vkmnq'],this[_0x2d55('0x1a')]=_0x2d55('0x17b'),BDLayers['Util'][_0x2d55('0x222')](this,_0x2b56bc);},'itemClick':function(){var _0x54a392={'XOguW':_0x2d55('0x17b'),'QbkBf':_0x2d55('0x7ca'),'SxkwG':function(_0x3cdaed,_0x3d1e59){return _0x3cdaed*_0x3d1e59;},'anGbp':function(_0x3a8a55,_0xe7e69c){return _0x3a8a55%_0xe7e69c;},'UdpLo':function(_0x426b90,_0x4cfce8){return _0x426b90*_0x4cfce8;},'AwCPI':function(_0x2f0e2e,_0x2bc768){return _0x2f0e2e%_0x2bc768;},'mrKqB':function(_0x573a1b,_0xfdf4cd){return _0x573a1b%_0xfdf4cd;},'jjMht':_0x2d55('0x81')};const _0x53779d=window['event'][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x53779d,_0x54a392['QbkBf'])?handleClass['removeClass'](_0x53779d,_0x54a392[_0x2d55('0x419')]):handleClass[_0x2d55('0x53c')](_0x53779d,_0x54a392[_0x2d55('0x419')]),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['on'](_0x54a392['jjMht'],_0x4c8659=>{var _0x54fdd4,_0x11bf47,_0x4d41b9,_0x4ffac2,_0x55a1a7,_0x4e8ceb;this[_0x2d55('0x514')]&&this[_0x2d55('0x514')]['remove'](),_0x53779d[_0x2d55('0x56c')][_0x2d55('0x202')](_0x54a392[_0x2d55('0x479')])&&handleClass['hasClass'](_0x53779d,_0x54a392[_0x2d55('0x419')])?(_0x4e8ceb=~~_0x4c8659[_0x2d55('0x203')]['x'],_0x54fdd4=~~_0x54a392[_0x2d55('0x265')](_0x54a392[_0x2d55('0x4a7')](_0x4c8659[_0x2d55('0x203')]['x'],0x1),0x3c),_0x11bf47=~~_0x54a392[_0x2d55('0x265')](_0x54a392[_0x2d55('0x265')](_0x54a392[_0x2d55('0x4a7')](_0x4c8659[_0x2d55('0x203')]['x'],0x1),0x3c)%0x1,0x3c),_0x4d41b9=~~_0x4c8659['coordinate']['y'],_0x4ffac2=~~_0x54a392[_0x2d55('0x822')](_0x54a392['AwCPI'](_0x4c8659[_0x2d55('0x203')]['y'],0x1),0x3c),_0x55a1a7=~~_0x54a392[_0x2d55('0x822')](_0x54a392[_0x2d55('0x363')](_0x54a392[_0x2d55('0x822')](_0x4c8659[_0x2d55('0x203')]['y']%0x1,0x3c),0x1),0x3c),_0x4e8ceb={'single':!0x0,'width':0x12c,'height':0x69,'custom':!0x1,'dx':-0x3,'dy':-0xc,'content':_0x2d55('0x1c9')+_0x4c8659['coordinate']['x']+',\x20'+_0x4c8659[_0x2d55('0x203')]['y']+_0x2d55('0x86e')+_0x4e8ceb+'°'+Math[_0x2d55('0x4e9')](_0x54fdd4)+'′'+Math[_0x2d55('0x4e9')](_0x11bf47)+_0x2d55('0xf9')+_0x4d41b9+'°'+Math['abs'](_0x4ffac2)+'′'+Math['abs'](_0x55a1a7)+'″'},this[_0x2d55('0x514')]=new maptalks['ui'][(_0x2d55('0x728'))](_0x4e8ceb),this['infoWindow'][_0x2d55('0x6ce')](this[_0x2d55('0x4f3')][_0x2d55('0x700')])[_0x2d55('0x6a0')](_0x4c8659['coordinate'])):this[_0x2d55('0x514')]&&this[_0x2d55('0x514')]['remove']();});},'CLASS_NAME':'BDLayers.Lib.Control.TBItemPickPoint'}),BDLayers['Lib'][_0x2d55('0x50b')][_0x2d55('0x40f')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItem'],{'initialize':function(_0x120e23,_0x9a3c1b){var _0x297a9c={'mdsMr':'top-right'};this[_0x2d55('0x5fe')]='定位',this[_0x2d55('0x1a')]=_0x2d55('0x7cb'),BDLayers['Util'][_0x2d55('0x222')](this,_0x9a3c1b),this[_0x2d55('0x69b')]||(this[_0x2d55('0x69b')]=new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x21b'))]({'position':_0x297a9c['mdsMr'],'draggable':!0x0,'custom':!0x0,'content':_0x2d55('0x3af')}));},'itemClick':function(){var _0xbde249={'EvVxn':_0x2d55('0x85e'),'gEkUR':_0x2d55('0x6bc'),'zSPfU':'data-initialValue','TrCAo':_0x2d55('0x7c5'),'ULKjC':function(_0x51a4d8,_0x20a63a){return _0x51a4d8!==_0x20a63a;},'afaLh':_0x2d55('0x2ee'),'TWcQV':_0x2d55('0xa9'),'tavnY':'fvalue_lat','UghyU':'mvalue_lat','MXWDS':function(_0x12e5b8,_0x481726,_0x1fdbee,_0x5ab84d){return _0x12e5b8(_0x481726,_0x1fdbee,_0x5ab84d);},'OLtAE':_0x2d55('0x58f'),'tImAu':_0x2d55('0x13f'),'YySEx':_0x2d55('0x463'),'VtdVt':function(_0x198810,_0xee5465){return _0x198810!==_0xee5465;},'sOmzV':_0x2d55('0x35c'),'iKOHp':'dvalue_lng','oUUFk':'mvalue_lng','UblVq':function(_0x24554a,_0x47e055){return _0x24554a(_0x47e055);},'pnfau':function(_0x4bf08b,_0x438a81){return _0x4bf08b(_0x438a81);},'naRBI':'positionTip','MKZBM':_0x2d55('0x7e5'),'NpkPj':_0x2d55('0x61e'),'XnOiz':function(_0x1e5e5c,_0x43b06e){return _0x1e5e5c(_0x43b06e);},'uOjno':_0x2d55('0x7b2'),'ZJhlU':_0x2d55('0x81'),'QVelc':function(_0x278c89,_0x289c7f){return _0x278c89!==_0x289c7f;},'splnN':_0x2d55('0x26d'),'jsdTL':_0x2d55('0x127'),'nYTiD':_0x2d55('0x7d0'),'xxUCq':'containerlat','fzceF':_0x2d55('0x2ba'),'ZcfES':function(_0x520b53,_0x10f5cc){return _0x520b53+_0x10f5cc;},'TmQEN':function(_0x3d5b64,_0x3b0a00){return _0x3d5b64/_0x3b0a00;},'MgdGn':function(_0x3b106a,_0x500746){return _0x3b106a(_0x500746);},'dcHSz':_0x2d55('0x7ca'),'QhTNu':'\x20active','fOGrh':function(_0x833072,_0x292c55,_0x22bd8b){return _0x833072(_0x292c55,_0x22bd8b);},'CIdNM':'.position-content\x20input','mCTaC':_0x2d55('0x506'),'dZFpx':_0x2d55('0x2a0'),'wPJYS':function(_0xdcae6c,_0x2785fb,_0x4dd8f5,_0x58537e){return _0xdcae6c(_0x2785fb,_0x4dd8f5,_0x58537e);},'TOLwk':_0x2d55('0x7ac')};var _0x18d355=window[_0x2d55('0x6b')][_0x2d55('0x459')],_0x20e26a=this['options'][_0x2d55('0x700')],_0x12d0af=(handleClass['hasClass'](_0x18d355,_0xbde249[_0x2d55('0x750')])?handleClass[_0x2d55('0x2df')](_0x18d355,_0x2d55('0x7ca')):handleClass[_0x2d55('0x53c')](_0x18d355,_0xbde249['QhTNu']),_0x20e26a[_0x2d55('0x150')](_0xbde249[_0x2d55('0x628')]),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')]['targetDiv']+_0x2d55('0x704')),_0x2d55('0x7ca')),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x377')),_0xbde249[_0x2d55('0x750')]),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this['options'][_0x2d55('0x185')]+_0x2d55('0x4f4')),_0x2d55('0x7ca')),this[_0x2d55('0x4f3')]['controlList']['cj'][_0x2d55('0x69b')][_0x2d55('0x49b')](),this['options']['controlList']['cmj'][_0x2d55('0x69b')][_0x2d55('0x49b')](),document[_0x2d55('0x110')](_0xbde249[_0x2d55('0x666')])[_0x2d55('0x3a7')][_0x2d55('0x69c')]='0',_0xbde249[_0x2d55('0x876')](setTimeout,function(){document[_0x2d55('0x110')](_0xbde249[_0x2d55('0x666')])[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0xbde249[_0x2d55('0x799')];},0xfa),this[_0x2d55('0x69b')]['isVisible']()?this[_0x2d55('0x69b')][_0x2d55('0x45d')]():(this[_0x2d55('0x69b')]['show'](),document[_0x2d55('0x4d5')](_0xbde249[_0x2d55('0x42a')])[_0x2d55('0x457')](_0x40cdf8=>{_0x40cdf8['value']=_0x40cdf8[_0x2d55('0x2ed')](_0xbde249[_0x2d55('0x180')]);}),document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x112')])[_0x2d55('0x884')]='',document[_0x2d55('0x4ed')](_0x2d55('0x35c'))['style'][_0x2d55('0x3fe')]='block',document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x24f')])['style'][_0x2d55('0x3fe')]=_0xbde249['gEkUR'],document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x27b')])[_0x2d55('0x3a7')]['display']=_0xbde249[_0x2d55('0xe5')],document['getElementById']('containerlat')[_0x2d55('0x3a7')][_0x2d55('0x3fe')]='none'),_0xbde249['MXWDS'](_0x3a84bc,document[_0x2d55('0x4ed')](_0x2d55('0x1c2')),_0x58c928,!0x0),_0x3a84bc(document[_0x2d55('0x4ed')](_0xbde249['mCTaC']),_0x58c928,!0x1),_0xbde249[_0x2d55('0x762')](_0x3a84bc,document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x11a')]),function(_0x44f3da){var _0x52a8f7=_0xbde249[_0x2d55('0x25d')][_0x2d55('0x77c')]('|');var _0x1a4704=0x0;while(!![]){switch(_0x52a8f7[_0x1a4704++]){case'0':{var _0x444852,_0x5b8e0c,_0x8ede94;_0x8ede94=_0xbde249[_0x2d55('0x29f')](_0xbde249[_0x2d55('0x799')],document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x27b')])['style']['display'])?document[_0x2d55('0x4ed')](_0xbde249['afaLh'])['value']:(_0x444852=document['getElementById'](_0xbde249['TWcQV'])['value'],_0x5b8e0c=document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x19e')])[_0x2d55('0x2c')],_0x8ede94=document['getElementById'](_0xbde249['UghyU'])['value'],_0xbde249['MXWDS'](_0x5e7228,_0x444852,_0x5b8e0c,_0x8ede94));}continue;case'1':var _0x36ef2f=new maptalks[(_0x2d55('0x28c'))]([_0x12dcaf,_0x8ede94],{'id':_0xbde249[_0x2d55('0x2a5')],'symbol':{'markerFile':_0xbde249[_0x2d55('0x5ae')],'markerWidth':0x14,'markerHeight':0x1b}});continue;case'2':{var _0x12dcaf;_0x44f3da[_0x2d55('0x150')](_0xbde249[_0x2d55('0x628')]),_0x12dcaf=_0xbde249['VtdVt'](_0xbde249[_0x2d55('0x799')],document['getElementById'](_0xbde249[_0x2d55('0x10')])[_0x2d55('0x3a7')]['display'])?document[_0x2d55('0x4ed')]('inputlng')['value']:(_0x12dcaf=document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x597')])[_0x2d55('0x2c')],_0x444852=document[_0x2d55('0x4ed')](_0x2d55('0x2e9'))[_0x2d55('0x2c')],_0x5b8e0c=document['getElementById'](_0xbde249[_0x2d55('0x66f')])[_0x2d55('0x2c')],_0xbde249['MXWDS'](_0x5e7228,_0x12dcaf,_0x444852,_0x5b8e0c));}continue;case'3':if(!_0xbde249[_0x2d55('0x660')](_0x460d50,_0x12dcaf)||!_0xbde249[_0x2d55('0x660')](_0x460d50,_0x8ede94))return _0xbde249[_0x2d55('0x13e')](_0x460d50,_0x12dcaf)?document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x112')])[_0x2d55('0x884')]=_0xbde249[_0x2d55('0x696')]:document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x112')])[_0x2d55('0x884')]=_0xbde249[_0x2d55('0x44b')];continue;case'4':new maptalks[(_0x2d55('0x221'))](_0xbde249[_0x2d55('0x628')],_0x36ef2f)[_0x2d55('0x6ce')](_0x44f3da),_0x44f3da['panTo']([_0x12dcaf,_0x8ede94]);continue;}break;}},_0x20e26a),this[_0x2d55('0x69b')]);function _0x3a84bc(_0x32ba89,_0x2fbd2e,_0x480423){var _0xc0b7d4={'obsBH':function(_0x1bfc73,_0x180968){return _0xbde249[_0x2d55('0x2b7')](_0x1bfc73,_0x180968);}};_0x32ba89[_0x2d55('0x2ed')](_0x2d55('0x7b2'))||(_0x32ba89[_0x2d55('0x604')](_0xbde249[_0x2d55('0x809')],0x1),_0x32ba89['addEventListener'](_0xbde249[_0x2d55('0x2b9')],function(){Array[_0x2d55('0x26a')](_0x480423)?_0xc0b7d4[_0x2d55('0x43f')](_0x2fbd2e,..._0x480423):_0xc0b7d4[_0x2d55('0x43f')](_0x2fbd2e,_0x480423);}));}function _0x58c928(_0x47456e){_0x47456e?(_0xbde249['QVelc'](_0xbde249[_0x2d55('0x799')],document['getElementById'](_0xbde249['sOmzV'])['style'][_0x2d55('0x3fe')])?(document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x10')])[_0x2d55('0x3a7')]['display']='none',document['getElementById'](_0xbde249[_0x2d55('0x24f')])['style'][_0x2d55('0x3fe')]=_0xbde249['jsdTL']):(document['getElementById'](_0xbde249[_0x2d55('0x10')])[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0xbde249[_0x2d55('0xe5')],document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x24f')])[_0x2d55('0x3a7')]['display']=_0x2d55('0x6bc')),document['querySelectorAll'](_0xbde249[_0x2d55('0x617')])[_0x2d55('0x457')](_0x530610=>{_0x530610[_0x2d55('0x2c')]=_0x530610['getAttribute']('data-initialValue');})):(_0x2d55('0x6bc')!==document[_0x2d55('0x4ed')](_0x2d55('0x2ee'))['style'][_0x2d55('0x3fe')]?(document['getElementById']('inputlat')[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0xbde249[_0x2d55('0x799')],document[_0x2d55('0x4ed')]('containerlat')['style'][_0x2d55('0x3fe')]=_0x2d55('0x127')):(document[_0x2d55('0x4ed')](_0xbde249[_0x2d55('0x27b')])[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0xbde249['jsdTL'],document[_0x2d55('0x4ed')](_0xbde249['xxUCq'])[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x2d55('0x6bc')),document[_0x2d55('0x4d5')](_0xbde249[_0x2d55('0x5f6')])['forEach'](_0x43eb2c=>{_0x43eb2c[_0x2d55('0x2c')]=_0x43eb2c[_0x2d55('0x2ed')](_0xbde249[_0x2d55('0x180')]);}));}function _0x5e7228(_0x55dc5e,_0xa9d992,_0xd3af78){_0xa9d992=_0xbde249[_0x2d55('0x2b1')](parseFloat(_0xa9d992),_0xbde249['XnOiz'](parseFloat,_0xd3af78/0x3c));return parseFloat(_0xbde249[_0x2d55('0xe9')](_0xa9d992,0x3c))+_0xbde249[_0x2d55('0x4cc')](parseFloat,_0x55dc5e);}function _0x460d50(_0x5c530e){return!!/^(\-|\+)?(((\d|[1-9]\d|1[0-7]\d|0{1,3})\.\d{0,6})|(\d|[1-9]\d|1[0-7]\d|0{1,3})|180\.0{0,6}|180)$/['test'](_0x5c530e);}_0xbde249[_0x2d55('0x829')](_0x3a84bc,document['getElementById'](_0xbde249[_0x2d55('0x205')]),function(_0x3a0811,_0x3824b7,_0x17dc44){handleClass[_0x2d55('0x2df')](_0x3a0811,_0xbde249['dcHSz']),_0x3824b7[_0x2d55('0x150')](_0xbde249[_0x2d55('0x628')]),_0x17dc44[_0x2d55('0x45d')]();},[_0x18d355,_0x20e26a,_0x12d0af]),document[_0x2d55('0x4d5')](_0xbde249[_0x2d55('0x42a')])['forEach'](_0x24b4ea=>{_0x24b4ea[_0x2d55('0x4e5')]=function(){_0x24b4ea[_0x2d55('0x2c')]='';},_0x24b4ea[_0x2d55('0x3e1')]=function(){_0x24b4ea['value']&&_0x24b4ea[_0x2d55('0x2c')][_0x2d55('0x7dd')]()||(_0x24b4ea['value']=_0x24b4ea['getAttribute'](_0xbde249[_0x2d55('0x180')]));};});},'CLASS_NAME':'BDLayers.Lib.Control.TBItemPosition'}),BDLayers[_0x2d55('0x47b')]['Control']['TBItemDraw']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'initialize':function(_0x2b2fba,_0x29f8d9){var _0x1a02b7={'cayaa':function(_0x3004e3,_0x1df0d6){return _0x3004e3!=_0x1df0d6;},'sXLtw':'DrawBoxactive','BysbX':function(_0x31028b,_0x1da013){return _0x31028b+_0x1da013;},'qvNaU':function(_0x236cd6,_0x4a7dc1){return _0x236cd6+_0x4a7dc1;},'YRahq':function(_0x2f254d,_0x3ed299){return _0x2f254d+_0x3ed299;},'ikkns':function(_0x33b9c0,_0x52199f,_0x5cf713){return _0x33b9c0(_0x52199f,_0x5cf713);},'bdwkc':function(_0x6f4db3,_0x536267){return _0x6f4db3+_0x536267;},'gfphm':_0x2d55('0x85e'),'rVYSN':_0x2d55('0x6f8'),'oMFVw':function(_0x14eb35,_0x3c1802,_0x1d4297){return _0x14eb35(_0x3c1802,_0x1d4297);},'gARRx':'#41a6ec\x20','vizVU':_0x2d55('0x251'),'HNSxN':_0x2d55('0x476'),'RpVRG':_0x2d55('0x78c'),'dEcrf':_0x2d55('0x227'),'YAxId':_0x2d55('0x81'),'PFGCN':_0x2d55('0x38d'),'kvaxq':_0x2d55('0xc2'),'XnaRo':_0x2d55('0x4c'),'mxzIi':_0x2d55('0xfd'),'kxSJt':_0x2d55('0x292'),'PkASa':_0x2d55('0x325'),'kKXvW':_0x2d55('0x5d5'),'gGTEh':function(_0x1b3336,_0x1e2332,_0x5ef751){return _0x1b3336(_0x1e2332,_0x5ef751);},'sWVVb':function(_0x35aaab,_0x2feb52,_0x538dea){return _0x35aaab(_0x2feb52,_0x538dea);},'RInSu':'.closeDrawimg','AEhKZ':function(_0x2d0f2c,_0x1e3112,_0x5971a9){return _0x2d0f2c(_0x1e3112,_0x5971a9);},'LsHKE':'.DrawLineString','XzOWu':function(_0xc4f0dd,_0x2dc08b,_0x4f0f40){return _0xc4f0dd(_0x2dc08b,_0x4f0f40);},'qkZUi':_0x2d55('0x513'),'GgtAs':function(_0xb8a0c,_0x5b65e0,_0x2b7466){return _0xb8a0c(_0x5b65e0,_0x2b7466);},'VMQgd':_0x2d55('0x6d'),'tezNE':'.DrawCircle','FVPVh':function(_0x3304de,_0x35c3d0,_0x2f2363){return _0x3304de(_0x35c3d0,_0x2f2363);},'omtHm':'.DrawFreeHandLineString'};BDLayers[_0x2d55('0x84f')]['extend'](this,{'handlers':{},'_triggeringCount':0x0});let _0x5ebe32=this;this[_0x2d55('0x5fe')]='绘制',this[_0x2d55('0x1a')]='toolbar-hz',BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x29f8d9),this[_0x2d55('0x69b')]||(this['mapTool']=new maptalks['DrawTool']({'mode':_0x1a02b7[_0x2d55('0x59')]}),setTimeout(()=>{var _0x85f72a={'IStHv':_0x1a02b7[_0x2d55('0x335')],'PwQfu':function(_0x456efa,_0x5ed1a9){return _0x1a02b7[_0x2d55('0x1c6')](_0x456efa,_0x5ed1a9);},'BuPhW':_0x1a02b7['gfphm'],'xnApW':_0x2d55('0x6bc'),'vUOmG':_0x1a02b7[_0x2d55('0x72e')],'ubVgx':_0x2d55('0x82a'),'wezaZ':_0x1a02b7[_0x2d55('0x1bd')],'DpokN':_0x1a02b7['kvaxq'],'sSaPM':_0x1a02b7[_0x2d55('0x59')],'ItxmM':_0x1a02b7[_0x2d55('0x14')],'sADjc':_0x1a02b7[_0x2d55('0x405')],'CRjHJ':_0x1a02b7[_0x2d55('0x6d2')]};function _0x458ddd(_0x4966ee,_0x578027){document['querySelector'](_0x4966ee)[_0x2d55('0x199')](_0x85f72a['IStHv'],_0x578027);}function _0xe50c00(_0x1990c3,_0x1c1344){var _0x2dd9db=(_0x2dd9db=_0x85f72a[_0x2d55('0x368')](_0x85f72a[_0x2d55('0x368')]('\x20',_0x1990c3[_0x2d55('0x56c')]),'\x20'))[_0x2d55('0x7eb')](/(\s+)/gi,'\x20');removed=(removed=_0x2dd9db['replace'](_0x85f72a[_0x2d55('0x368')](_0x85f72a[_0x2d55('0x368')]('\x20',_0x1c1344),'\x20'),'\x20'))[_0x2d55('0x7eb')](/(^\s+)|(\s+$)/g,''),_0x1990c3[_0x2d55('0x56c')]=removed;}document[_0x2d55('0x110')](_0x1a02b7[_0x2d55('0x2de')])['parentNode'][_0x2d55('0x89a')][_0x2d55('0x1ce')]('beforeEnd','\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20id=\x27DrawPop\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawTitle\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawPopIcon\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<span>绘制面板</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27closeDrawimg\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27apptitle\x27>==</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawContent\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawPadding\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20点\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27点\x27\x20class=\x27DrawPoint\x20DrawDiv\x27><div></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20线\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27线\x27\x20class=\x27DrawLineString\x20DrawDiv\x27><div></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20多边形\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27多边形\x27\x20class=\x27DrawPolygon\x20DrawDiv\x27><div></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20矩形\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27矩形\x27\x20class=\x27DrawRectangle\x20DrawDiv\x27><div></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20圆形\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27圆形\x27\x20class=\x27DrawCircle\x20DrawDiv\x27><div></div></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20弧线\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27弧线\x27\x20class=\x27DrawCubicBezierCurve\x20DrawDiv\x27><div></div></div>\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<!--\x20手绘\x20-->\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20title=\x27手绘\x27\x20class=\x27DrawFreeHandLineString\x20DrawDiv\x27><div></div></div>\x20\x20\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x27DrawBox\x27></div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20');for(const _0x2f34b4 of document[_0x2d55('0x4e8')](_0x1a02b7[_0x2d55('0x827')]))_0x2f34b4['onclick']=function(_0x227151){if(_0x41efcd=_0x2f34b4,_0x1a02b7['cayaa'](0x0,(_0x127ed4=(_0x127ed4=_0x1a02b7['sXLtw'])||'')[_0x2d55('0x7eb')](/\s/g,'')['length'])&&new RegExp(_0x1a02b7[_0x2d55('0x3c0')](_0x1a02b7[_0x2d55('0x42')]('\x20',_0x127ed4),'\x20'))[_0x2d55('0x494')](_0x1a02b7[_0x2d55('0x3ce')](_0x1a02b7[_0x2d55('0x3ce')]('\x20',_0x41efcd['className']),'\x20')))_0xe50c00(_0x2f34b4,_0x1a02b7[_0x2d55('0x586')]),_0x1a02b7[_0x2d55('0x117')](setTimeout,function(){_0x5ebe32[_0x2d55('0x69b')]['disable']();},0xa);else{for(const _0x54a132 of document[_0x2d55('0x4e8')](_0x2d55('0x5d5')))_0x1a02b7['ikkns'](_0xe50c00,_0x54a132,_0x2d55('0xc8'));_0x127ed4=_0x2f34b4,_0x41efcd=_0x1a02b7[_0x2d55('0x586')],_0x150988=_0x127ed4[_0x2d55('0x56c')],added=_0x1a02b7['bdwkc'](_0x150988,''!=_0x150988?'\x20':'')+_0x41efcd,_0x127ed4[_0x2d55('0x56c')]=added;}var _0x150988,_0x41efcd,_0x127ed4;};_0x1a02b7['gGTEh'](_0x458ddd,_0x2d55('0x500'),function(_0x50289c){document[_0x2d55('0x110')](_0x1a02b7[_0x2d55('0x6dd')])[_0x2d55('0x3a7')][_0x2d55('0x69c')]='0',document['querySelector'](_0x1a02b7[_0x2d55('0x72e')])&&(document[_0x2d55('0x110')](_0x1a02b7['gfphm'])[_0x2d55('0x3a7')][_0x2d55('0x347')]='0'),_0x1a02b7[_0x2d55('0x752')](setTimeout,function(){document[_0x2d55('0x110')](_0x85f72a[_0x2d55('0x5ff')])[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x85f72a[_0x2d55('0x11e')];},0xfa);}),_0x1a02b7[_0x2d55('0x7d5')](_0x458ddd,_0x1a02b7['RInSu'],function(_0x48fc84){handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+'\x20.toolbar-hz'),_0x2d55('0x7ca')),document[_0x2d55('0x110')](_0x2d55('0x85e'))[_0x2d55('0x3a7')]['opacity']='0',document[_0x2d55('0x110')](_0x85f72a[_0x2d55('0x55a')])&&(document['querySelector'](_0x85f72a['BuPhW'])['style'][_0x2d55('0x347')]='0'),setTimeout(function(){document['querySelector']('#DrawPop')['style']['display']='none';},0xfa);}[_0x2d55('0x7cf')](this)),_0x1a02b7['sWVVb'](_0x458ddd,_0x2d55('0x426'),function(){_0x5ebe32['mapTool'][_0x2d55('0x60a')]({'markerType':_0x2d55('0x1da'),'markerFill':_0x85f72a['ubVgx'],'markerFillOpacity':{'property':_0x85f72a[_0x2d55('0x231')],'type':_0x85f72a[_0x2d55('0x627')]},'markerLineWidth':0x0,'markerLineOpacity':0x1,'markerWidth':0x28,'markerHeight':0x28}),_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x6f6')](_0x85f72a[_0x2d55('0x442')])[_0x2d55('0x1f8')]();}),_0x1a02b7[_0x2d55('0x536')](_0x458ddd,_0x1a02b7['LsHKE'],function(){_0x5ebe32['mapTool']['setSymbol']({'lineColor':_0x1a02b7[_0x2d55('0x14')]}),_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x6f6')](_0x1a02b7['vizVU'])[_0x2d55('0x1f8')]();}),_0x1a02b7[_0x2d55('0x6ad')](_0x458ddd,_0x1a02b7['qkZUi'],function(){_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x60a')]({'lineColor':_0x85f72a[_0x2d55('0x816')]}),_0x5ebe32[_0x2d55('0x69b')]['setMode'](_0x85f72a[_0x2d55('0x74d')])[_0x2d55('0x1f8')]();}),_0x1a02b7['GgtAs'](_0x458ddd,_0x1a02b7[_0x2d55('0x88e')],function(){_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x60a')]({'lineColor':_0x1a02b7[_0x2d55('0x14')]}),_0x5ebe32['mapTool'][_0x2d55('0x6f6')](_0x1a02b7[_0x2d55('0x775')])[_0x2d55('0x1f8')]();}),_0x458ddd(_0x1a02b7[_0x2d55('0x4c9')],function(){_0x5ebe32['mapTool'][_0x2d55('0x60a')]({'lineColor':_0x1a02b7[_0x2d55('0x14')]}),_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x6f6')](_0x1a02b7[_0x2d55('0x13')])[_0x2d55('0x1f8')]();}),_0x1a02b7[_0x2d55('0x1b2')](_0x458ddd,'.DrawCubicBezierCurve',function(){_0x5ebe32['mapTool'][_0x2d55('0x60a')]({'lineColor':_0x85f72a[_0x2d55('0x816')]}),_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x6f6')](_0x85f72a[_0x2d55('0x56f')])[_0x2d55('0x1f8')]();}),_0x1a02b7[_0x2d55('0x1b2')](_0x458ddd,_0x1a02b7[_0x2d55('0x831')],function(){_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x60a')]({'lineColor':_0x1a02b7[_0x2d55('0x14')]}),_0x5ebe32[_0x2d55('0x69b')][_0x2d55('0x6f6')](_0x1a02b7[_0x2d55('0x780')])[_0x2d55('0x1f8')]();});},0x14));},'itemClick':function(){var _0x2a83e6={'zbTrL':_0x2d55('0x6f8'),'pCYec':_0x2d55('0x85e'),'TpbPk':_0x2d55('0x89'),'zISPe':_0x2d55('0x6bc'),'VpLMW':'active','yEijZ':'position','hYlLJ':_0x2d55('0x127'),'jPZGG':function(_0x1b68e3,_0x58f4a1,_0x32799a){return _0x1b68e3(_0x58f4a1,_0x32799a);}};var _0x266f33=window['event'][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x266f33,_0x2a83e6[_0x2d55('0x45a')])?handleClass[_0x2d55('0x2df')](_0x266f33,_0x2a83e6[_0x2d55('0x45a')]):handleClass[_0x2d55('0x53c')](_0x266f33,_0x2a83e6['VpLMW']),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x704')),_0x2a83e6[_0x2d55('0x45a')]),handleClass[_0x2d55('0x2df')](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x377')),_0x2d55('0x7ca')),handleClass['removeClass'](document[_0x2d55('0x110')]('#'+this[_0x2d55('0x4f3')][_0x2d55('0x185')]+_0x2d55('0x210')),_0x2a83e6[_0x2d55('0x45a')]),this[_0x2d55('0x4f3')]['controlList']['cj'][_0x2d55('0x69b')][_0x2d55('0x49b')](),this[_0x2d55('0x4f3')]['controlList'][_0x2d55('0x1ac')][_0x2d55('0x69b')]['disable'](),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['dw']['mapTool'][_0x2d55('0x45d')](),this[_0x2d55('0x4f3')][_0x2d55('0x566')]['dw'][_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x150')](_0x2a83e6['yEijZ']);let _0x266006=document[_0x2d55('0x110')](_0x2a83e6[_0x2d55('0x45e')]);console[_0x2d55('0x10b')](_0x266006[_0x2d55('0x3a7')][_0x2d55('0x69c')]),'0'==_0x266006[_0x2d55('0x3a7')]['opacity']||''==_0x266006[_0x2d55('0x3a7')][_0x2d55('0x69c')]?(_0x266006[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x2a83e6[_0x2d55('0x35')],setTimeout(function(){_0x266006[_0x2d55('0x3a7')][_0x2d55('0x69c')]='1',document[_0x2d55('0x110')](_0x2a83e6['zbTrL'])&&(document[_0x2d55('0x110')](_0x2a83e6[_0x2d55('0x45e')])[_0x2d55('0x3a7')][_0x2d55('0x347')]=_0x2a83e6[_0x2d55('0x40c')]);},0xa)):(_0x266006[_0x2d55('0x3a7')][_0x2d55('0x69c')]='0',document[_0x2d55('0x110')](_0x2a83e6[_0x2d55('0x7a1')])&&(document[_0x2d55('0x110')](_0x2a83e6[_0x2d55('0x45e')])[_0x2d55('0x3a7')][_0x2d55('0x347')]='0'),_0x2a83e6['jPZGG'](setTimeout,function(){_0x266006[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x2a83e6[_0x2d55('0x621')];},0xfa));},'CLASS_NAME':_0x2d55('0x4ca')}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x85')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'initialize':function(_0x24e034,_0x34ab36){var _0x348c83={'tmHus':'清除绘制','lkLAb':_0x2d55('0x27f')};this[_0x2d55('0x5fe')]=_0x348c83[_0x2d55('0x33b')],this[_0x2d55('0x1a')]=_0x348c83['lkLAb'],BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x34ab36);},'itemClick':function(){var _0x3fa84e={'ATiYW':_0x2d55('0x5d5'),'bzyoj':'DrawBoxactive','MiDqY':function(_0x4420fe,_0xa2bcec){return _0x4420fe+_0xa2bcec;},'pBfgQ':function(_0x15c16d,_0x318304){return _0x15c16d+_0x318304;}};this[_0x2d55('0x4f3')][_0x2d55('0x559')][_0x2d55('0x69b')][_0x2d55('0x49b')](),this[_0x2d55('0x4f3')]['layer'][_0x2d55('0x7a5')]();for(const _0x5b5569 of document['getElementsByClassName'](_0x3fa84e[_0x2d55('0x2eb')]))_0x39b3fb=_0x5b5569,_0x3df071=_0x3fa84e[_0x2d55('0x485')],_0x4c53b3=void 0x0,_0x4c53b3=(_0x4c53b3=_0x3fa84e[_0x2d55('0x1b9')]('\x20',_0x39b3fb[_0x2d55('0x56c')])+'\x20')[_0x2d55('0x7eb')](/(\s+)/gi,'\x20'),removed=(removed=_0x4c53b3[_0x2d55('0x7eb')](_0x3fa84e[_0x2d55('0x1b9')](_0x3fa84e[_0x2d55('0x594')]('\x20',_0x3df071),'\x20'),'\x20'))[_0x2d55('0x7eb')](/(^\s+)|(\s+$)/g,''),_0x39b3fb['className']=removed;var _0x39b3fb,_0x3df071,_0x4c53b3;},'CLASS_NAME':'BDLayers.Lib.Control.TBItemZoom'}),BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x4a4')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x753')],{'isDisabled':!0x0,'initialize':function(_0x2d5ad1,_0x2d6ae9){var _0x4c9ec9={'ybwWm':function(_0x50deca,_0x58df32){return _0x50deca/_0x58df32;},'SVdUd':function(_0x2ca123,_0x5d8816){return _0x2ca123*_0x5d8816;},'uKjZu':function(_0x38a76c,_0x33dc8a){return _0x38a76c<_0x33dc8a;},'gOIKC':function(_0x38e26d,_0xdea34a){return _0x38e26d-_0xdea34a;},'VPUAI':function(_0x387961,_0x49b4da){return _0x387961<_0x49b4da;},'UtqOn':function(_0x2617a9,_0x4ef3d8){return _0x2617a9-_0x4ef3d8;},'SlbrT':function(_0x434d51,_0x3e4c28){return _0x434d51+_0x3e4c28;},'YXhuD':function(_0xa9cbe8,_0x17b118){return _0xa9cbe8*_0x17b118;},'FPbhd':function(_0x1fd56c,_0x2fb074){return _0x1fd56c*_0x2fb074;},'vMFTx':function(_0x1a49e7,_0x30fb41){return _0x1a49e7+_0x30fb41;},'Bddel':function(_0x6e3b27,_0x5f1814){return _0x6e3b27*_0x5f1814;},'uMvDb':function(_0x5c18fb,_0x1de4b4){return _0x5c18fb*_0x1de4b4;},'bbiTa':function(_0x1bb325,_0x1f71b0){return _0x1bb325+_0x1f71b0;},'oCDwe':function(_0x46d0bc,_0x24b09a){return _0x46d0bc+_0x24b09a;},'CYoDT':function(_0x335c18,_0xe60f46){return _0x335c18+_0xe60f46;},'KRyjW':'#bbb','kMwUp':function(_0x256aaa,_0x589554){return _0x256aaa+_0x589554;},'gHiWy':function(_0x553317,_0x248c48){return _0x553317*_0x248c48;},'KqYwL':_0x2d55('0x32b'),'BWYkF':function(_0x3aa8c3,_0xafe572){return _0x3aa8c3/_0xafe572;},'YLThz':function(_0x5b8e0e,_0x56ece2){return _0x5b8e0e*_0x56ece2;},'VGKEp':function(_0x341edd,_0x263036){return _0x341edd-_0x263036;},'kMsdZ':_0x2d55('0x631'),'aGfOl':_0x2d55('0x50c'),'QxCwK':'mouseout','QUbBd':_0x2d55('0x68e')};this['title']=_0x4c9ec9[_0x2d55('0x3b2')],this[_0x2d55('0x1a')]='toolbar-fdj',BDLayers[_0x2d55('0x84f')]['setOptions'](this,_0x2d6ae9);var _0x475638=null;this['options'][_0x2d55('0x700')]['on'](_0x4c9ec9['aGfOl'],function(_0x592062){this[_0x2d55('0x480')]||(_0x475638=_0x592062[_0x2d55('0x355')],this[_0x2d55('0x4f3')][_0x2d55('0x700')][_0x2d55('0x32e')]()['setToRedraw']());}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['on'](_0x4c9ec9['QxCwK'],function(){this[_0x2d55('0x480')]||(_0x475638=null,this['options'][_0x2d55('0x700')][_0x2d55('0x32e')]()[_0x2d55('0x192')]());}[_0x2d55('0x7cf')](this)),this[_0x2d55('0x4f3')][_0x2d55('0x700')]['on'](_0x4c9ec9[_0x2d55('0x1e9')],function(_0x28ecc2){if(!this[_0x2d55('0x480')]&&_0x475638){for(var _0x509548,_0x256a58,_0x28ecc2=_0x28ecc2[_0x2d55('0x135')],_0x102d56=0x96,_0x16611a=window['devicePixelRatio']||_0x4c9ec9[_0x2d55('0x2f0')](window[_0x2d55('0x725')][_0x2d55('0x461')],window[_0x2d55('0x725')][_0x2d55('0x296')]),_0x325963=_0x475638['x']*_0x16611a,_0x1c976e=_0x475638['y']*_0x16611a,_0x1293d8=_0x4c9ec9[_0x2d55('0x67d')](0x2,_0x102d56*=_0x4c9ec9[_0x2d55('0xf0')](0x1,_0x16611a)?0x2:0x1)+0x2,_0xc675ed=_0x28ecc2[_0x2d55('0x874')](_0x4c9ec9['gOIKC'](_0x325963,_0x102d56),_0x4c9ec9['gOIKC'](_0x1c976e,_0x102d56),_0x1293d8,_0x1293d8)[_0x2d55('0x10c')],_0x16611a=_0x28ecc2[_0x2d55('0x18b')](_0x1293d8,_0x1293d8),_0x112946=_0x16611a['data'],_0xcae9f6=0x0;_0x4c9ec9[_0x2d55('0x5b9')](_0xcae9f6,_0x1293d8);++_0xcae9f6)for(var _0x390375=0x0;_0x390375<_0x1293d8;++_0x390375){var _0x4b113a=_0x4c9ec9['UtqOn'](_0x390375,_0x102d56),_0x3fb53e=_0x4c9ec9[_0x2d55('0x2da')](_0xcae9f6,_0x102d56),_0x56e92a=_0x390375,_0x150666=_0xcae9f6,_0x4b113a=(_0x4c9ec9[_0x2d55('0x5b9')](Math[_0x2d55('0x843')](_0x4c9ec9[_0x2d55('0x1fb')](_0x4c9ec9[_0x2d55('0x67d')](_0x4b113a,_0x4b113a),_0x4c9ec9[_0x2d55('0x2b6')](_0x3fb53e,_0x3fb53e))),_0x102d56)&&(_0x56e92a=Math[_0x2d55('0x61')](_0x4c9ec9['SlbrT'](_0x102d56,_0x4c9ec9[_0x2d55('0x2f0')](_0x4b113a,0x2))),_0x150666=Math[_0x2d55('0x61')](_0x102d56+_0x4c9ec9[_0x2d55('0x2f0')](_0x3fb53e,0x2))),_0x4c9ec9['FPbhd'](0x4,_0x4c9ec9[_0x2d55('0x43b')](_0x4c9ec9[_0x2d55('0x26b')](_0xcae9f6,_0x1293d8),_0x390375))),_0x3fb53e=_0x4c9ec9[_0x2d55('0x39c')](0x4,_0x4c9ec9[_0x2d55('0x43b')](_0x4c9ec9[_0x2d55('0x39c')](_0x150666,_0x1293d8),_0x56e92a));_0x112946[_0x4b113a]=_0xc675ed[_0x3fb53e],_0x112946[_0x4c9ec9[_0x2d55('0x6c6')](0x1,_0x4b113a)]=_0xc675ed[_0x4c9ec9[_0x2d55('0x6c6')](0x1,_0x3fb53e)],_0x112946[_0x4c9ec9[_0x2d55('0x6c6')](0x2,_0x4b113a)]=_0xc675ed[_0x4c9ec9[_0x2d55('0x6c6')](0x2,_0x3fb53e)],_0x112946[_0x4c9ec9[_0x2d55('0x691')](0x3,_0x4b113a)]=_0xc675ed[_0x4c9ec9[_0x2d55('0x429')](0x3,_0x3fb53e)];}_0x28ecc2['beginPath'](),_0x28ecc2[_0x2d55('0x441')]=_0x4c9ec9[_0x2d55('0x5ec')],_0x28ecc2[_0x2d55('0x191')]=0x2,_0x28ecc2['arc'](_0x325963,_0x1c976e,_0x4c9ec9['kMwUp'](0x2,_0x102d56),0x0,_0x4c9ec9[_0x2d55('0x69d')](0x2,Math['PI'])),_0x28ecc2[_0x2d55('0x216')](),_0x28ecc2['closePath'](),_0x28ecc2[_0x2d55('0x477')]((_0x28ecc2=_0x16611a,_0x16611a=_0x1293d8,_0x509548=document['createElement']('canvas'),_0x256a58=document[_0x2d55('0x5b6')](_0x4c9ec9[_0x2d55('0x576')]),_0x509548[_0x2d55('0x4f6')]=_0x509548[_0x2d55('0x347')]=_0x256a58['width']=_0x256a58[_0x2d55('0x347')]=_0x16611a,_0x509548['getContext']('2d')[_0x2d55('0x440')](_0x28ecc2,0x0,0x0),(_0x28ecc2=_0x256a58[_0x2d55('0xd7')]('2d'))[_0x2d55('0x556')](),_0x28ecc2[_0x2d55('0x3b8')](_0x4c9ec9[_0x2d55('0x7e7')](_0x16611a,0x2),_0x4c9ec9['BWYkF'](_0x16611a,0x2),_0x4c9ec9['BWYkF'](_0x16611a,0x2),0x0,_0x4c9ec9[_0x2d55('0xdc')](0x2,Math['PI'])),_0x28ecc2[_0x2d55('0x1c5')](),_0x28ecc2[_0x2d55('0x477')](_0x509548,0x0,0x0),_0x256a58),_0x4c9ec9['VGKEp'](_0x325963,_0x4c9ec9[_0x2d55('0x7e7')](_0x1293d8,0x2)),_0x4c9ec9[_0x2d55('0x3c3')](_0x1c976e,_0x1293d8/0x2));}}[_0x2d55('0x7cf')](this));},'itemClick':function(){var _0x30c597={'tnTem':_0x2d55('0x7ca')};var _0x71d0c2=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass['hasClass'](_0x71d0c2,_0x30c597[_0x2d55('0x1be')])?handleClass[_0x2d55('0x2df')](_0x71d0c2,_0x30c597[_0x2d55('0x1be')]):handleClass['addClass'](_0x71d0c2,_0x30c597[_0x2d55('0x1be')]),handleClass[_0x2d55('0xb9')](_0x71d0c2,_0x30c597[_0x2d55('0x1be')])?this['isDisabled']=!0x1:this[_0x2d55('0x480')]=!0x0;},'CLASS_NAME':_0x2d55('0x88c')}),BDLayers[_0x2d55('0x47b')]['Control'][_0x2d55('0x464')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')]['TBItem'],{'initialize':function(_0x46ba05,_0x84921b){var _0x196901={'MCopW':_0x2d55('0x22b')};this[_0x2d55('0x5fe')]=_0x196901[_0x2d55('0x776')],this[_0x2d55('0x1a')]='toolbar-export-image',BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x84921b);},'itemClick':function(){var _0x368d98={'PeEHU':'active','nBPht':'image/jpeg','uSXdH':'map'};let _0x1a100c=this;var _0x388c0d=window[_0x2d55('0x6b')][_0x2d55('0x459')];handleClass[_0x2d55('0xb9')](_0x388c0d,_0x368d98[_0x2d55('0x764')])?handleClass['removeClass'](_0x388c0d,_0x368d98[_0x2d55('0x764')]):handleClass['addClass'](_0x388c0d,_0x2d55('0x7ca')),handleClass[_0x2d55('0xb9')](_0x388c0d,_0x2d55('0x7ca'))&&(_0x1a100c['options'][_0x2d55('0x700')][_0x2d55('0x87e')]({'mimeType':_0x368d98['nBPht'],'save':!0x0,'fileName':_0x368d98[_0x2d55('0xc0')]}),handleClass['removeClass'](_0x388c0d,_0x2d55('0x7ca')));},'CLASS_NAME':'BDLayers.Lib.Control.TBItemExportImage'}),BDLayers[_0x2d55('0x47b')][_0x2d55('0x729')][_0x2d55('0xeb')]=BDLayers[_0x2d55('0x2ca')]({'projection':{'projection':BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')]['EPSG3857']},'map':null,'baseLayers':null,'layers':null,'_glSence':null,'controlList':{},'interactions':null,'options':{'mapType':BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x520')],'mapModel':BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')][_0x2d55('0xf4')],'center':[118.892788,32.08221],'showCenter':!0x1,'defaultZoom':0x8,'maxZoom':0x16,'minZoom':0x3,'draggable':!0x1,'pitch':0x0,'bearing':0x0,'baseControl':!0x0,'errorUrl':null,'mapModelControl':!0x1,'nightMode':!0x1,'zoomControl':!0x1,'scaleControl':!0x1,'overviewControl':!0x1,'magnifierControl':!0x1,'exportImage':!0x1,'distanceControl':!0x1,'areaControl':!0x1,'positionControl':!0x1,'compass':!0x1,'drawControl':!0x1,'mapInitialState':!0x1,'fullScreenControl':!0x1,'boundary':null,'dragPitch':!0x0,'dragPan':!0x0,'dragRotate':!0x0,'scrollWheelZoom':!0x0,'touchZoom':!0x0,'doubleClickZoom':!0x1,'shader':null,'browserCache':!0x0,'showCopyright':!0x0,'seamlessZoom':!0x0,'markerZoom':!0x0,'initialState':_0x2d55('0x230'),'itemnav':!0x1,'itemNavAll':!0x1,'pickPoint':!0x1,'toolsShow':!0x0,'devicePixelRatio':0x1,'zoomDiff':0x1,'isIconChangeToMap':!0x1,'vertical':!0x1,'crs':BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')]['EPSG3857'],'lights':null},'drawTool':null,'mapRotatePlayer':null,'initialize':function(_0x3563d4,_0x44bd67){var _0x31dba6={'LkcrU':function(_0x1f8e09,_0x2fccd9){return _0x1f8e09<_0x2fccd9;},'womMz':function(_0x436213,_0x3a61f4){return _0x436213<_0x3a61f4;},'fIPBm':function(_0x2397e1,_0x969138){return _0x2397e1-_0x969138;},'XwCOY':function(_0x5eccf3,_0x3e6b92){return _0x5eccf3*_0x3e6b92;},'phQGm':function(_0x506986,_0x124af1){return _0x506986/_0x124af1;},'RDNmC':function(_0x6514a4,_0x5a1567){return _0x6514a4*_0x5a1567;},'NbcSZ':function(_0x3a35dc,_0x41c9df){return _0x3a35dc/_0x41c9df;},'hwpvn':function(_0x4aeda0,_0x136bbe){return _0x4aeda0!==_0x136bbe;},'QOqbI':_0x2d55('0x330'),'QaMPi':_0x2d55('0x539'),'OvJFL':_0x2d55('0x7ba')};this[_0x2d55('0x185')]=_0x3563d4,BDLayers['Util'][_0x2d55('0x229')](this,{'handlers':{},'_triggeringCount':0x0}),BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x44bd67),this['layers']=new HashMap();var _0x17b3ee,_0x44bd67={'annotation':this[_0x2d55('0x4f3')]['annotation'],'boundary':this[_0x2d55('0x4f3')][_0x2d55('0x730')],'browserCache':this[_0x2d55('0x4f3')]['browserCache'],'shade':this[_0x2d55('0x4f3')][_0x2d55('0x67b')],'layermodal':this[_0x2d55('0x4f3')][_0x2d55('0x65c')],'tilebaseOpt':{}},_0x44bd67=(this[_0x2d55('0x3b9')](_0x44bd67),this[_0x2d55('0x4f3')][_0x2d55('0x796')]&&(this[_0x2d55('0x2ef')]={'projection':this[_0x2d55('0x4f3')][_0x2d55('0x796')]}),this[_0x2d55('0x700')]=new maptalks[(_0x2d55('0x54c'))](_0x3563d4,{'spatialReference':this['projection'],'doubleClickZoom':this[_0x2d55('0x4f3')][_0x2d55('0xa2')],'center':this[_0x2d55('0x4f3')][_0x2d55('0x2ce')],'centerCross':this['options'][_0x2d55('0x2cf')],'dragPitch':this[_0x2d55('0x4f3')][_0x2d55('0x5a')],'dragPan':this['options'][_0x2d55('0x158')],'dragRotate':this[_0x2d55('0x4f3')][_0x2d55('0x41d')],'scrollWheelZoom':this[_0x2d55('0x4f3')]['scrollWheelZoom'],'touchZoom':this[_0x2d55('0x4f3')][_0x2d55('0x7a7')],'doubleClickZoom':this[_0x2d55('0x4f3')][_0x2d55('0xa2')],'zoom':this[_0x2d55('0x4f3')][_0x2d55('0x53e')],'minZoom':this[_0x2d55('0x4f3')]['minZoom'],'maxZoom':this[_0x2d55('0x4f3')][_0x2d55('0x65a')],'pitch':this['options']['pitch'],'bearing':this[_0x2d55('0x4f3')][_0x2d55('0x50d')],'initialState':this[_0x2d55('0x4f3')][_0x2d55('0x2db')],'itemnav':this[_0x2d55('0x4f3')][_0x2d55('0x56a')],'seamlessZoom':this[_0x2d55('0x4f3')][_0x2d55('0x255')],'zoomDiff':this[_0x2d55('0x4f3')][_0x2d55('0x14d')],'lights':this['options'][_0x2d55('0x376')]||null,'devicePixelRatio':this[_0x2d55('0x4f3')][_0x2d55('0x652')]}),this[_0x2d55('0x683')]&&(this[_0x2d55('0x700')][_0x2d55('0x507')](this[_0x2d55('0x683')]['toLayer']()),this[_0x2d55('0x683')][_0x2d55('0x2a8')]()[_0x2d55('0x196')]()),BDLayers[_0x2d55('0x84f')][_0x2d55('0x4fa')](_0x31dba6[_0x2d55('0x336')])),_0x3563d4=(maptalks['DomUtil'][_0x2d55('0x61a')](_0x44bd67),new BDLayers[(_0x2d55('0x47b'))]['Layer'][(_0x2d55('0x5bd'))](_0x31dba6[_0x2d55('0x2a7')]));this['addCustomLayers'](_0x3563d4),this[_0x2d55('0x4f3')][_0x2d55('0x439')]&&this[_0x2d55('0x7')](this[_0x2d55('0x4f3')]['baseControl']),this['options'][_0x2d55('0x19c')]&&(_0x17b3ee=this[_0x2d55('0x700')][_0x2d55('0x570')](),this[_0x2d55('0x700')]['on'](_0x31dba6['OvJFL'],function(){var _0x580556={'lwtBj':function(_0x3fac0f,_0x112cf4){return _0x31dba6[_0x2d55('0x68a')](_0x3fac0f,_0x112cf4);},'Nnsch':function(_0x2e3c8f,_0x7e54f5){return _0x31dba6['womMz'](_0x2e3c8f,_0x7e54f5);},'uaGqH':function(_0x1d453e,_0x4a3d1f){return _0x1d453e+_0x4a3d1f;},'OXdFC':function(_0x2651b9,_0x4d4a51){return _0x31dba6[_0x2d55('0x9c')](_0x2651b9,_0x4d4a51);},'oMXzr':function(_0x4b3f64,_0x316c1e){return _0x31dba6[_0x2d55('0x4c4')](_0x4b3f64,_0x316c1e);},'MNaFG':function(_0x4b11b5,_0x5c2167){return _0x31dba6[_0x2d55('0x6f1')](_0x4b11b5,_0x5c2167);},'PUdWn':function(_0x11e0df,_0x335d7b){return _0x31dba6['RDNmC'](_0x11e0df,_0x335d7b);},'Wyenl':function(_0x4436dd,_0x2bbfaf){return _0x31dba6[_0x2d55('0x815')](_0x4436dd,_0x2bbfaf);},'AltWa':function(_0x14a3f3,_0x173038){return _0x14a3f3<_0x173038;},'SDoRr':function(_0x4886ec,_0x2373aa){return _0x31dba6[_0x2d55('0x9c')](_0x4886ec,_0x2373aa);},'JHfBL':function(_0x392ba7,_0x35f266){return _0x31dba6[_0x2d55('0x17c')](_0x392ba7,_0x35f266);}};var _0x1d71de=this['map'][_0x2d55('0x570')]();{var _0x40562e,_0x353756;_0x31dba6['hwpvn'](_0x1d71de,_0x17b3ee)&&(_0x40562e=this[_0x2d55('0x700')][_0x2d55('0x331')](function(_0x1d25fa){return _0x1d25fa;}),_0x353756=[],_0x40562e[_0x2d55('0x457')](_0x1a02a3=>{_0x1a02a3[_0x2d55('0x768')]&&_0x580556[_0x2d55('0x34e')](0x0,(_0x1a02a3=_0x1a02a3[_0x2d55('0x768')][_0x2d55('0x644')]())[_0x2d55('0x6e9')])&&_0x353756[_0x2d55('0x590')](..._0x1a02a3);}),_0x353756[_0x2d55('0x457')](_0x35f9e4=>{if(_0x35f9e4[_0x2d55('0x8a0')][_0x2d55('0x1f')]){var _0x4d2219,_0x4ffd38,_0x5a1e32,_0xf8e01a,_0x379edf,_0x1199ec,_0xc2998f=_0x35f9e4[_0x2d55('0x8a0')][_0x2d55('0x1f')]();Array[_0x2d55('0x26a')](_0xc2998f)?_0xc2998f[0x0][_0x2d55('0x5d6')]&&(_0x4d2219=_0xc2998f[0x0]['markerWidth'],_0x1199ec=_0xc2998f[0x0][_0x2d55('0x87f')],_0xc2998f[0x1][_0x2d55('0x421')])&&(_0x4ffd38=_0xc2998f[0x1]['textSize']):(_0xc2998f['markerWidth']&&(_0x4d2219=_0xc2998f['markerWidth'],_0x1199ec=_0xc2998f[_0x2d55('0x87f')]),_0xc2998f[_0x2d55('0x421')]&&(_0x4ffd38=_0xc2998f[_0x2d55('0x421')])),_0x4d2219&&(_0xf8e01a=_0x580556[_0x2d55('0x3bf')](_0x17b3ee,_0x1d71de)?(_0x5a1e32=_0x580556[_0x2d55('0x3d8')](_0x4d2219,0x5*_0x580556['OXdFC'](_0x1d71de,_0x17b3ee)),_0x1199ec+_0x580556['oMXzr'](_0x580556[_0x2d55('0x2f')](0x5,_0x4d2219),_0x1199ec)*(_0x1d71de-_0x17b3ee)):_0x580556[_0x2d55('0x3bf')](0xf,_0x4d2219)?(_0x5a1e32=_0x4d2219-_0x580556[_0x2d55('0x7de')](0x5,_0x580556['OXdFC'](_0x17b3ee,_0x1d71de)),_0x580556[_0x2d55('0x4c2')](_0x1199ec,_0x580556[_0x2d55('0x578')](_0x580556[_0x2d55('0x720')](0x5,_0x4d2219)*_0x1199ec,_0x580556['OXdFC'](_0x17b3ee,_0x1d71de)))):(_0x5a1e32=_0x4d2219,_0x1199ec)),_0x4ffd38&&(_0x379edf=_0x580556['AltWa'](_0x17b3ee,_0x1d71de)?_0x4ffd38+_0x580556['SDoRr'](_0x1d71de,_0x17b3ee):0xc<_0x4ffd38?_0x580556[_0x2d55('0x53f')](_0x4ffd38,_0x580556[_0x2d55('0x53f')](_0x17b3ee,_0x1d71de)):_0x4ffd38);let _0x440660=Array[_0x2d55('0x26a')](_0xc2998f)?[]:{};_0x4d2219&&(_0x1199ec={'markerWidth':_0x5a1e32,'markerHeight':_0xf8e01a},Array[_0x2d55('0x26a')](_0xc2998f)?_0x440660['push'](_0x1199ec):_0x440660=_0x1199ec),_0x4ffd38&&(Array[_0x2d55('0x26a')](_0xc2998f)?_0x440660[_0x2d55('0x590')]({'textSize':_0x379edf}):_0x440660['textSize']=_0x379edf),(Array[_0x2d55('0x26a')](_0x440660)&&_0x580556[_0x2d55('0x7d1')](0x0,_0x440660[_0x2d55('0x6e9')])||_0x580556[_0x2d55('0x7d1')](0x0,Object[_0x2d55('0x70a')](_0x440660)[_0x2d55('0x6e9')]))&&_0x35f9e4[_0x2d55('0x8a0')][_0x2d55('0x802')](_0x440660);}}),_0x17b3ee=_0x1d71de);}}['bind'](this)));},'createGLScense'(_0x3cff38){return this['_glSence']=new maptalks['GroupGLLayer'](_0x2d55('0x3ca'),[]),_0x3cff38&&_0x3cff38[_0x2d55('0x392')]&&this['_glSence'][_0x2d55('0x18')](_0x3cff38[_0x2d55('0x392')]),this[_0x2d55('0xb0')][_0x2d55('0x6ce')](this[_0x2d55('0x700')]),this[_0x2d55('0xb0')];},'getBaseLayers'(_0x3911d8){var _0xb4b8d5={'NBufl':_0x2d55('0x623'),'ThkiA':_0x2d55('0x230'),'itjoK':'streetBlue','QcOXx':_0x2d55('0x128'),'UsEme':'community','mNmHw':_0x2d55('0x4f2')};switch(this[_0x2d55('0x4f3')]['mapType']){case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x520')]:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')]['EPSG3857'],this['baseLayers']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x3c9'))](_0x3911d8);break;case BDLayers['Lib'][_0x2d55('0x168')]['BaseLayerType'][_0x2d55('0x206')]:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0xcf')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))]['Layer'][(_0x2d55('0x3c9'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['BaseLayerType'][_0x2d55('0x315')]:this[_0x2d55('0x2ef')]={'projection':BDLayers['Lib']['Constant'][_0x2d55('0x3fa')][_0x2d55('0x189')]},_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['PROJECTION'][_0x2d55('0x189')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))]['Layer'][(_0x2d55('0x41a'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['BaseLayerType'][_0x2d55('0x160')]:this['projection']={'projection':BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x3fa')][_0x2d55('0x189')]},_0x3911d8['projection']=BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x3fa')][_0x2d55('0x189')],_0x3911d8[_0x2d55('0x3a7')]=_0x2d55('0x172'),this['baseLayers']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x41a'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x72b')]:this[_0x2d55('0x2ef')]={'projection':BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x189')]},_0x3911d8['projection']=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x189')],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5[_0x2d55('0x1ed')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x41a'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')]['Constant']['BaseLayerType'][_0x2d55('0x1d2')]:this[_0x2d55('0x2ef')]={'projection':BDLayers['Lib'][_0x2d55('0x168')]['PROJECTION'][_0x2d55('0x189')]},_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x189')],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5['ThkiA'],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['BaiduLayers'](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x856')]:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x492')],this['baseLayers']=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x77'))](_0x3911d8);break;case BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x133')]['AmapGCJ02']:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['PROJECTION'][_0x2d55('0x492')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x518'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')]['GeoQ_StreetBlue']:_0x3911d8['projection']=BDLayers[_0x2d55('0x47b')]['Constant']['PROJECTION'][_0x2d55('0x492')],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5[_0x2d55('0x44c')],this['baseLayers']=new BDLayers[(_0x2d55('0x47b'))]['Layer']['GeoQLayers'](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x133')][_0x2d55('0x51c')]:_0x3911d8['projection']=BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x492')],_0x3911d8['style']=_0xb4b8d5[_0x2d55('0x609')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))]['Layer']['GeoQLayers'](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x133')][_0x2d55('0x789')]:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')]['Constant']['PROJECTION'][_0x2d55('0x492')],_0x3911d8['style']='streetWarm',this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0x6e0'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x17')]:_0x3911d8['projection']=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')]['EPSG3857'],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5['UsEme'],this['baseLayers']=new BDLayers['Lib']['Layer'][(_0x2d55('0x6e0'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')]['GeoQ_StreetBlue_GCJ02']:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')]['Constant'][_0x2d55('0x3fa')]['EPSG3857'],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5[_0x2d55('0x44c')],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))][(_0x2d55('0xd'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x277')]:_0x3911d8['projection']=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x492')],_0x3911d8[_0x2d55('0x3a7')]='streetGray',this['baseLayers']=new BDLayers[(_0x2d55('0x47b'))]['Layer']['GeoQGCJ02Layers'](_0x3911d8);break;case BDLayers['Lib'][_0x2d55('0x168')]['BaseLayerType']['GeoQ_StreetWarm_GCJ02']:_0x3911d8[_0x2d55('0x2ef')]=BDLayers['Lib'][_0x2d55('0x168')][_0x2d55('0x3fa')][_0x2d55('0x492')],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5['mNmHw'],this[_0x2d55('0x683')]=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0xd'))](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x208')]:_0x3911d8[_0x2d55('0x2ef')]=BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')]['PROJECTION'][_0x2d55('0x492')],_0x3911d8[_0x2d55('0x3a7')]=_0xb4b8d5['UsEme'],this[_0x2d55('0x683')]=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['GeoQGCJ02Layers'](_0x3911d8);break;case BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x54d')]:this['projection']={'projection':this['options']['crs']},_0x3911d8[_0x2d55('0x2ef')]=this['options'][_0x2d55('0x796')],_0x3911d8[_0x2d55('0x270')]=this[_0x2d55('0x4f3')][_0x2d55('0x270')],this[_0x2d55('0x683')]=new BDLayers['Lib'][(_0x2d55('0x404'))][(_0x2d55('0x11f'))](_0x3911d8);break;default:BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x133')][_0x2d55('0x5ac')];this[_0x2d55('0x683')]=null;}},'addCustomLayers':function(_0x5ee198,_0x2be0b1,_0x101aab){var _0xcf1b5c={'JbUyg':function(_0x3479ae,_0x189aaa){return _0x3479ae<_0x189aaa;}};if(_0x5ee198){if(_0x101aab)if(_0x5ee198['layer'][_0x2d55('0x5df')]&&_0xcf1b5c[_0x2d55('0x391')](0x0,_0x5ee198[_0x2d55('0x749')][_0x2d55('0x5df')][_0x2d55('0x6e9')])){const _0x5a8ae2=this;_0x5ee198['layer'][_0x2d55('0x5df')][_0x2d55('0x457')](function(_0x4c82a8){_0x5a8ae2[_0x2d55('0xb0')][_0x2d55('0x197')](_0x4c82a8);});}else this[_0x2d55('0xb0')]['addLayer'](_0x5ee198[_0x2d55('0x749')]);else _0x5ee198[_0x2d55('0x4a0')](this['map']);_0x2be0b1&&_0xcf1b5c[_0x2d55('0x391')](0x0,_0x2be0b1)&&_0x5ee198[_0x2d55('0x20a')](_0x2be0b1),this[_0x2d55('0x5df')]['put'](_0x5ee198['id'],_0x5ee198);}},'getLayer':function(_0x257097){return this[_0x2d55('0x5df')][_0x2d55('0x86')](_0x257097);},'removeLayersById':function(_0x5e3b5a){var _0x1e50f3=this[_0x2d55('0x5df')][_0x2d55('0x86')](_0x5e3b5a);_0x1e50f3&&(this['layers'][_0x2d55('0x860')](_0x5e3b5a),this[_0x2d55('0x700')][_0x2d55('0x150')](_0x1e50f3[_0x2d55('0x749')]),this[_0x2d55('0xb0')])&&this['_glSence'][_0x2d55('0x150')](_0x1e50f3[_0x2d55('0x749')]);},'removeLayers':function(){},'changeMapModel':function(){},'createBaseMapTools':function(_0x2e8664){var _0x34dda5={'DlWfR':_0x2d55('0xe'),'DIgHV':function(_0xe0a806,_0x26e3ca){return _0xe0a806===_0x26e3ca;},'NYKHA':function(_0x541df5,_0x12fe9f){return _0x541df5===_0x12fe9f;},'qeNHg':'maptalks-toolbar-vertical','NQKEd':_0x2d55('0x151'),'bLvZt':function(_0x5147c6,_0x2250cf){return _0x5147c6===_0x2250cf;},'ewigX':_0x2d55('0x3de'),'MCkXR':'auto','EXhjB':_0x2d55('0x37d'),'vkhzd':function(_0x437251,_0xd6af78){return _0x437251===_0xd6af78;},'ofwWB':function(_0x725ae5,_0x2b3ad1){return _0x725ae5+_0x2b3ad1;},'dgwFs':function(_0x3ec7fb,_0x3a49c0){return _0x3ec7fb!==_0x3a49c0;},'XqhGo':function(_0x2c5780,_0x3fa8d1){return _0x2c5780!==_0x3fa8d1;},'kADgU':_0x2d55('0x526'),'KQpOr':function(_0x1c6255,_0x4294c5){return _0x1c6255===_0x4294c5;},'CodWV':'rotate(0)','DKOpe':_0x2d55('0x481'),'iIlOm':_0x2d55('0x5fe'),'BfHSr':_0x2d55('0x49f'),'rWaFa':function(_0x3dc7ca,_0x433aaa){return _0x3dc7ca===_0x433aaa;},'DMuKy':_0x2d55('0x864'),'EPYRA':_0x2d55('0x1ca'),'CUPsZ':_0x2d55('0x467'),'FfZCg':'tbitem_scale','IBFPX':_0x2d55('0x104'),'rujgZ':_0x2d55('0x5c7'),'afWXG':_0x2d55('0x24c'),'bPpdQ':_0x2d55('0x43e'),'vWCXY':_0x2d55('0x3ab'),'hyhJU':_0x2d55('0x811'),'QvWuQ':_0x2d55('0x12e'),'AdNGT':_0x2d55('0x232'),'knEwZ':'tbitem_compass','jXVuW':'tbitem_mapInitialState','Lbdha':_0x2d55('0x468'),'qEirP':_0x2d55('0x710'),'pRjnX':_0x2d55('0x106'),'zvcBv':_0x2d55('0x1e0'),'xpYCk':_0x2d55('0x40a'),'CTGIB':_0x2d55('0xa1'),'TPuyB':function(_0x364778,_0x361b1f){return _0x364778<_0x361b1f;},'oGsSs':function(_0x53f920,_0x15c690){return _0x53f920<_0x15c690;},'xXSoa':_0x2d55('0x350'),'wOZEr':_0x2d55('0x371'),'oGaox':_0x2d55('0x80b'),'pZBfP':function(_0x3ed673,_0x1c4003,_0xf4b135){return _0x3ed673(_0x1c4003,_0xf4b135);},'QyjRj':'maptalks-tr-toolbar-app-p','YaMsw':_0x2d55('0x7ca'),'xTKLF':_0x2d55('0x6bc'),'AGnww':function(_0x12344f,_0x321cd0){return _0x12344f==_0x321cd0;}};if(_0x2e8664){var _0x35d3b3,_0xf08db,_0x2e8664=new BDLayers['Lib'][(_0x2d55('0x50b'))][(_0x2d55('0x690'))](_0x2d55('0x502'),{'map':this['map'],'baseLayers':this[_0x2d55('0x683')]}),_0xe07ed8=(this['controlList']['wx']=_0x2e8664,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))]['TBItemDark'](_0x34dda5[_0x2d55('0x781')],{'map':this[_0x2d55('0x700')],'baseLayers':this[_0x2d55('0x683')]})),_0x48b861=(this[_0x2d55('0x566')][_0x2d55('0x7b9')]=_0xe07ed8,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x120'))]('tbitem_dis',{'controlList':this[_0x2d55('0x566')],'targetDiv':this[_0x2d55('0x185')]})),_0xe95244=(_0x48b861[_0x2d55('0x69b')]&&(_0x48b861[_0x2d55('0x69b')][_0x2d55('0x6ce')](this[_0x2d55('0x700')]),_0x48b861['mapTool']['disable']()),this[_0x2d55('0x566')]['cj']=_0x48b861,new BDLayers[(_0x2d55('0x47b'))]['Control'][(_0x2d55('0x54'))](_0x34dda5[_0x2d55('0x2d9')],{'controlList':this[_0x2d55('0x566')],'targetDiv':this['targetDiv']})),_0x41cd7a=(_0xe95244[_0x2d55('0x69b')]&&(_0xe95244[_0x2d55('0x69b')]['addTo'](this[_0x2d55('0x700')]),_0xe95244['mapTool'][_0x2d55('0x49b')]()),this[_0x2d55('0x566')]['cmj']=_0xe95244,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x73d'))](_0x34dda5[_0x2d55('0x56d')],{'map':this[_0x2d55('0x700')]})),_0x556a7b=(_0x41cd7a[_0x2d55('0x69b')]&&(_0x41cd7a[_0x2d55('0x69b')][_0x2d55('0x6ce')](this[_0x2d55('0x700')]),_0x41cd7a[_0x2d55('0x69b')]['hide']()),this[_0x2d55('0x566')]['sf']=_0x41cd7a,new BDLayers['Lib']['Control']['TBItemScale'](_0x34dda5[_0x2d55('0x1ee')])),_0x1ed982=(_0x556a7b[_0x2d55('0x69b')]&&(_0x556a7b['mapTool']['addTo'](this[_0x2d55('0x700')]),_0x556a7b[_0x2d55('0x69b')][_0x2d55('0x45d')]()),this[_0x2d55('0x566')][_0x2d55('0x278')]=_0x556a7b,new BDLayers[(_0x2d55('0x47b'))]['Control']['TBItemOverview'](_0x34dda5[_0x2d55('0x271')])),_0x4f55fc=(_0x1ed982[_0x2d55('0x69b')]&&(_0x1ed982[_0x2d55('0x69b')]['addTo'](this['map']),_0x1ed982[_0x2d55('0x69b')][_0x2d55('0x45d')]()),this[_0x2d55('0x566')]['yy']=_0x1ed982,new BDLayers['Lib'][(_0x2d55('0x50b'))][(_0x2d55('0x547'))](_0x34dda5[_0x2d55('0x1fe')],{'map':this[_0x2d55('0x700')]})),_0x499309=(this[_0x2d55('0x566')][_0x2d55('0x2c4')]=_0x4f55fc,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))]['TBItemPosition'](_0x34dda5[_0x2d55('0x33d')],{'controlList':this[_0x2d55('0x566')],'map':this[_0x2d55('0x700')],'targetDiv':this[_0x2d55('0x185')]})),_0x337b4d=(_0x499309[_0x2d55('0x69b')]&&(_0x499309['mapTool'][_0x2d55('0x6ce')](this[_0x2d55('0x700')]),_0x499309[_0x2d55('0x69b')]['hide']()),this['controlList']['dw']=_0x499309,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))]['TBItemFullScreen'](_0x34dda5[_0x2d55('0x5e4')],{'map':this['map']})),_0x581b13=(this[_0x2d55('0x566')]['qp']=_0x1ed982,new BDLayers['Lib']['Control'][(_0x2d55('0x475'))](_0x34dda5[_0x2d55('0x878')],{'controlList':this[_0x2d55('0x566')],'targetDiv':this[_0x2d55('0x185')],'vertical':this[_0x2d55('0x4f3')][_0x2d55('0x4ac')]})),_0x303c4f=(_0x581b13[_0x2d55('0x69b')]&&((this[_0x2d55('0x717')]=_0x581b13)[_0x2d55('0x69b')][_0x2d55('0x6ce')](this[_0x2d55('0x700')]),_0x581b13[_0x2d55('0x69b')]['disable'](),(_0x35d3b3=new maptalks[(_0x2d55('0x221'))](_0x34dda5[_0x2d55('0x1f9')])['addTo'](this[_0x2d55('0x700')]))[_0x2d55('0x20a')](0x64),_0x581b13[_0x2d55('0x69b')]['on'](_0x2d55('0xe'),function(_0x5995cf){console[_0x2d55('0x10b')](_0x5995cf[_0x2d55('0xe3')]),_0x35d3b3['addGeometry'](_0x5995cf[_0x2d55('0xe3')]),_0x581b13['trigger'](_0x34dda5['DlWfR'],_0x5995cf[_0x2d55('0xe3')]);}),_0xf08db=new BDLayers['Lib'][(_0x2d55('0x50b'))][(_0x2d55('0x85'))](_0x2d55('0x503'),{'item':_0x581b13,'layer':_0x35d3b3})),new BDLayers['Lib'][(_0x2d55('0x50b'))][(_0x2d55('0x4a4'))](_0x34dda5['QvWuQ'],{'map':this[_0x2d55('0x700')]})),_0x1726c0=(this[_0x2d55('0x566')][_0x2d55('0x88d')]=_0x303c4f,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x464'))](_0x34dda5[_0x2d55('0x195')],{'map':this[_0x2d55('0x700')]})),_0x26b1dc=(this[_0x2d55('0x566')][_0x2d55('0x413')]=_0x1726c0,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x55c'))](_0x34dda5['knEwZ'],{'map':this[_0x2d55('0x700')],'baseLayers':this['baseLayers']})),_0x48bb5e=(this[_0x2d55('0x566')][_0x2d55('0x74c')]=_0x26b1dc,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x795'))](_0x34dda5[_0x2d55('0x5c9')],{'map':this['map'],'baseLayers':this[_0x2d55('0x683')]})),_0x40a1fa=(this[_0x2d55('0x566')][_0x2d55('0x88f')]=_0x48bb5e,new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x50b'))][(_0x2d55('0x23d'))](_0x34dda5['Lbdha'],{'map':this[_0x2d55('0x700')],'controlList':this[_0x2d55('0x566')]})),_0x51266e=(this['controlList'][_0x2d55('0x47e')]=_0x40a1fa,[_0x2e8664[_0x2d55('0x109')](),_0xe07ed8['getItem'](),_0x26b1dc[_0x2d55('0x109')](),_0x40a1fa[_0x2d55('0x109')](),_0x41cd7a['getItem'](),_0x556a7b['getItem'](),_0x4f55fc['getItem'](),_0x1ed982['getItem'](),_0x303c4f[_0x2d55('0x109')](),_0x1726c0[_0x2d55('0x109')](),_0x48b861[_0x2d55('0x109')](),_0xe95244[_0x2d55('0x109')](),_0x499309['getItem'](),_0x581b13[_0x2d55('0x109')](),_0xf08db['getItem'](),_0x48bb5e['getItem'](),_0x337b4d[_0x2d55('0x109')]()]),_0x2e8664=(new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x654'))]({'position':_0x34dda5[_0x2d55('0x557')],'items':_0x51266e,'vertical':this[_0x2d55('0x4f3')][_0x2d55('0x4ac')]})[_0x2d55('0x6ce')](this['map']),document['getElementsByClassName'](_0x34dda5[_0x2d55('0x2c8')])[0x0]),_0xe07ed8=document[_0x2d55('0x5b6')](_0x34dda5['pRjnX']),_0x26b1dc=(_0xe07ed8[_0x2d55('0x56c')]='maptalks-toolbar-drag',_0x2e8664['parentNode'][_0x2d55('0x124')](_0xe07ed8),_0xe07ed8[_0x2d55('0x604')](_0x34dda5[_0x2d55('0x111')],_0x34dda5[_0x2d55('0xe0')]),document['createElement'](_0x34dda5[_0x2d55('0x342')])),_0x40a1fa=(_0x26b1dc[_0x2d55('0x56c')]=_0x34dda5[_0x2d55('0x22c')],_0x2e8664[_0x2d55('0x89a')][_0x2d55('0x124')](_0x26b1dc),document['createElement'](_0x34dda5[_0x2d55('0x342')])),_0x1a2302=(_0x40a1fa[_0x2d55('0x56c')]='maptalks-toolbar-icon',_0x26b1dc[_0x2d55('0x124')](_0x40a1fa),window[_0x2d55('0x64a')]['userAgent'][_0x2d55('0x2e1')](/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)&&_0x2e8664[_0x2d55('0x89a')]['classList'][_0x2d55('0x69a')](_0x34dda5[_0x2d55('0x7a6')]),_0x2e8664[_0x2d55('0x2c5')]);for(let _0x2eb7f0=0x0;_0x34dda5[_0x2d55('0x733')](_0x2eb7f0,_0x1a2302['length']);_0x2eb7f0++)_0x51266e[_0x2eb7f0][_0x2d55('0x1a')]&&0x0<_0x51266e[_0x2eb7f0][_0x2d55('0x1a')][_0x2d55('0x6e9')]&&(_0x1a2302[_0x2eb7f0][_0x2d55('0x56c')]=_0x51266e[_0x2eb7f0][_0x2d55('0x1a')]),_0x51266e[_0x2eb7f0][_0x2d55('0x5fe')]&&_0x34dda5[_0x2d55('0x2d6')](0x0,_0x51266e[_0x2eb7f0][_0x2d55('0x5fe')][_0x2d55('0x6e9')])&&_0x1a2302[_0x2eb7f0][_0x2d55('0x604')](_0x34dda5[_0x2d55('0x111')],_0x51266e[_0x2eb7f0][_0x2d55('0x5fe')]);let _0x19441d=this;var _0x551acc=document[_0x2d55('0x4e8')](_0x34dda5[_0x2d55('0x2c8')])[0x0],_0x1e8fec=document['getElementsByClassName'](_0x34dda5[_0x2d55('0x75f')])[0x0],_0x345b36=(document[_0x2d55('0x199')](_0x2d55('0x81'),function(_0x5e6e5c){_0x34dda5[_0x2d55('0x6e5')](_0x5e6e5c[_0x2d55('0x9e')],_0x1e8fec)&&(_0x34dda5[_0x2d55('0x62e')](_0x34dda5[_0x2d55('0x801')],_0x1e8fec[_0x2d55('0x89a')]['className'])?(_0x19441d['options'][_0x2d55('0x4ac')]=!0x1,_0x1e8fec['parentNode'][_0x2d55('0x56c')]=_0x34dda5[_0x2d55('0x637')],_0x551acc[_0x2d55('0x3a7')]['width']&&_0x34dda5[_0x2d55('0x684')](_0x34dda5[_0x2d55('0x16b')],_0x551acc[_0x2d55('0x3a7')][_0x2d55('0x4f6')])?_0x551acc[_0x2d55('0x3a7')][_0x2d55('0x347')]='0':_0x551acc['style'][_0x2d55('0x347')]=_0x34dda5[_0x2d55('0x2d1')],_0x551acc[_0x2d55('0x3a7')][_0x2d55('0x4f6')]=_0x34dda5[_0x2d55('0x7a8')]):(_0x19441d[_0x2d55('0x4f3')][_0x2d55('0x4ac')]=!0x0,_0x1e8fec[_0x2d55('0x89a')][_0x2d55('0x56c')]=_0x2d55('0x47'),_0x551acc['style']['height']&&_0x34dda5['vkhzd'](_0x34dda5[_0x2d55('0x16b')],_0x551acc[_0x2d55('0x3a7')]['height'])?_0x551acc[_0x2d55('0x3a7')]['width']='0':_0x551acc[_0x2d55('0x3a7')][_0x2d55('0x4f6')]=_0x2d55('0x7e'),_0x551acc[_0x2d55('0x3a7')]['height']=_0x34dda5[_0x2d55('0x7a8')]));}),document['getElementsByClassName'](_0x34dda5[_0x2d55('0x4d9')])[0x0]),_0x40ef89=document[_0x2d55('0x4e8')]('maptalks-toolbar-click')[0x0];_0x40ef89['setAttribute'](_0x34dda5[_0x2d55('0x111')],'收起'),this[_0x2d55('0x4f3')][_0x2d55('0x56b')]||(_0x345b36[_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x2d55('0x481'),_0x19441d['options'][_0x2d55('0x4ac')]?(_0x551acc[_0x2d55('0x3a7')][_0x2d55('0x4f6')]='0',_0x551acc['style'][_0x2d55('0x347')]=_0x34dda5[_0x2d55('0x7a8')]):(_0x551acc['style'][_0x2d55('0x4f6')]=_0x34dda5['EXhjB'],_0x551acc['style'][_0x2d55('0x347')]='0'),_0x40ef89['setAttribute'](_0x34dda5[_0x2d55('0x111')],'展开'));let _0x1ce312=null,_0x52142c='0';_0x19441d[_0x2d55('0x4f3')][_0x2d55('0x4ac')]&&(_0x1ce312=document[_0x2d55('0x110')](_0x34dda5[_0x2d55('0x258')])[_0x2d55('0x89a')],_0x34dda5[_0x2d55('0x839')](setTimeout,()=>{_0x52142c=_0x34dda5[_0x2d55('0x4a1')](_0x1ce312['offsetWidth'],'px');},0x64)),document['addEventListener'](_0x2d55('0x81'),function(_0x2370e5){var _0x2370e5=_0x2370e5[_0x2d55('0x9e')];_0x34dda5[_0x2d55('0x4a8')](_0x2370e5,_0x40ef89)&&_0x34dda5[_0x2d55('0x5b')](_0x2370e5,_0x345b36)||(_0x2370e5=document[_0x2d55('0x4e8')](_0x34dda5['kADgU'])[0x0],_0x19441d['options'][_0x2d55('0x4ac')]?_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x4f6')]&&_0x34dda5[_0x2d55('0x309')](_0x34dda5[_0x2d55('0x16b')],_0x2370e5[_0x2d55('0x3a7')]['width'])?(_0x2370e5['style'][_0x2d55('0x4f6')]=_0x34dda5[_0x2d55('0x2d1')],_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x347')]=_0x2d55('0x37d'),_0x345b36[_0x2d55('0x3a7')][_0x2d55('0x184')]=_0x34dda5[_0x2d55('0x582')],_0x40ef89[_0x2d55('0x604')]('title','收起'),_0x1ce312[_0x2d55('0x3a7')][_0x2d55('0x4f6')]=_0x52142c):(_0x345b36['style'][_0x2d55('0x184')]=_0x34dda5[_0x2d55('0x4d1')],_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x4f6')]='0',_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x347')]=_0x34dda5[_0x2d55('0x7a8')],_0x40ef89['setAttribute'](_0x34dda5[_0x2d55('0x111')],'展开'),_0x1ce312[_0x2d55('0x3a7')][_0x2d55('0x4f6')]=_0x34dda5[_0x2d55('0x75c')]):_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x347')]&&_0x34dda5[_0x2d55('0x75')](_0x34dda5[_0x2d55('0x16b')],_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x347')])?(_0x2370e5[_0x2d55('0x3a7')]['height']=_0x34dda5['MCkXR'],_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x4f6')]=_0x34dda5['EXhjB'],_0x345b36['style'][_0x2d55('0x184')]=_0x34dda5['CodWV'],_0x40ef89[_0x2d55('0x604')](_0x34dda5['iIlOm'],'收起')):(_0x345b36['style'][_0x2d55('0x184')]=_0x34dda5[_0x2d55('0x4d1')],_0x2370e5[_0x2d55('0x3a7')][_0x2d55('0x347')]='0',_0x2370e5[_0x2d55('0x3a7')]['width']=_0x34dda5[_0x2d55('0x7a8')],_0x40ef89['setAttribute'](_0x34dda5['iIlOm'],'展开')));});var _0x3e42a7,_0x41cd7a=document[_0x2d55('0x4e8')](_0x34dda5[_0x2d55('0x7a6')])[0x0],_0x4bb379=(_0x41cd7a&&(_0x556a7b=_0x41cd7a['parentNode'],_0x4f55fc=_0x41cd7a['parentNode'][_0x2d55('0x89a')],_0x556a7b['style'][_0x2d55('0x543')]='5px',_0x556a7b[_0x2d55('0x52e')][_0x2d55('0x69a')]('maptalks-tr-toolbar-app'),_0x4f55fc[_0x2d55('0x52e')][_0x2d55('0x69a')](_0x34dda5[_0x2d55('0x266')])),this[_0x2d55('0x4f3')][_0x2d55('0x65c')]===BDLayers[_0x2d55('0x47b')][_0x2d55('0x168')][_0x2d55('0x610')]['Satellite']&&(_0x1ed982=document['querySelector']('#'+this[_0x2d55('0x185')]+_0x2d55('0x89e')),handleClass['addClass'](_0x1ed982,_0x34dda5[_0x2d55('0x1f5')])),{'wx':this[_0x2d55('0x4f3')][_0x2d55('0x24')],'yjms':this['options'][_0x2d55('0xcc')],'sf':this[_0x2d55('0x4f3')][_0x2d55('0x1f2')],'blc':this[_0x2d55('0x4f3')][_0x2d55('0x1bc')],'yy':this['options'][_0x2d55('0x7c8')],'sqdw':this[_0x2d55('0x4f3')][_0x2d55('0x5eb')],'fdj':this['options'][_0x2d55('0x5d7')],'export-image':this[_0x2d55('0x4f3')][_0x2d55('0x59a')],'cj':this[_0x2d55('0x4f3')][_0x2d55('0xaa')],'cmj':this[_0x2d55('0x4f3')][_0x2d55('0x886')],'dw':this[_0x2d55('0x4f3')][_0x2d55('0x6d6')],'hz':this['options'][_0x2d55('0x7da')],'zbz':this[_0x2d55('0x4f3')][_0x2d55('0x68f')],'nav':this[_0x2d55('0x4f3')][_0x2d55('0x58')],'cszt':this['options'][_0x2d55('0x39')],'qp':this[_0x2d55('0x4f3')][_0x2d55('0x116')]});for(_0x3e42a7 in _0x4bb379)_0x4bb379[_0x3e42a7]||(document[_0x2d55('0x110')]('#'+this[_0x2d55('0x185')]+_0x2d55('0x80')+_0x3e42a7)[_0x2d55('0x3a7')][_0x2d55('0x3fe')]=_0x34dda5[_0x2d55('0x592')],_0x34dda5['AGnww']('hz',_0x3e42a7)&&(document[_0x2d55('0x110')]('#'+this[_0x2d55('0x185')]+_0x2d55('0x692'))[_0x2d55('0x3a7')]['display']=_0x34dda5[_0x2d55('0x592')]));}},'addMarker':function(_0xaf89ad){var _0x35d3cf={'YNplL':_0x2d55('0x539')};_0xaf89ad&&this[_0x2d55('0x5df')][_0x2d55('0x86')](_0x35d3cf['YNplL'])[_0x2d55('0x293')](_0xaf89ad);},'addMarkers':function(_0x290a71){var _0x4b7a2a={'PuxQc':_0x2d55('0x539')};_0x290a71&&this[_0x2d55('0x5df')]['get'](_0x4b7a2a[_0x2d55('0x252')])[_0x2d55('0x875')](_0x290a71);},'removeMarker':function(_0xa117f2){var _0x1c6151={'GgnDs':_0x2d55('0x539')};this['layers'][_0x2d55('0x86')](_0x1c6151[_0x2d55('0x449')])[_0x2d55('0x27e')](_0xa117f2);},'removeMarkers':function(_0x472b95){var _0x316d90={'KpKuM':'def_markerlayer'};this['layers'][_0x2d55('0x86')](_0x316d90[_0x2d55('0x560')])[_0x2d55('0x88a')](_0x472b95);},'getCenter':function(){return this[_0x2d55('0x700')][_0x2d55('0x66b')]();},'setCenter':function(_0x311ebf){return this['map'][_0x2d55('0x847')](_0x311ebf);},'getZoom':function(){return this[_0x2d55('0x700')][_0x2d55('0x570')]();},'getMinZoom':function(){return this[_0x2d55('0x700')][_0x2d55('0x616')]();},'getMaxZoom':function(){return this['map'][_0x2d55('0x549')]();},'setMaxZoom':function(_0x1d71b6){this[_0x2d55('0x700')]['setMaxZoom'](_0x1d71b6);},'setMinZoom':function(_0x838daf){this[_0x2d55('0x700')][_0x2d55('0x3e5')](_0x838daf);},'getExtent':function(){return this['map'][_0x2d55('0x164')]();},'getPitch':function(){return this[_0x2d55('0x700')][_0x2d55('0x661')]();},'setPitch':function(_0x4ded46){this[_0x2d55('0x700')][_0x2d55('0xe8')](_0x4ded46);},'getBearing':function(){return this[_0x2d55('0x700')][_0x2d55('0x472')]();},'setBearing':function(_0x539ae2){this['map']['setBearing'](_0x539ae2);},'getSize':function(){return this['map'][_0x2d55('0xbd')]();},'getBounds':function(){},'panToPoint':function(_0x541903,_0x479bdf){this[_0x2d55('0x700')]['panTo'](_0x541903);},'flyToPoint':function(_0x50eba5,_0x482841){this[_0x2d55('0x700')][_0x2d55('0x46')]({'center':_0x50eba5,'zoom':_0x482841[_0x2d55('0x398')]||this[_0x2d55('0x570')](),'pitch':_0x482841[_0x2d55('0xc3')]||this[_0x2d55('0x661')](),'bearing':_0x482841[_0x2d55('0x50d')]||this['getBearing']()},{'duration':_0x482841[_0x2d55('0x73b')]||0x7d0});},'isInBound':function(_0x546be0,_0x19cd61){},'setZoom':function(_0xd7f22,_0x30e2b5){this['map'][_0x2d55('0x2e5')](_0xd7f22,_0x30e2b5);},'setCenterAndZoom':function(_0x11d9bf,_0x1701bd){this[_0x2d55('0x700')]['setCenterAndZoom'](_0x11d9bf,_0x1701bd);},'setMaxExtent':function(_0x3c7978){this['map']['setMaxExtent'](_0x3c7978);},'fitExtent':function(_0x419bd7,_0x43bf18){this['map'][_0x2d55('0x25c')](_0x419bd7,_0x43bf18);},'fitBound':function(_0x577e8f){_0x577e8f=new maptalks[(_0x2d55('0x5fb'))](new maptalks[(_0x2d55('0x4b0'))](_0x577e8f[_0x2d55('0x2')],_0x577e8f[_0x2d55('0x746')]),new maptalks[(_0x2d55('0x4b0'))](_0x577e8f[_0x2d55('0x349')],_0x577e8f['latMax']));this[_0x2d55('0x700')][_0x2d55('0x25c')](_0x577e8f);},'on':function(_0x364f80,_0x3b3bdd){this['map']['on'](_0x364f80,_0x3b3bdd);},'getProjection':function(){return this['map'][_0x2d55('0x11c')]();},'coordinateToContainerPoint':function(_0x390425){return this[_0x2d55('0x700')][_0x2d55('0x615')](_0x390425);},'animateTo':function(_0x294284,_0x39d28a,_0x48a271){this[_0x2d55('0x700')][_0x2d55('0x46')](_0x294284,_0x39d28a,function(_0x48bc4b){_0x48a271&&_0x48a271(_0x48bc4b);});},'regDarkClickHandler':function(_0x15067c){this['controlList'][0x1][_0x2d55('0x808')](_0x15067c);},'removeDistanceOrArea':function(){this[_0x2d55('0x566')]['cj']['remove'](),this[_0x2d55('0x566')][_0x2d55('0x1ac')][_0x2d55('0x860')]();},'isInteracting':function(){return this[_0x2d55('0x700')][_0x2d55('0x1a3')]();},'getMap':function(){return this[_0x2d55('0x700')];},'getMapJson':function(){return this['map']['toJson']();},'distanceToPixel':function(_0x2624b1,_0x8e47ce){return this[_0x2d55('0x700')][_0x2d55('0x5c0')](_0x2624b1,_0x8e47ce);},'getDevicePixelRatio':function(){return this['map'][_0x2d55('0x54f')]();},'startRotateMap':function(_0x1b9718){var _0x36788d={'NNoYH':function(_0x31b0bd,_0x1b645b){return _0x31b0bd+_0x1b645b;}};return this[_0x2d55('0x714')]||(this[_0x2d55('0x714')]=this['map'][_0x2d55('0x46')]({'bearing':_0x36788d[_0x2d55('0x6d9')](this['map'][_0x2d55('0x472')](),0x168)},{'easing':_0x2d55('0x2d8'),'duration':_0x1b9718,'repeat':!0x0})),this['mapRotatePlayer']['play'](),this[_0x2d55('0x714')];},'pauseRotateMap':function(){this[_0x2d55('0x714')]&&this[_0x2d55('0x714')]['pause']();},'finishRotateMap':function(){this[_0x2d55('0x714')]&&(this[_0x2d55('0x714')][_0x2d55('0x3d3')](),this[_0x2d55('0x714')]=null);},'addTerrain':function(_0x364a05){this[_0x2d55('0xb0')]&&this[_0x2d55('0xb0')]['setTerrain'](_0x364a05);},'removeTerrain':function(){this[_0x2d55('0xb0')]&&this[_0x2d55('0xb0')][_0x2d55('0x567')](null);},'sortLayers':function(_0x231de3){this['map'][_0x2d55('0x73a')](_0x231de3);},'config':function(_0x3336b4,_0x5bf3f7){this[_0x2d55('0x700')][_0x2d55('0x524')](_0x3336b4,_0x5bf3f7);},'identify':function(_0xd29a90,_0x3ecdc2){this['map'][_0x2d55('0x703')](_0xd29a90,_0x3ecdc2);},'toJSON':function(){return this['map'][_0x2d55('0x49d')]();},'setMenu':function(_0x4dea4d){this[_0x2d55('0x700')]['setMenu'](_0x4dea4d);},'openMenu':function(){this['map'][_0x2d55('0x3ee')]();},'setPopContent':function(_0x194441){this['map']&&new maptalks['ui'][(_0x2d55('0x728'))](_0x194441)[_0x2d55('0x6ce')](this['map']);},'addControl':function(_0x145c2f){this[_0x2d55('0x700')][_0x2d55('0x2ec')](_0x145c2f);},'addToolbar':function(_0x216a0c){_0x216a0c['addTo'](this[_0x2d55('0x700')]);},'CLASS_NAME':_0x2d55('0x47a')}),maptalks[_0x2d55('0x731')]['prototype'][_0x2d55('0x32d')]=function(){const _0xf78ec=4.5,_0x577b13=0x0,_0x358901=0x0;var _0x2e75a3=this[_0x2d55('0x3e9')](),_0x31c126=this[_0x2d55('0x20b')]()[_0x2d55('0xbd')](),_0x2e75a3=(this['composer']=new THREE['EffectComposer'](_0x2e75a3),this['composer'][_0x2d55('0x154')](_0x31c126[_0x2d55('0x4f6')],_0x31c126[_0x2d55('0x347')]),this['getScene']()),_0x2b1601=this['getCamera'](),_0x2e75a3=(this[_0x2d55('0x8f')]=new THREE[(_0x2d55('0x52d'))](_0x2e75a3,_0x2b1601),this[_0x2d55('0x1b')][_0x2d55('0x79c')](this[_0x2d55('0x8f')]),this[_0x2d55('0x786')]=new THREE['UnrealBloomPass'](new THREE[(_0x2d55('0x81d'))](_0x31c126[_0x2d55('0x4f6')],_0x31c126['height'])));_0x2e75a3[_0x2d55('0x84a')]=!0x0,_0x2e75a3[_0x2d55('0x1d4')]=_0x577b13,_0x2e75a3[_0x2d55('0x1b6')]=_0xf78ec,_0x2e75a3[_0x2d55('0x84d')]=_0x358901,this['composer'][_0x2d55('0x79c')](_0x2e75a3),this[_0x2d55('0x41')]=!0x0;},maptalks[_0x2d55('0x731')][_0x2d55('0x4e2')][_0x2d55('0x264')]=function(){this[_0x2d55('0x32e')]()[_0x2d55('0x3c4')]=function(){var _0x3cb85c=this[_0x2d55('0x749')],_0x385e95=(_0x3cb85c[_0x2d55('0x7ab')](),this['_syncCamera'](),this[_0x2d55('0x135')]),_0x5bdada=this[_0x2d55('0x389')],_0x499c50=this['scene'];_0x3cb85c['bloomEnable']&&_0x3cb85c[_0x2d55('0x1b')]&&0x1<_0x3cb85c['composer']['passes'][_0x2d55('0x6e9')]?(_0x385e95['autoClear']&&(_0x385e95[_0x2d55('0x42b')]=!0x1),_0x3cb85c[_0x2d55('0x786')]&&_0x5bdada[_0x2d55('0x5df')][_0x2d55('0x218')](0x1),_0x3cb85c&&_0x3cb85c['composer']&&_0x3cb85c[_0x2d55('0x1b')][_0x2d55('0x423')](0x0),_0x385e95['clearDepth'](),_0x5bdada[_0x2d55('0x5df')][_0x2d55('0x218')](0x0)):_0x385e95['autoClear']||(_0x385e95[_0x2d55('0x42b')]=!0x0),_0x385e95[_0x2d55('0x423')](_0x499c50,_0x5bdada),this[_0x2d55('0x50e')]();};};class a extends maptalks[_0x2d55('0x888')]{constructor(_0x44bada,_0x19cc0c,_0x3e1c66,_0x21b57d){_0x19cc0c=maptalks[_0x2d55('0x84f')][_0x2d55('0x229')]({},{'speed':0.005,'radius':0x1,'altitude':0x0,'interactive':!0x1},_0x19cc0c,{'layer':_0x21b57d,'coordinate':_0x44bada}),super(),this[_0x2d55('0x7f2')](_0x19cc0c);var {altitude:_0x19cc0c,radius:_0x2ca473}=_0x19cc0c,_0x2ca473=_0x21b57d[_0x2d55('0x313')](_0x2ca473,_0x2ca473)['x'],_0x2ca473=new THREE[(_0x2d55('0x16a'))](0.001,_0x2ca473,0x14,0x5,0x0,0x2*Math['PI']),_0x2ca473=(this[_0x2d55('0x3')](),new THREE[(_0x2d55('0x774'))](_0x2ca473,_0x3e1c66)),_0x3e1c66=(this[_0x2d55('0xc7')]()[_0x2d55('0x69a')](_0x2ca473),_0x21b57d[_0x2d55('0x313')](_0x19cc0c,_0x19cc0c)['x']),_0x2ca473=_0x21b57d[_0x2d55('0x159')](_0x44bada,_0x3e1c66);this[_0x2d55('0xc7')]()[_0x2d55('0x463')][_0x2d55('0x10a')](_0x2ca473);}['_animation'](){var _0x364e3b=this[_0x2d55('0xc7')]()[_0x2d55('0x3db')][0x0],_0x22f0c4=this[_0x2d55('0x15b')]()['speed'];_0x364e3b[_0x2d55('0x233')]['uniforms'][_0x2d55('0xc4')][_0x2d55('0x2c')]+=_0x22f0c4;}}class d extends maptalks['BaseObject']{constructor(_0x147e22,_0x1a6d47,_0x5506e3,_0x573b1c){_0x1a6d47=maptalks['Util'][_0x2d55('0x229')]({},{'altitude':0x0},_0x1a6d47,{'layer':_0x573b1c}),super(),this[_0x2d55('0x7f2')](_0x1a6d47);_0x573b1c=new THREE[(_0x2d55('0x1e3'))](_0x147e22[_0x2d55('0xc7')]()[_0x2d55('0xe3')],0x1),_0x1a6d47=new THREE[(_0x2d55('0x5c5'))](_0x573b1c,_0x5506e3);this[_0x2d55('0x3')](),this[_0x2d55('0xc7')]()[_0x2d55('0x69a')](_0x1a6d47),this[_0x2d55('0xc7')]()['position'][_0x2d55('0x10a')](_0x147e22[_0x2d55('0xc7')]()[_0x2d55('0x463')]);}}const r=_0x2d55('0x28d');var n={'interactive':!0x1,'altitude':0x0};class o extends maptalks[_0x2d55('0x888')]{constructor(_0x32892d,_0x252cc1,_0x478161,_0x52c30c,_0x42bea6){var _0x19b551={'jufXz':function(_0x37a96d,_0x3ce1db,_0x56bd32){return _0x37a96d(_0x3ce1db,_0x56bd32);},'jTIvY':'altitude'};_0x252cc1=maptalks[_0x2d55('0x84f')]['extend']({},n,_0x252cc1,{'layer':_0x478161,'polygon':_0x32892d}),super(),this[_0x2d55('0x7f2')](_0x252cc1);var _0x3ad7e3=new THREE[(_0x2d55('0x1fc'))](),_0x52c30c=_0x3ad7e3['load'](_0x52c30c),_0x3ad7e3=(_0x52c30c[_0x2d55('0x529')]=_0x52c30c[_0x2d55('0x859')]=THREE[_0x2d55('0x317')],_0x3ad7e3[_0x2d55('0x58d')](_0x42bea6)),_0x42bea6=(_0x3ad7e3[_0x2d55('0x529')]=_0x3ad7e3['wrapT']=THREE[_0x2d55('0x317')],this[_0x2d55('0x233')]=new THREE['ShaderMaterial']({'fragmentShader':r,'uniforms':{'iTime':{'type':'f','value':0x0},'iResolution':{'type':'v3','value':new THREE[(_0x2d55('0x2ac'))](0x1,0x1,0x1)},'iChannel0':{'type':'t','value':_0x52c30c},'iChannel1':{'type':'t','value':_0x3ad7e3}}})),_0x52c30c=_0x478161[_0x2d55('0x20b')]()['getSize'](),_0x3ad7e3=(_0x42bea6[_0x2d55('0x534')]['iResolution']['value']['set'](_0x52c30c['width'],_0x52c30c[_0x2d55('0x347')],0x1),_0x19b551[_0x2d55('0x2d0')](l,_0x32892d,_0x478161)),_0x52c30c=(this[_0x2d55('0x2bc')](_0x3ad7e3,_0x42bea6),_0x252cc1)[_0x19b551[_0x2d55('0x676')]],_0x3ad7e3=_0x478161['distanceToVector3'](_0x52c30c,_0x52c30c)['x'],_0x42bea6=_0x32892d[_0x2d55('0x66b')](),_0x252cc1=_0x478161[_0x2d55('0x159')](_0x42bea6,_0x3ad7e3);this[_0x2d55('0xc7')]()[_0x2d55('0x463')][_0x2d55('0x10a')](_0x252cc1);}[_0x2d55('0x572')](){var _0x38b1ea={'EJuVf':function(_0x566c34,_0x261e14){return _0x566c34/_0x261e14;}};this[_0x2d55('0x233')]['uniforms'][_0x2d55('0x23f')]['value']+=_0x38b1ea[_0x2d55('0x4')](0x1,0x3c);}}function y(_0x2141f6,_0x217a3f,_0xfc1cf8){var _0x5b6ff3={'dPIxx':function(_0x28a591,_0x2afe5e){return _0x28a591<_0x2afe5e;}};var _0x26c8e9=(_0x2141f6=Array['isArray'](_0x2141f6)?new maptalks[(_0x2d55('0xfd'))](_0x2141f6):_0x2141f6)[_0x2d55('0x6ea')](),_0x2141f6=_0x2141f6['getHoles']();const _0x3691e8=[],_0x25308d=[],_0x2be749=[];_0x26c8e9[_0x2d55('0x457')](_0x3d3f58=>{_0x3d3f58=_0x217a3f[_0x2d55('0x159')](_0x3d3f58)[_0x2d55('0x243')](_0xfc1cf8);_0x3691e8[_0x2d55('0x590')](_0x3d3f58['x'],_0x3d3f58['y'],_0x3d3f58['z']),_0x2be749['push'](_0x3d3f58);}),_0x2141f6&&_0x5b6ff3[_0x2d55('0x79d')](0x0,_0x2141f6[_0x2d55('0x6e9')])&&_0x2141f6[_0x2d55('0x457')](_0x12b27e=>{_0x25308d[_0x2d55('0x590')](_0x2be749['length']),_0x12b27e[_0x2d55('0x457')](_0x370789=>{_0x370789=_0x217a3f[_0x2d55('0x159')](_0x370789)[_0x2d55('0x243')](_0xfc1cf8);_0x3691e8[_0x2d55('0x590')](_0x370789['x'],_0x370789['y'],_0x370789['z']),_0x2be749['push'](_0x370789);});});_0x26c8e9=_0x5b6ff3[_0x2d55('0x79d')](0x0,_0x25308d['length'])?_0x25308d:void 0x0,_0x2141f6=earcut(_0x3691e8,_0x26c8e9,0x3);return{'positionsV':_0x2be749,'faces':_0x2141f6};}function l(_0x287cb8,_0x27b744){var _0x3e6b72={'QpMnd':function(_0x3d7391,_0x462ccc){return _0x3d7391 instanceof _0x462ccc;},'XPrva':function(_0x1f1dc8,_0x254291,_0x379990,_0x18c0df){return _0x1f1dc8(_0x254291,_0x379990,_0x18c0df);},'iaPYS':function(_0x19fc2d,_0xeb4549){return _0x19fc2d<_0xeb4549;}};var _0x1a195f=new THREE[(_0x2d55('0x130'))]();let _0x2878b9=[],_0x513c47=[];var _0x5b0807=_0x27b744[_0x2d55('0x159')](_0x287cb8[_0x2d55('0x66b')]());if(_0x3e6b72[_0x2d55('0x63')](_0x287cb8,maptalks[_0x2d55('0xfd')])){var {positionsV:_0x5507b7,faces:_0x2cbb9e}=_0x3e6b72['XPrva'](y,_0x287cb8,_0x27b744,_0x5b0807);_0x2878b9=_0x5507b7,_0x513c47=_0x2cbb9e;}else{var _0x4034f0=_0x287cb8[_0x2d55('0x601')]();for(let _0x27b95d=0x0,_0x4521fb=_0x4034f0[_0x2d55('0x6e9')];_0x27b95d<_0x4521fb;_0x27b95d++){var {positionsV:_0x35be1f,faces:_0x502857}=y(_0x4034f0[_0x27b95d],_0x27b744,_0x5b0807);if(_0x3e6b72[_0x2d55('0x2e0')](0x0,_0x27b95d)){var _0x431b46=_0x2878b9[_0x2d55('0x6e9')];for(let _0x31e252=0x0,_0x19752b=_0x502857[_0x2d55('0x6e9')];_0x3e6b72[_0x2d55('0x2e0')](_0x31e252,_0x19752b);_0x31e252++)_0x502857[_0x31e252]+=_0x431b46;}_0x35be1f[_0x2d55('0x457')](_0x5e682a=>{_0x2878b9[_0x2d55('0x590')](_0x5e682a);}),_0x502857[_0x2d55('0x457')](_0x4c5256=>{_0x513c47[_0x2d55('0x590')](_0x4c5256);});}}_0x1a195f['vertices']=_0x2878b9;for(let _0x2338fb=0x0,_0x2f70d4=_0x513c47['length'];_0x3e6b72[_0x2d55('0x2e0')](_0x2338fb,_0x2f70d4);_0x2338fb+=0x3){var _0x177e97=new THREE['Face3'](_0x513c47[_0x2338fb],_0x513c47[_0x2338fb+0x1],_0x513c47[_0x2338fb+0x2]);_0x1a195f['faces']['push'](_0x177e97);}return _0x1a195f[_0x2d55('0x41e')](),_0x1a195f[_0x2d55('0x244')](),_0x1a195f;}BDLayers[_0x2d55('0x5fd')]['Overlays']['VMarkerRingEff']=BDLayers[_0x2d55('0x2ca')]({'options':{'speed':0.005,'radius':0x1,'altitude':0x0,'interactive':!0x1,'color':_0x2d55('0x642')},'id':null,'marker':null,'initialize':function(_0x140745,_0x2b232b,_0x42073b,_0x512b72){BDLayers['Util']['extend'](this,{'handlers':{},'_triggeringCount':0x0}),_0x42073b&&BDLayers[_0x2d55('0x84f')][_0x2d55('0x222')](this,_0x42073b),this['id']=_0x140745,this[_0x2d55('0x8a0')]=new a(_0x2b232b,{'radius':this[_0x2d55('0x4f3')][_0x2d55('0x84d')],'speed':this[_0x2d55('0x4f3')][_0x2d55('0x6b3')],'altitude':this[_0x2d55('0x4f3')]['altitude'],'interactive':this['options'][_0x2d55('0x262')]},this[_0x2d55('0x5cc')](),_0x512b72);},'getMarker':function(){return this[_0x2d55('0x8a0')];},'getId':function(){return id;},'getMateriral':function(_0x1a06fd=0x0){var _0x212e43={'sJNSt':function(_0x10d63c,_0x34222b){return _0x10d63c||_0x34222b;}};_0x1a06fd={'uniforms':{'color':{'type':'c','value':new THREE[(_0x2d55('0x788'))](this[_0x2d55('0x4f3')][_0x2d55('0x18f')])},'time':{'type':'f','value':-1.5},'type':{'type':'f','value':_0x212e43[_0x2d55('0x5f9')](_0x1a06fd,0x0)},'num':{'type':'f','value':0x4}},'vertexShaderSource':_0x2d55('0x6ee'),'fragmentShaderSource':_0x2d55('0x1e2')};return new THREE[(_0x2d55('0x24a'))]({'uniforms':_0x1a06fd['uniforms'],'defaultAttributeValues':{},'vertexShader':_0x1a06fd[_0x2d55('0x176')],'fragmentShader':_0x1a06fd[_0x2d55('0x651')],'blending':THREE['AdditiveBlending'],'depthWrite':!0x1,'depthTest':!0x0,'side':THREE[_0x2d55('0x797')],'transparent':!0x0,'fog':!0x0});},'CLASS_NAME':_0x2d55('0x3d2')}),BDLayers['LibViz'][_0x2d55('0x404')][_0x2d55('0x9d')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'initialize':function(_0x4beb31,_0x3fce9f,_0xd9e2d8){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this['options'],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x4beb31,_0xd9e2d8),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x9d'))](_0x4beb31,_0x3fce9f,{'heatValueScale':this[_0x2d55('0x4f3')]['heatValueScale']||0.7,'forceRenderOnRotating':this[_0x2d55('0x4f3')][_0x2d55('0x3df')]||!0x0,'forceRenderOnMoving':this['options'][_0x2d55('0x4aa')]||!0x0}),this[_0x2d55('0x533')]('created',this);},'CLASS_NAME':_0x2d55('0x302')}),BDLayers[_0x2d55('0x5fd')][_0x2d55('0x404')][_0x2d55('0x3f8')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBLayer'],{'actor':null,'vectortilelayer':null,'style':null,'initialize':function(_0x1e17a3,_0x5e740c){var _0x164d28={'stLaG':function(_0x575cb0,_0x1f758d,_0x2ee315,_0x3b9cfd,_0x438f2c){return _0x575cb0(_0x1f758d,_0x2ee315,_0x3b9cfd,_0x438f2c);},'BayPX':function(_0x43a031,_0x28405f){return _0x43a031(_0x28405f);},'nrWaC':_0x2d55('0xba')};BDLayers[_0x2d55('0x84f')]['extend'](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers['Lib']['Layer']['CBLayer'][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x1e17a3,_0x5e740c),_0x5e740c[_0x2d55('0x3a7')]&&(this[_0x2d55('0x3a7')]=_0x5e740c[_0x2d55('0x3a7')]),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0});var _0x2ddd4d=this;this[_0x2d55('0x749')][_0x2d55('0x82b')]=function(_0x12cfa7,_0x50652a,_0x4a8fd5){var _0x316982={'aTMad':function(_0x11a07a,_0x34c92f,_0x5ad65b,_0x8abc92,_0x1a1884){return _0x164d28['stLaG'](_0x11a07a,_0x34c92f,_0x5ad65b,_0x8abc92,_0x1a1884);},'yuZqv':function(_0x455dbc,_0x45d8dd){return _0x164d28[_0x2d55('0x883')](_0x455dbc,_0x45d8dd);},'SYlqC':_0x164d28[_0x2d55('0x418')]};var _0x417bd1=new THREE[(_0x2d55('0xa5'))](0xffffff);_0x417bd1[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa)['normalize'](),_0x50652a[_0x2d55('0x69a')](_0x417bd1),_0x2ddd4d[_0x2d55('0x76e')]=_0x2ddd4d[_0x2d55('0x749')][_0x2d55('0x824')](_0x2ddd4d[_0x2d55('0x4f3')][_0x2d55('0x3a8')],{'subdomains':['a','b','c','d'],'debug':!0x1,'interactive':!0x1,'worker':!0x1,'showHeight':_0x2ddd4d['options'][_0x2d55('0x295')]||!0x1},_0x2ddd4d[_0x2d55('0x36d')][_0x2d55('0x7cf')](this)),_0x2ddd4d[_0x2d55('0x76e')][_0x2d55('0x5c6')]=function(_0x1b5b2e){var _0x4a6b18={'ptDZl':function(_0xdc08bf,_0x1543f5,_0xa89632,_0x57d50d){return _0xdc08bf(_0x1543f5,_0xa89632,_0x57d50d);}};const {key:_0x41a8d7,url:_0x55245f,callback:_0x375080,img:_0x4658c8}=_0x1b5b2e;_0x1b5b2e=_0x41a8d7[_0x2d55('0x202')]('_')?'_':'-';let [,_0x1311a6,_0x523bc2,_0x18bf9c]=_0x41a8d7[_0x2d55('0x77c')](_0x1b5b2e);_0x523bc2=_0x316982[_0x2d55('0x113')](parseInt,_0x523bc2),_0x1311a6=_0x316982[_0x2d55('0x113')](parseInt,_0x1311a6),_0x18bf9c=parseInt(_0x18bf9c),axios[_0x2d55('0x86')](_0x55245f,{'timeout':0x2710,'responseType':_0x316982[_0x2d55('0x84b')]})[_0x2d55('0x37f')](function(_0x3b516b){_0x3b516b=_0x316982[_0x2d55('0x817')](mvt2GeoJSON,_0x3b516b[_0x2d55('0x10c')],_0x523bc2,_0x1311a6,_0x18bf9c);console[_0x2d55('0x10b')](_0x3b516b),_0x375080(_0x41a8d7,_0x3b516b,_0x4658c8);})[_0x2d55('0x5b5')](function(_0x4e539d){_0x4a6b18[_0x2d55('0x1eb')](_0x375080,_0x41a8d7,null,_0x4658c8);})[_0x2d55('0xa8')](()=>{});},_0x2ddd4d[_0x2d55('0x700')][_0x2d55('0x197')](_0x2ddd4d[_0x2d55('0x76e')]),_0x2ddd4d[_0x2d55('0x5d1')]();}[_0x2d55('0x7cf')](this),this[_0x2d55('0x533')](_0x2d55('0x501'),this),this[_0x2d55('0x4d6')]=_0x2d55('0x834');},'getMaterial':function(_0x920634,_0x28f8c9,_0x371b2d,_0x5b8377){var _0x11c24c=null;try{this[_0x2d55('0x3a7')]['forEach'](_0x73f6f7=>{_0x73f6f7[_0x2d55('0x3b1')]==_0x920634&&(_0x11c24c=this[_0x2d55('0x65b')](_0x73f6f7));});}catch(_0x2d53fb){console[_0x2d55('0x7c2')](_0x2d53fb);}return _0x11c24c;},'getStyleFormType':function(_0x324210){var _0x1c9b73={'bxqmr':_0x2d55('0x3e0'),'XFSBS':'toFat','JNKcc':_0x2d55('0x4b6'),'vXIbm':_0x2d55('0x512'),'Jtybb':_0x2d55('0x171')};switch(_0x324210[_0x2d55('0x6c4')]){case _0x2d55('0x2a6'):return{'color':_0x324210['color']||'black','fontSize':_0x324210[_0x2d55('0x6c0')]||0xc,'altitude':_0x324210['altitude']||0x3};case _0x1c9b73['bxqmr']:var _0x5d222e=_0x2d55('0x300');return _0x324210['dash']&&0x1==_0x324210[_0x2d55('0x7c6')]?(_0x5d222e=_0x2d55('0x5cb'),(_0x4042bf=new THREE[(_0x2d55('0x5a7'))]({'color':_0x324210['color'],'transparent':_0x324210[_0x2d55('0x4bf')],'opacity':_0x324210['opacity'],'linewidth':_0x324210['linewidth'],'dashSize':0.2,'gapSize':0.2,'dashed':!0x0}))[_0x2d55('0x3b4')][_0x2d55('0x354')]=''):_0x4042bf=_0x324210[_0x2d55('0x3ac')]?((_0x23337f=new THREE[(_0x2d55('0x1fc'))]()[_0x2d55('0x58d')](_0x324210[_0x2d55('0x3ac')]))[_0x2d55('0x857')]=0x10,_0x23337f[_0x2d55('0x529')]=THREE[_0x2d55('0x317')],_0x23337f[_0x2d55('0x859')]=THREE[_0x2d55('0x317')],this[_0x2d55('0x749')]['getCamera'](),new MeshLineMaterial({'map':_0x23337f,'useMap':!0x0,'lineWidth':_0x324210[_0x2d55('0x36e')],'sizeAttenuation':!0x1,'transparent':!0x0})):(_0x5d222e=_0x1c9b73[_0x2d55('0x237')],new THREE['LineMaterial']({'color':_0x324210[_0x2d55('0x18f')],'transparent':_0x324210[_0x2d55('0x4bf')],'opacity':_0x324210['opacity'],'linewidth':_0x324210['linewidth']})),{'linematerial':_0x4042bf,'toModel':_0x5d222e,'showText':_0x324210[_0x2d55('0x734')]&&!0x1,'txtmaterial':{'color':_0x324210[_0x2d55('0x31a')]||_0x2d55('0x171'),'fontSize':_0x324210['fontSize']||0xc,'altitude':_0x324210['fontAltitude']||0x3}};case _0x1c9b73[_0x2d55('0x402')]:var _0x5d222e='toFat',_0x23337f=new THREE[(_0x2d55('0x5a7'))]({'color':_0x324210[_0x2d55('0x38e')],'transparent':_0x324210[_0x2d55('0x4bf')],'opacity':_0x324210[_0x2d55('0x69c')],'linewidth':_0x324210['dashlinewidth'],'dashSize':0.1,'gapSize':0.1,'dashed':!0x0}),_0x4042bf=(_0x23337f['defines']['USE_DASH']='',new THREE[(_0x2d55('0x5a7'))]({'color':_0x324210[_0x2d55('0x7bc')],'transparent':_0x324210[_0x2d55('0x4bf')],'opacity':_0x324210[_0x2d55('0x69c')],'linewidth':_0x324210[_0x2d55('0x7fe')]}));return{'dashlinematerial':_0x23337f,'bglinematerial':_0x4042bf,'toModel':_0x5d222e};case _0x1c9b73[_0x2d55('0x2f7')]:return{'polygonmaterial':new THREE[(_0x2d55('0x81c'))]({'color':_0x324210[_0x2d55('0x18f')],'transparent':_0x324210[_0x2d55('0x4bf')],'opacity':_0x324210['opacity']}),'showText':_0x324210[_0x2d55('0x734')]&&!0x1,'txtmaterial':{'color':_0x324210['fontColor']||_0x1c9b73[_0x2d55('0x71')],'fontSize':_0x324210[_0x2d55('0x6c0')]||0xc,'altitude':_0x324210[_0x2d55('0x896')]||0x3}};default:return null;}},'updateSybml':function(_0x21872b){this[_0x2d55('0x3a7')]=_0x21872b;},'show':function(){this[_0x2d55('0x76e')][_0x2d55('0x6a0')]();},'hide':function(){this[_0x2d55('0x76e')][_0x2d55('0x45d')]();},'animation':function(){var _0x7f4d0b={'LdZuN':function(_0x464058,_0x11559b){return _0x464058(_0x11559b);}};this[_0x2d55('0x700')][_0x2d55('0x122')]()||this[_0x2d55('0x700')][_0x2d55('0x153')]()||this[_0x2d55('0x700')][_0x2d55('0x782')]()||(this[_0x2d55('0x749')][_0x2d55('0x5d8')]=!this[_0x2d55('0x749')][_0x2d55('0x5d8')],this[_0x2d55('0x749')][_0x2d55('0x5d8')]&&this[_0x2d55('0x749')]['renderScene']()),_0x7f4d0b[_0x2d55('0x5d2')](requestAnimationFrame,this[_0x2d55('0x5d1')][_0x2d55('0x7cf')](this));},'CLASS_NAME':_0x2d55('0x834')}),BDLayers['LibViz'][_0x2d55('0x404')][_0x2d55('0x885')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'extendLayer':null,'vertexShader':null,'fragmentShader':null,'meshs':[],'initialize':function(_0x46352d,_0x275cb9){var _0x2c2605={'aRALv':_0x2d55('0x59f'),'ZaUPR':'/img/skybox/02/','joIxI':function(_0x1c6fcd,_0x4eb783){return _0x1c6fcd+_0x4eb783;},'HkgQl':_0x2d55('0x71c'),'dAmEZ':_0x2d55('0x2bb'),'VVsbb':function(_0x161df4,_0x8fa637){return _0x161df4+_0x8fa637;},'PrDuy':'ypos.jpg','xtjhY':function(_0x4e56bf,_0x2e89f3){return _0x4e56bf+_0x2e89f3;},'KMCFs':_0x2d55('0x618'),'SCekb':function(_0x4e1c17,_0x1935bd){return _0x4e1c17+_0x1935bd;},'pglKh':_0x2d55('0x5b8'),'xkbvd':'zneg.jpg','VNviI':_0x2d55('0x501')};this[_0x2d55('0x842')]=_0x2d55('0x345'),this[_0x2d55('0x6e1')]='\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20vec3\x20topColor;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20vec3\x20skylineColor;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20vec3\x20bottomColor;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20float\x20offset;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20float\x20exponent;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20uniform\x20vec3\x20skyCenter;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20varying\x20vec3\x20vWorldPosition;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20void\x20main()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20vec3\x20position\x20=\x20vec3(vWorldPosition.x\x20-\x20skyCenter.x,\x20vWorldPosition.y\x20-\x20skyCenter.y,\x20vWorldPosition.z\x20-\x20skyCenter.z);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20float\x20h\x20=\x20normalize(\x20position\x20+\x20offset\x20).y;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20vec3\x20color;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(h\x20>\x200.0)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color\x20=\x20mix(\x20skylineColor,\x20topColor,\x20max(\x20pow(\x20max(\x20h,\x200.0\x20),\x20exponent\x20),\x200.0\x20)\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color\x20=\x20mix(\x20skylineColor,\x20bottomColor,\x20max(\x20pow(\x20max(\x20-h,\x200.0\x20),\x20exponent\x20),\x200.0\x20)\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20gl_FragColor\x20=\x20vec4(color\x20,\x201.0\x20);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}',BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')]['options']),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x46352d,_0x275cb9),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0});var _0x2a3c3b=this;this['layer'][_0x2d55('0x82b')]=function(_0xba98aa,_0x6e9356,_0x9d612){_0x2a3c3b[_0x2d55('0x749')][_0x2d55('0x20a')](-0x3e8);var _0x155dc3=new THREE[(_0x2d55('0xa5'))](0xffffff),_0x155dc3=(_0x155dc3[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa)['normalize'](),_0x6e9356[_0x2d55('0x69a')](_0x155dc3),_0x9d612[_0x2d55('0x69a')](new THREE[(_0x2d55('0x6c8'))](_0x2c2605[_0x2d55('0x770')],0x2)),_0x2c2605[_0x2d55('0x5a9')]),_0x9d612=[_0x2c2605[_0x2d55('0x1f3')](_0x155dc3,_0x2c2605[_0x2d55('0x13c')]),_0x155dc3+_0x2c2605[_0x2d55('0x77d')],_0x2c2605[_0x2d55('0x4ff')](_0x155dc3,_0x2c2605[_0x2d55('0x515')]),_0x2c2605[_0x2d55('0x9')](_0x155dc3,_0x2c2605['KMCFs']),_0x2c2605[_0x2d55('0x422')](_0x155dc3,_0x2c2605['pglKh']),_0x155dc3+_0x2c2605['xkbvd']],_0x155dc3=null,_0x155dc3=_0x275cb9[_0x2d55('0x4ec')]?new THREE[(_0x2d55('0x6e7'))]()[_0x2d55('0x58d')](_0x275cb9[_0x2d55('0x4ec')]):new THREE['CubeTextureLoader']()[_0x2d55('0x58d')](_0x9d612);_0x6e9356['background']=_0x155dc3,_0x6e9356[_0x2d55('0x52')]['x']=-Math['PI']/0x2,_0x2a3c3b[_0x2d55('0x5d1')]();}[_0x2d55('0x7cf')](this),this[_0x2d55('0x533')](_0x2c2605[_0x2d55('0x4a6')],this);},'createSky':function(_0xad962=0xfa0,_0x426ba1=0x20,_0x187444=0xf,_0x4f3992=new THREE[(_0x2d55('0x2ac'))]()){_0x4f3992={'topColor':{'value':new THREE['Color'](0x86b6f5)},'skylineColor':{'value':new THREE[(_0x2d55('0x788'))](0xffffff)},'bottomColor':{'value':new THREE['Color'](0x999999)},'offset':{'value':0x190},'exponent':{'value':0.9},'skyCenter':{'value':_0x4f3992||new THREE[(_0x2d55('0x2ac'))]()}},_0xad962=new THREE['SphereBufferGeometry'](_0xad962,_0x426ba1,_0x187444),_0x426ba1=new THREE['ShaderMaterial']({'uniforms':_0x4f3992,'vertexShader':this[_0x2d55('0x842')],'fragmentShader':this[_0x2d55('0x6e1')],'side':THREE[_0x2d55('0x2b0')]}),_0x187444=new THREE[(_0x2d55('0x774'))](_0xad962,_0x426ba1);return _0x187444[_0x2d55('0x20e')]=_0x2d55('0x893'),_0x187444[_0x2d55('0x863')][_0x2d55('0x343')]=!0x1,_0x187444;},'animation':function(){var _0x493011={'dRsXq':function(_0x2ba1fb,_0x162c48){return _0x2ba1fb(_0x162c48);}};this[_0x2d55('0x749')]['_needsUpdate']=!this[_0x2d55('0x749')]['_needsUpdate'],this[_0x2d55('0x749')]['_needsUpdate']&&this[_0x2d55('0x749')][_0x2d55('0x3c4')](),_0x493011['dRsXq'](requestAnimationFrame,this[_0x2d55('0x5d1')][_0x2d55('0x7cf')](this));},'CLASS_NAME':'BDLayers.LibViz.Layer.SkyBoxLayer'}),BDLayers[_0x2d55('0x5fd')][_0x2d55('0x404')]['VMarkerLayer']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'markers':null,'initialize':function(_0x2cf56b,_0x58f045){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x2cf56b,_0x58f045),this[_0x2d55('0x768')]=new HashMap(),this['layer']=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0});this['layer']['prepareToDraw']=function(_0x56cc07,_0x4f2a98,_0x2e4b08){var _0xbb8a40=new THREE[(_0x2d55('0xa5'))](0xffffff);_0xbb8a40[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa)['normalize'](),_0x4f2a98[_0x2d55('0x69a')](_0xbb8a40);}['bind'](this);},'addMarker':function(_0x387499,_0xd92a05,_0x195cab){var _0x2702fe={'GKeip':function(_0x5e02c0,_0x3b0f3f){return _0x5e02c0==_0x3b0f3f;},'aptKE':_0x2d55('0xb5')};if(_0x2702fe['GKeip'](_0x2702fe[_0x2d55('0x26')],_0x195cab[_0x2d55('0x6c4')])){_0xd92a05=new BDLayers[(_0x2d55('0x5fd'))]['Overlays'][(_0x2d55('0x581'))](_0x387499,_0xd92a05,_0x195cab,this[_0x2d55('0x749')]);this[_0x2d55('0x768')][_0x2d55('0x63c')](_0x387499,_0xd92a05);for(var _0x4c267f=0x0;_0x4c267f<this['markers']['values']()[_0x2d55('0x6e9')];_0x4c267f++)this[_0x2d55('0x768')][_0x2d55('0x644')]()[_0x4c267f]['id']===_0x387499&&this[_0x2d55('0x749')][_0x2d55('0x823')](this['markers'][_0x2d55('0x644')]()[_0x4c267f][_0x2d55('0x8a0')]);this[_0x2d55('0x5d1')]();}},'removeMarker':function(_0x181b1b){var _0x25246f=this[_0x2d55('0x768')]['get'](_0x181b1b);_0x25246f&&(this['layer'][_0x2d55('0x80e')](_0x25246f[_0x2d55('0x8a0')]),this[_0x2d55('0x768')][_0x2d55('0x860')](_0x181b1b));},'removeAll':function(){var _0x233092={'xVSBP':function(_0x4c14cb,_0x301b51){return _0x4c14cb<_0x301b51;}};for(var _0x313ec0=0x0;_0x233092[_0x2d55('0x571')](_0x313ec0,this['markers'][_0x2d55('0x644')]()[_0x2d55('0x6e9')]);_0x313ec0++)this[_0x2d55('0x749')][_0x2d55('0x80e')](this[_0x2d55('0x768')]['values']()[_0x313ec0]['marker']);this[_0x2d55('0x749')][_0x2d55('0x7a5')](),this[_0x2d55('0x768')][_0x2d55('0x7a5')]();},'animation':function(){var _0x2b16ab={'vlfel':function(_0x417087,_0x5afb8f){return _0x417087(_0x5afb8f);}};this[_0x2d55('0x749')][_0x2d55('0x5d8')]=!this['layer']['_needsUpdate'],this[_0x2d55('0x749')][_0x2d55('0x5d8')]&&this[_0x2d55('0x749')][_0x2d55('0x3c4')](),_0x2b16ab[_0x2d55('0x7c7')](requestAnimationFrame,this[_0x2d55('0x5d1')]['bind'](this));},'CLASS_NAME':_0x2d55('0x89f')}),BDLayers[_0x2d55('0x5fd')][_0x2d55('0x404')]['VBloomLayer']=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')],{'bloomMeshMap':null,'initialize':function(_0x3d9669,_0x2ad15b){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x3d9669,_0x2ad15b),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0});this['bloomMeshMap']=new HashMap(),this[_0x2d55('0x749')]['prepareToDraw']=function(_0x379b3e,_0x30e67a,_0x2edf94){var _0x49658b=new THREE[(_0x2d55('0xa5'))](0xffffff);_0x49658b[_0x2d55('0x463')]['set'](0x0,-0xa,0xa)[_0x2d55('0xec')](),_0x30e67a[_0x2d55('0x69a')](_0x49658b),this[_0x2d55('0x749')][_0x2d55('0x32d')](),this[_0x2d55('0x749')][_0x2d55('0x264')](),this[_0x2d55('0x5d1')]();}[_0x2d55('0x7cf')](this);},'addGeom':function(_0x1f6d00,_0x203892,_0x4086b5,_0x22785){var _0x266eda={'pysgc':function(_0x25bd95,_0x45f176){return _0x25bd95<_0x45f176;},'xgYnl':_0x2d55('0x852')};var _0x156579=this,_0x22785=_0x22785||bdmap[_0x2d55('0x784')][_0x2d55('0x2ae')][_0x2d55('0x92')]();axios['get'](_0x203892,{'timeout':0x2710,'responseType':_0x266eda[_0x2d55('0x830')],'headers':{'X-ACCESS-TOKEN':_0x22785}})[_0x2d55('0x37f')](function(_0x1ce744){_0x1ce744[_0x2d55('0x10c')][_0x2d55('0x286')][_0x2d55('0x53')]&&_0x266eda['pysgc'](0x0,_0x1ce744[_0x2d55('0x10c')]['result']['records'][_0x2d55('0x6e9')])&&_0x1ce744[_0x2d55('0x10c')][_0x2d55('0x286')]['records']['forEach'](function(_0x59bdd5){_0x156579[_0x2d55('0x224')](_0x1f6d00,JSON[_0x2d55('0x114')](_0x59bdd5[_0x2d55('0x15a')]),_0x4086b5),_0x156579[_0x2d55('0x749')][_0x2d55('0x48')]();});})[_0x2d55('0x5b5')](function(_0x22bd01){console[_0x2d55('0x10b')](_0x22bd01);})[_0x2d55('0xa8')](()=>{});},'addExtrudePolygon':function(_0x5eba1b,_0xda4344,_0x56d1de){var _0x362350={'gcBFx':function(_0x2b9b5a,_0x6d4726){return _0x2b9b5a===_0x6d4726;},'fAUBC':'MultiPolygon','ekCoq':_0x2d55('0xfd'),'MmTny':function(_0x2298e2,_0x14495f){return _0x2298e2!==_0x14495f;},'JaubM':_0x2d55('0x415'),'BsuMc':function(_0x496fbe,_0x19c26f){return _0x496fbe===_0x19c26f;},'zQEOT':_0x2d55('0x251'),'Krxql':function(_0x27a7c8,_0x4e6386){return _0x27a7c8/_0x4e6386;}};var _0x16f3b5=[],_0x2edd25=new THREE[(_0x2d55('0x5a7'))]({'color':_0x56d1de[_0x2d55('0x18f')],'transparent':!0x0,'linewidth':0x2});_0xda4344[_0x2d55('0x759')]['slice'](0x0,_0x362350[_0x2d55('0x45c')](0x1,0x0))[_0x2d55('0x457')](_0x3583e9=>{const _0xb7feb=[];_0x3583e9=_0x3583e9[_0x2d55('0xe3')];_0x362350[_0x2d55('0x2fc')](_0x362350['fAUBC'],_0x3583e9[_0x2d55('0x6c4')])?_0x3583e9[_0x2d55('0x537')][_0x2d55('0x457')](_0xdb35eb=>{_0xb7feb[_0x2d55('0x590')](new maptalks[(_0x2d55('0x251'))](_0xdb35eb[0x0]));}):_0x362350[_0x2d55('0x2fc')](_0x362350[_0x2d55('0x23c')],_0x3583e9['type'])?_0xb7feb[_0x2d55('0x590')](new maptalks[(_0x2d55('0x251'))](_0x3583e9[_0x2d55('0x537')][0x0])):_0x362350['MmTny'](_0x362350[_0x2d55('0x28b')],_0x3583e9[_0x2d55('0x6c4')])&&_0x362350[_0x2d55('0x338')](_0x362350[_0x2d55('0x39a')],_0x3583e9[_0x2d55('0x6c4')])&&_0xb7feb['push'](new maptalks['LineString'](_0x3583e9[_0x2d55('0x537')])),_0xb7feb[_0x2d55('0x457')](_0x320777=>{_0x320777=this[_0x2d55('0x749')]['toFatLine'](_0x320777,{'altitude':_0x56d1de[_0x2d55('0xab')],'interactive':!0x1},_0x2edd25);_0x56d1de[_0x2d55('0x357')]&&_0x320777[_0x2d55('0xc7')]()[_0x2d55('0x5df')][_0x2d55('0x1f8')](0x1),_0x16f3b5[_0x2d55('0x590')](_0x320777);});}),this['layer'][_0x2d55('0x823')](_0x16f3b5),this[_0x2d55('0x5d1')]();},'removeGeom':function(_0x9b9964){},'animation':function(){this['layer'][_0x2d55('0x5d8')]=!this[_0x2d55('0x749')][_0x2d55('0x5d8')],this['layer'][_0x2d55('0x5d8')]&&this['layer']['renderScene'](),requestAnimationFrame(this['animation'][_0x2d55('0x7cf')](this));},'CLASS_NAME':'BDLayers.LibViz.Layer.VBloomLayer'}),BDLayers[_0x2d55('0x5fd')]['Layer'][_0x2d55('0x745')]=BDLayers['Class'](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')]['CBLayer'],{'lines':null,'linesAll':[],'terrains':null,'sceneConfig':{},'intervelLines':null,'initialize':function(_0x2d7c5d,_0x3319a0,_0x4f5595){var _0x186fca={'hGfXn':_0x2d55('0x59f'),'oPCly':_0x2d55('0x5d1')};BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')]['__proto__'][_0x2d55('0x4f3')]),BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x2d7c5d,_0x3319a0),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0});var _0x572942=this;_0x572942['layer'][_0x2d55('0x82b')]=function(_0x55b935,_0x150ed8,_0x46e9fd){var _0x203eb4=new THREE[(_0x2d55('0xa5'))](0xffffff);_0x203eb4[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa)[_0x2d55('0xec')](),_0x150ed8[_0x2d55('0x69a')](_0x203eb4),_0x150ed8[_0x2d55('0x69a')](new THREE[(_0x2d55('0x833'))](_0x186fca[_0x2d55('0x3da')],0.2)),_0x572942[_0x2d55('0x749')][_0x2d55('0x524')](_0x186fca['oPCly'],!0x0),_0x3319a0[_0x2d55('0x318')]&&_0x572942['addLines'](_0x3319a0[_0x2d55('0x318')],_0x3319a0[_0x2d55('0x18f')],_0x3319a0[_0x2d55('0x52b')]);}['bind'](this),_0x572942[_0x2d55('0x392')]={'postProcess':{'enable':!0x0,'antialias':{'enable':!0x0},'bloom':{'enable':!0x0,'threshold':0x0,'factor':0x1,'radius':0.02}}},_0x4f5595[_0x2d55('0xb0')]&&_0x4f5595['_glSence'][_0x2d55('0x18')](_0x572942[_0x2d55('0x392')]),_0x4f5595['_glSence']&&_0x4f5595[_0x2d55('0xb0')][_0x2d55('0x197')](_0x572942[_0x2d55('0x749')]);},'addLines':function(_0x267c64,_0x372c10,_0x52750d,_0x72e3d8){var _0x32cb4a={'WXTsg':function(_0x20b3b8,_0x1f48bf,_0x114178,_0x1b5064){return _0x20b3b8(_0x1f48bf,_0x114178,_0x1b5064);},'SGtAQ':function(_0x4a9dd5,_0x11c33d){return _0x4a9dd5||_0x11c33d;},'bZcaB':function(_0xbaf23e,_0x504570){return _0xbaf23e||_0x504570;}};_0x372c10=new THREE['LineBasicMaterial']({'linewidth':0x1,'color':_0x372c10||_0x32cb4a[_0x2d55('0x51f')](rgb,0xfa,0x0,0x0),'opacity':_0x32cb4a[_0x2d55('0x434')](_0x52750d,0x1),'transparent':_0x32cb4a[_0x2d55('0x715')](_0x72e3d8,!0x0),'blending':THREE['AdditiveBlending']});this[_0x2d55('0x6b2')]=this['layer']['toLines'](_0x267c64[_0x2d55('0x759')],{'altitude':0x0,'bloom':!0x0},_0x372c10),this[_0x2d55('0x749')][_0x2d55('0x823')](this[_0x2d55('0x6b2')]),this[_0x2d55('0x527')]['push'](this[_0x2d55('0x6b2')]);},'removeAll':function(){this[_0x2d55('0x527')][_0x2d55('0x457')](_0x3493df=>{this['layer'][_0x2d55('0x80e')](_0x3493df);}),this[_0x2d55('0x527')]=[];},'lineFlicker':function(_0x18faec){var _0x11b90e={'LOrFE':function(_0x49fd35,_0x1778ad){return _0x49fd35(_0x1778ad);},'OAcsw':function(_0x38cf52,_0x288d40,_0x4b7969){return _0x38cf52(_0x288d40,_0x4b7969);},'qAtkG':function(_0x814fe2,_0x549934){return _0x814fe2||_0x549934;}};this[_0x2d55('0xd0')]&&_0x11b90e[_0x2d55('0xe7')](clearInterval,this[_0x2d55('0xd0')]);let _0x184574=!0x0;this[_0x2d55('0xd0')]=_0x11b90e['OAcsw'](setInterval,()=>{_0x184574=_0x184574?this[_0x2d55('0x392')][_0x2d55('0x66d')][_0x2d55('0xc6')][_0x2d55('0x1f8')]=!0x1:this['sceneConfig']['postProcess']['bloom']['enable']=!0x0;},_0x11b90e[_0x2d55('0x453')](_0x18faec,0xc8));},'cancelLineFlicker':function(){var _0x1c9bfb={'PfPJg':function(_0x31078d,_0x17c496){return _0x31078d(_0x17c496);}};_0x1c9bfb[_0x2d55('0x668')](clearInterval,this[_0x2d55('0xd0')]),this[_0x2d55('0x392')]['postProcess'][_0x2d55('0xc6')][_0x2d55('0x1f8')]=!0x0;},'removeLayer':function(_0x40e4bb){_0x40e4bb[_0x2d55('0x700')][_0x2d55('0x150')](groupLayer);},'CLASS_NAME':_0x2d55('0x447')}),BDLayers[_0x2d55('0x5fd')][_0x2d55('0x404')][_0x2d55('0x69e')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')],{'extrudePolygons':null,'initialize':function(_0x151d9e,_0x4446b5){BDLayers['Util'][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this['__proto__'][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')][_0x2d55('0x55e')](this,_0x151d9e,_0x4446b5),this['layer']=new maptalks['ThreeLayer'](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0,'minZoom':this['options'][_0x2d55('0xf7')]||0x3,'maxZoom':this[_0x2d55('0x4f3')][_0x2d55('0x65a')]||0x18}),this[_0x2d55('0x400')]=[],this[_0x2d55('0x749')][_0x2d55('0x82b')]=function(_0x5017f7,_0x21286f,_0x1ddf9c){var _0x487488=new THREE[(_0x2d55('0x833'))](0xffffff,0.9),_0x487488=(_0x21286f[_0x2d55('0x69a')](_0x487488),new THREE['DirectionalLight'](0xffffff,0.1));_0x487488[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa),_0x21286f[_0x2d55('0x69a')](_0x487488),this[_0x2d55('0x5d1')]();}[_0x2d55('0x7cf')](this);},'addGeom':function(_0x1b5345,_0x3bfd9a,_0x532169){var _0x18cf22={'nokym':_0x2d55('0x312'),'HSGzp':_0x2d55('0x852')};console[_0x2d55('0xc4')](_0x18cf22[_0x2d55('0x4d0')]);var _0x33078b=this;axios[_0x2d55('0x86')](_0x3bfd9a,{'timeout':0x2710,'responseType':_0x18cf22[_0x2d55('0x1a1')]})['then'](function(_0x5ecba7){console[_0x2d55('0x4eb')](_0x2d55('0x312')),_0x33078b['addExtrudePolygon'](_0x1b5345,_0x5ecba7[_0x2d55('0x10c')],_0x532169),_0x33078b[_0x2d55('0x749')][_0x2d55('0x48')]();})[_0x2d55('0x5b5')](function(_0x5179b9){console[_0x2d55('0x10b')](_0x5179b9);})[_0x2d55('0xa8')](()=>{});},'addExtrudePolygon':function(_0x154a79,_0x4a8c26,_0x5549cd){var _0x46da68={'QqCqE':_0x2d55('0x21f'),'gNSCA':_0x2d55('0x59f'),'EJiQc':'workerload'};console[_0x2d55('0xc4')](_0x46da68[_0x2d55('0x5a4')]);var _0x4a8c26=_0x4a8c26[_0x2d55('0x759')][_0x2d55('0x700')](_0x1f4a0f=>{var _0x2f7d5f=maptalks['GeoJSON'][_0x2d55('0xf8')](_0x1f4a0f);return _0x2f7d5f[_0x2d55('0x1c4')]({'height':_0x1f4a0f[_0x2d55('0x6e')][_0x2d55('0x577')]}),_0x2f7d5f;}),_0xd4349f=this[_0x2d55('0x45f')](_0x5549cd);const _0x18556a=this[_0x2d55('0x749')][_0x2d55('0x1a7')](_0x4a8c26,{'interactive':!0x1,'topColor':_0x5549cd[_0x2d55('0x607')]||_0x46da68[_0x2d55('0x236')],'asynchronous':_0x5549cd['asynchronous']},_0xd4349f);_0x5549cd['asynchronous']&&(_0x5549cd[_0x2d55('0x6a5')]||_0x5549cd[_0x2d55('0x4b9')])?_0x18556a['on'](_0x46da68[_0x2d55('0x8')],function(){this[_0x2d55('0x803')](_0x18556a,_0x5549cd);}['bind'](this)):this[_0x2d55('0x803')](_0x18556a,_0x5549cd);},'addMeshToLayer':function(_0x11e718,_0x148c32){var _0x2b9d01={'hWFrV':_0x2d55('0x738'),'kXukx':function(_0x4500a4,_0x1c06aa){return _0x4500a4<_0x1c06aa;},'Vqngg':function(_0x7632ff,_0x190c4e){return _0x7632ff<_0x190c4e;},'QYikT':_0x2d55('0x190'),'zsthT':_0x2d55('0x1f7')};if(console[_0x2d55('0x4eb')](_0x2d55('0x21f')),_0x148c32['isLoadTexture']){var _0x44c126=new THREE[(_0x2d55('0x788'))](_0x148c32[_0x2d55('0x607')]||_0x2b9d01[_0x2d55('0x57b')]),_0x4ac137=_0x11e718[_0x2d55('0xc7')]()[_0x2d55('0xe3')],_0x470117=new THREE[(_0x2d55('0x130'))]()[_0x2d55('0x496')](_0x4ac137),{vertices:_0x34a1a9,faces:_0xc5d093,faceVertexUvs:_0x164a2e}=_0x470117;for(let _0x209f8d=0x0,_0x1e7c21=_0xc5d093['length'];_0x209f8d<_0x1e7c21;_0x209f8d++){var {a:_0x3d778b,b:_0x4faeff,c:_0x42bfa5}=_0xc5d093[_0x209f8d],_0x3d778b=_0x34a1a9[_0x3d778b],_0x4faeff=_0x34a1a9[_0x4faeff],_0x42bfa5=_0x34a1a9[_0x42bfa5];if(_0x2b9d01[_0x2d55('0x785')](0x0,_0x3d778b['z'])&&_0x2b9d01[_0x2d55('0x785')](0x0,_0x4faeff['z'])&&_0x2b9d01['kXukx'](0x0,_0x42bfa5['z'])){var _0x9b2329=_0xc5d093[_0x209f8d][_0x2d55('0x2ad')];for(let _0x4a3a89=0x0,_0x11e009=_0x9b2329[_0x2d55('0x6e9')];_0x4a3a89<_0x11e009;_0x4a3a89++)_0x9b2329[_0x4a3a89]['r']=_0x44c126['r'],_0x9b2329[_0x4a3a89]['g']=_0x44c126['g'],_0x9b2329[_0x4a3a89]['b']=_0x44c126['b'];var _0x142629=_0x164a2e[0x0][_0x209f8d];for(let _0x4f248c=0x0,_0x1fdd31=_0x142629['length'];_0x2b9d01[_0x2d55('0x98')](_0x4f248c,_0x1fdd31);_0x4f248c++)_0x142629[_0x4f248c]['x']=0x0,_0x142629[_0x4f248c]['y']=0x0;}}_0x11e718['getObject3d']()[_0x2d55('0xe3')]=new THREE[(_0x2d55('0x7e8'))]()[_0x2d55('0x814')](_0x470117),_0x4ac137[_0x2d55('0x1a2')](),_0x470117[_0x2d55('0x1a2')]();}this['extrudePolygons']['push'](_0x11e718),_0x148c32[_0x2d55('0x6a5')]&&(console['time'](_0x2b9d01[_0x2d55('0x139')]),_0x4ac137=new d(_0x11e718,{'interactive':!0x1},this[_0x2d55('0xcd')](_0x148c32),this['layer']),this[_0x2d55('0x400')][_0x2d55('0x590')](_0x4ac137),console[_0x2d55('0x4eb')](_0x2b9d01[_0x2d55('0x139')])),this['layer'][_0x2d55('0x823')](this[_0x2d55('0x400')]),console[_0x2d55('0x4eb')](_0x2b9d01['zsthT']),_0x148c32[_0x2d55('0x99')]&&(this[_0x2d55('0x749')]['hide'](),this[_0x2d55('0x2fb')](_0x148c32)),this[_0x2d55('0x5d1')]();},'getBuildingsMaterial':function(_0x3b8b3f){var _0x34e9c9={'MlirL':'../img/building.png','BSPoG':_0x2d55('0x59f')};_0x3b8b3f=_0x3b8b3f[_0x2d55('0x4b9')]?((_0x3b8b3f=new THREE[(_0x2d55('0x1fc'))]()[_0x2d55('0x58d')](_0x3b8b3f[_0x2d55('0x81a')]||_0x34e9c9[_0x2d55('0x35a')]))[_0x2d55('0x45b')]=!0x0,_0x3b8b3f[_0x2d55('0x529')]=_0x3b8b3f[_0x2d55('0x859')]=THREE[_0x2d55('0x317')],_0x3b8b3f[_0x2d55('0x541')]['set'](0x1,0x4),new THREE[(_0x2d55('0x7e3'))]({'map':_0x3b8b3f,'transparent':!0x0,'color':_0x34e9c9[_0x2d55('0x414')]})):new THREE['MeshPhongMaterial']({'color':0x0,'emissive':0xcccccc,'shininess':0x1e,'opacity':0.5,'transparent':!0x0});return _0x3b8b3f[_0x2d55('0x2ad')]=THREE[_0x2d55('0x61d')],_0x3b8b3f;},'getLineMaterial':function(_0x4b537f){_0x4b537f=new THREE[(_0x2d55('0x21'))]({'color':_0x4b537f[_0x2d55('0x6da')]||'rgb(15,159,190)','transparent':!0x0,'linewidth':0x1,'opacity':_0x4b537f['outlineColorOpacity']||0.7});return _0x4b537f[_0x2d55('0x3c')]=!0x0,_0x4b537f['depthTest']=!0x0,_0x4b537f[_0x2d55('0x384')]=0x1,_0x4b537f[_0x2d55('0x72a')]=0x1,_0x4b537f;},'removeGeom':function(_0xc665c6){},'animation':function(){var _0x143d8c={'fAVeo':function(_0x186273,_0x51cc5d){return _0x186273(_0x51cc5d);}};this[_0x2d55('0x749')][_0x2d55('0x5d8')]=!this[_0x2d55('0x749')][_0x2d55('0x5d8')],this[_0x2d55('0x749')][_0x2d55('0x5d8')]&&this[_0x2d55('0x749')][_0x2d55('0x3c4')](),_0x143d8c[_0x2d55('0x2dd')](requestAnimationFrame,this[_0x2d55('0x5d1')][_0x2d55('0x7cf')](this));},'animateShow':function(_0x13e361){this[_0x2d55('0x400')]['forEach'](function(_0x1689d4){_0x1689d4[_0x2d55('0x2fb')]({'duration':0xbb8}),_0x13e361[_0x2d55('0x99')]&&this[_0x2d55('0x749')][_0x2d55('0x6a0')]();}['bind'](this));},'CLASS_NAME':_0x2d55('0x63e')}),BDLayers['LibViz']['Layer'][_0x2d55('0x792')]=BDLayers[_0x2d55('0x2ca')](BDLayers['Lib'][_0x2d55('0x404')][_0x2d55('0x310')],{'waters':null,'watersAll':[],'stats':null,'terrains':null,'initialize':function(_0x48716c,_0x812ad5){BDLayers[_0x2d55('0x84f')][_0x2d55('0x229')](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')][_0x2d55('0x4e2')]['initialize'][_0x2d55('0x55e')](this,_0x48716c,_0x812ad5),this['layer']=new maptalks[(_0x2d55('0x731'))](this['id'],{'forceRenderOnMoving':!0x0,'forceRenderOnRotating':!0x0,'minZoom':this[_0x2d55('0x4f3')][_0x2d55('0xf7')]||0x3,'maxZoom':this[_0x2d55('0x4f3')]['maxZoom']||0x18});var _0x2b905a=this;this[_0x2d55('0x749')]['prepareToDraw']=function(_0x3b5775,_0x4565be,_0x5376af){_0x2b905a[_0x2d55('0x311')]=new Stats(),_0x2b905a[_0x2d55('0x311')][_0x2d55('0x638')]['style'][_0x2d55('0x810')]=0x64,document[_0x2d55('0x4ed')](_0x812ad5[_0x2d55('0x7af')])['appendChild'](_0x2b905a[_0x2d55('0x311')][_0x2d55('0x638')]);var _0x3682d2=new THREE['DirectionalLight'](0xffffff);_0x3682d2[_0x2d55('0x463')][_0x2d55('0x218')](0x0,-0xa,0xa)[_0x2d55('0xec')](),_0x4565be['add'](_0x3682d2),_0x812ad5[_0x2d55('0x318')]&&_0x2b905a['addWater'](_0x48716c,_0x812ad5);}['bind'](this);},'addWaters':function(_0x5a1120){var _0x11db1f=maptalks[_0x2d55('0x1e7')][_0x2d55('0xf8')](_0x5a1120[_0x2d55('0x318')]);this['waters']=_0x11db1f[_0x2d55('0x700')](_0x11095d=>new o(_0x11095d,{},this['layer'],_0x5a1120[_0x2d55('0x849')],_0x5a1120[_0x2d55('0x3ae')])),this['layer'][_0x2d55('0x823')](this[_0x2d55('0x3f6')]),this[_0x2d55('0x749')]['config'](_0x2d55('0x5d1'),!0x0),this['watersAll'][_0x2d55('0x590')](this[_0x2d55('0x3f6')]);},'removeAll':function(){var _0x44ff8d={'QDwHK':_0x2d55('0x5d1')};this['watersAll'][_0x2d55('0x457')](_0x79268d=>{this[_0x2d55('0x749')][_0x2d55('0x80e')](_0x79268d);}),this[_0x2d55('0x855')]=[],this[_0x2d55('0x749')][_0x2d55('0x524')](_0x44ff8d['QDwHK'],!0x1);},'CLASS_NAME':'BDLayers.LibViz.Layer.VWaterLayer'}),BDLayers['Lib']['Layer'][_0x2d55('0x6cb')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')]['Layer'][_0x2d55('0x310')],{'layer_markers':null,'initialize':function(_0x4d8ff8,_0x420c0e){var _0x935a32={'EFpoe':_0x2d55('0x501')};BDLayers[_0x2d55('0x84f')]['extend'](this[_0x2d55('0x4f3')],this[_0x2d55('0x6cc')][_0x2d55('0x6cc')][_0x2d55('0x4f3')]),BDLayers[_0x2d55('0x47b')][_0x2d55('0x404')][_0x2d55('0x310')][_0x2d55('0x4e2')][_0x2d55('0x27c')]['call'](this,_0x4d8ff8,_0x420c0e),this[_0x2d55('0x749')]=new maptalks[(_0x2d55('0x455'))](this['id'],this[_0x2d55('0x4f3')]),this[_0x2d55('0x749')][_0x2d55('0x768')]=this['layer_markers'],this['trigger'](_0x935a32[_0x2d55('0x52a')],this);},'getLayer':function(){return this[_0x2d55('0x749')];},'filter':function(_0x975d2a){return this[_0x2d55('0x749')]['filter'](_0x975d2a);},'getExtent':function(){return this['layer'][_0x2d55('0x164')]();},'setStyle':function(_0x3a8644){this['layer'][_0x2d55('0x3a9')](_0x3a8644);},'show':function(){this[_0x2d55('0x749')][_0x2d55('0x6a0')]();},'hide':function(){this[_0x2d55('0x749')][_0x2d55('0x45d')]();},'addMarker':function(_0x3a2687){(_0x3a2687[_0x2d55('0x5d3')]?_0x3a2687[_0x2d55('0x5d3')]():_0x3a2687)['addTo'](this[_0x2d55('0x749')]);},'addMarkers':function(_0x1279e5){_0x1279e5=_0x1279e5[_0x2d55('0x700')](function(_0x37af32){return _0x37af32[_0x2d55('0x5d3')]?_0x37af32[_0x2d55('0x5d3')]():_0x37af32;});this[_0x2d55('0x749')][_0x2d55('0x34c')](_0x1279e5);},'removeMarker':function(_0x59eb94){this[_0x2d55('0x749')]['removeGeometry']([_0x59eb94]);},'removeMarkers':function(_0x50adbd){this['layer'][_0x2d55('0x15f')](_0x50adbd);},'getMarkerId':function(_0xa1bfb4){return this[_0x2d55('0x749')][_0x2d55('0x7ae')](_0xa1bfb4);},'getMarkers':function(){return this[_0x2d55('0x3d7')]['values']();},'CLASS_NAME':'BDLayers.Lib.Layer.CBPointLayer'}),window[_0x2d55('0x380')][_0x2d55('0x784')]||(window['bdmap']['comp']={}),window[_0x2d55('0x380')][_0x2d55('0x784')]['login']=new function(){var _0x37949c={'TSEdV':function(_0x395e81,_0x4e7e32){return _0x395e81===_0x4e7e32;},'AUIlr':function(_0x4e825d,_0x29c819){return _0x4e825d(_0x29c819);},'WESfe':function(_0x43fb15,_0x420044){return _0x43fb15+_0x420044;},'PuCSA':function(_0x21695e,_0x2a6ef3){return _0x21695e+_0x2a6ef3;}};function _0x229cdb(_0xf9074){axios[_0x2d55('0x86')](_0xf9074,{'timeout':0x2710})[_0x2d55('0x37f')](function(_0x208d2f){_0x37949c['TSEdV'](0xc8,_0x208d2f[_0x2d55('0x10c')][_0x2d55('0x685')])&&bdmap['comp'][_0x2d55('0x2ae')][_0x2d55('0x1f4')](_0x208d2f[_0x2d55('0x10c')][_0x2d55('0x15e')]);})['catch'](_0x256ccb=>{_0x37949c['AUIlr'](_0x229cdb,_0xf9074);});}this['loginSystem']=function(_0x3dde13,_0x2e19dc,_0x43a4e2){var _0x3e3320={'XPFtI':function(_0x171f6a,_0x5920d4){return _0x37949c[_0x2d55('0x2cd')](_0x171f6a,_0x5920d4);}};let _0x1f309c;_0x229cdb(_0x1f309c=_0x37949c['WESfe'](_0x37949c[_0x2d55('0x595')](_0x3dde13,_0x2d55('0x647')+_0x2e19dc+_0x2d55('0x359')),_0x43a4e2)),setInterval(()=>{_0x3e3320['XPFtI'](_0x229cdb,_0x1f309c);},0x1b7740);};}(),function(){var _0x3f3796={'HQbug':function(_0x38076f,_0x35a393){return _0x38076f*_0x35a393;},'mjuNu':function(_0x30341e,_0x2009f9){return _0x30341e+_0x2009f9;},'xuVXh':function(_0x92086b,_0x507e43){return _0x92086b+_0x507e43;},'VxuKL':function(_0x2bdffe,_0x4b8864){return _0x2bdffe+_0x4b8864;},'ngRng':function(_0x30b24e,_0x31b537){return _0x30b24e+_0x31b537;},'lLGLf':function(_0x187a90,_0x25acf5){return _0x187a90+_0x25acf5;},'uupEV':function(_0x2739d3,_0x2b3e96){return _0x2739d3+_0x2b3e96;},'fSUQV':function(_0x482df4,_0x4f2cec){return _0x482df4+_0x4f2cec;},'GkqIN':'bdlayer','CBXQS':function(_0x54df81){return _0x54df81();},'JMZui':function(_0x1cdcef){return _0x1cdcef();},'RbpPl':function(_0x1649b5){return _0x1649b5();},'xMxvW':function(_0x3598e5){return _0x3598e5();},'SezIo':function(_0x403610){return _0x403610();}};function _0x2d451b(){return(_0x3f3796[_0x2d55('0x4c3')](0x10000,_0x3f3796['mjuNu'](0x1,Math[_0x2d55('0x7b8')]()))|0x0)['toString'](0x10)[_0x2d55('0x438')](0x1);}window[_0x2d55('0x380')][_0x2d55('0x784')]||(window[_0x2d55('0x380')][_0x2d55('0x784')]={}),window[_0x2d55('0x380')]['comp'][_0x2d55('0x2ae')]=new function(){var _0x703e2e=null;this[_0x2d55('0x337')]=function(){_0x703e2e=_0x3f3796['xuVXh'](_0x3f3796[_0x2d55('0x6d8')](_0x3f3796[_0x2d55('0x152')](_0x3f3796[_0x2d55('0x6df')](_0x3f3796['ngRng'](_0x3f3796[_0x2d55('0x4f5')](_0x3f3796[_0x2d55('0x26f')](_0x3f3796['fSUQV'](_0x3f3796['fSUQV'](_0x3f3796[_0x2d55('0x115')],_0x3f3796[_0x2d55('0x62f')](_0x3f3796[_0x2d55('0x1ef')](_0x2d451b),_0x3f3796[_0x2d55('0x1ef')](_0x2d451b))),'-')+_0x3f3796[_0x2d55('0x4d')](_0x2d451b)+'-',_0x3f3796[_0x2d55('0x88')](_0x2d451b)),'-'),_0x3f3796[_0x2d55('0x4c8')](_0x2d451b)),'-'),_0x2d451b()),_0x3f3796['SezIo'](_0x2d451b)),_0x3f3796[_0x2d55('0x562')](_0x2d451b));},this[_0x2d55('0x92')]=function(){return localStorage[_0x2d55('0x109')](_0x703e2e);},this[_0x2d55('0x1f4')]=function(_0xde17c4){localStorage[_0x2d55('0x248')](_0x703e2e,_0xde17c4);};}();}(),function(){var _0x2dd4f={'BDbtM':function(_0x142faf,_0x347dda){return _0x142faf|_0x347dda;},'rIyie':function(_0x8ba7a6,_0x86890f){return _0x8ba7a6*_0x86890f;},'oxkvO':function(_0x162061,_0x1c4a0d){return _0x162061+_0x1c4a0d;},'sAVYX':function(_0x2ee80c,_0x4d63e5){return _0x2ee80c+_0x4d63e5;},'kkznq':function(_0xa6d6dd,_0x19f4cf){return _0xa6d6dd+_0x19f4cf;},'oRVwA':function(_0x7cd5cd,_0x4dfda1){return _0x7cd5cd+_0x4dfda1;},'nGODb':function(_0x49a35b,_0x1489f1){return _0x49a35b+_0x1489f1;},'DWAby':function(_0xaef3ac,_0x1eeb05){return _0xaef3ac+_0x1eeb05;},'PBAcb':function(_0x4211ec){return _0x4211ec();},'dKpKH':function(_0xc659a6){return _0xc659a6();},'nqOfI':function(_0x283106){return _0x283106();},'ccoPI':function(_0x525eb5,_0x4d6fe1){return _0x525eb5(_0x4d6fe1);},'TlQnL':function(_0x4c7643,_0x421433){return _0x4c7643<_0x421433;},'GKVLV':_0x2d55('0x7f6'),'pCHfG':function(_0x2ec788,_0x46af36){return _0x2ec788+_0x46af36;},'KGoek':function(_0x21819b,_0x35ce8b){return _0x21819b===_0x35ce8b;}};function _0x372c3d(){return _0x2dd4f[_0x2d55('0x722')](_0x2dd4f[_0x2d55('0x1b0')](0x10000,_0x2dd4f['oxkvO'](0x1,Math['random']())),0x0)[_0x2d55('0x25e')](0x10)['substring'](0x1);}function _0x225742(){return _0x2dd4f[_0x2d55('0x5e6')](_0x2dd4f[_0x2d55('0x5e6')](_0x2dd4f[_0x2d55('0x19')](_0x2dd4f[_0x2d55('0x587')](_0x2dd4f[_0x2d55('0x587')](_0x2dd4f['oRVwA'](_0x2dd4f['nGODb'](_0x2dd4f[_0x2d55('0x5f2')](_0x2dd4f[_0x2d55('0x5d4')](_0x372c3d(),_0x2dd4f[_0x2d55('0x2a')](_0x372c3d)),'-'),_0x2dd4f[_0x2d55('0x2a')](_0x372c3d)),'-'),_0x372c3d())+'-',_0x2dd4f[_0x2d55('0x767')](_0x372c3d)),'-'),_0x2dd4f['dKpKH'](_0x372c3d)),_0x2dd4f['nqOfI'](_0x372c3d))+_0x2dd4f[_0x2d55('0x3c1')](_0x372c3d);}window[_0x2d55('0x380')][_0x2d55('0x784')]||(window[_0x2d55('0x380')][_0x2d55('0x784')]={}),window[_0x2d55('0x380')][_0x2d55('0x784')][_0x2d55('0x334')]=new function(){var _0x6c0fb0={'OYaar':function(_0x422a8c,_0x5b37db,_0x12b687){return _0x422a8c(_0x5b37db,_0x12b687);},'emGGO':function(_0xe54ae5,_0x11f814){return _0x2dd4f[_0x2d55('0x4b4')](_0xe54ae5,_0x11f814);},'QBKMj':function(_0x3a046d,_0x48a3e2){return _0x3a046d===_0x48a3e2;},'IJkwD':function(_0x2dad3d,_0x51dfd5){return _0x2dd4f[_0x2d55('0x5b7')](_0x2dad3d,_0x51dfd5);},'OrfCw':_0x2dd4f[_0x2d55('0x702')],'brnxO':_0x2d55('0x55b'),'DGaSO':function(_0x37e626,_0x34a2aa){return _0x2dd4f[_0x2d55('0x7fb')](_0x37e626,_0x34a2aa);},'swXMK':_0x2d55('0x3e0'),'AxiiI':function(_0xc0bbfa){return _0x2dd4f[_0x2d55('0x3c1')](_0xc0bbfa);},'dJzfG':function(_0xab19f5,_0x368dfb){return _0x2dd4f['ccoPI'](_0xab19f5,_0x368dfb);},'jTGIG':function(_0x1c035a,_0x5dda56){return _0x2dd4f[_0x2d55('0x2d3')](_0x1c035a,_0x5dda56);},'IgEfK':function(_0x36d35b,_0x34eec1){return _0x2dd4f['pCHfG'](_0x36d35b,_0x34eec1);},'rurze':function(_0x3b32be,_0x564c9b){return _0x3b32be===_0x564c9b;}};this['loadNormalLW']=function(_0x9d0389,_0x36b45c,_0x299237,_0x537abc,_0x298fe9,_0x598ab4){var _0x10fc8a={'JRxWp':function(_0x17b8ae,_0x5e01ea){return _0x6c0fb0[_0x2d55('0x7ce')](_0x17b8ae,_0x5e01ea);},'nvUrQ':function(_0x227b24,_0x2fde0c){return _0x6c0fb0[_0x2d55('0x96')](_0x227b24,_0x2fde0c);},'FvlPF':function(_0x16aeda,_0x1f8b0b){return _0x6c0fb0[_0x2d55('0x7f9')](_0x16aeda,_0x1f8b0b);},'PMvkO':function(_0x494531,_0x15ae3e,_0x434694){return _0x494531(_0x15ae3e,_0x434694);},'JrpyJ':function(_0x2fbcf9,_0x3542e0,_0x2ba42b){return _0x6c0fb0[_0x2d55('0x215')](_0x2fbcf9,_0x3542e0,_0x2ba42b);},'gDfyC':'success'};var _0x596faa=_0x36b45c[_0x2d55('0x700')],_0x36b45c=_0x36b45c[_0x2d55('0x5df')],_0x1182d0=_0x36b45c[_0x2d55('0x86')](_0x299237),_0x38e420=(_0x36b45c[_0x2d55('0x86')](_0x299237)&&(_0x36b45c[_0x2d55('0x860')](_0x299237),_0x596faa[_0x2d55('0x150')](_0x1182d0[_0x2d55('0x749')])),new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x404'))]['CBVectorLayer'](_0x299237)),_0x1182d0=(_0x38e420[_0x2d55('0x4a0')](_0x596faa),_0x38e420['layer'][_0x2d55('0x6ce')](_0x596faa),_0x38e420[_0x2d55('0x749')][_0x2d55('0x20a')](0x62),_0x36b45c[_0x2d55('0x63c')](_0x38e420['id'],_0x38e420),bdmap['comp']['tokenHelper']['getToken']());axios['get'](_0x9d0389,{'timeout':0x2710,'headers':{'X-ACCESS-TOKEN':_0x1182d0}})['then'](function(_0x499dce){var _0x320802={'bJWax':function(_0x474bb0,_0x4255e4){return _0x10fc8a[_0x2d55('0x35e')](_0x474bb0,_0x4255e4);}};if(_0x499dce[_0x2d55('0x10c')][_0x2d55('0x286')]['records']&&_0x10fc8a[_0x2d55('0x66')](0x0,_0x499dce['data']['result'][_0x2d55('0x53')][_0x2d55('0x6e9')])){let _0x91f7ae=_0x499dce[_0x2d55('0x10c')][_0x2d55('0x286')][_0x2d55('0x53')],_0x4c237b=[],_0x191738=(_0x298fe9||axios[_0x2d55('0x86')](_0x537abc)[_0x2d55('0x37f')](function(_0x19841f){_0x320802[_0x2d55('0x532')](_0x2d55('0x5e1'),_0x19841f[_0x2d55('0x10c')][_0x2d55('0x685')])&&_0x19841f['data'][_0x2d55('0x10c')][_0x2d55('0x457')](_0x46aa5d=>{_0x4c237b[_0x2d55('0x590')](_0x46aa5d['colour_code']);});}),_0x10fc8a[_0x2d55('0x805')](setInterval,()=>{var _0x10148b={'pvycP':function(_0x377f15,_0x4db6db){return _0x377f15+_0x4db6db;}};(_0x298fe9||0x0<_0x4c237b[_0x2d55('0x6e9')])&&(_0x10fc8a['JRxWp'](clearInterval,_0x191738),_0x91f7ae[_0x2d55('0x457')](_0x5493fe=>{var _0x53b1e0={'cJmME':function(_0x31e294,_0x447a8d){return _0x10148b['pvycP'](_0x31e294,_0x447a8d);}};JSON['parse'](_0x5493fe['content'])[_0x2d55('0x759')][_0x2d55('0x457')]((_0x2ad115,_0x33e5d6)=>{var _0x156f4b={'CyPuE':function(_0x5e0ee0,_0x1ea951){return _0x5e0ee0+_0x1ea951;},'plAYJ':function(_0x4f2c74,_0x33aeb8){return _0x53b1e0['cJmME'](_0x4f2c74,_0x33aeb8);}};_0x2ad115['geometry'][_0x2d55('0x537')][_0x2d55('0x457')]((_0x72614f,_0x3d24d5)=>{_0x3d24d5=new BDLayers['Lib']['Overlays'][(_0x2d55('0x1c0'))](_0x156f4b['CyPuE'](_0x156f4b[_0x2d55('0x257')](_0x2d55('0x3e0')+_0x33e5d6+_0x2d55('0x545'),_0x3d24d5),_0x299237),{'coordinates':_0x72614f,'symbol':{'lineColor':_0x298fe9||_0x4c237b[0x0],'lineWidth':0x3}});_0x38e420['layer'][_0x2d55('0x34c')](_0x3d24d5[_0x2d55('0x32c')]||_0x3d24d5),_0x38e420[_0x2d55('0x238')][_0x2d55('0x63c')](_0x3d24d5['id'],_0x3d24d5);});});}));},0x64));}_0x598ab4&&_0x10fc8a[_0x2d55('0x352')](_0x598ab4,_0x10fc8a[_0x2d55('0xa4')],rsp);})[_0x2d55('0x5b5')](_0x48c2f0=>{_0x598ab4&&_0x6c0fb0[_0x2d55('0x215')](_0x598ab4,'error',_0x48c2f0);});},this[_0x2d55('0x39d')]=function(_0x24a3d7,_0x4e8834,_0x41ee0e,_0x3660c3,_0x41c46f,_0x45d4ac){var _0x44228f={'XhBWN':function(_0x2777bf,_0x3648ca){return _0x2777bf!==_0x3648ca;},'ItQjF':_0x6c0fb0[_0x2d55('0x57c')],'MlXqp':function(_0x14a032,_0x5bbe26){return _0x6c0fb0[_0x2d55('0x2e7')](_0x14a032,_0x5bbe26);},'ArvkQ':function(_0x3a8eda,_0xb48fdc){return _0x6c0fb0[_0x2d55('0x16c')](_0x3a8eda,_0xb48fdc);}};var _0x5793a3=_0x41ee0e['map'],_0x41ee0e=_0x41ee0e['layers'],_0x39da02=(_0x41ee0e['get'](_0x3660c3)&&(_0x46b9cd=_0x41ee0e['get'](_0x3660c3),_0x5793a3[_0x2d55('0x150')](_0x46b9cd[_0x2d55('0x749')]),_0x41ee0e['remove'](_0x3660c3)),new BDLayers[(_0x2d55('0x47b'))]['Layer']['CBVectorLayer'](_0x3660c3)),_0x46b9cd=(_0x39da02[_0x2d55('0x4a0')](_0x5793a3),_0x39da02[_0x2d55('0x749')][_0x2d55('0x6ce')](_0x5793a3),_0x39da02[_0x2d55('0x749')][_0x2d55('0x20a')](0x63),_0x41ee0e[_0x2d55('0x63c')](_0x39da02['id'],_0x39da02),'');_0x46b9cd=_0x41c46f&&_0x41c46f[_0x2d55('0x491')]?_0x41c46f[_0x2d55('0x491')]:_0x6c0fb0[_0x2d55('0x2e7')]((_0x3660c3=new Date())[_0x2d55('0x416')]()+('-'+_0x6c0fb0[_0x2d55('0x2e7')](_0x3660c3[_0x2d55('0x5f0')](),0x1)+'-'+_0x3660c3['getDate']()+'\x20'+_0x3660c3[_0x2d55('0x3dd')]()+':'+_0x3660c3['getMinutes']()+':'),_0x3660c3[_0x2d55('0x6d3')]()),axios({'method':'get','url':_0x24a3d7,'params':{'date':_0x46b9cd}})['then'](_0x202d7a=>{var _0xcba091={'xLpDx':function(_0x5e0bc0,_0x2e54af){return _0x5e0bc0!==_0x2e54af;},'WtOVR':_0x6c0fb0[_0x2d55('0xda')],'bEAde':_0x6c0fb0[_0x2d55('0x57c')],'Ulhfo':function(_0x42ba8e,_0x177a19){return _0x42ba8e!==_0x177a19;},'SXYfs':function(_0x5b497a,_0x5bcb8b){return _0x6c0fb0[_0x2d55('0x303')](_0x5b497a,_0x5bcb8b);},'bjEUm':_0x6c0fb0[_0x2d55('0x36f')],'ZBnpW':function(_0x2804dc){return _0x6c0fb0[_0x2d55('0x4df')](_0x2804dc);}};var _0x333565,_0x42aae3,_0x5406b1,_0x5f4031;_0x45d4ac&&_0x6c0fb0[_0x2d55('0x167')](_0x45d4ac,_0x202d7a),_0x202d7a[_0x2d55('0x10c')]&&_0x202d7a[_0x2d55('0x10c')][_0x2d55('0x685')]&&_0x6c0fb0[_0x2d55('0x5a6')]('200',_0x202d7a[_0x2d55('0x10c')][_0x2d55('0x685')])&&(_0x333565=[],_0x202d7a['data']['data'][_0x2d55('0x457')](_0x3af689=>{_0x333565['push']({'id':_0x3af689['id'],'colour':_0x3af689[_0x2d55('0x284')]||_0x3af689[_0x2d55('0x254')],'level':_0x3af689[_0x2d55('0x5e9')]||_0x3af689[_0x2d55('0x198')],'colour_code':_0x3af689[_0x2d55('0x606')],'flow':_0x3af689['link_flow'],'name':_0x3af689[_0x2d55('0x552')],'no':_0x3af689[_0x2d55('0x6ca')],'direc':_0x3af689[_0x2d55('0xb6')],'geom':JSON['parse'](_0x3af689['geom'])[_0x2d55('0x537')][0x0]});}),_0x6c0fb0[_0x2d55('0x7f9')](0x0,_0x333565['length']))&&(_0x39da02['layer'][_0x2d55('0x7a5')](),_0x39da02['layer_markers'][_0x2d55('0x7a5')](),_0x39da02[_0x2d55('0x238')][_0x2d55('0x7a5')](),_0x42aae3=_0x333565,_0x5406b1=_0x39da02,(_0x202d7a=_0x4e8834)?(_0x5f4031=bdmap[_0x2d55('0x784')][_0x2d55('0x2ae')]['getToken'](),axios[_0x2d55('0x86')](_0x202d7a,{'timeout':0x2710,'headers':{'X-ACCESS-TOKEN':_0x5f4031}})[_0x2d55('0x37f')](function(_0x24c6c7){var _0x13ece2={'Zngzo':function(_0x151349,_0x30fab1){return _0x44228f['XhBWN'](_0x151349,_0x30fab1);},'aWICh':_0x2d55('0x7f6'),'cEqtS':_0x44228f[_0x2d55('0x1ff')],'UdxRu':function(_0x3b27dc,_0x497183){return _0x44228f[_0x2d55('0x7ec')](_0x3b27dc,_0x497183);},'IFJwt':function(_0x4be0da,_0x5e8d0d){return _0x44228f[_0x2d55('0x40e')](_0x4be0da,_0x5e8d0d);}};JSON['parse'](_0x24c6c7[_0x2d55('0x10c')][_0x2d55('0x286')][_0x2d55('0x53')][0x0][_0x2d55('0x15a')]);_0x24c6c7['data'][_0x2d55('0x286')]['records']&&0x0<_0x24c6c7[_0x2d55('0x10c')]['result'][_0x2d55('0x53')][_0x2d55('0x6e9')]&&_0x24c6c7[_0x2d55('0x10c')][_0x2d55('0x286')]['records'][_0x2d55('0x457')](_0x5d4a3f=>{var _0x420ccb={'eNyiC':function(_0x53195b,_0x1691c1){return _0x13ece2[_0x2d55('0x7e2')](_0x53195b,_0x1691c1);}};let _0x1b1163=JSON[_0x2d55('0x114')](_0x5d4a3f[_0x2d55('0x15a')]);_0x42aae3['forEach'](_0x1babdd=>{var _0x5267c7={'yIuSR':function(_0x599f1d,_0x64e181){return _0x13ece2[_0x2d55('0x6ed')](_0x599f1d,_0x64e181);},'TpRtM':_0x13ece2[_0x2d55('0x825')],'IroSB':_0x13ece2['cEqtS'],'BujlX':function(_0x525d05,_0x371724){return _0x13ece2['UdxRu'](_0x525d05,_0x371724);},'wvZes':function(_0x44b21e){return _0x44b21e();}};_0x1b1163['features'][_0x2d55('0x457')]((_0x3e4d2d,_0x4571da)=>{_0x420ccb[_0x2d55('0x86b')](_0x1babdd['no'],_0x3e4d2d[_0x2d55('0x6e')][_0x2d55('0x6ca')])&&_0x420ccb[_0x2d55('0x86b')](_0x1babdd['direc'],_0x3e4d2d[_0x2d55('0x6e')][_0x2d55('0xb6')])&&_0x3e4d2d[_0x2d55('0xe3')][_0x2d55('0x537')][_0x2d55('0x457')]((_0xeffe11,_0x35c97c)=>{let _0x271ab6=0x3;_0x5267c7[_0x2d55('0x599')](_0x5267c7[_0x2d55('0x1a5')],_0x1babdd[_0x2d55('0x46d')])&&_0x5267c7['IroSB']!==_0x1babdd[_0x2d55('0x46d')]&&_0x5267c7[_0x2d55('0x599')](_0x2d55('0x5f1'),_0x1babdd[_0x2d55('0x46d')])||(_0x271ab6=0x5);_0x35c97c=new BDLayers['Lib'][(_0x2d55('0x58c'))][(_0x2d55('0x1c0'))](_0x5267c7[_0x2d55('0x806')](_0x2d55('0x3e0')+_0x4571da+_0x1babdd[_0x2d55('0x46d')]+_0x5267c7[_0x2d55('0x7c3')](_0x225742)+'child',_0x35c97c),{'coordinates':_0xeffe11,'symbol':{'lineColor':_0x1babdd[_0x2d55('0x606')],'lineWidth':_0x271ab6}});_0x5406b1[_0x2d55('0x749')][_0x2d55('0x34c')](_0x35c97c[_0x2d55('0x32c')]||_0x35c97c),_0x5406b1['layer_geoms'][_0x2d55('0x63c')](_0x35c97c['id'],_0x35c97c);});});});});})):_0x42aae3[_0x2d55('0x457')](_0x41e12f=>{let _0x344110=0x3;_0xcba091['xLpDx'](_0xcba091[_0x2d55('0x37a')],_0x41e12f[_0x2d55('0x46d')])&&_0xcba091[_0x2d55('0x4dd')](_0xcba091['bEAde'],_0x41e12f['level'])&&_0xcba091[_0x2d55('0x7d8')]('轻度拥堵',_0x41e12f['level'])||(_0x344110=0x5);_0x41e12f=new BDLayers[(_0x2d55('0x47b'))][(_0x2d55('0x58c'))][(_0x2d55('0x1c0'))](_0xcba091[_0x2d55('0x31c')](_0xcba091['SXYfs'](_0xcba091[_0x2d55('0x6ff')]+i,_0x41e12f[_0x2d55('0x46d')]),_0xcba091[_0x2d55('0x707')](_0x225742)),{'coordinates':_0x41e12f[_0x2d55('0x32c')],'symbol':{'lineColor':_0x41e12f[_0x2d55('0x606')],'lineWidth':_0x344110}});_0x5406b1[_0x2d55('0x749')][_0x2d55('0x34c')](_0x41e12f['geom']||_0x41e12f),_0x5406b1['layer_geoms'][_0x2d55('0x63c')](_0x41e12f['id'],_0x41e12f);}));});},this[_0x2d55('0xbc')]=function(_0x5aac6d,_0x270094,_0x2118a9){var _0x43ec77,_0x39c9a9=_0x5aac6d[_0x2d55('0x700')],_0x5aac6d=_0x5aac6d[_0x2d55('0x5df')];_0x5aac6d[_0x2d55('0x86')](_0x270094)&&(_0x43ec77=_0x5aac6d[_0x2d55('0x86')](_0x270094),_0x39c9a9[_0x2d55('0x150')](_0x43ec77[_0x2d55('0x749')]),_0x5aac6d[_0x2d55('0x860')](_0x270094),_0x2118a9)&&_0x2118a9();};}();}(),BDLayers[_0x2d55('0x699')][_0x2d55('0x374')]=BDLayers[_0x2d55('0x2ca')](BDLayers[_0x2d55('0x47b')][_0x2d55('0x50b')][_0x2d55('0x753')],{'itemClick':function(_0x2f222f){var _0x320e71={'oxucz':_0x2d55('0x4c7'),'RXiBz':_0x2d55('0x7ca'),'ZtDkl':_0x2d55('0x7bb'),'KfEEN':function(_0x7501b6,_0x3fe9ad){return _0x7501b6(_0x3fe9ad);}};var _0x4d8a58=window[_0x2d55('0x6b')][_0x2d55('0x459')],_0x4abfe0=bdmap[_0x2d55('0x3d9')][_0x2d55('0x7ea')]()['traffic'];handleClass[_0x2d55('0xb9')](_0x4d8a58,_0x320e71[_0x2d55('0x5af')])?handleClass[_0x2d55('0x2df')](_0x4d8a58,_0x320e71[_0x2d55('0x5af')]):handleClass[_0x2d55('0x53c')](_0x4d8a58,_0x2d55('0x7ca')),handleClass['hasClass'](_0x4d8a58,'active')?(bdmap[_0x2d55('0x784')]['trafficSituation']['loadNormalLW'](_0x4abfe0[_0x2d55('0x333')],_0x2f222f,_0x320e71[_0x2d55('0x388')],_0x4abfe0[_0x2d55('0x646')]),bdmap[_0x2d55('0x784')][_0x2d55('0x334')][_0x2d55('0x39d')](_0x4abfe0[_0x2d55('0x3a8')],_0x4abfe0[_0x2d55('0x7a4')],_0x2f222f,_0x320e71[_0x2d55('0x61b')]),mapSetInterval=setInterval(()=>{bdmap['comp'][_0x2d55('0x334')]['removeStateLW'](_0x2f222f,'jtts_traffic_bdmap'),bdmap['comp'][_0x2d55('0x334')][_0x2d55('0x39d')](_0x4abfe0['url'],_0x4abfe0[_0x2d55('0x7a4')],_0x2f222f,_0x320e71['oxucz']);},0xea60)):(_0x320e71['KfEEN'](clearInterval,mapSetInterval),bdmap['comp']['trafficSituation'][_0x2d55('0xbc')](_0x2f222f,_0x320e71[_0x2d55('0x388')]),bdmap[_0x2d55('0x784')][_0x2d55('0x334')][_0x2d55('0xbc')](_0x2f222f,_0x320e71['oxucz']));},'CLASS_NAME':_0x2d55('0x2c2')}),window['bdmap'][_0x2d55('0x784')]||(window['bdmap'][_0x2d55('0x784')]={}),window[_0x2d55('0x380')]['comp']['Trajectory']=new function(){var _0x3c70ba={'NQksS':function(_0x351354,_0x2c0ccf){return _0x351354>_0x2c0ccf;},'bQQyG':_0x2d55('0x4e0'),'eBgav':_0x2d55('0x2e8'),'qhJqH':'playing','FsNJS':function(_0x230a59,_0x8b0c56){return _0x230a59*_0x8b0c56;}};this[_0x2d55('0x56e')]=function({mapView:_0x27b42e,latlons:_0x251275,unitTime:_0x457dbc=0x1f4,speedValue:_0x5acf59=0x1,mapToCenter:_0x9a0a1=!0x0,markerSymbol:_0x4348b3,isExtent:_0x4870bd=!0x0}={}){var _0x42c039=_0x3c70ba[_0x2d55('0xc1')][_0x2d55('0x77c')]('|');var _0x255ed5=0x0;while(!![]){switch(_0x42c039[_0x255ed5++]){case'0':var _0x2da44d=new maptalks['RoutePlayer']({'path':_0x46f195},_0x27b42e[_0x2d55('0x700')],{'unitTime':_0x457dbc*_0x5acf59,'maxTrailLine':0x2,'lineSymbol':{'lineWidth':0x4,'lineColor':_0x3c70ba['eBgav'],'smoothness':0.5},'markerSymbol':_0x4348b3});continue;case'1':return _0x4870bd&&(_0x251275=new maptalks[(_0x2d55('0x5fb'))](new maptalks[(_0x2d55('0x4b0'))](Math['min'](..._0x45b8b2),Math[_0x2d55('0xfa')](..._0x4480a)),new maptalks[(_0x2d55('0x4b0'))](Math[_0x2d55('0x744')](..._0x45b8b2),Math[_0x2d55('0x744')](..._0x4480a))),_0x27b42e[_0x2d55('0x700')]['fitExtent'](_0x251275,0x0)),_0x9a0a1?_0x2da44d['on'](_0x3c70ba[_0x2d55('0x33a')],function(_0x28cf46){_0x27b42e[_0x2d55('0x847')](_0x2da44d['getCurrentCoordinates']());}):_0x2da44d['on'](_0x2d55('0x432'),function(_0x49537a){var _0x4b89d3=_0x27b42e[_0x2d55('0x700')][_0x2d55('0x164')](),_0x33645a=_0x2da44d[_0x2d55('0x71a')]();(_0x33645a['x']<_0x4b89d3[_0x2d55('0x535')]||_0x3c70ba[_0x2d55('0x2a4')](_0x33645a['x'],_0x4b89d3[_0x2d55('0x33f')])||_0x33645a['y']<_0x4b89d3[_0x2d55('0x17a')]||_0x33645a['y']>_0x4b89d3['ymax'])&&_0x27b42e['setCenter'](_0x33645a);}),_0x2da44d;case'2':var _0x396dcb={'MtmIC':function(_0x4706ce,_0xc39dd1){return _0x3c70ba['FsNJS'](_0x4706ce,_0xc39dd1);}};continue;case'3':var _0x46f195=[],_0x4480a=[],_0x45b8b2=[];continue;case'4':_0x251275[_0x2d55('0x457')]((_0x315129,_0x3dd520)=>{_0x46f195['push']([_0x315129[0x0],_0x315129[0x1],_0x396dcb['MtmIC'](0x30d40,_0x3dd520),{'info':_0x3dd520}]),_0x4480a[_0x2d55('0x590')](_0x315129[0x1]),_0x45b8b2['push'](_0x315129[0x0]);});continue;}break;}},this[_0x2d55('0x25f')]=function(_0xd25080){_0xd25080[_0x2d55('0x3f7')]();},this[_0x2d55('0x721')]=function(_0x3273a3){_0x3273a3[_0x2d55('0x44d')]();},this[_0x2d55('0xd4')]=function(_0x84d31){_0x84d31[_0x2d55('0x837')]();},this['trajectorySpeed']=function(_0x87cc80,_0x314645=0x1,_0x3a015b=0x1f4){_0x87cc80[_0x2d55('0x4a9')](_0x3c70ba[_0x2d55('0x4b5')](_0x3a015b,_0x314645));},this[_0x2d55('0x169')]=function(_0x48b281){_0x48b281[_0x2d55('0x860')]();};}(),window[_0x2d55('0x380')][_0x2d55('0x784')]||(window[_0x2d55('0x380')][_0x2d55('0x784')]={}),window[_0x2d55('0x380')][_0x2d55('0x784')]['SvgFileToDraw']=new function(){var _0x5bd942={'heNQD':_0x2d55('0x23a'),'SMpVf':_0x2d55('0xfe'),'VCGfo':'path','uytiK':_0x2d55('0x1ae'),'FLhUf':'stroke','tCfqP':_0x2d55('0x1f0'),'gFSzQ':_0x2d55('0x6bc'),'SkEvC':function(_0x4af869,_0x1611f0){return _0x4af869<_0x1611f0;},'OkBdp':function(_0x37a930,_0x57e316){return _0x37a930(_0x57e316);},'UBwGR':function(_0x3103d9,_0x5d4b1d){return _0x3103d9+_0x5d4b1d;},'bKTVB':function(_0x298846,_0x157055){return _0x298846+_0x157055;},'IoExQ':function(_0x5cdf92,_0x1f04f6){return _0x5cdf92+_0x1f04f6;},'QRdHy':function(_0x1f7cd7,_0x5377b4){return _0x1f7cd7===_0x5377b4;},'dJgPX':function(_0x44d418,_0x9e6d37){return _0x44d418+_0x9e6d37;}};this[_0x2d55('0x3cb')]=function(_0x14df4c){var _0x300324={'name':_0x14df4c[_0x2d55('0x20e')],'icon':_0x14df4c['appPath'],'symbol':[],'id':_0x14df4c['id'],'type':_0x5bd942['heNQD']},_0x522b94=[],_0x3adafb=window[_0x2d55('0xcb')]['createElement']('li'),_0x16686f=(_0x3adafb['id']=_0x5bd942[_0x2d55('0x351')],_0x3adafb[_0x2d55('0x884')]=_0x14df4c['appPath'],document['body']['appendChild'](_0x3adafb),document[_0x2d55('0x4ed')]('mySvg')[_0x2d55('0x5ba')](_0x5bd942[_0x2d55('0x899')]));for(let _0x2a63e0=0x0;_0x2a63e0<_0x16686f['length'];_0x2a63e0++){var _0x59c6f0=window['getComputedStyle'](_0x16686f[_0x2a63e0]);let _0x335cfd='',_0x3b758b='',_0x17ca9f='';var _0x561bcd=_0x16686f[_0x2a63e0][_0x2d55('0x2ed')]('d');_0x335cfd=_0x59c6f0?_0x59c6f0[_0x2d55('0x67c')](_0x2d55('0x1ae')):_0x16686f[_0x2a63e0]['getAttribute'](_0x5bd942[_0x2d55('0x7f3')]),_0x3b758b=_0x59c6f0?_0x59c6f0[_0x2d55('0x67c')](_0x2d55('0x216')):_0x16686f[_0x2a63e0][_0x2d55('0x2ed')](_0x5bd942[_0x2d55('0x726')]),_0x17ca9f=_0x59c6f0?_0x59c6f0[_0x2d55('0x67c')](_0x5bd942[_0x2d55('0x41b')]):_0x16686f[_0x2a63e0][_0x2d55('0x2ed')](_0x5bd942['tCfqP']),_0x522b94[_0x2d55('0x590')]({'path':_0x561bcd,'fill':this['rgbToHex'](_0x335cfd)||_0x2d55('0x6bc'),'stroke-width':_0x17ca9f?_0x17ca9f[_0x2d55('0x77c')]('px')[0x0]:'2','stroke':this[_0x2d55('0x53d')](_0x3b758b)||_0x5bd942['gFSzQ'],'fill-opacity':_0x335cfd?0x1:0x0});}return _0x300324[_0x2d55('0x21c')]=_0x522b94,document[_0x2d55('0x12c')][_0x2d55('0x65d')](_0x3adafb),_0x300324;},this[_0x2d55('0x3b6')]=function(_0x23b68b){var _0x25ab28={'LNoHH':function(_0x2483c4,_0x12d496){return _0x2483c4===_0x12d496;}};let _0x33e2a4=[];return _0x23b68b&&_0x5bd942[_0x2d55('0x49')](0x0,_0x23b68b['length'])&&_0x23b68b[_0x2d55('0x457')](_0x558733=>{_0x25ab28['LNoHH']('3',_0x558733[_0x2d55('0x360')])&&(_0x558733=this[_0x2d55('0x3cb')](_0x558733),_0x33e2a4[_0x2d55('0x590')](_0x558733));}),_0x33e2a4;},this['svgToDraw']=function(_0x10945e,_0x3e94cd){_0x3e94cd[_0x2d55('0x60a')](_0x10945e['symbol']);},this[_0x2d55('0x53d')]=function(_0x33a7cd){var _0xb3efe0,_0xa3cd78,_0x33a7cd=_0x33a7cd[_0x2d55('0x2e1')](/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);return _0x33a7cd?(_0xb3efe0=_0x5bd942['OkBdp'](parseInt,_0x33a7cd[0x1]),_0xa3cd78=parseInt(_0x33a7cd[0x2]),_0x33a7cd=_0x5bd942[_0x2d55('0x5aa')](parseInt,_0x33a7cd[0x3]),_0x5bd942['UBwGR'](_0x5bd942[_0x2d55('0x81e')](_0x5bd942[_0x2d55('0x71f')]('#',this[_0x2d55('0x66c')](_0xb3efe0)),this[_0x2d55('0x66c')](_0xa3cd78)),this[_0x2d55('0x66c')](_0x33a7cd))):'';},this['toHex']=function(_0x1b1953){_0x1b1953=_0x1b1953['toString'](0x10);return _0x5bd942[_0x2d55('0x5fa')](0x1,_0x1b1953[_0x2d55('0x6e9')])?_0x5bd942['dJgPX']('0',_0x1b1953):_0x1b1953;};}(),window[_0x2d55('0x380')]||(window[_0x2d55('0x380')]={}),window['bdmap']['comp']||(window[_0x2d55('0x380')][_0x2d55('0x784')]={}),window[_0x2d55('0x380')][_0x2d55('0x3d9')]=new function(){var _0x234708={'sguWX':_0x2d55('0x3c7'),'YinGY':function(_0x3549a9,_0x5bb1e2){return _0x3549a9(_0x5bb1e2);},'HEQRT':'click','ThHxL':_0x2d55('0x6f5'),'NOXGq':_0x2d55('0x1ea'),'mdZRB':function(_0x2abf7d,_0x226e8d){return _0x2abf7d(_0x226e8d);},'qGVYn':'.maptalks-toolbar-hx','hUjhh':_0x2d55('0x0'),'ccrYT':_0x2d55('0x20d'),'qWqZO':_0x2d55('0x12c'),'ocHMe':'#toolbar-jtts','RMhdY':_0x2d55('0x7ed')};var _0x1d731f={};this[_0x2d55('0x1df')]=function(_0x991f67){if(bdmap['comp'][_0x2d55('0x2ae')][_0x2d55('0x337')](),_0x991f67[_0x2d55('0x43a')]&&($(_0x2d55('0x325'))[_0x2d55('0x3ec')](_0x234708[_0x2d55('0x826')]),_0x234708[_0x2d55('0x219')]($,'body')['on'](_0x234708[_0x2d55('0x60c')],_0x234708[_0x2d55('0x12b')],()=>{window['open'](_0x991f67['mapPrint'][_0x2d55('0x3a8')],_0x2d55('0x348'));})),!_0x991f67['autho'])throw new Error(_0x234708['NOXGq']);try{if(bdmap[_0x2d55('0x784')][_0x2d55('0x499')][_0x2d55('0x504')](_0x991f67[_0x2d55('0x241')]['url'],_0x991f67['autho'][_0x2d55('0x868')],_0x991f67[_0x2d55('0x241')]['password']),_0x991f67[_0x2d55('0x25a')]){_0x1d731f[_0x2d55('0x548')]=_0x991f67[_0x2d55('0x25a')],_0x234708[_0x2d55('0xfc')]($,_0x234708['qGVYn'])[_0x2d55('0x3ec')](_0x234708['hUjhh']);let _0x47fcf2=new BDLayers['Extend']['TBItemMapTraffic'](_0x234708[_0x2d55('0x2ea')],_0x991f67[_0x2d55('0x596')]);_0x234708['mdZRB']($,_0x234708[_0x2d55('0x1de')])['on'](_0x234708[_0x2d55('0x60c')],_0x234708[_0x2d55('0x83f')],()=>{_0x47fcf2[_0x2d55('0x1b7')](_0x991f67[_0x2d55('0x596')]);});}}catch(_0x9d289c){throw new Error(_0x234708[_0x2d55('0x182')]);}},this[_0x2d55('0x7ea')]=function(){return _0x1d731f;};}(),window[_0x2d55('0x380')]||(window[_0x2d55('0x380')]={}),window['bdmap'][_0x2d55('0x78')]=new function(){var _0x449be9={'XVCnn':function(_0x2f69c1,_0x3c5c3c){return _0x2f69c1<_0x3c5c3c;},'YNzPq':function(_0x45471d,_0xbe2741){return _0x45471d<_0xbe2741;}};var _0x2c210a=new HashMap();this['loadMainMap']=function(_0x40d269,_0x175899){_0x2c210a[_0x2d55('0x7bd')](_0x40d269)&&_0x2c210a[_0x2d55('0x860')](_0x40d269);_0x175899=new BDLayers['Lib'][(_0x2d55('0x729'))][(_0x2d55('0xeb'))](_0x40d269,_0x175899);_0x2c210a[_0x2d55('0x63c')](_0x40d269,{'map':_0x175899,'div':_0x40d269});},this['Animation']=maptalks[_0x2d55('0x5d1')]['Animation'],this[_0x2d55('0x654')]=function(_0x32d830){return new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x654'))](_0x32d830);},this[_0x2d55('0x21b')]=function(_0x501fed){return new maptalks[(_0x2d55('0x7bf'))]['Panel'](_0x501fed);},this[_0x2d55('0x30')]=function(_0x4bfd90,_0x4b5b75){return maptalks[_0x2d55('0x54c')]['fromJSON'](_0x4bfd90,_0x4b5b75);},this[_0x2d55('0x3a0')]=function(_0x5b1716){return maptalks[_0x2d55('0x404')][_0x2d55('0x3cf')](_0x5b1716);},this['GeometryFromJSON']=function(_0x52c5f2){return maptalks['Geometry'][_0x2d55('0x3cf')](_0x52c5f2);},this[_0x2d55('0x742')]=function(_0xf36d6a){return new maptalks[(_0x2d55('0x7bf'))][(_0x2d55('0x742'))](_0xf36d6a);},this[_0x2d55('0x3d')]=function(_0x531bf6){return _0x531bf6?_0x2c210a[_0x2d55('0x86')](_0x531bf6)[_0x2d55('0x700')]:_0x449be9['XVCnn'](0x0,_0x2c210a[_0x2d55('0x644')]()[_0x2d55('0x6e9')])?_0x2c210a[_0x2d55('0x644')]()[0x0][_0x2d55('0x700')]:void 0x0;},this[_0x2d55('0x77e')]=function(_0x2fd786){return _0x2fd786?_0x2c210a['get'](_0x2fd786)[_0x2d55('0x106')]:_0x449be9[_0x2d55('0x4cb')](0x0,_0x2c210a[_0x2d55('0x644')]()[_0x2d55('0x6e9')])?_0x2c210a['values']()[0x0][_0x2d55('0x106')]:void 0x0;};}(),window[_0x2d55('0x4e1')]||(window[_0x2d55('0x4e1')]={}),window[_0x2d55('0x4e1')][_0x2d55('0x4fc')]=info4dev[_0x2d55('0x4fc')];